Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional line breaks - creates extra spacing in HTML #412

Open
mattisdada opened this issue Jun 3, 2021 · 4 comments
Open

Additional line breaks - creates extra spacing in HTML #412

mattisdada opened this issue Jun 3, 2021 · 4 comments

Comments

@mattisdada
Copy link

mattisdada commented Jun 3, 2021

Hi,

Context: We're using Squire as a HTML editor primarily for HTML that is generated by Outlook originally.

We've noticed that for <p> elements (and others) that Squire inserts a <br> at the end, it's this line: https://github.com/neilj/Squire/blob/8ff042dd22f34a50e79e122bc443e9227035ebaa/source/Node.js#L277

Testing internally, by removing this line, does indeed break the cursor as expected. (but we get lovely clean HTML)

But unfortunately this is affecting our output from Squire with it adding in a bunch of <br>s and extra whitespace in :(

HTML Before:

<p class="MsoNormal">Test</p>

HTML After:

<p class="MsoNormal">Test<br></p>

How are other people handling this? Should we re-process the HTML afterwards and strip these out? Are we maybe doing something dumb with the way we get the HTML back from Squire? (listening to the input event and using .getHTML())

@the-djmaze
Copy link

Depends if you can reopen the saved HTML.
Like re-open draft mail.

Then keep them or enter hell of browser issues due to block elements...

@nik736
Copy link

nik736 commented Mar 4, 2024

@mattisdada I have the same issue. Do you mind sharing your solution? Stripping them out afterwards seems to be unreliable as well, since in my case those could be user generated line breaks.

@mattisdada
Copy link
Author

@mattisdada I have the same issue. Do you mind sharing your solution? Stripping them out afterwards seems to be unreliable as well, since in my case those could be user generated line breaks.

I'm really sorry, no longer work at the company that I was doing this project with and I honestly cannot recall if we ever found a solution, or if we did, what that solution was 😅 . Sorry about that!

@the-djmaze
Copy link

Some browsers require a <br> inside block elements, else you can't focus your cursor (for editing) inside it.

When you get the HTML outside Squire, the <br> should be removed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants