vue-codemirror6 1.4.0 → 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,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.22
8
+ * @version 1.4.1
9
9
  * @see {@link https://github.com/logue/vue-codemirror6}
10
10
  */
11
11
 
@@ -17,8 +17,8 @@ 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
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-10-17T01:01:41.290Z"
20
+ version: "1.4.1",
21
+ date: "2025-10-17T22:30:13.688Z"
22
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
23
  function M(t, l = {}, i) {
24
24
  if (Y)
@@ -30,8 +30,7 @@ function M(t, l = {}, i) {
30
30
  i
31
31
  );
32
32
  }
33
- const oe = (t) => typeof t == "function" ? t() : t;
34
- var ue = 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 ue = 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 ue = 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 ue = 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 ue = 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 ue = 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.
@@ -398,7 +404,7 @@ var ue = ee({
398
404
  // Placeholder
399
405
  t.placeholder ? H(t.placeholder) : void 0,
400
406
  // Keymap and Indent with Tab
401
- o.length !== 0 ? K.of(o) : void 0,
407
+ o.length > 0 ? K.of(o) : void 0,
402
408
  // Append Extensions
403
409
  ...t.extensions
404
410
  ].filter((c) => !!c);
@@ -425,7 +431,7 @@ var ue = ee({
425
431
  },
426
432
  { immediate: !0 }
427
433
  ), ae(async () => {
428
- if (typeof window > "u" || !i.value)
434
+ if (globalThis.window === void 0 || !i.value)
429
435
  return;
430
436
  let a = s.value;
431
437
  i.value.childNodes[0] && (s.value !== "" && console.warn(
@@ -452,15 +458,15 @@ var ue = ee({
452
458
  }), e.value?.dispatch({
453
459
  effects: S.appendConfig.of(y.value)
454
460
  });
455
- }, N = (a, n) => e.value?.state.sliceDoc(a, n), U = (a) => e.value?.state.doc.line(a + 1).text, $ = () => e.value?.state.doc.lines ?? 0, k = () => e.value?.state.selection.main.head ?? 0, z = () => e.value?.state.selection.ranges ?? [], E = () => e.value ? e.value.state.sliceDoc(
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(
456
462
  e.value.state.selection.main.from,
457
463
  e.value.state.selection.main.to
458
- ) : "", R = () => {
464
+ ) : "", E = () => {
459
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
- }, T = () => e.value?.state.selection.ranges.some(
469
+ }, R = () => e.value?.state.selection.ranges.some(
464
470
  (a) => !a.empty
465
471
  ) ?? !1, _ = (a, n, o) => {
466
472
  e.value && e.value.dispatch({
@@ -496,13 +502,13 @@ var ue = ee({
496
502
  forceReconfigure: L,
497
503
  // Bellow is CodeMirror5's function
498
504
  getRange: N,
499
- getLine: U,
500
- lineCount: $,
501
- getCursor: k,
502
- listSelections: z,
503
- getSelection: E,
504
- getSelections: R,
505
- somethingSelected: T,
505
+ getLine: T,
506
+ lineCount: U,
507
+ getCursor: $,
508
+ listSelections: k,
509
+ getSelection: z,
510
+ getSelections: E,
511
+ somethingSelected: R,
506
512
  replaceRange: _,
507
513
  replaceSelection: D,
508
514
  setCursor: A,
@@ -529,8 +535,7 @@ var ue = ee({
529
535
  ) : void 0
530
536
  );
531
537
  }
532
- });
533
- const ge = (t) => t.component("CodeMirror", ue);
538
+ }), ge = (t) => t.component("CodeMirror", ue);
534
539
  export {
535
540
  he as Meta,
536
541
  ue as default,
@@ -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(s,E,O,f,o,c,b,l){"use strict";const M={version:"1.3.22",date:"2025-10-17T01:01:41.290Z"},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;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":(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(typeof window>"u"||!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)})},U=(a,n)=>e.value?.state.sliceDoc(a,n),k=a=>e.value?.state.doc.line(a+1).text,z=()=>e.value?.state.doc.lines??0,R=()=>e.value?.state.selection.main.head??0,T=()=>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: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 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)}});const 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);
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,c,w,i){"use strict";const M={version:"1.3.22",date:"2025-10-17T01:01:41.290Z"},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;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":(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}})}}),L=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(typeof window>"u"||!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 T=()=>{!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:L,diagnosticCount:S,dom:e.value?.contentDOM,lint:T,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)}});const q=t=>t.component("CodeMirror",b);l.Meta=M,l.default=b,l.install=q,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})}));
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.4.0",
4
+ "version": "1.4.1",
5
5
  "license": "MIT",
6
6
  "description": "CodeMirror6 Component for vue2 and vue3.",
7
7
  "keywords": [
@@ -34,10 +34,8 @@
34
34
  "bugs": {
35
35
  "url": "https://github.com/logue/vue-codemirror6/issues"
36
36
  },
37
- "main": "dist/index.umd.js",
37
+ "main": "dist/index.cjs.js",
38
38
  "module": "dist/index.es.js",
39
- "jsdelivr": "dist/index.iife.js",
40
- "unpkg": "dist/index.iife.js",
41
39
  "types": "dist/index.d.ts",
42
40
  "exports": {
43
41
  ".": {
@@ -51,18 +49,13 @@
51
49
  },
52
50
  "./iife": {
53
51
  "default": "./dist/index.iife.js"
54
- },
55
- "./package.json": "./package.json"
52
+ }
56
53
  },
57
54
  "files": [
58
55
  "CHANGELOG.md",
59
- "/dist",
60
- "./src/components/CodeMirror.ts"
56
+ "/dist"
61
57
  ],
62
58
  "sideEffects": false,
63
- "browser": {
64
- "./sfc": "./src/components/CodeMirror.ts"
65
- },
66
59
  "engines": {
67
60
  "node": ">=18",
68
61
  "pnpm": ">=10.3.0"
@@ -102,12 +95,21 @@
102
95
  "vue": "^2.7.14 || ^3.3.4"
103
96
  },
104
97
  "devDependencies": {
98
+ "@codemirror/autocomplete": "^6.19.0",
99
+ "@codemirror/commands": "^6.9.0",
100
+ "@codemirror/language": "^6.11.3",
105
101
  "@codemirror/lang-javascript": "^6.2.4",
106
102
  "@codemirror/lang-json": "^6.0.2",
107
103
  "@codemirror/lang-markdown": "^6.4.0",
108
104
  "@codemirror/lang-vue": "^0.1.3",
105
+ "@codemirror/lint": "^6.9.0",
106
+ "@codemirror/search": "^6.5.11",
107
+ "@codemirror/state": "^6.5.2",
108
+ "@codemirror/view": "^6.38.6",
109
+ "codemirror": "^6.0.2",
110
+ "style-mod": "^4.1.3",
109
111
  "@tsconfig/node-lts": "^22.0.2",
110
- "@types/node": "^24.8.0",
112
+ "@types/node": "^24.8.1",
111
113
  "@vitejs/plugin-vue": "^6.0.1",
112
114
  "@vitest/ui": "^3.2.4",
113
115
  "@vue/compiler-sfc": "^3.5.22",
@@ -117,7 +119,7 @@
117
119
  "@vue/tsconfig": "^0.8.1",
118
120
  "@vueuse/core": "^13.9.0",
119
121
  "bootstrap": "^5.3.8",
120
- "eslint": "^9.37.0",
122
+ "eslint": "^9.38.0",
121
123
  "eslint-import-resolver-custom-alias": "^1.3.2",
122
124
  "eslint-import-resolver-typescript": "^4.4.4",
123
125
  "eslint-linter-browserify": "^9.37.0",
@@ -125,7 +127,7 @@
125
127
  "eslint-plugin-playwright": "^2.2.2",
126
128
  "eslint-plugin-vue": "^10.5.1",
127
129
  "eslint-plugin-vuejs-accessibility": "^2.4.1",
128
- "happy-dom": "^20.0.4",
130
+ "happy-dom": "^20.0.5",
129
131
  "husky": "^9.1.7",
130
132
  "jiti": "^2.6.1",
131
133
  "lint-staged": "^16.2.4",
@@ -160,4 +162,4 @@
160
162
  "json5": ">=2.2.3",
161
163
  "yaml": ">=2.6.0"
162
164
  }
163
- }
165
+ }