vue-codemirror6 0.6.7 → 0.6.8
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/README.md +11 -7
- package/dist/components/CodeMirror.d.ts.map +1 -1
- package/dist/index.es.js +54 -57
- package/dist/index.umd.js +2 -2
- package/package.json +11 -11
package/README.md
CHANGED
|
@@ -30,7 +30,7 @@ For Vue 2.7 or later, import vue directly like Vue3.
|
|
|
30
30
|
| ---------- | --------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
31
31
|
| basic | boolean | Use [basicSetup](https://codemirror.net/docs/ref/#codemirror.basicSetup). |
|
|
32
32
|
| minimal | boolean | Use [miniSetup](https://codemirror.net/docs/ref/#codemirror.minimalSetup). If a `basic` prop is also specified, that setting will take precedence. |
|
|
33
|
-
| dark | boolean | Toggle Darkmode.
|
|
33
|
+
| dark | boolean | Toggle Darkmode. |
|
|
34
34
|
| wrap | boolean | Line text wrapping. see [lineWrapping](https://codemirror.net/6/docs/ref/#view.EditorView.lineWrapping). |
|
|
35
35
|
| tab | boolean | Enables tab indentation. |
|
|
36
36
|
| theme | { [selector: string]: StyleSpec } | Specify the theme. For example, if you use [@codemirror/theme-one-dark](https://github.com/codemirror/theme-one-dark), import `oneDark` and put it in this prop. |
|
|
@@ -170,6 +170,11 @@ export default defineComponent({
|
|
|
170
170
|
/** text */
|
|
171
171
|
const value: Ref<string> = ref('');
|
|
172
172
|
|
|
173
|
+
/** Dark mode **/
|
|
174
|
+
const dark: Ref<boolean> = ref(
|
|
175
|
+
window.matchMedia('(prefers-color-scheme: dark)').matches
|
|
176
|
+
);
|
|
177
|
+
|
|
173
178
|
/**
|
|
174
179
|
* CodeMirror Language
|
|
175
180
|
*
|
|
@@ -177,12 +182,6 @@ export default defineComponent({
|
|
|
177
182
|
*/
|
|
178
183
|
const lang: LanguageSupport = md();
|
|
179
184
|
|
|
180
|
-
/** Dark mode **/
|
|
181
|
-
const dark = ref(window.matchMedia('(prefers-color-scheme: dark)').matches);
|
|
182
|
-
|
|
183
|
-
/** When dark value changed, sync vuetify's dark mode */
|
|
184
|
-
watch(dark, v => (vuetify.theme.dark = v));
|
|
185
|
-
|
|
186
185
|
/**
|
|
187
186
|
* Internationalization Config.
|
|
188
187
|
* In this example, the display language to Japanese.
|
|
@@ -221,6 +220,9 @@ export default defineComponent({
|
|
|
221
220
|
'No diagnostics': 'エラーなし',
|
|
222
221
|
});
|
|
223
222
|
|
|
223
|
+
/** When dark value changed, sync vuetify's dark mode */
|
|
224
|
+
watch(dark, v => (vuetify.theme.dark = v));
|
|
225
|
+
|
|
224
226
|
return {
|
|
225
227
|
dark,
|
|
226
228
|
value,
|
|
@@ -295,3 +297,5 @@ const config: UserConfig = {
|
|
|
295
297
|
## LICENSE
|
|
296
298
|
|
|
297
299
|
[MIT](LICENSE)
|
|
300
|
+
|
|
301
|
+
© 2022 by Logue.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeMirror.d.ts","sourceRoot":"","sources":["../../src/components/CodeMirror.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"CodeMirror.d.ts","sourceRoot":"","sources":["../../src/components/CodeMirror.ts"],"names":[],"mappings":"AAAA,OAAO,EAUL,KAAK,QAAQ,EACb,KAAK,GAAG,EACR,KAAK,YAAY,EAClB,MAAM,UAAU,CAAC;AAOlB,OAAO,EAAE,eAAe,EAAE,WAAW,EAAe,MAAM,mBAAmB,CAAC;AAM9E,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,wBAAwB;IACvC,mBAAmB;IACnB,CAAC,CAAC,EAAE,mBAAmB,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAAC;IACrD,4BAA4B;IAC5B,CAAC,CAAC,EAAE,aAAa,EAAE,KAAK,EAAE,UAAU,GAAG,IAAI,CAAC;CAC7C;AAED,2BAA2B;;IAWvB,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;;;;;;;;;;;;sBA6JO,MAAM,OAAO,MAAM,KAAG,MAAM;sBAO5B,MAAM,KAAG,MAAM;qBAGlB,MAAM;qBAEN,MAAM;0BAED,SAAS,cAAc,EAAE;wBAG3B,MAAM;yBASL,MAAM,EAAE;6BAGJ,OAAO;gCAWtB,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;;IArWvC,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,wBAmaG"}
|
package/dist/index.es.js
CHANGED
|
@@ -5,23 +5,23 @@
|
|
|
5
5
|
* @author Logue <logue@hotmail.co.jp>
|
|
6
6
|
* @copyright 2022 By Masashi Yoshikawa All rights reserved.
|
|
7
7
|
* @license MIT
|
|
8
|
-
* @version 0.6.
|
|
8
|
+
* @version 0.6.8
|
|
9
9
|
* @see {@link https://github.com/logue/vue-codemirror6}
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
import { isVue2 as V, Vue2 as
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import { EditorView as
|
|
12
|
+
import { isVue2 as V, Vue2 as x, h, defineComponent as B, ref as p, computed as r, toRaw as O, watch as v, onMounted as M, nextTick as R, onUnmounted as j } from "vue-demi";
|
|
13
|
+
import { compact as E, trim as T } from "lodash";
|
|
14
|
+
import { EditorState as g, StateEffect as $, EditorSelection as y } from "@codemirror/state";
|
|
15
|
+
import { EditorView as d, keymap as D } from "@codemirror/view";
|
|
16
16
|
import { linter as G, lintGutter as L } from "@codemirror/lint";
|
|
17
17
|
import { basicSetup as A, minimalSetup as F } from "codemirror";
|
|
18
18
|
import { indentWithTab as N } from "@codemirror/commands";
|
|
19
|
-
const U = (t) => t ? Object.entries(t).reduce((i, [n, s]) => (n = n.charAt(0).toUpperCase() + n.slice(1), n = `on${n}`, { ...i, [n]: s }), {}) : {},
|
|
20
|
-
if (V && parseInt(
|
|
19
|
+
const U = (t) => t ? Object.entries(t).reduce((i, [n, s]) => (n = n.charAt(0).toUpperCase() + n.slice(1), n = `on${n}`, { ...i, [n]: s }), {}) : {}, S = (t, i = {}, n) => {
|
|
20
|
+
if (V && parseInt(x.version) < 2.7)
|
|
21
21
|
return h(t, i, n);
|
|
22
22
|
const { props: s, domProps: o, on: l, ...c } = i, u = l ? U(l) : {};
|
|
23
23
|
return h(t, { ...c, ...s, ...o, ...u }, n);
|
|
24
|
-
}, W = (t) => typeof t == "function" ? t() : t,
|
|
24
|
+
}, W = (t) => typeof t == "function" ? t() : t, w = B({
|
|
25
25
|
name: "CodeMirror",
|
|
26
26
|
model: {
|
|
27
27
|
prop: "modelValue",
|
|
@@ -89,69 +89,66 @@ const U = (t) => t ? Object.entries(t).reduce((i, [n, s]) => (n = n.charAt(0).to
|
|
|
89
89
|
},
|
|
90
90
|
emits: ["update:modelValue", "update:view"],
|
|
91
91
|
setup(t, i) {
|
|
92
|
-
const n =
|
|
92
|
+
const n = p(), s = p(t.modelValue);
|
|
93
93
|
let o;
|
|
94
|
-
const l =
|
|
94
|
+
const l = r({
|
|
95
95
|
get: () => o.state.selection,
|
|
96
96
|
set: (e) => o.dispatch({ selection: e })
|
|
97
|
-
}), c =
|
|
97
|
+
}), c = r({
|
|
98
98
|
get: () => l.value.main.head || 0,
|
|
99
99
|
set: (e) => o.dispatch({ selection: { anchor: e } })
|
|
100
|
-
}), u =
|
|
100
|
+
}), u = r({
|
|
101
101
|
get: () => o.state,
|
|
102
102
|
set: (e) => o.setState(e)
|
|
103
|
-
}),
|
|
103
|
+
}), b = r({
|
|
104
104
|
get: () => o.hasFocus,
|
|
105
105
|
set: (e) => {
|
|
106
106
|
e && o.focus();
|
|
107
107
|
}
|
|
108
|
-
}), m =
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
108
|
+
}), m = r(() => E([
|
|
109
|
+
t.basic ? A : void 0,
|
|
110
|
+
t.minimal && !t.basic ? F : void 0,
|
|
111
|
+
d.updateListener.of((e) => f("update:view", e)),
|
|
112
|
+
d.theme(t.theme, { dark: t.dark }),
|
|
113
|
+
t.wrap ? d.lineWrapping : void 0,
|
|
114
|
+
t.tab ? D.of([N]) : void 0,
|
|
115
|
+
t.phrases ? g.phrases.of(t.phrases) : void 0,
|
|
116
|
+
t.readonly ? g.readOnly.of(t.readonly) : void 0,
|
|
117
|
+
t.editable ? d.editable.of(t.editable) : void 0,
|
|
118
|
+
t.lang ? O(t.lang) : void 0,
|
|
119
|
+
t.linter ? G(t.linter) : void 0,
|
|
120
|
+
t.linter && t.lintGutter ? L() : void 0,
|
|
121
|
+
...t.extensions
|
|
122
|
+
])), f = i.emit;
|
|
123
|
+
return v(() => t.modelValue, (e) => {
|
|
124
|
+
if (o.composing)
|
|
125
|
+
return;
|
|
126
|
+
const a = o.state.selection;
|
|
119
127
|
o.dispatch({
|
|
120
|
-
|
|
128
|
+
changes: { from: 0, to: o.state.doc.length, insert: e },
|
|
129
|
+
selection: a
|
|
121
130
|
});
|
|
122
|
-
}),
|
|
131
|
+
}), v(m, (e) => {
|
|
132
|
+
o.dispatch({
|
|
133
|
+
effects: $.reconfigure.of(e)
|
|
134
|
+
});
|
|
135
|
+
}), M(async () => {
|
|
123
136
|
let e = s.value;
|
|
124
|
-
n.value && n.value.childNodes[0] && (s.value !== "" && console.warn("[CodeMirror.vue] The <code-mirror> tag contains child elements that overwrite the `v-model` values."), e =
|
|
137
|
+
n.value && n.value.childNodes[0] && (s.value !== "" && console.warn("[CodeMirror.vue] The <code-mirror> tag contains child elements that overwrite the `v-model` values."), e = T(n.value.childNodes[0].innerText)), o = new d({
|
|
125
138
|
doc: e,
|
|
126
|
-
extensions:
|
|
139
|
+
extensions: m.value,
|
|
127
140
|
parent: n.value,
|
|
128
141
|
dispatch: (a) => {
|
|
129
|
-
o.update([a]), !a.changes.empty &&
|
|
142
|
+
o.update([a]), !a.changes.empty && f("update:modelValue", o.state.doc.toString());
|
|
130
143
|
}
|
|
131
|
-
}), await
|
|
132
|
-
}),
|
|
133
|
-
const f = () => T([
|
|
134
|
-
t.basic ? A : void 0,
|
|
135
|
-
t.minimal && !t.basic ? F : void 0,
|
|
136
|
-
r.updateListener.of((e) => m("update:view", e)),
|
|
137
|
-
r.theme(t.theme, { dark: t.dark }),
|
|
138
|
-
t.wrap ? r.lineWrapping : void 0,
|
|
139
|
-
t.tab ? D.of([N]) : void 0,
|
|
140
|
-
t.phrases ? p.phrases.of(t.phrases) : void 0,
|
|
141
|
-
t.readonly ? p.readOnly.of(t.readonly) : void 0,
|
|
142
|
-
t.editable ? r.editable.of(t.editable) : void 0,
|
|
143
|
-
t.lang ? R(t.lang) : void 0,
|
|
144
|
-
t.linter ? G(t.linter) : void 0,
|
|
145
|
-
t.linter && t.lintGutter ? L() : void 0,
|
|
146
|
-
...t.extensions
|
|
147
|
-
]);
|
|
148
|
-
return {
|
|
144
|
+
}), await R();
|
|
145
|
+
}), j(() => o.destroy()), {
|
|
149
146
|
context: i,
|
|
150
147
|
editor: n,
|
|
151
148
|
cursor: c,
|
|
152
149
|
selection: l,
|
|
153
150
|
state: u,
|
|
154
|
-
focus:
|
|
151
|
+
focus: b,
|
|
155
152
|
getRange: (e, a) => o.state.sliceDoc(e, a),
|
|
156
153
|
getLine: (e) => o.state.doc.line(e + 1).text,
|
|
157
154
|
lineCount: () => o.state.doc.lines,
|
|
@@ -160,29 +157,29 @@ const U = (t) => t ? Object.entries(t).reduce((i, [n, s]) => (n = n.charAt(0).to
|
|
|
160
157
|
getSelection: () => o.state.sliceDoc(o.state.selection.main.from, o.state.selection.main.to),
|
|
161
158
|
getSelections: () => o.state.selection.ranges.map((e) => o.state.sliceDoc(e.from, e.to)),
|
|
162
159
|
somethingSelected: () => o.state.selection.ranges.some((e) => !e.empty),
|
|
163
|
-
replaceRange: (e, a,
|
|
164
|
-
changes: { from: a, to:
|
|
160
|
+
replaceRange: (e, a, C) => o.dispatch({
|
|
161
|
+
changes: { from: a, to: C, insert: e }
|
|
165
162
|
}),
|
|
166
163
|
replaceSelection: (e) => o.dispatch(o.state.replaceSelection(e)),
|
|
167
164
|
setCursor: (e) => c.value = e,
|
|
168
165
|
setSelection: (e, a) => o.dispatch({ selection: { anchor: e, head: a } }),
|
|
169
166
|
setSelections: (e, a) => o.dispatch({
|
|
170
|
-
selection:
|
|
167
|
+
selection: y.create(e, a)
|
|
171
168
|
}),
|
|
172
169
|
extendSelectionsBy: (e) => o.dispatch({
|
|
173
|
-
selection:
|
|
170
|
+
selection: y.create(l.value.ranges.map((a) => a.extend(e(a))))
|
|
174
171
|
})
|
|
175
172
|
};
|
|
176
173
|
},
|
|
177
174
|
render() {
|
|
178
|
-
return
|
|
175
|
+
return S("div", {
|
|
179
176
|
ref: "editor",
|
|
180
177
|
class: "vue-codemirror"
|
|
181
|
-
}, this.$slots.default ?
|
|
178
|
+
}, this.$slots.default ? S("aside", { style: "display: none;", "aria-hidden": "true" }, W(this.$slots.default)) : void 0);
|
|
182
179
|
}
|
|
183
|
-
}), ce = (t) => t.component("CodeMirror",
|
|
184
|
-
typeof window < "u" && window.Vue && window.Vue.use(
|
|
180
|
+
}), ce = (t) => t.component("CodeMirror", w);
|
|
181
|
+
typeof window < "u" && window.Vue && window.Vue.use(w);
|
|
185
182
|
export {
|
|
186
|
-
|
|
183
|
+
w as default,
|
|
187
184
|
ce as install
|
|
188
185
|
};
|
package/dist/index.umd.js
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* @author Logue <logue@hotmail.co.jp>
|
|
6
6
|
* @copyright 2022 By Masashi Yoshikawa All rights reserved.
|
|
7
7
|
* @license MIT
|
|
8
|
-
* @version 0.6.
|
|
8
|
+
* @version 0.6.8
|
|
9
9
|
* @see {@link https://github.com/logue/vue-codemirror6}
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
(function(a,n){typeof exports=="object"&&typeof module<"u"?n(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"],n):(a=typeof globalThis<"u"?globalThis:a||self,n(a.CodeMirror={},a.VueDemi,a.lodash,a.state,a.view,a.lint,a.codemirror,a.commands))})(this,function(a,n,p,u,d,g,y,V){"use strict";const C=t=>t?Object.entries(t).reduce((r,[i,c])=>(i=i.charAt(0).toUpperCase()+i.slice(1),i=`on${i}`,{...r,[i]:c}),{}):{},S=(t,r={},i)=>{if(n.isVue2&&parseInt(n.Vue2.version)<2.7)return n.h(t,r,i);const{props:c,domProps:o,on:l,...f}=r,h=l?C(l):{};return n.h(t,{...f,...c,...o,...h},i)},b=t=>typeof t=="function"?t():t,m=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:view"],setup(t,r){const i=n.ref(),c=n.ref(t.modelValue);let o;const l=n.computed({get:()=>o.state.selection,set:e=>o.dispatch({selection:e})}),f=n.computed({get:()=>l.value.main.head||0,set:e=>o.dispatch({selection:{anchor:e}})}),h=n.computed({get:()=>o.state,set:e=>o.setState(e)}),
|
|
12
|
+
(function(a,n){typeof exports=="object"&&typeof module<"u"?n(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"],n):(a=typeof globalThis<"u"?globalThis:a||self,n(a.CodeMirror={},a.VueDemi,a.lodash,a.state,a.view,a.lint,a.codemirror,a.commands))})(this,function(a,n,p,u,d,g,y,V){"use strict";const C=t=>t?Object.entries(t).reduce((r,[i,c])=>(i=i.charAt(0).toUpperCase()+i.slice(1),i=`on${i}`,{...r,[i]:c}),{}):{},S=(t,r={},i)=>{if(n.isVue2&&parseInt(n.Vue2.version)<2.7)return n.h(t,r,i);const{props:c,domProps:o,on:l,...f}=r,h=l?C(l):{};return n.h(t,{...f,...c,...o,...h},i)},b=t=>typeof t=="function"?t():t,m=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:view"],setup(t,r){const i=n.ref(),c=n.ref(t.modelValue);let o;const l=n.computed({get:()=>o.state.selection,set:e=>o.dispatch({selection:e})}),f=n.computed({get:()=>l.value.main.head||0,set:e=>o.dispatch({selection:{anchor:e}})}),h=n.computed({get:()=>o.state,set:e=>o.setState(e)}),B=n.computed({get:()=>o.hasFocus,set:e=>{e&&o.focus()}}),v=n.computed(()=>p.compact([t.basic?y.basicSetup:void 0,t.minimal&&!t.basic?y.minimalSetup:void 0,d.EditorView.updateListener.of(e=>w("update:view",e)),d.EditorView.theme(t.theme,{dark:t.dark}),t.wrap?d.EditorView.lineWrapping:void 0,t.tab?d.keymap.of([V.indentWithTab]):void 0,t.phrases?u.EditorState.phrases.of(t.phrases):void 0,t.readonly?u.EditorState.readOnly.of(t.readonly):void 0,t.editable?d.EditorView.editable.of(t.editable):void 0,t.lang?n.toRaw(t.lang):void 0,t.linter?g.linter(t.linter):void 0,t.linter&&t.lintGutter?g.lintGutter():void 0,...t.extensions])),w=r.emit;return n.watch(()=>t.modelValue,e=>{if(o.composing)return;const s=o.state.selection;o.dispatch({changes:{from:0,to:o.state.doc.length,insert:e},selection:s})}),n.watch(v,e=>{o.dispatch({effects:u.StateEffect.reconfigure.of(e)})}),n.onMounted(async()=>{let e=c.value;i.value&&i.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(i.value.childNodes[0].innerText)),o=new d.EditorView({doc:e,extensions:v.value,parent:i.value,dispatch:s=>{o.update([s]),!s.changes.empty&&w("update:modelValue",o.state.doc.toString())}}),await n.nextTick()}),n.onUnmounted(()=>o.destroy()),{context:r,editor:i,cursor:f,selection:l,state:h,focus:B,getRange:(e,s)=>o.state.sliceDoc(e,s),getLine:e=>o.state.doc.line(e+1).text,lineCount:()=>o.state.doc.lines,getCursor:()=>f.value,listSelections:()=>o.state.selection.ranges,getSelection:()=>o.state.sliceDoc(o.state.selection.main.from,o.state.selection.main.to),getSelections:()=>o.state.selection.ranges.map(e=>o.state.sliceDoc(e.from,e.to)),somethingSelected:()=>o.state.selection.ranges.some(e=>!e.empty),replaceRange:(e,s,E)=>o.dispatch({changes:{from:s,to:E,insert:e}}),replaceSelection:e=>o.dispatch(o.state.replaceSelection(e)),setCursor:e=>f.value=e,setSelection:(e,s)=>o.dispatch({selection:{anchor:e,head:s}}),setSelections:(e,s)=>o.dispatch({selection:u.EditorSelection.create(e,s)}),extendSelectionsBy:e=>o.dispatch({selection:u.EditorSelection.create(l.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)}}),x=t=>t.component("CodeMirror",m);typeof window<"u"&&window.Vue&&window.Vue.use(m),a.default=m,a.install=x,Object.defineProperties(a,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
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": "0.6.
|
|
4
|
+
"version": "0.6.8",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "CodeMirror6 Component for vue2 and vue3",
|
|
7
7
|
"keywords": [
|
|
@@ -78,25 +78,25 @@
|
|
|
78
78
|
},
|
|
79
79
|
"devDependencies": {
|
|
80
80
|
"@codemirror/lang-javascript": "^6.0.2",
|
|
81
|
-
"@codemirror/lang-markdown": "^6.0.
|
|
81
|
+
"@codemirror/lang-markdown": "^6.0.1",
|
|
82
82
|
"@types/lodash": "^4.14.182",
|
|
83
|
-
"@types/node": "^18.
|
|
84
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
85
|
-
"@typescript-eslint/parser": "^5.
|
|
83
|
+
"@types/node": "^18.6.3",
|
|
84
|
+
"@typescript-eslint/eslint-plugin": "^5.31.0",
|
|
85
|
+
"@typescript-eslint/parser": "^5.31.0",
|
|
86
86
|
"@vitejs/plugin-vue": "^3.0.1",
|
|
87
87
|
"@vue/eslint-config-prettier": "^7.0.0",
|
|
88
88
|
"@vue/tsconfig": "^0.1.3",
|
|
89
89
|
"codemirror": "^6.0.1",
|
|
90
|
-
"eslint": "^8.
|
|
90
|
+
"eslint": "^8.21.0",
|
|
91
91
|
"eslint-config-google": "^0.14.0",
|
|
92
92
|
"eslint-config-prettier": "^8.5.0",
|
|
93
93
|
"eslint-import-resolver-alias": "^1.1.2",
|
|
94
94
|
"eslint-import-resolver-typescript": "^3.3.0",
|
|
95
|
-
"eslint-plugin-html": "^7.
|
|
95
|
+
"eslint-plugin-html": "^7.1.0",
|
|
96
96
|
"eslint-plugin-import": "^2.26.0",
|
|
97
|
-
"eslint-plugin-jsdoc": "^39.3.
|
|
97
|
+
"eslint-plugin-jsdoc": "^39.3.4",
|
|
98
98
|
"eslint-plugin-tsdoc": "^0.2.16",
|
|
99
|
-
"eslint-plugin-vue": "^9.
|
|
99
|
+
"eslint-plugin-vue": "^9.3.0",
|
|
100
100
|
"eslint-plugin-vuejs-accessibility": "^1.2.0",
|
|
101
101
|
"eslint-plugin-yaml": "^0.5.0",
|
|
102
102
|
"eslint4b-prebuilt": "^6.7.2",
|
|
@@ -107,12 +107,12 @@
|
|
|
107
107
|
"rimraf": "^3.0.2",
|
|
108
108
|
"rollup-plugin-visualizer": "^5.7.1",
|
|
109
109
|
"typescript": "^4.7.4",
|
|
110
|
-
"vite": "^3.0.
|
|
110
|
+
"vite": "^3.0.4",
|
|
111
111
|
"vite-plugin-banner": "^0.3.0",
|
|
112
112
|
"vite-plugin-checker": "^0.4.9",
|
|
113
113
|
"vue": "^3.2.37",
|
|
114
114
|
"vue-eslint-parser": "^9.0.3",
|
|
115
|
-
"vue-tsc": "^0.39.
|
|
115
|
+
"vue-tsc": "^0.39.4"
|
|
116
116
|
},
|
|
117
117
|
"husky": {
|
|
118
118
|
"hooks": {
|