Quill: Get and set cursor

Created on 7 Aug 2015  路  3Comments  路  Source: quilljs/quill

Is there anyway one get get/set the cursor in Quill? I'm not talking about the multi cursor module, but just the default cursor with a single edit. I want to let users save the document and the position of the cursor. If the document is loaded at a later stage, the cursor position should also be loaded and Quill should move it to the previously saved location.

Most helpful comment

Quill.getSelection() and Quill.setSelection()

All 3 comments

Quill.getSelection() and Quill.setSelection()

Thanks, that's sort of what I was looking for. Is there any way to translate the cursor selection to pixel offset? Hence, if the cursor is at position 50, how many pixels from the top (and left) of the editor content is it.

Or otherwise, determine in which div the cursor is (the divs that are added for a newline). Once you know in which newline-div the cursor is, one can simply multiply it by the height of the div (and subtract some padding).

You can use getBounds(50). It's not finalized yet so for now you must pass in an integer index. If you want to do it for the current location of the cursor you'll have to use it in combination with getSelection()

Was this page helpful?
0 / 5 - 0 ratings

Related issues

GildedHonour picture GildedHonour  路  3Comments

eamodio picture eamodio  路  3Comments

aletorrado picture aletorrado  路  3Comments

DaniilVeriga picture DaniilVeriga  路  3Comments

lustoykov picture lustoykov  路  3Comments