diff --git a/manifest.json b/manifest.json index fcb6306..c8770d2 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "metaedit", "name": "MetaEdit", - "version": "1.6.12", + "version": "1.6.13", "minAppVersion": "0.12.0", "description": "MetaEdit helps you manage your metadata.", "author": "Christian B. B. Houmann", diff --git a/package.json b/package.json index e0cc5c7..75b19e4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "metaedit", - "version": "1.6.12", + "version": "1.6.13", "description": "MetaEdit helps you manage your metadata.", "main": "main.js", "scripts": { diff --git a/src/IMetaEditApi.ts b/src/IMetaEditApi.ts index d90a7ed..d437bf8 100644 --- a/src/IMetaEditApi.ts +++ b/src/IMetaEditApi.ts @@ -3,5 +3,6 @@ import type {TFile} from "obsidian"; export interface IMetaEditApi { autoprop: (propertyName: string) => void; update: (propertyName: string, propertyValue: string, file: TFile | string) => Promise; + getPropertyValue: (propertyName: string, file: (TFile | string)) => Promise; } diff --git a/src/MetaEditApi.ts b/src/MetaEditApi.ts index a736f44..1107c07 100644 --- a/src/MetaEditApi.ts +++ b/src/MetaEditApi.ts @@ -12,6 +12,7 @@ export class MetaEditApi { return { autoprop: this.getAutopropFunction(), update: this.getUpdateFunction(), + getPropertyValue: this.getGetPropertyValueFunction(), }; } @@ -49,4 +50,19 @@ export class MetaEditApi { return targetFile; } + + private getGetPropertyValueFunction(): (propertyName: string, file: (TFile | string)) => Promise { + return async (propertyName: string, file: TFile | string) => { + const targetFile = this.getFileFromTFileOrPath(file); + if (!targetFile) return; + + const controller: MetaController = new MetaController(this.plugin.app, this.plugin); + const propsInFile: Property[] = await controller.getPropertiesInFile(targetFile); + + const targetProperty = propsInFile.find(prop => prop.key === propertyName); + if (!targetProperty) return; + + return targetProperty.content; + } + } } \ No newline at end of file diff --git a/versions.json b/versions.json index ce4afb0..b103c45 100644 --- a/versions.json +++ b/versions.json @@ -1,3 +1,3 @@ { - "1.6.12": "0.12.0" + "1.6.13": "0.12.0" }