Giter VIP home page Giter VIP logo

Comments (7)

fjaen avatar fjaen commented on June 15, 2024

In fact the problem is that "Blockly" is not instantiated when I access Blockly.mainWorkspace

from ngx-blockly.

IBlackI avatar IBlackI commented on June 15, 2024

The blockly is no longer a global, but is exported. So you can import it from ngx-blockly and use it. e.g.
image

from ngx-blockly.

fjaen avatar fjaen commented on June 15, 2024

ok! I understand. Many things have changed.
Then, how do I have access now the Lua property? It seems is not there anymore

Blockly.Lua.valueToCode(...)
Blockly.Lua.ORDER_ATOMIC

I have also realized that now a block created with the workspace does not have methods initSvg or render nor a blockInstance property. Please, do you know how is this done now?

auxBlock.blockInstance.setConcreteInstancesOnly(false);
auxBlock.initSvg();
auxBlock.render();

Many thanks again for your great help

from ngx-blockly.

IBlackI avatar IBlackI commented on June 15, 2024

I do not have an answer regarding the lua.
As for the initSvg, the return of new workspace block is a Blockly.Block, but only Blockly.BlockSvg have that methods. So you will need to tell typescript it is an BlockSvg like this:
image

from ngx-blockly.

fjaen avatar fjaen commented on June 15, 2024

Thank you veru much. It is weird that the exported Blockly does not expose a Javascript or a Lua property to generate code. In the examples provided in the Blockly documentation they use Blockly.Javascript.valueToCode(...). I am a bit lost now :-( because I cannot generate code from custom blocks.

from ngx-blockly.

roroettg avatar roroettg commented on June 15, 2024

Unfortunately the latest changes to Blockly made that approach incompatible with typescript. To access Generators do it like this:

Blockly[NgxBlocklyGenerator.LUA].valueToCode() or Blockly['Lua'].valueToCode()

from ngx-blockly.

fjaen avatar fjaen commented on June 15, 2024

Thank you very much! It works!

from ngx-blockly.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.