Skip to content

Commit

Permalink
getPropertiesInFile API addition
Browse files Browse the repository at this point in the history
  • Loading branch information
chhoumann committed Jun 24, 2021
1 parent 682755a commit 6f0f361
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "metaedit",
"name": "MetaEdit",
"version": "1.6.14",
"version": "1.6.15",
"minAppVersion": "0.12.0",
"description": "MetaEdit helps you manage your metadata.",
"author": "Christian B. B. Houmann",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "metaedit",
"version": "1.6.14",
"version": "1.6.15",
"description": "MetaEdit helps you manage your metadata.",
"main": "main.js",
"scripts": {
Expand Down
2 changes: 2 additions & 0 deletions src/IMetaEditApi.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import type {TFile} from "obsidian";
import type {Property} from "./parser";

export interface IMetaEditApi {
autoprop: (propertyName: string) => void;
update: (propertyName: string, propertyValue: string, file: TFile | string) => Promise<void>;
getPropertyValue: (propertyName: string, file: (TFile | string)) => Promise<any>;
getFilesWithProperty: (propertyName: string) => TFile[];
createYamlProperty: (propertyName: string, propertyValue: string, file: TFile | string) => Promise<void>;
getPropertiesInFile: (file: TFile | string) => Promise<Property[]>;
}

13 changes: 12 additions & 1 deletion src/MetaEditApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ export class MetaEditApi {
update: this.getUpdateFunction(),
getPropertyValue: this.getGetPropertyValueFunction(),
getFilesWithProperty: this.getGetFilesWithPropertyFunction(),
createYamlProperty: this.getCreateYamlPropertyFunction()
createYamlProperty: this.getCreateYamlPropertyFunction(),
getPropertiesInFile: this.getGetPropertiesInFile(),
};
}

Expand Down Expand Up @@ -83,4 +84,14 @@ export class MetaEditApi {
await controller.addYamlProp(propertyName, propertyValue, targetFile);
}
}

private getGetPropertiesInFile() {
return async (file: TFile | string): Promise<Property[]> => {
const targetFile = this.getFileFromTFileOrPath(file);
if (!targetFile) return;

const controller: MetaController = new MetaController(this.plugin.app, this.plugin);
return await controller.getPropertiesInFile(targetFile);
}
}
}
2 changes: 1 addition & 1 deletion versions.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"1.6.14": "0.12.0"
"1.6.15": "0.12.0"
}

0 comments on commit 6f0f361

Please sign in to comment.