From 2df2fefdc9590a9b459afc789a1cbcf1e4cb02c1 Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Sun, 8 Jan 2023 10:39:11 +0100 Subject: [PATCH] fix(tiptap): mention transform, close #521 --- composables/content-parse.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/composables/content-parse.ts b/composables/content-parse.ts index f6e0aab7..8deaa57a 100644 --- a/composables/content-parse.ts +++ b/composables/content-parse.ts @@ -10,6 +10,7 @@ export interface ContentParseOptions { markdown?: boolean replaceUnicodeEmoji?: boolean astTransforms?: Transform[] + convertMentionLink?: boolean } const sanitizerBasicClasses = filterClasses(/^(h-\S*|p-\S*|u-\S*|dt-\S*|e-\S*|mention|hashtag|ellipsis|invisible)$/u) @@ -53,6 +54,7 @@ export function parseMastodonHTML( const { markdown = true, replaceUnicodeEmoji = true, + convertMentionLink = false, } = options if (markdown) { @@ -77,6 +79,9 @@ export function parseMastodonHTML( if (markdown) transforms.push(transformMarkdown) + if (convertMentionLink) + transforms.push(transformMentionLink) + transforms.push(replaceCustomEmoji(options.emojis || {})) transforms.push(transformParagraphs) @@ -92,6 +97,7 @@ export function convertMastodonHTML(html: string, customEmojis: Record