Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: convert some files to es classes #5917

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion core/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ const parsing = goog.require('Blockly.utils.parsing');
const {Abstract} = goog.requireType('Blockly.Events.Abstract');
const {Align, Input} = goog.require('Blockly.Input');
const {ASTNode} = goog.require('Blockly.ASTNode');
/* eslint-disable-next-line no-unused-vars */
const {BlockMove} = goog.requireType('Blockly.Events.BlockMove');
const {Blocks} = goog.require('Blockly.blocks');
/* eslint-disable-next-line no-unused-vars */
const {Comment} = goog.requireType('Blockly.Comment');
Expand Down Expand Up @@ -2098,7 +2100,8 @@ Block.prototype.moveBy = function(dx, dy) {
if (this.parentBlock_) {
throw Error('Block has parent.');
}
const event = new (eventUtils.get(eventUtils.BLOCK_MOVE))(this);
const event = /** @type {!BlockMove} */ (
new (eventUtils.get(eventUtils.BLOCK_MOVE))(this));
this.xy_.translate(dx, dy);
event.recordNew();
eventUtils.fire(event);
Expand Down
6 changes: 4 additions & 2 deletions core/block_dragger.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ const dom = goog.require('Blockly.utils.dom');
const eventUtils = goog.require('Blockly.Events.utils');
const registry = goog.require('Blockly.registry');
/* eslint-disable-next-line no-unused-vars */
const {BlockMove} = goog.requireType('Blockly.Events.BlockMove');
/* eslint-disable-next-line no-unused-vars */
const {BlockSvg} = goog.requireType('Blockly.BlockSvg');
const {Coordinate} = goog.require('Blockly.utils.Coordinate');
/* eslint-disable-next-line no-unused-vars */
Expand Down Expand Up @@ -376,8 +378,8 @@ const BlockDragger = class {
* @protected
*/
fireMoveEvent_() {
const event =
new (eventUtils.get(eventUtils.BLOCK_MOVE))(this.draggingBlock_);
const event = /** @type {!BlockMove} */
(new (eventUtils.get(eventUtils.BLOCK_MOVE))(this.draggingBlock_));
event.oldCoordinate = this.startXY_;
event.recordNew();
eventUtils.fire(event);
Expand Down
5 changes: 4 additions & 1 deletion core/block_svg.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ const userAgent = goog.require('Blockly.utils.userAgent');
const {ASTNode} = goog.require('Blockly.ASTNode');
const {Block} = goog.require('Blockly.Block');
/* eslint-disable-next-line no-unused-vars */
const {BlockMove} = goog.requireType('Blockly.Events.BlockMove');
/* eslint-disable-next-line no-unused-vars */
const {Comment} = goog.requireType('Blockly.Comment');
const {ConnectionType} = goog.require('Blockly.ConnectionType');
/* eslint-disable-next-line no-unused-vars */
Expand Down Expand Up @@ -468,7 +470,8 @@ BlockSvg.prototype.moveBy = function(dx, dy) {
const eventsEnabled = eventUtils.isEnabled();
let event;
if (eventsEnabled) {
event = new (eventUtils.get(eventUtils.BLOCK_MOVE))(this);
event = /** @type {!BlockMove} */
(new (eventUtils.get(eventUtils.BLOCK_MOVE))(this));
}
const xy = this.getRelativeToSurfaceXY();
this.translate(xy.x + dx, xy.y + dy);
Expand Down
7 changes: 5 additions & 2 deletions core/bubble_dragger.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ const eventUtils = goog.require('Blockly.Events.utils');
const svgMath = goog.require('Blockly.utils.svgMath');
/* eslint-disable-next-line no-unused-vars */
const {BlockDragSurfaceSvg} = goog.requireType('Blockly.BlockDragSurfaceSvg');
/* eslint-disable-next-line no-unused-vars */
const {CommentMove} = goog.requireType('Blockly.Events.CommentMove');
const {ComponentManager} = goog.require('Blockly.ComponentManager');
const {Coordinate} = goog.require('Blockly.utils.Coordinate');
/* eslint-disable-next-line no-unused-vars */
Expand Down Expand Up @@ -244,8 +246,9 @@ const BubbleDragger = class {
if (this.draggingBubble_.isComment) {
// TODO (adodson): Resolve build errors when requiring
// WorkspaceCommentSvg.
const event = new (eventUtils.get(eventUtils.COMMENT_MOVE))(
/** @type {!WorkspaceCommentSvg} */ (this.draggingBubble_));
const event = /** @type {!CommentMove} */
(new (eventUtils.get(eventUtils.COMMENT_MOVE))(
/** @type {!WorkspaceCommentSvg} */ (this.draggingBubble_)));
event.setOldCoordinate(this.startXY_);
event.recordNew();
eventUtils.fire(event);
Expand Down
Loading