Add a plugin to convert shadow blocks to real blocks when they are modified
Category
- Plugins
Component
Not sure what a good name for this is.
Is your feature request related to a problem? Please describe. It seems some projects prefer having real blocks rather than shadow blocks. Having the shadows turn into real blocks is nice because it makes it seem like your values are "filling in".
Describe the solution you'd like A plugin that turns shadow blocks into real blocks when the blocks are edited.
Describe alternatives you've considered
N/A
Additional context
Some complications that would need to be handled:
- Undo and redo
- Shadow blocks with shadow children
Also, we may not want this as a first-party plugin. But I'm filing here to track it.
The original tracking issue for this is: https://github.com/google/blockly/issues/311 A PR that was previously created for this is: https://github.com/google/blockly/pull/319
Hello! I'm investigating this issue now.
Regarding hierarchies of shadow blocks with shadow children... I propose that when editing a block, it and all ancestor (previous or parent) blocks should be made into real blocks, but child blocks can remain as shadows until they are edited. Not sure if this'll work with getShadowDom() though, especially if the block is detached from the parent that defined the hierarchy, it might be easier to just reify the whole hierarchy.
Regarding undo... I think the desired behavior is straightforward here, but the problem is that changes to the shadowed state of a block simply aren't recorded to the undo history yet? They need to be recorded, undone, and grouped with whatever change caused the shadowed state to change.