Skip VS15 (Emoji textual presentation). (#8553)
Mastodon converts all Emoji to images, whether they have a VS15 after them or not, but leaves the VS15 in the string, which is displayed as a black box in Safari.remotes/1727458204337373841/tmp_refs/heads/signup-info-prompt
parent
5c609c7419
commit
a060beee72
|
@ -73,5 +73,10 @@ describe('emoji', () => {
|
||||||
expect(emojify('<span class="invisible">😄<br/>😴</span>😇'))
|
expect(emojify('<span class="invisible">😄<br/>😴</span>😇'))
|
||||||
.toEqual('<span class="invisible">😄<br/>😴</span><img draggable="false" class="emojione" alt="😇" title=":innocent:" src="/emoji/1f607.svg" />');
|
.toEqual('<span class="invisible">😄<br/>😴</span><img draggable="false" class="emojione" alt="😇" title=":innocent:" src="/emoji/1f607.svg" />');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('skips the textual presentation VS15 character', () => {
|
||||||
|
expect(emojify('✴︎')) // This is U+2734 EIGHT POINTED BLACK STAR then U+FE0E VARIATION SELECTOR-15
|
||||||
|
.toEqual('<img draggable="false" class="emojione" alt="✴" title=":eight_pointed_black_star:" src="/emoji/2734.svg" />');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -62,6 +62,10 @@ const emojify = (str, customEmojis = {}) => {
|
||||||
const title = shortCode ? `:${shortCode}:` : '';
|
const title = shortCode ? `:${shortCode}:` : '';
|
||||||
replacement = `<img draggable="false" class="emojione" alt="${match}" title="${title}" src="${assetHost}/emoji/${filename}.svg" />`;
|
replacement = `<img draggable="false" class="emojione" alt="${match}" title="${title}" src="${assetHost}/emoji/${filename}.svg" />`;
|
||||||
rend = i + match.length;
|
rend = i + match.length;
|
||||||
|
// If the matched character was followed by VS15 (for selecting text presentation), skip it.
|
||||||
|
if (str.codePointAt(rend) === 65038) {
|
||||||
|
rend += 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
rtn += str.slice(0, i) + replacement;
|
rtn += str.slice(0, i) + replacement;
|
||||||
str = str.slice(rend);
|
str = str.slice(rend);
|
||||||
|
|
Loading…
Reference in New Issue