Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 0 additions & 35 deletions libs/pxt-common/pxt-core.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand All @@ -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;

/**
Expand All @@ -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;

/**
Expand All @@ -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;

/**
Expand Down Expand Up @@ -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;

/**
Expand All @@ -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;

/**
Expand All @@ -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;

/**
Expand All @@ -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[];

/**
Expand Down
15 changes: 13 additions & 2 deletions pxtblocks/fields/field_roundMatrix.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
/// <reference path="../../built/pxtsim.d.ts"/>

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;
Expand Down Expand Up @@ -34,7 +45,7 @@ namespace pxtblockly {

private currentDragState_: boolean;

constructor(text: string, params: any, validator?: Function) {
constructor(text: string, params: any, validator?: Blockly.FieldValidator<any>) {
super(text, validator);
this.params = params;

Expand Down
65 changes: 44 additions & 21 deletions pxtblocks/fields/field_roundMatrixSmall.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
/// <reference path="../../built/pxtlib.d.ts" />

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][];
Expand All @@ -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;
Expand All @@ -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<any>) {
super(text, validator);
this.colors = [
'#8E07BA','#FF8A00', '#FFC200',
Expand Down Expand Up @@ -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();
Expand All @@ -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";
}
Expand All @@ -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() {
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2701,7 +2701,7 @@ export class ProjectView
return Util.promiseTimeout(1000, this.requestScreenshotPromise = new Promise<string>((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;
})
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/toolbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,7 @@ export class CategoryItem extends data.Component<CategoryItemProps, CategoryItem
if (onCategoryClick) onCategoryClick(treeRow, index);
//LBOS changes to allow for dynamic color change of flyout
const allBackgrounds: HTMLCollectionOf<Element> = 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);
Expand Down