Files
Verso/services/web/frontend/js/features/pdf-preview/components/pdf-preview-detached-root.tsx
T
DavidandCopybot cd335419ff Merge pull request #29603 from overleaf/dp-detached-pdf-light
Fix missing light theme for detached pdf

GitOrigin-RevId: 61af7e34c44f6d2842ca9d5c1b5d7458a2a1a6c8
2025-11-11 09:05:34 +00:00

48 lines
1.3 KiB
TypeScript

import { createRoot } from 'react-dom/client'
import PdfPreview from './pdf-preview'
import useWaitForI18n from '../../../shared/hooks/use-wait-for-i18n'
import { ReactContextRoot } from '@/features/ide-react/context/react-context-root'
import { useIsNewEditorEnabled } from '@/features/ide-redesign/utils/new-editor-utils'
import useThemedPage from '@/shared/hooks/use-themed-page'
function PdfPreviewDetachedRoot() {
const { isReady } = useWaitForI18n()
if (!isReady) {
return null
}
return (
<ReactContextRoot>
<PdfPreviewDetachedRootContent />
</ReactContextRoot>
)
}
function PdfPreviewDetachedRootContent() {
useThemedPage() // set the page theme based on user settings
return (
<EditorRedesignWrapper>
<PdfPreview />
</EditorRedesignWrapper>
)
}
function EditorRedesignWrapper({ children }: { children: React.ReactNode }) {
const newEditorEnabled = useIsNewEditorEnabled()
if (!newEditorEnabled) {
return <>{children}</>
}
// TODO ide-redesign-cleanup: this wrapper should not be required
return <div className="ide-redesign-main">{children}</div>
}
export default PdfPreviewDetachedRoot // for testing
const element = document.getElementById('pdf-preview-detached-root')
if (element) {
const root = createRoot(element)
root.render(<PdfPreviewDetachedRoot />)
}