@@ -30,6 +30,13 @@ export default defineComponent({
3030 generatedElements: {},
3131 }
3232 },
33+ watch: {
34+ taskResponse () {
35+ if (! this .waitingForTask ) {
36+ this .loadPreviewMermaid ()
37+ }
38+ },
39+ },
3340 mounted () {
3441 this .$nextTick (() => {
3542 this .$refs .assistantDialog .focus ()
@@ -47,6 +54,7 @@ export default defineComponent({
4754 this .excalidrawApi .updateScene ({
4855 elements,
4956 })
57+ this .onCancel ()
5058 },
5159 async loadPreviewMermaid () {
5260 parseMermaidToExcalidraw (this .taskResponse ).then (async (res ) => {
@@ -77,50 +85,112 @@ export default defineComponent({
7785 </script >
7886
7987<template >
80- <NcModal v-if =" show " :can-close =" true " @close =" onCancel " >
88+ <NcModal v-if =" show "
89+ :can-close =" true "
90+ size="large"
91+ @close =" onCancel " >
8192 <div class =" assistant-dialog" >
8293 <div v-if =" !waitingForTask && !taskResponse" >
8394 <NcTextField ref="assistantDialog"
8495 v-model =" assistantQuery "
8596 label="Assistant"
8697 type="text" />
87- <NcButton type="submit"
88- @click =" onCancel " >
89- Close
90- </NcButton >
91- <NcButton type="submit" @click =" onSubmit " >
92- submit
93- </NcButton >
98+ <div class =" dialog-buttons" >
99+ <NcButton type="submit"
100+ @click =" onCancel " >
101+ Close
102+ </NcButton >
103+ <NcButton type="submit" @click =" onSubmit " >
104+ Generate
105+ </NcButton >
106+ </div >
94107 </div >
95108 <div v-else-if =" !waitingForTask && taskResponse" class =" preview-wrapper" >
96- <NcTextArea v-model =" taskResponse "
97- label="Generated mermaid"
98- type="text" />
99- <NcButton type="submit" @click =" loadPreviewMermaid " >
100- preview
101- </NcButton >
102- <div ref =" canvasRef" class =" assistant-mermaid-preview" />
103- <NcButton type="submit" @click =" onLoadToEditor " >
104- submit
105- </NcButton >
109+ <div class =" preview" >
110+ <NcTextArea v-model =" taskResponse "
111+ class="generated"
112+ input-class="generated-input"
113+ label="Generated mermaid"
114+ resize="none"
115+ type="text"
116+ @change =" loadPreviewMermaid " />
117+ <div class =" preview-canvas-wrapper" >
118+ <div ref =" canvasRef" class =" assistant-mermaid-preview" />
119+ </div >
120+ </div >
121+ <div class =" dialog-buttons" >
122+ <NcButton type="submit"
123+ @click =" () => taskResponse = ' ' " >
124+ back
125+ </NcButton >
126+ <NcButton type="submit" @click =" onLoadToEditor " >
127+ submit
128+ </NcButton >
129+ </div >
106130 </div >
107131 </div >
108132 </NcModal >
109133</template >
110-
111- <style scoped>
112- .preview-wrapper {
134+ <style >
135+ .assistant-mermaid-preview {
136+ height : 100% ;
137+ canvas {
138+ height : 100% ;
139+ }
140+ }
141+ .generated {
142+ .textarea __main-wrapper {
143+ height : 100% ;
144+ }
145+ .textarea__input {
146+ height : 100% ;
147+ }
148+ }
149+ </style >
150+ <style scoped lang="scss">
151+ .preview-button {
152+ height : 1rem ;
153+ }
154+ .assistant-dialog {
155+ height : 100% ;
113156 display : flex ;
114157 flex-direction : column ;
115- align-items : center ;
158+ justify-content : space-evenly ;
159+ }
160+ .preview-wrapper {
161+ height : 100% ;
162+ display : flex ;
163+ flex-direction : column ;
164+ justify-content : space-between ;
165+ padding : 15px ;
166+ padding-top : 30px ;
167+ }
168+
169+ .preview {
170+ height : 90% ;
171+ display : flex ;
172+ flex-direction : row ;
173+ align-items : flex-start ;
116174}
117175
118- .assistant-mermaid-preview {
119- margin-block : 20 px ;
120- align-self : flex-end ;
176+ .generated {
177+ width : 50 % ;
178+ height : 100 % ;
121179}
122180
123- .assistant-dialog {
124- padding-block : 25px ;
181+ .preview-canvas-wrapper {
182+ height : 100% ;
183+ width : 50% ;
184+ flex-grow : 1 ;
185+ display : flex ;
186+ justify-content : center ;
125187}
188+
189+ .dialog-buttons {
190+ display : flex ;
191+ justify-content : space-between ;
192+ align-items : center ;
193+ width : 100% ;
194+ }
195+
126196 </style >
0 commit comments