INNER CODE UNIT · TypeScript

CopilotPlugin

eugeneyan/obsidian-copilot · plugin/main.ts:20

export default class CopilotPlugin extends Plugin {
	settings: CopilotPluginSettings;
	processing = false;

	// Opens a new pane to display the retrieved docs
	async openNewPane(content: string) {
		const filename = 'Retrieved docs.md';
		let file = this.app.vault.getAbstractFileByPath(filename) as TFile;

		if (file) {
			await this.app.vault.modify(file, content);
		} else {
			file = await this.app.vault.create(filename, content);
		}

		// Check if there is already an open pane with the file
		const existingLeaf = this.app.workspace.getLeavesOfType('markdown').find(leaf => leaf.view.file && leaf.view.file.path === file.path);

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…