pdf-log-entry-content.tsx 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. alwaysExpandRawContent = false,
  19. }: {
  20. rawContent?: string
  21. formattedContent?: React.ReactNode
  22. extraInfoURL?: string | null
  23. index?: number
  24. logEntry?: LogEntry
  25. alwaysExpandRawContent?: boolean
  26. }) {
  27. const { t } = useTranslation()
  28. return (
  29. <div className="log-entry-content">
  30. {formattedContent && (
  31. <div className="log-entry-formatted-content">{formattedContent}</div>
  32. )}
  33. {extraInfoURL && (
  34. <div className="log-entry-content-link">
  35. <a href={extraInfoURL} target="_blank" rel="noopener">
  36. {t('log_hint_extra_info')}
  37. </a>
  38. </div>
  39. )}
  40. {logEntry &&
  41. pdfLogEntryComponents.map(
  42. ({ import: { default: Component }, path }) => (
  43. <Component key={path} index={index} logEntry={logEntry} />
  44. )
  45. )}
  46. {rawContent && (
  47. <PdfLogEntryRawContent
  48. rawContent={rawContent}
  49. collapsedSize={150}
  50. alwaysExpanded={alwaysExpandRawContent}
  51. />
  52. )}
  53. </div>
  54. )
  55. }