pxt-core 7.4.12 → 7.4.13

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.
@@ -3127,6 +3127,63 @@ return Blockly.Blocks;
3127
3127
 
3128
3128
  //# sourceMappingURL=blocks_compressed.js.map
3129
3129
 
3130
+ !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("blockly/core"));else if("function"==typeof define&&define.amd)define(["blockly/core"],t);else{var o="object"==typeof exports?t(require("blockly/core")):t(e.Blockly);for(var r in o)("object"==typeof exports?exports:e)[r]=o[r]}}(this,(function(e){return function(e){var t={};function o(r){if(t[r])return t[r].exports;var s=t[r]={i:r,l:!1,exports:{}};return e[r].call(s.exports,s,s.exports,o),s.l=!0,s.exports}return o.m=e,o.c=t,o.d=function(e,t,r){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(e,t){if(1&t&&(e=o(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(o.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var s in e)o.d(r,s,function(t){return e[t]}.bind(null,s));return r},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="/dist/",o(o.s=1)}([function(t,o){t.exports=e},function(e,t,o){"use strict";o.r(t),o.d(t,"Constants",(function(){return r})),o.d(t,"FlyoutCursor",(function(){return a})),o.d(t,"FlyoutCursorPluginInfo",(function(){return l})),o.d(t,"LineCursor",(function(){return d})),o.d(t,"LineCursorPluginInfo",(function(){return y})),o.d(t,"Navigation",(function(){return h})),o.d(t,"NavigationController",(function(){return S}));var r={};o.r(r),o.d(r,"STATE",(function(){return s})),o.d(r,"SHORTCUT_NAMES",(function(){return i})),o.d(r,"LOGGING_MSG_TYPE",(function(){return n}));
3131
+ /**
3132
+ * @license
3133
+ * Copyright 2021 Google LLC
3134
+ * SPDX-License-Identifier: Apache-2.0
3135
+ */
3136
+ const s={WORKSPACE:"workspace",FLYOUT:"flyout",TOOLBOX:"toolbox"},i={PREVIOUS:"previous",NEXT:"next",IN:"in",OUT:"out",INSERT:"insert",MARK:"mark",DISCONNECT:"disconnect",TOOLBOX:"toolbox",EXIT:"exit",TOGGLE_KEYBOARD_NAV:"toggle_keyboard_nav",COPY:"keyboard_nav_copy",CUT:"keyboard_nav_cut",PASTE:"keyboard_nav_paste",DELETE:"keyboard_nav_delete",MOVE_WS_CURSOR_UP:"workspace_up",MOVE_WS_CURSOR_DOWN:"workspace_down",MOVE_WS_CURSOR_LEFT:"workspace_left",MOVE_WS_CURSOR_RIGHT:"workspace_right"},n={ERROR:"error",WARN:"warn",LOG:"log"};var c=o(0);
3137
+ /**
3138
+ * @license
3139
+ * Copyright 2021 Google LLC
3140
+ * SPDX-License-Identifier: Apache-2.0
3141
+ */class a extends c.Cursor{constructor(){super()}next(){const e=this.getCurNode();if(!e)return null;const t=e.next();return t&&this.setCurNode(t),t}in(){return null}prev(){const e=this.getCurNode();if(!e)return null;const t=e.prev();return t&&this.setCurNode(t),t}out(){return null}}const u=c.registry.Type.CURSOR;c.registry.register(u,"FlyoutCursor",a);const l={[u]:"FlyoutCursor"};
3142
+ /**
3143
+ * @license
3144
+ * Copyright 2020 Google LLC
3145
+ * SPDX-License-Identifier: Apache-2.0
3146
+ */class d extends c.BasicCursor{constructor(){super()}next(){const e=this.getCurNode();if(!e)return null;let t=this.getNextNode_(e,this.validLineNode);return t&&(t.getType()==c.ASTNode.types.INPUT||t.getType()==c.ASTNode.types.NEXT)&&t.getLocation().targetBlock()&&(t=this.getNextNode_(t,this.validLineNode)),t&&this.setCurNode(t),t}in(){const e=this.getCurNode();if(!e)return null;const t=this.getNextNode_(e,this.validInLineNode);return t&&this.setCurNode(t),t}prev(){const e=this.getCurNode();if(!e)return null;let t=this.getPreviousNode_(e,this.validLineNode);return t&&(t.getType()==c.ASTNode.types.INPUT||t.getType()==c.ASTNode.types.NEXT)&&t.getLocation().targetBlock()&&(t=this.getPreviousNode_(t,this.validLineNode)),t&&this.setCurNode(t),t}out(){const e=this.getCurNode();if(!e)return null;const t=this.getPreviousNode_(e,this.validInLineNode);return t&&this.setCurNode(t),t}validLineNode(e){if(!e)return!1;let t=!1;const o=e.getLocation(),r=e&&e.getType();return r==c.ASTNode.types.BLOCK?null===o.outputConnection&&(t=!0):(r==c.ASTNode.types.INPUT&&o.type==c.NEXT_STATEMENT||r==c.ASTNode.types.NEXT)&&(t=!0),t}validInLineNode(e){if(!e)return!1;let t=!1;const o=e.getLocation(),r=e&&e.getType();return(r==c.ASTNode.types.FIELD||r==c.ASTNode.types.INPUT&&o.type==c.INPUT_VALUE)&&(t=!0),t}}const g=c.registry.Type.CURSOR;c.registry.register(g,"LineCursor",d);const y={[g]:"LineCursor"};
3147
+ /**
3148
+ * @license
3149
+ * Copyright 2021 Google LLC
3150
+ * SPDX-License-Identifier: Apache-2.0
3151
+ */class h{constructor(){this.workspaceStates={},this.loggingCallback=null,this.WS_MOVE_DISTANCE=40,this.MARKER_NAME="local_marker_1",this.DEFAULT_WS_COORDINATE=new c.utils.Coordinate(100,100),this.WS_COORDINATE_ON_DELETE=new c.utils.Coordinate(100,100),this.wsChangeWrapper=this.workspaceChangeListener.bind(this),this.flyoutChangeWrapper=this.flyoutChangeListener.bind(this),this.workspaces=[]}addWorkspace(e){this.workspaces.push(e);const t=e.getFlyout();e.getMarkerManager().registerMarker(this.MARKER_NAME,new c.Marker),e.addChangeListener(this.wsChangeWrapper),t&&this.addFlyout(t)}removeWorkspace(e){const t=this.workspaces.indexOf(e),o=e.getFlyout();e.getCursor()&&this.disableKeyboardAccessibility(e),t>-1&&this.workspaces.splice(t,1),e.getMarkerManager()&&e.getMarkerManager().unregisterMarker(this.MARKER_NAME),e.removeChangeListener(this.wsChangeWrapper),o&&this.removeFlyout(o)}setState(e,t){this.workspaceStates[e.id]=t}getState(e){return this.workspaceStates[e.id]}getMarker(e){return e.getMarker(this.MARKER_NAME)}addFlyout(e){const t=e.getWorkspace();t.addChangeListener(this.flyoutChangeWrapper);const o=c.registry.getClass(u,"FlyoutCursor");t.getMarkerManager().setCursor(new o)}removeFlyout(e){e.getWorkspace().removeChangeListener(this.flyoutChangeWrapper)}workspaceChangeListener(e){const t=c.Workspace.getById(e.workspaceId);if(t&&t.keyboardAccessibilityMode)switch(e.type){case c.Events.DELETE:this.handleBlockDeleteByDrag(t,e);break;case c.Events.BLOCK_CHANGE:"mutation"===e.element&&this.handleBlockMutation(t,e);break;case c.Events.CLICK:this.handleWorkspaceClick(t,e);break;case c.Events.TOOLBOX_ITEM_SELECT:this.handleToolboxCategoryClick(t,e);break;case c.Events.BLOCK_CREATE:this.handleBlockCreate(t,e)}}flyoutChangeListener(e){const t=c.Workspace.getById(e.workspaceId),o=t.targetWorkspace,r=o.getFlyout();if(o&&o.keyboardAccessibilityMode&&!r.autoClose)if(e.type===c.Events.CLICK&&"block"===e.targetType){const r=t.getBlockById(e.blockId);this.handleBlockClickInFlyout(o,r)}else if(e.type===c.Events.SELECTED){const r=t.getBlockById(e.newElementId);this.handleBlockClickInFlyout(o,r)}}handleBlockCreate(e,t){this.getState(e)===s.FLYOUT&&(this.resetFlyout(e,!!e.getToolbox()),this.setState(e,s.WORKSPACE))}handleBlockMutation(e,t){const o=t.blockId,r=e.getCursor();if(r){const e=r.getCurNode(),t=e?e.getSourceBlock():null;t&&t.id===o&&r.setCurNode(c.ASTNode.createBlockNode(t))}}handleWorkspaceClick(e,t){this.getState(e)!==s.WORKSPACE&&(this.resetFlyout(e,!!e.getToolbox()),this.setState(e,s.WORKSPACE))}handleToolboxCategoryClick(e,t){const o=this.getState(e);t.newItem&&o!==s.TOOLBOX?this.focusToolbox(e):t.newItem||(this.resetFlyout(e,!!e.getToolbox()),this.setState(e,s.WORKSPACE))}handleBlockDeleteByDrag(e,t){const o=t.blockId,r=t.ids,s=e.getCursor();if(!s||!s.getCurNode()||!s.getCurNode().getSourceBlock())return;const i=s.getCurNode().getSourceBlock();(i.id===o||r.indexOf(i.id)>-1)&&s.setCurNode(c.ASTNode.createWorkspaceNode(e,this.WS_COORDINATE_ON_DELETE))}handleBlockClickInFlyout(e,t){t&&(t.isShadow()&&(t=t.getParent()),this.getFlyoutCursor(e).setCurNode(c.ASTNode.createStackNode(t)),this.setState(e,s.FLYOUT))}moveCursorOnBlockDelete(e,t){if(!e||!e.getCursor())return;const o=e.getCursor(),r=o.getCurNode(),s=r?r.getSourceBlock():null;if(s===t)if(s.getParent()){const e=s.previousConnection||s.outputConnection;e&&o.setCurNode(c.ASTNode.createConnectionNode(e.targetConnection))}else o.setCurNode(c.ASTNode.createWorkspaceNode(s.workspace,s.getRelativeToSurfaceXY()));else s&&t.getChildren(!1).indexOf(s)>-1&&o.setCurNode(c.ASTNode.createWorkspaceNode(s.workspace,s.getRelativeToSurfaceXY()))}focusToolbox(e){const t=e.getToolbox();if(t&&(this.setState(e,s.TOOLBOX),this.resetFlyout(e,!1),this.getMarker(e).getCurNode()||this.markAtCursor(e),!t.getSelectedItem())){const e=t.getToolboxItems();for(let o,r=0;o=e[r];r++)if(o.isSelectable()){t.selectItemByPosition(r);break}}}focusFlyout(e){const t=e.getFlyout();if(this.setState(e,s.FLYOUT),this.getMarker(e).getCurNode()||this.markAtCursor(e),t&&t.getWorkspace()){const o=t.getWorkspace().getTopBlocks(!0);if(o.length>0){const t=c.ASTNode.createStackNode(o[0]);this.getFlyoutCursor(e).setCurNode(t)}}}focusWorkspace(e){c.hideChaff();const t=!!e.getToolbox();this.resetFlyout(e,t),this.setState(e,s.WORKSPACE),this.setCursorOnWorkspaceFocus(e)}setCursorOnWorkspaceFocus(e){const t=e.getTopBlocks(!0),o=e.getCursor(),r=new c.utils.Coordinate(this.DEFAULT_WS_COORDINATE.x/e.scale,this.DEFAULT_WS_COORDINATE.y/e.scale);if(t.length>0)o.setCurNode(c.ASTNode.createTopNode(t[0]));else{const t=c.ASTNode.createWorkspaceNode(e,r);o.setCurNode(t)}}getFlyoutCursor(e){const t=e.getFlyout();return t?t.getWorkspace().getCursor():null}insertFromFlyout(e){const t=this.createNewBlock(e);if(!t)return;const o=this.getMarker(e).getCurNode();this.tryToConnectMarkerAndCursor(e,o,c.ASTNode.createBlockNode(t))||this.warn("Something went wrong while inserting a block from the flyout."),this.focusWorkspace(e),e.getCursor().setCurNode(c.ASTNode.createTopNode(t)),this.removeMark(e)}createNewBlock(e){const t=e.getFlyout();if(!t||!t.isVisible())return this.warn("Trying to insert from the flyout when the flyout does not exist or is not visible"),null;const o=this.getFlyoutCursor(e).getCurNode().getLocation();if(!o.isEnabled())return this.warn("Can't insert a disabled block."),null;const r=t.createBlock(o);return r.render(),r.setConnectionTracking(!0),r}resetFlyout(e,t){this.getFlyoutCursor(e)&&(this.getFlyoutCursor(e).hide(),t&&e.getFlyout().hide())}connectMarkerAndCursor(e){const t=this.getMarker(e).getCurNode(),o=e.getCursor().getCurNode();return!(!t||!o)&&this.tryToConnectMarkerAndCursor(e,t,o)}tryToConnectMarkerAndCursor(e,t,o){if(!this.logConnectionWarning(t,o))return!1;const r=t.getType(),s=o.getType(),i=o.getLocation(),n=t.getLocation();if(t.isConnection()&&o.isConnection()){const e=i,t=n;return this.connect(e,t)}if(t.isConnection()&&(s==c.ASTNode.types.BLOCK||s==c.ASTNode.types.STACK)){const e=i,t=n;return this.insertBlock(e,t)}if(r==c.ASTNode.types.WORKSPACE){const e=o?o.getSourceBlock():null;return this.moveBlockToWorkspace(e,t)}return this.warn("Unexpected state in tryToConnectMarkerAndCursor."),!1}logConnectionWarning(e,t){if(!e)return this.warn("Cannot insert with no marked node."),!1;if(!t)return this.warn("Cannot insert with no cursor node."),!1;const o=e.getType(),r=t.getType();return o==c.ASTNode.types.FIELD?(this.warn("Should not have been able to mark a field."),!1):o==c.ASTNode.types.BLOCK?(this.warn("Should not have been able to mark a block."),!1):o==c.ASTNode.types.STACK?(this.warn("Should not have been able to mark a stack."),!1):r==c.ASTNode.types.FIELD?(this.warn("Cannot attach a field to anything else."),!1):r!=c.ASTNode.types.WORKSPACE||(this.warn("Cannot attach a workspace to anything else."),!1)}moveBlockToWorkspace(e,t){return!!e&&(e.isShadow()?(this.warn("Cannot move a shadow block to the workspace."),!1):(e.getParent()&&e.unplug(!1),e.moveTo(t.getWsCoordinate()),!0))}disconnectChild(e,t){const o=e.getSourceBlock(),r=t.getSourceBlock();let s;o.getRootBlock()===r.getRootBlock()&&(o.getDescendants(!1).indexOf(r)>-1?(s=this.getInferiorConnection(t),s&&s.disconnect()):(s=this.getInferiorConnection(e),s&&s.disconnect()))}connect(e,t){if(!e||!t)return!1;const o=this.getInferiorConnection(e),r=this.getSuperiorConnection(t),s=this.getSuperiorConnection(e),i=this.getInferiorConnection(t);if(o&&r&&this.moveAndConnect(o,r))return!0;if(s&&i&&this.moveAndConnect(s,i))return!0;if(this.moveAndConnect(e,t))return!0;{const o=e.getConnectionChecker(),r=o.canConnectWithReason(e,t,!1);return this.warn("Connection failed with error: "+o.getErrorMessage(r,e,t)),!1}}getInferiorConnection(e){const t=e.getSourceBlock();return e.isSuperior()?t.previousConnection?t.previousConnection:t.outputConnection?t.outputConnection:null:e}getSuperiorConnection(e){return e.isSuperior()?e:e.targetConnection?e.targetConnection:null}moveAndConnect(e,t){if(!e||!t)return!1;const o=e.getSourceBlock();if(e.getConnectionChecker().canConnect(e,t,!1)&&!t.getSourceBlock().isShadow()){if(this.disconnectChild(e,t),!t.isSuperior()){o.getRootBlock().positionNearConnection(e,t)}return t.connect(e),!0}return!1}insertBlock(e,t){switch(t.type){case c.PREVIOUS_STATEMENT:if(this.connect(e.nextConnection,t))return!0;break;case c.NEXT_STATEMENT:if(this.connect(e.previousConnection,t))return!0;break;case c.INPUT_VALUE:if(this.connect(e.outputConnection,t))return!0;break;case c.OUTPUT_VALUE:for(let o=0;o<e.inputList.length;o++){const r=e.inputList[o].connection;if(r&&r.type===c.INPUT_VALUE&&this.connect(r,t))return!0}if(e.outputConnection&&this.connect(e.outputConnection,t))return!0}return this.warn("This block can not be inserted at the marked location."),!1}disconnectBlocks(e){const t=e.getCursor().getCurNode();if(!t.isConnection())return void this.log("Cannot disconnect blocks when the cursor is not on a connection");const o=t.getLocation();if(!o.isConnected())return void this.log("Cannot disconnect unconnected connection");const r=o.isSuperior()?o:o.targetConnection,s=o.isSuperior()?o.targetConnection:o;if(s.getSourceBlock().isShadow())return void this.log("Cannot disconnect a shadow block");r.disconnect(),s.bumpAwayFrom(r),r.getSourceBlock().getRootBlock().bringToFront();const i=c.ASTNode.createConnectionNode(r);e.getCursor().setCurNode(i)}markAtCursor(e){this.getMarker(e).setCurNode(e.getCursor().getCurNode())}removeMark(e){const t=this.getMarker(e);t.setCurNode(null),t.hide()}enableKeyboardAccessibility(e){this.workspaces.indexOf(e)>-1&&!e.keyboardAccessibilityMode&&(e.keyboardAccessibilityMode=!0,this.focusWorkspace(e))}disableKeyboardAccessibility(e){this.workspaces.indexOf(e)>-1&&e.keyboardAccessibilityMode&&(e.keyboardAccessibilityMode=!1,e.getCursor().hide(),this.getMarker(e).hide(),this.getFlyoutCursor(e)&&this.getFlyoutCursor(e).hide())}log(e){this.loggingCallback?this.loggingCallback(n.LOG,e):console.log(e)}warn(e){this.loggingCallback?this.loggingCallback(n.WARN,e):console.warn(e)}error(e){this.loggingCallback?this.loggingCallback(n.ERROR,e):console.error(e)}moveWSCursor(e,t,o){const r=e.getCursor(),s=e.getCursor().getCurNode();if(s.getType()!==c.ASTNode.types.WORKSPACE)return!1;const i=s.getWsCoordinate(),n=t*this.WS_MOVE_DISTANCE+i.x,a=o*this.WS_MOVE_DISTANCE+i.y;return r.setCurNode(c.ASTNode.createWorkspaceNode(e,new c.utils.Coordinate(n,a))),!0}handleEnterForWS(e){const t=e.getCursor().getCurNode(),o=t.getType();o==c.ASTNode.types.FIELD?t.getLocation().showEditor():t.isConnection()||o==c.ASTNode.types.WORKSPACE?this.markAtCursor(e):o==c.ASTNode.types.BLOCK?this.warn("Cannot mark a block."):o==c.ASTNode.types.STACK&&this.warn("Cannot mark a stack.")}paste(){if(!c.clipboardXml_)return!1;let e=c.clipboardSource_,t=!1;if(e.isFlyout&&(e=e.targetWorkspace),c.clipboardTypeCounts_&&e.isCapacityAvailable(c.clipboardTypeCounts_)){c.Events.setGroup(!0);const o=c.Xml.domToBlock(c.clipboardXml_,e);o&&(this.insertPastedBlock(e,o),c.Events.isEnabled()&&!o.isShadow()&&c.Events.fire(new c.Events.BlockCreate(o)),t=!0),c.Events.setGroup(!1)}return t}insertPastedBlock(e,t){let o=!1;const r=e.getMarker(this.MARKER_NAME).getCurNode();return r&&(o=this.tryToConnectMarkerAndCursor(e,r,c.ASTNode.createBlockNode(t))),o}dispose(){for(const e of this.workspaces)this.removeWorkspace(e)}}
3152
+ /**
3153
+ * @license
3154
+ * Copyright 2021 Google LLC
3155
+ * SPDX-License-Identifier: Apache-2.0
3156
+ */const C=c.Gesture.prototype.doWorkspaceClick_;c.Gesture.prototype.doWorkspaceClick_=function(e){C.call(this,e);const t=this.creatorWorkspace_;if(e.shiftKey&&t.keyboardAccessibilityMode){const o=new c.utils.Coordinate(e.clientX,e.clientY),r=c.utils.screenToWsCoordinates(t,o),s=c.ASTNode.createWorkspaceNode(t,r);t.getCursor().setCurNode(s)}};const p=c.Gesture.prototype.doBlockClick_;c.Gesture.prototype.doBlockClick_=function(e){p.call(this,e),!this.targetBlock_.isInFlyout&&this.mostRecentEvent_.shiftKey&&this.targetBlock_.workspace.keyboardAccessibilityMode&&this.creatorWorkspace_.getCursor().setCurNode(c.ASTNode.createTopNode(this.targetBlock_))};
3157
+ /**
3158
+ * @license
3159
+ * Copyright 2021 Google LLC
3160
+ * SPDX-License-Identifier: Apache-2.0
3161
+ */
3162
+ class S{constructor(e){this.navigation=e||new h}init(){this.addShortcutHandlers(),this.registerDefaults()}addShortcutHandlers(){c.FieldColour&&(c.FieldColour.prototype.onShortcut=this.fieldColourHandler),c.FieldDropdown&&(c.FieldDropdown.prototype.onShortcut=this.fieldDropdownHandler),c.Toolbox&&(c.Toolbox.prototype.onShortcut=this.toolboxHandler)}removeShortcutHandlers(){c.FieldColour&&(c.FieldColour.prototype.onShortcut=null),c.FieldDropdown&&(c.FieldDropdown.prototype.onShortcut=null),c.Toolbox&&(c.Toolbox.prototype.onShortcut=null)}fieldColourHandler(e){if(this.picker_)switch(e.name){case i.PREVIOUS:return this.moveHighlightBy_(0,-1),!0;case i.NEXT:return this.moveHighlightBy_(0,1),!0;case i.OUT:return this.moveHighlightBy_(-1,0),!0;case i.IN:return this.moveHighlightBy_(1,0),!0;default:return!1}return c.FieldColour.superClass_.onShortcut.call(this,e)}fieldDropdownHandler(e){if(this.menu_)switch(e.name){case i.PREVIOUS:return this.menu_.highlightPrevious(),!0;case i.NEXT:return this.menu_.highlightNext(),!0;default:return!1}return c.FieldDropdown.superClass_.onShortcut.call(this,e)}toolboxHandler(e){if(!this.selectedItem_)return!1;switch(e.name){case i.PREVIOUS:return this.selectPrevious_();case i.OUT:return this.selectParent_();case i.NEXT:return this.selectNext_();case i.IN:return this.selectChild_();default:return!1}}addWorkspace(e){this.navigation.addWorkspace(e)}removeWorkspace(e){this.navigation.removeWorkspace(e)}enable(e){this.navigation.enableKeyboardAccessibility(e)}disable(e){this.navigation.disableKeyboardAccessibility(e)}fieldShortcutHandler(e,t){const o=e.getCursor();if(!o||!o.getCurNode())return;const r=o.getCurNode();return r.getType()===c.ASTNode.types.FIELD&&r.getLocation().onShortcut(t)}registerPrevious(){const e={name:i.PREVIOUS,preconditionFn:e=>e.keyboardAccessibilityMode,callback:(e,t,o)=>{const r=e.getFlyout(),i=e.getToolbox();let n=!1;switch(this.navigation.getState(e)){case s.WORKSPACE:return n=this.fieldShortcutHandler(e,o),n||(e.getCursor().prev(),n=!0),n;case s.FLYOUT:return n=this.fieldShortcutHandler(e,o),n||(r.getWorkspace().getCursor().prev(),n=!0),n;case s.TOOLBOX:return!(!i||"function"!=typeof i.onShortcut)&&i.onShortcut(o);default:return!1}}};c.ShortcutRegistry.registry.register(e),c.ShortcutRegistry.registry.addKeyMapping(c.utils.KeyCodes.W,e.name)}registerToggleKeyboardNav(){const e={name:i.TOGGLE_KEYBOARD_NAV,callback:e=>(e.keyboardAccessibilityMode?this.navigation.disableKeyboardAccessibility(e):this.navigation.enableKeyboardAccessibility(e),!0)};c.ShortcutRegistry.registry.register(e);const t=c.ShortcutRegistry.registry.createSerializedKey(c.utils.KeyCodes.K,[c.utils.KeyCodes.CTRL,c.utils.KeyCodes.SHIFT]);c.ShortcutRegistry.registry.addKeyMapping(t,e.name)}registerOut(){const e={name:i.OUT,preconditionFn:e=>e.keyboardAccessibilityMode,callback:(e,t,o)=>{const r=e.getToolbox();let i=!1;switch(this.navigation.getState(e)){case s.WORKSPACE:return i=this.fieldShortcutHandler(e,o),i||(e.getCursor().out(),i=!0),i;case s.FLYOUT:return this.navigation.focusToolbox(e),!0;case s.TOOLBOX:return!(!r||"function"!=typeof r.onShortcut)&&r.onShortcut(o);default:return!1}}};c.ShortcutRegistry.registry.register(e),c.ShortcutRegistry.registry.addKeyMapping(c.utils.KeyCodes.A,e.name)}registerNext(){const e={name:i.NEXT,preconditionFn:e=>e.keyboardAccessibilityMode,callback:(e,t,o)=>{const r=e.getToolbox(),i=e.getFlyout();let n=!1;switch(this.navigation.getState(e)){case s.WORKSPACE:return n=this.fieldShortcutHandler(e,o),n||(e.getCursor().next(),n=!0),n;case s.FLYOUT:return n=this.fieldShortcutHandler(e,o),n||(i.getWorkspace().getCursor().next(),n=!0),n;case s.TOOLBOX:return!(!r||"function"!=typeof r.onShortcut)&&r.onShortcut(o);default:return!1}}};c.ShortcutRegistry.registry.register(e),c.ShortcutRegistry.registry.addKeyMapping(c.utils.KeyCodes.S,e.name)}registerIn(){const e={name:i.IN,preconditionFn:e=>e.keyboardAccessibilityMode,callback:(e,t,o)=>{const r=e.getToolbox();let i=!1;switch(this.navigation.getState(e)){case s.WORKSPACE:return i=this.fieldShortcutHandler(e,o),i||(e.getCursor().in(),i=!0),i;case s.TOOLBOX:return i=!(!r||"function"!=typeof r.onShortcut)&&r.onShortcut(o),i||this.navigation.focusFlyout(e),!0;default:return!1}}};c.ShortcutRegistry.registry.register(e),c.ShortcutRegistry.registry.addKeyMapping(c.utils.KeyCodes.D,e.name)}registerInsert(){const e={name:i.INSERT,preconditionFn:e=>e.keyboardAccessibilityMode&&!e.options.readOnly,callback:e=>{switch(this.navigation.getState(e)){case s.WORKSPACE:return this.navigation.connectMarkerAndCursor(e);default:return!1}}};c.ShortcutRegistry.registry.register(e),c.ShortcutRegistry.registry.addKeyMapping(c.utils.KeyCodes.I,e.name)}registerMark(){const e={name:i.MARK,preconditionFn:e=>e.keyboardAccessibilityMode&&!e.options.readOnly,callback:e=>{switch(this.navigation.getState(e)){case s.WORKSPACE:return this.navigation.handleEnterForWS(e),!0;case s.FLYOUT:return this.navigation.insertFromFlyout(e),!0;default:return!1}}};c.ShortcutRegistry.registry.register(e),c.ShortcutRegistry.registry.addKeyMapping(c.utils.KeyCodes.ENTER,e.name)}registerDisconnect(){const e={name:i.DISCONNECT,preconditionFn:e=>e.keyboardAccessibilityMode&&!e.options.readOnly,callback:e=>{switch(this.navigation.getState(e)){case s.WORKSPACE:return this.navigation.disconnectBlocks(e),!0;default:return!1}}};c.ShortcutRegistry.registry.register(e),c.ShortcutRegistry.registry.addKeyMapping(c.utils.KeyCodes.X,e.name)}registerToolboxFocus(){const e={name:i.TOOLBOX,preconditionFn:e=>e.keyboardAccessibilityMode&&!e.options.readOnly,callback:e=>{switch(this.navigation.getState(e)){case s.WORKSPACE:return e.getToolbox()?this.navigation.focusToolbox(e):this.navigation.focusFlyout(e),!0;default:return!1}}};c.ShortcutRegistry.registry.register(e),c.ShortcutRegistry.registry.addKeyMapping(c.utils.KeyCodes.T,e.name)}registerExit(){const e={name:i.EXIT,preconditionFn:e=>e.keyboardAccessibilityMode,callback:e=>{switch(this.navigation.getState(e)){case s.FLYOUT:case s.TOOLBOX:return this.navigation.focusWorkspace(e),!0;default:return!1}}};c.ShortcutRegistry.registry.register(e,!0),c.ShortcutRegistry.registry.addKeyMapping(c.utils.KeyCodes.ESC,e.name,!0),c.ShortcutRegistry.registry.addKeyMapping(c.utils.KeyCodes.E,e.name,!0)}registerWorkspaceMoveLeft(){const e={name:i.MOVE_WS_CURSOR_LEFT,preconditionFn:e=>e.keyboardAccessibilityMode&&!e.options.readOnly,callback:e=>this.navigation.moveWSCursor(e,-1,0)};c.ShortcutRegistry.registry.register(e);const t=c.ShortcutRegistry.registry.createSerializedKey(c.utils.KeyCodes.A,[c.utils.KeyCodes.SHIFT]);c.ShortcutRegistry.registry.addKeyMapping(t,e.name)}registerWorkspaceMoveRight(){const e={name:i.MOVE_WS_CURSOR_RIGHT,preconditionFn:e=>e.keyboardAccessibilityMode&&!e.options.readOnly,callback:e=>this.navigation.moveWSCursor(e,1,0)};c.ShortcutRegistry.registry.register(e);const t=c.ShortcutRegistry.registry.createSerializedKey(c.utils.KeyCodes.D,[c.utils.KeyCodes.SHIFT]);c.ShortcutRegistry.registry.addKeyMapping(t,e.name)}registerWorkspaceMoveUp(){const e={name:i.MOVE_WS_CURSOR_UP,preconditionFn:e=>e.keyboardAccessibilityMode&&!e.options.readOnly,callback:e=>this.navigation.moveWSCursor(e,0,-1)};c.ShortcutRegistry.registry.register(e);const t=c.ShortcutRegistry.registry.createSerializedKey(c.utils.KeyCodes.W,[c.utils.KeyCodes.SHIFT]);c.ShortcutRegistry.registry.addKeyMapping(t,e.name)}registerWorkspaceMoveDown(){const e={name:i.MOVE_WS_CURSOR_DOWN,preconditionFn:e=>e.keyboardAccessibilityMode&&!e.options.readOnly,callback:e=>this.navigation.moveWSCursor(e,0,1)};c.ShortcutRegistry.registry.register(e);const t=c.ShortcutRegistry.registry.createSerializedKey(c.utils.KeyCodes.S,[c.utils.KeyCodes.SHIFT]);c.ShortcutRegistry.registry.addKeyMapping(t,e.name)}registerCopy(){const e={name:i.COPY,preconditionFn:e=>{if(e.keyboardAccessibilityMode&&!e.options.readOnly){const t=e.getCursor().getCurNode();if(t&&t.getSourceBlock()){const e=t.getSourceBlock();return!c.Gesture.inProgress()&&e&&e.isDeletable()&&e.isMovable()}}return!1},callback:e=>{const t=e.getCursor().getCurNode().getSourceBlock();c.hideChaff(),c.copy(t)}};c.ShortcutRegistry.registry.register(e);const t=c.ShortcutRegistry.registry.createSerializedKey(c.utils.KeyCodes.C,[c.utils.KeyCodes.CTRL]);c.ShortcutRegistry.registry.addKeyMapping(t,e.name,!0);const o=c.ShortcutRegistry.registry.createSerializedKey(c.utils.KeyCodes.C,[c.utils.KeyCodes.ALT]);c.ShortcutRegistry.registry.addKeyMapping(o,e.name,!0);const r=c.ShortcutRegistry.registry.createSerializedKey(c.utils.KeyCodes.C,[c.utils.KeyCodes.META]);c.ShortcutRegistry.registry.addKeyMapping(r,e.name,!0)}registerPaste(){const e={name:i.PASTE,preconditionFn:e=>e.keyboardAccessibilityMode&&!e.options.readOnly&&!c.Gesture.inProgress(),callback:()=>this.navigation.paste()};c.ShortcutRegistry.registry.register(e);const t=c.ShortcutRegistry.registry.createSerializedKey(c.utils.KeyCodes.V,[c.utils.KeyCodes.CTRL]);c.ShortcutRegistry.registry.addKeyMapping(t,e.name,!0);const o=c.ShortcutRegistry.registry.createSerializedKey(c.utils.KeyCodes.V,[c.utils.KeyCodes.ALT]);c.ShortcutRegistry.registry.addKeyMapping(o,e.name,!0);const r=c.ShortcutRegistry.registry.createSerializedKey(c.utils.KeyCodes.V,[c.utils.KeyCodes.META]);c.ShortcutRegistry.registry.addKeyMapping(r,e.name,!0)}registerCut(){const e={name:i.CUT,preconditionFn:e=>{if(e.keyboardAccessibilityMode&&!e.options.readOnly){const t=e.getCursor().getCurNode();if(t&&t.getSourceBlock()){const e=t.getSourceBlock();return!c.Gesture.inProgress()&&e&&e.isDeletable()&&e.isMovable()&&!e.workspace.isFlyout}}return!1},callback:e=>{const t=e.getCursor().getCurNode().getSourceBlock();return c.copy(t),this.navigation.moveCursorOnBlockDelete(e,t),c.deleteBlock(t),!0}};c.ShortcutRegistry.registry.register(e);const t=c.ShortcutRegistry.registry.createSerializedKey(c.utils.KeyCodes.X,[c.utils.KeyCodes.CTRL]);c.ShortcutRegistry.registry.addKeyMapping(t,e.name,!0);const o=c.ShortcutRegistry.registry.createSerializedKey(c.utils.KeyCodes.X,[c.utils.KeyCodes.ALT]);c.ShortcutRegistry.registry.addKeyMapping(o,e.name,!0);const r=c.ShortcutRegistry.registry.createSerializedKey(c.utils.KeyCodes.X,[c.utils.KeyCodes.META]);c.ShortcutRegistry.registry.addKeyMapping(r,e.name,!0)}registerDelete(){const e={name:i.DELETE,preconditionFn:function(e){if(e.keyboardAccessibilityMode&&!e.options.readOnly){const t=e.getCursor().getCurNode();if(t&&t.getSourceBlock()){const e=t.getSourceBlock();return e&&e.isDeletable()}}return!1},callback:(e,t)=>{const o=e.getCursor().getCurNode().getSourceBlock();return t.preventDefault(),!c.Gesture.inProgress()&&(this.navigation.moveCursorOnBlockDelete(e,o),c.deleteBlock(o),!0)}};c.ShortcutRegistry.registry.register(e),c.ShortcutRegistry.registry.addKeyMapping(c.utils.KeyCodes.DELETE,e.name,!0),c.ShortcutRegistry.registry.addKeyMapping(c.utils.KeyCodes.BACKSPACE,e.name,!0)}registerDefaults(){this.registerPrevious(),this.registerNext(),this.registerIn(),this.registerOut(),this.registerDisconnect(),this.registerExit(),this.registerInsert(),this.registerMark(),this.registerToolboxFocus(),this.registerToggleKeyboardNav(),this.registerWorkspaceMoveDown(),this.registerWorkspaceMoveLeft(),this.registerWorkspaceMoveUp(),this.registerWorkspaceMoveRight(),this.registerCopy(),this.registerPaste(),this.registerCut(),this.registerDelete()}dispose(){const e=Object.values(i);for(const t of e)c.ShortcutRegistry.registry.unregister(t);this.removeShortcutHandlers(),this.navigation.dispose()}}
3163
+ /**
3164
+ * @license
3165
+ * Copyright 2021 Google LLC
3166
+ * SPDX-License-Identifier: Apache-2.0
3167
+ */}])}));
3168
+ //# sourceMappingURL=index.js.map
3169
+ !function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("blockly/core"));else if("function"==typeof define&&define.amd)define(["blockly/core"],e);else{var i="object"==typeof exports?e(require("blockly/core")):e(t.Blockly);for(var s in i)("object"==typeof exports?exports:t)[s]=i[s]}}(this,(function(t){return function(t){var e={};function i(s){if(e[s])return e[s].exports;var n=e[s]={i:s,l:!1,exports:{}};return t[s].call(n.exports,n,n.exports,i),n.l=!0,n.exports}return i.m=t,i.c=e,i.d=function(t,e,s){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:s})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var s=Object.create(null);if(i.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)i.d(s,n,function(e){return t[e]}.bind(null,n));return s},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="/dist/",i(i.s=1)}([function(e,i){e.exports=t},function(t,e,i){"use strict";i.r(e),i.d(e,"WorkspaceSearch",(function(){return l}));
3170
+ /**
3171
+ * @license
3172
+ * Copyright 2020 Google LLC
3173
+ * SPDX-License-Identifier: Apache-2.0
3174
+ */
3175
+ const s=["path.blocklyPath.blockly-ws-search-highlight {","fill: black;","}","path.blocklyPath.blockly-ws-search-highlight.blockly-ws-search-current {","fill: grey;","}",".blockly-ws-search-close-btn {","background: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iMTQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgd2lkdGg9IjE0Ij48cGF0aCBkPSJNMTkgNi40MUwxNy41OSA1IDEyIDEwLjU5IDYuNDEgNSA1IDYuNDEgMTAuNTkgMTIgNSAxNy41OSA2LjQxIDE5IDEyIDEzLjQxIDE3LjU5IDE5IDE5IDE3LjU5IDEzLjQxIDEyeiIvPjxwYXRoIGQ9Ik0wIDBoMjR2MjRIMHoiIGZpbGw9Im5vbmUiLz48L3N2Zz4=) no-repeat top left;","}",".blockly-ws-search-next-btn {","background: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iMTQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgd2lkdGg9IjE0Ij48cGF0aCBkPSJNNy40MSA4LjU5TDEyIDEzLjE3bDQuNTktNC41OEwxOCAxMGwtNiA2LTYtNiAxLjQxLTEuNDF6Ii8+PHBhdGggZD0iTTAgMGgyNHYyNEgwVjB6IiBmaWxsPSJub25lIi8+PC9zdmc+) no-repeat top left;","}",".blockly-ws-search-previous-btn {","background: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iMTQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgd2lkdGg9IjE0Ij48cGF0aCBkPSJNNy40MSAxNS40MUwxMiAxMC44M2w0LjU5IDQuNThMMTggMTRsLTYtNi02IDZ6Ii8+PHBhdGggZD0iTTAgMGgyNHYyNEgweiIgZmlsbD0ibm9uZSIvPjwvc3ZnPg==) no-repeat top left;","}",".blockly-ws-search {","background: white;","border: solid lightgrey .5px;","box-shadow: 0px 10px 20px grey;","justify-content: center;","padding: .25em;","position: absolute;","z-index: 70;","}",".blockly-ws-search-input input {","border: none;","}",".blockly-ws-search button {","border: none;","}",".blockly-ws-search-actions {","display: flex;","}",".blockly-ws-search-container {","display: flex;","}",".blockly-ws-search-content {","display: flex;","}"],n=function(){let t=!1;return function(){if(t)return;t=!0;const e=s.join("\n"),i=document.createElement("style");i.id="blockly-ws-search-style";const n=document.createTextNode(e);i.appendChild(n),document.head.insertBefore(i,document.head.firstChild)}}();var o=i(0);
3176
+ /**
3177
+ * @license
3178
+ * Copyright 2020 Google LLC
3179
+ * SPDX-License-Identifier: Apache-2.0
3180
+ */class l{constructor(t){this.workspace_=t,this.id="workspaceSearch",this.htmlDiv_=null,this.actionDiv_=null,this.inputElement_=null,this.textInputPlaceholder_="Search",this.blocks_=[],this.currentBlockIndex_=-1,this.searchText_="",this.searchOnInput=!0,this.caseSensitive=!1,this.preserveSelected=!0,this.boundEvents_=[]}init(){this.workspace_.getComponentManager().addComponent({component:this,weight:0,capabilities:[o.ComponentManager.Capability.POSITIONABLE]}),n(),this.createDom_(),this.setVisible_(!1),this.workspace_.resize()}dispose(){for(const t of this.boundEvents_)o.unbindEvent_(t);this.boundEvents_=null,this.htmlDiv_&&(this.htmlDiv_.remove(),this.htmlDiv_=null),this.actionDiv_=null,this.inputElement_=null}createDom_(){const t=this.workspace_.getInjectionDiv();this.addEvent_(t,"keydown",this,t=>this.onWorkspaceKeyDown_(t)),this.htmlDiv_=document.createElement("div"),o.utils.dom.addClass(this.htmlDiv_,"blockly-ws-search");const e=document.createElement("div");o.utils.dom.addClass(e,"blockly-ws-search-container");const i=document.createElement("div");o.utils.dom.addClass(i,"blockly-ws-search-content"),e.appendChild(i);const s=document.createElement("div");o.utils.dom.addClass(s,"blockly-ws-search-input"),this.inputElement_=this.createTextInput_(),this.addEvent_(this.inputElement_,"keydown",this,t=>this.onKeyDown_(t)),this.addEvent_(this.inputElement_,"input",this,()=>this.onInput_()),this.addEvent_(this.inputElement_,"click",this,()=>this.searchAndHighlight(this.searchText_,this.preserveSelected)),s.appendChild(this.inputElement_),i.appendChild(s),this.actionDiv_=document.createElement("div"),o.utils.dom.addClass(this.actionDiv_,"blockly-ws-search-actions"),i.appendChild(this.actionDiv_);const n=this.createNextBtn_();n&&this.addActionBtn(n,()=>this.next());const l=this.createPreviousBtn_();l&&this.addActionBtn(l,()=>this.previous());const c=this.createCloseBtn_();c&&(this.addBtnListener_(c,()=>this.close()),e.appendChild(c)),this.htmlDiv_.appendChild(e),t.insertBefore(this.htmlDiv_,this.workspace_.getParentSvg())}addEvent_(t,e,i,s){const n=o.bindEventWithChecks_(t,e,i,s);this.boundEvents_.push(n)}addActionBtn(t,e){this.addBtnListener_(t,e),this.actionDiv_.appendChild(t)}createTextInput_(){const t=document.createElement("input");return t.type="text",t.setAttribute("placeholder",this.textInputPlaceholder_),t}createNextBtn_(){return this.createBtn_("blockly-ws-search-next-btn","Find next")}createPreviousBtn_(){return this.createBtn_("blockly-ws-search-previous-btn","Find previous")}createCloseBtn_(){return this.createBtn_("blockly-ws-search-close-btn","Close search bar")}createBtn_(t,e){const i=document.createElement("button");return o.utils.dom.addClass(i,t),i.setAttribute("aria-label",e),i}addBtnListener_(t,e){this.addEvent_(t,"click",this,e),this.addEvent_(t,"keydown",this,t=>{t.keyCode===o.utils.KeyCodes.ENTER?(e(t),t.preventDefault()):t.keyCode===o.utils.KeyCodes.ESC&&this.close(),t.stopPropagation()})}getBoundingRectangle(){const t=this.htmlDiv_.style.top,e=this.htmlDiv_.style.left;return new o.utils.Rect(t,t+this.htmlDiv_.style.height,e,e+this.htmlDiv_.style.width)}position(t,e){this.workspace_.RTL?this.htmlDiv_.style.left=t.absoluteMetrics.left+"px":t.toolboxMetrics.position===o.TOOLBOX_AT_RIGHT?this.htmlDiv_.style.right=t.toolboxMetrics.width+"px":this.htmlDiv_.style.right="0",this.htmlDiv_.style.top=t.absoluteMetrics.top+"px"}onInput_(){if(this.searchOnInput){const t=this.inputElement_.value.trim();t!==this.searchText_&&this.searchAndHighlight(t,this.preserveSelected)}}onKeyDown_(t){if(t.keyCode===o.utils.KeyCodes.ESC)this.close();else if(t.keyCode===o.utils.KeyCodes.ENTER)if(this.searchOnInput)this.next();else{const t=this.inputElement_.value.trim();t!==this.searchText_&&this.searchAndHighlight(t,this.preserveSelected)}}onWorkspaceKeyDown_(t){(t.ctrlKey||t.metaKey)&&t.keyCode===o.utils.KeyCodes.F&&(this.open(),t.preventDefault(),t.stopPropagation())}previous(){this.setCurrentBlock_(this.currentBlockIndex_-1)}next(){this.setCurrentBlock_(this.currentBlockIndex_+1)}setSearchPlaceholder(t){this.textInputPlaceholder_=t,this.inputElement_&&this.inputElement_.setAttribute("placeholder",this.textInputPlaceholder_)}setCurrentBlock_(t){if(!this.blocks_.length)return;let e=this.blocks_[this.currentBlockIndex_];e&&this.unhighlightCurrentSelection_(e),this.currentBlockIndex_=(t%this.blocks_.length+this.blocks_.length)%this.blocks_.length,e=this.blocks_[this.currentBlockIndex_],this.highlightCurrentSelection_(e),this.scrollToVisible_(e)}open(){this.setVisible_(!0),this.inputElement_.focus(),this.searchText_&&this.searchAndHighlight(this.searchText_)}close(){this.setVisible_(!1),this.workspace_.markFocused(),this.clearBlocks()}setVisible_(t){this.htmlDiv_.style.display=t?"flex":"none"}searchAndHighlight(t,e){const i=this.blocks_[this.currentBlockIndex_];this.searchText_=t.trim(),this.clearBlocks(),this.blocks_=this.getMatchingBlocks_(this.workspace_,this.searchText_,this.caseSensitive),this.highlightSearchGroup_(this.blocks_);let s=0;e&&(s=this.blocks_.indexOf(i),s=s>-1?s:0),this.setCurrentBlock_(s)}getSearchPool_(t){return t.getAllBlocks(!0).filter(t=>{const e=t.getSurroundParent();return!e||!e.isCollapsed()})}isBlockMatch_(t,e,i){let s="";if(t.isCollapsed())s=t.toString();else{const e=[];t.inputList.forEach(t=>{t.fieldRow.forEach(t=>{e.push(t.getText())})}),s=e.join(" ").trim()}return i||(s=s.toLowerCase()),s.indexOf(e)>-1}getMatchingBlocks_(t,e,i){if(!e)return[];return this.caseSensitive||(e=e.toLowerCase()),this.getSearchPool_(t).filter(t=>this.isBlockMatch_(t,e,i))}clearBlocks(){this.unhighlightSearchGroup_(this.blocks_);const t=this.blocks_[this.currentBlockIndex_];t&&this.unhighlightCurrentSelection_(t),this.currentBlockIndex_=-1,this.blocks_=[]}highlightCurrentSelection_(t){const e=t.pathObject.svgPath;o.utils.dom.addClass(e,"blockly-ws-search-current")}unhighlightCurrentSelection_(t){const e=t.pathObject.svgPath;o.utils.dom.removeClass(e,"blockly-ws-search-current")}highlightSearchGroup_(t){t.forEach(t=>{const e=t.pathObject.svgPath;o.utils.dom.addClass(e,"blockly-ws-search-highlight")})}unhighlightSearchGroup_(t){t.forEach(t=>{const e=t.pathObject.svgPath;o.utils.dom.removeClass(e,"blockly-ws-search-highlight")})}scrollToVisible_(t){if(!this.workspace_.isMovable())return;const e=t.getRelativeToSurfaceXY(),i=this.workspace_.scale,s=t.width*i,n=t.height*i,o=e.y*i,l=(e.y+t.height)*i,c=this.workspace_.RTL?e.x*i-s:e.x*i,h=this.workspace_.RTL?e.x*i:e.x*i+s,r=this.workspace_.getMetrics();let a=r.viewLeft;const d=c<r.viewLeft,u=h>r.viewLeft+r.viewWidth,p=s>r.viewWidth;!p&&d||p&&!this.workspace_.RTL?a=c:(!p&&u||p&&this.workspace_.RTL)&&(a=h-r.viewWidth);let _=r.viewTop;const g=o<r.viewTop,b=l>r.viewTop+r.viewHeight,y=n>r.viewHeight;if(g||y&&b?_=o:b&&(_=l-r.viewHeight),a!==r.viewLeft||_!==r.viewTop){const t=document.activeElement;this.workspace_.scroll(-a,-_),t&&t.focus()}}}
3181
+ /**
3182
+ * @license
3183
+ * Copyright 2020 Google LLC
3184
+ * SPDX-License-Identifier: Apache-2.0
3185
+ */}])}));
3186
+ //# sourceMappingURL=index.js.map
3130
3187
  // This file was automatically generated. Do not modify.
