Enable chat UI in the note area for a bigger view (#111)

This commit is contained in:
Logan Yang 2023-07-13 15:48:55 -07:00 committed by GitHub
parent 37c578548f
commit 9f27dd3634
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 30 additions and 5 deletions

View file

@ -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",

4
package-lock.json generated
View file

@ -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",

View file

@ -1,6 +1,6 @@
{
"name": "obsidian-copilot",
"version": "2.3.4",
"version": "2.3.5",
"description": "ChatGPT integration for Obsidian",
"main": "main.js",
"scripts": {

View file

@ -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());
}

View file

@ -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"
}