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 1
1
---
2
- count : -1
2
+ count : 0
3
3
someList :
4
4
- 1708945050652
5
5
- 1709918700548
@@ -246,7 +246,21 @@ actions:
246
246
247
247
```
248
248
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}] `
250
264
251
265
``` meta-bind-button
252
266
label: Add Current Time to List
Original file line number Diff line number Diff line change @@ -21,7 +21,6 @@ import {
21
21
import { MDLinkParser } from 'packages/core/src/parsers/MarkdownLinkParser' ;
22
22
import { expectType , openURL } from 'packages/core/src/utils/Utils' ;
23
23
import { parseLiteral } from 'packages/core/src/utils/Literal' ;
24
-
25
24
import { type NotePosition } from 'packages/core/src/config/APIConfigs' ;
26
25
import { ErrorLevel , MetaBindJsError , MetaBindParsingError } from 'packages/core/src/utils/errors/MetaBindErrors' ;
27
26
@@ -293,9 +292,16 @@ export class ButtonActionRunner {
293
292
}
294
293
295
294
// 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
+ ) ;
299
305
} else {
300
306
this . plugin . api . setMetadata ( bindTarget , parseLiteral ( action . value ) ) ;
301
307
}
You can’t perform that action at this time.
0 commit comments