Skip to content

Commit

Permalink
fix load xml file and reset workspace
Browse files Browse the repository at this point in the history
  • Loading branch information
mariopesch committed Nov 26, 2024
1 parent d609ffb commit 0084ac3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/components/Tutorial/Builder/BlocklyExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class BlocklyExample extends Component {
var xml = this.props.value;
// check if value is valid xml;
try {
Blockly.Xml.textToDom(xml);
Blockly.utils.xml.textToDom(xml);
this.props.deleteError(this.props.index, "xml");
} catch (err) {
xml = initialXml;
Expand Down
7 changes: 5 additions & 2 deletions src/components/Workspace/OpenProject.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@ class OpenProject extends Component {
this.props.clearStats();
Blockly.Xml.domToWorkspace(xmlFile, workspace);
if (workspace.getAllBlocks().length < 1) {
Blockly.Xml.domToWorkspace(Blockly.Xml.textToDom(xmlBefore), workspace);
Blockly.Xml.domToWorkspace(
Blockly.utils.xml.textToDom(xmlBefore),
workspace,
);
this.setState({
open: true,
title: Blockly.Msg.no_blocks_found_title,
Expand Down Expand Up @@ -104,7 +107,7 @@ class OpenProject extends Component {
reader.onloadend = () => {
var xmlDom = null;
try {
xmlDom = Blockly.Xml.textToDom(reader.result);
xmlDom = Blockly.utils.xml.textToDom(reader.result);
var boardAttribute = xmlDom.getAttribute("board");
if (!boardAttribute) {
this.setState({ showOldXMLFileWarning: true });
Expand Down
2 changes: 1 addition & 1 deletion src/components/Workspace/ResetWorkspace.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class ResetWorkspace extends Component {
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);
const xmlDom = Blockly.utils.xml.textToDom(initialXml);
Blockly.Xml.clearWorkspaceAndLoadFromXml(xmlDom, workspace);
Blockly.Events.enable();
workspace.options.maxBlocks = Infinity;
Expand Down

0 comments on commit 0084ac3

Please sign in to comment.