@anu3ev/fabric-image-editor 0.1.65 → 0.1.66
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 +143 -137
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
1
|
+
var ye = Object.defineProperty, pe = Object.defineProperties;
|
|
2
|
+
var Ie = Object.getOwnPropertyDescriptors;
|
|
3
3
|
var Y = Object.getOwnPropertySymbols;
|
|
4
|
-
var
|
|
5
|
-
var
|
|
4
|
+
var le = Object.prototype.hasOwnProperty, he = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var de = (r, e, t) => e in r ? ye(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, y = (r, e) => {
|
|
6
6
|
for (var t in e || (e = {}))
|
|
7
|
-
|
|
7
|
+
le.call(e, t) && de(r, t, e[t]);
|
|
8
8
|
if (Y)
|
|
9
9
|
for (var t of Y(e))
|
|
10
|
-
|
|
10
|
+
he.call(e, t) && de(r, t, e[t]);
|
|
11
11
|
return r;
|
|
12
|
-
},
|
|
12
|
+
}, ge = (r, e) => pe(r, Ie(e));
|
|
13
13
|
var _ = (r, e) => {
|
|
14
14
|
var t = {};
|
|
15
15
|
for (var s in r)
|
|
16
|
-
|
|
16
|
+
le.call(r, s) && e.indexOf(s) < 0 && (t[s] = r[s]);
|
|
17
17
|
if (r != null && Y)
|
|
18
18
|
for (var s of Y(r))
|
|
19
|
-
e.indexOf(s) < 0 &&
|
|
19
|
+
e.indexOf(s) < 0 && he.call(r, s) && (t[s] = r[s]);
|
|
20
20
|
return t;
|
|
21
21
|
};
|
|
22
22
|
var v = (r, e, t) => new Promise((s, n) => {
|
|
@@ -35,15 +35,15 @@ var v = (r, e, t) => new Promise((s, n) => {
|
|
|
35
35
|
}, o = (d) => d.done ? s(d.value) : Promise.resolve(d.value).then(i, a);
|
|
36
36
|
o((t = t.apply(r, e)).next());
|
|
37
37
|
});
|
|
38
|
-
import { ActiveSelection as p, util as H, controlsUtils as
|
|
39
|
-
import { create as
|
|
40
|
-
import
|
|
41
|
-
var
|
|
38
|
+
import { ActiveSelection as p, util as H, controlsUtils as ve, InteractiveFabricObject as Ae, loadSVGFromURL as Se, FabricImage as R, Point as P, Rect as Ce, Circle as Ne, Triangle as De, Group as J, Canvas as Le, Pattern as we } from "fabric";
|
|
39
|
+
import { create as Ee } from "jsondiffpatch";
|
|
40
|
+
import Oe from "diff-match-patch";
|
|
41
|
+
var Te = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", L = 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 += Te[s[e] & 63];
|
|
44
44
|
return t;
|
|
45
45
|
};
|
|
46
|
-
class
|
|
46
|
+
class z {
|
|
47
47
|
/**
|
|
48
48
|
* Конструктор принимает редактор и опции.
|
|
49
49
|
* @param params
|
|
@@ -61,7 +61,7 @@ class R {
|
|
|
61
61
|
* @param params.options.adaptCanvasToContainerOnResize — адаптировать канвас к размерам контейнера при изменении размеров окна
|
|
62
62
|
*/
|
|
63
63
|
constructor({ editor: e, options: t = {} }) {
|
|
64
|
-
this.isDragging = !1, this.lastMouseX = 0, this.lastMouseY = 0, this.isUndoRedoKeyPressed = !1, this.isSpacePressed = !1, this.savedSelection = [], this.canvasDragging = !1, this.mouseWheelZooming = !1, this.bringToFrontOnSelection = !1, this.resetObjectFitByDoubleClick = !1, this.copyObjectsByHotkey = !1, this.pasteImageFromClipboard = !1, this.undoRedoByHotKeys = !1, this.selectAllByHotkey = !1, this.deleteObjectsByHotkey = !1, this.adaptCanvasToContainerOnResize = !1, this.editor = e, this.canvas = e.canvas, this.options = t, this.handleContainerResizeBound =
|
|
64
|
+
this.isDragging = !1, this.lastMouseX = 0, this.lastMouseY = 0, this.isUndoRedoKeyPressed = !1, this.isSpacePressed = !1, this.savedSelection = [], this.canvasDragging = !1, this.mouseWheelZooming = !1, this.bringToFrontOnSelection = !1, this.resetObjectFitByDoubleClick = !1, this.copyObjectsByHotkey = !1, this.pasteImageFromClipboard = !1, this.undoRedoByHotKeys = !1, this.selectAllByHotkey = !1, this.deleteObjectsByHotkey = !1, this.adaptCanvasToContainerOnResize = !1, this.editor = e, this.canvas = e.canvas, this.options = t, this.handleContainerResizeBound = z.debounce(this.handleContainerResize.bind(this), 500), this.handleCopyEventBound = this.handleCopyEvent.bind(this), this.handlePasteEventBound = this.handlePasteEvent.bind(this), this.handleUndoRedoEventBound = this.handleUndoRedoEvent.bind(this), this.handleUndoRedoKeyUpBound = this.handleUndoRedoKeyUp.bind(this), this.handleSelectAllEventBound = this.handleSelectAllEvent.bind(this), this.handleDeleteObjectsEventBound = this.handleDeleteObjectsEvent.bind(this), this.handleSpaceKeyDownBound = this.handleSpaceKeyDown.bind(this), this.handleSpaceKeyUpBound = this.handleSpaceKeyUp.bind(this), this.handleObjectModifiedHistoryBound = z.debounce(this.handleObjectModifiedHistory.bind(this), 300), this.handleObjectRotatingHistoryBound = z.debounce(this.handleObjectRotatingHistory.bind(this), 300), this.handleObjectAddedHistoryBound = this.handleObjectAddedHistory.bind(this), this.handleObjectRemovedHistoryBound = this.handleObjectRemovedHistory.bind(this), this.handleOverlayUpdateBound = this.handleOverlayUpdate.bind(this), this.handleCanvasDragStartBound = this.handleCanvasDragStart.bind(this), this.handleCanvasDraggingBound = this.handleCanvasDragging.bind(this), this.handleCanvasDragEndBound = this.handleCanvasDragEnd.bind(this), this.handleMouseWheelZoomBound = this.handleMouseWheelZoom.bind(this), this.handleBringToFrontBound = this.handleBringToFront.bind(this), this.handleResetObjectFitBound = this.handleResetObjectFit.bind(this), this.handleLockedSelectionBound = this._filterLockedSelection.bind(this), this.init();
|
|
65
65
|
}
|
|
66
66
|
/**
|
|
67
67
|
* Инициализация всех обработчиков согласно опциям.
|
|
@@ -364,7 +364,7 @@ class R {
|
|
|
364
364
|
};
|
|
365
365
|
}
|
|
366
366
|
}
|
|
367
|
-
class
|
|
367
|
+
class ke {
|
|
368
368
|
/**
|
|
369
369
|
* Класс для динамической загрузки внешних модулей.
|
|
370
370
|
*/
|
|
@@ -382,7 +382,7 @@ class Te {
|
|
|
382
382
|
return this.loaders[e] ? (this.cache.has(e) || this.cache.set(e, this.loaders[e]()), this.cache.get(e)) : Promise.reject(new Error(`Unknown module "${e}"`));
|
|
383
383
|
}
|
|
384
384
|
}
|
|
385
|
-
function
|
|
385
|
+
function xe(r) {
|
|
386
386
|
return new Worker(
|
|
387
387
|
"" + new URL("assets/worker-CN39s7P7.js", import.meta.url).href,
|
|
388
388
|
{
|
|
@@ -390,13 +390,13 @@ function ke(r) {
|
|
|
390
390
|
}
|
|
391
391
|
);
|
|
392
392
|
}
|
|
393
|
-
class
|
|
393
|
+
class Be {
|
|
394
394
|
/**
|
|
395
395
|
* @param scriptUrl — URL скрипта воркера.
|
|
396
396
|
* По-умолчанию использует DefaultWorker из соседнего файла
|
|
397
397
|
*/
|
|
398
398
|
constructor(e) {
|
|
399
|
-
e ? this.worker = new Worker(e, { type: "module" }) : this.worker = new
|
|
399
|
+
e ? this.worker = new Worker(e, { type: "module" }) : this.worker = new xe(), this._callbacks = /* @__PURE__ */ new Map(), this.worker.onmessage = this._handleMessage.bind(this);
|
|
400
400
|
}
|
|
401
401
|
/**
|
|
402
402
|
* Обработчик сообщений от воркера
|
|
@@ -436,26 +436,26 @@ class xe {
|
|
|
436
436
|
this.worker.terminate();
|
|
437
437
|
}
|
|
438
438
|
}
|
|
439
|
-
const N = 12,
|
|
439
|
+
const N = 12, Ue = 2, K = 8, q = 20, Re = 100, ee = 20, te = 8, Ze = 100, F = 32, se = 1, ze = "#2B2D33", ne = "#3D8BF4", ie = "#FFFFFF";
|
|
440
440
|
function W(r, e, t, s, n) {
|
|
441
|
-
const i = N, a =
|
|
442
|
-
r.save(), r.translate(e, t), r.rotate(H.degreesToRadians(n.angle)), r.fillStyle =
|
|
443
|
-
}
|
|
444
|
-
function ge(r, e, t, s, n) {
|
|
445
|
-
const i = J, a = K, o = Ue;
|
|
446
|
-
r.save(), r.translate(e, t), r.rotate(H.degreesToRadians(n.angle)), r.fillStyle = ne, r.strokeStyle = se, r.lineWidth = te, r.beginPath(), r.roundRect(-i / 2, -a / 2, i, a, o), r.fill(), r.stroke(), r.restore();
|
|
441
|
+
const i = N, a = Ue;
|
|
442
|
+
r.save(), r.translate(e, t), r.rotate(H.degreesToRadians(n.angle)), r.fillStyle = ie, r.strokeStyle = ne, r.lineWidth = se, r.beginPath(), r.roundRect(-i / 2, -i / 2, i, i, a), r.fill(), r.stroke(), r.restore();
|
|
447
443
|
}
|
|
448
444
|
function ue(r, e, t, s, n) {
|
|
449
|
-
const i =
|
|
450
|
-
r.save(), r.translate(e, t), r.rotate(H.degreesToRadians(n.angle)), r.fillStyle =
|
|
445
|
+
const i = K, a = q, o = Re;
|
|
446
|
+
r.save(), r.translate(e, t), r.rotate(H.degreesToRadians(n.angle)), r.fillStyle = ie, r.strokeStyle = ne, r.lineWidth = se, r.beginPath(), r.roundRect(-i / 2, -a / 2, i, a, o), r.fill(), r.stroke(), r.restore();
|
|
447
|
+
}
|
|
448
|
+
function Me(r, e, t, s, n) {
|
|
449
|
+
const i = ee, a = te, o = Ze;
|
|
450
|
+
r.save(), r.translate(e, t), r.rotate(H.degreesToRadians(n.angle)), r.fillStyle = ie, r.strokeStyle = ne, r.lineWidth = se, r.beginPath(), r.roundRect(-i / 2, -a / 2, i, a, o), r.fill(), r.stroke(), r.restore();
|
|
451
451
|
}
|
|
452
|
-
const
|
|
453
|
-
|
|
454
|
-
function
|
|
452
|
+
const He = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTE4Ljc1IDQuMzc1djMuNzVhLjYyNS42MjUgMCAwIDEtLjYyNS42MjVoLTMuNzVhLjYyNS42MjUgMCAwIDEgMC0xLjI1aDIuMTRsLTIuMDc3LTEuOTAzLS4wMi0uMDE5YTYuMjUgNi4yNSAwIDEgMC0uMTMgOC45NjcuNjI2LjYyNiAwIDAgMSAuODYuOTA5QTcuNDU2IDcuNDU2IDAgMCAxIDEwIDE3LjVoLS4xMDNhNy41IDcuNSAwIDEgMSA1LjM5Ni0xMi44MTJMMTcuNSA2LjcwM1Y0LjM3NWEuNjI1LjYyNSAwIDAgMSAxLjI1IDBaIi8+PC9zdmc+", fe = new Image();
|
|
453
|
+
fe.src = He;
|
|
454
|
+
function Ye(r, e, t, s, n) {
|
|
455
455
|
const a = F / 2;
|
|
456
|
-
r.save(), r.translate(e, t), r.rotate(H.degreesToRadians(n.angle)), r.fillStyle = ze, r.beginPath(), r.arc(0, 0, a, 0, 2 * Math.PI), r.fill(), r.drawImage(
|
|
456
|
+
r.save(), r.translate(e, t), r.rotate(H.degreesToRadians(n.angle)), r.fillStyle = ze, r.beginPath(), r.arc(0, 0, a, 0, 2 * Math.PI), r.fill(), r.drawImage(fe, -a / 2, -a / 2, a, a), r.restore();
|
|
457
457
|
}
|
|
458
|
-
const
|
|
458
|
+
const _e = {
|
|
459
459
|
// Угловые точки
|
|
460
460
|
tl: {
|
|
461
461
|
render: W,
|
|
@@ -487,47 +487,47 @@ const Ye = {
|
|
|
487
487
|
},
|
|
488
488
|
// Середина вертикалей
|
|
489
489
|
ml: {
|
|
490
|
-
render:
|
|
491
|
-
sizeX:
|
|
492
|
-
sizeY:
|
|
490
|
+
render: ue,
|
|
491
|
+
sizeX: K,
|
|
492
|
+
sizeY: q,
|
|
493
493
|
offsetX: 0,
|
|
494
494
|
offsetY: 0
|
|
495
495
|
},
|
|
496
496
|
mr: {
|
|
497
|
-
render:
|
|
498
|
-
sizeX:
|
|
499
|
-
sizeY:
|
|
497
|
+
render: ue,
|
|
498
|
+
sizeX: K,
|
|
499
|
+
sizeY: q,
|
|
500
500
|
offsetX: 0,
|
|
501
501
|
offsetY: 0
|
|
502
502
|
},
|
|
503
503
|
// Середина горизонталей
|
|
504
504
|
mt: {
|
|
505
|
-
render:
|
|
506
|
-
sizeX:
|
|
507
|
-
sizeY:
|
|
505
|
+
render: Me,
|
|
506
|
+
sizeX: ee,
|
|
507
|
+
sizeY: te,
|
|
508
508
|
offsetX: 0,
|
|
509
509
|
offsetY: 0
|
|
510
510
|
},
|
|
511
511
|
mb: {
|
|
512
|
-
render:
|
|
513
|
-
sizeX:
|
|
514
|
-
sizeY:
|
|
512
|
+
render: Me,
|
|
513
|
+
sizeX: ee,
|
|
514
|
+
sizeY: te,
|
|
515
515
|
offsetX: 0,
|
|
516
516
|
offsetY: 0
|
|
517
517
|
},
|
|
518
518
|
// Специальный «rotate» контрол
|
|
519
519
|
mtr: {
|
|
520
|
-
render:
|
|
520
|
+
render: Ye,
|
|
521
521
|
sizeX: F,
|
|
522
522
|
sizeY: F,
|
|
523
523
|
offsetX: 0,
|
|
524
524
|
offsetY: -F
|
|
525
525
|
}
|
|
526
526
|
};
|
|
527
|
-
class
|
|
527
|
+
class We {
|
|
528
528
|
static apply() {
|
|
529
|
-
const e =
|
|
530
|
-
Object.entries(
|
|
529
|
+
const e = ve.createObjectDefaultControls();
|
|
530
|
+
Object.entries(_e).forEach(([t, s]) => {
|
|
531
531
|
Object.assign(e[t], {
|
|
532
532
|
render: s.render,
|
|
533
533
|
sizeX: s.sizeX,
|
|
@@ -538,10 +538,10 @@ class _e {
|
|
|
538
538
|
var l;
|
|
539
539
|
(l = a.target.canvas) == null || l.setCursor("grabbing");
|
|
540
540
|
});
|
|
541
|
-
}),
|
|
541
|
+
}), Ae.ownDefaults.controls = e;
|
|
542
542
|
}
|
|
543
543
|
}
|
|
544
|
-
const
|
|
544
|
+
const Pe = "data:image/svg+x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MyAwbC0zLjk3LTIuMzE2TDMuNzQgMTBaIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiLz48L3N2Zz4=", Je = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI0VDNEU0MCIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNOC4xMjUgMS4yNUExLjg3NSAxLjg3NSAwIDAgMCA2LjI1IDMuMTI1di42MjVIMy4xMjVhLjYyNS42MjUgMCAwIDAgMCAxLjI1aC42MjV2MTEuMjVBMS4yNSAxLjI1IDAgMCAwIDUgMTcuNWgxMGExLjI1IDEuMjUgMCAwIDAgMS4yNS0xLjI1VjVoLjYyNWEuNjI1LjYyNSAwIDAgMCAwLTEuMjVIMTMuNzV2LS42MjVhMS44NzUgMS44NzUgMCAwIDAtMS44NzUtMS44NzVoLTMuNzVabTQuMzc1IDIuNXYtLjYyNWEuNjI1LjYyNSAwIDAgMC0uNjI1LS42MjVoLTMuNzVhLjYyNS42MjUgMCAwIDAtLjYyNS42MjV2LjYyNWg1Wk01IDE2LjI1VjVoMTB2MTEuMjVINVpNOC4xMjUgNy41Yy4zNDUgMCAuNjI1LjI4LjYyNS42MjV2NWEuNjI1LjYyNSAwIDEgMS0xLjI1IDB2LTVjMC0uMzQ1LjI4LS42MjUuNjI1LS42MjVabTQuMzc1IDUuNjI1di01YS42MjUuNjI1IDAgMCAwLTEuMjUgMHY1YS42MjUuNjI1IDAgMSAwIDEuMjUgMFoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPjwvc3ZnPg==", Z = {
|
|
545
545
|
style: {
|
|
546
546
|
position: "absolute",
|
|
547
547
|
display: "none",
|
|
@@ -608,14 +608,14 @@ const We = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMj
|
|
|
608
608
|
],
|
|
609
609
|
offsetTop: 50,
|
|
610
610
|
icons: {
|
|
611
|
-
copyPaste:
|
|
612
|
-
delete:
|
|
613
|
-
lock:
|
|
614
|
-
unlock:
|
|
615
|
-
bringToFront:
|
|
616
|
-
sendToBack:
|
|
617
|
-
bringForward:
|
|
618
|
-
sendBackwards:
|
|
611
|
+
copyPaste: Pe,
|
|
612
|
+
delete: Je,
|
|
613
|
+
lock: Fe,
|
|
614
|
+
unlock: Ve,
|
|
615
|
+
bringToFront: Qe,
|
|
616
|
+
sendToBack: $e,
|
|
617
|
+
bringForward: Ge,
|
|
618
|
+
sendBackwards: Xe
|
|
619
619
|
},
|
|
620
620
|
handlers: {
|
|
621
621
|
copyPaste: (r) => v(null, null, function* () {
|
|
@@ -646,18 +646,18 @@ const We = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMj
|
|
|
646
646
|
}
|
|
647
647
|
}
|
|
648
648
|
};
|
|
649
|
-
class
|
|
649
|
+
class Ke {
|
|
650
650
|
constructor({ editor: e }) {
|
|
651
651
|
this.currentTarget = null, this.currentLocked = !1, this.isTransforming = !1, this.editor = e, this.canvas = e.canvas, this.options = e.options, this._initToolbar();
|
|
652
652
|
}
|
|
653
653
|
_initToolbar() {
|
|
654
654
|
if (!this.options.showToolbar) return;
|
|
655
655
|
const e = this.options.toolbar || {};
|
|
656
|
-
this.config =
|
|
657
|
-
style: y(y({},
|
|
658
|
-
btnStyle: y(y({},
|
|
659
|
-
icons: y(y({},
|
|
660
|
-
handlers: y(y({},
|
|
656
|
+
this.config = ge(y(y({}, Z), e), {
|
|
657
|
+
style: y(y({}, Z.style), e.style || {}),
|
|
658
|
+
btnStyle: y(y({}, Z.btnStyle), e.btnStyle || {}),
|
|
659
|
+
icons: y(y({}, Z.icons), e.icons || {}),
|
|
660
|
+
handlers: y(y({}, Z.handlers), e.handlers || {})
|
|
661
661
|
}), this.currentTarget = null, this.currentLocked = !1, 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 = () => {
|
|
662
662
|
this.el.style.display = "none";
|
|
663
663
|
}, this._createDOM(), this._bindEvents();
|
|
@@ -762,7 +762,7 @@ class Je {
|
|
|
762
762
|
this.el.removeEventListener("mouseover", this._onBtnOver), this.el.removeEventListener("mouseout", this._onBtnOut), this.canvas.off("mouse:down", this._onMouseDown), this.canvas.off("object:moving", this._onObjectMoving), this.canvas.off("object:scaling", this._onObjectScaling), this.canvas.off("object:rotating", this._onObjectRotating), this.canvas.off("mouse:up", this._onMouseUp), this.canvas.off("object:modified", this._onObjectModified), this.canvas.off("selection:created", this._onSelectionChange), this.canvas.off("selection:updated", this._onSelectionChange), this.canvas.off("after:render", this._onSelectionChange), this.canvas.off("selection:cleared", this._onSelectionClear), this.el.remove();
|
|
763
763
|
}
|
|
764
764
|
}
|
|
765
|
-
class
|
|
765
|
+
class qe {
|
|
766
766
|
constructor({ editor: e }) {
|
|
767
767
|
this.editor = e, this.canvas = e.canvas, this._historySuspendCount = 0, this.baseState = null, this.patches = [], this.currentIndex = 0, this.maxHistoryLength = e.options.maxHistoryLength, this.totalChangesCount = 0, this.baseStateChangesCount = 0, this._createDiffPatcher();
|
|
768
768
|
}
|
|
@@ -774,7 +774,7 @@ class Ke {
|
|
|
774
774
|
return this.patches[this.currentIndex - 1] || null;
|
|
775
775
|
}
|
|
776
776
|
_createDiffPatcher() {
|
|
777
|
-
this.diffPatcher =
|
|
777
|
+
this.diffPatcher = Ee({
|
|
778
778
|
objectHash(e) {
|
|
779
779
|
const t = e;
|
|
780
780
|
return [
|
|
@@ -798,7 +798,7 @@ class Ke {
|
|
|
798
798
|
includeValueOnMove: !1
|
|
799
799
|
},
|
|
800
800
|
textDiff: {
|
|
801
|
-
diffMatchPatch:
|
|
801
|
+
diffMatchPatch: Oe,
|
|
802
802
|
minLength: 60
|
|
803
803
|
}
|
|
804
804
|
});
|
|
@@ -965,7 +965,7 @@ class Ke {
|
|
|
965
965
|
});
|
|
966
966
|
}
|
|
967
967
|
}
|
|
968
|
-
const
|
|
968
|
+
const et = 0.1, tt = 2, st = 0.1, nt = 90, B = 16, U = 16, O = 4096, T = 4096, $ = "application/image-editor:";
|
|
969
969
|
class D {
|
|
970
970
|
constructor({ editor: e }) {
|
|
971
971
|
this.editor = e, this.options = e.options, this._createdBlobUrls = [], this.acceptContentTypes = this.editor.options.acceptContentTypes, this.acceptFormats = this.getAllowedFormatsFromContentTypes();
|
|
@@ -1018,20 +1018,20 @@ class D {
|
|
|
1018
1018
|
data: { source: t, format: h, contentType: l, acceptContentTypes: g, acceptFormats: u }
|
|
1019
1019
|
}), null;
|
|
1020
1020
|
if (this._createdBlobUrls.push(m), h === "svg") {
|
|
1021
|
-
const b = yield
|
|
1021
|
+
const b = yield Se(m);
|
|
1022
1022
|
M = H.groupSVGElements(b.objects, b.options);
|
|
1023
1023
|
} else
|
|
1024
|
-
M = yield
|
|
1024
|
+
M = yield R.fromURL(m, { crossOrigin: "anonymous" });
|
|
1025
1025
|
const { width: f, height: j } = M;
|
|
1026
|
-
if (M instanceof
|
|
1026
|
+
if (M instanceof R) {
|
|
1027
1027
|
const b = M.getElement();
|
|
1028
1028
|
let S = "";
|
|
1029
1029
|
if (b instanceof HTMLImageElement ? S = b.src : b instanceof HTMLCanvasElement && (S = b.toDataURL()), j > T || f > O) {
|
|
1030
1030
|
const w = yield this.resizeImageToBoundaries(S, "max"), E = URL.createObjectURL(w);
|
|
1031
|
-
this._createdBlobUrls.push(E), M = yield
|
|
1031
|
+
this._createdBlobUrls.push(E), M = yield R.fromURL(E, { crossOrigin: "anonymous" });
|
|
1032
1032
|
} else if (j < U || f < B) {
|
|
1033
1033
|
const w = yield this.resizeImageToBoundaries(S, "min"), E = URL.createObjectURL(w);
|
|
1034
|
-
this._createdBlobUrls.push(E), M = yield
|
|
1034
|
+
this._createdBlobUrls.push(E), M = yield R.fromURL(E, { crossOrigin: "anonymous" });
|
|
1035
1035
|
}
|
|
1036
1036
|
}
|
|
1037
1037
|
if (M.set("id", `${M.type}-${L()}`), M.set("format", h), s === "scale-montage")
|
|
@@ -1152,27 +1152,27 @@ class D {
|
|
|
1152
1152
|
[S]
|
|
1153
1153
|
);
|
|
1154
1154
|
if (c) {
|
|
1155
|
-
const k = m * 0.264583, C = M * 0.264583,
|
|
1155
|
+
const k = m * 0.264583, C = M * 0.264583, je = (yield this.editor.moduleLoader.loadModule("jspdf")).jsPDF, Q = new je({
|
|
1156
1156
|
orientation: k > C ? "landscape" : "portrait",
|
|
1157
1157
|
unit: "mm",
|
|
1158
1158
|
format: [k, C]
|
|
1159
1159
|
});
|
|
1160
1160
|
if (Q.addImage(String(w), "JPG", 0, 0, k, C), n) {
|
|
1161
|
-
const
|
|
1161
|
+
const ce = {
|
|
1162
1162
|
image: Q.output("datauristring"),
|
|
1163
1163
|
format: "pdf",
|
|
1164
1164
|
contentType: "application/pdf",
|
|
1165
1165
|
fileName: t
|
|
1166
1166
|
};
|
|
1167
|
-
return a.fire("editor:canvas-exported",
|
|
1167
|
+
return a.fire("editor:canvas-exported", ce), ce;
|
|
1168
1168
|
}
|
|
1169
|
-
const
|
|
1170
|
-
image: new File([
|
|
1169
|
+
const be = Q.output("blob"), re = {
|
|
1170
|
+
image: new File([be], t, { type: "application/pdf" }),
|
|
1171
1171
|
format: "pdf",
|
|
1172
1172
|
contentType: "application/pdf",
|
|
1173
1173
|
fileName: t
|
|
1174
1174
|
};
|
|
1175
|
-
return a.fire("editor:canvas-exported",
|
|
1175
|
+
return a.fire("editor:canvas-exported", re), re;
|
|
1176
1176
|
}
|
|
1177
1177
|
if (n) {
|
|
1178
1178
|
const I = {
|
|
@@ -1183,13 +1183,13 @@ class D {
|
|
|
1183
1183
|
};
|
|
1184
1184
|
return a.fire("editor:canvas-exported", I), I;
|
|
1185
1185
|
}
|
|
1186
|
-
const E = h === "svg" && !A ? t.replace(/\.[^/.]+$/, ".png") : t,
|
|
1186
|
+
const E = h === "svg" && !A ? t.replace(/\.[^/.]+$/, ".png") : t, oe = {
|
|
1187
1187
|
image: new File([b], E, { type: l }),
|
|
1188
1188
|
format: h,
|
|
1189
1189
|
contentType: l,
|
|
1190
1190
|
fileName: E
|
|
1191
1191
|
};
|
|
1192
|
-
return a.fire("editor:canvas-exported",
|
|
1192
|
+
return a.fire("editor:canvas-exported", oe), oe;
|
|
1193
1193
|
} catch (c) {
|
|
1194
1194
|
return this.editor.errorManager.emitError({
|
|
1195
1195
|
origin: "ImageManager",
|
|
@@ -1245,7 +1245,7 @@ class D {
|
|
|
1245
1245
|
};
|
|
1246
1246
|
return o.fire("editor:object-exported", j), j;
|
|
1247
1247
|
}
|
|
1248
|
-
if (i && c instanceof
|
|
1248
|
+
if (i && c instanceof R) {
|
|
1249
1249
|
const M = yield createImageBitmap(c.getElement()), f = yield d.post(
|
|
1250
1250
|
"toDataURL",
|
|
1251
1251
|
{
|
|
@@ -1414,11 +1414,11 @@ class D {
|
|
|
1414
1414
|
return t ? t[1] : "";
|
|
1415
1415
|
}
|
|
1416
1416
|
}
|
|
1417
|
-
const x = (r, e, t) => Math.max(Math.min(r, t), e),
|
|
1418
|
-
function
|
|
1417
|
+
const x = (r, e, t) => Math.max(Math.min(r, t), e), me = (r, e) => r * e, it = (r, e) => new P(r / 2, e / 2);
|
|
1418
|
+
function at(r) {
|
|
1419
1419
|
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";
|
|
1420
1420
|
}
|
|
1421
|
-
class
|
|
1421
|
+
class ot {
|
|
1422
1422
|
/**
|
|
1423
1423
|
* @param options
|
|
1424
1424
|
* @param options.editor – экземпляр редактора
|
|
@@ -1451,7 +1451,7 @@ class at {
|
|
|
1451
1451
|
options: { canvasBackstoreWidth: o }
|
|
1452
1452
|
} = this.editor, { width: d, height: c } = a, l = x(Number(e), B, O);
|
|
1453
1453
|
if (!o || o === "auto" || n ? this.adaptCanvasToContainer() : o ? this.setCanvasBackstoreWidth(Number(o)) : this.setCanvasBackstoreWidth(l), a.set({ width: l }), (m = i.clipPath) == null || m.set({ width: l }), t) {
|
|
1454
|
-
const M = l / d, f =
|
|
1454
|
+
const M = l / d, f = me(c, M);
|
|
1455
1455
|
this.setResolutionHeight(f);
|
|
1456
1456
|
return;
|
|
1457
1457
|
}
|
|
@@ -1481,7 +1481,7 @@ class at {
|
|
|
1481
1481
|
options: { canvasBackstoreHeight: o }
|
|
1482
1482
|
} = this.editor, { width: d, height: c } = a, l = x(Number(e), U, T);
|
|
1483
1483
|
if (!o || o === "auto" || n ? this.adaptCanvasToContainer() : o ? this.setCanvasBackstoreHeight(Number(o)) : this.setCanvasBackstoreHeight(l), a.set({ height: l }), (m = i.clipPath) == null || m.set({ height: l }), t) {
|
|
1484
|
-
const M = l / c, f =
|
|
1484
|
+
const M = l / c, f = me(d, M);
|
|
1485
1485
|
this.setResolutionWidth(f);
|
|
1486
1486
|
return;
|
|
1487
1487
|
}
|
|
@@ -1499,7 +1499,7 @@ class at {
|
|
|
1499
1499
|
*/
|
|
1500
1500
|
centerMontageArea() {
|
|
1501
1501
|
var d;
|
|
1502
|
-
const { canvas: e, montageArea: t } = this.editor, s = e.getWidth(), n = e.getHeight(), i = e.getZoom(), a =
|
|
1502
|
+
const { canvas: e, montageArea: t } = this.editor, s = e.getWidth(), n = e.getHeight(), i = e.getZoom(), a = it(s, n);
|
|
1503
1503
|
t.set({
|
|
1504
1504
|
left: s / 2,
|
|
1505
1505
|
top: n / 2
|
|
@@ -1750,7 +1750,7 @@ class at {
|
|
|
1750
1750
|
montageAreaHeight: d
|
|
1751
1751
|
}
|
|
1752
1752
|
} = this.editor, c = e || n.getActiveObject();
|
|
1753
|
-
if (!
|
|
1753
|
+
if (!at(c)) return;
|
|
1754
1754
|
const { width: l, height: h } = c;
|
|
1755
1755
|
let g = Math.min(l, O), u = Math.min(h, T);
|
|
1756
1756
|
if (t) {
|
|
@@ -1803,9 +1803,9 @@ class at {
|
|
|
1803
1803
|
return e.getObjects().filter((i) => i.id !== t.id && i.id !== (s == null ? void 0 : s.id));
|
|
1804
1804
|
}
|
|
1805
1805
|
}
|
|
1806
|
-
class
|
|
1806
|
+
class rt {
|
|
1807
1807
|
constructor({ editor: e }) {
|
|
1808
|
-
this.editor = e, this.options = e.options, this.minZoom = this.options.minZoom ||
|
|
1808
|
+
this.editor = e, this.options = e.options, this.minZoom = this.options.minZoom || et, this.maxZoom = this.options.maxZoom || tt, this.defaultZoom = this.options.defaultScale, this.maxZoomFactor = this.options.maxZoomFactor;
|
|
1809
1809
|
}
|
|
1810
1810
|
/**
|
|
1811
1811
|
* Метод рассчитывает и применяет зум по умолчанию для монтажной области редактора.
|
|
@@ -1827,7 +1827,7 @@ class ot {
|
|
|
1827
1827
|
* @fires editor:zoom-changed
|
|
1828
1828
|
* Если передавать координаты курсора, то нужно быть аккуратнее, так как юзер может выйти за пределы рабочей области
|
|
1829
1829
|
*/
|
|
1830
|
-
zoom(e =
|
|
1830
|
+
zoom(e = st, t = {}) {
|
|
1831
1831
|
var g, u;
|
|
1832
1832
|
if (!e) return;
|
|
1833
1833
|
const { minZoom: s, maxZoom: n } = this, { canvas: i } = this.editor, a = i.getZoom(), o = i.getCenterPoint(), d = (g = t.pointX) != null ? g : o.x, c = (u = t.pointY) != null ? u : o.y, l = new P(d, c);
|
|
@@ -1870,7 +1870,7 @@ class ot {
|
|
|
1870
1870
|
* @param options.withoutSave - Не сохранять состояние
|
|
1871
1871
|
* @fires editor:object-rotated
|
|
1872
1872
|
*/
|
|
1873
|
-
rotate(e =
|
|
1873
|
+
rotate(e = nt, { withoutSave: t } = {}) {
|
|
1874
1874
|
const { canvas: s, historyManager: n } = this.editor, i = s.getActiveObject();
|
|
1875
1875
|
if (!i) return;
|
|
1876
1876
|
const a = i.angle + e;
|
|
@@ -2025,7 +2025,7 @@ class ot {
|
|
|
2025
2025
|
});
|
|
2026
2026
|
}
|
|
2027
2027
|
}
|
|
2028
|
-
class
|
|
2028
|
+
class ct {
|
|
2029
2029
|
constructor({ editor: e }) {
|
|
2030
2030
|
this.editor = e, this.isBlocked = !1, this.overlayMask = null, this._createOverlay();
|
|
2031
2031
|
}
|
|
@@ -2208,7 +2208,7 @@ class V {
|
|
|
2208
2208
|
});
|
|
2209
2209
|
}
|
|
2210
2210
|
}
|
|
2211
|
-
class
|
|
2211
|
+
class dt {
|
|
2212
2212
|
/**
|
|
2213
2213
|
* Менеджер фигур для редактора.
|
|
2214
2214
|
* @param options - Опции и настройки менеджера фигур.
|
|
@@ -2248,7 +2248,7 @@ class ct {
|
|
|
2248
2248
|
"height",
|
|
2249
2249
|
"fill"
|
|
2250
2250
|
]);
|
|
2251
|
-
const { canvas: g } = this.editor, u = new
|
|
2251
|
+
const { canvas: g } = this.editor, u = new Ce(y({
|
|
2252
2252
|
id: e,
|
|
2253
2253
|
left: t,
|
|
2254
2254
|
top: s,
|
|
@@ -2288,7 +2288,7 @@ class ct {
|
|
|
2288
2288
|
"radius",
|
|
2289
2289
|
"fill"
|
|
2290
2290
|
]);
|
|
2291
|
-
const { canvas: h } = this.editor, g = new
|
|
2291
|
+
const { canvas: h } = this.editor, g = new Ne(y({
|
|
2292
2292
|
id: e,
|
|
2293
2293
|
left: t,
|
|
2294
2294
|
top: s,
|
|
@@ -2330,7 +2330,7 @@ class ct {
|
|
|
2330
2330
|
"height",
|
|
2331
2331
|
"fill"
|
|
2332
2332
|
]);
|
|
2333
|
-
const { canvas: g } = this.editor, u = new
|
|
2333
|
+
const { canvas: g } = this.editor, u = new De(y({
|
|
2334
2334
|
id: e,
|
|
2335
2335
|
left: t,
|
|
2336
2336
|
top: s,
|
|
@@ -2341,7 +2341,7 @@ class ct {
|
|
|
2341
2341
|
return !t && !s && g.centerObject(u), c || (g.add(u), d || g.setActiveObject(u), g.renderAll()), u;
|
|
2342
2342
|
}
|
|
2343
2343
|
}
|
|
2344
|
-
class
|
|
2344
|
+
class lt {
|
|
2345
2345
|
/**
|
|
2346
2346
|
* @param options
|
|
2347
2347
|
* @param options.editor - экземпляр редактора с доступом к canvas
|
|
@@ -2381,7 +2381,7 @@ class dt {
|
|
|
2381
2381
|
return;
|
|
2382
2382
|
}
|
|
2383
2383
|
if (s.type !== "image") {
|
|
2384
|
-
const g =
|
|
2384
|
+
const g = `${$}${JSON.stringify(s.toObject(["format"]))}`;
|
|
2385
2385
|
navigator.clipboard.writeText(g).catch((u) => {
|
|
2386
2386
|
t.emitWarning({
|
|
2387
2387
|
origin: "ClipboardManager",
|
|
@@ -2398,11 +2398,16 @@ class dt {
|
|
|
2398
2398
|
c[g] = d.charCodeAt(g);
|
|
2399
2399
|
const l = new Blob([c.buffer], { type: a }), h = new ClipboardItem({ [a]: l });
|
|
2400
2400
|
navigator.clipboard.write([h]).catch((g) => {
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2401
|
+
const u = `${$}${JSON.stringify(s.toObject(["format"]))}`;
|
|
2402
|
+
navigator.clipboard.writeText(u).catch((m) => {
|
|
2403
|
+
t.emitError({
|
|
2404
|
+
origin: "ClipboardManager",
|
|
2405
|
+
method: "copy",
|
|
2406
|
+
code: "CLIPBOARD_WRITE_IMAGE_FAILED",
|
|
2407
|
+
// eslint-disable-next-line max-len
|
|
2408
|
+
message: `Ошибка записи изображения в буфер обмена: ${g.message}. Fallback также не удался: ${m.message}`,
|
|
2409
|
+
data: { originalError: g, fallbackError: m }
|
|
2410
|
+
});
|
|
2406
2411
|
});
|
|
2407
2412
|
});
|
|
2408
2413
|
});
|
|
@@ -2415,28 +2420,29 @@ class dt {
|
|
|
2415
2420
|
*/
|
|
2416
2421
|
handlePasteEvent(t) {
|
|
2417
2422
|
return v(this, arguments, function* ({ clipboardData: e }) {
|
|
2418
|
-
var
|
|
2419
|
-
if (!((
|
|
2423
|
+
var c;
|
|
2424
|
+
if (!((c = e == null ? void 0 : e.items) != null && c.length)) {
|
|
2425
|
+
this.paste();
|
|
2426
|
+
return;
|
|
2427
|
+
}
|
|
2420
2428
|
const s = e.getData("text/plain");
|
|
2421
|
-
if (s && s.startsWith(
|
|
2429
|
+
if (s && s.startsWith($)) {
|
|
2422
2430
|
this.paste();
|
|
2423
2431
|
return;
|
|
2424
2432
|
}
|
|
2425
|
-
const { imageManager: n } = this.editor, { items: i } = e, a = i[i.length - 1];
|
|
2426
|
-
if (a.type !== "text/html") {
|
|
2427
|
-
const c = a.getAsFile();
|
|
2428
|
-
if (!c) return;
|
|
2433
|
+
const { imageManager: n } = this.editor, { items: i } = e, a = i[i.length - 1], o = a.getAsFile();
|
|
2434
|
+
if (a.type !== "text/html" && o) {
|
|
2429
2435
|
const l = new FileReader();
|
|
2430
2436
|
l.onload = (h) => {
|
|
2431
2437
|
h.target && this.editor.imageManager.importImage({ source: h.target.result });
|
|
2432
|
-
}, l.readAsDataURL(
|
|
2438
|
+
}, l.readAsDataURL(o);
|
|
2433
2439
|
return;
|
|
2434
2440
|
}
|
|
2435
|
-
const
|
|
2436
|
-
if (
|
|
2437
|
-
const
|
|
2438
|
-
if (
|
|
2439
|
-
n.importImage({ source:
|
|
2441
|
+
const d = e.getData("text/html");
|
|
2442
|
+
if (d) {
|
|
2443
|
+
const g = new DOMParser().parseFromString(d, "text/html").querySelector("img");
|
|
2444
|
+
if (g != null && g.src) {
|
|
2445
|
+
n.importImage({ source: g.src });
|
|
2440
2446
|
return;
|
|
2441
2447
|
}
|
|
2442
2448
|
}
|
|
@@ -2524,10 +2530,10 @@ class G {
|
|
|
2524
2530
|
});
|
|
2525
2531
|
}
|
|
2526
2532
|
static _isGroupOrSelection(e) {
|
|
2527
|
-
return e instanceof p || e instanceof
|
|
2533
|
+
return e instanceof p || e instanceof J;
|
|
2528
2534
|
}
|
|
2529
2535
|
}
|
|
2530
|
-
class
|
|
2536
|
+
class ht {
|
|
2531
2537
|
constructor({ editor: e }) {
|
|
2532
2538
|
this.editor = e;
|
|
2533
2539
|
}
|
|
@@ -2546,7 +2552,7 @@ class lt {
|
|
|
2546
2552
|
n.suspendHistory();
|
|
2547
2553
|
const i = e || s.getActiveObject();
|
|
2548
2554
|
if (!i || !(i instanceof p)) return;
|
|
2549
|
-
const a = i.getObjects(), o = new
|
|
2555
|
+
const a = i.getObjects(), o = new J(a);
|
|
2550
2556
|
a.forEach((d) => s.remove(d)), o.set("id", `${o.type}-${L()}`), s.add(o), s.setActiveObject(o), s.renderAll(), n.resumeHistory(), t || n.saveState(), s.fire("editor:objects-grouped", {
|
|
2551
2557
|
object: i,
|
|
2552
2558
|
group: o,
|
|
@@ -2567,7 +2573,7 @@ class lt {
|
|
|
2567
2573
|
const { canvas: s, historyManager: n } = this.editor;
|
|
2568
2574
|
n.suspendHistory();
|
|
2569
2575
|
const i = e || s.getActiveObject();
|
|
2570
|
-
if (!(i instanceof
|
|
2576
|
+
if (!(i instanceof J)) return;
|
|
2571
2577
|
const a = i.removeAll();
|
|
2572
2578
|
s.remove(i), a.forEach((d) => s.add(d));
|
|
2573
2579
|
const o = new p(a, {
|
|
@@ -2580,7 +2586,7 @@ class lt {
|
|
|
2580
2586
|
});
|
|
2581
2587
|
}
|
|
2582
2588
|
}
|
|
2583
|
-
class
|
|
2589
|
+
class gt {
|
|
2584
2590
|
constructor({ editor: e }) {
|
|
2585
2591
|
this.editor = e;
|
|
2586
2592
|
}
|
|
@@ -2595,7 +2601,7 @@ class ht {
|
|
|
2595
2601
|
i && s.lockObject({ object: a, skipInnerObjects: !0, withoutSave: !0 }), e.setActiveObject(a), e.requestRenderAll(), e.fire("editor:all-objects-selected", { selected: a });
|
|
2596
2602
|
}
|
|
2597
2603
|
}
|
|
2598
|
-
class
|
|
2604
|
+
class ut {
|
|
2599
2605
|
constructor({ editor: e }) {
|
|
2600
2606
|
this.editor = e;
|
|
2601
2607
|
}
|
|
@@ -2623,7 +2629,7 @@ class gt {
|
|
|
2623
2629
|
}));
|
|
2624
2630
|
}
|
|
2625
2631
|
}
|
|
2626
|
-
const
|
|
2632
|
+
const Mt = {
|
|
2627
2633
|
IMAGE_MANAGER: {
|
|
2628
2634
|
/**
|
|
2629
2635
|
* Некорректный Content-Type изображения
|
|
@@ -2764,10 +2770,10 @@ class X {
|
|
|
2764
2770
|
* @returns true, если код допустим, иначе false
|
|
2765
2771
|
*/
|
|
2766
2772
|
static isValidErrorCode(e) {
|
|
2767
|
-
return e ? Object.values(
|
|
2773
|
+
return e ? Object.values(Mt).some((t) => Object.values(t).includes(e)) : !1;
|
|
2768
2774
|
}
|
|
2769
2775
|
}
|
|
2770
|
-
class
|
|
2776
|
+
class ae {
|
|
2771
2777
|
/**
|
|
2772
2778
|
* Конструктор класса ImageEditor.
|
|
2773
2779
|
* @param canvasId - идентификатор канваса, в котором будет создан редактор
|
|
@@ -2795,7 +2801,7 @@ class ie {
|
|
|
2795
2801
|
scaleType: c,
|
|
2796
2802
|
_onReadyCallback: l
|
|
2797
2803
|
} = this.options;
|
|
2798
|
-
if (
|
|
2804
|
+
if (We.apply(), this.canvas = new Le(this.containerId, this.options), this.moduleLoader = new ke(), this.workerManager = new Be(), this.errorManager = new X({ editor: this }), this.historyManager = new qe({ editor: this }), this.toolbar = new Ke({ editor: this }), this.transformManager = new rt({ editor: this }), this.canvasManager = new ot({ editor: this }), this.imageManager = new D({ editor: this }), this.layerManager = new V({ editor: this }), this.shapeManager = new dt({ editor: this }), this.interactionBlocker = new ct({ editor: this }), this.clipboardManager = new lt({ editor: this }), this.objectLockManager = new G({ editor: this }), this.groupingManager = new ht({ editor: this }), this.selectionManager = new gt({ editor: this }), this.deletionManager = new ut({ editor: this }), this._createMontageArea(), this._createClippingArea(), this.listeners = new z({ editor: this, options: this.options }), this.canvasManager.setEditorContainerWidth(e), this.canvasManager.setEditorContainerHeight(t), this.canvasManager.setCanvasWrapperWidth(s), this.canvasManager.setCanvasWrapperHeight(n), this.canvasManager.setCanvasCSSWidth(i), this.canvasManager.setCanvasCSSHeight(a), o != null && o.source) {
|
|
2799
2805
|
const {
|
|
2800
2806
|
source: h,
|
|
2801
2807
|
scale: g = `image-${c}`,
|
|
@@ -2818,7 +2824,7 @@ class ie {
|
|
|
2818
2824
|
this.montageArea = this.shapeManager.addRectangle({
|
|
2819
2825
|
width: e,
|
|
2820
2826
|
height: t,
|
|
2821
|
-
fill:
|
|
2827
|
+
fill: ae._createMosaicPattern(),
|
|
2822
2828
|
stroke: null,
|
|
2823
2829
|
strokeWidth: 0,
|
|
2824
2830
|
selectable: !1,
|
|
@@ -2868,13 +2874,13 @@ class ie {
|
|
|
2868
2874
|
const e = document.createElement("canvas");
|
|
2869
2875
|
e.width = 20, e.height = 20;
|
|
2870
2876
|
const t = e.getContext("2d");
|
|
2871
|
-
return t.fillStyle = "#ddd", t.fillRect(0, 0, 40, 40), t.fillStyle = "#ccc", t.fillRect(0, 0, 10, 10), t.fillRect(10, 10, 10, 10), new
|
|
2877
|
+
return t.fillStyle = "#ddd", t.fillRect(0, 0, 40, 40), t.fillStyle = "#ccc", t.fillRect(0, 0, 10, 10), t.fillRect(10, 10, 10, 10), new we({
|
|
2872
2878
|
source: e,
|
|
2873
2879
|
repeat: "repeat"
|
|
2874
2880
|
});
|
|
2875
2881
|
}
|
|
2876
2882
|
}
|
|
2877
|
-
const
|
|
2883
|
+
const mt = {
|
|
2878
2884
|
/**
|
|
2879
2885
|
* Опции редактора
|
|
2880
2886
|
*/
|
|
@@ -2963,18 +2969,18 @@ const Mt = {
|
|
|
2963
2969
|
resetObjectFitByDoubleClick: !0,
|
|
2964
2970
|
keyboardIgnoreSelectors: []
|
|
2965
2971
|
};
|
|
2966
|
-
function
|
|
2967
|
-
const t = y(y({},
|
|
2972
|
+
function At(r, e = {}) {
|
|
2973
|
+
const t = y(y({}, mt), e), s = document.getElementById(r);
|
|
2968
2974
|
if (!s)
|
|
2969
2975
|
return Promise.reject(new Error(`Контейнер с ID "${r}" не найден.`));
|
|
2970
2976
|
const n = document.createElement("canvas");
|
|
2971
2977
|
return n.id = `${r}-canvas`, s.appendChild(n), t.editorContainer = s, new Promise((i) => {
|
|
2972
2978
|
t._onReadyCallback = i;
|
|
2973
|
-
const a = new
|
|
2979
|
+
const a = new ae(n.id, t);
|
|
2974
2980
|
window[r] = a;
|
|
2975
2981
|
});
|
|
2976
2982
|
}
|
|
2977
2983
|
export {
|
|
2978
|
-
|
|
2984
|
+
At as default
|
|
2979
2985
|
};
|
|
2980
2986
|
//# sourceMappingURL=main.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.66",
|
|
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": [
|