3131
3188
 
3132
3189
  'use strict';
@@ -7173,7 +7230,7 @@ var pxt;
7173
7230
  var pxt;
7174
7231
  (function (pxt) {
7175
7232
  var blocks;
7176
- (function (blocks) {
7233
+ (function (blocks_4) {
7177
7234
  const typeDefaults = {
7178
7235
  "string": {
7179
7236
  field: "TEXT",
@@ -7197,8 +7254,8 @@ var pxt;
7197
7254
  }
7198
7255
  };
7199
7256
  // Add numbers before input names to prevent clashes with the ones added by BlocklyLoader
7200
- blocks.optionalDummyInputPrefix = "0_optional_dummy";
7201
- blocks.optionalInputWithFieldPrefix = "0_optional_field";
7257
+ blocks_4.optionalDummyInputPrefix = "0_optional_dummy";
7258
+ blocks_4.optionalInputWithFieldPrefix = "0_optional_field";
7202
7259
  // Matches arrays
7203
7260
  function isArrayType(type) {
7204
7261
  const arrayTypeRegex = /^(?:Array<(.+)>)|(?:(.+)\[\])|(?:\[.+\])$/;
@@ -7219,7 +7276,7 @@ var pxt;
7219
7276
  return undefined;
7220
7277
  }
7221
7278
  }
7222
- blocks.isArrayType = isArrayType;
7279
+ blocks_4.isArrayType = isArrayType;
7223
7280
  // Matches tuples
7224
7281
  function isTupleType(type) {
7225
7282
  const tupleTypeRegex = /^\[(.+)\]$/;
@@ -7233,7 +7290,7 @@ var pxt;
7233
7290
  return undefined;
7234
7291
  }
7235
7292
  }
7236
- blocks.isTupleType = isTupleType;
7293
+ blocks_4.isTupleType = isTupleType;
7237
7294
  const primitiveTypeRegex = /^(string|number|boolean)$/;
7238
7295
  // list of built-in blocks, should be touched.
7239
7296
  let _builtinBlocks;
@@ -7245,8 +7302,8 @@ var pxt;
7245
7302
  }
7246
7303
  return _builtinBlocks;
7247
7304
  }
7248
- blocks.builtinBlocks = builtinBlocks;
7249
- blocks.buildinBlockStatements = {
7305
+ blocks_4.builtinBlocks = builtinBlocks;
7306
+ blocks_4.buildinBlockStatements = {
7250
7307
  "controls_if": true,
7251
7308
  "controls_for": true,
7252
7309
  "pxt_controls_for": true,
@@ -7265,7 +7322,7 @@ var pxt;
7265
7322
  let b = cachedBlocks[type];
7266
7323
  return b ? b.fn : undefined;
7267
7324
  }
7268
- blocks.blockSymbol = blockSymbol;
7325
+ blocks_4.blockSymbol = blockSymbol;
7269
7326
  function createShadowValue(info, p, shadowId, defaultV) {
7270
7327
  defaultV = defaultV || p.defaultValue;
7271
7328
  shadowId = shadowId || p.shadowBlockId;
@@ -7390,7 +7447,7 @@ var pxt;
7390
7447
  }
7391
7448
  return value;
7392
7449
  }
7393
- blocks.createShadowValue = createShadowValue;
7450
+ blocks_4.createShadowValue = createShadowValue;
7394
7451
  function buildArrayShadow(shadow, blockType, fieldName, fieldValues) {
7395
7452
  const itemCount = fieldValues ? fieldValues.length : 2;
7396
7453
  const mut = document.createElement('mutation');
@@ -7419,7 +7476,7 @@ var pxt;
7419
7476
  headingLabel.setAttribute('web-class', 'blocklyFlyoutHeading');
7420
7477
  return headingLabel;
7421
7478
  }
7422
- blocks.createFlyoutHeadingLabel = createFlyoutHeadingLabel;
7479
+ blocks_4.createFlyoutHeadingLabel = createFlyoutHeadingLabel;
7423
7480
  function createFlyoutGroupLabel(name, icon, labelLineWidth, helpCallback) {
7424
7481
  const groupLabel = createFlyoutLabel(name, undefined, icon);
7425
7482
  groupLabel.setAttribute('web-class', 'blocklyFlyoutGroup');
@@ -7432,7 +7489,7 @@ var pxt;
7432
7489
  }
7433
7490
  return groupLabel;
7434
7491
  }
7435
- blocks.createFlyoutGroupLabel = createFlyoutGroupLabel;
7492
+ blocks_4.createFlyoutGroupLabel = createFlyoutGroupLabel;
7436
7493
  function createFlyoutLabel(name, color, icon, iconClass) {
7437
7494
  // Add the Heading label
7438
7495
  let headingLabel = Blockly.utils.xml.createElement('label');
@@ -7458,7 +7515,7 @@ var pxt;
7458
7515
  button.setAttribute('callbackKey', callbackKey);
7459
7516
  return button;
7460
7517
  }
7461
- blocks.createFlyoutButton = createFlyoutButton;
7518
+ blocks_4.createFlyoutButton = createFlyoutButton;
7462
7519
  function createToolboxBlock(info, fn, comp) {
7463
7520
  //
7464
7521
  // toolbox update
@@ -7527,14 +7584,14 @@ var pxt;
7527
7584
  }
7528
7585
  return block;
7529
7586
  }
