From d99a0829521fcc22f7dca2c839d33cefe89cf602 Mon Sep 17 00:00:00 2001 From: Karishma Chadha Date: Thu, 7 Jun 2018 10:09:38 -0400 Subject: [PATCH 1/3] CommentChange events now store text changes in an object with property text, instead of just a string. --- src/engine/blocks.js | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/engine/blocks.js b/src/engine/blocks.js index 85ef3b204..01e60121f 100644 --- a/src/engine/blocks.js +++ b/src/engine/blocks.js @@ -374,17 +374,15 @@ class Blocks { } const comment = currTarget.comments[e.commentId]; const change = e.newContents_; - if (typeof change === 'object') { - if (change.hasOwnProperty('minimized')) { - comment.minimized = change.minimized; - break; - } else if (change.hasOwnProperty('width') && change.hasOwnProperty('height')){ - comment.width = change.width; - comment.height = change.height; - break; - } - } else if (typeof change === 'string') { - comment.text = change; + if (change.hasOwnProperty('minimized')) { + comment.minimized = change.minimized; + break; + } else if (change.hasOwnProperty('width') && change.hasOwnProperty('height')){ + comment.width = change.width; + comment.height = change.height; + break; + } else if (change.hasOwnProperty('text')) { + comment.text = change.text; break; } log.warn(`Unrecognized comment change: ${ From 7b55d8e7ab07351eb7163d5b4c5f7aa728dcb200 Mon Sep 17 00:00:00 2001 From: Karishma Chadha Date: Thu, 7 Jun 2018 10:18:34 -0400 Subject: [PATCH 2/3] Undo change that moves block comment relative to block move. --- src/engine/blocks.js | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/src/engine/blocks.js b/src/engine/blocks.js index 01e60121f..ef62522af 100644 --- a/src/engine/blocks.js +++ b/src/engine/blocks.js @@ -295,9 +295,8 @@ class Blocks { oldInput: e.oldInputName, newParent: e.newParentId, newInput: e.newInputName, - newCoordinate: e.newCoordinate, - oldCoordinate: e.oldCoordinate - }, optRuntime); + newCoordinate: e.newCoordinate + }); break; case 'dragOutside': if (optRuntime) { @@ -550,10 +549,8 @@ class Blocks { /** * Block management: move blocks from parent to parent * @param {!object} e Blockly move event to be processed - * @param {?Runtime} optRuntime Optional runtime for updating the position - * of a comment on the block that moved. */ - moveBlock (e, optRuntime) { + moveBlock (e) { if (!this._blocks.hasOwnProperty(e.id)) { return; } @@ -562,19 +559,6 @@ class Blocks { if (e.newCoordinate) { this._blocks[e.id].x = e.newCoordinate.x; this._blocks[e.id].y = e.newCoordinate.y; - - // If the moved block has a comment, update the position of the comment. - if (typeof this._blocks[e.id].comment === 'string' && optRuntime && - e.oldCoordinate) { - const commentId = this._blocks[e.id].comment; - const currTarget = optRuntime.getEditingTarget(); - if (currTarget && currTarget.comments.hasOwnProperty(commentId)) { - const deltaX = e.newCoordinate.x - e.oldCoordinate.x; - const deltaY = e.newCoordinate.y - e.oldCoordinate.y; - currTarget.comments[commentId].x += deltaX; - currTarget.comments[commentId].y += deltaY; - } - } } // Remove from any old parent. From 6bc04c4bef30dc0eebbcec1836f16f1d0f6a4816 Mon Sep 17 00:00:00 2001 From: Karishma Chadha Date: Thu, 7 Jun 2018 11:04:03 -0400 Subject: [PATCH 3/3] Let comment change event handler multitask. --- src/engine/blocks.js | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/engine/blocks.js b/src/engine/blocks.js index ef62522af..8234a6e24 100644 --- a/src/engine/blocks.js +++ b/src/engine/blocks.js @@ -375,18 +375,14 @@ class Blocks { const change = e.newContents_; if (change.hasOwnProperty('minimized')) { comment.minimized = change.minimized; - break; - } else if (change.hasOwnProperty('width') && change.hasOwnProperty('height')){ + } + if (change.hasOwnProperty('width') && change.hasOwnProperty('height')){ comment.width = change.width; comment.height = change.height; - break; - } else if (change.hasOwnProperty('text')) { - comment.text = change.text; - break; } - log.warn(`Unrecognized comment change: ${ - JSON.stringify(change)} for comment with id: ${e.commentId}.`); - return; + if (change.hasOwnProperty('text')) { + comment.text = change.text; + } } break; case 'comment_move':