Skip to content

Fix copy/paste issues and mutators#146

Open
LappiLappland wants to merge 7 commits into
mit-cml:mainfrom
LappiLappland:fix/copy-paste-behaviour
Open

Fix copy/paste issues and mutators#146
LappiLappland wants to merge 7 commits into
mit-cml:mainfrom
LappiLappland:fix/copy-paste-behaviour

Conversation

@LappiLappland

Copy link
Copy Markdown

The basics

The details

Resolves

Fixes #136 and #143

Proposed Changes

  1. Moved copy/paste callbacks to shared functions in global.js. They should ideally behave exactly the same and creating shared functions ensures that (fixes "paste into visible area" not working with paste by context menu)
  2. Added copyMutatorId variable that tracks if last elements were copied from mutator workspace and its id. If this variable is present, then we try to find workspace by id and insert elements there
  3. Updated dataCopyToStorage to never save mutator blocks in the storage. Now nothing will be saved in the storage if you copy mutator blocks
  4. Fixed minor issue with cut/delete inconsistency. Cut shortcut was not deselecting destroyed elements
  5. Replaced if (selected instanceof MultiselectDraggable) else if (!dragSelection.size) check to a simple if (selected instanceof MultiselectDraggable) else. !dragSelection.size check was ignoring the fact that single block in dragSelection is not wrapped inside MultiselectDraggable
  6. Updated test helpers to support mutator workspaces and top/all block selectors (To be fair, I just copied code from [cd0718e](https://github.com/mit-cml/workspace-multiselect/commit/cd0718ee70c6e35ca57e85a6412e4123a2dadd85) by @mjgallag. Thanks for making it!)

Reason for Changes

  1. Shared function ensures consistency between behaviours. It won't be necessary to keep both contextmenu and shortcuts in sync. (Although I can revert this commit, if necessary)
  2. copyMutatorId variables allows copy/paste inside mutator blocks, a feature original Blockly supports. Also fixes the bug when mutator blocks can end up in the main workspace breaking code generation and possibly even deserialization
  3. Mutator blocks are never saved in the storage so they can't be pasted on page reload
  4. Cut shortcut now removes selection from deleted elements for consistency with delete shortcut
  5. Removing !dragSelection.size check aligns with multiselect logic - drag selection with size 1 is not wrapped in MultiselectDragging
  6. Test helpers update was required for mutator blocks testing

Test Coverage

  1. Added mutator.spec.ts file that tests mutators behaviour with copy/paste. Mutator blocks only support single selection, so file is inside select folder
  2. Added tests for multiselecting single block/comment and performing actions on them

Documentation

N/A

Additional Information

I did both issues in this pull request, because I've moved copy/paste logic and wanted to avoid merge conflicts. Hope that's not a problem!

@mjgallag mjgallag self-requested a review May 24, 2026 12:59
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.

Issues with copy/paste behaviour

1 participant