Skip to content

Commit 2508806

Browse files
committed
chore: cleanup playground and module
1 parent 69f4e26 commit 2508806

File tree

5 files changed

+64
-78
lines changed

5 files changed

+64
-78
lines changed

docs/package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@
3131
"pnpm": {
3232
"onlyBuiltDependencies": [
3333
"better-sqlite3"
34+
],
35+
"ignoredBuiltDependencies": [
36+
"@parcel/watcher",
37+
"esbuild",
38+
"vue-demi",
39+
"workerd"
3440
]
3541
},
3642
"packageManager": "pnpm@10.6.5"

playground/app.vue

Lines changed: 57 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,59 @@
1+
<script setup lang="ts">
2+
import { javascript } from '@codemirror/lang-javascript'
3+
import type { ViewUpdate } from '@codemirror/view'
4+
import type { CodeMirrorRef, Statistics } from '../src/runtime/types/nuxt-codemirror'
5+
6+
const code = ref('console.log("Hello, CodeMirror!");')
7+
const codemirror = ref<CodeMirrorRef>()
8+
9+
const handleChange = (value: string, viewUpdate: ViewUpdate) => {
10+
console.log('Value changed:', value)
11+
console.log('View updated:', viewUpdate)
12+
}
13+
14+
const handleStatistics = (stats: Statistics) => {
15+
console.log('Editor statistics:', stats)
16+
}
17+
18+
const handleUpdate = (viewUpdate: ViewUpdate) => {
19+
console.log('Editor updated:', viewUpdate)
20+
}
21+
22+
onMounted(() => {
23+
if (codemirror.value) {
24+
console.log('Log editorRef', codemirror.value.editor)
25+
console.log('Log containerRef', codemirror.value.container)
26+
}
27+
28+
watchEffect(() => {
29+
if (codemirror.value) {
30+
console.log('Log StateRef', codemirror.value.state)
31+
console.log('Log viewRef', codemirror.value.view)
32+
}
33+
})
34+
})
35+
</script>
36+
137
<template>
2-
<NuxtLayout>
3-
<NuxtPage />
4-
</NuxtLayout>
38+
<div>
39+
<NuxtCodeMirror
40+
ref="codemirror"
41+
v-model="code"
42+
style="width: 500px; height: 400px;"
43+
placeholder="Enter your code here..."
44+
:auto-focus="true"
45+
:editable="true"
46+
:extensions="[javascript()]"
47+
:basic-setup="[true]"
48+
:indent-with-tab="true"
49+
@on-change="handleChange"
50+
@statistics="handleStatistics"
51+
@on-update="handleUpdate"
52+
/>
53+
<div>{{ code }}</div>
54+
<input
55+
v-model="code"
56+
type="text"
57+
>
58+
</div>
559
</template>

playground/nuxt.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export default defineNuxtConfig({
22
modules: ['../src/module'],
3-
devtools: { enabled: false },
3+
devtools: { enabled: true },
44
devServer: {
55
port: 4000,
66
},

playground/pages/index.vue

Lines changed: 0 additions & 62 deletions
This file was deleted.

src/runtime/getDefaultExtensions.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import {
3030
foldKeymap,
3131
} from '@codemirror/language'
3232
import { lintKeymap } from '@codemirror/lint'
33-
import { minimalSetup } from 'codemirror'
3433
import { defaultLightThemeOption } from './theme/light'
3534

3635
export * from '@codemirror/theme-one-dark'
@@ -74,17 +73,6 @@ export interface DefaultExtensionsOptions {
7473
editable?: boolean
7574
}
7675

77-
export const minimalSetup2: Extension = (() => [
78-
highlightSpecialChars(),
79-
history(),
80-
drawSelection(),
81-
syntaxHighlighting(defaultHighlightStyle, { fallback: true }),
82-
keymap.of([
83-
...defaultKeymap,
84-
...historyKeymap,
85-
]),
86-
])()
87-
8876
/**
8977
* Basic setup that includes standard CodeMirror extensions
9078
*/

0 commit comments

Comments
 (0)