vue-codemirror6 1.1.14 → 1.1.16
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/CHANGELOG.md +3 -1
- package/dist/index.es.js +21 -22
- package/dist/index.iife.js +20 -21
- package/dist/index.umd.js +20 -21
- package/dist/src/index.d.ts +1 -1
- package/package.json +10 -11
- package/src/components/CodeMirror.ts +33 -26
package/CHANGELOG.md
CHANGED
|
@@ -4,9 +4,11 @@ All notable changes to this project will be documented in this file. Dates are d
|
|
|
4
4
|
|
|
5
5
|
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
6
6
|
|
|
7
|
-
#### [1.1.
|
|
7
|
+
#### [1.1.16](https://github.com/logue/vue-codemirror6/compare/1.1.13...1.1.16)
|
|
8
8
|
|
|
9
|
+
- Expose `view`. #16 [`daf3e6b`](https://github.com/logue/vue-codemirror6/commit/daf3e6b17a161a5c0c5a35ea2442d85421f05d82)
|
|
9
10
|
- Fixed Maximum call stack size exceeded error. [`f10eaae`](https://github.com/logue/vue-codemirror6/commit/f10eaaea9145bc1d7a6605ab3cb8a82c0ca12df6)
|
|
11
|
+
- Partially fixed the problem that the values defined in props disappeared under certain conditions. [`1cc4468`](https://github.com/logue/vue-codemirror6/commit/1cc4468e35e39ee8eaae1b2f007e3425a757217f)
|
|
10
12
|
|
|
11
13
|
#### [1.1.13](https://github.com/logue/vue-codemirror6/compare/1.1.12...1.1.13)
|
|
12
14
|
|
package/dist/index.es.js
CHANGED
|
@@ -5,14 +5,14 @@
|
|
|
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.1.
|
|
8
|
+
* @version 1.1.16
|
|
9
9
|
* @see {@link https://github.com/logue/vue-codemirror6}
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
import { isVue2, h as h$1, defineComponent, ref, shallowRef, computed, watch, onMounted, nextTick, onUnmounted } from 'vue-demi';
|
|
13
13
|
import { compact, trim } from 'lodash';
|
|
14
14
|
import { basicSetup, minimalSetup } from 'codemirror';
|
|
15
|
-
import { EditorState, StateEffect, EditorSelection } from '@codemirror/state';
|
|
15
|
+
import { Compartment, EditorState, StateEffect, EditorSelection } from '@codemirror/state';
|
|
16
16
|
import { EditorView, keymap, placeholder } from '@codemirror/view';
|
|
17
17
|
import { indentWithTab } from '@codemirror/commands';
|
|
18
18
|
import { linter, lintGutter, forceLinting } from '@codemirror/lint';
|
|
@@ -38,7 +38,7 @@ function h(type, options = {}, chidren) {
|
|
|
38
38
|
chidren
|
|
39
39
|
);
|
|
40
40
|
}
|
|
41
|
-
const slot = (defaultSlots) => typeof defaultSlots
|
|
41
|
+
const slot = (defaultSlots) => typeof defaultSlots === "function" ? defaultSlots() : defaultSlots;
|
|
42
42
|
|
|
43
43
|
var CodeMirror = defineComponent({
|
|
44
44
|
/** Component Name */
|
|
@@ -258,7 +258,7 @@ var CodeMirror = defineComponent({
|
|
|
258
258
|
* @param props - Props
|
|
259
259
|
* @param context - Context
|
|
260
260
|
*/
|
|
261
|
-
// @ts-
|
|
261
|
+
// @ts-expect-error
|
|
262
262
|
setup(props, context) {
|
|
263
263
|
const editor = ref();
|
|
264
264
|
const doc = ref(props.modelValue);
|
|
@@ -272,7 +272,7 @@ var CodeMirror = defineComponent({
|
|
|
272
272
|
set: (s) => view.value.setState(s)
|
|
273
273
|
});
|
|
274
274
|
const cursor = computed({
|
|
275
|
-
get: () => view.value.state.selection.main.head
|
|
275
|
+
get: () => view.value.state.selection.main.head,
|
|
276
276
|
set: (a) => view.value.dispatch({ selection: { anchor: a } })
|
|
277
277
|
});
|
|
278
278
|
const focus = computed({
|
|
@@ -286,6 +286,8 @@ var CodeMirror = defineComponent({
|
|
|
286
286
|
const length = computed(
|
|
287
287
|
() => view.value.state.doc.length
|
|
288
288
|
);
|
|
289
|
+
const language = new Compartment();
|
|
290
|
+
const tabSize = new Compartment();
|
|
289
291
|
const extensions = computed(
|
|
290
292
|
() => (
|
|
291
293
|
// TODO: Ignore previous prop was not changed.
|
|
@@ -307,7 +309,7 @@ var CodeMirror = defineComponent({
|
|
|
307
309
|
// Allow Multiple Selections
|
|
308
310
|
EditorState.allowMultipleSelections.of(props.allowMultipleSelections),
|
|
309
311
|
// Indent tab size
|
|
310
|
-
props.tabSize ? EditorState.tabSize.of(props.tabSize) : void 0,
|
|
312
|
+
props.tabSize ? tabSize.of(EditorState.tabSize.of(props.tabSize)) : void 0,
|
|
311
313
|
// locale settings
|
|
312
314
|
props.phrases ? EditorState.phrases.of(props.phrases) : void 0,
|
|
313
315
|
// Readonly option
|
|
@@ -317,7 +319,7 @@ var CodeMirror = defineComponent({
|
|
|
317
319
|
// Set Line break char
|
|
318
320
|
props.lineSeparator ? EditorState.lineSeparator.of(props.lineSeparator) : void 0,
|
|
319
321
|
// Lang
|
|
320
|
-
props.lang ? props.lang
|
|
322
|
+
props.lang ? language.of(props.lang) : void 0,
|
|
321
323
|
// Append Linter settings
|
|
322
324
|
props.linter ? linter(props.linter, props.linterConfig) : void 0,
|
|
323
325
|
// Show 🔴 to error line when linter enabled.
|
|
@@ -349,17 +351,15 @@ var CodeMirror = defineComponent({
|
|
|
349
351
|
watch(
|
|
350
352
|
() => extensions.value,
|
|
351
353
|
(exts) => {
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
})
|
|
356
|
-
);
|
|
354
|
+
view.value.dispatch({
|
|
355
|
+
effects: StateEffect.reconfigure.of(exts)
|
|
356
|
+
});
|
|
357
357
|
}
|
|
358
358
|
);
|
|
359
359
|
watch(focus, (isFocus) => context.emit("focus", isFocus));
|
|
360
360
|
onMounted(async () => {
|
|
361
361
|
let value = doc.value;
|
|
362
|
-
if (editor.value
|
|
362
|
+
if (editor.value?.childNodes[0]) {
|
|
363
363
|
if (doc.value !== "") {
|
|
364
364
|
console.warn(
|
|
365
365
|
"[CodeMirror.vue] The <code-mirror> tag contains child elements that overwrite the `v-model` values."
|
|
@@ -388,10 +388,8 @@ var CodeMirror = defineComponent({
|
|
|
388
388
|
});
|
|
389
389
|
});
|
|
390
390
|
onUnmounted(() => {
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
context.emit("destroy");
|
|
394
|
-
}
|
|
391
|
+
view.value.destroy();
|
|
392
|
+
context.emit("destroy");
|
|
395
393
|
});
|
|
396
394
|
const lint = () => {
|
|
397
395
|
if (props.linter) {
|
|
@@ -437,6 +435,7 @@ var CodeMirror = defineComponent({
|
|
|
437
435
|
});
|
|
438
436
|
context.expose({
|
|
439
437
|
editor,
|
|
438
|
+
view,
|
|
440
439
|
cursor,
|
|
441
440
|
selection,
|
|
442
441
|
state,
|
|
@@ -466,19 +465,19 @@ var CodeMirror = defineComponent({
|
|
|
466
465
|
},
|
|
467
466
|
render() {
|
|
468
467
|
return h(
|
|
469
|
-
// @ts-
|
|
468
|
+
// @ts-expect-error
|
|
470
469
|
this.$props.tag,
|
|
471
470
|
{
|
|
472
471
|
ref: "editor",
|
|
473
472
|
class: "vue-codemirror"
|
|
474
473
|
},
|
|
475
|
-
// @ts-
|
|
474
|
+
// @ts-expect-error
|
|
476
475
|
this.$slots.default ? (
|
|
477
476
|
// Hide original content
|
|
478
477
|
h(
|
|
479
478
|
"aside",
|
|
480
479
|
{ style: "display: none;", "aria-hidden": "true" },
|
|
481
|
-
// @ts-
|
|
480
|
+
// @ts-expect-error
|
|
482
481
|
slot(this.$slots.default)
|
|
483
482
|
)
|
|
484
483
|
) : void 0
|
|
@@ -487,8 +486,8 @@ var CodeMirror = defineComponent({
|
|
|
487
486
|
});
|
|
488
487
|
|
|
489
488
|
const meta = {
|
|
490
|
-
version: "1.1.
|
|
491
|
-
date: "2023-03-
|
|
489
|
+
version: "1.1.16",
|
|
490
|
+
date: "2023-03-18T00:54:23.388Z"
|
|
492
491
|
};
|
|
493
492
|
|
|
494
493
|
const installCodeMirror = (app) => app.component("CodeMirror", CodeMirror);
|
package/dist/index.iife.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
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.1.
|
|
8
|
+
* @version 1.1.16
|
|
9
9
|
* @see {@link https://github.com/logue/vue-codemirror6}
|
|
10
10
|
*/
|
|
11
11
|
|
|
@@ -33,7 +33,7 @@ var CodeMirror = (function (exports, vueDemi, lodash, codemirror, state, view, c
|
|
|
33
33
|
chidren
|
|
34
34
|
);
|
|
35
35
|
}
|
|
36
|
-
const slot = (defaultSlots) => typeof defaultSlots
|
|
36
|
+
const slot = (defaultSlots) => typeof defaultSlots === "function" ? defaultSlots() : defaultSlots;
|
|
37
37
|
|
|
38
38
|
var CodeMirror = vueDemi.defineComponent({
|
|
39
39
|
/** Component Name */
|
|
@@ -253,7 +253,7 @@ var CodeMirror = (function (exports, vueDemi, lodash, codemirror, state, view, c
|
|
|
253
253
|
* @param props - Props
|
|
254
254
|
* @param context - Context
|
|
255
255
|
*/
|
|
256
|
-
// @ts-
|
|
256
|
+
// @ts-expect-error
|
|
257
257
|
setup(props, context) {
|
|
258
258
|
const editor = vueDemi.ref();
|
|
259
259
|
const doc = vueDemi.ref(props.modelValue);
|
|
@@ -267,7 +267,7 @@ var CodeMirror = (function (exports, vueDemi, lodash, codemirror, state, view, c
|
|
|
267
267
|
set: (s) => view$1.value.setState(s)
|
|
268
268
|
});
|
|
269
269
|
const cursor = vueDemi.computed({
|
|
270
|
-
get: () => view$1.value.state.selection.main.head
|
|
270
|
+
get: () => view$1.value.state.selection.main.head,
|
|
271
271
|
set: (a) => view$1.value.dispatch({ selection: { anchor: a } })
|
|
272
272
|
});
|
|
273
273
|
const focus = vueDemi.computed({
|
|
@@ -281,6 +281,8 @@ var CodeMirror = (function (exports, vueDemi, lodash, codemirror, state, view, c
|
|
|
281
281
|
const length = vueDemi.computed(
|
|
282
282
|
() => view$1.value.state.doc.length
|
|
283
283
|
);
|
|
284
|
+
const language = new state.Compartment();
|
|
285
|
+
const tabSize = new state.Compartment();
|
|
284
286
|
const extensions = vueDemi.computed(
|
|
285
287
|
() => (
|
|
286
288
|
// TODO: Ignore previous prop was not changed.
|
|
@@ -302,7 +304,7 @@ var CodeMirror = (function (exports, vueDemi, lodash, codemirror, state, view, c
|
|
|
302
304
|
// Allow Multiple Selections
|
|
303
305
|
state.EditorState.allowMultipleSelections.of(props.allowMultipleSelections),
|
|
304
306
|
// Indent tab size
|
|
305
|
-
props.tabSize ? state.EditorState.tabSize.of(props.tabSize) : void 0,
|
|
307
|
+
props.tabSize ? tabSize.of(state.EditorState.tabSize.of(props.tabSize)) : void 0,
|
|
306
308
|
// locale settings
|
|
307
309
|
props.phrases ? state.EditorState.phrases.of(props.phrases) : void 0,
|
|
308
310
|
// Readonly option
|
|
@@ -312,7 +314,7 @@ var CodeMirror = (function (exports, vueDemi, lodash, codemirror, state, view, c
|
|
|
312
314
|
// Set Line break char
|
|
313
315
|
props.lineSeparator ? state.EditorState.lineSeparator.of(props.lineSeparator) : void 0,
|
|
314
316
|
// Lang
|
|
315
|
-
props.lang ? props.lang
|
|
317
|
+
props.lang ? language.of(props.lang) : void 0,
|
|
316
318
|
// Append Linter settings
|
|
317
319
|
props.linter ? lint.linter(props.linter, props.linterConfig) : void 0,
|
|
318
320
|
// Show 🔴 to error line when linter enabled.
|
|
@@ -344,17 +346,15 @@ var CodeMirror = (function (exports, vueDemi, lodash, codemirror, state, view, c
|
|
|
344
346
|
vueDemi.watch(
|
|
345
347
|
() => extensions.value,
|
|
346
348
|
(exts) => {
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
})
|
|
351
|
-
);
|
|
349
|
+
view$1.value.dispatch({
|
|
350
|
+
effects: state.StateEffect.reconfigure.of(exts)
|
|
351
|
+
});
|
|
352
352
|
}
|
|
353
353
|
);
|
|
354
354
|
vueDemi.watch(focus, (isFocus) => context.emit("focus", isFocus));
|
|
355
355
|
vueDemi.onMounted(async () => {
|
|
356
356
|
let value = doc.value;
|
|
357
|
-
if (editor.value
|
|
357
|
+
if (editor.value?.childNodes[0]) {
|
|
358
358
|
if (doc.value !== "") {
|
|
359
359
|
console.warn(
|
|
360
360
|
"[CodeMirror.vue] The <code-mirror> tag contains child elements that overwrite the `v-model` values."
|
|
@@ -383,10 +383,8 @@ var CodeMirror = (function (exports, vueDemi, lodash, codemirror, state, view, c
|
|
|
383
383
|
});
|
|
384
384
|
});
|
|
385
385
|
vueDemi.onUnmounted(() => {
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
context.emit("destroy");
|
|
389
|
-
}
|
|
386
|
+
view$1.value.destroy();
|
|
387
|
+
context.emit("destroy");
|
|
390
388
|
});
|
|
391
389
|
const lint$1 = () => {
|
|
392
390
|
if (props.linter) {
|
|
@@ -432,6 +430,7 @@ var CodeMirror = (function (exports, vueDemi, lodash, codemirror, state, view, c
|
|
|
432
430
|
});
|
|
433
431
|
context.expose({
|
|
434
432
|
editor,
|
|
433
|
+
view: view$1,
|
|
435
434
|
cursor,
|
|
436
435
|
selection,
|
|
437
436
|
state: state$1,
|
|
@@ -461,19 +460,19 @@ var CodeMirror = (function (exports, vueDemi, lodash, codemirror, state, view, c
|
|
|
461
460
|
},
|
|
462
461
|
render() {
|
|
463
462
|
return h(
|
|
464
|
-
// @ts-
|
|
463
|
+
// @ts-expect-error
|
|
465
464
|
this.$props.tag,
|
|
466
465
|
{
|
|
467
466
|
ref: "editor",
|
|
468
467
|
class: "vue-codemirror"
|
|
469
468
|
},
|
|
470
|
-
// @ts-
|
|
469
|
+
// @ts-expect-error
|
|
471
470
|
this.$slots.default ? (
|
|
472
471
|
// Hide original content
|
|
473
472
|
h(
|
|
474
473
|
"aside",
|
|
475
474
|
{ style: "display: none;", "aria-hidden": "true" },
|
|
476
|
-
// @ts-
|
|
475
|
+
// @ts-expect-error
|
|
477
476
|
slot(this.$slots.default)
|
|
478
477
|
)
|
|
479
478
|
) : void 0
|
|
@@ -482,8 +481,8 @@ var CodeMirror = (function (exports, vueDemi, lodash, codemirror, state, view, c
|
|
|
482
481
|
});
|
|
483
482
|
|
|
484
483
|
const meta = {
|
|
485
|
-
version: "1.1.
|
|
486
|
-
date: "2023-03-
|
|
484
|
+
version: "1.1.16",
|
|
485
|
+
date: "2023-03-18T00:54:23.388Z"
|
|
487
486
|
};
|
|
488
487
|
|
|
489
488
|
const installCodeMirror = (app) => app.component("CodeMirror", CodeMirror);
|
package/dist/index.umd.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
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.1.
|
|
8
|
+
* @version 1.1.16
|
|
9
9
|
* @see {@link https://github.com/logue/vue-codemirror6}
|
|
10
10
|
*/
|
|
11
11
|
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
chidren
|
|
37
37
|
);
|
|
38
38
|
}
|
|
39
|
-
const slot = (defaultSlots) => typeof defaultSlots
|
|
39
|
+
const slot = (defaultSlots) => typeof defaultSlots === "function" ? defaultSlots() : defaultSlots;
|
|
40
40
|
|
|
41
41
|
var CodeMirror = vueDemi.defineComponent({
|
|
42
42
|
/** Component Name */
|
|
@@ -256,7 +256,7 @@
|
|
|
256
256
|
* @param props - Props
|
|
257
257
|
* @param context - Context
|
|
258
258
|
*/
|
|
259
|
-
// @ts-
|
|
259
|
+
// @ts-expect-error
|
|
260
260
|
setup(props, context) {
|
|
261
261
|
const editor = vueDemi.ref();
|
|
262
262
|
const doc = vueDemi.ref(props.modelValue);
|
|
@@ -270,7 +270,7 @@
|
|
|
270
270
|
set: (s) => view$1.value.setState(s)
|
|
271
271
|
});
|
|
272
272
|
const cursor = vueDemi.computed({
|
|
273
|
-
get: () => view$1.value.state.selection.main.head
|
|
273
|
+
get: () => view$1.value.state.selection.main.head,
|
|
274
274
|
set: (a) => view$1.value.dispatch({ selection: { anchor: a } })
|
|
275
275
|
});
|
|
276
276
|
const focus = vueDemi.computed({
|
|
@@ -284,6 +284,8 @@
|
|
|
284
284
|
const length = vueDemi.computed(
|
|
285
285
|
() => view$1.value.state.doc.length
|
|
286
286
|
);
|
|
287
|
+
const language = new state.Compartment();
|
|
288
|
+
const tabSize = new state.Compartment();
|
|
287
289
|
const extensions = vueDemi.computed(
|
|
288
290
|
() => (
|
|
289
291
|
// TODO: Ignore previous prop was not changed.
|
|
@@ -305,7 +307,7 @@
|
|
|
305
307
|
// Allow Multiple Selections
|
|
306
308
|
state.EditorState.allowMultipleSelections.of(props.allowMultipleSelections),
|
|
307
309
|
// Indent tab size
|
|
308
|
-
props.tabSize ? state.EditorState.tabSize.of(props.tabSize) : void 0,
|
|
310
|
+
props.tabSize ? tabSize.of(state.EditorState.tabSize.of(props.tabSize)) : void 0,
|
|
309
311
|
// locale settings
|
|
310
312
|
props.phrases ? state.EditorState.phrases.of(props.phrases) : void 0,
|
|
311
313
|
// Readonly option
|
|
@@ -315,7 +317,7 @@
|
|
|
315
317
|
// Set Line break char
|
|
316
318
|
props.lineSeparator ? state.EditorState.lineSeparator.of(props.lineSeparator) : void 0,
|
|
317
319
|
// Lang
|
|
318
|
-
props.lang ? props.lang
|
|
320
|
+
props.lang ? language.of(props.lang) : void 0,
|
|
319
321
|
// Append Linter settings
|
|
320
322
|
props.linter ? lint.linter(props.linter, props.linterConfig) : void 0,
|
|
321
323
|
// Show 🔴 to error line when linter enabled.
|
|
@@ -347,17 +349,15 @@
|
|
|
347
349
|
vueDemi.watch(
|
|
348
350
|
() => extensions.value,
|
|
349
351
|
(exts) => {
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
})
|
|
354
|
-
);
|
|
352
|
+
view$1.value.dispatch({
|
|
353
|
+
effects: state.StateEffect.reconfigure.of(exts)
|
|
354
|
+
});
|
|
355
355
|
}
|
|
356
356
|
);
|
|
357
357
|
vueDemi.watch(focus, (isFocus) => context.emit("focus", isFocus));
|
|
358
358
|
vueDemi.onMounted(async () => {
|
|
359
359
|
let value = doc.value;
|
|
360
|
-
if (editor.value
|
|
360
|
+
if (editor.value?.childNodes[0]) {
|
|
361
361
|
if (doc.value !== "") {
|
|
362
362
|
console.warn(
|
|
363
363
|
"[CodeMirror.vue] The <code-mirror> tag contains child elements that overwrite the `v-model` values."
|
|
@@ -386,10 +386,8 @@
|
|
|
386
386
|
});
|
|
387
387
|
});
|
|
388
388
|
vueDemi.onUnmounted(() => {
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
context.emit("destroy");
|
|
392
|
-
}
|
|
389
|
+
view$1.value.destroy();
|
|
390
|
+
context.emit("destroy");
|
|
393
391
|
});
|
|
394
392
|
const lint$1 = () => {
|
|
395
393
|
if (props.linter) {
|
|
@@ -435,6 +433,7 @@
|
|
|
435
433
|
});
|
|
436
434
|
context.expose({
|
|
437
435
|
editor,
|
|
436
|
+
view: view$1,
|
|
438
437
|
cursor,
|
|
439
438
|
selection,
|
|
440
439
|
state: state$1,
|
|
@@ -464,19 +463,19 @@
|
|
|
464
463
|
},
|
|
465
464
|
render() {
|
|
466
465
|
return h(
|
|
467
|
-
// @ts-
|
|
466
|
+
// @ts-expect-error
|
|
468
467
|
this.$props.tag,
|
|
469
468
|
{
|
|
470
469
|
ref: "editor",
|
|
471
470
|
class: "vue-codemirror"
|
|
472
471
|
},
|
|
473
|
-
// @ts-
|
|
472
|
+
// @ts-expect-error
|
|
474
473
|
this.$slots.default ? (
|
|
475
474
|
// Hide original content
|
|
476
475
|
h(
|
|
477
476
|
"aside",
|
|
478
477
|
{ style: "display: none;", "aria-hidden": "true" },
|
|
479
|
-
// @ts-
|
|
478
|
+
// @ts-expect-error
|
|
480
479
|
slot(this.$slots.default)
|
|
481
480
|
)
|
|
482
481
|
) : void 0
|
|
@@ -485,8 +484,8 @@
|
|
|
485
484
|
});
|
|
486
485
|
|
|
487
486
|
const meta = {
|
|
488
|
-
version: "1.1.
|
|
489
|
-
date: "2023-03-
|
|
487
|
+
version: "1.1.16",
|
|
488
|
+
date: "2023-03-18T00:54:23.388Z"
|
|
490
489
|
};
|
|
491
490
|
|
|
492
491
|
const installCodeMirror = (app) => app.component("CodeMirror", CodeMirror);
|
package/dist/src/index.d.ts
CHANGED
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": "1.1.
|
|
4
|
+
"version": "1.1.16",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "CodeMirror6 Component for vue2 and vue3.",
|
|
7
7
|
"keywords": [
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"node": ">=18.15.0",
|
|
57
57
|
"yarn": ">=1.22.19"
|
|
58
58
|
},
|
|
59
|
-
"packageManager": "yarn@3.
|
|
59
|
+
"packageManager": "yarn@3.5.0",
|
|
60
60
|
"sideEffects": false,
|
|
61
61
|
"scripts": {
|
|
62
62
|
"dev": "vite",
|
|
@@ -86,25 +86,24 @@
|
|
|
86
86
|
"@codemirror/lang-markdown": "^6.1.0",
|
|
87
87
|
"@codemirror/lang-vue": "^0.1.1",
|
|
88
88
|
"@types/lodash": "^4.14.191",
|
|
89
|
-
"@types/node": "^18.15.
|
|
89
|
+
"@types/node": "^18.15.3",
|
|
90
90
|
"@typescript-eslint/eslint-plugin": "^5.55.0",
|
|
91
91
|
"@typescript-eslint/parser": "^5.55.0",
|
|
92
|
-
"@vitejs/plugin-vue": "^4.
|
|
92
|
+
"@vitejs/plugin-vue": "^4.1.0",
|
|
93
93
|
"@vue/eslint-config-prettier": "^7.1.0",
|
|
94
94
|
"@vue/tsconfig": "^0.1.3",
|
|
95
95
|
"@vueuse/core": "^9.13.0",
|
|
96
96
|
"eslint": "^8.36.0",
|
|
97
|
-
"eslint-config-
|
|
98
|
-
"eslint-config-prettier": "^8.7.0",
|
|
97
|
+
"eslint-config-standard-with-typescript": "latest",
|
|
99
98
|
"eslint-import-resolver-alias": "^1.1.2",
|
|
100
99
|
"eslint-import-resolver-typescript": "^3.5.3",
|
|
101
100
|
"eslint-linter-browserify": "^8.36.0",
|
|
102
101
|
"eslint-plugin-html": "^7.1.0",
|
|
103
102
|
"eslint-plugin-import": "^2.27.5",
|
|
104
|
-
"eslint-plugin-
|
|
105
|
-
"eslint-plugin-
|
|
103
|
+
"eslint-plugin-n": "^15.6.1",
|
|
104
|
+
"eslint-plugin-promise": "^6.1.1",
|
|
106
105
|
"eslint-plugin-tsdoc": "^0.2.17",
|
|
107
|
-
"eslint-plugin-vue": "
|
|
106
|
+
"eslint-plugin-vue": "latest",
|
|
108
107
|
"eslint-plugin-vuejs-accessibility": "^2.1.0",
|
|
109
108
|
"eslint-plugin-yaml": "^0.5.0",
|
|
110
109
|
"husky": "^8.0.3",
|
|
@@ -113,9 +112,9 @@
|
|
|
113
112
|
"prettier": "^2.8.4",
|
|
114
113
|
"rimraf": "^4.4.0",
|
|
115
114
|
"rollup-plugin-visualizer": "^5.9.0",
|
|
116
|
-
"sass": "^1.59.
|
|
115
|
+
"sass": "^1.59.3",
|
|
117
116
|
"typescript": "^4.9.5",
|
|
118
|
-
"vite": "^4.
|
|
117
|
+
"vite": "^4.2.0",
|
|
119
118
|
"vite-plugin-banner": "^0.7.0",
|
|
120
119
|
"vite-plugin-checker": "^0.5.6",
|
|
121
120
|
"vite-plugin-dts": "^2.1.0",
|
|
@@ -23,6 +23,7 @@ import { compact, trim } from 'lodash';
|
|
|
23
23
|
// CodeMirror
|
|
24
24
|
import { basicSetup, minimalSetup } from 'codemirror';
|
|
25
25
|
import {
|
|
26
|
+
Compartment,
|
|
26
27
|
EditorSelection,
|
|
27
28
|
EditorState,
|
|
28
29
|
StateEffect,
|
|
@@ -91,7 +92,7 @@ export default defineComponent({
|
|
|
91
92
|
* @see {@link https://codemirror.net/docs/ref/#view.EditorView^theme}
|
|
92
93
|
*/
|
|
93
94
|
theme: {
|
|
94
|
-
type: Object as PropType<
|
|
95
|
+
type: Object as PropType<Record<string, StyleSpec>>,
|
|
95
96
|
default: () => {},
|
|
96
97
|
},
|
|
97
98
|
/** Dark Mode */
|
|
@@ -287,7 +288,7 @@ export default defineComponent({
|
|
|
287
288
|
* @param props - Props
|
|
288
289
|
* @param context - Context
|
|
289
290
|
*/
|
|
290
|
-
// @ts-
|
|
291
|
+
// @ts-expect-error
|
|
291
292
|
setup(props, context: SetupContext<CodeMirrorEmitsOptions>) {
|
|
292
293
|
/** Editor DOM */
|
|
293
294
|
const editor: Ref<HTMLElement | undefined> = ref();
|
|
@@ -324,7 +325,7 @@ export default defineComponent({
|
|
|
324
325
|
|
|
325
326
|
/** Cursor Position */
|
|
326
327
|
const cursor: WritableComputedRef<number> = computed({
|
|
327
|
-
get: () => view.value.state.selection.main.head
|
|
328
|
+
get: () => view.value.state.selection.main.head,
|
|
328
329
|
set: a => view.value.dispatch({ selection: { anchor: a } }),
|
|
329
330
|
});
|
|
330
331
|
|
|
@@ -347,6 +348,12 @@ export default defineComponent({
|
|
|
347
348
|
() => view.value.state.doc.length
|
|
348
349
|
);
|
|
349
350
|
|
|
351
|
+
// Synamic Reconfiguration
|
|
352
|
+
// @see https://codemirror.net/examples/config/
|
|
353
|
+
|
|
354
|
+
const language = new Compartment();
|
|
355
|
+
const tabSize = new Compartment();
|
|
356
|
+
|
|
350
357
|
/** Get CodeMirror Extension */
|
|
351
358
|
const extensions: ComputedRef<Extension[]> = computed(() =>
|
|
352
359
|
// TODO: Ignore previous prop was not changed.
|
|
@@ -368,7 +375,9 @@ export default defineComponent({
|
|
|
368
375
|
// Allow Multiple Selections
|
|
369
376
|
EditorState.allowMultipleSelections.of(props.allowMultipleSelections),
|
|
370
377
|
// Indent tab size
|
|
371
|
-
props.tabSize
|
|
378
|
+
props.tabSize
|
|
379
|
+
? tabSize.of(EditorState.tabSize.of(props.tabSize))
|
|
380
|
+
: undefined,
|
|
372
381
|
// locale settings
|
|
373
382
|
props.phrases ? EditorState.phrases.of(props.phrases) : undefined,
|
|
374
383
|
// Readonly option
|
|
@@ -380,7 +389,7 @@ export default defineComponent({
|
|
|
380
389
|
? EditorState.lineSeparator.of(props.lineSeparator)
|
|
381
390
|
: undefined,
|
|
382
391
|
// Lang
|
|
383
|
-
props.lang ? props.lang
|
|
392
|
+
props.lang ? language.of(props.lang) : undefined,
|
|
384
393
|
// Append Linter settings
|
|
385
394
|
props.linter ? linter(props.linter, props.linterConfig) : undefined,
|
|
386
395
|
// Show 🔴 to error line when linter enabled.
|
|
@@ -422,11 +431,9 @@ export default defineComponent({
|
|
|
422
431
|
watch(
|
|
423
432
|
() => extensions.value,
|
|
424
433
|
exts => {
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
})
|
|
429
|
-
);
|
|
434
|
+
view.value.dispatch({
|
|
435
|
+
effects: StateEffect.reconfigure.of(exts),
|
|
436
|
+
});
|
|
430
437
|
}
|
|
431
438
|
);
|
|
432
439
|
|
|
@@ -437,7 +444,7 @@ export default defineComponent({
|
|
|
437
444
|
onMounted(async () => {
|
|
438
445
|
/** Initial value */
|
|
439
446
|
let value: string | Text = doc.value;
|
|
440
|
-
if (editor.value
|
|
447
|
+
if (editor.value?.childNodes[0]) {
|
|
441
448
|
// when slot mode, overwrite initial value
|
|
442
449
|
if (doc.value !== '') {
|
|
443
450
|
console.warn(
|
|
@@ -458,6 +465,7 @@ export default defineComponent({
|
|
|
458
465
|
// console.log(view.state.doc.toString(), tr);
|
|
459
466
|
if (tr.changes.empty) return;
|
|
460
467
|
// child-to-parent binding
|
|
468
|
+
// eslint-disable-next-line @typescript-eslint/no-base-to-string
|
|
461
469
|
const v = view.value.state.doc.toString();
|
|
462
470
|
context.emit('update:modelValue', v);
|
|
463
471
|
context.emit('change', view.value.state);
|
|
@@ -466,7 +474,7 @@ export default defineComponent({
|
|
|
466
474
|
|
|
467
475
|
await nextTick();
|
|
468
476
|
context.emit('ready', {
|
|
469
|
-
view
|
|
477
|
+
view,
|
|
470
478
|
state: view.value.state,
|
|
471
479
|
container: editor.value,
|
|
472
480
|
});
|
|
@@ -474,10 +482,8 @@ export default defineComponent({
|
|
|
474
482
|
|
|
475
483
|
/** Destroy */
|
|
476
484
|
onUnmounted(() => {
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
context.emit('destroy');
|
|
480
|
-
}
|
|
485
|
+
view.value.destroy();
|
|
486
|
+
context.emit('destroy');
|
|
481
487
|
});
|
|
482
488
|
|
|
483
489
|
/**
|
|
@@ -485,7 +491,7 @@ export default defineComponent({
|
|
|
485
491
|
*
|
|
486
492
|
* @see {@link https://codemirror.net/docs/ref/#lint.forceLinting}
|
|
487
493
|
*/
|
|
488
|
-
const lint = () => {
|
|
494
|
+
const lint = (): void => {
|
|
489
495
|
if (props.linter) {
|
|
490
496
|
forceLinting(view.value);
|
|
491
497
|
}
|
|
@@ -496,7 +502,7 @@ export default defineComponent({
|
|
|
496
502
|
*
|
|
497
503
|
* @see {@link https://codemirror.net/examples/config/#top-level-reconfiguration}
|
|
498
504
|
*/
|
|
499
|
-
const forceReconfigure = () => {
|
|
505
|
+
const forceReconfigure = (): void => {
|
|
500
506
|
// Deconfigure all Extensions
|
|
501
507
|
view.value.dispatch({
|
|
502
508
|
effects: StateEffect.reconfigure.of([]),
|
|
@@ -562,7 +568,7 @@ export default defineComponent({
|
|
|
562
568
|
replacement: string | Text,
|
|
563
569
|
from: number,
|
|
564
570
|
to: number
|
|
565
|
-
) =>
|
|
571
|
+
): void =>
|
|
566
572
|
view.value.dispatch({
|
|
567
573
|
changes: { from, to, insert: replacement },
|
|
568
574
|
});
|
|
@@ -572,7 +578,7 @@ export default defineComponent({
|
|
|
572
578
|
*
|
|
573
579
|
* @param replacement - replacement text
|
|
574
580
|
*/
|
|
575
|
-
const replaceSelection = (replacement: string | Text) =>
|
|
581
|
+
const replaceSelection = (replacement: string | Text): void =>
|
|
576
582
|
view.value.dispatch(view.value.state.replaceSelection(replacement));
|
|
577
583
|
/**
|
|
578
584
|
* Set the cursor position.
|
|
@@ -586,7 +592,7 @@ export default defineComponent({
|
|
|
586
592
|
* @param anchor - anchor position
|
|
587
593
|
* @param head -
|
|
588
594
|
*/
|
|
589
|
-
const setSelection = (anchor: number, head?: number) =>
|
|
595
|
+
const setSelection = (anchor: number, head?: number): void =>
|
|
590
596
|
view.value.dispatch({ selection: { anchor, head } });
|
|
591
597
|
/**
|
|
592
598
|
* Sets a new set of selections. There must be at least one selection in the given array.
|
|
@@ -597,7 +603,7 @@ export default defineComponent({
|
|
|
597
603
|
const setSelections = (
|
|
598
604
|
ranges: readonly SelectionRange[],
|
|
599
605
|
primary?: number
|
|
600
|
-
) =>
|
|
606
|
+
): void =>
|
|
601
607
|
view.value.dispatch({
|
|
602
608
|
selection: EditorSelection.create(ranges, primary),
|
|
603
609
|
});
|
|
@@ -606,7 +612,7 @@ export default defineComponent({
|
|
|
606
612
|
*
|
|
607
613
|
* @param f - function
|
|
608
614
|
*/
|
|
609
|
-
const extendSelectionsBy = (f:
|
|
615
|
+
const extendSelectionsBy = (f: any): void =>
|
|
610
616
|
view.value.dispatch({
|
|
611
617
|
selection: EditorSelection.create(
|
|
612
618
|
selection.value.ranges.map((r: SelectionRange) => r.extend(f(r)))
|
|
@@ -616,6 +622,7 @@ export default defineComponent({
|
|
|
616
622
|
/** Export properties and functions */
|
|
617
623
|
context.expose({
|
|
618
624
|
editor,
|
|
625
|
+
view,
|
|
619
626
|
cursor,
|
|
620
627
|
selection,
|
|
621
628
|
state,
|
|
@@ -651,19 +658,19 @@ export default defineComponent({
|
|
|
651
658
|
// </div>
|
|
652
659
|
// </template>
|
|
653
660
|
return h(
|
|
654
|
-
// @ts-
|
|
661
|
+
// @ts-expect-error
|
|
655
662
|
this.$props.tag,
|
|
656
663
|
{
|
|
657
664
|
ref: 'editor',
|
|
658
665
|
class: 'vue-codemirror',
|
|
659
666
|
},
|
|
660
|
-
// @ts-
|
|
667
|
+
// @ts-expect-error
|
|
661
668
|
this.$slots.default
|
|
662
669
|
? // Hide original content
|
|
663
670
|
h(
|
|
664
671
|
'aside',
|
|
665
672
|
{ style: 'display: none;', 'aria-hidden': 'true' },
|
|
666
|
-
// @ts-
|
|
673
|
+
// @ts-expect-error
|
|
667
674
|
slot(this.$slots.default)
|
|
668
675
|
)
|
|
669
676
|
: undefined
|