WorkspaceLeaf class represents a single pane in the workspace that can contain a view. Leaves are the building blocks of the workspace layout.
Properties
The 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 assumptions about the parent.The view associated with this leaf.
The hover popover associated with this leaf, if any.
Methods
openFile()
Opens a file in this leaf.The file to open
Optional view state configuration
Promise that resolves when the file is opened
Example
open()
Opens a view in this leaf.The view to open
Promise that resolves with the opened view
getViewState()
Gets the current view state of this leaf.The current view state
Example
setViewState()
Sets the view state of this leaf.The new view state to set
Optional ephemeral state
Promise that resolves when the view state is set
Example
isDeferred
Returns true if this leaf is currently deferred because it is in the background. A deferred leaf will have aDeferredView as its view, instead of the View that it should normally have for its type (like MarkdownView for the markdown type).
Whether the leaf is deferred
loadIfDeferred()
If this view is currently deferred, loads it and awaits until it has fully loaded.Promise that resolves when the leaf is loaded
Example
getEphemeralState()
Gets the ephemeral state of this leaf.The ephemeral state
setEphemeralState()
Sets the ephemeral state of this leaf.The ephemeral state to set
togglePinned()
Toggles the pinned state of this leaf.Example
setPinned()
Sets the pinned state of this leaf.Whether the leaf should be pinned
Example
setGroupMember()
Sets this leaf to be in the same group as another leaf.The leaf whose group to join
setGroup()
Sets the group of this leaf.The group ID
detach()
Detaches and removes this leaf from the workspace.Example
getIcon()
Gets the icon for this leaf’s view.The icon name for this leaf’s view
getDisplayText()
Gets the display text for this leaf’s view.The display text for this leaf’s view
Example
onResize()
Called when the leaf is resized.getRoot()
Gets the root workspace item containing this leaf.The root workspace item
WorkspaceItem
Since: 0.10.2
getContainer()
Gets the root container parent item, which can be one of:WorkspaceRootWorkspaceWindow
The container for this leaf
WorkspaceItem
Since: 0.15.4