#31297 closed defect (bug) (duplicate)
Convert non-breaking spaces to HTML entities on editor switch
Reported by: | Kau-Boy | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | TinyMCE | Keywords: | has-patch |
Focuses: | administration | Cc: |
Description
The issue:
When you copy some text from a website or document, that uses non-breaking spaces (\u00a0) and you paste such text into the "Visual" editor, they will be correctly translated into an
HTML entity. But if you than switch to the "Text" editor, those non-breaking spaces, a user cannot see that the pasted text has some of these non-breaking characters.
On a website, an author pasting text was wondering, why the text had some unexpected linebreaks. As he couldn't see the non-breaking spaces, he had explanation for that.
Possible solutions:
I see two different solution:
- Convert the non-breaking space to it's HTML entity (as I do in the patch), so the user is able to identify those space, so he can decide whether he want to replace them with oridnary spaces or leave them as is.
- Add the visualchars plugin so the user can view invisible character and delete the non-breaking spaces both from the "Visual" and the "Text" editor.
Solution 1 has the drawback, that the spaces are not converted, if the user is pasting the text into the "Text" editor. But that is also the case in the current default TinyMCE version and users using the "Text" editor are usually more advanched users who might now about such spaces.
Attachments (2)
Change History (9)
#4
@
9 years ago
This issue is still present in trunk. I updated my patch and tested it again. The solution is still working as described above.
#5
@
9 years ago
To see the issue, I created a sample. Just download the following HTML file, open it in a browser and paste the content into the editor ("Visual" mode). You will see the issue in the editor (in "Visual" mode) and in the frontend, using TwentyFifteen.
#7
@
9 years ago
- Milestone Awaiting Review deleted
- Resolution set to duplicate
- Status changed from new to closed
This ticket seems close enough to #26842, closing as a duplicate.
Looking at the patch: better way of doing this is to set TinyMCE to stop converting
to U+00A0, see https://core.trac.wordpress.org/ticket/26842#comment:1. However that is not 100% backwards compatible and requires changes in many places to support it (pretty much all PHP and JS regex that filters post_content and uses \s
).
Solution 1 is also how TinyMCE behaves by default.