Add color arg to /echo for custom color

a4e72da40fc9a2e25f17b2b1c2a2c490bc9e75f8

Wolfsblvt <wolfsblvt@gmail.com>

1 files changed, +19 -10Ignore whitespace
public/scripts/slash-commands.js+19 -10
@@ -772,11 +772,6 @@ export function initDefaultSlashCommands() {
772772 ],
773773 }),
774774 SlashCommandNamedArgument.fromProps({
775- name: 'cssClass',
776- description: 'additional css class to add to the toast message (e.g. for custom styling)',
777- typeList: [ARGUMENT_TYPE.STRING],
778- }),
779- SlashCommandNamedArgument.fromProps({
780775 name: 'timeout',
781776 description: 'time in milliseconds to display the toast message. Set this and \'extendedTimeout\' to 0 to show indefinitely until dismissed.',
782777 typeList: [ARGUMENT_TYPE.NUMBER],
@@ -802,6 +797,15 @@ export function initDefaultSlashCommands() {
802797 defaultValue: 'false',
803798 enumList: commonEnumProviders.boolean('trueFalse')(),
804799 }),
800+ SlashCommandNamedArgument.fromProps({
801+ name: 'cssClass',
802+ description: 'additional css class to add to the toast message (e.g. for custom styling)',
803+ typeList: [ARGUMENT_TYPE.STRING],
804+ }),
805+ SlashCommandNamedArgument.fromProps({
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.',
808+ })
805809 ],
806810 unnamedArgumentList: [
807811 new SlashCommandArgument(
@@ -2186,7 +2190,7 @@ async function generateCallback(args, value) {
21862190
21872191/**
21882192 *
21892193 * @param {{title?: string, severity?: string, cssClasstimeout?: string, timeoutextendedTimeout?: string, extendedTimeoutpreventDuplicates?: string, preventDuplicatesawaitDismissal?: string, awaitDismissalcssClass?: string, color?: string}} args - named arguments from the slash command
21902194 * @param {string} value - The string to echo (unnamed argument from the slash command)
21912195 * @returns {Promise<string>} The text that was echoed
21922196 */
@@ -2226,22 +2230,27 @@ async function echoCallback(args, value) {
22262230 options.toastClass = args.cssClass;
22272231 }
22282232
2233+ let toast;
22292234 switch (severity) {
22302235 case 'error':
22312236 toast = toastr.error(value, title, options);
22322237 break;
22332238 case 'warning':
22342239 toast = toastr.warning(value, title, options);
22352240 break;
22362241 case 'success':
22372242 toast = toastr.success(value, title, options);
22382243 break;
22392244 case 'info':
22402245 default:
22412246 toast = toastr.info(value, title, options);
22422247 break;
22432248 }
22442249
2250+ if (args.color) {
2251+ toast.css('background-color', args.color);
2252+ }
2253+
22452254 if (awaitDismissal) {
22462255 return new Promise((resolve) => {
22472256 resolveToastDismissal = resolve;