From 86edd829c0de9e593806b7933995a9d95e3d5a11 Mon Sep 17 00:00:00 2001 From: Chris Willis-Ford <cwillisf@users.noreply.github.com> Date: Tue, 18 Jun 2019 11:21:03 -0700 Subject: [PATCH] Apply suggestions from code review Comments slightly tweaked from kchadha's suggestions Co-Authored-By: Karishma Chadha <kchadha@media.mit.edu> --- src/containers/blocks.jsx | 2 +- src/lib/define-dynamic-block.js | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/containers/blocks.jsx b/src/containers/blocks.jsx index e6d138087..6ec5771c6 100644 --- a/src/containers/blocks.jsx +++ b/src/containers/blocks.jsx @@ -442,7 +442,7 @@ class Blocks extends React.Component { } }; - // scratch-blocks implements a menu or custom field as a special kind of block + // scratch-blocks implements a menu or custom field as a special kind of block ("shadow" block) // these actually define blocks and MUST run regardless of the UI state defineBlocks( Object.getOwnPropertyNames(categoryInfo.customFieldTypes) diff --git a/src/lib/define-dynamic-block.js b/src/lib/define-dynamic-block.js index 4f561d6cd..af1aa4279 100644 --- a/src/lib/define-dynamic-block.js +++ b/src/lib/define-dynamic-block.js @@ -3,6 +3,16 @@ import ArgumentType from 'scratch-vm/src/extension-support/argument-type'; import BlockType from 'scratch-vm/src/extension-support/block-type'; +/** + * Define a block using extension info which has the ability to dynamically determine (and update) its layout. + * This functionality is used for extension blocks which can change its properties based on different state + * information. For example, the `control_stop` block changes its shape based on which menu item is selected + * and a variable block changes its text to reflect the variable name without using an editable field. + * @param {object} ScratchBlocks - The ScratchBlocks name space. + * @param {object} categoryInfo - Information about this block's extension category, including any menus and icons. + * @param {object} staticBlockInfo - The base block information before any dynamic changes. + * @param {string} extendedOpcode - The opcode for the block (including the extension ID). + */ // TODO: grow this until it can fully replace `_convertForScratchBlocks` in the VM runtime const defineDynamicBlock = (ScratchBlocks, categoryInfo, staticBlockInfo, extendedOpcode) => ({ init: function () { -- GitLab