@anu3ev/fabric-image-editor 0.1.1 → 0.1.2
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.
- package/dist/{main.js → bundle.js} +40 -42
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ActiveSelection as Z, util as z, controlsUtils as Oe, InteractiveFabricObject as Te, Pattern as Ee, loadSVGFromURL as ke, FabricImage as de, Point as xe, Rect as Be, Circle as Ze, Triangle as ze, Group as Ue, Canvas as Pe } from "fabric";
|
|
2
2
|
import { create as Ye } from "jsondiffpatch";
|
|
3
|
-
var He = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict",
|
|
3
|
+
var He = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", I = function() {
|
|
4
4
|
for (var e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 21, t = "", a = crypto.getRandomValues(new Uint8Array(e |= 0)); e--; )
|
|
5
5
|
t += He[a[e] & 63];
|
|
6
6
|
return t;
|
|
@@ -383,7 +383,7 @@ class Re {
|
|
|
383
383
|
* По-умолчанию использует файл рядом с этим модулем
|
|
384
384
|
*/
|
|
385
385
|
constructor() {
|
|
386
|
-
var e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : new URL("
|
|
386
|
+
var e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : new URL("" + new URL("worker.js", import.meta.url).href, import.meta.url);
|
|
387
387
|
this.worker = new Worker(e, {
|
|
388
388
|
type: "module"
|
|
389
389
|
}), this._callbacks = /* @__PURE__ */ new Map(), this.worker.onmessage = this._handleMessage.bind(this);
|
|
@@ -417,7 +417,7 @@ class Re {
|
|
|
417
417
|
* @returns {Promise<any>}
|
|
418
418
|
*/
|
|
419
419
|
post(e, t) {
|
|
420
|
-
var a = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : [], r = "".concat(e, ":").concat(
|
|
420
|
+
var a = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : [], r = "".concat(e, ":").concat(I(8));
|
|
421
421
|
return new Promise((n, o) => {
|
|
422
422
|
this._callbacks.set(r, {
|
|
423
423
|
resolve: n,
|
|
@@ -674,7 +674,7 @@ function me(i, e) {
|
|
|
674
674
|
}
|
|
675
675
|
return t;
|
|
676
676
|
}
|
|
677
|
-
function
|
|
677
|
+
function M(i) {
|
|
678
678
|
for (var e = 1; e < arguments.length; e++) {
|
|
679
679
|
var t = arguments[e] != null ? arguments[e] : {};
|
|
680
680
|
e % 2 ? me(Object(t), !0).forEach(function(a) {
|
|
@@ -714,11 +714,11 @@ class lt {
|
|
|
714
714
|
if (this.options = t.options, !!this.options.showToolbar) {
|
|
715
715
|
this.editor = t, this.canvas = t.canvas;
|
|
716
716
|
var a = this.options.toolbar || {};
|
|
717
|
-
this.config =
|
|
718
|
-
style:
|
|
719
|
-
btnStyle:
|
|
720
|
-
icons:
|
|
721
|
-
handlers:
|
|
717
|
+
this.config = M(M(M({}, E), a), {}, {
|
|
718
|
+
style: M(M({}, E.style), a.style || {}),
|
|
719
|
+
btnStyle: M(M({}, E.btnStyle), a.btnStyle || {}),
|
|
720
|
+
icons: M(M({}, E.icons), a.icons || {}),
|
|
721
|
+
handlers: M(M({}, E.handlers), a.handlers || {})
|
|
722
722
|
}), this.currentTarget = null, this.currentLocked = null, this.isTransforming = !1, this._onMouseDown = this._handleMouseDown.bind(this), this._onObjectMoving = this._startTransform.bind(this), this._onObjectScaling = this._startTransform.bind(this), this._onObjectRotating = this._startTransform.bind(this), this._onMouseUp = this._endTransform.bind(this), this._onObjectModified = this._endTransform.bind(this), this._onSelectionChange = this._updateToolbar.bind(this), this._onSelectionClear = () => {
|
|
723
723
|
this.el.style.display = "none";
|
|
724
724
|
}, this._createDOM(), this._bindEvents();
|
|
@@ -1119,8 +1119,8 @@ class L {
|
|
|
1119
1119
|
t._createdBlobUrls.push(u);
|
|
1120
1120
|
var v = L.getFormatFromContentType(o);
|
|
1121
1121
|
if (v === "svg") {
|
|
1122
|
-
var
|
|
1123
|
-
h = z.groupSVGElements(
|
|
1122
|
+
var j = yield ke(u);
|
|
1123
|
+
h = z.groupSVGElements(j.objects, j.options);
|
|
1124
1124
|
} else
|
|
1125
1125
|
h = yield de.fromURL(u, {
|
|
1126
1126
|
crossOrigin: "anonymous"
|
|
@@ -1130,14 +1130,12 @@ class L {
|
|
|
1130
1130
|
height: b
|
|
1131
1131
|
} = h;
|
|
1132
1132
|
if (b > C || m > D) {
|
|
1133
|
-
var
|
|
1134
|
-
|
|
1135
|
-
var I = URL.createObjectURL(M);
|
|
1136
|
-
console.log("resizedBlobURL", I), t._createdBlobUrls.push(I), h = yield de.fromURL(I, {
|
|
1133
|
+
var y = yield t.resizeImageToBoundaries(h._element.src, "max"), S = URL.createObjectURL(y);
|
|
1134
|
+
t._createdBlobUrls.push(S), h = yield de.fromURL(S, {
|
|
1137
1135
|
crossOrigin: "anonymous"
|
|
1138
|
-
})
|
|
1136
|
+
});
|
|
1139
1137
|
}
|
|
1140
|
-
if (h.set("id", "".concat(h.type, "-").concat(
|
|
1138
|
+
if (h.set("id", "".concat(h.type, "-").concat(I())), h.set("format", v), r === "scale-montage")
|
|
1141
1139
|
t.editor.canvasManager.scaleMontageAreaToImage({
|
|
1142
1140
|
object: h,
|
|
1143
1141
|
withoutSave: !0
|
|
@@ -1223,21 +1221,21 @@ class L {
|
|
|
1223
1221
|
left: g,
|
|
1224
1222
|
top: f,
|
|
1225
1223
|
width: v,
|
|
1226
|
-
height:
|
|
1224
|
+
height: j
|
|
1227
1225
|
} = c.getBoundingRect(), m = yield s.clone(["id", "format", "locked"]);
|
|
1228
1226
|
["image/jpg", "image/jpeg"].includes(u) && (m.backgroundColor = "#ffffff");
|
|
1229
1227
|
var b = m.getObjects().find((N) => N.id === c.id);
|
|
1230
1228
|
b.visible = !1, m.viewportTransform = [1, 0, 0, 1, -g, -f], m.setDimensions({
|
|
1231
1229
|
width: v,
|
|
1232
|
-
height:
|
|
1230
|
+
height: j
|
|
1233
1231
|
}, {
|
|
1234
1232
|
backstoreOnly: !0
|
|
1235
1233
|
}), m.renderAll();
|
|
1236
|
-
var
|
|
1237
|
-
if (h === "svg" &&
|
|
1238
|
-
var
|
|
1234
|
+
var y = m.getObjects().filter((N) => N.format).every((N) => N.format === "svg");
|
|
1235
|
+
if (h === "svg" && y) {
|
|
1236
|
+
var S = m.toSVG();
|
|
1239
1237
|
m.dispose();
|
|
1240
|
-
var O = L._exportSVGStringAsFile(
|
|
1238
|
+
var O = L._exportSVGStringAsFile(S, {
|
|
1241
1239
|
exportAsBase64: n,
|
|
1242
1240
|
exportAsBlob: o,
|
|
1243
1241
|
fileName: a
|
|
@@ -1267,7 +1265,7 @@ class L {
|
|
|
1267
1265
|
bitmap: ae
|
|
1268
1266
|
}, [ae]);
|
|
1269
1267
|
if (l) {
|
|
1270
|
-
var ne = 0.264583, W = v * ne, _ =
|
|
1268
|
+
var ne = 0.264583, W = v * ne, _ = j * ne, we = (yield t.editor.moduleLoader.loadModule("jspdf")).jsPDF, R = new we({
|
|
1271
1269
|
orientation: W > _ ? "landscape" : "portrait",
|
|
1272
1270
|
unit: "mm",
|
|
1273
1271
|
format: [W, _]
|
|
@@ -1300,7 +1298,7 @@ class L {
|
|
|
1300
1298
|
};
|
|
1301
1299
|
return s.fire("editor:canvas-exported", se), se;
|
|
1302
1300
|
}
|
|
1303
|
-
var ce = h === "svg" && !
|
|
1301
|
+
var ce = h === "svg" && !y ? a.replace(/\.[^/.]+$/, ".png") : a, Le = new File([w], ce, {
|
|
1304
1302
|
type: u
|
|
1305
1303
|
}), ue = {
|
|
1306
1304
|
image: Le,
|
|
@@ -1354,31 +1352,31 @@ class L {
|
|
|
1354
1352
|
return c.fire("editor:object-exported", f), f;
|
|
1355
1353
|
}
|
|
1356
1354
|
if (o) {
|
|
1357
|
-
var v = yield createImageBitmap(l._element),
|
|
1355
|
+
var v = yield createImageBitmap(l._element), j = yield d.post("toDataURL", {
|
|
1358
1356
|
format: u,
|
|
1359
1357
|
quality: 1,
|
|
1360
1358
|
bitmap: v
|
|
1361
1359
|
}, [v]), m = {
|
|
1362
|
-
image:
|
|
1360
|
+
image: j,
|
|
1363
1361
|
format: u,
|
|
1364
1362
|
contentType: n,
|
|
1365
1363
|
fileName: r
|
|
1366
1364
|
};
|
|
1367
1365
|
return c.fire("editor:object-exported", m), m;
|
|
1368
1366
|
}
|
|
1369
|
-
var b = l.toCanvasElement(),
|
|
1367
|
+
var b = l.toCanvasElement(), y = yield new Promise((w) => {
|
|
1370
1368
|
b.toBlob(w);
|
|
1371
1369
|
});
|
|
1372
1370
|
if (s) {
|
|
1373
|
-
var
|
|
1374
|
-
image:
|
|
1371
|
+
var S = {
|
|
1372
|
+
image: y,
|
|
1375
1373
|
format: u,
|
|
1376
1374
|
contentType: n,
|
|
1377
1375
|
fileName: r
|
|
1378
1376
|
};
|
|
1379
|
-
return c.fire("editor:object-exported",
|
|
1377
|
+
return c.fire("editor:object-exported", S), S;
|
|
1380
1378
|
}
|
|
1381
|
-
var O = new File([
|
|
1379
|
+
var O = new File([y], r, {
|
|
1382
1380
|
type: n
|
|
1383
1381
|
}), A = {
|
|
1384
1382
|
image: O,
|
|
@@ -1763,9 +1761,9 @@ class jt {
|
|
|
1763
1761
|
if (t) {
|
|
1764
1762
|
var {
|
|
1765
1763
|
width: v,
|
|
1766
|
-
height:
|
|
1767
|
-
} = n, m = l / v, b = u /
|
|
1768
|
-
g = v *
|
|
1764
|
+
height: j
|
|
1765
|
+
} = n, m = l / v, b = u / j, y = Math.max(m, b);
|
|
1766
|
+
g = v * y, f = j * y;
|
|
1769
1767
|
}
|
|
1770
1768
|
this.setResolutionWidth(g, {
|
|
1771
1769
|
withoutSave: !0
|
|
@@ -2420,7 +2418,7 @@ class Ct {
|
|
|
2420
2418
|
*/
|
|
2421
2419
|
addRectangle() {
|
|
2422
2420
|
var e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, {
|
|
2423
|
-
id: t = "rect-".concat(
|
|
2421
|
+
id: t = "rect-".concat(I()),
|
|
2424
2422
|
left: a,
|
|
2425
2423
|
top: r,
|
|
2426
2424
|
width: n = 100,
|
|
@@ -2457,7 +2455,7 @@ class Ct {
|
|
|
2457
2455
|
*/
|
|
2458
2456
|
addCircle() {
|
|
2459
2457
|
var e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, {
|
|
2460
|
-
id: t = "circle-".concat(
|
|
2458
|
+
id: t = "circle-".concat(I()),
|
|
2461
2459
|
left: a,
|
|
2462
2460
|
top: r,
|
|
2463
2461
|
radius: n = 50,
|
|
@@ -2493,7 +2491,7 @@ class Ct {
|
|
|
2493
2491
|
*/
|
|
2494
2492
|
addTriangle() {
|
|
2495
2493
|
var e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, {
|
|
2496
|
-
id: t = "triangle-".concat(
|
|
2494
|
+
id: t = "triangle-".concat(I()),
|
|
2497
2495
|
left: a,
|
|
2498
2496
|
top: r,
|
|
2499
2497
|
width: n = 100,
|
|
@@ -2606,7 +2604,7 @@ class Lt {
|
|
|
2606
2604
|
if (e.clipboard) {
|
|
2607
2605
|
var a = yield e.clipboard.clone();
|
|
2608
2606
|
t.discardActiveObject(), a.set({
|
|
2609
|
-
id: "".concat(a.type, "-").concat(
|
|
2607
|
+
id: "".concat(a.type, "-").concat(I()),
|
|
2610
2608
|
left: a.left + 10,
|
|
2611
2609
|
top: a.top + 10,
|
|
2612
2610
|
evented: !0
|
|
@@ -2729,7 +2727,7 @@ class Tt {
|
|
|
2729
2727
|
var n = e || a.getActiveObject();
|
|
2730
2728
|
if (n && n.type === "activeselection") {
|
|
2731
2729
|
var o = n.getObjects(), s = new Ue(o);
|
|
2732
|
-
o.forEach((c) => a.remove(c)), s.set("id", "".concat(s.type, "-").concat(
|
|
2730
|
+
o.forEach((c) => a.remove(c)), s.set("id", "".concat(s.type, "-").concat(I())), a.add(s), a.setActiveObject(s), a.renderAll(), r.resumeHistory(), t || r.saveState(), a.fire("editor:objects-grouped");
|
|
2733
2731
|
}
|
|
2734
2732
|
}
|
|
2735
2733
|
/**
|
|
@@ -2857,7 +2855,7 @@ class Bt {
|
|
|
2857
2855
|
minZoom: r,
|
|
2858
2856
|
maxZoom: n
|
|
2859
2857
|
} = t;
|
|
2860
|
-
this.containerId = e, this.editorId = "".concat(e, "-").concat(
|
|
2858
|
+
this.containerId = e, this.editorId = "".concat(e, "-").concat(I()), this.clipboard = null, this.defaultZoom = a, this.minZoom = r || vt, this.maxZoom = n || mt, this.init();
|
|
2861
2859
|
}
|
|
2862
2860
|
init() {
|
|
2863
2861
|
var e = this;
|
|
@@ -3144,4 +3142,4 @@ function Wt(i) {
|
|
|
3144
3142
|
export {
|
|
3145
3143
|
Wt as default
|
|
3146
3144
|
};
|
|
3147
|
-
//# sourceMappingURL=
|
|
3145
|
+
//# sourceMappingURL=bundle.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anu3ev/fabric-image-editor",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "JavaScript image editor built on FabricJS, allowing you to create instances with an integrated montage area and providing an API to modify and manage state.",
|
|
5
5
|
"module": "dist/main.js",
|
|
6
6
|
"files": [
|