WordPress.org

Make WordPress Core

Opened 7 years ago

Closed 3 years ago

#29171 closed defect (bug) (worksforme)

empty (and valid) span tags are removed when switching from visual to text editor and back to visual

Reported by: ruud@… Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.9
Component: TinyMCE Keywords: has-patch needs-testing
Focuses: Cc:

Description

Forwarded from #28940, related #27391.

The difference with #27391 is that when I tried to use a Bootstrap 3 Glyphicon approach while having the 28940.patch installed the editor removes the (empty) span tag. The span tag doesn't use any new schema type of attribute, just a regular class.

(see http://getbootstrap.com/components/ Glyphicons, How to use for testing)

Attachments (2)

29171.patch (1.2 KB) - added by ruud@… 7 years ago.
Patch for #29171 (using 28940.patch as a template)
29171.2.patch (1.5 KB) - added by azaozz 5 years ago.

Download all attachments as: .zip

Change History (15)

#1 @ruud@…
7 years ago

  • Keywords needs-patch dev-feedback added

#2 @ruud@…
7 years ago

Modified 28940.patch to create this patch.

@ruud@…
7 years ago

Patch for #29171 (using 28940.patch as a template)

#3 @ruud@…
7 years ago

  • Keywords has-patch added; needs-patch removed

#4 @stephdau
7 years ago

I've tested trunk (with and without 28940.patch installed), and empty spans are always stripped out when switching from text to visual and back (with or without class, etc).

I've tried trunk with your attachment:29171.patch patch, and it did not make a difference, empty spans are still being stripped: https://cloudup.com/couAlDKgtGu

Am I missing something?

Last edited 7 years ago by stephdau (previous) (diff)

This ticket was mentioned in IRC in #wordpress-dev by stephdau. View the logs.


7 years ago

#6 @iseulde
7 years ago

  • Version changed from trunk to 3.9

#7 @ruud@…
7 years ago

Hi Stephdau, thanks for checking the patch.

I've watched your video, it is stripping empty span tags as it should.

You describe that spans with classes also get stripped out.
Did you test that case after you applied the patch?
The patch is supposed to fix exactly that.

#8 @chriscct7
6 years ago

  • Keywords needs-testing added

@azaozz
5 years ago

#9 @azaozz
5 years ago

  • Keywords dev-feedback removed
  • Milestone changed from Awaiting Review to 4.9

29171.patch looks good but maybe better to not use &nbsp; for padding. It is "visible" in the editor and the element can still be considered "empty". Thinking it's better to use <wbr /> as it doesn't affect the element at all and is easy to deal with both in the DOM and in the HTML.

In 29171.2.patch: use <wbr /> to pad empty spans and links so they are not removed on editor cleanup.

This ticket was mentioned in Slack in #core by westonruter. View the logs.


5 years ago

This ticket was mentioned in Slack in #core by melchoyce. View the logs.


4 years ago

#12 @melchoyce
4 years ago

  • Milestone changed from 4.9 to Future Release

#13 @azaozz
3 years ago

  • Milestone Future Release deleted
  • Resolution set to worksforme
  • Status changed from new to closed

Similarly to #28940, this is now superseded by the block editor. Closing as worksforme, please feel free to reopen if it makes sense to attempt to fix this in TinyMCE.

The proposed fixes above (padding empty spans inside the contenteditable area) should still work but would potentially bring edge cases in Chromium browsers as they are known to insert many empty spans in certain cases.

Note: See TracTickets for help on using tickets.