Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.2.0"
},
"publishConfig": {
"access": "public",
Expand Down
11 changes: 8 additions & 3 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 @@ -184,7 +185,7 @@ export class ContentHighlight {
private onChange(event: Blockly.Events.Abstract) {
if (event.type === Blockly.Events.THEME_CHANGE) {
this.applyColor();
} else if (contentChangeEvents.indexOf(event.type) !== -1) {
} else if ((contentChangeEvents as string[]).indexOf(event.type) !== -1) {
const metricsManager = this.workspace.getMetricsManager();
if (event.type !== Blockly.Events.VIEWPORT_CHANGE) {
// The content metrics change when it's not a viewport change event.
Expand All @@ -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
Loading