customized-fabric 1.3.5 → 1.3.7
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/ClipartObject/index.js +4 -1
- package/lib/ClipartObject/interfaces.d.ts +1 -0
- package/lib/ImagePlaceholderObject/index.js +22 -17
- package/lib/ImagePlaceholderObject/interfaces.d.ts +1 -0
- package/lib/TextInputObject/index.js +4 -1
- package/lib/TextInputObject/interfaces.d.ts +1 -0
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/index.js +3 -6
- package/package.json +1 -1
@@ -48,9 +48,12 @@ const ClipartClass = fabric_1.fabric.util.createClass(fabric_1.fabric.Group, {
|
|
48
48
|
objectCaching: false,
|
49
49
|
});
|
50
50
|
if (options?.isOriginal) {
|
51
|
-
this.rectObject
|
51
|
+
this.rectObject?.set({ strokeWidth: 0 });
|
52
52
|
}
|
53
53
|
else {
|
54
|
+
if (options?.hideStroke) {
|
55
|
+
this.rectObject?.set({ strokeWidth: 0 });
|
56
|
+
}
|
54
57
|
if (options?.clipartFile || options?.clipartUrl) {
|
55
58
|
this.loadImage(options?.clipartFile ?? options.clipartUrl);
|
56
59
|
}
|
@@ -33,15 +33,20 @@ const ImagePlaceholderClass = fabric_1.fabric.util.createClass(fabric_1.fabric.G
|
|
33
33
|
imageType: "Full color",
|
34
34
|
objectCaching: false,
|
35
35
|
});
|
36
|
-
if (options?.imageFile) {
|
37
|
-
this.loadImage(options?.imageFile);
|
38
|
-
}
|
39
36
|
if (options?.isOriginal) {
|
40
|
-
this.rectObject
|
37
|
+
this.rectObject?.set({ strokeWidth: 0 });
|
41
38
|
}
|
42
39
|
else {
|
43
|
-
if (options?.
|
44
|
-
this.
|
40
|
+
if (options?.hideStroke) {
|
41
|
+
this.rectObject?.set({ strokeWidth: 0 });
|
42
|
+
}
|
43
|
+
else {
|
44
|
+
if (options?.maskFile || options?.maskUrl) {
|
45
|
+
this.loadMask(options?.maskFile ?? options?.maskUrl);
|
46
|
+
}
|
47
|
+
}
|
48
|
+
if (options?.imageFile) {
|
49
|
+
this.loadImage(options?.imageFile);
|
45
50
|
}
|
46
51
|
}
|
47
52
|
if (options?.imageType) {
|
@@ -175,14 +180,14 @@ const ImagePlaceholderClass = fabric_1.fabric.util.createClass(fabric_1.fabric.G
|
|
175
180
|
this.canvas?.renderAll();
|
176
181
|
},
|
177
182
|
getMask: async function () {
|
178
|
-
if (this.
|
179
|
-
return this.
|
183
|
+
if (this.mask) {
|
184
|
+
return this.mask;
|
180
185
|
}
|
181
186
|
if (this?.maskUrl) {
|
182
|
-
const
|
183
|
-
|
184
|
-
scaleX: this.width / (
|
185
|
-
scaleY: this.height / (
|
187
|
+
const mask = await (0, utils_1.loadImageFromUrl)(this.maskUrl);
|
188
|
+
mask?.set({
|
189
|
+
scaleX: this.width / (mask?.width ?? this.width),
|
190
|
+
scaleY: this.height / (mask?.height ?? this.height),
|
186
191
|
absolutePositioned: true,
|
187
192
|
originX: "center",
|
188
193
|
originY: "center",
|
@@ -190,11 +195,11 @@ const ImagePlaceholderClass = fabric_1.fabric.util.createClass(fabric_1.fabric.G
|
|
190
195
|
left: this.left,
|
191
196
|
angle: this.angle,
|
192
197
|
});
|
193
|
-
this.
|
194
|
-
return
|
198
|
+
this.mask = mask;
|
199
|
+
return mask;
|
195
200
|
}
|
196
201
|
else {
|
197
|
-
const
|
202
|
+
const mask = new fabric_1.fabric.Rect({
|
198
203
|
width: this.width,
|
199
204
|
height: this.height,
|
200
205
|
scaleX: this.scaleX,
|
@@ -206,8 +211,8 @@ const ImagePlaceholderClass = fabric_1.fabric.util.createClass(fabric_1.fabric.G
|
|
206
211
|
left: this.left,
|
207
212
|
angle: this.angle,
|
208
213
|
});
|
209
|
-
this.
|
210
|
-
return
|
214
|
+
this.mask = mask;
|
215
|
+
return mask;
|
211
216
|
}
|
212
217
|
},
|
213
218
|
loadCustomizedImage: async function (image) {
|
@@ -56,9 +56,12 @@ const TextInputClass = fabric_1.fabric.util.createClass(fabric_1.fabric.Group, {
|
|
56
56
|
width: this.width,
|
57
57
|
});
|
58
58
|
if (options?.isOriginal) {
|
59
|
-
this.rectObject
|
59
|
+
this.rectObject?.set({ strokeWidth: 0 });
|
60
60
|
}
|
61
61
|
else {
|
62
|
+
if (options?.hideStroke) {
|
63
|
+
this.rectObject?.set({ strokeWidth: 0 });
|
64
|
+
}
|
62
65
|
if (options?.fontUrl) {
|
63
66
|
(0, utils_1.loadFontFromUrl)(options?.fontUrl, text?.fontFamily ?? "").then(() => {
|
64
67
|
this.canvas?.renderAll?.();
|
package/lib/utils/index.d.ts
CHANGED
@@ -15,6 +15,7 @@ export declare const lockObject: (object: fabric.Object | any, locked: boolean,
|
|
15
15
|
export declare const lockAllObjects: (canvas: fabric.Canvas, locked: boolean, selectable?: boolean) => void;
|
16
16
|
export declare const getObject: (object: any, options?: {
|
17
17
|
isOriginal?: boolean;
|
18
|
+
hideStroke?: boolean;
|
18
19
|
}) => Clipart | ImagePlaceholder | TextInput | undefined;
|
19
20
|
export declare const asyncGetObject: (object: any, options?: {
|
20
21
|
isOriginal?: boolean;
|
package/lib/utils/index.js
CHANGED
@@ -130,24 +130,21 @@ const getObject = (object, options) => {
|
|
130
130
|
case constants_1.OBJECT_TYPES.textInput: {
|
131
131
|
const textInputObject = new TextInputObject_1.default({
|
132
132
|
...object,
|
133
|
-
|
133
|
+
...options,
|
134
134
|
});
|
135
135
|
return textInputObject;
|
136
136
|
}
|
137
137
|
case constants_1.OBJECT_TYPES.clipart: {
|
138
138
|
const clipartObject = new ClipartObject_1.default({
|
139
139
|
...object,
|
140
|
-
|
140
|
+
...options,
|
141
141
|
});
|
142
|
-
if (object?.clipartUrl) {
|
143
|
-
clipartObject?.loadImage?.(object?.clipartUrl);
|
144
|
-
}
|
145
142
|
return clipartObject;
|
146
143
|
}
|
147
144
|
case constants_1.OBJECT_TYPES.imagePlaceHolder: {
|
148
145
|
const imagePlaceHolderObject = new ImagePlaceholderObject_1.default({
|
149
146
|
...object,
|
150
|
-
|
147
|
+
...options,
|
151
148
|
});
|
152
149
|
return imagePlaceHolderObject;
|
153
150
|
}
|