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,7 +5,10 @@ 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;
|
||||||
|
if (target.getAttribute("data-inline-memo-content")) {
|
||||||
|
space = 0;
|
||||||
|
if (target.getClientRects().length > 1) {
|
||||||
let lastWidth = 0;
|
let lastWidth = 0;
|
||||||
if (event) {
|
if (event) {
|
||||||
Array.from(target.getClientRects()).forEach(item => {
|
Array.from(target.getClientRects()).forEach(item => {
|
||||||
|
|
@ -22,6 +25,7 @@ export const showTooltip = (message: string, target: Element, tooltipClass?: str
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (targetRect.height === 0 || !message) {
|
if (targetRect.height === 0 || !message) {
|
||||||
hideTooltip();
|
hideTooltip();
|
||||||
return;
|
return;
|
||||||
|
|
@ -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