Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(): fix import cycle #8506

Merged
merged 2 commits into from
Dec 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
15 changes: 15 additions & 0 deletions src/util/misc/groupSVGElements.ts
Original file line number Diff line number Diff line change
@@ -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);
};
2 changes: 1 addition & 1 deletion src/util/misc/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
15 changes: 0 additions & 15 deletions src/util/misc/svgParsing.ts
Original file line number Diff line number Diff line change
@@ -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';
/**
Expand Down Expand Up @@ -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',
Expand Down