@@ -51,18 +51,19 @@ const fixCollapsedBlocks = () => {
51
51
}
52
52
}
53
53
54
- const cleanUpForBlockLoad = ( blocksToClean , dropEvent = { } ) => {
54
+ const cleanUpOnLoad = ( blocksToClean , dropEvent = { } ) => {
55
55
const { clientX, clientY } = dropEvent
56
- Blockly . Events . setGroup ( true )
57
56
const blocklyMetrics = Blockly . mainWorkspace . getMetrics ( )
58
57
const scaleCancellation = ( 1 / Blockly . mainWorkspace . scale )
59
58
const blocklyLeft = blocklyMetrics . absoluteLeft - blocklyMetrics . viewLeft
60
59
const blocklyTop = ( document . body . offsetHeight - blocklyMetrics . viewHeight ) - blocklyMetrics . viewTop
61
60
const cursorX = ( clientX ) ? ( clientX - blocklyLeft ) * scaleCancellation : 0
62
- const cursorY = ( clientY ) ? ( clientY - blocklyTop ) * scaleCancellation : 0
61
+ let cursorY = ( clientY ) ? ( clientY - blocklyTop ) * scaleCancellation : 0
62
+ Blockly . Events . setGroup ( true )
63
63
for ( const block of blocksToClean ) {
64
64
block . moveBy ( cursorX , cursorY )
65
65
block . snapToGrid ( )
66
+ cursorY += block . getHeightWidth ( ) . height + Blockly . BlockSvg . MIN_BLOCK_Y
66
67
}
67
68
Blockly . Events . setGroup ( false )
68
69
// Fire an event to allow scrollbars to resize.
@@ -210,7 +211,7 @@ export default class _Blockly {
210
211
for ( const block of Array . prototype . slice . call ( xml . children ) ) {
211
212
addedBlocks . push ( this . addDomBlocks ( block ) )
212
213
}
213
- cleanUpForBlockLoad ( addedBlocks , dropEvent )
214
+ cleanUpOnLoad ( addedBlocks , dropEvent )
214
215
this . blocksXmlStr = Blockly . Xml . domToPrettyText (
215
216
Blockly . Xml . workspaceToDom ( Blockly . mainWorkspace ) )
216
217
observer . emit ( 'ui.log.success' ,
0 commit comments