mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-04-14 03:15:49 +02:00
Add {cursor} token to template plugin
This commit is contained in:
parent
b330b74347
commit
ee5d1a47dc
@ -133,16 +133,22 @@ enabled(){
|
||||
|
||||
var useTemplate = (contents, append) => {
|
||||
let ele = $(".js-compose-text");
|
||||
if (ele.length === 0)return;
|
||||
|
||||
if (ele.length === 0){
|
||||
return;
|
||||
}
|
||||
let value = append ? ele.val()+contents : contents;
|
||||
let tokenCursor = null;
|
||||
|
||||
// TODO
|
||||
[value, tokenCursor] = readTemplateToken(value, "cursor");
|
||||
|
||||
ele.val(append ? ele.val()+contents : contents);
|
||||
ele.val(value);
|
||||
ele.focus();
|
||||
|
||||
if (tokenCursor.length === 1){
|
||||
let [ index, length ] = tokenCursor[0];
|
||||
ele[0].selectionStart = index;
|
||||
ele[0].selectionEnd = index+(length | 0 || 0);
|
||||
}
|
||||
|
||||
if (!append){
|
||||
hideTemplateModal();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user