vue-codemirror6 0.1.0 → 0.3.0
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 +92 -94
- package/dist/components/CodeMirror.vue.d.ts +134 -33
- package/dist/components/CodeMirror.vue.d.ts.map +1 -1
- package/dist/index.d.ts +104 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.d.ts +96 -4
- package/dist/index.esm.d.ts.map +1 -1
- package/dist/interfaces/CodeMirrorEmitsInterface.d.ts +9 -0
- package/dist/interfaces/CodeMirrorEmitsInterface.d.ts.map +1 -0
- package/dist/interfaces/CodeMirrorPropsInterface.d.ts +56 -0
- package/dist/interfaces/CodeMirrorPropsInterface.d.ts.map +1 -0
- package/dist/vue-codemirror6.es.js +139 -177
- package/dist/vue-codemirror6.umd.js +8 -3
- package/package.json +33 -21
- package/src/components/CodeMirror.vue +220 -178
package/dist/index.esm.d.ts
CHANGED
|
@@ -1,6 +1,98 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
+
};
|
|
5
97
|
export default _default;
|
|
6
98
|
//# sourceMappingURL=index.esm.d.ts.map
|
package/dist/index.esm.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.d.ts","sourceRoot":"","sources":["../src/index.esm.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.esm.d.ts","sourceRoot":"","sources":["../src/index.esm.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,wBAoBK"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ViewUpdate } from '@codemirror/view';
|
|
2
|
+
/** Emit Interface */
|
|
3
|
+
export default interface CodeMirrorEmitsInterface {
|
|
4
|
+
/** Model Update */
|
|
5
|
+
(e: 'update:modelValue', value: string): void;
|
|
6
|
+
/** CodeMirror ViewUpdate */
|
|
7
|
+
(e: 'update', value: ViewUpdate): void;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=CodeMirrorEmitsInterface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CodeMirrorEmitsInterface.d.ts","sourceRoot":"","sources":["../../src/interfaces/CodeMirrorEmitsInterface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,qBAAqB;AACrB,MAAM,CAAC,OAAO,WAAW,wBAAwB;IAC/C,mBAAmB;IACnB,CAAC,CAAC,EAAE,mBAAmB,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9C,4BAA4B;IAC5B,CAAC,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,GAAG,IAAI,CAAC;CACxC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -1,196 +1,158 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defineComponent, ref, computed, watch, onMounted, onUnmounted, openBlock, createElementBlock, withDirectives, createElementVNode, renderSlot, vShow } from "vue";
|
|
2
2
|
import { EditorState } from "@codemirror/state";
|
|
3
3
|
import { EditorView } from "@codemirror/view";
|
|
4
|
-
import {
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
10
|
-
if (decorator = decorators[i])
|
|
11
|
-
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
12
|
-
if (kind && result)
|
|
13
|
-
__defProp(target, key, result);
|
|
14
|
-
return result;
|
|
15
|
-
};
|
|
16
|
-
let CodeMirror = class extends Vue {
|
|
17
|
-
onValueChanged() {
|
|
18
|
-
if (this.editor.composing) {
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
const previous = this.editor.state.selection;
|
|
22
|
-
this.editor.setState(EditorState.create({
|
|
23
|
-
doc: this.value,
|
|
24
|
-
extensions: this.extension,
|
|
25
|
-
selection: previous
|
|
26
|
-
}));
|
|
27
|
-
}
|
|
28
|
-
onToggleDarkMode() {
|
|
29
|
-
this.editor.setState(EditorState.create({
|
|
30
|
-
doc: this.value,
|
|
31
|
-
extensions: this.extension
|
|
32
|
-
}));
|
|
33
|
-
}
|
|
34
|
-
get extension() {
|
|
35
|
-
const ext = compact([
|
|
36
|
-
EditorView.updateListener.of((update) => this.$emit("update", update)),
|
|
37
|
-
EditorView.theme(this.theme, { dark: this.dark }),
|
|
38
|
-
this.phrases ? EditorState.phrases.of(this.phrases) : void 0,
|
|
39
|
-
this.lang ? this.lang : void 0,
|
|
40
|
-
EditorState.readOnly.of(this.readonly),
|
|
41
|
-
EditorView.editable.of(this.editable)
|
|
42
|
-
]);
|
|
43
|
-
if (this.linter.length !== 0) {
|
|
44
|
-
merge(ext, this.linter);
|
|
45
|
-
}
|
|
46
|
-
if (this.extensions.length !== 0) {
|
|
47
|
-
merge(ext, this.extensions);
|
|
48
|
-
}
|
|
49
|
-
console.debug("[CodeMirror.vue] Loaded extensions:", ext);
|
|
50
|
-
return ext;
|
|
51
|
-
}
|
|
52
|
-
mounted() {
|
|
53
|
-
let value = this.value;
|
|
54
|
-
if (!this.value && this.$slots.default !== void 0) {
|
|
55
|
-
value = this.getChildrenTextContent(this.$slots.default);
|
|
56
|
-
}
|
|
57
|
-
this.editor = new EditorView({
|
|
58
|
-
state: EditorState.create({
|
|
59
|
-
doc: value,
|
|
60
|
-
extensions: this.extension
|
|
61
|
-
}),
|
|
62
|
-
parent: this.$refs.editor,
|
|
63
|
-
dispatch: (tr) => {
|
|
64
|
-
this.editor.update([tr]);
|
|
65
|
-
if (tr.changes.empty)
|
|
66
|
-
return;
|
|
67
|
-
this.$emit("input", this.editor.state.doc.toString());
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
beforeDestroy() {
|
|
72
|
-
this.editor.destroy();
|
|
73
|
-
}
|
|
74
|
-
getChildrenTextContent(children) {
|
|
75
|
-
return children.map((node) => node.children ? this.getChildrenTextContent(node.children) : node.text || "\n").join("");
|
|
4
|
+
import { merge, compact } from "lodash";
|
|
5
|
+
var _export_sfc = (sfc, props) => {
|
|
6
|
+
const target = sfc.__vccOpts || sfc;
|
|
7
|
+
for (const [key, val] of props) {
|
|
8
|
+
target[key] = val;
|
|
76
9
|
}
|
|
10
|
+
return target;
|
|
77
11
|
};
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
if (
|
|
140
|
-
|
|
12
|
+
const _sfc_main = defineComponent({
|
|
13
|
+
name: "CodeMirror",
|
|
14
|
+
model: {
|
|
15
|
+
prop: "modelValue",
|
|
16
|
+
event: "update:modelValue"
|
|
17
|
+
},
|
|
18
|
+
props: {
|
|
19
|
+
modelValue: {
|
|
20
|
+
type: String,
|
|
21
|
+
default: ""
|
|
22
|
+
},
|
|
23
|
+
theme: {
|
|
24
|
+
type: Object,
|
|
25
|
+
default: void 0
|
|
26
|
+
},
|
|
27
|
+
dark: {
|
|
28
|
+
type: Boolean,
|
|
29
|
+
default: false
|
|
30
|
+
},
|
|
31
|
+
readonly: {
|
|
32
|
+
type: Boolean,
|
|
33
|
+
default: false
|
|
34
|
+
},
|
|
35
|
+
editable: {
|
|
36
|
+
type: Boolean,
|
|
37
|
+
default: true
|
|
38
|
+
},
|
|
39
|
+
extensions: {
|
|
40
|
+
type: Array,
|
|
41
|
+
default: void 0
|
|
42
|
+
},
|
|
43
|
+
phrases: {
|
|
44
|
+
type: Object,
|
|
45
|
+
default: void 0
|
|
46
|
+
},
|
|
47
|
+
lang: {
|
|
48
|
+
type: Object,
|
|
49
|
+
default: void 0
|
|
50
|
+
},
|
|
51
|
+
linter: {
|
|
52
|
+
type: Array,
|
|
53
|
+
default: void 0
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
emits: ["update:modelValue", "update"],
|
|
57
|
+
setup(props, context) {
|
|
58
|
+
const editor = ref();
|
|
59
|
+
const modelValue = ref(props.modelValue);
|
|
60
|
+
const dark = ref(props.dark);
|
|
61
|
+
const emit = context.emit;
|
|
62
|
+
const extensions = computed(() => {
|
|
63
|
+
const ext = [
|
|
64
|
+
EditorView.updateListener.of((update) => {
|
|
65
|
+
emit("update", update);
|
|
66
|
+
}),
|
|
67
|
+
EditorView.theme(props.theme || {}, { dark: props.dark }),
|
|
68
|
+
props.phrases ? EditorState.phrases.of(props.phrases) : void 0,
|
|
69
|
+
props.lang,
|
|
70
|
+
props.readonly ? EditorState.readOnly.of(props.readonly) : void 0,
|
|
71
|
+
props.editable ? EditorView.editable.of(props.editable) : void 0
|
|
72
|
+
];
|
|
73
|
+
if (props.linter) {
|
|
74
|
+
merge(ext, props.linter);
|
|
141
75
|
}
|
|
142
|
-
if (
|
|
143
|
-
|
|
76
|
+
if (props.extensions) {
|
|
77
|
+
merge(ext, props.extensions);
|
|
144
78
|
}
|
|
145
|
-
|
|
146
|
-
|
|
79
|
+
return compact(ext);
|
|
80
|
+
});
|
|
81
|
+
let view;
|
|
82
|
+
watch(modelValue, (current) => {
|
|
83
|
+
if (view.composing) {
|
|
84
|
+
return;
|
|
147
85
|
}
|
|
86
|
+
const previous = view.state.selection;
|
|
87
|
+
view.setState(EditorState.create({
|
|
88
|
+
doc: current,
|
|
89
|
+
extensions: extensions.value,
|
|
90
|
+
selection: previous
|
|
91
|
+
}));
|
|
92
|
+
});
|
|
93
|
+
watch(dark, () => {
|
|
94
|
+
view.setState(EditorState.create({
|
|
95
|
+
doc: modelValue.value,
|
|
96
|
+
extensions: extensions.value
|
|
97
|
+
}));
|
|
98
|
+
});
|
|
99
|
+
onMounted(() => {
|
|
100
|
+
const value = !modelValue.value && editor.value ? editor.value.childNodes[0].innerText : modelValue.value;
|
|
101
|
+
view = new EditorView({
|
|
102
|
+
state: EditorState.create({
|
|
103
|
+
doc: value,
|
|
104
|
+
extensions: extensions.value
|
|
105
|
+
}),
|
|
106
|
+
parent: editor.value,
|
|
107
|
+
dispatch: (tr) => {
|
|
108
|
+
view.update([tr]);
|
|
109
|
+
if (tr.changes.empty)
|
|
110
|
+
return;
|
|
111
|
+
modelValue.value = view.state.doc.toString();
|
|
112
|
+
emit("update:modelValue", modelValue.value);
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
onUnmounted(() => view.destroy());
|
|
117
|
+
return {
|
|
118
|
+
context,
|
|
119
|
+
editor
|
|
148
120
|
};
|
|
149
|
-
options._ssrRegister = hook;
|
|
150
|
-
} else if (injectStyles) {
|
|
151
|
-
hook = shadowMode ? function() {
|
|
152
|
-
injectStyles.call(this, (options.functional ? this.parent : this).$root.$options.shadowRoot);
|
|
153
|
-
} : injectStyles;
|
|
154
|
-
}
|
|
155
|
-
if (hook) {
|
|
156
|
-
if (options.functional) {
|
|
157
|
-
options._injectStyles = hook;
|
|
158
|
-
var originalRender = options.render;
|
|
159
|
-
options.render = function renderWithStyleInjection(h, context) {
|
|
160
|
-
hook.call(context);
|
|
161
|
-
return originalRender(h, context);
|
|
162
|
-
};
|
|
163
|
-
} else {
|
|
164
|
-
var existing = options.beforeCreate;
|
|
165
|
-
options.beforeCreate = existing ? [].concat(existing, hook) : [hook];
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
return {
|
|
169
|
-
exports: scriptExports,
|
|
170
|
-
options
|
|
171
|
-
};
|
|
172
|
-
}
|
|
173
|
-
const __cssModules = {};
|
|
174
|
-
var __component__ = /* @__PURE__ */ normalizeComponent(CodeMirror, render, staticRenderFns, false, __vue2_injectStyles, null, null, null);
|
|
175
|
-
function __vue2_injectStyles(context) {
|
|
176
|
-
for (let o in __cssModules) {
|
|
177
|
-
this[o] = __cssModules[o];
|
|
178
121
|
}
|
|
122
|
+
});
|
|
123
|
+
const _hoisted_1 = {
|
|
124
|
+
ref: "editor",
|
|
125
|
+
class: "vue-codemirror"
|
|
126
|
+
};
|
|
127
|
+
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
128
|
+
return openBlock(), createElementBlock("div", _hoisted_1, [
|
|
129
|
+
withDirectives(createElementVNode("div", null, [
|
|
130
|
+
renderSlot(_ctx.$slots, "default")
|
|
131
|
+
], 512), [
|
|
132
|
+
[vShow, _ctx.context.slots.defatlt]
|
|
133
|
+
])
|
|
134
|
+
], 512);
|
|
179
135
|
}
|
|
180
|
-
var component$1 = /* @__PURE__ */
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
Vue2.component("CodeMirror", installable);
|
|
136
|
+
var component$1 = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
|
|
137
|
+
var component = (() => {
|
|
138
|
+
return {
|
|
139
|
+
install: (app) => {
|
|
140
|
+
app.component("CodeMirror", component$1);
|
|
141
|
+
}
|
|
187
142
|
};
|
|
188
|
-
return installable;
|
|
189
143
|
})();
|
|
190
144
|
var namedExports = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
191
145
|
__proto__: null,
|
|
192
146
|
"default": component
|
|
193
147
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
148
|
+
/**
|
|
149
|
+
* Vue CodeMirror6 Component
|
|
150
|
+
*
|
|
151
|
+
* @license MIT
|
|
152
|
+
* @author Logue {@link logue@hotmail.co.jp}
|
|
153
|
+
* @copyright 2022 Masashi Yoshikawa {@link https://logue.dev/} All rights reserved.
|
|
154
|
+
* @see {@link https://github.com/logue/vue-codemirror6}
|
|
155
|
+
*/
|
|
194
156
|
Object.entries(namedExports).forEach(([exportName, exported]) => {
|
|
195
157
|
if (exportName !== "default")
|
|
196
158
|
component[exportName] = exported;
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
-
(function(
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
(function(t,o){typeof exports=="object"&&typeof module<"u"?module.exports=o(require("vue"),require("@codemirror/state"),require("@codemirror/view"),require("lodash")):typeof define=="function"&&define.amd?define(["vue","@codemirror/state","@codemirror/view","lodash"],o):(t=typeof globalThis<"u"?globalThis:t||self,t.CodeMirror=o(t.Vue,t.state,t.view,t.lodash))})(this,function(t,o,s,u){"use strict";var v=(e,a)=>{const n=e.__vccOpts||e;for(const[r,c]of a)n[r]=c;return n};const y=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,a){const n=t.ref(),r=t.ref(e.modelValue),c=t.ref(e.dark),m=a.emit,p=t.computed(()=>{const i=[s.EditorView.updateListener.of(l=>{m("update",l)}),s.EditorView.theme(e.theme||{},{dark:e.dark}),e.phrases?o.EditorState.phrases.of(e.phrases):void 0,e.lang,e.readonly?o.EditorState.readOnly.of(e.readonly):void 0,e.editable?s.EditorView.editable.of(e.editable):void 0];return e.linter&&u.merge(i,e.linter),e.extensions&&u.merge(i,e.extensions),u.compact(i)});let d;return t.watch(r,i=>{if(d.composing)return;const l=d.state.selection;d.setState(o.EditorState.create({doc:i,extensions:p.value,selection:l}))}),t.watch(c,()=>{d.setState(o.EditorState.create({doc:r.value,extensions:p.value}))}),t.onMounted(()=>{const i=!r.value&&n.value?n.value.childNodes[0].innerText:r.value;d=new s.EditorView({state:o.EditorState.create({doc:i,extensions:p.value}),parent:n.value,dispatch:l=>{d.update([l]),!l.changes.empty&&(r.value=d.state.doc.toString(),m("update:modelValue",r.value))}})}),t.onUnmounted(()=>d.destroy()),{context:a,editor:n}}}),h={ref:"editor",class:"vue-codemirror"};function _(e,a,n,r,c,m){return t.openBlock(),t.createElementBlock("div",h,[t.withDirectives(t.createElementVNode("div",null,[t.renderSlot(e.$slots,"default")],512),[[t.vShow,e.context.slots.defatlt]])],512)}var E=v(y,[["render",_]]),f=(()=>({install:e=>{e.component("CodeMirror",E)}}))(),S=Object.freeze(Object.defineProperty({__proto__:null,default:f},Symbol.toStringTag,{value:"Module"}));/**
|
|
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
|
+
*/return Object.entries(S).forEach(([e,a])=>{e!=="default"&&(f[e]=a)}),f});
|
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.
|
|
5
|
-
"description": "CodeMirror6 Component for
|
|
4
|
+
"version": "0.3.0",
|
|
5
|
+
"description": "CodeMirror6 Component for vue 2 / 3",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"vuejs",
|
|
8
8
|
"vue",
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"code-editor",
|
|
12
12
|
"text-editor",
|
|
13
13
|
"vue2",
|
|
14
|
+
"vue3",
|
|
14
15
|
"web-editor",
|
|
15
16
|
"vue-plugin",
|
|
16
17
|
"vue-component",
|
|
@@ -54,35 +55,46 @@
|
|
|
54
55
|
"sideEffects": false,
|
|
55
56
|
"scripts": {
|
|
56
57
|
"dev": "vite",
|
|
58
|
+
"clean": "rimraf node_modules/.vite",
|
|
57
59
|
"build": "vite build & vue-tsc",
|
|
58
60
|
"build:clean": "rimraf dist",
|
|
59
61
|
"lint": "eslint . --fix --cache --cache-location ./node_modules/.vite/vite-plugin-eslint && prettier . --write",
|
|
60
62
|
"lint:markup": "vue-tsc --noEmit",
|
|
61
|
-
"
|
|
63
|
+
"switch:2": "vue-demi-switch 2",
|
|
64
|
+
"switch:3": "vue-demi-switch 3",
|
|
65
|
+
"prepare": "husky install",
|
|
66
|
+
"postinstall": "npx vue-demi-fix"
|
|
62
67
|
},
|
|
63
68
|
"dependencies": {
|
|
69
|
+
"vue-demi": "latest"
|
|
70
|
+
},
|
|
71
|
+
"peerDependencies": {
|
|
72
|
+
"@vue/composition-api": "^1.4.9",
|
|
73
|
+
"vue": "^2.6.14 || ^3.2.31"
|
|
74
|
+
},
|
|
75
|
+
"peerDependenciesMeta": {
|
|
76
|
+
"@vue/composition-api": {
|
|
77
|
+
"optional": true
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
"devDependencies": {
|
|
64
81
|
"@codemirror/basic-setup": "^0.19.1",
|
|
65
82
|
"@codemirror/lang-markdown": "^0.19.6",
|
|
66
83
|
"@codemirror/language": "^0.19.8",
|
|
67
84
|
"@codemirror/lint": "^0.19.6",
|
|
68
85
|
"@codemirror/view": "^0.19.47",
|
|
69
|
-
"
|
|
70
|
-
"vue": "^2.6.14",
|
|
71
|
-
"vue-class-component": "^7.2.6",
|
|
72
|
-
"vue-property-decorator": "^9.1.2"
|
|
73
|
-
},
|
|
74
|
-
"devDependencies": {
|
|
86
|
+
"@modyqyw/vite-plugin-eslint": "^1.1.0",
|
|
75
87
|
"@types/lodash": "^4.14.180",
|
|
76
|
-
"@types/node": "^17.0.
|
|
77
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
78
|
-
"@typescript-eslint/parser": "^5.
|
|
79
|
-
"@
|
|
88
|
+
"@types/node": "^17.0.23",
|
|
89
|
+
"@typescript-eslint/eslint-plugin": "^5.17.0",
|
|
90
|
+
"@typescript-eslint/parser": "^5.17.0",
|
|
91
|
+
"@vitejs/plugin-vue": "^2.2.4",
|
|
80
92
|
"@vue/eslint-config-typescript": "^10.0.0",
|
|
81
|
-
"eslint": "^8.
|
|
93
|
+
"eslint": "^8.12.0",
|
|
82
94
|
"eslint-config-google": "^0.14.0",
|
|
83
95
|
"eslint-config-prettier": "^8.5.0",
|
|
84
96
|
"eslint-import-resolver-alias": "^1.1.2",
|
|
85
|
-
"eslint-import-resolver-typescript": "^2.
|
|
97
|
+
"eslint-import-resolver-typescript": "^2.7.0",
|
|
86
98
|
"eslint-plugin-import": "^2.25.4",
|
|
87
99
|
"eslint-plugin-prettier": "^4.0.0",
|
|
88
100
|
"eslint-plugin-prettier-vue": "^3.1.0",
|
|
@@ -91,19 +103,19 @@
|
|
|
91
103
|
"eslint-plugin-vuejs-accessibility": "^1.1.1",
|
|
92
104
|
"husky": "^7.0.4",
|
|
93
105
|
"lint-staged": "^12.3.7",
|
|
94
|
-
"
|
|
95
|
-
"prettier
|
|
106
|
+
"lodash": "^4.17.21",
|
|
107
|
+
"prettier": "^2.6.1",
|
|
108
|
+
"prettier-plugin-jsdoc": "^0.3.33",
|
|
96
109
|
"prettier-plugin-md-nocjsp": "^1.2.0",
|
|
97
110
|
"prettier-plugin-sort-imports": "^1.6.0",
|
|
98
111
|
"rimraf": "^3.0.2",
|
|
99
|
-
"typescript": "
|
|
112
|
+
"typescript": "^4.6.3",
|
|
100
113
|
"vite": "^2.8.6",
|
|
101
|
-
"vite-dts": "^1.0.4",
|
|
102
|
-
"vite-plugin-eslint": "^1.3.0",
|
|
103
114
|
"vite-plugin-vue2": "^1.9.3",
|
|
115
|
+
"vue": "^3.2.31",
|
|
104
116
|
"vue-eslint-parser": "^8.3.0",
|
|
105
117
|
"vue-template-compiler": "^2.6.14",
|
|
106
|
-
"vue-tsc": "^0.33.
|
|
118
|
+
"vue-tsc": "^0.33.9"
|
|
107
119
|
},
|
|
108
120
|
"husky": {
|
|
109
121
|
"hooks": {
|