google / blockly

The web-based visual programming editor.
https://developers.google.com/blockly/
Apache License 2.0
12.51k stars 3.72k forks source link

Add Grid extension point #8614

Open riknoll opened 1 month ago

riknoll commented 1 month ago

Check for duplicates

Problem

Currently there is no mechanism I'm aware of for overriding the Grid class that renders the grid background for workspaces. Being able to extend this class would allow for more background options such as a repeating image or other custom patterns.

You can override the background today using CSS, but it won't scroll and scale with the workspace like the grid does.

Request

Add an extension point that lets developers override the Grid class. I believe the parsing code for grid options would also need to be overridden; perhaps it could be moved to a static method on Grid rather than on Options.

Alternatives considered

No response

Additional context

In our MakeCode for Minecraft editor, we use an image as the background instead of a grid. Previously the code for this was in the microsoft/pxt-blockly fork but ever since we deprecated that repo we've lost the ability to do this in a clean manner.

As a temporary fix, I have implemented it with a rather heinous monkey patch.

Also, if this is a desirable change I would be willing to submit a PR!

cpcallen commented 1 month ago

Hi @riknoll. This seems like a perfectly reasonable request, and we'd definitely be willing to take a PR for this. Obviously it's important that the existing functionality be preserved, but otherwise we're happy to consider whatever approach you think is most suitable.