mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2024-12-11 17:07:07 +01:00
5cb319771d
* set pipe to empty string on empty closure * fix missing parser flags and scope * add closure serializing * add enum provider function to slash command arguments * add enum providers for /bg, /ask, and /go * fix index out of bounds returning undefined * keep whitespace as is in mixed unnamed args (string+closure) * add _hasUnnamedArgument to named arguments dictionary * allow /var key=x retrieval * add enum provider to /tag-add * fix typo (case) * add option to make enum matching optional * add executor to enum provider * change /tag-add enum provider to only show tags not already assigned * add enum provider to /tag-remove * fix name enum provider excluding groups * remove void from slash command callback return types * Lint undefined and null pipes * enable pointer events in chat autocomplete * fix type hint --------- Co-authored-by: LenAnderson <Anderson.Len@outlook.com> Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>
45 lines
1.9 KiB
JavaScript
45 lines
1.9 KiB
JavaScript
import { SlashCommandNamedArgumentAutoCompleteOption } from '../slash-commands/SlashCommandNamedArgumentAutoCompleteOption.js';
|
|
import { AutoCompleteOption } from './AutoCompleteOption.js';
|
|
// import { AutoCompleteSecondaryNameResult } from './AutoCompleteSecondaryNameResult.js';
|
|
|
|
|
|
|
|
export class AutoCompleteNameResult {
|
|
/**@type {string} */ name;
|
|
/**@type {number} */ start;
|
|
/**@type {AutoCompleteOption[]} */ optionList = [];
|
|
/**@type {boolean} */ canBeQuoted = false;
|
|
/**@type {()=>string} */ makeNoMatchText = ()=>`No matches found for "${this.name}"`;
|
|
/**@type {()=>string} */ makeNoOptionsText = ()=>'No options';
|
|
|
|
|
|
/**
|
|
* @param {string} name Name (potentially partial) of the name at the requested index.
|
|
* @param {number} start Index where the name starts.
|
|
* @param {AutoCompleteOption[]} optionList A list of autocomplete options found in the current scope.
|
|
* @param {boolean} canBeQuoted Whether the name can be inside quotes.
|
|
* @param {()=>string} makeNoMatchText Function that returns text to show when no matches where found.
|
|
* @param {()=>string} makeNoOptionsText Function that returns text to show when no options are available to match against.
|
|
*/
|
|
constructor(name, start, optionList = [], canBeQuoted = false, makeNoMatchText = null, makeNoOptionsText = null) {
|
|
this.name = name;
|
|
this.start = start;
|
|
this.optionList = optionList;
|
|
this.canBeQuoted = canBeQuoted;
|
|
this.noMatchText = makeNoMatchText ?? this.makeNoMatchText;
|
|
this.noOptionstext = makeNoOptionsText ?? this.makeNoOptionsText;
|
|
}
|
|
|
|
|
|
/**
|
|
*
|
|
* @param {string} text The whole text
|
|
* @param {number} index Cursor index within text
|
|
* @param {boolean} isSelect Whether autocomplete was triggered by selecting an autocomplete option
|
|
* @returns {AutoCompleteSecondaryNameResult}
|
|
*/
|
|
getSecondaryNameAt(text, index, isSelect) {
|
|
return null;
|
|
}
|
|
}
|