2025-11-10 08:03:27 +00:00
|
|
|
import type VaultkeeperAIPlugin from "main";
|
2025-11-07 00:28:22 +00:00
|
|
|
import { Modal } from "obsidian";
|
|
|
|
|
import { Resolve } from "Services/DependencyService";
|
|
|
|
|
import { Services } from "Services/Services";
|
2025-11-08 13:31:53 +00:00
|
|
|
import HelpModalSvelte from './HelpModalSvelte.svelte';
|
|
|
|
|
import { mount, unmount } from 'svelte';
|
|
|
|
|
import { Selector } from 'Enums/Selector';
|
2025-11-07 00:28:22 +00:00
|
|
|
|
|
|
|
|
export class HelpModal extends Modal {
|
2025-11-08 13:31:53 +00:00
|
|
|
|
|
|
|
|
private component: Record<string, any> | null = null;
|
|
|
|
|
|
2025-11-07 00:28:22 +00:00
|
|
|
public constructor() {
|
2025-11-10 08:03:27 +00:00
|
|
|
const plugin = Resolve<VaultkeeperAIPlugin>(Services.VaultkeeperAIPlugin);
|
2025-11-07 00:28:22 +00:00
|
|
|
super(plugin.app);
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-08 13:31:53 +00:00
|
|
|
onOpen() {
|
|
|
|
|
const { contentEl, modalEl, containerEl } = this;
|
|
|
|
|
|
|
|
|
|
containerEl.addClass(Selector.HelpModal);
|
|
|
|
|
modalEl.addClass(Selector.HelpModal);
|
|
|
|
|
|
|
|
|
|
this.component = mount(HelpModalSvelte, {
|
|
|
|
|
target: contentEl,
|
|
|
|
|
props: {
|
2025-11-09 19:59:41 +00:00
|
|
|
onClose: () => this.close(),
|
|
|
|
|
initialTopic: (this as any).initialTopic
|
2025-11-08 13:31:53 +00:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-09 19:59:41 +00:00
|
|
|
public open(initialTopic?: number): void {
|
|
|
|
|
(this as any).initialTopic = initialTopic;
|
|
|
|
|
super.open();
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-08 13:31:53 +00:00
|
|
|
onClose() {
|
|
|
|
|
if (this.component) {
|
|
|
|
|
unmount(this.component);
|
|
|
|
|
this.component = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const { contentEl } = this;
|
|
|
|
|
contentEl.empty();
|
|
|
|
|
}
|
2025-11-07 00:28:22 +00:00
|
|
|
}
|