diff --git a/core/block_dragger.ts b/core/block_dragger.ts index 8d57344ea2e..972c5fa2bea 100644 --- a/core/block_dragger.ts +++ b/core/block_dragger.ts @@ -71,8 +71,18 @@ export class BlockDragger implements IBlockDragger { /** Whether the block would be deleted if dropped immediately. */ protected wouldDeleteBlock_ = false; + protected startXY_: Coordinate; + /** The parent block at the start of the drag. */ + private startParentConn: RenderedConnection | null = null; + + /** + * The child block at the start of the drag. Only gets set if + * `healStack` is true. + */ + private startChildConn: RenderedConnection | null = null; + /** * @deprecated To be removed in v11. Updating icons is now handled by the * block's `moveDuringDrag` method. @@ -137,6 +147,13 @@ export class BlockDragger implements IBlockDragger { blockAnimation.disconnectUiStop(); if (this.shouldDisconnect_(healStack)) { + this.startParentConn = + this.draggingBlock_.outputConnection?.targetConnection ?? + this.draggingBlock_.previousConnection?.targetConnection; + if (healStack) { + this.startChildConn = + this.draggingBlock_.nextConnection?.targetConnection; + } this.disconnectBlock_(healStack, currentDragDeltaXY); } this.draggingBlock_.setDragging(true); @@ -424,17 +441,10 @@ export class BlockDragger implements IBlockDragger { .getLayerManager() ?.moveOffDragLayer(this.draggingBlock_, layers.BLOCK); this.draggingBlock_.setDragging(false); - if (delta) { - // !preventMove + if (preventMove) { + this.moveToOriginalPosition(); + } else if (delta) { this.updateBlockAfterMove_(); - } else { - // Blocks dragged directly from a flyout may need to be bumped into - // bounds. - bumpObjects.bumpIntoBounds( - this.draggingBlock_.workspace, - this.workspace_.getMetricsManager().getScrollMetrics(true), - this.draggingBlock_, - ); } } // Must dispose after `updateBlockAfterMove_` is called to not break the @@ -445,6 +455,32 @@ export class BlockDragger implements IBlockDragger { eventUtils.setGroup(false); } + /** + * Moves the dragged block back to its original position before the start of + * the drag. Reconnects any parent and child blocks. + */ + private moveToOriginalPosition() { + this.startChildConn?.connect(this.draggingBlock_.nextConnection); + if (this.startParentConn) { + switch (this.startParentConn.type) { + case ConnectionType.INPUT_VALUE: + this.startParentConn.connect(this.draggingBlock_.outputConnection); + break; + case ConnectionType.NEXT_STATEMENT: + this.startParentConn.connect(this.draggingBlock_.previousConnection); + } + } else { + this.draggingBlock_.moveTo(this.startXY_, ['drag']); + // Blocks dragged directly from a flyout may need to be bumped into + // bounds. + bumpObjects.bumpIntoBounds( + this.draggingBlock_.workspace, + this.workspace_.getMetricsManager().getScrollMetrics(true), + this.draggingBlock_, + ); + } + } + /** * Calculates the drag delta and new location values after a block is dragged. * diff --git a/core/connection_previewers/insertion_marker_previewer.ts b/core/connection_previewers/insertion_marker_previewer.ts index 414d8dfe7da..3038502287d 100644 --- a/core/connection_previewers/insertion_marker_previewer.ts +++ b/core/connection_previewers/insertion_marker_previewer.ts @@ -158,6 +158,7 @@ export class InsertionMarkerPreviewer implements IConnectionPreviewer { private createInsertionMarker(origBlock: BlockSvg) { const result = this.workspace.newBlock(origBlock.type); result.setInsertionMarker(true); + result.setInputsInline(origBlock.getInputsInline()); if (origBlock.saveExtraState) { const state = origBlock.saveExtraState(true); if (state && result.loadExtraState) { diff --git a/core/trashcan.ts b/core/trashcan.ts index 42c32ea1f34..b253a6f320d 100644 --- a/core/trashcan.ts +++ b/core/trashcan.ts @@ -736,10 +736,10 @@ const ANIMATION_LENGTH = 80; const ANIMATION_FRAMES = 4; /** The minimum (resting) opacity of the trashcan and lid. */ -const OPACITY_MIN = 0.4; +const OPACITY_MIN = 1.0; /** The maximum (hovered) opacity of the trashcan and lid. */ -const OPACITY_MAX = 0.8; +const OPACITY_MAX = 1.0; /** * The maximum angle the trashcan lid can opens to. At the end of the open diff --git a/media/sprites.png b/media/sprites.png index 20aadb6c4c3..18f844bdfdc 100644 Binary files a/media/sprites.png and b/media/sprites.png differ diff --git a/media/sprites.svg b/media/sprites.svg index 3f09ef3a4d6..aa78ff742ea 100644 --- a/media/sprites.svg +++ b/media/sprites.svg @@ -18,16 +18,16 @@ text-anchor: middle; } .trash { - fill: #888; + fill: #000; } .zoom { fill: none; - stroke: #888; + stroke: #000; stroke-width: 2; stroke-linecap: round; } .zoom>.center { - fill: #888; + fill: #000; stroke-width: 0; } diff --git a/package.json b/package.json index a7ac581f02d..d0f30e3f48d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "blockly", - "version": "10.4.3", + "version": "10.5.0-beta.1", "description": "Blockly is a library for building visual programming editors.", "keywords": [ "blockly"