pdf-preview-detached-root.js 815 B

123456789101112131415161718192021222324252627282930
  1. import ReactDOM from 'react-dom'
  2. import PdfPreview from './pdf-preview'
  3. import { ContextRoot } from '../../../shared/context/root-context'
  4. import useWaitForI18n from '../../../shared/hooks/use-wait-for-i18n'
  5. import { Shortcuts } from './shortcuts'
  6. import PdfPreviewDetachedRootSafariWarning from './pdf-preview-detached-root-safari-warning'
  7. function PdfPreviewDetachedRoot() {
  8. const { isReady } = useWaitForI18n()
  9. if (!isReady) {
  10. return null
  11. }
  12. return (
  13. <ContextRoot>
  14. <Shortcuts>
  15. <PdfPreviewDetachedRootSafariWarning />
  16. <PdfPreview />
  17. </Shortcuts>
  18. </ContextRoot>
  19. )
  20. }
  21. export default PdfPreviewDetachedRoot // for testing
  22. const element = document.getElementById('pdf-preview-detached-root')
  23. if (element) {
  24. ReactDOM.render(<PdfPreviewDetachedRoot />, element)
  25. }