-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Text Editor: Adding new lines between blocks and inside block content #663
Conversation
Yaay! I love this so much. MASSIVELY better. And once we merge in #662, (for which I apologize), it'll be still better yet! :D |
I wouldn't object to us going even further. I.e. do this:
instead of
But I'm also completely okay with us not going those extra steps. I imagine it gets very complex very quickly. |
@jasmussen We may want to try an HTML beautifier for this. We need to check the performance and size of a library like this. Anyone aware of a good light HTML beautifier @aduth @iseulde ? |
More parsing! 😱 😄 |
It sounds like we should hold off on that for now! As you were — let's not let perfect be the enemy of good! :D |
With the parsing, I'm just kidding. But we could avoid it though if we only do it visual => text, and not beautify when loading from the database (leave it as they saved it). |
c7f4363
to
c617670
Compare
I've added a beautifier @jasmussen. It's not the exact output you're proposing but really close. It has a lot of options we can tweak. |
OMG 😍 I love this so much. If it doesn't make things overly complex for the parsing, I really really dig this! ❤️❤️❤️❤️❤️ |
Any technical 👀 here? |
I'll have a quick look |
Works great here, I have no concerns with it... Just a question: would it not work to beautify the whole content instead of block per block? |
@iseulde It could but the difference is that we won't be able to control the new lines between the blocks, we'll have only a single new line instead of two between the different blocks. |
Should we have beautified the HTML in |
@aduth Technically it doesn't matter since it'll be beautified when switching to TextEditor |
I mean more in the sense that we want |
@youknowriad, this is quite a jump back in time 😅, but do you have any recollection of why this particular clause was added? I'm looking at this while reviewing #17164. |
@mcsf I think (I may be wrong though) that the idea is that if we serialize these blocks (don't ignore them) it will produce a lot of "empty lines" in the resulting HTML. |
Closes #633
This PR adds new lines between blocks and inside block delimeters if the content is not empty.
When parsing we trim the content of the blocks to avoid unecessary spaces, I think this is fine because the
save
method of each block return element or elements for all cases excluding the fallback block.We also ignore fallback blocks with empty content.