compiler-setting.tsx 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import { useProjectSettingsContext } from '@/features/editor-left-menu/context/project-settings-context'
  2. import DropdownSetting from '../dropdown-setting'
  3. import type { Option } from '../dropdown-setting'
  4. import { useTranslation } from 'react-i18next'
  5. import { usePermissionsContext } from '@/features/ide-react/context/permissions-context'
  6. import { ProjectCompiler } from '@ol-types/project-settings'
  7. import { useSetCompilationSettingWithEvent } from '@/features/editor-left-menu/hooks/use-set-compilation-setting'
  8. const OPTIONS: Option<ProjectCompiler>[] = [
  9. {
  10. value: 'pdflatex',
  11. label: 'pdfLaTeX',
  12. },
  13. {
  14. value: 'latex',
  15. label: 'LaTeX',
  16. },
  17. {
  18. value: 'xelatex',
  19. label: 'XeLaTeX',
  20. },
  21. {
  22. value: 'lualatex',
  23. label: 'LuaLaTeX',
  24. },
  25. ]
  26. export default function CompilerSetting() {
  27. const { compiler, setCompiler } = useProjectSettingsContext()
  28. const { t } = useTranslation()
  29. const { write } = usePermissionsContext()
  30. const changeCompiler = useSetCompilationSettingWithEvent(
  31. 'compiler',
  32. setCompiler
  33. )
  34. return (
  35. <DropdownSetting
  36. id="compiler"
  37. label={t('compiler')}
  38. description={t('the_latex_engine_used_for_compiling')}
  39. disabled={!write}
  40. options={OPTIONS}
  41. onChange={changeCompiler}
  42. value={compiler}
  43. translateOptions="no"
  44. />
  45. )
  46. }