Skip to content
Closed
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
627 changes: 363 additions & 264 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"@eslint/js": "^8.49.0",
"@typescript-eslint/eslint-plugin": "^6.7.2",
"@typescript-eslint/parser": "^6.7.2",
"blockly": "^12.0.0-beta.1",
"blockly": "^12.0.0-beta.5",
"conventional-changelog-conventionalcommits": "^5.0.0",
"eslint": "^8.49.0",
"eslint-config-google": "^0.14.0",
Expand Down
12 changes: 12 additions & 0 deletions plugins/field-bitmap/src/field-bitmap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,18 @@ export class FieldBitmap extends Blockly.Field<number[][]> {
);
}
}

/**
* Returns this field's class.
*
* Used by keyboard navigation to look up the rules for navigating from this
* field.
*
* @returns This field's class.
*/
getClass() {
return FieldBitmap;
}
}

interface Buttons {
Expand Down
2 changes: 1 addition & 1 deletion plugins/field-colour/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"typescript": "^5.4.5"
},
"peerDependencies": {
"blockly": "^11.0.0"
"blockly": "^12.0.0"
},
"publishConfig": {
"access": "public",
Expand Down
14 changes: 13 additions & 1 deletion plugins/field-colour/src/field_colour.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ export class FieldColour extends Blockly.Field<string> {
*
* @returns True if this field should take up the full block. False otherwise.
*/
protected isFullBlockField(): boolean {
override isFullBlockField(): boolean {
const block = this.getSourceBlock();
if (!block) throw new Blockly.UnattachedFieldError();

Expand Down Expand Up @@ -729,6 +729,18 @@ export class FieldColour extends Blockly.Field<string> {
// the static fromJson method.
return new this(options.colour, undefined, options);
}

/**
* Returns this field's class.
*
* Used by keyboard navigation to look up the rules for navigating from this
* field.
*
* @returns This field's class.
*/
getClass() {
return FieldColour;
}
}

/** The default value for this field. */
Expand Down
41 changes: 36 additions & 5 deletions plugins/field-grid-dropdown/src/grid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@
* SPDX-License-Identifier: Apache-2.0
*/

import {utils, browserEvents, MenuOption} from 'blockly/core';
import {
browserEvents,
FieldDropdown,
ImageProperties,
MenuOption,
utils,
} from 'blockly/core';
import {GridItem} from './grid_item';

/**
Expand Down Expand Up @@ -88,6 +94,9 @@
private populateItems(options: MenuOption[]) {
let row = document.createElement('div');
for (const [index, item] of options.entries()) {
// TODO(#2507): Don't just ignore separators.
if (item === FieldDropdown.SEPARATOR) continue;

if (index % this.columns === 0) {
row = document.createElement('div');
row.className = 'blocklyFieldGridRow';
Expand All @@ -97,11 +106,11 @@

const [label, value] = item;
const content = (() => {
if (typeof label === 'object') {
if (isImageProperties(label)) {
// Convert ImageProperties to an HTMLImageElement.
const image = new Image(label['width'], label['height']);
image.src = label['src'];
image.alt = label['alt'] || '';
const image = new Image(label.width, label.height);
image.src = label.src;
image.alt = label.alt || '';
return image;
}
return label;
Expand Down Expand Up @@ -290,3 +299,25 @@
return this.itemAtIndex(index);
}
}

/**
* Returns whether or not an object conforms to the ImageProperties
* interface.
*
* @param obj The object to test.
* @returns True iff the object conforms to ImageProperties.
*/
function isImageProperties(obj: any): obj is ImageProperties {

Check warning on line 310 in plugins/field-grid-dropdown/src/grid.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
return (
obj &&
typeof obj === 'object' &&
'src' in obj &&
typeof obj.src === 'string' &&
'alt' in obj &&
typeof obj.alt === 'string' &&
'width' in obj &&
typeof obj.width === 'number' &&
'height' in obj &&
typeof obj.height === 'number'
);
}
7 changes: 5 additions & 2 deletions plugins/field-multilineinput/src/field_multilineinput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,11 @@ export class FieldMultilineInput extends Blockly.FieldTextInput {
);
}
let textLines = this.getText();
// TODO(google/blockly#8738): Use minimum-width setting mechanism
// to be introduced in PR #9011.
if (!textLines) {
// Prevent the field from disappearing if empty.
return Blockly.Field.NBSP;
return '\u00A0'; // Non-breaking space.
}
const lines = textLines.split('\n');
textLines = '';
Expand All @@ -182,7 +184,8 @@ export class FieldMultilineInput extends Blockly.FieldTextInput {
}
// Replace whitespace with non-breaking spaces so the text doesn't
// collapse.
text = text.replace(/\s/g, Blockly.Field.NBSP);
// TODO(google/blockly#8738): Use Blockly.Field.NBSP.
text = text.replace(/\s/g, '\u00A0'); // Non-breaking space.

textLines += text;
if (i !== displayLinesNumber - 1) {
Expand Down
2 changes: 1 addition & 1 deletion plugins/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"boot": "lerna bootstrap",
"build": "lerna run build",
"clean": "lerna run clean",
"clean:node": "lerna run clean --yes",
"clean:node": "lerna clean --yes",
"postinstall": "npm run boot",
"predeploy": "lerna run predeploy",
"test": "lerna run test"
Expand Down
Loading