feat: Allow specifying the placeholder text of workspace comments. (#8608)

This commit is contained in:
Aaron Dodson
2024-10-02 10:32:44 -07:00
committed by GitHub
parent 14c9b1abcb
commit 2dfd8c30ad
3 changed files with 11 additions and 1 deletions

View File

@@ -684,6 +684,11 @@ export class CommentView implements IRenderedElement {
this.onTextChange();
}
/** Sets the placeholder text displayed for an empty comment. */
setPlaceholderText(text: string) {
this.textArea.placeholder = text;
}
/** Registers a callback that listens for text changes. */
addTextChangeListener(listener: (oldText: string, newText: string) => void) {
this.textChangeListeners.push(listener);

View File

@@ -104,6 +104,11 @@ export class RenderedWorkspaceComment
this.view.setText(text);
}
/** Sets the placeholder text displayed if the comment is empty. */
setPlaceholderText(text: string): void {
this.view.setPlaceholderText(text);
}
/** Sets the size of the comment. */
override setSize(size: Size) {
// setSize will trigger the change listener that updates

View File

@@ -617,7 +617,7 @@ export function registerCommentCreate() {
if (!workspace) return;
eventUtils.setGroup(true);
const comment = new RenderedWorkspaceComment(workspace);
comment.setText(Msg['WORKSPACE_COMMENT_DEFAULT_TEXT']);
comment.setPlaceholderText(Msg['WORKSPACE_COMMENT_DEFAULT_TEXT']);
comment.moveTo(
pixelsToWorkspaceCoords(
new Coordinate(e.clientX, e.clientY),