in core/workspace_comment_render_svg.js [102:210]
Blockly.WorkspaceCommentSvg.prototype.render = function() {
if (this.rendered_) {
return;
}
var size = this.getHeightWidth();
// Add text area
if (!this.isEditable() || Blockly.utils.userAgent.IE) {
this.createUneditableText_()
this.svgGroup_.appendChild(this.uneditableTextGroup_);
} else {
this.commentEditor_ = this.createEditor_();
this.svgGroup_.appendChild(this.commentEditor_);
}
var backdrop = this.commentEditor_ || this.uneditableTextGroup_;
this.svgHandleTarget_ = Blockly.utils.dom.createSvgElement(
Blockly.utils.Svg.RECT,
// pxt-blockly: Custom comment rendering
{
'class': 'blocklyCommentHandleTarget',
'fill': 'transparent',
'rx': Blockly.WorkspaceCommentSvg.BORDER_WIDTH,
'ry': Blockly.WorkspaceCommentSvg.BORDER_WIDTH,
'height': Blockly.WorkspaceCommentSvg.TOP_BAR_HEIGHT
}, this.svgGroup_);
this.svgGroup_.appendChild(this.svgHandleTarget_);
this.svgRectTarget_ = Blockly.utils.dom.createSvgElement(
Blockly.utils.Svg.RECT,
{
'class': 'blocklyDraggable blocklyCommentTarget',
'x': 0,
'y': 0,
'rx': 4 * Blockly.WorkspaceCommentSvg.BORDER_WIDTH,
'ry': 4 * Blockly.WorkspaceCommentSvg.BORDER_WIDTH
}, this.svgGroup_);
if (this.isEditable() && !Blockly.utils.userAgent.IE) {
// Add the resize icon
this.addResizeDom_();
// pxt-blockly: Custom workspace comment delete rendering
// if (this.isDeletable()) {
// // Add the delete icon
// this.addDeleteDom_();
// }
}
this.createTopBarIcons_();
this.createTopBarLabel_();
// Show / hide relevant things based on minimized state
if (this.isMinimized()) {
this.minimizeArrow_.setAttributeNS('http://www.w3.org/1999/xlink',
'xlink:href', Blockly.mainWorkspace.options.pathToMedia + 'comment-arrow-up.svg');
backdrop.setAttribute('display', 'none');
this.resizeGroup_.setAttribute('display', 'none');
} else {
this.minimizeArrow_.setAttributeNS('http://www.w3.org/1999/xlink',
'xlink:href', Blockly.mainWorkspace.options.pathToMedia + 'comment-arrow-down.svg');
this.topBarLabel_.setAttribute('display', 'none');
}
// Set the content
if (this.textarea_) {
this.textarea_.value = this.content_;
} else {
// Split up the text content into multiple lines
for (var i = 0; i < this.content_.length; i += Blockly.WorkspaceCommentSvg.UNEDITABLE_TEXT_LENGTH) {
var line = this.content_.substring(i, i + Blockly.WorkspaceCommentSvg.UNEDITABLE_TEXT_LENGTH);
this.pushUneditableTextLine_(line);
}
}
if (this.isEditable() && !Blockly.utils.userAgent.IE) {
this.setSize(size.width, size.height);
} else {
var width = Blockly.WorkspaceCommentSvg.UNEDITABLE_TEXT_LENGTH * 8;
width += 25;
var height = this.uneditableTextLineY - 10;
this.setSize(width, height);
}
this.rendered_ = true;
if (this.resizeGroup_) {
Blockly.browserEvents.conditionalBind(
this.resizeGroup_, 'mousedown', this, this.resizeMouseDown_);
Blockly.bindEventWithChecks_(
this.resizeGroup_, 'mouseup', this, this.resizeMouseUp_);
}
Blockly.bindEventWithChecks_(
this.minimizeArrow_, 'mousedown', this, this.minimizeArrowMouseDown_);
Blockly.bindEventWithChecks_(
this.minimizeArrow_, 'mouseout', this, this.minimizeArrowMouseOut_);
Blockly.bindEventWithChecks_(
this.minimizeArrow_, 'mouseup', this, this.minimizeArrowMouseUp_);
if (this.isDeletable()) {
Blockly.browserEvents.conditionalBind(
this.deleteGroup_, 'mousedown', this, this.deleteMouseDown_);
Blockly.browserEvents.conditionalBind(
this.deleteGroup_, 'mouseout', this, this.deleteMouseOut_);
Blockly.browserEvents.conditionalBind(
this.deleteGroup_, 'mouseup', this, this.deleteMouseUp_);
}
};