File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed
Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -101,6 +101,31 @@ Blockly.FieldExpandableAdd.prototype.init = function() {
101101 this . boxGroup_
102102 ) ;
103103 this . fieldGroup_ . insertBefore ( this . boxGroup_ , this . textElement_ ) ;
104+
105+ // since this field is typicall paired with expandable_remove, no need to paste this twice
106+ // inject utility code to source block
107+ this . sourceBlock_ . fillInBlock = function ( connection , type , optValue ) {
108+ const srcBlock = this . sourceBlock_ ;
109+ if ( connection . sourceBlock_ . isInsertionMarker_ ) return ;
110+
111+ Blockly . Events . disable ( ) ;
112+ const block = srcBlock . workspace . newBlock ( type ) ;
113+ try {
114+ if ( optValue ) block . setFieldValue ( optValue ) ;
115+ block . setShadow ( true ) ;
116+ if ( ! srcBlock . isInsertionMarker ( ) ) {
117+ block . initSvg ( ) ;
118+ block . render ( false ) ;
119+ }
120+ } finally {
121+ Blockly . Events . enable ( ) ;
122+ }
123+
124+ if ( Blockly . Events . isEnabled ( ) ) Blockly . Events . fire ( new Blockly . Events . BlockCreate ( block ) ) ;
125+ if ( block . outputConnection ) block . outputConnection . connect ( connection ) ;
126+ else block . previousConnection . connect ( connection ) ;
127+ return block ;
128+ }
104129} ;
105130
106131/**
You can’t perform that action at this time.
0 commit comments