Skip to content

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

:art: tooltip

Vanessa64fdb274fb11
diff --git a/app/src/dialog/tooltip.ts b/app/src/dialog/tooltip.ts
index a6e71dc184..fb8596f104 100644
--- a/app/src/dialog/tooltip.ts
+++ b/app/src/dialog/tooltip.ts
@@ -17,11 +17,6 @@ export const showTooltip = (message: string, target: Element, error = false) =>
} else {
messageElement.innerHTML = message;
}
- if (target.parentElement.getAttribute("data-type") === "navigation-file") {
- const parentRect = target.parentElement.getBoundingClientRect();
- setPosition(messageElement, parentRect.right + 8, parentRect.top);
- return;
- }
if (error) {
messageElement.classList.add("tooltip--error");
} else {
@@ -33,15 +28,23 @@ export const showTooltip = (message: string, target: Element, error = false) =>
messageElement.classList.remove("tooltip--memo");
}
let left = targetRect.left;
- if (target.getAttribute("data-position") === "right") {
+ let top = targetRect.bottom;
+ const position = target.getAttribute("data-position")
+ if (position === "right") {
+ // block icon
left = targetRect.right - messageElement.clientWidth;
+ } else if (position === "parentE") {
+ // tree and outline
+ const parentRect = target.parentElement.getBoundingClientRect();
+ top = parentRect.top;
+ left = parentRect.right + 8;
}
- const bottomHeight = window.innerHeight - targetRect.bottom;
+ const bottomHeight = window.innerHeight - top;
messageElement.style.maxHeight = Math.max(targetRect.top, bottomHeight) + "px";
if (targetRect.top > bottomHeight) {
messageElement.style.top = (targetRect.top - messageElement.clientHeight) + "px";
} else {
- messageElement.style.top = targetRect.bottom + "px";
+ messageElement.style.top = top + "px";
}
if (left + messageElement.clientWidth > window.innerWidth) {
messageElement.style.left = (window.innerWidth - messageElement.clientWidth) + "px";
diff --git a/app/src/layout/dock/Files.ts b/app/src/layout/dock/Files.ts
index f0aa7eee14..542bd89caf 100644
--- a/app/src/layout/dock/Files.ts
+++ b/app/src/layout/dock/Files.ts
@@ -1004,7 +1004,7 @@ class="b3-list-item b3-list-item--hide-action" data-path="${item.path}">
<svg class="b3-list-item__arrow"><use xlink:href="#iconRight"></use></svg>
</span>
<span class="b3-list-item__icon b3-tooltips b3-tooltips__n" aria-label="${window.siyuan.languages.changeIcon}">${unicode2Emoji(item.icon || (item.subFileCount === 0 ? Constants.SIYUAN_IMAGE_FILE : Constants.SIYUAN_IMAGE_FOLDER))}</span>
- <span class="b3-list-item__text ariaLabel"
+ <span class="b3-list-item__text ariaLabel" data-position="parentE"
aria-label="${escapeHtml(ariaLabel)}">${getDisplayName(item.name, true, true)}</span>
<span data-type="more-file" class="b3-list-item__action b3-tooltips b3-tooltips__nw" aria-label="${window.siyuan.languages.more}">
<svg><use xlink:href="#iconMore"></use></svg>
diff --git a/app/src/util/Tree.ts b/app/src/util/Tree.ts
index 94de65d9a3..6655a49369 100644
--- a/app/src/util/Tree.ts
+++ b/app/src/util/Tree.ts
@@ -63,10 +63,10 @@ export class Tree {
} else if (item.type === "tag") {
iconHTML = '<svg class="b3-list-item__graphic"><use xlink:href="#iconTags"></use></svg>';
} else if (item.type === "backlink") {
- titleTip = ` title="${item.hPath}"`;
+ titleTip = ` aria-label="${item.hPath}"`;
iconHTML = `<svg class="b3-list-item__graphic popover__block" data-id="${item.id}"><use xlink:href="#${getIconByType(item.nodeType, item.subType)}"></use></svg>`;
} else if (item.type === "outline") {
- titleTip = ` title="${Lute.EscapeHTMLStr(Lute.BlockDOM2Content(item.name))}"`;
+ titleTip = ` aria-label="${Lute.EscapeHTMLStr(Lute.BlockDOM2Content(item.name))}"`;
iconHTML = `<svg class="b3-list-item__graphic popover__block" data-id="${item.id}"><use xlink:href="#${getIconByType(item.nodeType, item.subType)}"></use></svg>`;
}
let countHTML = "";
@@ -94,7 +94,7 @@ ${item.label ? "data-label='" + item.label + "'" : ""}>
<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}
- <span class="b3-list-item__text"${titleTip}>${item.name}</span>
+ <span class="b3-list-item__text ariaLabel" data-position="parentE"${titleTip}>${item.name}</span>
${this.topExtHTML || ""}
${countHTML}
</li>`;
@@ -148,7 +148,7 @@ data-def-path="${item.defPath}">
<svg data-id="${item.id}" class="b3-list-item__arrow"><use xlink:href="#iconRight"></use></svg>
</span>
${iconHTML}
- <span class="b3-list-item__text" ${type === "outline" ? ' title="' + Lute.EscapeHTMLStr(Lute.BlockDOM2Content(item.content)) + '"' : ""}>${item.content}</span>
+ <span class="b3-list-item__text ariaLabel" data-position="parentE" ${type === "outline" ? ' aria-label="' + Lute.EscapeHTMLStr(Lute.BlockDOM2Content(item.content)) + '"' : ""}>${item.content}</span>
${countHTML}
${this.blockExtHTML || ""}
</li>`;