FileView
Official
File view
Import:
import { FileView } from 'obsidian';Signature:
export class FileView extends ItemViewExtends: ItemView
Constructor
new FileView(leaf: WorkspaceLeaf)Constructor.
To extract the constructor type, use ExtractConstructor<FileView>.
Properties
| Property | Type | Description | |
|---|---|---|---|
| actionsEl | HTMLElement | Container of actions for the view. (Inherited from ItemView) | |
| allowNoFile | boolean | Whether the view may be run without an attached file.. | |
| backButtonEl | HTMLButtonElement | Back button element for changing view history. (Inherited from ItemView) | |
| canDropAnywhere | boolean | Whether the view may be dropped anywhere in workspace. (Inherited from ItemView) | |
| contentEl | HTMLElement | The parent element of the content. (Inherited from ItemView) | |
| file | null | TFile | The file that is currently being viewed. | |
| forwardButtonEl | HTMLButtonElement | Forward button element for changing view history. (Inherited from ItemView) | |
| headerEl | HTMLElement | Header bar container of view. (Inherited from ItemView) | |
| iconEl | HTMLElement | Icon element for the view (for dragging). (Inherited from ItemView) | |
| leftSidebarToggleEl | HTMLElement | null | Toggle button for the left sidebar, shown on mobile. null on desktop.(Inherited from ItemView) | |
| moreOptionsButtonEl | HTMLAnchorElement | Anchor button for revealing more view actions. (Inherited from ItemView) | |
| navigation | boolean | Whether the file view can be navigated. | |
| titleContainerEl | HTMLElement | Container for the title of the view. (Inherited from ItemView) | |
| titleEl | HTMLElement | Title element for the view. (Inherited from ItemView) | |
| titleParentEl | HTMLElement | Title of the parent. (Inherited from ItemView) |
Methods
| Method | Returns | Description | |
|---|---|---|---|
| addAction(icon, title, callback) | HTMLElement | Add an action to the item view. (Inherited from ItemView) | |
| canAcceptExtension(extension) | boolean | Whether the file view can accept an extension. | |
| getDisplayText() | string | Get the display text for the file view. | |
| getState() | Record<string, unknown> | Get the state of the file view. | |
| getSyncViewState() | unknown | Get view state for sync plugin. | |
| handleDrop(event, draggable, isOver) | DropResult | null | Handle a drop event on this view. (Inherited from ItemView) | |
| loadFile(file) | Promise<unknown> | Loads the file with the onLoadFile function. | |
| onDelete(file) | Promise<void> | Updates the view if it contains the deleted file. | |
| onGroupChange() | void | Handle a linked group change event. (Inherited from ItemView) | |
| onload() | void | Called when the file view is loaded. | |
| onLoadFile(file) | Promise<void> | Called when the file is loaded. | |
| onMoreOptions(event) | void | Handle the 'more options' button click event. (Inherited from ItemView) | |
| onMoreOptionsMenu(e) | void | Handle the 'more options' context menu event. (Inherited from ItemView) | |
| onRename(file) | Promise<void> | Called when the file is renamed. | |
| onUnloadFile(file) | Promise<void> | Called when the file is unloaded. | |
| receiveSyncState(view) | void | Receives sync state from another file view, opening the other view's file if it differs. | |
| renderBreadcrumbs() | void | Render the breadcrumb navigation for this file view. | |
| setState(state, result) | Promise<void> | Set the state of the file view. | |
| syncState(e) | Promise<unknown> | Synchronize the view state with the sync plugin. | |
| updateNavButtons() | void | Update the state of the back/forward navigation buttons. (Inherited from ItemView) |
Links to this page: