@@ -8,6 +8,7 @@ import ANSICard from '@modules/evaluation/components/ANSICard.vue'
8
8
import ToolbarBtn from ' ./ToolbarBtn.vue'
9
9
import Block from ' ./Block.vue'
10
10
import ToolbarAlignment from ' ./ToolbarAlignment.vue'
11
+ import { useCss } from ' @composables/css'
11
12
12
13
const MonacoEditor = defineAsyncComponent (() => import (' @modules/monaco/components/MEditor.vue' ))
13
14
@@ -64,7 +65,7 @@ async function setChart() {
64
65
setTimeout (() => (chartLoading .value = false ), 300 )
65
66
}
66
67
67
- watch (() => model .value .body , setChart , { immediate: true })
68
+ watch ([ () => model .value .body , () => model . value . attrs ], setChart , { immediate: true , deep : true })
68
69
69
70
// edit
70
71
@@ -76,15 +77,19 @@ const parser = new MarkdownParser()
76
77
async function update() {
77
78
const node = new MarkdownNodeComponent ()
78
79
79
- node .name = ' script '
80
+ node .name = ' chart '
80
81
node .body = code .value
81
82
node .attrs = config .value
82
83
83
- const attrsAsString = Object .entries (node .attrs )
84
+ let attrsAsString = Object .entries (node .attrs )
84
85
.map (([key , value ]) => ` ${key }="${value }" ` )
85
86
.join (' ' )
86
87
87
- const markdown = ` :: script ${attrsAsString }\n ${node .body }\n ::\n `
88
+ if (attrsAsString ) {
89
+ attrsAsString = ` { ${attrsAsString } } `
90
+ }
91
+
92
+ const markdown = ` :: chart${attrsAsString }\n\n ${node .body }\n ::\n `
88
93
89
94
node .tokens = parser .toTokens (markdown , {
90
95
includeEndOfFileToken: false ,
@@ -117,6 +122,7 @@ const mode = ref<'chart' | 'debug' | 'dataset'>('chart')
117
122
118
123
// attrs
119
124
125
+ const css = useCss ()
120
126
const loadingAttrs = ref (false )
121
127
122
128
const config = ref ({
@@ -125,6 +131,15 @@ const config = ref({
125
131
align: ' left' ,
126
132
})
127
133
134
+ const style = computed (() => {
135
+ return {
136
+ height: css .toMeasurement (config .value .height ),
137
+ width: css .toMeasurement (config .value .width ),
138
+ marginLeft: [' right' , ' center' ].includes (config .value .align ) ? ' auto' : undefined ,
139
+ marginRight: [' left' , ' center' ].includes (config .value .align ) ? ' auto' : undefined ,
140
+ }
141
+ })
142
+
128
143
watch (
129
144
() => model .value .attrs ,
130
145
() => {
@@ -219,7 +234,7 @@ watch(
219
234
220
235
<div class =" w-28 flex items-center" >
221
236
<v-input
222
- v-model.lazy.number =" config.height"
237
+ v-model.lazy =" config.height"
223
238
flat
224
239
size =" sm"
225
240
data-test-id =" toolbar-input-height"
@@ -231,7 +246,7 @@ watch(
231
246
</div >
232
247
<div class =" w-28 flex items-center" >
233
248
<v-input
234
- v-model.lazy.number =" config.width"
249
+ v-model.lazy =" config.width"
235
250
flat
236
251
size =" sm"
237
252
data-test-id =" toolbar-input-width"
@@ -247,16 +262,16 @@ watch(
247
262
<v-icon name =" chart-pie" class =" text-[10rem] text-t-secondary" />
248
263
</div >
249
264
250
- <v-chart v-else-if =" mode === 'chart'" :options =" chartOptions" />
265
+ <v-chart v-else-if =" mode === 'chart'" :style = " style " : options =" chartOptions" />
251
266
252
- <ANSICard
253
- v-else-if = " mode === 'debug' "
254
- :model-value =" evaluationOutput"
255
- :empty-message = " $t('noEntity', [$t('log', 2)]) "
256
- data-test-id = " debug-view "
257
- >
258
- < template # empty >
259
- < div class = " h-full w-full flex items-center justify-center text-t-secondary " >
267
+ <template v-else-if = " mode === ' debug ' " >
268
+ < div :style = " style " class = " bg-b-03 p-4 " >
269
+ < ANSICard :model-value =" evaluationOutput" data-test-id = " debug-view " />
270
+
271
+ < div
272
+ v-if = " !evaluationOutput.length "
273
+ class = " h-full w-full flex items-center justify-center text-t-secondary "
274
+ >
260
275
<div class =" flex flex-col items-center space-y-2" >
261
276
<v-icon name =" bug" class =" text-4xl" />
262
277
@@ -265,8 +280,8 @@ watch(
265
280
</div >
266
281
</div >
267
282
</div >
268
- </template >
269
- </ANSICard >
283
+ </div >
284
+ </template >
270
285
271
286
<MonacoEditor
272
287
v-else-if =" mode === 'dataset'"
0 commit comments