vue-codemirror6 0.0.3 → 0.0.6
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 +36 -8
- package/dist/components/CodeMirror.vue.d.ts +63 -0
- package/dist/components/CodeMirror.vue.d.ts.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/{types/entry.esm.d.ts → dist/index.esm.d.ts} +6 -6
- package/dist/index.esm.d.ts.map +1 -0
- package/dist/vue-codemirror6.es.js +34 -9593
- package/dist/vue-codemirror6.umd.js +2 -12
- package/package.json +46 -28
- package/src/components/CodeMirror.vue +92 -27
- package/types/entry.d.ts +0 -4
- package/types/entry.d.ts.map +0 -1
- package/types/entry.esm.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -4,7 +4,21 @@ A component for using [CodeMirror6](https://codemirror.net/6/) with Vue. Unlike
|
|
|
4
4
|
|
|
5
5
|
## Usage
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
This component can handle bidirectional binding by `v-model` like a general Vue component.
|
|
8
|
+
|
|
9
|
+
Other options are currently as follows:
|
|
10
|
+
|
|
11
|
+
| attribute | information |
|
|
12
|
+
| ---------- | -------------------------------------------------------------------------------------------------------------------------------- |
|
|
13
|
+
| lang | The language you want to have syntax highlighting. see <https://codemirror.net/6/#languages> |
|
|
14
|
+
| phrases | Specify here if you want to make the displayed character string multilingual. see <https://codemirror.net/6/examples/translate/> |
|
|
15
|
+
| extensions | Includes enhancements to extend CodeMirror. Such as [@codemirror/basic-setup](https://github.com/codemirror/basic-setup). |
|
|
16
|
+
| dark | Toggle Darkmode. |
|
|
17
|
+
| linter | Set Linter. see example <https://codesandbox.io/s/f6nb0?file=/src/index.js> |
|
|
18
|
+
|
|
19
|
+
## Example
|
|
20
|
+
|
|
21
|
+
When using as a Markdown editor on [Vuetify](https://vuetifyjs.com/).
|
|
8
22
|
|
|
9
23
|
```vue
|
|
10
24
|
<template>
|
|
@@ -14,6 +28,7 @@ When using as a Markdown editor on Vuetify.
|
|
|
14
28
|
:phrases="phreses"
|
|
15
29
|
:extensions="extensions"
|
|
16
30
|
:dark="$vuetify.theme.dark"
|
|
31
|
+
@update="onCmUpdate"
|
|
17
32
|
/>
|
|
18
33
|
</template>
|
|
19
34
|
|
|
@@ -25,8 +40,10 @@ import CodeMirror from 'vue-codemirror6';
|
|
|
25
40
|
|
|
26
41
|
// CodeMirror extensions
|
|
27
42
|
import { basicSetup } from '@codemirror/basic-setup';
|
|
28
|
-
import { LanguageSupport } from '@codemirror/language';
|
|
29
43
|
import { markdown } from '@codemirror/lang-markdown';
|
|
44
|
+
import type { ViewUpdate } from '@codemirror/view';
|
|
45
|
+
import type { Extension } from '@codemirror/state';
|
|
46
|
+
import type { LanguageSupport } from '@codemirror/language';
|
|
30
47
|
|
|
31
48
|
@Component({ components: { CodeMirror } })
|
|
32
49
|
export default class Home extends Vue {
|
|
@@ -36,14 +53,14 @@ export default class Home extends Vue {
|
|
|
36
53
|
/**
|
|
37
54
|
* CodeMirror Language
|
|
38
55
|
*
|
|
39
|
-
* @see {@link https://codemirror.net/6/docs/ref/#language
|
|
56
|
+
* @see {@link https://codemirror.net/6/docs/ref/#language | @codemirror/language}
|
|
40
57
|
*/
|
|
41
58
|
lang: LanguageSupport = markdown();
|
|
42
59
|
|
|
43
60
|
/**
|
|
44
|
-
* Internationalization Config
|
|
61
|
+
* Internationalization Config. In this example, the display language is Japanese.
|
|
45
62
|
*
|
|
46
|
-
* @see {@link https://codemirror.net/6/examples/translate
|
|
63
|
+
* @see {@link https://codemirror.net/6/examples/translate/ | Example: Internationalization}
|
|
47
64
|
*/
|
|
48
65
|
phrases: Record<string, string> = {
|
|
49
66
|
// @codemirror/view
|
|
@@ -79,12 +96,23 @@ export default class Home extends Vue {
|
|
|
79
96
|
/**
|
|
80
97
|
* CodeMirror Extensions
|
|
81
98
|
*
|
|
82
|
-
* @see {@link:https://codemirror.net/6/docs/ref/#state.Extension|Extending Editor State}
|
|
99
|
+
* @see {@link:https://codemirror.net/6/docs/ref/#state.Extension | Extending Editor State}
|
|
83
100
|
*/
|
|
84
|
-
extensions: [
|
|
85
|
-
/** @see {@link:https://codemirror.net/6/docs/ref/#basic-setup|basic-setup} */
|
|
101
|
+
extensions: Extension[] = [
|
|
102
|
+
/** @see {@link:https://codemirror.net/6/docs/ref/#basic-setup | basic-setup} */
|
|
86
103
|
basicSetup
|
|
87
104
|
]
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* CodeMirror Hook View update event
|
|
108
|
+
*
|
|
109
|
+
* @param update View Update
|
|
110
|
+
*
|
|
111
|
+
* @see {@link https://codemirror.net/6/docs/ref/#view.ViewUpdate|class ViewUpdate}
|
|
112
|
+
*/
|
|
113
|
+
onCmUpdate(update: ViewUpdate) {
|
|
114
|
+
console.log(update)
|
|
115
|
+
}
|
|
88
116
|
}
|
|
89
117
|
```
|
|
90
118
|
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { Vue } from 'vue-property-decorator';
|
|
2
|
+
import { type Extension } from '@codemirror/state';
|
|
3
|
+
import type { LanguageSupport } from '@codemirror/language';
|
|
4
|
+
import type { Diagnostic } from '@codemirror/lint';
|
|
5
|
+
import type { StyleSpec } from 'style-mod';
|
|
6
|
+
/** CodeMirror Component */
|
|
7
|
+
export default class CodeMirror extends Vue {
|
|
8
|
+
/** Editor */
|
|
9
|
+
private editor;
|
|
10
|
+
/**
|
|
11
|
+
* Theme
|
|
12
|
+
*
|
|
13
|
+
* @see {@link https://codemirror.net/6/examples/styling/ | Example: Styling}
|
|
14
|
+
*/
|
|
15
|
+
readonly theme: {
|
|
16
|
+
[selector: string]: StyleSpec;
|
|
17
|
+
};
|
|
18
|
+
/** Dark Mode */
|
|
19
|
+
readonly dark: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Language Phreses
|
|
22
|
+
*
|
|
23
|
+
* @see {@link https://codemirror.net/6/examples/translate/ | Example: Internationalization}
|
|
24
|
+
*/
|
|
25
|
+
readonly phrases: Record<string, string>;
|
|
26
|
+
/**
|
|
27
|
+
* Additional Extension
|
|
28
|
+
*
|
|
29
|
+
* @see {@link https://codemirror.net/6/docs/ref/#state.Extension | Extending Editor State}
|
|
30
|
+
*/
|
|
31
|
+
readonly extensions: Extension[];
|
|
32
|
+
/**
|
|
33
|
+
* CodeMirror Language
|
|
34
|
+
*
|
|
35
|
+
* @see {@link https://codemirror.net/6/docs/ref/#language | @codemirror/language}
|
|
36
|
+
*/
|
|
37
|
+
readonly lang: LanguageSupport;
|
|
38
|
+
/**
|
|
39
|
+
* CodeMirror Linter
|
|
40
|
+
*
|
|
41
|
+
* @see {@link https://codemirror.net/6/docs/ref/#lint | @codemirror/lint}
|
|
42
|
+
*/
|
|
43
|
+
readonly linter: Diagnostic[];
|
|
44
|
+
/** Input */
|
|
45
|
+
readonly value: string;
|
|
46
|
+
/**
|
|
47
|
+
* Input value changed
|
|
48
|
+
*
|
|
49
|
+
* @see {@link https://codemirror.net/6/docs/migration/#making-changes | Making Changes}
|
|
50
|
+
*/
|
|
51
|
+
onValueChanged(): void;
|
|
52
|
+
/** Darkmode */
|
|
53
|
+
onToggleDarkMode(): void;
|
|
54
|
+
/** CodeMirror Extension */
|
|
55
|
+
get extension(): Extension[];
|
|
56
|
+
/** When loaded */
|
|
57
|
+
mounted(): void;
|
|
58
|
+
/** Destroy */
|
|
59
|
+
beforeDestroy(): void;
|
|
60
|
+
/** Vue node to plain text */
|
|
61
|
+
private getChildrenTextContent;
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=CodeMirror.vue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CodeMirror.vue.d.ts","sourceRoot":"","sources":["../../src/components/CodeMirror.vue.ts"],"names":[],"mappings":"AACA,OAAO,EAAmB,GAAG,EAAS,MAAM,wBAAwB,CAAC;AAGrE,OAAO,EAEL,KAAK,SAAS,EAEf,MAAM,mBAAmB,CAAC;AAE3B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
2
|
-
import component from './components/CodeMirror.vue';
|
|
3
|
-
declare type InstallableComponent = typeof component & PluginObject<any>;
|
|
4
|
-
declare const _default: InstallableComponent;
|
|
5
|
-
export default _default;
|
|
6
|
-
//# sourceMappingURL=
|
|
1
|
+
import { PluginObject } from 'vue';
|
|
2
|
+
import component from './components/CodeMirror.vue';
|
|
3
|
+
declare type InstallableComponent = typeof component & PluginObject<any>;
|
|
4
|
+
declare const _default: InstallableComponent;
|
|
5
|
+
export default _default;
|
|
6
|
+
//# sourceMappingURL=index.esm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.esm.d.ts","sourceRoot":"","sources":["../src/index.esm.ts"],"names":[],"mappings":"AAAA,OAAa,EAAE,YAAY,EAAE,MAAM,KAAK,CAAC;AAGzC,OAAO,SAAS,MAAM,6BAA6B,CAAC;AAGpD,aAAK,oBAAoB,GAAG,OAAO,SAAS,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;;AAKjE,wBASK"}
|