diff --git a/libs/pxt-common/pxt-core.d.ts b/libs/pxt-common/pxt-core.d.ts
index e467dff7142d..f614e6c1c72d 100644
--- a/libs/pxt-common/pxt-core.d.ts
+++ b/libs/pxt-common/pxt-core.d.ts
@@ -272,11 +272,7 @@ declare interface String {
//% shim=String_::charAt weight=48
//% help=text/char-at
//% blockId="string_get" block="char from %this=text|at %pos" blockNamespace="text"
-<<<<<<< HEAD
- //% advanced=true
-=======
//% this.defl="this"
->>>>>>> upstream/master
charAt(index: number): string;
/** Returns the length of a String object. */
@@ -288,15 +284,8 @@ declare interface String {
* Return the Unicode value of the character at the specified location.
* @param index The zero-based index of the desired character. If there is no character at the specified index, NaN is returned.
*/
-<<<<<<< HEAD
//% shim=String_::charCodeAt
//% advanced=true
-=======
- //% shim=String_::charCodeAt weight=46
- //% help=text/char-code-at
- //% blockId="string_charcode_at" block="char code from $this=text|at $index" blockNamespace="text"
- //% this.defl="this"
->>>>>>> upstream/master
charCodeAt(index: number): number;
/**
@@ -306,11 +295,7 @@ declare interface String {
//% shim=String_::compare
//% help=text/compare
//% blockId="string_compare" block="compare %this=text| to %that" blockNamespace="text"
-<<<<<<< HEAD
//% advanced=true
-=======
- //% this.defl="this"
->>>>>>> upstream/master
compare(that: string): number;
/**
@@ -321,11 +306,7 @@ declare interface String {
//% helper=stringSubstr
//% help=text/substr
//% blockId="string_substr" block="substring of %this=text|from %start|of length %length" blockNamespace="text"
-<<<<<<< HEAD
//% advanced=true
-=======
- //% this.defl="this"
->>>>>>> upstream/master
substr(start: number, length?: number): string;
/**
@@ -362,11 +343,7 @@ declare interface String {
//% help=text/is-empty
//% blockId="string_isempty" blockNamespace="text"
//% block="%this=text| is empty"
-<<<<<<< HEAD
//% advanced=true
-=======
- //% this.defl="this"
->>>>>>> upstream/master
isEmpty(): boolean;
/**
@@ -378,11 +355,7 @@ declare interface String {
//% help=text/index-of
//% blockId="string_indexof" blockNamespace="text"
//% block="%this=text|find index of %searchValue"
-<<<<<<< HEAD
//% advanced=true
-=======
- //% this.defl="this"
->>>>>>> upstream/master
indexOf(searchValue: string, start?: number): number;
/**
@@ -394,11 +367,7 @@ declare interface String {
//% help=text/includes
//% blockId="string_includes" blockNamespace="text"
//% block="%this=text|includes %searchValue"
-<<<<<<< HEAD
//% advanced=true
-=======
- //% this.defl="this"
->>>>>>> upstream/master
includes(searchValue: string, start?: number): boolean;
/**
@@ -410,11 +379,7 @@ declare interface String {
//% help=text/split
//% blockId="string_split" blockNamespace="text"
//% block="split %this=text|at %separator"
-<<<<<<< HEAD
//% advanced=true
-=======
- //% this.defl="this"
->>>>>>> upstream/master
split(separator?: string, limit?: number): string[];
/**
diff --git a/pxtblocks/fields/field_roundMatrix.ts b/pxtblocks/fields/field_roundMatrix.ts
index 871c4b0499c4..81f95b61c16e 100644
--- a/pxtblocks/fields/field_roundMatrix.ts
+++ b/pxtblocks/fields/field_roundMatrix.ts
@@ -1,8 +1,19 @@
///
+import * as Blockly from "blockly";
+import { FieldCustom } from "./field_utils";
+
namespace pxtblockly {
- export class FieldRoundMatrix extends Blockly.Field implements Blockly.FieldCustom {
+ const rowRegex = /^.*[\.#].*$/;
+
+ enum LabelMode {
+ None,
+ Number,
+ Letter
+ }
+
+ export class FieldRoundMatrix extends Blockly.Field implements FieldCustom {
private static CELL_WIDTH = 25;
private static CELL_HORIZONTAL_MARGIN = 7;
private static CELL_VERTICAL_MARGIN = 5;
@@ -34,7 +45,7 @@ namespace pxtblockly {
private currentDragState_: boolean;
- constructor(text: string, params: any, validator?: Function) {
+ constructor(text: string, params: any, validator?: Blockly.FieldValidator) {
super(text, validator);
this.params = params;
diff --git a/pxtblocks/fields/field_roundMatrixSmall.ts b/pxtblocks/fields/field_roundMatrixSmall.ts
index 43297853a045..2e1d2d8614d8 100644
--- a/pxtblocks/fields/field_roundMatrixSmall.ts
+++ b/pxtblocks/fields/field_roundMatrixSmall.ts
@@ -1,9 +1,19 @@
///
+import * as Blockly from "blockly";
+import { FieldCustom } from "./field_utils";
+import { FieldSpriteEditorOptions } from "./field_sprite";
namespace pxtblockly {
import svg = pxt.svgUtil;
+ const rowRegex = /^.*[\.#].*$/;
+
+ enum LabelMode {
+ None,
+ Number,
+ Letter
+ }
interface ParsedSpriteEditorOptions {
sizes: [number, number][];
@@ -21,7 +31,7 @@ namespace pxtblockly {
const TOTAL_WIDTH = PADDING * 2 + BG_PADDING * 2 + PREVIEW_WIDTH;
const DEFAULT_COLOR = "#AAA4AE";
- export class FieldRoundMatrixSmall extends Blockly.Field implements Blockly.FieldCustom {
+ export class FieldRoundMatrixSmall extends Blockly.Field implements FieldCustom {
public isFieldCustom_ = true;
private params: ParsedSpriteEditorOptions;
@@ -33,7 +43,7 @@ namespace pxtblockly {
private redoStack: pxtmatrix.CanvasState[];
private colors: string[];
- constructor(text: string, params: any, validator?: Function) {
+ constructor(text: string, params: any, validator?: Blockly.FieldValidator) {
super(text, validator);
this.colors = [
'#8E07BA','#FF8A00', '#FFC200',
@@ -71,16 +81,21 @@ namespace pxtblockly {
// Force a render.
this.render_();
- (this as any).mouseDownWrapper_ = Blockly.bindEventWithChecks_((this as any).getClickTarget_(), "mousedown", this, (this as any).onMouseDown_)
+ (this as any).mouseDownWrapper_ = Blockly.browserEvents.bind((this as any).getClickTarget_(), "mousedown", this, (this as any).onMouseDown_)
}
-
/**
* Show the inline free-text editor on top of the text.
* @private
*/
showEditor_() {
- const windowSize = goog.dom.getViewportSize();
- const scrollOffset = goog.style.getViewportPageOffset(document);
+ const windowSize = {
+ width: window.innerWidth,
+ height: window.innerHeight
+ };
+ const scrollOffset = {
+ x: document.documentElement.scrollLeft || document.body.scrollLeft,
+ y: document.documentElement.scrollTop || document.body.scrollTop
+ };
// If there is an existing drop-down someone else owns, hide it immediately and clear it.
Blockly.DropDownDiv.hideWithoutAnimation();
@@ -106,34 +121,42 @@ namespace pxtblockly {
//}
this.editor.setSizePresets([[7,7]]);
- goog.style.setHeight(contentDiv, this.editor.outerHeight() + 1);
- goog.style.setWidth(contentDiv, this.editor.outerWidth() + 1);
- goog.style.setStyle(contentDiv, "overflow", "hidden");
- goog.style.setStyle(contentDiv, "max-height", "500px");
+ function setHeight(element: HTMLElement, height: number | string): void {
+ element.style.height = typeof height === 'number' ? height + 'px' : height;
+ }
+ function setWidth(element: HTMLElement, width: number | string): void {
+ element.style.width = typeof width === 'number' ? width + 'px' : width;
+ }
+ function setStyle(element: HTMLElement, property: string, value: string | null): void {
+ element.style[property as any] = value;
+ }
+
+ setHeight(contentDiv, this.editor.outerHeight() + 1);
+ setWidth(contentDiv, this.editor.outerWidth() + 1);
+ setStyle(contentDiv, "overflow", "hidden");
+ setStyle(contentDiv, "max-height", "500px");
pxt.BrowserUtils.addClass(contentDiv.parentElement, "sprite-editor-dropdown")
Blockly.DropDownDiv.setColour("#2c3e50", "#2c3e50");
- Blockly.DropDownDiv.showPositionedByBlock(this, this.sourceBlock_, () => {
+ Blockly.DropDownDiv.showPositionedByBlock(this, this.sourceBlock_ as Blockly.BlockSvg, () => {
this.editor.closeEditor();
this.state = this.editor.bitmap().image;
this.redrawPreview();
if (this.sourceBlock_ && Blockly.Events.isEnabled()) {
Blockly.Events.fire(new Blockly.Events.BlockChange(
- this.sourceBlock_, 'field', this.name, this.text_, this.getText()));
+ this.sourceBlock_, 'field', this.name, this.getValue(), this.getText()));
}
- goog.style.setHeight(contentDiv, null);
- goog.style.setWidth(contentDiv, null);
- goog.style.setStyle(contentDiv, "overflow", null);
- goog.style.setStyle(contentDiv, "max-height", null);
+ setHeight(contentDiv, null);
+ setWidth(contentDiv, null);
+ setStyle(contentDiv, "overflow", null);
+ setStyle(contentDiv, "max-height", null);
pxt.BrowserUtils.removeClass(contentDiv.parentElement, "sprite-editor-dropdown");
this.editor.removeKeyListeners();
});
-
this.editor.addKeyListeners();
this.editor.layout();
}
-
private isInFlyout() {
return ((this.sourceBlock_.workspace as Blockly.WorkspaceSvg).getParentSvg() as SVGElement).className.baseVal == "blocklyFlyout";
}
@@ -148,14 +171,14 @@ namespace pxtblockly {
return pxtmatrix.bitmapToImageLiteral(this.state, pxt.editor.FileType.TypeScript);
}
- setText(newText: string) {
+ setValue(newText: string) {
if (newText == null) {
return;
}
this.parseBitmap(newText);
this.redrawPreview();
- super.setText(newText);
+ super.setValue(newText);
}
private redrawPreview() {
@@ -235,7 +258,7 @@ namespace pxtblockly {
return canvas.toDataURL();
}
- private getColor(val : number) {
+ private getColor(val: number) {
if(val - 1 >= 0 && val - 1 < this.colors.length) {
return this.colors[val-1]
} else {
diff --git a/webapp/src/app.tsx b/webapp/src/app.tsx
index 6967466f8b55..a7f4448e886b 100644
--- a/webapp/src/app.tsx
+++ b/webapp/src/app.tsx
@@ -2701,7 +2701,7 @@ export class ProjectView
return Util.promiseTimeout(1000, this.requestScreenshotPromise = new Promise((resolve, reject) => {
this.pushScreenshotHandler(msg => resolve(pxt.BrowserUtils.imageDataToPNG(msg.data, 3)));
})) // simulator might be stopped or in bad shape
- .catch(e => {
+ .catch(() => {
pxt.tickEvent('screenshot.timeout');
return undefined;
})
diff --git a/webapp/src/toolbox.tsx b/webapp/src/toolbox.tsx
index 77b9a42852e0..b804aae67c7c 100644
--- a/webapp/src/toolbox.tsx
+++ b/webapp/src/toolbox.tsx
@@ -727,7 +727,7 @@ export class CategoryItem extends data.Component = document.getElementsByClassName('blocklyFlyout')
- const nameid:string = treeRow.nameid;
+ const nameid: string = treeRow.nameid;
let selected: HTMLElement;
for (let index = 0; index < allBackgrounds.length; index++) {
const element: HTMLElement = (allBackgrounds[index] as HTMLElement);