@anu3ev/fabric-image-editor 0.1.36 → 0.1.38
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 +124 -109
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var Te = Object.defineProperty;
|
|
2
2
|
var G = Object.getOwnPropertySymbols;
|
|
3
3
|
var Me = Object.prototype.hasOwnProperty, fe = Object.prototype.propertyIsEnumerable;
|
|
4
|
-
var me = (o, e, t) => e in o ? Te(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t,
|
|
4
|
+
var me = (o, e, t) => e in o ? Te(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t, w = (o, e) => {
|
|
5
5
|
for (var t in e || (e = {}))
|
|
6
6
|
Me.call(e, t) && me(o, t, e[t]);
|
|
7
7
|
if (G)
|
|
@@ -406,9 +406,9 @@ class Fe {
|
|
|
406
406
|
this.worker.terminate();
|
|
407
407
|
}
|
|
408
408
|
}
|
|
409
|
-
var
|
|
409
|
+
var C = 12, Ve = 2, te = 8, ae = 20, Ge = 100, re = 20, ie = 8, Xe = 100, ne = 32, se = 1, Qe = "#2B2D33", oe = "#3D8BF4", ce = "#FFFFFF";
|
|
410
410
|
function Q(o, e, t, a, r) {
|
|
411
|
-
var i =
|
|
411
|
+
var i = C, n = Ve;
|
|
412
412
|
o.save(), o.translate(e, t), o.rotate(R.degreesToRadians(r.angle)), o.fillStyle = ce, o.strokeStyle = oe, o.lineWidth = se, o.beginPath(), o.roundRect(-12 / 2, -12 / 2, i, i, n), o.fill(), o.stroke(), o.restore();
|
|
413
413
|
}
|
|
414
414
|
function je(o, e, t, a, r) {
|
|
@@ -429,29 +429,29 @@ var $e = {
|
|
|
429
429
|
// Угловые точки
|
|
430
430
|
tl: {
|
|
431
431
|
render: Q,
|
|
432
|
-
sizeX:
|
|
433
|
-
sizeY:
|
|
432
|
+
sizeX: C,
|
|
433
|
+
sizeY: C,
|
|
434
434
|
offsetX: 0,
|
|
435
435
|
offsetY: 0
|
|
436
436
|
},
|
|
437
437
|
tr: {
|
|
438
438
|
render: Q,
|
|
439
|
-
sizeX:
|
|
440
|
-
sizeY:
|
|
439
|
+
sizeX: C,
|
|
440
|
+
sizeY: C,
|
|
441
441
|
offsetX: 0,
|
|
442
442
|
offsetY: 0
|
|
443
443
|
},
|
|
444
444
|
bl: {
|
|
445
445
|
render: Q,
|
|
446
|
-
sizeX:
|
|
447
|
-
sizeY:
|
|
446
|
+
sizeX: C,
|
|
447
|
+
sizeY: C,
|
|
448
448
|
offsetX: 0,
|
|
449
449
|
offsetY: 0
|
|
450
450
|
},
|
|
451
451
|
br: {
|
|
452
452
|
render: Q,
|
|
453
|
-
sizeX:
|
|
454
|
-
sizeY:
|
|
453
|
+
sizeX: C,
|
|
454
|
+
sizeY: C,
|
|
455
455
|
offsetX: 0,
|
|
456
456
|
offsetY: 0
|
|
457
457
|
},
|
|
@@ -647,7 +647,7 @@ function be(o, e) {
|
|
|
647
647
|
}
|
|
648
648
|
return t;
|
|
649
649
|
}
|
|
650
|
-
function
|
|
650
|
+
function p(o) {
|
|
651
651
|
for (var e = 1; e < arguments.length; e++) {
|
|
652
652
|
var t = arguments[e] != null ? arguments[e] : {};
|
|
653
653
|
e % 2 ? be(Object(t), !0).forEach(function(a) {
|
|
@@ -687,11 +687,11 @@ class ht {
|
|
|
687
687
|
if (this.options = t.options, !!this.options.showToolbar) {
|
|
688
688
|
this.editor = t, this.canvas = t.canvas;
|
|
689
689
|
var a = this.options.toolbar || {};
|
|
690
|
-
this.config =
|
|
691
|
-
style:
|
|
692
|
-
btnStyle:
|
|
693
|
-
icons:
|
|
694
|
-
handlers:
|
|
690
|
+
this.config = p(p(p({}, H), a), {}, {
|
|
691
|
+
style: p(p({}, H.style), a.style || {}),
|
|
692
|
+
btnStyle: p(p({}, H.btnStyle), a.btnStyle || {}),
|
|
693
|
+
icons: p(p({}, H.icons), a.icons || {}),
|
|
694
|
+
handlers: p(p({}, H.handlers), a.handlers || {})
|
|
695
695
|
}), 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 = () => {
|
|
696
696
|
this.el.style.display = "none";
|
|
697
697
|
}, this._createDOM(), this._bindEvents();
|
|
@@ -865,6 +865,9 @@ class gt {
|
|
|
865
865
|
get skipHistory() {
|
|
866
866
|
return this._historySuspendCount > 0;
|
|
867
867
|
}
|
|
868
|
+
get lastPatch() {
|
|
869
|
+
return this.patches[this.currentIndex - 1] || null;
|
|
870
|
+
}
|
|
868
871
|
_createDiffPatcher() {
|
|
869
872
|
this.diffPatcher = _e({
|
|
870
873
|
objectHash(e) {
|
|
@@ -910,7 +913,7 @@ class gt {
|
|
|
910
913
|
currentIndex: t,
|
|
911
914
|
patches: a
|
|
912
915
|
} = this, r = JSON.parse(JSON.stringify(e)), i = 0; i < t; i += 1)
|
|
913
|
-
r = this.diffPatcher.patch(r, a[i]);
|
|
916
|
+
r = this.diffPatcher.patch(r, a[i].diff);
|
|
914
917
|
return console.log("getFullState state", r), r;
|
|
915
918
|
}
|
|
916
919
|
/**
|
|
@@ -929,7 +932,10 @@ class gt {
|
|
|
929
932
|
console.log("Нет изменений для сохранения.");
|
|
930
933
|
return;
|
|
931
934
|
}
|
|
932
|
-
console.log("baseState", this.baseState), this.currentIndex < this.patches.length && this.patches.splice(this.currentIndex), console.log("diff", a), this.totalChangesCount += 1, this.patches.push(
|
|
935
|
+
console.log("baseState", this.baseState), this.currentIndex < this.patches.length && this.patches.splice(this.currentIndex), console.log("diff", a), this.totalChangesCount += 1, this.patches.push({
|
|
936
|
+
id: D(),
|
|
937
|
+
diff: a
|
|
938
|
+
}), this.currentIndex += 1, this.patches.length > this.maxHistoryLength && (this.baseState = this.diffPatcher.patch(this.baseState, this.patches[0].diff), this.patches.shift(), this.currentIndex -= 1, this.baseStateChangesCount += 1), console.log("Состояние сохранено. Текущий индекс истории:", this.currentIndex);
|
|
933
939
|
}
|
|
934
940
|
}
|
|
935
941
|
/**
|
|
@@ -1028,7 +1034,7 @@ function O(o) {
|
|
|
1028
1034
|
});
|
|
1029
1035
|
};
|
|
1030
1036
|
}
|
|
1031
|
-
class
|
|
1037
|
+
class L {
|
|
1032
1038
|
/**
|
|
1033
1039
|
* @param {object} options
|
|
1034
1040
|
* @param {ImageEditor} options.editor - экземпляр редактора с доступом к canvas
|
|
@@ -1066,23 +1072,23 @@ class C {
|
|
|
1066
1072
|
transformManager: c,
|
|
1067
1073
|
historyManager: u,
|
|
1068
1074
|
errorManager: l
|
|
1069
|
-
} = t.editor, d = yield t.getContentType(a), h =
|
|
1075
|
+
} = t.editor, d = yield t.getContentType(a), h = L.getFormatFromContentType(d), {
|
|
1070
1076
|
acceptContentTypes: g,
|
|
1071
|
-
acceptFormats:
|
|
1077
|
+
acceptFormats: M
|
|
1072
1078
|
} = t;
|
|
1073
1079
|
if (!t.isAllowedContentType(d)) {
|
|
1074
|
-
var
|
|
1080
|
+
var m = "Неверный contentType для изображения: ".concat(d, ". Ожидается один из: ").concat(t.acceptContentTypes.join(", "), ".");
|
|
1075
1081
|
return l.emitError({
|
|
1076
1082
|
origin: "ImageManager",
|
|
1077
1083
|
method: "importImage",
|
|
1078
1084
|
code: "INVALID_CONTENT_TYPE",
|
|
1079
|
-
message:
|
|
1085
|
+
message: m,
|
|
1080
1086
|
data: {
|
|
1081
1087
|
source: a,
|
|
1082
1088
|
format: h,
|
|
1083
1089
|
contentType: d,
|
|
1084
1090
|
acceptContentTypes: g,
|
|
1085
|
-
acceptFormats:
|
|
1091
|
+
acceptFormats: M
|
|
1086
1092
|
}
|
|
1087
1093
|
}), null;
|
|
1088
1094
|
}
|
|
@@ -1092,13 +1098,13 @@ class C {
|
|
|
1092
1098
|
if (a instanceof File)
|
|
1093
1099
|
f = URL.createObjectURL(a);
|
|
1094
1100
|
else if (typeof a == "string") {
|
|
1095
|
-
var
|
|
1101
|
+
var N = yield fetch(a, {
|
|
1096
1102
|
mode: "cors"
|
|
1097
|
-
}),
|
|
1103
|
+
}), b = yield N.blob({
|
|
1098
1104
|
type: d,
|
|
1099
1105
|
quality: 1
|
|
1100
1106
|
});
|
|
1101
|
-
f = URL.createObjectURL(
|
|
1107
|
+
f = URL.createObjectURL(b);
|
|
1102
1108
|
} else
|
|
1103
1109
|
return l.emitError({
|
|
1104
1110
|
origin: "ImageManager",
|
|
@@ -1110,26 +1116,26 @@ class C {
|
|
|
1110
1116
|
format: h,
|
|
1111
1117
|
contentType: d,
|
|
1112
1118
|
acceptContentTypes: g,
|
|
1113
|
-
acceptFormats:
|
|
1119
|
+
acceptFormats: M
|
|
1114
1120
|
}
|
|
1115
1121
|
}), null;
|
|
1116
1122
|
if (t._createdBlobUrls.push(f), h === "svg") {
|
|
1117
|
-
var
|
|
1118
|
-
v = R.groupSVGElements(
|
|
1123
|
+
var I = yield xe(f);
|
|
1124
|
+
v = R.groupSVGElements(I.objects, I.options);
|
|
1119
1125
|
} else
|
|
1120
1126
|
v = yield q.fromURL(f, {
|
|
1121
1127
|
crossOrigin: "anonymous"
|
|
1122
1128
|
});
|
|
1123
1129
|
var {
|
|
1124
|
-
width:
|
|
1125
|
-
height:
|
|
1130
|
+
width: S,
|
|
1131
|
+
height: j
|
|
1126
1132
|
} = v;
|
|
1127
|
-
if (
|
|
1128
|
-
var
|
|
1133
|
+
if (j > T || S > E) {
|
|
1134
|
+
var y = yield t.resizeImageToBoundaries(v._element.src, "max"), B = URL.createObjectURL(y);
|
|
1129
1135
|
t._createdBlobUrls.push(B), v = yield q.fromURL(B, {
|
|
1130
1136
|
crossOrigin: "anonymous"
|
|
1131
1137
|
});
|
|
1132
|
-
} else if (
|
|
1138
|
+
} else if (j < x || S < k) {
|
|
1133
1139
|
var W = yield t.resizeImageToBoundaries(v._element.src, "min"), Z = URL.createObjectURL(W);
|
|
1134
1140
|
t._createdBlobUrls.push(Z), v = yield q.fromURL(Z, {
|
|
1135
1141
|
crossOrigin: "anonymous"
|
|
@@ -1152,7 +1158,7 @@ class C {
|
|
|
1152
1158
|
object: v,
|
|
1153
1159
|
type: "contain",
|
|
1154
1160
|
withoutSave: !0
|
|
1155
|
-
}) : r === "image-cover" && (
|
|
1161
|
+
}) : r === "image-cover" && (S > F || j > z) && c.fitObject({
|
|
1156
1162
|
object: v,
|
|
1157
1163
|
type: "cover",
|
|
1158
1164
|
withoutSave: !0
|
|
@@ -1240,57 +1246,57 @@ class C {
|
|
|
1240
1246
|
workerManager: u
|
|
1241
1247
|
} = t.editor;
|
|
1242
1248
|
try {
|
|
1243
|
-
var l = r === "application/pdf", d = l ? "image/jpg" : r, h =
|
|
1249
|
+
var l = r === "application/pdf", d = l ? "image/jpg" : r, h = L.getFormatFromContentType(d);
|
|
1244
1250
|
c.setCoords();
|
|
1245
1251
|
var {
|
|
1246
1252
|
left: g,
|
|
1247
|
-
top:
|
|
1248
|
-
width:
|
|
1253
|
+
top: M,
|
|
1254
|
+
width: m,
|
|
1249
1255
|
height: f
|
|
1250
1256
|
} = c.getBoundingRect(), v = yield s.clone(["id", "format", "locked"]);
|
|
1251
1257
|
["image/jpg", "image/jpeg"].includes(d) && (v.backgroundColor = "#ffffff");
|
|
1252
|
-
var
|
|
1253
|
-
|
|
1254
|
-
width:
|
|
1258
|
+
var N = v.getObjects().find((A) => A.id === c.id);
|
|
1259
|
+
N.visible = !1, v.viewportTransform = [1, 0, 0, 1, -g, -M], v.setDimensions({
|
|
1260
|
+
width: m,
|
|
1255
1261
|
height: f
|
|
1256
1262
|
}, {
|
|
1257
1263
|
backstoreOnly: !0
|
|
1258
1264
|
}), v.renderAll();
|
|
1259
|
-
var
|
|
1260
|
-
if (h === "svg" &&
|
|
1261
|
-
var
|
|
1265
|
+
var b = v.getObjects().filter((A) => A.format).every((A) => A.format === "svg");
|
|
1266
|
+
if (h === "svg" && b) {
|
|
1267
|
+
var I = v.toSVG();
|
|
1262
1268
|
v.dispose();
|
|
1263
|
-
var
|
|
1269
|
+
var S = L._exportSVGStringAsFile(I, {
|
|
1264
1270
|
exportAsBase64: i,
|
|
1265
1271
|
exportAsBlob: n,
|
|
1266
1272
|
fileName: a
|
|
1267
|
-
}),
|
|
1268
|
-
image:
|
|
1273
|
+
}), j = {
|
|
1274
|
+
image: S,
|
|
1269
1275
|
format: "svg",
|
|
1270
1276
|
contentType: "image/svg+xml",
|
|
1271
1277
|
fileName: a.replace(/\.[^/.]+$/, ".svg")
|
|
1272
1278
|
};
|
|
1273
|
-
return s.fire("editor:canvas-exported",
|
|
1279
|
+
return s.fire("editor:canvas-exported", j), j;
|
|
1274
1280
|
}
|
|
1275
|
-
var
|
|
1276
|
-
v.getElement().toBlob(
|
|
1281
|
+
var y = yield new Promise((A) => {
|
|
1282
|
+
v.getElement().toBlob(A);
|
|
1277
1283
|
});
|
|
1278
1284
|
if (v.dispose(), n) {
|
|
1279
1285
|
var B = {
|
|
1280
|
-
image:
|
|
1286
|
+
image: y,
|
|
1281
1287
|
format: h,
|
|
1282
1288
|
contentType: d,
|
|
1283
1289
|
fileName: a
|
|
1284
1290
|
};
|
|
1285
1291
|
return s.fire("editor:canvas-exported", B), B;
|
|
1286
1292
|
}
|
|
1287
|
-
var W = yield createImageBitmap(
|
|
1293
|
+
var W = yield createImageBitmap(y), Z = yield u.post("toDataURL", {
|
|
1288
1294
|
format: h,
|
|
1289
1295
|
quality: 1,
|
|
1290
1296
|
bitmap: W
|
|
1291
1297
|
}, [W]);
|
|
1292
1298
|
if (l) {
|
|
1293
|
-
var F = 0.264583, z =
|
|
1299
|
+
var F = 0.264583, z = m * F, U = f * F, V = (yield t.editor.moduleLoader.loadModule("jspdf")).jsPDF, Y = new V({
|
|
1294
1300
|
orientation: z > U ? "landscape" : "portrait",
|
|
1295
1301
|
unit: "mm",
|
|
1296
1302
|
format: [z, U]
|
|
@@ -1323,7 +1329,7 @@ class C {
|
|
|
1323
1329
|
};
|
|
1324
1330
|
return s.fire("editor:canvas-exported", he), he;
|
|
1325
1331
|
}
|
|
1326
|
-
var ge = h === "svg" && !
|
|
1332
|
+
var ge = h === "svg" && !b ? a.replace(/\.[^/.]+$/, ".png") : a, Ee = new File([y], ge, {
|
|
1327
1333
|
type: d
|
|
1328
1334
|
}), ve = {
|
|
1329
1335
|
image: Ee,
|
|
@@ -1332,12 +1338,12 @@ class C {
|
|
|
1332
1338
|
fileName: ge
|
|
1333
1339
|
};
|
|
1334
1340
|
return s.fire("editor:canvas-exported", ve), ve;
|
|
1335
|
-
} catch (
|
|
1341
|
+
} catch (A) {
|
|
1336
1342
|
return t.editor.errorManager.emitError({
|
|
1337
1343
|
origin: "ImageManager",
|
|
1338
1344
|
method: "exportCanvasAsImageFile",
|
|
1339
1345
|
code: "IMAGE_EXPORT_FAILED",
|
|
1340
|
-
message: "Ошибка экспорта изображения: ".concat(
|
|
1346
|
+
message: "Ошибка экспорта изображения: ".concat(A.message),
|
|
1341
1347
|
data: {
|
|
1342
1348
|
contentType: r,
|
|
1343
1349
|
fileName: a,
|
|
@@ -1386,26 +1392,26 @@ class C {
|
|
|
1386
1392
|
}
|
|
1387
1393
|
}), "";
|
|
1388
1394
|
try {
|
|
1389
|
-
var d =
|
|
1395
|
+
var d = L.getFormatFromContentType(i);
|
|
1390
1396
|
if (d === "svg") {
|
|
1391
1397
|
var h = l.toSVG(), g = t._exportSVGStringAsFile(h, {
|
|
1392
1398
|
exportAsBase64: n,
|
|
1393
1399
|
exportAsBlob: s,
|
|
1394
1400
|
fileName: r
|
|
1395
|
-
}),
|
|
1401
|
+
}), M = {
|
|
1396
1402
|
image: g,
|
|
1397
1403
|
format: d,
|
|
1398
1404
|
contentType: "image/svg+xml",
|
|
1399
1405
|
fileName: r.replace(/\.[^/.]+$/, ".svg")
|
|
1400
1406
|
};
|
|
1401
|
-
return c.fire("editor:object-exported",
|
|
1407
|
+
return c.fire("editor:object-exported", M), M;
|
|
1402
1408
|
}
|
|
1403
1409
|
if (n) {
|
|
1404
|
-
var
|
|
1410
|
+
var m = yield createImageBitmap(l._element), f = yield u.post("toDataURL", {
|
|
1405
1411
|
format: d,
|
|
1406
1412
|
quality: 1,
|
|
1407
|
-
bitmap:
|
|
1408
|
-
}, [
|
|
1413
|
+
bitmap: m
|
|
1414
|
+
}, [m]), v = {
|
|
1409
1415
|
image: f,
|
|
1410
1416
|
format: d,
|
|
1411
1417
|
contentType: i,
|
|
@@ -1413,33 +1419,33 @@ class C {
|
|
|
1413
1419
|
};
|
|
1414
1420
|
return c.fire("editor:object-exported", v), v;
|
|
1415
1421
|
}
|
|
1416
|
-
var
|
|
1417
|
-
|
|
1422
|
+
var N = l.toCanvasElement(), b = yield new Promise((y) => {
|
|
1423
|
+
N.toBlob(y);
|
|
1418
1424
|
});
|
|
1419
1425
|
if (s) {
|
|
1420
|
-
var
|
|
1421
|
-
image:
|
|
1426
|
+
var I = {
|
|
1427
|
+
image: b,
|
|
1422
1428
|
format: d,
|
|
1423
1429
|
contentType: i,
|
|
1424
1430
|
fileName: r
|
|
1425
1431
|
};
|
|
1426
|
-
return c.fire("editor:object-exported",
|
|
1432
|
+
return c.fire("editor:object-exported", I), I;
|
|
1427
1433
|
}
|
|
1428
|
-
var
|
|
1434
|
+
var S = new File([b], r, {
|
|
1429
1435
|
type: i
|
|
1430
|
-
}),
|
|
1431
|
-
image:
|
|
1436
|
+
}), j = {
|
|
1437
|
+
image: S,
|
|
1432
1438
|
format: d,
|
|
1433
1439
|
contentType: i,
|
|
1434
1440
|
fileName: r
|
|
1435
1441
|
};
|
|
1436
|
-
return c.fire("editor:object-exported",
|
|
1437
|
-
} catch (
|
|
1442
|
+
return c.fire("editor:object-exported", j), j;
|
|
1443
|
+
} catch (y) {
|
|
1438
1444
|
return t.editor.errorManager.emitError({
|
|
1439
1445
|
origin: "ImageManager",
|
|
1440
1446
|
method: "exportObjectAsImageFile",
|
|
1441
1447
|
code: "IMAGE_EXPORT_FAILED",
|
|
1442
|
-
message: "Ошибка экспорта объекта: ".concat(
|
|
1448
|
+
message: "Ошибка экспорта объекта: ".concat(y.message),
|
|
1443
1449
|
data: {
|
|
1444
1450
|
contentType: i,
|
|
1445
1451
|
fileName: r,
|
|
@@ -1485,7 +1491,7 @@ class C {
|
|
|
1485
1491
|
* @returns {string[]} - массив допустимых форматов изображений
|
|
1486
1492
|
*/
|
|
1487
1493
|
getAllowedFormatsFromContentTypes() {
|
|
1488
|
-
return this.acceptContentTypes.map((e) =>
|
|
1494
|
+
return this.acceptContentTypes.map((e) => L.getFormatFromContentType(e)).filter((e) => e);
|
|
1489
1495
|
}
|
|
1490
1496
|
/**
|
|
1491
1497
|
* Извлекает чистый формат (subtype) из contentType,
|
|
@@ -1554,7 +1560,7 @@ class C {
|
|
|
1554
1560
|
try {
|
|
1555
1561
|
var t, a = new URL(e), r = (t = a.pathname.split(".").pop()) === null || t === void 0 ? void 0 : t.toLowerCase(), i = {};
|
|
1556
1562
|
return this.acceptContentTypes.forEach((n) => {
|
|
1557
|
-
var s =
|
|
1563
|
+
var s = L.getFormatFromContentType(n);
|
|
1558
1564
|
s && (i[s] = n);
|
|
1559
1565
|
}), i[r] || "application/octet-stream";
|
|
1560
1566
|
} catch (n) {
|
|
@@ -1630,9 +1636,9 @@ class jt {
|
|
|
1630
1636
|
}
|
|
1631
1637
|
var {
|
|
1632
1638
|
left: g,
|
|
1633
|
-
top:
|
|
1634
|
-
} = this.getObjectDefaultCoords(n),
|
|
1635
|
-
i.setViewportTransform([
|
|
1639
|
+
top: M
|
|
1640
|
+
} = this.getObjectDefaultCoords(n), m = i.getZoom();
|
|
1641
|
+
i.setViewportTransform([m, 0, 0, m, g, M]), this.centerMontageArea(), a || this.editor.historyManager.saveState(), i == null || i.fire("editor:resolution-width-changed", {
|
|
1636
1642
|
width: e
|
|
1637
1643
|
});
|
|
1638
1644
|
}
|
|
@@ -1674,9 +1680,9 @@ class jt {
|
|
|
1674
1680
|
}
|
|
1675
1681
|
var {
|
|
1676
1682
|
left: g,
|
|
1677
|
-
top:
|
|
1678
|
-
} = this.getObjectDefaultCoords(n),
|
|
1679
|
-
i.setViewportTransform([
|
|
1683
|
+
top: M
|
|
1684
|
+
} = this.getObjectDefaultCoords(n), m = i.getZoom();
|
|
1685
|
+
i.setViewportTransform([m, 0, 0, m, g, M]), this.centerMontageArea(), a || this.editor.historyManager.saveState(), i == null || i.fire("editor:resolution-height-changed", {
|
|
1680
1686
|
height: e
|
|
1681
1687
|
});
|
|
1682
1688
|
}
|
|
@@ -1931,16 +1937,20 @@ class jt {
|
|
|
1931
1937
|
} = u, h = Math.min(l, E), g = Math.min(d, T);
|
|
1932
1938
|
if (t) {
|
|
1933
1939
|
var {
|
|
1934
|
-
width:
|
|
1935
|
-
height:
|
|
1936
|
-
} = i, f = l /
|
|
1937
|
-
h =
|
|
1940
|
+
width: M,
|
|
1941
|
+
height: m
|
|
1942
|
+
} = i, f = l / M, v = d / m, N = Math.max(f, v);
|
|
1943
|
+
h = M * N, g = m * N;
|
|
1938
1944
|
}
|
|
1939
|
-
this.setResolutionWidth(h, {
|
|
1945
|
+
if (this.setResolutionWidth(h, {
|
|
1940
1946
|
withoutSave: !0
|
|
1941
1947
|
}), this.setResolutionHeight(g, {
|
|
1942
1948
|
withoutSave: !0
|
|
1943
|
-
}),
|
|
1949
|
+
}), l > s || d > c) {
|
|
1950
|
+
var b = r.editorContainer, I = b.clientWidth, S = b.clientHeight * 0.5, j = Math.min(s, S), y = Math.min(c, I);
|
|
1951
|
+
n.calculateAndApplyDefaultZoom(j, y);
|
|
1952
|
+
}
|
|
1953
|
+
n.resetObject(u, {
|
|
1944
1954
|
withoutSave: !0
|
|
1945
1955
|
}), r.centerObject(u), r.renderAll(), a || this.editor.historyManager.saveState(), r.fire("editor:canvas-scaled", {
|
|
1946
1956
|
width: h,
|
|
@@ -2194,7 +2204,7 @@ class yt {
|
|
|
2194
2204
|
historyManager: s
|
|
2195
2205
|
} = this.editor, c = e || i.getActiveObject();
|
|
2196
2206
|
if (c) {
|
|
2197
|
-
if (["activeselection"].includes(c.type) && !r) {
|
|
2207
|
+
if (c.set("angle", 0), ["activeselection"].includes(c.type) && !r) {
|
|
2198
2208
|
var u = c.getObjects();
|
|
2199
2209
|
i.discardActiveObject(), u.forEach((h) => {
|
|
2200
2210
|
var g = n.calculateScaleFactor({
|
|
@@ -2230,7 +2240,9 @@ class yt {
|
|
|
2230
2240
|
/**
|
|
2231
2241
|
* Сброс масштаба объекта до дефолтного
|
|
2232
2242
|
* @param {fabric.Object} object
|
|
2233
|
-
* @param {
|
|
2243
|
+
* @param {Object} options
|
|
2244
|
+
* @param {Boolean} [options.withoutSave] - Не сохранять состояние
|
|
2245
|
+
* @param {Boolean} [options.alwaysFitObject] - вписывать объект в рабочую область даже если он меньше рабочей области
|
|
2234
2246
|
* @returns
|
|
2235
2247
|
* @fires editor:object-reset
|
|
2236
2248
|
*/
|
|
@@ -2248,31 +2260,35 @@ class yt {
|
|
|
2248
2260
|
}
|
|
2249
2261
|
} = this.editor, u = e || r.getActiveObject();
|
|
2250
2262
|
if (!(!u || u.locked)) {
|
|
2251
|
-
|
|
2263
|
+
s.suspendHistory();
|
|
2264
|
+
var l = u.type === "image" || u.format === "svg";
|
|
2265
|
+
if (l || u.set({
|
|
2252
2266
|
scaleX: 1,
|
|
2253
2267
|
scaleY: 1,
|
|
2254
2268
|
flipX: !1,
|
|
2255
2269
|
flipY: !1,
|
|
2256
2270
|
angle: 0
|
|
2257
|
-
}),
|
|
2271
|
+
}), t)
|
|
2258
2272
|
this.fitObject({
|
|
2259
2273
|
object: u,
|
|
2260
|
-
withoutSave: !0
|
|
2274
|
+
withoutSave: !0,
|
|
2275
|
+
fitAsOneObject: !0
|
|
2261
2276
|
});
|
|
2262
2277
|
else {
|
|
2263
2278
|
var {
|
|
2264
|
-
width:
|
|
2265
|
-
height:
|
|
2279
|
+
width: d,
|
|
2280
|
+
height: h
|
|
2266
2281
|
} = i, {
|
|
2267
|
-
width:
|
|
2268
|
-
height:
|
|
2282
|
+
width: g,
|
|
2283
|
+
height: M
|
|
2269
2284
|
} = u, m = n.calculateScaleFactor({
|
|
2270
2285
|
imageObject: u,
|
|
2271
2286
|
scaleType: c
|
|
2272
|
-
});
|
|
2273
|
-
|
|
2287
|
+
}), f = c === "contain" && m < 1 || c === "cover" && (g > d || M > h);
|
|
2288
|
+
f ? this.fitObject({
|
|
2274
2289
|
object: u,
|
|
2275
|
-
withoutSave: !0
|
|
2290
|
+
withoutSave: !0,
|
|
2291
|
+
fitAsOneObject: !0
|
|
2276
2292
|
}) : u.set({
|
|
2277
2293
|
scaleX: 1,
|
|
2278
2294
|
scaleY: 1
|
|
@@ -2562,7 +2578,7 @@ class bt {
|
|
|
2562
2578
|
"height",
|
|
2563
2579
|
"fill"
|
|
2564
2580
|
]);
|
|
2565
|
-
const { canvas: h } = this.editor, g = new Ze(
|
|
2581
|
+
const { canvas: h } = this.editor, g = new Ze(w({
|
|
2566
2582
|
id: e,
|
|
2567
2583
|
left: t,
|
|
2568
2584
|
top: a,
|
|
@@ -2602,7 +2618,7 @@ class bt {
|
|
|
2602
2618
|
"radius",
|
|
2603
2619
|
"fill"
|
|
2604
2620
|
]);
|
|
2605
|
-
const { canvas: d } = this.editor, h = new ze(
|
|
2621
|
+
const { canvas: d } = this.editor, h = new ze(w({
|
|
2606
2622
|
id: e,
|
|
2607
2623
|
left: t,
|
|
2608
2624
|
top: a,
|
|
@@ -2644,7 +2660,7 @@ class bt {
|
|
|
2644
2660
|
"height",
|
|
2645
2661
|
"fill"
|
|
2646
2662
|
]);
|
|
2647
|
-
const { canvas: h } = this.editor, g = new Ue(
|
|
2663
|
+
const { canvas: h } = this.editor, g = new Ue(w({
|
|
2648
2664
|
id: e,
|
|
2649
2665
|
left: t,
|
|
2650
2666
|
top: a,
|
|
@@ -3035,7 +3051,7 @@ class K {
|
|
|
3035
3051
|
message: n,
|
|
3036
3052
|
data: r
|
|
3037
3053
|
};
|
|
3038
|
-
this._buffer.push(
|
|
3054
|
+
this._buffer.push(w({
|
|
3039
3055
|
type: "editor:error"
|
|
3040
3056
|
}, s)), this.editor.canvas.fire("editor:error", s);
|
|
3041
3057
|
}
|
|
@@ -3063,7 +3079,7 @@ class K {
|
|
|
3063
3079
|
message: n,
|
|
3064
3080
|
data: i
|
|
3065
3081
|
};
|
|
3066
|
-
this._buffer.push(
|
|
3082
|
+
this._buffer.push(w({
|
|
3067
3083
|
type: "editor:warning"
|
|
3068
3084
|
}, s)), this.editor.canvas.fire("editor:warning", s);
|
|
3069
3085
|
}
|
|
@@ -3096,7 +3112,7 @@ class ue {
|
|
|
3096
3112
|
scaleType: u,
|
|
3097
3113
|
_onReadyCallback: l
|
|
3098
3114
|
} = this.options;
|
|
3099
|
-
if (qe.apply(), this.canvas = new He(this.containerId, this.options), this.moduleLoader = new We(), this.workerManager = new Fe(), this.errorManager = new K({ editor: this }), this.historyManager = new gt({ editor: this }), this.toolbar = new ht({ editor: this }), this.transformManager = new yt({ editor: this }), this.canvasManager = new jt({ editor: this }), this.imageManager = new
|
|
3115
|
+
if (qe.apply(), this.canvas = new He(this.containerId, this.options), this.moduleLoader = new We(), this.workerManager = new Fe(), this.errorManager = new K({ editor: this }), this.historyManager = new gt({ editor: this }), this.toolbar = new ht({ editor: this }), this.transformManager = new yt({ editor: this }), this.canvasManager = new jt({ editor: this }), this.imageManager = new L({ editor: this }), this.layerManager = new J({ editor: this }), this.shapeManager = new bt({ editor: this }), this.interactionBlocker = new pt({ editor: this }), this.clipboardManager = new It({ editor: this }), this.objectLockManager = new St({ editor: this }), this.groupingManager = new At({ editor: this }), this.selectionManager = new Ct({ editor: this }), this.deletionManager = new Dt({ editor: this }), this._createMontageArea(), this._createClippingArea(), this.listeners = new P({ editor: this, options: this.options }), this.canvasManager.setEditorContainerWidth(e), this.canvasManager.setEditorContainerHeight(t), this.canvasManager.setCanvasWrapperWidth(a), this.canvasManager.setCanvasWrapperHeight(r), this.canvasManager.setCanvasCSSWidth(i), this.canvasManager.setCanvasCSSHeight(n), s != null && s.source) {
|
|
3100
3116
|
const {
|
|
3101
3117
|
source: d,
|
|
3102
3118
|
scale: h = `image-${u}`,
|
|
@@ -3172,7 +3188,6 @@ const wt = {
|
|
|
3172
3188
|
*/
|
|
3173
3189
|
preserveObjectStacking: !0,
|
|
3174
3190
|
controlsAboveOverlay: !0,
|
|
3175
|
-
centeredScaling: !0,
|
|
3176
3191
|
centeredRotation: !0,
|
|
3177
3192
|
/*
|
|
3178
3193
|
* Кастомные опции
|
|
@@ -3256,7 +3271,7 @@ const wt = {
|
|
|
3256
3271
|
resetObjectFitByDoubleClick: !0
|
|
3257
3272
|
};
|
|
3258
3273
|
function Ot(o, e = {}) {
|
|
3259
|
-
const t =
|
|
3274
|
+
const t = w(w({}, wt), e), a = document.getElementById(o);
|
|
3260
3275
|
if (!a)
|
|
3261
3276
|
return Promise.reject(new Error(`Контейнер с ID "${o}" не найден.`));
|
|
3262
3277
|
const r = document.createElement("canvas");
|
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.38",
|
|
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": [
|