feat: implement client-side emoji parsing for display and server-side emoji rendering to canvas.
No files matched your search
@@ -17,7 +17,7 @@ export function parseTextWithEmojis(text: string): EmojiSegment[] {
|
||||
// Use twemoji to parse and replace emojis
|
||||
const parsed = twemoji.parse(text, {
|
||||
callback: (icon: string, options: any) => {
|
||||
return `https://cdn.jsdelivr.net/gh/twitter/twemoji@14.0.2/assets/72x72/${icon}.png`;
|
||||
return `https://cdn.jsdelivr.net/gh/jdecked/twemoji@latest/assets/72x72/${icon}.png`;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -33,7 +33,7 @@ export function parseTextWithEmojis(text: string): EmojiSegment[] {
|
||||
|
||||
let node;
|
||||
let currentText = '';
|
||||
|
||||
|
||||
while ((node = walker.nextNode())) {
|
||||
if (node.nodeType === Node.TEXT_NODE) {
|
||||
if (node.textContent) {
|
||||
@@ -45,7 +45,7 @@ export function parseTextWithEmojis(text: string): EmojiSegment[] {
|
||||
segments.push({ type: 'text', content: currentText });
|
||||
currentText = '';
|
||||
}
|
||||
|
||||
|
||||
const img = node as HTMLImageElement;
|
||||
segments.push({
|
||||
type: 'emoji',
|
||||
@@ -75,7 +75,7 @@ export function textToTwemojiHtml(text: string, className?: string): string {
|
||||
return twemoji.parse(text, {
|
||||
className: className || 'inline-block align-middle',
|
||||
callback: (icon: string, options: any) => {
|
||||
return `https://cdn.jsdelivr.net/gh/twitter/twemoji@14.0.2/assets/72x72/${icon}.png`;
|
||||
return `https://cdn.jsdelivr.net/gh/jdecked/twemoji@latest/assets/72x72/${icon}.png`;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Before Width: | Height: | Size: 551 B |
|
Before Width: | Height: | Size: 923 B |
|
Before Width: | Height: | Size: 557 B |
|
Before Width: | Height: | Size: 458 B |
|
Before Width: | Height: | Size: 562 B |
|
Before Width: | Height: | Size: 403 B |
|
Before Width: | Height: | Size: 682 B |
|
Before Width: | Height: | Size: 561 B |
|
Before Width: | Height: | Size: 603 B |
|
Before Width: | Height: | Size: 517 B |
|
Before Width: | Height: | Size: 495 B |
|
Before Width: | Height: | Size: 668 B |
|
Before Width: | Height: | Size: 670 B |
|
Before Width: | Height: | Size: 640 B |
|
Before Width: | Height: | Size: 722 B |
|
Before Width: | Height: | Size: 553 B |
|
Before Width: | Height: | Size: 747 B |
|
Before Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 697 B |
|
Before Width: | Height: | Size: 287 B |
|
Before Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 849 B |
|
Before Width: | Height: | Size: 989 B |
|
Before Width: | Height: | Size: 662 B |
|
Before Width: | Height: | Size: 245 B |
|
Before Width: | Height: | Size: 723 B |
|
Before Width: | Height: | Size: 481 B |
|
Before Width: | Height: | Size: 453 B |
|
Before Width: | Height: | Size: 847 B |
|
Before Width: | Height: | Size: 205 B |
|
Before Width: | Height: | Size: 835 B |
|
Before Width: | Height: | Size: 387 B |
|
Before Width: | Height: | Size: 230 B |
|
Before Width: | Height: | Size: 402 B |
|
Before Width: | Height: | Size: 559 B |
|
Before Width: | Height: | Size: 652 B |
|
Before Width: | Height: | Size: 406 B |
|
Before Width: | Height: | Size: 336 B |
|
Before Width: | Height: | Size: 247 B |
|
Before Width: | Height: | Size: 390 B |
|
Before Width: | Height: | Size: 244 B |
|
Before Width: | Height: | Size: 411 B |
|
Before Width: | Height: | Size: 940 B |
|
Before Width: | Height: | Size: 279 B |
|
Before Width: | Height: | Size: 978 B |
|
Before Width: | Height: | Size: 919 B |
|
Before Width: | Height: | Size: 884 B |
|
Before Width: | Height: | Size: 666 B |
|
Before Width: | Height: | Size: 871 B |
|
Before Width: | Height: | Size: 805 B |
|
Before Width: | Height: | Size: 419 B |
|
Before Width: | Height: | Size: 1000 B |
|
Before Width: | Height: | Size: 270 B |
|
Before Width: | Height: | Size: 214 B |
|
Before Width: | Height: | Size: 669 B |
|
Before Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 459 B |
|
Before Width: | Height: | Size: 445 B |
|
Before Width: | Height: | Size: 706 B |
|
Before Width: | Height: | Size: 602 B |
|
Before Width: | Height: | Size: 389 B |
|
Before Width: | Height: | Size: 356 B |
|
Before Width: | Height: | Size: 220 B |
|
Before Width: | Height: | Size: 233 B |
|
Before Width: | Height: | Size: 961 B |
|
Before Width: | Height: | Size: 394 B |
|
Before Width: | Height: | Size: 341 B |
|
Before Width: | Height: | Size: 410 B |
|
Before Width: | Height: | Size: 245 B |
|
Before Width: | Height: | Size: 233 B |
|
Before Width: | Height: | Size: 453 B |
|
Before Width: | Height: | Size: 569 B |
|
Before Width: | Height: | Size: 574 B |
|
Before Width: | Height: | Size: 357 B |
|
Before Width: | Height: | Size: 913 B |
|
Before Width: | Height: | Size: 539 B |
|
Before Width: | Height: | Size: 549 B |
|
Before Width: | Height: | Size: 503 B |
|
Before Width: | Height: | Size: 246 B |
|
Before Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 643 B |
|
Before Width: | Height: | Size: 251 B |
|
Before Width: | Height: | Size: 696 B |
|
Before Width: | Height: | Size: 584 B |
|
Before Width: | Height: | Size: 524 B |
|
Before Width: | Height: | Size: 454 B |
|
Before Width: | Height: | Size: 362 B |
|
Before Width: | Height: | Size: 688 B |
|
Before Width: | Height: | Size: 247 B |
|
Before Width: | Height: | Size: 461 B |
|
Before Width: | Height: | Size: 586 B |
|
Before Width: | Height: | Size: 809 B |
|
Before Width: | Height: | Size: 362 B |
|
Before Width: | Height: | Size: 833 B |
|
Before Width: | Height: | Size: 560 B |
|
Before Width: | Height: | Size: 368 B |
|
Before Width: | Height: | Size: 260 B |
|
Before Width: | Height: | Size: 956 B |
|
Before Width: | Height: | Size: 977 B |