mirror of
https://github.com/langgenius/dify.git
synced 2026-06-26 14:51:13 +08:00
fix(markdown): handle mailto: links without target="_blank" to allow email client to open
## Summary When mailto: links are rendered in chat responses, clicking them does not open the email client because the Link component adds target="_blank" to all valid URLs including mailto: links. With target="_blank", browsers attempt to open a new tab for mailto: links, which results in a blank tab or nothing happening instead of launching the default email client. ## Changes Added a check for mailto: links before the default target="_blank" rendering. mailto: links are now rendered as plain <a> tags without target="_blank", allowing the browser to properly handle the mailto: protocol and open the user's default email client. Related: #12954 #16243
This commit is contained in:
parent
d0bb642fc5
commit
de866d617b
@ -36,6 +36,10 @@ const Link = ({ node, children, ...props }: any) => {
|
||||
if (!href || !isValidUrl(href))
|
||||
return <span>{children}</span>
|
||||
|
||||
// Handle mailto: links without target="_blank" to allow email client to open directly
|
||||
if (href.toString().startsWith('mailto:'))
|
||||
return <a href={href} className={commonClassName}>{children}</a>
|
||||
|
||||
return <a href={href} target="_blank" rel="noopener noreferrer" className={commonClassName}>{children || 'Download'}</a>
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user