diff --git a/app/src/block/popover.ts b/app/src/block/popover.ts index 761682677..9b01d8bd3 100644 --- a/app/src/block/popover.ts +++ b/app/src/block/popover.ts @@ -7,7 +7,7 @@ import {App} from "../index"; import {Constants} from "../constants"; import {getCellText} from "../protyle/render/av/cell"; import {isTouchDevice} from "../util/functions"; -import {escapeAriaLabel} from "../util/escape"; +import {escapeAriaLabel, escapeHtml} from "../util/escape"; let popoverTargetElement: HTMLElement; let notebookItemElement: HTMLElement | false; @@ -81,7 +81,7 @@ export const initBlockPopover = (app: App) => { } } if (!tip) { - tip = aElement.getAttribute("data-inline-memo-content"); + tip = escapeHtml(aElement.getAttribute("data-inline-memo-content")); if (tip) { tooltipClass = "memo"; // 为行级备注添加 class https://github.com/siyuan-note/siyuan/issues/6161 } diff --git a/app/src/dialog/tooltip.ts b/app/src/dialog/tooltip.ts index e3f502c6e..dddcae76b 100644 --- a/app/src/dialog/tooltip.ts +++ b/app/src/dialog/tooltip.ts @@ -4,7 +4,16 @@ export const showTooltip = (message: string, target: Element, tooltipClass?: str if (isMobile()) { return; } - const targetRect = target.getBoundingClientRect(); + 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 (targetRect.height === 0 || !message) { hideTooltip(); return; @@ -78,7 +87,7 @@ export const showTooltip = (message: string, target: Element, tooltipClass?: str if (top + messageElement.clientHeight > window.innerHeight) { if (targetRect.top - positionDiff > window.innerHeight - top) { - top = targetRect.top - positionDiff - messageElement.clientHeight; + top = Math.max(0, targetRect.top - positionDiff - messageElement.clientHeight); messageElement.style.maxHeight = (targetRect.top - positionDiff) + "px"; } else { messageElement.style.maxHeight = (window.innerHeight - top) + "px";