vue-codemirror6 0.1.6 → 0.1.7
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 +24 -20
- package/dist/components/CodeMirror.vue.d.ts +119 -23
- package/dist/components/CodeMirror.vue.d.ts.map +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/interfaces/CodeMirrorEmitsInterface.d.ts +1 -1
- package/dist/interfaces/CodeMirrorEmitsInterface.d.ts.map +1 -1
- package/dist/vue-codemirror6.es.js +8 -8
- package/dist/vue-codemirror6.umd.js +2 -2
- package/package.json +24 -27
- package/src/components/CodeMirror.vue +9 -6
package/README.md
CHANGED
|
@@ -19,13 +19,16 @@ When using with Vue2, [@vue/composition-api](https://www.npmjs.com/package/@vue/
|
|
|
19
19
|
|
|
20
20
|
| Props | Type | Information |
|
|
21
21
|
| ---------- | --------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
22
|
-
|
|
|
22
|
+
| basic | boolean | Use [basic-setup](https://codemirror.net/6/docs/ref/#basic-setup). |
|
|
23
|
+
| dark | boolean | Toggle Darkmode. It can be changed in real time, but the input value will return to the initial value. |
|
|
24
|
+
| wrap | boolean | Line text wrapping. see [lineWrapping](https://codemirror.net/6/docs/ref/#view.EditorView.lineWrapping). |
|
|
25
|
+
| tab | boolean | Enables tab indentation. |
|
|
23
26
|
| theme | { [selector: string]: StyleSpec } | Specify the theme. For example, if you use [@codemirror/theme-one-dark](https://github.com/codemirror/theme-one-dark), import `oneDark` and put it in this prop. |
|
|
24
27
|
| readonly | boolean | Makes the cursor visible or you can drag the text but not edit the value. |
|
|
25
28
|
| editable | boolean | When this is set to false, it is similar to `readonly`, except that the cursor is not displayed like the normal pre tag. |
|
|
26
29
|
| lang | LanguageSupport | The language you want to have syntax highlighting. see <https://codemirror.net/6/#languages> |
|
|
27
30
|
| phrases | Record<string, string> | Specify here if you want to make the displayed character string multilingual. see <https://codemirror.net/6/examples/translate/> |
|
|
28
|
-
| extensions | Extension[] | Includes enhancements to extend CodeMirror.
|
|
31
|
+
| extensions | Extension[] | Includes enhancements to extend CodeMirror. |
|
|
29
32
|
| linter | Diagnostic[] | Set Linter. see example <https://codesandbox.io/s/f6nb0?file=/src/index.js> |
|
|
30
33
|
|
|
31
34
|
Notice: `lang` and `linter` can also be set together in `extensions`. This is defined for usability compatibility with past CodeMirrors.
|
|
@@ -121,23 +124,22 @@ When using as a Markdown editor on [Vuetify](https://vuetifyjs.com/).
|
|
|
121
124
|
<template>
|
|
122
125
|
<code-mirror
|
|
123
126
|
v-model="value"
|
|
127
|
+
basic
|
|
128
|
+
:dark="dark"
|
|
124
129
|
:lang="lang"
|
|
125
130
|
:phrases="phreses"
|
|
126
|
-
:extensions="extensions"
|
|
127
|
-
:dark="$vuetify.theme.dark"
|
|
128
131
|
/>
|
|
129
132
|
</template>
|
|
130
133
|
|
|
131
134
|
<script lang="ts">
|
|
132
|
-
import { ref, type Ref
|
|
135
|
+
import { ref, defineComponent, type Ref } from 'vue';
|
|
133
136
|
|
|
134
137
|
// Load component
|
|
135
138
|
import CodeMirror from 'vue-codemirror6';
|
|
136
139
|
|
|
137
140
|
// CodeMirror extensions
|
|
138
141
|
import type { LanguageSupport } from '@codemirror/language';
|
|
139
|
-
import { markdown } from '@codemirror/lang-markdown';
|
|
140
|
-
import { basicSetup } from '@codemirror/basic-setup';
|
|
142
|
+
import { markdown as md } from '@codemirror/lang-markdown';
|
|
141
143
|
import type { Extension } from '@codemirror/state';
|
|
142
144
|
import type { ViewUpdate } from '@codemirror/view';
|
|
143
145
|
|
|
@@ -146,6 +148,12 @@ export default defineComponent({
|
|
|
146
148
|
CodeMirror,
|
|
147
149
|
},
|
|
148
150
|
setup() {
|
|
151
|
+
/**
|
|
152
|
+
* Get Vuetify instance
|
|
153
|
+
* @see {@link https://github.com/logue/vite-vue2-vuetify-ts-starter | vite-vue2-vuetify-ts-starter}
|
|
154
|
+
*/
|
|
155
|
+
const vuetify = useVuetify();
|
|
156
|
+
|
|
149
157
|
/** text */
|
|
150
158
|
const value: Ref<string> = ref('');
|
|
151
159
|
|
|
@@ -154,7 +162,13 @@ export default defineComponent({
|
|
|
154
162
|
*
|
|
155
163
|
* @see {@link https://codemirror.net/6/docs/ref/#language | @codemirror/language}
|
|
156
164
|
*/
|
|
157
|
-
const lang: Ref<LanguageSupport> = ref(
|
|
165
|
+
const lang: Ref<LanguageSupport> = ref(md());
|
|
166
|
+
|
|
167
|
+
/** Dark mode **/
|
|
168
|
+
const dark = ref(window.matchMedia('(prefers-color-scheme: dark)').matches);
|
|
169
|
+
|
|
170
|
+
/** When dark value changed, sync vuetify's dark mode */
|
|
171
|
+
watch(dark, v => (vuetify.theme.dark = v));
|
|
158
172
|
|
|
159
173
|
/**
|
|
160
174
|
* Internationalization Config.
|
|
@@ -193,21 +207,11 @@ export default defineComponent({
|
|
|
193
207
|
'No diagnostics': 'エラーなし',
|
|
194
208
|
});
|
|
195
209
|
|
|
196
|
-
/**
|
|
197
|
-
* CodeMirror Extensions
|
|
198
|
-
*
|
|
199
|
-
* @see {@link:https://codemirror.net/6/docs/ref/#state.Extension | Extending Editor State}
|
|
200
|
-
*/
|
|
201
|
-
const extensions: Ref<Extension[]> = ref([
|
|
202
|
-
/** @see {@link:https://codemirror.net/6/docs/ref/#basic-setup | basic-setup} */
|
|
203
|
-
basicSetup,
|
|
204
|
-
]);
|
|
205
|
-
|
|
206
210
|
return {
|
|
211
|
+
dark,
|
|
207
212
|
value,
|
|
208
213
|
lang,
|
|
209
214
|
phrases,
|
|
210
|
-
extensions,
|
|
211
215
|
};
|
|
212
216
|
},
|
|
213
217
|
});
|
|
@@ -231,8 +235,8 @@ const config: UserConfig = {
|
|
|
231
235
|
'vue-codemirror6',
|
|
232
236
|
'@codemirror/state',
|
|
233
237
|
'@codemirror/view',
|
|
234
|
-
// Add the following as needed.
|
|
235
238
|
'@codemirror/basic-setup',
|
|
239
|
+
// Add the following as needed.
|
|
236
240
|
'@codemirror/lang-html',
|
|
237
241
|
'@codemirror/lang-javascript',
|
|
238
242
|
'@codemirror/lang-markdown',
|
|
@@ -4,6 +4,7 @@ import type { Extension, Text } from '@codemirror/state';
|
|
|
4
4
|
import type { LanguageSupport } from '@codemirror/language';
|
|
5
5
|
import type { Diagnostic } from '@codemirror/lint';
|
|
6
6
|
import type { StyleSpec } from 'style-mod';
|
|
7
|
+
/** CodeMirror Component */
|
|
7
8
|
declare const _default: import("vue").ComponentOptions<import("vue").default, import("@vue/composition-api").ShallowUnwrapRef<{
|
|
8
9
|
context: SetupContext<{}>;
|
|
9
10
|
editor: Ref<Element | undefined>;
|
|
@@ -23,7 +24,7 @@ declare const _default: import("vue").ComponentOptions<import("vue").default, im
|
|
|
23
24
|
anchor: number;
|
|
24
25
|
head?: number | undefined;
|
|
25
26
|
}>;
|
|
26
|
-
default: undefined;
|
|
27
|
+
default: () => undefined;
|
|
27
28
|
};
|
|
28
29
|
/**
|
|
29
30
|
* Theme
|
|
@@ -93,7 +94,7 @@ declare const _default: import("vue").ComponentOptions<import("vue").default, im
|
|
|
93
94
|
*/
|
|
94
95
|
extensions: {
|
|
95
96
|
type: PropType<Extension[]>;
|
|
96
|
-
default:
|
|
97
|
+
default: () => never[];
|
|
97
98
|
};
|
|
98
99
|
/**
|
|
99
100
|
* Language Phreses
|
|
@@ -102,7 +103,7 @@ declare const _default: import("vue").ComponentOptions<import("vue").default, im
|
|
|
102
103
|
*/
|
|
103
104
|
phrases: {
|
|
104
105
|
type: PropType<Record<string, string>>;
|
|
105
|
-
default: undefined;
|
|
106
|
+
default: () => undefined;
|
|
106
107
|
};
|
|
107
108
|
/**
|
|
108
109
|
* CodeMirror Language
|
|
@@ -111,7 +112,7 @@ declare const _default: import("vue").ComponentOptions<import("vue").default, im
|
|
|
111
112
|
*/
|
|
112
113
|
lang: {
|
|
113
114
|
type: PropType<LanguageSupport>;
|
|
114
|
-
default: undefined;
|
|
115
|
+
default: () => undefined;
|
|
115
116
|
};
|
|
116
117
|
/**
|
|
117
118
|
* CodeMirror Linter
|
|
@@ -120,28 +121,124 @@ declare const _default: import("vue").ComponentOptions<import("vue").default, im
|
|
|
120
121
|
*/
|
|
121
122
|
linter: {
|
|
122
123
|
type: PropType<Diagnostic[]>;
|
|
123
|
-
default: undefined;
|
|
124
|
+
default: () => undefined;
|
|
124
125
|
};
|
|
125
|
-
}, {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
126
|
+
}, import("@vue/composition-api").ExtractPropTypes<{
|
|
127
|
+
/** Model value */
|
|
128
|
+
modelValue: {
|
|
129
|
+
type: PropType<string | Text>;
|
|
130
|
+
default: string;
|
|
130
131
|
};
|
|
132
|
+
/**
|
|
133
|
+
* Selection
|
|
134
|
+
*
|
|
135
|
+
* @see {@link https://codemirror.net/6/docs/ref/#state.EditorSelection | EditorSelection}
|
|
136
|
+
*/
|
|
137
|
+
selection: {
|
|
138
|
+
type: PropType<EditorSelection | {
|
|
139
|
+
anchor: number;
|
|
140
|
+
head?: number | undefined;
|
|
141
|
+
}>;
|
|
142
|
+
default: () => undefined;
|
|
143
|
+
};
|
|
144
|
+
/**
|
|
145
|
+
* Theme
|
|
146
|
+
*
|
|
147
|
+
* @see {@link https://codemirror.net/6/examples/styling/ | Example: Styling}
|
|
148
|
+
*/
|
|
131
149
|
theme: {
|
|
132
|
-
|
|
150
|
+
type: PropType<{
|
|
151
|
+
[selector: string]: StyleSpec;
|
|
152
|
+
}>;
|
|
153
|
+
default: () => {};
|
|
133
154
|
};
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
155
|
+
/** Dark Mode */
|
|
156
|
+
dark: {
|
|
157
|
+
type: BooleanConstructor;
|
|
158
|
+
default: boolean;
|
|
159
|
+
};
|
|
160
|
+
/**
|
|
161
|
+
* Use Basic Setup
|
|
162
|
+
*
|
|
163
|
+
* @see {@link https://codemirror.net/6/docs/ref/#basic-setup | basic-setup}
|
|
164
|
+
*/
|
|
165
|
+
basic: {
|
|
166
|
+
type: BooleanConstructor;
|
|
167
|
+
default: boolean;
|
|
168
|
+
};
|
|
169
|
+
/**
|
|
170
|
+
* Line wrapping
|
|
171
|
+
*
|
|
172
|
+
* @see {@link https://codemirror.net/6/docs/ref/#view.EditorView%5ElineWrapping | LineWrapping}
|
|
173
|
+
*/
|
|
174
|
+
wrap: {
|
|
175
|
+
type: BooleanConstructor;
|
|
176
|
+
default: boolean;
|
|
177
|
+
};
|
|
178
|
+
/**
|
|
179
|
+
* Tab handling
|
|
180
|
+
*
|
|
181
|
+
* @see {@link https://codemirror.net/6/examples/tab/ | Tab Handling}
|
|
182
|
+
*/
|
|
183
|
+
tab: {
|
|
184
|
+
type: BooleanConstructor;
|
|
185
|
+
default: boolean;
|
|
186
|
+
};
|
|
187
|
+
/**
|
|
188
|
+
* Readonly
|
|
189
|
+
*
|
|
190
|
+
* @see {@link https://codemirror.net/6/docs/ref/#state.EditorState%5EreadOnly | readOnly}
|
|
191
|
+
*/
|
|
192
|
+
readonly: {
|
|
193
|
+
type: BooleanConstructor;
|
|
194
|
+
default: boolean;
|
|
195
|
+
};
|
|
196
|
+
/**
|
|
197
|
+
* Editable
|
|
198
|
+
*
|
|
199
|
+
* @see {@link https://codemirror.net/6/docs/ref/#view.EditorView%5Eeditable | editable}
|
|
200
|
+
*/
|
|
201
|
+
editable: {
|
|
202
|
+
type: BooleanConstructor;
|
|
203
|
+
default: boolean;
|
|
204
|
+
};
|
|
205
|
+
/**
|
|
206
|
+
* Additional Extension
|
|
207
|
+
*
|
|
208
|
+
* @see {@link https://codemirror.net/6/docs/ref/#state.Extension | Extending Editor State}
|
|
209
|
+
*/
|
|
210
|
+
extensions: {
|
|
211
|
+
type: PropType<Extension[]>;
|
|
212
|
+
default: () => never[];
|
|
213
|
+
};
|
|
214
|
+
/**
|
|
215
|
+
* Language Phreses
|
|
216
|
+
*
|
|
217
|
+
* @see {@link https://codemirror.net/6/examples/translate/ | Example: Internationalization}
|
|
218
|
+
*/
|
|
219
|
+
phrases: {
|
|
220
|
+
type: PropType<Record<string, string>>;
|
|
221
|
+
default: () => undefined;
|
|
222
|
+
};
|
|
223
|
+
/**
|
|
224
|
+
* CodeMirror Language
|
|
225
|
+
*
|
|
226
|
+
* @see {@link https://codemirror.net/6/docs/ref/#language | @codemirror/language}
|
|
227
|
+
*/
|
|
228
|
+
lang: {
|
|
229
|
+
type: PropType<LanguageSupport>;
|
|
230
|
+
default: () => undefined;
|
|
231
|
+
};
|
|
232
|
+
/**
|
|
233
|
+
* CodeMirror Linter
|
|
234
|
+
*
|
|
235
|
+
* @see {@link https://codemirror.net/6/docs/ref/#lint | @codemirror/lint}
|
|
236
|
+
*/
|
|
237
|
+
linter: {
|
|
238
|
+
type: PropType<Diagnostic[]>;
|
|
239
|
+
default: () => undefined;
|
|
240
|
+
};
|
|
241
|
+
}>> & Omit<import("vue").VueConstructor<import("vue").default>, never> & (new (...args: any[]) => import("@vue/composition-api").ComponentRenderProxy<{
|
|
145
242
|
modelValue: string | Text;
|
|
146
243
|
selection: EditorSelection | {
|
|
147
244
|
anchor: number;
|
|
@@ -202,6 +299,5 @@ declare const _default: import("vue").ComponentOptions<import("vue").default, im
|
|
|
202
299
|
lang: LanguageSupport;
|
|
203
300
|
linter: Diagnostic[];
|
|
204
301
|
}, true>);
|
|
205
|
-
/** CodeMirror Component */
|
|
206
302
|
export default _default;
|
|
207
303
|
//# sourceMappingURL=CodeMirror.vue.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeMirror.vue.d.ts","sourceRoot":"","sources":["../../src/components/CodeMirror.vue.ts"],"names":[],"mappings":"AACA,OAAO,EAWL,KAAK,QAAQ,EACb,KAAK,GAAG,EACR,KAAK,YAAY,EAClB,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,eAAe,EAAe,MAAM,mBAAmB,CAAC;AASjE,OAAO,KAAK,EAAE,SAAS,EAAE,IAAI,EAAe,MAAM,mBAAmB,CAAC;AACtE,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;;;;;
|
|
1
|
+
{"version":3,"file":"CodeMirror.vue.d.ts","sourceRoot":"","sources":["../../src/components/CodeMirror.vue.ts"],"names":[],"mappings":"AACA,OAAO,EAWL,KAAK,QAAQ,EACb,KAAK,GAAG,EACR,KAAK,YAAY,EAClB,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,eAAe,EAAe,MAAM,mBAAmB,CAAC;AASjE,OAAO,KAAK,EAAE,SAAS,EAAE,IAAI,EAAe,MAAM,mBAAmB,CAAC;AACtE,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;AAE3C,2BAA2B;;;;;IAWvB,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;;;;;;IA9GH,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;;;;;;;;gBAlG6B,MAAM;;;;;;;;;;;;;;;;;;;;;;gBAAN,MAAM;;;;;;;;;;;;;;;;;;;gBAAN,MAAM;;;;;;;;;;;;;;;;;AAtB1C,wBAgQG"}
|
package/dist/index.d.ts
CHANGED
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
* @see {@link https://github.com/logue/vue-codemirror6}
|
|
8
8
|
*/
|
|
9
9
|
import CodeMirror from './components/CodeMirror.vue';
|
|
10
|
-
|
|
11
|
-
declare const installCodeMirror: void | ((app: App) => void);
|
|
10
|
+
declare const installCodeMirror: void | ((app: any) => any);
|
|
12
11
|
export { CodeMirror as default, installCodeMirror as install };
|
|
13
12
|
//# 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":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA;;;;;;;GAOG;AAEH,OAAO,UAAU,MAAM,6BAA6B,CAAC;AAGrD,QAAA,MAAM,iBAAiB,4BAEV,CAAC;AAEd,OAAO,EAAE,UAAU,IAAI,OAAO,EAAE,iBAAiB,IAAI,OAAO,EAAE,CAAC"}
|
|
@@ -2,7 +2,7 @@ import type { ViewUpdate } from '@codemirror/view';
|
|
|
2
2
|
/** Emit Interface */
|
|
3
3
|
export default interface CodeMirrorEmitsInterface {
|
|
4
4
|
/** Model Update */
|
|
5
|
-
(e: 'update:modelValue', value: string): void;
|
|
5
|
+
(e: 'update:modelValue', value: string | Text): void;
|
|
6
6
|
/** CodeMirror ViewUpdate */
|
|
7
7
|
(e: 'update', value: ViewUpdate): void;
|
|
8
8
|
}
|
|
@@ -1 +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;
|
|
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,GAAG,IAAI,CAAC;IACrD,4BAA4B;IAC5B,CAAC,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,GAAG,IAAI,CAAC;CACxC"}
|
|
@@ -17,7 +17,7 @@ var __vue2_script = defineComponent({
|
|
|
17
17
|
},
|
|
18
18
|
selection: {
|
|
19
19
|
type: Object,
|
|
20
|
-
default: void 0
|
|
20
|
+
default: () => void 0
|
|
21
21
|
},
|
|
22
22
|
theme: {
|
|
23
23
|
type: Object,
|
|
@@ -51,19 +51,21 @@ var __vue2_script = defineComponent({
|
|
|
51
51
|
},
|
|
52
52
|
extensions: {
|
|
53
53
|
type: Array,
|
|
54
|
-
default:
|
|
54
|
+
default: () => {
|
|
55
|
+
return [];
|
|
56
|
+
}
|
|
55
57
|
},
|
|
56
58
|
phrases: {
|
|
57
59
|
type: Object,
|
|
58
|
-
default: void 0
|
|
60
|
+
default: () => void 0
|
|
59
61
|
},
|
|
60
62
|
lang: {
|
|
61
63
|
type: Object,
|
|
62
|
-
default: void 0
|
|
64
|
+
default: () => void 0
|
|
63
65
|
},
|
|
64
66
|
linter: {
|
|
65
67
|
type: Array,
|
|
66
|
-
default: void 0
|
|
68
|
+
default: () => void 0
|
|
67
69
|
}
|
|
68
70
|
},
|
|
69
71
|
emits: ["update:modelValue", "update"],
|
|
@@ -224,7 +226,5 @@ var CodeMirror = /* @__PURE__ */ function() {
|
|
|
224
226
|
* @copyright 2022 Masashi Yoshikawa {@link https://logue.dev/} All rights reserved.
|
|
225
227
|
* @see {@link https://github.com/logue/vue-codemirror6}
|
|
226
228
|
*/
|
|
227
|
-
const installCodeMirror = isVue2 ? (app) =>
|
|
228
|
-
app.component("CodeMirror", CodeMirror);
|
|
229
|
-
} : install();
|
|
229
|
+
const installCodeMirror = isVue2 ? (app) => app.component("CodeMirror", CodeMirror) : install();
|
|
230
230
|
export { CodeMirror as default, installCodeMirror as install };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
(function(n,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("vue-demi"),require("@codemirror/state"),require("@codemirror/view"),require("@codemirror/basic-setup"),require("@codemirror/commands"),require("lodash")):typeof define=="function"&&define.amd?define(["exports","vue-demi","@codemirror/state","@codemirror/view","@codemirror/basic-setup","@codemirror/commands","lodash"],o):(n=typeof globalThis<"u"?globalThis:n||self,o(n.CodeMirror={},n.VueDemi,n.state,n.view,n.basicSetup,n.commands,n.lodash))})(this,function(n,o,m,c,C,S,_){"use strict";var w=o.defineComponent({name:"CodeMirror",model:{prop:"modelValue",event:"update:modelValue"},props:{modelValue:{type:String,default:""},selection:{type:Object,default:
|
|
1
|
+
(function(n,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("vue-demi"),require("@codemirror/state"),require("@codemirror/view"),require("@codemirror/basic-setup"),require("@codemirror/commands"),require("lodash")):typeof define=="function"&&define.amd?define(["exports","vue-demi","@codemirror/state","@codemirror/view","@codemirror/basic-setup","@codemirror/commands","lodash"],o):(n=typeof globalThis<"u"?globalThis:n||self,o(n.CodeMirror={},n.VueDemi,n.state,n.view,n.basicSetup,n.commands,n.lodash))})(this,function(n,o,m,c,C,S,_){"use strict";var w=o.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:Array,default:()=>{}}},emits:["update:modelValue","update"],setup(e,a){const d=o.ref(),s=o.ref(e.modelValue),{dark:u}=o.toRefs(e),v=a.emit,f=o.computed(()=>{const t=[e.basic?C.basicSetup:void 0,c.EditorView.updateListener.of(r=>v("update",r)),c.EditorView.theme(e.theme,{dark:u.value}),e.wrap?c.EditorView.lineWrapping:void 0,e.tab?c.keymap.of([S.indentWithTab]):void 0,e.phrases?m.EditorState.phrases.of(e.phrases):void 0,e.readonly?m.EditorState.readOnly.of(e.readonly):void 0,e.editable?c.EditorView.editable.of(e.editable):void 0,e.lang?o.toRaw(e.lang):void 0];return e.linter&&_.merge(t,e.linter),e.extensions&&_.merge(t,e.extensions),_.compact(t)});let i;return o.watch(s,t=>{if(i.composing)return;const r=i.state.selection;i.setState(m.EditorState.create({doc:t,extensions:f.value,selection:r}))}),o.watch(u,()=>{i.setState(m.EditorState.create({doc:s.value,extensions:f.value}))}),o.onMounted(async()=>{s.value==""&&d.value&&(s.value=_.trim(d.value.childNodes[0].innerText)),i=new c.EditorView({state:m.EditorState.create({doc:s.value,selection:e.selection,extensions:f.value}),parent:d.value,dispatch:t=>{i.update([t]),!t.changes.empty&&(s.value=i.state.doc.toString(),v("update:modelValue",s.value))}}),await o.nextTick()}),o.onUnmounted(()=>i.destroy()),{context:a,editor:d}}}),V=function(){var e=this,a=e.$createElement,d=e._self._c||a;return d("div",{ref:"editor",staticClass:"vue-codemirror"},[d("aside",{directives:[{name:"show",rawName:"v-show",value:!e.context.slots.default,expression:"!context.slots.default"}]},[e._t("default")],2)])},E=[];function T(e,a,d,s,u,v,f,i){var t=typeof e=="function"?e.options:e;a&&(t.render=a,t.staticRenderFns=d,t._compiled=!0),s&&(t.functional=!0),v&&(t._scopeId="data-v-"+v);var r;if(f?(r=function(l){l=l||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,!l&&typeof __VUE_SSR_CONTEXT__<"u"&&(l=__VUE_SSR_CONTEXT__),u&&u.call(this,l),l&&l._registeredComponents&&l._registeredComponents.add(f)},t._ssrRegister=r):u&&(r=i?function(){u.call(this,(t.functional?this.parent:this).$root.$options.shadowRoot)}:u),r)if(t.functional){t._injectStyles=r;var R=t.render;t.render=function($,b){return r.call(b),R($,b)}}else{var y=t.beforeCreate;t.beforeCreate=y?[].concat(y,r):[r]}return{exports:e,options:t}}const h={};var M=T(w,V,E,!1,g,null,null,null);function g(e){for(let a in h)this[a]=h[a]}var p=function(){return M.exports}();/**
|
|
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 O=o.isVue2?e=>
|
|
8
|
+
*/const O=o.isVue2?e=>e.component("CodeMirror",p):o.install();n.default=p,n.install=O,Object.defineProperties(n,{__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.1.
|
|
4
|
+
"version": "0.1.7",
|
|
5
5
|
"description": "CodeMirror6 Component for vue2",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"vuejs",
|
|
@@ -55,25 +55,24 @@
|
|
|
55
55
|
"sideEffects": false,
|
|
56
56
|
"scripts": {
|
|
57
57
|
"dev": "vite",
|
|
58
|
-
"clean": "rimraf node_modules/.vite",
|
|
58
|
+
"clean": "rimraf node_modules/.vite && npx vue-demi-fix",
|
|
59
59
|
"build": "vite build & vue-tsc --declaration --emitDeclarationOnly",
|
|
60
|
+
"build:analyze": "vue-tsc --noEmit && vite build --mode analyze",
|
|
60
61
|
"build:clean": "rimraf dist",
|
|
61
|
-
"lint": "eslint
|
|
62
|
+
"lint": "eslint --fix --cache --cache-location ./node_modules/.vite/vite-plugin-eslint && prettier . -w -u",
|
|
62
63
|
"lint:markup": "vue-tsc --noEmit",
|
|
63
|
-
"switch:2": "vue-demi-switch 2 & npx vue-demi-fix",
|
|
64
|
-
"switch:3": "vue-demi-switch 3 vue3 & npx vue-demi-fix",
|
|
65
64
|
"prepare": "husky install",
|
|
66
65
|
"postinstall": "npx vue-demi-fix"
|
|
67
66
|
},
|
|
68
67
|
"dependencies": {
|
|
69
|
-
"vue-demi": "
|
|
68
|
+
"vue-demi": ">=0.12.5"
|
|
70
69
|
},
|
|
71
70
|
"peerDependencies": {
|
|
72
|
-
"@codemirror/basic-setup": "
|
|
73
|
-
"@codemirror/state": "
|
|
74
|
-
"@codemirror/view": "
|
|
75
|
-
"@vue/composition-api": "
|
|
76
|
-
"vue": "^2.6.14 || ^3.2.
|
|
71
|
+
"@codemirror/basic-setup": ">=0.20",
|
|
72
|
+
"@codemirror/state": ">=0.20",
|
|
73
|
+
"@codemirror/view": ">=0.20",
|
|
74
|
+
"@vue/composition-api": "=>1.6.2",
|
|
75
|
+
"vue": "^2.6.14 || ^3.2.36"
|
|
77
76
|
},
|
|
78
77
|
"peerDependenciesMeta": {
|
|
79
78
|
"@vue/composition-api": {
|
|
@@ -82,42 +81,40 @@
|
|
|
82
81
|
},
|
|
83
82
|
"devDependencies": {
|
|
84
83
|
"@codemirror/basic-setup": "^0.20.0",
|
|
85
|
-
"@codemirror/lang-markdown": "^0.20.
|
|
86
|
-
"@codemirror/language": "^0.20.1",
|
|
87
|
-
"@codemirror/lint": "^0.20.2",
|
|
88
|
-
"@modyqyw/vite-plugin-eslint": "^1.3.2",
|
|
84
|
+
"@codemirror/lang-markdown": "^0.20.1",
|
|
89
85
|
"@types/lodash": "^4.14.182",
|
|
90
|
-
"@types/node": "^17.0.
|
|
91
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
92
|
-
"@typescript-eslint/parser": "^5.
|
|
93
|
-
"@vue/composition-api": "^1.6.
|
|
94
|
-
"@vue/eslint-config-
|
|
95
|
-
"eslint": "^8.
|
|
86
|
+
"@types/node": "^17.0.35",
|
|
87
|
+
"@typescript-eslint/eslint-plugin": "^5.26.0",
|
|
88
|
+
"@typescript-eslint/parser": "^5.26.0",
|
|
89
|
+
"@vue/composition-api": "^1.6.2",
|
|
90
|
+
"@vue/eslint-config-prettier": "^7.0.0",
|
|
91
|
+
"eslint": "^8.16.0",
|
|
96
92
|
"eslint-config-google": "^0.14.0",
|
|
97
93
|
"eslint-config-prettier": "^8.5.0",
|
|
98
94
|
"eslint-import-resolver-alias": "^1.1.2",
|
|
99
95
|
"eslint-import-resolver-typescript": "^2.7.1",
|
|
100
96
|
"eslint-plugin-import": "^2.26.0",
|
|
101
|
-
"eslint-plugin-
|
|
102
|
-
"eslint-plugin-prettier-vue": "^3.1.0",
|
|
97
|
+
"eslint-plugin-jsdoc": "^39.3.2",
|
|
103
98
|
"eslint-plugin-tsdoc": "^0.2.16",
|
|
104
99
|
"eslint-plugin-vue": "^9.0.1",
|
|
105
100
|
"eslint-plugin-vuejs-accessibility": "^1.1.1",
|
|
106
101
|
"husky": "^8.0.1",
|
|
107
|
-
"lint-staged": "^12.4.
|
|
102
|
+
"lint-staged": "^12.4.2",
|
|
108
103
|
"lodash": "^4.17.21",
|
|
109
104
|
"prettier": "^2.6.2",
|
|
110
105
|
"prettier-plugin-jsdoc": "^0.3.38",
|
|
111
106
|
"prettier-plugin-md-nocjsp": "^1.2.0",
|
|
112
|
-
"prettier-plugin-sort-imports": "^1.6.
|
|
107
|
+
"prettier-plugin-sort-imports": "^1.6.1",
|
|
113
108
|
"rimraf": "^3.0.2",
|
|
114
|
-
"
|
|
109
|
+
"rollup-plugin-visualizer": "^5.6.0",
|
|
110
|
+
"typescript": "^4.7.2",
|
|
115
111
|
"vite": "^2.9.9",
|
|
112
|
+
"vite-plugin-checker": "^0.4.6",
|
|
116
113
|
"vite-plugin-vue2": "^2.0.1",
|
|
117
114
|
"vue": "^2.6.14",
|
|
118
115
|
"vue-eslint-parser": "^9.0.2",
|
|
119
116
|
"vue-template-compiler": "^2.6.14",
|
|
120
|
-
"vue-tsc": "^0.34.
|
|
117
|
+
"vue-tsc": "^0.34.16"
|
|
121
118
|
},
|
|
122
119
|
"husky": {
|
|
123
120
|
"hooks": {
|
|
@@ -61,7 +61,7 @@ export default defineComponent({
|
|
|
61
61
|
type: Object as PropType<
|
|
62
62
|
EditorSelection | { anchor: number; head?: number }
|
|
63
63
|
>,
|
|
64
|
-
default: undefined,
|
|
64
|
+
default: () => undefined,
|
|
65
65
|
},
|
|
66
66
|
/**
|
|
67
67
|
* Theme
|
|
@@ -131,7 +131,9 @@ export default defineComponent({
|
|
|
131
131
|
*/
|
|
132
132
|
extensions: {
|
|
133
133
|
type: Array as PropType<Extension[]>,
|
|
134
|
-
default:
|
|
134
|
+
default: () => {
|
|
135
|
+
return [];
|
|
136
|
+
},
|
|
135
137
|
},
|
|
136
138
|
/**
|
|
137
139
|
* Language Phreses
|
|
@@ -140,7 +142,7 @@ export default defineComponent({
|
|
|
140
142
|
*/
|
|
141
143
|
phrases: {
|
|
142
144
|
type: Object as PropType<Record<string, string>>,
|
|
143
|
-
default: undefined,
|
|
145
|
+
default: () => undefined,
|
|
144
146
|
},
|
|
145
147
|
/**
|
|
146
148
|
* CodeMirror Language
|
|
@@ -149,7 +151,7 @@ export default defineComponent({
|
|
|
149
151
|
*/
|
|
150
152
|
lang: {
|
|
151
153
|
type: Object as PropType<LanguageSupport>,
|
|
152
|
-
default: undefined,
|
|
154
|
+
default: () => undefined,
|
|
153
155
|
},
|
|
154
156
|
/**
|
|
155
157
|
* CodeMirror Linter
|
|
@@ -158,13 +160,14 @@ export default defineComponent({
|
|
|
158
160
|
*/
|
|
159
161
|
linter: {
|
|
160
162
|
type: Array as PropType<Diagnostic[]>,
|
|
161
|
-
default: undefined,
|
|
163
|
+
default: () => undefined,
|
|
162
164
|
},
|
|
163
165
|
},
|
|
164
166
|
/** Emits */
|
|
165
167
|
emits: ['update:modelValue', 'update'],
|
|
166
168
|
/**
|
|
167
169
|
* Setup
|
|
170
|
+
*
|
|
168
171
|
* @param props - Props
|
|
169
172
|
* @param context - Context
|
|
170
173
|
*/
|
|
@@ -257,7 +260,7 @@ export default defineComponent({
|
|
|
257
260
|
|
|
258
261
|
/** When loaded */
|
|
259
262
|
onMounted(async () => {
|
|
260
|
-
|
|
263
|
+
// overwrite initial value
|
|
261
264
|
if (doc.value == '' && editor.value) {
|
|
262
265
|
doc.value = trim((editor.value.childNodes[0] as HTMLElement).innerText);
|
|
263
266
|
}
|