diff --git a/dev/App.vue b/dev/App.vue
index 9769676..6a6fe62 100644
--- a/dev/App.vue
+++ b/dev/App.vue
@@ -1,50 +1,88 @@
@@ -97,6 +135,14 @@
+
+
+
+
@@ -111,6 +157,7 @@
:disabled="state.disabled"
:style="{ backgroundColor: state.backgroundColor }"
:extensions="extensions"
+ :phrases="state.phrases === 'en-us' ? {} : germanPhrases"
v-model="code"
@ready="handleReady"
@change="consoleLog('change', $event)"
@@ -122,47 +169,47 @@
diff --git a/src/codemirror.ts b/src/codemirror.ts
index 7a98f29..535ec83 100644
--- a/src/codemirror.ts
+++ b/src/codemirror.ts
@@ -96,6 +96,13 @@ export const getEditorTools = (view: EditorView) => {
reTabSize([EditorState.tabSize.of(tabSize), indentUnit.of(' '.repeat(tabSize))])
}
+ // phrases
+ // https://codemirror.net/examples/translate/
+ const { run: rePhrases } = createEditorCompartment(view)
+ const setPhrases = (phrases: Record) => {
+ rePhrases([EditorState.phrases.of(phrases)])
+ }
+
// set editor's placeholder
const { run: rePlaceholder } = createEditorCompartment(view)
const setPlaceholder = (value: string) => {
@@ -117,6 +124,7 @@ export const getEditorTools = (view: EditorView) => {
toggleDisabled,
toggleIndentWithTab,
setTabSize,
+ setPhrases,
setPlaceholder,
setStyle
}
diff --git a/src/component.ts b/src/component.ts
index 016abd8..4c6ccd0 100644
--- a/src/component.ts
+++ b/src/component.ts
@@ -97,6 +97,13 @@ export default defineComponent({
{ immediate: true }
)
+ // watch prop.phrases
+ watch(
+ () => config.value.phrases,
+ (phrases) => editorTools.setPhrases(phrases!),
+ { immediate: true }
+ )
+
// watch prop.placeholder
watch(
() => config.value.placeholder,
diff --git a/src/props.ts b/src/props.ts
index 5ede91c..e4564df 100644
--- a/src/props.ts
+++ b/src/props.ts
@@ -19,7 +19,8 @@ export const configProps = {
// codemirror options
root: Object as PropType,
extensions: Array as PropType,
- selection: Object as PropType
+ selection: Object as PropType,
+ phrases: Object
}
export const modelValueProp = {