Skip to content

SearchView

Unofficial

obsidian#View that displays the global search results pane.

Import:

import type { SearchView } from '@obsidian-typings/obsidian-public-latest';

Signature:

export interface SearchView extends View

Extends: View

Constructor

new SearchView(leaf: WorkspaceLeaf)

Constructor.

To extract the constructor type, use ExtractConstructor<View>.

Properties

PropertyTypeDescription
_childrenComponent[]Child Components attached to current component, will be unloaded on unloading parent component.
(Inherited from View)
_eventsEventRef[]Events that are attached to the current component, will be detached on unloading parent component.
(Inherited from View)
_loadedbooleanWhether the component and its children are loaded.
(Inherited from View)
appAppThe Obsidian app instance.
(Inherited from View)
closeablebooleanWhether the leaf may close the view.
(Inherited from View)
containerElHTMLElementThe container HTML element for the component.
(Inherited from View)
iconIconNameThe icon of the view.
(Inherited from View)
leafWorkspaceLeafThe leaf of the view.
(Inherited from View)
navigationbooleanWhether or not the view is intended for navigation. If your view is a static view that is not intended to be navigated away, set this to false. (For example: File explorer, calendar, etc.) If your view opens a file or can be otherwise navigated, set this to true. (For example: Markdown editor view, Kanban view, PDF view, etc.)
(Inherited from View)
scopenull | ScopeAssign an optional scope to your view to register hotkeys for when the view is in focus.
(Inherited from View)

Methods

MethodReturnsDescription
addChild(component)TAdds a child component, loading it if this component is loaded.
(Inherited from View)
close()Promise<void>Closes the view.
(Inherited from View)
getDisplayText()stringGet the display text of the view.
(Inherited from View)
getEphemeralState()Record<string, unknown>Get the ephemeral state of the view.
(Inherited from View)
getIcon()IconNameGet the icon of the view.
(Inherited from View)
getQuery()stringReturns the value of the search element.
getSideTooltipPlacement()'left' | 'right' | undefinedReturns the placement of the tooltip.
(Inherited from View)
getState()Record<string, unknown>Get the state of the view.
(Inherited from View)
getViewType()typeof ViewType.SearchGet the current view type.
handleCopy(event)voidHandle copy event on metadata editor and serialize properties.
(Inherited from View)
handleCut(event)voidHandle cut event on metadata editor and serialize and remove properties.
(Inherited from View)
handlePaste(event)voidHandle paste event of properties on metadata editor.
(Inherited from View)
load()voidLoad this component and its children.
(Inherited from View)
onClose()Promise<void>Called when the view is closed.
(Inherited from View)
onCopyResultsClick(event)voidHandle the copy search results button click.
onHeaderMenu(e)voidCalled when the header context menu is triggered.
(Inherited from View)
onKeyArrowDownInFocus(event)voidHandle the down arrow key when a search result is focused.
onKeyArrowLeftInFocus(event)voidHandle the left arrow key when a search result is focused.
onKeyArrowRightInFocus(event)voidHandle the right arrow key when a search result is focused.
onKeyArrowUpInFocus(event)voidHandle the up arrow key when a search result is focused.
onKeyEnterInFocus(event)voidHandle the enter key when a search result is focused.
onKeyShowMoreAfter(e)voidShow more context lines after a match.
onKeyShowMoreBefore(e)voidShow more context lines before a match.
onload()voidOverride this to load your component.
(Inherited from View)
onOpen()Promise<void>Called when the view is opened.
(Inherited from View)
onPaneMenu(menu, source)voidPopulates the pane menu.

(Replaces the previously removed onHeaderMenu and onMoreOptionsMenu)
(Inherited from View)
onResize()voidCalled when the size of this view is changed.
(Inherited from View)
onTabHeaderClick()voidCalled when the tap header is clicked. Brings this tab to the front.
onTabMenu(menu)voidAdds the menu items to the menu.
(Inherited from View)
onunload()voidOverride this to unload your component
(Inherited from View)
open(parentEl)Promise<void>Opens the view.
(Inherited from View)
register(cb)voidRegisters a callback to be called when unloading.
(Inherited from View)
registerDomEvent(el, type, callback, options?)voidRegisters a DOM event to be detached when unloading.
(Inherited from View)
registerDomEvent(el, type, callback, options?)voidRegisters a DOM event to be detached when unloading
(Inherited from View)
registerDomEvent(el, type, callback, options?)voidRegisters a DOM event to be detached when unloading
(Inherited from View)
registerEvent(eventRef)voidRegisters an event to be detached when unloading.
(Inherited from View)
registerInterval(id)numberRegisters an interval (from setInterval) to be cancelled when unloading. Use window.setInterval instead of setInterval to avoid TypeScript confusing between NodeJS vs Browser API
(Inherited from View)
registerScopeEvent(keymapEventHandler)voidRegister a scope keymap event handler to be removed on unload.
(Inherited from View)
removeChild(component)TRemoves a child component, unloading it.
(Inherited from View)
renderSearchInfo(e, parentEl)voidRender search metadata information into the given parent element.
saveSearch()voidSaves the current search string to the recent searches in Local Storage.
setCollapseAll(e)voidSet whether all search results are collapsed.
setEphemeralState(state)voidSet the ephemeral state of the view.
(Inherited from View)
setExplainSearch(e)voidToggle the search query explanation display.
setExtraContext(e)voidSet whether extra context lines are shown around matches.
setMatchingCase(e)voidSet whether the search is case-sensitive.
setQuery(value)voidSets the value of the search element.
setSortOrder(sortOrder)voidSet the sort order for search results.
setState(state, result)Promise<void>Set the state of the view.
(Inherited from View)
startSearch()voidStarts the search and renders the results.
stopSearch()voidStops the search and clears the results.
toggleFilterSection()voidToggles the visibility of the filter section. Called if clicked on 'Search settings'.
unload()voidOverride this to unload your component.
(Inherited from View)

Links to this page: