quill icon indicating copy to clipboard operation
quill copied to clipboard

How to get the position of the cursor on the screen?

Open xuergo opened this issue 3 years ago • 1 comments

image I need the height to grow automatically while keeping the cursor in the viewing area,But I don't know if I can make it happen🙏🙏🙏

xuergo avatar Dec 11 '21 07:12 xuergo

There is a cursor blot in quill core. You can use like this:

findCursorPosition(index){
    this.quill.insertEmbed(index, 'cursor', {}, Quill.sources.SILENT); // Create cursor blot at your desired index (your current index)
    const cursor = document.querySelector('.ql-cursor'); // Find cursor element
    if(cursor) {
      console.log(cursor.getBoundingClientRect()); // Get position
      cursor.remove(); // Remove cursor
    }
}

Hanho-Kim avatar Jul 01 '22 03:07 Hanho-Kim

https://quilljs.com/docs/api/

benbro avatar Jan 29 '24 18:01 benbro