Skip to content

editor-suggest

Helpers for EditorSuggest: giving one priority over the others, and opening one from a command.

Read from Obsidian 1.15.0: the editor asks each suggest in app.workspace.editorSuggest.suggests in order, and the first whose trigger accepts the cursor wins, so registration order decides which suggest opens. A suggest shows its list only when the trigger is explicit (the user typed) or it is already open.

Class Description
CommandEditorSuggest 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: ts 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' \});
Interface Description
CommandEditorSuggestOpenFromCommandParams Parameters for CommandEditorSuggest.openFromCommand.
PrioritizeEditorSuggestParams Parameters for prioritizeEditorSuggest.
Function Description
prioritizeEditorSuggest Moves a registered editor suggest to the front of the list the editor asks, so it opens ahead of every other suggest whose trigger accepts the same text, Obsidian’s own [[ and # suggests included. A suggest prioritized later goes ahead of it in turn.