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 ViewExtends: 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) | |
| _revealActiveFileQueued | boolean | Whether revealing the active file is deferred until the view is shown. | |
| _sortQueued | boolean | Whether sorting is deferred until the view is shown. | |
| activeDom | FileTreeItem | FolderTreeItem | null | undefined | The active file row, or no row when the active file is absent from the tree. | |
| app | App | The Obsidian app instance. (Inherited from View) | |
| autoRevealButtonEl | HTMLDivElement | Button that toggles revealing the active file. | |
| autoRevealFile | boolean | Whether the active file is automatically revealed. | |
| collapseOrExpandAllEl | HTMLDivElement | Button that collapses or expands all folders. | |
| containerEl | HTMLElement | The container HTML element for the component. (Inherited from View) | |
| fileBeingRenamed | null | TAbstractFile | The file or folder being renamed, or null. | |
| fileItems | FileExplorerViewFileItemsRecord | Mapping of file path to tree item. | |
| fileRenameScope | Scope | Keyboard scope used during inline renaming. | |
| files | WeakMapWrapper<HTMLElement, TAbstractFile> | Mapping of tree self element to abstract file. | |
| headerDom | HeaderDom | Navigation header containing the view controls. | |
| icon | IconName | The icon of the view. (Inherited from View) | |
| itemsBeingCut | (FileTreeItem | FolderTreeItem)[] | Tree items marked by the last cut, cleared once they are pasted. | |
| 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. | |
| navFileContainerEl | HTMLDivElement | Container for the file tree. | |
| 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) | |
| search | NavigationSearch | Search visibility and input controls. | |
| searchQuery | null | ObsidianSearchQuery | The active filter query for the file explorer, or null when no filter is applied. | |
| sortOrder | FileExplorerViewSortOrder | Current sort order of file tree items. | |
| tree | Tree<FileTreeItem | FolderTreeItem> | Tree view of files. | |
| workQueue | PromisedQueue | Queue serializing file tree updates. |
Methods
| Method | Returns | Description | |
|---|---|---|---|
| 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. | |
| close() | Promise<void> | Closes the view. (Inherited from View) | |
| createAbstractFile(type, location, newLeaf) | Promise<void> | Creates an file or folder. | |
| 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 | 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.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) | |
| onConfigChanged(key) | void | Handle a vault configuration change. | |
| 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'. | |
| onFileClick($event, targetEl) | void | Handle a click on a file or folder title. | |
| onFileContextMenu($event, file) | void | Build 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) | void | Called when a file is opened. Brings the file to the front. | |
| onFilePointerout($event, targetEl) | void | Dismiss the title tooltip when the pointer leaves. | |
| onFilePointerover($event, targetEl) | void | Show the file or folder title tooltip. | |
| 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) | |
| onSearchChanged(query) | void | Called when the filter query changes. Compiles it into FileExplorerView.searchQuery and filters the tree by file path. | |
| onTabMenu(menu) | void | Adds the menu items to the menu. (Inherited from View) | |
| onTitleBlur() | void | Save the inline rename when the title loses focus. | |
| onToggleAutoReveal() | void | Toggle automatic revealing and save the layout. | |
| 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) | |
| revealActiveFile() | void | Expand ancestors and scroll the active file into view. | |
| revealInFolder(file) | void | Reveal a file or folder in the file tree. | |
| saveRename() | Promise<boolean> | Save the current inline rename. | |
| setAutoReveal(value) | void | Set whether the active file is revealed automatically. | |
| 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) | |
| showSearch() | void | Show and focus the search input. | |
| 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) | |
| updateShowUnsupportedFiles() | void | Refresh unsupported-file visibility and tree layout. |
Links to this page: