insertHTML

Release 2.6.0 and above.

Inserts HTML.

If the parameter has an ID, it is inserted at the position corresponding to the ID and Offset.

If the ID does not exist, it is inserted in the next paragraph based on the current Selection.

Parameters:

<table> <thead> <tr><th>Name</th><th>Type</th><th>Description</th></tr> </thead> <tbody> <tr> <td><code>html</code></td> <td>String</td> <td>The HTML string to insert.</td> </tr> <tr> <td><code>id</code></td> <td>String</td> <td>The ID of the paragraph where the HTML will be inserted.</td> </tr> <tr> <td><code>offset</code></td> <td>Number</td> <td>The position where the HTML will be inserted (offset [default = 0]).</td> </tr> <tr> <td>

<code>forceRender</code>

Release 2.11.0 and above.

</td> <td>Boolean</td> <td>Whether to render immediately (default true).</td> </tr> </tbody> </table>

Example:

var html = '<svg xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="none" viewBox="0 0 130.67 131.67" style="width: 100%; height: 100%; transform: matrix(1, 0, 0, 1, 0, 0); left: 0px; top: 0px;"><g transform="translate(1.335, 1.335)"><path stroke-width="2.67" d="M 0,64.5 A 64,64.5 0 0,1 64,0 A 64,64.5 0 0,1 128,64.5 A 64,64.5 0 0,1 64,129 A 64,64.5 0 0,1 0,64.5 Z " stroke="rgb(79, 129, 189)" stroke-dasharray="" fill="rgb(247, 150, 70)" vector-effect="non-scaling-stroke"></path></g></svg>';
editor.insertHTML(html);

Example2:

var html = 'html Content';
editor.insertHTML(html, id, offset);

Demo:

<!-- html -->
<p id='sign'>&nbsp;</p>
// javascript
var html = '<img src="https://synapeditor.com/wp-content/uploads/2019/08/newvalue_01.png" style="width:50px; height:50px;">';
var paragraphId = 'sign';
editor.insertHTML(html, paragraphId);