views:

30

answers:

1

I want clear content by change event and save last cursor position

ed.onChange.add(function(ed, o) {
    var newContent = o.content.replace(/SOMEREGEXP/ig, "");
    ed.setContent(newContent);
    //ed.selection.select(ed.getBody(), true);
    //ed.selection.collapse(false);
});

How can this do?

A: 

Try:

ed.onChange.add(function(ed, o) {
    var bookmark = ed.selection.getBookmark();
    var newContent = o.content.replace(/SOMEREGEXP/ig, "");
    ed.setContent(newContent);
    ed.selection.moveToBookmark(bookmark );
});
Thariama