vue-codemirror6 1.1.15 → 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 CHANGED
@@ -4,11 +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.15](https://github.com/logue/vue-codemirror6/compare/1.1.13...1.1.15)
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)
10
11
  - Partially fixed the problem that the values defined in props disappeared under certain conditions. [`1cc4468`](https://github.com/logue/vue-codemirror6/commit/1cc4468e35e39ee8eaae1b2f007e3425a757217f)
11
- - Update CHANGELOG.md. [`f313ddc`](https://github.com/logue/vue-codemirror6/commit/f313ddc4d5e622b8ae4b52842178bb88149ec99c)
12
12
 
13
13
  #### [1.1.13](https://github.com/logue/vue-codemirror6/compare/1.1.12...1.1.13)
14
14
 
@@ -24,7 +24,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
24
24
 
25
25
  - chore(CODEOWNERS): CODEOWNERS.com Bot, at your service! [`#14`](https://github.com/logue/vue-codemirror6/pull/14)
26
26
  - Update demo code. (Replaced @codemirror/html to @codemirror/vue.) [`8da1a8a`](https://github.com/logue/vue-codemirror6/commit/8da1a8a4e37d713cc78281ce9c304c42a06940dc)
27
- - Changed implementation to generate \*.d.ts with vite-plugin-dts. [`1caaa20`](https://github.com/logue/vue-codemirror6/commit/1caaa20b1423a3d252a6c770a630fb60e2e3440d)
27
+ - Changed implementation to generate *.d.ts with vite-plugin-dts. [`1caaa20`](https://github.com/logue/vue-codemirror6/commit/1caaa20b1423a3d252a6c770a630fb60e2e3440d)
28
28
  - Update README.md. [`f8dd493`](https://github.com/logue/vue-codemirror6/commit/f8dd4934a7b9cc089cd830473db5250d28b3389b)
29
29
 
30
30
  #### [1.1.11](https://github.com/logue/vue-codemirror6/compare/1.1.3...1.1.11)
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.15
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 == "function" ? defaultSlots() : 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-ignore
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 || 0,
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.extension : void 0,
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.
@@ -357,7 +359,7 @@ var CodeMirror = defineComponent({
357
359
  watch(focus, (isFocus) => context.emit("focus", isFocus));
358
360
  onMounted(async () => {
359
361
  let value = doc.value;
360
- if (editor.value && editor.value.childNodes[0]) {
362
+ if (editor.value?.childNodes[0]) {
361
363
  if (doc.value !== "") {
362
364
  console.warn(
363
365
  "[CodeMirror.vue] The <code-mirror> tag contains child elements that overwrite the `v-model` values."
@@ -386,10 +388,8 @@ var CodeMirror = defineComponent({
386
388
  });
387
389
  });
388
390
  onUnmounted(() => {
389
- if (view.value) {
390
- view.value.destroy();
391
- context.emit("destroy");
392
- }
391
+ view.value.destroy();
392
+ context.emit("destroy");
393
393
  });
394
394
  const lint = () => {
395
395
  if (props.linter) {
@@ -435,6 +435,7 @@ var CodeMirror = defineComponent({
435
435
  });
436
436
  context.expose({
437
437
  editor,
438
+ view,
438
439
  cursor,
439
440
  selection,
440
441
  state,
@@ -464,19 +465,19 @@ var CodeMirror = defineComponent({
464
465
  },
465
466
  render() {
466
467
  return h(
467
- // @ts-ignore
468
+ // @ts-expect-error
468
469
  this.$props.tag,
469
470
  {
470
471
  ref: "editor",
471
472
  class: "vue-codemirror"
472
473
  },
473
- // @ts-ignore
474
+ // @ts-expect-error
474
475
  this.$slots.default ? (
475
476
  // Hide original content
476
477
  h(
477
478
  "aside",
478
479
  { style: "display: none;", "aria-hidden": "true" },
479
- // @ts-ignore
480
+ // @ts-expect-error
480
481
  slot(this.$slots.default)
481
482
  )
482
483
  ) : void 0
@@ -485,8 +486,8 @@ var CodeMirror = defineComponent({
485
486
  });
486
487
 
487
488
  const meta = {
488
- version: "1.1.15",
489
- date: "2023-03-14T09:58:31.925Z"
489
+ version: "1.1.16",
490
+ date: "2023-03-18T00:54:23.388Z"
490
491
  };
491
492
 
492
493
  const installCodeMirror = (app) => app.component("CodeMirror", CodeMirror);
@@ -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.15
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 == "function" ? defaultSlots() : 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-ignore
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 || 0,
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.extension : void 0,
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.
@@ -352,7 +354,7 @@ var CodeMirror = (function (exports, vueDemi, lodash, codemirror, state, view, c
352
354
  vueDemi.watch(focus, (isFocus) => context.emit("focus", isFocus));
353
355
  vueDemi.onMounted(async () => {
354
356
  let value = doc.value;
355
- if (editor.value && editor.value.childNodes[0]) {
357
+ if (editor.value?.childNodes[0]) {
356
358
  if (doc.value !== "") {
357
359
  console.warn(
358
360
  "[CodeMirror.vue] The <code-mirror> tag contains child elements that overwrite the `v-model` values."
@@ -381,10 +383,8 @@ var CodeMirror = (function (exports, vueDemi, lodash, codemirror, state, view, c
381
383
  });
382
384
  });
383
385
  vueDemi.onUnmounted(() => {
384
- if (view$1.value) {
385
- view$1.value.destroy();
386
- context.emit("destroy");
387
- }
386
+ view$1.value.destroy();
387
+ context.emit("destroy");
388
388
  });
389
389
  const lint$1 = () => {
390
390
  if (props.linter) {
@@ -430,6 +430,7 @@ var CodeMirror = (function (exports, vueDemi, lodash, codemirror, state, view, c
430
430
  });
431
431
  context.expose({
432
432
  editor,
433
+ view: view$1,
433
434
  cursor,
434
435
  selection,
435
436
  state: state$1,
@@ -459,19 +460,19 @@ var CodeMirror = (function (exports, vueDemi, lodash, codemirror, state, view, c
459
460
  },
460
461
  render() {
461
462
  return h(
462
- // @ts-ignore
463
+ // @ts-expect-error
463
464
  this.$props.tag,
464
465
  {
465
466
  ref: "editor",
466
467
  class: "vue-codemirror"
467
468
  },
468
- // @ts-ignore
469
+ // @ts-expect-error
469
470
  this.$slots.default ? (
470
471
  // Hide original content
471
472
  h(
472
473
  "aside",
473
474
  { style: "display: none;", "aria-hidden": "true" },
474
- // @ts-ignore
475
+ // @ts-expect-error
475
476
  slot(this.$slots.default)
476
477
  )
477
478
  ) : void 0
@@ -480,8 +481,8 @@ var CodeMirror = (function (exports, vueDemi, lodash, codemirror, state, view, c
480
481
  });
481
482
 
482
483
  const meta = {
483
- version: "1.1.15",
484
- date: "2023-03-14T09:58:31.925Z"
484
+ version: "1.1.16",
485
+ date: "2023-03-18T00:54:23.388Z"
485
486
  };
486
487
 
487
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.15
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 == "function" ? defaultSlots() : 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-ignore
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 || 0,
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.extension : void 0,
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.
@@ -355,7 +357,7 @@
355
357
  vueDemi.watch(focus, (isFocus) => context.emit("focus", isFocus));
356
358
  vueDemi.onMounted(async () => {
357
359
  let value = doc.value;
358
- if (editor.value && editor.value.childNodes[0]) {
360
+ if (editor.value?.childNodes[0]) {
359
361
  if (doc.value !== "") {
360
362
  console.warn(
361
363
  "[CodeMirror.vue] The <code-mirror> tag contains child elements that overwrite the `v-model` values."
@@ -384,10 +386,8 @@
384
386
  });
385
387
  });
386
388
  vueDemi.onUnmounted(() => {
387
- if (view$1.value) {
388
- view$1.value.destroy();
389
- context.emit("destroy");
390
- }
389
+ view$1.value.destroy();
390
+ context.emit("destroy");
391
391
  });
392
392
  const lint$1 = () => {
393
393
  if (props.linter) {
@@ -433,6 +433,7 @@
433
433
  });
434
434
  context.expose({
435
435
  editor,
436
+ view: view$1,
436
437
  cursor,
437
438
  selection,
438
439
  state: state$1,
@@ -462,19 +463,19 @@
462
463
  },
463
464
  render() {
464
465
  return h(
465
- // @ts-ignore
466
+ // @ts-expect-error
466
467
  this.$props.tag,
467
468
  {
468
469
  ref: "editor",
469
470
  class: "vue-codemirror"
470
471
  },
471
- // @ts-ignore
472
+ // @ts-expect-error
472
473
  this.$slots.default ? (
473
474
  // Hide original content
474
475
  h(
475
476
  "aside",
476
477
  { style: "display: none;", "aria-hidden": "true" },
477
- // @ts-ignore
478
+ // @ts-expect-error
478
479
  slot(this.$slots.default)
479
480
  )
480
481
  ) : void 0
@@ -483,8 +484,8 @@
483
484
  });
484
485
 
485
486
  const meta = {
486
- version: "1.1.15",
487
- date: "2023-03-14T09:58:31.925Z"
487
+ version: "1.1.16",
488
+ date: "2023-03-18T00:54:23.388Z"
488
489
  };
489
490
 
490
491
  const installCodeMirror = (app) => app.component("CodeMirror", CodeMirror);
@@ -1,4 +1,4 @@
1
1
  import CodeMirror from './components/CodeMirror';
2
2
  import Meta from './Meta';
3
- declare const installCodeMirror: (app: any) => any;
3
+ declare const installCodeMirror: (app: any) => void;
4
4
  export { CodeMirror as default, installCodeMirror as install, Meta };
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.15",
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.4.1",
59
+ "packageManager": "yarn@3.5.0",
60
60
  "sideEffects": false,
61
61
  "scripts": {
62
62
  "dev": "vite",
@@ -89,22 +89,21 @@
89
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.0.0",
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-google": "^0.14.0",
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-jsdoc": "^40.0.2",
105
- "eslint-plugin-prettier": "^4.2.1",
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": "^9.9.0",
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.2",
115
+ "sass": "^1.59.3",
117
116
  "typescript": "^4.9.5",
118
- "vite": "^4.1.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<{ [selector: string]: StyleSpec }>,
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-ignore
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 || 0,
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 ? EditorState.tabSize.of(props.tabSize) : undefined,
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.extension : undefined,
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.
@@ -435,7 +444,7 @@ export default defineComponent({
435
444
  onMounted(async () => {
436
445
  /** Initial value */
437
446
  let value: string | Text = doc.value;
438
- if (editor.value && editor.value.childNodes[0]) {
447
+ if (editor.value?.childNodes[0]) {
439
448
  // when slot mode, overwrite initial value
440
449
  if (doc.value !== '') {
441
450
  console.warn(
@@ -456,6 +465,7 @@ export default defineComponent({
456
465
  // console.log(view.state.doc.toString(), tr);
457
466
  if (tr.changes.empty) return;
458
467
  // child-to-parent binding
468
+ // eslint-disable-next-line @typescript-eslint/no-base-to-string
459
469
  const v = view.value.state.doc.toString();
460
470
  context.emit('update:modelValue', v);
461
471
  context.emit('change', view.value.state);
@@ -464,7 +474,7 @@ export default defineComponent({
464
474
 
465
475
  await nextTick();
466
476
  context.emit('ready', {
467
- view: view,
477
+ view,
468
478
  state: view.value.state,
469
479
  container: editor.value,
470
480
  });
@@ -472,10 +482,8 @@ export default defineComponent({
472
482
 
473
483
  /** Destroy */
474
484
  onUnmounted(() => {
475
- if (view.value) {
476
- view.value.destroy();
477
- context.emit('destroy');
478
- }
485
+ view.value.destroy();
486
+ context.emit('destroy');
479
487
  });
480
488
 
481
489
  /**
@@ -483,7 +491,7 @@ export default defineComponent({
483
491
  *
484
492
  * @see {@link https://codemirror.net/docs/ref/#lint.forceLinting}
485
493
  */
486
- const lint = () => {
494
+ const lint = (): void => {
487
495
  if (props.linter) {
488
496
  forceLinting(view.value);
489
497
  }
@@ -494,7 +502,7 @@ export default defineComponent({
494
502
  *
495
503
  * @see {@link https://codemirror.net/examples/config/#top-level-reconfiguration}
496
504
  */
497
- const forceReconfigure = () => {
505
+ const forceReconfigure = (): void => {
498
506
  // Deconfigure all Extensions
499
507
  view.value.dispatch({
500
508
  effects: StateEffect.reconfigure.of([]),
@@ -560,7 +568,7 @@ export default defineComponent({
560
568
  replacement: string | Text,
561
569
  from: number,
562
570
  to: number
563
- ) =>
571
+ ): void =>
564
572
  view.value.dispatch({
565
573
  changes: { from, to, insert: replacement },
566
574
  });
@@ -570,7 +578,7 @@ export default defineComponent({
570
578
  *
571
579
  * @param replacement - replacement text
572
580
  */
573
- const replaceSelection = (replacement: string | Text) =>
581
+ const replaceSelection = (replacement: string | Text): void =>
574
582
  view.value.dispatch(view.value.state.replaceSelection(replacement));
575
583
  /**
576
584
  * Set the cursor position.
@@ -584,7 +592,7 @@ export default defineComponent({
584
592
  * @param anchor - anchor position
585
593
  * @param head -
586
594
  */
587
- const setSelection = (anchor: number, head?: number) =>
595
+ const setSelection = (anchor: number, head?: number): void =>
588
596
  view.value.dispatch({ selection: { anchor, head } });
589
597
  /**
590
598
  * Sets a new set of selections. There must be at least one selection in the given array.
@@ -595,7 +603,7 @@ export default defineComponent({
595
603
  const setSelections = (
596
604
  ranges: readonly SelectionRange[],
597
605
  primary?: number
598
- ) =>
606
+ ): void =>
599
607
  view.value.dispatch({
600
608
  selection: EditorSelection.create(ranges, primary),
601
609
  });
@@ -604,7 +612,7 @@ export default defineComponent({
604
612
  *
605
613
  * @param f - function
606
614
  */
607
- const extendSelectionsBy = (f: Function) =>
615
+ const extendSelectionsBy = (f: any): void =>
608
616
  view.value.dispatch({
609
617
  selection: EditorSelection.create(
610
618
  selection.value.ranges.map((r: SelectionRange) => r.extend(f(r)))
@@ -614,6 +622,7 @@ export default defineComponent({
614
622
  /** Export properties and functions */
615
623
  context.expose({
616
624
  editor,
625
+ view,
617
626
  cursor,
618
627
  selection,
619
628
  state,
@@ -649,19 +658,19 @@ export default defineComponent({
649
658
  // </div>
650
659
  // </template>
651
660
  return h(
652
- // @ts-ignore
661
+ // @ts-expect-error
653
662
  this.$props.tag,
654
663
  {
655
664
  ref: 'editor',
656
665
  class: 'vue-codemirror',
657
666
  },
658
- // @ts-ignore
667
+ // @ts-expect-error
659
668
  this.$slots.default
660
669
  ? // Hide original content
661
670
  h(
662
671
  'aside',
663
672
  { style: 'display: none;', 'aria-hidden': 'true' },
664
- // @ts-ignore
673
+ // @ts-expect-error
665
674
  slot(this.$slots.default)
666
675
  )
667
676
  : undefined