2022-07-20 10:01:48 -04:00
|
|
|
import { useTranslation } from 'react-i18next'
|
|
|
|
import Icon from '../../../shared/components/icon'
|
2024-09-30 04:11:26 -04:00
|
|
|
import MaterialIcon from '@/shared/components/material-icon'
|
|
|
|
import OLButton from '@/features/ui/components/ol/ol-button'
|
|
|
|
import BootstrapVersionSwitcher from '@/features/ui/components/bootstrap-5/bootstrap-version-switcher'
|
2022-07-20 10:01:48 -04:00
|
|
|
import { useLayoutContext } from '../../../shared/context/layout-context'
|
|
|
|
|
|
|
|
function SwitchToEditorButton() {
|
|
|
|
const { pdfLayout, setView, detachRole } = useLayoutContext()
|
|
|
|
|
|
|
|
const { t } = useTranslation()
|
|
|
|
|
|
|
|
if (detachRole) {
|
|
|
|
return null
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pdfLayout === 'sideBySide') {
|
|
|
|
return null
|
|
|
|
}
|
|
|
|
|
|
|
|
function handleClick() {
|
|
|
|
setView('editor')
|
2024-11-05 06:59:07 -05:00
|
|
|
window.setTimeout(() => {
|
|
|
|
window.dispatchEvent(new Event('editor:focus'))
|
|
|
|
})
|
2022-07-20 10:01:48 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
2024-09-30 04:11:26 -04:00
|
|
|
<OLButton
|
|
|
|
variant="secondary"
|
2024-10-08 10:22:13 -04:00
|
|
|
size="sm"
|
2022-07-20 10:01:48 -04:00
|
|
|
onClick={handleClick}
|
2024-09-30 04:11:26 -04:00
|
|
|
bs3Props={{
|
|
|
|
bsSize: 'xsmall',
|
|
|
|
className: 'switch-to-editor-btn toolbar-btn-secondary',
|
|
|
|
}}
|
2022-07-20 10:01:48 -04:00
|
|
|
>
|
2024-09-30 04:11:26 -04:00
|
|
|
<BootstrapVersionSwitcher
|
|
|
|
bs3={<Icon type="code" className="toolbar-btn-secondary-icon" />}
|
|
|
|
bs5={<MaterialIcon type="code" />}
|
|
|
|
/>
|
|
|
|
{t('switch_to_editor')}
|
|
|
|
</OLButton>
|
2022-07-20 10:01:48 -04:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default SwitchToEditorButton
|