synctex-toasts.tsx 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import { GlobalToastGeneratorEntry } from '@/features/ide-react/components/global-toasts'
  2. import { useTranslation } from 'react-i18next'
  3. import OLButton from '@/features/ui/components/ol/ol-button'
  4. export const SynctexFileErrorToast = () => {
  5. const { t } = useTranslation()
  6. return (
  7. <div className="synctex-error-toast-content">
  8. <span>{t('synctex_failed')}</span>
  9. <OLButton
  10. href="/learn/how-to/SyncTeX_Errors"
  11. target="_blank"
  12. variant="secondary"
  13. size="sm"
  14. >
  15. {t('more_info')}
  16. </OLButton>
  17. </div>
  18. )
  19. }
  20. const generators: GlobalToastGeneratorEntry[] = [
  21. {
  22. key: 'synctex:file-error',
  23. generator: () => ({
  24. content: <SynctexFileErrorToast />,
  25. type: 'warning',
  26. autoHide: true,
  27. delay: 4000,
  28. isDismissible: true,
  29. }),
  30. },
  31. ]
  32. export default generators
  33. export const showFileErrorToast = () => {
  34. window.dispatchEvent(
  35. new CustomEvent('ide:show-toast', {
  36. detail: {
  37. key: 'synctex:file-error',
  38. },
  39. })
  40. )
  41. }