1

I am making a messaging app, and a user can reply to a message. He therefore arrives on the CKEditor editor; I managed to put the message he's replying to in the editor, but I can't seem to place the cursor at the start of the editor and move the message he's replying to a few lines further down. (like when replying to an email).

Here's my code :

CKEDITOR.on('instanceReady', function(e) {
        e.editor.setData('Message to reply to');
        var selection = e.editor.getSelection();
        var range = e.editor.createRange();
        range.moveToElementEditStart(range.root);
        e.editor.getSelection().selectRanges([range]);
    });

But it doesn't work...

Thank you.

yinyang
  • 99
  • 8
  • Does this answer your question? [Set keyboard caret position in html textbox](https://stackoverflow.com/questions/512528/set-keyboard-caret-position-in-html-textbox) – Webber Aug 22 '20 at 16:38
  • I tested with https://stackoverflow.com/questions/512528/set-keyboard-caret-position-in-html-textbox and https://stackoverflow.com/questions/499126/jquery-set-cursor-position-in-text-area but it doesn't work, maybe because is a ckeditor ? – yinyang Aug 22 '20 at 18:17
  • Possible to include your HTML and build a [working example](https://stackoverflow.com/help/minimal-reproducible-example) to demonstrate the issue? Also see [Set cursor to specific position in CKEditor](https://stackoverflow.com/questions/16835365/set-cursor-to-specific-position-in-ckeditor), – showdev Aug 22 '20 at 21:53

0 Answers0