mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-03-08 05:32:33 +01:00
This commit is contained in:
parent
7c1f49e862
commit
aa208bb3fc
7 changed files with 113 additions and 113 deletions
|
|
@ -4,6 +4,7 @@ import {fetchSyncPost} from "../util/fetch";
|
|||
import {hideTooltip, showTooltip} from "../dialog/tooltip";
|
||||
import {getIdFromSYProtocol} from "../util/pathName";
|
||||
import {App} from "../index";
|
||||
import {Constants} from "../constants";
|
||||
|
||||
let popoverTargetElement: HTMLElement;
|
||||
export const initBlockPopover = (app: App) => {
|
||||
|
|
@ -56,7 +57,7 @@ export const initBlockPopover = (app: App) => {
|
|||
clearTimeout(timeoutHide);
|
||||
timeoutHide = window.setTimeout(() => {
|
||||
hidePopover(event);
|
||||
}, 200);
|
||||
}, Constants.TIMEOUT_INPUT);
|
||||
|
||||
if (!getTarget(event, aElement)) {
|
||||
return;
|
||||
|
|
@ -84,7 +85,7 @@ export const initBlockPopover = (app: App) => {
|
|||
if (!popoverTargetElement && !aElement) {
|
||||
clearTimeout(timeout);
|
||||
}
|
||||
}, 200);
|
||||
}, Constants.TIMEOUT_INPUT);
|
||||
timeout = window.setTimeout(() => {
|
||||
if (!getTarget(event, aElement)) {
|
||||
return;
|
||||
|
|
@ -95,32 +96,34 @@ export const initBlockPopover = (app: App) => {
|
|||
});
|
||||
};
|
||||
|
||||
const hidePopover = (event: MouseEvent & { target: HTMLElement, path: HTMLElement[] }) => {
|
||||
if (hasClosestByClassName(event.target, "b3-menu") ||
|
||||
(event.target.id && event.target.tagName !== "svg" && (event.target.id.startsWith("minder_node") || event.target.id.startsWith("kity_") || event.target.id.startsWith("node_")))
|
||||
|| event.target.classList.contains("counter")
|
||||
|| event.target.tagName === "circle"
|
||||
const hidePopover = (event: MouseEvent & { path: HTMLElement[] }) => {
|
||||
// pad 端点击后 event.target 不会更新。
|
||||
const target = document.elementFromPoint(event.clientX, event.clientY);
|
||||
if (hasClosestByClassName(target, "b3-menu") ||
|
||||
(target.id && target.tagName !== "svg" && (target.id.startsWith("minder_node") || target.id.startsWith("kity_") || target.id.startsWith("node_")))
|
||||
|| target.classList.contains("counter")
|
||||
|| target.tagName === "circle"
|
||||
) {
|
||||
// b3-menu 需要处理,(( 后的 hint 上的图表移上去需显示预览
|
||||
// gutter & mindmap & 文件树上的数字 & 关系图节点不处理
|
||||
return false;
|
||||
}
|
||||
popoverTargetElement = hasClosestByAttribute(event.target, "data-type", "block-ref") as HTMLElement ||
|
||||
hasClosestByAttribute(event.target, "data-type", "virtual-block-ref") as HTMLElement;
|
||||
popoverTargetElement = hasClosestByAttribute(target, "data-type", "block-ref") as HTMLElement ||
|
||||
hasClosestByAttribute(target, "data-type", "virtual-block-ref") as HTMLElement;
|
||||
if (popoverTargetElement && popoverTargetElement.classList.contains("b3-tooltips")) {
|
||||
popoverTargetElement = undefined;
|
||||
}
|
||||
if (!popoverTargetElement) {
|
||||
popoverTargetElement = hasClosestByClassName(event.target, "popover__block") as HTMLElement;
|
||||
popoverTargetElement = hasClosestByClassName(target, "popover__block") as HTMLElement;
|
||||
}
|
||||
const linkElement = hasClosestByAttribute(event.target, "data-type", "a", true);
|
||||
const linkElement = hasClosestByAttribute(target, "data-type", "a", true);
|
||||
if (!popoverTargetElement && linkElement && linkElement.getAttribute("data-href")?.startsWith("siyuan://blocks")) {
|
||||
popoverTargetElement = linkElement;
|
||||
}
|
||||
if (!popoverTargetElement) {
|
||||
// 移动到弹窗的 loading 元素上,但经过 settimeout 后 loading 已经被移除了
|
||||
// https://ld246.com/article/1673596577519/comment/1673767749885#comments
|
||||
let targetElement = event.target;
|
||||
let targetElement = target;
|
||||
if (!targetElement.parentElement && event.path && event.path[1]) {
|
||||
targetElement = event.path[1];
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue