From f997bb661ff778c8b844aa8383c0dd02a9a84918 Mon Sep 17 00:00:00 2001 From: Delucse <46593742+Delucse@users.noreply.github.com> Date: Sun, 13 Sep 2020 13:19:09 +0200 Subject: [PATCH] update initialXml --- src/components/Blockly/BlocklyWindow.js | 26 +++++++++++++------------ src/components/Tutorial/Tutorial.js | 2 +- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/components/Blockly/BlocklyWindow.js b/src/components/Blockly/BlocklyWindow.js index 1ee6baa..7b66b81 100644 --- a/src/components/Blockly/BlocklyWindow.js +++ b/src/components/Blockly/BlocklyWindow.js @@ -1,7 +1,7 @@ import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { connect } from 'react-redux'; -import { onChangeWorkspace } from '../../actions/workspaceActions'; +import { onChangeWorkspace, clearStats } from '../../actions/workspaceActions'; import * as De from './msg/de'; import BlocklyComponent from './'; import * as Blockly from 'blockly/core'; @@ -22,6 +22,7 @@ class BlocklyWindow extends Component { componentDidMount() { const workspace = Blockly.getMainWorkspace(); this.props.onChangeWorkspace({}); + this.props.clearStats(); workspace.addChangeListener((event) => { this.props.onChangeWorkspace(event); Blockly.Events.disableOrphans(event); @@ -29,15 +30,15 @@ class BlocklyWindow extends Component { Blockly.svgResize(workspace); } - // componentDidUpdate(props) { - // const workspace = Blockly.getMainWorkspace(); - // if(props.initialXml !== this.props.initialXml){ - // // guarantees that the current xml-code (this.props.initialXml) is rendered - // workspace.clear(); - // Blockly.Xml.domToWorkspace(Blockly.Xml.textToDom(this.props.initialXml), workspace); - // } - // Blockly.svgResize(workspace); - // } + componentDidUpdate(props) { + const workspace = Blockly.getMainWorkspace(); + if(props.initialXml !== this.props.initialXml){ + // guarantees that the current xml-code (this.props.initialXml) is rendered + workspace.clear(); + Blockly.Xml.domToWorkspace(Blockly.Xml.textToDom(this.props.initialXml), workspace); + } + Blockly.svgResize(workspace); + } render() { return ( @@ -77,8 +78,9 @@ class BlocklyWindow extends Component { } BlocklyWindow.propTypes = { - onChangeWorkspace: PropTypes.func.isRequired + onChangeWorkspace: PropTypes.func.isRequired, + clearStats: PropTypes.func.isRequired }; -export default connect(null, { onChangeWorkspace })(BlocklyWindow); +export default connect(null, { onChangeWorkspace, clearStats })(BlocklyWindow); diff --git a/src/components/Tutorial/Tutorial.js b/src/components/Tutorial/Tutorial.js index 743e6f2..c5c1d9e 100644 --- a/src/components/Tutorial/Tutorial.js +++ b/src/components/Tutorial/Tutorial.js @@ -48,7 +48,7 @@ class Tutorial extends Component {
{/* calc(Card-padding: 10px + Button-height: 35px + Button-marginTop: 15px)*/} - + {step ? step.type === 'instruction' ?