small fixes
This commit is contained in:
parent
d86b7ba333
commit
ad523574e2
|
@ -60,18 +60,17 @@ const convertUnicode = (c: string) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const convertEmoji = (str: string, customEmojis: any, autoplay: boolean) => {
|
const convertEmoji = (str: string, customEmojis: any, autoplay: boolean) => {
|
||||||
|
if (str.length < 3) return str;
|
||||||
if (str in customEmojis) {
|
if (str in customEmojis) {
|
||||||
const emoji = customEmojis[str];
|
const emoji = customEmojis[str];
|
||||||
const filename = autoplay ? emoji.url : emoji.static_url;
|
const filename = autoplay ? emoji.url : emoji.static_url;
|
||||||
|
|
||||||
if (filename?.length > 0) {
|
if (filename?.length > 0) {
|
||||||
return convertCustom(str, filename);
|
return convertCustom(str, filename);
|
||||||
} else {
|
|
||||||
return str;
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
return str;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return str;
|
||||||
};
|
};
|
||||||
|
|
||||||
const popStack = (stack: string, open: boolean, res: string) => {
|
const popStack = (stack: string, open: boolean, res: string) => {
|
||||||
|
@ -132,8 +131,9 @@ const emojify = (str: string | any, customEmojis = {}, autoplay = false) => {
|
||||||
.contents()
|
.contents()
|
||||||
.filter(filterTextNodes)
|
.filter(filterTextNodes)
|
||||||
.each((idx, el) => {
|
.each((idx, el) => {
|
||||||
|
// skip common case
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
if (el.data.length < 3) return;
|
if (el.data.length === 0 || el.data === ' ') return;
|
||||||
|
|
||||||
// mutating el.data is incorrect but we do it to prevent a second dom parse
|
// mutating el.data is incorrect but we do it to prevent a second dom parse
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
|
|
Loading…
Reference in New Issue