|
|
@@ -5,7 +5,7 @@ import { EditorView } from '@codemirror/view'
|
|
|
import { EditorState, StateEffect } from '@codemirror/state'
|
|
|
import { javascript } from '@codemirror/lang-javascript'
|
|
|
import { useId } from '@/hooks'
|
|
|
-// '{"paramName":"page","paramType":"int","paramDesc":"分页页码","require":true}'
|
|
|
+
|
|
|
export const CodeMirrorTsx = defineComponent({
|
|
|
name: 'code-mirror-tsx',
|
|
|
props: {
|
|
|
@@ -38,17 +38,11 @@ export const CodeMirrorTsx = defineComponent({
|
|
|
doc: transDoc(),
|
|
|
extensions: [basicSetup, javascript()]
|
|
|
})
|
|
|
- // transDoc(),
|
|
|
+
|
|
|
view.value = new EditorView({
|
|
|
state: editorState,
|
|
|
parent: document.getElementById(`editorRef-${id}`)!
|
|
|
})
|
|
|
-
|
|
|
- setTimeout(() => {
|
|
|
- console.dir(document.getElementById(`editorRef-${id}`))
|
|
|
-
|
|
|
- // console.log(document.getElementById(`editorRef-${id}`)!.getValue())
|
|
|
- }, 10000)
|
|
|
}
|
|
|
|
|
|
onMounted(() => {
|
|
|
@@ -59,6 +53,10 @@ export const CodeMirrorTsx = defineComponent({
|
|
|
})
|
|
|
})
|
|
|
|
|
|
+ ctx.expose({
|
|
|
+ getValue: () => JSON.parse(JSON.stringify(view.value!.state.doc.toJSON().join('')))
|
|
|
+ })
|
|
|
+
|
|
|
return () => (
|
|
|
<div ref="editorRef" id={`editorRef-${id}`}></div>
|
|
|
)
|