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.
@@ -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.set({ strokeWidth: 0 });
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
  }
@@ -7,4 +7,5 @@ export interface IClipartOptions extends fabric.IGroupOptions {
7
7
  clipartFile?: File;
8
8
  isOriginal?: boolean;
9
9
  isAdditional?: boolean;
10
+ hideStroke?: boolean;
10
11
  }
@@ -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.set({ strokeWidth: 0 });
37
+ this.rectObject?.set({ strokeWidth: 0 });
41
38
  }
42
39
  else {
43
- if (options?.maskFile || options?.maskUrl) {
44
- this.loadMask(options?.maskFile ?? options?.maskUrl);
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.maskObject) {
179
- return this.maskObject;
183
+ if (this.mask) {
184
+ return this.mask;
180
185
  }
181
186
  if (this?.maskUrl) {
182
- const maskObject = await (0, utils_1.loadImageFromUrl)(this.maskUrl);
183
- maskObject?.set({
184
- scaleX: this.width / (maskObject?.width ?? this.width),
185
- scaleY: this.height / (maskObject?.height ?? 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.maskObject = maskObject;
194
- return maskObject;
198
+ this.mask = mask;
199
+ return mask;
195
200
  }
196
201
  else {
197
- const maskObject = new fabric_1.fabric.Rect({
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.maskObject = maskObject;
210
- return maskObject;
214
+ this.mask = mask;
215
+ return mask;
211
216
  }
212
217
  },
213
218
  loadCustomizedImage: async function (image) {
@@ -48,5 +48,6 @@ export interface IImagePlaceholderOptions extends fabric.IGroupOptions {
48
48
  image?: IImageOptions;
49
49
  maskUrl?: string;
50
50
  maskFile?: File;
51
+ hideStroke?: boolean;
51
52
  }
52
53
  export declare type ImageFilterType = "Full color" | "Grayscale" | "Blend color";
@@ -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.set({ strokeWidth: 0 });
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?.();
@@ -22,4 +22,5 @@ export interface ITextInputOptions extends fabric.IGroupOptions {
22
22
  fontUrl?: string;
23
23
  isOriginal?: boolean;
24
24
  isAdditional?: boolean;
25
+ hideStroke?: boolean;
25
26
  }
@@ -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;
@@ -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
- isOriginal: options?.isOriginal,
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
- isOriginal: options?.isOriginal,
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
- isOriginal: options?.isOriginal,
147
+ ...options,
151
148
  });
152
149
  return imagePlaceHolderObject;
153
150
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "customized-fabric",
3
- "version": "1.3.5",
3
+ "version": "1.3.7",
4
4
  "description": "Customized fabric",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",