vue-codemirror6 0.6.5 → 0.6.6

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
@@ -234,25 +234,26 @@ export default defineComponent({
234
234
 
235
235
  ## Methods
236
236
 
237
- | Methods | Description |
238
- | ------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------ |
239
- | selection() | Get the [EditorSelection](https://codemirror.net/docs/ref/#state.EditorSelection) instance. |
240
- | getRange(from?: number, to?: number) | Get the text between the given points in the editor. |
241
- | getLine(number: number) | Get the content of line. |
242
- | lineCount() | Get the number of lines in the editor. |
243
- | getCursor() | Retrieve one end of the primary selection. |
244
- | listSelections() | Retrieves a list of all current selections. |
245
- | getSelection() | Get the currently selected code. |
246
- | getSelections() | The length of the given array should be the same as the number of active selections. |
247
- | somethingSelected() | Return true if any text is selected. |
248
- | replaceRange(replacement: string \| Text, from: number, to: number) | Replace the part of the document between from and to with the given string. |
249
- | replaceSelection(replacement: string \| Text) | Replace the selection(s) with the given string. |
250
- | setCursor(position: number) | Set the cursor position. |
251
- | setSelection(anchor: number, head?: number) | Set a single selection range. |
252
- | setSelections(ranges: readonly SelectionRange[], primary?: number) | Sets a new set of selections. |
253
- | extendSelectionsBy(f: Function) | Applies the given function to all existing selections, and calls extendSelections on the result. |
254
- | focus() | Set focus |
255
- | hasFocus() | is Focused |
237
+ | Methods | Description |
238
+ | ------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- |
239
+ | selection | Get and set the [EditorSelection](https://codemirror.net/docs/ref/#state.EditorSelection) instance. |
240
+ | cursor | Get and set the cursor location. |
241
+ | getRange(from?: number, to?: number) | Get the text between the given points in the editor. |
242
+ | getLine(number: number) | Get the content of line. |
243
+ | lineCount() | Get the number of lines in the editor. |
244
+ | getCursor() | Retrieve one end of the primary selection. |
245
+ | listSelections() | Retrieves a list of all current selections. |
246
+ | getSelection() | Get the currently selected code. |
247
+ | getSelections() | The length of the given array should be the same as the number of active selections. |
248
+ | somethingSelected() | Return true if any text is selected. |
249
+ | replaceRange(replacement: string \| Text, from: number, to: number) | Replace the part of the document between from and to with the given string. |
250
+ | replaceSelection(replacement: string \| Text) | Replace the selection(s) with the given string. |
251
+ | setCursor(position: number) | Set the cursor position. |
252
+ | setSelection(anchor: number, head?: number) | Set a single selection range. |
253
+ | setSelections(ranges: readonly SelectionRange[], primary?: number) | Sets a new set of selections. |
254
+ | extendSelectionsBy(f: Function) | Applies the given function to all existing selections, and calls extendSelections on the result. |
255
+ | focus() | Set focus |
256
+ | hasFocus() | is Focused |
256
257
 
257
258
  ## Recommendations
258
259
 
@@ -10,8 +10,9 @@ export interface CodeMirrorEmitsInterface {
10
10
  /** Model Update */
11
11
  (e: 'update:modelValue', value: string | Text): void;
12
12
  /** CodeMirror ViewUpdate */
13
- (e: 'update', value: ViewUpdate): void;
13
+ (e: 'update:view', value: ViewUpdate): void;
14
14
  }
15
+ /** CodeMirror Component */
15
16
  declare const _default: import("vue-demi").DefineComponent<{
16
17
  /** Model value */
17
18
  modelValue: {
@@ -122,7 +123,7 @@ declare const _default: import("vue-demi").DefineComponent<{
122
123
  */
123
124
  linter: {
124
125
  type: PropType<LintSource>;
125
- default: () => undefined;
126
+ default: undefined;
126
127
  };
127
128
  /** Show Gutter */
128
129
  lintGutter: {
@@ -133,8 +134,8 @@ declare const _default: import("vue-demi").DefineComponent<{
133
134
  context: SetupContext<import("vue-demi").EmitsOptions>;
134
135
  editor: Ref<Element | undefined>;
135
136
  cursor: Ref<number>;
136
- selection: () => EditorSelection;
137
- getRange: (from?: number | undefined, to?: number | undefined) => string;
137
+ selection: Ref<EditorSelection>;
138
+ getRange: (from?: number, to?: number) => string;
138
139
  getLine: (number: number) => string;
139
140
  lineCount: () => number;
140
141
  getCursor: () => number;
@@ -145,8 +146,8 @@ declare const _default: import("vue-demi").DefineComponent<{
145
146
  replaceRange: (replacement: string | Text, from: number, to: number) => void;
146
147
  replaceSelection: (replacement: string | Text) => void;
147
148
  setCursor: (position: number) => number;
148
- setSelection: (anchor: number, head?: number | undefined) => void;
149
- setSelections: (ranges: readonly SelectionRange[], primary?: number | undefined) => void;
149
+ setSelection: (anchor: number, head?: number) => void;
150
+ setSelections: (ranges: readonly SelectionRange[], primary?: number) => void;
150
151
  extendSelectionsBy: (f: Function) => void;
151
152
  focus: () => void;
152
153
  hasFocus: () => boolean;
@@ -260,7 +261,7 @@ declare const _default: import("vue-demi").DefineComponent<{
260
261
  */
261
262
  linter: {
262
263
  type: PropType<LintSource>;
263
- default: () => undefined;
264
+ default: undefined;
264
265
  };
265
266
  /** Show Gutter */
266
267
  lintGutter: {
@@ -285,6 +286,5 @@ declare const _default: import("vue-demi").DefineComponent<{
285
286
  linter: LintSource;
286
287
  lintGutter: boolean;
287
288
  }>;
288
- /** CodeMirror Component */
289
289
  export default _default;
290
290
  //# sourceMappingURL=CodeMirror.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"CodeMirror.d.ts","sourceRoot":"","sources":["../../src/components/CodeMirror.ts"],"names":[],"mappings":"AAAA,OAAO,EASL,KAAK,QAAQ,EACb,KAAK,GAAG,EACR,KAAK,YAAY,EAClB,MAAM,UAAU,CAAC;AAOlB,OAAO,EAAE,eAAe,EAA4B,MAAM,mBAAmB,CAAC;AAM9E,OAAO,KAAK,EACV,SAAS,EACT,cAAc,EACd,IAAI,EAEL,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE3C,qBAAqB;AACrB,MAAM,WAAW,wBAAwB;IACvC,mBAAmB;IACnB,CAAC,CAAC,EAAE,mBAAmB,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,I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;oBAUlB,OAAO;;IAnW5B,kBAAkB;;;;;IAKlB;;;;OAIG;;;;;;;IAOH,gBAAgB;;;;;IAKhB;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAOH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;AA3HtB,wBA4ZG"}
@@ -1,3 +1,4 @@
1
+ import { VNode } from 'vue-demi';
1
2
  interface Options {
2
3
  class?: string;
3
4
  domProps?: Record<any, any>;
@@ -7,9 +8,7 @@ interface Options {
7
8
  style?: string;
8
9
  'aria-hidden'?: string;
9
10
  }
10
- declare const h: (type: string | Record<any, any>, options?: Options, chidren?: any) => import("vue-demi").VNode<import("vue-demi").RendererNode, import("vue-demi").RendererElement, {
11
- [key: string]: any;
12
- }>;
11
+ declare const h: (type: string | Record<any, any>, options?: Options, chidren?: any) => VNode;
13
12
  declare const slot: (defaultSlots: any) => any;
14
13
  export { slot, h as default };
15
14
  //# sourceMappingURL=h-demi.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"h-demi.d.ts","sourceRoot":"","sources":["../../src/helpers/h-demi.ts"],"names":[],"mappings":"AAEA,UAAU,OAAO;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IAC5B,EAAE,CAAC,EAAE,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IACzB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAWD,QAAA,MAAM,CAAC,SACC,MAAM,GAAG,OAAO,GAAG,EAAE,GAAG,CAAC,YACtB,OAAO,YACN,GAAG;;EAWd,CAAC;AAEF,QAAA,MAAM,IAAI,iBAAkB,GAAG,QACoC,CAAC;AAEpE,OAAO,EAAE,IAAI,EAAE,CAAC,IAAI,OAAO,EAAE,CAAC"}
1
+ {"version":3,"file":"h-demi.d.ts","sourceRoot":"","sources":["../../src/helpers/h-demi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,EAAQ,MAAM,UAAU,CAAC;AAE3D,UAAU,OAAO;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IAC5B,EAAE,CAAC,EAAE,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IACzB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAWD,QAAA,MAAM,CAAC,SACC,MAAM,GAAG,OAAO,GAAG,EAAE,GAAG,CAAC,YACtB,OAAO,YACN,GAAG,KACZ,KAcF,CAAC;AAEF,QAAA,MAAM,IAAI,iBAAkB,GAAG,QACoC,CAAC;AAEpE,OAAO,EAAE,IAAI,EAAE,CAAC,IAAI,OAAO,EAAE,CAAC"}
package/dist/index.es.js CHANGED
@@ -5,11 +5,11 @@
5
5
  * @author Logue <logue@hotmail.co.jp>
6
6
  * @copyright 2022 By Masashi Yoshikawa All rights reserved.
7
7
  * @license MIT
8
- * @version 0.6.5
8
+ * @version 0.6.6
9
9
  * @see {@link https://github.com/logue/vue-codemirror6}
10
10
  */
11
11
 
12
- import { isVue2, h as h$1, defineComponent, ref, computed, watch, onMounted, nextTick, onUnmounted, toRaw } from "vue-demi";
12
+ import { isVue2, Vue2, h as h$1, defineComponent, ref, computed, watch, onMounted, nextTick, onUnmounted, toRaw } from "vue-demi";
13
13
  import { trim, compact } from "lodash";
14
14
  import { StateEffect, EditorState, EditorSelection } from "@codemirror/state";
15
15
  import { EditorView, keymap } from "@codemirror/view";
@@ -18,7 +18,7 @@ import { basicSetup, minimalSetup } from "codemirror";
18
18
  import { indentWithTab } from "@codemirror/commands";
19
19
  const adaptOnsV3 = (ons) => {
20
20
  if (!ons)
21
- return null;
21
+ return {};
22
22
  return Object.entries(ons).reduce((ret, [key, handler]) => {
23
23
  key = key.charAt(0).toUpperCase() + key.slice(1);
24
24
  key = `on${key}`;
@@ -26,8 +26,9 @@ const adaptOnsV3 = (ons) => {
26
26
  }, {});
27
27
  };
28
28
  const h = (type, options = {}, chidren) => {
29
- if (isVue2)
29
+ if (isVue2 && parseInt(Vue2.version) < 2.7) {
30
30
  return h$1(type, options, chidren);
31
+ }
31
32
  const { props, domProps, on, ...extraOptions } = options;
32
33
  const ons = on ? adaptOnsV3(on) : {};
33
34
  return h$1(type, { ...extraOptions, ...props, ...domProps, ...ons }, chidren);
@@ -94,7 +95,7 @@ var CodeMirror = defineComponent({
94
95
  },
95
96
  linter: {
96
97
  type: Function,
97
- default: () => void 0
98
+ default: void 0
98
99
  },
99
100
  lintGutter: {
100
101
  type: Boolean,
@@ -106,9 +107,13 @@ var CodeMirror = defineComponent({
106
107
  const editor = ref();
107
108
  const doc = ref(props.modelValue);
108
109
  let view;
110
+ const selection = computed({
111
+ get: () => view.state.selection,
112
+ set: (s) => view.dispatch({ selection: s })
113
+ });
109
114
  const cursor = computed({
110
- get: () => view.state.selection.main.head || 0,
111
- set: (p) => view.dispatch({ selection: { anchor: p } })
115
+ get: () => selection.value.main.head || 0,
116
+ set: (a) => view.dispatch({ selection: { anchor: a } })
112
117
  });
113
118
  const emit = context.emit;
114
119
  watch(() => props.modelValue, (text) => {
@@ -152,7 +157,7 @@ var CodeMirror = defineComponent({
152
157
  const extensions = compact([
153
158
  props.basic ? basicSetup : void 0,
154
159
  props.minimal && !props.basic ? minimalSetup : void 0,
155
- EditorView.updateListener.of((update) => emit("update", update)),
160
+ EditorView.updateListener.of((update) => emit("update:view", update)),
156
161
  EditorView.theme(props.theme, { dark: props.dark }),
157
162
  props.wrap ? EditorView.lineWrapping : void 0,
158
163
  props.tab ? keymap.of([indentWithTab]) : void 0,
@@ -166,15 +171,14 @@ var CodeMirror = defineComponent({
166
171
  ]);
167
172
  return extensions;
168
173
  };
169
- const selection = () => view.state.selection;
170
174
  const getRange = (from, to) => view.state.sliceDoc(from, to);
171
175
  const getLine = (number) => view.state.doc.line(number + 1).text;
172
176
  const lineCount = () => view.state.doc.lines;
173
177
  const getCursor = () => cursor.value;
174
- const listSelections = () => selection().ranges;
175
- const getSelection = () => view.state.sliceDoc(selection().main.from, selection().main.to);
176
- const getSelections = () => selection().ranges.map((r) => view.state.sliceDoc(r.from, r.to));
177
- const somethingSelected = () => selection().ranges.some((r) => !r.empty);
178
+ const listSelections = () => view.state.selection.ranges;
179
+ const getSelection = () => view.state.sliceDoc(view.state.selection.main.from, view.state.selection.main.to);
180
+ const getSelections = () => view.state.selection.ranges.map((r) => view.state.sliceDoc(r.from, r.to));
181
+ const somethingSelected = () => view.state.selection.ranges.some((r) => !r.empty);
178
182
  const replaceRange = (replacement, from, to) => view.dispatch({
179
183
  changes: { from, to, insert: replacement }
180
184
  });
@@ -185,7 +189,7 @@ var CodeMirror = defineComponent({
185
189
  selection: EditorSelection.create(ranges, primary)
186
190
  });
187
191
  const extendSelectionsBy = (f) => view.dispatch({
188
- selection: EditorSelection.create(selection().ranges.map((r) => r.extend(f(r))))
192
+ selection: EditorSelection.create(selection.value.ranges.map((r) => r.extend(f(r))))
189
193
  });
190
194
  const focus = () => view.focus();
191
195
  const hasFocus = () => view.hasFocus;
package/dist/index.umd.js CHANGED
@@ -5,8 +5,8 @@
5
5
  * @author Logue <logue@hotmail.co.jp>
6
6
  * @copyright 2022 By Masashi Yoshikawa All rights reserved.
7
7
  * @license MIT
8
- * @version 0.6.5
8
+ * @version 0.6.6
9
9
  * @see {@link https://github.com/logue/vue-codemirror6}
10
10
  */
11
11
 
12
- (function(r,n){typeof exports=="object"&&typeof module<"u"?n(exports,require("vue-demi"),require("lodash"),require("@codemirror/state"),require("@codemirror/view"),require("@codemirror/lint"),require("codemirror"),require("@codemirror/commands")):typeof define=="function"&&define.amd?define(["exports","vue-demi","lodash","@codemirror/state","@codemirror/view","@codemirror/lint","codemirror","@codemirror/commands"],n):(r=typeof globalThis<"u"?globalThis:r||self,n(r.CodeMirror={},r.VueDemi,r.lodash,r.state,r.view,r.lint,r.codemirror,r.commands))})(this,function(r,n,g,f,c,y,S,w){"use strict";const V=e=>e?Object.entries(e).reduce((s,[a,l])=>(a=a.charAt(0).toUpperCase()+a.slice(1),a=`on${a}`,{...s,[a]:l}),{}):null,v=(e,s={},a)=>{if(n.isVue2)return n.h(e,s,a);const{props:l,domProps:o,on:u,...m}=s,h=u?V(u):{};return n.h(e,{...m,...l,...o,...h},a)},C=e=>typeof e=="function"?e():e;var p=n.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},wrap:{type:Boolean,default:!1},tab:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1},editable:{type:Boolean,default:!0},extensions:{type:Array,default:()=>[]},phrases:{type:Object,default:()=>{}},lang:{type:Object,default:()=>{}},linter:{type:Function,default:()=>{}},lintGutter:{type:Boolean,defalt:!1}},emits:["update:modelValue","update:view"],setup(e,s){const a=n.ref(),l=n.ref(e.modelValue);let o;const u=n.computed({get:()=>o.state.selection.main.head||0,set:t=>o.dispatch({selection:{anchor:t}})}),m=s.emit;n.watch(()=>e.modelValue,t=>{if(o.composing)return;const i=o.state.selection;o.dispatch({changes:{from:0,to:o.state.doc.length,insert:t},selection:i})}),n.watch(()=>e.dark,()=>{o.dispatch({effects:f.StateEffect.reconfigure.of(h())})}),n.onMounted(async()=>{let t=l.value;a.value&&a.value.childNodes[0]&&(l.value!==""&&console.warn("[CodeMirror.vue] The <code-mirror> tag contains child elements that overwrite the `v-model` values."),t=g.trim(a.value.childNodes[0].innerText)),o=new c.EditorView({doc:t,extensions:h(),parent:a.value,dispatch:i=>{o.update([i]),!i.changes.empty&&m("update:modelValue",o.state.doc.toString())}}),await n.nextTick()}),n.onUnmounted(()=>o.destroy());const h=()=>g.compact([e.basic?S.basicSetup:void 0,e.minimal&&!e.basic?S.minimalSetup:void 0,c.EditorView.updateListener.of(i=>m("update",i)),c.EditorView.theme(e.theme,{dark:e.dark}),e.wrap?c.EditorView.lineWrapping:void 0,e.tab?c.keymap.of([w.indentWithTab]):void 0,e.phrases?f.EditorState.phrases.of(e.phrases):void 0,e.readonly?f.EditorState.readOnly.of(e.readonly):void 0,e.editable?c.EditorView.editable.of(e.editable):void 0,e.lang?n.toRaw(e.lang):void 0,e.linter?y.linter(e.linter):void 0,e.linter&&e.lintGutter?y.lintGutter():void 0,...e.extensions]),d=()=>o.state.selection;return{context:s,editor:a,cursor:u,selection:d,getRange:(t,i)=>o.state.sliceDoc(t,i),getLine:t=>o.state.doc.line(t+1).text,lineCount:()=>o.state.doc.lines,getCursor:()=>u.value,listSelections:()=>d().ranges,getSelection:()=>o.state.sliceDoc(d().main.from,d().main.to),getSelections:()=>d().ranges.map(t=>o.state.sliceDoc(t.from,t.to)),somethingSelected:()=>d().ranges.some(t=>!t.empty),replaceRange:(t,i,b)=>o.dispatch({changes:{from:i,to:b,insert:t}}),replaceSelection:t=>o.dispatch(o.state.replaceSelection(t)),setCursor:t=>u.value=t,setSelection:(t,i)=>o.dispatch({selection:{anchor:t,head:i}}),setSelections:(t,i)=>o.dispatch({selection:f.EditorSelection.create(t,i)}),extendSelectionsBy:t=>o.dispatch({selection:f.EditorSelection.create(d().ranges.map(i=>i.extend(t(i))))}),focus:()=>o.focus(),hasFocus:()=>o.hasFocus}},render(){return v("div",{ref:"editor",class:"vue-codemirror"},this.$slots.default?v("aside",{style:"display: none;","aria-hidden":"true"},C(this.$slots.default)):void 0)}});const x=e=>e.component("CodeMirror",p);typeof window<"u"&&window.Vue&&window.Vue.use(p),r.default=p,r.install=x,Object.defineProperties(r,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
12
+ (function(a,n){typeof exports=="object"&&typeof module<"u"?n(exports,require("vue-demi"),require("lodash"),require("@codemirror/state"),require("@codemirror/view"),require("@codemirror/lint"),require("codemirror"),require("@codemirror/commands")):typeof define=="function"&&define.amd?define(["exports","vue-demi","lodash","@codemirror/state","@codemirror/view","@codemirror/lint","codemirror","@codemirror/commands"],n):(a=typeof globalThis<"u"?globalThis:a||self,n(a.CodeMirror={},a.VueDemi,a.lodash,a.state,a.view,a.lint,a.codemirror,a.commands))})(this,function(a,n,p,u,c,g,y,w){"use strict";const V=e=>e?Object.entries(e).reduce((r,[s,d])=>(s=s.charAt(0).toUpperCase()+s.slice(1),s=`on${s}`,{...r,[s]:d}),{}):{},v=(e,r={},s)=>{if(n.isVue2&&parseInt(n.Vue2.version)<2.7)return n.h(e,r,s);const{props:d,domProps:t,on:l,...f}=r,m=l?V(l):{};return n.h(e,{...f,...d,...t,...m},s)},C=e=>typeof e=="function"?e():e;var h=n.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},wrap:{type:Boolean,default:!1},tab:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1},editable:{type:Boolean,default:!0},extensions:{type:Array,default:()=>[]},phrases:{type:Object,default:()=>{}},lang:{type:Object,default:()=>{}},linter:{type:Function,default:void 0},lintGutter:{type:Boolean,defalt:!1}},emits:["update:modelValue","update:view"],setup(e,r){const s=n.ref(),d=n.ref(e.modelValue);let t;const l=n.computed({get:()=>t.state.selection,set:o=>t.dispatch({selection:o})}),f=n.computed({get:()=>l.value.main.head||0,set:o=>t.dispatch({selection:{anchor:o}})}),m=r.emit;n.watch(()=>e.modelValue,o=>{if(t.composing)return;const i=t.state.selection;t.dispatch({changes:{from:0,to:t.state.doc.length,insert:o},selection:i})}),n.watch(()=>e.dark,()=>{t.dispatch({effects:u.StateEffect.reconfigure.of(S())})}),n.onMounted(async()=>{let o=d.value;s.value&&s.value.childNodes[0]&&(d.value!==""&&console.warn("[CodeMirror.vue] The <code-mirror> tag contains child elements that overwrite the `v-model` values."),o=p.trim(s.value.childNodes[0].innerText)),t=new c.EditorView({doc:o,extensions:S(),parent:s.value,dispatch:i=>{t.update([i]),!i.changes.empty&&m("update:modelValue",t.state.doc.toString())}}),await n.nextTick()}),n.onUnmounted(()=>t.destroy());const S=()=>p.compact([e.basic?y.basicSetup:void 0,e.minimal&&!e.basic?y.minimalSetup:void 0,c.EditorView.updateListener.of(i=>m("update:view",i)),c.EditorView.theme(e.theme,{dark:e.dark}),e.wrap?c.EditorView.lineWrapping:void 0,e.tab?c.keymap.of([w.indentWithTab]):void 0,e.phrases?u.EditorState.phrases.of(e.phrases):void 0,e.readonly?u.EditorState.readOnly.of(e.readonly):void 0,e.editable?c.EditorView.editable.of(e.editable):void 0,e.lang?n.toRaw(e.lang):void 0,e.linter?g.linter(e.linter):void 0,e.linter&&e.lintGutter?g.lintGutter():void 0,...e.extensions]);return{context:r,editor:s,cursor:f,selection:l,getRange:(o,i)=>t.state.sliceDoc(o,i),getLine:o=>t.state.doc.line(o+1).text,lineCount:()=>t.state.doc.lines,getCursor:()=>f.value,listSelections:()=>t.state.selection.ranges,getSelection:()=>t.state.sliceDoc(t.state.selection.main.from,t.state.selection.main.to),getSelections:()=>t.state.selection.ranges.map(o=>t.state.sliceDoc(o.from,o.to)),somethingSelected:()=>t.state.selection.ranges.some(o=>!o.empty),replaceRange:(o,i,b)=>t.dispatch({changes:{from:i,to:b,insert:o}}),replaceSelection:o=>t.dispatch(t.state.replaceSelection(o)),setCursor:o=>f.value=o,setSelection:(o,i)=>t.dispatch({selection:{anchor:o,head:i}}),setSelections:(o,i)=>t.dispatch({selection:u.EditorSelection.create(o,i)}),extendSelectionsBy:o=>t.dispatch({selection:u.EditorSelection.create(l.value.ranges.map(i=>i.extend(o(i))))}),focus:()=>t.focus(),hasFocus:()=>t.hasFocus}},render(){return v("div",{ref:"editor",class:"vue-codemirror"},this.$slots.default?v("aside",{style:"display: none;","aria-hidden":"true"},C(this.$slots.default)):void 0)}});const x=e=>e.component("CodeMirror",h);typeof window<"u"&&window.Vue&&window.Vue.use(h),a.default=h,a.install=x,Object.defineProperties(a,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
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": "0.6.5",
4
+ "version": "0.6.6",
5
5
  "description": "CodeMirror6 Component for vue2 and vue3",
6
6
  "keywords": [
7
7
  "vuejs",
@@ -64,11 +64,11 @@
64
64
  "prepare": "husky install"
65
65
  },
66
66
  "dependencies": {
67
- "codemirror": "^6.0.1",
68
67
  "vue-demi": "latest"
69
68
  },
70
69
  "peerDependencies": {
71
- "@vue/composition-api": "^1.6.3",
70
+ "@vue/composition-api": "^1.7.0",
71
+ "codemirror": "^6.0.1",
72
72
  "vue": "^2.6.14 || ^3.2.37"
73
73
  },
74
74
  "peerDependenciesMeta": {
@@ -80,21 +80,22 @@
80
80
  "@codemirror/lang-javascript": "^6.0.1",
81
81
  "@codemirror/lang-markdown": "^6.0.0",
82
82
  "@types/lodash": "^4.14.182",
83
- "@types/node": "^18.0.1",
84
- "@typescript-eslint/eslint-plugin": "^5.30.4",
85
- "@typescript-eslint/parser": "^5.30.4",
83
+ "@types/node": "^18.0.3",
84
+ "@typescript-eslint/eslint-plugin": "^5.30.5",
85
+ "@typescript-eslint/parser": "^5.30.5",
86
86
  "@vitejs/plugin-vue": "^2.3.3",
87
87
  "@vue/eslint-config-prettier": "^7.0.0",
88
+ "codemirror": "^6.0.1",
88
89
  "eslint": "^8.19.0",
89
90
  "eslint-config-google": "^0.14.0",
90
91
  "eslint-config-prettier": "^8.5.0",
91
92
  "eslint-import-resolver-alias": "^1.1.2",
92
- "eslint-import-resolver-typescript": "^3.2.0",
93
+ "eslint-import-resolver-typescript": "^3.2.4",
93
94
  "eslint-plugin-html": "^6.2.0",
94
95
  "eslint-plugin-import": "^2.26.0",
95
96
  "eslint-plugin-jsdoc": "^39.3.3",
96
97
  "eslint-plugin-tsdoc": "^0.2.16",
97
- "eslint-plugin-vue": "^9.1.1",
98
+ "eslint-plugin-vue": "^9.2.0",
98
99
  "eslint-plugin-vuejs-accessibility": "^1.2.0",
99
100
  "eslint-plugin-yaml": "^0.5.0",
100
101
  "eslint4b-prebuilt": "^6.7.2",
@@ -104,10 +105,10 @@
104
105
  "prettier": "^2.7.1",
105
106
  "rimraf": "^3.0.2",
106
107
  "rollup-plugin-visualizer": "^5.6.0",
107
- "typescript": "4.6.*",
108
+ "typescript": "^4.7.4",
108
109
  "vite": "^2.9.13",
109
110
  "vite-plugin-banner": "^0.3.0",
110
- "vite-plugin-checker": "^0.4.7",
111
+ "vite-plugin-checker": "^0.4.8",
111
112
  "vue": "^3.2.37",
112
113
  "vue-eslint-parser": "^9.0.3",
113
114
  "vue-tsc": "^0.38.2"