У меня есть <div>
с contenteditable="true"
, и после вставки я очищаю вставленный контент с помощью Sanitize.js. Проблема, конечно, в том, что после санации курсор ставится на начало div. Как я могу поставить курсор после вставленного содержимого?
HTML: <div contentEditable="true" id="ce"></div>
JS из примеров Sanitize.js (изменено):
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);
}