mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-02-21 22:47:41 +01:00
fix key conflicts in QR editor
This commit is contained in:
parent
490b2004b7
commit
0fc9b11adf
@ -328,18 +328,20 @@ export class QuickReply {
|
||||
if (this.isExecuting) return;
|
||||
if (evt.key == 'Tab' && !evt.shiftKey && !evt.ctrlKey && !evt.altKey) {
|
||||
evt.preventDefault();
|
||||
evt.stopImmediatePropagation();
|
||||
evt.stopPropagation();
|
||||
const start = message.selectionStart;
|
||||
const end = message.selectionEnd;
|
||||
if (end - start > 0 && message.value.substring(start, end).includes('\n')) {
|
||||
evt.stopImmediatePropagation();
|
||||
evt.stopPropagation();
|
||||
const lineStart = message.value.lastIndexOf('\n', start - 1);
|
||||
const count = message.value.substring(lineStart, end).split('\n').length - 1;
|
||||
message.value = `${message.value.substring(0, lineStart)}${message.value.substring(lineStart, end).replace(/\n/g, '\n\t')}${message.value.substring(end)}`;
|
||||
message.selectionStart = start + 1;
|
||||
message.selectionEnd = end + count;
|
||||
updateSyntax();
|
||||
} else {
|
||||
} else if (!(ac.isReplaceable && ac.isActive)) {
|
||||
evt.stopImmediatePropagation();
|
||||
evt.stopPropagation();
|
||||
message.value = `${message.value.substring(0, start)}\t${message.value.substring(end)}`;
|
||||
message.selectionStart = start + 1;
|
||||
message.selectionEnd = end + 1;
|
||||
@ -357,7 +359,7 @@ export class QuickReply {
|
||||
message.selectionStart = start - 1;
|
||||
message.selectionEnd = end - count;
|
||||
updateSyntax();
|
||||
} else if (evt.key == 'Enter' && !evt.ctrlKey && !evt.shiftKey && !evt.altKey) {
|
||||
} else if (evt.key == 'Enter' && !evt.ctrlKey && !evt.shiftKey && !evt.altKey && !(ac.isReplaceable && ac.isActive)) {
|
||||
evt.stopImmediatePropagation();
|
||||
evt.stopPropagation();
|
||||
evt.preventDefault();
|
||||
@ -389,7 +391,7 @@ export class QuickReply {
|
||||
}
|
||||
}
|
||||
});
|
||||
setSlashCommandAutoComplete(message, true);
|
||||
const ac = await setSlashCommandAutoComplete(message, true);
|
||||
message.addEventListener('wheel', (evt)=>{
|
||||
updateScrollDebounced(evt);
|
||||
});
|
||||
|
@ -3507,6 +3507,7 @@ async function executeSlashCommands(text, handleParserErrors = true, scope = nul
|
||||
*
|
||||
* @param {HTMLTextAreaElement} textarea The textarea to receive autocomplete
|
||||
* @param {Boolean} isFloating Whether to show the auto complete as a floating window (e.g., large QR editor)
|
||||
* @returns {Promise<AutoComplete>}
|
||||
*/
|
||||
export async function setSlashCommandAutoComplete(textarea, isFloating = false) {
|
||||
function canUseNegativeLookbehind() {
|
||||
@ -3530,6 +3531,7 @@ export async function setSlashCommandAutoComplete(textarea, isFloating = false)
|
||||
async (text, index) => await parser.getNameAt(text, index),
|
||||
isFloating,
|
||||
);
|
||||
return ac;
|
||||
}
|
||||
/**@type {HTMLTextAreaElement} */
|
||||
const sendTextarea = document.querySelector('#send_textarea');
|
||||
|
Loading…
x
Reference in New Issue
Block a user