chore: remove declareLegacyNamespace from events (#5532)

- Adds an extra events/utils.js file to hold helper methods related to events.
This commit is contained in:
alschmiedt
2021-09-24 14:20:32 -07:00
committed by GitHub
parent 16b6d4526a
commit 2b34748e0e
72 changed files with 1243 additions and 1126 deletions

View File

@@ -15,7 +15,6 @@ goog.module('Blockly.ContextMenu');
/* eslint-disable-next-line no-unused-vars */
const WorkspaceSvg = goog.requireType('Blockly.WorkspaceSvg');
const Coordinate = goog.require('Blockly.utils.Coordinate');
const Events = goog.require('Blockly.Events');
const Menu = goog.require('Blockly.Menu');
const MenuItem = goog.require('Blockly.MenuItem');
const Msg = goog.require('Blockly.Msg');
@@ -27,6 +26,7 @@ const browserEvents = goog.require('Blockly.browserEvents');
const clipboard = goog.require('Blockly.clipboard');
const deprecation = goog.require('Blockly.utils.deprecation');
const dom = goog.require('Blockly.utils.dom');
const eventUtils = goog.require('Blockly.Events.utils');
const internalConstants = goog.require('Blockly.internalConstants');
const userAgent = goog.require('Blockly.utils.userAgent');
const utils = goog.require('Blockly.utils');
@@ -242,7 +242,7 @@ exports.dispose = dispose;
*/
const callbackFactory = function(block, xml) {
return function() {
Events.disable();
eventUtils.disable();
let newBlock;
try {
newBlock = Xml.domToBlock(xml, block.workspace);
@@ -256,10 +256,10 @@ const callbackFactory = function(block, xml) {
xy.y += internalConstants.SNAP_RADIUS * 2;
newBlock.moveBy(xy.x, xy.y);
} finally {
Events.enable();
eventUtils.enable();
}
if (Events.isEnabled() && !newBlock.isShadow()) {
Events.fire(new (Events.get(Events.BLOCK_CREATE))(newBlock));
if (eventUtils.isEnabled() && !newBlock.isShadow()) {
eventUtils.fire(new (eventUtils.get(eventUtils.BLOCK_CREATE))(newBlock));
}
newBlock.select();
};
@@ -279,9 +279,9 @@ const commentDeleteOption = function(comment) {
text: Msg['REMOVE_COMMENT'],
enabled: true,
callback: function() {
Events.setGroup(true);
eventUtils.setGroup(true);
comment.dispose();
Events.setGroup(false);
eventUtils.setGroup(false);
}
};
return deleteOption;