Skip to content

Commit

Permalink
Remove text trim (excalidraw#947)
Browse files Browse the repository at this point in the history
This was added when we were computing the width without adding "pre" behavior. Now it is no longer an issue
  • Loading branch information
vjeux authored Mar 14, 2020
1 parent b49f9b2 commit 809d7ba
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions src/element/textWysiwyg.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@ type TextWysiwygParams = {
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({
initText,
x,
Expand All @@ -30,9 +24,6 @@ export function textWysiwyg({
onSubmit,
onCancel,
}: 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");
try {
editable.contentEditable = "plaintext-only";
Expand Down Expand Up @@ -110,7 +101,7 @@ export function textWysiwyg({

function handleSubmit() {
if (editable.innerText) {
onSubmit(trimText(editable.innerText));
onSubmit(editable.innerText);
} else {
onCancel();
}
Expand Down

0 comments on commit 809d7ba

Please sign in to comment.