From 867dcdb7161e21ab331e7e806c84f01df0ab3844 Mon Sep 17 00:00:00 2001 From: Neil Fraser Date: Tue, 13 Mar 2018 15:42:04 -0700 Subject: [PATCH] Add IDs to bubbles. --- core/block_svg.js | 2 +- core/bubble.js | 8 ++++++++ core/comment.js | 2 ++ core/mutator.js | 2 ++ core/warning.js | 2 ++ 5 files changed, 15 insertions(+), 1 deletion(-) diff --git a/core/block_svg.js b/core/block_svg.js index d799c2ea2..52b4e6dc2 100644 --- a/core/block_svg.js +++ b/core/block_svg.js @@ -101,7 +101,7 @@ Blockly.BlockSvg = function(workspace, prototypeName, opt_id) { workspace, prototypeName, opt_id); // Expose this block's ID on its top-level SVG group. - this.svgGroup_.id = this.id; + this.svgGroup_.id = 'block' + this.id; }; goog.inherits(Blockly.BlockSvg, Blockly.Block); diff --git a/core/bubble.js b/core/bubble.js index 73cfa67a0..40a999354 100644 --- a/core/bubble.js +++ b/core/bubble.js @@ -282,6 +282,14 @@ Blockly.Bubble.prototype.getSvgRoot = function() { return this.bubbleGroup_; }; +/** + * Expose the block's ID on the bubble's top-level SVG group. + * @param {string} id Bubble type and ID of block. + */ +Blockly.Bubble.prototype.setSvgId = function(id) { + this.bubbleGroup_.id = id; +}; + /** * Handle a mouse-down on bubble's border. * @param {!Event} e Mouse down event. diff --git a/core/comment.js b/core/comment.js index f6815a30a..61f2aaaf9 100644 --- a/core/comment.js +++ b/core/comment.js @@ -200,6 +200,8 @@ Blockly.Comment.prototype.setVisible = function(visible) { /** @type {!Blockly.WorkspaceSvg} */ (this.block_.workspace), this.createEditor_(), this.block_.svgPath_, this.iconXY_, this.width_, this.height_); + // Expose this comment's block's ID on its top-level SVG group. + this.bubble_.setSvgId('comment' + this.block_.id); this.bubble_.registerResizeEvent(this.resizeBubble_.bind(this)); this.updateColour(); } else { diff --git a/core/mutator.js b/core/mutator.js index f6690e2fa..f80d915f2 100644 --- a/core/mutator.js +++ b/core/mutator.js @@ -249,6 +249,8 @@ Blockly.Mutator.prototype.setVisible = function(visible) { this.bubble_ = new Blockly.Bubble( /** @type {!Blockly.WorkspaceSvg} */ (this.block_.workspace), this.createEditor_(), this.block_.svgPath_, this.iconXY_, null, null); + // Expose this mutator's block's ID on its top-level SVG group. + this.bubble_.setSvgId('mutator' + this.block_.id); var tree = this.workspace_.options.languageTree; if (tree) { this.workspace_.flyout_.init(this.workspace_); diff --git a/core/warning.js b/core/warning.js index 6f6cfcd25..72c75bbfb 100644 --- a/core/warning.js +++ b/core/warning.js @@ -124,6 +124,8 @@ Blockly.Warning.prototype.setVisible = function(visible) { this.bubble_ = new Blockly.Bubble( /** @type {!Blockly.WorkspaceSvg} */ (this.block_.workspace), paragraph, this.block_.svgPath_, this.iconXY_, null, null); + // Expose this warning's block's ID on its top-level SVG group. + this.bubble_.setSvgId('warning' + this.block_.id); if (this.block_.RTL) { // Right-align the paragraph. // This cannot be done until the bubble is rendered on screen.