mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Add escapeHtml arg to /echo
This commit is contained in:
@ -805,7 +805,14 @@ export function initDefaultSlashCommands() {
|
|||||||
SlashCommandNamedArgument.fromProps({
|
SlashCommandNamedArgument.fromProps({
|
||||||
name: 'color',
|
name: 'color',
|
||||||
description: 'custom CSS color of the toast message. Accepts all valid CSS color values (e.g. \'red\', \'#FF0000\', \'rgb(255, 0, 0)\').<br />>Can be more customizable with the \'cssClass\' argument and custom classes.',
|
description: 'custom CSS color of the toast message. Accepts all valid CSS color values (e.g. \'red\', \'#FF0000\', \'rgb(255, 0, 0)\').<br />>Can be more customizable with the \'cssClass\' argument and custom classes.',
|
||||||
})
|
}),
|
||||||
|
SlashCommandNamedArgument.fromProps({
|
||||||
|
name: 'escapeHtml',
|
||||||
|
description: 'whether to escape HTML in the toast message.',
|
||||||
|
typeList: [ARGUMENT_TYPE.BOOLEAN],
|
||||||
|
defaultValue: 'true',
|
||||||
|
enumList: commonEnumProviders.boolean('trueFalse')(),
|
||||||
|
}),
|
||||||
],
|
],
|
||||||
unnamedArgumentList: [
|
unnamedArgumentList: [
|
||||||
new SlashCommandArgument(
|
new SlashCommandArgument(
|
||||||
@ -2190,7 +2197,7 @@ async function generateCallback(args, value) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param {{title?: string, severity?: string, timeout?: string, extendedTimeout?: string, preventDuplicates?: string, awaitDismissal?: string, cssClass?: string, color?: string}} args - named arguments from the slash command
|
* @param {{title?: string, severity?: string, timeout?: string, extendedTimeout?: string, preventDuplicates?: string, awaitDismissal?: string, cssClass?: string, color?: string, escapeHtml?: string}} args - named arguments from the slash command
|
||||||
* @param {string} value - The string to echo (unnamed argument from the slash command)
|
* @param {string} value - The string to echo (unnamed argument from the slash command)
|
||||||
* @returns {Promise<string>} The text that was echoed
|
* @returns {Promise<string>} The text that was echoed
|
||||||
*/
|
*/
|
||||||
@ -2217,6 +2224,8 @@ async function echoCallback(args, value) {
|
|||||||
if (args.timeout && !isNaN(parseInt(args.timeout))) options.timeOut = parseInt(args.timeout);
|
if (args.timeout && !isNaN(parseInt(args.timeout))) options.timeOut = parseInt(args.timeout);
|
||||||
if (args.extendedTimeout && !isNaN(parseInt(args.extendedTimeout))) options.extendedTimeOut = parseInt(args.extendedTimeout);
|
if (args.extendedTimeout && !isNaN(parseInt(args.extendedTimeout))) options.extendedTimeOut = parseInt(args.extendedTimeout);
|
||||||
if (isTrueBoolean(args.preventDuplicates)) options.preventDuplicates = true;
|
if (isTrueBoolean(args.preventDuplicates)) options.preventDuplicates = true;
|
||||||
|
if (args.cssClass) options.toastClass = args.cssClass;
|
||||||
|
if (args.escapeHtml !== undefined) options.escapeHtml = isTrueBoolean(args.escapeHtml);
|
||||||
|
|
||||||
// Prepare possible await handling
|
// Prepare possible await handling
|
||||||
let awaitDismissal = isTrueBoolean(args.awaitDismissal);
|
let awaitDismissal = isTrueBoolean(args.awaitDismissal);
|
||||||
@ -2226,10 +2235,6 @@ async function echoCallback(args, value) {
|
|||||||
options.onHidden = () => resolveToastDismissal(value);
|
options.onHidden = () => resolveToastDismissal(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.cssClass) {
|
|
||||||
options.toastClass = args.cssClass;
|
|
||||||
}
|
|
||||||
|
|
||||||
let toast;
|
let toast;
|
||||||
switch (severity) {
|
switch (severity) {
|
||||||
case 'error':
|
case 'error':
|
||||||
|
Reference in New Issue
Block a user