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

Property Type Description
_children Component[] Child Components attached to current component, will be unloaded on unloading parent component.
(Inherited from View)
_events EventRef[] Events that are attached to the current component, will be detached on unloading parent component.
(Inherited from View)
_loaded boolean Whether the component and its children are loaded.
(Inherited from View)
app App The Obsidian app instance.
(Inherited from View)
closeable boolean Whether the leaf may close the view.
(Inherited from View)
containerEl HTMLElement The container HTML element for the component.
(Inherited from View)
icon IconName The icon of the view.
(Inherited from View)
leaf WorkspaceLeaf The leaf of the view.
(Inherited from View)
navigation boolean Whether 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)
scope null | Scope Assign an optional scope to your view to register hotkeys for when the view is in focus.
(Inherited from View)

Methods

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

(Replaces the previously removed onHeaderMenu and onMoreOptionsMenu)
(Inherited from View)
onResize() void Called when the size of this view is changed.
(Inherited from View)
onTabHeaderClick() void Called when the tap header is clicked. Brings this tab to the front.
onTabMenu(menu) void Adds the menu items to the menu.
(Inherited from View)
onunload() void Override this to unload your component
(Inherited from View)
open(parentEl) Promise<void> Opens the view.
(Inherited from View)
register(cb) void Registers a callback to be called when unloading.
(Inherited from View)
registerDomEvent(el, type, callback, options?) void Registers a DOM event to be detached when unloading.
(Inherited from View)
registerDomEvent(el, type, callback, options?) void Registers a DOM event to be detached when unloading
(Inherited from View)
registerDomEvent(el, type, callback, options?) void Registers a DOM event to be detached when unloading
(Inherited from View)
registerEvent(eventRef) void Registers an event to be detached when unloading.
(Inherited from View)
registerInterval(id) number Registers 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) void Register a scope keymap event handler to be removed on unload.
(Inherited from View)
removeChild(component) T Removes a child component, unloading it.
(Inherited from View)
renderSearchInfo(e, parentEl) void Render search metadata information into the given parent element.
saveSearch() void Saves the current search string to the recent searches in Local Storage.
setCollapseAll(e) void Set whether all search results are collapsed.
setEphemeralState(state) void Set the ephemeral state of the view.
(Inherited from View)
setExplainSearch(e) void Toggle the search query explanation display.
setExtraContext(e) void Set whether extra context lines are shown around matches.
setMatchingCase(e) void Set whether the search is case-sensitive.
setQuery(value) void Sets the value of the search element.
setSortOrder(sortOrder) void Set the sort order for search results.
setState(state, result) Promise<void> Set the state of the view.
(Inherited from View)
startSearch() void Starts the search and renders the results.
stopSearch() void Stops the search and clears the results.
toggleFilterSection() void Toggles the visibility of the filter section. Called if clicked on 'Search settings'.
unload() void Override this to unload your component.
(Inherited from View)

Links to this page: