I have <div>one that has one contenteditable="true", and after pasting, I sanitize pasting content with Sanitize.js . The problem, of course, is that after sanitization, the cursor is placed at the beginning of the div. How to place cursor position after pasted content?
HTML:
<div contentEditable="true" id="ce"></div>
JS from Sanitize.js examples (changed):
function do_sanitize(){
var elm = document.getElementById('ce');
var cfg = Sanitize.Config.RELAXED;
var s = new Sanitize(cfg);
var cleaned_html = s.clean_node(elm);
var clean_container = document.getElementById('ce');
while(clean_container.childNodes.length > 0) {
clean_container.removeChild(clean_container.firstChild);
}
clean_container.appendChild(cleaned_html);
}
source
share