vue-codemirror6 1.3.15 → 1.3.17
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 +2 -13
- package/dist/components/CodeMirror.d.ts +6 -6
- package/dist/index.es.js +31 -36
- package/dist/index.iife.js +3 -3
- package/dist/index.umd.js +3 -3
- package/package.json +16 -17
- package/src/components/CodeMirror.ts +12 -16
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
|
@@ -203,7 +203,7 @@ export default defineComponent({
|
|
|
203
203
|
|
|
204
204
|
### Full Example
|
|
205
205
|
|
|
206
|
-
When using as a Markdown editor on [
|
|
206
|
+
When using as a Markdown editor on [vite-vue3-ts-starter](https://github.com/logue/vite-vue3-ts-starter).
|
|
207
207
|
|
|
208
208
|
```vue
|
|
209
209
|
<script lang="ts" setup>
|
|
@@ -361,18 +361,7 @@ const config: UserConfig = {
|
|
|
361
361
|
output: {
|
|
362
362
|
manualChunks: {
|
|
363
363
|
// ...
|
|
364
|
-
codemirror: [
|
|
365
|
-
// Split CodeMirror code.
|
|
366
|
-
'vue-codemirror6',
|
|
367
|
-
'codemirror',
|
|
368
|
-
'@codemirror/autocomplete',
|
|
369
|
-
'@codemirror/commands',
|
|
370
|
-
'@codemirror/language',
|
|
371
|
-
'@codemirror/lint',
|
|
372
|
-
'@codemirror/search',
|
|
373
|
-
'@codemirror/state',
|
|
374
|
-
'@codemirror/view',
|
|
375
|
-
],
|
|
364
|
+
codemirror: ['vue-codemirror6'],
|
|
376
365
|
'codemirror-lang': [
|
|
377
366
|
// Add the following as needed.
|
|
378
367
|
'@codemirror/lang-html',
|
|
@@ -143,7 +143,7 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
|
|
|
143
143
|
*/
|
|
144
144
|
phrases: {
|
|
145
145
|
type: PropType<Record<string, string>>;
|
|
146
|
-
default:
|
|
146
|
+
default: undefined;
|
|
147
147
|
};
|
|
148
148
|
/**
|
|
149
149
|
* CodeMirror Language
|
|
@@ -152,7 +152,7 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
|
|
|
152
152
|
*/
|
|
153
153
|
lang: {
|
|
154
154
|
type: PropType<LanguageSupport>;
|
|
155
|
-
default:
|
|
155
|
+
default: undefined;
|
|
156
156
|
};
|
|
157
157
|
/**
|
|
158
158
|
* CodeMirror Linter
|
|
@@ -200,7 +200,7 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
|
|
|
200
200
|
*/
|
|
201
201
|
gutterConfig: {
|
|
202
202
|
type: ObjectConstructor;
|
|
203
|
-
default:
|
|
203
|
+
default: undefined;
|
|
204
204
|
};
|
|
205
205
|
/**
|
|
206
206
|
* Using tag
|
|
@@ -398,7 +398,7 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
|
|
|
398
398
|
*/
|
|
399
399
|
phrases: {
|
|
400
400
|
type: PropType<Record<string, string>>;
|
|
401
|
-
default:
|
|
401
|
+
default: undefined;
|
|
402
402
|
};
|
|
403
403
|
/**
|
|
404
404
|
* CodeMirror Language
|
|
@@ -407,7 +407,7 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
|
|
|
407
407
|
*/
|
|
408
408
|
lang: {
|
|
409
409
|
type: PropType<LanguageSupport>;
|
|
410
|
-
default:
|
|
410
|
+
default: undefined;
|
|
411
411
|
};
|
|
412
412
|
/**
|
|
413
413
|
* CodeMirror Linter
|
|
@@ -455,7 +455,7 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
|
|
|
455
455
|
*/
|
|
456
456
|
gutterConfig: {
|
|
457
457
|
type: ObjectConstructor;
|
|
458
|
-
default:
|
|
458
|
+
default: undefined;
|
|
459
459
|
};
|
|
460
460
|
/**
|
|
461
461
|
* Using tag
|
package/dist/index.es.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
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.17
|
|
9
9
|
* @see {@link https://github.com/logue/vue-codemirror6}
|
|
10
10
|
*/
|
|
11
11
|
|
|
@@ -13,12 +13,12 @@ import { indentWithTab as W } from "@codemirror/commands";
|
|
|
13
13
|
import { indentUnit as G } from "@codemirror/language";
|
|
14
14
|
import { linter as P, lintGutter as Z, forceLinting as b, diagnosticCount as k } from "@codemirror/lint";
|
|
15
15
|
import { EditorState as s, Compartment as w, StateEffect as y, EditorSelection as C } from "@codemirror/state";
|
|
16
|
-
import { EditorView as
|
|
16
|
+
import { EditorView as r, keymap as q, placeholder as H } from "@codemirror/view";
|
|
17
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
|
|
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
19
|
const me = {
|
|
20
|
-
version: "1.3.
|
|
21
|
-
date: "2025-
|
|
20
|
+
version: "1.3.17",
|
|
21
|
+
date: "2025-06-02T14:16:10.878Z"
|
|
22
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
23
|
function B(e, i = {}, l) {
|
|
24
24
|
if (X)
|
|
@@ -178,8 +178,7 @@ var oe = Y({
|
|
|
178
178
|
*/
|
|
179
179
|
phrases: {
|
|
180
180
|
type: Object,
|
|
181
|
-
default:
|
|
182
|
-
}
|
|
181
|
+
default: void 0
|
|
183
182
|
},
|
|
184
183
|
/**
|
|
185
184
|
* CodeMirror Language
|
|
@@ -188,8 +187,7 @@ var oe = Y({
|
|
|
188
187
|
*/
|
|
189
188
|
lang: {
|
|
190
189
|
type: Object,
|
|
191
|
-
default:
|
|
192
|
-
}
|
|
190
|
+
default: void 0
|
|
193
191
|
},
|
|
194
192
|
/**
|
|
195
193
|
* CodeMirror Linter
|
|
@@ -237,8 +235,7 @@ var oe = Y({
|
|
|
237
235
|
*/
|
|
238
236
|
gutterConfig: {
|
|
239
237
|
type: Object,
|
|
240
|
-
default:
|
|
241
|
-
}
|
|
238
|
+
default: void 0
|
|
242
239
|
},
|
|
243
240
|
/**
|
|
244
241
|
* Using tag
|
|
@@ -278,39 +275,41 @@ var oe = Y({
|
|
|
278
275
|
* @param context - Context
|
|
279
276
|
*/
|
|
280
277
|
setup(e, i) {
|
|
281
|
-
const l = v(), u = v(e.modelValue), t = ee(new
|
|
278
|
+
const l = v(), u = v(e.modelValue), t = ee(new r()), d = c({
|
|
282
279
|
get: () => t.value.hasFocus,
|
|
283
280
|
set: (a) => {
|
|
284
281
|
a && t.value.focus();
|
|
285
282
|
}
|
|
286
|
-
}), f =
|
|
283
|
+
}), f = c({
|
|
287
284
|
get: () => t.value.state.selection,
|
|
288
285
|
set: (a) => t.value.dispatch({ selection: a })
|
|
289
|
-
}), m =
|
|
286
|
+
}), m = c({
|
|
290
287
|
get: () => t.value.state.selection.main.head,
|
|
291
288
|
set: (a) => t.value.dispatch({ selection: { anchor: a } })
|
|
292
|
-
}), M =
|
|
289
|
+
}), M = c(
|
|
293
290
|
{
|
|
294
291
|
get: () => t.value.state.toJSON(),
|
|
295
292
|
set: (a) => t.value.setState(s.fromJSON(a))
|
|
296
293
|
}
|
|
297
|
-
), S = v(0), h = v(0), g =
|
|
294
|
+
), S = v(0), h = v(0), g = c(() => {
|
|
298
295
|
const a = new w(), n = new w();
|
|
299
296
|
if (e.basic && e.minimal)
|
|
300
|
-
throw
|
|
297
|
+
throw new Error(
|
|
298
|
+
"[Vue CodeMirror] Both basic and minimal cannot be specified."
|
|
299
|
+
);
|
|
301
300
|
return [
|
|
302
301
|
// Toggle basic setup
|
|
303
302
|
e.basic && !e.minimal ? K : void 0,
|
|
304
303
|
// Toggle minimal setup
|
|
305
304
|
e.minimal && !e.basic ? Q : void 0,
|
|
306
305
|
// ViewUpdate event listener
|
|
307
|
-
|
|
306
|
+
r.updateListener.of((o) => {
|
|
308
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));
|
|
309
308
|
}),
|
|
310
309
|
// Toggle light/dark mode.
|
|
311
|
-
|
|
310
|
+
r.theme(e.theme, { dark: e.dark }),
|
|
312
311
|
// Toggle line wrapping
|
|
313
|
-
e.wrap ?
|
|
312
|
+
e.wrap ? r.lineWrapping : void 0,
|
|
314
313
|
// Indent with tab
|
|
315
314
|
e.tab ? q.of([W]) : void 0,
|
|
316
315
|
// Tab character
|
|
@@ -324,7 +323,7 @@ var oe = Y({
|
|
|
324
323
|
// Readonly option
|
|
325
324
|
s.readOnly.of(e.readonly),
|
|
326
325
|
// Editable option
|
|
327
|
-
|
|
326
|
+
r.editable.of(!e.disabled),
|
|
328
327
|
// Set Line break char
|
|
329
328
|
e.lineSeparator ? s.lineSeparator.of(e.lineSeparator) : void 0,
|
|
330
329
|
// Lang
|
|
@@ -341,11 +340,7 @@ var oe = Y({
|
|
|
341
340
|
});
|
|
342
341
|
V(
|
|
343
342
|
g,
|
|
344
|
-
(a) => {
|
|
345
|
-
t.value?.dispatch({
|
|
346
|
-
effects: y.reconfigure.of(a)
|
|
347
|
-
});
|
|
348
|
-
},
|
|
343
|
+
(a) => t.value?.dispatch({ effects: y.reconfigure.of(a) }),
|
|
349
344
|
{ immediate: !0 }
|
|
350
345
|
), V(
|
|
351
346
|
() => e.modelValue,
|
|
@@ -368,11 +363,11 @@ var oe = Y({
|
|
|
368
363
|
let a = u.value;
|
|
369
364
|
l.value && (l.value.childNodes[0] && (u.value !== "" && console.warn(
|
|
370
365
|
"[CodeMirror.vue] The <code-mirror> tag contains child elements that overwrite the `v-model` values."
|
|
371
|
-
), a = l.value.childNodes[0].innerText.trim()), t.value = new
|
|
366
|
+
), a = l.value.childNodes[0].innerText.trim()), t.value = new r({
|
|
372
367
|
parent: l.value,
|
|
373
368
|
state: s.create({ doc: a, extensions: g.value }),
|
|
374
369
|
dispatch: (n) => {
|
|
375
|
-
t.value.update([n]), !(n.changes.empty || !n.docChanged) && (i.emit("update:modelValue", n.state.doc.toString()
|
|
370
|
+
t.value.update([n]), !(n.changes.empty || !n.docChanged) && (i.emit("update:modelValue", n.state.doc.toString()), i.emit("change", n.state));
|
|
376
371
|
}
|
|
377
372
|
}), await ae(), i.emit("ready", {
|
|
378
373
|
view: t.value,
|
|
@@ -399,16 +394,16 @@ var oe = Y({
|
|
|
399
394
|
t.value.state.selection.main.from,
|
|
400
395
|
t.value.state.selection.main.to
|
|
401
396
|
)) !== null && a !== void 0 ? a : "";
|
|
402
|
-
},
|
|
397
|
+
}, E = () => {
|
|
403
398
|
const a = t.value.state;
|
|
404
399
|
return a ? a.selection.ranges.map(
|
|
405
400
|
(n) => a.sliceDoc(n.from, n.to)
|
|
406
401
|
) : [];
|
|
407
|
-
},
|
|
402
|
+
}, R = () => t.value.state.selection.ranges.some(
|
|
408
403
|
(a) => !a.empty
|
|
409
|
-
),
|
|
404
|
+
), T = (a, n, o) => t.value.dispatch({
|
|
410
405
|
changes: { from: n, to: o, insert: a }
|
|
411
|
-
}),
|
|
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({
|
|
412
407
|
selection: C.create(a, n)
|
|
413
408
|
}), A = (a) => t.value.dispatch({
|
|
414
409
|
selection: C.create(
|
|
@@ -433,10 +428,10 @@ var oe = Y({
|
|
|
433
428
|
getCursor: N,
|
|
434
429
|
listSelections: U,
|
|
435
430
|
getSelection: z,
|
|
436
|
-
getSelections:
|
|
437
|
-
somethingSelected:
|
|
438
|
-
replaceRange:
|
|
439
|
-
replaceSelection:
|
|
431
|
+
getSelections: E,
|
|
432
|
+
somethingSelected: R,
|
|
433
|
+
replaceRange: T,
|
|
434
|
+
replaceSelection: D,
|
|
440
435
|
setCursor: F,
|
|
441
436
|
setSelection: I,
|
|
442
437
|
setSelections: J,
|
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.17
|
|
9
9
|
* @see {@link https://github.com/logue/vue-codemirror6}
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
var CodeMirror=function(u,V,E,f,i,
|
|
13
|
-
`)===a)return;const n=!t.value.state.selection.ranges.every(
|
|
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);
|
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.17
|
|
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.
|
|
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()
|
|
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})});
|
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.17",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "CodeMirror6 Component for vue2 and vue3.",
|
|
7
7
|
"keywords": [
|
|
@@ -73,60 +73,59 @@
|
|
|
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
78
|
"@codemirror/language": "^6.11.0",
|
|
78
79
|
"@codemirror/lint": "^6.8.5",
|
|
80
|
+
"@codemirror/search": "^6.5.11",
|
|
79
81
|
"@codemirror/state": "^6.5.2",
|
|
80
|
-
"@codemirror/view": "^6.
|
|
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.29",
|
|
98
97
|
"@vitejs/plugin-vue": "^5.2.4",
|
|
99
|
-
"@vue/compiler-sfc": "^3.5.
|
|
98
|
+
"@vue/compiler-sfc": "^3.5.16",
|
|
100
99
|
"@vue/eslint-config-prettier": "^10.2.0",
|
|
101
100
|
"@vue/eslint-config-typescript": "^14.5.0",
|
|
102
101
|
"@vue/test-utils": "^2.4.6",
|
|
103
102
|
"@vue/tsconfig": "^0.7.0",
|
|
104
|
-
"@vueuse/core": "^13.
|
|
103
|
+
"@vueuse/core": "^13.3.0",
|
|
105
104
|
"bootstrap": "^5.3.6",
|
|
106
|
-
"eslint": "^9.
|
|
105
|
+
"eslint": "^9.28.0",
|
|
107
106
|
"eslint-import-resolver-custom-alias": "^1.3.2",
|
|
108
|
-
"eslint-import-resolver-typescript": "^4.
|
|
109
|
-
"eslint-linter-browserify": "^9.
|
|
107
|
+
"eslint-import-resolver-typescript": "^4.4.2",
|
|
108
|
+
"eslint-linter-browserify": "^9.28.0",
|
|
110
109
|
"eslint-plugin-import": "^2.31.0",
|
|
111
110
|
"eslint-plugin-playwright": "^2.2.0",
|
|
112
111
|
"eslint-plugin-vue": "^10.1.0",
|
|
113
112
|
"eslint-plugin-vuejs-accessibility": "^2.4.1",
|
|
114
113
|
"husky": "^9.1.7",
|
|
115
114
|
"jiti": "^2.4.2",
|
|
116
|
-
"lint-staged": "^16.
|
|
117
|
-
"npm-run-all2": "^8.0.
|
|
115
|
+
"lint-staged": "^16.1.0",
|
|
116
|
+
"npm-run-all2": "^8.0.4",
|
|
118
117
|
"prettier": "^3.5.3",
|
|
119
118
|
"rimraf": "^6.0.1",
|
|
120
|
-
"rollup-plugin-visualizer": "^
|
|
121
|
-
"sass": "^1.89.
|
|
119
|
+
"rollup-plugin-visualizer": "^6.0.1",
|
|
120
|
+
"sass": "^1.89.1",
|
|
122
121
|
"supports-color": "^10.0.0",
|
|
123
122
|
"typescript": "^5.8.3",
|
|
124
|
-
"typescript-eslint": "^8.
|
|
123
|
+
"typescript-eslint": "^8.33.0",
|
|
125
124
|
"vite": "^6.3.5",
|
|
126
125
|
"vite-plugin-banner": "^0.8.1",
|
|
127
126
|
"vite-plugin-checker": "^0.9.3",
|
|
128
127
|
"vite-plugin-dts": "^4.5.4",
|
|
129
|
-
"vue": "^3.5.
|
|
128
|
+
"vue": "^3.5.16",
|
|
130
129
|
"vue-eslint-parser": "^10.1.3",
|
|
131
130
|
"vue-markdown-wasm": "^0.5.1",
|
|
132
131
|
"vue-tsc": "^2.2.10"
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
// Helpers
|
|
2
|
-
|
|
3
|
-
// CodeMirror
|
|
4
1
|
import { indentWithTab } from '@codemirror/commands';
|
|
5
2
|
import { indentUnit, type LanguageSupport } from '@codemirror/language';
|
|
6
3
|
import {
|
|
7
|
-
diagnosticCount as
|
|
4
|
+
diagnosticCount as linterDiagnosticCount,
|
|
8
5
|
forceLinting,
|
|
9
6
|
linter,
|
|
10
7
|
lintGutter,
|
|
@@ -201,7 +198,7 @@ export default defineComponent({
|
|
|
201
198
|
*/
|
|
202
199
|
phrases: {
|
|
203
200
|
type: Object as PropType<Record<string, string>>,
|
|
204
|
-
default:
|
|
201
|
+
default: undefined,
|
|
205
202
|
},
|
|
206
203
|
/**
|
|
207
204
|
* CodeMirror Language
|
|
@@ -210,7 +207,7 @@ export default defineComponent({
|
|
|
210
207
|
*/
|
|
211
208
|
lang: {
|
|
212
209
|
type: Object as PropType<LanguageSupport>,
|
|
213
|
-
default:
|
|
210
|
+
default: undefined,
|
|
214
211
|
},
|
|
215
212
|
/**
|
|
216
213
|
* CodeMirror Linter
|
|
@@ -260,7 +257,7 @@ export default defineComponent({
|
|
|
260
257
|
*/
|
|
261
258
|
gutterConfig: {
|
|
262
259
|
type: Object,
|
|
263
|
-
default:
|
|
260
|
+
default: undefined,
|
|
264
261
|
},
|
|
265
262
|
/**
|
|
266
263
|
* Using tag
|
|
@@ -372,7 +369,9 @@ export default defineComponent({
|
|
|
372
369
|
const language = new Compartment();
|
|
373
370
|
const tabSize = new Compartment();
|
|
374
371
|
if (props.basic && props.minimal) {
|
|
375
|
-
throw
|
|
372
|
+
throw new Error(
|
|
373
|
+
'[Vue CodeMirror] Both basic and minimal cannot be specified.'
|
|
374
|
+
);
|
|
376
375
|
}
|
|
377
376
|
// TODO: Ignore previous prop was not changed.
|
|
378
377
|
return [
|
|
@@ -441,17 +440,14 @@ export default defineComponent({
|
|
|
441
440
|
props.placeholder ? placeholder(props.placeholder) : undefined,
|
|
442
441
|
// Append Extensions
|
|
443
442
|
...props.extensions,
|
|
444
|
-
].filter((extension): extension is Extension => !!extension);
|
|
443
|
+
].filter((extension): extension is Extension => !!extension); // Filter undefined
|
|
445
444
|
});
|
|
446
445
|
|
|
447
446
|
// Extension (mostly props) Changed
|
|
448
447
|
watch(
|
|
449
448
|
extensions,
|
|
450
|
-
exts =>
|
|
451
|
-
view.value?.dispatch({
|
|
452
|
-
effects: StateEffect.reconfigure.of(exts),
|
|
453
|
-
});
|
|
454
|
-
},
|
|
449
|
+
exts =>
|
|
450
|
+
view.value?.dispatch({ effects: StateEffect.reconfigure.of(exts) }),
|
|
455
451
|
{ immediate: true }
|
|
456
452
|
);
|
|
457
453
|
|
|
@@ -516,7 +512,7 @@ export default defineComponent({
|
|
|
516
512
|
|
|
517
513
|
// console.log(view.state.doc.toString(), tr);
|
|
518
514
|
// state.toString() is not defined, so use toJSON and toText function to convert string.
|
|
519
|
-
context.emit('update:modelValue', tr.state.doc.toString()
|
|
515
|
+
context.emit('update:modelValue', tr.state.doc.toString());
|
|
520
516
|
// Emit EditorState
|
|
521
517
|
context.emit('change', tr.state);
|
|
522
518
|
},
|
|
@@ -549,7 +545,7 @@ export default defineComponent({
|
|
|
549
545
|
if (props.forceLinting) {
|
|
550
546
|
forceLinting(view.value);
|
|
551
547
|
}
|
|
552
|
-
diagnosticCount.value =
|
|
548
|
+
diagnosticCount.value = linterDiagnosticCount(view.value.state);
|
|
553
549
|
};
|
|
554
550
|
|
|
555
551
|
/**
|