|
|
@@ -1,6 +1,6 @@
|
|
|
<template>
|
|
|
<div class="common-preview">
|
|
|
- <div class="audit-content" >
|
|
|
+ <div class="audit-content">
|
|
|
<div ref="previewMain" class="main-container" :style="{ paddingLeft: '0', paddingRight: '0' }">
|
|
|
<main :class="['preview-main', 'no-audit']" :style="computedCommonPreviewStyle">
|
|
|
<div class="preview-left" :style="{ backgroundColor: background.background?.is_global ? '' : '#fff' }"></div>
|
|
|
@@ -8,10 +8,10 @@
|
|
|
ref="courseware"
|
|
|
:is-show-group="false"
|
|
|
:group-show-all="true"
|
|
|
- :group-row-list="contentGroupRowList"
|
|
|
+ :group-row-list="groupRowList"
|
|
|
:data="data"
|
|
|
:courseware-id="curSelectId"
|
|
|
- :component-list="componentList"
|
|
|
+ :component-list="cList"
|
|
|
:background="background"
|
|
|
:can-remark="false"
|
|
|
:show-remark="false"
|
|
|
@@ -35,7 +35,7 @@ import { isTrue } from '@/utils/validate';
|
|
|
import { buildCoursewareStyle } from '@/views/book/courseware/preview/common/utils/coursewareStyle';
|
|
|
|
|
|
export default {
|
|
|
- name: 'CommonPreview',
|
|
|
+ name: 'BookEep',
|
|
|
components: {
|
|
|
CoursewarePreview,
|
|
|
},
|
|
|
@@ -55,10 +55,15 @@ export default {
|
|
|
type: String,
|
|
|
default: '',
|
|
|
},
|
|
|
+ // 组件内容
|
|
|
+ content: {
|
|
|
+ type: String,
|
|
|
+ default: '',
|
|
|
+ },
|
|
|
// 内容分组行列表
|
|
|
contentGroupRowList: {
|
|
|
- type: Array,
|
|
|
- default: () => [],
|
|
|
+ type: String,
|
|
|
+ default: '',
|
|
|
},
|
|
|
// 组件列表
|
|
|
componentList: {
|
|
|
@@ -66,14 +71,59 @@ export default {
|
|
|
default: () => [],
|
|
|
},
|
|
|
// 教材背景
|
|
|
- background: {
|
|
|
- type: Object,
|
|
|
- default: () => ({}),
|
|
|
+ bookBackground: {
|
|
|
+ type: String,
|
|
|
+ default: '',
|
|
|
},
|
|
|
},
|
|
|
data() {
|
|
|
+ const processHtmlString = this.processHtmlString;
|
|
|
+ const cList = this.componentList || [];
|
|
|
+ cList.forEach((x) => {
|
|
|
+ if (x.component_type === 'audio') {
|
|
|
+ let _c = JSON.parse(x.content);
|
|
|
+ let p = _c.property || {};
|
|
|
+ if (!p.file_name_display_mode) p.file_name_display_mode = 'true';
|
|
|
+ if (p.view_method === 'independent' && !p.style_mode) {
|
|
|
+ p.style_mode = 'middle';
|
|
|
+ }
|
|
|
+ if (!p.style_mode) p.style_mode = 'big';
|
|
|
+ if (p.view_method === 'icon') {
|
|
|
+ p.file_name_display_mode = 'false';
|
|
|
+ p.view_method = 'independent';
|
|
|
+ p.style_mode = 'small';
|
|
|
+ }
|
|
|
+
|
|
|
+ x.content = JSON.stringify(_c);
|
|
|
+ } else if (x.component_type === 'richtext') {
|
|
|
+ if (!processHtmlString) return;
|
|
|
+ let _c = JSON.parse(x.content);
|
|
|
+ let p = _c.property || {};
|
|
|
+ let lev = Number(p.title_style_level);
|
|
|
+ if (p.is_title !== 'true' || lev < 1 || !_c.content) return;
|
|
|
+
|
|
|
+ let style = this.title_list.find((y) => y.level === lev) || {};
|
|
|
+ if (style && style.style) {
|
|
|
+ style = JSON.parse(style.style);
|
|
|
+ let c_text = _c.content;
|
|
|
+
|
|
|
+ const parser = new DOMParser();
|
|
|
+ const doc = parser.parseFromString(c_text, 'text/html');
|
|
|
+ const body = doc.body;
|
|
|
+ const pElements = body.querySelectorAll('p');
|
|
|
+ processHtmlString(pElements, style);
|
|
|
+ _c.content = body.innerHTML;
|
|
|
+
|
|
|
+ x.content = JSON.stringify(_c);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
return {
|
|
|
- data: { row_list: [] },
|
|
|
+ background: this.bookBackground.length > 0 ? JSON.parse(this.bookBackground) : {},
|
|
|
+ groupRowList: this.contentGroupRowList.length > 0 ? JSON.parse(this.contentGroupRowList) : [],
|
|
|
+ data: this.content.length > 0 ? JSON.parse(this.content) : { row_list: [] },
|
|
|
+ cList,
|
|
|
curSelectId: this.id,
|
|
|
isTrue,
|
|
|
sidebarShow: true,
|
|
|
@@ -112,6 +162,29 @@ export default {
|
|
|
convertText(text) {
|
|
|
return text;
|
|
|
},
|
|
|
+
|
|
|
+ processHtmlString(pElements, styleConfig, isClear = false) {
|
|
|
+ const _pElements = pElements || [];
|
|
|
+ _pElements.forEach((pElement) => {
|
|
|
+ if (pElement.innerHTML !== '<br data-mce-bogus="1">') {
|
|
|
+ pElement.innerHTML = pElement.innerText;
|
|
|
+ }
|
|
|
+ if (isClear) {
|
|
|
+ pElement.removeAttribute('style');
|
|
|
+ pElement.removeAttribute('data-mce-style');
|
|
|
+ } else {
|
|
|
+ const style = pElement.style;
|
|
|
+
|
|
|
+ if (styleConfig.font) style.fontFamily = styleConfig.font;
|
|
|
+ if (styleConfig.font_size) style.fontSize = styleConfig.font_size;
|
|
|
+ if (styleConfig.text_color) style.color = styleConfig.text_color;
|
|
|
+
|
|
|
+ style.fontWeight = styleConfig.bold === 'true' ? 'bold' : 'normal';
|
|
|
+ style.fontStyle = styleConfig.italic === 'true' ? 'italic' : 'normal';
|
|
|
+ if (styleConfig.indent || styleConfig.indent === 0) style.marginLeft = `${styleConfig.indent}px`;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
},
|
|
|
};
|
|
|
</script>
|