From 82a2dd90a7f965205882875bf7325dd4428fd0e9 Mon Sep 17 00:00:00 2001 From: Sam El-Husseini Date: Tue, 16 Mar 2021 08:54:13 -0700 Subject: [PATCH] Use registry to instantiate flyout from trashcan (#4706) * Instantiate flyouts using registry in trashcan --- core/trashcan.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/core/trashcan.js b/core/trashcan.js index ba0311ee8..3f25b8585 100644 --- a/core/trashcan.js +++ b/core/trashcan.js @@ -19,6 +19,7 @@ goog.require('Blockly.Events'); /** @suppress {extraRequire} */ goog.require('Blockly.Events.TrashcanOpen'); goog.require('Blockly.IPositionable'); +goog.require('Blockly.registry'); goog.require('Blockly.Scrollbar'); goog.require('Blockly.utils.dom'); goog.require('Blockly.utils.math'); @@ -84,18 +85,18 @@ Blockly.Trashcan = function(workspace) { flyoutWorkspaceOptions.toolboxPosition = this.workspace_.toolboxPosition == Blockly.utils.toolbox.Position.TOP ? Blockly.utils.toolbox.Position.BOTTOM : Blockly.utils.toolbox.Position.TOP; - if (!Blockly.HorizontalFlyout) { - throw Error('Missing require for Blockly.HorizontalFlyout'); - } - this.flyout = new Blockly.HorizontalFlyout(flyoutWorkspaceOptions); + var HorizontalFlyout = Blockly.registry.getClassFromOptions( + Blockly.registry.Type.FLYOUTS_HORIZONTAL_TOOLBOX, + this.workspace_.options, true); + this.flyout = new HorizontalFlyout(flyoutWorkspaceOptions); } else { flyoutWorkspaceOptions.toolboxPosition = this.workspace_.toolboxPosition == Blockly.utils.toolbox.Position.RIGHT ? Blockly.utils.toolbox.Position.LEFT : Blockly.utils.toolbox.Position.RIGHT; - if (!Blockly.VerticalFlyout) { - throw Error('Missing require for Blockly.VerticalFlyout'); - } - this.flyout = new Blockly.VerticalFlyout(flyoutWorkspaceOptions); + var VerticalFlyout = Blockly.registry.getClassFromOptions( + Blockly.registry.Type.FLYOUTS_VERTICAL_TOOLBOX, + this.workspace_.options, true); + this.flyout = new VerticalFlyout(flyoutWorkspaceOptions); } this.workspace_.addChangeListener(this.onDelete_.bind(this)); };