mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
show command details as argument and enum details
This commit is contained in:
@ -99,7 +99,7 @@ export class SlashCommandAutoCompleteNameResult extends AutoCompleteNameResult {
|
|||||||
const result = new AutoCompleteSecondaryNameResult(
|
const result = new AutoCompleteSecondaryNameResult(
|
||||||
value,
|
value,
|
||||||
start + name.length,
|
start + name.length,
|
||||||
cmdArg.enumList.map(it=>new SlashCommandEnumAutoCompleteOption(it)),
|
cmdArg.enumList.map(it=>new SlashCommandEnumAutoCompleteOption(this.executor.command, it)),
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
result.isRequired = true;
|
result.isRequired = true;
|
||||||
@ -154,7 +154,7 @@ export class SlashCommandAutoCompleteNameResult extends AutoCompleteNameResult {
|
|||||||
const result = new AutoCompleteSecondaryNameResult(
|
const result = new AutoCompleteSecondaryNameResult(
|
||||||
value,
|
value,
|
||||||
start,
|
start,
|
||||||
cmdArg.enumList.map(it=>new SlashCommandEnumAutoCompleteOption(it)),
|
cmdArg.enumList.map(it=>new SlashCommandEnumAutoCompleteOption(this.executor.command, it)),
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
const isCompleteValue = cmdArg.enumList.find(it=>it.value == value);
|
const isCompleteValue = cmdArg.enumList.find(it=>it.value == value);
|
||||||
|
@ -1,16 +1,20 @@
|
|||||||
import { AutoCompleteOption } from '../autocomplete/AutoCompleteOption.js';
|
import { AutoCompleteOption } from '../autocomplete/AutoCompleteOption.js';
|
||||||
|
import { SlashCommand } from './SlashCommand.js';
|
||||||
import { SlashCommandEnumValue } from './SlashCommandEnumValue.js';
|
import { SlashCommandEnumValue } from './SlashCommandEnumValue.js';
|
||||||
|
|
||||||
export class SlashCommandEnumAutoCompleteOption extends AutoCompleteOption {
|
export class SlashCommandEnumAutoCompleteOption extends AutoCompleteOption {
|
||||||
|
/**@type {SlashCommand}*/ cmd;
|
||||||
/**@type {SlashCommandEnumValue}*/ enumValue;
|
/**@type {SlashCommandEnumValue}*/ enumValue;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param {SlashCommand} cmd
|
||||||
* @param {SlashCommandEnumValue} enumValue
|
* @param {SlashCommandEnumValue} enumValue
|
||||||
*/
|
*/
|
||||||
constructor(enumValue) {
|
constructor(cmd, enumValue) {
|
||||||
super(enumValue.value, '◊');
|
super(enumValue.value, '◊');
|
||||||
|
this.cmd = cmd;
|
||||||
this.enumValue = enumValue;
|
this.enumValue = enumValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -25,22 +29,6 @@ export class SlashCommandEnumAutoCompleteOption extends AutoCompleteOption {
|
|||||||
|
|
||||||
|
|
||||||
renderDetails() {
|
renderDetails() {
|
||||||
const frag = document.createDocumentFragment();
|
return this.cmd.renderHelpDetails();
|
||||||
const specs = document.createElement('div'); {
|
|
||||||
specs.classList.add('specs');
|
|
||||||
const name = document.createElement('div'); {
|
|
||||||
name.classList.add('name');
|
|
||||||
name.classList.add('monospace');
|
|
||||||
name.textContent = this.name;
|
|
||||||
specs.append(name);
|
|
||||||
}
|
|
||||||
frag.append(specs);
|
|
||||||
}
|
|
||||||
const help = document.createElement('span'); {
|
|
||||||
help.classList.add('help');
|
|
||||||
help.textContent = this.enumValue.description;
|
|
||||||
frag.append(help);
|
|
||||||
}
|
|
||||||
return frag;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,22 +27,6 @@ export class SlashCommandNamedArgumentAutoCompleteOption extends AutoCompleteOpt
|
|||||||
|
|
||||||
|
|
||||||
renderDetails() {
|
renderDetails() {
|
||||||
const frag = document.createDocumentFragment();
|
return this.cmd.renderHelpDetails();
|
||||||
const specs = document.createElement('div'); {
|
|
||||||
specs.classList.add('specs');
|
|
||||||
const name = document.createElement('div'); {
|
|
||||||
name.classList.add('name');
|
|
||||||
name.classList.add('monospace');
|
|
||||||
name.textContent = this.name;
|
|
||||||
specs.append(name);
|
|
||||||
}
|
|
||||||
frag.append(specs);
|
|
||||||
}
|
|
||||||
const help = document.createElement('span'); {
|
|
||||||
help.classList.add('help');
|
|
||||||
help.innerHTML = `${this.arg.isRequired ? '' : '(optional) '}${this.arg.description ?? ''}`;
|
|
||||||
frag.append(help);
|
|
||||||
}
|
|
||||||
return frag;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user