/** * WordPress dependencies */ // eslint-disable-next-line import/named import { BlockInstance, parse } from '@wordpress/blocks'; import { Button, __experimentalDivider as Divider, KeyboardShortcuts, Tooltip } from '@wordpress/components'; import { useEffect, useState } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; import { arrowLeft, arrowRight, Icon, page } from '@wordpress/icons'; import { Telemetry } from '../../../../js/telemetry/telemetry'; /** * Internal dependencies */ import { InboundSmartLink } from '../provider'; import { BlockPreview } from './component-block-preview'; /** * The props for the ThreeDots component. * * @since 3.16.0 */ type ThreeDotsProps = { topOrBottom: 'top' | 'bottom'; }; /** * Displays three dots. * * @since 3.16.0 * * @param {ThreeDotsProps} props The component's props. */ const ThreeDots: React.FC = ( { topOrBottom, }: ThreeDotsProps ): React.JSX.Element => { return (
( … )
); }; /** * The props for the LinkingPostDetails component. * * @since 3.16.0 */ type LinkingPostDetailsProps = { link: InboundSmartLink; }; /** * Displays the linking post details. * * @since 3.16.0 * * @param {LinkingPostDetailsProps} props The component's props. */ const LinkingPostDetails = ( { link }: LinkingPostDetailsProps ): React.JSX.Element => { return (
{ link.post_data?.image ? ( { ) : (
) }
{ link.post_data?.title }
{ link.post_data?.date } by { link.post_data?.author }
{ link.post_data?.type.label }
); }; /** * The props for the InboundLinkDetails component. * * @since 3.16.0 */ type InboundLinkDetailsProps = { link: InboundSmartLink; onPrevious: () => void; onNext: () => void; hasPrevious: boolean; hasNext: boolean; }; /** * Displays the inbound smart link details. * * @since 3.16.0 * * @param {InboundLinkDetailsProps} props The component's props. */ export const InboundLinkDetails = ( { link, onPrevious, onNext, hasPrevious, hasNext, }: InboundLinkDetailsProps ): React.JSX.Element => { const [ blocks, setBlocks ] = useState( [] ); useEffect( () => { const paragraph = link.post_data?.paragraph; const gutenbergParagraph = ` ${ paragraph ?? '

' } `; if ( ! paragraph ) { return; } setBlocks( parse( gutenbergParagraph ) ); }, [ link ] ); return (
{ link.post_data?.title }
{ ! link.post_data?.is_first_paragraph && } { ! link.post_data?.is_last_paragraph && }
); };