vue-codemirror6 0.3.0 → 0.3.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 +5 -10
- package/dist/components/CodeMirror.vue.d.ts +4 -4
- package/dist/components/CodeMirror.vue.d.ts.map +1 -1
- package/dist/index.d.ts +4 -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 +13 -15
- package/src/components/CodeMirror.vue +11 -16
- package/dist/index.esm.d.ts +0 -98
- package/dist/index.esm.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
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.
|
|
@@ -11,6 +11,7 @@ A component for using [CodeMirror6](https://codemirror.net/6/) with Vue. Unrelat
|
|
|
11
11
|
## Usage
|
|
12
12
|
|
|
13
13
|
This component can handle bidirectional binding by `v-model` like a general Vue component.
|
|
14
|
+
When using with Vue2, [@vue/composition-api](https://www.npmjs.com/package/@vue/composition-api) is required separately.
|
|
14
15
|
|
|
15
16
|
### Props
|
|
16
17
|
|
|
@@ -59,21 +60,15 @@ Mark up as follows to make it work at a minimum.
|
|
|
59
60
|
<script>
|
|
60
61
|
import { ref, defineComponent } from 'vue';
|
|
61
62
|
|
|
62
|
-
import CodeMirror from '
|
|
63
|
+
import CodeMirror from 'vue-codeMirror6';
|
|
63
64
|
|
|
64
65
|
export default defineComponent({
|
|
65
66
|
components: {
|
|
66
67
|
CodeMirror,
|
|
67
68
|
},
|
|
68
69
|
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
|
-
);
|
|
70
|
+
const value = ref('Cozy lummox gives smart squid who asks for job pen.');
|
|
71
|
+
|
|
77
72
|
return { value };
|
|
78
73
|
},
|
|
79
74
|
});
|
|
@@ -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;
|
|
@@ -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;AAKzE,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,8 @@
|
|
|
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
|
-
default: string;
|
|
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 };
|
|
107
13
|
//# 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"}
|
|
@@ -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, 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 h=(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),v=u.emit,p=t.computed(()=>{const a=[f.EditorView.updateListener.of(l=>{v("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:p.value,selection:l}))}),t.watch(c,()=>{n.setState(s.EditorState.create({doc:r.value,extensions:p.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:p.value}),parent:d.value,dispatch:l=>{n.update([l]),!l.changes.empty&&(r.value=n.state.doc.toString(),v("update:modelValue",r.value))}})}),t.onUnmounted(()=>n.destroy()),{context:u,editor:d}}}),S={ref:"editor",class:"vue-codemirror"};function _(e,u,d,r,c,v){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 y=h(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",y)};o.CodeMirror=y,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.1",
|
|
5
|
+
"description": "CodeMirror6 Component for vue3",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"vuejs",
|
|
8
8
|
"vue",
|
|
@@ -59,9 +59,8 @@
|
|
|
59
59
|
"build": "vite build & vue-tsc",
|
|
60
60
|
"build:clean": "rimraf dist",
|
|
61
61
|
"lint": "eslint . --fix --cache --cache-location ./node_modules/.vite/vite-plugin-eslint && prettier . --write",
|
|
62
|
-
"
|
|
63
|
-
"switch:
|
|
64
|
-
"switch:3": "vue-demi-switch 3",
|
|
62
|
+
"switch:2": "vue-demi-switch 2 & npx vue-demi-fix & rimraf node_modules/.vite",
|
|
63
|
+
"switch:3": "vue-demi-switch 3 & npx vue-demi-fix & rimraf node_modules/.vite",
|
|
65
64
|
"prepare": "husky install",
|
|
66
65
|
"postinstall": "npx vue-demi-fix"
|
|
67
66
|
},
|
|
@@ -78,17 +77,17 @@
|
|
|
78
77
|
}
|
|
79
78
|
},
|
|
80
79
|
"devDependencies": {
|
|
81
|
-
"@codemirror/basic-setup": "^0.19.
|
|
80
|
+
"@codemirror/basic-setup": "^0.19.3",
|
|
82
81
|
"@codemirror/lang-markdown": "^0.19.6",
|
|
83
|
-
"@codemirror/language": "^0.19.
|
|
82
|
+
"@codemirror/language": "^0.19.10",
|
|
84
83
|
"@codemirror/lint": "^0.19.6",
|
|
85
|
-
"@codemirror/view": "^0.19.
|
|
86
|
-
"@modyqyw/vite-plugin-eslint": "^1.
|
|
87
|
-
"@types/lodash": "^4.14.
|
|
84
|
+
"@codemirror/view": "^0.19.48",
|
|
85
|
+
"@modyqyw/vite-plugin-eslint": "^1.2.0",
|
|
86
|
+
"@types/lodash": "^4.14.181",
|
|
88
87
|
"@types/node": "^17.0.23",
|
|
89
88
|
"@typescript-eslint/eslint-plugin": "^5.17.0",
|
|
90
89
|
"@typescript-eslint/parser": "^5.17.0",
|
|
91
|
-
"@vitejs/plugin-vue": "^2.
|
|
90
|
+
"@vitejs/plugin-vue": "^2.3.1",
|
|
92
91
|
"@vue/eslint-config-typescript": "^10.0.0",
|
|
93
92
|
"eslint": "^8.12.0",
|
|
94
93
|
"eslint-config-google": "^0.14.0",
|
|
@@ -104,14 +103,13 @@
|
|
|
104
103
|
"husky": "^7.0.4",
|
|
105
104
|
"lint-staged": "^12.3.7",
|
|
106
105
|
"lodash": "^4.17.21",
|
|
107
|
-
"prettier": "^2.6.
|
|
108
|
-
"prettier-plugin-jsdoc": "^0.3.
|
|
106
|
+
"prettier": "^2.6.2",
|
|
107
|
+
"prettier-plugin-jsdoc": "^0.3.36",
|
|
109
108
|
"prettier-plugin-md-nocjsp": "^1.2.0",
|
|
110
109
|
"prettier-plugin-sort-imports": "^1.6.0",
|
|
111
110
|
"rimraf": "^3.0.2",
|
|
112
111
|
"typescript": "^4.6.3",
|
|
113
|
-
"vite": "^2.
|
|
114
|
-
"vite-plugin-vue2": "^1.9.3",
|
|
112
|
+
"vite": "^2.9.1",
|
|
115
113
|
"vue": "^3.2.31",
|
|
116
114
|
"vue-eslint-parser": "^8.3.0",
|
|
117
115
|
"vue-template-compiler": "^2.6.14",
|
|
@@ -1,37 +1,32 @@
|
|
|
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
22
|
import type CodeMirrorPropsInterface from '@/interfaces/CodeMirrorPropsInterface';
|
|
23
23
|
import type CodeMirrorEmitsInterface from '@/interfaces/CodeMirrorEmitsInterface';
|
|
24
24
|
|
|
25
|
-
import {
|
|
26
|
-
EditorState,
|
|
27
|
-
type Extension,
|
|
28
|
-
type Transaction,
|
|
29
|
-
} from '@codemirror/state';
|
|
30
|
-
import { EditorView, type ViewUpdate } from '@codemirror/view';
|
|
25
|
+
import type { Extension, Transaction } from '@codemirror/state';
|
|
31
26
|
import type { LanguageSupport } from '@codemirror/language';
|
|
27
|
+
import type { ViewUpdate } from '@codemirror/view';
|
|
32
28
|
import type { Diagnostic } from '@codemirror/lint';
|
|
33
29
|
import type { StyleSpec } from 'style-mod';
|
|
34
|
-
import { compact, merge } from 'lodash';
|
|
35
30
|
|
|
36
31
|
/** CodeMirror Component */
|
|
37
32
|
export default defineComponent({
|
|
@@ -125,7 +120,7 @@ export default defineComponent({
|
|
|
125
120
|
* @param props - Props
|
|
126
121
|
* @param context - Context
|
|
127
122
|
*/
|
|
128
|
-
setup(props: CodeMirrorPropsInterface, context: SetupContext
|
|
123
|
+
setup(props: CodeMirrorPropsInterface, context: SetupContext) {
|
|
129
124
|
/** Editor DOM */
|
|
130
125
|
const editor: Ref<Element | undefined> = ref<Element>();
|
|
131
126
|
|
|
@@ -147,7 +142,7 @@ export default defineComponent({
|
|
|
147
142
|
emit('update', update);
|
|
148
143
|
}),
|
|
149
144
|
// Toggle light/dark mode.
|
|
150
|
-
EditorView.theme(props.theme || {}, { dark:
|
|
145
|
+
EditorView.theme(props.theme || {}, { dark: dark.value }),
|
|
151
146
|
// locale settings
|
|
152
147
|
props.phrases ? EditorState.phrases.of(props.phrases) : undefined,
|
|
153
148
|
// Parser language setting
|
|
@@ -209,7 +204,7 @@ export default defineComponent({
|
|
|
209
204
|
|
|
210
205
|
/** When loaded */
|
|
211
206
|
onMounted(() => {
|
|
212
|
-
/** Value */
|
|
207
|
+
/** Initial Value */
|
|
213
208
|
const value =
|
|
214
209
|
!modelValue.value && editor.value
|
|
215
210
|
? (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"}
|