Workspace
Defined in: obsidian.d.ts:4601
Extends
Constructors
new Workspace()
new Workspace():
Workspace
Returns
Inherited from
Properties
_
_:
Record
<string
,EventsEntry
[]>
Defined in: src/obsidian/augmentations/Events.d.ts:5
Inherited from
activeEditor
activeEditor:
null
|MarkdownFileInfo
Defined in: obsidian.d.ts:4661
A component managing the current editor. This can be null if the active view has no editor.
activeLeaf
activeLeaf:
null
|WorkspaceLeaf
Defined in: obsidian.d.ts:4637
Indicates the currently focused leaf, if one exists.
Please avoid using activeLeaf
directly, especially without checking whether
activeLeaf
is null.
activeTabGroup
activeTabGroup:
WorkspaceTabs
Defined in: src/obsidian/augmentations/Workspace.d.ts:24
Currently active tab group
app
app:
App
Defined in: src/obsidian/augmentations/Workspace.d.ts:28
Reference to App
containerEl
containerEl:
HTMLElement
Defined in: obsidian.d.ts:4643
editorExtensions
editorExtensions:
Extension
[]
Defined in: src/obsidian/augmentations/Workspace.d.ts:34
Registered CodeMirror editor extensions, to be applied to all CM instances
lastActiveFile
lastActiveFile:
TFile
Defined in: src/obsidian/augmentations/Workspace.d.ts:47
Last opened file in the vault
layoutReady
layoutReady:
boolean
Defined in: obsidian.d.ts:4649
If the layout of the app has been successfully initialized. To react to the layout becoming ready, use Workspace.onLayoutReady
leftRibbon
leftRibbon:
WorkspaceRibbon
Defined in: obsidian.d.ts:4614
leftSplit
leftSplit:
WorkspaceSidedock
|WorkspaceMobileDrawer
Defined in: obsidian.d.ts:4606
protocolHandlers
protocolHandlers:
Map
<string
,ObsidianProtocolHandler
>
Defined in: src/obsidian/augmentations/Workspace.d.ts:65
Protocol handlers registered on the workspace
recentFileTracker
recentFileTracker:
RecentFileTracker
Defined in: src/obsidian/augmentations/Workspace.d.ts:69
Tracks last opened files in the vault
requestSaveLayout
Defined in: obsidian.d.ts:4654
Save the state of the current workspace layout.
rightRibbon
rightRibbon:
WorkspaceRibbon
Defined in: obsidian.d.ts:4619
rightSplit
rightSplit:
WorkspaceSidedock
|WorkspaceMobileDrawer
Defined in: obsidian.d.ts:4610
rootSplit
rootSplit:
WorkspaceRoot
Defined in: obsidian.d.ts:4623
undoHistory
undoHistory:
StateHistory
[]
Defined in: src/obsidian/augmentations/Workspace.d.ts:77
List of states that were closed and may be reopened
Methods
changeLayout()
changeLayout(
workspace
):Promise
<void
>
Defined in: obsidian.d.ts:4672
Parameters
workspace
any
Returns
Promise
<void
>
createLeafBySplit()
createLeafBySplit(
leaf
,direction
?,before
?):WorkspaceLeaf
Defined in: obsidian.d.ts:4687
Parameters
leaf
direction?
before?
boolean
Returns
createLeafInParent()
createLeafInParent(
parent
,index
):WorkspaceLeaf
Defined in: obsidian.d.ts:4682
Parameters
parent
index
number
Returns
detachLeavesOfType()
detachLeavesOfType(
viewType
):void
Defined in: obsidian.d.ts:4843
Remove all leaves of the given type.
Parameters
viewType
string
Returns
void
duplicateLeaf()
Call Signature
duplicateLeaf(
leaf
,direction
?):Promise
<WorkspaceLeaf
>
Defined in: obsidian.d.ts:4698
Parameters
leaf
direction?
Returns
Call Signature
duplicateLeaf(
leaf
,leafType
,direction
?):Promise
<WorkspaceLeaf
>
Defined in: obsidian.d.ts:4702
Parameters
leaf
leafType
boolean
| PaneType
direction?
Returns
ensureSideLeaf()
ensureSideLeaf(
type
,side
,options
?):Promise
<WorkspaceLeaf
>
Defined in: obsidian.d.ts:4800
Get side leaf or create one if one does not exist.
Parameters
type
string
side
options?
active
boolean
reveal
boolean
split
boolean
state
any
Returns
getActiveFile()
getActiveFile():
null
|TFile
Defined in: obsidian.d.ts:4822
Returns the file for the current view if it’s a FileView
.
Otherwise, it will return the most recently active file.
Returns
null
| TFile
getActiveFileView()
getActiveFileView():
null
|FileView
Defined in: src/obsidian/augmentations/Workspace.d.ts:106
Get active file view if exists
Returns
null
| FileView
getActiveLeafOfViewType()
getActiveLeafOfViewType<
T
>(type
):null
|T
Defined in: src/obsidian/augmentations/Workspace.d.ts:108
Type Parameters
• T extends View
Parameters
type
Constructor
<T
>
Returns
null
| T
getActiveViewOfType()
getActiveViewOfType<
T
>(type
):null
|T
Defined in: obsidian.d.ts:4815
Get the currently active view of a given type.
Type Parameters
• T extends View
Parameters
type
Constructor
<T
>
Returns
null
| T
getAdjacentLeafInDirection()
getAdjacentLeafInDirection(
leaf
,direction
):null
|WorkspaceLeaf
Defined in: src/obsidian/augmentations/Workspace.d.ts:114
Get adjacent leaf in specified direction
Parameters
leaf
direction
"left"
| "right"
| "bottom"
| "top"
Returns
null
| WorkspaceLeaf
getFocusedContainer()
getFocusedContainer():
WorkspaceSplit
Defined in: src/obsidian/augmentations/Workspace.d.ts:133
Get the workspace split for the currently focused container
Returns
getGroupLeaves()
getGroupLeaves(
group
):WorkspaceLeaf
[]
Defined in: obsidian.d.ts:4776
Get all leaves that belong to a group
Parameters
group
string
id
Returns
getLastOpenFiles()
getLastOpenFiles():
string
[]
Defined in: obsidian.d.ts:4855
Get the filenames of the 10 most recently opened files.
Returns
string
[]
getLayout()
getLayout():
Record
<string
,unknown
>
Defined in: obsidian.d.ts:4677
Returns
Record
<string
, unknown
>
getLeaf()
Call Signature
getLeaf(
newLeaf
?,direction
?):WorkspaceLeaf
Defined in: obsidian.d.ts:4715
Creates a new leaf in a leaf adjacent to the currently active leaf.
If direction is 'vertical'
, the leaf will appear to the right.
If direction is 'horizontal'
, the leaf will appear below the current leaf.
Parameters
newLeaf?
"split"
direction?
Returns
Call Signature
getLeaf(
newLeaf
?):WorkspaceLeaf
Defined in: obsidian.d.ts:4729
If newLeaf is false (or not set) then an existing leaf which can be navigated is returned, or a new leaf will be created if there was no leaf available.
If newLeaf is 'tab'
or true
then a new leaf will be created in the preferred
location within the root split and returned.
If newLeaf is 'split'
then a new leaf will be created adjacent to the currently active leaf.
If newLeaf is 'window'
then a popout window will be created with a new leaf inside.
Parameters
newLeaf?
boolean
| PaneType
Returns
getLeafById()
getLeafById(
id
):null
|WorkspaceLeaf
Defined in: obsidian.d.ts:4770
Retrieve a leaf by its id.
Parameters
id
string
id of the leaf to retrieve.
Returns
null
| WorkspaceLeaf
getLeavesOfType()
Call Signature
getLeavesOfType(
viewType
):WorkspaceLeaf
[]
Defined in: obsidian.d.ts:4838
Get all leaves of a given type.
Parameters
viewType
string
Returns
Call Signature
getLeavesOfType<
TViewType
>(viewType
):TypedWorkspaceLeaf
<ViewTypeViewMapping
[TViewType
]>[]
Defined in: src/obsidian/augmentations/Workspace.d.ts:137
Get leaves of a specific view type
Type Parameters
• TViewType extends ViewTypeType
Parameters
viewType
TViewType
Returns
TypedWorkspaceLeaf
<ViewTypeViewMapping
[TViewType
]>[]
getLeftLeaf()
getLeftLeaf(
split
):null
|WorkspaceLeaf
Defined in: obsidian.d.ts:4789
Create a new leaf inside the left sidebar.
Parameters
split
boolean
Should the existing split be split up?
Returns
null
| WorkspaceLeaf
getMostRecentLeaf()
getMostRecentLeaf(
root
?):null
|WorkspaceLeaf
Defined in: obsidian.d.ts:4783
Get the most recently active leaf in a given workspace root. Useful for interacting with the leaf in the root split while a sidebar leaf might be active.
Parameters
root?
Root for the leaves you want to search. If a root is not provided, the rootSplit
and leaves within pop-outs will be searched.
Returns
null
| WorkspaceLeaf
getRecentFiles()
getRecentFiles(
arg
?):string
[]
Defined in: src/obsidian/augmentations/Workspace.d.ts:143
Get n last opened files of type (defaults to 10)
Parameters
arg?
maxCount
number
showCanvas
boolean
showImages
boolean
showMarkdown
boolean
showNonImageAttachments
boolean
Returns
string
[]
getRightLeaf()
getRightLeaf(
split
):null
|WorkspaceLeaf
Defined in: obsidian.d.ts:4795
Create a new leaf inside the right sidebar.
Parameters
split
boolean
Should the existing split be split up?
Returns
null
| WorkspaceLeaf
getSideLeaf()
getSideLeaf(
sideRibbon
,split
):WorkspaceLeaf
Defined in: src/obsidian/augmentations/Workspace.d.ts:156
Get leaf in the side ribbon/dock and split if necessary
Parameters
sideRibbon
Side ribbon to get leaf from
WorkspaceSidedock
| WorkspaceMobileDrawer
split
boolean
Whether to split the leaf if it does not exist
Returns
getUnpinnedLeaf()
getUnpinnedLeaf():
WorkspaceLeaf
Defined in: obsidian.d.ts:4707
Returns
iterateAllLeaves()
iterateAllLeaves(
callback
):void
Defined in: obsidian.d.ts:4833
Iterate through all leaves, including main area leaves, floating leaves, and sidebar leaves.
Parameters
callback
(leaf
) => any
Returns
void
iterateLeaves()
iterateLeaves(
split
,callback
):void
Defined in: src/obsidian/augmentations/Workspace.d.ts:166
Iterate the leaves of a split
Parameters
split
callback
(leaf
) => unknown
Returns
void
iterateRootLeaves()
iterateRootLeaves(
callback
):void
Defined in: obsidian.d.ts:4828
Iterate through all leaves in the main area of the workspace.
Parameters
callback
(leaf
) => any
Returns
void
iterateTabs()
iterateTabs(
tabs
,cb
):boolean
Defined in: src/obsidian/augmentations/Workspace.d.ts:170
Iterate the tabs of a split till meeting a condition
Parameters
tabs
WorkspaceSplit
| WorkspaceSplit
[]
cb
(leaf
) => boolean
Returns
boolean
moveLeafToPopout()
moveLeafToPopout(
leaf
,data
?):WorkspaceWindow
Defined in: obsidian.d.ts:4737
Migrates this leaf to a new popout window. Only works on the desktop app.
Parameters
leaf
data?
Returns
Throws
Error if the app does not support popout windows (i.e. on mobile or if Electron version is too old)
off()
off(
name
,callback
):void
Defined in: obsidian.d.ts:1441
Parameters
name
string
callback
(…data
) => unknown
Returns
void
Inherited from
offref()
offref(
ref
):void
Defined in: obsidian.d.ts:1445
Parameters
ref
Returns
void
Inherited from
on()
Call Signature
on(
name
,callback
,ctx
?):EventRef
Defined in: obsidian.d.ts:4869
Triggered when the active Markdown file is modified. React to file changes before they are saved to disk.
Parameters
name
"quick-preview"
callback
(file
, data
) => any
ctx?
any
Returns
Inherited from
Call Signature
on(
name
,callback
,ctx
?):EventRef
Defined in: obsidian.d.ts:4874
Triggered when a WorkspaceItem
is resized or the workspace layout has changed.
Parameters
name
"resize"
callback
() => any
ctx?
any
Returns
Inherited from
Events.on
Call Signature
on(
name
,callback
,ctx
?):EventRef
Defined in: obsidian.d.ts:4880
Triggered when the active leaf changes.
Parameters
name
"active-leaf-change"
callback
(leaf
) => any
ctx?
any
Returns
Inherited from
Events.on
Call Signature
on(
name
,callback
,ctx
?):EventRef
Defined in: obsidian.d.ts:4886
Triggered when the active file changes. The file could be in a new leaf, an existing leaf, or an embed.
Parameters
name
"file-open"
callback
(file
) => any
ctx?
any
Returns
Inherited from
Events.on
Call Signature
on(
name
,callback
,ctx
?):EventRef
Defined in: obsidian.d.ts:4891
Parameters
name
"layout-change"
callback
() => any
ctx?
any
Returns
Inherited from
Events.on
Call Signature
on(
name
,callback
,ctx
?):EventRef
Defined in: obsidian.d.ts:4896
Triggered when a new popout window is created.
Parameters
name
"window-open"
callback
(win
, window
) => any
ctx?
any
Returns
Inherited from
Events.on
Call Signature
on(
name
,callback
,ctx
?):EventRef
Defined in: obsidian.d.ts:4901
Triggered when a popout window is closed.
Parameters
name
"window-close"
callback
(win
, window
) => any
ctx?
any
Returns
Inherited from
Events.on
Call Signature
on(
name
,callback
,ctx
?):EventRef
Defined in: obsidian.d.ts:4906
Triggered when the CSS of the app has changed.
Parameters
name
"css-change"
callback
() => any
ctx?
any
Returns
Inherited from
Events.on
Call Signature
on(
name
,callback
,ctx
?):EventRef
Defined in: obsidian.d.ts:4912
Triggered when the user opens the context menu on a file.
Parameters
name
"file-menu"
callback
(menu
, file
, source
, leaf
?) => any
ctx?
any
Returns
Inherited from
Events.on
Call Signature
on(
name
,callback
,ctx
?):EventRef
Defined in: obsidian.d.ts:4917
Triggered when the user opens the context menu with multiple files selected in the File Explorer.
Parameters
name
"files-menu"
callback
(menu
, files
, source
, leaf
?) => any
ctx?
any
Returns
Inherited from
Events.on
Call Signature
on(
name
,callback
,ctx
?):EventRef
Defined in: obsidian.d.ts:4923
Triggered when the user opens the context menu on an external URL.
Parameters
name
"url-menu"
callback
(menu
, url
) => any
ctx?
any
Returns
Inherited from
Events.on
Call Signature
on(
name
,callback
,ctx
?):EventRef
Defined in: obsidian.d.ts:4928
Triggered when the user opens the context menu on an editor.
Parameters
name
"editor-menu"
callback
(menu
, editor
, info
) => any
ctx?
any
Returns
Inherited from
Events.on
Call Signature
on(
name
,callback
,ctx
?):EventRef
Defined in: obsidian.d.ts:4933
Triggered when changes to an editor has been applied, either programmatically or from a user event.
Parameters
name
"editor-change"
callback
(editor
, info
) => any
ctx?
any
Returns
Inherited from
Events.on
Call Signature
on(
name
,callback
,ctx
?):EventRef
Defined in: obsidian.d.ts:4941
Triggered when the editor receives a paste event.
Check for evt.defaultPrevented
before attempting to handle this event, and return if it has been already handled.
Use evt.preventDefault()
to indicate that you’ve handled the event.
Parameters
name
"editor-paste"
callback
(evt
, editor
, info
) => any
ctx?
any
Returns
Inherited from
Events.on
Call Signature
on(
name
,callback
,ctx
?):EventRef
Defined in: obsidian.d.ts:4948
Triggered when the editor receives a drop event.
Check for evt.defaultPrevented
before attempting to handle this event, and return if it has been already handled.
Use evt.preventDefault()
to indicate that you’ve handled the event.
Parameters
name
"editor-drop"
callback
(evt
, editor
, info
) => any
ctx?
any
Returns
Inherited from
Events.on
Call Signature
on(
name
,callback
,ctx
?):EventRef
Defined in: obsidian.d.ts:4956
Triggered when the app is about to quit. Not guaranteed to actually run. Perform some best effort cleanup here.
Parameters
name
"quit"
callback
(tasks
) => any
ctx?
any
Returns
Inherited from
Events.on
Call Signature
on(
name
,callback
,ctx
?):EventRef
Defined in: src/obsidian/augmentations/Workspace.d.ts:181
Triggers when the browser history is updated.
Parameters
name
"browser:update-history"
‘browser:update-history’
callback
() => unknown
Callback function
ctx?
unknown
Context
Returns
Event reference
Inherited from
Events.on
Call Signature
on(
name
,callback
,ctx
?):EventRef
Defined in: src/obsidian/augmentations/Workspace.d.ts:185
Triggers when the user opens a context menu on a connection in the canvas
Parameters
name
"canvas:edge-menu"
callback
(menu
, connection
) => void
ctx?
unknown
Returns
Inherited from
Events.on
Call Signature
on(
name
,callback
,ctx
?):EventRef
Defined in: src/obsidian/augmentations/Workspace.d.ts:193
Triggers when the user drops edge connection to empty space in the canvas
Parameters
name
"canvas:node-connection-drop-menu"
callback
(menu
, originalNode
, connection
) => void
ctx?
unknown
Returns
Inherited from
Events.on
Call Signature
on(
name
,callback
,ctx
?):EventRef
Defined in: src/obsidian/augmentations/Workspace.d.ts:201
Triggers when the user opens a context menu on a single node in the canvas
Parameters
name
"canvas:node-menu"
callback
(menu
, node
) => void
ctx?
unknown
Returns
Inherited from
Events.on
Call Signature
on(
name
,callback
,ctx
?):EventRef
Defined in: src/obsidian/augmentations/Workspace.d.ts:205
Triggers when the user opens a context menu on a selection of multiple nodes in the canvas
Parameters
name
"canvas:selection-menu"
callback
(menu
, canvasView
) => void
ctx?
unknown
Returns
Inherited from
Events.on
Call Signature
on(
name
,callback
,ctx
?):EventRef
Defined in: src/obsidian/augmentations/Workspace.d.ts:218
Triggers when the editor selection changes.
Parameters
name
"editor-selection-change"
‘editor-selection-change’
callback
(editor
, info
) => unknown
Callback function
ctx?
unknown
Context
Returns
Event reference
Inherited from
Events.on
Call Signature
on(
name
,callback
,ctx
?):EventRef
Defined in: src/obsidian/augmentations/Workspace.d.ts:233
Triggers when workspace layout is loaded
Parameters
name
"layout-ready"
callback
() => void
ctx?
unknown
Returns
Inherited from
Events.on
Call Signature
on(
name
,callback
,ctx
?):EventRef
Defined in: src/obsidian/augmentations/Workspace.d.ts:242
Triggers when the leaf menu is opened.
Parameters
name
"leaf-menu"
‘leaf-menu’
callback
(menu
, leaf
) => unknown
Callback function
ctx?
unknown
Context
Returns
Event reference
Inherited from
Events.on
Call Signature
on(
name
,callback
,ctx
?):EventRef
Defined in: src/obsidian/augmentations/Workspace.d.ts:251
Triggers when the markdown scroll event is fired.
Parameters
name
"markdown-scroll"
‘markdown-scroll’
callback
(view
) => unknown
Callback function
ctx?
unknown
Context
Returns
Event reference
Inherited from
Events.on
Call Signature
on(
name
,callback
,ctx
?):EventRef
Defined in: src/obsidian/augmentations/Workspace.d.ts:260
Triggers when the markdown viewport menu is opened.
Parameters
name
"markdown-viewport-menu"
‘markdown-viewport-menu’
callback
(menu
, view
, sectionName
, menuItem
) => unknown
Callback function
ctx?
unknown
Context
Returns
Event reference
Inherited from
Events.on
Call Signature
on(
name
,callback
,ctx
?):EventRef
Defined in: src/obsidian/augmentations/Workspace.d.ts:272
Triggers when user clicks on ‘N results’ button in search view
Parameters
name
"search:results-menu"
callback
(menu
, search
) => void
ctx?
unknown
Returns
Inherited from
Events.on
onLayoutReady()
onLayoutReady(
callback
):void
Defined in: obsidian.d.ts:4668
Runs the callback function right away if layout is already ready, or push it to a queue to be called later when layout is ready.
Parameters
callback
() => any
Returns
void
openLinkText()
openLinkText(
linktext
,sourcePath
,newLeaf
?,openViewState
?):Promise
<void
>
Defined in: obsidian.d.ts:4748
Parameters
linktext
string
sourcePath
string
newLeaf?
boolean
| PaneType
openViewState?
Returns
Promise
<void
>
openPopout()
openPopout(
data
?):WorkspaceWindow
Defined in: src/obsidian/augmentations/Workspace.d.ts:300
Open a leaf in a popup window
Parameters
data?
Returns
openPopoutLeaf()
openPopoutLeaf(
data
?):WorkspaceLeaf
Defined in: obsidian.d.ts:4744
Open a new popout window with a single new leaf and return that leaf. Only works on the desktop app.
Parameters
data?
Returns
revealLeaf()
revealLeaf(
leaf
):Promise
<void
>
Defined in: obsidian.d.ts:4850
Bring a given leaf to the foreground. If the leaf is in a sidebar, the sidebar will be uncollapsed.
await
this function to ensure your view has been fully loaded and is not deferred.
Parameters
leaf
Returns
Promise
<void
>
saveLayout()
saveLayout():
Promise
<void
>
Defined in: src/obsidian/augmentations/Workspace.d.ts:325
Save workspace layout to disk
Returns
Promise
<void
>
setActiveLeaf()
Call Signature
setActiveLeaf(
leaf
,params
?):void
Defined in: obsidian.d.ts:4755
Sets the active leaf
Parameters
leaf
The new active leaf
params?
Parameter object of whether to set the focus.
focus
boolean
Returns
void
Call Signature
setActiveLeaf(
leaf
,pushHistory
,focus
):void
Defined in: obsidian.d.ts:4763
Parameters
leaf
pushHistory
boolean
focus
boolean
Returns
void
splitActiveLeaf()
splitActiveLeaf(
direction
?):WorkspaceLeaf
Defined in: obsidian.d.ts:4692
Parameters
direction?
Returns
splitLeafOrActive()
splitLeafOrActive(
leaf
?,direction
?):WorkspaceLeaf
Defined in: src/obsidian/augmentations/Workspace.d.ts:333
Split provided leaf, or active leaf if none provided
Parameters
leaf?
direction?
Returns
trigger()
trigger(
name
, …data
):void
Defined in: obsidian.d.ts:1449
Parameters
name
string
data
…unknown
[]
Returns
void
Inherited from
tryTrigger()
tryTrigger(
evt
,args
):void
Defined in: obsidian.d.ts:1453
Parameters
evt
args
unknown
[]
Returns
void
Inherited from
updateOptions()
updateOptions():
void
Defined in: obsidian.d.ts:4862
Calling this function will update/reconfigure the options of all Markdown views. It is fairly expensive, so it should not be called frequently.
Returns
void
updateTitle()
updateTitle():
void
Defined in: src/obsidian/augmentations/Workspace.d.ts:351
Update the internal title of the application
Returns
void
Remark
This title is shown as the application title in the OS taskbar