SuggestModal<T>
Official
A suggest modal.
Import:
import { SuggestModal } from 'obsidian';Signature:
export class SuggestModal<T> extends Modal implements ISuggestOwner<T>Extends: Modal
Implements: ISuggestOwner<T>
Constructor
new SuggestModal(app: App)Constructor.
To extract the constructor type, use ExtractConstructor<SuggestModal>.
Properties
| Property | Type | Description | |
|---|---|---|---|
| app | App | The Obsidian app instance. (Inherited from Modal) | |
| bgEl | HTMLElement | Background applied to application to dim it (Inherited from Modal) | |
| bgOpacity | string | Opacity percentage of the background (Inherited from Modal) | |
| chooser | SuggestModalChooser<T, this> | The suggestion chooser that manages selection and rendering. | |
| clearButtonEl | HTMLDivElement | Button element to clear the input field. | |
| containerEl | HTMLElement | The container HTML element for the modal. (Inherited from Modal) | |
| contentEl | HTMLElement | The HTML element that represents the content of the modal. (Inherited from Modal) | |
| ctaEl | HTMLDivElement | Call-to-action element displayed in the modal. | |
| dimBackground | boolean | Whether the background is being dimmed (Inherited from Modal) | |
| emptyStateText | string | The text to display when there are no suggestions. | |
| hasInitialInputFocus | boolean | Whether the modal focuses its first input when opened. (Inherited from Modal) | |
| headerEl | HTMLDivElement | Header element of the modal dialog. (Inherited from Modal) | |
| inputEl | HTMLInputElement | The input element. | |
| instructionsEl | HTMLDivElement | Element displaying keyboard shortcut instructions. | |
| isOpen | boolean | Whether the suggest modal is currently open. | |
| limit | number | The limit of the number of suggestions. | |
| modalEl | HTMLElement | The HTML element that represents the modal. (Inherited from Modal) | |
| resultContainerEl | HTMLElement | The result container element. | |
| scope | Scope | The scope for the keymaps. (Inherited from Modal) | |
| selection | null | WindowSelection | Selection logic handler (Inherited from Modal) | |
| shouldAnimate | boolean | Whether the modal should animate (Inherited from Modal) | |
| shouldRestoreSelection | boolean | Whether the modal should restore the selection when it is opened or closed. (Inherited from Modal) | |
| titleEl | HTMLElement | The HTML element that represents the title of the modal. (Inherited from Modal) | |
| win | null | Window | Reference to the global Window object. (Inherited from Modal) |
Methods
| Method | Returns | Description | |
|---|---|---|---|
| animateClose() | Promise<void> | Performed when animation is complete (Inherited from Modal) | |
| animateOpen() | Promise<void> | Performed when animation is started (Inherited from Modal) | |
| close() | void | Close the modal. (Inherited from Modal) | |
| getRootEl() | HTMLElement | Gets the modal's root element. (Inherited from Modal) | |
| getSuggestions(query) | Promise<T[]> | T[] | Get the suggestions. | |
| onChooseSuggestion(item, evt) | void | Choose a suggestion. | |
| onClickOutside(evt) | void | Closes the modal when a click occurs outside of it, unless the event was already handled. (Inherited from Modal) | |
| onClose() | void | Called when the modal is closed. (Inherited from Modal) | |
| onEscapeKey() | void | On escape key press close modal (Inherited from Modal) | |
| onHistoryBack() | void | Called when the user navigates back in the history. (Inherited from Modal) | |
| onHistoryForward() | void | Called when the user navigates forward in the history. (Inherited from Modal) | |
| onInput() | void | Handle input change in the suggest modal. | |
| onNoSuggestion() | void | Set the callback to be called when there are no suggestions. | |
| onOpen() | Promise<void> | void | Called when the modal is opened. (Inherited from Modal) | |
| onWindowClose() | void | On closing of the modal (Inherited from Modal) | |
| open() | void | Show the modal on the the active window. On phones, the modal will animate on screen. (Inherited from Modal) | |
| renderSuggestion(value, el) | void | Render a suggestion. | |
| selectActiveSuggestion(evt) | void | Select the active suggestion. | |
| selectSuggestion(value, evt) | void | Select a suggestion. | |
| setBackgroundOpacity(opacity) | this | Set the background opacity of the dimmed background. (Inherited from Modal) | |
| setCloseCallback(callback) | this | Set the callback to be called when the modal is closed. (Inherited from Modal) | |
| setContent(content) | this | Set the content of the modal. (Inherited from Modal) | |
| setDimBackground(dim) | this | Set whether the background should be dimmed. (Inherited from Modal) | |
| setInstructions(instructions) | void | Set the instructions. | |
| setPlaceholder(placeholder) | void | Set the placeholder text. | |
| setTitle(title) | this | Set the title of the modal. (Inherited from Modal) | |
| updateSuggestions() | void | Refresh the displayed suggestions based on the current query. |
Links to this page: