WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#22175 closed defect (bug) (fixed)

Switching to Visual Editor strips table attributes

Reported by: batmoo Owned by: azaozz
Milestone: 3.5 Priority: normal
Severity: blocker Version: 3.5
Component: TinyMCE Keywords:
Focuses: Cc:

Description

  • Add or Edit a Post
  • Switch to HTML editor
  • Insert a table like below
  • Switch to Visual Editor
  • Switch back to HTML editor
  • Table attributes have been stripped: <table border="0">

Example table:

<table border="0" align="left" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td>Hello</td>
</tr>
</tbody>
</table>

Attachments (2)

22175.patch (628 bytes) - added by azaozz 3 years ago.
22175-1.patch (1.3 KB) - added by azaozz 3 years ago.

Download all attachments as: .zip

Change History (18)

comment:1 @scribu3 years ago

Previously: #13314

comment:2 @scribu3 years ago

  • Milestone changed from Awaiting Review to 3.5

comment:3 @SergeyBiryukov3 years ago

align, cellspacing, cellpadding, and width attributes are listed as obsolete:
http://www.w3.org/TR/html-markup/table.html

comment:4 @matt3 years ago

Yep we can't strip those, even though they're old we're destroying data.

comment:5 @SergeyBiryukov3 years ago

Appears to be a regression caused by switching TinyMCE's schema to 'html5' in [21875].

Last edited 3 years ago by SergeyBiryukov (previous) (diff)

comment:6 follow-up: @nacin3 years ago

Yeah, ideally, schema => html5 should make TinyMCE more liberal in every way. It should not remove deprecated or removed elements or attributes.

What bothers me is that the 'schema' attribute is new. If this was a design decision rather than a side effect, we should have a conversation with TinyMCE about working towards avoiding data destruction for future development.

comment:7 @nacin3 years ago

  • Severity changed from normal to blocker

comment:8 in reply to: ↑ 6 @batmoo3 years ago

Replying to nacin:

What bothers me is that the 'schema' attribute is new. If this was a design decision rather than a side effect, we should have a conversation with TinyMCE about working towards avoiding data destruction for future development.

Is someone having this discussion with TinyMCE? Or should we patch up a workaround for now?

comment:9 @azaozz3 years ago

Did some more research about old/obsolete HTML3 attributes. They only work if the element has no css styling. On top of that some obsolete attributes are ignored as soon as any css styling is applied, even when there is no direct css style that replaces them.

In that terms we are not talking about "loosing data" but rather about preserving obsolete code that introduces inconsistencies.

Since tables were used mostly for layout, the behaviour of obsolete attributed is more consistent there. Perhaps they should be treated as special case. We can set TinyMCE to allow all HTML attributes on them.

Last edited 3 years ago by azaozz (previous) (diff)

@azaozz3 years ago

comment:10 @azaozz3 years ago

22175.patch overrides the internal cleanup in TinyMCE for <table> allowing all attributes.

comment:11 @nacin3 years ago

Does schema => 'html5' remove anything else?

comment:12 @azaozz3 years ago

Still looking at that. Another obsolete attribute we should probably allow is <a name="...">. Seems a lot of users are still trying to use old style anchors. There's no good way to do that from the settings, will patch tiny_mce.js.

@azaozz3 years ago

comment:13 @azaozz3 years ago

22175-1.patch adds the obsolete table attributes and <a name> to the html5 schema in TinyMCE using the 'wordpress' plugin. It also allows for this to be disabled from the init array.

comment:14 @azaozz3 years ago

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

In 22411:

Allow commonly used obsolete HTML5 attributes in TinyMCE, table[summary|width|border|frame|rules|cellspacing|cellpadding|align|bgcolor] and a[name], fixes #22175

comment:15 @azaozz3 years ago

As discussed in #wordpress-dev removed the extra setting to disable this. Can be overwritten from another MCE plugin if needed.

comment:16 @azaozz3 years ago

In 22600:

TinyMCE: extend the allowed obsolete attributes to include tr, th and td (thead, tfoot and tbody weren't around in HTML 3.2), see #22175

Note: See TracTickets for help on using tickets.