@anu3ev/fabric-image-editor 0.1.74 → 0.1.75
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 +21 -29
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -38,9 +38,9 @@ var y = (r, e, t) => new Promise((s, a) => {
|
|
|
38
38
|
import { ActiveSelection as v, util as P, controlsUtils as Se, InteractiveFabricObject as Ee, loadSVGFromURL as De, FabricImage as z, Point as G, Gradient as Me, Rect as Ne, Circle as Oe, Triangle as Le, Group as q, Canvas as we, Pattern as Te } from "fabric";
|
|
39
39
|
import { create as ke } from "jsondiffpatch";
|
|
40
40
|
import Be from "diff-match-patch";
|
|
41
|
-
var
|
|
41
|
+
var xe = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", A = function() {
|
|
42
42
|
for (var e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 21, t = "", s = crypto.getRandomValues(new Uint8Array(e |= 0)); e--; )
|
|
43
|
-
t +=
|
|
43
|
+
t += xe[s[e] & 63];
|
|
44
44
|
return t;
|
|
45
45
|
};
|
|
46
46
|
class Y {
|
|
@@ -372,7 +372,7 @@ class Y {
|
|
|
372
372
|
};
|
|
373
373
|
}
|
|
374
374
|
}
|
|
375
|
-
class
|
|
375
|
+
class _e {
|
|
376
376
|
/**
|
|
377
377
|
* Класс для динамической загрузки внешних модулей.
|
|
378
378
|
*/
|
|
@@ -1460,7 +1460,7 @@ class O {
|
|
|
1460
1460
|
return t ? t[1] : "";
|
|
1461
1461
|
}
|
|
1462
1462
|
}
|
|
1463
|
-
const
|
|
1463
|
+
const x = (r, e, t) => Math.max(Math.min(r, t), e), je = (r, e) => r * e, rt = (r, e) => new G(r / 2, e / 2);
|
|
1464
1464
|
function ct(r) {
|
|
1465
1465
|
return ((r == null ? void 0 : r.type) === "image" || (r == null ? void 0 : r.format) === "svg") && typeof (r == null ? void 0 : r.width) == "number" && typeof (r == null ? void 0 : r.height) == "number";
|
|
1466
1466
|
}
|
|
@@ -1495,7 +1495,7 @@ class dt {
|
|
|
1495
1495
|
canvas: n,
|
|
1496
1496
|
montageArea: o,
|
|
1497
1497
|
options: { canvasBackstoreWidth: i }
|
|
1498
|
-
} = this.editor, { width: c, height: d } = o, h =
|
|
1498
|
+
} = this.editor, { width: c, height: d } = o, h = x(Number(e), R, w);
|
|
1499
1499
|
if (!i || i === "auto" || a ? this.adaptCanvasToContainer() : i ? this.setCanvasBackstoreWidth(Number(i)) : this.setCanvasBackstoreWidth(h), o.set({ width: h }), (f = n.clipPath) == null || f.set({ width: h }), t) {
|
|
1500
1500
|
const m = h / c, M = je(d, m);
|
|
1501
1501
|
this.setResolutionHeight(M);
|
|
@@ -1525,7 +1525,7 @@ class dt {
|
|
|
1525
1525
|
canvas: n,
|
|
1526
1526
|
montageArea: o,
|
|
1527
1527
|
options: { canvasBackstoreHeight: i }
|
|
1528
|
-
} = this.editor, { width: c, height: d } = o, h =
|
|
1528
|
+
} = this.editor, { width: c, height: d } = o, h = x(Number(e), U, T);
|
|
1529
1529
|
if (!i || i === "auto" || a ? this.adaptCanvasToContainer() : i ? this.setCanvasBackstoreHeight(Number(i)) : this.setCanvasBackstoreHeight(h), o.set({ height: h }), (f = n.clipPath) == null || f.set({ height: h }), t) {
|
|
1530
1530
|
const m = h / d, M = je(c, m);
|
|
1531
1531
|
this.setResolutionWidth(M);
|
|
@@ -1578,7 +1578,7 @@ class dt {
|
|
|
1578
1578
|
*/
|
|
1579
1579
|
setCanvasBackstoreWidth(e) {
|
|
1580
1580
|
if (!e || typeof e != "number") return;
|
|
1581
|
-
const t =
|
|
1581
|
+
const t = x(e, R, w);
|
|
1582
1582
|
this.editor.canvas.setDimensions({ width: t }, { backstoreOnly: !0 });
|
|
1583
1583
|
}
|
|
1584
1584
|
/**
|
|
@@ -1587,7 +1587,7 @@ class dt {
|
|
|
1587
1587
|
*/
|
|
1588
1588
|
setCanvasBackstoreHeight(e) {
|
|
1589
1589
|
if (!e || typeof e != "number") return;
|
|
1590
|
-
const t =
|
|
1590
|
+
const t = x(e, U, T);
|
|
1591
1591
|
this.editor.canvas.setDimensions({ height: t }, { backstoreOnly: !0 });
|
|
1592
1592
|
}
|
|
1593
1593
|
/**
|
|
@@ -1596,7 +1596,7 @@ class dt {
|
|
|
1596
1596
|
* с учётом минимальных и максимальных значений.
|
|
1597
1597
|
*/
|
|
1598
1598
|
adaptCanvasToContainer() {
|
|
1599
|
-
const { canvas: e } = this.editor, t = this.getEditorContainer(), s = t.clientWidth, a = t.clientHeight, n =
|
|
1599
|
+
const { canvas: e } = this.editor, t = this.getEditorContainer(), s = t.clientWidth, a = t.clientHeight, n = x(s, R, w), o = x(a, U, T);
|
|
1600
1600
|
e.setDimensions({ width: n, height: o }, { backstoreOnly: !0 });
|
|
1601
1601
|
}
|
|
1602
1602
|
/**
|
|
@@ -2135,7 +2135,7 @@ class ht {
|
|
|
2135
2135
|
}), e.upperCanvasEl.style.pointerEvents = "", e.lowerCanvasEl.style.pointerEvents = "", this.overlayMask.visible = !1, e.requestRenderAll(), e.fire("editor:enabled"), s.resumeHistory();
|
|
2136
2136
|
}
|
|
2137
2137
|
}
|
|
2138
|
-
class
|
|
2138
|
+
class _ {
|
|
2139
2139
|
constructor({ editor: e }) {
|
|
2140
2140
|
this.editor = e, this.backgroundObject = null;
|
|
2141
2141
|
}
|
|
@@ -2159,7 +2159,7 @@ class x {
|
|
|
2159
2159
|
a.set({ fill: e }), a.set("backgroundId", `background-${A()}`), this.editor.canvas.requestRenderAll();
|
|
2160
2160
|
} else
|
|
2161
2161
|
this._removeCurrentBackground(), this._createColorBackground(e);
|
|
2162
|
-
this.editor.canvas.fire("background:changed", { type: "color", color: e }), s.resumeHistory(), t || s.saveState();
|
|
2162
|
+
this.editor.canvas.fire("editor:background:changed", { type: "color", color: e }), s.resumeHistory(), t || s.saveState();
|
|
2163
2163
|
} catch (s) {
|
|
2164
2164
|
this.editor.errorManager.emitError({
|
|
2165
2165
|
code: "BACKGROUND_CREATION_FAILED",
|
|
@@ -2183,15 +2183,15 @@ class x {
|
|
|
2183
2183
|
try {
|
|
2184
2184
|
const { historyManager: s } = this.editor, { backgroundObject: a } = this;
|
|
2185
2185
|
if (s.suspendHistory(), a && a.backgroundType === "gradient") {
|
|
2186
|
-
const n =
|
|
2187
|
-
if (
|
|
2186
|
+
const n = _._createFabricGradient(e);
|
|
2187
|
+
if (_._isGradientEqual(a.fill, n)) {
|
|
2188
2188
|
s.resumeHistory();
|
|
2189
2189
|
return;
|
|
2190
2190
|
}
|
|
2191
2191
|
a.set({ fill: n }), a.set("backgroundId", `background-${A()}`), this.editor.canvas.requestRenderAll();
|
|
2192
2192
|
} else
|
|
2193
2193
|
this._removeCurrentBackground(), this._createGradientBackground(e);
|
|
2194
|
-
this.editor.canvas.fire("background:changed", {
|
|
2194
|
+
this.editor.canvas.fire("editor:background:changed", {
|
|
2195
2195
|
type: "gradient",
|
|
2196
2196
|
gradientParams: e
|
|
2197
2197
|
}), s.resumeHistory(), t || s.saveState();
|
|
@@ -2270,7 +2270,7 @@ class x {
|
|
|
2270
2270
|
}) {
|
|
2271
2271
|
try {
|
|
2272
2272
|
const { historyManager: a } = this.editor;
|
|
2273
|
-
a.suspendHistory(),
|
|
2273
|
+
a.suspendHistory(), yield this._createImageBackground(e), this.editor.canvas.fire("editor:background:changed", {
|
|
2274
2274
|
type: "image",
|
|
2275
2275
|
imageSource: e,
|
|
2276
2276
|
backgroundObject: this.backgroundObject
|
|
@@ -2294,16 +2294,8 @@ class x {
|
|
|
2294
2294
|
removeBackground({ withoutSave: e = !1 } = {}) {
|
|
2295
2295
|
try {
|
|
2296
2296
|
const { historyManager: t } = this.editor;
|
|
2297
|
-
if (!this.backgroundObject)
|
|
2298
|
-
|
|
2299
|
-
code: "NO_BACKGROUND_TO_REMOVE",
|
|
2300
|
-
origin: "BackgroundManager",
|
|
2301
|
-
method: "removeBackground",
|
|
2302
|
-
message: "Нет фона для удаления"
|
|
2303
|
-
});
|
|
2304
|
-
return;
|
|
2305
|
-
}
|
|
2306
|
-
t.suspendHistory(), this._removeCurrentBackground(), this.editor.canvas.fire("background:removed"), t.resumeHistory(), e || t.saveState();
|
|
2297
|
+
if (!this.backgroundObject) return;
|
|
2298
|
+
t.suspendHistory(), this._removeCurrentBackground(), this.editor.canvas.fire("editor:background:removed"), t.resumeHistory(), e || t.saveState();
|
|
2307
2299
|
} catch (t) {
|
|
2308
2300
|
this.editor.errorManager.emitError({
|
|
2309
2301
|
code: "BACKGROUND_REMOVAL_FAILED",
|
|
@@ -2356,7 +2348,7 @@ class x {
|
|
|
2356
2348
|
backgroundType: "gradient",
|
|
2357
2349
|
backgroundId: `background-${A()}`
|
|
2358
2350
|
}, { withoutSelection: !0 }), this.refresh();
|
|
2359
|
-
const t =
|
|
2351
|
+
const t = _._createFabricGradient(e);
|
|
2360
2352
|
this.backgroundObject.set("fill", t), this.editor.canvas.requestRenderAll();
|
|
2361
2353
|
}
|
|
2362
2354
|
/**
|
|
@@ -2383,7 +2375,7 @@ class x {
|
|
|
2383
2375
|
id: "background",
|
|
2384
2376
|
backgroundType: "image",
|
|
2385
2377
|
backgroundId: `background-${A()}`
|
|
2386
|
-
}), this.backgroundObject = t, this.refresh();
|
|
2378
|
+
}), this._removeCurrentBackground(), this.backgroundObject = t, this.refresh();
|
|
2387
2379
|
});
|
|
2388
2380
|
}
|
|
2389
2381
|
/**
|
|
@@ -2407,7 +2399,7 @@ class x {
|
|
|
2407
2399
|
{ offset: n / 100, color: s }
|
|
2408
2400
|
];
|
|
2409
2401
|
if (e.type === "linear") {
|
|
2410
|
-
const l = e.angle * Math.PI / 180, g =
|
|
2402
|
+
const l = e.angle * Math.PI / 180, g = _._angleToCoords(l);
|
|
2411
2403
|
return new Me({
|
|
2412
2404
|
type: "linear",
|
|
2413
2405
|
gradientUnits: "percentage",
|
|
@@ -3345,7 +3337,7 @@ class re {
|
|
|
3345
3337
|
scaleType: d,
|
|
3346
3338
|
_onReadyCallback: h
|
|
3347
3339
|
} = this.options;
|
|
3348
|
-
if (Ve.apply(), this.canvas = new we(this.containerId, this.options), this.moduleLoader = new
|
|
3340
|
+
if (Ve.apply(), this.canvas = new we(this.containerId, this.options), this.moduleLoader = new _e(), this.workerManager = new Ue(), this.errorManager = new $({ editor: this }), this.historyManager = new st({ editor: this }), this.toolbar = new tt({ editor: this }), this.transformManager = new lt({ editor: this }), this.canvasManager = new dt({ editor: this }), this.imageManager = new O({ editor: this }), this.layerManager = new Q({ editor: this }), this.shapeManager = new gt({ editor: this }), this.interactionBlocker = new ht({ editor: this }), this.backgroundManager = new _({ editor: this }), this.clipboardManager = new ut({ editor: this }), this.objectLockManager = new K({ editor: this }), this.groupingManager = new Mt({ editor: this }), this.selectionManager = new ft({ editor: this }), this.deletionManager = new mt({ editor: this }), this._createMontageArea(), this._createClippingArea(), this.listeners = new Y({ editor: this, options: this.options }), this.canvasManager.setEditorContainerWidth(e), this.canvasManager.setEditorContainerHeight(t), this.canvasManager.setCanvasWrapperWidth(s), this.canvasManager.setCanvasWrapperHeight(a), this.canvasManager.setCanvasCSSWidth(n), this.canvasManager.setCanvasCSSHeight(o), i != null && i.source) {
|
|
3349
3341
|
const {
|
|
3350
3342
|
source: l,
|
|
3351
3343
|
scale: g = `image-${d}`,
|
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.75",
|
|
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": [
|