Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Allowing <thead> in RTE

Avatar

Level 4

When we paste modern tables into RTE, we see that <thead> is removed and <tbody> is added to wrap the whole table.  This is unacceptable markup.  How do we use <thead> in our embedded tables?

1 Accepted Solution

Avatar

Correct answer by
Level 10

trench999 wrote...

 

I think this is a case of an RTE not being able to easily protect a user against making a mess, but there should be some way to allow an override.  The last bullet:  How does one configure this?

 

Unfortunately, Currently it is not built in.  If you have strong business case please reopen the daycare ticket OR create a new ticket and request for "prefer preserve" option for rte to leave <thead> information "as is". 

View solution in original post

6 Replies

Avatar

Level 10

Look at Class CQ.form.rte.plugins.TablePlugin, defaultValues has header set to "none" - which means it would not include <thead> (table header) tags, and thus might be causing this issue.

http://dev.day.com/docs/en/cq/current/widgets-api/index.html?class=CQ.form.rte.plugins.Plugin

Defaults to: { "cellspacing": "0", "cellpadding": "1", "border": "1", "columns": "3", "rows": "2", "header": "none", "tableTemplate": null }

Avatar

Level 4

We're actually not using the table plugin. We're simply pasting html into source.  Does this still apply?

Avatar

Level 10

When working with RTE in a component, typically its done via a component dialog built using JCR nodes and then plug-ins are configured so that additional functionality is added, as described here.

http://dev.day.com/docs/en/cq/5-5/administering/configuring_rich_text_editor.html

You are not using a RTE this way?

Avatar

Level 4

This use case is specifically in our tailored Text Editor that is primarily the RTE widget.  We are using some plugins, but not the table one for some UX reasons.  During automated migrations we have some tables coming into these RTE widgets and simply need the <thead> to stay intact.

We talked to Day Care about this and received a thorough reply:

---------

The reported issue is a known limitation of CQ 5.6.1. The similar bug was already opened with R&D on behalf of another AEM customer. The response from our development team was the following:

Please note that it is generally not possible to keep HTML "as is" for WYSIWYG editing, as some adjustments are simply required to make a HTML fragment editable at all. It is strongly recommended to use a non-WYSIWYG component for texts that really require preserving HTML "as is".

Non-exhaustive list of automatic DOM changes:

  • comments are removed
  • block content is enforced (_line 1<br>line 2_ is converted to _<p>line 1<br>line 2</p>_)
  • nested lists may be changed to be correct HTML (_<ul><li>item 1</li><ul><li>Item 1.1</li></ul></ul>_ will be changed to _<ul><li>item 1<ul><li>Item 1.1</li></ul></li></ul>_)
  • Tags that are not supported may be removed (this is basically configurable, but there is a reason for removing unsupported tags, so subsequent errors should be expected if a text with unsupported HTML is edited).

In this special case (_<thead>_), none of the "popular" RTE's (_CKeditor_, _TinyMCE_) does fully support _<thead>_. CKeditor creates and manages a <thead> section under several intransparent circumstances, but creates invalid HTML if for example a cell from _<thead>_ is merged with a cell from _<tbody>_. TinyMCE doesn't allow to create _<thead>_ at all, but actually preserves it if inserted from source code view. If the user tries to merge cells from _<thead>_ and _<tbody>_, it doesn't allow so.

-----

I think this is a case of an RTE not being able to easily protect a user against making a mess, but there should be some way to allow an override.  The last bullet:  How does one configure this?

Avatar

Correct answer by
Level 10

trench999 wrote...

 

I think this is a case of an RTE not being able to easily protect a user against making a mess, but there should be some way to allow an override.  The last bullet:  How does one configure this?

 

Unfortunately, Currently it is not built in.  If you have strong business case please reopen the daycare ticket OR create a new ticket and request for "prefer preserve" option for rte to leave <thead> information "as is". 

Avatar

Level 2

HI All,

I have tried the above solution but seems that its only generates <th> element but not <thead> element in the table.

Has anyone found out any solution to include <thead>?

Thanks,

Mayur