vue-codemirror6 0.6.3 → 0.6.4
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 +1 -1
- package/dist/components/CodeMirror.d.ts +4 -4
- package/dist/components/CodeMirror.d.ts.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.es.js +4 -10
- package/dist/index.umd.js +2 -2
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -61,7 +61,7 @@ Notice: `lang` and `linter` can also be set together in `extensions`. This is de
|
|
|
61
61
|
|
|
62
62
|
- [`@codemirror/theme-one-dark`](https://github.com/codemirror/theme-one-dark)
|
|
63
63
|
- [`upleveled/theme-vs-code-dark-plus`](https://github.com/upleveled/theme-vs-code-dark-plus)
|
|
64
|
-
- [
|
|
64
|
+
- [`codemirror6-bootstrap-theme`](https://github.com/logue/codemirror6-bootstrap-theme)
|
|
65
65
|
|
|
66
66
|
## Example
|
|
67
67
|
|
|
@@ -12,7 +12,6 @@ export interface CodeMirrorEmitsInterface {
|
|
|
12
12
|
/** CodeMirror ViewUpdate */
|
|
13
13
|
(e: 'update', value: ViewUpdate): void;
|
|
14
14
|
}
|
|
15
|
-
/** CodeMirror Component */
|
|
16
15
|
declare const _default: import("vue-demi").DefineComponent<{
|
|
17
16
|
/** Model value */
|
|
18
17
|
modelValue: {
|
|
@@ -135,7 +134,7 @@ declare const _default: import("vue-demi").DefineComponent<{
|
|
|
135
134
|
editor: Ref<Element | undefined>;
|
|
136
135
|
cursor: Ref<number>;
|
|
137
136
|
selection: () => EditorSelection;
|
|
138
|
-
getRange: (from?: number, to?: number) => string;
|
|
137
|
+
getRange: (from?: number | undefined, to?: number | undefined) => string;
|
|
139
138
|
getLine: (number: number) => string;
|
|
140
139
|
lineCount: () => number;
|
|
141
140
|
getCursor: () => number;
|
|
@@ -146,8 +145,8 @@ declare const _default: import("vue-demi").DefineComponent<{
|
|
|
146
145
|
replaceRange: (replacement: string | Text, from: number, to: number) => void;
|
|
147
146
|
replaceSelection: (replacement: string | Text) => void;
|
|
148
147
|
setCursor: (position: number) => number;
|
|
149
|
-
setSelection: (anchor: number, head?: number) => void;
|
|
150
|
-
setSelections: (ranges: readonly SelectionRange[], primary?: number) => void;
|
|
148
|
+
setSelection: (anchor: number, head?: number | undefined) => void;
|
|
149
|
+
setSelections: (ranges: readonly SelectionRange[], primary?: number | undefined) => void;
|
|
151
150
|
extendSelectionsBy: (f: Function) => void;
|
|
152
151
|
focus: () => void;
|
|
153
152
|
hasFocus: () => boolean;
|
|
@@ -286,5 +285,6 @@ declare const _default: import("vue-demi").DefineComponent<{
|
|
|
286
285
|
linter: LintSource;
|
|
287
286
|
lintGutter: boolean;
|
|
288
287
|
}>;
|
|
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;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,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,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;4BAS1B,SAAS,cAAc,EAAE;4BAWJ,QAAQ;;oBAUlB,OAAO;;IArV5B,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;;;;;;;;;;;;;;;;;;;;;;;AA5HtB,2BAA2B;AAC3B,wBA8YG"}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA;;;;;;;GAOG;AACH,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
|
@@ -94,21 +94,12 @@ var CodeMirror = defineComponent({
|
|
|
94
94
|
setup(props, context) {
|
|
95
95
|
const editor = ref();
|
|
96
96
|
const doc = ref(props.modelValue);
|
|
97
|
+
let view;
|
|
97
98
|
const cursor = computed({
|
|
98
99
|
get: () => view.state.selection.main.head,
|
|
99
100
|
set: (p) => view.dispatch({ selection: { anchor: p } })
|
|
100
101
|
});
|
|
101
102
|
const emit = context.emit;
|
|
102
|
-
let view;
|
|
103
|
-
watch(doc, (value) => {
|
|
104
|
-
if (view.composing) {
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
view.dispatch({
|
|
108
|
-
changes: { from: 0, to: value.length, insert: value },
|
|
109
|
-
selection: { anchor: cursor.value }
|
|
110
|
-
});
|
|
111
|
-
});
|
|
112
103
|
watch(() => props.modelValue, (text) => view.dispatch({
|
|
113
104
|
changes: { from: 0, to: view.state.doc.length, insert: text },
|
|
114
105
|
selection: { anchor: cursor.value }
|
|
@@ -221,4 +212,7 @@ var CodeMirror = defineComponent({
|
|
|
221
212
|
* @see {@link https://github.com/logue/vue-codemirror6}
|
|
222
213
|
*/
|
|
223
214
|
const installCodeMirror = (app) => app.component("CodeMirror", CodeMirror);
|
|
215
|
+
if (typeof window !== "undefined" && window.Vue) {
|
|
216
|
+
window.Vue.use(CodeMirror);
|
|
217
|
+
}
|
|
224
218
|
export { CodeMirror as default, installCodeMirror as install };
|
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("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,f,u,g,
|
|
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,f,u,g,y,w,S){"use strict";const V=e=>e?Object.entries(e).reduce((d,[i,s])=>(i=i.charAt(0).toUpperCase()+i.slice(1),i=`on${i}`,{...d,[i]:s}),{}):null,v=(e,d={},i)=>{if(n.isVue2)return n.h(e,d,i);const{props:s,domProps:o,on:c,...m}=d,h=c?V(c):{};return n.h(e,{...m,...s,...o,...h},i)},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:window.matchMedia("(prefers-color-scheme: dark)").matches},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(),s=n.ref(e.modelValue);let o;const c=n.computed({get:()=>o.state.selection.main.head,set:t=>o.dispatch({selection:{anchor:t}})}),m=d.emit;n.watch(()=>e.modelValue,t=>o.dispatch({changes:{from:0,to:o.state.doc.length,insert:t},selection:{anchor:c.value}})),n.watch(()=>e.dark,()=>{o.dispatch({effects:f.StateEffect.reconfigure.of(h())})}),n.onMounted(async()=>{let t=s.value;i.value&&i.value.childNodes[0]&&(s.value!==""&&console.warn("[CodeMirror.vue] The <code-mirror> tag contains child elements that overwrite the `v-model` values."),t=S.trim(i.value.childNodes[0].innerText)),o=new u.EditorView({doc:t,extensions:h(),parent:i.value,dispatch:a=>{o.update([a]),!a.changes.empty&&(s.value=o.state.doc.toString(),m("update:modelValue",s.value))}}),await n.nextTick()}),n.onUnmounted(()=>o.destroy());const h=()=>S.compact([e.basic?y.basicSetup:void 0,e.minimal&&!e.basic?y.minimalSetup:void 0,u.EditorView.updateListener.of(a=>m("update",a)),u.EditorView.theme(e.theme,{dark:e.dark}),e.wrap?u.EditorView.lineWrapping:void 0,e.tab?u.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?u.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]),l=()=>o.state.selection;return{context:d,editor:i,cursor:c,selection:l,getRange:(t,a)=>o.state.sliceDoc(t,a),getLine:t=>o.state.doc.line(t+1).text,lineCount:()=>o.state.doc.lines,getCursor:()=>c.value,listSelections:()=>l().ranges,getSelection:()=>o.state.sliceDoc(l().main.from,l().main.to),getSelections:()=>l().ranges.map(t=>o.state.sliceDoc(t.from,t.to)),somethingSelected:()=>l().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=>c.value=t,setSelection:(t,a)=>o.dispatch({selection:{anchor:t,head:a}}),setSelections:(t,a)=>o.dispatch({selection:f.EditorSelection.create(t,a)}),extendSelectionsBy:t=>o.dispatch({selection:f.EditorSelection.create(l().ranges.map(a=>a.extend(t(a))))}),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)}});/**
|
|
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 x=e=>e.component("CodeMirror",
|
|
8
|
+
*/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.4",
|
|
5
5
|
"description": "CodeMirror6 Component for vue2 and vue3",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"vuejs",
|
|
@@ -81,15 +81,15 @@
|
|
|
81
81
|
"@codemirror/lang-markdown": "^6.0.0",
|
|
82
82
|
"@types/lodash": "^4.14.182",
|
|
83
83
|
"@types/node": "^18.0.0",
|
|
84
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
85
|
-
"@typescript-eslint/parser": "^5.
|
|
84
|
+
"@typescript-eslint/eslint-plugin": "^5.30.0",
|
|
85
|
+
"@typescript-eslint/parser": "^5.30.0",
|
|
86
86
|
"@vitejs/plugin-vue": "^2.3.3",
|
|
87
87
|
"@vue/eslint-config-prettier": "^7.0.0",
|
|
88
88
|
"eslint": "^8.18.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": "^
|
|
92
|
+
"eslint-import-resolver-typescript": "^3.1.1",
|
|
93
93
|
"eslint-plugin-html": "^6.2.0",
|
|
94
94
|
"eslint-plugin-import": "^2.26.0",
|
|
95
95
|
"eslint-plugin-jsdoc": "^39.3.3",
|
|
@@ -99,17 +99,17 @@
|
|
|
99
99
|
"eslint-plugin-yaml": "^0.5.0",
|
|
100
100
|
"eslint4b-prebuilt": "^6.7.2",
|
|
101
101
|
"husky": "^8.0.1",
|
|
102
|
-
"lint-staged": "^13.0.
|
|
102
|
+
"lint-staged": "^13.0.3",
|
|
103
103
|
"lodash": "^4.17.21",
|
|
104
104
|
"prettier": "^2.7.1",
|
|
105
105
|
"rimraf": "^3.0.2",
|
|
106
106
|
"rollup-plugin-visualizer": "^5.6.0",
|
|
107
|
-
"typescript": "
|
|
108
|
-
"vite": "^2.9.
|
|
107
|
+
"typescript": "4.6.*",
|
|
108
|
+
"vite": "^2.9.13",
|
|
109
109
|
"vite-plugin-checker": "^0.4.6",
|
|
110
110
|
"vue": "^3.2.37",
|
|
111
111
|
"vue-eslint-parser": "^9.0.3",
|
|
112
|
-
"vue-tsc": "^0.38.
|
|
112
|
+
"vue-tsc": "^0.38.2"
|
|
113
113
|
},
|
|
114
114
|
"husky": {
|
|
115
115
|
"hooks": {
|