问题
I updated a TYPO3 website from 7->8->9. Now the problem is that the RTE CKEditor keeps deleting style attributes and even styles.
So and old Element with content:
<div class="mobilr">
<table height="655" width="972" style="vertical-align: middle; background-color: rgb(255, 255, 255); border-style: solid; border-color: rgb(187, 187, 187);" class="centertable">
<tbody>
<tr style="vertical-align: middle;">
<td>
<p> </p>
....
is loaded in the editor as:
<table class="centertable" style="height:655px; width:972px">
<tbody>
<tr>
<td>
<p> </p>
...
So when you save you loose your style information. I tried the following TypoScript:
RTE.default.proc.allowedClasses = centertable, mobilr
RTE.default.proc.allowTags = table, tbody, tr, th, td, h1, h2, h3, h4, h5, h6, div, p, br, span, ul, ol, li, strong, em, b, i, u, sub, sup, a, img, hr, abbr, acronym, cente
RTE.default.proc.keepPDIVattribs := addToList(style)
RTE.default.proc.entryHTMLparser_db.tags.p.allowedAttribs = class, align, style
RTE.default.proc.entryHTMLparser_db.tags.td.allowedAttribs = class, align, style
RTE.default.proc.entryHTMLparser_db.tags.tr.allowedAttribs = class, align, style
RTE.default.proc.entryHTMLparser_db.tags.table.allowedAttribs = class, align, style
RTE.default.proc.entryHTMLparser_db.tags.div.allowedAttribs = class, align, style
RTE.default.proc.entryHTMLparser_db.tags.h1.allowedAttribs = class, align, style
RTE.default.proc.entryHTMLparser_db.tags.h2.allowedAttribs = class, align, style
This sadly has no effect. I placed the code in my setup and on the page. Is there a way to completely shut down the entryHTMLparser or another idea to solve this without using TS?
Thank you in advance for your help.
回答1:
That could be the configuration in the .yaml files; I see in the
EXT:rte_ckeditor/Configuration/RTE/Processing.yaml:
processing:
allowAttributes: [class, id, title, dir, lang, xml:lang, itemscope, itemtype, itemprop]
You can provide your own configuration following for example this guide; I'd try with
processing:
allowAttributes: [class, id, title, dir, lang, xml:lang, itemscope, itemtype, itemprop, style]
来源:https://stackoverflow.com/questions/55741464/typo3-9-5-4-ckeditor-rte-deletes-style-attributes