pxt-core 7.4.20 → 7.4.24

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/built/cli.js CHANGED
@@ -1757,11 +1757,17 @@ async function buildSemanticUIAsync(parsed) {
1757
1757
  "--include-path=" + lessIncludePaths
1758
1758
  ]
1759
1759
  });
1760
+ let fontAwesomeSource = "node_modules/@fortawesome/fontawesome-free/webfonts/";
1761
+ if (!fs.existsSync(fontAwesomeSource)) {
1762
+ fontAwesomeSource = "node_modules/pxt-core/" + fontAwesomeSource;
1763
+ }
1760
1764
  // Inline all of our icon fonts
1761
1765
  let semCss = await readFileAsync('built/web/semantic.css', "utf8");
1762
1766
  semCss = await linkFontAsync("icons", semCss);
1763
1767
  semCss = await linkFontAsync("outline-icons", semCss);
1764
1768
  semCss = await linkFontAsync("brand-icons", semCss);
1769
+ semCss = await linkFontAsync("fa-solid-900", semCss, fontAwesomeSource, "\\.\\.\\/webfonts\\/");
1770
+ semCss = await linkFontAsync("fa-regular-400", semCss, fontAwesomeSource, "\\.\\.\\/webfonts\\/");
1765
1771
  // Append icons.css to semantic.css (custom pxt icons)
1766
1772
  const iconsFile = isPxtCore ? 'built/web/icons.css' : 'node_modules/pxt-core/built/web/icons.css';
1767
1773
  const iconsCss = await readFileAsync(iconsFile, "utf8");
@@ -1791,10 +1797,6 @@ async function buildSemanticUIAsync(parsed) {
1791
1797
  "--include-path=" + lessIncludePaths
1792
1798
  ]
1793
1799
  });
1794
- let fontAwesomeSource = "node_modules/@fortawesome/fontawesome-free/webfonts/";
1795
- if (!fs.existsSync(fontAwesomeSource)) {
1796
- fontAwesomeSource = "node_modules/pxt-core/" + fontAwesomeSource;
1797
- }
1798
1800
  let skillmapCss = await readFileAsync(`built/web/react-common-skillmap.css`, "utf8");
1799
1801
  skillmapCss = await linkFontAsync("fa-solid-900", skillmapCss, fontAwesomeSource, "\\.\\.\\/webfonts\\/");
1800
1802
  skillmapCss = await linkFontAsync("fa-regular-400", skillmapCss, fontAwesomeSource, "\\.\\.\\/webfonts\\/");
package/built/pxt.js CHANGED
@@ -157707,11 +157707,17 @@ async function buildSemanticUIAsync(parsed) {
157707
157707
  "--include-path=" + lessIncludePaths
157708
157708
  ]
157709
157709
  });
157710
+ let fontAwesomeSource = "node_modules/@fortawesome/fontawesome-free/webfonts/";
157711
+ if (!fs.existsSync(fontAwesomeSource)) {
157712
+ fontAwesomeSource = "node_modules/pxt-core/" + fontAwesomeSource;
157713
+ }
157710
157714
  // Inline all of our icon fonts
157711
157715
  let semCss = await readFileAsync('built/web/semantic.css', "utf8");
157712
157716
  semCss = await linkFontAsync("icons", semCss);
157713
157717
  semCss = await linkFontAsync("outline-icons", semCss);
157714
157718
  semCss = await linkFontAsync("brand-icons", semCss);
157719
+ semCss = await linkFontAsync("fa-solid-900", semCss, fontAwesomeSource, "\\.\\.\\/webfonts\\/");
157720
+ semCss = await linkFontAsync("fa-regular-400", semCss, fontAwesomeSource, "\\.\\.\\/webfonts\\/");
157715
157721
  // Append icons.css to semantic.css (custom pxt icons)
157716
157722
  const iconsFile = isPxtCore ? 'built/web/icons.css' : 'node_modules/pxt-core/built/web/icons.css';
157717
157723
  const iconsCss = await readFileAsync(iconsFile, "utf8");
@@ -157741,10 +157747,6 @@ async function buildSemanticUIAsync(parsed) {
157741
157747
  "--include-path=" + lessIncludePaths
157742
157748
  ]
157743
157749
  });
