forked from abner/for-legacy-web
Remove twemoji dependency.
Support re-connecting after going / starting offline.
This commit is contained in:
@@ -1,22 +1,43 @@
|
||||
import twemoji from 'twemoji';
|
||||
import { EmojiPacks } from '../../redux/reducers/settings';
|
||||
|
||||
var EMOJI_PACK = 'mutant';
|
||||
const REVISION = 3;
|
||||
|
||||
/*export function setEmojiPack(pack: EmojiPacks) {
|
||||
export function setEmojiPack(pack: EmojiPacks) {
|
||||
EMOJI_PACK = pack;
|
||||
}*/
|
||||
}
|
||||
|
||||
// Originally taken from Twemoji source code,
|
||||
// re-written by bree to be more readable.
|
||||
function codePoints(rune: string) {
|
||||
const pairs = [];
|
||||
let low = 0;
|
||||
let i = 0;
|
||||
|
||||
while (i < rune.length) {
|
||||
const charCode = rune.charCodeAt(i++);
|
||||
if (low) {
|
||||
pairs.push(0x10000 + ((low - 0xd800) << 10) + (charCode - 0xdc00));
|
||||
low = 0;
|
||||
} else if (0xd800 <= charCode && charCode <= 0xdbff) {
|
||||
low = charCode;
|
||||
} else {
|
||||
pairs.push(charCode);
|
||||
}
|
||||
}
|
||||
|
||||
return pairs;
|
||||
}
|
||||
|
||||
// Taken from Twemoji source code.
|
||||
// scripts/build.js#344
|
||||
// grabTheRightIcon(rawText);
|
||||
const UFE0Fg = /\uFE0F/g;
|
||||
const U200D = String.fromCharCode(0x200D);
|
||||
function toCodePoint(emoji: string) {
|
||||
return twemoji.convert.toCodePoint(emoji.indexOf(U200D) < 0 ?
|
||||
emoji.replace(UFE0Fg, '') :
|
||||
emoji
|
||||
);
|
||||
function toCodePoint(rune: string) {
|
||||
return codePoints(rune.indexOf(U200D) < 0 ? rune.replace(UFE0Fg, '') : rune)
|
||||
.map((val) => val.toString(16))
|
||||
.join("-")
|
||||
}
|
||||
|
||||
function parseEmoji(emoji: string) {
|
||||
|
||||
@@ -52,23 +52,6 @@ export default function Embed({ embed }: Props) {
|
||||
|
||||
switch (embed.type) {
|
||||
case 'Website': {
|
||||
// ! FIXME: move this to january
|
||||
/*if (embed.url && YOUTUBE_RE.test(embed.url)) {
|
||||
embed.color = '#FF424F';
|
||||
}
|
||||
|
||||
if (embed.url && TWITCH_RE.test(embed.url)) {
|
||||
embed.color = '#7B68EE';
|
||||
}
|
||||
|
||||
if (embed.url && SPOTIFY_RE.test(embed.url)) {
|
||||
embed.color = '#1ABC9C';
|
||||
}
|
||||
|
||||
if (embed.url && SOUNDCLOUD_RE.test(embed.url)) {
|
||||
embed.color = '#FF7F50';
|
||||
}*/
|
||||
|
||||
// Determine special embed size.
|
||||
let mw, mh;
|
||||
let largeMedia = (embed.special && embed.special.type !== 'None') || embed.image?.size === 'Large';
|
||||
|
||||
Reference in New Issue
Block a user