fabric 7.3.1 → 7.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +40 -27
- package/dist/_virtual/{_@oxc-project_runtime@0.122.0 → _@oxc-project_runtime@0.126.0}/helpers/defineProperty.mjs +1 -1
- package/{dist-extensions/_virtual/_@oxc-project_runtime@0.122.0 → dist/_virtual/_@oxc-project_runtime@0.126.0}/helpers/toPrimitive.mjs +1 -1
- package/dist/_virtual/{_@oxc-project_runtime@0.122.0 → _@oxc-project_runtime@0.126.0}/helpers/toPropertyKey.mjs +1 -1
- package/{dist-extensions/_virtual/_@oxc-project_runtime@0.122.0 → dist/_virtual/_@oxc-project_runtime@0.126.0}/helpers/typeof.mjs +1 -1
- package/dist/index.js +88 -66
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +35 -35
- package/dist/index.min.js.map +1 -1
- package/dist/index.min.mjs +37 -37
- package/dist/index.min.mjs.map +1 -1
- package/dist/index.mjs +88 -66
- package/dist/index.mjs.map +1 -1
- package/dist/index.node.cjs +83 -62
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.mjs +83 -62
- package/dist/index.node.mjs.map +1 -1
- package/dist/package.min.mjs +1 -1
- package/dist/package.mjs +1 -1
- package/dist/src/Collection.min.mjs +1 -1
- package/dist/src/Collection.mjs +1 -1
- package/dist/src/LayoutManager/LayoutManager.min.mjs +1 -1
- package/dist/src/LayoutManager/LayoutManager.mjs +1 -1
- package/dist/src/LayoutManager/LayoutStrategies/ClipPathLayout.min.mjs +1 -1
- package/dist/src/LayoutManager/LayoutStrategies/ClipPathLayout.mjs +1 -1
- package/dist/src/LayoutManager/LayoutStrategies/FitContentLayout.min.mjs +1 -1
- package/dist/src/LayoutManager/LayoutStrategies/FitContentLayout.mjs +1 -1
- package/dist/src/LayoutManager/LayoutStrategies/FixedLayout.min.mjs +1 -1
- package/dist/src/LayoutManager/LayoutStrategies/FixedLayout.mjs +1 -1
- package/dist/src/LayoutManager/LayoutStrategies/LayoutStrategy.min.mjs +1 -1
- package/dist/src/LayoutManager/LayoutStrategies/LayoutStrategy.mjs +1 -1
- package/dist/src/Observable.min.mjs +1 -1
- package/dist/src/Observable.mjs +1 -1
- package/dist/src/Pattern/Pattern.min.mjs +1 -1
- package/dist/src/Pattern/Pattern.mjs +1 -1
- package/dist/src/Shadow.min.mjs +1 -1
- package/dist/src/Shadow.mjs +1 -1
- package/dist/src/brushes/BaseBrush.min.mjs +1 -1
- package/dist/src/brushes/BaseBrush.mjs +1 -1
- package/dist/src/brushes/CircleBrush.min.mjs +1 -1
- package/dist/src/brushes/CircleBrush.mjs +1 -1
- package/dist/src/brushes/PencilBrush.min.mjs +1 -1
- package/dist/src/brushes/PencilBrush.mjs +1 -1
- package/dist/src/brushes/SprayBrush.min.mjs +1 -1
- package/dist/src/brushes/SprayBrush.mjs +1 -1
- package/dist/src/cache.min.mjs +1 -1
- package/dist/src/cache.mjs +1 -1
- package/dist/src/canvas/Canvas.min.mjs +1 -1
- package/dist/src/canvas/Canvas.mjs +1 -1
- package/dist/src/canvas/DOMManagers/CanvasDOMManager.min.mjs +1 -1
- package/dist/src/canvas/DOMManagers/CanvasDOMManager.mjs +1 -1
- package/dist/src/canvas/DOMManagers/StaticCanvasDOMManager.min.mjs +1 -1
- package/dist/src/canvas/DOMManagers/StaticCanvasDOMManager.mjs +1 -1
- package/dist/src/canvas/SelectableCanvas.min.mjs +1 -1
- package/dist/src/canvas/SelectableCanvas.mjs +1 -1
- package/dist/src/canvas/StaticCanvas.d.ts +1 -1
- package/dist/src/canvas/StaticCanvas.d.ts.map +1 -1
- package/dist/src/canvas/StaticCanvas.min.mjs +5 -5
- package/dist/src/canvas/StaticCanvas.min.mjs.map +1 -1
- package/dist/src/canvas/StaticCanvas.mjs +4 -4
- package/dist/src/canvas/StaticCanvas.mjs.map +1 -1
- package/dist/src/canvas/TextEditingManager.min.mjs +1 -1
- package/dist/src/canvas/TextEditingManager.mjs +1 -1
- package/dist/src/color/Color.min.mjs +1 -1
- package/dist/src/color/Color.mjs +1 -1
- package/dist/src/config.min.mjs +1 -1
- package/dist/src/config.mjs +1 -1
- package/dist/src/controls/Control.min.mjs +1 -1
- package/dist/src/controls/Control.mjs +1 -1
- package/dist/src/filters/BaseFilter.min.mjs +1 -1
- package/dist/src/filters/BaseFilter.mjs +1 -1
- package/dist/src/filters/BlendColor.min.mjs +1 -1
- package/dist/src/filters/BlendColor.mjs +1 -1
- package/dist/src/filters/BlendImage.min.mjs +1 -1
- package/dist/src/filters/BlendImage.mjs +1 -1
- package/dist/src/filters/Blur.min.mjs +1 -1
- package/dist/src/filters/Blur.mjs +1 -1
- package/dist/src/filters/Brightness.min.mjs +1 -1
- package/dist/src/filters/Brightness.mjs +1 -1
- package/dist/src/filters/Canvas2dFilterBackend.min.mjs +1 -1
- package/dist/src/filters/Canvas2dFilterBackend.mjs +1 -1
- package/dist/src/filters/ColorMatrix.min.mjs +1 -1
- package/dist/src/filters/ColorMatrix.mjs +1 -1
- package/dist/src/filters/ColorMatrixFilters.min.mjs +1 -1
- package/dist/src/filters/ColorMatrixFilters.mjs +1 -1
- package/dist/src/filters/Composed.min.mjs +1 -1
- package/dist/src/filters/Composed.mjs +1 -1
- package/dist/src/filters/Contrast.min.mjs +1 -1
- package/dist/src/filters/Contrast.mjs +1 -1
- package/dist/src/filters/Convolute.min.mjs +1 -1
- package/dist/src/filters/Convolute.min.mjs.map +1 -1
- package/dist/src/filters/Convolute.mjs +1 -1
- package/dist/src/filters/Gamma.min.mjs +1 -1
- package/dist/src/filters/Gamma.mjs +1 -1
- package/dist/src/filters/Grayscale.min.mjs +1 -1
- package/dist/src/filters/Grayscale.mjs +1 -1
- package/dist/src/filters/HueRotation.min.mjs +1 -1
- package/dist/src/filters/HueRotation.mjs +1 -1
- package/dist/src/filters/Invert.min.mjs +1 -1
- package/dist/src/filters/Invert.mjs +1 -1
- package/dist/src/filters/Noise.min.mjs +1 -1
- package/dist/src/filters/Noise.mjs +1 -1
- package/dist/src/filters/Pixelate.min.mjs +1 -1
- package/dist/src/filters/Pixelate.mjs +1 -1
- package/dist/src/filters/RemoveColor.min.mjs +1 -1
- package/dist/src/filters/RemoveColor.mjs +1 -1
- package/dist/src/filters/Resize.min.mjs +2 -2
- package/dist/src/filters/Resize.min.mjs.map +1 -1
- package/dist/src/filters/Resize.mjs +2 -2
- package/dist/src/filters/Resize.mjs.map +1 -1
- package/dist/src/filters/Saturation.min.mjs +1 -1
- package/dist/src/filters/Saturation.mjs +1 -1
- package/dist/src/filters/Vibrance.min.mjs +1 -1
- package/dist/src/filters/Vibrance.mjs +1 -1
- package/dist/src/filters/WebGLFilterBackend.min.mjs +1 -1
- package/dist/src/filters/WebGLFilterBackend.mjs +1 -1
- package/dist/src/gradient/Gradient.d.ts.map +1 -1
- package/dist/src/gradient/Gradient.min.mjs +4 -4
- package/dist/src/gradient/Gradient.min.mjs.map +1 -1
- package/dist/src/gradient/Gradient.mjs +6 -2
- package/dist/src/gradient/Gradient.mjs.map +1 -1
- package/dist/src/gradient/typedefs.d.ts +7 -7
- package/dist/src/parser/applyViewboxTransform.d.ts.map +1 -1
- package/dist/src/parser/applyViewboxTransform.min.mjs +1 -1
- package/dist/src/parser/applyViewboxTransform.min.mjs.map +1 -1
- package/dist/src/parser/applyViewboxTransform.mjs +2 -4
- package/dist/src/parser/applyViewboxTransform.mjs.map +1 -1
- package/dist/src/shapes/ActiveSelection.min.mjs +1 -1
- package/dist/src/shapes/ActiveSelection.mjs +1 -1
- package/dist/src/shapes/Circle.min.mjs +2 -2
- package/dist/src/shapes/Circle.min.mjs.map +1 -1
- package/dist/src/shapes/Circle.mjs +1 -1
- package/dist/src/shapes/Ellipse.min.mjs +1 -1
- package/dist/src/shapes/Ellipse.mjs +1 -1
- package/dist/src/shapes/Group.min.mjs +1 -1
- package/dist/src/shapes/Group.mjs +1 -1
- package/dist/src/shapes/IText/DraggableTextDelegate.min.mjs +1 -1
- package/dist/src/shapes/IText/DraggableTextDelegate.mjs +1 -1
- package/dist/src/shapes/IText/IText.d.ts.map +1 -1
- package/dist/src/shapes/IText/IText.min.mjs +1 -1
- package/dist/src/shapes/IText/IText.min.mjs.map +1 -1
- package/dist/src/shapes/IText/IText.mjs +3 -3
- package/dist/src/shapes/IText/IText.mjs.map +1 -1
- package/dist/src/shapes/IText/ITextBehavior.min.mjs +1 -1
- package/dist/src/shapes/IText/ITextBehavior.mjs +1 -1
- package/dist/src/shapes/IText/ITextClickBehavior.min.mjs +1 -1
- package/dist/src/shapes/IText/ITextClickBehavior.mjs +1 -1
- package/dist/src/shapes/Image.min.mjs +1 -1
- package/dist/src/shapes/Image.mjs +1 -1
- package/dist/src/shapes/Line.min.mjs +1 -1
- package/dist/src/shapes/Line.mjs +1 -1
- package/dist/src/shapes/Object/FabricObjectSVGExportMixin.d.ts.map +1 -1
- package/dist/src/shapes/Object/FabricObjectSVGExportMixin.min.mjs +2 -2
- package/dist/src/shapes/Object/FabricObjectSVGExportMixin.min.mjs.map +1 -1
- package/dist/src/shapes/Object/FabricObjectSVGExportMixin.mjs +11 -26
- package/dist/src/shapes/Object/FabricObjectSVGExportMixin.mjs.map +1 -1
- package/dist/src/shapes/Object/InteractiveObject.d.ts.map +1 -1
- package/dist/src/shapes/Object/InteractiveObject.min.mjs +1 -1
- package/dist/src/shapes/Object/InteractiveObject.min.mjs.map +1 -1
- package/dist/src/shapes/Object/InteractiveObject.mjs +7 -6
- package/dist/src/shapes/Object/InteractiveObject.mjs.map +1 -1
- package/dist/src/shapes/Object/Object.min.mjs +1 -1
- package/dist/src/shapes/Object/Object.mjs +1 -1
- package/dist/src/shapes/Object/ObjectGeometry.d.ts.map +1 -1
- package/dist/src/shapes/Object/ObjectGeometry.min.mjs +1 -1
- package/dist/src/shapes/Object/ObjectGeometry.min.mjs.map +1 -1
- package/dist/src/shapes/Object/ObjectGeometry.mjs +6 -2
- package/dist/src/shapes/Object/ObjectGeometry.mjs.map +1 -1
- package/dist/src/shapes/Object/types/FabricObjectProps.d.ts +1 -1
- package/dist/src/shapes/Path.min.mjs +1 -1
- package/dist/src/shapes/Path.mjs +1 -1
- package/dist/src/shapes/Polygon.min.mjs +1 -1
- package/dist/src/shapes/Polygon.mjs +1 -1
- package/dist/src/shapes/Polyline.min.mjs +1 -1
- package/dist/src/shapes/Polyline.mjs +1 -1
- package/dist/src/shapes/Rect.min.mjs +1 -1
- package/dist/src/shapes/Rect.mjs +1 -1
- package/dist/src/shapes/Text/StyledText.min.mjs +1 -1
- package/dist/src/shapes/Text/StyledText.mjs +1 -1
- package/dist/src/shapes/Text/Text.d.ts +4 -4
- package/dist/src/shapes/Text/Text.min.mjs +1 -1
- package/dist/src/shapes/Text/Text.min.mjs.map +1 -1
- package/dist/src/shapes/Text/Text.mjs +3 -3
- package/dist/src/shapes/Text/Text.mjs.map +1 -1
- package/dist/src/shapes/Text/TextSVGExportMixin.d.ts.map +1 -1
- package/dist/src/shapes/Text/TextSVGExportMixin.min.mjs +2 -2
- package/dist/src/shapes/Text/TextSVGExportMixin.min.mjs.map +1 -1
- package/dist/src/shapes/Text/TextSVGExportMixin.mjs +14 -7
- package/dist/src/shapes/Text/TextSVGExportMixin.mjs.map +1 -1
- package/dist/src/shapes/Textbox.d.ts.map +1 -1
- package/dist/src/shapes/Textbox.min.mjs +2 -2
- package/dist/src/shapes/Textbox.min.mjs.map +1 -1
- package/dist/src/shapes/Textbox.mjs +2 -3
- package/dist/src/shapes/Textbox.mjs.map +1 -1
- package/dist/src/shapes/Triangle.min.mjs +1 -1
- package/dist/src/shapes/Triangle.mjs +1 -1
- package/dist/src/util/animation/AnimationBase.min.mjs +1 -1
- package/dist/src/util/animation/AnimationBase.mjs +1 -1
- package/dist/src/util/animation/easing.min.mjs +1 -1
- package/dist/src/util/animation/easing.min.mjs.map +1 -1
- package/dist/src/util/animation/easing.mjs +1 -1
- package/dist/src/util/animation/easing.mjs.map +1 -1
- package/dist/src/util/internals/applyCanvasTransform.d.ts +1 -1
- package/dist/src/util/internals/applyCanvasTransform.min.mjs.map +1 -1
- package/dist/src/util/internals/applyCanvasTransform.mjs +1 -1
- package/dist/src/util/internals/applyCanvasTransform.mjs.map +1 -1
- package/dist/src/util/internals/svgExportCheck.d.ts +4 -0
- package/dist/src/util/internals/svgExportCheck.d.ts.map +1 -0
- package/dist/src/util/internals/svgExportCheck.min.mjs +2 -0
- package/dist/src/util/internals/svgExportCheck.min.mjs.map +1 -0
- package/dist/src/util/internals/svgExportCheck.mjs +12 -0
- package/dist/src/util/internals/svgExportCheck.mjs.map +1 -0
- package/dist/src/util/misc/matrix.d.ts +14 -0
- package/dist/src/util/misc/matrix.d.ts.map +1 -1
- package/dist/src/util/misc/matrix.min.mjs +1 -1
- package/dist/src/util/misc/matrix.min.mjs.map +1 -1
- package/dist/src/util/misc/matrix.mjs +15 -1
- package/dist/src/util/misc/matrix.mjs.map +1 -1
- package/dist/src/util/misc/mergeClipPaths.d.ts +1 -1
- package/dist/src/util/misc/mergeClipPaths.min.mjs.map +1 -1
- package/dist/src/util/misc/mergeClipPaths.mjs +1 -1
- package/dist/src/util/misc/mergeClipPaths.mjs.map +1 -1
- package/dist/src/util/misc/objectEnlive.min.mjs.map +1 -1
- package/dist/src/util/misc/objectEnlive.mjs +1 -1
- package/dist/src/util/misc/objectEnlive.mjs.map +1 -1
- package/dist/src/util/misc/projectStroke/StrokeLineJoinProjections.min.mjs +1 -1
- package/dist/src/util/misc/projectStroke/StrokeLineJoinProjections.min.mjs.map +1 -1
- package/dist/src/util/misc/projectStroke/StrokeLineJoinProjections.mjs +1 -1
- package/dist/src/util/misc/svgParsing.d.ts +2 -2
- package/dist/src/util/misc/svgParsing.d.ts.map +1 -1
- package/dist/src/util/misc/svgParsing.min.mjs +1 -1
- package/dist/src/util/misc/svgParsing.min.mjs.map +1 -1
- package/dist/src/util/misc/svgParsing.mjs +8 -3
- package/dist/src/util/misc/svgParsing.mjs.map +1 -1
- package/dist/src/util/path/index.d.ts.map +1 -1
- package/dist/src/util/path/index.min.mjs +1 -1
- package/dist/src/util/path/index.min.mjs.map +1 -1
- package/dist/src/util/path/index.mjs +2 -1
- package/dist/src/util/path/index.mjs.map +1 -1
- package/dist/src/util/path/regex.min.mjs.map +1 -1
- package/dist/src/util/path/regex.mjs +1 -1
- package/dist/src/util/path/regex.mjs.map +1 -1
- package/dist-extensions/_virtual/{_@oxc-project_runtime@0.122.0 → _@oxc-project_runtime@0.126.0}/helpers/defineProperty.mjs +1 -1
- package/{dist/_virtual/_@oxc-project_runtime@0.122.0 → dist-extensions/_virtual/_@oxc-project_runtime@0.126.0}/helpers/toPrimitive.mjs +1 -1
- package/dist-extensions/_virtual/{_@oxc-project_runtime@0.122.0 → _@oxc-project_runtime@0.126.0}/helpers/toPropertyKey.mjs +1 -1
- package/{dist/_virtual/_@oxc-project_runtime@0.122.0 → dist-extensions/_virtual/_@oxc-project_runtime@0.126.0}/helpers/typeof.mjs +1 -1
- package/dist-extensions/aligning_guidelines/index.mjs +1 -1
- package/dist-extensions/cropping_controls/croppingHandlers.mjs +1 -7
- package/dist-extensions/cropping_controls/croppingHandlers.mjs.map +1 -1
- package/dist-extensions/extensions/cropping_controls/croppingHandlers.d.ts.map +1 -1
- package/dist-extensions/fabric-extensions.min.js +1 -1
- package/dist-extensions/fabric-extensions.min.js.map +1 -1
- package/dist-extensions/src/canvas/StaticCanvas.d.ts +1 -1
- package/dist-extensions/src/canvas/StaticCanvas.d.ts.map +1 -1
- package/dist-extensions/src/gradient/Gradient.d.ts.map +1 -1
- package/dist-extensions/src/gradient/typedefs.d.ts +7 -7
- package/dist-extensions/src/parser/applyViewboxTransform.d.ts.map +1 -1
- package/dist-extensions/src/shapes/IText/IText.d.ts.map +1 -1
- package/dist-extensions/src/shapes/Object/FabricObjectSVGExportMixin.d.ts.map +1 -1
- package/dist-extensions/src/shapes/Object/InteractiveObject.d.ts.map +1 -1
- package/dist-extensions/src/shapes/Object/ObjectGeometry.d.ts.map +1 -1
- package/dist-extensions/src/shapes/Object/types/FabricObjectProps.d.ts +1 -1
- package/dist-extensions/src/shapes/Text/Text.d.ts +4 -4
- package/dist-extensions/src/shapes/Text/TextSVGExportMixin.d.ts.map +1 -1
- package/dist-extensions/src/shapes/Textbox.d.ts.map +1 -1
- package/dist-extensions/src/util/internals/applyCanvasTransform.d.ts +1 -1
- package/dist-extensions/src/util/internals/svgExportCheck.d.ts +4 -0
- package/dist-extensions/src/util/internals/svgExportCheck.d.ts.map +1 -0
- package/dist-extensions/src/util/misc/matrix.d.ts +14 -0
- package/dist-extensions/src/util/misc/matrix.d.ts.map +1 -1
- package/dist-extensions/src/util/misc/mergeClipPaths.d.ts +1 -1
- package/dist-extensions/src/util/misc/svgParsing.d.ts +2 -2
- package/dist-extensions/src/util/misc/svgParsing.d.ts.map +1 -1
- package/dist-extensions/src/util/path/index.d.ts.map +1 -1
- package/extensions/cropping_controls/croppingHandlers.ts +13 -19
- package/package.json +10 -10
- package/src/LayoutManager/README.md +3 -3
- package/src/canvas/StaticCanvas.spec.ts +19 -0
- package/src/canvas/StaticCanvas.ts +7 -3
- package/src/filters/Resize.ts +1 -1
- package/src/gradient/Gradient.spec.ts +60 -1
- package/src/gradient/Gradient.ts +9 -2
- package/src/gradient/typedefs.ts +7 -7
- package/src/parser/applyViewboxTransform.ts +2 -4
- package/src/shapes/IText/IText.ts +1 -2
- package/src/shapes/IText/ITextBehavior.test.ts +6 -6
- package/src/shapes/Object/FabricObject.spec.ts +3 -2
- package/src/shapes/Object/FabricObjectSVGExportMixin.ts +47 -37
- package/src/shapes/Object/InteractiveObject.ts +13 -3
- package/src/shapes/Object/Object-interactivity.spec.ts +126 -7
- package/src/shapes/Object/ObjectGeometry.spec.ts +10 -1
- package/src/shapes/Object/ObjectGeometry.ts +10 -3
- package/src/shapes/Object/objectSvgExport.spec.ts +27 -0
- package/src/shapes/Object/types/FabricObjectProps.ts +1 -1
- package/src/shapes/Text/Text.spec.ts +25 -0
- package/src/shapes/Text/Text.ts +5 -5
- package/src/shapes/Text/TextSVGExportMixin.ts +25 -11
- package/src/shapes/Textbox.ts +1 -2
- package/src/util/animation/animations.spec.ts +1 -1
- package/src/util/animation/easing.ts +1 -1
- package/src/util/internals/applyCanvasTransform.ts +1 -1
- package/src/util/internals/svgExportCheck.ts +20 -0
- package/src/util/misc/matrix.spec.ts +52 -0
- package/src/util/misc/matrix.ts +16 -0
- package/src/util/misc/mergeClipPaths.ts +1 -1
- package/src/util/misc/objectEnlive.ts +1 -1
- package/src/util/misc/svgParsing.ts +22 -10
- package/src/util/path/index.ts +3 -2
- package/src/util/path/regex.ts +1 -1
- package/src/util/typeAssertions.spec.ts +1 -1
- /package/dist/_virtual/{_@oxc-project_runtime@0.122.0 → _@oxc-project_runtime@0.126.0}/helpers/defineProperty.min.mjs +0 -0
- /package/dist/_virtual/{_@oxc-project_runtime@0.122.0 → _@oxc-project_runtime@0.126.0}/helpers/toPrimitive.min.mjs +0 -0
- /package/dist/_virtual/{_@oxc-project_runtime@0.122.0 → _@oxc-project_runtime@0.126.0}/helpers/toPropertyKey.min.mjs +0 -0
- /package/dist/_virtual/{_@oxc-project_runtime@0.122.0 → _@oxc-project_runtime@0.126.0}/helpers/typeof.min.mjs +0 -0
package/src/shapes/Textbox.ts
CHANGED
|
@@ -209,7 +209,7 @@ export class Textbox<
|
|
|
209
209
|
return true;
|
|
210
210
|
}
|
|
211
211
|
let offset = 0,
|
|
212
|
-
nextLineIndex
|
|
212
|
+
nextLineIndex: number,
|
|
213
213
|
nextOffset: number,
|
|
214
214
|
shouldLimit = false;
|
|
215
215
|
const map = this._styleMap[lineIndex],
|
|
@@ -450,7 +450,6 @@ export class Textbox<
|
|
|
450
450
|
);
|
|
451
451
|
// layout words
|
|
452
452
|
const data = wordsData[lineIndex];
|
|
453
|
-
offset = 0;
|
|
454
453
|
let i;
|
|
455
454
|
for (i = 0; i < data.length; i++) {
|
|
456
455
|
const { word, width: wordWidth } = data[i];
|
|
@@ -397,7 +397,7 @@ describe('animate', () => {
|
|
|
397
397
|
expect(run).toBeGreaterThanOrEqual(3);
|
|
398
398
|
vi.advanceTimersByTime(duration + 20);
|
|
399
399
|
});
|
|
400
|
-
it('abort function is
|
|
400
|
+
it('abort function is called with object as context', async () => {
|
|
401
401
|
const object = new FabricObject({ left: 123, top: 124 });
|
|
402
402
|
let context: any;
|
|
403
403
|
object.animate(
|
|
@@ -149,7 +149,7 @@ export const easeInOutExpo: TEasingFunction = (t, b, c, d) => {
|
|
|
149
149
|
if (t < 1) {
|
|
150
150
|
return (c / 2) * 2 ** (10 * (t - 1)) + b;
|
|
151
151
|
}
|
|
152
|
-
return (c / 2) * -(2 ** (-10 *
|
|
152
|
+
return (c / 2) * -(2 ** (-10 * (t - 1)) + 2) + b;
|
|
153
153
|
};
|
|
154
154
|
|
|
155
155
|
/**
|
|
@@ -4,7 +4,7 @@ import type { StaticCanvas } from '../../canvas/StaticCanvas';
|
|
|
4
4
|
* Set the transform of the passed context to the same of a specific Canvas or StaticCanvas.
|
|
5
5
|
* setTransform is used since this utility will RESET the ctx transform to the basic value
|
|
6
6
|
* of retina scaling and viewport transform
|
|
7
|
-
* It is not meant to be added to other transforms, it is used internally to
|
|
7
|
+
* It is not meant to be added to other transforms, it is used internally to prepare canvases to draw
|
|
8
8
|
* @param ctx
|
|
9
9
|
* @param canvas
|
|
10
10
|
*/
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const unsafeSvgStyleValueRegex = new RegExp(
|
|
2
|
+
String.raw`[\0-\x1F\x7F;<>\\]|\/\*|\*\/|url\s*\(|expression\s*\(|(?:java|vb)script\s*:|data\s*:|@import\b`,
|
|
3
|
+
'iu',
|
|
4
|
+
);
|
|
5
|
+
|
|
6
|
+
export const isSafeSvgStyleValue = (value: unknown): value is string =>
|
|
7
|
+
typeof value === 'string' &&
|
|
8
|
+
value.trim().length > 0 &&
|
|
9
|
+
!unsafeSvgStyleValueRegex.test(value);
|
|
10
|
+
|
|
11
|
+
export const getSafeSvgStyleNumber = (
|
|
12
|
+
value: unknown,
|
|
13
|
+
fallback = '',
|
|
14
|
+
): string => {
|
|
15
|
+
const numeric = Number(value);
|
|
16
|
+
return Number.isFinite(numeric) ? `${numeric}` : fallback;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const getSafeSvgStyleToken = (value: unknown, fallback = ''): string =>
|
|
20
|
+
typeof value === 'string' && isSafeSvgStyleValue(value) ? value : fallback;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { describe, expect, it } from 'vitest';
|
|
2
2
|
import {
|
|
3
3
|
calcDimensionsMatrix,
|
|
4
|
+
calcPlaneZoom,
|
|
5
|
+
calcPlaneScaleY,
|
|
4
6
|
composeMatrix,
|
|
5
7
|
createRotateMatrix,
|
|
6
8
|
invertTransform,
|
|
@@ -113,6 +115,56 @@ describe('matrix', () => {
|
|
|
113
115
|
});
|
|
114
116
|
});
|
|
115
117
|
|
|
118
|
+
describe('calcPlaneZoom', () => {
|
|
119
|
+
it('returns 1 for the identity matrix', () => {
|
|
120
|
+
expect(calcPlaneZoom(iMatrix)).toBe(1);
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
it('returns the scale factor of a pure scale matrix', () => {
|
|
124
|
+
expect(calcPlaneZoom([2, 0, 0, 2, 0, 0])).toBe(2);
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
it('returns the scale factor of a rotated matrix regardless of angle', () => {
|
|
128
|
+
const cos = Math.SQRT1_2,
|
|
129
|
+
sin = Math.SQRT1_2;
|
|
130
|
+
expect(calcPlaneZoom([cos, sin, -sin, cos, 0, 0])).toBeCloseTo(1);
|
|
131
|
+
expect(
|
|
132
|
+
calcPlaneZoom([2 * cos, 2 * sin, -2 * sin, 2 * cos, 0, 0]),
|
|
133
|
+
).toBeCloseTo(2);
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
it('is independent of translation', () => {
|
|
137
|
+
expect(calcPlaneZoom([3, 0, 0, 3, 100, 200])).toBe(3);
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
describe('calcPlaneScaleY', () => {
|
|
142
|
+
it('returns 1 for the identity matrix', () => {
|
|
143
|
+
expect(calcPlaneScaleY(iMatrix)).toBe(1);
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
it('returns the scale factor of a pure uniform scale matrix', () => {
|
|
147
|
+
expect(calcPlaneScaleY([2, 0, 0, 2, 0, 0])).toBe(2);
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
it('returns the Y scale factor of a rotated matrix regardless of angle', () => {
|
|
151
|
+
const cos = Math.SQRT1_2,
|
|
152
|
+
sin = Math.SQRT1_2;
|
|
153
|
+
expect(calcPlaneScaleY([cos, sin, -sin, cos, 0, 0])).toBeCloseTo(1);
|
|
154
|
+
expect(
|
|
155
|
+
calcPlaneScaleY([2 * cos, 2 * sin, -2 * sin, 2 * cos, 0, 0]),
|
|
156
|
+
).toBeCloseTo(2);
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
it('returns the Y-axis scale independently for a non-uniform scale matrix', () => {
|
|
160
|
+
expect(calcPlaneScaleY([2, 0, 0, 3, 0, 0])).toBe(3);
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
it('is independent of translation', () => {
|
|
164
|
+
expect(calcPlaneScaleY([3, 0, 0, 5, 100, 200])).toBe(5);
|
|
165
|
+
});
|
|
166
|
+
});
|
|
167
|
+
|
|
116
168
|
describe('transformPoint', () => {
|
|
117
169
|
it('transforms a point using a transformation matrix', () => {
|
|
118
170
|
const point = new Point(2, 2);
|
package/src/util/misc/matrix.ts
CHANGED
|
@@ -108,6 +108,22 @@ export const multiplyTransformMatrixArray = (
|
|
|
108
108
|
export const calcPlaneRotation = ([a, b]: TMat2D) =>
|
|
109
109
|
Math.atan2(b, a) as TRadian;
|
|
110
110
|
|
|
111
|
+
/**
|
|
112
|
+
* Returns the uniform scale (zoom) magnitude of a 2D affine matrix,
|
|
113
|
+
* computed as the length of the image of the unit X basis vector.
|
|
114
|
+
*/
|
|
115
|
+
export const calcPlaneZoom = ([a, b]: TMat2D) => Math.sqrt(a * a + b * b);
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Returns the Y-axis scale magnitude of a 2D affine matrix,
|
|
119
|
+
* computed as the length of the image of the unit Y basis vector.
|
|
120
|
+
* We do not support non uniform zooming on the viewport but to make things work
|
|
121
|
+
* we need to have a function that can return the value on Y axis.
|
|
122
|
+
* Bug reports and features will be planned with zoom being just a number
|
|
123
|
+
* that is the same for both axis
|
|
124
|
+
*/
|
|
125
|
+
export const calcPlaneScaleY = ([, , c, d]: TMat2D) => Math.sqrt(c * c + d * d);
|
|
126
|
+
|
|
111
127
|
/**
|
|
112
128
|
* Decomposes standard 2x3 matrix into transform components
|
|
113
129
|
* @param {TMat2D} a transformMatrix
|
|
@@ -5,7 +5,7 @@ import { Group } from '../../shapes/Group';
|
|
|
5
5
|
* Merges 2 clip paths into one visually equal clip path
|
|
6
6
|
*
|
|
7
7
|
* **IMPORTANT**:\
|
|
8
|
-
* Does **NOT** clone the arguments, clone them
|
|
8
|
+
* Does **NOT** clone the arguments, clone them prior if necessary.
|
|
9
9
|
*
|
|
10
10
|
* Creates a wrapper (group) that contains one clip path and is clipped by the other so content is kept where both overlap.
|
|
11
11
|
* Use this method if both the clip paths may have nested clip paths of their own, so assigning one to the other's clip path property is not possible.
|
|
@@ -171,7 +171,7 @@ export const enlivenObjectEnlivables = <
|
|
|
171
171
|
/**
|
|
172
172
|
* clipPath or shadow or gradient or text on a path or a pattern,
|
|
173
173
|
* or the backgroundImage or overlayImage of canvas
|
|
174
|
-
* If we have a type and there is a
|
|
174
|
+
* If we have a type and there is a class registered for it, we enlive it.
|
|
175
175
|
* If there is no class registered for it we return the value as is
|
|
176
176
|
* */
|
|
177
177
|
if (value.type && classRegistry.has(value.type)) {
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import { Color } from '../../color/Color';
|
|
2
2
|
import { config } from '../../config';
|
|
3
3
|
import { DEFAULT_SVG_FONT_SIZE, FILL, NONE } from '../../constants';
|
|
4
|
-
import type {
|
|
4
|
+
import type {
|
|
5
|
+
TBBox,
|
|
6
|
+
SVGElementName,
|
|
7
|
+
SupportedSVGUnit,
|
|
8
|
+
TFiller,
|
|
9
|
+
} from '../../typedefs';
|
|
10
|
+
import { isSafeSvgStyleValue } from '../internals/svgExportCheck';
|
|
5
11
|
import { escapeXml } from '../lang_string';
|
|
6
12
|
import { toFixed } from './toFixed';
|
|
7
13
|
|
|
@@ -126,24 +132,30 @@ export const parsePreserveAspectRatioAttribute = (
|
|
|
126
132
|
*/
|
|
127
133
|
export const colorPropToSVG = (
|
|
128
134
|
prop: string,
|
|
129
|
-
value?:
|
|
135
|
+
value?: string | TFiller | null,
|
|
130
136
|
inlineStyle = true,
|
|
131
137
|
) => {
|
|
132
138
|
let colorValue;
|
|
133
139
|
let opacityValue;
|
|
134
140
|
if (!value) {
|
|
135
141
|
colorValue = 'none';
|
|
136
|
-
} else if (value.toLive) {
|
|
137
|
-
colorValue = `url(#SVGID_${escapeXml(value.id)})`;
|
|
142
|
+
} else if ((value as TFiller).toLive) {
|
|
143
|
+
colorValue = `url(#SVGID_${escapeXml((value as TFiller).id)})`;
|
|
138
144
|
} else {
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
+
const rawValue = String(value);
|
|
146
|
+
if (!isSafeSvgStyleValue(rawValue)) {
|
|
147
|
+
colorValue = new Color('black').toRgb();
|
|
148
|
+
} else {
|
|
149
|
+
const color = new Color(rawValue),
|
|
150
|
+
opacity = color.getAlpha();
|
|
151
|
+
|
|
152
|
+
colorValue = color.toRgb();
|
|
153
|
+
if (opacity !== 1) {
|
|
154
|
+
opacityValue = opacity.toString();
|
|
155
|
+
}
|
|
145
156
|
}
|
|
146
157
|
}
|
|
158
|
+
|
|
147
159
|
if (inlineStyle) {
|
|
148
160
|
return `${prop}: ${colorValue}; ${
|
|
149
161
|
opacityValue ? `${prop}-opacity: ${opacityValue}; ` : ''
|
package/src/util/path/index.ts
CHANGED
|
@@ -355,7 +355,7 @@ export const makePathSimpler = (path: TComplexPathData): TSimplePathData => {
|
|
|
355
355
|
let x = 0,
|
|
356
356
|
y = 0;
|
|
357
357
|
// x1 and y1 represent the last point of the subpath. the subpath is started with
|
|
358
|
-
// m or M command. When a z or Z command is drawn, x and y need to be
|
|
358
|
+
// m or M command. When a z or Z command is drawn, x and y need to be reset to
|
|
359
359
|
// the last x1 and y1.
|
|
360
360
|
let x1 = 0,
|
|
361
361
|
y1 = 0;
|
|
@@ -877,7 +877,8 @@ export const parsePath = (pathString: string): TComplexPathData => {
|
|
|
877
877
|
// 00, 01, 10 or 11, making them identical to a plain number for the regex reMyNum
|
|
878
878
|
// reset the regexp
|
|
879
879
|
regExpArcCommandPoints.lastIndex = 0;
|
|
880
|
-
|
|
880
|
+
let out: RegExpExecArray | null;
|
|
881
|
+
while ((out = regExpArcCommandPoints.exec(matchStr))) {
|
|
881
882
|
paramArr.push(...out.slice(1));
|
|
882
883
|
}
|
|
883
884
|
} else {
|
package/src/util/path/regex.ts
CHANGED
|
@@ -5,7 +5,7 @@ const commaWsp = `\\s*,?\\s*`;
|
|
|
5
5
|
/**
|
|
6
6
|
* p for param
|
|
7
7
|
* using "bad naming" here because it makes the regex much easier to read
|
|
8
|
-
* p is a number that is preceded by an
|
|
8
|
+
* p is a number that is preceded by an arbitrary number of spaces, maybe 0,
|
|
9
9
|
* a comma or not, and then possibly more spaces or not.
|
|
10
10
|
*/
|
|
11
11
|
const p = `${commaWsp}(${reNum})`;
|
|
@@ -41,7 +41,7 @@ describe('typeAssertions', () => {
|
|
|
41
41
|
const newText = new NewText('hello world');
|
|
42
42
|
expect(isTextObject(newText)).toBe(true);
|
|
43
43
|
});
|
|
44
|
-
test('can safeguard
|
|
44
|
+
test('can safeguard against other FabricObjects', () => {
|
|
45
45
|
const path = new Path('M 0 0 L 1 1');
|
|
46
46
|
expect(isTextObject(path)).toBe(false);
|
|
47
47
|
});
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|