Skip to content
Snippets Groups Projects
Commit 96bca3ad authored by Jan-Hendrik Willms's avatar Jan-Hendrik Willms
Browse files

fixes #4020

Closes #4020

Merge request studip/studip!2869
parent 647f8332
No related branches found
No related tags found
No related merge requests found
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<ckeditor <ckeditor
:editor="editor" :editor="editor"
:config="editorConfig" :config="editorConfig"
@ready="prefill" @ready="onReady"
v-model="currentText" v-model="currentText"
@input="onInput" @input="onInput"
/> />
...@@ -29,11 +29,15 @@ export default { ...@@ -29,11 +29,15 @@ export default {
}, },
default: 'classic', default: 'classic',
}, },
autofocus: Boolean,
}, },
data() { data() {
return { return {
currentText: '', currentText: '',
editorConfig: {}, editorConfig: {},
createdEditor: null,
shouldFocus: this.autofocus,
}; };
}, },
computed: { computed: {
...@@ -48,13 +52,25 @@ export default { ...@@ -48,13 +52,25 @@ export default {
}, },
}, },
methods: { methods: {
prefill(editor) { onReady(editor) {
this.createdEditor = editor;
this.currentText = this.text; this.currentText = this.text;
if (this.shouldFocus) {
this.focus();
}
}, },
onInput(value) { onInput(value) {
this.currentText = value; this.currentText = value;
this.$emit('input', value); this.$emit('input', value);
}, },
focus() {
if (this.createdEditor) {
this.createdEditor.focus();
} else {
this.shouldFocus = true;
}
}
}, },
created() { created() {
STUDIP.loadChunk('mathjax'); STUDIP.loadChunk('mathjax');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment