Skip to content

Commit

Permalink
open new window when click external link
Browse files Browse the repository at this point in the history
  • Loading branch information
an-lee committed Mar 5, 2024
1 parent cf1cd52 commit 4c8ba67
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion enjoy/src/renderer/components/messages/user-message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,22 @@ export const UserMessageComponent = (props: {
className="flex items-end justify-end space-x-2 pl-10"
>
<div className="flex flex-col gap-2 px-4 py-2 bg-sky-500/30 border-sky-500 rounded-lg shadow-sm w-full">
<Markdown className="select-text prose">{message.content}</Markdown>
<Markdown
className="select-text prose"
components={{
a({ node, children, ...props }) {
try {
new URL(props.href ?? "");
props.target = "_blank";
props.rel = "noopener noreferrer";
} catch (e) {}

return <a {...props}>{children}</a>;
},
}}
>
{message.content}
</Markdown>

{Boolean(speech) && <SpeechPlayer speech={speech} />}

Expand Down

0 comments on commit 4c8ba67

Please sign in to comment.