vue-codemirror6 1.5.1 → 1.6.0

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/index.es.js CHANGED
@@ -3,305 +3,415 @@
3
3
  *
4
4
  * @description CodeMirror6 Component for vue2 and vue3.
5
5
  * @author Logue <logue@hotmail.co.jp>
6
- * @copyright 2022-2026 By Masashi Yoshikawa All rights reserved.
7
6
  * @license MIT
8
- * @version 1.5.1
7
+ * @version 1.6.0
9
8
  * @see {@link https://github.com/logue/vue-codemirror6}
10
9
  */
11
10
 
12
- import { indentWithTab as e } from "@codemirror/commands";
13
- import { indentUnit as t } from "@codemirror/language";
14
- import { diagnosticCount as n, forceLinting as r, lintGutter as i, linter as a } from "@codemirror/lint";
15
- import { Compartment as o, EditorSelection as s, EditorState as c, StateEffect as l } from "@codemirror/state";
16
- import { EditorView as u, keymap as d, placeholder as f } from "@codemirror/view";
17
- import { basicSetup as p, minimalSetup as m } from "codemirror";
18
- import { computed as h, defineComponent as g, h as _, isVue2 as v, nextTick as y, onMounted as b, onUnmounted as x, ref as S, shallowRef as C, watch as w } from "vue-demi";
19
- //#region src/Meta.ts
20
- var T = {
21
- version: "1.5.1",
22
- date: "2026-04-03T05:31:33.377Z"
23
- }, E = (e) => e ? Object.entries(e).reduce((e, [t, n]) => (t = t.charAt(0).toUpperCase() + t.slice(1), t = `on${t}`, {
24
- ...e,
25
- [t]: n
26
- }), {}) : {};
27
- function D(e, t = {}, n) {
28
- if (v) return _(e, t, n);
29
- let { props: r, domProps: i, on: a, ...o } = t, s = a ? E(a) : {};
30
- return _(e, {
31
- ...o,
32
- ...r,
33
- ...i,
34
- ...s
35
- }, n);
11
+ import { indentWithTab } from "@codemirror/commands";
12
+ import { indentUnit } from "@codemirror/language";
13
+ import { diagnosticCount as lint_diagnosticCount, forceLinting, lintGutter, linter } from "@codemirror/lint";
14
+ import { Compartment, EditorSelection, EditorState, StateEffect } from "@codemirror/state";
15
+ import { EditorView, keymap, placeholder } from "@codemirror/view";
16
+ import { basicSetup, minimalSetup } from "codemirror";
17
+ import { computed, defineComponent, h, isVue2, nextTick, onMounted, onUnmounted, ref, shallowRef, watch } from "vue-demi";
18
+ const Meta = {
19
+ version: "1.6.0",
20
+ date: "2026-07-03T10:06:19.129Z"
21
+ };
22
+ const adaptOnsV3 = (ons)=>{
23
+ if (!ons) return {};
24
+ return Object.entries(ons).reduce((ret, [key, handler])=>{
25
+ key = key.charAt(0).toUpperCase() + key.slice(1);
26
+ key = `on${key}`;
27
+ return {
28
+ ...ret,
29
+ [key]: handler
30
+ };
31
+ }, {});
32
+ };
33
+ function h_demi_h(type, options = {}, children) {
34
+ if (isVue2) return h(type, options, children);
35
+ const { props, domProps, on, ...extraOptions } = options;
36
+ const ons = on ? adaptOnsV3(on) : {};
37
+ return h(type, {
38
+ ...extraOptions,
39
+ ...props,
40
+ ...domProps,
41
+ ...ons
42
+ }, children);
36
43
  }
37
- var O = (e) => typeof e == "function" ? e() : e, k = g({
38
- name: "CodeMirror",
39
- model: {
40
- prop: "modelValue",
41
- event: "update:modelValue"
42
- },
43
- props: {
44
- modelValue: {
45
- type: String,
46
- default: ""
47
- },
48
- theme: {
49
- type: Object,
50
- default: () => ({})
51
- },
52
- dark: {
53
- type: Boolean,
54
- default: !1
55
- },
56
- basic: {
57
- type: Boolean,
58
- default: !1
59
- },
60
- minimal: {
61
- type: Boolean,
62
- default: !1
63
- },
64
- placeholder: {
65
- type: String,
66
- default: void 0
67
- },
68
- wrap: {
69
- type: Boolean,
70
- default: !1
71
- },
72
- tab: {
73
- type: Boolean,
74
- default: !1
75
- },
76
- indentUnit: {
77
- type: String,
78
- default: void 0
79
- },
80
- allowMultipleSelections: {
81
- type: Boolean,
82
- default: !1
83
- },
84
- tabSize: {
85
- type: Number,
86
- default: void 0
87
- },
88
- lineSeparator: {
89
- type: String,
90
- default: void 0
91
- },
92
- readonly: {
93
- type: Boolean,
94
- default: !1
95
- },
96
- disabled: {
97
- type: Boolean,
98
- default: !1
99
- },
100
- extensions: {
101
- type: Array,
102
- default: () => []
103
- },
104
- phrases: {
105
- type: Object,
106
- default: void 0
107
- },
108
- lang: {
109
- type: Object,
110
- default: void 0
111
- },
112
- linter: {
113
- type: Function,
114
- default: void 0
115
- },
116
- linterConfig: {
117
- type: Object,
118
- default: () => ({})
119
- },
120
- forceLinting: {
121
- type: Boolean,
122
- default: !1
123
- },
124
- gutter: {
125
- type: Boolean,
126
- default: !1
127
- },
128
- gutterConfig: {
129
- type: Object,
130
- default: void 0
131
- },
132
- tag: {
133
- type: String,
134
- default: "div"
135
- },
136
- scrollIntoView: {
137
- type: Boolean,
138
- default: !0
139
- },
140
- preserveScrollPosition: {
141
- type: Boolean,
142
- default: !1
143
- },
144
- keymap: {
145
- type: Array,
146
- default: () => []
147
- }
148
- },
149
- emits: {
150
- "update:modelValue": (e = "") => !0,
151
- update: (e) => !0,
152
- ready: (e) => !0,
153
- focus: (e) => !0,
154
- change: (e) => !0,
155
- destroy: () => !0
156
- },
157
- setup(g, _) {
158
- let v = S(), T = S(g.modelValue), E = C(void 0), D = h({
159
- get: () => E.value?.hasFocus ?? !1,
160
- set: (e) => {
161
- e && E.value && E.value.focus();
162
- }
163
- }), O = h({
164
- get: () => E.value?.state.selection,
165
- set: (e) => {
166
- E.value && e && E.value.dispatch({ selection: e });
167
- }
168
- }), k = h({
169
- get: () => E.value?.state.selection.main.head ?? 0,
170
- set: (e) => {
171
- E.value && E.value.dispatch({ selection: { anchor: e } });
172
- }
173
- }), A = h({
174
- get: () => E.value?.state.toJSON(),
175
- set: (e) => {
176
- E.value && e && E.value.setState(c.fromJSON(e));
177
- }
178
- }), j = S(0), M = S(0), N = h(() => {
179
- let n = new o(), s = new o();
180
- if (g.basic && g.minimal) throw Error("[Vue CodeMirror] Both basic and minimal cannot be specified.");
181
- let l = [];
182
- return g.keymap && g.keymap.length > 0 && (l = g.keymap), g.tab && l.push(e), [
183
- g.basic && !g.minimal ? p : void 0,
184
- g.minimal && !g.basic ? m : void 0,
185
- u.updateListener.of((e) => {
186
- E.value && (_.emit("focus", E.value.hasFocus), j.value = E.value.state.doc?.length, !(e.changes.empty || !e.docChanged) && (g.linter && (g.forceLinting && r(E.value), M.value = g.linter(E.value).length), _.emit("update", e)));
187
- }),
188
- u.theme(g.theme, { dark: g.dark }),
189
- g.wrap ? u.lineWrapping : void 0,
190
- g.indentUnit ? t.of(g.indentUnit) : void 0,
191
- c.allowMultipleSelections.of(g.allowMultipleSelections),
192
- g.tabSize ? s.of(c.tabSize.of(g.tabSize)) : void 0,
193
- g.phrases ? c.phrases.of(g.phrases) : void 0,
194
- c.readOnly.of(g.readonly),
195
- u.editable.of(!g.disabled),
196
- g.lineSeparator ? c.lineSeparator.of(g.lineSeparator) : void 0,
197
- g.lang ? n.of(g.lang) : void 0,
198
- g.linter ? a(g.linter, g.linterConfig) : void 0,
199
- g.linter && g.gutter ? i(g.gutterConfig) : void 0,
200
- g.placeholder ? f(g.placeholder) : void 0,
201
- l.length > 0 ? d.of(l) : void 0,
202
- ...g.extensions
203
- ].filter((e) => !!e);
204
- });
205
- w(N, (e) => E.value?.dispatch({ effects: l.reconfigure.of(e) }), { immediate: !0 }), w(() => g.modelValue, async (e) => {
206
- if (!E.value || E.value.composing || E.value.state.doc.toJSON().join(g.lineSeparator ?? "\n") === e) return;
207
- let t = !E.value.state.selection.ranges.every((t) => t.anchor < e.length && t.head < e.length), n = {
208
- from: 0,
209
- to: E.value.state.doc.length,
210
- insert: e
211
- }, r = g.preserveScrollPosition ? E.value.scrollSnapshot().map(E.value.state.changes(n)) : void 0;
212
- E.value.dispatch({
213
- changes: n,
214
- selection: t ? {
215
- anchor: 0,
216
- head: 0
217
- } : E.value.state.selection,
218
- scrollIntoView: g.scrollIntoView,
219
- effects: r ? [r] : void 0
220
- });
221
- }, { immediate: !0 }), b(async () => {
222
- if (globalThis.window === void 0 || !v.value) return;
223
- let e = T.value;
224
- v.value.childNodes[0] && (T.value !== "" && console.warn("[CodeMirror.vue] The <code-mirror> tag contains child elements that overwrite the `v-model` values."), e = v.value.childNodes[0].innerText.trim()), E.value = new u({
225
- parent: v.value,
226
- state: c.create({
227
- doc: e,
228
- extensions: N.value
229
- }),
230
- dispatch: (e) => {
231
- E.value && (E.value.update([e]), !(e.changes.empty || !e.docChanged) && (_.emit("update:modelValue", e.state.doc.toString()), _.emit("change", e.state)));
232
- }
233
- }), await y(), _.emit("ready", {
234
- view: E.value,
235
- state: E.value.state,
236
- container: v.value
237
- });
238
- }), x(() => {
239
- E.value && (E.value.destroy(), _.emit("destroy"));
240
- });
241
- let P = {
242
- editor: v,
243
- view: E,
244
- cursor: k,
245
- selection: O,
246
- focus: D,
247
- length: j,
248
- json: A,
249
- diagnosticCount: M,
250
- dom: E.value?.contentDOM,
251
- lint: () => {
252
- !g.linter || !E.value || (g.forceLinting && r(E.value), M.value = n(E.value.state));
253
- },
254
- forceReconfigure: () => {
255
- E.value?.dispatch({ effects: l.reconfigure.of([]) }), E.value?.dispatch({ effects: l.appendConfig.of(N.value) });
256
- },
257
- getRange: (e, t) => E.value?.state.sliceDoc(e, t),
258
- getLine: (e) => E.value?.state.doc.line(e + 1).text,
259
- lineCount: () => E.value?.state.doc.lines ?? 0,
260
- getCursor: () => E.value?.state.selection.main.head ?? 0,
261
- listSelections: () => E.value?.state.selection.ranges ?? [],
262
- getSelection: () => E.value ? E.value.state.sliceDoc(E.value.state.selection.main.from, E.value.state.selection.main.to) : "",
263
- getSelections: () => {
264
- let e = E.value?.state;
265
- return e ? e.selection.ranges.map((t) => e.sliceDoc(t.from, t.to)) : [];
266
- },
267
- somethingSelected: () => E.value?.state.selection.ranges.some((e) => !e.empty) ?? !1,
268
- replaceRange: (e, t, n) => {
269
- E.value && E.value.dispatch({ changes: {
270
- from: t,
271
- to: n,
272
- insert: e
273
- } });
274
- },
275
- replaceSelection: (e) => {
276
- E.value && E.value.dispatch(E.value.state.replaceSelection(e));
277
- },
278
- setCursor: (e) => {
279
- E.value && E.value.dispatch({ selection: { anchor: e } });
280
- },
281
- setSelection: (e, t) => {
282
- E.value && E.value.dispatch({ selection: {
283
- anchor: e,
284
- head: t
285
- } });
286
- },
287
- setSelections: (e, t) => {
288
- E.value && E.value.dispatch({ selection: s.create(e, t) });
289
- },
290
- extendSelectionsBy: (e) => {
291
- E.value && O.value && E.value.dispatch({ selection: s.create(O.value.ranges.map((t) => t.extend(e(t)))) });
292
- }
293
- };
294
- return _.expose(P), P;
295
- },
296
- render() {
297
- return D(this.$props.tag, {
298
- ref: "editor",
299
- class: "vue-codemirror"
300
- }, this.$slots.default ? D("aside", {
301
- style: "display: none;",
302
- "aria-hidden": "true"
303
- }, O(this.$slots.default)) : void 0);
304
- }
305
- }), A = (e) => e.component("CodeMirror", k);
306
- //#endregion
307
- export { T as Meta, k as default, A as install };
44
+ const slot = (defaultSlots)=>'function' == typeof defaultSlots ? defaultSlots() : defaultSlots ?? [];
45
+ const CodeMirror = defineComponent({
46
+ name: 'CodeMirror',
47
+ model: {
48
+ prop: 'modelValue',
49
+ event: 'update:modelValue'
50
+ },
51
+ props: {
52
+ modelValue: {
53
+ type: String,
54
+ default: ''
55
+ },
56
+ theme: {
57
+ type: Object,
58
+ default: ()=>({})
59
+ },
60
+ dark: {
61
+ type: Boolean,
62
+ default: false
63
+ },
64
+ basic: {
65
+ type: Boolean,
66
+ default: false
67
+ },
68
+ minimal: {
69
+ type: Boolean,
70
+ default: false
71
+ },
72
+ placeholder: {
73
+ type: String,
74
+ default: void 0
75
+ },
76
+ wrap: {
77
+ type: Boolean,
78
+ default: false
79
+ },
80
+ tab: {
81
+ type: Boolean,
82
+ default: false
83
+ },
84
+ indentUnit: {
85
+ type: String,
86
+ default: void 0
87
+ },
88
+ allowMultipleSelections: {
89
+ type: Boolean,
90
+ default: false
91
+ },
92
+ tabSize: {
93
+ type: Number,
94
+ default: void 0
95
+ },
96
+ lineSeparator: {
97
+ type: String,
98
+ default: void 0
99
+ },
100
+ readonly: {
101
+ type: Boolean,
102
+ default: false
103
+ },
104
+ disabled: {
105
+ type: Boolean,
106
+ default: false
107
+ },
108
+ extensions: {
109
+ type: Array,
110
+ default: ()=>[]
111
+ },
112
+ phrases: {
113
+ type: Object,
114
+ default: void 0
115
+ },
116
+ lang: {
117
+ type: Object,
118
+ default: void 0
119
+ },
120
+ linter: {
121
+ type: Function,
122
+ default: void 0
123
+ },
124
+ linterConfig: {
125
+ type: Object,
126
+ default: ()=>({})
127
+ },
128
+ forceLinting: {
129
+ type: Boolean,
130
+ default: false
131
+ },
132
+ gutter: {
133
+ type: Boolean,
134
+ default: false
135
+ },
136
+ gutterConfig: {
137
+ type: Object,
138
+ default: void 0
139
+ },
140
+ tag: {
141
+ type: String,
142
+ default: 'div'
143
+ },
144
+ scrollIntoView: {
145
+ type: Boolean,
146
+ default: true
147
+ },
148
+ preserveScrollPosition: {
149
+ type: Boolean,
150
+ default: false
151
+ },
152
+ keymap: {
153
+ type: Array,
154
+ default: ()=>[]
155
+ }
156
+ },
157
+ emits: {
158
+ 'update:modelValue': (_value = '')=>true,
159
+ update: (_value)=>true,
160
+ ready: (_value)=>true,
161
+ focus: (_value)=>true,
162
+ change: (_value)=>true,
163
+ destroy: ()=>true
164
+ },
165
+ setup (props, context) {
166
+ const editor = ref();
167
+ const doc = ref(props.modelValue);
168
+ const view = shallowRef(void 0);
169
+ const focus = computed({
170
+ get: ()=>view.value?.hasFocus ?? false,
171
+ set: (f)=>{
172
+ if (f && view.value) view.value.focus();
173
+ }
174
+ });
175
+ const selection = computed({
176
+ get: ()=>view.value?.state.selection,
177
+ set: (selection)=>{
178
+ if (view.value && selection) view.value.dispatch({
179
+ selection
180
+ });
181
+ }
182
+ });
183
+ const cursor = computed({
184
+ get: ()=>view.value?.state.selection.main.head ?? 0,
185
+ set: (anchor)=>{
186
+ if (view.value) view.value.dispatch({
187
+ selection: {
188
+ anchor
189
+ }
190
+ });
191
+ }
192
+ });
193
+ const json = computed({
194
+ get: ()=>view.value?.state.toJSON(),
195
+ set: (j)=>{
196
+ if (view.value && j) view.value.setState(EditorState.fromJSON(j));
197
+ }
198
+ });
199
+ const length = ref(0);
200
+ const diagnosticCount = ref(0);
201
+ const extensions = computed(()=>{
202
+ const language = new Compartment();
203
+ const tabSize = new Compartment();
204
+ if (props.basic && props.minimal) throw new Error('[Vue CodeMirror] Both basic and minimal cannot be specified.');
205
+ let keymaps = [];
206
+ if (props.keymap && props.keymap.length > 0) keymaps = props.keymap;
207
+ if (props.tab) keymaps.push(indentWithTab);
208
+ return [
209
+ props.basic && !props.minimal ? basicSetup : void 0,
210
+ props.minimal && !props.basic ? minimalSetup : void 0,
211
+ EditorView.updateListener.of((update)=>{
212
+ if (!view.value) return;
213
+ context.emit('focus', view.value.hasFocus);
214
+ length.value = view.value.state.doc?.length;
215
+ if (update.changes.empty || !update.docChanged) return;
216
+ if (props.linter) {
217
+ if (props.forceLinting) forceLinting(view.value);
218
+ diagnosticCount.value = props.linter(view.value).length;
219
+ }
220
+ context.emit('update', update);
221
+ }),
222
+ EditorView.theme(props.theme, {
223
+ dark: props.dark
224
+ }),
225
+ props.wrap ? EditorView.lineWrapping : void 0,
226
+ props.indentUnit ? indentUnit.of(props.indentUnit) : void 0,
227
+ EditorState.allowMultipleSelections.of(props.allowMultipleSelections),
228
+ props.tabSize ? tabSize.of(EditorState.tabSize.of(props.tabSize)) : void 0,
229
+ props.phrases ? EditorState.phrases.of(props.phrases) : void 0,
230
+ EditorState.readOnly.of(props.readonly),
231
+ EditorView.editable.of(!props.disabled),
232
+ props.lineSeparator ? EditorState.lineSeparator.of(props.lineSeparator) : void 0,
233
+ props.lang ? language.of(props.lang) : void 0,
234
+ props.linter ? linter(props.linter, props.linterConfig) : void 0,
235
+ props.linter && props.gutter ? lintGutter(props.gutterConfig) : void 0,
236
+ props.placeholder ? placeholder(props.placeholder) : void 0,
237
+ keymaps.length > 0 ? keymap.of(keymaps) : void 0,
238
+ ...props.extensions
239
+ ].filter((extension)=>!!extension);
240
+ });
241
+ watch(extensions, (exts)=>view.value?.dispatch({
242
+ effects: StateEffect.reconfigure.of(exts)
243
+ }), {
244
+ immediate: true
245
+ });
246
+ watch(()=>props.modelValue, async (value)=>{
247
+ if (!view.value) return;
248
+ if (view.value.composing || view.value.state.doc.toJSON().join(props.lineSeparator ?? '\n') === value) return;
249
+ const isSelectionOutOfRange = !view.value.state.selection.ranges.every((range)=>range.anchor < value.length && range.head < value.length);
250
+ const changes = {
251
+ from: 0,
252
+ to: view.value.state.doc.length,
253
+ insert: value
254
+ };
255
+ const scrollSnapshot = props.preserveScrollPosition ? view.value.scrollSnapshot().map(view.value.state.changes(changes)) : void 0;
256
+ view.value.dispatch({
257
+ changes,
258
+ selection: isSelectionOutOfRange ? {
259
+ anchor: 0,
260
+ head: 0
261
+ } : view.value.state.selection,
262
+ scrollIntoView: props.scrollIntoView,
263
+ effects: scrollSnapshot ? [
264
+ scrollSnapshot
265
+ ] : void 0
266
+ });
267
+ }, {
268
+ immediate: true
269
+ });
270
+ onMounted(async ()=>{
271
+ if (void 0 === globalThis.window || !editor.value) return;
272
+ let value = doc.value;
273
+ if (editor.value.childNodes[0]) {
274
+ if ('' !== doc.value) console.warn('[CodeMirror.vue] The <code-mirror> tag contains child elements that overwrite the `v-model` values.');
275
+ value = editor.value.childNodes[0].innerText.trim();
276
+ }
277
+ view.value = new EditorView({
278
+ parent: editor.value,
279
+ state: EditorState.create({
280
+ doc: value,
281
+ extensions: extensions.value
282
+ }),
283
+ dispatch: (tr)=>{
284
+ if (!view.value) return;
285
+ view.value.update([
286
+ tr
287
+ ]);
288
+ if (tr.changes.empty || !tr.docChanged) return;
289
+ context.emit('update:modelValue', tr.state.doc.toString());
290
+ context.emit('change', tr.state);
291
+ }
292
+ });
293
+ await nextTick();
294
+ context.emit('ready', {
295
+ view: view.value,
296
+ state: view.value.state,
297
+ container: editor.value
298
+ });
299
+ });
300
+ onUnmounted(()=>{
301
+ if (view.value) {
302
+ view.value.destroy();
303
+ context.emit('destroy');
304
+ }
305
+ });
306
+ const lint = ()=>{
307
+ if (!props.linter || !view.value) return;
308
+ if (props.forceLinting) forceLinting(view.value);
309
+ diagnosticCount.value = lint_diagnosticCount(view.value.state);
310
+ };
311
+ const forceReconfigure = ()=>{
312
+ view.value?.dispatch({
313
+ effects: StateEffect.reconfigure.of([])
314
+ });
315
+ view.value?.dispatch({
316
+ effects: StateEffect.appendConfig.of(extensions.value)
317
+ });
318
+ };
319
+ const getRange = (from, to)=>view.value?.state.sliceDoc(from, to);
320
+ const getLine = (number)=>view.value?.state.doc.line(number + 1).text;
321
+ const lineCount = ()=>view.value?.state.doc.lines ?? 0;
322
+ const getCursor = ()=>view.value?.state.selection.main.head ?? 0;
323
+ const listSelections = ()=>view.value?.state.selection.ranges ?? [];
324
+ const getSelection = ()=>{
325
+ if (!view.value) return '';
326
+ return view.value.state.sliceDoc(view.value.state.selection.main.from, view.value.state.selection.main.to);
327
+ };
328
+ const getSelections = ()=>{
329
+ const s = view.value?.state;
330
+ if (!s) return [];
331
+ return s.selection.ranges.map((r)=>s.sliceDoc(r.from, r.to));
332
+ };
333
+ const somethingSelected = ()=>view.value?.state.selection.ranges.some((r)=>!r.empty) ?? false;
334
+ const replaceRange = (replacement, from, to)=>{
335
+ if (view.value) view.value.dispatch({
336
+ changes: {
337
+ from,
338
+ to,
339
+ insert: replacement
340
+ }
341
+ });
342
+ };
343
+ const replaceSelection = (replacement)=>{
344
+ if (view.value) view.value.dispatch(view.value.state.replaceSelection(replacement));
345
+ };
346
+ const setCursor = (position)=>{
347
+ if (view.value) view.value.dispatch({
348
+ selection: {
349
+ anchor: position
350
+ }
351
+ });
352
+ };
353
+ const setSelection = (anchor, head)=>{
354
+ if (view.value) view.value.dispatch({
355
+ selection: {
356
+ anchor,
357
+ head
358
+ }
359
+ });
360
+ };
361
+ const setSelections = (ranges, primary)=>{
362
+ if (view.value) view.value.dispatch({
363
+ selection: EditorSelection.create(ranges, primary)
364
+ });
365
+ };
366
+ const extendSelectionsBy = (f)=>{
367
+ if (view.value && selection.value) view.value.dispatch({
368
+ selection: EditorSelection.create(selection.value.ranges.map((r)=>r.extend(f(r))))
369
+ });
370
+ };
371
+ const exposed = {
372
+ editor,
373
+ view,
374
+ cursor,
375
+ selection,
376
+ focus,
377
+ length,
378
+ json,
379
+ diagnosticCount,
380
+ dom: view.value?.contentDOM,
381
+ lint,
382
+ forceReconfigure,
383
+ getRange,
384
+ getLine,
385
+ lineCount,
386
+ getCursor,
387
+ listSelections,
388
+ getSelection,
389
+ getSelections,
390
+ somethingSelected,
391
+ replaceRange,
392
+ replaceSelection,
393
+ setCursor,
394
+ setSelection,
395
+ setSelections,
396
+ extendSelectionsBy
397
+ };
398
+ context.expose(exposed);
399
+ return exposed;
400
+ },
401
+ render () {
402
+ return h_demi_h(this.$props.tag, {
403
+ ref: 'editor',
404
+ class: 'vue-codemirror'
405
+ }, this.$slots.default ? h_demi_h('aside', {
406
+ style: 'display: none;',
407
+ 'aria-hidden': 'true'
408
+ }, slot(this.$slots.default)) : void 0);
409
+ }
410
+ });
411
+ const installCodeMirror = (app)=>{
412
+ app.component('CodeMirror', CodeMirror);
413
+ };
414
+ export default CodeMirror;
415
+ export { Meta, installCodeMirror as install };
416
+
417
+ //# sourceMappingURL=index.es.js.map