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) 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',