EditorSuggest
Defined in: obsidian.d.ts:1367
Extends
Section titled “Extends”Extended by
Section titled “Extended by”Type Parameters
Section titled “Type Parameters”T
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new EditorSuggest<
T
>(app
):EditorSuggest
<T
>
Defined in: obsidian.d.ts:1381
Parameters
Section titled “Parameters”Returns
Section titled “Returns”EditorSuggest
<T
>
Overrides
Section titled “Overrides”Properties
Section titled “Properties”app:
App
Defined in: obsidian.d.ts:3400
Inherited from
Section titled “Inherited from”context
Section titled “context”context:
null
|EditorSuggestContext
Defined in: obsidian.d.ts:1374
Current suggestion context, containing the result of onTrigger
.
This will be null any time the EditorSuggest is not supposed to run.
isOpen
Section titled “isOpen”isOpen:
boolean
Defined in: src/obsidian/augmentations/PopoverSuggest.d.ts:24
Whether the suggestion popup is currently open and visible.
Inherited from
Section titled “Inherited from”limit:
number
Defined in: obsidian.d.ts:1379
Override this to use a different limit for suggestion items
scope:
Scope
Defined in: obsidian.d.ts:3402
Inherited from
Section titled “Inherited from”suggestEl
Section titled “suggestEl”suggestEl:
HTMLElement
Defined in: src/obsidian/augmentations/PopoverSuggest.d.ts:38
Suggestion container element.
Inherited from
Section titled “Inherited from”suggestions
Section titled “suggestions”suggestions:
SuggestionContainer
<T
>
Defined in: src/obsidian/augmentations/PopoverSuggest.d.ts:45
Handles selection and rendering of the suggestions.
Inherited from
Section titled “Inherited from”Methods
Section titled “Methods”close()
Section titled “close()”Call Signature
Section titled “Call Signature”close():
void
Defined in: obsidian.d.ts:3409
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”Call Signature
Section titled “Call Signature”close():
void
Defined in: src/obsidian/augmentations/PopoverSuggest.d.ts:52
Closes the popover.
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”constructor__()
Section titled “constructor__()”constructor__(
app
):this
Defined in: src/obsidian/augmentations/EditorSuggest.d.ts:32
Create a new EditorSuggest.
Parameters
Section titled “Parameters”The app instance.
Returns
Section titled “Returns”this
Inherited from
Section titled “Inherited from”getSuggestions()
Section titled “getSuggestions()”
abstract
getSuggestions(context
):T
[] |Promise
<T
[]>
Defined in: obsidian.d.ts:1402
Generate suggestion items based on this context. Can be async, but preferably sync. When generating async suggestions, you should pass the context along.
Parameters
Section titled “Parameters”context
Section titled “context”Returns
Section titled “Returns”T
[] | Promise
<T
[]>
getSuggestions__()
Section titled “getSuggestions__()”getSuggestions__(
context
):T
[] |Promise
<T
[]>
Defined in: src/obsidian/augmentations/EditorSuggest.d.ts:59
Generate suggestion items based on this context. Can be async, but preferably sync. When generating async suggestions, you should pass the context along.
Parameters
Section titled “Parameters”context
Section titled “context”The context of the suggestion.
Returns
Section titled “Returns”T
[] | Promise
<T
[]>
The suggestion items.
Examples
Section titled “Examples”class MyEditorSuggest extends EditorSuggest<string> { public override getSuggestions(context: EditorSuggestContext): string[] { return ['Item 1', 'Item 2', 'Item 3']; }}
class MyEditorSuggest extends EditorSuggest<string> { public override getSuggestions(context: EditorSuggestContext): Promise<string[]> { return Promise.resolve(['Item 1', 'Item 2', 'Item 3']); }}
onTrigger()
Section titled “onTrigger()”
abstract
onTrigger(cursor
,editor
,file
):null
|EditorSuggestTriggerInfo
Defined in: obsidian.d.ts:1396
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
Section titled “Parameters”cursor
Section titled “cursor”editor
Section titled “editor”null
| TFile
Returns
Section titled “Returns”null
| EditorSuggestTriggerInfo
onTrigger__()
Section titled “onTrigger__()”onTrigger__(
cursor
,editor
,file
):null
|EditorSuggestTriggerInfo
Defined in: src/obsidian/augmentations/EditorSuggest.d.ts:88
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
Section titled “Parameters”cursor
Section titled “cursor”The cursor position.
editor
Section titled “editor”The editor instance.
The file instance.
null
| TFile
Returns
Section titled “Returns”null
| EditorSuggestTriggerInfo
The trigger info or null
if the suggestion is not supposed to be triggered.
Example
Section titled “Example”class MyEditorSuggest extends EditorSuggest<string> { public override onTrigger(cursor: EditorPosition, editor: Editor, file: TFile | null): EditorSuggestTriggerInfo | null { return { start: cursor, end: cursor, query: file?.basename ?? '' }; }}
open()
Section titled “open()”Call Signature
Section titled “Call Signature”open():
void
Defined in: obsidian.d.ts:3407
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”Call Signature
Section titled “Call Signature”open():
void
Defined in: src/obsidian/augmentations/PopoverSuggest.d.ts:69
Opens the popover.
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”renderSuggestion()
Section titled “renderSuggestion()”
abstract
renderSuggestion(value
,el
):void
Defined in: obsidian.d.ts:3415
Render the suggestion item into DOM.
Parameters
Section titled “Parameters”T
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”PopoverSuggest
.renderSuggestion
renderSuggestion__()
Section titled “renderSuggestion__()”renderSuggestion__(
value
,el
):void
Defined in: src/obsidian/augmentations/PopoverSuggest.d.ts:88
Render the suggestion.
Parameters
Section titled “Parameters”T
The value to render.
The element to render the suggestion to.
Returns
Section titled “Returns”void
Example
Section titled “Example”class MyPopoverSuggest extends PopoverSuggest<string> { public override renderSuggestion(value: string, el: HTMLElement): void { el.createEl('strong', { text: value }); }}
Inherit Doc
Section titled “Inherit Doc”Inherited from
Section titled “Inherited from”PopoverSuggest
.renderSuggestion__
selectSuggestion()
Section titled “selectSuggestion()”
abstract
selectSuggestion(value
,evt
):void
Defined in: obsidian.d.ts:3420
Called when the user makes a selection.
Parameters
Section titled “Parameters”T
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”PopoverSuggest
.selectSuggestion
selectSuggestion__()
Section titled “selectSuggestion__()”selectSuggestion__(
value
,evt
):void
Defined in: src/obsidian/augmentations/PopoverSuggest.d.ts:107
Select the suggestion.
Parameters
Section titled “Parameters”T
The value to select.
The event that triggered the selection.
Returns
Section titled “Returns”void
Example
Section titled “Example”class MyPopoverSuggest extends PopoverSuggest<string> { public override selectSuggestion(value: string, evt: MouseEvent | KeyboardEvent): void { console.log(value); }}
Inherit Doc
Section titled “Inherit Doc”Inherited from
Section titled “Inherited from”PopoverSuggest
.selectSuggestion__
setInstructions()
Section titled “setInstructions()”Call Signature
Section titled “Call Signature”setInstructions(
instructions
):void
Defined in: obsidian.d.ts:1385
Parameters
Section titled “Parameters”instructions
Section titled “instructions”Returns
Section titled “Returns”void
Call Signature
Section titled “Call Signature”setInstructions(
instructions
):void
Defined in: src/obsidian/augmentations/EditorSuggest.d.ts:100
Set the instructions for the suggestion.
Parameters
Section titled “Parameters”instructions
Section titled “instructions”The instructions for the suggestion.
Returns
Section titled “Returns”void
Example
Section titled “Example”suggest.setInstructions([{ command: '↑↓', purpose: 'Navigate' }]);
showSuggestions()
Section titled “showSuggestions()”showSuggestions(
results
):void
Defined in: src/obsidian/augmentations/EditorSuggest.d.ts:107
Show suggestions.
Parameters
Section titled “Parameters”results
Section titled “results”Returns
Section titled “Returns”void