From 34171769d75bc1472792df929917209d92f016ec Mon Sep 17 00:00:00 2001 From: Vanessa Date: Mon, 13 Feb 2023 20:17:30 +0800 Subject: [PATCH] :art: https://github.com/siyuan-note/siyuan/issues/3499 --- app/src/layout/dock/index.ts | 1 + app/src/protyle/util/selection.ts | 10 +++++++--- app/src/util/globalShortcut.ts | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/src/layout/dock/index.ts b/app/src/layout/dock/index.ts index 65916d443..2854d26ff 100644 --- a/app/src/layout/dock/index.ts +++ b/app/src/layout/dock/index.ts @@ -117,6 +117,7 @@ ${this.position === "Top" ? ("top:" + (this.element.offsetHeight + document.getE } else { target.setAttribute("aria-label", window.siyuan.languages.unpin); this.layout.element.style.opacity = ""; + this.layout.element.style.transition = "var(--b3-width-transition)"; if (hasActive) { this.resizeElement.classList.remove("fn__none"); } diff --git a/app/src/protyle/util/selection.ts b/app/src/protyle/util/selection.ts index 610754ed9..0e134e44a 100644 --- a/app/src/protyle/util/selection.ts +++ b/app/src/protyle/util/selection.ts @@ -198,10 +198,14 @@ export const getSelectionPosition = (nodeElement: Element, range?: Range) => { if (!parentElement) { parentElement = range.startContainer.childNodes[range.startOffset - 1] as HTMLElement; } - while (!parentElement.getClientRects || (parentElement.getClientRects && parentElement.getClientRects().length === 0)) { - parentElement = parentElement.parentElement; + if (!parentElement) { + cursorRect = range.getBoundingClientRect(); + } else { + while (!parentElement.getClientRects || (parentElement.getClientRects && parentElement.getClientRects().length === 0)) { + parentElement = parentElement.parentElement; + } + cursorRect = parentElement.getClientRects()[0]; } - cursorRect = parentElement.getClientRects()[0]; } } } else { diff --git a/app/src/util/globalShortcut.ts b/app/src/util/globalShortcut.ts index 89fa6c8dd..0b6e11779 100644 --- a/app/src/util/globalShortcut.ts +++ b/app/src/util/globalShortcut.ts @@ -95,7 +95,7 @@ export const globalShortcut = () => { }); window.siyuan.hideBreadcrumb = false; } - if (!isWindow() && !hasClosestByClassName(event.target, "b3-dialog")) { + if (!isWindow() && !hasClosestByClassName(event.target, "b3-dialog") && !hasClosestByClassName(event.target, "b3-menu")) { if (event.clientX < 43) { if (!window.siyuan.layout.leftDock.pin && window.siyuan.layout.leftDock.layout.element.clientWidth > 0) { if (event.clientY > document.getElementById("toolbar").clientHeight + document.getElementById("dockTop").clientHeight &&