11<script setup lang="ts">
22import { javascript } from ' @codemirror/lang-javascript'
3+ import { lineNumbersRelative } from ' @uiw/codemirror-extensions-line-numbers-relative'
34
45import type { ViewUpdate } from ' @codemirror/view'
56import type { CodeMirrorRef , Statistics } from ' ../src/runtime/types/nuxt-codemirror'
@@ -8,7 +9,7 @@ const code = ref('console.log("Hello, CodeMirror!");')
89const theme = ref <' light' | ' dark' | ' none' >(' light' )
910const codemirror = ref <CodeMirrorRef >()
1011
11- const extensions = [javascript ({ jsx: true , typescript: true })]
12+ const extensions = [lineNumbersRelative , javascript ({ jsx: true , typescript: true })]
1213
1314const handleChange = (value : string , viewUpdate : ViewUpdate ) => {
1415 console .log (' Value changed:' , value )
@@ -23,23 +24,19 @@ const handleUpdate = (viewUpdate: ViewUpdate) => {
2324 console .log (' Editor updated:' , viewUpdate )
2425}
2526
26- onMounted (async () => {
27- await nextTick ()
28-
29- watchEffect (() => {
30- if (codemirror .value ) {
31- console .log (' blaaaaa' , codemirror .value .editor )
32- }
33- })
27+ onMounted (() => {
28+ if (codemirror .value ) {
29+ console .log (' blaaaaa' , codemirror .value .editor )
30+ }
3431})
3532 </script >
3633
3734<template >
3835 <NuxtCodeMirror
3936 ref =" codemirror"
4037 v-model =" code"
41- style =" width : 500px ; height : 400px ;"
4238 :extensions =" extensions"
39+ style =" width : 500px ; height : 400px ;"
4340 :theme =" theme"
4441 placeholder =" Enter your code here..."
4542 :auto-focus =" true"
0 commit comments