mirror of
https://github.com/google/blockly.git
synced 2026-01-11 19:07:08 +01:00
Make colour optional in JSON. Add ;/n in generator stub.
This commit is contained in:
@@ -647,7 +647,7 @@ Blockly.Blocks['procedures_callnoreturn'] = {
|
||||
for (var i = 0; i < this.arguments_.length; i++) {
|
||||
if (Blockly.Names.equals(oldName, this.arguments_[i])) {
|
||||
this.arguments_[i] = newName;
|
||||
this.getInput('ARG' + i).fieldRow[0].setText(newName);
|
||||
this.getInput('ARG' + i).fieldRow[0].setValue(newName);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -929,7 +929,9 @@ Blockly.Block.prototype.jsonInit = function(json) {
|
||||
'Must not have both an output and a previousStatement.');
|
||||
|
||||
// Set basic properties of block.
|
||||
this.setColour(json['colour']);
|
||||
if (json['colour'] !== undefined) {
|
||||
this.setColour(json['colour']);
|
||||
}
|
||||
|
||||
// Interpolate the message blocks.
|
||||
var i = 0;
|
||||
|
||||
@@ -642,11 +642,8 @@ Blockly.Connection.prototype.setCheck = function(check) {
|
||||
this.check_ = check;
|
||||
// The new value type may not be compatible with the existing connection.
|
||||
if (this.targetConnection && !this.checkType_(this.targetConnection)) {
|
||||
if (this.isSuperior()) {
|
||||
this.targetBlock().setParent(null);
|
||||
} else {
|
||||
this.sourceBlock_.setParent(null);
|
||||
}
|
||||
var child = this.isSuperior() ? this.targetBlock() : this.sourceBlock_;
|
||||
child.setParent(null);
|
||||
// Bump away.
|
||||
this.sourceBlock_.bumpNeighbours_();
|
||||
}
|
||||
|
||||
@@ -576,12 +576,20 @@ function updateGenerator(block) {
|
||||
}
|
||||
}
|
||||
}
|
||||
// Most languages end lines with a semicolon. Python does not.
|
||||
var lineEnd = {
|
||||
'JavaScript': ';',
|
||||
'Python': '',
|
||||
'PHP': ';',
|
||||
'Dart': ';'
|
||||
};
|
||||
code.push(" // TODO: Assemble " + language + " into code variable.");
|
||||
code.push(" var code = \'...\';");
|
||||
if (block.outputConnection) {
|
||||
code.push(" var code = '...';");
|
||||
code.push(" // TODO: Change ORDER_NONE to the correct strength.");
|
||||
code.push(" return [code, Blockly." + language + ".ORDER_NONE];");
|
||||
} else {
|
||||
code.push(" var code = '..." + (lineEnd[language] || '') + "\\n';");
|
||||
code.push(" return code;");
|
||||
}
|
||||
code.push("};");
|
||||
|
||||
Reference in New Issue
Block a user