mirror of
https://github.com/google/blockly.git
synced 2026-01-11 02:47:09 +01:00
Forbid any ancestor of the block containing the marked connection from being moved to said connection.
This commit is contained in:
@@ -46,13 +46,20 @@ blocklyApp.ClipboardService = ng.core
|
||||
this.areConnectionsCompatible_(connection, nextConnection));
|
||||
},
|
||||
isMovableToMarkedConnection: function(block) {
|
||||
// It should not be possible to move a block to one of its own
|
||||
// connections.
|
||||
if (this.markedConnection_ &&
|
||||
this.markedConnection_.sourceBlock_.id == block.id) {
|
||||
// It should not be possible to move any ancestor of the block containing
|
||||
// the marked spot to the marked spot.
|
||||
if (!this.markedConnection_) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var markedSpotAncestorBlock = this.markedConnection_.getSourceBlock();
|
||||
while (markedSpotAncestorBlock) {
|
||||
if (markedSpotAncestorBlock.id == block.id) {
|
||||
return false;
|
||||
}
|
||||
markedSpotAncestorBlock = markedSpotAncestorBlock.getParent();
|
||||
}
|
||||
|
||||
return this.canBeCopiedToMarkedConnection(block);
|
||||
},
|
||||
canBeCopiedToMarkedConnection: function(block) {
|
||||
|
||||
Reference in New Issue
Block a user