andy-stack_vaultkeeper-ai/Views/MainView.ts

37 lines
702 B
TypeScript
Raw Normal View History

2025-09-08 14:50:06 +00:00
import { ItemView, WorkspaceLeaf } from 'obsidian';
import { mount, unmount } from 'svelte';
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);
}
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();
this.input = mount(ChatWindow, {
2025-09-08 14:50:06 +00:00
target: container,
props: {}
2025-09-08 14:50:06 +00:00
});
}
async onClose() {
if (this.input) {
unmount(this.input);
}
}
}