|
|
@@ -430,6 +430,7 @@ export default {
|
|
|
default: false,
|
|
|
},
|
|
|
},
|
|
|
+ inject: ['processHtmlString'],
|
|
|
data() {
|
|
|
const sidebarIconList = [
|
|
|
{ icon: 'search', title: '搜索', handle: 'getSearch', param: { type: '5' } },
|
|
|
@@ -646,7 +647,7 @@ export default {
|
|
|
({ courseware_info }) => {
|
|
|
this.courseware_info = { ...this.courseware_info, ...courseware_info };
|
|
|
this.getLangList();
|
|
|
- },
|
|
|
+ }
|
|
|
);
|
|
|
},
|
|
|
/**
|
|
|
@@ -656,6 +657,7 @@ export default {
|
|
|
getCoursewareComponentContent_View(id) {
|
|
|
ContentGetCoursewareContent_View({ id }).then(
|
|
|
({ content, component_list, content_group_row_list, title_list }) => {
|
|
|
+ if (title_list) this.title_list = title_list || [];
|
|
|
if (content) {
|
|
|
const _content = JSON.parse(content);
|
|
|
this.data = _content;
|
|
|
@@ -666,7 +668,7 @@ export default {
|
|
|
} else {
|
|
|
this.data = { row_list: [] };
|
|
|
}
|
|
|
-
|
|
|
+ let processHtmlString = typeof this.processHtmlString === 'function' ? this.processHtmlString : null;
|
|
|
if (component_list) this.component_list = component_list;
|
|
|
this.component_list.forEach((x) => {
|
|
|
if (x.component_type === 'audio') {
|
|
|
@@ -684,20 +686,39 @@ export default {
|
|
|
}
|
|
|
|
|
|
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);
|
|
|
+ }
|
|
|
}
|
|
|
});
|
|
|
|
|
|
if (content_group_row_list) this.content_group_row_list = JSON.parse(content_group_row_list) || [];
|
|
|
- if (title_list) this.title_list = title_list || [];
|
|
|
- },
|
|
|
+ }
|
|
|
);
|
|
|
},
|
|
|
-
|
|
|
getLangList() {
|
|
|
GetLanguageTypeList({ book_id: this.courseware_info.book_id, is_contain_zh: 'true' }).then(
|
|
|
({ language_type_list }) => {
|
|
|
this.langList = language_type_list;
|
|
|
- },
|
|
|
+ }
|
|
|
);
|
|
|
},
|
|
|
|
|
|
@@ -810,7 +831,7 @@ export default {
|
|
|
this.$refs.courserware.handleResult(
|
|
|
this.$refs.previewMain.scrollTop,
|
|
|
this.$refs.previewMain.scrollLeft,
|
|
|
- this.select_node,
|
|
|
+ this.select_node
|
|
|
);
|
|
|
},
|
|
|
/**
|
|
|
@@ -1133,7 +1154,7 @@ export default {
|
|
|
x.coursewareId === note.coursewareId &&
|
|
|
x.blockId === note.blockId &&
|
|
|
x.startIndex === note.startIndex &&
|
|
|
- x.endIndex === note.endIndex,
|
|
|
+ x.endIndex === note.endIndex
|
|
|
);
|
|
|
if (old) {
|
|
|
this.oldRichData = old;
|
|
|
@@ -1227,7 +1248,7 @@ export default {
|
|
|
x.coursewareId === collect.coursewareId &&
|
|
|
x.blockId === collect.blockId &&
|
|
|
x.startIndex === collect.startIndex &&
|
|
|
- x.endIndex === collect.endIndex,
|
|
|
+ x.endIndex === collect.endIndex
|
|
|
);
|
|
|
if (old) {
|
|
|
this.$message({
|