From 7c22c46ee685815fbbdd06764bee3f929736c873 Mon Sep 17 00:00:00 2001 From: Shreyans Pathak Date: Mon, 15 Jul 2024 14:54:30 -0400 Subject: [PATCH] refactor: Add `addClass` and `removeClass` methods to blockSvg (#8337) * refactor: Add `addClass` and `removeClass` methods to blockSvg * fix: lint * fix: jsdoc --- core/block_svg.ts | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/core/block_svg.ts b/core/block_svg.ts index ac6970dce..adef213d5 100644 --- a/core/block_svg.ts +++ b/core/block_svg.ts @@ -671,6 +671,24 @@ export class BlockSvg } } + /** + * Add a CSS class to the SVG group of this block. + * + * @param className + */ + addClass(className: string) { + dom.addClass(this.svgGroup_, className); + } + + /** + * Remove a CSS class from the SVG group of this block. + * + * @param className + */ + removeClass(className: string) { + dom.removeClass(this.svgGroup_, className); + } + /** * Recursively adds or removes the dragging class to this node and its * children. @@ -683,10 +701,10 @@ export class BlockSvg if (adding) { this.translation = ''; common.draggingConnections.push(...this.getConnections_(true)); - dom.addClass(this.svgGroup_, 'blocklyDragging'); + this.addClass('blocklyDragging'); } else { common.draggingConnections.length = 0; - dom.removeClass(this.svgGroup_, 'blocklyDragging'); + this.removeClass('blocklyDragging'); } // Recurse through all blocks attached under this one. for (let i = 0; i < this.childBlocks_.length; i++) {