Skip to content

TypedWorkspaceLeaf<TView>

Unofficial

A workspace leaf with a strongly typed view.

Import:

import type { TypedWorkspaceLeaf } from '@obsidian-typings/obsidian-public-latest';

Signature:

export interface TypedWorkspaceLeaf<TView extends View> extends WorkspaceLeaf

Extends: WorkspaceLeaf

Constructor

new TypedWorkspaceLeaf(app: App, id?: string | undefined)

Constructor.

To get the constructor instance, use getWorkspaceLeafConstructor from obsidian-typings/implementations.

Properties

PropertyTypeDescription
_Record<string, EventsEntry[]>Internal storage of registered event handlers by event name.
(Inherited from WorkspaceLeaf)
_emptyViewThe cached empty-state view shown when the leaf has no file open.
(Inherited from WorkspaceLeaf)
activeTimenumberTimestamp of when this leaf was last activated.
(Inherited from WorkspaceLeaf)
appAppReference to the app instance.
(Inherited from WorkspaceLeaf)
componentComponentThe component managing the lifecycle of this workspace item.
(Inherited from WorkspaceLeaf)
containerElHTMLDivElementContainer element for this workspace item.
(Inherited from WorkspaceLeaf)
dimensionnull | numberThe flex-grow dimension of this item within its parent split.
(Inherited from WorkspaceLeaf)
groupnull | stringThe linked group this leaf belongs to, or null if ungrouped.
(Inherited from WorkspaceLeaf)
heightnumberCurrent height of the leaf in pixels.
(Inherited from WorkspaceLeaf)
historyWorkspaceLeafHistoryNavigation history for this leaf (back/forward).
(Inherited from WorkspaceLeaf)
hoverPopoverHoverPopover | nullThe hover popover associated with this leaf.
(Inherited from WorkspaceLeaf)
idstringUnique identifier for this workspace item.
(Inherited from WorkspaceLeaf)
parentWorkspaceMobileDrawer | WorkspaceTabsThe direct parent of the leaf.

On desktop, a leaf is always a child of a WorkspaceTabs component. On mobile, a leaf might be a child of a WorkspaceMobileDrawer. Perform an instanceof check before making an assumption about the parent.
(Inherited from WorkspaceLeaf)
pinnedbooleanWhether this leaf is pinned (prevented from being navigated away).
(Inherited from WorkspaceLeaf)
resizeHandleElHTMLHRElementThe resize handle element used for adjusting item dimensions.
(Inherited from WorkspaceLeaf)
resizeObservernull | ResizeObserverObserver that tracks size changes of this leaf.
(Inherited from WorkspaceLeaf)
tabHeaderCloseElHTMLDivElement | nullClose button element in the tab header.
(Inherited from WorkspaceLeaf)
tabHeaderElHTMLElementThe tab header element for this leaf.
(Inherited from WorkspaceLeaf)
tabHeaderInnerIconElHTMLElementIcon element inside the tab header.
(Inherited from WorkspaceLeaf)
tabHeaderInnerTitleElHTMLElementTitle element inside the tab header.
(Inherited from WorkspaceLeaf)
tabHeaderStatusContainerElHTMLDivElement | nullContainer element for tab header status indicators.
(Inherited from WorkspaceLeaf)
tabHeaderStatusLinkElHTMLDivElement | nullStatus element indicating linked group membership in the tab header.
(Inherited from WorkspaceLeaf)
tabHeaderStatusPinElHTMLDivElement | nullStatus element indicating pinned state in the tab header.
(Inherited from WorkspaceLeaf)
type'leaf'The workspace item type identifier for this leaf.
(Inherited from WorkspaceLeaf)
viewMaybeDeferredView<TView>The typed view attached to this leaf.
widthnumberCurrent width of the leaf in pixels.
(Inherited from WorkspaceLeaf)
workingbooleanWhether this leaf is currently loading or processing.
(Inherited from WorkspaceLeaf)
workspaceWorkspaceReference to the workspace this item belongs to.
(Inherited from WorkspaceLeaf)

Methods

