import { PostRichText } from "$/components/shared/PostRichText"; import { getDisplayName } from "$/lib/feeds"; import type { ProfileViewBasic, RichTextFacet } from "$/lib/types"; import { formatHandle } from "$/lib/utils/text"; import { createMemo, type ParentProps, Show } from "solid-js"; function QuotedText(props: { facets?: RichTextFacet[] | null; text: string; truncated: boolean }) { return ( {props.text}

}>

{props.text}

}> {facets => (
)} ); } type QuotedPreviewContentProps = { author: ProfileViewBasic | null; emptyText?: string; facets?: RichTextFacet[] | null; preview: string; truncated: boolean; }; function QuotedPreviewContent(props: QuotedPreviewContentProps) { return ( <> {(value) => { const author = value(); return (

{getDisplayName(author)} {formatHandle(author.handle, author.did)}

); }}
{props.emptyText ?? "Quoted post"}

}> {(text) => }
); } type QuotedPostPreviewProps = ParentProps< { author: ProfileViewBasic | null; class?: string; emptyText?: string; facets?: RichTextFacet[] | null; href?: string | null; onOpenPost?: () => void; text?: unknown; title: string; truncate?: boolean; } >; function shouldHandleWithCallback(event: MouseEvent) { return event.button === 0 && !event.altKey && !event.ctrlKey && !event.metaKey && !event.shiftKey; } export function QuotedPostPreview(props: QuotedPostPreviewProps) { const preview = createMemo(() => (typeof props.text === "string" ? props.text : "")); const href = createMemo(() => (typeof props.href === "string" && props.href.trim().length > 0 ? props.href : null)); const openInNewTab = createMemo(() => !!props.href && /^https?:\/\//i.test(props.href)); const truncated = createMemo(() => props.truncate ?? false); return (

{props.title}

}> }> {(quotedHref) => ( { event.stopPropagation(); if (!props.onOpenPost || !shouldHandleWithCallback(event)) { return; } event.preventDefault(); props.onOpenPost(); }}> )} {(children) =>
{children()}
}
); }