SuggestionContainer<T>
Unofficial
Container for displaying and navigating editor suggestion items.
Import:
import type { SuggestionContainer } from '@obsidian-typings/obsidian-public-latest';Signature:
export interface SuggestionContainer<T>Properties
| Property | Type | Description | |
|---|---|---|---|
| chooser | EditorSuggest<T> | Which suggestions should be picked from. | |
| containerEl | HTMLElement | Pop-up element that displays the suggestions. | |
| selectedItem | number | The currently focused item. | |
| suggestions | HTMLElement[] | List of all possible suggestions as elements. | |
| values | SearchResult[] | List of all possible suggestions as data. |
Methods
| Method | Returns | Description | |
|---|---|---|---|
| addMessage(text) | HTMLElement | Add an empty message with provided text. | |
| addSuggestion(suggestion) | void | Add suggestion to container. | |
| forceSetSelectedItem(index, event) | void | Set selected item to one specified by index, if keyboard navigation, force scroll into view. | |
| getSelectedElement() | HTMLElement | null | Get the DOM element of the currently selected suggestion. | |
| getSelectedValue() | null | SearchResult | Get the data value of the currently selected suggestion. | |
| moveDown(event) | boolean | Move selected item to next suggestion. | |
| moveUp(event) | boolean | Move selected item to previous suggestion. | |
| onSuggestionClick(event, element) | void | Process click on suggestion item. | |
| onSuggestionMouseover(event, element) | unknown | Process hover on suggestion item. | |
| pageDown(event) | boolean | Move selected item to the one in the next 'page' (next visible block). | |
| pageUp(event) | boolean | Move selected item to the one in the previous 'page' (previous visible block). | |
| setSelectedItem(index, event) | void | Set selected item to one specified by index, invokes forceSetSelectedItem. | |
| setSuggestions(suggestions) | void | Empties original container and adds multiple suggestions. | |
| useSelectedItem(event) | boolean | Use currently selected suggestion as the accepted one. |
Links to this page: