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.
Files changed (262) hide show
  1. package/blockly.d.ts +18963 -18432
  2. package/blockly.min.js +852 -844
  3. package/blockly_compressed.js +669 -664
  4. package/blockly_compressed.js.map +1 -1
  5. package/blocks/blocks.js +47 -0
  6. package/blocks/colour.js +13 -3
  7. package/blocks/lists.js +22 -13
  8. package/blocks/logic.js +13 -3
  9. package/blocks/loops.js +24 -11
  10. package/blocks/math.js +12 -3
  11. package/blocks/procedures.js +41 -27
  12. package/blocks/text.js +22 -13
  13. package/blocks/variables.js +14 -3
  14. package/blocks/variables_dynamic.js +13 -3
  15. package/blocks_compressed.js +146 -141
  16. package/blocks_compressed.js.map +1 -1
  17. package/core/block.js +1869 -1814
  18. package/core/block_drag_surface.js +201 -200
  19. package/core/block_dragger.js +377 -373
  20. package/core/block_svg.js +1593 -1479
  21. package/core/blockly.js +8 -22
  22. package/core/blocks.js +9 -2
  23. package/core/browser_events.js +22 -5
  24. package/core/bubble.js +841 -797
  25. package/core/bubble_dragger.js +213 -206
  26. package/core/bump_objects.js +2 -2
  27. package/core/clipboard.js +9 -9
  28. package/core/comment.js +353 -332
  29. package/core/common.js +46 -17
  30. package/core/component_manager.js +181 -174
  31. package/core/config.js +87 -0
  32. package/core/connection.js +595 -584
  33. package/core/connection_checker.js +242 -244
  34. package/core/connection_db.js +235 -230
  35. package/core/contextmenu.js +9 -6
  36. package/core/contextmenu_items.js +1 -2
  37. package/core/contextmenu_registry.js +93 -89
  38. package/core/css.js +474 -474
  39. package/core/delete_area.js +45 -42
  40. package/core/drag_target.js +57 -56
  41. package/core/dropdowndiv.js +153 -163
  42. package/core/events/events.js +2 -2
  43. package/core/events/events_abstract.js +89 -77
  44. package/core/events/events_block_base.js +37 -36
  45. package/core/events/events_block_change.js +130 -124
  46. package/core/events/events_block_create.js +73 -71
  47. package/core/events/events_block_delete.js +84 -82
  48. package/core/events/events_block_drag.js +50 -49
  49. package/core/events/events_block_move.js +147 -140
  50. package/core/events/events_bubble_open.js +51 -50
  51. package/core/events/events_click.js +48 -44
  52. package/core/events/events_comment_base.js +72 -69
  53. package/core/events/events_comment_change.js +63 -61
  54. package/core/events/events_comment_create.js +44 -42
  55. package/core/events/events_comment_delete.js +42 -40
  56. package/core/events/events_comment_move.js +106 -104
  57. package/core/events/events_marker_move.js +65 -64
  58. package/core/events/events_selected.js +46 -45
  59. package/core/events/events_theme_change.js +36 -35
  60. package/core/events/events_toolbox_item_select.js +46 -45
  61. package/core/events/events_trashcan_open.js +37 -36
  62. package/core/events/events_ui.js +47 -46
  63. package/core/events/events_ui_base.js +30 -29
  64. package/core/events/events_var_base.js +37 -36
  65. package/core/events/events_var_create.js +50 -48
  66. package/core/events/events_var_delete.js +50 -48
  67. package/core/events/events_var_rename.js +51 -49
  68. package/core/events/events_viewport.js +66 -65
  69. package/core/events/utils.js +29 -14
  70. package/core/events/workspace_events.js +49 -55
  71. package/core/extensions.js +4 -3
  72. package/core/field.js +1061 -997
  73. package/core/field_angle.js +462 -442
  74. package/core/field_checkbox.js +194 -182
  75. package/core/field_colour.js +519 -505
  76. package/core/field_dropdown.js +617 -598
  77. package/core/field_image.js +229 -220
  78. package/core/field_label.js +102 -91
  79. package/core/field_label_serializable.js +42 -41
  80. package/core/field_multilineinput.js +372 -358
  81. package/core/field_number.js +272 -253
  82. package/core/field_textinput.js +499 -467
  83. package/core/field_variable.js +458 -420
  84. package/core/flyout_base.js +1005 -952
  85. package/core/flyout_button.js +277 -260
  86. package/core/flyout_horizontal.js +304 -302
  87. package/core/flyout_metrics_manager.js +64 -64
  88. package/core/flyout_vertical.js +306 -300
  89. package/core/generator.js +459 -446
  90. package/core/gesture.js +829 -813
  91. package/core/grid.js +166 -163
  92. package/core/icon.js +168 -159
  93. package/core/inject.js +7 -5
  94. package/core/input.js +257 -248
  95. package/core/insertion_marker_manager.js +655 -624
  96. package/core/internal_constants.js +0 -129
  97. package/core/keyboard_nav/ast_node.js +605 -596
  98. package/core/keyboard_nav/basic_cursor.js +166 -165
  99. package/core/keyboard_nav/cursor.js +99 -97
  100. package/core/keyboard_nav/marker.js +83 -79
  101. package/core/keyboard_nav/tab_navigate_cursor.js +18 -23
  102. package/core/marker_manager.js +153 -141
  103. package/core/menu.js +377 -372
  104. package/core/menuitem.js +223 -217
  105. package/core/metrics_manager.js +403 -390
  106. package/core/mutator.js +468 -437
  107. package/core/names.js +229 -188
  108. package/core/options.js +290 -284
  109. package/core/procedures.js +29 -17
  110. package/core/registry.js +19 -16
  111. package/core/rendered_connection.js +482 -463
  112. package/core/renderers/common/block_rendering.js +9 -3
  113. package/core/renderers/common/constants.js +1119 -1112
  114. package/core/renderers/common/debug.js +14 -0
  115. package/core/renderers/common/debugger.js +338 -316
  116. package/core/renderers/common/drawer.js +380 -370
  117. package/core/renderers/common/i_path_object.js +2 -2
  118. package/core/renderers/common/info.js +626 -618
  119. package/core/renderers/common/marker_svg.js +579 -541
  120. package/core/renderers/common/path_object.js +203 -200
  121. package/core/renderers/common/renderer.js +220 -218
  122. package/core/renderers/geras/constants.js +36 -36
  123. package/core/renderers/geras/drawer.js +155 -147
  124. package/core/renderers/geras/highlight_constants.js +244 -238
  125. package/core/renderers/geras/highlighter.js +231 -179
  126. package/core/renderers/geras/info.js +392 -369
  127. package/core/renderers/geras/measurables/inline_input.js +25 -19
  128. package/core/renderers/geras/measurables/statement_input.js +23 -17
  129. package/core/renderers/geras/path_object.js +106 -121
  130. package/core/renderers/geras/renderer.js +96 -98
  131. package/core/renderers/measurables/base.js +30 -18
  132. package/core/renderers/measurables/bottom_row.js +83 -80
  133. package/core/renderers/measurables/connection.js +22 -15
  134. package/core/renderers/measurables/external_value_input.js +35 -22
  135. package/core/renderers/measurables/field.js +35 -20
  136. package/core/renderers/measurables/hat.js +18 -13
  137. package/core/renderers/measurables/icon.js +24 -17
  138. package/core/renderers/measurables/in_row_spacer.js +15 -13
  139. package/core/renderers/measurables/inline_input.js +43 -33
  140. package/core/renderers/measurables/input_connection.js +41 -28
  141. package/core/renderers/measurables/input_row.js +50 -44
  142. package/core/renderers/measurables/jagged_edge.js +14 -12
  143. package/core/renderers/measurables/next_connection.js +16 -14
  144. package/core/renderers/measurables/output_connection.js +26 -20
  145. package/core/renderers/measurables/previous_connection.js +16 -15
  146. package/core/renderers/measurables/round_corner.js +20 -18
  147. package/core/renderers/measurables/row.js +184 -168
  148. package/core/renderers/measurables/spacer_row.js +38 -23
  149. package/core/renderers/measurables/square_corner.js +18 -16
  150. package/core/renderers/measurables/statement_input.js +23 -20
  151. package/core/renderers/measurables/top_row.js +88 -85
  152. package/core/renderers/minimalist/constants.js +8 -7
  153. package/core/renderers/minimalist/drawer.js +11 -10
  154. package/core/renderers/minimalist/info.js +18 -18
  155. package/core/renderers/minimalist/renderer.js +40 -39
  156. package/core/renderers/thrasos/info.js +258 -248
  157. package/core/renderers/thrasos/renderer.js +20 -20
  158. package/core/renderers/zelos/constants.js +898 -873
  159. package/core/renderers/zelos/drawer.js +186 -169
  160. package/core/renderers/zelos/info.js +502 -479
  161. package/core/renderers/zelos/marker_svg.js +129 -115
  162. package/core/renderers/zelos/measurables/bottom_row.js +31 -30
  163. package/core/renderers/zelos/measurables/inputs.js +22 -21
  164. package/core/renderers/zelos/measurables/row_elements.js +14 -13
  165. package/core/renderers/zelos/measurables/top_row.js +34 -33
  166. package/core/renderers/zelos/path_object.js +181 -180
  167. package/core/renderers/zelos/renderer.js +91 -92
  168. package/core/scrollbar.js +759 -713
  169. package/core/scrollbar_pair.js +250 -245
  170. package/core/serialization/blocks.js +19 -9
  171. package/core/serialization/workspaces.js +3 -2
  172. package/core/shortcut_registry.js +286 -277
  173. package/core/sprites.js +31 -0
  174. package/core/theme.js +135 -141
  175. package/core/theme_manager.js +147 -143
  176. package/core/toolbox/category.js +602 -576
  177. package/core/toolbox/collapsible_category.js +226 -227
  178. package/core/toolbox/separator.js +70 -61
  179. package/core/toolbox/toolbox.js +934 -927
  180. package/core/toolbox/toolbox_item.js +115 -99
  181. package/core/tooltip.js +108 -35
  182. package/core/touch.js +8 -3
  183. package/core/touch_gesture.js +254 -251
  184. package/core/trashcan.js +606 -595
  185. package/core/utils/coordinate.js +97 -95
  186. package/core/utils/dom.js +2 -2
  187. package/core/utils/global.js +2 -0
  188. package/core/utils/rect.js +41 -37
  189. package/core/utils/sentinel.js +25 -0
  190. package/core/utils/size.js +30 -27
  191. package/core/utils/svg.js +18 -16
  192. package/core/variable_map.js +325 -341
  193. package/core/variable_model.js +55 -54
  194. package/core/variables.js +9 -2
  195. package/core/variables_dynamic.js +3 -1
  196. package/core/warning.js +126 -120
  197. package/core/widgetdiv.js +4 -4
  198. package/core/workspace.js +685 -664
  199. package/core/workspace_audio.js +124 -118
  200. package/core/workspace_comment.js +308 -298
  201. package/core/workspace_comment_svg.js +1029 -951
  202. package/core/workspace_drag_surface_svg.js +147 -140
  203. package/core/workspace_dragger.js +70 -71
  204. package/core/workspace_svg.js +2322 -2297
  205. package/core/xml.js +30 -20
  206. package/core/zoom_controls.js +431 -439
  207. package/dart_compressed.js +40 -43
  208. package/dart_compressed.js.map +1 -1
  209. package/generators/dart/colour.js +56 -64
  210. package/generators/dart/lists.js +61 -50
  211. package/generators/dart/math.js +160 -148
  212. package/generators/dart/text.js +83 -61
  213. package/generators/javascript/colour.js +37 -34
  214. package/generators/javascript/lists.js +50 -43
  215. package/generators/javascript/math.js +123 -139
  216. package/generators/javascript/text.js +67 -81
  217. package/generators/lua/colour.js +25 -23
  218. package/generators/lua/lists.js +97 -69
  219. package/generators/lua/logic.js +1 -2
  220. package/generators/lua/math.js +182 -144
  221. package/generators/lua/text.js +116 -99
  222. package/generators/php/colour.js +38 -32
  223. package/generators/php/lists.js +109 -89
  224. package/generators/php/math.js +90 -81
  225. package/generators/php/text.js +63 -61
  226. package/generators/python/colour.js +18 -18
  227. package/generators/python/lists.js +38 -30
  228. package/generators/python/loops.js +12 -8
  229. package/generators/python/math.js +104 -106
  230. package/generators/python/text.js +34 -30
  231. package/javascript_compressed.js +37 -39
  232. package/javascript_compressed.js.map +1 -1
  233. package/lua_compressed.js +39 -42
  234. package/lua_compressed.js.map +1 -1
  235. package/msg/az.js +2 -2
  236. package/msg/be.js +4 -4
  237. package/msg/cs.js +15 -15
  238. package/msg/de.js +1 -1
  239. package/msg/diq.js +1 -1
  240. package/msg/eo.js +1 -1
  241. package/msg/es.js +1 -1
  242. package/msg/fa.js +1 -1
  243. package/msg/fr.js +4 -4
  244. package/msg/he.js +1 -1
  245. package/msg/hr.js +2 -2
  246. package/msg/hy.js +2 -2
  247. package/msg/id.js +12 -12
  248. package/msg/inh.js +14 -14
  249. package/msg/ja.js +7 -7
  250. package/msg/lv.js +29 -29
  251. package/msg/pa.js +3 -3
  252. package/msg/smn.js +436 -0
  253. package/msg/te.js +1 -1
  254. package/msg/yue.js +1 -1
  255. package/msg/zh-hans.js +3 -3
  256. package/msg/zh-hant.js +3 -3
  257. package/package.json +7 -6
  258. package/php_compressed.js +38 -42
  259. package/php_compressed.js.map +1 -1
  260. package/python_compressed.js +26 -25
  261. package/python_compressed.js.map +1 -1
  262. package/blocks/all.js +0 -23
