mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Merge pull request #3964 from SillyTavern/click-to-edit
Decouple "click to edit" from document mode
This commit is contained in:
@@ -1576,7 +1576,8 @@ jQuery(function () {
|
||||
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 ($('.edit_textarea').length) return;
|
||||
$(this).closest('.mes').find('.mes_edit').trigger('click');
|
||||
|
@@ -320,6 +320,7 @@ let power_user = {
|
||||
external_media_allowed_overrides: [],
|
||||
external_media_forbidden_overrides: [],
|
||||
pin_styles: true,
|
||||
click_to_edit: false,
|
||||
};
|
||||
|
||||
let themes = [];
|
||||
@@ -1322,6 +1323,12 @@ function applyTheme(name) {
|
||||
switchSwipeNumAllMessages();
|
||||
},
|
||||
},
|
||||
{
|
||||
key: 'click_to_edit',
|
||||
action: () => {
|
||||
$('#click_to_edit').prop('checked', power_user.click_to_edit);
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
for (const { key, selector, type, action } of themeProperties) {
|
||||
@@ -1452,6 +1459,10 @@ async function loadPowerUserSettings(settings, data) {
|
||||
const defaultStscript = JSON.parse(JSON.stringify(power_user.stscript));
|
||||
// Load from settings.json
|
||||
if (settings.power_user !== undefined) {
|
||||
// Migrate old preference to a new setting
|
||||
if (settings.power_user.click_to_edit === undefined && settings.power_user.chat_display === chat_styles.DOCUMENT) {
|
||||
settings.power_user.click_to_edit = true;
|
||||
}
|
||||
Object.assign(power_user, settings.power_user);
|
||||
}
|
||||
|
||||
@@ -1647,6 +1658,7 @@ async function loadPowerUserSettings(settings, data) {
|
||||
$('#auto-load-chat-checkbox').prop('checked', power_user.auto_load_chat);
|
||||
$('#forbid_external_media').prop('checked', power_user.forbid_external_media);
|
||||
$('#pin_styles').prop('checked', power_user.pin_styles);
|
||||
$('#click_to_edit').prop('checked', power_user.click_to_edit);
|
||||
|
||||
for (const theme of themes) {
|
||||
const option = document.createElement('option');
|
||||
@@ -2379,6 +2391,7 @@ function getThemeObject(name) {
|
||||
reduced_motion: power_user.reduced_motion,
|
||||
compact_input_area: power_user.compact_input_area,
|
||||
show_swipe_num_all_messages: power_user.show_swipe_num_all_messages,
|
||||
click_to_edit: power_user.click_to_edit,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -3929,6 +3942,11 @@ $(document).ready(() => {
|
||||
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_file').trigger('click');
|
||||
});
|
||||
|
Reference in New Issue
Block a user