Search code examples
javascriptcontenteditablemedium-editor

Change focus to particular para in medium editor (github)


How to change the position of cursor to particular para in medium editor. I am able to fetch node of the target para but unable to relocate cursor. Tried focus() but its not working. Also tried Editor.selectElement() but it highlights the whole para, didn't move the cursor. Any help on this? Just a beginner to editor. Thanks in advance

https://github.com/yabwe/medium-editor


Solution

  • So found out the solution for this. MediumEditor provides method for this

    MediumEditor.selection.moveCursor(document, element, 0);
    

    It doesn't works on if editor is blur (In that case you need to focus the editor first and then use this method)