@@ -25,6 +25,7 @@ const props = defineProps<{
2525}>()
2626
2727const emit = defineEmits <{
28+ toggleMode: []
2829 updateEditorContent: [value : string ]
2930 selectPath: [path : string ]
3031 goParent: []
@@ -49,6 +50,18 @@ const {
4950 canUploadImage : () => props .canUploadImage ,
5051 uploadImage: props .uploadImage
5152})
53+
54+ const richEditorHandlers = computed (() => ({
55+ ... editorHandlers ,
56+ toggleRawMode: {
57+ canExecute : () => true ,
58+ execute : () => {
59+ emit (' toggleMode' )
60+ return true
61+ },
62+ isActive : () => false
63+ }
64+ }))
5265 </script >
5366
5467<template >
@@ -134,22 +147,40 @@ const {
134147 </div >
135148 </template >
136149
137- <UTextarea
150+ <div
138151 v-if =" props.editorViewMode === 'raw'"
139- :model-value =" props.editorContent"
140- :rows =" 30"
141- :autoresize =" false"
142- class =" editoro-raw"
143- :placeholder =" t('main.rawPlaceholder')"
144- @update:model-value =" emit('updateEditorContent', String($event || ''))"
145- />
152+ class =" editoro-raw-wrap"
153+ >
154+ <div class =" editoro-raw-switch-wrap" >
155+ <UButton
156+ size =" xs"
157+ color =" neutral"
158+ variant =" soft"
159+ class =" editoro-raw-switch"
160+ icon =" i-lucide-square-pen"
161+ :aria-label =" t('editorMode.toRich')"
162+ @click =" emit('toggleMode')"
163+ >
164+ {{ t('editorMode.rich') }}
165+ </UButton >
166+ </div >
167+
168+ <UTextarea
169+ :model-value =" props.editorContent"
170+ :rows =" 30"
171+ :autoresize =" false"
172+ class =" editoro-raw"
173+ :placeholder =" t('main.rawPlaceholder')"
174+ @update:model-value =" emit('updateEditorContent', String($event || ''))"
175+ />
176+ </div >
146177
147178 <UEditor
148179 v-else
149180 :model-value =" props.editorContent"
150181 class =" editoro-editor"
151182 content-type =" markdown"
152- :handlers =" editorHandlers "
183+ :handlers =" richEditorHandlers "
153184 :placeholder =" t('main.editorPlaceholder')"
154185 @update:model-value =" emit('updateEditorContent', String($event || ''))"
155186 >
@@ -278,8 +309,23 @@ const {
278309 font-family : ui-monospace , SFMono-Regular, Menlo, monospace ;
279310}
280311
312+ .editoro-raw-wrap {
313+ position : relative ;
314+ width : 100% ;
315+ height : 100% ;
316+ min-height : 0 ;
317+ }
318+
319+ .editoro-raw-switch-wrap {
320+ position : absolute ;
321+ top : 0.75rem ;
322+ right : 1rem ;
323+ z-index : 10 ;
324+ }
325+
281326.editoro-raw :deep(textarea ) {
282327 height : 100% ;
328+ padding-right : 6.25rem ;
283329}
284330
285331.editoro-toolbar {
0 commit comments