update initialXml
This commit is contained in:
parent
e7723487c9
commit
f997bb661f
@ -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);
|
||||
|
@ -48,7 +48,7 @@ class Tutorial extends Component {
|
||||
<div style={{display: 'flex'}}>
|
||||
<StepperVertical steps={steps}/>
|
||||
{/* calc(Card-padding: 10px + Button-height: 35px + Button-marginTop: 15px)*/}
|
||||
<Card style={{padding: '10px 10px 60px 10px', display: 'block', position: 'relative', height: 'max-content'}}>
|
||||
<Card style={{padding: '10px 10px 60px 10px', display: 'block', position: 'relative', height: 'max-content', width: '100%'}}>
|
||||
{step ?
|
||||
step.type === 'instruction' ?
|
||||
<Instruction step={step}/>
|
||||
|
Loading…
x
Reference in New Issue
Block a user