feat(main): ribbon opens the panel as a tab, tab and sidedock leaves reused separately
This commit is contained in:
@@ -9,8 +9,8 @@ Two things:
|
|||||||
|
|
||||||
## Commands
|
## Commands
|
||||||
|
|
||||||
- **Beaver: Open panel** - the right sidedock (also the ribbon icon).
|
- **Beaver: Open panel in a tab** - the wide layout with the conversation rail on the left (also the ribbon icon).
|
||||||
- **Beaver: Open panel in a tab** - the wide layout with the conversation rail on the left.
|
- **Beaver: Open panel** - the narrow column in the right sidedock; a tab and a column can be open at once, each command reuses its own.
|
||||||
- **Beaver: Open chat in panel** - the active note has `conversation_id` in its frontmatter; the panel shows that conversation.
|
- **Beaver: Open chat in panel** - the active note has `conversation_id` in its frontmatter; the panel shows that conversation.
|
||||||
- **Beaver: Send using selected agent** / **Send using different agent** - the note has `agent:` in its frontmatter.
|
- **Beaver: Send using selected agent** / **Send using different agent** - the note has `agent:` in its frontmatter.
|
||||||
|
|
||||||
|
|||||||
+8
-2
@@ -163,7 +163,7 @@ export default class BeaverPlugin extends Plugin {
|
|||||||
this.addSettingTab(new BeaverSettingsTab(this.app, this));
|
this.addSettingTab(new BeaverSettingsTab(this.app, this));
|
||||||
this.registerView(VIEW_TYPE_PANEL, (leaf) => new PanelView(leaf, this));
|
this.registerView(VIEW_TYPE_PANEL, (leaf) => new PanelView(leaf, this));
|
||||||
this.addRibbonIcon("bot", "Beaver", () => {
|
this.addRibbonIcon("bot", "Beaver", () => {
|
||||||
this.openPanel("side").catch(() => undefined);
|
this.openPanel("tab").catch(() => undefined);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.addCommand({
|
this.addCommand({
|
||||||
@@ -279,10 +279,16 @@ export default class BeaverPlugin extends Plugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Reveal a panel (creating one on first use) and, given an id, show it.
|
// Reveal a panel (creating one on first use) and, given an id, show it.
|
||||||
|
// A tab and a sidedock column can coexist; each placement reuses its own.
|
||||||
async openPanel(placement: "side" | "tab", id?: string): Promise<void> {
|
async openPanel(placement: "side" | "tab", id?: string): Promise<void> {
|
||||||
const { workspace } = this.app;
|
const { workspace } = this.app;
|
||||||
|
const inTabs = (candidate: WorkspaceLeaf) =>
|
||||||
|
candidate.getRoot() === workspace.rootSplit;
|
||||||
let leaf: WorkspaceLeaf | null =
|
let leaf: WorkspaceLeaf | null =
|
||||||
workspace.getLeavesOfType(VIEW_TYPE_PANEL)[0] ?? null;
|
workspace
|
||||||
|
.getLeavesOfType(VIEW_TYPE_PANEL)
|
||||||
|
.find((candidate) => inTabs(candidate) === (placement === "tab")) ??
|
||||||
|
null;
|
||||||
if (!leaf) {
|
if (!leaf) {
|
||||||
leaf =
|
leaf =
|
||||||
placement === "tab"
|
placement === "tab"
|
||||||
|
|||||||
Reference in New Issue
Block a user