FileSuggest<T>
Unofficial
Editor suggestion provider for file and link autocompletion.
Import:
import type { FileSuggest } from '@obsidian-typings/obsidian-public-latest';Signature:
export interface FileSuggest<T> extends EditorSuggest<T>Extends: EditorSuggest<T>
Constructor
new FileSuggest(app: App)Constructor.
To extract the constructor type, use ExtractConstructor<EditorSuggest>.
Properties
| Property | Type | Description | |
|---|---|---|---|
| app | App | The Obsidian app instance. (Inherited from EditorSuggest) | |
| context | EditorSuggestContext | null | Current suggestion context, containing the result of onTrigger. This will be null any time the EditorSuggest is not supposed to run.(Inherited from EditorSuggest) | |
| instructionsEl | HTMLElement | The element holding the keyboard-shortcut instructions. (Inherited from EditorSuggest) | |
| isOpen | boolean | Whether the suggestion popup is currently open and visible. (Inherited from EditorSuggest) | |
| limit | number | Override this to use a different limit for suggestion items. (Inherited from EditorSuggest) | |
| scope | Scope | The scope for the keymaps. (Inherited from EditorSuggest) | |
| suggestEl | HTMLDivElement | Suggestion container element. (Inherited from EditorSuggest) | |
| suggestInnerEl | HTMLElement | The inner element holding the rendered suggestions. (Inherited from EditorSuggest) | |
| suggestions | SuggestionContainer<T> | Handles selection and rendering of the suggestions. (Inherited from EditorSuggest) | |
| suggestManager | FileSuggestManager | Manages fetching of suggestions from metadatacache. |
Methods
| Method | Returns | Description | |
|---|---|---|---|
| attachDom() | void | Attaches the suggestion popover to the document with an open animation. (Inherited from EditorSuggest) | |
| autoDestroy() | void | Automatically destroy the popover when its associated element is removed. (Inherited from EditorSuggest) | |
| close() | void | Closes the popover. (Inherited from EditorSuggest) | |
| detachDom() | void | Detaches the suggestion popover from the document. (Inherited from EditorSuggest) | |
| 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. (Inherited from EditorSuggest) | |
| onEscapeKey() | void | Handle the escape key to close the popover. (Inherited from EditorSuggest) | |
| 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.(Inherited from EditorSuggest) | |
| open() | void | Opens the popover. (Inherited from EditorSuggest) | |
| renderSuggestion(value, el) | void | Render the suggestion. (Inherited from EditorSuggest) | |
| reposition(rect, textDirection?) | void | Reposition the popover relative to the given bounding rectangle. (Inherited from EditorSuggest) | |
| selectSuggestion(value, evt) | void | Select the suggestion. (Inherited from EditorSuggest) | |
| setAutoDestroy(el) | void | Set the element that triggers automatic destruction of the popover when removed. (Inherited from EditorSuggest) | |
| setInstructions(instructions) | void | Set the instructions for the suggestion. (Inherited from EditorSuggest) | |
| showSuggestions(results) | void | Show suggestions. (Inherited from EditorSuggest) | |
| trigger(editor, file, force) | boolean | Evaluates the trigger at the cursor and updates the suggestion context. (Inherited from EditorSuggest) | |
| updatePosition() | void | Repositions the suggestion popover at the current trigger location. (Inherited from EditorSuggest) |