mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
debugger
This commit is contained in:
@ -376,9 +376,26 @@ export class QuickReply {
|
|||||||
message.addEventListener('scroll', (evt)=>{
|
message.addEventListener('scroll', (evt)=>{
|
||||||
updateScrollDebounced();
|
updateScrollDebounced();
|
||||||
});
|
});
|
||||||
|
const removeBreakpoint = (bp)=>{
|
||||||
|
// start at -1 because "/" is not included in start-end
|
||||||
|
let start = bp.start - 1;
|
||||||
|
// step left until forward slash "/"
|
||||||
|
while (message.value[start] != '/') start--;
|
||||||
|
// step left while whitespace (except newline) before start
|
||||||
|
while (/[^\S\n]/.test(message.value[start - 1])) start--;
|
||||||
|
// if newline before indent, include the newline for removal
|
||||||
|
if (message.value[start - 1] == '\n') start--;
|
||||||
|
let end = bp.end;
|
||||||
|
// step right while whitespace
|
||||||
|
while (/\s/.test(message.value[end])) end++;
|
||||||
|
// if pipe after whitepace, include pipe for removal
|
||||||
|
if (message.value[end] == '|') end++;
|
||||||
|
const v = `${message.value.slice(0, start)}${message.value.slice(end)}`;
|
||||||
|
message.value = v;
|
||||||
|
message.dispatchEvent(new Event('input', { bubbles:true }));
|
||||||
|
};
|
||||||
message.addEventListener('pointerup', async(evt)=>{
|
message.addEventListener('pointerup', async(evt)=>{
|
||||||
if (!evt.ctrlKey) return;
|
if (!evt.ctrlKey) return;
|
||||||
const selIdx = message.selectionStart;
|
|
||||||
const parser = new SlashCommandParser();
|
const parser = new SlashCommandParser();
|
||||||
parser.parse(message.value, false);
|
parser.parse(message.value, false);
|
||||||
const cmdIdx = parser.commandIndex.findLastIndex(it=>it.start <= message.selectionStart && it.end >= message.selectionStart);
|
const cmdIdx = parser.commandIndex.findLastIndex(it=>it.start <= message.selectionStart && it.end >= message.selectionStart);
|
||||||
@ -386,40 +403,10 @@ export class QuickReply {
|
|||||||
const cmd = parser.commandIndex[cmdIdx];
|
const cmd = parser.commandIndex[cmdIdx];
|
||||||
if (cmd instanceof SlashCommandBreakPoint) {
|
if (cmd instanceof SlashCommandBreakPoint) {
|
||||||
const bp = cmd;
|
const bp = cmd;
|
||||||
// start at -1 because "/" is not included in start-end
|
removeBreakpoint(bp);
|
||||||
let start = bp.start - 1;
|
|
||||||
// step left until forward slash "/"
|
|
||||||
while (message.value[start] != '/') start--;
|
|
||||||
// step left while whitespace (except newline) before start
|
|
||||||
while (/[^\S\n]/.test(message.value[start - 1])) start--;
|
|
||||||
// if newline before indent, include the newline for removal
|
|
||||||
if (message.value[start - 1] == '\n') start--;
|
|
||||||
let end = bp.end;
|
|
||||||
// step right while whitespace
|
|
||||||
while (/\s/.test(message.value[end])) end++;
|
|
||||||
// if pipe after whitepace, include pipe for removal
|
|
||||||
if (message.value[end ] == '|') end++;
|
|
||||||
const v = `${message.value.slice(0, start)}${message.value.slice(end)}`;
|
|
||||||
message.value = v;
|
|
||||||
message.dispatchEvent(new Event('input', { bubbles:true }));
|
|
||||||
} else if (parser.commandIndex[cmdIdx - 1] instanceof SlashCommandBreakPoint) {
|
} else if (parser.commandIndex[cmdIdx - 1] instanceof SlashCommandBreakPoint) {
|
||||||
const bp = parser.commandIndex[cmdIdx - 1];
|
const bp = parser.commandIndex[cmdIdx - 1];
|
||||||
// start at -1 because "/" is not included in start-end
|
removeBreakpoint(bp);
|
||||||
let start = bp.start - 1;
|
|
||||||
// step left until forward slash "/"
|
|
||||||
while (message.value[start] != '/') start--;
|
|
||||||
// step left while whitespace (except newline) before start
|
|
||||||
while (/[^\S\n]/.test(message.value[start - 1])) start--;
|
|
||||||
// if newline before indent, include the newline for removal
|
|
||||||
if (message.value[start - 1] == '\n') start--;
|
|
||||||
let end = bp.end;
|
|
||||||
// step right while whitespace
|
|
||||||
while (/\s/.test(message.value[end])) end++;
|
|
||||||
// if pipe after whitepace, include pipe for removal
|
|
||||||
if (message.value[end] == '|') end++;
|
|
||||||
const v = `${message.value.slice(0, start)}${message.value.slice(end)}`;
|
|
||||||
message.value = v;
|
|
||||||
message.dispatchEvent(new Event('input', { bubbles:true }));
|
|
||||||
} else {
|
} else {
|
||||||
// start at -1 because "/" is not included in start-end
|
// start at -1 because "/" is not included in start-end
|
||||||
let start = cmd.start - 1;
|
let start = cmd.start - 1;
|
||||||
|
Reference in New Issue
Block a user