Add /popup command
This commit is contained in:
parent
4fd68e5be7
commit
851a00630a
|
@ -174,6 +174,7 @@ parser.addCommand('input', inputCallback, ['prompt'], '<span class="monospace">(
|
||||||
parser.addCommand('run', runCallback, ['call', 'exec'], '<span class="monospace">(QR label)</span> – runs a Quick Reply with the specified name from the current preset.', true, true);
|
parser.addCommand('run', runCallback, ['call', 'exec'], '<span class="monospace">(QR label)</span> – runs a Quick Reply with the specified name from the current preset.', true, true);
|
||||||
parser.addCommand('messages', getMessagesCallback, ['message'], '<span class="monospace">(names=off/on [message index or range])</span> – returns the specified message or range of messages as a string.', true, true);
|
parser.addCommand('messages', getMessagesCallback, ['message'], '<span class="monospace">(names=off/on [message index or range])</span> – returns the specified message or range of messages as a string.', true, true);
|
||||||
parser.addCommand('setinput', setInputCallback, [], '<span class="monospace">(text)</span> – sets the user input to the specified text and passes it to the next command through the pipe.', true, true);
|
parser.addCommand('setinput', setInputCallback, [], '<span class="monospace">(text)</span> – sets the user input to the specified text and passes it to the next command through the pipe.', true, true);
|
||||||
|
parser.addCommand('popup', popupCallback, [], '<span class="monospace">(text)</span> – shows a blocking popup with the specified text.', true, true);
|
||||||
registerVariableCommands();
|
registerVariableCommands();
|
||||||
|
|
||||||
const NARRATOR_NAME_KEY = 'narrator_name';
|
const NARRATOR_NAME_KEY = 'narrator_name';
|
||||||
|
@ -185,6 +186,14 @@ function setInputCallback(_, value) {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function popupCallback(_, value) {
|
||||||
|
const safeValue = DOMPurify.sanitize(value || '');
|
||||||
|
await delay(1);
|
||||||
|
await callPopup(safeValue, 'text');
|
||||||
|
await delay(1);
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
function getMessagesCallback(args, value) {
|
function getMessagesCallback(args, value) {
|
||||||
const includeNames = !isFalseBoolean(args?.names);
|
const includeNames = !isFalseBoolean(args?.names);
|
||||||
const range = stringToRange(value, 0, chat.length - 1);
|
const range = stringToRange(value, 0, chat.length - 1);
|
||||||
|
|
Loading…
Reference in New Issue