FileSuggestModal
Unofficial
Base suggest modal for choosing a file, shared by the quick switcher and the mobile “insert file” chooser.
A null suggestion stands for creating a new file named after the query, offered when nothing matches and FileSuggestModal.supportsCreate is true.
Import:
import type { FileSuggestModal } from '@obsidian-typings/obsidian-public-latest';Signature:
export interface FileSuggestModal extends SuggestModal<FileSuggestModalSuggestion | null>Extends: SuggestModal<FileSuggestModalSuggestion | null>
Constructor
new FileSuggestModal(app: App)Constructor.
Properties
| Property | Type | Description | |
|---|---|---|---|
| allowCreateNewFile | boolean | Whether the modal may create a new file named after the query. | |
| app | App | The Obsidian app instance. (Inherited from SuggestModal) | |
| bgEl | HTMLElement | Background applied to application to dim it (Inherited from SuggestModal) | |
| bgOpacity | string | Opacity percentage of the background (Inherited from SuggestModal) | |
| chooser | SuggestModalChooser<FileSuggestModalSuggestion | null, this> | The suggestion chooser that manages selection and rendering. (Inherited from SuggestModal) | |
| clearButtonEl | HTMLDivElement | Button element to clear the input field. (Inherited from SuggestModal) | |
| containerEl | HTMLElement | The container HTML element for the modal. (Inherited from SuggestModal) | |
| contentEl | HTMLElement | The HTML element that represents the content of the modal. (Inherited from SuggestModal) | |
| context | 'embed' | 'view' | Which registry decides whether a non-image attachment extension is offered: view asks the view registry, embed the embed registry. | |
| createButtonEl | HTMLButtonElement | The "create file" button, shown in the input on mobile while FileSuggestModal.allowCreateNewFile is true. | |
| ctaEl | HTMLDivElement | Call-to-action element displayed in the modal. (Inherited from SuggestModal) | |
| dimBackground | boolean | Whether the background is being dimmed (Inherited from SuggestModal) | |
| emptyStateText | string | The text to display when there are no suggestions. (Inherited from SuggestModal) | |
| hasInitialInputFocus | boolean | Whether the modal focuses its first input when opened. (Inherited from SuggestModal) | |
| headerEl | HTMLDivElement | Header element of the modal dialog. (Inherited from SuggestModal) | |
| inputEl | HTMLInputElement | The input element. (Inherited from SuggestModal) | |
| instructionsEl | HTMLDivElement | Element displaying keyboard shortcut instructions. (Inherited from SuggestModal) | |
| isAnimated | boolean | Whether the current opening animates, set from Modal.canAnimate on each Modal.open; it also gates swipe-to-dismiss on the header. (Inherited from SuggestModal) | |
| isOpen | boolean | Whether the suggest modal is currently open. (Inherited from SuggestModal) | |
| limit | number | The limit of the number of suggestions. (Inherited from SuggestModal) | |
| modalEl | HTMLElement | The HTML element that represents the modal. (Inherited from SuggestModal) | |
| resultContainerEl | HTMLElement | The result container element. (Inherited from SuggestModal) | |
| scope | Scope | The scope for the keymaps. (Inherited from SuggestModal) | |
| selection | null | WindowSelection | Selection logic handler (Inherited from SuggestModal) | |
| shouldAnimateOpen | boolean | Whether opening the modal should animate. (Inherited from SuggestModal) | |
| shouldRestoreSelection | boolean | Whether the modal should restore the selection when it is opened or closed. (Inherited from SuggestModal) | |
| shouldShowAlias | boolean | Whether the frontmatter aliases of each file are matched against the query as well. | |
| shouldShowAllTypes | boolean | Whether files of every extension are offered, registered or not, when FileSuggestModal.shouldShowNonImageAttachments is true. | |
| shouldShowImages | boolean | Whether image files are offered. | |
| shouldShowMarkdown | boolean | Whether Markdown files are offered. | |
| shouldShowNonAttachments | boolean | Whether canvas and base files are offered. | |
| shouldShowNonFileBookmarks | boolean | Whether bookmarks that are not file bookmarks (folders, searches, graphs, URLs) are offered. | |
| shouldShowNonImageAttachments | boolean | Whether non-image attachments with a registered extension are offered. | |
| shouldShowUnresolved | boolean | Whether the link text of unresolved links is offered. | |
| supportsCreate | boolean | Whether creating a new file is offered: FileSuggestModal.allowCreateNewFile and FileSuggestModal.shouldShowMarkdown are both true. | |
| titleEl | HTMLElement | The HTML element that represents the title of the modal. (Inherited from SuggestModal) | |
| win | null | Window | Reference to the global Window object. (Inherited from SuggestModal) |
Methods
| Method | Returns | Description | |
|---|---|---|---|
| animateClose() | Promise<void> | Performed when animation is complete (Inherited from SuggestModal) | |
| animateOpen() | Promise<void> | Performed when animation is started (Inherited from SuggestModal) | |
| canAnimate() | boolean | Checks whether this device supports modal animation. (Inherited from SuggestModal) | |
| canDismiss() | boolean | Checks whether clicking outside may dismiss the modal. (Inherited from SuggestModal) | |
| close() | void | Close the modal. (Inherited from SuggestModal) | |
| getRootEl() | HTMLElement | Gets the modal's root element. (Inherited from SuggestModal) | |
| getSuggestions(query) | FileSuggestModalSuggestion[] | Gets the suggestions for a query. The query is trimmed first. An empty query returns the recent files that are offered and not excluded by the user, with a null match. Otherwise every offered vault file is fuzzy-matched by its path (without the .md extension), and, when FileSuggestModal.shouldShowAlias is true, by each of its frontmatter aliases; a file excluded by the user is kept but its score is lowered by 10. Unresolved link text and bookmarks are added when enabled, and the result is sorted by descending score. | |
| onChooseSuggestion(item, evt) | void | Choose a suggestion. (Inherited from SuggestModal) | |
| onClickOutside(evt) | void | Closes the modal when a click occurs outside of it, unless the event was already handled. (Inherited from SuggestModal) | |
| onClose() | void | Called when the modal is closed. (Inherited from SuggestModal) | |
| onEscapeKey() | void | On escape key press close modal (Inherited from SuggestModal) | |
| onHistoryBack() | void | Called when the user navigates back in the history. (Inherited from SuggestModal) | |
| onHistoryForward() | void | Called when the user navigates forward in the history. (Inherited from SuggestModal) | |
| onInput() | void | Handle input change in the suggest modal. (Inherited from SuggestModal) | |
| onNoSuggestion() | void | Set the callback to be called when there are no suggestions. (Inherited from SuggestModal) | |
| onOpen() | Promise<void> | void | Called when the modal is opened. (Inherited from SuggestModal) | |
| onSelectedChange(value, evt?) | void | Called after every selection change, including the programmatic one that follows SuggestModalChooser.setSuggestions. (Inherited from SuggestModal) | |
| onWindowClose() | void | On closing of the modal (Inherited from SuggestModal) | |
| open() | void | Show the modal on the the active window. On phones, the modal will animate on screen. (Inherited from SuggestModal) | |
| renderSuggestion(value, el) | void | Renders a suggestion. | |
| renderSuggestion(value, el) | void | Render a suggestion. (Inherited from SuggestModal) | |
| selectActiveSuggestion(evt) | void | Select the active suggestion. (Inherited from SuggestModal) | |
| selectSuggestion(value, evt) | void | Select a suggestion. (Inherited from SuggestModal) | |
| setBackgroundOpacity(opacity) | this | Set the background opacity of the dimmed background. (Inherited from SuggestModal) | |
| setCloseCallback(callback) | this | Set the callback to be called when the modal is closed. (Inherited from SuggestModal) | |
| setContent(content) | this | Set the content of the modal. (Inherited from SuggestModal) | |
| setDimBackground(dim) | this | Set whether the background should be dimmed. (Inherited from SuggestModal) | |
| setInstructions(instructions) | void | Set the instructions. (Inherited from SuggestModal) | |
| setPlaceholder(placeholder) | void | Set the placeholder text. (Inherited from SuggestModal) | |
| setTitle(title) | this | Set the title of the modal. (Inherited from SuggestModal) | |
| updateSuggestions() | void | Refresh the displayed suggestions based on the current query. (Inherited from SuggestModal) |
Links to this page: