Main Pane

by arasan95
5
4
3
2
1
Score: 50/100

Description

Designate a main pane in Obsidian and automatically route file opens to it.

Reviews

No reviews yet.

Stats

1
stars
21
downloads
0
forks
2
days
2
days
2
days
0
total PRs
0
open PRs
0
closed PRs
0
merged PRs
0
total issues
0
open issues
0
closed issues
7
commits

README file from

Github

Main Pane

Designate one pane as your Main Pane, and route file-open operations to it.

In a common setup the workspace is split left/right:

  • Left pane = main working area
  • Right pane = Graph, Juggl, backlinks, reference notes, …

Main Pane redirects opens so that, wherever you open (links, Quick Switcher, File Explorer, Search, Backlinks, Graph, Command Palette, new notes, other plugins, …), the file opens up in your chosen Main Pane.

Features

  • Mark / Clear Main Pane — Command Palette commands (Main Pane: Set Current Pane as Main Pane, Main Pane: Clear Main Pane) plus buttons in the settings tab.
  • Always open in the Main Pane — every file-open surface is redirected to a new tab in the Main Pane. Split / pop-out opens (Alt+click, Cmd+Shift+Alt+click) stay native.
  • Toggle redirect mode — when you do not want an open to go to the Main Pane, click the status-bar indicator (or run Main Pane: Toggle Redirect to Main Pane) to switch redirect off; the opened note then stays where it was opened. Click again to turn redirect back on.
  • Bound to the pane, not the note — the designation follows the tab strip. Switching, moving, or deleting notes inside it does not move the designation, and closing the last note tab keeps the pane alive with an empty tab (unless Auto-select is on).
  • Visual indicator — a thin accent outline + small ◉ Main Pane badge on the pane, plus a status bar icon. Toggleable (Settings → Indicator → Show indicator).
  • Robust lifecycle — if the Main Pane is closed, the designation is cleared silently (no errors). An optional setting auto-promotes the most recently used pane.

How it works

Obsidian 1.13+ funnels essentially every file-open surface through WorkspaceLeaf.openFile() (links resolve to it via workspace.openLinkTextleaf.openLinkText, and the File Explorer, Search, Backlinks, Graph, Quick Switcher, new notes, and other plugins call it directly). The plugin uses two official mechanisms:

  1. Route the open. WorkspaceLeaf.openFile is wrapped. When Obsidian is about to navigate a leaf outside the Main Pane, the file is opened in a new tab of the Main Pane instead, with the original state/eState preserved.
  2. Place the new tab. Workspace.getLeaf("tab" | true) is wrapped: the Main Pane's leaf is briefly marked as the most recent one, so Obsidian's own "new tab" logic creates the tab inside the Main Pane's tab strip.

