mirror of
https://github.com/google/blockly.git
synced 2026-01-10 10:27:08 +01:00
added editable property to workspaceComment (#3480)
* added editable property to workspaceComment
This commit is contained in:
committed by
Sam El-Husseini
parent
f5bb5b6143
commit
7d24276721
@@ -95,6 +95,12 @@ Blockly.WorkspaceComment = function(workspace, content, height, width, opt_id) {
|
||||
*/
|
||||
this.movable_ = true;
|
||||
|
||||
/**
|
||||
* @type {boolean}
|
||||
* @private
|
||||
*/
|
||||
this.editable_ = true;
|
||||
|
||||
/**
|
||||
* @protected
|
||||
* @type {string}
|
||||
@@ -229,6 +235,23 @@ Blockly.WorkspaceComment.prototype.setMovable = function(movable) {
|
||||
this.movable_ = movable;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get whether this comment is editable or not.
|
||||
* @return {boolean} True if editable.
|
||||
*/
|
||||
Blockly.WorkspaceComment.prototype.isEditable = function() {
|
||||
return this.editable_ &&
|
||||
!(this.workspace && this.workspace.options.readOnly);
|
||||
};
|
||||
|
||||
/**
|
||||
* Set whether this comment is editable or not.
|
||||
* @param {boolean} editable True if editable.
|
||||
*/
|
||||
Blockly.WorkspaceComment.prototype.setEditable = function(editable) {
|
||||
this.editable_ = editable;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns this comment's text.
|
||||
* @return {string} Comment text.
|
||||
|
||||
@@ -160,6 +160,7 @@ Blockly.WorkspaceCommentSvg.prototype.createEditor_ = function() {
|
||||
var textarea = document.createElementNS(Blockly.utils.dom.HTML_NS, 'textarea');
|
||||
textarea.className = 'blocklyCommentTextarea';
|
||||
textarea.setAttribute('dir', this.RTL ? 'RTL' : 'LTR');
|
||||
textarea.readOnly = !this.isEditable();
|
||||
body.appendChild(textarea);
|
||||
this.textarea_ = textarea;
|
||||
this.foreignObject_.appendChild(body);
|
||||
|
||||
@@ -483,6 +483,17 @@ Blockly.WorkspaceCommentSvg.prototype.setMovable = function(movable) {
|
||||
this.updateMovable();
|
||||
};
|
||||
|
||||
/**
|
||||
* Set whether this comment is editable or not.
|
||||
* @param {boolean} editable True if editable.
|
||||
*/
|
||||
Blockly.WorkspaceCommentSvg.prototype.setEditable = function(editable) {
|
||||
Blockly.WorkspaceCommentSvg.superClass_.setEditable.call(this, editable);
|
||||
if (this.textarea_) {
|
||||
this.textarea_.readOnly = !editable;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Recursively adds or removes the dragging class to this node and its children.
|
||||
* @param {boolean} adding True if adding, false if removing.
|
||||
|
||||
Reference in New Issue
Block a user