Vanessa 2022-05-30 11:51:22 +08:00
parent 3204156c74
commit 4370aefb02

View file

@ -2,6 +2,8 @@ import {getIconByType} from "../editor/getIcon";
import {hasClosestByTag} from "../protyle/util/hasClosest"; import {hasClosestByTag} from "../protyle/util/hasClosest";
import {isMobile} from "./functions"; import {isMobile} from "./functions";
import {mathRender} from "../protyle/markdown/mathRender"; import {mathRender} from "../protyle/markdown/mathRender";
import {unicode2Emoji} from "../emoji";
import {Constants} from "../constants";
export class Tree { export class Tree {
public element: HTMLElement; public element: HTMLElement;
@ -92,11 +94,20 @@ ${item.label ? "data-label='" + item.label + "'" : ""}>
data.forEach((item: IBlock & { data.forEach((item: IBlock & {
subType: string; subType: string;
count: string; count: string;
ial?: {
icon: string
}
}) => { }) => {
let countHTML = ""; let countHTML = "";
if (item.count) { if (item.count) {
countHTML = `<span class="counter">${item.count}</span>`; countHTML = `<span class="counter">${item.count}</span>`;
} }
let iconHTML;
if (item.type === "NodeDocument") {
iconHTML = `<span data-defids='["${item.defID}"]' class="b3-list-item__icon popover__block" data-id="${item.id}">${unicode2Emoji(item.ial.icon || Constants.SIYUAN_IMAGE_FILE)}</span>`
} else {
iconHTML = `<svg data-defids='["${item.defID}"]' class="b3-list-item__graphic popover__block" data-id="${item.id}"><use xlink:href="#${getIconByType(item.type, item.subType)}"></use></svg>`
}
html += `<li ${type === "backlink" ? 'draggable="true"' : ""} html += `<li ${type === "backlink" ? 'draggable="true"' : ""}
class="b3-list-item ${isMobile() ? "" : "b3-list-item--hide-action"}" class="b3-list-item ${isMobile() ? "" : "b3-list-item--hide-action"}"
data-node-id="${item.id}" data-node-id="${item.id}"
@ -109,7 +120,7 @@ data-def-path="${item.defPath}">
<span style="padding-left: ${item.depth * 16}px" class="b3-list-item__toggle"> <span style="padding-left: ${item.depth * 16}px" class="b3-list-item__toggle">
<svg data-id="${item.id}" class="b3-list-item__arrow${item.children ? "" : " fn__hidden"}"><use xlink:href="#iconRight"></use></svg> <svg data-id="${item.id}" class="b3-list-item__arrow${item.children ? "" : " fn__hidden"}"><use xlink:href="#iconRight"></use></svg>
</span> </span>
<svg data-defids='["${item.defID}"]' class="b3-list-item__graphic popover__block" data-id="${item.id}"><use xlink:href="#${getIconByType(item.type, item.subType)}"></use></svg> ${iconHTML}
<span class="b3-list-item__text">${item.content}</span> <span class="b3-list-item__text">${item.content}</span>
${countHTML} ${countHTML}
${this.blockExtHTML || ""} ${this.blockExtHTML || ""}