Skip to content

Commit

Permalink
fix(Message): open link with external browser (janhq#1339)
Browse files Browse the repository at this point in the history
* fix(Message): janhq#1321 open link with external browser

Signed-off-by: James <[email protected]>

---------

Signed-off-by: James <[email protected]>
Co-authored-by: James <[email protected]>
  • Loading branch information
namchuai and James authored Jan 4, 2024
1 parent 26eb1d9 commit 97c0fee
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions web/screens/Chat/SimpleTextMessage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ChatCompletionRole, MessageStatus, ThreadMessage } from '@janhq/core'
import hljs from 'highlight.js'

import { useAtomValue } from 'jotai'
import { Marked } from 'marked'
import { Marked, Renderer } from 'marked'

import { markedHighlight } from 'marked-highlight'

Expand All @@ -30,7 +30,7 @@ const SimpleTextMessage: React.FC<ThreadMessage> = (props) => {
}
const clipboard = useClipboard({ timeout: 1000 })

const marked = new Marked(
const marked: Marked = new Marked(
markedHighlight({
langPrefix: 'hljs',
highlight(code, lang) {
Expand All @@ -46,6 +46,11 @@ const SimpleTextMessage: React.FC<ThreadMessage> = (props) => {
}),
{
renderer: {
link: (href, title, text) => {
return Renderer.prototype.link
?.apply(this, [href, title, text])
.replace('<a', "<a target='_blank'")
},
code(code, lang, escaped) {
return `
<div class="relative code-block group/item">
Expand Down

0 comments on commit 97c0fee

Please sign in to comment.