fabric 6.0.0-beta1 → 6.0.0-beta11
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/.eslintignore +3 -0
- package/.eslintrc.js +8 -0
- package/.gitpod.yml +17 -1
- package/.prettierignore +3 -0
- package/CHANGELOG.md +158 -0
- package/CONTRIBUTING.md +103 -88
- package/README.md +31 -17
- package/babel-jest.config.js +6 -0
- package/dist/fabric.d.ts +75 -1020
- package/dist/{index.cjs → index.js} +22801 -23051
- package/dist/index.js.map +1 -0
- package/dist/index.min.js +1 -1
- package/dist/index.mjs +22790 -23045
- package/dist/index.mjs.map +1 -1
- package/dist/index.node.cjs +22778 -23007
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.d.ts +9 -4
- package/dist/index.node.mjs +22768 -23002
- package/dist/index.node.mjs.map +1 -1
- package/dist/src/{util/class_registry.d.ts → ClassRegistry.d.ts} +2 -3
- package/dist/src/Collection.d.ts +37 -27
- package/dist/src/EventTypeDefs.d.ts +39 -42
- package/dist/src/Intersection.d.ts +12 -0
- package/dist/src/Observable.d.ts +17 -11
- package/dist/src/{Pattern.d.ts → Pattern/Pattern.d.ts} +23 -28
- package/dist/src/Pattern/index.d.ts +3 -0
- package/dist/src/Pattern/types.d.ts +9 -0
- package/dist/src/Point.d.ts +42 -42
- package/dist/src/Shadow.d.ts +12 -3
- package/dist/src/brushes/BaseBrush.d.ts +1 -5
- package/dist/src/brushes/CircleBrush.d.ts +2 -7
- package/dist/src/brushes/PatternBrush.d.ts +2 -2
- package/dist/src/brushes/PencilBrush.d.ts +8 -8
- package/dist/src/brushes/SprayBrush.d.ts +2 -7
- package/dist/src/brushes/typedefs.d.ts +18 -0
- package/dist/src/cache.d.ts +2 -1
- package/dist/src/canvas/Canvas.d.ts +22 -229
- package/dist/src/canvas/CanvasOptions.d.ts +232 -0
- package/dist/src/canvas/DOMManagers/CanvasDOMManager.d.ts +29 -0
- package/dist/src/canvas/DOMManagers/StaticCanvasDOMManager.d.ts +29 -0
- package/dist/src/canvas/DOMManagers/util.d.ts +24 -0
- package/dist/src/canvas/SelectableCanvas.d.ts +52 -265
- package/dist/src/canvas/StaticCanvas.d.ts +57 -195
- package/dist/src/canvas/StaticCanvasOptions.d.ts +153 -0
- package/dist/src/canvas/TextEditingManager.d.ts +5 -1
- package/dist/src/color/Color.d.ts +1 -23
- package/dist/src/color/constants.d.ts +96 -14
- package/dist/src/color/typedefs.d.ts +16 -0
- package/dist/src/color/util.d.ts +18 -3
- package/dist/src/constants.d.ts +8 -1
- package/dist/src/controls/Control.d.ts +14 -13
- package/dist/src/controls/changeWidth.d.ts +1 -1
- package/dist/src/controls/{default_controls.d.ts → commonControls.d.ts} +1 -23
- package/dist/src/controls/{controls.render.d.ts → controlRendering.d.ts} +6 -6
- package/dist/src/controls/drag.d.ts +1 -1
- package/dist/src/controls/fireEvent.d.ts +3 -0
- package/dist/src/controls/index.d.ts +13 -0
- package/dist/src/controls/rotate.d.ts +1 -1
- package/dist/src/controls/scale.d.ts +2 -2
- package/dist/src/controls/scaleSkew.d.ts +2 -2
- package/dist/src/controls/skew.d.ts +1 -1
- package/dist/src/controls/util.d.ts +2 -2
- package/dist/src/controls/wrapWithFireEvent.d.ts +1 -1
- package/dist/src/controls/wrapWithFixedAnchor.d.ts +1 -1
- package/dist/src/env/browser.d.ts +1 -1
- package/dist/src/env/index.d.ts +25 -4
- package/dist/src/env/node.d.ts +4 -1
- package/dist/src/env/types.d.ts +7 -6
- package/dist/src/filters/BaseFilter.d.ts +24 -20
- package/dist/src/filters/BlendColor.d.ts +17 -17
- package/dist/src/filters/BlendImage.d.ts +13 -10
- package/dist/src/filters/Blur.d.ts +4 -2
- package/dist/src/filters/Boilerplate.d.ts +6 -4
- package/dist/src/filters/Brightness.d.ts +4 -2
- package/dist/src/filters/Canvas2dFilterBackend.d.ts +1 -1
- package/dist/src/filters/ColorMatrix.d.ts +4 -2
- package/dist/src/filters/ColorMatrixFilters.d.ts +128 -760
- package/dist/src/filters/Composed.d.ts +7 -8
- package/dist/src/filters/Contrast.d.ts +4 -2
- package/dist/src/filters/Convolute.d.ts +6 -5
- package/dist/src/filters/FilterBackend.d.ts +2 -1
- package/dist/src/filters/GLProbes/GLProbe.d.ts +7 -0
- package/dist/src/filters/GLProbes/NodeGLProbe.d.ts +11 -0
- package/dist/src/filters/GLProbes/WebGLProbe.d.ts +20 -0
- package/dist/src/filters/Gamma.d.ts +6 -4
- package/dist/src/filters/Grayscale.d.ts +7 -5
- package/dist/src/filters/HueRotation.d.ts +3 -2
- package/dist/src/filters/Invert.d.ts +4 -2
- package/dist/src/filters/Noise.d.ts +4 -2
- package/dist/src/filters/Pixelate.d.ts +4 -2
- package/dist/src/filters/RemoveColor.d.ts +4 -2
- package/dist/src/filters/Resize.d.ts +37 -18
- package/dist/src/filters/Saturation.d.ts +4 -2
- package/dist/src/filters/Vibrance.d.ts +4 -2
- package/dist/src/filters/WebGLFilterBackend.d.ts +10 -7
- package/dist/src/filters/filters.d.ts +23 -0
- package/dist/src/filters/index.d.ts +7 -0
- package/dist/src/filters/shaders/baseFilter.d.ts +4 -0
- package/dist/src/filters/shaders/blendColor.d.ts +13 -0
- package/dist/src/filters/shaders/blendImage.d.ts +3 -0
- package/dist/src/filters/shaders/blur.d.ts +2 -0
- package/dist/src/filters/shaders/brightness.d.ts +2 -0
- package/dist/src/filters/shaders/colorMatrix.d.ts +2 -0
- package/dist/src/filters/shaders/constrast.d.ts +2 -0
- package/dist/src/filters/shaders/convolute.d.ts +11 -0
- package/dist/src/filters/shaders/gamma.d.ts +2 -0
- package/dist/src/filters/shaders/grayscale.d.ts +3 -0
- package/dist/src/filters/shaders/invert.d.ts +2 -0
- package/dist/src/filters/shaders/noise.d.ts +2 -0
- package/dist/src/filters/shaders/pixelate.d.ts +2 -0
- package/dist/src/filters/shaders/removeColor.d.ts +2 -0
- package/dist/src/filters/shaders/saturation.d.ts +2 -0
- package/dist/src/filters/shaders/vibrance.d.ts +2 -0
- package/dist/src/filters/typedefs.d.ts +2 -2
- package/dist/src/filters/utils.d.ts +3 -0
- package/dist/src/gradient/Gradient.d.ts +5 -4
- package/dist/src/gradient/index.d.ts +3 -0
- package/dist/src/gradient/parser/misc.d.ts +1 -1
- package/dist/src/gradient/parser/parseColorStops.d.ts +2 -5
- package/dist/src/gradient/parser/parseCoords.d.ts +1 -1
- package/dist/src/gradient/typedefs.d.ts +2 -2
- package/dist/src/parser/applyViewboxTransform.d.ts +9 -1
- package/dist/src/parser/constants.d.ts +2 -15
- package/dist/src/parser/doesSomeParentMatch.d.ts +1 -1
- package/dist/src/parser/elementById.d.ts +2 -1
- package/dist/src/parser/elementMatchesRule.d.ts +1 -1
- package/dist/src/parser/elements_parser.d.ts +32 -2
- package/dist/src/parser/getCSSRules.d.ts +3 -2
- package/dist/src/parser/getGlobalStylesForElement.d.ts +2 -1
- package/dist/src/parser/getGradientDefs.d.ts +1 -1
- package/dist/src/parser/getMultipleNodes.d.ts +1 -1
- package/dist/src/parser/getSvgRegex.d.ts +1 -1
- package/dist/src/parser/hasInvalidAncestor.d.ts +2 -0
- package/dist/src/parser/loadSVGFromString.d.ts +11 -5
- package/dist/src/parser/loadSVGFromURL.d.ts +11 -5
- package/dist/src/parser/normalizeAttr.d.ts +2 -1
- package/dist/src/parser/normalizeValue.d.ts +1 -1
- package/dist/src/parser/parseAttributes.d.ts +2 -1
- package/dist/src/parser/parseFontDeclaration.d.ts +1 -1
- package/dist/src/parser/parsePointsAttribute.d.ts +2 -4
- package/dist/src/parser/parseSVGDocument.d.ts +15 -8
- package/dist/src/parser/parseStyleAttribute.d.ts +1 -1
- package/dist/src/parser/parseStyleObject.d.ts +7 -1
- package/dist/src/parser/parseStyleString.d.ts +7 -1
- package/dist/src/parser/parseTransformAttribute.d.ts +3 -2
- package/dist/src/parser/parseUseDirectives.d.ts +1 -1
- package/dist/src/parser/recursivelyParseGradientsXlink.d.ts +1 -1
- package/dist/src/parser/selectorMatches.d.ts +1 -1
- package/dist/src/parser/setStrokeFillOpacity.d.ts +1 -1
- package/dist/src/parser/typedefs.d.ts +10 -0
- package/dist/src/shapes/ActiveSelection.d.ts +27 -4
- package/dist/src/shapes/Circle.d.ts +28 -8
- package/dist/src/shapes/Ellipse.d.ts +25 -14
- package/dist/src/shapes/Group.d.ts +78 -51
- package/dist/src/shapes/IText/DraggableTextDelegate.d.ts +1 -1
- package/dist/src/shapes/IText/IText.d.ts +43 -29
- package/dist/src/shapes/IText/ITextBehavior.d.ts +10 -8
- package/dist/src/shapes/IText/ITextClickBehavior.d.ts +6 -14
- package/dist/src/shapes/IText/ITextKeyBehavior.d.ts +35 -30
- package/dist/src/shapes/IText/constants.d.ts +2 -2
- package/dist/src/shapes/Image.d.ts +54 -23
- package/dist/src/shapes/Line.d.ts +33 -28
- package/dist/src/shapes/Object/AnimatableObject.d.ts +3 -3
- package/dist/src/shapes/Object/FabricObject.d.ts +6 -4
- package/dist/src/shapes/Object/FabricObjectSVGExportMixin.d.ts +21 -23
- package/dist/src/shapes/Object/InteractiveObject.d.ts +55 -41
- package/dist/src/shapes/Object/Object.d.ts +57 -365
- package/dist/src/shapes/Object/ObjectGeometry.d.ts +3 -19
- package/dist/src/shapes/Object/ObjectOrigin.d.ts +6 -75
- package/dist/src/shapes/Object/StackedObject.d.ts +14 -4
- package/dist/src/shapes/Object/defaultValues.d.ts +71 -72
- package/dist/src/shapes/Object/types/BaseProps.d.ts +84 -0
- package/dist/src/shapes/Object/types/BorderProps.d.ts +37 -0
- package/dist/src/shapes/Object/types/ControlProps.d.ts +62 -0
- package/dist/src/shapes/Object/types/FabricObjectProps.d.ts +96 -0
- package/dist/src/shapes/Object/types/FillStrokeProps.d.ts +80 -0
- package/dist/src/shapes/Object/types/LockInteractionProps.d.ts +51 -0
- package/dist/src/shapes/Object/types/ObjectProps.d.ts +42 -0
- package/dist/src/shapes/Object/types/SerializedObjectProps.d.ts +66 -0
- package/dist/src/shapes/Object/types/index.d.ts +6 -0
- package/dist/src/shapes/Path.d.ts +131 -39
- package/dist/src/shapes/Polygon.d.ts +5 -2
- package/dist/src/shapes/Polyline.d.ts +39 -15
- package/dist/src/shapes/Rect.d.ts +30 -8
- package/dist/src/shapes/Text/StyledText.d.ts +19 -13
- package/dist/src/shapes/Text/Text.d.ts +102 -59
- package/dist/src/shapes/Text/TextSVGExportMixin.d.ts +20 -5
- package/dist/src/shapes/Text/constants.d.ts +13 -0
- package/dist/src/shapes/Textbox.d.ts +72 -22
- package/dist/src/shapes/Triangle.d.ts +13 -3
- package/dist/src/typedefs.d.ts +31 -27
- package/dist/src/util/animation/AnimationBase.d.ts +1 -1
- package/dist/src/util/animation/AnimationFrameProvider.d.ts +0 -5
- package/dist/src/util/animation/ArrayAnimation.d.ts +1 -1
- package/dist/src/util/animation/ColorAnimation.d.ts +1 -1
- package/dist/src/util/animation/ValueAnimation.d.ts +1 -1
- package/dist/src/util/animation/animate.d.ts +2 -2
- package/dist/src/util/animation/easing.d.ts +1 -1
- package/dist/src/util/animation/index.d.ts +3 -0
- package/dist/src/util/animation/types.d.ts +1 -1
- package/dist/src/util/applyMixins.d.ts +1 -1
- package/dist/src/util/dom_event.d.ts +3 -2
- package/dist/src/util/dom_misc.d.ts +3 -31
- package/dist/src/util/dom_style.d.ts +1 -1
- package/dist/src/util/index.d.ts +37 -0
- package/dist/src/util/internals/cleanupSvgAttribute.d.ts +2 -0
- package/dist/src/util/{dom_request.d.ts → internals/dom_request.d.ts} +6 -4
- package/dist/src/util/internals/findRight.d.ts +2 -0
- package/dist/src/util/internals/index.d.ts +4 -3
- package/dist/src/util/misc/boundingBoxFromPoints.d.ts +4 -4
- package/dist/src/util/misc/dom.d.ts +1 -1
- package/dist/src/util/misc/findScaleTo.d.ts +7 -16
- package/dist/src/util/misc/groupSVGElements.d.ts +1 -1
- package/dist/src/util/misc/isTransparent.d.ts +3 -3
- package/dist/src/util/misc/matrix.d.ts +90 -14
- package/dist/src/util/misc/objectEnlive.d.ts +8 -21
- package/dist/src/util/misc/objectTransforms.d.ts +1 -1
- package/dist/src/util/misc/pick.d.ts +1 -0
- package/dist/src/util/misc/planeChange.d.ts +2 -5
- package/dist/src/util/misc/projectStroke/StrokeLineCapProjections.d.ts +4 -3
- package/dist/src/util/misc/projectStroke/StrokeLineJoinProjections.d.ts +19 -10
- package/dist/src/util/misc/projectStroke/StrokeProjectionsBase.d.ts +6 -4
- package/dist/src/util/misc/projectStroke/index.d.ts +4 -3
- package/dist/src/util/misc/projectStroke/types.d.ts +4 -4
- package/dist/src/util/misc/resolveOrigin.d.ts +1 -1
- package/dist/src/util/misc/svgParsing.d.ts +4 -12
- package/dist/src/util/misc/vectors.d.ts +28 -13
- package/dist/src/util/path/index.d.ts +96 -0
- package/dist/src/util/path/regex.d.ts +2 -0
- package/dist/src/util/path/typechecks.d.ts +24 -0
- package/dist/src/util/path/typedefs.d.ts +220 -0
- package/dist/src/util/transform_matrix_removal.d.ts +1 -1
- package/dist/src/util/{types.d.ts → typeAssertions.d.ts} +6 -4
- package/fabric.ts +121 -416
- package/index.node.ts +12 -12
- package/jest.config.js +195 -0
- package/lib/aligning_guidelines.js +2 -2
- package/package.json +43 -21
- package/playwright.config.ts +77 -0
- package/playwright.setup.ts +16 -0
- package/rollup.config.mjs +28 -7
- package/scripts/git.mjs +36 -0
- package/scripts/index.mjs +9 -124
- package/scripts/sandbox.mjs +149 -0
- package/src/{util/class_registry.ts → ClassRegistry.ts} +11 -9
- package/src/Collection.ts +63 -28
- package/src/CommonMethods.ts +3 -4
- package/src/EventTypeDefs.ts +102 -100
- package/src/Intersection.ts +54 -25
- package/src/Observable.ts +36 -40
- package/src/{Pattern.ts → Pattern/Pattern.ts} +39 -43
- package/src/Pattern/index.ts +2 -0
- package/src/Pattern/types.ts +17 -0
- package/src/Point.ts +43 -43
- package/src/Shadow.ts +28 -29
- package/src/brushes/BaseBrush.ts +1 -3
- package/src/brushes/CircleBrush.test.ts +11 -0
- package/src/brushes/CircleBrush.ts +6 -11
- package/src/brushes/PatternBrush.ts +2 -2
- package/src/brushes/PencilBrush.ts +10 -10
- package/src/brushes/SprayBrush.ts +6 -11
- package/src/brushes/typedefs.ts +18 -0
- package/src/cache.ts +2 -1
- package/src/canvas/Canvas.ts +173 -251
- package/src/canvas/CanvasOptions.ts +301 -0
- package/src/canvas/DOMManagers/CanvasDOMManager.ts +124 -0
- package/src/canvas/DOMManagers/StaticCanvasDOMManager.ts +80 -0
- package/src/canvas/DOMManagers/util.spec.ts +26 -0
- package/src/canvas/DOMManagers/util.ts +98 -0
- package/src/canvas/SelectableCanvas.ts +228 -575
- package/src/canvas/StaticCanvas.ts +119 -325
- package/src/canvas/StaticCanvasOptions.ts +199 -0
- package/src/canvas/TextEditingManager.ts +24 -2
- package/src/canvas/canvas_gestures.mixin.ts +10 -10
- package/src/color/Color.ts +51 -135
- package/src/color/color_map.ts +13 -13
- package/src/color/constants.ts +98 -17
- package/src/color/typedefs.ts +18 -0
- package/src/color/util.ts +68 -7
- package/src/constants.ts +11 -1
- package/src/controls/Control.ts +26 -18
- package/src/controls/changeWidth.ts +5 -4
- package/src/controls/{default_controls.ts → commonControls.ts} +2 -29
- package/src/controls/{controls.render.ts → controlRendering.ts} +5 -5
- package/src/controls/drag.ts +5 -4
- package/src/{util → controls}/fireEvent.ts +4 -1
- package/src/controls/index.ts +22 -0
- package/src/controls/polyControl.ts +4 -4
- package/src/controls/rotate.ts +1 -1
- package/src/controls/scale.ts +2 -2
- package/src/controls/scaleSkew.ts +2 -2
- package/src/controls/skew.ts +4 -3
- package/src/controls/util.ts +6 -5
- package/src/controls/wrapWithFireEvent.ts +2 -2
- package/src/controls/wrapWithFixedAnchor.ts +1 -1
- package/src/env/browser.ts +6 -2
- package/src/env/index.ts +27 -8
- package/src/env/node.ts +32 -26
- package/src/env/types.ts +7 -6
- package/src/filters/BaseFilter.ts +69 -69
- package/src/filters/BlendColor.ts +41 -80
- package/src/filters/BlendImage.ts +34 -58
- package/src/filters/Blur.ts +16 -37
- package/src/filters/Boilerplate.ts +25 -22
- package/src/filters/Brightness.ts +15 -23
- package/src/filters/Canvas2dFilterBackend.ts +1 -1
- package/src/filters/ColorMatrix.ts +17 -26
- package/src/filters/ColorMatrixFilters.ts +15 -46
- package/src/filters/Composed.ts +11 -18
- package/src/filters/Contrast.ts +13 -23
- package/src/filters/Convolute.ts +15 -170
- package/src/filters/FilterBackend.ts +10 -4
- package/src/filters/GLProbes/GLProbe.ts +7 -0
- package/src/filters/GLProbes/NodeGLProbe.ts +15 -0
- package/src/filters/{WebGLProbe.ts → GLProbes/WebGLProbe.ts} +9 -24
- package/src/filters/Gamma.ts +25 -40
- package/src/filters/Grayscale.ts +17 -50
- package/src/filters/HueRotation.ts +12 -14
- package/src/filters/Invert.ts +16 -32
- package/src/filters/Noise.ts +15 -28
- package/src/filters/Pixelate.ts +15 -31
- package/src/filters/RemoveColor.ts +16 -27
- package/src/filters/Resize.ts +142 -111
- package/src/filters/Saturation.ts +16 -27
- package/src/filters/Vibrance.ts +15 -28
- package/src/filters/WebGLFilterBackend.ts +69 -36
- package/src/filters/filters.ts +30 -0
- package/src/filters/index.ts +12 -0
- package/src/filters/shaders/baseFilter.ts +17 -0
- package/src/filters/shaders/blendColor.ts +33 -0
- package/src/filters/shaders/blendImage.ts +32 -0
- package/src/filters/shaders/blur.ts +24 -0
- package/src/filters/shaders/brightness.ts +11 -0
- package/src/filters/shaders/colorMatrix.ts +12 -0
- package/src/filters/shaders/constrast.ts +11 -0
- package/src/filters/shaders/convolute.ts +154 -0
- package/src/filters/shaders/gamma.ts +15 -0
- package/src/filters/shaders/grayscale.ts +36 -0
- package/src/filters/shaders/invert.ts +19 -0
- package/src/filters/shaders/noise.ts +16 -0
- package/src/filters/shaders/pixelate.ts +19 -0
- package/src/filters/shaders/removeColor.ts +13 -0
- package/src/filters/shaders/saturation.ts +15 -0
- package/src/filters/shaders/vibrance.ts +16 -0
- package/src/filters/typedefs.ts +2 -7
- package/src/filters/utils.ts +7 -0
- package/src/gradient/Gradient.ts +19 -18
- package/src/gradient/index.ts +2 -0
- package/src/gradient/parser/misc.ts +1 -1
- package/src/gradient/parser/parseColorStops.ts +2 -1
- package/src/gradient/parser/parseCoords.ts +2 -2
- package/src/gradient/typedefs.ts +2 -2
- package/src/mixins/eraser_brush.mixin.ts +2 -1
- package/src/parser/applyViewboxTransform.ts +57 -45
- package/src/parser/constants.ts +7 -26
- package/src/parser/doesSomeParentMatch.ts +7 -8
- package/src/parser/elementById.ts +8 -13
- package/src/parser/elementMatchesRule.ts +4 -7
- package/src/parser/elements_parser.ts +140 -133
- package/src/parser/getCSSRules.ts +43 -42
- package/src/parser/getGlobalStylesForElement.ts +11 -8
- package/src/parser/getGradientDefs.ts +11 -10
- package/src/parser/getMultipleNodes.ts +10 -6
- package/src/parser/getSvgRegex.ts +1 -3
- package/src/parser/hasInvalidAncestor.ts +19 -0
- package/src/parser/loadSVGFromString.ts +19 -16
- package/src/parser/loadSVGFromURL.ts +36 -30
- package/src/parser/normalizeAttr.ts +3 -8
- package/src/parser/normalizeValue.ts +29 -22
- package/src/parser/parseAttributes.ts +39 -37
- package/src/parser/parseFontDeclaration.ts +4 -2
- package/src/parser/parsePointsAttribute.ts +8 -11
- package/src/parser/parseSVGDocument.ts +68 -80
- package/src/parser/parseStyleAttribute.ts +2 -3
- package/src/parser/parseStyleObject.ts +15 -13
- package/src/parser/parseStyleString.ts +13 -11
- package/src/parser/parseTransformAttribute.ts +54 -115
- package/src/parser/parseUseDirectives.ts +38 -36
- package/src/parser/recursivelyParseGradientsXlink.ts +18 -18
- package/src/parser/selectorMatches.ts +11 -11
- package/src/parser/setStrokeFillOpacity.ts +18 -17
- package/src/parser/typedefs.ts +15 -0
- package/src/shapes/ActiveSelection.ts +55 -13
- package/src/shapes/Circle.ts +81 -45
- package/src/shapes/Ellipse.ts +60 -37
- package/src/shapes/Group.spec.ts +15 -0
- package/src/shapes/Group.ts +151 -99
- package/src/shapes/IText/DraggableTextDelegate.ts +28 -33
- package/src/shapes/IText/IText.ts +86 -54
- package/src/shapes/IText/ITextBehavior.test.ts +93 -0
- package/src/shapes/IText/ITextBehavior.ts +75 -57
- package/src/shapes/IText/ITextClickBehavior.ts +44 -73
- package/src/shapes/IText/ITextKeyBehavior.ts +120 -120
- package/src/shapes/IText/__snapshots__/ITextBehavior.test.ts.snap +810 -0
- package/src/shapes/IText/constants.ts +41 -23
- package/src/shapes/Image.ts +185 -114
- package/src/shapes/Line.ts +108 -151
- package/src/shapes/Object/AnimatableObject.ts +4 -7
- package/src/shapes/Object/FabricObject.ts +17 -7
- package/src/shapes/Object/FabricObjectSVGExportMixin.ts +50 -73
- package/src/shapes/Object/InteractiveObject.ts +105 -76
- package/src/shapes/Object/Object.ts +166 -473
- package/src/shapes/Object/ObjectGeometry.ts +12 -28
- package/src/shapes/Object/ObjectOrigin.ts +19 -96
- package/src/shapes/Object/StackedObject.ts +36 -21
- package/src/shapes/Object/defaultValues.ts +7 -9
- package/src/shapes/Object/types/BaseProps.ts +96 -0
- package/src/shapes/Object/types/BorderProps.ts +40 -0
- package/src/shapes/Object/types/ControlProps.ts +69 -0
- package/src/shapes/Object/types/FabricObjectProps.ts +111 -0
- package/src/shapes/Object/types/FillStrokeProps.ts +90 -0
- package/src/shapes/Object/types/LockInteractionProps.ts +57 -0
- package/src/shapes/Object/types/ObjectProps.ts +49 -0
- package/src/shapes/Object/types/SerializedObjectProps.ts +73 -0
- package/src/shapes/Object/types/index.ts +7 -0
- package/src/shapes/Path.ts +172 -126
- package/src/shapes/Polygon.ts +12 -9
- package/src/shapes/Polyline.ts +172 -94
- package/src/shapes/Rect.ts +57 -29
- package/src/shapes/Text/StyledText.ts +49 -48
- package/src/shapes/Text/Text.spec.ts +73 -0
- package/src/shapes/Text/Text.ts +281 -314
- package/src/shapes/Text/TextSVGExportMixin.ts +103 -26
- package/src/shapes/Text/__snapshots__/Text.spec.ts.snap +214 -0
- package/src/shapes/Text/constants.ts +111 -0
- package/src/shapes/Textbox.spec.ts +89 -0
- package/src/shapes/Textbox.ts +170 -73
- package/src/shapes/Triangle.ts +25 -11
- package/src/shapes/__snapshots__/Textbox.spec.ts.snap +164 -0
- package/src/typedefs.ts +41 -34
- package/src/util/animation/AnimationBase.ts +1 -1
- package/src/util/animation/AnimationFrameProvider.ts +3 -22
- package/src/util/animation/ArrayAnimation.ts +1 -1
- package/src/util/animation/ColorAnimation.ts +1 -1
- package/src/util/animation/ValueAnimation.ts +1 -1
- package/src/util/animation/animate.ts +2 -2
- package/src/util/animation/easing.ts +1 -1
- package/src/util/animation/index.ts +2 -0
- package/src/util/animation/types.ts +1 -1
- package/src/util/applyMixins.ts +1 -1
- package/src/util/dom_event.ts +9 -8
- package/src/util/dom_misc.ts +18 -109
- package/src/util/dom_style.ts +4 -2
- package/src/util/index.ts +118 -0
- package/src/util/internals/cleanupSvgAttribute.test.ts +16 -0
- package/src/util/internals/cleanupSvgAttribute.ts +8 -0
- package/src/util/internals/cloneDeep.test.ts +16 -0
- package/src/util/{dom_request.ts → internals/dom_request.ts} +13 -25
- package/src/util/internals/findRight.ts +11 -0
- package/src/util/internals/getRandomInt.test.ts +33 -0
- package/src/util/internals/index.ts +4 -3
- package/src/util/misc/boundingBoxFromPoints.ts +5 -4
- package/src/util/misc/dom.ts +10 -5
- package/src/util/misc/findScaleTo.ts +7 -22
- package/src/util/misc/isTransparent.ts +9 -32
- package/src/util/misc/matrix.ts +164 -57
- package/src/util/misc/objectEnlive.ts +25 -33
- package/src/util/misc/objectTransforms.ts +3 -2
- package/src/util/misc/pick.ts +12 -0
- package/src/util/misc/planeChange.ts +4 -13
- package/src/util/misc/projectStroke/StrokeLineCapProjections.ts +60 -24
- package/src/util/misc/projectStroke/StrokeLineJoinProjections.ts +156 -73
- package/src/util/misc/projectStroke/StrokeProjectionsBase.ts +7 -16
- package/src/util/misc/projectStroke/index.ts +35 -7
- package/src/util/misc/projectStroke/types.ts +4 -4
- package/src/util/misc/resolveOrigin.ts +1 -1
- package/src/util/misc/svgParsing.ts +20 -30
- package/src/util/misc/textStyles.ts +5 -6
- package/src/util/misc/vectors.ts +44 -26
- package/src/util/path/__snapshots__/index.spec.ts.snap +55 -0
- package/src/util/path/index.spec.ts +17 -0
- package/src/util/{path.ts → path/index.ts} +419 -321
- package/src/util/path/regex.ts +39 -0
- package/src/util/path/typechecks.ts +145 -0
- package/src/util/path/typedefs.ts +305 -0
- package/src/util/transform_matrix_removal.ts +4 -3
- package/src/util/{types.ts → typeAssertions.ts} +10 -3
- package/toMatchRoundedSnapshot.ts +66 -0
- package/tsconfig.json +1 -1
- package/dist/index.cjs.map +0 -1
- package/dist/src/filters/WebGLProbe.d.ts +0 -28
- package/dist/src/gradient/parser/index.d.ts +0 -4
- package/dist/src/mixins/stateful.mixin.d.ts +0 -18
- package/dist/src/parser/hasAncestorWithNodeName.d.ts +0 -2
- package/dist/src/parser/parseElements.d.ts +0 -11
- package/dist/src/parser/rotateMatrix.d.ts +0 -2
- package/dist/src/parser/scaleMatrix.d.ts +0 -2
- package/dist/src/parser/skewMatrix.d.ts +0 -2
- package/dist/src/parser/translateMatrix.d.ts +0 -2
- package/dist/src/util/fireEvent.d.ts +0 -3
- package/dist/src/util/lang_class.d.ts +0 -12
- package/dist/src/util/path.d.ts +0 -108
- package/scripts/transform_files.mjs +0 -504
- package/src/gradient/parser/index.ts +0 -3
- package/src/mixins/stateful.mixin.ts +0 -104
- package/src/parser/hasAncestorWithNodeName.ts +0 -14
- package/src/parser/parseElements.ts +0 -28
- package/src/parser/rotateMatrix.ts +0 -21
- package/src/parser/scaleMatrix.ts +0 -9
- package/src/parser/skewMatrix.ts +0 -6
- package/src/parser/translateMatrix.ts +0 -8
- package/src/util/lang_class.ts +0 -90
package/.eslintignore
ADDED
package/.eslintrc.js
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
module.exports = {
|
|
2
2
|
root: true,
|
|
3
3
|
parser: '@typescript-eslint/parser',
|
|
4
|
+
parserOptions: {
|
|
5
|
+
project: true,
|
|
6
|
+
tsconfigRootDir: './',
|
|
7
|
+
},
|
|
4
8
|
plugins: ['@typescript-eslint'],
|
|
5
9
|
extends: [
|
|
6
10
|
'eslint:recommended',
|
|
7
11
|
'plugin:@typescript-eslint/recommended',
|
|
12
|
+
// this is too noisy for now
|
|
13
|
+
// 'plugin:@typescript-eslint/recommended-requiring-type-checking',
|
|
8
14
|
'prettier',
|
|
9
15
|
],
|
|
10
16
|
overrides: [
|
|
@@ -13,6 +19,8 @@ module.exports = {
|
|
|
13
19
|
},
|
|
14
20
|
],
|
|
15
21
|
rules: {
|
|
22
|
+
'@typescript-eslint/consistent-type-exports': 'error',
|
|
23
|
+
'@typescript-eslint/consistent-type-imports': 'error',
|
|
16
24
|
'@typescript-eslint/ban-types': 1,
|
|
17
25
|
'@typescript-eslint/ban-ts-comment': 1,
|
|
18
26
|
'no-restricted-globals': [
|
package/.gitpod.yml
CHANGED
|
@@ -1,2 +1,18 @@
|
|
|
1
|
+
# https://www.gitpod.io/docs/config-gitpod-file
|
|
2
|
+
|
|
1
3
|
tasks:
|
|
2
|
-
-
|
|
4
|
+
- name: Build & Watch
|
|
5
|
+
init: npm install
|
|
6
|
+
command: npm run build -- -w -f
|
|
7
|
+
|
|
8
|
+
- name: Node
|
|
9
|
+
init: npm install
|
|
10
|
+
command: npm start node -- --no-watch
|
|
11
|
+
|
|
12
|
+
- name: Next.js
|
|
13
|
+
init: npm install
|
|
14
|
+
command: npm start next -- --no-watch
|
|
15
|
+
|
|
16
|
+
- name: Vanilla
|
|
17
|
+
init: npm install
|
|
18
|
+
command: npm start vanilla -- --no-watch
|
package/.prettierignore
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,164 @@
|
|
|
2
2
|
|
|
3
3
|
## [next]
|
|
4
4
|
|
|
5
|
+
## [6.0.0-beta11]
|
|
6
|
+
|
|
7
|
+
- patch(): Avoid unwanted mutation to passed objects array to Group constructor [#9151](https://github.com/fabricjs/fabric.js/pull/9151)
|
|
8
|
+
- patch(): ActiveSelection initialization + types [#9143](https://github.com/fabricjs/fabric.js/pull/9143)
|
|
9
|
+
- chore(TS): BREAKING remove canvas.interactive, added typings for canvas options [#9140](https://github.com/fabricjs/fabric.js/pull/9140)
|
|
10
|
+
- chore(TS): BREAKING PREVIOUS BETA mv + rename `TProps` => `TOptions` [#9139](https://github.com/fabricjs/fabric.js/pull/9139)
|
|
11
|
+
- test(playwright): Use embedded eval from playwright [#9133](https://github.com/fabricjs/fabric.js/pull/9133)
|
|
12
|
+
- chore(TS): Fix event types and .once this binding [#9119](https://github.com/fabricjs/fabric.js/pull/9130)
|
|
13
|
+
- docs(): rm `canvas2pdf` [#9135](https://github.com/fabricjs/fabric.js/pull/9135)
|
|
14
|
+
- chore(TS): export types [#9129](https://github.com/fabricjs/fabric.js/pull/9129)
|
|
15
|
+
- ci(e2e): support relative imports [#9108](https://github.com/fabricjs/fabric.js/pull/9108)
|
|
16
|
+
- chore(TS): complete type check [#9119](https://github.com/fabricjs/fabric.js/pull/9119)
|
|
17
|
+
- chore(TS): Add type-checking to files excluded with ts-nocheck [#9097](https://github.com/fabricjs/fabric.js/pull/9097)
|
|
18
|
+
- chore(TS): Add type-checking to files excluded with ts-nocheck ( Parser mostly ) [#9085](https://github.com/fabricjs/fabric.js/pull/9085)
|
|
19
|
+
- docs(): revise test section [#9114](https://github.com/fabricjs/fabric.js/pull/9114)
|
|
20
|
+
- fix(): #8344 stroke projection [#8374](https://github.com/fabricjs/fabric.js/pull/8374)
|
|
21
|
+
- fix(Filters) Removing type from the options passed in the constructor [#9089](https://github.com/fabricjs/fabric.js/pull/9089)
|
|
22
|
+
- feat(InteractiveObject): add `getActiveControl()` to expose `__corner` [#9102](https://github.com/fabricjs/fabric.js/pull/9102)
|
|
23
|
+
- ci(sandbox): bump next.js [#9100](https://github.com/fabricjs/fabric.js/pull/9100)
|
|
24
|
+
- test(playwright): add snapshots, refactor utils, coverage [#9078](https://github.com/fabricjs/fabric.js/pull/9078)
|
|
25
|
+
- test(Text): Add some tests for text in Jest [#9083](https://github.com/fabricjs/fabric.js/pull/9083)
|
|
26
|
+
- ci(): Install system deps only when necessary [#9086](https://github.com/fabricjs/fabric.js/pull/9086)
|
|
27
|
+
- fix(util, Path): path distance measurement fix for M cmd [#9076](https://github.com/fabricjs/fabric.js/pull/9076)
|
|
28
|
+
- chore(TS): Image class type checks, BREAKING change to FromURL static method [#9036](https://github.com/fabricjs/fabric.js/pull/9036)
|
|
29
|
+
- ci(): properly checkout head for stats [#9080](https://github.com/fabricjs/fabric.js/pull/9080)
|
|
30
|
+
- fix(Text): `_getFontDeclaration` wasn't considering fontFamily from the style object [#9082](https://github.com/fabricjs/fabric.js/pull/9082)
|
|
31
|
+
- chore(TS): Fix ITextBehaviour enterEditing type [#9075](https://github.com/fabricjs/fabric.js/pull/9075)
|
|
32
|
+
- chore(TS): export FabricObjectProps and GroupProps [#9025](https://github.com/fabricjs/fabric.js/pull/9025)
|
|
33
|
+
- chore(TS): Replace BaseFabricObject with FabricObject [#9016](https://github.com/fabricjs/fabric.js/pull/9016)
|
|
34
|
+
- refactor(svgImport): remove the css/gradient/clipPath global definitions [#9030](https://github.com/fabricjs/fabric.js/pull/9030)
|
|
35
|
+
- fix(): tweaks to type getter [#9022](https://github.com/fabricjs/fabric.js/pull/9022)
|
|
36
|
+
- ci() Refactor GHA actions for caching and reuse [#9029](https://github.com/fabricjs/fabric.js/pull/9029)
|
|
37
|
+
- ci(): install dev deps types [#9039](https://github.com/fabricjs/fabric.js/pull/9039)
|
|
38
|
+
|
|
39
|
+
## [6.0.0-beta10]
|
|
40
|
+
|
|
41
|
+
- chore(TS): Remove @ts-nocheck from Text class. [#9018](https://github.com/fabricjs/fabric.js/pull/9018)
|
|
42
|
+
- Fix(Textbox) minimum word width calculation across all lines [#9004](https://github.com/fabricjs/fabric.js/pull/9004)
|
|
43
|
+
- ci(): add Jest for the unit tests [#8919](https://github.com/fabricjs/fabric.js/pull/8919)
|
|
44
|
+
- ci(): Revert "invoke tests after changelog action (#8974)" [#9013](https://github.com/fabricjs/fabric.js/pull/9013)
|
|
45
|
+
- fix(IText): empty line selection [#9019](https://github.com/fabricjs/fabric.js/pull/9019)
|
|
46
|
+
- ci(): Added playwright testing [#8616](https://github.com/fabricjs/fabric.js/pull/8616)
|
|
47
|
+
- fix(IText): `exitEditing` should clear contextTop [#9020](https://github.com/fabricjs/fabric.js/pull/9020)
|
|
48
|
+
- ci(): prettier after changelog action [#9021](https://github.com/fabricjs/fabric.js/pull/9021)
|
|
49
|
+
|
|
50
|
+
## [6.0.0-beta9]
|
|
51
|
+
|
|
52
|
+
- fix(fabric): Fix the serialization and registry dependency from minification [#9009](https://github.com/fabricjs/fabric.js/pull/9009)
|
|
53
|
+
- chore(TS): remove troublesome `AssertKeys` TS construct [#9012](https://github.com/fabricjs/fabric.js/pull/9012)
|
|
54
|
+
- fix(lib): fix aligning_guideline zoom [#8998](https://github.com/fabricjs/fabric.js/pull/8998)
|
|
55
|
+
- fix(IText): support control interaction in text editing mode [#8995](https://github.com/fabricjs/fabric.js/pull/8995)
|
|
56
|
+
- fix(Textbox): `splitByGrapheme` measurements infix length bug [#8990](https://github.com/fabricjs/fabric.js/pull/8990)
|
|
57
|
+
- patch(Text): styles es6 minor patch [#8988](https://github.com/fabricjs/fabric.js/pull/8988)
|
|
58
|
+
|
|
59
|
+
## [6.0.0-beta8]
|
|
60
|
+
|
|
61
|
+
- BREAKING fix(IText): detect cursor from proper offsets, remove getLocalPointer from IText class [#8972](https://github.com/fabricjs/fabric.js/pull/8972)
|
|
62
|
+
- fix(Text): styles line break [#8973](https://github.com/fabricjs/fabric.js/pull/8973)
|
|
63
|
+
- fix(): regression to itext focusing from #8939 [#8970](https://github.com/fabricjs/fabric.js/pull/8970)
|
|
64
|
+
- ci(): warn build errors in dev mode [#8971](https://github.com/fabricjs/fabric.js/pull/8971)
|
|
65
|
+
- ci(): invoke tests after changelog action [#8974](https://github.com/fabricjs/fabric.js/pull/8974)
|
|
66
|
+
- chore(TS): Export more types [#8965](https://github.com/fabricjs/fabric.js/pull/8965)
|
|
67
|
+
- BREAKING: fabric.util.makeElementSelectable / fabric.util.makeElementUnselectable are removed [#8930](https://github.com/fabricjs/fabric.js/pull/8930)
|
|
68
|
+
- refactor(): Canvas DOM delegation to utility class [#8930](https://github.com/fabricjs/fabric.js/pull/8930)
|
|
69
|
+
|
|
70
|
+
## [6.0.0-beta7]
|
|
71
|
+
|
|
72
|
+
- feat(): Export setFilterBackend and port the texture filtering option from fabric 5, exports some extra types [#8954](https://github.com/fabricjs/fabric.js/pull/8954)
|
|
73
|
+
- chore(): swap commonly used string with constants [#8933](https://github.com/fabricjs/fabric.js/pull/8933)
|
|
74
|
+
- chore(TS): Add more text types [#8941](https://github.com/fabricjs/fabric.js/pull/8941)
|
|
75
|
+
- ci(): fix changelog action race condition [#8949](https://github.com/fabricjs/fabric.js/pull/8949)
|
|
76
|
+
- ci(): automate PR changelog [#8938](https://github.com/fabricjs/fabric.js/pull/8938)
|
|
77
|
+
- chore(): move canvas click handler to TextManager [#8939](https://github.com/fabricjs/fabric.js/pull/8939)
|
|
78
|
+
- refactor(): write less bulky code [#8943](https://github.com/fabricjs/fabric.js/pull/8943)
|
|
79
|
+
|
|
80
|
+
## [6.0.0-beta6]
|
|
81
|
+
|
|
82
|
+
- patch(): expose `Control#shouldActivate` [#8934](https://github.com/fabricjs/fabric.js/pull/8934)
|
|
83
|
+
- feat(Color) Improve regex for new standards, more documentation and code cleanup [#8916](https://github.com/fabricjs/fabric.js/pull/8916)
|
|
84
|
+
- fix(TS): extending canvas and object event types (`type` => `interface`) [#8926](https://github.com/fabricjs/fabric.js/pull/8926)
|
|
85
|
+
- chore(build) simple deps update [#8929](https://github.com/fabricjs/fabric.js/pull/8929)
|
|
86
|
+
- fix(Canvas): sync cleanup of dom elements in dispose [#8903](https://github.com/fabricjs/fabric.js/pull/8903)
|
|
87
|
+
- chore(TS): export util types [#8915](https://github.com/fabricjs/fabric.js/pull/8915)
|
|
88
|
+
- chore(TS): change enums with types [#8918](https://github.com/fabricjs/fabric.js/pull/8918)
|
|
89
|
+
- chore(TS): export gradient types
|
|
90
|
+
- chore(lint) export filter colors and brushes types [#8913](https://github.com/fabricjs/fabric.js/pull/8913)
|
|
91
|
+
- chore(lint) Add a rule for import type [#8907](https://github.com/fabricjs/fabric.js/pull/8907)
|
|
92
|
+
- fix(Object): dirty unflagging inconsistency [#8910](https://github.com/fabricjs/fabric.js/pull/8910)
|
|
93
|
+
- chore(TS): minor type/import fixes [#8904](https://github.com/fabricjs/fabric.js/pull/8904)
|
|
94
|
+
- chore(): Matrix util cleanup [#8894](https://github.com/fabricjs/fabric.js/pull/8894)
|
|
95
|
+
- chore(TS): pattern cleanup + export types [#8875](https://github.com/fabricjs/fabric.js/pull/8875)
|
|
96
|
+
- fix(): Disable offscreen check for bg and overlay when not needed [#8898](https://github.com/fabricjs/fabric.js/pull/8898)
|
|
97
|
+
- chore(): cleanup #8888 [#8892](https://github.com/fabricjs/fabric.js/pull/8892)
|
|
98
|
+
- feat(env): relative window/document, support iframe [#8897](https://github.com/fabricjs/fabric.js/pull/8897)
|
|
99
|
+
- docs(): add repo repro link to `bug_report.yml` [#8900](https://github.com/fabricjs/fabric.js/pull/8900)
|
|
100
|
+
- refactor(fabric.Line): Line position is calculated from the center between the 2 points now [#8877](https://github.com/fabricjs/fabric.js/pull/8877)
|
|
101
|
+
- chore(Path, Polyline): Clean up old SVG import code [#8857](https://github.com/fabricjs/fabric.js/pull/8857)
|
|
102
|
+
|
|
103
|
+
## [6.0.0-beta5]
|
|
104
|
+
|
|
105
|
+
- refactor(): SVG loading and parsing functionality are now promises or async. Callback have been removed [#8884](https://github.com/fabricjs/fabric.js/pull/8884)
|
|
106
|
+
- refactor(fabric.Line): Line position is calculated from the center between the 2 points now [#8877](https://github.com/fabricjs/fabric.js/pull/8877)
|
|
107
|
+
- bundle(): export `setEnv` for test interoperability [#8888](https://github.com/fabricjs/fabric.js/pull/8888)
|
|
108
|
+
|
|
109
|
+
## [6.0.0-beta4]
|
|
110
|
+
|
|
111
|
+
- chore(): Code cleanup and reuse of code in svg-parsing code [#8881](https://github.com/fabricjs/fabric.js/pull/8881)
|
|
112
|
+
- chore(TS): Parse transform attribute typing [#8878](https://github.com/fabricjs/fabric.js/pull/8878)
|
|
113
|
+
- chore(TS): Fix typing for DOMParser [#8871](https://github.com/fabricjs/fabric.js/pull/8871)
|
|
114
|
+
- fix(Path, Polyline): fix for SVG import [#8879](https://github.com/fabricjs/fabric.js/pull/8879)
|
|
115
|
+
- chore(TS) add types for loadSVGFromURl, parseSVGDocument, loadSVGFromString [#8869](https://github.com/fabricjs/fabric.js/pull/8869)
|
|
116
|
+
- chore(TS): finalize Path migration [#8438](https://github.com/fabricjs/fabric.js/pull/8438)
|
|
117
|
+
- fix(Path, Obect) Fix path parsing edge case for zeroed arc command and for too small canvas patterns [#8853](https://github.com/fabricjs/fabric.js/pull/8853)
|
|
118
|
+
|
|
119
|
+
## [6.0.0-beta3]
|
|
120
|
+
|
|
121
|
+
- chore(TS): Path type fixes [#8842](https://github.com/fabricjs/fabric.js/pull/8842)
|
|
122
|
+
- fix(TS): add types to some untyped empty arrays [#8830](https://github.com/fabricjs/fabric.js/pull/8830)
|
|
123
|
+
- chore(TS): Complete typings for toObject/fromObject [#8756](https://github.com/fabricjs/fabric.js/pull/8756)
|
|
124
|
+
- fix(): text styles edge case [#8820](https://github.com/fabricjs/fabric.js/pull/8820)
|
|
125
|
+
- chore(TS): Group types [#8807](https://github.com/fabricjs/fabric.js/pull/8807)
|
|
126
|
+
- chore(TS): Path util typings and refactoring [#8787](https://github.com/fabricjs/fabric.js/pull/8787)
|
|
127
|
+
- rename(): `IPoint` => `XY` [#8806](https://github.com/fabricjs/fabric.js/pull/8806)
|
|
128
|
+
- ci(): use sandbox apps in issue template, use the current branch when deploying an app, minors [#8803](https://github.com/fabricjs/fabric.js/pull/8803)
|
|
129
|
+
- perf(): optimize `perPixelTargetFind` [#8770](https://github.com/fabricjs/fabric.js/pull/8770)
|
|
130
|
+
- BREAKING fix(): reflect NUM_FRACTION_DIGITS to SVG path data [#8782] (https://github.com/fabricjs/fabric.js/pull/8782)
|
|
131
|
+
- fix(IText): layout change regression caused by #8663 (`text` was changed but layout was skipped) [#8711](https://github.com/fabricjs/fabric.js/pull/8711)
|
|
132
|
+
- fix(IText, Textbox): fix broken text input [#8775](https://github.com/fabricjs/fabric.js/pull/8775)
|
|
133
|
+
- ci(): `.codesandbox` [#8135](https://github.com/fabricjs/fabric.js/pull/8135)
|
|
134
|
+
- ci(): disallow circular deps [#8759](https://github.com/fabricjs/fabric.js/pull/8759)
|
|
135
|
+
- fix(): env WebGL import cycle [#8758](https://github.com/fabricjs/fabric.js/pull/8758)
|
|
136
|
+
- chore(TS): remove controls from prototype. BREAKING: controls aren't shared anymore [#8753](https://github.com/fabricjs/fabric.js/pull/8753)
|
|
137
|
+
- chore(TS): remove object `type` from prototype [#8714](https://github.com/fabricjs/fabric.js/pull/8714)
|
|
138
|
+
- chore(TS): type Object props [#8677](https://github.com/fabricjs/fabric.js/issues/8677)
|
|
139
|
+
- chore(TS): remove default values from filter prototypes [#8742](https://github.com/fabricjs/fabric.js/issues/8742)
|
|
140
|
+
- chore(TS): remove default values from Objects prototypes, ( filters in a followup ) [#8719](https://github.com/fabricjs/fabric.js/issues/8719)
|
|
141
|
+
- fix(Intersection): bug causing selection edge case [#8735](https://github.com/fabricjs/fabric.js/pull/8735)
|
|
142
|
+
- chore(TS): class interface for options/brevity [#8674](https://github.com/fabricjs/fabric.js/issues/8674)
|
|
143
|
+
- ci(): fix import autocomplete in dev mode #8725
|
|
144
|
+
- chore(): remove deprecated class util [#8731](https://github.com/fabricjs/fabric.js/pull/8731)
|
|
145
|
+
- lint(): fix eslint errors [#8729](https://github.com/fabricjs/fabric.js/pull/8729)
|
|
146
|
+
- fix(TS): `this.constructor` types [#8675](https://github.com/fabricjs/fabric.js/issues/8675)
|
|
147
|
+
- fix(DraggableText): drag image blur [#8712](https://github.com/fabricjs/fabric.js/pull/8712)
|
|
148
|
+
- ci(): Fix tests for firefox 110 update [#8710](https://github.com/fabricjs/fabric.js/pull/8710)
|
|
149
|
+
- chore(): index files for exports and tree shaking [#8661](https://github.com/fabricjs/fabric.js/pull/8661)
|
|
150
|
+
- ci(test): cleanup node config (#8694 followup) [#8707](https://github.com/fabricjs/fabric.js/issues/8707)
|
|
151
|
+
- fix(): BREAKING set/discard active object return value, discard active object now return false if no discard happened [#8672](https://github.com/fabricjs/fabric.js/issues/8672)
|
|
152
|
+
- fix(): selection logic to support nested multiselection [#8665](https://github.com/fabricjs/fabric.js/issues/8665)
|
|
153
|
+
- fix(test): remove bad node config [#8694](https://github.com/fabricjs/fabric.js/issues/8694)
|
|
154
|
+
- fix(): keep browser files as .js [#8690](https://github.com/fabricjs/fabric.js/issues/8690)
|
|
155
|
+
- fix(): object dispose removes canvas/event refs [#8673](https://github.com/fabricjs/fabric.js/issues/8673)
|
|
156
|
+
- fix(test): Textbox `fromObject` test is incorrectly trying to restore an instance [#8686](https://github.com/fabricjs/fabric.js/pull/8686)
|
|
157
|
+
- TS(): Moved cache properties to static properties on classes [#xxxx](https://github.com/fabricjs/fabric.js/pull/xxxx)
|
|
158
|
+
- refactor(): Moved cache properties to static properties on classes [#8662](https://github.com/fabricjs/fabric.js/pull/8662)
|
|
159
|
+
- docs(): v6 announcements [#8664](https://github.com/fabricjs/fabric.js/issues/8664)
|
|
160
|
+
- ci(): remove TS transformer [#8660](https://github.com/fabricjs/fabric.js/pull/8660)
|
|
161
|
+
- refactor(): BREAKING remove stateful mixin and functionality [#8663](https://github.com/fabricjs/fabric.js/pull/8663)
|
|
162
|
+
- patch(): Added WebGLProbe to env, removed isLikelyNode, added specific env dispose ( instead of cleanup JSDOM ) [#8652](https://github.com/fabricjs/fabric.js/pull/8652)
|
|
5
163
|
- ci(): Removed the browser publish script [#8656](https://github.com/fabricjs/fabric.js/pull/8656)
|
|
6
164
|
- feat(): Node entry point [#8632](https://github.com/fabricjs/fabric.js/pull/8632)
|
|
7
165
|
- chore(): Change import and export strategy [#8622](https://github.com/fabricjs/fabric.js/pull/8622)
|
package/CONTRIBUTING.md
CHANGED
|
@@ -62,12 +62,14 @@ Answering questions and addressing issues, as well as fixing and adding types (s
|
|
|
62
62
|
- [Issues][issues]
|
|
63
63
|
- [Discussions][discussions]
|
|
64
64
|
|
|
65
|
-
### 🎮 Adding a DEMO
|
|
65
|
+
### 🎮 Adding a DEMO (currently not possible)
|
|
66
|
+
|
|
67
|
+
**New website is under construction. Contributions are welcome.**
|
|
66
68
|
|
|
67
69
|
Take a look at an existing [demo file][demo_file].\
|
|
68
70
|
Create a new file in the same directory (`posts/demos/_posts`) and follow [**developing the website**](#fabricjscom-deprecated).
|
|
69
71
|
|
|
70
|
-
### ~~`fabricjs.com`~~ (
|
|
72
|
+
### ~~`fabricjs.com`~~ (currently not possible)
|
|
71
73
|
|
|
72
74
|
To develop fabric's site you need to clone [`fabricjs.com`][website_repo] in the same parent folder of [`fabric.js`][repo], so that `fabric.js` and `fabricjs.com` are siblings.
|
|
73
75
|
|
|
@@ -91,25 +93,29 @@ Fabric is an open source project 🦄 and as such depends on the **genuine effor
|
|
|
91
93
|
|
|
92
94
|
- Read this section through.
|
|
93
95
|
- Take a look at [**GOTCHAS**][gotchas]
|
|
94
|
-
- Follow [Developing](#-developing-) and
|
|
96
|
+
- Follow [Developing](#-developing-) and [Testing](#-testing).
|
|
95
97
|
|
|
96
98
|
### ✅ Guidelines
|
|
97
99
|
|
|
100
|
+
- **Be patient** \
|
|
101
|
+
Sometimes it takes time to get back to you. Someone eventually will. Having a small, concise and super clear change will make maintainers more prone to handle it quickly.
|
|
98
102
|
- **Code Style** \
|
|
99
103
|
Fabric uses [`prettier`][prettier] to format files and [`eslint`][eslint] for linting (`npm run lint -- --fix`).\
|
|
100
104
|
To enjoy a seamless dev experience add the [`Prettier - Code formatter`][prettier_extension] extension via the extensions toolbar in VSCode.
|
|
101
|
-
|
|
102
|
-
|
|
105
|
+
If that doesn't work, once the PR is ready run `npm run prettier:write` and commit the changes.
|
|
106
|
+
Do not reorder imports. Irrelevant changes in a PR that are not created by prettier aren't needed nor welcome.
|
|
103
107
|
- **Tests** \
|
|
104
|
-
PRs must be backed with relevant tests, follow [TESTING](#-testing).
|
|
108
|
+
PRs must be backed with relevant tests, follow [TESTING](#-testing). If you never wrote a test or you find our tests unclear to extend, just ask for help.
|
|
109
|
+
Aim to cover 100% of the changes.
|
|
105
110
|
- **Docs** \
|
|
106
111
|
Add relevant comments to your code if necessary using [JSDoc 3][jsdoc] and update relevant guides.\
|
|
107
112
|
The generated documentation can be found at [fabricjs.com][docs], see [DOCS](#-improving-docs).
|
|
108
113
|
- **Changelog**\
|
|
109
|
-
Add a concise listing to the [**CHANGELOG**](CHANGELOG.md) describing what has changed.
|
|
114
|
+
Add a concise listing to the [**CHANGELOG**](CHANGELOG.md) describing what has changed or let github actions add the PR title for you.
|
|
110
115
|
- **1️⃣ PR per feature/bug** \
|
|
111
116
|
Create a new branch for every pull request.\
|
|
112
117
|
If you want to do more than one thing, create multiple pull requests 💪.
|
|
118
|
+
If your bug fix or feature requires a refactor, don't refactor. Commit the bugfix or the feature with the current code structure, let it sink, give some time to surface issues with the change, then when the bug or the feature seem solid, a refactor or code improvement can be tried
|
|
113
119
|
- **And there you go!** \
|
|
114
120
|
If you still have questions we're always happy to help.
|
|
115
121
|
|
|
@@ -122,108 +128,110 @@ It is more than likely you will be requested to change stuff and refine your wor
|
|
|
122
128
|
[](../../actions/workflows/tests.yml)
|
|
123
129
|
[](../../actions/workflows/codeql-analysis.yml)
|
|
124
130
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
-
|
|
133
|
-
|
|
134
|
-
```bash
|
|
135
|
-
|
|
136
|
-
npm run build -- -f -w
|
|
137
|
-
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
- run tests:
|
|
141
|
-
|
|
142
|
-
```bash
|
|
143
|
-
|
|
144
|
-
npm test -- -a -d
|
|
145
|
-
> Running all tests in debug mode (read more in the help section)
|
|
146
|
-
|
|
147
|
-
npm test -- -s visual --dev -l -c chrome
|
|
148
|
-
> Running live visual tests on chrome (navigate to see)
|
|
131
|
+
| Suite | unit (node) | e2e (browser) |
|
|
132
|
+
| ---------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
133
|
+
| Framework | [`jest`][jest] | [`playwright`][playwright] |
|
|
134
|
+
| Setup | | <pre>npm run build -- -f -w</pre> |
|
|
135
|
+
| Running Tests<br><br><br><br><br><pre>\<test cmd\> -- [filter] [watch]</pre> | <pre>npm run test:jest -- [filters] [-w]</pre><br><br><br>It is advised to use filters to save time.<br> | <pre>npm run test:e2e -- [filters] [--ui]</pre><br>In some machines babel is flaky and doesn't build the test files. In that is the case, try running the command using `npx` directly, see [`playwright.setup.ts`](./playwright.setup.ts). |
|
|
136
|
+
| Writing Tests | Add/update `src/*.(spec\|test).ts` files | - Update tests in `e2e/tests`<br>- Create a new test based on `e2e/template` |
|
|
137
|
+
| Test Gen | | <pre>npm start vanilla<br>npx playwright codegen http://localhost:1234</pre> |
|
|
138
|
+
| Test Spec | | - `index.ts`: built and loaded into the web app<br> - `index.spec.ts`: test spec<br> |
|
|
139
|
+
| Outputs | Snapshots next to the test file | - Snapshots next to the test file <br>- `e2e/test-report`<br>- `e2e/test-results` |
|
|
149
140
|
|
|
150
|
-
|
|
141
|
+
### Legacy Test Suite
|
|
151
142
|
|
|
152
|
-
|
|
143
|
+
We **discourage** writing new tests in the legacy suite and **encourage** migrating failing tests to the new suite.
|
|
144
|
+
However, it is not carved in stone.
|
|
153
145
|
|
|
154
|
-
|
|
146
|
+
The test suites use [`QUnit`][qunit] for assertions and [`testem`][testem] for serving the browser tests.
|
|
155
147
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
-
|
|
172
|
-
|
|
173
|
-
|
|
148
|
+
- `unit` tests: test logic and state
|
|
149
|
+
- `visual` tests: test visual outcome against image refs located at `test/visual/golden`
|
|
150
|
+
|
|
151
|
+
#### Getting Started
|
|
152
|
+
|
|
153
|
+
- Build and watch for changes
|
|
154
|
+
```bash
|
|
155
|
+
npm run build -- -f -w
|
|
156
|
+
```
|
|
157
|
+
- Run the _legacy_ test suite on `chrome` (many tests are skipped on `node`)
|
|
158
|
+
```bash
|
|
159
|
+
npm test -- -a -c chrome
|
|
160
|
+
```
|
|
161
|
+
- Handle failing tests
|
|
162
|
+
- Fix logic
|
|
163
|
+
- If needed, alter tests with **caution**
|
|
164
|
+
- Rerun failing tests
|
|
165
|
+
- Save time by rerunning failing tests only
|
|
166
|
+
- Select failing test files
|
|
167
|
+
```bash
|
|
168
|
+
npm test -- -c chrome
|
|
169
|
+
```
|
|
170
|
+
- **OR** launch the browser test suite in _dev mode_ to watch for test changes
|
|
171
|
+
```bash
|
|
172
|
+
npm test -- -c chrome --dev -l
|
|
173
|
+
```
|
|
174
|
+
- In case of failing visual tests, there are 2 options to view visual diffs (in order to understand what is wrong)
|
|
175
|
+
- Testing in _visual debug mode_ is comfortable when using with `Github Desktop` to view the diffs since refs will be overwritten (rerunning tests will use the overwritten refs so be cautious)
|
|
176
|
+
```bash
|
|
177
|
+
npm test -- -d -c chrome
|
|
178
|
+
```
|
|
179
|
+
- Launching the browser test suite
|
|
180
|
+
```bash
|
|
181
|
+
npm test -- -c chrome --dev -l
|
|
182
|
+
```
|
|
183
|
+
- Take into account that different environments produce different outputs so it is advised to run both in `chrome` and `node`.
|
|
184
|
+
- Committing refs is done **ONLY** with `chrome` output.
|
|
185
|
+
- When you are done, rerun the entire test suit to verify all tests pass.
|
|
186
|
+
- If you are submitting a PR, visit the PR page on github to see all checks have passed (different platforms and config are covered by the checks).
|
|
187
|
+
- Refer to the command docs
|
|
188
|
+
```bash
|
|
189
|
+
npm test -- -h
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
#### Adding Tests
|
|
193
|
+
|
|
194
|
+
Add tests to relevant files or add new files when necessary under `test/unit` or `test/visual`.
|
|
195
|
+
|
|
196
|
+
- [`unit` test example][unit_test]
|
|
197
|
+
- [`visual` test example][visual_test]
|
|
198
|
+
|
|
199
|
+
If you need to change test config ask for guidance.
|
|
174
200
|
|
|
175
201
|
---
|
|
176
202
|
|
|
177
203
|
## 🚧🎢 Developing 💡✨
|
|
178
204
|
|
|
179
|
-
###
|
|
205
|
+
### Getting Started
|
|
180
206
|
|
|
181
|
-
1. 🍴 Fork the repository
|
|
182
|
-
1. 💾 Clone your 🍴 to your 💻
|
|
207
|
+
1. 🍴 Fork and clone 💾 the repository
|
|
183
208
|
1. Install dependencies 🕹️ `npm i --include=dev`
|
|
184
|
-
1. Next Up [Prototyping](#-prototyping) & [Testing](#-testing)
|
|
185
|
-
|
|
186
|
-
#### Online
|
|
187
|
-
|
|
188
|
-
[](https://gitpod.io/from-referrer/)
|
|
189
|
-
|
|
190
|
-
Gitpod will start the [prototyping](#-prototyping) apps and expose them as endpoints.
|
|
191
|
-
`A service is available on port ...` popups will show up.
|
|
192
|
-
|
|
193
|
-
### 🧭 Prototyping
|
|
194
209
|
|
|
195
|
-
|
|
210
|
+
### Starting an App
|
|
196
211
|
|
|
197
212
|
```bash
|
|
213
|
+
npm start <template>
|
|
214
|
+
npm start -- --help
|
|
215
|
+
```
|
|
198
216
|
|
|
199
|
-
|
|
200
|
-
> building next app at /path/to/sandbox
|
|
201
|
-
|
|
202
|
-
npm run sandbox start </path/to/sandbox>
|
|
203
|
-
> starting dev server
|
|
204
|
-
|
|
205
|
-
npm run sandbox deploy </path/to/sandbox>
|
|
206
|
-
> created codesandbox https://codesandbox.io/s/fgh476
|
|
207
|
-
|
|
208
|
-
npm run sandbox deploy -- --template node
|
|
209
|
-
> created codesandbox https://codesandbox.io/s/fgh476
|
|
217
|
+
You can deploy an app to codesandbox via the cli or build an app at a path of your choosing:
|
|
210
218
|
|
|
219
|
+
```bash
|
|
220
|
+
npm run sandbox deploy <path/to/app>
|
|
221
|
+
npm run sandbox build <template> <path/to/app>
|
|
211
222
|
npm run sandbox -- --help
|
|
223
|
+
```
|
|
212
224
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
> sandbox commands
|
|
225
|
+
Refer to [`.codesandbox/README.md`](.codesandbox/README.md) for more information.
|
|
216
226
|
|
|
217
|
-
|
|
218
|
-
-h, --help display help for command
|
|
227
|
+
### Online
|
|
219
228
|
|
|
220
|
-
|
|
221
|
-
deploy [options] [path] deploy a sandbox to codesandbox
|
|
222
|
-
build <template> [destination] build and start a sandbox
|
|
223
|
-
start <path> start a sandbox
|
|
224
|
-
help [command] display help for command
|
|
229
|
+
You can actively develop fabric online using [Github Codespaces][github_codespaces], [Gitpod][gitpod] or CodeSandbox:
|
|
225
230
|
|
|
226
|
-
|
|
231
|
+
- After the Github Codespace has started run `npm start <template>` to start a prototyping app.
|
|
232
|
+
- Gitpod will start the prototyping apps and expose them as endpoints available on forwarded ports.
|
|
233
|
+
`A service is available on port ...` popups will show up.
|
|
234
|
+
- Codesandbox: _available soon_.
|
|
227
235
|
|
|
228
236
|
### 🔮 Symlinking
|
|
229
237
|
|
|
@@ -231,6 +239,7 @@ Establish symlinking to work with a local version on separate projects.
|
|
|
231
239
|
|
|
232
240
|
1. From `fabric.js` folder run `npm link` **OR** `yarn link`.
|
|
233
241
|
1. From the project's folder run `npm link fabric` **OR** `yarn link fabric`.
|
|
242
|
+
1. Consider flagging `--save` to avoid confusion regarding what version of fabric is being used by the project.
|
|
234
243
|
|
|
235
244
|
See [npm link][npm_link] **OR** [yarn link][yarn_link].\
|
|
236
245
|
Don't forget to unlink the package once you're done.
|
|
@@ -254,7 +263,13 @@ Don't forget to unlink the package once you're done.
|
|
|
254
263
|
[prettier_extension]: https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode
|
|
255
264
|
[eslint]: https://eslint.org/
|
|
256
265
|
[jsdoc]: https://jsdoc.app/
|
|
266
|
+
[playwright]: https://playwright.dev/
|
|
267
|
+
[jest]: https://jestjs.io/
|
|
257
268
|
[qunit]: https://qunitjs.com/
|
|
258
269
|
[testem]: https://github.com/testem/testem
|
|
270
|
+
[unit_test]: https://github.com/fabricjs/fabric.js/blob/93dd2dcca705a4b481fbc9982da4952ef5b4ed1d/test/unit/point.js#L227-L237
|
|
271
|
+
[visual_test]: https://github.com/fabricjs/fabric.js/blob/93dd2dcca705a4b481fbc9982da4952ef5b4ed1d/test/visual/generic_rendering.js#L44-L67
|
|
272
|
+
[github_codespaces]: https://github.com/codespaces/new?hide_repo_select=true&ref=master&repo=712530
|
|
273
|
+
[gitpod]: https://gitpod.io/from-referrer/
|
|
259
274
|
[npm_link]: https://docs.npmjs.com/cli/v8/commands/npm-link
|
|
260
275
|
[yarn_link]: https://yarnpkg.com/cli/link
|
package/README.md
CHANGED
|
@@ -42,7 +42,7 @@ A **simple and powerful Javascript HTML5 canvas library**.
|
|
|
42
42
|
- Out of the box interactions such as scale, move, rotate, skew, group...
|
|
43
43
|
- Built in shapes, controls, animations, image filters, gradients, patterns, brushes...
|
|
44
44
|
- `JPG`, `PNG`, `JSON` and `SVG` i/o
|
|
45
|
-
- Typed and modular
|
|
45
|
+
- [Typed and modular](#migrating-to-v6)
|
|
46
46
|
- [Unit tested](CONTRIBUTING.md#%F0%9F%A7%AA%20testing)
|
|
47
47
|
|
|
48
48
|
#### Supported Browsers/Environments
|
|
@@ -60,20 +60,23 @@ A **simple and powerful Javascript HTML5 canvas library**.
|
|
|
60
60
|
|
|
61
61
|
Fabric.js Does not use transpilation by default, the browser version we support is determined by the level of canvas api we want to use and some js syntax. While JS can be easily transpiled, canvas API can't.
|
|
62
62
|
|
|
63
|
-
##
|
|
63
|
+
## Migrating to v6
|
|
64
|
+
|
|
65
|
+
v6 is a **MAJOR** effort including migrating to TS and es6, countless fixes, rewrites and features.\
|
|
66
|
+
Currently in beta, refer to [#8299](../../issues/8299) for guidance.
|
|
64
67
|
|
|
65
68
|
```bash
|
|
66
|
-
$ npm install fabric --save
|
|
69
|
+
$ npm install fabric@beta --save
|
|
67
70
|
// or
|
|
68
|
-
$ yarn add fabric
|
|
71
|
+
$ yarn add fabric@beta
|
|
69
72
|
```
|
|
70
73
|
|
|
71
|
-
|
|
72
|
-
// es6 imports
|
|
73
|
-
import { fabric } from 'fabric';
|
|
74
|
+
## Installation
|
|
74
75
|
|
|
75
|
-
|
|
76
|
-
|
|
76
|
+
```bash
|
|
77
|
+
$ npm install fabric --save
|
|
78
|
+
// or
|
|
79
|
+
$ yarn add fabric
|
|
77
80
|
```
|
|
78
81
|
|
|
79
82
|
#### Browser
|
|
@@ -92,6 +95,15 @@ Follow these [instructions][node_canvas_install] to get `node-canvas` up and run
|
|
|
92
95
|
|
|
93
96
|
## Quick Start
|
|
94
97
|
|
|
98
|
+
```js
|
|
99
|
+
// v6
|
|
100
|
+
import { Canvas, Rect } from 'fabric'; // browser
|
|
101
|
+
import { StaticCanvas, Rect } from 'fabric/node'; // node
|
|
102
|
+
|
|
103
|
+
// v5
|
|
104
|
+
import { fabric } from 'fabric';
|
|
105
|
+
```
|
|
106
|
+
|
|
95
107
|
<details><summary><b>Plain HTML</b></summary>
|
|
96
108
|
|
|
97
109
|
```html
|
|
@@ -117,10 +129,11 @@ Follow these [instructions][node_canvas_install] to get `node-canvas` up and run
|
|
|
117
129
|
|
|
118
130
|
```tsx
|
|
119
131
|
import React, { useEffect, useRef } from 'react';
|
|
120
|
-
import
|
|
132
|
+
import * as fabric from 'fabric'; // v6
|
|
133
|
+
import { fabric } from 'fabric'; // v5
|
|
121
134
|
|
|
122
135
|
export const FabricJSCanvas = () => {
|
|
123
|
-
const canvasEl = useRef(null);
|
|
136
|
+
const canvasEl = useRef<HTMLCanvasElement>(null);
|
|
124
137
|
useEffect(() => {
|
|
125
138
|
const options = { ... };
|
|
126
139
|
const canvas = new fabric.Canvas(canvasEl.current, options);
|
|
@@ -132,8 +145,8 @@ export const FabricJSCanvas = () => {
|
|
|
132
145
|
}
|
|
133
146
|
}, []);
|
|
134
147
|
|
|
135
|
-
return
|
|
136
|
-
}
|
|
148
|
+
return <canvas width="300" height="300" ref={canvasEl}/>;
|
|
149
|
+
};
|
|
137
150
|
|
|
138
151
|
```
|
|
139
152
|
|
|
@@ -142,8 +155,9 @@ export const FabricJSCanvas = () => {
|
|
|
142
155
|
<details><summary><b>Node.js</b></summary>
|
|
143
156
|
|
|
144
157
|
```js
|
|
145
|
-
|
|
146
|
-
|
|
158
|
+
import http from 'http';
|
|
159
|
+
import * as fabric from 'fabric/node'; // v6
|
|
160
|
+
import { fabric } from 'fabric'; // v5
|
|
147
161
|
|
|
148
162
|
const port = 8080;
|
|
149
163
|
|
|
@@ -177,6 +191,8 @@ http
|
|
|
177
191
|
|
|
178
192
|
</details>
|
|
179
193
|
|
|
194
|
+
See our ready to use [templates](./.codesandbox/templates/).
|
|
195
|
+
|
|
180
196
|
---
|
|
181
197
|
|
|
182
198
|
## Other Solutions
|
|
@@ -186,7 +202,6 @@ http
|
|
|
186
202
|
| [Three.js][three.js] | 3D graphics |
|
|
187
203
|
| [PixiJS][pixijs] | WebGL renderer |
|
|
188
204
|
| [Konva][konva] | Similar features | ❌ |
|
|
189
|
-
| [Canvas2PDF][canvas2pdf] | PDF renderer |
|
|
190
205
|
| [html-to-image][html-to-image] | HTML to image/canvas |
|
|
191
206
|
|
|
192
207
|
## More Resources
|
|
@@ -214,7 +229,6 @@ http
|
|
|
214
229
|
|
|
215
230
|
[asturur]: https://github.com/asturur
|
|
216
231
|
[asturur_twitter]: https://twitter.com/AndreaBogazzi
|
|
217
|
-
[canvas2pdf]: https://github.com/joshua-gould/canvas2pdf
|
|
218
232
|
[cdnjs]: https://cdnjs.com/libraries/fabric.js
|
|
219
233
|
[code_triage]: https://www.codetriage.com/kangax/fabric.js
|
|
220
234
|
[codepens]: https://codepen.io/tag/fabricjs
|