vue-codemirror6 0.6.4 → 0.6.5
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 +3 -1
- package/dist/components/CodeMirror.d.ts +3 -3
- package/dist/components/CodeMirror.d.ts.map +1 -1
- package/dist/index.d.ts +0 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.es.js +27 -19
- package/dist/index.umd.js +9 -5
- package/package.json +14 -10
package/README.md
CHANGED
|
@@ -16,12 +16,14 @@ yarn add vue-codemirror6
|
|
|
16
16
|
|
|
17
17
|
This component can handle bidirectional binding by `v-model` like a general Vue component.
|
|
18
18
|
|
|
19
|
-
When using with
|
|
19
|
+
When using with Vue 2.6, [@vue/composition-api](https://www.npmjs.com/package/@vue/composition-api) is required separately.
|
|
20
20
|
|
|
21
21
|
```sh
|
|
22
22
|
yarn add vue-codemirror6 @vue/composition-api
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
+
For Vue 2.7 or later, import vue directly like Vue3.
|
|
26
|
+
|
|
25
27
|
### Props
|
|
26
28
|
|
|
27
29
|
| Props | Type | Information |
|
|
@@ -122,7 +122,7 @@ declare const _default: import("vue-demi").DefineComponent<{
|
|
|
122
122
|
*/
|
|
123
123
|
linter: {
|
|
124
124
|
type: PropType<LintSource>;
|
|
125
|
-
default: undefined;
|
|
125
|
+
default: () => undefined;
|
|
126
126
|
};
|
|
127
127
|
/** Show Gutter */
|
|
128
128
|
lintGutter: {
|
|
@@ -150,7 +150,7 @@ declare const _default: import("vue-demi").DefineComponent<{
|
|
|
150
150
|
extendSelectionsBy: (f: Function) => void;
|
|
151
151
|
focus: () => void;
|
|
152
152
|
hasFocus: () => boolean;
|
|
153
|
-
}, 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<{
|
|
153
|
+
}, unknown, {}, {}, import("vue-demi").ComponentOptionsMixin, import("vue-demi").ComponentOptionsMixin, import("vue-demi").EmitsOptions, "update:modelValue" | "update:view", import("vue-demi").VNodeProps & import("vue-demi").AllowedComponentProps & import("vue-demi").ComponentCustomProps, Readonly<import("vue-demi").ExtractPropTypes<{
|
|
154
154
|
/** Model value */
|
|
155
155
|
modelValue: {
|
|
156
156
|
type: PropType<string | Text>;
|
|
@@ -260,7 +260,7 @@ declare const _default: import("vue-demi").DefineComponent<{
|
|
|
260
260
|
*/
|
|
261
261
|
linter: {
|
|
262
262
|
type: PropType<LintSource>;
|
|
263
|
-
default: undefined;
|
|
263
|
+
default: () => undefined;
|
|
264
264
|
};
|
|
265
265
|
/** Show Gutter */
|
|
266
266
|
lintGutter: {
|
|
@@ -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;
|
|
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,M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
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Vue CodeMirror6 Component
|
|
3
|
-
*
|
|
4
|
-
* @license MIT
|
|
5
|
-
* @author Logue {@link logue@hotmail.co.jp}
|
|
6
|
-
* @copyright 2022 Masashi Yoshikawa {@link https://logue.dev/} All rights reserved.
|
|
7
|
-
* @see {@link https://github.com/logue/vue-codemirror6}
|
|
8
|
-
*/
|
|
9
1
|
import CodeMirror from './components/CodeMirror';
|
|
10
2
|
declare const installCodeMirror: (app: any) => any;
|
|
11
3
|
export { CodeMirror as default, installCodeMirror as install };
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,yBAAyB,CAAC;AAGjD,QAAA,MAAM,iBAAiB,mBAAiD,CAAC;AAEzE,OAAO,EAAE,UAAU,IAAI,OAAO,EAAE,iBAAiB,IAAI,OAAO,EAAE,CAAC"}
|
package/dist/index.es.js
CHANGED
|
@@ -1,10 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* vue-codemirror6
|
|
3
|
+
*
|
|
4
|
+
* @description CodeMirror6 Component for vue2 and vue3
|
|
5
|
+
* @author Logue <logue@hotmail.co.jp>
|
|
6
|
+
* @copyright 2022 By Masashi Yoshikawa All rights reserved.
|
|
7
|
+
* @license MIT
|
|
8
|
+
* @version 0.6.5
|
|
9
|
+
* @see {@link https://github.com/logue/vue-codemirror6}
|
|
10
|
+
*/
|
|
11
|
+
|
|
1
12
|
import { isVue2, h as h$1, defineComponent, ref, computed, watch, onMounted, nextTick, onUnmounted, toRaw } from "vue-demi";
|
|
13
|
+
import { trim, compact } from "lodash";
|
|
2
14
|
import { StateEffect, EditorState, EditorSelection } from "@codemirror/state";
|
|
3
15
|
import { EditorView, keymap } from "@codemirror/view";
|
|
4
16
|
import { linter, lintGutter } from "@codemirror/lint";
|
|
5
17
|
import { basicSetup, minimalSetup } from "codemirror";
|
|
6
18
|
import { indentWithTab } from "@codemirror/commands";
|
|
7
|
-
import { trim, compact } from "lodash";
|
|
8
19
|
const adaptOnsV3 = (ons) => {
|
|
9
20
|
if (!ons)
|
|
10
21
|
return null;
|
|
@@ -41,7 +52,7 @@ var CodeMirror = defineComponent({
|
|
|
41
52
|
},
|
|
42
53
|
dark: {
|
|
43
54
|
type: Boolean,
|
|
44
|
-
default:
|
|
55
|
+
default: false
|
|
45
56
|
},
|
|
46
57
|
basic: {
|
|
47
58
|
type: Boolean,
|
|
@@ -83,27 +94,33 @@ var CodeMirror = defineComponent({
|
|
|
83
94
|
},
|
|
84
95
|
linter: {
|
|
85
96
|
type: Function,
|
|
86
|
-
default: void 0
|
|
97
|
+
default: () => void 0
|
|
87
98
|
},
|
|
88
99
|
lintGutter: {
|
|
89
100
|
type: Boolean,
|
|
90
101
|
defalt: false
|
|
91
102
|
}
|
|
92
103
|
},
|
|
93
|
-
emits: ["update:modelValue", "update"],
|
|
104
|
+
emits: ["update:modelValue", "update:view"],
|
|
94
105
|
setup(props, context) {
|
|
95
106
|
const editor = ref();
|
|
96
107
|
const doc = ref(props.modelValue);
|
|
97
108
|
let view;
|
|
98
109
|
const cursor = computed({
|
|
99
|
-
get: () => view.state.selection.main.head,
|
|
110
|
+
get: () => view.state.selection.main.head || 0,
|
|
100
111
|
set: (p) => view.dispatch({ selection: { anchor: p } })
|
|
101
112
|
});
|
|
102
113
|
const emit = context.emit;
|
|
103
|
-
watch(() => props.modelValue, (text) =>
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
114
|
+
watch(() => props.modelValue, (text) => {
|
|
115
|
+
if (view.composing) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
const previous = view.state.selection;
|
|
119
|
+
view.dispatch({
|
|
120
|
+
changes: { from: 0, to: view.state.doc.length, insert: text },
|
|
121
|
+
selection: previous
|
|
122
|
+
});
|
|
123
|
+
});
|
|
107
124
|
watch(() => props.dark, () => {
|
|
108
125
|
view.dispatch({
|
|
109
126
|
effects: StateEffect.reconfigure.of(getExtensions())
|
|
@@ -125,8 +142,7 @@ var CodeMirror = defineComponent({
|
|
|
125
142
|
view.update([tr]);
|
|
126
143
|
if (tr.changes.empty)
|
|
127
144
|
return;
|
|
128
|
-
|
|
129
|
-
emit("update:modelValue", doc.value);
|
|
145
|
+
emit("update:modelValue", view.state.doc.toString());
|
|
130
146
|
}
|
|
131
147
|
});
|
|
132
148
|
await nextTick();
|
|
@@ -203,14 +219,6 @@ var CodeMirror = defineComponent({
|
|
|
203
219
|
}, this.$slots.default ? h("aside", { style: "display: none;", "aria-hidden": "true" }, slot(this.$slots.default)) : void 0);
|
|
204
220
|
}
|
|
205
221
|
});
|
|
206
|
-
/**
|
|
207
|
-
* Vue CodeMirror6 Component
|
|
208
|
-
*
|
|
209
|
-
* @license MIT
|
|
210
|
-
* @author Logue {@link logue@hotmail.co.jp}
|
|
211
|
-
* @copyright 2022 Masashi Yoshikawa {@link https://logue.dev/} All rights reserved.
|
|
212
|
-
* @see {@link https://github.com/logue/vue-codemirror6}
|
|
213
|
-
*/
|
|
214
222
|
const installCodeMirror = (app) => app.component("CodeMirror", CodeMirror);
|
|
215
223
|
if (typeof window !== "undefined" && window.Vue) {
|
|
216
224
|
window.Vue.use(CodeMirror);
|
package/dist/index.umd.js
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
*
|
|
1
|
+
/**
|
|
2
|
+
* vue-codemirror6
|
|
3
3
|
*
|
|
4
|
+
* @description CodeMirror6 Component for vue2 and vue3
|
|
5
|
+
* @author Logue <logue@hotmail.co.jp>
|
|
6
|
+
* @copyright 2022 By Masashi Yoshikawa All rights reserved.
|
|
4
7
|
* @license MIT
|
|
5
|
-
* @
|
|
6
|
-
* @copyright 2022 Masashi Yoshikawa {@link https://logue.dev/} All rights reserved.
|
|
8
|
+
* @version 0.6.5
|
|
7
9
|
* @see {@link https://github.com/logue/vue-codemirror6}
|
|
8
|
-
*/
|
|
10
|
+
*/
|
|
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"}})});
|
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.
|
|
4
|
+
"version": "0.6.5",
|
|
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.
|
|
67
|
+
"codemirror": "^6.0.1",
|
|
68
68
|
"vue-demi": "latest"
|
|
69
69
|
},
|
|
70
70
|
"peerDependencies": {
|
|
71
|
-
"@vue/composition-api": "^1.6.
|
|
71
|
+
"@vue/composition-api": "^1.6.3",
|
|
72
72
|
"vue": "^2.6.14 || ^3.2.37"
|
|
73
73
|
},
|
|
74
74
|
"peerDependenciesMeta": {
|
|
@@ -77,19 +77,19 @@
|
|
|
77
77
|
}
|
|
78
78
|
},
|
|
79
79
|
"devDependencies": {
|
|
80
|
-
"@codemirror/lang-javascript": "^6.0.
|
|
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.
|
|
84
|
-
"@typescript-eslint/eslint-plugin": "^5.30.
|
|
85
|
-
"@typescript-eslint/parser": "^5.30.
|
|
83
|
+
"@types/node": "^18.0.1",
|
|
84
|
+
"@typescript-eslint/eslint-plugin": "^5.30.4",
|
|
85
|
+
"@typescript-eslint/parser": "^5.30.4",
|
|
86
86
|
"@vitejs/plugin-vue": "^2.3.3",
|
|
87
87
|
"@vue/eslint-config-prettier": "^7.0.0",
|
|
88
|
-
"eslint": "^8.
|
|
88
|
+
"eslint": "^8.19.0",
|
|
89
89
|
"eslint-config-google": "^0.14.0",
|
|
90
90
|
"eslint-config-prettier": "^8.5.0",
|
|
91
91
|
"eslint-import-resolver-alias": "^1.1.2",
|
|
92
|
-
"eslint-import-resolver-typescript": "^3.
|
|
92
|
+
"eslint-import-resolver-typescript": "^3.2.0",
|
|
93
93
|
"eslint-plugin-html": "^6.2.0",
|
|
94
94
|
"eslint-plugin-import": "^2.26.0",
|
|
95
95
|
"eslint-plugin-jsdoc": "^39.3.3",
|
|
@@ -106,7 +106,8 @@
|
|
|
106
106
|
"rollup-plugin-visualizer": "^5.6.0",
|
|
107
107
|
"typescript": "4.6.*",
|
|
108
108
|
"vite": "^2.9.13",
|
|
109
|
-
"vite-plugin-
|
|
109
|
+
"vite-plugin-banner": "^0.3.0",
|
|
110
|
+
"vite-plugin-checker": "^0.4.7",
|
|
110
111
|
"vue": "^3.2.37",
|
|
111
112
|
"vue-eslint-parser": "^9.0.3",
|
|
112
113
|
"vue-tsc": "^0.38.2"
|
|
@@ -119,5 +120,8 @@
|
|
|
119
120
|
"lint-staged": {
|
|
120
121
|
"*.{js,ts,json,htm,html}": "eslint --fix --cache --cache-location ./node_modules/.vite/vite-plugin-eslint",
|
|
121
122
|
"*": "prettier -w -u"
|
|
123
|
+
},
|
|
124
|
+
"resolutions": {
|
|
125
|
+
"prettier": "^2.7.1"
|
|
122
126
|
}
|
|
123
127
|
}
|