blockly 7.20211209.3 → 8.0.1-beta.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 +582 -546
- package/blockly_compressed.js +448 -416
- package/blockly_compressed.js.map +1 -1
- package/blocks/blocks.js +47 -0
- package/blocks/colour.js +13 -3
- package/blocks/lists.js +33 -18
- package/blocks/logic.js +24 -8
- package/blocks/loops.js +20 -7
- package/blocks/math.js +12 -3
- package/blocks/procedures.js +41 -27
- package/blocks/text.js +33 -18
- package/blocks/variables.js +14 -3
- package/blocks/variables_dynamic.js +13 -3
- package/blocks_compressed.js +129 -126
- 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 +20 -10
- 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/utils/toolbox.js +1 -1
- 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 +5 -4
- 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 +5 -4
- package/javascript_compressed.js.map +1 -1
- package/lua_compressed.js +5 -4
- package/lua_compressed.js.map +1 -1
- package/msg/ab.js +1 -2
- package/msg/ace.js +1 -2
- package/msg/af.js +1 -2
- package/msg/am.js +1 -2
- package/msg/ar.js +1 -2
- package/msg/ast.js +1 -2
- package/msg/az.js +3 -4
- package/msg/ba.js +1 -2
- package/msg/bcc.js +1 -2
- package/msg/be-tarask.js +1 -2
- package/msg/be.js +5 -6
- package/msg/bg.js +1 -2
- package/msg/bn.js +1 -2
- package/msg/br.js +1 -2
- package/msg/bs.js +1 -2
- package/msg/ca.js +1 -2
- package/msg/cdo.js +1 -2
- package/msg/cs.js +16 -17
- package/msg/da.js +1 -2
- package/msg/de.js +2 -3
- package/msg/diq.js +2 -3
- package/msg/dty.js +1 -2
- package/msg/ee.js +1 -2
- package/msg/el.js +1 -2
- package/msg/en-gb.js +1 -2
- package/msg/en.js +1 -2
- package/msg/eo.js +2 -3
- package/msg/es.js +2 -3
- package/msg/et.js +1 -2
- package/msg/eu.js +1 -2
- package/msg/fa.js +2 -3
- package/msg/fi.js +1 -2
- package/msg/fo.js +1 -2
- package/msg/fr.js +5 -6
- package/msg/frr.js +1 -2
- package/msg/gl.js +1 -2
- package/msg/gn.js +1 -2
- package/msg/gor.js +1 -2
- package/msg/ha.js +1 -2
- package/msg/hak.js +1 -2
- package/msg/he.js +2 -3
- package/msg/hi.js +1 -2
- package/msg/hr.js +3 -4
- package/msg/hrx.js +1 -2
- package/msg/hu.js +1 -2
- package/msg/hy.js +3 -4
- package/msg/ia.js +1 -2
- package/msg/id.js +13 -14
- package/msg/ig.js +1 -2
- package/msg/inh.js +15 -16
- package/msg/is.js +1 -2
- package/msg/it.js +1 -2
- package/msg/ja.js +8 -9
- package/msg/ka.js +1 -2
- package/msg/kab.js +1 -2
- package/msg/kbd-cyrl.js +1 -2
- package/msg/km.js +1 -2
- package/msg/kn.js +1 -2
- package/msg/ko.js +1 -2
- package/msg/ksh.js +1 -2
- package/msg/ku-latn.js +1 -2
- package/msg/ky.js +1 -2
- package/msg/la.js +1 -2
- package/msg/lb.js +1 -2
- package/msg/lki.js +1 -2
- package/msg/lo.js +1 -2
- package/msg/lrc.js +1 -2
- package/msg/lt.js +1 -2
- package/msg/lv.js +30 -31
- package/msg/mg.js +1 -2
- package/msg/mk.js +1 -2
- package/msg/ml.js +1 -2
- package/msg/mnw.js +1 -2
- package/msg/ms.js +1 -2
- package/msg/my.js +1 -2
- package/msg/mzn.js +1 -2
- package/msg/nb.js +1 -2
- package/msg/ne.js +1 -2
- package/msg/nl.js +1 -2
- package/msg/oc.js +1 -2
- package/msg/olo.js +1 -2
- package/msg/pa.js +4 -5
- package/msg/pl.js +1 -2
- package/msg/pms.js +1 -2
- package/msg/ps.js +1 -2
- package/msg/pt-br.js +1 -2
- package/msg/pt.js +1 -2
- package/msg/ro.js +1 -2
- package/msg/ru.js +1 -2
- package/msg/sc.js +1 -2
- package/msg/sco.js +1 -2
- package/msg/sd.js +1 -2
- package/msg/shn.js +1 -2
- package/msg/si.js +1 -2
- package/msg/sk.js +1 -2
- package/msg/skr-arab.js +1 -2
- package/msg/sl.js +1 -2
- package/msg/smn.js +435 -0
- package/msg/sq.js +1 -2
- package/msg/sr-latn.js +1 -2
- package/msg/sr.js +1 -2
- package/msg/sv.js +1 -2
- package/msg/sw.js +1 -2
- package/msg/ta.js +1 -2
- package/msg/tcy.js +1 -2
- package/msg/te.js +2 -3
- package/msg/th.js +1 -2
- package/msg/ti.js +1 -2
- package/msg/tl.js +1 -2
- package/msg/tlh.js +1 -2
- package/msg/tr.js +1 -2
- package/msg/ug-arab.js +1 -2
- package/msg/uk.js +1 -2
- package/msg/ur.js +1 -2
- package/msg/uz.js +1 -2
- package/msg/vi.js +1 -2
- package/msg/xmf.js +1 -2
- package/msg/yo.js +1 -2
- package/msg/yue.js +2 -3
- package/msg/zgh.js +1 -2
- package/msg/zh-hans.js +4 -5
- package/msg/zh-hant.js +4 -5
- package/package.json +7 -6
- package/php_compressed.js +5 -4
- package/php_compressed.js.map +1 -1
- package/python_compressed.js +5 -4
- package/python_compressed.js.map +1 -1
- package/blocks/all.js +0 -36
package/blocks/blocks.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2021 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @fileoverview All the blocks. (Entry point for blocks_compressed.js.)
|
|
9
|
+
* @suppress {extraRequire}
|
|
10
|
+
*/
|
|
11
|
+
'use strict';
|
|
12
|
+
|
|
13
|
+
goog.module('Blockly.libraryBlocks');
|
|
14
|
+
goog.module.declareLegacyNamespace();
|
|
15
|
+
|
|
16
|
+
const colour = goog.require('Blockly.libraryBlocks.colour');
|
|
17
|
+
const lists = goog.require('Blockly.libraryBlocks.lists');
|
|
18
|
+
const logic = goog.require('Blockly.libraryBlocks.logic');
|
|
19
|
+
const loops = goog.require('Blockly.libraryBlocks.loops');
|
|
20
|
+
const math = goog.require('Blockly.libraryBlocks.math');
|
|
21
|
+
const procedures = goog.require('Blockly.libraryBlocks.procedures');
|
|
22
|
+
const texts = goog.require('Blockly.libraryBlocks.texts');
|
|
23
|
+
const variables = goog.require('Blockly.libraryBlocks.variables');
|
|
24
|
+
const variablesDynamic = goog.require('Blockly.libraryBlocks.variablesDynamic');
|
|
25
|
+
/* eslint-disable-next-line no-unused-vars */
|
|
26
|
+
const {BlockDefinition} = goog.requireType('Blockly.blocks');
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
exports.colour = colour;
|
|
30
|
+
exports.lists = lists;
|
|
31
|
+
exports.logic = logic;
|
|
32
|
+
exports.loops = loops;
|
|
33
|
+
exports.math = math;
|
|
34
|
+
exports.procedures = procedures;
|
|
35
|
+
exports.texts = texts;
|
|
36
|
+
exports.variables = variables;
|
|
37
|
+
exports.variablesDynamic = variablesDynamic;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* A dictionary of the block definitions provided by all the
|
|
41
|
+
* Blockly.libraryBlocks.* modules.
|
|
42
|
+
* @type {!Object<string, !BlockDefinition>}
|
|
43
|
+
*/
|
|
44
|
+
const blocks = Object.assign(
|
|
45
|
+
{}, colour.blocks, lists.blocks, logic.blocks, loops.blocks, math.blocks,
|
|
46
|
+
procedures.blocks, variables.blocks, variablesDynamic.blocks);
|
|
47
|
+
exports.blocks = blocks;
|
package/blocks/colour.js
CHANGED
|
@@ -9,14 +9,20 @@
|
|
|
9
9
|
*/
|
|
10
10
|
'use strict';
|
|
11
11
|
|
|
12
|
-
goog.module('Blockly.
|
|
12
|
+
goog.module('Blockly.libraryBlocks.colour');
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
/* eslint-disable-next-line no-unused-vars */
|
|
15
|
+
const {BlockDefinition} = goog.requireType('Blockly.blocks');
|
|
16
|
+
const {createBlockDefinitionsFromJsonArray, defineBlocks} = goog.require('Blockly.common');
|
|
15
17
|
/** @suppress {extraRequire} */
|
|
16
18
|
goog.require('Blockly.FieldColour');
|
|
17
19
|
|
|
18
20
|
|
|
19
|
-
|
|
21
|
+
/**
|
|
22
|
+
* A dictionary of the block definitions provided by this module.
|
|
23
|
+
* @type {!Object<string, !BlockDefinition>}
|
|
24
|
+
*/
|
|
25
|
+
const blocks = createBlockDefinitionsFromJsonArray([
|
|
20
26
|
// Block for colour picker.
|
|
21
27
|
{
|
|
22
28
|
'type': 'colour_picker',
|
|
@@ -107,3 +113,7 @@ defineBlocksWithJsonArray([
|
|
|
107
113
|
'tooltip': '%{BKY_COLOUR_BLEND_TOOLTIP}',
|
|
108
114
|
},
|
|
109
115
|
]);
|
|
116
|
+
exports.blocks = blocks;
|
|
117
|
+
|
|
118
|
+
// Register provided blocks.
|
|
119
|
+
defineBlocks(blocks);
|
package/blocks/lists.js
CHANGED
|
@@ -10,25 +10,30 @@
|
|
|
10
10
|
*/
|
|
11
11
|
'use strict';
|
|
12
12
|
|
|
13
|
-
goog.module('Blockly.
|
|
13
|
+
goog.module('Blockly.libraryBlocks.lists');
|
|
14
14
|
|
|
15
15
|
const xmlUtils = goog.require('Blockly.utils.xml');
|
|
16
16
|
const {Align} = goog.require('Blockly.Input');
|
|
17
17
|
/* eslint-disable-next-line no-unused-vars */
|
|
18
18
|
const {Block} = goog.requireType('Blockly.Block');
|
|
19
|
-
|
|
19
|
+
/* eslint-disable-next-line no-unused-vars */
|
|
20
|
+
const {BlockDefinition} = goog.requireType('Blockly.blocks');
|
|
20
21
|
const {ConnectionType} = goog.require('Blockly.ConnectionType');
|
|
21
22
|
const {FieldDropdown} = goog.require('Blockly.FieldDropdown');
|
|
22
23
|
const {Msg} = goog.require('Blockly.Msg');
|
|
23
24
|
const {Mutator} = goog.require('Blockly.Mutator');
|
|
24
25
|
/* eslint-disable-next-line no-unused-vars */
|
|
25
26
|
const {Workspace} = goog.requireType('Blockly.Workspace');
|
|
26
|
-
const {
|
|
27
|
+
const {createBlockDefinitionsFromJsonArray, defineBlocks} = goog.require('Blockly.common');
|
|
27
28
|
/** @suppress {extraRequire} */
|
|
28
29
|
goog.require('Blockly.FieldDropdown');
|
|
29
30
|
|
|
30
31
|
|
|
31
|
-
|
|
32
|
+
/**
|
|
33
|
+
* A dictionary of the block definitions provided by this module.
|
|
34
|
+
* @type {!Object<string, !BlockDefinition>}
|
|
35
|
+
*/
|
|
36
|
+
const blocks = createBlockDefinitionsFromJsonArray([
|
|
32
37
|
// Block for creating an empty list
|
|
33
38
|
// The 'list_create_with' block is preferred as it is more flexible.
|
|
34
39
|
// <block type="lists_create_with">
|
|
@@ -112,8 +117,9 @@ defineBlocksWithJsonArray([
|
|
|
112
117
|
'helpUrl': '%{BKY_LISTS_LENGTH_HELPURL}',
|
|
113
118
|
},
|
|
114
119
|
]);
|
|
120
|
+
exports.blocks = blocks;
|
|
115
121
|
|
|
116
|
-
|
|
122
|
+
blocks['lists_create_with'] = {
|
|
117
123
|
/**
|
|
118
124
|
* Block for creating a list with any number of elements of any type.
|
|
119
125
|
* @this {Block}
|
|
@@ -192,10 +198,13 @@ Blocks['lists_create_with'] = {
|
|
|
192
198
|
let itemBlock = containerBlock.getInputTargetBlock('STACK');
|
|
193
199
|
// Count number of inputs.
|
|
194
200
|
const connections = [];
|
|
195
|
-
while (itemBlock
|
|
201
|
+
while (itemBlock) {
|
|
202
|
+
if (itemBlock.isInsertionMarker()) {
|
|
203
|
+
itemBlock = itemBlock.getNextBlock();
|
|
204
|
+
continue;
|
|
205
|
+
}
|
|
196
206
|
connections.push(itemBlock.valueConnection_);
|
|
197
|
-
itemBlock =
|
|
198
|
-
itemBlock.nextConnection && itemBlock.nextConnection.targetBlock();
|
|
207
|
+
itemBlock = itemBlock.getNextBlock();
|
|
199
208
|
}
|
|
200
209
|
// Disconnect any children that don't belong.
|
|
201
210
|
for (let i = 0; i < this.itemCount_; i++) {
|
|
@@ -220,10 +229,13 @@ Blocks['lists_create_with'] = {
|
|
|
220
229
|
let itemBlock = containerBlock.getInputTargetBlock('STACK');
|
|
221
230
|
let i = 0;
|
|
222
231
|
while (itemBlock) {
|
|
232
|
+
if (itemBlock.isInsertionMarker()) {
|
|
233
|
+
itemBlock = itemBlock.getNextBlock();
|
|
234
|
+
continue;
|
|
235
|
+
}
|
|
223
236
|
const input = this.getInput('ADD' + i);
|
|
224
237
|
itemBlock.valueConnection_ = input && input.connection.targetConnection;
|
|
225
|
-
itemBlock =
|
|
226
|
-
itemBlock.nextConnection && itemBlock.nextConnection.targetBlock();
|
|
238
|
+
itemBlock = itemBlock.getNextBlock();
|
|
227
239
|
i++;
|
|
228
240
|
}
|
|
229
241
|
},
|
|
@@ -255,7 +267,7 @@ Blocks['lists_create_with'] = {
|
|
|
255
267
|
},
|
|
256
268
|
};
|
|
257
269
|
|
|
258
|
-
|
|
270
|
+
blocks['lists_create_with_container'] = {
|
|
259
271
|
/**
|
|
260
272
|
* Mutator block for list container.
|
|
261
273
|
* @this {Block}
|
|
@@ -270,7 +282,7 @@ Blocks['lists_create_with_container'] = {
|
|
|
270
282
|
},
|
|
271
283
|
};
|
|
272
284
|
|
|
273
|
-
|
|
285
|
+
blocks['lists_create_with_item'] = {
|
|
274
286
|
/**
|
|
275
287
|
* Mutator block for adding items.
|
|
276
288
|
* @this {Block}
|
|
@@ -285,7 +297,7 @@ Blocks['lists_create_with_item'] = {
|
|
|
285
297
|
},
|
|
286
298
|
};
|
|
287
299
|
|
|
288
|
-
|
|
300
|
+
blocks['lists_indexOf'] = {
|
|
289
301
|
/**
|
|
290
302
|
* Block for finding an item in the list.
|
|
291
303
|
* @this {Block}
|
|
@@ -312,7 +324,7 @@ Blocks['lists_indexOf'] = {
|
|
|
312
324
|
},
|
|
313
325
|
};
|
|
314
326
|
|
|
315
|
-
|
|
327
|
+
blocks['lists_getIndex'] = {
|
|
316
328
|
/**
|
|
317
329
|
* Block for getting element at index.
|
|
318
330
|
* @this {Block}
|
|
@@ -516,7 +528,7 @@ Blocks['lists_getIndex'] = {
|
|
|
516
528
|
},
|
|
517
529
|
};
|
|
518
530
|
|
|
519
|
-
|
|
531
|
+
blocks['lists_setIndex'] = {
|
|
520
532
|
/**
|
|
521
533
|
* Block for setting the element at index.
|
|
522
534
|
* @this {Block}
|
|
@@ -668,7 +680,7 @@ Blocks['lists_setIndex'] = {
|
|
|
668
680
|
},
|
|
669
681
|
};
|
|
670
682
|
|
|
671
|
-
|
|
683
|
+
blocks['lists_getSublist'] = {
|
|
672
684
|
/**
|
|
673
685
|
* Block for getting sublist.
|
|
674
686
|
* @this {Block}
|
|
@@ -786,7 +798,7 @@ Blocks['lists_getSublist'] = {
|
|
|
786
798
|
},
|
|
787
799
|
};
|
|
788
800
|
|
|
789
|
-
|
|
801
|
+
blocks['lists_sort'] = {
|
|
790
802
|
/**
|
|
791
803
|
* Block for sorting a list.
|
|
792
804
|
* @this {Block}
|
|
@@ -826,7 +838,7 @@ Blocks['lists_sort'] = {
|
|
|
826
838
|
},
|
|
827
839
|
};
|
|
828
840
|
|
|
829
|
-
|
|
841
|
+
blocks['lists_split'] = {
|
|
830
842
|
/**
|
|
831
843
|
* Block for splitting text into a list, or joining a list into text.
|
|
832
844
|
* @this {Block}
|
|
@@ -913,3 +925,6 @@ Blocks['lists_split'] = {
|
|
|
913
925
|
// dropdown values.
|
|
914
926
|
// XML hooks are kept for backwards compatibility.
|
|
915
927
|
};
|
|
928
|
+
|
|
929
|
+
// Register provided blocks.
|
|
930
|
+
defineBlocks(blocks);
|
package/blocks/logic.js
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
*/
|
|
11
11
|
'use strict';
|
|
12
12
|
|
|
13
|
-
goog.module('Blockly.
|
|
13
|
+
goog.module('Blockly.libraryBlocks.logic');
|
|
14
14
|
|
|
15
15
|
/* eslint-disable-next-line no-unused-vars */
|
|
16
16
|
const AbstractEvent = goog.requireType('Blockly.Events.Abstract');
|
|
@@ -19,20 +19,26 @@ const Extensions = goog.require('Blockly.Extensions');
|
|
|
19
19
|
const xmlUtils = goog.require('Blockly.utils.xml');
|
|
20
20
|
/* eslint-disable-next-line no-unused-vars */
|
|
21
21
|
const {Block} = goog.requireType('Blockly.Block');
|
|
22
|
+
/* eslint-disable-next-line no-unused-vars */
|
|
23
|
+
const {BlockDefinition} = goog.requireType('Blockly.blocks');
|
|
22
24
|
const {Msg} = goog.require('Blockly.Msg');
|
|
23
25
|
const {Mutator} = goog.require('Blockly.Mutator');
|
|
24
26
|
/* eslint-disable-next-line no-unused-vars */
|
|
25
27
|
const {RenderedConnection} = goog.requireType('Blockly.RenderedConnection');
|
|
26
28
|
/* eslint-disable-next-line no-unused-vars */
|
|
27
29
|
const {Workspace} = goog.requireType('Blockly.Workspace');
|
|
28
|
-
const {
|
|
30
|
+
const {createBlockDefinitionsFromJsonArray, defineBlocks} = goog.require('Blockly.common');
|
|
29
31
|
/** @suppress {extraRequire} */
|
|
30
32
|
goog.require('Blockly.FieldDropdown');
|
|
31
33
|
/** @suppress {extraRequire} */
|
|
32
34
|
goog.require('Blockly.FieldLabel');
|
|
33
35
|
|
|
34
36
|
|
|
35
|
-
|
|
37
|
+
/**
|
|
38
|
+
* A dictionary of the block definitions provided by this module.
|
|
39
|
+
* @type {!Object<string, !BlockDefinition>}
|
|
40
|
+
*/
|
|
41
|
+
const blocks = createBlockDefinitionsFromJsonArray([
|
|
36
42
|
// Block for boolean data type: true and false.
|
|
37
43
|
{
|
|
38
44
|
'type': 'logic_boolean',
|
|
@@ -258,6 +264,7 @@ defineBlocksWithJsonArray([
|
|
|
258
264
|
'tooltip': '%{BKY_CONTROLS_IF_ELSE_TOOLTIP}',
|
|
259
265
|
},
|
|
260
266
|
]);
|
|
267
|
+
exports.blocks = blocks;
|
|
261
268
|
|
|
262
269
|
/**
|
|
263
270
|
* Tooltip text, keyed by block OP value. Used by logic_compare and
|
|
@@ -387,7 +394,11 @@ const CONTROLS_IF_MUTATOR_MIXIN = {
|
|
|
387
394
|
const valueConnections = [null];
|
|
388
395
|
const statementConnections = [null];
|
|
389
396
|
let elseStatementConnection = null;
|
|
390
|
-
while (clauseBlock
|
|
397
|
+
while (clauseBlock) {
|
|
398
|
+
if (clauseBlock.isInsertionMarker()) {
|
|
399
|
+
clauseBlock = clauseBlock.getNextBlock();
|
|
400
|
+
continue;
|
|
401
|
+
}
|
|
391
402
|
switch (clauseBlock.type) {
|
|
392
403
|
case 'controls_if_elseif':
|
|
393
404
|
this.elseifCount_++;
|
|
@@ -401,8 +412,7 @@ const CONTROLS_IF_MUTATOR_MIXIN = {
|
|
|
401
412
|
default:
|
|
402
413
|
throw TypeError('Unknown block type: ' + clauseBlock.type);
|
|
403
414
|
}
|
|
404
|
-
clauseBlock = clauseBlock.
|
|
405
|
-
clauseBlock.nextConnection.targetBlock();
|
|
415
|
+
clauseBlock = clauseBlock.getNextBlock();
|
|
406
416
|
}
|
|
407
417
|
this.updateShape_();
|
|
408
418
|
// Reconnect any child blocks.
|
|
@@ -418,6 +428,10 @@ const CONTROLS_IF_MUTATOR_MIXIN = {
|
|
|
418
428
|
let clauseBlock = containerBlock.nextConnection.targetBlock();
|
|
419
429
|
let i = 1;
|
|
420
430
|
while (clauseBlock) {
|
|
431
|
+
if (clauseBlock.isInsertionMarker()) {
|
|
432
|
+
clauseBlock = clauseBlock.getNextBlock();
|
|
433
|
+
continue;
|
|
434
|
+
}
|
|
421
435
|
switch (clauseBlock.type) {
|
|
422
436
|
case 'controls_if_elseif': {
|
|
423
437
|
const inputIf = this.getInput('IF' + i);
|
|
@@ -438,8 +452,7 @@ const CONTROLS_IF_MUTATOR_MIXIN = {
|
|
|
438
452
|
default:
|
|
439
453
|
throw TypeError('Unknown block type: ' + clauseBlock.type);
|
|
440
454
|
}
|
|
441
|
-
clauseBlock = clauseBlock.
|
|
442
|
-
clauseBlock.nextConnection.targetBlock();
|
|
455
|
+
clauseBlock = clauseBlock.getNextBlock();
|
|
443
456
|
}
|
|
444
457
|
},
|
|
445
458
|
/**
|
|
@@ -645,3 +658,6 @@ const LOGIC_TERNARY_ONCHANGE_MIXIN = {
|
|
|
645
658
|
};
|
|
646
659
|
|
|
647
660
|
Extensions.registerMixin('logic_ternary', LOGIC_TERNARY_ONCHANGE_MIXIN);
|
|
661
|
+
|
|
662
|
+
// Register provided blocks.
|
|
663
|
+
defineBlocks(blocks);
|
package/blocks/loops.js
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
*/
|
|
11
11
|
'use strict';
|
|
12
12
|
|
|
13
|
-
goog.module('Blockly.
|
|
13
|
+
goog.module('Blockly.libraryBlocks.loops');
|
|
14
14
|
|
|
15
15
|
/* eslint-disable-next-line no-unused-vars */
|
|
16
16
|
const AbstractEvent = goog.requireType('Blockly.Events.Abstract');
|
|
@@ -18,11 +18,13 @@ const ContextMenu = goog.require('Blockly.ContextMenu');
|
|
|
18
18
|
const Events = goog.require('Blockly.Events');
|
|
19
19
|
const Extensions = goog.require('Blockly.Extensions');
|
|
20
20
|
const Variables = goog.require('Blockly.Variables');
|
|
21
|
-
const common = goog.require('Blockly.common');
|
|
22
21
|
const xmlUtils = goog.require('Blockly.utils.xml');
|
|
23
22
|
/* eslint-disable-next-line no-unused-vars */
|
|
24
23
|
const {Block} = goog.requireType('Blockly.Block');
|
|
24
|
+
/* eslint-disable-next-line no-unused-vars */
|
|
25
|
+
const {BlockDefinition} = goog.requireType('Blockly.blocks');
|
|
25
26
|
const {Msg} = goog.require('Blockly.Msg');
|
|
27
|
+
const {createBlockDefinitionsFromJsonArray, defineBlocks} = goog.require('Blockly.common');
|
|
26
28
|
/** @suppress {extraRequire} */
|
|
27
29
|
goog.require('Blockly.FieldDropdown');
|
|
28
30
|
/** @suppress {extraRequire} */
|
|
@@ -35,7 +37,11 @@ goog.require('Blockly.FieldVariable');
|
|
|
35
37
|
goog.require('Blockly.Warning');
|
|
36
38
|
|
|
37
39
|
|
|
38
|
-
|
|
40
|
+
/**
|
|
41
|
+
* A dictionary of the block definitions provided by this module.
|
|
42
|
+
* @type {!Object<string, !BlockDefinition>}
|
|
43
|
+
*/
|
|
44
|
+
const blocks = createBlockDefinitionsFromJsonArray([
|
|
39
45
|
// Block for repeat n times (external number).
|
|
40
46
|
{
|
|
41
47
|
'type': 'controls_repeat_ext',
|
|
@@ -205,6 +211,7 @@ common.defineBlocksWithJsonArray([
|
|
|
205
211
|
],
|
|
206
212
|
},
|
|
207
213
|
]);
|
|
214
|
+
exports.blocks = blocks;
|
|
208
215
|
|
|
209
216
|
/**
|
|
210
217
|
* Tooltips for the 'controls_whileUntil' block, keyed by MODE value.
|
|
@@ -286,13 +293,16 @@ Extensions.register(
|
|
|
286
293
|
* To add a new loop type add this to your code:
|
|
287
294
|
*
|
|
288
295
|
* // If using the Blockly npm package and es6 import syntax:
|
|
289
|
-
* import {
|
|
290
|
-
* loopTypes.add('custom_loop');
|
|
296
|
+
* import {loops} from 'blockly/blocks';
|
|
297
|
+
* loops.loopTypes.add('custom_loop');
|
|
291
298
|
*
|
|
292
299
|
* // Else if using Closure Compiler and goog.modules:
|
|
293
|
-
* const {loopTypes} = goog.require('Blockly.
|
|
300
|
+
* const {loopTypes} = goog.require('Blockly.libraryBlocks.loops');
|
|
294
301
|
* loopTypes.add('custom_loop');
|
|
295
302
|
*
|
|
303
|
+
* // Else if using blockly_compressed + blockss_compressed.js in browser:
|
|
304
|
+
* Blockly.libraryBlocks.loopTypes.add('custom_loop');
|
|
305
|
+
*
|
|
296
306
|
* @type {!Set<string>}
|
|
297
307
|
*/
|
|
298
308
|
const loopTypes = new Set([
|
|
@@ -332,7 +342,7 @@ const CONTROL_FLOW_IN_LOOP_CHECK_MIXIN = {
|
|
|
332
342
|
/**
|
|
333
343
|
* Called whenever anything on the workspace changes.
|
|
334
344
|
* Add warning if this flow block is not nested inside a loop.
|
|
335
|
-
* @param {!AbstractEvent} e
|
|
345
|
+
* @param {!AbstractEvent} e Move event.
|
|
336
346
|
* @this {Block}
|
|
337
347
|
*/
|
|
338
348
|
onchange: function(e) {
|
|
@@ -358,3 +368,6 @@ const CONTROL_FLOW_IN_LOOP_CHECK_MIXIN = {
|
|
|
358
368
|
|
|
359
369
|
Extensions.registerMixin(
|
|
360
370
|
'controls_flow_in_loop_check', CONTROL_FLOW_IN_LOOP_CHECK_MIXIN);
|
|
371
|
+
|
|
372
|
+
// Register provided blocks.
|
|
373
|
+
defineBlocks(blocks);
|
package/blocks/math.js
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
*/
|
|
11
11
|
'use strict';
|
|
12
12
|
|
|
13
|
-
goog.module('Blockly.
|
|
13
|
+
goog.module('Blockly.libraryBlocks.math');
|
|
14
14
|
|
|
15
15
|
const Extensions = goog.require('Blockly.Extensions');
|
|
16
16
|
// N.B.: Blockly.FieldDropdown needed for type AND side-effects.
|
|
@@ -20,7 +20,8 @@ const xmlUtils = goog.require('Blockly.utils.xml');
|
|
|
20
20
|
/* eslint-disable-next-line no-unused-vars */
|
|
21
21
|
const {Block} = goog.requireType('Blockly.Block');
|
|
22
22
|
/* eslint-disable-next-line no-unused-vars */
|
|
23
|
-
const {
|
|
23
|
+
const {BlockDefinition} = goog.requireType('Blockly.blocks');
|
|
24
|
+
const {createBlockDefinitionsFromJsonArray, defineBlocks} = goog.require('Blockly.common');
|
|
24
25
|
/** @suppress {extraRequire} */
|
|
25
26
|
goog.require('Blockly.FieldLabel');
|
|
26
27
|
/** @suppress {extraRequire} */
|
|
@@ -29,7 +30,11 @@ goog.require('Blockly.FieldNumber');
|
|
|
29
30
|
goog.require('Blockly.FieldVariable');
|
|
30
31
|
|
|
31
32
|
|
|
32
|
-
|
|
33
|
+
/**
|
|
34
|
+
* A dictionary of the block definitions provided by this module.
|
|
35
|
+
* @type {!Object<string, !BlockDefinition>}
|
|
36
|
+
*/
|
|
37
|
+
const blocks = createBlockDefinitionsFromJsonArray([
|
|
33
38
|
// Block for numeric value.
|
|
34
39
|
{
|
|
35
40
|
'type': 'math_number',
|
|
@@ -384,6 +389,7 @@ defineBlocksWithJsonArray([
|
|
|
384
389
|
'helpUrl': '%{BKY_MATH_ATAN2_HELPURL}',
|
|
385
390
|
},
|
|
386
391
|
]);
|
|
392
|
+
exports.blocks = blocks;
|
|
387
393
|
|
|
388
394
|
/**
|
|
389
395
|
* Mapping of math block OP value to tooltip message for blocks
|
|
@@ -581,3 +587,6 @@ const LIST_MODES_MUTATOR_EXTENSION = function() {
|
|
|
581
587
|
Extensions.registerMutator(
|
|
582
588
|
'math_modes_of_list_mutator', LIST_MODES_MUTATOR_MIXIN,
|
|
583
589
|
LIST_MODES_MUTATOR_EXTENSION);
|
|
590
|
+
|
|
591
|
+
// Register provided blocks.
|
|
592
|
+
defineBlocks(blocks);
|
package/blocks/procedures.js
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
*/
|
|
11
11
|
'use strict';
|
|
12
12
|
|
|
13
|
-
goog.module('Blockly.
|
|
13
|
+
goog.module('Blockly.libraryBlocks.procedures');
|
|
14
14
|
|
|
15
15
|
/* eslint-disable-next-line no-unused-vars */
|
|
16
16
|
const AbstractEvent = goog.requireType('Blockly.Events.Abstract');
|
|
@@ -19,12 +19,13 @@ const Events = goog.require('Blockly.Events');
|
|
|
19
19
|
const Procedures = goog.require('Blockly.Procedures');
|
|
20
20
|
const Variables = goog.require('Blockly.Variables');
|
|
21
21
|
const Xml = goog.require('Blockly.Xml');
|
|
22
|
-
const internalConstants = goog.require('Blockly.internalConstants');
|
|
23
22
|
const xmlUtils = goog.require('Blockly.utils.xml');
|
|
24
23
|
const {Align} = goog.require('Blockly.Input');
|
|
25
24
|
/* eslint-disable-next-line no-unused-vars */
|
|
26
25
|
const {Block} = goog.requireType('Blockly.Block');
|
|
27
|
-
|
|
26
|
+
/* eslint-disable-next-line no-unused-vars */
|
|
27
|
+
const {BlockDefinition} = goog.requireType('Blockly.blocks');
|
|
28
|
+
const {config} = goog.require('Blockly.config');
|
|
28
29
|
/* eslint-disable-next-line no-unused-vars */
|
|
29
30
|
const {FieldCheckbox} = goog.require('Blockly.FieldCheckbox');
|
|
30
31
|
const {FieldLabel} = goog.require('Blockly.FieldLabel');
|
|
@@ -36,12 +37,20 @@ const {Names} = goog.require('Blockly.Names');
|
|
|
36
37
|
const {VariableModel} = goog.requireType('Blockly.VariableModel');
|
|
37
38
|
/* eslint-disable-next-line no-unused-vars */
|
|
38
39
|
const {Workspace} = goog.requireType('Blockly.Workspace');
|
|
40
|
+
const {defineBlocks} = goog.require('Blockly.common');
|
|
39
41
|
/** @suppress {extraRequire} */
|
|
40
42
|
goog.require('Blockly.Comment');
|
|
41
43
|
/** @suppress {extraRequire} */
|
|
42
44
|
goog.require('Blockly.Warning');
|
|
43
45
|
|
|
44
46
|
|
|
47
|
+
/**
|
|
48
|
+
* A dictionary of the block definitions provided by this module.
|
|
49
|
+
* @type {!Object<string, !BlockDefinition>}
|
|
50
|
+
*/
|
|
51
|
+
const blocks = {};
|
|
52
|
+
exports.blocks = blocks;
|
|
53
|
+
|
|
45
54
|
/**
|
|
46
55
|
* Common properties for the procedure_defnoreturn and
|
|
47
56
|
* procedure_defreturn blocks.
|
|
@@ -434,10 +443,9 @@ const PROCEDURE_DEF_COMMON = {
|
|
|
434
443
|
}
|
|
435
444
|
}
|
|
436
445
|
},
|
|
437
|
-
callType_: 'procedures_callnoreturn',
|
|
438
446
|
};
|
|
439
447
|
|
|
440
|
-
|
|
448
|
+
blocks['procedures_defnoreturn'] = {
|
|
441
449
|
...PROCEDURE_DEF_COMMON,
|
|
442
450
|
/**
|
|
443
451
|
* Block for defining a procedure with no return value.
|
|
@@ -477,9 +485,10 @@ Blocks['procedures_defnoreturn'] = {
|
|
|
477
485
|
getProcedureDef: function() {
|
|
478
486
|
return [this.getFieldValue('NAME'), this.arguments_, false];
|
|
479
487
|
},
|
|
488
|
+
callType_: 'procedures_callnoreturn',
|
|
480
489
|
};
|
|
481
490
|
|
|
482
|
-
|
|
491
|
+
blocks['procedures_defreturn'] = {
|
|
483
492
|
...PROCEDURE_DEF_COMMON,
|
|
484
493
|
/**
|
|
485
494
|
* Block for defining a procedure with a return value.
|
|
@@ -522,9 +531,10 @@ Blocks['procedures_defreturn'] = {
|
|
|
522
531
|
getProcedureDef: function() {
|
|
523
532
|
return [this.getFieldValue('NAME'), this.arguments_, true];
|
|
524
533
|
},
|
|
534
|
+
callType_: 'procedures_callreturn',
|
|
525
535
|
};
|
|
526
536
|
|
|
527
|
-
|
|
537
|
+
blocks['procedures_mutatorcontainer'] = {
|
|
528
538
|
/**
|
|
529
539
|
* Mutator block for procedure container.
|
|
530
540
|
* @this {Block}
|
|
@@ -542,7 +552,7 @@ Blocks['procedures_mutatorcontainer'] = {
|
|
|
542
552
|
},
|
|
543
553
|
};
|
|
544
554
|
|
|
545
|
-
|
|
555
|
+
blocks['procedures_mutatorarg'] = {
|
|
546
556
|
/**
|
|
547
557
|
* Mutator block for procedure argument.
|
|
548
558
|
* @this {Block}
|
|
@@ -950,19 +960,18 @@ const PROCEDURE_CALL_COMMON = {
|
|
|
950
960
|
const block = xmlUtils.createElement('block');
|
|
951
961
|
block.setAttribute('type', this.defType_);
|
|
952
962
|
const xy = this.getRelativeToSurfaceXY();
|
|
953
|
-
const x = xy.x +
|
|
954
|
-
const y = xy.y +
|
|
963
|
+
const x = xy.x + config.snapRadius * (this.RTL ? -1 : 1);
|
|
964
|
+
const y = xy.y + config.snapRadius * 2;
|
|
955
965
|
block.setAttribute('x', x);
|
|
956
966
|
block.setAttribute('y', y);
|
|
957
967
|
const mutation = this.mutationToDom();
|
|
958
968
|
block.appendChild(mutation);
|
|
959
969
|
const field = xmlUtils.createElement('field');
|
|
960
970
|
field.setAttribute('name', 'NAME');
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
this.renameProcedure('', callName);
|
|
971
|
+
const callName = this.getProcedureCall();
|
|
972
|
+
const newName = Procedures.findLegalName(callName, this);
|
|
973
|
+
if (callName !== newName) {
|
|
974
|
+
this.renameProcedure(callName, newName);
|
|
966
975
|
}
|
|
967
976
|
field.appendChild(xmlUtils.createTextNode(callName));
|
|
968
977
|
block.appendChild(field);
|
|
@@ -1033,7 +1042,7 @@ const PROCEDURE_CALL_COMMON = {
|
|
|
1033
1042
|
},
|
|
1034
1043
|
};
|
|
1035
1044
|
|
|
1036
|
-
|
|
1045
|
+
blocks['procedures_callnoreturn'] = {
|
|
1037
1046
|
...PROCEDURE_CALL_COMMON,
|
|
1038
1047
|
/**
|
|
1039
1048
|
* Block for calling a procedure with no return value.
|
|
@@ -1056,7 +1065,7 @@ Blocks['procedures_callnoreturn'] = {
|
|
|
1056
1065
|
defType_: 'procedures_defnoreturn',
|
|
1057
1066
|
};
|
|
1058
1067
|
|
|
1059
|
-
|
|
1068
|
+
blocks['procedures_callreturn'] = {
|
|
1060
1069
|
...PROCEDURE_CALL_COMMON,
|
|
1061
1070
|
/**
|
|
1062
1071
|
* Block for calling a procedure with a return value.
|
|
@@ -1078,7 +1087,7 @@ Blocks['procedures_callreturn'] = {
|
|
|
1078
1087
|
defType_: 'procedures_defreturn',
|
|
1079
1088
|
};
|
|
1080
1089
|
|
|
1081
|
-
|
|
1090
|
+
blocks['procedures_ifreturn'] = {
|
|
1082
1091
|
/**
|
|
1083
1092
|
* Block for conditionally returning a value from a procedure.
|
|
1084
1093
|
* @this {Block}
|
|
@@ -1130,11 +1139,12 @@ Blocks['procedures_ifreturn'] = {
|
|
|
1130
1139
|
/**
|
|
1131
1140
|
* Called whenever anything on the workspace changes.
|
|
1132
1141
|
* Add warning if this flow block is not nested inside a loop.
|
|
1133
|
-
* @param {!AbstractEvent}
|
|
1142
|
+
* @param {!AbstractEvent} e Move event.
|
|
1134
1143
|
* @this {Block}
|
|
1135
1144
|
*/
|
|
1136
|
-
onchange: function(
|
|
1137
|
-
if (this.workspace.isDragging && this.workspace.isDragging()
|
|
1145
|
+
onchange: function(e) {
|
|
1146
|
+
if (this.workspace.isDragging && this.workspace.isDragging() ||
|
|
1147
|
+
e.type !== Events.BLOCK_MOVE) {
|
|
1138
1148
|
return; // Don't change state at the start of a drag.
|
|
1139
1149
|
}
|
|
1140
1150
|
let legal = false;
|
|
@@ -1162,14 +1172,15 @@ Blocks['procedures_ifreturn'] = {
|
|
|
1162
1172
|
this.hasReturnValue_ = true;
|
|
1163
1173
|
}
|
|
1164
1174
|
this.setWarningText(null);
|
|
1165
|
-
if (!this.isInFlyout) {
|
|
1166
|
-
this.setEnabled(true);
|
|
1167
|
-
}
|
|
1168
1175
|
} else {
|
|
1169
1176
|
this.setWarningText(Msg['PROCEDURES_IFRETURN_WARNING']);
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1177
|
+
}
|
|
1178
|
+
if (!this.isInFlyout) {
|
|
1179
|
+
const group = Events.getGroup();
|
|
1180
|
+
// Makes it so the move and the disable event get undone together.
|
|
1181
|
+
Events.setGroup(e.group);
|
|
1182
|
+
this.setEnabled(legal);
|
|
1183
|
+
Events.setGroup(group);
|
|
1173
1184
|
}
|
|
1174
1185
|
},
|
|
1175
1186
|
/**
|
|
@@ -1179,3 +1190,6 @@ Blocks['procedures_ifreturn'] = {
|
|
|
1179
1190
|
*/
|
|
1180
1191
|
FUNCTION_TYPES: ['procedures_defnoreturn', 'procedures_defreturn'],
|
|
1181
1192
|
};
|
|
1193
|
+
|
|
1194
|
+
// Register provided blocks.
|
|
1195
|
+
defineBlocks(blocks);
|