vue-codemirror6 1.6.1 → 1.7.0
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/README.ja.md +60 -66
- package/README.md +77 -69
- package/dist/index.d.ts +510 -718
- package/dist/index.es.js +371 -369
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +9 -498
- package/package.json +82 -88
- package/CHANGELOG.md +0 -332
- package/dist/index.cjs +0 -461
- package/dist/index.cjs.map +0 -1
- package/dist/index.umd.js.map +0 -1
package/README.ja.md
CHANGED
|
@@ -6,12 +6,13 @@
|
|
|
6
6
|
<img src="https://user-images.githubusercontent.com/480173/224358008-6ffad05d-1d97-4c18-8554-7d41b03f88ab.png" alt="logo" width="300" height="300" />
|
|
7
7
|
</p>
|
|
8
8
|
|
|
9
|
-
[](https://www.jsdelivr.com/package/npm/vue-codemirror6)
|
|
10
|
-
[](https://www.npmjs.com/package/vue-codemirror6)
|
|
11
|
-
[](https://uiwjs.github.io/npm-unpkg/#/pkg/vue-codemirror6/file/README.md)
|
|
12
9
|
[](https://www.npmjs.com/package/vue-codemirror6)
|
|
10
|
+
[](https://www.npmjs.com/package/vue-codemirror6)
|
|
11
|
+
[](https://www.jsdelivr.com/package/npm/vue-codemirror6)
|
|
12
|
+
[](https://uiwjs.github.io/npm-unpkg/#/pkg/@logue/vue-codemirror6/file/README.md)
|
|
13
13
|
[](https://gitpod.io/#https://github.com/logue/vue-codemirror6)
|
|
14
|
-
[](https://x.com/logue256)
|
|
15
|
+
[](https://github.com/sponsors/logue)
|
|
15
16
|
|
|
16
17
|
Vueで[CodeMirror6](https://codemirror.net/6/)を使用するためのコンポーネントです。このコンポーネントはVue2とVue3の両方で動作します。
|
|
17
18
|
|
|
@@ -152,16 +153,16 @@ pnpm install vue-codemirror6 @vue/composition-api
|
|
|
152
153
|
</template>
|
|
153
154
|
|
|
154
155
|
<script>
|
|
155
|
-
import { ref, defineComponent } from
|
|
156
|
+
import { ref, defineComponent } from "vue";
|
|
156
157
|
|
|
157
|
-
import CodeMirror from
|
|
158
|
+
import CodeMirror from "vue-codemirror6";
|
|
158
159
|
|
|
159
160
|
export default defineComponent({
|
|
160
161
|
components: {
|
|
161
162
|
CodeMirror,
|
|
162
163
|
},
|
|
163
164
|
setup() {
|
|
164
|
-
const value = ref(
|
|
165
|
+
const value = ref("Cozy lummox gives smart squid who asks for job pen.");
|
|
165
166
|
|
|
166
167
|
return { value };
|
|
167
168
|
},
|
|
@@ -181,16 +182,17 @@ export default defineComponent({
|
|
|
181
182
|
<pre>
|
|
182
183
|
{
|
|
183
184
|
"key": "value"
|
|
184
|
-
}</pre
|
|
185
|
+
}</pre
|
|
186
|
+
>
|
|
185
187
|
</code-mirror>
|
|
186
188
|
</template>
|
|
187
189
|
|
|
188
190
|
<script>
|
|
189
|
-
import { ref, defineComponent } from
|
|
191
|
+
import { ref, defineComponent } from "vue";
|
|
190
192
|
|
|
191
|
-
import { json, jsonParseLinter } from
|
|
193
|
+
import { json, jsonParseLinter } from "@codemirror/lang-json";
|
|
192
194
|
|
|
193
|
-
import CodeMirror from
|
|
195
|
+
import CodeMirror from "vue-codemirror6";
|
|
194
196
|
|
|
195
197
|
export default defineComponent({
|
|
196
198
|
components: {
|
|
@@ -217,9 +219,9 @@ Nuxt 3を使用している場合は、コンポーネントを直接使用で
|
|
|
217
219
|
</template>
|
|
218
220
|
|
|
219
221
|
<script setup lang="ts">
|
|
220
|
-
import { ref } from
|
|
221
|
-
import CodeMirror from
|
|
222
|
-
import { javascript } from
|
|
222
|
+
import { ref } from "vue";
|
|
223
|
+
import CodeMirror from "vue-codemirror6";
|
|
224
|
+
import { javascript } from "@codemirror/lang-javascript";
|
|
223
225
|
|
|
224
226
|
const value = ref('console.log("Hello, World!");');
|
|
225
227
|
const lang = javascript();
|
|
@@ -242,23 +244,23 @@ Nuxt 2を使用している場合や問題が発生した場合は、コンポ
|
|
|
242
244
|
|
|
243
245
|
```vue
|
|
244
246
|
<script lang="ts" setup>
|
|
245
|
-
import { ref, defineComponent, type Ref } from
|
|
247
|
+
import { ref, defineComponent, type Ref } from "vue";
|
|
246
248
|
|
|
247
249
|
// コンポーネントの読み込み
|
|
248
|
-
import CodeMirror from
|
|
250
|
+
import CodeMirror from "vue-codemirror6";
|
|
249
251
|
|
|
250
252
|
// CodeMirror拡張機能
|
|
251
|
-
import { markdown as md } from
|
|
252
|
-
import type { LanguageSupport } from
|
|
253
|
-
import type { Extension } from
|
|
254
|
-
import type { ViewUpdate } from
|
|
253
|
+
import { markdown as md } from "@codemirror/lang-markdown";
|
|
254
|
+
import type { LanguageSupport } from "@codemirror/language";
|
|
255
|
+
import type { Extension } from "@codemirror/state";
|
|
256
|
+
import type { ViewUpdate } from "@codemirror/view";
|
|
255
257
|
|
|
256
258
|
/** テキスト */
|
|
257
|
-
const value: Ref<string> = ref(
|
|
259
|
+
const value: Ref<string> = ref("");
|
|
258
260
|
|
|
259
261
|
/** ダークモード **/
|
|
260
262
|
const dark: Ref<boolean> = ref(
|
|
261
|
-
window.matchMedia(
|
|
263
|
+
window.matchMedia("(prefers-color-scheme: dark)").matches,
|
|
262
264
|
);
|
|
263
265
|
|
|
264
266
|
/**
|
|
@@ -277,40 +279,40 @@ const lang: LanguageSupport = md();
|
|
|
277
279
|
*/
|
|
278
280
|
const phrases: Record<string, string> = {
|
|
279
281
|
// @codemirror/view
|
|
280
|
-
|
|
282
|
+
"Control character": "制御文字",
|
|
281
283
|
// @codemirror/commands
|
|
282
|
-
|
|
284
|
+
"Selection deleted": "選択を削除",
|
|
283
285
|
// @codemirror/language
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
to:
|
|
287
|
-
|
|
288
|
-
unfold:
|
|
289
|
-
|
|
290
|
-
|
|
286
|
+
"Folded lines": "折り畳まれた行",
|
|
287
|
+
"Unfolded lines": "折り畳める行",
|
|
288
|
+
to: "行き先",
|
|
289
|
+
"folded code": "折り畳まれたコード",
|
|
290
|
+
unfold: "折り畳みを解除",
|
|
291
|
+
"Fold line": "行を折り畳む",
|
|
292
|
+
"Unfold line": "行の折り畳む解除",
|
|
291
293
|
// @codemirror/search
|
|
292
|
-
|
|
293
|
-
go:
|
|
294
|
-
Find:
|
|
295
|
-
Replace:
|
|
296
|
-
next:
|
|
297
|
-
previous:
|
|
298
|
-
all:
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
regexp:
|
|
302
|
-
replace:
|
|
303
|
-
|
|
304
|
-
close:
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
294
|
+
"Go to line": "行き先の行",
|
|
295
|
+
go: "OK",
|
|
296
|
+
Find: "検索",
|
|
297
|
+
Replace: "置き換え",
|
|
298
|
+
next: "▼",
|
|
299
|
+
previous: "▲",
|
|
300
|
+
all: "すべて",
|
|
301
|
+
"match case": "一致条件",
|
|
302
|
+
"by word": "全文検索",
|
|
303
|
+
regexp: "正規表現",
|
|
304
|
+
replace: "置き換え",
|
|
305
|
+
"replace all": "すべてを置き換え",
|
|
306
|
+
close: "閉じる",
|
|
307
|
+
"current match": "現在の一致",
|
|
308
|
+
"replaced $ matches": "$ 件の一致を置き換え",
|
|
309
|
+
"replaced match on line $": "$ 行の一致を置き換え",
|
|
310
|
+
"on line": "した行",
|
|
309
311
|
// @codemirror/autocomplete
|
|
310
|
-
Completions:
|
|
312
|
+
Completions: "自動補完",
|
|
311
313
|
// @codemirror/lint
|
|
312
|
-
Diagnostics:
|
|
313
|
-
|
|
314
|
+
Diagnostics: "エラー",
|
|
315
|
+
"No diagnostics": "エラーなし",
|
|
314
316
|
};
|
|
315
317
|
</script>
|
|
316
318
|
|
|
@@ -338,8 +340,8 @@ const phrases: Record<string, string> = {
|
|
|
338
340
|
|
|
339
341
|
```vue
|
|
340
342
|
<script setup lang="ts">
|
|
341
|
-
import { ref, onMounted, type Ref, type PropType } from
|
|
342
|
-
import CodeMirror from
|
|
343
|
+
import { ref, onMounted, type Ref, type PropType } from "vue";
|
|
344
|
+
import CodeMirror from "vue-codemirror6";
|
|
343
345
|
|
|
344
346
|
const cm: Ref<InstanceType<typeof CodeMirror> | undefined> = ref();
|
|
345
347
|
|
|
@@ -396,12 +398,12 @@ const config: UserConfig = {
|
|
|
396
398
|
output: {
|
|
397
399
|
manualChunks: {
|
|
398
400
|
// ...
|
|
399
|
-
codemirror: [
|
|
400
|
-
|
|
401
|
+
codemirror: ["vue-codemirror6"],
|
|
402
|
+
"codemirror-lang": [
|
|
401
403
|
// 必要に応じて以下を追加してください。
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
404
|
+
"@codemirror/lang-html",
|
|
405
|
+
"@codemirror/lang-javascript",
|
|
406
|
+
"@codemirror/lang-markdown",
|
|
405
407
|
],
|
|
406
408
|
// ...
|
|
407
409
|
},
|
|
@@ -443,11 +445,3 @@ pnpm test:coverage
|
|
|
443
445
|
|
|
444
446
|
©2022-2026 by Logue.
|
|
445
447
|
[MITライセンス](LICENSE)の下でライセンスされています。
|
|
446
|
-
|
|
447
|
-
## 🎨 開発者のために作られました
|
|
448
|
-
|
|
449
|
-
このライブラリは、**最新の開発者体験**に焦点を当てて構築されています。これを維持するには、すべてがシームレスに動作することを確認するための継続的なテストと更新が必要です。
|
|
450
|
-
|
|
451
|
-
このプロジェクトの細部へのこだわりを評価していただける場合は、Vue.jsとMetaverseエコシステム全体での私の仕事をサポートするために、小額のスポンサーシップをいただければ幸いです。
|
|
452
|
-
|
|
453
|
-
[](https://github.com/sponsors/logue)
|
package/README.md
CHANGED
|
@@ -6,12 +6,13 @@ English | [日本語](README.ja.md)
|
|
|
6
6
|
<img src="https://user-images.githubusercontent.com/480173/224358008-6ffad05d-1d97-4c18-8554-7d41b03f88ab.png" alt="logo" width="300" height="300" />
|
|
7
7
|
</p>
|
|
8
8
|
|
|
9
|
-
[](https://www.jsdelivr.com/package/npm/vue-codemirror6)
|
|
10
|
-
[](https://www.npmjs.com/package/vue-codemirror6)
|
|
11
|
-
[](https://uiwjs.github.io/npm-unpkg/#/pkg/vue-codemirror6/file/README.md)
|
|
12
9
|
[](https://www.npmjs.com/package/vue-codemirror6)
|
|
10
|
+
[](https://www.npmjs.com/package/vue-codemirror6)
|
|
11
|
+
[](https://www.jsdelivr.com/package/npm/vue-codemirror6)
|
|
12
|
+
[](https://uiwjs.github.io/npm-unpkg/#/pkg/@logue/vue-codemirror6/file/README.md)
|
|
13
13
|
[](https://gitpod.io/#https://github.com/logue/vue-codemirror6)
|
|
14
|
-
[](https://x.com/logue256)
|
|
15
|
+
[](https://github.com/sponsors/logue)
|
|
15
16
|
|
|
16
17
|
A component for using [CodeMirror6](https://codemirror.net/6/) with Vue. This component works in both Vue2 and Vue3.
|
|
17
18
|
|
|
@@ -151,16 +152,16 @@ Mark up as follows to make it work at a minimum.
|
|
|
151
152
|
</template>
|
|
152
153
|
|
|
153
154
|
<script>
|
|
154
|
-
import { ref, defineComponent } from
|
|
155
|
+
import { ref, defineComponent } from "vue";
|
|
155
156
|
|
|
156
|
-
import CodeMirror from
|
|
157
|
+
import CodeMirror from "vue-codemirror6";
|
|
157
158
|
|
|
158
159
|
export default defineComponent({
|
|
159
160
|
components: {
|
|
160
161
|
CodeMirror,
|
|
161
162
|
},
|
|
162
163
|
setup() {
|
|
163
|
-
const value = ref(
|
|
164
|
+
const value = ref("Cozy lummox gives smart squid who asks for job pen.");
|
|
164
165
|
|
|
165
166
|
return { value };
|
|
166
167
|
},
|
|
@@ -180,16 +181,17 @@ Also, insert a `<pre>` tag to prevent the text in the slot from being automatica
|
|
|
180
181
|
<pre>
|
|
181
182
|
{
|
|
182
183
|
"key": "value"
|
|
183
|
-
}</pre
|
|
184
|
+
}</pre
|
|
185
|
+
>
|
|
184
186
|
</code-mirror>
|
|
185
187
|
</template>
|
|
186
188
|
|
|
187
189
|
<script>
|
|
188
|
-
import { ref, defineComponent } from
|
|
190
|
+
import { ref, defineComponent } from "vue";
|
|
189
191
|
|
|
190
|
-
import { json, jsonParseLinter } from
|
|
192
|
+
import { json, jsonParseLinter } from "@codemirror/lang-json";
|
|
191
193
|
|
|
192
|
-
import CodeMirror from
|
|
194
|
+
import CodeMirror from "vue-codemirror6";
|
|
193
195
|
|
|
194
196
|
export default defineComponent({
|
|
195
197
|
components: {
|
|
@@ -215,10 +217,10 @@ If you're using Nuxt 3, you can use the component directly:
|
|
|
215
217
|
<code-mirror v-model="value" :lang="lang" />
|
|
216
218
|
</template>
|
|
217
219
|
|
|
218
|
-
<script
|
|
219
|
-
import { ref } from
|
|
220
|
-
import CodeMirror from
|
|
221
|
-
import { javascript } from
|
|
220
|
+
<script lang="ts" setup vapor>
|
|
221
|
+
import { ref } from "vue";
|
|
222
|
+
import CodeMirror from "vue-codemirror6";
|
|
223
|
+
import { javascript } from "@codemirror/lang-javascript";
|
|
222
224
|
|
|
223
225
|
const value = ref('console.log("Hello, World!");');
|
|
224
226
|
const lang = javascript();
|
|
@@ -240,24 +242,24 @@ For Nuxt 2 or if you encounter any issues, you can wrap the component with `<Cli
|
|
|
240
242
|
When using as a Markdown editor on [vite-vue3-ts-starter](https://github.com/logue/vite-vue3-ts-starter).
|
|
241
243
|
|
|
242
244
|
```vue
|
|
243
|
-
<script lang="ts" setup>
|
|
244
|
-
import { ref, defineComponent, type Ref } from
|
|
245
|
+
<script lang="ts" setup vapor>
|
|
246
|
+
import { ref, defineComponent, type Ref } from "vue";
|
|
245
247
|
|
|
246
248
|
// Load component
|
|
247
|
-
import CodeMirror from
|
|
249
|
+
import CodeMirror from "vue-codemirror6";
|
|
248
250
|
|
|
249
251
|
// CodeMirror extensions
|
|
250
|
-
import { markdown as md } from
|
|
251
|
-
import type { LanguageSupport } from
|
|
252
|
-
import type { Extension } from
|
|
253
|
-
import type { ViewUpdate } from
|
|
252
|
+
import { markdown as md } from "@codemirror/lang-markdown";
|
|
253
|
+
import type { LanguageSupport } from "@codemirror/language";
|
|
254
|
+
import type { Extension } from "@codemirror/state";
|
|
255
|
+
import type { ViewUpdate } from "@codemirror/view";
|
|
254
256
|
|
|
255
257
|
/** text */
|
|
256
|
-
const value: Ref<string> = ref(
|
|
258
|
+
const value: Ref<string> = ref("");
|
|
257
259
|
|
|
258
260
|
/** Dark mode **/
|
|
259
261
|
const dark: Ref<boolean> = ref(
|
|
260
|
-
window.matchMedia(
|
|
262
|
+
window.matchMedia("(prefers-color-scheme: dark)").matches,
|
|
261
263
|
);
|
|
262
264
|
|
|
263
265
|
/**
|
|
@@ -276,40 +278,40 @@ const lang: LanguageSupport = md();
|
|
|
276
278
|
*/
|
|
277
279
|
const phrases: Record<string, string> = {
|
|
278
280
|
// @codemirror/view
|
|
279
|
-
|
|
281
|
+
"Control character": "制御文字",
|
|
280
282
|
// @codemirror/commands
|
|
281
|
-
|
|
283
|
+
"Selection deleted": "選択を削除",
|
|
282
284
|
// @codemirror/language
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
to:
|
|
286
|
-
|
|
287
|
-
unfold:
|
|
288
|
-
|
|
289
|
-
|
|
285
|
+
"Folded lines": "折り畳まれた行",
|
|
286
|
+
"Unfolded lines": "折り畳める行",
|
|
287
|
+
to: "行き先",
|
|
288
|
+
"folded code": "折り畳まれたコード",
|
|
289
|
+
unfold: "折り畳みを解除",
|
|
290
|
+
"Fold line": "行を折り畳む",
|
|
291
|
+
"Unfold line": "行の折り畳む解除",
|
|
290
292
|
// @codemirror/search
|
|
291
|
-
|
|
292
|
-
go:
|
|
293
|
-
Find:
|
|
294
|
-
Replace:
|
|
295
|
-
next:
|
|
296
|
-
previous:
|
|
297
|
-
all:
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
regexp:
|
|
301
|
-
replace:
|
|
302
|
-
|
|
303
|
-
close:
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
293
|
+
"Go to line": "行き先の行",
|
|
294
|
+
go: "OK",
|
|
295
|
+
Find: "検索",
|
|
296
|
+
Replace: "置き換え",
|
|
297
|
+
next: "▼",
|
|
298
|
+
previous: "▲",
|
|
299
|
+
all: "すべて",
|
|
300
|
+
"match case": "一致条件",
|
|
301
|
+
"by word": "全文検索",
|
|
302
|
+
regexp: "正規表現",
|
|
303
|
+
replace: "置き換え",
|
|
304
|
+
"replace all": "すべてを置き換え",
|
|
305
|
+
close: "閉じる",
|
|
306
|
+
"current match": "現在の一致",
|
|
307
|
+
"replaced $ matches": "$ 件の一致を置き換え",
|
|
308
|
+
"replaced match on line $": "$ 行の一致を置き換え",
|
|
309
|
+
"on line": "した行",
|
|
308
310
|
// @codemirror/autocomplete
|
|
309
|
-
Completions:
|
|
311
|
+
Completions: "自動補完",
|
|
310
312
|
// @codemirror/lint
|
|
311
|
-
Diagnostics:
|
|
312
|
-
|
|
313
|
+
Diagnostics: "エラー",
|
|
314
|
+
"No diagnostics": "エラーなし",
|
|
313
315
|
};
|
|
314
316
|
</script>
|
|
315
317
|
|
|
@@ -336,9 +338,9 @@ const phrases: Record<string, string> = {
|
|
|
336
338
|
## Parameter / Function
|
|
337
339
|
|
|
338
340
|
```vue
|
|
339
|
-
<script
|
|
340
|
-
import { ref, onMounted, type Ref, type PropType } from
|
|
341
|
-
import CodeMirror from
|
|
341
|
+
<script lang="ts" setup vapor>
|
|
342
|
+
import { ref, onMounted, type Ref, type PropType } from "vue";
|
|
343
|
+
import CodeMirror from "vue-codemirror6";
|
|
342
344
|
|
|
343
345
|
const cm: Ref<InstanceType<typeof CodeMirror> | undefined> = ref();
|
|
344
346
|
|
|
@@ -383,6 +385,20 @@ Since the above method is usually sufficient, its **active use is not recommende
|
|
|
383
385
|
| setSelections(ranges: readonly SelectionRange[], primary?: number) | Sets a new set of selections. |
|
|
384
386
|
| extendSelectionsBy(f: Function) | Applies the given function to all existing selections, and calls extendSelections on the result. |
|
|
385
387
|
|
|
388
|
+
## WebComponents Feature (Experimental)
|
|
389
|
+
|
|
390
|
+
By importing it with CodeMirror, it can also be used as a Web Component.
|
|
391
|
+
|
|
392
|
+
```js
|
|
393
|
+
import { CodeMirror } from "vue-codemirror6";
|
|
394
|
+
|
|
395
|
+
customElements.define("code-mirror", CodeMirror);
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
```html
|
|
399
|
+
<code-mirror></code-mirror>
|
|
400
|
+
```
|
|
401
|
+
|
|
386
402
|
## Recommendations
|
|
387
403
|
|
|
388
404
|
Since CodeMirror has a relatively large capacity, when using [vite](https://vitejs.dev), it is recommended to set it to output as a separate file using the [`manualChunks`](https://vitejs.dev/guide/build.html#chunking-strategy) option at build time as shown below.
|
|
@@ -395,12 +411,12 @@ const config: UserConfig = {
|
|
|
395
411
|
output: {
|
|
396
412
|
manualChunks: {
|
|
397
413
|
// ...
|
|
398
|
-
codemirror: [
|
|
399
|
-
|
|
414
|
+
codemirror: ["vue-codemirror6"],
|
|
415
|
+
"codemirror-lang": [
|
|
400
416
|
// Add the following as needed.
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
417
|
+
"@codemirror/lang-html",
|
|
418
|
+
"@codemirror/lang-javascript",
|
|
419
|
+
"@codemirror/lang-markdown",
|
|
404
420
|
],
|
|
405
421
|
// ...
|
|
406
422
|
},
|
|
@@ -442,11 +458,3 @@ The test suite includes:
|
|
|
442
458
|
|
|
443
459
|
©2022-2026 by Logue.
|
|
444
460
|
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
|
-
[](https://github.com/sponsors/logue)
|