|
2 | 2 | select: c |
3 | 3 | --- |
4 | 4 |
|
5 | | -test |
6 | | -```meta-bind-js |
7 | | -const declaration = mb.createDeclaration( |
8 | | - 'select', |
9 | | - [ |
10 | | - {type: 'option', value: 'a'}, |
11 | | - {type: 'option', value: 'c'}, |
12 | | - ] |
13 | | -); |
| 5 | +```js-engine |
| 6 | +const mb = engine.getPlugin('obsidian-meta-bind-plugin').api; |
14 | 7 |
|
15 | | -mb.bindDeclaration(declaration, 'select'); |
| 8 | +const options = ['a', 'b', 'c']; |
16 | 9 |
|
17 | | -const inputField = mb.createInputField(declaration, undefined, 'block'); |
| 10 | +let declaration = mb.inputField.createInputFieldDeclaration(); |
| 11 | +declaration = mb.inputField.setType(declaration, 'select'); |
| 12 | +declaration = mb.inputField.setBindTargetMetadataField(declaration, 'select'); |
18 | 13 |
|
19 | | -inputField.readSignal.registerListener({callback: (value) => console.log(`test ${value}`)}) |
| 14 | +for (const option of options) { |
| 15 | + declaration = mb.inputField.addArgument(declaration, {name: 'option', value: option}); |
| 16 | +} |
20 | 17 |
|
21 | | -ctx.addChild(inputField); |
22 | | -``` |
| 18 | +mb.createInputField(declaration, 'block', context.file.path, container, component); |
23 | 19 |
|
24 | | -```meta-bind-js |
25 | | -const declaration = mb.createDeclaration( |
26 | | - 'select', |
27 | | - [ |
28 | | - {type: 'option', value: 'd'}, |
29 | | - {type: 'option', value: 'e'}, |
30 | | - ] |
31 | | -); |
32 | | -
|
33 | | -mb.bindDeclaration(declaration, 'select'); |
34 | | -
|
35 | | -const inputField = mb.createInputField(declaration, undefined, 'block'); |
36 | | -
|
37 | | -ctx.addChild(inputField); |
38 | | -``` |
39 | | - |
40 | | -```js |
41 | | -const declaration = mb.createDeclaration( |
42 | | - 'select', |
43 | | - [ |
44 | | - {type: 'option', value: 'a'}, |
45 | | - {type: 'option', value: 'c'}, |
46 | | - ], |
47 | | - 'select' |
48 | | -); |
49 | | - |
50 | | -0000 |
51 | | - |
52 | | -const inputField = mb.createInputField(declaration, undefined, 'block'); |
53 | | - |
54 | | -ctx.addChild(inputField); |
55 | | -``` |
56 | | - |
57 | | -test |
| 20 | +``` |
0 commit comments