How to set cursor position to end of table cell in CKEditor 5?

Viewed 177

Is there a way to set the cursor at the end of the inserted text of a table cell in CKEditor5?

The cursor is coming at the front of the table cell text. It is not coming at the end of the inserted text of table cell.

I am using below piece of code to put the cursor at the end of table cell.

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

Above method is only working for text field, it is not working in table cell.

Any help will be appreciated.

1 Answers

The below solution works for me... For entering the content in table cell we can use

editor.model.insertContent().
 
editor.model.change(writer => {
        const modelFragment = "data to be inserted"
        editor.model.insertContent(modelFragment, editor.model.document.selection.getFirstPosition());
      });

By using editor.model.document.selection.getFirstPosition() method , the cursor will automatically came to last line of table cell

Related