@@ -9,6 +9,7 @@ import ToolbarBtn from './ToolbarBtn.vue'
9
9
import Block from ' ./Block.vue'
10
10
import ToolbarAlignment from ' ./ToolbarAlignment.vue'
11
11
import { useCss } from ' @composables/css'
12
+ import { resolvers } from ' @modules/block-editor/composables/resolvers'
12
13
13
14
const MonacoEditor = defineAsyncComponent (() => import (' @modules/monaco/components/MEditor.vue' ))
14
15
@@ -25,6 +26,8 @@ const chartLoading = ref(true)
25
26
const evaluation = useEvaluation ()
26
27
const evaluationOutput = ref <string []>([])
27
28
29
+ evaluation .addResolver (... resolvers )
30
+
28
31
evaluation .addResolver (
29
32
defineResolver ({
30
33
test : (id ) => id === ' app:chart' ,
@@ -58,8 +61,10 @@ async function setChart() {
58
61
59
62
await runtime .onDone ()
60
63
64
+ console .log (chartOptions )
65
+
61
66
if (runtime .evaluation .stderr ) {
62
- mode .value = ' debug'
67
+ config .value . mode = ' debug'
63
68
}
64
69
65
70
setTimeout (() => (chartLoading .value = false ), 300 )
@@ -80,6 +85,7 @@ async function update() {
80
85
node .name = ' chart'
81
86
node .body = code .value
82
87
node .attrs = config .value
88
+ node .meta = model .value .meta
83
89
84
90
let attrsAsString = Object .entries (node .attrs )
85
91
.map (([key , value ]) => ` ${key }="${value }" ` )
@@ -95,8 +101,6 @@ async function update() {
95
101
includeEndOfFileToken: false ,
96
102
})
97
103
98
- node .meta = model .value .meta
99
-
100
104
model .value = node
101
105
}
102
106
@@ -117,18 +121,16 @@ watch(
117
121
}
118
122
)
119
123
120
- // modes
121
- const mode = ref <' chart' | ' debug' | ' dataset' >(' chart' )
122
-
123
124
// attrs
124
125
125
126
const css = useCss ()
126
127
const loadingAttrs = ref (false )
127
128
128
129
const config = ref ({
129
130
height: ' 500' ,
130
- width: ' 500 ' ,
131
+ width: ' 100% ' ,
131
132
align: ' left' ,
133
+ mode: ' chart' as ' chart' | ' debug' | ' dataset' ,
132
134
})
133
135
134
136
const style = computed (() => {
@@ -147,9 +149,10 @@ watch(
147
149
148
150
const { attrs } = model .value
149
151
150
- config .value .height = attrs .height || ' 500'
151
- config .value .width = attrs .width || ' 500'
152
- config .value .align = attrs .align || ' left'
152
+ config .value .height = attrs .height || config .value .height
153
+ config .value .width = attrs .width || config .value .width
154
+ config .value .align = attrs .align || config .value .align
155
+ config .value .mode = (attrs .mode as any ) || config .value .mode
153
156
154
157
loadingAttrs .value = false
155
158
},
@@ -185,9 +188,9 @@ watch(
185
188
<template #activator =" { attrs } " >
186
189
<ToolbarBtn
187
190
v-bind =" attrs"
188
- :active =" mode === 'chart'"
191
+ :active =" config. mode === 'chart'"
189
192
data-test-id =" toolbar-chart-btn"
190
- @click =" mode = 'chart'"
193
+ @click =" config. mode = 'chart'"
191
194
>
192
195
<v-icon name =" chart-pie" />
193
196
</ToolbarBtn >
@@ -208,9 +211,9 @@ watch(
208
211
<template #activator =" { attrs } " >
209
212
<ToolbarBtn
210
213
v-bind =" attrs"
211
- :active =" mode === 'debug'"
214
+ :active =" config. mode === 'debug'"
212
215
data-test-id =" toolbar-debug-btn"
213
- @click =" mode = 'debug'"
216
+ @click =" config. mode = 'debug'"
214
217
>
215
218
<v-icon name =" bug" />
216
219
</ToolbarBtn >
@@ -222,9 +225,9 @@ watch(
222
225
<template #activator =" { attrs } " >
223
226
<ToolbarBtn
224
227
v-bind =" attrs"
225
- :active =" mode === 'dataset'"
228
+ :active =" config. mode === 'dataset'"
226
229
data-test-id =" toolbar-dataset-btn"
227
- @click =" mode = 'dataset'"
230
+ @click =" config. mode = 'dataset'"
228
231
>
229
232
<v-icon name =" mdi:code-json" />
230
233
</ToolbarBtn >
@@ -266,10 +269,10 @@ watch(
266
269
<v-icon name =" chart-pie" class =" text-[10rem] text-t-secondary" />
267
270
</div >
268
271
269
- <v-chart v-else-if =" mode === 'chart'" :style =" style" :options =" chartOptions" />
272
+ <v-chart v-else-if =" config. mode === 'chart'" :style =" style" :options =" chartOptions" />
270
273
271
- <template v-else-if =" mode === ' debug' " >
272
- <div :style =" style" class =" bg-b-03 p-4" >
274
+ <template v-else-if =" config . mode === ' debug' " >
275
+ <div :style =" { height: style.height } " class =" bg-b-03 p-4 w-full " >
273
276
<ANSICard :model-value =" evaluationOutput" data-test-id =" debug-view" />
274
277
275
278
<div
@@ -288,12 +291,13 @@ watch(
288
291
</template >
289
292
290
293
<MonacoEditor
291
- v-else-if =" mode === 'dataset'"
294
+ v-else-if =" config. mode === 'dataset'"
292
295
data-test-id =" dataset-view"
293
296
:model-value =" inspect(chartOptions)"
294
297
language =" json"
295
298
folding
296
299
readonly
300
+ :style =" { height: style.height }"
297
301
:padding =" {
298
302
top: 8,
299
303
bottom: 8,
0 commit comments