mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Markdown hotkeys for textareas (#2800)
* initial commit * dont hijack all ctrl keybinds * change strikethrough bind, convert to subscribable class, target key textareas * better early return, hotkey reversiblility * possible undo solution, key checks to switch * execCommand alternate, perfect Undo * format full word when caret is in the middle of a word * double backticks do nothing, dummy. * ctrl+K for ....'K'ode snippet... * remove console logs * Add new hotkeys to help * Allow hotkeys in message edit textarea * add markdown hotkey help text * help text addition to mention hotkeys work in message edits * add markdown hotkeys to WI entry content box * disengage if alt/win pressed, universal prevent default * disengage if shiftKey pressed * re-allow shift for one special case * add MD hotkeys toggle in user settings * add markdown enabled icon on relevant textareas when appropriate * Add icon to help * Uniform formatting * Add opacity to icon --------- Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>
This commit is contained in:
@ -200,6 +200,7 @@ let power_user = {
|
||||
relaxed_api_urls: false,
|
||||
world_import_dialog: true,
|
||||
enable_auto_select_input: false,
|
||||
enable_md_hotkeys: false,
|
||||
tag_import_setting: tag_import_setting.ASK,
|
||||
disable_group_trimming: false,
|
||||
single_line: false,
|
||||
@ -1452,6 +1453,7 @@ async function loadPowerUserSettings(settings, data) {
|
||||
$('#relaxed_api_urls').prop('checked', power_user.relaxed_api_urls);
|
||||
$('#world_import_dialog').prop('checked', power_user.world_import_dialog);
|
||||
$('#enable_auto_select_input').prop('checked', power_user.enable_auto_select_input);
|
||||
$('#enable_md_hotkeys').prop('checked', power_user.enable_md_hotkeys);
|
||||
$('#trim_spaces').prop('checked', power_user.trim_spaces);
|
||||
$('#continue_on_send').prop('checked', power_user.continue_on_send);
|
||||
$('#quick_continue').prop('checked', power_user.quick_continue);
|
||||
@ -1601,6 +1603,17 @@ async function loadPowerUserSettings(settings, data) {
|
||||
switchSpoilerMode();
|
||||
loadMovingUIState();
|
||||
loadCharListState();
|
||||
toggleMDHotkeyIconDisplay();
|
||||
}
|
||||
|
||||
function toggleMDHotkeyIconDisplay() {
|
||||
if (power_user.enable_md_hotkeys) {
|
||||
$('.mdhotkey_location').each(function () {
|
||||
$(this).parent().append('<i class="fa-brands fa-markdown mdhotkey_icon"></i>');
|
||||
});
|
||||
} else {
|
||||
$('.mdhotkey_icon').remove();
|
||||
}
|
||||
}
|
||||
|
||||
function loadCharListState() {
|
||||
@ -3610,6 +3623,13 @@ $(document).ready(() => {
|
||||
saveSettingsDebounced();
|
||||
});
|
||||
|
||||
$('#enable_md_hotkeys').on('input', function () {
|
||||
const value = !!$(this).prop('checked');
|
||||
power_user.enable_md_hotkeys = value;
|
||||
toggleMDHotkeyIconDisplay();
|
||||
saveSettingsDebounced();
|
||||
});
|
||||
|
||||
$('#spoiler_free_mode').on('input', function () {
|
||||
power_user.spoiler_free_mode = !!$(this).prop('checked');
|
||||
switchSpoilerMode();
|
||||
|
Reference in New Issue
Block a user