Prechádzať zdrojové kódy

Trim wysiwyg text to avoid misalignment on Firefox (#454)

Faustino Kialungila 5 rokov pred
rodič
commit
86cb228df4
1 zmenil súbory, kde vykonal 7 pridanie a 1 odobranie
  1. 7 1
      src/element/textWysiwyg.tsx

+ 7 - 1
src/element/textWysiwyg.tsx

@@ -10,6 +10,12 @@ type TextWysiwygParams = {
   onSubmit: (text: string) => void;
 };
 
+// When WYSIWYG text ends with white spaces, the text gets vertically misaligned
+// in order to fix this issue, we remove those white spaces
+function trimText(text: string) {
+  return text.trim();
+}
+
 export function textWysiwyg({
   initText,
   x,
@@ -77,7 +83,7 @@ export function textWysiwyg({
 
   function handleSubmit() {
     if (editable.innerText) {
-      onSubmit(editable.innerText);
+      onSubmit(trimText(editable.innerText));
     }
     cleanup();
   }