overleaf/services/web/frontend/js/features/pdf-preview/components/pdf-logs-entries.js
Alf Eaton 73bc3418a2 Add React version of the PDF preview pane (#5135)
GitOrigin-RevId: fcc88a362c3e97c9fddf85d47c3a83a0a0b89432
2021-10-01 08:03:12 +00:00

46 lines
1.2 KiB
JavaScript

import { memo, useCallback } from 'react'
import PropTypes from 'prop-types'
import { useTranslation } from 'react-i18next'
import PreviewLogsPaneEntry from '../../preview/components/preview-logs-pane-entry'
function PdfLogsEntries({ entries }) {
const { t } = useTranslation()
const syncToEntry = useCallback(entry => {
window.dispatchEvent(
new CustomEvent('synctex:sync-to-entry', {
detail: entry,
})
)
}, [])
return (
<>
{entries.map(logEntry => (
<PreviewLogsPaneEntry
key={logEntry.key}
headerTitle={logEntry.message}
rawContent={logEntry.content}
logType={logEntry.type}
formattedContent={logEntry.humanReadableHintComponent}
extraInfoURL={logEntry.extraInfoURL}
level={logEntry.level}
entryAriaLabel={t('log_entry_description', {
level: logEntry.level,
})}
sourceLocation={{
file: logEntry.file,
line: logEntry.line,
column: logEntry.column,
}}
onSourceLocationClick={syncToEntry}
/>
))}
</>
)
}
PdfLogsEntries.propTypes = {
entries: PropTypes.arrayOf(PropTypes.object),
}
export default memo(PdfLogsEntries)