diff --git a/components/CodeEditor.vue b/components/CodeEditor.vue index f30f69f..531a193 100644 --- a/components/CodeEditor.vue +++ b/components/CodeEditor.vue @@ -25,10 +25,9 @@ const options = computed( }, ) -onMounted(() => { - const editor = toRaw( - container.value!.$editor as monaco.editor.IStandaloneCodeEditor, - ) +watchEffect(() => { + const editor = toRaw(container.value?.$editor) + if (!editor) return editor.onDidChangeCursorPosition((e) => { editorCursor.value = editor.getModel()!.getOffsetAt(e.position) })