vue-codemirror6 0.5.1 → 0.5.2
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
|
@@ -37,6 +37,7 @@ yarn add vue-codemirror6 @vue/composition-api
|
|
|
37
37
|
| phrases | Record<string, string> | Specify here if you want to make the displayed character string multilingual. see <https://codemirror.net/6/examples/translate/> |
|
|
38
38
|
| extensions | Extension[] | Includes enhancements to extend CodeMirror. |
|
|
39
39
|
| linter | LintSource | Set Linter. Enter a linter (eg `esLint([arbitrary rule])` function for `@codemirror / lang-javascript`, `jsonParseLinter()`function for`@codemirror/json`). See the sources for various language libraries for more information. |
|
|
40
|
+
| lintGutter | boolean | Display 🔴 on the line where there was an error when `linter` was specified. It will not work if `linter` is not specified. |
|
|
40
41
|
|
|
41
42
|
Notice: `lang` and `linter` can also be set together in `extensions`. This is defined for usability compatibility with past CodeMirrors.
|
|
42
43
|
|
|
@@ -126,7 +127,7 @@ export default defineComponent({
|
|
|
126
127
|
|
|
127
128
|
### Full Example
|
|
128
129
|
|
|
129
|
-
When using as a Markdown editor on [vite-vue2-vuetify-ts-starter](https://github.com/logue/vite-vue2-vuetify-ts-starter
|
|
130
|
+
When using as a Markdown editor on [vite-vue2-vuetify-ts-starter](https://github.com/logue/vite-vue2-vuetify-ts-starter).
|
|
130
131
|
|
|
131
132
|
```vue
|
|
132
133
|
<template>
|
|
@@ -241,12 +242,12 @@ const config: UserConfig = {
|
|
|
241
242
|
// ...
|
|
242
243
|
codemirror: [
|
|
243
244
|
// Split CodeMirror code.
|
|
244
|
-
'@codemirror/basic-setup'
|
|
245
|
-
'@codemirror/commands'
|
|
246
|
-
'@codemirror/language'
|
|
247
|
-
'@codemirror/lint'
|
|
248
|
-
'@codemirror/state'
|
|
249
|
-
'@codemirror/view'
|
|
245
|
+
'@codemirror/basic-setup',
|
|
246
|
+
'@codemirror/commands',
|
|
247
|
+
'@codemirror/language',
|
|
248
|
+
'@codemirror/lint',
|
|
249
|
+
'@codemirror/state',
|
|
250
|
+
'@codemirror/view',
|
|
250
251
|
// Add the following as needed.
|
|
251
252
|
'@codemirror/lang-html',
|
|
252
253
|
'@codemirror/lang-javascript',
|
|
@@ -120,6 +120,11 @@ declare const _default: import("vue-demi").DefineComponent<{
|
|
|
120
120
|
type: PropType<LintSource>;
|
|
121
121
|
default: () => undefined;
|
|
122
122
|
};
|
|
123
|
+
/** Show Gutter */
|
|
124
|
+
lintGutter: {
|
|
125
|
+
type: BooleanConstructor;
|
|
126
|
+
defalt: boolean;
|
|
127
|
+
};
|
|
123
128
|
}, {
|
|
124
129
|
context: SetupContext<import("vue-demi").EmitsOptions>;
|
|
125
130
|
editor: Ref<Element | undefined>;
|
|
@@ -238,6 +243,11 @@ declare const _default: import("vue-demi").DefineComponent<{
|
|
|
238
243
|
type: PropType<LintSource>;
|
|
239
244
|
default: () => undefined;
|
|
240
245
|
};
|
|
246
|
+
/** Show Gutter */
|
|
247
|
+
lintGutter: {
|
|
248
|
+
type: BooleanConstructor;
|
|
249
|
+
defalt: boolean;
|
|
250
|
+
};
|
|
241
251
|
}>>, {
|
|
242
252
|
modelValue: string | Text;
|
|
243
253
|
selection: EditorSelection | {
|
|
@@ -257,6 +267,7 @@ declare const _default: import("vue-demi").DefineComponent<{
|
|
|
257
267
|
phrases: Record<string, string>;
|
|
258
268
|
lang: LanguageSupport;
|
|
259
269
|
linter: LintSource;
|
|
270
|
+
lintGutter: boolean;
|
|
260
271
|
}>;
|
|
261
272
|
export default _default;
|
|
262
273
|
//# sourceMappingURL=CodeMirror.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeMirror.d.ts","sourceRoot":"","sources":["../../src/components/CodeMirror.ts"],"names":[],"mappings":"AAAA,OAAO,EAWL,KAAK,QAAQ,EACb,KAAK,GAAG,EACR,KAAK,YAAY,EAClB,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,eAAe,EAAe,MAAM,mBAA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;OAIG;;;;;IAKH;;;;OAIG;;;;;IAOH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH,kBAAkB;;;;;;;;;IAnHlB,kBAAkB;;;;;IAKlB;;;;OAIG;;;oBAG6B,MAAM;;;;;IAItC;;;;OAIG;;;;;;;IAOH,gBAAgB;;;;;IAKhB;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAOH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH,kBAAkB;;;;;;;;gBAvGc,MAAM;;;;;;;;;;;;;;;;;;AAtB1C,wBAmRG"}
|
package/dist/helpers/h-demi.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
interface Options {
|
|
2
|
+
class?: string;
|
|
2
3
|
domProps?: Record<any, any>;
|
|
3
4
|
on?: Record<any, any>;
|
|
4
5
|
props?: Record<any, any>;
|
|
5
6
|
ref?: string;
|
|
6
|
-
class?: string;
|
|
7
7
|
style?: string;
|
|
8
8
|
}
|
|
9
9
|
declare const h: (type: string | Record<any, any>, options?: Options, chidren?: any) => import("vue-demi").VNode<import("vue-demi").RendererNode, import("vue-demi").RendererElement, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"h-demi.d.ts","sourceRoot":"","sources":["../../src/helpers/h-demi.ts"],"names":[],"mappings":"AAEA,UAAU,OAAO;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;
|
|
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;CAChB;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"}
|
package/dist/index.es.js
CHANGED
|
@@ -4,7 +4,7 @@ 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 { compact, trim } from "lodash";
|
|
8
8
|
const adaptOnsV3 = (ons) => {
|
|
9
9
|
if (!ons)
|
|
10
10
|
return null;
|
|
@@ -19,14 +19,9 @@ const h = (type, options = {}, chidren) => {
|
|
|
19
19
|
return h$1(type, options, chidren);
|
|
20
20
|
const { props, domProps, on, ...extraOptions } = options;
|
|
21
21
|
const ons = on ? adaptOnsV3(on) : {};
|
|
22
|
-
|
|
23
|
-
return h$1(type, params, chidren);
|
|
24
|
-
};
|
|
25
|
-
const slot = (defaultSlots) => {
|
|
26
|
-
if (typeof defaultSlots == "function")
|
|
27
|
-
return defaultSlots();
|
|
28
|
-
return defaultSlots;
|
|
22
|
+
return h$1(type, { ...extraOptions, ...props, ...domProps, ...ons }, chidren);
|
|
29
23
|
};
|
|
24
|
+
const slot = (defaultSlots) => typeof defaultSlots == "function" ? defaultSlots() : defaultSlots;
|
|
30
25
|
var CodeMirror = defineComponent({
|
|
31
26
|
name: "CodeMirror",
|
|
32
27
|
model: {
|
|
@@ -87,8 +82,12 @@ var CodeMirror = defineComponent({
|
|
|
87
82
|
default: () => void 0
|
|
88
83
|
},
|
|
89
84
|
linter: {
|
|
90
|
-
type:
|
|
85
|
+
type: Function,
|
|
91
86
|
default: () => void 0
|
|
87
|
+
},
|
|
88
|
+
lintGutter: {
|
|
89
|
+
type: Boolean,
|
|
90
|
+
defalt: false
|
|
92
91
|
}
|
|
93
92
|
},
|
|
94
93
|
emits: ["update:modelValue", "update"],
|
|
@@ -97,25 +96,20 @@ var CodeMirror = defineComponent({
|
|
|
97
96
|
const doc = ref(props.modelValue);
|
|
98
97
|
const { dark } = toRefs(props);
|
|
99
98
|
const emit = context.emit;
|
|
100
|
-
const exts = computed(() =>
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
if (props.extensions) {
|
|
115
|
-
merge(ext, props.extensions);
|
|
116
|
-
}
|
|
117
|
-
return compact(ext);
|
|
118
|
-
});
|
|
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
|
+
]));
|
|
119
113
|
let view;
|
|
120
114
|
watch(doc, (current) => {
|
|
121
115
|
if (view.composing) {
|
|
@@ -135,7 +129,10 @@ var CodeMirror = defineComponent({
|
|
|
135
129
|
}));
|
|
136
130
|
});
|
|
137
131
|
onMounted(async () => {
|
|
138
|
-
if (
|
|
132
|
+
if (editor.value && editor.value.childNodes[0]) {
|
|
133
|
+
if (doc.value !== "") {
|
|
134
|
+
console.warn("[CodeMirror.vue] The CodeMirror tag contains child elements that overwrite the model values.");
|
|
135
|
+
}
|
|
139
136
|
doc.value = trim(editor.value.childNodes[0].innerText);
|
|
140
137
|
}
|
|
141
138
|
view = new EditorView({
|
package/dist/index.umd.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
(function(r,t){typeof exports=="object"&&typeof module<"u"?t(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"],t):(r=typeof globalThis<"u"?globalThis:r||self,t(r.CodeMirror={},r.VueDemi,r.state,r.view,r.lint,r.basicSetup,r.commands,r.lodash))})(this,function(r,t,s,
|
|
1
|
+
(function(r,t){typeof exports=="object"&&typeof module<"u"?t(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"],t):(r=typeof globalThis<"u"?globalThis:r||self,t(r.CodeMirror={},r.VueDemi,r.state,r.view,r.lint,r.basicSetup,r.commands,r.lodash))})(this,function(r,t,s,n,m,y,b,h){"use strict";const V=e=>e?Object.entries(e).reduce((a,[o,i])=>(o=o.charAt(0).toUpperCase()+o.slice(1),o=`on${o}`,{...a,[o]:i}),{}):null,v=(e,a={},o)=>{if(t.isVue2)return t.h(e,a,o);const{props:i,domProps:f,on:u,...c}=a,d=u?V(u):{};return t.h(e,{...c,...i,...f,...d},o)},w=e=>typeof e=="function"?e():e;var p=t.defineComponent({name:"CodeMirror",model:{prop:"modelValue",event:"update:modelValue"},props:{modelValue:{type:String,default:""},selection:{type:Object,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:()=>{}},lintGutter:{type:Boolean,defalt:!1}},emits:["update:modelValue","update"],setup(e,a){const o=t.ref(),i=t.ref(e.modelValue),{dark:f}=t.toRefs(e),u=a.emit,c=t.computed(()=>h.compact([e.basic?y.basicSetup:void 0,n.EditorView.updateListener.of(l=>u("update",l)),n.EditorView.theme(e.theme,{dark:f.value}),e.wrap?n.EditorView.lineWrapping:void 0,e.tab?n.keymap.of([b.indentWithTab]):void 0,e.phrases?s.EditorState.phrases.of(e.phrases):void 0,e.readonly?s.EditorState.readOnly.of(e.readonly):void 0,e.editable?n.EditorView.editable.of(e.editable):void 0,e.lang?t.toRaw(e.lang):void 0,e.linter?m.linter(e.linter):void 0,e.linter&&e.lintGutter?m.lintGutter():void 0,...e.extensions]));let d;return t.watch(i,l=>{if(d.composing)return;const E=d.state.selection;d.setState(s.EditorState.create({doc:l,extensions:c.value,selection:E}))}),t.watch(f,()=>{d.setState(s.EditorState.create({doc:i.value,extensions:c.value}))}),t.onMounted(async()=>{o.value&&o.value.childNodes[0]&&(i.value!==""&&console.warn("[CodeMirror.vue] The CodeMirror tag contains child elements that overwrite the model values."),i.value=h.trim(o.value.childNodes[0].innerText)),d=new n.EditorView({state:s.EditorState.create({doc:i.value,selection:e.selection,extensions:c.value}),parent:o.value,dispatch:l=>{d.update([l]),!l.changes.empty&&(i.value=d.state.doc.toString(),u("update:modelValue",i.value))}}),await t.nextTick()}),t.onUnmounted(()=>d.destroy()),{context:a,editor:o}},render(){return v("div",{ref:"editor",class:"vue-codemirror"},this.$slots.default?v("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 S=e=>e.component("CodeMirror",
|
|
8
|
+
*/const S=e=>e.component("CodeMirror",p);r.default=p,r.install=S,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.2",
|
|
5
5
|
"description": "CodeMirror6 Component for vue2 and vue3",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"vuejs",
|
|
@@ -110,7 +110,7 @@
|
|
|
110
110
|
"prettier": "^2.6.2",
|
|
111
111
|
"prettier-plugin-jsdoc": "^0.3.38",
|
|
112
112
|
"prettier-plugin-md-nocjsp": "^1.2.0",
|
|
113
|
-
"prettier-plugin-sort-imports": "^1.
|
|
113
|
+
"prettier-plugin-sort-imports": "^1.7.0",
|
|
114
114
|
"rimraf": "^3.0.2",
|
|
115
115
|
"rollup-plugin-visualizer": "^5.6.0",
|
|
116
116
|
"typescript": "^4.7.2",
|
|
@@ -118,7 +118,7 @@
|
|
|
118
118
|
"vite-plugin-checker": "^0.4.6",
|
|
119
119
|
"vue": "^3.2.36",
|
|
120
120
|
"vue-eslint-parser": "^9.0.2",
|
|
121
|
-
"vue-tsc": "^0.
|
|
121
|
+
"vue-tsc": "^0.35.0"
|
|
122
122
|
},
|
|
123
123
|
"husky": {
|
|
124
124
|
"hooks": {
|