From 887443c321ff57d3eb93faf2fffa142b5ab9b202 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Mon, 19 Jun 2023 21:01:57 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20sync=20tip=20=E8=BD=AC=E4=B9=89?= =?UTF-8?q?=E5=8F=8A=E6=94=AF=E6=8C=81=E7=82=B9=E5=87=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/assets/scss/component/_tooltips.scss | 10 +++++++++- app/src/block/popover.ts | 2 +- app/src/dialog/tooltip.ts | 5 ++++- app/src/layout/topBar.ts | 17 +++++++++-------- 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/app/src/assets/scss/component/_tooltips.scss b/app/src/assets/scss/component/_tooltips.scss index 14e106c67..2fb9745ad 100644 --- a/app/src/assets/scss/component/_tooltips.scss +++ b/app/src/assets/scss/component/_tooltips.scss @@ -1,5 +1,5 @@ .tooltip { - pointer-events: none; + user-select: none; // 同步悬浮需要点击链接,因此不能使用 pointer-events: none; position: fixed; z-index: 1000000; padding: 4px 8px; @@ -16,6 +16,14 @@ animation-fill-mode: both; animation-name: zoomIn; + a { + color: var(--b3-theme-secondary); + + &:hover { + text-decoration: underline; + } + } + &--error { background: var(--b3-theme-error); } diff --git a/app/src/block/popover.ts b/app/src/block/popover.ts index e16108489..caef260f4 100644 --- a/app/src/block/popover.ts +++ b/app/src/block/popover.ts @@ -37,7 +37,7 @@ export const initBlockPopover = (app: App) => { event.stopPropagation(); return; } - } else if (!aElement) { + } else if (!aElement && !hasClosestByAttribute(event.target, "id", "tooltip", true)) { hideTooltip(); } if (window.siyuan.config.editor.floatWindowMode === 1 || window.siyuan.shiftIsPressed) { diff --git a/app/src/dialog/tooltip.ts b/app/src/dialog/tooltip.ts index 3ace54993..1f10b41e3 100644 --- a/app/src/dialog/tooltip.ts +++ b/app/src/dialog/tooltip.ts @@ -26,13 +26,16 @@ export const showTooltip = (message: string, target: Element, error = false) => messageElement.classList.add("tooltip--memo"); // 为行级备注添加 class https://github.com/siyuan-note/siyuan/issues/6161 } let left = targetRect.left; + let topSpace = 8 const position = target.getAttribute("data-position"); if (position === "right") { left = targetRect.right - messageElement.clientWidth; } else if (position === "center") { left = targetRect.left + (targetRect.width - messageElement.clientWidth) / 2; + } else if (position === "top") { + topSpace = 0; } - setPosition(messageElement, left, targetRect.top + targetRect.height + 8, targetRect.height * 2 + 8); + setPosition(messageElement, left, targetRect.top + targetRect.height + topSpace, targetRect.height * 2 + 8); }; export const hideTooltip = () => { diff --git a/app/src/layout/topBar.ts b/app/src/layout/topBar.ts index 3b2e27dfd..67e477576 100644 --- a/app/src/layout/topBar.ts +++ b/app/src/layout/topBar.ts @@ -41,7 +41,7 @@ export const initBar = (app: App) => { ${getWorkspaceName()} -
+