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() {
805 SlashCommandNamedArgument.fromProps({805 SlashCommandNamedArgument.fromProps({
806 name: 'color',806 name: 'color',
807 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.',807 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.',
808 })808 }),
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 }),
809 ],816 ],
810 unnamedArgumentList: [817 unnamedArgumentList: [
811 new SlashCommandArgument(818 new SlashCommandArgument(
@@ -2190,7 +2197,7 @@ async function generateCallback(args, value) {
21902197
2191/**2198/**
2192 *2199 *
2193 * @param {{title?: string, severity?: string, timeout?: string, extendedTimeout?: string, preventDuplicates?: string, awaitDismissal?: string, cssClass?: string, color?: string}} args - named arguments from the slash command2200 * @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
2194 * @param {string} value - The string to echo (unnamed argument from the slash command)2201 * @param {string} value - The string to echo (unnamed argument from the slash command)
2195 * @returns {Promise<string>} The text that was echoed2202 * @returns {Promise<string>} The text that was echoed
2196 */2203 */
@@ -2217,6 +2224,8 @@ async function echoCallback(args, value) {
2217 if (args.timeout && !isNaN(parseInt(args.timeout))) options.timeOut = parseInt(args.timeout);2224 if (args.timeout && !isNaN(parseInt(args.timeout))) options.timeOut = parseInt(args.timeout);
2218 if (args.extendedTimeout && !isNaN(parseInt(args.extendedTimeout))) options.extendedTimeOut = parseInt(args.extendedTimeout);2225 if (args.extendedTimeout && !isNaN(parseInt(args.extendedTimeout))) options.extendedTimeOut = parseInt(args.extendedTimeout);
2219 if (isTrueBoolean(args.preventDuplicates)) options.preventDuplicates = true;2226 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
2221 // Prepare possible await handling2230 // Prepare possible await handling
2222 let awaitDismissal = isTrueBoolean(args.awaitDismissal);2231 let awaitDismissal = isTrueBoolean(args.awaitDismissal);
@@ -2226,10 +2235,6 @@ async function echoCallback(args, value) {
2226 options.onHidden = () => resolveToastDismissal(value);2235 options.onHidden = () => resolveToastDismissal(value);
2227 }2236 }
22282237
2229 if (args.cssClass) {
2230 options.toastClass = args.cssClass;
2231 }
2232
2233 let toast;2238 let toast;
2234 switch (severity) {2239 switch (severity) {
2235 case 'error':2240 case 'error':