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-public-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)
_revealActiveFileQueuedbooleanWhether revealing the active file is deferred until the view is shown.
_sortQueuedbooleanWhether sorting is deferred until the view is shown.
activeDomFileTreeItem | FolderTreeItem | null | undefinedThe active file row, or no row when the active file is absent from the tree.
appAppThe Obsidian app instance.
(Inherited from View)
autoRevealButtonElHTMLDivElementButton that toggles revealing the active file.
autoRevealFilebooleanWhether the active file is automatically revealed.
collapseOrExpandAllElHTMLDivElementButton that collapses or expands all folders.
containerElHTMLElementThe container HTML element for the component.
(Inherited from View)
fileBeingRenamednull | TAbstractFileThe file or folder being renamed, or null.
fileItemsFileExplorerViewFileItemsRecordMapping of file path to tree item.
fileRenameScopeScopeKeyboard scope used during inline renaming.
filesWeakMapWrapper<HTMLElement, TAbstractFile>Mapping of tree self element to abstract file.
headerDomHeaderDomNavigation header containing the view controls.
iconIconNameThe icon of the view.
(Inherited from View)
itemsBeingCut(FileTreeItem | FolderTreeItem)[]Tree items marked by the last cut, cleared once they are pasted.
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.
navFileContainerElHTMLDivElementContainer for the file tree.
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)
searchNavigationSearchSearch visibility and input controls.
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.
workQueuePromisedQueueQueue serializing file tree updates.

Methods

MethodReturnsDescription
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.
close()Promise<void>Closes the view.
(Inherited from View)
createAbstractFile(type, location, newLeaf)Promise<void>Creates an file or folder.
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 | FolderTreeItem)[]Get a sorted list of the tree items for a specific folder's direct children, subfolders first.
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)
onConfigChanged(key)voidHandle a vault configuration change.
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'.
onFileClick($event, targetEl)voidHandle a click on a file or folder title.
onFileContextMenu($event, file)voidBuild and show the context menu for a file or folder. When the file is one of several selected items, shows the multi-file menu (files-menu) for the whole selection instead of the file-menu.
onFileOpen(file)voidCalled when a file is opened. Brings the file to the front.
onFilePointerout($event, targetEl)voidDismiss the title tooltip when the pointer leaves.
onFilePointerover($event, targetEl)voidShow the file or folder title tooltip.
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)
onSearchChanged(query)voidCalled when the filter query changes. Compiles it into FileExplorerView.searchQuery and filters the tree by file path.
onTabMenu(menu)voidAdds the menu items to the menu.
(Inherited from View)
onTitleBlur()voidSave the inline rename when the title loses focus.
onToggleAutoReveal()voidToggle automatic revealing and save the layout.
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)
revealActiveFile()voidExpand ancestors and scroll the active file into view.
revealInFolder(file)voidReveal a file or folder in the file tree.
saveRename()Promise<boolean>Save the current inline rename.
setAutoReveal(value)voidSet whether the active file is revealed automatically.
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)
showSearch()voidShow and focus the search input.
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)
updateShowUnsupportedFiles()voidRefresh unsupported-file visibility and tree layout.

Links to this page: