import { Dispatch, SetStateAction } from 'react' import { Backdrop, Box, CircularProgress, Paper, Tab, Tooltip, Typography } from '@mui/material' import { styled } from '@mui/material/styles' import Editor, { MonacoDiffEditor } from 'react-monaco-editor' import { TabContext, TabList, TabPanel } from '@mui/lab' import FilePathInputModal from '../../components/filePathInputModal' import FileMenu from './internal/components/fileMenu' import RunMenu from './internal/components/runMenu' import LogComponent from './internal/components/log/logComponent' import LogTabWithIcons from './internal/components/log/logTabWithIcons' import { usePrompt } from '../../utils/hooks' import { getLanguageFromExtension } from './internal/helper' import useEditor from './internal/hooks/useEditor' import { RunTimeType } from '../../context/appContext' import { LogObject } from '../../utils' const StyledTabPanel = styled(TabPanel)(() => ({ padding: '10px' })) const StyledTab = styled(Tab)(() => ({ fontSize: '1rem', color: 'gray', '&.Mui-selected': { color: 'black' } })) type SASjsEditorProps = { selectedFilePath: string setSelectedFilePath: (filePath: string, refreshSideBar?: boolean) => void tab: string setTab: Dispatch> } const SASjsEditor = ({ selectedFilePath, setSelectedFilePath, tab, setTab }: SASjsEditorProps) => { const { fileContent, isLoading, log, openFilePathInputModal, prevFileContent, runTimes, selectedFileExtension, selectedRunTime, showDiff, webout, Dialog, handleChangeRunTime, handleDiffEditorDidMount, handleEditorDidMount, handleFilePathInput, handleRunBtnClick, handleTabChange, saveFile, setShowDiff, setOpenFilePathInputModal, setFileContent, Snackbar } = useEditor({ selectedFilePath, setSelectedFilePath, setTab }) usePrompt( 'Changes you made may not be saved.', prevFileContent !== fileContent && !!selectedFilePath ) const fileMenu = ( ) const monacoEditor = showDiff ? ( setFileContent(val)} /> ) : ( setFileContent(val)} /> ) // INFO: variable indicating if selected run type is SAS if there are any errors or warnings in the log const logWithErrorsOrWarnings = selectedRunTime === RunTimeType.SAS && log && typeof log === 'object' return ( theme.zIndex.drawer + 1 }} open={isLoading} > {selectedFilePath && !runTimes.includes(selectedFileExtension) ? ( {fileMenu} {monacoEditor} ) : ( ) : ( '' ) } onClick={() => { const logWrapper = document.querySelector(`#logWrapper`) if (logWrapper) logWrapper.scrollTop = 0 }} /> Webout } value="webout" /> {fileMenu} {monacoEditor}

Press CTRL + ENTER to run code

{log && ( )}
{webout}
)}
) } export default SASjsEditor