Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: https://github.com/siyuan-note/siyuan/issues/17340

Vanessa979b92c3e502
diff --git a/app/src/layout/dock/Backlink.ts b/app/src/layout/dock/Backlink.ts
index 1ccc489e21..6857ea1918 100644
--- a/app/src/layout/dock/Backlink.ts
+++ b/app/src/layout/dock/Backlink.ts
@@ -109,7 +109,7 @@ export class Backlink extends Model {
</div>
<div class="backlinkList fn__flex-1"></div>
<div class="block__icons">
- <div class="block__logo">
+ <div class="block__logo fn__pointer" data-type="mention">
<svg class="block__logoicon"><use xlink:href="#iconLink"></use></svg>${window.siyuan.languages.mentions}
</div>
<span class="counter listMCount" style="margin-left: 0;"></span>
@@ -273,11 +273,13 @@ export class Backlink extends Model {
this.setFocus();
let target = event.target as HTMLElement;
while (target && !target.isEqualNode(this.element)) {
- if (target.classList.contains("block__icon") && target.parentElement.parentElement === this.element) {
+ if ((target.classList.contains("block__icon") || target.classList.contains("block__logo")) &&
+ target.parentElement.parentElement === this.element) {
const type = target.getAttribute("data-type");
switch (type) {
case "refresh":
this.refresh();
+ event.stopPropagation();
break;
case "mExpand":
Array.from(this.mTree.element.firstElementChild.children).forEach((item: HTMLElement) => {
@@ -285,6 +287,7 @@ export class Backlink extends Model {
this.toggleItem(item, true);
}
});
+ event.stopPropagation();
break;
case "mCollapse":
this.mTree.element.querySelectorAll(".protyle").forEach(item => {
@@ -293,13 +296,16 @@ export class Backlink extends Model {
this.mTree.element.querySelectorAll(".b3-list-item__arrow").forEach(item => {
item.classList.remove("b3-list-item__arrow--open");
});
+ event.stopPropagation();
break;
case "min":
getDockByType("backlink").toggleModel("backlink", false, true);
+ event.stopPropagation();
break;
case "search":
target.previousElementSibling.classList.remove("fn__none");
(target.previousElementSibling as HTMLInputElement).select();
+ event.stopPropagation();
break;
case "sort":
case "mSort":
@@ -308,33 +314,12 @@ export class Backlink extends Model {
event.stopPropagation();
break;
case "layout":
- if (this.mTree.element.style.flex) {
- if (this.mTree.element.style.height === "0px") {
- this.tree.element.classList.remove("fn__none");
- this.mTree.element.removeAttribute("style");
- target.setAttribute("aria-label", window.siyuan.languages.up);
- target.querySelector("use").setAttribute("xlink:href", "#iconUp");
- } else {
- this.tree.element.classList.remove("fn__none");
- this.mTree.element.removeAttribute("style");
- target.setAttribute("aria-label", window.siyuan.languages.down);
- target.querySelector("use").setAttribute("xlink:href", "#iconDown");
- }
- } else {
- if (target.getAttribute("aria-label") === window.siyuan.languages.down) {
- this.tree.element.classList.remove("fn__none");
- this.mTree.element.setAttribute("style", "flex:none;height:0px");
- target.setAttribute("aria-label", window.siyuan.languages.up);
- target.querySelector("use").setAttribute("xlink:href", "#iconUp");
- } else {
- this.tree.element.classList.add("fn__none");
- this.mTree.element.setAttribute("style", `flex:none;height:${this.element.clientHeight - this.tree.element.previousElementSibling.clientHeight * 2}px`);
- target.setAttribute("aria-label", window.siyuan.languages.down);
- target.querySelector("use").setAttribute("xlink:href", "#iconDown");
- }
- }
- this.tree.element.dispatchEvent(new CustomEvent("scroll"));
- this.mTree.element.dispatchEvent(new CustomEvent("scroll"));
+ this.setLayout(target);
+ event.stopPropagation();
+ break;
+ case "mention":
+ this.setLayout(target.parentElement.querySelector('[data-type="layout"]'));
+ event.stopPropagation();
break;
}
}
@@ -345,6 +330,36 @@ export class Backlink extends Model {
this.searchBacklinks(true);
}
+ private setLayout(element: HTMLElement) {
+ if (this.mTree.element.style.flex) {
+ if (this.mTree.element.style.height === "0px") {
+ this.tree.element.classList.remove("fn__none");
+ this.mTree.element.removeAttribute("style");
+ element.setAttribute("aria-label", window.siyuan.languages.up);
+ element.querySelector("use").setAttribute("xlink:href", "#iconUp");
+ } else {
+ this.tree.element.classList.remove("fn__none");
+ this.mTree.element.removeAttribute("style");
+ element.setAttribute("aria-label", window.siyuan.languages.down);
+ element.querySelector("use").setAttribute("xlink:href", "#iconDown");
+ }
+ } else {
+ if (element.getAttribute("aria-label") === window.siyuan.languages.down) {
+ this.tree.element.classList.remove("fn__none");
+ this.mTree.element.setAttribute("style", "flex:none;height:0px");
+ element.setAttribute("aria-label", window.siyuan.languages.up);
+ element.querySelector("use").setAttribute("xlink:href", "#iconUp");
+ } else {
+ this.tree.element.classList.add("fn__none");
+ this.mTree.element.setAttribute("style", `flex:none;height:${this.element.clientHeight - this.tree.element.previousElementSibling.clientHeight * 2}px`);
+ element.setAttribute("aria-label", window.siyuan.languages.down);
+ element.querySelector("use").setAttribute("xlink:href", "#iconDown");
+ }
+ }
+ this.tree.element.dispatchEvent(new CustomEvent("scroll"));
+ this.mTree.element.dispatchEvent(new CustomEvent("scroll"));
+ }
+
private setFocus() {
if (this.type === "local") {
setPanelFocus(this.element.parentElement.parentElement);