vue-codemirror6 1.3.4 → 1.3.7

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/README.md CHANGED
@@ -362,7 +362,7 @@ const config: UserConfig = {
362
362
  // ...
363
363
  codemirror: [
364
364
  // Split CodeMirror code.
365
- 'vue-codemirror6'
365
+ 'vue-codemirror6',
366
366
  'codemirror',
367
367
  '@codemirror/autocomplete',
368
368
  '@codemirror/commands',
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.4
8
+ * @version 1.3.6
9
9
  * @see {@link https://github.com/logue/vue-codemirror6}
10
10
  */
11
11
 
@@ -15,25 +15,23 @@ import { forceLinting as b, linter as P, lintGutter as Z, diagnosticCount as k }
15
15
  import { EditorState as s, Compartment as C, StateEffect as y, EditorSelection as w } from "@codemirror/state";
16
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 r, watch as $, onMounted as te, nextTick as ae, onUnmounted as ne } from "vue-demi";
19
- const ie = {
20
- version: "1.3.4",
21
- date: "2024-07-11T09:11:00.140Z"
22
- };
23
- var he = ie;
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
- function B(e, l = {}, i) {
18
+ import { isVue2 as X, h as O, defineComponent as Y, ref as v, shallowRef as ee, computed as r, watch as B, onMounted as te, nextTick as ae, onUnmounted as ne } from "vue-demi";
19
+ const me = {
20
+ version: "1.3.6",
21
+ date: "2024-11-05T16:13:38.583Z"
22
+ }, ie = (e) => e ? Object.entries(e).reduce((l, [i, u]) => (i = i.charAt(0).toUpperCase() + i.slice(1), i = `on${i}`, { ...l, [i]: u }), {}) : {};
23
+ function M(e, l = {}, i) {
26
24
  if (X)
27
25
  return O(e, l, i);
28
- const { props: u, domProps: t, on: d, ...f } = l, m = d ? le(d) : {};
26
+ const { props: u, domProps: t, on: d, ...f } = l, m = d ? ie(d) : {};
29
27
  return O(
30
28
  e,
31
29
  { ...f, ...u, ...t, ...m },
32
30
  i
33
31
  );
34
32
  }
35
- const oe = (e) => typeof e == "function" ? e() : e;
36
- var se = Y({
33
+ const le = (e) => typeof e == "function" ? e() : e;
34
+ var oe = Y({
37
35
  /** Component Name */
38
36
  name: "CodeMirror",
39
37
  /** Model Definition */
@@ -283,7 +281,7 @@ var se = Y({
283
281
  }), m = r({
284
282
  get: () => t.value.state.selection.main.head,
285
283
  set: (a) => t.value.dispatch({ selection: { anchor: a } })
286
- }), M = r(
284
+ }), V = r(
287
285
  {
288
286
  get: () => t.value.state.toJSON(),
289
287
  set: (a) => t.value.setState(s.fromJSON(a))
@@ -333,7 +331,7 @@ var se = Y({
333
331
  ...e.extensions
334
332
  ].filter((o) => !!o);
335
333
  });
336
- $(
334
+ B(
337
335
  g,
338
336
  (a) => {
339
337
  t.value?.dispatch({
@@ -341,7 +339,7 @@ var se = Y({
341
339
  });
342
340
  },
343
341
  { immediate: !0 }
344
- ), $(
342
+ ), B(
345
343
  () => e.modelValue,
346
344
  async (a) => {
347
345
  if (t.value.composing || // IME fix
@@ -376,7 +374,7 @@ var se = Y({
376
374
  }), ne(() => {
377
375
  t.value.destroy(), l.emit("destroy");
378
376
  });
379
- const V = () => {
377
+ const $ = () => {
380
378
  !e.linter || !t.value || (e.forceLinting && b(t.value), h.value = k(t.value.state));
381
379
  }, j = () => {
382
380
  t.value?.dispatch({
@@ -415,10 +413,10 @@ var se = Y({
415
413
  selection: f,
416
414
  focus: d,
417
415
  length: S,
418
- json: M,
416
+ json: V,
419
417
  diagnosticCount: h,
420
418
  dom: t.value.contentDOM,
421
- lint: V,
419
+ lint: $,
422
420
  forceReconfigure: j,
423
421
  // Bellow is CodeMirror5's function
424
422
  getRange: x,
@@ -439,7 +437,7 @@ var se = Y({
439
437
  return l.expose(p), p;
440
438
  },
441
439
  render() {
442
- return B(
440
+ return M(
443
441
  this.$props.tag,
444
442
  {
445
443
  ref: "editor",
@@ -447,18 +445,18 @@ var se = Y({
447
445
  },
448
446
  this.$slots.default ? (
449
447
  // Hide original content
450
- B(
448
+ M(
451
449
  "aside",
452
450
  { style: "display: none;", "aria-hidden": "true" },
453
- oe(this.$slots.default)
451
+ le(this.$slots.default)
454
452
  )
455
453
  ) : void 0
456
454
  );
457
455
  }
458
456
  });
459
- const ge = (e) => e.component("CodeMirror", se);
457
+ const he = (e) => e.component("CodeMirror", oe);
460
458
  export {
461
- he as Meta,
462
- se as default,
463
- ge as install
459
+ me as Meta,
460
+ oe as default,
461
+ he as install
464
462
  };
@@ -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.4
8
+ * @version 1.3.6
9
9
  * @see {@link https://github.com/logue/vue-codemirror6}
10
10
  */
11
11
 
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);
12
+ var CodeMirror=function(u,E,V,f,i,r,y,l){"use strict";const O={version:"1.3.6",date:"2024-11-05T16:13:38.583Z"},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 r.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,r.EditorView.updateListener.of(d=>{c.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),c.emit("update",d))}),r.EditorView.theme(e.theme,{dark:e.dark}),e.wrap?r.EditorView.lineWrapping:void 0,e.tab?r.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),r.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?r.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=>{if(t.value.composing||t.value.state.doc.toJSON().join(e.lineSeparator??`
13
+ `)===a)return;const n=!t.value.state.selection.ranges.every(d=>d.anchor<a.length&&d.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 r.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,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(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.4
8
+ * @version 1.3.6
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,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??`
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";const O={version:"1.3.6",date:"2024-11-05T16:13:38.583Z"},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
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})});
@@ -1,4 +1,4 @@
1
1
  import { default as MetaInterface } from './interfaces/MetaInterface';
2
-
3
2
  declare const meta: MetaInterface;
4
3
  export default meta;
4
+ //# sourceMappingURL=Meta.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Meta.d.ts","sourceRoot":"","sources":["../../src/Meta.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,aAAa,MAAM,4BAA4B,CAAC;AAG5D,QAAA,MAAM,IAAI,EAAE,aAGX,CAAC;AACF,eAAe,IAAI,CAAC"}
@@ -0,0 +1,496 @@
1
+ import { LanguageSupport } from '@codemirror/language';
2
+ import { LintSource } from '@codemirror/lint';
3
+ import { EditorSelection, EditorState, Extension, SelectionRange, StateField, Text } from '@codemirror/state';
4
+ import { EditorView, ViewUpdate } from '@codemirror/view';
5
+ import { PropType, Ref, ShallowRef, WritableComputedRef } from 'vue-demi';
6
+ import { StyleSpec } from 'style-mod';
7
+ /** CodeMirror Component */
8
+ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
9
+ /** Model value */
10
+ modelValue: {
11
+ type: PropType<string | Text>;
12
+ default: string;
13
+ };
14
+ /**
15
+ * Theme
16
+ *
17
+ * @see {@link https://codemirror.net/docs/ref/#view.EditorView^theme}
18
+ */
19
+ theme: {
20
+ type: PropType<Record<string, StyleSpec>>;
21
+ default: () => {};
22
+ };
23
+ /** Dark Mode */
24
+ dark: {
25
+ type: BooleanConstructor;
26
+ default: boolean;
27
+ };
28
+ /**
29
+ * Use Basic Setup
30
+ *
31
+ * @see {@link https://codemirror.net/docs/ref/#codemirror.basicSetup}
32
+ */
33
+ basic: {
34
+ type: BooleanConstructor;
35
+ default: boolean;
36
+ };
37
+ /**
38
+ * Use Minimal Setup (The basic setting has priority.)
39
+ *
40
+ * @see {@link https://codemirror.net/docs/ref/#codemirror.minimalSetup}
41
+ */
42
+ minimal: {
43
+ type: BooleanConstructor;
44
+ default: boolean;
45
+ };
46
+ /**
47
+ * Placeholder
48
+ *
49
+ * @see {@link https://codemirror.net/docs/ref/#view.placeholder}
50
+ */
51
+ placeholder: {
52
+ type: PropType<string | HTMLElement>;
53
+ default: undefined;
54
+ };
55
+ /**
56
+ * Line wrapping
57
+ *
58
+ * An extension that enables line wrapping in the editor (by setting CSS white-space to pre-wrap in the content).
59
+ *
60
+ * @see {@link https://codemirror.net/docs/ref/#view.EditorView%5ElineWrapping}
61
+ */
62
+ wrap: {
63
+ type: BooleanConstructor;
64
+ default: boolean;
65
+ };
66
+ /**
67
+ * Allow tab key indent.
68
+ *
69
+ * @see {@link https://codemirror.net/examples/tab/}
70
+ */
71
+ tab: {
72
+ type: BooleanConstructor;
73
+ default: boolean;
74
+ };
75
+ /**
76
+ * Tab character
77
+ */
78
+ indentUnit: {
79
+ type: StringConstructor;
80
+ default: undefined;
81
+ };
82
+ /**
83
+ * Allow Multiple Selection.
84
+ *
85
+ * @see {@link https://codemirror.net/docs/ref/#state.EditorState^allowMultipleSelections}
86
+ */
87
+ allowMultipleSelections: {
88
+ type: BooleanConstructor;
89
+ default: boolean;
90
+ };
91
+ /**
92
+ * Tab size
93
+ *
94
+ * @see {@link https://codemirror.net/docs/ref/#state.EditorState^tabSize}
95
+ */
96
+ tabSize: {
97
+ type: NumberConstructor;
98
+ default: undefined;
99
+ };
100
+ /**
101
+ * Set line break (separetor) char.
102
+ *
103
+ * @see {@link https://codemirror.net/docs/ref/#state.EditorState^lineSeparator}
104
+ */
105
+ lineSeparator: {
106
+ type: StringConstructor;
107
+ default: undefined;
108
+ };
109
+ /**
110
+ * Readonly
111
+ *
112
+ * @see {@link https://codemirror.net/docs/ref/#state.EditorState^readOnly}
113
+ */
114
+ readonly: {
115
+ type: BooleanConstructor;
116
+ default: boolean;
117
+ };
118
+ /**
119
+ * Disable input.
120
+ *
121
+ * This is the reversed value of the CodeMirror editable.
122
+ * Similar to `readonly`, but setting this value to true disables dragging.
123
+ *
124
+ * @see {@link https://codemirror.net/docs/ref/#view.EditorView^editable}
125
+ */
126
+ disabled: {
127
+ type: BooleanConstructor;
128
+ default: boolean;
129
+ };
130
+ /**
131
+ * Additional Extension
132
+ *
133
+ * @see {@link https://codemirror.net/docs/ref/#state.Extension}
134
+ */
135
+ extensions: {
136
+ type: PropType<Extension[]>;
137
+ default: () => never[];
138
+ };
139
+ /**
140
+ * Language Phreses
141
+ *
142
+ * @see {@link https://codemirror.net/examples/translate/}
143
+ */
144
+ phrases: {
145
+ type: PropType<Record<string, string>>;
146
+ default: () => undefined;
147
+ };
148
+ /**
149
+ * CodeMirror Language
150
+ *
151
+ * @see {@link https://codemirror.net/docs/ref/#language}
152
+ */
153
+ lang: {
154
+ type: PropType<LanguageSupport>;
155
+ default: () => undefined;
156
+ };
157
+ /**
158
+ * CodeMirror Linter
159
+ *
160
+ * @see {@link https://codemirror.net/docs/ref/#lint.linter}
161
+ */
162
+ linter: {
163
+ type: PropType<LintSource | any>;
164
+ default: undefined;
165
+ };
166
+ /**
167
+ * Linter Config
168
+ *
169
+ * @see {@link https://codemirror.net/docs/ref/#lint.linter^config}
170
+ */
171
+ linterConfig: {
172
+ type: ObjectConstructor;
173
+ default: () => {};
174
+ };
175
+ /**
176
+ * Forces any linters configured to run when the editor is idle to run right away.
177
+ *
178
+ * @see {@link https://codemirror.net/docs/ref/#lint.forceLinting}
179
+ */
180
+ forceLinting: {
181
+ type: BooleanConstructor;
182
+ default: boolean;
183
+ };
184
+ /**
185
+ * Show Linter Gutter
186
+ *
187
+ * An area to 🔴 the lines with errors will be displayed.
188
+ * This feature is not enabled if `linter` is not specified.
189
+ *
190
+ * @see {@link https://codemirror.net/docs/ref/#lint.lintGutter}
191
+ */
192
+ gutter: {
193
+ type: BooleanConstructor;
194
+ default: boolean;
195
+ };
196
+ /**
197
+ * Gutter Config
198
+ *
199
+ * @see {@link https://codemirror.net/docs/ref/#lint.lintGutter^config}
200
+ */
201
+ gutterConfig: {
202
+ type: ObjectConstructor;
203
+ default: () => undefined;
204
+ };
205
+ /**
206
+ * Using tag
207
+ */
208
+ tag: {
209
+ type: StringConstructor;
210
+ default: string;
211
+ };
212
+ }>, {
213
+ editor: Ref<HTMLElement | undefined, HTMLElement | undefined>;
214
+ view: ShallowRef<EditorView>;
215
+ cursor: WritableComputedRef<number, number>;
216
+ selection: WritableComputedRef<EditorSelection, EditorSelection>;
217
+ focus: WritableComputedRef<boolean, boolean>;
218
+ length: Ref<number, number>;
219
+ json: WritableComputedRef<Record<string, StateField<any>>, Record<string, StateField<any>>>;
220
+ diagnosticCount: Ref<number, number>;
221
+ dom: HTMLElement;
222
+ lint: () => void;
223
+ forceReconfigure: () => void;
224
+ getRange: (from?: number, to?: number) => string | undefined;
225
+ getLine: (number: number) => string;
226
+ lineCount: () => number;
227
+ getCursor: () => number;
228
+ listSelections: () => readonly SelectionRange[];
229
+ getSelection: () => string;
230
+ getSelections: () => string[];
231
+ somethingSelected: () => boolean;
232
+ replaceRange: (replacement: string | Text, from: number, to: number) => void;
233
+ replaceSelection: (replacement: string | Text) => void;
234
+ setCursor: (position: number) => void;
235
+ setSelection: (anchor: number, head?: number) => void;
236
+ setSelections: (ranges: readonly SelectionRange[], primary?: number) => void;
237
+ extendSelectionsBy: (f: any) => void;
238
+ }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
239
+ /** Model Update */
240
+ 'update:modelValue': (_value?: string | Text) => true;
241
+ /** CodeMirror ViewUpdate */
242
+ update: (_value: ViewUpdate) => true;
243
+ /** CodeMirror onReady */
244
+ ready: (_value: {
245
+ view: EditorView;
246
+ state: EditorState;
247
+ container: HTMLElement;
248
+ }) => true;
249
+ /** CodeMirror onFocus */
250
+ focus: (_value: boolean) => true;
251
+ /** State Changed */
252
+ change: (_value: EditorState) => true;
253
+ /** CodeMirror onDestroy */
254
+ destroy: () => true;
255
+ }, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
256
+ /** Model value */
257
+ modelValue: {
258
+ type: PropType<string | Text>;
259
+ default: string;
260
+ };
261
+ /**
262
+ * Theme
263
+ *
264
+ * @see {@link https://codemirror.net/docs/ref/#view.EditorView^theme}
265
+ */
266
+ theme: {
267
+ type: PropType<Record<string, StyleSpec>>;
268
+ default: () => {};
269
+ };
270
+ /** Dark Mode */
271
+ dark: {
272
+ type: BooleanConstructor;
273
+ default: boolean;
274
+ };
275
+ /**
276
+ * Use Basic Setup
277
+ *
278
+ * @see {@link https://codemirror.net/docs/ref/#codemirror.basicSetup}
279
+ */
280
+ basic: {
281
+ type: BooleanConstructor;
282
+ default: boolean;
283
+ };
284
+ /**
285
+ * Use Minimal Setup (The basic setting has priority.)
286
+ *
287
+ * @see {@link https://codemirror.net/docs/ref/#codemirror.minimalSetup}
288
+ */
289
+ minimal: {
290
+ type: BooleanConstructor;
291
+ default: boolean;
292
+ };
293
+ /**
294
+ * Placeholder
295
+ *
296
+ * @see {@link https://codemirror.net/docs/ref/#view.placeholder}
297
+ */
298
+ placeholder: {
299
+ type: PropType<string | HTMLElement>;
300
+ default: undefined;
301
+ };
302
+ /**
303
+ * Line wrapping
304
+ *
305
+ * An extension that enables line wrapping in the editor (by setting CSS white-space to pre-wrap in the content).
306
+ *
307
+ * @see {@link https://codemirror.net/docs/ref/#view.EditorView%5ElineWrapping}
308
+ */
309
+ wrap: {
310
+ type: BooleanConstructor;
311
+ default: boolean;
312
+ };
313
+ /**
314
+ * Allow tab key indent.
315
+ *
316
+ * @see {@link https://codemirror.net/examples/tab/}
317
+ */
318
+ tab: {
319
+ type: BooleanConstructor;
320
+ default: boolean;
321
+ };
322
+ /**
323
+ * Tab character
324
+ */
325
+ indentUnit: {
326
+ type: StringConstructor;
327
+ default: undefined;
328
+ };
329
+ /**
330
+ * Allow Multiple Selection.
331
+ *
332
+ * @see {@link https://codemirror.net/docs/ref/#state.EditorState^allowMultipleSelections}
333
+ */
334
+ allowMultipleSelections: {
335
+ type: BooleanConstructor;
336
+ default: boolean;
337
+ };
338
+ /**
339
+ * Tab size
340
+ *
341
+ * @see {@link https://codemirror.net/docs/ref/#state.EditorState^tabSize}
342
+ */
343
+ tabSize: {
344
+ type: NumberConstructor;
345
+ default: undefined;
346
+ };
347
+ /**
348
+ * Set line break (separetor) char.
349
+ *
350
+ * @see {@link https://codemirror.net/docs/ref/#state.EditorState^lineSeparator}
351
+ */
352
+ lineSeparator: {
353
+ type: StringConstructor;
354
+ default: undefined;
355
+ };
356
+ /**
357
+ * Readonly
358
+ *
359
+ * @see {@link https://codemirror.net/docs/ref/#state.EditorState^readOnly}
360
+ */
361
+ readonly: {
362
+ type: BooleanConstructor;
363
+ default: boolean;
364
+ };
365
+ /**
366
+ * Disable input.
367
+ *
368
+ * This is the reversed value of the CodeMirror editable.
369
+ * Similar to `readonly`, but setting this value to true disables dragging.
370
+ *
371
+ * @see {@link https://codemirror.net/docs/ref/#view.EditorView^editable}
372
+ */
373
+ disabled: {
374
+ type: BooleanConstructor;
375
+ default: boolean;
376
+ };
377
+ /**
378
+ * Additional Extension
379
+ *
380
+ * @see {@link https://codemirror.net/docs/ref/#state.Extension}
381
+ */
382
+ extensions: {
383
+ type: PropType<Extension[]>;
384
+ default: () => never[];
385
+ };
386
+ /**
387
+ * Language Phreses
388
+ *
389
+ * @see {@link https://codemirror.net/examples/translate/}
390
+ */
391
+ phrases: {
392
+ type: PropType<Record<string, string>>;
393
+ default: () => undefined;
394
+ };
395
+ /**
396
+ * CodeMirror Language
397
+ *
398
+ * @see {@link https://codemirror.net/docs/ref/#language}
399
+ */
400
+ lang: {
401
+ type: PropType<LanguageSupport>;
402
+ default: () => undefined;
403
+ };
404
+ /**
405
+ * CodeMirror Linter
406
+ *
407
+ * @see {@link https://codemirror.net/docs/ref/#lint.linter}
408
+ */
409
+ linter: {
410
+ type: PropType<LintSource | any>;
411
+ default: undefined;
412
+ };
413
+ /**
414
+ * Linter Config
415
+ *
416
+ * @see {@link https://codemirror.net/docs/ref/#lint.linter^config}
417
+ */
418
+ linterConfig: {
419
+ type: ObjectConstructor;
420
+ default: () => {};
421
+ };
422
+ /**
423
+ * Forces any linters configured to run when the editor is idle to run right away.
424
+ *
425
+ * @see {@link https://codemirror.net/docs/ref/#lint.forceLinting}
426
+ */
427
+ forceLinting: {
428
+ type: BooleanConstructor;
429
+ default: boolean;
430
+ };
431
+ /**
432
+ * Show Linter Gutter
433
+ *
434
+ * An area to 🔴 the lines with errors will be displayed.
435
+ * This feature is not enabled if `linter` is not specified.
436
+ *
437
+ * @see {@link https://codemirror.net/docs/ref/#lint.lintGutter}
438
+ */
439
+ gutter: {
440
+ type: BooleanConstructor;
441
+ default: boolean;
442
+ };
443
+ /**
444
+ * Gutter Config
445
+ *
446
+ * @see {@link https://codemirror.net/docs/ref/#lint.lintGutter^config}
447
+ */
448
+ gutterConfig: {
449
+ type: ObjectConstructor;
450
+ default: () => undefined;
451
+ };
452
+ /**
453
+ * Using tag
454
+ */
455
+ tag: {
456
+ type: StringConstructor;
457
+ default: string;
458
+ };
459
+ }>> & Readonly<{
460
+ onChange?: ((_value: EditorState) => any) | undefined;
461
+ onFocus?: ((_value: boolean) => any) | undefined;
462
+ "onUpdate:modelValue"?: ((_value?: string | Text | undefined) => any) | undefined;
463
+ onUpdate?: ((_value: ViewUpdate) => any) | undefined;
464
+ onReady?: ((_value: {
465
+ view: EditorView;
466
+ state: EditorState;
467
+ container: HTMLElement;
468
+ }) => any) | undefined;
469
+ onDestroy?: (() => any) | undefined;
470
+ }>, {
471
+ modelValue: string | Text;
472
+ theme: Record<string, StyleSpec>;
473
+ dark: boolean;
474
+ basic: boolean;
475
+ minimal: boolean;
476
+ placeholder: string | HTMLElement;
477
+ wrap: boolean;
478
+ tab: boolean;
479
+ indentUnit: string;
480
+ allowMultipleSelections: boolean;
481
+ tabSize: number;
482
+ lineSeparator: string;
483
+ readonly: boolean;
484
+ disabled: boolean;
485
+ extensions: Extension[];
486
+ phrases: Record<string, string>;
487
+ lang: LanguageSupport;
488
+ linter: any;
489
+ linterConfig: Record<string, any>;
490
+ forceLinting: boolean;
491
+ gutter: boolean;
492
+ gutterConfig: Record<string, any>;
493
+ tag: string;
494
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
495
+ export default _default;
496
+ //# sourceMappingURL=CodeMirror.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CodeMirror.d.ts","sourceRoot":"","sources":["../../../src/components/CodeMirror.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,16 @@
1
+ import { Slots, VNode, VNodeProps } from 'vue-demi';
2
+ interface Options extends VNodeProps {
3
+ class?: string;
4
+ domProps?: VNodeProps;
5
+ on?: Record<string, () => void>;
6
+ props?: VNodeProps;
7
+ style?: string;
8
+ 'aria-hidden'?: string;
9
+ }
10
+ /**
11
+ * hDemi function.
12
+ */
13
+ export default function h(type: string | Record<any, any>, options?: Options, chidren?: any): VNode;
14
+ export declare const slot: (defaultSlots: any) => Slots;
15
+ export {};
16
+ //# sourceMappingURL=h-demi.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"h-demi.d.ts","sourceRoot":"","sources":["../../../src/helpers/h-demi.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAGL,KAAK,KAAK,EACV,KAAK,KAAK,EACV,KAAK,UAAU,EAChB,MAAM,UAAU,CAAC;AAElB,UAAU,OAAQ,SAAQ,UAAU;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,UAAU,CAAC;IACtB,EAAE,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,IAAI,CAAC,CAAC;IAChC,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAaD;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,CAAC,CACvB,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,EAC/B,OAAO,GAAE,OAAY,EACrB,OAAO,CAAC,EAAE,GAAG,GACZ,KAAK,CAcP;AAED,eAAO,MAAM,IAAI,iBAAkB,GAAG,KAAG,KAC2B,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import { default as Meta } from './Meta';
2
2
  import { default as CodeMirror } from './components/CodeMirror';
3
-
4
3
  declare const installCodeMirror: (app: any) => void;
5
4
  export { CodeMirror as default, installCodeMirror as install, Meta };
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,QAAQ,CAAC;AAC1B,OAAO,UAAU,MAAM,yBAAyB,CAAC;AAGjD,QAAA,MAAM,iBAAiB,QAAS,GAAG,KAAG,IACG,CAAC;AAE1C,OAAO,EAAE,UAAU,IAAI,OAAO,EAAE,iBAAiB,IAAI,OAAO,EAAE,IAAI,EAAE,CAAC"}
@@ -0,0 +1,8 @@
1
+ /** Build information meta data */
2
+ export default interface MetaInterface {
3
+ /** Version */
4
+ version: string;
5
+ /** Build date */
6
+ date: string;
7
+ }
8
+ //# sourceMappingURL=MetaInterface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MetaInterface.d.ts","sourceRoot":"","sources":["../../../src/interfaces/MetaInterface.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAClC,MAAM,CAAC,OAAO,WAAW,aAAa;IACpC,cAAc;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,iBAAiB;IACjB,IAAI,EAAE,MAAM,CAAC;CACd"}
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.4",
4
+ "version": "1.3.7",
5
5
  "license": "MIT",
6
6
  "description": "CodeMirror6 Component for vue2 and vue3.",
7
7
  "keywords": [
@@ -36,12 +36,12 @@
36
36
  },
37
37
  "main": "dist/index.umd.js",
38
38
  "module": "dist/index.es.js",
39
- "types": "dist/index.d.ts",
39
+ "types": "dist/src/index.d.ts",
40
40
  "exports": {
41
41
  ".": {
42
42
  "import": "./dist/index.es.js",
43
43
  "require": "./dist/index.umd.js",
44
- "types": "./dist/index.d.ts"
44
+ "types": "./dist/src/index.d.ts"
45
45
  }
46
46
  },
47
47
  "files": [
@@ -53,9 +53,9 @@
53
53
  "./sfc": "./src/components/CodeMirror.ts"
54
54
  },
55
55
  "engines": {
56
- "yarn": ">=1.22.19"
56
+ "pnpm": ">=9.12.3"
57
57
  },
58
- "packageManager": "yarn@4.3.1",
58
+ "packageManager": "pnpm@9.12.3",
59
59
  "sideEffects": false,
60
60
  "scripts": {
61
61
  "dev": "vite",
@@ -67,58 +67,67 @@
67
67
  "lint": "eslint . --fix --cache --cache-location ./node_modules/.vite/vite-plugin-eslint && prettier . --write",
68
68
  "preview": "vite preview --mode=docs",
69
69
  "build-only": "vite build",
70
- "type-check": "vue-tsc --build --force",
71
- "prepare": "husky install",
70
+ "type-check": "vue-tsc --declaration --emitDeclarationOnly",
71
+ "prepare": "husky",
72
72
  "version": "auto-changelog -p && git add CHANGELOG.md"
73
73
  },
74
74
  "dependencies": {
75
+ "@codemirror/commands": "^6.7.1",
76
+ "@codemirror/language": "^6.10.3",
77
+ "@codemirror/lint": "^6.8.2",
78
+ "@codemirror/state": "^6.4.1",
79
+ "@codemirror/view": "^6.34.2",
75
80
  "codemirror": "^6.0.1",
81
+ "style-mod": "^4.1.2",
82
+ "vue-codemirror6": "file:",
76
83
  "vue-demi": "latest"
77
84
  },
78
85
  "peerDependencies": {
79
86
  "vue": "^2.7.14 || ^3.4"
80
87
  },
81
88
  "devDependencies": {
89
+ "@codemirror/autocomplete": "^6.18.2",
82
90
  "@codemirror/lang-javascript": "^6.2.2",
83
91
  "@codemirror/lang-json": "^6.0.1",
84
- "@codemirror/lang-markdown": "^6.2.5",
85
- "@codemirror/lang-vue": "0.1.2",
86
- "@eslint/js": "^9.6.0",
87
- "@tsconfig/node-lts": "^20.1.3",
88
- "@types/node": "^20.14.10",
89
- "@typescript-eslint/eslint-plugin": "^7.16.0",
90
- "@vitejs/plugin-vue": "^5.0.5",
91
- "@vue/compiler-sfc": "^3.4.31",
92
- "@vue/eslint-config-prettier": "^9.0.0",
92
+ "@codemirror/lang-markdown": "^6.3.1",
93
+ "@codemirror/lang-vue": "^0.1.3",
94
+ "@codemirror/search": "^6.5.7",
95
+ "@eslint/js": "^9.14.0",
96
+ "@tsconfig/node-lts": "^22.0.0",
97
+ "@types/node": "^22.9.0",
98
+ "@typescript-eslint/eslint-plugin": "^8.13.0",
99
+ "@vitejs/plugin-vue": "^5.1.4",
100
+ "@vue/compiler-sfc": "^3.5.12",
101
+ "@vue/eslint-config-prettier": "^10.1.0",
93
102
  "@vue/tsconfig": "^0.5.1",
94
- "@vueuse/core": "^10.11.0",
103
+ "@vueuse/core": "^11.2.0",
95
104
  "bootstrap": "^5.3.3",
96
- "eslint": "^9.6.0",
105
+ "eslint": "^9.14.0",
97
106
  "eslint-import-resolver-alias": "^1.1.2",
98
- "eslint-import-resolver-typescript": "^3.6.1",
99
- "eslint-linter-browserify": "^9.6.0",
100
- "eslint-plugin-import": "^2.29.1",
107
+ "eslint-import-resolver-typescript": "^3.6.3",
108
+ "eslint-linter-browserify": "^9.14.0",
109
+ "eslint-plugin-import": "^2.31.0",
101
110
  "eslint-plugin-tsdoc": "^0.3.0",
102
- "eslint-plugin-vue": "^9.27.0",
103
- "eslint-plugin-vuejs-accessibility": "^2.3.1",
111
+ "eslint-plugin-vue": "^9.30.0",
112
+ "eslint-plugin-vuejs-accessibility": "^2.4.1",
104
113
  "eslint-plugin-yaml": "^1.0.3",
105
- "husky": "^9.0.11",
106
- "lint-staged": "^15.2.7",
114
+ "husky": "^9.1.6",
115
+ "lint-staged": "^15.2.10",
107
116
  "npm-run-all": "^4.1.5",
108
- "prettier": "^3.3.2",
117
+ "prettier": "^3.3.3",
109
118
  "rimraf": "^6.0.1",
110
119
  "rollup-plugin-visualizer": "^5.12.0",
111
- "sass": "^1.77.7",
112
- "typescript": "^5.5.3",
113
- "typescript-eslint": "^7.16.0",
114
- "vite": "^5.3.3",
115
- "vite-plugin-banner": "^0.7.1",
116
- "vite-plugin-checker": "^0.7.1",
117
- "vite-plugin-dts": "^3.9.1",
118
- "vue": "^3.4.31",
120
+ "sass": "^1.80.6",
121
+ "typescript": "~5.6.3",
122
+ "typescript-eslint": "^8.13.0",
123
+ "vite": "^5.4.10",
124
+ "vite-plugin-banner": "^0.8.0",
125
+ "vite-plugin-checker": "^0.8.0",
126
+ "vite-plugin-dts": "^4.3.0",
127
+ "vue": "^3.5.12",
119
128
  "vue-eslint-parser": "^9.4.3",
120
129
  "vue-markdown-wasm": "^0.4.0",
121
- "vue-tsc": "^2.0.26"
130
+ "vue-tsc": "^2.1.10"
122
131
  },
123
132
  "husky": {
124
133
  "hooks": {
@@ -130,13 +139,7 @@
130
139
  "*": "prettier -w -u"
131
140
  },
132
141
  "resolutions": {
133
- "braces": ">=3.0.3",
134
142
  "json5": ">=2.2.3",
135
- "ip": ">=2.0.1",
136
- "lodash": ">=4.17.21",
137
- "postcss": ">=8.4.31",
138
- "semver": ">=7.5.3",
139
- "tar": ">=6.2.1",
140
- "yaml": ">=2.3.2"
143
+ "yaml": ">=2.6.0"
141
144
  }
142
145
  }
@@ -462,14 +462,16 @@ export default defineComponent({
462
462
 
463
463
  // Range Fix ?
464
464
  // https://github.com/logue/vue-codemirror6/issues/27
465
- const isSelectionOutOfRange = !view.value.state.selection.ranges.every(
465
+ const isSelectionOutOfRange = !view.value.state.selection.ranges.every(
466
466
  range => range.anchor < value.length && range.head < value.length
467
- )
468
-
467
+ );
468
+
469
469
  // Update
470
470
  view.value.dispatch({
471
471
  changes: { from: 0, to: view.value.state.doc.length, insert: value },
472
- selection: isSelectionOutOfRange ? { anchor: 0, head: 0 } : view.value.state.selection,
472
+ selection: isSelectionOutOfRange
473
+ ? { anchor: 0, head: 0 }
474
+ : view.value.state.selection,
473
475
  scrollIntoView: true,
474
476
  });
475
477
  },
@@ -1,3 +0,0 @@
1
- /** CodeMirror Component */
2
- declare const _default: any;
3
- export default _default;