Add IDs to bubbles.

This commit is contained in:
Neil Fraser
2018-03-13 15:42:04 -07:00
committed by Neil Fraser
parent 7c48c271fd
commit 867dcdb716
5 changed files with 15 additions and 1 deletions

View File

@@ -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);

View File

@@ -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.

View File

@@ -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 {

View File

@@ -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_);

View File

@@ -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.