diff --git a/manifest.json b/manifest.json index 523712a4..e50a0c29 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "copilot", "name": "Copilot", - "version": "2.3.4", + "version": "2.3.5", "minAppVersion": "0.15.0", "description": "A ChatGPT Copilot in Obsidian.", "author": "Logan Yang", diff --git a/package-lock.json b/package-lock.json index 9c122b02..d834535a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "obsidian-copilot", - "version": "2.3.4", + "version": "2.3.5", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "obsidian-copilot", - "version": "2.3.4", + "version": "2.3.5", "license": "AGPL-3.0", "dependencies": { "@huggingface/inference": "^1.8.0", diff --git a/package.json b/package.json index 72c5e00e..f9e77435 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "obsidian-copilot", - "version": "2.3.4", + "version": "2.3.5", "description": "ChatGPT integration for Obsidian", "main": "main.js", "scripts": { diff --git a/src/main.ts b/src/main.ts index bddc2f07..4738751b 100644 --- a/src/main.ts +++ b/src/main.ts @@ -77,6 +77,14 @@ export default class CopilotPlugin extends Plugin { } }); + this.addCommand({ + id: 'chat-toggle-window-note-area', + name: 'Toggle Copilot Chat Window in Note Area', + callback: () => { + this.toggleViewNoteArea(); + } + }); + this.addRibbonIcon('message-square', 'Copilot Chat', (evt: MouseEvent) => { this.toggleView(); }); @@ -397,6 +405,22 @@ export default class CopilotPlugin extends Plugin { this.chatIsVisible = false; } + async toggleViewNoteArea() { + const leaves = this.app.workspace.getLeavesOfType(CHAT_VIEWTYPE); + leaves.length > 0 ? this.deactivateView() : this.activateViewNoteArea(); + } + + async activateViewNoteArea() { + this.app.workspace.detachLeavesOfType(CHAT_VIEWTYPE); + this.activateViewPromise = this.app.workspace.getLeaf(true).setViewState({ + type: CHAT_VIEWTYPE, + active: true, + }); + await this.activateViewPromise; + this.app.workspace.revealLeaf(this.app.workspace.getLeavesOfType(CHAT_VIEWTYPE)[0]); + this.chatIsVisible = true; + } + async loadSettings() { this.settings = Object.assign({}, DEFAULT_SETTINGS, await this.loadData()); } diff --git a/versions.json b/versions.json index 7898023b..19a77ba0 100644 --- a/versions.json +++ b/versions.json @@ -18,5 +18,6 @@ "2.3.1": "0.15.0", "2.3.2": "0.15.0", "2.3.3": "0.15.0", - "2.3.4": "0.15.0" + "2.3.4": "0.15.0", + "2.3.5": "0.15.0" } \ No newline at end of file