nodeskini 1.0.0 → 1.0.2
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/blocklySkini/archive/blocklyControleur.js +87 -0
- package/blocklySkini/archive/blocklySkini.js +84 -0
- package/blocklySkini/archive/blocklyhop.js +75 -0
- package/blocklySkini/archive/clientControleurBlocly.js +170 -0
- package/blocklySkini/archive/index.html +76 -0
- package/blocklySkini/archive/testHHsuspend.txt +89 -0
- package/blocklySkini/archive/testHHtrap.txt +262 -0
- package/blocklySkini/archive/testOrchestration.txt +177 -0
- package/blocklySkini/archive/testOrchestration.xml +447 -0
- package/blocklySkini/archive/testOrchestration2.xml +456 -0
- package/blocklySkini/blockly/README.md +77 -0
- package/blocklySkini/blockly/blockly.d.ts +21480 -0
- package/blocklySkini/blockly/blockly.js +25 -0
- package/blocklySkini/blockly/blockly.min.js +2188 -0
- package/blocklySkini/blockly/blockly_compressed.js +1455 -0
- package/blocklySkini/blockly/blockly_compressed.js.map +1 -0
- package/blocklySkini/blockly/blocks/colour.js +122 -0
- package/blocklySkini/blockly/blocks/lists.js +862 -0
- package/blocklySkini/blockly/blocks/logic.js +635 -0
- package/blocklySkini/blockly/blocks/loops.js +357 -0
- package/blocklySkini/blockly/blocks/math.js +566 -0
- package/blocklySkini/blockly/blocks/procedures.js +1072 -0
- package/blocklySkini/blockly/blocks/text.js +923 -0
- package/blocklySkini/blockly/blocks/variables.js +163 -0
- package/blocklySkini/blockly/blocks/variables_dynamic.js +180 -0
- package/blocklySkini/blockly/blocks.d.ts +15 -0
- package/blocklySkini/blockly/blocks.js +27 -0
- package/blocklySkini/blockly/blocks_compressed.js +182 -0
- package/blocklySkini/blockly/blocks_compressed.js.map +1 -0
- package/blocklySkini/blockly/browser.js +36 -0
- package/blocklySkini/blockly/core/block.js +2010 -0
- package/blocklySkini/blockly/core/block_animations.js +203 -0
- package/blocklySkini/blockly/core/block_drag_surface.js +212 -0
- package/blocklySkini/blockly/core/block_dragger.js +378 -0
- package/blocklySkini/blockly/core/block_events.js +548 -0
- package/blocklySkini/blockly/core/block_svg.js +1763 -0
- package/blocklySkini/blockly/core/blockly.js +674 -0
- package/blocklySkini/blockly/core/blocks.js +23 -0
- package/blocklySkini/blockly/core/bubble.js +880 -0
- package/blocklySkini/blockly/core/bubble_dragger.js +274 -0
- package/blocklySkini/blockly/core/comment.js +439 -0
- package/blocklySkini/blockly/core/components/component.js +554 -0
- package/blocklySkini/blockly/core/components/tree/basenode.js +895 -0
- package/blocklySkini/blockly/core/components/tree/treecontrol.js +332 -0
- package/blocklySkini/blockly/core/components/tree/treenode.js +172 -0
- package/blocklySkini/blockly/core/connection.js +682 -0
- package/blocklySkini/blockly/core/connection_checker.js +285 -0
- package/blocklySkini/blockly/core/connection_db.js +295 -0
- package/blocklySkini/blockly/core/constants.js +277 -0
- package/blocklySkini/blockly/core/contextmenu.js +307 -0
- package/blocklySkini/blockly/core/contextmenu_items.js +534 -0
- package/blocklySkini/blockly/core/contextmenu_registry.js +165 -0
- package/blocklySkini/blockly/core/css.js +549 -0
- package/blocklySkini/blockly/core/dropdowndiv.js +776 -0
- package/blocklySkini/blockly/core/events.js +387 -0
- package/blocklySkini/blockly/core/events_abstract.js +106 -0
- package/blocklySkini/blockly/core/extensions.js +450 -0
- package/blocklySkini/blockly/core/field.js +1162 -0
- package/blocklySkini/blockly/core/field_angle.js +562 -0
- package/blocklySkini/blockly/core/field_checkbox.js +220 -0
- package/blocklySkini/blockly/core/field_colour.js +664 -0
- package/blocklySkini/blockly/core/field_dropdown.js +760 -0
- package/blocklySkini/blockly/core/field_image.js +286 -0
- package/blocklySkini/blockly/core/field_label.js +130 -0
- package/blocklySkini/blockly/core/field_label_serializable.js +69 -0
- package/blocklySkini/blockly/core/field_multilineinput.js +299 -0
- package/blocklySkini/blockly/core/field_number.js +317 -0
- package/blocklySkini/blockly/core/field_registry.js +66 -0
- package/blocklySkini/blockly/core/field_textinput.js +616 -0
- package/blocklySkini/blockly/core/field_variable.js +463 -0
- package/blocklySkini/blockly/core/flyout_base.js +1071 -0
- package/blocklySkini/blockly/core/flyout_button.js +325 -0
- package/blocklySkini/blockly/core/flyout_dragger.js +76 -0
- package/blocklySkini/blockly/core/flyout_horizontal.js +388 -0
- package/blocklySkini/blockly/core/flyout_vertical.js +397 -0
- package/blocklySkini/blockly/core/generator.js +482 -0
- package/blocklySkini/blockly/core/gesture.js +993 -0
- package/blocklySkini/blockly/core/grid.js +222 -0
- package/blocklySkini/blockly/core/icon.js +206 -0
- package/blocklySkini/blockly/core/inject.js +487 -0
- package/blocklySkini/blockly/core/input.js +296 -0
- package/blocklySkini/blockly/core/insertion_marker_manager.js +700 -0
- package/blocklySkini/blockly/core/interfaces/i_accessibility.js +72 -0
- package/blocklySkini/blockly/core/interfaces/i_bounded_element.js +31 -0
- package/blocklySkini/blockly/core/interfaces/i_bubble.js +83 -0
- package/blocklySkini/blockly/core/interfaces/i_connection_checker.js +94 -0
- package/blocklySkini/blockly/core/interfaces/i_contextmenu.js +26 -0
- package/blocklySkini/blockly/core/interfaces/i_copyable.js +40 -0
- package/blocklySkini/blockly/core/interfaces/i_deletable.js +27 -0
- package/blocklySkini/blockly/core/interfaces/i_deletearea.js +28 -0
- package/blocklySkini/blockly/core/interfaces/i_flyout.js +178 -0
- package/blocklySkini/blockly/core/interfaces/i_movable.js +27 -0
- package/blocklySkini/blockly/core/interfaces/i_registrable.js +22 -0
- package/blocklySkini/blockly/core/interfaces/i_registrable_field.js +31 -0
- package/blocklySkini/blockly/core/interfaces/i_selectable.js +43 -0
- package/blocklySkini/blockly/core/interfaces/i_styleable.js +33 -0
- package/blocklySkini/blockly/core/interfaces/i_toolbox.js +131 -0
- package/blocklySkini/blockly/core/interfaces/i_toolbox_item.js +148 -0
- package/blocklySkini/blockly/core/keyboard_nav/action.js +26 -0
- package/blocklySkini/blockly/core/keyboard_nav/ast_node.js +684 -0
- package/blocklySkini/blockly/core/keyboard_nav/basic_cursor.js +208 -0
- package/blocklySkini/blockly/core/keyboard_nav/cursor.js +170 -0
- package/blocklySkini/blockly/core/keyboard_nav/flyout_cursor.js +106 -0
- package/blocklySkini/blockly/core/keyboard_nav/key_map.js +190 -0
- package/blocklySkini/blockly/core/keyboard_nav/marker.js +120 -0
- package/blocklySkini/blockly/core/keyboard_nav/navigation.js +1084 -0
- package/blocklySkini/blockly/core/keyboard_nav/tab_navigate_cursor.js +48 -0
- package/blocklySkini/blockly/core/marker_manager.js +183 -0
- package/blocklySkini/blockly/core/menu.js +465 -0
- package/blocklySkini/blockly/core/menuitem.js +280 -0
- package/blocklySkini/blockly/core/msg.js +31 -0
- package/blocklySkini/blockly/core/mutator.js +555 -0
- package/blocklySkini/blockly/core/names.js +186 -0
- package/blocklySkini/blockly/core/options.js +365 -0
- package/blocklySkini/blockly/core/procedures.js +404 -0
- package/blocklySkini/blockly/core/registry.js +265 -0
- package/blocklySkini/blockly/core/rendered_connection.js +565 -0
- package/blocklySkini/blockly/core/renderers/common/block_rendering.js +81 -0
- package/blocklySkini/blockly/core/renderers/common/constants.js +1256 -0
- package/blocklySkini/blockly/core/renderers/common/debugger.js +431 -0
- package/blocklySkini/blockly/core/renderers/common/drawer.js +468 -0
- package/blocklySkini/blockly/core/renderers/common/i_path_object.js +151 -0
- package/blocklySkini/blockly/core/renderers/common/info.js +775 -0
- package/blocklySkini/blockly/core/renderers/common/marker_svg.js +687 -0
- package/blocklySkini/blockly/core/renderers/common/path_object.js +279 -0
- package/blocklySkini/blockly/core/renderers/common/renderer.js +301 -0
- package/blocklySkini/blockly/core/renderers/geras/constants.js +64 -0
- package/blocklySkini/blockly/core/renderers/geras/drawer.js +205 -0
- package/blocklySkini/blockly/core/renderers/geras/highlight_constants.js +311 -0
- package/blocklySkini/blockly/core/renderers/geras/highlighter.js +256 -0
- package/blocklySkini/blockly/core/renderers/geras/info.js +483 -0
- package/blocklySkini/blockly/core/renderers/geras/measurables/inputs.js +67 -0
- package/blocklySkini/blockly/core/renderers/geras/path_object.js +177 -0
- package/blocklySkini/blockly/core/renderers/geras/renderer.js +138 -0
- package/blocklySkini/blockly/core/renderers/measurables/base.js +44 -0
- package/blocklySkini/blockly/core/renderers/measurables/connections.js +114 -0
- package/blocklySkini/blockly/core/renderers/measurables/inputs.js +160 -0
- package/blocklySkini/blockly/core/renderers/measurables/row_elements.js +185 -0
- package/blocklySkini/blockly/core/renderers/measurables/rows.js +532 -0
- package/blocklySkini/blockly/core/renderers/measurables/types.js +349 -0
- package/blocklySkini/blockly/core/renderers/minimalist/constants.js +29 -0
- package/blocklySkini/blockly/core/renderers/minimalist/drawer.js +32 -0
- package/blocklySkini/blockly/core/renderers/minimalist/info.js +45 -0
- package/blocklySkini/blockly/core/renderers/minimalist/renderer.js +70 -0
- package/blocklySkini/blockly/core/renderers/thrasos/info.js +338 -0
- package/blocklySkini/blockly/core/renderers/thrasos/renderer.js +45 -0
- package/blocklySkini/blockly/core/renderers/zelos/constants.js +1002 -0
- package/blocklySkini/blockly/core/renderers/zelos/drawer.js +233 -0
- package/blocklySkini/blockly/core/renderers/zelos/info.js +587 -0
- package/blocklySkini/blockly/core/renderers/zelos/marker_svg.js +148 -0
- package/blocklySkini/blockly/core/renderers/zelos/measurables/inputs.js +47 -0
- package/blocklySkini/blockly/core/renderers/zelos/measurables/row_elements.js +37 -0
- package/blocklySkini/blockly/core/renderers/zelos/measurables/rows.js +108 -0
- package/blocklySkini/blockly/core/renderers/zelos/path_object.js +244 -0
- package/blocklySkini/blockly/core/renderers/zelos/renderer.js +130 -0
- package/blocklySkini/blockly/core/requires.js +84 -0
- package/blocklySkini/blockly/core/scrollbar.js +880 -0
- package/blocklySkini/blockly/core/theme/classic.js +87 -0
- package/blocklySkini/blockly/core/theme/dark.js +33 -0
- package/blocklySkini/blockly/core/theme/deuteranopia.js +104 -0
- package/blocklySkini/blockly/core/theme/highcontrast.js +119 -0
- package/blocklySkini/blockly/core/theme/modern.js +108 -0
- package/blocklySkini/blockly/core/theme/tritanopia.js +103 -0
- package/blocklySkini/blockly/core/theme/zelos.js +106 -0
- package/blocklySkini/blockly/core/theme.js +236 -0
- package/blocklySkini/blockly/core/theme_manager.js +197 -0
- package/blocklySkini/blockly/core/toolbox/category.js +690 -0
- package/blocklySkini/blockly/core/toolbox/collapsible_category.js +294 -0
- package/blocklySkini/blockly/core/toolbox/separator.js +123 -0
- package/blocklySkini/blockly/core/toolbox/toolbox.js +984 -0
- package/blocklySkini/blockly/core/toolbox/toolbox_item.js +145 -0
- package/blocklySkini/blockly/core/toolbox.js +943 -0
- package/blocklySkini/blockly/core/tooltip.js +387 -0
- package/blocklySkini/blockly/core/touch.js +255 -0
- package/blocklySkini/blockly/core/touch_gesture.js +325 -0
- package/blocklySkini/blockly/core/trashcan.js +661 -0
- package/blocklySkini/blockly/core/ui_events.js +85 -0
- package/blocklySkini/blockly/core/utils/aria.js +167 -0
- package/blocklySkini/blockly/core/utils/colour.js +208 -0
- package/blocklySkini/blockly/core/utils/coordinate.js +125 -0
- package/blocklySkini/blockly/core/utils/deprecation.js +34 -0
- package/blocklySkini/blockly/core/utils/dom.js +391 -0
- package/blocklySkini/blockly/core/utils/global.js +37 -0
- package/blocklySkini/blockly/core/utils/idgenerator.js +33 -0
- package/blocklySkini/blockly/core/utils/keycodes.js +164 -0
- package/blocklySkini/blockly/core/utils/math.js +56 -0
- package/blocklySkini/blockly/core/utils/metrics.js +124 -0
- package/blocklySkini/blockly/core/utils/object.js +73 -0
- package/blocklySkini/blockly/core/utils/rect.js +54 -0
- package/blocklySkini/blockly/core/utils/size.js +58 -0
- package/blocklySkini/blockly/core/utils/string.js +284 -0
- package/blocklySkini/blockly/core/utils/style.js +281 -0
- package/blocklySkini/blockly/core/utils/svg.js +181 -0
- package/blocklySkini/blockly/core/utils/svg_paths.js +142 -0
- package/blocklySkini/blockly/core/utils/toolbox.js +401 -0
- package/blocklySkini/blockly/core/utils/useragent.js +110 -0
- package/blocklySkini/blockly/core/utils/xml.js +79 -0
- package/blocklySkini/blockly/core/utils.js +652 -0
- package/blocklySkini/blockly/core/variable_events.js +248 -0
- package/blocklySkini/blockly/core/variable_map.js +414 -0
- package/blocklySkini/blockly/core/variable_model.js +95 -0
- package/blocklySkini/blockly/core/variables.js +571 -0
- package/blocklySkini/blockly/core/variables_dynamic.js +100 -0
- package/blocklySkini/blockly/core/warning.js +200 -0
- package/blocklySkini/blockly/core/widgetdiv.js +241 -0
- package/blocklySkini/blockly/core/workspace.js +786 -0
- package/blocklySkini/blockly/core/workspace_audio.js +153 -0
- package/blocklySkini/blockly/core/workspace_comment.js +373 -0
- package/blocklySkini/blockly/core/workspace_comment_render_svg.js +461 -0
- package/blocklySkini/blockly/core/workspace_comment_svg.js +701 -0
- package/blocklySkini/blockly/core/workspace_drag_surface_svg.js +176 -0
- package/blocklySkini/blockly/core/workspace_dragger.js +85 -0
- package/blocklySkini/blockly/core/workspace_events.js +93 -0
- package/blocklySkini/blockly/core/workspace_svg.js +2661 -0
- package/blocklySkini/blockly/core/ws_comment_events.js +417 -0
- package/blocklySkini/blockly/core/xml.js +827 -0
- package/blocklySkini/blockly/core/zoom_controls.js +449 -0
- package/blocklySkini/blockly/core-browser.js +34 -0
- package/blocklySkini/blockly/core.d.ts +15 -0
- package/blocklySkini/blockly/core.js +38 -0
- package/blocklySkini/blockly/dart.d.ts +15 -0
- package/blocklySkini/blockly/dart.js +27 -0
- package/blocklySkini/blockly/dart_compressed.js +114 -0
- package/blocklySkini/blockly/dart_compressed.js.map +1 -0
- package/blocklySkini/blockly/generators/dart/colour.js +114 -0
- package/blocklySkini/blockly/generators/dart/lists.js +447 -0
- package/blocklySkini/blockly/generators/dart/logic.js +127 -0
- package/blocklySkini/blockly/generators/dart/loops.js +169 -0
- package/blocklySkini/blockly/generators/dart/math.js +485 -0
- package/blocklySkini/blockly/generators/dart/procedures.js +111 -0
- package/blocklySkini/blockly/generators/dart/text.js +339 -0
- package/blocklySkini/blockly/generators/dart/variables.js +32 -0
- package/blocklySkini/blockly/generators/dart/variables_dynamic.js +21 -0
- package/blocklySkini/blockly/generators/dart.js +290 -0
- package/blocklySkini/blockly/generators/javascript/colour.js +89 -0
- package/blocklySkini/blockly/generators/javascript/lists.js +388 -0
- package/blocklySkini/blockly/generators/javascript/logic.js +129 -0
- package/blocklySkini/blockly/generators/javascript/loops.js +184 -0
- package/blocklySkini/blockly/generators/javascript/math.js +409 -0
- package/blocklySkini/blockly/generators/javascript/procedures.js +113 -0
- package/blocklySkini/blockly/generators/javascript/text.js +367 -0
- package/blocklySkini/blockly/generators/javascript/variables.js +32 -0
- package/blocklySkini/blockly/generators/javascript/variables_dynamic.js +23 -0
- package/blocklySkini/blockly/generators/javascript.js +317 -0
- package/blocklySkini/blockly/generators/lua/colour.js +76 -0
- package/blocklySkini/blockly/generators/lua/lists.js +368 -0
- package/blocklySkini/blockly/generators/lua/logic.js +127 -0
- package/blocklySkini/blockly/generators/lua/loops.js +173 -0
- package/blocklySkini/blockly/generators/lua/math.js +423 -0
- package/blocklySkini/blockly/generators/lua/procedures.js +113 -0
- package/blocklySkini/blockly/generators/lua/text.js +353 -0
- package/blocklySkini/blockly/generators/lua/variables.js +32 -0
- package/blocklySkini/blockly/generators/lua/variables_dynamic.js +21 -0
- package/blocklySkini/blockly/generators/lua.js +198 -0
- package/blocklySkini/blockly/generators/php/colour.js +91 -0
- package/blocklySkini/blockly/generators/php/lists.js +498 -0
- package/blocklySkini/blockly/generators/php/logic.js +128 -0
- package/blocklySkini/blockly/generators/php/loops.js +170 -0
- package/blocklySkini/blockly/generators/php/math.js +370 -0
- package/blocklySkini/blockly/generators/php/procedures.js +132 -0
- package/blocklySkini/blockly/generators/php/text.js +271 -0
- package/blocklySkini/blockly/generators/php/variables.js +32 -0
- package/blocklySkini/blockly/generators/php/variables_dynamic.js +21 -0
- package/blocklySkini/blockly/generators/php.js +318 -0
- package/blocklySkini/blockly/generators/python/colour.js +72 -0
- package/blocklySkini/blockly/generators/python/lists.js +349 -0
- package/blocklySkini/blockly/generators/python/logic.js +127 -0
- package/blocklySkini/blockly/generators/python/loops.js +214 -0
- package/blocklySkini/blockly/generators/python/math.js +385 -0
- package/blocklySkini/blockly/generators/python/procedures.js +134 -0
- package/blocklySkini/blockly/generators/python/text.js +293 -0
- package/blocklySkini/blockly/generators/python/variables.js +32 -0
- package/blocklySkini/blockly/generators/python/variables_dynamic.js +21 -0
- package/blocklySkini/blockly/generators/python.js +322 -0
- package/blocklySkini/blockly/index.d.ts +22 -0
- package/blocklySkini/blockly/index.js +24 -0
- package/blocklySkini/blockly/javascript.d.ts +15 -0
- package/blocklySkini/blockly/javascript.js +27 -0
- package/blocklySkini/blockly/javascript_compressed.js +115 -0
- package/blocklySkini/blockly/javascript_compressed.js.map +1 -0
- package/blocklySkini/blockly/lua.d.ts +15 -0
- package/blocklySkini/blockly/lua.js +27 -0
- package/blocklySkini/blockly/lua_compressed.js +94 -0
- package/blocklySkini/blockly/lua_compressed.js.map +1 -0
- package/blocklySkini/blockly/media/1x1.gif +0 -0
- package/blocklySkini/blockly/media/click.mp3 +0 -0
- package/blocklySkini/blockly/media/click.ogg +0 -0
- package/blocklySkini/blockly/media/click.wav +0 -0
- package/blocklySkini/blockly/media/delete.mp3 +0 -0
- package/blocklySkini/blockly/media/delete.ogg +0 -0
- package/blocklySkini/blockly/media/delete.wav +0 -0
- package/blocklySkini/blockly/media/disconnect.mp3 +0 -0
- package/blocklySkini/blockly/media/disconnect.ogg +0 -0
- package/blocklySkini/blockly/media/disconnect.wav +0 -0
- package/blocklySkini/blockly/media/dropdown-arrow.svg +1 -0
- package/blocklySkini/blockly/media/handclosed.cur +0 -0
- package/blocklySkini/blockly/media/handdelete.cur +0 -0
- package/blocklySkini/blockly/media/handopen.cur +0 -0
- package/blocklySkini/blockly/media/pilcrow.png +0 -0
- package/blocklySkini/blockly/media/quote0.png +0 -0
- package/blocklySkini/blockly/media/quote1.png +0 -0
- package/blocklySkini/blockly/media/sprites.png +0 -0
- package/blocklySkini/blockly/media/sprites.svg +74 -0
- package/blocklySkini/blockly/msg/ab.d.ts +16 -0
- package/blocklySkini/blockly/msg/ab.js +447 -0
- package/blocklySkini/blockly/msg/ar.d.ts +16 -0
- package/blocklySkini/blockly/msg/ar.js +447 -0
- package/blocklySkini/blockly/msg/az.d.ts +16 -0
- package/blocklySkini/blockly/msg/az.js +447 -0
- package/blocklySkini/blockly/msg/ba.d.ts +16 -0
- package/blocklySkini/blockly/msg/ba.js +447 -0
- package/blocklySkini/blockly/msg/bcc.d.ts +16 -0
- package/blocklySkini/blockly/msg/bcc.js +447 -0
- package/blocklySkini/blockly/msg/be-tarask.d.ts +16 -0
- package/blocklySkini/blockly/msg/be-tarask.js +447 -0
- package/blocklySkini/blockly/msg/be.d.ts +16 -0
- package/blocklySkini/blockly/msg/be.js +447 -0
- package/blocklySkini/blockly/msg/bg.d.ts +16 -0
- package/blocklySkini/blockly/msg/bg.js +447 -0
- package/blocklySkini/blockly/msg/bn.d.ts +16 -0
- package/blocklySkini/blockly/msg/bn.js +447 -0
- package/blocklySkini/blockly/msg/br.d.ts +16 -0
- package/blocklySkini/blockly/msg/br.js +447 -0
- package/blocklySkini/blockly/msg/ca.d.ts +16 -0
- package/blocklySkini/blockly/msg/ca.js +447 -0
- package/blocklySkini/blockly/msg/constants.d.ts +16 -0
- package/blocklySkini/blockly/msg/cs.d.ts +16 -0
- package/blocklySkini/blockly/msg/cs.js +447 -0
- package/blocklySkini/blockly/msg/da.d.ts +16 -0
- package/blocklySkini/blockly/msg/da.js +447 -0
- package/blocklySkini/blockly/msg/de.d.ts +16 -0
- package/blocklySkini/blockly/msg/de.js +447 -0
- package/blocklySkini/blockly/msg/diq.d.ts +16 -0
- package/blocklySkini/blockly/msg/diq.js +447 -0
- package/blocklySkini/blockly/msg/dty.d.ts +16 -0
- package/blocklySkini/blockly/msg/dty.js +447 -0
- package/blocklySkini/blockly/msg/ee.d.ts +16 -0
- package/blocklySkini/blockly/msg/ee.js +447 -0
- package/blocklySkini/blockly/msg/el.d.ts +16 -0
- package/blocklySkini/blockly/msg/el.js +447 -0
- package/blocklySkini/blockly/msg/en-gb.d.ts +16 -0
- package/blocklySkini/blockly/msg/en-gb.js +447 -0
- package/blocklySkini/blockly/msg/en.d.ts +16 -0
- package/blocklySkini/blockly/msg/en.js +447 -0
- package/blocklySkini/blockly/msg/eo.d.ts +16 -0
- package/blocklySkini/blockly/msg/eo.js +447 -0
- package/blocklySkini/blockly/msg/es.d.ts +16 -0
- package/blocklySkini/blockly/msg/es.js +447 -0
- package/blocklySkini/blockly/msg/et.d.ts +16 -0
- package/blocklySkini/blockly/msg/et.js +447 -0
- package/blocklySkini/blockly/msg/eu.d.ts +16 -0
- package/blocklySkini/blockly/msg/eu.js +447 -0
- package/blocklySkini/blockly/msg/fa.d.ts +16 -0
- package/blocklySkini/blockly/msg/fa.js +447 -0
- package/blocklySkini/blockly/msg/fi.d.ts +16 -0
- package/blocklySkini/blockly/msg/fi.js +447 -0
- package/blocklySkini/blockly/msg/fr.d.ts +16 -0
- package/blocklySkini/blockly/msg/fr.js +447 -0
- package/blocklySkini/blockly/msg/gl.d.ts +16 -0
- package/blocklySkini/blockly/msg/gl.js +447 -0
- package/blocklySkini/blockly/msg/gor.d.ts +16 -0
- package/blocklySkini/blockly/msg/gor.js +447 -0
- package/blocklySkini/blockly/msg/ha.d.ts +16 -0
- package/blocklySkini/blockly/msg/ha.js +447 -0
- package/blocklySkini/blockly/msg/he.d.ts +16 -0
- package/blocklySkini/blockly/msg/he.js +447 -0
- package/blocklySkini/blockly/msg/hi.d.ts +16 -0
- package/blocklySkini/blockly/msg/hi.js +447 -0
- package/blocklySkini/blockly/msg/hrx.d.ts +16 -0
- package/blocklySkini/blockly/msg/hrx.js +447 -0
- package/blocklySkini/blockly/msg/hu.d.ts +16 -0
- package/blocklySkini/blockly/msg/hu.js +447 -0
- package/blocklySkini/blockly/msg/hy.d.ts +16 -0
- package/blocklySkini/blockly/msg/hy.js +447 -0
- package/blocklySkini/blockly/msg/ia.d.ts +16 -0
- package/blocklySkini/blockly/msg/ia.js +447 -0
- package/blocklySkini/blockly/msg/id.d.ts +16 -0
- package/blocklySkini/blockly/msg/id.js +447 -0
- package/blocklySkini/blockly/msg/ig.d.ts +16 -0
- package/blocklySkini/blockly/msg/ig.js +447 -0
- package/blocklySkini/blockly/msg/is.d.ts +16 -0
- package/blocklySkini/blockly/msg/is.js +447 -0
- package/blocklySkini/blockly/msg/it.d.ts +16 -0
- package/blocklySkini/blockly/msg/it.js +447 -0
- package/blocklySkini/blockly/msg/ja.d.ts +16 -0
- package/blocklySkini/blockly/msg/ja.js +447 -0
- package/blocklySkini/blockly/msg/kab.d.ts +16 -0
- package/blocklySkini/blockly/msg/kab.js +447 -0
- package/blocklySkini/blockly/msg/kn.d.ts +16 -0
- package/blocklySkini/blockly/msg/kn.js +447 -0
- package/blocklySkini/blockly/msg/ko.d.ts +16 -0
- package/blocklySkini/blockly/msg/ko.js +447 -0
- package/blocklySkini/blockly/msg/lb.d.ts +16 -0
- package/blocklySkini/blockly/msg/lb.js +447 -0
- package/blocklySkini/blockly/msg/lki.d.ts +16 -0
- package/blocklySkini/blockly/msg/lki.js +447 -0
- package/blocklySkini/blockly/msg/lo.d.ts +16 -0
- package/blocklySkini/blockly/msg/lo.js +447 -0
- package/blocklySkini/blockly/msg/lrc.d.ts +16 -0
- package/blocklySkini/blockly/msg/lrc.js +447 -0
- package/blocklySkini/blockly/msg/lt.d.ts +16 -0
- package/blocklySkini/blockly/msg/lt.js +447 -0
- package/blocklySkini/blockly/msg/lv.d.ts +16 -0
- package/blocklySkini/blockly/msg/lv.js +447 -0
- package/blocklySkini/blockly/msg/mk.d.ts +16 -0
- package/blocklySkini/blockly/msg/mk.js +447 -0
- package/blocklySkini/blockly/msg/mnw.d.ts +16 -0
- package/blocklySkini/blockly/msg/mnw.js +447 -0
- package/blocklySkini/blockly/msg/ms.d.ts +16 -0
- package/blocklySkini/blockly/msg/ms.js +447 -0
- package/blocklySkini/blockly/msg/msg.d.ts +444 -0
- package/blocklySkini/blockly/msg/nb.d.ts +16 -0
- package/blocklySkini/blockly/msg/nb.js +447 -0
- package/blocklySkini/blockly/msg/nl.d.ts +16 -0
- package/blocklySkini/blockly/msg/nl.js +447 -0
- package/blocklySkini/blockly/msg/oc.d.ts +16 -0
- package/blocklySkini/blockly/msg/oc.js +447 -0
- package/blocklySkini/blockly/msg/pl.d.ts +16 -0
- package/blocklySkini/blockly/msg/pl.js +447 -0
- package/blocklySkini/blockly/msg/pms.d.ts +16 -0
- package/blocklySkini/blockly/msg/pms.js +447 -0
- package/blocklySkini/blockly/msg/pt-br.d.ts +16 -0
- package/blocklySkini/blockly/msg/pt-br.js +447 -0
- package/blocklySkini/blockly/msg/pt.d.ts +16 -0
- package/blocklySkini/blockly/msg/pt.js +447 -0
- package/blocklySkini/blockly/msg/qqq.d.ts +16 -0
- package/blocklySkini/blockly/msg/ro.d.ts +16 -0
- package/blocklySkini/blockly/msg/ro.js +447 -0
- package/blocklySkini/blockly/msg/ru.d.ts +16 -0
- package/blocklySkini/blockly/msg/ru.js +447 -0
- package/blocklySkini/blockly/msg/sc.d.ts +16 -0
- package/blocklySkini/blockly/msg/sc.js +447 -0
- package/blocklySkini/blockly/msg/sd.d.ts +16 -0
- package/blocklySkini/blockly/msg/sd.js +447 -0
- package/blocklySkini/blockly/msg/shn.d.ts +16 -0
- package/blocklySkini/blockly/msg/shn.js +447 -0
- package/blocklySkini/blockly/msg/sk.d.ts +16 -0
- package/blocklySkini/blockly/msg/sk.js +447 -0
- package/blocklySkini/blockly/msg/skr-arab.d.ts +16 -0
- package/blocklySkini/blockly/msg/skr-arab.js +447 -0
- package/blocklySkini/blockly/msg/sl.d.ts +16 -0
- package/blocklySkini/blockly/msg/sl.js +447 -0
- package/blocklySkini/blockly/msg/sq.d.ts +16 -0
- package/blocklySkini/blockly/msg/sq.js +447 -0
- package/blocklySkini/blockly/msg/sr-latn.d.ts +16 -0
- package/blocklySkini/blockly/msg/sr-latn.js +447 -0
- package/blocklySkini/blockly/msg/sr.d.ts +16 -0
- package/blocklySkini/blockly/msg/sr.js +447 -0
- package/blocklySkini/blockly/msg/sv.d.ts +16 -0
- package/blocklySkini/blockly/msg/sv.js +447 -0
- package/blocklySkini/blockly/msg/synonyms.d.ts +16 -0
- package/blocklySkini/blockly/msg/ta.d.ts +16 -0
- package/blocklySkini/blockly/msg/ta.js +447 -0
- package/blocklySkini/blockly/msg/tcy.d.ts +16 -0
- package/blocklySkini/blockly/msg/tcy.js +447 -0
- package/blocklySkini/blockly/msg/te.d.ts +16 -0
- package/blocklySkini/blockly/msg/te.js +447 -0
- package/blocklySkini/blockly/msg/th.d.ts +16 -0
- package/blocklySkini/blockly/msg/th.js +447 -0
- package/blocklySkini/blockly/msg/tl.d.ts +16 -0
- package/blocklySkini/blockly/msg/tl.js +447 -0
- package/blocklySkini/blockly/msg/tlh.d.ts +16 -0
- package/blocklySkini/blockly/msg/tlh.js +447 -0
- package/blocklySkini/blockly/msg/tr.d.ts +16 -0
- package/blocklySkini/blockly/msg/tr.js +447 -0
- package/blocklySkini/blockly/msg/ug-arab.d.ts +16 -0
- package/blocklySkini/blockly/msg/ug-arab.js +447 -0
- package/blocklySkini/blockly/msg/uk.d.ts +16 -0
- package/blocklySkini/blockly/msg/uk.js +447 -0
- package/blocklySkini/blockly/msg/ur.d.ts +16 -0
- package/blocklySkini/blockly/msg/ur.js +447 -0
- package/blocklySkini/blockly/msg/vi.d.ts +16 -0
- package/blocklySkini/blockly/msg/vi.js +447 -0
- package/blocklySkini/blockly/msg/xmf.d.ts +16 -0
- package/blocklySkini/blockly/msg/xmf.js +447 -0
- package/blocklySkini/blockly/msg/yo.d.ts +16 -0
- package/blocklySkini/blockly/msg/yo.js +447 -0
- package/blocklySkini/blockly/msg/zh-hans.d.ts +16 -0
- package/blocklySkini/blockly/msg/zh-hans.js +447 -0
- package/blocklySkini/blockly/msg/zh-hant.d.ts +16 -0
- package/blocklySkini/blockly/msg/zh-hant.js +447 -0
- package/blocklySkini/blockly/node.js +35 -0
- package/blocklySkini/blockly/package.json +84 -0
- package/blocklySkini/blockly/php.d.ts +15 -0
- package/blocklySkini/blockly/php.js +27 -0
- package/blocklySkini/blockly/php_compressed.js +103 -0
- package/blocklySkini/blockly/php_compressed.js.map +1 -0
- package/blocklySkini/blockly/python.d.ts +15 -0
- package/blocklySkini/blockly/python.js +27 -0
- package/blocklySkini/blockly/python_compressed.js +98 -0
- package/blocklySkini/blockly/python_compressed.js.map +1 -0
- package/blocklySkini/blocklySkini.html +81 -0
- package/blocklySkini/orchestrations/.xml +1 -0
- package/blocklySkini/orchestrations/BluesSkini-1.xml +231 -0
- package/blocklySkini/orchestrations/BluesSkini-2.xml +741 -0
- package/blocklySkini/orchestrations/BluesSkini-3.xml +731 -0
- package/blocklySkini/orchestrations/BluesSkini-4.xml +695 -0
- package/blocklySkini/orchestrations/BluesSkini-5.xml +731 -0
- package/blocklySkini/orchestrations/BluesSkini.xml +704 -0
- package/blocklySkini/orchestrations/FunkBitwig-1.xml +778 -0
- package/blocklySkini/orchestrations/FunkBitwig-2.xml +471 -0
- package/blocklySkini/orchestrations/JouerLeBonInstrument1-1.xml +784 -0
- package/blocklySkini/orchestrations/MajeurMineur-1.xml +638 -0
- package/blocklySkini/orchestrations/Opus5-3 - Copie.xml +1041 -0
- package/blocklySkini/orchestrations/Opus5-3.xml +1128 -0
- package/blocklySkini/orchestrations/Quatuor1-1.xml +357 -0
- package/blocklySkini/orchestrations/TechnoBitwig-1.xml +221 -0
- package/blocklySkini/orchestrations/TestBlockly.xml +497 -0
- package/blocklySkini/orchestrations/TestBlockly1.xml +500 -0
- package/blocklySkini/orchestrations/TestBlockly2.xml +792 -0
- package/blocklySkini/orchestrations/TestBlockly3-1.xml +1182 -0
- package/blocklySkini/orchestrations/TestBlockly3.xml +1251 -0
- package/blocklySkini/orchestrations/TestFunction.xml +143 -0
- package/blocklySkini/orchestrations/TestIf.xml +80 -0
- package/blocklySkini/orchestrations/TestLoop.xml +127 -0
- package/blocklySkini/orchestrations/TestOrchestration2.xml +460 -0
- package/blocklySkini/orchestrations/TestPrint.xml +70 -0
- package/blocklySkini/orchestrations/TestSubMod.xml +81 -0
- package/blocklySkini/orchestrations/Testlogic.xml +113 -0
- package/blocklySkini/orchestrations/TrouveLaPercu-1.xml +813 -0
- package/blocklySkini/orchestrations/TrouveLaPercu-2.xml +813 -0
- package/blocklySkini/orchestrations/bar.xml +496 -0
- package/blocklySkini/orchestrations/bar2.xml +496 -0
- package/blocklySkini/orchestrations/foo.xml +500 -0
- package/blocklySkini/orchestrations/opus5Blockly - Copie.xml +496 -0
- package/blocklySkini/orchestrations/opus5Blockly-3.xml +868 -0
- package/blocklySkini/orchestrations/opus5Blockly.xml +496 -0
- package/blocklySkini/orchestrations/testOrchestration3.xml +483 -0
- package/blocklySkini/orchestrations/testOrchestration4.xml +487 -0
- package/blocklySkini/scripts/hiphop_blocks.js +6104 -0
- package/blocklySkini/scripts/main2.js +801 -0
- package/blocklySkini/styles/index.css +320 -0
- package/blocklySkini/styles/material.css +11552 -0
- package/package.json +4 -3
|
@@ -0,0 +1,760 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2012 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @fileoverview Dropdown input field. Used for editable titles and variables.
|
|
9
|
+
* In the interests of a consistent UI, the toolbox shares some functions and
|
|
10
|
+
* properties with the context menu.
|
|
11
|
+
* @author fraser@google.com (Neil Fraser)
|
|
12
|
+
*/
|
|
13
|
+
'use strict';
|
|
14
|
+
|
|
15
|
+
goog.provide('Blockly.FieldDropdown');
|
|
16
|
+
|
|
17
|
+
goog.require('Blockly.Events');
|
|
18
|
+
goog.require('Blockly.Events.BlockChange');
|
|
19
|
+
goog.require('Blockly.Field');
|
|
20
|
+
goog.require('Blockly.fieldRegistry');
|
|
21
|
+
goog.require('Blockly.Menu');
|
|
22
|
+
goog.require('Blockly.MenuItem');
|
|
23
|
+
goog.require('Blockly.navigation');
|
|
24
|
+
goog.require('Blockly.utils');
|
|
25
|
+
goog.require('Blockly.utils.aria');
|
|
26
|
+
goog.require('Blockly.utils.Coordinate');
|
|
27
|
+
goog.require('Blockly.utils.dom');
|
|
28
|
+
goog.require('Blockly.utils.object');
|
|
29
|
+
goog.require('Blockly.utils.Size');
|
|
30
|
+
goog.require('Blockly.utils.string');
|
|
31
|
+
goog.require('Blockly.utils.Svg');
|
|
32
|
+
goog.require('Blockly.utils.userAgent');
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Class for an editable dropdown field.
|
|
37
|
+
* @param {(!Array.<!Array>|!Function)} menuGenerator A non-empty array of
|
|
38
|
+
* options for a dropdown list, or a function which generates these options.
|
|
39
|
+
* @param {Function=} opt_validator A function that is called to validate
|
|
40
|
+
* changes to the field's value. Takes in a language-neutral dropdown
|
|
41
|
+
* option & returns a validated language-neutral dropdown option, or null to
|
|
42
|
+
* abort the change.
|
|
43
|
+
* @param {Object=} opt_config A map of options used to configure the field.
|
|
44
|
+
* See the [field creation documentation]{@link https://developers.google.com/blockly/guides/create-custom-blocks/fields/built-in-fields/dropdown#creation}
|
|
45
|
+
* for a list of properties this parameter supports.
|
|
46
|
+
* @extends {Blockly.Field}
|
|
47
|
+
* @constructor
|
|
48
|
+
* @throws {TypeError} If `menuGenerator` options are incorrectly structured.
|
|
49
|
+
*/
|
|
50
|
+
Blockly.FieldDropdown = function(menuGenerator, opt_validator, opt_config) {
|
|
51
|
+
if (typeof menuGenerator != 'function') {
|
|
52
|
+
Blockly.FieldDropdown.validateOptions_(menuGenerator);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* An array of options for a dropdown list,
|
|
57
|
+
* or a function which generates these options.
|
|
58
|
+
* @type {(!Array.<!Array>|
|
|
59
|
+
* !function(this:Blockly.FieldDropdown): !Array.<!Array>)}
|
|
60
|
+
* @protected
|
|
61
|
+
*/
|
|
62
|
+
this.menuGenerator_ = menuGenerator;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* A cache of the most recently generated options.
|
|
66
|
+
* @type {Array.<!Array.<string>>}
|
|
67
|
+
* @private
|
|
68
|
+
*/
|
|
69
|
+
this.generatedOptions_ = null;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* The prefix field label, of common words set after options are trimmed.
|
|
73
|
+
* @type {?string}
|
|
74
|
+
* @package
|
|
75
|
+
*/
|
|
76
|
+
this.prefixField = null;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* The suffix field label, of common words set after options are trimmed.
|
|
80
|
+
* @type {?string}
|
|
81
|
+
* @package
|
|
82
|
+
*/
|
|
83
|
+
this.suffixField = null;
|
|
84
|
+
|
|
85
|
+
this.trimOptions_();
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* The currently selected option. The field is initialized with the
|
|
89
|
+
* first option selected.
|
|
90
|
+
* @type {!Object}
|
|
91
|
+
* @private
|
|
92
|
+
*/
|
|
93
|
+
this.selectedOption_ = this.getOptions(false)[0];
|
|
94
|
+
|
|
95
|
+
// Call parent's constructor.
|
|
96
|
+
Blockly.FieldDropdown.superClass_.constructor.call(
|
|
97
|
+
this, this.selectedOption_[1], opt_validator, opt_config);
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* A reference to the currently selected menu item.
|
|
101
|
+
* @type {Blockly.MenuItem}
|
|
102
|
+
* @private
|
|
103
|
+
*/
|
|
104
|
+
this.selectedMenuItem_ = null;
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* The dropdown menu.
|
|
108
|
+
* @type {Blockly.Menu}
|
|
109
|
+
* @private
|
|
110
|
+
*/
|
|
111
|
+
this.menu_ = null;
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* SVG image element if currently selected option is an image, or null.
|
|
115
|
+
* @type {SVGImageElement}
|
|
116
|
+
* @private
|
|
117
|
+
*/
|
|
118
|
+
this.imageElement_ = null;
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Tspan based arrow element.
|
|
122
|
+
* @type {SVGTSpanElement}
|
|
123
|
+
* @private
|
|
124
|
+
*/
|
|
125
|
+
this.arrow_ = null;
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* SVG based arrow element.
|
|
129
|
+
* @type {SVGElement}
|
|
130
|
+
* @private
|
|
131
|
+
*/
|
|
132
|
+
this.svgArrow_ = null;
|
|
133
|
+
};
|
|
134
|
+
Blockly.utils.object.inherits(Blockly.FieldDropdown, Blockly.Field);
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Dropdown image properties.
|
|
138
|
+
* @typedef {{
|
|
139
|
+
* src:string,
|
|
140
|
+
* alt:string,
|
|
141
|
+
* width:number,
|
|
142
|
+
* height:number
|
|
143
|
+
* }}
|
|
144
|
+
*/
|
|
145
|
+
Blockly.FieldDropdown.ImageProperties;
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Construct a FieldDropdown from a JSON arg object.
|
|
149
|
+
* @param {!Object} options A JSON object with options (options).
|
|
150
|
+
* @return {!Blockly.FieldDropdown} The new field instance.
|
|
151
|
+
* @package
|
|
152
|
+
* @nocollapse
|
|
153
|
+
*/
|
|
154
|
+
Blockly.FieldDropdown.fromJson = function(options) {
|
|
155
|
+
return new Blockly.FieldDropdown(options['options'], undefined, options);
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Serializable fields are saved by the XML renderer, non-serializable fields
|
|
160
|
+
* are not. Editable fields should also be serializable.
|
|
161
|
+
* @type {boolean}
|
|
162
|
+
*/
|
|
163
|
+
Blockly.FieldDropdown.prototype.SERIALIZABLE = true;
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Horizontal distance that a checkmark overhangs the dropdown.
|
|
167
|
+
*/
|
|
168
|
+
Blockly.FieldDropdown.CHECKMARK_OVERHANG = 25;
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Maximum height of the dropdown menu, as a percentage of the viewport height.
|
|
172
|
+
*/
|
|
173
|
+
Blockly.FieldDropdown.MAX_MENU_HEIGHT_VH = 0.45;
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* The y offset from the top of the field to the top of the image, if an image
|
|
177
|
+
* is selected.
|
|
178
|
+
* @type {number}
|
|
179
|
+
* @const
|
|
180
|
+
* @private
|
|
181
|
+
*/
|
|
182
|
+
Blockly.FieldDropdown.IMAGE_Y_OFFSET = 5;
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* The total vertical padding above and below an image.
|
|
186
|
+
* @type {number}
|
|
187
|
+
* @const
|
|
188
|
+
* @private
|
|
189
|
+
*/
|
|
190
|
+
Blockly.FieldDropdown.IMAGE_Y_PADDING =
|
|
191
|
+
Blockly.FieldDropdown.IMAGE_Y_OFFSET * 2;
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Android can't (in 2014) display "▾", so use "▼" instead.
|
|
195
|
+
*/
|
|
196
|
+
Blockly.FieldDropdown.ARROW_CHAR =
|
|
197
|
+
Blockly.utils.userAgent.ANDROID ? '\u25BC' : '\u25BE';
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Mouse cursor style when over the hotspot that initiates the editor.
|
|
201
|
+
*/
|
|
202
|
+
Blockly.FieldDropdown.prototype.CURSOR = 'default';
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Create the block UI for this dropdown.
|
|
206
|
+
* @package
|
|
207
|
+
*/
|
|
208
|
+
Blockly.FieldDropdown.prototype.initView = function() {
|
|
209
|
+
if (this.shouldAddBorderRect_()) {
|
|
210
|
+
this.createBorderRect_();
|
|
211
|
+
} else {
|
|
212
|
+
this.clickTarget_ = this.sourceBlock_.getSvgRoot();
|
|
213
|
+
}
|
|
214
|
+
this.createTextElement_();
|
|
215
|
+
|
|
216
|
+
this.imageElement_ = Blockly.utils.dom.createSvgElement(
|
|
217
|
+
Blockly.utils.Svg.IMAGE, {}, this.fieldGroup_);
|
|
218
|
+
|
|
219
|
+
if (this.getConstants().FIELD_DROPDOWN_SVG_ARROW) {
|
|
220
|
+
this.createSVGArrow_();
|
|
221
|
+
} else {
|
|
222
|
+
this.createTextArrow_();
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
if (this.borderRect_) {
|
|
226
|
+
Blockly.utils.dom.addClass(this.borderRect_, 'blocklyDropdownRect');
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Whether or not the dropdown should add a border rect.
|
|
232
|
+
* @return {boolean} True if the dropdown field should add a border rect.
|
|
233
|
+
* @protected
|
|
234
|
+
*/
|
|
235
|
+
Blockly.FieldDropdown.prototype.shouldAddBorderRect_ = function() {
|
|
236
|
+
return !this.getConstants().FIELD_DROPDOWN_NO_BORDER_RECT_SHADOW ||
|
|
237
|
+
(this.getConstants().FIELD_DROPDOWN_NO_BORDER_RECT_SHADOW &&
|
|
238
|
+
!this.sourceBlock_.isShadow());
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Create a tspan based arrow.
|
|
243
|
+
* @protected
|
|
244
|
+
*/
|
|
245
|
+
Blockly.FieldDropdown.prototype.createTextArrow_ = function() {
|
|
246
|
+
this.arrow_ = Blockly.utils.dom.createSvgElement(
|
|
247
|
+
Blockly.utils.Svg.TSPAN, {}, this.textElement_);
|
|
248
|
+
this.arrow_.appendChild(document.createTextNode(
|
|
249
|
+
this.sourceBlock_.RTL ?
|
|
250
|
+
Blockly.FieldDropdown.ARROW_CHAR + ' ' :
|
|
251
|
+
' ' + Blockly.FieldDropdown.ARROW_CHAR));
|
|
252
|
+
if (this.sourceBlock_.RTL) {
|
|
253
|
+
this.textElement_.insertBefore(this.arrow_, this.textContent_);
|
|
254
|
+
} else {
|
|
255
|
+
this.textElement_.appendChild(this.arrow_);
|
|
256
|
+
}
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Create an SVG based arrow.
|
|
261
|
+
* @protected
|
|
262
|
+
*/
|
|
263
|
+
Blockly.FieldDropdown.prototype.createSVGArrow_ = function() {
|
|
264
|
+
this.svgArrow_ = Blockly.utils.dom.createSvgElement(
|
|
265
|
+
Blockly.utils.Svg.IMAGE, {
|
|
266
|
+
'height': this.getConstants().FIELD_DROPDOWN_SVG_ARROW_SIZE + 'px',
|
|
267
|
+
'width': this.getConstants().FIELD_DROPDOWN_SVG_ARROW_SIZE + 'px'
|
|
268
|
+
}, this.fieldGroup_);
|
|
269
|
+
this.svgArrow_.setAttributeNS(Blockly.utils.dom.XLINK_NS, 'xlink:href',
|
|
270
|
+
this.getConstants().FIELD_DROPDOWN_SVG_ARROW_DATAURI);
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Create a dropdown menu under the text.
|
|
275
|
+
* @param {Event=} opt_e Optional mouse event that triggered the field to open,
|
|
276
|
+
* or undefined if triggered programmatically.
|
|
277
|
+
* @protected
|
|
278
|
+
*/
|
|
279
|
+
Blockly.FieldDropdown.prototype.showEditor_ = function(opt_e) {
|
|
280
|
+
this.menu_ = this.dropdownCreate_();
|
|
281
|
+
if (opt_e && typeof opt_e.clientX === 'number') {
|
|
282
|
+
this.menu_.openingCoords =
|
|
283
|
+
new Blockly.utils.Coordinate(opt_e.clientX, opt_e.clientY);
|
|
284
|
+
} else {
|
|
285
|
+
this.menu_.openingCoords = null;
|
|
286
|
+
}
|
|
287
|
+
// Element gets created in render.
|
|
288
|
+
this.menu_.render(Blockly.DropDownDiv.getContentDiv());
|
|
289
|
+
var menuElement = /** @type {!Element} */ (this.menu_.getElement());
|
|
290
|
+
Blockly.utils.dom.addClass(menuElement, 'blocklyDropdownMenu');
|
|
291
|
+
|
|
292
|
+
if (this.getConstants().FIELD_DROPDOWN_COLOURED_DIV) {
|
|
293
|
+
var primaryColour = (this.sourceBlock_.isShadow()) ?
|
|
294
|
+
this.sourceBlock_.getParent().getColour() :
|
|
295
|
+
this.sourceBlock_.getColour();
|
|
296
|
+
var borderColour = (this.sourceBlock_.isShadow()) ?
|
|
297
|
+
this.sourceBlock_.getParent().style.colourTertiary :
|
|
298
|
+
this.sourceBlock_.style.colourTertiary;
|
|
299
|
+
Blockly.DropDownDiv.setColour(primaryColour, borderColour);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
Blockly.DropDownDiv.showPositionedByField(
|
|
303
|
+
this, this.dropdownDispose_.bind(this));
|
|
304
|
+
|
|
305
|
+
// Focusing needs to be handled after the menu is rendered and positioned.
|
|
306
|
+
// Otherwise it will cause a page scroll to get the misplaced menu in
|
|
307
|
+
// view. See issue #1329.
|
|
308
|
+
this.menu_.focus();
|
|
309
|
+
|
|
310
|
+
if (this.selectedMenuItem_) {
|
|
311
|
+
this.menu_.setHighlighted(this.selectedMenuItem_);
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
this.applyColour();
|
|
315
|
+
};
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* Create the dropdown editor.
|
|
319
|
+
* @return {!Blockly.Menu} The newly created dropdown menu.
|
|
320
|
+
* @private
|
|
321
|
+
*/
|
|
322
|
+
Blockly.FieldDropdown.prototype.dropdownCreate_ = function() {
|
|
323
|
+
var menu = new Blockly.Menu();
|
|
324
|
+
menu.setRole(Blockly.utils.aria.Role.LISTBOX);
|
|
325
|
+
|
|
326
|
+
var options = this.getOptions(false);
|
|
327
|
+
this.selectedMenuItem_ = null;
|
|
328
|
+
for (var i = 0; i < options.length; i++) {
|
|
329
|
+
var content = options[i][0]; // Human-readable text or image.
|
|
330
|
+
var value = options[i][1]; // Language-neutral value.
|
|
331
|
+
if (typeof content == 'object') {
|
|
332
|
+
// An image, not text.
|
|
333
|
+
var image = new Image(content['width'], content['height']);
|
|
334
|
+
image.src = content['src'];
|
|
335
|
+
image.alt = content['alt'] || '';
|
|
336
|
+
content = image;
|
|
337
|
+
}
|
|
338
|
+
var menuItem = new Blockly.MenuItem(content, value);
|
|
339
|
+
menuItem.setRole(Blockly.utils.aria.Role.OPTION);
|
|
340
|
+
menuItem.setRightToLeft(this.sourceBlock_.RTL);
|
|
341
|
+
menuItem.setCheckable(true);
|
|
342
|
+
menu.addChild(menuItem);
|
|
343
|
+
menuItem.setChecked(value == this.value_);
|
|
344
|
+
if (value == this.value_) {
|
|
345
|
+
this.selectedMenuItem_ = menuItem;
|
|
346
|
+
}
|
|
347
|
+
menuItem.onAction(this.handleMenuActionEvent_, this);
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
return menu;
|
|
351
|
+
};
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* Disposes of events and dom-references belonging to the dropdown editor.
|
|
355
|
+
* @private
|
|
356
|
+
*/
|
|
357
|
+
Blockly.FieldDropdown.prototype.dropdownDispose_ = function() {
|
|
358
|
+
if (this.menu_) {
|
|
359
|
+
this.menu_.dispose();
|
|
360
|
+
}
|
|
361
|
+
this.menu_ = null;
|
|
362
|
+
this.selectedMenuItem_ = null;
|
|
363
|
+
this.applyColour();
|
|
364
|
+
};
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* Handle an action in the dropdown menu.
|
|
368
|
+
* @param {!Blockly.MenuItem} menuItem The MenuItem selected within menu.
|
|
369
|
+
* @private
|
|
370
|
+
*/
|
|
371
|
+
Blockly.FieldDropdown.prototype.handleMenuActionEvent_ = function(menuItem) {
|
|
372
|
+
Blockly.DropDownDiv.hideIfOwner(this, true);
|
|
373
|
+
this.onItemSelected_(/** @type {!Blockly.Menu} */ (this.menu_), menuItem);
|
|
374
|
+
};
|
|
375
|
+
|
|
376
|
+
/**
|
|
377
|
+
* Handle the selection of an item in the dropdown menu.
|
|
378
|
+
* @param {!Blockly.Menu} menu The Menu component clicked.
|
|
379
|
+
* @param {!Blockly.MenuItem} menuItem The MenuItem selected within menu.
|
|
380
|
+
* @protected
|
|
381
|
+
*/
|
|
382
|
+
Blockly.FieldDropdown.prototype.onItemSelected_ = function(menu, menuItem) {
|
|
383
|
+
this.setValue(menuItem.getValue());
|
|
384
|
+
};
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* Factor out common words in statically defined options.
|
|
388
|
+
* Create prefix and/or suffix labels.
|
|
389
|
+
* @private
|
|
390
|
+
*/
|
|
391
|
+
Blockly.FieldDropdown.prototype.trimOptions_ = function() {
|
|
392
|
+
var options = this.menuGenerator_;
|
|
393
|
+
if (!Array.isArray(options)) {
|
|
394
|
+
return;
|
|
395
|
+
}
|
|
396
|
+
var hasImages = false;
|
|
397
|
+
|
|
398
|
+
// Localize label text and image alt text.
|
|
399
|
+
for (var i = 0; i < options.length; i++) {
|
|
400
|
+
var label = options[i][0];
|
|
401
|
+
if (typeof label == 'string') {
|
|
402
|
+
options[i][0] = Blockly.utils.replaceMessageReferences(label);
|
|
403
|
+
} else {
|
|
404
|
+
if (label.alt != null) {
|
|
405
|
+
options[i][0].alt = Blockly.utils.replaceMessageReferences(label.alt);
|
|
406
|
+
}
|
|
407
|
+
hasImages = true;
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
if (hasImages || options.length < 2) {
|
|
411
|
+
return; // Do nothing if too few items or at least one label is an image.
|
|
412
|
+
}
|
|
413
|
+
var strings = [];
|
|
414
|
+
for (var i = 0; i < options.length; i++) {
|
|
415
|
+
strings.push(options[i][0]);
|
|
416
|
+
}
|
|
417
|
+
var shortest = Blockly.utils.string.shortestStringLength(strings);
|
|
418
|
+
var prefixLength = Blockly.utils.string.commonWordPrefix(strings, shortest);
|
|
419
|
+
var suffixLength = Blockly.utils.string.commonWordSuffix(strings, shortest);
|
|
420
|
+
if (!prefixLength && !suffixLength) {
|
|
421
|
+
return;
|
|
422
|
+
}
|
|
423
|
+
if (shortest <= prefixLength + suffixLength) {
|
|
424
|
+
// One or more strings will entirely vanish if we proceed. Abort.
|
|
425
|
+
return;
|
|
426
|
+
}
|
|
427
|
+
if (prefixLength) {
|
|
428
|
+
this.prefixField = strings[0].substring(0, prefixLength - 1);
|
|
429
|
+
}
|
|
430
|
+
if (suffixLength) {
|
|
431
|
+
this.suffixField = strings[0].substr(1 - suffixLength);
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
this.menuGenerator_ = Blockly.FieldDropdown.applyTrim_(options, prefixLength,
|
|
435
|
+
suffixLength);
|
|
436
|
+
};
|
|
437
|
+
|
|
438
|
+
/**
|
|
439
|
+
* Use the calculated prefix and suffix lengths to trim all of the options in
|
|
440
|
+
* the given array.
|
|
441
|
+
* @param {!Array.<!Array>} options Array of option tuples:
|
|
442
|
+
* (human-readable text or image, language-neutral name).
|
|
443
|
+
* @param {number} prefixLength The length of the common prefix.
|
|
444
|
+
* @param {number} suffixLength The length of the common suffix
|
|
445
|
+
* @return {!Array.<!Array>} A new array with all of the option text trimmed.
|
|
446
|
+
*/
|
|
447
|
+
Blockly.FieldDropdown.applyTrim_ = function(options,
|
|
448
|
+
prefixLength, suffixLength) {
|
|
449
|
+
var newOptions = [];
|
|
450
|
+
// Remove the prefix and suffix from the options.
|
|
451
|
+
for (var i = 0; i < options.length; i++) {
|
|
452
|
+
var text = options[i][0];
|
|
453
|
+
var value = options[i][1];
|
|
454
|
+
text = text.substring(prefixLength, text.length - suffixLength);
|
|
455
|
+
newOptions[i] = [text, value];
|
|
456
|
+
}
|
|
457
|
+
return newOptions;
|
|
458
|
+
};
|
|
459
|
+
|
|
460
|
+
/**
|
|
461
|
+
* @return {boolean} True if the option list is generated by a function.
|
|
462
|
+
* Otherwise false.
|
|
463
|
+
*/
|
|
464
|
+
Blockly.FieldDropdown.prototype.isOptionListDynamic = function() {
|
|
465
|
+
return typeof this.menuGenerator_ == 'function';
|
|
466
|
+
};
|
|
467
|
+
|
|
468
|
+
/**
|
|
469
|
+
* Return a list of the options for this dropdown.
|
|
470
|
+
* @param {boolean=} opt_useCache For dynamic options, whether or not to use the
|
|
471
|
+
* cached options or to re-generate them.
|
|
472
|
+
* @return {!Array.<!Array>} A non-empty array of option tuples:
|
|
473
|
+
* (human-readable text or image, language-neutral name).
|
|
474
|
+
* @throws {TypeError} If generated options are incorrectly structured.
|
|
475
|
+
*/
|
|
476
|
+
Blockly.FieldDropdown.prototype.getOptions = function(opt_useCache) {
|
|
477
|
+
if (this.isOptionListDynamic()) {
|
|
478
|
+
if (!this.generatedOptions_ || !opt_useCache) {
|
|
479
|
+
this.generatedOptions_ = this.menuGenerator_.call(this);
|
|
480
|
+
Blockly.FieldDropdown.validateOptions_(this.generatedOptions_);
|
|
481
|
+
}
|
|
482
|
+
return this.generatedOptions_;
|
|
483
|
+
}
|
|
484
|
+
return /** @type {!Array.<!Array.<string>>} */ (this.menuGenerator_);
|
|
485
|
+
};
|
|
486
|
+
|
|
487
|
+
/**
|
|
488
|
+
* Ensure that the input value is a valid language-neutral option.
|
|
489
|
+
* @param {*=} opt_newValue The input value.
|
|
490
|
+
* @return {?string} A valid language-neutral option, or null if invalid.
|
|
491
|
+
* @protected
|
|
492
|
+
*/
|
|
493
|
+
Blockly.FieldDropdown.prototype.doClassValidation_ = function(opt_newValue) {
|
|
494
|
+
var isValueValid = false;
|
|
495
|
+
var options = this.getOptions(true);
|
|
496
|
+
for (var i = 0, option; (option = options[i]); i++) {
|
|
497
|
+
// Options are tuples of human-readable text and language-neutral values.
|
|
498
|
+
if (option[1] == opt_newValue) {
|
|
499
|
+
isValueValid = true;
|
|
500
|
+
break;
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
if (!isValueValid) {
|
|
504
|
+
if (this.sourceBlock_) {
|
|
505
|
+
console.warn('Cannot set the dropdown\'s value to an unavailable option.' +
|
|
506
|
+
' Block type: ' + this.sourceBlock_.type + ', Field name: ' + this.name +
|
|
507
|
+
', Value: ' + opt_newValue);
|
|
508
|
+
}
|
|
509
|
+
return null;
|
|
510
|
+
}
|
|
511
|
+
return /** @type {string} */ (opt_newValue);
|
|
512
|
+
};
|
|
513
|
+
|
|
514
|
+
/**
|
|
515
|
+
* Update the value of this dropdown field.
|
|
516
|
+
* @param {*} newValue The value to be saved. The default validator guarantees
|
|
517
|
+
* that this is one of the valid dropdown options.
|
|
518
|
+
* @protected
|
|
519
|
+
*/
|
|
520
|
+
Blockly.FieldDropdown.prototype.doValueUpdate_ = function(newValue) {
|
|
521
|
+
Blockly.FieldDropdown.superClass_.doValueUpdate_.call(this, newValue);
|
|
522
|
+
var options = this.getOptions(true);
|
|
523
|
+
for (var i = 0, option; (option = options[i]); i++) {
|
|
524
|
+
if (option[1] == this.value_) {
|
|
525
|
+
this.selectedOption_ = option;
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
};
|
|
529
|
+
|
|
530
|
+
/**
|
|
531
|
+
* Updates the dropdown arrow to match the colour/style of the block.
|
|
532
|
+
* @package
|
|
533
|
+
*/
|
|
534
|
+
Blockly.FieldDropdown.prototype.applyColour = function() {
|
|
535
|
+
if (this.borderRect_) {
|
|
536
|
+
this.borderRect_.setAttribute('stroke',
|
|
537
|
+
this.sourceBlock_.style.colourTertiary);
|
|
538
|
+
if (this.menu_) {
|
|
539
|
+
this.borderRect_.setAttribute('fill',
|
|
540
|
+
this.sourceBlock_.style.colourTertiary);
|
|
541
|
+
} else {
|
|
542
|
+
this.borderRect_.setAttribute('fill', 'transparent');
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
// Update arrow's colour.
|
|
546
|
+
if (this.sourceBlock_ && this.arrow_) {
|
|
547
|
+
if (this.sourceBlock_.isShadow()) {
|
|
548
|
+
this.arrow_.style.fill = this.sourceBlock_.style.colourSecondary;
|
|
549
|
+
} else {
|
|
550
|
+
this.arrow_.style.fill = this.sourceBlock_.style.colourPrimary;
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
};
|
|
554
|
+
|
|
555
|
+
/**
|
|
556
|
+
* Draws the border with the correct width.
|
|
557
|
+
* @protected
|
|
558
|
+
*/
|
|
559
|
+
Blockly.FieldDropdown.prototype.render_ = function() {
|
|
560
|
+
// Hide both elements.
|
|
561
|
+
this.textContent_.nodeValue = '';
|
|
562
|
+
this.imageElement_.style.display = 'none';
|
|
563
|
+
|
|
564
|
+
// Show correct element.
|
|
565
|
+
var option = this.selectedOption_ && this.selectedOption_[0];
|
|
566
|
+
if (option && typeof option == 'object') {
|
|
567
|
+
this.renderSelectedImage_(
|
|
568
|
+
/** @type {!Blockly.FieldDropdown.ImageProperties} */ (option));
|
|
569
|
+
} else {
|
|
570
|
+
this.renderSelectedText_();
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
this.positionBorderRect_();
|
|
574
|
+
};
|
|
575
|
+
|
|
576
|
+
/**
|
|
577
|
+
* Renders the selected option, which must be an image.
|
|
578
|
+
* @param {!Blockly.FieldDropdown.ImageProperties} imageJson Selected
|
|
579
|
+
* option that must be an image.
|
|
580
|
+
* @private
|
|
581
|
+
*/
|
|
582
|
+
Blockly.FieldDropdown.prototype.renderSelectedImage_ = function(imageJson) {
|
|
583
|
+
this.imageElement_.style.display = '';
|
|
584
|
+
this.imageElement_.setAttributeNS(
|
|
585
|
+
Blockly.utils.dom.XLINK_NS, 'xlink:href', imageJson.src);
|
|
586
|
+
this.imageElement_.setAttribute('height', imageJson.height);
|
|
587
|
+
this.imageElement_.setAttribute('width', imageJson.width);
|
|
588
|
+
|
|
589
|
+
var imageHeight = Number(imageJson.height);
|
|
590
|
+
var imageWidth = Number(imageJson.width);
|
|
591
|
+
|
|
592
|
+
// Height and width include the border rect.
|
|
593
|
+
var hasBorder = !!this.borderRect_;
|
|
594
|
+
var height = Math.max(
|
|
595
|
+
hasBorder ? this.getConstants().FIELD_DROPDOWN_BORDER_RECT_HEIGHT : 0,
|
|
596
|
+
imageHeight + Blockly.FieldDropdown.IMAGE_Y_PADDING);
|
|
597
|
+
var xPadding = hasBorder ? this.getConstants().FIELD_BORDER_RECT_X_PADDING : 0;
|
|
598
|
+
var arrowWidth = 0;
|
|
599
|
+
if (this.svgArrow_) {
|
|
600
|
+
arrowWidth = this.positionSVGArrow_(imageWidth + xPadding, height / 2 -
|
|
601
|
+
this.getConstants().FIELD_DROPDOWN_SVG_ARROW_SIZE / 2);
|
|
602
|
+
} else {
|
|
603
|
+
arrowWidth = Blockly.utils.dom.getFastTextWidth(
|
|
604
|
+
/** @type {!SVGTSpanElement} */ (this.arrow_),
|
|
605
|
+
this.getConstants().FIELD_TEXT_FONTSIZE,
|
|
606
|
+
this.getConstants().FIELD_TEXT_FONTWEIGHT,
|
|
607
|
+
this.getConstants().FIELD_TEXT_FONTFAMILY);
|
|
608
|
+
}
|
|
609
|
+
this.size_.width = imageWidth + arrowWidth + xPadding * 2;
|
|
610
|
+
this.size_.height = height;
|
|
611
|
+
|
|
612
|
+
var arrowX = 0;
|
|
613
|
+
if (this.sourceBlock_.RTL) {
|
|
614
|
+
var imageX = xPadding + arrowWidth;
|
|
615
|
+
this.imageElement_.setAttribute('x', imageX);
|
|
616
|
+
} else {
|
|
617
|
+
arrowX = imageWidth + arrowWidth;
|
|
618
|
+
this.textElement_.setAttribute('text-anchor', 'end');
|
|
619
|
+
this.imageElement_.setAttribute('x', xPadding);
|
|
620
|
+
}
|
|
621
|
+
this.imageElement_.setAttribute('y', height / 2 - imageHeight / 2);
|
|
622
|
+
|
|
623
|
+
this.positionTextElement_(arrowX + xPadding, imageWidth + arrowWidth);
|
|
624
|
+
};
|
|
625
|
+
|
|
626
|
+
/**
|
|
627
|
+
* Renders the selected option, which must be text.
|
|
628
|
+
* @private
|
|
629
|
+
*/
|
|
630
|
+
Blockly.FieldDropdown.prototype.renderSelectedText_ = function() {
|
|
631
|
+
// Retrieves the selected option to display through getText_.
|
|
632
|
+
this.textContent_.nodeValue = this.getDisplayText_();
|
|
633
|
+
Blockly.utils.dom.addClass(/** @type {!Element} */ (this.textElement_),
|
|
634
|
+
'blocklyDropdownText');
|
|
635
|
+
this.textElement_.setAttribute('text-anchor', 'start');
|
|
636
|
+
|
|
637
|
+
// Height and width include the border rect.
|
|
638
|
+
var hasBorder = !!this.borderRect_;
|
|
639
|
+
var height = Math.max(
|
|
640
|
+
hasBorder ? this.getConstants().FIELD_DROPDOWN_BORDER_RECT_HEIGHT : 0,
|
|
641
|
+
this.getConstants().FIELD_TEXT_HEIGHT);
|
|
642
|
+
var textWidth = Blockly.utils.dom.getFastTextWidth(this.textElement_,
|
|
643
|
+
this.getConstants().FIELD_TEXT_FONTSIZE,
|
|
644
|
+
this.getConstants().FIELD_TEXT_FONTWEIGHT,
|
|
645
|
+
this.getConstants().FIELD_TEXT_FONTFAMILY);
|
|
646
|
+
var xPadding = hasBorder ? this.getConstants().FIELD_BORDER_RECT_X_PADDING : 0;
|
|
647
|
+
var arrowWidth = 0;
|
|
648
|
+
if (this.svgArrow_) {
|
|
649
|
+
arrowWidth = this.positionSVGArrow_(textWidth + xPadding, height / 2 -
|
|
650
|
+
this.getConstants().FIELD_DROPDOWN_SVG_ARROW_SIZE / 2);
|
|
651
|
+
}
|
|
652
|
+
this.size_.width = textWidth + arrowWidth + xPadding * 2;
|
|
653
|
+
this.size_.height = height;
|
|
654
|
+
|
|
655
|
+
this.positionTextElement_(xPadding, textWidth);
|
|
656
|
+
};
|
|
657
|
+
|
|
658
|
+
/**
|
|
659
|
+
* Position a drop-down arrow at the appropriate location at render-time.
|
|
660
|
+
* @param {number} x X position the arrow is being rendered at, in px.
|
|
661
|
+
* @param {number} y Y position the arrow is being rendered at, in px.
|
|
662
|
+
* @return {number} Amount of space the arrow is taking up, in px.
|
|
663
|
+
* @private
|
|
664
|
+
*/
|
|
665
|
+
Blockly.FieldDropdown.prototype.positionSVGArrow_ = function(x, y) {
|
|
666
|
+
if (!this.svgArrow_) {
|
|
667
|
+
return 0;
|
|
668
|
+
}
|
|
669
|
+
var hasBorder = !!this.borderRect_;
|
|
670
|
+
var xPadding = hasBorder ? this.getConstants().FIELD_BORDER_RECT_X_PADDING : 0;
|
|
671
|
+
var textPadding = this.getConstants().FIELD_DROPDOWN_SVG_ARROW_PADDING;
|
|
672
|
+
var svgArrowSize = this.getConstants().FIELD_DROPDOWN_SVG_ARROW_SIZE;
|
|
673
|
+
var arrowX = this.sourceBlock_.RTL ? xPadding : x + textPadding;
|
|
674
|
+
this.svgArrow_.setAttribute('transform',
|
|
675
|
+
'translate(' + arrowX + ',' + y + ')');
|
|
676
|
+
return svgArrowSize + textPadding;
|
|
677
|
+
};
|
|
678
|
+
|
|
679
|
+
/**
|
|
680
|
+
* Use the `getText_` developer hook to override the field's text
|
|
681
|
+
* representation. Get the selected option text. If the selected option is an
|
|
682
|
+
* image we return the image alt text.
|
|
683
|
+
* @return {?string} Selected option text.
|
|
684
|
+
* @protected
|
|
685
|
+
* @override
|
|
686
|
+
*/
|
|
687
|
+
Blockly.FieldDropdown.prototype.getText_ = function() {
|
|
688
|
+
if (!this.selectedOption_) {
|
|
689
|
+
return null;
|
|
690
|
+
}
|
|
691
|
+
var option = this.selectedOption_[0];
|
|
692
|
+
if (typeof option == 'object') {
|
|
693
|
+
return option['alt'];
|
|
694
|
+
}
|
|
695
|
+
return option;
|
|
696
|
+
};
|
|
697
|
+
|
|
698
|
+
/**
|
|
699
|
+
* Validates the data structure to be processed as an options list.
|
|
700
|
+
* @param {?} options The proposed dropdown options.
|
|
701
|
+
* @throws {TypeError} If proposed options are incorrectly structured.
|
|
702
|
+
* @private
|
|
703
|
+
*/
|
|
704
|
+
Blockly.FieldDropdown.validateOptions_ = function(options) {
|
|
705
|
+
if (!Array.isArray(options)) {
|
|
706
|
+
throw TypeError('FieldDropdown options must be an array.');
|
|
707
|
+
}
|
|
708
|
+
if (!options.length) {
|
|
709
|
+
throw TypeError('FieldDropdown options must not be an empty array.');
|
|
710
|
+
}
|
|
711
|
+
var foundError = false;
|
|
712
|
+
for (var i = 0; i < options.length; ++i) {
|
|
713
|
+
var tuple = options[i];
|
|
714
|
+
if (!Array.isArray(tuple)) {
|
|
715
|
+
foundError = true;
|
|
716
|
+
console.error(
|
|
717
|
+
'Invalid option[' + i + ']: Each FieldDropdown option must be an ' +
|
|
718
|
+
'array. Found: ', tuple);
|
|
719
|
+
} else if (typeof tuple[1] != 'string') {
|
|
720
|
+
foundError = true;
|
|
721
|
+
console.error(
|
|
722
|
+
'Invalid option[' + i + ']: Each FieldDropdown option id must be ' +
|
|
723
|
+
'a string. Found ' + tuple[1] + ' in: ', tuple);
|
|
724
|
+
} else if (tuple[0] &&
|
|
725
|
+
(typeof tuple[0] != 'string') &&
|
|
726
|
+
(typeof tuple[0].src != 'string')) {
|
|
727
|
+
foundError = true;
|
|
728
|
+
console.error(
|
|
729
|
+
'Invalid option[' + i + ']: Each FieldDropdown option must have a ' +
|
|
730
|
+
'string label or image description. Found' + tuple[0] + ' in: ',
|
|
731
|
+
tuple);
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
if (foundError) {
|
|
735
|
+
throw TypeError('Found invalid FieldDropdown options.');
|
|
736
|
+
}
|
|
737
|
+
};
|
|
738
|
+
|
|
739
|
+
/**
|
|
740
|
+
* Handles the given action.
|
|
741
|
+
* This is only triggered when keyboard accessibility mode is enabled.
|
|
742
|
+
* @param {!Blockly.Action} action The action to be handled.
|
|
743
|
+
* @return {boolean} True if the field handled the action, false otherwise.
|
|
744
|
+
* @package
|
|
745
|
+
*/
|
|
746
|
+
Blockly.FieldDropdown.prototype.onBlocklyAction = function(action) {
|
|
747
|
+
if (this.menu_) {
|
|
748
|
+
if (action === Blockly.navigation.ACTION_PREVIOUS) {
|
|
749
|
+
this.menu_.highlightPrevious();
|
|
750
|
+
return true;
|
|
751
|
+
} else if (action === Blockly.navigation.ACTION_NEXT) {
|
|
752
|
+
this.menu_.highlightNext();
|
|
753
|
+
return true;
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
return Blockly.FieldDropdown.superClass_.onBlocklyAction.call(this, action);
|
|
757
|
+
};
|
|
758
|
+
|
|
759
|
+
|
|
760
|
+
Blockly.fieldRegistry.register('field_dropdown', Blockly.FieldDropdown);
|