Use registry to instantiate flyout from trashcan (#4706)

* Instantiate flyouts using registry in trashcan
This commit is contained in:
Sam El-Husseini
2021-03-16 08:54:13 -07:00
committed by GitHub
parent d58c80db76
commit 82a2dd90a7

View File

@@ -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));
};