pdf-log-entry-content.tsx 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import { useTranslation } from 'react-i18next'
  2. import PdfLogEntryRawContent from './pdf-log-entry-raw-content'
  3. import importOverleafModules from '../../../../macros/import-overleaf-module.macro'
  4. import { LogEntry } from '../util/types'
  5. import { ElementType } from 'react'
  6. const pdfLogEntryComponents = importOverleafModules(
  7. 'pdfLogEntryComponents'
  8. ) as {
  9. import: { default: ElementType }
  10. path: string
  11. }[]
  12. export default function PdfLogEntryContent({
  13. rawContent,
  14. formattedContent,
  15. extraInfoURL,
  16. index,
  17. logEntry,
  18. }: {
  19. rawContent?: string
  20. formattedContent?: React.ReactNode
  21. extraInfoURL?: string | null
  22. index?: number
  23. logEntry?: LogEntry
  24. }) {
  25. const { t } = useTranslation()
  26. return (
  27. <div className="log-entry-content">
  28. {formattedContent && (
  29. <div className="log-entry-formatted-content">{formattedContent}</div>
  30. )}
  31. {extraInfoURL && (
  32. <div className="log-entry-content-link">
  33. <a href={extraInfoURL} target="_blank" rel="noopener">
  34. {t('log_hint_extra_info')}
  35. </a>
  36. </div>
  37. )}
  38. {logEntry &&
  39. pdfLogEntryComponents.map(
  40. ({ import: { default: Component }, path }) => (
  41. <Component key={path} index={index} logEntry={logEntry} />
  42. )
  43. )}
  44. {rawContent && (
  45. <PdfLogEntryRawContent rawContent={rawContent} collapsedSize={150} />
  46. )}
  47. </div>
  48. )
  49. }