### Install Vertical Tabs Plugin for Obsidian Source: https://context7.com/oxdc/obsidian-vertical-tabs/llms.txt Instructions for installing the Vertical Tabs plugin via Obsidian's Community Plugins interface or by manual download and extraction. This code block is a comment explaining the installation steps. ```plaintext // The plugin is installed through Obsidian's Community Plugins interface // 1. Open Obsidian Settings > Community Plugins // 2. Browse for "Vertical Tabs" // 3. Click Install, then Enable // Alternatively, install manually: // 1. Download the latest release from GitHub // 2. Extract to .obsidian/plugins/vertical-tabs/ // 3. Enable in Community Plugins settings ``` -------------------------------- ### Persistence Manager: Instance-Scoped Storage (TypeScript) Source: https://context7.com/oxdc/obsidian-vertical-tabs/llms.txt Shows how to manage instance-scoped storage, which is unique to the current vault on the current device. This data is stored in localStorage using both installation and device IDs. ```typescript // Instance-scoped storage (this vault on this device only) // Stored in localStorage with both installation ID and device ID function useInstanceStorage(): void { const pm = plugin.persistenceManager; // Store instance-specific data pm.instance.set('window-state', { position: { x: 100, y: 200 }, size: { width: 800, height: 600 } }); // Retrieve instance-specific data const windowState = pm.instance.get<{ position: { x: number; y: number }; size: { width: number; height: number }; }>('window-state'); console.log('Window state:', windowState); // Check and remove if (pm.instance.has('window-state')) { pm.instance.remove('window-state'); } } useInstanceStorage(); ``` -------------------------------- ### Set Tab Navigation Strategy in Vertical Tabs Source: https://context7.com/oxdc/obsidian-vertical-tabs/llms.txt Shows how to change the tab navigation strategy using the `useSettings` hook from `PluginContext`. It lists available strategies and provides an example for configuring the 'ide' strategy with specific presets. Requires `useSettings` and `TabNavigationStrategy`. ```typescript import { useSettings } from './models/PluginContext'; import { TabNavigationStrategy } from './models/TabNavigation'; // Available strategies: // - "obsidian-plus": Enhanced Obsidian navigation (default) // - "obsidian": Default Obsidian behavior // - "ide": VSCode-like with ephemeral tabs and deduplication // - "explorer": Ephemeral tabs without deduplication // - "notebook": Always new tab with deduplication // - "prefer-new-tab": Always open in new tab // - "custom": Custom configuration // Change navigation strategy const { setTabNavigationStrategy } = useSettings.getState(); setTabNavigationStrategy(app, TabNavigationStrategy.IDE); // IDE mode configuration example const idePreset = { alwaysOpenInNewTab: false, deduplicateTabs: true, // Prevent duplicate tabs deduplicateSameGroupTabs: false, deduplicateSidebarTabs: false, deduplicatePopupTabs: false, ephemeralTabs: true, // Temporary tabs (like VSCode) autoCloseEphemeralTabs: true, // Auto-close unused ephemeral tabs smartNavigation: true // Intelligent tab placement }; setTabNavigationStrategy(app, "ide", idePreset); ``` -------------------------------- ### Manage Device-Specific Plugin Settings Source: https://context7.com/oxdc/obsidian-vertical-tabs/llms.txt This code manages device-specific settings for the Obsidian plugin, allowing it to be disabled on a particular device without affecting others. It includes loading, saving, and toggling the disable state, as well as accessing device and installation IDs. It utilizes functions and state from './models/PluginContext'. ```typescript import { useSettings, DISABLE_KEY } from './models/PluginContext'; const { loadDeviceSpecificSettings, saveDeviceSpecificSettings, toggleDisableOnThisDevice } = useSettings.getState(); // Load device-specific settings from localStorage loadDeviceSpecificSettings(); // Disable plugin on this device only toggleDisableOnThisDevice(true); // Enable plugin on this device toggleDisableOnThisDevice(false); // Save device-specific settings saveDeviceSpecificSettings(); // Check if disabled on this device const disabledOnDevice = useSettings.getState().disableOnThisDevice; console.log('Disabled on this device:', disabledOnDevice); // Access device ID and installation ID const pm = plugin.persistenceManager; console.log('Device ID:', pm.deviceID); console.log('Installation ID:', pm.installationID); ``` -------------------------------- ### Manage Ephemeral Tabs Behavior in TypeScript Source: https://context7.com/oxdc/obsidian-vertical-tabs/llms.txt Provides functions to manage ephemeral tabs (temporary, VSCode-style tabs) in Obsidian. This includes enabling the feature, installing necessary handlers, and converting ephemeral tabs to permanent ones either individually or in bulk. Depends on ephemeral tab service functions and Obsidian's workspace. ```typescript import { installTabHeaderHandlers, makeLeafNonEphemeral, makeLeafNonEphemeralByID } from './services/EphemeralTabs'; // Enable ephemeral tabs const { setSettings } = useSettings.getState(); setSettings({ ephemeralTabs: true, autoCloseEphemeralTabs: true }); // Install handlers for all tabs installTabHeaderHandlers(app); // Make a specific tab non-ephemeral (permanent) const leaf = app.workspace.activeLeaf; if (leaf) { makeLeafNonEphemeral(leaf); } // Make tab non-ephemeral by ID makeLeafNonEphemeralByID(app, "leaf-id-123"); // Make multiple tabs non-ephemeral const leafIDs = ["leaf-1", "leaf-2", "leaf-3"]; makeTabsNonEphemeralByList(app, leafIDs); ``` -------------------------------- ### Create and Load Bookmarks for Tabs and Groups Source: https://context7.com/oxdc/obsidian-vertical-tabs/llms.txt This TypeScript code illustrates how to create bookmarks for individual tabs, entire tab groups, and tab history within Obsidian. It also shows how to load the name of a saved bookmark. It requires functions from './models/VTBookmark' and Obsidian's 'WorkspaceParent' and 'WorkspaceLeaf' types. ```typescript import { createBookmarkForGroup, createBookmarkForLeaf, createBookmarkForLeafHistory, loadNameFromBookmark } from './models/VTBookmark'; import { WorkspaceParent, WorkspaceLeaf } from 'obsidian'; // Create bookmark for entire tab group const group: WorkspaceParent = app.workspace.rootSplit; await createBookmarkForGroup(app, group, 'My Project Workspace'); // Create bookmark for single tab const leaf: WorkspaceLeaf = app.workspace.activeLeaf; await createBookmarkForLeaf(app, leaf, 'Important Note'); // Create bookmark from tab history await createBookmarkForLeafHistory(app, leaf); // Load bookmark name for group const bookmarkName = await loadNameFromBookmark(app, group); console.log('Bookmark name:', bookmarkName); ``` -------------------------------- ### Configure Basic Vertical Tabs Plugin Settings Source: https://context7.com/oxdc/obsidian-vertical-tabs/llms.txt Demonstrates how to access and manipulate basic plugin settings for Vertical Tabs. It shows default settings and how to load/save them using the plugin instance. Requires the ObsidianVerticalTabs plugin and PluginSettings model. ```typescript import ObsidianVerticalTabs from './main'; import { DEFAULT_SETTINGS } from './models/PluginSettings'; // Plugin loads with default settings const defaultConfig = { showActiveTabs: false, // Show active tabs in horizontal bar hideSidebars: true, // Hide default sidebars trimTabNames: false, // Trim long tab names zenMode: false, // Enable zen mode enableTabZoom: false, // Allow per-tab zooming ephemeralTabs: false, // VSCode-style temporary tabs deduplicateTabs: false, // Prevent duplicate tabs navigationStrategy: "obsidian-plus", // Tab navigation mode backgroundMode: false, // Run in background disableOnThisDevice: false // Disable plugin on this device }; // Access plugin instance in code const plugin: ObsidianVerticalTabs = app.plugins.plugins['vertical-tabs']; // Load and save settings await plugin.loadSettings(); await plugin.saveSettings(); ``` -------------------------------- ### Persistence Manager: Device-Scoped Storage (TypeScript) Source: https://context7.com/oxdc/obsidian-vertical-tabs/llms.txt Demonstrates how to use device-scoped storage via the PersistenceManager. This storage synchronizes settings across vaults on the same device and is stored in localStorage. ```typescript import { PersistenceManager } from './models/PersistenceManager'; // Access persistence manager const plugin: ObsidianVerticalTabs = app.plugins.plugins['vertical-tabs']; const pm: PersistenceManager = plugin.persistenceManager; // Device-scoped storage (syncs across vaults on same device) // Stored in localStorage with device ID pm.device.set('user-preference', { theme: 'dark', fontSize: 14 }); const preference = pm.device.get<{ theme: string; fontSize: number }>('user-preference'); console.log('Preference:', preference); // Check if key exists if (pm.device.has('user-preference')) { console.log('Preference found'); } // Remove data pm.device.remove('user-preference'); ``` -------------------------------- ### Extract Public Key using jq Source: https://github.com/oxdc/obsidian-vertical-tabs/blob/master/KEYS.txt This command extracts the public key from a plugin's manifest.json file using the `jq` utility. It assumes the public key is stored under the '.publicKey' field. ```bash jq -r '.publicKey' /path/to/your/plugin/manifest.json ``` -------------------------------- ### Persistence Manager: Vault-Scoped Storage (TypeScript) Source: https://context7.com/oxdc/obsidian-vertical-tabs/llms.txt Illustrates using vault-scoped storage, which syncs data across devices for a specific vault. Data is stored as JSON files in the vault's plugin directory and operations are asynchronous. ```typescript // Vault-scoped storage (syncs across devices for this vault) // Stored in .obsidian/plugins/vertical-tabs/ as JSON files // All operations are async async function useVaultStorage(): Promise { const pm = plugin.persistenceManager; // Save vault-specific data await pm.vault.set('tab-layout', { groups: ['Group 1', 'Group 2'], collapsed: [false, true] }); // Load vault-specific data const layout = await pm.vault.get<{ groups: string[]; collapsed: boolean[] }>('tab-layout'); console.log('Layout:', layout); // Check existence const exists = await pm.vault.has('tab-layout'); console.log('Layout exists:', exists); // Remove data await pm.vault.remove('tab-layout'); } useVaultStorage(); ``` -------------------------------- ### TypeScript: Custom Zoom Levels for Obsidian Tabs Source: https://context7.com/oxdc/obsidian-vertical-tabs/llms.txt Demonstrates how to set and manage custom zoom levels for Obsidian tabs using constants for minimum, maximum, and step zoom values. It includes functions to apply zoom with validation and shows how zoom state is persisted. ```typescript import { MIN_ZOOM, MAX_ZOOM, ZOOM_STEP } from './services/TabZoom'; // Zoom constants console.log('Min zoom:', MIN_ZOOM); // 0.5 (50%) console.log('Max zoom:', MAX_ZOOM); // 3.0 (300%) console.log('Zoom step:', ZOOM_STEP); // 0.1 (10%) // Apply custom zoom with validation function applyCustomZoom(view: View, zoomLevel: number): void { const clampedZoom = Math.min(Math.max(zoomLevel, MIN_ZOOM), MAX_ZOOM); setZoomFactor(view, clampedZoom); } // Example: Set zoom to 75% const activeView = app.workspace.activeLeaf?.view; if (activeView) { applyCustomZoom(activeView, 0.75); } // Zoom state persists in ephemeral state const eState = view.getEphemeralState(); console.log('Saved zoom:', eState.zoom); ``` -------------------------------- ### Link Folders to Tab Groups and Configure Settings Source: https://context7.com/oxdc/obsidian-vertical-tabs/llms.txt This snippet shows how to link a folder to a tab group in Obsidian and manage linked folder settings. It includes defining sort strategies, linking folders using the 'linkFolderToGroup' function, and configuring settings like 'linkedFolderLimit' and 'linkedFolderSortStrategy'. It also demonstrates adding menu items to the folder context menu. ```typescript import { linkFolderToGroup, linkedFolderSortStrategyOptions } from './services/OpenFolder'; import { TFolder, WorkspaceParent } from 'obsidian'; // Available sort strategies for linked folders const sortOptions = linkedFolderSortStrategyOptions; console.log('Sort options:', sortOptions); // Link folder to group const folder: TFolder = app.vault.getAbstractFileByPath('Projects/MyProject') as TFolder; const group: WorkspaceParent = app.workspace.rootSplit; linkFolderToGroup(app, folder, group); // Configure linked folder settings const { setSettings } = useSettings.getState(); setSettings({ linkedFolderLimit: 10, // Max files to show linkedFolderSortStrategy: 'fileNameAToZ' // Sort strategy }); // Add menu items to folder context menu addMenuItemsToFolderContextMenu(app); ``` -------------------------------- ### Integrate Plugin Context and Settings in React Components Source: https://context7.com/oxdc/obsidian-vertical-tabs/llms.txt This code shows how to provide and consume plugin context within React components using PluginContext. It also demonstrates accessing and modifying settings like zen mode via Zustand selectors and actions. Requires PluginContext, usePlugin, useApp, useSettings hooks. ```typescript import { PluginContext, usePlugin, useApp, useSettings } from './models/PluginContext'; import React from 'react'; // Provide plugin context to React tree function MyPluginView({ plugin }: { plugin: ObsidianVerticalTabs }) { return ( ); } // Access plugin in child components function MyComponent() { const plugin = usePlugin(); const app = useApp(); const settings = useSettings.use.zenMode(); const toggleZen = () => { useSettings.getState().toggleZenMode(); }; return (

