vue-codemirror6 1.0.3 → 1.1.1

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.
@@ -1,11 +1,11 @@
1
- import { type ObjectEmitsOptions, type PropType, type Ref, type SetupContext } from 'vue-demi';
1
+ import { type ComputedRef, type ObjectEmitsOptions, type PropType, type Ref, type SetupContext, type WritableComputedRef } from 'vue-demi';
2
2
  import { EditorSelection, EditorState } from '@codemirror/state';
3
3
  import { EditorView } from '@codemirror/view';
4
4
  import type { Extension, SelectionRange, Text } from '@codemirror/state';
5
5
  import type { LanguageSupport } from '@codemirror/language';
6
- import type { ViewUpdate } from '@codemirror/view';
7
6
  import type { LintSource } from '@codemirror/lint';
8
7
  import type { StyleSpec } from 'style-mod';
8
+ import type { ViewUpdate } from '@codemirror/view';
9
9
  /** Emit Interface */
10
10
  export interface CodeMirrorEmitsOptions extends ObjectEmitsOptions {
11
11
  /** Model Update */
@@ -18,10 +18,10 @@ export interface CodeMirrorEmitsOptions extends ObjectEmitsOptions {
18
18
  (e: 'ready', value: {
19
19
  view: EditorView;
20
20
  state: EditorState;
21
- container: HTMLDivElement;
21
+ container: HTMLElement;
22
22
  }): void;
23
- /** onChanged (same as update:modelValue) */
24
- (e: 'changed', value: string | Text): void;
23
+ /** onChange (same as update:modelValue) */
24
+ (e: 'change', value: string | Text): void;
25
25
  }
26
26
  /** CodeMirror Component */
27
27
  declare const _default: import("vue-demi").DefineComponent<{
@@ -33,13 +33,13 @@ declare const _default: import("vue-demi").DefineComponent<{
33
33
  /**
34
34
  * Theme
35
35
  *
36
- * @see {@link https://codemirror.net/6/examples/styling/ | Example: Styling}
36
+ * @see {@link https://codemirror.net/docs/ref/#view.EditorView^theme}
37
37
  */
38
38
  theme: {
39
39
  type: PropType<{
40
40
  [selector: string]: StyleSpec;
41
41
  }>;
42
- default: () => {};
42
+ default: () => void;
43
43
  };
44
44
  /** Dark Mode */
45
45
  dark: {
@@ -49,7 +49,7 @@ declare const _default: import("vue-demi").DefineComponent<{
49
49
  /**
50
50
  * Use Basic Setup
51
51
  *
52
- * @see {@link https://codemirror.net/docs/ref/#codemirror.basicSetup | basicSetup}
52
+ * @see {@link https://codemirror.net/docs/ref/#codemirror.basicSetup}
53
53
  */
54
54
  basic: {
55
55
  type: BooleanConstructor;
@@ -58,52 +58,84 @@ declare const _default: import("vue-demi").DefineComponent<{
58
58
  /**
59
59
  * Use Minimal Setup (The basic setting has priority.)
60
60
  *
61
- * @see {@link https://codemirror.net/docs/ref/#codemirror.minimalSetup | minimalSetup}
61
+ * @see {@link https://codemirror.net/docs/ref/#codemirror.minimalSetup}
62
62
  */
63
63
  minimal: {
64
64
  type: BooleanConstructor;
65
65
  default: boolean;
66
66
  };
67
+ /**
68
+ * Placeholder
69
+ *
70
+ * @see {@link https://codemirror.net/docs/ref/#view.placeholder}
71
+ */
72
+ placeholder: {
73
+ type: PropType<string | HTMLElement>;
74
+ default: undefined;
75
+ };
67
76
  /**
68
77
  * Line wrapping
69
78
  *
70
- * @see {@link https://codemirror.net/6/docs/ref/#view.EditorView%5ElineWrapping | LineWrapping}
79
+ * An extension that enables line wrapping in the editor (by setting CSS white-space to pre-wrap in the content).
80
+ *
81
+ * @see {@link https://codemirror.net/docs/ref/#view.EditorView%5ElineWrapping}
71
82
  */
72
83
  wrap: {
73
84
  type: BooleanConstructor;
74
85
  default: boolean;
75
86
  };
76
87
  /**
77
- * Tab handling
88
+ * Allow tab key indent.
78
89
  *
79
- * @see {@link https://codemirror.net/6/examples/tab/ | Tab Handling}
90
+ * @see {@link https://codemirror.net/examples/tab/}
80
91
  */
81
92
  tab: {
82
93
  type: BooleanConstructor;
83
94
  default: boolean;
84
95
  };
96
+ /**
97
+ * Tab size
98
+ *
99
+ * @see {@link https://codemirror.net/docs/ref/#state.EditorState^tabSize}
100
+ */
101
+ tabSize: {
102
+ type: NumberConstructor;
103
+ default: undefined;
104
+ };
105
+ /**
106
+ * Set line break (separetor) char.
107
+ *
108
+ * @see {@link https://codemirror.net/docs/ref/#state.EditorState^lineSeparator}
109
+ */
110
+ lineSeparator: {
111
+ type: StringConstructor;
112
+ default: undefined;
113
+ };
85
114
  /**
86
115
  * Readonly
87
116
  *
88
- * @see {@link https://codemirror.net/6/docs/ref/#state.EditorState%5EreadOnly | readOnly}
117
+ * @see {@link https://codemirror.net/docs/ref/#state.EditorState^readOnly}
89
118
  */
90
119
  readonly: {
91
120
  type: BooleanConstructor;
92
121
  default: boolean;
93
122
  };
94
123
  /**
95
- * Editable
124
+ * Disable input.
96
125
  *
97
- * @see {@link https://codemirror.net/6/docs/ref/#view.EditorView%5Eeditable | editable}
126
+ * This is the reversed value of the CodeMirror editable.
127
+ * Similar to `readonly`, but setting this value to true disables dragging.
128
+ *
129
+ * @see {@link https://codemirror.net/docs/ref/#view.EditorView^editable}
98
130
  */
99
- editable: {
131
+ disabled: {
100
132
  type: BooleanConstructor;
101
133
  default: boolean;
102
134
  };
103
135
  /**
104
136
  * Additional Extension
105
137
  *
106
- * @see {@link https://codemirror.net/6/docs/ref/#state.Extension | Extending Editor State}
138
+ * @see {@link https://codemirror.net/docs/ref/#state.Extension}
107
139
  */
108
140
  extensions: {
109
141
  type: PropType<Extension[]>;
@@ -112,7 +144,7 @@ declare const _default: import("vue-demi").DefineComponent<{
112
144
  /**
113
145
  * Language Phreses
114
146
  *
115
- * @see {@link https://codemirror.net/6/examples/translate/ | Example: Internationalization}
147
+ * @see {@link https://codemirror.net/examples/translate/}
116
148
  */
117
149
  phrases: {
118
150
  type: PropType<Record<string, string>>;
@@ -121,7 +153,7 @@ declare const _default: import("vue-demi").DefineComponent<{
121
153
  /**
122
154
  * CodeMirror Language
123
155
  *
124
- * @see {@link https://codemirror.net/6/docs/ref/#language | @codemirror/language}
156
+ * @see {@link https://codemirror.net/docs/ref/#language}
125
157
  */
126
158
  lang: {
127
159
  type: PropType<LanguageSupport>;
@@ -130,18 +162,45 @@ declare const _default: import("vue-demi").DefineComponent<{
130
162
  /**
131
163
  * CodeMirror Linter
132
164
  *
133
- * @see {@link https://codemirror.net/6/docs/ref/#lint | @codemirror/lint}
165
+ * @see {@link https://codemirror.net/docs/ref/#lint.linter}
134
166
  */
135
167
  linter: {
136
168
  type: PropType<LintSource>;
137
169
  default: undefined;
138
170
  };
139
- /** Show Gutter */
140
- lintGutter: {
171
+ /**
172
+ * Linter Config
173
+ *
174
+ * @see {@link https://codemirror.net/docs/ref/#lint.linter^config}
175
+ */
176
+ linterConfig: {
177
+ type: ObjectConstructor;
178
+ default: () => void;
179
+ };
180
+ /**
181
+ * Show Linter Gutter
182
+ *
183
+ * An area to 🔴 the lines with errors will be displayed.
184
+ * This feature is not enabled if `linter` is not specified.
185
+ *
186
+ * @see {@link https://codemirror.net/docs/ref/#lint.lintGutter}
187
+ */
188
+ gutter: {
141
189
  type: BooleanConstructor;
142
190
  defalt: boolean;
143
191
  };
144
- /** Using tag */
192
+ /**
193
+ * Gutter Config
194
+ *
195
+ * @see {@link https://codemirror.net/docs/ref/#lint.lintGutter^config}
196
+ */
197
+ gutterConfig: {
198
+ type: ObjectConstructor;
199
+ default: () => void;
200
+ };
201
+ /**
202
+ * Using tag
203
+ */
145
204
  tag: {
146
205
  type: StringConstructor;
147
206
  default: string;
@@ -149,10 +208,12 @@ declare const _default: import("vue-demi").DefineComponent<{
149
208
  }, {
150
209
  context: SetupContext<CodeMirrorEmitsOptions>;
151
210
  editor: Ref<HTMLElement | undefined>;
152
- cursor: Ref<number>;
153
- selection: Ref<EditorSelection>;
154
- state: Ref<EditorState>;
155
- focus: Ref<boolean>;
211
+ cursor: WritableComputedRef<number>;
212
+ selection: WritableComputedRef<EditorSelection>;
213
+ state: WritableComputedRef<EditorState>;
214
+ focus: WritableComputedRef<boolean>;
215
+ length: ComputedRef<number>;
216
+ lint: () => void;
156
217
  getRange: (from?: number, to?: number) => string;
157
218
  getLine: (number: number) => string;
158
219
  lineCount: () => number;
@@ -167,7 +228,7 @@ declare const _default: import("vue-demi").DefineComponent<{
167
228
  setSelection: (anchor: number, head?: number) => void;
168
229
  setSelections: (ranges: readonly SelectionRange[], primary?: number) => void;
169
230
  extendSelectionsBy: (f: Function) => void;
170
- }, unknown, {}, {}, import("vue-demi").ComponentOptionsMixin, import("vue-demi").ComponentOptionsMixin, CodeMirrorEmitsOptions, "update:modelValue" | "update" | "focus" | "ready" | "changed", import("vue-demi").VNodeProps & import("vue-demi").AllowedComponentProps & import("vue-demi").ComponentCustomProps, Readonly<import("vue-demi").ExtractPropTypes<{
231
+ }, unknown, {}, {}, import("vue-demi").ComponentOptionsMixin, import("vue-demi").ComponentOptionsMixin, CodeMirrorEmitsOptions, "update:modelValue" | "update" | "focus" | "ready" | "change", import("vue-demi").VNodeProps & import("vue-demi").AllowedComponentProps & import("vue-demi").ComponentCustomProps, Readonly<import("vue-demi").ExtractPropTypes<{
171
232
  /** Model value */
172
233
  modelValue: {
173
234
  type: PropType<string | Text>;
@@ -176,13 +237,13 @@ declare const _default: import("vue-demi").DefineComponent<{
176
237
  /**
177
238
  * Theme
178
239
  *
179
- * @see {@link https://codemirror.net/6/examples/styling/ | Example: Styling}
240
+ * @see {@link https://codemirror.net/docs/ref/#view.EditorView^theme}
180
241
  */
181
242
  theme: {
182
243
  type: PropType<{
183
244
  [selector: string]: StyleSpec;
184
245
  }>;
185
- default: () => {};
246
+ default: () => void;
186
247
  };
187
248
  /** Dark Mode */
188
249
  dark: {
@@ -192,7 +253,7 @@ declare const _default: import("vue-demi").DefineComponent<{
192
253
  /**
193
254
  * Use Basic Setup
194
255
  *
195
- * @see {@link https://codemirror.net/docs/ref/#codemirror.basicSetup | basicSetup}
256
+ * @see {@link https://codemirror.net/docs/ref/#codemirror.basicSetup}
196
257
  */
197
258
  basic: {
198
259
  type: BooleanConstructor;
@@ -201,52 +262,84 @@ declare const _default: import("vue-demi").DefineComponent<{
201
262
  /**
202
263
  * Use Minimal Setup (The basic setting has priority.)
203
264
  *
204
- * @see {@link https://codemirror.net/docs/ref/#codemirror.minimalSetup | minimalSetup}
265
+ * @see {@link https://codemirror.net/docs/ref/#codemirror.minimalSetup}
205
266
  */
206
267
  minimal: {
207
268
  type: BooleanConstructor;
208
269
  default: boolean;
209
270
  };
271
+ /**
272
+ * Placeholder
273
+ *
274
+ * @see {@link https://codemirror.net/docs/ref/#view.placeholder}
275
+ */
276
+ placeholder: {
277
+ type: PropType<string | HTMLElement>;
278
+ default: undefined;
279
+ };
210
280
  /**
211
281
  * Line wrapping
212
282
  *
213
- * @see {@link https://codemirror.net/6/docs/ref/#view.EditorView%5ElineWrapping | LineWrapping}
283
+ * An extension that enables line wrapping in the editor (by setting CSS white-space to pre-wrap in the content).
284
+ *
285
+ * @see {@link https://codemirror.net/docs/ref/#view.EditorView%5ElineWrapping}
214
286
  */
215
287
  wrap: {
216
288
  type: BooleanConstructor;
217
289
  default: boolean;
218
290
  };
219
291
  /**
220
- * Tab handling
292
+ * Allow tab key indent.
221
293
  *
222
- * @see {@link https://codemirror.net/6/examples/tab/ | Tab Handling}
294
+ * @see {@link https://codemirror.net/examples/tab/}
223
295
  */
224
296
  tab: {
225
297
  type: BooleanConstructor;
226
298
  default: boolean;
227
299
  };
300
+ /**
301
+ * Tab size
302
+ *
303
+ * @see {@link https://codemirror.net/docs/ref/#state.EditorState^tabSize}
304
+ */
305
+ tabSize: {
306
+ type: NumberConstructor;
307
+ default: undefined;
308
+ };
309
+ /**
310
+ * Set line break (separetor) char.
311
+ *
312
+ * @see {@link https://codemirror.net/docs/ref/#state.EditorState^lineSeparator}
313
+ */
314
+ lineSeparator: {
315
+ type: StringConstructor;
316
+ default: undefined;
317
+ };
228
318
  /**
229
319
  * Readonly
230
320
  *
231
- * @see {@link https://codemirror.net/6/docs/ref/#state.EditorState%5EreadOnly | readOnly}
321
+ * @see {@link https://codemirror.net/docs/ref/#state.EditorState^readOnly}
232
322
  */
233
323
  readonly: {
234
324
  type: BooleanConstructor;
235
325
  default: boolean;
236
326
  };
237
327
  /**
238
- * Editable
328
+ * Disable input.
329
+ *
330
+ * This is the reversed value of the CodeMirror editable.
331
+ * Similar to `readonly`, but setting this value to true disables dragging.
239
332
  *
240
- * @see {@link https://codemirror.net/6/docs/ref/#view.EditorView%5Eeditable | editable}
333
+ * @see {@link https://codemirror.net/docs/ref/#view.EditorView^editable}
241
334
  */
242
- editable: {
335
+ disabled: {
243
336
  type: BooleanConstructor;
244
337
  default: boolean;
245
338
  };
246
339
  /**
247
340
  * Additional Extension
248
341
  *
249
- * @see {@link https://codemirror.net/6/docs/ref/#state.Extension | Extending Editor State}
342
+ * @see {@link https://codemirror.net/docs/ref/#state.Extension}
250
343
  */
251
344
  extensions: {
252
345
  type: PropType<Extension[]>;
@@ -255,7 +348,7 @@ declare const _default: import("vue-demi").DefineComponent<{
255
348
  /**
256
349
  * Language Phreses
257
350
  *
258
- * @see {@link https://codemirror.net/6/examples/translate/ | Example: Internationalization}
351
+ * @see {@link https://codemirror.net/examples/translate/}
259
352
  */
260
353
  phrases: {
261
354
  type: PropType<Record<string, string>>;
@@ -264,7 +357,7 @@ declare const _default: import("vue-demi").DefineComponent<{
264
357
  /**
265
358
  * CodeMirror Language
266
359
  *
267
- * @see {@link https://codemirror.net/6/docs/ref/#language | @codemirror/language}
360
+ * @see {@link https://codemirror.net/docs/ref/#language}
268
361
  */
269
362
  lang: {
270
363
  type: PropType<LanguageSupport>;
@@ -273,18 +366,45 @@ declare const _default: import("vue-demi").DefineComponent<{
273
366
  /**
274
367
  * CodeMirror Linter
275
368
  *
276
- * @see {@link https://codemirror.net/6/docs/ref/#lint | @codemirror/lint}
369
+ * @see {@link https://codemirror.net/docs/ref/#lint.linter}
277
370
  */
278
371
  linter: {
279
372
  type: PropType<LintSource>;
280
373
  default: undefined;
281
374
  };
282
- /** Show Gutter */
283
- lintGutter: {
375
+ /**
376
+ * Linter Config
377
+ *
378
+ * @see {@link https://codemirror.net/docs/ref/#lint.linter^config}
379
+ */
380
+ linterConfig: {
381
+ type: ObjectConstructor;
382
+ default: () => void;
383
+ };
384
+ /**
385
+ * Show Linter Gutter
386
+ *
387
+ * An area to 🔴 the lines with errors will be displayed.
388
+ * This feature is not enabled if `linter` is not specified.
389
+ *
390
+ * @see {@link https://codemirror.net/docs/ref/#lint.lintGutter}
391
+ */
392
+ gutter: {
284
393
  type: BooleanConstructor;
285
394
  defalt: boolean;
286
395
  };
287
- /** Using tag */
396
+ /**
397
+ * Gutter Config
398
+ *
399
+ * @see {@link https://codemirror.net/docs/ref/#lint.lintGutter^config}
400
+ */
401
+ gutterConfig: {
402
+ type: ObjectConstructor;
403
+ default: () => void;
404
+ };
405
+ /**
406
+ * Using tag
407
+ */
288
408
  tag: {
289
409
  type: StringConstructor;
290
410
  default: string;
@@ -299,15 +419,20 @@ declare const _default: import("vue-demi").DefineComponent<{
299
419
  dark: boolean;
300
420
  basic: boolean;
301
421
  minimal: boolean;
422
+ placeholder: string | HTMLElement;
302
423
  wrap: boolean;
303
424
  tab: boolean;
425
+ tabSize: number;
426
+ lineSeparator: string;
304
427
  readonly: boolean;
305
- editable: boolean;
428
+ disabled: boolean;
306
429
  extensions: Extension[];
307
430
  phrases: Record<string, string>;
308
431
  lang: LanguageSupport;
309
432
  linter: LintSource;
310
- lintGutter: boolean;
433
+ linterConfig: Record<string, any>;
434
+ gutter: boolean;
435
+ gutterConfig: Record<string, any>;
311
436
  tag: string;
312
437
  }>;
313
438
  export default _default;
@@ -1 +1 @@
1
- {"version":3,"file":"CodeMirror.d.ts","sourceRoot":"","sources":["../../src/components/CodeMirror.ts"],"names":[],"mappings":"AAAA,OAAO,EAWL,KAAK,kBAAkB,EACvB,KAAK,QAAQ,EACb,KAAK,GAAG,EACR,KAAK,YAAY,EAElB,MAAM,UAAU,CAAC;AAOlB,OAAO,EAAE,eAAe,EAAE,WAAW,EAAe,MAAM,mBAAmB,CAAC;AAC9E,OAAO,EAAE,UAAU,EAAU,MAAM,kBAAkB,CAAC;AAKtD,OAAO,KAAK,EACV,SAAS,EACT,cAAc,EACd,IAAI,EAEL,M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,EAAE;wBAG3B,MAAM;yBASL,MAAM,EAAE;6BAKJ,OAAO;gCAatB,MAAM,GAAG,IAAI,QACpB,MAAM,MACR,MAAM;oCAW2B,MAAM,GAAG,IAAI;0BAOvB,MAAM;2BAOL,MAAM,SAAS,MAAM;4BASzC,SAAS,cAAc,EAAE,YACvB,MAAM;4BAUa,QAAQ;;IAxdvC,kBAAkB;;;;;IAKlB;;;;OAIG;;;;;;;IAKH,gBAAgB;;;;;IAKhB;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;;;OAMG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;;;;OAOG;;;;;IAKH;;;;OAIG;;;;;IAOH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;;;;OAOG;;;;;IAKH;;;;OAIG;;;;;IAKH;;OAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAzLP,wBAwhBG"}
package/dist/index.es.js CHANGED
@@ -5,17 +5,17 @@
5
5
  * @author Logue <logue@hotmail.co.jp>
6
6
  * @copyright 2022 By Masashi Yoshikawa All rights reserved.
7
7
  * @license MIT
8
- * @version 1.0.3
8
+ * @version 1.1.1
9
9
  * @see {@link https://github.com/logue/vue-codemirror6}
10
10
  */
11
11
 
12
- import { isVue2, Vue2, h as h$1, defineComponent, ref, shallowRef, computed, toRaw, watch, onMounted, nextTick, onUnmounted } from 'vue-demi';
12
+ import { isVue2, Vue2, h as h$1, defineComponent, ref, shallowRef, computed, watch, onMounted, nextTick, onUnmounted } from 'vue-demi';
13
13
  import { compact, trim } from 'lodash';
14
- import { EditorState, StateEffect, EditorSelection } from '@codemirror/state';
15
- import { EditorView, keymap } from '@codemirror/view';
16
- import { linter, lintGutter } from '@codemirror/lint';
17
14
  import { basicSetup, minimalSetup } from 'codemirror';
15
+ import { EditorState, StateEffect, EditorSelection } from '@codemirror/state';
16
+ import { EditorView, keymap, placeholder } from '@codemirror/view';
18
17
  import { indentWithTab } from '@codemirror/commands';
18
+ import { linter, lintGutter, forceLinting } from '@codemirror/lint';
19
19
 
20
20
  const adaptOnsV3 = (ons) => {
21
21
  if (!ons)
@@ -54,7 +54,6 @@ const CodeMirror = defineComponent({
54
54
  theme: {
55
55
  type: Object,
56
56
  default: () => {
57
- return {};
58
57
  }
59
58
  },
60
59
  dark: {
@@ -69,6 +68,10 @@ const CodeMirror = defineComponent({
69
68
  type: Boolean,
70
69
  default: false
71
70
  },
71
+ placeholder: {
72
+ type: String,
73
+ default: void 0
74
+ },
72
75
  wrap: {
73
76
  type: Boolean,
74
77
  default: false
@@ -77,13 +80,21 @@ const CodeMirror = defineComponent({
77
80
  type: Boolean,
78
81
  default: false
79
82
  },
83
+ tabSize: {
84
+ type: Number,
85
+ default: void 0
86
+ },
87
+ lineSeparator: {
88
+ type: String,
89
+ default: void 0
90
+ },
80
91
  readonly: {
81
92
  type: Boolean,
82
93
  default: false
83
94
  },
84
- editable: {
95
+ disabled: {
85
96
  type: Boolean,
86
- default: true
97
+ default: false
87
98
  },
88
99
  extensions: {
89
100
  type: Array,
@@ -103,16 +114,26 @@ const CodeMirror = defineComponent({
103
114
  type: Function,
104
115
  default: void 0
105
116
  },
106
- lintGutter: {
117
+ linterConfig: {
118
+ type: Object,
119
+ default: () => {
120
+ }
121
+ },
122
+ gutter: {
107
123
  type: Boolean,
108
124
  defalt: false
109
125
  },
126
+ gutterConfig: {
127
+ type: Object,
128
+ default: () => {
129
+ }
130
+ },
110
131
  tag: {
111
132
  type: String,
112
133
  default: "div"
113
134
  }
114
135
  },
115
- emits: ["update:modelValue", "update", "ready", "focus", "changed"],
136
+ emits: ["update:modelValue", "update", "ready", "focus", "change"],
116
137
  setup(props, context) {
117
138
  const editor = ref();
118
139
  const doc = ref(props.modelValue);
@@ -121,14 +142,14 @@ const CodeMirror = defineComponent({
121
142
  get: () => view.value.state.selection,
122
143
  set: (s) => view.value.dispatch({ selection: s })
123
144
  });
124
- const cursor = computed({
125
- get: () => selection.value.main.head || 0,
126
- set: (a) => view.value.dispatch({ selection: { anchor: a } })
127
- });
128
145
  const state = computed({
129
146
  get: () => view.value.state,
130
147
  set: (s) => view.value.setState(s)
131
148
  });
149
+ const cursor = computed({
150
+ get: () => view.value.state.selection.main.head || 0,
151
+ set: (a) => view.value.dispatch({ selection: { anchor: a } })
152
+ });
132
153
  const focus = computed({
133
154
  get: () => view.value.hasFocus,
134
155
  set: (f) => {
@@ -137,6 +158,9 @@ const CodeMirror = defineComponent({
137
158
  }
138
159
  }
139
160
  });
161
+ const length = computed(
162
+ () => view.value.state.doc.length
163
+ );
140
164
  const extensions = computed(
141
165
  () => compact([
142
166
  props.basic ? basicSetup : void 0,
@@ -147,37 +171,39 @@ const CodeMirror = defineComponent({
147
171
  EditorView.theme(props.theme, { dark: props.dark }),
148
172
  props.wrap ? EditorView.lineWrapping : void 0,
149
173
  props.tab ? keymap.of([indentWithTab]) : void 0,
174
+ props.tabSize ? EditorState.tabSize.of(props.tabSize) : void 0,
150
175
  props.phrases ? EditorState.phrases.of(props.phrases) : void 0,
151
176
  EditorState.readOnly.of(props.readonly),
152
- EditorView.editable.of(props.editable),
153
- props.lang ? toRaw(props.lang) : void 0,
154
- props.linter ? linter(props.linter) : void 0,
155
- props.linter && props.lintGutter ? lintGutter() : void 0,
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,
156
183
  ...props.extensions
157
184
  ])
158
185
  );
159
186
  watch(
160
187
  () => props.modelValue,
161
188
  (value) => {
162
- if (!view.value || view.value.composing) {
189
+ if (view.value.composing) {
163
190
  return;
164
191
  }
165
- const previous = view.value.state.selection;
166
192
  view.value.dispatch({
167
193
  changes: { from: 0, to: view.value.state.doc.length, insert: value },
168
- selection: previous
194
+ selection: view.value.state.selection,
195
+ scrollIntoView: true
169
196
  });
170
197
  },
171
198
  { immediate: true }
172
199
  );
173
- watch(extensions, (e) => {
174
- view.value.dispatch({
175
- effects: StateEffect.reconfigure.of(e)
176
- });
177
- });
178
- watch(focus, (isFocus) => {
179
- context.emit("focus", isFocus);
180
- });
200
+ watch(
201
+ extensions,
202
+ (exts) => view.value.dispatch({
203
+ effects: StateEffect.reconfigure.of(exts)
204
+ })
205
+ );
206
+ watch(focus, (isFocus) => context.emit("focus", isFocus));
181
207
  onMounted(async () => {
182
208
  let value = doc.value;
183
209
  if (editor.value && editor.value.childNodes[0]) {
@@ -194,7 +220,7 @@ const CodeMirror = defineComponent({
194
220
  return;
195
221
  const v = view.value.state.doc.toString();
196
222
  context.emit("update:modelValue", v);
197
- context.emit("changed", v);
223
+ context.emit("change", v);
198
224
  }
199
225
  });
200
226
  await nextTick();
@@ -204,7 +230,10 @@ const CodeMirror = defineComponent({
204
230
  container: editor.value
205
231
  });
206
232
  });
207
- onUnmounted(() => view.value.destroy());
233
+ onUnmounted(() => {
234
+ view.value.destroy();
235
+ });
236
+ const lint = () => forceLinting(view.value);
208
237
  const getRange = (from, to) => view.value.state.sliceDoc(from, to);
209
238
  const getLine = (number) => view.value.state.doc.line(number + 1).text;
210
239
  const lineCount = () => view.value.state.doc.lines;
@@ -241,6 +270,8 @@ const CodeMirror = defineComponent({
241
270
  selection,
242
271
  state,
243
272
  focus,
273
+ length,
274
+ lint,
244
275
  getRange,
245
276
  getLine,
246
277
  lineCount,
@@ -274,8 +305,8 @@ const CodeMirror = defineComponent({
274
305
  });
275
306
 
276
307
  const meta = {
277
- version: "1.0.3",
278
- date: "2022-10-11T23:57:24.765Z"
308
+ version: "1.1.1",
309
+ date: "2022-11-07T00:40:00.830Z"
279
310
  };
280
311
 
281
312
  const installCodeMirror = (app) => app.component("CodeMirror", CodeMirror);