From 3732a2cc16b4de6cd60f4836151d4a3292c627fa 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 6e2d3383..15e7a205 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 }