Skip to content

FileView

Official

File view

Import:

import { FileView } from 'obsidian';

Signature:

export class FileView extends ItemView

Extends: ItemView

Constructor

new FileView(leaf: WorkspaceLeaf)

Constructor.

To extract the constructor type, use ExtractConstructor<FileView>.

Properties

PropertyTypeDescription
actionsElHTMLElementContainer of actions for the view.
(Inherited from ItemView)
allowNoFilebooleanWhether the view may be run without an attached file..
backButtonElHTMLButtonElementBack button element for changing view history.
(Inherited from ItemView)
canDropAnywherebooleanWhether the view may be dropped anywhere in workspace.
(Inherited from ItemView)
contentElHTMLElementThe parent element of the content.
(Inherited from ItemView)
filenull | TFileThe file that is currently being viewed.
forwardButtonElHTMLButtonElementForward button element for changing view history.
(Inherited from ItemView)
headerElHTMLElementHeader bar container of view.
(Inherited from ItemView)
iconElHTMLElementIcon element for the view (for dragging).
(Inherited from ItemView)
leftSidebarToggleElHTMLElement | nullToggle button for the left sidebar, shown on mobile. null on desktop.
(Inherited from ItemView)
moreOptionsButtonElHTMLAnchorElementAnchor button for revealing more view actions.
(Inherited from ItemView)
navigationbooleanWhether the file view can be navigated.
titleContainerElHTMLElementContainer for the title of the view.
(Inherited from ItemView)
titleElHTMLElementTitle element for the view.
(Inherited from ItemView)
titleParentElHTMLElementTitle of the parent.
(Inherited from ItemView)

Methods

MethodReturnsDescription
addAction(icon, title, callback)HTMLElementAdd an action to the item view.
(Inherited from ItemView)
canAcceptExtension(extension)booleanWhether the file view can accept an extension.
getDisplayText()stringGet the display text for the file view.
getState()Record<string, unknown>Get the state of the file view.
getSyncViewState()unknownGet view state for sync plugin.
handleDrop(event, draggable, isOver)DropResult | nullHandle 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()voidHandle a linked group change event.
(Inherited from ItemView)
onload()voidCalled when the file view is loaded.
onLoadFile(file)Promise<void>Called when the file is loaded.
onMoreOptions(event)voidHandle the 'more options' button click event.
(Inherited from ItemView)
onMoreOptionsMenu(e)voidHandle 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)voidReceives sync state from another file view, opening the other view's file if it differs.
renderBreadcrumbs()voidRender 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()voidUpdate the state of the back/forward navigation buttons.
(Inherited from ItemView)

Links to this page: