Merge pull request #3964 from SillyTavern/click-to-edit Decouple "click to edit" from document mode
Signed| @@ -4508,10 +4508,11 @@ | |||
| 4508 | <small data-i18n="Tags as Folders">Tags as Folders</small> | 4508 | <small data-i18n="Tags as Folders">Tags as Folders</small> |
| 4509 | <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> | 4509 | <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> |
| 4510 | </label> | 4510 | </label> |
| 4511 | 4511 | <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."> | |
| 4512 | <input id="click_to_edit" type="checkbox" /> | ||
| 4513 | <small data-i18n="Click to Edit">Click to Edit</small> | ||
| 4514 | </label> | ||
| 4512 | </div> | 4515 | </div> |
| 4513 | |||
| 4514 | |||
| 4515 | </div> | 4516 | </div> |
| 4516 | </div> | 4517 | </div> |
| 4517 | <div name="UserSettingsSecondColumn" id="UI-Customization" class="flex-container flexFlowColumn wide100p flexNoGap flex1"> | 4518 | <div name="UserSettingsSecondColumn" id="UI-Customization" class="flex-container flexFlowColumn wide100p flexNoGap flex1"> |
| @@ -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 | }); |
| 1578 | 1578 | ||
| 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'); |
| @@ -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 | }; |
| 324 | 325 | ||
| 325 | let themes = []; | 326 | let 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 | ]; |
| 1326 | 1333 | ||
| 1327 | for (const { key, selector, type, action } of themeProperties) { | 1334 | for (const { key, selector, type, action } of themeProperties) { |
| @@ -1452,6 +1459,10 @@ async function loadPowerUserSettings(settings, data) { | |||
| 1452 | const defaultStscript = JSON.parse(JSON.stringify(power_user.stscript)); | 1459 | const defaultStscript = JSON.parse(JSON.stringify(power_user.stscript)); |
| 1453 | // Load from settings.json | 1460 | // Load from settings.json |
| 1454 | if (settings.power_user !== undefined) { | 1461 | if (settings.power_user !== undefined) { |
| 1462 | // Migrate old preference to a new setting | ||
| 1463 | if (settings.power_user.click_to_edit === undefined && settings.power_user.chat_display === chat_styles.DOCUMENT) { | ||
| 1464 | settings.power_user.click_to_edit = true; | ||
| 1465 | } | ||
| 1455 | Object.assign(power_user, settings.power_user); | 1466 | Object.assign(power_user, settings.power_user); |
| 1456 | } | 1467 | } |
| 1457 | 1468 | ||
| @@ -1647,6 +1658,7 @@ async function loadPowerUserSettings(settings, data) { | |||
| 1647 | $('#auto-load-chat-checkbox').prop('checked', power_user.auto_load_chat); | 1658 | $('#auto-load-chat-checkbox').prop('checked', power_user.auto_load_chat); |
| 1648 | $('#forbid_external_media').prop('checked', power_user.forbid_external_media); | 1659 | $('#forbid_external_media').prop('checked', power_user.forbid_external_media); |
| 1649 | $('#pin_styles').prop('checked', power_user.pin_styles); | 1660 | $('#pin_styles').prop('checked', power_user.pin_styles); |
| 1661 | $('#click_to_edit').prop('checked', power_user.click_to_edit); | ||
| 1650 | 1662 | ||
| 1651 | for (const theme of themes) { | 1663 | for (const theme of themes) { |
| 1652 | const option = document.createElement('option'); | 1664 | const option = document.createElement('option'); |
| @@ -2379,6 +2391,7 @@ function getThemeObject(name) { | |||
| 2379 | reduced_motion: power_user.reduced_motion, | 2391 | reduced_motion: power_user.reduced_motion, |
| 2380 | compact_input_area: power_user.compact_input_area, | 2392 | compact_input_area: power_user.compact_input_area, |
| 2381 | show_swipe_num_all_messages: power_user.show_swipe_num_all_messages, | 2393 | show_swipe_num_all_messages: power_user.show_swipe_num_all_messages, |
| 2394 | click_to_edit: power_user.click_to_edit, | ||
| 2382 | }; | 2395 | }; |
| 2383 | } | 2396 | } |
| 2384 | 2397 | ||
| @@ -3929,6 +3942,11 @@ $(document).ready(() => { | |||
| 3929 | applyStylePins(); | 3942 | applyStylePins(); |
| 3930 | }); | 3943 | }); |
| 3931 | 3944 | ||
| 3945 | $('#click_to_edit').on('input', function () { | ||
| 3946 | power_user.click_to_edit = !!$(this).prop('checked'); | ||
| 3947 | saveSettingsDebounced(); | ||
| 3948 | }); | ||
| 3949 | |||
| 3932 | $('#ui_preset_import_button').on('click', function () { | 3950 | $('#ui_preset_import_button').on('click', function () { |
| 3933 | $('#ui_preset_import_file').trigger('click'); | 3951 | $('#ui_preset_import_file').trigger('click'); |
| 3934 | }); | 3952 | }); |