mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-02-22 15:07:42 +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 (this.isExecuting) return;
|
||||||
if (evt.key == 'Tab' && !evt.shiftKey && !evt.ctrlKey && !evt.altKey) {
|
if (evt.key == 'Tab' && !evt.shiftKey && !evt.ctrlKey && !evt.altKey) {
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
evt.stopImmediatePropagation();
|
|
||||||
evt.stopPropagation();
|
|
||||||
const start = message.selectionStart;
|
const start = message.selectionStart;
|
||||||
const end = message.selectionEnd;
|
const end = message.selectionEnd;
|
||||||
if (end - start > 0 && message.value.substring(start, end).includes('\n')) {
|
if (end - start > 0 && message.value.substring(start, end).includes('\n')) {
|
||||||
|
evt.stopImmediatePropagation();
|
||||||
|
evt.stopPropagation();
|
||||||
const lineStart = message.value.lastIndexOf('\n', start - 1);
|
const lineStart = message.value.lastIndexOf('\n', start - 1);
|
||||||
const count = message.value.substring(lineStart, end).split('\n').length - 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.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.selectionStart = start + 1;
|
||||||
message.selectionEnd = end + count;
|
message.selectionEnd = end + count;
|
||||||
updateSyntax();
|
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.value = `${message.value.substring(0, start)}\t${message.value.substring(end)}`;
|
||||||
message.selectionStart = start + 1;
|
message.selectionStart = start + 1;
|
||||||
message.selectionEnd = end + 1;
|
message.selectionEnd = end + 1;
|
||||||
@ -357,7 +359,7 @@ export class QuickReply {
|
|||||||
message.selectionStart = start - 1;
|
message.selectionStart = start - 1;
|
||||||
message.selectionEnd = end - count;
|
message.selectionEnd = end - count;
|
||||||
updateSyntax();
|
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.stopImmediatePropagation();
|
||||||
evt.stopPropagation();
|
evt.stopPropagation();
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
@ -389,7 +391,7 @@ export class QuickReply {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
setSlashCommandAutoComplete(message, true);
|
const ac = await setSlashCommandAutoComplete(message, true);
|
||||||
message.addEventListener('wheel', (evt)=>{
|
message.addEventListener('wheel', (evt)=>{
|
||||||
updateScrollDebounced(evt);
|
updateScrollDebounced(evt);
|
||||||
});
|
});
|
||||||
|
@ -3507,6 +3507,7 @@ async function executeSlashCommands(text, handleParserErrors = true, scope = nul
|
|||||||
*
|
*
|
||||||
* @param {HTMLTextAreaElement} textarea The textarea to receive autocomplete
|
* @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)
|
* @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) {
|
export async function setSlashCommandAutoComplete(textarea, isFloating = false) {
|
||||||
function canUseNegativeLookbehind() {
|
function canUseNegativeLookbehind() {
|
||||||
@ -3530,6 +3531,7 @@ export async function setSlashCommandAutoComplete(textarea, isFloating = false)
|
|||||||
async (text, index) => await parser.getNameAt(text, index),
|
async (text, index) => await parser.getNameAt(text, index),
|
||||||
isFloating,
|
isFloating,
|
||||||
);
|
);
|
||||||
|
return ac;
|
||||||
}
|
}
|
||||||
/**@type {HTMLTextAreaElement} */
|
/**@type {HTMLTextAreaElement} */
|
||||||
const sendTextarea = document.querySelector('#send_textarea');
|
const sendTextarea = document.querySelector('#send_textarea');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user