Move set/getParentContainer into common

This commit is contained in:
Rachel Fenichel
2021-07-30 13:55:17 -07:00
parent 084c421597
commit 1eabe91fa6
6 changed files with 38 additions and 13 deletions

View File

@@ -101,13 +101,6 @@ Blockly.selected = null;
*/
Blockly.draggingConnections = [];
/**
* Container element to render the WidgetDiv, DropDownDiv and Tooltip.
* @type {?Element}
* @package
*/
Blockly.parentContainer = null;
/**
* Returns the dimensions of the specified SVG image.
* @param {!SVGElement} svg SVG image.
@@ -377,9 +370,7 @@ Blockly.hueToHex = function(hue) {
* This method is a NOP if called after the first ``Blockly.inject``.
* @param {!Element} container The container element.
*/
Blockly.setParentContainer = function(container) {
Blockly.parentContainer = container;
};
Blockly.setParentContainer = Blockly.common.setParentContainer;
/** Aliases. */

View File

@@ -44,3 +44,31 @@ const setMainWorkspace = function(workspace) {
mainWorkspace = workspace;
};
exports.setMainWorkspace = setMainWorkspace;
/**
* Container element in which to render the WidgetDiv, DropDownDiv and Tooltip.
* @type {?Element}
*/
let parentContainer;
/**
* Get the container element in which to render the WidgetDiv, DropDownDiv and\
* Tooltip.
* @return {?Element}
*/
const getParentContainer = function() {
return parentContainer;
};
exports.getParentContainer = getParentContainer;
/**
* Set the parent container. This is the container element that the WidgetDiv,
* DropDownDiv, and Tooltip are rendered into the first time `Blockly.inject`
* is called.
* This method is a NOP if called after the first ``Blockly.inject``.
* @param {!Element} newParent The container element.
*/
const setParentContainer = function(newParent) {
parentContainer = newParent;
};
exports.setParentContainer = setParentContainer;

View File

@@ -163,7 +163,7 @@ Blockly.DropDownDiv.createDom = function() {
}
var div = document.createElement('div');
div.className = 'blocklyDropDownDiv';
var container = Blockly.parentContainer || document.body;
var container = Blockly.common.getParentContainer() || document.body;
container.appendChild(div);
/**
* The div element.

View File

@@ -22,6 +22,7 @@
goog.provide('Blockly.Tooltip');
goog.require('Blockly.browserEvents');
goog.require('Blockly.common');
goog.require('Blockly.utils.string');
@@ -170,7 +171,7 @@ Blockly.Tooltip.createDom = function() {
// Create an HTML container for popup overlays (e.g. editor widgets).
Blockly.Tooltip.DIV = document.createElement('div');
Blockly.Tooltip.DIV.className = 'blocklyTooltipDiv';
var container = Blockly.parentContainer || document.body;
var container = Blockly.common.getParentContainer() || document.body;
container.appendChild(Blockly.Tooltip.DIV);
};

View File

@@ -67,7 +67,7 @@ Blockly.WidgetDiv.createDom = function() {
*/
Blockly.WidgetDiv.DIV = document.createElement('div');
Blockly.WidgetDiv.DIV.className = 'blocklyWidgetDiv';
var container = Blockly.parentContainer || document.body;
var container = Blockly.common.getParentContainer() || document.body;
container.appendChild(Blockly.WidgetDiv.DIV);
};

View File

@@ -172,8 +172,13 @@ goog.addDependency('../../core/toolbox/category.js', ['Blockly.ToolboxCategory']
goog.addDependency('../../core/toolbox/collapsible_category.js', ['Blockly.CollapsibleToolboxCategory'], ['Blockly.ICollapsibleToolboxItem', '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.BlockSvg', 'Blockly.CollapsibleToolboxCategory', 'Blockly.ComponentManager', 'Blockly.Css', 'Blockly.DeleteArea', 'Blockly.Events', 'Blockly.Events.ToolboxItemSelect', 'Blockly.IAutoHideable', 'Blockly.IKeyboardAccessible', 'Blockly.IStyleable', 'Blockly.IToolbox', 'Blockly.Options', 'Blockly.Touch', 'Blockly.browserEvents', 'Blockly.constants', 'Blockly.registry', 'Blockly.utils', 'Blockly.utils.Rect', 'Blockly.utils.aria', 'Blockly.utils.dom', 'Blockly.utils.toolbox'], {'lang': 'es5'});
<<<<<<< HEAD
goog.addDependency('../../core/toolbox/toolbox_item.js', ['Blockly.ToolboxItem'], ['Blockly.IToolboxItem', 'Blockly.utils.IdGenerator'], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../core/tooltip.js', ['Blockly.Tooltip'], ['Blockly.browserEvents', 'Blockly.utils.string']);
=======
goog.addDependency('../../core/toolbox/toolbox_item.js', ['Blockly.ToolboxItem'], ['Blockly.IToolboxItem']);
goog.addDependency('../../core/tooltip.js', ['Blockly.Tooltip'], ['Blockly.browserEvents', 'Blockly.common', 'Blockly.utils.string']);
>>>>>>> c62fba04 (Move set/getParentContainer into common)
goog.addDependency('../../core/touch.js', ['Blockly.Touch'], ['Blockly.internalConstants', 'Blockly.utils', 'Blockly.utils.global', 'Blockly.utils.string']);
goog.addDependency('../../core/touch_gesture.js', ['Blockly.TouchGesture'], ['Blockly.Gesture', 'Blockly.browserEvents', 'Blockly.utils', 'Blockly.utils.Coordinate', 'Blockly.utils.object']);
goog.addDependency('../../core/trashcan.js', ['Blockly.Trashcan'], ['Blockly.ComponentManager', 'Blockly.DeleteArea', 'Blockly.Events', 'Blockly.Events.TrashcanOpen', 'Blockly.IAutoHideable', 'Blockly.IPositionable', 'Blockly.Options', 'Blockly.Xml', 'Blockly.browserEvents', 'Blockly.internalConstants', 'Blockly.registry', 'Blockly.uiPosition', 'Blockly.utils', 'Blockly.utils.Rect', 'Blockly.utils.Svg', 'Blockly.utils.dom', 'Blockly.utils.toolbox'], {'lang': 'es6', 'module': 'goog'});