Add escapeHtml arg to /echo

885a0145073f56e6ef811dfeaaa11e386f1a97af

Wolfsblvt <wolfsblvt@gmail.com>

1 files changed, +11 -6Ignore whitespace
public/scripts/slash-commands.js+11 -6
@@ -805,7 +805,14 @@ export function initDefaultSlashCommands() {
805805 SlashCommandNamedArgument.fromProps({
806806 name: 'color',
807807 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.',
808808 }),
809+ SlashCommandNamedArgument.fromProps({
810+ name: 'escapeHtml',
811+ description: 'whether to escape HTML in the toast message.',
812+ typeList: [ARGUMENT_TYPE.BOOLEAN],
813+ defaultValue: 'true',
814+ enumList: commonEnumProviders.boolean('trueFalse')(),
815+ }),
809816 ],
810817 unnamedArgumentList: [
811818 new SlashCommandArgument(
@@ -2190,7 +2197,7 @@ async function generateCallback(args, value) {
21902197
21912198/**
21922199 *
21932200 * @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
21942201 * @param {string} value - The string to echo (unnamed argument from the slash command)
21952202 * @returns {Promise<string>} The text that was echoed
21962203 */
@@ -2217,6 +2224,8 @@ async function echoCallback(args, value) {
22172224 if (args.timeout && !isNaN(parseInt(args.timeout))) options.timeOut = parseInt(args.timeout);
22182225 if (args.extendedTimeout && !isNaN(parseInt(args.extendedTimeout))) options.extendedTimeOut = parseInt(args.extendedTimeout);
22192226 if (isTrueBoolean(args.preventDuplicates)) options.preventDuplicates = true;
2227+ if (args.cssClass) options.toastClass = args.cssClass;
2228+ if (args.escapeHtml !== undefined) options.escapeHtml = isTrueBoolean(args.escapeHtml);
22202229
22212230 // Prepare possible await handling
22222231 let awaitDismissal = isTrueBoolean(args.awaitDismissal);
@@ -2226,10 +2235,6 @@ async function echoCallback(args, value) {
22262235 options.onHidden = () => resolveToastDismissal(value);
22272236 }
22282237
2229- if (args.cssClass) {
2230- options.toastClass = args.cssClass;
2231- }
2232-
22332238 let toast;
22342239 switch (severity) {
22352240 case 'error':