mirror of
https://github.com/meld-cp/obsidian-build.git
synced 2026-07-22 07:30:25 +00:00
add load and get to markers
This commit is contained in:
parent
474d4eb4a2
commit
79bc5215e8
6 changed files with 22 additions and 4 deletions
|
|
@ -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()`
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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": {
|
||||
|
|
|
|||
|
|
@ -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 );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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[]>;
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
}
|
||||
Loading…
Reference in a new issue