mirror of
https://github.com/google/blockly.git
synced 2026-01-08 09:30:06 +01:00
fix: Use a readonly textarea for non-editable comments. (#8632)
* fix: Use a readonly textarea for non-editable comments. * chore: Run formatter. * chore: remove old function definition
This commit is contained in:
@@ -63,6 +63,8 @@ export class TextInputBubble extends Bubble {
|
||||
20 + Bubble.DOUBLE_BORDER,
|
||||
);
|
||||
|
||||
private editable = true;
|
||||
|
||||
/**
|
||||
* @param workspace The workspace this bubble belongs to.
|
||||
* @param anchor The anchor location of the thing this bubble is attached to.
|
||||
@@ -96,6 +98,21 @@ export class TextInputBubble extends Bubble {
|
||||
this.onTextChange();
|
||||
}
|
||||
|
||||
/** Sets whether or not the text in the bubble is editable. */
|
||||
setEditable(editable: boolean) {
|
||||
this.editable = editable;
|
||||
if (this.editable) {
|
||||
this.textArea.removeAttribute('readonly');
|
||||
} else {
|
||||
this.textArea.setAttribute('readonly', '');
|
||||
}
|
||||
}
|
||||
|
||||
/** Returns whether or not the text in the bubble is editable. */
|
||||
isEditable(): boolean {
|
||||
return this.editable;
|
||||
}
|
||||
|
||||
/** Adds a change listener to be notified when this bubble's text changes. */
|
||||
addTextChangeListener(listener: () => void) {
|
||||
this.textChangeListeners.push(listener);
|
||||
|
||||
Reference in New Issue
Block a user