vue-codemirror6 1.1.10 → 1.1.12

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.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.10
8
+ * @version 1.1.12
9
9
  * @see {@link https://github.com/logue/vue-codemirror6}
10
10
  */
11
11
 
@@ -24,8 +24,8 @@
24
24
  return { ...ret, [key]: handler };
25
25
  }, {});
26
26
  };
27
- const h = (type, options = {}, chidren) => {
28
- if (vueDemi.isVue2 && parseInt(vueDemi.Vue2.version) < 2.7) {
27
+ function h(type, options = {}, chidren) {
28
+ if (vueDemi.isVue2) {
29
29
  return vueDemi.h(type, options, chidren);
30
30
  }
31
31
  const { props, domProps, on, ...extraOptions } = options;
@@ -35,103 +35,219 @@
35
35
  { ...extraOptions, ...props, ...domProps, ...ons },
36
36
  chidren
37
37
  );
38
- };
38
+ }
39
39
  const slot = (defaultSlots) => typeof defaultSlots == "function" ? defaultSlots() : defaultSlots;
40
40
 
41
41
  var CodeMirror = vueDemi.defineComponent({
42
+ /** Component Name */
42
43
  name: "CodeMirror",
44
+ /** Model Definition */
43
45
  model: {
44
46
  prop: "modelValue",
45
47
  event: "update:modelValue"
46
48
  },
49
+ /** Props Definition */
47
50
  props: {
51
+ /** Model value */
48
52
  modelValue: {
49
53
  type: String,
50
54
  default: ""
51
55
  },
56
+ /**
57
+ * Theme
58
+ *
59
+ * @see {@link https://codemirror.net/docs/ref/#view.EditorView^theme}
60
+ */
52
61
  theme: {
53
62
  type: Object,
54
63
  default: () => {
55
64
  }
56
65
  },
66
+ /** Dark Mode */
57
67
  dark: {
58
68
  type: Boolean,
59
69
  default: false
60
70
  },
71
+ /**
72
+ * Use Basic Setup
73
+ *
74
+ * @see {@link https://codemirror.net/docs/ref/#codemirror.basicSetup}
75
+ */
61
76
  basic: {
62
77
  type: Boolean,
63
78
  default: false
64
79
  },
80
+ /**
81
+ * Use Minimal Setup (The basic setting has priority.)
82
+ *
83
+ * @see {@link https://codemirror.net/docs/ref/#codemirror.minimalSetup}
84
+ */
65
85
  minimal: {
66
86
  type: Boolean,
67
87
  default: false
68
88
  },
89
+ /**
90
+ * Placeholder
91
+ *
92
+ * @see {@link https://codemirror.net/docs/ref/#view.placeholder}
93
+ */
69
94
  placeholder: {
70
95
  type: String,
71
96
  default: void 0
72
97
  },
98
+ /**
99
+ * Line wrapping
100
+ *
101
+ * An extension that enables line wrapping in the editor (by setting CSS white-space to pre-wrap in the content).
102
+ *
103
+ * @see {@link https://codemirror.net/docs/ref/#view.EditorView%5ElineWrapping}
104
+ */
73
105
  wrap: {
74
106
  type: Boolean,
75
107
  default: false
76
108
  },
109
+ /**
110
+ * Allow tab key indent.
111
+ *
112
+ * @see {@link https://codemirror.net/examples/tab/}
113
+ */
77
114
  tab: {
78
115
  type: Boolean,
79
116
  default: false
80
117
  },
118
+ /**
119
+ * Tab size
120
+ *
121
+ * @see {@link https://codemirror.net/docs/ref/#state.EditorState^tabSize}
122
+ */
81
123
  tabSize: {
82
124
  type: Number,
83
125
  default: void 0
84
126
  },
127
+ /**
128
+ * Set line break (separetor) char.
129
+ *
130
+ * @see {@link https://codemirror.net/docs/ref/#state.EditorState^lineSeparator}
131
+ */
85
132
  lineSeparator: {
86
133
  type: String,
87
134
  default: void 0
88
135
  },
136
+ /**
137
+ * Readonly
138
+ *
139
+ * @see {@link https://codemirror.net/docs/ref/#state.EditorState^readOnly}
140
+ */
89
141
  readonly: {
90
142
  type: Boolean,
91
143
  default: false
92
144
  },
145
+ /**
146
+ * Disable input.
147
+ *
148
+ * This is the reversed value of the CodeMirror editable.
149
+ * Similar to `readonly`, but setting this value to true disables dragging.
150
+ *
151
+ * @see {@link https://codemirror.net/docs/ref/#view.EditorView^editable}
152
+ */
93
153
  disabled: {
94
154
  type: Boolean,
95
155
  default: false
96
156
  },
157
+ /**
158
+ * Additional Extension
159
+ *
160
+ * @see {@link https://codemirror.net/docs/ref/#state.Extension}
161
+ */
97
162
  extensions: {
98
163
  type: Array,
99
164
  default: () => {
100
165
  return [];
101
166
  }
102
167
  },
168
+ /**
169
+ * Language Phreses
170
+ *
171
+ * @see {@link https://codemirror.net/examples/translate/}
172
+ */
103
173
  phrases: {
104
174
  type: Object,
105
175
  default: () => void 0
106
176
  },
177
+ /**
178
+ * CodeMirror Language
179
+ *
180
+ * @see {@link https://codemirror.net/docs/ref/#language}
181
+ */
107
182
  lang: {
108
183
  type: Object,
109
184
  default: () => void 0
110
185
  },
186
+ /**
187
+ * CodeMirror Linter
188
+ *
189
+ * @see {@link https://codemirror.net/docs/ref/#lint.linter}
190
+ */
111
191
  linter: {
112
192
  type: Function,
113
193
  default: void 0
114
194
  },
195
+ /**
196
+ * Linter Config
197
+ *
198
+ * @see {@link https://codemirror.net/docs/ref/#lint.linter^config}
199
+ */
115
200
  linterConfig: {
116
201
  type: Object,
117
- default: () => {
118
- }
202
+ default: () => void 0
203
+ },
204
+ /**
205
+ * Forces any linters configured to run when the editor is idle to run right away.
206
+ *
207
+ * @see {@link https://codemirror.net/docs/ref/#lint.forceLinting}
208
+ */
209
+ forceLinting: {
210
+ type: Boolean,
211
+ default: false
119
212
  },
213
+ /**
214
+ * Show Linter Gutter
215
+ *
216
+ * An area to 🔴 the lines with errors will be displayed.
217
+ * This feature is not enabled if `linter` is not specified.
218
+ *
219
+ * @see {@link https://codemirror.net/docs/ref/#lint.lintGutter}
220
+ */
120
221
  gutter: {
121
222
  type: Boolean,
122
223
  defalt: false
123
224
  },
225
+ /**
226
+ * Gutter Config
227
+ *
228
+ * @see {@link https://codemirror.net/docs/ref/#lint.lintGutter^config}
229
+ */
124
230
  gutterConfig: {
125
231
  type: Object,
126
- default: () => {
127
- }
232
+ default: () => void 0
128
233
  },
234
+ /**
235
+ * Using tag
236
+ */
129
237
  tag: {
130
238
  type: String,
131
239
  default: "div"
132
240
  }
133
241
  },
242
+ /** Emits */
134
243
  emits: ["update:modelValue", "update", "ready", "focus", "change", "destroy"],
244
+ /**
245
+ * Setup
246
+ *
247
+ * @param props - Props
248
+ * @param context - Context
249
+ */
250
+ // @ts-ignore
135
251
  setup(props, context) {
136
252
  const editor = vueDemi.ref();
137
253
  const doc = vueDemi.ref(props.modelValue);
@@ -160,26 +276,45 @@
160
276
  () => view$1.value.state.doc.length
161
277
  );
162
278
  const extensions = vueDemi.computed(
163
- () => lodash.compact([
164
- props.basic ? codemirror.basicSetup : void 0,
165
- props.minimal && !props.basic ? codemirror.minimalSetup : void 0,
166
- view.EditorView.updateListener.of(
167
- (update) => context.emit("update", update)
168
- ),
169
- view.EditorView.theme(props.theme, { dark: props.dark }),
170
- props.wrap ? view.EditorView.lineWrapping : void 0,
171
- props.tab ? view.keymap.of([commands.indentWithTab]) : void 0,
172
- props.tabSize ? state.EditorState.tabSize.of(props.tabSize) : void 0,
173
- props.phrases ? state.EditorState.phrases.of(props.phrases) : void 0,
174
- state.EditorState.readOnly.of(props.readonly),
175
- view.EditorView.editable.of(!props.disabled),
176
- props.lineSeparator ? state.EditorState.lineSeparator.of(props.lineSeparator) : void 0,
177
- props.lang ? props.lang : void 0,
178
- props.linter ? lint.linter(props.linter, props.linterConfig) : void 0,
179
- props.linter && props.gutter ? lint.lintGutter(props.gutterConfig) : void 0,
180
- props.placeholder ? view.placeholder(props.placeholder) : void 0,
181
- ...props.extensions
182
- ])
279
+ () => (
280
+ // TODO: Ignore previous prop was not changed.
281
+ lodash.compact([
282
+ // Toggle basic setup
283
+ props.basic ? codemirror.basicSetup : void 0,
284
+ // Toggle minimal setup
285
+ props.minimal && !props.basic ? codemirror.minimalSetup : void 0,
286
+ // ViewUpdate event listener
287
+ view.EditorView.updateListener.of(
288
+ (update) => context.emit("update", update)
289
+ ),
290
+ // Toggle light/dark mode.
291
+ view.EditorView.theme(props.theme, { dark: props.dark }),
292
+ // Toggle line wrapping
293
+ props.wrap ? view.EditorView.lineWrapping : void 0,
294
+ // Indent with tab
295
+ props.tab ? view.keymap.of([commands.indentWithTab]) : void 0,
296
+ // Indent tab size
297
+ props.tabSize ? state.EditorState.tabSize.of(props.tabSize) : void 0,
298
+ // locale settings
299
+ props.phrases ? state.EditorState.phrases.of(props.phrases) : void 0,
300
+ // Readonly option
301
+ state.EditorState.readOnly.of(props.readonly),
302
+ // Editable option
303
+ view.EditorView.editable.of(!props.disabled),
304
+ // Set Line break char
305
+ props.lineSeparator ? state.EditorState.lineSeparator.of(props.lineSeparator) : void 0,
306
+ // Lang
307
+ props.lang ? props.lang : void 0,
308
+ // Append Linter settings
309
+ props.linter ? lint.linter(props.linter, props.linterConfig) : void 0,
310
+ // Show 🔴 to error line when linter enabled.
311
+ props.linter && props.gutter ? lint.lintGutter(props.gutterConfig) : void 0,
312
+ // Placeholder
313
+ props.placeholder ? view.placeholder(props.placeholder) : void 0,
314
+ // Append Extensions (such as basic-setup)
315
+ ...props.extensions
316
+ ])
317
+ )
183
318
  );
184
319
  vueDemi.watch(
185
320
  () => props.modelValue,
@@ -187,6 +322,9 @@
187
322
  if (view$1.value.composing) {
188
323
  return;
189
324
  }
325
+ if (props.linter && props.forceLinting) {
326
+ lint.forceLinting(view$1.value);
327
+ }
190
328
  view$1.value.dispatch({
191
329
  changes: { from: 0, to: view$1.value.state.doc.length, insert: value },
192
330
  selection: view$1.value.state.selection,
@@ -196,10 +334,12 @@
196
334
  { immediate: true }
197
335
  );
198
336
  vueDemi.watch(
199
- extensions,
200
- (exts) => view$1.value.dispatch({
201
- effects: state.StateEffect.reconfigure.of(exts)
202
- })
337
+ () => extensions.value,
338
+ (exts) => {
339
+ view$1.value.dispatch({
340
+ effects: state.StateEffect.reconfigure.of(exts)
341
+ });
342
+ }
203
343
  );
204
344
  vueDemi.watch(focus, (isFocus) => context.emit("focus", isFocus));
205
345
  vueDemi.onMounted(async () => {
@@ -289,6 +429,7 @@
289
429
  length,
290
430
  lint: lint$1,
291
431
  forceReconfigure,
432
+ // Bellow is CodeMirror5's function
292
433
  getRange,
293
434
  getLine,
294
435
  lineCount,
@@ -310,23 +451,29 @@
310
451
  },
311
452
  render() {
312
453
  return h(
454
+ // @ts-ignore
313
455
  this.$props.tag,
314
456
  {
315
457
  ref: "editor",
316
458
  class: "vue-codemirror"
317
459
  },
318
- this.$slots.default ? h(
319
- "aside",
320
- { style: "display: none;", "aria-hidden": "true" },
321
- slot(this.$slots.default)
460
+ // @ts-ignore
461
+ this.$slots.default ? (
462
+ // Hide original content
463
+ h(
464
+ "aside",
465
+ { style: "display: none;", "aria-hidden": "true" },
466
+ // @ts-ignore
467
+ slot(this.$slots.default)
468
+ )
322
469
  ) : void 0
323
470
  );
324
471
  }
325
472
  });
326
473
 
327
474
  const meta = {
328
- version: "1.1.10",
329
- date: "2023-01-29T01:57:06.994Z"
475
+ version: "1.1.12",
476
+ date: "2023-03-10T04:51:22.645Z"
330
477
  };
331
478
 
332
479
  const installCodeMirror = (app) => app.component("CodeMirror", CodeMirror);
@@ -0,0 +1,3 @@
1
+ import type MetaInterface from './interfaces/MetaInterface';
2
+ declare const meta: MetaInterface;
3
+ export default meta;
@@ -0,0 +1,27 @@
1
+ import { type ObjectEmitsOptions } from 'vue-demi';
2
+ import { EditorState, type Text } from '@codemirror/state';
3
+ import { EditorView, type ViewUpdate } from '@codemirror/view';
4
+ /** Emit Interface */
5
+ export interface CodeMirrorEmitsOptions extends ObjectEmitsOptions {
6
+ /** Model Update */
7
+ (e: 'update:modelValue', value: string | Text): void;
8
+ /** CodeMirror ViewUpdate */
9
+ (e: 'update', value: ViewUpdate): void;
10
+ /** CodeMirror onFocus */
11
+ (e: 'focus', value: boolean): void;
12
+ /** CodeMirror onReady */
13
+ (e: 'ready', value: {
14
+ view: EditorView;
15
+ state: EditorState;
16
+ container: HTMLElement;
17
+ }): void;
18
+ /** CodeMirror onDestroy */
19
+ (e: 'destroy'): void;
20
+ /** State Changed */
21
+ (e: 'change', value: EditorState): void;
22
+ /** Diagnostic Count */
23
+ (e: 'diagnosticCount'): number;
24
+ }
25
+ /** CodeMirror Component */
26
+ declare const _default: import("vue-demi").DefineComponent<unknown, object, {}, import("vue-demi").ComputedOptions, import("vue-demi").MethodOptions, import("vue-demi").ComponentOptionsMixin, import("vue-demi").ComponentOptionsMixin, {}, string, import("vue-demi").VNodeProps & import("vue-demi").AllowedComponentProps & import("vue-demi").ComponentCustomProps, Readonly<unknown>, {}>;
27
+ export default _default;
@@ -1,18 +1,20 @@
1
- /**
2
- * h-demi - h function for Vue 2 and 3
3
- *
4
- * @see {@link https://github.com/vueuse/vue-demi/issues/65}
5
- */
6
- import { type VNode } from 'vue-demi';
7
- interface Options {
8
- class?: string;
9
- domProps?: Record<any, any>;
10
- on?: Record<any, any>;
11
- props?: Record<any, any>;
12
- ref?: string;
13
- style?: string;
14
- 'aria-hidden'?: string;
15
- }
16
- declare const h: (type: string | Record<any, any>, options?: Options, chidren?: any) => VNode;
17
- declare const slot: (defaultSlots: any) => any;
18
- export { slot, h as default };
1
+ /**
2
+ * h-demi - h function for Vue 2 and 3
3
+ *
4
+ * @see {@link https://github.com/vueuse/vue-demi/issues/65}
5
+ */
6
+ import { type Slots, type VNode, type VNodeProps } from 'vue-demi';
7
+ interface Options extends VNodeProps {
8
+ class?: string;
9
+ domProps?: Record<any, any>;
10
+ on?: Record<any, any>;
11
+ props?: Record<any, any>;
12
+ style?: string;
13
+ 'aria-hidden'?: string;
14
+ }
15
+ /**
16
+ * hDemi function.
17
+ */
18
+ declare function h(type: string | Record<any, any>, options?: Options, chidren?: any): VNode;
19
+ declare const slot: (defaultSlots: any) => Slots;
20
+ export { slot, h as default };
@@ -1,4 +1,4 @@
1
- import CodeMirror from './components/CodeMirror';
2
- import Meta from './Meta';
3
- declare const installCodeMirror: (app: any) => any;
4
- export { CodeMirror as default, installCodeMirror as install, Meta };
1
+ import CodeMirror from './components/CodeMirror';
2
+ import Meta from './Meta';
3
+ declare const installCodeMirror: (app: any) => any;
4
+ export { CodeMirror as default, installCodeMirror as install, Meta };
@@ -1,7 +1,7 @@
1
- /** Build information meta data */
2
- export default interface MetaInterface {
3
- /** Version */
4
- version: string;
5
- /** Build date */
6
- date: string;
7
- }
1
+ /** Build information meta data */
2
+ export default interface MetaInterface {
3
+ /** Version */
4
+ version: string;
5
+ /** Build date */
6
+ date: string;
7
+ }
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.10",
4
+ "version": "1.1.12",
5
5
  "license": "MIT",
6
6
  "description": "CodeMirror6 Component for vue2 and vue3.",
7
7
  "keywords": [
@@ -36,12 +36,12 @@
36
36
  },
37
37
  "main": "dist/index.umd.js",
38
38
  "module": "dist/index.es.js",
39
- "types": "dist/index.d.ts",
39
+ "types": "dist/src/index.d.ts",
40
40
  "exports": {
41
41
  ".": {
42
42
  "import": "./dist/index.es.js",
43
43
  "require": "./dist/index.umd.js",
44
- "types": "./dist/index.d.ts"
44
+ "types": "./dist/src/index.d.ts"
45
45
  }
46
46
  },
47
47
  "files": [
@@ -53,21 +53,20 @@
53
53
  "./sfc": "./src/components/CodeMirror.ts"
54
54
  },
55
55
  "engines": {
56
- "node": ">=18.13.0",
57
- "yarn": ">=1.22.10"
56
+ "node": ">=18.15.0",
57
+ "yarn": ">=1.22.19"
58
58
  },
59
- "packageManager": "yarn@3.3.1",
59
+ "packageManager": "yarn@3.4.1",
60
60
  "sideEffects": false,
61
61
  "scripts": {
62
62
  "dev": "vite",
63
63
  "clean": "rimraf node_modules/.vite",
64
64
  "type-check": "tsc --noEmit --composite false",
65
- "build": "run-p type-check build-only build-declaration",
65
+ "build": "run-p type-check build-only",
66
66
  "build:analyze": "vite build --mode=analyze",
67
67
  "build:clean": "rimraf dist docs",
68
68
  "build:docs": "vite build --mode=docs",
69
69
  "build-only": "vite build",
70
- "build-declaration": "tsc -p tsconfig.app.json --composite false",
71
70
  "lint": "eslint . --fix --cache --cache-location ./node_modules/.vite/vite-plugin-eslint && prettier . --write",
72
71
  "preview": "vite preview --mode=docs",
73
72
  "prepare": "husky install",
@@ -80,7 +79,7 @@
80
79
  },
81
80
  "peerDependencies": {
82
81
  "@vue/composition-api": "^1.7.1",
83
- "vue": "^2.6.14 || ^3.2.39"
82
+ "vue": "^2.6.14 || ^3.2.47"
84
83
  },
85
84
  "peerDependenciesMeta": {
86
85
  "@vue/composition-api": {
@@ -88,45 +87,48 @@
88
87
  }
89
88
  },
90
89
  "devDependencies": {
91
- "@codemirror/lang-javascript": "^6.1.2",
90
+ "@codemirror/lang-javascript": "^6.1.4",
92
91
  "@codemirror/lang-json": "^6.0.1",
93
- "@codemirror/lang-markdown": "^6.0.5",
92
+ "@codemirror/lang-markdown": "^6.1.0",
93
+ "@codemirror/lang-vue": "^0.1.1",
94
94
  "@types/lodash": "^4.14.191",
95
- "@types/node": "^18.11.18",
96
- "@typescript-eslint/eslint-plugin": "^5.49.0",
97
- "@typescript-eslint/parser": "^5.49.0",
95
+ "@types/node": "^18.15.0",
96
+ "@typescript-eslint/eslint-plugin": "^5.54.1",
97
+ "@typescript-eslint/parser": "^5.54.1",
98
98
  "@vitejs/plugin-vue": "^4.0.0",
99
- "@vue/eslint-config-prettier": "^7.0.0",
99
+ "@vue/eslint-config-prettier": "^7.1.0",
100
100
  "@vue/tsconfig": "^0.1.3",
101
- "@vueuse/core": "^9.11.1",
102
- "eslint": "^8.33.0",
101
+ "@vueuse/core": "^9.13.0",
102
+ "eslint": "^8.35.0",
103
103
  "eslint-config-google": "^0.14.0",
104
- "eslint-config-prettier": "^8.6.0",
104
+ "eslint-config-prettier": "^8.7.0",
105
105
  "eslint-import-resolver-alias": "^1.1.2",
106
106
  "eslint-import-resolver-typescript": "^3.5.3",
107
- "eslint-linter-browserify": "^8.33.0",
107
+ "eslint-linter-browserify": "^8.35.0",
108
108
  "eslint-plugin-html": "^7.1.0",
109
109
  "eslint-plugin-import": "^2.27.5",
110
- "eslint-plugin-jsdoc": "^39.7.0",
110
+ "eslint-plugin-jsdoc": "^40.0.1",
111
111
  "eslint-plugin-prettier": "^4.2.1",
112
112
  "eslint-plugin-tsdoc": "^0.2.17",
113
113
  "eslint-plugin-vue": "^9.9.0",
114
114
  "eslint-plugin-vuejs-accessibility": "^2.1.0",
115
115
  "eslint-plugin-yaml": "^0.5.0",
116
116
  "husky": "^8.0.3",
117
- "lint-staged": "^13.1.0",
117
+ "lint-staged": "^13.1.2",
118
118
  "npm-run-all": "^4.1.5",
119
- "prettier": "^2.8.3",
120
- "rimraf": "^4.1.2",
119
+ "prettier": "^2.8.4",
120
+ "rimraf": "^4.4.0",
121
121
  "rollup-plugin-visualizer": "^5.9.0",
122
- "typescript": "^4.9.4",
123
- "vite": "^4.0.4",
122
+ "sass": "^1.58.3",
123
+ "typescript": "^4.9.5",
124
+ "vite": "^4.1.4",
124
125
  "vite-plugin-banner": "^0.7.0",
125
- "vite-plugin-checker": "^0.5.5",
126
- "vue": "^3.2.45",
126
+ "vite-plugin-checker": "^0.5.6",
127
+ "vite-plugin-dts": "^2.1.0",
128
+ "vue": "^3.2.47",
127
129
  "vue-eslint-parser": "^9.1.0",
128
- "vue-markdown-wasm": "^0.3.1",
129
- "vue-tsc": "^1.0.24"
130
+ "vue-markdown-wasm": "^0.3.6",
131
+ "vue-tsc": "^1.2.0"
130
132
  },
131
133
  "husky": {
132
134
  "hooks": {
@@ -138,6 +140,7 @@
138
140
  "*": "prettier -w -u"
139
141
  },
140
142
  "resolutions": {
141
- "json5": "^2.2.3"
143
+ "json5": "^2.2.3",
144
+ "http-cache-semantics": "^4.1.1"
142
145
  }
143
146
  }