diff --git a/src/copilotView.ts b/src/copilotView.ts index ccf5d467..0faf8636 100644 --- a/src/copilotView.ts +++ b/src/copilotView.ts @@ -4,7 +4,7 @@ import CopilotPlugin from "./main"; import axios from 'axios'; -export default class ChatGPTView extends ItemView { +export default class CopilotChatView extends ItemView { sharedState: SharedState; plugin: CopilotPlugin; model: string; @@ -32,7 +32,7 @@ export default class ChatGPTView extends ItemView { // Return a unique identifier for this view getViewType(): string { - return 'chat-gpt-view'; + return 'copilot-chat-view'; } // Return an icon for this view @@ -42,12 +42,12 @@ export default class ChatGPTView extends ItemView { // Return a title for this view getTitle(): string { - return 'ChatGPT'; + return 'Copilot Chat'; } // Implement the getDisplayText method getDisplayText(): string { - return 'ChatGPT'; + return 'Copilot Chat'; } // Render the chat interface and add event listeners @@ -180,14 +180,14 @@ export default class ChatGPTView extends ItemView { // Your ChatGPT API interaction logic here console.log(`Sending message: ${message}`); - const {loadingMessageEl, dotInterval} = this.createLoadingDots(chatMessages); + // const {loadingMessageEl, dotInterval} = this.createLoadingDots(chatMessages); // Get a response from the ChatGPT API const chatGPTResponse = await this.getChatGPTResponse(message); // Stop the running "..." effect - clearInterval(dotInterval); - if (loadingMessageEl.parentElement) { - loadingMessageEl.parentElement.remove(); - } + // clearInterval(dotInterval); + // if (loadingMessageEl.parentElement) { + // loadingMessageEl.parentElement.remove(); + // } // After receiving a response from the ChatGPT API, append it to the chat interface this.appendMessage(chatMessages, chatGPTResponse, this.model); this.scrollToBottom(chatMessages); diff --git a/src/main.ts b/src/main.ts index 92ed31c3..92c01cf0 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,9 +1,9 @@ import { App, Modal, Plugin } from 'obsidian'; import { CopilotSettingTab } from "./settings"; -import ChatGPTView from './copilotView'; +import CopilotChatView from './copilotView'; import { SharedState } from './sharedState'; -const CHATGPT_VIEWTYPE = 'chat-gpt-view'; +const CHAT_VIEWTYPE = 'copilot-chat-view'; interface CopilotSettings { openAiApiKey: string; @@ -29,8 +29,8 @@ export default class CopilotPlugin extends Plugin { // Register your custom View class this.registerView( - 'chat-gpt-view', - (leaf) => new ChatGPTView(leaf, this)); + 'copilot-chat-view', + (leaf) => new CopilotChatView(leaf, this)); this.addRibbonIcon('message-square', 'ChatGPT', (evt: MouseEvent) => { // open or close the chatgpt view @@ -47,21 +47,21 @@ export default class CopilotPlugin extends Plugin { } toggleView() { - const leaves = this.app.workspace.getLeavesOfType(CHATGPT_VIEWTYPE); + const leaves = this.app.workspace.getLeavesOfType(CHAT_VIEWTYPE); leaves.length > 0 ? this.deactivateView() : this.activateView(); } async activateView() { - this.app.workspace.detachLeavesOfType(CHATGPT_VIEWTYPE); + this.app.workspace.detachLeavesOfType(CHAT_VIEWTYPE); await this.app.workspace.getRightLeaf(false).setViewState({ - type: CHATGPT_VIEWTYPE, + type: CHAT_VIEWTYPE, active: true, }); - this.app.workspace.revealLeaf(this.app.workspace.getLeavesOfType(CHATGPT_VIEWTYPE)[0]); + this.app.workspace.revealLeaf(this.app.workspace.getLeavesOfType(CHAT_VIEWTYPE)[0]); } async deactivateView() { - this.app.workspace.detachLeavesOfType(CHATGPT_VIEWTYPE); + this.app.workspace.detachLeavesOfType(CHAT_VIEWTYPE); } onunload() { diff --git a/styles.css b/styles.css index c59d64c0..c07a5d7a 100644 --- a/styles.css +++ b/styles.css @@ -118,17 +118,13 @@ If your plugin does not need CSS, delete this file. background-color: rgba(58, 58, 58, 0.8); color: #ffffff; border-radius: 5px; - padding: 8px; - margin-top: 4px; - margin-bottom: 4px; + padding: 4px; width: 100%; } .chat-message.chatgpt { border-radius: 5px; - padding: 8px; - margin-top: 4px; - margin-bottom: 4px; + padding: 4px; width: 100%; } @@ -139,7 +135,7 @@ If your plugin does not need CSS, delete this file. .chat-message-content { display: inline; - line-height: 1.2; + line-height: 1.3; } .clipboard-button {