mirror of
https://github.com/google/blockly.git
synced 2026-01-09 10:00:09 +01:00
83 lines
2.2 KiB
JavaScript
83 lines
2.2 KiB
JavaScript
/**
|
|
* @license
|
|
* Copyright 2021 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
/**
|
|
* @fileoverview Common functions used both internally and externally, but which
|
|
* must not be at the top level to avoid circular dependencies.
|
|
* @author fenichel@google.com (Rachel Fenichel)
|
|
*/
|
|
'use strict';
|
|
|
|
goog.module('Blockly.common');
|
|
goog.module.declareLegacyNamespace();
|
|
|
|
/* eslint-disable-next-line no-unused-vars */
|
|
const Connection = goog.requireType('Blockly.Connection');
|
|
/* eslint-disable-next-line no-unused-vars */
|
|
const Workspace = goog.requireType('Blockly.Workspace');
|
|
|
|
|
|
/**
|
|
* The main workspace most recently used.
|
|
* Set by Blockly.WorkspaceSvg.prototype.markFocused
|
|
* @type {!Workspace}
|
|
*/
|
|
let mainWorkspace;
|
|
|
|
/**
|
|
* Returns the last used top level workspace (based on focus). Try not to use
|
|
* this function, particularly if there are multiple Blockly instances on a
|
|
* page.
|
|
* @return {!Workspace} The main workspace.
|
|
*/
|
|
const getMainWorkspace = function() {
|
|
return mainWorkspace;
|
|
};
|
|
exports.getMainWorkspace = getMainWorkspace;
|
|
|
|
/**
|
|
* Sets last used main workspace.
|
|
* @param {!Workspace} workspace The most recently used top level workspace.
|
|
*/
|
|
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} The parent container.
|
|
*/
|
|
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;
|
|
|
|
/**
|
|
* All of the connections on blocks that are currently being dragged.
|
|
* @type {!Array<!Connection>}
|
|
*/
|
|
exports.draggingConnections = [];
|