fix(tiptap): fix truncation breaking mentions and hashtags in TextViewStatic

Reorder processing steps: truncate raw markdown first, then preprocess.
Previously, preprocessMarkdown converted mentions/hashtags to HTML tags
before truncation, but truncateMarkdown only recognizes markdown syntax
([@Label](/item/id)), not HTML tags (<span data-item-mention...>),
causing tags to be cut in half.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Anton Tranelis 2026-01-16 09:33:25 +01:00
parent 9f74815ee3
commit 317ec72c7e

View File

@ -56,20 +56,21 @@ export const TextViewStatic = ({
innerText = text innerText = text
} }
// Pre-process markdown first (converts naked URLs to links, etc.) // First truncate the raw markdown (before preprocessing)
// Then truncate the processed markdown // Then preprocess (converts naked URLs, mentions, hashtags to HTML tags)
// Finally convert to HTML // Finally convert to HTML
const html = useMemo(() => { const html = useMemo(() => {
if (!innerText) return '' if (!innerText) return ''
// First preprocess to normalize all URLs/mentions/hashtags // First truncate if needed (works on raw markdown syntax)
let processed = preprocessMarkdown(innerText) let processed = innerText
// Then truncate if needed (works on normalized markdown)
if (truncate) { if (truncate) {
processed = truncateMarkdown(processed, 100) processed = truncateMarkdown(processed, 100)
} }
// Then preprocess to normalize all URLs/mentions/hashtags to HTML tags
processed = preprocessMarkdown(processed)
return simpleMarkdownToHtml(processed, tags, { items, getItemColor }) return simpleMarkdownToHtml(processed, tags, { items, getItemColor })
}, [innerText, truncate, tags, items, getItemColor]) }, [innerText, truncate, tags, items, getItemColor])