|
|
|
@ -8,17 +8,11 @@ interface ScratchpadOptions {
|
|
|
|
|
value?: string;
|
|
|
|
|
language?: string;
|
|
|
|
|
handleUpdateCode?: (str: string, event: monaco.editor.IModelContentChangedEvent) => void;
|
|
|
|
|
mainSize?: number;
|
|
|
|
|
recordSize?: number;
|
|
|
|
|
pretestSize?: number;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default connect((state: any) => ({
|
|
|
|
|
value: state.editor.code,
|
|
|
|
|
language: window.LANGS[state.editor.lang]?.monaco,
|
|
|
|
|
mainSize: state.ui.main.size,
|
|
|
|
|
pretestSize: state.ui.pretest.size,
|
|
|
|
|
recordSize: state.ui.records.size,
|
|
|
|
|
}), (dispatch) => ({
|
|
|
|
|
handleUpdateCode: (code: string) => {
|
|
|
|
|
dispatch({
|
|
|
|
@ -66,7 +60,7 @@ export default connect((state: any) => ({
|
|
|
|
|
|
|
|
|
|
async componentDidUpdate(prevProps) {
|
|
|
|
|
const {
|
|
|
|
|
value, language, mainSize, recordSize, pretestSize,
|
|
|
|
|
value, language,
|
|
|
|
|
} = this.props;
|
|
|
|
|
const { monaco } = await load([language]);
|
|
|
|
|
const { editor, model } = this;
|
|
|
|
@ -94,11 +88,6 @@ export default connect((state: any) => ({
|
|
|
|
|
this.model = monaco.editor.getModel(uri) || monaco.editor.createModel(val, language, uri);
|
|
|
|
|
editor.setModel(this.model);
|
|
|
|
|
}
|
|
|
|
|
if (editor) {
|
|
|
|
|
if (prevProps.mainSize !== mainSize
|
|
|
|
|
|| prevProps.recordSize !== recordSize
|
|
|
|
|
|| prevProps.pretestSize !== pretestSize) editor.layout();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
componentWillUnmount() {
|
|
|
|
|