mit-cml / workspace-multiselect

A Blockly plugin that allows you to drag, select and manipulate multiple blocks in the workspace.
https://hollowman6.github.io/workspace-multiselect/multi-workspace
11 stars 12 forks source link

Duplicating multiple blocks #8

Closed zakx closed 1 year ago

zakx commented 1 year ago

I'm trying to duplicate multiple blocks. However, only the topmost block gets duplicated correctly.

https://user-images.githubusercontent.com/628602/225938214-d5ff63f3-176e-4ca1-a8a3-b693a245e46b.mp4

The project README suggests that it should have worked in the past.

When omitting the !hasSelectedParent(block) check in https://github.com/mit-cml/workspace-multiselect/blob/main/src/multiselect_contextmenu.js#L52-L54, I am able to duplicate all selected blocks, but I am unsure if this would introduce futher errors or lead to inconsistencies in certain cases. Any ideas?

zakx commented 1 year ago

It looks like the issue is that the if block reports that the repeat block is their parent, while the check is only useful for actual children like the "10" insert for the repeat block.

zakx commented 1 year ago

It feels like getSurroundParent() (https://github.com/google/blockly/blob/develop/core/block.ts#L591) would be the correct way to figure out if the block in question is part of another block?

HollowMan6 commented 1 year ago

Okay, I will look into this soon.

HollowMan6 commented 1 year ago

Hi! A fix is now available and pending for review. https://github.com/mit-cml/workspace-multiselect/pull/9