customized-fabric 1.6.6 → 1.6.8
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/lib/ClipartObject/constants.js +2 -2
- package/lib/CurvedTextObject/constants.js +2 -2
- package/lib/ImagePlaceholderObject/constants.js +2 -2
- package/lib/ImagePlaceholderObject/index.d.ts +1 -0
- package/lib/ImagePlaceholderObject/index.js +12 -5
- package/lib/TextInputObject/constants.js +2 -2
- package/lib/utils/index.js +2 -2
- package/package.json +1 -1
| @@ -6,9 +6,9 @@ exports.CURVED_TEXT_OBJECT_ATTRIBUTES = { | |
| 6 6 | 
             
                type: "CURVED_TEXT",
         | 
| 7 7 | 
             
                maxFontSize: 200,
         | 
| 8 8 | 
             
                stroke: {
         | 
| 9 | 
            -
                    stroke: "# | 
| 9 | 
            +
                    stroke: "#333",
         | 
| 10 10 | 
             
                    strokeDashArray: [5, 5],
         | 
| 11 | 
            -
                    strokeWidth:  | 
| 11 | 
            +
                    strokeWidth: 1,
         | 
| 12 12 | 
             
                },
         | 
| 13 13 | 
             
            };
         | 
| 14 14 | 
             
            exports.PARENT_ATTRIBUTES = ["top", "left", "width", "height", "angle"];
         | 
| @@ -5,9 +5,9 @@ exports.IMAGE_PLACEHOLDER_OBJECT_ATTRIBUTES = { | |
| 5 5 | 
             
                name: "Image placeholder",
         | 
| 6 6 | 
             
                type: "IMAGE_PLACEHOLDER",
         | 
| 7 7 | 
             
                stroke: {
         | 
| 8 | 
            -
                    stroke: "# | 
| 8 | 
            +
                    stroke: "#333",
         | 
| 9 9 | 
             
                    strokeDashArray: [5, 5],
         | 
| 10 | 
            -
                    strokeWidth:  | 
| 10 | 
            +
                    strokeWidth: 1,
         | 
| 11 11 | 
             
                },
         | 
| 12 12 | 
             
            };
         | 
| 13 13 | 
             
            exports.IMAGE_FILTER_TYPES = {
         | 
| @@ -50,5 +50,6 @@ export default class ImagePlaceholder extends fabric.Group { | |
| 50 50 | 
             
                setImageType?: (type: ImageFilterType) => void;
         | 
| 51 51 | 
             
                setImageColor?: (color: string) => void;
         | 
| 52 52 | 
             
                applyImageFilters?: (image: fabric.Image | undefined) => void;
         | 
| 53 | 
            +
                fitImage?: (image: fabric.Image, cover?: boolean) => void;
         | 
| 53 54 | 
             
                constructor(options?: IImagePlaceholderOptions);
         | 
| 54 55 | 
             
            }
         | 
| @@ -96,13 +96,20 @@ const ImagePlaceholderClass = fabric_1.fabric.util.createClass(fabric_1.fabric.G | |
| 96 96 | 
             
                    this.fitImage(this.imageObject);
         | 
| 97 97 | 
             
                    this.canvas?.renderAll?.();
         | 
| 98 98 | 
             
                },
         | 
| 99 | 
            -
                fitImage: function (image) {
         | 
| 99 | 
            +
                fitImage: function (image, cover = false) {
         | 
| 100 100 | 
             
                    if (image) {
         | 
| 101 101 | 
             
                        const imageScaleX = this.width / (image?.width ?? 1);
         | 
| 102 102 | 
             
                        const imageScaleY = this.height / (image?.height ?? 1);
         | 
| 103 | 
            -
                         | 
| 104 | 
            -
                             | 
| 105 | 
            -
             | 
| 103 | 
            +
                        if (cover) {
         | 
| 104 | 
            +
                            imageScaleX < imageScaleY
         | 
| 105 | 
            +
                                ? image.set({ scaleX: imageScaleY, scaleY: imageScaleY })
         | 
| 106 | 
            +
                                : image.set({ scaleX: imageScaleX, scaleY: imageScaleX });
         | 
| 107 | 
            +
                        }
         | 
| 108 | 
            +
                        else {
         | 
| 109 | 
            +
                            imageScaleX > imageScaleY
         | 
| 110 | 
            +
                                ? image.set({ scaleX: imageScaleY, scaleY: imageScaleY })
         | 
| 111 | 
            +
                                : image.set({ scaleX: imageScaleX, scaleY: imageScaleX });
         | 
| 112 | 
            +
                        }
         | 
| 106 113 | 
             
                    }
         | 
| 107 114 | 
             
                },
         | 
| 108 115 | 
             
                getSettings: function (attribute) {
         | 
| @@ -128,7 +135,7 @@ const ImagePlaceholderClass = fabric_1.fabric.util.createClass(fabric_1.fabric.G | |
| 128 135 | 
             
                        if (index >= 0) {
         | 
| 129 136 | 
             
                            canvas.insertAt(loadedImage, index, false);
         | 
| 130 137 | 
             
                        }
         | 
| 131 | 
            -
                        this.fitImage(this.uploadedImage);
         | 
| 138 | 
            +
                        this.fitImage(this.uploadedImage, true);
         | 
| 132 139 | 
             
                        this.applyImageFilters(this.uploadedImage);
         | 
| 133 140 | 
             
                        canvas?.renderAll();
         | 
| 134 141 | 
             
                    }
         | 
| @@ -6,9 +6,9 @@ exports.TEXT_INPUT_OBJECT_ATTRIBUTES = { | |
| 6 6 | 
             
                type: "TEXT_INPUT",
         | 
| 7 7 | 
             
                maxFontSize: 200,
         | 
| 8 8 | 
             
                stroke: {
         | 
| 9 | 
            -
                    stroke: "# | 
| 9 | 
            +
                    stroke: "#333",
         | 
| 10 10 | 
             
                    strokeDashArray: [5, 5],
         | 
| 11 | 
            -
                    strokeWidth:  | 
| 11 | 
            +
                    strokeWidth: 1,
         | 
| 12 12 | 
             
                },
         | 
| 13 13 | 
             
            };
         | 
| 14 14 | 
             
            exports.PARENT_ATTRIBUTES = ["top", "left", "width", "height", "angle"];
         | 
    
        package/lib/utils/index.js
    CHANGED
    
    | @@ -211,8 +211,8 @@ exports.asyncGetObject = asyncGetObject; | |
| 211 211 | 
             
            fabric_1.fabric.Object.prototype.transparentCorners = false;
         | 
| 212 212 | 
             
            fabric_1.fabric.Object.prototype.cornerColor = "transparent";
         | 
| 213 213 | 
             
            fabric_1.fabric.Object.prototype.cornerStyle = "circle";
         | 
| 214 | 
            -
            fabric_1.fabric.Object.prototype.cornerStrokeColor = " | 
| 215 | 
            -
            fabric_1.fabric.Object.prototype.borderColor = " | 
| 214 | 
            +
            fabric_1.fabric.Object.prototype.cornerStrokeColor = "#3b75cf";
         | 
| 215 | 
            +
            fabric_1.fabric.Object.prototype.borderColor = "#3b75cf";
         | 
| 216 216 | 
             
            fabric_1.fabric.Group.prototype.originX = "center";
         | 
| 217 217 | 
             
            fabric_1.fabric.Group.prototype.originY = "center";
         | 
| 218 218 | 
             
            fabric_1.fabric.ActiveSelection.prototype.originX = "center";
         |