From 1dade85ef34134601a448bdd9ba3ec07dec57789 Mon Sep 17 00:00:00 2001 From: umaranis Date: Sun, 11 Feb 2024 10:05:16 +1100 Subject: [PATCH] bug: floating formatter toolbar position --- .../src/core/plugins/util/setFloatingElemPosition.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/svelte-lexical/src/core/plugins/util/setFloatingElemPosition.ts b/packages/svelte-lexical/src/core/plugins/util/setFloatingElemPosition.ts index 80a4bef..714d48a 100644 --- a/packages/svelte-lexical/src/core/plugins/util/setFloatingElemPosition.ts +++ b/packages/svelte-lexical/src/core/plugins/util/setFloatingElemPosition.ts @@ -12,6 +12,7 @@ export function setFloatingElemPosition( targetRect: DOMRect | null, floatingElem: HTMLElement, anchorElem: HTMLElement, + isLink: boolean = false, verticalGap: number = VERTICAL_GAP, horizontalOffset: number = HORIZONTAL_OFFSET, ): void { @@ -31,7 +32,11 @@ export function setFloatingElemPosition( let left = targetRect.left - horizontalOffset; if (top < editorScrollerRect.top) { - top += floatingElemRect.height + targetRect.height + verticalGap * 2; + // adjusted height for link element if the element is at top + top += + floatingElemRect.height + + targetRect.height + + verticalGap * (isLink ? 9 : 2); } if (left + floatingElemRect.width > editorScrollerRect.right) {