* Unplug this block's output from an input on another block. Optionally * reconnect the block's parent to the only child block, if possible. * * @param opt_healStack Disconnect right-side block and connect to left-side * block. Defaults to false.
(opt_healStack?: boolean)
| 417 | * block. Defaults to false. |
| 418 | */ |
| 419 | private unplugFromRow(opt_healStack?: boolean) { |
| 420 | let parentConnection = null; |
| 421 | if (this.outputConnection?.isConnected()) { |
| 422 | parentConnection = this.outputConnection.targetConnection; |
| 423 | // Disconnect from any superior block. |
| 424 | this.outputConnection.disconnect(); |
| 425 | } |
| 426 | |
| 427 | // Return early in obvious cases. |
| 428 | if (!parentConnection || !opt_healStack) { |
| 429 | return; |
| 430 | } |
| 431 | |
| 432 | const thisConnection = this.getOnlyValueConnection(); |
| 433 | if ( |
| 434 | !thisConnection || |
| 435 | !thisConnection.isConnected() || |
| 436 | thisConnection.targetBlock()!.isShadow() |
| 437 | ) { |
| 438 | // Too many or too few possible connections on this block, or there's |
| 439 | // nothing on the other side of this connection. |
| 440 | return; |
| 441 | } |
| 442 | |
| 443 | const childConnection = thisConnection.targetConnection; |
| 444 | // Disconnect the child block. |
| 445 | childConnection?.disconnect(); |
| 446 | // Connect child to the parent if possible, otherwise bump away. |
| 447 | if ( |
| 448 | this.workspace.connectionChecker.canConnect( |
| 449 | childConnection, |
| 450 | parentConnection, |
| 451 | false, |
| 452 | ) |
| 453 | ) { |
| 454 | parentConnection.connect(childConnection!); |
| 455 | } else { |
| 456 | childConnection?.onFailedConnect(parentConnection); |
| 457 | } |
| 458 | } |
| 459 | |
| 460 | /** |
| 461 | * Returns the connection on the value input that is connected to another |
no test coverage detected