mirror of
https://github.com/google/blockly.git
synced 2026-01-10 02:17:09 +01:00
feat: Allow specifying the placeholder text of workspace comments. (#8608)
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user