vue-codemirror6 1.3.3 → 1.3.4

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.es.js CHANGED
@@ -5,7 +5,7 @@
5
5
  * @author Logue <logue@hotmail.co.jp>
6
6
  * @copyright 2022-2024 By Masashi Yoshikawa All rights reserved.
7
7
  * @license MIT
8
- * @version 1.3.2
8
+ * @version 1.3.4
9
9
  * @see {@link https://github.com/logue/vue-codemirror6}
10
10
  */
11
11
 
@@ -13,22 +13,22 @@ import { indentWithTab as G } from "@codemirror/commands";
13
13
  import { indentUnit as I } from "@codemirror/language";
14
14
  import { forceLinting as b, linter as P, lintGutter as Z, diagnosticCount as k } from "@codemirror/lint";
15
15
  import { EditorState as s, Compartment as C, StateEffect as y, EditorSelection as w } from "@codemirror/state";
16
- import { EditorView as r, keymap as q, placeholder as H } from "@codemirror/view";
16
+ import { EditorView as c, keymap as q, placeholder as H } from "@codemirror/view";
17
17
  import { basicSetup as K, minimalSetup as Q } from "codemirror";
18
- import { isVue2 as X, h as O, defineComponent as Y, ref as v, shallowRef as ee, computed as d, watch as $, onMounted as te, nextTick as ae, onUnmounted as ne } from "vue-demi";
18
+ import { isVue2 as X, h as O, defineComponent as Y, ref as v, shallowRef as ee, computed as r, watch as $, onMounted as te, nextTick as ae, onUnmounted as ne } from "vue-demi";
19
19
  const ie = {
20
- version: "1.3.2",
21
- date: "2024-06-10T11:57:17.342Z"
20
+ version: "1.3.4",
21
+ date: "2024-07-11T09:11:00.140Z"
22
22
  };
23
- var ge = ie;
23
+ var he = ie;
24
24
  const le = (e) => e ? Object.entries(e).reduce((l, [i, u]) => (i = i.charAt(0).toUpperCase() + i.slice(1), i = `on${i}`, { ...l, [i]: u }), {}) : {};
25
25
  function B(e, l = {}, i) {
26
26
  if (X)
27
27
  return O(e, l, i);
28
- const { props: u, domProps: t, on: f, ...c } = l, m = f ? le(f) : {};
28
+ const { props: u, domProps: t, on: d, ...f } = l, m = d ? le(d) : {};
29
29
  return O(
30
30
  e,
31
- { ...c, ...u, ...t, ...m },
31
+ { ...f, ...u, ...t, ...m },
32
32
  i
33
33
  );
34
34
  }
@@ -272,23 +272,23 @@ var se = Y({
272
272
  * @param context - Context
273
273
  */
274
274
  setup(e, l) {
275
- const i = v(), u = v(e.modelValue), t = ee(new r()), f = d({
275
+ const i = v(), u = v(e.modelValue), t = ee(new c()), d = r({
276
276
  get: () => t.value.hasFocus,
277
277
  set: (a) => {
278
278
  a && t.value.focus();
279
279
  }
280
- }), c = d({
280
+ }), f = r({
281
281
  get: () => t.value.state.selection,
282
282
  set: (a) => t.value.dispatch({ selection: a })
283
- }), m = d({
283
+ }), m = r({
284
284
  get: () => t.value.state.selection.main.head,
285
285
  set: (a) => t.value.dispatch({ selection: { anchor: a } })
286
- }), M = d(
286
+ }), M = r(
287
287
  {
288
288
  get: () => t.value.state.toJSON(),
289
289
  set: (a) => t.value.setState(s.fromJSON(a))
290
290
  }
291
- ), S = v(0), g = v(0), h = d(() => {
291
+ ), S = v(0), h = v(0), g = r(() => {
292
292
  const a = new C(), n = new C();
293
293
  if (e.basic && e.minimal)
294
294
  throw "[Vue CodeMirror] Both basic and minimal cannot be specified.";
@@ -298,13 +298,13 @@ var se = Y({
298
298
  // Toggle minimal setup
299
299
  e.minimal && !e.basic ? Q : void 0,
300
300
  // ViewUpdate event listener
301
- r.updateListener.of((o) => {
302
- l.emit("focus", t.value.hasFocus), S.value = t.value.state.doc?.length, !(o.changes.empty || !o.docChanged) && (e.linter && (e.forceLinting && b(t.value), g.value = e.linter(t.value).length), l.emit("update", o));
301
+ c.updateListener.of((o) => {
302
+ l.emit("focus", t.value.hasFocus), S.value = t.value.state.doc?.length, !(o.changes.empty || !o.docChanged) && (e.linter && (e.forceLinting && b(t.value), h.value = e.linter(t.value).length), l.emit("update", o));
303
303
  }),
304
304
  // Toggle light/dark mode.
305
- r.theme(e.theme, { dark: e.dark }),
305
+ c.theme(e.theme, { dark: e.dark }),
306
306
  // Toggle line wrapping
307
- e.wrap ? r.lineWrapping : void 0,
307
+ e.wrap ? c.lineWrapping : void 0,
308
308
  // Indent with tab
309
309
  e.tab ? q.of([G]) : void 0,
310
310
  // Tab character
@@ -318,7 +318,7 @@ var se = Y({
318
318
  // Readonly option
319
319
  s.readOnly.of(e.readonly),
320
320
  // Editable option
321
- r.editable.of(!e.disabled),
321
+ c.editable.of(!e.disabled),
322
322
  // Set Line break char
323
323
  e.lineSeparator ? s.lineSeparator.of(e.lineSeparator) : void 0,
324
324
  // Lang
@@ -334,7 +334,7 @@ var se = Y({
334
334
  ].filter((o) => !!o);
335
335
  });
336
336
  $(
337
- h,
337
+ g,
338
338
  (a) => {
339
339
  t.value?.dispatch({
340
340
  effects: y.reconfigure.of(a)
@@ -344,13 +344,16 @@ var se = Y({
344
344
  ), $(
345
345
  () => e.modelValue,
346
346
  async (a) => {
347
- t.value.composing || // IME fix
347
+ if (t.value.composing || // IME fix
348
348
  t.value.state.doc.toJSON().join(e.lineSeparator ?? `
349
- `) === a || c.value.ranges.every(
350
- (n) => n.anchor < a.length && n.head < a.length
351
- ) && t.value.dispatch({
349
+ `) === a)
350
+ return;
351
+ const n = !t.value.state.selection.ranges.every(
352
+ (o) => o.anchor < a.length && o.head < a.length
353
+ );
354
+ t.value.dispatch({
352
355
  changes: { from: 0, to: t.value.state.doc.length, insert: a },
353
- selection: t.value.state.selection,
356
+ selection: n ? { anchor: 0, head: 0 } : t.value.state.selection,
354
357
  scrollIntoView: !0
355
358
  });
356
359
  },
@@ -359,9 +362,9 @@ var se = Y({
359
362
  let a = u.value;
360
363
  i.value && (i.value.childNodes[0] && (u.value !== "" && console.warn(
361
364
  "[CodeMirror.vue] The <code-mirror> tag contains child elements that overwrite the `v-model` values."
362
- ), a = i.value.childNodes[0].innerText.trim()), t.value = new r({
365
+ ), a = i.value.childNodes[0].innerText.trim()), t.value = new c({
363
366
  parent: i.value,
364
- state: s.create({ doc: a, extensions: h.value }),
367
+ state: s.create({ doc: a, extensions: g.value }),
365
368
  dispatch: (n) => {
366
369
  t.value.update([n]), !(n.changes.empty || !n.docChanged) && (l.emit("update:modelValue", n.state.doc.toString() ?? ""), l.emit("change", n.state));
367
370
  }
@@ -374,12 +377,12 @@ var se = Y({
374
377
  t.value.destroy(), l.emit("destroy");
375
378
  });
376
379
  const V = () => {
377
- !e.linter || !t.value || (e.forceLinting && b(t.value), g.value = k(t.value.state));
380
+ !e.linter || !t.value || (e.forceLinting && b(t.value), h.value = k(t.value.state));
378
381
  }, j = () => {
379
382
  t.value?.dispatch({
380
383
  effects: y.reconfigure.of([])
381
384
  }), t.value?.dispatch({
382
- effects: y.appendConfig.of(h.value)
385
+ effects: y.appendConfig.of(g.value)
383
386
  });
384
387
  }, x = (a, n) => t.value.state.sliceDoc(a, n), _ = (a) => t.value.state.doc.line(a + 1).text, L = () => t.value.state.doc.lines, N = () => t.value.state.selection.main.head, U = () => {
385
388
  let a;
@@ -390,30 +393,30 @@ var se = Y({
390
393
  t.value.state.selection.main.from,
391
394
  t.value.state.selection.main.to
392
395
  )) !== null && a !== void 0 ? a : "";
393
- }, T = () => {
396
+ }, R = () => {
394
397
  const a = t.value.state;
395
398
  return a ? a.selection.ranges.map(
396
399
  (n) => a.sliceDoc(n.from, n.to)
397
400
  ) : [];
398
- }, D = () => t.value.state.selection.ranges.some(
401
+ }, T = () => t.value.state.selection.ranges.some(
399
402
  (a) => !a.empty
400
- ), E = (a, n, o) => t.value.dispatch({
403
+ ), D = (a, n, o) => t.value.dispatch({
401
404
  changes: { from: n, to: o, insert: a }
402
- }), R = (a) => t.value.dispatch(t.value.state.replaceSelection(a)), F = (a) => t.value.dispatch({ selection: { anchor: a } }), J = (a, n) => t.value.dispatch({ selection: { anchor: a, head: n } }), A = (a, n) => t.value.dispatch({
405
+ }), E = (a) => t.value.dispatch(t.value.state.replaceSelection(a)), F = (a) => t.value.dispatch({ selection: { anchor: a } }), J = (a, n) => t.value.dispatch({ selection: { anchor: a, head: n } }), A = (a, n) => t.value.dispatch({
403
406
  selection: w.create(a, n)
404
407
  }), W = (a) => t.value.dispatch({
405
408
  selection: w.create(
406
- c.value.ranges.map((n) => n.extend(a(n)))
409
+ f.value.ranges.map((n) => n.extend(a(n)))
407
410
  )
408
411
  }), p = {
409
412
  editor: i,
410
413
  view: t,
411
414
  cursor: m,
412
- selection: c,
413
- focus: f,
415
+ selection: f,
416
+ focus: d,
414
417
  length: S,
415
418
  json: M,
416
- diagnosticCount: g,
419
+ diagnosticCount: h,
417
420
  dom: t.value.contentDOM,
418
421
  lint: V,
419
422
  forceReconfigure: j,
@@ -424,10 +427,10 @@ var se = Y({
424
427
  getCursor: N,
425
428
  listSelections: U,
426
429
  getSelection: z,
427
- getSelections: T,
428
- somethingSelected: D,
429
- replaceRange: E,
430
- replaceSelection: R,
430
+ getSelections: R,
431
+ somethingSelected: T,
432
+ replaceRange: D,
433
+ replaceSelection: E,
431
434
  setCursor: F,
432
435
  setSelection: J,
433
436
  setSelections: A,
@@ -453,9 +456,9 @@ var se = Y({
453
456
  );
454
457
  }
455
458
  });
456
- const he = (e) => e.component("CodeMirror", se);
459
+ const ge = (e) => e.component("CodeMirror", se);
457
460
  export {
458
- ge as Meta,
461
+ he as Meta,
459
462
  se as default,
460
- he as install
463
+ ge as install
461
464
  };
@@ -5,9 +5,9 @@
5
5
  * @author Logue <logue@hotmail.co.jp>
6
6
  * @copyright 2022-2024 By Masashi Yoshikawa All rights reserved.
7
7
  * @license MIT
8
- * @version 1.3.2
8
+ * @version 1.3.4
9
9
  * @see {@link https://github.com/logue/vue-codemirror6}
10
10
  */
11
11
 
12
- var CodeMirror=function(u,E,V,f,i,c,y,l){"use strict";var M={version:"1.3.2",date:"2024-06-10T11:57:17.342Z"};const O=e=>e?Object.entries(e).reduce((r,[o,s])=>(o=o.charAt(0).toUpperCase()+o.slice(1),o=`on${o}`,{...r,[o]:s}),{}):{};function b(e,r={},o){if(l.isVue2)return l.h(e,r,o);const{props:s,domProps:t,on:g,...v}=r,h=g?O(g):{};return l.h(e,{...v,...s,...t,...h},o)}const $=e=>typeof e=="function"?e():e;var C=l.defineComponent({name:"CodeMirror",model:{prop:"modelValue",event:"update:modelValue"},props:{modelValue:{type:String,default:""},theme:{type:Object,default:()=>({})},dark:{type:Boolean,default:!1},basic:{type:Boolean,default:!1},minimal:{type:Boolean,default:!1},placeholder:{type:String,default:void 0},wrap:{type:Boolean,default:!1},tab:{type:Boolean,default:!1},indentUnit:{type:String,default:void 0},allowMultipleSelections:{type:Boolean,default:!1},tabSize:{type:Number,default:void 0},lineSeparator:{type:String,default:void 0},readonly:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},extensions:{type:Array,default:()=>[]},phrases:{type:Object,default:()=>{}},lang:{type:Object,default:()=>{}},linter:{type:Function,default:void 0},linterConfig:{type:Object,default:()=>({})},forceLinting:{type:Boolean,default:!1},gutter:{type:Boolean,default:!1},gutterConfig:{type:Object,default:()=>{}},tag:{type:String,default:"div"}},emits:{"update:modelValue":(e="")=>!0,update:e=>!0,ready:e=>!0,focus:e=>!0,change:e=>!0,destroy:()=>!0},setup(e,r){const o=l.ref(),s=l.ref(e.modelValue),t=l.shallowRef(new c.EditorView),g=l.computed({get:()=>t.value.hasFocus,set:a=>{a&&t.value.focus()}}),v=l.computed({get:()=>t.value.state.selection,set:a=>t.value.dispatch({selection:a})}),h=l.computed({get:()=>t.value.state.selection.main.head,set:a=>t.value.dispatch({selection:{anchor:a}})}),j=l.computed({get:()=>t.value.state.toJSON(),set:a=>t.value.setState(i.EditorState.fromJSON(a))}),w=l.ref(0),m=l.ref(0),S=l.computed(()=>{const a=new i.Compartment,n=new i.Compartment;if(e.basic&&e.minimal)throw"[Vue CodeMirror] Both basic and minimal cannot be specified.";return[e.basic&&!e.minimal?y.basicSetup:void 0,e.minimal&&!e.basic?y.minimalSetup:void 0,c.EditorView.updateListener.of(d=>{r.emit("focus",t.value.hasFocus),w.value=t.value.state.doc?.length,!(d.changes.empty||!d.docChanged)&&(e.linter&&(e.forceLinting&&f.forceLinting(t.value),m.value=e.linter(t.value).length),r.emit("update",d))}),c.EditorView.theme(e.theme,{dark:e.dark}),e.wrap?c.EditorView.lineWrapping:void 0,e.tab?c.keymap.of([E.indentWithTab]):void 0,e.indentUnit?V.indentUnit.of(e.indentUnit):void 0,i.EditorState.allowMultipleSelections.of(e.allowMultipleSelections),e.tabSize?n.of(i.EditorState.tabSize.of(e.tabSize)):void 0,e.phrases?i.EditorState.phrases.of(e.phrases):void 0,i.EditorState.readOnly.of(e.readonly),c.EditorView.editable.of(!e.disabled),e.lineSeparator?i.EditorState.lineSeparator.of(e.lineSeparator):void 0,e.lang?a.of(e.lang):void 0,e.linter?f.linter(e.linter,e.linterConfig):void 0,e.linter&&e.gutter?f.lintGutter(e.gutterConfig):void 0,e.placeholder?c.placeholder(e.placeholder):void 0,...e.extensions].filter(d=>!!d)});l.watch(S,a=>{t.value?.dispatch({effects:i.StateEffect.reconfigure.of(a)})},{immediate:!0}),l.watch(()=>e.modelValue,async a=>{t.value.composing||t.value.state.doc.toJSON().join(e.lineSeparator??`
13
- `)===a||v.value.ranges.every(n=>n.anchor<a.length&&n.head<a.length)&&t.value.dispatch({changes:{from:0,to:t.value.state.doc.length,insert:a},selection:t.value.state.selection,scrollIntoView:!0})},{immediate:!0}),l.onMounted(async()=>{let a=s.value;o.value&&(o.value.childNodes[0]&&(s.value!==""&&console.warn("[CodeMirror.vue] The <code-mirror> tag contains child elements that overwrite the `v-model` values."),a=o.value.childNodes[0].innerText.trim()),t.value=new c.EditorView({parent:o.value,state:i.EditorState.create({doc:a,extensions:S.value}),dispatch:n=>{t.value.update([n]),!(n.changes.empty||!n.docChanged)&&(r.emit("update:modelValue",n.state.doc.toString()??""),r.emit("change",n.state))}}),await l.nextTick(),r.emit("ready",{view:t.value,state:t.value.state,container:o.value}))}),l.onUnmounted(()=>{t.value.destroy(),r.emit("destroy")});const _=()=>{!e.linter||!t.value||(e.forceLinting&&f.forceLinting(t.value),m.value=f.diagnosticCount(t.value.state))},L=()=>{t.value?.dispatch({effects:i.StateEffect.reconfigure.of([])}),t.value?.dispatch({effects:i.StateEffect.appendConfig.of(S.value)})},N=(a,n)=>t.value.state.sliceDoc(a,n),U=a=>t.value.state.doc.line(a+1).text,z=()=>t.value.state.doc.lines,T=()=>t.value.state.selection.main.head,R=()=>{let a;return(a=t.value.state.selection.ranges)!==null&&a!==void 0?a:[]},F=()=>{let a;return(a=t.value.state.sliceDoc(t.value.state.selection.main.from,t.value.state.selection.main.to))!==null&&a!==void 0?a:""},J=()=>{const a=t.value.state;return a?a.selection.ranges.map(n=>a.sliceDoc(n.from,n.to)):[]},x=()=>t.value.state.selection.ranges.some(a=>!a.empty),A=(a,n,d)=>t.value.dispatch({changes:{from:n,to:d,insert:a}}),P=a=>t.value.dispatch(t.value.state.replaceSelection(a)),W=a=>t.value.dispatch({selection:{anchor:a}}),G=(a,n)=>t.value.dispatch({selection:{anchor:a,head:n}}),I=(a,n)=>t.value.dispatch({selection:i.EditorSelection.create(a,n)}),Z=a=>t.value.dispatch({selection:i.EditorSelection.create(v.value.ranges.map(n=>n.extend(a(n))))}),p={editor:o,view:t,cursor:h,selection:v,focus:g,length:w,json:j,diagnosticCount:m,dom:t.value.contentDOM,lint:_,forceReconfigure:L,getRange:N,getLine:U,lineCount:z,getCursor:T,listSelections:R,getSelection:F,getSelections:J,somethingSelected:x,replaceRange:A,replaceSelection:P,setCursor:W,setSelection:G,setSelections:I,extendSelectionsBy:Z};return r.expose(p),p},render(){return b(this.$props.tag,{ref:"editor",class:"vue-codemirror"},this.$slots.default?b("aside",{style:"display: none;","aria-hidden":"true"},$(this.$slots.default)):void 0)}});const B=e=>e.component("CodeMirror",C);return u.Meta=M,u.default=C,u.install=B,Object.defineProperty(u,"__esModule",{value:!0}),u}({},commands,language,lint,state,view,codemirror,VueDemi);
12
+ var CodeMirror=function(u,E,V,f,i,d,y,l){"use strict";var O={version:"1.3.4",date:"2024-07-11T09:11:00.140Z"};const M=e=>e?Object.entries(e).reduce((c,[o,s])=>(o=o.charAt(0).toUpperCase()+o.slice(1),o=`on${o}`,{...c,[o]:s}),{}):{};function b(e,c={},o){if(l.isVue2)return l.h(e,c,o);const{props:s,domProps:t,on:v,...g}=c,h=v?M(v):{};return l.h(e,{...g,...s,...t,...h},o)}const $=e=>typeof e=="function"?e():e;var C=l.defineComponent({name:"CodeMirror",model:{prop:"modelValue",event:"update:modelValue"},props:{modelValue:{type:String,default:""},theme:{type:Object,default:()=>({})},dark:{type:Boolean,default:!1},basic:{type:Boolean,default:!1},minimal:{type:Boolean,default:!1},placeholder:{type:String,default:void 0},wrap:{type:Boolean,default:!1},tab:{type:Boolean,default:!1},indentUnit:{type:String,default:void 0},allowMultipleSelections:{type:Boolean,default:!1},tabSize:{type:Number,default:void 0},lineSeparator:{type:String,default:void 0},readonly:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},extensions:{type:Array,default:()=>[]},phrases:{type:Object,default:()=>{}},lang:{type:Object,default:()=>{}},linter:{type:Function,default:void 0},linterConfig:{type:Object,default:()=>({})},forceLinting:{type:Boolean,default:!1},gutter:{type:Boolean,default:!1},gutterConfig:{type:Object,default:()=>{}},tag:{type:String,default:"div"}},emits:{"update:modelValue":(e="")=>!0,update:e=>!0,ready:e=>!0,focus:e=>!0,change:e=>!0,destroy:()=>!0},setup(e,c){const o=l.ref(),s=l.ref(e.modelValue),t=l.shallowRef(new d.EditorView),v=l.computed({get:()=>t.value.hasFocus,set:a=>{a&&t.value.focus()}}),g=l.computed({get:()=>t.value.state.selection,set:a=>t.value.dispatch({selection:a})}),h=l.computed({get:()=>t.value.state.selection.main.head,set:a=>t.value.dispatch({selection:{anchor:a}})}),j=l.computed({get:()=>t.value.state.toJSON(),set:a=>t.value.setState(i.EditorState.fromJSON(a))}),w=l.ref(0),m=l.ref(0),S=l.computed(()=>{const a=new i.Compartment,n=new i.Compartment;if(e.basic&&e.minimal)throw"[Vue CodeMirror] Both basic and minimal cannot be specified.";return[e.basic&&!e.minimal?y.basicSetup:void 0,e.minimal&&!e.basic?y.minimalSetup:void 0,d.EditorView.updateListener.of(r=>{c.emit("focus",t.value.hasFocus),w.value=t.value.state.doc?.length,!(r.changes.empty||!r.docChanged)&&(e.linter&&(e.forceLinting&&f.forceLinting(t.value),m.value=e.linter(t.value).length),c.emit("update",r))}),d.EditorView.theme(e.theme,{dark:e.dark}),e.wrap?d.EditorView.lineWrapping:void 0,e.tab?d.keymap.of([E.indentWithTab]):void 0,e.indentUnit?V.indentUnit.of(e.indentUnit):void 0,i.EditorState.allowMultipleSelections.of(e.allowMultipleSelections),e.tabSize?n.of(i.EditorState.tabSize.of(e.tabSize)):void 0,e.phrases?i.EditorState.phrases.of(e.phrases):void 0,i.EditorState.readOnly.of(e.readonly),d.EditorView.editable.of(!e.disabled),e.lineSeparator?i.EditorState.lineSeparator.of(e.lineSeparator):void 0,e.lang?a.of(e.lang):void 0,e.linter?f.linter(e.linter,e.linterConfig):void 0,e.linter&&e.gutter?f.lintGutter(e.gutterConfig):void 0,e.placeholder?d.placeholder(e.placeholder):void 0,...e.extensions].filter(r=>!!r)});l.watch(S,a=>{t.value?.dispatch({effects:i.StateEffect.reconfigure.of(a)})},{immediate:!0}),l.watch(()=>e.modelValue,async a=>{if(t.value.composing||t.value.state.doc.toJSON().join(e.lineSeparator??`
13
+ `)===a)return;const n=!t.value.state.selection.ranges.every(r=>r.anchor<a.length&&r.head<a.length);t.value.dispatch({changes:{from:0,to:t.value.state.doc.length,insert:a},selection:n?{anchor:0,head:0}:t.value.state.selection,scrollIntoView:!0})},{immediate:!0}),l.onMounted(async()=>{let a=s.value;o.value&&(o.value.childNodes[0]&&(s.value!==""&&console.warn("[CodeMirror.vue] The <code-mirror> tag contains child elements that overwrite the `v-model` values."),a=o.value.childNodes[0].innerText.trim()),t.value=new d.EditorView({parent:o.value,state:i.EditorState.create({doc:a,extensions:S.value}),dispatch:n=>{t.value.update([n]),!(n.changes.empty||!n.docChanged)&&(c.emit("update:modelValue",n.state.doc.toString()??""),c.emit("change",n.state))}}),await l.nextTick(),c.emit("ready",{view:t.value,state:t.value.state,container:o.value}))}),l.onUnmounted(()=>{t.value.destroy(),c.emit("destroy")});const _=()=>{!e.linter||!t.value||(e.forceLinting&&f.forceLinting(t.value),m.value=f.diagnosticCount(t.value.state))},L=()=>{t.value?.dispatch({effects:i.StateEffect.reconfigure.of([])}),t.value?.dispatch({effects:i.StateEffect.appendConfig.of(S.value)})},N=(a,n)=>t.value.state.sliceDoc(a,n),U=a=>t.value.state.doc.line(a+1).text,z=()=>t.value.state.doc.lines,R=()=>t.value.state.selection.main.head,T=()=>{let a;return(a=t.value.state.selection.ranges)!==null&&a!==void 0?a:[]},F=()=>{let a;return(a=t.value.state.sliceDoc(t.value.state.selection.main.from,t.value.state.selection.main.to))!==null&&a!==void 0?a:""},J=()=>{const a=t.value.state;return a?a.selection.ranges.map(n=>a.sliceDoc(n.from,n.to)):[]},x=()=>t.value.state.selection.ranges.some(a=>!a.empty),A=(a,n,r)=>t.value.dispatch({changes:{from:n,to:r,insert:a}}),P=a=>t.value.dispatch(t.value.state.replaceSelection(a)),W=a=>t.value.dispatch({selection:{anchor:a}}),G=(a,n)=>t.value.dispatch({selection:{anchor:a,head:n}}),I=(a,n)=>t.value.dispatch({selection:i.EditorSelection.create(a,n)}),Z=a=>t.value.dispatch({selection:i.EditorSelection.create(g.value.ranges.map(n=>n.extend(a(n))))}),p={editor:o,view:t,cursor:h,selection:g,focus:v,length:w,json:j,diagnosticCount:m,dom:t.value.contentDOM,lint:_,forceReconfigure:L,getRange:N,getLine:U,lineCount:z,getCursor:R,listSelections:T,getSelection:F,getSelections:J,somethingSelected:x,replaceRange:A,replaceSelection:P,setCursor:W,setSelection:G,setSelections:I,extendSelectionsBy:Z};return c.expose(p),p},render(){return b(this.$props.tag,{ref:"editor",class:"vue-codemirror"},this.$slots.default?b("aside",{style:"display: none;","aria-hidden":"true"},$(this.$slots.default)):void 0)}});const B=e=>e.component("CodeMirror",C);return u.Meta=O,u.default=C,u.install=B,Object.defineProperty(u,"__esModule",{value:!0}),u}({},commands,language,lint,state,view,codemirror,VueDemi);
package/dist/index.umd.js CHANGED
@@ -5,9 +5,9 @@
5
5
  * @author Logue <logue@hotmail.co.jp>
6
6
  * @copyright 2022-2024 By Masashi Yoshikawa All rights reserved.
7
7
  * @license MIT
8
- * @version 1.3.2
8
+ * @version 1.3.4
9
9
  * @see {@link https://github.com/logue/vue-codemirror6}
10
10
  */
11
11
 
12
- (function(l,f){typeof exports=="object"&&typeof module<"u"?f(exports,require("@codemirror/commands"),require("@codemirror/language"),require("@codemirror/lint"),require("@codemirror/state"),require("@codemirror/view"),require("codemirror"),require("vue-demi")):typeof define=="function"&&define.amd?define(["exports","@codemirror/commands","@codemirror/language","@codemirror/lint","@codemirror/state","@codemirror/view","codemirror","vue-demi"],f):(l=typeof globalThis<"u"?globalThis:l||self,f(l.CodeMirror={},l.commands,l.language,l.lint,l.state,l.view,l.codemirror,l.VueDemi))})(this,function(l,f,V,v,r,c,p,i){"use strict";var M={version:"1.3.2",date:"2024-06-10T11:57:17.342Z"};const O=e=>e?Object.entries(e).reduce((d,[o,u])=>(o=o.charAt(0).toUpperCase()+o.slice(1),o=`on${o}`,{...d,[o]:u}),{}):{};function w(e,d={},o){if(i.isVue2)return i.h(e,d,o);const{props:u,domProps:t,on:h,...m}=d,g=h?O(h):{};return i.h(e,{...m,...u,...t,...g},o)}const $=e=>typeof e=="function"?e():e;var C=i.defineComponent({name:"CodeMirror",model:{prop:"modelValue",event:"update:modelValue"},props:{modelValue:{type:String,default:""},theme:{type:Object,default:()=>({})},dark:{type:Boolean,default:!1},basic:{type:Boolean,default:!1},minimal:{type:Boolean,default:!1},placeholder:{type:String,default:void 0},wrap:{type:Boolean,default:!1},tab:{type:Boolean,default:!1},indentUnit:{type:String,default:void 0},allowMultipleSelections:{type:Boolean,default:!1},tabSize:{type:Number,default:void 0},lineSeparator:{type:String,default:void 0},readonly:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},extensions:{type:Array,default:()=>[]},phrases:{type:Object,default:()=>{}},lang:{type:Object,default:()=>{}},linter:{type:Function,default:void 0},linterConfig:{type:Object,default:()=>({})},forceLinting:{type:Boolean,default:!1},gutter:{type:Boolean,default:!1},gutterConfig:{type:Object,default:()=>{}},tag:{type:String,default:"div"}},emits:{"update:modelValue":(e="")=>!0,update:e=>!0,ready:e=>!0,focus:e=>!0,change:e=>!0,destroy:()=>!0},setup(e,d){const o=i.ref(),u=i.ref(e.modelValue),t=i.shallowRef(new c.EditorView),h=i.computed({get:()=>t.value.hasFocus,set:a=>{a&&t.value.focus()}}),m=i.computed({get:()=>t.value.state.selection,set:a=>t.value.dispatch({selection:a})}),g=i.computed({get:()=>t.value.state.selection.main.head,set:a=>t.value.dispatch({selection:{anchor:a}})}),j=i.computed({get:()=>t.value.state.toJSON(),set:a=>t.value.setState(r.EditorState.fromJSON(a))}),b=i.ref(0),S=i.ref(0),y=i.computed(()=>{const a=new r.Compartment,n=new r.Compartment;if(e.basic&&e.minimal)throw"[Vue CodeMirror] Both basic and minimal cannot be specified.";return[e.basic&&!e.minimal?p.basicSetup:void 0,e.minimal&&!e.basic?p.minimalSetup:void 0,c.EditorView.updateListener.of(s=>{d.emit("focus",t.value.hasFocus),b.value=t.value.state.doc?.length,!(s.changes.empty||!s.docChanged)&&(e.linter&&(e.forceLinting&&v.forceLinting(t.value),S.value=e.linter(t.value).length),d.emit("update",s))}),c.EditorView.theme(e.theme,{dark:e.dark}),e.wrap?c.EditorView.lineWrapping:void 0,e.tab?c.keymap.of([f.indentWithTab]):void 0,e.indentUnit?V.indentUnit.of(e.indentUnit):void 0,r.EditorState.allowMultipleSelections.of(e.allowMultipleSelections),e.tabSize?n.of(r.EditorState.tabSize.of(e.tabSize)):void 0,e.phrases?r.EditorState.phrases.of(e.phrases):void 0,r.EditorState.readOnly.of(e.readonly),c.EditorView.editable.of(!e.disabled),e.lineSeparator?r.EditorState.lineSeparator.of(e.lineSeparator):void 0,e.lang?a.of(e.lang):void 0,e.linter?v.linter(e.linter,e.linterConfig):void 0,e.linter&&e.gutter?v.lintGutter(e.gutterConfig):void 0,e.placeholder?c.placeholder(e.placeholder):void 0,...e.extensions].filter(s=>!!s)});i.watch(y,a=>{t.value?.dispatch({effects:r.StateEffect.reconfigure.of(a)})},{immediate:!0}),i.watch(()=>e.modelValue,async a=>{t.value.composing||t.value.state.doc.toJSON().join(e.lineSeparator??`
13
- `)===a||m.value.ranges.every(n=>n.anchor<a.length&&n.head<a.length)&&t.value.dispatch({changes:{from:0,to:t.value.state.doc.length,insert:a},selection:t.value.state.selection,scrollIntoView:!0})},{immediate:!0}),i.onMounted(async()=>{let a=u.value;o.value&&(o.value.childNodes[0]&&(u.value!==""&&console.warn("[CodeMirror.vue] The <code-mirror> tag contains child elements that overwrite the `v-model` values."),a=o.value.childNodes[0].innerText.trim()),t.value=new c.EditorView({parent:o.value,state:r.EditorState.create({doc:a,extensions:y.value}),dispatch:n=>{t.value.update([n]),!(n.changes.empty||!n.docChanged)&&(d.emit("update:modelValue",n.state.doc.toString()??""),d.emit("change",n.state))}}),await i.nextTick(),d.emit("ready",{view:t.value,state:t.value.state,container:o.value}))}),i.onUnmounted(()=>{t.value.destroy(),d.emit("destroy")});const _=()=>{!e.linter||!t.value||(e.forceLinting&&v.forceLinting(t.value),S.value=v.diagnosticCount(t.value.state))},q=()=>{t.value?.dispatch({effects:r.StateEffect.reconfigure.of([])}),t.value?.dispatch({effects:r.StateEffect.appendConfig.of(y.value)})},L=(a,n)=>t.value.state.sliceDoc(a,n),T=a=>t.value.state.doc.line(a+1).text,x=()=>t.value.state.doc.lines,N=()=>t.value.state.selection.main.head,U=()=>{let a;return(a=t.value.state.selection.ranges)!==null&&a!==void 0?a:[]},z=()=>{let a;return(a=t.value.state.sliceDoc(t.value.state.selection.main.from,t.value.state.selection.main.to))!==null&&a!==void 0?a:""},R=()=>{const a=t.value.state;return a?a.selection.ranges.map(n=>a.sliceDoc(n.from,n.to)):[]},F=()=>t.value.state.selection.ranges.some(a=>!a.empty),J=(a,n,s)=>t.value.dispatch({changes:{from:n,to:s,insert:a}}),A=a=>t.value.dispatch(t.value.state.replaceSelection(a)),P=a=>t.value.dispatch({selection:{anchor:a}}),W=(a,n)=>t.value.dispatch({selection:{anchor:a,head:n}}),G=(a,n)=>t.value.dispatch({selection:r.EditorSelection.create(a,n)}),I=a=>t.value.dispatch({selection:r.EditorSelection.create(m.value.ranges.map(n=>n.extend(a(n))))}),E={editor:o,view:t,cursor:g,selection:m,focus:h,length:b,json:j,diagnosticCount:S,dom:t.value.contentDOM,lint:_,forceReconfigure:q,getRange:L,getLine:T,lineCount:x,getCursor:N,listSelections:U,getSelection:z,getSelections:R,somethingSelected:F,replaceRange:J,replaceSelection:A,setCursor:P,setSelection:W,setSelections:G,extendSelectionsBy:I};return d.expose(E),E},render(){return w(this.$props.tag,{ref:"editor",class:"vue-codemirror"},this.$slots.default?w("aside",{style:"display: none;","aria-hidden":"true"},$(this.$slots.default)):void 0)}});const B=e=>e.component("CodeMirror",C);l.Meta=M,l.default=C,l.install=B,Object.defineProperty(l,"__esModule",{value:!0})});
12
+ (function(l,f){typeof exports=="object"&&typeof module<"u"?f(exports,require("@codemirror/commands"),require("@codemirror/language"),require("@codemirror/lint"),require("@codemirror/state"),require("@codemirror/view"),require("codemirror"),require("vue-demi")):typeof define=="function"&&define.amd?define(["exports","@codemirror/commands","@codemirror/language","@codemirror/lint","@codemirror/state","@codemirror/view","codemirror","vue-demi"],f):(l=typeof globalThis<"u"?globalThis:l||self,f(l.CodeMirror={},l.commands,l.language,l.lint,l.state,l.view,l.codemirror,l.VueDemi))})(this,function(l,f,V,v,r,s,p,i){"use strict";var O={version:"1.3.4",date:"2024-07-11T09:11:00.140Z"};const M=e=>e?Object.entries(e).reduce((d,[o,u])=>(o=o.charAt(0).toUpperCase()+o.slice(1),o=`on${o}`,{...d,[o]:u}),{}):{};function w(e,d={},o){if(i.isVue2)return i.h(e,d,o);const{props:u,domProps:t,on:m,...h}=d,g=m?M(m):{};return i.h(e,{...h,...u,...t,...g},o)}const $=e=>typeof e=="function"?e():e;var C=i.defineComponent({name:"CodeMirror",model:{prop:"modelValue",event:"update:modelValue"},props:{modelValue:{type:String,default:""},theme:{type:Object,default:()=>({})},dark:{type:Boolean,default:!1},basic:{type:Boolean,default:!1},minimal:{type:Boolean,default:!1},placeholder:{type:String,default:void 0},wrap:{type:Boolean,default:!1},tab:{type:Boolean,default:!1},indentUnit:{type:String,default:void 0},allowMultipleSelections:{type:Boolean,default:!1},tabSize:{type:Number,default:void 0},lineSeparator:{type:String,default:void 0},readonly:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},extensions:{type:Array,default:()=>[]},phrases:{type:Object,default:()=>{}},lang:{type:Object,default:()=>{}},linter:{type:Function,default:void 0},linterConfig:{type:Object,default:()=>({})},forceLinting:{type:Boolean,default:!1},gutter:{type:Boolean,default:!1},gutterConfig:{type:Object,default:()=>{}},tag:{type:String,default:"div"}},emits:{"update:modelValue":(e="")=>!0,update:e=>!0,ready:e=>!0,focus:e=>!0,change:e=>!0,destroy:()=>!0},setup(e,d){const o=i.ref(),u=i.ref(e.modelValue),t=i.shallowRef(new s.EditorView),m=i.computed({get:()=>t.value.hasFocus,set:a=>{a&&t.value.focus()}}),h=i.computed({get:()=>t.value.state.selection,set:a=>t.value.dispatch({selection:a})}),g=i.computed({get:()=>t.value.state.selection.main.head,set:a=>t.value.dispatch({selection:{anchor:a}})}),j=i.computed({get:()=>t.value.state.toJSON(),set:a=>t.value.setState(r.EditorState.fromJSON(a))}),b=i.ref(0),S=i.ref(0),y=i.computed(()=>{const a=new r.Compartment,n=new r.Compartment;if(e.basic&&e.minimal)throw"[Vue CodeMirror] Both basic and minimal cannot be specified.";return[e.basic&&!e.minimal?p.basicSetup:void 0,e.minimal&&!e.basic?p.minimalSetup:void 0,s.EditorView.updateListener.of(c=>{d.emit("focus",t.value.hasFocus),b.value=t.value.state.doc?.length,!(c.changes.empty||!c.docChanged)&&(e.linter&&(e.forceLinting&&v.forceLinting(t.value),S.value=e.linter(t.value).length),d.emit("update",c))}),s.EditorView.theme(e.theme,{dark:e.dark}),e.wrap?s.EditorView.lineWrapping:void 0,e.tab?s.keymap.of([f.indentWithTab]):void 0,e.indentUnit?V.indentUnit.of(e.indentUnit):void 0,r.EditorState.allowMultipleSelections.of(e.allowMultipleSelections),e.tabSize?n.of(r.EditorState.tabSize.of(e.tabSize)):void 0,e.phrases?r.EditorState.phrases.of(e.phrases):void 0,r.EditorState.readOnly.of(e.readonly),s.EditorView.editable.of(!e.disabled),e.lineSeparator?r.EditorState.lineSeparator.of(e.lineSeparator):void 0,e.lang?a.of(e.lang):void 0,e.linter?v.linter(e.linter,e.linterConfig):void 0,e.linter&&e.gutter?v.lintGutter(e.gutterConfig):void 0,e.placeholder?s.placeholder(e.placeholder):void 0,...e.extensions].filter(c=>!!c)});i.watch(y,a=>{t.value?.dispatch({effects:r.StateEffect.reconfigure.of(a)})},{immediate:!0}),i.watch(()=>e.modelValue,async a=>{if(t.value.composing||t.value.state.doc.toJSON().join(e.lineSeparator??`
13
+ `)===a)return;const n=!t.value.state.selection.ranges.every(c=>c.anchor<a.length&&c.head<a.length);t.value.dispatch({changes:{from:0,to:t.value.state.doc.length,insert:a},selection:n?{anchor:0,head:0}:t.value.state.selection,scrollIntoView:!0})},{immediate:!0}),i.onMounted(async()=>{let a=u.value;o.value&&(o.value.childNodes[0]&&(u.value!==""&&console.warn("[CodeMirror.vue] The <code-mirror> tag contains child elements that overwrite the `v-model` values."),a=o.value.childNodes[0].innerText.trim()),t.value=new s.EditorView({parent:o.value,state:r.EditorState.create({doc:a,extensions:y.value}),dispatch:n=>{t.value.update([n]),!(n.changes.empty||!n.docChanged)&&(d.emit("update:modelValue",n.state.doc.toString()??""),d.emit("change",n.state))}}),await i.nextTick(),d.emit("ready",{view:t.value,state:t.value.state,container:o.value}))}),i.onUnmounted(()=>{t.value.destroy(),d.emit("destroy")});const _=()=>{!e.linter||!t.value||(e.forceLinting&&v.forceLinting(t.value),S.value=v.diagnosticCount(t.value.state))},q=()=>{t.value?.dispatch({effects:r.StateEffect.reconfigure.of([])}),t.value?.dispatch({effects:r.StateEffect.appendConfig.of(y.value)})},L=(a,n)=>t.value.state.sliceDoc(a,n),T=a=>t.value.state.doc.line(a+1).text,x=()=>t.value.state.doc.lines,N=()=>t.value.state.selection.main.head,U=()=>{let a;return(a=t.value.state.selection.ranges)!==null&&a!==void 0?a:[]},z=()=>{let a;return(a=t.value.state.sliceDoc(t.value.state.selection.main.from,t.value.state.selection.main.to))!==null&&a!==void 0?a:""},R=()=>{const a=t.value.state;return a?a.selection.ranges.map(n=>a.sliceDoc(n.from,n.to)):[]},F=()=>t.value.state.selection.ranges.some(a=>!a.empty),J=(a,n,c)=>t.value.dispatch({changes:{from:n,to:c,insert:a}}),A=a=>t.value.dispatch(t.value.state.replaceSelection(a)),P=a=>t.value.dispatch({selection:{anchor:a}}),W=(a,n)=>t.value.dispatch({selection:{anchor:a,head:n}}),G=(a,n)=>t.value.dispatch({selection:r.EditorSelection.create(a,n)}),I=a=>t.value.dispatch({selection:r.EditorSelection.create(h.value.ranges.map(n=>n.extend(a(n))))}),E={editor:o,view:t,cursor:g,selection:h,focus:m,length:b,json:j,diagnosticCount:S,dom:t.value.contentDOM,lint:_,forceReconfigure:q,getRange:L,getLine:T,lineCount:x,getCursor:N,listSelections:U,getSelection:z,getSelections:R,somethingSelected:F,replaceRange:J,replaceSelection:A,setCursor:P,setSelection:W,setSelections:G,extendSelectionsBy:I};return d.expose(E),E},render(){return w(this.$props.tag,{ref:"editor",class:"vue-codemirror"},this.$slots.default?w("aside",{style:"display: none;","aria-hidden":"true"},$(this.$slots.default)):void 0)}});const B=e=>e.component("CodeMirror",C);l.Meta=O,l.default=C,l.install=B,Object.defineProperty(l,"__esModule",{value:!0})});
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.3.3",
4
+ "version": "1.3.4",
5
5
  "license": "MIT",
6
6
  "description": "CodeMirror6 Component for vue2 and vue3.",
7
7
  "keywords": [