mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-03-04 03:40:15 +01:00
Improve the class name of showTooltip() (#12746)
This commit is contained in:
parent
bc53babb85
commit
1139ffddc0
3 changed files with 23 additions and 14 deletions
|
|
@ -1,6 +1,6 @@
|
|||
import {isMobile} from "../util/functions";
|
||||
|
||||
export const showTooltip = (message: string, target: Element, error = false) => {
|
||||
export const showTooltip = (message: string, target: Element, tooltipClass?: string) => {
|
||||
if (isMobile()) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -16,15 +16,16 @@ export const showTooltip = (message: string, target: Element, error = false) =>
|
|||
} else {
|
||||
messageElement.innerHTML = message;
|
||||
}
|
||||
if (error) {
|
||||
messageElement.classList.add("tooltip--error");
|
||||
|
||||
if (tooltipClass) {
|
||||
messageElement.classList.add("tooltip--" + tooltipClass);
|
||||
} else {
|
||||
messageElement.classList.remove("tooltip--error");
|
||||
}
|
||||
if (target.getAttribute("data-inline-memo-content")) {
|
||||
messageElement.classList.add("tooltip--memo"); // 为行级备注添加 class https://github.com/siyuan-note/siyuan/issues/6161
|
||||
} else {
|
||||
messageElement.classList.remove("tooltip--memo");
|
||||
const classesToRemove = Array.from(messageElement.classList).filter(className =>
|
||||
className.startsWith("tooltip--")
|
||||
);
|
||||
classesToRemove.forEach(className => {
|
||||
messageElement.classList.remove(className);
|
||||
});
|
||||
}
|
||||
|
||||
let left = targetRect.left;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue