Skip to content

Commit 031f351

Browse files
maribethbjohnnesky
andauthored
fix: handle comment moves and resizes in content-highlight (#2653)
* fix: Hide content highlight on comment drag, update on resize. * Built against newer version of Blockly. * fix: remove cast --------- Co-authored-by: John Nesky <johnnesky@gmail.com> Co-authored-by: John Nesky <nesky@google.com>
1 parent d240405 commit 031f351

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

plugins/content-highlight/src/index.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const contentChangeEvents: string[] = [
1919
Blockly.Events.BLOCK_MOVE,
2020
Blockly.Events.BLOCK_DELETE,
2121
Blockly.Events.COMMENT_MOVE,
22+
Blockly.Events.COMMENT_RESIZE,
2223
Blockly.Events.COMMENT_CREATE,
2324
Blockly.Events.COMMENT_DELETE,
2425
];
@@ -197,7 +198,9 @@ export class ContentHighlight {
197198
this.position(this.cachedContentMetrics, absoluteMetrics);
198199
}
199200
} else if (event.type === Blockly.Events.BLOCK_DRAG) {
200-
this.handleBlockDrag(event as Blockly.Events.BlockDrag);
201+
this.handleDragEvent(event as Blockly.Events.BlockDrag);
202+
} else if (event.type === Blockly.Events.COMMENT_DRAG) {
203+
this.handleDragEvent(event as Blockly.Events.CommentDrag);
201204
} else if (event.type === Blockly.Events.BLOCK_CHANGE) {
202205
// Resizes the content highlight when it is a block change event
203206
const metricsManager = this.workspace.getMetricsManager();
@@ -212,7 +215,9 @@ export class ContentHighlight {
212215
*
213216
* @param event The BlockDrag event.
214217
*/
215-
private handleBlockDrag(event: Blockly.Events.BlockDrag) {
218+
private handleDragEvent(
219+
event: Blockly.Events.BlockDrag | Blockly.Events.CommentDrag,
220+
) {
216221
const opacity = event.isStart ? '0' : '1';
217222
this.svgGroup?.setAttribute('opacity', opacity);
218223
}

0 commit comments

Comments
 (0)