WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 7 months ago

Last modified 7 months ago

#39837 closed defect (bug) (worksforme)

Random blank spaces appearing at end of lines

Reported by: maliktunga Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.7.2
Component: TinyMCE Keywords:
Focuses: Cc:
PR Number:

Description

So far, I have encountered this issue only with the visual editor.

When I write in the visual editor, it often adds "ghost formatting" that makes it so that I get blank spaces a bit everywhere at the end of lines, while the next word(s) in the paragraph would totally fit in that blank space.

I have no knowledge in technical terms, so I will define those random blank spaces as "ghost formatting", since it seems to be integrated in the HTML code, yet it's invisible in the HTML editor.

I can easily find examples from my blog. However I am not sure that I can really share the broken HTML code, since in most text boxes the "ghost formatting" gets lost in the process...

This is the broken HTML code:

La <em>Kompleta Gramatiko</em> adaptis frazi ek verko qua esis obsoleta <em>de la komenco</em>! Beaufront adaptis la paragrafo por la nova verbi «mixita», ma semblas, ke lu ankore nesavis pri <b>ind</b>... Nam yen ke on ja trovis <b>honorinda</b>, <b>ridinda</b> e <b>shaminda</b> en la <em>Dictionnaire français-international</em> (1908)!

This is the fixed HTML code:

La <em>Kompleta Gramatiko</em> adaptis frazi ek verko qua esis obsoleta <em>de la komenco</em>! Beaufront adaptis la paragrafo por la nova verbi «mixita», ma semblas, ke lu ankore nesavis pri <b>ind</b>... Nam yen ke on ja trovis <b>honorinda</b>, <b>ridinda</b> e <b>shaminda</b> en la <em>Dictionnaire français-international</em> (1908)!

Fixing it is simple: I copy the paragraph, paste it in a text box that doesn't support the "ghost formatting" (e.g. Chromium's address bar) then copy and paste it back into the HTML editor. Somehow, the blank spaces disappear. However, that workaround easily gets tedious since I have to do it every time...

I attached a screenshot that shows how the two codes looks like on my blog and in the visual editor.

I use Chromium 55.0.2883.87 Built on Ubuntu , running on elementary 0.4 (64-bit).

Attachments (3)

blank.png (55.6 KB) - added by maliktunga 3 years ago.
Comparison of the broken HTML code and the repaired HTML code
broken.txt (693 bytes) - added by maliktunga 3 years ago.
A sample of broken HTML code
repaired.txt (343 bytes) - added by maliktunga 3 years ago.
A sample of repaired HTML code

Download all attachments as: .zip

Change History (6)

@maliktunga
3 years ago

Comparison of the broken HTML code and the repaired HTML code

#1 @SergeyBiryukov
3 years ago

  • Component changed from Formatting to TinyMCE

@maliktunga
3 years ago

A sample of broken HTML code

@maliktunga
3 years ago

A sample of repaired HTML code

#2 @maliktunga
3 years ago

From a friend who knows coding a bit more than I:

He says that there are five spaces in the broken code that are actually non-breaking spaces (C2A0). They seem to have been inserted before and after HTML tags.

#3 @azaozz
7 months ago

  • Milestone Awaiting Review deleted
  • Resolution set to worksforme
  • Status changed from new to closed

there are five spaces in the broken code that are actually non-breaking spaces

Yes, this is the same feature (bug) in the browsers trying to keep empty spaces typed by the user in contenteditable. In some cases and in some browsers these invisible non-breaking spaces are inserted at many different places. Unfortunately it is impossible to "guess" whether the user intended to insert a &nbsp; or the browser just added it, so fixing this is pretty hard/prone to errors and edge cases.

This works much better in the block editor now. Closing as worksforme as it is the expected browser behaviour in contenteditable. Feel free to reopen with ideas about how to make it better in the classic editor, if still needed.

Last edited 7 months ago by azaozz (previous) (diff)
Note: See TracTickets for help on using tickets.