CommandEditorSuggest<T>
An editor suggest that a command can open at the cursor, without a trigger character.
CommandEditorSuggest.openFromCommand opens it at the cursor; the text typed after that point, on the same line, is the query, and moving the cursor before that point or off the line closes it. A subclass may still open on typed text by overriding CommandEditorSuggest.onTextTrigger.
Register it as usual, so the editor keeps it updated while the user types:
const suggest = new EmojiSuggest(this.app);this.registerEditorSuggest(suggest);this.addCommand({ editorCallback: (editor, ctx) => { suggest.openFromCommand({ editor, file: ctx.file }); }, id: 'insert-emoji', name: 'Insert emoji'});Import:
import { CommandEditorSuggest } from '@mnaoumov/obsidian-lib/editor-suggest';Signature:
export class CommandEditorSuggest<T> extends EditorSuggest<T>Extends: EditorSuggest<T>
Methods
| Method | Returns | Description |
|---|---|---|
| close() | void | Closes the suggest, ending a command-opened session. |
| onTextTrigger(_cursor, _editor, _file) | EditorSuggestTriggerInfo | null | Decides whether the suggest opens on typed text, outside a command-opened session. Never, by default. |
| onTrigger(cursor, editor, file) | EditorSuggestTriggerInfo | null | Decides whether the suggest opens. While a command-opened session lasts, the query is the text from where it was opened to the cursor; otherwise CommandEditorSuggest.onTextTrigger decides. |
| openFromCommand(params) | boolean | Opens the suggest at the cursor of an editor, typically from a command's editorCallback. |