feat: custom emoji

This commit is contained in:
codytseng 2025-08-22 21:05:44 +08:00
parent 481d6a1447
commit 71d4420604
46 changed files with 885 additions and 176 deletions

View file

@ -7,7 +7,9 @@ import {
URL_REGEX,
WS_URL_REGEX
} from '@/constants'
import { TEmoji } from '@/types'
import { clsx, type ClassValue } from 'clsx'
import { parseNativeEmoji } from 'emoji-picker-react/src/dataUtils/parseNativeEmoji'
import { franc } from 'franc-min'
import { twMerge } from 'tailwind-merge'
@ -133,3 +135,16 @@ export function detectLanguage(text?: string): string | null {
return 'und'
}
}
export function parseEmojiPickerUnified(unified: string): string | TEmoji | undefined {
if (unified.startsWith(':')) {
const secondColonIndex = unified.indexOf(':', 1)
if (secondColonIndex < 0) return undefined
const shortcode = unified.slice(1, secondColonIndex)
const url = unified.slice(secondColonIndex + 1)
return { shortcode, url }
} else {
return parseNativeEmoji(unified)
}
}