mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-18 07:30:12 +01:00
This commit is contained in:
parent
84df895469
commit
9156aee244
1 changed files with 22 additions and 18 deletions
|
|
@ -5,21 +5,25 @@ export const showTooltip = (message: string, target: Element, tooltipClass?: str
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let targetRect = target.getBoundingClientRect();
|
let targetRect = target.getBoundingClientRect();
|
||||||
if (target.getAttribute("data-inline-memo-content") && target.getClientRects().length > 1) {
|
let space = 0.5;
|
||||||
let lastWidth = 0;
|
if (target.getAttribute("data-inline-memo-content")) {
|
||||||
if (event) {
|
space = 0;
|
||||||
Array.from(target.getClientRects()).forEach(item => {
|
if (target.getClientRects().length > 1) {
|
||||||
if (event.clientY >= item.top - 3 && event.clientY <= item.bottom) {
|
let lastWidth = 0;
|
||||||
targetRect = item;
|
if (event) {
|
||||||
}
|
Array.from(target.getClientRects()).forEach(item => {
|
||||||
});
|
if (event.clientY >= item.top - 3 && event.clientY <= item.bottom) {
|
||||||
} else {
|
targetRect = item;
|
||||||
Array.from(target.getClientRects()).forEach(item => {
|
}
|
||||||
if (item.width > lastWidth) {
|
});
|
||||||
targetRect = item;
|
} else {
|
||||||
}
|
Array.from(target.getClientRects()).forEach(item => {
|
||||||
lastWidth = item.width;
|
if (item.width > lastWidth) {
|
||||||
});
|
targetRect = item;
|
||||||
|
}
|
||||||
|
lastWidth = item.width;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (targetRect.height === 0 || !message) {
|
if (targetRect.height === 0 || !message) {
|
||||||
|
|
@ -60,7 +64,7 @@ export const showTooltip = (message: string, target: Element, tooltipClass?: str
|
||||||
}
|
}
|
||||||
} else if (position?.endsWith("west")) {
|
} else if (position?.endsWith("west")) {
|
||||||
// west: gutter & 标题图标 & av relation
|
// west: gutter & 标题图标 & av relation
|
||||||
const positionDiff = parseInt(position) || 0.5;
|
const positionDiff = parseInt(position) || space;
|
||||||
top = Math.max(0, targetRect.top - (messageElement.clientHeight - targetRect.height) / 2);
|
top = Math.max(0, targetRect.top - (messageElement.clientHeight - targetRect.height) / 2);
|
||||||
if (top > window.innerHeight - messageElement.clientHeight) {
|
if (top > window.innerHeight - messageElement.clientHeight) {
|
||||||
top = window.innerHeight - messageElement.clientHeight;
|
top = window.innerHeight - messageElement.clientHeight;
|
||||||
|
|
@ -71,7 +75,7 @@ export const showTooltip = (message: string, target: Element, tooltipClass?: str
|
||||||
}
|
}
|
||||||
} else if (position?.endsWith("north")) {
|
} else if (position?.endsWith("north")) {
|
||||||
// north: av 视图,列,多选描述, protyle-icon
|
// north: av 视图,列,多选描述, protyle-icon
|
||||||
const positionDiff = parseInt(position) || 0.5;
|
const positionDiff = parseInt(position) || space;
|
||||||
left = Math.max(0, targetRect.left - (messageElement.clientWidth - targetRect.width) / 2);
|
left = Math.max(0, targetRect.left - (messageElement.clientWidth - targetRect.width) / 2);
|
||||||
top = targetRect.top - messageElement.clientHeight - positionDiff;
|
top = targetRect.top - messageElement.clientHeight - positionDiff;
|
||||||
if (top < 0) {
|
if (top < 0) {
|
||||||
|
|
@ -88,7 +92,7 @@ export const showTooltip = (message: string, target: Element, tooltipClass?: str
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// ${number}south & 默认值
|
// ${number}south & 默认值
|
||||||
const positionDiff = parseInt(position) || 0.5;
|
const positionDiff = parseInt(position) || space;
|
||||||
left = Math.max(0, targetRect.left - (messageElement.clientWidth - targetRect.width) / 2);
|
left = Math.max(0, targetRect.left - (messageElement.clientWidth - targetRect.width) / 2);
|
||||||
top = targetRect.bottom + positionDiff;
|
top = targetRect.bottom + positionDiff;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue