File tree Expand file tree Collapse file tree 2 files changed +26
-6
lines changed
packages/core/src/fields/button Expand file tree Collapse file tree 2 files changed +26
-6
lines changed Original file line number Diff line number Diff line change 11---
2- count : -1
2+ count : 0
33someList :
44 - 1708945050652
55 - 1709918700548
@@ -246,7 +246,21 @@ actions:
246246
247247```
248248
249- ` BUTTON[count-decrement, count-reset, count-increment] ` ` VIEW[{count}] `
249+ Count: ` BUTTON[count-decrement, count-reset, count-increment] ` ` VIEW[{count}] `
250+
251+ ``` meta-bind-button
252+ label: "Add count to count2"
253+ hidden: false
254+ style: default
255+ actions:
256+ - type: updateMetadata
257+ bindTarget: count2
258+ evaluate: true
259+ value: "x + getMetadata('count')"
260+
261+ ```
262+
263+ Count2: ` VIEW[{count2}] `
250264
251265``` meta-bind-button
252266label: Add Current Time to List
Original file line number Diff line number Diff line change @@ -21,7 +21,6 @@ import {
2121import { MDLinkParser } from 'packages/core/src/parsers/MarkdownLinkParser' ;
2222import { expectType , openURL } from 'packages/core/src/utils/Utils' ;
2323import { parseLiteral } from 'packages/core/src/utils/Literal' ;
24-
2524import { type NotePosition } from 'packages/core/src/config/APIConfigs' ;
2625import { ErrorLevel , MetaBindJsError , MetaBindParsingError } from 'packages/core/src/utils/errors/MetaBindErrors' ;
2726
@@ -293,9 +292,16 @@ export class ButtonActionRunner {
293292 }
294293
295294 // eslint-disable-next-line @typescript-eslint/no-implied-eval
296- const func = new Function ( 'x' , `return ${ action . value } ;` ) as ( value : unknown ) => unknown ;
297-
298- this . plugin . api . updateMetadata ( bindTarget , func ) ;
295+ const func = new Function ( 'x' , 'getMetadata' , `return ${ action . value } ;` ) as (
296+ value : unknown ,
297+ getMetadata : ( bindTarget : string ) => unknown ,
298+ ) => unknown ;
299+
300+ this . plugin . api . updateMetadata ( bindTarget , value =>
301+ func ( value , bindTarget => {
302+ return this . plugin . api . getMetadata ( this . plugin . api . parseBindTarget ( bindTarget , filePath ) ) ;
303+ } ) ,
304+ ) ;
299305 } else {
300306 this . plugin . api . setMetadata ( bindTarget , parseLiteral ( action . value ) ) ;
301307 }
You can’t perform that action at this time.
0 commit comments