From 2b4d11068dce6a4fa509caad3ef42314933c2e2d Mon Sep 17 00:00:00 2001 From: Dian Date: Fri, 31 Jan 2025 22:15:50 +0800 Subject: [PATCH] when clicking ribbon open the new leaf/view --- main.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/main.ts b/main.ts index c15bef9..6a0fa66 100644 --- a/main.ts +++ b/main.ts @@ -30,6 +30,12 @@ const DEFAULT_SETTINGS: MyPluginSettings = { export default class NemesisPlugin extends Plugin { settings: MyPluginSettings; + async testFunction() { + const { workspace } = this.app; + + // let a = await workspace.ensureSideLeaf(VIEW_TYPE_EXAMPLE, "right"); + // console.log(a); + } async activateView() { const { workspace } = this.app; let leaf: WorkspaceLeaf | null = null; @@ -47,6 +53,10 @@ export default class NemesisPlugin extends Plugin { }); } } + if (leaf) { + workspace.revealLeaf(leaf); + workspace.setActiveLeaf(leaf); + } } async onload() { @@ -67,6 +77,7 @@ export default class NemesisPlugin extends Plugin { new Notice("This is a notice!"); console.log("click"); this.activateView(); + this.testFunction(); // console.log(`My openai key: ${this.settings.openAiKey}`); } );