Add HTML Code using postMassges

Hello!

I’m pretty new to using the editor, so I have a few questions.
Can postMessages be used to insert an HTML from my backend to the editor render?

Like this:
<div style='text-align: center; font-family: arial,helvetica,sans-serif; font-size: small;'><img style='-webkit-user-select: none' src='loadimage.jpg'><br />This should be my text<br />#{variable}<br />#{variable}<br />Contato: (#{procevariable}) #{variable} - Email: #{variable}</div>

Right now I’m using the InsertText function to add it, but it adds this as text.
Also, is it possible to add a select element to the header? I’m using the “Insert_Button” postMessage to add a button that opens a modal for the user to get the info I need.

To insert HTML, did you consider Action_Paste ? See PostMessage API — SDK https://sdk.collaboraonline.com/ documentation

text/html should work as a mimetype.

@vmiklos thanks for the replay! It worked, but when trying to put the image in the HTML, the editor showed me an error message, saying it could not add an image from another site.

1 Like