Remove text trim (#947)

This was added when we were computing the width without adding "pre" behavior. Now it is no longer an issue
This commit is contained in:
Christopher Chedeau 2020-03-14 14:00:20 -07:00 committed by GitHub
parent b49f9b29e5
commit 809d7ba9f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -13,12 +13,6 @@ type TextWysiwygParams = {
onCancel: () => void; onCancel: () => 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({ export function textWysiwyg({
initText, initText,
x, x,
@ -30,9 +24,6 @@ export function textWysiwyg({
onSubmit, onSubmit,
onCancel, onCancel,
}: TextWysiwygParams) { }: TextWysiwygParams) {
// Using contenteditable here as it has dynamic width.
// But this solution has an issue — it allows to paste
// multiline text, which is not currently supported
const editable = document.createElement("div"); const editable = document.createElement("div");
try { try {
editable.contentEditable = "plaintext-only"; editable.contentEditable = "plaintext-only";
@ -110,7 +101,7 @@ export function textWysiwyg({
function handleSubmit() { function handleSubmit() {
if (editable.innerText) { if (editable.innerText) {
onSubmit(trimText(editable.innerText)); onSubmit(editable.innerText);
} else { } else {
onCancel(); onCancel();
} }