Is it possible to add an attachment element without the surrounding HTML tags to Trix editor

38 Views Asked by At

Im trying to add an element to my trix editor with specific classes. As far as im aware this can only be done using the attachment like so:

var attachment = new Trix.Attachment({ content: '<a class="class1 class2">@trix</a>' })
element.editor.insertAttachment(attachment)

The issue with this though is that Trix.attachment surrounds the element im adding with a <figure> element and inserts a fig caption element (so having to write a script that removes these and it just seems messy)

And when i try use the insertHTML function is removes any class i set on the HTML element im inserting.

So i guess im asking is there a way to use insertHTML without it removing classes i set on the elements or is there a way i can insert an attachment without it surrounded with extra HTML

Thanks

0

There are 0 best solutions below