overleaf-cep/services/web/frontend/js/features/pdf-preview/components/synctex-toasts.tsx
Alf Eaton c732a02b38 Use toast notifications for SyncTeX errors and handle missing file errors (#24579)
GitOrigin-RevId: 88c6658ff0d11fdb43cef19c48b542a3b2206666
2025-04-28 08:05:42 +00:00

47 lines
1 KiB
TypeScript

import { GlobalToastGeneratorEntry } from '@/features/ide-react/components/global-toasts'
import { useTranslation } from 'react-i18next'
import OLButton from '@/features/ui/components/ol/ol-button'
export const SynctexFileErrorToast = () => {
const { t } = useTranslation()
return (
<div className="synctex-error-toast-content">
<span>{t('synctex_failed')}</span>
<OLButton
href="/learn/how-to/SyncTeX_Errors"
target="_blank"
variant="secondary"
size="sm"
>
{t('more_info')}
</OLButton>
</div>
)
}
const generators: GlobalToastGeneratorEntry[] = [
{
key: 'synctex:file-error',
generator: () => ({
content: <SynctexFileErrorToast />,
type: 'warning',
autoHide: true,
delay: 4000,
isDismissible: true,
}),
},
]
export default generators
export const showFileErrorToast = () => {
window.dispatchEvent(
new CustomEvent('ide:show-toast', {
detail: {
key: 'synctex:file-error',
},
})
)
}