Skip to main content

Workspace

Extends Events

Constructor​

constructor();

Properties​

leftSplit​

leftSplit: WorkspaceSidedock | WorkspaceMobileDrawer

rightSplit​

rightSplit: WorkspaceSidedock | WorkspaceMobileDrawer

leftRibbon​

leftRibbon: WorkspaceRibbon

rightRibbon​

rightRibbon: WorkspaceRibbon

rootSplit​

rootSplit: WorkspaceRoot

activeLeaf​

activeLeaf: WorkspaceLeaf

Indicates the currently focused leaf, if one exists.

Please avoid using activeLeaf directly, especially without checking whether activeLeaf is null.

The recommended alternatives are:

  • If you need information about the current view, use {@link getActiveViewOfType}.
  • If you need to open a new file or navigate a view, use {@link getLeaf}.

containerEl​

containerEl: HTMLElement

layoutReady​

layoutReady: boolean

requestSaveLayout​

requestSaveLayout: Debouncer<[], Promise<void>>

activeEditor​

activeEditor: MarkdownFileInfo

A component managing the current editor. This can be null if the active view has no editor.

Methods​

onLayoutReady​

onLayoutReady(callback: () => any): 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.

changeLayout​

changeLayout(workspace: any): Promise<void>;

getLayout​

getLayout(): any;

createLeafInParent​

createLeafInParent(parent: WorkspaceSplit, index: number): WorkspaceLeaf;

createLeafBySplit​

createLeafBySplit(leaf: WorkspaceLeaf, direction?: SplitDirection, before?: boolean): WorkspaceLeaf;

splitActiveLeaf​

splitActiveLeaf(direction?: SplitDirection): WorkspaceLeaf;

duplicateLeaf​

duplicateLeaf(leaf: WorkspaceLeaf, direction?: SplitDirection): Promise<WorkspaceLeaf>;

duplicateLeaf​

duplicateLeaf(leaf: WorkspaceLeaf, leafType: PaneType | boolean, direction?: SplitDirection): Promise<WorkspaceLeaf>;

getUnpinnedLeaf​

getUnpinnedLeaf(type?: string): WorkspaceLeaf;

getLeaf​

getLeaf(newLeaf?: 'split', direction?: SplitDirection): 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. 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.

getLeaf​

getLeaf(newLeaf?: PaneType | boolean): 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. 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.

moveLeafToPopout​

moveLeafToPopout(leaf: WorkspaceLeaf, data?: WorkspaceWindowInitData): WorkspaceWindow;

Migrates this leaf to a new popout window. Only works on the desktop app.

openPopoutLeaf​

openPopoutLeaf(data?: WorkspaceWindowInitData): WorkspaceLeaf;

Open a new popout window with a single new leaf and return that leaf. Only works on the desktop app.

openLinkText​

openLinkText(linktext: string, sourcePath: string, newLeaf?: PaneType | boolean, openViewState?: OpenViewState): Promise<void>;

setActiveLeaf​

setActiveLeaf(leaf: WorkspaceLeaf, params?: {
focus?: boolean;
}): void;

Sets the active leaf

setActiveLeaf​

setActiveLeaf(leaf: WorkspaceLeaf, pushHistory: boolean, focus: boolean): void;

Sets the active leaf

getLeafById​

getLeafById(id: string): WorkspaceLeaf;

getGroupLeaves​

getGroupLeaves(group: string): WorkspaceLeaf[];

getMostRecentLeaf​

getMostRecentLeaf(root?: WorkspaceParent): WorkspaceLeaf | null;

getLeftLeaf​

getLeftLeaf(split: boolean): WorkspaceLeaf;

getRightLeaf​

getRightLeaf(split: boolean): WorkspaceLeaf;

getActiveViewOfType​

getActiveViewOfType<T extends View>(type: Constructor<T>): T | null;

getActiveFile​

getActiveFile(): TFile | null;

Returns the file for the current view if it's a FileView.

Otherwise, it will recent the most recently active file.

