tweb-i2p/src/components/chat/emojiHelper.ts
morethanwords 7dc7dde962 Emoji 13.0
Emoji autocomplete helper
Fix parsing gender emoji
Fix loading first comment
Fix selecting emoji in ESG
Deactivate parallel tabs
Fix bubble reply containers width
Reset pinned dialogs order
2021-05-25 13:45:35 +03:00

46 lines
1.2 KiB
TypeScript

import type ChatInput from "./input";
import { appendEmoji, getEmojiFromElement } from "../emoticonsDropdown/tabs/emoji";
import { ScrollableX } from "../scrollable";
import AutocompleteHelper from "./autocompleteHelper";
export default class EmojiHelper extends AutocompleteHelper {
private scrollable: ScrollableX;
constructor(appendTo: HTMLElement, private chatInput: ChatInput) {
super(appendTo, 'x', (target) => {
this.chatInput.onEmojiSelected(getEmojiFromElement(target as any), true);
});
this.container.classList.add('emoji-helper');
}
private init() {
this.list = document.createElement('div');
this.list.classList.add('emoji-helper-emojis', 'super-emojis');
this.container.append(this.list);
this.scrollable = new ScrollableX(this.container);
}
public renderEmojis(emojis: string[]) {
if(this.init) {
this.init();
this.init = null;
}
if(emojis.length) {
this.list.innerHTML = '';
emojis.forEach(emoji => {
appendEmoji(emoji, this.list, false, true);
});
}
if(!this.hidden) {
this.scrollable.container.scrollLeft = 0;
}
this.toggle(!emojis.length);
}
}