/** * @file * * Mock of Obsidian's `WorkspaceTabs`, the tab group that holds leaves. */ import type { WorkspaceSplit as WorkspaceSplitOriginal, WorkspaceTabs as WorkspaceTabsOriginal } from 'obsidian'; import type { SerializedWorkspaceItem } from '../internal/types.mjs'; import type { Workspace } from './Workspace.mjs'; import type { WorkspaceItem } from './WorkspaceItem.mjs'; import { WorkspaceParent } from './WorkspaceParent.mjs'; /** * Mock of Obsidian's `WorkspaceTabs`, a tab group whose children are leaves. * * The mock tracks the leaves, which of them is the current tab, and whether the group is stacked. Nothing is * rendered, so the tab headers, their widths and the scrolling that go with them are absent. */ export declare class WorkspaceTabs extends WorkspaceParent { /** * Whether the tab group may keep a single child; always `true`, as in Obsidian. */ allowSingleChild: boolean; /** * The index in {@link WorkspaceTabs.children} of the tab currently shown. `Workspace.setActiveLeaf` moves it, and * `Workspace.getUnpinnedLeaf` reuses only a leaf that is its group's current tab. */ currentTab: number; /** * Whether the group shows its tabs stacked rather than as a single visible tab. `false` unless * {@link WorkspaceTabs.setStacked} sets it. */ isStacked: boolean; /** * The split the tab group sits in. A tab group with no parent holds an empty strict proxy instead, which throws on * any member access. */ parent: WorkspaceSplitOriginal; /** * The item kind, `tabs`, as Obsidian names it. */ type: string; /** * Creates a tab group. Obsidian does not construct it publicly; use {@link WorkspaceTabs.create2__}. * * @param workspace - The workspace the tab group belongs to. * @param id - The item id. */ protected constructor(workspace: Workspace, id?: string); /** * Mock-only factory: creates a tab group, spyable via `vi.spyOn(WorkspaceTabs, 'create2__')`. The numbered * subclass variant of `create__`. * * @param workspace - The workspace the tab group belongs to. * @param id - The item id. * @returns The new tab group. */ static create2__(workspace: Workspace, id?: string): WorkspaceTabs; /** * Mock-only: views a value typed as Obsidian's `WorkspaceTabs` as this mock. The numbered subclass variant of * `fromOriginalType__`. * * @param value - The value typed as the original `WorkspaceTabs`. * @returns The same object, typed as the mock. */ static fromOriginalType4__(value: WorkspaceTabsOriginal): WorkspaceTabs; /** * Mock-only: views this mock as Obsidian's `WorkspaceTabs` type. The numbered subclass variant of * `asOriginalType__`. * * @returns The same object, typed as the original `WorkspaceTabs`. */ asOriginalType4__(): WorkspaceTabsOriginal; /** * Mock-only construction hook, called at the end of the constructor; a no-op meant for * `vi.spyOn(WorkspaceTabs.prototype, 'constructor4__')`. * * @param _workspace - The workspace the tab group was created with. * @param _id - The item id the tab group was created with. */ constructor4__(_workspace: Workspace, _id?: string): void; /** * Removes a child, keeping {@link WorkspaceTabs.currentTab} on the same leaf when another one went, and moving it to * the nearest remaining tab when the current one did — as Obsidian does. Removing the last child records whether the * group was stacked, so the group the workspace re-creates in an emptied root split matches it. * * @param child - The child to remove. */ removeChild(child: WorkspaceItem): void; /** * Shows a child of the group, by identity. * * @param tab - The child to show; one that is not a child of this group is ignored. */ selectTab(tab: WorkspaceItem): void; /** * Shows the tab at an index, clamped to the group's range. As in Obsidian, selecting the tab that is already current * does nothing. * * @param index - The index to show. */ selectTabIndex(index: number): void; /** * Serializes the tab group, as Obsidian does: the parent's keys, `currentTab` when it is past the first tab, and * `stacked` when the group is stacked. * * @returns The serialized tab group. */ serialize(): SerializedWorkspaceItem; /** * Stacks or unstacks the group. As in Obsidian, a group that holds children asks the workspace to update the layout. * * @param stacked - Whether the group should be stacked. */ setStacked(stacked: boolean): void; private requireWorkspace; }