add load and get to markers

This commit is contained in:
Cleon 2023-02-04 18:11:02 +13:00
parent 474d4eb4a2
commit 79bc5215e8
6 changed files with 22 additions and 4 deletions

View file

@ -146,6 +146,10 @@ Markers can be used to replace sections of a note with dynamic values. Sections
- `$.markers.target_file( file? )`
- Sets the target file to `file`
- `file` is optional and defaults to the current note
- `await $.markers.load()`
- Loads target file markers into memory
- `$.markers.get( name )`
- Gets the marker value named `name` from memory
- `$.markers.set( name, value )`
- Sets the marker value named `name` in memory
- `$.markers.clear()`

View file

@ -1,7 +1,7 @@
{
"id": "meld-build",
"name": "Meld Build",
"version": "0.1.5",
"version": "0.1.6",
"minAppVersion": "1.0.1",
"description": "Write and execute (sandboxed) JavaScript to render templates, query DataView and create dynamic notes.",
"author": "meld-cp",

View file

@ -1,6 +1,6 @@
{
"name": "meld-build-obsidian-plugin",
"version": "0.1.5",
"version": "0.1.6",
"description": "This is a sample plugin for Obsidian (https://obsidian.md)",
"main": "main.js",
"scripts": {

View file

@ -43,6 +43,17 @@ export class MarkerRunContextImplemention implements TMarkerRunContext {
this.newValues.clear();
}
async load() : Promise<void>{
const markers = await this.fetch();
markers.forEach(mk => {
this.set(mk.name, mk.value);
});
}
get( name: string ) : string|null|undefined {
return this.newValues.get( name );
}
set( name: string, value: string|null ): void {
this.newValues.set( name, value );
}

View file

@ -73,8 +73,10 @@ export type TMarkerRunContext = {
clear() : void;
get( name:string ): string|null|undefined;
set( name:string, value:string|null ): void;
load() : Promise<void>;
fetch() : Promise<MarkerValue[]>;
apply( clearUnknownMarkerValues?:boolean ) : Promise<MarkerChange[]>;

View file

@ -3,5 +3,6 @@
"0.1.2": "1.0.1",
"0.1.3": "1.0.1",
"0.1.4": "1.0.1",
"0.1.5": "1.0.1"
"0.1.5": "1.0.1",
"0.1.6": "1.0.1"
}