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

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)
fileItems FileExplorerViewFileItemsRecord Mapping of file path to tree item.
files WeakMapWrapper<HTMLElement, TAbstractFile> Mapping of tree self element to abstract file.
icon IconName The icon of the view.
(Inherited from View)
lastDropTargetEl HTMLElement | null Last dragged over folder item element. null when there is no folder item being dragged over.
leaf WorkspaceLeaf The leaf of the view.
(Inherited from View)
mouseoverExpandTimeout null | number Timeout ID for expanding a folder on mouseover during drag, or null.
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)
ready boolean Indicate ready state of the view.
requestSort Debouncer<[], void> Try to sort tree items.
scope null | Scope Assign an optional scope to your view to register hotkeys for when the view is in focus.
(Inherited from View)
sortOrder FileExplorerViewSortOrder Current sort order of file tree items.
tree Tree<FileTreeItem | FolderTreeItem> Tree view of files.

Methods

Method Returns Description
acceptRename() Promise<void> Try to rename the file.
addChild(component) T Adds 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) void Used internally to attach drop handler to the tree root and folder items.
attachFileEvents(e) void Attach 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) unknown Create a tree item DOM element for the given folder.
createItemDom(file) unknown Create a tree item DOM element for the given file.
displayError(message, fileItem) void Display an error message on a file tree item.
dragFiles(event, t) unknown Handle dragging files from the file explorer.
exitRename() void Quits the rename.
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)
getNodeId(e) unknown Get the unique node identifier for a tree item.
getSideTooltipPlacement() 'left' | 'right' | undefined Returns 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.FileExplorer 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)
isItem(item) boolean Check whether the given object is a file tree item.
load() void Load this component and its children.
(Inherited from View)
onClose() Promise<void> Called when the view is closed.
(Inherited from View)
onCreate(file) void Is 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) void Is called when a file in vault is deleted. Updates the file tree.
onDeleteSelectedFiles(event) unknown Called when delete is requested.
onExtensionsUpdated() void Called when a extensions update is triggered. Event: 'extensions-updated'.
onFileMouseout(event, targetEl) void Called when the mouse pointer moves away from an element. Event: 'mouseout'.
onFileMouseover(event, targetEl) void Called when the mouse pointer is moved over an element. Updates the tooltip information. Event: 'mouseover'.
onFileOpen(file) void Called when a file is opened. Brings the file to the front.
onFileRenameInput(e) void Handle input events in the file rename text field.
onHeaderMenu(e) void Called when the header context menu is triggered.
(Inherited from View)
onKeyEnterInRename(event) void Called when 'Enter' is pressed while rename. Accepts the rename.
onKeyEscInRename() void Called when 'ESC' is pressed while rename. Denies the rename.
onKeyRename(event) void Called when the rename shortcut is pressed.
onload() void Override this to load your component.
(Inherited from View)
onModify() void Request a sort if not sorted properly.
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)
onRename(file, oldPath) void Is called when a file in vault is renamed. Updates the file tree.
onResize() void Called when the size of this view is changed.
(Inherited from View)
onTabMenu(menu) void Adds the menu items to the menu.
(Inherited from View)
onTitleBlur() void Called when the title is deselected. Calls acceptRename().
onunload() void Override this to unload your component
(Inherited from View)
open(parentEl) Promise<void> Opens the view.
(Inherited from View)
openFileContextMenu(event, fileItemEl) void Opens the context menu for the file item.
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)
revealInFolder(file) void Reveal a file or folder in the file tree.
setEphemeralState(state) void Set the ephemeral state of the view.
(Inherited from View)
setIsAllCollapsed(e) void Set whether all folders are collapsed.
setSortOrder(order) void Updates the sort order and sort by it.
setState(state, result) Promise<void> Set the state of the view.
(Inherited from View)
sort() void Sorts the file items in this view.
startRenameFile(e) unknown Begin inline renaming of a file tree item.
unload() void Override this to unload your component.
(Inherited from View)
updateConfig() void Reloads the config from vault and update all items.

Links to this page: