Skip to content

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 FileSuggestModal

Extends: FileSuggestModal

Constructor

new QuickSwitcherModal(app: App, options: SwitcherPluginOptions)

Constructor.

Properties

PropertyTypeDescription
allowCreateNewFilebooleanWhether the modal may create a new file named after the query.
(Inherited from FileSuggestModal)
appAppThe Obsidian app instance.
(Inherited from FileSuggestModal)
bgElHTMLElementBackground applied to application to dim it
(Inherited from FileSuggestModal)
bgOpacitystringOpacity percentage of the background
(Inherited from FileSuggestModal)
chooserSuggestModalChooser<FileSuggestModalSuggestion | null, this>The suggestion chooser that manages selection and rendering.
(Inherited from FileSuggestModal)
clearButtonElHTMLDivElementButton element to clear the input field.
(Inherited from FileSuggestModal)
containerElHTMLElementThe container HTML element for the modal.
(Inherited from FileSuggestModal)
contentElHTMLElementThe 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)
createButtonElHTMLButtonElementThe "create file" button, shown in the input on mobile while FileSuggestModal.allowCreateNewFile is true.
(Inherited from FileSuggestModal)
ctaElHTMLDivElementCall-to-action element displayed in the modal.
(Inherited from FileSuggestModal)
dimBackgroundbooleanWhether the background is being dimmed
(Inherited from FileSuggestModal)
emptyStateTextstringThe text to display when there are no suggestions.
(Inherited from FileSuggestModal)
hasInitialInputFocusbooleanWhether the modal focuses its first input when opened.
(Inherited from FileSuggestModal)
headerElHTMLDivElementHeader element of the modal dialog.
(Inherited from FileSuggestModal)
inputElHTMLInputElementThe input element.
(Inherited from FileSuggestModal)
instructionsElHTMLDivElementElement displaying keyboard shortcut instructions.
(Inherited from FileSuggestModal)
isAnimatedbooleanWhether the current opening animates, set from Modal.canAnimate on each Modal.open; it also gates swipe-to-dismiss on the header.
(Inherited from FileSuggestModal)
isOpenbooleanWhether the suggest modal is currently open.
(Inherited from FileSuggestModal)
limitnumberThe limit of the number of suggestions.
(Inherited from FileSuggestModal)
modalElHTMLElementThe HTML element that represents the modal.
(Inherited from FileSuggestModal)
resultContainerElHTMLElementThe result container element.
(Inherited from FileSuggestModal)
scopeScopeThe scope for the keymaps.
(Inherited from FileSuggestModal)
selectionnull | WindowSelectionSelection logic handler
(Inherited from FileSuggestModal)
shouldAnimateOpenbooleanWhether opening the modal should animate.
(Inherited from FileSuggestModal)
shouldRestoreSelectionbooleanWhether the modal should restore the selection when it is opened or closed.
(Inherited from FileSuggestModal)
shouldShowAliasbooleanWhether the frontmatter aliases of each file are matched against the query as well.
(Inherited from FileSuggestModal)
shouldShowAllTypesbooleanWhether files of every extension are offered, registered or not, when FileSuggestModal.shouldShowNonImageAttachments is true.
(Inherited from FileSuggestModal)
shouldShowImagesbooleanWhether image files are offered.
(Inherited from FileSuggestModal)
shouldShowMarkdownbooleanWhether Markdown files are offered.
(Inherited from FileSuggestModal)
shouldShowNonAttachmentsbooleanWhether canvas and base files are offered.
(Inherited from FileSuggestModal)
shouldShowNonFileBookmarksbooleanWhether bookmarks that are not file bookmarks (folders, searches, graphs, URLs) are offered.
(Inherited from FileSuggestModal)
shouldShowNonImageAttachmentsbooleanWhether non-image attachments with a registered extension are offered.
(Inherited from FileSuggestModal)
shouldShowUnresolvedbooleanWhether the link text of unresolved links is offered.
(Inherited from FileSuggestModal)
supportsCreatebooleanWhether creating a new file is offered: FileSuggestModal.allowCreateNewFile and FileSuggestModal.shouldShowMarkdown are both true.
(Inherited from FileSuggestModal)
titleElHTMLElementThe HTML element that represents the title of the modal.
(Inherited from FileSuggestModal)
winnull | WindowReference to the global Window object.
(Inherited from FileSuggestModal)

Methods

MethodReturnsDescription
animateClose()Promise<void>Performed when animation is complete
(Inherited from FileSuggestModal)
animateOpen()Promise<void>Performed when animation is started
(Inherited from FileSuggestModal)
canAnimate()booleanChecks whether this device supports modal animation.
(Inherited from FileSuggestModal)
canDismiss()booleanChecks whether clicking outside may dismiss the modal.
(Inherited from FileSuggestModal)
close()voidClose the modal.
(Inherited from FileSuggestModal)
getRootEl()HTMLElementGets 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)voidOpens 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)voidChoose a suggestion.
(Inherited from FileSuggestModal)
onClickOutside(evt)voidCloses the modal when a click occurs outside of it, unless the event was already handled.
(Inherited from FileSuggestModal)
onClose()voidCalled when the modal is closed.
(Inherited from FileSuggestModal)
onEscapeKey()voidOn escape key press close modal
(Inherited from FileSuggestModal)
onHistoryBack()voidCalled when the user navigates back in the history.
(Inherited from FileSuggestModal)
onHistoryForward()voidCalled when the user navigates forward in the history.
(Inherited from FileSuggestModal)
onInput()voidHandle input change in the suggest modal.
(Inherited from FileSuggestModal)
onNoSuggestion()voidSet the callback to be called when there are no suggestions.
(Inherited from FileSuggestModal)
onOpen()Promise<void> | voidCalled when the modal is opened.
(Inherited from FileSuggestModal)
onSelectedChange(value, evt?)voidCalled after every selection change, including the programmatic one that follows SuggestModalChooser.setSuggestions.
(Inherited from FileSuggestModal)
onWindowClose()voidOn closing of the modal
(Inherited from FileSuggestModal)
open()voidShow the modal on the the active window. On phones, the modal will animate on screen.
(Inherited from FileSuggestModal)
renderSuggestion(value, el)voidRenders a suggestion.
(Inherited from FileSuggestModal)
selectActiveSuggestion(evt)voidSelect the active suggestion.
(Inherited from FileSuggestModal)
selectSuggestion(value, evt)voidSelect a suggestion.
(Inherited from FileSuggestModal)
setBackgroundOpacity(opacity)thisSet the background opacity of the dimmed background.
(Inherited from FileSuggestModal)
setCloseCallback(callback)thisSet the callback to be called when the modal is closed.
(Inherited from FileSuggestModal)
setContent(content)thisSet the content of the modal.
(Inherited from FileSuggestModal)
setDimBackground(dim)thisSet whether the background should be dimmed.
(Inherited from FileSuggestModal)
setInstructions(instructions)voidSet the instructions.
(Inherited from FileSuggestModal)
setPlaceholder(placeholder)voidSet the placeholder text.
(Inherited from FileSuggestModal)
setTitle(title)thisSet the title of the modal.
(Inherited from FileSuggestModal)
updateSuggestions()voidRefresh the displayed suggestions based on the current query.
(Inherited from FileSuggestModal)

Links to this page: