From 7c6085e7b9145ec805b5aa129df66df5b8228f10 Mon Sep 17 00:00:00 2001 From: shanyue Date: Mon, 16 Mar 2026 23:08:34 +0800 Subject: [PATCH] fix(svgcanvas): Handle 'none' stroke color in SVG elements (#1084) This update modifies the stroke color handling in both the SvgCanvas and ext-connector modules. When the stroke color is set to 'none', it now correctly assigns an empty string or 'none' instead of a hex value, ensuring proper rendering of SVG elements without strokes. --- packages/svgcanvas/svgcanvas.js | 4 +++- src/editor/extensions/ext-connector/ext-connector.js | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/svgcanvas/svgcanvas.js b/packages/svgcanvas/svgcanvas.js index fa56c98c..dc856f51 100644 --- a/packages/svgcanvas/svgcanvas.js +++ b/packages/svgcanvas/svgcanvas.js @@ -201,7 +201,9 @@ class SvgCanvas { this.curConfig.initFill.color, fill_paint: null, fill_opacity: this.curConfig.initFill.opacity, - stroke: `#${this.curConfig.initStroke.color}`, + stroke: + (this.curConfig.initStroke.color === 'none' ? '' : '#') + + this.curConfig.initStroke.color, stroke_paint: null, stroke_opacity: this.curConfig.initStroke.opacity, stroke_width: this.curConfig.initStroke.width, diff --git a/src/editor/extensions/ext-connector/ext-connector.js b/src/editor/extensions/ext-connector/ext-connector.js index cabba606..f8c5a4ab 100644 --- a/src/editor/extensions/ext-connector/ext-connector.js +++ b/src/editor/extensions/ext-connector/ext-connector.js @@ -447,7 +447,10 @@ export default { attr: { id: 'conn_' + svgCanvas.getNextId(), points: `${x},${y} ${x},${y} ${startX},${startY}`, - stroke: `#${initStroke.color}`, + stroke: + initStroke.color === 'none' + ? 'none' + : `#${initStroke.color}`, 'stroke-width': !startElem.stroke_width || startElem.stroke_width === 0 ? initStroke.width