mirror of
https://github.com/google/blockly.git
synced 2026-01-07 17:10:11 +01:00
fix: remove parameter from wouldDelete (#7968)
This commit is contained in:
@@ -205,7 +205,7 @@ export class BlockDragger implements IBlockDragger {
|
|||||||
const block = this.draggingBlock_;
|
const block = this.draggingBlock_;
|
||||||
this.moveBlock(block, delta);
|
this.moveBlock(block, delta);
|
||||||
this.updateDragTargets(e, block);
|
this.updateDragTargets(e, block);
|
||||||
this.wouldDeleteBlock_ = this.wouldDeleteBlock(e, block, delta);
|
this.wouldDeleteBlock_ = this.wouldDeleteBlock(e, block);
|
||||||
this.updateCursorDuringBlockDrag_();
|
this.updateCursorDuringBlockDrag_();
|
||||||
this.updateConnectionPreview(block, delta);
|
this.updateConnectionPreview(block, delta);
|
||||||
}
|
}
|
||||||
@@ -237,14 +237,8 @@ export class BlockDragger implements IBlockDragger {
|
|||||||
*
|
*
|
||||||
* @param e The most recent move event.
|
* @param e The most recent move event.
|
||||||
* @param draggingBlock The block being dragged.
|
* @param draggingBlock The block being dragged.
|
||||||
* @param delta How far the pointer has moved from the position
|
|
||||||
* at the start of the drag, in pixel units.
|
|
||||||
*/
|
*/
|
||||||
private wouldDeleteBlock(
|
private wouldDeleteBlock(e: PointerEvent, draggingBlock: BlockSvg): boolean {
|
||||||
e: PointerEvent,
|
|
||||||
draggingBlock: BlockSvg,
|
|
||||||
delta: Coordinate,
|
|
||||||
): boolean {
|
|
||||||
const dragTarget = this.workspace_.getDragTarget(e);
|
const dragTarget = this.workspace_.getDragTarget(e);
|
||||||
if (!dragTarget) return false;
|
if (!dragTarget) return false;
|
||||||
|
|
||||||
@@ -255,10 +249,7 @@ export class BlockDragger implements IBlockDragger {
|
|||||||
);
|
);
|
||||||
if (!isDeleteArea) return false;
|
if (!isDeleteArea) return false;
|
||||||
|
|
||||||
return (dragTarget as IDeleteArea).wouldDelete(
|
return (dragTarget as IDeleteArea).wouldDelete(draggingBlock);
|
||||||
draggingBlock,
|
|
||||||
!!this.getConnectionCandidate(draggingBlock, delta),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ export class BubbleDragger {
|
|||||||
ComponentManager.Capability.DELETE_AREA,
|
ComponentManager.Capability.DELETE_AREA,
|
||||||
);
|
);
|
||||||
if (isDeleteArea) {
|
if (isDeleteArea) {
|
||||||
return (dragTarget as IDeleteArea).wouldDelete(this.bubble, false);
|
return (dragTarget as IDeleteArea).wouldDelete(this.bubble);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -47,8 +47,6 @@ export const config: Config = {
|
|||||||
/**
|
/**
|
||||||
* Maximum misalignment between connections for them to snap together.
|
* Maximum misalignment between connections for them to snap together.
|
||||||
* This should be the same as the snap radius.
|
* This should be the same as the snap radius.
|
||||||
*
|
|
||||||
* @deprecated v11 - This is no longer used. Use snapRadius instead.
|
|
||||||
*/
|
*/
|
||||||
connectingSnapRadius: DEFAULT_SNAP_RADIUS,
|
connectingSnapRadius: DEFAULT_SNAP_RADIUS,
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -51,15 +51,14 @@ export class DeleteArea extends DragTarget implements IDeleteArea {
|
|||||||
* before onDragEnter/onDragOver/onDragExit.
|
* before onDragEnter/onDragOver/onDragExit.
|
||||||
*
|
*
|
||||||
* @param element The block or bubble currently being dragged.
|
* @param element The block or bubble currently being dragged.
|
||||||
* @param couldConnect Whether the element could could connect to another.
|
|
||||||
* @returns Whether the element provided would be deleted if dropped on this
|
* @returns Whether the element provided would be deleted if dropped on this
|
||||||
* area.
|
* area.
|
||||||
*/
|
*/
|
||||||
wouldDelete(element: IDraggable, couldConnect: boolean): boolean {
|
wouldDelete(element: IDraggable): boolean {
|
||||||
if (element instanceof BlockSvg) {
|
if (element instanceof BlockSvg) {
|
||||||
const block = element;
|
const block = element;
|
||||||
const couldDeleteBlock = !block.getParent() && block.isDeletable();
|
const couldDeleteBlock = !block.getParent() && block.isDeletable();
|
||||||
this.updateWouldDelete_(couldDeleteBlock && !couldConnect);
|
this.updateWouldDelete_(couldDeleteBlock);
|
||||||
} else {
|
} else {
|
||||||
this.updateWouldDelete_(element.isDeletable());
|
this.updateWouldDelete_(element.isDeletable());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -88,11 +88,7 @@ export class Dragger implements IDragger {
|
|||||||
);
|
);
|
||||||
if (!isDeleteArea) return false;
|
if (!isDeleteArea) return false;
|
||||||
|
|
||||||
return (dragTarget as IDeleteArea).wouldDelete(
|
return (dragTarget as IDeleteArea).wouldDelete(draggable);
|
||||||
draggable,
|
|
||||||
false,
|
|
||||||
// !!this.getConnectionCandidate(draggable, delta),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Handles any drag cleanup. */
|
/** Handles any drag cleanup. */
|
||||||
|
|||||||
@@ -384,10 +384,7 @@ export class InsertionMarkerManager {
|
|||||||
ComponentManager.Capability.DELETE_AREA,
|
ComponentManager.Capability.DELETE_AREA,
|
||||||
);
|
);
|
||||||
if (isDeleteArea) {
|
if (isDeleteArea) {
|
||||||
return (dragTarget as IDeleteArea).wouldDelete(
|
return (dragTarget as IDeleteArea).wouldDelete(this.topBlock);
|
||||||
this.topBlock,
|
|
||||||
newCandidate,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -21,9 +21,8 @@ export interface IDeleteArea extends IDragTarget {
|
|||||||
* before onDragEnter/onDragOver/onDragExit.
|
* before onDragEnter/onDragOver/onDragExit.
|
||||||
*
|
*
|
||||||
* @param element The block or bubble currently being dragged.
|
* @param element The block or bubble currently being dragged.
|
||||||
* @param couldConnect Whether the element could could connect to another.
|
|
||||||
* @returns Whether the element provided would be deleted if dropped on this
|
* @returns Whether the element provided would be deleted if dropped on this
|
||||||
* area.
|
* area.
|
||||||
*/
|
*/
|
||||||
wouldDelete(element: IDraggable, couldConnect: boolean): boolean;
|
wouldDelete(element: IDraggable): boolean;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -532,14 +532,12 @@ export class Toolbox
|
|||||||
* before onDragEnter/onDragOver/onDragExit.
|
* before onDragEnter/onDragOver/onDragExit.
|
||||||
*
|
*
|
||||||
* @param element The block or bubble currently being dragged.
|
* @param element The block or bubble currently being dragged.
|
||||||
* @param _couldConnect Whether the element could could connect to another.
|
|
||||||
* @returns Whether the element provided would be deleted if dropped on this
|
* @returns Whether the element provided would be deleted if dropped on this
|
||||||
* area.
|
* area.
|
||||||
*/
|
*/
|
||||||
override wouldDelete(element: IDraggable, _couldConnect: boolean): boolean {
|
override wouldDelete(element: IDraggable): boolean {
|
||||||
if (element instanceof BlockSvg) {
|
if (element instanceof BlockSvg) {
|
||||||
const block = element;
|
const block = element;
|
||||||
// Prefer dragging to the toolbox over connecting to other blocks.
|
|
||||||
this.updateWouldDelete_(!block.getParent() && block.isDeletable());
|
this.updateWouldDelete_(!block.getParent() && block.isDeletable());
|
||||||
} else {
|
} else {
|
||||||
this.updateWouldDelete_(element.isDeletable());
|
this.updateWouldDelete_(element.isDeletable());
|
||||||
|
|||||||
Reference in New Issue
Block a user