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:
Aaron Dodson
2024-11-04 09:43:17 -08:00
committed by GitHub
parent d053008b80
commit aedcfd6da5
3 changed files with 33 additions and 26 deletions

View File

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