From 3fda0fa8c08e7e89a01b518bff4ad7cb91ef14ec Mon Sep 17 00:00:00 2001 From: Chang Min Bark Date: Sun, 14 Jul 2024 03:00:42 -0400 Subject: [PATCH 1/4] fix: added id to rendered ws comments; made getCommentById public; added blocklyDraggable class to ws comments --- core/comments/comment_view.ts | 2 +- core/comments/rendered_workspace_comment.ts | 1 + core/workspace.ts | 1 - 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/comments/comment_view.ts b/core/comments/comment_view.ts index 8fa3ea69473..bda2b9762a8 100644 --- a/core/comments/comment_view.ts +++ b/core/comments/comment_view.ts @@ -104,7 +104,7 @@ export class CommentView implements IRenderedElement { constructor(private readonly workspace: WorkspaceSvg) { this.svgRoot = dom.createSvgElement(Svg.G, { - 'class': 'blocklyComment blocklyEditable', + 'class': 'blocklyComment blocklyEditable blocklyDraggable', }); this.highlightRect = this.createHighlightRect(this.svgRoot); diff --git a/core/comments/rendered_workspace_comment.ts b/core/comments/rendered_workspace_comment.ts index 1234d6ef8e9..79caf6a1d58 100644 --- a/core/comments/rendered_workspace_comment.ts +++ b/core/comments/rendered_workspace_comment.ts @@ -57,6 +57,7 @@ export class RenderedWorkspaceComment // Set the size to the default size as defined in the superclass. this.view.setSize(this.getSize()); this.view.setEditable(this.isEditable()); + this.view.getSvgRoot().setAttribute('data-id', this.id); this.addModelUpdateBindings(); diff --git a/core/workspace.ts b/core/workspace.ts index 2e9b2b0a1e9..16f32611b2b 100644 --- a/core/workspace.ts +++ b/core/workspace.ts @@ -748,7 +748,6 @@ export class Workspace implements IASTNodeLocation { * * @param id ID of comment to find. * @returns The sought after comment, or null if not found. - * @internal */ getCommentById(id: string): WorkspaceComment | null { return this.commentDB.get(id) ?? null; From 890d502b54738b6e9d50e4afe76fd3258e3722ae Mon Sep 17 00:00:00 2001 From: Chang Min Bark Date: Fri, 16 Aug 2024 04:51:25 -0400 Subject: [PATCH 2/4] fix: added workspace comments and comment drag strategy isDeadOrDying checks --- .idea/.gitignore | 5 +++++ .idea/blockly.iml | 12 ++++++++++++ .idea/modules.xml | 8 ++++++++ .idea/vcs.xml | 6 ++++++ core/comments/workspace_comment.ts | 2 +- core/dragging/comment_drag_strategy.ts | 2 +- 6 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/blockly.iml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 00000000000..b58b603fea7 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,5 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/blockly.iml b/.idea/blockly.iml new file mode 100644 index 00000000000..24643cc3744 --- /dev/null +++ b/.idea/blockly.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 00000000000..d209b67faed --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 00000000000..35eb1ddfbbc --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/core/comments/workspace_comment.ts b/core/comments/workspace_comment.ts index 0764b5168d2..45fe3878319 100644 --- a/core/comments/workspace_comment.ts +++ b/core/comments/workspace_comment.ts @@ -183,7 +183,7 @@ export class WorkspaceComment { * workspace is read-only. */ isDeletable(): boolean { - return this.isOwnDeletable() && !this.workspace.options.readOnly; + return this.isOwnDeletable() && !this.isDeadOrDying() && !this.workspace.options.readOnly; } /** diff --git a/core/dragging/comment_drag_strategy.ts b/core/dragging/comment_drag_strategy.ts index 2ad5fa144fe..0fcf8c5e89d 100644 --- a/core/dragging/comment_drag_strategy.ts +++ b/core/dragging/comment_drag_strategy.ts @@ -22,7 +22,7 @@ export class CommentDragStrategy implements IDragStrategy { } isMovable(): boolean { - return this.comment.isOwnMovable() && !this.workspace.options.readOnly; + return this.comment.isOwnMovable() && !this.comment.isDeadOrDying() && !this.workspace.options.readOnly; } startDrag(): void { From 270f1fa783daacd9479541258ce43c50890b75d3 Mon Sep 17 00:00:00 2001 From: Chang Min Bark Date: Fri, 16 Aug 2024 05:16:10 -0400 Subject: [PATCH 3/4] chore: removed .idea files --- .idea/.gitignore | 5 ----- .idea/blockly.iml | 12 ------------ .idea/modules.xml | 8 -------- .idea/vcs.xml | 6 ------ 4 files changed, 31 deletions(-) delete mode 100644 .idea/.gitignore delete mode 100644 .idea/blockly.iml delete mode 100644 .idea/modules.xml delete mode 100644 .idea/vcs.xml diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index b58b603fea7..00000000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml -# Editor-based HTTP Client requests -/httpRequests/ diff --git a/.idea/blockly.iml b/.idea/blockly.iml deleted file mode 100644 index 24643cc3744..00000000000 --- a/.idea/blockly.iml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index d209b67faed..00000000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 35eb1ddfbbc..00000000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file From 4dc7c76597ef877899489a4acd2543df21fdd755 Mon Sep 17 00:00:00 2001 From: Chang Min Bark Date: Fri, 16 Aug 2024 22:54:22 -0400 Subject: [PATCH 4/4] chore: formatted with prettier --- core/comments/workspace_comment.ts | 6 +++++- core/dragging/comment_drag_strategy.ts | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/core/comments/workspace_comment.ts b/core/comments/workspace_comment.ts index 49baadf274d..f3774c6a696 100644 --- a/core/comments/workspace_comment.ts +++ b/core/comments/workspace_comment.ts @@ -183,7 +183,11 @@ export class WorkspaceComment { * workspace is read-only. */ isDeletable(): boolean { - return this.isOwnDeletable() && !this.isDeadOrDying() && !this.workspace.options.readOnly; + return ( + this.isOwnDeletable() && + !this.isDeadOrDying() && + !this.workspace.options.readOnly + ); } /** diff --git a/core/dragging/comment_drag_strategy.ts b/core/dragging/comment_drag_strategy.ts index 39e2675a3f9..56f890a3e2d 100644 --- a/core/dragging/comment_drag_strategy.ts +++ b/core/dragging/comment_drag_strategy.ts @@ -25,7 +25,11 @@ export class CommentDragStrategy implements IDragStrategy { } isMovable(): boolean { - return this.comment.isOwnMovable() && !this.comment.isDeadOrDying() && !this.workspace.options.readOnly; + return ( + this.comment.isOwnMovable() && + !this.comment.isDeadOrDying() && + !this.workspace.options.readOnly + ); } startDrag(): void {