import React, { 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 { usePrompt } from '../../utils/hooks' import { getLanguageFromExtension } from './internal/helper' import useEditor from './internal/hooks/useEditor' 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 { ctrlPressed, fileContent, isLoading, log, openFilePathInputModal, prevFileContent, runTimes, selectedFileExtension, selectedRunTime, showDiff, webout, Dialog, handleChangeRunTime, handleDiffEditorDidMount, handleEditorDidMount, handleFilePathInput, handleKeyDown, handleKeyUp, 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)} /> ) return ( theme.zIndex.drawer + 1 }} open={isLoading} > {selectedFilePath && !runTimes.includes(selectedFileExtension) ? ( {fileMenu} {monacoEditor} ) : ( Webout } value="webout" /> {fileMenu} {monacoEditor}

Press CTRL + ENTER to run code

Log

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