blockly 11.0.0-beta.5 → 11.0.0-beta.7

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 (139) hide show
  1. package/blockly.min.js +722 -763
  2. package/blockly_compressed.js +676 -680
  3. package/blockly_compressed.js.map +1 -1
  4. package/blocks_compressed.js +27 -29
  5. package/blocks_compressed.js.map +1 -1
  6. package/core/block.d.ts +12 -6
  7. package/core/block_svg.d.ts +28 -42
  8. package/core/blockly.d.ts +11 -51
  9. package/core/bubbles/bubble.d.ts +17 -2
  10. package/core/bubbles/mini_workspace_bubble.d.ts +1 -1
  11. package/core/bubbles/text_bubble.d.ts +1 -1
  12. package/core/bubbles/textinput_bubble.d.ts +1 -1
  13. package/core/clipboard.d.ts +0 -19
  14. package/core/comments/comment_view.d.ts +207 -0
  15. package/core/comments/rendered_workspace_comment.d.ts +75 -0
  16. package/core/comments/workspace_comment.d.ts +107 -0
  17. package/core/comments.d.ts +9 -0
  18. package/core/connection.d.ts +1 -1
  19. package/core/delete_area.d.ts +1 -2
  20. package/core/dragging/block_drag_strategy.d.ts +105 -0
  21. package/core/dragging/bubble_drag_strategy.d.ts +20 -0
  22. package/core/dragging/comment_drag_strategy.d.ts +20 -0
  23. package/core/dragging/dragger.d.ts +47 -0
  24. package/core/events/events.d.ts +3 -0
  25. package/core/events/events_click.d.ts +1 -1
  26. package/core/events/events_comment_base.d.ts +6 -1
  27. package/core/events/events_comment_change.d.ts +1 -1
  28. package/core/events/events_comment_collapse.d.ts +39 -0
  29. package/core/events/events_comment_create.d.ts +5 -1
  30. package/core/events/events_comment_delete.d.ts +5 -1
  31. package/core/events/events_comment_move.d.ts +17 -1
  32. package/core/events/utils.d.ts +2 -0
  33. package/core/field_dropdown.d.ts +1 -0
  34. package/core/field_image.d.ts +1 -1
  35. package/core/flyout_base.d.ts +17 -1
  36. package/core/flyout_button.d.ts +26 -1
  37. package/core/generator.d.ts +1 -1
  38. package/core/gesture.d.ts +25 -54
  39. package/core/grid.d.ts +9 -9
  40. package/core/icons/comment_icon.d.ts +8 -3
  41. package/core/icons/icon.d.ts +0 -6
  42. package/core/icons/icon_types.d.ts +2 -2
  43. package/core/icons/mutator_icon.d.ts +1 -16
  44. package/core/icons/warning_icon.d.ts +1 -1
  45. package/core/inputs/input.d.ts +10 -19
  46. package/core/{connection_previewers/insertion_marker_previewer.d.ts → insertion_marker_previewer.d.ts} +3 -3
  47. package/core/interfaces/i_comment_icon.d.ts +21 -0
  48. package/core/interfaces/i_deletable.d.ts +6 -0
  49. package/core/interfaces/i_delete_area.d.ts +1 -2
  50. package/core/interfaces/i_draggable.d.ts +47 -3
  51. package/core/interfaces/i_dragger.d.ts +32 -0
  52. package/core/interfaces/i_has_bubble.d.ts +1 -1
  53. package/core/interfaces/i_parameter_model.d.ts +7 -0
  54. package/core/interfaces/i_procedure_model.d.ts +7 -0
  55. package/core/interfaces/i_selectable.d.ts +5 -3
  56. package/core/internal_constants.d.ts +0 -7
  57. package/core/keyboard_nav/ast_node.d.ts +21 -2
  58. package/core/options.d.ts +1 -0
  59. package/core/registry.d.ts +2 -2
  60. package/core/renderers/common/drawer.d.ts +0 -7
  61. package/core/renderers/common/marker_svg.d.ts +7 -0
  62. package/core/renderers/measurables/icon.d.ts +0 -5
  63. package/core/serialization/priorities.d.ts +2 -0
  64. package/core/serialization/procedures.d.ts +28 -26
  65. package/core/serialization/workspace_comments.d.ts +45 -0
  66. package/core/serialization.d.ts +2 -1
  67. package/core/toolbox/toolbox.d.ts +1 -2
  68. package/core/utils/dom.d.ts +0 -9
  69. package/core/utils/keycodes.d.ts +32 -32
  70. package/core/utils/size.d.ts +10 -0
  71. package/core/utils/string.d.ts +0 -10
  72. package/core/workspace_comment_svg.d.ts +1 -2
  73. package/core/workspace_svg.d.ts +0 -27
  74. package/core/xml.d.ts +9 -3
  75. package/core-node.js +31 -0
  76. package/dart.d.ts +1 -24
  77. package/dart_compressed.js +22 -72
  78. package/dart_compressed.js.map +1 -1
  79. package/generators/dart/dart_generator.d.ts +17 -17
  80. package/generators/dart/text.d.ts +0 -1
  81. package/generators/javascript/javascript_generator.d.ts +34 -35
  82. package/generators/javascript/text.d.ts +0 -1
  83. package/generators/lua/lua_generator.d.ts +10 -10
  84. package/generators/lua/text.d.ts +0 -1
  85. package/generators/php/php_generator.d.ts +36 -36
  86. package/generators/php/text.d.ts +0 -1
  87. package/generators/python/python_generator.d.ts +20 -21
  88. package/generators/python/text.d.ts +0 -1
  89. package/index.js +19 -7
  90. package/javascript.d.ts +1 -41
  91. package/javascript_compressed.js +19 -54
  92. package/javascript_compressed.js.map +1 -1
  93. package/lua.d.ts +1 -18
  94. package/lua_compressed.js +24 -47
  95. package/lua_compressed.js.map +1 -1
  96. package/media/delete-icon.svg +1 -0
  97. package/media/foldout-icon.svg +1 -0
  98. package/media/resize-handle.svg +3 -0
  99. package/msg/ce.d.ts +8 -0
  100. package/msg/dtp.d.ts +8 -0
  101. package/msg/hsb.d.ts +8 -0
  102. package/msg/tdd.d.ts +8 -0
  103. package/package.json +46 -12
  104. package/php.d.ts +1 -43
  105. package/php_compressed.js +13 -46
  106. package/php_compressed.js.map +1 -1
  107. package/python.d.ts +1 -27
  108. package/python_compressed.js +21 -40
  109. package/python_compressed.js.map +1 -1
  110. package/blockly.js +0 -22
  111. package/blocks.js +0 -22
  112. package/browser.js +0 -30
  113. package/core/block_dragger.d.ts +0 -212
  114. package/core/bubble_dragger.d.ts +0 -77
  115. package/core/field_angle.d.ts +0 -208
  116. package/core/field_colour.d.ts +0 -243
  117. package/core/field_multilineinput.d.ts +0 -182
  118. package/core/interfaces/i_block_dragger.d.ts +0 -47
  119. package/core/renderers/minimalist/constants.d.ts +0 -21
  120. package/core/renderers/minimalist/drawer.d.ts +0 -26
  121. package/core/renderers/minimalist/info.d.ts +0 -35
  122. package/core/renderers/minimalist/minimalist.d.ts +0 -12
  123. package/core/renderers/minimalist/renderer.d.ts +0 -48
  124. package/core-browser.js +0 -26
  125. package/core.js +0 -26
  126. package/dart.js +0 -22
  127. package/generators/dart/colour.d.ts +0 -16
  128. package/generators/javascript/colour.d.ts +0 -16
  129. package/generators/lua/colour.d.ts +0 -16
  130. package/generators/php/colour.d.ts +0 -16
  131. package/generators/python/colour.d.ts +0 -16
  132. package/javascript.js +0 -23
  133. package/lua.js +0 -22
  134. package/msg/constants.d.ts +0 -14
  135. package/msg/qqq.d.ts +0 -14
  136. package/msg/synonyms.d.ts +0 -14
  137. package/node.js +0 -21
  138. package/php.js +0 -22
  139. package/python.js +0 -23
