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

Property Type Description
_ Record<string, EventsEntry[]> Internal storage of registered event handlers by event name.
(Inherited from Events)
app App Reference to the app instance.
component Component The component managing the lifecycle of this workspace item.
containerEl HTMLDivElement Container element for this workspace item.
dimension null | number The flex-grow dimension of this item within its parent split.
id string Unique identifier for this workspace item.
parent WorkspaceParent The direct parent of the leaf.
resizeHandleEl HTMLHRElement The resize handle element used for adjusting item dimensions.
type string The type identifier for this workspace item (e.g. 'leaf', 'split', 'tabs').
workspace Workspace Reference to the workspace this item belongs to.

Methods

Method Returns Description
detach() void Detach this item from its parent.
getContainer() WorkspaceContainer Get the root container parent item, which can be one of:. - WorkspaceRoot - WorkspaceWindow
getIcon() IconName Get the icon name for this workspace item.
getRoot() WorkspaceItem Get the root item.
off(name, callback) void Remove an event listener.
(Inherited from Events)
offref(ref) void Remove an event listener by reference.
(Inherited from Events)
on(name, callback, ctx?) EventRef Add an event listener.
(Inherited from Events)
onResizeStart(evt) void Handle the start of a resize operation on this item.
serialize() SerializedWorkspaceItem Serialize this workspace item's state for persistence.
setDimension(dimension) void Set the flex-grow dimension of this item within its parent split.
setParent(parent) void Set the parent split for this workspace item.
trigger(name, data?) void Trigger an event, executing all the listeners in order even if some of them throw an error.
(Inherited from Events)
tryTrigger(evt, args) void Try 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: