How to keep original html or adjust SunEditor's standardized html function?
Hi SunEditor,
When add html to the editor, SunEditor will standardize the html by adding some tags, removing the attributes of some tags, especially the <img> and <table>.
For my project, I need SunEditor to keep the original Html? or adjust SunEditor's standardized html function?
Could you give me some guide.
Yes, interested in this one too, it also does this with the <div> tags, although managed to force a class that i can alter through a CSS file, in my instance I want to put a background image or color to a <div> .
Sorry, for the late reply.😢
The __se__tag class prevents subtag changes.
can you show me the you html string?
Is there a solution to this problem?
@JiHong88 My html:
<table>
<tr>
<td>
<a href="#">link</a>
</td>
</tr>
</table>
After standardization:
<table>
<tbody>
<tr>
<td>
<div><a href="#">link</a></div>
</td>
</tr>
</tbody>
</table>
@cscxj Currently, That format is a forced format. Can't chang.
@JiHong88 not sure if this is related but im trying to add attributes in code view but when i toggle back in it disappears
<h1 id="my-anchor">Introduction<h1>
@AbdulkarimOgaji
You can use the attributesWhitelist option.
ex)
attributesWhitelist: {
'all': 'style|data-.+', // Apply to all tags
input': 'checked|name' // Apply to input tag
'???': '*' // "*" === all attributes
}
I tried that snippet above as well, and it does work for the style attribute, but not class. I assume that's because class is part of the native attributes and it conflicts if allowed in the whitelist so using this:
'all': 'class|style',
This code wouldn't actually work for class just style. Is that assumption correct?
It seems the "class" attribute always gets removed even with 'all': '*' Is there any workaround for this?
https://github.com/JiHong88/suneditor/issues/1320
As of 2.46.3, you should be able to use strictMode: false option, no? Maybe this issue can be closed?