157744
- let fontAwesomeSource = "node_modules/@fortawesome/fontawesome-free/webfonts/";
157745
- if (!fs.existsSync(fontAwesomeSource)) {
157746
- fontAwesomeSource = "node_modules/pxt-core/" + fontAwesomeSource;
157747
- }
157748
157750
  let skillmapCss = await readFileAsync(`built/web/react-common-skillmap.css`, "utf8");
157749
157751
  skillmapCss = await linkFontAsync("fa-solid-900", skillmapCss, fontAwesomeSource, "\\.\\.\\/webfonts\\/");
157750
157752
  skillmapCss = await linkFontAsync("fa-regular-400", skillmapCss, fontAwesomeSource, "\\.\\.\\/webfonts\\/");
@@ -1656,7 +1656,7 @@ return Blockly.Functions.namesInUse(b,null,a)[c]?(Blockly.alert(Blockly.Msg.VARI
1656
1656
  Blockly.Functions.mutateCallersAndDefinition=function(a,b,c){var d=Blockly.Functions.getDefinition(a,b);d?(a=Blockly.Functions.getCallers(a,d.workspace),a.push(d),Blockly.Events.setGroup(!0),a.forEach(function(a){var b=a.mutationToDom(),e=b&&Blockly.Xml.domToText(b);a.domToMutation(c);var h=a.mutationToDom(),k=h&&Blockly.Xml.domToText(h);if(e!=k)if(Blockly.Events.fire(new Blockly.Events.BlockChange(a,"mutation",null,e,k)),a.id==d.id){var l=Blockly.Functions.getArgMap(b),m=Blockly.Functions.getArgMap(h,
1657
1657
  !0);d.getDescendants().forEach(function(a){if(Blockly.pxtBlocklyUtils.isFunctionArgumentReporter(a)){var b=a.getFieldValue("VALUE"),c=l[b];m[c]?m[c]!==b&&a.setFieldValue(m[c],"VALUE"):a.dispose()}})}else setTimeout(function(){a.bumpNeighbours()},Blockly.BUMP_DELAY)}),Blockly.Events.setGroup(!1)):console.warn("Attempted to change function "+a+", but no definition block was found on the workspace")};
1658
1658
  Blockly.Functions.createFlyout=function(a,b){var c=new Blockly.Options({scrollbars:!0,disabledPatternId:a.options.disabledPatternId,parentWorkspace:a,rtl:a.RTL,oneBasedIndex:a.options.oneBasedIndex,horizontalLayout:a.horizontalLayout,toolboxPosition:a.options.toolboxPosition,zoomOptions:a.options.zoomOptions,renderer:a.options.renderer,rendererOverrides:a.options.rendererOverrides,newFunctions:a.options.newFunctions,move:{scrollbars:!0}});c=c.horizontalLayout?new Blockly.HorizontalFlyout(c):new Blockly.VerticalFlyout(c);
1659
- var d=c.createDom("svg");goog.dom.insertSiblingAfter(d,b);c.init(a);return c};Blockly.VERSION="4.0.7";Blockly.mainWorkspace=null;Blockly.selected=null;Blockly.draggingConnections=[];Blockly.clipboardXml_=null;Blockly.clipboardSource_=null;Blockly.clipboardTypeCounts_=null;Blockly.cache3dSupported_=null;Blockly.parentContainer=null;Blockly.svgSize=function(a){Blockly.utils.deprecation.warn("Blockly.svgSize","March 2021","March 2022","workspace.getCachedParentSvgSize");return new Blockly.utils.Size(a.cachedWidth_,a.cachedHeight_)};Blockly.resizeSvgContents=function(a){a.resizeContents()};
1659
+ var d=c.createDom("svg");goog.dom.insertSiblingAfter(d,b);c.init(a);return c};Blockly.VERSION="4.0.8";Blockly.mainWorkspace=null;Blockly.selected=null;Blockly.draggingConnections=[];Blockly.clipboardXml_=null;Blockly.clipboardSource_=null;Blockly.clipboardTypeCounts_=null;Blockly.cache3dSupported_=null;Blockly.parentContainer=null;Blockly.svgSize=function(a){Blockly.utils.deprecation.warn("Blockly.svgSize","March 2021","March 2022","workspace.getCachedParentSvgSize");return new Blockly.utils.Size(a.cachedWidth_,a.cachedHeight_)};Blockly.resizeSvgContents=function(a){a.resizeContents()};
1660
1660
  Blockly.svgResize=function(a){for(;a.options.parentWorkspace;)a=a.options.parentWorkspace;var b=a.getParentSvg(),c=a.getCachedParentSvgSize(),d=b.parentNode;if(d){var e=d.offsetWidth;d=d.offsetHeight;c.width!=e&&(b.setAttribute("width",e+"px"),a.setCachedParentSvgSize(e,null));c.height!=d&&(b.setAttribute("height",d+"px"),a.setCachedParentSvgSize(null,d));a.resize()}};
1661
1661
  Blockly.onKeyDown=function(a){var b=Blockly.mainWorkspace;if(b&&!(Blockly.utils.isTargetInput(a)||b.rendered&&!b.isVisible()))Blockly.ShortcutRegistry.registry.onKeyDown(b,a)};Blockly.deleteBlock=function(a){a.workspace.isFlyout||(Blockly.Events.setGroup(!0),Blockly.hideChaff(),a.outputConnection?a.dispose(!1,!0):a.dispose(!0,!0),Blockly.Events.setGroup(!1))};Blockly.copy=function(a){if(a=a.toCopyData())Blockly.clipboardXml_=a.xml,Blockly.clipboardSource_=a.source,Blockly.clipboardTypeCounts_=a.typeCounts};
1662
1662
  Blockly.paste=function(){if(!Blockly.clipboardXml_)return!1;var a=Blockly.clipboardSource_;a.isFlyout&&(a=a.targetWorkspace);return Blockly.clipboardTypeCounts_&&a.isCapacityAvailable(Blockly.clipboardTypeCounts_)?(Blockly.Events.setGroup(!0),a.paste(Blockly.clipboardXml_),Blockly.Events.setGroup(!1),!0):!1};
@@ -1986,8 +1986,7 @@ Blockly.ContextMenuItems.registerDisable=function(){Blockly.ContextMenuRegistry.
1986
1986
  scopeType:Blockly.ContextMenuRegistry.ScopeType.BLOCK,id:"blockDisable",weight:5})};
