diff --git a/core/blockly.js b/core/blockly.js index 2cf685de4..5d109460e 100644 --- a/core/blockly.js +++ b/core/blockly.js @@ -19,11 +19,9 @@ goog.provide('Blockly'); goog.require('Blockly.browserEvents'); goog.require('Blockly.clipboard'); goog.require('Blockly.common'); -goog.require('Blockly.ComponentManager'); goog.require('Blockly.connectionTypes'); goog.require('Blockly.constants'); goog.require('Blockly.dialog'); -goog.require('Blockly.DropDownDiv'); goog.require('Blockly.Events'); /** @suppress {extraRequire} */ goog.require('Blockly.Events.BlockCreate'); @@ -42,7 +40,6 @@ goog.require('Blockly.internalConstants'); /** @suppress {extraRequire} */ goog.require('Blockly.Procedures'); goog.require('Blockly.ShortcutRegistry'); -goog.require('Blockly.Tooltip'); /** @suppress {extraRequire} */ goog.require('Blockly.Touch'); goog.require('Blockly.utils'); @@ -52,7 +49,6 @@ goog.require('Blockly.utils.Size'); goog.require('Blockly.utils.toolbox'); /** @suppress {extraRequire} */ goog.require('Blockly.Variables'); -goog.require('Blockly.WidgetDiv'); goog.require('Blockly.WorkspaceSvg'); /** @suppress {extraRequire} */ goog.require('Blockly.Xml'); @@ -184,7 +180,7 @@ Blockly.onKeyDown = function(e) { Blockly.deleteBlock = function(selected) { if (!selected.workspace.isFlyout) { Blockly.Events.setGroup(true); - Blockly.hideChaff(); + Blockly.common.getMainWorkspace().hideChaff(); if (selected.outputConnection) { // Do not attempt to heal rows // (https://github.com/google/blockly/issues/4832) @@ -232,20 +228,13 @@ Blockly.onContextMenu_ = function(e) { /** * Close tooltips, context menus, dropdown selections, etc. + * @deprecated Use Blockly.common.getMainWorkspace().hideChaff() * @param {boolean=} opt_onlyClosePopups Whether only popups should be closed. */ Blockly.hideChaff = function(opt_onlyClosePopups) { - Blockly.Tooltip.hide(); - Blockly.WidgetDiv.hide(); - Blockly.DropDownDiv.hideWithoutAnimation(); - - var onlyClosePopups = !!opt_onlyClosePopups; - var workspace = Blockly.common.getMainWorkspace(); - var autoHideables = workspace.getComponentManager().getComponents( - Blockly.ComponentManager.Capability.AUTOHIDEABLE, true); - autoHideables.forEach(function(autoHideable) { - autoHideable.autoHide(onlyClosePopups); - }); + Blockly.utils.deprecation.warn( + 'Blockly.hideChaff', 'September 2021', 'September 2022'); + Blockly.common.getMainWorkspace().hideChaff(opt_onlyClosePopups); }; /** diff --git a/core/bubble.js b/core/bubble.js index dbe10cd1b..3abfc61ad 100644 --- a/core/bubble.js +++ b/core/bubble.js @@ -13,8 +13,6 @@ goog.module('Blockly.Bubble'); goog.module.declareLegacyNamespace(); -// TODO(#5073): Fix Blockly requires for Blockly.hideChaff() -// const Blockly = goog.require('Blockly'); /* eslint-disable-next-line no-unused-vars */ const BlockDragSurfaceSvg = goog.requireType('Blockly.BlockDragSurfaceSvg'); /* eslint-disable-next-line no-unused-vars */ @@ -396,7 +394,7 @@ Bubble.prototype.resizeMouseDown_ = function(e) { document, 'mouseup', this, Bubble.bubbleMouseUp_); Bubble.onMouseMoveWrapper_ = browserEvents.conditionalBind( document, 'mousemove', this, this.resizeMouseMove_); - Blockly.hideChaff(); + this.workspace_.hideChaff(); // This event has been handled. No need to bubble up to the document. e.stopPropagation(); }; diff --git a/core/flyout_base.js b/core/flyout_base.js index 43b099aeb..52c9367a1 100644 --- a/core/flyout_base.js +++ b/core/flyout_base.js @@ -15,7 +15,6 @@ goog.module.declareLegacyNamespace(); /* eslint-disable-next-line no-unused-vars */ const Block = goog.requireType('Blockly.Block'); -const Blockly = goog.require('Blockly'); /* eslint-disable-next-line no-unused-vars */ const BlockSvg = goog.requireType('Blockly.BlockSvg'); const ComponentManager = goog.require('Blockly.ComponentManager'); @@ -858,7 +857,7 @@ Flyout.prototype.createBlock = function(originalBlock) { } // Close the flyout. - Blockly.hideChaff(); + this.targetWorkspace.hideChaff(); const newVariables = Variables.getAddedVariables( this.targetWorkspace, variablesBeforeCreation); diff --git a/core/gesture.js b/core/gesture.js index bf28e9315..679b4b69e 100644 --- a/core/gesture.js +++ b/core/gesture.js @@ -490,7 +490,7 @@ Gesture.prototype.doStart = function(e) { // Hide chaff also hides the flyout, so don't do it if the click is in a // flyout. - Blockly.hideChaff(!!this.flyout_); + this.startWorkspace_.hideChaff(!!this.flyout_); this.startWorkspace_.markFocused(); this.mostRecentEvent_ = e; @@ -625,12 +625,12 @@ Gesture.prototype.cancel = function() { Gesture.prototype.handleRightClick = function(e) { if (this.targetBlock_) { this.bringBlockToFront_(); - Blockly.hideChaff(!!this.flyout_); + this.targetBlock_.workspace.hideChaff(!!this.flyout_); this.targetBlock_.showContextMenu(e); } else if (this.startBubble_) { this.startBubble_.showContextMenu(e); } else if (this.startWorkspace_ && !this.flyout_) { - Blockly.hideChaff(); + this.startWorkspace_.hideChaff(); this.startWorkspace_.showContextMenu(e); } diff --git a/core/inject.js b/core/inject.js index 3b807e490..be10e7c08 100644 --- a/core/inject.js +++ b/core/inject.js @@ -213,7 +213,7 @@ const init = function(mainWorkspace) { const workspaceResizeHandler = browserEvents.conditionalBind(window, 'resize', null, function() { - Blockly.hideChaff(true); + mainWorkspace.hideChaff(true); Blockly.svgResize(mainWorkspace); goog.module.get('Blockly.bumpObjects') .bumpTopObjectsIntoBounds(mainWorkspace); diff --git a/core/interfaces/i_autohideable.js b/core/interfaces/i_autohideable.js index c3c7a8125..fa881770a 100644 --- a/core/interfaces/i_autohideable.js +++ b/core/interfaces/i_autohideable.js @@ -6,7 +6,7 @@ /** * @fileoverview The interface for a component that is automatically hidden - * when Blockly.hideChaff is called. + * when WorkspaceSvg.hideChaff is called. * @author kozbial@google.com (Monica Kozbial) */ @@ -27,7 +27,7 @@ const IComponent = goog.requireType('Blockly.IComponent'); const IAutoHideable = function() {}; /** - * Hides the component. Called in Blockly.hideChaff. + * Hides the component. Called in WorkspaceSvg.hideChaff. * @param {boolean} onlyClosePopups Whether only popups should be closed. * Flyouts should not be closed if this is true. */ diff --git a/core/scrollbar.js b/core/scrollbar.js index 9877d8201..980a16f45 100644 --- a/core/scrollbar.js +++ b/core/scrollbar.js @@ -774,7 +774,7 @@ Scrollbar.prototype.onMouseUpHandle_ = function() { * @private */ Scrollbar.prototype.cleanUp_ = function() { - Blockly.hideChaff(true); + this.workspace_.hideChaff(true); if (Scrollbar.onMouseUpWrapper_) { browserEvents.unbind(Scrollbar.onMouseUpWrapper_); Scrollbar.onMouseUpWrapper_ = null; diff --git a/core/shortcut_items.js b/core/shortcut_items.js index 259a8c4bc..73ef30c65 100644 --- a/core/shortcut_items.js +++ b/core/shortcut_items.js @@ -47,8 +47,8 @@ const registerEscape = function() { preconditionFn: function(workspace) { return !workspace.options.readOnly; }, - callback: function() { - Blockly.hideChaff(); + callback: function(workspace) { + workspace.hideChaff(); return true; } }; @@ -101,7 +101,7 @@ const registerCopy = function() { // Prevent the default copy behavior, which may beep or otherwise indicate // an error due to the lack of a selection. e.preventDefault(); - Blockly.hideChaff(); + workspace.hideChaff(); clipboard.copy(/** @type {!ICopyable} */ (Blockly.selected)); return true; } @@ -194,7 +194,7 @@ const registerUndo = function() { }, callback: function(workspace) { // 'z' for undo 'Z' is for redo. - Blockly.hideChaff(); + workspace.hideChaff(); workspace.undo(false); return true; } @@ -228,7 +228,7 @@ const registerRedo = function() { }, callback: function(workspace) { // 'z' for undo 'Z' is for redo. - Blockly.hideChaff(); + workspace.hideChaff(); workspace.undo(true); return true; } diff --git a/core/theme_manager.js b/core/theme_manager.js index 859a33658..d5d1908c7 100644 --- a/core/theme_manager.js +++ b/core/theme_manager.js @@ -113,7 +113,9 @@ ThemeManager.prototype.setTheme = function(theme) { } } - Blockly.hideChaff(); + for (const workspace of this.subscribedWorkspaces_) { + workspace.hideChaff(); + } }; /** diff --git a/core/toolbox/toolbox.js b/core/toolbox/toolbox.js index f5eea1890..3b44eb0c2 100644 --- a/core/toolbox/toolbox.js +++ b/core/toolbox/toolbox.js @@ -50,6 +50,7 @@ const WorkspaceSvg = goog.requireType('Blockly.WorkspaceSvg'); const aria = goog.require('Blockly.utils.aria'); const browserEvents = goog.require('Blockly.browserEvents'); const dom = goog.require('Blockly.utils.dom'); +const common = goog.require('Blockly.common'); const keyCodes = goog.require('Blockly.utils.KeyCodes'); const object = goog.require('Blockly.utils.object'); const registry = goog.require('Blockly.registry'); @@ -315,7 +316,7 @@ Toolbox.prototype.attachEvents_ = function(container, contentsContainer) { Toolbox.prototype.onClick_ = function(e) { if (utils.isRightButton(e) || e.target == this.HtmlDiv) { // Close flyout. - Blockly.hideChaff(false); + common.getMainWorkspace().hideChaff(false); } else { const targetElement = e.target; const itemId = targetElement.getAttribute('id'); @@ -327,7 +328,7 @@ Toolbox.prototype.onClick_ = function(e) { } } // Just close popups. - Blockly.hideChaff(true); + common.getMainWorkspace().hideChaff(true); } Touch.clearTouchIdentifier(); // Don't block future drags. }; @@ -847,7 +848,7 @@ Toolbox.prototype.setVisible = function(isVisible) { }; /** - * Hides the component. Called in Blockly.hideChaff. + * Hides the component. Called in WorkspaceSvg.hideChaff. * @param {boolean} onlyClosePopups Whether only popups should be closed. * Flyouts should not be closed if this is true. */ diff --git a/core/trashcan.js b/core/trashcan.js index b3a459f01..d34cd0803 100644 --- a/core/trashcan.js +++ b/core/trashcan.js @@ -410,7 +410,7 @@ Trashcan.prototype.closeFlyout = function() { }; /** - * Hides the component. Called in Blockly.hideChaff. + * Hides the component. Called in WorkspaceSvg.hideChaff. * @param {boolean} onlyClosePopups Whether only popups should be closed. * Flyouts should not be closed if this is true. */ diff --git a/core/workspace_comment_svg.js b/core/workspace_comment_svg.js index 0b68db82e..1d009af0f 100644 --- a/core/workspace_comment_svg.js +++ b/core/workspace_comment_svg.js @@ -868,7 +868,7 @@ WorkspaceCommentSvg.prototype.resizeMouseDown_ = function(e) { document, 'mouseup', this, this.resizeMouseUp_); this.onMouseMoveWrapper_ = browserEvents.conditionalBind( document, 'mousemove', this, this.resizeMouseMove_); - Blockly.hideChaff(); + this.workspace.hideChaff(); // This event has been handled. No need to bubble up to the document. e.stopPropagation(); }; diff --git a/core/workspace_svg.js b/core/workspace_svg.js index 419879bad..d00289904 100644 --- a/core/workspace_svg.js +++ b/core/workspace_svg.js @@ -28,6 +28,7 @@ const ContextMenuRegistry = goog.require('Blockly.ContextMenuRegistry'); const Coordinate = goog.require('Blockly.utils.Coordinate'); /* eslint-disable-next-line no-unused-vars */ const Cursor = goog.requireType('Blockly.Cursor'); +const DropDownDiv = goog.require('Blockly.DropDownDiv'); const Events = goog.require('Blockly.Events'); /* eslint-disable-next-line no-unused-vars */ const FlyoutButton = goog.requireType('Blockly.FlyoutButton'); @@ -63,6 +64,7 @@ const Svg = goog.require('Blockly.utils.Svg'); /* eslint-disable-next-line no-unused-vars */ const Theme = goog.requireType('Blockly.Theme'); const ThemeManager = goog.require('Blockly.ThemeManager'); +const Tooltip = goog.require('Blockly.Tooltip'); const TouchGesture = goog.require('Blockly.TouchGesture'); /* eslint-disable-next-line no-unused-vars */ const Trashcan = goog.requireType('Blockly.Trashcan'); @@ -72,6 +74,7 @@ const VariableModel = goog.requireType('Blockly.VariableModel'); const Variables = goog.requireType('Blockly.Variables'); /* eslint-disable-next-line no-unused-vars */ const VariablesDynamic = goog.requireType('Blockly.VariablesDynamic'); +const WidgetDiv = goog.require('Blockly.WidgetDiv'); const Workspace = goog.require('Blockly.Workspace'); const WorkspaceAudio = goog.require('Blockly.WorkspaceAudio'); /* eslint-disable-next-line no-unused-vars */ @@ -1443,7 +1446,7 @@ WorkspaceSvg.prototype.setVisible = function(isVisible) { this.toolbox_.position(); } } else { - Blockly.hideChaff(true); + this.hideChaff(true); } }; @@ -2273,7 +2276,7 @@ WorkspaceSvg.prototype.setScale = function(newScale) { } this.scale = newScale; - Blockly.hideChaff(false); + this.hideChaff(false); // Get the flyout, if any, whether our own or owned by the toolbox. const flyout = this.getFlyout(false); if (flyout && flyout.isVisible()) { @@ -2328,7 +2331,7 @@ WorkspaceSvg.prototype.getScale = function() { * @package */ WorkspaceSvg.prototype.scroll = function(x, y) { - Blockly.hideChaff(/* opt_onlyClosePopups */ true); + this.hideChaff(/* opt_onlyClosePopups= */ true); // Keep scrolling within the bounds of the content. const metrics = this.getMetrics(); @@ -2644,4 +2647,20 @@ WorkspaceSvg.prototype.getGrid = function() { return this.grid_; }; +/** + * Close tooltips, context menus, dropdown selections, etc. + * @param {boolean=} opt_onlyClosePopups Whether only popups should be closed. + */ +WorkspaceSvg.prototype.hideChaff = function(opt_onlyClosePopups) { + Tooltip.hide(); + WidgetDiv.hide(); + DropDownDiv.hideWithoutAnimation(); + + var onlyClosePopups = !!opt_onlyClosePopups; + var autoHideables = this.getComponentManager().getComponents( + Blockly.ComponentManager.Capability.AUTOHIDEABLE, true); + autoHideables.forEach( + (autoHideable) => autoHideable.autoHide(onlyClosePopups)); +}; + exports = WorkspaceSvg; diff --git a/demos/blockfactory/app_controller.js b/demos/blockfactory/app_controller.js index 58b70b88d..62157b04a 100644 --- a/demos/blockfactory/app_controller.js +++ b/demos/blockfactory/app_controller.js @@ -631,7 +631,7 @@ AppController.prototype.confirmLeavePage = function(e) { * @param {string} id ID of element to show. */ AppController.prototype.openModal = function(id) { - Blockly.hideChaff(); + Blockly.common.getMainWorkspace().hideChaff(); this.modalName_ = id; document.getElementById(id).style.display = 'block'; document.getElementById('modalShadow').style.display = 'block'; diff --git a/demos/blockfactory/factory.js b/demos/blockfactory/factory.js index 9f01f36f2..49ee849c1 100644 --- a/demos/blockfactory/factory.js +++ b/demos/blockfactory/factory.js @@ -88,7 +88,7 @@ BlockFactory.formatChange = function() { var languageTA = document.getElementById('languageTA'); if (document.getElementById('format').value == 'Manual-JSON' || document.getElementById('format').value == 'Manual-JS') { - Blockly.hideChaff(); + Blockly.common.getMainWorkspace().hideChaff(); mask.style.display = 'block'; languagePre.style.display = 'none'; languageTA.style.display = 'block'; diff --git a/demos/blockfactory_old/factory.js b/demos/blockfactory_old/factory.js index a324a567e..6486bc4f2 100644 --- a/demos/blockfactory_old/factory.js +++ b/demos/blockfactory_old/factory.js @@ -35,7 +35,7 @@ function formatChange() { var languagePre = document.getElementById('languagePre'); var languageTA = document.getElementById('languageTA'); if (document.getElementById('format').value == 'Manual') { - Blockly.hideChaff(); + Blockly.common.getMainWorkspace().hideChaff(); mask.style.display = 'block'; languagePre.style.display = 'none'; languageTA.style.display = 'block'; diff --git a/demos/custom-fields/turtle/index.html b/demos/custom-fields/turtle/index.html index 975d20c8e..dd8cb40af 100644 --- a/demos/custom-fields/turtle/index.html +++ b/demos/custom-fields/turtle/index.html @@ -112,7 +112,7 @@ } function toggleEditable() { - Blockly.hideChaff(); + workspace.hideChaff(); var blocks = workspace.getAllBlocks(false); for(var i = 0, block; block = blocks[i]; i++) { block.setEditable(!block.isEditable()); @@ -120,7 +120,7 @@ } function toggleCollapsed() { - Blockly.hideChaff(); + workspace.hideChaff(); var blocks = workspace.getAllBlocks(false); for(var i = 0, block; block = blocks[i]; i++) { block.setCollapsed(!block.isCollapsed()); diff --git a/tests/deps.js b/tests/deps.js index 0366481cc..d720d5640 100644 --- a/tests/deps.js +++ b/tests/deps.js @@ -12,7 +12,7 @@ goog.addDependency('../../core/block_animations.js', ['Blockly.blockAnimations'] goog.addDependency('../../core/block_drag_surface.js', ['Blockly.BlockDragSurfaceSvg'], ['Blockly.utils', 'Blockly.utils.Coordinate', 'Blockly.utils.Svg', 'Blockly.utils.dom'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/block_dragger.js', ['Blockly.BlockDragger'], ['Blockly.Events', 'Blockly.Events.BlockDrag', 'Blockly.Events.BlockMove', 'Blockly.InsertionMarkerManager', 'Blockly.blockAnimations', 'Blockly.bumpObjects', 'Blockly.common', 'Blockly.registry', 'Blockly.utils.Coordinate', 'Blockly.utils.dom'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/block_svg.js', ['Blockly.BlockSvg'], ['Blockly.ASTNode', 'Blockly.Block', 'Blockly.ContextMenu', 'Blockly.ContextMenuRegistry', 'Blockly.Events', 'Blockly.Events.BlockMove', 'Blockly.Events.Selected', 'Blockly.FieldLabel', 'Blockly.MarkerManager', 'Blockly.Msg', 'Blockly.RenderedConnection', 'Blockly.TabNavigateCursor', 'Blockly.Tooltip', 'Blockly.Touch', 'Blockly.Xml', 'Blockly.blockAnimations', 'Blockly.browserEvents', 'Blockly.common', 'Blockly.connectionTypes', 'Blockly.constants', 'Blockly.internalConstants', 'Blockly.utils', 'Blockly.utils.Coordinate', 'Blockly.utils.Rect', 'Blockly.utils.Svg', 'Blockly.utils.deprecation', 'Blockly.utils.dom', 'Blockly.utils.object', 'Blockly.utils.userAgent'], {'lang': 'es6', 'module': 'goog'}); -goog.addDependency('../../core/blockly.js', ['Blockly'], ['Blockly.ComponentManager', 'Blockly.DropDownDiv', 'Blockly.Events', 'Blockly.Events.BlockCreate', 'Blockly.Events.FinishedLoading', 'Blockly.Events.Ui', 'Blockly.Events.UiBase', 'Blockly.Events.VarCreate', 'Blockly.Procedures', 'Blockly.ShortcutRegistry', 'Blockly.Tooltip', 'Blockly.Touch', 'Blockly.Variables', 'Blockly.WidgetDiv', 'Blockly.WorkspaceSvg', 'Blockly.Xml', 'Blockly.browserEvents', 'Blockly.clipboard', 'Blockly.common', 'Blockly.connectionTypes', 'Blockly.constants', 'Blockly.dialog', 'Blockly.inject', 'Blockly.inputTypes', 'Blockly.internalConstants', 'Blockly.utils', 'Blockly.utils.Size', 'Blockly.utils.colour', 'Blockly.utils.deprecation', 'Blockly.utils.toolbox']); +goog.addDependency('../../core/blockly.js', ['Blockly'], ['Blockly.Events', 'Blockly.Events.BlockCreate', 'Blockly.Events.FinishedLoading', 'Blockly.Events.Ui', 'Blockly.Events.UiBase', 'Blockly.Events.VarCreate', 'Blockly.Procedures', 'Blockly.ShortcutRegistry', 'Blockly.Touch', 'Blockly.Variables', 'Blockly.WorkspaceSvg', 'Blockly.Xml', 'Blockly.browserEvents', 'Blockly.clipboard', 'Blockly.common', 'Blockly.connectionTypes', 'Blockly.constants', 'Blockly.dialog', 'Blockly.inject', 'Blockly.inputTypes', 'Blockly.internalConstants', 'Blockly.utils', 'Blockly.utils.Size', 'Blockly.utils.colour', 'Blockly.utils.deprecation', 'Blockly.utils.toolbox']); goog.addDependency('../../core/blockly_options.js', ['Blockly.BlocklyOptions'], [], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/blocks.js', ['Blockly.Blocks'], [], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/browser_events.js', ['Blockly.browserEvents'], ['Blockly.Touch', 'Blockly.utils.global'], {'lang': 'es6', 'module': 'goog'}); @@ -78,7 +78,7 @@ goog.addDependency('../../core/field_number.js', ['Blockly.FieldNumber'], ['Bloc goog.addDependency('../../core/field_registry.js', ['Blockly.fieldRegistry'], ['Blockly.registry'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/field_textinput.js', ['Blockly.FieldTextInput'], ['Blockly.DropDownDiv', 'Blockly.Events', 'Blockly.Events.BlockChange', 'Blockly.Field', 'Blockly.Msg', 'Blockly.WidgetDiv', 'Blockly.browserEvents', 'Blockly.dialog', 'Blockly.fieldRegistry', 'Blockly.utils', 'Blockly.utils.Coordinate', 'Blockly.utils.KeyCodes', 'Blockly.utils.aria', 'Blockly.utils.dom', 'Blockly.utils.object', 'Blockly.utils.userAgent'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/field_variable.js', ['Blockly.FieldVariable'], ['Blockly.Events.BlockChange', 'Blockly.FieldDropdown', 'Blockly.Msg', 'Blockly.VariableModel', 'Blockly.Variables', 'Blockly.Xml', 'Blockly.fieldRegistry', 'Blockly.internalConstants', 'Blockly.utils', 'Blockly.utils.Size', 'Blockly.utils.object'], {'lang': 'es6', 'module': 'goog'}); -goog.addDependency('../../core/flyout_base.js', ['Blockly.Flyout'], ['Blockly', 'Blockly.ComponentManager', 'Blockly.DeleteArea', 'Blockly.Events', 'Blockly.Events.BlockCreate', 'Blockly.Events.VarCreate', 'Blockly.FlyoutMetricsManager', 'Blockly.Gesture', 'Blockly.ScrollbarPair', 'Blockly.Tooltip', 'Blockly.Touch', 'Blockly.Variables', 'Blockly.WorkspaceSvg', 'Blockly.Xml', 'Blockly.blockRendering', 'Blockly.browserEvents', 'Blockly.utils', 'Blockly.utils.Coordinate', 'Blockly.utils.Svg', 'Blockly.utils.dom', 'Blockly.utils.idGenerator', 'Blockly.utils.object', 'Blockly.utils.toolbox', 'Blockly.utils.xml'], {'lang': 'es6', 'module': 'goog'}); +goog.addDependency('../../core/flyout_base.js', ['Blockly.Flyout'], ['Blockly.ComponentManager', 'Blockly.DeleteArea', 'Blockly.Events', 'Blockly.Events.BlockCreate', 'Blockly.Events.VarCreate', 'Blockly.FlyoutMetricsManager', 'Blockly.Gesture', 'Blockly.ScrollbarPair', 'Blockly.Tooltip', 'Blockly.Touch', 'Blockly.Variables', 'Blockly.WorkspaceSvg', 'Blockly.Xml', 'Blockly.blockRendering', 'Blockly.browserEvents', 'Blockly.utils', 'Blockly.utils.Coordinate', 'Blockly.utils.Svg', 'Blockly.utils.dom', 'Blockly.utils.idGenerator', 'Blockly.utils.object', 'Blockly.utils.toolbox', 'Blockly.utils.xml'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/flyout_button.js', ['Blockly.FlyoutButton'], ['Blockly.Css', 'Blockly.browserEvents', 'Blockly.utils', 'Blockly.utils.Coordinate', 'Blockly.utils.Svg', 'Blockly.utils.dom', 'Blockly.utils.style'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/flyout_horizontal.js', ['Blockly.HorizontalFlyout'], ['Blockly.DropDownDiv', 'Blockly.Flyout', 'Blockly.Scrollbar', 'Blockly.WidgetDiv', 'Blockly.registry', 'Blockly.utils', 'Blockly.utils.Rect', 'Blockly.utils.object', 'Blockly.utils.toolbox'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/flyout_metrics_manager.js', ['Blockly.FlyoutMetricsManager'], ['Blockly.MetricsManager', 'Blockly.utils.object'], {'lang': 'es6', 'module': 'goog'}); @@ -205,7 +205,7 @@ goog.addDependency('../../core/theme_manager.js', ['Blockly.ThemeManager'], ['Bl goog.addDependency('../../core/toolbox/category.js', ['Blockly.ToolboxCategory'], ['Blockly', 'Blockly.Css', 'Blockly.ToolboxItem', 'Blockly.registry', 'Blockly.utils', 'Blockly.utils.aria', 'Blockly.utils.colour', 'Blockly.utils.dom', 'Blockly.utils.object', 'Blockly.utils.toolbox'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/toolbox/collapsible_category.js', ['Blockly.CollapsibleToolboxCategory'], ['Blockly.ToolboxCategory', 'Blockly.ToolboxSeparator', 'Blockly.registry', 'Blockly.utils.aria', 'Blockly.utils.dom', 'Blockly.utils.object', 'Blockly.utils.toolbox'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/toolbox/separator.js', ['Blockly.ToolboxSeparator'], ['Blockly.Css', 'Blockly.ToolboxItem', 'Blockly.registry', 'Blockly.utils.dom', 'Blockly.utils.object'], {'lang': 'es6', 'module': 'goog'}); -goog.addDependency('../../core/toolbox/toolbox.js', ['Blockly.Toolbox'], ['Blockly', 'Blockly.BlockSvg', 'Blockly.CollapsibleToolboxCategory', 'Blockly.ComponentManager', 'Blockly.Css', 'Blockly.DeleteArea', 'Blockly.Events', 'Blockly.Events.ToolboxItemSelect', 'Blockly.Options', 'Blockly.Touch', 'Blockly.browserEvents', 'Blockly.registry', 'Blockly.utils', 'Blockly.utils.KeyCodes', 'Blockly.utils.Rect', 'Blockly.utils.aria', 'Blockly.utils.dom', 'Blockly.utils.object', 'Blockly.utils.toolbox'], {'lang': 'es6', 'module': 'goog'}); +goog.addDependency('../../core/toolbox/toolbox.js', ['Blockly.Toolbox'], ['Blockly', 'Blockly.BlockSvg', 'Blockly.CollapsibleToolboxCategory', 'Blockly.ComponentManager', 'Blockly.Css', 'Blockly.DeleteArea', 'Blockly.Events', 'Blockly.Events.ToolboxItemSelect', 'Blockly.Options', 'Blockly.Touch', 'Blockly.browserEvents', 'Blockly.common', 'Blockly.registry', 'Blockly.utils', 'Blockly.utils.KeyCodes', 'Blockly.utils.Rect', 'Blockly.utils.aria', 'Blockly.utils.dom', 'Blockly.utils.object', 'Blockly.utils.toolbox'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/toolbox/toolbox_item.js', ['Blockly.ToolboxItem'], ['Blockly.utils.idGenerator'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/tooltip.js', ['Blockly.Tooltip'], ['Blockly.browserEvents', 'Blockly.common', 'Blockly.utils.deprecation', 'Blockly.utils.string'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/touch.js', ['Blockly.Touch'], ['Blockly.internalConstants', 'Blockly.utils.global', 'Blockly.utils.string'], {'lang': 'es6', 'module': 'goog'}); @@ -244,7 +244,7 @@ goog.addDependency('../../core/workspace_comment.js', ['Blockly.WorkspaceComment goog.addDependency('../../core/workspace_comment_svg.js', ['Blockly.WorkspaceCommentSvg'], ['Blockly', 'Blockly.ContextMenu', 'Blockly.Css', 'Blockly.Events', 'Blockly.Events.CommentCreate', 'Blockly.Events.CommentDelete', 'Blockly.Events.CommentMove', 'Blockly.Events.Selected', 'Blockly.Touch', 'Blockly.WorkspaceComment', 'Blockly.browserEvents', 'Blockly.utils', 'Blockly.utils.Coordinate', 'Blockly.utils.Rect', 'Blockly.utils.Svg', 'Blockly.utils.dom', 'Blockly.utils.object'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/workspace_drag_surface_svg.js', ['Blockly.WorkspaceDragSurfaceSvg'], ['Blockly.utils', 'Blockly.utils.Svg', 'Blockly.utils.dom'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/workspace_dragger.js', ['Blockly.WorkspaceDragger'], ['Blockly.utils.Coordinate'], {'lang': 'es6', 'module': 'goog'}); -goog.addDependency('../../core/workspace_svg.js', ['Blockly.WorkspaceSvg'], ['Blockly.BlockSvg', 'Blockly.ComponentManager', 'Blockly.ConnectionDB', 'Blockly.ContextMenu', 'Blockly.ContextMenuRegistry', 'Blockly.Events', 'Blockly.Events.BlockCreate', 'Blockly.Events.ThemeChange', 'Blockly.Events.ViewportChange', 'Blockly.Gesture', 'Blockly.Grid', 'Blockly.MarkerManager', 'Blockly.MetricsManager', 'Blockly.Msg', 'Blockly.Options', 'Blockly.ThemeManager', 'Blockly.Themes.Classic', 'Blockly.TouchGesture', 'Blockly.Workspace', 'Blockly.WorkspaceAudio', 'Blockly.Xml', 'Blockly.blockRendering', 'Blockly.browserEvents', 'Blockly.common', 'Blockly.internalConstants', 'Blockly.registry', 'Blockly.utils', 'Blockly.utils.Coordinate', 'Blockly.utils.Rect', 'Blockly.utils.Size', 'Blockly.utils.Svg', 'Blockly.utils.dom', 'Blockly.utils.object', 'Blockly.utils.toolbox'], {'lang': 'es6', 'module': 'goog'}); +goog.addDependency('../../core/workspace_svg.js', ['Blockly.WorkspaceSvg'], ['Blockly.BlockSvg', 'Blockly.ComponentManager', 'Blockly.ConnectionDB', 'Blockly.ContextMenu', 'Blockly.ContextMenuRegistry', 'Blockly.DropDownDiv', 'Blockly.Events', 'Blockly.Events.BlockCreate', 'Blockly.Events.ThemeChange', 'Blockly.Events.ViewportChange', 'Blockly.Gesture', 'Blockly.Grid', 'Blockly.MarkerManager', 'Blockly.MetricsManager', 'Blockly.Msg', 'Blockly.Options', 'Blockly.ThemeManager', 'Blockly.Themes.Classic', 'Blockly.Tooltip', 'Blockly.TouchGesture', 'Blockly.WidgetDiv', 'Blockly.Workspace', 'Blockly.WorkspaceAudio', 'Blockly.Xml', 'Blockly.blockRendering', 'Blockly.browserEvents', 'Blockly.common', 'Blockly.internalConstants', 'Blockly.registry', 'Blockly.utils', 'Blockly.utils.Coordinate', 'Blockly.utils.Rect', 'Blockly.utils.Size', 'Blockly.utils.Svg', 'Blockly.utils.dom', 'Blockly.utils.object', 'Blockly.utils.toolbox'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/xml.js', ['Blockly.Xml'], ['Blockly.Events', 'Blockly.inputTypes', 'Blockly.utils.Size', 'Blockly.utils.dom', 'Blockly.utils.xml'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/zoom_controls.js', ['Blockly.ZoomControls'], ['Blockly.ComponentManager', 'Blockly.Css', 'Blockly.Events', 'Blockly.Events.Click', 'Blockly.Touch', 'Blockly.browserEvents', 'Blockly.internalConstants', 'Blockly.uiPosition', 'Blockly.utils.Rect', 'Blockly.utils.Size', 'Blockly.utils.Svg', 'Blockly.utils.dom'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('base.js', [], []); diff --git a/tests/mocha/keydown_test.js b/tests/mocha/keydown_test.js index 22fdbf96e..c7b39d885 100644 --- a/tests/mocha/keydown_test.js +++ b/tests/mocha/keydown_test.js @@ -39,7 +39,8 @@ suite('Key Down', function() { suite('Escape', function() { setup(function() { this.event = createKeyDownEvent(Blockly.utils.KeyCodes.ESC, 'NotAField'); - this.hideChaffSpy = sinon.spy(Blockly, 'hideChaff'); + this.hideChaffSpy = sinon.spy( + Blockly.WorkspaceSvg.prototype, 'hideChaff'); }); test('Simple', function() { Blockly.onKeyDown(this.event); @@ -60,7 +61,8 @@ suite('Key Down', function() { suite('Delete Block', function() { setup(function() { - this.hideChaffSpy = sinon.spy(Blockly, 'hideChaff'); + this.hideChaffSpy = sinon.spy( + Blockly.WorkspaceSvg.prototype, 'hideChaff'); setSelectedBlock(this.workspace); this.deleteSpy = sinon.spy(Blockly.selected, 'dispose'); }); @@ -94,7 +96,8 @@ suite('Key Down', function() { setup(function() { setSelectedBlock(this.workspace); this.copySpy = sinon.spy(Blockly.clipboard, 'copy'); - this.hideChaffSpy = sinon.spy(Blockly, 'hideChaff'); + this.hideChaffSpy = sinon.spy( + Blockly.WorkspaceSvg.prototype, 'hideChaff'); }); var testCases = [ ['Control C', createKeyDownEvent(Blockly.utils.KeyCodes.C, 'NotAField', [Blockly.utils.KeyCodes.CTRL])], @@ -165,7 +168,8 @@ suite('Key Down', function() { suite('Undo', function() { setup(function() { this.undoSpy = sinon.spy(this.workspace, 'undo'); - this.hideChaffSpy = sinon.spy(Blockly, 'hideChaff'); + this.hideChaffSpy = sinon.spy( + Blockly.WorkspaceSvg.prototype, 'hideChaff'); }); var testCases = [ ['Control Z', createKeyDownEvent(Blockly.utils.KeyCodes.Z, 'NotAField', [Blockly.utils.KeyCodes.CTRL])], @@ -211,7 +215,8 @@ suite('Key Down', function() { suite('Redo', function() { setup(function() { this.redoSpy = sinon.spy(this.workspace, 'undo'); - this.hideChaffSpy = sinon.spy(Blockly, 'hideChaff'); + this.hideChaffSpy = sinon.spy( + Blockly.WorkspaceSvg.prototype, 'hideChaff'); }); var testCases = [ ['Control Shift Z', createKeyDownEvent(Blockly.utils.KeyCodes.Z, 'NotAField', [Blockly.utils.KeyCodes.CTRL, Blockly.utils.KeyCodes.SHIFT])], @@ -258,7 +263,8 @@ suite('Key Down', function() { setup(function() { this.ctrlYEvent = createKeyDownEvent(Blockly.utils.KeyCodes.Y, 'NotAField', [Blockly.utils.KeyCodes.CTRL]); this.undoSpy = sinon.spy(this.workspace, 'undo'); - this.hideChaffSpy = sinon.spy(Blockly, 'hideChaff'); + this.hideChaffSpy = sinon.spy( + Blockly.WorkspaceSvg.prototype, 'hideChaff'); }); test('Simple', function() { Blockly.onKeyDown(this.ctrlYEvent); diff --git a/tests/mocha/toolbox_test.js b/tests/mocha/toolbox_test.js index f494aacc5..f19287664 100644 --- a/tests/mocha/toolbox_test.js +++ b/tests/mocha/toolbox_test.js @@ -135,7 +135,8 @@ suite('Toolbox', function() { }); test('Toolbox clicked -> Should close flyout', function() { - var hideChaffStub = sinon.stub(Blockly, "hideChaff"); + var hideChaffStub = sinon.stub( + Blockly.WorkspaceSvg.prototype, "hideChaff"); var evt = new MouseEvent('click', {}); this.toolbox.HtmlDiv.dispatchEvent(evt); sinon.assert.calledOnce(hideChaffStub);