package/blockly.js DELETED
@@ -1,22 +0,0 @@
1
- /* eslint-disable */
2
- ;(function(root, factory) {
3
- if (typeof define === 'function' && define.amd) { // AMD
4
- define(['./blockly_compressed'], factory);
5
- } else if (typeof exports === 'object') { // Node.js
6
- module.exports = factory(require('./blockly_compressed'));
7
- } else { // Browser
8
- root.Blockly = factory(root.Blockly);
9
- }
10
- }(this, function(Blockly) {
11
- /**
12
- * @license
13
- * Copyright 2020 Google LLC
14
- * SPDX-License-Identifier: Apache-2.0
15
- */
16
-
17
- /**
18
- * @fileoverview Blockly module; just a wrapper for blockly_compressed.js.
19
- */
20
-
21
- return Blockly;
22
- }));
package/blocks.js DELETED
@@ -1,22 +0,0 @@
1
- /* eslint-disable */
2
- ;(function(root, factory) {
3
- if (typeof define === 'function' && define.amd) { // AMD
4
- define(['./blocks_compressed'], factory);
5
- } else if (typeof exports === 'object') { // Node.js
6
- module.exports = factory(require('./blocks_compressed'));
7
- } else { // Browser
8
- root.BlocklyBlocks = factory(root.BlocklyBlocks);
9
- }
10
- }(this, function(BlocklyBlocks) {
11
- /**
12
- * @license
13
- * Copyright 2020 Google LLC
14
- * SPDX-License-Identifier: Apache-2.0
15
- */
16
-
17
- /**
18
- * @fileoverview Blockly blocks module; just a wrapper for blocks_compressed.js.
19
- */
20
-
21
- return BlocklyBlocks;
22
- }));
package/browser.js DELETED
@@ -1,30 +0,0 @@
1
- /* eslint-disable */
2
- ;(function(root, factory) {
3
- if (typeof define === 'function' && define.amd) { // AMD
4
- define(['./core-browser', './msg/en', './blocks', './javascript'], factory);
5
- } else if (typeof exports === 'object') { // Node.js
6
- module.exports = factory(require('./core-browser'), require('./msg/en'), require('./blocks'), require('./javascript'));
7
- } else { // Browser
8
- root.Blockly = factory(root.Blockly, root.En, root.BlocklyBlocks, root.BlocklyJS);
9
- }
10
- }(this, function(Blockly, En, BlocklyBlocks, BlocklyJS) {
11
- /**
12
- * @license
13
- * Copyright 2019 Google LLC
14
- * SPDX-License-Identifier: Apache-2.0
15
- */
16
-
17
- /**
18
- * @fileoverview Blockly module for the browser. This includes Blockly core
19
- * and built in blocks, the JavaScript code generator and the English block
20
- * localization files.
21
- */
22
-
23
- /* eslint-disable */
24
- 'use strict';
25
-
26
- // Include the EN Locale by default.
27
- Blockly.setLocale(En);
28
-
29
- return Blockly;
30
- }));
@@ -1,212 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2017 Google LLC
4
- * SPDX-License-Identifier: Apache-2.0
5
- */
6
- /**
7
- * Methods for dragging a block visually.
8
- *
9
- * @class
10
- */
11
- import './events/events_block_drag.js';
12
- import type { BlockSvg } from './block_svg.js';
13
- import type { Icon } from './icons/icon.js';
14
- import type { IBlockDragger } from './interfaces/i_block_dragger.js';
15
- import { Coordinate } from './utils/coordinate.js';
16
- import type { WorkspaceSvg } from './workspace_svg.js';
17
- import { IConnectionPreviewer } from './blockly.js';
18
- /**
19
- * Class for a block dragger. It moves blocks around the workspace when they
20
- * are being dragged by a mouse or touch.
21
- */
22
- export declare class BlockDragger implements IBlockDragger {
23
- /** The top block in the stack that is being dragged. */
24
- protected draggingBlock_: BlockSvg;
25
- protected connectionPreviewer: IConnectionPreviewer;
26
- /** The workspace on which the block is being dragged. */
27
- protected workspace_: WorkspaceSvg;
28
- /** Which drag area the mouse pointer is over, if any. */
29
- private dragTarget_;
30
- private connectionCandidate;
31
- /** Whether the block would be deleted if dropped immediately. */
32
- protected wouldDeleteBlock_: boolean;
33
- protected startXY_: Coordinate;
34
- /**
35
- * @deprecated To be removed in v11. Updating icons is now handled by the
36
- * block's `moveDuringDrag` method.
37
- */
38
- protected dragIconData_: IconPositionData[];
39
- /**
40
- * @param block The block to drag.
41
- * @param workspace The workspace to drag on.
42
- */
43
- constructor(block: BlockSvg, workspace: WorkspaceSvg);
44
- /**
45
- * Sever all links from this object.
46
- *
47
- * @internal
48
- */
49
- dispose(): void;
50
- /**
51
- * Start dragging a block.
52
- *
53
- * @param currentDragDeltaXY How far the pointer has moved from the position
54
- * at mouse down, in pixel units.
55
- * @param healStack Whether or not to heal the stack after disconnecting.
56
- */
57
- startDrag(currentDragDeltaXY: Coordinate, healStack: boolean): void;
58
- /**
59
- * Whether or not we should disconnect the block when a drag is started.
60
- *
61
- * @param healStack Whether or not to heal the stack after disconnecting.
62
- * @returns True to disconnect the block, false otherwise.
63
- */
64
- protected shouldDisconnect_(healStack: boolean): boolean;
65
- /**
66
- * Disconnects the block and moves it to a new location.
67
- *
68
- * @param healStack Whether or not to heal the stack after disconnecting.
69
- * @param currentDragDeltaXY How far the pointer has moved from the position
70
- * at mouse down, in pixel units.
71
- */
72
- protected disconnectBlock_(healStack: boolean, currentDragDeltaXY: Coordinate): void;
73
- /** Fire a UI event at the start of a block drag. */
74
- protected fireDragStartEvent_(): void;
75
- /**
76
- * Execute a step of block dragging, based on the given event. Update the
77
- * display accordingly.
78
- *
79
- * @param e The most recent move event.
80
- * @param delta How far the pointer has moved from the position
81
- * at the start of the drag, in pixel units.
82
- */
83
- drag(e: PointerEvent, delta: Coordinate): void;
84
- /**
85
- * @param draggingBlock The block being dragged.
86
- * @param dragDelta How far the pointer has moved from the position
87
- * at the start of the drag, in pixel units.
88
- */
89
- private moveBlock;
90
- private updateDragTargets;
91
- /**
92
- * Returns true if we would delete the block if it was dropped at this time,
93
- * false otherwise.
94
- *
95
- * @param e The most recent move event.
96
- * @param draggingBlock The block being dragged.
97
- * @param delta How far the pointer has moved from the position
98
- * at the start of the drag, in pixel units.
99
- */
100
- private wouldDeleteBlock;
101
- /**
102
- * @param draggingBlock The block being dragged.
103
- * @param dragDelta How far the pointer has moved from the position
104
- * at the start of the drag, in pixel units.
105
- */
106
- private updateConnectionPreview;
107
- /**
108
- * Returns true if the given orphan block can connect at the end of the
109
- * top block's stack or row, false otherwise.
110
- */
111
- private orphanCanConnectAtEnd;
112
- /**
113
- * Returns true if the current candidate is better than the new candidate.
114
- *
115
- * We slightly prefer the current candidate even if it is farther away.
116
- */
117
- private currCandidateIsBetter;
118
- /**
119
- * Returns the closest valid candidate connection, if one can be found.
120
- *
121
- * Valid neighbour connections are within the configured start radius, with a
122
- * compatible type (input, output, etc) and connection check.
123
- */
124
- private getConnectionCandidate;
125
- /**
126
- * Returns all of the connections we might connect to blocks on the workspace.
127
- *
128
- * Includes any connections on the dragging block, and any last next
129
- * connection on the stack (if one exists).
130
- */
131
- private getLocalConnections;
132
- /**
133
- * Finish a block drag and put the block back on the workspace.
134
- *
135
- * @param e The pointerup event.
136
- * @param currentDragDeltaXY How far the pointer has moved from the position
137
- * at the start of the drag, in pixel units.
138
- */
139
- endDrag(e: PointerEvent, currentDragDeltaXY: Coordinate): void;
140
- /**
141
- * Calculates the drag delta and new location values after a block is dragged.
142
- *
143
- * @param currentDragDeltaXY How far the pointer has moved from the start of
144
- * the drag, in pixel units.
145
- * @returns New location after drag. delta is in workspace units. newLocation
146
- * is the new coordinate where the block should end up.
147
- */
148
- protected getNewLocationAfterDrag_(currentDragDeltaXY: Coordinate): {
149
- delta: Coordinate;
150
- newLocation: Coordinate;
151
- };
152
- /**
153
- * May delete the dragging block, if allowed. If `this.wouldDeleteBlock_` is
154
- * not true, the block will not be deleted. This should be called at the end
155
- * of a block drag.
156
- *
157
- * @returns True if the block was deleted.
158
- */
159
- protected maybeDeleteBlock_(): boolean;
160
- /**
161
- * Updates the necessary information to place a block at a certain location.
162
- */
163
- protected updateBlockAfterMove_(): void;
164
- private applyConnections;
165
- /** Fire a UI event at the end of a block drag. */
166
- protected fireDragEndEvent_(): void;
167
- /**
168
- * Adds or removes the style of the cursor for the toolbox.
169
- * This is what changes the cursor to display an x when a deletable block is
170
- * held over the toolbox.
171
- *
172
- * @param isEnd True if we are at the end of a drag, false otherwise.
173
- */
174
- protected updateToolboxStyle_(isEnd: boolean): void;
175
- /** Fire a move event at the end of a block drag. */
176
- protected fireMoveEvent_(): void;
177
- /**
178
- * Update the cursor (and possibly the trash can lid) to reflect whether the
179
- * dragging block would be deleted if released immediately.
180
- */
181
- protected updateCursorDuringBlockDrag_(): void;
182
- /**
183
- * Convert a coordinate object from pixels to workspace units, including a
184
- * correction for mutator workspaces.
185
- * This function does not consider differing origins. It simply scales the
186
- * input's x and y values.
187
- *
188
- * @param pixelCoord A coordinate with x and y values in CSS pixel units.
189
- * @returns The input coordinate divided by the workspace scale.
190
- */
191
- protected pixelsToWorkspaceUnits_(pixelCoord: Coordinate): Coordinate;
192
- /**
193
- * Move all of the icons connected to this drag.
194
- *
195
- * @deprecated To be removed in v11. This is now handled by the block's
196
- * `moveDuringDrag` method.
197
- */
198
- protected dragIcons_(): void;
199
- /**
200
- * Get a list of the insertion markers that currently exist. Drags have 0, 1,
201
- * or 2 insertion markers.
202
- *
203
- * @returns A possibly empty list of insertion marker blocks.
204
- */
205
- getInsertionMarkers(): BlockSvg[];
206
- }
207
- /** Data about the position of a given icon. */
208
- export interface IconPositionData {
209
- location: Coordinate;
210
- icon: Icon;
211
- }
212
- //# sourceMappingURL=block_dragger.d.ts.map
@@ -1,77 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2018 Google LLC
4
- * SPDX-License-Identifier: Apache-2.0
5
- */
6
- import type { IBubble } from './interfaces/i_bubble.js';
7
- import { Coordinate } from './utils/coordinate.js';
8
- import type { WorkspaceSvg } from './workspace_svg.js';
9
- /**
10
- * Class for a bubble dragger. It moves things on the bubble canvas around the
11
- * workspace when they are being dragged by a mouse or touch. These can be
12
- * block comments, mutators, warnings, or workspace comments.
13
- */
14
- export declare class BubbleDragger {
15
- private bubble;
16
- private workspace;
17
- /** Which drag target the mouse pointer is over, if any. */
18
- private dragTarget_;
19
- /** Whether the bubble would be deleted if dropped immediately. */
20
- private wouldDeleteBubble_;
21
- private readonly startXY_;
22
- /**
23
- * @param bubble The item on the bubble canvas to drag.
24
- * @param workspace The workspace to drag on.
25
- */
26
- constructor(bubble: IBubble, workspace: WorkspaceSvg);
27
- /**
28
- * Start dragging a bubble.
29
- *
30
- * @internal
31
- */
32
- startBubbleDrag(): void;
33
- /**
34
- * Execute a step of bubble dragging, based on the given event. Update the
35
- * display accordingly.
36
- *
37
- * @param e The most recent move event.
38
- * @param currentDragDeltaXY How far the pointer has moved from the position
39
- * at the start of the drag, in pixel units.
40
- * @internal
41
- */
42
- dragBubble(e: PointerEvent, currentDragDeltaXY: Coordinate): void;
43
- /**
44
- * Whether ending the drag would delete the bubble.
45
- *
46
- * @param dragTarget The drag target that the bubblee is currently over.
47
- * @returns Whether dropping the bubble immediately would delete the block.
48
- */
49
- private shouldDelete_;
50
- /**
51
- * Update the cursor (and possibly the trash can lid) to reflect whether the
52
- * dragging bubble would be deleted if released immediately.
53
- */
54
- private updateCursorDuringBubbleDrag_;
55
- /**
56
- * Finish a bubble drag and put the bubble back on the workspace.
57
- *
58
- * @param e The pointerup event.
59
- * @param currentDragDeltaXY How far the pointer has moved from the position
60
- * at the start of the drag, in pixel units.
61
- * @internal
62
- */
63
- endBubbleDrag(e: PointerEvent, currentDragDeltaXY: Coordinate): void;
64
- /** Fire a move event at the end of a bubble drag. */
65
- private fireMoveEvent_;
66
- /**
67
- * Convert a coordinate object from pixels to workspace units, including a
68
- * correction for mutator workspaces.
69
- * This function does not consider differing origins. It simply scales the
70
- * input's x and y values.
71
- *
72
- * @param pixelCoord A coordinate with x and y values in CSS pixel units.
73
- * @returns The input coordinate divided by the workspace scale.
74
- */
75
- private pixelsToWorkspaceUnits_;
76
- }
77
- //# sourceMappingURL=bubble_dragger.d.ts.map
@@ -1,208 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2013 Google LLC
4
- * SPDX-License-Identifier: Apache-2.0
5
- */
6
- import { Field } from './field.js';
7
- import { FieldInput, FieldInputConfig, FieldInputValidator } from './field_input.js';
8
- /**
9
- * Class for an editable angle field.
10
- */
11
- export declare class FieldAngle extends FieldInput<number> {
12
- /** Half the width of protractor image. */
13
- static readonly HALF: number;
14
- /**
15
- * Radius of protractor circle. Slightly smaller than protractor size since
16
- * otherwise SVG crops off half the border at the edges.
17
- */
18
- static readonly RADIUS: number;
19
- /**
20
- * Default property describing which direction makes an angle field's value
21
- * increase. Angle increases clockwise (true) or counterclockwise (false).
22
- */
23
- static readonly CLOCKWISE = false;
24
- /**
25
- * The default offset of 0 degrees (and all angles). Always offsets in the
26
- * counterclockwise direction, regardless of the field's clockwise property.
27
- * Usually either 0 (0 = right) or 90 (0 = up).
28
- */
29
- static readonly OFFSET = 0;
30
- /**
31
- * The default maximum angle to allow before wrapping.
32
- * Usually either 360 (for 0 to 359.9) or 180 (for -179.9 to 180).
33
- */
34
- static readonly WRAP = 360;
35
- /**
36
- * The default amount to round angles to when using a mouse or keyboard nav
37
- * input. Must be a positive integer to support keyboard navigation.
38
- */
39
- static readonly ROUND = 15;
40
- /**
41
- * Whether the angle should increase as the angle picker is moved clockwise
42
- * (true) or counterclockwise (false).
43
- */
44
- private clockwise;
45
- /**
46
- * The offset of zero degrees (and all other angles).
47
- */
48
- private offset;
49
- /**
50
- * The maximum angle to allow before wrapping.
51
- */
52
- private wrap;
53
- /**
54
- * The amount to round angles to when using a mouse or keyboard nav input.
55
- */
56
- private round;
57
- /**
58
- * Array holding info needed to unbind events.
59
- * Used for disposing.
60
- * Ex: [[node, name, func], [node, name, func]].
61
- */
62
- private boundEvents;
63
- /** Dynamic red line pointing at the value's angle. */
64
- private line;
65
- /** Dynamic pink area extending from 0 to the value's angle. */
66
- private gauge;
67
- /** The degree symbol for this field. */
68
- protected symbol_: SVGTSpanElement | null;
69
- /**
70
- * @param value The initial value of the field. Should cast to a number.
71
- * Defaults to 0. Also accepts Field.SKIP_SETUP if you wish to skip setup
72
- * (only used by subclasses that want to handle configuration and setting
73
- * the field value after their own constructors have run).
74
- * @param validator A function that is called to validate changes to the
75
- * field's value. Takes in a number & returns a validated number, or null
76
- * to abort the change.
77
- * @param config A map of options used to configure the field.
78
- * See the [field creation documentation]{@link
79
- * https://developers.google.com/blockly/guides/create-custom-blocks/fields/built-in-fields/angle#creation}
80
- * for a list of properties this parameter supports.
81
- */
82
- constructor(value?: string | number | typeof Field.SKIP_SETUP, validator?: FieldAngleValidator, config?: FieldAngleConfig);
83
- /**
84
- * Configure the field based on the given map of options.
85
- *
86
- * @param config A map of options to configure the field based on.
87
- */
88
- protected configure_(config: FieldAngleConfig): void;
89
- /**
90
- * Create the block UI for this field.
91
- */
92
- initView(): void;
93
- /** Updates the angle when the field rerenders. */
94
- protected render_(): void;
95
- /**
96
- * Create and show the angle field's editor.
97
- *
98
- * @param e Optional mouse event that triggered the field to open,
99
- * or undefined if triggered programmatically.
100
- */
101
- protected showEditor_(e?: Event): void;
102
- /**
103
- * Creates the angle dropdown editor.
104
- *
105
- * @returns The newly created slider.
106
- */
107
- private dropdownCreate;
108
- /** Disposes of events and DOM-references belonging to the angle editor. */
109
- private dropdownDispose;
110
- /** Hide the editor. */
111
- private hide;
112
- /**
113
- * Set the angle to match the mouse's position.
114
- *
115
- * @param e Mouse move event.
116
- */
117
- protected onMouseMove_(e: PointerEvent): void;
118
- /**
119
- * Handles and displays values that are input via mouse or arrow key input.
120
- * These values need to be rounded and wrapped before being displayed so
121
- * that the text input's value is appropriate.
122
- *
123
- * @param angle New angle.
124
- */
125
- private displayMouseOrKeyboardValue;
126
- /** Redraw the graph with the current angle. */
127
- private updateGraph;
128
- /**
129
- * Handle key down to the editor.
130
- *
131
- * @param e Keyboard event.
132
- */
133
- protected onHtmlInputKeyDown_(e: KeyboardEvent): void;
134
- /**
135
- * Ensure that the input value is a valid angle.
136
- *
137
- * @param newValue The input value.
138
- * @returns A valid angle, or null if invalid.
139
- */
140
- protected doClassValidation_(newValue?: any): number | null;
141
- /**
142
- * Wraps the value so that it is in the range (-360 + wrap, wrap).
143
- *
144
- * @param value The value to wrap.
145
- * @returns The wrapped value.
146
- */
147
- private wrapValue;
148
- /**
149
- * Construct a FieldAngle from a JSON arg object.
150
- *
151
- * @param options A JSON object with options (angle).
152
- * @returns The new field instance.
153
- * @nocollapse
154
- * @internal
155
- */
156
- static fromJson(options: FieldAngleFromJsonConfig): FieldAngle;
157
- }
158
- /**
159
- * The two main modes of the angle field.
160
- * Compass specifies:
161
- * - clockwise: true
162
- * - offset: 90
163
- * - wrap: 0
164
- * - round: 15
165
- *
166
- * Protractor specifies:
167
- * - clockwise: false
168
- * - offset: 0
169
- * - wrap: 0
170
- * - round: 15
171
- */
172
- export declare enum Mode {
173
- COMPASS = "compass",
174
- PROTRACTOR = "protractor"
175
- }
176
- /**
177
- * Extra configuration options for the angle field.
178
- */
179
- export interface FieldAngleConfig extends FieldInputConfig {
180
- mode?: Mode;
181
- clockwise?: boolean;
182
- offset?: number;
183
- wrap?: number;
184
- round?: number;
185
- }
186
- /**
187
- * fromJson configuration options for the angle field.
188
- */
189
- export interface FieldAngleFromJsonConfig extends FieldAngleConfig {
190
- angle?: number;
191
- }
192
- /**
193
- * A function that is called to validate changes to the field's value before
194
- * they are set.
195
- *
196
- * @see {@link https://developers.google.com/blockly/guides/create-custom-blocks/fields/validators#return_values}
197
- * @param newValue The value to be validated.
198
- * @returns One of three instructions for setting the new value: `T`, `null`,
199
- * or `undefined`.
200
- *
201
- * - `T` to set this function's returned value instead of `newValue`.
202
- *
203
- * - `null` to invoke `doValueInvalid_` and not set a value.
204
- *
205
- * - `undefined` to set `newValue` as is.
206
- */
207
- export type FieldAngleValidator = FieldInputValidator<number>;
208
- //# sourceMappingURL=field_angle.d.ts.map