Skip to content

Commit

Permalink
feat: Allow specifying the placeholder text of workspace comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
gonfunko committed Oct 1, 2024
1 parent ad07e6c commit fa9ebf1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions core/comments/comment_view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions core/comments/rendered_workspace_comment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion core/contextmenu_items.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit fa9ebf1

Please sign in to comment.