1
0
mirror of https://github.com/chylex/TweetDuck.git synced 2025-04-23 03:15:48 +02:00

Fix emoji keyboard to append emoji at caret instead of the end

This commit is contained in:
chylex 2017-04-05 23:08:52 +02:00
parent 742df9dff3
commit 58296aa266

View File

@ -84,9 +84,17 @@ enabled(){
keyboard.addEventListener("click", function(e){
if (e.target.tagName === "IMG"){
input.val(input.val()+e.target.getAttribute("alt"));
var val = input.val();
var inserted = e.target.getAttribute("alt");
var posStart = input[0].selectionStart;
var posEnd = input[0].selectionEnd;
input.val(val.slice(0, posStart)+inserted+val.slice(posStart));
input.trigger("change");
input.focus();
input[0].selectionStart = posStart+inserted.length;
input[0].selectionEnd = posEnd+inserted.length;
}
e.stopPropagation();