draft-setting.tsx 980 B

123456789101112131415161718192021222324252627282930313233343536
  1. import { useTranslation } from 'react-i18next'
  2. import { useDetachCompileContext as useCompileContext } from '@/shared/context/detach-compile-context'
  3. import { useMemo } from 'react'
  4. import DropdownSetting from '../dropdown-setting'
  5. import { useSetCompilationSettingWithEvent } from '@/features/editor-left-menu/hooks/use-set-compilation-setting'
  6. export default function DraftSetting() {
  7. const { draft, setDraft } = useCompileContext()
  8. const { t } = useTranslation()
  9. const changeDraft = useSetCompilationSettingWithEvent(
  10. 'compile-mode',
  11. setDraft
  12. )
  13. const options = useMemo(
  14. () => [
  15. { label: t('normal'), value: false },
  16. {
  17. label: t('fast_draft'),
  18. value: true,
  19. },
  20. ],
  21. [t]
  22. )
  23. return (
  24. <DropdownSetting
  25. id="draft"
  26. label={t('compile_mode')}
  27. options={options}
  28. description={t('switch_compile_mode_for_faster_draft_compilation')}
  29. value={draft}
  30. onChange={changeDraft}
  31. />
  32. )
  33. }