import { Suspense, lazy } from 'react' import { useIdeContext } from 'src/helpers/hooks/useIdeContext' import { makeCodeStoreKey } from 'src/helpers/hooks/useIdeState' import { requestRender } from 'src/helpers/hooks/useIdeState' const Editor = lazy(() => import('@monaco-editor/react')) export const matchEditorVsDarkTheme = { // Some colors to roughly match the vs-dark editor theme Bg: { backgroundColor: 'rgb(30,30,30)' }, Text: { color: 'rgb(212,212,212)' }, TextBrown: { color: 'rgb(206,144,120)' }, } const IdeEditor = () => { const { state, thunkDispatch } = useIdeContext() const ideTypeToLanguageMap = { cadQuery: 'python', openScad: 'cpp', } function handleCodeChange(value, _event) { thunkDispatch({ type: 'updateCode', payload: value }) } function handleSaveHotkey(event) { //ctrl|meta + s is very intuitive for most devs const { key, ctrlKey, metaKey } = event if (key === 's' && (ctrlKey || metaKey)) { event.preventDefault() thunkDispatch((dispatch, getState) => { const state = getState() dispatch({ type: 'setLoading' }) requestRender({ state, dispatch, code: state.code, viewerSize: state.viewerSize, camera: state.camera, }) }) localStorage.setItem(makeCodeStoreKey(state.ideType), state.code) } } const loading = (
. . . loading
) return (
) } export default IdeEditor