Skip to content

Commit

Permalink
Blockly.utils.xml.textToDomDocument has been removed
Browse files Browse the repository at this point in the history
  • Loading branch information
klein0r committed Jun 7, 2024
1 parent e17c900 commit d3abb6c
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/src/Components/BlocklyEditor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -398,18 +398,23 @@ class BlocklyEditor extends React.Component {
if (!xml.startsWith('<xml')) {
xml = `<xml xmlns="https://developers.google.com/blockly/xml">${xml}</xml>`;
}
/*
// TODO: WHY?!
const variables = xml.replace(/[\n\r]/g, '').match(/<variables>(.*)<\/variables>/);
if (variables) {
const vars = this.Blockly.utils.xml.textToDomDocument(`<variables>${variables[1]}</variables>`);
if (vars) {
const nodes = vars.childNodes && vars.childNodes[0] && vars.childNodes[0].childNodes;
if (nodes) {
for (let i = 0; i < nodes.length; i++) {
nodes[i].id && this.blocklyWorkspace.createVariable(nodes[i].id);
const parser = new DOMParser();
const vars = parser.parseFromString(`<variables>${variables[1]}</variables>`, 'text/xml').firstChild;
for (const child of vars.children) {
if (child.tagName === 'variable') {
// e.g. timeout or interval
const varType = child.getAttribute('type');
if (varType) {
this.blocklyWorkspace.createVariable(child.getAttribute('id'), varType);
}
}
}
}
*/
xml = xml.replace(/[\n\r]/g, '').replace(/<variables>.*<\/variables>/g, '');
window.scripts.loading = true;

Expand Down

0 comments on commit d3abb6c

Please sign in to comment.