@blockly/block-dynamic-connection
A group of Blockly blocks that add and remove connections dynamically.
Installation
npm install @blockly/block-dynamic-connection --save
Usage
import * as Blockly from 'blockly';
import * as BlockDynamicConnection from '@blockly/block-dynamic-connection';
const myWorkspace = Blockly.inject({
// options...
plugins: {
connectionPreviewer:
BlockDynamicConnection.decoratePreviewer(
// Replace with a custom connection previewer, or remove to decorate
// the default one.
Blockly.InsertionMarkerPreviewer,
),
},
};
// Add the change listener so connections will be finalized on deletion.
workspace.addChangeListener(BlockDynamicConnection.finalizeConnections);
API
overrideOldBlockDefinitions: Replaces the Blockly default blocks with the dynamic connection blocks. This enables projects to use the dynamic block plugin without changing existing XML/JSON.
Blocks
dynamic_text_joinreplacestext_joindynamic_list_createreplaceslists_create_withdynamic_ifreplacescontrols_if
License
Apache 2.0
A group of blocks that add connections dynamically.
Functions
| Function | Description |
|---|---|
| blockIsDynamic | A type guard that checks if the given block fulfills the DynamicBlock interface. |
| decoratePreviewer | Returns a connection previewer constructor that decorates the passed constructor to add connection previewing. |
| finalizeConnections | Finalizes connections when certain events (such as block deletion) are detected. |
| overrideOldBlockDefinitions | - |