1987
1987
  Blockly.ContextMenuItems.registerDelete=function(){Blockly.ContextMenuRegistry.registry.register({displayText:function(a){var b=a.block;a=b.getDescendants(!1).length;(b=b.getNextBlock())&&(a-=b.getDescendants(!1).length);return 1==a?Blockly.Msg.DELETE_BLOCK:Blockly.Msg.DELETE_X_BLOCKS.replace("%1",String(a))},preconditionFn:function(a){return!a.block.isInFlyout&&a.block.isDeletable()?"enabled":"hidden"},callback:function(a){Blockly.Events.setGroup(!0);a.block&&Blockly.deleteBlock(a.block);Blockly.Events.setGroup(!1)},
1988
1988
  scopeType:Blockly.ContextMenuRegistry.ScopeType.BLOCK,id:"blockDelete",weight:6})};Blockly.ContextMenuItems.registerHelp=function(){Blockly.ContextMenuRegistry.registry.register({displayText:function(){return Blockly.Msg.HELP},preconditionFn:function(a){a=a.block;return("function"==typeof a.helpUrl?a.helpUrl():a.helpUrl)?"enabled":"hidden"},callback:function(a){a.block.showHelp()},scopeType:Blockly.ContextMenuRegistry.ScopeType.BLOCK,id:"blockHelp",weight:7})};
