JiHong88 / suneditor

Pure javascript based WYSIWYG html editor, with no dependencies.
http://suneditor.com
MIT License
1.72k stars 308 forks source link

How to get caret position (pixel x, y on the screen) #656

Open phuongnh5 opened 3 years ago

phuongnh5 commented 3 years ago

I have a scenario need show popover suggestion at caret location. I have used function core.getSelection() and have information about anchorNode (text), anchorOffset. The position, width height of anchorNode.parentNode is available, however I cannot find the way to get relative position(x,y) of current caret to parentNode. Is there anyway to get this position?

JiHong88 commented 3 years ago

@phuongnh5 https://github.com/JiHong88/SunEditor/blob/master/src/lib/core.js#L5700 This is a method to designate the position of the balloon toolbar. (It is coded taking into account the case that the size of the toolbar varies depending on the screen.)

In version 3.0.0, I will add common methods related to the position of the cursor.

rozek commented 4 weeks ago

it seems that the provided link no longer points to the proper position in your code - could you please provide a function name or s.th. similar instead?