I have a <div>
that has contenteditable="true"
and after paste I'm sanitizing pasted content with Sanitize.js. The problem is, of course, that after Sanitization the cursor is put on the start of the div. How can I put cursor position after the pasted content?
HTML:
<div contentEditable="true" id="ce"></div>
JS from Sanitize.js examples (modified):
function do_sanitize(){
var elm = document.getElementById('ce');
var cfg = Sanitize.Config.RELAXED;
// Create new Sanitize object
var s = new Sanitize(cfg);
var cleaned_html = s.clean_node(elm);
// Prepare container for sanitized HTML and append it
var clean_container = document.getElementById('ce');
while(clean_container.childNodes.length > 0) {
clean_container.removeChild(clean_container.firstChild);
}
clean_container.appendChild(cleaned_html);
}