mirror of
https://github.com/aljazceru/rabbit.git
synced 2025-12-17 14:04:21 +01:00
35 lines
1.2 KiB
TypeScript
35 lines
1.2 KiB
TypeScript
import { For } from 'solid-js';
|
|
import parseTextNote, { type ParsedTextNoteNode } from '@/core/parseTextNote';
|
|
import type { Event as NostrEvent } from 'nostr-tools/event';
|
|
import PlainTextDisplay from '@/components/textNote/PlainTextDisplay';
|
|
import MentionedUserDisplay from '@/components/textNote/MentionedUserDisplay';
|
|
import MentionedEventDisplay from '@/components/textNote/MentionedEventDisplay';
|
|
|
|
export type TextNoteContentDisplayProps = {
|
|
event: NostrEvent;
|
|
};
|
|
|
|
const TextNoteContentDisplay = (props: TextNoteContentDisplayProps) => {
|
|
return (
|
|
<For each={parseTextNote(props.event)}>
|
|
{(item: ParsedTextNoteNode) => {
|
|
if (item.type === 'PlainText') {
|
|
return <PlainTextDisplay plainText={item} />;
|
|
}
|
|
if (item.type === 'MentionedUser') {
|
|
return <MentionedUserDisplay mentionedUser={item} />;
|
|
}
|
|
if (item.type === 'MentionedEvent') {
|
|
return <MentionedEventDisplay mentionedEvent={item} />;
|
|
}
|
|
if (item.type === 'HashTag') {
|
|
return <span class="text-blue-500 underline ">{item.content}</span>;
|
|
}
|
|
return null;
|
|
}}
|
|
</For>
|
|
);
|
|
};
|
|
|
|
export default TextNoteContentDisplay;
|