Skip to content

Commit

Permalink
fix: Hide content highlight on comment drag, update on resize.
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnesky committed Jun 29, 2024
1 parent 51f153f commit 8a24ec7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion plugins/content-highlight/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"typescript": "^5.4.5"
},
"peerDependencies": {
"blockly": "^11.0.0"
"blockly": "^11.1.2"
},
"publishConfig": {
"access": "public",
Expand Down
9 changes: 7 additions & 2 deletions plugins/content-highlight/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const contentChangeEvents = [
Blockly.Events.BLOCK_MOVE,
Blockly.Events.BLOCK_DELETE,
Blockly.Events.COMMENT_MOVE,
Blockly.Events.COMMENT_RESIZE,
Blockly.Events.COMMENT_CREATE,
Blockly.Events.COMMENT_DELETE,
];
Expand Down Expand Up @@ -196,7 +197,9 @@ export class ContentHighlight {
this.position(this.cachedContentMetrics, absoluteMetrics);
}
} else if (event.type === Blockly.Events.BLOCK_DRAG) {
this.handleBlockDrag(event as Blockly.Events.BlockDrag);
this.handleDragEvent(event as Blockly.Events.BlockDrag);
} else if (event.type === Blockly.Events.COMMENT_DRAG) {
this.handleDragEvent(event as Blockly.Events.CommentDrag);
} else if (event.type === Blockly.Events.BLOCK_CHANGE) {
// Resizes the content highlight when it is a block change event
const metricsManager = this.workspace.getMetricsManager();
Expand All @@ -211,7 +214,9 @@ export class ContentHighlight {
*
* @param event The BlockDrag event.
*/
private handleBlockDrag(event: Blockly.Events.BlockDrag) {
private handleDragEvent(
event: Blockly.Events.BlockDrag | Blockly.Events.CommentDrag,
) {
const opacity = event.isStart ? '0' : '1';
this.svgGroup?.setAttribute('opacity', opacity);
}
Expand Down

0 comments on commit 8a24ec7

Please sign in to comment.