File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed
src/features/ui/chat/chat-message-area Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change 1- import React , { ForwardRefRenderFunction } from "react" ;
1+ import React , { ForwardRefRenderFunction , useEffect } from "react" ;
22
33interface ChatMessageContentAreaProps {
44 children ?: React . ReactNode ;
@@ -8,10 +8,20 @@ const ChatMessageContentArea: ForwardRefRenderFunction<
88 HTMLDivElement ,
99 ChatMessageContentAreaProps
1010> = ( props , ref ) => {
11+ useEffect ( ( ) => {
12+ const links = ref . current ?. querySelectorAll ( 'a' ) ; // Select all anchor tags in the current ref
13+ if ( links ) {
14+ links . forEach ( link => {
15+ link . setAttribute ( 'target' , '_blank' ) ; // Open in new tab
16+ link . setAttribute ( 'rel' , 'noopener noreferrer' ) ; // Security measure
17+ } ) ;
18+ }
19+ } , [ props . children ] ) ; // Run effect when children change
20+
1121 return (
1222 < div
1323 ref = { ref }
14- className = "container max-w-3xl relative min-h-screen pb-[240px] pt-16 flex flex-col gap-16"
24+ className = "container max-w-3xl relative min-h-screen pb-[240px] pt-16 flex flex-col gap-16"
1525 >
1626 { props . children }
1727 </ div >
You can’t perform that action at this time.
0 commit comments