Fix RichText prop in Kind9802Renderer to pass event object (#213)

* fix: pass source event to RichText in highlight feed preview

The source event preview in HighlightRenderer was only passing the
content string to RichText, which meant custom emoji tags from the
source event weren't processed. Now passes the source event with
the preview content to enable proper emoji and tag-based rendering.

* refactor: use CSS truncation for highlight source preview

- Pass sourceEvent directly for notes instead of extracting content
- Only create synthetic event with title for articles
- CSS line-clamp-1 and overflow-hidden handle truncation
- Media and event embeds remain disabled

---------

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Alejandro
2026-01-24 10:17:46 +01:00
committed by GitHub
parent e008d76021
commit d1ccd930ff

View File

@@ -32,13 +32,8 @@ export function Kind9802Renderer({ event }: BaseEventProps) {
// Load the source event for preview // Load the source event for preview
const sourceEvent = useNostrEvent(eventPointer || addressPointer); const sourceEvent = useNostrEvent(eventPointer || addressPointer);
// Extract title or content preview from source event (getArticleTitle caches internally) // Get article title if this is an article (caches internally)
const sourcePreview = (() => { const sourceTitle = sourceEvent ? getArticleTitle(sourceEvent) : null;
if (!sourceEvent) return null;
const title = getArticleTitle(sourceEvent);
if (title) return title;
return sourceEvent.content || null;
})();
// Handle click to open source event // Handle click to open source event
const handleOpenEvent = () => { const handleOpenEvent = () => {
@@ -93,18 +88,20 @@ export function Kind9802Renderer({ event }: BaseEventProps) {
className="text-xs flex-shrink-0 line-clamp-1" className="text-xs flex-shrink-0 line-clamp-1"
/> />
{/* Title or Content Preview */} {/* Title or Content Preview - CSS handles truncation */}
{sourcePreview && ( <div
<div className="hover:underline hover:decoration-dotted cursor-crosshair text-xs line-clamp-1 overflow-hidden min-w-0"
className="hover:underline hover:decoration-dotted cursor-crosshair text-xs line-clamp-1 break-words" onClick={handleOpenEvent}
onClick={handleOpenEvent} >
> <RichText
<RichText event={
content={sourcePreview} sourceTitle
options={{ showMedia: false, showEventEmbeds: false }} ? { ...sourceEvent, content: sourceTitle }
/> : sourceEvent
</div> }
)} options={{ showMedia: false, showEventEmbeds: false }}
/>
</div>
</div> </div>
)} )}