feat: custom emoji
This commit is contained in:
parent
481d6a1447
commit
71d4420604
46 changed files with 885 additions and 176 deletions
|
|
@ -1,3 +1,5 @@
|
|||
import customEmojiService from '@/services/custom-emoji.service'
|
||||
import { emojis, shortcodeToEmoji } from '@tiptap/extension-emoji'
|
||||
import { JSONContent } from '@tiptap/react'
|
||||
import { nip19 } from 'nostr-tools'
|
||||
|
||||
|
|
@ -38,7 +40,18 @@ function _parseEditorJsonToText(node?: JSONContent): string {
|
|||
return '\n'
|
||||
case 'mention':
|
||||
return node.attrs ? `nostr:${node.attrs.id}` : ''
|
||||
case 'emoji':
|
||||
return parseEmojiNodeName(node.attrs?.name)
|
||||
default:
|
||||
return ''
|
||||
}
|
||||
}
|
||||
|
||||
function parseEmojiNodeName(name?: string): string {
|
||||
if (!name) return ''
|
||||
if (customEmojiService.isCustomEmojiId(name)) {
|
||||
return `:${name}:`
|
||||
}
|
||||
const emoji = shortcodeToEmoji(name, emojis)
|
||||
return emoji ? (emoji.emoji ?? '') : ''
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue