mirror of
https://github.com/utopia-os/utopia-ui.git
synced 2026-02-06 09:55:47 +00:00
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:
parent
9f74815ee3
commit
317ec72c7e
@ -56,20 +56,21 @@ export const TextViewStatic = ({
|
||||
innerText = text
|
||||
}
|
||||
|
||||
// Pre-process markdown first (converts naked URLs to links, etc.)
|
||||
// Then truncate the processed markdown
|
||||
// First truncate the raw markdown (before preprocessing)
|
||||
// Then preprocess (converts naked URLs, mentions, hashtags to HTML tags)
|
||||
// Finally convert to HTML
|
||||
const html = useMemo(() => {
|
||||
if (!innerText) return ''
|
||||
|
||||
// First preprocess to normalize all URLs/mentions/hashtags
|
||||
let processed = preprocessMarkdown(innerText)
|
||||
|
||||
// Then truncate if needed (works on normalized markdown)
|
||||
// First truncate if needed (works on raw markdown syntax)
|
||||
let processed = innerText
|
||||
if (truncate) {
|
||||
processed = truncateMarkdown(processed, 100)
|
||||
}
|
||||
|
||||
// Then preprocess to normalize all URLs/mentions/hashtags to HTML tags
|
||||
processed = preprocessMarkdown(processed)
|
||||
|
||||
return simpleMarkdownToHtml(processed, tags, { items, getItemColor })
|
||||
}, [innerText, truncate, tags, items, getItemColor])
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user