Merge pull request #4646 from dataease/pr@dev@fix_rich-text

fix(仪表板):修复部分富文本组件样式无法保存问题
This commit is contained in:
王嘉豪 2023-02-27 16:32:55 +08:00 committed by GitHub
commit b8ee001f2a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 4 deletions

View File

@ -37,7 +37,6 @@ import 'tinymce/plugins/nonbreaking'
import 'tinymce/plugins/pagebreak'
import { mapState } from 'vuex'
import Vue from 'vue'
import xssCheck from 'xss'
export default {
name: 'DeRichText',
@ -78,7 +77,7 @@ export default {
canEdit: false,
//
tinymceId: 'tinymce-' + this.element.id,
myValue: xssCheck(this.propValue),
myValue: this.propValue,
init: {
selector: '#tinymce-' + this.element.id,
toolbar_items_size: 'small',

View File

@ -38,7 +38,6 @@ import 'tinymce/plugins/pagebreak'
import { mapState } from 'vuex'
import bus from '@/utils/bus'
import { uuid } from 'vue-uuid'
import xssCheck from 'xss'
export default {
name: 'DeRichTextView',
@ -140,6 +139,10 @@ export default {
}
},
myValue(newValue) {
if (this.canEdit) {
const ed = tinymce.editors[this.tinymceId]
this.element.propValue.textValue = ed.getContent()
}
this.initReady && this.$store.commit('canvasChange')
}
},
@ -153,7 +156,7 @@ export default {
viewInit() {
bus.$on('fieldSelect-' + this.element.propValue.viewId, this.fieldSelect)
tinymce.init({})
this.myValue = xssCheck(this.assignment(this.element.propValue.textValue))
this.myValue = this.assignment(this.element.propValue.textValue)
bus.$on('initCurFields-' + this.element.id, this.initCurFieldsChange)
this.$nextTick(() => {
this.initReady = true

View File

@ -10,6 +10,7 @@ import { uuid } from 'vue-uuid'
import store from '@/store'
import { AIDED_DESIGN, MOBILE_SETTING, PAGE_LINE_DESIGN, PANEL_CHART_INFO, TAB_COMMON_STYLE } from '@/views/panel/panel'
import html2canvas from 'html2canvasde'
import xssCheck from 'xss'
export function deepCopy(target) {
if (typeof target === 'object' && target !== null) {
@ -101,6 +102,9 @@ export function panelDataPrepare(componentData, componentStyle, callback) {
componentStyle.chartCommonStyle = deepCopy(COMMON_BACKGROUND)
}
componentData.forEach((item, index) => {
if (item.component && item.component === 'v-text') {
item.propValue = xssCheck(item.propValue)
}
if (item.component && item.component === 'de-date') {
const widget = ApplicationContext.getService(item.serviceName)
if (item.options.attrs &&