@@ -17,9 +17,10 @@
17
17
  */
18
18
  goog.module('Blockly.geras.InlineInput');
19
19
 
20
- const object = goog.require('Blockly.utils.object');
21
20
  /* eslint-disable-next-line no-unused-vars */
22
- const {ConstantProvider} = goog.requireType('Blockly.blockRendering.ConstantProvider');
21
+ const {ConstantProvider: BaseConstantProvider} = goog.requireType('Blockly.blockRendering.ConstantProvider');
22
+ /* eslint-disable-next-line no-unused-vars */
23
+ const {ConstantProvider: GerasConstantProvider} = goog.requireType('Blockly.geras.ConstantProvider');
23
24
  const {InlineInput: BaseInlineInput} = goog.require('Blockly.blockRendering.InlineInput');
24
25
  /* eslint-disable-next-line no-unused-vars */
25
26
  const {Input} = goog.requireType('Blockly.Input');
@@ -27,26 +28,31 @@ const {Input} = goog.requireType('Blockly.Input');
27
28
 
28
29
  /**
29
30
  * An object containing information about the space an inline input takes up
30
- * during rendering
31
- * @param {!ConstantProvider} constants The rendering
32
- * constants provider.
33
- * @param {!Input} input The inline input to measure and store
34
- * information for.
35
- * @package
36
- * @constructor
31
+ * during rendering.
37
32
  * @extends {BaseInlineInput}
38
33
  * @alias Blockly.geras.InlineInput
39
34
  */
