vue-codemirror6 1.1.10 → 1.1.11

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/Meta.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // This file is auto-generated by the build system.
2
2
  const meta = {
3
- version: '1.1.10',
4
- date: '2023-01-29T01:57:06.994Z',
3
+ version: '1.1.11',
4
+ date: '2023-02-04T13:41:04.676Z',
5
5
  };
6
6
  export default meta;
package/dist/index.es.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.11
9
9
  * @see {@link https://github.com/logue/vue-codemirror6}
10
10
  */
11
11
 
@@ -41,99 +41,207 @@ const h = (type, options = {}, chidren) => {
41
41
  const slot = (defaultSlots) => typeof defaultSlots == "function" ? defaultSlots() : defaultSlots;
42
42
 
43
43
  var CodeMirror = defineComponent({
44
+ /** Component Name */
44
45
  name: "CodeMirror",
46
+ /** Model Definition */
45
47
  model: {
46
48
  prop: "modelValue",
47
49
  event: "update:modelValue"
48
50
  },
51
+ /** Props Definition */
49
52
  props: {
53
+ /** Model value */
50
54
  modelValue: {
51
55
  type: String,
52
56
  default: ""
53
57
  },
58
+ /**
59
+ * Theme
60
+ *
61
+ * @see {@link https://codemirror.net/docs/ref/#view.EditorView^theme}
62
+ */
54
63
  theme: {
55
64
  type: Object,
56
65
  default: () => {
57
66
  }
58
67
  },
68
+ /** Dark Mode */
59
69
  dark: {
60
70
  type: Boolean,
61
71
  default: false
62
72
  },
73
+ /**
74
+ * Use Basic Setup
75
+ *
76
+ * @see {@link https://codemirror.net/docs/ref/#codemirror.basicSetup}
77
+ */
63
78
  basic: {
64
79
  type: Boolean,
65
80
  default: false
66
81
  },
82
+ /**
83
+ * Use Minimal Setup (The basic setting has priority.)
84
+ *
85
+ * @see {@link https://codemirror.net/docs/ref/#codemirror.minimalSetup}
86
+ */
67
87
  minimal: {
68
88
  type: Boolean,
69
89
  default: false
70
90
  },
91
+ /**
92
+ * Placeholder
93
+ *
94
+ * @see {@link https://codemirror.net/docs/ref/#view.placeholder}
95
+ */
71
96
  placeholder: {
72
97
  type: String,
73
98
  default: void 0
74
99
  },
100
+ /**
101
+ * Line wrapping
102
+ *
103
+ * An extension that enables line wrapping in the editor (by setting CSS white-space to pre-wrap in the content).
104
+ *
105
+ * @see {@link https://codemirror.net/docs/ref/#view.EditorView%5ElineWrapping}
106
+ */
75
107
  wrap: {
76
108
  type: Boolean,
77
109
  default: false
78
110
  },
111
+ /**
112
+ * Allow tab key indent.
113
+ *
114
+ * @see {@link https://codemirror.net/examples/tab/}
115
+ */
79
116
  tab: {
80
117
  type: Boolean,
81
118
  default: false
82
119
  },
120
+ /**
121
+ * Tab size
122
+ *
123
+ * @see {@link https://codemirror.net/docs/ref/#state.EditorState^tabSize}
124
+ */
83
125
  tabSize: {
84
126
  type: Number,
85
127
  default: void 0
86
128
  },
129
+ /**
130
+ * Set line break (separetor) char.
131
+ *
132
+ * @see {@link https://codemirror.net/docs/ref/#state.EditorState^lineSeparator}
133
+ */
87
134
  lineSeparator: {
88
135
  type: String,
89
136
  default: void 0
90
137
  },
138
+ /**
139
+ * Readonly
140
+ *
141
+ * @see {@link https://codemirror.net/docs/ref/#state.EditorState^readOnly}
142
+ */
91
143
  readonly: {
92
144
  type: Boolean,
93
145
  default: false
94
146
  },
147
+ /**
148
+ * Disable input.
149
+ *
150
+ * This is the reversed value of the CodeMirror editable.
151
+ * Similar to `readonly`, but setting this value to true disables dragging.
152
+ *
153
+ * @see {@link https://codemirror.net/docs/ref/#view.EditorView^editable}
154
+ */
95
155
  disabled: {
96
156
  type: Boolean,
97
157
  default: false
98
158
  },
159
+ /**
160
+ * Additional Extension
161
+ *
162
+ * @see {@link https://codemirror.net/docs/ref/#state.Extension}
163
+ */
99
164
  extensions: {
100
165
  type: Array,
101
166
  default: () => {
102
167
  return [];
103
168
  }
104
169
  },
170
+ /**
171
+ * Language Phreses
172
+ *
173
+ * @see {@link https://codemirror.net/examples/translate/}
174
+ */
105
175
  phrases: {
106
176
  type: Object,
107
177
  default: () => void 0
108
178
  },
179
+ /**
180
+ * CodeMirror Language
181
+ *
182
+ * @see {@link https://codemirror.net/docs/ref/#language}
183
+ */
109
184
  lang: {
110
185
  type: Object,
111
186
  default: () => void 0
112
187
  },
188
+ /**
189
+ * CodeMirror Linter
190
+ *
191
+ * @see {@link https://codemirror.net/docs/ref/#lint.linter}
192
+ */
113
193
  linter: {
114
194
  type: Function,
115
195
  default: void 0
116
196
  },
197
+ /**
198
+ * Linter Config
199
+ *
200
+ * @see {@link https://codemirror.net/docs/ref/#lint.linter^config}
201
+ */
117
202
  linterConfig: {
118
203
  type: Object,
119
204
  default: () => {
120
205
  }
121
206
  },
207
+ /**
208
+ * Show Linter Gutter
209
+ *
210
+ * An area to 🔴 the lines with errors will be displayed.
211
+ * This feature is not enabled if `linter` is not specified.
212
+ *
213
+ * @see {@link https://codemirror.net/docs/ref/#lint.lintGutter}
214
+ */
122
215
  gutter: {
123
216
  type: Boolean,
124
217
  defalt: false
125
218
  },
219
+ /**
220
+ * Gutter Config
221
+ *
222
+ * @see {@link https://codemirror.net/docs/ref/#lint.lintGutter^config}
223
+ */
126
224
  gutterConfig: {
127
225
  type: Object,
128
226
  default: () => {
129
227
  }
130
228
  },
229
+ /**
230
+ * Using tag
231
+ */
131
232
  tag: {
132
233
  type: String,
133
234
  default: "div"
134
235
  }
135
236
  },
237
+ /** Emits */
136
238
  emits: ["update:modelValue", "update", "ready", "focus", "change", "destroy"],
239
+ /**
240
+ * Setup
241
+ *
242
+ * @param props - Props
243
+ * @param context - Context
244
+ */
137
245
  setup(props, context) {
138
246
  const editor = ref();
139
247
  const doc = ref(props.modelValue);
@@ -162,26 +270,45 @@ var CodeMirror = defineComponent({
162
270
  () => view.value.state.doc.length
163
271
  );
164
272
  const extensions = computed(
165
- () => compact([
166
- props.basic ? basicSetup : void 0,
167
- props.minimal && !props.basic ? minimalSetup : void 0,
168
- EditorView.updateListener.of(
169
- (update) => context.emit("update", update)
170
- ),
171
- EditorView.theme(props.theme, { dark: props.dark }),
172
- props.wrap ? EditorView.lineWrapping : void 0,
173
- props.tab ? keymap.of([indentWithTab]) : void 0,
174
- props.tabSize ? EditorState.tabSize.of(props.tabSize) : void 0,
175
- props.phrases ? EditorState.phrases.of(props.phrases) : void 0,
176
- EditorState.readOnly.of(props.readonly),
177
- EditorView.editable.of(!props.disabled),
178
- props.lineSeparator ? EditorState.lineSeparator.of(props.lineSeparator) : void 0,
179
- props.lang ? props.lang : void 0,
180
- props.linter ? linter(props.linter, props.linterConfig) : void 0,
181
- props.linter && props.gutter ? lintGutter(props.gutterConfig) : void 0,
182
- props.placeholder ? placeholder(props.placeholder) : void 0,
183
- ...props.extensions
184
- ])
273
+ () => (
274
+ // TODO: Ignore previous prop was not changed.
275
+ compact([
276
+ // Toggle basic setup
277
+ props.basic ? basicSetup : void 0,
278
+ // Toggle minimal setup
279
+ props.minimal && !props.basic ? minimalSetup : void 0,
280
+ // ViewUpdate event listener
281
+ EditorView.updateListener.of(
282
+ (update) => context.emit("update", update)
283
+ ),
284
+ // Toggle light/dark mode.
285
+ EditorView.theme(props.theme, { dark: props.dark }),
286
+ // Toggle line wrapping
287
+ props.wrap ? EditorView.lineWrapping : void 0,
288
+ // Indent with tab
289
+ props.tab ? keymap.of([indentWithTab]) : void 0,
290
+ // Indent tab size
291
+ props.tabSize ? EditorState.tabSize.of(props.tabSize) : void 0,
292
+ // locale settings
293
+ props.phrases ? EditorState.phrases.of(props.phrases) : void 0,
294
+ // Readonly option
295
+ EditorState.readOnly.of(props.readonly),
296
+ // Editable option
297
+ EditorView.editable.of(!props.disabled),
298
+ // Set Line break char
299
+ props.lineSeparator ? EditorState.lineSeparator.of(props.lineSeparator) : void 0,
300
+ // Lang
301
+ props.lang ? props.lang : void 0,
302
+ // Append Linter settings
303
+ props.linter ? linter(props.linter, props.linterConfig) : void 0,
304
+ // Show 🔴 to error line when linter enabled.
305
+ props.linter && props.gutter ? lintGutter(props.gutterConfig) : void 0,
306
+ // Placeholder
307
+ props.placeholder ? placeholder(props.placeholder) : void 0,
308
+ // Append Extensions (such as basic-setup)
309
+ ...props.extensions
310
+ ])
311
+ )
185
312
  );
186
313
  watch(
187
314
  () => props.modelValue,
@@ -199,9 +326,12 @@ var CodeMirror = defineComponent({
199
326
  );
200
327
  watch(
201
328
  extensions,
202
- (exts) => view.value.dispatch({
203
- effects: StateEffect.reconfigure.of(exts)
204
- })
329
+ (exts) => (
330
+ // TODO: Reduce unchanched value
331
+ view.value.dispatch({
332
+ effects: StateEffect.reconfigure.of(exts)
333
+ })
334
+ )
205
335
  );
206
336
  watch(focus, (isFocus) => context.emit("focus", isFocus));
207
337
  onMounted(async () => {
@@ -291,6 +421,7 @@ var CodeMirror = defineComponent({
291
421
  length,
292
422
  lint,
293
423
  forceReconfigure,
424
+ // Bellow is CodeMirror5's function
294
425
  getRange,
295
426
  getLine,
296
427
  lineCount,
@@ -317,18 +448,21 @@ var CodeMirror = defineComponent({
317
448
  ref: "editor",
318
449
  class: "vue-codemirror"
319
450
  },
320
- this.$slots.default ? h(
321
- "aside",
322
- { style: "display: none;", "aria-hidden": "true" },
323
- slot(this.$slots.default)
451
+ this.$slots.default ? (
452
+ // Hide original content
453
+ h(
454
+ "aside",
455
+ { style: "display: none;", "aria-hidden": "true" },
456
+ slot(this.$slots.default)
457
+ )
324
458
  ) : void 0
325
459
  );
326
460
  }
327
461
  });
328
462
 
329
463
  const meta = {
330
- version: "1.1.10",
331
- date: "2023-01-29T01:57:06.994Z"
464
+ version: "1.1.11",
465
+ date: "2023-02-04T13:41:04.676Z"
332
466
  };
333
467
 
334
468
  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.10
8
+ * @version 1.1.11
9
9
  * @see {@link https://github.com/logue/vue-codemirror6}
10
10
  */
11
11
 
@@ -36,99 +36,207 @@ var CodeMirror = (function (exports, vueDemi, lodash, codemirror, state, view, c
36
36
  const slot = (defaultSlots) => typeof defaultSlots == "function" ? defaultSlots() : defaultSlots;
37
37
 
38
38
  var CodeMirror = vueDemi.defineComponent({
39
+ /** Component Name */
39
40
  name: "CodeMirror",
41
+ /** Model Definition */
40
42
  model: {
41
43
  prop: "modelValue",
42
44
  event: "update:modelValue"
43
45
  },
46
+ /** Props Definition */
44
47
  props: {
48
+ /** Model value */
45
49
  modelValue: {
46
50
  type: String,
47
51
  default: ""
48
52
  },
53
+ /**
54
+ * Theme
55
+ *
56
+ * @see {@link https://codemirror.net/docs/ref/#view.EditorView^theme}
57
+ */
49
58
  theme: {
50
59
  type: Object,
51
60
  default: () => {
52
61
  }
53
62
  },
63
+ /** Dark Mode */
54
64
  dark: {
55
65
  type: Boolean,
56
66
  default: false
57
67
  },
68
+ /**
69
+ * Use Basic Setup
70
+ *
71
+ * @see {@link https://codemirror.net/docs/ref/#codemirror.basicSetup}
72
+ */
58
73
  basic: {
59
74
  type: Boolean,
60
75
  default: false
61
76
  },
77
+ /**
78
+ * Use Minimal Setup (The basic setting has priority.)
79
+ *
80
+ * @see {@link https://codemirror.net/docs/ref/#codemirror.minimalSetup}
81
+ */
62
82
  minimal: {
63
83
  type: Boolean,
64
84
  default: false
65
85
  },
86
+ /**
87
+ * Placeholder
88
+ *
89
+ * @see {@link https://codemirror.net/docs/ref/#view.placeholder}
90
+ */
66
91
  placeholder: {
67
92
  type: String,
68
93
  default: void 0
69
94
  },
95
+ /**
96
+ * Line wrapping
97
+ *
98
+ * An extension that enables line wrapping in the editor (by setting CSS white-space to pre-wrap in the content).
99
+ *
100
+ * @see {@link https://codemirror.net/docs/ref/#view.EditorView%5ElineWrapping}
101
+ */
70
102
  wrap: {
71
103
  type: Boolean,
72
104
  default: false
73
105
  },
106
+ /**
107
+ * Allow tab key indent.
108
+ *
109
+ * @see {@link https://codemirror.net/examples/tab/}
110
+ */
74
111
  tab: {
75
112
  type: Boolean,
76
113
  default: false
77
114
  },
115
+ /**
116
+ * Tab size
117
+ *
118
+ * @see {@link https://codemirror.net/docs/ref/#state.EditorState^tabSize}
119
+ */
78
120
  tabSize: {
79
121
  type: Number,
80
122
  default: void 0
81
123
  },
124
+ /**
125
+ * Set line break (separetor) char.
126
+ *
127
+ * @see {@link https://codemirror.net/docs/ref/#state.EditorState^lineSeparator}
128
+ */
82
129
  lineSeparator: {
83
130
  type: String,
84
131
  default: void 0
85
132
  },
133
+ /**
134
+ * Readonly
135
+ *
136
+ * @see {@link https://codemirror.net/docs/ref/#state.EditorState^readOnly}
137
+ */
86
138
  readonly: {
87
139
  type: Boolean,
88
140
  default: false
89
141
  },
142
+ /**
143
+ * Disable input.
144
+ *
145
+ * This is the reversed value of the CodeMirror editable.
146
+ * Similar to `readonly`, but setting this value to true disables dragging.
147
+ *
148
+ * @see {@link https://codemirror.net/docs/ref/#view.EditorView^editable}
149
+ */
90
150
  disabled: {
91
151
  type: Boolean,
92
152
  default: false
93
153
  },
154
+ /**
155
+ * Additional Extension
156
+ *
157
+ * @see {@link https://codemirror.net/docs/ref/#state.Extension}
158
+ */
94
159
  extensions: {
95
160
  type: Array,
96
161
  default: () => {
97
162
  return [];
98
163
  }
99
164
  },
165
+ /**
166
+ * Language Phreses
167
+ *
168
+ * @see {@link https://codemirror.net/examples/translate/}
169
+ */
100
170
  phrases: {
101
171
  type: Object,
102
172
  default: () => void 0
103
173
  },
174
+ /**
175
+ * CodeMirror Language
176
+ *
177
+ * @see {@link https://codemirror.net/docs/ref/#language}
178
+ */
104
179
  lang: {
105
180
  type: Object,
106
181
  default: () => void 0
107
182
  },
183
+ /**
184
+ * CodeMirror Linter
185
+ *
186
+ * @see {@link https://codemirror.net/docs/ref/#lint.linter}
187
+ */
108
188
  linter: {
109
189
  type: Function,
110
190
  default: void 0
111
191
  },
192
+ /**
193
+ * Linter Config
194
+ *
195
+ * @see {@link https://codemirror.net/docs/ref/#lint.linter^config}
196
+ */
112
197
  linterConfig: {
113
198
  type: Object,
114
199
  default: () => {
115
200
  }
116
201
  },
202
+ /**
203
+ * Show Linter Gutter
204
+ *
205
+ * An area to 🔴 the lines with errors will be displayed.
206
+ * This feature is not enabled if `linter` is not specified.
207
+ *
208
+ * @see {@link https://codemirror.net/docs/ref/#lint.lintGutter}
209
+ */
117
210
  gutter: {
118
211
  type: Boolean,
119
212
  defalt: false
120
213
  },
214
+ /**
215
+ * Gutter Config
216
+ *
217
+ * @see {@link https://codemirror.net/docs/ref/#lint.lintGutter^config}
218
+ */
121
219
  gutterConfig: {
122
220
  type: Object,
123
221
  default: () => {
124
222
  }
125
223
  },
224
+ /**
225
+ * Using tag
226
+ */
126
227
  tag: {
127
228
  type: String,
128
229
  default: "div"
129
230
  }
130
231
  },
232
+ /** Emits */
131
233
  emits: ["update:modelValue", "update", "ready", "focus", "change", "destroy"],
234
+ /**
235
+ * Setup
236
+ *
237
+ * @param props - Props
238
+ * @param context - Context
239
+ */
132
240
  setup(props, context) {
133
241
  const editor = vueDemi.ref();
134
242
  const doc = vueDemi.ref(props.modelValue);
@@ -157,26 +265,45 @@ var CodeMirror = (function (exports, vueDemi, lodash, codemirror, state, view, c
157
265
  () => view$1.value.state.doc.length
158
266
  );
159
267
  const extensions = vueDemi.computed(
160
- () => lodash.compact([
161
- props.basic ? codemirror.basicSetup : void 0,
162
- props.minimal && !props.basic ? codemirror.minimalSetup : void 0,
163
- view.EditorView.updateListener.of(
164
- (update) => context.emit("update", update)
165
- ),
166
- view.EditorView.theme(props.theme, { dark: props.dark }),
167
- props.wrap ? view.EditorView.lineWrapping : void 0,
168
- props.tab ? view.keymap.of([commands.indentWithTab]) : void 0,
169
- props.tabSize ? state.EditorState.tabSize.of(props.tabSize) : void 0,
170
- props.phrases ? state.EditorState.phrases.of(props.phrases) : void 0,
171
- state.EditorState.readOnly.of(props.readonly),
172
- view.EditorView.editable.of(!props.disabled),
173
- props.lineSeparator ? state.EditorState.lineSeparator.of(props.lineSeparator) : void 0,
174
- props.lang ? props.lang : void 0,
175
- props.linter ? lint.linter(props.linter, props.linterConfig) : void 0,
176
- props.linter && props.gutter ? lint.lintGutter(props.gutterConfig) : void 0,
177
- props.placeholder ? view.placeholder(props.placeholder) : void 0,
178
- ...props.extensions
179
- ])
268
+ () => (
269
+ // TODO: Ignore previous prop was not changed.
270
+ lodash.compact([
271
+ // Toggle basic setup
272
+ props.basic ? codemirror.basicSetup : void 0,
273
+ // Toggle minimal setup
274
+ props.minimal && !props.basic ? codemirror.minimalSetup : void 0,
275
+ // ViewUpdate event listener
276
+ view.EditorView.updateListener.of(
277
+ (update) => context.emit("update", update)
278
+ ),
279
+ // Toggle light/dark mode.
280
+ view.EditorView.theme(props.theme, { dark: props.dark }),
281
+ // Toggle line wrapping
282
+ props.wrap ? view.EditorView.lineWrapping : void 0,
283
+ // Indent with tab
284
+ props.tab ? view.keymap.of([commands.indentWithTab]) : void 0,
285
+ // Indent tab size
286
+ props.tabSize ? state.EditorState.tabSize.of(props.tabSize) : void 0,
287
+ // locale settings
288
+ props.phrases ? state.EditorState.phrases.of(props.phrases) : void 0,
289
+ // Readonly option
290
+ state.EditorState.readOnly.of(props.readonly),
291
+ // Editable option
292
+ view.EditorView.editable.of(!props.disabled),
293
+ // Set Line break char
294
+ props.lineSeparator ? state.EditorState.lineSeparator.of(props.lineSeparator) : void 0,
295
+ // Lang
296
+ props.lang ? props.lang : void 0,
297
+ // Append Linter settings
298
+ props.linter ? lint.linter(props.linter, props.linterConfig) : void 0,
299
+ // Show 🔴 to error line when linter enabled.
300
+ props.linter && props.gutter ? lint.lintGutter(props.gutterConfig) : void 0,
301
+ // Placeholder
302
+ props.placeholder ? view.placeholder(props.placeholder) : void 0,
303
+ // Append Extensions (such as basic-setup)
304
+ ...props.extensions
305
+ ])
306
+ )
180
307
  );
181
308
  vueDemi.watch(
182
309
  () => props.modelValue,
@@ -194,9 +321,12 @@ var CodeMirror = (function (exports, vueDemi, lodash, codemirror, state, view, c
194
321
  );
195
322
  vueDemi.watch(
196
323
  extensions,
197
- (exts) => view$1.value.dispatch({
198
- effects: state.StateEffect.reconfigure.of(exts)
199
- })
324
+ (exts) => (
325
+ // TODO: Reduce unchanched value
326
+ view$1.value.dispatch({
327
+ effects: state.StateEffect.reconfigure.of(exts)
328
+ })
329
+ )
200
330
  );
201
331
  vueDemi.watch(focus, (isFocus) => context.emit("focus", isFocus));
202
332
  vueDemi.onMounted(async () => {
@@ -286,6 +416,7 @@ var CodeMirror = (function (exports, vueDemi, lodash, codemirror, state, view, c
286
416
  length,
287
417
  lint: lint$1,
288
418
  forceReconfigure,
419
+ // Bellow is CodeMirror5's function
289
420
  getRange,
290
421
  getLine,
291
422
  lineCount,
@@ -312,18 +443,21 @@ var CodeMirror = (function (exports, vueDemi, lodash, codemirror, state, view, c
312
443
  ref: "editor",
313
444
  class: "vue-codemirror"
314
445
  },
315
- this.$slots.default ? h(
316
- "aside",
317
- { style: "display: none;", "aria-hidden": "true" },
318
- slot(this.$slots.default)
446
+ this.$slots.default ? (
447
+ // Hide original content
448
+ h(
449
+ "aside",
450
+ { style: "display: none;", "aria-hidden": "true" },
451
+ slot(this.$slots.default)
452
+ )
319
453
  ) : void 0
320
454
  );
321
455
  }
322
456
  });
323
457
 
324
458
  const meta = {
325
- version: "1.1.10",
326
- date: "2023-01-29T01:57:06.994Z"
459
+ version: "1.1.11",
460
+ date: "2023-02-04T13:41:04.676Z"
327
461
  };
328
462
 
329
463
  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.10
8
+ * @version 1.1.11
9
9
  * @see {@link https://github.com/logue/vue-codemirror6}
10
10
  */
11
11
 
@@ -39,99 +39,207 @@
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
202
  default: () => {
118
203
  }
119
204
  },
205
+ /**
206
+ * Show Linter Gutter
207
+ *
208
+ * An area to 🔴 the lines with errors will be displayed.
209
+ * This feature is not enabled if `linter` is not specified.
210
+ *
211
+ * @see {@link https://codemirror.net/docs/ref/#lint.lintGutter}
212
+ */
120
213
  gutter: {
121
214
  type: Boolean,
122
215
  defalt: false
123
216
  },
217
+ /**
218
+ * Gutter Config
219
+ *
220
+ * @see {@link https://codemirror.net/docs/ref/#lint.lintGutter^config}
221
+ */
124
222
  gutterConfig: {
125
223
  type: Object,
126
224
  default: () => {
127
225
  }
128
226
  },
227
+ /**
228
+ * Using tag
229
+ */
129
230
  tag: {
130
231
  type: String,
131
232
  default: "div"
132
233
  }
133
234
  },
235
+ /** Emits */
134
236
  emits: ["update:modelValue", "update", "ready", "focus", "change", "destroy"],
237
+ /**
238
+ * Setup
239
+ *
240
+ * @param props - Props
241
+ * @param context - Context
242
+ */
135
243
  setup(props, context) {
136
244
  const editor = vueDemi.ref();
137
245
  const doc = vueDemi.ref(props.modelValue);
@@ -160,26 +268,45 @@
160
268
  () => view$1.value.state.doc.length
161
269
  );
162
270
  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
- ])
271
+ () => (
272
+ // TODO: Ignore previous prop was not changed.
273
+ lodash.compact([
274
+ // Toggle basic setup
275
+ props.basic ? codemirror.basicSetup : void 0,
276
+ // Toggle minimal setup
277
+ props.minimal && !props.basic ? codemirror.minimalSetup : void 0,
278
+ // ViewUpdate event listener
279
+ view.EditorView.updateListener.of(
280
+ (update) => context.emit("update", update)
281
+ ),
282
+ // Toggle light/dark mode.
283
+ view.EditorView.theme(props.theme, { dark: props.dark }),
284
+ // Toggle line wrapping
285
+ props.wrap ? view.EditorView.lineWrapping : void 0,
286
+ // Indent with tab
287
+ props.tab ? view.keymap.of([commands.indentWithTab]) : void 0,
288
+ // Indent tab size
289
+ props.tabSize ? state.EditorState.tabSize.of(props.tabSize) : void 0,
290
+ // locale settings
291
+ props.phrases ? state.EditorState.phrases.of(props.phrases) : void 0,
292
+ // Readonly option
293
+ state.EditorState.readOnly.of(props.readonly),
294
+ // Editable option
295
+ view.EditorView.editable.of(!props.disabled),
296
+ // Set Line break char
297
+ props.lineSeparator ? state.EditorState.lineSeparator.of(props.lineSeparator) : void 0,
298
+ // Lang
299
+ props.lang ? props.lang : void 0,
300
+ // Append Linter settings
301
+ props.linter ? lint.linter(props.linter, props.linterConfig) : void 0,
302
+ // Show 🔴 to error line when linter enabled.
303
+ props.linter && props.gutter ? lint.lintGutter(props.gutterConfig) : void 0,
304
+ // Placeholder
305
+ props.placeholder ? view.placeholder(props.placeholder) : void 0,
306
+ // Append Extensions (such as basic-setup)
307
+ ...props.extensions
308
+ ])
309
+ )
183
310
  );
184
311
  vueDemi.watch(
185
312
  () => props.modelValue,
@@ -197,9 +324,12 @@
197
324
  );
198
325
  vueDemi.watch(
199
326
  extensions,
200
- (exts) => view$1.value.dispatch({
201
- effects: state.StateEffect.reconfigure.of(exts)
202
- })
327
+ (exts) => (
328
+ // TODO: Reduce unchanched value
329
+ view$1.value.dispatch({
330
+ effects: state.StateEffect.reconfigure.of(exts)
331
+ })
332
+ )
203
333
  );
204
334
  vueDemi.watch(focus, (isFocus) => context.emit("focus", isFocus));
205
335
  vueDemi.onMounted(async () => {
@@ -289,6 +419,7 @@
289
419
  length,
290
420
  lint: lint$1,
291
421
  forceReconfigure,
422
+ // Bellow is CodeMirror5's function
292
423
  getRange,
293
424
  getLine,
294
425
  lineCount,
@@ -315,18 +446,21 @@
315
446
  ref: "editor",
316
447
  class: "vue-codemirror"
317
448
  },
318
- this.$slots.default ? h(
319
- "aside",
320
- { style: "display: none;", "aria-hidden": "true" },
321
- slot(this.$slots.default)
449
+ this.$slots.default ? (
450
+ // Hide original content
451
+ h(
452
+ "aside",
453
+ { style: "display: none;", "aria-hidden": "true" },
454
+ slot(this.$slots.default)
455
+ )
322
456
  ) : void 0
323
457
  );
324
458
  }
325
459
  });
326
460
 
327
461
  const meta = {
328
- version: "1.1.10",
329
- date: "2023-01-29T01:57:06.994Z"
462
+ version: "1.1.11",
463
+ date: "2023-02-04T13:41:04.676Z"
330
464
  };
331
465
 
332
466
  const installCodeMirror = (app) => app.component("CodeMirror", CodeMirror);
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.11",
5
5
  "license": "MIT",
6
6
  "description": "CodeMirror6 Component for vue2 and vue3.",
7
7
  "keywords": [
@@ -88,17 +88,17 @@
88
88
  }
89
89
  },
90
90
  "devDependencies": {
91
- "@codemirror/lang-javascript": "^6.1.2",
91
+ "@codemirror/lang-javascript": "^6.1.3",
92
92
  "@codemirror/lang-json": "^6.0.1",
93
93
  "@codemirror/lang-markdown": "^6.0.5",
94
94
  "@types/lodash": "^4.14.191",
95
95
  "@types/node": "^18.11.18",
96
- "@typescript-eslint/eslint-plugin": "^5.49.0",
97
- "@typescript-eslint/parser": "^5.49.0",
96
+ "@typescript-eslint/eslint-plugin": "^5.50.0",
97
+ "@typescript-eslint/parser": "^5.50.0",
98
98
  "@vitejs/plugin-vue": "^4.0.0",
99
99
  "@vue/eslint-config-prettier": "^7.0.0",
100
100
  "@vue/tsconfig": "^0.1.3",
101
- "@vueuse/core": "^9.11.1",
101
+ "@vueuse/core": "^9.12.0",
102
102
  "eslint": "^8.33.0",
103
103
  "eslint-config-google": "^0.14.0",
104
104
  "eslint-config-prettier": "^8.6.0",
@@ -107,7 +107,7 @@
107
107
  "eslint-linter-browserify": "^8.33.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": "^39.8.0",
111
111
  "eslint-plugin-prettier": "^4.2.1",
112
112
  "eslint-plugin-tsdoc": "^0.2.17",
113
113
  "eslint-plugin-vue": "^9.9.0",
@@ -119,13 +119,15 @@
119
119
  "prettier": "^2.8.3",
120
120
  "rimraf": "^4.1.2",
121
121
  "rollup-plugin-visualizer": "^5.9.0",
122
- "typescript": "^4.9.4",
123
- "vite": "^4.0.4",
122
+ "sass": "^1.58.0",
123
+ "sass-loader": "^13.2.0",
124
+ "typescript": "^4.9.5",
125
+ "vite": "^4.1.1",
124
126
  "vite-plugin-banner": "^0.7.0",
125
127
  "vite-plugin-checker": "^0.5.5",
126
- "vue": "^3.2.45",
128
+ "vue": "3.2.45",
127
129
  "vue-eslint-parser": "^9.1.0",
128
- "vue-markdown-wasm": "^0.3.1",
130
+ "vue-markdown-wasm": "^0.3.2",
129
131
  "vue-tsc": "^1.0.24"
130
132
  },
131
133
  "husky": {
@@ -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
  }