mirror of
https://github.com/google/blockly.git
synced 2026-01-11 10:57:07 +01:00
Merge branch 'develop' into goog.module-prep
This resolves a conflict in `blockly_uncompressed.js`, and missing updates to `test/deps.js`, caused by PR #5041.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
*_compressed*.js
|
||||
gulpfile.js
|
||||
/msg/*
|
||||
/build/*
|
||||
/dist/*
|
||||
/core/utils/global.js
|
||||
/tests/blocks/*
|
||||
|
||||
@@ -742,25 +742,33 @@ Blockly.Block.prototype.getChildren = function(ordered) {
|
||||
* @package
|
||||
*/
|
||||
Blockly.Block.prototype.setParent = function(newParent) {
|
||||
if (newParent == this.parentBlock_) {
|
||||
if (newParent === this.parentBlock_) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check that block is connected to new parent if new parent is not null and
|
||||
// that block is not connected to superior one if new parent is null.
|
||||
var connection = this.previousConnection || this.outputConnection;
|
||||
var isConnected = !!(connection && connection.targetBlock());
|
||||
|
||||
if (isConnected && newParent && connection.targetBlock() !== newParent) {
|
||||
throw Error('Block connected to superior one that is not new parent.');
|
||||
} else if (!isConnected && newParent) {
|
||||
throw Error('Block not connected to new parent.');
|
||||
} else if (isConnected && !newParent) {
|
||||
throw Error('Cannot set parent to null while block is still connected to' +
|
||||
' superior block.');
|
||||
}
|
||||
|
||||
if (this.parentBlock_) {
|
||||
// Remove this block from the old parent's child list.
|
||||
Blockly.utils.arrayRemove(this.parentBlock_.childBlocks_, this);
|
||||
|
||||
// Disconnect from superior blocks.
|
||||
if (this.previousConnection && this.previousConnection.isConnected()) {
|
||||
throw Error('Still connected to previous block.');
|
||||
}
|
||||
if (this.outputConnection && this.outputConnection.isConnected()) {
|
||||
throw Error('Still connected to parent block.');
|
||||
}
|
||||
this.parentBlock_ = null;
|
||||
// This block hasn't actually moved on-screen, so there's no need to update
|
||||
// its connection locations.
|
||||
// its connection locations.
|
||||
} else {
|
||||
// Remove this block from the workspace's list of top-most blocks.
|
||||
// New parent must be non-null so remove this block from the workspace's
|
||||
// list of top-most blocks.
|
||||
this.workspace.removeTopBlock(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -159,7 +159,7 @@ Blockly.BlockDragSurfaceSvg.prototype.translateSurfaceInternal_ = function() {
|
||||
this.SVG_.style.display = 'block';
|
||||
|
||||
Blockly.utils.dom.setCssTransform(
|
||||
this.SVG_, 'translate3d(' + x + 'px, ' + y + 'px, 0px)');
|
||||
this.SVG_, 'translate3d(' + x + 'px, ' + y + 'px, 0)');
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -55,6 +55,7 @@ goog.requireType('Blockly.WorkspaceSvg');
|
||||
* the individual field's documentation for a list of properties this
|
||||
* parameter supports.
|
||||
* @constructor
|
||||
* @abstract
|
||||
* @implements {Blockly.IASTNodeLocationSvg}
|
||||
* @implements {Blockly.IASTNodeLocationWithBlock}
|
||||
* @implements {Blockly.IKeyboardAccessible}
|
||||
@@ -276,7 +277,7 @@ Blockly.Field.prototype.configure_ = function(config) {
|
||||
*/
|
||||
Blockly.Field.prototype.setSourceBlock = function(block) {
|
||||
if (this.sourceBlock_) {
|
||||
throw Error('Field already bound to a block.');
|
||||
throw Error('Field already bound to a block');
|
||||
}
|
||||
this.sourceBlock_ = block;
|
||||
};
|
||||
|
||||
@@ -135,7 +135,9 @@ Blockly.FieldAngle.prototype.DEFAULT_VALUE = 0;
|
||||
* @nocollapse
|
||||
*/
|
||||
Blockly.FieldAngle.fromJson = function(options) {
|
||||
return new Blockly.FieldAngle(options['angle'], undefined, options);
|
||||
// `this` might be a subclass of FieldAngle if that class doesn't override
|
||||
// the static fromJson method.
|
||||
return new this(options['angle'], undefined, options);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -63,7 +63,9 @@ Blockly.FieldCheckbox.prototype.DEFAULT_VALUE = false;
|
||||
* @nocollapse
|
||||
*/
|
||||
Blockly.FieldCheckbox.fromJson = function(options) {
|
||||
return new Blockly.FieldCheckbox(options['checked'], undefined, options);
|
||||
// `this` might be a subclass of FieldCheckbox if that class doesn't override
|
||||
// the static fromJson method.
|
||||
return new this(options['checked'], undefined, options);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -104,7 +104,9 @@ Blockly.utils.object.inherits(Blockly.FieldColour, Blockly.Field);
|
||||
* @nocollapse
|
||||
*/
|
||||
Blockly.FieldColour.fromJson = function(options) {
|
||||
return new Blockly.FieldColour(options['colour'], undefined, options);
|
||||
// `this` might be a subclass of FieldColour if that class doesn't override
|
||||
// the static fromJson method.
|
||||
return new this(options['colour'], undefined, options);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -149,7 +149,9 @@ Blockly.FieldDropdown.ImageProperties;
|
||||
* @nocollapse
|
||||
*/
|
||||
Blockly.FieldDropdown.fromJson = function(options) {
|
||||
return new Blockly.FieldDropdown(options['options'], undefined, options);
|
||||
// `this` might be a subclass of FieldDropdown if that class doesn't override
|
||||
// the static fromJson method.
|
||||
return new this(options['options'], undefined, options);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -132,8 +132,9 @@ Blockly.FieldImage.prototype.DEFAULT_VALUE = '';
|
||||
* @nocollapse
|
||||
*/
|
||||
Blockly.FieldImage.fromJson = function(options) {
|
||||
return new Blockly.FieldImage(
|
||||
options['src'], options['width'], options['height'],
|
||||
// `this` might be a subclass of FieldImage if that class doesn't override
|
||||
// the static fromJson method.
|
||||
return new this(options['src'], options['width'], options['height'],
|
||||
undefined, undefined, undefined, options);
|
||||
};
|
||||
|
||||
|
||||
@@ -65,7 +65,9 @@ Blockly.FieldLabel.prototype.DEFAULT_VALUE = '';
|
||||
*/
|
||||
Blockly.FieldLabel.fromJson = function(options) {
|
||||
var text = Blockly.utils.replaceMessageReferences(options['text']);
|
||||
return new Blockly.FieldLabel(text, undefined, options);
|
||||
// `this` might be a subclass of FieldLabel if that class doesn't override
|
||||
// the static fromJson method.
|
||||
return new this(text, undefined, options);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -48,7 +48,9 @@ Blockly.utils.object.inherits(Blockly.FieldLabelSerializable,
|
||||
*/
|
||||
Blockly.FieldLabelSerializable.fromJson = function(options) {
|
||||
var text = Blockly.utils.replaceMessageReferences(options['text']);
|
||||
return new Blockly.FieldLabelSerializable(text, undefined, options);
|
||||
// `this` might be a subclass of FieldLabelSerializable if that class doesn't
|
||||
// override the static fromJson method.
|
||||
return new this(text, undefined, options);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -89,7 +89,9 @@ Blockly.FieldMultilineInput.prototype.configure_ = function(config) {
|
||||
*/
|
||||
Blockly.FieldMultilineInput.fromJson = function(options) {
|
||||
var text = Blockly.utils.replaceMessageReferences(options['text']);
|
||||
return new Blockly.FieldMultilineInput(text, undefined, options);
|
||||
// `this` might be a subclass of FieldMultilineInput if that class doesn't
|
||||
// override the static fromJson method.
|
||||
return new this(text, undefined, options);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -91,7 +91,9 @@ Blockly.FieldNumber.prototype.DEFAULT_VALUE = 0;
|
||||
* @nocollapse
|
||||
*/
|
||||
Blockly.FieldNumber.fromJson = function(options) {
|
||||
return new Blockly.FieldNumber(options['value'],
|
||||
// `this` might be a subclass of FieldNumber if that class doesn't override
|
||||
// the static fromJson method.
|
||||
return new this(options['value'],
|
||||
undefined, undefined, undefined, undefined, options);
|
||||
};
|
||||
|
||||
|
||||
@@ -110,7 +110,9 @@ Blockly.FieldTextInput.prototype.DEFAULT_VALUE = '';
|
||||
*/
|
||||
Blockly.FieldTextInput.fromJson = function(options) {
|
||||
var text = Blockly.utils.replaceMessageReferences(options['text']);
|
||||
return new Blockly.FieldTextInput(text, undefined, options);
|
||||
// `this` might be a subclass of FieldTextInput if that class doesn't override
|
||||
// the static fromJson method.
|
||||
return new this(text, undefined, options);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -340,6 +342,7 @@ Blockly.FieldTextInput.prototype.showInlineEditor_ = function(quietInput) {
|
||||
* @protected
|
||||
*/
|
||||
Blockly.FieldTextInput.prototype.widgetCreate_ = function() {
|
||||
Blockly.Events.setGroup(true);
|
||||
var div = Blockly.WidgetDiv.DIV;
|
||||
|
||||
Blockly.utils.dom.addClass(this.getClickTarget_(), 'editing');
|
||||
@@ -368,8 +371,8 @@ Blockly.FieldTextInput.prototype.widgetCreate_ = function() {
|
||||
div.style.borderRadius = borderRadius;
|
||||
div.style.transition = 'box-shadow 0.25s ease 0s';
|
||||
if (this.getConstants().FIELD_TEXTINPUT_BOX_SHADOW) {
|
||||
div.style.boxShadow = 'rgba(255, 255, 255, 0.3) 0px 0px 0px ' +
|
||||
4 * scale + 'px';
|
||||
div.style.boxShadow = 'rgba(255, 255, 255, 0.3) 0 0 0 ' +
|
||||
(4 * scale) + 'px';
|
||||
}
|
||||
}
|
||||
htmlInput.style.borderRadius = borderRadius;
|
||||
@@ -402,6 +405,7 @@ Blockly.FieldTextInput.prototype.widgetDispose_ = function() {
|
||||
if (this.onFinishEditing_) {
|
||||
this.onFinishEditing_(this.value_);
|
||||
}
|
||||
Blockly.Events.setGroup(false);
|
||||
|
||||
// Actual disposal.
|
||||
this.unbindInputEvents_();
|
||||
@@ -477,15 +481,10 @@ Blockly.FieldTextInput.prototype.onHtmlInputChange_ = function(_e) {
|
||||
if (text !== this.htmlInput_.oldValue_) {
|
||||
this.htmlInput_.oldValue_ = text;
|
||||
|
||||
// TODO(#2169): Once issue is fixed the setGroup functionality could be
|
||||
// moved up to the Field setValue method. This would create a
|
||||
// broader fix for all field types.
|
||||
Blockly.Events.setGroup(true);
|
||||
var value = this.getValueFromEditorText_(text);
|
||||
this.setValue(value);
|
||||
this.forceRerender();
|
||||
this.resizeEditor_();
|
||||
Blockly.Events.setGroup(false);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -100,8 +100,9 @@ Blockly.utils.object.inherits(Blockly.FieldVariable, Blockly.FieldDropdown);
|
||||
*/
|
||||
Blockly.FieldVariable.fromJson = function(options) {
|
||||
var varName = Blockly.utils.replaceMessageReferences(options['variable']);
|
||||
return new Blockly.FieldVariable(
|
||||
varName, undefined, undefined, undefined, options);
|
||||
// `this` might be a subclass of FieldVariable if that class doesn't override
|
||||
// the static fromJson method.
|
||||
return new this(varName, undefined, undefined, undefined, options);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -343,6 +343,10 @@ Blockly.HorizontalFlyout.prototype.reflowInternal_ = function() {
|
||||
for (var i = 0, block; (block = blocks[i]); i++) {
|
||||
flyoutHeight = Math.max(flyoutHeight, block.getHeightWidth().height);
|
||||
}
|
||||
var buttons = this.buttons_;
|
||||
for (var i = 0, button; (button = buttons[i]); i++) {
|
||||
flyoutHeight = Math.max(flyoutHeight, button.height);
|
||||
}
|
||||
flyoutHeight += this.MARGIN * 1.5;
|
||||
flyoutHeight *= this.workspace_.scale;
|
||||
flyoutHeight += Blockly.Scrollbar.scrollbarThickness;
|
||||
|
||||
@@ -82,8 +82,3 @@ goog.require('Blockly.zelos.Renderer');
|
||||
// Blockly Themes.
|
||||
// Classic is the default theme.
|
||||
goog.require('Blockly.Themes.Classic');
|
||||
goog.require('Blockly.Themes.Dark');
|
||||
goog.require('Blockly.Themes.Deuteranopia');
|
||||
goog.require('Blockly.Themes.HighContrast');
|
||||
goog.require('Blockly.Themes.Tritanopia');
|
||||
// goog.require('Blockly.Themes.Modern');
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2019 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* @fileoverview Dark theme.
|
||||
* @author samelh@google.com (Sam El-Husseini)
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
goog.provide('Blockly.Themes.Dark');
|
||||
|
||||
goog.require('Blockly.Theme');
|
||||
|
||||
Blockly.Themes.Dark = Blockly.Theme.defineTheme('dark', {
|
||||
'base': Blockly.Themes.Classic,
|
||||
'componentStyles': {
|
||||
'workspaceBackgroundColour': '#1e1e1e',
|
||||
'toolboxBackgroundColour': 'blackBackground',
|
||||
'toolboxForegroundColour': '#fff',
|
||||
'flyoutBackgroundColour': '#252526',
|
||||
'flyoutForegroundColour': '#ccc',
|
||||
'flyoutOpacity': 1,
|
||||
'scrollbarColour': '#797979',
|
||||
'insertionMarkerColour': '#fff',
|
||||
'insertionMarkerOpacity': 0.3,
|
||||
'scrollbarOpacity': 0.4,
|
||||
'cursorColour': '#d0d0d0',
|
||||
'blackBackground': '#333'
|
||||
}
|
||||
});
|
||||
@@ -1,104 +0,0 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2019 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* @fileoverview Deuteranopia theme.
|
||||
* A colour palette for people that have deuteranopia (the inability to perceive
|
||||
* green light). This can also be used for people that have protanopia (the
|
||||
* inability to perceive red light).
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
goog.provide('Blockly.Themes.Deuteranopia');
|
||||
|
||||
goog.require('Blockly.Theme');
|
||||
|
||||
|
||||
// Temporary holding object.
|
||||
Blockly.Themes.Deuteranopia = {};
|
||||
|
||||
Blockly.Themes.Deuteranopia.defaultBlockStyles = {
|
||||
"colour_blocks": {
|
||||
"colourPrimary": "#f2a72c",
|
||||
"colourSecondary": "#f1c172",
|
||||
"colourTertiary": "#da921c"
|
||||
},
|
||||
"list_blocks": {
|
||||
"colourPrimary": "#7d65ab",
|
||||
"colourSecondary": "#a88be0",
|
||||
"colourTertiary": "#66518e"
|
||||
},
|
||||
"logic_blocks": {
|
||||
"colourPrimary": "#9fd2f1",
|
||||
"colourSecondary": "#c0e0f4",
|
||||
"colourTertiary": "#74bae5"
|
||||
},
|
||||
"loop_blocks": {
|
||||
"colourPrimary": "#795a07",
|
||||
"colourSecondary": "#ac8726",
|
||||
"colourTertiary": "#c4a03f"
|
||||
},
|
||||
"math_blocks": {
|
||||
"colourPrimary": "#e6da39",
|
||||
"colourSecondary": "#f3ec8e",
|
||||
"colourTertiary": "#f2eeb7"
|
||||
},
|
||||
"procedure_blocks": {
|
||||
"colourPrimary": "#590721",
|
||||
"colourSecondary": "#8c475d",
|
||||
"colourTertiary": "#885464"
|
||||
},
|
||||
"text_blocks": {
|
||||
"colourPrimary": "#058863",
|
||||
"colourSecondary": "#5ecfaf",
|
||||
"colourTertiary": "#04684c"
|
||||
},
|
||||
"variable_blocks": {
|
||||
"colourPrimary": "#47025a",
|
||||
"colourSecondary": "#820fa1",
|
||||
"colourTertiary": "#8e579d"
|
||||
},
|
||||
"variable_dynamic_blocks": {
|
||||
"colourPrimary": "#47025a",
|
||||
"colourSecondary": "#820fa1",
|
||||
"colourTertiary": "#8e579d"
|
||||
}
|
||||
};
|
||||
|
||||
Blockly.Themes.Deuteranopia.categoryStyles = {
|
||||
"colour_category": {
|
||||
"colour": "#f2a72c"
|
||||
},
|
||||
"list_category": {
|
||||
"colour": "#7d65ab"
|
||||
},
|
||||
"logic_category": {
|
||||
"colour": "#9fd2f1"
|
||||
},
|
||||
"loop_category": {
|
||||
"colour": "#795a07"
|
||||
},
|
||||
"math_category": {
|
||||
"colour": "#e6da39"
|
||||
},
|
||||
"procedure_category": {
|
||||
"colour": "#590721"
|
||||
},
|
||||
"text_category": {
|
||||
"colour": "#058863"
|
||||
},
|
||||
"variable_category": {
|
||||
"colour": "#47025a"
|
||||
},
|
||||
"variable_dynamic_category": {
|
||||
"colour": "#47025a"
|
||||
}
|
||||
};
|
||||
|
||||
Blockly.Themes.Deuteranopia =
|
||||
new Blockly.Theme('deuteranopia',
|
||||
Blockly.Themes.Deuteranopia.defaultBlockStyles,
|
||||
Blockly.Themes.Deuteranopia.categoryStyles);
|
||||
@@ -1,119 +0,0 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2018 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* @fileoverview High contrast theme.
|
||||
* Darker colours to contrast the white font.
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
goog.provide('Blockly.Themes.HighContrast');
|
||||
|
||||
goog.require('Blockly.Theme');
|
||||
|
||||
|
||||
// Temporary holding object.
|
||||
Blockly.Themes.HighContrast = {};
|
||||
|
||||
Blockly.Themes.HighContrast.defaultBlockStyles = {
|
||||
"colour_blocks": {
|
||||
"colourPrimary": "#a52714",
|
||||
"colourSecondary": "#FB9B8C",
|
||||
"colourTertiary": "#FBE1DD"
|
||||
},
|
||||
"list_blocks": {
|
||||
"colourPrimary": "#4a148c",
|
||||
"colourSecondary": "#AD7BE9",
|
||||
"colourTertiary": "#CDB6E9"
|
||||
},
|
||||
"logic_blocks": {
|
||||
"colourPrimary": "#01579b",
|
||||
"colourSecondary": "#64C7FF",
|
||||
"colourTertiary": "#C5EAFF"
|
||||
},
|
||||
"loop_blocks": {
|
||||
"colourPrimary": "#33691e",
|
||||
"colourSecondary": "#9AFF78",
|
||||
"colourTertiary": "#E1FFD7"
|
||||
},
|
||||
"math_blocks": {
|
||||
"colourPrimary": "#1a237e",
|
||||
"colourSecondary": "#8A9EFF",
|
||||
"colourTertiary": "#DCE2FF"
|
||||
},
|
||||
"procedure_blocks": {
|
||||
"colourPrimary": "#006064",
|
||||
"colourSecondary": "#77E6EE",
|
||||
"colourTertiary": "#CFECEE"
|
||||
},
|
||||
"text_blocks": {
|
||||
"colourPrimary": "#004d40",
|
||||
"colourSecondary": "#5ae27c",
|
||||
"colourTertiary": "#D2FFDD"
|
||||
},
|
||||
"variable_blocks": {
|
||||
"colourPrimary": "#880e4f",
|
||||
"colourSecondary": "#FF73BE",
|
||||
"colourTertiary": "#FFD4EB"
|
||||
},
|
||||
"variable_dynamic_blocks": {
|
||||
"colourPrimary": "#880e4f",
|
||||
"colourSecondary": "#FF73BE",
|
||||
"colourTertiary": "#FFD4EB"
|
||||
},
|
||||
"hat_blocks": {
|
||||
"colourPrimary": "#880e4f",
|
||||
"colourSecondary": "#FF73BE",
|
||||
"colourTertiary": "#FFD4EB",
|
||||
"hat": "cap"
|
||||
}
|
||||
};
|
||||
|
||||
Blockly.Themes.HighContrast.categoryStyles = {
|
||||
"colour_category": {
|
||||
"colour": "#a52714"
|
||||
},
|
||||
"list_category": {
|
||||
"colour": "#4a148c"
|
||||
},
|
||||
"logic_category": {
|
||||
"colour": "#01579b"
|
||||
},
|
||||
"loop_category": {
|
||||
"colour": "#33691e"
|
||||
},
|
||||
"math_category": {
|
||||
"colour": "#1a237e"
|
||||
},
|
||||
"procedure_category": {
|
||||
"colour": "#006064"
|
||||
},
|
||||
"text_category": {
|
||||
"colour": "#004d40"
|
||||
},
|
||||
"variable_category": {
|
||||
"colour": "#880e4f"
|
||||
},
|
||||
"variable_dynamic_category": {
|
||||
"colour": "#880e4f"
|
||||
}
|
||||
};
|
||||
|
||||
// This style is still being fleshed out and may change.
|
||||
Blockly.Themes.HighContrast =
|
||||
new Blockly.Theme('highcontrast',
|
||||
Blockly.Themes.HighContrast.defaultBlockStyles,
|
||||
Blockly.Themes.HighContrast.categoryStyles);
|
||||
|
||||
Blockly.Themes.HighContrast.setComponentStyle('selectedGlowColour', '#000000');
|
||||
Blockly.Themes.HighContrast.setComponentStyle('selectedGlowSize', 1);
|
||||
Blockly.Themes.HighContrast.setComponentStyle('replacementGlowColour', '#000000');
|
||||
|
||||
Blockly.Themes.HighContrast.setFontStyle({
|
||||
'family': null, // Use default font-family.
|
||||
'weight': null, // Use default font-weight.
|
||||
'size': 16
|
||||
});
|
||||
@@ -1,108 +0,0 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2018 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* @fileoverview Modern theme.
|
||||
* Same colours as classic, but single coloured border.
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
goog.provide('Blockly.Themes.Modern');
|
||||
|
||||
goog.require('Blockly.Theme');
|
||||
|
||||
|
||||
// Temporary holding object.
|
||||
Blockly.Themes.Modern = {};
|
||||
|
||||
Blockly.Themes.Modern.defaultBlockStyles = {
|
||||
"colour_blocks": {
|
||||
"colourPrimary": "#a5745b",
|
||||
"colourSecondary": "#dbc7bd",
|
||||
"colourTertiary": "#845d49"
|
||||
},
|
||||
"list_blocks": {
|
||||
"colourPrimary": "#745ba5",
|
||||
"colourSecondary": "#c7bddb",
|
||||
"colourTertiary": "#5d4984"
|
||||
},
|
||||
"logic_blocks": {
|
||||
"colourPrimary": "#5b80a5",
|
||||
"colourSecondary": "#bdccdb",
|
||||
"colourTertiary": "#496684"
|
||||
},
|
||||
"loop_blocks": {
|
||||
"colourPrimary": "#5ba55b",
|
||||
"colourSecondary": "#bddbbd",
|
||||
"colourTertiary": "#498449"
|
||||
},
|
||||
"math_blocks": {
|
||||
"colourPrimary": "#5b67a5",
|
||||
"colourSecondary": "#bdc2db",
|
||||
"colourTertiary": "#495284"
|
||||
},
|
||||
"procedure_blocks": {
|
||||
"colourPrimary": "#995ba5",
|
||||
"colourSecondary": "#d6bddb",
|
||||
"colourTertiary": "#7a4984"
|
||||
},
|
||||
"text_blocks": {
|
||||
"colourPrimary": "#5ba58c",
|
||||
"colourSecondary": "#bddbd1",
|
||||
"colourTertiary": "#498470"
|
||||
},
|
||||
"variable_blocks": {
|
||||
"colourPrimary": "#a55b99",
|
||||
"colourSecondary": "#dbbdd6",
|
||||
"colourTertiary": "#84497a"
|
||||
},
|
||||
"variable_dynamic_blocks": {
|
||||
"colourPrimary": "#a55b99",
|
||||
"colourSecondary": "#dbbdd6",
|
||||
"colourTertiary": "#84497a"
|
||||
},
|
||||
"hat_blocks": {
|
||||
"colourPrimary": "#a55b99",
|
||||
"colourSecondary": "#dbbdd6",
|
||||
"colourTertiary": "#84497a",
|
||||
"hat": "cap"
|
||||
}
|
||||
};
|
||||
|
||||
Blockly.Themes.Modern.categoryStyles = {
|
||||
"colour_category": {
|
||||
"colour": "#a5745b"
|
||||
},
|
||||
"list_category": {
|
||||
"colour": "#745ba5"
|
||||
},
|
||||
"logic_category": {
|
||||
"colour": "#5b80a5"
|
||||
},
|
||||
"loop_category": {
|
||||
"colour": "#5ba55b"
|
||||
},
|
||||
"math_category": {
|
||||
"colour": "#5b67a5"
|
||||
},
|
||||
"procedure_category": {
|
||||
"colour": "#995ba5"
|
||||
},
|
||||
"text_category": {
|
||||
"colour": "#5ba58c"
|
||||
},
|
||||
"variable_category": {
|
||||
"colour": "#a55b99"
|
||||
},
|
||||
"variable_dynamic_category": {
|
||||
"colour": "#a55b99"
|
||||
}
|
||||
};
|
||||
|
||||
// This style is still being fleshed out and may change.
|
||||
Blockly.Themes.Modern =
|
||||
new Blockly.Theme('modern', Blockly.Themes.Modern.defaultBlockStyles,
|
||||
Blockly.Themes.Modern.categoryStyles);
|
||||
@@ -1,103 +0,0 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2019 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* @fileoverview Tritanopia theme.
|
||||
* A colour palette for people that have tritanopia (the inability to perceive
|
||||
* blue light).
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
goog.provide('Blockly.Themes.Tritanopia');
|
||||
|
||||
goog.require('Blockly.Theme');
|
||||
|
||||
|
||||
// Temporary holding object.
|
||||
Blockly.Themes.Tritanopia = {};
|
||||
|
||||
Blockly.Themes.Tritanopia.defaultBlockStyles = {
|
||||
"colour_blocks": {
|
||||
"colourPrimary": "#05427f",
|
||||
"colourSecondary": "#2974c0",
|
||||
"colourTertiary": "#2d74bb"
|
||||
},
|
||||
"list_blocks": {
|
||||
"colourPrimary": "#b69ce8",
|
||||
"colourSecondary": "#ccbaef",
|
||||
"colourTertiary": "#9176c5"
|
||||
},
|
||||
"logic_blocks": {
|
||||
"colourPrimary": "#9fd2f1",
|
||||
"colourSecondary": "#c0e0f4",
|
||||
"colourTertiary": "#74bae5"
|
||||
},
|
||||
"loop_blocks": {
|
||||
"colourPrimary": "#aa1846",
|
||||
"colourSecondary": "#d36185",
|
||||
"colourTertiary": "#7c1636"
|
||||
},
|
||||
"math_blocks": {
|
||||
"colourPrimary": "#e6da39",
|
||||
"colourSecondary": "#f3ec8e",
|
||||
"colourTertiary": "#f2eeb7"
|
||||
},
|
||||
"procedure_blocks": {
|
||||
"colourPrimary": "#590721",
|
||||
"colourSecondary": "#8c475d",
|
||||
"colourTertiary": "#885464"
|
||||
},
|
||||
"text_blocks": {
|
||||
"colourPrimary": "#058863",
|
||||
"colourSecondary": "#5ecfaf",
|
||||
"colourTertiary": "#04684c"
|
||||
},
|
||||
"variable_blocks": {
|
||||
"colourPrimary": "#4b2d84",
|
||||
"colourSecondary": "#816ea7",
|
||||
"colourTertiary": "#83759e"
|
||||
},
|
||||
"variable_dynamic_blocks": {
|
||||
"colourPrimary": "#4b2d84",
|
||||
"colourSecondary": "#816ea7",
|
||||
"colourTertiary": "#83759e"
|
||||
}
|
||||
};
|
||||
|
||||
Blockly.Themes.Tritanopia.categoryStyles = {
|
||||
"colour_category": {
|
||||
"colour": "#05427f"
|
||||
},
|
||||
"list_category": {
|
||||
"colour": "#b69ce8"
|
||||
},
|
||||
"logic_category": {
|
||||
"colour": "#9fd2f1"
|
||||
},
|
||||
"loop_category": {
|
||||
"colour": "#aa1846"
|
||||
},
|
||||
"math_category": {
|
||||
"colour": "#e6da39"
|
||||
},
|
||||
"procedure_category": {
|
||||
"colour": "#590721"
|
||||
},
|
||||
"text_category": {
|
||||
"colour": "#058863"
|
||||
},
|
||||
"variable_category": {
|
||||
"colour": "#4b2d84"
|
||||
},
|
||||
"variable_dynamic_category": {
|
||||
"colour": "#4b2d84"
|
||||
}
|
||||
};
|
||||
|
||||
Blockly.Themes.Tritanopia =
|
||||
new Blockly.Theme('tritanopia',
|
||||
Blockly.Themes.Tritanopia.defaultBlockStyles,
|
||||
Blockly.Themes.Tritanopia.categoryStyles);
|
||||
@@ -652,7 +652,7 @@ Blockly.Css.register([
|
||||
|
||||
'.blocklyToolboxDiv[dir="RTL"] .blocklyTreeRow {',
|
||||
'margin-left: 8px;',
|
||||
'padding-right: 0px',
|
||||
'padding-right: 0',
|
||||
'}',
|
||||
|
||||
'.blocklyTreeIcon {',
|
||||
|
||||
@@ -370,7 +370,7 @@ Blockly.utils.dom.measureFontMetrics = function(text, fontSize, fontWeight,
|
||||
|
||||
var block = document.createElement('div');
|
||||
block.style.width = '1px';
|
||||
block.style.height = '0px';
|
||||
block.style.height = 0;
|
||||
|
||||
var div = document.createElement('div');
|
||||
div.setAttribute('style', 'position: fixed; top: 0; left: 0; display: flex;');
|
||||
|
||||
@@ -19,15 +19,25 @@ goog.provide('Blockly.utils.object');
|
||||
|
||||
/**
|
||||
* Inherit the prototype methods from one constructor into another.
|
||||
*
|
||||
* @param {!Function} childCtor Child class.
|
||||
* @param {!Function} parentCtor Parent class.
|
||||
* @suppress {strictMissingProperties} superClass_ is not defined on Function.
|
||||
*/
|
||||
Blockly.utils.object.inherits = function(childCtor, parentCtor) {
|
||||
// Set a .superClass_ property so that methods can call parent methods
|
||||
// without hard-coding the parent class name.
|
||||
// Could be replaced by ES6's super().
|
||||
childCtor.superClass_ = parentCtor.prototype;
|
||||
|
||||
// Link the child class to the parent class so that static methods inherit.
|
||||
Object.setPrototypeOf(childCtor, parentCtor);
|
||||
|
||||
// Replace the child constructor's prototype object with an instance
|
||||
// of the parent class.
|
||||
childCtor.prototype = Object.create(parentCtor.prototype);
|
||||
childCtor.prototype.constructor = childCtor;
|
||||
// Alternatively, one could use this instead:
|
||||
// Object.setPrototypeOf(childCtor.prototype, parentCtor.prototype);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -94,7 +94,7 @@ Blockly.WorkspaceDragSurfaceSvg.prototype.translateSurface = function(x, y) {
|
||||
|
||||
this.SVG_.style.display = 'block';
|
||||
Blockly.utils.dom.setCssTransform(
|
||||
this.SVG_, 'translate3d(' + fixedX + 'px, ' + fixedY + 'px, 0px)');
|
||||
this.SVG_, 'translate3d(' + fixedX + 'px, ' + fixedY + 'px, 0)');
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -236,9 +236,9 @@ CustomFields.FieldTurtle.prototype.render_ = function() {
|
||||
break;
|
||||
case 'Mask':
|
||||
this.mask_.style.display = '';
|
||||
this.turtleGroup_.setAttribute('transform', 'translate(0,1.2)');
|
||||
this.turtleGroup_.setAttribute('transform', 'translate(0,6)');
|
||||
this.textElement_.setAttribute('transform',
|
||||
'translate(' + this.TEXT_OFFSET_X + ',4)');
|
||||
'translate(' + this.TEXT_OFFSET_X + ',12)');
|
||||
break;
|
||||
case 'Propeller':
|
||||
this.propeller_.style.display = '';
|
||||
@@ -631,7 +631,7 @@ CustomFields.FieldTurtle.prototype.createView_ = function() {
|
||||
this.mask_ = Blockly.utils.dom.createSvgElement('image',
|
||||
{
|
||||
'width': '50',
|
||||
'height': '14'
|
||||
'height': '24'
|
||||
}, scaleGroup);
|
||||
this.mask_.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href',
|
||||
'media/mask.svg');
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
<tr>
|
||||
<td>
|
||||
<textarea id="importExport"
|
||||
style="width: 200px; height: 480px;"></textarea>s
|
||||
style="width: 200px; height: 480px;"></textarea>
|
||||
</td>
|
||||
<td>
|
||||
<div id="blocklyDiv" style="width: 600px; height: 480px;"></div>
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
"COLOUR_RGB_RED": "röd",
|
||||
"COLOUR_RGB_GREEN": "grön",
|
||||
"COLOUR_RGB_BLUE": "blå",
|
||||
"COLOUR_RGB_TOOLTIP": "Skapa en färg med det angivna mängden röd, grön och blå.\nAlla värden måste vara mellan 0 och 100.",
|
||||
"COLOUR_RGB_TOOLTIP": "Skapa en färg med det angivna mängden röd, grön och blå. Alla värden måste vara mellan 0 och 100.",
|
||||
"COLOUR_BLEND_HELPURL": "https://meyerweb.com/eric/tools/color-blend/#:::rgbp",
|
||||
"COLOUR_BLEND_TITLE": "blanda",
|
||||
"COLOUR_BLEND_COLOUR1": "färg 1",
|
||||
|
||||
12645
package-lock.json
generated
12645
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -28,8 +28,8 @@ function prepareDeployDir(done) {
|
||||
if (fs.existsSync(demoTmpDir)) {
|
||||
rimraf.sync(demoTmpDir);
|
||||
}
|
||||
fs.mkdirSync(demoStaticTmpDir, { recursive: true });
|
||||
done()
|
||||
fs.mkdirSync(demoStaticTmpDir, {recursive: true});
|
||||
done();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -383,9 +383,8 @@ this removal!
|
||||
*/
|
||||
function buildLangfiles(done) {
|
||||
// Create output directory.
|
||||
// TODO(#5000): does mkidr -p work on Windows?
|
||||
const outputDir = path.join(BUILD_DIR, 'msg', 'js');
|
||||
execSync(`mkdir -p ${outputDir}`, {stdio: 'inherit'});
|
||||
fs.mkdirSync(outputDir, {recursive: true});
|
||||
|
||||
// Run create_messages.py.
|
||||
let json_files = fs.readdirSync(path.join('msg', 'json'));
|
||||
|
||||
@@ -374,7 +374,7 @@ function packageJSON(cb) {
|
||||
const json = Object.assign({}, packageJson);
|
||||
delete json['scripts'];
|
||||
if (!fs.existsSync(RELEASE_DIR)) {
|
||||
fs.mkdirSync(RELEASE_DIR);
|
||||
fs.mkdirSync(RELEASE_DIR, {recursive: true});
|
||||
}
|
||||
fs.writeFileSync(`${RELEASE_DIR}/package.json`,
|
||||
JSON.stringify(json, null, 2));
|
||||
|
||||
@@ -151,17 +151,12 @@ goog.addDependency('../../core/renderers/zelos/measurables/row_elements.js', ['B
|
||||
goog.addDependency('../../core/renderers/zelos/measurables/rows.js', ['Blockly.zelos.BottomRow', 'Blockly.zelos.TopRow'], ['Blockly.blockRendering.BottomRow', 'Blockly.blockRendering.TopRow', 'Blockly.utils.object']);
|
||||
goog.addDependency('../../core/renderers/zelos/path_object.js', ['Blockly.zelos.PathObject'], ['Blockly.blockRendering.PathObject', 'Blockly.utils.Svg', 'Blockly.utils.dom', 'Blockly.utils.object', 'Blockly.zelos.ConstantProvider']);
|
||||
goog.addDependency('../../core/renderers/zelos/renderer.js', ['Blockly.zelos.Renderer'], ['Blockly.InsertionMarkerManager', 'Blockly.blockRendering', 'Blockly.blockRendering.Renderer', 'Blockly.connectionTypes', 'Blockly.constants', 'Blockly.utils.object', 'Blockly.zelos.ConstantProvider', 'Blockly.zelos.Drawer', 'Blockly.zelos.MarkerSvg', 'Blockly.zelos.PathObject', 'Blockly.zelos.RenderInfo']);
|
||||
goog.addDependency('../../core/requires.js', ['Blockly.requires'], ['Blockly', 'Blockly.Comment', 'Blockly.ContextMenuItems', 'Blockly.FieldAngle', 'Blockly.FieldCheckbox', 'Blockly.FieldColour', 'Blockly.FieldDropdown', 'Blockly.FieldImage', 'Blockly.FieldLabelSerializable', 'Blockly.FieldMultilineInput', 'Blockly.FieldNumber', 'Blockly.FieldTextInput', 'Blockly.FieldVariable', 'Blockly.FlyoutButton', 'Blockly.Generator', 'Blockly.HorizontalFlyout', 'Blockly.Mutator', 'Blockly.ShortcutItems', 'Blockly.Themes.Classic', 'Blockly.Themes.Dark', 'Blockly.Themes.Deuteranopia', 'Blockly.Themes.HighContrast', 'Blockly.Themes.Tritanopia', 'Blockly.Toolbox', 'Blockly.Trashcan', 'Blockly.VariablesDynamic', 'Blockly.VerticalFlyout', 'Blockly.Warning', 'Blockly.ZoomControls', 'Blockly.geras.Renderer', 'Blockly.thrasos.Renderer', 'Blockly.zelos.Renderer']);
|
||||
goog.addDependency('../../core/requires.js', ['Blockly.requires'], ['Blockly', 'Blockly.Comment', 'Blockly.ContextMenuItems', 'Blockly.FieldAngle', 'Blockly.FieldCheckbox', 'Blockly.FieldColour', 'Blockly.FieldDropdown', 'Blockly.FieldImage', 'Blockly.FieldLabelSerializable', 'Blockly.FieldMultilineInput', 'Blockly.FieldNumber', 'Blockly.FieldTextInput', 'Blockly.FieldVariable', 'Blockly.FlyoutButton', 'Blockly.Generator', 'Blockly.HorizontalFlyout', 'Blockly.Mutator', 'Blockly.ShortcutItems', 'Blockly.Themes.Classic', 'Blockly.Toolbox', 'Blockly.Trashcan', 'Blockly.VariablesDynamic', 'Blockly.VerticalFlyout', 'Blockly.Warning', 'Blockly.ZoomControls', 'Blockly.geras.Renderer', 'Blockly.thrasos.Renderer', 'Blockly.zelos.Renderer']);
|
||||
goog.addDependency('../../core/scrollbar.js', ['Blockly.Scrollbar', 'Blockly.ScrollbarPair'], ['Blockly.Events', 'Blockly.Touch', 'Blockly.browserEvents', 'Blockly.utils', 'Blockly.utils.Coordinate', 'Blockly.utils.Metrics', 'Blockly.utils.Svg', 'Blockly.utils.dom']);
|
||||
goog.addDependency('../../core/shortcut_items.js', ['Blockly.ShortcutItems'], ['Blockly.Gesture', 'Blockly.ShortcutRegistry', 'Blockly.utils.KeyCodes']);
|
||||
goog.addDependency('../../core/shortcut_registry.js', ['Blockly.ShortcutRegistry'], ['Blockly.utils.KeyCodes', 'Blockly.utils.object']);
|
||||
goog.addDependency('../../core/theme.js', ['Blockly.Theme'], ['Blockly.registry', 'Blockly.utils', 'Blockly.utils.object']);
|
||||
goog.addDependency('../../core/theme/classic.js', ['Blockly.Themes.Classic'], ['Blockly.Theme']);
|
||||
goog.addDependency('../../core/theme/dark.js', ['Blockly.Themes.Dark'], ['Blockly.Theme']);
|
||||
goog.addDependency('../../core/theme/deuteranopia.js', ['Blockly.Themes.Deuteranopia'], ['Blockly.Theme']);
|
||||
goog.addDependency('../../core/theme/highcontrast.js', ['Blockly.Themes.HighContrast'], ['Blockly.Theme']);
|
||||
goog.addDependency('../../core/theme/modern.js', ['Blockly.Themes.Modern'], ['Blockly.Theme']);
|
||||
goog.addDependency('../../core/theme/tritanopia.js', ['Blockly.Themes.Tritanopia'], ['Blockly.Theme']);
|
||||
goog.addDependency('../../core/theme/zelos.js', ['Blockly.Themes.Zelos'], ['Blockly.Theme']);
|
||||
goog.addDependency('../../core/theme_manager.js', ['Blockly.ThemeManager'], ['Blockly.Theme']);
|
||||
goog.addDependency('../../core/toolbox/category.js', ['Blockly.ToolboxCategory'], ['Blockly.ISelectableToolboxItem', 'Blockly.ToolboxItem', 'Blockly.registry', 'Blockly.utils', 'Blockly.utils.aria', 'Blockly.utils.dom', 'Blockly.utils.object', 'Blockly.utils.toolbox'], {'lang': 'es5'});
|
||||
|
||||
@@ -890,6 +890,96 @@ suite('Blocks', function() {
|
||||
chai.assert.equal(this.getNext().length, 6);
|
||||
});
|
||||
});
|
||||
suite('Setting Parent Block', function() {
|
||||
setup(function() {
|
||||
this.printBlock = Blockly.Xml.domToBlock(Blockly.Xml.textToDom(
|
||||
'<block type="text_print">' +
|
||||
' <value name="TEXT">' +
|
||||
' <block type="text_join">' +
|
||||
' <mutation items="2"></mutation>' +
|
||||
' <value name="ADD0">' +
|
||||
' <block type="text">' +
|
||||
' </block>' +
|
||||
' </value>' +
|
||||
' </block>' +
|
||||
' </value>' +
|
||||
'</block>'
|
||||
), this.workspace);
|
||||
this.textJoinBlock = this.printBlock.getInputTargetBlock('TEXT');
|
||||
this.textBlock = this.textJoinBlock.getInputTargetBlock('ADD0');
|
||||
});
|
||||
|
||||
function assertBlockIsOnlyChild(parent, child, inputName) {
|
||||
chai.assert.equal(parent.getChildren().length, 1);
|
||||
chai.assert.equal(parent.getInputTargetBlock(inputName), child);
|
||||
chai.assert.equal(child.getParent(), parent);
|
||||
}
|
||||
function assertNonParentAndOrphan(nonParent, orphan, inputName) {
|
||||
chai.assert.equal(nonParent.getChildren().length, 0);
|
||||
chai.assert.isNull(nonParent.getInputTargetBlock('TEXT'));
|
||||
chai.assert.isNull(orphan.getParent());
|
||||
}
|
||||
function assertOriginalSetup() {
|
||||
assertBlockIsOnlyChild(this.printBlock, this.textJoinBlock, 'TEXT');
|
||||
assertBlockIsOnlyChild(this.textJoinBlock, this.textBlock, 'ADD0');
|
||||
}
|
||||
|
||||
test('Setting to connected parent', function() {
|
||||
chai.assert.doesNotThrow(this.textJoinBlock.setParent
|
||||
.bind(this.textJoinBlock, this.printBlock));
|
||||
assertOriginalSetup.call(this);
|
||||
});
|
||||
test('Setting to new parent after connecting to it', function() {
|
||||
this.textJoinBlock.outputConnection.disconnect();
|
||||
this.textBlock.outputConnection
|
||||
.connect(this.printBlock.getInput('TEXT').connection);
|
||||
chai.assert.doesNotThrow(this.textBlock.setParent
|
||||
.bind(this.textBlock, this.printBlock));
|
||||
assertBlockIsOnlyChild(this.printBlock, this.textBlock, 'TEXT');
|
||||
});
|
||||
test('Setting to new parent while connected to other block', function() {
|
||||
// Setting to grandparent with no available input connection.
|
||||
chai.assert.throws(this.textBlock.setParent
|
||||
.bind(this.textBlock, this.printBlock));
|
||||
this.textJoinBlock.outputConnection.disconnect();
|
||||
// Setting to block with available input connection.
|
||||
chai.assert.throws(this.textBlock.setParent
|
||||
.bind(this.textBlock, this.printBlock));
|
||||
assertNonParentAndOrphan(this.printBlock, this.textJoinBlock, 'TEXT');
|
||||
assertBlockIsOnlyChild(this.textJoinBlock, this.textBlock, 'ADD0');
|
||||
});
|
||||
test('Setting to same parent after disconnecting from it', function() {
|
||||
this.textJoinBlock.outputConnection.disconnect();
|
||||
chai.assert.throws(this.textJoinBlock.setParent
|
||||
.bind(this.textJoinBlock, this.printBlock));
|
||||
assertNonParentAndOrphan(this.printBlock, this.textJoinBlock, 'TEXT');
|
||||
});
|
||||
test('Setting to new parent when orphan', function() {
|
||||
this.textBlock.outputConnection.disconnect();
|
||||
// When new parent has no available input connection.
|
||||
chai.assert.throws(this.textBlock.setParent
|
||||
.bind(this.textBlock, this.printBlock));
|
||||
this.textJoinBlock.outputConnection.disconnect();
|
||||
// When new parent has available input connection.
|
||||
chai.assert.throws(this.textBlock.setParent
|
||||
.bind(this.textBlock, this.printBlock));
|
||||
|
||||
assertNonParentAndOrphan(this.printBlock, this.textJoinBlock, 'TEXT');
|
||||
assertNonParentAndOrphan(this.printBlock, this.textBlock, 'TEXT');
|
||||
assertNonParentAndOrphan(this.textJoinBlock, this.textBlock, 'ADD0');
|
||||
});
|
||||
test('Setting parent to null after disconnecting', function() {
|
||||
this.textBlock.outputConnection.disconnect();
|
||||
chai.assert.doesNotThrow(this.textBlock.setParent
|
||||
.bind(this.textBlock, null));
|
||||
assertNonParentAndOrphan(this.textJoinBlock, this.textBlock, 'ADD0');
|
||||
});
|
||||
test('Setting parent to null without disconnecting', function() {
|
||||
chai.assert.throws(this.textBlock.setParent
|
||||
.bind(this.textBlock, null));
|
||||
assertOriginalSetup.call(this);
|
||||
});
|
||||
});
|
||||
suite('Remove Connections Programmatically', function() {
|
||||
test('Output', function() {
|
||||
var block = createRenderedBlock(this.workspace, 'row_block');
|
||||
@@ -1106,11 +1196,16 @@ suite('Blocks', function() {
|
||||
});
|
||||
suite('Getting/Setting Field (Values)', function() {
|
||||
setup(function() {
|
||||
this.workspace = Blockly.inject('blocklyDiv');
|
||||
this.block = Blockly.Xml.domToBlock(Blockly.Xml.textToDom(
|
||||
'<block type="text"><field name = "TEXT">test</field></block>'
|
||||
), this.workspace);
|
||||
});
|
||||
|
||||
teardown(function() {
|
||||
workspaceTeardown.call(this, this.workspace);
|
||||
});
|
||||
|
||||
test('Getting Field', function() {
|
||||
chai.assert.instanceOf(this.block.getField('TEXT'), Blockly.Field);
|
||||
});
|
||||
@@ -1289,8 +1384,8 @@ suite('Blocks', function() {
|
||||
});
|
||||
suite('Connecting and Disconnecting', function() {
|
||||
test('Connect Block to Next', function() {
|
||||
var blockA = createRenderedBlock(this.workspace,'stack_block');
|
||||
var blockB = createRenderedBlock(this.workspace,'stack_block');
|
||||
var blockA = createRenderedBlock(this.workspace, 'stack_block');
|
||||
var blockB = createRenderedBlock(this.workspace, 'stack_block');
|
||||
|
||||
blockA.setCollapsed(true);
|
||||
assertCollapsed(blockA);
|
||||
@@ -1298,8 +1393,8 @@ suite('Blocks', function() {
|
||||
assertNotCollapsed(blockB);
|
||||
});
|
||||
test('Connect Block to Value Input', function() {
|
||||
var blockA = createRenderedBlock(this.workspace,'row_block');
|
||||
var blockB = createRenderedBlock(this.workspace,'row_block');
|
||||
var blockA = createRenderedBlock(this.workspace, 'row_block');
|
||||
var blockB = createRenderedBlock(this.workspace, 'row_block');
|
||||
|
||||
blockA.setCollapsed(true);
|
||||
assertCollapsed(blockA);
|
||||
@@ -1310,8 +1405,8 @@ suite('Blocks', function() {
|
||||
chai.assert.isFalse(isBlockHidden(blockB));
|
||||
});
|
||||
test('Connect Block to Statement Input', function() {
|
||||
var blockA = createRenderedBlock(this.workspace,'statement_block');
|
||||
var blockB = createRenderedBlock(this.workspace,'stack_block');
|
||||
var blockA = createRenderedBlock(this.workspace, 'statement_block');
|
||||
var blockB = createRenderedBlock(this.workspace, 'stack_block');
|
||||
|
||||
blockA.setCollapsed(true);
|
||||
assertCollapsed(blockA);
|
||||
@@ -1323,9 +1418,9 @@ suite('Blocks', function() {
|
||||
chai.assert.isFalse(isBlockHidden(blockB));
|
||||
});
|
||||
test('Connect Block to Child of Collapsed - Input', function() {
|
||||
var blockA = createRenderedBlock(this.workspace,'row_block');
|
||||
var blockB = createRenderedBlock(this.workspace,'row_block');
|
||||
var blockC = createRenderedBlock(this.workspace,'row_block');
|
||||
var blockA = createRenderedBlock(this.workspace, 'row_block');
|
||||
var blockB = createRenderedBlock(this.workspace, 'row_block');
|
||||
var blockC = createRenderedBlock(this.workspace, 'row_block');
|
||||
|
||||
blockA.getInput('INPUT').connection.connect(blockB.outputConnection);
|
||||
blockA.setCollapsed(true);
|
||||
@@ -1340,9 +1435,9 @@ suite('Blocks', function() {
|
||||
chai.assert.isFalse(isBlockHidden(blockC));
|
||||
});
|
||||
test('Connect Block to Child of Collapsed - Next', function() {
|
||||
var blockA = createRenderedBlock(this.workspace,'statement_block');
|
||||
var blockB = createRenderedBlock(this.workspace,'stack_block');
|
||||
var blockC = createRenderedBlock(this.workspace,'stack_block');
|
||||
var blockA = createRenderedBlock(this.workspace, 'statement_block');
|
||||
var blockB = createRenderedBlock(this.workspace, 'stack_block');
|
||||
var blockC = createRenderedBlock(this.workspace, 'stack_block');
|
||||
|
||||
blockA.getInput('STATEMENT').connection
|
||||
.connect(blockB.previousConnection);
|
||||
@@ -1358,9 +1453,9 @@ suite('Blocks', function() {
|
||||
chai.assert.isFalse(isBlockHidden(blockC));
|
||||
});
|
||||
test('Connect Block to Value Input Already Taken', function() {
|
||||
var blockA = createRenderedBlock(this.workspace,'row_block');
|
||||
var blockB = createRenderedBlock(this.workspace,'row_block');
|
||||
var blockC = createRenderedBlock(this.workspace,'row_block');
|
||||
var blockA = createRenderedBlock(this.workspace, 'row_block');
|
||||
var blockB = createRenderedBlock(this.workspace, 'row_block');
|
||||
var blockC = createRenderedBlock(this.workspace, 'row_block');
|
||||
|
||||
blockA.getInput('INPUT').connection.connect(blockB.outputConnection);
|
||||
blockA.setCollapsed(true);
|
||||
@@ -1377,9 +1472,9 @@ suite('Blocks', function() {
|
||||
chai.assert.isFalse(isBlockHidden(blockC));
|
||||
});
|
||||
test('Connect Block to Statement Input Already Taken', function() {
|
||||
var blockA = createRenderedBlock(this.workspace,'statement_block');
|
||||
var blockB = createRenderedBlock(this.workspace,'stack_block');
|
||||
var blockC = createRenderedBlock(this.workspace,'stack_block');
|
||||
var blockA = createRenderedBlock(this.workspace, 'statement_block');
|
||||
var blockB = createRenderedBlock(this.workspace, 'stack_block');
|
||||
var blockC = createRenderedBlock(this.workspace, 'stack_block');
|
||||
|
||||
blockA.getInput('STATEMENT').connection
|
||||
.connect(blockB.previousConnection);
|
||||
@@ -1398,9 +1493,9 @@ suite('Blocks', function() {
|
||||
chai.assert.isFalse(isBlockHidden(blockC));
|
||||
});
|
||||
test('Connect Block with Child - Input', function() {
|
||||
var blockA = createRenderedBlock(this.workspace,'row_block');
|
||||
var blockB = createRenderedBlock(this.workspace,'row_block');
|
||||
var blockC = createRenderedBlock(this.workspace,'row_block');
|
||||
var blockA = createRenderedBlock(this.workspace, 'row_block');
|
||||
var blockB = createRenderedBlock(this.workspace, 'row_block');
|
||||
var blockC = createRenderedBlock(this.workspace, 'row_block');
|
||||
|
||||
blockB.getInput('INPUT').connection.connect(blockC.outputConnection);
|
||||
blockA.setCollapsed(true);
|
||||
@@ -1415,9 +1510,9 @@ suite('Blocks', function() {
|
||||
chai.assert.isFalse(isBlockHidden(blockC));
|
||||
});
|
||||
test('Connect Block with Child - Statement', function() {
|
||||
var blockA = createRenderedBlock(this.workspace,'statement_block');
|
||||
var blockB = createRenderedBlock(this.workspace,'stack_block');
|
||||
var blockC = createRenderedBlock(this.workspace,'stack_block');
|
||||
var blockA = createRenderedBlock(this.workspace, 'statement_block');
|
||||
var blockB = createRenderedBlock(this.workspace, 'stack_block');
|
||||
var blockC = createRenderedBlock(this.workspace, 'stack_block');
|
||||
|
||||
blockB.nextConnection.connect(blockC.previousConnection);
|
||||
blockA.setCollapsed(true);
|
||||
@@ -1433,8 +1528,8 @@ suite('Blocks', function() {
|
||||
chai.assert.isFalse(isBlockHidden(blockC));
|
||||
});
|
||||
test('Disconnect Block from Value Input', function() {
|
||||
var blockA = createRenderedBlock(this.workspace,'row_block');
|
||||
var blockB = createRenderedBlock(this.workspace,'row_block');
|
||||
var blockA = createRenderedBlock(this.workspace, 'row_block');
|
||||
var blockB = createRenderedBlock(this.workspace, 'row_block');
|
||||
|
||||
blockA.getInput('INPUT').connection.connect(blockB.outputConnection);
|
||||
blockA.setCollapsed(true);
|
||||
@@ -1444,8 +1539,8 @@ suite('Blocks', function() {
|
||||
chai.assert.isFalse(isBlockHidden(blockB));
|
||||
});
|
||||
test('Disconnect Block from Statement Input', function() {
|
||||
var blockA = createRenderedBlock(this.workspace,'statement_block');
|
||||
var blockB = createRenderedBlock(this.workspace,'stack_block');
|
||||
var blockA = createRenderedBlock(this.workspace, 'statement_block');
|
||||
var blockB = createRenderedBlock(this.workspace, 'stack_block');
|
||||
|
||||
blockA.getInput('STATEMENT').connection
|
||||
.connect(blockB.previousConnection);
|
||||
@@ -1456,9 +1551,9 @@ suite('Blocks', function() {
|
||||
chai.assert.isFalse(isBlockHidden(blockB));
|
||||
});
|
||||
test('Disconnect Block from Child of Collapsed - Input', function() {
|
||||
var blockA = createRenderedBlock(this.workspace,'row_block');
|
||||
var blockB = createRenderedBlock(this.workspace,'row_block');
|
||||
var blockC = createRenderedBlock(this.workspace,'row_block');
|
||||
var blockA = createRenderedBlock(this.workspace, 'row_block');
|
||||
var blockB = createRenderedBlock(this.workspace, 'row_block');
|
||||
var blockC = createRenderedBlock(this.workspace, 'row_block');
|
||||
|
||||
blockA.getInput('INPUT').connection.connect(blockB.outputConnection);
|
||||
blockB.getInput('INPUT').connection.connect(blockC.outputConnection);
|
||||
@@ -1471,9 +1566,9 @@ suite('Blocks', function() {
|
||||
chai.assert.isFalse(isBlockHidden(blockC));
|
||||
});
|
||||
test('Disconnect Block from Child of Collapsed - Next', function() {
|
||||
var blockA = createRenderedBlock(this.workspace,'statement_block');
|
||||
var blockB = createRenderedBlock(this.workspace,'stack_block');
|
||||
var blockC = createRenderedBlock(this.workspace,'stack_block');
|
||||
var blockA = createRenderedBlock(this.workspace, 'statement_block');
|
||||
var blockB = createRenderedBlock(this.workspace, 'stack_block');
|
||||
var blockC = createRenderedBlock(this.workspace, 'stack_block');
|
||||
|
||||
blockA.getInput('STATEMENT').connection
|
||||
.connect(blockB.previousConnection);
|
||||
@@ -1487,9 +1582,9 @@ suite('Blocks', function() {
|
||||
chai.assert.isFalse(isBlockHidden(blockC));
|
||||
});
|
||||
test('Disconnect Block with Child - Input', function() {
|
||||
var blockA = createRenderedBlock(this.workspace,'row_block');
|
||||
var blockB = createRenderedBlock(this.workspace,'row_block');
|
||||
var blockC = createRenderedBlock(this.workspace,'row_block');
|
||||
var blockA = createRenderedBlock(this.workspace, 'row_block');
|
||||
var blockB = createRenderedBlock(this.workspace, 'row_block');
|
||||
var blockC = createRenderedBlock(this.workspace, 'row_block');
|
||||
|
||||
blockB.getInput('INPUT').connection.connect(blockC.outputConnection);
|
||||
blockA.getInput('INPUT').connection.connect(blockB.outputConnection);
|
||||
@@ -1503,9 +1598,9 @@ suite('Blocks', function() {
|
||||
chai.assert.isFalse(isBlockHidden(blockC));
|
||||
});
|
||||
test('Disconnect Block with Child - Statement', function() {
|
||||
var blockA = createRenderedBlock(this.workspace,'statement_block');
|
||||
var blockB = createRenderedBlock(this.workspace,'stack_block');
|
||||
var blockC = createRenderedBlock(this.workspace,'stack_block');
|
||||
var blockA = createRenderedBlock(this.workspace, 'statement_block');
|
||||
var blockB = createRenderedBlock(this.workspace, 'stack_block');
|
||||
var blockC = createRenderedBlock(this.workspace, 'stack_block');
|
||||
|
||||
blockB.nextConnection.connect(blockC.previousConnection);
|
||||
blockA.getInput('STATEMENT').connection
|
||||
@@ -1522,7 +1617,7 @@ suite('Blocks', function() {
|
||||
});
|
||||
suite('Adding and Removing Block Parts', function() {
|
||||
test('Add Previous Connection', function() {
|
||||
var blockA = createRenderedBlock(this.workspace,'empty_block');
|
||||
var blockA = createRenderedBlock(this.workspace, 'empty_block');
|
||||
blockA.setCollapsed(true);
|
||||
assertCollapsed(blockA);
|
||||
blockA.setPreviousStatement(true);
|
||||
@@ -1530,7 +1625,7 @@ suite('Blocks', function() {
|
||||
chai.assert.isNotNull(blockA.previousConnection);
|
||||
});
|
||||
test('Add Next Connection', function() {
|
||||
var blockA = createRenderedBlock(this.workspace,'empty_block');
|
||||
var blockA = createRenderedBlock(this.workspace, 'empty_block');
|
||||
blockA.setCollapsed(true);
|
||||
assertCollapsed(blockA);
|
||||
blockA.setNextStatement(true);
|
||||
@@ -1538,7 +1633,7 @@ suite('Blocks', function() {
|
||||
chai.assert.isNotNull(blockA.nextConnection);
|
||||
});
|
||||
test('Add Input', function() {
|
||||
var blockA = createRenderedBlock(this.workspace,'empty_block');
|
||||
var blockA = createRenderedBlock(this.workspace, 'empty_block');
|
||||
blockA.setCollapsed(true);
|
||||
assertCollapsed(blockA);
|
||||
blockA.appendDummyInput('NAME');
|
||||
@@ -1546,7 +1641,7 @@ suite('Blocks', function() {
|
||||
chai.assert.isNotNull(blockA.getInput('NAME'));
|
||||
});
|
||||
test('Add Field', function() {
|
||||
var blockA = createRenderedBlock(this.workspace,'empty_block');
|
||||
var blockA = createRenderedBlock(this.workspace, 'empty_block');
|
||||
var input = blockA.appendDummyInput('NAME');
|
||||
blockA.setCollapsed(true);
|
||||
assertCollapsed(blockA);
|
||||
@@ -1557,14 +1652,14 @@ suite('Blocks', function() {
|
||||
chai.assert.equal(field.getText(), 'test');
|
||||
});
|
||||
test('Add Icon', function() {
|
||||
var blockA = createRenderedBlock(this.workspace,'empty_block');
|
||||
var blockA = createRenderedBlock(this.workspace, 'empty_block');
|
||||
blockA.setCollapsed(true);
|
||||
assertCollapsed(blockA);
|
||||
blockA.setCommentText('test');
|
||||
assertCollapsed(blockA);
|
||||
});
|
||||
test('Remove Previous Connection', function() {
|
||||
var blockA = createRenderedBlock(this.workspace,'empty_block');
|
||||
var blockA = createRenderedBlock(this.workspace, 'empty_block');
|
||||
blockA.setPreviousStatement(true);
|
||||
blockA.setCollapsed(true);
|
||||
assertCollapsed(blockA);
|
||||
@@ -1573,7 +1668,7 @@ suite('Blocks', function() {
|
||||
chai.assert.isNull(blockA.previousConnection);
|
||||
});
|
||||
test('Remove Next Connection', function() {
|
||||
var blockA = createRenderedBlock(this.workspace,'empty_block');
|
||||
var blockA = createRenderedBlock(this.workspace, 'empty_block');
|
||||
blockA.setNextStatement(true);
|
||||
blockA.setCollapsed(true);
|
||||
assertCollapsed(blockA);
|
||||
@@ -1582,7 +1677,7 @@ suite('Blocks', function() {
|
||||
chai.assert.isNull(blockA.nextConnection);
|
||||
});
|
||||
test('Remove Input', function() {
|
||||
var blockA = createRenderedBlock(this.workspace,'empty_block');
|
||||
var blockA = createRenderedBlock(this.workspace, 'empty_block');
|
||||
blockA.appendDummyInput('NAME');
|
||||
blockA.setCollapsed(true);
|
||||
assertCollapsed(blockA);
|
||||
@@ -1591,7 +1686,7 @@ suite('Blocks', function() {
|
||||
chai.assert.isNull(blockA.getInput('NAME'));
|
||||
});
|
||||
test('Remove Field', function() {
|
||||
var blockA = createRenderedBlock(this.workspace,'empty_block');
|
||||
var blockA = createRenderedBlock(this.workspace, 'empty_block');
|
||||
var input = blockA.appendDummyInput('NAME');
|
||||
input.appendField(new Blockly.FieldLabel('test'), 'FIELD');
|
||||
blockA.setCollapsed(true);
|
||||
@@ -1602,7 +1697,7 @@ suite('Blocks', function() {
|
||||
chai.assert.isNull(field);
|
||||
});
|
||||
test('Remove Icon', function() {
|
||||
var blockA = createRenderedBlock(this.workspace,'empty_block');
|
||||
var blockA = createRenderedBlock(this.workspace, 'empty_block');
|
||||
blockA.setCommentText('test');
|
||||
blockA.setCollapsed(true);
|
||||
assertCollapsed(blockA);
|
||||
@@ -1612,7 +1707,7 @@ suite('Blocks', function() {
|
||||
});
|
||||
suite('Renaming Vars', function() {
|
||||
test('Simple Rename', function() {
|
||||
var blockA = createRenderedBlock(this.workspace,'variable_block');
|
||||
var blockA = createRenderedBlock(this.workspace, 'variable_block');
|
||||
|
||||
blockA.setCollapsed(true);
|
||||
assertCollapsed(blockA, 'x');
|
||||
@@ -1622,7 +1717,7 @@ suite('Blocks', function() {
|
||||
assertCollapsed(blockA, 'y');
|
||||
});
|
||||
test('Coalesce, Different Case', function() {
|
||||
var blockA = createRenderedBlock(this.workspace,'variable_block');
|
||||
var blockA = createRenderedBlock(this.workspace, 'variable_block');
|
||||
|
||||
blockA.setCollapsed(true);
|
||||
assertCollapsed(blockA, 'x');
|
||||
@@ -1634,8 +1729,8 @@ suite('Blocks', function() {
|
||||
});
|
||||
suite('Disabled Blocks', function() {
|
||||
test('Children of Collapsed Blocks Should Enable Properly', function() {
|
||||
var blockA = createRenderedBlock(this.workspace,'statement_block');
|
||||
var blockB = createRenderedBlock(this.workspace,'stack_block');
|
||||
var blockA = createRenderedBlock(this.workspace, 'statement_block');
|
||||
var blockB = createRenderedBlock(this.workspace, 'stack_block');
|
||||
blockA.getInput('STATEMENT').connection
|
||||
.connect(blockB.previousConnection);
|
||||
// Disable the block and collapse it.
|
||||
@@ -1651,8 +1746,8 @@ suite('Blocks', function() {
|
||||
chai.assert.isFalse(blockB.getSvgRoot().classList.contains('blocklyDisabled'));
|
||||
});
|
||||
test('Children of Collapsed Block Should Not Update', function() {
|
||||
var blockA = createRenderedBlock(this.workspace,'statement_block');
|
||||
var blockB = createRenderedBlock(this.workspace,'stack_block');
|
||||
var blockA = createRenderedBlock(this.workspace, 'statement_block');
|
||||
var blockB = createRenderedBlock(this.workspace, 'stack_block');
|
||||
blockA.getInput('STATEMENT').connection
|
||||
.connect(blockB.previousConnection);
|
||||
|
||||
@@ -1670,8 +1765,8 @@ suite('Blocks', function() {
|
||||
sinon.assert.notCalled(blockUpdateDisabled);
|
||||
});
|
||||
test('Disabled Children of Collapsed Blocks Should Stay Disabled', function() {
|
||||
var blockA = createRenderedBlock(this.workspace,'statement_block');
|
||||
var blockB = createRenderedBlock(this.workspace,'stack_block');
|
||||
var blockA = createRenderedBlock(this.workspace, 'statement_block');
|
||||
var blockB = createRenderedBlock(this.workspace, 'stack_block');
|
||||
blockA.getInput('STATEMENT').connection
|
||||
.connect(blockB.previousConnection);
|
||||
|
||||
|
||||
@@ -934,7 +934,7 @@ suite('Events', function() {
|
||||
new Blockly.Events.Click(block1),
|
||||
new Blockly.Events.BubbleOpen(block2, true, 'mutator'),
|
||||
new Blockly.Events.Click(block2),
|
||||
new Blockly.Events.BubbleOpen(block3, true,'warning'),
|
||||
new Blockly.Events.BubbleOpen(block3, true, 'warning'),
|
||||
new Blockly.Events.Click(block3)
|
||||
];
|
||||
var filteredEvents = Blockly.Events.filter(events, true);
|
||||
|
||||
@@ -71,7 +71,7 @@ suite('Angle Fields', function() {
|
||||
validTestCaseAssertField, assertFieldDefault);
|
||||
|
||||
testHelpers.runFromJsonSuiteTests(
|
||||
Blockly.FieldAngle, validValueTestCases,invalidValueTestCases,
|
||||
Blockly.FieldAngle, validValueTestCases, invalidValueTestCases,
|
||||
validTestCaseAssertField, assertFieldDefault);
|
||||
|
||||
suite('setValue', function() {
|
||||
|
||||
@@ -74,7 +74,7 @@ suite('Checkbox Fields', function() {
|
||||
validTestCaseAssertField, assertFieldDefault);
|
||||
|
||||
testHelpers.runFromJsonSuiteTests(
|
||||
Blockly.FieldCheckbox, validValueTestCases,invalidValueTestCases,
|
||||
Blockly.FieldCheckbox, validValueTestCases, invalidValueTestCases,
|
||||
validTestCaseAssertField, assertFieldDefault);
|
||||
|
||||
suite('setValue', function() {
|
||||
|
||||
@@ -99,7 +99,7 @@ suite('Colour Fields', function() {
|
||||
validTestCaseAssertField, assertFieldDefault);
|
||||
|
||||
testHelpers.runFromJsonSuiteTests(
|
||||
Blockly.FieldColour, validValueTestCases,invalidValueTestCases,
|
||||
Blockly.FieldColour, validValueTestCases, invalidValueTestCases,
|
||||
validTestCaseAssertField, assertFieldDefault);
|
||||
|
||||
suite('setValue', function() {
|
||||
|
||||
@@ -114,8 +114,8 @@ suite('Dropdown Fields', function() {
|
||||
suite('Validators', function() {
|
||||
setup(function() {
|
||||
this.dropdownField = new Blockly.FieldDropdown([
|
||||
["1a","1A"], ["1b","1B"], ["1c","1C"],
|
||||
["2a","2A"], ["2b","2B"], ["2c","2C"]]);
|
||||
["1a", "1A"], ["1b", "1B"], ["1c", "1C"],
|
||||
["2a", "2A"], ["2b", "2B"], ["2c", "2C"]]);
|
||||
});
|
||||
teardown(function() {
|
||||
this.dropdownField.setValidator(null);
|
||||
|
||||
@@ -59,7 +59,7 @@ suite('Image Fields', function() {
|
||||
validTestCaseAssertField);
|
||||
|
||||
testHelpers.runFromJsonSuiteTests(
|
||||
Blockly.FieldImage, validValueCreationTestCases,invalidValueTestCases,
|
||||
Blockly.FieldImage, validValueCreationTestCases, invalidValueTestCases,
|
||||
validTestCaseAssertField);
|
||||
|
||||
/**
|
||||
|
||||
@@ -64,7 +64,7 @@ suite('Label Serializable Fields', function() {
|
||||
invalidValueTestCases, validTestCaseAssertField, assertFieldDefault);
|
||||
|
||||
testHelpers.runFromJsonSuiteTests(
|
||||
Blockly.FieldLabelSerializable, validValueTestCases,invalidValueTestCases,
|
||||
Blockly.FieldLabelSerializable, validValueTestCases, invalidValueTestCases,
|
||||
validTestCaseAssertField, assertFieldDefault);
|
||||
|
||||
suite('setValue', function() {
|
||||
|
||||
@@ -64,7 +64,7 @@ suite('Label Fields', function() {
|
||||
validTestCaseAssertField, assertFieldDefault);
|
||||
|
||||
testHelpers.runFromJsonSuiteTests(
|
||||
Blockly.FieldLabel, validValueTestCases,invalidValueTestCases,
|
||||
Blockly.FieldLabel, validValueTestCases, invalidValueTestCases,
|
||||
validTestCaseAssertField, assertFieldDefault);
|
||||
|
||||
suite('setValue', function() {
|
||||
|
||||
@@ -66,7 +66,7 @@ suite('Multiline Input Fields', function() {
|
||||
validTestCaseAssertField, assertFieldDefault);
|
||||
|
||||
testHelpers.runFromJsonSuiteTests(
|
||||
Blockly.FieldMultilineInput, validValueTestCases,invalidValueTestCases,
|
||||
Blockly.FieldMultilineInput, validValueTestCases, invalidValueTestCases,
|
||||
validTestCaseAssertField, assertFieldDefault);
|
||||
|
||||
suite('setValue', function() {
|
||||
|
||||
@@ -88,7 +88,7 @@ suite('Number Fields', function() {
|
||||
validTestCaseAssertField, assertFieldDefault);
|
||||
|
||||
testHelpers.runFromJsonSuiteTests(
|
||||
Blockly.FieldNumber, validValueTestCases,invalidValueTestCases,
|
||||
Blockly.FieldNumber, validValueTestCases, invalidValueTestCases,
|
||||
validTestCaseAssertField, assertFieldDefault);
|
||||
|
||||
suite('setValue', function() {
|
||||
|
||||
@@ -64,7 +64,7 @@ suite('Text Input Fields', function() {
|
||||
validTestCaseAssertField, assertFieldDefault);
|
||||
|
||||
testHelpers.runFromJsonSuiteTests(
|
||||
Blockly.FieldTextInput, validValueTestCases,invalidValueTestCases,
|
||||
Blockly.FieldTextInput, validValueTestCases, invalidValueTestCases,
|
||||
validTestCaseAssertField, assertFieldDefault);
|
||||
|
||||
suite('setValue', function() {
|
||||
|
||||
@@ -90,7 +90,7 @@ suite('Flyout', function() {
|
||||
this.flyout.targetWorkspace.toolboxPosition =
|
||||
Blockly.utils.toolbox.Position.RIGHT;
|
||||
this.flyout.toolboxPosition_ = Blockly.utils.toolbox.Position.RIGHT;
|
||||
chai.assert.equal(this.flyout.getX(), 90,'x + width should be aligned with toolbox');
|
||||
chai.assert.equal(this.flyout.getX(), 90, 'x + width should be aligned with toolbox');
|
||||
});
|
||||
});
|
||||
// These tests simulate a trashcan flyout, i.e. the flyout under test is on the
|
||||
@@ -260,7 +260,7 @@ suite('Flyout', function() {
|
||||
{type: "button"},
|
||||
{type: "button"}
|
||||
];
|
||||
var expectedGaps = [20,24,24];
|
||||
var expectedGaps = [20, 24, 24];
|
||||
var flyoutInfo = flyoutSpy.returnValues[0];
|
||||
var contents = flyoutInfo.contents;
|
||||
var gaps = flyoutInfo.gaps;
|
||||
|
||||
@@ -45,7 +45,7 @@ suite('Gesture', function() {
|
||||
|
||||
setup(function() {
|
||||
sharedTestSetup.call(this);
|
||||
defineBasicBlockWithField(this.sharedCleanup);
|
||||
defineBasicBlockWithField();
|
||||
var toolbox = document.getElementById('gesture-test-toolbox');
|
||||
this.workspace = Blockly.inject('blocklyDiv', {toolbox: toolbox});
|
||||
});
|
||||
|
||||
@@ -18,7 +18,7 @@ suite('Key Down', function() {
|
||||
* @param {Blockly.Workspace} workspace The workspace to create a new block on.
|
||||
*/
|
||||
function setSelectedBlock(workspace) {
|
||||
defineStackBlock(this.sharedCleanup);
|
||||
defineStackBlock();
|
||||
Blockly.selected = workspace.newBlock('stack_block');
|
||||
}
|
||||
|
||||
|
||||
@@ -20,8 +20,8 @@ suite('Names', function() {
|
||||
|
||||
test('Safe name', function() {
|
||||
var varDB = new Blockly.Names('window,door');
|
||||
chai.assert.equal(varDB.safeName_(''), 'unnamed','SafeName empty.');
|
||||
chai.assert.equal(varDB.safeName_('foobar'), 'foobar','SafeName ok.');
|
||||
chai.assert.equal(varDB.safeName_(''), 'unnamed', 'SafeName empty.');
|
||||
chai.assert.equal(varDB.safeName_('foobar'), 'foobar', 'SafeName ok.');
|
||||
chai.assert.equal(varDB.safeName_('9lives'), 'my_9lives', 'SafeName number start.');
|
||||
chai.assert.equal(varDB.safeName_('lives9'), 'lives9', 'SafeName number end.');
|
||||
chai.assert.equal(varDB.safeName_('!@#$'), '____', 'SafeName special chars.');
|
||||
|
||||
@@ -765,7 +765,7 @@ suite('Procedures', function() {
|
||||
'Callers are enabled when their definition is enabled (call ' +
|
||||
i + ')');
|
||||
}
|
||||
chai.assert.equal(firedEvents.length,3,
|
||||
chai.assert.equal(firedEvents.length, 3,
|
||||
'An event was fired for the definition and each caller');
|
||||
for (var i = 0; i < 3; i++) {
|
||||
chai.assert.equal(firedEvents[i].group, 'g2',
|
||||
@@ -801,7 +801,7 @@ suite('Procedures', function() {
|
||||
'Caller remains in disabled state when the definition is enabled');
|
||||
chai.assert.isTrue(this.barCalls[1].isEnabled(),
|
||||
'Caller returns to previous enabled state when the definition is enabled');
|
||||
chai.assert.equal(firedEvents.length,2,
|
||||
chai.assert.equal(firedEvents.length, 2,
|
||||
'An event was fired for the definition and the enabled caller');
|
||||
for (var i = 0; i < 2; i++) {
|
||||
chai.assert.equal(firedEvents[i].group, 'g2',
|
||||
|
||||
@@ -29,7 +29,14 @@ async function runMochaTestsInBrowser() {
|
||||
// Run in headless mode on Github Actions.
|
||||
if (process.env.CI) {
|
||||
options.capabilities['goog:chromeOptions'] = {
|
||||
args: ['--headless', '--no-sandbox', '--disable-dev-shm-usage']
|
||||
args: [
|
||||
'--headless', '--no-sandbox', '--disable-dev-shm-usage',
|
||||
'--allow-file-access-from-files',
|
||||
]
|
||||
};
|
||||
} else {
|
||||
options.capabilities['goog:chromeOptions'] = {
|
||||
args: ['--allow-file-access-from-files']
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -456,7 +456,7 @@ function assertNthCallEventArgEquals(spy, n, instanceType, expectedProperties,
|
||||
assertXmlProperties_(eventArg, xmlProperties);
|
||||
}
|
||||
|
||||
function defineStackBlock(sharedCleanupObj) {
|
||||
function defineStackBlock() {
|
||||
Blockly.defineBlocksWithJsonArray([{
|
||||
"type": "stack_block",
|
||||
"message0": "",
|
||||
@@ -465,7 +465,7 @@ function defineStackBlock(sharedCleanupObj) {
|
||||
}]);
|
||||
}
|
||||
|
||||
function defineRowBlock(sharedCleanupObj) {
|
||||
function defineRowBlock() {
|
||||
Blockly.defineBlocksWithJsonArray([{
|
||||
"type": "row_block",
|
||||
"message0": "%1",
|
||||
@@ -479,7 +479,7 @@ function defineRowBlock(sharedCleanupObj) {
|
||||
}]);
|
||||
}
|
||||
|
||||
function defineStatementBlock(sharedCleanupObj) {
|
||||
function defineStatementBlock() {
|
||||
Blockly.defineBlocksWithJsonArray([{
|
||||
"type": "statement_block",
|
||||
"message0": "%1",
|
||||
@@ -496,7 +496,7 @@ function defineStatementBlock(sharedCleanupObj) {
|
||||
"helpUrl": ""
|
||||
}]);
|
||||
}
|
||||
function defineBasicBlockWithField(sharedCleanupObj) {
|
||||
function defineBasicBlockWithField() {
|
||||
Blockly.defineBlocksWithJsonArray([{
|
||||
"type": "test_field_block",
|
||||
"message0": "%1",
|
||||
|
||||
@@ -20,7 +20,7 @@ suite('Theme', function() {
|
||||
Blockly.registry.typeMap_['theme'] = {};
|
||||
});
|
||||
|
||||
function defineThemeTestBlocks(sharedCleanupObj) {
|
||||
function defineThemeTestBlocks() {
|
||||
Blockly.defineBlocksWithJsonArray([{
|
||||
"type": "stack_block",
|
||||
"message0": "",
|
||||
@@ -117,7 +117,7 @@ suite('Theme', function() {
|
||||
});
|
||||
|
||||
test('Set Theme', function() {
|
||||
defineThemeTestBlocks(this.sharedCleanup);
|
||||
defineThemeTestBlocks();
|
||||
try {
|
||||
var blockStyles = createBlockStyles();
|
||||
var theme = new Blockly.Theme('themeName', blockStyles);
|
||||
|
||||
@@ -414,7 +414,7 @@ suite('Toolbox', function() {
|
||||
});
|
||||
test('Select collapsible item -> Should close flyout', function() {
|
||||
var newItem = getCollapsibleItem(this.toolbox);
|
||||
testHideFlyout(this.toolbox,null, newItem);
|
||||
testHideFlyout(this.toolbox, null, newItem);
|
||||
});
|
||||
test('Select selectable item -> Should open flyout', function() {
|
||||
var showFlyoutstub = sinon.stub(this.toolbox.flyout_, 'show');
|
||||
|
||||
@@ -14,7 +14,7 @@ suite('Utils', function() {
|
||||
|
||||
test('genUid', function() {
|
||||
var uuids = {};
|
||||
chai.assert.equal([1,2,3].indexOf(4), -1);
|
||||
chai.assert.equal([1, 2, 3].indexOf(4), -1);
|
||||
for (var i = 0; i < 1000; i++) {
|
||||
var uuid = Blockly.utils.genUid();
|
||||
chai.assert.isFalse(uuid in uuids, 'UUID different: ' + uuid);
|
||||
|
||||
@@ -150,7 +150,7 @@ suite('Workspace comment', function() {
|
||||
test('Initial position', function() {
|
||||
var xy = this.comment.getXY();
|
||||
chai.assert.equal(xy.x, 0, 'Initial X position');
|
||||
chai.assert.equal(xy.y, 0,'Initial Y position');
|
||||
chai.assert.equal(xy.y, 0, 'Initial Y position');
|
||||
});
|
||||
|
||||
test('moveBy', function() {
|
||||
@@ -177,7 +177,7 @@ suite('Workspace comment', function() {
|
||||
chai.assert.equal(
|
||||
this.comment.getContent(), 'comment text');
|
||||
chai.assert.equal(
|
||||
this.workspace.undoStack_.length, 1,'Workspace undo stack');
|
||||
this.workspace.undoStack_.length, 1, 'Workspace undo stack');
|
||||
});
|
||||
|
||||
test('Set to same value', function() {
|
||||
|
||||
@@ -72,7 +72,7 @@ suite('WorkspaceSvg', function() {
|
||||
|
||||
Blockly.Xml.appendDomToWorkspace(dom, this.workspace);
|
||||
var blocks = this.workspace.getAllBlocks(false);
|
||||
chai.assert.equal(blocks.length, 2,'Block count');
|
||||
chai.assert.equal(blocks.length, 2, 'Block count');
|
||||
var shadowBlock = blocks[1];
|
||||
chai.assert.exists(shadowBlock.getSvgRoot());
|
||||
|
||||
@@ -185,7 +185,7 @@ suite('WorkspaceSvg', function() {
|
||||
assertSpyFiredViewportEvent(
|
||||
eventsFireStub, workspace, expectedProperties);
|
||||
assertSpyFiredViewportEvent(
|
||||
changeListenerSpy, workspace,expectedProperties);
|
||||
changeListenerSpy, workspace, expectedProperties);
|
||||
sinon.assert.callCount(changeListenerSpy, expectedEventCount);
|
||||
sinon.assert.callCount(eventsFireStub, expectedEventCount);
|
||||
}
|
||||
|
||||
@@ -455,13 +455,13 @@ function testAWorkspace() {
|
||||
test('Over instance limit', function() {
|
||||
this.workspace.options.maxInstances['get_var_block'] = 1;
|
||||
chai.assert.equal(this.workspace.remainingCapacityOfType('get_var_block'),
|
||||
-1,'With maxInstances limit 1');
|
||||
-1, 'With maxInstances limit 1');
|
||||
});
|
||||
|
||||
test('Over instance limit of 0', function() {
|
||||
this.workspace.options.maxInstances['get_var_block'] = 0;
|
||||
chai.assert.equal(this.workspace.remainingCapacityOfType('get_var_block'),
|
||||
-2,'With maxInstances limit 0');
|
||||
-2, 'With maxInstances limit 0');
|
||||
});
|
||||
|
||||
test('Over instance limit with multiple block types', function() {
|
||||
@@ -470,7 +470,7 @@ function testAWorkspace() {
|
||||
this.workspace.newBlock('');
|
||||
this.workspace.options.maxInstances['get_var_block'] = 1;
|
||||
chai.assert.equal(this.workspace.remainingCapacityOfType('get_var_block'),
|
||||
-1,'With maxInstances limit 1');
|
||||
-1, 'With maxInstances limit 1');
|
||||
});
|
||||
|
||||
test('Over instance limit of 0 with multiple block types', function() {
|
||||
@@ -479,7 +479,7 @@ function testAWorkspace() {
|
||||
this.workspace.newBlock('');
|
||||
this.workspace.options.maxInstances['get_var_block'] = 0;
|
||||
chai.assert.equal(this.workspace.remainingCapacityOfType('get_var_block'),
|
||||
-2,'With maxInstances limit 0');
|
||||
-2, 'With maxInstances limit 0');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -611,7 +611,7 @@ function testAWorkspace() {
|
||||
|
||||
test('Trivial', function() {
|
||||
chai.assert.equal(
|
||||
this.workspace.getBlockById(this.blockA.id),this.blockA);
|
||||
this.workspace.getBlockById(this.blockA.id), this.blockA);
|
||||
chai.assert.equal(
|
||||
this.workspace.getBlockById(this.blockB.id), this.blockB);
|
||||
});
|
||||
@@ -1294,7 +1294,7 @@ function testAWorkspace() {
|
||||
|
||||
this.workspace.undo(true);
|
||||
// Expect that variable 'id2' is recreated
|
||||
assertBlockVarModelName(this.workspace,0, 'name2');
|
||||
assertBlockVarModelName(this.workspace, 0, 'name2');
|
||||
chai.assert.isNull(this.workspace.getVariableById('id1'));
|
||||
assertVariableValues(this.workspace, 'name2', 'type2', 'id2');
|
||||
});
|
||||
|
||||
@@ -713,7 +713,7 @@ suite('XML', function() {
|
||||
});
|
||||
suite('appendDomToWorkspace', function() {
|
||||
setup(function() {
|
||||
addBlockTypeToCleanup(this.sharedCleanup,'test_block');
|
||||
addBlockTypeToCleanup(this.sharedCleanup, 'test_block');
|
||||
Blockly.Blocks['test_block'] = {
|
||||
init: function() {
|
||||
this.jsonInit({
|
||||
|
||||
Reference in New Issue
Block a user