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
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.4",
"blockly": "^12.0.0-beta.6",
"conventional-changelog-conventionalcommits": "^5.0.0",
"eslint": "^8.49.0",
"eslint-config-google": "^0.14.0",
Expand Down
2 changes: 1 addition & 1 deletion plugins/block-shareable-procedures/src/blocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ const procedureDefUpdateShapeMixin = {
*/
doProcedureUpdate: function () {
this.setFieldValue(this.getProcedureModel().getName(), 'NAME');
this.setEnabled(this.getProcedureModel().getEnabled());
this.setDisabledReason(!this.getProcedureModel().getEnabled());
this.updateParameters_();
this.updateMutator_();
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ suite('Procedures', function () {
test('disabling a procedure def block updates the procedure model', function () {
const defBlock = createProcDefBlock(this.workspace);

defBlock.setEnabled(false);
defBlock.setDisabledReason(true);
globalThis.clock.runAll();

assert.isFalse(
Expand Down Expand Up @@ -1204,7 +1204,7 @@ suite('Procedures', function () {
const defBlock = createProcDefBlock(this.workspace);
const callBlock = createProcCallBlock(this.workspace);

defBlock.setEnabled(false);
defBlock.setDisabledReason(true);
globalThis.clock.runAll();

assert.isFalse(
Expand All @@ -1220,10 +1220,10 @@ suite('Procedures', function () {
function () {
const defBlock = createProcDefBlock(this.workspace);
const callBlock = createProcCallBlock(this.workspace);
defBlock.setEnabled(false);
defBlock.setDisabledReason(true);
globalThis.clock.runAll();

defBlock.setEnabled(true);
defBlock.setDisabledReason(false);
globalThis.clock.runAll();

assert.isTrue(
Expand All @@ -1241,12 +1241,12 @@ suite('Procedures', function () {
const defBlock = createProcDefBlock(this.workspace);
const callBlock = createProcCallBlock(this.workspace);
globalThis.clock.runAll();
callBlock.setEnabled(false);
callBlock.setDisabledReason(true);
globalThis.clock.runAll();
defBlock.setEnabled(false);
defBlock.setDisabledReason(true);
globalThis.clock.runAll();

defBlock.setEnabled(true);
defBlock.setDisabledReason(false);
globalThis.clock.runAll();

assert.isFalse(
Expand Down
9 changes: 0 additions & 9 deletions plugins/field-colour/src/field_colour.ts
Original file line number Diff line number Diff line change
Expand Up @@ -728,15 +728,6 @@ export class FieldColour extends Blockly.Field<string> {
// the static fromJson method.
return new this(options.colour, undefined, options);
}

/**
* Returns the class of this field.
*
* @returns FieldColour.
*/
getClass() {
return FieldColour;
}
}

/** The default value for this field. */
Expand Down
38 changes: 33 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, FieldDropdown} from 'blockly/core';
import {
browserEvents,
FieldDropdown,
ImageProperties,
MenuOption,
utils,
} from 'blockly/core';
import {GridItem} from './grid_item';

/**
Expand Down Expand Up @@ -100,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 @@ -293,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'
);
}
12 changes: 6 additions & 6 deletions plugins/field-grid-dropdown/test/field_test.mocha.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ suite('FieldGridDropdown', function () {
expectedText: 'a',
args: [
[
[{src: 'scrA', alt: 'a'}, 'A'],
[{src: 'scrB', alt: 'b'}, 'B'],
[{src: 'scrC', alt: 'c'}, 'C'],
[{src: 'scrA', alt: 'a', width: 0, height: 0}, 'A'],
[{src: 'scrB', alt: 'b', width: 0, height: 0}, 'B'],
[{src: 'scrC', alt: 'c', width: 0, height: 0}, 'C'],
],
],
},
Expand All @@ -99,9 +99,9 @@ suite('FieldGridDropdown', function () {
args: [
() => {
return [
[{src: 'scrA', alt: 'a'}, 'A'],
[{src: 'scrB', alt: 'b'}, 'B'],
[{src: 'scrC', alt: 'c'}, 'C'],
[{src: 'scrA', alt: 'a', width: 0, height: 0}, 'A'],
[{src: 'scrB', alt: 'b', width: 0, height: 0}, 'B'],
[{src: 'scrC', alt: 'c', width: 0, height: 0}, 'C'],
];
},
],
Expand Down
Loading
Loading