vue-codemirror6 1.3.17 → 1.3.20

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,12 +4,12 @@ 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.3.17](https://github.com/logue/vue-codemirror6/compare/1.3.13...1.3.17)
7
+ #### [1.3.20](https://github.com/logue/vue-codemirror6/compare/1.3.13...1.3.20)
8
8
 
9
9
  - fix: full example link [`#58`](https://github.com/logue/vue-codemirror6/pull/58)
10
10
  - Update dependencies. [`985f36f`](https://github.com/logue/vue-codemirror6/commit/985f36f23c4fc1b562b53b664deb7ff1eec79989)
11
+ - Update vue, codemirror. [`bfbd153`](https://github.com/logue/vue-codemirror6/commit/bfbd153eeec6c718b95bb719117ad5a02dcf6a37)
11
12
  - Removed unnecessary comment. [`8d624a4`](https://github.com/logue/vue-codemirror6/commit/8d624a46cebc0f9196e5987f793e90184332ae4b)
12
- - Fixed typo. [`b39f9cb`](https://github.com/logue/vue-codemirror6/commit/b39f9cb0993708338f0a96429b4cdc2fd510208e)
13
13
 
14
14
  #### [1.3.13](https://github.com/logue/vue-codemirror6/compare/1.3.8...1.3.13)
15
15
 
package/README.md CHANGED
@@ -56,6 +56,7 @@ This component can handle bidirectional binding by `v-model` like a general Vue
56
56
  | gutterConfig | Object | see <https://codemirror.net/docs/ref/#lint.lintGutter^config> |
57
57
  | tag | string | HTML tags used in the component. (Default is `div` tag.) |
58
58
  | scrollIntoView | boolean | Allows an external update to scroll the form. (Default is `true`) |
59
+ | keymap | KeyBinding[] | Key bindings associate key names with command-style functions. See <https://codemirror.net/docs/ref/#view.KeyBinding> |
59
60
 
60
61
  ⚠ Notice: `lang` and `linter` can also be set together in `extensions`. These are separated for compatibility with previous versions of CodeMirror settings and for typing props.
61
62
 
@@ -1,7 +1,7 @@
1
1
  import { LanguageSupport } from '@codemirror/language';
2
2
  import { LintSource } from '@codemirror/lint';
3
3
  import { EditorSelection, EditorState, Extension, SelectionRange, StateField, Text } from '@codemirror/state';
4
- import { EditorView, ViewUpdate } from '@codemirror/view';
4
+ import { EditorView, KeyBinding, ViewUpdate } from '@codemirror/view';
5
5
  import { PropType, Ref, ShallowRef, WritableComputedRef } from 'vue-demi';
6
6
  import { StyleSpec } from 'style-mod';
7
7
  /** CodeMirror Component */
@@ -74,6 +74,10 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
74
74
  };
75
75
  /**
76
76
  * Tab character
77
+ * This is the unit of indentation used when the editor is configured to indent with tabs.
78
+ * It is also used to determine the size of the tab character when the editor is configured to use tabs for indentation..
79
+ *
80
+ * @see {@link https://codemirror.net/docs/ref/#state.EditorState^indentUnit}
77
81
  */
78
82
  indentUnit: {
79
83
  type: StringConstructor;
@@ -81,6 +85,10 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
81
85
  };
82
86
  /**
83
87
  * Allow Multiple Selection.
88
+ * This allows the editor to have multiple selections at the same time.
89
+ * This is useful for editing multiple parts of the document at once.
90
+ * If this is set to true, the editor will allow multiple selections.
91
+ * If this is set to false, the editor will only allow a single selection.
84
92
  *
85
93
  * @see {@link https://codemirror.net/docs/ref/#state.EditorState^allowMultipleSelections}
86
94
  */
@@ -90,6 +98,9 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
90
98
  };
91
99
  /**
92
100
  * Tab size
101
+ * This is the number of spaces that a tab character represents in the editor.
102
+ * It is used to determine the size of the tab character when the editor is configured to use tabs for indentation.
103
+ * If this is set to a number, the editor will use that number of spaces for each tab character.
93
104
  *
94
105
  * @see {@link https://codemirror.net/docs/ref/#state.EditorState^tabSize}
95
106
  */
@@ -100,6 +111,9 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
100
111
  /**
101
112
  * Set line break (separetor) char.
102
113
  *
114
+ * This is the character that is used to separate lines in the editor.
115
+ * It is used to determine the line break character when the editor is configured to use a specific line break character.
116
+ *
103
117
  * @see {@link https://codemirror.net/docs/ref/#state.EditorState^lineSeparator}
104
118
  */
105
119
  lineSeparator: {
@@ -109,6 +123,11 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
109
123
  /**
110
124
  * Readonly
111
125
  *
126
+ * This is a CodeMirror Facet that allows you to set the editor to read-only mode.
127
+ * When this is set to true, the editor will not allow any changes to be made to the document.
128
+ * This is useful for displaying code that should not be edited, such as documentation or examples.
129
+ * If this is set to false, the editor will allow changes to be made to the document.
130
+ *
112
131
  * @see {@link https://codemirror.net/docs/ref/#state.EditorState^readOnly}
113
132
  */
114
133
  readonly: {
@@ -130,6 +149,8 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
130
149
  /**
131
150
  * Additional Extension
132
151
  *
152
+ * You can use this to add any additional extensions that you want to use in the editor.
153
+ *
133
154
  * @see {@link https://codemirror.net/docs/ref/#state.Extension}
134
155
  */
135
156
  extensions: {
@@ -139,6 +160,10 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
139
160
  /**
140
161
  * Language Phreses
141
162
  *
163
+ * This is a CodeMirror Facet that allows you to define custom phrases for the editor.
164
+ * It can be used to override default phrases or add new ones.
165
+ * This is useful for translating the editor to different languages or for customizing the editor's UI.
166
+ *
142
167
  * @see {@link https://codemirror.net/examples/translate/}
143
168
  */
144
169
  phrases: {
@@ -148,6 +173,10 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
148
173
  /**
149
174
  * CodeMirror Language
150
175
  *
176
+ * This is a CodeMirror Facet that allows you to define the language of the editor.
177
+ * It can be used to enable syntax highlighting and other language-specific features.
178
+ * It is useful for displaying code in a specific language, such as JavaScript, Python, or HTML.
179
+ *
151
180
  * @see {@link https://codemirror.net/docs/ref/#language}
152
181
  */
153
182
  lang: {
@@ -157,6 +186,11 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
157
186
  /**
158
187
  * CodeMirror Linter
159
188
  *
189
+ * This is a CodeMirror Facet that allows you to define a linter for the editor.
190
+ * It can be used to check the code for errors and warnings, and to provide feedback to the user.
191
+ * It is useful for displaying code in a specific language, such as JavaScript, Python, or HTML.
192
+ * This is useful for providing feedback to the user about the code they are writing.
193
+ *
160
194
  * @see {@link https://codemirror.net/docs/ref/#lint.linter}
161
195
  */
162
196
  linter: {
@@ -166,6 +200,10 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
166
200
  /**
167
201
  * Linter Config
168
202
  *
203
+ * This is a CodeMirror Facet that allows you to define the configuration for the linter.
204
+ * It can be used to specify options for the linter, such as the severity of errors and warnings, and to customize the behavior of the linter.
205
+ * This is useful for providing feedback to the user about the code they are writing.
206
+ *
169
207
  * @see {@link https://codemirror.net/docs/ref/#lint.linter^config}
170
208
  */
171
209
  linterConfig: {
@@ -175,6 +213,8 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
175
213
  /**
176
214
  * Forces any linters configured to run when the editor is idle to run right away.
177
215
  *
216
+ * This is useful for running linters on the initial load of the editor, or when the user has made changes to the code and wants to see the results immediately.
217
+ *
178
218
  * @see {@link https://codemirror.net/docs/ref/#lint.forceLinting}
179
219
  */
180
220
  forceLinting: {
@@ -196,6 +236,10 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
196
236
  /**
197
237
  * Gutter Config
198
238
  *
239
+ * This is a CodeMirror Facet that allows you to define the configuration for the gutter.
240
+ * It can be used to specify options for the gutter, such as the size of the gutter, the position of the gutter, and to customize the behavior of the gutter.
241
+ * This is useful for providing feedback to the user about the code they are writing.
242
+ *
199
243
  * @see {@link https://codemirror.net/docs/ref/#lint.lintGutter^config}
200
244
  */
201
245
  gutterConfig: {
@@ -211,12 +255,28 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
211
255
  };
212
256
  /**
213
257
  * Allows an external update to scroll the form.
258
+ *
259
+ * This is useful for scrolling the editor to a specific position when the user has made changes to the code and wants to see the results immediately.
260
+ * If this is set to true, the editor will scroll to the position specified in the transaction.
261
+ * If this is set to false, the editor will not scroll to the position specified in the transaction.
262
+ *
214
263
  * @see {@link https://codemirror.net/docs/ref/#state.TransactionSpec.scrollIntoView}
215
264
  */
216
265
  scrollIntoView: {
217
266
  type: BooleanConstructor;
218
267
  default: boolean;
219
268
  };
269
+ /**
270
+ * Key map
271
+ * This is a CodeMirror Facet that allows you to define custom key bindings.
272
+ * It can be used to override default key bindings or add new ones.
273
+ *
274
+ * @see {@link https://codemirror.net/docs/ref/#view.keymap}
275
+ */
276
+ keymap: {
277
+ type: PropType<KeyBinding[]>;
278
+ default: () => never[];
279
+ };
220
280
  }>, {
221
281
  editor: Ref<HTMLElement | undefined, HTMLElement | undefined>;
222
282
  view: ShallowRef<EditorView>;
@@ -329,6 +389,10 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
329
389
  };
330
390
  /**
331
391
  * Tab character
392
+ * This is the unit of indentation used when the editor is configured to indent with tabs.
393
+ * It is also used to determine the size of the tab character when the editor is configured to use tabs for indentation..
394
+ *
395
+ * @see {@link https://codemirror.net/docs/ref/#state.EditorState^indentUnit}
332
396
  */
333
397
  indentUnit: {
334
398
  type: StringConstructor;
@@ -336,6 +400,10 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
336
400
  };
337
401
  /**
338
402
  * Allow Multiple Selection.
403
+ * This allows the editor to have multiple selections at the same time.
404
+ * This is useful for editing multiple parts of the document at once.
405
+ * If this is set to true, the editor will allow multiple selections.
406
+ * If this is set to false, the editor will only allow a single selection.
339
407
  *
340
408
  * @see {@link https://codemirror.net/docs/ref/#state.EditorState^allowMultipleSelections}
341
409
  */
@@ -345,6 +413,9 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
345
413
  };
346
414
  /**
347
415
  * Tab size
416
+ * This is the number of spaces that a tab character represents in the editor.
417
+ * It is used to determine the size of the tab character when the editor is configured to use tabs for indentation.
418
+ * If this is set to a number, the editor will use that number of spaces for each tab character.
348
419
  *
349
420
  * @see {@link https://codemirror.net/docs/ref/#state.EditorState^tabSize}
350
421
  */
@@ -355,6 +426,9 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
355
426
  /**
356
427
  * Set line break (separetor) char.
357
428
  *
429
+ * This is the character that is used to separate lines in the editor.
430
+ * It is used to determine the line break character when the editor is configured to use a specific line break character.
431
+ *
358
432
  * @see {@link https://codemirror.net/docs/ref/#state.EditorState^lineSeparator}
359
433
  */
360
434
  lineSeparator: {
@@ -364,6 +438,11 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
364
438
  /**
365
439
  * Readonly
366
440
  *
441
+ * This is a CodeMirror Facet that allows you to set the editor to read-only mode.
442
+ * When this is set to true, the editor will not allow any changes to be made to the document.
443
+ * This is useful for displaying code that should not be edited, such as documentation or examples.
444
+ * If this is set to false, the editor will allow changes to be made to the document.
445
+ *
367
446
  * @see {@link https://codemirror.net/docs/ref/#state.EditorState^readOnly}
368
447
  */
369
448
  readonly: {
@@ -385,6 +464,8 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
385
464
  /**
386
465
  * Additional Extension
387
466
  *
467
+ * You can use this to add any additional extensions that you want to use in the editor.
468
+ *
388
469
  * @see {@link https://codemirror.net/docs/ref/#state.Extension}
389
470
  */
390
471
  extensions: {
@@ -394,6 +475,10 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
394
475
  /**
395
476
  * Language Phreses
396
477
  *
478
+ * This is a CodeMirror Facet that allows you to define custom phrases for the editor.
479
+ * It can be used to override default phrases or add new ones.
480
+ * This is useful for translating the editor to different languages or for customizing the editor's UI.
481
+ *
397
482
  * @see {@link https://codemirror.net/examples/translate/}
398
483
  */
399
484
  phrases: {
@@ -403,6 +488,10 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
403
488
  /**
404
489
  * CodeMirror Language
405
490
  *
491
+ * This is a CodeMirror Facet that allows you to define the language of the editor.
492
+ * It can be used to enable syntax highlighting and other language-specific features.
493
+ * It is useful for displaying code in a specific language, such as JavaScript, Python, or HTML.
494
+ *
406
495
  * @see {@link https://codemirror.net/docs/ref/#language}
407
496
  */
408
497
  lang: {
@@ -412,6 +501,11 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
412
501
  /**
413
502
  * CodeMirror Linter
414
503
  *
504
+ * This is a CodeMirror Facet that allows you to define a linter for the editor.
505
+ * It can be used to check the code for errors and warnings, and to provide feedback to the user.
506
+ * It is useful for displaying code in a specific language, such as JavaScript, Python, or HTML.
507
+ * This is useful for providing feedback to the user about the code they are writing.
508
+ *
415
509
  * @see {@link https://codemirror.net/docs/ref/#lint.linter}
416
510
  */
417
511
  linter: {
@@ -421,6 +515,10 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
421
515
  /**
422
516
  * Linter Config
423
517
  *
518
+ * This is a CodeMirror Facet that allows you to define the configuration for the linter.
519
+ * It can be used to specify options for the linter, such as the severity of errors and warnings, and to customize the behavior of the linter.
520
+ * This is useful for providing feedback to the user about the code they are writing.
521
+ *
424
522
  * @see {@link https://codemirror.net/docs/ref/#lint.linter^config}
425
523
  */
426
524
  linterConfig: {
@@ -430,6 +528,8 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
430
528
  /**
431
529
  * Forces any linters configured to run when the editor is idle to run right away.
432
530
  *
531
+ * This is useful for running linters on the initial load of the editor, or when the user has made changes to the code and wants to see the results immediately.
532
+ *
433
533
  * @see {@link https://codemirror.net/docs/ref/#lint.forceLinting}
434
534
  */
435
535
  forceLinting: {
@@ -451,6 +551,10 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
451
551
  /**
452
552
  * Gutter Config
453
553
  *
554
+ * This is a CodeMirror Facet that allows you to define the configuration for the gutter.
555
+ * It can be used to specify options for the gutter, such as the size of the gutter, the position of the gutter, and to customize the behavior of the gutter.
556
+ * This is useful for providing feedback to the user about the code they are writing.
557
+ *
454
558
  * @see {@link https://codemirror.net/docs/ref/#lint.lintGutter^config}
455
559
  */
456
560
  gutterConfig: {
@@ -466,12 +570,28 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
466
570
  };
467
571
  /**
468
572
  * Allows an external update to scroll the form.
573
+ *
574
+ * This is useful for scrolling the editor to a specific position when the user has made changes to the code and wants to see the results immediately.
575
+ * If this is set to true, the editor will scroll to the position specified in the transaction.
576
+ * If this is set to false, the editor will not scroll to the position specified in the transaction.
577
+ *
469
578
  * @see {@link https://codemirror.net/docs/ref/#state.TransactionSpec.scrollIntoView}
470
579
  */
471
580
  scrollIntoView: {
472
581
  type: BooleanConstructor;
473
582
  default: boolean;
474
583
  };
584
+ /**
585
+ * Key map
586
+ * This is a CodeMirror Facet that allows you to define custom key bindings.
587
+ * It can be used to override default key bindings or add new ones.
588
+ *
589
+ * @see {@link https://codemirror.net/docs/ref/#view.keymap}
590
+ */
591
+ keymap: {
592
+ type: PropType<KeyBinding[]>;
593
+ default: () => never[];
594
+ };
475
595
  }>> & Readonly<{
476
596
  onChange?: ((_value: EditorState) => any) | undefined;
477
597
  onFocus?: ((_value: boolean) => any) | undefined;
@@ -508,5 +628,6 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
508
628
  gutterConfig: Record<string, any>;
509
629
  tag: string;
510
630
  scrollIntoView: boolean;
631
+ keymap: KeyBinding[];
511
632
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
512
633
  export default _default;
package/dist/index.es.js CHANGED
@@ -5,33 +5,33 @@
5
5
  * @author Logue <logue@hotmail.co.jp>
6
6
  * @copyright 2022-2025 By Masashi Yoshikawa All rights reserved.
7
7
  * @license MIT
8
- * @version 1.3.17
8
+ * @version 1.3.20
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 b, diagnosticCount as k } from "@codemirror/lint";
15
- import { EditorState as s, Compartment as w, StateEffect as y, EditorSelection as C } from "@codemirror/state";
16
- import { EditorView as r, keymap as q, placeholder as H } from "@codemirror/view";
17
- import { basicSetup as K, minimalSetup as Q } from "codemirror";
18
- import { isVue2 as X, h as O, defineComponent as Y, ref as v, shallowRef as ee, computed as c, watch as V, onMounted as te, nextTick as ae, onUnmounted as ne } from "vue-demi";
19
- const me = {
20
- version: "1.3.17",
21
- date: "2025-06-02T14:16:10.878Z"
22
- }, le = (e) => e ? Object.entries(e).reduce((i, [l, u]) => (l = l.charAt(0).toUpperCase() + l.slice(1), l = `on${l}`, { ...i, [l]: u }), {}) : {};
23
- function B(e, i = {}, l) {
24
- if (X)
25
- return O(e, i, l);
26
- const { props: u, domProps: t, on: d, ...f } = i, m = d ? le(d) : {};
27
- return O(
14
+ import { linter as P, lintGutter as Z, forceLinting as w, diagnosticCount as q } from "@codemirror/lint";
15
+ import { EditorState as s, Compartment as C, StateEffect as S, EditorSelection as O } from "@codemirror/state";
16
+ import { EditorView as c, placeholder as H, keymap as K } from "@codemirror/view";
17
+ import { basicSetup as Q, minimalSetup as X } from "codemirror";
18
+ import { isVue2 as Y, h as V, defineComponent as ee, ref as m, shallowRef as te, computed as d, watch as B, onMounted as ae, nextTick as ne, onUnmounted as le } from "vue-demi";
19
+ const he = {
20
+ version: "1.3.20",
21
+ date: "2025-06-20T15:57:15.852Z"
22
+ }, ie = (e) => e ? Object.entries(e).reduce((i, [l, u]) => (l = l.charAt(0).toUpperCase() + l.slice(1), l = `on${l}`, { ...i, [l]: u }), {}) : {};
23
+ function M(e, i = {}, l) {
24
+ if (Y)
25
+ return V(e, i, l);
26
+ const { props: u, domProps: t, on: f, ...v } = i, h = f ? ie(f) : {};
27
+ return V(
28
28
  e,
29
- { ...f, ...u, ...t, ...m },
29
+ { ...v, ...u, ...t, ...h },
30
30
  l
31
31
  );
32
32
  }
33
- const ie = (e) => typeof e == "function" ? e() : e;
34
- var oe = Y({
33
+ const oe = (e) => typeof e == "function" ? e() : e;
34
+ var se = ee({
35
35
  /** Component Name */
36
36
  name: "CodeMirror",
37
37
  /** Model Definition */
@@ -109,6 +109,10 @@ var oe = Y({
109
109
  },
110
110
  /**
111
111
  * Tab character
112
+ * This is the unit of indentation used when the editor is configured to indent with tabs.
113
+ * It is also used to determine the size of the tab character when the editor is configured to use tabs for indentation..
114
+ *
115
+ * @see {@link https://codemirror.net/docs/ref/#state.EditorState^indentUnit}
112
116
  */
113
117
  indentUnit: {
114
118
  type: String,
@@ -116,6 +120,10 @@ var oe = Y({
116
120
  },
117
121
  /**
118
122
  * Allow Multiple Selection.
123
+ * This allows the editor to have multiple selections at the same time.
124
+ * This is useful for editing multiple parts of the document at once.
125
+ * If this is set to true, the editor will allow multiple selections.
126
+ * If this is set to false, the editor will only allow a single selection.
119
127
  *
120
128
  * @see {@link https://codemirror.net/docs/ref/#state.EditorState^allowMultipleSelections}
121
129
  */
@@ -125,6 +133,9 @@ var oe = Y({
125
133
  },
126
134
  /**
127
135
  * Tab size
136
+ * This is the number of spaces that a tab character represents in the editor.
137
+ * It is used to determine the size of the tab character when the editor is configured to use tabs for indentation.
138
+ * If this is set to a number, the editor will use that number of spaces for each tab character.
128
139
  *
129
140
  * @see {@link https://codemirror.net/docs/ref/#state.EditorState^tabSize}
130
141
  */
@@ -135,6 +146,9 @@ var oe = Y({
135
146
  /**
136
147
  * Set line break (separetor) char.
137
148
  *
149
+ * This is the character that is used to separate lines in the editor.
150
+ * It is used to determine the line break character when the editor is configured to use a specific line break character.
151
+ *
138
152
  * @see {@link https://codemirror.net/docs/ref/#state.EditorState^lineSeparator}
139
153
  */
140
154
  lineSeparator: {
@@ -144,6 +158,11 @@ var oe = Y({
144
158
  /**
145
159
  * Readonly
146
160
  *
161
+ * This is a CodeMirror Facet that allows you to set the editor to read-only mode.
162
+ * When this is set to true, the editor will not allow any changes to be made to the document.
163
+ * This is useful for displaying code that should not be edited, such as documentation or examples.
164
+ * If this is set to false, the editor will allow changes to be made to the document.
165
+ *
147
166
  * @see {@link https://codemirror.net/docs/ref/#state.EditorState^readOnly}
148
167
  */
149
168
  readonly: {
@@ -165,6 +184,8 @@ var oe = Y({
165
184
  /**
166
185
  * Additional Extension
167
186
  *
187
+ * You can use this to add any additional extensions that you want to use in the editor.
188
+ *
168
189
  * @see {@link https://codemirror.net/docs/ref/#state.Extension}
169
190
  */
170
191
  extensions: {
@@ -174,6 +195,10 @@ var oe = Y({
174
195
  /**
175
196
  * Language Phreses
176
197
  *
198
+ * This is a CodeMirror Facet that allows you to define custom phrases for the editor.
199
+ * It can be used to override default phrases or add new ones.
200
+ * This is useful for translating the editor to different languages or for customizing the editor's UI.
201
+ *
177
202
  * @see {@link https://codemirror.net/examples/translate/}
178
203
  */
179
204
  phrases: {
@@ -183,6 +208,10 @@ var oe = Y({
183
208
  /**
184
209
  * CodeMirror Language
185
210
  *
211
+ * This is a CodeMirror Facet that allows you to define the language of the editor.
212
+ * It can be used to enable syntax highlighting and other language-specific features.
213
+ * It is useful for displaying code in a specific language, such as JavaScript, Python, or HTML.
214
+ *
186
215
  * @see {@link https://codemirror.net/docs/ref/#language}
187
216
  */
188
217
  lang: {
@@ -192,6 +221,11 @@ var oe = Y({
192
221
  /**
193
222
  * CodeMirror Linter
194
223
  *
224
+ * This is a CodeMirror Facet that allows you to define a linter for the editor.
225
+ * It can be used to check the code for errors and warnings, and to provide feedback to the user.
226
+ * It is useful for displaying code in a specific language, such as JavaScript, Python, or HTML.
227
+ * This is useful for providing feedback to the user about the code they are writing.
228
+ *
195
229
  * @see {@link https://codemirror.net/docs/ref/#lint.linter}
196
230
  */
197
231
  linter: {
@@ -201,6 +235,10 @@ var oe = Y({
201
235
  /**
202
236
  * Linter Config
203
237
  *
238
+ * This is a CodeMirror Facet that allows you to define the configuration for the linter.
239
+ * It can be used to specify options for the linter, such as the severity of errors and warnings, and to customize the behavior of the linter.
240
+ * This is useful for providing feedback to the user about the code they are writing.
241
+ *
204
242
  * @see {@link https://codemirror.net/docs/ref/#lint.linter^config}
205
243
  */
206
244
  linterConfig: {
@@ -210,6 +248,8 @@ var oe = Y({
210
248
  /**
211
249
  * Forces any linters configured to run when the editor is idle to run right away.
212
250
  *
251
+ * This is useful for running linters on the initial load of the editor, or when the user has made changes to the code and wants to see the results immediately.
252
+ *
213
253
  * @see {@link https://codemirror.net/docs/ref/#lint.forceLinting}
214
254
  */
215
255
  forceLinting: {
@@ -231,6 +271,10 @@ var oe = Y({
231
271
  /**
232
272
  * Gutter Config
233
273
  *
274
+ * This is a CodeMirror Facet that allows you to define the configuration for the gutter.
275
+ * It can be used to specify options for the gutter, such as the size of the gutter, the position of the gutter, and to customize the behavior of the gutter.
276
+ * This is useful for providing feedback to the user about the code they are writing.
277
+ *
234
278
  * @see {@link https://codemirror.net/docs/ref/#lint.lintGutter^config}
235
279
  */
236
280
  gutterConfig: {
@@ -246,11 +290,27 @@ var oe = Y({
246
290
  },
247
291
  /**
248
292
  * Allows an external update to scroll the form.
293
+ *
294
+ * This is useful for scrolling the editor to a specific position when the user has made changes to the code and wants to see the results immediately.
295
+ * If this is set to true, the editor will scroll to the position specified in the transaction.
296
+ * If this is set to false, the editor will not scroll to the position specified in the transaction.
297
+ *
249
298
  * @see {@link https://codemirror.net/docs/ref/#state.TransactionSpec.scrollIntoView}
250
299
  */
251
300
  scrollIntoView: {
252
301
  type: Boolean,
253
302
  default: !0
303
+ },
304
+ /**
305
+ * Key map
306
+ * This is a CodeMirror Facet that allows you to define custom key bindings.
307
+ * It can be used to override default key bindings or add new ones.
308
+ *
309
+ * @see {@link https://codemirror.net/docs/ref/#view.keymap}
310
+ */
311
+ keymap: {
312
+ type: Array,
313
+ default: () => []
254
314
  }
255
315
  },
256
316
  /** Emits */
@@ -275,43 +335,42 @@ var oe = Y({
275
335
  * @param context - Context
276
336
  */
277
337
  setup(e, i) {
278
- const l = v(), u = v(e.modelValue), t = ee(new r()), d = c({
338
+ const l = m(), u = m(e.modelValue), t = te(new c()), f = d({
279
339
  get: () => t.value.hasFocus,
280
340
  set: (a) => {
281
341
  a && t.value.focus();
282
342
  }
283
- }), f = c({
343
+ }), v = d({
284
344
  get: () => t.value.state.selection,
285
345
  set: (a) => t.value.dispatch({ selection: a })
286
- }), m = c({
346
+ }), h = d({
287
347
  get: () => t.value.state.selection.main.head,
288
348
  set: (a) => t.value.dispatch({ selection: { anchor: a } })
289
- }), M = c(
349
+ }), $ = d(
290
350
  {
291
351
  get: () => t.value.state.toJSON(),
292
352
  set: (a) => t.value.setState(s.fromJSON(a))
293
353
  }
294
- ), S = v(0), h = v(0), g = c(() => {
295
- const a = new w(), n = new w();
354
+ ), p = m(0), g = m(0), y = d(() => {
355
+ const a = new C(), n = new C();
296
356
  if (e.basic && e.minimal)
297
357
  throw new Error(
298
358
  "[Vue CodeMirror] Both basic and minimal cannot be specified."
299
359
  );
300
- return [
360
+ let o = [];
361
+ return e.keymap && e.keymap.length > 0 && (o = e.keymap), e.tab && o.push(W), [
301
362
  // Toggle basic setup
302
- e.basic && !e.minimal ? K : void 0,
363
+ e.basic && !e.minimal ? Q : void 0,
303
364
  // Toggle minimal setup
304
- e.minimal && !e.basic ? Q : void 0,
365
+ e.minimal && !e.basic ? X : void 0,
305
366
  // ViewUpdate event listener
306
- r.updateListener.of((o) => {
307
- i.emit("focus", t.value.hasFocus), S.value = t.value.state.doc?.length, !(o.changes.empty || !o.docChanged) && (e.linter && (e.forceLinting && b(t.value), h.value = e.linter(t.value).length), i.emit("update", o));
367
+ c.updateListener.of((r) => {
368
+ i.emit("focus", t.value.hasFocus), p.value = t.value.state.doc?.length, !(r.changes.empty || !r.docChanged) && (e.linter && (e.forceLinting && w(t.value), g.value = e.linter(t.value).length), i.emit("update", r));
308
369
  }),
309
370
  // Toggle light/dark mode.
310
- r.theme(e.theme, { dark: e.dark }),
371
+ c.theme(e.theme, { dark: e.dark }),
311
372
  // Toggle line wrapping
312
- e.wrap ? r.lineWrapping : void 0,
313
- // Indent with tab
314
- e.tab ? q.of([W]) : void 0,
373
+ e.wrap ? c.lineWrapping : void 0,
315
374
  // Tab character
316
375
  e.indentUnit ? G.of(e.indentUnit) : void 0,
317
376
  // Allow Multiple Selections
@@ -323,7 +382,7 @@ var oe = Y({
323
382
  // Readonly option
324
383
  s.readOnly.of(e.readonly),
325
384
  // Editable option
326
- r.editable.of(!e.disabled),
385
+ c.editable.of(!e.disabled),
327
386
  // Set Line break char
328
387
  e.lineSeparator ? s.lineSeparator.of(e.lineSeparator) : void 0,
329
388
  // Lang
@@ -334,15 +393,17 @@ var oe = Y({
334
393
  e.linter && e.gutter ? Z(e.gutterConfig) : void 0,
335
394
  // Placeholder
336
395
  e.placeholder ? H(e.placeholder) : void 0,
396
+ // Keymap and Indent with Tab
397
+ o.length !== 0 ? K.of(o) : void 0,
337
398
  // Append Extensions
338
399
  ...e.extensions
339
- ].filter((o) => !!o);
400
+ ].filter((r) => !!r);
340
401
  });
341
- V(
342
- g,
343
- (a) => t.value?.dispatch({ effects: y.reconfigure.of(a) }),
402
+ B(
403
+ y,
404
+ (a) => t.value?.dispatch({ effects: S.reconfigure.of(a) }),
344
405
  { immediate: !0 }
345
- ), V(
406
+ ), B(
346
407
  () => e.modelValue,
347
408
  async (a) => {
348
409
  if (t.value.composing || // IME fix
@@ -359,33 +420,33 @@ var oe = Y({
359
420
  });
360
421
  },
361
422
  { immediate: !0 }
362
- ), te(async () => {
423
+ ), ae(async () => {
363
424
  let a = u.value;
364
425
  l.value && (l.value.childNodes[0] && (u.value !== "" && console.warn(
365
426
  "[CodeMirror.vue] The <code-mirror> tag contains child elements that overwrite the `v-model` values."
366
- ), a = l.value.childNodes[0].innerText.trim()), t.value = new r({
427
+ ), a = l.value.childNodes[0].innerText.trim()), t.value = new c({
367
428
  parent: l.value,
368
- state: s.create({ doc: a, extensions: g.value }),
429
+ state: s.create({ doc: a, extensions: y.value }),
369
430
  dispatch: (n) => {
370
431
  t.value.update([n]), !(n.changes.empty || !n.docChanged) && (i.emit("update:modelValue", n.state.doc.toString()), i.emit("change", n.state));
371
432
  }
372
- }), await ae(), i.emit("ready", {
433
+ }), await ne(), i.emit("ready", {
373
434
  view: t.value,
374
435
  state: t.value.state,
375
436
  container: l.value
376
437
  }));
377
- }), ne(() => {
438
+ }), le(() => {
378
439
  t.value.destroy(), i.emit("destroy");
379
440
  });
380
- const $ = () => {
381
- !e.linter || !t.value || (e.forceLinting && b(t.value), h.value = k(t.value.state));
382
- }, j = () => {
441
+ const j = () => {
442
+ !e.linter || !t.value || (e.forceLinting && w(t.value), g.value = q(t.value.state));
443
+ }, x = () => {
383
444
  t.value?.dispatch({
384
- effects: y.reconfigure.of([])
445
+ effects: S.reconfigure.of([])
385
446
  }), t.value?.dispatch({
386
- effects: y.appendConfig.of(g.value)
447
+ effects: S.appendConfig.of(y.value)
387
448
  });
388
- }, x = (a, n) => t.value.state.sliceDoc(a, n), _ = (a) => t.value.state.doc.line(a + 1).text, L = () => t.value.state.doc.lines, N = () => t.value.state.selection.main.head, U = () => {
449
+ }, _ = (a, n) => t.value.state.sliceDoc(a, n), L = (a) => t.value.state.doc.line(a + 1).text, N = () => t.value.state.doc.lines, U = () => t.value.state.selection.main.head, k = () => {
389
450
  let a;
390
451
  return (a = t.value.state.selection.ranges) !== null && a !== void 0 ? a : [];
391
452
  }, z = () => {
@@ -403,44 +464,44 @@ var oe = Y({
403
464
  (a) => !a.empty
404
465
  ), T = (a, n, o) => t.value.dispatch({
405
466
  changes: { from: n, to: o, insert: a }
406
- }), D = (a) => t.value.dispatch(t.value.state.replaceSelection(a)), F = (a) => t.value.dispatch({ selection: { anchor: a } }), I = (a, n) => t.value.dispatch({ selection: { anchor: a, head: n } }), J = (a, n) => t.value.dispatch({
407
- selection: C.create(a, n)
408
- }), A = (a) => t.value.dispatch({
409
- selection: C.create(
410
- f.value.ranges.map((n) => n.extend(a(n)))
467
+ }), D = (a) => t.value.dispatch(t.value.state.replaceSelection(a)), A = (a) => t.value.dispatch({ selection: { anchor: a } }), F = (a, n) => t.value.dispatch({ selection: { anchor: a, head: n } }), I = (a, n) => t.value.dispatch({
468
+ selection: O.create(a, n)
469
+ }), J = (a) => t.value.dispatch({
470
+ selection: O.create(
471
+ v.value.ranges.map((n) => n.extend(a(n)))
411
472
  )
412
- }), p = {
473
+ }), b = {
413
474
  editor: l,
414
475
  view: t,
415
- cursor: m,
416
- selection: f,
417
- focus: d,
418
- length: S,
419
- json: M,
420
- diagnosticCount: h,
476
+ cursor: h,
477
+ selection: v,
478
+ focus: f,
479
+ length: p,
480
+ json: $,
481
+ diagnosticCount: g,
421
482
  dom: t.value.contentDOM,
422
- lint: $,
423
- forceReconfigure: j,
483
+ lint: j,
484
+ forceReconfigure: x,
424
485
  // Bellow is CodeMirror5's function
425
- getRange: x,
426
- getLine: _,
427
- lineCount: L,
428
- getCursor: N,
429
- listSelections: U,
486
+ getRange: _,
487
+ getLine: L,
488
+ lineCount: N,
489
+ getCursor: U,
490
+ listSelections: k,
430
491
  getSelection: z,
431
492
  getSelections: E,
432
493
  somethingSelected: R,
433
494
  replaceRange: T,
434
495
  replaceSelection: D,
435
- setCursor: F,
436
- setSelection: I,
437
- setSelections: J,
438
- extendSelectionsBy: A
496
+ setCursor: A,
497
+ setSelection: F,
498
+ setSelections: I,
499
+ extendSelectionsBy: J
439
500
  };
440
- return i.expose(p), p;
501
+ return i.expose(b), b;
441
502
  },
442
503
  render() {
443
- return B(
504
+ return M(
444
505
  this.$props.tag,
445
506
  {
446
507
  ref: "editor",
@@ -448,18 +509,18 @@ var oe = Y({
448
509
  },
449
510
  this.$slots.default ? (
450
511
  // Hide original content
451
- B(
512
+ M(
452
513
  "aside",
453
514
  { style: "display: none;", "aria-hidden": "true" },
454
- ie(this.$slots.default)
515
+ oe(this.$slots.default)
455
516
  )
456
517
  ) : void 0
457
518
  );
458
519
  }
459
520
  });
460
- const he = (e) => e.component("CodeMirror", oe);
521
+ const ge = (e) => e.component("CodeMirror", se);
461
522
  export {
462
- me as Meta,
463
- oe as default,
464
- he as install
523
+ he as Meta,
524
+ se as default,
525
+ ge as install
465
526
  };
@@ -5,9 +5,9 @@
5
5
  * @author Logue <logue@hotmail.co.jp>
6
6
  * @copyright 2022-2025 By Masashi Yoshikawa All rights reserved.
7
7
  * @license MIT
8
- * @version 1.3.17
8
+ * @version 1.3.20
9
9
  * @see {@link https://github.com/logue/vue-codemirror6}
10
10
  */
11
11
 
12
- var CodeMirror=function(u,V,E,f,i,d,y,l){"use strict";const O={version:"1.3.17",date:"2025-06-02T14:16:10.878Z"},M=e=>e?Object.entries(e).reduce((c,[o,s])=>(o=o.charAt(0).toUpperCase()+o.slice(1),o=`on${o}`,{...c,[o]:s}),{}):{};function b(e,c={},o){if(l.isVue2)return l.h(e,c,o);const{props:s,domProps:t,on:v,...g}=c,h=v?M(v):{};return l.h(e,{...g,...s,...t,...h},o)}const B=e=>typeof e=="function"?e():e;var w=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}},emits:{"update:modelValue":(e="")=>!0,update:e=>!0,ready:e=>!0,focus:e=>!0,change:e=>!0,destroy:()=>!0},setup(e,c){const o=l.ref(),s=l.ref(e.modelValue),t=l.shallowRef(new d.EditorView),v=l.computed({get:()=>t.value.hasFocus,set:a=>{a&&t.value.focus()}}),g=l.computed({get:()=>t.value.state.selection,set:a=>t.value.dispatch({selection:a})}),h=l.computed({get:()=>t.value.state.selection.main.head,set:a=>t.value.dispatch({selection:{anchor:a}})}),j=l.computed({get:()=>t.value.state.toJSON(),set:a=>t.value.setState(i.EditorState.fromJSON(a))}),C=l.ref(0),m=l.ref(0),S=l.computed(()=>{const a=new i.Compartment,n=new i.Compartment;if(e.basic&&e.minimal)throw new Error("[Vue CodeMirror] Both basic and minimal cannot be specified.");return[e.basic&&!e.minimal?y.basicSetup:void 0,e.minimal&&!e.basic?y.minimalSetup:void 0,d.EditorView.updateListener.of(r=>{c.emit("focus",t.value.hasFocus),C.value=t.value.state.doc?.length,!(r.changes.empty||!r.docChanged)&&(e.linter&&(e.forceLinting&&f.forceLinting(t.value),m.value=e.linter(t.value).length),c.emit("update",r))}),d.EditorView.theme(e.theme,{dark:e.dark}),e.wrap?d.EditorView.lineWrapping:void 0,e.tab?d.keymap.of([V.indentWithTab]):void 0,e.indentUnit?E.indentUnit.of(e.indentUnit):void 0,i.EditorState.allowMultipleSelections.of(e.allowMultipleSelections),e.tabSize?n.of(i.EditorState.tabSize.of(e.tabSize)):void 0,e.phrases?i.EditorState.phrases.of(e.phrases):void 0,i.EditorState.readOnly.of(e.readonly),d.EditorView.editable.of(!e.disabled),e.lineSeparator?i.EditorState.lineSeparator.of(e.lineSeparator):void 0,e.lang?a.of(e.lang):void 0,e.linter?f.linter(e.linter,e.linterConfig):void 0,e.linter&&e.gutter?f.lintGutter(e.gutterConfig):void 0,e.placeholder?d.placeholder(e.placeholder):void 0,...e.extensions].filter(r=>!!r)});l.watch(S,a=>t.value?.dispatch({effects:i.StateEffect.reconfigure.of(a)}),{immediate:!0}),l.watch(()=>e.modelValue,async a=>{if(t.value.composing||t.value.state.doc.toJSON().join(e.lineSeparator??`
13
- `)===a)return;const n=!t.value.state.selection.ranges.every(r=>r.anchor<a.length&&r.head<a.length);t.value.dispatch({changes:{from:0,to:t.value.state.doc.length,insert:a},selection:n?{anchor:0,head:0}:t.value.state.selection,scrollIntoView:e.scrollIntoView})},{immediate:!0}),l.onMounted(async()=>{let a=s.value;o.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()),t.value=new d.EditorView({parent:o.value,state:i.EditorState.create({doc:a,extensions:S.value}),dispatch:n=>{t.value.update([n]),!(n.changes.empty||!n.docChanged)&&(c.emit("update:modelValue",n.state.doc.toString()),c.emit("change",n.state))}}),await l.nextTick(),c.emit("ready",{view:t.value,state:t.value.state,container:o.value}))}),l.onUnmounted(()=>{t.value.destroy(),c.emit("destroy")});const _=()=>{!e.linter||!t.value||(e.forceLinting&&f.forceLinting(t.value),m.value=f.diagnosticCount(t.value.state))},L=()=>{t.value?.dispatch({effects:i.StateEffect.reconfigure.of([])}),t.value?.dispatch({effects:i.StateEffect.appendConfig.of(S.value)})},N=(a,n)=>t.value.state.sliceDoc(a,n),U=a=>t.value.state.doc.line(a+1).text,z=()=>t.value.state.doc.lines,R=()=>t.value.state.selection.main.head,T=()=>{let a;return(a=t.value.state.selection.ranges)!==null&&a!==void 0?a:[]},F=()=>{let a;return(a=t.value.state.sliceDoc(t.value.state.selection.main.from,t.value.state.selection.main.to))!==null&&a!==void 0?a:""},I=()=>{const a=t.value.state;return a?a.selection.ranges.map(n=>a.sliceDoc(n.from,n.to)):[]},J=()=>t.value.state.selection.ranges.some(a=>!a.empty),x=(a,n,r)=>t.value.dispatch({changes:{from:n,to:r,insert:a}}),A=a=>t.value.dispatch(t.value.state.replaceSelection(a)),P=a=>t.value.dispatch({selection:{anchor:a}}),W=(a,n)=>t.value.dispatch({selection:{anchor:a,head:n}}),G=(a,n)=>t.value.dispatch({selection:i.EditorSelection.create(a,n)}),Z=a=>t.value.dispatch({selection:i.EditorSelection.create(g.value.ranges.map(n=>n.extend(a(n))))}),p={editor:o,view:t,cursor:h,selection:g,focus:v,length:C,json:j,diagnosticCount:m,dom:t.value.contentDOM,lint:_,forceReconfigure:L,getRange:N,getLine:U,lineCount:z,getCursor:R,listSelections:T,getSelection:F,getSelections:I,somethingSelected:J,replaceRange:x,replaceSelection:A,setCursor:P,setSelection:W,setSelections:G,extendSelectionsBy:Z};return c.expose(p),p},render(){return b(this.$props.tag,{ref:"editor",class:"vue-codemirror"},this.$slots.default?b("aside",{style:"display: none;","aria-hidden":"true"},B(this.$slots.default)):void 0)}});const $=e=>e.component("CodeMirror",w);return u.Meta=O,u.default=w,u.install=$,Object.defineProperty(u,"__esModule",{value:!0}),u}({},commands,language,lint,state,view,codemirror,VueDemi);
12
+ var CodeMirror=function(u,E,O,f,i,d,b,l){"use strict";const M={version:"1.3.20",date:"2025-06-20T15:57:15.852Z"},B=e=>e?Object.entries(e).reduce((c,[o,s])=>(o=o.charAt(0).toUpperCase()+o.slice(1),o=`on${o}`,{...c,[o]:s}),{}):{};function w(e,c={},o){if(l.isVue2)return l.h(e,c,o);const{props:s,domProps:t,on:h,...g}=c,m=h?B(h):{};return l.h(e,{...g,...s,...t,...m},o)}const $=e=>typeof e=="function"?e():e;var 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":(e="")=>!0,update:e=>!0,ready:e=>!0,focus:e=>!0,change:e=>!0,destroy:()=>!0},setup(e,c){const o=l.ref(),s=l.ref(e.modelValue),t=l.shallowRef(new d.EditorView),h=l.computed({get:()=>t.value.hasFocus,set:a=>{a&&t.value.focus()}}),g=l.computed({get:()=>t.value.state.selection,set:a=>t.value.dispatch({selection:a})}),m=l.computed({get:()=>t.value.state.selection.main.head,set:a=>t.value.dispatch({selection:{anchor:a}})}),_=l.computed({get:()=>t.value.state.toJSON(),set:a=>t.value.setState(i.EditorState.fromJSON(a))}),p=l.ref(0),y=l.ref(0),S=l.computed(()=>{const a=new i.Compartment,n=new i.Compartment;if(e.basic&&e.minimal)throw new Error("[Vue CodeMirror] Both basic and minimal cannot be specified.");let r=[];return e.keymap&&e.keymap.length>0&&(r=e.keymap),e.tab&&r.push(E.indentWithTab),[e.basic&&!e.minimal?b.basicSetup:void 0,e.minimal&&!e.basic?b.minimalSetup:void 0,d.EditorView.updateListener.of(v=>{c.emit("focus",t.value.hasFocus),p.value=t.value.state.doc?.length,!(v.changes.empty||!v.docChanged)&&(e.linter&&(e.forceLinting&&f.forceLinting(t.value),y.value=e.linter(t.value).length),c.emit("update",v))}),d.EditorView.theme(e.theme,{dark:e.dark}),e.wrap?d.EditorView.lineWrapping:void 0,e.indentUnit?O.indentUnit.of(e.indentUnit):void 0,i.EditorState.allowMultipleSelections.of(e.allowMultipleSelections),e.tabSize?n.of(i.EditorState.tabSize.of(e.tabSize)):void 0,e.phrases?i.EditorState.phrases.of(e.phrases):void 0,i.EditorState.readOnly.of(e.readonly),d.EditorView.editable.of(!e.disabled),e.lineSeparator?i.EditorState.lineSeparator.of(e.lineSeparator):void 0,e.lang?a.of(e.lang):void 0,e.linter?f.linter(e.linter,e.linterConfig):void 0,e.linter&&e.gutter?f.lintGutter(e.gutterConfig):void 0,e.placeholder?d.placeholder(e.placeholder):void 0,r.length!==0?d.keymap.of(r):void 0,...e.extensions].filter(v=>!!v)});l.watch(S,a=>t.value?.dispatch({effects:i.StateEffect.reconfigure.of(a)}),{immediate:!0}),l.watch(()=>e.modelValue,async a=>{if(t.value.composing||t.value.state.doc.toJSON().join(e.lineSeparator??`
13
+ `)===a)return;const n=!t.value.state.selection.ranges.every(r=>r.anchor<a.length&&r.head<a.length);t.value.dispatch({changes:{from:0,to:t.value.state.doc.length,insert:a},selection:n?{anchor:0,head:0}:t.value.state.selection,scrollIntoView:e.scrollIntoView})},{immediate:!0}),l.onMounted(async()=>{let a=s.value;o.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()),t.value=new d.EditorView({parent:o.value,state:i.EditorState.create({doc:a,extensions:S.value}),dispatch:n=>{t.value.update([n]),!(n.changes.empty||!n.docChanged)&&(c.emit("update:modelValue",n.state.doc.toString()),c.emit("change",n.state))}}),await l.nextTick(),c.emit("ready",{view:t.value,state:t.value.state,container:o.value}))}),l.onUnmounted(()=>{t.value.destroy(),c.emit("destroy")});const L=()=>{!e.linter||!t.value||(e.forceLinting&&f.forceLinting(t.value),y.value=f.diagnosticCount(t.value.state))},N=()=>{t.value?.dispatch({effects:i.StateEffect.reconfigure.of([])}),t.value?.dispatch({effects:i.StateEffect.appendConfig.of(S.value)})},U=(a,n)=>t.value.state.sliceDoc(a,n),k=a=>t.value.state.doc.line(a+1).text,z=()=>t.value.state.doc.lines,R=()=>t.value.state.selection.main.head,T=()=>{let a;return(a=t.value.state.selection.ranges)!==null&&a!==void 0?a:[]},A=()=>{let a;return(a=t.value.state.sliceDoc(t.value.state.selection.main.from,t.value.state.selection.main.to))!==null&&a!==void 0?a:""},F=()=>{const a=t.value.state;return a?a.selection.ranges.map(n=>a.sliceDoc(n.from,n.to)):[]},I=()=>t.value.state.selection.ranges.some(a=>!a.empty),J=(a,n,r)=>t.value.dispatch({changes:{from:n,to:r,insert:a}}),x=a=>t.value.dispatch(t.value.state.replaceSelection(a)),P=a=>t.value.dispatch({selection:{anchor:a}}),W=(a,n)=>t.value.dispatch({selection:{anchor:a,head:n}}),G=(a,n)=>t.value.dispatch({selection:i.EditorSelection.create(a,n)}),Z=a=>t.value.dispatch({selection:i.EditorSelection.create(g.value.ranges.map(n=>n.extend(a(n))))}),V={editor:o,view:t,cursor:m,selection:g,focus:h,length:p,json:_,diagnosticCount:y,dom:t.value.contentDOM,lint:L,forceReconfigure:N,getRange:U,getLine:k,lineCount:z,getCursor:R,listSelections:T,getSelection:A,getSelections:F,somethingSelected:I,replaceRange:J,replaceSelection:x,setCursor:P,setSelection:W,setSelections:G,extendSelectionsBy:Z};return c.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"},$(this.$slots.default)):void 0)}});const j=e=>e.component("CodeMirror",C);return u.Meta=M,u.default=C,u.install=j,Object.defineProperty(u,"__esModule",{value:!0}),u}({},commands,language,lint,state,view,codemirror,VueDemi);
package/dist/index.umd.js CHANGED
@@ -5,9 +5,9 @@
5
5
  * @author Logue <logue@hotmail.co.jp>
6
6
  * @copyright 2022-2025 By Masashi Yoshikawa All rights reserved.
7
7
  * @license MIT
8
- * @version 1.3.17
8
+ * @version 1.3.20
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,E,v,r,s,p,o){"use strict";const O={version:"1.3.17",date:"2025-06-02T14:16:10.878Z"},M=e=>e?Object.entries(e).reduce((d,[i,u])=>(i=i.charAt(0).toUpperCase()+i.slice(1),i=`on${i}`,{...d,[i]:u}),{}):{};function w(e,d={},i){if(o.isVue2)return o.h(e,d,i);const{props:u,domProps:t,on:m,...h}=d,g=m?M(m):{};return o.h(e,{...h,...u,...t,...g},i)}const B=e=>typeof e=="function"?e():e;var C=o.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}},emits:{"update:modelValue":(e="")=>!0,update:e=>!0,ready:e=>!0,focus:e=>!0,change:e=>!0,destroy:()=>!0},setup(e,d){const i=o.ref(),u=o.ref(e.modelValue),t=o.shallowRef(new s.EditorView),m=o.computed({get:()=>t.value.hasFocus,set:a=>{a&&t.value.focus()}}),h=o.computed({get:()=>t.value.state.selection,set:a=>t.value.dispatch({selection:a})}),g=o.computed({get:()=>t.value.state.selection.main.head,set:a=>t.value.dispatch({selection:{anchor:a}})}),j=o.computed({get:()=>t.value.state.toJSON(),set:a=>t.value.setState(r.EditorState.fromJSON(a))}),b=o.ref(0),S=o.ref(0),y=o.computed(()=>{const a=new r.Compartment,n=new r.Compartment;if(e.basic&&e.minimal)throw new Error("[Vue CodeMirror] Both basic and minimal cannot be specified.");return[e.basic&&!e.minimal?p.basicSetup:void 0,e.minimal&&!e.basic?p.minimalSetup:void 0,s.EditorView.updateListener.of(c=>{d.emit("focus",t.value.hasFocus),b.value=t.value.state.doc?.length,!(c.changes.empty||!c.docChanged)&&(e.linter&&(e.forceLinting&&v.forceLinting(t.value),S.value=e.linter(t.value).length),d.emit("update",c))}),s.EditorView.theme(e.theme,{dark:e.dark}),e.wrap?s.EditorView.lineWrapping:void 0,e.tab?s.keymap.of([f.indentWithTab]):void 0,e.indentUnit?E.indentUnit.of(e.indentUnit):void 0,r.EditorState.allowMultipleSelections.of(e.allowMultipleSelections),e.tabSize?n.of(r.EditorState.tabSize.of(e.tabSize)):void 0,e.phrases?r.EditorState.phrases.of(e.phrases):void 0,r.EditorState.readOnly.of(e.readonly),s.EditorView.editable.of(!e.disabled),e.lineSeparator?r.EditorState.lineSeparator.of(e.lineSeparator):void 0,e.lang?a.of(e.lang):void 0,e.linter?v.linter(e.linter,e.linterConfig):void 0,e.linter&&e.gutter?v.lintGutter(e.gutterConfig):void 0,e.placeholder?s.placeholder(e.placeholder):void 0,...e.extensions].filter(c=>!!c)});o.watch(y,a=>t.value?.dispatch({effects:r.StateEffect.reconfigure.of(a)}),{immediate:!0}),o.watch(()=>e.modelValue,async a=>{if(t.value.composing||t.value.state.doc.toJSON().join(e.lineSeparator??`
13
- `)===a)return;const n=!t.value.state.selection.ranges.every(c=>c.anchor<a.length&&c.head<a.length);t.value.dispatch({changes:{from:0,to:t.value.state.doc.length,insert:a},selection:n?{anchor:0,head:0}:t.value.state.selection,scrollIntoView:e.scrollIntoView})},{immediate:!0}),o.onMounted(async()=>{let a=u.value;i.value&&(i.value.childNodes[0]&&(u.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()),t.value=new s.EditorView({parent:i.value,state:r.EditorState.create({doc:a,extensions:y.value}),dispatch:n=>{t.value.update([n]),!(n.changes.empty||!n.docChanged)&&(d.emit("update:modelValue",n.state.doc.toString()),d.emit("change",n.state))}}),await o.nextTick(),d.emit("ready",{view:t.value,state:t.value.state,container:i.value}))}),o.onUnmounted(()=>{t.value.destroy(),d.emit("destroy")});const _=()=>{!e.linter||!t.value||(e.forceLinting&&v.forceLinting(t.value),S.value=v.diagnosticCount(t.value.state))},q=()=>{t.value?.dispatch({effects:r.StateEffect.reconfigure.of([])}),t.value?.dispatch({effects:r.StateEffect.appendConfig.of(y.value)})},L=(a,n)=>t.value.state.sliceDoc(a,n),T=a=>t.value.state.doc.line(a+1).text,x=()=>t.value.state.doc.lines,N=()=>t.value.state.selection.main.head,U=()=>{let a;return(a=t.value.state.selection.ranges)!==null&&a!==void 0?a:[]},z=()=>{let a;return(a=t.value.state.sliceDoc(t.value.state.selection.main.from,t.value.state.selection.main.to))!==null&&a!==void 0?a:""},R=()=>{const a=t.value.state;return a?a.selection.ranges.map(n=>a.sliceDoc(n.from,n.to)):[]},F=()=>t.value.state.selection.ranges.some(a=>!a.empty),I=(a,n,c)=>t.value.dispatch({changes:{from:n,to:c,insert:a}}),J=a=>t.value.dispatch(t.value.state.replaceSelection(a)),A=a=>t.value.dispatch({selection:{anchor:a}}),P=(a,n)=>t.value.dispatch({selection:{anchor:a,head:n}}),W=(a,n)=>t.value.dispatch({selection:r.EditorSelection.create(a,n)}),G=a=>t.value.dispatch({selection:r.EditorSelection.create(h.value.ranges.map(n=>n.extend(a(n))))}),V={editor:i,view:t,cursor:g,selection:h,focus:m,length:b,json:j,diagnosticCount:S,dom:t.value.contentDOM,lint:_,forceReconfigure:q,getRange:L,getLine:T,lineCount:x,getCursor:N,listSelections:U,getSelection:z,getSelections:R,somethingSelected:F,replaceRange:I,replaceSelection:J,setCursor:A,setSelection:P,setSelections:W,extendSelectionsBy:G};return d.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"},B(this.$slots.default)):void 0)}});const $=e=>e.component("CodeMirror",C);l.Meta=O,l.default=C,l.install=$,Object.defineProperty(l,"__esModule",{value:!0})});
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,s,w,i){"use strict";const M={version:"1.3.20",date:"2025-06-20T15:57:15.852Z"},B=e=>e?Object.entries(e).reduce((d,[o,u])=>(o=o.charAt(0).toUpperCase()+o.slice(1),o=`on${o}`,{...d,[o]:u}),{}):{};function C(e,d={},o){if(i.isVue2)return i.h(e,d,o);const{props:u,domProps:t,on:h,...g}=d,y=h?B(h):{};return i.h(e,{...g,...u,...t,...y},o)}const $=e=>typeof e=="function"?e():e;var 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":(e="")=>!0,update:e=>!0,ready:e=>!0,focus:e=>!0,change:e=>!0,destroy:()=>!0},setup(e,d){const o=i.ref(),u=i.ref(e.modelValue),t=i.shallowRef(new s.EditorView),h=i.computed({get:()=>t.value.hasFocus,set:a=>{a&&t.value.focus()}}),g=i.computed({get:()=>t.value.state.selection,set:a=>t.value.dispatch({selection:a})}),y=i.computed({get:()=>t.value.state.selection.main.head,set:a=>t.value.dispatch({selection:{anchor:a}})}),_=i.computed({get:()=>t.value.state.toJSON(),set:a=>t.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(e.basic&&e.minimal)throw new Error("[Vue CodeMirror] Both basic and minimal cannot be specified.");let c=[];return e.keymap&&e.keymap.length>0&&(c=e.keymap),e.tab&&c.push(f.indentWithTab),[e.basic&&!e.minimal?w.basicSetup:void 0,e.minimal&&!e.basic?w.minimalSetup:void 0,s.EditorView.updateListener.of(m=>{d.emit("focus",t.value.hasFocus),V.value=t.value.state.doc?.length,!(m.changes.empty||!m.docChanged)&&(e.linter&&(e.forceLinting&&v.forceLinting(t.value),S.value=e.linter(t.value).length),d.emit("update",m))}),s.EditorView.theme(e.theme,{dark:e.dark}),e.wrap?s.EditorView.lineWrapping:void 0,e.indentUnit?O.indentUnit.of(e.indentUnit):void 0,r.EditorState.allowMultipleSelections.of(e.allowMultipleSelections),e.tabSize?n.of(r.EditorState.tabSize.of(e.tabSize)):void 0,e.phrases?r.EditorState.phrases.of(e.phrases):void 0,r.EditorState.readOnly.of(e.readonly),s.EditorView.editable.of(!e.disabled),e.lineSeparator?r.EditorState.lineSeparator.of(e.lineSeparator):void 0,e.lang?a.of(e.lang):void 0,e.linter?v.linter(e.linter,e.linterConfig):void 0,e.linter&&e.gutter?v.lintGutter(e.gutterConfig):void 0,e.placeholder?s.placeholder(e.placeholder):void 0,c.length!==0?s.keymap.of(c):void 0,...e.extensions].filter(m=>!!m)});i.watch(p,a=>t.value?.dispatch({effects:r.StateEffect.reconfigure.of(a)}),{immediate:!0}),i.watch(()=>e.modelValue,async a=>{if(t.value.composing||t.value.state.doc.toJSON().join(e.lineSeparator??`
13
+ `)===a)return;const n=!t.value.state.selection.ranges.every(c=>c.anchor<a.length&&c.head<a.length);t.value.dispatch({changes:{from:0,to:t.value.state.doc.length,insert:a},selection:n?{anchor:0,head:0}:t.value.state.selection,scrollIntoView:e.scrollIntoView})},{immediate:!0}),i.onMounted(async()=>{let a=u.value;o.value&&(o.value.childNodes[0]&&(u.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()),t.value=new s.EditorView({parent:o.value,state:r.EditorState.create({doc:a,extensions:p.value}),dispatch:n=>{t.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:t.value,state:t.value.state,container:o.value}))}),i.onUnmounted(()=>{t.value.destroy(),d.emit("destroy")});const q=()=>{!e.linter||!t.value||(e.forceLinting&&v.forceLinting(t.value),S.value=v.diagnosticCount(t.value.state))},L=()=>{t.value?.dispatch({effects:r.StateEffect.reconfigure.of([])}),t.value?.dispatch({effects:r.StateEffect.appendConfig.of(p.value)})},T=(a,n)=>t.value.state.sliceDoc(a,n),x=a=>t.value.state.doc.line(a+1).text,N=()=>t.value.state.doc.lines,U=()=>t.value.state.selection.main.head,k=()=>{let a;return(a=t.value.state.selection.ranges)!==null&&a!==void 0?a:[]},z=()=>{let a;return(a=t.value.state.sliceDoc(t.value.state.selection.main.from,t.value.state.selection.main.to))!==null&&a!==void 0?a:""},R=()=>{const a=t.value.state;return a?a.selection.ranges.map(n=>a.sliceDoc(n.from,n.to)):[]},A=()=>t.value.state.selection.ranges.some(a=>!a.empty),F=(a,n,c)=>t.value.dispatch({changes:{from:n,to:c,insert:a}}),I=a=>t.value.dispatch(t.value.state.replaceSelection(a)),J=a=>t.value.dispatch({selection:{anchor:a}}),P=(a,n)=>t.value.dispatch({selection:{anchor:a,head:n}}),W=(a,n)=>t.value.dispatch({selection:r.EditorSelection.create(a,n)}),G=a=>t.value.dispatch({selection:r.EditorSelection.create(g.value.ranges.map(n=>n.extend(a(n))))}),E={editor:o,view:t,cursor:y,selection:g,focus:h,length:V,json:_,diagnosticCount:S,dom:t.value.contentDOM,lint:q,forceReconfigure:L,getRange:T,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"},$(this.$slots.default)):void 0)}});const j=e=>e.component("CodeMirror",b);l.Meta=M,l.default=b,l.install=j,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.3.17",
4
+ "version": "1.3.20",
5
5
  "license": "MIT",
6
6
  "description": "CodeMirror6 Component for vue2 and vue3.",
7
7
  "keywords": [
@@ -56,7 +56,7 @@
56
56
  "engines": {
57
57
  "pnpm": ">=10.3.0"
58
58
  },
59
- "packageManager": "pnpm@10.11.0",
59
+ "packageManager": "pnpm@10.12.1",
60
60
  "sideEffects": false,
61
61
  "scripts": {
62
62
  "dev": "vite",
@@ -75,12 +75,12 @@
75
75
  "dependencies": {
76
76
  "@codemirror/autocomplete": "^6.18.6",
77
77
  "@codemirror/commands": "^6.8.1",
78
- "@codemirror/language": "^6.11.0",
78
+ "@codemirror/language": "^6.11.1",
79
79
  "@codemirror/lint": "^6.8.5",
80
80
  "@codemirror/search": "^6.5.11",
81
81
  "@codemirror/state": "^6.5.2",
82
- "@codemirror/view": "^6.37.1",
83
- "codemirror": "^6.0.1",
82
+ "@codemirror/view": "^6.37.2",
83
+ "codemirror": "^6.0.2",
84
84
  "style-mod": "^4.1.2",
85
85
  "vue-demi": "latest"
86
86
  },
@@ -89,43 +89,43 @@
89
89
  },
90
90
  "devDependencies": {
91
91
  "@codemirror/lang-javascript": "^6.2.4",
92
- "@codemirror/lang-json": "^6.0.1",
93
- "@codemirror/lang-markdown": "^6.3.2",
92
+ "@codemirror/lang-json": "^6.0.2",
93
+ "@codemirror/lang-markdown": "^6.3.3",
94
94
  "@codemirror/lang-vue": "^0.1.3",
95
95
  "@tsconfig/node-lts": "^22.0.1",
96
- "@types/node": "^22.15.29",
96
+ "@types/node": "^24.0.3",
97
97
  "@vitejs/plugin-vue": "^5.2.4",
98
- "@vue/compiler-sfc": "^3.5.16",
98
+ "@vue/compiler-sfc": "^3.5.17",
99
99
  "@vue/eslint-config-prettier": "^10.2.0",
100
- "@vue/eslint-config-typescript": "^14.5.0",
100
+ "@vue/eslint-config-typescript": "^14.5.1",
101
101
  "@vue/test-utils": "^2.4.6",
102
102
  "@vue/tsconfig": "^0.7.0",
103
- "@vueuse/core": "^13.3.0",
104
- "bootstrap": "^5.3.6",
105
- "eslint": "^9.28.0",
103
+ "@vueuse/core": "^13.4.0",
104
+ "bootstrap": "^5.3.7",
105
+ "eslint": "^9.29.0",
106
106
  "eslint-import-resolver-custom-alias": "^1.3.2",
107
- "eslint-import-resolver-typescript": "^4.4.2",
108
- "eslint-linter-browserify": "^9.28.0",
107
+ "eslint-import-resolver-typescript": "^4.4.3",
108
+ "eslint-linter-browserify": "^9.29.0",
109
109
  "eslint-plugin-import": "^2.31.0",
110
110
  "eslint-plugin-playwright": "^2.2.0",
111
- "eslint-plugin-vue": "^10.1.0",
111
+ "eslint-plugin-vue": "^10.2.0",
112
112
  "eslint-plugin-vuejs-accessibility": "^2.4.1",
113
113
  "husky": "^9.1.7",
114
114
  "jiti": "^2.4.2",
115
- "lint-staged": "^16.1.0",
115
+ "lint-staged": "^16.1.2",
116
116
  "npm-run-all2": "^8.0.4",
117
117
  "prettier": "^3.5.3",
118
118
  "rimraf": "^6.0.1",
119
- "rollup-plugin-visualizer": "^6.0.1",
120
- "sass": "^1.89.1",
119
+ "rollup-plugin-visualizer": "^6.0.3",
120
+ "sass-embedded": "^1.89.2",
121
121
  "supports-color": "^10.0.0",
122
122
  "typescript": "^5.8.3",
123
- "typescript-eslint": "^8.33.0",
123
+ "typescript-eslint": "^8.34.1",
124
124
  "vite": "^6.3.5",
125
125
  "vite-plugin-banner": "^0.8.1",
126
126
  "vite-plugin-checker": "^0.9.3",
127
127
  "vite-plugin-dts": "^4.5.4",
128
- "vue": "^3.5.16",
128
+ "vue": "^3.5.17",
129
129
  "vue-eslint-parser": "^10.1.3",
130
130
  "vue-markdown-wasm": "^0.5.1",
131
131
  "vue-tsc": "^2.2.10"
@@ -23,6 +23,7 @@ import {
23
23
  EditorView,
24
24
  keymap,
25
25
  placeholder,
26
+ type KeyBinding,
26
27
  type ViewUpdate,
27
28
  } from '@codemirror/view';
28
29
  import { basicSetup, minimalSetup } from 'codemirror';
@@ -127,6 +128,10 @@ export default defineComponent({
127
128
  },
128
129
  /**
129
130
  * Tab character
131
+ * This is the unit of indentation used when the editor is configured to indent with tabs.
132
+ * It is also used to determine the size of the tab character when the editor is configured to use tabs for indentation..
133
+ *
134
+ * @see {@link https://codemirror.net/docs/ref/#state.EditorState^indentUnit}
130
135
  */
131
136
  indentUnit: {
132
137
  type: String,
@@ -134,6 +139,10 @@ export default defineComponent({
134
139
  },
135
140
  /**
136
141
  * Allow Multiple Selection.
142
+ * This allows the editor to have multiple selections at the same time.
143
+ * This is useful for editing multiple parts of the document at once.
144
+ * If this is set to true, the editor will allow multiple selections.
145
+ * If this is set to false, the editor will only allow a single selection.
137
146
  *
138
147
  * @see {@link https://codemirror.net/docs/ref/#state.EditorState^allowMultipleSelections}
139
148
  */
@@ -143,6 +152,9 @@ export default defineComponent({
143
152
  },
144
153
  /**
145
154
  * Tab size
155
+ * This is the number of spaces that a tab character represents in the editor.
156
+ * It is used to determine the size of the tab character when the editor is configured to use tabs for indentation.
157
+ * If this is set to a number, the editor will use that number of spaces for each tab character.
146
158
  *
147
159
  * @see {@link https://codemirror.net/docs/ref/#state.EditorState^tabSize}
148
160
  */
@@ -153,6 +165,9 @@ export default defineComponent({
153
165
  /**
154
166
  * Set line break (separetor) char.
155
167
  *
168
+ * This is the character that is used to separate lines in the editor.
169
+ * It is used to determine the line break character when the editor is configured to use a specific line break character.
170
+ *
156
171
  * @see {@link https://codemirror.net/docs/ref/#state.EditorState^lineSeparator}
157
172
  */
158
173
  lineSeparator: {
@@ -162,6 +177,11 @@ export default defineComponent({
162
177
  /**
163
178
  * Readonly
164
179
  *
180
+ * This is a CodeMirror Facet that allows you to set the editor to read-only mode.
181
+ * When this is set to true, the editor will not allow any changes to be made to the document.
182
+ * This is useful for displaying code that should not be edited, such as documentation or examples.
183
+ * If this is set to false, the editor will allow changes to be made to the document.
184
+ *
165
185
  * @see {@link https://codemirror.net/docs/ref/#state.EditorState^readOnly}
166
186
  */
167
187
  readonly: {
@@ -183,6 +203,8 @@ export default defineComponent({
183
203
  /**
184
204
  * Additional Extension
185
205
  *
206
+ * You can use this to add any additional extensions that you want to use in the editor.
207
+ *
186
208
  * @see {@link https://codemirror.net/docs/ref/#state.Extension}
187
209
  */
188
210
  extensions: {
@@ -194,6 +216,10 @@ export default defineComponent({
194
216
  /**
195
217
  * Language Phreses
196
218
  *
219
+ * This is a CodeMirror Facet that allows you to define custom phrases for the editor.
220
+ * It can be used to override default phrases or add new ones.
221
+ * This is useful for translating the editor to different languages or for customizing the editor's UI.
222
+ *
197
223
  * @see {@link https://codemirror.net/examples/translate/}
198
224
  */
199
225
  phrases: {
@@ -203,6 +229,10 @@ export default defineComponent({
203
229
  /**
204
230
  * CodeMirror Language
205
231
  *
232
+ * This is a CodeMirror Facet that allows you to define the language of the editor.
233
+ * It can be used to enable syntax highlighting and other language-specific features.
234
+ * It is useful for displaying code in a specific language, such as JavaScript, Python, or HTML.
235
+ *
206
236
  * @see {@link https://codemirror.net/docs/ref/#language}
207
237
  */
208
238
  lang: {
@@ -212,6 +242,11 @@ export default defineComponent({
212
242
  /**
213
243
  * CodeMirror Linter
214
244
  *
245
+ * This is a CodeMirror Facet that allows you to define a linter for the editor.
246
+ * It can be used to check the code for errors and warnings, and to provide feedback to the user.
247
+ * It is useful for displaying code in a specific language, such as JavaScript, Python, or HTML.
248
+ * This is useful for providing feedback to the user about the code they are writing.
249
+ *
215
250
  * @see {@link https://codemirror.net/docs/ref/#lint.linter}
216
251
  */
217
252
  linter: {
@@ -221,6 +256,10 @@ export default defineComponent({
221
256
  /**
222
257
  * Linter Config
223
258
  *
259
+ * This is a CodeMirror Facet that allows you to define the configuration for the linter.
260
+ * It can be used to specify options for the linter, such as the severity of errors and warnings, and to customize the behavior of the linter.
261
+ * This is useful for providing feedback to the user about the code they are writing.
262
+ *
224
263
  * @see {@link https://codemirror.net/docs/ref/#lint.linter^config}
225
264
  */
226
265
  linterConfig: {
@@ -232,6 +271,8 @@ export default defineComponent({
232
271
  /**
233
272
  * Forces any linters configured to run when the editor is idle to run right away.
234
273
  *
274
+ * This is useful for running linters on the initial load of the editor, or when the user has made changes to the code and wants to see the results immediately.
275
+ *
235
276
  * @see {@link https://codemirror.net/docs/ref/#lint.forceLinting}
236
277
  */
237
278
  forceLinting: {
@@ -253,6 +294,10 @@ export default defineComponent({
253
294
  /**
254
295
  * Gutter Config
255
296
  *
297
+ * This is a CodeMirror Facet that allows you to define the configuration for the gutter.
298
+ * It can be used to specify options for the gutter, such as the size of the gutter, the position of the gutter, and to customize the behavior of the gutter.
299
+ * This is useful for providing feedback to the user about the code they are writing.
300
+ *
256
301
  * @see {@link https://codemirror.net/docs/ref/#lint.lintGutter^config}
257
302
  */
258
303
  gutterConfig: {
@@ -268,12 +313,28 @@ export default defineComponent({
268
313
  },
269
314
  /**
270
315
  * Allows an external update to scroll the form.
316
+ *
317
+ * This is useful for scrolling the editor to a specific position when the user has made changes to the code and wants to see the results immediately.
318
+ * If this is set to true, the editor will scroll to the position specified in the transaction.
319
+ * If this is set to false, the editor will not scroll to the position specified in the transaction.
320
+ *
271
321
  * @see {@link https://codemirror.net/docs/ref/#state.TransactionSpec.scrollIntoView}
272
322
  */
273
323
  scrollIntoView: {
274
324
  type: Boolean,
275
325
  default: true,
276
326
  },
327
+ /**
328
+ * Key map
329
+ * This is a CodeMirror Facet that allows you to define custom key bindings.
330
+ * It can be used to override default key bindings or add new ones.
331
+ *
332
+ * @see {@link https://codemirror.net/docs/ref/#view.keymap}
333
+ */
334
+ keymap: {
335
+ type: Array as PropType<KeyBinding[]>,
336
+ default: () => [],
337
+ },
277
338
  },
278
339
  /** Emits */
279
340
  emits: {
@@ -373,6 +434,17 @@ export default defineComponent({
373
434
  '[Vue CodeMirror] Both basic and minimal cannot be specified.'
374
435
  );
375
436
  }
437
+ /** Keymap */
438
+ let keymaps: KeyBinding[] = [];
439
+ if (props.keymap && props.keymap.length > 0) {
440
+ // If keymap is specified, use it.
441
+ keymaps = props.keymap;
442
+ }
443
+ if (props.tab) {
444
+ // If tab is enabled, add indentWithTab to keymap.
445
+ keymaps.push(indentWithTab);
446
+ }
447
+
376
448
  // TODO: Ignore previous prop was not changed.
377
449
  return [
378
450
  // Toggle basic setup
@@ -408,8 +480,6 @@ export default defineComponent({
408
480
  EditorView.theme(props.theme, { dark: props.dark }),
409
481
  // Toggle line wrapping
410
482
  props.wrap ? EditorView.lineWrapping : undefined,
411
- // Indent with tab
412
- props.tab ? keymap.of([indentWithTab]) : undefined,
413
483
  // Tab character
414
484
  props.indentUnit ? indentUnit.of(props.indentUnit) : undefined,
415
485
  // Allow Multiple Selections
@@ -438,6 +508,8 @@ export default defineComponent({
438
508
  : undefined,
439
509
  // Placeholder
440
510
  props.placeholder ? placeholder(props.placeholder) : undefined,
511
+ // Keymap and Indent with Tab
512
+ keymaps.length !== 0 ? keymap.of(keymaps) : undefined,
441
513
  // Append Extensions
442
514
  ...props.extensions,
443
515
  ].filter((extension): extension is Extension => !!extension); // Filter undefined