Skip to content

EditorSuggest.getSuggestions method

EditorSuggest › getSuggestions

Official

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

Signature:

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

Parameters:

Parameter Type Description
context EditorSuggestContext The context of the suggestion.

Returns: Promise<T[]> | T[]The suggestion items.

Since: 0.12.17

Example:

class MyEditorSuggest extends EditorSuggest<string> {
public override getSuggestions(context: EditorSuggestContext): string[] {
return ['Item 1', 'Item 2', 'Item 3'];
}
}

Example:

class MyEditorSuggest extends EditorSuggest<string> {
public override getSuggestions(context: EditorSuggestContext): Promise<string[]> {
return Promise.resolve(['Item 1', 'Item 2', 'Item 3']);
}
}