1989
- Blockly.ContextMenuItems.registerBlockOptions_=function(){Blockly.ContextMenuItems.registerDuplicate();Blockly.ContextMenuItems.registerComment();Blockly.ContextMenuItems.registerInline();Blockly.ContextMenuItems.registerCollapseExpandBlock();Blockly.ContextMenuItems.registerDisable();Blockly.ContextMenuItems.registerDelete();Blockly.ContextMenuItems.registerHelp()};Blockly.ContextMenuItems.registerDefaultOptions=function(){Blockly.ContextMenuItems.registerWorkspaceOptions_();Blockly.ContextMenuItems.registerBlockOptions_()};
1990
- Blockly.ContextMenuItems.registerDefaultOptions();Blockly.Mutator=function(a){Blockly.Mutator.superClass_.constructor.call(this,null);this.quarkNames_=a};Blockly.utils.object.inherits(Blockly.Mutator,Blockly.Icon);Blockly.Mutator.prototype.workspace_=null;Blockly.Mutator.prototype.workspaceWidth_=0;Blockly.Mutator.prototype.workspaceHeight_=0;Blockly.Mutator.prototype.setBlock=function(a){this.block_=a};Blockly.Mutator.prototype.getWorkspace=function(){return this.workspace_};
1989
+ Blockly.ContextMenuItems.registerBlockOptions_=function(){Blockly.ContextMenuItems.registerDuplicate();Blockly.ContextMenuItems.registerComment();Blockly.ContextMenuItems.registerCollapseExpandBlock();Blockly.ContextMenuItems.registerDisable();Blockly.ContextMenuItems.registerDelete();Blockly.ContextMenuItems.registerHelp()};Blockly.ContextMenuItems.registerDefaultOptions=function(){Blockly.ContextMenuItems.registerWorkspaceOptions_();Blockly.ContextMenuItems.registerBlockOptions_()};Blockly.ContextMenuItems.registerDefaultOptions();Blockly.Mutator=function(a){Blockly.Mutator.superClass_.constructor.call(this,null);this.quarkNames_=a};Blockly.utils.object.inherits(Blockly.Mutator,Blockly.Icon);Blockly.Mutator.prototype.workspace_=null;Blockly.Mutator.prototype.workspaceWidth_=0;Blockly.Mutator.prototype.workspaceHeight_=0;Blockly.Mutator.prototype.setBlock=function(a){this.block_=a};Blockly.Mutator.prototype.getWorkspace=function(){return this.workspace_};
1991
1990
  Blockly.Mutator.prototype.drawIcon_=function(a){Blockly.utils.dom.createSvgElement(Blockly.utils.Svg.RECT,{"class":"blocklyIconShape",rx:"10",ry:"10",height:"16",width:"16"},a);Blockly.utils.dom.createSvgElement(Blockly.utils.Svg.PATH,{"class":"blocklyIconSymbol",d:"m4.203,7.296 0,1.368 -0.92,0.677 -0.11,0.41 0.9,1.559 0.41,0.11 1.043,-0.457 1.187,0.683 0.127,1.134 0.3,0.3 1.8,0 0.3,-0.299 0.127,-1.138 1.185,-0.682 1.046,0.458 0.409,-0.11 0.9,-1.559 -0.11,-0.41 -0.92,-0.677 0,-1.366 0.92,-0.677 0.11,-0.41 -0.9,-1.559 -0.409,-0.109 -1.046,0.458 -1.185,-0.682 -0.127,-1.138 -0.3,-0.299 -1.8,0 -0.3,0.3 -0.126,1.135 -1.187,0.682 -1.043,-0.457 -0.41,0.11 -0.899,1.559 0.108,0.409z"},
1992
1991
  a);Blockly.utils.dom.createSvgElement(Blockly.utils.Svg.CIRCLE,{"class":"blocklyIconShape",r:"2.7",cx:"8",cy:"8"},a)};Blockly.Mutator.prototype.iconClick_=function(a){this.block_.isEditable()&&Blockly.Icon.prototype.iconClick_.call(this,a)};
