Decouple "click to edit" from document mode

This commit is contained in:
Cohee
2025-05-06 22:02:20 +03:00
parent 0f1bb766f6
commit 5e31a21d8d
3 changed files with 20 additions and 4 deletions

View File

@ -4498,10 +4498,11 @@
<small data-i18n="Tags as Folders">Tags as Folders</small> <small data-i18n="Tags as Folders">Tags as Folders</small>
<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> <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>
</label> </label>
<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.">
<input id="click_to_edit" type="checkbox" />
<small data-i18n="Click to Edit">Click to Edit</small>
</label>
</div> </div>
</div> </div>
</div> </div>
<div name="UserSettingsSecondColumn" id="UI-Customization" class="flex-container flexFlowColumn wide100p flexNoGap flex1"> <div name="UserSettingsSecondColumn" id="UI-Customization" class="flex-container flexFlowColumn wide100p flexNoGap flex1">

View File

@ -1576,7 +1576,8 @@ jQuery(function () {
await callGenericPopup(wrapper, POPUP_TYPE.TEXT, '', { wide: true, large: true }); await callGenericPopup(wrapper, POPUP_TYPE.TEXT, '', { wide: true, large: true });
}); });
$(document).on('click', 'body.documentstyle .mes .mes_text', function () { $(document).on('click', 'body .mes .mes_text', function () {
if (!power_user.click_to_edit) return;
if (window.getSelection().toString()) return; if (window.getSelection().toString()) return;
if ($('.edit_textarea').length) return; if ($('.edit_textarea').length) return;
$(this).closest('.mes').find('.mes_edit').trigger('click'); $(this).closest('.mes').find('.mes_edit').trigger('click');

View File

@ -320,6 +320,7 @@ let power_user = {
external_media_allowed_overrides: [], external_media_allowed_overrides: [],
external_media_forbidden_overrides: [], external_media_forbidden_overrides: [],
pin_styles: true, pin_styles: true,
click_to_edit: false,
}; };
let themes = []; let themes = [];
@ -1322,6 +1323,12 @@ function applyTheme(name) {
switchSwipeNumAllMessages(); switchSwipeNumAllMessages();
}, },
}, },
{
key: 'click_to_edit',
action: () => {
$('#click_to_edit').prop('checked', power_user.click_to_edit);
},
},
]; ];
for (const { key, selector, type, action } of themeProperties) { for (const { key, selector, type, action } of themeProperties) {
@ -1647,6 +1654,7 @@ async function loadPowerUserSettings(settings, data) {
$('#auto-load-chat-checkbox').prop('checked', power_user.auto_load_chat); $('#auto-load-chat-checkbox').prop('checked', power_user.auto_load_chat);
$('#forbid_external_media').prop('checked', power_user.forbid_external_media); $('#forbid_external_media').prop('checked', power_user.forbid_external_media);
$('#pin_styles').prop('checked', power_user.pin_styles); $('#pin_styles').prop('checked', power_user.pin_styles);
$('#click_to_edit').prop('checked', power_user.click_to_edit);
for (const theme of themes) { for (const theme of themes) {
const option = document.createElement('option'); const option = document.createElement('option');
@ -2379,6 +2387,7 @@ function getThemeObject(name) {
reduced_motion: power_user.reduced_motion, reduced_motion: power_user.reduced_motion,
compact_input_area: power_user.compact_input_area, compact_input_area: power_user.compact_input_area,
show_swipe_num_all_messages: power_user.show_swipe_num_all_messages, show_swipe_num_all_messages: power_user.show_swipe_num_all_messages,
click_to_edit: power_user.click_to_edit,
}; };
} }
@ -3929,6 +3938,11 @@ $(document).ready(() => {
applyStylePins(); applyStylePins();
}); });
$('#click_to_edit').on('input', function () {
power_user.click_to_edit = !!$(this).prop('checked');
saveSettingsDebounced();
});
$('#ui_preset_import_button').on('click', function () { $('#ui_preset_import_button').on('click', function () {
$('#ui_preset_import_file').trigger('click'); $('#ui_preset_import_file').trigger('click');
}); });