vue-codemirror6 0.3.0 → 0.3.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/README.md +8 -11
- package/dist/components/CodeMirror.vue.d.ts +5 -5
- package/dist/components/CodeMirror.vue.d.ts.map +1 -1
- package/dist/index.d.ts +5 -98
- package/dist/index.d.ts.map +1 -1
- package/dist/vue-codemirror6.es.js +11 -21
- package/dist/vue-codemirror6.umd.js +2 -2
- package/package.json +30 -30
- package/src/components/CodeMirror.vue +11 -17
- package/dist/index.esm.d.ts +0 -98
- package/dist/index.esm.d.ts.map +0 -1
- package/dist/interfaces/CodeMirrorPropsInterface.d.ts +0 -56
- package/dist/interfaces/CodeMirrorPropsInterface.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -3,14 +3,17 @@
|
|
|
3
3
|
[](https://www.jsdelivr.com/package/npm/vue-codemirror6)
|
|
4
4
|
[](https://www.npmjs.com/package/vue-codemirror6)
|
|
5
5
|
[](https://uiwjs.github.io/npm-unpkg/#/pkg/vue-codemirror6/file/README.md)
|
|
6
|
-
[](https://www.npmjs.com/package
|
|
6
|
+
[](https://www.npmjs.com/package/vue-codemirror6)
|
|
7
7
|
[](https://gitpod.io/#https://github.com/logue/vue-codemirror6)
|
|
8
8
|
|
|
9
9
|
A component for using [CodeMirror6](https://codemirror.net/6/) with Vue. Unrelated to [surmon-china's vue-codemirror](https://github.com/surmon-china/vue-codemirror), it is for CodeMirror6.
|
|
10
10
|
|
|
11
|
+
If you are using Vue2, please use `0.1.x`. (The component itself supports both, but the script generated by vue-demi can only output one)
|
|
12
|
+
|
|
11
13
|
## Usage
|
|
12
14
|
|
|
13
15
|
This component can handle bidirectional binding by `v-model` like a general Vue component.
|
|
16
|
+
When using with Vue2, [@vue/composition-api](https://www.npmjs.com/package/@vue/composition-api) is required separately.
|
|
14
17
|
|
|
15
18
|
### Props
|
|
16
19
|
|
|
@@ -59,21 +62,15 @@ Mark up as follows to make it work at a minimum.
|
|
|
59
62
|
<script>
|
|
60
63
|
import { ref, defineComponent } from 'vue';
|
|
61
64
|
|
|
62
|
-
import CodeMirror from '
|
|
65
|
+
import CodeMirror from 'vue-codemirror6';
|
|
63
66
|
|
|
64
67
|
export default defineComponent({
|
|
65
68
|
components: {
|
|
66
69
|
CodeMirror,
|
|
67
70
|
},
|
|
68
71
|
setup() {
|
|
69
|
-
const value = ref(
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
[Lorem ipsum](https://www.lipsum.com/) dolor sit amet, **consectetur** adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
|
|
73
|
-
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
|
|
74
|
-
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
|
|
75
|
-
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.`
|
|
76
|
-
);
|
|
72
|
+
const value = ref('Cozy lummox gives smart squid who asks for job pen.');
|
|
73
|
+
|
|
77
74
|
return { value };
|
|
78
75
|
},
|
|
79
76
|
});
|
|
@@ -102,7 +99,7 @@ import { ref, defineComponent } from 'vue';
|
|
|
102
99
|
|
|
103
100
|
import { json } from '@codemirror/lang-json';
|
|
104
101
|
|
|
105
|
-
import CodeMirror from '
|
|
102
|
+
import CodeMirror from 'vue-codemirror6';
|
|
106
103
|
|
|
107
104
|
export default defineComponent({
|
|
108
105
|
components: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { Ref, PropType, SetupContext } from 'vue-demi';
|
|
2
|
+
import type { Extension } from '@codemirror/state';
|
|
3
3
|
import type { LanguageSupport } from '@codemirror/language';
|
|
4
4
|
import type { Diagnostic } from '@codemirror/lint';
|
|
5
5
|
import type { StyleSpec } from 'style-mod';
|
|
@@ -80,9 +80,9 @@ declare const _default: import("vue-demi").DefineComponent<{
|
|
|
80
80
|
default: undefined;
|
|
81
81
|
};
|
|
82
82
|
}, {
|
|
83
|
-
context: SetupContext<EmitsOptions>;
|
|
83
|
+
context: SetupContext<import("vue-demi").EmitsOptions>;
|
|
84
84
|
editor: Ref<Element | undefined>;
|
|
85
|
-
}, unknown, {}, {}, import("vue-demi").ComponentOptionsMixin, import("vue-demi").ComponentOptionsMixin, EmitsOptions, "update:modelValue" | "update", import("vue-demi").VNodeProps & import("vue-demi").AllowedComponentProps & import("vue-demi").ComponentCustomProps, Readonly<import("vue-demi").ExtractPropTypes<{
|
|
85
|
+
}, 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<{
|
|
86
86
|
/** Model value */
|
|
87
87
|
modelValue: {
|
|
88
88
|
type: StringConstructor;
|
|
@@ -159,12 +159,12 @@ declare const _default: import("vue-demi").DefineComponent<{
|
|
|
159
159
|
default: undefined;
|
|
160
160
|
};
|
|
161
161
|
}>>, {
|
|
162
|
+
readonly: boolean;
|
|
162
163
|
modelValue: string;
|
|
163
164
|
theme: {
|
|
164
165
|
[selector: string]: StyleSpec;
|
|
165
166
|
};
|
|
166
167
|
dark: boolean;
|
|
167
|
-
readonly: boolean;
|
|
168
168
|
editable: boolean;
|
|
169
169
|
extensions: Extension[];
|
|
170
170
|
phrases: Record<string, string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeMirror.vue.d.ts","sourceRoot":"","sources":["../../src/components/CodeMirror.vue.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CodeMirror.vue.d.ts","sourceRoot":"","sources":["../../src/components/CodeMirror.vue.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAe,GAAG,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAIzE,OAAO,KAAK,EAAE,SAAS,EAAe,MAAM,mBAAmB,CAAC;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;;IAavC,kBAAkB;;;;;IAKlB;;;;OAIG;;;;;;;IAKH,gBAAgB;;;;;IAKhB;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;;;;;IApEH,kBAAkB;;;;;IAKlB;;;;OAIG;;;;;;;IAKH,gBAAgB;;;;;IAKhB;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;;;;;;;;;;;;;;AA/EP,2BAA2B;AAC3B,wBA+MG"}
|
package/dist/index.d.ts
CHANGED
|
@@ -6,102 +6,9 @@
|
|
|
6
6
|
* @copyright 2022 Masashi Yoshikawa {@link https://logue.dev/} All rights reserved.
|
|
7
7
|
* @see {@link https://github.com/logue/vue-codemirror6}
|
|
8
8
|
*/
|
|
9
|
-
import
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
};
|
|
15
|
-
theme: {
|
|
16
|
-
type: import("vue").PropType<{
|
|
17
|
-
[selector: string]: import("style-mod").StyleSpec;
|
|
18
|
-
}>;
|
|
19
|
-
default: undefined;
|
|
20
|
-
};
|
|
21
|
-
dark: {
|
|
22
|
-
type: BooleanConstructor;
|
|
23
|
-
default: boolean;
|
|
24
|
-
};
|
|
25
|
-
readonly: {
|
|
26
|
-
type: BooleanConstructor;
|
|
27
|
-
default: boolean;
|
|
28
|
-
};
|
|
29
|
-
editable: {
|
|
30
|
-
type: BooleanConstructor;
|
|
31
|
-
default: boolean;
|
|
32
|
-
};
|
|
33
|
-
extensions: {
|
|
34
|
-
type: import("vue").PropType<import("@codemirror/state").Extension[]>;
|
|
35
|
-
default: undefined;
|
|
36
|
-
};
|
|
37
|
-
phrases: {
|
|
38
|
-
type: import("vue").PropType<Record<string, string>>;
|
|
39
|
-
default: undefined;
|
|
40
|
-
};
|
|
41
|
-
lang: {
|
|
42
|
-
type: import("vue").PropType<import("@codemirror/language").LanguageSupport>;
|
|
43
|
-
default: undefined;
|
|
44
|
-
};
|
|
45
|
-
linter: {
|
|
46
|
-
type: import("vue").PropType<import("@codemirror/lint").Diagnostic[]>;
|
|
47
|
-
default: undefined;
|
|
48
|
-
};
|
|
49
|
-
}, {
|
|
50
|
-
context: import("vue").SetupContext<import("vue").EmitsOptions>;
|
|
51
|
-
editor: import("vue").Ref<Element | undefined>;
|
|
52
|
-
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("vue").EmitsOptions, "update:modelValue" | "update", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
53
|
-
modelValue: {
|
|
54
|
-
type: StringConstructor;
|
|
55
|
-
default: string;
|
|
56
|
-
};
|
|
57
|
-
theme: {
|
|
58
|
-
type: import("vue").PropType<{
|
|
59
|
-
[selector: string]: import("style-mod").StyleSpec;
|
|
60
|
-
}>;
|
|
61
|
-
default: undefined;
|
|
62
|
-
};
|
|
63
|
-
dark: {
|
|
64
|
-
type: BooleanConstructor;
|
|
65
|
-
default: boolean;
|
|
66
|
-
};
|
|
67
|
-
readonly: {
|
|
68
|
-
type: BooleanConstructor;
|
|
69
|
-
default: boolean;
|
|
70
|
-
};
|
|
71
|
-
editable: {
|
|
72
|
-
type: BooleanConstructor;
|
|
73
|
-
default: boolean;
|
|
74
|
-
};
|
|
75
|
-
extensions: {
|
|
76
|
-
type: import("vue").PropType<import("@codemirror/state").Extension[]>;
|
|
77
|
-
default: undefined;
|
|
78
|
-
};
|
|
79
|
-
phrases: {
|
|
80
|
-
type: import("vue").PropType<Record<string, string>>;
|
|
81
|
-
default: undefined;
|
|
82
|
-
};
|
|
83
|
-
lang: {
|
|
84
|
-
type: import("vue").PropType<import("@codemirror/language").LanguageSupport>;
|
|
85
|
-
default: undefined;
|
|
86
|
-
};
|
|
87
|
-
linter: {
|
|
88
|
-
type: import("vue").PropType<import("@codemirror/lint").Diagnostic[]>;
|
|
89
|
-
default: undefined;
|
|
90
|
-
};
|
|
91
|
-
}>>, {
|
|
92
|
-
modelValue: string;
|
|
93
|
-
theme: {
|
|
94
|
-
[selector: string]: import("style-mod").StyleSpec;
|
|
95
|
-
};
|
|
96
|
-
dark: boolean;
|
|
97
|
-
readonly: boolean;
|
|
98
|
-
editable: boolean;
|
|
99
|
-
extensions: import("@codemirror/state").Extension[];
|
|
100
|
-
phrases: Record<string, string>;
|
|
101
|
-
lang: import("@codemirror/language").LanguageSupport;
|
|
102
|
-
linter: import("@codemirror/lint").Diagnostic[];
|
|
103
|
-
}> | {
|
|
104
|
-
install: (app: any) => void;
|
|
105
|
-
}) & typeof namedExports;
|
|
106
|
-
export default _default;
|
|
9
|
+
import CodeMirror from './components/CodeMirror.vue';
|
|
10
|
+
import { App } from 'vue-demi';
|
|
11
|
+
declare const installCodeMirror: (app: App) => void;
|
|
12
|
+
export { CodeMirror, installCodeMirror as install };
|
|
13
|
+
export default CodeMirror;
|
|
107
14
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,UAAU,MAAM,6BAA6B,CAAC;AACrD,OAAO,EAAW,GAAG,EAAE,MAAM,UAAU,CAAC;AAIxC,QAAA,MAAM,iBAAiB,QAAS,GAAG,SAElC,CAAC;AAEF,OAAO,EAAE,UAAU,EAAE,iBAAiB,IAAI,OAAO,EAAE,CAAC;AACpD,eAAe,UAAU,CAAC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { defineComponent, ref, computed, watch, onMounted, onUnmounted,
|
|
1
|
+
import { defineComponent, ref, computed, watch, onMounted, onUnmounted, install } from "vue-demi";
|
|
2
2
|
import { EditorState } from "@codemirror/state";
|
|
3
3
|
import { EditorView } from "@codemirror/view";
|
|
4
4
|
import { merge, compact } from "lodash";
|
|
5
|
+
import { openBlock, createElementBlock, withDirectives, createElementVNode, renderSlot, vShow } from "vue";
|
|
5
6
|
var _export_sfc = (sfc, props) => {
|
|
6
7
|
const target = sfc.__vccOpts || sfc;
|
|
7
8
|
for (const [key, val] of props) {
|
|
@@ -64,7 +65,7 @@ const _sfc_main = defineComponent({
|
|
|
64
65
|
EditorView.updateListener.of((update) => {
|
|
65
66
|
emit("update", update);
|
|
66
67
|
}),
|
|
67
|
-
EditorView.theme(props.theme || {}, { dark:
|
|
68
|
+
EditorView.theme(props.theme || {}, { dark: dark.value }),
|
|
68
69
|
props.phrases ? EditorState.phrases.of(props.phrases) : void 0,
|
|
69
70
|
props.lang,
|
|
70
71
|
props.readonly ? EditorState.readOnly.of(props.readonly) : void 0,
|
|
@@ -126,25 +127,14 @@ const _hoisted_1 = {
|
|
|
126
127
|
};
|
|
127
128
|
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
128
129
|
return openBlock(), createElementBlock("div", _hoisted_1, [
|
|
129
|
-
withDirectives(createElementVNode("
|
|
130
|
+
withDirectives(createElementVNode("aside", null, [
|
|
130
131
|
renderSlot(_ctx.$slots, "default")
|
|
131
132
|
], 512), [
|
|
132
|
-
[vShow, _ctx.context.slots.
|
|
133
|
+
[vShow, !_ctx.context.slots.default]
|
|
133
134
|
])
|
|
134
135
|
], 512);
|
|
135
136
|
}
|
|
136
|
-
var
|
|
137
|
-
var component = (() => {
|
|
138
|
-
return {
|
|
139
|
-
install: (app) => {
|
|
140
|
-
app.component("CodeMirror", component$1);
|
|
141
|
-
}
|
|
142
|
-
};
|
|
143
|
-
})();
|
|
144
|
-
var namedExports = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
145
|
-
__proto__: null,
|
|
146
|
-
"default": component
|
|
147
|
-
}, Symbol.toStringTag, { value: "Module" }));
|
|
137
|
+
var CodeMirror = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
|
|
148
138
|
/**
|
|
149
139
|
* Vue CodeMirror6 Component
|
|
150
140
|
*
|
|
@@ -153,8 +143,8 @@ var namedExports = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePr
|
|
|
153
143
|
* @copyright 2022 Masashi Yoshikawa {@link https://logue.dev/} All rights reserved.
|
|
154
144
|
* @see {@link https://github.com/logue/vue-codemirror6}
|
|
155
145
|
*/
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
}
|
|
160
|
-
export {
|
|
146
|
+
install();
|
|
147
|
+
const installCodeMirror = (app) => {
|
|
148
|
+
app.component("CodeMirror", CodeMirror);
|
|
149
|
+
};
|
|
150
|
+
export { CodeMirror, CodeMirror as default, installCodeMirror as install };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
(function(t
|
|
1
|
+
(function(o,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue-demi"),require("@codemirror/state"),require("@codemirror/view"),require("lodash"),require("vue")):typeof define=="function"&&define.amd?define(["exports","vue-demi","@codemirror/state","@codemirror/view","lodash","vue"],t):(o=typeof globalThis<"u"?globalThis:o||self,t(o.CodeMirror={},o.VueDemi,o.state,o.view,o.lodash,o.Vue))})(this,function(o,t,s,f,m,i){"use strict";var p=(e,u)=>{const d=e.__vccOpts||e;for(const[r,c]of u)d[r]=c;return d};const V=t.defineComponent({name:"CodeMirror",model:{prop:"modelValue",event:"update:modelValue"},props:{modelValue:{type:String,default:""},theme:{type:Object,default:void 0},dark:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1},editable:{type:Boolean,default:!0},extensions:{type:Array,default:void 0},phrases:{type:Object,default:void 0},lang:{type:Object,default:void 0},linter:{type:Array,default:void 0}},emits:["update:modelValue","update"],setup(e,u){const d=t.ref(),r=t.ref(e.modelValue),c=t.ref(e.dark),y=u.emit,h=t.computed(()=>{const a=[f.EditorView.updateListener.of(l=>{y("update",l)}),f.EditorView.theme(e.theme||{},{dark:c.value}),e.phrases?s.EditorState.phrases.of(e.phrases):void 0,e.lang,e.readonly?s.EditorState.readOnly.of(e.readonly):void 0,e.editable?f.EditorView.editable.of(e.editable):void 0];return e.linter&&m.merge(a,e.linter),e.extensions&&m.merge(a,e.extensions),m.compact(a)});let n;return t.watch(r,a=>{if(n.composing)return;const l=n.state.selection;n.setState(s.EditorState.create({doc:a,extensions:h.value,selection:l}))}),t.watch(c,()=>{n.setState(s.EditorState.create({doc:r.value,extensions:h.value}))}),t.onMounted(()=>{const a=!r.value&&d.value?d.value.childNodes[0].innerText:r.value;n=new f.EditorView({state:s.EditorState.create({doc:a,extensions:h.value}),parent:d.value,dispatch:l=>{n.update([l]),!l.changes.empty&&(r.value=n.state.doc.toString(),y("update:modelValue",r.value))}})}),t.onUnmounted(()=>n.destroy()),{context:u,editor:d}}}),S={ref:"editor",class:"vue-codemirror"};function _(e,u,d,r,c,y){return i.openBlock(),i.createElementBlock("div",S,[i.withDirectives(i.createElementVNode("aside",null,[i.renderSlot(e.$slots,"default")],512),[[i.vShow,!e.context.slots.default]])],512)}var v=p(V,[["render",_]]);/**
|
|
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
|
-
*/
|
|
8
|
+
*/t.install();const E=e=>{e.component("CodeMirror",v)};o.CodeMirror=v,o.default=v,o.install=E,Object.defineProperties(o,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "vue-codemirror6",
|
|
4
|
-
"version": "0.3.
|
|
5
|
-
"description": "CodeMirror6 Component for
|
|
4
|
+
"version": "0.3.3",
|
|
5
|
+
"description": "CodeMirror6 Component for vue3",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"vuejs",
|
|
8
8
|
"vue",
|
|
@@ -56,12 +56,12 @@
|
|
|
56
56
|
"scripts": {
|
|
57
57
|
"dev": "vite",
|
|
58
58
|
"clean": "rimraf node_modules/.vite",
|
|
59
|
-
"build": "vite build & vue-tsc",
|
|
59
|
+
"build": "vite build & vue-tsc --declaration --emitDeclarationOnly",
|
|
60
60
|
"build:clean": "rimraf dist",
|
|
61
61
|
"lint": "eslint . --fix --cache --cache-location ./node_modules/.vite/vite-plugin-eslint && prettier . --write",
|
|
62
62
|
"lint:markup": "vue-tsc --noEmit",
|
|
63
|
-
"switch:2": "vue-demi-switch 2",
|
|
64
|
-
"switch:3": "vue-demi-switch 3",
|
|
63
|
+
"switch:2": "vue-demi-switch 2 & npx vue-demi-fix",
|
|
64
|
+
"switch:3": "vue-demi-switch 3 vue3 & npx vue-demi-fix",
|
|
65
65
|
"prepare": "husky install",
|
|
66
66
|
"postinstall": "npx vue-demi-fix"
|
|
67
67
|
},
|
|
@@ -69,8 +69,10 @@
|
|
|
69
69
|
"vue-demi": "latest"
|
|
70
70
|
},
|
|
71
71
|
"peerDependencies": {
|
|
72
|
-
"@
|
|
73
|
-
"
|
|
72
|
+
"@codemirror/state": "latest",
|
|
73
|
+
"@codemirror/view": "latest",
|
|
74
|
+
"@vue/composition-api": "latest",
|
|
75
|
+
"vue": "^2.6.14 || ^3.2.33"
|
|
74
76
|
},
|
|
75
77
|
"peerDependenciesMeta": {
|
|
76
78
|
"@vue/composition-api": {
|
|
@@ -78,44 +80,42 @@
|
|
|
78
80
|
}
|
|
79
81
|
},
|
|
80
82
|
"devDependencies": {
|
|
81
|
-
"@codemirror/basic-setup": "^0.
|
|
82
|
-
"@codemirror/lang-markdown": "^0.
|
|
83
|
-
"@codemirror/language": "^0.
|
|
84
|
-
"@codemirror/lint": "^0.
|
|
85
|
-
"@
|
|
86
|
-
"@
|
|
87
|
-
"@types/
|
|
88
|
-
"@
|
|
89
|
-
"@typescript-eslint/
|
|
90
|
-
"@
|
|
91
|
-
"@vitejs/plugin-vue": "^2.2.4",
|
|
83
|
+
"@codemirror/basic-setup": "^0.20.0",
|
|
84
|
+
"@codemirror/lang-markdown": "^0.20.0",
|
|
85
|
+
"@codemirror/language": "^0.20.0",
|
|
86
|
+
"@codemirror/lint": "^0.20.1",
|
|
87
|
+
"@modyqyw/vite-plugin-eslint": "^1.3.0",
|
|
88
|
+
"@types/lodash": "^4.14.182",
|
|
89
|
+
"@types/node": "^17.0.27",
|
|
90
|
+
"@typescript-eslint/eslint-plugin": "^5.21.0",
|
|
91
|
+
"@typescript-eslint/parser": "^5.21.0",
|
|
92
|
+
"@vitejs/plugin-vue": "^2.3.1",
|
|
92
93
|
"@vue/eslint-config-typescript": "^10.0.0",
|
|
93
|
-
"eslint": "^8.
|
|
94
|
+
"eslint": "^8.14.0",
|
|
94
95
|
"eslint-config-google": "^0.14.0",
|
|
95
96
|
"eslint-config-prettier": "^8.5.0",
|
|
96
97
|
"eslint-import-resolver-alias": "^1.1.2",
|
|
97
|
-
"eslint-import-resolver-typescript": "^2.7.
|
|
98
|
-
"eslint-plugin-import": "^2.
|
|
98
|
+
"eslint-import-resolver-typescript": "^2.7.1",
|
|
99
|
+
"eslint-plugin-import": "^2.26.0",
|
|
99
100
|
"eslint-plugin-prettier": "^4.0.0",
|
|
100
101
|
"eslint-plugin-prettier-vue": "^3.1.0",
|
|
101
|
-
"eslint-plugin-tsdoc": "^0.2.
|
|
102
|
-
"eslint-plugin-vue": "^8.
|
|
102
|
+
"eslint-plugin-tsdoc": "^0.2.16",
|
|
103
|
+
"eslint-plugin-vue": "^8.7.1",
|
|
103
104
|
"eslint-plugin-vuejs-accessibility": "^1.1.1",
|
|
104
105
|
"husky": "^7.0.4",
|
|
105
|
-
"lint-staged": "^12.
|
|
106
|
+
"lint-staged": "^12.4.0",
|
|
106
107
|
"lodash": "^4.17.21",
|
|
107
|
-
"prettier": "^2.6.
|
|
108
|
-
"prettier-plugin-jsdoc": "^0.3.
|
|
108
|
+
"prettier": "^2.6.2",
|
|
109
|
+
"prettier-plugin-jsdoc": "^0.3.38",
|
|
109
110
|
"prettier-plugin-md-nocjsp": "^1.2.0",
|
|
110
111
|
"prettier-plugin-sort-imports": "^1.6.0",
|
|
111
112
|
"rimraf": "^3.0.2",
|
|
112
113
|
"typescript": "^4.6.3",
|
|
113
|
-
"vite": "^2.
|
|
114
|
-
"
|
|
115
|
-
"vue": "^3.2.31",
|
|
114
|
+
"vite": "^2.9.5",
|
|
115
|
+
"vue": "^3.2.33",
|
|
116
116
|
"vue-eslint-parser": "^8.3.0",
|
|
117
117
|
"vue-template-compiler": "^2.6.14",
|
|
118
|
-
"vue-tsc": "^0.
|
|
118
|
+
"vue-tsc": "^0.34.10"
|
|
119
119
|
},
|
|
120
120
|
"husky": {
|
|
121
121
|
"hooks": {
|
|
@@ -1,37 +1,31 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div ref="editor" class="vue-codemirror">
|
|
3
|
-
<
|
|
3
|
+
<aside v-show="!context.slots.default"><slot /></aside>
|
|
4
4
|
</div>
|
|
5
5
|
</template>
|
|
6
6
|
|
|
7
7
|
<script lang="ts">
|
|
8
8
|
import {
|
|
9
9
|
computed,
|
|
10
|
-
type ComputedRef,
|
|
11
10
|
ref,
|
|
12
11
|
watch,
|
|
13
12
|
onMounted,
|
|
14
13
|
onUnmounted,
|
|
15
|
-
type Ref,
|
|
16
14
|
defineComponent,
|
|
17
|
-
type PropType,
|
|
18
|
-
type SetupContext,
|
|
19
|
-
EmitsOptions,
|
|
20
15
|
} from 'vue-demi';
|
|
16
|
+
import { EditorState } from '@codemirror/state';
|
|
17
|
+
import { EditorView } from '@codemirror/view';
|
|
18
|
+
import { compact, merge } from 'lodash';
|
|
19
|
+
|
|
20
|
+
import type { ComputedRef, Ref, PropType, SetupContext } from 'vue-demi';
|
|
21
21
|
|
|
22
|
-
import type CodeMirrorPropsInterface from '@/interfaces/CodeMirrorPropsInterface';
|
|
23
22
|
import type CodeMirrorEmitsInterface from '@/interfaces/CodeMirrorEmitsInterface';
|
|
24
23
|
|
|
25
|
-
import {
|
|
26
|
-
EditorState,
|
|
27
|
-
type Extension,
|
|
28
|
-
type Transaction,
|
|
29
|
-
} from '@codemirror/state';
|
|
30
|
-
import { EditorView, type ViewUpdate } from '@codemirror/view';
|
|
24
|
+
import type { Extension, Transaction } from '@codemirror/state';
|
|
31
25
|
import type { LanguageSupport } from '@codemirror/language';
|
|
26
|
+
import type { ViewUpdate } from '@codemirror/view';
|
|
32
27
|
import type { Diagnostic } from '@codemirror/lint';
|
|
33
28
|
import type { StyleSpec } from 'style-mod';
|
|
34
|
-
import { compact, merge } from 'lodash';
|
|
35
29
|
|
|
36
30
|
/** CodeMirror Component */
|
|
37
31
|
export default defineComponent({
|
|
@@ -125,7 +119,7 @@ export default defineComponent({
|
|
|
125
119
|
* @param props - Props
|
|
126
120
|
* @param context - Context
|
|
127
121
|
*/
|
|
128
|
-
setup(props
|
|
122
|
+
setup(props, context: SetupContext) {
|
|
129
123
|
/** Editor DOM */
|
|
130
124
|
const editor: Ref<Element | undefined> = ref<Element>();
|
|
131
125
|
|
|
@@ -147,7 +141,7 @@ export default defineComponent({
|
|
|
147
141
|
emit('update', update);
|
|
148
142
|
}),
|
|
149
143
|
// Toggle light/dark mode.
|
|
150
|
-
EditorView.theme(props.theme || {}, { dark:
|
|
144
|
+
EditorView.theme(props.theme || {}, { dark: dark.value }),
|
|
151
145
|
// locale settings
|
|
152
146
|
props.phrases ? EditorState.phrases.of(props.phrases) : undefined,
|
|
153
147
|
// Parser language setting
|
|
@@ -209,7 +203,7 @@ export default defineComponent({
|
|
|
209
203
|
|
|
210
204
|
/** When loaded */
|
|
211
205
|
onMounted(() => {
|
|
212
|
-
/** Value */
|
|
206
|
+
/** Initial Value */
|
|
213
207
|
const value =
|
|
214
208
|
!modelValue.value && editor.value
|
|
215
209
|
? (editor.value.childNodes[0] as HTMLDivElement).innerText
|
package/dist/index.esm.d.ts
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
declare const _default: import("vue-demi").DefineComponent<{
|
|
2
|
-
modelValue: {
|
|
3
|
-
type: StringConstructor;
|
|
4
|
-
default: string;
|
|
5
|
-
};
|
|
6
|
-
theme: {
|
|
7
|
-
type: import("vue-demi").PropType<{
|
|
8
|
-
[selector: string]: import("style-mod").StyleSpec;
|
|
9
|
-
}>;
|
|
10
|
-
default: undefined;
|
|
11
|
-
};
|
|
12
|
-
dark: {
|
|
13
|
-
type: BooleanConstructor;
|
|
14
|
-
default: boolean;
|
|
15
|
-
};
|
|
16
|
-
readonly: {
|
|
17
|
-
type: BooleanConstructor;
|
|
18
|
-
default: boolean;
|
|
19
|
-
};
|
|
20
|
-
editable: {
|
|
21
|
-
type: BooleanConstructor;
|
|
22
|
-
default: boolean;
|
|
23
|
-
};
|
|
24
|
-
extensions: {
|
|
25
|
-
type: import("vue-demi").PropType<import("@codemirror/state").Extension[]>;
|
|
26
|
-
default: undefined;
|
|
27
|
-
};
|
|
28
|
-
phrases: {
|
|
29
|
-
type: import("vue-demi").PropType<Record<string, string>>;
|
|
30
|
-
default: undefined;
|
|
31
|
-
};
|
|
32
|
-
lang: {
|
|
33
|
-
type: import("vue-demi").PropType<import("@codemirror/language").LanguageSupport>;
|
|
34
|
-
default: undefined;
|
|
35
|
-
};
|
|
36
|
-
linter: {
|
|
37
|
-
type: import("vue-demi").PropType<import("@codemirror/lint").Diagnostic[]>;
|
|
38
|
-
default: undefined;
|
|
39
|
-
};
|
|
40
|
-
}, {
|
|
41
|
-
context: import("vue-demi").SetupContext<import("vue-demi").EmitsOptions>;
|
|
42
|
-
editor: import("vue-demi").Ref<Element | undefined>;
|
|
43
|
-
}, 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<{
|
|
44
|
-
modelValue: {
|
|
45
|
-
type: StringConstructor;
|
|
46
|
-
default: string;
|
|
47
|
-
};
|
|
48
|
-
theme: {
|
|
49
|
-
type: import("vue-demi").PropType<{
|
|
50
|
-
[selector: string]: import("style-mod").StyleSpec;
|
|
51
|
-
}>;
|
|
52
|
-
default: undefined;
|
|
53
|
-
};
|
|
54
|
-
dark: {
|
|
55
|
-
type: BooleanConstructor;
|
|
56
|
-
default: boolean;
|
|
57
|
-
};
|
|
58
|
-
readonly: {
|
|
59
|
-
type: BooleanConstructor;
|
|
60
|
-
default: boolean;
|
|
61
|
-
};
|
|
62
|
-
editable: {
|
|
63
|
-
type: BooleanConstructor;
|
|
64
|
-
default: boolean;
|
|
65
|
-
};
|
|
66
|
-
extensions: {
|
|
67
|
-
type: import("vue-demi").PropType<import("@codemirror/state").Extension[]>;
|
|
68
|
-
default: undefined;
|
|
69
|
-
};
|
|
70
|
-
phrases: {
|
|
71
|
-
type: import("vue-demi").PropType<Record<string, string>>;
|
|
72
|
-
default: undefined;
|
|
73
|
-
};
|
|
74
|
-
lang: {
|
|
75
|
-
type: import("vue-demi").PropType<import("@codemirror/language").LanguageSupport>;
|
|
76
|
-
default: undefined;
|
|
77
|
-
};
|
|
78
|
-
linter: {
|
|
79
|
-
type: import("vue-demi").PropType<import("@codemirror/lint").Diagnostic[]>;
|
|
80
|
-
default: undefined;
|
|
81
|
-
};
|
|
82
|
-
}>>, {
|
|
83
|
-
modelValue: string;
|
|
84
|
-
theme: {
|
|
85
|
-
[selector: string]: import("style-mod").StyleSpec;
|
|
86
|
-
};
|
|
87
|
-
dark: boolean;
|
|
88
|
-
readonly: boolean;
|
|
89
|
-
editable: boolean;
|
|
90
|
-
extensions: import("@codemirror/state").Extension[];
|
|
91
|
-
phrases: Record<string, string>;
|
|
92
|
-
lang: import("@codemirror/language").LanguageSupport;
|
|
93
|
-
linter: import("@codemirror/lint").Diagnostic[];
|
|
94
|
-
}> | {
|
|
95
|
-
install: (app: any) => void;
|
|
96
|
-
};
|
|
97
|
-
export default _default;
|
|
98
|
-
//# sourceMappingURL=index.esm.d.ts.map
|
package/dist/index.esm.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.d.ts","sourceRoot":"","sources":["../src/index.esm.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,wBAoBK"}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import type { LanguageSupport } from '@codemirror/language';
|
|
2
|
-
import type { Extension } from '@codemirror/state';
|
|
3
|
-
import type { Diagnostic } from '@codemirror/lint';
|
|
4
|
-
import type { StyleSpec } from 'style-mod';
|
|
5
|
-
/** Prop Interface */
|
|
6
|
-
export default interface CodeMirrorPropsInterface {
|
|
7
|
-
/** Model value */
|
|
8
|
-
modelValue: string;
|
|
9
|
-
/**
|
|
10
|
-
* Theme
|
|
11
|
-
*
|
|
12
|
-
* @see {@link https://codemirror.net/6/examples/styling/ | Example: Styling}
|
|
13
|
-
*/
|
|
14
|
-
theme?: {
|
|
15
|
-
[selector: string]: StyleSpec;
|
|
16
|
-
};
|
|
17
|
-
/** Dark Mode */
|
|
18
|
-
dark?: boolean;
|
|
19
|
-
/**
|
|
20
|
-
* Readonly
|
|
21
|
-
*
|
|
22
|
-
* @see {@link https://codemirror.net/6/docs/ref/#state.EditorState%5EreadOnly | readOnly}
|
|
23
|
-
*/
|
|
24
|
-
readonly?: boolean;
|
|
25
|
-
/**
|
|
26
|
-
* Editable
|
|
27
|
-
*
|
|
28
|
-
* @see {@link https://codemirror.net/6/docs/ref/#view.EditorView%5Eeditable | editable}
|
|
29
|
-
*/
|
|
30
|
-
editable?: boolean;
|
|
31
|
-
/**
|
|
32
|
-
* Additional Extension
|
|
33
|
-
*
|
|
34
|
-
* @see {@link https://codemirror.net/6/docs/ref/#state.Extension | Extending Editor State}
|
|
35
|
-
*/
|
|
36
|
-
extensions?: Extension[];
|
|
37
|
-
/**
|
|
38
|
-
* Language Phreses
|
|
39
|
-
*
|
|
40
|
-
* @see {@link https://codemirror.net/6/examples/translate/ | Example: Internationalization}
|
|
41
|
-
*/
|
|
42
|
-
phrases?: Record<string, string>;
|
|
43
|
-
/**
|
|
44
|
-
* CodeMirror Language
|
|
45
|
-
*
|
|
46
|
-
* @see {@link https://codemirror.net/6/docs/ref/#language | @codemirror/language}
|
|
47
|
-
*/
|
|
48
|
-
lang?: LanguageSupport;
|
|
49
|
-
/**
|
|
50
|
-
* CodeMirror Linter
|
|
51
|
-
*
|
|
52
|
-
* @see {@link https://codemirror.net/6/docs/ref/#lint | @codemirror/lint}
|
|
53
|
-
*/
|
|
54
|
-
linter?: Diagnostic[];
|
|
55
|
-
}
|
|
56
|
-
//# sourceMappingURL=CodeMirrorPropsInterface.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CodeMirrorPropsInterface.d.ts","sourceRoot":"","sources":["../../src/interfaces/CodeMirrorPropsInterface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE3C,qBAAqB;AACrB,MAAM,CAAC,OAAO,WAAW,wBAAwB;IAC/C,kBAAkB;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,KAAK,CAAC,EAAE;QAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAA;KAAE,CAAC;IAC1C,gBAAgB;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;OAIG;IACH,UAAU,CAAC,EAAE,SAAS,EAAE,CAAC;IACzB;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC;;;;OAIG;IACH,IAAI,CAAC,EAAE,eAAe,CAAC;IACvB;;;;OAIG;IACH,MAAM,CAAC,EAAE,UAAU,EAAE,CAAC;CACvB"}
|