enter to submit emoji
This commit is contained in:
parent
e7e5a51a6c
commit
c0244acf2b
2 changed files with 18 additions and 2 deletions
|
@ -132,18 +132,23 @@ class Emoji {
|
||||||
topBar.append(search);
|
topBar.append(search);
|
||||||
|
|
||||||
let html: HTMLElement | undefined = undefined;
|
let html: HTMLElement | undefined = undefined;
|
||||||
|
let topEmoji: undefined | Emoji = undefined;
|
||||||
function updateSearch(this: typeof Emoji) {
|
function updateSearch(this: typeof Emoji) {
|
||||||
if (search.value === "") {
|
if (search.value === "") {
|
||||||
if (html) html.click();
|
if (html) html.click();
|
||||||
search.style.removeProperty("width");
|
search.style.removeProperty("width");
|
||||||
|
topEmoji = undefined;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
search.style.setProperty("width", "3in");
|
search.style.setProperty("width", "3in");
|
||||||
title.innerText = "";
|
title.innerText = "";
|
||||||
body.innerHTML = "";
|
body.innerHTML = "";
|
||||||
for (const [emoji] of this.searchEmoji(search.value, localuser, 200)) {
|
const searchResults = this.searchEmoji(search.value, localuser, 200);
|
||||||
|
if (searchResults[0]) {
|
||||||
|
topEmoji = searchResults[0][0];
|
||||||
|
}
|
||||||
|
for (const [emoji] of searchResults) {
|
||||||
const emojiElem = document.createElement("div");
|
const emojiElem = document.createElement("div");
|
||||||
emojiElem.classList.add("emojiSelect");
|
emojiElem.classList.add("emojiSelect");
|
||||||
|
|
||||||
|
@ -161,6 +166,14 @@ class Emoji {
|
||||||
search.addEventListener("input", () => {
|
search.addEventListener("input", () => {
|
||||||
updateSearch.call(this);
|
updateSearch.call(this);
|
||||||
});
|
});
|
||||||
|
search.addEventListener("keyup", (e) => {
|
||||||
|
if (e.key === "Enter" && topEmoji) {
|
||||||
|
res(topEmoji);
|
||||||
|
if (Contextmenu.currentmenu !== "") {
|
||||||
|
Contextmenu.currentmenu.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
menu.append(topBar);
|
menu.append(topBar);
|
||||||
|
|
||||||
|
|
|
@ -151,6 +151,9 @@ class Message extends SnowFlake {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
reactionToggle(emoji: string | Emoji) {
|
reactionToggle(emoji: string | Emoji) {
|
||||||
|
if (emoji instanceof Emoji && !emoji.id && emoji.emoji) {
|
||||||
|
emoji = emoji.emoji;
|
||||||
|
}
|
||||||
let remove = false;
|
let remove = false;
|
||||||
for (const thing of this.reactions) {
|
for (const thing of this.reactions) {
|
||||||
if (thing.emoji.name === emoji) {
|
if (thing.emoji.name === emoji) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue