customized-fabric 1.1.5 → 1.1.7

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.
@@ -2,7 +2,7 @@ import { fabric } from "fabric";
2
2
  import { IClipartOptions } from "./interfaces";
3
3
  import { ObjectId } from "../utils/objectId";
4
4
  export declare const toClipartObject: (clipartObject: Clipart) => {
5
- _id: ObjectId | undefined;
5
+ id: ObjectId | undefined;
6
6
  personalizeId: number | undefined;
7
7
  layerId: number | undefined;
8
8
  name: string | undefined;
@@ -122,7 +122,7 @@ const ClipartClass = fabric_1.fabric.util.createClass(fabric_1.fabric.Group, {
122
122
  });
123
123
  const toClipartObject = (clipartObject) => {
124
124
  return {
125
- _id: clipartObject._id,
125
+ id: clipartObject._id,
126
126
  personalizeId: clipartObject.layerId,
127
127
  layerId: clipartObject.layerId,
128
128
  name: clipartObject.name,
@@ -23,6 +23,6 @@ export default class ImagePlaceholder extends fabric.Group {
23
23
  width?: number;
24
24
  height?: number;
25
25
  }) => void;
26
- toImageObject?: () => void;
26
+ toImageObject?: () => object;
27
27
  constructor(options?: IImagePlaceholderOptions);
28
28
  }
@@ -97,8 +97,14 @@ const ImagePlaceholderClass = fabric_1.fabric.util.createClass(fabric_1.fabric.G
97
97
  getSettings: function (attribute) {
98
98
  return this.get(attribute);
99
99
  },
100
- loadUploadedImage: async function (imageFile) {
101
- const loadedImage = await (0, utils_1.loadImageFromFile)(imageFile);
100
+ loadUploadedImage: async function (image) {
101
+ let loadedImage = undefined;
102
+ if (image instanceof File) {
103
+ loadedImage = await (0, utils_1.loadImageFromFile)(image);
104
+ }
105
+ else if (typeof image == "string") {
106
+ loadedImage = await (0, utils_1.loadImageFromUrl)(image);
107
+ }
102
108
  const clipPath = new fabric_1.fabric.Rect({
103
109
  width: this.width,
104
110
  height: this.height,
@@ -106,18 +112,20 @@ const ImagePlaceholderClass = fabric_1.fabric.util.createClass(fabric_1.fabric.G
106
112
  left: this.left,
107
113
  absolutePositioned: true,
108
114
  });
109
- loadedImage.set({
110
- originX: "left",
111
- originY: "top",
112
- top: this.top,
113
- left: this.left,
114
- clipPath: clipPath,
115
- });
116
- this.fitImage(loadedImage);
117
- this.uploadedImage = loadedImage;
118
- const canvas = this?.canvas;
119
- canvas?.add(this.uploadedImage);
120
- canvas?.renderAll();
115
+ if (loadedImage) {
116
+ loadedImage.set({
117
+ originX: "left",
118
+ originY: "top",
119
+ top: this.top,
120
+ left: this.left,
121
+ clipPath: clipPath,
122
+ });
123
+ this.fitImage(loadedImage);
124
+ this.uploadedImage = loadedImage;
125
+ const canvas = this?.canvas;
126
+ canvas?.add(this.uploadedImage);
127
+ canvas?.renderAll();
128
+ }
121
129
  return this.uploadedImage;
122
130
  },
123
131
  removeUploadedImage: function () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "customized-fabric",
3
- "version": "1.1.5",
3
+ "version": "1.1.7",
4
4
  "description": "Customized fabric",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -22,4 +22,4 @@
22
22
  "@types/fabric": "^5.3.3",
23
23
  "typescript": "^5.2.2"
24
24
  }
25
- }
25
+ }