From faa44c566085de18bf21b2e10b100490d17dc949 Mon Sep 17 00:00:00 2001 From: Rachel Fenichel Date: Thu, 14 Mar 2024 13:02:13 -0700 Subject: [PATCH 1/4] chore: delete uses of colour blocks from most other plugins --- .../custom-renderer-codelab/src/toolbox.js | 100 ------------------ .../complete-code/index.html | 38 ------- .../starter-code/index.html | 38 ------- examples/devsite-demo/toolbox.js | 65 ------------ examples/devsite-landing-demo/toolbox.js | 65 ------------ .../src/toolbox.js | 97 ----------------- examples/rtl-demo/index.html | 19 ---- examples/sample-app-ts/src/toolbox.ts | 97 ----------------- examples/sample-app/src/toolbox.js | 97 ----------------- plugins/dev-tools/src/toolboxCategories.js | 78 -------------- .../src/toolboxCategories.js | 78 -------------- plugins/theme-dark/test/index.js | 78 -------------- plugins/theme-deuteranopia/test/index.js | 78 -------------- plugins/theme-highcontrast/test/index.js | 78 -------------- plugins/theme-modern/test/index.js | 78 -------------- plugins/theme-tritanopia/test/index.js | 78 -------------- 16 files changed, 1162 deletions(-) diff --git a/examples/custom-renderer-codelab/src/toolbox.js b/examples/custom-renderer-codelab/src/toolbox.js index 0da9795cbb..15a8fca671 100644 --- a/examples/custom-renderer-codelab/src/toolbox.js +++ b/examples/custom-renderer-codelab/src/toolbox.js @@ -495,28 +495,6 @@ export const toolbox = { }, }, }, - { - kind: 'block', - type: 'add_text', - inputs: { - TEXT: { - shadow: { - type: 'text', - fields: { - TEXT: 'abc', - }, - }, - }, - COLOR: { - shadow: { - type: 'colour_picker', - fields: { - COLOUR: '#aa00cc', - }, - }, - }, - }, - }, ], }, { @@ -622,84 +600,6 @@ export const toolbox = { }, ], }, - { - kind: 'category', - name: 'Color', - categorystyle: 'colour_category', - contents: [ - { - kind: 'block', - type: 'colour_picker', - }, - { - kind: 'block', - type: 'colour_random', - }, - { - kind: 'block', - type: 'colour_rgb', - inputs: { - RED: { - shadow: { - type: 'math_number', - fields: { - NUM: 100, - }, - }, - }, - GREEN: { - shadow: { - type: 'math_number', - fields: { - NUM: 50, - }, - }, - }, - BLUE: { - shadow: { - type: 'math_number', - fields: { - NUM: 0, - }, - }, - }, - }, - }, - { - kind: 'block', - type: 'colour_blend', - inputs: { - COLOUR1: { - shadow: { - type: 'colour_picker', - fields: { - COLOUR: '#ff0000', - }, - }, - }, - COLOUR2: { - shadow: { - type: 'colour_picker', - fields: { - COLOUR: '#3333ff', - }, - }, - }, - RATIO: { - shadow: { - type: 'math_number', - fields: { - NUM: 0.5, - }, - }, - }, - }, - }, - ], - }, - { - kind: 'sep', - }, { kind: 'category', name: 'Variables', diff --git a/examples/custom-toolbox-codelab/complete-code/index.html b/examples/custom-toolbox-codelab/complete-code/index.html index 3635b1fb28..d92f7d4b92 100644 --- a/examples/custom-toolbox-codelab/complete-code/index.html +++ b/examples/custom-toolbox-codelab/complete-code/index.html @@ -346,44 +346,6 @@

Toolbox Customization Codelab

- - - - - - - 100 - - - - - 50 - - - - - 0 - - - - - - - #ff0000 - - - - - #3333ff - - - - - 0.5 - - - - Toolbox Customization Codelab - - - - - - - 100 - - - - - 50 - - - - - 0 - - - - - - - #ff0000 - - - - - #3333ff - - - - - 0.5 - - - - Date: Thu, 14 Mar 2024 13:16:59 -0700 Subject: [PATCH 2/4] chore: delete colour blocks from shadow block converter --- plugins/shadow-block-converter/test/index.ts | 22 -------------------- 1 file changed, 22 deletions(-) diff --git a/plugins/shadow-block-converter/test/index.ts b/plugins/shadow-block-converter/test/index.ts index 13cf0aa7c9..876360d9f7 100644 --- a/plugins/shadow-block-converter/test/index.ts +++ b/plugins/shadow-block-converter/test/index.ts @@ -25,28 +25,6 @@ const toolbox: Blockly.utils.toolbox.ToolboxDefinition = { }, }, }, - { - kind: 'block', - type: 'colour_blend', - inputs: { - COLOUR1: { - shadow: {type: 'colour_picker', fields: {COLOUR: '#ff0000'}}, - block: undefined, - }, - COLOUR2: { - shadow: {type: 'colour_picker', fields: {COLOUR: '#3333ff'}}, - block: undefined, - }, - RATIO: { - shadow: {type: 'math_number', fields: {NUM: 0.5}}, - block: undefined, - }, - }, - }, - { - kind: 'block', - type: 'colour_picker', - }, { kind: 'block', type: 'text_print', From 1c9110b60e0ee84f2a860a40826976432e53d2b8 Mon Sep 17 00:00:00 2001 From: Rachel Fenichel Date: Thu, 14 Mar 2024 13:55:05 -0700 Subject: [PATCH 3/4] chore: stop using colour fields in block-test plugin --- plugins/block-test/src/fields/defaults.js | 52 -------- plugins/block-test/src/fields/validators.js | 125 -------------------- plugins/block-test/src/mutators.js | 65 ++++++---- 3 files changed, 44 insertions(+), 198 deletions(-) diff --git a/plugins/block-test/src/fields/defaults.js b/plugins/block-test/src/fields/defaults.js index 732802a6c8..75defa8032 100644 --- a/plugins/block-test/src/fields/defaults.js +++ b/plugins/block-test/src/fields/defaults.js @@ -85,50 +85,6 @@ Blockly.defineBlocksWithJsonArray([ tooltip: '', helpUrl: '', }, - { - type: 'test_fields_colour', - message0: 'colour %1', - args0: [ - { - type: 'field_colour', - name: 'COLOUR', - colour: '#ff0000', - }, - ], - style: 'math_blocks', - tooltip: '', - helpUrl: '', - }, - { - type: 'test_fields_colour_options', - message0: 'colour options %1', - args0: [ - { - type: 'field_colour', - name: 'COLOUR', - colour: '#ff4040', - colourOptions: [ - '#ff4040', - '#ff8080', - '#ffc0c0', - '#4040ff', - '#8080ff', - '#c0c0ff', - ], - colourTitles: [ - 'dark pink', - 'pink', - 'light pink', - 'dark blue', - 'blue', - 'light blue', - ], - columns: 3, - }, - ], - style: 'math_blocks', - tooltip: 'test tooltip', - }, { type: 'test_fields_variable', message0: 'variable %1', @@ -230,14 +186,6 @@ export const category = { kind: 'BLOCK', type: 'test_fields_checkbox', }, - { - kind: 'BLOCK', - type: 'test_fields_colour', - }, - { - kind: 'BLOCK', - type: 'test_fields_colour_options', - }, { kind: 'BLOCK', type: 'test_fields_text_input', diff --git a/plugins/block-test/src/fields/validators.js b/plugins/block-test/src/fields/validators.js index 7b0f0edf4a..e67c7661ad 100644 --- a/plugins/block-test/src/fields/validators.js +++ b/plugins/block-test/src/fields/validators.js @@ -217,111 +217,6 @@ Blockly.Blocks['test_validators_checkbox_not_match_null'] = { }, }; -Blockly.Blocks['test_validators_colour_null'] = { - init: function () { - const colourField = new Blockly.FieldColour('#ff0000', this.validate); - colourField.setColours([ - '#ffffff', - '#ffdcdc', - '#ffb4b4', - '#ff8c8c', - '#ff6464', - '#ff3c3c', - '#ff1414', - '#00ffff', - '#00dcdc', - '#00b4b4', - '#008c8c', - '#006464', - '#003c3c', - '#001414', - ]); - - this.appendDummyInput() - .appendField('always null') - .appendField(colourField, 'INPUT'); - this.setColour(230); - this.setCommentText( - 'All input validates to null (invalid). This means' + - ' the field value should not change.', - ); - }, - - validate: function (newValue) { - return null; - }, -}; -Blockly.Blocks['test_validators_colour_force_red'] = { - init: function () { - const colourField = new Blockly.FieldColour('#ff0000', this.validate); - colourField.setColours([ - '#ffffff', - '#ffdcdc', - '#ffb4b4', - '#ff8c8c', - '#ff6464', - '#ff3c3c', - '#ff1414', - '#00ffff', - '#00dcdc', - '#00b4b4', - '#008c8c', - '#006464', - '#003c3c', - '#001414', - ]); - - this.appendDummyInput() - .appendField('force full red') - .appendField(colourField, 'INPUT'); - this.setColour(230); - this.setCommentText( - 'The input will have its red value replaced with' + ' full red.', - ); - }, - - validate: function (newValue) { - return '#ff' + newValue.substr(3, 4); - }, -}; -Blockly.Blocks['test_validators_colour_red_null'] = { - init: function () { - const colourField = new Blockly.FieldColour('#ff0000', this.validate); - colourField.setColours([ - '#ffffff', - '#ffdcdc', - '#ffb4b4', - '#ff8c8c', - '#ff6464', - '#ff3c3c', - '#ff1414', - '#00ffff', - '#00dcdc', - '#00b4b4', - '#008c8c', - '#006464', - '#003c3c', - '#001414', - ]); - - this.appendDummyInput() - .appendField('not red -> null') - .appendField(colourField, 'INPUT'); - this.setColour(230); - this.setCommentText( - 'If the input does not have full red, the input will validate to' + - ' null (invalid). Otherwise it will return the input value', - ); - }, - - validate: function (newValue) { - if (newValue.substr(1, 2) != 'ff') { - return null; - } - return newValue; - }, -}; - Blockly.Blocks['test_validators_dropdown_null'] = { init: function () { this.appendDummyInput() @@ -627,26 +522,6 @@ export const category = { kind: 'SEP', gap: '12', }, - { - kind: 'BLOCK', - type: 'test_validators_colour_null', - }, - { - kind: 'SEP', - gap: '12', - }, - { - kind: 'BLOCK', - type: 'test_validators_colour_force_red', - }, - { - kind: 'SEP', - gap: '12', - }, - { - kind: 'BLOCK', - type: 'test_validators_colour_red_null', - }, { kind: 'LABEL', text: 'Dropdowns', diff --git a/plugins/block-test/src/mutators.js b/plugins/block-test/src/mutators.js index 48e8123e69..24571e0e72 100644 --- a/plugins/block-test/src/mutators.js +++ b/plugins/block-test/src/mutators.js @@ -14,13 +14,13 @@ import * as Blockly from 'blockly/core'; Blockly.defineBlocksWithJsonArray([ { - type: 'test_mutator_colorChange', - message0: 'colour %1', + type: 'test_mutator_textChange', + message0: 'mutator text: %1', args0: [ { - type: 'field_colour', - name: 'COLOUR', - colour: '#ff0000', + type: 'field_input', + name: 'MUTATOR_TEXT', + text: 'a label', }, ], style: 'colour_blocks', @@ -41,7 +41,7 @@ const COLOR_CHANGE_MUTATOR = { */ mutationToDom: function () { const container = Blockly.utils.xml.createElement('mutation'); - container.setAttribute('colour', this.getColour()); + container.setAttribute('arbitrary', this.getFieldValue('LABEL')); return container; }, /** @@ -50,23 +50,23 @@ const COLOR_CHANGE_MUTATOR = { * @this {Blockly.Block} */ domToMutation: function (xmlElement) { - this.setColour(xmlElement.getAttribute('colour')); + this.setFieldValue('LABEL', xmlElement.getAttribute('arbitrary')); }, /** * Returns the state of this block as a json serializable object. - * @returns {{colour: string}} The state of this block. + * @returns {{arbitrary: string}} The state of this block. * @this {Blockly.Block} */ saveExtraState: function () { - return {colour: this.getColour()}; + return {arbitrary: this.getFieldValue('LABEL')}; }, /** * Applies the state to this block. - * @param {{color: string}} state The state to apply. + * @param {{arbitrary: string}} state The state to apply. * @this {Blockly.Block} */ loadExtraState: function (state) { - this.setColour(state['colour']); + this.setFieldValue(state['arbitrary'], 'LABEL'); }, /** * Populate the mutator's dialog with this block's components. @@ -76,10 +76,12 @@ const COLOR_CHANGE_MUTATOR = { */ decompose: function (workspace) { const containerBlock = Blockly.serialization.blocks.append( - {type: 'test_mutator_colorChange'}, + {type: 'test_mutator_textChange'}, workspace, ); - containerBlock.getField('COLOUR').setValue(this.getColour()); + containerBlock + .getField('MUTATOR_TEXT') + .setValue(this.getFieldValue('LABEL')); return containerBlock; }, /** @@ -88,7 +90,7 @@ const COLOR_CHANGE_MUTATOR = { * @this {Blockly.Block} */ compose: function (containerBlock) { - this.setColour(containerBlock.getFieldValue('COLOUR')); + this.setFieldValue(containerBlock.getFieldValue('MUTATOR_TEXT'), 'LABEL'); }, }; @@ -100,12 +102,12 @@ for (let i = 0; i < n; i++) { const defineBlocks = blocksIds.map((t) => ({ type: t, - message0: 'colour %1', + message0: 'mutator text: %1', args0: [ { - type: 'field_colour', - name: 'COLOUR', - colour: '#ff0000', + type: 'field_input', + name: 'MUTATOR_TEXT', + text: 'a label', }, ], style: 'colour_blocks', @@ -114,7 +116,14 @@ const defineBlocks = blocksIds.map((t) => ({ Blockly.defineBlocksWithJsonArray([ { type: 'test_mutators_many', - message0: 'test many blocks mutator', + message0: 'test many blocks mutator %1', + args0: [ + { + type: 'field_label', + name: 'LABEL', + text: 'changeable label', + }, + ], mutator: 'test_many_blocks_mutator', colour: '#000000', }, @@ -132,7 +141,14 @@ Blockly.Extensions.registerMutator( Blockly.defineBlocksWithJsonArray([ { type: 'test_mutators_noflyout', - message0: 'noflyout mutator', + message0: 'noflyout mutator %1', + args0: [ + { + type: 'field_label', + name: 'LABEL', + text: 'changeable label', + }, + ], mutator: 'test_noflyout_mutator', colour: '#000000', }, @@ -149,7 +165,14 @@ Blockly.Extensions.registerMutator( Blockly.defineBlocksWithJsonArray([ { type: 'test_mutators_changeableFlyout', - message0: 'changeable flyout mutator', + message0: 'changeable flyout mutator %1', + args0: [ + { + type: 'field_label', + name: 'LABEL', + text: 'changeable label', + }, + ], mutator: 'test_changeableFlyout_mutator', colour: '#000000', }, From 433f3c934707f81b535000e16aadfb465b0b0633 Mon Sep 17 00:00:00 2001 From: Rachel Fenichel Date: Fri, 15 Mar 2024 13:13:13 -0700 Subject: [PATCH 4/4] fix: param order --- plugins/block-test/src/mutators.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/block-test/src/mutators.js b/plugins/block-test/src/mutators.js index 24571e0e72..76316f9cc6 100644 --- a/plugins/block-test/src/mutators.js +++ b/plugins/block-test/src/mutators.js @@ -50,7 +50,7 @@ const COLOR_CHANGE_MUTATOR = { * @this {Blockly.Block} */ domToMutation: function (xmlElement) { - this.setFieldValue('LABEL', xmlElement.getAttribute('arbitrary')); + this.setFieldValue(xmlElement.getAttribute('arbitrary'), 'LABEL'); }, /** * Returns the state of this block as a json serializable object.