mirror of
https://github.com/google/blockly.git
synced 2026-01-08 01:20:12 +01:00
Support a custom container element for the dropdowndiv, widgetdiv and tooltip. (#3772)
* Support a custom container element for the dropdowndiv, widgetdiv and tooltip
This commit is contained in:
@@ -90,6 +90,13 @@ Blockly.clipboardTypeCounts_ = null;
|
||||
*/
|
||||
Blockly.cache3dSupported_ = null;
|
||||
|
||||
/**
|
||||
* Container element to render the WidgetDiv, DropDownDiv and Tooltip.
|
||||
* @type {?Element}
|
||||
* @package
|
||||
*/
|
||||
Blockly.parentContainer = null;
|
||||
|
||||
/**
|
||||
* Blockly opaque event data used to unbind events when using
|
||||
* `Blockly.bindEvent_` and `Blockly.bindEventWithChecks_`.
|
||||
@@ -661,3 +668,14 @@ Blockly.checkBlockColourConstant_ = function(
|
||||
console.warn(warning);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 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} container The container element.
|
||||
*/
|
||||
Blockly.setParentContainer = function(container) {
|
||||
Blockly.parentContainer = container;
|
||||
};
|
||||
|
||||
@@ -127,7 +127,8 @@ Blockly.DropDownDiv.createDom = function() {
|
||||
}
|
||||
var div = document.createElement('div');
|
||||
div.className = 'blocklyDropDownDiv';
|
||||
document.body.appendChild(div);
|
||||
var container = Blockly.parentContainer || document.body;
|
||||
container.appendChild(div);
|
||||
/**
|
||||
* The div element.
|
||||
* @type {!Element}
|
||||
|
||||
@@ -121,7 +121,8 @@ 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';
|
||||
document.body.appendChild(Blockly.Tooltip.DIV);
|
||||
var container = Blockly.parentContainer || document.body;
|
||||
container.appendChild(Blockly.Tooltip.DIV);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -62,7 +62,8 @@ Blockly.WidgetDiv.createDom = function() {
|
||||
*/
|
||||
Blockly.WidgetDiv.DIV = document.createElement('div');
|
||||
Blockly.WidgetDiv.DIV.className = 'blocklyWidgetDiv';
|
||||
document.body.appendChild(Blockly.WidgetDiv.DIV);
|
||||
var container = Blockly.parentContainer || document.body;
|
||||
container.appendChild(Blockly.WidgetDiv.DIV);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user