vue-codemirror6 0.6.6 → 0.6.7
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 +2 -2
- package/dist/components/CodeMirror.d.ts +3 -3
- package/dist/components/CodeMirror.d.ts.map +1 -1
- package/dist/helpers/h-demi.d.ts +1 -1
- package/dist/helpers/h-demi.d.ts.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.es.js +116 -158
- package/dist/index.umd.js +2 -2
- package/package.json +21 -20
package/README.md
CHANGED
|
@@ -238,6 +238,8 @@ export default defineComponent({
|
|
|
238
238
|
| ------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- |
|
|
239
239
|
| selection | Get and set the [EditorSelection](https://codemirror.net/docs/ref/#state.EditorSelection) instance. |
|
|
240
240
|
| cursor | Get and set the cursor location. |
|
|
241
|
+
| state | Get and set [EditorState](https://codemirror.net/docs/ref/#state.EditorState). |
|
|
242
|
+
| focus | Get and set focus. |
|
|
241
243
|
| getRange(from?: number, to?: number) | Get the text between the given points in the editor. |
|
|
242
244
|
| getLine(number: number) | Get the content of line. |
|
|
243
245
|
| lineCount() | Get the number of lines in the editor. |
|
|
@@ -252,8 +254,6 @@ export default defineComponent({
|
|
|
252
254
|
| setSelection(anchor: number, head?: number) | Set a single selection range. |
|
|
253
255
|
| setSelections(ranges: readonly SelectionRange[], primary?: number) | Sets a new set of selections. |
|
|
254
256
|
| extendSelectionsBy(f: Function) | Applies the given function to all existing selections, and calls extendSelections on the result. |
|
|
255
|
-
| focus() | Set focus |
|
|
256
|
-
| hasFocus() | is Focused |
|
|
257
257
|
|
|
258
258
|
## Recommendations
|
|
259
259
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type PropType, type Ref, type SetupContext } from 'vue-demi';
|
|
2
|
-
import { EditorSelection } from '@codemirror/state';
|
|
2
|
+
import { EditorSelection, EditorState } from '@codemirror/state';
|
|
3
3
|
import type { Extension, SelectionRange, Text } from '@codemirror/state';
|
|
4
4
|
import type { LanguageSupport } from '@codemirror/language';
|
|
5
5
|
import type { ViewUpdate } from '@codemirror/view';
|
|
@@ -135,6 +135,8 @@ declare const _default: import("vue-demi").DefineComponent<{
|
|
|
135
135
|
editor: Ref<Element | undefined>;
|
|
136
136
|
cursor: Ref<number>;
|
|
137
137
|
selection: Ref<EditorSelection>;
|
|
138
|
+
state: Ref<EditorState>;
|
|
139
|
+
focus: Ref<boolean>;
|
|
138
140
|
getRange: (from?: number, to?: number) => string;
|
|
139
141
|
getLine: (number: number) => string;
|
|
140
142
|
lineCount: () => number;
|
|
@@ -149,8 +151,6 @@ declare const _default: import("vue-demi").DefineComponent<{
|
|
|
149
151
|
setSelection: (anchor: number, head?: number) => void;
|
|
150
152
|
setSelections: (ranges: readonly SelectionRange[], primary?: number) => void;
|
|
151
153
|
extendSelectionsBy: (f: Function) => void;
|
|
152
|
-
focus: () => void;
|
|
153
|
-
hasFocus: () => boolean;
|
|
154
154
|
}, unknown, {}, {}, import("vue-demi").ComponentOptionsMixin, import("vue-demi").ComponentOptionsMixin, import("vue-demi").EmitsOptions, "update:modelValue" | "update:view", import("vue-demi").VNodeProps & import("vue-demi").AllowedComponentProps & import("vue-demi").ComponentCustomProps, Readonly<import("vue-demi").ExtractPropTypes<{
|
|
155
155
|
/** Model value */
|
|
156
156
|
modelValue: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeMirror.d.ts","sourceRoot":"","sources":["../../src/components/CodeMirror.ts"],"names":[],"mappings":"AAAA,OAAO,EASL,KAAK,QAAQ,EACb,KAAK,GAAG,EACR,KAAK,YAAY,EAClB,MAAM,UAAU,CAAC;AAOlB,OAAO,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"CodeMirror.d.ts","sourceRoot":"","sources":["../../src/components/CodeMirror.ts"],"names":[],"mappings":"AAAA,OAAO,EASL,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;;;;;;;;;;;;sBAuJO,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;;IA/VvC,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,wBA6ZG"}
|
package/dist/helpers/h-demi.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"h-demi.d.ts","sourceRoot":"","sources":["../../src/helpers/h-demi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,EAAQ,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"h-demi.d.ts","sourceRoot":"","sources":["../../src/helpers/h-demi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,KAAK,EAAQ,MAAM,UAAU,CAAC;AAEhE,UAAU,OAAO;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IAC5B,EAAE,CAAC,EAAE,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IACzB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAWD,QAAA,MAAM,CAAC,SACC,MAAM,GAAG,OAAO,GAAG,EAAE,GAAG,CAAC,YACtB,OAAO,YACN,GAAG,KACZ,KAcF,CAAC;AAEF,QAAA,MAAM,IAAI,iBAAkB,GAAG,QACoC,CAAC;AAEpE,OAAO,EAAE,IAAI,EAAE,CAAC,IAAI,OAAO,EAAE,CAAC"}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,yBAAyB,CAAC;AAGjD,QAAA,MAAM,iBAAiB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,yBAAyB,CAAC;AAGjD,QAAA,MAAM,iBAAiB,QAAS,GAAG,QAA4C,CAAC;AAEhF,OAAO,EAAE,UAAU,IAAI,OAAO,EAAE,iBAAiB,IAAI,OAAO,EAAE,CAAC"}
|
package/dist/index.es.js
CHANGED
|
@@ -5,36 +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.7
|
|
9
9
|
* @see {@link https://github.com/logue/vue-codemirror6}
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
import { isVue2, Vue2
|
|
13
|
-
import { trim, compact } from "lodash";
|
|
14
|
-
import { StateEffect
|
|
15
|
-
import { EditorView, keymap } from "@codemirror/view";
|
|
16
|
-
import { linter, lintGutter } from "@codemirror/lint";
|
|
17
|
-
import { basicSetup, minimalSetup } from "codemirror";
|
|
18
|
-
import { indentWithTab } from "@codemirror/commands";
|
|
19
|
-
const
|
|
20
|
-
if (
|
|
21
|
-
return
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return { ...ret, [key]: handler };
|
|
26
|
-
}, {});
|
|
27
|
-
};
|
|
28
|
-
const h = (type, options = {}, chidren) => {
|
|
29
|
-
if (isVue2 && parseInt(Vue2.version) < 2.7) {
|
|
30
|
-
return h$1(type, options, chidren);
|
|
31
|
-
}
|
|
32
|
-
const { props, domProps, on, ...extraOptions } = options;
|
|
33
|
-
const ons = on ? adaptOnsV3(on) : {};
|
|
34
|
-
return h$1(type, { ...extraOptions, ...props, ...domProps, ...ons }, chidren);
|
|
35
|
-
};
|
|
36
|
-
const slot = (defaultSlots) => typeof defaultSlots == "function" ? defaultSlots() : defaultSlots;
|
|
37
|
-
var CodeMirror = defineComponent({
|
|
12
|
+
import { isVue2 as V, Vue2 as C, h, defineComponent as x, ref as g, computed as d, watch as B, onMounted as O, nextTick as M, onUnmounted as E, toRaw as R } from "vue-demi";
|
|
13
|
+
import { trim as j, compact as T } from "lodash";
|
|
14
|
+
import { StateEffect as $, EditorState as p, EditorSelection as v } from "@codemirror/state";
|
|
15
|
+
import { EditorView as r, keymap as D } from "@codemirror/view";
|
|
16
|
+
import { linter as G, lintGutter as L } from "@codemirror/lint";
|
|
17
|
+
import { basicSetup as A, minimalSetup as F } from "codemirror";
|
|
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 }), {}) : {}, y = (t, i = {}, n) => {
|
|
20
|
+
if (V && parseInt(C.version) < 2.7)
|
|
21
|
+
return h(t, i, n);
|
|
22
|
+
const { props: s, domProps: o, on: l, ...c } = i, u = l ? U(l) : {};
|
|
23
|
+
return h(t, { ...c, ...s, ...o, ...u }, n);
|
|
24
|
+
}, W = (t) => typeof t == "function" ? t() : t, S = x({
|
|
38
25
|
name: "CodeMirror",
|
|
39
26
|
model: {
|
|
40
27
|
prop: "modelValue",
|
|
@@ -47,51 +34,49 @@ var CodeMirror = defineComponent({
|
|
|
47
34
|
},
|
|
48
35
|
theme: {
|
|
49
36
|
type: Object,
|
|
50
|
-
default: () => {
|
|
51
|
-
return {};
|
|
52
|
-
}
|
|
37
|
+
default: () => ({})
|
|
53
38
|
},
|
|
54
39
|
dark: {
|
|
55
40
|
type: Boolean,
|
|
56
|
-
default:
|
|
41
|
+
default: !1
|
|
57
42
|
},
|
|
58
43
|
basic: {
|
|
59
44
|
type: Boolean,
|
|
60
|
-
default:
|
|
45
|
+
default: !1
|
|
61
46
|
},
|
|
62
47
|
minimal: {
|
|
63
48
|
type: Boolean,
|
|
64
|
-
default:
|
|
49
|
+
default: !1
|
|
65
50
|
},
|
|
66
51
|
wrap: {
|
|
67
52
|
type: Boolean,
|
|
68
|
-
default:
|
|
53
|
+
default: !1
|
|
69
54
|
},
|
|
70
55
|
tab: {
|
|
71
56
|
type: Boolean,
|
|
72
|
-
default:
|
|
57
|
+
default: !1
|
|
73
58
|
},
|
|
74
59
|
readonly: {
|
|
75
60
|
type: Boolean,
|
|
76
|
-
default:
|
|
61
|
+
default: !1
|
|
77
62
|
},
|
|
78
63
|
editable: {
|
|
79
64
|
type: Boolean,
|
|
80
|
-
default:
|
|
65
|
+
default: !0
|
|
81
66
|
},
|
|
82
67
|
extensions: {
|
|
83
68
|
type: Array,
|
|
84
|
-
default: () =>
|
|
85
|
-
return [];
|
|
86
|
-
}
|
|
69
|
+
default: () => []
|
|
87
70
|
},
|
|
88
71
|
phrases: {
|
|
89
72
|
type: Object,
|
|
90
|
-
default: () =>
|
|
73
|
+
default: () => {
|
|
74
|
+
}
|
|
91
75
|
},
|
|
92
76
|
lang: {
|
|
93
77
|
type: Object,
|
|
94
|
-
default: () =>
|
|
78
|
+
default: () => {
|
|
79
|
+
}
|
|
95
80
|
},
|
|
96
81
|
linter: {
|
|
97
82
|
type: Function,
|
|
@@ -99,132 +84,105 @@ var CodeMirror = defineComponent({
|
|
|
99
84
|
},
|
|
100
85
|
lintGutter: {
|
|
101
86
|
type: Boolean,
|
|
102
|
-
defalt:
|
|
87
|
+
defalt: !1
|
|
103
88
|
}
|
|
104
89
|
},
|
|
105
90
|
emits: ["update:modelValue", "update:view"],
|
|
106
|
-
setup(
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
91
|
+
setup(t, i) {
|
|
92
|
+
const n = g(), s = g(t.modelValue);
|
|
93
|
+
let o;
|
|
94
|
+
const l = d({
|
|
95
|
+
get: () => o.state.selection,
|
|
96
|
+
set: (e) => o.dispatch({ selection: e })
|
|
97
|
+
}), c = d({
|
|
98
|
+
get: () => l.value.main.head || 0,
|
|
99
|
+
set: (e) => o.dispatch({ selection: { anchor: e } })
|
|
100
|
+
}), u = d({
|
|
101
|
+
get: () => o.state,
|
|
102
|
+
set: (e) => o.setState(e)
|
|
103
|
+
}), w = d({
|
|
104
|
+
get: () => o.hasFocus,
|
|
105
|
+
set: (e) => {
|
|
106
|
+
e && o.focus();
|
|
122
107
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
});
|
|
134
|
-
onMounted(async () => {
|
|
135
|
-
let value = doc.value;
|
|
136
|
-
if (editor.value && editor.value.childNodes[0]) {
|
|
137
|
-
if (doc.value !== "") {
|
|
138
|
-
console.warn("[CodeMirror.vue] The <code-mirror> tag contains child elements that overwrite the `v-model` values.");
|
|
139
|
-
}
|
|
140
|
-
value = trim(editor.value.childNodes[0].innerText);
|
|
108
|
+
}), m = i.emit;
|
|
109
|
+
B(t, (e) => {
|
|
110
|
+
if (e.modelValue) {
|
|
111
|
+
if (o.composing)
|
|
112
|
+
return;
|
|
113
|
+
const a = o.state.selection;
|
|
114
|
+
o.dispatch({
|
|
115
|
+
changes: { from: 0, to: o.state.doc.length, insert: e.modelValue },
|
|
116
|
+
selection: a
|
|
117
|
+
});
|
|
141
118
|
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
extensions: getExtensions(),
|
|
145
|
-
parent: editor.value,
|
|
146
|
-
dispatch: (tr) => {
|
|
147
|
-
view.update([tr]);
|
|
148
|
-
if (tr.changes.empty)
|
|
149
|
-
return;
|
|
150
|
-
emit("update:modelValue", view.state.doc.toString());
|
|
151
|
-
}
|
|
119
|
+
o.dispatch({
|
|
120
|
+
effects: $.reconfigure.of(f())
|
|
152
121
|
});
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
const getSelection = () => view.state.sliceDoc(view.state.selection.main.from, view.state.selection.main.to);
|
|
180
|
-
const getSelections = () => view.state.selection.ranges.map((r) => view.state.sliceDoc(r.from, r.to));
|
|
181
|
-
const somethingSelected = () => view.state.selection.ranges.some((r) => !r.empty);
|
|
182
|
-
const replaceRange = (replacement, from, to) => view.dispatch({
|
|
183
|
-
changes: { from, to, insert: replacement }
|
|
184
|
-
});
|
|
185
|
-
const replaceSelection = (replacement) => view.dispatch(view.state.replaceSelection(replacement));
|
|
186
|
-
const setCursor = (position) => cursor.value = position;
|
|
187
|
-
const setSelection = (anchor, head) => view.dispatch({ selection: { anchor, head } });
|
|
188
|
-
const setSelections = (ranges, primary) => view.dispatch({
|
|
189
|
-
selection: EditorSelection.create(ranges, primary)
|
|
190
|
-
});
|
|
191
|
-
const extendSelectionsBy = (f) => view.dispatch({
|
|
192
|
-
selection: EditorSelection.create(selection.value.ranges.map((r) => r.extend(f(r))))
|
|
193
|
-
});
|
|
194
|
-
const focus = () => view.focus();
|
|
195
|
-
const hasFocus = () => view.hasFocus;
|
|
122
|
+
}), O(async () => {
|
|
123
|
+
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 = j(n.value.childNodes[0].innerText)), o = new r({
|
|
125
|
+
doc: e,
|
|
126
|
+
extensions: f(),
|
|
127
|
+
parent: n.value,
|
|
128
|
+
dispatch: (a) => {
|
|
129
|
+
o.update([a]), !a.changes.empty && m("update:modelValue", o.state.doc.toString());
|
|
130
|
+
}
|
|
131
|
+
}), await M();
|
|
132
|
+
}), E(() => o.destroy());
|
|
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
|
+
]);
|
|
196
148
|
return {
|
|
197
|
-
context,
|
|
198
|
-
editor,
|
|
199
|
-
cursor,
|
|
200
|
-
selection,
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
149
|
+
context: i,
|
|
150
|
+
editor: n,
|
|
151
|
+
cursor: c,
|
|
152
|
+
selection: l,
|
|
153
|
+
state: u,
|
|
154
|
+
focus: w,
|
|
155
|
+
getRange: (e, a) => o.state.sliceDoc(e, a),
|
|
156
|
+
getLine: (e) => o.state.doc.line(e + 1).text,
|
|
157
|
+
lineCount: () => o.state.doc.lines,
|
|
158
|
+
getCursor: () => c.value,
|
|
159
|
+
listSelections: () => o.state.selection.ranges,
|
|
160
|
+
getSelection: () => o.state.sliceDoc(o.state.selection.main.from, o.state.selection.main.to),
|
|
161
|
+
getSelections: () => o.state.selection.ranges.map((e) => o.state.sliceDoc(e.from, e.to)),
|
|
162
|
+
somethingSelected: () => o.state.selection.ranges.some((e) => !e.empty),
|
|
163
|
+
replaceRange: (e, a, b) => o.dispatch({
|
|
164
|
+
changes: { from: a, to: b, insert: e }
|
|
165
|
+
}),
|
|
166
|
+
replaceSelection: (e) => o.dispatch(o.state.replaceSelection(e)),
|
|
167
|
+
setCursor: (e) => c.value = e,
|
|
168
|
+
setSelection: (e, a) => o.dispatch({ selection: { anchor: e, head: a } }),
|
|
169
|
+
setSelections: (e, a) => o.dispatch({
|
|
170
|
+
selection: v.create(e, a)
|
|
171
|
+
}),
|
|
172
|
+
extendSelectionsBy: (e) => o.dispatch({
|
|
173
|
+
selection: v.create(l.value.ranges.map((a) => a.extend(e(a))))
|
|
174
|
+
})
|
|
217
175
|
};
|
|
218
176
|
},
|
|
219
177
|
render() {
|
|
220
|
-
return
|
|
178
|
+
return y("div", {
|
|
221
179
|
ref: "editor",
|
|
222
180
|
class: "vue-codemirror"
|
|
223
|
-
}, this.$slots.default ?
|
|
181
|
+
}, this.$slots.default ? y("aside", { style: "display: none;", "aria-hidden": "true" }, W(this.$slots.default)) : void 0);
|
|
224
182
|
}
|
|
225
|
-
});
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
183
|
+
}), ce = (t) => t.component("CodeMirror", S);
|
|
184
|
+
typeof window < "u" && window.Vue && window.Vue.use(S);
|
|
185
|
+
export {
|
|
186
|
+
S as default,
|
|
187
|
+
ce as install
|
|
188
|
+
};
|
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.7
|
|
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,
|
|
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)}),E=n.computed({get:()=>o.hasFocus,set:e=>{e&&o.focus()}}),v=r.emit;n.watch(t,e=>{if(e.modelValue){if(o.composing)return;const s=o.state.selection;o.dispatch({changes:{from:0,to:o.state.doc.length,insert:e.modelValue},selection:s})}o.dispatch({effects:u.StateEffect.reconfigure.of(w())})}),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:w(),parent:i.value,dispatch:s=>{o.update([s]),!s.changes.empty&&v("update:modelValue",o.state.doc.toString())}}),await n.nextTick()}),n.onUnmounted(()=>o.destroy());const w=()=>p.compact([t.basic?y.basicSetup:void 0,t.minimal&&!t.basic?y.minimalSetup:void 0,d.EditorView.updateListener.of(e=>v("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]);return{context:r,editor:i,cursor:f,selection:l,state:h,focus:E,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,B)=>o.dispatch({changes:{from:s,to:B,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,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "vue-codemirror6",
|
|
4
|
-
"version": "0.6.
|
|
4
|
+
"version": "0.6.7",
|
|
5
|
+
"license": "MIT",
|
|
5
6
|
"description": "CodeMirror6 Component for vue2 and vue3",
|
|
6
7
|
"keywords": [
|
|
7
8
|
"vuejs",
|
|
@@ -32,24 +33,23 @@
|
|
|
32
33
|
"bugs": {
|
|
33
34
|
"url": "https://github.com/logue/vue-codemirror6/issues"
|
|
34
35
|
},
|
|
35
|
-
"engines": {
|
|
36
|
-
"node": ">=16.15.1",
|
|
37
|
-
"yarn": ">=1.22.4"
|
|
38
|
-
},
|
|
39
|
-
"packageManager": "yarn@3.2.1",
|
|
40
|
-
"license": "MIT",
|
|
41
36
|
"main": "./dist/index.umd.js",
|
|
42
37
|
"module": "./dist/index.es.js",
|
|
38
|
+
"types": "./dist/index.d.ts",
|
|
43
39
|
"exports": {
|
|
44
40
|
".": {
|
|
45
41
|
"import": "./dist/index.es.js",
|
|
46
42
|
"require": "./dist/index.umd.js"
|
|
47
43
|
}
|
|
48
44
|
},
|
|
49
|
-
"types": "./dist/index.d.ts",
|
|
50
45
|
"files": [
|
|
51
46
|
"/dist"
|
|
52
47
|
],
|
|
48
|
+
"engines": {
|
|
49
|
+
"node": ">=16.16.0",
|
|
50
|
+
"yarn": ">=1.22.4"
|
|
51
|
+
},
|
|
52
|
+
"packageManager": "yarn@3.2.1",
|
|
53
53
|
"sideEffects": false,
|
|
54
54
|
"scripts": {
|
|
55
55
|
"dev": "vite",
|
|
@@ -77,21 +77,22 @@
|
|
|
77
77
|
}
|
|
78
78
|
},
|
|
79
79
|
"devDependencies": {
|
|
80
|
-
"@codemirror/lang-javascript": "^6.0.
|
|
80
|
+
"@codemirror/lang-javascript": "^6.0.2",
|
|
81
81
|
"@codemirror/lang-markdown": "^6.0.0",
|
|
82
82
|
"@types/lodash": "^4.14.182",
|
|
83
|
-
"@types/node": "^18.0.
|
|
84
|
-
"@typescript-eslint/eslint-plugin": "^5.30.
|
|
85
|
-
"@typescript-eslint/parser": "^5.30.
|
|
86
|
-
"@vitejs/plugin-vue": "^
|
|
83
|
+
"@types/node": "^18.0.6",
|
|
84
|
+
"@typescript-eslint/eslint-plugin": "^5.30.7",
|
|
85
|
+
"@typescript-eslint/parser": "^5.30.7",
|
|
86
|
+
"@vitejs/plugin-vue": "^3.0.1",
|
|
87
87
|
"@vue/eslint-config-prettier": "^7.0.0",
|
|
88
|
+
"@vue/tsconfig": "^0.1.3",
|
|
88
89
|
"codemirror": "^6.0.1",
|
|
89
|
-
"eslint": "^8.
|
|
90
|
+
"eslint": "^8.20.0",
|
|
90
91
|
"eslint-config-google": "^0.14.0",
|
|
91
92
|
"eslint-config-prettier": "^8.5.0",
|
|
92
93
|
"eslint-import-resolver-alias": "^1.1.2",
|
|
93
|
-
"eslint-import-resolver-typescript": "^3.
|
|
94
|
-
"eslint-plugin-html": "^
|
|
94
|
+
"eslint-import-resolver-typescript": "^3.3.0",
|
|
95
|
+
"eslint-plugin-html": "^7.0.0",
|
|
95
96
|
"eslint-plugin-import": "^2.26.0",
|
|
96
97
|
"eslint-plugin-jsdoc": "^39.3.3",
|
|
97
98
|
"eslint-plugin-tsdoc": "^0.2.16",
|
|
@@ -104,14 +105,14 @@
|
|
|
104
105
|
"lodash": "^4.17.21",
|
|
105
106
|
"prettier": "^2.7.1",
|
|
106
107
|
"rimraf": "^3.0.2",
|
|
107
|
-
"rollup-plugin-visualizer": "^5.
|
|
108
|
+
"rollup-plugin-visualizer": "^5.7.1",
|
|
108
109
|
"typescript": "^4.7.4",
|
|
109
|
-
"vite": "^
|
|
110
|
+
"vite": "^3.0.2",
|
|
110
111
|
"vite-plugin-banner": "^0.3.0",
|
|
111
|
-
"vite-plugin-checker": "^0.4.
|
|
112
|
+
"vite-plugin-checker": "^0.4.9",
|
|
112
113
|
"vue": "^3.2.37",
|
|
113
114
|
"vue-eslint-parser": "^9.0.3",
|
|
114
|
-
"vue-tsc": "^0.
|
|
115
|
+
"vue-tsc": "^0.39.0"
|
|
115
116
|
},
|
|
116
117
|
"husky": {
|
|
117
118
|
"hooks": {
|