trix
trix copied to clipboard
Insert image to trix-editor through javascript
Does anyone know how to insert attachment in trix editor with javascript ?,
- I have the image through the url, and that url is working properly
- and when i use const attachment = new Trix.Attachment({content : url}) and insertAttachment, it only display the url not the image
- Trix version: 2.04
- Browser name and version: Chrome Version 112.0.5615.49 (Official Build) (64-bit)
- Operating system: Windows
Hey, have you found a solution to this?
Have you tried?
new Trix.Attachment({content : url, contentType:"image"})
function addImageUrl(url, caption) {
const attachment = new Trix.Attachment({ filename: caption, url: url, contentType: "image/png" })
element.editor.insertAttachment(attachment)
}
this worked for me.