feat: custom emoji font in editor
This commit is contained in:
parent
e97068f000
commit
8f68fa12e4
7 changed files with 153 additions and 86 deletions
|
@ -1,8 +1,9 @@
|
|||
// @unimport-disable
|
||||
import type { Emoji } from 'masto'
|
||||
import type { Node } from 'ultrahtml'
|
||||
import { TEXT_NODE, parse, render, walkSync } from 'ultrahtml'
|
||||
|
||||
const EMOJI_REGEX = /(\p{Emoji_Presentation})/ug
|
||||
export const EMOJI_REGEX = /(\p{Emoji_Presentation})/ug
|
||||
|
||||
const decoder = process.client ? document.createElement('textarea') : null as any as HTMLTextAreaElement
|
||||
export function decodeHtml(text: string) {
|
||||
|
@ -118,7 +119,10 @@ export function treeToText(input: Node): string {
|
|||
|
||||
// add spaces around emoji to prevent parsing errors: 2 or more consecutive emojis will not be parsed
|
||||
if (input.name === 'img' && input.attributes.class?.includes('custom-emoji'))
|
||||
return ` :${input.attributes['data-emoji-id']}: `
|
||||
return `:${input.attributes['data-emoji-id']}:`
|
||||
|
||||
if (input.name === 'em-emoji')
|
||||
return `${input.attributes.native}`
|
||||
|
||||
return pre + body + post
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue