Make WordPress Core

Opened 4 years ago

Closed 4 years ago

#39437 closed enhancement (fixed)

TinyMCE: better way to remove spaces from empty paragraphs

Reported by: azaozz Owned by: azaozz
Milestone: 4.8 Priority: normal
Severity: normal Version:
Component: TinyMCE Keywords: has-patch
Focuses: Cc:


Follow up from #35890 and #38294.

It seems better to remove the white space chars (and  ) in the DOM after the post content is loaded instead of searching through the HTML string with regex. It could be slower in some cases, but is a lot "cleaner".

Attachments (1)

39437.patch (1.1 KB) - added by azaozz 4 years ago.

Download all attachments as: .zip

Change History (6)

4 years ago

#1 @azaozz
4 years ago

  • Keywords has-patch added

In 39437.patch: remove empty spaces from paragraphs in the DOM instead of searching through the source HTML with regex.

#2 @iseulde
4 years ago

Looks good to me. Just not sure why we check for the length to be 10, it seems kind of random. We shouldn't unnecessarily check long strings of course, but still. If we are only inserting  , maybe we should only check for that?

#3 @azaozz
4 years ago

We are looking primarily for   but in innerHTML sometimes there can be couple of white space chars around it (also depends on the browser) so 10 is a good compromise between length and functionality. We want innerHTML to avoid paragraphs with inline tags.

#4 @iseulde
4 years ago

Looks good then. :)

#5 @azaozz
4 years ago

  • Owner set to azaozz
  • Resolution set to fixed
  • Status changed from new to closed

In 39902:

TinyMCE: improve removal of spaces from empty paragraphs when loading HTML in the editor.

Fixes #39437.

Note: See TracTickets for help on using tickets.