jakiestfu / Medium.js

A tiny JavaScript library for making contenteditable beautiful (Like Medium's editor)

Home Page:http://jakiestfu.github.io/Medium.js/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

What methods are available to control the Cursor / Caret?

pixeline opened this issue · comments

Hi!
Could you clarify for me what methods are actually available to control the caret or cursor position?

For instance, I thought i could use medium.cursor.moveCursorToEnd() but that throws errors.

My personal needs are to be able to place the caret at the very beginning or at the very end of the editable zone, after an ajax update of the html content.

For move cursor to end or beginning you can use this:

var editor = new Medium({ ... });

// move cursor to end
editor.cursor.moveCursorToEnd(editor.element.lastChild);

// for move cursor to beginning
editor.cursor.caretToBeginning(editor.element.firstChild);