use DrT's code for files

pull/142/head
Aevann 2023-03-18 16:27:12 +02:00
parent 0b2e923c2f
commit 3d11c58b33
2 changed files with 20 additions and 26 deletions

View File

@ -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
@ -468,7 +486,7 @@ function handle_files(input, newfiles) {
if (span.innerHTML != ' ') span.innerHTML += ', '
span.innerHTML += file.name.substr(0, 30);
if (location.pathname != '/chat')
ta.setRangeText(`[${file.name}]`);
insertText(ta, `[${file.name}]`);
}
autoExpand(ta)

View File

@ -285,31 +285,7 @@ function emojiAddToInput(event)
strToInsert = emojiSelectSuffixDOMs[i].value + strToInsert;
strToInsert = ":" + strToInsert + ":"
const newPos = emojiInputTargetDOM.selectionStart + strToInsert.length;
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);
insertText(emojiInputTargetDOM, strToInsert)
// kick-start the preview
emojiInputTargetDOM.dispatchEvent(new Event('input'));