From b9e663f09e8d9070eb5b271c4609dd2234671a14 Mon Sep 17 00:00:00 2001 From: Rachel Fenichel Date: Mon, 15 Nov 2021 16:26:05 -0800 Subject: [PATCH] chore: add deprecation warnings in blockly.js --- core/blockly.js | 26 +++++++++++++++++++++++--- core/common.js | 2 +- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/core/blockly.js b/core/blockly.js index 13c78ae5292..5ada7495ed3 100644 --- a/core/blockly.js +++ b/core/blockly.js @@ -311,9 +311,16 @@ exports.svgSize = common.svgSize; * Size the workspace when the contents change. This also updates * scrollbars accordingly. * @param {!WorkspaceSvg} workspace The workspace to resize. + * @deprecated * @alias Blockly.resizeSvgContents */ -exports.resizeSvgContents = common.resizeSvgContents; +const resizeSvgContents = function(workspace) { + deprecation.warn( + 'Blockly.resizeSvgContents', 'December 2021', 'December 2022', + 'Blockly.common.resizeSvgContents'); + common.resizeSvgContents(workspace); +}; +exports.resizeSvgContents = resizeSvgContents; /** * Copy a block or workspace comment onto the local clipboard. @@ -346,7 +353,13 @@ exports.duplicate = clipboard.duplicate; * @param {boolean=} opt_onlyClosePopups Whether only popups should be closed. * @alias Blockly.hideChaff */ -exports.hideChaff = common.hideChaff; +const hideChaff = function(opt_onlyClosePopups) { + deprecation.warn( + 'Blockly.hideChaff', 'December 2021', 'December 2022', + 'workspace.hideChaff'); + common.hideChaff(opt_onlyClosePopups); +}; +exports.hideChaff = hideChaff; /** * Returns the main workspace. Returns the last used main workspace (based on @@ -369,9 +382,16 @@ exports.defineBlocksWithJsonArray = common.defineBlocksWithJsonArray; * Is the given string a number (includes negative and decimals). * @param {string} str Input string. * @return {boolean} True if number, false otherwise. + * @deprecated * @alias Blockly.isNumber */ -exports.isNumber = utils.math.isNumber; +const isNumber = function(str) { + deprecation.warn( + 'Blockly.isNumber', 'December 2021', 'December 2022', + 'Blockly.utils.math.isNumber'); + return utils.math.isNumber(str); +}; +exports.isNumber = isNumber; /** * Set the parent container. This is the container element that the WidgetDiv, diff --git a/core/common.js b/core/common.js index 8e034f8f348..2a5406bc8e0 100644 --- a/core/common.js +++ b/core/common.js @@ -171,7 +171,7 @@ exports.resizeSvgContents = resizeSvgContents; * Returns the dimensions of the specified SVG image. * @param {!SVGElement} svg SVG image. * @return {!Size} Contains width and height properties. - * @deprecated Use workspace.setCachedParentSvgSize. (2021 March 5) + * @deprecated Use workspace.getCachedParentSvgSize. (2021 March 5) * @alias Blockly.common.svgSize */ const svgSize = function(svg) {