mirror of
https://github.com/google/blockly.git
synced 2026-01-10 10:27:08 +01:00
Make generator an optional module (#3105)
This commit is contained in:
@@ -56,7 +56,8 @@ goog.require('Blockly.Workspace');
|
||||
* @throws When block is not valid or block name is not allowed.
|
||||
*/
|
||||
Blockly.Block = function(workspace, prototypeName, opt_id) {
|
||||
if (typeof Blockly.Generator.prototype[prototypeName] !== 'undefined') {
|
||||
if (Blockly.Generator &&
|
||||
typeof Blockly.Generator.prototype[prototypeName] != 'undefined') {
|
||||
// Occluding Generator class members is not allowed.
|
||||
throw Error('Block prototypeName "' + prototypeName +
|
||||
'" conflicts with Blockly.Generator members.');
|
||||
@@ -1052,7 +1053,7 @@ Blockly.Block.prototype.setOnChange = function(onchangeFn) {
|
||||
Blockly.Block.prototype.getField = function(name) {
|
||||
for (var i = 0, input; input = this.inputList[i]; i++) {
|
||||
for (var j = 0, field; field = input.fieldRow[j]; j++) {
|
||||
if (field.name === name) {
|
||||
if (field.name == name) {
|
||||
return field;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,6 @@ goog.provide('Blockly');
|
||||
goog.require('Blockly.BlockSvg.render');
|
||||
goog.require('Blockly.Events');
|
||||
goog.require('Blockly.Events.Ui');
|
||||
goog.require('Blockly.Generator');
|
||||
goog.require('Blockly.navigation');
|
||||
goog.require('Blockly.Procedures');
|
||||
goog.require('Blockly.Tooltip');
|
||||
|
||||
@@ -362,7 +362,7 @@ Blockly.Css.CONTENT = [
|
||||
'}',
|
||||
|
||||
'.blocklyMultilineText {',
|
||||
' font-family: monospace;',
|
||||
'font-family: monospace;',
|
||||
'}',
|
||||
|
||||
'.blocklyNonEditableText>text {',
|
||||
|
||||
@@ -355,7 +355,7 @@ Blockly.Extensions.buildTooltipForDropdown = function(dropdownName,
|
||||
* @this {Blockly.Block}
|
||||
*/
|
||||
var extensionFn = function() {
|
||||
if (this.type && blockTypesChecked.indexOf(this.type) === -1) {
|
||||
if (this.type && blockTypesChecked.indexOf(this.type) == -1) {
|
||||
Blockly.Extensions.checkDropdownOptionsInTable_(
|
||||
this, dropdownName, lookupTable);
|
||||
blockTypesChecked.push(this.type);
|
||||
@@ -365,7 +365,7 @@ Blockly.Extensions.buildTooltipForDropdown = function(dropdownName,
|
||||
var value = this.getFieldValue(dropdownName);
|
||||
var tooltip = lookupTable[value];
|
||||
if (tooltip == null) {
|
||||
if (blockTypesChecked.indexOf(this.type) === -1) {
|
||||
if (blockTypesChecked.indexOf(this.type) == -1) {
|
||||
// Warn for missing values on generated tooltips.
|
||||
var warning = 'No tooltip mapping for value ' + value +
|
||||
' of field ' + dropdownName;
|
||||
|
||||
@@ -41,6 +41,10 @@ goog.require('Blockly.VerticalFlyout');
|
||||
// Flyout buttons are needed by the variable category,
|
||||
// and by any custom toolbox that has a button or a label.
|
||||
goog.require('Blockly.FlyoutButton');
|
||||
// If there is code generation into any language, then the generator is needed.
|
||||
// Should not be required when using advanced compilation since
|
||||
// individual generator files should already have this require.
|
||||
goog.require('Blockly.Generator');
|
||||
// If the toolbox does not have categories and only has a simple flyout, then
|
||||
// 'Blockly.Toolbox' is not needed.
|
||||
goog.require('Blockly.Toolbox');
|
||||
|
||||
Reference in New Issue
Block a user