vue-codemirror6 1.0.0 → 1.0.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/components/CodeMirror.d.ts +1 -1
- package/dist/components/CodeMirror.d.ts.map +1 -1
- package/dist/index.es.js +67 -36
- package/dist/index.iife.js +12 -0
- package/dist/index.umd.js +3 -3
- package/package.json +18 -18
|
@@ -280,7 +280,7 @@ declare const _default: import("vue-demi").DefineComponent<{
|
|
|
280
280
|
defalt: boolean;
|
|
281
281
|
};
|
|
282
282
|
}>> & {
|
|
283
|
-
[x: `on${string}`]: ((...args: never) => any) | undefined;
|
|
283
|
+
[x: `on${Capitalize<string>}`]: ((...args: never) => any) | undefined;
|
|
284
284
|
}, {
|
|
285
285
|
modelValue: string | Text;
|
|
286
286
|
theme: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeMirror.d.ts","sourceRoot":"","sources":["../../src/components/CodeMirror.ts"],"names":[],"mappings":"AAAA,OAAO,EAWL,KAAK,kBAAkB,EACvB,KAAK,QAAQ,EACb,KAAK,GAAG,EACR,KAAK,YAAY,EAElB,MAAM,UAAU,CAAC;AAOlB,OAAO,EAAE,eAAe,EAAE,WAAW,EAAe,MAAM,mBAAmB,CAAC;AAC9E,OAAO,EAAE,UAAU,EAAU,MAAM,kBAAkB,CAAC;AAKtD,OAAO,KAAK,EACV,SAAS,EACT,cAAc,EACd,IAAI,EAEL,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE3C,qBAAqB;AACrB,MAAM,WAAW,sBAAuB,SAAQ,kBAAkB;IAChE,mBAAmB;IACn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B,MAAM;qBAEN,MAAM;0BAED,SAAS,cAAc,EAAE;wBAG3B,MAAM;yBASL,MAAM,EAAE;6BAKJ,OAAO;gCAatB,MAAM,GAAG,IAAI,QACpB,MAAM,MACR,MAAM;oCAW2B,MAAM,GAAG,IAAI;0BAOvB,MAAM;2BAOL,MAAM,SAAS,MAAM;4BASzC,SAAS,cAAc,EAAE,YACvB,MAAM;4BAUa,QAAQ;;IAnXvC,kBAAkB;;;;;IAKlB;;;;OAIG;;;;;;;IAOH,gBAAgB;;;;;IAKhB;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAOH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;AA3HtB,wBAibG"}
|
package/dist/index.es.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* vue-codemirror6
|
|
3
3
|
*
|
|
4
|
-
* @description CodeMirror6 Component for vue2 and vue3
|
|
4
|
+
* @description CodeMirror6 Component for vue2 and vue3.
|
|
5
5
|
* @author Logue <logue@hotmail.co.jp>
|
|
6
6
|
* @copyright 2022 By Masashi Yoshikawa All rights reserved.
|
|
7
7
|
* @license MIT
|
|
8
|
-
* @version 1.0.
|
|
8
|
+
* @version 1.0.1
|
|
9
9
|
* @see {@link https://github.com/logue/vue-codemirror6}
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
import { isVue2 as C, Vue2 as V, h as
|
|
12
|
+
import { isVue2 as C, Vue2 as V, h as p, defineComponent as B, ref as g, shallowRef as x, computed as u, toRaw as O, watch as m, onMounted as M, nextTick as R, onUnmounted as j } from "vue-demi";
|
|
13
13
|
import { compact as E, trim as T } from "lodash";
|
|
14
14
|
import { EditorState as y, StateEffect as $, EditorSelection as S } from "@codemirror/state";
|
|
15
15
|
import { EditorView as c, keymap as D } from "@codemirror/view";
|
|
@@ -18,9 +18,13 @@ import { basicSetup as A, minimalSetup as F } from "codemirror";
|
|
|
18
18
|
import { indentWithTab as N } from "@codemirror/commands";
|
|
19
19
|
const U = (a) => a ? Object.entries(a).reduce((l, [o, s]) => (o = o.charAt(0).toUpperCase() + o.slice(1), o = `on${o}`, { ...l, [o]: s }), {}) : {}, w = (a, l = {}, o) => {
|
|
20
20
|
if (C && parseInt(V.version) < 2.7)
|
|
21
|
-
return
|
|
21
|
+
return p(a, l, o);
|
|
22
22
|
const { props: s, domProps: t, on: i, ...r } = l, d = i ? U(i) : {};
|
|
23
|
-
return
|
|
23
|
+
return p(
|
|
24
|
+
a,
|
|
25
|
+
{ ...r, ...s, ...t, ...d },
|
|
26
|
+
o
|
|
27
|
+
);
|
|
24
28
|
}, W = (a) => typeof a == "function" ? a() : a, b = B({
|
|
25
29
|
name: "CodeMirror",
|
|
26
30
|
model: {
|
|
@@ -89,7 +93,7 @@ const U = (a) => a ? Object.entries(a).reduce((l, [o, s]) => (o = o.charAt(0).to
|
|
|
89
93
|
},
|
|
90
94
|
emits: ["update:modelValue", "update", "ready", "focus", "changed"],
|
|
91
95
|
setup(a, l) {
|
|
92
|
-
const o =
|
|
96
|
+
const o = g(), s = g(a.modelValue), t = x(new c()), i = u({
|
|
93
97
|
get: () => t.value.state.selection,
|
|
94
98
|
set: (e) => t.value.dispatch({ selection: e })
|
|
95
99
|
}), r = u({
|
|
@@ -103,27 +107,35 @@ const U = (a) => a ? Object.entries(a).reduce((l, [o, s]) => (o = o.charAt(0).to
|
|
|
103
107
|
set: (e) => {
|
|
104
108
|
e && t.value.focus();
|
|
105
109
|
}
|
|
106
|
-
}), h = u(
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
110
|
+
}), h = u(
|
|
111
|
+
() => E([
|
|
112
|
+
a.basic ? A : void 0,
|
|
113
|
+
a.minimal && !a.basic ? F : void 0,
|
|
114
|
+
c.updateListener.of(
|
|
115
|
+
(e) => l.emit("update", e)
|
|
116
|
+
),
|
|
117
|
+
c.theme(a.theme, { dark: a.dark }),
|
|
118
|
+
a.wrap ? c.lineWrapping : void 0,
|
|
119
|
+
a.tab ? D.of([N]) : void 0,
|
|
120
|
+
a.phrases ? y.phrases.of(a.phrases) : void 0,
|
|
121
|
+
y.readOnly.of(a.readonly),
|
|
122
|
+
c.editable.of(a.editable),
|
|
123
|
+
a.lang ? O(a.lang) : void 0,
|
|
124
|
+
a.linter ? G(a.linter) : void 0,
|
|
125
|
+
a.linter && a.lintGutter ? L() : void 0,
|
|
126
|
+
...a.extensions
|
|
127
|
+
])
|
|
128
|
+
);
|
|
129
|
+
return m(
|
|
130
|
+
() => a.modelValue,
|
|
131
|
+
(e) => {
|
|
132
|
+
!t.value || t.value.composing || t.value.dispatch({
|
|
133
|
+
changes: { from: 0, to: t.value.state.doc.length, insert: e },
|
|
134
|
+
selection: i.value
|
|
135
|
+
});
|
|
136
|
+
},
|
|
137
|
+
{ immediate: !0 }
|
|
138
|
+
), m(h, (e) => {
|
|
127
139
|
t.value.dispatch({
|
|
128
140
|
effects: $.reconfigure.of(e)
|
|
129
141
|
});
|
|
@@ -131,7 +143,9 @@ const U = (a) => a ? Object.entries(a).reduce((l, [o, s]) => (o = o.charAt(0).to
|
|
|
131
143
|
l.emit("focus", e);
|
|
132
144
|
}), M(async () => {
|
|
133
145
|
let e = s.value;
|
|
134
|
-
o.value && o.value.childNodes[0] && (s.value !== "" && console.warn(
|
|
146
|
+
o.value && o.value.childNodes[0] && (s.value !== "" && console.warn(
|
|
147
|
+
"[CodeMirror.vue] The <code-mirror> tag contains child elements that overwrite the `v-model` values."
|
|
148
|
+
), e = T(o.value.childNodes[0].innerText)), t.value = new c({
|
|
135
149
|
doc: e,
|
|
136
150
|
extensions: h.value,
|
|
137
151
|
parent: o.value,
|
|
@@ -158,9 +172,16 @@ const U = (a) => a ? Object.entries(a).reduce((l, [o, s]) => (o = o.charAt(0).to
|
|
|
158
172
|
lineCount: () => t.value.state.doc.lines,
|
|
159
173
|
getCursor: () => r.value,
|
|
160
174
|
listSelections: () => t.value.state.selection.ranges,
|
|
161
|
-
getSelection: () => t.value.state.sliceDoc(
|
|
162
|
-
|
|
163
|
-
|
|
175
|
+
getSelection: () => t.value.state.sliceDoc(
|
|
176
|
+
t.value.state.selection.main.from,
|
|
177
|
+
t.value.state.selection.main.to
|
|
178
|
+
),
|
|
179
|
+
getSelections: () => t.value.state.selection.ranges.map(
|
|
180
|
+
(e) => t.value.state.sliceDoc(e.from, e.to)
|
|
181
|
+
),
|
|
182
|
+
somethingSelected: () => t.value.state.selection.ranges.some(
|
|
183
|
+
(e) => !e.empty
|
|
184
|
+
),
|
|
164
185
|
replaceRange: (e, n, v) => t.value.dispatch({
|
|
165
186
|
changes: { from: n, to: v, insert: e }
|
|
166
187
|
}),
|
|
@@ -171,15 +192,25 @@ const U = (a) => a ? Object.entries(a).reduce((l, [o, s]) => (o = o.charAt(0).to
|
|
|
171
192
|
selection: S.create(e, n)
|
|
172
193
|
}),
|
|
173
194
|
extendSelectionsBy: (e) => t.value.dispatch({
|
|
174
|
-
selection: S.create(
|
|
195
|
+
selection: S.create(
|
|
196
|
+
i.value.ranges.map((n) => n.extend(e(n)))
|
|
197
|
+
)
|
|
175
198
|
})
|
|
176
199
|
};
|
|
177
200
|
},
|
|
178
201
|
render() {
|
|
179
|
-
return w(
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
202
|
+
return w(
|
|
203
|
+
"div",
|
|
204
|
+
{
|
|
205
|
+
ref: "editor",
|
|
206
|
+
class: "vue-codemirror"
|
|
207
|
+
},
|
|
208
|
+
this.$slots.default ? w(
|
|
209
|
+
"aside",
|
|
210
|
+
{ style: "display: none;", "aria-hidden": "true" },
|
|
211
|
+
W(this.$slots.default)
|
|
212
|
+
) : void 0
|
|
213
|
+
);
|
|
183
214
|
}
|
|
184
215
|
}), ce = (a) => a.component("CodeMirror", b);
|
|
185
216
|
typeof window < "u" && window.Vue && window.Vue.use(b);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* vue-codemirror6
|
|
3
|
+
*
|
|
4
|
+
* @description CodeMirror6 Component for vue2 and vue3.
|
|
5
|
+
* @author Logue <logue@hotmail.co.jp>
|
|
6
|
+
* @copyright 2022 By Masashi Yoshikawa All rights reserved.
|
|
7
|
+
* @license MIT
|
|
8
|
+
* @version 1.0.1
|
|
9
|
+
* @see {@link https://github.com/logue/vue-codemirror6}
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
var CodeMirror=function(f,n,m,r,i,p,S,b){"use strict";const C=a=>a?Object.entries(a).reduce((s,[o,d])=>(o=o.charAt(0).toUpperCase()+o.slice(1),o=`on${o}`,{...s,[o]:d}),{}):{},y=(a,s={},o)=>{if(n.isVue2&&parseInt(n.Vue2.version)<2.7)return n.h(a,s,o);const{props:d,domProps:t,on:c,...u}=s,v=c?C(c):{};return n.h(a,{...u,...d,...t,...v},o)},E=a=>typeof a=="function"?a():a,g=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},wrap:{type:Boolean,default:!1},tab:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1},editable:{type:Boolean,default:!0},extensions:{type:Array,default:()=>[]},phrases:{type:Object,default:()=>{}},lang:{type:Object,default:()=>{}},linter:{type:Function,default:void 0},lintGutter:{type:Boolean,defalt:!1}},emits:["update:modelValue","update","ready","focus","changed"],setup(a,s){const o=n.ref(),d=n.ref(a.modelValue),t=n.shallowRef(new i.EditorView),c=n.computed({get:()=>t.value.state.selection,set:e=>t.value.dispatch({selection:e})}),u=n.computed({get:()=>c.value.main.head||0,set:e=>t.value.dispatch({selection:{anchor:e}})}),v=n.computed({get:()=>t.value.state,set:e=>t.value.setState(e)}),w=n.computed({get:()=>t.value.hasFocus,set:e=>{e&&t.value.focus()}}),V=n.computed(()=>m.compact([a.basic?S.basicSetup:void 0,a.minimal&&!a.basic?S.minimalSetup:void 0,i.EditorView.updateListener.of(e=>s.emit("update",e)),i.EditorView.theme(a.theme,{dark:a.dark}),a.wrap?i.EditorView.lineWrapping:void 0,a.tab?i.keymap.of([b.indentWithTab]):void 0,a.phrases?r.EditorState.phrases.of(a.phrases):void 0,r.EditorState.readOnly.of(a.readonly),i.EditorView.editable.of(a.editable),a.lang?n.toRaw(a.lang):void 0,a.linter?p.linter(a.linter):void 0,a.linter&&a.lintGutter?p.lintGutter():void 0,...a.extensions]));return n.watch(()=>a.modelValue,e=>{!t.value||t.value.composing||t.value.dispatch({changes:{from:0,to:t.value.state.doc.length,insert:e},selection:c.value})},{immediate:!0}),n.watch(V,e=>{t.value.dispatch({effects:r.StateEffect.reconfigure.of(e)})}),n.watch(w,e=>{s.emit("focus",e)}),n.onMounted(async()=>{let e=d.value;o.value&&o.value.childNodes[0]&&(d.value!==""&&console.warn("[CodeMirror.vue] The <code-mirror> tag contains child elements that overwrite the `v-model` values."),e=m.trim(o.value.childNodes[0].innerText)),t.value=new i.EditorView({doc:e,extensions:V.value,parent:o.value,dispatch:l=>{if(t.value.update([l]),l.changes.empty)return;const h=t.value.state.doc.toString();s.emit("update:modelValue",h),s.emit("changed",h)}}),await n.nextTick(),s.emit("ready",{view:t,state:v.value,container:o.value})}),n.onUnmounted(()=>t.value.destroy()),{context:s,editor:o,cursor:u,selection:c,state:v,focus:w,getRange:(e,l)=>t.value.state.sliceDoc(e,l),getLine:e=>t.value.state.doc.line(e+1).text,lineCount:()=>t.value.state.doc.lines,getCursor:()=>u.value,listSelections:()=>t.value.state.selection.ranges,getSelection:()=>t.value.state.sliceDoc(t.value.state.selection.main.from,t.value.state.selection.main.to),getSelections:()=>t.value.state.selection.ranges.map(e=>t.value.state.sliceDoc(e.from,e.to)),somethingSelected:()=>t.value.state.selection.ranges.some(e=>!e.empty),replaceRange:(e,l,h)=>t.value.dispatch({changes:{from:l,to:h,insert:e}}),replaceSelection:e=>t.value.dispatch(t.value.state.replaceSelection(e)),setCursor:e=>u.value=e,setSelection:(e,l)=>t.value.dispatch({selection:{anchor:e,head:l}}),setSelections:(e,l)=>t.value.dispatch({selection:r.EditorSelection.create(e,l)}),extendSelectionsBy:e=>t.value.dispatch({selection:r.EditorSelection.create(c.value.ranges.map(l=>l.extend(e(l))))})}},render(){return y("div",{ref:"editor",class:"vue-codemirror"},this.$slots.default?y("aside",{style:"display: none;","aria-hidden":"true"},E(this.$slots.default)):void 0)}}),B=a=>a.component("CodeMirror",g);return typeof window<"u"&&window.Vue&&window.Vue.use(g),f.default=g,f.install=B,Object.defineProperties(f,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),f}({},VueDemi,lodash,state,view,lint,codemirror,commands);
|
package/dist/index.umd.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* vue-codemirror6
|
|
3
3
|
*
|
|
4
|
-
* @description CodeMirror6 Component for vue2 and vue3
|
|
4
|
+
* @description CodeMirror6 Component for vue2 and vue3.
|
|
5
5
|
* @author Logue <logue@hotmail.co.jp>
|
|
6
6
|
* @copyright 2022 By Masashi Yoshikawa All rights reserved.
|
|
7
7
|
* @license MIT
|
|
8
|
-
* @version 1.0.
|
|
8
|
+
* @version 1.0.1
|
|
9
9
|
* @see {@link https://github.com/logue/vue-codemirror6}
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
(function(i,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("vue-demi"),require("lodash"),require("@codemirror/state"),require("@codemirror/view"),require("@codemirror/lint"),require("codemirror"),require("@codemirror/commands")):typeof define=="function"&&define.amd?define(["exports","vue-demi","lodash","@codemirror/state","@codemirror/view","@codemirror/lint","codemirror","@codemirror/commands"],a):(i=typeof globalThis<"u"?globalThis:i||self,a(i.CodeMirror={},i.VueDemi,i.lodash,i.state,i.view,i.lint,i.codemirror,i.commands))})(this,function(i,a,p,u,r,g,y,C){"use strict";const
|
|
12
|
+
(function(i,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("vue-demi"),require("lodash"),require("@codemirror/state"),require("@codemirror/view"),require("@codemirror/lint"),require("codemirror"),require("@codemirror/commands")):typeof define=="function"&&define.amd?define(["exports","vue-demi","lodash","@codemirror/state","@codemirror/view","@codemirror/lint","codemirror","@codemirror/commands"],a):(i=typeof globalThis<"u"?globalThis:i||self,a(i.CodeMirror={},i.VueDemi,i.lodash,i.state,i.view,i.lint,i.codemirror,i.commands))})(this,function(i,a,p,u,r,g,y,C){"use strict";const E=o=>o?Object.entries(o).reduce((l,[n,c])=>(n=n.charAt(0).toUpperCase()+n.slice(1),n=`on${n}`,{...l,[n]:c}),{}):{},S=(o,l={},n)=>{if(a.isVue2&&parseInt(a.Vue2.version)<2.7)return a.h(o,l,n);const{props:c,domProps:t,on:d,...f}=l,m=d?E(d):{};return a.h(o,{...f,...c,...t,...m},n)},b=o=>typeof o=="function"?o():o,h=a.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},wrap:{type:Boolean,default:!1},tab:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1},editable:{type:Boolean,default:!0},extensions:{type:Array,default:()=>[]},phrases:{type:Object,default:()=>{}},lang:{type:Object,default:()=>{}},linter:{type:Function,default:void 0},lintGutter:{type:Boolean,defalt:!1}},emits:["update:modelValue","update","ready","focus","changed"],setup(o,l){const n=a.ref(),c=a.ref(o.modelValue),t=a.shallowRef(new r.EditorView),d=a.computed({get:()=>t.value.state.selection,set:e=>t.value.dispatch({selection:e})}),f=a.computed({get:()=>d.value.main.head||0,set:e=>t.value.dispatch({selection:{anchor:e}})}),m=a.computed({get:()=>t.value.state,set:e=>t.value.setState(e)}),w=a.computed({get:()=>t.value.hasFocus,set:e=>{e&&t.value.focus()}}),V=a.computed(()=>p.compact([o.basic?y.basicSetup:void 0,o.minimal&&!o.basic?y.minimalSetup:void 0,r.EditorView.updateListener.of(e=>l.emit("update",e)),r.EditorView.theme(o.theme,{dark:o.dark}),o.wrap?r.EditorView.lineWrapping:void 0,o.tab?r.keymap.of([C.indentWithTab]):void 0,o.phrases?u.EditorState.phrases.of(o.phrases):void 0,u.EditorState.readOnly.of(o.readonly),r.EditorView.editable.of(o.editable),o.lang?a.toRaw(o.lang):void 0,o.linter?g.linter(o.linter):void 0,o.linter&&o.lintGutter?g.lintGutter():void 0,...o.extensions]));return a.watch(()=>o.modelValue,e=>{!t.value||t.value.composing||t.value.dispatch({changes:{from:0,to:t.value.state.doc.length,insert:e},selection:d.value})},{immediate:!0}),a.watch(V,e=>{t.value.dispatch({effects:u.StateEffect.reconfigure.of(e)})}),a.watch(w,e=>{l.emit("focus",e)}),a.onMounted(async()=>{let e=c.value;n.value&&n.value.childNodes[0]&&(c.value!==""&&console.warn("[CodeMirror.vue] The <code-mirror> tag contains child elements that overwrite the `v-model` values."),e=p.trim(n.value.childNodes[0].innerText)),t.value=new r.EditorView({doc:e,extensions:V.value,parent:n.value,dispatch:s=>{if(t.value.update([s]),s.changes.empty)return;const v=t.value.state.doc.toString();l.emit("update:modelValue",v),l.emit("changed",v)}}),await a.nextTick(),l.emit("ready",{view:t,state:m.value,container:n.value})}),a.onUnmounted(()=>t.value.destroy()),{context:l,editor:n,cursor:f,selection:d,state:m,focus:w,getRange:(e,s)=>t.value.state.sliceDoc(e,s),getLine:e=>t.value.state.doc.line(e+1).text,lineCount:()=>t.value.state.doc.lines,getCursor:()=>f.value,listSelections:()=>t.value.state.selection.ranges,getSelection:()=>t.value.state.sliceDoc(t.value.state.selection.main.from,t.value.state.selection.main.to),getSelections:()=>t.value.state.selection.ranges.map(e=>t.value.state.sliceDoc(e.from,e.to)),somethingSelected:()=>t.value.state.selection.ranges.some(e=>!e.empty),replaceRange:(e,s,v)=>t.value.dispatch({changes:{from:s,to:v,insert:e}}),replaceSelection:e=>t.value.dispatch(t.value.state.replaceSelection(e)),setCursor:e=>f.value=e,setSelection:(e,s)=>t.value.dispatch({selection:{anchor:e,head:s}}),setSelections:(e,s)=>t.value.dispatch({selection:u.EditorSelection.create(e,s)}),extendSelectionsBy:e=>t.value.dispatch({selection:u.EditorSelection.create(d.value.ranges.map(s=>s.extend(e(s))))})}},render(){return S("div",{ref:"editor",class:"vue-codemirror"},this.$slots.default?S("aside",{style:"display: none;","aria-hidden":"true"},b(this.$slots.default)):void 0)}}),B=o=>o.component("CodeMirror",h);typeof window<"u"&&window.Vue&&window.Vue.use(h),i.default=h,i.install=B,Object.defineProperties(i,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "vue-codemirror6",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.1",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"description": "CodeMirror6 Component for vue2 and vue3",
|
|
6
|
+
"description": "CodeMirror6 Component for vue2 and vue3.",
|
|
7
7
|
"keywords": [
|
|
8
8
|
"vuejs",
|
|
9
9
|
"vue",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"node": ">=16.17.0",
|
|
55
55
|
"yarn": ">=1.22.10"
|
|
56
56
|
},
|
|
57
|
-
"packageManager": "yarn@3.2.
|
|
57
|
+
"packageManager": "yarn@3.2.3",
|
|
58
58
|
"sideEffects": false,
|
|
59
59
|
"scripts": {
|
|
60
60
|
"dev": "vite",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"peerDependencies": {
|
|
75
75
|
"@vue/composition-api": "^1.7.0",
|
|
76
76
|
"codemirror": "^6.0.1",
|
|
77
|
-
"vue": "^2.6.14 || ^3.2.
|
|
77
|
+
"vue": "^2.6.14 || ^3.2.39"
|
|
78
78
|
},
|
|
79
79
|
"peerDependenciesMeta": {
|
|
80
80
|
"@vue/composition-api": {
|
|
@@ -85,23 +85,23 @@
|
|
|
85
85
|
"@codemirror/lang-javascript": "^6.0.2",
|
|
86
86
|
"@codemirror/lang-markdown": "^6.0.1",
|
|
87
87
|
"@types/lodash": "^4.14.184",
|
|
88
|
-
"@types/node": "^18.7.
|
|
89
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
90
|
-
"@typescript-eslint/parser": "^5.
|
|
91
|
-
"@vitejs/plugin-vue": "^3.0
|
|
88
|
+
"@types/node": "^18.7.16",
|
|
89
|
+
"@typescript-eslint/eslint-plugin": "^5.36.2",
|
|
90
|
+
"@typescript-eslint/parser": "^5.36.2",
|
|
91
|
+
"@vitejs/plugin-vue": "^3.1.0",
|
|
92
92
|
"@vue/eslint-config-prettier": "^7.0.0",
|
|
93
93
|
"@vue/tsconfig": "^0.1.3",
|
|
94
94
|
"codemirror": "^6.0.1",
|
|
95
|
-
"eslint": "^8.
|
|
95
|
+
"eslint": "^8.23.0",
|
|
96
96
|
"eslint-config-google": "^0.14.0",
|
|
97
97
|
"eslint-config-prettier": "^8.5.0",
|
|
98
98
|
"eslint-import-resolver-alias": "^1.1.2",
|
|
99
|
-
"eslint-import-resolver-typescript": "^3.
|
|
99
|
+
"eslint-import-resolver-typescript": "^3.5.1",
|
|
100
100
|
"eslint-plugin-html": "^7.1.0",
|
|
101
101
|
"eslint-plugin-import": "^2.26.0",
|
|
102
102
|
"eslint-plugin-jsdoc": "^39.3.6",
|
|
103
103
|
"eslint-plugin-tsdoc": "^0.2.16",
|
|
104
|
-
"eslint-plugin-vue": "^9.
|
|
104
|
+
"eslint-plugin-vue": "^9.4.0",
|
|
105
105
|
"eslint-plugin-vuejs-accessibility": "^1.2.0",
|
|
106
106
|
"eslint-plugin-yaml": "^0.5.0",
|
|
107
107
|
"eslint4b-prebuilt": "^6.7.2",
|
|
@@ -110,14 +110,14 @@
|
|
|
110
110
|
"lodash": "^4.17.21",
|
|
111
111
|
"prettier": "^2.7.1",
|
|
112
112
|
"rimraf": "^3.0.2",
|
|
113
|
-
"rollup-plugin-visualizer": "^5.
|
|
114
|
-
"typescript": "^4.
|
|
115
|
-
"vite": "^3.0
|
|
116
|
-
"vite-plugin-banner": "^0.
|
|
117
|
-
"vite-plugin-checker": "^0.
|
|
118
|
-
"vue": "^3.2.
|
|
113
|
+
"rollup-plugin-visualizer": "^5.8.1",
|
|
114
|
+
"typescript": "^4.8.2",
|
|
115
|
+
"vite": "^3.1.0",
|
|
116
|
+
"vite-plugin-banner": "^0.5.0",
|
|
117
|
+
"vite-plugin-checker": "^0.5.1",
|
|
118
|
+
"vue": "^3.2.39",
|
|
119
119
|
"vue-eslint-parser": "^9.0.3",
|
|
120
|
-
"vue-tsc": "^0.40.
|
|
120
|
+
"vue-tsc": "^0.40.13"
|
|
121
121
|
},
|
|
122
122
|
"husky": {
|
|
123
123
|
"hooks": {
|