vue-codemirror6 1.4.1 → 1.4.2
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/LICENSE +1 -1
- package/README.md +1 -1
- package/dist/index.cjs.js +3 -3
- package/dist/index.es.js +5 -5
- package/dist/index.iife.js +3 -3
- package/dist/index.umd.js +3 -3
- package/package.json +44 -39
package/LICENSE
CHANGED
package/README.md
CHANGED
package/dist/index.cjs.js
CHANGED
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @description CodeMirror6 Component for vue2 and vue3.
|
|
5
5
|
* @author Logue <logue@hotmail.co.jp>
|
|
6
|
-
* @copyright 2022-
|
|
6
|
+
* @copyright 2022-2026 By Masashi Yoshikawa All rights reserved.
|
|
7
7
|
* @license MIT
|
|
8
|
-
* @version 1.4.
|
|
8
|
+
* @version 1.4.2
|
|
9
9
|
* @see {@link https://github.com/logue/vue-codemirror6}
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var R=require("@codemirror/commands"),A=require("@codemirror/language"),v=require("@codemirror/lint"),o=require("@codemirror/state"),s=require("@codemirror/view"),b=require("codemirror"),n=require("vue-demi");const F={version:"1.4.
|
|
12
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var R=require("@codemirror/commands"),A=require("@codemirror/language"),v=require("@codemirror/lint"),o=require("@codemirror/state"),s=require("@codemirror/view"),b=require("codemirror"),n=require("vue-demi");const F={version:"1.4.2",date:"2026-02-17T01:27:59.529Z"},I=t=>t?Object.entries(t).reduce((u,[l,c])=>(l=l.charAt(0).toUpperCase()+l.slice(1),l=`on${l}`,{...u,[l]:c}),{}):{};function p(t,u={},l){if(n.isVue2)return n.h(t,u,l);const{props:c,domProps:e,on:m,...d}=u,h=m?I(m):{};return n.h(t,{...d,...c,...e,...h},l)}const J=t=>typeof t=="function"?t():t,C=n.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,u){const l=n.ref(),c=n.ref(t.modelValue),e=n.shallowRef(void 0),m=n.computed({get:()=>e.value?.hasFocus??!1,set:a=>{a&&e.value&&e.value.focus()}}),d=n.computed({get:()=>e.value?.state.selection,set:a=>{e.value&&a&&e.value.dispatch({selection:a})}}),h=n.computed({get:()=>e.value?.state.selection.main.head??0,set:a=>{e.value&&e.value.dispatch({selection:{anchor:a}})}}),E=n.computed({get:()=>e.value?.state.toJSON(),set:a=>{e.value&&a&&e.value.setState(o.EditorState.fromJSON(a))}}),S=n.ref(0),g=n.ref(0),y=n.computed(()=>{const a=new o.Compartment,i=new o.Compartment;if(t.basic&&t.minimal)throw new Error("[Vue CodeMirror] Both basic and minimal cannot be specified.");let r=[];return t.keymap&&t.keymap.length>0&&(r=t.keymap),t.tab&&r.push(R.indentWithTab),[t.basic&&!t.minimal?b.basicSetup:void 0,t.minimal&&!t.basic?b.minimalSetup:void 0,s.EditorView.updateListener.of(f=>{e.value&&(u.emit("focus",e.value.hasFocus),S.value=e.value.state.doc?.length,!(f.changes.empty||!f.docChanged)&&(t.linter&&(t.forceLinting&&v.forceLinting(e.value),g.value=t.linter(e.value).length),u.emit("update",f)))}),s.EditorView.theme(t.theme,{dark:t.dark}),t.wrap?s.EditorView.lineWrapping:void 0,t.indentUnit?A.indentUnit.of(t.indentUnit):void 0,o.EditorState.allowMultipleSelections.of(t.allowMultipleSelections),t.tabSize?i.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),s.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?v.linter(t.linter,t.linterConfig):void 0,t.linter&&t.gutter?v.lintGutter(t.gutterConfig):void 0,t.placeholder?s.placeholder(t.placeholder):void 0,r.length>0?s.keymap.of(r):void 0,...t.extensions].filter(f=>!!f)});n.watch(y,a=>e.value?.dispatch({effects:o.StateEffect.reconfigure.of(a)}),{immediate:!0}),n.watch(()=>t.modelValue,async a=>{if(!e.value||e.value.composing||e.value.state.doc.toJSON().join(t.lineSeparator??`
|
|
13
13
|
`)===a)return;const i=!e.value.state.selection.ranges.every(r=>r.anchor<a.length&&r.head<a.length);e.value.dispatch({changes:{from:0,to:e.value.state.doc.length,insert:a},selection:i?{anchor:0,head:0}:e.value.state.selection,scrollIntoView:t.scrollIntoView})},{immediate:!0}),n.onMounted(async()=>{if(globalThis.window===void 0||!l.value)return;let a=c.value;l.value.childNodes[0]&&(c.value!==""&&console.warn("[CodeMirror.vue] The <code-mirror> tag contains child elements that overwrite the `v-model` values."),a=l.value.childNodes[0].innerText.trim()),e.value=new s.EditorView({parent:l.value,state:o.EditorState.create({doc:a,extensions:y.value}),dispatch:i=>{e.value&&(e.value.update([i]),!(i.changes.empty||!i.docChanged)&&(u.emit("update:modelValue",i.state.doc.toString()),u.emit("change",i.state)))}}),await n.nextTick(),u.emit("ready",{view:e.value,state:e.value.state,container:l.value})}),n.onUnmounted(()=>{e.value&&(e.value.destroy(),u.emit("destroy"))});const V=()=>{!t.linter||!e.value||(t.forceLinting&&v.forceLinting(e.value),g.value=v.diagnosticCount(e.value.state))},O=()=>{e.value?.dispatch({effects:o.StateEffect.reconfigure.of([])}),e.value?.dispatch({effects:o.StateEffect.appendConfig.of(y.value)})},B=(a,i)=>e.value?.state.sliceDoc(a,i),M=a=>e.value?.state.doc.line(a+1).text,j=()=>e.value?.state.doc.lines??0,q=()=>e.value?.state.selection.main.head??0,L=()=>e.value?.state.selection.ranges??[],_=()=>e.value?e.value.state.sliceDoc(e.value.state.selection.main.from,e.value.state.selection.main.to):"",$=()=>{const a=e.value?.state;return a?a.selection.ranges.map(i=>a.sliceDoc(i.from,i.to)):[]},x=()=>e.value?.state.selection.ranges.some(a=>!a.empty)??!1,N=(a,i,r)=>{e.value&&e.value.dispatch({changes:{from:i,to:r,insert:a}})},T=a=>{e.value&&e.value.dispatch(e.value.state.replaceSelection(a))},U=a=>{e.value&&e.value.dispatch({selection:{anchor:a}})},k=(a,i)=>{e.value&&e.value.dispatch({selection:{anchor:a,head:i}})},z=(a,i)=>{e.value&&e.value.dispatch({selection:o.EditorSelection.create(a,i)})},D=a=>{e.value&&d.value&&e.value.dispatch({selection:o.EditorSelection.create(d.value.ranges.map(i=>i.extend(a(i))))})},w={editor:l,view:e,cursor:h,selection:d,focus:m,length:S,json:E,diagnosticCount:g,dom:e.value?.contentDOM,lint:V,forceReconfigure:O,getRange:B,getLine:M,lineCount:j,getCursor:q,listSelections:L,getSelection:_,getSelections:$,somethingSelected:x,replaceRange:N,replaceSelection:T,setCursor:U,setSelection:k,setSelections:z,extendSelectionsBy:D};return u.expose(w),w},render(){return p(this.$props.tag,{ref:"editor",class:"vue-codemirror"},this.$slots.default?p("aside",{style:"display: none;","aria-hidden":"true"},J(this.$slots.default)):void 0)}}),P=t=>t.component("CodeMirror",C);exports.Meta=F;exports.default=C;exports.install=P;
|
package/dist/index.es.js
CHANGED
|
@@ -3,22 +3,22 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @description CodeMirror6 Component for vue2 and vue3.
|
|
5
5
|
* @author Logue <logue@hotmail.co.jp>
|
|
6
|
-
* @copyright 2022-
|
|
6
|
+
* @copyright 2022-2026 By Masashi Yoshikawa All rights reserved.
|
|
7
7
|
* @license MIT
|
|
8
|
-
* @version 1.4.
|
|
8
|
+
* @version 1.4.2
|
|
9
9
|
* @see {@link https://github.com/logue/vue-codemirror6}
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
import { indentWithTab as W } from "@codemirror/commands";
|
|
13
13
|
import { indentUnit as G } from "@codemirror/language";
|
|
14
|
-
import {
|
|
14
|
+
import { forceLinting as w, linter as P, lintGutter as Z, diagnosticCount as q } from "@codemirror/lint";
|
|
15
15
|
import { EditorState as u, Compartment as C, StateEffect as S, EditorSelection as O } from "@codemirror/state";
|
|
16
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
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.4.
|
|
21
|
-
date: "
|
|
20
|
+
version: "1.4.2",
|
|
21
|
+
date: "2026-02-17T01:27:59.529Z"
|
|
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)
|
package/dist/index.iife.js
CHANGED
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @description CodeMirror6 Component for vue2 and vue3.
|
|
5
5
|
* @author Logue <logue@hotmail.co.jp>
|
|
6
|
-
* @copyright 2022-
|
|
6
|
+
* @copyright 2022-2026 By Masashi Yoshikawa All rights reserved.
|
|
7
7
|
* @license MIT
|
|
8
|
-
* @version 1.4.
|
|
8
|
+
* @version 1.4.2
|
|
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.4.
|
|
12
|
+
var CodeMirror=(function(s,E,O,f,o,c,b,l){"use strict";const M={version:"1.4.2",date:"2026-02-17T01:27:59.529Z"},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
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
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @description CodeMirror6 Component for vue2 and vue3.
|
|
5
5
|
* @author Logue <logue@hotmail.co.jp>
|
|
6
|
-
* @copyright 2022-
|
|
6
|
+
* @copyright 2022-2026 By Masashi Yoshikawa All rights reserved.
|
|
7
7
|
* @license MIT
|
|
8
|
-
* @version 1.4.
|
|
8
|
+
* @version 1.4.2
|
|
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.4.
|
|
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.2",date:"2026-02-17T01:27:59.529Z"},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
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.
|
|
4
|
+
"version": "1.4.2",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "CodeMirror6 Component for vue2 and vue3.",
|
|
7
7
|
"keywords": [
|
|
@@ -57,10 +57,10 @@
|
|
|
57
57
|
],
|
|
58
58
|
"sideEffects": false,
|
|
59
59
|
"engines": {
|
|
60
|
-
"node": ">=
|
|
60
|
+
"node": "^20.19.0 || >=22.12.0",
|
|
61
61
|
"pnpm": ">=10.3.0"
|
|
62
62
|
},
|
|
63
|
-
"packageManager": "pnpm@10.
|
|
63
|
+
"packageManager": "pnpm@10.29.3",
|
|
64
64
|
"scripts": {
|
|
65
65
|
"dev": "vite",
|
|
66
66
|
"clean": "rimraf node_modules/.vite",
|
|
@@ -68,7 +68,10 @@
|
|
|
68
68
|
"build:analyze": "vite build --mode=analyze",
|
|
69
69
|
"build:clean": "rimraf dist docs",
|
|
70
70
|
"build:docs": "vite build --mode=docs",
|
|
71
|
-
"lint": "
|
|
71
|
+
"lint": "run-s lint:*",
|
|
72
|
+
"lint:oxlint": "oxlint . --fix",
|
|
73
|
+
"lint:eslint": "eslint . --fix --cache --cache-location ./node_modules/.vite/eslint-cache",
|
|
74
|
+
"lint:prettier": "prettier \"./**/*.{js,ts,json,css,sass,scss,htm,html,vue,md}\" -w -u",
|
|
72
75
|
"preview": "vite preview --mode=docs",
|
|
73
76
|
"build-only": "vite build",
|
|
74
77
|
"type-check": "vue-tsc --declaration --emitDeclarationOnly",
|
|
@@ -95,59 +98,61 @@
|
|
|
95
98
|
"vue": "^2.7.14 || ^3.3.4"
|
|
96
99
|
},
|
|
97
100
|
"devDependencies": {
|
|
98
|
-
"@codemirror/autocomplete": "^6.
|
|
99
|
-
"@codemirror/commands": "^6.
|
|
100
|
-
"@codemirror/language": "^6.11.3",
|
|
101
|
+
"@codemirror/autocomplete": "^6.20.0",
|
|
102
|
+
"@codemirror/commands": "^6.10.2",
|
|
101
103
|
"@codemirror/lang-javascript": "^6.2.4",
|
|
102
104
|
"@codemirror/lang-json": "^6.0.2",
|
|
103
|
-
"@codemirror/lang-markdown": "^6.
|
|
105
|
+
"@codemirror/lang-markdown": "^6.5.0",
|
|
104
106
|
"@codemirror/lang-vue": "^0.1.3",
|
|
105
|
-
"@codemirror/
|
|
106
|
-
"@codemirror/
|
|
107
|
-
"@codemirror/
|
|
108
|
-
"@codemirror/
|
|
109
|
-
"codemirror": "^6.
|
|
110
|
-
"
|
|
111
|
-
"@
|
|
112
|
-
"@
|
|
113
|
-
"@
|
|
114
|
-
"@
|
|
115
|
-
"@vue/compiler-sfc": "^3.5.22",
|
|
107
|
+
"@codemirror/language": "^6.12.1",
|
|
108
|
+
"@codemirror/lint": "^6.9.4",
|
|
109
|
+
"@codemirror/search": "^6.6.0",
|
|
110
|
+
"@codemirror/state": "^6.5.4",
|
|
111
|
+
"@codemirror/view": "^6.39.14",
|
|
112
|
+
"@tsconfig/node-lts": "^24.0.0",
|
|
113
|
+
"@types/node": "^25.2.3",
|
|
114
|
+
"@vitejs/plugin-vue": "^6.0.4",
|
|
115
|
+
"@vitest/ui": "^4.0.18",
|
|
116
|
+
"@vue/compiler-sfc": "^3.5.28",
|
|
116
117
|
"@vue/eslint-config-prettier": "^10.2.0",
|
|
117
118
|
"@vue/eslint-config-typescript": "^14.6.0",
|
|
118
119
|
"@vue/test-utils": "^2.4.6",
|
|
119
120
|
"@vue/tsconfig": "^0.8.1",
|
|
120
|
-
"@vueuse/core": "^
|
|
121
|
+
"@vueuse/core": "^14.2.1",
|
|
121
122
|
"bootstrap": "^5.3.8",
|
|
122
|
-
"
|
|
123
|
+
"codemirror": "^6.0.2",
|
|
124
|
+
"eslint": "^10.0.0",
|
|
123
125
|
"eslint-import-resolver-custom-alias": "^1.3.2",
|
|
124
126
|
"eslint-import-resolver-typescript": "^4.4.4",
|
|
125
|
-
"eslint-linter-browserify": "^
|
|
127
|
+
"eslint-linter-browserify": "^10.0.0",
|
|
126
128
|
"eslint-plugin-import": "^2.32.0",
|
|
127
|
-
"eslint-plugin-
|
|
128
|
-
"eslint-plugin-
|
|
129
|
-
"eslint-plugin-
|
|
130
|
-
"
|
|
129
|
+
"eslint-plugin-oxlint": "^1.48.0",
|
|
130
|
+
"eslint-plugin-playwright": "^2.5.1",
|
|
131
|
+
"eslint-plugin-vue": "^10.8.0",
|
|
132
|
+
"eslint-plugin-vuejs-accessibility": "^2.5.0",
|
|
133
|
+
"happy-dom": "^20.6.1",
|
|
131
134
|
"husky": "^9.1.7",
|
|
132
135
|
"jiti": "^2.6.1",
|
|
133
|
-
"lint-staged": "^16.2.
|
|
136
|
+
"lint-staged": "^16.2.7",
|
|
134
137
|
"npm-run-all2": "^8.0.4",
|
|
135
|
-
"
|
|
136
|
-
"
|
|
138
|
+
"oxlint": "^1.48.0",
|
|
139
|
+
"prettier": "^3.8.1",
|
|
140
|
+
"rimraf": "^6.1.3",
|
|
137
141
|
"rollup-plugin-visualizer": "^6.0.5",
|
|
138
|
-
"sass-embedded": "^1.
|
|
142
|
+
"sass-embedded": "^1.97.3",
|
|
143
|
+
"style-mod": "^4.1.3",
|
|
139
144
|
"supports-color": "^10.2.2",
|
|
140
145
|
"typescript": "^5.9.3",
|
|
141
|
-
"typescript-eslint": "^8.
|
|
142
|
-
"vite": "^7.1
|
|
146
|
+
"typescript-eslint": "^8.56.0",
|
|
147
|
+
"vite": "^7.3.1",
|
|
143
148
|
"vite-plugin-banner": "^0.8.1",
|
|
144
|
-
"vite-plugin-checker": "^0.
|
|
149
|
+
"vite-plugin-checker": "^0.12.0",
|
|
145
150
|
"vite-plugin-dts": "^4.5.4",
|
|
146
|
-
"vitest": "^
|
|
147
|
-
"vue": "^3.5.
|
|
148
|
-
"vue-eslint-parser": "^10.
|
|
149
|
-
"vue-markdown-wasm": "^0.
|
|
150
|
-
"vue-tsc": "^3.
|
|
151
|
+
"vitest": "^4.0.18",
|
|
152
|
+
"vue": "^3.5.28",
|
|
153
|
+
"vue-eslint-parser": "^10.4.0",
|
|
154
|
+
"vue-markdown-wasm": "^1.0.1",
|
|
155
|
+
"vue-tsc": "^3.2.4"
|
|
151
156
|
},
|
|
152
157
|
"husky": {
|
|
153
158
|
"hooks": {
|
|
@@ -162,4 +167,4 @@
|
|
|
162
167
|
"json5": ">=2.2.3",
|
|
163
168
|
"yaml": ">=2.6.0"
|
|
164
169
|
}
|
|
165
|
-
}
|
|
170
|
+
}
|