2025-09-08 14:50:06 +00:00
|
|
|
import { ItemView, WorkspaceLeaf } from 'obsidian';
|
|
|
|
|
import { mount, unmount } from 'svelte';
|
2025-09-16 16:14:37 +00:00
|
|
|
import ChatWindow from 'Components/ChatWindow.svelte';
|
2025-09-08 14:50:06 +00:00
|
|
|
|
|
|
|
|
export const VIEW_TYPE_MAIN = 'main-view';
|
|
|
|
|
|
|
|
|
|
export class MainView extends ItemView {
|
|
|
|
|
constructor(leaf: WorkspaceLeaf) {
|
|
|
|
|
super(leaf);
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-16 16:14:37 +00:00
|
|
|
input: ReturnType<typeof ChatWindow> | undefined;
|
2025-09-08 14:50:06 +00:00
|
|
|
|
|
|
|
|
getViewType() {
|
|
|
|
|
return VIEW_TYPE_MAIN;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getDisplayText() {
|
|
|
|
|
return 'Main View';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async onOpen() {
|
|
|
|
|
const container = this.contentEl;
|
|
|
|
|
container.empty();
|
|
|
|
|
|
2025-09-16 16:14:37 +00:00
|
|
|
this.input = mount(ChatWindow, {
|
2025-09-08 14:50:06 +00:00
|
|
|
target: container,
|
2025-09-16 16:14:37 +00:00
|
|
|
props: {}
|
2025-09-08 14:50:06 +00:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async onClose() {
|
|
|
|
|
if (this.input) {
|
|
|
|
|
unmount(this.input);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|