When I drag the block to the workspace, the shadow block is not in the right place.
Thank you.
Blockly.Blocks.lists_create_with={
init:function(){
this.setHelpUrl(Blockly.Msg.LISTS_CREATE_WITH_HELPURL);
this.setStyle("list_blocks");
this.itemCount_=3;
this.updateShape_();
this.setOutput(!0,"Array");
this.setMutator(new Blockly.Mutator(["lists_create_with_item"]));
this.setTooltip(Blockly.Msg.LISTS_CREATE_WITH_TOOLTIP)
}
,mutationToDom:function(){
var a=Blockly.utils.xml.createElement("mutation");
a.setAttribute("items",this.itemCount_);
return a
}
,domToMutation:function(a){
this.itemCount_=parseInt(a.getAttribute("items"),10);
this.updateShape_()
}
,decompose:function(a){
var b=a.newBlock("lists_create_with_container");
b.initSvg();
for(var c=b.getInput("STACK").connection,d=0;d<this.itemCount_;d++){
var e=a.newBlock("lists_create_with_item");
e.initSvg();
c.connect(e.previousConnection);
c=e.nextConnection}
return b
}
,compose:function(a){
var b=a.getInputTargetBlock("STACK");
for(a=[];b&&!b.isInsertionMarker();)
a.push(b.valueConnection_),b=b.nextConnection&&b.nextConnection.targetBlock();
for(b=0;b<this.itemCount_;b++){
var c=this.getInput("ADD"+b).connection.targetConnection;
c&&-1==a.indexOf(c)&&c.disconnect()
}
this.itemCount_=a.length;
this.updateShape_();
for(b=0;b<this.itemCount_;b++)
Blockly.Mutator.reconnect(a[b],this,"ADD"+b)
}
,saveConnections:function(a){
a=a.getInputTargetBlock("STACK");
for(var b=0;a;){
var c=this.getInput("ADD"+b);
a.valueConnection_=c&&c.connection.targetConnection;
b++;
a=a.nextConnection&&a.nextConnection.targetBlock()
}
}
,updateShape_:function(){
this.itemCount_&&this.getInput("EMPTY")?this.removeInput("EMPTY"):this.itemCount_||this.getInput("EMPTY")||this.appendDummyInput("EMPTY").appendField(Blockly.Msg.LISTS_CREATE_EMPTY_TITLE,"TITLE");
for(var a=0;a<this.itemCount_;a++)
if(!this.getInput("ADD"+a)){
var b=this.appendValueInput("ADD"+a).setAlign(Blockly.ALIGN_RIGHT);
0==a&&b.appendField(Blockly.Msg.LISTS_CREATE_WITH_INPUT_WITH,"TITLE")
}
for(;this.getInput("ADD"+a);)
this.removeInput("ADD"+a),a++
}
,onchange: function(event) {
if (!this.workspace) {
// Block is deleted.
return;
}
if (!event.recordUndo) {
// Events not generated by user. Skip handling.
return;
}
if (this.mutator.block_.parentBlock_) {
if (this.mutator.block_.parentBlock_.type=="procedures_callnoreturn") {
this.getField("TITLE").setValue(Blockly.Msg["LISTS_CREATE_WITH_INPUT_WITH_PROCEDURE_VALUE"]);
this.getField("TITLE").isDirty_=true;
return;
}
else if (this.mutator.block_.parentBlock_.type=="procedures_callreturn") {
this.getField("TITLE").setValue(Blockly.Msg["LISTS_CREATE_WITH_INPUT_WITH_PROCEDURE_VALUE"]);
this.getField("TITLE").isDirty_=true;
return;
}
else if (this.mutator.block_.parentBlock_.type=="procedures_defnoreturn"||this.mutator.block_.parentBlock_.type=="procedures_defreturn") {
if (this.itemCount_) {
for (var i=0;i<this.itemCount_;i++) {
var targetBlock = this.getInputTargetBlock('ADD'+i);
if (targetBlock) {
if (targetBlock.type!="variables_set2") {
targetBlock.unplug();
}
}
}
}
this.getField("TITLE").setValue(Blockly.Msg.LISTS_CREATE_WITH_INPUT_WITH_PROCEDURE);
this.getField("TITLE").isDirty_=true;
//this.setInputsInline(!0);
return;
}
}
if (this.itemCount_) {
for (var i=0;i<this.itemCount_;i++) {
var targetBlock = this.getInputTargetBlock('ADD'+i);
if (targetBlock) {
if (targetBlock.type=="variables_set2") {
this.getField("TITLE").setValue(Blockly.Msg.LISTS_CREATE_WITH_INPUT_WITH_PROCEDURE);
this.getField("TITLE").isDirty_=true;
return;
}
}
}
this.getField("TITLE").setValue(Blockly.Msg.LISTS_CREATE_WITH_INPUT_WITH);
}
else
this.getField("TITLE").setValue(Blockly.Msg.LISTS_CREATE_EMPTY_TITLE);
this.getField("TITLE").isDirty_=true;
this.setInputsInline(0);
}
};