WordPress.org

Make WordPress Core

Opened 21 months ago

Closed 20 months ago

Last modified 20 months 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 20 months ago.
22175-1.patch (1.3 KB) - added by azaozz 20 months ago.

Download all attachments as: .zip

Change History (18)

comment:1 scribu21 months ago

Previously: #13314

comment:2 scribu21 months ago

  • Milestone changed from Awaiting Review to 3.5

comment:3 SergeyBiryukov21 months ago

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

comment:4 matt21 months ago

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

comment:5 SergeyBiryukov21 months ago

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

Last edited 21 months ago by SergeyBiryukov (previous) (diff)

comment:6 follow-up: nacin21 months 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 nacin21 months ago

  • Severity changed from normal to blocker

comment:8 in reply to: ↑ 6 batmoo20 months 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 azaozz20 months 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 20 months ago by azaozz (previous) (diff)

azaozz20 months ago

comment:10 azaozz20 months ago

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

comment:11 nacin20 months ago

Does schema => 'html5' remove anything else?

comment:12 azaozz20 months 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.

azaozz20 months ago

comment:13 azaozz20 months 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 azaozz20 months 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 azaozz20 months ago

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

comment:16 azaozz20 months 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.