1
+ import * as Sentry from '@sentry/react' ;
1
2
import { Spinner } from '@wordpress/components' ;
2
3
import { createInterpolateElement } from '@wordpress/element' ;
3
4
import { __ } from '@wordpress/i18n' ;
@@ -18,6 +19,7 @@ import { AIInput } from './ai-input';
18
19
import { MessageThinking } from './assistant-thinking' ;
19
20
import Button from './button' ;
20
21
import WelcomeComponent from './welcome-message-prompt' ;
22
+
21
23
interface ContentTabAssistantProps {
22
24
selectedSite : SiteDetails ;
23
25
}
@@ -168,7 +170,7 @@ export const Message = ( { children, isUser, className }: MessageProps ) => {
168
170
>
169
171
{ typeof children === 'string' ? (
170
172
< div className = "assistant-markdown" >
171
- < Markdown components = { { code : CodeBlock } } remarkPlugins = { [ remarkGfm ] } >
173
+ < Markdown components = { { a : Anchor , code : CodeBlock } } remarkPlugins = { [ remarkGfm ] } >
172
174
{ children }
173
175
</ Markdown >
174
176
</ div >
@@ -180,6 +182,34 @@ export const Message = ( { children, isUser, className }: MessageProps ) => {
180
182
) ;
181
183
} ;
182
184
185
+ function Anchor ( props : JSX . IntrinsicElements [ 'a' ] & ExtraProps ) {
186
+ const { href } = props ;
187
+
188
+ return (
189
+ < a
190
+ { ...props }
191
+ onClick = { ( e ) => {
192
+ if ( ! href ) {
193
+ return ;
194
+ }
195
+
196
+ e . preventDefault ( ) ;
197
+ try {
198
+ getIpcApi ( ) . openURL ( href ) ;
199
+ } catch ( error ) {
200
+ getIpcApi ( ) . showMessageBox ( {
201
+ type : 'error' ,
202
+ message : __ ( 'Failed to open link' ) ,
203
+ detail : __ ( 'We were unable to open the link. Please try again.' ) ,
204
+ buttons : [ __ ( 'OK' ) ] ,
205
+ } ) ;
206
+ Sentry . captureException ( error ) ;
207
+ }
208
+ } }
209
+ />
210
+ ) ;
211
+ }
212
+
183
213
const AuthenticatedView = memo (
184
214
( {
185
215
messages,
0 commit comments