Insertion

insertBreakline #

Inserts the br tag at the caret.


let insertion = this.app.create('insertion');
insertion.insertBreakline();

insertHtml #

Arguments
html String

Inserts html at the caret. This method is used for inserting inline html. In other cases you should use editor.inserContent.


let insertion = this.app.create('insertion');

insertion.insertHtml('<span>HTML</span>');
insertion.insertHtml('&nbsp;');

insertNode #

Arguments
element Node, Element, Dom
caret (optional) String

Inserts a node at caret.


// create node
let node = document.createElement('img');
node.src = 'image-url';

// insert
let insertion = this.app.create('insertion');
insertion.insertNode(node);

You can specify a caret position after inserting the node.


insertion.insertNode(node, 'end');
insertion.insertNode(node, 'start');
insertion.insertNode(node, 'after');
insertion.insertNode(node, 'before');