vue-codemirror6 0.5.4 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -2
- package/dist/components/CodeMirror.d.ts +30 -10
- package/dist/components/CodeMirror.d.ts.map +1 -1
- package/dist/index.es.js +35 -29
- package/dist/index.umd.js +2 -2
- package/package.json +18 -22
package/README.md
CHANGED
|
@@ -26,7 +26,8 @@ yarn add vue-codemirror6 @vue/composition-api
|
|
|
26
26
|
|
|
27
27
|
| Props | Type | Information |
|
|
28
28
|
| ---------- | --------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
29
|
-
| basic | boolean | Use [
|
|
29
|
+
| basic | boolean | Use [basicSetup](https://codemirror.net/docs/ref/#codemirror.basicSetup). |
|
|
30
|
+
| minimal | boolean | Use [miniSetup](https://codemirror.net/docs/ref/#codemirror.minimalSetup). If a `basic` prop is also specified, that setting will take precedence. |
|
|
30
31
|
| dark | boolean | Toggle Darkmode. It can be changed in real time, but the input value will return to the initial value. |
|
|
31
32
|
| wrap | boolean | Line text wrapping. see [lineWrapping](https://codemirror.net/6/docs/ref/#view.EditorView.lineWrapping). |
|
|
32
33
|
| tab | boolean | Enables tab indentation. |
|
|
@@ -228,6 +229,28 @@ export default defineComponent({
|
|
|
228
229
|
</script>
|
|
229
230
|
```
|
|
230
231
|
|
|
232
|
+
## Methods
|
|
233
|
+
|
|
234
|
+
| Methods | Description |
|
|
235
|
+
| ------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------ |
|
|
236
|
+
| selection() | Get the [EditorSelection](https://codemirror.net/docs/ref/#state.EditorSelection) instance. |
|
|
237
|
+
| getRange(from?: number, to?: number) | Get the text between the given points in the editor. |
|
|
238
|
+
| getLine(number: number) | Get the content of line. |
|
|
239
|
+
| lineCount() | Get the number of lines in the editor. |
|
|
240
|
+
| getCursor() | Retrieve one end of the primary selection. |
|
|
241
|
+
| listSelections() | Retrieves a list of all current selections. |
|
|
242
|
+
| getSelection() | Get the currently selected code. |
|
|
243
|
+
| getSelections() | The length of the given array should be the same as the number of active selections. |
|
|
244
|
+
| somethingSelected() | Return true if any text is selected. |
|
|
245
|
+
| replaceRange(replacement: string \| Text, from: number, to: number) | Replace the part of the document between from and to with the given string. |
|
|
246
|
+
| replaceSelection(replacement: string \| Text) | Replace the selection(s) with the given string. |
|
|
247
|
+
| setCursor(position: number) | Set the cursor position. |
|
|
248
|
+
| setSelection(anchor: number, head?: number) | Set a single selection range. |
|
|
249
|
+
| setSelections(ranges: readonly SelectionRange[], primary?: number) | Sets a new set of selections. |
|
|
250
|
+
| extendSelectionsBy(f: Function) | Applies the given function to all existing selections, and calls extendSelections on the result. |
|
|
251
|
+
| focus() | Set focus |
|
|
252
|
+
| hasFocus() | is Focused |
|
|
253
|
+
|
|
231
254
|
## Recommendations
|
|
232
255
|
|
|
233
256
|
Since CodeMirror has a relatively large capacity, when using vite, it is recommended to set it to output as a separate file using the [`manualChunks`](https://vitejs.dev/guide/build.html#chunking-strategy) option at build time as shown below.
|
|
@@ -242,10 +265,13 @@ const config: UserConfig = {
|
|
|
242
265
|
// ...
|
|
243
266
|
codemirror: [
|
|
244
267
|
// Split CodeMirror code.
|
|
245
|
-
'
|
|
268
|
+
'vue-codemirror6'
|
|
269
|
+
'codemirror',
|
|
270
|
+
'@codemirror/autocomplete',
|
|
246
271
|
'@codemirror/commands',
|
|
247
272
|
'@codemirror/language',
|
|
248
273
|
'@codemirror/lint',
|
|
274
|
+
'@codemirror/search',
|
|
249
275
|
'@codemirror/state',
|
|
250
276
|
'@codemirror/view',
|
|
251
277
|
// Add the following as needed.
|
|
@@ -38,12 +38,21 @@ declare const _default: import("vue-demi").DefineComponent<{
|
|
|
38
38
|
/**
|
|
39
39
|
* Use Basic Setup
|
|
40
40
|
*
|
|
41
|
-
* @see {@link https://codemirror.net/
|
|
41
|
+
* @see {@link https://codemirror.net/docs/ref/#codemirror.basicSetup | basicSetup}
|
|
42
42
|
*/
|
|
43
43
|
basic: {
|
|
44
44
|
type: BooleanConstructor;
|
|
45
45
|
default: boolean;
|
|
46
46
|
};
|
|
47
|
+
/**
|
|
48
|
+
* Use Minimal Setup (The basic setting has priority.)
|
|
49
|
+
*
|
|
50
|
+
* @see {@link https://codemirror.net/docs/ref/#codemirror.minimalSetup | minimalSetup}
|
|
51
|
+
*/
|
|
52
|
+
minimal: {
|
|
53
|
+
type: BooleanConstructor;
|
|
54
|
+
default: boolean;
|
|
55
|
+
};
|
|
47
56
|
/**
|
|
48
57
|
* Line wrapping
|
|
49
58
|
*
|
|
@@ -124,21 +133,22 @@ declare const _default: import("vue-demi").DefineComponent<{
|
|
|
124
133
|
}, {
|
|
125
134
|
context: SetupContext<import("vue-demi").EmitsOptions>;
|
|
126
135
|
editor: Ref<Element | undefined>;
|
|
136
|
+
cursor: Ref<number>;
|
|
127
137
|
selection: () => EditorSelection;
|
|
128
|
-
getRange: (
|
|
129
|
-
getLine: (
|
|
138
|
+
getRange: (from?: number, to?: number) => string;
|
|
139
|
+
getLine: (number: number) => string;
|
|
130
140
|
lineCount: () => number;
|
|
131
141
|
getCursor: () => number;
|
|
132
142
|
listSelections: () => readonly SelectionRange[];
|
|
133
143
|
getSelection: () => string;
|
|
134
144
|
getSelections: () => string[];
|
|
135
145
|
somethingSelected: () => boolean;
|
|
136
|
-
replaceRange: (
|
|
137
|
-
replaceSelection: (
|
|
138
|
-
setCursor: (
|
|
139
|
-
setSelection: (anchor: number, head
|
|
140
|
-
setSelections: (ranges: readonly SelectionRange[],
|
|
141
|
-
extendSelectionsBy: (f:
|
|
146
|
+
replaceRange: (replacement: string | Text, from: number, to: number) => void;
|
|
147
|
+
replaceSelection: (replacement: string | Text) => void;
|
|
148
|
+
setCursor: (position: number) => number;
|
|
149
|
+
setSelection: (anchor: number, head?: number) => void;
|
|
150
|
+
setSelections: (ranges: readonly SelectionRange[], primary?: number) => void;
|
|
151
|
+
extendSelectionsBy: (f: Function) => void;
|
|
142
152
|
focus: () => void;
|
|
143
153
|
hasFocus: () => boolean;
|
|
144
154
|
}, 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<{
|
|
@@ -166,12 +176,21 @@ declare const _default: import("vue-demi").DefineComponent<{
|
|
|
166
176
|
/**
|
|
167
177
|
* Use Basic Setup
|
|
168
178
|
*
|
|
169
|
-
* @see {@link https://codemirror.net/
|
|
179
|
+
* @see {@link https://codemirror.net/docs/ref/#codemirror.basicSetup | basicSetup}
|
|
170
180
|
*/
|
|
171
181
|
basic: {
|
|
172
182
|
type: BooleanConstructor;
|
|
173
183
|
default: boolean;
|
|
174
184
|
};
|
|
185
|
+
/**
|
|
186
|
+
* Use Minimal Setup (The basic setting has priority.)
|
|
187
|
+
*
|
|
188
|
+
* @see {@link https://codemirror.net/docs/ref/#codemirror.minimalSetup | minimalSetup}
|
|
189
|
+
*/
|
|
190
|
+
minimal: {
|
|
191
|
+
type: BooleanConstructor;
|
|
192
|
+
default: boolean;
|
|
193
|
+
};
|
|
175
194
|
/**
|
|
176
195
|
* Line wrapping
|
|
177
196
|
*
|
|
@@ -256,6 +275,7 @@ declare const _default: import("vue-demi").DefineComponent<{
|
|
|
256
275
|
};
|
|
257
276
|
dark: boolean;
|
|
258
277
|
basic: boolean;
|
|
278
|
+
minimal: boolean;
|
|
259
279
|
wrap: boolean;
|
|
260
280
|
tab: boolean;
|
|
261
281
|
readonly: boolean;
|
|
@@ -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,EAUL,KAAK,QAAQ,EACb,KAAK,GAAG,EACR,KAAK,YAAY,EAClB,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,eAAe,EAA4B,MAAM,mBAAmB,CAAC;AAU9E,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;;;;;IAKH;;;;OAIG;;;;;IAOH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH,kBAAkB;;;;;;;;;qBAgJI,eAAe;sBAUZ,MAAM,OAAO,MAAM,KAAG,MAAM;sBAO5B,MAAM,KAAG,MAAM;qBAGlB,MAAM;qBAEN,MAAM;0BAED,SAAS,cAAc,EAAE;wBAE3B,MAAM;yBAML,MAAM,EAAE;6BAGJ,OAAO;gCAWtB,MAAM,GAAG,IAAI,QACpB,MAAM,MACR,MAAM;oCAW2B,MAAM,GAAG,IAAI;0BAOvB,MAAM;2BAOL,MAAM,SAAS,MAAM;4BASzC,SAAS,cAAc,EAAE,YACvB,MAAM;4BAUa,QAAQ;;oBAUlB,OAAO;;IAxW5B,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,wBA6ZG"}
|
package/dist/index.es.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
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";
|
|
1
|
+
import { isVue2, h as h$1, defineComponent, ref, toRefs, computed, watch, onMounted, nextTick, onUnmounted, toRaw } from "vue-demi";
|
|
2
|
+
import { StateEffect, EditorState, EditorSelection } from "@codemirror/state";
|
|
3
3
|
import { EditorView, keymap } from "@codemirror/view";
|
|
4
4
|
import { linter, lintGutter } from "@codemirror/lint";
|
|
5
|
-
import { basicSetup } from "
|
|
5
|
+
import { basicSetup, minimalSetup } from "codemirror";
|
|
6
6
|
import { indentWithTab } from "@codemirror/commands";
|
|
7
7
|
import { trim, compact } from "lodash";
|
|
8
8
|
const adaptOnsV3 = (ons) => {
|
|
@@ -47,6 +47,10 @@ var CodeMirror = defineComponent({
|
|
|
47
47
|
type: Boolean,
|
|
48
48
|
default: false
|
|
49
49
|
},
|
|
50
|
+
minimal: {
|
|
51
|
+
type: Boolean,
|
|
52
|
+
default: false
|
|
53
|
+
},
|
|
50
54
|
wrap: {
|
|
51
55
|
type: Boolean,
|
|
52
56
|
default: false
|
|
@@ -91,40 +95,41 @@ var CodeMirror = defineComponent({
|
|
|
91
95
|
const editor = ref();
|
|
92
96
|
const { dark } = toRefs(props);
|
|
93
97
|
const doc = ref(props.modelValue);
|
|
98
|
+
const cursor = computed({
|
|
99
|
+
get: () => view.state.selection.main.head,
|
|
100
|
+
set: (p) => view.dispatch({ selection: { anchor: p } })
|
|
101
|
+
});
|
|
94
102
|
const emit = context.emit;
|
|
95
103
|
let view;
|
|
96
104
|
watch(doc, (value) => {
|
|
97
105
|
if (view.composing) {
|
|
98
106
|
return;
|
|
99
107
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
selection: previous
|
|
105
|
-
}));
|
|
108
|
+
view.dispatch({
|
|
109
|
+
changes: { from: 0, to: value.length, insert: value },
|
|
110
|
+
selection: { anchor: cursor.value }
|
|
111
|
+
});
|
|
106
112
|
});
|
|
107
113
|
watch(() => props.modelValue, (text) => view.dispatch({
|
|
108
|
-
changes: { from: 0, to: view.state.doc.length, insert: text }
|
|
114
|
+
changes: { from: 0, to: view.state.doc.length, insert: text },
|
|
115
|
+
selection: { anchor: cursor.value }
|
|
109
116
|
}));
|
|
110
117
|
watch(dark, () => {
|
|
111
|
-
view.
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
}));
|
|
118
|
+
view.dispatch({
|
|
119
|
+
effects: StateEffect.appendConfig.of(EditorView.theme(props.theme, { dark: dark.value }))
|
|
120
|
+
});
|
|
115
121
|
});
|
|
116
122
|
onMounted(async () => {
|
|
123
|
+
let value = doc.value;
|
|
117
124
|
if (editor.value && editor.value.childNodes[0]) {
|
|
118
125
|
if (doc.value !== "") {
|
|
119
126
|
console.warn("[CodeMirror.vue] The <code-mirror> tag contains child elements that overwrite the `v-model` values.");
|
|
120
127
|
}
|
|
121
|
-
|
|
128
|
+
value = trim(editor.value.childNodes[0].innerText);
|
|
122
129
|
}
|
|
123
130
|
view = new EditorView({
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
extensions: getExtensions()
|
|
127
|
-
}),
|
|
131
|
+
doc: value,
|
|
132
|
+
extensions: getExtensions(),
|
|
128
133
|
parent: editor.value,
|
|
129
134
|
dispatch: (tr) => {
|
|
130
135
|
view.update([tr]);
|
|
@@ -140,6 +145,7 @@ var CodeMirror = defineComponent({
|
|
|
140
145
|
const getExtensions = () => {
|
|
141
146
|
const extensions = compact([
|
|
142
147
|
props.basic ? basicSetup : void 0,
|
|
148
|
+
props.minimal && !props.basic ? minimalSetup : void 0,
|
|
143
149
|
EditorView.updateListener.of((update) => emit("update", update)),
|
|
144
150
|
EditorView.theme(props.theme, { dark: dark.value }),
|
|
145
151
|
props.wrap ? EditorView.lineWrapping : void 0,
|
|
@@ -152,26 +158,25 @@ var CodeMirror = defineComponent({
|
|
|
152
158
|
props.linter && props.lintGutter ? lintGutter() : void 0,
|
|
153
159
|
...props.extensions
|
|
154
160
|
]);
|
|
155
|
-
console.debug("[CodeMirror.vue] Loaded extensions: ", extensions);
|
|
156
161
|
return extensions;
|
|
157
162
|
};
|
|
158
163
|
const selection = () => view.state.selection;
|
|
159
|
-
const getRange = (
|
|
160
|
-
const getLine = (
|
|
164
|
+
const getRange = (from, to) => view.state.sliceDoc(from, to);
|
|
165
|
+
const getLine = (number) => view.state.doc.line(number + 1).text;
|
|
161
166
|
const lineCount = () => view.state.doc.lines;
|
|
162
|
-
const getCursor = () =>
|
|
167
|
+
const getCursor = () => cursor.value;
|
|
163
168
|
const listSelections = () => selection().ranges;
|
|
164
169
|
const getSelection = () => view.state.sliceDoc(selection().main.from, selection().main.to);
|
|
165
170
|
const getSelections = () => selection().ranges.map((r) => view.state.sliceDoc(r.from, r.to));
|
|
166
171
|
const somethingSelected = () => selection().ranges.some((r) => !r.empty);
|
|
167
|
-
const replaceRange = (
|
|
168
|
-
changes: { from, to, insert:
|
|
172
|
+
const replaceRange = (replacement, from, to) => view.dispatch({
|
|
173
|
+
changes: { from, to, insert: replacement }
|
|
169
174
|
});
|
|
170
|
-
const replaceSelection = (
|
|
171
|
-
const setCursor = (
|
|
175
|
+
const replaceSelection = (replacement) => view.dispatch(view.state.replaceSelection(replacement));
|
|
176
|
+
const setCursor = (position) => cursor.value = position;
|
|
172
177
|
const setSelection = (anchor, head) => view.dispatch({ selection: { anchor, head } });
|
|
173
|
-
const setSelections = (ranges,
|
|
174
|
-
selection: EditorSelection.create(ranges,
|
|
178
|
+
const setSelections = (ranges, primary) => view.dispatch({
|
|
179
|
+
selection: EditorSelection.create(ranges, primary)
|
|
175
180
|
});
|
|
176
181
|
const extendSelectionsBy = (f) => view.dispatch({
|
|
177
182
|
selection: EditorSelection.create(selection().ranges.map((r) => r.extend(f(r))))
|
|
@@ -181,6 +186,7 @@ var CodeMirror = defineComponent({
|
|
|
181
186
|
return {
|
|
182
187
|
context,
|
|
183
188
|
editor,
|
|
189
|
+
cursor,
|
|
184
190
|
selection,
|
|
185
191
|
getRange,
|
|
186
192
|
getLine,
|
package/dist/index.umd.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
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("
|
|
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"),require("@codemirror/commands"),require("lodash")):typeof define=="function"&&define.amd?define(["exports","vue-demi","@codemirror/state","@codemirror/view","@codemirror/lint","codemirror","@codemirror/commands","lodash"],n):(r=typeof globalThis<"u"?globalThis:r||self,n(r.CodeMirror={},r.VueDemi,r.state,r.view,r.lint,r.codemirror,r.commands,r.lodash))})(this,function(r,n,m,c,p,g,V,y){"use strict";const C=e=>e?Object.entries(e).reduce((d,[i,l])=>(i=i.charAt(0).toUpperCase()+i.slice(1),i=`on${i}`,{...d,[i]:l}),{}):null,S=(e,d={},i)=>{if(n.isVue2)return n.h(e,d,i);const{props:l,domProps:u,on:s,...h}=d,o=s?C(s):{};return n.h(e,{...h,...l,...u,...o},i)},w=e=>typeof e=="function"?e():e;var v=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"],setup(e,d){const i=n.ref(),{dark:l}=n.toRefs(e),u=n.ref(e.modelValue),s=n.computed({get:()=>o.state.selection.main.head,set:t=>o.dispatch({selection:{anchor:t}})}),h=d.emit;let o;n.watch(u,t=>{o.composing||o.dispatch({changes:{from:0,to:t.length,insert:t},selection:{anchor:s.value}})}),n.watch(()=>e.modelValue,t=>o.dispatch({changes:{from:0,to:o.state.doc.length,insert:t},selection:{anchor:s.value}})),n.watch(l,()=>{o.dispatch({effects:m.StateEffect.appendConfig.of(c.EditorView.theme(e.theme,{dark:l.value}))})}),n.onMounted(async()=>{let t=u.value;i.value&&i.value.childNodes[0]&&(u.value!==""&&console.warn("[CodeMirror.vue] The <code-mirror> tag contains child elements that overwrite the `v-model` values."),t=y.trim(i.value.childNodes[0].innerText)),o=new c.EditorView({doc:t,extensions:E(),parent:i.value,dispatch:a=>{o.update([a]),!a.changes.empty&&(u.value=o.state.doc.toString(),h("update:modelValue",u.value))}}),await n.nextTick()}),n.onUnmounted(()=>o.destroy());const E=()=>y.compact([e.basic?g.basicSetup:void 0,e.minimal&&!e.basic?g.minimalSetup:void 0,c.EditorView.updateListener.of(a=>h("update",a)),c.EditorView.theme(e.theme,{dark:l.value}),e.wrap?c.EditorView.lineWrapping:void 0,e.tab?c.keymap.of([V.indentWithTab]):void 0,e.phrases?m.EditorState.phrases.of(e.phrases):void 0,e.readonly?m.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?p.linter(e.linter):void 0,e.linter&&e.lintGutter?p.lintGutter():void 0,...e.extensions]),f=()=>o.state.selection;return{context:d,editor:i,cursor:s,selection:f,getRange:(t,a)=>o.state.sliceDoc(t,a),getLine:t=>o.state.doc.line(t+1).text,lineCount:()=>o.state.doc.lines,getCursor:()=>s.value,listSelections:()=>f().ranges,getSelection:()=>o.state.sliceDoc(f().main.from,f().main.to),getSelections:()=>f().ranges.map(t=>o.state.sliceDoc(t.from,t.to)),somethingSelected:()=>f().ranges.some(t=>!t.empty),replaceRange:(t,a,b)=>o.dispatch({changes:{from:a,to:b,insert:t}}),replaceSelection:t=>o.dispatch(o.state.replaceSelection(t)),setCursor:t=>s.value=t,setSelection:(t,a)=>o.dispatch({selection:{anchor:t,head:a}}),setSelections:(t,a)=>o.dispatch({selection:m.EditorSelection.create(t,a)}),extendSelectionsBy:t=>o.dispatch({selection:m.EditorSelection.create(f().ranges.map(a=>a.extend(t(a))))}),focus:()=>o.focus(),hasFocus:()=>o.hasFocus}},render(){return S("div",{ref:"editor",class:"vue-codemirror"},this.$slots.default?S("aside",{style:"display: none;"},w(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 x=e=>e.component("CodeMirror",v);r.default=v,r.install=x,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.
|
|
4
|
+
"version": "0.6.1",
|
|
5
5
|
"description": "CodeMirror6 Component for vue2 and vue3",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"vuejs",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"url": "https://github.com/logue/vue-codemirror6/issues"
|
|
34
34
|
},
|
|
35
35
|
"engines": {
|
|
36
|
-
"node": ">=16.15.
|
|
36
|
+
"node": ">=16.15.1",
|
|
37
37
|
"yarn": ">=1.22.4"
|
|
38
38
|
},
|
|
39
39
|
"packageManager": "yarn@3.2.1",
|
|
@@ -64,16 +64,12 @@
|
|
|
64
64
|
"prepare": "husky install"
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"
|
|
68
|
-
"@codemirror/commands": "latest",
|
|
69
|
-
"@codemirror/lint": "latest",
|
|
70
|
-
"@codemirror/state": "latest",
|
|
71
|
-
"@codemirror/view": "latest",
|
|
67
|
+
"codemirror": "^6.0.0",
|
|
72
68
|
"vue-demi": "latest"
|
|
73
69
|
},
|
|
74
70
|
"peerDependencies": {
|
|
75
71
|
"@vue/composition-api": "^1.6.2",
|
|
76
|
-
"vue": "^2.6.14 || ^3.2.
|
|
72
|
+
"vue": "^2.6.14 || ^3.2.37"
|
|
77
73
|
},
|
|
78
74
|
"peerDependenciesMeta": {
|
|
79
75
|
"@vue/composition-api": {
|
|
@@ -81,15 +77,15 @@
|
|
|
81
77
|
}
|
|
82
78
|
},
|
|
83
79
|
"devDependencies": {
|
|
84
|
-
"@codemirror/lang-javascript": "^0.
|
|
85
|
-
"@codemirror/lang-markdown": "^0.
|
|
80
|
+
"@codemirror/lang-javascript": "^6.0.0",
|
|
81
|
+
"@codemirror/lang-markdown": "^6.0.0",
|
|
86
82
|
"@types/lodash": "^4.14.182",
|
|
87
|
-
"@types/node": "^17.0.
|
|
88
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
89
|
-
"@typescript-eslint/parser": "^5.
|
|
83
|
+
"@types/node": "^17.0.43",
|
|
84
|
+
"@typescript-eslint/eslint-plugin": "^5.28.0",
|
|
85
|
+
"@typescript-eslint/parser": "^5.28.0",
|
|
90
86
|
"@vitejs/plugin-vue": "^2.3.3",
|
|
91
87
|
"@vue/eslint-config-prettier": "^7.0.0",
|
|
92
|
-
"eslint": "^8.
|
|
88
|
+
"eslint": "^8.17.0",
|
|
93
89
|
"eslint-config-google": "^0.14.0",
|
|
94
90
|
"eslint-config-prettier": "^8.5.0",
|
|
95
91
|
"eslint-import-resolver-alias": "^1.1.2",
|
|
@@ -98,22 +94,22 @@
|
|
|
98
94
|
"eslint-plugin-import": "^2.26.0",
|
|
99
95
|
"eslint-plugin-jsdoc": "^39.3.2",
|
|
100
96
|
"eslint-plugin-tsdoc": "^0.2.16",
|
|
101
|
-
"eslint-plugin-vue": "^9.
|
|
102
|
-
"eslint-plugin-vuejs-accessibility": "^1.
|
|
97
|
+
"eslint-plugin-vue": "^9.1.1",
|
|
98
|
+
"eslint-plugin-vuejs-accessibility": "^1.2.0",
|
|
103
99
|
"eslint-plugin-yaml": "^0.5.0",
|
|
104
100
|
"eslint4b-prebuilt": "^6.7.2",
|
|
105
101
|
"husky": "^8.0.1",
|
|
106
|
-
"lint-staged": "^
|
|
102
|
+
"lint-staged": "^13.0.1",
|
|
107
103
|
"lodash": "^4.17.21",
|
|
108
|
-
"prettier": "^2.
|
|
104
|
+
"prettier": "^2.7.0",
|
|
109
105
|
"rimraf": "^3.0.2",
|
|
110
106
|
"rollup-plugin-visualizer": "^5.6.0",
|
|
111
|
-
"typescript": "^4.7.
|
|
112
|
-
"vite": "^2.9.
|
|
107
|
+
"typescript": "^4.7.3",
|
|
108
|
+
"vite": "^2.9.12",
|
|
113
109
|
"vite-plugin-checker": "^0.4.6",
|
|
114
|
-
"vue": "^3.2.
|
|
110
|
+
"vue": "^3.2.37",
|
|
115
111
|
"vue-eslint-parser": "^9.0.2",
|
|
116
|
-
"vue-tsc": "^0.
|
|
112
|
+
"vue-tsc": "^0.37.8"
|
|
117
113
|
},
|
|
118
114
|
"husky": {
|
|
119
115
|
"hooks": {
|