mirror of
https://github.com/pybricks/pybricks-code.git
synced 2026-09-12 01:23:52 +00:00
drop 'editor' saga context
This is no longer used.
This commit is contained in:
+3
-14
@@ -5,7 +5,7 @@ import { Classes } from '@blueprintjs/core';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import SplitterLayout from 'react-splitter-layout';
|
||||
import { useLocalStorage, useTernaryDarkMode } from 'usehooks-ts';
|
||||
import Editor, { EditorType } from '../editor/Editor';
|
||||
import Editor from '../editor/Editor';
|
||||
import Explorer from '../explorer/Explorer';
|
||||
import { useSettingIsShowDocsEnabled } from '../settings/hooks';
|
||||
import StatusBar from '../status-bar/StatusBar';
|
||||
@@ -121,12 +121,7 @@ const Docs: React.VFC = () => {
|
||||
);
|
||||
};
|
||||
|
||||
type AppProps = {
|
||||
/** Called when the editor is initialized. */
|
||||
onEditorChanged?: (editor: EditorType) => void;
|
||||
};
|
||||
|
||||
const App: React.VoidFunctionComponent<AppProps> = ({ onEditorChanged }) => {
|
||||
const App: React.VFC = () => {
|
||||
const { isDarkMode } = useTernaryDarkMode();
|
||||
const { isSettingShowDocsEnabled } = useSettingIsShowDocsEnabled();
|
||||
const [isDragging, setIsDragging] = useState(false);
|
||||
@@ -172,13 +167,7 @@ const App: React.VoidFunctionComponent<AppProps> = ({ onEditorChanged }) => {
|
||||
secondaryInitialSize={terminalSplit}
|
||||
onSecondaryPaneSizeChange={setTerminalSplit}
|
||||
>
|
||||
<Editor
|
||||
onEditorChanged={(editor) => {
|
||||
if (onEditorChanged) {
|
||||
onEditorChanged(editor);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
<Editor />
|
||||
<div className="pb-app-terminal-padding h-100">
|
||||
<Terminal />
|
||||
</div>
|
||||
|
||||
+3
-18
@@ -26,11 +26,6 @@ import { UntitledHintContribution } from './untitledHint';
|
||||
|
||||
import './editor.scss';
|
||||
|
||||
/**
|
||||
* The editor type. Null indicates no current editor.
|
||||
*/
|
||||
export type EditorType = monaco.editor.ICodeEditor | null;
|
||||
|
||||
const pybricksMicroPythonId = 'pybricks-micropython';
|
||||
monaco.languages.register({ id: pybricksMicroPythonId });
|
||||
|
||||
@@ -186,9 +181,7 @@ function useEditorAction(
|
||||
);
|
||||
}
|
||||
|
||||
type EditorProps = { onEditorChanged?: (editor: EditorType) => void };
|
||||
|
||||
const Editor: React.VoidFunctionComponent<EditorProps> = ({ onEditorChanged }) => {
|
||||
const Editor: React.VFC = () => {
|
||||
const dispatch = useDispatch();
|
||||
|
||||
const [editor, setEditor] = useState<monaco.editor.IStandaloneCodeEditor>();
|
||||
@@ -265,21 +258,13 @@ const Editor: React.VoidFunctionComponent<EditorProps> = ({ onEditorChanged }) =
|
||||
(editor) => {
|
||||
editor.focus();
|
||||
setEditor(editor);
|
||||
|
||||
if (onEditorChanged) {
|
||||
onEditorChanged(editor);
|
||||
}
|
||||
},
|
||||
[onEditorChanged, setEditor],
|
||||
[setEditor],
|
||||
);
|
||||
|
||||
const handleEditorWillUnmount = useCallback<EditorWillUnmount>(() => {
|
||||
if (onEditorChanged) {
|
||||
onEditorChanged(null);
|
||||
}
|
||||
|
||||
setEditor(undefined);
|
||||
}, [onEditorChanged, setEditor]);
|
||||
}, [setEditor]);
|
||||
|
||||
const handleChange = useCallback<ChangeHandler>(
|
||||
// REVISIT: need to ensure we have exclusive access to file
|
||||
|
||||
+1
-4
@@ -25,7 +25,6 @@ const toaster = I18nToaster.create(i18nManager);
|
||||
|
||||
const sagaMiddleware = createSagaMiddleware<RootSagaContext>({
|
||||
context: {
|
||||
editor: null,
|
||||
nextMessageId: createCountFunc(),
|
||||
notification: { toaster },
|
||||
terminal: defaultTerminalContext,
|
||||
@@ -54,9 +53,7 @@ ReactDOM.render(
|
||||
<Provider store={store}>
|
||||
<I18nContext.Provider value={i18nManager}>
|
||||
<ViewHeightSensor />
|
||||
<App
|
||||
onEditorChanged={(editor) => sagaMiddleware.setContext({ editor })}
|
||||
/>
|
||||
<App />
|
||||
</I18nContext.Provider>
|
||||
</Provider>
|
||||
</React.StrictMode>,
|
||||
|
||||
+1
-2
@@ -6,7 +6,6 @@ import { didStart } from './app/actions';
|
||||
import app from './app/sagas';
|
||||
import blePybricksService from './ble-pybricks-service/sagas';
|
||||
import ble from './ble/sagas';
|
||||
import { EditorType } from './editor/Editor';
|
||||
import editor from './editor/sagas';
|
||||
import errorLog from './error-log/sagas';
|
||||
import explorer from './explorer/sagas';
|
||||
@@ -43,6 +42,6 @@ export default function* (): Generator {
|
||||
/**
|
||||
* Combined type for all saga contexts.
|
||||
*/
|
||||
export type RootSagaContext = { editor: EditorType } & FirmwareSagaContext &
|
||||
export type RootSagaContext = FirmwareSagaContext &
|
||||
NotificationSagaContext &
|
||||
TerminalSagaContext;
|
||||
|
||||
Reference in New Issue
Block a user