Commit fd91565e authored by NGPixel's avatar NGPixel

fix: ckeditor - beautify html before saving

parent 281172a9
...@@ -19,6 +19,7 @@ import _ from 'lodash' ...@@ -19,6 +19,7 @@ import _ from 'lodash'
import { get, sync } from 'vuex-pathify' import { get, sync } from 'vuex-pathify'
import DecoupledEditor from '@requarks/ckeditor5' import DecoupledEditor from '@requarks/ckeditor5'
import EditorConflict from './ckeditor/conflict.vue' import EditorConflict from './ckeditor/conflict.vue'
import { html as beautify } from 'js-beautify/js/lib/beautifier.min.js'
/* global siteLangs */ /* global siteLangs */
...@@ -81,7 +82,7 @@ export default { ...@@ -81,7 +82,7 @@ export default {
} }
this.editor.model.document.on('change:data', _.debounce(evt => { this.editor.model.document.on('change:data', _.debounce(evt => {
this.$store.set('editor/content', this.editor.getData()) this.$store.set('editor/content', beautify(this.editor.getData(), { indent_size: 2, end_with_newline: true }))
}, 300)) }, 300))
this.$root.$on('editorInsert', opts => { this.$root.$on('editorInsert', opts => {
......
...@@ -248,6 +248,7 @@ ...@@ -248,6 +248,7 @@
"i18next-xhr-backend": "3.2.2", "i18next-xhr-backend": "3.2.2",
"ignore-loader": "0.1.2", "ignore-loader": "0.1.2",
"jest": "25.4.0", "jest": "25.4.0",
"js-beautify": "1.11.0",
"js-cookie": "2.2.1", "js-cookie": "2.2.1",
"mermaid": "8.5.0", "mermaid": "8.5.0",
"mini-css-extract-plugin": "0.9.0", "mini-css-extract-plugin": "0.9.0",
......
This diff was suppressed by a .gitattributes entry.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment