Make WordPress Core

Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#22175 closed defect (bug) (fixed)

Switching to Visual Editor strips table attributes

Reported by: batmoo's profile batmoo Owned by: azaozz's profile 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 12 years ago.
22175-1.patch (1.3 KB) - added by azaozz 12 years ago.

Download all attachments as: .zip

Change History (18)

#1 @scribu
12 years ago

Previously: #13314

#2 @scribu
12 years ago

  • Milestone changed from Awaiting Review to 3.5

#3 @SergeyBiryukov
12 years ago

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

#4 @matt
12 years ago

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

#5 @SergeyBiryukov
12 years ago

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

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

#6 follow-up: @nacin
12 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.

#7 @nacin
12 years ago

  • Severity changed from normal to blocker

#8 in reply to: ↑ 6 @batmoo
12 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?

#9 @azaozz
12 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 12 years ago by azaozz (previous) (diff)

@azaozz
12 years ago

#10 @azaozz
12 years ago

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

#11 @nacin
12 years ago

Does schema => 'html5' remove anything else?

#12 @azaozz
12 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.

@azaozz
12 years ago

#13 @azaozz
12 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.

#14 @azaozz
12 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

#15 @azaozz
12 years ago

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

#16 @azaozz
12 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.