Zen Mode: {settings ? 'On' : 'Off'}

); } ``` -------------------------------- ### Verify Public Key Fingerprint with sha256sum Source: https://github.com/oxdc/obsidian-vertical-tabs/blob/master/KEYS.txt This command verifies the fingerprint of a received public key. It decodes the base64 encoded key and then calculates its SHA256 hash for comparison against known fingerprints. ```bash echo -n "[PUBLIC_KEY_YOU_RECEIVED]" | base64 -d | sha256sum ``` -------------------------------- ### Access Obsidian Vertical Tabs Settings with Zustand Selectors Source: https://context7.com/oxdc/obsidian-vertical-tabs/llms.txt Demonstrates efficient access to individual and multiple settings using Zustand selectors, and retrieving actions for state modification. This allows for optimized re-rendering in React components. Requires the useSettings hook. ```typescript import { useSettings } from './models/PluginContext'; function SettingsComponent() { // Access individual settings (efficient re-rendering) const zenMode = useSettings.use.zenMode(); const ephemeralTabs = useSettings.use.ephemeralTabs(); const enableTabZoom = useSettings.use.enableTabZoom(); // Access multiple settings const { navigationStrategy, deduplicateTabs } = useSettings((state) => ({ navigationStrategy: state.navigationStrategy, deduplicateTabs: state.deduplicateTabs })); // Get actions const { setSettings, toggleZenMode } = useSettings.getState(); return (

Navigation: {navigationStrategy}

); } ``` -------------------------------- ### Define and Trigger Custom Events in Obsidian Source: https://context7.com/oxdc/obsidian-vertical-tabs/llms.txt This snippet demonstrates how to define custom event names and trigger them within the Obsidian workspace. It also shows how to listen for specific events and react to their triggers. It depends on the 'EVENTS' constant from './constants/Events'. ```typescript import { EVENTS } from './constants/Events'; // Available custom events const events = { DEDUPLICATE_TABS: 'vertical-tabs:deduplicate-tabs', EPHEMERAL_TABS_INIT: 'vertical-tabs:ephemeral-tabs-init', EPHEMERAL_TABS_DEINIT: 'vertical-tabs:ephemeral-tabs-deinit', EPHEMERAL_TABS_UPDATE: 'vertical-tabs:ephemeral-tabs-update', UPDATE_TOGGLE: 'vertical-tabs:update-toggle', ENHANCED_KEYBOARD_TAB_SWITCH: 'vertical-tabs:enhanced-keyboard-tab-switch', RESET_KEYBOARD_TAB_SWITCH: 'vertical-tabs:reset-keyboard-tab-switch', GROUP_VIEW_CHANGE: 'vertical-tabs:group-view-change', EPHEMERAL_TOGGLE: 'vertical-tabs:ephemeral-toggle', ALT_KEY_PRESSED: 'vertical-tabs:alt-key-pressed' }; // Trigger deduplication app.workspace.trigger(EVENTS.DEDUPLICATE_TABS); // Trigger ephemeral tabs initialization app.workspace.trigger(EVENTS.EPHEMERAL_TABS_INIT, true); // Listen to events app.workspace.on(EVENTS.GROUP_VIEW_CHANGE, (viewType) => { console.log('Group view changed to:', viewType); }); // Listen to ephemeral toggle on a leaf leaf.on(EVENTS.EPHEMERAL_TOGGLE, (isEphemeral) => { console.log('Tab ephemeral state:', isEphemeral); }); ``` -------------------------------- ### Configure Vertical Tabs Group Views (TypeScript) Source: https://context7.com/oxdc/obsidian-vertical-tabs/llms.txt Configures the minimum width for column views and the zoom factor for mission control views. It also allows updating multiple group view options and applying general settings for the plugin. ```typescript import { setColumnViewMinWidth, setMissionControlViewZoomFactor } from './models/VTGroupView'; import { useSettings } from './models/PluginContext'; // Configure Column View setColumnViewMinWidth(300); // Minimum width in pixels // Configure Mission Control View setMissionControlViewZoomFactor(0.5); // Zoom factor (0.5 = 50%) // Update multiple group view options const { setGroupViewOptions } = useSettings.getState(); setGroupViewOptions(app, { columnViewMinWidth: 400, missionControlViewZoomFactor: 0.6, continuousViewShowMetadata: true, continuousViewShowBacklinks: true }); // Apply settings const { setSettings } = useSettings.getState(); setSettings({ columnViewMinWidth: 350, continuousViewShowMetadata: false, continuousViewShowBacklinks: false, missionControlViewZoomFactor: 0.5, disablePointerInMissionControlView: true }); ``` -------------------------------- ### Monkey Patch Obsidian API with 'monkey-around' Source: https://context7.com/oxdc/obsidian-vertical-tabs/llms.txt This snippet demonstrates advanced API usage by 'monkey patching' Obsidian's core classes like WorkspaceLeaf, ItemView, and Workspace using the 'monkey-around' library. It allows for custom logic modification of existing methods, such as controlling tab navigation, handling ephemeral states with zoom, and customizing link opening behavior. ```typescript import { around } from 'monkey-around'; import { WorkspaceLeaf, ItemView, Workspace } from 'obsidian'; // Patch WorkspaceLeaf.prototype.canNavigate plugin.register( around(WorkspaceLeaf.prototype, { canNavigate(old) { return function () { // Custom navigation logic const settings = plugin.settings; if (settings.alwaysOpenInNewTab) { return false; // Always create new tab } return old.call(this); }; } }) ); // Patch ItemView to handle zoom state plugin.register( around(ItemView.prototype, { setEphemeralState(old) { return function (eState: object) { const newState = { zoom: this.zoom ?? 1, ...eState }; old.call(this, newState); this.zoom = newState.zoom; }; } }) ); // Patch Workspace.openLinkText for custom link handling around(Workspace.prototype, { openLinkText(old) { return async function (linkText, sourcePath, newLeaf?, openViewState?) { console.log('Opening link:', linkText); return old.call(this, linkText, sourcePath, newLeaf, openViewState); }; } }); ``` -------------------------------- ### Open Vertical Tabs View in Obsidian Source: https://context7.com/oxdc/obsidian-vertical-tabs/llms.txt Provides TypeScript code to programmatically open the Vertical Tabs view within Obsidian. It handles finding an existing leaf or creating a new one and revealing it. Dependencies include WorkspaceLeaf and VERTICAL_TABS_VIEW. ```typescript import { WorkspaceLeaf } from 'obsidian'; import { VERTICAL_TABS_VIEW } from './views/VerticalTabsView'; // Programmatically open the vertical tabs view async function openVerticalTabs(app: App): Promise { try { // Get existing leaf or create new one in left sidebar const leaf: WorkspaceLeaf = app.workspace.getLeavesOfType(VERTICAL_TABS_VIEW)[0] ?? app.workspace.getLeftLeaf(false); // Set view state and reveal leaf.setViewState({ type: VERTICAL_TABS_VIEW, active: true }); app.workspace.revealLeaf(leaf); } catch (error) { console.error('Failed to open Vertical Tabs:', error); } } // Use the command palette app.commands.executeCommandById('vertical-tabs:open-vertical-tabs'); ``` -------------------------------- ### TypeScript: Obsidian Group View Types and Display Modes Source: https://context7.com/oxdc/obsidian-vertical-tabs/llms.txt Demonstrates how to identify, set, and refresh group view types in Obsidian. It covers different view types like Default, Continuous, Column, and Mission Control views, and how to manage them programmatically. ```typescript import { GroupViewType, identifyGroupViewType, setGroupViewType, refreshGroupViewTypes } from './models/VTGroupView'; import { WorkspaceParent } from 'obsidian'; // Available group view types const viewTypes = { Default: GroupViewType.Default, // "vt-default-view" ContinuousView: GroupViewType.ContinuousView, // "vt-continuous-view" ColumnView: GroupViewType.ColumnView, // "vt-column-view" MissionControlView: GroupViewType.MissionControlView // "vt-mission-control-view" }; // Get current group view type const group: WorkspaceParent = app.workspace.rootSplit; const currentView = identifyGroupViewType(group); console.log('Current view:', currentView); // Change group view type setGroupViewType(group, GroupViewType.ColumnView); // Refresh all group views refreshGroupViewTypes(app); ``` -------------------------------- ### Configure Custom Navigation Strategy in TypeScript Source: https://context7.com/oxdc/obsidian-vertical-tabs/llms.txt Sets up a custom navigation strategy for Obsidian tabs, allowing fine-grained control over tab behavior like always opening in new tabs, deduplication across various scopes, and ephemeral tab settings. Requires access to plugin settings and the Obsidian app instance. ```typescript import { useSettings } from './models/PluginContext'; // Create custom navigation strategy function setCustomStrategy(app: App): void { const customSettings = { alwaysOpenInNewTab: false, deduplicateTabs: true, deduplicateSameGroupTabs: true, // Deduplicate within same group deduplicateSidebarTabs: true, // Deduplicate sidebar tabs deduplicatePopupTabs: true, // Deduplicate popup tabs ephemeralTabs: true, autoCloseEphemeralTabs: false, // Keep ephemeral tabs open smartNavigation: true }; const { setTabNavigationStrategy } = useSettings.getState(); setTabNavigationStrategy(app, "custom", customSettings); } // Usage setCustomStrategy(app); ``` -------------------------------- ### Manage Linked Folders in Obsidian Vertical Tabs Source: https://context7.com/oxdc/obsidian-vertical-tabs/llms.txt This snippet demonstrates how to add, check, retrieve, and remove linked folders within a workspace group using the ViewState model. It requires the useViewState hook and WorkspaceParent type. ```typescript import { useViewState } from './models/ViewState'; import { WorkspaceParent } from 'obsidian'; const viewState = useViewState.getState(); // Add linked folder to group const group: WorkspaceParent = app.workspace.rootSplit; const linkedFolder = { path: 'Projects/MyProject', sortStrategy: 'fileNameAToZ' }; viewState.addLinkedGroup(group.id, linkedFolder); // Check if group is linked const isLinked = viewState.isLinkedGroup(group.id); console.log('Group is linked:', isLinked); // Get linked folder info const folder = viewState.getLinkedFolder(group.id); console.log('Linked folder:', folder); // Remove linked folder viewState.removeLinkedGroup(group); ``` -------------------------------- ### TypeScript: Manage Obsidian Tabs and Groups Source: https://context7.com/oxdc/obsidian-vertical-tabs/llms.txt Provides TypeScript code for managing tabs within Obsidian, including fetching tab data, refreshing the tab cache, retrieving information about the currently open file in a leaf, and moving tabs between groups or to the end of a group. ```typescript import { getTabs, getOpenFileOfLeaf, moveTab, moveTabToEnd } from './services/GetTabs'; import { tabCacheStore } from './stores/TabCacheStore'; // Get all tabs organized by groups const tabCache = getTabs(app); console.log('Tab cache:', tabCache); // Refresh tab cache tabCacheStore.getActions().refresh(app); // Get tab cache state const { content, groupIDs, leaveIDs } = tabCacheStore.getState(); console.log('Group IDs:', groupIDs); console.log('Leaf IDs:', leaveIDs); // Get file opened in a leaf const leaf = app.workspace.activeLeaf; const file = getOpenFileOfLeaf(app, leaf); console.log('Open file:', file?.path); // Move tab to different position const sourceLeafID = "leaf-source-id"; const targetLeafID = "leaf-target-id"; const movedLeaf = moveTab(app, sourceLeafID, targetLeafID); // Move tab to end of group const targetGroup = app.workspace.rootSplit; const movedToEnd = moveTabToEnd(app, sourceLeafID, targetGroup); ``` -------------------------------- ### View State Management: Active Leaf and Focus (TypeScript) Source: https://context7.com/oxdc/obsidian-vertical-tabs/llms.txt Handles tracking the active workspace leaf and managing focus. Includes functions to set and retrieve the latest active leaf, lock focus on the current or a specific leaf, and detect if the active group has changed. ```typescript import { useViewState } from './models/ViewState'; import { WorkspaceLeaf } from 'obsidian'; const viewState = useViewState.getState(); // Track latest active leaf const leaf: WorkspaceLeaf = app.workspace.activeLeaf; viewState.setLatestActiveLeaf(plugin, leaf); // Get latest active leaf const latestLeaf = viewState.latestActiveLeaf; console.log('Latest active leaf:', latestLeaf?.id); // Lock focus on current leaf viewState.lockFocus(plugin); // Lock focus on specific leaf viewState.lockFocusOnLeaf(app, leaf); // Check if group changed between leaf switches const oldLeaf = viewState.latestActiveLeaf; const newLeaf = app.workspace.activeLeaf; const groupChanged = viewState.checkIfGroupChanged(app.workspace, oldLeaf, newLeaf); console.log('Group changed:', groupChanged); ``` -------------------------------- ### TypeScript: Sort Tabs in Obsidian Source: https://context7.com/oxdc/obsidian-vertical-tabs/llms.txt Shows how to sort tabs in Obsidian using various strategies like alphabetical order, pinned status, and recency. It demonstrates applying a sort strategy to the tab cache and clearing it. ```typescript import { sortTabs, sortStrategies } from './services/SortTabs'; import { tabCacheStore } from './stores/TabCacheStore'; // Available sort strategies const strategies = { titleAToZ: sortStrategies.titleAToZ, // Alphabetical A-Z titleZToA: sortStrategies.titleZToA, // Alphabetical Z-A pinnedAtTop: sortStrategies.pinnedAtTop, // Pinned tabs first pinnedAtBottom: sortStrategies.pinnedAtBottom, // Pinned tabs last recentOnTop: sortStrategies.recentOnTop, // Most recent first recentOnBottom: sortStrategies.recentOnBottom, // Least recent first oldestOnTop: sortStrategies.oldestOnTop, // Oldest files first oldestOnBottom: sortStrategies.oldestOnBottom // Newest files first }; // Sort tabs in a group const group = app.workspace.rootSplit; const sortedLeaves = sortTabs(group, strategies.titleAToZ); // Apply sort strategy to cache const { setSortStrategy, sort } = tabCacheStore.getActions(); setSortStrategy(strategies.recentOnTop); sort(); // Apply the sort // Clear sort strategy setSortStrategy(null); ``` -------------------------------- ### View State Management: Group Visibility (TypeScript) Source: https://context7.com/oxdc/obsidian-vertical-tabs/llms.txt Manages the visibility and collapse state of groups within the view. Allows setting group titles, toggling collapse/expand, and hiding/showing groups, as well as controlling all groups simultaneously. ```typescript import { useViewState } from './models/ViewState'; const viewState = useViewState.getState(); // Set group title viewState.setGroupTitle('group-id-123', 'My Project'); // Toggle group collapse state viewState.toggleCollapsedGroup('group-id-123', true); // Collapse viewState.toggleCollapsedGroup('group-id-123', false); // Expand // Toggle group visibility viewState.toggleHiddenGroup('group-id-123', true); // Hide viewState.toggleHiddenGroup('group-id-123', false); // Show // Collapse all groups viewState.setAllCollapsed(); // Expand all groups viewState.setAllExpanded(); // Auto-uncollapse active group viewState.uncollapseActiveGroup(app); ``` -------------------------------- ### Enhanced Keyboard Tab Switching in Obsidian Vertical Tabs Source: https://context7.com/oxdc/obsidian-vertical-tabs/llms.txt Code for enabling and disabling enhanced keyboard tab switching, along with utilities for managing view cues and revealing tabs by user index. This improves navigation efficiency for keyboard users. Requires useSettings and useViewState hooks. ```typescript import { useSettings } from './models/PluginContext'; import { useViewState } from './models/ViewState'; // Enable enhanced keyboard tab switch const { toggleEnhancedKeyboardTabSwitch } = useSettings.getState(); toggleEnhancedKeyboardTabSwitch(app, true); // Disable enhanced keyboard tab switch toggleEnhancedKeyboardTabSwitch(app, false); // View cue management for keyboard navigation const viewState = useViewState.getState(); // Map real index to view cue index const viewCueIndex = viewState.mapViewCueIndex(5); // Convert user index back to real index const numOfLeaves = 10; const realIndex = viewState.convertBackToRealIndex(3, numOfLeaves); // Reveal tab by user index viewState.revealTabOfUserIndex(app, 5, false); // Modify and reset view cue viewState.modifyViewCueCallback(app); viewState.resetViewCueCallback(app); ``` -------------------------------- ### Control Zen Mode in Obsidian Vertical Tabs Source: https://context7.com/oxdc/obsidian-vertical-tabs/llms.txt Provides functions to toggle, enable, disable, and check the status of Zen Mode using the settings state. It allows fine-grained control over the UI appearance for focused work. Requires the useSettings hook. ```typescript import { useSettings } from './models/PluginContext'; const { toggleZenMode, setSettings } = useSettings.getState(); // Toggle zen mode toggleZenMode(); // Enable zen mode with settings setSettings({ zenMode: true, showActiveTabsInZenMode: false // Hide active tabs in zen mode }); // Disable zen mode setSettings({ zenMode: false }); // Check zen mode state const isZenMode = useSettings.getState().zenMode; console.log('Zen mode enabled:', isZenMode); ``` -------------------------------- ### Configure Tab Deduplication Settings in TypeScript Source: https://context7.com/oxdc/obsidian-vertical-tabs/llms.txt Allows configuration of tab deduplication behavior through plugin settings. Options include enabling global deduplication and specifying whether to include tabs within the same group, sidebar, or popup windows. Deduplication occurs automatically on file open actions. ```typescript import { useSettings } from './models/PluginContext'; // Configure deduplication behavior const { setSettings } = useSettings.getState(); setSettings({ deduplicateTabs: true, // Enable global deduplication deduplicateSameGroupTabs: true, // Deduplicate within same group only deduplicateSidebarTabs: true, // Include sidebar tabs deduplicatePopupTabs: true // Include popup windows }); // Deduplication happens automatically when: // 1. Opening a file that's already open // 2. Clicking a link to an open file // 3. Using Quick Switcher to open a file // 4. Opening from file explorer // Example: Handle deduplication before file opens app.workspace.on('file-open', async (file) => { if (file) { await handleBeforeOpen(app, file); } }); ``` -------------------------------- ### Control Background Mode in Obsidian Vertical Tabs Source: https://context7.com/oxdc/obsidian-vertical-tabs/llms.txt This snippet demonstrates how to enable, disable, and toggle the background mode, which affects the visibility and placement of vertical tabs. It requires the app instance and settings state. Requires the useSettings hook. ```typescript import { useSettings } from './models/PluginContext'; const { toggleBackgroundMode } = useSettings.getState(); // Enable background mode (hides vertical tabs, moves to separate group) toggleBackgroundMode(app, true); // Disable background mode (shows vertical tabs, restores to sidebar) toggleBackgroundMode(app, false); // Toggle background mode toggleBackgroundMode(app); // Check background mode state const isBackground = useSettings.getState().backgroundMode; console.log('Background mode:', isBackground); ``` -------------------------------- ### Control Per-Tab Zooming with TypeScript Source: https://context7.com/oxdc/obsidian-vertical-tabs/llms.txt Enables and manages per-tab zooming functionality in Obsidian. This code snippet shows how to enable the feature, zoom in/out, reset zoom to default, retrieve the current zoom level, and set a specific zoom factor for the active view. Requires tab zoom service functions and the Obsidian View API. ```typescript import { zoomIn, zoomOut, resetZoom, getZoomFactor, setZoomFactor } from './services/TabZoom'; import { View } from 'obsidian'; // Enable tab zoom feature const { setSettings } = useSettings.getState(); setSettings({ enableTabZoom: true }); // Get current view const view: View = app.workspace.activeLeaf?.view; if (view) { // Zoom in (increases by 0.1) zoomIn(view); // Zoom out (decreases by 0.1) zoomOut(view); // Reset to 100% resetZoom(view); // Get current zoom level const currentZoom = getZoomFactor(view); // Returns number (1.0 = 100%) console.log('Current zoom:', currentZoom); // Set specific zoom level (0.5 to 3.0 range) setZoomFactor(view, 1.5); // 150% } ``` -------------------------------- ### Perform Tab Deduplication with TypeScript Source: https://context7.com/oxdc/obsidian-vertical-tabs/llms.txt Enables deduplication of tabs in Obsidian, preventing multiple instances of the same file from being open. Includes functions to deduplicate existing tabs immediately and to deduplicate a specific file across targeted leaves, optionally focusing on the kept tab. Requires deduplication service functions and Obsidian's workspace and vault APIs. ```typescript import { deduplicateForTargets, deduplicateExistingTabs } from './services/DeduplicateTab'; import { TFile, WorkspaceLeaf } from 'obsidian'; // Deduplicate existing tabs immediately deduplicateExistingTabs(app); // Deduplicate specific file across target leaves const file: TFile = app.vault.getAbstractFileByPath('MyNote.md') as TFile; const targetLeaves: WorkspaceLeaf[] = app.workspace.getLeavesOfType('markdown'); // Deduplicate and focus on the kept tab const keptLeaf = deduplicateForTargets(app, file, targetLeaves, true); if (keptLeaf) { console.log('Tab deduplicated, kept leaf:', keptLeaf.id); } ``` -------------------------------- ### Check and Control Ephemeral Tab State in TypeScript Source: https://context7.com/oxdc/obsidian-vertical-tabs/llms.txt Illustrates how to check if a tab is ephemeral and how to manually make ephemeral tabs permanent. It covers programmatic conversion and event-driven conversions triggered by double-clicking a tab header or modifying an editor. Relies on Obsidian's WorkspaceLeaf and editor events. ```typescript import { WorkspaceLeaf } from 'obsidian'; // Check if tab is ephemeral function isTabEphemeral(leaf: WorkspaceLeaf): boolean { return leaf.isEphemeral === true; } // Ephemeral tabs become permanent on: // 1. Double-click on tab header leaf.tabHeaderEl?.ondblclick = (event: MouseEvent) => { makeLeafNonEphemeral(leaf); event.stopPropagation(); }; // 2. Editing the file app.workspace.on('editor-change', (_, info) => { if (info instanceof MarkdownView) { makeLeafNonEphemeral(info.leaf); } }); // 3. Manual conversion makeLeafNonEphemeral(leaf); ``` -------------------------------- ### TypeScript: Close Tabs in Obsidian Groups Source: https://context7.com/oxdc/obsidian-vertical-tabs/llms.txt Illustrates TypeScript functions for closing tabs within Obsidian groups. It covers closing all other tabs in the same group, closing tabs above the current one, closing tabs below the current one, and safely detaching a leaf with a specified timeout to prevent race conditions. ```typescript import { closeOthersInGroup, closeTabsToTopInGroup, closeTabsToBottomInGroup, safeDetach } from './services/CloseTabs'; import { WorkspaceLeaf } from 'obsidian'; const leaf: WorkspaceLeaf = app.workspace.activeLeaf; // Close all other tabs in the same group closeOthersInGroup(app, leaf); // Close all tabs above current tab closeTabsToTopInGroup(app, leaf); // Close all tabs below current tab closeTabsToBottomInGroup(app, leaf); // Safely detach a leaf (with timeout to prevent issues) safeDetach(leaf); // SAFE_DETACH_TIMEOUT is 100ms to prevent race conditions ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.