import type { Diagnostic } from '@codemirror/lint';
import CheckIcon from '@mui/icons-material/Check';
import ErrorIcon from '@mui/icons-material/Error';
import FormatListNumberedIcon from '@mui/icons-material/FormatListNumbered';
import FormatPaint from '@mui/icons-material/FormatPaint';
import InfoOutlinedIcon from '@mui/icons-material/InfoOutlined';
import RedoIcon from '@mui/icons-material/Redo';
import SearchIcon from '@mui/icons-material/Search';
import UndoIcon from '@mui/icons-material/Undo';
import WarningIcon from '@mui/icons-material/Warning';
import IconButton from '@mui/material/IconButton';
import Stack from '@mui/material/Stack';
import ToggleButton from '@mui/material/ToggleButton';
import ToggleButtonGroup from '@mui/material/ToggleButtonGroup';
import { observer } from 'mobx-react-lite';
import React from 'react';
import { useRootStore } from '../RootStore';
// Exhastive switch as proven by TypeScript.
// eslint-disable-next-line consistent-return
function getLintIcon(severity: Diagnostic['severity'] | undefined) {
switch (severity) {
case 'error':
return ;
case 'warning':
return ;
case 'info':
return ;
default:
return ;
}
}
function EditorButtons(): JSX.Element {
const { editorStore } = useRootStore();
return (
editorStore.undo()}
aria-label="Undo"
color="inherit"
>
editorStore.redo()}
aria-label="Redo"
color="inherit"
>
editorStore.toggleLineNumbers()}
aria-label="Show line numbers"
aria-controls={editorStore.lineNumbersId}
value="show-line-numbers"
>
editorStore.searchPanel.toggle()}
aria-label="Show find/replace"
{...(editorStore.searchPanel.state && {
'aria-controls': editorStore.searchPanel.id,
})}
value="show-search-panel"
>
editorStore.lintPanel.toggle()}
aria-label="Show diagnostics panel"
{...(editorStore.lintPanel.state && {
'aria-controls': editorStore.lintPanel.id,
})}
value="show-lint-panel"
>
{getLintIcon(editorStore.highestDiagnosticLevel)}
editorStore.formatText()}
aria-label="Automatic format"
color="inherit"
>
);
}
export default observer(EditorButtons);