vue-codemirror6 1.4.1 → 1.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,23 +4,22 @@ All notable changes to this project will be documented in this file. Dates are d
4
4
 
5
5
  Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
6
6
 
7
- #### [1.4.1](https://github.com/logue/vue-codemirror6/compare/1.4.0...1.4.1)
7
+ #### [1.4.3](https://github.com/logue/vue-codemirror6/compare/1.4.2...1.4.3)
8
8
 
9
- - Move the contents of Codemirror.ts to index.ts. [`d9a624b`](https://github.com/logue/vue-codemirror6/commit/d9a624bbe61034b2a5abe553b0e362818ea8e91b)
10
- - Delete unnecessary specifications. [`0eec4b1`](https://github.com/logue/vue-codemirror6/commit/0eec4b1510e3dbb16cf7927b673e109f7be9e68a)
11
- - Fixed type check error. [`7e80246`](https://github.com/logue/vue-codemirror6/commit/7e802465e3fde974a9c797d8512e20639fb2edbe)
9
+ - Replace eslint-plugin-import to eslint-plugin-x. [`e46491a`](https://github.com/logue/vue-codemirror6/commit/e46491a24270f8ea392a3354bbecbaf7092f8ef9)
10
+ - Add Japanese Readme. [`e279cc0`](https://github.com/logue/vue-codemirror6/commit/e279cc0e1b23bba6c1dd690fb6a963b82e8508f6)
12
11
 
13
- #### [1.4.0](https://github.com/logue/vue-codemirror6/compare/1.3.21...1.4.0)
12
+ #### [1.4.2](https://github.com/logue/vue-codemirror6/compare/1.4.0...1.4.2)
14
13
 
15
- > 17 October 2025
14
+ > 17 February 2026
16
15
 
17
- - Update CHANGELOG.md. [`0d97dff`](https://github.com/logue/vue-codemirror6/commit/0d97dff0e60abc577cf4dd2ff67218cbbde5f6c0)
18
- - Add support for SSR (Nuxt, VitePress、Quasar SSR etc) [`98b5f28`](https://github.com/logue/vue-codemirror6/commit/98b5f28e505bab4b9bb55e1e989d507011e19208)
19
- - Add Test program. [`9fd5409`](https://github.com/logue/vue-codemirror6/commit/9fd5409e37751fe2a54de9e8a221aaf707b84731)
16
+ - Move the contents of Codemirror.ts to index.ts. [`d9a624b`](https://github.com/logue/vue-codemirror6/commit/d9a624bbe61034b2a5abe553b0e362818ea8e91b)
17
+ - Fixed dark mode in demo program. [`dd54015`](https://github.com/logue/vue-codemirror6/commit/dd54015c8ebb11cf24dd8d5b38e1e35e00ed56b5)
18
+ - Add oxilint. [`abb115e`](https://github.com/logue/vue-codemirror6/commit/abb115edd0bcafd641c4a7b35af566bdb1630334)
20
19
 
21
- #### [1.3.21](https://github.com/logue/vue-codemirror6/compare/1.3.13...1.3.21)
20
+ #### [1.4.0](https://github.com/logue/vue-codemirror6/compare/1.3.13...1.4.0)
22
21
 
23
- > 12 July 2025
22
+ > 17 October 2025
24
23
 
25
24
  - fix: full example link [`#58`](https://github.com/logue/vue-codemirror6/pull/58)
26
25
  - Update dependencies. [`985f36f`](https://github.com/logue/vue-codemirror6/commit/985f36f23c4fc1b562b53b664deb7ff1eec79989)
@@ -39,7 +38,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
39
38
 
40
39
  > 22 November 2024
41
40
 
42
- - Fix sample code syntax error [`#47`](https://github.com/logue/vue-codemirror6/pull/47)
41
+ - Fix sample code syntax error [`#47`](https://github.com/logue/vue-codemirror6/pull/47)
43
42
  - chore: demo docs [`#43`](https://github.com/logue/vue-codemirror6/pull/43)
44
43
  - fix: editor not update content when `modelValue` change and selection is out of range [`#44`](https://github.com/logue/vue-codemirror6/pull/44)
45
44
  - chore: props and readme doc [`#31`](https://github.com/logue/vue-codemirror6/pull/31)
@@ -71,7 +70,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
71
70
 
72
71
  - chore(CODEOWNERS): CODEOWNERS.com Bot, at your service! [`#14`](https://github.com/logue/vue-codemirror6/pull/14)
73
72
  - Update demo code. (Replaced @codemirror/html to @codemirror/vue.) [`8da1a8a`](https://github.com/logue/vue-codemirror6/commit/8da1a8a4e37d713cc78281ce9c304c42a06940dc)
74
- - Changed implementation to generate \*.d.ts with vite-plugin-dts. [`1caaa20`](https://github.com/logue/vue-codemirror6/commit/1caaa20b1423a3d252a6c770a630fb60e2e3440d)
73
+ - Changed implementation to generate *.d.ts with vite-plugin-dts. [`1caaa20`](https://github.com/logue/vue-codemirror6/commit/1caaa20b1423a3d252a6c770a630fb60e2e3440d)
75
74
  - Update README.md. [`f8dd493`](https://github.com/logue/vue-codemirror6/commit/f8dd4934a7b9cc089cd830473db5250d28b3389b)
76
75
 
77
76
  #### [1.1.11](https://github.com/logue/vue-codemirror6/compare/1.1.3...1.1.11)
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2022-2025 Masashi Yoshikawa
3
+ Copyright (c) 2022-2026 Masashi Yoshikawa
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.ja.md ADDED
@@ -0,0 +1,453 @@
1
+ # vue-codemirror6
2
+
3
+ [English](README.md) | 日本語
4
+
5
+ <p align="center">
6
+ <img src="https://user-images.githubusercontent.com/480173/224358008-6ffad05d-1d97-4c18-8554-7d41b03f88ab.png" alt="logo" width="300" height="300" />
7
+ </p>
8
+
9
+ [![jsdelivr CDN](https://data.jsdelivr.com/v1/package/npm/vue-codemirror6/badge)](https://www.jsdelivr.com/package/npm/vue-codemirror6)
10
+ [![NPM Downloads](https://img.shields.io/npm/dm/vue-codemirror6.svg?style=flat)](https://www.npmjs.com/package/vue-codemirror6)
11
+ [![Open in unpkg](https://img.shields.io/badge/Open%20in-unpkg-blue)](https://uiwjs.github.io/npm-unpkg/#/pkg/vue-codemirror6/file/README.md)
12
+ [![npm version](https://img.shields.io/npm/v/vue-codemirror6.svg)](https://www.npmjs.com/package/vue-codemirror6)
13
+ [![Open in Gitpod](https://shields.io/badge/Open%20in-Gitpod-green?logo=Gitpod)](https://gitpod.io/#https://github.com/logue/vue-codemirror6)
14
+ [![Twitter Follow](https://img.shields.io/twitter/follow/logue256?style=plastic)](https://twitter.com/logue256)
15
+
16
+ Vueで[CodeMirror6](https://codemirror.net/6/)を使用するためのコンポーネントです。このコンポーネントはVue2とVue3の両方で動作します。
17
+
18
+ - [変更履歴](./CHANGELOG.md)
19
+
20
+ ## 使い方
21
+
22
+ ```sh
23
+ yarn add vue-codemirror6 codemirror
24
+ ```
25
+
26
+ Vue 2.7以下の場合は、[@vue/composition-api](https://www.npmjs.com/package/@vue/composition-api)が別途必要です。
27
+
28
+ ```sh
29
+ yarn add vue-codemirror6 @vue/composition-api
30
+ ```
31
+
32
+ このコンポーネントは、一般的なVueコンポーネントと同様に`v-model`で双方向バインディングを処理できます。
33
+
34
+ ## Props
35
+
36
+ | Props | Type | 説明 |
37
+ | ------------------------- | --------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
38
+ | model-value | string \| Text | テキスト値。(`value`ではありません) |
39
+ | basic | boolean | [basicSetup](https://codemirror.net/docs/ref/#codemirror.basicSetup)を使用します。 |
40
+ | minimal | boolean | [miniSetup](https://codemirror.net/docs/ref/#codemirror.minimalSetup)を使用します。`basic` propも指定されている場合は、そちらの設定が優先されます。 |
41
+ | dark | boolean | ダークモードの切り替え。 |
42
+ | placeholder | string | 空白の場合にプレースホルダーテキスト(またはHTML DOM)を追加します。 |
43
+ | wrap | boolean | テキストの行折り返し。[lineWrapping](https://codemirror.net/6/docs/ref/#view.EditorView.lineWrapping)を参照してください。 |
44
+ | tab | boolean | タブインデントを有効にします。 |
45
+ | allow-multiple-selections | boolean | 複数選択を許可します。[allowMultipleSelections](https://codemirror.net/docs/ref/#state.EditorState^allowMultipleSelections)を参照してください。 |
46
+ | tab-size | number | この状態で使用するタブサイズを設定します。 |
47
+ | line-separator | string | 改行(区切り文字)を設定します。(デフォルトは`\n`です。) |
48
+ | theme | { [selector: string]: StyleSpec } | テーマを指定します。例えば、[@codemirror/theme-one-dark](https://github.com/codemirror/theme-one-dark)を使用する場合は、`oneDark`をインポートしてこのpropに設定します。 |
49
+ | readonly | boolean | カーソルを表示したり、テキストをドラッグできますが、値を編集することはできません。 |
50
+ | disabled | boolean | CodeMirrorのeditableの逆の値です。`readonly`に似ていますが、この値をtrueに設定するとドラッグも無効になります。 |
51
+ | lang | LanguageSupport | 構文ハイライトを使用したい言語。<https://codemirror.net/6/#languages>を参照してください。 |
52
+ | phrases | Record&lt;string, string&gt; | 表示される文字列を多言語化したい場合はここで指定します。<https://codemirror.net/6/examples/translate/>を参照してください。 |
53
+ | extensions | Extension[] | CodeMirrorを拡張する機能拡張が含まれます。 |
54
+ | linter | LintSource | リンターを設定します。`@codemirror/lang-javascript`の場合は`esLint([任意のルール])`関数、`@codemirror/json`の場合は`jsonParseLinter()`関数を入力します。詳細については、各言語ライブラリのソースを参照してください。 |
55
+ | linterConfig | Object | <https://codemirror.net/docs/ref/#lint.linter^config>を参照してください。 |
56
+ | forceLinting | boolean | <https://codemirror.net/docs/ref/#lint.forceLinting>を参照してください。 |
57
+ | gutter | boolean | `linter`が指定されている場合、エラーがあった行に🔴を表示します。`linter`が指定されていない場合は機能しません。 |
58
+ | gutterConfig | Object | <https://codemirror.net/docs/ref/#lint.lintGutter^config>を参照してください。 |
59
+ | tag | string | コンポーネントで使用されるHTMLタグ。(デフォルトは`div`タグです。) |
60
+ | scrollIntoView | boolean | 外部更新でフォームをスクロールできるようにします。(デフォルトは`true`です。) |
61
+ | keymap | KeyBinding[] | キーバインディングは、キー名をコマンドスタイルの関数に関連付けます。<https://codemirror.net/docs/ref/#view.KeyBinding>を参照してください。 |
62
+
63
+ ⚠ 注意: `lang`と`linter`は、`extensions`にまとめて設定することもできます。これらは、以前のバージョンのCodeMirror設定との互換性とpropsの型付けのために分離されています。
64
+
65
+ ### サポートされている言語
66
+
67
+ #### 公式
68
+
69
+ - [`@codemirror/lang-angular`](https://www.npmjs.com/package/@codemirror/lang-angular)
70
+ - [`@codemirror/lang-cpp`](https://www.npmjs.com/package/@codemirror/lang-cpp)
71
+ - [`@codemirror/lang-css`](https://www.npmjs.com/package/@codemirror/lang-css)
72
+ - [`@codemirror/lang-html`](https://www.npmjs.com/package/@codemirror/lang-html)
73
+ - [`@codemirror/lang-java`](https://www.npmjs.com/package/@codemirror/lang-java)
74
+ - [`@codemirror/lang-javascript`](https://www.npmjs.com/package/@codemirror/lang-javascript)
75
+ - [`@codemirror/lang-json`](https://www.npmjs.com/package/@codemirror/lang-json)
76
+ - [`@codemirror/lang-lezer`](https://www.npmjs.com/package/@codemirror/lang-lezer)
77
+ - [`@codemirror/lang-markdown`](https://www.npmjs.com/package/@codemirror/lang-markdown)
78
+ - [`@codemirror/lang-php`](https://www.npmjs.com/package/@codemirror/lang-php)
79
+ - [`@codemirror/lang-python`](https://www.npmjs.com/package/@codemirror/lang-python)
80
+ - [`@codemirror/lang-rust`](https://www.npmjs.com/package/@codemirror/lang-rust)
81
+ - [`@codemirror/lang-sql`](https://www.npmjs.com/package/@codemirror/lang-sql)
82
+ - [`@codemirror/lang-vue`](https://www.npmjs.com/package/@codemirror/lang-vue)
83
+ - [`@codemirror/lang-west`](https://www.npmjs.com/package/@codemirror/lang-west)
84
+ - [`@codemirror/lang-xml`](https://www.npmjs.com/package/@codemirror/lang-xml)
85
+
86
+ ### 非公式
87
+
88
+ - [`@phoenix-plugin-registry/petetnt.brackets-codemirror-fortran`](https://www.npmjs.com/package/@phoenix-plugin-registry/petetnt.brackets-codemirror-fortran)
89
+ - [`@phoenix-plugin-registry/petetnt.brackets-codemirror-go`](https://www.npmjs.com/package/@phoenix-plugin-registry/petetnt.brackets-codemirror-go)
90
+ - [`@acarl005/lang-sql`](https://www.npmjs.com/package/@acarl005/lang-sql)
91
+ - [`@ark-us/codemirror-lang-taylor`](https://www.npmjs.com/package/@ark-us/codemirror-lang-taylor)
92
+ - [`@formulavize/lang-fiz`](https://www.npmjs.com/package/@formulavize/lang-fiz)
93
+ - [`@gravitywiz/codemirror-lang-gfcalc`](https://www.npmjs.com/package/@gravitywiz/codemirror-lang-gfcalc)
94
+ - [`@nextjournal/lang-clojure`](https://www.npmjs.com/package/@nextjournal/lang-clojure)
95
+ - [`@plutojl/lang-julia`](https://www.npmjs.com/package/@plutojl/lang-julia)
96
+ - [`@polybase/codemirror-lang-javascript`](https://www.npmjs.com/package/@polybase/codemirror-lang-javascript)
97
+ - [`@replit/codemirror-lang-nix`](https://www.npmjs.com/package/@replit/codemirror-lang-nix)
98
+ - [`@replit/codemirror-lang-csharp`](https://www.npmjs.com/package/@replit/codemirror-lang-csharp)
99
+ - [`@replit/codemirror-lang-solidity`](https://www.npmjs.com/package/@replit/codemirror-lang-solidity)
100
+ - [`@replit/codemirror-lang-svelte`](https://www.npmjs.com/package/@replit/codemirror-lang-svelte)
101
+ - [`@zhijiu/lang-sql`](https://www.npmjs.com/package/@zhijiu/lang-sql)
102
+ - [`codemirror-lang-bool`](https://www.npmjs.com/package/codemirror-lang-bool)
103
+ - [`codemirror-lang-brainfuck`](https://www.npmjs.com/package/codemirror-lang-brainfuck)
104
+ - [`codemirror-lang-cherry`](https://www.npmjs.com/package/codemirror-lang-cherry)
105
+ - [`codemirror-lang-chordpro`](https://www.npmjs.com/package/codemirror-lang-chordpro)
106
+ - [`codemirror-lang-circom`](https://www.npmjs.com/package/codemirror-lang-circom)
107
+ - [`codemirror-lang-edn`](https://www.npmjs.com/package/codemirror-lang-edn)
108
+ - [`codemirror-lang-ejs`](https://www.npmjs.com/package/codemirror-lang-ejs)
109
+ - [`codemirror-lang-fsl`](https://www.npmjs.com/package/codemirror-lang-fsl)
110
+ - [`codemirror-lang-gml`](https://www.npmjs.com/package/codemirror-lang-gml)
111
+ - [`codemirror-lang-golfscript`](https://www.npmjs.com/package/codemirror-lang-golfscript)
112
+ - [`codemirror-lang-homescript`](https://www.npmjs.com/package/codemirror-lang-homescript)
113
+ - [`codemirror-lang-html-n8n`](https://www.npmjs.com/package/codemirror-lang-html-n8n)
114
+ - [`codemirror-lang-inform7`](https://www.npmjs.com/package/codemirror-lang-inform7)
115
+ - [`codemirror-lang-j`](https://www.npmjs.com/package/codemirror-lang-j)
116
+ - [`codemirror-lang-janet`](https://www.npmjs.com/package/codemirror-lang-janet)
117
+ - [`codemirror-lang-k`](https://www.npmjs.com/package/codemirror-lang-k)
118
+ - [`codemirror-lang-karol`](https://www.npmjs.com/package/codemirror-lang-karol)
119
+ - [`codemirror-lang-mermaid`](https://www.npmjs.com/package/codemirror-lang-mermaid)
120
+ - [`codemirror-lang-n8n-expression`](https://www.npmjs.com/package/codemirror-lang-n8n-expression)
121
+ - [`codemirror-lang-prolog`](https://www.npmjs.com/package/codemirror-lang-prolog)
122
+ - [`codemirror-lang-qpen`](https://www.npmjs.com/package/codemirror-lang-qpen)
123
+ - [`codemirror-lang-qtam`](https://www.npmjs.com/package/codemirror-lang-qtam)
124
+ - [`codemirror-lang-r`](https://www.npmjs.com/package/codemirror-lang-r)
125
+ - [`codemirror-lang-rome-ast`](https://www.npmjs.com/package/codemirror-lang-rome-ast)
126
+ - [`codemirror-lang-rome`](https://www.npmjs.com/package/codemirror-lang-rome)
127
+ - [`codemirror-lang-rush`](https://www.npmjs.com/package/codemirror-lang-rush)
128
+ - [`codemirror-lang-scopescript`](https://www.npmjs.com/package/codemirror-lang-scopescript)
129
+ - [`codemirror-lang-statement`](https://www.npmjs.com/package/codemirror-lang-statement)
130
+ - [`gcode-lang-codemirror`](https://www.npmjs.com/package/gcode-lang-codemirror)
131
+ - [`gmail-lang`](https://www.npmjs.com/package/gmail-lang)
132
+ - [`lang-bqn`](https://www.npmjs.com/package/lang-bqn)
133
+ - [`lang-clojure`](https://www.npmjs.com/package/lang-clojure)
134
+ - [`lang-d`](https://www.npmjs.com/package/lang-d)
135
+ - [`lang-feel`](https://www.npmjs.com/package/lang-feel)
136
+ - [`lang-firestore`](https://www.npmjs.com/package/lang-firestore)
137
+
138
+ ### サポートされているテーマ
139
+
140
+ - [`@codemirror/theme-one-dark`](https://github.com/codemirror/theme-one-dark)
141
+ - [`upleveled/theme-vs-code-dark-plus`](https://github.com/upleveled/theme-vs-code-dark-plus)
142
+ - [`codemirror6-bootstrap-theme`](https://github.com/logue/codemirror6-bootstrap-theme)
143
+
144
+ ## 例
145
+
146
+ 最小限で動作させるには、以下のようにマークアップします。
147
+
148
+ ```vue
149
+ <template>
150
+ <code-mirror v-model="value" />
151
+ </template>
152
+
153
+ <script>
154
+ import { ref, defineComponent } from 'vue';
155
+
156
+ import CodeMirror from 'vue-codemirror6';
157
+
158
+ export default defineComponent({
159
+ components: {
160
+ CodeMirror,
161
+ },
162
+ setup() {
163
+ const value = ref('Cozy lummox gives smart squid who asks for job pen.');
164
+
165
+ return { value };
166
+ },
167
+ });
168
+ </script>
169
+ ```
170
+
171
+ ### スロットを使用した例
172
+
173
+ スロットの内容は既存の`v-model`を上書きします。このため、`v-model`を使用せずに`readonly` propで単に表示する場合に使用することをお勧めします。
174
+
175
+ また、スロット内のテキストが自動的にフォーマットされないように、`<pre>`タグを挿入します。
176
+
177
+ ```vue
178
+ <template>
179
+ <code-mirror :lang="lang" :linter="linter">
180
+ <pre>
181
+ {
182
+ "key": "value"
183
+ }</pre
184
+ >
185
+ </code-mirror>
186
+ </template>
187
+
188
+ <script>
189
+ import { ref, defineComponent } from 'vue';
190
+
191
+ import { json, jsonParseLinter } from '@codemirror/lang-json';
192
+
193
+ import CodeMirror from 'vue-codemirror6';
194
+
195
+ export default defineComponent({
196
+ components: {
197
+ CodeMirror,
198
+ },
199
+ setup() {
200
+ const lang = json();
201
+ const linter = jsonParseLinter();
202
+ return { lang, linter };
203
+ },
204
+ });
205
+ </script>
206
+ ```
207
+
208
+ ### SSR(Nuxt.jsなど)での使用
209
+
210
+ このコンポーネントはSSR互換になりました。CodeMirrorはクライアント側でのみ初期化され、サーバー側レンダリング中にコンポーネントがエラーなく安全にレンダリングされます。
211
+
212
+ Nuxt 3を使用している場合は、コンポーネントを直接使用できます:
213
+
214
+ ```vue
215
+ <template>
216
+ <code-mirror v-model="value" :lang="lang" />
217
+ </template>
218
+
219
+ <script setup lang="ts">
220
+ import { ref } from 'vue';
221
+ import CodeMirror from 'vue-codemirror6';
222
+ import { javascript } from '@codemirror/lang-javascript';
223
+
224
+ const value = ref('console.log("Hello, World!");');
225
+ const lang = javascript();
226
+ </script>
227
+ ```
228
+
229
+ Nuxt 2を使用している場合や問題が発生した場合は、コンポーネントを`<ClientOnly>`でラップできます:
230
+
231
+ ```vue
232
+ <template>
233
+ <client-only>
234
+ <code-mirror v-model="value" :lang="lang" />
235
+ </client-only>
236
+ </template>
237
+ ```
238
+
239
+ ### 完全な例
240
+
241
+ [vite-vue3-ts-starter](https://github.com/logue/vite-vue3-ts-starter)でMarkdownエディターとして使用する場合。
242
+
243
+ ```vue
244
+ <script lang="ts" setup>
245
+ import { ref, defineComponent, type Ref } from 'vue';
246
+
247
+ // コンポーネントの読み込み
248
+ import CodeMirror from 'vue-codemirror6';
249
+
250
+ // CodeMirror拡張機能
251
+ import { markdown as md } from '@codemirror/lang-markdown';
252
+ import type { LanguageSupport } from '@codemirror/language';
253
+ import type { Extension } from '@codemirror/state';
254
+ import type { ViewUpdate } from '@codemirror/view';
255
+
256
+ /** テキスト */
257
+ const value: Ref<string> = ref('');
258
+
259
+ /** ダークモード **/
260
+ const dark: Ref<boolean> = ref(
261
+ window.matchMedia('(prefers-color-scheme: dark)').matches
262
+ );
263
+
264
+ /**
265
+ * CodeMirror言語
266
+ *
267
+ * @see {@link https://codemirror.net/6/docs/ref/#language | @codemirror/language}
268
+ */
269
+ const lang: LanguageSupport = md();
270
+
271
+ /**
272
+ * 国際化設定。
273
+ * この例では、表示言語を日本語にしています。
274
+ * vue-i18nと組み合わせて使用する場合は、リアクティブである必要があります。
275
+ *
276
+ * @see {@link https://codemirror.net/6/examples/translate/ | Example: Internationalization}
277
+ */
278
+ const phrases: Record<string, string> = {
279
+ // @codemirror/view
280
+ 'Control character': '制御文字',
281
+ // @codemirror/commands
282
+ 'Selection deleted': '選択を削除',
283
+ // @codemirror/language
284
+ 'Folded lines': '折り畳まれた行',
285
+ 'Unfolded lines': '折り畳める行',
286
+ to: '行き先',
287
+ 'folded code': '折り畳まれたコード',
288
+ unfold: '折り畳みを解除',
289
+ 'Fold line': '行を折り畳む',
290
+ 'Unfold line': '行の折り畳む解除',
291
+ // @codemirror/search
292
+ 'Go to line': '行き先の行',
293
+ go: 'OK',
294
+ Find: '検索',
295
+ Replace: '置き換え',
296
+ next: '▼',
297
+ previous: '▲',
298
+ all: 'すべて',
299
+ 'match case': '一致条件',
300
+ 'by word': '全文検索',
301
+ regexp: '正規表現',
302
+ replace: '置き換え',
303
+ 'replace all': 'すべてを置き換え',
304
+ close: '閉じる',
305
+ 'current match': '現在の一致',
306
+ 'replaced $ matches': '$ 件の一致を置き換え',
307
+ 'replaced match on line $': '$ 行の一致を置き換え',
308
+ 'on line': 'した行',
309
+ // @codemirror/autocomplete
310
+ Completions: '自動補完',
311
+ // @codemirror/lint
312
+ Diagnostics: 'エラー',
313
+ 'No diagnostics': 'エラーなし',
314
+ };
315
+ </script>
316
+
317
+ <template>
318
+ <code-mirror
319
+ v-model="value"
320
+ basic
321
+ :dark="dark"
322
+ :lang="lang"
323
+ :phrases="phrases"
324
+ />
325
+ </template>
326
+ ```
327
+
328
+ ## イベント
329
+
330
+ | イベント | 説明 |
331
+ | -------- | ------------------------------------------------------------------------------------------------------------------------ |
332
+ | ready | CodeMirrorが読み込まれたとき。 |
333
+ | focus | フォーカスが変更されたとき。 |
334
+ | update | CodeMirrorの状態が変更されたとき。[ViewUpdate](https://codemirror.net/docs/ref/#view.ViewUpdate)オブジェクトを返します。 |
335
+ | change | 値が変更されたとき。[EditorState](https://codemirror.net/docs/ref/#state.EditorState)を返します。 |
336
+
337
+ ## パラメータ / 関数
338
+
339
+ ```vue
340
+ <script setup lang="ts">
341
+ import { ref, onMounted, type Ref, type PropType } from 'vue';
342
+ import CodeMirror from 'vue-codemirror6';
343
+
344
+ const cm: Ref<InstanceType<typeof CodeMirror> | undefined> = ref();
345
+
346
+ onMounted(() => {
347
+ console.log(cm.value?.json);
348
+ });
349
+ </script>
350
+ <template>
351
+ <code-mirror ref="cm" />
352
+ </template>
353
+ ```
354
+
355
+ | 関数 / パラメータ | 説明 |
356
+ | ------------------ | ------------------------------------------------------------------------------------------------------------- |
357
+ | view | [EditorView](https://codemirror.net/docs/ref/#view.EditorView)を取得および設定します。 |
358
+ | selection | [EditorSelection](https://codemirror.net/docs/ref/#state.EditorSelection)インスタンスを取得および設定します。 |
359
+ | cursor | [Cursor](https://codemirror.net/docs/ref/#state.EditorSelection^cursor)の位置を取得および設定します。 |
360
+ | json | 状態をJSON直列化可能なオブジェクトとして取得および設定します。 |
361
+ | focus | [Focus](https://codemirror.net/docs/ref/#view.EditorView.focus)を取得および設定します。 |
362
+ | lint() | リンターを強制実行します(`linter`propが指定されている場合のみ)。 |
363
+ | forceReconfigure() | すべての拡張機能を再登録します。 |
364
+
365
+ ### CodeMirror5の後方互換関数
366
+
367
+ 以下の説明は、[codemirror5](https://codemirror.net/5/)に精通している方向けの互換メソッドです。
368
+ 通常、上記のメソッドで十分であるため、**積極的な使用は推奨されません**。
369
+
370
+ | 関数 | 説明 |
371
+ | ------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- |
372
+ | getRange(from?: number, to?: number) | エディター内の指定されたポイント間のテキストを取得します。 |
373
+ | getLine(number: number) | 行の内容を取得します。 |
374
+ | lineCount() | エディターの行数を取得します。 |
375
+ | getCursor() | 主選択の一方の端を取得します。 |
376
+ | listSelections() | 現在のすべての選択のリストを取得します。 |
377
+ | getSelection() | 現在選択されているコードを取得します。 |
378
+ | getSelections() | 指定された配列の長さは、アクティブな選択の数と同じである必要があります。 |
379
+ | somethingSelected() | テキストが選択されている場合はtrueを返します。 |
380
+ | replaceRange(replacement: string \| Text, from: number, to: number) | fromからtoまでのドキュメントの部分を指定された文字列で置き換えます。 |
381
+ | replaceSelection(replacement: string \| Text) | 選択を指定された文字列で置き換えます。 |
382
+ | setCursor(position: number) | カーソル位置を設定します。 |
383
+ | setSelection(anchor: number, head?: number) | 単一の選択範囲を設定します。 |
384
+ | setSelections(ranges: readonly SelectionRange[], primary?: number) | 新しい選択のセットを設定します。 |
385
+ | extendSelectionsBy(f: Function) | すべての既存の選択に指定された関数を適用し、結果に対してextendSelectionsを呼び出します。 |
386
+
387
+ ## 推奨事項
388
+
389
+ CodeMirrorは比較的大容量であるため、[vite](https://vitejs.dev)を使用する場合は、ビルド時に以下のように[`manualChunks`](https://vitejs.dev/guide/build.html#chunking-strategy)オプションを使用して別ファイルとして出力するように設定することをお勧めします。
390
+
391
+ ```ts
392
+ const config: UserConfig = {
393
+ // ...
394
+ build: {
395
+ rollupOptions: {
396
+ output: {
397
+ manualChunks: {
398
+ // ...
399
+ codemirror: ['vue-codemirror6'],
400
+ 'codemirror-lang': [
401
+ // 必要に応じて以下を追加してください。
402
+ '@codemirror/lang-html',
403
+ '@codemirror/lang-javascript',
404
+ '@codemirror/lang-markdown',
405
+ ],
406
+ // ...
407
+ },
408
+ },
409
+ },
410
+ },
411
+ // ...
412
+ };
413
+ ```
414
+
415
+ ## 開発
416
+
417
+ ### テスト
418
+
419
+ このプロジェクトは、ユニットテストに[Vitest](https://vitest.dev/)を使用しています。
420
+
421
+ ```bash
422
+ # テストを実行
423
+ pnpm test
424
+
425
+ # ウォッチモードでテストを実行
426
+ pnpm test:watch
427
+
428
+ # UIを使用してテストを実行
429
+ pnpm test:ui
430
+
431
+ # カバレッジを使用してテストを実行
432
+ pnpm test:coverage
433
+ ```
434
+
435
+ テストスイートには以下が含まれます:
436
+
437
+ - **コンポーネントテスト**: 基本的なレンダリング、props、イベント、v-modelバインディングのテスト
438
+ - **SSRテスト**: Nuxt.jsやその他のSSRフレームワークの適切なサーバー側レンダリング互換性の確保
439
+ - **メソッドテスト**: 公開されているすべてのメソッドが正しく動作することを検証
440
+ - **エッジケース**: エラー処理と異常なシナリオのテスト
441
+
442
+ ## ライセンス
443
+
444
+ ©2022-2026 by Logue.
445
+ [MITライセンス](LICENSE)の下でライセンスされています。
446
+
447
+ ## 🎨 開発者のために作られました
448
+
449
+ このライブラリは、**最新の開発者体験**に焦点を当てて構築されています。これを維持するには、すべてがシームレスに動作することを確認するための継続的なテストと更新が必要です。
450
+
451
+ このプロジェクトの細部へのこだわりを評価していただける場合は、Vue.jsとMetaverseエコシステム全体での私の仕事をサポートするために、小額のスポンサーシップをいただければ幸いです。
452
+
453
+ [![GitHub Sponsors](https://img.shields.io/github/sponsors/logue?label=Sponsor&logo=github&color=ea4aaa)](https://github.com/sponsors/logue)
package/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # vue-codemirror6
2
2
 
3
+ English | [日本語](README.ja.md)
4
+
3
5
  <p align="center">
4
6
  <img src="https://user-images.githubusercontent.com/480173/224358008-6ffad05d-1d97-4c18-8554-7d41b03f88ab.png" alt="logo" width="300" height="300" />
5
7
  </p>
@@ -438,5 +440,13 @@ The test suite includes:
438
440
 
439
441
  ## LICENSE
440
442
 
441
- ©2022-2025 by Logue.
443
+ ©2022-2026 by Logue.
442
444
  Licensed under the [MIT License](LICENSE).
445
+
446
+ ## 🎨 Crafted for Developers
447
+
448
+ This library is built with a focus **modern developer experience**. Maintaining it involves constant testing and updates to ensure everything works seamlessly.
449
+
450
+ If you appreciate the attention to detail in this project, a small sponsorship would go a long way in supporting my work across the Vue.js and Metaverse ecosystems.
451
+
452
+ [![GitHub Sponsors](https://img.shields.io/github/sponsors/logue?label=Sponsor&logo=github&color=ea4aaa)](https://github.com/sponsors/logue)
package/dist/index.cjs.js CHANGED
@@ -3,11 +3,11 @@
3
3
  *
4
4
  * @description CodeMirror6 Component for vue2 and vue3.
5
5
  * @author Logue <logue@hotmail.co.jp>
6
- * @copyright 2022-2025 By Masashi Yoshikawa All rights reserved.
6
+ * @copyright 2022-2026 By Masashi Yoshikawa All rights reserved.
7
7
  * @license MIT
8
- * @version 1.4.1
8
+ * @version 1.4.3
9
9
  * @see {@link https://github.com/logue/vue-codemirror6}
10
10
  */
11
11
 
12
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var R=require("@codemirror/commands"),A=require("@codemirror/language"),v=require("@codemirror/lint"),o=require("@codemirror/state"),s=require("@codemirror/view"),b=require("codemirror"),n=require("vue-demi");const F={version:"1.4.1",date:"2025-10-17T22:30:13.688Z"},I=t=>t?Object.entries(t).reduce((u,[l,c])=>(l=l.charAt(0).toUpperCase()+l.slice(1),l=`on${l}`,{...u,[l]:c}),{}):{};function p(t,u={},l){if(n.isVue2)return n.h(t,u,l);const{props:c,domProps:e,on:m,...d}=u,h=m?I(m):{};return n.h(t,{...d,...c,...e,...h},l)}const J=t=>typeof t=="function"?t():t,C=n.defineComponent({name:"CodeMirror",model:{prop:"modelValue",event:"update:modelValue"},props:{modelValue:{type:String,default:""},theme:{type:Object,default:()=>({})},dark:{type:Boolean,default:!1},basic:{type:Boolean,default:!1},minimal:{type:Boolean,default:!1},placeholder:{type:String,default:void 0},wrap:{type:Boolean,default:!1},tab:{type:Boolean,default:!1},indentUnit:{type:String,default:void 0},allowMultipleSelections:{type:Boolean,default:!1},tabSize:{type:Number,default:void 0},lineSeparator:{type:String,default:void 0},readonly:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},extensions:{type:Array,default:()=>[]},phrases:{type:Object,default:void 0},lang:{type:Object,default:void 0},linter:{type:Function,default:void 0},linterConfig:{type:Object,default:()=>({})},forceLinting:{type:Boolean,default:!1},gutter:{type:Boolean,default:!1},gutterConfig:{type:Object,default:void 0},tag:{type:String,default:"div"},scrollIntoView:{type:Boolean,default:!0},keymap:{type:Array,default:()=>[]}},emits:{"update:modelValue":(t="")=>!0,update:t=>!0,ready:t=>!0,focus:t=>!0,change:t=>!0,destroy:()=>!0},setup(t,u){const l=n.ref(),c=n.ref(t.modelValue),e=n.shallowRef(void 0),m=n.computed({get:()=>e.value?.hasFocus??!1,set:a=>{a&&e.value&&e.value.focus()}}),d=n.computed({get:()=>e.value?.state.selection,set:a=>{e.value&&a&&e.value.dispatch({selection:a})}}),h=n.computed({get:()=>e.value?.state.selection.main.head??0,set:a=>{e.value&&e.value.dispatch({selection:{anchor:a}})}}),E=n.computed({get:()=>e.value?.state.toJSON(),set:a=>{e.value&&a&&e.value.setState(o.EditorState.fromJSON(a))}}),S=n.ref(0),g=n.ref(0),y=n.computed(()=>{const a=new o.Compartment,i=new o.Compartment;if(t.basic&&t.minimal)throw new Error("[Vue CodeMirror] Both basic and minimal cannot be specified.");let r=[];return t.keymap&&t.keymap.length>0&&(r=t.keymap),t.tab&&r.push(R.indentWithTab),[t.basic&&!t.minimal?b.basicSetup:void 0,t.minimal&&!t.basic?b.minimalSetup:void 0,s.EditorView.updateListener.of(f=>{e.value&&(u.emit("focus",e.value.hasFocus),S.value=e.value.state.doc?.length,!(f.changes.empty||!f.docChanged)&&(t.linter&&(t.forceLinting&&v.forceLinting(e.value),g.value=t.linter(e.value).length),u.emit("update",f)))}),s.EditorView.theme(t.theme,{dark:t.dark}),t.wrap?s.EditorView.lineWrapping:void 0,t.indentUnit?A.indentUnit.of(t.indentUnit):void 0,o.EditorState.allowMultipleSelections.of(t.allowMultipleSelections),t.tabSize?i.of(o.EditorState.tabSize.of(t.tabSize)):void 0,t.phrases?o.EditorState.phrases.of(t.phrases):void 0,o.EditorState.readOnly.of(t.readonly),s.EditorView.editable.of(!t.disabled),t.lineSeparator?o.EditorState.lineSeparator.of(t.lineSeparator):void 0,t.lang?a.of(t.lang):void 0,t.linter?v.linter(t.linter,t.linterConfig):void 0,t.linter&&t.gutter?v.lintGutter(t.gutterConfig):void 0,t.placeholder?s.placeholder(t.placeholder):void 0,r.length>0?s.keymap.of(r):void 0,...t.extensions].filter(f=>!!f)});n.watch(y,a=>e.value?.dispatch({effects:o.StateEffect.reconfigure.of(a)}),{immediate:!0}),n.watch(()=>t.modelValue,async a=>{if(!e.value||e.value.composing||e.value.state.doc.toJSON().join(t.lineSeparator??`
12
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var R=require("@codemirror/commands"),A=require("@codemirror/language"),v=require("@codemirror/lint"),o=require("@codemirror/state"),s=require("@codemirror/view"),b=require("codemirror"),n=require("vue-demi");const F={version:"1.4.3",date:"2026-03-05T01:41:40.028Z"},I=t=>t?Object.entries(t).reduce((u,[l,c])=>(l=l.charAt(0).toUpperCase()+l.slice(1),l=`on${l}`,{...u,[l]:c}),{}):{};function p(t,u={},l){if(n.isVue2)return n.h(t,u,l);const{props:c,domProps:e,on:m,...d}=u,h=m?I(m):{};return n.h(t,{...d,...c,...e,...h},l)}const J=t=>typeof t=="function"?t():t,C=n.defineComponent({name:"CodeMirror",model:{prop:"modelValue",event:"update:modelValue"},props:{modelValue:{type:String,default:""},theme:{type:Object,default:()=>({})},dark:{type:Boolean,default:!1},basic:{type:Boolean,default:!1},minimal:{type:Boolean,default:!1},placeholder:{type:String,default:void 0},wrap:{type:Boolean,default:!1},tab:{type:Boolean,default:!1},indentUnit:{type:String,default:void 0},allowMultipleSelections:{type:Boolean,default:!1},tabSize:{type:Number,default:void 0},lineSeparator:{type:String,default:void 0},readonly:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},extensions:{type:Array,default:()=>[]},phrases:{type:Object,default:void 0},lang:{type:Object,default:void 0},linter:{type:Function,default:void 0},linterConfig:{type:Object,default:()=>({})},forceLinting:{type:Boolean,default:!1},gutter:{type:Boolean,default:!1},gutterConfig:{type:Object,default:void 0},tag:{type:String,default:"div"},scrollIntoView:{type:Boolean,default:!0},keymap:{type:Array,default:()=>[]}},emits:{"update:modelValue":(t="")=>!0,update:t=>!0,ready:t=>!0,focus:t=>!0,change:t=>!0,destroy:()=>!0},setup(t,u){const l=n.ref(),c=n.ref(t.modelValue),e=n.shallowRef(void 0),m=n.computed({get:()=>e.value?.hasFocus??!1,set:a=>{a&&e.value&&e.value.focus()}}),d=n.computed({get:()=>e.value?.state.selection,set:a=>{e.value&&a&&e.value.dispatch({selection:a})}}),h=n.computed({get:()=>e.value?.state.selection.main.head??0,set:a=>{e.value&&e.value.dispatch({selection:{anchor:a}})}}),E=n.computed({get:()=>e.value?.state.toJSON(),set:a=>{e.value&&a&&e.value.setState(o.EditorState.fromJSON(a))}}),S=n.ref(0),g=n.ref(0),y=n.computed(()=>{const a=new o.Compartment,i=new o.Compartment;if(t.basic&&t.minimal)throw new Error("[Vue CodeMirror] Both basic and minimal cannot be specified.");let r=[];return t.keymap&&t.keymap.length>0&&(r=t.keymap),t.tab&&r.push(R.indentWithTab),[t.basic&&!t.minimal?b.basicSetup:void 0,t.minimal&&!t.basic?b.minimalSetup:void 0,s.EditorView.updateListener.of(f=>{e.value&&(u.emit("focus",e.value.hasFocus),S.value=e.value.state.doc?.length,!(f.changes.empty||!f.docChanged)&&(t.linter&&(t.forceLinting&&v.forceLinting(e.value),g.value=t.linter(e.value).length),u.emit("update",f)))}),s.EditorView.theme(t.theme,{dark:t.dark}),t.wrap?s.EditorView.lineWrapping:void 0,t.indentUnit?A.indentUnit.of(t.indentUnit):void 0,o.EditorState.allowMultipleSelections.of(t.allowMultipleSelections),t.tabSize?i.of(o.EditorState.tabSize.of(t.tabSize)):void 0,t.phrases?o.EditorState.phrases.of(t.phrases):void 0,o.EditorState.readOnly.of(t.readonly),s.EditorView.editable.of(!t.disabled),t.lineSeparator?o.EditorState.lineSeparator.of(t.lineSeparator):void 0,t.lang?a.of(t.lang):void 0,t.linter?v.linter(t.linter,t.linterConfig):void 0,t.linter&&t.gutter?v.lintGutter(t.gutterConfig):void 0,t.placeholder?s.placeholder(t.placeholder):void 0,r.length>0?s.keymap.of(r):void 0,...t.extensions].filter(f=>!!f)});n.watch(y,a=>e.value?.dispatch({effects:o.StateEffect.reconfigure.of(a)}),{immediate:!0}),n.watch(()=>t.modelValue,async a=>{if(!e.value||e.value.composing||e.value.state.doc.toJSON().join(t.lineSeparator??`
13
13
  `)===a)return;const i=!e.value.state.selection.ranges.every(r=>r.anchor<a.length&&r.head<a.length);e.value.dispatch({changes:{from:0,to:e.value.state.doc.length,insert:a},selection:i?{anchor:0,head:0}:e.value.state.selection,scrollIntoView:t.scrollIntoView})},{immediate:!0}),n.onMounted(async()=>{if(globalThis.window===void 0||!l.value)return;let a=c.value;l.value.childNodes[0]&&(c.value!==""&&console.warn("[CodeMirror.vue] The <code-mirror> tag contains child elements that overwrite the `v-model` values."),a=l.value.childNodes[0].innerText.trim()),e.value=new s.EditorView({parent:l.value,state:o.EditorState.create({doc:a,extensions:y.value}),dispatch:i=>{e.value&&(e.value.update([i]),!(i.changes.empty||!i.docChanged)&&(u.emit("update:modelValue",i.state.doc.toString()),u.emit("change",i.state)))}}),await n.nextTick(),u.emit("ready",{view:e.value,state:e.value.state,container:l.value})}),n.onUnmounted(()=>{e.value&&(e.value.destroy(),u.emit("destroy"))});const V=()=>{!t.linter||!e.value||(t.forceLinting&&v.forceLinting(e.value),g.value=v.diagnosticCount(e.value.state))},O=()=>{e.value?.dispatch({effects:o.StateEffect.reconfigure.of([])}),e.value?.dispatch({effects:o.StateEffect.appendConfig.of(y.value)})},B=(a,i)=>e.value?.state.sliceDoc(a,i),M=a=>e.value?.state.doc.line(a+1).text,j=()=>e.value?.state.doc.lines??0,q=()=>e.value?.state.selection.main.head??0,L=()=>e.value?.state.selection.ranges??[],_=()=>e.value?e.value.state.sliceDoc(e.value.state.selection.main.from,e.value.state.selection.main.to):"",$=()=>{const a=e.value?.state;return a?a.selection.ranges.map(i=>a.sliceDoc(i.from,i.to)):[]},x=()=>e.value?.state.selection.ranges.some(a=>!a.empty)??!1,N=(a,i,r)=>{e.value&&e.value.dispatch({changes:{from:i,to:r,insert:a}})},T=a=>{e.value&&e.value.dispatch(e.value.state.replaceSelection(a))},U=a=>{e.value&&e.value.dispatch({selection:{anchor:a}})},k=(a,i)=>{e.value&&e.value.dispatch({selection:{anchor:a,head:i}})},z=(a,i)=>{e.value&&e.value.dispatch({selection:o.EditorSelection.create(a,i)})},D=a=>{e.value&&d.value&&e.value.dispatch({selection:o.EditorSelection.create(d.value.ranges.map(i=>i.extend(a(i))))})},w={editor:l,view:e,cursor:h,selection:d,focus:m,length:S,json:E,diagnosticCount:g,dom:e.value?.contentDOM,lint:V,forceReconfigure:O,getRange:B,getLine:M,lineCount:j,getCursor:q,listSelections:L,getSelection:_,getSelections:$,somethingSelected:x,replaceRange:N,replaceSelection:T,setCursor:U,setSelection:k,setSelections:z,extendSelectionsBy:D};return u.expose(w),w},render(){return p(this.$props.tag,{ref:"editor",class:"vue-codemirror"},this.$slots.default?p("aside",{style:"display: none;","aria-hidden":"true"},J(this.$slots.default)):void 0)}}),P=t=>t.component("CodeMirror",C);exports.Meta=F;exports.default=C;exports.install=P;
package/dist/index.es.js CHANGED
@@ -3,22 +3,22 @@
3
3
  *
4
4
  * @description CodeMirror6 Component for vue2 and vue3.
5
5
  * @author Logue <logue@hotmail.co.jp>
6
- * @copyright 2022-2025 By Masashi Yoshikawa All rights reserved.
6
+ * @copyright 2022-2026 By Masashi Yoshikawa All rights reserved.
7
7
  * @license MIT
8
- * @version 1.4.1
8
+ * @version 1.4.3
9
9
  * @see {@link https://github.com/logue/vue-codemirror6}
10
10
  */
11
11
 
12
12
  import { indentWithTab as W } from "@codemirror/commands";
13
13
  import { indentUnit as G } from "@codemirror/language";
14
- import { linter as P, lintGutter as Z, forceLinting as w, diagnosticCount as q } from "@codemirror/lint";
14
+ import { forceLinting as w, linter as P, lintGutter as Z, diagnosticCount as q } from "@codemirror/lint";
15
15
  import { EditorState as u, Compartment as C, StateEffect as S, EditorSelection as O } from "@codemirror/state";
16
16
  import { EditorView as d, placeholder as H, keymap as K } from "@codemirror/view";
17
17
  import { basicSetup as Q, minimalSetup as X } from "codemirror";
18
18
  import { isVue2 as Y, h as V, defineComponent as ee, ref as m, shallowRef as te, computed as f, watch as B, onMounted as ae, nextTick as ne, onUnmounted as ie } from "vue-demi";
19
19
  const he = {
20
- version: "1.4.1",
21
- date: "2025-10-17T22:30:13.688Z"
20
+ version: "1.4.3",
21
+ date: "2026-03-05T01:41:40.028Z"
22
22
  }, le = (t) => t ? Object.entries(t).reduce((l, [i, s]) => (i = i.charAt(0).toUpperCase() + i.slice(1), i = `on${i}`, { ...l, [i]: s }), {}) : {};
23
23
  function M(t, l = {}, i) {
24
24
  if (Y)
@@ -3,11 +3,11 @@
3
3
  *
4
4
  * @description CodeMirror6 Component for vue2 and vue3.
5
5
  * @author Logue <logue@hotmail.co.jp>
6
- * @copyright 2022-2025 By Masashi Yoshikawa All rights reserved.
6
+ * @copyright 2022-2026 By Masashi Yoshikawa All rights reserved.
7
7
  * @license MIT
8
- * @version 1.4.1
8
+ * @version 1.4.3
9
9
  * @see {@link https://github.com/logue/vue-codemirror6}
10
10
  */
11
11
 
12
- var CodeMirror=(function(s,E,O,f,o,c,b,l){"use strict";const M={version:"1.4.1",date:"2025-10-17T22:30:13.688Z"},B=t=>t?Object.entries(t).reduce((r,[i,d])=>(i=i.charAt(0).toUpperCase()+i.slice(1),i=`on${i}`,{...r,[i]:d}),{}):{};function w(t,r={},i){if(l.isVue2)return l.h(t,r,i);const{props:d,domProps:e,on:g,...v}=r,m=g?B(g):{};return l.h(t,{...v,...d,...e,...m},i)}const j=t=>typeof t=="function"?t():t,C=l.defineComponent({name:"CodeMirror",model:{prop:"modelValue",event:"update:modelValue"},props:{modelValue:{type:String,default:""},theme:{type:Object,default:()=>({})},dark:{type:Boolean,default:!1},basic:{type:Boolean,default:!1},minimal:{type:Boolean,default:!1},placeholder:{type:String,default:void 0},wrap:{type:Boolean,default:!1},tab:{type:Boolean,default:!1},indentUnit:{type:String,default:void 0},allowMultipleSelections:{type:Boolean,default:!1},tabSize:{type:Number,default:void 0},lineSeparator:{type:String,default:void 0},readonly:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},extensions:{type:Array,default:()=>[]},phrases:{type:Object,default:void 0},lang:{type:Object,default:void 0},linter:{type:Function,default:void 0},linterConfig:{type:Object,default:()=>({})},forceLinting:{type:Boolean,default:!1},gutter:{type:Boolean,default:!1},gutterConfig:{type:Object,default:void 0},tag:{type:String,default:"div"},scrollIntoView:{type:Boolean,default:!0},keymap:{type:Array,default:()=>[]}},emits:{"update:modelValue":(t="")=>!0,update:t=>!0,ready:t=>!0,focus:t=>!0,change:t=>!0,destroy:()=>!0},setup(t,r){const i=l.ref(),d=l.ref(t.modelValue),e=l.shallowRef(void 0),g=l.computed({get:()=>e.value?.hasFocus??!1,set:a=>{a&&e.value&&e.value.focus()}}),v=l.computed({get:()=>e.value?.state.selection,set:a=>{e.value&&a&&e.value.dispatch({selection:a})}}),m=l.computed({get:()=>e.value?.state.selection.main.head??0,set:a=>{e.value&&e.value.dispatch({selection:{anchor:a}})}}),_=l.computed({get:()=>e.value?.state.toJSON(),set:a=>{e.value&&a&&e.value.setState(o.EditorState.fromJSON(a))}}),p=l.ref(0),y=l.ref(0),S=l.computed(()=>{const a=new o.Compartment,n=new o.Compartment;if(t.basic&&t.minimal)throw new Error("[Vue CodeMirror] Both basic and minimal cannot be specified.");let u=[];return t.keymap&&t.keymap.length>0&&(u=t.keymap),t.tab&&u.push(E.indentWithTab),[t.basic&&!t.minimal?b.basicSetup:void 0,t.minimal&&!t.basic?b.minimalSetup:void 0,c.EditorView.updateListener.of(h=>{e.value&&(r.emit("focus",e.value.hasFocus),p.value=e.value.state.doc?.length,!(h.changes.empty||!h.docChanged)&&(t.linter&&(t.forceLinting&&f.forceLinting(e.value),y.value=t.linter(e.value).length),r.emit("update",h)))}),c.EditorView.theme(t.theme,{dark:t.dark}),t.wrap?c.EditorView.lineWrapping:void 0,t.indentUnit?O.indentUnit.of(t.indentUnit):void 0,o.EditorState.allowMultipleSelections.of(t.allowMultipleSelections),t.tabSize?n.of(o.EditorState.tabSize.of(t.tabSize)):void 0,t.phrases?o.EditorState.phrases.of(t.phrases):void 0,o.EditorState.readOnly.of(t.readonly),c.EditorView.editable.of(!t.disabled),t.lineSeparator?o.EditorState.lineSeparator.of(t.lineSeparator):void 0,t.lang?a.of(t.lang):void 0,t.linter?f.linter(t.linter,t.linterConfig):void 0,t.linter&&t.gutter?f.lintGutter(t.gutterConfig):void 0,t.placeholder?c.placeholder(t.placeholder):void 0,u.length>0?c.keymap.of(u):void 0,...t.extensions].filter(h=>!!h)});l.watch(S,a=>e.value?.dispatch({effects:o.StateEffect.reconfigure.of(a)}),{immediate:!0}),l.watch(()=>t.modelValue,async a=>{if(!e.value||e.value.composing||e.value.state.doc.toJSON().join(t.lineSeparator??`
12
+ var CodeMirror=(function(s,E,O,f,o,c,b,l){"use strict";const M={version:"1.4.3",date:"2026-03-05T01:41:40.028Z"},B=t=>t?Object.entries(t).reduce((r,[i,d])=>(i=i.charAt(0).toUpperCase()+i.slice(1),i=`on${i}`,{...r,[i]:d}),{}):{};function w(t,r={},i){if(l.isVue2)return l.h(t,r,i);const{props:d,domProps:e,on:g,...v}=r,m=g?B(g):{};return l.h(t,{...v,...d,...e,...m},i)}const j=t=>typeof t=="function"?t():t,C=l.defineComponent({name:"CodeMirror",model:{prop:"modelValue",event:"update:modelValue"},props:{modelValue:{type:String,default:""},theme:{type:Object,default:()=>({})},dark:{type:Boolean,default:!1},basic:{type:Boolean,default:!1},minimal:{type:Boolean,default:!1},placeholder:{type:String,default:void 0},wrap:{type:Boolean,default:!1},tab:{type:Boolean,default:!1},indentUnit:{type:String,default:void 0},allowMultipleSelections:{type:Boolean,default:!1},tabSize:{type:Number,default:void 0},lineSeparator:{type:String,default:void 0},readonly:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},extensions:{type:Array,default:()=>[]},phrases:{type:Object,default:void 0},lang:{type:Object,default:void 0},linter:{type:Function,default:void 0},linterConfig:{type:Object,default:()=>({})},forceLinting:{type:Boolean,default:!1},gutter:{type:Boolean,default:!1},gutterConfig:{type:Object,default:void 0},tag:{type:String,default:"div"},scrollIntoView:{type:Boolean,default:!0},keymap:{type:Array,default:()=>[]}},emits:{"update:modelValue":(t="")=>!0,update:t=>!0,ready:t=>!0,focus:t=>!0,change:t=>!0,destroy:()=>!0},setup(t,r){const i=l.ref(),d=l.ref(t.modelValue),e=l.shallowRef(void 0),g=l.computed({get:()=>e.value?.hasFocus??!1,set:a=>{a&&e.value&&e.value.focus()}}),v=l.computed({get:()=>e.value?.state.selection,set:a=>{e.value&&a&&e.value.dispatch({selection:a})}}),m=l.computed({get:()=>e.value?.state.selection.main.head??0,set:a=>{e.value&&e.value.dispatch({selection:{anchor:a}})}}),_=l.computed({get:()=>e.value?.state.toJSON(),set:a=>{e.value&&a&&e.value.setState(o.EditorState.fromJSON(a))}}),p=l.ref(0),y=l.ref(0),S=l.computed(()=>{const a=new o.Compartment,n=new o.Compartment;if(t.basic&&t.minimal)throw new Error("[Vue CodeMirror] Both basic and minimal cannot be specified.");let u=[];return t.keymap&&t.keymap.length>0&&(u=t.keymap),t.tab&&u.push(E.indentWithTab),[t.basic&&!t.minimal?b.basicSetup:void 0,t.minimal&&!t.basic?b.minimalSetup:void 0,c.EditorView.updateListener.of(h=>{e.value&&(r.emit("focus",e.value.hasFocus),p.value=e.value.state.doc?.length,!(h.changes.empty||!h.docChanged)&&(t.linter&&(t.forceLinting&&f.forceLinting(e.value),y.value=t.linter(e.value).length),r.emit("update",h)))}),c.EditorView.theme(t.theme,{dark:t.dark}),t.wrap?c.EditorView.lineWrapping:void 0,t.indentUnit?O.indentUnit.of(t.indentUnit):void 0,o.EditorState.allowMultipleSelections.of(t.allowMultipleSelections),t.tabSize?n.of(o.EditorState.tabSize.of(t.tabSize)):void 0,t.phrases?o.EditorState.phrases.of(t.phrases):void 0,o.EditorState.readOnly.of(t.readonly),c.EditorView.editable.of(!t.disabled),t.lineSeparator?o.EditorState.lineSeparator.of(t.lineSeparator):void 0,t.lang?a.of(t.lang):void 0,t.linter?f.linter(t.linter,t.linterConfig):void 0,t.linter&&t.gutter?f.lintGutter(t.gutterConfig):void 0,t.placeholder?c.placeholder(t.placeholder):void 0,u.length>0?c.keymap.of(u):void 0,...t.extensions].filter(h=>!!h)});l.watch(S,a=>e.value?.dispatch({effects:o.StateEffect.reconfigure.of(a)}),{immediate:!0}),l.watch(()=>t.modelValue,async a=>{if(!e.value||e.value.composing||e.value.state.doc.toJSON().join(t.lineSeparator??`
13
13
  `)===a)return;const n=!e.value.state.selection.ranges.every(u=>u.anchor<a.length&&u.head<a.length);e.value.dispatch({changes:{from:0,to:e.value.state.doc.length,insert:a},selection:n?{anchor:0,head:0}:e.value.state.selection,scrollIntoView:t.scrollIntoView})},{immediate:!0}),l.onMounted(async()=>{if(globalThis.window===void 0||!i.value)return;let a=d.value;i.value.childNodes[0]&&(d.value!==""&&console.warn("[CodeMirror.vue] The <code-mirror> tag contains child elements that overwrite the `v-model` values."),a=i.value.childNodes[0].innerText.trim()),e.value=new c.EditorView({parent:i.value,state:o.EditorState.create({doc:a,extensions:S.value}),dispatch:n=>{e.value&&(e.value.update([n]),!(n.changes.empty||!n.docChanged)&&(r.emit("update:modelValue",n.state.doc.toString()),r.emit("change",n.state)))}}),await l.nextTick(),r.emit("ready",{view:e.value,state:e.value.state,container:i.value})}),l.onUnmounted(()=>{e.value&&(e.value.destroy(),r.emit("destroy"))});const $=()=>{!t.linter||!e.value||(t.forceLinting&&f.forceLinting(e.value),y.value=f.diagnosticCount(e.value.state))},N=()=>{e.value?.dispatch({effects:o.StateEffect.reconfigure.of([])}),e.value?.dispatch({effects:o.StateEffect.appendConfig.of(S.value)})},T=(a,n)=>e.value?.state.sliceDoc(a,n),U=a=>e.value?.state.doc.line(a+1).text,k=()=>e.value?.state.doc.lines??0,z=()=>e.value?.state.selection.main.head??0,R=()=>e.value?.state.selection.ranges??[],A=()=>e.value?e.value.state.sliceDoc(e.value.state.selection.main.from,e.value.state.selection.main.to):"",F=()=>{const a=e.value?.state;return a?a.selection.ranges.map(n=>a.sliceDoc(n.from,n.to)):[]},I=()=>e.value?.state.selection.ranges.some(a=>!a.empty)??!1,J=(a,n,u)=>{e.value&&e.value.dispatch({changes:{from:n,to:u,insert:a}})},x=a=>{e.value&&e.value.dispatch(e.value.state.replaceSelection(a))},P=a=>{e.value&&e.value.dispatch({selection:{anchor:a}})},W=(a,n)=>{e.value&&e.value.dispatch({selection:{anchor:a,head:n}})},G=(a,n)=>{e.value&&e.value.dispatch({selection:o.EditorSelection.create(a,n)})},Z=a=>{e.value&&v.value&&e.value.dispatch({selection:o.EditorSelection.create(v.value.ranges.map(n=>n.extend(a(n))))})},V={editor:i,view:e,cursor:m,selection:v,focus:g,length:p,json:_,diagnosticCount:y,dom:e.value?.contentDOM,lint:$,forceReconfigure:N,getRange:T,getLine:U,lineCount:k,getCursor:z,listSelections:R,getSelection:A,getSelections:F,somethingSelected:I,replaceRange:J,replaceSelection:x,setCursor:P,setSelection:W,setSelections:G,extendSelectionsBy:Z};return r.expose(V),V},render(){return w(this.$props.tag,{ref:"editor",class:"vue-codemirror"},this.$slots.default?w("aside",{style:"display: none;","aria-hidden":"true"},j(this.$slots.default)):void 0)}}),L=t=>t.component("CodeMirror",C);return s.Meta=M,s.default=C,s.install=L,Object.defineProperty(s,"__esModule",{value:!0}),s})({},commands,language,lint,state,view,codemirror,VueDemi);
package/dist/index.umd.js CHANGED
@@ -3,11 +3,11 @@
3
3
  *
4
4
  * @description CodeMirror6 Component for vue2 and vue3.
5
5
  * @author Logue <logue@hotmail.co.jp>
6
- * @copyright 2022-2025 By Masashi Yoshikawa All rights reserved.
6
+ * @copyright 2022-2026 By Masashi Yoshikawa All rights reserved.
7
7
  * @license MIT
8
- * @version 1.4.1
8
+ * @version 1.4.3
9
9
  * @see {@link https://github.com/logue/vue-codemirror6}
10
10
  */
11
11
 
12
- (function(l,f){typeof exports=="object"&&typeof module<"u"?f(exports,require("@codemirror/commands"),require("@codemirror/language"),require("@codemirror/lint"),require("@codemirror/state"),require("@codemirror/view"),require("codemirror"),require("vue-demi")):typeof define=="function"&&define.amd?define(["exports","@codemirror/commands","@codemirror/language","@codemirror/lint","@codemirror/state","@codemirror/view","codemirror","vue-demi"],f):(l=typeof globalThis<"u"?globalThis:l||self,f(l.CodeMirror={},l.commands,l.language,l.lint,l.state,l.view,l.codemirror,l.VueDemi))})(this,(function(l,f,O,v,r,c,w,i){"use strict";const M={version:"1.4.1",date:"2025-10-17T22:30:13.688Z"},B=t=>t?Object.entries(t).reduce((d,[o,s])=>(o=o.charAt(0).toUpperCase()+o.slice(1),o=`on${o}`,{...d,[o]:s}),{}):{};function C(t,d={},o){if(i.isVue2)return i.h(t,d,o);const{props:s,domProps:e,on:g,...m}=d,y=g?B(g):{};return i.h(t,{...m,...s,...e,...y},o)}const j=t=>typeof t=="function"?t():t,b=i.defineComponent({name:"CodeMirror",model:{prop:"modelValue",event:"update:modelValue"},props:{modelValue:{type:String,default:""},theme:{type:Object,default:()=>({})},dark:{type:Boolean,default:!1},basic:{type:Boolean,default:!1},minimal:{type:Boolean,default:!1},placeholder:{type:String,default:void 0},wrap:{type:Boolean,default:!1},tab:{type:Boolean,default:!1},indentUnit:{type:String,default:void 0},allowMultipleSelections:{type:Boolean,default:!1},tabSize:{type:Number,default:void 0},lineSeparator:{type:String,default:void 0},readonly:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},extensions:{type:Array,default:()=>[]},phrases:{type:Object,default:void 0},lang:{type:Object,default:void 0},linter:{type:Function,default:void 0},linterConfig:{type:Object,default:()=>({})},forceLinting:{type:Boolean,default:!1},gutter:{type:Boolean,default:!1},gutterConfig:{type:Object,default:void 0},tag:{type:String,default:"div"},scrollIntoView:{type:Boolean,default:!0},keymap:{type:Array,default:()=>[]}},emits:{"update:modelValue":(t="")=>!0,update:t=>!0,ready:t=>!0,focus:t=>!0,change:t=>!0,destroy:()=>!0},setup(t,d){const o=i.ref(),s=i.ref(t.modelValue),e=i.shallowRef(void 0),g=i.computed({get:()=>e.value?.hasFocus??!1,set:a=>{a&&e.value&&e.value.focus()}}),m=i.computed({get:()=>e.value?.state.selection,set:a=>{e.value&&a&&e.value.dispatch({selection:a})}}),y=i.computed({get:()=>e.value?.state.selection.main.head??0,set:a=>{e.value&&e.value.dispatch({selection:{anchor:a}})}}),q=i.computed({get:()=>e.value?.state.toJSON(),set:a=>{e.value&&a&&e.value.setState(r.EditorState.fromJSON(a))}}),V=i.ref(0),S=i.ref(0),p=i.computed(()=>{const a=new r.Compartment,n=new r.Compartment;if(t.basic&&t.minimal)throw new Error("[Vue CodeMirror] Both basic and minimal cannot be specified.");let u=[];return t.keymap&&t.keymap.length>0&&(u=t.keymap),t.tab&&u.push(f.indentWithTab),[t.basic&&!t.minimal?w.basicSetup:void 0,t.minimal&&!t.basic?w.minimalSetup:void 0,c.EditorView.updateListener.of(h=>{e.value&&(d.emit("focus",e.value.hasFocus),V.value=e.value.state.doc?.length,!(h.changes.empty||!h.docChanged)&&(t.linter&&(t.forceLinting&&v.forceLinting(e.value),S.value=t.linter(e.value).length),d.emit("update",h)))}),c.EditorView.theme(t.theme,{dark:t.dark}),t.wrap?c.EditorView.lineWrapping:void 0,t.indentUnit?O.indentUnit.of(t.indentUnit):void 0,r.EditorState.allowMultipleSelections.of(t.allowMultipleSelections),t.tabSize?n.of(r.EditorState.tabSize.of(t.tabSize)):void 0,t.phrases?r.EditorState.phrases.of(t.phrases):void 0,r.EditorState.readOnly.of(t.readonly),c.EditorView.editable.of(!t.disabled),t.lineSeparator?r.EditorState.lineSeparator.of(t.lineSeparator):void 0,t.lang?a.of(t.lang):void 0,t.linter?v.linter(t.linter,t.linterConfig):void 0,t.linter&&t.gutter?v.lintGutter(t.gutterConfig):void 0,t.placeholder?c.placeholder(t.placeholder):void 0,u.length>0?c.keymap.of(u):void 0,...t.extensions].filter(h=>!!h)});i.watch(p,a=>e.value?.dispatch({effects:r.StateEffect.reconfigure.of(a)}),{immediate:!0}),i.watch(()=>t.modelValue,async a=>{if(!e.value||e.value.composing||e.value.state.doc.toJSON().join(t.lineSeparator??`
12
+ (function(l,f){typeof exports=="object"&&typeof module<"u"?f(exports,require("@codemirror/commands"),require("@codemirror/language"),require("@codemirror/lint"),require("@codemirror/state"),require("@codemirror/view"),require("codemirror"),require("vue-demi")):typeof define=="function"&&define.amd?define(["exports","@codemirror/commands","@codemirror/language","@codemirror/lint","@codemirror/state","@codemirror/view","codemirror","vue-demi"],f):(l=typeof globalThis<"u"?globalThis:l||self,f(l.CodeMirror={},l.commands,l.language,l.lint,l.state,l.view,l.codemirror,l.VueDemi))})(this,(function(l,f,O,v,r,c,w,i){"use strict";const M={version:"1.4.3",date:"2026-03-05T01:41:40.028Z"},B=t=>t?Object.entries(t).reduce((d,[o,s])=>(o=o.charAt(0).toUpperCase()+o.slice(1),o=`on${o}`,{...d,[o]:s}),{}):{};function C(t,d={},o){if(i.isVue2)return i.h(t,d,o);const{props:s,domProps:e,on:g,...m}=d,y=g?B(g):{};return i.h(t,{...m,...s,...e,...y},o)}const j=t=>typeof t=="function"?t():t,b=i.defineComponent({name:"CodeMirror",model:{prop:"modelValue",event:"update:modelValue"},props:{modelValue:{type:String,default:""},theme:{type:Object,default:()=>({})},dark:{type:Boolean,default:!1},basic:{type:Boolean,default:!1},minimal:{type:Boolean,default:!1},placeholder:{type:String,default:void 0},wrap:{type:Boolean,default:!1},tab:{type:Boolean,default:!1},indentUnit:{type:String,default:void 0},allowMultipleSelections:{type:Boolean,default:!1},tabSize:{type:Number,default:void 0},lineSeparator:{type:String,default:void 0},readonly:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},extensions:{type:Array,default:()=>[]},phrases:{type:Object,default:void 0},lang:{type:Object,default:void 0},linter:{type:Function,default:void 0},linterConfig:{type:Object,default:()=>({})},forceLinting:{type:Boolean,default:!1},gutter:{type:Boolean,default:!1},gutterConfig:{type:Object,default:void 0},tag:{type:String,default:"div"},scrollIntoView:{type:Boolean,default:!0},keymap:{type:Array,default:()=>[]}},emits:{"update:modelValue":(t="")=>!0,update:t=>!0,ready:t=>!0,focus:t=>!0,change:t=>!0,destroy:()=>!0},setup(t,d){const o=i.ref(),s=i.ref(t.modelValue),e=i.shallowRef(void 0),g=i.computed({get:()=>e.value?.hasFocus??!1,set:a=>{a&&e.value&&e.value.focus()}}),m=i.computed({get:()=>e.value?.state.selection,set:a=>{e.value&&a&&e.value.dispatch({selection:a})}}),y=i.computed({get:()=>e.value?.state.selection.main.head??0,set:a=>{e.value&&e.value.dispatch({selection:{anchor:a}})}}),q=i.computed({get:()=>e.value?.state.toJSON(),set:a=>{e.value&&a&&e.value.setState(r.EditorState.fromJSON(a))}}),V=i.ref(0),S=i.ref(0),p=i.computed(()=>{const a=new r.Compartment,n=new r.Compartment;if(t.basic&&t.minimal)throw new Error("[Vue CodeMirror] Both basic and minimal cannot be specified.");let u=[];return t.keymap&&t.keymap.length>0&&(u=t.keymap),t.tab&&u.push(f.indentWithTab),[t.basic&&!t.minimal?w.basicSetup:void 0,t.minimal&&!t.basic?w.minimalSetup:void 0,c.EditorView.updateListener.of(h=>{e.value&&(d.emit("focus",e.value.hasFocus),V.value=e.value.state.doc?.length,!(h.changes.empty||!h.docChanged)&&(t.linter&&(t.forceLinting&&v.forceLinting(e.value),S.value=t.linter(e.value).length),d.emit("update",h)))}),c.EditorView.theme(t.theme,{dark:t.dark}),t.wrap?c.EditorView.lineWrapping:void 0,t.indentUnit?O.indentUnit.of(t.indentUnit):void 0,r.EditorState.allowMultipleSelections.of(t.allowMultipleSelections),t.tabSize?n.of(r.EditorState.tabSize.of(t.tabSize)):void 0,t.phrases?r.EditorState.phrases.of(t.phrases):void 0,r.EditorState.readOnly.of(t.readonly),c.EditorView.editable.of(!t.disabled),t.lineSeparator?r.EditorState.lineSeparator.of(t.lineSeparator):void 0,t.lang?a.of(t.lang):void 0,t.linter?v.linter(t.linter,t.linterConfig):void 0,t.linter&&t.gutter?v.lintGutter(t.gutterConfig):void 0,t.placeholder?c.placeholder(t.placeholder):void 0,u.length>0?c.keymap.of(u):void 0,...t.extensions].filter(h=>!!h)});i.watch(p,a=>e.value?.dispatch({effects:r.StateEffect.reconfigure.of(a)}),{immediate:!0}),i.watch(()=>t.modelValue,async a=>{if(!e.value||e.value.composing||e.value.state.doc.toJSON().join(t.lineSeparator??`
13
13
  `)===a)return;const n=!e.value.state.selection.ranges.every(u=>u.anchor<a.length&&u.head<a.length);e.value.dispatch({changes:{from:0,to:e.value.state.doc.length,insert:a},selection:n?{anchor:0,head:0}:e.value.state.selection,scrollIntoView:t.scrollIntoView})},{immediate:!0}),i.onMounted(async()=>{if(globalThis.window===void 0||!o.value)return;let a=s.value;o.value.childNodes[0]&&(s.value!==""&&console.warn("[CodeMirror.vue] The <code-mirror> tag contains child elements that overwrite the `v-model` values."),a=o.value.childNodes[0].innerText.trim()),e.value=new c.EditorView({parent:o.value,state:r.EditorState.create({doc:a,extensions:p.value}),dispatch:n=>{e.value&&(e.value.update([n]),!(n.changes.empty||!n.docChanged)&&(d.emit("update:modelValue",n.state.doc.toString()),d.emit("change",n.state)))}}),await i.nextTick(),d.emit("ready",{view:e.value,state:e.value.state,container:o.value})}),i.onUnmounted(()=>{e.value&&(e.value.destroy(),d.emit("destroy"))});const L=()=>{!t.linter||!e.value||(t.forceLinting&&v.forceLinting(e.value),S.value=v.diagnosticCount(e.value.state))},_=()=>{e.value?.dispatch({effects:r.StateEffect.reconfigure.of([])}),e.value?.dispatch({effects:r.StateEffect.appendConfig.of(p.value)})},$=(a,n)=>e.value?.state.sliceDoc(a,n),x=a=>e.value?.state.doc.line(a+1).text,N=()=>e.value?.state.doc.lines??0,U=()=>e.value?.state.selection.main.head??0,k=()=>e.value?.state.selection.ranges??[],z=()=>e.value?e.value.state.sliceDoc(e.value.state.selection.main.from,e.value.state.selection.main.to):"",R=()=>{const a=e.value?.state;return a?a.selection.ranges.map(n=>a.sliceDoc(n.from,n.to)):[]},A=()=>e.value?.state.selection.ranges.some(a=>!a.empty)??!1,F=(a,n,u)=>{e.value&&e.value.dispatch({changes:{from:n,to:u,insert:a}})},I=a=>{e.value&&e.value.dispatch(e.value.state.replaceSelection(a))},J=a=>{e.value&&e.value.dispatch({selection:{anchor:a}})},P=(a,n)=>{e.value&&e.value.dispatch({selection:{anchor:a,head:n}})},W=(a,n)=>{e.value&&e.value.dispatch({selection:r.EditorSelection.create(a,n)})},G=a=>{e.value&&m.value&&e.value.dispatch({selection:r.EditorSelection.create(m.value.ranges.map(n=>n.extend(a(n))))})},E={editor:o,view:e,cursor:y,selection:m,focus:g,length:V,json:q,diagnosticCount:S,dom:e.value?.contentDOM,lint:L,forceReconfigure:_,getRange:$,getLine:x,lineCount:N,getCursor:U,listSelections:k,getSelection:z,getSelections:R,somethingSelected:A,replaceRange:F,replaceSelection:I,setCursor:J,setSelection:P,setSelections:W,extendSelectionsBy:G};return d.expose(E),E},render(){return C(this.$props.tag,{ref:"editor",class:"vue-codemirror"},this.$slots.default?C("aside",{style:"display: none;","aria-hidden":"true"},j(this.$slots.default)):void 0)}}),T=t=>t.component("CodeMirror",b);l.Meta=M,l.default=b,l.install=T,Object.defineProperty(l,"__esModule",{value:!0})}));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "vue-codemirror6",
4
- "version": "1.4.1",
4
+ "version": "1.4.3",
5
5
  "license": "MIT",
6
6
  "description": "CodeMirror6 Component for vue2 and vue3.",
7
7
  "keywords": [
@@ -57,10 +57,10 @@
57
57
  ],
58
58
  "sideEffects": false,
59
59
  "engines": {
60
- "node": ">=18",
60
+ "node": "^20.19.0 || >=22.12.0",
61
61
  "pnpm": ">=10.3.0"
62
62
  },
63
- "packageManager": "pnpm@10.18.3",
63
+ "packageManager": "pnpm@10.30.3",
64
64
  "scripts": {
65
65
  "dev": "vite",
66
66
  "clean": "rimraf node_modules/.vite",
@@ -68,7 +68,10 @@
68
68
  "build:analyze": "vite build --mode=analyze",
69
69
  "build:clean": "rimraf dist docs",
70
70
  "build:docs": "vite build --mode=docs",
71
- "lint": "eslint . --fix --cache --cache-location ./node_modules/.vite/vite-plugin-eslint && prettier . --write",
71
+ "lint": "run-s lint:*",
72
+ "lint:oxlint": "oxlint . --fix",
73
+ "lint:eslint": "eslint . --fix --cache --cache-location ./node_modules/.vite/eslint-cache",
74
+ "lint:prettier": "prettier \"./**/*.{js,ts,json,css,sass,scss,htm,html,vue,md}\" -w -u",
72
75
  "preview": "vite preview --mode=docs",
73
76
  "build-only": "vite build",
74
77
  "type-check": "vue-tsc --declaration --emitDeclarationOnly",
@@ -95,59 +98,62 @@
95
98
  "vue": "^2.7.14 || ^3.3.4"
96
99
  },
97
100
  "devDependencies": {
98
- "@codemirror/autocomplete": "^6.19.0",
99
- "@codemirror/commands": "^6.9.0",
100
- "@codemirror/language": "^6.11.3",
101
- "@codemirror/lang-javascript": "^6.2.4",
101
+ "@codemirror/autocomplete": "^6.20.1",
102
+ "@codemirror/commands": "^6.10.2",
103
+ "@codemirror/lang-javascript": "^6.2.5",
102
104
  "@codemirror/lang-json": "^6.0.2",
103
- "@codemirror/lang-markdown": "^6.4.0",
105
+ "@codemirror/lang-markdown": "^6.5.0",
104
106
  "@codemirror/lang-vue": "^0.1.3",
105
- "@codemirror/lint": "^6.9.0",
106
- "@codemirror/search": "^6.5.11",
107
- "@codemirror/state": "^6.5.2",
108
- "@codemirror/view": "^6.38.6",
109
- "codemirror": "^6.0.2",
110
- "style-mod": "^4.1.3",
111
- "@tsconfig/node-lts": "^22.0.2",
112
- "@types/node": "^24.8.1",
113
- "@vitejs/plugin-vue": "^6.0.1",
114
- "@vitest/ui": "^3.2.4",
115
- "@vue/compiler-sfc": "^3.5.22",
107
+ "@codemirror/language": "^6.12.2",
108
+ "@codemirror/lint": "^6.9.5",
109
+ "@codemirror/search": "^6.6.0",
110
+ "@codemirror/state": "^6.5.4",
111
+ "@codemirror/view": "^6.39.16",
112
+ "@tsconfig/node-lts": "^24.0.0",
113
+ "@types/node": "^25.3.3",
114
+ "@vitejs/plugin-vue": "^6.0.4",
115
+ "@vitest/ui": "^4.0.18",
116
+ "@vue/compiler-sfc": "^3.5.29",
116
117
  "@vue/eslint-config-prettier": "^10.2.0",
117
- "@vue/eslint-config-typescript": "^14.6.0",
118
+ "@vue/eslint-config-typescript": "^14.7.0",
118
119
  "@vue/test-utils": "^2.4.6",
119
- "@vue/tsconfig": "^0.8.1",
120
- "@vueuse/core": "^13.9.0",
120
+ "@vue/tsconfig": "^0.9.0",
121
+ "@vueuse/core": "^14.2.1",
121
122
  "bootstrap": "^5.3.8",
122
- "eslint": "^9.38.0",
123
+ "codemirror": "^6.0.2",
124
+ "eslint": "^10.0.2",
123
125
  "eslint-import-resolver-custom-alias": "^1.3.2",
124
126
  "eslint-import-resolver-typescript": "^4.4.4",
125
- "eslint-linter-browserify": "^9.37.0",
126
- "eslint-plugin-import": "^2.32.0",
127
- "eslint-plugin-playwright": "^2.2.2",
128
- "eslint-plugin-vue": "^10.5.1",
129
- "eslint-plugin-vuejs-accessibility": "^2.4.1",
130
- "happy-dom": "^20.0.5",
127
+ "eslint-linter-browserify": "^10.0.2",
128
+ "eslint-plugin-import-x": "^4.16.1",
129
+ "eslint-plugin-oxlint": "^1.51.0",
130
+ "eslint-plugin-playwright": "^2.9.0",
131
+ "eslint-plugin-security": "^4.0.0",
132
+ "eslint-plugin-vue": "^10.8.0",
133
+ "eslint-plugin-vuejs-accessibility": "^2.5.0",
134
+ "happy-dom": "^20.8.3",
131
135
  "husky": "^9.1.7",
132
136
  "jiti": "^2.6.1",
133
- "lint-staged": "^16.2.4",
137
+ "lint-staged": "^16.3.2",
134
138
  "npm-run-all2": "^8.0.4",
135
- "prettier": "^3.6.2",
136
- "rimraf": "^6.0.1",
137
- "rollup-plugin-visualizer": "^6.0.5",
138
- "sass-embedded": "^1.93.2",
139
+ "oxlint": "^1.51.0",
140
+ "prettier": "^3.8.1",
141
+ "rimraf": "^6.1.3",
142
+ "rollup-plugin-visualizer": "^7.0.1",
143
+ "sass-embedded": "^1.97.3",
144
+ "style-mod": "^4.1.3",
139
145
  "supports-color": "^10.2.2",
140
146
  "typescript": "^5.9.3",
141
- "typescript-eslint": "^8.46.1",
142
- "vite": "^7.1.10",
147
+ "typescript-eslint": "^8.56.1",
148
+ "vite": "^7.3.1",
143
149
  "vite-plugin-banner": "^0.8.1",
144
- "vite-plugin-checker": "^0.11.0",
150
+ "vite-plugin-checker": "^0.12.0",
145
151
  "vite-plugin-dts": "^4.5.4",
146
- "vitest": "^3.2.4",
147
- "vue": "^3.5.22",
148
- "vue-eslint-parser": "^10.2.0",
149
- "vue-markdown-wasm": "^0.5.2",
150
- "vue-tsc": "^3.1.1"
152
+ "vitest": "^4.0.18",
153
+ "vue": "^3.5.29",
154
+ "vue-eslint-parser": "^10.4.0",
155
+ "vue-markdown-wasm": "^1.0.1",
156
+ "vue-tsc": "^3.2.5"
151
157
  },
152
158
  "husky": {
153
159
  "hooks": {
@@ -160,6 +166,7 @@
160
166
  },
161
167
  "resolutions": {
162
168
  "json5": ">=2.2.3",
169
+ "minimatch": ">=10.2.3",
163
170
  "yaml": ">=2.6.0"
164
171
  }
165
172
  }