Skip to content

Commit 1135bdf

Browse files
authored
fix (#4098)
1 parent e4ef26f commit 1135bdf

3 files changed

Lines changed: 4 additions & 2 deletions

File tree

app/assets/javascripts/admin/plugins/codemirror.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
//= require codemirror/mode/css/css
44
//= require codemirror/mode/htmlmixed/htmlmixed
55
//= require codemirror/mode/sass/sass
6+
//= require codemirror/addon/display/autorefresh
67

78
/*global CodeMirror */
89

app/javascript/apps/blocks-editor/components/Editor.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ export default {
157157
},
158158
159159
wireCancelButtons(root) {
160-
// The `.vue__changes__cancel` button closes the offcanvas.
161160
root.querySelectorAll('.vue__editor__actions__cancel').forEach((button) => {
162161
button.addEventListener('click', (event) => {
163162
event.preventDefault();

app/javascript/apps/blocks-editor/components/inputs/CodeInput.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,12 @@ export default {
3030
},
3131
},
3232
mounted() {
33+
this.$refs.textarea.value = this.modelValue || '';
34+
3335
const config = window.codemirrorManager.defaultConfig();
3436
config.mode = 'htmlmixed';
37+
config.autoRefresh = true;
3538
this.editor = window.CodeMirror.fromTextArea(this.$refs.textarea, config);
36-
this.editor.setValue(this.modelValue || '');
3739
this.editor.on('change', (instance) => {
3840
this.$emit('update:modelValue', instance.getValue());
3941
});

0 commit comments

Comments
 (0)