vue-codemirror6 0.3.6 → 0.3.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 +21 -20
- package/dist/components/CodeMirror.vue.d.ts +12 -148
- 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 +21 -32
- package/src/components/CodeMirror.vue +9 -6
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ When using with Vue2, [@vue/composition-api](https://www.npmjs.com/package/@vue/
|
|
|
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.
|
|
23
|
+
| dark | boolean | Toggle Darkmode. It can be changed in real time, but the input value will return to the initial value. |
|
|
24
24
|
| wrap | boolean | Line text wrapping. see [lineWrapping](https://codemirror.net/6/docs/ref/#view.EditorView.lineWrapping). |
|
|
25
25
|
| tab | boolean | Enables tab indentation. |
|
|
26
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. |
|
|
@@ -28,7 +28,7 @@ When using with Vue2, [@vue/composition-api](https://www.npmjs.com/package/@vue/
|
|
|
28
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. |
|
|
29
29
|
| lang | LanguageSupport | The language you want to have syntax highlighting. see <https://codemirror.net/6/#languages> |
|
|
30
30
|
| phrases | Record<string, string> | Specify here if you want to make the displayed character string multilingual. see <https://codemirror.net/6/examples/translate/> |
|
|
31
|
-
| extensions | Extension[] | Includes enhancements to extend CodeMirror.
|
|
31
|
+
| extensions | Extension[] | Includes enhancements to extend CodeMirror. |
|
|
32
32
|
| linter | Diagnostic[] | Set Linter. see example <https://codesandbox.io/s/f6nb0?file=/src/index.js> |
|
|
33
33
|
|
|
34
34
|
Notice: `lang` and `linter` can also be set together in `extensions`. This is defined for usability compatibility with past CodeMirrors.
|
|
@@ -124,23 +124,22 @@ When using as a Markdown editor on [Vuetify](https://vuetifyjs.com/).
|
|
|
124
124
|
<template>
|
|
125
125
|
<code-mirror
|
|
126
126
|
v-model="value"
|
|
127
|
+
basic
|
|
128
|
+
:dark="dark"
|
|
127
129
|
:lang="lang"
|
|
128
130
|
:phrases="phreses"
|
|
129
|
-
:extensions="extensions"
|
|
130
|
-
:dark="$vuetify.theme.dark"
|
|
131
131
|
/>
|
|
132
132
|
</template>
|
|
133
133
|
|
|
134
134
|
<script lang="ts">
|
|
135
|
-
import { ref, type Ref
|
|
135
|
+
import { ref, defineComponent, type Ref } from 'vue';
|
|
136
136
|
|
|
137
137
|
// Load component
|
|
138
138
|
import CodeMirror from 'vue-codemirror6';
|
|
139
139
|
|
|
140
140
|
// CodeMirror extensions
|
|
141
141
|
import type { LanguageSupport } from '@codemirror/language';
|
|
142
|
-
import { markdown } from '@codemirror/lang-markdown';
|
|
143
|
-
import { basicSetup } from '@codemirror/basic-setup';
|
|
142
|
+
import { markdown as md } from '@codemirror/lang-markdown';
|
|
144
143
|
import type { Extension } from '@codemirror/state';
|
|
145
144
|
import type { ViewUpdate } from '@codemirror/view';
|
|
146
145
|
|
|
@@ -149,6 +148,12 @@ export default defineComponent({
|
|
|
149
148
|
CodeMirror,
|
|
150
149
|
},
|
|
151
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
|
+
|
|
152
157
|
/** text */
|
|
153
158
|
const value: Ref<string> = ref('');
|
|
154
159
|
|
|
@@ -157,7 +162,13 @@ export default defineComponent({
|
|
|
157
162
|
*
|
|
158
163
|
* @see {@link https://codemirror.net/6/docs/ref/#language | @codemirror/language}
|
|
159
164
|
*/
|
|
160
|
-
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));
|
|
161
172
|
|
|
162
173
|
/**
|
|
163
174
|
* Internationalization Config.
|
|
@@ -196,21 +207,11 @@ export default defineComponent({
|
|
|
196
207
|
'No diagnostics': 'エラーなし',
|
|
197
208
|
});
|
|
198
209
|
|
|
199
|
-
/**
|
|
200
|
-
* CodeMirror Extensions
|
|
201
|
-
*
|
|
202
|
-
* @see {@link:https://codemirror.net/6/docs/ref/#state.Extension | Extending Editor State}
|
|
203
|
-
*/
|
|
204
|
-
const extensions: Ref<Extension[]> = ref([
|
|
205
|
-
/** @see {@link:https://codemirror.net/6/docs/ref/#basic-setup | basic-setup} */
|
|
206
|
-
basicSetup,
|
|
207
|
-
]);
|
|
208
|
-
|
|
209
210
|
return {
|
|
211
|
+
dark,
|
|
210
212
|
value,
|
|
211
213
|
lang,
|
|
212
214
|
phrases,
|
|
213
|
-
extensions,
|
|
214
215
|
};
|
|
215
216
|
},
|
|
216
217
|
});
|
|
@@ -234,8 +235,8 @@ const config: UserConfig = {
|
|
|
234
235
|
'vue-codemirror6',
|
|
235
236
|
'@codemirror/state',
|
|
236
237
|
'@codemirror/view',
|
|
237
|
-
// Add the following as needed.
|
|
238
238
|
'@codemirror/basic-setup',
|
|
239
|
+
// Add the following as needed.
|
|
239
240
|
'@codemirror/lang-html',
|
|
240
241
|
'@codemirror/lang-javascript',
|
|
241
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-demi").DefineComponent<{
|
|
8
9
|
/** Model value */
|
|
9
10
|
modelValue: {
|
|
@@ -20,7 +21,7 @@ declare const _default: import("vue-demi").DefineComponent<{
|
|
|
20
21
|
anchor: number;
|
|
21
22
|
head?: number | undefined;
|
|
22
23
|
}>;
|
|
23
|
-
default: undefined;
|
|
24
|
+
default: () => undefined;
|
|
24
25
|
};
|
|
25
26
|
/**
|
|
26
27
|
* Theme
|
|
@@ -90,7 +91,7 @@ declare const _default: import("vue-demi").DefineComponent<{
|
|
|
90
91
|
*/
|
|
91
92
|
extensions: {
|
|
92
93
|
type: PropType<Extension[]>;
|
|
93
|
-
default:
|
|
94
|
+
default: () => never[];
|
|
94
95
|
};
|
|
95
96
|
/**
|
|
96
97
|
* Language Phreses
|
|
@@ -99,7 +100,7 @@ declare const _default: import("vue-demi").DefineComponent<{
|
|
|
99
100
|
*/
|
|
100
101
|
phrases: {
|
|
101
102
|
type: PropType<Record<string, string>>;
|
|
102
|
-
default: undefined;
|
|
103
|
+
default: () => undefined;
|
|
103
104
|
};
|
|
104
105
|
/**
|
|
105
106
|
* CodeMirror Language
|
|
@@ -108,7 +109,7 @@ declare const _default: import("vue-demi").DefineComponent<{
|
|
|
108
109
|
*/
|
|
109
110
|
lang: {
|
|
110
111
|
type: PropType<LanguageSupport>;
|
|
111
|
-
default: undefined;
|
|
112
|
+
default: () => undefined;
|
|
112
113
|
};
|
|
113
114
|
/**
|
|
114
115
|
* CodeMirror Linter
|
|
@@ -117,148 +118,12 @@ declare const _default: import("vue-demi").DefineComponent<{
|
|
|
117
118
|
*/
|
|
118
119
|
linter: {
|
|
119
120
|
type: PropType<Diagnostic[]>;
|
|
120
|
-
default: undefined;
|
|
121
|
+
default: () => undefined;
|
|
121
122
|
};
|
|
122
123
|
}, {
|
|
123
124
|
context: SetupContext<import("vue-demi").EmitsOptions>;
|
|
124
125
|
editor: Ref<Element | undefined>;
|
|
125
|
-
}, unknown, {}, {}, import("vue-demi").ComponentOptionsMixin, import("vue-demi").ComponentOptionsMixin, import("vue-demi").EmitsOptions, "update:modelValue" | "update", import("vue-demi").
|
|
126
|
-
/** Component Name */
|
|
127
|
-
name: string;
|
|
128
|
-
/** Model Definition */
|
|
129
|
-
model: {
|
|
130
|
-
prop: string;
|
|
131
|
-
event: string;
|
|
132
|
-
};
|
|
133
|
-
/** Props Definition */
|
|
134
|
-
props: {
|
|
135
|
-
/** Model value */
|
|
136
|
-
modelValue: {
|
|
137
|
-
type: PropType<string | Text>;
|
|
138
|
-
default: string;
|
|
139
|
-
};
|
|
140
|
-
/**
|
|
141
|
-
* Selection
|
|
142
|
-
*
|
|
143
|
-
* @see {@link https://codemirror.net/6/docs/ref/#state.EditorSelection | EditorSelection}
|
|
144
|
-
*/
|
|
145
|
-
selection: {
|
|
146
|
-
type: PropType<EditorSelection | {
|
|
147
|
-
anchor: number;
|
|
148
|
-
head?: number | undefined;
|
|
149
|
-
}>;
|
|
150
|
-
default: undefined;
|
|
151
|
-
};
|
|
152
|
-
/**
|
|
153
|
-
* Theme
|
|
154
|
-
*
|
|
155
|
-
* @see {@link https://codemirror.net/6/examples/styling/ | Example: Styling}
|
|
156
|
-
*/
|
|
157
|
-
theme: {
|
|
158
|
-
type: PropType<{
|
|
159
|
-
[selector: string]: StyleSpec;
|
|
160
|
-
}>;
|
|
161
|
-
default: () => {};
|
|
162
|
-
};
|
|
163
|
-
/** Dark Mode */
|
|
164
|
-
dark: {
|
|
165
|
-
type: BooleanConstructor;
|
|
166
|
-
default: boolean;
|
|
167
|
-
};
|
|
168
|
-
/**
|
|
169
|
-
* Use Basic Setup
|
|
170
|
-
*
|
|
171
|
-
* @see {@link https://codemirror.net/6/docs/ref/#basic-setup | basic-setup}
|
|
172
|
-
*/
|
|
173
|
-
basic: {
|
|
174
|
-
type: BooleanConstructor;
|
|
175
|
-
default: boolean;
|
|
176
|
-
};
|
|
177
|
-
/**
|
|
178
|
-
* Line wrapping
|
|
179
|
-
*
|
|
180
|
-
* @see {@link https://codemirror.net/6/docs/ref/#view.EditorView%5ElineWrapping | LineWrapping}
|
|
181
|
-
*/
|
|
182
|
-
wrap: {
|
|
183
|
-
type: BooleanConstructor;
|
|
184
|
-
default: boolean;
|
|
185
|
-
};
|
|
186
|
-
/**
|
|
187
|
-
* Tab handling
|
|
188
|
-
*
|
|
189
|
-
* @see {@link https://codemirror.net/6/examples/tab/ | Tab Handling}
|
|
190
|
-
*/
|
|
191
|
-
tab: {
|
|
192
|
-
type: BooleanConstructor;
|
|
193
|
-
default: boolean;
|
|
194
|
-
};
|
|
195
|
-
/**
|
|
196
|
-
* Readonly
|
|
197
|
-
*
|
|
198
|
-
* @see {@link https://codemirror.net/6/docs/ref/#state.EditorState%5EreadOnly | readOnly}
|
|
199
|
-
*/
|
|
200
|
-
readonly: {
|
|
201
|
-
type: BooleanConstructor;
|
|
202
|
-
default: boolean;
|
|
203
|
-
};
|
|
204
|
-
/**
|
|
205
|
-
* Editable
|
|
206
|
-
*
|
|
207
|
-
* @see {@link https://codemirror.net/6/docs/ref/#view.EditorView%5Eeditable | editable}
|
|
208
|
-
*/
|
|
209
|
-
editable: {
|
|
210
|
-
type: BooleanConstructor;
|
|
211
|
-
default: boolean;
|
|
212
|
-
};
|
|
213
|
-
/**
|
|
214
|
-
* Additional Extension
|
|
215
|
-
*
|
|
216
|
-
* @see {@link https://codemirror.net/6/docs/ref/#state.Extension | Extending Editor State}
|
|
217
|
-
*/
|
|
218
|
-
extensions: {
|
|
219
|
-
type: PropType<Extension[]>;
|
|
220
|
-
default: undefined;
|
|
221
|
-
};
|
|
222
|
-
/**
|
|
223
|
-
* Language Phreses
|
|
224
|
-
*
|
|
225
|
-
* @see {@link https://codemirror.net/6/examples/translate/ | Example: Internationalization}
|
|
226
|
-
*/
|
|
227
|
-
phrases: {
|
|
228
|
-
type: PropType<Record<string, string>>;
|
|
229
|
-
default: undefined;
|
|
230
|
-
};
|
|
231
|
-
/**
|
|
232
|
-
* CodeMirror Language
|
|
233
|
-
*
|
|
234
|
-
* @see {@link https://codemirror.net/6/docs/ref/#language | @codemirror/language}
|
|
235
|
-
*/
|
|
236
|
-
lang: {
|
|
237
|
-
type: PropType<LanguageSupport>;
|
|
238
|
-
default: undefined;
|
|
239
|
-
};
|
|
240
|
-
/**
|
|
241
|
-
* CodeMirror Linter
|
|
242
|
-
*
|
|
243
|
-
* @see {@link https://codemirror.net/6/docs/ref/#lint | @codemirror/lint}
|
|
244
|
-
*/
|
|
245
|
-
linter: {
|
|
246
|
-
type: PropType<Diagnostic[]>;
|
|
247
|
-
default: undefined;
|
|
248
|
-
};
|
|
249
|
-
};
|
|
250
|
-
/** Emits */
|
|
251
|
-
emits: ("update:modelValue" | "update")[];
|
|
252
|
-
/**
|
|
253
|
-
* Setup
|
|
254
|
-
* @param props - Props
|
|
255
|
-
* @param context - Context
|
|
256
|
-
*/
|
|
257
|
-
setup(props: any, context: SetupContext): {
|
|
258
|
-
context: SetupContext<import("vue-demi").EmitsOptions>;
|
|
259
|
-
editor: Ref<Element | undefined>;
|
|
260
|
-
};
|
|
261
|
-
}, import("vue-demi").VNodeProps & import("vue-demi").AllowedComponentProps & import("vue-demi").ComponentCustomProps, Readonly<import("vue-demi").ExtractPropTypes<{
|
|
126
|
+
}, 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<{
|
|
262
127
|
/** Model value */
|
|
263
128
|
modelValue: {
|
|
264
129
|
type: PropType<string | Text>;
|
|
@@ -274,7 +139,7 @@ declare const _default: import("vue-demi").DefineComponent<{
|
|
|
274
139
|
anchor: number;
|
|
275
140
|
head?: number | undefined;
|
|
276
141
|
}>;
|
|
277
|
-
default: undefined;
|
|
142
|
+
default: () => undefined;
|
|
278
143
|
};
|
|
279
144
|
/**
|
|
280
145
|
* Theme
|
|
@@ -344,7 +209,7 @@ declare const _default: import("vue-demi").DefineComponent<{
|
|
|
344
209
|
*/
|
|
345
210
|
extensions: {
|
|
346
211
|
type: PropType<Extension[]>;
|
|
347
|
-
default:
|
|
212
|
+
default: () => never[];
|
|
348
213
|
};
|
|
349
214
|
/**
|
|
350
215
|
* Language Phreses
|
|
@@ -353,7 +218,7 @@ declare const _default: import("vue-demi").DefineComponent<{
|
|
|
353
218
|
*/
|
|
354
219
|
phrases: {
|
|
355
220
|
type: PropType<Record<string, string>>;
|
|
356
|
-
default: undefined;
|
|
221
|
+
default: () => undefined;
|
|
357
222
|
};
|
|
358
223
|
/**
|
|
359
224
|
* CodeMirror Language
|
|
@@ -362,7 +227,7 @@ declare const _default: import("vue-demi").DefineComponent<{
|
|
|
362
227
|
*/
|
|
363
228
|
lang: {
|
|
364
229
|
type: PropType<LanguageSupport>;
|
|
365
|
-
default: undefined;
|
|
230
|
+
default: () => undefined;
|
|
366
231
|
};
|
|
367
232
|
/**
|
|
368
233
|
* CodeMirror Linter
|
|
@@ -371,7 +236,7 @@ declare const _default: import("vue-demi").DefineComponent<{
|
|
|
371
236
|
*/
|
|
372
237
|
linter: {
|
|
373
238
|
type: PropType<Diagnostic[]>;
|
|
374
|
-
default: undefined;
|
|
239
|
+
default: () => undefined;
|
|
375
240
|
};
|
|
376
241
|
}>>, {
|
|
377
242
|
readonly: boolean;
|
|
@@ -393,6 +258,5 @@ declare const _default: import("vue-demi").DefineComponent<{
|
|
|
393
258
|
lang: LanguageSupport;
|
|
394
259
|
linter: Diagnostic[];
|
|
395
260
|
}>;
|
|
396
|
-
/** CodeMirror Component */
|
|
397
261
|
export default _default;
|
|
398
262
|
//# 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;;;;;;;;;;;;;;;;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: typeof Vue2) => 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"}
|
|
@@ -25,7 +25,7 @@ const _sfc_main = defineComponent({
|
|
|
25
25
|
},
|
|
26
26
|
selection: {
|
|
27
27
|
type: Object,
|
|
28
|
-
default: void 0
|
|
28
|
+
default: () => void 0
|
|
29
29
|
},
|
|
30
30
|
theme: {
|
|
31
31
|
type: Object,
|
|
@@ -59,19 +59,21 @@ const _sfc_main = defineComponent({
|
|
|
59
59
|
},
|
|
60
60
|
extensions: {
|
|
61
61
|
type: Array,
|
|
62
|
-
default:
|
|
62
|
+
default: () => {
|
|
63
|
+
return [];
|
|
64
|
+
}
|
|
63
65
|
},
|
|
64
66
|
phrases: {
|
|
65
67
|
type: Object,
|
|
66
|
-
default: void 0
|
|
68
|
+
default: () => void 0
|
|
67
69
|
},
|
|
68
70
|
lang: {
|
|
69
71
|
type: Object,
|
|
70
|
-
default: void 0
|
|
72
|
+
default: () => void 0
|
|
71
73
|
},
|
|
72
74
|
linter: {
|
|
73
75
|
type: Array,
|
|
74
|
-
default: void 0
|
|
76
|
+
default: () => void 0
|
|
75
77
|
}
|
|
76
78
|
},
|
|
77
79
|
emits: ["update:modelValue", "update"],
|
|
@@ -168,7 +170,5 @@ var CodeMirror = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]
|
|
|
168
170
|
* @copyright 2022 Masashi Yoshikawa {@link https://logue.dev/} All rights reserved.
|
|
169
171
|
* @see {@link https://github.com/logue/vue-codemirror6}
|
|
170
172
|
*/
|
|
171
|
-
const installCodeMirror = isVue2 ? (app) =>
|
|
172
|
-
app.component("CodeMirror", CodeMirror);
|
|
173
|
-
} : install();
|
|
173
|
+
const installCodeMirror = isVue2 ? (app) => app.component("CodeMirror", CodeMirror) : install();
|
|
174
174
|
export { CodeMirror as default, installCodeMirror as install };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
(function(o,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue-demi"),require("@codemirror/state"),require("@codemirror/view"),require("@codemirror/basic-setup"),require("@codemirror/commands"),require("lodash"),require("vue")):typeof define=="function"&&define.amd?define(["exports","vue-demi","@codemirror/state","@codemirror/view","@codemirror/basic-setup","@codemirror/commands","lodash","vue"],t):(o=typeof globalThis<"u"?globalThis:o||self,t(o.CodeMirror={},o.VueDemi,o.state,o.view,o.basicSetup,o.commands,o.lodash,o.Vue))})(this,function(o,t,s,n,h,S,f,l){"use strict";var V=(e,c)=>{const
|
|
1
|
+
(function(o,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue-demi"),require("@codemirror/state"),require("@codemirror/view"),require("@codemirror/basic-setup"),require("@codemirror/commands"),require("lodash"),require("vue")):typeof define=="function"&&define.amd?define(["exports","vue-demi","@codemirror/state","@codemirror/view","@codemirror/basic-setup","@codemirror/commands","lodash","vue"],t):(o=typeof globalThis<"u"?globalThis:o||self,t(o.CodeMirror={},o.VueDemi,o.state,o.view,o.basicSetup,o.commands,o.lodash,o.Vue))})(this,function(o,t,s,n,h,S,f,l){"use strict";var V=(e,c)=>{const a=e.__vccOpts||e;for(const[r,u]of c)a[r]=u;return a};const b=t.defineComponent({name:"CodeMirror",model:{prop:"modelValue",event:"update:modelValue"},props:{modelValue:{type:String,default:""},selection:{type:Object,default:()=>{}},theme:{type:Object,default:()=>({})},dark:{type:Boolean,default:!1},basic:{type:Boolean,default:!1},wrap:{type:Boolean,default:!1},tab:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1},editable:{type:Boolean,default:!0},extensions:{type:Array,default:()=>[]},phrases:{type:Object,default:()=>{}},lang:{type:Object,default:()=>{}},linter:{type:Array,default:()=>{}}},emits:["update:modelValue","update"],setup(e,c){const a=t.ref(),r=t.ref(e.modelValue),{dark:u}=t.toRefs(e),m=c.emit,y=t.computed(()=>{const i=[e.basic?h.basicSetup:void 0,n.EditorView.updateListener.of(p=>m("update",p)),n.EditorView.theme(e.theme,{dark:u.value}),e.wrap?n.EditorView.lineWrapping:void 0,e.tab?n.keymap.of([S.indentWithTab]):void 0,e.phrases?s.EditorState.phrases.of(e.phrases):void 0,e.readonly?s.EditorState.readOnly.of(e.readonly):void 0,e.editable?n.EditorView.editable.of(e.editable):void 0,e.lang?t.toRaw(e.lang):void 0];return e.linter&&f.merge(i,e.linter),e.extensions&&f.merge(i,e.extensions),f.compact(i)});let d;return t.watch(r,i=>{if(d.composing)return;const p=d.state.selection;d.setState(s.EditorState.create({doc:i,extensions:y.value,selection:p}))}),t.watch(u,()=>{d.setState(s.EditorState.create({doc:r.value,extensions:y.value}))}),t.onMounted(async()=>{r.value==""&&a.value&&(r.value=f.trim(a.value.childNodes[0].innerText)),d=new n.EditorView({state:s.EditorState.create({doc:r.value,selection:e.selection,extensions:y.value}),parent:a.value,dispatch:i=>{d.update([i]),!i.changes.empty&&(r.value=d.state.doc.toString(),m("update:modelValue",r.value))}}),await t.nextTick()}),t.onUnmounted(()=>d.destroy()),{context:c,editor:a}}}),w={ref:"editor",class:"vue-codemirror"};function E(e,c,a,r,u,m){return l.openBlock(),l.createElementBlock("div",w,[l.withDirectives(l.createElementVNode("aside",null,[l.renderSlot(e.$slots,"default")],512),[[l.vShow,!e.context.slots.default]])],512)}var v=V(b,[["render",E]]);/**
|
|
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 _=t.isVue2?e=>
|
|
8
|
+
*/const _=t.isVue2?e=>e.component("CodeMirror",v):t.install();o.default=v,o.install=_,Object.defineProperties(o,{__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.3.
|
|
4
|
+
"version": "0.3.7",
|
|
5
5
|
"description": "CodeMirror6 Component for vue3",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"vuejs",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
},
|
|
34
34
|
"engines": {
|
|
35
35
|
"node": ">=16.15.0",
|
|
36
|
-
"yarn": "
|
|
36
|
+
"yarn": ">=1.22.4"
|
|
37
37
|
},
|
|
38
38
|
"license": "MIT",
|
|
39
39
|
"main": "./dist/vue-codemirror6.umd.js",
|
|
@@ -55,76 +55,65 @@
|
|
|
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
60
|
"build:analyze": "vue-tsc --noEmit && vite build --mode analyze",
|
|
61
61
|
"build:docs": "vite build --config vite.config.docs.ts",
|
|
62
62
|
"build:clean": "rimraf dist",
|
|
63
|
-
"lint": "eslint
|
|
63
|
+
"lint": "eslint --fix --cache --cache-location ./node_modules/.vite/vite-plugin-eslint && prettier . -w -u",
|
|
64
64
|
"lint:markup": "vue-tsc --noEmit",
|
|
65
|
-
"switch:2": "vue-demi-switch 2 & npx vue-demi-fix",
|
|
66
|
-
"switch:3": "vue-demi-switch 3 vue3 & npx vue-demi-fix",
|
|
67
65
|
"preview": "vite preview --config vite.config.docs.ts",
|
|
68
66
|
"prepare": "husky install",
|
|
69
67
|
"postinstall": "npx vue-demi-fix"
|
|
70
68
|
},
|
|
71
69
|
"dependencies": {
|
|
72
|
-
"vue-demi": "
|
|
70
|
+
"vue-demi": ">=0.12.5"
|
|
73
71
|
},
|
|
74
72
|
"peerDependencies": {
|
|
75
|
-
"@codemirror/basic-setup": "
|
|
76
|
-
"@codemirror/state": "
|
|
77
|
-
"@codemirror/view": "
|
|
78
|
-
"
|
|
79
|
-
"vue": "^2.6.14 || ^3.2.33"
|
|
73
|
+
"@codemirror/basic-setup": ">=0.20",
|
|
74
|
+
"@codemirror/state": ">=0.20",
|
|
75
|
+
"@codemirror/view": ">=0.20",
|
|
76
|
+
"vue": "^2.6.14 || ^3.2.36"
|
|
80
77
|
},
|
|
81
78
|
"peerDependenciesMeta": {
|
|
82
79
|
"@vue/composition-api": {
|
|
83
80
|
"optional": true
|
|
84
|
-
},
|
|
85
|
-
"@codemirror/basic-setup": {
|
|
86
|
-
"optional": true
|
|
87
81
|
}
|
|
88
82
|
},
|
|
89
83
|
"devDependencies": {
|
|
90
84
|
"@codemirror/basic-setup": "^0.20.0",
|
|
91
|
-
"@codemirror/lang-markdown": "^0.20.
|
|
92
|
-
"@codemirror/language": "^0.20.1",
|
|
93
|
-
"@codemirror/lint": "^0.20.2",
|
|
94
|
-
"@modyqyw/vite-plugin-eslint": "^1.3.2",
|
|
85
|
+
"@codemirror/lang-markdown": "^0.20.1",
|
|
95
86
|
"@types/lodash": "^4.14.182",
|
|
96
|
-
"@types/node": "^17.0.
|
|
97
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
98
|
-
"@typescript-eslint/parser": "^5.
|
|
87
|
+
"@types/node": "^17.0.35",
|
|
88
|
+
"@typescript-eslint/eslint-plugin": "^5.26.0",
|
|
89
|
+
"@typescript-eslint/parser": "^5.26.0",
|
|
99
90
|
"@vitejs/plugin-vue": "^2.3.3",
|
|
100
|
-
"@vue/eslint-config-
|
|
101
|
-
"eslint": "^8.
|
|
91
|
+
"@vue/eslint-config-prettier": "^7.0.0",
|
|
92
|
+
"eslint": "^8.16.0",
|
|
102
93
|
"eslint-config-google": "^0.14.0",
|
|
103
94
|
"eslint-config-prettier": "^8.5.0",
|
|
104
95
|
"eslint-import-resolver-alias": "^1.1.2",
|
|
105
96
|
"eslint-import-resolver-typescript": "^2.7.1",
|
|
106
97
|
"eslint-plugin-import": "^2.26.0",
|
|
107
|
-
"eslint-plugin-
|
|
108
|
-
"eslint-plugin-prettier-vue": "^3.1.0",
|
|
98
|
+
"eslint-plugin-jsdoc": "^39.3.2",
|
|
109
99
|
"eslint-plugin-tsdoc": "^0.2.16",
|
|
110
100
|
"eslint-plugin-vue": "^9.0.1",
|
|
111
101
|
"eslint-plugin-vuejs-accessibility": "^1.1.1",
|
|
112
102
|
"husky": "^8.0.1",
|
|
113
|
-
"lint-staged": "^12.4.
|
|
103
|
+
"lint-staged": "^12.4.2",
|
|
114
104
|
"lodash": "^4.17.21",
|
|
115
105
|
"prettier": "^2.6.2",
|
|
116
106
|
"prettier-plugin-jsdoc": "^0.3.38",
|
|
117
107
|
"prettier-plugin-md-nocjsp": "^1.2.0",
|
|
118
|
-
"prettier-plugin-sort-imports": "^1.6.
|
|
108
|
+
"prettier-plugin-sort-imports": "^1.6.1",
|
|
119
109
|
"rimraf": "^3.0.2",
|
|
120
110
|
"rollup-plugin-visualizer": "^5.6.0",
|
|
121
|
-
"typescript": "^4.
|
|
111
|
+
"typescript": "^4.7.2",
|
|
122
112
|
"vite": "^2.9.9",
|
|
123
113
|
"vite-plugin-checker": "^0.4.6",
|
|
124
|
-
"vue": "^3.2.
|
|
114
|
+
"vue": "^3.2.36",
|
|
125
115
|
"vue-eslint-parser": "^9.0.2",
|
|
126
|
-
"vue-
|
|
127
|
-
"vue-tsc": "^0.34.15"
|
|
116
|
+
"vue-tsc": "^0.34.16"
|
|
128
117
|
},
|
|
129
118
|
"husky": {
|
|
130
119
|
"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
|
}
|