diff --git a/core/comments/comment_view.ts b/core/comments/comment_view.ts index 798f51f961..7146f21cae 100644 --- a/core/comments/comment_view.ts +++ b/core/comments/comment_view.ts @@ -52,7 +52,7 @@ export class CommentView implements IRenderedElement { private textArea: HTMLTextAreaElement; /** The current size of the comment in workspace units. */ - private size: Size = new Size(120, 100); + private size: Size; /** Whether the comment is collapsed or not. */ private collapsed: boolean = false; @@ -102,6 +102,9 @@ export class CommentView implements IRenderedElement { /** Size of this comment when the resize drag was initiated. */ private preResizeSize?: Size; + /** The default size of newly created comments. */ + static defaultCommentSize = new Size(120, 100); + constructor(private readonly workspace: WorkspaceSvg) { this.svgRoot = dom.createSvgElement(Svg.G, { 'class': 'blocklyComment blocklyEditable blocklyDraggable', @@ -128,6 +131,7 @@ export class CommentView implements IRenderedElement { workspace.getLayerManager()?.append(this, layers.BLOCK); // Set size to the default size. + this.size = CommentView.defaultCommentSize; this.setSizeWithoutFiringEvents(this.size); // Set default transform (including inverted scale for RTL). diff --git a/core/comments/workspace_comment.ts b/core/comments/workspace_comment.ts index 0764b5168d..9d50f74fc7 100644 --- a/core/comments/workspace_comment.ts +++ b/core/comments/workspace_comment.ts @@ -11,6 +11,7 @@ import * as idGenerator from '../utils/idgenerator.js'; import * as eventUtils from '../events/utils.js'; import {CommentMove} from '../events/events_comment_move.js'; import {CommentResize} from '../events/events_comment_resize.js'; +import {CommentView} from './comment_view.js'; export class WorkspaceComment { /** The unique identifier for this comment. */ @@ -20,7 +21,7 @@ export class WorkspaceComment { private text = ''; /** The size of the comment in workspace units. */ - private size = new Size(120, 100); + private size: Size; /** Whether the comment is collapsed or not. */ private collapsed = false; @@ -55,6 +56,7 @@ export class WorkspaceComment { id?: string, ) { this.id = id && !workspace.getCommentById(id) ? id : idGenerator.genUid(); + this.size = CommentView.defaultCommentSize; workspace.addTopComment(this);