This commit is contained in:
Vanessa 2023-03-25 16:56:56 +08:00
parent b4395bfca4
commit e936a2d5d7
5 changed files with 77 additions and 17 deletions

View file

@ -74,6 +74,14 @@ export class Tree {
countHTML = `<span class="counter">${item.count}</span>`;
}
const hasChild = (item.children && item.children.length > 0) || (item.blocks && item.blocks.length > 0);
let style = "";
if (isMobile()) {
if (item.depth > 0) {
style = `padding-left: ${(item.depth - 1) * 29 + 40}px`
}
} else {
style = `padding-left: ${(item.depth - 1) * 18 + 22}px;margin-right: 2px`
}
html += `<li class="b3-list-item"
${(item.nodeType !== "NodeDocument" && item.type === "backlink") ? 'draggable="true" ' : ""}
${item.id ? 'data-node-id="' + item.id + '"' : ""}
@ -82,7 +90,7 @@ data-treetype="${item.type}"
data-type="${item.nodeType}"
data-subtype="${item.subType}"
${item.label ? "data-label='" + item.label + "'" : ""}>
<span style="padding-left: ${(item.depth - 1) * 18 + 22}px;margin-right: 2px" class="b3-list-item__toggle${(item.type === "backlink" || hasChild) ? " b3-list-item__toggle--hl" : ""}${hasChild||item.type === "backlink" ? "" : " fn__hidden"}">
<span style="${style}" class="b3-list-item__toggle${(item.type === "backlink" || hasChild) ? " b3-list-item__toggle--hl" : ""}${hasChild || item.type === "backlink" ? "" : " fn__hidden"}">
<svg data-id="${encodeURIComponent(item.name + item.depth)}" class="b3-list-item__arrow${hasChild ? " b3-list-item__arrow--open" : ""}"><use xlink:href="#iconRight"></use></svg>
</span>
${iconHTML}
@ -119,6 +127,14 @@ ${item.label ? "data-label='" + item.label + "'" : ""}>
} 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>`;
}
let style = "";
if (isMobile()) {
if (item.depth > 0) {
style = `padding-left: ${(item.depth - 1) * 29 + 40}px`
}
} else {
style = `padding-left: ${(item.depth - 1) * 18 + 22}px;margin-right: 2px`
}
html += `<li ${type === "backlink" ? 'draggable="true"' : ""}
class="b3-list-item ${isMobile() ? "" : "b3-list-item--hide-action"}"
data-node-id="${item.id}"
@ -128,7 +144,7 @@ data-type="${item.type}"
data-subtype="${item.subType}"
data-treetype="${type}"
data-def-path="${item.defPath}">
<span style="padding-left: ${(item.depth - 1) * 18 + 22}px;margin-right: 2px" class="b3-list-item__toggle${item.children ? " b3-list-item__toggle--hl" : ""}${item.children ? "" : " fn__hidden"}">
<span style="${style}" class="b3-list-item__toggle${item.children ? " b3-list-item__toggle--hl" : ""}${item.children ? "" : " fn__hidden"}">
<svg data-id="${item.id}" class="b3-list-item__arrow"><use xlink:href="#iconRight"></use></svg>
</span>
${iconHTML}