vue-codemirror6 1.1.32 → 1.2.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/dist/index.es.js +179 -263
- package/dist/index.iife.js +3 -526
- package/dist/index.umd.js +3 -527
- package/package.json +31 -30
- package/src/components/CodeMirror.ts +2 -1
package/LICENSE
CHANGED
package/dist/index.es.js
CHANGED
|
@@ -5,41 +5,29 @@
|
|
|
5
5
|
* @author Logue <logue@hotmail.co.jp>
|
|
6
6
|
* @copyright 2022-2023 By Masashi Yoshikawa All rights reserved.
|
|
7
7
|
* @license MIT
|
|
8
|
-
* @version 1.
|
|
8
|
+
* @version 1.2.0
|
|
9
9
|
* @see {@link https://github.com/logue/vue-codemirror6}
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
import { isVue2, h as
|
|
13
|
-
import { basicSetup, minimalSetup } from
|
|
14
|
-
import { EditorView, keymap, placeholder } from
|
|
15
|
-
import { EditorState, Compartment, StateEffect, EditorSelection } from
|
|
16
|
-
import { forceLinting
|
|
17
|
-
import { indentWithTab } from
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
if (
|
|
21
|
-
return
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
};
|
|
28
|
-
function h(type, options = {}, chidren) {
|
|
29
|
-
if (isVue2) {
|
|
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(
|
|
35
|
-
type,
|
|
36
|
-
{ ...extraOptions, ...props, ...domProps, ...ons },
|
|
37
|
-
chidren
|
|
12
|
+
import { isVue2 as G, h as b, defineComponent as I, ref as v, shallowRef as P, computed as c, watch as C, onMounted as Z, nextTick as k, onUnmounted as q } from "vue-demi";
|
|
13
|
+
import { basicSetup as H, minimalSetup as K } from "codemirror";
|
|
14
|
+
import { EditorView as r, keymap as Q, placeholder as X } from "@codemirror/view";
|
|
15
|
+
import { EditorState as s, Compartment as w, StateEffect as y, EditorSelection as O } from "@codemirror/state";
|
|
16
|
+
import { forceLinting as $, linter as Y, lintGutter as ee, diagnosticCount as te } from "@codemirror/lint";
|
|
17
|
+
import { indentWithTab as ae } from "@codemirror/commands";
|
|
18
|
+
const le = (e) => e ? Object.entries(e).reduce((o, [n, u]) => (n = n.charAt(0).toUpperCase() + n.slice(1), n = `on${n}`, { ...o, [n]: u }), {}) : {};
|
|
19
|
+
function B(e, o = {}, n) {
|
|
20
|
+
if (G)
|
|
21
|
+
return b(e, o, n);
|
|
22
|
+
const { props: u, domProps: t, on: d, ...f } = o, m = d ? le(d) : {};
|
|
23
|
+
return b(
|
|
24
|
+
e,
|
|
25
|
+
{ ...f, ...u, ...t, ...m },
|
|
26
|
+
n
|
|
38
27
|
);
|
|
39
28
|
}
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
var CodeMirror = defineComponent({
|
|
29
|
+
const ne = (e) => typeof e == "function" ? e() : e;
|
|
30
|
+
var oe = I({
|
|
43
31
|
/** Component Name */
|
|
44
32
|
name: "CodeMirror",
|
|
45
33
|
/** Model Definition */
|
|
@@ -67,7 +55,7 @@ var CodeMirror = defineComponent({
|
|
|
67
55
|
/** Dark Mode */
|
|
68
56
|
dark: {
|
|
69
57
|
type: Boolean,
|
|
70
|
-
default:
|
|
58
|
+
default: !1
|
|
71
59
|
},
|
|
72
60
|
/**
|
|
73
61
|
* Use Basic Setup
|
|
@@ -76,7 +64,7 @@ var CodeMirror = defineComponent({
|
|
|
76
64
|
*/
|
|
77
65
|
basic: {
|
|
78
66
|
type: Boolean,
|
|
79
|
-
default:
|
|
67
|
+
default: !1
|
|
80
68
|
},
|
|
81
69
|
/**
|
|
82
70
|
* Use Minimal Setup (The basic setting has priority.)
|
|
@@ -85,7 +73,7 @@ var CodeMirror = defineComponent({
|
|
|
85
73
|
*/
|
|
86
74
|
minimal: {
|
|
87
75
|
type: Boolean,
|
|
88
|
-
default:
|
|
76
|
+
default: !1
|
|
89
77
|
},
|
|
90
78
|
/**
|
|
91
79
|
* Placeholder
|
|
@@ -105,7 +93,7 @@ var CodeMirror = defineComponent({
|
|
|
105
93
|
*/
|
|
106
94
|
wrap: {
|
|
107
95
|
type: Boolean,
|
|
108
|
-
default:
|
|
96
|
+
default: !1
|
|
109
97
|
},
|
|
110
98
|
/**
|
|
111
99
|
* Allow tab key indent.
|
|
@@ -114,7 +102,7 @@ var CodeMirror = defineComponent({
|
|
|
114
102
|
*/
|
|
115
103
|
tab: {
|
|
116
104
|
type: Boolean,
|
|
117
|
-
default:
|
|
105
|
+
default: !1
|
|
118
106
|
},
|
|
119
107
|
/**
|
|
120
108
|
* Allow Multiple Selection.
|
|
@@ -123,7 +111,7 @@ var CodeMirror = defineComponent({
|
|
|
123
111
|
*/
|
|
124
112
|
allowMultipleSelections: {
|
|
125
113
|
type: Boolean,
|
|
126
|
-
default:
|
|
114
|
+
default: !1
|
|
127
115
|
},
|
|
128
116
|
/**
|
|
129
117
|
* Tab size
|
|
@@ -150,7 +138,7 @@ var CodeMirror = defineComponent({
|
|
|
150
138
|
*/
|
|
151
139
|
readonly: {
|
|
152
140
|
type: Boolean,
|
|
153
|
-
default:
|
|
141
|
+
default: !1
|
|
154
142
|
},
|
|
155
143
|
/**
|
|
156
144
|
* Disable input.
|
|
@@ -162,7 +150,7 @@ var CodeMirror = defineComponent({
|
|
|
162
150
|
*/
|
|
163
151
|
disabled: {
|
|
164
152
|
type: Boolean,
|
|
165
|
-
default:
|
|
153
|
+
default: !1
|
|
166
154
|
},
|
|
167
155
|
/**
|
|
168
156
|
* Additional Extension
|
|
@@ -171,9 +159,7 @@ var CodeMirror = defineComponent({
|
|
|
171
159
|
*/
|
|
172
160
|
extensions: {
|
|
173
161
|
type: Array,
|
|
174
|
-
default: () =>
|
|
175
|
-
return [];
|
|
176
|
-
}
|
|
162
|
+
default: () => []
|
|
177
163
|
},
|
|
178
164
|
/**
|
|
179
165
|
* Language Phreses
|
|
@@ -182,7 +168,8 @@ var CodeMirror = defineComponent({
|
|
|
182
168
|
*/
|
|
183
169
|
phrases: {
|
|
184
170
|
type: Object,
|
|
185
|
-
default: () =>
|
|
171
|
+
default: () => {
|
|
172
|
+
}
|
|
186
173
|
},
|
|
187
174
|
/**
|
|
188
175
|
* CodeMirror Language
|
|
@@ -191,7 +178,8 @@ var CodeMirror = defineComponent({
|
|
|
191
178
|
*/
|
|
192
179
|
lang: {
|
|
193
180
|
type: Object,
|
|
194
|
-
default: () =>
|
|
181
|
+
default: () => {
|
|
182
|
+
}
|
|
195
183
|
},
|
|
196
184
|
/**
|
|
197
185
|
* CodeMirror Linter
|
|
@@ -209,9 +197,7 @@ var CodeMirror = defineComponent({
|
|
|
209
197
|
*/
|
|
210
198
|
linterConfig: {
|
|
211
199
|
type: Object,
|
|
212
|
-
default: () => {
|
|
213
|
-
return {};
|
|
214
|
-
}
|
|
200
|
+
default: () => ({})
|
|
215
201
|
},
|
|
216
202
|
/**
|
|
217
203
|
* Forces any linters configured to run when the editor is idle to run right away.
|
|
@@ -220,7 +206,7 @@ var CodeMirror = defineComponent({
|
|
|
220
206
|
*/
|
|
221
207
|
forceLinting: {
|
|
222
208
|
type: Boolean,
|
|
223
|
-
default:
|
|
209
|
+
default: !1
|
|
224
210
|
},
|
|
225
211
|
/**
|
|
226
212
|
* Show Linter Gutter
|
|
@@ -232,7 +218,7 @@ var CodeMirror = defineComponent({
|
|
|
232
218
|
*/
|
|
233
219
|
gutter: {
|
|
234
220
|
type: Boolean,
|
|
235
|
-
defalt:
|
|
221
|
+
defalt: !1
|
|
236
222
|
},
|
|
237
223
|
/**
|
|
238
224
|
* Gutter Config
|
|
@@ -241,7 +227,8 @@ var CodeMirror = defineComponent({
|
|
|
241
227
|
*/
|
|
242
228
|
gutterConfig: {
|
|
243
229
|
type: Object,
|
|
244
|
-
default: () =>
|
|
230
|
+
default: () => {
|
|
231
|
+
}
|
|
245
232
|
},
|
|
246
233
|
/**
|
|
247
234
|
* Using tag
|
|
@@ -254,17 +241,17 @@ var CodeMirror = defineComponent({
|
|
|
254
241
|
/** Emits */
|
|
255
242
|
emits: {
|
|
256
243
|
/** Model Update */
|
|
257
|
-
"update:modelValue": (
|
|
244
|
+
"update:modelValue": (e) => !0,
|
|
258
245
|
/** CodeMirror ViewUpdate */
|
|
259
|
-
update: (
|
|
246
|
+
update: (e) => !0,
|
|
260
247
|
/** CodeMirror onReady */
|
|
261
|
-
ready: (
|
|
248
|
+
ready: (e) => !0,
|
|
262
249
|
/** CodeMirror onFocus */
|
|
263
|
-
focus: (
|
|
250
|
+
focus: (e) => !0,
|
|
264
251
|
/** State Changed */
|
|
265
|
-
change: (
|
|
252
|
+
change: (e) => !0,
|
|
266
253
|
/** CodeMirror onDestroy */
|
|
267
|
-
destroy: () =>
|
|
254
|
+
destroy: () => !0
|
|
268
255
|
},
|
|
269
256
|
/**
|
|
270
257
|
* Setup
|
|
@@ -272,238 +259,166 @@ var CodeMirror = defineComponent({
|
|
|
272
259
|
* @param props - Props
|
|
273
260
|
* @param context - Context
|
|
274
261
|
*/
|
|
275
|
-
setup(
|
|
276
|
-
const
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
get: () => view.value.hasFocus,
|
|
281
|
-
set: (f) => {
|
|
282
|
-
if (f) {
|
|
283
|
-
view.value.focus();
|
|
284
|
-
}
|
|
262
|
+
setup(e, o) {
|
|
263
|
+
const n = v(), u = v(e.modelValue), t = P(new r()), d = c({
|
|
264
|
+
get: () => t.value.hasFocus,
|
|
265
|
+
set: (a) => {
|
|
266
|
+
a && t.value.focus();
|
|
285
267
|
}
|
|
286
|
-
})
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
set: (a) => view.value.dispatch({ selection: { anchor: a } })
|
|
294
|
-
});
|
|
295
|
-
const json = computed(
|
|
268
|
+
}), f = c({
|
|
269
|
+
get: () => t.value.state.selection,
|
|
270
|
+
set: (a) => t.value.dispatch({ selection: a })
|
|
271
|
+
}), m = c({
|
|
272
|
+
get: () => t.value.state.selection.main.head,
|
|
273
|
+
set: (a) => t.value.dispatch({ selection: { anchor: a } })
|
|
274
|
+
}), M = c(
|
|
296
275
|
{
|
|
297
|
-
get: () =>
|
|
298
|
-
set: (
|
|
276
|
+
get: () => t.value.state.toJSON(),
|
|
277
|
+
set: (a) => t.value.setState(s.fromJSON(a))
|
|
299
278
|
}
|
|
300
|
-
)
|
|
301
|
-
|
|
302
|
-
const diagnosticCount$1 = ref(0);
|
|
303
|
-
const extensions = computed(() => {
|
|
304
|
-
const language = new Compartment();
|
|
305
|
-
const tabSize = new Compartment();
|
|
279
|
+
), p = v(0), g = v(0), h = c(() => {
|
|
280
|
+
const a = new w(), l = new w();
|
|
306
281
|
return [
|
|
307
282
|
// Toggle basic setup
|
|
308
|
-
|
|
283
|
+
e.basic ? H : void 0,
|
|
309
284
|
// Toggle minimal setup
|
|
310
|
-
|
|
285
|
+
e.minimal && !e.basic ? K : void 0,
|
|
311
286
|
// ViewUpdate event listener
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
length.value = view.value.state.doc.length;
|
|
315
|
-
if (update.changes.empty || !update.docChanged) {
|
|
316
|
-
return;
|
|
317
|
-
}
|
|
318
|
-
if (props.linter) {
|
|
319
|
-
if (props.forceLinting) {
|
|
320
|
-
forceLinting(view.value);
|
|
321
|
-
}
|
|
322
|
-
diagnosticCount$1.value = props.linter(view.value).length;
|
|
323
|
-
}
|
|
324
|
-
context.emit("update", update);
|
|
287
|
+
r.updateListener.of((i) => {
|
|
288
|
+
o.emit("focus", t.value.hasFocus), p.value = t.value.state.doc.length, !(i.changes.empty || !i.docChanged) && (e.linter && (e.forceLinting && $(t.value), g.value = e.linter(t.value).length), o.emit("update", i));
|
|
325
289
|
}),
|
|
326
290
|
// Toggle light/dark mode.
|
|
327
|
-
|
|
291
|
+
r.theme(e.theme, { dark: e.dark }),
|
|
328
292
|
// Toggle line wrapping
|
|
329
|
-
|
|
293
|
+
e.wrap ? r.lineWrapping : void 0,
|
|
330
294
|
// Indent with tab
|
|
331
|
-
|
|
295
|
+
e.tab ? Q.of([ae]) : void 0,
|
|
332
296
|
// Allow Multiple Selections
|
|
333
|
-
|
|
297
|
+
s.allowMultipleSelections.of(e.allowMultipleSelections),
|
|
334
298
|
// Indent tab size
|
|
335
|
-
|
|
299
|
+
e.tabSize ? l.of(s.tabSize.of(e.tabSize)) : void 0,
|
|
336
300
|
// locale settings
|
|
337
|
-
|
|
301
|
+
e.phrases ? s.phrases.of(e.phrases) : void 0,
|
|
338
302
|
// Readonly option
|
|
339
|
-
|
|
303
|
+
s.readOnly.of(e.readonly),
|
|
340
304
|
// Editable option
|
|
341
|
-
|
|
305
|
+
r.editable.of(!e.disabled),
|
|
342
306
|
// Set Line break char
|
|
343
|
-
|
|
307
|
+
e.lineSeparator ? s.lineSeparator.of(e.lineSeparator) : void 0,
|
|
344
308
|
// Lang
|
|
345
|
-
|
|
309
|
+
e.lang ? a.of(e.lang) : void 0,
|
|
346
310
|
// Append Linter settings
|
|
347
|
-
|
|
311
|
+
e.linter ? Y(e.linter, e.linterConfig) : void 0,
|
|
348
312
|
// Show 🔴 to error line when linter enabled.
|
|
349
|
-
|
|
313
|
+
e.linter && e.gutter ? ee(e.gutterConfig) : void 0,
|
|
350
314
|
// Placeholder
|
|
351
|
-
|
|
315
|
+
e.placeholder ? X(e.placeholder) : void 0,
|
|
352
316
|
// Append Extensions
|
|
353
|
-
...
|
|
354
|
-
].filter((
|
|
317
|
+
...e.extensions
|
|
318
|
+
].filter((i) => !!i);
|
|
355
319
|
});
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
(
|
|
359
|
-
|
|
360
|
-
effects:
|
|
320
|
+
C(
|
|
321
|
+
h,
|
|
322
|
+
(a) => {
|
|
323
|
+
t.value?.dispatch({
|
|
324
|
+
effects: y.reconfigure.of(a)
|
|
361
325
|
});
|
|
362
326
|
},
|
|
363
|
-
{ immediate:
|
|
364
|
-
)
|
|
365
|
-
|
|
366
|
-
() =>
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
changes: { from: 0, to: view.value.state.doc.length, insert: value },
|
|
374
|
-
selection: view.value.state.selection,
|
|
375
|
-
scrollIntoView: true
|
|
327
|
+
{ immediate: !0 }
|
|
328
|
+
), C(
|
|
329
|
+
() => e.modelValue,
|
|
330
|
+
async (a) => {
|
|
331
|
+
t.value.composing || // IME fix
|
|
332
|
+
t.value.state.doc.toJSON().join(e.lineSeparator ?? `
|
|
333
|
+
`) === a || t.value.dispatch({
|
|
334
|
+
changes: { from: 0, to: t.value.state.doc.length, insert: a },
|
|
335
|
+
selection: t.value.state.selection,
|
|
336
|
+
scrollIntoView: !0
|
|
376
337
|
});
|
|
377
338
|
},
|
|
378
|
-
{ immediate:
|
|
379
|
-
)
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
"[CodeMirror.vue] The <code-mirror> tag contains child elements that overwrite the `v-model` values."
|
|
389
|
-
);
|
|
339
|
+
{ immediate: !0 }
|
|
340
|
+
), Z(async () => {
|
|
341
|
+
let a = u.value;
|
|
342
|
+
n.value && (n.value.childNodes[0] && (u.value !== "" && console.warn(
|
|
343
|
+
"[CodeMirror.vue] The <code-mirror> tag contains child elements that overwrite the `v-model` values."
|
|
344
|
+
), a = n.value.childNodes[0].innerText.trim()), t.value = new r({
|
|
345
|
+
parent: n.value,
|
|
346
|
+
state: s.create({ doc: a, extensions: h.value }),
|
|
347
|
+
dispatch: (l) => {
|
|
348
|
+
t.value.update([l]), !(l.changes.empty || !l.docChanged) && (o.emit("update:modelValue", l.state.doc.toString()), o.emit("change", l.state));
|
|
390
349
|
}
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
if (tr.changes.empty || !tr.docChanged) {
|
|
399
|
-
return;
|
|
400
|
-
}
|
|
401
|
-
context.emit("update:modelValue", tr.state.doc.toString());
|
|
402
|
-
context.emit("change", tr.state);
|
|
403
|
-
}
|
|
404
|
-
});
|
|
405
|
-
await nextTick();
|
|
406
|
-
context.emit("ready", {
|
|
407
|
-
view: view.value,
|
|
408
|
-
state: view.value.state,
|
|
409
|
-
container: editor.value
|
|
410
|
-
});
|
|
411
|
-
});
|
|
412
|
-
onUnmounted(() => {
|
|
413
|
-
view.value.destroy();
|
|
414
|
-
context.emit("destroy");
|
|
350
|
+
}), await k(), o.emit("ready", {
|
|
351
|
+
view: t.value,
|
|
352
|
+
state: t.value.state,
|
|
353
|
+
container: n.value
|
|
354
|
+
}));
|
|
355
|
+
}), q(() => {
|
|
356
|
+
t.value.destroy(), o.emit("destroy");
|
|
415
357
|
});
|
|
416
|
-
const
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
diagnosticCount$1.value = diagnosticCount(view.value.state);
|
|
424
|
-
};
|
|
425
|
-
const forceReconfigure = () => {
|
|
426
|
-
view.value?.dispatch({
|
|
427
|
-
effects: StateEffect.reconfigure.of([])
|
|
428
|
-
});
|
|
429
|
-
view.value?.dispatch({
|
|
430
|
-
effects: StateEffect.appendConfig.of(extensions.value)
|
|
358
|
+
const V = () => {
|
|
359
|
+
!e.linter || !t.value || (e.forceLinting && $(t.value), g.value = te(t.value.state));
|
|
360
|
+
}, j = () => {
|
|
361
|
+
t.value?.dispatch({
|
|
362
|
+
effects: y.reconfigure.of([])
|
|
363
|
+
}), t.value?.dispatch({
|
|
364
|
+
effects: y.appendConfig.of(h.value)
|
|
431
365
|
});
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
return
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
(
|
|
455
|
-
);
|
|
456
|
-
};
|
|
457
|
-
const somethingSelected = () => view.value.state.selection.ranges.some(
|
|
458
|
-
(r) => !r.empty
|
|
459
|
-
);
|
|
460
|
-
const replaceRange = (replacement, from, to) => view.value.dispatch({
|
|
461
|
-
changes: { from, to, insert: replacement }
|
|
462
|
-
});
|
|
463
|
-
const replaceSelection = (replacement) => view.value.dispatch(view.value.state.replaceSelection(replacement));
|
|
464
|
-
const setCursor = (position) => view.value.dispatch({ selection: { anchor: position } });
|
|
465
|
-
const setSelection = (anchor, head) => view.value.dispatch({ selection: { anchor, head } });
|
|
466
|
-
const setSelections = (ranges, primary) => view.value.dispatch({
|
|
467
|
-
selection: EditorSelection.create(ranges, primary)
|
|
468
|
-
});
|
|
469
|
-
const extendSelectionsBy = (f) => view.value.dispatch({
|
|
470
|
-
selection: EditorSelection.create(
|
|
471
|
-
selection.value.ranges.map((r) => r.extend(f(r)))
|
|
366
|
+
}, x = (a, l) => t.value.state.sliceDoc(a, l), L = (a) => t.value.state.doc.line(a + 1).text, N = () => t.value.state.doc.lines, z = () => t.value.state.selection.main.head, T = () => {
|
|
367
|
+
let a;
|
|
368
|
+
return (a = t.value.state.selection.ranges) !== null && a !== void 0 ? a : [];
|
|
369
|
+
}, D = () => {
|
|
370
|
+
let a;
|
|
371
|
+
return (a = t.value.state.sliceDoc(
|
|
372
|
+
t.value.state.selection.main.from,
|
|
373
|
+
t.value.state.selection.main.to
|
|
374
|
+
)) !== null && a !== void 0 ? a : "";
|
|
375
|
+
}, E = () => {
|
|
376
|
+
const a = t.value.state;
|
|
377
|
+
return a ? a.selection.ranges.map(
|
|
378
|
+
(l) => a.sliceDoc(l.from, l.to)
|
|
379
|
+
) : [];
|
|
380
|
+
}, R = () => t.value.state.selection.ranges.some(
|
|
381
|
+
(a) => !a.empty
|
|
382
|
+
), F = (a, l, i) => t.value.dispatch({
|
|
383
|
+
changes: { from: l, to: i, insert: a }
|
|
384
|
+
}), J = (a) => t.value.dispatch(t.value.state.replaceSelection(a)), A = (a) => t.value.dispatch({ selection: { anchor: a } }), U = (a, l) => t.value.dispatch({ selection: { anchor: a, head: l } }), W = (a, l) => t.value.dispatch({
|
|
385
|
+
selection: O.create(a, l)
|
|
386
|
+
}), _ = (a) => t.value.dispatch({
|
|
387
|
+
selection: O.create(
|
|
388
|
+
f.value.ranges.map((l) => l.extend(a(l)))
|
|
472
389
|
)
|
|
473
|
-
})
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
forceReconfigure,
|
|
390
|
+
}), S = {
|
|
391
|
+
editor: n,
|
|
392
|
+
view: t,
|
|
393
|
+
cursor: m,
|
|
394
|
+
selection: f,
|
|
395
|
+
focus: d,
|
|
396
|
+
length: p,
|
|
397
|
+
json: M,
|
|
398
|
+
diagnosticCount: g,
|
|
399
|
+
dom: t.value.contentDOM,
|
|
400
|
+
lint: V,
|
|
401
|
+
forceReconfigure: j,
|
|
486
402
|
// Bellow is CodeMirror5's function
|
|
487
|
-
getRange,
|
|
488
|
-
getLine,
|
|
489
|
-
lineCount,
|
|
490
|
-
getCursor,
|
|
491
|
-
listSelections,
|
|
492
|
-
getSelection,
|
|
493
|
-
getSelections,
|
|
494
|
-
somethingSelected,
|
|
495
|
-
replaceRange,
|
|
496
|
-
replaceSelection,
|
|
497
|
-
setCursor,
|
|
498
|
-
setSelection,
|
|
499
|
-
setSelections,
|
|
500
|
-
extendSelectionsBy
|
|
403
|
+
getRange: x,
|
|
404
|
+
getLine: L,
|
|
405
|
+
lineCount: N,
|
|
406
|
+
getCursor: z,
|
|
407
|
+
listSelections: T,
|
|
408
|
+
getSelection: D,
|
|
409
|
+
getSelections: E,
|
|
410
|
+
somethingSelected: R,
|
|
411
|
+
replaceRange: F,
|
|
412
|
+
replaceSelection: J,
|
|
413
|
+
setCursor: A,
|
|
414
|
+
setSelection: U,
|
|
415
|
+
setSelections: W,
|
|
416
|
+
extendSelectionsBy: _
|
|
501
417
|
};
|
|
502
|
-
|
|
503
|
-
return exposed;
|
|
418
|
+
return o.expose(S), S;
|
|
504
419
|
},
|
|
505
420
|
render() {
|
|
506
|
-
return
|
|
421
|
+
return B(
|
|
507
422
|
this.$props.tag,
|
|
508
423
|
{
|
|
509
424
|
ref: "editor",
|
|
@@ -511,22 +426,23 @@ var CodeMirror = defineComponent({
|
|
|
511
426
|
},
|
|
512
427
|
this.$slots.default ? (
|
|
513
428
|
// Hide original content
|
|
514
|
-
|
|
429
|
+
B(
|
|
515
430
|
"aside",
|
|
516
431
|
{ style: "display: none;", "aria-hidden": "true" },
|
|
517
|
-
|
|
432
|
+
ne(this.$slots.default)
|
|
518
433
|
)
|
|
519
434
|
) : void 0
|
|
520
435
|
);
|
|
521
436
|
}
|
|
522
437
|
});
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
438
|
+
const ie = {
|
|
439
|
+
version: "1.2.0",
|
|
440
|
+
date: "2024-01-08T15:53:56.825Z"
|
|
441
|
+
};
|
|
442
|
+
var ve = ie;
|
|
443
|
+
const me = (e) => e.component("CodeMirror", oe);
|
|
444
|
+
export {
|
|
445
|
+
ve as Meta,
|
|
446
|
+
oe as default,
|
|
447
|
+
me as install
|
|
527
448
|
};
|
|
528
|
-
var meta$1 = meta;
|
|
529
|
-
|
|
530
|
-
const installCodeMirror = (app) => app.component("CodeMirror", CodeMirror);
|
|
531
|
-
|
|
532
|
-
export { meta$1 as Meta, CodeMirror as default, installCodeMirror as install };
|