mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-16 17:10:53 +08:00
This commit is contained in:
parent
42065d6daa
commit
b43f5112bb
@ -17,6 +17,7 @@ import {preventScroll} from "../scroll/preventScroll";
|
||||
import {restoreScroll} from "../scroll/saveScroll";
|
||||
import {removeLoading} from "../ui/initUI";
|
||||
import {isMobile} from "../../util/functions";
|
||||
import {foldPassiveType} from "../wysiwyg/renderBacklink";
|
||||
|
||||
export const onGet = (data: IWebSocketData, protyle: IProtyle, action: string[] = [], scrollAttr?: IScrollAttr, renderTitle = false) => {
|
||||
protyle.wysiwyg.element.removeAttribute("data-top");
|
||||
@ -182,25 +183,7 @@ const setHTML = (options: {
|
||||
protyle.wysiwyg.element.innerHTML = options.content;
|
||||
}
|
||||
if (options.action.includes(Constants.CB_GET_BACKLINK)) {
|
||||
if (protyle.wysiwyg.element.firstElementChild.classList.contains("li")) {
|
||||
if (options.expand) {
|
||||
const thirdLiElement = protyle.wysiwyg.element.querySelector(".li .li .li");
|
||||
if (thirdLiElement) {
|
||||
thirdLiElement.setAttribute("fold", "1");
|
||||
}
|
||||
} else {
|
||||
protyle.wysiwyg.element.firstElementChild.setAttribute("fold", "1");
|
||||
}
|
||||
} else if (protyle.wysiwyg.element.firstElementChild.getAttribute("data-type") === "NodeHeading") {
|
||||
Array.from(protyle.wysiwyg.element.children).forEach((item, index) => {
|
||||
if ((options.expand && index > 2) || (!options.expand && index > 1)) {
|
||||
if ((options.expand && index === 3) || (!options.expand && index === 2)) {
|
||||
item.insertAdjacentHTML("beforebegin", '<div style="max-width: 100%;justify-content: center;" contenteditable="false" class="protyle-breadcrumb__item"><svg><use xlink:href="#iconMore"></use></svg></div>');
|
||||
}
|
||||
item.classList.add("fn__none");
|
||||
}
|
||||
});
|
||||
}
|
||||
foldPassiveType(options.expand, protyle.wysiwyg.element);
|
||||
}
|
||||
processRender(protyle.wysiwyg.element);
|
||||
highlightRender(protyle.wysiwyg.element);
|
||||
|
@ -27,21 +27,20 @@ export const renderBacklink = (protyle: IProtyle, backlinkData: {
|
||||
}
|
||||
};
|
||||
|
||||
const setBacklinkFold = (html: string, expand: boolean) => {
|
||||
const tempDom = document.createElement("template");
|
||||
tempDom.innerHTML = html;
|
||||
if (tempDom.content.firstElementChild.classList.contains("li")) {
|
||||
// 传递型折叠处理
|
||||
export const foldPassiveType = (expand: boolean, element: HTMLElement | DocumentFragment) => {
|
||||
if (element.firstElementChild.classList.contains("li")) {
|
||||
if (expand) {
|
||||
tempDom.content.querySelectorAll(".li .li .li").forEach(item => {
|
||||
element.querySelectorAll(".li .li .li").forEach(item => {
|
||||
if (item.childElementCount > 3) {
|
||||
item.setAttribute("fold", "1");
|
||||
}
|
||||
});
|
||||
} else {
|
||||
tempDom.content.firstElementChild.setAttribute("fold", "1");
|
||||
element.firstElementChild.setAttribute("fold", "1");
|
||||
}
|
||||
} else if (tempDom.content.firstElementChild.getAttribute("data-type") === "NodeHeading") {
|
||||
Array.from(tempDom.content.children).forEach((item, index) => {
|
||||
} else if (element.firstElementChild.getAttribute("data-type") === "NodeHeading") {
|
||||
Array.from(element.children).forEach((item, index) => {
|
||||
if ((expand && index > 2) || (!expand && index > 1)) {
|
||||
if ((expand && index === 3) || (!expand && index === 2)) {
|
||||
item.insertAdjacentHTML("beforebegin", '<div style="max-width: 100%;justify-content: center;" contenteditable="false" class="protyle-breadcrumb__item"><svg><use xlink:href="#iconMore"></use></svg></div>');
|
||||
@ -50,6 +49,12 @@ const setBacklinkFold = (html: string, expand: boolean) => {
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const setBacklinkFold = (html: string, expand: boolean) => {
|
||||
const tempDom = document.createElement("template");
|
||||
tempDom.innerHTML = html;
|
||||
foldPassiveType(expand, tempDom.content);
|
||||
return tempDom.innerHTML;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user