vue-codemirror6 1.3.22 → 1.4.1

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/dist/index.es.js CHANGED
@@ -5,33 +5,32 @@
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.22
8
+ * @version 1.4.1
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
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";
15
+ import { EditorState as u, Compartment as C, StateEffect as S, EditorSelection as O } from "@codemirror/state";
16
+ import { EditorView as d, placeholder as H, keymap as K } from "@codemirror/view";
17
17
  import { basicSetup as Q, minimalSetup as X } from "codemirror";
18
- 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";
18
+ import { isVue2 as Y, h as V, defineComponent as ee, ref as m, shallowRef as te, computed as f, watch as B, onMounted as ae, nextTick as ne, onUnmounted as ie } from "vue-demi";
19
19
  const he = {
20
- version: "1.3.22",
21
- date: "2025-07-12T05:13:58.540Z"
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) {
20
+ version: "1.4.1",
21
+ date: "2025-10-17T22:30:13.688Z"
22
+ }, le = (t) => t ? Object.entries(t).reduce((l, [i, s]) => (i = i.charAt(0).toUpperCase() + i.slice(1), i = `on${i}`, { ...l, [i]: s }), {}) : {};
23
+ function M(t, l = {}, i) {
24
24
  if (Y)
25
- return V(e, i, l);
26
- const { props: u, domProps: t, on: f, ...v } = i, h = f ? ie(f) : {};
25
+ return V(t, l, i);
26
+ const { props: s, domProps: e, on: v, ...r } = l, h = v ? le(v) : {};
27
27
  return V(
28
- e,
29
- { ...v, ...u, ...t, ...h },
30
- l
28
+ t,
29
+ { ...r, ...s, ...e, ...h },
30
+ i
31
31
  );
32
32
  }
