Skip to content

Commit 2d8b06d

Browse files
committed
chore(codemirror): upgrade lang-vue version for autoCloseTags
1 parent 0671ede commit 2d8b06d

File tree

3 files changed

+44
-20
lines changed

3 files changed

+44
-20
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,9 @@
5252
"@babel/types": "^7.15.6",
5353
"@codemirror/commands": "^6.2.4",
5454
"@codemirror/lang-css": "^6.2.0",
55+
"@codemirror/lang-html": "^6.4.4",
5556
"@codemirror/lang-javascript": "^6.1.9",
56-
"@codemirror/lang-vue": "^0.1.1",
57+
"@codemirror/lang-vue": "github:codemirror/lang-vue#dee8a16",
5758
"@codemirror/state": "^6.2.1",
5859
"@codemirror/theme-one-dark": "^6.1.2",
5960
"@codemirror/view": "^6.13.0",

pnpm-lock.yaml

Lines changed: 21 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/codemirror/CodeMirror.vue

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import type { ViewUpdate } from '@codemirror/view'
99
import { keymap } from '@codemirror/view'
1010
import { oneDark } from '@codemirror/theme-one-dark'
1111
import { indentLess, insertTab } from '@codemirror/commands'
12+
import { html } from '@codemirror/lang-html'
1213
import { debounce } from '../utils'
1314
1415
export interface Props {
@@ -35,7 +36,12 @@ onMounted(() => {
3536
const state = EditorState.create({
3637
extensions: [
3738
basicSetup,
38-
language.of(vue()),
39+
language.of(vue({
40+
base: html({
41+
matchClosingTags: true,
42+
autoCloseTags: true,
43+
}),
44+
})),
3945
EditorState.tabSize.of(2),
4046
EditorView.updateListener.of((update: ViewUpdate) => {
4147
if (update.docChanged)
@@ -59,12 +65,22 @@ onMounted(() => {
5965
})
6066
6167
watchEffect(() => {
62-
if (props.mode === 'javascript')
68+
if (props.mode === 'javascript') {
6369
editor.dispatch({ effects: language.reconfigure(javascript()) })
64-
else if (props.mode === 'css')
70+
}
71+
else if (props.mode === 'css') {
6572
editor.dispatch({ effects: language.reconfigure(css()) })
66-
else
67-
editor.dispatch({ effects: language.reconfigure(vue()) })
73+
}
74+
else {
75+
editor.dispatch({
76+
effects: language.reconfigure(vue({
77+
base: html({
78+
matchClosingTags: true,
79+
autoCloseTags: true,
80+
}),
81+
})),
82+
})
83+
}
6884
})
6985
7086
watchEffect(() => {

0 commit comments

Comments
 (0)