JS Editor: add missing block coverage (codegen + runtime + JS→Blocks)#5834
Conversation
This PR extends the JS Editor in both directions: Blocks → JS: adds block mappings and missing runtime methods. JS → Blocks: adds AST conversion rules for the same blocks (where applicable).
|
✅ All Jest tests passed! This PR is ready to merge. |
|
@walterbender @omsuneri can you please review if you get time, also recommend me important blocks to be added to the editor which are missing. here are the missing blocks list |
shashank03-dev
left a comment
There was a problem hiding this comment.
hey, I have a few questions regarding this. I noticed that fillShape(flow) calls doStartFill and awaits the flow(), but it doesn't seem to call an end fill command. Should there be something known as this.runCommand("doEndFill"); after the flow execution to close the shape properly? and did you add specific unit test strings for these new blocks to lock in the coverage, or does the current test setup catch them automatically?
|
@shashank03-dev Thanks for the review, There were no testcases for JS Editor ( i saw a PR open but not sure if it got merged). and i think the flow was never touched in this PR because it already existed before. so it should work. |
|
Thanks for the context, @zealot-zew! I totally understand that this was existing code. To make fillShape consistent and more robust. Adding a doEndFill call within a try...finally block would ensure the shape closes properly even if the inner flow() throws an error we could even do this ,this would be more easy for runtime |
|
@walterbender I have updated the Missing blocks list to make sure AI slop blocks are not there. Can you check some them so that i can proceed with adding them. https://docs.google.com/document/d/1IfFZksLIQqTQeF40G45nUC2eVfqdLVPsJEk-jnNIC2g/edit?tab=t.0 |
This PR completes missing block coverage in the JS Editor by adding support in both directions:
This ensures round-trip compatibility between Blocks and the JS Editor for the added blocks.
Blocks Added / Updated
1.
waitwait→doWait(seconds)GraphicsBlocksAPI.doWait(seconds)await mouse.doWait(n)→wait2.
erasemediaerasemedia→clearMedia()GraphicsBlocksAPI.clearMedia()await mouse.clearMedia()→erasemedia3.
beginfillbeginfill→beginFill()PenBlocksAPI.beginFill()await mouse.beginFill()→beginfill4.
endfillendfill→endFill()PenBlocksAPI.endFill()await mouse.endFill()→endfill5.
fill(clamp block)fill→fillShape(flow)await mouse.fillShape(async () => { ... })→fill6.
hollowline(clamp block)hollowline→hollowLine(flow)await mouse.hollowLine(async () => { ... })→hollowline7.
definemode(clamp block)definemode→defineMode(name, flow)await mouse.defineMode("name", async () => { ... })→definemode8.
movableMOVABLEDOMouse.MOVABLEDO)mouse.MOVABLEDO = true/false→movable9.
commentVerified In the JS Editor.

JS Editor Architeture for Reference:
