From 5be1a3df9c50d510c80bdd029302fdf19bd012c7 Mon Sep 17 00:00:00 2001 From: ShaMan123 Date: Sun, 11 Dec 2022 20:05:29 +0200 Subject: [PATCH 1/2] extract --- src/util/misc/groupSVGElements.ts | 15 +++++++++++++++ src/util/misc/misc.ts | 2 +- src/util/misc/svgParsing.ts | 15 --------------- 3 files changed, 16 insertions(+), 16 deletions(-) create mode 100644 src/util/misc/groupSVGElements.ts diff --git a/src/util/misc/groupSVGElements.ts b/src/util/misc/groupSVGElements.ts new file mode 100644 index 00000000000..7ed252cd837 --- /dev/null +++ b/src/util/misc/groupSVGElements.ts @@ -0,0 +1,15 @@ +import { FabricObject } from '../../shapes/fabricObject.class'; +import { Group } from '../../shapes/group.class'; + +/** + * Groups SVG elements (usually those retrieved from SVG document) + * @static + * @param {FabricObject[]} elements FabricObject(s) parsed from svg, to group + * @return {FabricObject | Group} + */ +export const groupSVGElements = (elements: FabricObject[]) => { + if (elements && elements.length === 1) { + return elements[0]; + } + return new Group(elements); +}; diff --git a/src/util/misc/misc.ts b/src/util/misc/misc.ts index da8d02360d6..c5d0835adea 100644 --- a/src/util/misc/misc.ts +++ b/src/util/misc/misc.ts @@ -33,10 +33,10 @@ import { toFixed } from './toFixed'; import { matrixToSVG, parsePreserveAspectRatioAttribute, - groupSVGElements, parseUnit, getSvgAttributes, } from './svgParsing'; +import { groupSVGElements } from './groupSVGElements'; import { findScaleToFit, findScaleToCover } from './findScaleTo'; import { capValue } from './capValue'; import { diff --git a/src/util/misc/svgParsing.ts b/src/util/misc/svgParsing.ts index 56d02ce0e06..60396bf1728 100644 --- a/src/util/misc/svgParsing.ts +++ b/src/util/misc/svgParsing.ts @@ -1,7 +1,5 @@ import { config } from '../../config'; import { DEFAULT_SVG_FONT_SIZE } from '../../constants'; -import type { FabricObject } from '../../shapes/fabricObject.class'; -import { Group } from '../../shapes/group.class'; import { SupportedSVGUnit, SVGElementName, TMat2D } from '../../typedefs'; import { toFixed } from './toFixed'; /** @@ -76,19 +74,6 @@ export const parseUnit = (value: string, fontSize: number) => { } }; -/** - * Groups SVG elements (usually those retrieved from SVG document) - * @static - * @param {FabricObject[]} elements FabricObject(s) parsed from svg, to group - * @return {FabricObject | Group} - */ -export const groupSVGElements = (elements: FabricObject[]) => { - if (elements && elements.length === 1) { - return elements[0]; - } - return new Group(elements); -}; - const enum MeetOrSlice { meet = 'meet', slice = 'slice', From ce7a134331ae3090aaaef79ac03c6fae0bd40168 Mon Sep 17 00:00:00 2001 From: ShaMan123 Date: Sun, 11 Dec 2022 20:09:38 +0200 Subject: [PATCH 2/2] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9033943daa4..66fca19bb23 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## [next] +- chore(TS): fix import cycle, extract `groupSVGElements` [#8506](https://github.com/fabricjs/fabric.js/pull/8506) - chore(TS): permissive `Point` typings [#8434](https://github.com/fabricjs/fabric.js/pull/8434) - chore(TS): polish files [#8488](https://github.com/fabricjs/fabric.js/pull/8488) - fix(TS): `EventSpec` recognition [#8497](https://github.com/fabricjs/fabric.js/pull/8497)