Skip to content

Conversation

@lizlooney
Copy link
Collaborator

Use a separate BlocklyComponent for each module

Renamed field currentModule to module.
Renamed field currentProject to project.
Renamed method getCurrentModuleType to getModuleType.

Updated places where getCurrentModuleType was called.
…kspace is not known.

Updated callers to explicitly call editor.getCurrentEditor only if appropriate.
…project from storage and put them in modulePathToContentText object.

App passes modulePathToContentText to editor during loadModuleBlocks.
When a module is saved, App updates modulePathToContentText.

Modified editor to use modulePathToContentText instead of fetching module content from storage.

Renamed saveBlocks to saveModule.
Replaced blocksEditor and blocklyComponent with modulePaths, modulePathToBocklyComponent and modulePathToEditor.
modulePaths controls how BlocklyComponents are created.
Changed code that used blocksEditor and blocklyComponent.
Added activeEditor function that is called when currentModule changes.
Added setupBlocklyComponent, a callback that is a called when a new BlocklyComponent is created.

In BlocklyComponent.tsx:
Renamed onWorkspaceRecreated to onWorkspaceCreated
Added modulePath to BlocklyComponentProps. Pass modulePath to onBlocklyComponentCreated and onWorkspaceCreated callbacks.
Added fields for parentDiv and savedScrollX/Y.
Only call Blockly.svgResize if the workspace is visible and is the main workspace.
Added setActive function and include it in BlocklyComponentType.
In setActive, handle either the BlocklyComponenent becoming inactive or active by hiding or showing the blockly workspace. Update scroll position if necessary when going from inactive to active.

In editor.ts:
Make many fields readonly since an editor is no longer reused for different modules.
Check whether the blockly workspace has been abandoned in many places.
…tor.

Change mrcWorkspaceToCode to take a Module instead of GeneratorContext.
Change mrcWorkspaceToCode to call context.setModule and this.init(workspace).
@lizlooney lizlooney requested a review from alan412 September 15, 2025 07:01
Copy link
Collaborator

@alan412 alan412 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love how much faster this makes switching between tabs. Overall I think this is great. Just a couple of minor suggestions for improvement. They are minor enough suggestions that I went ahead and approved.

@lizlooney lizlooney merged commit 6a1a2f5 into wpilibsuite:main Sep 15, 2025
1 check passed
@lizlooney lizlooney deleted the pr_separate_blockly_workspaces branch September 15, 2025 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants