From 70b3902e7a13f94e5616afab6ea2ebaafaacddb3 Mon Sep 17 00:00:00 2001 From: patak Date: Thu, 9 Mar 2023 12:18:03 +0100 Subject: [PATCH] fix: copy and paste custom-emoji (#1873) --- composables/content-parse.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/composables/content-parse.ts b/composables/content-parse.ts index 6e2d338316..15e7a20567 100644 --- a/composables/content-parse.ts +++ b/composables/content-parse.ts @@ -218,8 +218,10 @@ export function treeToText(input: Node): string { body = (input.children as Node[]).map(n => treeToText(n)).join('') if (input.name === 'img' || input.name === 'picture') { - if (input.attributes.class?.includes('custom-emoji')) - return `:${input.attributes['data-emoji-id'] || input.attributes.title}:` + if (input.attributes.class?.includes('custom-emoji')) { + 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')) return input.attributes.alt }