mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Add rawQuotes to override with named arg (#4032)
This commit is contained in:
@ -266,6 +266,14 @@ export function initDefaultSlashCommands() {
|
|||||||
enumList: slashCommandReturnHelper.enumList({ allowObject: true }),
|
enumList: slashCommandReturnHelper.enumList({ allowObject: true }),
|
||||||
forceEnum: true,
|
forceEnum: true,
|
||||||
}),
|
}),
|
||||||
|
SlashCommandNamedArgument.fromProps({
|
||||||
|
name: 'raw',
|
||||||
|
description: 'If true, does not alter quoted literal unnamed arguments',
|
||||||
|
typeList: [ARGUMENT_TYPE.BOOLEAN],
|
||||||
|
defaultValue: 'true',
|
||||||
|
enumProvider: commonEnumProviders.boolean('trueFalse'),
|
||||||
|
isRequired: false,
|
||||||
|
}),
|
||||||
],
|
],
|
||||||
unnamedArgumentList: [
|
unnamedArgumentList: [
|
||||||
new SlashCommandArgument(
|
new SlashCommandArgument(
|
||||||
@ -328,6 +336,14 @@ export function initDefaultSlashCommands() {
|
|||||||
enumList: slashCommandReturnHelper.enumList({ allowObject: true }),
|
enumList: slashCommandReturnHelper.enumList({ allowObject: true }),
|
||||||
forceEnum: true,
|
forceEnum: true,
|
||||||
}),
|
}),
|
||||||
|
SlashCommandNamedArgument.fromProps({
|
||||||
|
name: 'raw',
|
||||||
|
description: 'If true, does not alter quoted literal unnamed arguments',
|
||||||
|
typeList: [ARGUMENT_TYPE.BOOLEAN],
|
||||||
|
defaultValue: 'true',
|
||||||
|
enumProvider: commonEnumProviders.boolean('trueFalse'),
|
||||||
|
isRequired: false,
|
||||||
|
}),
|
||||||
],
|
],
|
||||||
unnamedArgumentList: [
|
unnamedArgumentList: [
|
||||||
new SlashCommandArgument(
|
new SlashCommandArgument(
|
||||||
@ -392,6 +408,14 @@ export function initDefaultSlashCommands() {
|
|||||||
enumList: slashCommandReturnHelper.enumList({ allowObject: true }),
|
enumList: slashCommandReturnHelper.enumList({ allowObject: true }),
|
||||||
forceEnum: true,
|
forceEnum: true,
|
||||||
}),
|
}),
|
||||||
|
SlashCommandNamedArgument.fromProps({
|
||||||
|
name: 'raw',
|
||||||
|
description: 'If true, does not alter quoted literal unnamed arguments',
|
||||||
|
typeList: [ARGUMENT_TYPE.BOOLEAN],
|
||||||
|
defaultValue: 'true',
|
||||||
|
enumProvider: commonEnumProviders.boolean('trueFalse'),
|
||||||
|
isRequired: false,
|
||||||
|
}),
|
||||||
],
|
],
|
||||||
unnamedArgumentList: [
|
unnamedArgumentList: [
|
||||||
new SlashCommandArgument(
|
new SlashCommandArgument(
|
||||||
@ -617,6 +641,14 @@ export function initDefaultSlashCommands() {
|
|||||||
enumList: slashCommandReturnHelper.enumList({ allowObject: true }),
|
enumList: slashCommandReturnHelper.enumList({ allowObject: true }),
|
||||||
forceEnum: true,
|
forceEnum: true,
|
||||||
}),
|
}),
|
||||||
|
SlashCommandNamedArgument.fromProps({
|
||||||
|
name: 'raw',
|
||||||
|
description: 'If true, does not alter quoted literal unnamed arguments',
|
||||||
|
typeList: [ARGUMENT_TYPE.BOOLEAN],
|
||||||
|
defaultValue: 'true',
|
||||||
|
enumProvider: commonEnumProviders.boolean('trueFalse'),
|
||||||
|
isRequired: false,
|
||||||
|
}),
|
||||||
],
|
],
|
||||||
unnamedArgumentList: [
|
unnamedArgumentList: [
|
||||||
new SlashCommandArgument(
|
new SlashCommandArgument(
|
||||||
@ -1013,6 +1045,14 @@ export function initDefaultSlashCommands() {
|
|||||||
description: 'a closure to call when the toast is clicked. This executed closure receives scope as provided in the script. Careful about possible side effects when manipulating variables and more.',
|
description: 'a closure to call when the toast is clicked. This executed closure receives scope as provided in the script. Careful about possible side effects when manipulating variables and more.',
|
||||||
typeList: [ARGUMENT_TYPE.CLOSURE],
|
typeList: [ARGUMENT_TYPE.CLOSURE],
|
||||||
}),
|
}),
|
||||||
|
SlashCommandNamedArgument.fromProps({
|
||||||
|
name: 'raw',
|
||||||
|
description: 'If true, does not alter quoted literal unnamed arguments',
|
||||||
|
typeList: [ARGUMENT_TYPE.BOOLEAN],
|
||||||
|
defaultValue: 'true',
|
||||||
|
enumProvider: commonEnumProviders.boolean('trueFalse'),
|
||||||
|
isRequired: false,
|
||||||
|
}),
|
||||||
],
|
],
|
||||||
unnamedArgumentList: [
|
unnamedArgumentList: [
|
||||||
new SlashCommandArgument(
|
new SlashCommandArgument(
|
||||||
|
@ -266,7 +266,7 @@ export class SlashCommand {
|
|||||||
rawQuotes.classList.add('rawQuotes');
|
rawQuotes.classList.add('rawQuotes');
|
||||||
rawQuotes.classList.add('fa-solid');
|
rawQuotes.classList.add('fa-solid');
|
||||||
rawQuotes.classList.add('fa-quote-left');
|
rawQuotes.classList.add('fa-quote-left');
|
||||||
rawQuotes.title = t`Does not alter quoted literal unnamed arguments`;
|
rawQuotes.title = t`Does not alter quoted literal unnamed arguments. Pass raw=false argument to override.`;
|
||||||
head.append(rawQuotes);
|
head.append(rawQuotes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { hljs } from '../../lib.js';
|
import { hljs } from '../../lib.js';
|
||||||
import { power_user } from '../power-user.js';
|
import { power_user } from '../power-user.js';
|
||||||
import { isTrueBoolean, uuidv4 } from '../utils.js';
|
import { isFalseBoolean, isTrueBoolean, uuidv4 } from '../utils.js';
|
||||||
import { SlashCommand } from './SlashCommand.js';
|
import { SlashCommand } from './SlashCommand.js';
|
||||||
import { ARGUMENT_TYPE, SlashCommandArgument } from './SlashCommandArgument.js';
|
import { ARGUMENT_TYPE, SlashCommandArgument } from './SlashCommandArgument.js';
|
||||||
import { SlashCommandClosure } from './SlashCommandClosure.js';
|
import { SlashCommandClosure } from './SlashCommandClosure.js';
|
||||||
@ -975,7 +975,9 @@ export class SlashCommandParser {
|
|||||||
cmd.startUnnamedArgs = this.index - (/\s(\s*)$/s.exec(this.behind)?.[1]?.length ?? 0);
|
cmd.startUnnamedArgs = this.index - (/\s(\s*)$/s.exec(this.behind)?.[1]?.length ?? 0);
|
||||||
cmd.endUnnamedArgs = this.index;
|
cmd.endUnnamedArgs = this.index;
|
||||||
if (this.testUnnamedArgument()) {
|
if (this.testUnnamedArgument()) {
|
||||||
cmd.unnamedArgumentList = this.parseUnnamedArgument(cmd.command?.unnamedArgumentList?.length && cmd?.command?.splitUnnamedArgument, cmd?.command?.splitUnnamedArgumentCount, cmd?.command?.rawQuotes);
|
const rawQuotesArg = cmd?.namedArgumentList?.find(a => a.name === 'raw');
|
||||||
|
const rawQuotes = cmd?.command?.rawQuotes && rawQuotesArg ? !isFalseBoolean(rawQuotesArg?.value?.toString()) : cmd?.command?.rawQuotes;
|
||||||
|
cmd.unnamedArgumentList = this.parseUnnamedArgument(cmd.command?.unnamedArgumentList?.length && cmd?.command?.splitUnnamedArgument, cmd?.command?.splitUnnamedArgumentCount, rawQuotes);
|
||||||
cmd.endUnnamedArgs = this.index;
|
cmd.endUnnamedArgs = this.index;
|
||||||
if (cmd.name == 'let') {
|
if (cmd.name == 'let') {
|
||||||
const keyArg = cmd.namedArgumentList.find(it=>it.name == 'key');
|
const keyArg = cmd.namedArgumentList.find(it=>it.name == 'key');
|
||||||
|
Reference in New Issue
Block a user