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

@@ -13,10 +13,10 @@
goog.module('Blockly.serialization.workspaces');
goog.module.declareLegacyNamespace();
const Events = goog.require('Blockly.Events');
// eslint-disable-next-line no-unused-vars
const Workspace = goog.require('Blockly.Workspace');
const dom = goog.require('Blockly.utils.dom');
const eventUtils = goog.require('Blockly.Events.utils');
const registry = goog.require('Blockly.registry');
@@ -57,11 +57,11 @@ const load = function(state, workspace, {recordUndo = false} = {}) {
.sort(([, {priority: priorityA}], [, {priority: priorityB}]) =>
priorityB - priorityA);
const prevRecordUndo = Events.getRecordUndo();
Events.setRecordUndo(recordUndo);
const existingGroup = Events.getGroup();
const prevRecordUndo = eventUtils.getRecordUndo();
eventUtils.setRecordUndo(recordUndo);
const existingGroup = eventUtils.getGroup();
if (!existingGroup) {
Events.setGroup(true);
eventUtils.setGroup(true);
}
dom.startTextWidthCache();
@@ -89,9 +89,9 @@ const load = function(state, workspace, {recordUndo = false} = {}) {
}
dom.stopTextWidthCache();
Events.fire(new (Events.get(Events.FINISHED_LOADING))(workspace));
eventUtils.fire(new (eventUtils.get(eventUtils.FINISHED_LOADING))(workspace));
Events.setGroup(existingGroup);
Events.setRecordUndo(prevRecordUndo);
eventUtils.setGroup(existingGroup);
eventUtils.setRecordUndo(prevRecordUndo);
};
exports.load = load;