iterateRootLeaves​

iterateRootLeaves(callback: (leaf: WorkspaceLeaf) => any): void;

Iterate through all leaves in the main area of the workspace.

iterateAllLeaves​

iterateAllLeaves(callback: (leaf: WorkspaceLeaf) => any): void;

Iterate through all leaves, including main area leaves, floating leaves, and sidebar leaves.

getLeavesOfType​

getLeavesOfType(viewType: string): WorkspaceLeaf[];

detachLeavesOfType​

detachLeavesOfType(viewType: string): void;

revealLeaf​

revealLeaf(leaf: WorkspaceLeaf): void;

getLastOpenFiles​

getLastOpenFiles(): string[];

updateOptions​

updateOptions(): void;

Calling this function will update/reconfigure the options of all markdown panes. It is fairly expensive, so it should not be called frequently.

iterateCodeMirrors​

iterateCodeMirrors(callback: (cm: CodeMirror.Editor) => any): void;

on​

on(name: 'quick-preview', callback: (file: TFile, data: string) => any, ctx?: any): EventRef;

Triggered when the CSS of the app has changed. Triggered when the user opens the context menu on a file. Triggered when the user opens the context menu on an editor. Triggered when changes to an editor has been applied, either programmatically or from a user event. 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. 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. Triggered when the app is about to quit. Not guaranteed to actually run. Perform some best effort cleanup here.

on​

on(name: 'resize', callback: () => any, ctx?: any): EventRef;

Triggered when the CSS of the app has changed. Triggered when the user opens the context menu on a file. Triggered when the user opens the context menu on an editor. Triggered when changes to an editor has been applied, either programmatically or from a user event. 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. 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. Triggered when the app is about to quit. Not guaranteed to actually run. Perform some best effort cleanup here.

on​

on(name: 'click', callback: (evt: MouseEvent) => any, ctx?: any): EventRef;

Triggered when the CSS of the app has changed. Triggered when the user opens the context menu on a file. Triggered when the user opens the context menu on an editor. Triggered when changes to an editor has been applied, either programmatically or from a user event. 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. 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. Triggered when the app is about to quit. Not guaranteed to actually run. Perform some best effort cleanup here.

on​

on(name: 'active-leaf-change', callback: (leaf: WorkspaceLeaf | null) => any, ctx?: any): EventRef;

Triggered when the CSS of the app has changed. Triggered when the user opens the context menu on a file. Triggered when the user opens the context menu on an editor. Triggered when changes to an editor has been applied, either programmatically or from a user event. 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. 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. Triggered when the app is about to quit. Not guaranteed to actually run. Perform some best effort cleanup here.

on​

on(name: 'file-open', callback: (file: TFile | null) => any, ctx?: any): EventRef;

Triggered when the CSS of the app has changed. Triggered when the user opens the context menu on a file. Triggered when the user opens the context menu on an editor. Triggered when changes to an editor has been applied, either programmatically or from a user event. 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. 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. Triggered when the app is about to quit. Not guaranteed to actually run. Perform some best effort cleanup here.

on​

on(name: 'layout-change', callback: () => any, ctx?: any): EventRef;

Triggered when the CSS of the app has changed. Triggered when the user opens the context menu on a file. Triggered when the user opens the context menu on an editor. Triggered when changes to an editor has been applied, either programmatically or from a user event. 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. 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. Triggered when the app is about to quit. Not guaranteed to actually run. Perform some best effort cleanup here.

on​

on(name: 'window-open', callback: (win: WorkspaceWindow, window: Window) => any, ctx?: any): EventRef;

Triggered when the CSS of the app has changed. Triggered when the user opens the context menu on a file. Triggered when the user opens the context menu on an editor. Triggered when changes to an editor has been applied, either programmatically or from a user event. 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. 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. Triggered when the app is about to quit. Not guaranteed to actually run. Perform some best effort cleanup here.

on​

on(name: 'window-close', callback: (win: WorkspaceWindow, window: Window) => any, ctx?: any): EventRef;

