fix: copy and paste custom-emoji (#1873)

This commit is contained in:
patak 2023-03-09 12:18:03 +01:00 committed by GitHub
parent fa3cfd6059
commit 3732a2cc16
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -218,8 +218,10 @@ export function treeToText(input: Node): string {
body = (input.children as Node[]).map(n => treeToText(n)).join('') body = (input.children as Node[]).map(n => treeToText(n)).join('')
if (input.name === 'img' || input.name === 'picture') { if (input.name === 'img' || input.name === 'picture') {
if (input.attributes.class?.includes('custom-emoji')) if (input.attributes.class?.includes('custom-emoji')) {
return `:${input.attributes['data-emoji-id'] || input.attributes.title}:` const id = input.attributes['data-emoji-id'] ?? input.attributes.title ?? input.attributes.alt ?? 'unknown'
return id[0] !== ':' ? `:${id}:` : id
}
if (input.attributes.class?.includes('iconify-emoji')) if (input.attributes.class?.includes('iconify-emoji'))
return input.attributes.alt return input.attributes.alt
} }