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