26
26
- [ CodeMirror6 styling] ( https://codemirror.net/6/examples/styling/ )
27
27
- [ CodeMirror discuss] ( https://discuss.codemirror.net/ )
28
28
29
- ### Previous version
29
+ ### Legacy version
30
30
31
31
- [ [email protected] (Vue2 / CodeMirror5)
] ( https://github.com/surmon-china/vue-codemirror/tree/v4.0.0 )
32
32
@@ -42,6 +42,20 @@ yarn add vue-codemirror
42
42
npm install vue-codemirror --save
43
43
```
44
44
45
+ #### Depending on your actual needs, you may need to install more CodeMirror packages
46
+
47
+ ``` base
48
+ // CodeMirror languages...
49
+ yarn @codemirror/lang-html
50
+ yarn @codemirror/lang-json
51
+ yarn @codemirror/lang-javascript
52
+
53
+ // CodeMirror themes...
54
+ yarn @codemirror/theme-one-dark
55
+
56
+ // more CodeMirror packages...
57
+ ```
58
+
45
59
#### local component
46
60
47
61
``` vue
@@ -108,33 +122,44 @@ app.use(VueCodemirror, {
108
122
109
123
### Component Props
110
124
111
- | prop | description | type | default |
112
- | :------------ | :------------------------------------------------------- | :--------------------------------- | :------- ------ |
113
- | autofocus | - | ` Boolean ` | ` false ` |
114
- | disabled | - | ` Boolean ` | ` false ` |
115
- | indentWithTab | Bind Tab key. | ` Boolean ` | ` true ` |
116
- | tabSize | Indent of Tab key. | ` Number ` | ` 2 ` |
117
- | placeholder | - | ` String ` | ` '' ` |
118
- | style | The css style object that acts on the CodeMirror itself. | ` Boolean ` | ` true ` |
119
- | extensions | Passed to CodeMirror. | ` EditorStateConfig['extensions']> ` | ` [basicSetup] ` |
120
- | root | Passed to CodeMirror. | ` ShadowRoot \| Document ` | ` undefined ` |
121
- | selection | Passed to CodeMirror. | ` EditorStateConfig['selection'] ` | ` undefined ` |
125
+ | prop | description | type | default |
126
+ | :------------ | :-------------------------------------------------------- | :----------------------- | :------ |
127
+ | autofocus | Focus editor immediately after mounted. | ` Boolean ` | ` false ` |
128
+ | disabled | Disable input behavior and disable change state. | ` Boolean ` | ` false ` |
129
+ | indentWithTab | Bind keyboard Tab key event . | ` Boolean ` | ` true ` |
130
+ | tabSize | Specify the indent when the Tab key is pressed. | ` Number ` | ` 2 ` |
131
+ | placeholder | Display when empty. | ` String ` | ` '' ` |
132
+ | style | The CSS style object that acts on the CodeMirror itself. | ` Object ` | ` {} ` |
133
+ | extensions | Passed to CodeMirror ` EditorState.create({ extensions }) ` | ` Extension ` | ` [] ` |
134
+ | selection | Passed to CodeMirror ` EditorState.create({ selection }) ` | ` EditorSelection ` | - |
135
+ | root | Passed to CodeMirror ` new EditorView({ root }) ` | ` ShadowRoot \| Document ` | - |
122
136
123
137
### Component Events
124
138
125
- | event | description | params |
126
- | :------------------ | :----------------------------- | :------------------------------------------------------------------------------- |
127
- | ` update:modelValue ` | When content(doc) change only. | ` (value: string, viewUpdate: ViewUpdate) ` |
128
- | change | ditto | ditto |
129
- | update | When CodeMirror state change. | ` (viewUpdate: ViewUpdate) ` |
130
- | focus | When CodeMirror focused. | ` (viewUpdate: ViewUpdate) ` |
131
- | blur | When CodeMirror blurred. | ` (viewUpdate: ViewUpdate) ` |
132
- | ready | When component mounted. | ` (payload: { view: EditorView; state: EditorState; container: HTMLDivElement }) ` |
139
+ | event | description | params |
140
+ | :------------------ | :------------------------------------------------------ | :------------------------------------------------------------------------------- |
141
+ | ` update:modelValue ` | ** Only** when the CodeMirror content (doc) has changed. | ` (value: string, viewUpdate: ViewUpdate) ` |
142
+ | change | ditto | ditto |
143
+ | update | When any state of CodeMirror changes. | ` (viewUpdate: ViewUpdate) ` |
144
+ | focus | When CodeMirror focused. | ` (viewUpdate: ViewUpdate) ` |
145
+ | blur | When CodeMirror blurred. | ` (viewUpdate: ViewUpdate) ` |
146
+ | ready | When edirot component mounted. | ` (payload: { view: EditorView; state: EditorState; container: HTMLDivElement }) ` |
147
+
148
+ ### Basic Setup
149
+
150
+ The [ basic-setup] ( https://codemirror.net/6/docs/ref/#basic-setup ) extension is integrated by default in the vue-codemirror configuration, and is intended as a handy helper to quickly set up CodeMirror without having to install and import a lot of standalone packages. If you want to override the default behavior of the config, just pass the empty array when installing the component globally.
151
+
152
+ ``` js
153
+ app .use (VueCodemirror, {
154
+ // keep the global default extensions empty
155
+ extension: []
156
+ })
157
+ ```
133
158
134
159
### Changelog
135
160
136
161
Detailed changes for each release are documented in the [ release notes] ( /CHANGELOG.md ) .
137
162
138
163
### License
139
164
140
- [ MIT] ( /LICENSE )
165
+ Licensed under the [ MIT] ( /LICENSE ) License.
0 commit comments