Make WordPress Core

Opened 10 years ago

Closed 9 years ago

Last modified 9 years ago

#31297 closed defect (bug) (duplicate)

Convert non-breaking spaces to HTML entities on editor switch

Reported by: kau-boy's profile 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:

  1. 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.
  1. 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)

31297.diff (538 bytes) - added by Kau-Boy 10 years ago.
31297.2.diff (536 bytes) - added by Kau-Boy 9 years ago.
Updated patch for the lastest trunk version of the JS file

Download all attachments as: .zip

Change History (9)

@Kau-Boy
10 years ago

#1 @Kau-Boy
10 years ago

  • Keywords has-patch added

#2 @Kau-Boy
10 years ago

Solution 1 is also how TinyMCE behaves by default.

#3 @DrewAPicture
9 years ago

  • Version trunk deleted

@Kau-Boy
9 years ago

Updated patch for the lastest trunk version of the JS file

#4 @Kau-Boy
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 @Kau-Boy
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.

https://gist.github.com/2ndkauboy/34fb28acab0c071f5999

#6 @obenland
9 years ago

@azaozz, could you take a look when you get a chance?

#7 @azaozz
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).

Version 1, edited 9 years ago by azaozz (previous) (next) (diff)
Note: See TracTickets for help on using tickets.