initial implementation of typed variables

This commit is contained in:
felixerdy
2020-09-18 15:19:58 +02:00
parent 38b025e012
commit 136b85e027
4 changed files with 11589 additions and 4 deletions
+4 -3
View File
@@ -35,10 +35,12 @@ import { Card } from '@material-ui/core';
Blockly.setLocale(locale);
class BlocklyComponent extends React.Component {
constructor(props) {
super(props);
this.blocklyDiv = React.createRef();
this.toolbox = React.createRef();
this.state = {workspace: undefined};
}
componentDidMount() {
@@ -50,6 +52,7 @@ class BlocklyComponent extends React.Component {
...rest
},
);
this.setState({workspace: this.primaryWorkspace})
if (initialXml) {
Blockly.Xml.domToWorkspace(Blockly.Xml.textToDom(initialXml), this.primaryWorkspace);
@@ -65,11 +68,9 @@ class BlocklyComponent extends React.Component {
}
render() {
return <React.Fragment>
<Card ref={this.blocklyDiv} id="blocklyDiv" style={this.props.style ? this.props.style : {}}/>
<Toolbox toolbox={this.toolbox} />
<Toolbox toolbox={this.toolbox} workspace={this.state.workspace} />
</React.Fragment>;
}
}