소스 검색

apply offset only if in container

zsviczian 2 년 전
부모
커밋
da06e8ad27
1개의 변경된 파일5개의 추가작업 그리고 3개의 파일을 삭제
  1. 5 3
      src/element/textWysiwyg.tsx

+ 5 - 3
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;