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 @@
4498 <small data-i18n="Tags as Folders">Tags as Folders</small>4498 <small data-i18n="Tags as Folders">Tags as Folders</small>
4499 <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>4499 <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>
4500 </label>4500 </label>
45014501 <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>
4502 </div>4505 </div>
4503
4504
4505 </div>4506 </div>
4506 </div>4507 </div>
4507 <div name="UserSettingsSecondColumn" id="UI-Customization" class="flex-container flexFlowColumn wide100p flexNoGap flex1">4508 <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 () {
1576 await callGenericPopup(wrapper, POPUP_TYPE.TEXT, '', { wide: true, large: true });1576 await callGenericPopup(wrapper, POPUP_TYPE.TEXT, '', { wide: true, large: true });
1577 });1577 });
15781578
1579 $(document).on('click', 'body.documentstyle .mes .mes_text', function () {1579 $(document).on('click', 'body .mes .mes_text', function () {
1580 if (!power_user.click_to_edit) return;
1580 if (window.getSelection().toString()) return;1581 if (window.getSelection().toString()) return;
1581 if ($('.edit_textarea').length) return;1582 if ($('.edit_textarea').length) return;
1582 $(this).closest('.mes').find('.mes_edit').trigger('click');1583 $(this).closest('.mes').find('.mes_edit').trigger('click');
public/scripts/power-user.js+14 -0
@@ -320,6 +320,7 @@ let power_user = {
320 external_media_allowed_overrides: [],320 external_media_allowed_overrides: [],
321 external_media_forbidden_overrides: [],321 external_media_forbidden_overrides: [],
322 pin_styles: true,322 pin_styles: true,
323 click_to_edit: false,
323};324};
324325
325let themes = [];326let themes = [];
@@ -1322,6 +1323,12 @@ function applyTheme(name) {
1322 switchSwipeNumAllMessages();1323 switchSwipeNumAllMessages();
1323 },1324 },
1324 },1325 },
1326 {
1327 key: 'click_to_edit',
1328 action: () => {
1329 $('#click_to_edit').prop('checked', power_user.click_to_edit);
1330 },
1331 },
1325 ];1332 ];
13261333
1327 for (const { key, selector, type, action } of themeProperties) {1334 for (const { key, selector, type, action } of themeProperties) {
@@ -1647,6 +1654,7 @@ async function loadPowerUserSettings(settings, data) {
1647 $('#auto-load-chat-checkbox').prop('checked', power_user.auto_load_chat);1654 $('#auto-load-chat-checkbox').prop('checked', power_user.auto_load_chat);
1648 $('#forbid_external_media').prop('checked', power_user.forbid_external_media);1655 $('#forbid_external_media').prop('checked', power_user.forbid_external_media);
1649 $('#pin_styles').prop('checked', power_user.pin_styles);1656 $('#pin_styles').prop('checked', power_user.pin_styles);
1657 $('#click_to_edit').prop('checked', power_user.click_to_edit);
16501658
1651 for (const theme of themes) {1659 for (const theme of themes) {
1652 const option = document.createElement('option');1660 const option = document.createElement('option');
@@ -2379,6 +2387,7 @@ function getThemeObject(name) {
2379 reduced_motion: power_user.reduced_motion,2387 reduced_motion: power_user.reduced_motion,
2380 compact_input_area: power_user.compact_input_area,2388 compact_input_area: power_user.compact_input_area,
2381 show_swipe_num_all_messages: power_user.show_swipe_num_all_messages,2389 show_swipe_num_all_messages: power_user.show_swipe_num_all_messages,
2390 click_to_edit: power_user.click_to_edit,
2382 };2391 };
2383}2392}
23842393
@@ -3929,6 +3938,11 @@ $(document).ready(() => {
3929 applyStylePins();3938 applyStylePins();
3930 });3939 });
39313940
3941 $('#click_to_edit').on('input', function () {
3942 power_user.click_to_edit = !!$(this).prop('checked');
3943 saveSettingsDebounced();
3944 });
3945
3932 $('#ui_preset_import_button').on('click', function () {3946 $('#ui_preset_import_button').on('click', function () {
3933 $('#ui_preset_import_file').trigger('click');3947 $('#ui_preset_import_file').trigger('click');
3934 });3948 });