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/14796

Vanessa4fe40c9fd558
diff --git a/app/src/block/popover.ts b/app/src/block/popover.ts
index 9b01d8bd3b..7aaed40de9 100644
--- a/app/src/block/popover.ts
+++ b/app/src/block/popover.ts
@@ -132,10 +132,10 @@ export const initBlockPopover = (app: App) => {
if (tip && !aElement.classList.contains("b3-tooltips")) {
// https://github.com/siyuan-note/siyuan/issues/11294
try {
- showTooltip(decodeURIComponent(tip), aElement, tooltipClass);
+ showTooltip(decodeURIComponent(tip), aElement, tooltipClass, event);
} catch (e) {
// https://ld246.com/article/1718235737991
- showTooltip(tip, aElement, tooltipClass);
+ showTooltip(tip, aElement, tooltipClass, event);
}
event.stopPropagation();
} else {
diff --git a/app/src/dialog/tooltip.ts b/app/src/dialog/tooltip.ts
index dddcae76bb..969300930f 100644
--- a/app/src/dialog/tooltip.ts
+++ b/app/src/dialog/tooltip.ts
@@ -1,18 +1,26 @@
import {isMobile} from "../util/functions";
-export const showTooltip = (message: string, target: Element, tooltipClass?: string) => {
+export const showTooltip = (message: string, target: Element, tooltipClass?: string, event?: MouseEvent) => {
if (isMobile()) {
return;
}
let targetRect = target.getBoundingClientRect();
if (target.getAttribute("data-inline-memo-content") && target.getClientRects().length > 1) {
let lastWidth = 0;
- Array.from(target.getClientRects()).forEach(item => {
- if (item.width > lastWidth) {
- targetRect = item;
- }
- lastWidth = item.width;
- });
+ if (event) {
+ Array.from(target.getClientRects()).forEach(item => {
+ if (event.clientY >= item.top - 3 && event.clientY <= item.bottom) {
+ targetRect = item;
+ }
+ });
+ } else {
+ Array.from(target.getClientRects()).forEach(item => {
+ if (item.width > lastWidth) {
+ targetRect = item;
+ }
+ lastWidth = item.width;
+ });
+ }
}
if (targetRect.height === 0 || !message) {
hideTooltip();
@@ -25,7 +33,6 @@ export const showTooltip = (message: string, target: Element, tooltipClass?: str
// 避免原本的 top 和 left 影响计算
messageElement.removeAttribute("style");
-
const position = target.getAttribute("data-position");
const parentRect = target.parentElement.getBoundingClientRect();