Skip to content

EditorSuggest

Defined in: obsidian.d.ts:1328

Extends

Extended by

Type Parameters

T

Constructors

new EditorSuggest()

new EditorSuggest<T>(app): EditorSuggest<T>

Defined in: obsidian.d.ts:1342

Parameters

app

App

Returns

EditorSuggest<T>

Overrides

PopoverSuggest.constructor

Properties

app

app: App

Defined in: obsidian.d.ts:3332

Inherited from

PopoverSuggest.app


context

context: null | EditorSuggestContext

Defined in: obsidian.d.ts:1335

Current suggestion context, containing the result of onTrigger. This will be null any time the EditorSuggest is not supposed to run.


isOpen

isOpen: boolean

Defined in: src/obsidian/augmentations/PopoverSuggest.d.ts:10

Whether the suggestion popup is currently open and visible

Inherited from

PopoverSuggest.isOpen


limit

limit: number

Defined in: obsidian.d.ts:1340

Override this to use a different limit for suggestion items


scope

scope: Scope

Defined in: obsidian.d.ts:3334

Inherited from

PopoverSuggest.scope


suggestEl

suggestEl: HTMLElement

Defined in: src/obsidian/augmentations/PopoverSuggest.d.ts:14

Suggestion container element

Inherited from

PopoverSuggest.suggestEl


suggestions

suggestions: SuggestionContainer<T>

Defined in: src/obsidian/augmentations/PopoverSuggest.d.ts:18

Handles selection and rendering of the suggestions

Inherited from

PopoverSuggest.suggestions

Methods

close()

close(): void

Defined in: obsidian.d.ts:3341

Returns

void

Inherited from

PopoverSuggest.close


getSuggestions()

abstract getSuggestions(context): T[] | Promise<T[]>

Defined in: obsidian.d.ts:1363

Generate suggestion items based on this context. Can be async, but preferably sync. When generating async suggestions, you should pass the context along.

Parameters

context

EditorSuggestContext

Returns

T[] | Promise<T[]>


onTrigger()

abstract onTrigger(cursor, editor, file): null | EditorSuggestTriggerInfo

Defined in: obsidian.d.ts:1357

Based on the editor line and cursor position, determine if this 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.

Parameters

cursor

EditorPosition

editor

Editor

file

null | TFile

Returns

null | EditorSuggestTriggerInfo


open()

open(): void

Defined in: obsidian.d.ts:3339

Returns

void

Inherited from

PopoverSuggest.open


renderSuggestion()

abstract renderSuggestion(value, el): void

Defined in: obsidian.d.ts:3347

Render the suggestion item into DOM.

Parameters

value

T

el

HTMLElement

Returns

void

Inherited from

PopoverSuggest.renderSuggestion


selectSuggestion()

abstract selectSuggestion(value, evt): void

Defined in: obsidian.d.ts:3352

Called when the user makes a selection.

Parameters

value

T

evt

MouseEvent | KeyboardEvent

Returns

void

Inherited from

PopoverSuggest.selectSuggestion


setInstructions()

setInstructions(instructions): void

Defined in: obsidian.d.ts:1346

Parameters

instructions

Instruction[]

Returns

void


showSuggestions()

showSuggestions(results): void

Defined in: src/obsidian/augmentations/EditorSuggest.d.ts:6

Parameters

results

SearchResult[]

Returns

void