40
- const InlineInput = function(constants, input) {
41
- InlineInput.superClass_.constructor.call(this, constants, input);
42
-
43
- if (this.connectedBlock) {
44
- // We allow the dark path to show on the parent block so that the child
45
- // block looks embossed. This takes up an extra pixel in both x and y.
46
- this.width += this.constants_.DARK_PATH_OFFSET;
47
- this.height += this.constants_.DARK_PATH_OFFSET;
35
+ class InlineInput extends BaseInlineInput {
36
+ /**
37
+ * @param {!BaseConstantProvider} constants The rendering
38
+ * constants provider.
39
+ * @param {!Input} input The inline input to measure and store
40
+ * information for.
41
+ * @package
42
+ */
43
+ constructor(constants, input) {
44
+ super(constants, input);
45
+
46
+ /** @type {!GerasConstantProvider} */
47
+ this.constants_;
48
+
49
+ if (this.connectedBlock) {
50
+ // We allow the dark path to show on the parent block so that the child
51
+ // block looks embossed. This takes up an extra pixel in both x and y.
52
+ this.width += this.constants_.DARK_PATH_OFFSET;
53
+ this.height += this.constants_.DARK_PATH_OFFSET;
54
+ }
48
55
  }
49
- };
50
- object.inherits(InlineInput, BaseInlineInput);
56
+ }
51
57
 
52
58
  exports.InlineInput = InlineInput;
@@ -17,9 +17,10 @@
17
17
  */
18
18
  goog.module('Blockly.geras.StatementInput');
19
19
 
20
- const object = goog.require('Blockly.utils.object');
21
20
  /* eslint-disable-next-line no-unused-vars */
22
- const {ConstantProvider} = goog.requireType('Blockly.blockRendering.ConstantProvider');
21
+ const {ConstantProvider: BaseConstantProvider} = goog.requireType('Blockly.blockRendering.ConstantProvider');
22
+ /* eslint-disable-next-line no-unused-vars */
23
+ const {ConstantProvider: GerasConstantProvider} = goog.requireType('Blockly.geras.ConstantProvider');
23
24
  /* eslint-disable-next-line no-unused-vars */
24
25
  const {Input} = goog.requireType('Blockly.Input');
25
26
  const {StatementInput: BaseStatementInput} = goog.require('Blockly.blockRendering.StatementInput');
@@ -27,25 +28,30 @@ const {StatementInput: BaseStatementInput} = goog.require('Blockly.blockRenderin
27
28
 
28
29
  /**
29
30
  * An object containing information about the space a statement input takes up
30
- * during rendering
31
- * @param {!ConstantProvider} constants The rendering
32
- * constants provider.
33
- * @param {!Input} input The statement input to measure and store
34
- * information for.
35
- * @package
36
- * @constructor
31
+ * during rendering.
37
32
  * @extends {BaseStatementInput}
38
33
  * @alias Blockly.geras.StatementInput
39
34
  */
40
- const StatementInput = function(constants, input) {
41
- StatementInput.superClass_.constructor.call(this, constants, input);
35
+ class StatementInput extends BaseStatementInput {
36
+ /**
37
+ * @param {!BaseConstantProvider} constants The rendering
38
+ * constants provider.
39
+ * @param {!Input} input The statement input to measure and store
40
+ * information for.
41
+ * @package
42
+ */
43
+ constructor(constants, input) {
44
+ super(constants, input);
45
+
46
+ /** @type {!GerasConstantProvider} */
47
+ this.constants_;
42
48
 
43
- if (this.connectedBlock) {
44
- // We allow the dark path to show on the parent block so that the child
45
- // block looks embossed. This takes up an extra pixel in both x and y.
46
- this.height += this.constants_.DARK_PATH_OFFSET;
49
+ if (this.connectedBlock) {
50
+ // We allow the dark path to show on the parent block so that the child
51
+ // block looks embossed. This takes up an extra pixel in both x and y.
52
+ this.height += this.constants_.DARK_PATH_OFFSET;
53
+ }
47
54
  }
48
- };
49
- object.inherits(StatementInput, BaseStatementInput);
55
+ }
50
56
 
51
57
  exports.StatementInput = StatementInput;
@@ -18,7 +18,6 @@ goog.module('Blockly.geras.PathObject');
18
18
 
19
19
  const colour = goog.require('Blockly.utils.colour');
20
20
  const dom = goog.require('Blockly.utils.dom');
21
- const object = goog.require('Blockly.utils.object');
22
21
  /* eslint-disable-next-line no-unused-vars */
23
22
  const {ConstantProvider} = goog.requireType('Blockly.geras.ConstantProvider');
24
23
  const {PathObject: BasePathObject} = goog.require('Blockly.blockRendering.PathObject');
@@ -30,152 +29,138 @@ const {Theme} = goog.requireType('Blockly.Theme');
30
29
  /**
31
30
  * An object that handles creating and setting each of the SVG elements
32
31
  * used by the renderer.
33
- * @param {!SVGElement} root The root SVG element.
34
- * @param {!Theme.BlockStyle} style The style object to use for
35
- * colouring.
36
- * @param {!ConstantProvider} constants The renderer's constants.
37
- * @constructor
38
- * @extends {BasePathObject}
39
- * @package
40
32
  * @alias Blockly.geras.PathObject
41
33
  */
42
- const PathObject = function(root, style, constants) {
34
+ class PathObject extends BasePathObject {
43
35
  /**
44
- * The renderer's constant provider.
45
- * @type {!ConstantProvider}
46
- */
47
- this.constants = constants;
48
-
49
- this.svgRoot = root;
50
-
51
- // The order of creation for these next three matters, because that
52
- // effectively sets their z-indices.
53
-
54
- /**
55
- * The dark path of the block.
56
- * @type {SVGElement}
36
+ * @param {!SVGElement} root The root SVG element.
37
+ * @param {!Theme.BlockStyle} style The style object to use for
38
+ * colouring.
39
+ * @param {!ConstantProvider} constants The renderer's constants.
57
40
  * @package
58
41
  */
59
- this.svgPathDark = dom.createSvgElement(
60
- Svg.PATH, {'class': 'blocklyPathDark', 'transform': 'translate(1,1)'},
61
- this.svgRoot);
42
+ constructor(root, style, constants) {
43
+ super(root, style, constants);
44
+ /**
45
+ * The renderer's constant provider.
46
+ * @type {!ConstantProvider}
47
+ */
48
+ this.constants = constants;
49
+
50
+ /**
51
+ * The dark path of the block.
52
+ * @type {SVGElement}
53
+ * @package
54
+ */
55
+ this.svgPathDark = dom.createSvgElement(
56
+ Svg.PATH, {'class': 'blocklyPathDark', 'transform': 'translate(1,1)'});
57
+
58
+ // SVG draw order is based on the order of elements (top most = back most)
59
+ // So we need to insert the dark path before the base path to make sure it
60
+ // gets drawn first.
61
+ this.svgRoot.insertBefore(this.svgPathDark, this.svgPath);
62
+
63
+ /**
64
+ * The light path of the block.
65
+ * @type {SVGElement}
66
+ * @package
67
+ */
68
+ this.svgPathLight = dom.createSvgElement(
69
+ Svg.PATH, {'class': 'blocklyPathLight'}, this.svgRoot);
70
+
71
+ /**
72
+ * The colour of the dark path on the block in '#RRGGBB' format.
73
+ * @type {string}
74
+ * @package
75
+ */
76
+ this.colourDark = '#000000';
77
+ }
62
78
 
63
79
  /**
64
- * The primary path of the block.
65
- * @type {!SVGElement}
66
- * @package
80
+ * @override
67
81
  */
68
- this.svgPath =
69
- dom.createSvgElement(Svg.PATH, {'class': 'blocklyPath'}, this.svgRoot);
82
+ setPath(mainPath) {
83
+ this.svgPath.setAttribute('d', mainPath);
84
+ this.svgPathDark.setAttribute('d', mainPath);
85
+ }
70
86
 
71
87
  /**
72
- * The light path of the block.
73
- * @type {SVGElement}
88
+ * Set the highlight path generated by the renderer onto the SVG element.
89
+ * @param {string} highlightPath The highlight path.
74
90
  * @package
75
91
  */
76
- this.svgPathLight = dom.createSvgElement(
77
- Svg.PATH, {'class': 'blocklyPathLight'}, this.svgRoot);
92
+ setHighlightPath(highlightPath) {
93
+ this.svgPathLight.setAttribute('d', highlightPath);
94
+ }
78
95
 
79
96
  /**
80
- * The colour of the dark path on the block in '#RRGGBB' format.
81
- * @type {string}
82
- * @package
97
+ * @override
83
98
  */
84
- this.colourDark = '#000000';
99
+ flipRTL() {
100
+ // Mirror the block's path.
101
+ this.svgPath.setAttribute('transform', 'scale(-1 1)');
102
+ this.svgPathLight.setAttribute('transform', 'scale(-1 1)');
103
+ this.svgPathDark.setAttribute('transform', 'translate(1,1) scale(-1 1)');
104
+ }
85
105
 
86
106
  /**
87
- * The style object to use when colouring block paths.
88
- * @type {!Theme.BlockStyle}
89
- * @package
107
+ * @override
90
108
  */
91
- this.style = style;
92
- };
93
- object.inherits(PathObject, BasePathObject);
109
+ applyColour(block) {
110
+ this.svgPathLight.style.display = '';
111
+ this.svgPathDark.style.display = '';
112
+ this.svgPathLight.setAttribute('stroke', this.style.colourTertiary);
113
+ this.svgPathDark.setAttribute('fill', this.colourDark);
94
114
 
95
- /**
96
- * @override
97
- */
98
- PathObject.prototype.setPath = function(mainPath) {
99
- this.svgPath.setAttribute('d', mainPath);
100
- this.svgPathDark.setAttribute('d', mainPath);
101
- };
102
-
103
- /**
104
- * Set the highlight path generated by the renderer onto the SVG element.
105
- * @param {string} highlightPath The highlight path.
106
- * @package
107
- */
108
- PathObject.prototype.setHighlightPath = function(highlightPath) {
109
- this.svgPathLight.setAttribute('d', highlightPath);
110
- };
111
-
112
- /**
113
- * @override
114
- */
115
- PathObject.prototype.flipRTL = function() {
116
- // Mirror the block's path.
117
- this.svgPath.setAttribute('transform', 'scale(-1 1)');
118
- this.svgPathLight.setAttribute('transform', 'scale(-1 1)');
119
- this.svgPathDark.setAttribute('transform', 'translate(1,1) scale(-1 1)');
120
- };
121
-
122
- /**
123
- * @override
124
- */
125
- PathObject.prototype.applyColour = function(block) {
126
- this.svgPathLight.style.display = '';
127
- this.svgPathDark.style.display = '';
128
- this.svgPathLight.setAttribute('stroke', this.style.colourTertiary);
129
- this.svgPathDark.setAttribute('fill', this.colourDark);
115
+ super.applyColour(block);
130
116
 
131
- PathObject.superClass_.applyColour.call(this, block);
132
-
133
- this.svgPath.setAttribute('stroke', 'none');
134
- };
117
+ this.svgPath.setAttribute('stroke', 'none');
118
+ }
135
119
 
136
- /**
137
- * @override
138
- */
139
- PathObject.prototype.setStyle = function(blockStyle) {
140
- this.style = blockStyle;
141
- this.colourDark =
142
- colour.blend('#000', this.style.colourPrimary, 0.2) || this.colourDark;
143
- };
120
+ /**
121
+ * @override
122
+ */
123
+ setStyle(blockStyle) {
124
+ this.style = blockStyle;
125
+ this.colourDark =
126
+ colour.blend('#000', this.style.colourPrimary, 0.2) || this.colourDark;
127
+ }
144
128
 
145
- /**
146
- * @override
147
- */
148
- PathObject.prototype.updateHighlighted = function(highlighted) {
149
- if (highlighted) {
150
- this.svgPath.setAttribute(
151
- 'filter', 'url(#' + this.constants.embossFilterId + ')');
152
- this.svgPathLight.style.display = 'none';
153
- } else {
154
- this.svgPath.setAttribute('filter', 'none');
155
- this.svgPathLight.style.display = 'inline';
129
+ /**
130
+ * @override
131
+ */
132
+ updateHighlighted(highlighted) {
133
+ if (highlighted) {
134
+ this.svgPath.setAttribute(
135
+ 'filter', 'url(#' + this.constants.embossFilterId + ')');
136
+ this.svgPathLight.style.display = 'none';
137
+ } else {
138
+ this.svgPath.setAttribute('filter', 'none');
139
+ this.svgPathLight.style.display = 'inline';
140
+ }
156
141
  }
157
- };
158
142
 
159
- /**
160
- * @override
161
- */
162
- PathObject.prototype.updateShadow_ = function(shadow) {
163
- if (shadow) {
164
- this.svgPathLight.style.display = 'none';
165
- this.svgPathDark.setAttribute('fill', this.style.colourSecondary);
166
- this.svgPath.setAttribute('stroke', 'none');
167
- this.svgPath.setAttribute('fill', this.style.colourSecondary);
143
+ /**
144
+ * @override
145
+ */
146
+ updateShadow_(shadow) {
147
+ if (shadow) {
148
+ this.svgPathLight.style.display = 'none';
149
+ this.svgPathDark.setAttribute('fill', this.style.colourSecondary);
150
+ this.svgPath.setAttribute('stroke', 'none');
151
+ this.svgPath.setAttribute('fill', this.style.colourSecondary);
152
+ }
168
153
  }
169
- };
170
154
 
171
- /**
172
- * @override
173
- */
174
- PathObject.prototype.updateDisabled_ = function(disabled) {
175
- PathObject.superClass_.updateDisabled_.call(this, disabled);
176
- if (disabled) {
177
- this.svgPath.setAttribute('stroke', 'none');
155
+ /**
156
+ * @override
157
+ */
158
+ updateDisabled_(disabled) {
159
+ super.updateDisabled_(disabled);
160
+ if (disabled) {
161
+ this.svgPath.setAttribute('stroke', 'none');
162
+ }
178
163
  }
179
- };
164
+ }
180
165
 
181
166
  exports.PathObject = PathObject;
@@ -16,7 +16,6 @@
16
16
  goog.module('Blockly.geras.Renderer');
17
17
 
18
18
  const blockRendering = goog.require('Blockly.blockRendering');
19
- const object = goog.require('Blockly.utils.object');
20
19
  /* eslint-disable-next-line no-unused-vars */
21
20
  const {BlockSvg} = goog.requireType('Blockly.BlockSvg');
22
21
  /* eslint-disable-next-line no-unused-vars */
@@ -35,116 +34,115 @@ const {Theme} = goog.requireType('Blockly.Theme');
35
34
 
36
35
  /**
37
36
  * The geras renderer.
38
- * @param {string} name The renderer name.
39
- * @package
40
- * @constructor
41
37
  * @extends {BaseRenderer}
42
38
  * @alias Blockly.geras.Renderer
43
39
  */
44
- const Renderer = function(name) {
45
- Renderer.superClass_.constructor.call(this, name);
46
-
40
+ class Renderer extends BaseRenderer {
47
41
  /**
48
- * The renderer's highlight constant provider.
49
- * @type {HighlightConstantProvider}
50
- * @private
42
+ * @param {string} name The renderer name.
43
+ * @package
51
44
  */
52
- this.highlightConstants_ = null;
53
- };
54
- object.inherits(Renderer, BaseRenderer);
45
+ constructor(name) {
46
+ super(name);
55
47
 
56
- /**
57
- * Initialize the renderer. Geras has a highlight provider in addition to
58
- * the normal constant provider.
59
- * @package
60
- * @override
61
- */
62
- Renderer.prototype.init = function(theme, opt_rendererOverrides) {
63
- Renderer.superClass_.init.call(this, theme, opt_rendererOverrides);
64
- this.highlightConstants_ = this.makeHighlightConstants_();
65
- this.highlightConstants_.init();
66
- };
48
+ /**
49
+ * The renderer's highlight constant provider.
50
+ * @type {HighlightConstantProvider}
51
+ * @private
52
+ */
53
+ this.highlightConstants_ = null;
54
+ }
67
55
 
68
- /**
69
- * @override
70
- */
71
- Renderer.prototype.refreshDom = function(svg, theme) {
72
- Renderer.superClass_.refreshDom.call(this, svg, theme);
73
- this.getHighlightConstants().init();
74
- };
56
+ /**
57
+ * Initialize the renderer. Geras has a highlight provider in addition to
58
+ * the normal constant provider.
59
+ * @package
60
+ * @override
61
+ */
62
+ init(theme, opt_rendererOverrides) {
63
+ super.init(theme, opt_rendererOverrides);
64
+ this.highlightConstants_ = this.makeHighlightConstants_();
65
+ this.highlightConstants_.init();
66
+ }
75
67
 
76
- /**
77
- * @override
78
- */
79
- Renderer.prototype.makeConstants_ = function() {
80
- return new ConstantProvider();
81
- };
68
+ /**
69
+ * @override
70
+ */
71
+ refreshDom(svg, theme) {
72
+ super.refreshDom(svg, theme);
73
+ this.getHighlightConstants().init();
74
+ }
82
75
 
83
- /**
84
- * Create a new instance of the renderer's render info object.
85
- * @param {!BlockSvg} block The block to measure.
86
- * @return {!RenderInfo} The render info object.
87
- * @protected
88
- * @override
89
- */
90
- Renderer.prototype.makeRenderInfo_ = function(block) {
91
- return new RenderInfo(this, block);
92
- };
76
+ /**
77
+ * @override
78
+ */
79
+ makeConstants_() {
80
+ return new ConstantProvider();
81
+ }
93
82
 
94
- /**
95
- * Create a new instance of the renderer's drawer.
96
- * @param {!BlockSvg} block The block to render.
97
- * @param {!BaseRenderInfo} info An object containing all
98
- * information needed to render this block.
99
- * @return {!Drawer} The drawer.
100
- * @protected
101
- * @override
102
- */
103
- Renderer.prototype.makeDrawer_ = function(block, info) {
104
- return new Drawer(
105
- block,
106
- /** @type {!RenderInfo} */ (info));
107
- };
83
+ /**
84
+ * Create a new instance of the renderer's render info object.
85
+ * @param {!BlockSvg} block The block to measure.
86
+ * @return {!RenderInfo} The render info object.
87
+ * @protected
88
+ * @override
89
+ */
90
+ makeRenderInfo_(block) {
91
+ return new RenderInfo(this, block);
92
+ }
108
93
 
109
- /**
110
- * Create a new instance of a renderer path object.
111
- * @param {!SVGElement} root The root SVG element.
112
- * @param {!Theme.BlockStyle} style The style object to use for
113
- * colouring.
114
- * @return {!PathObject} The renderer path object.
115
- * @package
116
- * @override
117
- */
118
- Renderer.prototype.makePathObject = function(root, style) {
119
- return new PathObject(
120
- root, style,
121
- /** @type {!ConstantProvider} */ (this.getConstants()));
122
- };
94
+ /**
95
+ * Create a new instance of the renderer's drawer.
96
+ * @param {!BlockSvg} block The block to render.
97
+ * @param {!BaseRenderInfo} info An object containing all information needed
98
+ * to render this block.
99
+ * @return {!Drawer} The drawer.
100
+ * @protected
101
+ * @override
102
+ */
103
+ makeDrawer_(block, info) {
104
+ return new Drawer(
105
+ block,
106
+ /** @type {!RenderInfo} */ (info));
107
+ }
123
108
 
124
- /**
125
- * Create a new instance of the renderer's highlight constant provider.
126
- * @return {!HighlightConstantProvider} The highlight constant
127
- * provider.
128
- * @protected
129
- */
130
- Renderer.prototype.makeHighlightConstants_ = function() {
131
- return new HighlightConstantProvider(
132
- /** @type {!BaseConstantProvider} */
133
- (this.getConstants()));
134
- };
109
+ /**
110
+ * Create a new instance of a renderer path object.
111
+ * @param {!SVGElement} root The root SVG element.
112
+ * @param {!Theme.BlockStyle} style The style object to use for colouring.
113
+ * @return {!PathObject} The renderer path object.
114
+ * @package
115
+ * @override
116
+ */
117
+ makePathObject(root, style) {
118
+ return new PathObject(
119
+ root, style,
120
+ /** @type {!ConstantProvider} */ (this.getConstants()));
121
+ }
135
122
 
136
- /**
137
- * Get the renderer's highlight constant provider. We assume that when this is
138
- * called, the renderer has already been initialized.
139
- * @return {!HighlightConstantProvider} The highlight constant
140
- * provider.
141
- * @package
142
- */
143
- Renderer.prototype.getHighlightConstants = function() {
144
- return (
145
- /** @type {!HighlightConstantProvider} */
146
- (this.highlightConstants_));
147
- };
123
+ /**
124
+ * Create a new instance of the renderer's highlight constant provider.
125
+ * @return {!HighlightConstantProvider} The highlight constant provider.
126
+ * @protected
127
+ */
128
+ makeHighlightConstants_() {
129
+ return new HighlightConstantProvider(
130
+ /** @type {!BaseConstantProvider} */
131
+ (this.getConstants()));
132
+ }
133
+
134
+ /**
135
+ * Get the renderer's highlight constant provider. We assume that when this
136
+ * is called, the renderer has already been initialized.
137
+ * @return {!HighlightConstantProvider} The highlight constant provider.
138
+ * @package
139
+ */
140
+ getHighlightConstants() {
141
+ return (
142
+ /** @type {!HighlightConstantProvider} */
143
+ (this.highlightConstants_));
144
+ }
145
+ }
148
146
 
149
147
  blockRendering.register('geras', Renderer);
150
148
 
@@ -25,28 +25,40 @@ const {Types} = goog.require('Blockly.blockRendering.Types');
25
25
  * The base class to represent a part of a block that takes up space during
26
26
  * rendering. The constructor for each non-spacer Measurable records the size
27
27
  * of the block element (e.g. field, statement input).
28
- * @param {!ConstantProvider} constants The rendering
29
- * constants provider.
30
- * @package
31
- * @constructor
32
28
  * @alias Blockly.blockRendering.Measurable
33
29
  */
34
- const Measurable = function(constants) {
35
- this.width = 0;
36
- this.height = 0;
37
- this.type = Types.NONE;
38
-
39
- this.xPos = 0;
40
- this.centerline = 0;
41
-
30
+ class Measurable {
42
31
  /**
43
- * The renderer's constant provider.
44
- * @type {!ConstantProvider}
45
- * @protected
32
+ * @param {!ConstantProvider} constants The rendering
33
+ * constants provider.
34
+ * @package
46
35
  */
47
- this.constants_ = constants;
36
+ constructor(constants) {
37
+ /** @type {number} */
38
+ this.width = 0;
39
+
40
+ /** @type {number} */
41
+ this.height = 0;
42
+
43
+ /** @type {number} */
44
+ this.type = Types.NONE;
45
+
46
+ /** @type {number} */
47
+ this.xPos = 0;
48
+
49
+ /** @type {number} */
50
+ this.centerline = 0;
51
+
52
+ /**
53
+ * The renderer's constant provider.
54
+ * @type {!ConstantProvider}
55
+ * @protected
56
+ */
57
+ this.constants_ = constants;
48
58
 
49
- this.notchOffset = this.constants_.NOTCH_OFFSET_LEFT;
50
- };
59
+ /** @type {number} */
60
+ this.notchOffset = this.constants_.NOTCH_OFFSET_LEFT;
61
+ }
62
+ }
51
63
 
52
64
  exports.Measurable = Measurable;