vue-codemirror6 0.0.2 → 0.0.5

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 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
- When using as a Markdown editor on Vuetify.
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|@codemirror/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/|Example: Internationalization}
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