fix load projects
This commit is contained in:
		
							parent
							
								
									190d676e5b
								
							
						
					
					
						commit
						d835ffc449
					
				| @ -21,17 +21,17 @@ class BlocklyWindow extends Component { | |||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   componentDidMount() { |   componentDidMount() { | ||||||
|     console.log(this.props); |  | ||||||
|     const workspace = Blockly.getMainWorkspace(); |     const workspace = Blockly.getMainWorkspace(); | ||||||
| 
 |     if (!this.props.initialXml) { | ||||||
|     if (this.props.workspaceXML !== "") { |       if (this.props.workspaceXML !== "") { | ||||||
|       Blockly.Xml.clearWorkspaceAndLoadFromXml( |         Blockly.Xml.clearWorkspaceAndLoadFromXml( | ||||||
|         Blockly.Xml.textToDom(this.props.workspaceXML), |           Blockly.Xml.textToDom(this.props.workspaceXML), | ||||||
|         workspace |           workspace | ||||||
|       ); |         ); | ||||||
|     } else { |       } else { | ||||||
|       this.props.onChangeWorkspace({}); |         this.props.onChangeWorkspace({}); | ||||||
|       this.props.clearStats(); |         this.props.clearStats(); | ||||||
|  |       } | ||||||
|     } |     } | ||||||
|     workspace.addChangeListener((event) => { |     workspace.addChangeListener((event) => { | ||||||
|       this.props.onChangeWorkspace(event); |       this.props.onChangeWorkspace(event); | ||||||
| @ -47,8 +47,6 @@ class BlocklyWindow extends Component { | |||||||
|   componentDidUpdate(props) { |   componentDidUpdate(props) { | ||||||
|     const workspace = Blockly.getMainWorkspace(); |     const workspace = Blockly.getMainWorkspace(); | ||||||
|     var xml = this.props.initialXml; |     var xml = this.props.initialXml; | ||||||
|     console.log(xml) |  | ||||||
|     console.log(this.props.xml) |  | ||||||
|     // if svg is true, then the update process is done in the BlocklySvg component
 |     // if svg is true, then the update process is done in the BlocklySvg component
 | ||||||
|     if (props.initialXml !== xml && !this.props.svg) { |     if (props.initialXml !== xml && !this.props.svg) { | ||||||
|       // guarantees that the current xml-code (this.props.initialXml) is rendered
 |       // guarantees that the current xml-code (this.props.initialXml) is rendered
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user