From da06e8ad2738530b57f7709e5e4288464f932f47 Mon Sep 17 00:00:00 2001 From: zsviczian Date: Mon, 6 Mar 2023 21:52:02 +0100 Subject: [PATCH] apply offset only if in container --- src/element/textWysiwyg.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/element/textWysiwyg.tsx b/src/element/textWysiwyg.tsx index befab7e58..1bc0954d3 100644 --- a/src/element/textWysiwyg.tsx +++ b/src/element/textWysiwyg.tsx @@ -270,13 +270,15 @@ export const textWysiwyg = ({ const lineHeight = updatedTextElement.containerId ? approxLineHeight : updatedTextElement.height / lines.length; + let magicOffset = 0; if (!container) { maxWidth = (appState.width - 8 - viewportX) / appState.zoom.value; textElementWidth = Math.min(textElementWidth, maxWidth); + } else { + magicOffset = excalidrawContainer + ? parseFloat(getComputedStyle(excalidrawContainer).fontSize) + : 16; } - const magicOffset = excalidrawContainer - ? parseFloat(getComputedStyle(excalidrawContainer).fontSize) - : 16; // Make sure text editor height doesn't go beyond viewport const editorMaxHeight = (appState.height - viewportY) / appState.zoom.value;