7530
- blocks.createToolboxBlock = createToolboxBlock;
7587
+ blocks_4.createToolboxBlock = createToolboxBlock;
7531
7588
  function injectBlocks(blockInfo) {
7532
7589
  cachedBlockInfo = blockInfo;
7533
7590
  Blockly.pxtBlocklyUtils.whitelistDraggableBlockTypes(blockInfo.blocks.filter(fn => fn.attributes.duplicateShadowOnDrag).map(fn => fn.attributes.blockId));
7534
7591
  // inject Blockly with all block definitions
7535
7592
  return blockInfo.blocks
7536
7593
  .map(fn => {
7537
- const comp = blocks.compileInfo(fn);
7594
+ const comp = blocks_4.compileInfo(fn);
7538
7595
  const block = createToolboxBlock(blockInfo, fn, comp);
7539
7596
  if (fn.attributes.blockBuiltin) {
7540
7597
  pxt.Util.assert(!!builtinBlocks()[fn.attributes.blockId]);
@@ -7548,7 +7605,7 @@ var pxt;
7548
7605
  return fn;
7549
7606
  });
7550
7607
  }
7551
- blocks.injectBlocks = injectBlocks;
7608
+ blocks_4.injectBlocks = injectBlocks;
7552
7609
  function injectBlockDefinition(info, fn, comp, blockXml) {
7553
7610
  let id = fn.attributes.blockId;
7554
7611
  if (builtinBlocks()[id]) {
@@ -7669,14 +7726,14 @@ var pxt;
7669
7726
  buildBlockFromDef(fn.attributes._def);
7670
7727
  let hasHandler = false;
7671
7728
  if (fn.attributes.mutate) {
7672
- blocks.addMutation(block, fn, fn.attributes.mutate);
7729
+ blocks_4.addMutation(block, fn, fn.attributes.mutate);
7673
7730
  }
7674
7731
  else if (fn.attributes.defaultInstance) {
7675
- blocks.addMutation(block, fn, blocks.MutatorTypes.DefaultInstanceMutator);
7732
+ blocks_4.addMutation(block, fn, blocks_4.MutatorTypes.DefaultInstanceMutator);
7676
7733
  }
7677
7734
  else if (fn.attributes._expandedDef && fn.attributes.expandableArgumentMode !== "disabled") {
7678
7735
  const shouldToggle = fn.attributes.expandableArgumentMode === "toggle";
7679
- blocks.initExpandableBlock(info, block, fn.attributes._expandedDef, comp, shouldToggle, () => buildBlockFromDef(fn.attributes._expandedDef, true));
7736
+ blocks_4.initExpandableBlock(info, block, fn.attributes._expandedDef, comp, shouldToggle, () => buildBlockFromDef(fn.attributes._expandedDef, true));
7680
7737
  }
7681
7738
  else if (comp.handlerArgs.length) {
7682
7739
  /**
@@ -7686,7 +7743,7 @@ var pxt;
7686
7743
  */
7687
7744
  hasHandler = true;
7688
7745
  if (fn.attributes.optionalVariableArgs) {
7689
- blocks.initVariableArgsBlock(block, comp.handlerArgs);
7746
+ blocks_4.initVariableArgsBlock(block, comp.handlerArgs);
7690
7747
  }
7691
7748
  else if (fn.attributes.draggableParameters) {
7692
7749
  comp.handlerArgs.filter(a => !a.inBlockDef).forEach(arg => {
@@ -7707,7 +7764,7 @@ var pxt;
7707
7764
  }
7708
7765
  }
7709
7766
  // Add mutation to save and restore custom field settings
7710
- blocks.appendMutation(block, {
7767
+ blocks_4.appendMutation(block, {
7711
7768
  mutationToDom: (el) => {
7712
7769
  block.inputList.forEach(input => {
7713
7770
  input.fieldRow.forEach((fieldRow) => {
@@ -7885,7 +7942,7 @@ var pxt;
7885
7942
  blocksInfo: info
7886
7943
  };
7887
7944
  pxt.Util.jsonMergeFrom(options, fn.attributes.paramFieldEditorOptions && fn.attributes.paramFieldEditorOptions[actName] || {});
7888
- fields.push(namedField(blocks.createFieldEditor(customField, defl, options), defName));
7945
+ fields.push(namedField(blocks_4.createFieldEditor(customField, defl, options), defName));
7889
7946
  }
7890
7947
  else
7891
7948
  fields.push(namedField(new Blockly.FieldDropdown(dd), defName));
@@ -7899,7 +7956,7 @@ var pxt;
7899
7956
  blocksInfo: info
7900
7957
  };
7901
7958
  pxt.Util.jsonMergeFrom(options, fn.attributes.paramFieldEditorOptions && fn.attributes.paramFieldEditorOptions[pr.actualName] || {});
7902
- fields.push(namedField(blocks.createFieldEditor(customField, defl, options), pr.definitionName));
7959
+ fields.push(namedField(blocks_4.createFieldEditor(customField, defl, options), pr.definitionName));
7903
7960
  }
7904
7961
  else {
7905
7962
  inputName = defName;
@@ -7925,7 +7982,7 @@ var pxt;
7925
7982
  input.setAlign(Blockly.ALIGN_LEFT);
7926
7983
  }
7927
7984
  else if (expanded) {
7928
- const prefix = hasParameter ? blocks.optionalInputWithFieldPrefix : blocks.optionalDummyInputPrefix;
7985
+ const prefix = hasParameter ? blocks_4.optionalInputWithFieldPrefix : blocks_4.optionalDummyInputPrefix;
7929
7986
  input = block.appendDummyInput(prefix + (anonIndex++));
7930
7987
  }
7931
7988
  else {
@@ -7964,13 +8021,13 @@ var pxt;
7964
8021
  var _a;
7965
8022
  return !!((_a = fn.parameters) === null || _a === void 0 ? void 0 : _a.some(pr => pxtc.parameterTypeIsArrowFunction(pr)));
7966
8023
  }
7967
- blocks.hasArrowFunction = hasArrowFunction;
8024
+ blocks_4.hasArrowFunction = hasArrowFunction;
7968
8025
  function cleanBlocks() {
7969
8026
  pxt.debug('removing all custom blocks');
7970
8027
  for (const b in cachedBlocks)
7971
8028
  removeBlock(cachedBlocks[b].fn);
7972
8029
  }
7973
- blocks.cleanBlocks = cleanBlocks;
8030
+ blocks_4.cleanBlocks = cleanBlocks;
7974
8031
  /**
7975
8032
  * Used by pxtrunner to initialize blocks in the docs
7976
8033
  */
@@ -7978,7 +8035,7 @@ var pxt;
7978
8035
  init();
7979
8036
  injectBlocks(blockInfo);
7980
8037
  }
7981
- blocks.initializeAndInject = initializeAndInject;
8038
+ blocks_4.initializeAndInject = initializeAndInject;
7982
8039
  /**
7983
8040
  * Used by main app to initialize blockly blocks.
7984
8041
  * Blocks are injected separately by called injectBlocks
@@ -7987,7 +8044,7 @@ var pxt;
7987
8044
  init();
7988
8045
  initJresIcons(blockInfo);
7989
8046
  }
7990
- blocks.initialize = initialize;
8047
+ blocks_4.initialize = initialize;
7991
8048
  let blocklyInitialized = false;
7992
8049
  function init() {
7993
8050
  if (blocklyInitialized)
@@ -7997,7 +8054,7 @@ var pxt;
7997
8054
  goog.require('Blockly.Blocks');
7998
8055
  Blockly.FieldCheckbox.CHECK_CHAR = '■';
7999
8056
  Blockly.Constants.ADD_START_HATS = !!pxt.appTarget.appTheme.blockHats;
8000
- blocks.initFieldEditors();
8057
+ blocks_4.initFieldEditors();
8001
8058
  initContextMenu();
8002
8059
  initOnStart();
8003
8060
  initMath();
@@ -8103,7 +8160,7 @@ var pxt;
8103
8160
  if (undeletable)
8104
8161
  block.setDeletable(false);
8105
8162
  let tb = document.getElementById('blocklyToolboxDefinition');
8106
- let xml = tb ? blocks.getFirstChildWithAttr(tb, "block", "type", id) : undefined;
8163
+ let xml = tb ? blocks_4.getFirstChildWithAttr(tb, "block", "type", id) : undefined;
8107
8164
  block.codeCard = {
8108
8165
  header: name,
8109
8166
  name: name,
@@ -8139,7 +8196,7 @@ var pxt;
8139
8196
  setHelpResources(this, id, name, tooltip, url, colour, colourSecondary, colourTertiary);
8140
8197
  };
8141
8198
  }
8142
- blocks.installHelpResources = installHelpResources;
8199
+ blocks_4.installHelpResources = installHelpResources;
8143
8200
  function initLists() {
8144
8201
  const msg = Blockly.Msg;
8145
8202
  // lists_create_with
@@ -8386,7 +8443,7 @@ var pxt;
8386
8443
  }
8387
8444
  };
8388
8445
  }
8389
- blocks.onShowContextMenu = undefined;
8446
+ blocks_4.onShowContextMenu = undefined;
8390
8447
  /**
8391
8448
  * The following patch to blockly is to add the Trash icon on top of the toolbox,
8392
8449
  * the trash icon should only show when a user drags a block that is already in the workspace.
@@ -8585,8 +8642,8 @@ var pxt;
8585
8642
  options.push(screenshotOption);
8586
8643
  }
8587
8644
  // custom options...
8588
- if (blocks.onShowContextMenu)
8589
- blocks.onShowContextMenu(this, options);
8645
+ if (blocks_4.onShowContextMenu)
8646
+ blocks_4.onShowContextMenu(this, options);
8590
8647
  };
8591
8648
  // Get rid of bumping behavior
8592
8649
  Blockly.Constants.Logic.LOGIC_COMPARE_ONCHANGE_MIXIN.onchange = function () { };
@@ -8936,8 +8993,8 @@ var pxt;
8936
8993
  const mathModuloDef = pxt.blocks.getBlockDefinition(mathModuloId);
8937
8994
  msg.MATH_MODULO_TITLE = mathModuloDef.block["MATH_MODULO_TITLE"];
8938
8995
  installBuiltinHelpInfo(mathModuloId);
8939
- blocks.initMathOpBlock();
8940
- blocks.initMathRoundBlock();
8996
+ blocks_4.initMathOpBlock();
8997
+ blocks_4.initMathRoundBlock();
8941
8998
  }
8942
8999
  function initVariables() {
8943
9000
  // We only give types to "special" variables like enum members and we don't
@@ -9281,7 +9338,7 @@ var pxt;
9281
9338
  const functionReturnId = "function_return";
9282
9339
  Blockly.Blocks[functionReturnId] = {
9283
9340
  init: function () {
9284
- blocks.initReturnStatement(this);
9341
+ blocks_4.initReturnStatement(this);
9285
9342
  },
9286
9343
  onchange: function (event) {
9287
9344
  const block = this;
@@ -9694,7 +9751,7 @@ var pxt;
9694
9751
  value.appendChild(shadow);
9695
9752
  return block;
9696
9753
  }
9697
- blocks.mkPredicateBlock = mkPredicateBlock;
9754
+ blocks_4.mkPredicateBlock = mkPredicateBlock;
9698
9755
  function mkFieldBlock(type, fieldName, fieldValue, isShadow) {
9699
9756
  const fieldBlock = document.createElement(isShadow ? "shadow" : "block");
9700
9757
  fieldBlock.setAttribute("type", pxt.Util.htmlEscape(type));
@@ -9704,7 +9761,7 @@ var pxt;
9704
9761
  fieldBlock.appendChild(field);
9705
9762
  return fieldBlock;
9706
9763
  }
9707
- blocks.mkFieldBlock = mkFieldBlock;
9764
+ blocks_4.mkFieldBlock = mkFieldBlock;
9708
9765
  function mkReturnStatementBlock() {
9709
9766
  const block = document.createElement("block");
9710
9767
  block.setAttribute("type", "function_return");
@@ -9715,7 +9772,7 @@ var pxt;
9715
9772
  value.appendChild(shadow);
9716
9773
  return block;
9717
9774
  }
9718
- blocks.mkReturnStatementBlock = mkReturnStatementBlock;
9775
+ blocks_4.mkReturnStatementBlock = mkReturnStatementBlock;
9719
9776
  let jresIconCache = {};
9720
9777
  function iconToFieldImage(id) {
9721
9778
  let url = jresIconCache[id];
@@ -9774,7 +9831,7 @@ var pxt;
9774
9831
  && sym.attributes.fixedInstance
9775
9832
  && isSubtype(apis, sym.retType, qName));
9776
9833
  }
9777
- blocks.getFixedInstanceDropdownValues = getFixedInstanceDropdownValues;
9834
+ blocks_4.getFixedInstanceDropdownValues = getFixedInstanceDropdownValues;
9778
9835
  function generateIcons(instanceSymbols) {
9779
9836
  const imgConv = new pxt.ImageConverter();
9780
9837
  instanceSymbols.forEach(v => {
@@ -9783,7 +9840,7 @@ var pxt;
9783
9840
  }
9784
9841
  });
9785
9842
  }
9786
- blocks.generateIcons = generateIcons;
9843
+ blocks_4.generateIcons = generateIcons;
9787
9844
  function getConstantDropdownValues(apis, qName) {
9788
9845
  return pxt.Util.values(apis.byQName).filter(sym => sym.attributes.blockIdentity === qName);
9789
9846
  }
@@ -9827,7 +9884,7 @@ var pxt;
9827
9884
  varField.setValue(model.getId());
9828
9885
  }
9829
9886
  }
9830
- blocks.setVarFieldValue = setVarFieldValue;
9887
+ blocks_4.setVarFieldValue = setVarFieldValue;
9831
9888
  function getBlockData(block) {
9832
9889
  if (!block.data) {
9833
9890
  return {
@@ -9843,21 +9900,52 @@ var pxt;
9843
9900
  }
9844
9901
  return JSON.parse(block.data);
9845
9902
  }
9846
- blocks.getBlockData = getBlockData;
9903
+ blocks_4.getBlockData = getBlockData;
9847
9904
  function setBlockData(block, data) {
9848
9905
  block.data = JSON.stringify(data);
9849
9906
  }
9850
- blocks.setBlockData = setBlockData;
9907
+ blocks_4.setBlockData = setBlockData;
9851
9908
  function setBlockDataForField(block, field, data) {
9852
9909
  const blockData = getBlockData(block);
9853
9910
  blockData.fieldData[field] = data;
9854
9911
  setBlockData(block, blockData);
9855
9912
  }
9856
- blocks.setBlockDataForField = setBlockDataForField;
9913
+ blocks_4.setBlockDataForField = setBlockDataForField;
9857
9914
  function getBlockDataForField(block, field) {
9858
9915
  return getBlockData(block).fieldData[field];
9859
9916
  }
9860
- blocks.getBlockDataForField = getBlockDataForField;
9917
+ blocks_4.getBlockDataForField = getBlockDataForField;
9918
+ class PxtWorkspaceSearch extends WorkspaceSearch {
9919
+ createDom_() {
9920
+ super.createDom_();
9921
+ this.addEvent_(this.workspace_.getInjectionDiv(), "click", this, (e) => {
9922
+ if (!this.htmlDiv_.contains(e.target)) {
9923
+ this.close();
9924
+ }
9925
+ });
9926
+ }
9927
+ highlightSearchGroup_(blocks) {
9928
+ blocks.forEach((block) => {
9929
+ const blockPath = block.pathObject.svgPath;
9930
+ Blockly.utils.dom.addClass(blockPath, 'blockly-ws-search-highlight-pxt');
9931
+ });
9932
+ }
9933
+ unhighlightSearchGroup_(blocks) {
9934
+ blocks.forEach((block) => {
9935
+ const blockPath = block.pathObject.svgPath;
9936
+ Blockly.utils.dom.removeClass(blockPath, 'blockly-ws-search-highlight-pxt');
9937
+ });
9938
+ }
9939
+ open() {
9940
+ super.open();
9941
+ Blockly.utils.dom.addClass(this.workspace_.getInjectionDiv(), 'blockly-ws-searching');
9942
+ }
9943
+ close() {
9944
+ super.close();
9945
+ Blockly.utils.dom.removeClass(this.workspace_.getInjectionDiv(), 'blockly-ws-searching');
9946
+ }
9947
+ }
9948
+ blocks_4.PxtWorkspaceSearch = PxtWorkspaceSearch;
9861
9949
  })(blocks = pxt.blocks || (pxt.blocks = {}));
9862
9950
  })(pxt || (pxt = {}));
9863
9951
  var pxt;
@@ -10353,7 +10441,7 @@ var pxt;
10353
10441
  var pxt;
10354
10442
  (function (pxt) {
10355
10443
  var blocks;
10356
- (function (blocks_4) {
10444
+ (function (blocks_5) {
10357
10445
  let workspace;
10358
10446
  let blocklyDiv;
10359
10447
  let BlockLayout;
@@ -10363,7 +10451,7 @@ var pxt;
10363
10451
  // Shuffle deprecated
10364
10452
  BlockLayout[BlockLayout["Clean"] = 3] = "Clean";
10365
10453
  BlockLayout[BlockLayout["Flow"] = 4] = "Flow";
10366
- })(BlockLayout = blocks_4.BlockLayout || (blocks_4.BlockLayout = {}));
10454
+ })(BlockLayout = blocks_5.BlockLayout || (blocks_5.BlockLayout = {}));
10367
10455
  function initRenderingWorkspace() {
10368
10456
  if (!workspace) {
10369
10457
  blocklyDiv = document.createElement("div");
@@ -10387,7 +10475,7 @@ var pxt;
10387
10475
  pxt.blocks.clearWithoutEvents(workspace);
10388
10476
  return workspace;
10389
10477
  }
10390
- blocks_4.initRenderingWorkspace = initRenderingWorkspace;
10478
+ blocks_5.initRenderingWorkspace = initRenderingWorkspace;
10391
10479
  function cleanRenderingWorkspace() {
10392
10480
  // We re-use the workspace across renders, catch any errors so we know to
10393
10481
  // create a new workspace if there was an error
@@ -10395,7 +10483,7 @@ var pxt;
10395
10483
  workspace.dispose();
10396
10484
  workspace = undefined;
10397
10485
  }
10398
- blocks_4.cleanRenderingWorkspace = cleanRenderingWorkspace;
10486
+ blocks_5.cleanRenderingWorkspace = cleanRenderingWorkspace;
10399
10487
  function renderWorkspace(options = { emPixels: 18, layout: BlockLayout.Align }) {
10400
10488
  const layout = options.splitSvg ? BlockLayout.Align : (options.layout || BlockLayout.Flow);
10401
10489
  switch (layout) {
@@ -10426,7 +10514,7 @@ var pxt;
10426
10514
  ? pxt.blocks.layout.splitSvg(svg, workspace, options.emPixels)
10427
10515
  : svg;
10428
10516
  }
10429
- blocks_4.renderWorkspace = renderWorkspace;
10517
+ blocks_5.renderWorkspace = renderWorkspace;
10430
10518
  function render(blocksXml, options = { emPixels: 18, layout: BlockLayout.Align }) {
10431
10519
  initRenderingWorkspace();
10432
10520
  try {
@@ -10443,7 +10531,7 @@ var pxt;
10443
10531
  cleanRenderingWorkspace();
10444
10532
  }
10445
10533
  }
10446
- blocks_4.render = render;
10534
+ blocks_5.render = render;
10447
10535
  function blocksMetrics(ws) {
10448
10536
  const blocks = ws.getTopBlocks(false);
10449
10537
  if (!blocks.length)
@@ -10465,7 +10553,7 @@ var pxt;
10465
10553
  height: m.b - m.t
10466
10554
  };
10467
10555
  }
10468
- blocks_4.blocksMetrics = blocksMetrics;
10556
+ blocks_5.blocksMetrics = blocksMetrics;
10469
10557
  })(blocks = pxt.blocks || (pxt.blocks = {}));
10470
10558
  })(pxt || (pxt = {}));
10471
10559
  /// <reference path="../localtypings/blockly.d.ts" />
@@ -10473,7 +10561,7 @@ var pxt;
10473
10561
  var pxt;
10474
10562
  (function (pxt) {
10475
10563
  var blocks;
10476
- (function (blocks_5) {
10564
+ (function (blocks_6) {
10477
10565
  function findRootBlocks(xmlDOM, type) {
10478
10566
  let blocks = [];
10479
10567
  for (const child in xmlDOM.children) {
@@ -10498,14 +10586,14 @@ var pxt;
10498
10586
  }
10499
10587
  return blocks;
10500
10588
  }
10501
- blocks_5.findRootBlocks = findRootBlocks;
10589
+ blocks_6.findRootBlocks = findRootBlocks;
10502
10590
  function findRootBlock(xmlDOM, type) {
10503
10591
  let blks = findRootBlocks(xmlDOM, type);
10504
10592
  if (blks.length)
10505
10593
  return blks[0];
10506
10594
  return null;
10507
10595
  }
10508
- blocks_5.findRootBlock = findRootBlock;
10596
+ blocks_6.findRootBlock = findRootBlock;
10509
10597
  })(blocks = pxt.blocks || (pxt.blocks = {}));
10510
10598
  })(pxt || (pxt = {}));
10511
10599
  var pxt;
@@ -13619,7 +13707,8 @@ var pxtblockly;
13619
13707
  }
13620
13708
  // The height of the preview on the block itself
13621
13709
  getPreviewHeight() {
13622
- return this.constants_.FIELD_BORDER_RECT_HEIGHT;
13710
+ var _a;
13711
+ return ((_a = this.getConstants()) === null || _a === void 0 ? void 0 : _a.FIELD_BORDER_RECT_HEIGHT) || 16;
13623
13712
  }
13624
13713
  getDropdownBackgroundColour() {
13625
13714
  if (this.sourceBlock_.parentBlock_) {
@@ -15864,7 +15953,8 @@ var pxtblockly;
15864
15953
  return this.pythonMode ? pxt.Util.lf("<python code>") : this.getValue();
15865
15954
  }
15866
15955
  applyColour() {
15867
- if (this.sourceBlock_ && this.constants_.FULL_BLOCK_FIELDS) {
15956
+ var _a;
15957
+ if (this.sourceBlock_ && ((_a = this.getConstants()) === null || _a === void 0 ? void 0 : _a.FULL_BLOCK_FIELDS)) {
15868
15958
  if (this.borderRect_) {
15869
15959
  this.borderRect_.setAttribute('stroke', this.sourceBlock_.style.colourTertiary);
15870
15960
  }
@@ -260,6 +260,13 @@ declare namespace pxt.blocks {
260
260
  function setBlockData(block: Blockly.Block, data: PXTBlockData): void;
261
261
  function setBlockDataForField(block: Blockly.Block, field: string, data: string): void;
262
262
  function getBlockDataForField(block: Blockly.Block, field: string): string;
263
+ class PxtWorkspaceSearch extends WorkspaceSearch {
264
+ protected createDom_(): void;
265
+ protected highlightSearchGroup_(blocks: Blockly.BlockSvg[]): void;
266
+ protected unhighlightSearchGroup_(blocks: Blockly.BlockSvg[]): void;
267
+ open(): void;
268
+ close(): void;
269
+ }
263
270
  }
264
271
  declare namespace pxt.blocks {
265
272
  /**