blockly 8.0.5 → 9.0.0-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.min.js +2002 -2269
- package/blockly_compressed.js +1499 -1994
- package/blockly_compressed.js.map +1 -1
- package/blocks/blocks.js +3 -2
- package/blocks/colour.js +3 -1
- package/blocks/lists.js +94 -22
- package/blocks/logic.js +14 -6
- package/blocks/loops.js +5 -3
- package/blocks/math.js +3 -1
- package/blocks/procedures.js +3 -1
- package/blocks/text.js +14 -6
- package/blocks/variables.js +3 -1
- package/blocks/variables_dynamic.js +3 -1
- package/blocks.d.ts +0 -2
- package/blocks_compressed.js +189 -171
- package/blocks_compressed.js.map +1 -1
- package/closure/goog/base.d.ts +1 -0
- package/closure/goog/base_minimal.d.ts +18 -0
- package/closure/goog/goog.d.ts +25 -0
- package/core/any_aliases.d.ts +1 -0
- package/core/any_aliases.ts +1 -0
- package/core/block.d.ts +779 -0
- package/core/{block.js → block.ts} +610 -719
- package/core/block_animations.d.ts +33 -0
- package/core/{block_animations.js → block_animations.ts} +75 -79
- package/core/block_drag_surface.d.ts +111 -0
- package/core/{block_drag_surface.js → block_drag_surface.ts} +85 -117
- package/core/block_dragger.d.ts +143 -0
- package/core/{block_dragger.js → block_dragger.ts} +139 -176
- package/core/block_svg.d.ts +588 -0
- package/core/{block_svg.js → block_svg.ts} +494 -630
- package/core/blockly.d.ts +562 -0
- package/core/blockly.js +1 -1
- package/core/blockly.ts +749 -0
- package/core/blockly_options.d.ts +69 -0
- package/core/blockly_options.ts +81 -0
- package/core/blocks.d.ts +17 -0
- package/core/{blocks.js → blocks.ts} +4 -8
- package/core/browser_events.d.ts +85 -0
- package/core/{browser_events.js → browser_events.ts} +98 -93
- package/core/bubble.d.ts +279 -0
- package/core/{bubble.js → bubble.ts} +277 -370
- package/core/bubble_dragger.d.ts +73 -0
- package/core/bubble_dragger.ts +229 -0
- package/core/bump_objects.d.ts +34 -0
- package/core/{bump_objects.js → bump_objects.ts} +54 -52
- package/core/clipboard.d.ts +42 -0
- package/core/clipboard.ts +91 -0
- package/core/comment.d.ts +113 -0
- package/core/{comment.js → comment.ts} +135 -185
- package/core/common.d.ts +129 -0
- package/core/{common.js → common.ts} +105 -82
- package/core/component_manager.d.ts +91 -0
- package/core/component_manager.ts +211 -0
- package/core/config.d.ts +23 -0
- package/core/{config.js → config.ts} +12 -19
- package/core/connection.d.ts +232 -0
- package/core/{connection.js → connection.ts} +187 -237
- package/core/connection_checker.d.ts +78 -0
- package/core/{connection_checker.js → connection_checker.ts} +66 -77
- package/core/connection_db.d.ts +91 -0
- package/core/{connection_db.js → connection_db.ts} +62 -87
- package/core/connection_type.d.ts +15 -0
- package/core/{connection_type.js → connection_type.ts} +8 -12
- package/core/constants.d.ts +15 -0
- package/core/{constants.js → constants.ts} +4 -8
- package/core/contextmenu.d.ts +80 -0
- package/core/{contextmenu.js → contextmenu.ts} +118 -153
- package/core/contextmenu_items.d.ts +77 -0
- package/core/contextmenu_items.ts +576 -0
- package/core/contextmenu_registry.d.ts +105 -0
- package/core/contextmenu_registry.ts +179 -0
- package/core/css.d.ts +24 -0
- package/core/{css.js → css.ts} +16 -24
- package/core/delete_area.d.ts +47 -0
- package/core/delete_area.ts +82 -0
- package/core/dialog.d.ts +61 -0
- package/core/dialog.ts +127 -0
- package/core/drag_target.d.ts +63 -0
- package/core/drag_target.ts +94 -0
- package/core/dropdowndiv.d.ts +155 -0
- package/core/{dropdowndiv.js → dropdowndiv.ts} +262 -333
- package/core/events/events.d.ts +102 -0
- package/core/events/events.ts +123 -0
- package/core/events/events_abstract.d.ts +51 -0
- package/core/events/events_abstract.ts +112 -0
- package/core/events/events_block_base.d.ts +31 -0
- package/core/events/events_block_base.ts +65 -0
- package/core/events/events_block_change.d.ts +55 -0
- package/core/events/{events_block_change.js → events_block_change.ts} +45 -48
- package/core/events/events_block_create.d.ts +35 -0
- package/core/events/{events_block_create.js → events_block_create.ts} +30 -35
- package/core/events/events_block_delete.d.ts +36 -0
- package/core/events/{events_block_delete.js → events_block_delete.ts} +34 -39
- package/core/events/events_block_drag.d.ts +36 -0
- package/core/events/events_block_drag.ts +82 -0
- package/core/events/events_block_move.d.ts +51 -0
- package/core/events/{events_block_move.js → events_block_move.ts} +54 -50
- package/core/events/events_bubble_open.d.ts +35 -0
- package/core/events/events_bubble_open.ts +82 -0
- package/core/events/events_click.d.ts +36 -0
- package/core/events/{events_click.js → events_click.ts} +27 -30
- package/core/events/events_comment_base.d.ts +39 -0
- package/core/events/events_comment_base.ts +107 -0
- package/core/events/events_comment_change.d.ts +43 -0
- package/core/events/{events_comment_change.js → events_comment_change.ts} +31 -28
- package/core/events/events_comment_create.d.ts +35 -0
- package/core/events/{events_comment_create.js → events_comment_create.ts} +24 -26
- package/core/events/events_comment_delete.d.ts +35 -0
- package/core/events/{events_comment_delete.js → events_comment_delete.ts} +20 -24
- package/core/events/events_comment_move.d.ts +55 -0
- package/core/events/{events_comment_move.js → events_comment_move.ts} +39 -42
- package/core/events/events_marker_move.d.ts +40 -0
- package/core/events/events_marker_move.ts +99 -0
- package/core/events/events_selected.d.ts +34 -0
- package/core/events/events_selected.ts +78 -0
- package/core/events/events_theme_change.d.ts +30 -0
- package/core/events/{events_theme_change.js → events_theme_change.ts} +19 -24
- package/core/events/events_toolbox_item_select.d.ts +34 -0
- package/core/events/events_toolbox_item_select.ts +79 -0
- package/core/events/events_trashcan_open.d.ts +31 -0
- package/core/events/events_trashcan_open.ts +68 -0
- package/core/events/events_ui.d.ts +37 -0
- package/core/events/{events_ui.js → events_ui.ts} +27 -26
- package/core/events/events_ui_base.d.ts +26 -0
- package/core/events/{events_ui_base.js → events_ui_base.ts} +17 -26
- package/core/events/events_var_base.d.ts +31 -0
- package/core/events/events_var_base.ts +65 -0
- package/core/events/events_var_create.d.ts +35 -0
- package/core/events/{events_var_create.js → events_var_create.ts} +24 -25
- package/core/events/events_var_delete.d.ts +35 -0
- package/core/events/{events_var_delete.js → events_var_delete.ts} +24 -25
- package/core/events/events_var_rename.d.ts +36 -0
- package/core/events/{events_var_rename.js → events_var_rename.ts} +25 -26
- package/core/events/events_viewport.d.ts +39 -0
- package/core/events/events_viewport.ts +100 -0
- package/core/events/utils.d.ts +272 -0
- package/core/events/{utils.js → utils.ts} +148 -219
- package/core/events/workspace_events.d.ts +36 -0
- package/core/events/workspace_events.ts +86 -0
- package/core/extensions.d.ts +107 -0
- package/core/{extensions.js → extensions.ts} +153 -172
- package/core/field.d.ts +534 -0
- package/core/{field.js → field.ts} +413 -489
- package/core/field_angle.d.ts +176 -0
- package/core/field_angle.ts +563 -0
- package/core/field_checkbox.d.ts +124 -0
- package/core/field_checkbox.ts +243 -0
- package/core/field_colour.d.ts +200 -0
- package/core/field_colour.ts +632 -0
- package/core/field_dropdown.d.ts +222 -0
- package/core/{field_dropdown.js → field_dropdown.ts} +277 -299
- package/core/field_image.d.ts +134 -0
- package/core/field_image.ts +282 -0
- package/core/field_label.d.ts +71 -0
- package/core/field_label.ts +152 -0
- package/core/field_label_serializable.d.ts +42 -0
- package/core/field_label_serializable.ts +76 -0
- package/core/field_multilineinput.d.ts +146 -0
- package/core/{field_multilineinput.js → field_multilineinput.ts} +166 -163
- package/core/field_number.d.ts +156 -0
- package/core/{field_number.js → field_number.ts} +110 -123
- package/core/field_registry.d.ts +45 -0
- package/core/{field_registry.js → field_registry.ts} +37 -30
- package/core/field_textinput.d.ts +219 -0
- package/core/field_textinput.ts +591 -0
- package/core/field_variable.d.ts +217 -0
- package/core/{field_variable.js → field_variable.ts} +174 -187
- package/core/flyout_base.d.ts +459 -0
- package/core/{flyout_base.js → flyout_base.ts} +429 -518
- package/core/flyout_button.d.ts +81 -0
- package/core/flyout_button.ts +292 -0
- package/core/flyout_horizontal.d.ts +82 -0
- package/core/{flyout_horizontal.js → flyout_horizontal.ts} +97 -107
- package/core/flyout_metrics_manager.d.ts +40 -0
- package/core/{flyout_metrics_manager.js → flyout_metrics_manager.ts} +22 -34
- package/core/flyout_vertical.d.ts +83 -0
- package/core/{flyout_vertical.js → flyout_vertical.ts} +106 -117
- package/core/generator.d.ts +205 -0
- package/core/{generator.js → generator.ts} +168 -193
- package/core/gesture.d.ts +357 -0
- package/core/{gesture.js → gesture.ts} +289 -369
- package/core/grid.d.ts +83 -0
- package/core/grid.ts +192 -0
- package/core/icon.d.ts +78 -0
- package/core/icon.ts +189 -0
- package/core/inject.d.ts +15 -0
- package/core/{inject.js → inject.ts} +101 -100
- package/core/input.d.ts +128 -0
- package/core/input.ts +309 -0
- package/core/input_types.d.ts +14 -0
- package/core/{input_types.js → input_types.ts} +8 -12
- package/core/insertion_marker_manager.d.ts +212 -0
- package/core/{insertion_marker_manager.js → insertion_marker_manager.ts} +234 -236
- package/core/interfaces/i_ast_node_location.d.ts +11 -0
- package/core/interfaces/{i_ast_node_location.js → i_ast_node_location.ts} +4 -7
- package/core/interfaces/i_ast_node_location_svg.d.ts +22 -0
- package/core/interfaces/i_ast_node_location_svg.ts +37 -0
- package/core/interfaces/i_ast_node_location_with_block.d.ts +18 -0
- package/core/interfaces/i_ast_node_location_with_block.ts +38 -0
- package/core/interfaces/i_autohideable.d.ts +18 -0
- package/core/interfaces/i_autohideable.ts +34 -0
- package/core/interfaces/i_block_dragger.d.ts +43 -0
- package/core/interfaces/i_block_dragger.ts +67 -0
- package/core/interfaces/i_bounded_element.d.ts +24 -0
- package/core/interfaces/i_bounded_element.ts +42 -0
- package/core/interfaces/i_bubble.d.ts +59 -0
- package/core/interfaces/i_bubble.ts +88 -0
- package/core/interfaces/i_collapsible_toolbox_item.d.ts +26 -0
- package/core/interfaces/i_collapsible_toolbox_item.ts +47 -0
- package/core/interfaces/i_component.d.ts +17 -0
- package/core/interfaces/{i_component.js → i_component.ts} +9 -14
- package/core/interfaces/i_connection_checker.d.ts +69 -0
- package/core/interfaces/i_connection_checker.ts +102 -0
- package/core/interfaces/i_contextmenu.d.ts +13 -0
- package/core/interfaces/i_contextmenu.ts +26 -0
- package/core/interfaces/i_copyable.d.ts +24 -0
- package/core/interfaces/i_copyable.ts +40 -0
- package/core/interfaces/i_deletable.d.ts +16 -0
- package/core/interfaces/{i_deletable.js → i_deletable.ts} +9 -13
- package/core/interfaces/i_delete_area.d.ts +25 -0
- package/core/interfaces/i_delete_area.ts +46 -0
- package/core/interfaces/i_drag_target.d.ts +53 -0
- package/core/interfaces/i_drag_target.ts +84 -0
- package/core/interfaces/i_draggable.d.ts +12 -0
- package/core/interfaces/{i_draggable.js → i_draggable.ts} +4 -10
- package/core/interfaces/i_flyout.d.ts +134 -0
- package/core/interfaces/i_flyout.ts +186 -0
- package/core/interfaces/i_keyboard_accessible.d.ts +18 -0
- package/core/interfaces/i_keyboard_accessible.ts +35 -0
- package/core/interfaces/i_metrics_manager.d.ts +117 -0
- package/core/interfaces/i_metrics_manager.ts +151 -0
- package/core/interfaces/i_movable.d.ts +16 -0
- package/core/interfaces/{i_movable.js → i_movable.ts} +9 -13
- package/core/interfaces/i_positionable.d.ts +27 -0
- package/core/interfaces/i_positionable.ts +50 -0
- package/core/interfaces/i_registrable.d.ts +11 -0
- package/core/interfaces/{i_registrable.js → i_registrable.ts} +3 -7
- package/core/interfaces/i_registrable_field.d.ts +17 -0
- package/core/interfaces/{i_registrable_field.js → i_registrable_field.ts} +8 -16
- package/core/interfaces/i_selectable.d.ts +18 -0
- package/core/interfaces/i_selectable.ts +34 -0
- package/core/interfaces/i_selectable_toolbox_item.d.ts +42 -0
- package/core/interfaces/i_selectable_toolbox_item.ts +64 -0
- package/core/interfaces/i_serializer.d.ts +42 -0
- package/core/interfaces/i_serializer.ts +65 -0
- package/core/interfaces/i_styleable.d.ts +21 -0
- package/core/interfaces/i_styleable.ts +35 -0
- package/core/interfaces/i_toolbox.d.ts +85 -0
- package/core/interfaces/i_toolbox.ts +127 -0
- package/core/interfaces/i_toolbox_item.d.ts +62 -0
- package/core/interfaces/i_toolbox_item.ts +84 -0
- package/core/internal_constants.d.ts +40 -0
- package/core/{internal_constants.js → internal_constants.ts} +13 -18
- package/core/keyboard_nav/ast_node.d.ts +239 -0
- package/core/keyboard_nav/{ast_node.js → ast_node.ts} +207 -231
- package/core/keyboard_nav/basic_cursor.d.ts +88 -0
- package/core/keyboard_nav/{basic_cursor.js → basic_cursor.ts} +55 -66
- package/core/keyboard_nav/cursor.d.ts +41 -0
- package/core/keyboard_nav/{cursor.js → cursor.ts} +25 -35
- package/core/keyboard_nav/marker.d.ts +58 -0
- package/core/keyboard_nav/{marker.js → marker.ts} +36 -55
- package/core/keyboard_nav/tab_navigate_cursor.d.ts +19 -0
- package/core/keyboard_nav/{tab_navigate_cursor.js → tab_navigate_cursor.ts} +11 -15
- package/core/main.d.ts +11 -0
- package/core/main.js +303 -0
- package/core/marker_manager.d.ts +85 -0
- package/core/marker_manager.ts +181 -0
- package/core/menu.d.ts +149 -0
- package/core/{menu.js → menu.ts} +141 -174
- package/core/menuitem.d.ts +118 -0
- package/core/menuitem.ts +240 -0
- package/core/metrics_manager.d.ts +201 -0
- package/core/{metrics_manager.js → metrics_manager.ts} +117 -156
- package/core/msg.d.ts +9 -0
- package/core/{msg.js → msg.ts} +4 -8
- package/core/mutator.d.ts +128 -0
- package/core/{mutator.js → mutator.ts} +196 -211
- package/core/names.d.ts +124 -0
- package/core/names.ts +267 -0
- package/core/options.d.ts +137 -0
- package/core/{options.js → options.ts} +147 -173
- package/core/positionable_helpers.d.ts +88 -0
- package/core/{positionable_helpers.js → positionable_helpers.ts} +63 -70
- package/core/procedures.d.ts +108 -0
- package/core/{procedures.js → procedures.ts} +143 -152
- package/core/registry.d.ts +137 -0
- package/core/registry.ts +339 -0
- package/core/rendered_connection.d.ts +191 -0
- package/core/{rendered_connection.js → rendered_connection.ts} +164 -184
- package/core/renderers/common/block_rendering.d.ts +114 -0
- package/core/renderers/common/block_rendering.ts +164 -0
- package/core/renderers/common/constants.d.ts +458 -0
- package/core/renderers/common/constants.ts +1124 -0
- package/core/renderers/common/debug.d.ts +28 -0
- package/core/renderers/common/{debug.js → debug.ts} +14 -20
- package/core/renderers/common/debugger.d.ts +120 -0
- package/core/renderers/common/{debugger.js → debugger.ts} +100 -124
- package/core/renderers/common/drawer.d.ts +132 -0
- package/core/renderers/common/{drawer.js → drawer.ts} +112 -137
- package/core/renderers/common/i_path_object.d.ts +117 -0
- package/core/renderers/common/i_path_object.ts +161 -0
- package/core/renderers/common/info.d.ts +194 -0
- package/core/renderers/common/{info.js → info.ts} +165 -222
- package/core/renderers/common/marker_svg.d.ts +220 -0
- package/core/renderers/common/marker_svg.ts +680 -0
- package/core/renderers/common/path_object.d.ts +146 -0
- package/core/renderers/common/path_object.ts +272 -0
- package/core/renderers/common/renderer.d.ts +157 -0
- package/core/renderers/common/renderer.ts +271 -0
- package/core/renderers/geras/constants.d.ts +23 -0
- package/core/renderers/geras/constants.ts +61 -0
- package/core/renderers/geras/drawer.d.ts +43 -0
- package/core/renderers/geras/{drawer.js → drawer.ts} +40 -84
- package/core/renderers/geras/geras.d.ts +11 -0
- package/core/renderers/geras/geras.ts +37 -0
- package/core/renderers/geras/highlight_constants.d.ts +108 -0
- package/core/renderers/geras/{highlight_constants.js → highlight_constants.ts} +107 -69
- package/core/renderers/geras/highlighter.d.ts +98 -0
- package/core/renderers/geras/{highlighter.js → highlighter.ts} +81 -86
- package/core/renderers/geras/info.d.ts +45 -0
- package/core/renderers/geras/{info.js → info.ts} +61 -99
- package/core/renderers/geras/measurables/inline_input.d.ts +23 -0
- package/core/renderers/geras/measurables/inline_input.ts +51 -0
- package/core/renderers/geras/measurables/statement_input.d.ts +23 -0
- package/core/renderers/geras/measurables/statement_input.ts +50 -0
- package/core/renderers/geras/path_object.d.ts +47 -0
- package/core/renderers/geras/{path_object.js → path_object.ts} +46 -74
- package/core/renderers/geras/renderer.d.ts +69 -0
- package/core/renderers/geras/renderer.ts +126 -0
- package/core/renderers/measurables/base.d.ts +27 -0
- package/core/renderers/measurables/base.ts +53 -0
- package/core/renderers/measurables/bottom_row.d.ts +61 -0
- package/core/renderers/measurables/bottom_row.ts +120 -0
- package/core/renderers/measurables/connection.d.ts +25 -0
- package/core/renderers/measurables/connection.ts +52 -0
- package/core/renderers/measurables/external_value_input.d.ts +27 -0
- package/core/renderers/measurables/external_value_input.ts +65 -0
- package/core/renderers/measurables/field.d.ts +30 -0
- package/core/renderers/measurables/field.ts +63 -0
- package/core/renderers/measurables/hat.d.ts +21 -0
- package/core/renderers/measurables/{hat.js → hat.ts} +12 -14
- package/core/renderers/measurables/icon.d.ts +26 -0
- package/core/renderers/measurables/{icon.js → icon.ts} +14 -18
- package/core/renderers/measurables/in_row_spacer.d.ts +21 -0
- package/core/renderers/measurables/in_row_spacer.ts +44 -0
- package/core/renderers/measurables/inline_input.d.ts +24 -0
- package/core/renderers/measurables/{inline_input.js → inline_input.ts} +22 -26
- package/core/renderers/measurables/input_connection.d.ts +29 -0
- package/core/renderers/measurables/input_connection.ts +66 -0
- package/core/renderers/measurables/input_row.d.ts +30 -0
- package/core/renderers/measurables/{input_row.js → input_row.ts} +24 -31
- package/core/renderers/measurables/jagged_edge.d.ts +20 -0
- package/core/renderers/measurables/{jagged_edge.js → jagged_edge.ts} +10 -13
- package/core/renderers/measurables/next_connection.d.ts +23 -0
- package/core/renderers/measurables/next_connection.ts +47 -0
- package/core/renderers/measurables/output_connection.d.ts +26 -0
- package/core/renderers/measurables/output_connection.ts +56 -0
- package/core/renderers/measurables/previous_connection.d.ts +23 -0
- package/core/renderers/measurables/previous_connection.ts +47 -0
- package/core/renderers/measurables/round_corner.d.ts +21 -0
- package/core/renderers/measurables/round_corner.ts +49 -0
- package/core/renderers/measurables/row.d.ts +141 -0
- package/core/renderers/measurables/row.ts +225 -0
- package/core/renderers/measurables/spacer_row.d.ts +29 -0
- package/core/renderers/measurables/spacer_row.ts +55 -0
- package/core/renderers/measurables/square_corner.d.ts +21 -0
- package/core/renderers/measurables/square_corner.ts +47 -0
- package/core/renderers/measurables/statement_input.d.ts +22 -0
- package/core/renderers/measurables/{statement_input.js → statement_input.ts} +14 -18
- package/core/renderers/measurables/top_row.d.ts +56 -0
- package/core/renderers/measurables/top_row.ts +122 -0
- package/core/renderers/measurables/types.d.ts +235 -0
- package/core/renderers/measurables/types.ts +332 -0
- package/core/renderers/minimalist/constants.d.ts +14 -0
- package/core/renderers/minimalist/{constants.js → constants.ts} +5 -10
- package/core/renderers/minimalist/drawer.d.ts +21 -0
- package/core/renderers/minimalist/drawer.ts +38 -0
- package/core/renderers/minimalist/info.d.ts +30 -0
- package/core/renderers/minimalist/info.ts +52 -0
- package/core/renderers/minimalist/minimalist.d.ts +6 -0
- package/core/renderers/minimalist/minimalist.ts +22 -0
- package/core/renderers/minimalist/renderer.d.ts +41 -0
- package/core/renderers/minimalist/renderer.ts +71 -0
- package/core/renderers/thrasos/info.d.ts +40 -0
- package/core/renderers/thrasos/{info.js → info.ts} +66 -67
- package/core/renderers/thrasos/renderer.d.ts +25 -0
- package/core/renderers/thrasos/renderer.ts +48 -0
- package/core/renderers/thrasos/thrasos.d.ts +4 -0
- package/core/renderers/thrasos/thrasos.ts +20 -0
- package/core/renderers/zelos/constants.d.ts +186 -0
- package/core/renderers/zelos/{constants.js → constants.ts} +294 -441
- package/core/renderers/zelos/drawer.d.ts +47 -0
- package/core/renderers/zelos/{drawer.js → drawer.ts} +73 -95
- package/core/renderers/zelos/info.d.ts +88 -0
- package/core/renderers/zelos/{info.js → info.ts} +111 -142
- package/core/renderers/zelos/marker_svg.d.ts +46 -0
- package/core/renderers/zelos/marker_svg.ts +151 -0
- package/core/renderers/zelos/measurables/bottom_row.d.ts +27 -0
- package/core/renderers/zelos/measurables/bottom_row.ts +53 -0
- package/core/renderers/zelos/measurables/inputs.d.ts +23 -0
- package/core/renderers/zelos/measurables/{inputs.js → inputs.ts} +14 -15
- package/core/renderers/zelos/measurables/row_elements.d.ts +21 -0
- package/core/renderers/zelos/measurables/row_elements.ts +45 -0
- package/core/renderers/zelos/measurables/top_row.d.ts +29 -0
- package/core/renderers/zelos/measurables/{top_row.js → top_row.ts} +14 -27
- package/core/renderers/zelos/path_object.d.ts +77 -0
- package/core/renderers/zelos/path_object.ts +215 -0
- package/core/renderers/zelos/renderer.d.ts +74 -0
- package/core/renderers/zelos/renderer.ts +142 -0
- package/core/renderers/zelos/zelos.d.ts +12 -0
- package/core/renderers/zelos/zelos.ts +39 -0
- package/core/scrollbar.d.ts +277 -0
- package/core/{scrollbar.js → scrollbar.ts} +307 -328
- package/core/scrollbar_pair.d.ts +105 -0
- package/core/{scrollbar_pair.js → scrollbar_pair.ts} +71 -79
- package/core/serialization/blocks.d.ts +98 -0
- package/core/serialization/{blocks.js → blocks.ts} +229 -228
- package/core/serialization/exceptions.d.ts +73 -0
- package/core/serialization/exceptions.ts +98 -0
- package/core/serialization/priorities.d.ts +15 -0
- package/core/serialization/{priorities.js → priorities.ts} +4 -10
- package/core/serialization/registry.d.ts +20 -0
- package/core/serialization/{registry.js → registry.ts} +11 -13
- package/core/serialization/variables.d.ts +14 -0
- package/core/serialization/{variables.js → variables.ts} +30 -32
- package/core/serialization/workspaces.d.ts +28 -0
- package/core/serialization/{workspaces.js → workspaces.ts} +30 -27
- package/core/shortcut_items.d.ts +61 -0
- package/core/{shortcut_items.js → shortcut_items.ts} +121 -157
- package/core/shortcut_registry.d.ts +151 -0
- package/core/shortcut_registry.ts +355 -0
- package/core/sprites.d.ts +19 -0
- package/core/{sprites.js → sprites.ts} +4 -6
- package/core/theme/classic.d.ts +12 -0
- package/core/theme/{classic.js → classic.ts} +5 -7
- package/core/theme/themes.d.ts +8 -0
- package/core/theme/themes.ts +22 -0
- package/core/theme/zelos.d.ts +11 -0
- package/core/theme/{zelos.js → zelos.ts} +4 -7
- package/core/theme.d.ts +142 -0
- package/core/theme.ts +221 -0
- package/core/theme_manager.d.ts +81 -0
- package/core/theme_manager.ts +186 -0
- package/core/toolbox/category.d.ts +239 -0
- package/core/toolbox/category.ts +679 -0
- package/core/toolbox/collapsible_category.d.ts +91 -0
- package/core/toolbox/collapsible_category.ts +273 -0
- package/core/toolbox/separator.d.ts +39 -0
- package/core/toolbox/separator.ts +105 -0
- package/core/toolbox/toolbox.d.ts +352 -0
- package/core/toolbox/{toolbox.js → toolbox.ts} +316 -432
- package/core/toolbox/toolbox_item.d.ts +85 -0
- package/core/toolbox/toolbox_item.ts +147 -0
- package/core/tooltip.d.ts +126 -0
- package/core/{tooltip.js → tooltip.ts} +136 -214
- package/core/touch.d.ts +121 -0
- package/core/touch.ts +306 -0
- package/core/touch_gesture.d.ts +115 -0
- package/core/{touch_gesture.js → touch_gesture.ts} +87 -125
- package/core/trashcan.d.ts +195 -0
- package/core/{trashcan.js → trashcan.ts} +226 -312
- package/core/utils/aria.d.ts +67 -0
- package/core/utils/{aria.js → aria.ts} +47 -61
- package/core/utils/array.d.ts +14 -0
- package/core/utils/{array.js → array.ts} +10 -12
- package/core/utils/colour.d.ts +103 -0
- package/core/utils/{colour.js → colour.ts} +60 -72
- package/core/utils/coordinate.d.ts +72 -0
- package/core/utils/coordinate.ts +124 -0
- package/core/utils/deprecation.d.ts +17 -0
- package/core/utils/{deprecation.js → deprecation.ts} +11 -11
- package/core/utils/dom.d.ts +165 -0
- package/core/utils/{dom.js → dom.ts} +125 -147
- package/core/utils/idgenerator.d.ts +25 -0
- package/core/utils/{idgenerator.js → idgenerator.ts} +15 -18
- package/core/utils/keycodes.d.ts +137 -0
- package/core/utils/keycodes.ts +169 -0
- package/core/utils/math.d.ts +30 -0
- package/core/utils/{math.js → math.ts} +17 -19
- package/core/utils/metrics.d.ts +64 -0
- package/core/utils/metrics.ts +97 -0
- package/core/utils/object.d.ts +35 -0
- package/core/utils/{object.js → object.ts} +30 -26
- package/core/utils/parsing.d.ts +50 -0
- package/core/utils/{parsing.js → parsing.ts} +50 -50
- package/core/utils/rect.d.ts +38 -0
- package/core/utils/{rect.js → rect.ts} +18 -31
- package/core/utils/sentinel.d.ts +11 -0
- package/core/utils/{sentinel.js → sentinel.ts} +3 -5
- package/core/utils/size.d.ts +27 -0
- package/core/utils/{size.js → size.ts} +12 -26
- package/core/utils/string.d.ts +55 -0
- package/core/utils/{string.js → string.ts} +64 -61
- package/core/utils/style.d.ts +127 -0
- package/core/utils/{style.js → style.ts} +102 -92
- package/core/utils/svg.d.ts +68 -0
- package/core/utils/svg.ts +88 -0
- package/core/utils/svg_math.d.ts +70 -0
- package/core/utils/{svg_math.js → svg_math.ts} +72 -71
- package/core/utils/svg_paths.d.ts +101 -0
- package/core/utils/{svg_paths.js → svg_paths.ts} +56 -65
- package/core/utils/toolbox.d.ts +193 -0
- package/core/utils/toolbox.ts +433 -0
- package/core/utils/useragent.d.ts +33 -0
- package/core/utils/useragent.ts +135 -0
- package/core/utils/xml.d.ts +52 -0
- package/core/utils/{xml.js → xml.ts} +26 -36
- package/core/utils.d.ts +217 -0
- package/core/utils.ts +428 -0
- package/core/variable_map.d.ts +141 -0
- package/core/{variable_map.js → variable_map.ts} +131 -149
- package/core/variable_model.d.ts +40 -0
- package/core/variable_model.ts +82 -0
- package/core/variables.d.ts +181 -0
- package/core/{variables.js → variables.ts} +206 -188
- package/core/variables_dynamic.d.ts +38 -0
- package/core/{variables_dynamic.js → variables_dynamic.ts} +47 -43
- package/core/warning.d.ts +50 -0
- package/core/{warning.js → warning.ts} +52 -66
- package/core/widgetdiv.d.ts +69 -0
- package/core/widgetdiv.ts +257 -0
- package/core/workspace.d.ts +386 -0
- package/core/workspace.ts +801 -0
- package/core/workspace_audio.d.ts +47 -0
- package/core/{workspace_audio.js → workspace_audio.ts} +47 -60
- package/core/workspace_comment.d.ts +170 -0
- package/core/workspace_comment.ts +398 -0
- package/core/workspace_comment_svg.d.ts +329 -0
- package/core/{workspace_comment_svg.js → workspace_comment_svg.ts} +347 -444
- package/core/workspace_drag_surface_svg.d.ts +68 -0
- package/core/{workspace_drag_surface_svg.js → workspace_drag_surface_svg.ts} +75 -82
- package/core/workspace_dragger.d.ts +48 -0
- package/core/workspace_dragger.ts +104 -0
- package/core/workspace_svg.d.ts +920 -0
- package/core/{workspace_svg.js → workspace_svg.ts} +855 -935
- package/core/xml.d.ts +117 -0
- package/core/{xml.js → xml.ts} +306 -326
- package/core/zoom_controls.d.ts +130 -0
- package/core/{zoom_controls.js → zoom_controls.ts} +185 -251
- package/core.d.ts +1 -3
- package/core.js +1 -2
- package/dart.d.ts +0 -3
- package/dart_compressed.js +387 -99
- package/dart_compressed.js.map +1 -1
- package/generators/dart/all.js +2 -0
- package/generators/dart/colour.js +1 -1
- package/generators/dart/lists.js +1 -1
- package/generators/dart/logic.js +1 -1
- package/generators/dart/loops.js +1 -1
- package/generators/dart/math.js +1 -1
- package/generators/dart/procedures.js +1 -1
- package/generators/dart/text.js +1 -1
- package/generators/dart/variables.js +1 -1
- package/generators/dart/variables_dynamic.js +1 -1
- package/generators/dart.js +1 -2
- package/generators/javascript/all.js +2 -0
- package/generators/javascript/colour.js +1 -1
- package/generators/javascript/lists.js +1 -1
- package/generators/javascript/logic.js +1 -1
- package/generators/javascript/loops.js +1 -1
- package/generators/javascript/math.js +4 -4
- package/generators/javascript/procedures.js +1 -1
- package/generators/javascript/text.js +2 -2
- package/generators/javascript/variables.js +1 -1
- package/generators/javascript/variables_dynamic.js +1 -1
- package/generators/javascript.js +1 -3
- package/generators/lua/all.js +2 -0
- package/generators/lua/colour.js +1 -1
- package/generators/lua/lists.js +1 -1
- package/generators/lua/logic.js +1 -1
- package/generators/lua/loops.js +1 -1
- package/generators/lua/math.js +1 -1
- package/generators/lua/procedures.js +1 -1
- package/generators/lua/text.js +1 -1
- package/generators/lua/variables.js +1 -1
- package/generators/lua/variables_dynamic.js +1 -1
- package/generators/lua.js +1 -2
- package/generators/php/all.js +2 -0
- package/generators/php/colour.js +1 -1
- package/generators/php/lists.js +1 -2
- package/generators/php/logic.js +1 -1
- package/generators/php/loops.js +1 -1
- package/generators/php/math.js +1 -1
- package/generators/php/procedures.js +1 -1
- package/generators/php/text.js +1 -1
- package/generators/php/variables.js +1 -1
- package/generators/php/variables_dynamic.js +1 -1
- package/generators/php.js +1 -2
- package/generators/python/all.js +2 -0
- package/generators/python/colour.js +3 -3
- package/generators/python/lists.js +1 -1
- package/generators/python/logic.js +1 -1
- package/generators/python/loops.js +4 -7
- package/generators/python/math.js +1 -1
- package/generators/python/procedures.js +1 -1
- package/generators/python/text.js +1 -1
- package/generators/python/variables.js +1 -1
- package/generators/python/variables_dynamic.js +1 -1
- package/generators/python.js +1 -2
- package/index.d.ts +2 -8
- package/javascript.d.ts +0 -3
- package/javascript_compressed.js +314 -104
- package/javascript_compressed.js.map +1 -1
- package/lua.d.ts +0 -3
- package/lua_compressed.js +399 -81
- package/lua_compressed.js.map +1 -1
- package/package.json +5 -5
- package/php.d.ts +0 -3
- package/php_compressed.js +322 -93
- package/php_compressed.js.map +1 -1
- package/python.d.ts +0 -3
- package/python_compressed.js +237 -90
- package/python_compressed.js.map +1 -1
- package/blockly.d.ts +0 -26127
- package/core/blockly_options.js +0 -28
- package/core/bubble_dragger.js +0 -298
- package/core/clipboard.js +0 -80
- package/core/component_manager.js +0 -263
- package/core/contextmenu_items.js +0 -651
- package/core/contextmenu_registry.js +0 -178
- package/core/delete_area.js +0 -87
- package/core/dialog.js +0 -107
- package/core/drag_target.js +0 -98
- package/core/events/events.js +0 -147
- package/core/events/events_abstract.js +0 -133
- package/core/events/events_block_base.js +0 -70
- package/core/events/events_block_drag.js +0 -89
- package/core/events/events_bubble_open.js +0 -90
- package/core/events/events_comment_base.js +0 -121
- package/core/events/events_marker_move.js +0 -110
- package/core/events/events_selected.js +0 -83
- package/core/events/events_toolbox_item_select.js +0 -84
- package/core/events/events_trashcan_open.js +0 -73
- package/core/events/events_var_base.js +0 -70
- package/core/events/events_viewport.js +0 -107
- package/core/events/workspace_events.js +0 -93
- package/core/field_angle.js +0 -591
- package/core/field_checkbox.js +0 -255
- package/core/field_colour.js +0 -717
- package/core/field_image.js +0 -304
- package/core/field_label.js +0 -149
- package/core/field_label_serializable.js +0 -80
- package/core/field_textinput.js +0 -619
- package/core/flyout_button.js +0 -356
- package/core/grid.js +0 -226
- package/core/icon.js +0 -225
- package/core/input.js +0 -335
- package/core/interfaces/i_ast_node_location_svg.js +0 -45
- package/core/interfaces/i_ast_node_location_with_block.js +0 -41
- package/core/interfaces/i_autohideable.js +0 -40
- package/core/interfaces/i_block_dragger.js +0 -66
- package/core/interfaces/i_bounded_element.js +0 -45
- package/core/interfaces/i_bubble.js +0 -95
- package/core/interfaces/i_collapsible_toolbox_item.js +0 -53
- package/core/interfaces/i_connection_checker.js +0 -104
- package/core/interfaces/i_contextmenu.js +0 -32
- package/core/interfaces/i_copyable.js +0 -49
- package/core/interfaces/i_delete_area.js +0 -50
- package/core/interfaces/i_drag_target.js +0 -88
- package/core/interfaces/i_flyout.js +0 -201
- package/core/interfaces/i_keyboard_accessible.js +0 -38
- package/core/interfaces/i_metrics_manager.js +0 -154
- package/core/interfaces/i_positionable.js +0 -51
- package/core/interfaces/i_selectable.js +0 -51
- package/core/interfaces/i_selectable_toolbox_item.js +0 -73
- package/core/interfaces/i_serializer.js +0 -77
- package/core/interfaces/i_styleable.js +0 -39
- package/core/interfaces/i_toolbox.js +0 -142
- package/core/interfaces/i_toolbox_item.js +0 -85
- package/core/marker_manager.js +0 -213
- package/core/menuitem.js +0 -292
- package/core/names.js +0 -293
- package/core/registry.js +0 -384
- package/core/renderers/common/block_rendering.js +0 -170
- package/core/renderers/common/constants.js +0 -1250
- package/core/renderers/common/i_path_object.js +0 -162
- package/core/renderers/common/marker_svg.js +0 -721
- package/core/renderers/common/path_object.js +0 -283
- package/core/renderers/common/renderer.js +0 -305
- package/core/renderers/geras/constants.js +0 -73
- package/core/renderers/geras/geras.js +0 -36
- package/core/renderers/geras/measurables/inline_input.js +0 -58
- package/core/renderers/geras/measurables/statement_input.js +0 -57
- package/core/renderers/geras/renderer.js +0 -149
- package/core/renderers/measurables/base.js +0 -64
- package/core/renderers/measurables/bottom_row.js +0 -138
- package/core/renderers/measurables/connection.js +0 -56
- package/core/renderers/measurables/external_value_input.js +0 -70
- package/core/renderers/measurables/field.js +0 -71
- package/core/renderers/measurables/in_row_spacer.js +0 -47
- package/core/renderers/measurables/input_connection.js +0 -75
- package/core/renderers/measurables/next_connection.js +0 -50
- package/core/renderers/measurables/output_connection.js +0 -61
- package/core/renderers/measurables/previous_connection.js +0 -50
- package/core/renderers/measurables/round_corner.js +0 -52
- package/core/renderers/measurables/row.js +0 -247
- package/core/renderers/measurables/spacer_row.js +0 -69
- package/core/renderers/measurables/square_corner.js +0 -50
- package/core/renderers/measurables/top_row.js +0 -143
- package/core/renderers/measurables/types.js +0 -353
- package/core/renderers/minimalist/drawer.js +0 -42
- package/core/renderers/minimalist/info.js +0 -54
- package/core/renderers/minimalist/minimalist.js +0 -26
- package/core/renderers/minimalist/renderer.js +0 -80
- package/core/renderers/thrasos/renderer.js +0 -53
- package/core/renderers/thrasos/thrasos.js +0 -22
- package/core/renderers/zelos/marker_svg.js +0 -179
- package/core/renderers/zelos/measurables/bottom_row.js +0 -66
- package/core/renderers/zelos/measurables/row_elements.js +0 -46
- package/core/renderers/zelos/path_object.js +0 -247
- package/core/renderers/zelos/renderer.js +0 -147
- package/core/renderers/zelos/zelos.js +0 -38
- package/core/serialization/exceptions.js +0 -144
- package/core/shortcut_registry.js +0 -366
- package/core/theme/themes.js +0 -23
- package/core/theme.js +0 -228
- package/core/theme_manager.js +0 -211
- package/core/toolbox/category.js +0 -751
- package/core/toolbox/collapsible_category.js +0 -311
- package/core/toolbox/separator.js +0 -133
- package/core/toolbox/toolbox_item.js +0 -173
- package/core/touch.js +0 -285
- package/core/utils/coordinate.js +0 -138
- package/core/utils/global.js +0 -41
- package/core/utils/keycodes.js +0 -172
- package/core/utils/metrics.js +0 -154
- package/core/utils/svg.js +0 -186
- package/core/utils/toolbox.js +0 -459
- package/core/utils/useragent.js +0 -197
- package/core/utils.js +0 -383
- package/core/variable_model.js +0 -96
- package/core/widgetdiv.js +0 -290
- package/core/workspace.js +0 -836
- package/core/workspace_comment.js +0 -400
- package/core/workspace_dragger.js +0 -115
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
* This is an abstract class that defines the UI on the block. Actual
|
|
10
10
|
* instances would be FieldTextInput, FieldDropdown, etc.
|
|
11
11
|
*/
|
|
12
|
-
'use strict';
|
|
13
12
|
|
|
14
13
|
/**
|
|
15
14
|
* Field. Used for editable titles, variables, etc.
|
|
@@ -17,283 +16,240 @@
|
|
|
17
16
|
* instances would be FieldTextInput, FieldDropdown, etc.
|
|
18
17
|
* @class
|
|
19
18
|
*/
|
|
20
|
-
goog
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const WidgetDiv = goog.require('Blockly.WidgetDiv');
|
|
24
|
-
const Xml = goog.require('Blockly.Xml');
|
|
25
|
-
const browserEvents = goog.require('Blockly.browserEvents');
|
|
26
|
-
const dom = goog.require('Blockly.utils.dom');
|
|
27
|
-
const dropDownDiv = goog.require('Blockly.dropDownDiv');
|
|
28
|
-
const eventUtils = goog.require('Blockly.Events.utils');
|
|
29
|
-
const parsing = goog.require('Blockly.utils.parsing');
|
|
30
|
-
const style = goog.require('Blockly.utils.style');
|
|
31
|
-
const userAgent = goog.require('Blockly.utils.userAgent');
|
|
32
|
-
const utilsXml = goog.require('Blockly.utils.xml');
|
|
33
|
-
/* eslint-disable-next-line no-unused-vars */
|
|
34
|
-
const {BlockSvg} = goog.requireType('Blockly.BlockSvg');
|
|
35
|
-
/* eslint-disable-next-line no-unused-vars */
|
|
36
|
-
const {Block} = goog.requireType('Blockly.Block');
|
|
37
|
-
/* eslint-disable-next-line no-unused-vars */
|
|
38
|
-
const {ConstantProvider} = goog.requireType('Blockly.blockRendering.ConstantProvider');
|
|
39
|
-
/* eslint-disable-next-line no-unused-vars */
|
|
40
|
-
const {Coordinate} = goog.requireType('Blockly.utils.Coordinate');
|
|
41
|
-
/* eslint-disable-next-line no-unused-vars */
|
|
42
|
-
const {IASTNodeLocationSvg} = goog.require('Blockly.IASTNodeLocationSvg');
|
|
43
|
-
/* eslint-disable-next-line no-unused-vars */
|
|
44
|
-
const {IASTNodeLocationWithBlock} = goog.require('Blockly.IASTNodeLocationWithBlock');
|
|
45
|
-
/* eslint-disable-next-line no-unused-vars */
|
|
46
|
-
const {IKeyboardAccessible} = goog.require('Blockly.IKeyboardAccessible');
|
|
47
|
-
/* eslint-disable-next-line no-unused-vars */
|
|
48
|
-
const {IRegistrable} = goog.require('Blockly.IRegistrable');
|
|
49
|
-
/* eslint-disable-next-line no-unused-vars */
|
|
50
|
-
const {Input} = goog.requireType('Blockly.Input');
|
|
51
|
-
const {MarkerManager} = goog.require('Blockly.MarkerManager');
|
|
52
|
-
const {Rect} = goog.require('Blockly.utils.Rect');
|
|
53
|
-
const {Sentinel} = goog.require('Blockly.utils.Sentinel');
|
|
54
|
-
/* eslint-disable-next-line no-unused-vars */
|
|
55
|
-
const {ShortcutRegistry} = goog.requireType('Blockly.ShortcutRegistry');
|
|
56
|
-
const {Size} = goog.require('Blockly.utils.Size');
|
|
57
|
-
const {Svg} = goog.require('Blockly.utils.Svg');
|
|
19
|
+
import * as goog from '../closure/goog/goog.js';
|
|
20
|
+
goog.declareModuleId('Blockly.Field');
|
|
21
|
+
|
|
58
22
|
/* eslint-disable-next-line no-unused-vars */
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
23
|
+
// Unused import preserved for side-effects. Remove if unneeded.
|
|
24
|
+
// import './shortcut_registry.js';
|
|
25
|
+
// Unused import preserved for side-effects. Remove if unneeded.
|
|
26
|
+
import './events/events_block_change.js';
|
|
27
|
+
// Unused import preserved for side-effects. Remove if unneeded.
|
|
28
|
+
// import './gesture.js';
|
|
29
|
+
|
|
30
|
+
import type {Block} from './block.js';
|
|
31
|
+
import type {BlockSvg} from './block_svg.js';
|
|
32
|
+
import * as browserEvents from './browser_events.js';
|
|
33
|
+
import * as dropDownDiv from './dropdowndiv.js';
|
|
34
|
+
import * as eventUtils from './events/utils.js';
|
|
35
|
+
import type {Input} from './input.js';
|
|
36
|
+
import type {IASTNodeLocationSvg} from './interfaces/i_ast_node_location_svg.js';
|
|
37
|
+
import type {IASTNodeLocationWithBlock} from './interfaces/i_ast_node_location_with_block.js';
|
|
38
|
+
import type {IKeyboardAccessible} from './interfaces/i_keyboard_accessible.js';
|
|
39
|
+
import type {IRegistrable} from './interfaces/i_registrable.js';
|
|
40
|
+
import {MarkerManager} from './marker_manager.js';
|
|
41
|
+
import type {ConstantProvider} from './renderers/common/constants.js';
|
|
42
|
+
import type {KeyboardShortcut} from './shortcut_registry.js';
|
|
43
|
+
import * as Tooltip from './tooltip.js';
|
|
44
|
+
import type {Coordinate} from './utils/coordinate.js';
|
|
45
|
+
import * as dom from './utils/dom.js';
|
|
46
|
+
import * as parsing from './utils/parsing.js';
|
|
47
|
+
import {Rect} from './utils/rect.js';
|
|
48
|
+
import {Sentinel} from './utils/sentinel.js';
|
|
49
|
+
import {Size} from './utils/size.js';
|
|
50
|
+
import * as style from './utils/style.js';
|
|
51
|
+
import {Svg} from './utils/svg.js';
|
|
52
|
+
import * as userAgent from './utils/useragent.js';
|
|
53
|
+
import * as utilsXml from './utils/xml.js';
|
|
54
|
+
import * as WidgetDiv from './widgetdiv.js';
|
|
55
|
+
import type {WorkspaceSvg} from './workspace_svg.js';
|
|
56
|
+
import * as Xml from './xml.js';
|
|
64
57
|
|
|
65
58
|
|
|
66
59
|
/**
|
|
67
60
|
* Abstract class for an editable field.
|
|
68
|
-
* @implements {IASTNodeLocationSvg}
|
|
69
|
-
* @implements {IASTNodeLocationWithBlock}
|
|
70
|
-
* @implements {IKeyboardAccessible}
|
|
71
|
-
* @implements {IRegistrable}
|
|
72
|
-
* @abstract
|
|
73
61
|
* @alias Blockly.Field
|
|
74
62
|
*/
|
|
75
|
-
class Field
|
|
63
|
+
export abstract class Field implements IASTNodeLocationSvg,
|
|
64
|
+
IASTNodeLocationWithBlock,
|
|
65
|
+
IKeyboardAccessible, IRegistrable {
|
|
66
|
+
/** The default value for this field. */
|
|
67
|
+
protected DEFAULT_VALUE: any = null;
|
|
68
|
+
|
|
69
|
+
/** Non-breaking space. */
|
|
70
|
+
static readonly NBSP = '\u00A0';
|
|
71
|
+
|
|
76
72
|
/**
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
* value after their own constructors have run).
|
|
81
|
-
* @param {?Function=} opt_validator A function that is called to validate
|
|
82
|
-
* changes to the field's value. Takes in a value & returns a validated
|
|
83
|
-
* value, or null to abort the change.
|
|
84
|
-
* @param {Object=} opt_config A map of options used to configure the field.
|
|
85
|
-
* Refer to the individual field's documentation for a list of properties
|
|
86
|
-
* this parameter supports.
|
|
73
|
+
* A value used to signal when a field's constructor should *not* set the
|
|
74
|
+
* field's value or run configure_, and should allow a subclass to do that
|
|
75
|
+
* instead.
|
|
87
76
|
*/
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Name of field. Unique within each block.
|
|
91
|
-
* Static labels are usually unnamed.
|
|
92
|
-
* @type {string|undefined}
|
|
93
|
-
*/
|
|
94
|
-
this.name = undefined;
|
|
77
|
+
static readonly SKIP_SETUP = new Sentinel();
|
|
95
78
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
this.value_ =
|
|
103
|
-
/** @type {typeof Field} */ (new.target).prototype.DEFAULT_VALUE;
|
|
79
|
+
/**
|
|
80
|
+
* Name of field. Unique within each block.
|
|
81
|
+
* Static labels are usually unnamed.
|
|
82
|
+
*/
|
|
83
|
+
name?: string = undefined;
|
|
84
|
+
protected value_: AnyDuringMigration;
|
|
104
85
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
*/
|
|
110
|
-
this.validator_ = null;
|
|
86
|
+
/** Validation function called when user edits an editable field. */
|
|
87
|
+
// AnyDuringMigration because: Type 'null' is not assignable to type
|
|
88
|
+
// 'Function'.
|
|
89
|
+
protected validator_: Function = null as AnyDuringMigration;
|
|
111
90
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
this.tooltip_ = null;
|
|
91
|
+
/**
|
|
92
|
+
* Used to cache the field's tooltip value if setTooltip is called when the
|
|
93
|
+
* field is not yet initialized. Is *not* guaranteed to be accurate.
|
|
94
|
+
*/
|
|
95
|
+
private tooltip_: Tooltip.TipInfo|null = null;
|
|
96
|
+
protected size_: Size;
|
|
119
97
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
98
|
+
/**
|
|
99
|
+
* Holds the cursors svg element when the cursor is attached to the field.
|
|
100
|
+
* This is null if there is no cursor on the field.
|
|
101
|
+
*/
|
|
102
|
+
// AnyDuringMigration because: Type 'null' is not assignable to type
|
|
103
|
+
// 'SVGElement'.
|
|
104
|
+
private cursorSvg_: SVGElement = null as AnyDuringMigration;
|
|
126
105
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
106
|
+
/**
|
|
107
|
+
* Holds the markers svg element when the marker is attached to the field.
|
|
108
|
+
* This is null if there is no marker on the field.
|
|
109
|
+
*/
|
|
110
|
+
// AnyDuringMigration because: Type 'null' is not assignable to type
|
|
111
|
+
// 'SVGElement'.
|
|
112
|
+
private markerSvg_: SVGElement = null as AnyDuringMigration;
|
|
134
113
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
* @private
|
|
140
|
-
*/
|
|
141
|
-
this.markerSvg_ = null;
|
|
114
|
+
/** The rendered field's SVG group element. */
|
|
115
|
+
// AnyDuringMigration because: Type 'null' is not assignable to type
|
|
116
|
+
// 'SVGGElement'.
|
|
117
|
+
protected fieldGroup_: SVGGElement = null as AnyDuringMigration;
|
|
142
118
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
*/
|
|
148
|
-
this.fieldGroup_ = null;
|
|
119
|
+
/** The rendered field's SVG border element. */
|
|
120
|
+
// AnyDuringMigration because: Type 'null' is not assignable to type
|
|
121
|
+
// 'SVGRectElement'.
|
|
122
|
+
protected borderRect_: SVGRectElement = null as AnyDuringMigration;
|
|
149
123
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
*/
|
|
155
|
-
this.borderRect_ = null;
|
|
124
|
+
/** The rendered field's SVG text element. */
|
|
125
|
+
// AnyDuringMigration because: Type 'null' is not assignable to type
|
|
126
|
+
// 'SVGTextElement'.
|
|
127
|
+
protected textElement_: SVGTextElement = null as AnyDuringMigration;
|
|
156
128
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
* @protected
|
|
161
|
-
*/
|
|
162
|
-
this.textElement_ = null;
|
|
129
|
+
/** The rendered field's text content element. */
|
|
130
|
+
// AnyDuringMigration because: Type 'null' is not assignable to type 'Text'.
|
|
131
|
+
protected textContent_: Text = null as AnyDuringMigration;
|
|
163
132
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
* @type {Text}
|
|
167
|
-
* @protected
|
|
168
|
-
*/
|
|
169
|
-
this.textContent_ = null;
|
|
133
|
+
/** Mouse down event listener data. */
|
|
134
|
+
private mouseDownWrapper_: browserEvents.Data|null = null;
|
|
170
135
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
*/
|
|
176
|
-
this.mouseDownWrapper_ = null;
|
|
136
|
+
/** Constants associated with the source block's renderer. */
|
|
137
|
+
// AnyDuringMigration because: Type 'null' is not assignable to type
|
|
138
|
+
// 'ConstantProvider'.
|
|
139
|
+
protected constants_: ConstantProvider = null as AnyDuringMigration;
|
|
177
140
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
this.constants_ = null;
|
|
141
|
+
/**
|
|
142
|
+
* Has this field been disposed of?
|
|
143
|
+
* @internal
|
|
144
|
+
*/
|
|
145
|
+
disposed = false;
|
|
184
146
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
* @type {boolean}
|
|
188
|
-
* @package
|
|
189
|
-
*/
|
|
190
|
-
this.disposed = false;
|
|
147
|
+
/** Maximum characters of text to display before adding an ellipsis. */
|
|
148
|
+
maxDisplayLength = 50;
|
|
191
149
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
*/
|
|
196
|
-
this.maxDisplayLength = 50;
|
|
150
|
+
/** Block this field is attached to. Starts as null, then set in init. */
|
|
151
|
+
// AnyDuringMigration because: Type 'null' is not assignable to type 'Block'.
|
|
152
|
+
protected sourceBlock_: Block = null as AnyDuringMigration;
|
|
197
153
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
* @type {Block}
|
|
201
|
-
* @protected
|
|
202
|
-
*/
|
|
203
|
-
this.sourceBlock_ = null;
|
|
154
|
+
/** Does this block need to be re-rendered? */
|
|
155
|
+
protected isDirty_ = true;
|
|
204
156
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
* @type {boolean}
|
|
208
|
-
* @protected
|
|
209
|
-
*/
|
|
210
|
-
this.isDirty_ = true;
|
|
157
|
+
/** Is the field visible, or hidden due to the block being collapsed? */
|
|
158
|
+
protected visible_ = true;
|
|
211
159
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
*/
|
|
217
|
-
this.visible_ = true;
|
|
160
|
+
/**
|
|
161
|
+
* Can the field value be changed using the editor on an editable block?
|
|
162
|
+
*/
|
|
163
|
+
protected enabled_ = true;
|
|
218
164
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
*/
|
|
224
|
-
this.enabled_ = true;
|
|
165
|
+
/** The element the click handler is bound to. */
|
|
166
|
+
// AnyDuringMigration because: Type 'null' is not assignable to type
|
|
167
|
+
// 'Element'.
|
|
168
|
+
protected clickTarget_: Element = null as AnyDuringMigration;
|
|
225
169
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
this.clickTarget_ = null;
|
|
170
|
+
/**
|
|
171
|
+
* The prefix field.
|
|
172
|
+
* @internal
|
|
173
|
+
*/
|
|
174
|
+
prefixField: string|null = null;
|
|
232
175
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
this.prefixField = null;
|
|
176
|
+
/**
|
|
177
|
+
* The suffix field.
|
|
178
|
+
* @internal
|
|
179
|
+
*/
|
|
180
|
+
suffixField: string|null = null;
|
|
239
181
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
this.suffixField = null;
|
|
182
|
+
/**
|
|
183
|
+
* Editable fields usually show some sort of UI indicating they are
|
|
184
|
+
* editable. They will also be saved by the serializer.
|
|
185
|
+
*/
|
|
186
|
+
EDITABLE = true;
|
|
246
187
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
188
|
+
/**
|
|
189
|
+
* Serializable fields are saved by the serializer, non-serializable fields
|
|
190
|
+
* are not. Editable fields should also be serializable. This is not the
|
|
191
|
+
* case by default so that SERIALIZABLE is backwards compatible.
|
|
192
|
+
*/
|
|
193
|
+
SERIALIZABLE = false;
|
|
253
194
|
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
* are not. Editable fields should also be serializable. This is not the
|
|
257
|
-
* case by default so that SERIALIZABLE is backwards compatible.
|
|
258
|
-
* @type {boolean}
|
|
259
|
-
*/
|
|
260
|
-
this.SERIALIZABLE = false;
|
|
195
|
+
/** Mouse cursor style when over the hotspot that initiates the editor. */
|
|
196
|
+
CURSOR = '';
|
|
261
197
|
|
|
198
|
+
/**
|
|
199
|
+
* @param value The initial value of the field.
|
|
200
|
+
* Also accepts Field.SKIP_SETUP if you wish to skip setup (only used by
|
|
201
|
+
* subclasses that want to handle configuration and setting the field value
|
|
202
|
+
* after their own constructors have run).
|
|
203
|
+
* @param opt_validator A function that is called to validate changes to the
|
|
204
|
+
* field's value. Takes in a value & returns a validated value, or null to
|
|
205
|
+
* abort the change.
|
|
206
|
+
* @param opt_config A map of options used to configure the field.
|
|
207
|
+
* Refer to the individual field's documentation for a list of properties
|
|
208
|
+
* this parameter supports.
|
|
209
|
+
*/
|
|
210
|
+
constructor(
|
|
211
|
+
value: AnyDuringMigration, opt_validator?: Function|null,
|
|
212
|
+
opt_config?: FieldConfig) {
|
|
262
213
|
/**
|
|
263
|
-
*
|
|
264
|
-
*
|
|
214
|
+
* A generic value possessed by the field.
|
|
215
|
+
* Should generally be non-null, only null when the field is created.
|
|
265
216
|
*/
|
|
266
|
-
this.
|
|
217
|
+
this.value_ = (new.target).prototype.DEFAULT_VALUE;
|
|
218
|
+
|
|
219
|
+
/** The size of the area rendered by the field. */
|
|
220
|
+
this.size_ = new Size(0, 0);
|
|
267
221
|
|
|
268
|
-
if (value === Field.SKIP_SETUP)
|
|
269
|
-
|
|
222
|
+
if (value === Field.SKIP_SETUP) {
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
if (opt_config) {
|
|
226
|
+
this.configure_(opt_config);
|
|
227
|
+
}
|
|
270
228
|
this.setValue(value);
|
|
271
|
-
if (opt_validator)
|
|
229
|
+
if (opt_validator) {
|
|
230
|
+
this.setValidator(opt_validator);
|
|
231
|
+
}
|
|
272
232
|
}
|
|
273
233
|
|
|
274
234
|
/**
|
|
275
235
|
* Process the configuration map passed to the field.
|
|
276
|
-
* @param
|
|
277
|
-
*
|
|
278
|
-
*
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
configure_(config) {
|
|
282
|
-
let tooltip = config['tooltip'];
|
|
283
|
-
if (typeof tooltip === 'string') {
|
|
284
|
-
tooltip = parsing.replaceMessageReferences(config['tooltip']);
|
|
285
|
-
}
|
|
286
|
-
tooltip && this.setTooltip(tooltip);
|
|
287
|
-
|
|
236
|
+
* @param config A map of options used to configure the field. See the
|
|
237
|
+
* individual field's documentation for a list of properties this
|
|
238
|
+
* parameter supports.
|
|
239
|
+
*/
|
|
240
|
+
protected configure_(config: FieldConfig) {
|
|
288
241
|
// TODO (#2884): Possibly add CSS class config option.
|
|
289
242
|
// TODO (#2885): Possibly add cursor config option.
|
|
243
|
+
if (config.tooltip) {
|
|
244
|
+
this.setTooltip(parsing.replaceMessageReferences(config.tooltip));
|
|
245
|
+
}
|
|
290
246
|
}
|
|
291
247
|
|
|
292
248
|
/**
|
|
293
249
|
* Attach this field to a block.
|
|
294
|
-
* @param
|
|
250
|
+
* @param block The block containing this field.
|
|
295
251
|
*/
|
|
296
|
-
setSourceBlock(block) {
|
|
252
|
+
setSourceBlock(block: Block) {
|
|
297
253
|
if (this.sourceBlock_) {
|
|
298
254
|
throw Error('Field already bound to a block');
|
|
299
255
|
}
|
|
@@ -302,44 +258,42 @@ class Field {
|
|
|
302
258
|
|
|
303
259
|
/**
|
|
304
260
|
* Get the renderer constant provider.
|
|
305
|
-
* @return
|
|
306
|
-
* provider.
|
|
261
|
+
* @return The renderer constant provider.
|
|
307
262
|
*/
|
|
308
|
-
getConstants() {
|
|
309
|
-
if (!this.constants_ && this.sourceBlock_ && this.sourceBlock_.
|
|
263
|
+
getConstants(): ConstantProvider|null {
|
|
264
|
+
if (!this.constants_ && this.sourceBlock_ && !this.sourceBlock_.disposed &&
|
|
310
265
|
this.sourceBlock_.workspace.rendered) {
|
|
311
|
-
this.constants_ =
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
.getConstants();
|
|
266
|
+
this.constants_ = (this.sourceBlock_.workspace as WorkspaceSvg)
|
|
267
|
+
.getRenderer()
|
|
268
|
+
.getConstants();
|
|
315
269
|
}
|
|
316
270
|
return this.constants_;
|
|
317
271
|
}
|
|
318
272
|
|
|
319
273
|
/**
|
|
320
274
|
* Get the block this field is attached to.
|
|
321
|
-
* @return
|
|
275
|
+
* @return The block containing this field.
|
|
322
276
|
*/
|
|
323
|
-
getSourceBlock() {
|
|
277
|
+
getSourceBlock(): Block {
|
|
324
278
|
return this.sourceBlock_;
|
|
325
279
|
}
|
|
326
280
|
|
|
327
281
|
/**
|
|
328
282
|
* Initialize everything to render this field. Override
|
|
329
283
|
* methods initModel and initView rather than this method.
|
|
330
|
-
* @package
|
|
331
284
|
* @final
|
|
285
|
+
* @internal
|
|
332
286
|
*/
|
|
333
287
|
init() {
|
|
334
288
|
if (this.fieldGroup_) {
|
|
335
289
|
// Field has already been initialized once.
|
|
336
290
|
return;
|
|
337
291
|
}
|
|
338
|
-
this.fieldGroup_ = dom.createSvgElement(Svg.G, {}
|
|
292
|
+
this.fieldGroup_ = dom.createSvgElement(Svg.G, {});
|
|
339
293
|
if (!this.isVisible()) {
|
|
340
294
|
this.fieldGroup_.style.display = 'none';
|
|
341
295
|
}
|
|
342
|
-
const sourceBlockSvg =
|
|
296
|
+
const sourceBlockSvg = this.sourceBlock_ as BlockSvg;
|
|
343
297
|
sourceBlockSvg.getSvgRoot().appendChild(this.fieldGroup_);
|
|
344
298
|
this.initView();
|
|
345
299
|
this.updateEditable();
|
|
@@ -350,7 +304,7 @@ class Field {
|
|
|
350
304
|
|
|
351
305
|
/**
|
|
352
306
|
* Create the block UI for this field.
|
|
353
|
-
* @
|
|
307
|
+
* @internal
|
|
354
308
|
*/
|
|
355
309
|
initView() {
|
|
356
310
|
this.createBorderRect_();
|
|
@@ -360,7 +314,7 @@ class Field {
|
|
|
360
314
|
/**
|
|
361
315
|
* Initializes the model of the field after it has been installed on a block.
|
|
362
316
|
* No-op by default.
|
|
363
|
-
* @
|
|
317
|
+
* @internal
|
|
364
318
|
*/
|
|
365
319
|
initModel() {}
|
|
366
320
|
|
|
@@ -368,13 +322,12 @@ class Field {
|
|
|
368
322
|
* Create a field border rect element. Not to be overridden by subclasses.
|
|
369
323
|
* Instead modify the result of the function inside initView, or create a
|
|
370
324
|
* separate function to call.
|
|
371
|
-
* @protected
|
|
372
325
|
*/
|
|
373
|
-
createBorderRect_() {
|
|
326
|
+
protected createBorderRect_() {
|
|
374
327
|
this.borderRect_ = dom.createSvgElement(
|
|
375
328
|
Svg.RECT, {
|
|
376
|
-
'rx': this.getConstants()
|
|
377
|
-
'ry': this.getConstants()
|
|
329
|
+
'rx': this.getConstants()!.FIELD_BORDER_RECT_RADIUS,
|
|
330
|
+
'ry': this.getConstants()!.FIELD_BORDER_RECT_RADIUS,
|
|
378
331
|
'x': 0,
|
|
379
332
|
'y': 0,
|
|
380
333
|
'height': this.size_.height,
|
|
@@ -388,15 +341,14 @@ class Field {
|
|
|
388
341
|
* Create a field text element. Not to be overridden by subclasses. Instead
|
|
389
342
|
* modify the result of the function inside initView, or create a separate
|
|
390
343
|
* function to call.
|
|
391
|
-
* @protected
|
|
392
344
|
*/
|
|
393
|
-
createTextElement_() {
|
|
345
|
+
protected createTextElement_() {
|
|
394
346
|
this.textElement_ = dom.createSvgElement(
|
|
395
347
|
Svg.TEXT, {
|
|
396
348
|
'class': 'blocklyText',
|
|
397
349
|
},
|
|
398
350
|
this.fieldGroup_);
|
|
399
|
-
if (this.getConstants()
|
|
351
|
+
if (this.getConstants()!.FIELD_TEXT_BASELINE_CENTER) {
|
|
400
352
|
this.textElement_.setAttribute('dominant-baseline', 'central');
|
|
401
353
|
}
|
|
402
354
|
this.textContent_ = document.createTextNode('');
|
|
@@ -406,9 +358,8 @@ class Field {
|
|
|
406
358
|
/**
|
|
407
359
|
* Bind events to the field. Can be overridden by subclasses if they need to
|
|
408
360
|
* do custom input handling.
|
|
409
|
-
* @protected
|
|
410
361
|
*/
|
|
411
|
-
bindEvents_() {
|
|
362
|
+
protected bindEvents_() {
|
|
412
363
|
Tooltip.bindMouseEvents(this.getClickTarget_());
|
|
413
364
|
this.mouseDownWrapper_ = browserEvents.conditionalBind(
|
|
414
365
|
this.getClickTarget_(), 'mousedown', this, this.onMouseDown_);
|
|
@@ -417,22 +368,21 @@ class Field {
|
|
|
417
368
|
/**
|
|
418
369
|
* Sets the field's value based on the given XML element. Should only be
|
|
419
370
|
* called by Blockly.Xml.
|
|
420
|
-
* @param
|
|
421
|
-
*
|
|
422
|
-
* @package
|
|
371
|
+
* @param fieldElement The element containing info about the field's state.
|
|
372
|
+
* @internal
|
|
423
373
|
*/
|
|
424
|
-
fromXml(fieldElement) {
|
|
374
|
+
fromXml(fieldElement: Element) {
|
|
425
375
|
this.setValue(fieldElement.textContent);
|
|
426
376
|
}
|
|
427
377
|
|
|
428
378
|
/**
|
|
429
379
|
* Serializes this field's value to XML. Should only be called by Blockly.Xml.
|
|
430
|
-
* @param
|
|
431
|
-
*
|
|
432
|
-
* @return
|
|
433
|
-
* @
|
|
380
|
+
* @param fieldElement The element to populate with info about the field's
|
|
381
|
+
* state.
|
|
382
|
+
* @return The element containing info about the field's state.
|
|
383
|
+
* @internal
|
|
434
384
|
*/
|
|
435
|
-
toXml(fieldElement) {
|
|
385
|
+
toXml(fieldElement: Element): Element {
|
|
436
386
|
fieldElement.textContent = this.getValue();
|
|
437
387
|
return fieldElement;
|
|
438
388
|
}
|
|
@@ -440,14 +390,13 @@ class Field {
|
|
|
440
390
|
/**
|
|
441
391
|
* Saves this fields value as something which can be serialized to JSON.
|
|
442
392
|
* Should only be called by the serialization system.
|
|
443
|
-
* @param
|
|
444
|
-
*
|
|
445
|
-
*
|
|
446
|
-
*
|
|
447
|
-
* @
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
saveState(_doFullSerialization) {
|
|
393
|
+
* @param _doFullSerialization If true, this signals to the field that if it
|
|
394
|
+
* normally just saves a reference to some state (eg variable fields) it
|
|
395
|
+
* should instead serialize the full state of the thing being referenced.
|
|
396
|
+
* @return JSON serializable state.
|
|
397
|
+
* @internal
|
|
398
|
+
*/
|
|
399
|
+
saveState(_doFullSerialization?: boolean): AnyDuringMigration {
|
|
451
400
|
const legacyState = this.saveLegacyState(Field);
|
|
452
401
|
if (legacyState !== null) {
|
|
453
402
|
return legacyState;
|
|
@@ -458,10 +407,10 @@ class Field {
|
|
|
458
407
|
/**
|
|
459
408
|
* Sets the field's state based on the given state value. Should only be
|
|
460
409
|
* called by the serialization system.
|
|
461
|
-
* @param
|
|
462
|
-
* @
|
|
410
|
+
* @param state The state we want to apply to the field.
|
|
411
|
+
* @internal
|
|
463
412
|
*/
|
|
464
|
-
loadState(state) {
|
|
413
|
+
loadState(state: AnyDuringMigration) {
|
|
465
414
|
if (this.loadLegacyState(Field, state)) {
|
|
466
415
|
return;
|
|
467
416
|
}
|
|
@@ -472,12 +421,11 @@ class Field {
|
|
|
472
421
|
* Returns a stringified version of the XML state, if it should be used.
|
|
473
422
|
* Otherwise this returns null, to signal the field should use its own
|
|
474
423
|
* serialization.
|
|
475
|
-
* @param
|
|
424
|
+
* @param callingClass The class calling this method.
|
|
476
425
|
* Used to see if `this` has overridden any relevant hooks.
|
|
477
|
-
* @return
|
|
478
|
-
* @protected
|
|
426
|
+
* @return The stringified version of the XML state, or null.
|
|
479
427
|
*/
|
|
480
|
-
saveLegacyState(callingClass) {
|
|
428
|
+
protected saveLegacyState(callingClass: AnyDuringMigration): string|null {
|
|
481
429
|
if (callingClass.prototype.saveState === this.saveState &&
|
|
482
430
|
callingClass.prototype.toXml !== this.toXml) {
|
|
483
431
|
const elem = utilsXml.createElement('field');
|
|
@@ -492,17 +440,18 @@ class Field {
|
|
|
492
440
|
}
|
|
493
441
|
|
|
494
442
|
/**
|
|
495
|
-
* Loads the given state using either the old XML
|
|
443
|
+
* Loads the given state using either the old XML hooks, if they should be
|
|
496
444
|
* used. Returns true to indicate loading has been handled, false otherwise.
|
|
497
|
-
* @param
|
|
445
|
+
* @param callingClass The class calling this method.
|
|
498
446
|
* Used to see if `this` has overridden any relevant hooks.
|
|
499
|
-
* @param
|
|
500
|
-
* @return
|
|
447
|
+
* @param state The state to apply to the field.
|
|
448
|
+
* @return Whether the state was applied or not.
|
|
501
449
|
*/
|
|
502
|
-
loadLegacyState(callingClass, state)
|
|
450
|
+
loadLegacyState(callingClass: AnyDuringMigration, state: AnyDuringMigration):
|
|
451
|
+
boolean {
|
|
503
452
|
if (callingClass.prototype.loadState === this.loadState &&
|
|
504
453
|
callingClass.prototype.fromXml !== this.fromXml) {
|
|
505
|
-
this.fromXml(Xml.textToDom(
|
|
454
|
+
this.fromXml(Xml.textToDom(state as string));
|
|
506
455
|
return true;
|
|
507
456
|
}
|
|
508
457
|
// Either they called this on purpose from their loadState, or they have
|
|
@@ -512,7 +461,7 @@ class Field {
|
|
|
512
461
|
|
|
513
462
|
/**
|
|
514
463
|
* Dispose of all DOM objects and events belonging to this editable field.
|
|
515
|
-
* @
|
|
464
|
+
* @internal
|
|
516
465
|
*/
|
|
517
466
|
dispose() {
|
|
518
467
|
dropDownDiv.hideIfOwner(this);
|
|
@@ -528,9 +477,7 @@ class Field {
|
|
|
528
477
|
this.disposed = true;
|
|
529
478
|
}
|
|
530
479
|
|
|
531
|
-
/**
|
|
532
|
-
* Add or remove the UI indicating if this field is editable or not.
|
|
533
|
-
*/
|
|
480
|
+
/** Add or remove the UI indicating if this field is editable or not. */
|
|
534
481
|
updateEditable() {
|
|
535
482
|
const group = this.fieldGroup_;
|
|
536
483
|
if (!this.EDITABLE || !group) {
|
|
@@ -550,9 +497,9 @@ class Field {
|
|
|
550
497
|
/**
|
|
551
498
|
* Set whether this field's value can be changed using the editor when the
|
|
552
499
|
* source block is editable.
|
|
553
|
-
* @param
|
|
500
|
+
* @param enabled True if enabled.
|
|
554
501
|
*/
|
|
555
|
-
setEnabled(enabled) {
|
|
502
|
+
setEnabled(enabled: boolean) {
|
|
556
503
|
this.enabled_ = enabled;
|
|
557
504
|
this.updateEditable();
|
|
558
505
|
}
|
|
@@ -560,17 +507,17 @@ class Field {
|
|
|
560
507
|
/**
|
|
561
508
|
* Check whether this field's value can be changed using the editor when the
|
|
562
509
|
* source block is editable.
|
|
563
|
-
* @return
|
|
510
|
+
* @return Whether this field is enabled.
|
|
564
511
|
*/
|
|
565
|
-
isEnabled() {
|
|
512
|
+
isEnabled(): boolean {
|
|
566
513
|
return this.enabled_;
|
|
567
514
|
}
|
|
568
515
|
|
|
569
516
|
/**
|
|
570
517
|
* Check whether this field defines the showEditor_ function.
|
|
571
|
-
* @return
|
|
518
|
+
* @return Whether this field is clickable.
|
|
572
519
|
*/
|
|
573
|
-
isClickable() {
|
|
520
|
+
isClickable(): boolean {
|
|
574
521
|
return this.enabled_ && !!this.sourceBlock_ &&
|
|
575
522
|
this.sourceBlock_.isEditable() &&
|
|
576
523
|
this.showEditor_ !== Field.prototype.showEditor_;
|
|
@@ -580,10 +527,10 @@ class Field {
|
|
|
580
527
|
* Check whether this field is currently editable. Some fields are never
|
|
581
528
|
* EDITABLE (e.g. text labels). Other fields may be EDITABLE but may exist on
|
|
582
529
|
* non-editable blocks or be currently disabled.
|
|
583
|
-
* @return
|
|
584
|
-
*
|
|
530
|
+
* @return Whether this field is currently enabled, editable and on an
|
|
531
|
+
* editable block.
|
|
585
532
|
*/
|
|
586
|
-
isCurrentlyEditable() {
|
|
533
|
+
isCurrentlyEditable(): boolean {
|
|
587
534
|
return this.enabled_ && this.EDITABLE && !!this.sourceBlock_ &&
|
|
588
535
|
this.sourceBlock_.isEditable();
|
|
589
536
|
}
|
|
@@ -591,9 +538,9 @@ class Field {
|
|
|
591
538
|
/**
|
|
592
539
|
* Check whether this field should be serialized by the XML renderer.
|
|
593
540
|
* Handles the logic for backwards compatibility and incongruous states.
|
|
594
|
-
* @return
|
|
541
|
+
* @return Whether this field should be serialized or not.
|
|
595
542
|
*/
|
|
596
|
-
isSerializable() {
|
|
543
|
+
isSerializable(): boolean {
|
|
597
544
|
let isSerializable = false;
|
|
598
545
|
if (this.name) {
|
|
599
546
|
if (this.SERIALIZABLE) {
|
|
@@ -611,19 +558,19 @@ class Field {
|
|
|
611
558
|
|
|
612
559
|
/**
|
|
613
560
|
* Gets whether this editable field is visible or not.
|
|
614
|
-
* @return
|
|
561
|
+
* @return True if visible.
|
|
615
562
|
*/
|
|
616
|
-
isVisible() {
|
|
563
|
+
isVisible(): boolean {
|
|
617
564
|
return this.visible_;
|
|
618
565
|
}
|
|
619
566
|
|
|
620
567
|
/**
|
|
621
568
|
* Sets whether this editable field is visible or not. Should only be called
|
|
622
569
|
* by input.setVisible.
|
|
623
|
-
* @param
|
|
624
|
-
* @
|
|
570
|
+
* @param visible True if visible.
|
|
571
|
+
* @internal
|
|
625
572
|
*/
|
|
626
|
-
setVisible(visible) {
|
|
573
|
+
setVisible(visible: boolean) {
|
|
627
574
|
if (this.visible_ === visible) {
|
|
628
575
|
return;
|
|
629
576
|
}
|
|
@@ -646,47 +593,45 @@ class Field {
|
|
|
646
593
|
* value is accepted as valid. This is to allow for fields using the
|
|
647
594
|
* validated function as a field-level change event notification.
|
|
648
595
|
*
|
|
649
|
-
* @param
|
|
650
|
-
*
|
|
596
|
+
* @param handler The validator function or null to clear a previous
|
|
597
|
+
* validator.
|
|
651
598
|
*/
|
|
652
|
-
setValidator(handler) {
|
|
599
|
+
setValidator(handler: Function) {
|
|
653
600
|
this.validator_ = handler;
|
|
654
601
|
}
|
|
655
602
|
|
|
656
603
|
/**
|
|
657
604
|
* Gets the validation function for editable fields, or null if not set.
|
|
658
|
-
* @return
|
|
605
|
+
* @return Validation function, or null.
|
|
659
606
|
*/
|
|
660
|
-
getValidator() {
|
|
607
|
+
getValidator(): Function|null {
|
|
661
608
|
return this.validator_;
|
|
662
609
|
}
|
|
663
610
|
|
|
664
611
|
/**
|
|
665
612
|
* Gets the group element for this editable field.
|
|
666
613
|
* Used for measuring the size and for positioning.
|
|
667
|
-
* @return
|
|
614
|
+
* @return The group element.
|
|
668
615
|
*/
|
|
669
|
-
getSvgRoot() {
|
|
670
|
-
return
|
|
616
|
+
getSvgRoot(): SVGGElement {
|
|
617
|
+
return this.fieldGroup_;
|
|
671
618
|
}
|
|
672
619
|
|
|
673
620
|
/**
|
|
674
621
|
* Updates the field to match the colour/style of the block. Should only be
|
|
675
622
|
* called by BlockSvg.applyColour().
|
|
676
|
-
* @
|
|
623
|
+
* @internal
|
|
677
624
|
*/
|
|
678
|
-
applyColour() {
|
|
679
|
-
|
|
680
|
-
}
|
|
625
|
+
applyColour() {}
|
|
626
|
+
// Non-abstract sub-classes may wish to implement this. See FieldDropdown.
|
|
681
627
|
|
|
682
628
|
/**
|
|
683
629
|
* Used by getSize() to move/resize any DOM elements, and get the new size.
|
|
684
630
|
*
|
|
685
631
|
* All rendering that has an effect on the size/shape of the block should be
|
|
686
632
|
* done here, and should be triggered by getSize().
|
|
687
|
-
* @protected
|
|
688
633
|
*/
|
|
689
|
-
render_() {
|
|
634
|
+
protected render_() {
|
|
690
635
|
if (this.textContent_) {
|
|
691
636
|
this.textContent_.nodeValue = this.getDisplayText_();
|
|
692
637
|
}
|
|
@@ -696,12 +641,12 @@ class Field {
|
|
|
696
641
|
/**
|
|
697
642
|
* Calls showEditor_ when the field is clicked if the field is clickable.
|
|
698
643
|
* Do not override.
|
|
699
|
-
* @param
|
|
700
|
-
*
|
|
701
|
-
* @package
|
|
644
|
+
* @param opt_e Optional mouse event that triggered the field to open, or
|
|
645
|
+
* undefined if triggered programmatically.
|
|
702
646
|
* @final
|
|
647
|
+
* @internal
|
|
703
648
|
*/
|
|
704
|
-
showEditor(opt_e) {
|
|
649
|
+
showEditor(opt_e?: Event) {
|
|
705
650
|
if (this.isClickable()) {
|
|
706
651
|
this.showEditor_(opt_e);
|
|
707
652
|
}
|
|
@@ -710,39 +655,33 @@ class Field {
|
|
|
710
655
|
/**
|
|
711
656
|
* A developer hook to create an editor for the field. This is no-op by
|
|
712
657
|
* default, and must be overriden to create an editor.
|
|
713
|
-
* @param
|
|
714
|
-
*
|
|
715
|
-
* @return {void}
|
|
716
|
-
* @protected
|
|
658
|
+
* @param _e Optional mouse event that triggered the field to open, or
|
|
659
|
+
* undefined if triggered programmatically.
|
|
717
660
|
*/
|
|
718
|
-
showEditor_(_e) {
|
|
719
|
-
|
|
720
|
-
}
|
|
661
|
+
protected showEditor_(_e?: Event): void {}
|
|
662
|
+
// NOP
|
|
721
663
|
|
|
722
664
|
/**
|
|
723
665
|
* Updates the size of the field based on the text.
|
|
724
|
-
* @param
|
|
725
|
-
* element.
|
|
726
|
-
* @protected
|
|
666
|
+
* @param opt_margin margin to use when positioning the text element.
|
|
727
667
|
*/
|
|
728
|
-
updateSize_(opt_margin) {
|
|
668
|
+
protected updateSize_(opt_margin?: number) {
|
|
729
669
|
const constants = this.getConstants();
|
|
730
|
-
const xOffset = opt_margin !== undefined ?
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
0);
|
|
670
|
+
const xOffset = opt_margin !== undefined ? opt_margin :
|
|
671
|
+
this.borderRect_ ? this.getConstants()!.FIELD_BORDER_RECT_X_PADDING :
|
|
672
|
+
0;
|
|
734
673
|
let totalWidth = xOffset * 2;
|
|
735
|
-
let totalHeight = constants
|
|
674
|
+
let totalHeight = constants!.FIELD_TEXT_HEIGHT;
|
|
736
675
|
|
|
737
676
|
let contentWidth = 0;
|
|
738
677
|
if (this.textElement_) {
|
|
739
678
|
contentWidth = dom.getFastTextWidth(
|
|
740
|
-
this.textElement_, constants
|
|
741
|
-
constants
|
|
679
|
+
this.textElement_, constants!.FIELD_TEXT_FONTSIZE,
|
|
680
|
+
constants!.FIELD_TEXT_FONTWEIGHT, constants!.FIELD_TEXT_FONTFAMILY);
|
|
742
681
|
totalWidth += contentWidth;
|
|
743
682
|
}
|
|
744
683
|
if (this.borderRect_) {
|
|
745
|
-
totalHeight = Math.max(totalHeight, constants
|
|
684
|
+
totalHeight = Math.max(totalHeight, constants!.FIELD_BORDER_RECT_HEIGHT);
|
|
746
685
|
}
|
|
747
686
|
|
|
748
687
|
this.size_.height = totalHeight;
|
|
@@ -755,52 +694,64 @@ class Field {
|
|
|
755
694
|
/**
|
|
756
695
|
* Position a field's text element after a size change. This handles both LTR
|
|
757
696
|
* and RTL positioning.
|
|
758
|
-
* @param
|
|
759
|
-
* @param
|
|
760
|
-
* @protected
|
|
697
|
+
* @param xOffset x offset to use when positioning the text element.
|
|
698
|
+
* @param contentWidth The content width.
|
|
761
699
|
*/
|
|
762
|
-
positionTextElement_(xOffset, contentWidth) {
|
|
700
|
+
protected positionTextElement_(xOffset: number, contentWidth: number) {
|
|
763
701
|
if (!this.textElement_) {
|
|
764
702
|
return;
|
|
765
703
|
}
|
|
766
704
|
const constants = this.getConstants();
|
|
767
705
|
const halfHeight = this.size_.height / 2;
|
|
768
706
|
|
|
707
|
+
// AnyDuringMigration because: Argument of type 'number' is not assignable
|
|
708
|
+
// to parameter of type 'string'.
|
|
769
709
|
this.textElement_.setAttribute(
|
|
770
710
|
'x',
|
|
771
|
-
this.sourceBlock_.RTL ? this.size_.width - contentWidth - xOffset :
|
|
772
|
-
|
|
711
|
+
(this.sourceBlock_.RTL ? this.size_.width - contentWidth - xOffset :
|
|
712
|
+
xOffset) as AnyDuringMigration);
|
|
713
|
+
// AnyDuringMigration because: Argument of type 'number' is not assignable
|
|
714
|
+
// to parameter of type 'string'.
|
|
773
715
|
this.textElement_.setAttribute(
|
|
774
716
|
'y',
|
|
775
|
-
constants
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
717
|
+
(constants!.FIELD_TEXT_BASELINE_CENTER ?
|
|
718
|
+
halfHeight :
|
|
719
|
+
halfHeight - constants!.FIELD_TEXT_HEIGHT / 2 +
|
|
720
|
+
constants!.FIELD_TEXT_BASELINE) as AnyDuringMigration);
|
|
779
721
|
}
|
|
780
722
|
|
|
781
|
-
/**
|
|
782
|
-
|
|
783
|
-
* @protected
|
|
784
|
-
*/
|
|
785
|
-
positionBorderRect_() {
|
|
723
|
+
/** Position a field's border rect after a size change. */
|
|
724
|
+
protected positionBorderRect_() {
|
|
786
725
|
if (!this.borderRect_) {
|
|
787
726
|
return;
|
|
788
727
|
}
|
|
789
|
-
|
|
790
|
-
|
|
728
|
+
// AnyDuringMigration because: Argument of type 'number' is not assignable
|
|
729
|
+
// to parameter of type 'string'.
|
|
791
730
|
this.borderRect_.setAttribute(
|
|
792
|
-
'
|
|
731
|
+
'width', this.size_.width as AnyDuringMigration);
|
|
732
|
+
// AnyDuringMigration because: Argument of type 'number' is not assignable
|
|
733
|
+
// to parameter of type 'string'.
|
|
793
734
|
this.borderRect_.setAttribute(
|
|
794
|
-
'
|
|
735
|
+
'height', this.size_.height as AnyDuringMigration);
|
|
736
|
+
// AnyDuringMigration because: Argument of type 'number' is not assignable
|
|
737
|
+
// to parameter of type 'string'.
|
|
738
|
+
this.borderRect_.setAttribute(
|
|
739
|
+
'rx',
|
|
740
|
+
this.getConstants()!.FIELD_BORDER_RECT_RADIUS as AnyDuringMigration);
|
|
741
|
+
// AnyDuringMigration because: Argument of type 'number' is not assignable
|
|
742
|
+
// to parameter of type 'string'.
|
|
743
|
+
this.borderRect_.setAttribute(
|
|
744
|
+
'ry',
|
|
745
|
+
this.getConstants()!.FIELD_BORDER_RECT_RADIUS as AnyDuringMigration);
|
|
795
746
|
}
|
|
796
747
|
|
|
797
748
|
/**
|
|
798
749
|
* Returns the height and width of the field.
|
|
799
750
|
*
|
|
800
751
|
* This should *in general* be the only place render_ gets called from.
|
|
801
|
-
* @return
|
|
752
|
+
* @return Height and width.
|
|
802
753
|
*/
|
|
803
|
-
getSize() {
|
|
754
|
+
getSize(): Size {
|
|
804
755
|
if (!this.isVisible()) {
|
|
805
756
|
return new Size(0, 0);
|
|
806
757
|
}
|
|
@@ -822,12 +773,11 @@ class Field {
|
|
|
822
773
|
/**
|
|
823
774
|
* Returns the bounding box of the rendered field, accounting for workspace
|
|
824
775
|
* scaling.
|
|
825
|
-
* @return
|
|
826
|
-
*
|
|
827
|
-
*
|
|
828
|
-
* @package
|
|
776
|
+
* @return An object with top, bottom, left, and right in pixels relative to
|
|
777
|
+
* the top left corner of the page (window coordinates).
|
|
778
|
+
* @internal
|
|
829
779
|
*/
|
|
830
|
-
getScaledBBox() {
|
|
780
|
+
getScaledBBox(): Rect {
|
|
831
781
|
let scaledWidth;
|
|
832
782
|
let scaledHeight;
|
|
833
783
|
let xy;
|
|
@@ -835,9 +785,8 @@ class Field {
|
|
|
835
785
|
// Browsers are inconsistent in what they return for a bounding box.
|
|
836
786
|
// - Webkit / Blink: fill-box / object bounding box
|
|
837
787
|
// - Gecko / Triden / EdgeHTML: stroke-box
|
|
838
|
-
const bBox = this.sourceBlock_.getHeightWidth();
|
|
839
|
-
const scale =
|
|
840
|
-
/** @type {!WorkspaceSvg} */ (this.sourceBlock_.workspace).scale;
|
|
788
|
+
const bBox = (this.sourceBlock_ as BlockSvg).getHeightWidth();
|
|
789
|
+
const scale = (this.sourceBlock_.workspace as WorkspaceSvg).scale;
|
|
841
790
|
xy = this.getAbsoluteXY_();
|
|
842
791
|
scaledWidth = bBox.width * scale;
|
|
843
792
|
scaledHeight = bBox.height * scale;
|
|
@@ -867,10 +816,9 @@ class Field {
|
|
|
867
816
|
/**
|
|
868
817
|
* Get the text from this field to display on the block. May differ from
|
|
869
818
|
* ``getText`` due to ellipsis, and other formatting.
|
|
870
|
-
* @return
|
|
871
|
-
* @protected
|
|
819
|
+
* @return Text to display.
|
|
872
820
|
*/
|
|
873
|
-
getDisplayText_() {
|
|
821
|
+
protected getDisplayText_(): string {
|
|
874
822
|
let text = this.getText();
|
|
875
823
|
if (!text) {
|
|
876
824
|
// Prevent the field from disappearing if empty.
|
|
@@ -893,14 +841,16 @@ class Field {
|
|
|
893
841
|
* Get the text from this field.
|
|
894
842
|
* Override getText_ to provide a different behavior than simply casting the
|
|
895
843
|
* value to a string.
|
|
896
|
-
* @return
|
|
844
|
+
* @return Current text.
|
|
897
845
|
* @final
|
|
898
846
|
*/
|
|
899
|
-
getText() {
|
|
847
|
+
getText(): string {
|
|
900
848
|
// this.getText_ was intended so that devs don't have to remember to call
|
|
901
849
|
// super when overriding how the text of the field is generated. (#2910)
|
|
902
850
|
const text = this.getText_();
|
|
903
|
-
if (text !== null)
|
|
851
|
+
if (text !== null) {
|
|
852
|
+
return String(text);
|
|
853
|
+
}
|
|
904
854
|
return String(this.getValue());
|
|
905
855
|
}
|
|
906
856
|
|
|
@@ -909,10 +859,9 @@ class Field {
|
|
|
909
859
|
* Override if the text representation of the value of this field
|
|
910
860
|
* is not just a string cast of its value.
|
|
911
861
|
* Return null to resort to a string cast.
|
|
912
|
-
* @return
|
|
913
|
-
* @protected
|
|
862
|
+
* @return Current text or null.
|
|
914
863
|
*/
|
|
915
|
-
getText_() {
|
|
864
|
+
protected getText_(): string|null {
|
|
916
865
|
return null;
|
|
917
866
|
}
|
|
918
867
|
|
|
@@ -921,11 +870,13 @@ class Field {
|
|
|
921
870
|
* rerender this field and adjust for any sizing changes.
|
|
922
871
|
* Other fields on the same block will not rerender, because their sizes have
|
|
923
872
|
* already been recorded.
|
|
924
|
-
* @
|
|
873
|
+
* @internal
|
|
925
874
|
*/
|
|
926
875
|
markDirty() {
|
|
927
876
|
this.isDirty_ = true;
|
|
928
|
-
|
|
877
|
+
// AnyDuringMigration because: Type 'null' is not assignable to type
|
|
878
|
+
// 'ConstantProvider'.
|
|
879
|
+
this.constants_ = null as AnyDuringMigration;
|
|
929
880
|
}
|
|
930
881
|
|
|
931
882
|
/**
|
|
@@ -933,13 +884,13 @@ class Field {
|
|
|
933
884
|
* rerender this field and adjust for any sizing changes.
|
|
934
885
|
* Other fields on the same block will not rerender, because their sizes have
|
|
935
886
|
* already been recorded.
|
|
936
|
-
* @
|
|
887
|
+
* @internal
|
|
937
888
|
*/
|
|
938
889
|
forceRerender() {
|
|
939
890
|
this.isDirty_ = true;
|
|
940
891
|
if (this.sourceBlock_ && this.sourceBlock_.rendered) {
|
|
941
|
-
this.sourceBlock_.render();
|
|
942
|
-
this.sourceBlock_.bumpNeighbours();
|
|
892
|
+
(this.sourceBlock_ as BlockSvg).render();
|
|
893
|
+
(this.sourceBlock_ as BlockSvg).bumpNeighbours();
|
|
943
894
|
this.updateMarkers_();
|
|
944
895
|
}
|
|
945
896
|
}
|
|
@@ -948,10 +899,10 @@ class Field {
|
|
|
948
899
|
* Used to change the value of the field. Handles validation and events.
|
|
949
900
|
* Subclasses should override doClassValidation_ and doValueUpdate_ rather
|
|
950
901
|
* than this method.
|
|
951
|
-
* @param
|
|
902
|
+
* @param newValue New value.
|
|
952
903
|
* @final
|
|
953
904
|
*/
|
|
954
|
-
setValue(newValue) {
|
|
905
|
+
setValue(newValue: AnyDuringMigration) {
|
|
955
906
|
const doLogging = false;
|
|
956
907
|
if (newValue === null) {
|
|
957
908
|
doLogging && console.log('null, return');
|
|
@@ -992,8 +943,8 @@ class Field {
|
|
|
992
943
|
|
|
993
944
|
this.doValueUpdate_(newValue);
|
|
994
945
|
if (source && eventUtils.isEnabled()) {
|
|
995
|
-
eventUtils.fire(new (eventUtils.get(eventUtils.BLOCK_CHANGE))
|
|
996
|
-
|
|
946
|
+
eventUtils.fire(new (eventUtils.get(eventUtils.BLOCK_CHANGE))!
|
|
947
|
+
(source, 'field', this.name || null, oldValue, newValue));
|
|
997
948
|
}
|
|
998
949
|
if (this.isDirty_) {
|
|
999
950
|
this.forceRerender();
|
|
@@ -1003,12 +954,13 @@ class Field {
|
|
|
1003
954
|
|
|
1004
955
|
/**
|
|
1005
956
|
* Process the result of validation.
|
|
1006
|
-
* @param
|
|
1007
|
-
* @param
|
|
1008
|
-
* @return
|
|
1009
|
-
* @private
|
|
957
|
+
* @param newValue New value.
|
|
958
|
+
* @param validatedValue Validated value.
|
|
959
|
+
* @return New value, or an Error object.
|
|
1010
960
|
*/
|
|
1011
|
-
processValidation_(
|
|
961
|
+
private processValidation_(
|
|
962
|
+
newValue: AnyDuringMigration,
|
|
963
|
+
validatedValue: AnyDuringMigration): AnyDuringMigration {
|
|
1012
964
|
if (validatedValue === null) {
|
|
1013
965
|
this.doValueInvalid_(newValue);
|
|
1014
966
|
if (this.isDirty_) {
|
|
@@ -1024,20 +976,20 @@ class Field {
|
|
|
1024
976
|
|
|
1025
977
|
/**
|
|
1026
978
|
* Get the current value of the field.
|
|
1027
|
-
* @return
|
|
979
|
+
* @return Current value.
|
|
1028
980
|
*/
|
|
1029
|
-
getValue() {
|
|
981
|
+
getValue(): AnyDuringMigration {
|
|
1030
982
|
return this.value_;
|
|
1031
983
|
}
|
|
1032
984
|
|
|
1033
985
|
/**
|
|
1034
986
|
* Used to validate a value. Returns input by default. Can be overridden by
|
|
1035
987
|
* subclasses, see FieldDropdown.
|
|
1036
|
-
* @param
|
|
1037
|
-
* @return
|
|
1038
|
-
* @protected
|
|
988
|
+
* @param opt_newValue The value to be validated.
|
|
989
|
+
* @return The validated value, same as input by default.
|
|
1039
990
|
*/
|
|
1040
|
-
doClassValidation_(opt_newValue)
|
|
991
|
+
protected doClassValidation_(opt_newValue?: AnyDuringMigration):
|
|
992
|
+
AnyDuringMigration {
|
|
1041
993
|
if (opt_newValue === null || opt_newValue === undefined) {
|
|
1042
994
|
return null;
|
|
1043
995
|
}
|
|
@@ -1047,10 +999,9 @@ class Field {
|
|
|
1047
999
|
/**
|
|
1048
1000
|
* Used to update the value of a field. Can be overridden by subclasses to do
|
|
1049
1001
|
* custom storage of values/updating of external things.
|
|
1050
|
-
* @param
|
|
1051
|
-
* @protected
|
|
1002
|
+
* @param newValue The value to be saved.
|
|
1052
1003
|
*/
|
|
1053
|
-
doValueUpdate_(newValue) {
|
|
1004
|
+
protected doValueUpdate_(newValue: AnyDuringMigration) {
|
|
1054
1005
|
this.value_ = newValue;
|
|
1055
1006
|
this.isDirty_ = true;
|
|
1056
1007
|
}
|
|
@@ -1059,25 +1010,20 @@ class Field {
|
|
|
1059
1010
|
* Used to notify the field an invalid value was input. Can be overridden by
|
|
1060
1011
|
* subclasses, see FieldTextInput.
|
|
1061
1012
|
* No-op by default.
|
|
1062
|
-
* @param
|
|
1063
|
-
* @protected
|
|
1013
|
+
* @param _invalidValue The input value that was determined to be invalid.
|
|
1064
1014
|
*/
|
|
1065
|
-
doValueInvalid_(_invalidValue) {
|
|
1066
|
-
|
|
1067
|
-
}
|
|
1015
|
+
protected doValueInvalid_(_invalidValue: AnyDuringMigration) {}
|
|
1016
|
+
// NOP
|
|
1068
1017
|
|
|
1069
1018
|
/**
|
|
1070
1019
|
* Handle a mouse down event on a field.
|
|
1071
|
-
* @param
|
|
1072
|
-
* @protected
|
|
1020
|
+
* @param e Mouse down event.
|
|
1073
1021
|
*/
|
|
1074
|
-
onMouseDown_(e) {
|
|
1075
|
-
if (!this.sourceBlock_ ||
|
|
1022
|
+
protected onMouseDown_(e: Event) {
|
|
1023
|
+
if (!this.sourceBlock_ || this.sourceBlock_.disposed) {
|
|
1076
1024
|
return;
|
|
1077
1025
|
}
|
|
1078
|
-
const gesture =
|
|
1079
|
-
/** @type {!WorkspaceSvg} */ (this.sourceBlock_.workspace)
|
|
1080
|
-
.getGesture(e);
|
|
1026
|
+
const gesture = (this.sourceBlock_.workspace as WorkspaceSvg).getGesture(e);
|
|
1081
1027
|
if (gesture) {
|
|
1082
1028
|
gesture.setStartField(this);
|
|
1083
1029
|
}
|
|
@@ -1085,18 +1031,18 @@ class Field {
|
|
|
1085
1031
|
|
|
1086
1032
|
/**
|
|
1087
1033
|
* Sets the tooltip for this field.
|
|
1088
|
-
* @param
|
|
1089
|
-
*
|
|
1090
|
-
*
|
|
1091
|
-
*
|
|
1034
|
+
* @param newTip The text for the tooltip, a function that returns the text
|
|
1035
|
+
* for the tooltip, a parent object whose tooltip will be used, or null to
|
|
1036
|
+
* display the tooltip of the parent block. To not display a tooltip pass
|
|
1037
|
+
* the empty string.
|
|
1092
1038
|
*/
|
|
1093
|
-
setTooltip(newTip) {
|
|
1039
|
+
setTooltip(newTip: Tooltip.TipInfo|null) {
|
|
1094
1040
|
if (!newTip && newTip !== '') { // If null or undefined.
|
|
1095
1041
|
newTip = this.sourceBlock_;
|
|
1096
1042
|
}
|
|
1097
1043
|
const clickTarget = this.getClickTarget_();
|
|
1098
1044
|
if (clickTarget) {
|
|
1099
|
-
clickTarget.tooltip = newTip;
|
|
1045
|
+
(clickTarget as AnyDuringMigration).tooltip = newTip;
|
|
1100
1046
|
} else {
|
|
1101
1047
|
// Field has not been initialized yet.
|
|
1102
1048
|
this.tooltip_ = newTip;
|
|
@@ -1105,9 +1051,9 @@ class Field {
|
|
|
1105
1051
|
|
|
1106
1052
|
/**
|
|
1107
1053
|
* Returns the tooltip text for this field.
|
|
1108
|
-
* @return
|
|
1054
|
+
* @return The tooltip text for this field.
|
|
1109
1055
|
*/
|
|
1110
|
-
getTooltip() {
|
|
1056
|
+
getTooltip(): string {
|
|
1111
1057
|
const clickTarget = this.getClickTarget_();
|
|
1112
1058
|
if (clickTarget) {
|
|
1113
1059
|
return Tooltip.getTooltipOfObject(clickTarget);
|
|
@@ -1120,51 +1066,47 @@ class Field {
|
|
|
1120
1066
|
* The element to bind the click handler to. If not set explicitly, defaults
|
|
1121
1067
|
* to the SVG root of the field. When this element is
|
|
1122
1068
|
* clicked on an editable field, the editor will open.
|
|
1123
|
-
* @return
|
|
1124
|
-
* @protected
|
|
1069
|
+
* @return Element to bind click handler to.
|
|
1125
1070
|
*/
|
|
1126
|
-
getClickTarget_() {
|
|
1071
|
+
protected getClickTarget_(): Element {
|
|
1127
1072
|
return this.clickTarget_ || this.getSvgRoot();
|
|
1128
1073
|
}
|
|
1129
1074
|
|
|
1130
1075
|
/**
|
|
1131
1076
|
* Return the absolute coordinates of the top-left corner of this field.
|
|
1132
1077
|
* The origin (0,0) is the top-left corner of the page body.
|
|
1133
|
-
* @return
|
|
1134
|
-
* @protected
|
|
1078
|
+
* @return Object with .x and .y properties.
|
|
1135
1079
|
*/
|
|
1136
|
-
getAbsoluteXY_() {
|
|
1137
|
-
return style.getPageOffset(
|
|
1138
|
-
/** @type {!SVGRectElement} */ (this.getClickTarget_()));
|
|
1080
|
+
protected getAbsoluteXY_(): Coordinate {
|
|
1081
|
+
return style.getPageOffset(this.getClickTarget_() as SVGRectElement);
|
|
1139
1082
|
}
|
|
1140
1083
|
|
|
1141
1084
|
/**
|
|
1142
1085
|
* Whether this field references any Blockly variables. If true it may need
|
|
1143
1086
|
* to be handled differently during serialization and deserialization.
|
|
1144
1087
|
* Subclasses may override this.
|
|
1145
|
-
* @return
|
|
1146
|
-
* @
|
|
1088
|
+
* @return True if this field has any variable references.
|
|
1089
|
+
* @internal
|
|
1147
1090
|
*/
|
|
1148
|
-
referencesVariables() {
|
|
1091
|
+
referencesVariables(): boolean {
|
|
1149
1092
|
return false;
|
|
1150
1093
|
}
|
|
1151
1094
|
|
|
1152
1095
|
/**
|
|
1153
1096
|
* Refresh the variable name referenced by this field if this field references
|
|
1154
1097
|
* variables.
|
|
1155
|
-
* @
|
|
1098
|
+
* @internal
|
|
1156
1099
|
*/
|
|
1157
|
-
refreshVariableName() {
|
|
1158
|
-
|
|
1159
|
-
}
|
|
1100
|
+
refreshVariableName() {}
|
|
1101
|
+
// NOP
|
|
1160
1102
|
|
|
1161
1103
|
/**
|
|
1162
1104
|
* Search through the list of inputs and their fields in order to find the
|
|
1163
1105
|
* parent input of a field.
|
|
1164
|
-
* @return
|
|
1165
|
-
* @
|
|
1106
|
+
* @return The input that the field belongs to.
|
|
1107
|
+
* @internal
|
|
1166
1108
|
*/
|
|
1167
|
-
getParentInput() {
|
|
1109
|
+
getParentInput(): Input {
|
|
1168
1110
|
let parentInput = null;
|
|
1169
1111
|
const block = this.sourceBlock_;
|
|
1170
1112
|
const inputs = block.inputList;
|
|
@@ -1179,45 +1121,46 @@ class Field {
|
|
|
1179
1121
|
}
|
|
1180
1122
|
}
|
|
1181
1123
|
}
|
|
1182
|
-
|
|
1124
|
+
// AnyDuringMigration because: Type 'Input | null' is not assignable to
|
|
1125
|
+
// type 'Input'.
|
|
1126
|
+
return parentInput as AnyDuringMigration;
|
|
1183
1127
|
}
|
|
1184
1128
|
|
|
1185
1129
|
/**
|
|
1186
1130
|
* Returns whether or not we should flip the field in RTL.
|
|
1187
|
-
* @return
|
|
1131
|
+
* @return True if we should flip in RTL.
|
|
1188
1132
|
*/
|
|
1189
|
-
getFlipRtl() {
|
|
1133
|
+
getFlipRtl(): boolean {
|
|
1190
1134
|
return false;
|
|
1191
1135
|
}
|
|
1192
1136
|
|
|
1193
1137
|
/**
|
|
1194
1138
|
* Returns whether or not the field is tab navigable.
|
|
1195
|
-
* @return
|
|
1139
|
+
* @return True if the field is tab navigable.
|
|
1196
1140
|
*/
|
|
1197
|
-
isTabNavigable() {
|
|
1141
|
+
isTabNavigable(): boolean {
|
|
1198
1142
|
return false;
|
|
1199
1143
|
}
|
|
1200
1144
|
|
|
1201
1145
|
/**
|
|
1202
1146
|
* Handles the given keyboard shortcut.
|
|
1203
|
-
* @param
|
|
1204
|
-
*
|
|
1205
|
-
* @return {boolean} True if the shortcut has been handled, false otherwise.
|
|
1206
|
-
* @public
|
|
1147
|
+
* @param _shortcut The shortcut to be handled.
|
|
1148
|
+
* @return True if the shortcut has been handled, false otherwise.
|
|
1207
1149
|
*/
|
|
1208
|
-
onShortcut(_shortcut) {
|
|
1150
|
+
onShortcut(_shortcut: KeyboardShortcut): boolean {
|
|
1209
1151
|
return false;
|
|
1210
1152
|
}
|
|
1211
1153
|
|
|
1212
1154
|
/**
|
|
1213
1155
|
* Add the cursor SVG to this fields SVG group.
|
|
1214
|
-
* @param
|
|
1215
|
-
*
|
|
1216
|
-
* @package
|
|
1156
|
+
* @param cursorSvg The SVG root of the cursor to be added to the field group.
|
|
1157
|
+
* @internal
|
|
1217
1158
|
*/
|
|
1218
|
-
setCursorSvg(cursorSvg) {
|
|
1159
|
+
setCursorSvg(cursorSvg: SVGElement) {
|
|
1219
1160
|
if (!cursorSvg) {
|
|
1220
|
-
|
|
1161
|
+
// AnyDuringMigration because: Type 'null' is not assignable to type
|
|
1162
|
+
// 'SVGElement'.
|
|
1163
|
+
this.cursorSvg_ = null as AnyDuringMigration;
|
|
1221
1164
|
return;
|
|
1222
1165
|
}
|
|
1223
1166
|
|
|
@@ -1227,13 +1170,14 @@ class Field {
|
|
|
1227
1170
|
|
|
1228
1171
|
/**
|
|
1229
1172
|
* Add the marker SVG to this fields SVG group.
|
|
1230
|
-
* @param
|
|
1231
|
-
*
|
|
1232
|
-
* @package
|
|
1173
|
+
* @param markerSvg The SVG root of the marker to be added to the field group.
|
|
1174
|
+
* @internal
|
|
1233
1175
|
*/
|
|
1234
|
-
setMarkerSvg(markerSvg) {
|
|
1176
|
+
setMarkerSvg(markerSvg: SVGElement) {
|
|
1235
1177
|
if (!markerSvg) {
|
|
1236
|
-
|
|
1178
|
+
// AnyDuringMigration because: Type 'null' is not assignable to type
|
|
1179
|
+
// 'SVGElement'.
|
|
1180
|
+
this.markerSvg_ = null as AnyDuringMigration;
|
|
1237
1181
|
return;
|
|
1238
1182
|
}
|
|
1239
1183
|
|
|
@@ -1241,42 +1185,22 @@ class Field {
|
|
|
1241
1185
|
this.markerSvg_ = markerSvg;
|
|
1242
1186
|
}
|
|
1243
1187
|
|
|
1244
|
-
/**
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
*/
|
|
1248
|
-
updateMarkers_() {
|
|
1249
|
-
const workspace =
|
|
1250
|
-
/** @type {!WorkspaceSvg} */ (this.sourceBlock_.workspace);
|
|
1188
|
+
/** Redraw any attached marker or cursor svgs if needed. */
|
|
1189
|
+
protected updateMarkers_() {
|
|
1190
|
+
const workspace = this.sourceBlock_.workspace as WorkspaceSvg;
|
|
1251
1191
|
if (workspace.keyboardAccessibilityMode && this.cursorSvg_) {
|
|
1252
|
-
workspace.getCursor()
|
|
1192
|
+
workspace.getCursor()!.draw();
|
|
1253
1193
|
}
|
|
1254
1194
|
if (workspace.keyboardAccessibilityMode && this.markerSvg_) {
|
|
1255
1195
|
// TODO(#4592): Update all markers on the field.
|
|
1256
|
-
workspace.getMarker(MarkerManager.LOCAL_MARKER)
|
|
1196
|
+
workspace.getMarker(MarkerManager.LOCAL_MARKER)!.draw();
|
|
1257
1197
|
}
|
|
1258
1198
|
}
|
|
1259
1199
|
}
|
|
1260
1200
|
|
|
1261
1201
|
/**
|
|
1262
|
-
*
|
|
1263
|
-
* @type {*}
|
|
1264
|
-
* @protected
|
|
1202
|
+
* Extra configuration options for the base field.
|
|
1265
1203
|
*/
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
* Non-breaking space.
|
|
1270
|
-
* @const
|
|
1271
|
-
*/
|
|
1272
|
-
Field.NBSP = '\u00A0';
|
|
1273
|
-
|
|
1274
|
-
/**
|
|
1275
|
-
* A value used to signal when a field's constructor should *not* set the
|
|
1276
|
-
* field's value or run configure_, and should allow a subclass to do that
|
|
1277
|
-
* instead.
|
|
1278
|
-
* @const
|
|
1279
|
-
*/
|
|
1280
|
-
Field.SKIP_SETUP = new Sentinel();
|
|
1281
|
-
|
|
1282
|
-
exports.Field = Field;
|
|
1204
|
+
export interface FieldConfig {
|
|
1205
|
+
tooltip?: string;
|
|
1206
|
+
}
|