You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021
  1. /**
  2. * @fileoverview Link component for rendering <a> tags in Markdown.
  3. * Extracted from the main markdown renderer for modularity.
  4. * Handles special rendering for "abbr:" type links for interactive chat actions.
  5. */
  6. import React from 'react'
  7. import { useChatContext } from '@/app/components/base/chat/chat/context'
  8. const Link = ({ node, children, ...props }: any) => {
  9. const { onSend } = useChatContext()
  10. if (node.properties?.href && node.properties.href?.toString().startsWith('abbr')) {
  11. const hidden_text = decodeURIComponent(node.properties.href.toString().split('abbr:')[1])
  12. return <abbr className="cursor-pointer underline !decoration-primary-700 decoration-dashed" onClick={() => onSend?.(hidden_text)} title={node.children[0]?.value || ''}>{node.children[0]?.value || ''}</abbr>
  13. }
  14. else {
  15. return <a {...props} target="_blank" className="cursor-pointer underline !decoration-primary-700 decoration-dashed">{children || 'Download'}</a>
  16. }
  17. }
  18. export default Link