forked from rDrama/rDrama
use DrT's code for files
parent
0b2e923c2f
commit
3d11c58b33
|
@ -422,6 +422,24 @@ function focusSearchBar(element)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function insertText(input, text) {
|
||||||
|
const newPos = input.selectionStart + text.length;
|
||||||
|
input.setRangeText(text);
|
||||||
|
|
||||||
|
if (window.chrome !== undefined)
|
||||||
|
setTimeout(function(){
|
||||||
|
input.focus();
|
||||||
|
for(let i = 0; i < 2; i++)
|
||||||
|
input.setSelectionRange(newPos, newPos);
|
||||||
|
|
||||||
|
input.focus();
|
||||||
|
for(let i = 0; i < 2; i++)
|
||||||
|
input.setSelectionRange(newPos, newPos);
|
||||||
|
}, 1);
|
||||||
|
else
|
||||||
|
input.setSelectionRange(newPos, newPos);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//FILE SHIT
|
//FILE SHIT
|
||||||
|
@ -468,7 +486,7 @@ function handle_files(input, newfiles) {
|
||||||
if (span.innerHTML != ' ') span.innerHTML += ', '
|
if (span.innerHTML != ' ') span.innerHTML += ', '
|
||||||
span.innerHTML += file.name.substr(0, 30);
|
span.innerHTML += file.name.substr(0, 30);
|
||||||
if (location.pathname != '/chat')
|
if (location.pathname != '/chat')
|
||||||
ta.setRangeText(`[${file.name}]`);
|
insertText(ta, `[${file.name}]`);
|
||||||
}
|
}
|
||||||
|
|
||||||
autoExpand(ta)
|
autoExpand(ta)
|
||||||
|
|
|
@ -285,31 +285,7 @@ function emojiAddToInput(event)
|
||||||
strToInsert = emojiSelectSuffixDOMs[i].value + strToInsert;
|
strToInsert = emojiSelectSuffixDOMs[i].value + strToInsert;
|
||||||
|
|
||||||
strToInsert = ":" + strToInsert + ":"
|
strToInsert = ":" + strToInsert + ":"
|
||||||
const newPos = emojiInputTargetDOM.selectionStart + strToInsert.length;
|
insertText(emojiInputTargetDOM, strToInsert)
|
||||||
|
|
||||||
emojiInputTargetDOM.setRangeText(strToInsert);
|
|
||||||
|
|
||||||
const emojiInsertedEvent = new CustomEvent("emojiInserted", { detail: { emoji: strToInsert } });
|
|
||||||
document.dispatchEvent(emojiInsertedEvent);
|
|
||||||
|
|
||||||
// Sir, come out and drink your Chromium complaint web
|
|
||||||
// I HATE CHROME. I HATE CHROME
|
|
||||||
if(window.chrome !== undefined)
|
|
||||||
setTimeout(function(){
|
|
||||||
console.warn("Chrome detected, r-slured mode enabled.");
|
|
||||||
|
|
||||||
// AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
|
||||||
// JUST WORK STUPID CHROME PIECE OF SHIT
|
|
||||||
emojiInputTargetDOM.focus();
|
|
||||||
for(let i = 0; i < 2; i++)
|
|
||||||
emojiInputTargetDOM.setSelectionRange(newPos, newPos);
|
|
||||||
|
|
||||||
emojiInputTargetDOM.focus();
|
|
||||||
for(let i = 0; i < 2; i++)
|
|
||||||
emojiInputTargetDOM.setSelectionRange(newPos, newPos);
|
|
||||||
}, 1);
|
|
||||||
else
|
|
||||||
emojiInputTargetDOM.setSelectionRange(newPos, newPos);
|
|
||||||
|
|
||||||
// kick-start the preview
|
// kick-start the preview
|
||||||
emojiInputTargetDOM.dispatchEvent(new Event('input'));
|
emojiInputTargetDOM.dispatchEvent(new Event('input'));
|
||||||
|
|
Loading…
Reference in New Issue