From 09403a07229eb0425403466358dd06479432e352 Mon Sep 17 00:00:00 2001 From: patak Date: Wed, 8 Mar 2023 21:42:01 +0100 Subject: [PATCH 1/2] fix: copy and paste custom-emoji --- composables/content-parse.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composables/content-parse.ts b/composables/content-parse.ts index 6e2d338316..923e4bcd23 100644 --- a/composables/content-parse.ts +++ b/composables/content-parse.ts @@ -219,7 +219,7 @@ export function treeToText(input: Node): string { if (input.name === 'img' || input.name === 'picture') { if (input.attributes.class?.includes('custom-emoji')) - return `:${input.attributes['data-emoji-id'] || input.attributes.title}:` + return `:${input.attributes['data-emoji-id'] ?? input.attributes.title ?? input.attributes.alt?.slice(1, -1)}:` if (input.attributes.class?.includes('iconify-emoji')) return input.attributes.alt } From fa123d4c02e01409d63b5af7c29aea2d4a72a74c Mon Sep 17 00:00:00 2001 From: patak Date: Thu, 9 Mar 2023 12:15:35 +0100 Subject: [PATCH 2/2] chore: more robust emoji id logic --- 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 923e4bcd23..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 ?? input.attributes.alt?.slice(1, -1)}:` + 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 }