-
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
Paste: Remove HTML Formatting Space #17470
Conversation
Hm, I think this should work for the MS Word issue (see #17459), too. Could we maybe add something like these two sample paragraphs to the MS Word fixture, though? |
2b1d9df
to
05bfe9b
Compare
@tfrommen I think https://github.com/WordPress/gutenberg/pull/17470/files#diff-d84fbca4bbde019dae6d0aa82778e23c should account for that. |
Does this account for |
@ZebulanStanphill that’s a good catch! I’ll disable it in pre elements. |
Hm, somehow I thought this would be specific to certain destinations, like MS Word, Google Doc, whatever. But now I see that this is running always. In that case, there are more use cases where line breaks are to be left alone, for example, the content of a I understand the reasoning behind this PR, but, for now, I would really love for the other, much more focused PR, #17459, to get merged. 😶 |
Form elements like |
Hi, |
packages/blocks/src/api/raw-handling/html-formatting-remover.js
Outdated
Show resolved
Hide resolved
4a454f6
to
29d2f30
Compare
There's a test failure which appears it could be legitimate (failing |
@aduth Fixed in the last commit. |
I'm not 100% confident that this is following the previously-mentioned specification, especially with regards to:
https://www.w3.org/TR/css-text-3/#white-space-phase-1 ...which isn't really explicitly handled here. But it does seem to work as expected with everything I've thrown at it. |
4c95a1d
to
760a492
Compare
Yeah, this is a simplified version. We can make adjustments if it's not enough. Tabs are replaced with spaces, which are preserved or removed depending on the context. |
character === ' ' || | ||
character === '\r' || | ||
character === '\n' || | ||
character === '\t' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
\f
(form feed) is also allowed here, though rare in practice.
Description
Fixes #13497. (Alternative to #17459. This is a more general solution to work with any source and any block type, so it also fixes the following issues:)
Fixes #17302.
Fixes #14298.
Fixes #13647.
In HTML, there are a few characters you can use to format the code (indent, make it pretty etc.):
\n
,\t
and normal spaces. We don't want our paste output to have these characters. Sequences of these characters should be removed, or replaced with a single normal space if it is a meaningful space (in other words, part of the content).To do: write unit tests.
How has this been tested?
Screenshots
Types of changes
Checklist: