mervick / emojionearea

Emoji Picker Plugin for jQuery
https://jsfiddle.net/mervick/1v03Lqnu/765/
MIT License
953 stars 257 forks source link

$("selector")[0].selectionStart does not work with emoji text area #409

Closed juniorjp closed 3 years ago

juniorjp commented 4 years ago

Hi, any way to solve this?

mervick commented 4 years ago

What browser? Any example? jsfiddle.net

Thiagoaugustto commented 4 years ago

Hi @mervick , how are you? The problem is this in the stack: https://stackoverflow.com/questions/63307114/get-the-cursor-position-in-a-text-that-has-emojis-and-insert-tags My function passes the wrong position, if there is an emoji in some part of the text.

juniorjp commented 4 years ago

@mervick , what we are trying to achieve is getting the last cursor position inside the contenteditable div, that way we can insert "tags" in the correct place. I have updated the title of the issue and created a jsfiddle showing what we want to achieve:

https://jsfiddle.net/7u2khqpd/2

I appreciate any feedback :)

mervick commented 3 years ago

Sorry for the late reply.

selectionStart works only for regular teaxtarea or input's, but emojionearea uses contenteditable div, so where is no way to make selectionStart works with div element

https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setSelectionRange