Skip to content

FileExplorerView

Unofficial

obsidian#View that renders the file explorer tree sidebar for navigating vault files and folders.

Import:

import type { FileExplorerView } from '@obsidian-typings/obsidian-catalyst-latest';

Signature:

export interface FileExplorerView extends View

Extends: View

Constructor

new FileExplorerView(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)
fileItemsFileExplorerViewFileItemsRecordMapping of file path to tree item.
filesWeakMapWrapper<HTMLElement, TAbstractFile>Mapping of tree self element to abstract file.
iconIconNameThe icon of the view.
(Inherited from View)
lastDropTargetElHTMLElement | nullLast dragged over folder item element. null when there is no folder item being dragged over.
leafWorkspaceLeafThe leaf of the view.
(Inherited from View)
mouseoverExpandTimeoutnull | numberTimeout ID for expanding a folder on mouseover during drag, or null.
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)
readybooleanIndicate ready state of the view.
requestSortDebouncer<[], void>Try to sort tree items.
scopenull | ScopeAssign an optional scope to your view to register hotkeys for when the view is in focus.
(Inherited from View)
searchQuerynull | ObsidianSearchQueryThe active filter query for the file explorer, or null when no filter is applied.
sortOrderFileExplorerViewSortOrderCurrent sort order of file tree items.
treeTree<FileTreeItem | FolderTreeItem>Tree view of files.

Methods

MethodReturnsDescription
acceptRename()Promise<void>Try to rename the file.
addChild(component)TAdds a child component, loading it if this component is loaded.
(Inherited from View)
afterCreate(file, newLeaf)Promise<void>Is Executed after creating the file or folder and opens the view and/or starts the rename.
attachDropHandler(folder, el)voidUsed internally to attach drop handler to the tree root and folder items.
attachFileEvents(e)voidAttach file-related event listeners to an element.
close()Promise<void>Closes the view.
(Inherited from View)
createAbstractFile(type, location, newLeaf)Promise<void>Creates an file or folder.
createFolderDom(folder)unknownCreate a tree item DOM element for the given folder.
createItemDom(file)unknownCreate a tree item DOM element for the given file.
displayError(message, fileItem)voidDisplay an error message on a file tree item.
dragFiles(event, t)unknownHandle dragging files from the file explorer.
exitRename()voidQuits the rename.
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)
getNodeId(e)unknownGet the unique node identifier for a tree item.
getSideTooltipPlacement()'left' | 'right' | undefinedReturns the placement of the tooltip.
(Inherited from View)
getSortedFolderItems(folder)FileTreeItem[]Get a sorted list of the tree items for a specific folder).
getState()Record<string, unknown>Get the state of the view.
(Inherited from View)
getViewType()typeof ViewType.FileExplorerGet 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)
isItem(item)booleanCheck whether the given object is a file tree item.
load()voidLoad this component and its children.
(Inherited from View)
onClose()Promise<void>Called when the view is closed.
(Inherited from View)
onCreate(file)voidIs called when a new file is created in vault. Updates the file tree.
onCreateNewFolderClick(event)Promise<void>Is called when on the new folder icon is clicked. Call createAbstractFile().
onCreateNewNoteClick(event)Promise<void>Is called when on the new note icon is clicked. Call createAbstractFile().
onDelete(file)voidIs called when a file in vault is deleted. Updates the file tree.
onDeleteSelectedFiles(event)unknownCalled when delete is requested.
onExtensionsUpdated()voidCalled when a extensions update is triggered. Event: 'extensions-updated'.
onFileMouseout(event, targetEl)voidCalled when the mouse pointer moves away from an element. Event: 'mouseout'.
onFileMouseover(event, targetEl)voidCalled when the mouse pointer is moved over an element. Updates the tooltip information. Event: 'mouseover'.
onFileOpen(file)voidCalled when a file is opened. Brings the file to the front.
onFileRenameInput(e)voidHandle input events in the file rename text field.
onHeaderMenu(e)voidCalled when the header context menu is triggered.
(Inherited from View)
onKeyEnterInRename(event)voidCalled when 'Enter' is pressed while rename. Accepts the rename.
onKeyEscInRename()voidCalled when 'ESC' is pressed while rename. Denies the rename.
onKeyRename(event)voidCalled when the rename shortcut is pressed.
onload()voidOverride this to load your component.
(Inherited from View)
onModify()voidRequest a sort if not sorted properly.
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)
onRename(file, oldPath)voidIs called when a file in vault is renamed. Updates the file tree.
onResize()voidCalled when the size of this view is changed.
(Inherited from View)
onTabMenu(menu)voidAdds the menu items to the menu.
(Inherited from View)
onTitleBlur()voidCalled when the title is deselected. Calls acceptRename().
onunload()voidOverride this to unload your component
(Inherited from View)
open(parentEl)Promise<void>Opens the view.
(Inherited from View)
openFileContextMenu(event, fileItemEl)voidOpens the context menu for the file item.
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)
revealInFolder(file)voidReveal a file or folder in the file tree.
setEphemeralState(state)voidSet the ephemeral state of the view.
(Inherited from View)
setIsAllCollapsed(e)voidSet whether all folders are collapsed.
setSortOrder(order)voidUpdates the sort order and sort by it.
setState(state, result)Promise<void>Set the state of the view.
(Inherited from View)
sort()voidSorts the file items in this view.
startRenameFile(e)unknownBegin inline renaming of a file tree item.
unload()voidOverride this to unload your component.
(Inherited from View)
updateConfig()voidReloads the config from vault and update all items.

Links to this page: