-
Notifications
You must be signed in to change notification settings - Fork 3.8k
feat: add copy api and paste into correct workspace #9215
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -76,7 +76,7 @@ suite('Clipboard', function () { | |
| await mutatorIcon.setBubbleVisible(true); | ||
| const mutatorWorkspace = mutatorIcon.getWorkspace(); | ||
| const elseIf = mutatorWorkspace.getBlocksByType('controls_if_elseif')[0]; | ||
| assert.notEqual(elseIf, undefined); | ||
| assert.isDefined(elseIf); | ||
| assert.lengthOf(mutatorWorkspace.getAllBlocks(), 2); | ||
| assert.lengthOf(this.workspace.getAllBlocks(), 1); | ||
| const data = elseIf.toCopyData(); | ||
|
|
@@ -85,6 +85,34 @@ suite('Clipboard', function () { | |
| assert.lengthOf(this.workspace.getAllBlocks(), 1); | ||
| }); | ||
|
|
||
| test('pasting into a mutator flyout pastes into the mutator workspace', async function () { | ||
| const block = Blockly.serialization.blocks.append( | ||
| { | ||
| 'type': 'controls_if', | ||
| 'id': 'blockId', | ||
| 'extraState': { | ||
| 'elseIfCount': 1, | ||
| }, | ||
| }, | ||
| this.workspace, | ||
| ); | ||
| const mutatorIcon = block.getIcon(Blockly.icons.IconType.MUTATOR); | ||
| await mutatorIcon.setBubbleVisible(true); | ||
| const mutatorWorkspace = mutatorIcon.getWorkspace(); | ||
| const mutatorFlyoutWorkspace = mutatorWorkspace | ||
| .getFlyout() | ||
| .getWorkspace(); | ||
| const elseIf = | ||
| mutatorFlyoutWorkspace.getBlocksByType('controls_if_elseif')[0]; | ||
| assert.isDefined(elseIf); | ||
| assert.lengthOf(mutatorWorkspace.getAllBlocks(), 2); | ||
| assert.lengthOf(this.workspace.getAllBlocks(), 1); | ||
| const data = elseIf.toCopyData(); | ||
| Blockly.clipboard.paste(data, mutatorFlyoutWorkspace); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just to check: without the change in (Just performing a cursory double check that the test fails correctly).
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, I verified this test fails if I stashed my other changes. |
||
| assert.lengthOf(mutatorWorkspace.getAllBlocks(), 3); | ||
| assert.lengthOf(this.workspace.getAllBlocks(), 1); | ||
| }); | ||
|
|
||
| suite('pasted blocks are placed in unambiguous locations', function () { | ||
| test('pasted blocks are bumped to not overlap', function () { | ||
| const block = Blockly.serialization.blocks.append( | ||
|
|
@@ -139,8 +167,7 @@ suite('Clipboard', function () { | |
| }); | ||
|
|
||
| suite('pasting comments', function () { | ||
| // TODO: Reenable test when we readd copy-paste. | ||
| test.skip('pasted comments are bumped to not overlap', function () { | ||
| test('pasted comments are bumped to not overlap', function () { | ||
| Blockly.Xml.domToWorkspace( | ||
| Blockly.utils.xml.textToDom( | ||
| '<xml><comment id="test" x=10 y=10/></xml>', | ||
|
|
@@ -153,7 +180,7 @@ suite('Clipboard', function () { | |
| const newComment = Blockly.clipboard.paste(data, this.workspace); | ||
| assert.deepEqual( | ||
| newComment.getRelativeToSurfaceXY(), | ||
| new Blockly.utils.Coordinate(60, 60), | ||
| new Blockly.utils.Coordinate(40, 40), | ||
| ); | ||
| }); | ||
| }); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's great to see test-only API bits get removed. :)