var node1 = $('<p>Paragraph 1</p>');
var node2 = $('<p>Paragraph 2</p>');
var marker = this.selection.getMarker();
node1.append(marker);
var container = $('<div />').append(node1).append(node2);
this.insert.htmlWithoutClean(container.html());
this.selection.restore();
To select some text, you can add two markers:
var node1 = $('<p>Paragraph 1</p>');
var node2 = $('<p>Paragraph 2</p>');
var marker1 = this.selection.getMarker(1);
var marker2 = this.selection.getMarker(2);
node1.prepend(marker1);
node2.append(marker2);
var container = $('<div />').append(node1).append(node2);
this.insert.htmlWithoutClean(container.html());
this.selection.restore();
getMarkerAsHtml
Returns marker as HTML.
If you wish to set cursor position to a specific location after pasting some text, you can use
markers.
For example:
var marker = this.selection.getMarkerAsHtml();
var html = '<p>Paragraph 1' + marker + '</p><p>Paragraph 2</p>';
this.insert.htmlWithoutClean(html);
this.selection.restore();
To select some text, you can add two markers:
var marker1 = this.selection.getMarkerAsHtml(1);
var marker2 = this.selection.getMarkerAsHtml(2);
var html = '<p>' + marker1 + 'Paragraph 1' + marker2 + '</p><p>Paragraph
2</p>';
this.insert.htmlWithoutClean(html);