Skip to content

EditorSuggest\<T\>

Defined in: suggest.ts:540

Base class for adding a type-ahead popover.

T

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

Defined in: suggest.ts:559

App

EditorSuggest<T>

PopoverSuggest.constructor

readonly app: App

Defined in: suggest.ts:39

PopoverSuggest.app


context: EditorSuggestContext | null = null

Defined in: suggest.ts:547

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


limit: number = -1

Defined in: suggest.ts:557

Override this to use a different limit for suggestion items


scope: Scope

Defined in: suggest.ts:549

PopoverSuggest.scope


suggestEl: HTMLElement

Defined in: suggest.ts:550

close(): void

Defined in: suggest.ts:566

void

PopoverSuggest.close


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

Defined in: suggest.ts:600

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

EditorSuggestContext

T[] | Promise<T[]>


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

Defined in: suggest.ts:588

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.

EditorPosition

Editor

TFile | null

EditorSuggestTriggerInfo | null


open(): void

Defined in: suggest.ts:571

void

PopoverSuggest.open


abstract renderSuggestion(value, el): void

Defined in: suggest.ts:53

T

HTMLElement

void

PopoverSuggest.renderSuggestion


abstract selectSuggestion(value, evt): void

Defined in: suggest.ts:58

T

MouseEvent | KeyboardEvent

void

PopoverSuggest.selectSuggestion


setInstructions(instructions): void

Defined in: suggest.ts:564

Instruction[]

void