#Richeditor tiptap allow html attributes

3 messages · Page 1 of 1 (latest)

upper edge
#

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:

        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,
                    }, .... ```
craggy gullBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> ✅ Mark Solution

snow idol
#

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.