overleaf-cep/services/web/frontend/js/features/pdf-preview/components/switch-to-editor-button.tsx
Mathias Jakobsen 4ab4fbdf51 Merge pull request #26951 from overleaf/mj-layout-broken
[web] Add restoreView to LayoutContext

GitOrigin-RevId: 3a50c1e215c99236f503285fee1c924df57e07e4
2025-07-11 08:05:06 +00:00

34 lines
822 B
TypeScript

import { useTranslation } from 'react-i18next'
import MaterialIcon from '@/shared/components/material-icon'
import OLButton from '@/features/ui/components/ol/ol-button'
import { useLayoutContext } from '../../../shared/context/layout-context'
function SwitchToEditorButton() {
const { pdfLayout, restoreView, detachRole } = useLayoutContext()
const { t } = useTranslation()
if (detachRole) {
return null
}
if (pdfLayout === 'sideBySide') {
return null
}
function handleClick() {
restoreView()
window.setTimeout(() => {
window.dispatchEvent(new Event('editor:focus'))
})
}
return (
<OLButton variant="secondary" size="sm" onClick={handleClick}>
<MaterialIcon type="code" />
{t('switch_to_editor')}
</OLButton>
)
}
export default SwitchToEditorButton