LayoutReadyWorkspace
Unofficial
A obsidian#Workspace whose layout is loaded, so the members that are null before that are set.
Get one with the isLayoutReady type guard or the onLayoutReadyEx helper from obsidian-typings/implementations.
Import:
import type { LayoutReadyWorkspace } from '@obsidian-typings/obsidian-public-latest';Example:
import { onLayoutReadyEx } from 'obsidian-typings/implementations';onLayoutReadyEx(this.app.workspace, (workspace) => { console.log(workspace.floatingSplit.children.length);});Signature:
export interface LayoutReadyWorkspace extends WorkspaceExtends: Workspace
Constructor
new LayoutReadyWorkspace(app: App, containerEl: HTMLElement)Constructor.
To get the constructor instance, use getWorkspaceConstructor from obsidian-typings/implementations.
Properties
| Property | Type | Description | |
|---|---|---|---|
| _ | Record<string, EventsEntry[]> | Internal storage of registered event handlers by event name. (Inherited from Workspace) | |
| _activeEditor | MarkdownFileInfo | null | Internal reference to the active editor. (Inherited from Workspace) | |
| activeEditor | MarkdownFileInfo | null | A component managing the current editor. This can be null if the active view has no editor.(Inherited from Workspace) | |
| activeLeaf | null | WorkspaceLeaf | Indicates the currently focused leaf, if one exists. Please avoid using activeLeaf directly, especially without checking whether activeLeaf is null.(Inherited from Workspace) | |
| activeTabGroup | WorkspaceTabs | Currently active tab group. | |
| app | App | Reference to the obsidian#App.(Inherited from Workspace) | |
| backlinkInDocument? | unknown | Backlink in document plugin instance, if enabled. (Inherited from Workspace) | |
| containerEl | HTMLElement | The container element of the workspace. (Inherited from Workspace) | |
| editorExtensions | Extension[] | Registered CodeMirror editor extensions, to be applied to all CM instances. (Inherited from Workspace) | |
| editorSuggest | EditorSuggestEx | The global editor suggest manager for live autocomplete. (Inherited from Workspace) | |
| floatingSplit | WorkspaceFloating | The workspace container that holds the popout (floating) windows. | |
| hoverLinkSources | WorkspaceHoverLinkSourcesRecord | Registered sources for hover link previews. (Inherited from Workspace) | |
| initialized | boolean | Whether the workspace has finished its initial layout load. (Inherited from Workspace) | |
| lastActiveFile | null | TFile | Last opened file in the vault, or null when no file has been opened yet.(Inherited from Workspace) | |
| lastTabGroupStacked | boolean | Whether the last active tab group had stacked tabs enabled. (Inherited from Workspace) | |
| layoutItemQueue | unknown[] | Queue of layout items pending initialization. (Inherited from Workspace) | |
| layoutReady | true | Whether the layout of the app has been successfully initialized. | |
| layoutReadyCallbacksDone | null | Promise<void> | Settles once every callback queued by Workspace.onLayoutReady before the layout was ready has run, awaiting those that return a promise. null until the layout is ready.(Inherited from Workspace) | |
| leftRibbon | WorkspaceRibbon | The left ribbon of the workspace. (Inherited from Workspace) | |
| leftSidebarToggleButtonEl | HTMLElement | Button element for toggling the left sidebar. (Inherited from Workspace) | |
| leftSplit | WorkspaceMobileDrawer | WorkspaceSidedock | The left split of the workspace. (Inherited from Workspace) | |
| mobileFileInfos | unknown[] | Array of renderCallbacks (Inherited from Workspace) | |
| onLayoutReadyCallbacks? | unknown | Callbacks queued to run when the layout is ready. (Inherited from Workspace) | |
| operatorFuncConfigs | Record<string, unknown> | Registered operator function configurations. (Inherited from Workspace) | |
| protocolHandler | WorkspaceProtocolHandler | Protocol handlers registered on the workspace. (Inherited from Workspace) | |
| recentFileTracker | RecentFileTracker | Tracks last opened files in the vault. (Inherited from Workspace) | |
| requestSaveLayout | Debouncer<[], Promise<void>> | Save the state of the current workspace layout. (Inherited from Workspace) | |
| rightRibbon | WorkspaceRibbon | The right ribbon of the workspace. (Inherited from Workspace) | |
| rightSidebarToggleButtonEl | HTMLElement | Button element for toggling the right sidebar. (Inherited from Workspace) | |
| rightSplit | WorkspaceMobileDrawer | WorkspaceSidedock | The right split of the workspace. (Inherited from Workspace) | |
| rootSplit | WorkspaceRoot | The root split of the workspace. (Inherited from Workspace) | |
| scope | WorkspaceScope | The workspace's key scope, a child of the app scope that delegates to the active leaf's view scope. (Inherited from Workspace) | |
| undoHistory | StateHistory[] | List of states that were closed and may be reopened. (Inherited from Workspace) |
Methods
| Method | Returns | Description | |
|---|---|---|---|
| activeLeafEvents() | void | Change active leaf and trigger leaf change event (Inherited from Workspace) | |
| addMobileFileInfo(file) | void | Add file to mobile file info (Inherited from Workspace) | |
| addRecentFile(file) | void | Add a file to the recent files list. (Inherited from Workspace) | |
| changeLayout(workspace) | Promise<void> | Change the layout of the workspace. (Inherited from Workspace) | |
| clearLayout() | Promise<void> | Clear layout of workspace and destruct all leaves (Inherited from Workspace) | |
| createLeafBySplit(leaf, direction?, before?) | WorkspaceLeaf | Create a leaf by a split. (Inherited from Workspace) | |
| createLeafInParent(parent, index) | WorkspaceLeaf | Create a leaf in a parent. (Inherited from Workspace) | |
| createLeafInTabGroup(tabs?) | WorkspaceLeaf | Create a leaf in the selected tab group or last used tab group. (Inherited from Workspace) | |
| deserializeLayout(leaf, ribbon?) | Promise<WorkspaceLeaf> | Deserialize workspace entries into actual Leaf objects. (Inherited from Workspace) | |
| detachLeavesOfType(viewType) | void | Remove all leaves of the given type. (Inherited from Workspace) | |
| duplicateLeaf(leaf, direction?) | Promise<WorkspaceLeaf> | Duplicate a leaf. (Inherited from Workspace) | |
| duplicateLeaf(leaf, leafType, direction?) | Promise<WorkspaceLeaf> | Duplicate a leaf. (Inherited from Workspace) | |
| ensureSideLeaf(type, side, options?) | Promise<WorkspaceLeaf> | Get side leaf or create one if one does not exist. (Inherited from Workspace) | |
| focusLeaf(leaf) | void | Focus on a specific leaf. (Inherited from Workspace) | |
| getActiveFile() | TFile | null | Returns the file for the current view if it's a FileView. Otherwise, it will return the most recently active file. (Inherited from Workspace) | |
| getActiveFileView() | FileView | null | Get active file view if exists. (Inherited from Workspace) | |
| getActiveLeafOfViewType(type) | null | T | Get the active leaf of the given view type. (Inherited from Workspace) | |
| getActiveViewOfType(type) | T | null | Get the currently active view of a given type. (Inherited from Workspace) | |
| getAdjacentLeafInDirection(leaf, direction) | null | WorkspaceLeaf | Get adjacent leaf in specified direction. (Inherited from Workspace) | |
| getDropDirection(e, rect, directions, leaf) | 'bottom' | 'center' | 'left' | 'right' | 'top' | Get the direction where the leaf should be dropped on dragevent (Inherited from Workspace) | |
| getDropLocation(e) | null | WorkspaceLeaf | Get the leaf where the leaf should be dropped on dragevent. (Inherited from Workspace) | |
| getFocusedContainer() | WorkspaceSplit | Get the workspace split for the currently focused container. (Inherited from Workspace) | |
| getGroupLeaves(group) | WorkspaceLeaf[] | Get all leaves that belong to a group. (Inherited from Workspace) | |
| getLastOpenFiles() | string[] | Get the filenames of the 10 most recently opened files. (Inherited from Workspace) | |
| getLayout() | Record<string, unknown> | Get the layout of the workspace. (Inherited from Workspace) | |
| getLeaf(newLeaf?, direction?) | WorkspaceLeaf | 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.(Inherited from Workspace) | |
| getLeaf(newLeaf?) | WorkspaceLeaf | 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.(Inherited from Workspace) | |
| getLeafById(id) | WorkspaceLeaf | null | Retrieve a leaf by its id. (Inherited from Workspace) | |
| getLeavesOfType(viewType) | WorkspaceLeaf[] | Get all leaves of a given type. (Inherited from Workspace) | |
| getLeavesOfType(viewType) | TypedWorkspaceLeaf<ViewTypeViewMapping[TViewType]>[] | Get leaves of a specific view type. Declared before the string overload, which would otherwise match every literal first.(Inherited from Workspace) | |
| getLeftLeaf(split) | WorkspaceLeaf | null | Create a new leaf inside the left sidebar. (Inherited from Workspace) | |
| getMostRecentLeaf(root?) | WorkspaceLeaf | null | 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. (Inherited from Workspace) | |
| getRecentFiles(options?) | string[] | Get n last opened files of type (defaults to 10). (Inherited from Workspace) | |
| getRightLeaf(split) | WorkspaceLeaf | null | Create a new leaf inside the right sidebar. (Inherited from Workspace) | |
| getSideLeaf(sideRibbon, split) | WorkspaceLeaf | Get leaf in the side ribbon/dock and split if necessary. (Inherited from Workspace) | |
| getUnpinnedLeaf() | WorkspaceLeaf | Get the unpinned leaf. (Inherited from Workspace) | |
| handleExternalLinkContextMenu(menu, linkText) | void | Handle the context menu for an external URL link. (Inherited from Workspace) | |
| handleLinkContextMenu(menu, linktext, sourcePath, leaf?) | boolean | Add a context menu to internal file links. (Inherited from Workspace) | |
| handleLinkContextMenu(menu, linkText, sourcePath, leaf?) | void | Handle the context menu for an internal link. (Inherited from Workspace) | |
| hasUndoHistory() | boolean | Check if there is any undo history available. (Inherited from Workspace) | |
| isAttached(leaf?) | boolean | Check if leaf has been attached to the workspace (Inherited from Workspace) | |
| isInSidebar(leaf) | boolean | Check if a leaf is in the sidebar. (Inherited from Workspace) | |
| isWorkspaceFocused() | boolean | Checks whether the workspace (the main window or a focused popout window) currently has focus. (Inherited from Workspace) | |
| iterateAllLeaves(callback) | void | Iterate through all leaves, including main area leaves, floating leaves, and sidebar leaves. (Inherited from Workspace) | |
| iterateCodeMirrors(_unused) | void | Iterate through all CodeMirror instances in the workspace. (Inherited from Workspace) | |
| iterateLeaves(split, callback) | void | Iterate the leaves of a split. (Inherited from Workspace) | |
| iterateRootLeaves(callback) | void | Iterate through all leaves in the main area of the workspace. (Inherited from Workspace) | |
| iterateTabs(tabs, cb) | boolean | Iterate the tabs of a split till meeting a condition. (Inherited from Workspace) | |
| loadLayout() | Promise<void> | Load workspace from disk and initialize (Inherited from Workspace) | |
| moveLeafToPopout(leaf, data?) | WorkspaceWindow | Migrates this leaf to a new popout window. Only works on the desktop app. (Inherited from Workspace) | |
| off(name, callback) | void | Remove an event listener. (Inherited from Workspace) | |
| offref(ref) | void | Remove an event listener by reference. (Inherited from Workspace) | |
| on('quick-preview', callback, ctx?) | EventRef | Triggered when the active Markdown file is modified. React to file changes before they are saved to disk. (Inherited from Workspace) | |
| on('resize', callback, ctx?) | EventRef | Triggered when a WorkspaceItem is resized or the workspace layout has changed. (Inherited from Workspace) | |
| on('active-leaf-change', callback, ctx?) | EventRef | Triggered when the active leaf changes. (Inherited from Workspace) | |
| on('file-open', callback, ctx?) | EventRef | Triggered when the active file changes. The file could be in a new leaf, an existing leaf, or an embed. Despite its name, this is a "focused file changed" event, not a "file was opened" one. It fires whenever Workspace.getActiveFile returns a different file than it did last time, so moving the focus to another leaf that already shows another file fires it too, while opening the file that is already active does not. The file is null when the newly active leaf shows no file.(Inherited from Workspace) | |
| on('layout-change', callback, ctx?) | EventRef | Triggered when the layout of the workspace changes. (Inherited from Workspace) | |
| on('window-open', callback, ctx?) | EventRef | Triggered when a new popout window is created. (Inherited from Workspace) | |
| on('window-close', callback, ctx?) | EventRef | Triggered when a popout window is closed. (Inherited from Workspace) | |
| on('css-change', callback, ctx?) | EventRef | Triggered when the CSS of the app has changed. (Inherited from Workspace) | |
| on('file-menu', callback, ctx?) | EventRef | Triggered when the user opens the context menu on a file. (Inherited from Workspace) | |
| on('files-menu', callback, ctx?) | EventRef | Triggered when the user opens the context menu with multiple files selected in the File Explorer. (Inherited from Workspace) | |
| on('url-menu', callback, ctx?) | EventRef | Triggered when the user opens the context menu on an external URL. (Inherited from Workspace) | |
| on('editor-menu', callback, ctx?) | EventRef | Triggered when the user opens the context menu on an editor. (Inherited from Workspace) | |
| on('editor-change', callback, ctx?) | EventRef | Triggered when changes to an editor has been applied, either programmatically or from a user event. (Inherited from Workspace) | |
| on('editor-paste', callback, ctx?) | EventRef | 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.(Inherited from Workspace) | |
| on('editor-drop', callback, ctx?) | EventRef | 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.(Inherited from Workspace) | |
| on('quit', callback, ctx?) | EventRef | Triggered when the app is about to quit. Not guaranteed to actually run. Perform some best effort cleanup here. (Inherited from Workspace) | |
| on('bookmarks:bookmarks-menu', callback, ctx?) | EventRef | Triggers when the context menu of a bookmark is opened in the Bookmarks view. (Inherited from Workspace) | |
| on('browser:update-history', callback, ctx?) | EventRef | Triggers when the browser history is updated. (Inherited from Workspace) | |
| on('canvas:edge-menu', callback, ctx?) | EventRef | Triggers when the user opens a context menu on a connection in the canvas. (Inherited from Workspace) | |
| on('canvas:node-connection-drop-menu', callback, ctx?) | EventRef | Triggers when the user drops edge connection to empty space in the canvas. (Inherited from Workspace) | |
| on('canvas:node-menu', callback, ctx?) | EventRef | Triggers when the user opens a context menu on a single node in the canvas. (Inherited from Workspace) | |
| on('canvas:selection-menu', callback, ctx?) | EventRef | Triggers when the user opens a context menu on a selection of multiple nodes in the canvas. (Inherited from Workspace) | |
| on('editor-selection-change', callback, ctx?) | EventRef | Triggers when the editor selection changes. (Inherited from Workspace) | |
| on('hover-link', callback, ctx?) | EventRef | Triggers when user hovers over any note link element (file explorer, editor, ...). (Inherited from Workspace) | |
| on('layout-ready', callback, ctx?) | EventRef | Triggers when workspace layout is loaded. (Inherited from Workspace) | |
| on('leaf-menu', callback, ctx?) | EventRef | Triggers when the leaf menu is opened. (Inherited from Workspace) | |
| on('markdown-properties-menu', callback, ctx?) | EventRef | Triggers when the properties menu of a note's metadata editor is opened. (Inherited from Workspace) | |
| on('markdown-scroll', callback, ctx?) | EventRef | Triggers when the markdown scroll event is fired. (Inherited from Workspace) | |
| on('markdown-viewport-menu', callback, ctx?) | EventRef | Triggers when the markdown viewport menu is opened. (Inherited from Workspace) | |
| on('receive-files-menu', callback, ctx?) | EventRef | Triggered when user shares files on mobile. (Inherited from Workspace) | |
| on('receive-text-menu', callback, ctx?) | EventRef | Triggered when user shares text on mobile. (Inherited from Workspace) | |
| on('search:results-menu', callback, ctx?) | EventRef | Triggers when user clicks on 'N results' button in search view. (Inherited from Workspace) | |
| on('swipe', callback, ctx?) | EventRef | Triggers when user swipes open left/right sidebar (Inherited from Workspace) | |
| on('tab-group-menu', callback, ctx?) | EventRef | Called whenever user opens tab group menu (contains e.g. stacked tabs button) (Inherited from Workspace) | |
| on(name, callback, ctx?) | EventRef | Add an event listener. (Inherited from Workspace) | |
| onDragLeaf(e, leaf) | void | Handles drag event on leaf (Inherited from Workspace) | |
| onLayoutChange(leaf?) | void | Handles layout change and saves layout to disk (Inherited from Workspace) | |
| onLayoutReady(callback) | void | 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. (Inherited from Workspace) | |
| onQuickPreview(file, data) | void | Trigger the quick preview event with the given arguments. (Inherited from Workspace) | |
| onResize() | void | Handle a resize event on the workspace. (Inherited from Workspace) | |
| onStartLink(leaf) | void | Handle the start of a link drag operation from a leaf. (Inherited from Workspace) | |
| openLinkText(linktext, sourcePath, newLeaf?, openViewState?) | Promise<void> | Open a link text. (Inherited from Workspace) | |
| openPopout(data?) | WorkspaceWindow | Open a leaf in a popup window. (Inherited from Workspace) | |
| openPopoutLeaf(data?) | WorkspaceLeaf | Open a new popout window with a single new leaf and return that leaf. Only works on the desktop app. (Inherited from Workspace) | |
| pushUndoHistory(leaf, parentID, rootID) | void | Push leaf change to history (Inherited from Workspace) | |
| readWorkspaceFile() | Promise<SerializedWorkspace> | Read workspace layout data from disk. (Inherited from Workspace) | |
| recursiveGetTarget(e, leaf) | null | WorkspaceTabs | Get drag event target location (Inherited from Workspace) | |
| registerEditorExtension(extension) | void | Register a CodeMirror editor extension. (Inherited from Workspace) | |
| registerHoverLinkSource(key, source) | void | Registers hover link source (Inherited from Workspace) | |
| registerObsidianProtocolHandler(protocol, handler) | void | Registers Obsidian protocol handler (Inherited from Workspace) | |
| registerOpenFileHandler() | void | Installs the desktop external-file open handler and processes a pending open request. (Inherited from Workspace) | |
| registerOperatorFuncConfigs(id, configs) | void | Register operator function configurations. (Inherited from Workspace) | |
| registerUriHook() | void | Constructs hook for receiving URI actions (Inherited from Workspace) | |
| requestActiveLeafEvents() | void | Request execution of activeLeaf change events (Inherited from Workspace) | |
| requestLayoutChangeEvents() | void | Request execution of layout change events. (Inherited from Workspace) | |
| requestResize() | void | Request execution of resize event (Inherited from Workspace) | |
| requestUpdateLayout() | void | Request execution of layout update event (Inherited from Workspace) | |
| revealLeaf(leaf) | Promise<void> | 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.(Inherited from Workspace) | |
| saveLayout() | Promise<void> | Save workspace layout to disk. (Inherited from Workspace) | |
| setActiveLeaf(leaf, params?) | void | Sets the active leaf. (Inherited from Workspace) | |
| setActiveLeaf(leaf, pushHistory, focus) | void | Sets the active leaf. (Inherited from Workspace) | |
| setLayout(data) | Promise<void> | Use deserialized layout data to reconstruct the workspace (Inherited from Workspace) | |
| splitActiveLeaf(direction?) | WorkspaceLeaf | Split the active leaf. (Inherited from Workspace) | |
| splitLeaf(leaf, newLeaf, direction?, before?) | void | Split leaves in specified direction (Inherited from Workspace) | |
| splitLeafOrActive(leaf?, direction?) | WorkspaceLeaf | Split provided leaf, or active leaf if none provided. (Inherited from Workspace) | |
| trigger(name, data?) | void | Trigger an event, executing all the listeners in order even if some of them throw an error. (Inherited from Workspace) | |
| 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 Workspace) | |
| unregisterEditorExtension(extension) | void | Unregister a CodeMirror editor extension (Inherited from Workspace) | |
| unregisterHoverLinkSource(key) | void | Unregister hover link source (Inherited from Workspace) | |
| unregisterObsidianProtocolHandler(protocol, handler) | void | Unregister Obsidian protocol handler (Inherited from Workspace) | |
| unregisterOperatorFuncConfigs(id) | void | Unregister operator function configurations. (Inherited from Workspace) | |
| unsetActiveEditor(editor) | void | Unset the active editor. (Inherited from Workspace) | |
| updateFrameless() | void | Update the frameless window chrome (title bar) display. (Inherited from Workspace) | |
| updateLayout() | void | Invoke workspace layout update, redraw and save (Inherited from Workspace) | |
| updateMobileVisibleTabGroup() | void | Update visibility of tab group (Inherited from Workspace) | |
| updateOptions() | void | Calling this function will update/reconfigure the options of all Markdown views. It is fairly expensive, so it should not be called frequently. (Inherited from Workspace) | |
| updateTitle() | void | Update the internal title of the application. (Inherited from Workspace) |
Links to this page: