Skip to content

FileSuggest<T>

Unofficial

Editor suggestion provider for file and link autocompletion.

Import:

import type { FileSuggest } from '@obsidian-typings/obsidian-catalyst-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

PropertyTypeDescription
appAppThe Obsidian app instance.
(Inherited from EditorSuggest)
contextEditorSuggestContext | nullCurrent suggestion context, containing the result of onTrigger. This will be null any time the EditorSuggest is not supposed to run.
(Inherited from EditorSuggest)
instructionsElHTMLElementThe element holding the keyboard-shortcut instructions.
(Inherited from EditorSuggest)
isOpenbooleanWhether the suggestion popup is currently open and visible.
(Inherited from EditorSuggest)
limitnumberOverride this to use a different limit for suggestion items.
(Inherited from EditorSuggest)
scopeScopeThe scope for the keymaps.
(Inherited from EditorSuggest)
suggestElHTMLDivElementSuggestion container element.
(Inherited from EditorSuggest)
suggestInnerElHTMLElementThe inner element holding the rendered suggestions.
(Inherited from EditorSuggest)
suggestionsSuggestModalChooser<T, this>Handles selection and rendering of the suggestions.
(Inherited from EditorSuggest)
suggestManagerFileSuggestManagerManages fetching of suggestions from metadatacache.
winnull | WindowThe window the suggestion popover is shown in, or null while closed.
(Inherited from EditorSuggest)

Methods

MethodReturnsDescription
attachDom()voidAttaches the suggestion popover to the document with an open animation.
(Inherited from EditorSuggest)
autoDestroy()voidAutomatically destroy the popover when its associated element is removed.
(Inherited from EditorSuggest)
close()voidCloses the popover.
(Inherited from EditorSuggest)
detachDom()voidDetaches 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()voidHandle the escape key to close the popover.
(Inherited from EditorSuggest)
onSelectedChange(value, evt?)voidCalled after every selection change, including the programmatic one that follows SuggestModalChooser.setSuggestions.
(Inherited from EditorSuggest)
onTrigger(cursor, editor, file)EditorSuggestTriggerInfo | nullBased 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()voidOpens the popover.
(Inherited from EditorSuggest)
renderSuggestion(value, el)voidRender the suggestion.
(Inherited from EditorSuggest)
reposition(rect, textDirection?)voidReposition the popover relative to the given bounding rectangle.
(Inherited from EditorSuggest)
selectSuggestion(value, evt)voidSelect the suggestion.
(Inherited from EditorSuggest)
setAutoDestroy(el)voidSet the element that triggers automatic destruction of the popover when removed.
(Inherited from EditorSuggest)
setInstructions(instructions)voidSet the instructions for the suggestion.
(Inherited from EditorSuggest)
showSuggestions(results)voidDisplay the given values as suggestions, truncated to limit, or close the popover if there are none.
(Inherited from EditorSuggest)
trigger(editor, file, force)booleanEvaluates the trigger at the cursor and updates the suggestion context.
(Inherited from EditorSuggest)
updatePosition()voidRepositions the suggestion popover at the current trigger location.
(Inherited from EditorSuggest)