diff --git a/src/components/content-tab-assistant.tsx b/src/components/content-tab-assistant.tsx index 19461bef7..9b6642464 100644 --- a/src/components/content-tab-assistant.tsx +++ b/src/components/content-tab-assistant.tsx @@ -1,3 +1,4 @@ +import * as Sentry from '@sentry/react'; import { Spinner } from '@wordpress/components'; import { createInterpolateElement } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; @@ -18,6 +19,7 @@ import { AIInput } from './ai-input'; import { MessageThinking } from './assistant-thinking'; import Button from './button'; import WelcomeComponent from './welcome-message-prompt'; + interface ContentTabAssistantProps { selectedSite: SiteDetails; } @@ -168,7 +170,7 @@ export const Message = ( { children, isUser, className }: MessageProps ) => { > { typeof children === 'string' ? (
- + { children }
@@ -180,6 +182,34 @@ export const Message = ( { children, isUser, className }: MessageProps ) => { ); }; +function Anchor( props: JSX.IntrinsicElements[ 'a' ] & ExtraProps ) { + const { href } = props; + + return ( + { + if ( ! href ) { + return; + } + + e.preventDefault(); + try { + getIpcApi().openURL( href ); + } catch ( error ) { + getIpcApi().showMessageBox( { + type: 'error', + message: __( 'Failed to open link' ), + detail: __( 'We were unable to open the link. Please try again.' ), + buttons: [ __( 'OK' ) ], + } ); + Sentry.captureException( error ); + } + } } + /> + ); +} + const AuthenticatedView = memo( ( { messages,