mirror of
https://github.com/google/blockly.git
synced 2026-01-09 01:50:11 +01:00
Migrate core/css.js to goog.module
This commit is contained in:
27
core/css.js
27
core/css.js
@@ -14,7 +14,8 @@
|
||||
* @name Blockly.Css
|
||||
* @namespace
|
||||
*/
|
||||
goog.provide('Blockly.Css');
|
||||
goog.module('Blockly.Css');
|
||||
goog.module.declareLegacyNamespace();
|
||||
|
||||
|
||||
/**
|
||||
@@ -22,7 +23,7 @@ goog.provide('Blockly.Css');
|
||||
* @type {boolean}
|
||||
* @private
|
||||
*/
|
||||
Blockly.Css.injected_ = false;
|
||||
let injected = false;
|
||||
|
||||
/**
|
||||
* Add some CSS to the blob that will be injected later. Allows optional
|
||||
@@ -30,12 +31,12 @@ Blockly.Css.injected_ = false;
|
||||
* The provided array of CSS will be destroyed by this function.
|
||||
* @param {!Array<string>} cssArray Array of CSS strings.
|
||||
*/
|
||||
Blockly.Css.register = function(cssArray) {
|
||||
if (Blockly.Css.injected_) {
|
||||
const register = function(cssArray) {
|
||||
if (injected) {
|
||||
throw Error('CSS already injected');
|
||||
}
|
||||
// Concatenate cssArray onto Blockly.Css.CONTENT.
|
||||
Array.prototype.push.apply(Blockly.Css.CONTENT, cssArray);
|
||||
// Concatenate cssArray onto CONTENT.
|
||||
Array.prototype.push.apply(CONTENT, cssArray);
|
||||
cssArray.length = 0; // Garbage collect provided CSS content.
|
||||
};
|
||||
|
||||
@@ -49,14 +50,14 @@ Blockly.Css.register = function(cssArray) {
|
||||
* (providing CSS becomes the document's responsibility).
|
||||
* @param {string} pathToMedia Path from page to the Blockly media directory.
|
||||
*/
|
||||
Blockly.Css.inject = function(hasCss, pathToMedia) {
|
||||
const inject = function(hasCss, pathToMedia) {
|
||||
// Only inject the CSS once.
|
||||
if (Blockly.Css.injected_) {
|
||||
if (injected) {
|
||||
return;
|
||||
}
|
||||
Blockly.Css.injected_ = true;
|
||||
let text = Blockly.Css.CONTENT.join('\n');
|
||||
Blockly.Css.CONTENT.length = 0; // Garbage collect CSS content.
|
||||
injected = true;
|
||||
let text = CONTENT.join('\n');
|
||||
CONTENT.length = 0; // Garbage collect CSS content.
|
||||
if (!hasCss) {
|
||||
return;
|
||||
}
|
||||
@@ -75,7 +76,7 @@ Blockly.Css.inject = function(hasCss, pathToMedia) {
|
||||
/**
|
||||
* Array making up the CSS content for Blockly.
|
||||
*/
|
||||
Blockly.Css.CONTENT = [
|
||||
const CONTENT = [
|
||||
`.blocklySvg {
|
||||
background-color: #fff;
|
||||
outline: none;
|
||||
@@ -552,3 +553,5 @@ Blockly.Css.CONTENT = [
|
||||
margin-right: -24px;
|
||||
}`,
|
||||
];
|
||||
|
||||
exports = {register, inject, CONTENT};
|
||||
|
||||
@@ -27,7 +27,7 @@ goog.addDependency('../../core/constants.js', ['Blockly.constants'], ['Blockly.c
|
||||
goog.addDependency('../../core/contextmenu.js', ['Blockly.ContextMenu'], ['Blockly.Events', 'Blockly.Events.BlockCreate', 'Blockly.Menu', 'Blockly.MenuItem', 'Blockly.Msg', 'Blockly.WidgetDiv', 'Blockly.Xml', 'Blockly.browserEvents', 'Blockly.constants', 'Blockly.utils', 'Blockly.utils.Coordinate', 'Blockly.utils.Rect', 'Blockly.utils.aria', 'Blockly.utils.dom', 'Blockly.utils.userAgent']);
|
||||
goog.addDependency('../../core/contextmenu_items.js', ['Blockly.ContextMenuItems'], ['Blockly.ContextMenuRegistry', 'Blockly.Events', 'Blockly.constants', 'Blockly.inputTypes'], {'lang': 'es5'});
|
||||
goog.addDependency('../../core/contextmenu_registry.js', ['Blockly.ContextMenuRegistry'], [], {'lang': 'es5'});
|
||||
goog.addDependency('../../core/css.js', ['Blockly.Css'], [], {'lang': 'es5'});
|
||||
goog.addDependency('../../core/css.js', ['Blockly.Css'], [], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../core/delete_area.js', ['Blockly.DeleteArea'], ['Blockly.BlockSvg', 'Blockly.DragTarget', 'Blockly.IDeleteArea']);
|
||||
goog.addDependency('../../core/drag_target.js', ['Blockly.DragTarget'], ['Blockly.IDragTarget']);
|
||||
goog.addDependency('../../core/dropdowndiv.js', ['Blockly.DropDownDiv'], ['Blockly.utils.Rect', 'Blockly.utils.dom', 'Blockly.utils.math', 'Blockly.utils.style']);
|
||||
|
||||
Reference in New Issue
Block a user