Vanessa 2025-12-09 11:13:37 +08:00
parent bff6f06999
commit bdee142509
2 changed files with 13 additions and 4 deletions

View file

@ -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
}

View file

@ -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";