Skip to content

Commit 75f6f97

Browse files
committed
fix: duplicate codemirror/state causing extensions not working
1 parent 6597299 commit 75f6f97

File tree

8 files changed

+6727
-68
lines changed

8 files changed

+6727
-68
lines changed

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
},
3131
"dependencies": {
3232
"@codemirror/commands": "^6.6.0",
33-
"@codemirror/lang-javascript": "^6.2.2",
3433
"@codemirror/state": "6.4.1",
3534
"@codemirror/theme-one-dark": "^6.1.1",
3635
"@codemirror/view": "6.28.1",

playground/app.vue

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<script setup lang="ts">
22
import { javascript } from '@codemirror/lang-javascript'
3+
import { lineNumbersRelative } from '@uiw/codemirror-extensions-line-numbers-relative'
34
45
import type { ViewUpdate } from '@codemirror/view'
56
import type { CodeMirrorRef, Statistics } from '../src/runtime/types/nuxt-codemirror'
@@ -8,7 +9,7 @@ const code = ref('console.log("Hello, CodeMirror!");')
89
const theme = ref<'light' | 'dark' | 'none'>('light')
910
const codemirror = ref<CodeMirrorRef>()
1011
11-
const extensions = [javascript({ jsx: true, typescript: true })]
12+
const extensions = [lineNumbersRelative, javascript({ jsx: true, typescript: true })]
1213
1314
const 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"

playground/package.json

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,17 @@
88
"generate": "nuxi generate"
99
},
1010
"dependencies": {
11-
"nuxt": "^3.12.4",
12-
"@nuxt/kit": "^3.12.4"
11+
"@codemirror/lang-javascript": "^6.2.2",
12+
"@nuxt/kit": "^3.12.4",
13+
"@uiw/codemirror-extensions-line-numbers-relative": "^4.23.0",
14+
"nuxt": "^3.12.4"
1315
},
14-
"resolutions": {
15-
"@codemirror/commands": "^6.6.0",
16+
"overrides": {
1617
"@codemirror/lang-javascript": "^6.2.2",
18+
"@codemirror/commands": "^6.6.0",
1719
"@codemirror/state": "6.4.1",
18-
"@codemirror/theme-one-dark": "^6.1.1",
20+
"@codemirror/theme-one-dark": "6.1.1",
1921
"@codemirror/view": "6.28.1",
20-
"@uiw/codemirror-extensions-basic-setup": "^4.23.0"
22+
"@uiw/codemirror-extensions-basic-setup": "4.23.0"
2123
}
2224
}

0 commit comments

Comments
 (0)