Ankur Aggarwal Ankur Aggarwal - 6 months ago 36
Javascript Question

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

Answer

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)