import { ChangeEvent, FC, memo, useCallback } from 'react' import useScopeValue from '@/shared/hooks/use-scope-value' import OLTooltip from '@/features/ui/components/ol/ol-tooltip' import useTutorial from '@/shared/hooks/promotions/use-tutorial' import { sendMB } from '../../../infrastructure/event-tracking' import { isValidTeXFile } from '../../../main/is-valid-tex-file' import { useTranslation } from 'react-i18next' import { EditorSwitchBeginnerTooltip, codeEditorModePrompt, } from './editor-switch-beginner-tooltip' function EditorSwitch() { const { t } = useTranslation() const [visual, setVisual] = useScopeValue('editor.showVisual') const [docName] = useScopeValue('editor.open_doc_name') const [codeEditorOpened] = useScopeValue('editor.codeEditorOpened') const richTextAvailable = isValidTeXFile(docName) const { completeTutorial } = useTutorial(codeEditorModePrompt, { location: 'logs', name: codeEditorModePrompt, }) const handleChange = useCallback( event => { const editorType = event.target.value switch (editorType) { case 'cm6': setVisual(false) if (!codeEditorOpened) { completeTutorial({ event: 'promo-click', action: 'complete' }) } break case 'rich-text': setVisual(true) break } sendMB('editor-switch-change', { editorType }) }, [codeEditorOpened, completeTutorial, setVisual] ) return (