3
votes

I'm using angular, and set the data of ckeditor with ngModel - when we render we set the data

editor.setData(ngModel.$viewValue);

We try to keep the cursor selection with ranges and bookmarks

but it always get to the start even if there are no DOM changes

I've tried many solutions such as

CKEditor: set cursor/caret positon

Set cursor to specific position in CKEditor

Couldn't make it work... :(

Can anyone help please...

2

2 Answers

0
votes

Try this:

var range = editor.createRange();
range.moveToElementEditablePosition( editor.editable(), true );
editor.getSelection().selectRanges( [ range ] );

Got it from this link Set cursor to specific position in CKEditor

0
votes

This will work for Ckeditor5:

editor.model.change( writer => {writer.setSelection( editor.model.document.getRoot(), 'end' );} );