1993
1992
  Blockly.Mutator.prototype.createEditor_=function(){this.svgDialog_=Blockly.utils.dom.createSvgElement(Blockly.utils.Svg.SVG,{x:Blockly.Bubble.BORDER_WIDTH,y:Blockly.Bubble.BORDER_WIDTH},null);if(this.quarkNames_.length)for(var a=Blockly.utils.xml.createElement("xml"),b=0,c;c=this.quarkNames_[b];b++){var d=Blockly.utils.xml.createElement("block");d.setAttribute("type",c);a.appendChild(d)}else a=null;b=new Blockly.Options({disable:!1,parentWorkspace:this.block_.workspace,media:this.block_.workspace.options.pathToMedia,
@@ -9931,7 +9930,7 @@ var pxt;
9931
9930
  createDom_() {
9932
9931
  super.createDom_();
9933
9932
  this.addEvent_(this.workspace_.getInjectionDiv(), "click", this, (e) => {
9934
- if (!this.htmlDiv_.contains(e.target)) {
9933
+ if (this.htmlDiv_.style.display == "flex" && !this.htmlDiv_.contains(e.target)) {
9935
9934
  this.close();
9936
9935
  }
9937
9936
  });
@@ -9948,8 +9947,71 @@ var pxt;
9948
9947
  Blockly.utils.dom.removeClass(blockPath, 'blockly-ws-search-highlight-pxt');
9949
9948
  });
9950
9949
  }
9950
+ /**
9951
+ * https://github.com/google/blockly-samples/blob/master/plugins/workspace-search/src/WorkspaceSearch.js#L633
9952
+ *
9953
+ * Modified to center offscreen blocks.
9954
+ */
9955
+ scrollToVisible_(block) {
9956
+ if (!this.workspace_.isMovable()) {
9957
+ // Cannot scroll to block in a non-movable workspace.
9958
+ return;
9959
+ }
9960
+ // XY is in workspace coordinates.
9961
+ const xy = block.getRelativeToSurfaceXY();
9962
+ const scale = this.workspace_.scale;
9963
+ // Block bounds in pixels relative to the workspace origin (0,0 is centre).
9964
+ const width = block.width * scale;
9965
+ const height = block.height * scale;
9966
+ const top = xy.y * scale;
9967
+ const bottom = (xy.y + block.height) * scale;
9968
+ // In RTL the block's position is the top right of the block, not top left.
9969
+ const left = this.workspace_.RTL ? xy.x * scale - width : xy.x * scale;
9970
+ const right = this.workspace_.RTL ? xy.x * scale : xy.x * scale + width;
9971
+ const metrics = this.workspace_.getMetrics();
9972
+ let targetLeft = metrics.viewLeft;
9973
+ const overflowLeft = left < metrics.viewLeft;
9974
+ const overflowRight = right > metrics.viewLeft + metrics.viewWidth;
9975
+ const wideBlock = width > metrics.viewWidth;
9976
+ if ((!wideBlock && overflowLeft) || (wideBlock && !this.workspace_.RTL)) {
9977
+ // Scroll to show left side of block
9978
+ targetLeft = left;
9979
+ }
9980
+ else if ((!wideBlock && overflowRight) ||
9981
+ (wideBlock && this.workspace_.RTL)) {
9982
+ // Scroll to show right side of block
9983
+ targetLeft = right - metrics.viewWidth;
9984
+ }
9985
+ let targetTop = metrics.viewTop;
9986
+ const overflowTop = top < metrics.viewTop;
9987
+ const overflowBottom = bottom > metrics.viewTop + metrics.viewHeight;
9988
+ const tallBlock = height > metrics.viewHeight;
9989
+ if (overflowTop || (tallBlock && overflowBottom)) {
9990
+ // Scroll to show top of block
9991
+ targetTop = top;
9992
+ }
9993
+ else if (overflowBottom) {
9994
+ // Scroll to show bottom of block
9995
+ targetTop = bottom - metrics.viewHeight;
9996
+ }
9997
+ if (targetLeft !== metrics.viewLeft || targetTop !== metrics.viewTop) {
9998
+ const activeEl = document.activeElement;
9999
+ if (wideBlock || tallBlock) {
10000
+ this.workspace_.scroll(-targetLeft, -targetTop);
10001
+ }
10002
+ else {
10003
+ this.workspace_.centerOnBlock(block.id);
10004
+ }
10005
+ if (activeEl) {
10006
+ // Blockly.WidgetDiv.hide called in scroll is taking away focus.
10007
+ // TODO: Review setFocused call in Blockly.WidgetDiv.hide.
10008
+ activeEl.focus();
10009
+ }
10010
+ }
10011
+ }
9951
10012
  open() {
9952
10013
  super.open();
10014
+ this.inputElement_.select();
9953
10015
  Blockly.utils.dom.addClass(this.workspace_.getInjectionDiv(), 'blockly-ws-searching');
9954
10016
  }
9955
10017
  close() {
@@ -15752,15 +15814,20 @@ var pxtblockly;
15752
15814
  let leftPadding = 0, rightPadding = 0;
15753
15815
  switch (outputShape) {
15754
15816
  case Blockly.OUTPUT_SHAPE_HEXAGONAL:
15755
- width = innerWidth;
15817
+ width = size.width / 2;
15756
15818
  halfWidth = width / 2;
15757
- let quarterWidth = halfWidth / 2;
15758
- // TODO: the left padding calculation is a hack, we should calculate left padding based on width (generic case)
15759
- leftPadding = -halfWidth + quarterWidth;
15760
- rightPadding = -quarterWidth;
15761
- const topLeftPoint = -quarterWidth;
15762
- const bottomRightPoint = halfWidth;
15763
- this.toggleThumb_.setAttribute('points', `${topLeftPoint},-14 ${topLeftPoint - 14},0 ${topLeftPoint},14 ${bottomRightPoint},14 ${bottomRightPoint + 14},0 ${bottomRightPoint},-14`);
15819
+ leftPadding = -halfWidth; // total translation when toggle is left-aligned = 0
15820
+ rightPadding = halfWidth - innerWidth; // total translation when right-aligned = width
15821
+ /**
15822
+ * Toggle defined clockwise from bottom left:
15823
+ *
15824
+ * 0, 14 ----------- width, 14
15825
+ * / \
15826
+ * -14, 0 width + 14, 0
15827
+ * \ /
15828
+ * 0, -14 ----------- width, -14
15829
+ */
15830
+ this.toggleThumb_.setAttribute('points', `${0},-14 -14,0 ${0},14 ${width},14 ${width + 14},0 ${width},-14`);
15764
15831
  break;
15765
15832
  case Blockly.OUTPUT_SHAPE_ROUND:
15766
15833
  case Blockly.OUTPUT_SHAPE_SQUARE:
@@ -264,6 +264,12 @@ declare namespace pxt.blocks {
264
264
  protected createDom_(): void;
265
265
  protected highlightSearchGroup_(blocks: Blockly.BlockSvg[]): void;
266
266
  protected unhighlightSearchGroup_(blocks: Blockly.BlockSvg[]): void;
267
+ /**
268
+ * https://github.com/google/blockly-samples/blob/master/plugins/workspace-search/src/WorkspaceSearch.js#L633
269
+ *
270
+ * Modified to center offscreen blocks.
271
+ */
272
+ protected scrollToVisible_(block: Blockly.BlockSvg): void;
267
273
  open(): void;
268
274
  close(): void;
269
275
  }
@@ -6307,7 +6307,7 @@ var pxt;
6307
6307
  createDom_() {
6308
6308
  super.createDom_();
6309
6309
  this.addEvent_(this.workspace_.getInjectionDiv(), "click", this, (e) => {
6310
- if (!this.htmlDiv_.contains(e.target)) {
6310
+ if (this.htmlDiv_.style.display == "flex" && !this.htmlDiv_.contains(e.target)) {
6311
6311
  this.close();
6312
6312
  }
6313
6313
  });
@@ -6324,8 +6324,71 @@ var pxt;
6324
6324
  Blockly.utils.dom.removeClass(blockPath, 'blockly-ws-search-highlight-pxt');
6325
6325
  });
6326
6326
  }
6327
+ /**
6328
+ * https://github.com/google/blockly-samples/blob/master/plugins/workspace-search/src/WorkspaceSearch.js#L633
6329
+ *
6330
+ * Modified to center offscreen blocks.
6331
+ */
6332
+ scrollToVisible_(block) {
6333
+ if (!this.workspace_.isMovable()) {
6334
+ // Cannot scroll to block in a non-movable workspace.
6335
+ return;
6336
+ }
6337
+ // XY is in workspace coordinates.
6338
+ const xy = block.getRelativeToSurfaceXY();
6339
+ const scale = this.workspace_.scale;
6340
+ // Block bounds in pixels relative to the workspace origin (0,0 is centre).
6341
+ const width = block.width * scale;
6342
+ const height = block.height * scale;
6343
+ const top = xy.y * scale;
6344
+ const bottom = (xy.y + block.height) * scale;
6345
+ // In RTL the block's position is the top right of the block, not top left.
6346
+ const left = this.workspace_.RTL ? xy.x * scale - width : xy.x * scale;
6347
+ const right = this.workspace_.RTL ? xy.x * scale : xy.x * scale + width;
6348
+ const metrics = this.workspace_.getMetrics();
6349
+ let targetLeft = metrics.viewLeft;
6350
+ const overflowLeft = left < metrics.viewLeft;
6351
+ const overflowRight = right > metrics.viewLeft + metrics.viewWidth;
6352
+ const wideBlock = width > metrics.viewWidth;
6353
+ if ((!wideBlock && overflowLeft) || (wideBlock && !this.workspace_.RTL)) {
6354
+ // Scroll to show left side of block
6355
+ targetLeft = left;
6356
+ }
6357
+ else if ((!wideBlock && overflowRight) ||
6358
+ (wideBlock && this.workspace_.RTL)) {
6359
+ // Scroll to show right side of block
6360
+ targetLeft = right - metrics.viewWidth;
6361
+ }
6362
+ let targetTop = metrics.viewTop;
6363
+ const overflowTop = top < metrics.viewTop;
6364
+ const overflowBottom = bottom > metrics.viewTop + metrics.viewHeight;
6365
+ const tallBlock = height > metrics.viewHeight;
6366
+ if (overflowTop || (tallBlock && overflowBottom)) {
6367
+ // Scroll to show top of block
6368
+ targetTop = top;
6369
+ }
6370
+ else if (overflowBottom) {
6371
+ // Scroll to show bottom of block
6372
+ targetTop = bottom - metrics.viewHeight;
6373
+ }
6374
+ if (targetLeft !== metrics.viewLeft || targetTop !== metrics.viewTop) {
6375
+ const activeEl = document.activeElement;
6376
+ if (wideBlock || tallBlock) {
6377
+ this.workspace_.scroll(-targetLeft, -targetTop);
6378
+ }
6379
+ else {
6380
+ this.workspace_.centerOnBlock(block.id);
6381
+ }
6382
+ if (activeEl) {
6383
+ // Blockly.WidgetDiv.hide called in scroll is taking away focus.
6384
+ // TODO: Review setFocused call in Blockly.WidgetDiv.hide.
6385
+ activeEl.focus();
6386
+ }
6387
+ }
6388
+ }
6327
6389
  open() {
6328
6390
  super.open();
6391
+ this.inputElement_.select();
6329
6392
  Blockly.utils.dom.addClass(this.workspace_.getInjectionDiv(), 'blockly-ws-searching');
6330
6393
  }
6331
6394
  close() {
@@ -12128,15 +12191,20 @@ var pxtblockly;
12128
12191
  let leftPadding = 0, rightPadding = 0;
12129
12192
  switch (outputShape) {
12130
12193
  case Blockly.OUTPUT_SHAPE_HEXAGONAL:
12131
- width = innerWidth;
12194
+ width = size.width / 2;
12132
12195
  halfWidth = width / 2;
12133
- let quarterWidth = halfWidth / 2;
12134
- // TODO: the left padding calculation is a hack, we should calculate left padding based on width (generic case)
12135
- leftPadding = -halfWidth + quarterWidth;
12136
- rightPadding = -quarterWidth;
12137
- const topLeftPoint = -quarterWidth;
12138
- const bottomRightPoint = halfWidth;
12139
- this.toggleThumb_.setAttribute('points', `${topLeftPoint},-14 ${topLeftPoint - 14},0 ${topLeftPoint},14 ${bottomRightPoint},14 ${bottomRightPoint + 14},0 ${bottomRightPoint},-14`);
12196
+ leftPadding = -halfWidth; // total translation when toggle is left-aligned = 0
12197
+ rightPadding = halfWidth - innerWidth; // total translation when right-aligned = width
12198
+ /**
12199
+ * Toggle defined clockwise from bottom left:
12200
+ *
12201
+ * 0, 14 ----------- width, 14
12202
+ * / \
12203
+ * -14, 0 width + 14, 0
12204
+ * \ /
12205
+ * 0, -14 ----------- width, -14
12206
+ */
12207
+ this.toggleThumb_.setAttribute('points', `${0},-14 -14,0 ${0},14 ${width},14 ${width + 14},0 ${width},-14`);
12140
12208
  break;
12141
12209
  case Blockly.OUTPUT_SHAPE_ROUND:
12142
12210
  case Blockly.OUTPUT_SHAPE_SQUARE: