Skip to content

Commit 59d5fd8

Browse files
committed
feat: add phrases prop
1 parent 12b1ef3 commit 59d5fd8

File tree

5 files changed

+24
-19
lines changed

5 files changed

+24
-19
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
## CHANGELOG
22

3+
### v6.1.0 (2022-08-27)
4+
5+
- feat: add `phrases` prop [#166](https://github.com/surmon-china/vue-codemirror/pull/166)
6+
37
### v6.0.2 (2022-07-27)
48

59
- fix: Use the correct global component name [#161](https://github.com/surmon-china/vue-codemirror/discussions/161)

README.md

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,13 @@ import { EditorState } from '@codemirror/state'
111111
setup() {
112112
const code = ref(`console.log('Hello, world!')`)
113113
const extensions = [javascript(), oneDark]
114-
114+
115115
// Codemirror EditorView instance ref
116116
const view = shallowRef()
117117
const handleReady = (payload) => {
118118
view.value = payload.view
119119
}
120-
120+
121121
// Status is available at all times via Codemirror EditorView
122122
const getCodemirrorStates = () => {
123123
const state = view.value.state
@@ -164,19 +164,20 @@ app.use(VueCodemirror, {
164164

165165
### Component Props
166166

167-
| prop | description | type | default |
168-
| :------------ | :----------------------------------------------------------------------- | :----------------------- | :------ |
169-
| modelValue | The input values accepted by the component also support two-way binding. | `String` | `''` |
170-
| autofocus | Focus editor immediately after mounted. | `Boolean` | `false` |
171-
| disabled | Disable input behavior and disable change state. | `Boolean` | `false` |
172-
| indentWithTab | Bind keyboard Tab key event. | `Boolean` | `true` |
173-
| tabSize | Specify the indent when the Tab key is pressed. | `Number` | `2` |
174-
| placeholder | Display when empty. | `String` | `''` |
175-
| style | The CSS style object that acts on the CodeMirror itself. | `Object` | `{}` |
176-
| autoDestroy | Auto destroy the CodeMirror instance before the component unmount. | `Boolean` | `true` |
177-
| extensions | Passed to CodeMirror `EditorState.create({ extensions })` | `Extension` | `[]` |
178-
| selection | Passed to CodeMirror `EditorState.create({ selection })` | `EditorSelection` | - |
179-
| root | Passed to CodeMirror `new EditorView({ root })` | `ShadowRoot \| Document` | - |
167+
| prop | description | type | default |
168+
| :------------ | :------------------------------------------------------------------------------------- | :----------------------- | :------ |
169+
| modelValue | The input values accepted by the component also support two-way binding. | `String` | `''` |
170+
| autofocus | Focus editor immediately after mounted. | `Boolean` | `false` |
171+
| disabled | Disable input behavior and disable change state. | `Boolean` | `false` |
172+
| indentWithTab | Bind keyboard Tab key event. | `Boolean` | `true` |
173+
| tabSize | Specify the indent when the Tab key is pressed. | `Number` | `2` |
174+
| placeholder | Display when empty. | `String` | `''` |
175+
| style | The CSS style object that acts on the CodeMirror itself. | `Object` | `{}` |
176+
| phrases | Codemirror [internationalization phrases](https://codemirror.net/examples/translate/). | `Object` | `{}` |
177+
| autoDestroy | Auto destroy the CodeMirror instance before the component unmount. | `Boolean` | `true` |
178+
| extensions | Passed to CodeMirror `EditorState.create({ extensions })` | `Extension` | `[]` |
179+
| selection | Passed to CodeMirror `EditorState.create({ selection })` | `EditorSelection` | - |
180+
| root | Passed to CodeMirror `new EditorView({ root })` | `ShadowRoot \| Document` | - |
180181

181182
### Component Events
182183

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "vue-codemirror",
33
"description": "CodeMirror code editor component for Vue",
4-
"version": "6.0.2",
4+
"version": "6.1.0",
55
"author": "Surmon",
66
"license": "MIT",
77
"keywords": [

src/component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ export default defineComponent({
100100
// watch prop.phrases
101101
watch(
102102
() => config.value.phrases,
103-
(phrases) => editorTools.setPhrases(phrases!),
103+
(phrases) => editorTools.setPhrases(phrases || {}),
104104
{ immediate: true }
105105
)
106106

src/props.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ export const configProps = {
1616
placeholder: String,
1717
style: Object as PropType<CSS.Properties>,
1818
autoDestroy: NonDefaultBooleanType,
19+
phrases: Object as PropType<Record<string, string>>,
1920
// codemirror options
2021
root: Object as PropType<ShadowRoot | Document>,
2122
extensions: Array as PropType<EditorStateConfig['extensions']>,
22-
selection: Object as PropType<EditorStateConfig['selection']>,
23-
phrases: Object
23+
selection: Object as PropType<EditorStateConfig['selection']>
2424
}
2525

2626
export const modelValueProp = {

0 commit comments

Comments
 (0)