zsviczian %!s(int64=2) %!d(string=hai) anos
pai
achega
6d071a8a13
Modificáronse 1 ficheiros con 5 adicións e 2 borrados
  1. 5 2
      src/element/textWysiwyg.tsx

+ 5 - 2
src/element/textWysiwyg.tsx

@@ -277,6 +277,9 @@ export const textWysiwyg = ({
         // As firefox, Safari needs little higher dimensions on DOM
         // As firefox, Safari needs little higher dimensions on DOM
         textElementWidth += 0.5;
         textElementWidth += 0.5;
       }
       }
+      const magicOffset = excalidrawContainer
+        ? parseFloat(getComputedStyle(excalidrawContainer).fontSize)
+        : 16;
       // Make sure text editor height doesn't go beyond viewport
       // Make sure text editor height doesn't go beyond viewport
       const editorMaxHeight =
       const editorMaxHeight =
         (appState.height - viewportY) / appState.zoom.value;
         (appState.height - viewportY) / appState.zoom.value;
@@ -284,9 +287,9 @@ export const textWysiwyg = ({
         font: getFontString(updatedTextElement),
         font: getFontString(updatedTextElement),
         // must be defined *after* font ¯\_(ツ)_/¯
         // must be defined *after* font ¯\_(ツ)_/¯
         lineHeight: `${lineHeight}px`,
         lineHeight: `${lineHeight}px`,
-        width: `${textElementWidth}px`,
+        width: `${textElementWidth+magicOffset*2}px`,
         height: `${textElementHeight}px`,
         height: `${textElementHeight}px`,
-        left: `${viewportX}px`,
+        left: `${viewportX-magicOffset}px`,
         top: `${viewportY}px`,
         top: `${viewportY}px`,
         transform: getTransform(
         transform: getTransform(
           textElementWidth,
           textElementWidth,