Skip to content

WorkspaceItem

Official

Workspace item.

Import:

import { WorkspaceItem } from 'obsidian';

Signature:

export class WorkspaceItem extends Events

Extends: Events

Constructor

new WorkspaceItem(workspace: Workspace, id?: string | undefined)

Constructor.

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

Properties

PropertyTypeDescription
_Record<string, EventsEntry[]>Internal storage of registered event handlers by event name.
(Inherited from Events)
appAppReference to the app instance.
componentComponentThe component managing the lifecycle of this workspace item.
containerElHTMLDivElementContainer element for this workspace item.
dimensionnull | numberThe flex-grow dimension of this item within its parent split.
idstringUnique identifier for this workspace item.
parentWorkspaceParentThe direct parent of the leaf.
resizeHandleElHTMLHRElementThe resize handle element used for adjusting item dimensions.
typestringThe type identifier for this workspace item (e.g. 'leaf', 'split', 'tabs').
workspaceWorkspaceReference to the workspace this item belongs to.

Methods

MethodReturnsDescription
detach()voidDetach this item from its parent.
getContainer()WorkspaceContainerGet the root container parent item, which can be one of:. - WorkspaceRoot - WorkspaceWindow
getIcon()IconNameGet the icon name for this workspace item.
getRoot()WorkspaceItemGet the root item.
off(name, callback)voidRemove an event listener.
(Inherited from Events)
offref(ref)voidRemove an event listener by reference.
(Inherited from Events)
on(name, callback, ctx?)EventRefAdd an event listener.
(Inherited from Events)
onResizeStart(evt)voidHandle the start of a resize operation on this item.
serialize()SerializedWorkspaceItemSerialize this workspace item's state for persistence.
setDimension(dimension)voidSet the flex-grow dimension of this item within its parent split.
setParent(parent)voidSet the parent split for this workspace item.
trigger(name, data?)voidTrigger an event, executing all the listeners in order even if some of them throw an error.
(Inherited from Events)
tryTrigger(evt, args)voidTry to trigger an event, executing all the listeners in order even if some of them throw an error.
(Inherited from Events)

Links to this page: