From 067fbb44884ad3cd06d17e7702f31b72a230879d Mon Sep 17 00:00:00 2001 From: Rachel Fenichel Date: Mon, 11 Nov 2019 15:17:26 -0800 Subject: [PATCH] Move highlightForReplacement into the path object as well. --- core/block_svg.js | 8 +------- core/renderers/common/i_path_object.js | 9 +++++++++ core/renderers/common/path_object.js | 12 ++++++++++++ 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/core/block_svg.js b/core/block_svg.js index 057f0d60c..cfcb3d6e6 100644 --- a/core/block_svg.js +++ b/core/block_svg.js @@ -1756,11 +1756,5 @@ Blockly.BlockSvg.prototype.getHeightWidth = function() { * @package */ Blockly.BlockSvg.prototype.highlightForReplacement = function(add) { - if (add) { - Blockly.utils.dom.addClass(/** @type {!Element} */ (this.svgGroup_), - 'blocklyReplaceable'); - } else { - Blockly.utils.dom.removeClass(/** @type {!Element} */ (this.svgGroup_), - 'blocklyReplaceable'); - } + this.pathObject.updateReplacementHighlight(add); }; diff --git a/core/renderers/common/i_path_object.js b/core/renderers/common/i_path_object.js index b7f6b405a..f9c7855fc 100644 --- a/core/renderers/common/i_path_object.js +++ b/core/renderers/common/i_path_object.js @@ -111,3 +111,12 @@ Blockly.blockRendering.IPathObject.prototype.updateInsertionMarker; * @package */ Blockly.blockRendering.IPathObject.prototype.updateMovable; + +/** + * Add or remove styling that shows that if the dragging block is dropped, this + * block will be replaced. If a shadow block, it will disappear. Otherwise it + * will bump. + * @param {boolean} enable True if styling should be added. + * @package + */ +Blockly.blockRendering.PathObject.prototype.updateReplacementHighlight; diff --git a/core/renderers/common/path_object.js b/core/renderers/common/path_object.js index f7ba75373..9766b8ff9 100644 --- a/core/renderers/common/path_object.js +++ b/core/renderers/common/path_object.js @@ -221,3 +221,15 @@ Blockly.blockRendering.PathObject.prototype.updateMovable = function(enable) { this.setClass_('blocklyDraggable', enable); }; +/** + * Add or remove styling that shows that if the dragging block is dropped, this + * block will be replaced. If a shadow block, it will disappear. Otherwise it + * will bump. + * @param {boolean} enable True if styling should be added. + * @package + */ +Blockly.blockRendering.PathObject.prototype.updateReplacementHighlight = + function(enable) { + /* eslint-disable indent */ + this.setClass_('blocklyReplaceable', enable); +}; /* eslint-enable indent */