Vanessa 2025-10-29 16:00:09 +08:00
parent 06f439f606
commit 1e60748e64

View file

@ -54,7 +54,7 @@ export class Tree {
}
}
private genHTML(data: IBlockTree[]) {
private genHTML(data: (IBlockTree & { folded?: boolean })[]) {
let html = `<ul${data[0].depth === 0 ? " class='b3-list b3-list--background'" : ""}>`;
data.forEach((item) => {
let titleTip = "";
@ -94,7 +94,7 @@ data-type="${item.nodeType}"
data-subtype="${item.subType}"
${item.label ? "data-label='" + item.label + "'" : ""}>
<span style="${style}" class="b3-list-item__toggle${showArrow ? " b3-list-item__toggle--hl" : ""}${showArrow ? "" : " fn__hidden"}">
<svg data-id="${item.id || encodeURIComponent(item.name + item.depth)}" class="b3-list-item__arrow${hasChild ? " b3-list-item__arrow--open" : ""}"><use xlink:href="#iconRight"></use></svg>
<svg data-id="${item.id || encodeURIComponent(item.name + item.depth)}" class="b3-list-item__arrow${(item.type === "outline" ? !item.folded : hasChild) ? " b3-list-item__arrow--open" : ""}"><use xlink:href="#iconRight"></use></svg>
</span>
${iconHTML}
<span class="b3-list-item__text ariaLabel" data-position="parentE"${titleTip}>${item.name}</span>
@ -105,7 +105,7 @@ ${item.label ? "data-label='" + item.label + "'" : ""}>
html += this.genHTML(item.children) + "</ul>";
}
if (item.blocks && item.blocks.length > 0) {
html += this.genBlockHTML(item.blocks, true, item.type) + "</ul>";
html += this.genBlockHTML(item.blocks, item.type === "outline" ? !item.folded : true, item.type) + "</ul>";
}
});
return html;
@ -153,7 +153,7 @@ data-subtype="${item.subType}"
data-treetype="${type}"
data-def-path="${item.defPath}">
<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${(type === "outline" && !item.folded) ? " b3-list-item__arrow--open" : ""}"><use xlink:href="#iconRight"></use></svg>
<svg data-id="${item.id}" class="b3-list-item__arrow${(type === "outline" ? !item.folded : show) ? " b3-list-item__arrow--open" : ""}"><use xlink:href="#iconRight"></use></svg>
</span>
${iconHTML}
<span class="b3-list-item__text ariaLabel" data-position="parentE" ${type === "outline" ? ' aria-label="' + escapeAriaLabel(Lute.BlockDOM2Content(item.content)) + '"' : ""}>${item.content}</span>
@ -161,7 +161,7 @@ data-def-path="${item.defPath}">
${this.blockExtHTML || ""}
</li>`;
if (item.children && item.children.length > 0) {
html += this.genBlockHTML(item.children, (type === "outline" && !item.folded) ? true : false, type) + "</ul>";
html += this.genBlockHTML(item.children, type === "outline" ? !item.folded : false, type) + "</ul>";
}
});
return html;