Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

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

Merged
merged 1 commit into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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