customized-fabric 1.7.4 → 1.7.5
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/ImagePlaceholderObject/index.d.ts +2 -0
- package/lib/ImagePlaceholderObject/index.js +9 -6
- package/lib/ImagePlaceholderObject/interfaces.d.ts +1 -0
- package/lib/utils/control.util.d.ts +1 -0
- package/lib/utils/control.util.js +14 -0
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/index.js +1 -10
- package/package.json +1 -1
|
@@ -18,6 +18,7 @@ export declare const toImagePlaceholderObject: (object: ImagePlaceholder) => {
|
|
|
18
18
|
removeBackground: boolean | undefined;
|
|
19
19
|
faceCutout: boolean | undefined;
|
|
20
20
|
advancedFilter: string | undefined;
|
|
21
|
+
objectFit: string | undefined;
|
|
21
22
|
};
|
|
22
23
|
};
|
|
23
24
|
export default class ImagePlaceholder extends fabric.Group {
|
|
@@ -37,6 +38,7 @@ export default class ImagePlaceholder extends fabric.Group {
|
|
|
37
38
|
layoutGroupId?: string;
|
|
38
39
|
layoutGroupName?: string;
|
|
39
40
|
advancedFilter?: string;
|
|
41
|
+
objectFit?: string;
|
|
40
42
|
getSettings?: (attribute: string) => any;
|
|
41
43
|
setSizes?: (options: {
|
|
42
44
|
width?: number;
|
|
@@ -32,6 +32,8 @@ const ImagePlaceholderClass = fabric_1.fabric.util.createClass(fabric_1.fabric.G
|
|
|
32
32
|
layerId: options?.personalizeId ?? options?.layerId,
|
|
33
33
|
imageType: "Full color",
|
|
34
34
|
objectCaching: false,
|
|
35
|
+
objectFit: "cover",
|
|
36
|
+
clipPath: this.rectObject,
|
|
35
37
|
});
|
|
36
38
|
if (options?.isOriginal) {
|
|
37
39
|
this.rectObject?.set({ strokeWidth: 0 });
|
|
@@ -50,14 +52,14 @@ const ImagePlaceholderClass = fabric_1.fabric.util.createClass(fabric_1.fabric.G
|
|
|
50
52
|
}
|
|
51
53
|
}
|
|
52
54
|
if (options?.imageSettings) {
|
|
53
|
-
const { type, color, removeBackground, faceCutout, advancedFilter } = options?.imageSettings;
|
|
55
|
+
const { type, color, removeBackground, faceCutout, advancedFilter, objectFit, } = options?.imageSettings;
|
|
54
56
|
if (type) {
|
|
55
57
|
this.setImageType(type);
|
|
56
58
|
}
|
|
57
59
|
if (color) {
|
|
58
60
|
this.setImageColor(color);
|
|
59
61
|
}
|
|
60
|
-
this.set({ removeBackground, faceCutout, advancedFilter });
|
|
62
|
+
this.set({ removeBackground, faceCutout, advancedFilter, objectFit });
|
|
61
63
|
}
|
|
62
64
|
},
|
|
63
65
|
loadImage: async function (image) {
|
|
@@ -70,7 +72,7 @@ const ImagePlaceholderClass = fabric_1.fabric.util.createClass(fabric_1.fabric.G
|
|
|
70
72
|
this.remove(this.imageObject);
|
|
71
73
|
this.imageObject = loadedImage;
|
|
72
74
|
this.add(this.imageObject);
|
|
73
|
-
this.fitImage(this.imageObject);
|
|
75
|
+
this.fitImage(this.imageObject, this.objectFit == "cover");
|
|
74
76
|
this.applyImageFilters(this.imageObject);
|
|
75
77
|
this.canvas?.renderAll();
|
|
76
78
|
}
|
|
@@ -93,7 +95,7 @@ const ImagePlaceholderClass = fabric_1.fabric.util.createClass(fabric_1.fabric.G
|
|
|
93
95
|
scaleX: this.width / this.maskObject.width,
|
|
94
96
|
scaleY: this.height / this.maskObject.height,
|
|
95
97
|
});
|
|
96
|
-
this.fitImage(this.imageObject);
|
|
98
|
+
this.fitImage(this.imageObject, this.objectFit == "cover");
|
|
97
99
|
this.canvas?.renderAll?.();
|
|
98
100
|
},
|
|
99
101
|
fitImage: function (image, cover = false) {
|
|
@@ -136,7 +138,7 @@ const ImagePlaceholderClass = fabric_1.fabric.util.createClass(fabric_1.fabric.G
|
|
|
136
138
|
if (index >= 0) {
|
|
137
139
|
canvas.insertAt(loadedImage, index, false);
|
|
138
140
|
}
|
|
139
|
-
this.fitImage(this.uploadedImage,
|
|
141
|
+
this.fitImage(this.uploadedImage, this.objectFit == "cover");
|
|
140
142
|
this.applyImageFilters(this.uploadedImage);
|
|
141
143
|
canvas?.renderAll();
|
|
142
144
|
}
|
|
@@ -200,7 +202,7 @@ const ImagePlaceholderClass = fabric_1.fabric.util.createClass(fabric_1.fabric.G
|
|
|
200
202
|
}
|
|
201
203
|
},
|
|
202
204
|
removeMask: async function () {
|
|
203
|
-
this.set({ clipPath:
|
|
205
|
+
this.set({ clipPath: this.rectObject, maskUrl: undefined });
|
|
204
206
|
this.remove(this.maskObject);
|
|
205
207
|
this.maskObject = undefined;
|
|
206
208
|
this.canvas?.renderAll();
|
|
@@ -307,6 +309,7 @@ const toImagePlaceholderObject = (object) => {
|
|
|
307
309
|
removeBackground: object?.removeBackground,
|
|
308
310
|
faceCutout: object?.faceCutout,
|
|
309
311
|
advancedFilter: object?.advancedFilter,
|
|
312
|
+
objectFit: object?.objectFit,
|
|
310
313
|
},
|
|
311
314
|
};
|
|
312
315
|
};
|
|
@@ -58,6 +58,7 @@ export interface IImagePlaceholderOptions extends fabric.IGroupOptions {
|
|
|
58
58
|
removeBackground?: boolean;
|
|
59
59
|
faceCutout?: boolean;
|
|
60
60
|
advancedFilter?: string;
|
|
61
|
+
objectFit?: string;
|
|
61
62
|
};
|
|
62
63
|
}
|
|
63
64
|
export declare type ImageFilterType = "Full color" | "Grayscale" | "Blend color";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const fabric_1 = require("fabric");
|
|
4
|
+
const constants_1 = require("../constants");
|
|
5
|
+
fabric_1.fabric.Object.prototype.transparentCorners = false;
|
|
6
|
+
fabric_1.fabric.Object.prototype.cornerColor = "transparent";
|
|
7
|
+
fabric_1.fabric.Object.prototype.cornerStyle = "circle";
|
|
8
|
+
fabric_1.fabric.Object.prototype.cornerStrokeColor = "#3b75cf";
|
|
9
|
+
fabric_1.fabric.Object.prototype.borderColor = "#3b75cf";
|
|
10
|
+
fabric_1.fabric.Group.prototype.originX = "center";
|
|
11
|
+
fabric_1.fabric.Group.prototype.originY = "center";
|
|
12
|
+
fabric_1.fabric.ActiveSelection.prototype.originX = "center";
|
|
13
|
+
fabric_1.fabric.ActiveSelection.prototype.originY = "center";
|
|
14
|
+
fabric_1.fabric.textureSize = constants_1.MAX_TEXTURE_SIZE;
|
package/lib/utils/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import ImagePlaceholder from "../ImagePlaceholderObject";
|
|
|
4
4
|
import TextInput from "../TextInputObject";
|
|
5
5
|
import { ImageFilterType } from "../ImagePlaceholderObject/interfaces";
|
|
6
6
|
import CurvedText from "../CurvedTextObject";
|
|
7
|
+
import "./control.util";
|
|
7
8
|
export declare const loadFontFromUrl: (url: string, name: string) => Promise<void>;
|
|
8
9
|
export declare const isFontLoaded: (name: string) => boolean;
|
|
9
10
|
export declare const loadImageFromFile: (image: File) => Promise<fabric.Image>;
|
package/lib/utils/index.js
CHANGED
|
@@ -30,6 +30,7 @@ const ClipartObject_1 = __importStar(require("../ClipartObject"));
|
|
|
30
30
|
const ImagePlaceholderObject_1 = __importStar(require("../ImagePlaceholderObject"));
|
|
31
31
|
const TextInputObject_1 = __importStar(require("../TextInputObject"));
|
|
32
32
|
const CurvedTextObject_1 = __importStar(require("../CurvedTextObject"));
|
|
33
|
+
require("./control.util");
|
|
33
34
|
const loadFontFromUrl = async (url, name) => {
|
|
34
35
|
if (!name || !url)
|
|
35
36
|
return;
|
|
@@ -205,16 +206,6 @@ const asyncGetObject = async (object, options) => {
|
|
|
205
206
|
}
|
|
206
207
|
};
|
|
207
208
|
exports.asyncGetObject = asyncGetObject;
|
|
208
|
-
fabric_1.fabric.Object.prototype.transparentCorners = false;
|
|
209
|
-
fabric_1.fabric.Object.prototype.cornerColor = "transparent";
|
|
210
|
-
fabric_1.fabric.Object.prototype.cornerStyle = "circle";
|
|
211
|
-
fabric_1.fabric.Object.prototype.cornerStrokeColor = "#3b75cf";
|
|
212
|
-
fabric_1.fabric.Object.prototype.borderColor = "#3b75cf";
|
|
213
|
-
fabric_1.fabric.Group.prototype.originX = "center";
|
|
214
|
-
fabric_1.fabric.Group.prototype.originY = "center";
|
|
215
|
-
fabric_1.fabric.ActiveSelection.prototype.originX = "center";
|
|
216
|
-
fabric_1.fabric.ActiveSelection.prototype.originY = "center";
|
|
217
|
-
fabric_1.fabric.textureSize = constants_1.MAX_TEXTURE_SIZE;
|
|
218
209
|
fabric_1.fabric.Object.prototype.toObject = (function (toObject) {
|
|
219
210
|
return function () {
|
|
220
211
|
switch (this.type) {
|