/*
* XmlDigitalTeaching v0.0.1
* Copyright ©Fri Apr 25 2025 16:10:48 GMT+0800 (中国标准时间) smile
* Released under the ISC License.
*/
import crypto from 'crypto';
import Vue from 'vue';
let componentNamespace = 'xml';
// 组件前缀命名只能更新一次,防止重复执行修改组件注册出错
let isUpdated = false;
// scss 命名不能通过 js 更改,在 SCSS 编译已经打包好了
const cssNamespace = 'xml';
const statePrefix = 'is-';
function createNamespace$1(name, {
prefix,
isUnPrefix
}) {
let useNamespace;
if (!isUpdated) {
isUpdated = true;
useNamespace = prefix || componentNamespace; // 更改前缀
}
if (prefix) {
if (name.indexOf(componentNamespace) === 0) {
return name.replace(componentNamespace, prefix);
}
return useNamespace.charAt(0).toUpperCase() + useNamespace.substr(1) + name;
}
if (name.indexOf(componentNamespace) === 0 || name.indexOf(componentNamespace.charAt(0).toUpperCase()) === 0) {
return name.charAt(0).toUpperCase() + name.substr(1);
}
return isUnPrefix ? name.charAt(0).toLowerCase() + name.substr(1) : componentNamespace + name.charAt(0).toUpperCase() + name.substr(1);
}
/**
* 生成 bem
* @param {} namespace 命名空间
* @param {*} block 块
* @param {*} blockSuffix 块多个单词
* @param {*} element 元素
* @param {*} modifier 修饰符
* @returns
*/
const _bem = (namespace, block, blockSuffix, element, modifier) => {
let cls = `${namespace}-${block}`;
if (blockSuffix) {
cls += `-${blockSuffix}`;
}
if (element) {
cls += `__${element}`;
}
if (modifier) {
cls += `--${modifier}`;
}
return cls;
};
const useNamespace = (block, namespace = cssNamespace) => {
const b = (blockSuffix = '') => _bem(namespace, block, blockSuffix, '', '');
const e = element => element ? _bem(namespace, block, '', element, '') : '';
const m = modifier => modifier ? _bem(namespace, block, '', '', modifier) : '';
const be = (blockSuffix, element) => blockSuffix && element ? _bem(namespace, block, blockSuffix, element, '') : '';
const em = (element, modifier) => element && modifier ? _bem(namespace, block, '', element, modifier) : '';
const bm = (blockSuffix, modifier) => blockSuffix && modifier ? _bem(namespace, block, blockSuffix, '', modifier) : '';
const bem = (blockSuffix, element, modifier) => blockSuffix && element && modifier ? _bem(namespace, block, blockSuffix, element, modifier) : '';
const is = (name, ...args) => {
const state = args.length >= 1 ? args[0] : true;
return name && state ? `${statePrefix}${name}` : '';
};
// for css var
// --el-xxx: value;
const cssVar = object => {
const styles = {};
for (const key in object) {
styles[`--${namespace}-${key}`] = object[key];
}
return styles;
};
// with block
const cssVarBlock = object => {
const styles = {};
for (const key in object) {
styles[`--${namespace}-${block}-${key}`] = object[key];
}
return styles;
};
const cssVarName = name => `--${namespace}-${name}`;
const cssVarBlockName = name => `--${namespace}-${block}-${name}`;
return {
cssNamespace,
componentNamespace,
b,
e,
m,
be,
em,
bm,
bem,
is,
// css
cssVar,
cssVarName,
cssVarBlock,
cssVarBlockName
};
};
// 样式资源包
let chalk = '';
// 默认主题
let defaultTheme = '#409EFF';
const tintColor = (color, tint) => {
color = color.replace('#', '');
let red = parseInt(color.slice(0, 2), 16);
let green = parseInt(color.slice(2, 4), 16);
let blue = parseInt(color.slice(4, 6), 16);
if (tint === 0) {
// when primary color is in its rgb space
return [red, green, blue].join(',');
} else {
red += Math.round(tint * (255 - red));
green += Math.round(tint * (255 - green));
blue += Math.round(tint * (255 - blue));
red = red.toString(16);
green = green.toString(16);
blue = blue.toString(16);
console.log('tintColor return', color, tint, `#${red}${green}${blue}`);
return `#${red}${green}${blue}`;
}
};
const shadeColor = (color, shade) => {
let red = parseInt(color.slice(0, 2), 16);
let green = parseInt(color.slice(2, 4), 16);
let blue = parseInt(color.slice(4, 6), 16);
red = Math.round((1 - shade) * red);
green = Math.round((1 - shade) * green);
blue = Math.round((1 - shade) * blue);
red = red.toString(16);
green = green.toString(16);
blue = blue.toString(16);
console.log('shadeColor return', color, shade, `#${red}${green}${blue}`);
return `#${red}${green}${blue}`;
};
const getThemeCluster = function (theme) {
const clusters = [theme];
for (let i = 0; i <= 9; i++) {
clusters.push(tintColor(theme, Number((i / 10).toFixed(2))));
}
clusters.push(shadeColor(theme, 0.1));
console.log('getThemeCluster return', theme, clusters);
return clusters;
};
const getCSSString = function (url) {
return new Promise(resolve => {
const xhr = new XMLHttpRequest();
xhr.onreadystatechange = () => {
if (xhr.readyState === 4 && xhr.status === 200) {
chalk = xhr.responseText.replace(/@font-face{[^}]+}/, '');
console.log('getCSSString: chalk', chalk);
resolve();
}
};
xhr.onerror = err => {
console.error('样式下载失败', err);
};
xhr.open('GET', url);
xhr.send();
});
};
const updateStyle$1 = function (style, oldCluster, newCluster) {
let newStyle = style;
oldCluster.forEach((color, index) => {
newStyle = newStyle.replace(new RegExp(color, 'ig'), newCluster[index]);
});
console.log('updateStyle: newStyle', newStyle);
return newStyle;
};
const updateElementTheme = async function (options = {}) {
const {
version = '2.15.8',
oldTheme,
primaryColor,
appendDom,
insertBefore,
cssUrl,
chalkStyle = 'chalk-style'
} = options;
if (typeof primaryColor !== 'string') return;
const themeCluster = getThemeCluster(primaryColor.replace('#', ''));
const originalCluster = getThemeCluster((oldTheme || defaultTheme).replace('#', ''));
const chalkHandler = id => {
const newStyle = updateStyle$1(chalk, originalCluster, themeCluster);
// 覆盖原来的样式
chalk = newStyle;
let styleTag = document.querySelector(id);
if (!styleTag) {
styleTag = document.createElement('style');
styleTag.setAttribute('id', id);
if (appendDom) {
if (insertBefore) {
appendDom.parentNode.insertBefore(styleTag, appendDom.nextSibling);
} else {
appendDom.appendChild(styleTag);
}
} else {
document.head.appendChild(styleTag);
}
}
styleTag.innerText = newStyle;
};
if (!chalk) {
const url = cssUrl || `https://unpkg.com/element-ui@${version}/lib/theme-chalk/index.css`;
await getCSSString(url);
}
chalkHandler(chalkStyle);
defaultTheme = primaryColor;
};
const updateUITheme = async function (options) {
const {
oldTheme = '#409EFF',
primaryColor,
primarySecondColor,
opacity = 0.7,
elementUI,
button = {
disabledFontColorPrimary: '#fff',
disabledBgColorPrimary: '#ccc',
disabledFontColorPlain: '#999',
disabledBgColorPlain: '#f5f5f5',
disabledFontColorGhost: '#999',
disabledBorderColorGhost: '#ccc'
}
} = options;
if (!primaryColor) return;
if (elementUI) {
try {
await updateElementTheme({
oldTheme,
primaryColor: primaryColor
});
} catch (err) {
console.error(err);
}
}
// const primaryOpc = colorPalette(primary, opacity)
// 第二种主题透明
const primarySecOpc = primarySecondColor ? tintColor(primarySecondColor, Number((1 - opacity).toFixed(2))) : '';
// const primaryDis = colorPalette(primary, disOpacity)
// const primarySecDis = colorPalette(primarySecondColor, disOpacity)
const primaryLightColors = [];
const el = document.documentElement;
el.style.setProperty(`--${cssNamespace}-color-primary`, primaryColor);
for (let i = 1; i <= 9; i++) {
const color = tintColor(primaryColor, Number((0.1 * i).toFixed(2)));
primaryLightColors.push(color);
el.style.setProperty(`--${cssNamespace}-color-primary-light-${i}`, color);
}
// disabled primary
el.style.setProperty(`--${cssNamespace}-button-disabled-font-color-primary`, button.disabledFontColorPrimary);
el.style.setProperty(`--${cssNamespace}-button-disabled-bg-color-primary`, button.disabledBgColorPrimary);
el.style.setProperty(`--${cssNamespace}-button-disabled-border-color-primary`, button.disabledBgColorPrimary);
// plain
el.style.setProperty(`--${cssNamespace}-button-disabled-font-color-primary-plain`, button.disabledFontColorPlain);
el.style.setProperty(`--${cssNamespace}-button-disabled-bg-color-primary-plain`, button.disabledBgColorPlain);
// ghost
el.style.setProperty(`--${cssNamespace}-button-disabled-font-color-primary-ghost`, button.disabledFontColorGhost);
el.style.setProperty(`--${cssNamespace}-button-disabled-border-color-primary-ghost`, button.disabledBorderColorGhost);
const buttonTheme = {
primary: {
'button-font-color': primarySecondColor ? primaryColor : '#fff',
'button-bg-color': primarySecondColor ? primarySecondColor : primaryColor,
'button-hover-font-color': primarySecondColor ? primaryColor : '#fff',
'button-hover-bg-color': primarySecondColor ? primarySecOpc : primaryLightColors[1],
'button-active-font-color': primarySecondColor ? primaryColor : '#fff',
'button-active-bg-color': primarySecondColor ? primarySecondColor : primaryColor
},
plain: {
'button-font-color-primary': primarySecondColor ? primarySecondColor : primaryColor,
'button-bg-color-primary': primarySecondColor ? primaryLightColors[3] : primaryLightColors[7],
'button-hover-font-color-primary': primarySecondColor ? primarySecondColor : primaryColor,
'button-hover-bg-color-primary': primarySecondColor ? primaryLightColors[4] : primaryLightColors[7],
'button-active-font-color-primary': primarySecondColor ? primarySecondColor : primaryColor,
'button-active-bg-color-primary': primarySecondColor ? primaryLightColors[3] : primaryLightColors[7]
}
};
Object.keys(buttonTheme).forEach(type => {
const item = buttonTheme[type];
Object.keys(item).forEach(property => {
el.style.setProperty(`--${cssNamespace}-${property}-${type}`, item[property]);
});
});
};
const rnds8Pool = new Uint8Array(256); // # of random values to pre-allocate
let poolPtr = rnds8Pool.length;
function rng() {
if (poolPtr > rnds8Pool.length - 16) {
crypto.randomFillSync(rnds8Pool);
poolPtr = 0;
}
return rnds8Pool.slice(poolPtr, poolPtr += 16);
}
var REGEX = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
function validate(uuid) {
return typeof uuid === 'string' && REGEX.test(uuid);
}
/**
* Convert array of 16 byte values to UUID string format of the form:
* XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
*/
const byteToHex = [];
for (let i = 0; i < 256; ++i) {
byteToHex.push((i + 0x100).toString(16).substr(1));
}
function stringify$2(arr, offset = 0) {
// Note: Be careful editing this code! It's been tuned for performance
// and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
const uuid = (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase(); // Consistency check for valid UUID. If this throws, it's likely due to one
// of the following:
// - One or more input array values don't map to a hex octet (leading to
// "undefined" in the uuid)
// - Invalid input values for the RFC `version` or `variant` fields
if (!validate(uuid)) {
throw TypeError('Stringified UUID is invalid');
}
return uuid;
}
function v4(options, buf, offset) {
options = options || {};
const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
rnds[6] = rnds[6] & 0x0f | 0x40;
rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
if (buf) {
offset = offset || 0;
for (let i = 0; i < 16; ++i) {
buf[offset + i] = rnds[i];
}
return buf;
}
return stringify$2(rnds);
}
let _that = {};
/**
*
* @param {
* textBookData:"教材信息",
* catalogList:"目录信息",
* looseLeafData:"所有活页内容",
* isTrial:"是否试读",
* textBookMergeLevel:"教材合并到目录的层级",
* trialChapterList:"试读章节列表"
* }
*
* @returns
*/
const formatTextBook = data => {
// _that = { ..._that, ...data }
_that = {
contentList: [],
componentIndex: 0,
componentTotal: 0,
chapterIndex: 0,
componentList: [],
isTrial: false,
isTrialIndex: 10,
textBookMergeLevel: 1,
trialChapterList: [],
firstLevelLabel: '',
firstLevelChapterId: '',
locationChapterId: '',
locationLabel: '',
injectStyle: '',
readableChapters: [],
textBookResource: {
imageList: [],
audioList: [],
videoList: [],
animationList: [],
curriculumList: [],
resourceList: [],
formulaList: [],
interactionList: [],
questionList: [],
testPaperList: [],
graphList: [],
imageTotal: 0,
audioTotal: 0,
videoTotal: 0,
animationTotal: 0,
curriculumTotal: 0,
resourceTotal: 0,
formulaTotal: 0,
interactionTotal: 0,
questionTotal: 0,
testPaperTotal: 0,
graphTotal: 0,
teachingResourceTotal: 0,
imageCurrent: 0,
audioCurrent: 0,
videoCurrent: 0,
animationCurrent: 0,
curriculumCurrent: 0,
resourceCurrent: 0,
formulaCurrent: 0,
interactionCurrent: 0,
questionCurrent: 0
},
...data
};
return new Promise(resolve => {
const getItemByChild = (list, level, orderNum) => {
for (let i = 0; i < list.length; i++) {
let it = list[i];
if (_that.looseLeafData[it.id] && _that.looseLeafData[it.id].looseLeafInfo) {
if (JSON.parse(_that.looseLeafData[it.id].looseLeafInfo).length > 0) {
// 更新组件总数
_that.componentTotal += JSON.parse(_that.looseLeafData[it.id].looseLeafInfo).length;
it.xmlCompRef = JSON.parse(_that.looseLeafData[it.id].looseLeafInfo)[0].xmlCompRef;
_that.looseLeafData[it.id].label = it.label;
} else {
_that.componentTotal += 1;
it.xmlCompRef = v4();
}
} else {
_that.componentTotal += 1;
it.xmlCompRef = v4();
}
it.chapterOrderNum = orderNum ? orderNum : i;
it.catalogLevel = level;
_that.contentList.push(it);
if (it.children) {
getItemByChild(it.children, level + 1, orderNum ? orderNum : i);
}
}
};
getItemByChild(_that.catalogList, 1, '');
// 处理数据格式
_that.chapterIndex = 0;
formattedData(_that.contentList[0].id, resolve); //@format
});
};
// 处理活页json数据信息 传入id获取数据解析为list
function formattedData(chapterId, resolve) {
let list = [];
if (_that.looseLeafData[chapterId] && _that.looseLeafData[chapterId].looseLeafInfo) {
if (JSON.parse(_that.looseLeafData[chapterId].looseLeafInfo).length > 0) {
list = JSON.parse(_that.looseLeafData[chapterId].looseLeafInfo);
} else {
list = [{
componentsName: 'xml-single-placeholder-group',
xmlCompRef: _that.contentList[_that.chapterIndex].xmlCompRef,
data: {}
}];
}
let moduleAttribute = _that.looseLeafData[chapterId].moduleAttributeInfo || '[]';
if (JSON.parse(moduleAttribute)?.length) {
JSON.parse(moduleAttribute).forEach(module => {
if (module.type === 'component' && module.target === 'xml-single-text-group') {
if (module.data?.injectStyle) {
_that.injectStyle += module.data.injectStyle;
}
}
});
}
} else {
list = [{
componentsName: 'xml-single-placeholder-group',
xmlCompRef: _that.contentList[_that.chapterIndex].xmlCompRef,
data: {}
}];
}
let source = {
imageList: [],
//图片列表
audioList: [],
//音频列表
videoList: [],
//视频列表
animationList: [],
//动画列表
curriculumList: [],
//微课列表
formulaList: [],
//公式列表
interactionList: [],
//互动列表
resourceList: [],
//资源列表
questionList: [],
//试题列表
testPaperList: [],
//试卷列表
graphList: [] //图谱列表
};
if (_that.contentList[_that.chapterIndex].catalogLevel == 1) {
_that.firstLevelLabel = _that.contentList[_that.chapterIndex].label;
_that.firstLevelChapterId = chapterId;
}
// 设置当前位置的章节ID和名称。 若当前目录层级小于等于教材合并到目录的层级
if (_that.contentList[_that.chapterIndex].catalogLevel <= _that.textBookMergeLevel) {
_that.locationChapterId = chapterId;
_that.locationLabel = _that.contentList[_that.chapterIndex].label;
}
let readIndex = Number(_that.componentTotal * (_that.isTrialIndex / 100)).toFixed(0); //可以试读到的组件index
let startIndex = _that.componentIndex;
list.map((element, index) => {
let isTrialExternal = _that.isTrial ? _that.componentIndex < readIndex || _that.trialChapterList.includes(chapterId) ? false : true : false;
// 向数据里添加位置信息,第一位:章节Id 、第二位:模块Id
let location = `xml-digital-teaching/${chapterId}/${element.xmlCompRef}`;
element.location = location;
element.chapterId = chapterId;
element.componentIndex = _that.componentIndex;
element.label = _that.contentList[_that.chapterIndex].label; //章节名字
element.firstLevelId = _that.firstLevelChapterId; //章节所在一级标题的Id
element.firstLevelLabel = _that.firstLevelLabel; //章节所在一级标题的名称
element.locationChapterId = _that.locationChapterId; //当前内容阅读所在目录id
element.locationLabel = _that.locationLabel; //当前内容阅读所在目录名称
element.chapterOrderNum = _that.contentList[_that.chapterIndex].chapterOrderNum; //当前内容阅读所在目录顺序
element.startIndex = startIndex; //章节开始位置
element.endIndex = startIndex + list.length; //章节结束位置
_that.componentIndex++;
// 处理文本图片
const processTextImages = e => {
e?.html?.replace(/
]*src=['"]([^'"]+)[^>]*>/gi, (match, p1) => {
let keyValue = match.split(' ');
let obj = {};
for (let i = 0; i < keyValue.length; i++) {
if (keyValue[i].indexOf('=') !== -1) {
let item = keyValue[i].split('=');
obj[item[0]] = item[1].replace(/\"/g, '').replace(/\/>/g, '');
}
}
if (obj['data-img-type'] == '1') {
source.imageList.push({
chapterId: chapterId,
label: _that.looseLeafData[chapterId].label,
firstLevelId: _that.firstLevelChapterId,
firstLevelLabel: _that.firstLevelLabel,
locationChapterId: _that.locationChapterId,
locationLabel: _that.locationLabel,
isTrialExternal: isTrialExternal,
location: location,
title: obj.alt || '图片',
uploadFileUrl: obj.src,
id: obj.id
});
}
});
};
// 根据不同的组件类型进行处理
if (element.componentsName == 'xml-single-text-group') {
// 文本
element.Text = element.data.pGroupData.textData?.html; //文本内容
processTextImages({
html: element.data.pGroupData.textData?.html
});
if (element.data?.graphLinks?.length) {
let linkWithLocationList = [];
element.data?.graphLinks.forEach((item, index) => {
item.targets.forEach(target => {
linkWithLocationList.push({
...item,
location,
titleClass: 'xml-graph-link',
index,
chapterId,
graphTargetP: target
});
});
});
source.graphList = [...source.graphList, ...linkWithLocationList];
}
} else if (element.componentsName == 'xml-single-image-group') {
// 图片
let textList = [];
element.data.pGroupData.imageData.imageList.map((item, index) => {
item.chapterId = chapterId;
item.label = _that.looseLeafData[chapterId].label;
item.firstLevelId = _that.firstLevelChapterId;
item.firstLevelLabel = _that.firstLevelLabel;
item.locationChapterId = _that.locationChapterId;
item.locationLabel = _that.locationLabel;
item.isTrialExternal = isTrialExternal;
item.location = location;
item.titleClass = 'xml-image-title';
item.index = index;
textList.push({
title: item.title,
titleClass: 'xml-image-title',
index: index
});
});
if (element.data.pGroupData.imageData.imgType != '0') {
source.imageList = source.imageList.concat(element.data.pGroupData.imageData.imageList);
}
element.textList = textList;
} else if (element.componentsName == 'xml-single-music-group') {
// 音频
let textList = [];
element.data.pGroupData.musicData.musicSetList.map((item, index) => {
item.chapterId = chapterId;
item.label = _that.looseLeafData[chapterId].label;
item.firstLevelId = _that.firstLevelChapterId;
item.firstLevelLabel = _that.firstLevelLabel;
item.locationChapterId = _that.locationChapterId;
item.locationLabel = _that.locationLabel;
item.isTrialExternal = isTrialExternal;
item.location = location;
item.titleClass = 'xml-audio-title';
item.index = index;
textList.push({
title: item.title,
titleClass: 'xml-audio-title',
index: index
});
});
source.audioList = source.audioList.concat(element.data.pGroupData.musicData.musicSetList);
element.textList = textList;
} else if (element.componentsName == 'xml-single-video-group') {
// 视频
let textList = [];
element.data.pGroupData.videoData.videoSetList.map((item, index) => {
item.chapterId = chapterId;
item.label = _that.looseLeafData[chapterId].label;
item.firstLevelId = _that.firstLevelChapterId;
item.firstLevelLabel = _that.firstLevelLabel;
item.locationChapterId = _that.locationChapterId;
item.locationLabel = _that.locationLabel;
item.isTrialExternal = isTrialExternal;
item.location = location;
item.titleClass = 'xml-video-title';
item.index = index;
textList.push({
title: item.title,
titleClass: 'xml-video-title',
index: index
});
});
if (element.data.pGroupData.videoData.videoType == '1') {
source.curriculumList = source.curriculumList.concat(element.data.pGroupData.videoData.videoSetList);
} else if (element.data.pGroupData.videoData.videoType == '2') {
source.animationList = source.animationList.concat(element.data.pGroupData.videoData.videoSetList);
} else {
source.videoList = source.videoList.concat(element.data.pGroupData.videoData.videoSetList);
}
element.textList = textList;
} else if (element.componentsName == 'xml-single-resource-group') {
// 资源
let textList = [];
element.data.pGroupData.resourceData.resourceSetList.map((item, index) => {
item.chapterId = chapterId;
item.label = _that.looseLeafData[chapterId].label;
item.firstLevelId = _that.firstLevelChapterId;
item.firstLevelLabel = _that.firstLevelLabel;
item.locationChapterId = _that.locationChapterId;
item.locationLabel = _that.locationLabel;
item.isTrialExternal = isTrialExternal;
item.location = location;
item.titleClass = 'xml-resource-title';
item.index = index;
item.ilk = 'resource';
let title = item.title || item.fileFormat;
textList.push({
title: title,
titleClass: 'xml-resource-title',
index: index
});
});
source.resourceList = source.resourceList.concat(element.data.pGroupData.resourceData.resourceSetList);
element.textList = textList;
} else if (element.componentsName == 'xml-single-book-group') {
// 电子书
let textList = [];
element.data.pGroupData.ebookData.ebookSetList.map((item, index) => {
item.chapterId = chapterId;
item.label = _that.looseLeafData[chapterId].label;
item.firstLevelId = _that.firstLevelChapterId;
item.firstLevelLabel = _that.firstLevelLabel;
item.locationChapterId = _that.locationChapterId;
item.locationLabel = _that.locationLabel;
item.isTrialExternal = isTrialExternal;
item.location = location;
item.titleClass = 'xml-ebook-title';
item.index = index;
item.ilk = 'ebook';
let title = item.title || item.name;
textList.push({
title: title,
titleClass: 'xml-ebook-title',
index: index
});
});
source.resourceList = source.resourceList.concat(element.data.pGroupData.ebookData.ebookSetList);
element.textList = textList;
} else if (element.componentsName == 'xml-single-question-group') {
// 试题
let textList = [];
element.data.pGroupData.questionData.questionSetList.map((item, index) => {
item.chapterId = chapterId;
item.label = _that.looseLeafData[chapterId].label;
item.firstLevelId = _that.firstLevelChapterId;
item.firstLevelLabel = _that.firstLevelLabel;
item.locationChapterId = _that.locationChapterId;
item.locationLabel = _that.locationLabel;
item.isTrialExternal = isTrialExternal;
item.location = location;
item.titleClass = 'xml-question-title';
item.index = index;
textList.push({
title: item.stem.content,
titleClass: 'xml-question-title',
index: index
});
});
source.questionList = source.questionList.concat(element.data.pGroupData.questionData.questionSetList);
element.textList = textList;
} else if (element.componentsName == 'xml-single-test-paper-group') {
// 试卷
let textList = [];
element.data.pGroupData.testPaperData.testPaperSetList.map((item, index) => {
item.chapterId = chapterId;
item.label = _that.looseLeafData[chapterId].label;
item.firstLevelId = _that.firstLevelChapterId;
item.firstLevelLabel = _that.firstLevelLabel;
item.locationChapterId = _that.locationChapterId;
item.locationLabel = _that.locationLabel;
item.isTrialExternal = isTrialExternal;
item.location = location;
item.titleClass = 'xml-paper-title';
item.index = index;
textList.push({
title: item.paperName,
titleClass: 'xml-paper-title',
index: index
});
});
source.testPaperList = source.testPaperList.concat(element.data.pGroupData.testPaperData.testPaperSetList);
element.textList = textList;
} else if (element.componentsName == 'xml-single-hotzone-group') {
//热区
let textList = [];
element.data.pGroupData.xmlBlockData.imageList.map((item, index) => {
textList.push({
title: item.title,
titleClass: 'xml-hot-zone-title',
index: index
});
});
element.textList = textList;
} else if (element.componentsName == 'xml-single-html-group') {
// element={
// ...element,
// data: {
// ...element.data,
// pGroupData: {
// ...element.data.pGroupData,
// htmlData: {
// ...element.data.pGroupData.htmlData,
// code: element.data.pGroupData.htmlData.code.replace(/