Decouple "click to edit" from document mode

5e31a21d8d8ff964370272b0896ee569f9a1a93e

Cohee <18619528+Cohee1207@users.noreply.github.com>

3 files changed, +20 -4Showing whitespace changes
public/index.html+4 -3
@@ -4498,10 +4498,11 @@
44984498 <small data-i18n="Tags as Folders">Tags as Folders</small>
44994499 <i title="Recent change: Tags must be marked as folders in the Tag Management menu to appear as such. Click here to bring it up." data-i18n="[title]Tags_as_Folders_desc" class="tags_view right_menu_button fa-solid fa-circle-exclamation"></i>
45004500 </label>
4501-
4501+ <label for="click_to_edit" class="checkbox_label" title="Click the message text in the chat log to edit it." data-i18n="[title]Click the message text in the chat log to edit it.">
4502+ <input id="click_to_edit" type="checkbox" />
4503+ <small data-i18n="Click to Edit">Click to Edit</small>
4504+ </label>
45024505 </div>
4503-
4504-
45054506 </div>
45064507 </div>
45074508 <div name="UserSettingsSecondColumn" id="UI-Customization" class="flex-container flexFlowColumn wide100p flexNoGap flex1">
public/scripts/chats.js+2 -1
@@ -1576,7 +1576,8 @@ jQuery(function () {
15761576 await callGenericPopup(wrapper, POPUP_TYPE.TEXT, '', { wide: true, large: true });
15771577 });
15781578
15791579 $(document).on('click', 'body.documentstyle .mes .mes_text', function () {
1580+ if (!power_user.click_to_edit) return;
15801581 if (window.getSelection().toString()) return;
15811582 if ($('.edit_textarea').length) return;
15821583 $(this).closest('.mes').find('.mes_edit').trigger('click');
public/scripts/power-user.js+14 -0
@@ -320,6 +320,7 @@ let power_user = {
320320 external_media_allowed_overrides: [],
321321 external_media_forbidden_overrides: [],
322322 pin_styles: true,
323+ click_to_edit: false,
323324};
324325
325326let themes = [];
@@ -1322,6 +1323,12 @@ function applyTheme(name) {
13221323 switchSwipeNumAllMessages();
13231324 },
13241325 },
1326+ {
1327+ key: 'click_to_edit',
1328+ action: () => {
1329+ $('#click_to_edit').prop('checked', power_user.click_to_edit);
1330+ },
1331+ },
13251332 ];
13261333
13271334 for (const { key, selector, type, action } of themeProperties) {
@@ -1647,6 +1654,7 @@ async function loadPowerUserSettings(settings, data) {
16471654 $('#auto-load-chat-checkbox').prop('checked', power_user.auto_load_chat);
16481655 $('#forbid_external_media').prop('checked', power_user.forbid_external_media);
16491656 $('#pin_styles').prop('checked', power_user.pin_styles);
1657+ $('#click_to_edit').prop('checked', power_user.click_to_edit);
16501658
16511659 for (const theme of themes) {
16521660 const option = document.createElement('option');
@@ -2379,6 +2387,7 @@ function getThemeObject(name) {
23792387 reduced_motion: power_user.reduced_motion,
23802388 compact_input_area: power_user.compact_input_area,
23812389 show_swipe_num_all_messages: power_user.show_swipe_num_all_messages,
2390+ click_to_edit: power_user.click_to_edit,
23822391 };
23832392}
23842393
@@ -3929,6 +3938,11 @@ $(document).ready(() => {
39293938 applyStylePins();
39303939 });
39313940
3941+ $('#click_to_edit').on('input', function () {
3942+ power_user.click_to_edit = !!$(this).prop('checked');
3943+ saveSettingsDebounced();
3944+ });
3945+
39323946 $('#ui_preset_import_button').on('click', function () {
39333947 $('#ui_preset_import_file').trigger('click');
39343948 });