blockly 7.20211209.2 → 8.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/blockly.d.ts +18963 -18432
- package/blockly.min.js +852 -844
- package/blockly_compressed.js +669 -664
- package/blockly_compressed.js.map +1 -1
- package/blocks/blocks.js +47 -0
- package/blocks/colour.js +13 -3
- package/blocks/lists.js +22 -13
- package/blocks/logic.js +13 -3
- package/blocks/loops.js +24 -11
- package/blocks/math.js +12 -3
- package/blocks/procedures.js +41 -27
- package/blocks/text.js +22 -13
- package/blocks/variables.js +14 -3
- package/blocks/variables_dynamic.js +13 -3
- package/blocks_compressed.js +146 -141
- package/blocks_compressed.js.map +1 -1
- package/core/block.js +1869 -1814
- package/core/block_drag_surface.js +201 -200
- package/core/block_dragger.js +377 -373
- package/core/block_svg.js +1593 -1479
- package/core/blockly.js +8 -22
- package/core/blocks.js +9 -2
- package/core/browser_events.js +22 -5
- package/core/bubble.js +841 -797
- package/core/bubble_dragger.js +213 -206
- package/core/bump_objects.js +2 -2
- package/core/clipboard.js +9 -9
- package/core/comment.js +353 -332
- package/core/common.js +46 -17
- package/core/component_manager.js +181 -174
- package/core/config.js +87 -0
- package/core/connection.js +595 -584
- package/core/connection_checker.js +242 -244
- package/core/connection_db.js +235 -230
- package/core/contextmenu.js +9 -6
- package/core/contextmenu_items.js +1 -2
- package/core/contextmenu_registry.js +93 -89
- package/core/css.js +474 -474
- package/core/delete_area.js +45 -42
- package/core/drag_target.js +57 -56
- package/core/dropdowndiv.js +153 -163
- package/core/events/events.js +2 -2
- package/core/events/events_abstract.js +89 -77
- package/core/events/events_block_base.js +37 -36
- package/core/events/events_block_change.js +130 -124
- package/core/events/events_block_create.js +73 -71
- package/core/events/events_block_delete.js +84 -82
- package/core/events/events_block_drag.js +50 -49
- package/core/events/events_block_move.js +147 -140
- package/core/events/events_bubble_open.js +51 -50
- package/core/events/events_click.js +48 -44
- package/core/events/events_comment_base.js +72 -69
- package/core/events/events_comment_change.js +63 -61
- package/core/events/events_comment_create.js +44 -42
- package/core/events/events_comment_delete.js +42 -40
- package/core/events/events_comment_move.js +106 -104
- package/core/events/events_marker_move.js +65 -64
- package/core/events/events_selected.js +46 -45
- package/core/events/events_theme_change.js +36 -35
- package/core/events/events_toolbox_item_select.js +46 -45
- package/core/events/events_trashcan_open.js +37 -36
- package/core/events/events_ui.js +47 -46
- package/core/events/events_ui_base.js +30 -29
- package/core/events/events_var_base.js +37 -36
- package/core/events/events_var_create.js +50 -48
- package/core/events/events_var_delete.js +50 -48
- package/core/events/events_var_rename.js +51 -49
- package/core/events/events_viewport.js +66 -65
- package/core/events/utils.js +29 -14
- package/core/events/workspace_events.js +49 -55
- package/core/extensions.js +4 -3
- package/core/field.js +1061 -997
- package/core/field_angle.js +462 -442
- package/core/field_checkbox.js +194 -182
- package/core/field_colour.js +519 -505
- package/core/field_dropdown.js +617 -598
- package/core/field_image.js +229 -220
- package/core/field_label.js +102 -91
- package/core/field_label_serializable.js +42 -41
- package/core/field_multilineinput.js +372 -358
- package/core/field_number.js +272 -253
- package/core/field_textinput.js +499 -467
- package/core/field_variable.js +458 -420
- package/core/flyout_base.js +1005 -952
- package/core/flyout_button.js +277 -260
- package/core/flyout_horizontal.js +304 -302
- package/core/flyout_metrics_manager.js +64 -64
- package/core/flyout_vertical.js +306 -300
- package/core/generator.js +459 -446
- package/core/gesture.js +829 -813
- package/core/grid.js +166 -163
- package/core/icon.js +168 -159
- package/core/inject.js +7 -5
- package/core/input.js +257 -248
- package/core/insertion_marker_manager.js +655 -624
- package/core/internal_constants.js +0 -129
- package/core/keyboard_nav/ast_node.js +605 -596
- package/core/keyboard_nav/basic_cursor.js +166 -165
- package/core/keyboard_nav/cursor.js +99 -97
- package/core/keyboard_nav/marker.js +83 -79
- package/core/keyboard_nav/tab_navigate_cursor.js +18 -23
- package/core/marker_manager.js +153 -141
- package/core/menu.js +377 -372
- package/core/menuitem.js +223 -217
- package/core/metrics_manager.js +403 -390
- package/core/mutator.js +468 -437
- package/core/names.js +229 -188
- package/core/options.js +290 -284
- package/core/procedures.js +29 -17
- package/core/registry.js +19 -16
- package/core/rendered_connection.js +482 -463
- package/core/renderers/common/block_rendering.js +9 -3
- package/core/renderers/common/constants.js +1119 -1112
- package/core/renderers/common/debug.js +14 -0
- package/core/renderers/common/debugger.js +338 -316
- package/core/renderers/common/drawer.js +380 -370
- package/core/renderers/common/i_path_object.js +2 -2
- package/core/renderers/common/info.js +626 -618
- package/core/renderers/common/marker_svg.js +579 -541
- package/core/renderers/common/path_object.js +203 -200
- package/core/renderers/common/renderer.js +220 -218
- package/core/renderers/geras/constants.js +36 -36
- package/core/renderers/geras/drawer.js +155 -147
- package/core/renderers/geras/highlight_constants.js +244 -238
- package/core/renderers/geras/highlighter.js +231 -179
- package/core/renderers/geras/info.js +392 -369
- package/core/renderers/geras/measurables/inline_input.js +25 -19
- package/core/renderers/geras/measurables/statement_input.js +23 -17
- package/core/renderers/geras/path_object.js +106 -121
- package/core/renderers/geras/renderer.js +96 -98
- package/core/renderers/measurables/base.js +30 -18
- package/core/renderers/measurables/bottom_row.js +83 -80
- package/core/renderers/measurables/connection.js +22 -15
- package/core/renderers/measurables/external_value_input.js +35 -22
- package/core/renderers/measurables/field.js +35 -20
- package/core/renderers/measurables/hat.js +18 -13
- package/core/renderers/measurables/icon.js +24 -17
- package/core/renderers/measurables/in_row_spacer.js +15 -13
- package/core/renderers/measurables/inline_input.js +43 -33
- package/core/renderers/measurables/input_connection.js +41 -28
- package/core/renderers/measurables/input_row.js +50 -44
- package/core/renderers/measurables/jagged_edge.js +14 -12
- package/core/renderers/measurables/next_connection.js +16 -14
- package/core/renderers/measurables/output_connection.js +26 -20
- package/core/renderers/measurables/previous_connection.js +16 -15
- package/core/renderers/measurables/round_corner.js +20 -18
- package/core/renderers/measurables/row.js +184 -168
- package/core/renderers/measurables/spacer_row.js +38 -23
- package/core/renderers/measurables/square_corner.js +18 -16
- package/core/renderers/measurables/statement_input.js +23 -20
- package/core/renderers/measurables/top_row.js +88 -85
- package/core/renderers/minimalist/constants.js +8 -7
- package/core/renderers/minimalist/drawer.js +11 -10
- package/core/renderers/minimalist/info.js +18 -18
- package/core/renderers/minimalist/renderer.js +40 -39
- package/core/renderers/thrasos/info.js +258 -248
- package/core/renderers/thrasos/renderer.js +20 -20
- package/core/renderers/zelos/constants.js +898 -873
- package/core/renderers/zelos/drawer.js +186 -169
- package/core/renderers/zelos/info.js +502 -479
- package/core/renderers/zelos/marker_svg.js +129 -115
- package/core/renderers/zelos/measurables/bottom_row.js +31 -30
- package/core/renderers/zelos/measurables/inputs.js +22 -21
- package/core/renderers/zelos/measurables/row_elements.js +14 -13
- package/core/renderers/zelos/measurables/top_row.js +34 -33
- package/core/renderers/zelos/path_object.js +181 -180
- package/core/renderers/zelos/renderer.js +91 -92
- package/core/scrollbar.js +759 -713
- package/core/scrollbar_pair.js +250 -245
- package/core/serialization/blocks.js +19 -9
- package/core/serialization/workspaces.js +3 -2
- package/core/shortcut_registry.js +286 -277
- package/core/sprites.js +31 -0
- package/core/theme.js +135 -141
- package/core/theme_manager.js +147 -143
- package/core/toolbox/category.js +602 -576
- package/core/toolbox/collapsible_category.js +226 -227
- package/core/toolbox/separator.js +70 -61
- package/core/toolbox/toolbox.js +934 -927
- package/core/toolbox/toolbox_item.js +115 -99
- package/core/tooltip.js +108 -35
- package/core/touch.js +8 -3
- package/core/touch_gesture.js +254 -251
- package/core/trashcan.js +606 -595
- package/core/utils/coordinate.js +97 -95
- package/core/utils/dom.js +2 -2
- package/core/utils/global.js +2 -0
- package/core/utils/rect.js +41 -37
- package/core/utils/sentinel.js +25 -0
- package/core/utils/size.js +30 -27
- package/core/utils/svg.js +18 -16
- package/core/variable_map.js +325 -341
- package/core/variable_model.js +55 -54
- package/core/variables.js +9 -2
- package/core/variables_dynamic.js +3 -1
- package/core/warning.js +126 -120
- package/core/widgetdiv.js +4 -4
- package/core/workspace.js +685 -664
- package/core/workspace_audio.js +124 -118
- package/core/workspace_comment.js +308 -298
- package/core/workspace_comment_svg.js +1029 -951
- package/core/workspace_drag_surface_svg.js +147 -140
- package/core/workspace_dragger.js +70 -71
- package/core/workspace_svg.js +2322 -2297
- package/core/xml.js +30 -20
- package/core/zoom_controls.js +431 -439
- package/dart_compressed.js +40 -43
- package/dart_compressed.js.map +1 -1
- package/generators/dart/colour.js +56 -64
- package/generators/dart/lists.js +61 -50
- package/generators/dart/math.js +160 -148
- package/generators/dart/text.js +83 -61
- package/generators/javascript/colour.js +37 -34
- package/generators/javascript/lists.js +50 -43
- package/generators/javascript/math.js +123 -139
- package/generators/javascript/text.js +67 -81
- package/generators/lua/colour.js +25 -23
- package/generators/lua/lists.js +97 -69
- package/generators/lua/logic.js +1 -2
- package/generators/lua/math.js +182 -144
- package/generators/lua/text.js +116 -99
- package/generators/php/colour.js +38 -32
- package/generators/php/lists.js +109 -89
- package/generators/php/math.js +90 -81
- package/generators/php/text.js +63 -61
- package/generators/python/colour.js +18 -18
- package/generators/python/lists.js +38 -30
- package/generators/python/loops.js +12 -8
- package/generators/python/math.js +104 -106
- package/generators/python/text.js +34 -30
- package/javascript_compressed.js +37 -39
- package/javascript_compressed.js.map +1 -1
- package/lua_compressed.js +39 -42
- package/lua_compressed.js.map +1 -1
- package/msg/az.js +2 -2
- package/msg/be.js +4 -4
- package/msg/cs.js +15 -15
- package/msg/de.js +1 -1
- package/msg/diq.js +1 -1
- package/msg/eo.js +1 -1
- package/msg/es.js +1 -1
- package/msg/fa.js +1 -1
- package/msg/fr.js +4 -4
- package/msg/he.js +1 -1
- package/msg/hr.js +2 -2
- package/msg/hy.js +2 -2
- package/msg/id.js +12 -12
- package/msg/inh.js +14 -14
- package/msg/ja.js +7 -7
- package/msg/lv.js +29 -29
- package/msg/pa.js +3 -3
- package/msg/smn.js +436 -0
- package/msg/te.js +1 -1
- package/msg/yue.js +1 -1
- package/msg/zh-hans.js +3 -3
- package/msg/zh-hant.js +3 -3
- package/package.json +7 -6
- package/php_compressed.js +38 -42
- package/php_compressed.js.map +1 -1
- package/python_compressed.js +26 -25
- package/python_compressed.js.map +1 -1
- package/blocks/all.js +0 -23
package/core/icon.js
CHANGED
|
@@ -29,188 +29,197 @@ const {Svg} = goog.require('Blockly.utils.Svg');
|
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
31
|
* Class for an icon.
|
|
32
|
-
* @param {BlockSvg} block The block associated with this icon.
|
|
33
|
-
* @constructor
|
|
34
32
|
* @abstract
|
|
35
33
|
* @alias Blockly.Icon
|
|
36
34
|
*/
|
|
37
|
-
|
|
35
|
+
class Icon {
|
|
38
36
|
/**
|
|
39
|
-
* The block this icon
|
|
40
|
-
* @type {BlockSvg}
|
|
41
|
-
* @protected
|
|
37
|
+
* @param {BlockSvg} block The block associated with this icon.
|
|
42
38
|
*/
|
|
43
|
-
|
|
39
|
+
constructor(block) {
|
|
40
|
+
/**
|
|
41
|
+
* The block this icon is attached to.
|
|
42
|
+
* @type {BlockSvg}
|
|
43
|
+
* @protected
|
|
44
|
+
*/
|
|
45
|
+
this.block_ = block;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* The icon SVG group.
|
|
49
|
+
* @type {?SVGGElement}
|
|
50
|
+
*/
|
|
51
|
+
this.iconGroup_ = null;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Whether this icon gets hidden when the block is collapsed.
|
|
55
|
+
* @type {boolean}
|
|
56
|
+
*/
|
|
57
|
+
this.collapseHidden = true;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Height and width of icons.
|
|
61
|
+
* @const
|
|
62
|
+
*/
|
|
63
|
+
this.SIZE = 17;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Bubble UI (if visible).
|
|
67
|
+
* @type {?Bubble}
|
|
68
|
+
* @protected
|
|
69
|
+
*/
|
|
70
|
+
this.bubble_ = null;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Absolute coordinate of icon's center.
|
|
74
|
+
* @type {?Coordinate}
|
|
75
|
+
* @protected
|
|
76
|
+
*/
|
|
77
|
+
this.iconXY_ = null;
|
|
78
|
+
}
|
|
44
79
|
|
|
45
80
|
/**
|
|
46
|
-
*
|
|
47
|
-
* @type {?SVGGElement}
|
|
81
|
+
* Create the icon on the block.
|
|
48
82
|
*/
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
* @type {?Coordinate}
|
|
73
|
-
* @protected
|
|
74
|
-
*/
|
|
75
|
-
Icon.prototype.iconXY_ = null;
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Create the icon on the block.
|
|
79
|
-
*/
|
|
80
|
-
Icon.prototype.createIcon = function() {
|
|
81
|
-
if (this.iconGroup_) {
|
|
82
|
-
// Icon already exists.
|
|
83
|
-
return;
|
|
83
|
+
createIcon() {
|
|
84
|
+
if (this.iconGroup_) {
|
|
85
|
+
// Icon already exists.
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
/* Here's the markup that will be generated:
|
|
89
|
+
<g class="blocklyIconGroup">
|
|
90
|
+
...
|
|
91
|
+
</g>
|
|
92
|
+
*/
|
|
93
|
+
this.iconGroup_ =
|
|
94
|
+
dom.createSvgElement(Svg.G, {'class': 'blocklyIconGroup'}, null);
|
|
95
|
+
if (this.block_.isInFlyout) {
|
|
96
|
+
dom.addClass(
|
|
97
|
+
/** @type {!Element} */ (this.iconGroup_),
|
|
98
|
+
'blocklyIconGroupReadonly');
|
|
99
|
+
}
|
|
100
|
+
this.drawIcon_(this.iconGroup_);
|
|
101
|
+
|
|
102
|
+
this.block_.getSvgRoot().appendChild(this.iconGroup_);
|
|
103
|
+
browserEvents.conditionalBind(
|
|
104
|
+
this.iconGroup_, 'mouseup', this, this.iconClick_);
|
|
105
|
+
this.updateEditable();
|
|
84
106
|
}
|
|
85
|
-
/* Here's the markup that will be generated:
|
|
86
|
-
<g class="blocklyIconGroup">
|
|
87
|
-
...
|
|
88
|
-
</g>
|
|
89
|
-
*/
|
|
90
|
-
this.iconGroup_ =
|
|
91
|
-
dom.createSvgElement(Svg.G, {'class': 'blocklyIconGroup'}, null);
|
|
92
|
-
if (this.block_.isInFlyout) {
|
|
93
|
-
dom.addClass(
|
|
94
|
-
/** @type {!Element} */ (this.iconGroup_), 'blocklyIconGroupReadonly');
|
|
95
|
-
}
|
|
96
|
-
this.drawIcon_(this.iconGroup_);
|
|
97
|
-
|
|
98
|
-
this.block_.getSvgRoot().appendChild(this.iconGroup_);
|
|
99
|
-
browserEvents.conditionalBind(
|
|
100
|
-
this.iconGroup_, 'mouseup', this, this.iconClick_);
|
|
101
|
-
this.updateEditable();
|
|
102
|
-
};
|
|
103
107
|
|
|
104
|
-
/**
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Add or remove the UI indicating if this icon may be clicked or not.
|
|
118
|
-
*/
|
|
119
|
-
Icon.prototype.updateEditable = function() {
|
|
120
|
-
// No-op on the base class.
|
|
121
|
-
};
|
|
108
|
+
/**
|
|
109
|
+
* Dispose of this icon.
|
|
110
|
+
*/
|
|
111
|
+
dispose() {
|
|
112
|
+
// Dispose of and unlink the icon.
|
|
113
|
+
dom.removeNode(this.iconGroup_);
|
|
114
|
+
this.iconGroup_ = null;
|
|
115
|
+
// Dispose of and unlink the bubble.
|
|
116
|
+
this.setVisible(false);
|
|
117
|
+
this.block_ = null;
|
|
118
|
+
}
|
|
122
119
|
|
|
123
|
-
/**
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
};
|
|
120
|
+
/**
|
|
121
|
+
* Add or remove the UI indicating if this icon may be clicked or not.
|
|
122
|
+
*/
|
|
123
|
+
updateEditable() {
|
|
124
|
+
// No-op on the base class.
|
|
125
|
+
}
|
|
130
126
|
|
|
131
|
-
/**
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
if (this.block_.workspace.isDragging()) {
|
|
138
|
-
// Drag operation is concluding. Don't open the editor.
|
|
139
|
-
return;
|
|
127
|
+
/**
|
|
128
|
+
* Is the associated bubble visible?
|
|
129
|
+
* @return {boolean} True if the bubble is visible.
|
|
130
|
+
*/
|
|
131
|
+
isVisible() {
|
|
132
|
+
return !!this.bubble_;
|
|
140
133
|
}
|
|
141
|
-
|
|
142
|
-
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Clicking on the icon toggles if the bubble is visible.
|
|
137
|
+
* @param {!Event} e Mouse click event.
|
|
138
|
+
* @protected
|
|
139
|
+
*/
|
|
140
|
+
iconClick_(e) {
|
|
141
|
+
if (this.block_.workspace.isDragging()) {
|
|
142
|
+
// Drag operation is concluding. Don't open the editor.
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
if (!this.block_.isInFlyout && !browserEvents.isRightButton(e)) {
|
|
146
|
+
this.setVisible(!this.isVisible());
|
|
147
|
+
}
|
|
143
148
|
}
|
|
144
|
-
};
|
|
145
149
|
|
|
146
|
-
/**
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
150
|
+
/**
|
|
151
|
+
* Change the colour of the associated bubble to match its block.
|
|
152
|
+
*/
|
|
153
|
+
applyColour() {
|
|
154
|
+
if (this.isVisible()) {
|
|
155
|
+
this.bubble_.setColour(this.block_.style.colourPrimary);
|
|
156
|
+
}
|
|
152
157
|
}
|
|
153
|
-
};
|
|
154
158
|
|
|
155
|
-
/**
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
159
|
+
/**
|
|
160
|
+
* Notification that the icon has moved. Update the arrow accordingly.
|
|
161
|
+
* @param {!Coordinate} xy Absolute location in workspace coordinates.
|
|
162
|
+
*/
|
|
163
|
+
setIconLocation(xy) {
|
|
164
|
+
this.iconXY_ = xy;
|
|
165
|
+
if (this.isVisible()) {
|
|
166
|
+
this.bubble_.setAnchorLocation(xy);
|
|
167
|
+
}
|
|
163
168
|
}
|
|
164
|
-
};
|
|
165
169
|
|
|
166
|
-
/**
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
170
|
+
/**
|
|
171
|
+
* Notification that the icon has moved, but we don't really know where.
|
|
172
|
+
* Recompute the icon's location from scratch.
|
|
173
|
+
*/
|
|
174
|
+
computeIconLocation() {
|
|
175
|
+
// Find coordinates for the centre of the icon and update the arrow.
|
|
176
|
+
const blockXY = this.block_.getRelativeToSurfaceXY();
|
|
177
|
+
const iconXY = svgMath.getRelativeXY(
|
|
178
|
+
/** @type {!SVGElement} */ (this.iconGroup_));
|
|
179
|
+
const newXY = new Coordinate(
|
|
180
|
+
blockXY.x + iconXY.x + this.SIZE / 2,
|
|
181
|
+
blockXY.y + iconXY.y + this.SIZE / 2);
|
|
182
|
+
if (!Coordinate.equals(this.getIconLocation(), newXY)) {
|
|
183
|
+
this.setIconLocation(newXY);
|
|
184
|
+
}
|
|
180
185
|
}
|
|
181
|
-
};
|
|
182
186
|
|
|
183
|
-
/**
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
}
|
|
187
|
+
/**
|
|
188
|
+
* Returns the center of the block's icon relative to the surface.
|
|
189
|
+
* @return {?Coordinate} Object with x and y properties in
|
|
190
|
+
* workspace coordinates.
|
|
191
|
+
*/
|
|
192
|
+
getIconLocation() {
|
|
193
|
+
return this.iconXY_;
|
|
194
|
+
}
|
|
191
195
|
|
|
192
|
-
/**
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
}
|
|
196
|
+
/**
|
|
197
|
+
* Get the size of the icon as used for rendering.
|
|
198
|
+
* This differs from the actual size of the icon, because it bulges slightly
|
|
199
|
+
* out of its row rather than increasing the height of its row.
|
|
200
|
+
* @return {!Size} Height and width.
|
|
201
|
+
*/
|
|
202
|
+
getCorrectedSize() {
|
|
203
|
+
// TODO (#2562): Remove getCorrectedSize.
|
|
204
|
+
return new Size(this.SIZE, this.SIZE - 2);
|
|
205
|
+
}
|
|
202
206
|
|
|
203
|
-
/**
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
207
|
+
/**
|
|
208
|
+
* Draw the icon.
|
|
209
|
+
* @param {!Element} _group The icon group.
|
|
210
|
+
* @protected
|
|
211
|
+
*/
|
|
212
|
+
drawIcon_(_group) {
|
|
213
|
+
// No-op on base class.
|
|
214
|
+
}
|
|
209
215
|
|
|
210
|
-
/**
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
216
|
+
/**
|
|
217
|
+
* Show or hide the icon.
|
|
218
|
+
* @param {boolean} _visible True if the icon should be visible.
|
|
219
|
+
*/
|
|
220
|
+
setVisible(_visible) {
|
|
221
|
+
// No-op on base class
|
|
222
|
+
}
|
|
223
|
+
}
|
|
215
224
|
|
|
216
225
|
exports.Icon = Icon;
|
package/core/inject.js
CHANGED
|
@@ -24,11 +24,11 @@ const browserEvents = goog.require('Blockly.browserEvents');
|
|
|
24
24
|
const bumpObjects = goog.require('Blockly.bumpObjects');
|
|
25
25
|
const common = goog.require('Blockly.common');
|
|
26
26
|
const dom = goog.require('Blockly.utils.dom');
|
|
27
|
+
const dropDownDiv = goog.require('Blockly.dropDownDiv');
|
|
27
28
|
const userAgent = goog.require('Blockly.utils.userAgent');
|
|
28
29
|
const {BlockDragSurfaceSvg} = goog.require('Blockly.BlockDragSurfaceSvg');
|
|
29
30
|
/* eslint-disable-next-line no-unused-vars */
|
|
30
31
|
const {BlocklyOptions} = goog.requireType('Blockly.BlocklyOptions');
|
|
31
|
-
const {DropDownDiv} = goog.require('Blockly.DropDownDiv');
|
|
32
32
|
const {Grid} = goog.require('Blockly.Grid');
|
|
33
33
|
const {Msg} = goog.require('Blockly.Msg');
|
|
34
34
|
const {Options} = goog.require('Blockly.Options');
|
|
@@ -59,7 +59,8 @@ const inject = function(container, opt_options) {
|
|
|
59
59
|
}
|
|
60
60
|
const options =
|
|
61
61
|
new Options(opt_options || (/** @type {!BlocklyOptions} */ ({})));
|
|
62
|
-
const subContainer =
|
|
62
|
+
const subContainer =
|
|
63
|
+
/** @type {!HTMLDivElement} */ (document.createElement('div'));
|
|
63
64
|
subContainer.className = 'injectionDiv';
|
|
64
65
|
subContainer.tabIndex = 0;
|
|
65
66
|
aria.setState(subContainer, aria.State.LABEL, Msg['WORKSPACE_ARIA_LABEL']);
|
|
@@ -192,7 +193,7 @@ const createMainWorkspace = function(
|
|
|
192
193
|
// The SVG is now fully assembled.
|
|
193
194
|
common.svgResize(mainWorkspace);
|
|
194
195
|
WidgetDiv.createDom();
|
|
195
|
-
|
|
196
|
+
dropDownDiv.createDom();
|
|
196
197
|
Tooltip.createDom();
|
|
197
198
|
return mainWorkspace;
|
|
198
199
|
};
|
|
@@ -274,7 +275,8 @@ const init = function(mainWorkspace) {
|
|
|
274
275
|
// TODO (https://github.com/google/blockly/issues/1998) handle cases where there
|
|
275
276
|
// are multiple workspaces and non-main workspaces are able to accept input.
|
|
276
277
|
const onKeyDown = function(e) {
|
|
277
|
-
const mainWorkspace =
|
|
278
|
+
const mainWorkspace =
|
|
279
|
+
/** @type {!WorkspaceSvg} */ (common.getMainWorkspace());
|
|
278
280
|
if (!mainWorkspace) {
|
|
279
281
|
return;
|
|
280
282
|
}
|
|
@@ -337,7 +339,7 @@ const bindDocumentEvents = function() {
|
|
|
337
339
|
/**
|
|
338
340
|
* Load sounds for the given workspace.
|
|
339
341
|
* @param {string} pathToMedia The path to the media directory.
|
|
340
|
-
* @param {!
|
|
342
|
+
* @param {!WorkspaceSvg} workspace The workspace to load sounds for.
|
|
341
343
|
*/
|
|
342
344
|
const loadSounds = function(pathToMedia, workspace) {
|
|
343
345
|
const audioMgr = workspace.getAudioManager();
|