vue-codemirror6 1.3.16 → 1.3.18
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 +10 -3
- package/README.md +1 -0
- package/dist/components/CodeMirror.d.ts +128 -7
- package/dist/index.es.js +145 -87
- package/dist/index.iife.js +3 -3
- package/dist/index.umd.js +3 -3
- package/package.json +11 -12
- package/src/components/CodeMirror.ts +79 -7
package/CHANGELOG.md
CHANGED
|
@@ -4,7 +4,14 @@ 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.
|
|
7
|
+
#### [1.3.17](https://github.com/logue/vue-codemirror6/compare/1.3.13...1.3.17)
|
|
8
|
+
|
|
9
|
+
- fix: full example link [`#58`](https://github.com/logue/vue-codemirror6/pull/58)
|
|
10
|
+
- Update dependencies. [`985f36f`](https://github.com/logue/vue-codemirror6/commit/985f36f23c4fc1b562b53b664deb7ff1eec79989)
|
|
11
|
+
- 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
|
+
|
|
14
|
+
#### [1.3.13](https://github.com/logue/vue-codemirror6/compare/1.3.8...1.3.13)
|
|
8
15
|
|
|
9
16
|
> 31 March 2025
|
|
10
17
|
|
|
@@ -16,7 +23,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
16
23
|
|
|
17
24
|
> 22 November 2024
|
|
18
25
|
|
|
19
|
-
- Fix sample code syntax
|
|
26
|
+
- Fix sample code syntax error [`#47`](https://github.com/logue/vue-codemirror6/pull/47)
|
|
20
27
|
- chore: demo docs [`#43`](https://github.com/logue/vue-codemirror6/pull/43)
|
|
21
28
|
- fix: editor not update content when `modelValue` change and selection is out of range [`#44`](https://github.com/logue/vue-codemirror6/pull/44)
|
|
22
29
|
- chore: props and readme doc [`#31`](https://github.com/logue/vue-codemirror6/pull/31)
|
|
@@ -48,7 +55,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
48
55
|
|
|
49
56
|
- chore(CODEOWNERS): CODEOWNERS.com Bot, at your service! [`#14`](https://github.com/logue/vue-codemirror6/pull/14)
|
|
50
57
|
- Update demo code. (Replaced @codemirror/html to @codemirror/vue.) [`8da1a8a`](https://github.com/logue/vue-codemirror6/commit/8da1a8a4e37d713cc78281ce9c304c42a06940dc)
|
|
51
|
-
- Changed implementation to generate
|
|
58
|
+
- Changed implementation to generate *.d.ts with vite-plugin-dts. [`1caaa20`](https://github.com/logue/vue-codemirror6/commit/1caaa20b1423a3d252a6c770a630fb60e2e3440d)
|
|
52
59
|
- Update README.md. [`f8dd493`](https://github.com/logue/vue-codemirror6/commit/f8dd4934a7b9cc089cd830473db5250d28b3389b)
|
|
53
60
|
|
|
54
61
|
#### [1.1.11](https://github.com/logue/vue-codemirror6/compare/1.1.3...1.1.11)
|
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,24 +160,37 @@ 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: {
|
|
145
170
|
type: PropType<Record<string, string>>;
|
|
146
|
-
default:
|
|
171
|
+
default: undefined;
|
|
147
172
|
};
|
|
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: {
|
|
154
183
|
type: PropType<LanguageSupport>;
|
|
155
|
-
default:
|
|
184
|
+
default: undefined;
|
|
156
185
|
};
|
|
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,11 +236,15 @@ 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: {
|
|
202
246
|
type: ObjectConstructor;
|
|
203
|
-
default:
|
|
247
|
+
default: undefined;
|
|
204
248
|
};
|
|
205
249
|
/**
|
|
206
250
|
* Using tag
|
|
@@ -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,24 +475,37 @@ 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: {
|
|
400
485
|
type: PropType<Record<string, string>>;
|
|
401
|
-
default:
|
|
486
|
+
default: undefined;
|
|
402
487
|
};
|
|
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: {
|
|
409
498
|
type: PropType<LanguageSupport>;
|
|
410
|
-
default:
|
|
499
|
+
default: undefined;
|
|
411
500
|
};
|
|
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,11 +551,15 @@ 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: {
|
|
457
561
|
type: ObjectConstructor;
|
|
458
|
-
default:
|
|
562
|
+
default: undefined;
|
|
459
563
|
};
|
|
460
564
|
/**
|
|
461
565
|
* Using tag
|
|
@@ -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.
|
|
8
|
+
* @version 1.3.18
|
|
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
|
|
15
|
-
import { EditorState as s, Compartment as
|
|
16
|
-
import { EditorView as
|
|
17
|
-
import { basicSetup as
|
|
18
|
-
import { isVue2 as
|
|
19
|
-
const
|
|
20
|
-
version: "1.3.
|
|
21
|
-
date: "2025-
|
|
22
|
-
},
|
|
23
|
-
function
|
|
24
|
-
if (
|
|
25
|
-
return
|
|
26
|
-
const { props: u, domProps: t, on:
|
|
27
|
-
return
|
|
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.18",
|
|
21
|
+
date: "2025-06-09T13:13:13.017Z"
|
|
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
|
-
{ ...
|
|
29
|
+
{ ...v, ...u, ...t, ...h },
|
|
30
30
|
l
|
|
31
31
|
);
|
|
32
32
|
}
|
|
33
|
-
const
|
|
34
|
-
var
|
|
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,26 +195,37 @@ 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: {
|
|
180
205
|
type: Object,
|
|
181
|
-
default:
|
|
182
|
-
}
|
|
206
|
+
default: void 0
|
|
183
207
|
},
|
|
184
208
|
/**
|
|
185
209
|
* CodeMirror Language
|
|
186
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
|
+
*
|
|
187
215
|
* @see {@link https://codemirror.net/docs/ref/#language}
|
|
188
216
|
*/
|
|
189
217
|
lang: {
|
|
190
218
|
type: Object,
|
|
191
|
-
default:
|
|
192
|
-
}
|
|
219
|
+
default: void 0
|
|
193
220
|
},
|
|
194
221
|
/**
|
|
195
222
|
* CodeMirror Linter
|
|
196
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
|
+
*
|
|
197
229
|
* @see {@link https://codemirror.net/docs/ref/#lint.linter}
|
|
198
230
|
*/
|
|
199
231
|
linter: {
|
|
@@ -203,6 +235,10 @@ var oe = Y({
|
|
|
203
235
|
/**
|
|
204
236
|
* Linter Config
|
|
205
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
|
+
*
|
|
206
242
|
* @see {@link https://codemirror.net/docs/ref/#lint.linter^config}
|
|
207
243
|
*/
|
|
208
244
|
linterConfig: {
|
|
@@ -212,6 +248,8 @@ var oe = Y({
|
|
|
212
248
|
/**
|
|
213
249
|
* Forces any linters configured to run when the editor is idle to run right away.
|
|
214
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
|
+
*
|
|
215
253
|
* @see {@link https://codemirror.net/docs/ref/#lint.forceLinting}
|
|
216
254
|
*/
|
|
217
255
|
forceLinting: {
|
|
@@ -233,12 +271,15 @@ var oe = Y({
|
|
|
233
271
|
/**
|
|
234
272
|
* Gutter Config
|
|
235
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
|
+
*
|
|
236
278
|
* @see {@link https://codemirror.net/docs/ref/#lint.lintGutter^config}
|
|
237
279
|
*/
|
|
238
280
|
gutterConfig: {
|
|
239
281
|
type: Object,
|
|
240
|
-
default:
|
|
241
|
-
}
|
|
282
|
+
default: void 0
|
|
242
283
|
},
|
|
243
284
|
/**
|
|
244
285
|
* Using tag
|
|
@@ -249,11 +290,27 @@ var oe = Y({
|
|
|
249
290
|
},
|
|
250
291
|
/**
|
|
251
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
|
+
*
|
|
252
298
|
* @see {@link https://codemirror.net/docs/ref/#state.TransactionSpec.scrollIntoView}
|
|
253
299
|
*/
|
|
254
300
|
scrollIntoView: {
|
|
255
301
|
type: Boolean,
|
|
256
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: () => []
|
|
257
314
|
}
|
|
258
315
|
},
|
|
259
316
|
/** Emits */
|
|
@@ -278,43 +335,42 @@ var oe = Y({
|
|
|
278
335
|
* @param context - Context
|
|
279
336
|
*/
|
|
280
337
|
setup(e, i) {
|
|
281
|
-
const l =
|
|
338
|
+
const l = m(), u = m(e.modelValue), t = te(new c()), f = d({
|
|
282
339
|
get: () => t.value.hasFocus,
|
|
283
340
|
set: (a) => {
|
|
284
341
|
a && t.value.focus();
|
|
285
342
|
}
|
|
286
|
-
}),
|
|
343
|
+
}), v = d({
|
|
287
344
|
get: () => t.value.state.selection,
|
|
288
345
|
set: (a) => t.value.dispatch({ selection: a })
|
|
289
|
-
}),
|
|
346
|
+
}), h = d({
|
|
290
347
|
get: () => t.value.state.selection.main.head,
|
|
291
348
|
set: (a) => t.value.dispatch({ selection: { anchor: a } })
|
|
292
|
-
}),
|
|
349
|
+
}), $ = d(
|
|
293
350
|
{
|
|
294
351
|
get: () => t.value.state.toJSON(),
|
|
295
352
|
set: (a) => t.value.setState(s.fromJSON(a))
|
|
296
353
|
}
|
|
297
|
-
),
|
|
298
|
-
const a = new
|
|
354
|
+
), p = m(0), g = m(0), y = d(() => {
|
|
355
|
+
const a = new C(), n = new C();
|
|
299
356
|
if (e.basic && e.minimal)
|
|
300
357
|
throw new Error(
|
|
301
358
|
"[Vue CodeMirror] Both basic and minimal cannot be specified."
|
|
302
359
|
);
|
|
303
|
-
|
|
360
|
+
let o = [];
|
|
361
|
+
return e.keymap && e.keymap.length > 0 && (o = e.keymap), e.tab && o.push(W), [
|
|
304
362
|
// Toggle basic setup
|
|
305
|
-
e.basic && !e.minimal ?
|
|
363
|
+
e.basic && !e.minimal ? Q : void 0,
|
|
306
364
|
// Toggle minimal setup
|
|
307
|
-
e.minimal && !e.basic ?
|
|
365
|
+
e.minimal && !e.basic ? X : void 0,
|
|
308
366
|
// ViewUpdate event listener
|
|
309
|
-
|
|
310
|
-
i.emit("focus", t.value.hasFocus),
|
|
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));
|
|
311
369
|
}),
|
|
312
370
|
// Toggle light/dark mode.
|
|
313
|
-
|
|
371
|
+
c.theme(e.theme, { dark: e.dark }),
|
|
314
372
|
// Toggle line wrapping
|
|
315
|
-
e.wrap ?
|
|
316
|
-
// Indent with tab
|
|
317
|
-
e.tab ? q.of([W]) : void 0,
|
|
373
|
+
e.wrap ? c.lineWrapping : void 0,
|
|
318
374
|
// Tab character
|
|
319
375
|
e.indentUnit ? G.of(e.indentUnit) : void 0,
|
|
320
376
|
// Allow Multiple Selections
|
|
@@ -326,7 +382,7 @@ var oe = Y({
|
|
|
326
382
|
// Readonly option
|
|
327
383
|
s.readOnly.of(e.readonly),
|
|
328
384
|
// Editable option
|
|
329
|
-
|
|
385
|
+
c.editable.of(!e.disabled),
|
|
330
386
|
// Set Line break char
|
|
331
387
|
e.lineSeparator ? s.lineSeparator.of(e.lineSeparator) : void 0,
|
|
332
388
|
// Lang
|
|
@@ -337,15 +393,17 @@ var oe = Y({
|
|
|
337
393
|
e.linter && e.gutter ? Z(e.gutterConfig) : void 0,
|
|
338
394
|
// Placeholder
|
|
339
395
|
e.placeholder ? H(e.placeholder) : void 0,
|
|
396
|
+
// Keymap and Indent with Tab
|
|
397
|
+
o.length !== 0 ? K.of(o) : void 0,
|
|
340
398
|
// Append Extensions
|
|
341
399
|
...e.extensions
|
|
342
|
-
].filter((
|
|
400
|
+
].filter((r) => !!r);
|
|
343
401
|
});
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
(a) => t.value?.dispatch({ effects:
|
|
402
|
+
B(
|
|
403
|
+
y,
|
|
404
|
+
(a) => t.value?.dispatch({ effects: S.reconfigure.of(a) }),
|
|
347
405
|
{ immediate: !0 }
|
|
348
|
-
),
|
|
406
|
+
), B(
|
|
349
407
|
() => e.modelValue,
|
|
350
408
|
async (a) => {
|
|
351
409
|
if (t.value.composing || // IME fix
|
|
@@ -362,33 +420,33 @@ var oe = Y({
|
|
|
362
420
|
});
|
|
363
421
|
},
|
|
364
422
|
{ immediate: !0 }
|
|
365
|
-
),
|
|
423
|
+
), ae(async () => {
|
|
366
424
|
let a = u.value;
|
|
367
425
|
l.value && (l.value.childNodes[0] && (u.value !== "" && console.warn(
|
|
368
426
|
"[CodeMirror.vue] The <code-mirror> tag contains child elements that overwrite the `v-model` values."
|
|
369
|
-
), a = l.value.childNodes[0].innerText.trim()), t.value = new
|
|
427
|
+
), a = l.value.childNodes[0].innerText.trim()), t.value = new c({
|
|
370
428
|
parent: l.value,
|
|
371
|
-
state: s.create({ doc: a, extensions:
|
|
429
|
+
state: s.create({ doc: a, extensions: y.value }),
|
|
372
430
|
dispatch: (n) => {
|
|
373
431
|
t.value.update([n]), !(n.changes.empty || !n.docChanged) && (i.emit("update:modelValue", n.state.doc.toString()), i.emit("change", n.state));
|
|
374
432
|
}
|
|
375
|
-
}), await
|
|
433
|
+
}), await ne(), i.emit("ready", {
|
|
376
434
|
view: t.value,
|
|
377
435
|
state: t.value.state,
|
|
378
436
|
container: l.value
|
|
379
437
|
}));
|
|
380
|
-
}),
|
|
438
|
+
}), le(() => {
|
|
381
439
|
t.value.destroy(), i.emit("destroy");
|
|
382
440
|
});
|
|
383
|
-
const
|
|
384
|
-
!e.linter || !t.value || (e.forceLinting &&
|
|
385
|
-
},
|
|
441
|
+
const j = () => {
|
|
442
|
+
!e.linter || !t.value || (e.forceLinting && w(t.value), g.value = q(t.value.state));
|
|
443
|
+
}, x = () => {
|
|
386
444
|
t.value?.dispatch({
|
|
387
|
-
effects:
|
|
445
|
+
effects: S.reconfigure.of([])
|
|
388
446
|
}), t.value?.dispatch({
|
|
389
|
-
effects:
|
|
447
|
+
effects: S.appendConfig.of(y.value)
|
|
390
448
|
});
|
|
391
|
-
},
|
|
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 = () => {
|
|
392
450
|
let a;
|
|
393
451
|
return (a = t.value.state.selection.ranges) !== null && a !== void 0 ? a : [];
|
|
394
452
|
}, z = () => {
|
|
@@ -406,44 +464,44 @@ var oe = Y({
|
|
|
406
464
|
(a) => !a.empty
|
|
407
465
|
), T = (a, n, o) => t.value.dispatch({
|
|
408
466
|
changes: { from: n, to: o, insert: a }
|
|
409
|
-
}), D = (a) => t.value.dispatch(t.value.state.replaceSelection(a)),
|
|
410
|
-
selection:
|
|
411
|
-
}),
|
|
412
|
-
selection:
|
|
413
|
-
|
|
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)))
|
|
414
472
|
)
|
|
415
|
-
}),
|
|
473
|
+
}), b = {
|
|
416
474
|
editor: l,
|
|
417
475
|
view: t,
|
|
418
|
-
cursor:
|
|
419
|
-
selection:
|
|
420
|
-
focus:
|
|
421
|
-
length:
|
|
422
|
-
json:
|
|
423
|
-
diagnosticCount:
|
|
476
|
+
cursor: h,
|
|
477
|
+
selection: v,
|
|
478
|
+
focus: f,
|
|
479
|
+
length: p,
|
|
480
|
+
json: $,
|
|
481
|
+
diagnosticCount: g,
|
|
424
482
|
dom: t.value.contentDOM,
|
|
425
|
-
lint:
|
|
426
|
-
forceReconfigure:
|
|
483
|
+
lint: j,
|
|
484
|
+
forceReconfigure: x,
|
|
427
485
|
// Bellow is CodeMirror5's function
|
|
428
|
-
getRange:
|
|
429
|
-
getLine:
|
|
430
|
-
lineCount:
|
|
431
|
-
getCursor:
|
|
432
|
-
listSelections:
|
|
486
|
+
getRange: _,
|
|
487
|
+
getLine: L,
|
|
488
|
+
lineCount: N,
|
|
489
|
+
getCursor: U,
|
|
490
|
+
listSelections: k,
|
|
433
491
|
getSelection: z,
|
|
434
492
|
getSelections: E,
|
|
435
493
|
somethingSelected: R,
|
|
436
494
|
replaceRange: T,
|
|
437
495
|
replaceSelection: D,
|
|
438
|
-
setCursor:
|
|
439
|
-
setSelection:
|
|
440
|
-
setSelections:
|
|
441
|
-
extendSelectionsBy:
|
|
496
|
+
setCursor: A,
|
|
497
|
+
setSelection: F,
|
|
498
|
+
setSelections: I,
|
|
499
|
+
extendSelectionsBy: J
|
|
442
500
|
};
|
|
443
|
-
return i.expose(
|
|
501
|
+
return i.expose(b), b;
|
|
444
502
|
},
|
|
445
503
|
render() {
|
|
446
|
-
return
|
|
504
|
+
return M(
|
|
447
505
|
this.$props.tag,
|
|
448
506
|
{
|
|
449
507
|
ref: "editor",
|
|
@@ -451,18 +509,18 @@ var oe = Y({
|
|
|
451
509
|
},
|
|
452
510
|
this.$slots.default ? (
|
|
453
511
|
// Hide original content
|
|
454
|
-
|
|
512
|
+
M(
|
|
455
513
|
"aside",
|
|
456
514
|
{ style: "display: none;", "aria-hidden": "true" },
|
|
457
|
-
|
|
515
|
+
oe(this.$slots.default)
|
|
458
516
|
)
|
|
459
517
|
) : void 0
|
|
460
518
|
);
|
|
461
519
|
}
|
|
462
520
|
});
|
|
463
|
-
const
|
|
521
|
+
const ge = (e) => e.component("CodeMirror", se);
|
|
464
522
|
export {
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
523
|
+
he as Meta,
|
|
524
|
+
se as default,
|
|
525
|
+
ge as install
|
|
468
526
|
};
|
package/dist/index.iife.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.
|
|
8
|
+
* @version 1.3.18
|
|
9
9
|
* @see {@link https://github.com/logue/vue-codemirror6}
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
var CodeMirror=function(u,
|
|
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
|
|
12
|
+
var CodeMirror=function(u,E,O,f,i,d,b,l){"use strict";const M={version:"1.3.18",date:"2025-06-09T13:13:13.017Z"},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.
|
|
8
|
+
* @version 1.3.18
|
|
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,
|
|
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}),
|
|
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.18",date:"2025-06-09T13:13:13.017Z"},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.
|
|
4
|
+
"version": "1.3.18",
|
|
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.
|
|
59
|
+
"packageManager": "pnpm@10.12.1",
|
|
60
60
|
"sideEffects": false,
|
|
61
61
|
"scripts": {
|
|
62
62
|
"dev": "vite",
|
|
@@ -73,28 +73,27 @@
|
|
|
73
73
|
"version": "auto-changelog -p && git add CHANGELOG.md"
|
|
74
74
|
},
|
|
75
75
|
"dependencies": {
|
|
76
|
+
"@codemirror/autocomplete": "^6.18.6",
|
|
76
77
|
"@codemirror/commands": "^6.8.1",
|
|
77
|
-
"@codemirror/language": "^6.11.
|
|
78
|
+
"@codemirror/language": "^6.11.1",
|
|
78
79
|
"@codemirror/lint": "^6.8.5",
|
|
80
|
+
"@codemirror/search": "^6.5.11",
|
|
79
81
|
"@codemirror/state": "^6.5.2",
|
|
80
82
|
"@codemirror/view": "^6.37.1",
|
|
81
83
|
"codemirror": "^6.0.1",
|
|
82
84
|
"style-mod": "^4.1.2",
|
|
83
|
-
"vue-codemirror6": "file:",
|
|
84
85
|
"vue-demi": "latest"
|
|
85
86
|
},
|
|
86
87
|
"peerDependencies": {
|
|
87
88
|
"vue": "^2.7.14 || ^3.4"
|
|
88
89
|
},
|
|
89
90
|
"devDependencies": {
|
|
90
|
-
"@codemirror/autocomplete": "^6.18.6",
|
|
91
91
|
"@codemirror/lang-javascript": "^6.2.4",
|
|
92
92
|
"@codemirror/lang-json": "^6.0.1",
|
|
93
93
|
"@codemirror/lang-markdown": "^6.3.2",
|
|
94
94
|
"@codemirror/lang-vue": "^0.1.3",
|
|
95
|
-
"@codemirror/search": "^6.5.11",
|
|
96
95
|
"@tsconfig/node-lts": "^22.0.1",
|
|
97
|
-
"@types/node": "^22.15.
|
|
96
|
+
"@types/node": "^22.15.30",
|
|
98
97
|
"@vitejs/plugin-vue": "^5.2.4",
|
|
99
98
|
"@vue/compiler-sfc": "^3.5.16",
|
|
100
99
|
"@vue/eslint-config-prettier": "^10.2.0",
|
|
@@ -105,11 +104,11 @@
|
|
|
105
104
|
"bootstrap": "^5.3.6",
|
|
106
105
|
"eslint": "^9.28.0",
|
|
107
106
|
"eslint-import-resolver-custom-alias": "^1.3.2",
|
|
108
|
-
"eslint-import-resolver-typescript": "^4.4.
|
|
107
|
+
"eslint-import-resolver-typescript": "^4.4.3",
|
|
109
108
|
"eslint-linter-browserify": "^9.28.0",
|
|
110
109
|
"eslint-plugin-import": "^2.31.0",
|
|
111
110
|
"eslint-plugin-playwright": "^2.2.0",
|
|
112
|
-
"eslint-plugin-vue": "^10.
|
|
111
|
+
"eslint-plugin-vue": "^10.2.0",
|
|
113
112
|
"eslint-plugin-vuejs-accessibility": "^2.4.1",
|
|
114
113
|
"husky": "^9.1.7",
|
|
115
114
|
"jiti": "^2.4.2",
|
|
@@ -117,11 +116,11 @@
|
|
|
117
116
|
"npm-run-all2": "^8.0.4",
|
|
118
117
|
"prettier": "^3.5.3",
|
|
119
118
|
"rimraf": "^6.0.1",
|
|
120
|
-
"rollup-plugin-visualizer": "^6.0.
|
|
121
|
-
"sass": "^1.89.1",
|
|
119
|
+
"rollup-plugin-visualizer": "^6.0.3",
|
|
120
|
+
"sass-embedded": "^1.89.1",
|
|
122
121
|
"supports-color": "^10.0.0",
|
|
123
122
|
"typescript": "^5.8.3",
|
|
124
|
-
"typescript-eslint": "^8.33.
|
|
123
|
+
"typescript-eslint": "^8.33.1",
|
|
125
124
|
"vite": "^6.3.5",
|
|
126
125
|
"vite-plugin-banner": "^0.8.1",
|
|
127
126
|
"vite-plugin-checker": "^0.9.3",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { indentWithTab } from '@codemirror/commands';
|
|
2
2
|
import { indentUnit, type LanguageSupport } from '@codemirror/language';
|
|
3
3
|
import {
|
|
4
|
-
diagnosticCount as
|
|
4
|
+
diagnosticCount as linterDiagnosticCount,
|
|
5
5
|
forceLinting,
|
|
6
6
|
linter,
|
|
7
7
|
lintGutter,
|
|
@@ -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,24 +216,37 @@ 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: {
|
|
200
226
|
type: Object as PropType<Record<string, string>>,
|
|
201
|
-
default:
|
|
227
|
+
default: undefined,
|
|
202
228
|
},
|
|
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: {
|
|
209
239
|
type: Object as PropType<LanguageSupport>,
|
|
210
|
-
default:
|
|
240
|
+
default: undefined,
|
|
211
241
|
},
|
|
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,11 +294,15 @@ 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: {
|
|
259
304
|
type: Object,
|
|
260
|
-
default:
|
|
305
|
+
default: undefined,
|
|
261
306
|
},
|
|
262
307
|
/**
|
|
263
308
|
* Using tag
|
|
@@ -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
|
|
@@ -545,7 +617,7 @@ export default defineComponent({
|
|
|
545
617
|
if (props.forceLinting) {
|
|
546
618
|
forceLinting(view.value);
|
|
547
619
|
}
|
|
548
|
-
diagnosticCount.value =
|
|
620
|
+
diagnosticCount.value = linterDiagnosticCount(view.value.state);
|
|
549
621
|
};
|
|
550
622
|
|
|
551
623
|
/**
|