mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-18 15:40:12 +01:00
This commit is contained in:
parent
b238a5de41
commit
ff87978204
2 changed files with 32 additions and 2 deletions
|
|
@ -163,6 +163,22 @@ export class Backlink extends Model {
|
||||||
position: "bottom",
|
position: "bottom",
|
||||||
action: [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT]
|
action: [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT]
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
toggleClick:(liElement: HTMLElement)=> {
|
||||||
|
const svgElement = liElement.firstElementChild.firstElementChild;
|
||||||
|
if (svgElement.classList.contains("b3-list-item__arrow--open")) {
|
||||||
|
svgElement.classList.remove("b3-list-item__arrow--open");
|
||||||
|
liElement.nextElementSibling?.classList.add("fn__none");
|
||||||
|
} else {
|
||||||
|
svgElement.classList.add("b3-list-item__arrow--open");
|
||||||
|
if (liElement.nextElementSibling && liElement.nextElementSibling.tagName === "UL") {
|
||||||
|
liElement.nextElementSibling.classList.remove("fn__none");
|
||||||
|
} else {
|
||||||
|
fetchPost("/api/ref/getBacklinkDoc", {defID:this.blockId, refTreeID:liElement.getAttribute("data-node-id")}, (response)=>{
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.mTree = new Tree({
|
this.mTree = new Tree({
|
||||||
|
|
@ -355,7 +371,14 @@ export class Backlink extends Model {
|
||||||
this.notebookId = data.box;
|
this.notebookId = data.box;
|
||||||
this.inputsElement[0].value = data.k;
|
this.inputsElement[0].value = data.k;
|
||||||
this.inputsElement[1].value = data.mk;
|
this.inputsElement[1].value = data.mk;
|
||||||
|
data.backlinks.forEach((item) => {
|
||||||
|
delete item.blocks
|
||||||
|
delete item.children
|
||||||
|
})
|
||||||
|
data.backmentions.forEach((item) => {
|
||||||
|
delete item.blocks
|
||||||
|
delete item.children
|
||||||
|
})
|
||||||
this.tree.updateData(data.backlinks);
|
this.tree.updateData(data.backlinks);
|
||||||
this.mTree.updateData(data.backmentions);
|
this.mTree.updateData(data.backmentions);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ export class Tree {
|
||||||
private click: (element: HTMLElement, event: MouseEvent) => void;
|
private click: (element: HTMLElement, event: MouseEvent) => void;
|
||||||
|
|
||||||
private ctrlClick: (element: HTMLElement) => void;
|
private ctrlClick: (element: HTMLElement) => void;
|
||||||
|
private toggleClick: (element: HTMLElement) => void;
|
||||||
private shiftClick: (element: HTMLElement) => void;
|
private shiftClick: (element: HTMLElement) => void;
|
||||||
private altClick: (element: HTMLElement) => void;
|
private altClick: (element: HTMLElement) => void;
|
||||||
private rightClick: (element: HTMLElement, event: MouseEvent) => void;
|
private rightClick: (element: HTMLElement, event: MouseEvent) => void;
|
||||||
|
|
@ -27,6 +28,7 @@ export class Tree {
|
||||||
ctrlClick?(element: HTMLElement): void
|
ctrlClick?(element: HTMLElement): void
|
||||||
altClick?(element: HTMLElement): void
|
altClick?(element: HTMLElement): void
|
||||||
shiftClick?(element: HTMLElement): void
|
shiftClick?(element: HTMLElement): void
|
||||||
|
toggleClick?(element: HTMLElement): void
|
||||||
rightClick?(element: HTMLElement, event: MouseEvent): void
|
rightClick?(element: HTMLElement, event: MouseEvent): void
|
||||||
}) {
|
}) {
|
||||||
this.click = options.click;
|
this.click = options.click;
|
||||||
|
|
@ -34,6 +36,7 @@ export class Tree {
|
||||||
this.altClick = options.altClick;
|
this.altClick = options.altClick;
|
||||||
this.shiftClick = options.shiftClick;
|
this.shiftClick = options.shiftClick;
|
||||||
this.rightClick = options.rightClick;
|
this.rightClick = options.rightClick;
|
||||||
|
this.toggleClick = options.toggleClick;
|
||||||
this.element = options.element;
|
this.element = options.element;
|
||||||
this.blockExtHTML = options.blockExtHTML;
|
this.blockExtHTML = options.blockExtHTML;
|
||||||
this.topExtHTML = options.topExtHTML;
|
this.topExtHTML = options.topExtHTML;
|
||||||
|
|
@ -76,7 +79,7 @@ data-type="${item.nodeType}"
|
||||||
data-subtype="${item.subType}"
|
data-subtype="${item.subType}"
|
||||||
${item.label ? "data-label='" + item.label + "'" : ""}>
|
${item.label ? "data-label='" + item.label + "'" : ""}>
|
||||||
<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="${encodeURIComponent(item.name + item.depth)}" class="b3-list-item__arrow ${((item.children && item.children.length > 0) || (item.blocks && item.blocks.length > 0)) ? "b3-list-item__arrow--open" : "fn__hidden"}"><use xlink:href="#iconRight"></use></svg>
|
<svg data-id="${encodeURIComponent(item.name + item.depth)}" class="b3-list-item__arrow ${((item.children && item.children.length > 0) || (item.blocks && item.blocks.length > 0)) ? "b3-list-item__arrow--open" : (item.type === "backlink" ? "" : "fn__hidden")}"><use xlink:href="#iconRight"></use></svg>
|
||||||
</span>
|
</span>
|
||||||
${iconHTML}
|
${iconHTML}
|
||||||
<span class="b3-list-item__text"${item.type === "outline" ? ' title="' + Lute.EscapeHTMLStr(Lute.BlockDOM2Content(item.name)) + '"' : ""}>${item.name}</span>
|
<span class="b3-list-item__text"${item.type === "outline" ? ' title="' + Lute.EscapeHTMLStr(Lute.BlockDOM2Content(item.name)) + '"' : ""}>${item.name}</span>
|
||||||
|
|
@ -137,6 +140,10 @@ data-def-path="${item.defPath}">
|
||||||
}
|
}
|
||||||
|
|
||||||
private toggleBlocks(liElement: HTMLElement) {
|
private toggleBlocks(liElement: HTMLElement) {
|
||||||
|
if (this.toggleClick) {
|
||||||
|
this.toggleClick(liElement)
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!liElement.nextElementSibling) {
|
if (!liElement.nextElementSibling) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue