customized-fabric 1.1.5 → 1.1.6
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.
@@ -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 (
|
101
|
-
|
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
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
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 () {
|