Triggered when the CSS of the app has changed. Triggered when the user opens the context menu on a file. Triggered when the user opens the context menu on an editor. Triggered when changes to an editor has been applied, either programmatically or from a user event. 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. 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. Triggered when the app is about to quit. Not guaranteed to actually run. Perform some best effort cleanup here.

on​

on(name: 'css-change', callback: () => any, ctx?: any): EventRef;

Triggered when the CSS of the app has changed. Triggered when the user opens the context menu on a file. Triggered when the user opens the context menu on an editor. Triggered when changes to an editor has been applied, either programmatically or from a user event. 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. 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. Triggered when the app is about to quit. Not guaranteed to actually run. Perform some best effort cleanup here.

on​

on(name: 'file-menu', callback: (menu: Menu, file: TAbstractFile, source: string, leaf?: WorkspaceLeaf) => any, ctx?: any): EventRef;

Triggered when the CSS of the app has changed. Triggered when the user opens the context menu on a file. Triggered when the user opens the context menu on an editor. Triggered when changes to an editor has been applied, either programmatically or from a user event. 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. 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. Triggered when the app is about to quit. Not guaranteed to actually run. Perform some best effort cleanup here.

on​

on(name: 'editor-menu', callback: (menu: Menu, editor: Editor, info: MarkdownView | MarkdownFileInfo) => any, ctx?: any): EventRef;

Triggered when the CSS of the app has changed. Triggered when the user opens the context menu on a file. Triggered when the user opens the context menu on an editor. Triggered when changes to an editor has been applied, either programmatically or from a user event. 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. 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. Triggered when the app is about to quit. Not guaranteed to actually run. Perform some best effort cleanup here.

on​

on(name: 'editor-change', callback: (editor: Editor, info: MarkdownView | MarkdownFileInfo) => any, ctx?: any): EventRef;

Triggered when the CSS of the app has changed. Triggered when the user opens the context menu on a file. Triggered when the user opens the context menu on an editor. Triggered when changes to an editor has been applied, either programmatically or from a user event. 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. 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. Triggered when the app is about to quit. Not guaranteed to actually run. Perform some best effort cleanup here.

on​

on(name: 'editor-paste', callback: (evt: ClipboardEvent, editor: Editor, info: MarkdownView | MarkdownFileInfo) => any, ctx?: any): EventRef;

Triggered when the CSS of the app has changed. Triggered when the user opens the context menu on a file. Triggered when the user opens the context menu on an editor. Triggered when changes to an editor has been applied, either programmatically or from a user event. 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. 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. Triggered when the app is about to quit. Not guaranteed to actually run. Perform some best effort cleanup here.

on​

on(name: 'editor-drop', callback: (evt: DragEvent, editor: Editor, info: MarkdownView | MarkdownFileInfo) => any, ctx?: any): EventRef;

Triggered when the CSS of the app has changed. Triggered when the user opens the context menu on a file. Triggered when the user opens the context menu on an editor. Triggered when changes to an editor has been applied, either programmatically or from a user event. 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. 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. Triggered when the app is about to quit. Not guaranteed to actually run. Perform some best effort cleanup here.

on​

on(name: 'codemirror', callback: (cm: CodeMirror.Editor) => any, ctx?: any): EventRef;

Triggered when the CSS of the app has changed. Triggered when the user opens the context menu on a file. Triggered when the user opens the context menu on an editor. Triggered when changes to an editor has been applied, either programmatically or from a user event. 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. 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. Triggered when the app is about to quit. Not guaranteed to actually run. Perform some best effort cleanup here.

on​

on(name: 'quit', callback: (tasks: Tasks) => any, ctx?: any): EventRef;

Triggered when the CSS of the app has changed. Triggered when the user opens the context menu on a file. Triggered when the user opens the context menu on an editor. Triggered when changes to an editor has been applied, either programmatically or from a user event. 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. 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. Triggered when the app is about to quit. Not guaranteed to actually run. Perform some best effort cleanup here.