|
@@ -154,6 +154,48 @@ const findElementById = (id, topics) => {
|
|
return curElement;
|
|
return curElement;
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+const checkElementisCovered = (id, type) => {
|
|
|
|
+ const elementDom = document.getElementById(id);
|
|
|
|
+
|
|
|
|
+ if (type === "EXPLAIN") {
|
|
|
|
+ const elemTitleDome = elementDom.querySelector(".elem-title");
|
|
|
|
+ const limitHeight = elemTitleDome
|
|
|
|
+ ? elementDom.offsetHeight - elemTitleDome.offsetHeight
|
|
|
|
+ : elementDom.offsetHeight;
|
|
|
|
+
|
|
|
|
+ let elementHeights = [];
|
|
|
|
+ elementDom
|
|
|
|
+ .querySelector(".elem-explain-elements")
|
|
|
|
+ .childNodes.forEach(node => {
|
|
|
|
+ if (!node.className.includes("elem-explain-element")) return;
|
|
|
|
+ elementHeights.push(
|
|
|
|
+ node.firstChild.offsetHeight + node.firstChild.offsetTop
|
|
|
|
+ );
|
|
|
|
+ });
|
|
|
|
+ return elementHeights.some(item => item > limitHeight);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (type === "COMPOSITION") {
|
|
|
|
+ const elemTitleDome = elementDom.querySelector(".elem-title");
|
|
|
|
+ const limitHeight = elemTitleDome
|
|
|
|
+ ? elementDom.offsetHeight - elemTitleDome.offsetHeight
|
|
|
|
+ : elementDom.offsetHeight;
|
|
|
|
+
|
|
|
|
+ let elementHeights = [];
|
|
|
|
+ elementDom
|
|
|
|
+ .querySelector(".elem-composition-elements")
|
|
|
|
+ .childNodes.forEach(node => {
|
|
|
|
+ if (!node.className.includes("elem-composition-element")) return;
|
|
|
|
+ elementHeights.push(
|
|
|
|
+ node.firstChild.offsetHeight + node.firstChild.offsetTop
|
|
|
|
+ );
|
|
|
|
+ });
|
|
|
|
+ return elementHeights.some(item => item > limitHeight);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return elementDom.offsetHeight < elementDom.firstChild.offsetHeight;
|
|
|
|
+};
|
|
|
|
+
|
|
const createFunc = {
|
|
const createFunc = {
|
|
EXPLAIN(element) {
|
|
EXPLAIN(element) {
|
|
return getExplainElements(element);
|
|
return getExplainElements(element);
|
|
@@ -349,6 +391,16 @@ const actions = {
|
|
const columnElements = state.topics[pos].elements;
|
|
const columnElements = state.topics[pos].elements;
|
|
const childIndex = columnElements.findIndex(item => item.id === element.id);
|
|
const childIndex = columnElements.findIndex(item => item.id === element.id);
|
|
element.id = getElementId();
|
|
element.id = getElementId();
|
|
|
|
+ // 作文题中的多线条和网格元素重新计算高度。
|
|
|
|
+ if (element.container.type === "COMPOSITION") {
|
|
|
|
+ if (element.type === "LINES") {
|
|
|
|
+ element.h = element.lineCount * (element.lineSpacing + 1);
|
|
|
|
+ }
|
|
|
|
+ if (element.type === "GRIDS") {
|
|
|
|
+ element.h =
|
|
|
|
+ element.rowCount * (element.columnSize + 1 + element.rowSpace) + 1;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
if (childIndex === -1) {
|
|
if (childIndex === -1) {
|
|
columnElements.push(element);
|
|
columnElements.push(element);
|
|
} else {
|
|
} else {
|
|
@@ -510,10 +562,10 @@ const actions = {
|
|
element.w = elementDom.offsetWidth;
|
|
element.w = elementDom.offsetWidth;
|
|
// 解答题小题与其他题有些区别。
|
|
// 解答题小题与其他题有些区别。
|
|
// 其他题都是通过内部子元素自动撑高元件,而解答题则需要手动设置高度。
|
|
// 其他题都是通过内部子元素自动撑高元件,而解答题则需要手动设置高度。
|
|
- const ESCAPE_ELEMENTS = ["EXPLAIN", "CARD_HEAD", "COMPOSITION"];
|
|
|
|
|
|
+ const ESCAPE_ELEMENTS = ["CARD_HEAD"];
|
|
element.isCovered =
|
|
element.isCovered =
|
|
!ESCAPE_ELEMENTS.includes(element.type) &&
|
|
!ESCAPE_ELEMENTS.includes(element.type) &&
|
|
- elementDom.offsetHeight < elementDom.firstChild.offsetHeight;
|
|
|
|
|
|
+ checkElementisCovered(`preview-${element.id}`, element.type);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
@@ -621,7 +673,7 @@ const actions = {
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
|
|
-export { fetchSameSerialNumberChildrenPositionInfo };
|
|
|
|
|
|
+export { fetchSameSerialNumberChildrenPositionInfo, checkElementisCovered };
|
|
|
|
|
|
export default {
|
|
export default {
|
|
namespaced: true,
|
|
namespaced: true,
|