I think the InputfieldTinyMCE's Paste Filter is great! Unfortunately, I've discovered one caveat that is fairly troublesome when used against Microsoft tabular data - empty table cells, or table header cells, (which Word or Excel generate for richtext content in the clipboard) end up getting removed. That said, because table cells are structural in their nature for the proper rendering of a table, even if empty, they should not be dropped.
I'm not sure if it's good practice to use empty anchor tags when inserting anchor points on a page (ex: <a id="jump-to-here"></a>), though it is somewhat common. Pasting rich text that contains that, I would gather, is probably more of a mistake than an intentional act. I am making an assumption though, so if expansion of my adjustment to include empty anchor elements is desirable, it may be warranted. Similarly, empty list item (<li></li>) elements do hold structure but are most often mistakes. (Just being thorough in my research!)
Since order may need to be preserved for <col> elements inside of a table for accessibility purposes, an empty tag may also be required to be kept. Technically, I don't think there should be an empty one, but if any exist, if one is dropped, the association to the rows/cells is also broken.
Anyhow, here is my suggested fix to wire/modules/Inputfield/InputfieldTinyMCE/InputfieldTinyMCE.js - this only corrects empty TD elements:
Replace the affected line, with the following:
html = html.replaceAll(/<(?!t[dh]\b)([-a-z0-9]+)[^>]*>\s*<\/\1>/ig, ''); // remove empty tags except td/th
NOTE: I'm linking to a specific version of the file in time in case there are any modifications in the interim to compare and contrast my suggested fix.
See the forum topic for additional information on what was discovered.
I think the InputfieldTinyMCE's Paste Filter is great! Unfortunately, I've discovered one caveat that is fairly troublesome when used against Microsoft tabular data - empty table cells, or table header cells, (which Word or Excel generate for richtext content in the clipboard) end up getting removed. That said, because table cells are structural in their nature for the proper rendering of a table, even if empty, they should not be dropped.
I'm not sure if it's good practice to use empty anchor tags when inserting anchor points on a page (ex:
<a id="jump-to-here"></a>), though it is somewhat common. Pasting rich text that contains that, I would gather, is probably more of a mistake than an intentional act. I am making an assumption though, so if expansion of my adjustment to include empty anchor elements is desirable, it may be warranted. Similarly, empty list item (<li></li>) elements do hold structure but are most often mistakes. (Just being thorough in my research!)Since order may need to be preserved for
<col>elements inside of a table for accessibility purposes, an empty tag may also be required to be kept. Technically, I don't think there should be an empty one, but if any exist, if one is dropped, the association to the rows/cells is also broken.Anyhow, here is my suggested fix to wire/modules/Inputfield/InputfieldTinyMCE/InputfieldTinyMCE.js - this only corrects empty TD elements:
Replace the affected line, with the following:
NOTE: I'm linking to a specific version of the file in time in case there are any modifications in the interim to compare and contrast my suggested fix.
See the forum topic for additional information on what was discovered.