SlashMenuController
The state of the "/" menu for one editor: whether it is open, the query typed after the slash, the filtered and sorted entries
and the selected one. SlashMenu is its default rendering; use it directly to build your own menu.
Import
import { SlashMenuController } from '@aionbuilders/nabu/ui';Constructor
new SlashMenuController(engine: Nabu, commands?: SlashCommand[])| Parameter | Type | Description |
|---|---|---|
engine | Nabu | n/a |
commandsoptional | SlashCommand[] | EXTRA entries of the integrator, added to the ones the loaded extensions contribute
( |
Properties
available
available: SlashCommand[]The entries of the loaded extensions plus the integrator's extras that apply at the caret (when), in the documented
order (group, order, declaration order).
commands
commands: SlashCommand[]filteredItems
filteredItems: SlashCommand[]The available entries matching the query: titles by substring, aliases by prefix.
match
match: {
block: any;
cursor: number;
query: string;
slashStart: number;
} | nullThe pending slash trigger at the caret: its block, where the slash starts, the caret and the query typed after it; null when there is none.
open
open: booleanWhether the menu should be shown: a trigger at the caret, at least one match, not dismissed, not read-only.
query
query: stringThe text typed after the slash (empty when no trigger).
selectedIndex
selectedIndex: numberIndex of the highlighted entry in filteredItems.
Methods
close()
close(): voidDismiss the menu for the current trigger position (Escape).
moveSelection()
moveSelection(delta: number): voidMove the highlight by delta entries, wrapping around.
| Parameter | Type | Description |
|---|---|---|
delta | number | n/a |
select()
select(index?: number): Promise<void>Run the command at the given index (default: the selected one).
| Parameter | Type | Description |
|---|---|---|
indexoptional | number | n/a |
Source: src/lib/ui/slash-menu.svelte.js:66