File tree Expand file tree Collapse file tree
zendesk_app/src/app/components/AutosendModal Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -56,19 +56,28 @@ export const AutosendModal = ({
5656 }
5757
5858 const getEndUserContentHtml = ( conversationEntry : ZendeskConversationEntry ) => {
59- return `${ conversationEntry . message . content || '' }
60- ${ conversationEntry . attachments
59+ const messageContent = ( conversationEntry . message . content || '' ) . replace (
60+ / < a \b (? ! [ ^ > ] * \b t a r g e t = ) [ ^ > ] * > / gi,
61+ ( match : string ) => {
62+ // Add target and rel attributes to open links in a new tab
63+ return match . replace ( / < a / , '<a target="_blank" rel="noopener noreferrer"' ) ;
64+ }
65+ ) ;
66+
67+ const attachmentLinks = conversationEntry . attachments
6168 ?. map (
6269 ( att : any ) => `
63- <div style="margin-top: 1em;">
64- <a href="${ att . contentUrl } " target="_blank" rel="noopener noreferrer">
65- 📎 ${ att . filename }
66- </a>
67- </div>
68- `
70+ <div style="margin-top: 1em;">
71+ <a href="${ att . contentUrl } " target="_blank" rel="noopener noreferrer">
72+ 📎 ${ att . filename }
73+ </a>
74+ </div>
75+ `
6976 )
70- . join ( '' ) } `
71- }
77+ . join ( '' ) || '' ;
78+
79+ return `${ messageContent } ${ attachmentLinks } ` ;
80+ } ;
7281
7382 return (
7483 < div className = { styles . main_container } >
You can’t perform that action at this time.
0 commit comments