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:
RossAscends
2024-09-14 20:16:26 +09:00
committed by GitHub
parent bbb0391459
commit b376ea884b
6 changed files with 229 additions and 26 deletions

View File

@ -242,6 +242,7 @@ import { INTERACTABLE_CONTROL_CLASS, initKeyboard } from './scripts/keyboard.js'
import { initDynamicStyles } from './scripts/dynamic-styles.js';
import { SlashCommandEnumValue, enumTypes } from './scripts/slash-commands/SlashCommandEnumValue.js';
import { commonEnumProviders, enumIcons } from './scripts/slash-commands/SlashCommandCommonEnumsProvider.js';
import { initInputMarkdown } from './scripts/input-md-formatting.js';
import { AbortReason } from './scripts/util/AbortReason.js';
//exporting functions and vars for mods
@ -951,6 +952,7 @@ async function firstLoadInit() {
initStats();
initCfg();
initLogprobs();
initInputMarkdown();
doDailyExtensionUpdatesCheck();
await hideLoader();
await fixViewport();
@ -10200,7 +10202,7 @@ jQuery(async function () {
.closest('.mes_block')
.find('.mes_text')
.append(
'<textarea id=\'curEditTextarea\' class=\'edit_textarea\' style=\'max-width:auto;\'></textarea>',
'<textarea id=\'curEditTextarea\' class=\'edit_textarea mdHotkeys\' style=\'max-width:auto;\'></textarea>',
);
$('#curEditTextarea').val(text);
let edit_textarea = $(this)