mirror of
https://github.com/andy-stack/vaultkeeper-ai.git
synced 2026-07-22 16:30:27 +00:00
Move replaceCopy function from Copy enum to Helpers module to improve separation of concerns. Add splitFrontmatter and mergeTagsIntoFrontmatter utilities for YAML frontmatter manipulation. Remove unused Beautify prompt and QuickActionsService. Add timeout support to Semaphore.wait(). Remove unused Event.QuickActionsSettingsChanged. Update all imports across AI classes, prompts, services, and tests.
46 lines
No EOL
1.7 KiB
TypeScript
46 lines
No EOL
1.7 KiB
TypeScript
import type VaultkeeperAIPlugin from "main";
|
|
import { Resolve } from "./DependencyService";
|
|
import { Services } from "./Services";
|
|
import { Notice, TFile, type WorkspaceLeaf } from "obsidian";
|
|
import type { FileSystemService } from "./FileSystemService";
|
|
|
|
export class WorkSpaceService {
|
|
private readonly plugin: VaultkeeperAIPlugin = Resolve<VaultkeeperAIPlugin>(Services.VaultkeeperAIPlugin);
|
|
private readonly fileSystemService: FileSystemService = Resolve<FileSystemService>(Services.FileSystemService);
|
|
|
|
public async openNote(noteName: string) {
|
|
const file: TFile | null = this.plugin.app.metadataCache.getFirstLinkpathDest(noteName, "");
|
|
const leaf: WorkspaceLeaf = this.plugin.app.workspace.getLeaf(false);
|
|
|
|
if (file) {
|
|
await leaf.openFile(file);
|
|
} else {
|
|
new Notice(`Failed to open note: "${noteName}"`);
|
|
}
|
|
}
|
|
|
|
public async openNoteByPath(path: string) {
|
|
const file = this.plugin.app.vault.getAbstractFileByPath(path);
|
|
|
|
if (file instanceof TFile) {
|
|
const leaf: WorkspaceLeaf = this.plugin.app.workspace.getLeaf(false);
|
|
await leaf.openFile(file);
|
|
} else {
|
|
new Notice(`Failed to open note: "${path}"`);
|
|
}
|
|
}
|
|
|
|
public getActiveFile(allowAccessToPluginRoot: boolean = false): TFile | null {
|
|
const activeFile = this.plugin.app.workspace.getActiveFile();
|
|
|
|
if (!activeFile || this.fileSystemService.isExclusion(activeFile.path, allowAccessToPluginRoot)) {
|
|
return null;
|
|
}
|
|
|
|
return activeFile;
|
|
}
|
|
|
|
public getLeavesOfType(type: string): WorkspaceLeaf[] {
|
|
return this.plugin.app.workspace.getLeavesOfType(type);
|
|
}
|
|
} |