vue-codemirror6 0.5.2 → 0.5.3
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/components/CodeMirror.d.ts +28 -31
- package/dist/components/CodeMirror.d.ts.map +1 -1
- package/dist/index.es.js +71 -31
- package/dist/index.umd.js +2 -2
- package/package.json +8 -13
- package/dist/interfaces/CodeMirrorEmitsInterface.d.ts +0 -9
- package/dist/interfaces/CodeMirrorEmitsInterface.d.ts.map +0 -1
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
import { type PropType, type Ref, type SetupContext } from 'vue-demi';
|
|
2
2
|
import { EditorSelection } from '@codemirror/state';
|
|
3
|
-
import type { Extension, Text } from '@codemirror/state';
|
|
3
|
+
import type { Extension, SelectionRange, Text } from '@codemirror/state';
|
|
4
4
|
import type { LanguageSupport } from '@codemirror/language';
|
|
5
|
+
import type { ViewUpdate } from '@codemirror/view';
|
|
5
6
|
import type { LintSource } from '@codemirror/lint';
|
|
6
7
|
import type { StyleSpec } from 'style-mod';
|
|
8
|
+
/** Emit Interface */
|
|
9
|
+
export interface CodeMirrorEmitsInterface {
|
|
10
|
+
/** Model Update */
|
|
11
|
+
(e: 'update:modelValue', value: string | Text): void;
|
|
12
|
+
/** CodeMirror ViewUpdate */
|
|
13
|
+
(e: 'update', value: ViewUpdate): void;
|
|
14
|
+
}
|
|
7
15
|
/** CodeMirror Component */
|
|
8
16
|
declare const _default: import("vue-demi").DefineComponent<{
|
|
9
17
|
/** Model value */
|
|
@@ -11,18 +19,6 @@ declare const _default: import("vue-demi").DefineComponent<{
|
|
|
11
19
|
type: PropType<string | Text>;
|
|
12
20
|
default: string;
|
|
13
21
|
};
|
|
14
|
-
/**
|
|
15
|
-
* Selection
|
|
16
|
-
*
|
|
17
|
-
* @see {@link https://codemirror.net/6/docs/ref/#state.EditorSelection | EditorSelection}
|
|
18
|
-
*/
|
|
19
|
-
selection: {
|
|
20
|
-
type: PropType<EditorSelection | {
|
|
21
|
-
anchor: number;
|
|
22
|
-
head?: number | undefined;
|
|
23
|
-
}>;
|
|
24
|
-
default: () => undefined;
|
|
25
|
-
};
|
|
26
22
|
/**
|
|
27
23
|
* Theme
|
|
28
24
|
*
|
|
@@ -118,7 +114,7 @@ declare const _default: import("vue-demi").DefineComponent<{
|
|
|
118
114
|
*/
|
|
119
115
|
linter: {
|
|
120
116
|
type: PropType<LintSource>;
|
|
121
|
-
default:
|
|
117
|
+
default: undefined;
|
|
122
118
|
};
|
|
123
119
|
/** Show Gutter */
|
|
124
120
|
lintGutter: {
|
|
@@ -128,24 +124,29 @@ declare const _default: import("vue-demi").DefineComponent<{
|
|
|
128
124
|
}, {
|
|
129
125
|
context: SetupContext<import("vue-demi").EmitsOptions>;
|
|
130
126
|
editor: Ref<Element | undefined>;
|
|
127
|
+
selection: () => EditorSelection;
|
|
128
|
+
getRange: (a?: number, b?: number) => string;
|
|
129
|
+
getLine: (n: number) => string;
|
|
130
|
+
lineCount: () => number;
|
|
131
|
+
getCursor: () => number;
|
|
132
|
+
listSelections: () => readonly SelectionRange[];
|
|
133
|
+
getSelection: () => string;
|
|
134
|
+
getSelections: () => string[];
|
|
135
|
+
somethingSelected: () => boolean;
|
|
136
|
+
replaceRange: (text: string | Text, from: number, to: number) => void;
|
|
137
|
+
replaceSelection: (text: string | Text) => void;
|
|
138
|
+
setCursor: (pos: number) => void;
|
|
139
|
+
setSelection: (anchor: number, head: number) => void;
|
|
140
|
+
setSelections: (ranges: readonly SelectionRange[], mainIndex?: number | undefined) => void;
|
|
141
|
+
extendSelectionsBy: (f: any) => void;
|
|
142
|
+
focus: () => void;
|
|
143
|
+
hasFocus: () => boolean;
|
|
131
144
|
}, unknown, {}, {}, import("vue-demi").ComponentOptionsMixin, import("vue-demi").ComponentOptionsMixin, import("vue-demi").EmitsOptions, "update:modelValue" | "update", import("vue-demi").VNodeProps & import("vue-demi").AllowedComponentProps & import("vue-demi").ComponentCustomProps, Readonly<import("vue-demi").ExtractPropTypes<{
|
|
132
145
|
/** Model value */
|
|
133
146
|
modelValue: {
|
|
134
147
|
type: PropType<string | Text>;
|
|
135
148
|
default: string;
|
|
136
149
|
};
|
|
137
|
-
/**
|
|
138
|
-
* Selection
|
|
139
|
-
*
|
|
140
|
-
* @see {@link https://codemirror.net/6/docs/ref/#state.EditorSelection | EditorSelection}
|
|
141
|
-
*/
|
|
142
|
-
selection: {
|
|
143
|
-
type: PropType<EditorSelection | {
|
|
144
|
-
anchor: number;
|
|
145
|
-
head?: number | undefined;
|
|
146
|
-
}>;
|
|
147
|
-
default: () => undefined;
|
|
148
|
-
};
|
|
149
150
|
/**
|
|
150
151
|
* Theme
|
|
151
152
|
*
|
|
@@ -241,7 +242,7 @@ declare const _default: import("vue-demi").DefineComponent<{
|
|
|
241
242
|
*/
|
|
242
243
|
linter: {
|
|
243
244
|
type: PropType<LintSource>;
|
|
244
|
-
default:
|
|
245
|
+
default: undefined;
|
|
245
246
|
};
|
|
246
247
|
/** Show Gutter */
|
|
247
248
|
lintGutter: {
|
|
@@ -250,10 +251,6 @@ declare const _default: import("vue-demi").DefineComponent<{
|
|
|
250
251
|
};
|
|
251
252
|
}>>, {
|
|
252
253
|
modelValue: string | Text;
|
|
253
|
-
selection: EditorSelection | {
|
|
254
|
-
anchor: number;
|
|
255
|
-
head?: number | undefined;
|
|
256
|
-
};
|
|
257
254
|
theme: {
|
|
258
255
|
[selector: string]: StyleSpec;
|
|
259
256
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeMirror.d.ts","sourceRoot":"","sources":["../../src/components/CodeMirror.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
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;AAElB,OAAO,EAAE,eAAe,EAAe,MAAM,mBAAmB,CAAC;AAUjE,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,IAAI,CAAC;IACrD,4BAA4B;IAC5B,CAAC,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,GAAG,IAAI,CAAC;CACxC;AAED,2BAA2B;;IAWvB,kBAAkB;;;;;IAKlB;;;;OAIG;;;;;;;IAOH,gBAAgB;;;;;IAKhB;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAOH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH,kBAAkB;;;;;;;;qBAiJI,eAAe;mBAKf,MAAM,MAAM,MAAM,KAAG,MAAM;iBAE7B,MAAM,KAAG,MAAM;qBACb,MAAM;qBACN,MAAM;0BACD,SAAS,cAAc,EAAE;wBAC3B,MAAM;yBAEL,MAAM,EAAE;6BAEJ,OAAO;yBAIT,MAAM,GAAG,IAAI,QAAQ,MAAM,MAAM,MAAM;6BAInC,MAAM,GAAG,IAAI;qBAErB,MAAM;2BAEA,MAAM,QAAQ,MAAM;4BAGxC,SAAS,cAAc,EAAE,cACrB,MAAM,GAAG,SAAS;;;oBAeX,OAAO;;IAvS5B,kBAAkB;;;;;IAKlB;;;;OAIG;;;;;;;IAOH,gBAAgB;;;;;IAKhB;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAOH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH,kBAAkB;;;;;;;;;;;;;;;;;;;;;;AAlHtB,wBA2VG"}
|
package/dist/index.es.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { isVue2, h as h$1, defineComponent, ref, toRefs,
|
|
2
|
-
import { EditorState } from "@codemirror/state";
|
|
1
|
+
import { isVue2, h as h$1, defineComponent, ref, toRefs, watch, onMounted, nextTick, onUnmounted, toRaw } from "vue-demi";
|
|
2
|
+
import { EditorState, EditorSelection } from "@codemirror/state";
|
|
3
3
|
import { EditorView, keymap } from "@codemirror/view";
|
|
4
4
|
import { linter, lintGutter } from "@codemirror/lint";
|
|
5
5
|
import { basicSetup } from "@codemirror/basic-setup";
|
|
6
6
|
import { indentWithTab } from "@codemirror/commands";
|
|
7
|
-
import {
|
|
7
|
+
import { trim, compact } from "lodash";
|
|
8
8
|
const adaptOnsV3 = (ons) => {
|
|
9
9
|
if (!ons)
|
|
10
10
|
return null;
|
|
@@ -33,10 +33,6 @@ var CodeMirror = defineComponent({
|
|
|
33
33
|
type: String,
|
|
34
34
|
default: ""
|
|
35
35
|
},
|
|
36
|
-
selection: {
|
|
37
|
-
type: Object,
|
|
38
|
-
default: () => void 0
|
|
39
|
-
},
|
|
40
36
|
theme: {
|
|
41
37
|
type: Object,
|
|
42
38
|
default: () => {
|
|
@@ -83,7 +79,7 @@ var CodeMirror = defineComponent({
|
|
|
83
79
|
},
|
|
84
80
|
linter: {
|
|
85
81
|
type: Function,
|
|
86
|
-
default:
|
|
82
|
+
default: void 0
|
|
87
83
|
},
|
|
88
84
|
lintGutter: {
|
|
89
85
|
type: Boolean,
|
|
@@ -93,53 +89,39 @@ var CodeMirror = defineComponent({
|
|
|
93
89
|
emits: ["update:modelValue", "update"],
|
|
94
90
|
setup(props, context) {
|
|
95
91
|
const editor = ref();
|
|
96
|
-
const doc = ref(props.modelValue);
|
|
97
92
|
const { dark } = toRefs(props);
|
|
93
|
+
const doc = ref(props.modelValue);
|
|
98
94
|
const emit = context.emit;
|
|
99
|
-
const exts = computed(() => compact([
|
|
100
|
-
props.basic ? basicSetup : void 0,
|
|
101
|
-
EditorView.updateListener.of((update) => emit("update", update)),
|
|
102
|
-
EditorView.theme(props.theme, { dark: dark.value }),
|
|
103
|
-
props.wrap ? EditorView.lineWrapping : void 0,
|
|
104
|
-
props.tab ? keymap.of([indentWithTab]) : void 0,
|
|
105
|
-
props.phrases ? EditorState.phrases.of(props.phrases) : void 0,
|
|
106
|
-
props.readonly ? EditorState.readOnly.of(props.readonly) : void 0,
|
|
107
|
-
props.editable ? EditorView.editable.of(props.editable) : void 0,
|
|
108
|
-
props.lang ? toRaw(props.lang) : void 0,
|
|
109
|
-
props.linter ? linter(props.linter) : void 0,
|
|
110
|
-
props.linter && props.lintGutter ? lintGutter() : void 0,
|
|
111
|
-
...props.extensions
|
|
112
|
-
]));
|
|
113
95
|
let view;
|
|
114
|
-
watch(doc, (
|
|
96
|
+
watch(doc, (value) => {
|
|
115
97
|
if (view.composing) {
|
|
116
98
|
return;
|
|
117
99
|
}
|
|
118
100
|
const previous = view.state.selection;
|
|
119
101
|
view.setState(EditorState.create({
|
|
120
|
-
doc:
|
|
121
|
-
extensions:
|
|
102
|
+
doc: value,
|
|
103
|
+
extensions: getExtensions(),
|
|
122
104
|
selection: previous
|
|
123
105
|
}));
|
|
124
106
|
});
|
|
107
|
+
watch(() => props.modelValue, (v) => view.setState(EditorState.create({ doc: v, extensions: getExtensions() })));
|
|
125
108
|
watch(dark, () => {
|
|
126
109
|
view.setState(EditorState.create({
|
|
127
110
|
doc: doc.value,
|
|
128
|
-
extensions:
|
|
111
|
+
extensions: getExtensions()
|
|
129
112
|
}));
|
|
130
113
|
});
|
|
131
114
|
onMounted(async () => {
|
|
132
115
|
if (editor.value && editor.value.childNodes[0]) {
|
|
133
116
|
if (doc.value !== "") {
|
|
134
|
-
console.warn("[CodeMirror.vue] The
|
|
117
|
+
console.warn("[CodeMirror.vue] The <code-mirror> tag contains child elements that overwrite the `v-model` values.");
|
|
135
118
|
}
|
|
136
119
|
doc.value = trim(editor.value.childNodes[0].innerText);
|
|
137
120
|
}
|
|
138
121
|
view = new EditorView({
|
|
139
122
|
state: EditorState.create({
|
|
140
123
|
doc: doc.value,
|
|
141
|
-
|
|
142
|
-
extensions: exts.value
|
|
124
|
+
extensions: getExtensions()
|
|
143
125
|
}),
|
|
144
126
|
parent: editor.value,
|
|
145
127
|
dispatch: (tr) => {
|
|
@@ -153,9 +135,67 @@ var CodeMirror = defineComponent({
|
|
|
153
135
|
await nextTick();
|
|
154
136
|
});
|
|
155
137
|
onUnmounted(() => view.destroy());
|
|
138
|
+
const getExtensions = () => {
|
|
139
|
+
const extensions = compact([
|
|
140
|
+
props.basic ? basicSetup : void 0,
|
|
141
|
+
EditorView.updateListener.of((update) => emit("update", update)),
|
|
142
|
+
EditorView.theme(props.theme, { dark: dark.value }),
|
|
143
|
+
props.wrap ? EditorView.lineWrapping : void 0,
|
|
144
|
+
props.tab ? keymap.of([indentWithTab]) : void 0,
|
|
145
|
+
props.phrases ? EditorState.phrases.of(props.phrases) : void 0,
|
|
146
|
+
props.readonly ? EditorState.readOnly.of(props.readonly) : void 0,
|
|
147
|
+
props.editable ? EditorView.editable.of(props.editable) : void 0,
|
|
148
|
+
props.lang ? toRaw(props.lang) : void 0,
|
|
149
|
+
props.linter ? linter(props.linter) : void 0,
|
|
150
|
+
props.linter && props.lintGutter ? lintGutter() : void 0,
|
|
151
|
+
...props.extensions
|
|
152
|
+
]);
|
|
153
|
+
console.debug("[CodeMirror.vue] Loaded extensions: ", extensions);
|
|
154
|
+
return extensions;
|
|
155
|
+
};
|
|
156
|
+
const selection = () => view.state.selection;
|
|
157
|
+
const getRange = (a, b) => view.state.sliceDoc(a, b);
|
|
158
|
+
const getLine = (n) => view.state.doc.line(n + 1).text;
|
|
159
|
+
const lineCount = () => view.state.doc.lines;
|
|
160
|
+
const getCursor = () => selection().main.head;
|
|
161
|
+
const listSelections = () => selection().ranges;
|
|
162
|
+
const getSelection = () => view.state.sliceDoc(selection().main.from, selection().main.to);
|
|
163
|
+
const getSelections = () => selection().ranges.map((r) => view.state.sliceDoc(r.from, r.to));
|
|
164
|
+
const somethingSelected = () => selection().ranges.some((r) => !r.empty);
|
|
165
|
+
const replaceRange = (text, from, to) => view.dispatch({
|
|
166
|
+
changes: { from, to, insert: text }
|
|
167
|
+
});
|
|
168
|
+
const replaceSelection = (text) => view.dispatch(view.state.replaceSelection(text));
|
|
169
|
+
const setCursor = (pos) => view.dispatch({ selection: { anchor: pos } });
|
|
170
|
+
const setSelection = (anchor, head) => view.dispatch({ selection: { anchor, head } });
|
|
171
|
+
const setSelections = (ranges, mainIndex) => view.dispatch({
|
|
172
|
+
selection: EditorSelection.create(ranges, mainIndex)
|
|
173
|
+
});
|
|
174
|
+
const extendSelectionsBy = (f) => view.dispatch({
|
|
175
|
+
selection: EditorSelection.create(selection().ranges.map((r) => r.extend(f(r))))
|
|
176
|
+
});
|
|
177
|
+
const focus = () => view.focus();
|
|
178
|
+
const hasFocus = () => view.hasFocus;
|
|
156
179
|
return {
|
|
157
180
|
context,
|
|
158
|
-
editor
|
|
181
|
+
editor,
|
|
182
|
+
selection,
|
|
183
|
+
getRange,
|
|
184
|
+
getLine,
|
|
185
|
+
lineCount,
|
|
186
|
+
getCursor,
|
|
187
|
+
listSelections,
|
|
188
|
+
getSelection,
|
|
189
|
+
getSelections,
|
|
190
|
+
somethingSelected,
|
|
191
|
+
replaceRange,
|
|
192
|
+
replaceSelection,
|
|
193
|
+
setCursor,
|
|
194
|
+
setSelection,
|
|
195
|
+
setSelections,
|
|
196
|
+
extendSelectionsBy,
|
|
197
|
+
focus,
|
|
198
|
+
hasFocus
|
|
159
199
|
};
|
|
160
200
|
},
|
|
161
201
|
render() {
|
package/dist/index.umd.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
(function(r,
|
|
1
|
+
(function(r,n){typeof exports=="object"&&typeof module<"u"?n(exports,require("vue-demi"),require("@codemirror/state"),require("@codemirror/view"),require("@codemirror/lint"),require("@codemirror/basic-setup"),require("@codemirror/commands"),require("lodash")):typeof define=="function"&&define.amd?define(["exports","vue-demi","@codemirror/state","@codemirror/view","@codemirror/lint","@codemirror/basic-setup","@codemirror/commands","lodash"],n):(r=typeof globalThis<"u"?globalThis:r||self,n(r.CodeMirror={},r.VueDemi,r.state,r.view,r.lint,r.basicSetup,r.commands,r.lodash))})(this,function(r,n,d,u,p,v,x,S){"use strict";const C=e=>e?Object.entries(e).reduce((l,[i,f])=>(i=i.charAt(0).toUpperCase()+i.slice(1),i=`on${i}`,{...l,[i]:f}),{}):null,g=(e,l={},i)=>{if(n.isVue2)return n.h(e,l,i);const{props:f,domProps:a,on:h,...o}=l,m=h?C(h):{};return n.h(e,{...o,...f,...a,...m},i)},V=e=>typeof e=="function"?e():e;var y=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},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"],setup(e,l){const i=n.ref(),{dark:f}=n.toRefs(e),a=n.ref(e.modelValue),h=l.emit;let o;n.watch(a,t=>{if(o.composing)return;const s=o.state.selection;o.setState(d.EditorState.create({doc:t,extensions:m(),selection:s}))}),n.watch(()=>e.modelValue,t=>o.setState(d.EditorState.create({doc:t,extensions:m()}))),n.watch(f,()=>{o.setState(d.EditorState.create({doc:a.value,extensions:m()}))}),n.onMounted(async()=>{i.value&&i.value.childNodes[0]&&(a.value!==""&&console.warn("[CodeMirror.vue] The <code-mirror> tag contains child elements that overwrite the `v-model` values."),a.value=S.trim(i.value.childNodes[0].innerText)),o=new u.EditorView({state:d.EditorState.create({doc:a.value,extensions:m()}),parent:i.value,dispatch:t=>{o.update([t]),!t.changes.empty&&(a.value=o.state.doc.toString(),h("update:modelValue",a.value))}}),await n.nextTick()}),n.onUnmounted(()=>o.destroy());const m=()=>{const t=S.compact([e.basic?v.basicSetup:void 0,u.EditorView.updateListener.of(s=>h("update",s)),u.EditorView.theme(e.theme,{dark:f.value}),e.wrap?u.EditorView.lineWrapping:void 0,e.tab?u.keymap.of([x.indentWithTab]):void 0,e.phrases?d.EditorState.phrases.of(e.phrases):void 0,e.readonly?d.EditorState.readOnly.of(e.readonly):void 0,e.editable?u.EditorView.editable.of(e.editable):void 0,e.lang?n.toRaw(e.lang):void 0,e.linter?p.linter(e.linter):void 0,e.linter&&e.lintGutter?p.lintGutter():void 0,...e.extensions]);return console.debug("[CodeMirror.vue] Loaded extensions: ",t),t},c=()=>o.state.selection;return{context:l,editor:i,selection:c,getRange:(t,s)=>o.state.sliceDoc(t,s),getLine:t=>o.state.doc.line(t+1).text,lineCount:()=>o.state.doc.lines,getCursor:()=>c().main.head,listSelections:()=>c().ranges,getSelection:()=>o.state.sliceDoc(c().main.from,c().main.to),getSelections:()=>c().ranges.map(t=>o.state.sliceDoc(t.from,t.to)),somethingSelected:()=>c().ranges.some(t=>!t.empty),replaceRange:(t,s,w)=>o.dispatch({changes:{from:s,to:w,insert:t}}),replaceSelection:t=>o.dispatch(o.state.replaceSelection(t)),setCursor:t=>o.dispatch({selection:{anchor:t}}),setSelection:(t,s)=>o.dispatch({selection:{anchor:t,head:s}}),setSelections:(t,s)=>o.dispatch({selection:d.EditorSelection.create(t,s)}),extendSelectionsBy:t=>o.dispatch({selection:d.EditorSelection.create(c().ranges.map(s=>s.extend(t(s))))}),focus:()=>o.focus(),hasFocus:()=>o.hasFocus}},render(){return g("div",{ref:"editor",class:"vue-codemirror"},this.$slots.default?g("aside",{style:"display: none;"},V(this.$slots.default)):void 0)}});/**
|
|
2
2
|
* Vue CodeMirror6 Component
|
|
3
3
|
*
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @author Logue {@link logue@hotmail.co.jp}
|
|
6
6
|
* @copyright 2022 Masashi Yoshikawa {@link https://logue.dev/} All rights reserved.
|
|
7
7
|
* @see {@link https://github.com/logue/vue-codemirror6}
|
|
8
|
-
*/const
|
|
8
|
+
*/const b=e=>e.component("CodeMirror",y);r.default=y,r.install=b,Object.defineProperties(r,{__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.5.
|
|
4
|
+
"version": "0.5.3",
|
|
5
5
|
"description": "CodeMirror6 Component for vue2 and vue3",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"vuejs",
|
|
@@ -40,9 +40,6 @@
|
|
|
40
40
|
"license": "MIT",
|
|
41
41
|
"main": "./dist/index.umd.js",
|
|
42
42
|
"module": "./dist/index.es.js",
|
|
43
|
-
"browser": {
|
|
44
|
-
"./sfc": "./src/components/CodeMirror.vue"
|
|
45
|
-
},
|
|
46
43
|
"exports": {
|
|
47
44
|
".": {
|
|
48
45
|
"import": "./dist/index.es.js",
|
|
@@ -51,8 +48,7 @@
|
|
|
51
48
|
},
|
|
52
49
|
"types": "./dist/index.d.ts",
|
|
53
50
|
"files": [
|
|
54
|
-
"/dist"
|
|
55
|
-
"/src/components/CodeMirror.vue"
|
|
51
|
+
"/dist"
|
|
56
52
|
],
|
|
57
53
|
"sideEffects": false,
|
|
58
54
|
"scripts": {
|
|
@@ -89,8 +85,8 @@
|
|
|
89
85
|
"@codemirror/lang-markdown": "^0.20.1",
|
|
90
86
|
"@types/lodash": "^4.14.182",
|
|
91
87
|
"@types/node": "^17.0.36",
|
|
92
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
93
|
-
"@typescript-eslint/parser": "^5.
|
|
88
|
+
"@typescript-eslint/eslint-plugin": "^5.27.0",
|
|
89
|
+
"@typescript-eslint/parser": "^5.27.0",
|
|
94
90
|
"@vitejs/plugin-vue": "^2.3.3",
|
|
95
91
|
"@vue/eslint-config-prettier": "^7.0.0",
|
|
96
92
|
"eslint": "^8.16.0",
|
|
@@ -98,19 +94,18 @@
|
|
|
98
94
|
"eslint-config-prettier": "^8.5.0",
|
|
99
95
|
"eslint-import-resolver-alias": "^1.1.2",
|
|
100
96
|
"eslint-import-resolver-typescript": "^2.7.1",
|
|
97
|
+
"eslint-plugin-html": "^6.2.0",
|
|
101
98
|
"eslint-plugin-import": "^2.26.0",
|
|
102
99
|
"eslint-plugin-jsdoc": "^39.3.2",
|
|
103
100
|
"eslint-plugin-tsdoc": "^0.2.16",
|
|
104
101
|
"eslint-plugin-vue": "^9.0.1",
|
|
105
102
|
"eslint-plugin-vuejs-accessibility": "^1.1.1",
|
|
103
|
+
"eslint-plugin-yaml": "^0.5.0",
|
|
106
104
|
"eslint4b-prebuilt": "^6.7.2",
|
|
107
105
|
"husky": "^8.0.1",
|
|
108
|
-
"lint-staged": "^12.4.
|
|
106
|
+
"lint-staged": "^12.4.3",
|
|
109
107
|
"lodash": "^4.17.21",
|
|
110
108
|
"prettier": "^2.6.2",
|
|
111
|
-
"prettier-plugin-jsdoc": "^0.3.38",
|
|
112
|
-
"prettier-plugin-md-nocjsp": "^1.2.0",
|
|
113
|
-
"prettier-plugin-sort-imports": "^1.7.0",
|
|
114
109
|
"rimraf": "^3.0.2",
|
|
115
110
|
"rollup-plugin-visualizer": "^5.6.0",
|
|
116
111
|
"typescript": "^4.7.2",
|
|
@@ -118,7 +113,7 @@
|
|
|
118
113
|
"vite-plugin-checker": "^0.4.6",
|
|
119
114
|
"vue": "^3.2.36",
|
|
120
115
|
"vue-eslint-parser": "^9.0.2",
|
|
121
|
-
"vue-tsc": "^0.35.
|
|
116
|
+
"vue-tsc": "^0.35.2"
|
|
122
117
|
},
|
|
123
118
|
"husky": {
|
|
124
119
|
"hooks": {
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { ViewUpdate } from '@codemirror/view';
|
|
2
|
-
/** Emit Interface */
|
|
3
|
-
export default interface CodeMirrorEmitsInterface {
|
|
4
|
-
/** Model Update */
|
|
5
|
-
(e: 'update:modelValue', value: string | Text): void;
|
|
6
|
-
/** CodeMirror ViewUpdate */
|
|
7
|
-
(e: 'update', value: ViewUpdate): void;
|
|
8
|
-
}
|
|
9
|
-
//# sourceMappingURL=CodeMirrorEmitsInterface.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CodeMirrorEmitsInterface.d.ts","sourceRoot":"","sources":["../../src/interfaces/CodeMirrorEmitsInterface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,qBAAqB;AACrB,MAAM,CAAC,OAAO,WAAW,wBAAwB;IAC/C,mBAAmB;IACnB,CAAC,CAAC,EAAE,mBAAmB,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAAC;IACrD,4BAA4B;IAC5B,CAAC,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,GAAG,IAAI,CAAC;CACxC"}
|