-
Notifications
You must be signed in to change notification settings - Fork 5
/
IVault.ts
44 lines (38 loc) · 1.59 KB
/
IVault.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { INoteView } from "INoteView";
import { DataWriteOptions, TAbstractFile, TFile, TFolder } from "obsidian";
import { LinkData } from "utils";
export interface IVault {
readonly configuration: IVaultConfiguration;
exists(path: string, caseSensitive?: boolean): Promise<boolean>;
createNote(path: string, content: string): Promise<TFile>;
getActiveNoteView(): INoteView | null;
createFolder(path: string): Promise<TFolder>;
rename(normalizedPath: string, normalizedNewPath: string): Promise<void>;
getBacklinksForFileByPath(file: string | TFile): Record<string, LinkData[]> | null;
read(file: TFile): Promise<string>;
modify(file: TFile, data: string, options?: DataWriteOptions): Promise<void>;
getFilesInFolder(folder: TFolder): TFile[];
getRoot(): TFolder;
getName(): string;
delete(file: TAbstractFile, force?: boolean): Promise<void>;
trash(file: TAbstractFile, system: boolean): Promise<void>;
getAbstractFileByPath(path: string): TAbstractFile | null;
getConfig(setting: string): boolean | string | number;
}
export interface IVaultConfiguration {
readonly useMarkdownLinks: boolean;
//return value: absolute | shortest | relative
readonly newLinkFormat: string;
}
export class VaultConfiguration implements IVaultConfiguration {
vault: IVault;
constructor(vault: IVault) {
this.vault = vault;
}
get useMarkdownLinks(): boolean {
return this.vault.getConfig("useMarkdownLinks") as boolean;
}
get newLinkFormat(): string {
return this.vault.getConfig("newLinkFormat") as string;
}
}