Split and pop-out opens (getLeaf("split" | "window"), i.e. Alt+click / Cmd+Shift+Alt+click) are tagged and passed through natively. In-note [[#heading]] navigation stays in the pane it was clicked in. On unload the original methods are restored.

When a sidebar view (Backlinks, Search, Graph, …) is active, Obsidian's plain open first creates an empty leaf inside that sidebar's tab strip; that leftover empty tab is detached again after the open lands in the Main Pane.

The Main Pane is a tab strip, not a note. When its last note tab is closed, the plugin opens an empty placeholder tab first so Obsidian does not destroy the pane (and the designation with it). Closing the placeholder itself closes the pane and clears the designation. With Auto-select a new Main Pane on, the pane is allowed to close and the most recently used pane is promoted instead.

Settings

Main Pane

  • Current Main Pane — shows which pane is designated (or Not set).
  • Set Active Pane as Main Pane — assigns the currently focused pane.
  • Clear Main Pane — removes the designation.

Open behavior

  • Redirect opens to Main Pane — one switch for all file-open surfaces (internal links, File Explorer, Search, Backlinks, Graph, Quick Switcher, Command Palette, other plugins). Obsidian does not expose which surface triggered an open, so per-surface toggles are not possible.
  • Open newly created files in Main Pane — independent switch for notes created by the "New note" command, Templater, QuickAdd, Dataview, Tasks, and similar plugins.

Indicator

  • Show pane outline — colored outline around the Main Pane.
  • Show pane badge — the ◉ Main Pane badge inside the pane.
  • Show status bar icon — the icon in the status bar (clicking it still toggles redirect mode).

When the Main Pane closes

  • Automatically select a new Main Pane — off: plain Clear; on: promote the most recently used pane.

Development

Requirements: Node.js ≥ 18, npm.

npm install          # install dependencies
npm run dev          # watch mode → rebuilds main.js on change
npm run build        # type-check + production bundle (main.js)
npm run typecheck    # TypeScript check only

Output: main.js (esbuild, CommonJS, targets ES2021). styles.css and manifest.json are copied unchanged.

Install for development

  1. Copy this folder into <vault>/.obsidian/plugins/main-pane/ (the folder name must match the plugin id main-pane).
  2. Reload Obsidian (or restart the app).
  3. Enable the Main Pane plugin in Settings → Community plugins.
  4. Run Main Pane: Set Current Pane as Main Pane from the Command Palette.

To update the plugin after a change, run npm run build, copy the new main.js, and reload Obsidian.

Usage

  1. In your split layout, click the pane you want to be the main working area.
  2. Run Main Pane: Set Current Pane as Main Pane (Command Palette).
  3. Open anything — links in the other pane, Quick Switcher, File Explorer, Search, Backlinks, Graph, create a new note — and it opens in a new tab of the designated pane, and the view switches to it.
  4. See the indicator (status bar) and the pane outline to know where opens will go. Click to toggle redirect mode on/off.
  5. Clear with Main Pane: Clear Main Pane, or set again after swapping.

When redirect mode is OFF, opens stay exactly where Obsidian would put them; the Main Pane designation and indicator remain so you can turn it back on with one click.

Limitations

  1. Drag & drop onto a specific tab strip. The file opens in the Main Pane (as designed), but an empty tab may remain in the strip it was dropped onto.
  2. Empty placeholder tab. Closing the last note tab of the Main Pane leaves an empty tab in that pane so the pane survives. Close that tab to remove the pane (and the designation).
  3. Not every open can be intercepted. Surfaces that build their own leaves or views (pop-out windows created directly, hover previews) may bypass the routing.
  4. Tab reuse in the Main Pane. If the file is already open in a tab of the Main Pane, the plugin switches to that tab instead of opening a duplicate; otherwise it opens a new tab in the Main Pane.
  5. Drag & drop targets the drop location. Dropping a file/link onto a specific pane opens it exactly there; the Main Pane redirect does not apply to drag-and-drop.
  6. Cross-session identification is best-effort. The Main Pane is saved by Obsidian's semi-internal leaf id, which is stable within a session but may change after a full app restart. On restart the plugin reports Not set (re-promote via the auto-select option or the command) instead of erroring.
  7. Main Pane should be a Markdown pane. Opening a note into a Graph/Canvas/Bases pane relies on Obsidian's own navigation; when the current view cannot display the file, Obsidian opens a standard markdown leaf instead.

Other plugins

  • Open Tab Settings — this plugin picks which pane hosts the tab, OTS picks how tabs are created/duplicated. They compose cleanly.
  • QuickAdd, Templater, Tasks, Dataview, Juggl — these use standard openFile calls, which are re-routed when the corresponding setting is on. Nothing in their settings or internals is touched.
  • On unload the plugin restores the original WorkspaceLeaf.openFile, WorkspaceLeaf.detach, and Workspace.getLeaf; there is nothing left behind.

Compatibility

  • main.js targets Obsidian 1.5.1+ (getLeafById); the routing relies on behavior present in Obsidian 1.13+.
  • Marked isDesktopOnly: false; desktop is the primary target — mobile pane behavior (drawers, pop-outs) varies.

Contributing

Improvements welcome. Please keep the "official-API only, no destructive hack" rule and document any new limitation in this README.

License

MIT — see LICENSE.