mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-05-02 02:34:08 +02:00
Fix emoji keyboard to append emoji at caret instead of the end
This commit is contained in:
parent
742df9dff3
commit
58296aa266
@ -84,9 +84,17 @@ enabled(){
|
|||||||
|
|
||||||
keyboard.addEventListener("click", function(e){
|
keyboard.addEventListener("click", function(e){
|
||||||
if (e.target.tagName === "IMG"){
|
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.trigger("change");
|
||||||
input.focus();
|
input.focus();
|
||||||
|
|
||||||
|
input[0].selectionStart = posStart+inserted.length;
|
||||||
|
input[0].selectionEnd = posEnd+inserted.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
|
Loading…
Reference in New Issue
Block a user