blockly 7.20211209.4 → 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/bubble_dragger.js
CHANGED
|
@@ -19,6 +19,8 @@ const eventUtils = goog.require('Blockly.Events.utils');
|
|
|
19
19
|
const svgMath = goog.require('Blockly.utils.svgMath');
|
|
20
20
|
/* eslint-disable-next-line no-unused-vars */
|
|
21
21
|
const {BlockDragSurfaceSvg} = goog.requireType('Blockly.BlockDragSurfaceSvg');
|
|
22
|
+
/* eslint-disable-next-line no-unused-vars */
|
|
23
|
+
const {CommentMove} = goog.requireType('Blockly.Events.CommentMove');
|
|
22
24
|
const {ComponentManager} = goog.require('Blockly.ComponentManager');
|
|
23
25
|
const {Coordinate} = goog.require('Blockly.utils.Coordinate');
|
|
24
26
|
/* eslint-disable-next-line no-unused-vars */
|
|
@@ -43,249 +45,254 @@ goog.require('Blockly.constants');
|
|
|
43
45
|
* Class for a bubble dragger. It moves things on the bubble canvas around the
|
|
44
46
|
* workspace when they are being dragged by a mouse or touch. These can be
|
|
45
47
|
* block comments, mutators, warnings, or workspace comments.
|
|
46
|
-
* @param {!IBubble} bubble The item on the bubble canvas to drag.
|
|
47
|
-
* @param {!WorkspaceSvg} workspace The workspace to drag on.
|
|
48
|
-
* @constructor
|
|
49
48
|
* @alias Blockly.BubbleDragger
|
|
50
49
|
*/
|
|
51
|
-
const BubbleDragger =
|
|
50
|
+
const BubbleDragger = class {
|
|
52
51
|
/**
|
|
53
|
-
* The item on the bubble canvas
|
|
54
|
-
* @
|
|
55
|
-
* @private
|
|
52
|
+
* @param {!IBubble} bubble The item on the bubble canvas to drag.
|
|
53
|
+
* @param {!WorkspaceSvg} workspace The workspace to drag on.
|
|
56
54
|
*/
|
|
57
|
-
|
|
55
|
+
constructor(bubble, workspace) {
|
|
56
|
+
/**
|
|
57
|
+
* The item on the bubble canvas that is being dragged.
|
|
58
|
+
* @type {!IBubble}
|
|
59
|
+
* @private
|
|
60
|
+
*/
|
|
61
|
+
this.draggingBubble_ = bubble;
|
|
58
62
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
/**
|
|
64
|
+
* The workspace on which the bubble is being dragged.
|
|
65
|
+
* @type {!WorkspaceSvg}
|
|
66
|
+
* @private
|
|
67
|
+
*/
|
|
68
|
+
this.workspace_ = workspace;
|
|
65
69
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
/**
|
|
71
|
+
* Which drag target the mouse pointer is over, if any.
|
|
72
|
+
* @type {?IDragTarget}
|
|
73
|
+
* @private
|
|
74
|
+
*/
|
|
75
|
+
this.dragTarget_ = null;
|
|
72
76
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
/**
|
|
78
|
+
* Whether the bubble would be deleted if dropped immediately.
|
|
79
|
+
* @type {boolean}
|
|
80
|
+
* @private
|
|
81
|
+
*/
|
|
82
|
+
this.wouldDeleteBubble_ = false;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* The location of the top left corner of the dragging bubble's body at the
|
|
86
|
+
* beginning of the drag, in workspace coordinates.
|
|
87
|
+
* @type {!Coordinate}
|
|
88
|
+
* @private
|
|
89
|
+
*/
|
|
90
|
+
this.startXY_ = this.draggingBubble_.getRelativeToSurfaceXY();
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* The drag surface to move bubbles to during a drag, or null if none should
|
|
94
|
+
* be used. Block dragging and bubble dragging use the same surface.
|
|
95
|
+
* @type {BlockDragSurfaceSvg}
|
|
96
|
+
* @private
|
|
97
|
+
*/
|
|
98
|
+
this.dragSurface_ =
|
|
99
|
+
svgMath.is3dSupported() && !!workspace.getBlockDragSurface() ?
|
|
100
|
+
workspace.getBlockDragSurface() :
|
|
101
|
+
null;
|
|
102
|
+
}
|
|
79
103
|
|
|
80
104
|
/**
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
* @
|
|
84
|
-
* @private
|
|
105
|
+
* Sever all links from this object.
|
|
106
|
+
* @package
|
|
107
|
+
* @suppress {checkTypes}
|
|
85
108
|
*/
|
|
86
|
-
|
|
109
|
+
dispose() {
|
|
110
|
+
this.draggingBubble_ = null;
|
|
111
|
+
this.workspace_ = null;
|
|
112
|
+
this.dragSurface_ = null;
|
|
113
|
+
}
|
|
87
114
|
|
|
88
115
|
/**
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
* @type {BlockDragSurfaceSvg}
|
|
92
|
-
* @private
|
|
116
|
+
* Start dragging a bubble. This includes moving it to the drag surface.
|
|
117
|
+
* @package
|
|
93
118
|
*/
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Sever all links from this object.
|
|
102
|
-
* @package
|
|
103
|
-
* @suppress {checkTypes}
|
|
104
|
-
*/
|
|
105
|
-
BubbleDragger.prototype.dispose = function() {
|
|
106
|
-
this.draggingBubble_ = null;
|
|
107
|
-
this.workspace_ = null;
|
|
108
|
-
this.dragSurface_ = null;
|
|
109
|
-
};
|
|
119
|
+
startBubbleDrag() {
|
|
120
|
+
if (!eventUtils.getGroup()) {
|
|
121
|
+
eventUtils.setGroup(true);
|
|
122
|
+
}
|
|
110
123
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
if (!eventUtils.getGroup()) {
|
|
117
|
-
eventUtils.setGroup(true);
|
|
118
|
-
}
|
|
124
|
+
this.workspace_.setResizesEnabled(false);
|
|
125
|
+
this.draggingBubble_.setAutoLayout(false);
|
|
126
|
+
if (this.dragSurface_) {
|
|
127
|
+
this.moveToDragSurface_();
|
|
128
|
+
}
|
|
119
129
|
|
|
120
|
-
|
|
121
|
-
this.draggingBubble_.setAutoLayout(false);
|
|
122
|
-
if (this.dragSurface_) {
|
|
123
|
-
this.moveToDragSurface_();
|
|
130
|
+
this.draggingBubble_.setDragging && this.draggingBubble_.setDragging(true);
|
|
124
131
|
}
|
|
125
132
|
|
|
126
|
-
|
|
127
|
-
|
|
133
|
+
/**
|
|
134
|
+
* Execute a step of bubble dragging, based on the given event. Update the
|
|
135
|
+
* display accordingly.
|
|
136
|
+
* @param {!Event} e The most recent move event.
|
|
137
|
+
* @param {!Coordinate} currentDragDeltaXY How far the pointer has
|
|
138
|
+
* moved from the position at the start of the drag, in pixel units.
|
|
139
|
+
* @package
|
|
140
|
+
*/
|
|
141
|
+
dragBubble(e, currentDragDeltaXY) {
|
|
142
|
+
const delta = this.pixelsToWorkspaceUnits_(currentDragDeltaXY);
|
|
143
|
+
const newLoc = Coordinate.sum(this.startXY_, delta);
|
|
144
|
+
this.draggingBubble_.moveDuringDrag(this.dragSurface_, newLoc);
|
|
128
145
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
* display accordingly.
|
|
132
|
-
* @param {!Event} e The most recent move event.
|
|
133
|
-
* @param {!Coordinate} currentDragDeltaXY How far the pointer has
|
|
134
|
-
* moved from the position at the start of the drag, in pixel units.
|
|
135
|
-
* @package
|
|
136
|
-
*/
|
|
137
|
-
BubbleDragger.prototype.dragBubble = function(e, currentDragDeltaXY) {
|
|
138
|
-
const delta = this.pixelsToWorkspaceUnits_(currentDragDeltaXY);
|
|
139
|
-
const newLoc = Coordinate.sum(this.startXY_, delta);
|
|
140
|
-
this.draggingBubble_.moveDuringDrag(this.dragSurface_, newLoc);
|
|
146
|
+
const oldDragTarget = this.dragTarget_;
|
|
147
|
+
this.dragTarget_ = this.workspace_.getDragTarget(e);
|
|
141
148
|
|
|
142
|
-
|
|
143
|
-
|
|
149
|
+
const oldWouldDeleteBubble = this.wouldDeleteBubble_;
|
|
150
|
+
this.wouldDeleteBubble_ = this.shouldDelete_(this.dragTarget_);
|
|
151
|
+
if (oldWouldDeleteBubble !== this.wouldDeleteBubble_) {
|
|
152
|
+
// Prevent unnecessary add/remove class calls.
|
|
153
|
+
this.updateCursorDuringBubbleDrag_();
|
|
154
|
+
}
|
|
144
155
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
156
|
+
// Call drag enter/exit/over after wouldDeleteBlock is called in
|
|
157
|
+
// shouldDelete_
|
|
158
|
+
if (this.dragTarget_ !== oldDragTarget) {
|
|
159
|
+
oldDragTarget && oldDragTarget.onDragExit(this.draggingBubble_);
|
|
160
|
+
this.dragTarget_ && this.dragTarget_.onDragEnter(this.draggingBubble_);
|
|
161
|
+
}
|
|
162
|
+
this.dragTarget_ && this.dragTarget_.onDragOver(this.draggingBubble_);
|
|
150
163
|
}
|
|
151
164
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
165
|
+
/**
|
|
166
|
+
* Whether ending the drag would delete the bubble.
|
|
167
|
+
* @param {?IDragTarget} dragTarget The drag target that the bubblee is
|
|
168
|
+
* currently over.
|
|
169
|
+
* @return {boolean} Whether dropping the bubble immediately would delete the
|
|
170
|
+
* block.
|
|
171
|
+
* @private
|
|
172
|
+
*/
|
|
173
|
+
shouldDelete_(dragTarget) {
|
|
174
|
+
if (dragTarget) {
|
|
175
|
+
const componentManager = this.workspace_.getComponentManager();
|
|
176
|
+
const isDeleteArea = componentManager.hasCapability(
|
|
177
|
+
dragTarget.id, ComponentManager.Capability.DELETE_AREA);
|
|
178
|
+
if (isDeleteArea) {
|
|
179
|
+
return (/** @type {!IDeleteArea} */ (dragTarget))
|
|
180
|
+
.wouldDelete(this.draggingBubble_, false);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
return false;
|
|
156
184
|
}
|
|
157
|
-
this.dragTarget_ && this.dragTarget_.onDragOver(this.draggingBubble_);
|
|
158
|
-
};
|
|
159
185
|
|
|
160
|
-
/**
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
*/
|
|
168
|
-
BubbleDragger.prototype.shouldDelete_ = function(dragTarget) {
|
|
169
|
-
if (dragTarget) {
|
|
170
|
-
const componentManager = this.workspace_.getComponentManager();
|
|
171
|
-
const isDeleteArea = componentManager.hasCapability(
|
|
172
|
-
dragTarget.id, ComponentManager.Capability.DELETE_AREA);
|
|
173
|
-
if (isDeleteArea) {
|
|
174
|
-
return (/** @type {!IDeleteArea} */ (dragTarget))
|
|
175
|
-
.wouldDelete(this.draggingBubble_, false);
|
|
176
|
-
}
|
|
186
|
+
/**
|
|
187
|
+
* Update the cursor (and possibly the trash can lid) to reflect whether the
|
|
188
|
+
* dragging bubble would be deleted if released immediately.
|
|
189
|
+
* @private
|
|
190
|
+
*/
|
|
191
|
+
updateCursorDuringBubbleDrag_() {
|
|
192
|
+
this.draggingBubble_.setDeleteStyle(this.wouldDeleteBubble_);
|
|
177
193
|
}
|
|
178
|
-
return false;
|
|
179
|
-
};
|
|
180
194
|
|
|
181
|
-
/**
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
195
|
+
/**
|
|
196
|
+
* Finish a bubble drag and put the bubble back on the workspace.
|
|
197
|
+
* @param {!Event} e The mouseup/touchend event.
|
|
198
|
+
* @param {!Coordinate} currentDragDeltaXY How far the pointer has
|
|
199
|
+
* moved from the position at the start of the drag, in pixel units.
|
|
200
|
+
* @package
|
|
201
|
+
*/
|
|
202
|
+
endBubbleDrag(e, currentDragDeltaXY) {
|
|
203
|
+
// Make sure internal state is fresh.
|
|
204
|
+
this.dragBubble(e, currentDragDeltaXY);
|
|
189
205
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
206
|
+
const preventMove = this.dragTarget_ &&
|
|
207
|
+
this.dragTarget_.shouldPreventMove(this.draggingBubble_);
|
|
208
|
+
let newLoc;
|
|
209
|
+
if (preventMove) {
|
|
210
|
+
newLoc = this.startXY_;
|
|
211
|
+
} else {
|
|
212
|
+
const delta = this.pixelsToWorkspaceUnits_(currentDragDeltaXY);
|
|
213
|
+
newLoc = Coordinate.sum(this.startXY_, delta);
|
|
214
|
+
}
|
|
215
|
+
// Move the bubble to its final location.
|
|
216
|
+
this.draggingBubble_.moveTo(newLoc.x, newLoc.y);
|
|
200
217
|
|
|
201
|
-
|
|
202
|
-
this.dragTarget_.
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
218
|
+
if (this.dragTarget_) {
|
|
219
|
+
this.dragTarget_.onDrop(this.draggingBubble_);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
if (this.wouldDeleteBubble_) {
|
|
223
|
+
// Fire a move event, so we know where to go back to for an undo.
|
|
224
|
+
this.fireMoveEvent_();
|
|
225
|
+
this.draggingBubble_.dispose(false, true);
|
|
226
|
+
} else {
|
|
227
|
+
// Put everything back onto the bubble canvas.
|
|
228
|
+
if (this.dragSurface_) {
|
|
229
|
+
this.dragSurface_.clearAndHide(this.workspace_.getBubbleCanvas());
|
|
230
|
+
}
|
|
231
|
+
if (this.draggingBubble_.setDragging) {
|
|
232
|
+
this.draggingBubble_.setDragging(false);
|
|
233
|
+
}
|
|
234
|
+
this.fireMoveEvent_();
|
|
235
|
+
}
|
|
236
|
+
this.workspace_.setResizesEnabled(true);
|
|
212
237
|
|
|
213
|
-
|
|
214
|
-
this.dragTarget_.onDrop(this.draggingBubble_);
|
|
238
|
+
eventUtils.setGroup(false);
|
|
215
239
|
}
|
|
216
240
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
241
|
+
/**
|
|
242
|
+
* Fire a move event at the end of a bubble drag.
|
|
243
|
+
* @private
|
|
244
|
+
*/
|
|
245
|
+
fireMoveEvent_() {
|
|
246
|
+
if (this.draggingBubble_.isComment) {
|
|
247
|
+
// TODO (adodson): Resolve build errors when requiring
|
|
248
|
+
// WorkspaceCommentSvg.
|
|
249
|
+
const event = /** @type {!CommentMove} */
|
|
250
|
+
(new (eventUtils.get(eventUtils.COMMENT_MOVE))(
|
|
251
|
+
/** @type {!WorkspaceCommentSvg} */ (this.draggingBubble_)));
|
|
252
|
+
event.setOldCoordinate(this.startXY_);
|
|
253
|
+
event.recordNew();
|
|
254
|
+
eventUtils.fire(event);
|
|
228
255
|
}
|
|
229
|
-
|
|
256
|
+
// TODO (fenichel): move events for comments.
|
|
257
|
+
return;
|
|
230
258
|
}
|
|
231
|
-
this.workspace_.setResizesEnabled(true);
|
|
232
259
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
260
|
+
/**
|
|
261
|
+
* Convert a coordinate object from pixels to workspace units, including a
|
|
262
|
+
* correction for mutator workspaces.
|
|
263
|
+
* This function does not consider differing origins. It simply scales the
|
|
264
|
+
* input's x and y values.
|
|
265
|
+
* @param {!Coordinate} pixelCoord A coordinate with x and y
|
|
266
|
+
* values in CSS pixel units.
|
|
267
|
+
* @return {!Coordinate} The input coordinate divided by the
|
|
268
|
+
* workspace scale.
|
|
269
|
+
* @private
|
|
270
|
+
*/
|
|
271
|
+
pixelsToWorkspaceUnits_(pixelCoord) {
|
|
272
|
+
const result = new Coordinate(
|
|
273
|
+
pixelCoord.x / this.workspace_.scale,
|
|
274
|
+
pixelCoord.y / this.workspace_.scale);
|
|
275
|
+
if (this.workspace_.isMutator) {
|
|
276
|
+
// If we're in a mutator, its scale is always 1, purely because of some
|
|
277
|
+
// oddities in our rendering optimizations. The actual scale is the same
|
|
278
|
+
// as the scale on the parent workspace. Fix that for dragging.
|
|
279
|
+
const mainScale = this.workspace_.options.parentWorkspace.scale;
|
|
280
|
+
result.scale(1 / mainScale);
|
|
281
|
+
}
|
|
282
|
+
return result;
|
|
248
283
|
}
|
|
249
|
-
// TODO (fenichel): move events for comments.
|
|
250
|
-
return;
|
|
251
|
-
};
|
|
252
284
|
|
|
253
|
-
/**
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
*/
|
|
264
|
-
BubbleDragger.prototype.pixelsToWorkspaceUnits_ = function(pixelCoord) {
|
|
265
|
-
const result = new Coordinate(
|
|
266
|
-
pixelCoord.x / this.workspace_.scale,
|
|
267
|
-
pixelCoord.y / this.workspace_.scale);
|
|
268
|
-
if (this.workspace_.isMutator) {
|
|
269
|
-
// If we're in a mutator, its scale is always 1, purely because of some
|
|
270
|
-
// oddities in our rendering optimizations. The actual scale is the same as
|
|
271
|
-
// the scale on the parent workspace.
|
|
272
|
-
// Fix that for dragging.
|
|
273
|
-
const mainScale = this.workspace_.options.parentWorkspace.scale;
|
|
274
|
-
result.scale(1 / mainScale);
|
|
285
|
+
/**
|
|
286
|
+
* Move the bubble onto the drag surface at the beginning of a drag. Move the
|
|
287
|
+
* drag surface to preserve the apparent location of the bubble.
|
|
288
|
+
* @private
|
|
289
|
+
*/
|
|
290
|
+
moveToDragSurface_() {
|
|
291
|
+
this.draggingBubble_.moveTo(0, 0);
|
|
292
|
+
this.dragSurface_.translateSurface(this.startXY_.x, this.startXY_.y);
|
|
293
|
+
// Execute the move on the top-level SVG component.
|
|
294
|
+
this.dragSurface_.setBlocksAndShow(this.draggingBubble_.getSvgRoot());
|
|
275
295
|
}
|
|
276
|
-
return result;
|
|
277
|
-
};
|
|
278
|
-
|
|
279
|
-
/**
|
|
280
|
-
* Move the bubble onto the drag surface at the beginning of a drag. Move the
|
|
281
|
-
* drag surface to preserve the apparent location of the bubble.
|
|
282
|
-
* @private
|
|
283
|
-
*/
|
|
284
|
-
BubbleDragger.prototype.moveToDragSurface_ = function() {
|
|
285
|
-
this.draggingBubble_.moveTo(0, 0);
|
|
286
|
-
this.dragSurface_.translateSurface(this.startXY_.x, this.startXY_.y);
|
|
287
|
-
// Execute the move on the top-level SVG component.
|
|
288
|
-
this.dragSurface_.setBlocksAndShow(this.draggingBubble_.getSvgRoot());
|
|
289
296
|
};
|
|
290
297
|
|
|
291
298
|
exports.BubbleDragger = BubbleDragger;
|
package/core/bump_objects.js
CHANGED
|
@@ -15,11 +15,11 @@
|
|
|
15
15
|
*/
|
|
16
16
|
goog.module('Blockly.bumpObjects');
|
|
17
17
|
|
|
18
|
-
/* eslint-disable-next-line no-unused-vars */
|
|
19
|
-
const Abstract = goog.requireType('Blockly.Events.Abstract');
|
|
20
18
|
const eventUtils = goog.require('Blockly.Events.utils');
|
|
21
19
|
const mathUtils = goog.require('Blockly.utils.math');
|
|
22
20
|
/* eslint-disable-next-line no-unused-vars */
|
|
21
|
+
const {Abstract} = goog.requireType('Blockly.Events.Abstract');
|
|
22
|
+
/* eslint-disable-next-line no-unused-vars */
|
|
23
23
|
const {BlockSvg} = goog.requireType('Blockly.BlockSvg');
|
|
24
24
|
/* eslint-disable-next-line no-unused-vars */
|
|
25
25
|
const {IBoundedElement} = goog.requireType('Blockly.IBoundedElement');
|
package/core/clipboard.js
CHANGED
|
@@ -15,7 +15,6 @@
|
|
|
15
15
|
*/
|
|
16
16
|
goog.module('Blockly.clipboard');
|
|
17
17
|
|
|
18
|
-
const eventUtils = goog.require('Blockly.Events.utils');
|
|
19
18
|
/* eslint-disable-next-line no-unused-vars */
|
|
20
19
|
const {ICopyable} = goog.requireType('Blockly.ICopyable');
|
|
21
20
|
|
|
@@ -39,13 +38,14 @@ exports.copy = copy;
|
|
|
39
38
|
|
|
40
39
|
/**
|
|
41
40
|
* Paste a block or workspace comment on to the main workspace.
|
|
42
|
-
* @return {
|
|
41
|
+
* @return {!ICopyable|null} The pasted thing if the paste
|
|
42
|
+
* was successful, null otherwise.
|
|
43
43
|
* @alias Blockly.clipboard.paste
|
|
44
44
|
* @package
|
|
45
45
|
*/
|
|
46
46
|
const paste = function() {
|
|
47
47
|
if (!copyData) {
|
|
48
|
-
return
|
|
48
|
+
return null;
|
|
49
49
|
}
|
|
50
50
|
// Pasting always pastes to the main workspace, even if the copy
|
|
51
51
|
// started in a flyout workspace.
|
|
@@ -55,12 +55,9 @@ const paste = function() {
|
|
|
55
55
|
}
|
|
56
56
|
if (copyData.typeCounts &&
|
|
57
57
|
workspace.isCapacityAvailable(copyData.typeCounts)) {
|
|
58
|
-
|
|
59
|
-
workspace.paste(copyData.saveInfo);
|
|
60
|
-
eventUtils.setGroup(false);
|
|
61
|
-
return true;
|
|
58
|
+
return workspace.paste(copyData.saveInfo);
|
|
62
59
|
}
|
|
63
|
-
return
|
|
60
|
+
return null;
|
|
64
61
|
};
|
|
65
62
|
exports.paste = paste;
|
|
66
63
|
|
|
@@ -68,13 +65,16 @@ exports.paste = paste;
|
|
|
68
65
|
* Duplicate this block and its children, or a workspace comment.
|
|
69
66
|
* @param {!ICopyable} toDuplicate Block or Workspace Comment to be
|
|
70
67
|
* duplicated.
|
|
68
|
+
* @return {!ICopyable|null} The block or workspace comment that was duplicated,
|
|
69
|
+
* or null if the duplication failed.
|
|
71
70
|
* @alias Blockly.clipboard.duplicate
|
|
72
71
|
* @package
|
|
73
72
|
*/
|
|
74
73
|
const duplicate = function(toDuplicate) {
|
|
75
74
|
const oldCopyData = copyData;
|
|
76
75
|
copy(toDuplicate);
|
|
77
|
-
toDuplicate.workspace.paste(copyData.saveInfo);
|
|
76
|
+
const pastedThing = toDuplicate.workspace.paste(copyData.saveInfo);
|
|
78
77
|
copyData = oldCopyData;
|
|
78
|
+
return pastedThing;
|
|
79
79
|
};
|
|
80
80
|
exports.duplicate = duplicate;
|