displaying the status of the tutorial

This commit is contained in:
Delucse
2020-09-07 15:57:09 +02:00
parent b42e466304
commit 4c66ab9173
9 changed files with 229 additions and 54 deletions
+1 -11
View File
@@ -1,7 +1,5 @@
import React, { Component } from 'react';
import * as Blockly from 'blockly/core';
import Breadcrumbs from '../Breadcrumbs';
import StepperHorizontal from './StepperHorizontal';
import StepperVertical from './StepperVertical';
@@ -11,7 +9,6 @@ import CodeViewer from '../CodeViewer';
import NotFound from '../NotFound';
import { tutorials } from './tutorials';
import { initialXml } from '../Blockly/initialXml.js';
import withWidth, { isWidthUp } from '@material-ui/core/withWidth';
import Tabs from '@material-ui/core/Tabs';
@@ -28,14 +25,7 @@ class Tutorial extends Component {
componentDidUpdate(props, state){
if(state.tutorialId !== Number(this.props.match.params.tutorialId)){
this.setState({tutorialId: Number(this.props.match.params.tutorialId)});
// clear workspace
const workspace = Blockly.getMainWorkspace();
Blockly.Events.disable(); // https://groups.google.com/forum/#!topic/blockly/m7e3g0TC75Y
// if events are disabled, then the workspace will be cleared AND the blocks are not in the trashcan
const xmlDom = Blockly.Xml.textToDom(initialXml)
Blockly.Xml.clearWorkspaceAndLoadFromXml(xmlDom, workspace);
Blockly.Events.enable();
this.setState({ value: 'introduction', tutorialId: Number(this.props.match.params.tutorialId) });
}
}