Richeditor tiptap allow html attributes

I have a html formatted text in database, eg: <img src="..." width="100%" alt="XY" style="border:red 1px solid"/> If I load this into the richeditor, the width and style tags will be removed. And vica versa: - I built an extension which allows to edit class, style, width, height, alt and title tag. - the alt and title tag will be in the saved html code, but the class, style, widht and height will be removed. How can I allow html attributes? I have this code in my image-editor.js, but still not allow these attributes in saved html:
addGlobalAttributes() {
return [
{
types: ["image"],
attributes: {
style: {
default: null,
parseHTML: (element) => element.getAttribute("style"),
renderHTML: (attributes) => {
if (!attributes.style) {
return null;
}
return {
style: attributes.style,
};
},
keepOnSplit: false,
}, ....
addGlobalAttributes() {
return [
{
types: ["image"],
attributes: {
style: {
default: null,
parseHTML: (element) => element.getAttribute("style"),
renderHTML: (attributes) => {
if (!attributes.style) {
return null;
}
return {
style: attributes.style,
};
},
keepOnSplit: false,
}, ....
2 Replies
awcodes
awcodes4d ago
I think this might be a priority issue. Ie the Core Image has a higher priority than the global attributes based on loading order. Try setting a higher priority on your custom extension.
Roland Barkóczi
Roland BarkócziOP4d ago
Could you give me a clue how to do it?

Did you find this page helpful?