33
- const oe = (e) => typeof e == "function" ? e() : e;
34
- var se = ee({
33
+ const oe = (t) => typeof t == "function" ? t() : t, ue = ee({
35
34
  /** Component Name */
36
35
  name: "CodeMirror",
37
36
  /** Model Definition */
@@ -63,6 +62,8 @@ var se = ee({
63
62
  /**
64
63
  * Use Basic Setup
65
64
  *
65
+ * This will enable the basic setup for the editor.
66
+ *
66
67
  * @see {@link https://codemirror.net/docs/ref/#codemirror.basicSetup}
67
68
  */
68
69
  basic: {
@@ -101,6 +102,8 @@ var se = ee({
101
102
  /**
102
103
  * Allow tab key indent.
103
104
  *
105
+ * This will enable the tab key to indent the current line or selection.
106
+ *
104
107
  * @see {@link https://codemirror.net/examples/tab/}
105
108
  */
106
109
  tab: {
@@ -109,6 +112,7 @@ var se = ee({
109
112
  },
110
113
  /**
111
114
  * Tab character
115
+ *
112
116
  * This is the unit of indentation used when the editor is configured to indent with tabs.
113
117
  * It is also used to determine the size of the tab character when the editor is configured to use tabs for indentation..
114
118
  *
@@ -120,6 +124,7 @@ var se = ee({
120
124
  },
121
125
  /**
122
126
  * Allow Multiple Selection.
127
+ *
123
128
  * This allows the editor to have multiple selections at the same time.
124
129
  * This is useful for editing multiple parts of the document at once.
125
130
  * If this is set to true, the editor will allow multiple selections.
@@ -133,6 +138,7 @@ var se = ee({
133
138
  },
134
139
  /**
135
140
  * Tab size
141
+ *
136
142
  * This is the number of spaces that a tab character represents in the editor.
137
143
  * It is used to determine the size of the tab character when the editor is configured to use tabs for indentation.
138
144
  * If this is set to a number, the editor will use that number of spaces for each tab character.
@@ -316,15 +322,15 @@ var se = ee({
316
322
  /** Emits */
317
323
  emits: {
318
324
  /** Model Update */
319
- "update:modelValue": (e = "") => !0,
325
+ "update:modelValue": (t = "") => !0,
320
326
  /** CodeMirror ViewUpdate */
321
- update: (e) => !0,
327
+ update: (t) => !0,
322
328
  /** CodeMirror onReady */
323
- ready: (e) => !0,
329
+ ready: (t) => !0,
324
330
  /** CodeMirror onFocus */
325
- focus: (e) => !0,
331
+ focus: (t) => !0,
326
332
  /** State Changed */
327
- change: (e) => !0,
333
+ change: (t) => !0,
328
334
  /** CodeMirror onDestroy */
329
335
  destroy: () => !0
330
336
  },
@@ -334,171 +340,183 @@ var se = ee({
334
340
  * @param props - Props
335
341
  * @param context - Context
336
342
  */
337
- setup(e, i) {
338
- const l = m(), u = m(e.modelValue), t = te(new c()), f = d({
339
- get: () => t.value.hasFocus,
343
+ setup(t, l) {
344
+ const i = m(), s = m(t.modelValue), e = te(void 0), v = f({
345
+ get: () => e.value?.hasFocus ?? !1,
340
346
  set: (a) => {
341
- a && t.value.focus();
347
+ a && e.value && e.value.focus();
342
348
  }
343
- }), v = d({
344
- get: () => t.value.state.selection,
345
- set: (a) => t.value.dispatch({ selection: a })
346
- }), h = d({
347
- get: () => t.value.state.selection.main.head,
348
- set: (a) => t.value.dispatch({ selection: { anchor: a } })
349
- }), $ = d(
350
- {
351
- get: () => t.value.state.toJSON(),
352
- set: (a) => t.value.setState(s.fromJSON(a))
349
+ }), r = f({
350
+ get: () => e.value?.state.selection,
351
+ set: (a) => {
352
+ e.value && a && e.value.dispatch({ selection: a });
353
+ }
354
+ }), h = f({
355
+ get: () => e.value?.state.selection.main.head ?? 0,
356
+ set: (a) => {
357
+ e.value && e.value.dispatch({ selection: { anchor: a } });
358
+ }
359
+ }), j = f({
360
+ get: () => e.value?.state.toJSON(),
361
+ set: (a) => {
362
+ e.value && a && e.value.setState(u.fromJSON(a));
353
363
  }
354
- ), p = m(0), g = m(0), y = d(() => {
364
+ }), p = m(0), g = m(0), y = f(() => {
355
365
  const a = new C(), n = new C();
356
- if (e.basic && e.minimal)
366
+ if (t.basic && t.minimal)
357
367
  throw new Error(
358
368
  "[Vue CodeMirror] Both basic and minimal cannot be specified."
359
369
  );
360
370
  let o = [];
361
- return e.keymap && e.keymap.length > 0 && (o = e.keymap), e.tab && o.push(W), [
371
+ return t.keymap && t.keymap.length > 0 && (o = t.keymap), t.tab && o.push(W), [
362
372
  // Toggle basic setup
363
- e.basic && !e.minimal ? Q : void 0,
373
+ t.basic && !t.minimal ? Q : void 0,
364
374
  // Toggle minimal setup
365
- e.minimal && !e.basic ? X : void 0,
375
+ t.minimal && !t.basic ? X : void 0,
366
376
  // ViewUpdate event listener
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));
377
+ d.updateListener.of((c) => {
378
+ e.value && (l.emit("focus", e.value.hasFocus), p.value = e.value.state.doc?.length, !(c.changes.empty || !c.docChanged) && (t.linter && (t.forceLinting && w(e.value), g.value = t.linter(e.value).length), l.emit("update", c)));
369
379
  }),
370
380
  // Toggle light/dark mode.
371
- c.theme(e.theme, { dark: e.dark }),
381
+ d.theme(t.theme, { dark: t.dark }),
372
382
  // Toggle line wrapping
373
- e.wrap ? c.lineWrapping : void 0,
383
+ t.wrap ? d.lineWrapping : void 0,
374
384
  // Tab character
375
- e.indentUnit ? G.of(e.indentUnit) : void 0,
385
+ t.indentUnit ? G.of(t.indentUnit) : void 0,
376
386
  // Allow Multiple Selections
377
- s.allowMultipleSelections.of(e.allowMultipleSelections),
387
+ u.allowMultipleSelections.of(t.allowMultipleSelections),
378
388
  // Indent tab size
379
- e.tabSize ? n.of(s.tabSize.of(e.tabSize)) : void 0,
389
+ t.tabSize ? n.of(u.tabSize.of(t.tabSize)) : void 0,
380
390
  // locale settings
381
- e.phrases ? s.phrases.of(e.phrases) : void 0,
391
+ t.phrases ? u.phrases.of(t.phrases) : void 0,
382
392
  // Readonly option
383
- s.readOnly.of(e.readonly),
393
+ u.readOnly.of(t.readonly),
384
394
  // Editable option
385
- c.editable.of(!e.disabled),
395
+ d.editable.of(!t.disabled),
386
396
  // Set Line break char
387
- e.lineSeparator ? s.lineSeparator.of(e.lineSeparator) : void 0,
397
+ t.lineSeparator ? u.lineSeparator.of(t.lineSeparator) : void 0,
388
398
  // Lang
389
- e.lang ? a.of(e.lang) : void 0,
399
+ t.lang ? a.of(t.lang) : void 0,
390
400
  // Append Linter settings
391
- e.linter ? P(e.linter, e.linterConfig) : void 0,
401
+ t.linter ? P(t.linter, t.linterConfig) : void 0,
392
402
  // Show 🔴 to error line when linter enabled.
393
- e.linter && e.gutter ? Z(e.gutterConfig) : void 0,
403
+ t.linter && t.gutter ? Z(t.gutterConfig) : void 0,
394
404
  // Placeholder
395
- e.placeholder ? H(e.placeholder) : void 0,
405
+ t.placeholder ? H(t.placeholder) : void 0,
396
406
  // Keymap and Indent with Tab
397
- o.length !== 0 ? K.of(o) : void 0,
407
+ o.length > 0 ? K.of(o) : void 0,
398
408
  // Append Extensions
399
- ...e.extensions
400
- ].filter((r) => !!r);
409
+ ...t.extensions
410
+ ].filter((c) => !!c);
401
411
  });
402
412
  B(
403
413
  y,
404
- (a) => t.value?.dispatch({ effects: S.reconfigure.of(a) }),
414
+ (a) => e.value?.dispatch({ effects: S.reconfigure.of(a) }),
405
415
  { immediate: !0 }
406
416
  ), B(
407
- () => e.modelValue,
417
+ () => t.modelValue,
408
418
  async (a) => {
409
- if (t.value.composing || // IME fix
410
- t.value.state.doc.toJSON().join(e.lineSeparator ?? `
419
+ if (!e.value || e.value.composing || // IME fix
420
+ e.value.state.doc.toJSON().join(t.lineSeparator ?? `
411
421
  `) === a)
412
422
  return;
413
- const n = !t.value.state.selection.ranges.every(
423
+ const n = !e.value.state.selection.ranges.every(
414
424
  (o) => o.anchor < a.length && o.head < a.length
415
425
  );
416
- t.value.dispatch({
417
- changes: { from: 0, to: t.value.state.doc.length, insert: a },
418
- selection: n ? { anchor: 0, head: 0 } : t.value.state.selection,
419
- scrollIntoView: e.scrollIntoView
426
+ e.value.dispatch({
427
+ changes: { from: 0, to: e.value.state.doc.length, insert: a },
428
+ selection: n ? { anchor: 0, head: 0 } : e.value.state.selection,
429
+ scrollIntoView: t.scrollIntoView
420
430
  });
421
431
  },
422
432
  { immediate: !0 }
423
433
  ), ae(async () => {
424
- let a = u.value;
425
- l.value && (l.value.childNodes[0] && (u.value !== "" && console.warn(
434
+ if (globalThis.window === void 0 || !i.value)
435
+ return;
436
+ let a = s.value;
437
+ i.value.childNodes[0] && (s.value !== "" && console.warn(
426
438
  "[CodeMirror.vue] The <code-mirror> tag contains child elements that overwrite the `v-model` values."
427
- ), a = l.value.childNodes[0].innerText.trim()), t.value = new c({
428
- parent: l.value,
429
- state: s.create({ doc: a, extensions: y.value }),
439
+ ), a = i.value.childNodes[0].innerText.trim()), e.value = new d({
440
+ parent: i.value,
441
+ state: u.create({ doc: a, extensions: y.value }),
430
442
  dispatch: (n) => {
431
- t.value.update([n]), !(n.changes.empty || !n.docChanged) && (i.emit("update:modelValue", n.state.doc.toString()), i.emit("change", n.state));
443
+ e.value && (e.value.update([n]), !(n.changes.empty || !n.docChanged) && (l.emit("update:modelValue", n.state.doc.toString()), l.emit("change", n.state)));
432
444
  }
433
- }), await ne(), i.emit("ready", {
434
- view: t.value,
435
- state: t.value.state,
436
- container: l.value
437
- }));
438
- }), le(() => {
439
- t.value.destroy(), i.emit("destroy");
445
+ }), await ne(), l.emit("ready", {
446
+ view: e.value,
447
+ state: e.value.state,
448
+ container: i.value
449
+ });
450
+ }), ie(() => {
451
+ e.value && (e.value.destroy(), l.emit("destroy"));
440
452
  });
441
- const j = () => {
442
- !e.linter || !t.value || (e.forceLinting && w(t.value), g.value = q(t.value.state));
443
- }, x = () => {
444
- t.value?.dispatch({
453
+ const x = () => {
454
+ !t.linter || !e.value || (t.forceLinting && w(e.value), g.value = q(e.value.state));
455
+ }, L = () => {
456
+ e.value?.dispatch({
445
457
  effects: S.reconfigure.of([])
446
- }), t.value?.dispatch({
458
+ }), e.value?.dispatch({
447
459
  effects: S.appendConfig.of(y.value)
448
460
  });
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 = () => {
450
- let a;
451
- return (a = t.value.state.selection.ranges) !== null && a !== void 0 ? a : [];
452
- }, z = () => {
453
- let a;
454
- return (a = t.value.state.sliceDoc(
455
- t.value.state.selection.main.from,
456
- t.value.state.selection.main.to
457
- )) !== null && a !== void 0 ? a : "";
458
- }, E = () => {
459
- const a = t.value.state;
461
+ }, N = (a, n) => e.value?.state.sliceDoc(a, n), T = (a) => e.value?.state.doc.line(a + 1).text, U = () => e.value?.state.doc.lines ?? 0, $ = () => e.value?.state.selection.main.head ?? 0, k = () => e.value?.state.selection.ranges ?? [], z = () => e.value ? e.value.state.sliceDoc(
462
+ e.value.state.selection.main.from,
463
+ e.value.state.selection.main.to
464
+ ) : "", E = () => {
465
+ const a = e.value?.state;
460
466
  return a ? a.selection.ranges.map(
461
467
  (n) => a.sliceDoc(n.from, n.to)
462
468
  ) : [];
463
- }, R = () => t.value.state.selection.ranges.some(
469
+ }, R = () => e.value?.state.selection.ranges.some(
464
470
  (a) => !a.empty
465
- ), T = (a, n, o) => t.value.dispatch({
466
- changes: { from: n, to: o, insert: a }
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)))
472
- )
473
- }), b = {
474
- editor: l,
475
- view: t,
471
+ ) ?? !1, _ = (a, n, o) => {
472
+ e.value && e.value.dispatch({
473
+ changes: { from: n, to: o, insert: a }
474
+ });
475
+ }, D = (a) => {
476
+ e.value && e.value.dispatch(e.value.state.replaceSelection(a));
477
+ }, A = (a) => {
478
+ e.value && e.value.dispatch({ selection: { anchor: a } });
479
+ }, F = (a, n) => {
480
+ e.value && e.value.dispatch({ selection: { anchor: a, head: n } });
481
+ }, I = (a, n) => {
482
+ e.value && e.value.dispatch({
483
+ selection: O.create(a, n)
484
+ });
485
+ }, J = (a) => {
486
+ e.value && r.value && e.value.dispatch({
487
+ selection: O.create(
488
+ r.value.ranges.map((n) => n.extend(a(n)))
489
+ )
490
+ });
491
+ }, b = {
492
+ editor: i,
493
+ view: e,
476
494
  cursor: h,
477
- selection: v,
478
- focus: f,
495
+ selection: r,
496
+ focus: v,
479
497
  length: p,
480
- json: $,
498
+ json: j,
481
499
  diagnosticCount: g,
482
- dom: t.value.contentDOM,
483
- lint: j,
484
- forceReconfigure: x,
500
+ dom: e.value?.contentDOM,
501
+ lint: x,
502
+ forceReconfigure: L,
485
503
  // Bellow is CodeMirror5's function
486
- getRange: _,
487
- getLine: L,
488
- lineCount: N,
489
- getCursor: U,
504
+ getRange: N,
505
+ getLine: T,
506
+ lineCount: U,
507
+ getCursor: $,
490
508
  listSelections: k,
491
509
  getSelection: z,
492
510
  getSelections: E,
493
511
  somethingSelected: R,
494
- replaceRange: T,
512
+ replaceRange: _,
495
513
  replaceSelection: D,
496
514
  setCursor: A,
497
515
  setSelection: F,
498
516
  setSelections: I,
499
517
  extendSelectionsBy: J
500
518
  };
501
- return i.expose(b), b;
519
+ return l.expose(b), b;
502
520
  },
503
521
  render() {
504
522
  return M(
@@ -517,10 +535,9 @@ var se = ee({
517
535
  ) : void 0
518
536
  );
519
537
  }
520
- });
521
- const ge = (e) => e.component("CodeMirror", se);
538
+ }), ge = (t) => t.component("CodeMirror", ue);
522
539
  export {
523
540
  he as Meta,
524
- se as default,
541
+ ue as default,
525
542
  ge as install
526
543
  };
@@ -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.22
8
+ * @version 1.4.1
9
9
  * @see {@link https://github.com/logue/vue-codemirror6}
10
10
  */
11
11
 
12
- var CodeMirror=function(u,E,O,f,i,d,b,l){"use strict";const M={version:"1.3.22",date:"2025-07-12T05:13:58.540Z"},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);
12
+ var CodeMirror=(function(s,E,O,f,o,c,b,l){"use strict";const M={version:"1.4.1",date:"2025-10-17T22:30:13.688Z"},B=t=>t?Object.entries(t).reduce((r,[i,d])=>(i=i.charAt(0).toUpperCase()+i.slice(1),i=`on${i}`,{...r,[i]:d}),{}):{};function w(t,r={},i){if(l.isVue2)return l.h(t,r,i);const{props:d,domProps:e,on:g,...v}=r,m=g?B(g):{};return l.h(t,{...v,...d,...e,...m},i)}const j=t=>typeof t=="function"?t():t,C=l.defineComponent({name:"CodeMirror",model:{prop:"modelValue",event:"update:modelValue"},props:{modelValue:{type:String,default:""},theme:{type:Object,default:()=>({})},dark:{type:Boolean,default:!1},basic:{type:Boolean,default:!1},minimal:{type:Boolean,default:!1},placeholder:{type:String,default:void 0},wrap:{type:Boolean,default:!1},tab:{type:Boolean,default:!1},indentUnit:{type:String,default:void 0},allowMultipleSelections:{type:Boolean,default:!1},tabSize:{type:Number,default:void 0},lineSeparator:{type:String,default:void 0},readonly:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},extensions:{type:Array,default:()=>[]},phrases:{type:Object,default:void 0},lang:{type:Object,default:void 0},linter:{type:Function,default:void 0},linterConfig:{type:Object,default:()=>({})},forceLinting:{type:Boolean,default:!1},gutter:{type:Boolean,default:!1},gutterConfig:{type:Object,default:void 0},tag:{type:String,default:"div"},scrollIntoView:{type:Boolean,default:!0},keymap:{type:Array,default:()=>[]}},emits:{"update:modelValue":(t="")=>!0,update:t=>!0,ready:t=>!0,focus:t=>!0,change:t=>!0,destroy:()=>!0},setup(t,r){const i=l.ref(),d=l.ref(t.modelValue),e=l.shallowRef(void 0),g=l.computed({get:()=>e.value?.hasFocus??!1,set:a=>{a&&e.value&&e.value.focus()}}),v=l.computed({get:()=>e.value?.state.selection,set:a=>{e.value&&a&&e.value.dispatch({selection:a})}}),m=l.computed({get:()=>e.value?.state.selection.main.head??0,set:a=>{e.value&&e.value.dispatch({selection:{anchor:a}})}}),_=l.computed({get:()=>e.value?.state.toJSON(),set:a=>{e.value&&a&&e.value.setState(o.EditorState.fromJSON(a))}}),p=l.ref(0),y=l.ref(0),S=l.computed(()=>{const a=new o.Compartment,n=new o.Compartment;if(t.basic&&t.minimal)throw new Error("[Vue CodeMirror] Both basic and minimal cannot be specified.");let u=[];return t.keymap&&t.keymap.length>0&&(u=t.keymap),t.tab&&u.push(E.indentWithTab),[t.basic&&!t.minimal?b.basicSetup:void 0,t.minimal&&!t.basic?b.minimalSetup:void 0,c.EditorView.updateListener.of(h=>{e.value&&(r.emit("focus",e.value.hasFocus),p.value=e.value.state.doc?.length,!(h.changes.empty||!h.docChanged)&&(t.linter&&(t.forceLinting&&f.forceLinting(e.value),y.value=t.linter(e.value).length),r.emit("update",h)))}),c.EditorView.theme(t.theme,{dark:t.dark}),t.wrap?c.EditorView.lineWrapping:void 0,t.indentUnit?O.indentUnit.of(t.indentUnit):void 0,o.EditorState.allowMultipleSelections.of(t.allowMultipleSelections),t.tabSize?n.of(o.EditorState.tabSize.of(t.tabSize)):void 0,t.phrases?o.EditorState.phrases.of(t.phrases):void 0,o.EditorState.readOnly.of(t.readonly),c.EditorView.editable.of(!t.disabled),t.lineSeparator?o.EditorState.lineSeparator.of(t.lineSeparator):void 0,t.lang?a.of(t.lang):void 0,t.linter?f.linter(t.linter,t.linterConfig):void 0,t.linter&&t.gutter?f.lintGutter(t.gutterConfig):void 0,t.placeholder?c.placeholder(t.placeholder):void 0,u.length>0?c.keymap.of(u):void 0,...t.extensions].filter(h=>!!h)});l.watch(S,a=>e.value?.dispatch({effects:o.StateEffect.reconfigure.of(a)}),{immediate:!0}),l.watch(()=>t.modelValue,async a=>{if(!e.value||e.value.composing||e.value.state.doc.toJSON().join(t.lineSeparator??`
13
+ `)===a)return;const n=!e.value.state.selection.ranges.every(u=>u.anchor<a.length&&u.head<a.length);e.value.dispatch({changes:{from:0,to:e.value.state.doc.length,insert:a},selection:n?{anchor:0,head:0}:e.value.state.selection,scrollIntoView:t.scrollIntoView})},{immediate:!0}),l.onMounted(async()=>{if(globalThis.window===void 0||!i.value)return;let a=d.value;i.value.childNodes[0]&&(d.value!==""&&console.warn("[CodeMirror.vue] The <code-mirror> tag contains child elements that overwrite the `v-model` values."),a=i.value.childNodes[0].innerText.trim()),e.value=new c.EditorView({parent:i.value,state:o.EditorState.create({doc:a,extensions:S.value}),dispatch:n=>{e.value&&(e.value.update([n]),!(n.changes.empty||!n.docChanged)&&(r.emit("update:modelValue",n.state.doc.toString()),r.emit("change",n.state)))}}),await l.nextTick(),r.emit("ready",{view:e.value,state:e.value.state,container:i.value})}),l.onUnmounted(()=>{e.value&&(e.value.destroy(),r.emit("destroy"))});const $=()=>{!t.linter||!e.value||(t.forceLinting&&f.forceLinting(e.value),y.value=f.diagnosticCount(e.value.state))},N=()=>{e.value?.dispatch({effects:o.StateEffect.reconfigure.of([])}),e.value?.dispatch({effects:o.StateEffect.appendConfig.of(S.value)})},T=(a,n)=>e.value?.state.sliceDoc(a,n),U=a=>e.value?.state.doc.line(a+1).text,k=()=>e.value?.state.doc.lines??0,z=()=>e.value?.state.selection.main.head??0,R=()=>e.value?.state.selection.ranges??[],A=()=>e.value?e.value.state.sliceDoc(e.value.state.selection.main.from,e.value.state.selection.main.to):"",F=()=>{const a=e.value?.state;return a?a.selection.ranges.map(n=>a.sliceDoc(n.from,n.to)):[]},I=()=>e.value?.state.selection.ranges.some(a=>!a.empty)??!1,J=(a,n,u)=>{e.value&&e.value.dispatch({changes:{from:n,to:u,insert:a}})},x=a=>{e.value&&e.value.dispatch(e.value.state.replaceSelection(a))},P=a=>{e.value&&e.value.dispatch({selection:{anchor:a}})},W=(a,n)=>{e.value&&e.value.dispatch({selection:{anchor:a,head:n}})},G=(a,n)=>{e.value&&e.value.dispatch({selection:o.EditorSelection.create(a,n)})},Z=a=>{e.value&&v.value&&e.value.dispatch({selection:o.EditorSelection.create(v.value.ranges.map(n=>n.extend(a(n))))})},V={editor:i,view:e,cursor:m,selection:v,focus:g,length:p,json:_,diagnosticCount:y,dom:e.value?.contentDOM,lint:$,forceReconfigure:N,getRange:T,getLine:U,lineCount:k,getCursor:z,listSelections:R,getSelection:A,getSelections:F,somethingSelected:I,replaceRange:J,replaceSelection:x,setCursor:P,setSelection:W,setSelections:G,extendSelectionsBy:Z};return r.expose(V),V},render(){return w(this.$props.tag,{ref:"editor",class:"vue-codemirror"},this.$slots.default?w("aside",{style:"display: none;","aria-hidden":"true"},j(this.$slots.default)):void 0)}}),L=t=>t.component("CodeMirror",C);return s.Meta=M,s.default=C,s.install=L,Object.defineProperty(s,"__esModule",{value:!0}),s})({},commands,language,lint,state,view,codemirror,VueDemi);
package/dist/index.umd.js CHANGED
@@ -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.22
8
+ * @version 1.4.1
9
9
  * @see {@link https://github.com/logue/vue-codemirror6}
10
10
  */
11
11
 
12
- (function(l,f){typeof exports=="object"&&typeof module<"u"?f(exports,require("@codemirror/commands"),require("@codemirror/language"),require("@codemirror/lint"),require("@codemirror/state"),require("@codemirror/view"),require("codemirror"),require("vue-demi")):typeof define=="function"&&define.amd?define(["exports","@codemirror/commands","@codemirror/language","@codemirror/lint","@codemirror/state","@codemirror/view","codemirror","vue-demi"],f):(l=typeof globalThis<"u"?globalThis:l||self,f(l.CodeMirror={},l.commands,l.language,l.lint,l.state,l.view,l.codemirror,l.VueDemi))})(this,function(l,f,O,v,r,s,w,i){"use strict";const M={version:"1.3.22",date:"2025-07-12T05:13:58.540Z"},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})});
12
+ (function(l,f){typeof exports=="object"&&typeof module<"u"?f(exports,require("@codemirror/commands"),require("@codemirror/language"),require("@codemirror/lint"),require("@codemirror/state"),require("@codemirror/view"),require("codemirror"),require("vue-demi")):typeof define=="function"&&define.amd?define(["exports","@codemirror/commands","@codemirror/language","@codemirror/lint","@codemirror/state","@codemirror/view","codemirror","vue-demi"],f):(l=typeof globalThis<"u"?globalThis:l||self,f(l.CodeMirror={},l.commands,l.language,l.lint,l.state,l.view,l.codemirror,l.VueDemi))})(this,(function(l,f,O,v,r,c,w,i){"use strict";const M={version:"1.4.1",date:"2025-10-17T22:30:13.688Z"},B=t=>t?Object.entries(t).reduce((d,[o,s])=>(o=o.charAt(0).toUpperCase()+o.slice(1),o=`on${o}`,{...d,[o]:s}),{}):{};function C(t,d={},o){if(i.isVue2)return i.h(t,d,o);const{props:s,domProps:e,on:g,...m}=d,y=g?B(g):{};return i.h(t,{...m,...s,...e,...y},o)}const j=t=>typeof t=="function"?t():t,b=i.defineComponent({name:"CodeMirror",model:{prop:"modelValue",event:"update:modelValue"},props:{modelValue:{type:String,default:""},theme:{type:Object,default:()=>({})},dark:{type:Boolean,default:!1},basic:{type:Boolean,default:!1},minimal:{type:Boolean,default:!1},placeholder:{type:String,default:void 0},wrap:{type:Boolean,default:!1},tab:{type:Boolean,default:!1},indentUnit:{type:String,default:void 0},allowMultipleSelections:{type:Boolean,default:!1},tabSize:{type:Number,default:void 0},lineSeparator:{type:String,default:void 0},readonly:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},extensions:{type:Array,default:()=>[]},phrases:{type:Object,default:void 0},lang:{type:Object,default:void 0},linter:{type:Function,default:void 0},linterConfig:{type:Object,default:()=>({})},forceLinting:{type:Boolean,default:!1},gutter:{type:Boolean,default:!1},gutterConfig:{type:Object,default:void 0},tag:{type:String,default:"div"},scrollIntoView:{type:Boolean,default:!0},keymap:{type:Array,default:()=>[]}},emits:{"update:modelValue":(t="")=>!0,update:t=>!0,ready:t=>!0,focus:t=>!0,change:t=>!0,destroy:()=>!0},setup(t,d){const o=i.ref(),s=i.ref(t.modelValue),e=i.shallowRef(void 0),g=i.computed({get:()=>e.value?.hasFocus??!1,set:a=>{a&&e.value&&e.value.focus()}}),m=i.computed({get:()=>e.value?.state.selection,set:a=>{e.value&&a&&e.value.dispatch({selection:a})}}),y=i.computed({get:()=>e.value?.state.selection.main.head??0,set:a=>{e.value&&e.value.dispatch({selection:{anchor:a}})}}),q=i.computed({get:()=>e.value?.state.toJSON(),set:a=>{e.value&&a&&e.value.setState(r.EditorState.fromJSON(a))}}),V=i.ref(0),S=i.ref(0),p=i.computed(()=>{const a=new r.Compartment,n=new r.Compartment;if(t.basic&&t.minimal)throw new Error("[Vue CodeMirror] Both basic and minimal cannot be specified.");let u=[];return t.keymap&&t.keymap.length>0&&(u=t.keymap),t.tab&&u.push(f.indentWithTab),[t.basic&&!t.minimal?w.basicSetup:void 0,t.minimal&&!t.basic?w.minimalSetup:void 0,c.EditorView.updateListener.of(h=>{e.value&&(d.emit("focus",e.value.hasFocus),V.value=e.value.state.doc?.length,!(h.changes.empty||!h.docChanged)&&(t.linter&&(t.forceLinting&&v.forceLinting(e.value),S.value=t.linter(e.value).length),d.emit("update",h)))}),c.EditorView.theme(t.theme,{dark:t.dark}),t.wrap?c.EditorView.lineWrapping:void 0,t.indentUnit?O.indentUnit.of(t.indentUnit):void 0,r.EditorState.allowMultipleSelections.of(t.allowMultipleSelections),t.tabSize?n.of(r.EditorState.tabSize.of(t.tabSize)):void 0,t.phrases?r.EditorState.phrases.of(t.phrases):void 0,r.EditorState.readOnly.of(t.readonly),c.EditorView.editable.of(!t.disabled),t.lineSeparator?r.EditorState.lineSeparator.of(t.lineSeparator):void 0,t.lang?a.of(t.lang):void 0,t.linter?v.linter(t.linter,t.linterConfig):void 0,t.linter&&t.gutter?v.lintGutter(t.gutterConfig):void 0,t.placeholder?c.placeholder(t.placeholder):void 0,u.length>0?c.keymap.of(u):void 0,...t.extensions].filter(h=>!!h)});i.watch(p,a=>e.value?.dispatch({effects:r.StateEffect.reconfigure.of(a)}),{immediate:!0}),i.watch(()=>t.modelValue,async a=>{if(!e.value||e.value.composing||e.value.state.doc.toJSON().join(t.lineSeparator??`
13
+ `)===a)return;const n=!e.value.state.selection.ranges.every(u=>u.anchor<a.length&&u.head<a.length);e.value.dispatch({changes:{from:0,to:e.value.state.doc.length,insert:a},selection:n?{anchor:0,head:0}:e.value.state.selection,scrollIntoView:t.scrollIntoView})},{immediate:!0}),i.onMounted(async()=>{if(globalThis.window===void 0||!o.value)return;let a=s.value;o.value.childNodes[0]&&(s.value!==""&&console.warn("[CodeMirror.vue] The <code-mirror> tag contains child elements that overwrite the `v-model` values."),a=o.value.childNodes[0].innerText.trim()),e.value=new c.EditorView({parent:o.value,state:r.EditorState.create({doc:a,extensions:p.value}),dispatch:n=>{e.value&&(e.value.update([n]),!(n.changes.empty||!n.docChanged)&&(d.emit("update:modelValue",n.state.doc.toString()),d.emit("change",n.state)))}}),await i.nextTick(),d.emit("ready",{view:e.value,state:e.value.state,container:o.value})}),i.onUnmounted(()=>{e.value&&(e.value.destroy(),d.emit("destroy"))});const L=()=>{!t.linter||!e.value||(t.forceLinting&&v.forceLinting(e.value),S.value=v.diagnosticCount(e.value.state))},_=()=>{e.value?.dispatch({effects:r.StateEffect.reconfigure.of([])}),e.value?.dispatch({effects:r.StateEffect.appendConfig.of(p.value)})},$=(a,n)=>e.value?.state.sliceDoc(a,n),x=a=>e.value?.state.doc.line(a+1).text,N=()=>e.value?.state.doc.lines??0,U=()=>e.value?.state.selection.main.head??0,k=()=>e.value?.state.selection.ranges??[],z=()=>e.value?e.value.state.sliceDoc(e.value.state.selection.main.from,e.value.state.selection.main.to):"",R=()=>{const a=e.value?.state;return a?a.selection.ranges.map(n=>a.sliceDoc(n.from,n.to)):[]},A=()=>e.value?.state.selection.ranges.some(a=>!a.empty)??!1,F=(a,n,u)=>{e.value&&e.value.dispatch({changes:{from:n,to:u,insert:a}})},I=a=>{e.value&&e.value.dispatch(e.value.state.replaceSelection(a))},J=a=>{e.value&&e.value.dispatch({selection:{anchor:a}})},P=(a,n)=>{e.value&&e.value.dispatch({selection:{anchor:a,head:n}})},W=(a,n)=>{e.value&&e.value.dispatch({selection:r.EditorSelection.create(a,n)})},G=a=>{e.value&&m.value&&e.value.dispatch({selection:r.EditorSelection.create(m.value.ranges.map(n=>n.extend(a(n))))})},E={editor:o,view:e,cursor:y,selection:m,focus:g,length:V,json:q,diagnosticCount:S,dom:e.value?.contentDOM,lint:L,forceReconfigure:_,getRange:$,getLine:x,lineCount:N,getCursor:U,listSelections:k,getSelection:z,getSelections:R,somethingSelected:A,replaceRange:F,replaceSelection:I,setCursor:J,setSelection:P,setSelections:W,extendSelectionsBy:G};return d.expose(E),E},render(){return C(this.$props.tag,{ref:"editor",class:"vue-codemirror"},this.$slots.default?C("aside",{style:"display: none;","aria-hidden":"true"},j(this.$slots.default)):void 0)}}),T=t=>t.component("CodeMirror",b);l.Meta=M,l.default=b,l.install=T,Object.defineProperty(l,"__esModule",{value:!0})}));