vue-codemirror6 0.3.6 → 0.5.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 +53 -41
- package/dist/components/{CodeMirror.vue.d.ts → CodeMirror.d.ts} +18 -154
- package/dist/components/CodeMirror.d.ts.map +1 -0
- package/dist/helpers/h-demi.d.ts +14 -0
- package/dist/helpers/h-demi.d.ts.map +1 -0
- package/dist/index.d.ts +2 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/{vue-codemirror6.es.js → index.es.js} +42 -36
- package/dist/index.umd.js +8 -0
- package/dist/interfaces/CodeMirrorEmitsInterface.d.ts +1 -1
- package/dist/interfaces/CodeMirrorEmitsInterface.d.ts.map +1 -1
- package/package.json +33 -39
- package/dist/components/CodeMirror.vue.d.ts.map +0 -1
- package/dist/vue-codemirror6.umd.js +0 -8
- package/src/components/CodeMirror.vue +0 -294
package/README.md
CHANGED
|
@@ -8,28 +8,35 @@
|
|
|
8
8
|
|
|
9
9
|
A component for using [CodeMirror6](https://codemirror.net/6/) with Vue. Unrelated to [surmon-china's vue-codemirror](https://github.com/surmon-china/vue-codemirror), it is for CodeMirror6.
|
|
10
10
|
|
|
11
|
-
If you are using Vue2, please use `0.1.x`. (The component itself supports both, but the script generated by vue-demi can only output one)
|
|
12
|
-
|
|
13
11
|
## Usage
|
|
14
12
|
|
|
13
|
+
```sh
|
|
14
|
+
yarn add vue-codemirror6
|
|
15
|
+
```
|
|
16
|
+
|
|
15
17
|
This component can handle bidirectional binding by `v-model` like a general Vue component.
|
|
18
|
+
|
|
16
19
|
When using with Vue2, [@vue/composition-api](https://www.npmjs.com/package/@vue/composition-api) is required separately.
|
|
17
20
|
|
|
21
|
+
```sh
|
|
22
|
+
yarn add vue-codemirror6 @vue/composition-api
|
|
23
|
+
```
|
|
24
|
+
|
|
18
25
|
### Props
|
|
19
26
|
|
|
20
|
-
| Props | Type | Information
|
|
21
|
-
| ---------- | --------------------------------- |
|
|
22
|
-
| basic | boolean | Use [basic-setup](https://codemirror.net/6/docs/ref/#basic-setup).
|
|
23
|
-
| dark | boolean | Toggle Darkmode.
|
|
24
|
-
| wrap | boolean | Line text wrapping. see [lineWrapping](https://codemirror.net/6/docs/ref/#view.EditorView.lineWrapping).
|
|
25
|
-
| tab | boolean | Enables tab indentation.
|
|
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.
|
|
27
|
-
| readonly | boolean | Makes the cursor visible or you can drag the text but not edit the value.
|
|
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
|
-
| lang | LanguageSupport | The language you want to have syntax highlighting. see <https://codemirror.net/6/#languages>
|
|
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.
|
|
32
|
-
| linter |
|
|
27
|
+
| Props | Type | Information |
|
|
28
|
+
| ---------- | --------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
29
|
+
| basic | boolean | Use [basic-setup](https://codemirror.net/6/docs/ref/#basic-setup). |
|
|
30
|
+
| dark | boolean | Toggle Darkmode. It can be changed in real time, but the input value will return to the initial value. |
|
|
31
|
+
| wrap | boolean | Line text wrapping. see [lineWrapping](https://codemirror.net/6/docs/ref/#view.EditorView.lineWrapping). |
|
|
32
|
+
| tab | boolean | Enables tab indentation. |
|
|
33
|
+
| 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. |
|
|
34
|
+
| readonly | boolean | Makes the cursor visible or you can drag the text but not edit the value. |
|
|
35
|
+
| 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. |
|
|
36
|
+
| lang | LanguageSupport | The language you want to have syntax highlighting. see <https://codemirror.net/6/#languages> |
|
|
37
|
+
| phrases | Record<string, string> | Specify here if you want to make the displayed character string multilingual. see <https://codemirror.net/6/examples/translate/> |
|
|
38
|
+
| extensions | Extension[] | Includes enhancements to extend CodeMirror. |
|
|
39
|
+
| linter | LintSource | Set Linter. Enter a linter (eg `esLint([arbitrary rule])` function for `@codemirror / lang-javascript`, `jsonParseLinter()`function for`@codemirror/json`). See the sources for various language libraries for more information. |
|
|
33
40
|
|
|
34
41
|
Notice: `lang` and `linter` can also be set together in `extensions`. This is defined for usability compatibility with past CodeMirrors.
|
|
35
42
|
|
|
@@ -88,7 +95,7 @@ Also, insert a `<pre>` tag to prevent the text in the slot from being automatica
|
|
|
88
95
|
|
|
89
96
|
```vue
|
|
90
97
|
<template>
|
|
91
|
-
<code-mirror :lang="lang" :
|
|
98
|
+
<code-mirror :lang="lang" :linter="linter">
|
|
92
99
|
<pre>
|
|
93
100
|
{
|
|
94
101
|
"key": "value"
|
|
@@ -100,7 +107,7 @@ Also, insert a `<pre>` tag to prevent the text in the slot from being automatica
|
|
|
100
107
|
<script>
|
|
101
108
|
import { ref, defineComponent } from 'vue';
|
|
102
109
|
|
|
103
|
-
import { json } from '@codemirror/lang-json';
|
|
110
|
+
import { json, jsonParseLinter } from '@codemirror/lang-json';
|
|
104
111
|
|
|
105
112
|
import CodeMirror from 'vue-codemirror6';
|
|
106
113
|
|
|
@@ -109,8 +116,9 @@ export default defineComponent({
|
|
|
109
116
|
CodeMirror,
|
|
110
117
|
},
|
|
111
118
|
setup() {
|
|
112
|
-
const lang =
|
|
113
|
-
|
|
119
|
+
const lang = json();
|
|
120
|
+
const linter = jsonParseLinter();
|
|
121
|
+
return { lang, linter };
|
|
114
122
|
},
|
|
115
123
|
});
|
|
116
124
|
</script>
|
|
@@ -118,29 +126,28 @@ export default defineComponent({
|
|
|
118
126
|
|
|
119
127
|
### Full Example
|
|
120
128
|
|
|
121
|
-
When using as a Markdown editor on [
|
|
129
|
+
When using as a Markdown editor on [vite-vue2-vuetify-ts-starter](https://github.com/logue/vite-vue2-vuetify-ts-starter ).
|
|
122
130
|
|
|
123
131
|
```vue
|
|
124
132
|
<template>
|
|
125
133
|
<code-mirror
|
|
126
134
|
v-model="value"
|
|
135
|
+
basic
|
|
136
|
+
:dark="dark"
|
|
127
137
|
:lang="lang"
|
|
128
138
|
:phrases="phreses"
|
|
129
|
-
:extensions="extensions"
|
|
130
|
-
:dark="$vuetify.theme.dark"
|
|
131
139
|
/>
|
|
132
140
|
</template>
|
|
133
141
|
|
|
134
142
|
<script lang="ts">
|
|
135
|
-
import { ref, type Ref
|
|
143
|
+
import { ref, defineComponent, type Ref } from 'vue';
|
|
136
144
|
|
|
137
145
|
// Load component
|
|
138
146
|
import CodeMirror from 'vue-codemirror6';
|
|
139
147
|
|
|
140
148
|
// CodeMirror extensions
|
|
141
149
|
import type { LanguageSupport } from '@codemirror/language';
|
|
142
|
-
import { markdown } from '@codemirror/lang-markdown';
|
|
143
|
-
import { basicSetup } from '@codemirror/basic-setup';
|
|
150
|
+
import { markdown as md } from '@codemirror/lang-markdown';
|
|
144
151
|
import type { Extension } from '@codemirror/state';
|
|
145
152
|
import type { ViewUpdate } from '@codemirror/view';
|
|
146
153
|
|
|
@@ -149,6 +156,12 @@ export default defineComponent({
|
|
|
149
156
|
CodeMirror,
|
|
150
157
|
},
|
|
151
158
|
setup() {
|
|
159
|
+
/**
|
|
160
|
+
* Get Vuetify instance
|
|
161
|
+
* @see {@link https://github.com/logue/vite-vue2-vuetify-ts-starter | vite-vue2-vuetify-ts-starter}
|
|
162
|
+
*/
|
|
163
|
+
const vuetify = useVuetify();
|
|
164
|
+
|
|
152
165
|
/** text */
|
|
153
166
|
const value: Ref<string> = ref('');
|
|
154
167
|
|
|
@@ -157,11 +170,18 @@ export default defineComponent({
|
|
|
157
170
|
*
|
|
158
171
|
* @see {@link https://codemirror.net/6/docs/ref/#language | @codemirror/language}
|
|
159
172
|
*/
|
|
160
|
-
const lang:
|
|
173
|
+
const lang: LanguageSupport = md();
|
|
174
|
+
|
|
175
|
+
/** Dark mode **/
|
|
176
|
+
const dark = ref(window.matchMedia('(prefers-color-scheme: dark)').matches);
|
|
177
|
+
|
|
178
|
+
/** When dark value changed, sync vuetify's dark mode */
|
|
179
|
+
watch(dark, v => (vuetify.theme.dark = v));
|
|
161
180
|
|
|
162
181
|
/**
|
|
163
182
|
* Internationalization Config.
|
|
164
183
|
* In this example, the display language to Japanese.
|
|
184
|
+
* Must be reactive when used in combination with vue-i18n.
|
|
165
185
|
*
|
|
166
186
|
* @see {@link https://codemirror.net/6/examples/translate/ | Example: Internationalization}
|
|
167
187
|
*/
|
|
@@ -196,21 +216,11 @@ export default defineComponent({
|
|
|
196
216
|
'No diagnostics': 'エラーなし',
|
|
197
217
|
});
|
|
198
218
|
|
|
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
219
|
return {
|
|
220
|
+
dark,
|
|
210
221
|
value,
|
|
211
222
|
lang,
|
|
212
223
|
phrases,
|
|
213
|
-
extensions,
|
|
214
224
|
};
|
|
215
225
|
},
|
|
216
226
|
});
|
|
@@ -231,11 +241,13 @@ const config: UserConfig = {
|
|
|
231
241
|
// ...
|
|
232
242
|
codemirror: [
|
|
233
243
|
// Split CodeMirror code.
|
|
234
|
-
'
|
|
235
|
-
'@codemirror/
|
|
236
|
-
'@codemirror/
|
|
244
|
+
'@codemirror/basic-setup': 'basicSetup',
|
|
245
|
+
'@codemirror/commands': 'commands',
|
|
246
|
+
'@codemirror/language': 'language',
|
|
247
|
+
'@codemirror/lint': 'lint',
|
|
248
|
+
'@codemirror/state': 'state',
|
|
249
|
+
'@codemirror/view': 'view',
|
|
237
250
|
// Add the following as needed.
|
|
238
|
-
'@codemirror/basic-setup',
|
|
239
251
|
'@codemirror/lang-html',
|
|
240
252
|
'@codemirror/lang-javascript',
|
|
241
253
|
'@codemirror/lang-markdown',
|
|
@@ -2,8 +2,9 @@ import { type PropType, type Ref, type SetupContext } from 'vue-demi';
|
|
|
2
2
|
import { EditorSelection } from '@codemirror/state';
|
|
3
3
|
import type { Extension, Text } from '@codemirror/state';
|
|
4
4
|
import type { LanguageSupport } from '@codemirror/language';
|
|
5
|
-
import type {
|
|
5
|
+
import type { LintSource } 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
|
|
@@ -116,149 +117,13 @@ declare const _default: import("vue-demi").DefineComponent<{
|
|
|
116
117
|
* @see {@link https://codemirror.net/6/docs/ref/#lint | @codemirror/lint}
|
|
117
118
|
*/
|
|
118
119
|
linter: {
|
|
119
|
-
type: PropType<
|
|
120
|
-
default: undefined;
|
|
120
|
+
type: PropType<LintSource>;
|
|
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
|
|
@@ -370,11 +235,10 @@ declare const _default: import("vue-demi").DefineComponent<{
|
|
|
370
235
|
* @see {@link https://codemirror.net/6/docs/ref/#lint | @codemirror/lint}
|
|
371
236
|
*/
|
|
372
237
|
linter: {
|
|
373
|
-
type: PropType<
|
|
374
|
-
default: undefined;
|
|
238
|
+
type: PropType<LintSource>;
|
|
239
|
+
default: () => undefined;
|
|
375
240
|
};
|
|
376
241
|
}>>, {
|
|
377
|
-
readonly: boolean;
|
|
378
242
|
modelValue: string | Text;
|
|
379
243
|
selection: EditorSelection | {
|
|
380
244
|
anchor: number;
|
|
@@ -387,12 +251,12 @@ declare const _default: import("vue-demi").DefineComponent<{
|
|
|
387
251
|
basic: boolean;
|
|
388
252
|
wrap: boolean;
|
|
389
253
|
tab: boolean;
|
|
254
|
+
readonly: boolean;
|
|
390
255
|
editable: boolean;
|
|
391
256
|
extensions: Extension[];
|
|
392
257
|
phrases: Record<string, string>;
|
|
393
258
|
lang: LanguageSupport;
|
|
394
|
-
linter:
|
|
259
|
+
linter: LintSource;
|
|
395
260
|
}>;
|
|
396
|
-
/** CodeMirror Component */
|
|
397
261
|
export default _default;
|
|
398
|
-
//# sourceMappingURL=CodeMirror.
|
|
262
|
+
//# sourceMappingURL=CodeMirror.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CodeMirror.d.ts","sourceRoot":"","sources":["../../src/components/CodeMirror.ts"],"names":[],"mappings":"AAAA,OAAO,EAWL,KAAK,QAAQ,EACb,KAAK,GAAG,EACR,KAAK,YAAY,EAClB,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,eAAe,EAAe,MAAM,mBAAmB,CAAC;AAWjE,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,wBA+QG"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
interface Options {
|
|
2
|
+
domProps?: Record<any, any>;
|
|
3
|
+
on?: Record<any, any>;
|
|
4
|
+
props?: Record<any, any>;
|
|
5
|
+
ref?: string;
|
|
6
|
+
class?: string;
|
|
7
|
+
style?: string;
|
|
8
|
+
}
|
|
9
|
+
declare const h: (type: string | Record<any, any>, options?: Options, chidren?: any) => import("vue-demi").VNode<import("vue-demi").RendererNode, import("vue-demi").RendererElement, {
|
|
10
|
+
[key: string]: any;
|
|
11
|
+
}>;
|
|
12
|
+
declare const slot: (defaultSlots: any) => any;
|
|
13
|
+
export { slot, h as default };
|
|
14
|
+
//# sourceMappingURL=h-demi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"h-demi.d.ts","sourceRoot":"","sources":["../../src/helpers/h-demi.ts"],"names":[],"mappings":"AAEA,UAAU,OAAO;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IAC5B,EAAE,CAAC,EAAE,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IACzB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAWD,QAAA,MAAM,CAAC,SACC,MAAM,GAAG,OAAO,GAAG,EAAE,GAAG,CAAC,YACtB,OAAO,YACN,GAAG;;EASd,CAAC;AAEF,QAAA,MAAM,IAAI,iBAAkB,GAAG,QAG9B,CAAC;AACF,OAAO,EAAE,IAAI,EAAE,CAAC,IAAI,OAAO,EAAE,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -6,8 +6,7 @@
|
|
|
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 CodeMirror from './components/CodeMirror
|
|
10
|
-
|
|
11
|
-
declare const installCodeMirror: void | ((app: typeof Vue2) => void);
|
|
9
|
+
import CodeMirror from './components/CodeMirror';
|
|
10
|
+
declare const installCodeMirror: (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,yBAAyB,CAAC;AAGjD,QAAA,MAAM,iBAAiB,mBAAiD,CAAC;AAEzE,OAAO,EAAE,UAAU,IAAI,OAAO,EAAE,iBAAiB,IAAI,OAAO,EAAE,CAAC"}
|
|
@@ -1,18 +1,33 @@
|
|
|
1
|
-
import { defineComponent, ref, toRefs, computed, toRaw, watch, onMounted, nextTick, onUnmounted
|
|
1
|
+
import { isVue2, h as h$1, defineComponent, ref, toRefs, computed, toRaw, watch, onMounted, nextTick, onUnmounted } from "vue-demi";
|
|
2
2
|
import { EditorState } from "@codemirror/state";
|
|
3
3
|
import { EditorView, keymap } from "@codemirror/view";
|
|
4
|
+
import { linter, lintGutter } from "@codemirror/lint";
|
|
4
5
|
import { basicSetup } from "@codemirror/basic-setup";
|
|
5
6
|
import { indentWithTab } from "@codemirror/commands";
|
|
6
7
|
import { merge, compact, trim } from "lodash";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
const adaptOnsV3 = (ons) => {
|
|
9
|
+
if (!ons)
|
|
10
|
+
return null;
|
|
11
|
+
return Object.entries(ons).reduce((ret, [key, handler]) => {
|
|
12
|
+
key = key.charAt(0).toUpperCase() + key.slice(1);
|
|
13
|
+
key = `on${key}`;
|
|
14
|
+
return { ...ret, [key]: handler };
|
|
15
|
+
}, {});
|
|
16
|
+
};
|
|
17
|
+
const h = (type, options = {}, chidren) => {
|
|
18
|
+
if (isVue2)
|
|
19
|
+
return h$1(type, options, chidren);
|
|
20
|
+
const { props, domProps, on, ...extraOptions } = options;
|
|
21
|
+
const ons = on ? adaptOnsV3(on) : {};
|
|
22
|
+
const params = { ...extraOptions, ...props, ...domProps, ...ons };
|
|
23
|
+
return h$1(type, params, chidren);
|
|
24
|
+
};
|
|
25
|
+
const slot = (defaultSlots) => {
|
|
26
|
+
if (typeof defaultSlots == "function")
|
|
27
|
+
return defaultSlots();
|
|
28
|
+
return defaultSlots;
|
|
14
29
|
};
|
|
15
|
-
|
|
30
|
+
var CodeMirror = defineComponent({
|
|
16
31
|
name: "CodeMirror",
|
|
17
32
|
model: {
|
|
18
33
|
prop: "modelValue",
|
|
@@ -25,7 +40,7 @@ const _sfc_main = defineComponent({
|
|
|
25
40
|
},
|
|
26
41
|
selection: {
|
|
27
42
|
type: Object,
|
|
28
|
-
default: void 0
|
|
43
|
+
default: () => void 0
|
|
29
44
|
},
|
|
30
45
|
theme: {
|
|
31
46
|
type: Object,
|
|
@@ -59,19 +74,21 @@ const _sfc_main = defineComponent({
|
|
|
59
74
|
},
|
|
60
75
|
extensions: {
|
|
61
76
|
type: Array,
|
|
62
|
-
default:
|
|
77
|
+
default: () => {
|
|
78
|
+
return [];
|
|
79
|
+
}
|
|
63
80
|
},
|
|
64
81
|
phrases: {
|
|
65
82
|
type: Object,
|
|
66
|
-
default: void 0
|
|
83
|
+
default: () => void 0
|
|
67
84
|
},
|
|
68
85
|
lang: {
|
|
69
86
|
type: Object,
|
|
70
|
-
default: void 0
|
|
87
|
+
default: () => void 0
|
|
71
88
|
},
|
|
72
89
|
linter: {
|
|
73
|
-
type:
|
|
74
|
-
default: void 0
|
|
90
|
+
type: Object,
|
|
91
|
+
default: () => void 0
|
|
75
92
|
}
|
|
76
93
|
},
|
|
77
94
|
emits: ["update:modelValue", "update"],
|
|
@@ -90,11 +107,10 @@ const _sfc_main = defineComponent({
|
|
|
90
107
|
props.phrases ? EditorState.phrases.of(props.phrases) : void 0,
|
|
91
108
|
props.readonly ? EditorState.readOnly.of(props.readonly) : void 0,
|
|
92
109
|
props.editable ? EditorView.editable.of(props.editable) : void 0,
|
|
93
|
-
props.lang ? toRaw(props.lang) : void 0
|
|
110
|
+
props.lang ? toRaw(props.lang) : void 0,
|
|
111
|
+
props.linter ? linter(props.linter) : void 0,
|
|
112
|
+
props.linter ? lintGutter() : void 0
|
|
94
113
|
];
|
|
95
|
-
if (props.linter) {
|
|
96
|
-
merge(ext, props.linter);
|
|
97
|
-
}
|
|
98
114
|
if (props.extensions) {
|
|
99
115
|
merge(ext, props.extensions);
|
|
100
116
|
}
|
|
@@ -144,22 +160,14 @@ const _sfc_main = defineComponent({
|
|
|
144
160
|
context,
|
|
145
161
|
editor
|
|
146
162
|
};
|
|
163
|
+
},
|
|
164
|
+
render() {
|
|
165
|
+
return h("div", {
|
|
166
|
+
ref: "editor",
|
|
167
|
+
class: "vue-codemirror"
|
|
168
|
+
}, this.$slots.default ? h("aside", { style: "display: none;" }, slot(this.$slots.default)) : void 0);
|
|
147
169
|
}
|
|
148
170
|
});
|
|
149
|
-
const _hoisted_1 = {
|
|
150
|
-
ref: "editor",
|
|
151
|
-
class: "vue-codemirror"
|
|
152
|
-
};
|
|
153
|
-
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
154
|
-
return openBlock(), createElementBlock("div", _hoisted_1, [
|
|
155
|
-
withDirectives(createElementVNode("aside", null, [
|
|
156
|
-
renderSlot(_ctx.$slots, "default")
|
|
157
|
-
], 512), [
|
|
158
|
-
[vShow, !_ctx.context.slots.default]
|
|
159
|
-
])
|
|
160
|
-
], 512);
|
|
161
|
-
}
|
|
162
|
-
var CodeMirror = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
|
|
163
171
|
/**
|
|
164
172
|
* Vue CodeMirror6 Component
|
|
165
173
|
*
|
|
@@ -168,7 +176,5 @@ var CodeMirror = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]
|
|
|
168
176
|
* @copyright 2022 Masashi Yoshikawa {@link https://logue.dev/} All rights reserved.
|
|
169
177
|
* @see {@link https://github.com/logue/vue-codemirror6}
|
|
170
178
|
*/
|
|
171
|
-
const installCodeMirror =
|
|
172
|
-
app.component("CodeMirror", CodeMirror);
|
|
173
|
-
} : install();
|
|
179
|
+
const installCodeMirror = (app) => app.component("CodeMirror", CodeMirror);
|
|
174
180
|
export { CodeMirror as default, installCodeMirror as install };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
(function(r,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue-demi"),require("@codemirror/state"),require("@codemirror/view"),require("@codemirror/lint"),require("@codemirror/basic-setup"),require("@codemirror/commands"),require("lodash")):typeof define=="function"&&define.amd?define(["exports","vue-demi","@codemirror/state","@codemirror/view","@codemirror/lint","@codemirror/basic-setup","@codemirror/commands","lodash"],t):(r=typeof globalThis<"u"?globalThis:r||self,t(r.CodeMirror={},r.VueDemi,r.state,r.view,r.lint,r.basicSetup,r.commands,r.lodash))})(this,function(r,t,s,l,h,b,V,m){"use strict";const w=e=>e?Object.entries(e).reduce((a,[o,i])=>(o=o.charAt(0).toUpperCase()+o.slice(1),o=`on${o}`,{...a,[o]:i}),{}):null,v=(e,a={},o)=>{if(t.isVue2)return t.h(e,a,o);const{props:i,domProps:f,on:u,...c}=a,n=u?w(u):{},d={...c,...i,...f,...n};return t.h(e,d,o)},x=e=>typeof e=="function"?e():e;var y=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:Object,default:()=>{}}},emits:["update:modelValue","update"],setup(e,a){const o=t.ref(),i=t.ref(e.modelValue),{dark:f}=t.toRefs(e),u=a.emit,c=t.computed(()=>{const d=[e.basic?b.basicSetup:void 0,l.EditorView.updateListener.of(p=>u("update",p)),l.EditorView.theme(e.theme,{dark:f.value}),e.wrap?l.EditorView.lineWrapping:void 0,e.tab?l.keymap.of([V.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?l.EditorView.editable.of(e.editable):void 0,e.lang?t.toRaw(e.lang):void 0,e.linter?h.linter(e.linter):void 0,e.linter?h.lintGutter():void 0];return e.extensions&&m.merge(d,e.extensions),m.compact(d)});let n;return t.watch(i,d=>{if(n.composing)return;const p=n.state.selection;n.setState(s.EditorState.create({doc:d,extensions:c.value,selection:p}))}),t.watch(f,()=>{n.setState(s.EditorState.create({doc:i.value,extensions:c.value}))}),t.onMounted(async()=>{i.value==""&&o.value&&(i.value=m.trim(o.value.childNodes[0].innerText)),n=new l.EditorView({state:s.EditorState.create({doc:i.value,selection:e.selection,extensions:c.value}),parent:o.value,dispatch:d=>{n.update([d]),!d.changes.empty&&(i.value=n.state.doc.toString(),u("update:modelValue",i.value))}}),await t.nextTick()}),t.onUnmounted(()=>n.destroy()),{context:a,editor:o}},render(){return v("div",{ref:"editor",class:"vue-codemirror"},this.$slots.default?v("aside",{style:"display: none;"},x(this.$slots.default)):void 0)}});/**
|
|
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
|
+
*/const S=e=>e.component("CodeMirror",y);r.default=y,r.install=S,Object.defineProperties(r,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
@@ -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"}
|
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 vue3",
|
|
4
|
+
"version": "0.5.1",
|
|
5
|
+
"description": "CodeMirror6 Component for vue2 and vue3",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"vuejs",
|
|
8
8
|
"vue",
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"vue-codemirror",
|
|
11
11
|
"code-editor",
|
|
12
12
|
"text-editor",
|
|
13
|
+
"vue2",
|
|
13
14
|
"vue3",
|
|
14
15
|
"web-editor",
|
|
15
16
|
"vue-plugin",
|
|
@@ -33,18 +34,19 @@
|
|
|
33
34
|
},
|
|
34
35
|
"engines": {
|
|
35
36
|
"node": ">=16.15.0",
|
|
36
|
-
"yarn": "
|
|
37
|
+
"yarn": ">=1.22.4"
|
|
37
38
|
},
|
|
39
|
+
"packageManager": "yarn@3.2.1",
|
|
38
40
|
"license": "MIT",
|
|
39
|
-
"main": "./dist/
|
|
40
|
-
"module": "./dist/
|
|
41
|
+
"main": "./dist/index.umd.js",
|
|
42
|
+
"module": "./dist/index.es.js",
|
|
41
43
|
"browser": {
|
|
42
44
|
"./sfc": "./src/components/CodeMirror.vue"
|
|
43
45
|
},
|
|
44
46
|
"exports": {
|
|
45
47
|
".": {
|
|
46
|
-
"import": "./dist/
|
|
47
|
-
"require": "./dist/
|
|
48
|
+
"import": "./dist/index.es.js",
|
|
49
|
+
"require": "./dist/index.umd.js"
|
|
48
50
|
}
|
|
49
51
|
},
|
|
50
52
|
"types": "./dist/index.d.ts",
|
|
@@ -55,76 +57,68 @@
|
|
|
55
57
|
"sideEffects": false,
|
|
56
58
|
"scripts": {
|
|
57
59
|
"dev": "vite",
|
|
58
|
-
"clean": "rimraf node_modules/.vite",
|
|
60
|
+
"clean": "rimraf node_modules/.vite && npx vue-demi-fix",
|
|
59
61
|
"build": "vite build & vue-tsc --declaration --emitDeclarationOnly",
|
|
60
62
|
"build:analyze": "vue-tsc --noEmit && vite build --mode analyze",
|
|
61
63
|
"build:docs": "vite build --config vite.config.docs.ts",
|
|
62
64
|
"build:clean": "rimraf dist",
|
|
63
|
-
"lint": "eslint
|
|
65
|
+
"lint": "eslint --fix --cache --cache-location ./node_modules/.vite/vite-plugin-eslint && prettier . -w -u",
|
|
64
66
|
"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
67
|
"preview": "vite preview --config vite.config.docs.ts",
|
|
68
|
-
"prepare": "husky install"
|
|
69
|
-
"postinstall": "npx vue-demi-fix"
|
|
68
|
+
"prepare": "husky install"
|
|
70
69
|
},
|
|
71
70
|
"dependencies": {
|
|
72
|
-
"vue-demi": "latest"
|
|
73
|
-
},
|
|
74
|
-
"peerDependencies": {
|
|
75
71
|
"@codemirror/basic-setup": "latest",
|
|
72
|
+
"@codemirror/commands": "latest",
|
|
73
|
+
"@codemirror/lint": "latest",
|
|
76
74
|
"@codemirror/state": "latest",
|
|
77
75
|
"@codemirror/view": "latest",
|
|
78
|
-
"
|
|
79
|
-
|
|
76
|
+
"vue-demi": "latest"
|
|
77
|
+
},
|
|
78
|
+
"peerDependencies": {
|
|
79
|
+
"@vue/composition-api": "^1.6.2",
|
|
80
|
+
"vue": "^2.6.14 || ^3.2.36"
|
|
80
81
|
},
|
|
81
82
|
"peerDependenciesMeta": {
|
|
82
83
|
"@vue/composition-api": {
|
|
83
84
|
"optional": true
|
|
84
|
-
},
|
|
85
|
-
"@codemirror/basic-setup": {
|
|
86
|
-
"optional": true
|
|
87
85
|
}
|
|
88
86
|
},
|
|
89
87
|
"devDependencies": {
|
|
90
|
-
"@codemirror/
|
|
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",
|
|
88
|
+
"@codemirror/lang-javascript": "^0.20.0",
|
|
89
|
+
"@codemirror/lang-markdown": "^0.20.1",
|
|
95
90
|
"@types/lodash": "^4.14.182",
|
|
96
|
-
"@types/node": "^17.0.
|
|
97
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
98
|
-
"@typescript-eslint/parser": "^5.
|
|
91
|
+
"@types/node": "^17.0.36",
|
|
92
|
+
"@typescript-eslint/eslint-plugin": "^5.26.0",
|
|
93
|
+
"@typescript-eslint/parser": "^5.26.0",
|
|
99
94
|
"@vitejs/plugin-vue": "^2.3.3",
|
|
100
|
-
"@vue/eslint-config-
|
|
101
|
-
"eslint": "^8.
|
|
95
|
+
"@vue/eslint-config-prettier": "^7.0.0",
|
|
96
|
+
"eslint": "^8.16.0",
|
|
102
97
|
"eslint-config-google": "^0.14.0",
|
|
103
98
|
"eslint-config-prettier": "^8.5.0",
|
|
104
99
|
"eslint-import-resolver-alias": "^1.1.2",
|
|
105
100
|
"eslint-import-resolver-typescript": "^2.7.1",
|
|
106
101
|
"eslint-plugin-import": "^2.26.0",
|
|
107
|
-
"eslint-plugin-
|
|
108
|
-
"eslint-plugin-prettier-vue": "^3.1.0",
|
|
102
|
+
"eslint-plugin-jsdoc": "^39.3.2",
|
|
109
103
|
"eslint-plugin-tsdoc": "^0.2.16",
|
|
110
104
|
"eslint-plugin-vue": "^9.0.1",
|
|
111
105
|
"eslint-plugin-vuejs-accessibility": "^1.1.1",
|
|
106
|
+
"eslint4b-prebuilt": "^6.7.2",
|
|
112
107
|
"husky": "^8.0.1",
|
|
113
|
-
"lint-staged": "^12.4.
|
|
108
|
+
"lint-staged": "^12.4.2",
|
|
114
109
|
"lodash": "^4.17.21",
|
|
115
110
|
"prettier": "^2.6.2",
|
|
116
111
|
"prettier-plugin-jsdoc": "^0.3.38",
|
|
117
112
|
"prettier-plugin-md-nocjsp": "^1.2.0",
|
|
118
|
-
"prettier-plugin-sort-imports": "^1.6.
|
|
113
|
+
"prettier-plugin-sort-imports": "^1.6.1",
|
|
119
114
|
"rimraf": "^3.0.2",
|
|
120
115
|
"rollup-plugin-visualizer": "^5.6.0",
|
|
121
|
-
"typescript": "^4.
|
|
116
|
+
"typescript": "^4.7.2",
|
|
122
117
|
"vite": "^2.9.9",
|
|
123
118
|
"vite-plugin-checker": "^0.4.6",
|
|
124
|
-
"vue": "^3.2.
|
|
119
|
+
"vue": "^3.2.36",
|
|
125
120
|
"vue-eslint-parser": "^9.0.2",
|
|
126
|
-
"vue-
|
|
127
|
-
"vue-tsc": "^0.34.15"
|
|
121
|
+
"vue-tsc": "^0.34.17"
|
|
128
122
|
},
|
|
129
123
|
"husky": {
|
|
130
124
|
"hooks": {
|
|
@@ -1 +0,0 @@
|
|
|
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;;IAavC,kBAAkB;;;;;IAKlB;;;;OAIG;;;oBAG6B,MAAM;;;;;IAItC;;;;OAIG;;;;;;;IAOH,gBAAgB;;;;;IAKhB;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;;;;;IArHL,qBAAqB;;IAErB,uBAAuB;;;;;IAKvB,uBAAuB;;QAErB,kBAAkB;;;;;QAKlB;;;;WAIG;;;wBAG6B,MAAM;;;;;QAItC;;;;WAIG;;;;;;;QAOH,gBAAgB;;;;;QAKhB;;;;WAIG;;;;;QAKH;;;;WAIG;;;;;QAKH;;;;WAIG;;;;;QAKH;;;;WAIG;;;;;QAKH;;;;WAIG;;;;;QAKH;;;;WAIG;;;;;QAKH;;;;WAIG;;;;;QAKH;;;;WAIG;;;;;QAKH;;;;WAIG;;;;;;IAML,YAAY;;IAEZ;;;;OAIG;+BACmB,YAAY;;;;;IAzHhC,kBAAkB;;;;;IAKlB;;;;OAIG;;;oBAG6B,MAAM;;;;;IAItC;;;;OAIG;;;;;;;IAOH,gBAAgB;;;;;IAKhB;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;;;;;gBAhG6B,MAAM;;;;;;;;;;;;;;;;AAvB1C,2BAA2B;AAC3B,wBA6PG"}
|
|
@@ -1,8 +0,0 @@
|
|
|
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 r=e.__vccOpts||e;for(const[a,u]of c)r[a]=u;return r};const b=t.defineComponent({name:"CodeMirror",model:{prop:"modelValue",event:"update:modelValue"},props:{modelValue:{type:String,default:""},selection:{type:Object,default:void 0},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: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,c){const r=t.ref(),a=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(a,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:a.value,extensions:y.value}))}),t.onMounted(async()=>{a.value==""&&r.value&&(a.value=f.trim(r.value.childNodes[0].innerText)),d=new n.EditorView({state:s.EditorState.create({doc:a.value,selection:e.selection,extensions:y.value}),parent:r.value,dispatch:i=>{d.update([i]),!i.changes.empty&&(a.value=d.state.doc.toString(),m("update:modelValue",a.value))}}),await t.nextTick()}),t.onUnmounted(()=>d.destroy()),{context:c,editor:r}}}),w={ref:"editor",class:"vue-codemirror"};function E(e,c,r,a,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
|
-
* 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
|
-
*/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"}})});
|
|
@@ -1,294 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div ref="editor" class="vue-codemirror">
|
|
3
|
-
<aside v-show="!context.slots.default"><slot /></aside>
|
|
4
|
-
</div>
|
|
5
|
-
</template>
|
|
6
|
-
|
|
7
|
-
<script lang="ts">
|
|
8
|
-
import {
|
|
9
|
-
computed,
|
|
10
|
-
defineComponent,
|
|
11
|
-
nextTick,
|
|
12
|
-
onMounted,
|
|
13
|
-
onUnmounted,
|
|
14
|
-
ref,
|
|
15
|
-
toRaw,
|
|
16
|
-
toRefs,
|
|
17
|
-
watch,
|
|
18
|
-
type ComputedRef,
|
|
19
|
-
type PropType,
|
|
20
|
-
type Ref,
|
|
21
|
-
type SetupContext,
|
|
22
|
-
} from 'vue-demi';
|
|
23
|
-
|
|
24
|
-
import { EditorSelection, EditorState } from '@codemirror/state';
|
|
25
|
-
import { EditorView, keymap } from '@codemirror/view';
|
|
26
|
-
import { basicSetup } from '@codemirror/basic-setup';
|
|
27
|
-
import { indentWithTab } from '@codemirror/commands';
|
|
28
|
-
|
|
29
|
-
import { compact, merge, trim } from 'lodash';
|
|
30
|
-
|
|
31
|
-
import type CodeMirrorEmitsInterface from '@/interfaces/CodeMirrorEmitsInterface';
|
|
32
|
-
|
|
33
|
-
import type { Extension, Text, Transaction } from '@codemirror/state';
|
|
34
|
-
import type { LanguageSupport } from '@codemirror/language';
|
|
35
|
-
import type { ViewUpdate } from '@codemirror/view';
|
|
36
|
-
import type { Diagnostic } from '@codemirror/lint';
|
|
37
|
-
import type { StyleSpec } from 'style-mod';
|
|
38
|
-
|
|
39
|
-
/** CodeMirror Component */
|
|
40
|
-
export default defineComponent({
|
|
41
|
-
/** Component Name */
|
|
42
|
-
name: 'CodeMirror',
|
|
43
|
-
/** Model Definition */
|
|
44
|
-
model: {
|
|
45
|
-
prop: 'modelValue',
|
|
46
|
-
event: 'update:modelValue',
|
|
47
|
-
},
|
|
48
|
-
/** Props Definition */
|
|
49
|
-
props: {
|
|
50
|
-
/** Model value */
|
|
51
|
-
modelValue: {
|
|
52
|
-
type: String as PropType<string | Text>,
|
|
53
|
-
default: '',
|
|
54
|
-
},
|
|
55
|
-
/**
|
|
56
|
-
* Selection
|
|
57
|
-
*
|
|
58
|
-
* @see {@link https://codemirror.net/6/docs/ref/#state.EditorSelection | EditorSelection}
|
|
59
|
-
*/
|
|
60
|
-
selection: {
|
|
61
|
-
type: Object as PropType<
|
|
62
|
-
EditorSelection | { anchor: number; head?: number }
|
|
63
|
-
>,
|
|
64
|
-
default: undefined,
|
|
65
|
-
},
|
|
66
|
-
/**
|
|
67
|
-
* Theme
|
|
68
|
-
*
|
|
69
|
-
* @see {@link https://codemirror.net/6/examples/styling/ | Example: Styling}
|
|
70
|
-
*/
|
|
71
|
-
theme: {
|
|
72
|
-
type: Object as PropType<{ [selector: string]: StyleSpec }>,
|
|
73
|
-
default: () => {
|
|
74
|
-
return {};
|
|
75
|
-
},
|
|
76
|
-
},
|
|
77
|
-
/** Dark Mode */
|
|
78
|
-
dark: {
|
|
79
|
-
type: Boolean,
|
|
80
|
-
default: false,
|
|
81
|
-
},
|
|
82
|
-
/**
|
|
83
|
-
* Use Basic Setup
|
|
84
|
-
*
|
|
85
|
-
* @see {@link https://codemirror.net/6/docs/ref/#basic-setup | basic-setup}
|
|
86
|
-
*/
|
|
87
|
-
basic: {
|
|
88
|
-
type: Boolean,
|
|
89
|
-
default: false,
|
|
90
|
-
},
|
|
91
|
-
/**
|
|
92
|
-
* Line wrapping
|
|
93
|
-
*
|
|
94
|
-
* @see {@link https://codemirror.net/6/docs/ref/#view.EditorView%5ElineWrapping | LineWrapping}
|
|
95
|
-
*/
|
|
96
|
-
wrap: {
|
|
97
|
-
type: Boolean,
|
|
98
|
-
default: false,
|
|
99
|
-
},
|
|
100
|
-
/**
|
|
101
|
-
* Tab handling
|
|
102
|
-
*
|
|
103
|
-
* @see {@link https://codemirror.net/6/examples/tab/ | Tab Handling}
|
|
104
|
-
*/
|
|
105
|
-
tab: {
|
|
106
|
-
type: Boolean,
|
|
107
|
-
default: false,
|
|
108
|
-
},
|
|
109
|
-
/**
|
|
110
|
-
* Readonly
|
|
111
|
-
*
|
|
112
|
-
* @see {@link https://codemirror.net/6/docs/ref/#state.EditorState%5EreadOnly | readOnly}
|
|
113
|
-
*/
|
|
114
|
-
readonly: {
|
|
115
|
-
type: Boolean,
|
|
116
|
-
default: false,
|
|
117
|
-
},
|
|
118
|
-
/**
|
|
119
|
-
* Editable
|
|
120
|
-
*
|
|
121
|
-
* @see {@link https://codemirror.net/6/docs/ref/#view.EditorView%5Eeditable | editable}
|
|
122
|
-
*/
|
|
123
|
-
editable: {
|
|
124
|
-
type: Boolean,
|
|
125
|
-
default: true,
|
|
126
|
-
},
|
|
127
|
-
/**
|
|
128
|
-
* Additional Extension
|
|
129
|
-
*
|
|
130
|
-
* @see {@link https://codemirror.net/6/docs/ref/#state.Extension | Extending Editor State}
|
|
131
|
-
*/
|
|
132
|
-
extensions: {
|
|
133
|
-
type: Array as PropType<Extension[]>,
|
|
134
|
-
default: undefined,
|
|
135
|
-
},
|
|
136
|
-
/**
|
|
137
|
-
* Language Phreses
|
|
138
|
-
*
|
|
139
|
-
* @see {@link https://codemirror.net/6/examples/translate/ | Example: Internationalization}
|
|
140
|
-
*/
|
|
141
|
-
phrases: {
|
|
142
|
-
type: Object as PropType<Record<string, string>>,
|
|
143
|
-
default: undefined,
|
|
144
|
-
},
|
|
145
|
-
/**
|
|
146
|
-
* CodeMirror Language
|
|
147
|
-
*
|
|
148
|
-
* @see {@link https://codemirror.net/6/docs/ref/#language | @codemirror/language}
|
|
149
|
-
*/
|
|
150
|
-
lang: {
|
|
151
|
-
type: Object as PropType<LanguageSupport>,
|
|
152
|
-
default: undefined,
|
|
153
|
-
},
|
|
154
|
-
/**
|
|
155
|
-
* CodeMirror Linter
|
|
156
|
-
*
|
|
157
|
-
* @see {@link https://codemirror.net/6/docs/ref/#lint | @codemirror/lint}
|
|
158
|
-
*/
|
|
159
|
-
linter: {
|
|
160
|
-
type: Array as PropType<Diagnostic[]>,
|
|
161
|
-
default: undefined,
|
|
162
|
-
},
|
|
163
|
-
},
|
|
164
|
-
/** Emits */
|
|
165
|
-
emits: ['update:modelValue', 'update'],
|
|
166
|
-
/**
|
|
167
|
-
* Setup
|
|
168
|
-
* @param props - Props
|
|
169
|
-
* @param context - Context
|
|
170
|
-
*/
|
|
171
|
-
setup(props, context: SetupContext) {
|
|
172
|
-
/** Editor DOM */
|
|
173
|
-
const editor: Ref<Element | undefined> = ref();
|
|
174
|
-
|
|
175
|
-
/** Internal value */
|
|
176
|
-
const doc: Ref<string | Text | undefined> = ref(props.modelValue);
|
|
177
|
-
|
|
178
|
-
/** Dark mode */
|
|
179
|
-
const { dark } = toRefs(props);
|
|
180
|
-
|
|
181
|
-
/** Emits */
|
|
182
|
-
const emit = context.emit as CodeMirrorEmitsInterface;
|
|
183
|
-
|
|
184
|
-
/** CodeMirror Extension */
|
|
185
|
-
const exts: ComputedRef<Extension[]> = computed(() => {
|
|
186
|
-
/** Default extension */
|
|
187
|
-
const ext = [
|
|
188
|
-
// Toggle basic setup
|
|
189
|
-
props.basic ? basicSetup : undefined,
|
|
190
|
-
// ViewUpdate event listener
|
|
191
|
-
EditorView.updateListener.of((update: ViewUpdate) =>
|
|
192
|
-
emit('update', update)
|
|
193
|
-
),
|
|
194
|
-
// Toggle light/dark mode.
|
|
195
|
-
EditorView.theme(props.theme, { dark: dark.value }),
|
|
196
|
-
// Toggle line wrapping
|
|
197
|
-
props.wrap ? EditorView.lineWrapping : undefined,
|
|
198
|
-
// Indent with tab
|
|
199
|
-
props.tab ? keymap.of([indentWithTab]) : undefined,
|
|
200
|
-
// locale settings
|
|
201
|
-
props.phrases ? EditorState.phrases.of(props.phrases) : undefined,
|
|
202
|
-
// Readonly option
|
|
203
|
-
props.readonly ? EditorState.readOnly.of(props.readonly) : undefined,
|
|
204
|
-
// Editable option
|
|
205
|
-
props.editable ? EditorView.editable.of(props.editable) : undefined,
|
|
206
|
-
// Lang
|
|
207
|
-
props.lang ? toRaw(props.lang) : undefined,
|
|
208
|
-
];
|
|
209
|
-
|
|
210
|
-
if (props.linter) {
|
|
211
|
-
// Append Linter settings
|
|
212
|
-
merge(ext, props.linter);
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
if (props.extensions) {
|
|
216
|
-
// Append Extensions (such as basic-setup)
|
|
217
|
-
merge(ext, props.extensions);
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
// console.debug('[CodeMirror.vue] Loaded extensions:', compact(ext));
|
|
221
|
-
return compact(ext);
|
|
222
|
-
});
|
|
223
|
-
|
|
224
|
-
/** CodeMirror Editor View */
|
|
225
|
-
let view: EditorView;
|
|
226
|
-
|
|
227
|
-
/**
|
|
228
|
-
* Input value changed
|
|
229
|
-
*
|
|
230
|
-
* @see {@link https://codemirror.net/6/docs/migration/#making-changes | Making Changes}
|
|
231
|
-
*/
|
|
232
|
-
watch(doc, current => {
|
|
233
|
-
if (view.composing) {
|
|
234
|
-
// IME fix
|
|
235
|
-
return;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
/** Previous cursor location */
|
|
239
|
-
const previous = view.state.selection;
|
|
240
|
-
view.setState(
|
|
241
|
-
EditorState.create({
|
|
242
|
-
doc: current,
|
|
243
|
-
extensions: exts.value,
|
|
244
|
-
selection: previous,
|
|
245
|
-
})
|
|
246
|
-
);
|
|
247
|
-
});
|
|
248
|
-
|
|
249
|
-
watch(dark, () => {
|
|
250
|
-
view.setState(
|
|
251
|
-
EditorState.create({
|
|
252
|
-
doc: doc.value,
|
|
253
|
-
extensions: exts.value,
|
|
254
|
-
})
|
|
255
|
-
);
|
|
256
|
-
});
|
|
257
|
-
|
|
258
|
-
/** When loaded */
|
|
259
|
-
onMounted(async () => {
|
|
260
|
-
/** Initial Value */
|
|
261
|
-
if (doc.value == '' && editor.value) {
|
|
262
|
-
doc.value = trim((editor.value.childNodes[0] as HTMLElement).innerText);
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
// Register Codemirror
|
|
266
|
-
view = new EditorView({
|
|
267
|
-
state: EditorState.create({
|
|
268
|
-
doc: doc.value,
|
|
269
|
-
selection: props.selection,
|
|
270
|
-
extensions: exts.value,
|
|
271
|
-
}),
|
|
272
|
-
parent: editor.value,
|
|
273
|
-
dispatch: (tr: Transaction) => {
|
|
274
|
-
view.update([tr]);
|
|
275
|
-
|
|
276
|
-
if (tr.changes.empty) return;
|
|
277
|
-
// to parent binding
|
|
278
|
-
doc.value = view.state.doc.toString();
|
|
279
|
-
emit('update:modelValue', doc.value);
|
|
280
|
-
},
|
|
281
|
-
});
|
|
282
|
-
await nextTick();
|
|
283
|
-
});
|
|
284
|
-
|
|
285
|
-
/** Destroy */
|
|
286
|
-
onUnmounted(() => view.destroy());
|
|
287
|
-
|
|
288
|
-
return {
|
|
289
|
-
context,
|
|
290
|
-
editor,
|
|
291
|
-
};
|
|
292
|
-
},
|
|
293
|
-
});
|
|
294
|
-
</script>
|