aboutsummaryrefslogtreecommitdiff
path: root/resources/vue/components/StudipWysiwyg.vue
diff options
context:
space:
mode:
Diffstat (limited to 'resources/vue/components/StudipWysiwyg.vue')
-rw-r--r--resources/vue/components/StudipWysiwyg.vue20
1 files changed, 18 insertions, 2 deletions
diff --git a/resources/vue/components/StudipWysiwyg.vue b/resources/vue/components/StudipWysiwyg.vue
index e343e80..799c5f1 100644
--- a/resources/vue/components/StudipWysiwyg.vue
+++ b/resources/vue/components/StudipWysiwyg.vue
@@ -2,7 +2,7 @@
<ckeditor
:editor="editor"
:config="editorConfig"
- @ready="prefill"
+ @ready="onReady"
v-model="currentText"
@input="onInput"
/>
@@ -29,11 +29,15 @@ export default {
},
default: 'classic',
},
+ autofocus: Boolean,
},
data() {
return {
currentText: '',
editorConfig: {},
+
+ createdEditor: null,
+ shouldFocus: this.autofocus,
};
},
computed: {
@@ -48,13 +52,25 @@ export default {
},
},
methods: {
- prefill(editor) {
+ onReady(editor) {
+ this.createdEditor = editor;
this.currentText = this.text;
+
+ if (this.shouldFocus) {
+ this.focus();
+ }
},
onInput(value) {
this.currentText = value;
this.$emit('input', value);
},
+ focus() {
+ if (this.createdEditor) {
+ this.createdEditor.focus();
+ } else {
+ this.shouldFocus = true;
+ }
+ }
},
created() {
STUDIP.loadChunk('mathjax');