From 30018581d343b4ff7bf4809f201d9487366748a6 Mon Sep 17 00:00:00 2001 From: ShaMan123 Date: Tue, 20 Sep 2022 09:36:57 +0300 Subject: [PATCH] fix(): group svg export --- src/shapes/group.class.ts | 58 ++++++++++++++++++++++----------------- 1 file changed, 33 insertions(+), 25 deletions(-) diff --git a/src/shapes/group.class.ts b/src/shapes/group.class.ts index d5689af3dc1..e598e3ef37c 100644 --- a/src/shapes/group.class.ts +++ b/src/shapes/group.class.ts @@ -998,22 +998,6 @@ import { Point } from '../point.class'; return fillStroke.join(''); }, - /** - * Returns svg representation of an instance - * @param {Function} [reviver] Method for further parsing of svg representation. - * @return {String} svg representation of an instance - */ - _toSVG: function (reviver) { - var svgString = ['\n']; - var bg = this._createSVGBgRect(reviver); - bg && svgString.push('\t\t', bg); - for (var i = 0; i < this._objects.length; i++) { - svgString.push('\t\t', this._objects[i].toSVG(reviver)); - } - svgString.push('\n'); - return svgString; - }, - /** * Returns styles-string for svg-export, specific version for group * @return {String} @@ -1027,21 +1011,45 @@ import { Point } from '../point.class'; return [opacity, this.getSvgFilter(), visibility].join(''); }, + /** + * @private + */ + createSVGMarkup: function (reviver, forClipping) { + const svgString = ['\n']; + const bg = this._createSVGBgRect(reviver); + bg && svgString.push('\t\t', bg); + for (let i = 0; i < this._objects.length; i++) { + svgString.push( + '\t\t', + this._objects[i][forClipping ? 'toClipPathSVG' : 'toSVG'](reviver) + ); + } + svgString.push('\n'); + return svgString; + }, + + /** + * Returns svg representation of an instance + * @param {Function} [reviver] Method for further parsing of svg representation. + * @return {String} svg representation of an instance + */ + _toSVG: function (reviver) { + return this.createSVGMarkup(reviver); + }, + /** * Returns svg clipPath representation of an instance * @param {Function} [reviver] Method for further parsing of svg representation. * @return {String} svg representation of an instance */ toClipPathSVG: function (reviver) { - var svgString = []; - var bg = this._createSVGBgRect(reviver); - bg && svgString.push('\t', bg); - for (var i = 0; i < this._objects.length; i++) { - svgString.push('\t', this._objects[i].toClipPathSVG(reviver)); - } - return this._createBaseClipPathSVGMarkup(svgString, { - reviver: reviver, - }); + return ( + '\t' + + this._createBaseClipPathSVGMarkup( + this.createSVGMarkup(reviver, true), + { reviver } + ) + ); }, /* _TO_SVG_END_ */ }