customized-fabric 1.7.4 → 1.7.6
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/ImagePlaceholderObject/index.d.ts +2 -0
- package/lib/ImagePlaceholderObject/index.js +8 -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,7 @@ 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",
|
35
36
|
});
|
36
37
|
if (options?.isOriginal) {
|
37
38
|
this.rectObject?.set({ strokeWidth: 0 });
|
@@ -50,14 +51,14 @@ const ImagePlaceholderClass = fabric_1.fabric.util.createClass(fabric_1.fabric.G
|
|
50
51
|
}
|
51
52
|
}
|
52
53
|
if (options?.imageSettings) {
|
53
|
-
const { type, color, removeBackground, faceCutout, advancedFilter } = options?.imageSettings;
|
54
|
+
const { type, color, removeBackground, faceCutout, advancedFilter, objectFit = "cover", } = options?.imageSettings;
|
54
55
|
if (type) {
|
55
56
|
this.setImageType(type);
|
56
57
|
}
|
57
58
|
if (color) {
|
58
59
|
this.setImageColor(color);
|
59
60
|
}
|
60
|
-
this.set({ removeBackground, faceCutout, advancedFilter });
|
61
|
+
this.set({ removeBackground, faceCutout, advancedFilter, objectFit });
|
61
62
|
}
|
62
63
|
},
|
63
64
|
loadImage: async function (image) {
|
@@ -70,7 +71,7 @@ const ImagePlaceholderClass = fabric_1.fabric.util.createClass(fabric_1.fabric.G
|
|
70
71
|
this.remove(this.imageObject);
|
71
72
|
this.imageObject = loadedImage;
|
72
73
|
this.add(this.imageObject);
|
73
|
-
this.fitImage(this.imageObject);
|
74
|
+
this.fitImage(this.imageObject, this.objectFit == "cover");
|
74
75
|
this.applyImageFilters(this.imageObject);
|
75
76
|
this.canvas?.renderAll();
|
76
77
|
}
|
@@ -93,7 +94,7 @@ const ImagePlaceholderClass = fabric_1.fabric.util.createClass(fabric_1.fabric.G
|
|
93
94
|
scaleX: this.width / this.maskObject.width,
|
94
95
|
scaleY: this.height / this.maskObject.height,
|
95
96
|
});
|
96
|
-
this.fitImage(this.imageObject);
|
97
|
+
this.fitImage(this.imageObject, this.objectFit == "cover");
|
97
98
|
this.canvas?.renderAll?.();
|
98
99
|
},
|
99
100
|
fitImage: function (image, cover = false) {
|
@@ -136,7 +137,7 @@ const ImagePlaceholderClass = fabric_1.fabric.util.createClass(fabric_1.fabric.G
|
|
136
137
|
if (index >= 0) {
|
137
138
|
canvas.insertAt(loadedImage, index, false);
|
138
139
|
}
|
139
|
-
this.fitImage(this.uploadedImage,
|
140
|
+
this.fitImage(this.uploadedImage, this.objectFit == "cover");
|
140
141
|
this.applyImageFilters(this.uploadedImage);
|
141
142
|
canvas?.renderAll();
|
142
143
|
}
|
@@ -200,7 +201,7 @@ const ImagePlaceholderClass = fabric_1.fabric.util.createClass(fabric_1.fabric.G
|
|
200
201
|
}
|
201
202
|
},
|
202
203
|
removeMask: async function () {
|
203
|
-
this.set({ clipPath:
|
204
|
+
this.set({ clipPath: this.rectObject, maskUrl: undefined });
|
204
205
|
this.remove(this.maskObject);
|
205
206
|
this.maskObject = undefined;
|
206
207
|
this.canvas?.renderAll();
|
@@ -307,6 +308,7 @@ const toImagePlaceholderObject = (object) => {
|
|
307
308
|
removeBackground: object?.removeBackground,
|
308
309
|
faceCutout: object?.faceCutout,
|
309
310
|
advancedFilter: object?.advancedFilter,
|
311
|
+
objectFit: object?.objectFit,
|
310
312
|
},
|
311
313
|
};
|
312
314
|
};
|
@@ -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) {
|