MethodReturnsDescription
canNavigate()booleanCheck whether this leaf can be navigated to a different view.
(Inherited from WorkspaceLeaf)
canPin()booleanChecks whether this leaf can be pinned (i.e. its parent is a tab group).
(Inherited from WorkspaceLeaf)
detach()voidDetach this leaf from its parent.
(Inherited from WorkspaceLeaf)
getContainer()WorkspaceContainerGet the root container parent item, which can be one of:. - WorkspaceRoot - WorkspaceWindow
(Inherited from WorkspaceLeaf)
getDisplayText()stringGet the display text of this leaf.
(Inherited from WorkspaceLeaf)
getEphemeralState()anyGet the ephemeral state of this leaf.
(Inherited from WorkspaceLeaf)
getHistoryState()WorkspaceLeafHistoryStateGet the current navigation history state of this leaf.
(Inherited from WorkspaceLeaf)
getIcon()IconNameGet the icon of this leaf.
(Inherited from WorkspaceLeaf)
getRoot()WorkspaceItemGet the root item.
(Inherited from WorkspaceLeaf)
getViewState()ViewStateGet the view state of this leaf.
(Inherited from WorkspaceLeaf)
handleDrop(event, draggable, isOver)DropResult | nullHandle a drop event on this leaf.
(Inherited from WorkspaceLeaf)
highlight()voidHighlight this leaf's tab header.
(Inherited from WorkspaceLeaf)
isVisible()booleanCheck whether this leaf is currently visible in the workspace.
(Inherited from WorkspaceLeaf)
loadIfDeferred()Promise<void>If this view is currently deferred, load it and await that it has fully loaded.
(Inherited from WorkspaceLeaf)
off(name, callback)voidRemove an event listener.
(Inherited from WorkspaceLeaf)
offref(ref)voidRemove an event listener by reference.
(Inherited from WorkspaceLeaf)
on('pinned-change', callback, ctx?)EventRefHandle the pinned-change event.
(Inherited from WorkspaceLeaf)
on('group-change', callback, ctx?)EventRefHandle the group-change event.
(Inherited from WorkspaceLeaf)
on('history-change', callback, ctx?)EventRefTriggers when the leaf's history gets updated (e.g. when new file is opened, or moving through history).
(Inherited from WorkspaceLeaf)
on('leaf-menu', callback, ctx?)EventRefTriggers when context menu action is executed on the leaf.
(Inherited from WorkspaceLeaf)
on(name, callback, ctx?)EventRefAdd an event listener.
(Inherited from WorkspaceLeaf)
onOpenTabHeaderMenu(evt, parentEl)voidHandle opening the context menu on this leaf's tab header.
(Inherited from WorkspaceLeaf)
onResize()voidHandle the resize event.
(Inherited from WorkspaceLeaf)
onResizeStart(evt)voidHandle the start of a resize operation on this item.
(Inherited from WorkspaceLeaf)
open(view)Promise<View>Open a view in this leaf.
(Inherited from WorkspaceLeaf)
openFile(file, openState?)Promise<void>Open a file in this leaf.
(Inherited from WorkspaceLeaf)
openLinkText(linktext, sourcePath, openViewState?)Promise<void>Open a link in the current leaf.
(Inherited from WorkspaceLeaf)
rebuildView()Promise<void>Rebuild the view associated with this leaf.
(Inherited from WorkspaceLeaf)
recordHistory(state)voidRecord a state entry in this leaf's navigation history.
(Inherited from WorkspaceLeaf)
serialize()SerializedWorkspaceItemSerialize this workspace item's state for persistence.
(Inherited from WorkspaceLeaf)
setDimension(flexgrow?)voidSet the vertical height a leaf may occupy if it is in a split. The height is not set directly, but by setting the flex-grow (css) of the element. This means to predictably affect the height, you also need to use setDimension on the other leafs of the column. (The flex-grow values of every leaf work basically like a ratio, e.g. 1:2 meaning the first leaf takes 33% of the height, and the second 67%.).
(Inherited from WorkspaceLeaf)
setDimension(dimension)voidSet the flex-grow dimension of this item within its parent split.
(Inherited from WorkspaceLeaf)
setEphemeralState(state)voidSet the ephemeral state of this leaf.
(Inherited from WorkspaceLeaf)
setGroup(group)voidSet the group of this leaf.
(Inherited from WorkspaceLeaf)
setGroupMember(other)voidSet another leaf as a group member of this leaf.
(Inherited from WorkspaceLeaf)
setParent(parent)voidSet the parent split for this workspace item.
(Inherited from WorkspaceLeaf)
setPinned(pinned)voidSet the pinned state of this leaf.
(Inherited from WorkspaceLeaf)
setViewState(viewState, eState?)Promise<void>Set the view state of this leaf.
(Inherited from WorkspaceLeaf)
togglePinned()voidToggle the pinned state of this leaf.
(Inherited from WorkspaceLeaf)
trigger(name, data?)voidTrigger an event, executing all the listeners in order even if some of them throw an error.
(Inherited from WorkspaceLeaf)
tryTrigger(evt, args)voidTry to trigger an event, executing all the listeners in order even if some of them throw an error.
(Inherited from WorkspaceLeaf)
unhighlight()voidRemove highlight from this leaf's tab header.
(Inherited from WorkspaceLeaf)
updateHeader()voidUpdate the tab header display (icon, title, status indicators).
(Inherited from WorkspaceLeaf)

Links to this page: