mirror of
https://github.com/langgenius/dify.git
synced 2026-09-08 02:43:49 +08:00
chore: enchance notify link ui (#36155)
This commit is contained in:
parent
af4b9bfa8f
commit
8b40de3c4e
@ -185,6 +185,15 @@ describe('markdown-with-directive', () => {
|
|||||||
})
|
})
|
||||||
expect(screen.getByText('Sanitized')).toBeInTheDocument()
|
expect(screen.getByText('Sanitized')).toBeInTheDocument()
|
||||||
expectDecorativeIcon(container, 'https://example.com/safe.png')
|
expectDecorativeIcon(container, 'https://example.com/safe.png')
|
||||||
|
sanitizeSpy.mockRestore()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should render markdown links without underline', () => {
|
||||||
|
render(<MarkdownWithDirective markdown="[Langfuse](https://langfuse.com)" />)
|
||||||
|
|
||||||
|
const link = screen.getByRole('link', { name: 'Langfuse' })
|
||||||
|
expect(link).toHaveClass('text-text-accent')
|
||||||
|
expect(link).toHaveStyle({ textDecoration: 'none' })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should render empty output and skip sanitizer when markdown is empty', () => {
|
it('should render empty output and skip sanitizer when markdown is empty', () => {
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
'use client'
|
'use client'
|
||||||
import type { ReactNode } from 'react'
|
import type { AnchorHTMLAttributes, ClassAttributes, ReactNode } from 'react'
|
||||||
import type { Components, StreamdownProps } from 'streamdown'
|
import type { Components, StreamdownProps } from 'streamdown'
|
||||||
import DOMPurify from 'dompurify'
|
import DOMPurify from 'dompurify'
|
||||||
import remarkDirective from 'remark-directive'
|
import remarkDirective from 'remark-directive'
|
||||||
@ -241,10 +241,25 @@ function directivePlugin() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const directiveComponents = {
|
const directiveComponents: Components = {
|
||||||
|
a: (props) => {
|
||||||
|
const { children, href } = props as ClassAttributes<HTMLAnchorElement> & AnchorHTMLAttributes<HTMLAnchorElement>
|
||||||
|
|
||||||
|
return (
|
||||||
|
<a
|
||||||
|
href={href}
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
className="text-text-accent"
|
||||||
|
style={{ textDecoration: 'none' }}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</a>
|
||||||
|
)
|
||||||
|
},
|
||||||
withiconcardlist: WithIconCardListAdapter,
|
withiconcardlist: WithIconCardListAdapter,
|
||||||
withiconcarditem: WithIconCardItemAdapter,
|
withiconcarditem: WithIconCardItemAdapter,
|
||||||
} satisfies Components
|
}
|
||||||
|
|
||||||
type MarkdownWithDirectiveProps = {
|
type MarkdownWithDirectiveProps = {
|
||||||
markdown: string
|
markdown: string
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user