Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add extension point for overriding Grid functionality #8751

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

riknoll
Copy link
Contributor

@riknoll riknoll commented Jan 28, 2025

The basics

The details

Resolves

Fixes #8614

Proposed Changes

Refactors the Grid class so that it can be overridden by a plugin. The static methods for parsing grid options and creating the SVG pattern element have also been moved onto a new GridProvider class which can be passed in as a plugin in the BlocklyOptions object. The implementations of these functions are unchanged; they just got moved around.

Originally, I just wanted these to be static methods on the IGrid interface, but the typings for the registry's getClass functions don't really allow for static properties and I didn't want to tear all that up in this PR.

I would love some feedback on the typing of GridOptions here. My example use case for this is the MakeCode Minecraft editor which overrides the grid with a background image that scrolls with the workspace. A plugin that provided that functionality would likely need to extend the GridOptions type with extra fields like the URL of the image, width/height, opacity, etc. However, the grid property of the BlocklyOptions object passed to inject is pretty strongly typed; the only way around it right now is to do a lot of casting to any.

Reason for Changes

See the linked issue for reasoning!

Test Coverage

Tested manually in the playground and by creating a test plugin locally. Happy to add unit tests, but I didn't see any for other extension points at a click glance.

Documentation

Additional Information

I can also add a plugin to blockly-samples that utilizes this change should this PR be approved.

@riknoll riknoll requested a review from a team as a code owner January 28, 2025 23:47
@riknoll riknoll requested a review from gonfunko January 28, 2025 23:47
@github-actions github-actions bot added PR: feature Adds a feature and removed PR: feature Adds a feature labels Jan 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: feature Adds a feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Grid extension point
2 participants