@anu3ev/fabric-image-editor 0.1.60 → 0.1.61
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.
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var u=(g,o,r)=>new Promise((i,e)=>{var d=t=>{try{n(r.next(t))}catch(c){e(c)}},l=t=>{try{n(r.throw(t))}catch(c){e(c)}},n=t=>t.done?i(t.value):Promise.resolve(t.value).then(d,l);n((r=r.apply(g,o)).next())});(function(){"use strict";self.onmessage=g=>u(
|
|
2
|
-
//# sourceMappingURL=worker-
|
|
1
|
+
var u=(g,o,r)=>new Promise((i,e)=>{var d=t=>{try{n(r.next(t))}catch(c){e(c)}},l=t=>{try{n(r.throw(t))}catch(c){e(c)}},n=t=>t.done?i(t.value):Promise.resolve(t.value).then(d,l);n((r=r.apply(g,o)).next())});(function(){"use strict";self.onmessage=g=>u(null,null,function*(){const{action:o,payload:r,requestId:i}=g.data;try{switch(o){case"resizeImage":{const{dataURL:e,maxWidth:d,maxHeight:l,minWidth:n,minHeight:t,sizeType:c}=r,h=yield createImageBitmap(yield(yield fetch(e)).blob());let{width:a,height:s}=h,w=Math.min(d/a,l/s);c==="min"&&(w=Math.max(n/a,t/s)),a=Math.floor(a*w),s=Math.floor(s*w);const m=new OffscreenCanvas(a,s),f=m.getContext("2d");if(!f)throw new Error("Failed to get 2D context from OffscreenCanvas");f.drawImage(h,0,0,a,s);const b=yield m.convertToBlob();self.postMessage({requestId:i,action:o,success:!0,data:b});break}case"toDataURL":{const{bitmap:e,format:d,quality:l,returnBlob:n}=r,{width:t,height:c}=e,h=new OffscreenCanvas(e.width,e.height),a=h.getContext("2d");if(!a)throw new Error("Failed to get 2D context from OffscreenCanvas");a.drawImage(e,0,0,t,c);const s=yield h.convertToBlob({type:d,quality:l});if(n){self.postMessage({requestId:i,action:o,success:!0,data:s});break}const w=yield new Promise(m=>{const f=new FileReader;f.onload=()=>m(f.result),f.readAsDataURL(s)});self.postMessage({requestId:i,action:o,success:!0,data:w});break}default:throw new Error(`Unknown action ${o}`)}}catch(e){self.postMessage({requestId:i,action:o,success:!1,error:e.message})}})})();
|
|
2
|
+
//# sourceMappingURL=worker-CN39s7P7.js.map
|
package/dist/main.js
CHANGED
|
@@ -19,7 +19,7 @@ var Y = (c, e) => {
|
|
|
19
19
|
e.indexOf(s) < 0 && de.call(c, s) && (t[s] = c[s]);
|
|
20
20
|
return t;
|
|
21
21
|
};
|
|
22
|
-
var
|
|
22
|
+
var v = (c, e, t) => new Promise((s, n) => {
|
|
23
23
|
var i = (d) => {
|
|
24
24
|
try {
|
|
25
25
|
o(t.next(d));
|
|
@@ -35,7 +35,7 @@ var I = (c, 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(c, e)).next());
|
|
37
37
|
});
|
|
38
|
-
import { ActiveSelection as
|
|
38
|
+
import { ActiveSelection as I, util as R, controlsUtils as ye, InteractiveFabricObject as pe, loadSVGFromURL as Ie, FabricImage as Z, Point as W, Rect as ve, Circle as Ae, Triangle as Se, Group as Q, Canvas as Ce, Pattern as Ne } from "fabric";
|
|
39
39
|
import { create as De } from "jsondiffpatch";
|
|
40
40
|
import Le from "diff-match-patch";
|
|
41
41
|
var we = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", L = function() {
|
|
@@ -61,7 +61,7 @@ class z {
|
|
|
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.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();
|
|
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
|
* Инициализация всех обработчиков согласно опциям.
|
|
@@ -98,7 +98,7 @@ class z {
|
|
|
98
98
|
this.canvas.setActiveObject(n[0]);
|
|
99
99
|
return;
|
|
100
100
|
}
|
|
101
|
-
const i = new
|
|
101
|
+
const i = new I(n, {
|
|
102
102
|
canvas: this.canvas
|
|
103
103
|
});
|
|
104
104
|
this.canvas.setActiveObject(i), this.canvas.requestRenderAll();
|
|
@@ -160,7 +160,7 @@ class z {
|
|
|
160
160
|
* @param event.code — код клавиши
|
|
161
161
|
*/
|
|
162
162
|
handleUndoRedoEvent(e) {
|
|
163
|
-
return
|
|
163
|
+
return v(this, null, function* () {
|
|
164
164
|
const { ctrlKey: t, metaKey: s, code: n, repeat: i } = e;
|
|
165
165
|
this._shouldIgnoreKeyboardEvent(e) || !t && !s || i || !/Mac/i.test(navigator.userAgent) && this.isUndoRedoKeyPressed || (n === "KeyZ" ? (e.preventDefault(), this.isUndoRedoKeyPressed = !0, yield this.editor.historyManager.undo()) : n === "KeyY" && (e.preventDefault(), this.isUndoRedoKeyPressed = !0, yield this.editor.historyManager.redo()));
|
|
166
166
|
});
|
|
@@ -195,27 +195,30 @@ class z {
|
|
|
195
195
|
}
|
|
196
196
|
/**
|
|
197
197
|
* Обработчик для нажатия пробела.
|
|
198
|
-
* Отключает
|
|
198
|
+
* Отключает взаимодействие с объектами и делает курсор "grab" для перетаскивания канваса.
|
|
199
199
|
* @param event — объект события
|
|
200
200
|
* @param event.code — код клавиши
|
|
201
201
|
*/
|
|
202
202
|
handleSpaceKeyDown(e) {
|
|
203
203
|
if (e.code !== "Space" || this._shouldIgnoreKeyboardEvent(e)) return;
|
|
204
204
|
const { canvas: t, editor: s, isSpacePressed: n, isDragging: i } = this;
|
|
205
|
-
n || i
|
|
205
|
+
if (n || i) return;
|
|
206
|
+
this.isSpacePressed = !0, e.preventDefault();
|
|
207
|
+
const a = t.getActiveObject() || null;
|
|
208
|
+
a instanceof I ? this.savedSelection = a.getObjects().slice() : a && (this.savedSelection = [a]), t.discardActiveObject(), t.set({
|
|
206
209
|
selection: !1,
|
|
207
210
|
defaultCursor: "grab"
|
|
208
|
-
}), t.setCursor("grab"), s.canvasManager.getObjects().forEach((
|
|
209
|
-
|
|
211
|
+
}), t.setCursor("grab"), s.canvasManager.getObjects().forEach((o) => {
|
|
212
|
+
o.set({
|
|
210
213
|
selectable: !1,
|
|
211
214
|
evented: !1
|
|
212
215
|
});
|
|
213
|
-
}));
|
|
216
|
+
}), t.requestRenderAll();
|
|
214
217
|
}
|
|
215
218
|
/**
|
|
216
219
|
* Обработчик для отпускания пробела.
|
|
217
220
|
* Завершает перетаскивание канваса, если оно активно.
|
|
218
|
-
*
|
|
221
|
+
* Восстанавливает нормальное взаимодействие с объектами.
|
|
219
222
|
* @param event — объект события
|
|
220
223
|
* @param event.code — код клавиши
|
|
221
224
|
*/
|
|
@@ -228,7 +231,21 @@ class z {
|
|
|
228
231
|
selectable: !0,
|
|
229
232
|
evented: !0
|
|
230
233
|
});
|
|
231
|
-
}));
|
|
234
|
+
}), this._restoreSelection(this.savedSelection), this.savedSelection = [], this.canvas.requestRenderAll());
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Восстанавливает выделение с проверкой корректности объектов
|
|
238
|
+
* @param selection - объекты для восстановления выделения
|
|
239
|
+
*/
|
|
240
|
+
_restoreSelection(e) {
|
|
241
|
+
const { canvas: t, editor: s } = this;
|
|
242
|
+
if (e.length === 0) return;
|
|
243
|
+
if (e.length === 1) {
|
|
244
|
+
t.setActiveObject(e[0]);
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
const n = e.filter((a) => s.canvasManager.getObjects().includes(a)), i = new I(n, { canvas: t });
|
|
248
|
+
t.setActiveObject(i);
|
|
232
249
|
}
|
|
233
250
|
// --- Обработчики для событий canvas (Fabric) ---
|
|
234
251
|
/**
|
|
@@ -308,7 +325,6 @@ class z {
|
|
|
308
325
|
origin: "Listeners",
|
|
309
326
|
method: "_shouldIgnoreKeyboardEvent",
|
|
310
327
|
code: "INVALID_SELECTOR",
|
|
311
|
-
// eslint-disable-next-line max-len
|
|
312
328
|
message: `Invalid keyboard ignore selector: "${a}". Error: ${o.message}`,
|
|
313
329
|
data: o
|
|
314
330
|
});
|
|
@@ -356,7 +372,7 @@ class Ee {
|
|
|
356
372
|
}
|
|
357
373
|
function Oe(c) {
|
|
358
374
|
return new Worker(
|
|
359
|
-
"" + new URL("assets/worker-
|
|
375
|
+
"" + new URL("assets/worker-CN39s7P7.js", import.meta.url).href,
|
|
360
376
|
{
|
|
361
377
|
name: c == null ? void 0 : c.name
|
|
362
378
|
}
|
|
@@ -408,50 +424,50 @@ class Te {
|
|
|
408
424
|
this.worker.terminate();
|
|
409
425
|
}
|
|
410
426
|
}
|
|
411
|
-
const N = 12, ke = 2,
|
|
412
|
-
function
|
|
427
|
+
const N = 12, ke = 2, $ = 8, J = 20, xe = 100, K = 20, q = 8, Be = 100, P = 32, ee = 1, Ze = "#2B2D33", te = "#3D8BF4", se = "#FFFFFF";
|
|
428
|
+
function _(c, e, t, s, n) {
|
|
413
429
|
const i = N, a = ke;
|
|
414
|
-
c.save(), c.translate(e, t), c.rotate(R.degreesToRadians(n.angle)), c.fillStyle = se, c.strokeStyle = te, c.lineWidth = ee, c.beginPath(), c.roundRect(-
|
|
430
|
+
c.save(), c.translate(e, t), c.rotate(R.degreesToRadians(n.angle)), c.fillStyle = se, c.strokeStyle = te, c.lineWidth = ee, c.beginPath(), c.roundRect(-i / 2, -i / 2, i, i, a), c.fill(), c.stroke(), c.restore();
|
|
415
431
|
}
|
|
416
432
|
function he(c, e, t, s, n) {
|
|
417
|
-
const i =
|
|
418
|
-
c.save(), c.translate(e, t), c.rotate(R.degreesToRadians(n.angle)), c.fillStyle = se, c.strokeStyle = te, c.lineWidth = ee, c.beginPath(), c.roundRect(-
|
|
433
|
+
const i = $, a = J, o = xe;
|
|
434
|
+
c.save(), c.translate(e, t), c.rotate(R.degreesToRadians(n.angle)), c.fillStyle = se, c.strokeStyle = te, c.lineWidth = ee, c.beginPath(), c.roundRect(-i / 2, -a / 2, i, a, o), c.fill(), c.stroke(), c.restore();
|
|
419
435
|
}
|
|
420
436
|
function ge(c, e, t, s, n) {
|
|
421
|
-
const i =
|
|
422
|
-
c.save(), c.translate(e, t), c.rotate(R.degreesToRadians(n.angle)), c.fillStyle = se, c.strokeStyle = te, c.lineWidth = ee, c.beginPath(), c.roundRect(-
|
|
437
|
+
const i = K, a = q, o = Be;
|
|
438
|
+
c.save(), c.translate(e, t), c.rotate(R.degreesToRadians(n.angle)), c.fillStyle = se, c.strokeStyle = te, c.lineWidth = ee, c.beginPath(), c.roundRect(-i / 2, -a / 2, i, a, o), c.fill(), c.stroke(), c.restore();
|
|
423
439
|
}
|
|
424
440
|
const Ue = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTE4Ljc1IDQuMzc1djMuNzVhLjYyNS42MjUgMCAwIDEtLjYyNS42MjVoLTMuNzVhLjYyNS42MjUgMCAwIDEgMC0xLjI1aDIuMTRsLTIuMDc3LTEuOTAzLS4wMi0uMDE5YTYuMjUgNi4yNSAwIDEgMC0uMTMgOC45NjcuNjI2LjYyNiAwIDAgMSAuODYuOTA5QTcuNDU2IDcuNDU2IDAgMCAxIDEwIDE3LjVoLS4xMDNhNy41IDcuNSAwIDEgMSA1LjM5Ni0xMi44MTJMMTcuNSA2LjcwM1Y0LjM3NWEuNjI1LjYyNSAwIDAgMSAxLjI1IDBaIi8+PC9zdmc+", ue = new Image();
|
|
425
441
|
ue.src = Ue;
|
|
426
442
|
function ze(c, e, t, s, n) {
|
|
427
|
-
const a =
|
|
428
|
-
c.save(), c.translate(e, t), c.rotate(R.degreesToRadians(n.angle)), c.fillStyle = Ze, c.beginPath(), c.arc(0, 0, a, 0, 2 * Math.PI), c.fill(), c.drawImage(ue, -
|
|
443
|
+
const a = P / 2;
|
|
444
|
+
c.save(), c.translate(e, t), c.rotate(R.degreesToRadians(n.angle)), c.fillStyle = Ze, c.beginPath(), c.arc(0, 0, a, 0, 2 * Math.PI), c.fill(), c.drawImage(ue, -a / 2, -a / 2, a, a), c.restore();
|
|
429
445
|
}
|
|
430
446
|
const Re = {
|
|
431
447
|
// Угловые точки
|
|
432
448
|
tl: {
|
|
433
|
-
render:
|
|
449
|
+
render: _,
|
|
434
450
|
sizeX: N,
|
|
435
451
|
sizeY: N,
|
|
436
452
|
offsetX: 0,
|
|
437
453
|
offsetY: 0
|
|
438
454
|
},
|
|
439
455
|
tr: {
|
|
440
|
-
render:
|
|
456
|
+
render: _,
|
|
441
457
|
sizeX: N,
|
|
442
458
|
sizeY: N,
|
|
443
459
|
offsetX: 0,
|
|
444
460
|
offsetY: 0
|
|
445
461
|
},
|
|
446
462
|
bl: {
|
|
447
|
-
render:
|
|
463
|
+
render: _,
|
|
448
464
|
sizeX: N,
|
|
449
465
|
sizeY: N,
|
|
450
466
|
offsetX: 0,
|
|
451
467
|
offsetY: 0
|
|
452
468
|
},
|
|
453
469
|
br: {
|
|
454
|
-
render:
|
|
470
|
+
render: _,
|
|
455
471
|
sizeX: N,
|
|
456
472
|
sizeY: N,
|
|
457
473
|
offsetX: 0,
|
|
@@ -460,40 +476,40 @@ const Re = {
|
|
|
460
476
|
// Середина вертикалей
|
|
461
477
|
ml: {
|
|
462
478
|
render: he,
|
|
463
|
-
sizeX:
|
|
464
|
-
sizeY:
|
|
479
|
+
sizeX: $,
|
|
480
|
+
sizeY: J,
|
|
465
481
|
offsetX: 0,
|
|
466
482
|
offsetY: 0
|
|
467
483
|
},
|
|
468
484
|
mr: {
|
|
469
485
|
render: he,
|
|
470
|
-
sizeX:
|
|
471
|
-
sizeY:
|
|
486
|
+
sizeX: $,
|
|
487
|
+
sizeY: J,
|
|
472
488
|
offsetX: 0,
|
|
473
489
|
offsetY: 0
|
|
474
490
|
},
|
|
475
491
|
// Середина горизонталей
|
|
476
492
|
mt: {
|
|
477
493
|
render: ge,
|
|
478
|
-
sizeX:
|
|
479
|
-
sizeY:
|
|
494
|
+
sizeX: K,
|
|
495
|
+
sizeY: q,
|
|
480
496
|
offsetX: 0,
|
|
481
497
|
offsetY: 0
|
|
482
498
|
},
|
|
483
499
|
mb: {
|
|
484
500
|
render: ge,
|
|
485
|
-
sizeX:
|
|
486
|
-
sizeY:
|
|
501
|
+
sizeX: K,
|
|
502
|
+
sizeY: q,
|
|
487
503
|
offsetX: 0,
|
|
488
504
|
offsetY: 0
|
|
489
505
|
},
|
|
490
506
|
// Специальный «rotate» контрол
|
|
491
507
|
mtr: {
|
|
492
508
|
render: ze,
|
|
493
|
-
sizeX:
|
|
494
|
-
sizeY:
|
|
509
|
+
sizeX: P,
|
|
510
|
+
sizeY: P,
|
|
495
511
|
offsetX: 0,
|
|
496
|
-
offsetY: -
|
|
512
|
+
offsetY: -P
|
|
497
513
|
}
|
|
498
514
|
};
|
|
499
515
|
class He {
|
|
@@ -513,7 +529,7 @@ class He {
|
|
|
513
529
|
}), pe.ownDefaults.controls = e;
|
|
514
530
|
}
|
|
515
531
|
}
|
|
516
|
-
const Ye = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNNi44NzUgMi41YS42MjUuNjI1IDAgMCAwLS42MjUuNjI0VjYuMjVIMy4xMjVhLjYyNS42MjUgMCAwIDAtLjYyNS42MjV2MTBjMCAuMzQ1LjI4LjYyNS42MjUuNjI1aDEwYy4zNDUgMCAuNjI1LS4yOC42MjUtLjYyNXYtMy4xMjZoMy4xMjVjLjM0NSAwIC42MjUtLjI4LjYyNS0uNjI1di0xMGEuNjI1LjYyNSAwIDAgMC0uNjI1LS42MjVoLTEwWm02Ljg3NSAxMGgyLjVWMy43NUg3LjV2Mi41aDUuNjI1Yy4zNDUgMCAuNjI1LjI4LjYyNS42MjV2NS42MjRabS0xMCAzLjc1VjcuNWg4Ljc1djguNzVIM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Ye = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMj
|
|
|
582
598
|
icons: {
|
|
583
599
|
copyPaste: Ye,
|
|
584
600
|
delete: Xe,
|
|
585
|
-
lock:
|
|
586
|
-
unlock:
|
|
601
|
+
lock: _e,
|
|
602
|
+
unlock: We,
|
|
587
603
|
bringToFront: Ve,
|
|
588
604
|
sendToBack: Ge,
|
|
589
605
|
bringForward: Pe,
|
|
590
606
|
sendBackwards: Fe
|
|
591
607
|
},
|
|
592
608
|
handlers: {
|
|
593
|
-
copyPaste: (c) =>
|
|
609
|
+
copyPaste: (c) => v(null, null, function* () {
|
|
594
610
|
yield c.clipboardManager.copy(), yield c.clipboardManager.paste(), c.clipboardManager.clipboard && c.canvas.fire("editor:object-duplicated", {
|
|
595
611
|
object: c.clipboardManager.clipboard
|
|
596
612
|
});
|
|
@@ -842,7 +858,7 @@ class $e {
|
|
|
842
858
|
* @fires editor:history-state-loaded
|
|
843
859
|
*/
|
|
844
860
|
loadStateFromFullState(e) {
|
|
845
|
-
return
|
|
861
|
+
return v(this, null, function* () {
|
|
846
862
|
if (!e) return;
|
|
847
863
|
console.log("loadStateFromFullState fullState", e);
|
|
848
864
|
const { canvas: t, canvasManager: s, interactionBlocker: n } = this.editor, { width: i, height: a } = t;
|
|
@@ -865,7 +881,7 @@ class $e {
|
|
|
865
881
|
* @fires editor:undo
|
|
866
882
|
*/
|
|
867
883
|
undo() {
|
|
868
|
-
return
|
|
884
|
+
return v(this, null, function* () {
|
|
869
885
|
if (!this.skipHistory) {
|
|
870
886
|
if (this.currentIndex <= 0) {
|
|
871
887
|
console.log("Нет предыдущих состояний для отмены.");
|
|
@@ -902,7 +918,7 @@ class $e {
|
|
|
902
918
|
* @fires editor:redo
|
|
903
919
|
*/
|
|
904
920
|
redo() {
|
|
905
|
-
return
|
|
921
|
+
return v(this, null, function* () {
|
|
906
922
|
if (!this.skipHistory) {
|
|
907
923
|
if (this.currentIndex >= this.patches.length) {
|
|
908
924
|
console.log("Нет состояний для повтора.");
|
|
@@ -953,7 +969,7 @@ class D {
|
|
|
953
969
|
* @returns возвращает Promise с объектом изображения или null в случае ошибки
|
|
954
970
|
*/
|
|
955
971
|
importImage(e) {
|
|
956
|
-
return
|
|
972
|
+
return v(this, null, function* () {
|
|
957
973
|
const {
|
|
958
974
|
source: t,
|
|
959
975
|
scale: s = `image-${this.options.scaleType}`,
|
|
@@ -1040,7 +1056,7 @@ class D {
|
|
|
1040
1056
|
* @returns возвращает Promise с Blob-объектом уменьшенного изображения
|
|
1041
1057
|
*/
|
|
1042
1058
|
resizeImageToBoundaries(e, t = "max") {
|
|
1043
|
-
return
|
|
1059
|
+
return v(this, null, function* () {
|
|
1044
1060
|
let s = `Размер изображения больше максимального размера канваса, поэтому оно будет уменьшено до максимальных размеров c сохранением пропорций: ${O}x${T}`;
|
|
1045
1061
|
t === "min" && (s = `Размер изображения меньше минимального размера канваса, поэтому оно будет увеличено до минимальных размеров c сохранением пропорций: ${x}x${B}`);
|
|
1046
1062
|
const n = {
|
|
@@ -1072,7 +1088,7 @@ class D {
|
|
|
1072
1088
|
* @fires editor:canvas-exported
|
|
1073
1089
|
*/
|
|
1074
1090
|
exportCanvasAsImageFile() {
|
|
1075
|
-
return
|
|
1091
|
+
return v(this, arguments, function* (e = {}) {
|
|
1076
1092
|
const {
|
|
1077
1093
|
fileName: t = "image.png",
|
|
1078
1094
|
contentType: s = "image/png",
|
|
@@ -1122,21 +1138,21 @@ class D {
|
|
|
1122
1138
|
[S]
|
|
1123
1139
|
);
|
|
1124
1140
|
if (r) {
|
|
1125
|
-
const k = m * 0.264583, C = M * 0.264583, Me = (yield this.editor.moduleLoader.loadModule("jspdf")).jsPDF,
|
|
1141
|
+
const k = m * 0.264583, C = M * 0.264583, Me = (yield this.editor.moduleLoader.loadModule("jspdf")).jsPDF, X = new Me({
|
|
1126
1142
|
orientation: k > C ? "landscape" : "portrait",
|
|
1127
1143
|
unit: "mm",
|
|
1128
1144
|
format: [k, C]
|
|
1129
1145
|
});
|
|
1130
|
-
if (
|
|
1146
|
+
if (X.addImage(String(w), "JPG", 0, 0, k, C), n) {
|
|
1131
1147
|
const oe = {
|
|
1132
|
-
image:
|
|
1148
|
+
image: X.output("datauristring"),
|
|
1133
1149
|
format: "pdf",
|
|
1134
1150
|
contentType: "application/pdf",
|
|
1135
1151
|
fileName: t
|
|
1136
1152
|
};
|
|
1137
1153
|
return a.fire("editor:canvas-exported", oe), oe;
|
|
1138
1154
|
}
|
|
1139
|
-
const me =
|
|
1155
|
+
const me = X.output("blob"), ae = {
|
|
1140
1156
|
image: new File([me], t, { type: "application/pdf" }),
|
|
1141
1157
|
format: "pdf",
|
|
1142
1158
|
contentType: "application/pdf",
|
|
@@ -1183,7 +1199,7 @@ class D {
|
|
|
1183
1199
|
* @fires editor:object-exported
|
|
1184
1200
|
*/
|
|
1185
1201
|
exportObjectAsImageFile() {
|
|
1186
|
-
return
|
|
1202
|
+
return v(this, arguments, function* (e = {}) {
|
|
1187
1203
|
const {
|
|
1188
1204
|
object: t,
|
|
1189
1205
|
fileName: s = "image.png",
|
|
@@ -1294,7 +1310,7 @@ class D {
|
|
|
1294
1310
|
* @public
|
|
1295
1311
|
*/
|
|
1296
1312
|
getContentType(e) {
|
|
1297
|
-
return
|
|
1313
|
+
return v(this, null, function* () {
|
|
1298
1314
|
return typeof e == "string" ? this.getContentTypeFromUrl(e) : e.type || "application/octet-stream";
|
|
1299
1315
|
});
|
|
1300
1316
|
}
|
|
@@ -1305,7 +1321,7 @@ class D {
|
|
|
1305
1321
|
* @public
|
|
1306
1322
|
*/
|
|
1307
1323
|
getContentTypeFromUrl(e) {
|
|
1308
|
-
return
|
|
1324
|
+
return v(this, null, function* () {
|
|
1309
1325
|
if (e.startsWith("data:")) {
|
|
1310
1326
|
const t = e.match(/^data:([^;]+)/);
|
|
1311
1327
|
return t ? t[1] : "application/octet-stream";
|
|
@@ -1458,7 +1474,7 @@ class tt {
|
|
|
1458
1474
|
*/
|
|
1459
1475
|
centerMontageArea() {
|
|
1460
1476
|
var d;
|
|
1461
|
-
const { canvas: e, montageArea: t } = this.editor, s = e.getWidth(), n = e.getHeight(), i = e.getZoom(), a = new
|
|
1477
|
+
const { canvas: e, montageArea: t } = this.editor, s = e.getWidth(), n = e.getHeight(), i = e.getZoom(), a = new W(s / 2, n / 2);
|
|
1462
1478
|
t.set({
|
|
1463
1479
|
left: s / 2,
|
|
1464
1480
|
top: n / 2
|
|
@@ -1543,7 +1559,7 @@ class tt {
|
|
|
1543
1559
|
if (l.length === 1)
|
|
1544
1560
|
e.setActiveObject(l[0]);
|
|
1545
1561
|
else {
|
|
1546
|
-
const h = new
|
|
1562
|
+
const h = new I(l, {
|
|
1547
1563
|
canvas: e
|
|
1548
1564
|
});
|
|
1549
1565
|
e.setActiveObject(h);
|
|
@@ -1787,7 +1803,7 @@ class st {
|
|
|
1787
1803
|
zoom(e = qe, t = {}) {
|
|
1788
1804
|
var g, u;
|
|
1789
1805
|
if (!e) return;
|
|
1790
|
-
const { minZoom: s, maxZoom: n } = this, { canvas: i } = this.editor, a = i.getZoom(), o = i.getCenterPoint(), d = (g = t.pointX) != null ? g : o.x, r = (u = t.pointY) != null ? u : o.y, l = new
|
|
1806
|
+
const { minZoom: s, maxZoom: n } = this, { canvas: i } = this.editor, a = i.getZoom(), o = i.getCenterPoint(), d = (g = t.pointX) != null ? g : o.x, r = (u = t.pointY) != null ? u : o.y, l = new W(d, r);
|
|
1791
1807
|
let h = Number((a + Number(e)).toFixed(2));
|
|
1792
1808
|
h > n && (h = n), h < s && (h = s), i.zoomToPoint(l, h), console.log({
|
|
1793
1809
|
currentZoom: a,
|
|
@@ -1805,7 +1821,7 @@ class st {
|
|
|
1805
1821
|
* @fires editor:zoom-changed
|
|
1806
1822
|
*/
|
|
1807
1823
|
setZoom(e = this.defaultZoom) {
|
|
1808
|
-
const { minZoom: t, maxZoom: s } = this, { canvas: n } = this.editor, i = new
|
|
1824
|
+
const { minZoom: t, maxZoom: s } = this, { canvas: n } = this.editor, i = new W(n.getCenterPoint());
|
|
1809
1825
|
let a = e;
|
|
1810
1826
|
e > s && (a = s), e < t && (a = t), n.zoomToPoint(i, a), n.fire("editor:zoom-changed", {
|
|
1811
1827
|
currentZoom: n.getZoom(),
|
|
@@ -1818,7 +1834,7 @@ class st {
|
|
|
1818
1834
|
* @fires editor:zoom-changed
|
|
1819
1835
|
*/
|
|
1820
1836
|
resetZoom() {
|
|
1821
|
-
const { canvas: e } = this.editor, t = new
|
|
1837
|
+
const { canvas: e } = this.editor, t = new W(e.getCenterPoint());
|
|
1822
1838
|
e.zoomToPoint(t, this.defaultZoom), this.editor.canvas.fire("editor:zoom-changed", {
|
|
1823
1839
|
currentZoom: e.getZoom(),
|
|
1824
1840
|
point: t
|
|
@@ -1881,7 +1897,7 @@ class st {
|
|
|
1881
1897
|
withoutSave: s
|
|
1882
1898
|
} = {}) {
|
|
1883
1899
|
const { canvas: n, historyManager: i } = this.editor, a = e || n.getActiveObject();
|
|
1884
|
-
a && (a instanceof
|
|
1900
|
+
a && (a instanceof I ? a.getObjects().forEach((o) => {
|
|
1885
1901
|
o.set("opacity", t);
|
|
1886
1902
|
}) : a.set("opacity", t), n.renderAll(), s || i.saveState(), n.fire("editor:object-opacity-changed", {
|
|
1887
1903
|
object: a,
|
|
@@ -1908,12 +1924,12 @@ class st {
|
|
|
1908
1924
|
} = {}) {
|
|
1909
1925
|
const { canvas: i, historyManager: a } = this.editor, o = e || i.getActiveObject();
|
|
1910
1926
|
if (o) {
|
|
1911
|
-
if (o instanceof
|
|
1927
|
+
if (o instanceof I && !n) {
|
|
1912
1928
|
const d = o.getObjects();
|
|
1913
1929
|
i.discardActiveObject(), d.forEach((l) => {
|
|
1914
1930
|
this._fitSingleObject(l, t);
|
|
1915
1931
|
});
|
|
1916
|
-
const r = new
|
|
1932
|
+
const r = new I(d, { canvas: i });
|
|
1917
1933
|
i.setActiveObject(r);
|
|
1918
1934
|
} else
|
|
1919
1935
|
this._fitSingleObject(o, t);
|
|
@@ -2043,7 +2059,7 @@ class nt {
|
|
|
2043
2059
|
}), e.upperCanvasEl.style.pointerEvents = "", e.lowerCanvasEl.style.pointerEvents = "", this.overlayMask.visible = !1, e.requestRenderAll(), e.fire("editor:enabled"), s.resumeHistory();
|
|
2044
2060
|
}
|
|
2045
2061
|
}
|
|
2046
|
-
class
|
|
2062
|
+
class F {
|
|
2047
2063
|
constructor({ editor: e }) {
|
|
2048
2064
|
this.editor = e;
|
|
2049
2065
|
}
|
|
@@ -2058,7 +2074,7 @@ class P {
|
|
|
2058
2074
|
const { canvas: s, historyManager: n } = this.editor;
|
|
2059
2075
|
n.suspendHistory();
|
|
2060
2076
|
const i = e || s.getActiveObject();
|
|
2061
|
-
i && (i instanceof
|
|
2077
|
+
i && (i instanceof I ? i.getObjects().forEach((a) => {
|
|
2062
2078
|
s.bringObjectToFront(a);
|
|
2063
2079
|
}) : s.bringObjectToFront(i), s.renderAll(), n.resumeHistory(), t || n.saveState(), s.fire("editor:object-bring-to-front", {
|
|
2064
2080
|
object: i,
|
|
@@ -2076,7 +2092,7 @@ class P {
|
|
|
2076
2092
|
const { canvas: s, historyManager: n } = this.editor;
|
|
2077
2093
|
n.suspendHistory();
|
|
2078
2094
|
const i = e || s.getActiveObject();
|
|
2079
|
-
i && (i instanceof
|
|
2095
|
+
i && (i instanceof I ? F._moveSelectionForward(s, i) : s.bringObjectForward(i), s.renderAll(), n.resumeHistory(), t || n.saveState(), s.fire("editor:object-bring-forward", {
|
|
2080
2096
|
object: i,
|
|
2081
2097
|
withoutSave: t
|
|
2082
2098
|
}));
|
|
@@ -2098,7 +2114,7 @@ class P {
|
|
|
2098
2114
|
i.suspendHistory();
|
|
2099
2115
|
const o = e || s.getActiveObject();
|
|
2100
2116
|
if (o) {
|
|
2101
|
-
if (o instanceof
|
|
2117
|
+
if (o instanceof I) {
|
|
2102
2118
|
const d = o.getObjects();
|
|
2103
2119
|
for (let r = d.length - 1; r >= 0; r -= 1)
|
|
2104
2120
|
s.sendObjectToBack(d[r]);
|
|
@@ -2125,7 +2141,7 @@ class P {
|
|
|
2125
2141
|
} = this.editor;
|
|
2126
2142
|
i.suspendHistory();
|
|
2127
2143
|
const o = e || s.getActiveObject();
|
|
2128
|
-
o && (o instanceof
|
|
2144
|
+
o && (o instanceof I ? F._moveSelectionBackwards(s, o) : s.sendObjectBackwards(o), s.sendObjectToBack(n), a && s.sendObjectToBack(a), s.renderAll(), i.resumeHistory(), t || i.saveState(), s.fire("editor:object-send-backwards", {
|
|
2129
2145
|
object: o,
|
|
2130
2146
|
withoutSave: t
|
|
2131
2147
|
}));
|
|
@@ -2315,7 +2331,7 @@ class at {
|
|
|
2315
2331
|
* @fires editor:object-copied
|
|
2316
2332
|
*/
|
|
2317
2333
|
copy() {
|
|
2318
|
-
return
|
|
2334
|
+
return v(this, null, function* () {
|
|
2319
2335
|
const { canvas: e, errorManager: t } = this.editor, s = e.getActiveObject();
|
|
2320
2336
|
if (!s) return;
|
|
2321
2337
|
try {
|
|
@@ -2402,7 +2418,7 @@ class at {
|
|
|
2402
2418
|
* @fires editor:object-pasted
|
|
2403
2419
|
*/
|
|
2404
2420
|
paste() {
|
|
2405
|
-
return
|
|
2421
|
+
return v(this, null, function* () {
|
|
2406
2422
|
const { canvas: e } = this.editor;
|
|
2407
2423
|
if (!this.clipboard) return;
|
|
2408
2424
|
const t = yield this.clipboard.clone(["format"]);
|
|
@@ -2411,13 +2427,13 @@ class at {
|
|
|
2411
2427
|
left: t.left + 10,
|
|
2412
2428
|
top: t.top + 10,
|
|
2413
2429
|
evented: !0
|
|
2414
|
-
}), t instanceof
|
|
2430
|
+
}), t instanceof I ? (t.canvas = e, t.forEachObject((s) => {
|
|
2415
2431
|
e.add(s);
|
|
2416
2432
|
})) : e.add(t), e.setActiveObject(t), e.requestRenderAll(), e.fire("editor:object-pasted", { object: t });
|
|
2417
2433
|
});
|
|
2418
2434
|
}
|
|
2419
2435
|
}
|
|
2420
|
-
class
|
|
2436
|
+
class V {
|
|
2421
2437
|
constructor({ editor: e }) {
|
|
2422
2438
|
this.editor = e;
|
|
2423
2439
|
}
|
|
@@ -2442,7 +2458,7 @@ class F {
|
|
|
2442
2458
|
lockSkewingY: !0,
|
|
2443
2459
|
locked: !0
|
|
2444
2460
|
};
|
|
2445
|
-
a.set(o), !t &&
|
|
2461
|
+
a.set(o), !t && V._isGroupOrSelection(a) && a.getObjects().forEach((r) => {
|
|
2446
2462
|
r.set(o);
|
|
2447
2463
|
}), n.renderAll(), s || i.saveState(), n.fire("editor:object-locked", {
|
|
2448
2464
|
object: a,
|
|
@@ -2470,7 +2486,7 @@ class F {
|
|
|
2470
2486
|
lockSkewingY: !1,
|
|
2471
2487
|
locked: !1
|
|
2472
2488
|
};
|
|
2473
|
-
i.set(a),
|
|
2489
|
+
i.set(a), V._isGroupOrSelection(i) && i.getObjects().forEach((o) => {
|
|
2474
2490
|
o.set(a);
|
|
2475
2491
|
}), s.renderAll(), t || n.saveState(), s.fire("editor:object-unlocked", {
|
|
2476
2492
|
object: i,
|
|
@@ -2478,7 +2494,7 @@ class F {
|
|
|
2478
2494
|
});
|
|
2479
2495
|
}
|
|
2480
2496
|
static _isGroupOrSelection(e) {
|
|
2481
|
-
return e instanceof
|
|
2497
|
+
return e instanceof I || e instanceof Q;
|
|
2482
2498
|
}
|
|
2483
2499
|
}
|
|
2484
2500
|
class ot {
|
|
@@ -2499,8 +2515,8 @@ class ot {
|
|
|
2499
2515
|
const { canvas: s, historyManager: n } = this.editor;
|
|
2500
2516
|
n.suspendHistory();
|
|
2501
2517
|
const i = e || s.getActiveObject();
|
|
2502
|
-
if (!i || !(i instanceof
|
|
2503
|
-
const a = i.getObjects(), o = new
|
|
2518
|
+
if (!i || !(i instanceof I)) return;
|
|
2519
|
+
const a = i.getObjects(), o = new Q(a);
|
|
2504
2520
|
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", {
|
|
2505
2521
|
object: i,
|
|
2506
2522
|
group: o,
|
|
@@ -2521,10 +2537,10 @@ class ot {
|
|
|
2521
2537
|
const { canvas: s, historyManager: n } = this.editor;
|
|
2522
2538
|
n.suspendHistory();
|
|
2523
2539
|
const i = e || s.getActiveObject();
|
|
2524
|
-
if (!(i instanceof
|
|
2540
|
+
if (!(i instanceof Q)) return;
|
|
2525
2541
|
const a = i.removeAll();
|
|
2526
2542
|
s.remove(i), a.forEach((d) => s.add(d));
|
|
2527
|
-
const o = new
|
|
2543
|
+
const o = new I(a, {
|
|
2528
2544
|
canvas: s
|
|
2529
2545
|
});
|
|
2530
2546
|
s.setActiveObject(o), s.renderAll(), n.resumeHistory(), t || n.saveState(), s.fire("editor:objects-ungrouped", {
|
|
@@ -2545,7 +2561,7 @@ class rt {
|
|
|
2545
2561
|
selectAll() {
|
|
2546
2562
|
const { canvas: e, canvasManager: t, objectLockManager: s } = this.editor;
|
|
2547
2563
|
e.discardActiveObject();
|
|
2548
|
-
const n = t.getObjects(), i = n.some((o) => o.locked), a = n.length > 1 ? new
|
|
2564
|
+
const n = t.getObjects(), i = n.some((o) => o.locked), a = n.length > 1 ? new I(t.getObjects(), { canvas: e }) : n[0];
|
|
2549
2565
|
i && s.lockObject({ object: a, skipInnerObjects: !0, withoutSave: !0 }), e.setActiveObject(a), e.requestRenderAll(), e.fire("editor:all-objects-selected", { selected: a });
|
|
2550
2566
|
}
|
|
2551
2567
|
}
|
|
@@ -2639,7 +2655,7 @@ const dt = {
|
|
|
2639
2655
|
REDO_ERROR: "REDO_ERROR"
|
|
2640
2656
|
}
|
|
2641
2657
|
};
|
|
2642
|
-
class
|
|
2658
|
+
class G {
|
|
2643
2659
|
constructor({ editor: e }) {
|
|
2644
2660
|
this._buffer = [], this.editor = e;
|
|
2645
2661
|
}
|
|
@@ -2666,7 +2682,7 @@ class V {
|
|
|
2666
2682
|
* @fires editor:error
|
|
2667
2683
|
*/
|
|
2668
2684
|
emitError({ origin: e = "ImageEditor", method: t = "Unknown Method", code: s, data: n, message: i }) {
|
|
2669
|
-
if (!
|
|
2685
|
+
if (!G.isValidErrorCode(s)) {
|
|
2670
2686
|
console.warn("Неизвестный код ошибки: ", { code: s, origin: e, method: t });
|
|
2671
2687
|
return;
|
|
2672
2688
|
}
|
|
@@ -2695,7 +2711,7 @@ class V {
|
|
|
2695
2711
|
* @fires editor:warning
|
|
2696
2712
|
*/
|
|
2697
2713
|
emitWarning({ origin: e = "ImageEditor", method: t = "Unknown Method", code: s, message: n, data: i }) {
|
|
2698
|
-
if (!
|
|
2714
|
+
if (!G.isValidErrorCode(s)) {
|
|
2699
2715
|
console.warn("Неизвестный код предупреждения: ", { code: s, origin: e, method: t });
|
|
2700
2716
|
return;
|
|
2701
2717
|
}
|
|
@@ -2736,7 +2752,7 @@ class ne {
|
|
|
2736
2752
|
* @fires editor:ready
|
|
2737
2753
|
*/
|
|
2738
2754
|
init() {
|
|
2739
|
-
return
|
|
2755
|
+
return v(this, null, function* () {
|
|
2740
2756
|
const {
|
|
2741
2757
|
editorContainerWidth: e,
|
|
2742
2758
|
editorContainerHeight: t,
|
|
@@ -2749,7 +2765,7 @@ class ne {
|
|
|
2749
2765
|
scaleType: r,
|
|
2750
2766
|
_onReadyCallback: l
|
|
2751
2767
|
} = this.options;
|
|
2752
|
-
if (He.apply(), this.canvas = new Ce(this.containerId, this.options), this.moduleLoader = new Ee(), this.workerManager = new Te(), this.errorManager = new
|
|
2768
|
+
if (He.apply(), this.canvas = new Ce(this.containerId, this.options), this.moduleLoader = new Ee(), this.workerManager = new Te(), this.errorManager = new G({ editor: this }), this.historyManager = new $e({ editor: this }), this.toolbar = new Qe({ editor: this }), this.transformManager = new st({ editor: this }), this.canvasManager = new tt({ editor: this }), this.imageManager = new D({ editor: this }), this.layerManager = new F({ editor: this }), this.shapeManager = new it({ editor: this }), this.interactionBlocker = new nt({ editor: this }), this.clipboardManager = new at({ editor: this }), this.objectLockManager = new V({ editor: this }), this.groupingManager = new ot({ editor: this }), this.selectionManager = new rt({ editor: this }), this.deletionManager = new ct({ 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) {
|
|
2753
2769
|
const {
|
|
2754
2770
|
source: h,
|
|
2755
2771
|
scale: g = `image-${r}`,
|
package/package.json
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anu3ev/fabric-image-editor",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.61",
|
|
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": [
|
|
7
7
|
"dist"
|
|
8
8
|
],
|
|
9
9
|
"type": "module",
|
|
10
|
+
"engines": {
|
|
11
|
+
"node": ">=20.0.0",
|
|
12
|
+
"npm": ">=9.0.0"
|
|
13
|
+
},
|
|
10
14
|
"scripts": {
|
|
11
15
|
"dev": "vite --config vite.config.dev.js",
|
|
12
16
|
"dev:build": "vite build --watch --mode development --config vite.config.dev.js",
|
|
@@ -16,12 +20,15 @@
|
|
|
16
20
|
"preview": "vite preview",
|
|
17
21
|
"lint": "eslint \"src/**/*.{js,ts}\"",
|
|
18
22
|
"test": "jest --coverage",
|
|
19
|
-
"test:watch": "jest --watch"
|
|
23
|
+
"test:watch": "jest --watch",
|
|
24
|
+
"test:ci": "jest --ci --coverage --watchAll=false",
|
|
25
|
+
"test:coverage": "jest --coverage --coverageReporters=json-summary --coverageReporters=lcov --coverageReporters=text"
|
|
20
26
|
},
|
|
21
27
|
"devDependencies": {
|
|
22
28
|
"@babel/core": "^7.26.7",
|
|
23
|
-
"@babel/preset-env": "^7.
|
|
29
|
+
"@babel/preset-env": "^7.28.3",
|
|
24
30
|
"@eslint/js": "^9.16.0",
|
|
31
|
+
"@types/fabric": "^5.3.10",
|
|
25
32
|
"@types/jest": "^30.0.0",
|
|
26
33
|
"@typescript-eslint/eslint-plugin": "^8.36.0",
|
|
27
34
|
"@typescript-eslint/parser": "^8.36.0",
|
|
@@ -32,8 +39,8 @@
|
|
|
32
39
|
"eslint-plugin-n": "^15.7.0",
|
|
33
40
|
"eslint-plugin-promise": "^6.6.0",
|
|
34
41
|
"eslint-plugin-sort-keys-fix": "^1.1.2",
|
|
35
|
-
"eslint-plugin-vue": "^9.
|
|
36
|
-
"globals": "^15.
|
|
42
|
+
"eslint-plugin-vue": "^9.33.0",
|
|
43
|
+
"globals": "^15.15.0",
|
|
37
44
|
"jest": "^29.7.0",
|
|
38
45
|
"jest-environment-jsdom": "^29.7.0",
|
|
39
46
|
"prettier": "^3.4.2",
|
|
@@ -47,8 +54,8 @@
|
|
|
47
54
|
},
|
|
48
55
|
"dependencies": {
|
|
49
56
|
"diff-match-patch": "^1.0.5",
|
|
50
|
-
"fabric": "^6.
|
|
51
|
-
"jsondiffpatch": "^0.6.
|
|
57
|
+
"fabric": "^6.7.1",
|
|
58
|
+
"jsondiffpatch": "^0.6.2",
|
|
52
59
|
"jspdf": "^3.0.1",
|
|
53
60
|
"nanoid": "^5.0.9"
|
|
54
61
|
},
|