Merge pull request #3964 from SillyTavern/click-to-edit Decouple "click to edit" from document mode

b71b94d4105a2a92fe4800223693d403a0c6e2b8

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

Signed
3 files changed, +24 -4Showing whitespace changes
public/index.html+4 -3
@@ -4508,10 +4508,11 @@
45084508 <small data-i18n="Tags as Folders">Tags as Folders</small>
45094509 <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>
45104510 </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>
45124515 </div>
4513-
4514-
45154516 </div>
45164517 </div>
45174518 <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+18 -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) {
@@ -1452,6 +1459,10 @@ async function loadPowerUserSettings(settings, data) {
14521459 const defaultStscript = JSON.parse(JSON.stringify(power_user.stscript));
14531460 // Load from settings.json
14541461 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+ }
14551466 Object.assign(power_user, settings.power_user);
14561467 }
14571468
@@ -1647,6 +1658,7 @@ async function loadPowerUserSettings(settings, data) {
16471658 $('#auto-load-chat-checkbox').prop('checked', power_user.auto_load_chat);
16481659 $('#forbid_external_media').prop('checked', power_user.forbid_external_media);
16491660 $('#pin_styles').prop('checked', power_user.pin_styles);
1661+ $('#click_to_edit').prop('checked', power_user.click_to_edit);
16501662
16511663 for (const theme of themes) {
16521664 const option = document.createElement('option');
@@ -2379,6 +2391,7 @@ function getThemeObject(name) {
23792391 reduced_motion: power_user.reduced_motion,
23802392 compact_input_area: power_user.compact_input_area,
23812393 show_swipe_num_all_messages: power_user.show_swipe_num_all_messages,
2394+ click_to_edit: power_user.click_to_edit,
23822395 };
23832396}
23842397
@@ -3929,6 +3942,11 @@ $(document).ready(() => {
39293942 applyStylePins();
39303943 });
39313944
3945+ $('#click_to_edit').on('input', function () {
3946+ power_user.click_to_edit = !!$(this).prop('checked');
3947+ saveSettingsDebounced();
3948+ });
3949+
39323950 $('#ui_preset_import_button').on('click', function () {
39333951 $('#ui_preset_import_file').trigger('click');
39343952 });