From cbf8735a55183c90dc2e76dc764bcb0babe5c3e1 Mon Sep 17 00:00:00 2001 From: Beka Westberg Date: Thu, 3 Mar 2022 15:50:56 +0000 Subject: [PATCH 1/2] fix: custom block context menus --- core/block.js | 6 ++++++ core/block_svg.js | 10 ++-------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/core/block.js b/core/block.js index 134ce88ab48..2868545cf3d 100644 --- a/core/block.js +++ b/core/block.js @@ -188,6 +188,12 @@ class Block { */ this.saveConnections = undefined; + /** + * An optional method for defining custom block context menu items. + * @type {undefined|?function(!Array)} + */ + this.customContextMenu = undefined; + /** * An optional property for suppressing adding STATEMENT_PREFIX and * STATEMENT_SUFFIX to generated code. diff --git a/core/block_svg.js b/core/block_svg.js index 3b81d63f857..98a81c62532 100644 --- a/core/block_svg.js +++ b/core/block_svg.js @@ -110,7 +110,7 @@ class BlockSvg extends Block { * mutation dialog button and UI to appear. * @type {undefined|?function(WorkspaceSvg):!BlockSvg} */ - this.decompose = undefined; + this.decompose; /** * An optional method called when a mutator dialog saves its content. @@ -119,13 +119,7 @@ class BlockSvg extends Block { * method for the default mutation dialog button and UI to appear. * @type {undefined|?function(!BlockSvg)} */ - this.compose = undefined; - - /** - * An optional method for defining custom block context menu items. - * @type {undefined|?function(!Array)} - */ - this.customContextMenu = undefined; + this.compose; /** * An property used internally to reference the block's rendering debugger. From 554b73806b1915369850bad12a18a06e8d111784 Mon Sep 17 00:00:00 2001 From: Beka Westberg Date: Thu, 3 Mar 2022 18:01:19 +0000 Subject: [PATCH 2/2] fix: move rendered-specific properties back into BlockSvg --- core/block.js | 31 ------------------------------- core/block_svg.js | 18 ++++++++++++++++-- tests/deps.js | 2 +- 3 files changed, 17 insertions(+), 34 deletions(-) diff --git a/core/block.js b/core/block.js index 2868545cf3d..1cf13246ebd 100644 --- a/core/block.js +++ b/core/block.js @@ -162,37 +162,6 @@ class Block { */ this.loadExtraState = undefined; - /** - * An optional method called by the default mutator UI which allows the - * block to "explode" itself into smaller sub blocks. This function should - * return a "top block" which is the main block in the mutator workspace - * that sub-blocks connect to. - * @type {undefined|?function():!Block} - */ - this.decompose = undefined; - - /** - * An optional method called by the deafult mutator UI which allows the - * block to configure itself based on the configuration of sub-blocks in - * the mutator workspace. This function should accept the "top block" which - * was returned by `decompose` as a paramter. - * @type {undefined|?function(!Block)} - */ - this.compose = undefined; - - /** - * An optional method called by the default mutator UI which gives the block - * a chance to save information about what child blocks are connected to - * what mutated connections. - * @type {undefined|?function(!Block)} - */ - this.saveConnections = undefined; - - /** - * An optional method for defining custom block context menu items. - * @type {undefined|?function(!Array)} - */ - this.customContextMenu = undefined; /** * An optional property for suppressing adding STATEMENT_PREFIX and diff --git a/core/block_svg.js b/core/block_svg.js index 98a81c62532..cc1e662893a 100644 --- a/core/block_svg.js +++ b/core/block_svg.js @@ -110,7 +110,7 @@ class BlockSvg extends Block { * mutation dialog button and UI to appear. * @type {undefined|?function(WorkspaceSvg):!BlockSvg} */ - this.decompose; + this.decompose = this.decompose; /** * An optional method called when a mutator dialog saves its content. @@ -119,7 +119,21 @@ class BlockSvg extends Block { * method for the default mutation dialog button and UI to appear. * @type {undefined|?function(!BlockSvg)} */ - this.compose; + this.compose = this.compose; + + /** + * An optional method called by the default mutator UI which gives the block + * a chance to save information about what child blocks are connected to + * what mutated connections. + * @type {undefined|?function(!BlockSvg)} + */ + this.saveConnections = this.saveConnections; + + /** + * An optional method for defining custom block context menu items. + * @type {undefined|?function(!Array)} + */ + this.customContextMenu = this.customContextMenu; /** * An property used internally to reference the block's rendering debugger. diff --git a/tests/deps.js b/tests/deps.js index 24df7a3c00e..ef4b6e87f34 100644 --- a/tests/deps.js +++ b/tests/deps.js @@ -143,7 +143,7 @@ goog.addDependency('../../core/registry.js', ['Blockly.registry'], [], {'lang': goog.addDependency('../../core/rendered_connection.js', ['Blockly.RenderedConnection'], ['Blockly.Connection', 'Blockly.ConnectionType', 'Blockly.Events.utils', 'Blockly.common', 'Blockly.config', 'Blockly.internalConstants', 'Blockly.utils.Coordinate', 'Blockly.utils.Svg', 'Blockly.utils.dom', 'Blockly.utils.svgMath', 'Blockly.utils.svgPaths'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/renderers/common/block_rendering.js', ['Blockly.blockRendering'], ['Blockly.blockRendering.BottomRow', 'Blockly.blockRendering.Connection', 'Blockly.blockRendering.ConstantProvider', 'Blockly.blockRendering.Debug', 'Blockly.blockRendering.Drawer', 'Blockly.blockRendering.ExternalValueInput', 'Blockly.blockRendering.Field', 'Blockly.blockRendering.Hat', 'Blockly.blockRendering.IPathObject', 'Blockly.blockRendering.Icon', 'Blockly.blockRendering.InRowSpacer', 'Blockly.blockRendering.InlineInput', 'Blockly.blockRendering.InputConnection', 'Blockly.blockRendering.InputRow', 'Blockly.blockRendering.JaggedEdge', 'Blockly.blockRendering.MarkerSvg', 'Blockly.blockRendering.Measurable', 'Blockly.blockRendering.NextConnection', 'Blockly.blockRendering.OutputConnection', 'Blockly.blockRendering.PathObject', 'Blockly.blockRendering.PreviousConnection', 'Blockly.blockRendering.RenderInfo', 'Blockly.blockRendering.Renderer', 'Blockly.blockRendering.RoundCorner', 'Blockly.blockRendering.Row', 'Blockly.blockRendering.SpacerRow', 'Blockly.blockRendering.SquareCorner', 'Blockly.blockRendering.StatementInput', 'Blockly.blockRendering.TopRow', 'Blockly.blockRendering.Types', 'Blockly.blockRendering.debug', 'Blockly.registry', 'Blockly.utils.deprecation'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/renderers/common/constants.js', ['Blockly.blockRendering.ConstantProvider'], ['Blockly.ConnectionType', 'Blockly.utils.Svg', 'Blockly.utils.colour', 'Blockly.utils.dom', 'Blockly.utils.object', 'Blockly.utils.parsing', 'Blockly.utils.svgPaths', 'Blockly.utils.userAgent'], {'lang': 'es6', 'module': 'goog'}); -goog.addDependency('../../core/renderers/common/debug.js', ['Blockly.blockRendering.debug'], [], {'lang': 'es6', 'module': 'goog'}); +goog.addDependency('../../core/renderers/common/debug.js', ['Blockly.blockRendering.debug'], ['Blockly.utils.deprecation'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/renderers/common/debugger.js', ['Blockly.blockRendering.Debug'], ['Blockly.ConnectionType', 'Blockly.FieldLabel', 'Blockly.blockRendering.Field', 'Blockly.blockRendering.InputConnection', 'Blockly.blockRendering.Types', 'Blockly.utils.Svg', 'Blockly.utils.dom'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/renderers/common/drawer.js', ['Blockly.blockRendering.Drawer'], ['Blockly.blockRendering.Connection', 'Blockly.blockRendering.Types', 'Blockly.blockRendering.debug', 'Blockly.utils.svgPaths'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/renderers/common/i_path_object.js', ['Blockly.blockRendering.IPathObject'], [], {'lang': 'es6', 'module': 'goog'});