EditorSuggest<T>
Official
Represents a autocomplete suggestion in the editor
Import:
import { EditorSuggest } from 'obsidian';Signature:
export class EditorSuggest<T> extends PopoverSuggest<T>Extends: PopoverSuggest<T>
Constructor
new EditorSuggest(app: App)Constructor.
To extract the constructor type, use ExtractConstructor<EditorSuggest>.
Properties
| Property | Type | Description | |
|---|---|---|---|
| app | App | The Obsidian app instance. (Inherited from PopoverSuggest) | |
| context | EditorSuggestContext | null | Current suggestion context, containing the result of onTrigger. This will be null any time the EditorSuggest is not supposed to run. | |
| instructionsEl | HTMLElement | The element holding the keyboard-shortcut instructions. | |
| isOpen | boolean | Whether the suggestion popup is currently open and visible. (Inherited from PopoverSuggest) | |
| limit | number | Override this to use a different limit for suggestion items. | |
| scope | Scope | The scope for the keymaps. (Inherited from PopoverSuggest) | |
| suggestEl | HTMLDivElement | Suggestion container element. (Inherited from PopoverSuggest) | |
| suggestInnerEl | HTMLElement | The inner element holding the rendered suggestions. (Inherited from PopoverSuggest) | |
| suggestions | SuggestionContainer<T> | Handles selection and rendering of the suggestions. (Inherited from PopoverSuggest) | |
| win | null | Window | The window the suggestion popover is shown in, or null while closed.(Inherited from PopoverSuggest) |
Methods
| Method | Returns | Description | |
|---|---|---|---|
| attachDom() | void | Attaches the suggestion popover to the document with an open animation. (Inherited from PopoverSuggest) | |
| autoDestroy() | void | Automatically destroy the popover when its associated element is removed. (Inherited from PopoverSuggest) | |
| close() | void | Closes the popover. (Inherited from PopoverSuggest) | |
| detachDom() | void | Detaches the suggestion popover from the document. (Inherited from PopoverSuggest) | |
| getSuggestions(context) | Promise<T[]> | T[] | Generate suggestion items based on this context. Can be async, but preferably sync. When generating async suggestions, you should pass the context along. | |
| onEscapeKey() | void | Handle the escape key to close the popover. (Inherited from PopoverSuggest) | |
| onTrigger(cursor, editor, file) | EditorSuggestTriggerInfo | null | Based on the editor line and cursor position, determine if this obsidian#EditorSuggest should be triggered at this moment. Typically, you would run a regular expression on the current line text before the cursor. Return null to indicate that this editor suggest is not supposed to be triggered.Please be mindful of performance when implementing this function, as it will be triggered very often (on each keypress). Keep it simple, and return null as early as possible if you determine that it is not the right time. | |
| open() | void | Opens the popover. (Inherited from PopoverSuggest) | |
| renderSuggestion(value, el) | void | Render the suggestion. (Inherited from PopoverSuggest) | |
| reposition(rect, textDirection?) | void | Reposition the popover relative to the given bounding rectangle. (Inherited from PopoverSuggest) | |
| selectSuggestion(value, evt) | void | Select the suggestion. (Inherited from PopoverSuggest) | |
| setAutoDestroy(el) | void | Set the element that triggers automatic destruction of the popover when removed. (Inherited from PopoverSuggest) | |
| setInstructions(instructions) | void | Set the instructions for the suggestion. | |
| showSuggestions(results) | void | Show suggestions. | |
| trigger(editor, file, force) | boolean | Evaluates the trigger at the cursor and updates the suggestion context. | |
| updatePosition() | void | Repositions the suggestion popover at the current trigger location. |
Links to this page: