feat: custom emoji
This commit is contained in:
parent
481d6a1447
commit
71d4420604
46 changed files with 885 additions and 176 deletions
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue