mirror of
https://github.com/google/blockly.git
synced 2026-01-08 17:40:09 +01:00
Make block comments an optional module. (#3053)
Measured as a 5 KB *increase* in code size, but that's because some other commit just landed between my tests. It's like running down an up escalator.
This commit is contained in:
@@ -28,6 +28,7 @@ goog.provide('Blockly.Blocks.procedures');
|
||||
|
||||
goog.require('Blockly');
|
||||
goog.require('Blockly.Blocks');
|
||||
goog.require('Blockly.Comment');
|
||||
goog.require('Blockly.FieldCheckbox');
|
||||
goog.require('Blockly.FieldLabel');
|
||||
goog.require('Blockly.FieldTextInput');
|
||||
|
||||
1
build.py
1
build.py
@@ -248,6 +248,7 @@ class Gen_compressed(threading.Thread):
|
||||
params.append(("js_code", """
|
||||
goog.provide('Blockly');
|
||||
goog.provide('Blockly.Blocks');
|
||||
goog.provide('Blockly.Comment');
|
||||
goog.provide('Blockly.FieldCheckbox');
|
||||
goog.provide('Blockly.FieldColour');
|
||||
goog.provide('Blockly.FieldDropdown');
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
goog.provide('Blockly.Block');
|
||||
|
||||
goog.require('Blockly.Blocks');
|
||||
goog.require('Blockly.Comment');
|
||||
goog.require('Blockly.Connection');
|
||||
goog.require('Blockly.Events');
|
||||
goog.require('Blockly.Events.BlockChange');
|
||||
|
||||
@@ -1092,6 +1092,9 @@ Blockly.BlockSvg.prototype.setCommentText = function(text) {
|
||||
var changedState = false;
|
||||
if (typeof text == 'string') {
|
||||
if (!this.comment) {
|
||||
if (!Blockly.Comment) {
|
||||
throw Error('Missing require for Blockly.Comment');
|
||||
}
|
||||
this.comment = new Blockly.Comment(this);
|
||||
changedState = true;
|
||||
}
|
||||
|
||||
@@ -27,26 +27,41 @@
|
||||
|
||||
goog.provide('Blockly.requires');
|
||||
|
||||
// Blockly Core.
|
||||
// Blockly Core (absolutely mandatory).
|
||||
goog.require('Blockly');
|
||||
goog.require('Blockly.Mutator');
|
||||
|
||||
|
||||
// If block comments aren't required, then Blockly.inject's "comments"
|
||||
// configuration must be false, and no blocks may be loaded from XML which
|
||||
// define comments.
|
||||
goog.require('Blockly.Comment');
|
||||
// If a trashcan on the workspace isn't required, then Blockly.inject's
|
||||
// "trashcan" configuration must be false.
|
||||
goog.require('Blockly.Trashcan');
|
||||
// If zoom controls aren't required, then Blockly.inject's
|
||||
// "zoom"/"controls" configuration must be false.
|
||||
goog.require('Blockly.ZoomControls');
|
||||
// Blockly Fields.
|
||||
goog.require('Blockly.FieldAngle');
|
||||
goog.require('Blockly.FieldCheckbox');
|
||||
goog.require('Blockly.FieldColour');
|
||||
// Date picker commented out since it increases footprint by 60%.
|
||||
// Add it only if you need it.
|
||||
// goog.require('Blockly.FieldDate');
|
||||
goog.require('Blockly.FieldDropdown');
|
||||
goog.require('Blockly.FieldLabelSerializable');
|
||||
goog.require('Blockly.FieldImage');
|
||||
goog.require('Blockly.FieldTextInput');
|
||||
goog.require('Blockly.FieldMultilineInput');
|
||||
goog.require('Blockly.FieldNumber');
|
||||
goog.require('Blockly.FieldVariable');
|
||||
|
||||
|
||||
// Block dependencies.
|
||||
// None of these should be required since individual block files should
|
||||
// include the requirements they depend on.
|
||||
// goog.require('Blockly.Mutator');
|
||||
// goog.require('Blockly.FieldAngle');
|
||||
// goog.require('Blockly.FieldCheckbox');
|
||||
// goog.require('Blockly.FieldColour');
|
||||
// goog.require('Blockly.FieldDropdown');
|
||||
// goog.require('Blockly.FieldLabelSerializable');
|
||||
// goog.require('Blockly.FieldImage');
|
||||
// goog.require('Blockly.FieldTextInput');
|
||||
// goog.require('Blockly.FieldMultilineInput');
|
||||
// goog.require('Blockly.FieldNumber');
|
||||
// goog.require('Blockly.FieldVariable');
|
||||
|
||||
|
||||
// Blockly Renderers.
|
||||
// At least one renderer is mandatory. Geras is the default one.
|
||||
// Others may be chosen using Blockly.inject's "renderer" configuration.
|
||||
goog.require('Blockly.geras.Renderer');
|
||||
goog.require('Blockly.thrasos.Renderer');
|
||||
goog.require('Blockly.zelos.Renderer');
|
||||
// goog.require('Blockly.thrasos.Renderer');
|
||||
// goog.require('Blockly.zelos.Renderer');
|
||||
|
||||
@@ -141,6 +141,7 @@ gulp.task('build-blocks', function () {
|
||||
const provides = `
|
||||
goog.provide('Blockly');
|
||||
goog.provide('Blockly.Blocks');
|
||||
goog.provide('Blockly.Comment');
|
||||
goog.provide('Blockly.FieldCheckbox');
|
||||
goog.provide('Blockly.FieldColour');
|
||||
goog.provide('Blockly.FieldDropdown');
|
||||
|
||||
Reference in New Issue
Block a user