Unresolved function or method textToDom() and domToBlock() in Blockly

Hello,

I'm facing an issue and could really use some help. Here's the problem:
I am trying to implement a feature in Blockly that imports a block from a PNG file using the textToDom() and domToBlock() methods. However, I am encountering the following issue in my development environment:

Unresolved function or method textToDom()
Unresolved function or method domToBlock()

Here is my code:

/**
 * Imports a block from a PNG file if the code chunk is present.
 * @param {!Blockly.WorkspaceSvg} workspace the target workspace for the block
 * @param {goog.math.Coordinate} xy the coordinate to place the block
 * @param {Blob} png the blob representing the PNG file
 */
Blockly.importPngAsBlock = function (workspace, xy, png) {
  new PNG().readFromBlob(png, function (png) {
    var xmlChunk = png.getCodeChunk();
    if (xmlChunk) {
      var xmlText = new TextDecoder().decode(xmlChunk.data);

      var xml = Blockly.utils.xml.textToDom(xmlText); // Error here
      xml = xml.firstElementChild;
      var block = Blockly.Xml.domToBlock(xml, workspace); // Error here
      block.moveBy(xy.x, xy.y);
      block.initSvg();
      workspace.requestRender(block);
    }
  });
};
  • I made changes to code.and compile the code after compilation
  • When hovering over xml, changes link to plover (an external JAR file).
  • The pre-existing, unmodified code links correctly to the appropriate files in appinventor.
  • An unresolved error occurs for the method textToDom().

Environment Details

  • macOS: Mac M1
  • IDE: intellij idea
  • Java Version:
openjdk 11.0.25 2024-10-15 LTS  
OpenJDK Runtime Environment Zulu11.76+21-CA (build 11.0.25+9-LTS)  
OpenJDK 64-Bit Server VM Zulu11.76+21-CA (build 11.0.25+9-LTS, mixed mode)  
  • Apache Ant Version:
Apache Ant(TM) version 1.10.15 compiled on August 25 2024  
  • Google Cloud SDK: Installed and configured

In recent versions of Blockly, methods for working with XML are found in Blockly.Xml , and not in Blockly.utils.xml .

What specifically is reporting these errors? Both of those functions exist so it sounds like an issue with your IDE configuration and not something specific to the code base.

Note: If you need them the .d.ts files for Blockly are in our code base and you should be able to include them from the lib/blockly/@types directory.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.