@anu3ev/fabric-image-editor 0.1.59 → 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
|
@@ -2,7 +2,7 @@ var fe = Object.defineProperty, je = Object.defineProperties;
|
|
|
2
2
|
var be = Object.getOwnPropertyDescriptors;
|
|
3
3
|
var H = Object.getOwnPropertySymbols;
|
|
4
4
|
var ce = Object.prototype.hasOwnProperty, de = Object.prototype.propertyIsEnumerable;
|
|
5
|
-
var re = (c, e, t) => e in c ? fe(c, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : c[e] = t,
|
|
5
|
+
var re = (c, e, t) => e in c ? fe(c, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : c[e] = t, y = (c, e) => {
|
|
6
6
|
for (var t in e || (e = {}))
|
|
7
7
|
ce.call(e, t) && re(c, t, e[t]);
|
|
8
8
|
if (H)
|
|
@@ -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();
|
|
@@ -143,7 +143,7 @@ class z {
|
|
|
143
143
|
*/
|
|
144
144
|
handleCopyEvent(e) {
|
|
145
145
|
const { ctrlKey: t, metaKey: s, code: n } = e;
|
|
146
|
-
!t && !s || n !== "KeyC" || (e.preventDefault(), this.editor.clipboardManager.copy());
|
|
146
|
+
this._shouldIgnoreKeyboardEvent(e) || !t && !s || n !== "KeyC" || (e.preventDefault(), this.editor.clipboardManager.copy());
|
|
147
147
|
}
|
|
148
148
|
/**
|
|
149
149
|
* Обработчик вставки объекта или изображения из буфера обмена.
|
|
@@ -160,9 +160,9 @@ 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
|
-
!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()));
|
|
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
|
});
|
|
167
167
|
}
|
|
168
168
|
/**
|
|
@@ -170,8 +170,8 @@ class z {
|
|
|
170
170
|
* @param event — объект события
|
|
171
171
|
* @param event.code — код клавиши
|
|
172
172
|
*/
|
|
173
|
-
handleUndoRedoKeyUp(
|
|
174
|
-
["KeyZ", "KeyY"].includes(e) && (this.isUndoRedoKeyPressed = !1);
|
|
173
|
+
handleUndoRedoKeyUp(e) {
|
|
174
|
+
this._shouldIgnoreKeyboardEvent(e) || ["KeyZ", "KeyY"].includes(e.code) && (this.isUndoRedoKeyPressed = !1);
|
|
175
175
|
}
|
|
176
176
|
/**
|
|
177
177
|
* Обработчик для выделения всех объектов (Ctrl+A).
|
|
@@ -181,45 +181,49 @@ class z {
|
|
|
181
181
|
* @param event.code — код клавиши
|
|
182
182
|
*/
|
|
183
183
|
handleSelectAllEvent(e) {
|
|
184
|
+
if (this._shouldIgnoreKeyboardEvent(e)) return;
|
|
184
185
|
const { ctrlKey: t, metaKey: s, code: n } = e;
|
|
185
186
|
!t && !s || n !== "KeyA" || (e.preventDefault(), this.editor.selectionManager.selectAll());
|
|
186
187
|
}
|
|
187
188
|
/**
|
|
188
|
-
* Обработчик для удаления объектов (Delete).
|
|
189
|
+
* Обработчик для удаления объектов (Delete или Backspace).
|
|
189
190
|
* @param event — объект события
|
|
190
191
|
* @param event.code — код клавиши
|
|
191
192
|
*/
|
|
192
193
|
handleDeleteObjectsEvent(e) {
|
|
193
|
-
e.code
|
|
194
|
+
this._shouldIgnoreKeyboardEvent(e) || e.code !== "Delete" && e.code !== "Backspace" || (e.preventDefault(), this.editor.deletionManager.deleteSelectedObjects());
|
|
194
195
|
}
|
|
195
196
|
/**
|
|
196
197
|
* Обработчик для нажатия пробела.
|
|
197
|
-
* Отключает
|
|
198
|
+
* Отключает взаимодействие с объектами и делает курсор "grab" для перетаскивания канваса.
|
|
198
199
|
* @param event — объект события
|
|
199
200
|
* @param event.code — код клавиши
|
|
200
201
|
*/
|
|
201
202
|
handleSpaceKeyDown(e) {
|
|
202
|
-
if (e.code !== "Space") return;
|
|
203
|
+
if (e.code !== "Space" || this._shouldIgnoreKeyboardEvent(e)) return;
|
|
203
204
|
const { canvas: t, editor: s, isSpacePressed: n, isDragging: i } = this;
|
|
204
|
-
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({
|
|
205
209
|
selection: !1,
|
|
206
210
|
defaultCursor: "grab"
|
|
207
|
-
}), t.setCursor("grab"), s.canvasManager.getObjects().forEach((
|
|
208
|
-
|
|
211
|
+
}), t.setCursor("grab"), s.canvasManager.getObjects().forEach((o) => {
|
|
212
|
+
o.set({
|
|
209
213
|
selectable: !1,
|
|
210
214
|
evented: !1
|
|
211
215
|
});
|
|
212
|
-
}));
|
|
216
|
+
}), t.requestRenderAll();
|
|
213
217
|
}
|
|
214
218
|
/**
|
|
215
219
|
* Обработчик для отпускания пробела.
|
|
216
220
|
* Завершает перетаскивание канваса, если оно активно.
|
|
217
|
-
*
|
|
221
|
+
* Восстанавливает нормальное взаимодействие с объектами.
|
|
218
222
|
* @param event — объект события
|
|
219
223
|
* @param event.code — код клавиши
|
|
220
224
|
*/
|
|
221
225
|
handleSpaceKeyUp(e) {
|
|
222
|
-
e.code
|
|
226
|
+
e.code !== "Space" || this._shouldIgnoreKeyboardEvent(e) || (this.isSpacePressed = !1, this.isDragging && this.handleCanvasDragEnd(), this.canvas.set({
|
|
223
227
|
defaultCursor: "default",
|
|
224
228
|
selection: !0
|
|
225
229
|
}), this.canvas.setCursor("default"), this.editor.canvasManager.getObjects().forEach((t) => {
|
|
@@ -227,7 +231,21 @@ class z {
|
|
|
227
231
|
selectable: !0,
|
|
228
232
|
evented: !0
|
|
229
233
|
});
|
|
230
|
-
}));
|
|
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);
|
|
231
249
|
}
|
|
232
250
|
// --- Обработчики для событий canvas (Fabric) ---
|
|
233
251
|
/**
|
|
@@ -285,6 +303,34 @@ class z {
|
|
|
285
303
|
const t = e == null ? void 0 : e.target;
|
|
286
304
|
t && this.editor.transformManager.resetObject(t);
|
|
287
305
|
}
|
|
306
|
+
/**
|
|
307
|
+
* Проверяет, должно ли событие клавиатуры быть проигнорировано
|
|
308
|
+
* Возвращает true если фокус находится в поле ввода или элементе из списка игнорируемых селекторов
|
|
309
|
+
* @param event - Событие клавиатуры
|
|
310
|
+
* @returns true если событие должно быть проигнорировано
|
|
311
|
+
*/
|
|
312
|
+
_shouldIgnoreKeyboardEvent(e) {
|
|
313
|
+
const t = e.target;
|
|
314
|
+
if (!t) return !1;
|
|
315
|
+
const s = ["input", "textarea", "select"], n = t.tagName.toLowerCase();
|
|
316
|
+
if (s.includes(n) || t.contentEditable === "true") return !0;
|
|
317
|
+
const { keyboardIgnoreSelectors: i } = this.options;
|
|
318
|
+
if (i != null && i.length)
|
|
319
|
+
for (const a of i)
|
|
320
|
+
try {
|
|
321
|
+
if (t.matches && t.matches(a) || t.closest && t.closest(a))
|
|
322
|
+
return !0;
|
|
323
|
+
} catch (o) {
|
|
324
|
+
this.editor.errorManager.emitWarning({
|
|
325
|
+
origin: "Listeners",
|
|
326
|
+
method: "_shouldIgnoreKeyboardEvent",
|
|
327
|
+
code: "INVALID_SELECTOR",
|
|
328
|
+
message: `Invalid keyboard ignore selector: "${a}". Error: ${o.message}`,
|
|
329
|
+
data: o
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
return !1;
|
|
333
|
+
}
|
|
288
334
|
/**
|
|
289
335
|
* Метод для удаления всех слушателей
|
|
290
336
|
*/
|
|
@@ -326,7 +372,7 @@ class Ee {
|
|
|
326
372
|
}
|
|
327
373
|
function Oe(c) {
|
|
328
374
|
return new Worker(
|
|
329
|
-
"" + new URL("assets/worker-
|
|
375
|
+
"" + new URL("assets/worker-CN39s7P7.js", import.meta.url).href,
|
|
330
376
|
{
|
|
331
377
|
name: c == null ? void 0 : c.name
|
|
332
378
|
}
|
|
@@ -378,50 +424,50 @@ class Te {
|
|
|
378
424
|
this.worker.terminate();
|
|
379
425
|
}
|
|
380
426
|
}
|
|
381
|
-
const N = 12, ke = 2,
|
|
382
|
-
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) {
|
|
383
429
|
const i = N, a = ke;
|
|
384
|
-
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();
|
|
385
431
|
}
|
|
386
432
|
function he(c, e, t, s, n) {
|
|
387
|
-
const i =
|
|
388
|
-
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();
|
|
389
435
|
}
|
|
390
436
|
function ge(c, e, t, s, n) {
|
|
391
|
-
const i =
|
|
392
|
-
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();
|
|
393
439
|
}
|
|
394
440
|
const Ue = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTE4Ljc1IDQuMzc1djMuNzVhLjYyNS42MjUgMCAwIDEtLjYyNS42MjVoLTMuNzVhLjYyNS42MjUgMCAwIDEgMC0xLjI1aDIuMTRsLTIuMDc3LTEuOTAzLS4wMi0uMDE5YTYuMjUgNi4yNSAwIDEgMC0uMTMgOC45NjcuNjI2LjYyNiAwIDAgMSAuODYuOTA5QTcuNDU2IDcuNDU2IDAgMCAxIDEwIDE3LjVoLS4xMDNhNy41IDcuNSAwIDEgMSA1LjM5Ni0xMi44MTJMMTcuNSA2LjcwM1Y0LjM3NWEuNjI1LjYyNSAwIDAgMSAxLjI1IDBaIi8+PC9zdmc+", ue = new Image();
|
|
395
441
|
ue.src = Ue;
|
|
396
442
|
function ze(c, e, t, s, n) {
|
|
397
|
-
const a =
|
|
398
|
-
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();
|
|
399
445
|
}
|
|
400
446
|
const Re = {
|
|
401
447
|
// Угловые точки
|
|
402
448
|
tl: {
|
|
403
|
-
render:
|
|
449
|
+
render: _,
|
|
404
450
|
sizeX: N,
|
|
405
451
|
sizeY: N,
|
|
406
452
|
offsetX: 0,
|
|
407
453
|
offsetY: 0
|
|
408
454
|
},
|
|
409
455
|
tr: {
|
|
410
|
-
render:
|
|
456
|
+
render: _,
|
|
411
457
|
sizeX: N,
|
|
412
458
|
sizeY: N,
|
|
413
459
|
offsetX: 0,
|
|
414
460
|
offsetY: 0
|
|
415
461
|
},
|
|
416
462
|
bl: {
|
|
417
|
-
render:
|
|
463
|
+
render: _,
|
|
418
464
|
sizeX: N,
|
|
419
465
|
sizeY: N,
|
|
420
466
|
offsetX: 0,
|
|
421
467
|
offsetY: 0
|
|
422
468
|
},
|
|
423
469
|
br: {
|
|
424
|
-
render:
|
|
470
|
+
render: _,
|
|
425
471
|
sizeX: N,
|
|
426
472
|
sizeY: N,
|
|
427
473
|
offsetX: 0,
|
|
@@ -430,14 +476,14 @@ const Re = {
|
|
|
430
476
|
// Середина вертикалей
|
|
431
477
|
ml: {
|
|
432
478
|
render: he,
|
|
433
|
-
sizeX:
|
|
479
|
+
sizeX: $,
|
|
434
480
|
sizeY: J,
|
|
435
481
|
offsetX: 0,
|
|
436
482
|
offsetY: 0
|
|
437
483
|
},
|
|
438
484
|
mr: {
|
|
439
485
|
render: he,
|
|
440
|
-
sizeX:
|
|
486
|
+
sizeX: $,
|
|
441
487
|
sizeY: J,
|
|
442
488
|
offsetX: 0,
|
|
443
489
|
offsetY: 0
|
|
@@ -445,30 +491,30 @@ const Re = {
|
|
|
445
491
|
// Середина горизонталей
|
|
446
492
|
mt: {
|
|
447
493
|
render: ge,
|
|
448
|
-
sizeX:
|
|
449
|
-
sizeY:
|
|
494
|
+
sizeX: K,
|
|
495
|
+
sizeY: q,
|
|
450
496
|
offsetX: 0,
|
|
451
497
|
offsetY: 0
|
|
452
498
|
},
|
|
453
499
|
mb: {
|
|
454
500
|
render: ge,
|
|
455
|
-
sizeX:
|
|
456
|
-
sizeY:
|
|
501
|
+
sizeX: K,
|
|
502
|
+
sizeY: q,
|
|
457
503
|
offsetX: 0,
|
|
458
504
|
offsetY: 0
|
|
459
505
|
},
|
|
460
506
|
// Специальный «rotate» контрол
|
|
461
507
|
mtr: {
|
|
462
508
|
render: ze,
|
|
463
|
-
sizeX:
|
|
464
|
-
sizeY:
|
|
509
|
+
sizeX: P,
|
|
510
|
+
sizeY: P,
|
|
465
511
|
offsetX: 0,
|
|
466
|
-
offsetY: -
|
|
512
|
+
offsetY: -P
|
|
467
513
|
}
|
|
468
514
|
};
|
|
469
515
|
class He {
|
|
470
516
|
static apply() {
|
|
471
|
-
const e =
|
|
517
|
+
const e = ye.createObjectDefaultControls();
|
|
472
518
|
Object.entries(Re).forEach(([t, s]) => {
|
|
473
519
|
Object.assign(e[t], {
|
|
474
520
|
render: s.render,
|
|
@@ -480,10 +526,10 @@ class He {
|
|
|
480
526
|
var l;
|
|
481
527
|
(l = a.target.canvas) == null || l.setCursor("grabbing");
|
|
482
528
|
});
|
|
483
|
-
}),
|
|
529
|
+
}), pe.ownDefaults.controls = e;
|
|
484
530
|
}
|
|
485
531
|
}
|
|
486
|
-
const Ye = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNNi44NzUgMi41YS42MjUuNjI1IDAgMCAwLS42MjUuNjI0VjYuMjVIMy4xMjVhLjYyNS42MjUgMCAwIDAtLjYyNS42MjV2MTBjMCAuMzQ1LjI4LjYyNS42MjUuNjI1aDEwYy4zNDUgMCAuNjI1LS4yOC42MjUtLjYyNXYtMy4xMjZoMy4xMjVjLjM0NSAwIC42MjUtLjI4LjYyNS0uNjI1di0xMGEuNjI1LjYyNSAwIDAgMC0uNjI1LS42MjVoLTEwWm02Ljg3NSAxMGgyLjVWMy43NUg3LjV2Mi41aDUuNjI1Yy4zNDUgMCAuNjI1LjI4LjYyNS42MjV2NS42MjRabS0xMCAzLjc1VjcuNWg4Ljc1djguNzVIMy43NVoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPjwvc3ZnPg==",
|
|
532
|
+
const Ye = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNNi44NzUgMi41YS42MjUuNjI1IDAgMCAwLS42MjUuNjI0VjYuMjVIMy4xMjVhLjYyNS42MjUgMCAwIDAtLjYyNS42MjV2MTBjMCAuMzQ1LjI4LjYyNS42MjUuNjI1aDEwYy4zNDUgMCAuNjI1LS4yOC42MjUtLj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jVhLjYyNS42MjUgMCAwIDAgMCAxLjI1aC42MjV2MTEuMjVBMS4yNSAxLjI1IDAgMCAwIDUgMTcuNWgxMGExLjI1IDEuMjUgMCAwIDAgMS4yNS0xLjI1VjVoLjYyNWEuNjI1LjYyNSAwIDAgMCAwLTEuMjVIMTMuNzV2LS42MjVhMS44NzUgMS44NzUgMCAwIDAtMS44NzUtMS44NzVoLTMuNzVabTQuMzc1IDIuNXYtLjYyNWEuNjI1LjYyNSAwIDAgMC0uNjI1LS42MjVoLTMuNzVhLjYyNS42MjUgMCAwIDAtLjYyNS42MjV2LjYyNWg1Wk01IDE2LjI1VjVoMTB2MTEuMjVINVpNOC4xMjUgNy41Yy4zNDUgMCAuNjI1LjI4LjYyNS42MjV2NWEuNjI1LjYyNSAwIDEgMS0xLjI1IDB2LTVjMC0uMzQ1LjI4LS42MjUuNjI1LS42MjVabTQuMzc1IDUuNjI1di01YS42MjUuNjI1IDAgMCAwLTEuMjUgMHY1YS42MjUuNjI1IDAgMSAwIDEuMjUgMFoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPjwvc3ZnPg==", U = {
|
|
487
533
|
style: {
|
|
488
534
|
position: "absolute",
|
|
489
535
|
display: "none",
|
|
@@ -552,15 +598,15 @@ const Ye = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMj
|
|
|
552
598
|
icons: {
|
|
553
599
|
copyPaste: Ye,
|
|
554
600
|
delete: Xe,
|
|
555
|
-
lock:
|
|
556
|
-
unlock:
|
|
601
|
+
lock: _e,
|
|
602
|
+
unlock: We,
|
|
557
603
|
bringToFront: Ve,
|
|
558
604
|
sendToBack: Ge,
|
|
559
605
|
bringForward: Pe,
|
|
560
606
|
sendBackwards: Fe
|
|
561
607
|
},
|
|
562
608
|
handlers: {
|
|
563
|
-
copyPaste: (c) =>
|
|
609
|
+
copyPaste: (c) => v(null, null, function* () {
|
|
564
610
|
yield c.clipboardManager.copy(), yield c.clipboardManager.paste(), c.clipboardManager.clipboard && c.canvas.fire("editor:object-duplicated", {
|
|
565
611
|
object: c.clipboardManager.clipboard
|
|
566
612
|
});
|
|
@@ -595,11 +641,11 @@ class Qe {
|
|
|
595
641
|
_initToolbar() {
|
|
596
642
|
if (!this.options.showToolbar) return;
|
|
597
643
|
const e = this.options.toolbar || {};
|
|
598
|
-
this.config = le(
|
|
599
|
-
style:
|
|
600
|
-
btnStyle:
|
|
601
|
-
icons:
|
|
602
|
-
handlers:
|
|
644
|
+
this.config = le(y(y({}, U), e), {
|
|
645
|
+
style: y(y({}, U.style), e.style || {}),
|
|
646
|
+
btnStyle: y(y({}, U.btnStyle), e.btnStyle || {}),
|
|
647
|
+
icons: y(y({}, U.icons), e.icons || {}),
|
|
648
|
+
handlers: y(y({}, U.handlers), e.handlers || {})
|
|
603
649
|
}), 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 = () => {
|
|
604
650
|
this.el.style.display = "none";
|
|
605
651
|
}, this._createDOM(), this._bindEvents();
|
|
@@ -702,7 +748,7 @@ class Qe {
|
|
|
702
748
|
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();
|
|
703
749
|
}
|
|
704
750
|
}
|
|
705
|
-
class
|
|
751
|
+
class $e {
|
|
706
752
|
constructor({ editor: e }) {
|
|
707
753
|
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();
|
|
708
754
|
}
|
|
@@ -812,7 +858,7 @@ class Je {
|
|
|
812
858
|
* @fires editor:history-state-loaded
|
|
813
859
|
*/
|
|
814
860
|
loadStateFromFullState(e) {
|
|
815
|
-
return
|
|
861
|
+
return v(this, null, function* () {
|
|
816
862
|
if (!e) return;
|
|
817
863
|
console.log("loadStateFromFullState fullState", e);
|
|
818
864
|
const { canvas: t, canvasManager: s, interactionBlocker: n } = this.editor, { width: i, height: a } = t;
|
|
@@ -835,7 +881,7 @@ class Je {
|
|
|
835
881
|
* @fires editor:undo
|
|
836
882
|
*/
|
|
837
883
|
undo() {
|
|
838
|
-
return
|
|
884
|
+
return v(this, null, function* () {
|
|
839
885
|
if (!this.skipHistory) {
|
|
840
886
|
if (this.currentIndex <= 0) {
|
|
841
887
|
console.log("Нет предыдущих состояний для отмены.");
|
|
@@ -872,7 +918,7 @@ class Je {
|
|
|
872
918
|
* @fires editor:redo
|
|
873
919
|
*/
|
|
874
920
|
redo() {
|
|
875
|
-
return
|
|
921
|
+
return v(this, null, function* () {
|
|
876
922
|
if (!this.skipHistory) {
|
|
877
923
|
if (this.currentIndex >= this.patches.length) {
|
|
878
924
|
console.log("Нет состояний для повтора.");
|
|
@@ -905,7 +951,7 @@ class Je {
|
|
|
905
951
|
});
|
|
906
952
|
}
|
|
907
953
|
}
|
|
908
|
-
const
|
|
954
|
+
const Je = 0.1, Ke = 2, qe = 0.1, et = 90, x = 16, B = 16, O = 4096, T = 4096;
|
|
909
955
|
class D {
|
|
910
956
|
constructor({ editor: e }) {
|
|
911
957
|
this.editor = e, this.options = e.options, this._createdBlobUrls = [], this.acceptContentTypes = this.editor.options.acceptContentTypes, this.acceptFormats = this.getAllowedFormatsFromContentTypes();
|
|
@@ -923,7 +969,7 @@ class D {
|
|
|
923
969
|
* @returns возвращает Promise с объектом изображения или null в случае ошибки
|
|
924
970
|
*/
|
|
925
971
|
importImage(e) {
|
|
926
|
-
return
|
|
972
|
+
return v(this, null, function* () {
|
|
927
973
|
const {
|
|
928
974
|
source: t,
|
|
929
975
|
scale: s = `image-${this.options.scaleType}`,
|
|
@@ -1010,7 +1056,7 @@ class D {
|
|
|
1010
1056
|
* @returns возвращает Promise с Blob-объектом уменьшенного изображения
|
|
1011
1057
|
*/
|
|
1012
1058
|
resizeImageToBoundaries(e, t = "max") {
|
|
1013
|
-
return
|
|
1059
|
+
return v(this, null, function* () {
|
|
1014
1060
|
let s = `Размер изображения больше максимального размера канваса, поэтому оно будет уменьшено до максимальных размеров c сохранением пропорций: ${O}x${T}`;
|
|
1015
1061
|
t === "min" && (s = `Размер изображения меньше минимального размера канваса, поэтому оно будет увеличено до минимальных размеров c сохранением пропорций: ${x}x${B}`);
|
|
1016
1062
|
const n = {
|
|
@@ -1042,7 +1088,7 @@ class D {
|
|
|
1042
1088
|
* @fires editor:canvas-exported
|
|
1043
1089
|
*/
|
|
1044
1090
|
exportCanvasAsImageFile() {
|
|
1045
|
-
return
|
|
1091
|
+
return v(this, arguments, function* (e = {}) {
|
|
1046
1092
|
const {
|
|
1047
1093
|
fileName: t = "image.png",
|
|
1048
1094
|
contentType: s = "image/png",
|
|
@@ -1054,14 +1100,14 @@ class D {
|
|
|
1054
1100
|
o.setCoords();
|
|
1055
1101
|
const { left: g, top: u, width: m, height: M } = o.getBoundingRect(), f = yield a.clone(["id", "format", "locked"]);
|
|
1056
1102
|
["image/jpg", "image/jpeg"].includes(l) && (f.backgroundColor = "#ffffff");
|
|
1057
|
-
const j = f.getObjects().find((
|
|
1103
|
+
const j = f.getObjects().find((p) => p.id === o.id);
|
|
1058
1104
|
j && (j.visible = !1), f.viewportTransform = [1, 0, 0, 1, -g, -u], f.setDimensions({ width: m, height: M }, { backstoreOnly: !0 }), f.renderAll();
|
|
1059
|
-
const A = f.getObjects().filter((
|
|
1105
|
+
const A = f.getObjects().filter((p) => p.format).every((p) => p.format === "svg");
|
|
1060
1106
|
if (h === "svg" && A) {
|
|
1061
|
-
const
|
|
1107
|
+
const p = f.toSVG();
|
|
1062
1108
|
f.dispose();
|
|
1063
1109
|
const C = {
|
|
1064
|
-
image: D._exportSVGStringAsFile(
|
|
1110
|
+
image: D._exportSVGStringAsFile(p, {
|
|
1065
1111
|
exportAsBase64: n,
|
|
1066
1112
|
exportAsBlob: i,
|
|
1067
1113
|
fileName: t
|
|
@@ -1072,19 +1118,19 @@ class D {
|
|
|
1072
1118
|
};
|
|
1073
1119
|
return a.fire("editor:canvas-exported", C), C;
|
|
1074
1120
|
}
|
|
1075
|
-
const b = yield new Promise((
|
|
1121
|
+
const b = yield new Promise((p, k) => {
|
|
1076
1122
|
f.getElement().toBlob((C) => {
|
|
1077
|
-
C ?
|
|
1123
|
+
C ? p(C) : k(new Error("Failed to create Blob from canvas"));
|
|
1078
1124
|
});
|
|
1079
1125
|
});
|
|
1080
1126
|
if (f.dispose(), i) {
|
|
1081
|
-
const
|
|
1127
|
+
const p = {
|
|
1082
1128
|
image: b,
|
|
1083
1129
|
format: h,
|
|
1084
1130
|
contentType: l,
|
|
1085
1131
|
fileName: t
|
|
1086
1132
|
};
|
|
1087
|
-
return a.fire("editor:canvas-exported",
|
|
1133
|
+
return a.fire("editor:canvas-exported", p), p;
|
|
1088
1134
|
}
|
|
1089
1135
|
const S = yield createImageBitmap(b), w = yield d.post(
|
|
1090
1136
|
"toDataURL",
|
|
@@ -1092,21 +1138,21 @@ class D {
|
|
|
1092
1138
|
[S]
|
|
1093
1139
|
);
|
|
1094
1140
|
if (r) {
|
|
1095
|
-
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({
|
|
1096
1142
|
orientation: k > C ? "landscape" : "portrait",
|
|
1097
1143
|
unit: "mm",
|
|
1098
1144
|
format: [k, C]
|
|
1099
1145
|
});
|
|
1100
|
-
if (
|
|
1146
|
+
if (X.addImage(String(w), "JPG", 0, 0, k, C), n) {
|
|
1101
1147
|
const oe = {
|
|
1102
|
-
image:
|
|
1148
|
+
image: X.output("datauristring"),
|
|
1103
1149
|
format: "pdf",
|
|
1104
1150
|
contentType: "application/pdf",
|
|
1105
1151
|
fileName: t
|
|
1106
1152
|
};
|
|
1107
1153
|
return a.fire("editor:canvas-exported", oe), oe;
|
|
1108
1154
|
}
|
|
1109
|
-
const me =
|
|
1155
|
+
const me = X.output("blob"), ae = {
|
|
1110
1156
|
image: new File([me], t, { type: "application/pdf" }),
|
|
1111
1157
|
format: "pdf",
|
|
1112
1158
|
contentType: "application/pdf",
|
|
@@ -1115,13 +1161,13 @@ class D {
|
|
|
1115
1161
|
return a.fire("editor:canvas-exported", ae), ae;
|
|
1116
1162
|
}
|
|
1117
1163
|
if (n) {
|
|
1118
|
-
const
|
|
1164
|
+
const p = {
|
|
1119
1165
|
image: w,
|
|
1120
1166
|
format: h,
|
|
1121
1167
|
contentType: l,
|
|
1122
1168
|
fileName: t
|
|
1123
1169
|
};
|
|
1124
|
-
return a.fire("editor:canvas-exported",
|
|
1170
|
+
return a.fire("editor:canvas-exported", p), p;
|
|
1125
1171
|
}
|
|
1126
1172
|
const E = h === "svg" && !A ? t.replace(/\.[^/.]+$/, ".png") : t, ie = {
|
|
1127
1173
|
image: new File([b], E, { type: l }),
|
|
@@ -1153,7 +1199,7 @@ class D {
|
|
|
1153
1199
|
* @fires editor:object-exported
|
|
1154
1200
|
*/
|
|
1155
1201
|
exportObjectAsImageFile() {
|
|
1156
|
-
return
|
|
1202
|
+
return v(this, arguments, function* (e = {}) {
|
|
1157
1203
|
const {
|
|
1158
1204
|
object: t,
|
|
1159
1205
|
fileName: s = "image.png",
|
|
@@ -1264,7 +1310,7 @@ class D {
|
|
|
1264
1310
|
* @public
|
|
1265
1311
|
*/
|
|
1266
1312
|
getContentType(e) {
|
|
1267
|
-
return
|
|
1313
|
+
return v(this, null, function* () {
|
|
1268
1314
|
return typeof e == "string" ? this.getContentTypeFromUrl(e) : e.type || "application/octet-stream";
|
|
1269
1315
|
});
|
|
1270
1316
|
}
|
|
@@ -1275,7 +1321,7 @@ class D {
|
|
|
1275
1321
|
* @public
|
|
1276
1322
|
*/
|
|
1277
1323
|
getContentTypeFromUrl(e) {
|
|
1278
|
-
return
|
|
1324
|
+
return v(this, null, function* () {
|
|
1279
1325
|
if (e.startsWith("data:")) {
|
|
1280
1326
|
const t = e.match(/^data:([^;]+)/);
|
|
1281
1327
|
return t ? t[1] : "application/octet-stream";
|
|
@@ -1428,7 +1474,7 @@ class tt {
|
|
|
1428
1474
|
*/
|
|
1429
1475
|
centerMontageArea() {
|
|
1430
1476
|
var d;
|
|
1431
|
-
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);
|
|
1432
1478
|
t.set({
|
|
1433
1479
|
left: s / 2,
|
|
1434
1480
|
top: n / 2
|
|
@@ -1513,7 +1559,7 @@ class tt {
|
|
|
1513
1559
|
if (l.length === 1)
|
|
1514
1560
|
e.setActiveObject(l[0]);
|
|
1515
1561
|
else {
|
|
1516
|
-
const h = new
|
|
1562
|
+
const h = new I(l, {
|
|
1517
1563
|
canvas: e
|
|
1518
1564
|
});
|
|
1519
1565
|
e.setActiveObject(h);
|
|
@@ -1730,7 +1776,7 @@ class tt {
|
|
|
1730
1776
|
}
|
|
1731
1777
|
class st {
|
|
1732
1778
|
constructor({ editor: e }) {
|
|
1733
|
-
this.editor = e, this.options = e.options, this.minZoom = this.options.minZoom ||
|
|
1779
|
+
this.editor = e, this.options = e.options, this.minZoom = this.options.minZoom || Je, this.maxZoom = this.options.maxZoom || Ke, this.defaultZoom = this.options.defaultScale, this.maxZoomFactor = this.options.maxZoomFactor;
|
|
1734
1780
|
}
|
|
1735
1781
|
/**
|
|
1736
1782
|
* Метод рассчитывает и применяет зум по умолчанию для монтажной области редактора.
|
|
@@ -1757,7 +1803,7 @@ class st {
|
|
|
1757
1803
|
zoom(e = qe, t = {}) {
|
|
1758
1804
|
var g, u;
|
|
1759
1805
|
if (!e) return;
|
|
1760
|
-
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);
|
|
1761
1807
|
let h = Number((a + Number(e)).toFixed(2));
|
|
1762
1808
|
h > n && (h = n), h < s && (h = s), i.zoomToPoint(l, h), console.log({
|
|
1763
1809
|
currentZoom: a,
|
|
@@ -1775,7 +1821,7 @@ class st {
|
|
|
1775
1821
|
* @fires editor:zoom-changed
|
|
1776
1822
|
*/
|
|
1777
1823
|
setZoom(e = this.defaultZoom) {
|
|
1778
|
-
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());
|
|
1779
1825
|
let a = e;
|
|
1780
1826
|
e > s && (a = s), e < t && (a = t), n.zoomToPoint(i, a), n.fire("editor:zoom-changed", {
|
|
1781
1827
|
currentZoom: n.getZoom(),
|
|
@@ -1788,7 +1834,7 @@ class st {
|
|
|
1788
1834
|
* @fires editor:zoom-changed
|
|
1789
1835
|
*/
|
|
1790
1836
|
resetZoom() {
|
|
1791
|
-
const { canvas: e } = this.editor, t = new
|
|
1837
|
+
const { canvas: e } = this.editor, t = new W(e.getCenterPoint());
|
|
1792
1838
|
e.zoomToPoint(t, this.defaultZoom), this.editor.canvas.fire("editor:zoom-changed", {
|
|
1793
1839
|
currentZoom: e.getZoom(),
|
|
1794
1840
|
point: t
|
|
@@ -1851,7 +1897,7 @@ class st {
|
|
|
1851
1897
|
withoutSave: s
|
|
1852
1898
|
} = {}) {
|
|
1853
1899
|
const { canvas: n, historyManager: i } = this.editor, a = e || n.getActiveObject();
|
|
1854
|
-
a && (a instanceof
|
|
1900
|
+
a && (a instanceof I ? a.getObjects().forEach((o) => {
|
|
1855
1901
|
o.set("opacity", t);
|
|
1856
1902
|
}) : a.set("opacity", t), n.renderAll(), s || i.saveState(), n.fire("editor:object-opacity-changed", {
|
|
1857
1903
|
object: a,
|
|
@@ -1878,12 +1924,12 @@ class st {
|
|
|
1878
1924
|
} = {}) {
|
|
1879
1925
|
const { canvas: i, historyManager: a } = this.editor, o = e || i.getActiveObject();
|
|
1880
1926
|
if (o) {
|
|
1881
|
-
if (o instanceof
|
|
1927
|
+
if (o instanceof I && !n) {
|
|
1882
1928
|
const d = o.getObjects();
|
|
1883
1929
|
i.discardActiveObject(), d.forEach((l) => {
|
|
1884
1930
|
this._fitSingleObject(l, t);
|
|
1885
1931
|
});
|
|
1886
|
-
const r = new
|
|
1932
|
+
const r = new I(d, { canvas: i });
|
|
1887
1933
|
i.setActiveObject(r);
|
|
1888
1934
|
} else
|
|
1889
1935
|
this._fitSingleObject(o, t);
|
|
@@ -2013,7 +2059,7 @@ class nt {
|
|
|
2013
2059
|
}), e.upperCanvasEl.style.pointerEvents = "", e.lowerCanvasEl.style.pointerEvents = "", this.overlayMask.visible = !1, e.requestRenderAll(), e.fire("editor:enabled"), s.resumeHistory();
|
|
2014
2060
|
}
|
|
2015
2061
|
}
|
|
2016
|
-
class
|
|
2062
|
+
class F {
|
|
2017
2063
|
constructor({ editor: e }) {
|
|
2018
2064
|
this.editor = e;
|
|
2019
2065
|
}
|
|
@@ -2028,7 +2074,7 @@ class P {
|
|
|
2028
2074
|
const { canvas: s, historyManager: n } = this.editor;
|
|
2029
2075
|
n.suspendHistory();
|
|
2030
2076
|
const i = e || s.getActiveObject();
|
|
2031
|
-
i && (i instanceof
|
|
2077
|
+
i && (i instanceof I ? i.getObjects().forEach((a) => {
|
|
2032
2078
|
s.bringObjectToFront(a);
|
|
2033
2079
|
}) : s.bringObjectToFront(i), s.renderAll(), n.resumeHistory(), t || n.saveState(), s.fire("editor:object-bring-to-front", {
|
|
2034
2080
|
object: i,
|
|
@@ -2046,7 +2092,7 @@ class P {
|
|
|
2046
2092
|
const { canvas: s, historyManager: n } = this.editor;
|
|
2047
2093
|
n.suspendHistory();
|
|
2048
2094
|
const i = e || s.getActiveObject();
|
|
2049
|
-
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", {
|
|
2050
2096
|
object: i,
|
|
2051
2097
|
withoutSave: t
|
|
2052
2098
|
}));
|
|
@@ -2068,7 +2114,7 @@ class P {
|
|
|
2068
2114
|
i.suspendHistory();
|
|
2069
2115
|
const o = e || s.getActiveObject();
|
|
2070
2116
|
if (o) {
|
|
2071
|
-
if (o instanceof
|
|
2117
|
+
if (o instanceof I) {
|
|
2072
2118
|
const d = o.getObjects();
|
|
2073
2119
|
for (let r = d.length - 1; r >= 0; r -= 1)
|
|
2074
2120
|
s.sendObjectToBack(d[r]);
|
|
@@ -2095,7 +2141,7 @@ class P {
|
|
|
2095
2141
|
} = this.editor;
|
|
2096
2142
|
i.suspendHistory();
|
|
2097
2143
|
const o = e || s.getActiveObject();
|
|
2098
|
-
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", {
|
|
2099
2145
|
object: o,
|
|
2100
2146
|
withoutSave: t
|
|
2101
2147
|
}));
|
|
@@ -2179,7 +2225,7 @@ class it {
|
|
|
2179
2225
|
"height",
|
|
2180
2226
|
"fill"
|
|
2181
2227
|
]);
|
|
2182
|
-
const { canvas: g } = this.editor, u = new ve(
|
|
2228
|
+
const { canvas: g } = this.editor, u = new ve(y({
|
|
2183
2229
|
id: e,
|
|
2184
2230
|
left: t,
|
|
2185
2231
|
top: s,
|
|
@@ -2219,7 +2265,7 @@ class it {
|
|
|
2219
2265
|
"radius",
|
|
2220
2266
|
"fill"
|
|
2221
2267
|
]);
|
|
2222
|
-
const { canvas: h } = this.editor, g = new Ae(
|
|
2268
|
+
const { canvas: h } = this.editor, g = new Ae(y({
|
|
2223
2269
|
id: e,
|
|
2224
2270
|
left: t,
|
|
2225
2271
|
top: s,
|
|
@@ -2261,7 +2307,7 @@ class it {
|
|
|
2261
2307
|
"height",
|
|
2262
2308
|
"fill"
|
|
2263
2309
|
]);
|
|
2264
|
-
const { canvas: g } = this.editor, u = new Se(
|
|
2310
|
+
const { canvas: g } = this.editor, u = new Se(y({
|
|
2265
2311
|
id: e,
|
|
2266
2312
|
left: t,
|
|
2267
2313
|
top: s,
|
|
@@ -2285,7 +2331,7 @@ class at {
|
|
|
2285
2331
|
* @fires editor:object-copied
|
|
2286
2332
|
*/
|
|
2287
2333
|
copy() {
|
|
2288
|
-
return
|
|
2334
|
+
return v(this, null, function* () {
|
|
2289
2335
|
const { canvas: e, errorManager: t } = this.editor, s = e.getActiveObject();
|
|
2290
2336
|
if (!s) return;
|
|
2291
2337
|
try {
|
|
@@ -2372,7 +2418,7 @@ class at {
|
|
|
2372
2418
|
* @fires editor:object-pasted
|
|
2373
2419
|
*/
|
|
2374
2420
|
paste() {
|
|
2375
|
-
return
|
|
2421
|
+
return v(this, null, function* () {
|
|
2376
2422
|
const { canvas: e } = this.editor;
|
|
2377
2423
|
if (!this.clipboard) return;
|
|
2378
2424
|
const t = yield this.clipboard.clone(["format"]);
|
|
@@ -2381,13 +2427,13 @@ class at {
|
|
|
2381
2427
|
left: t.left + 10,
|
|
2382
2428
|
top: t.top + 10,
|
|
2383
2429
|
evented: !0
|
|
2384
|
-
}), t instanceof
|
|
2430
|
+
}), t instanceof I ? (t.canvas = e, t.forEachObject((s) => {
|
|
2385
2431
|
e.add(s);
|
|
2386
2432
|
})) : e.add(t), e.setActiveObject(t), e.requestRenderAll(), e.fire("editor:object-pasted", { object: t });
|
|
2387
2433
|
});
|
|
2388
2434
|
}
|
|
2389
2435
|
}
|
|
2390
|
-
class
|
|
2436
|
+
class V {
|
|
2391
2437
|
constructor({ editor: e }) {
|
|
2392
2438
|
this.editor = e;
|
|
2393
2439
|
}
|
|
@@ -2412,7 +2458,7 @@ class F {
|
|
|
2412
2458
|
lockSkewingY: !0,
|
|
2413
2459
|
locked: !0
|
|
2414
2460
|
};
|
|
2415
|
-
a.set(o), !t &&
|
|
2461
|
+
a.set(o), !t && V._isGroupOrSelection(a) && a.getObjects().forEach((r) => {
|
|
2416
2462
|
r.set(o);
|
|
2417
2463
|
}), n.renderAll(), s || i.saveState(), n.fire("editor:object-locked", {
|
|
2418
2464
|
object: a,
|
|
@@ -2440,7 +2486,7 @@ class F {
|
|
|
2440
2486
|
lockSkewingY: !1,
|
|
2441
2487
|
locked: !1
|
|
2442
2488
|
};
|
|
2443
|
-
i.set(a),
|
|
2489
|
+
i.set(a), V._isGroupOrSelection(i) && i.getObjects().forEach((o) => {
|
|
2444
2490
|
o.set(a);
|
|
2445
2491
|
}), s.renderAll(), t || n.saveState(), s.fire("editor:object-unlocked", {
|
|
2446
2492
|
object: i,
|
|
@@ -2448,7 +2494,7 @@ class F {
|
|
|
2448
2494
|
});
|
|
2449
2495
|
}
|
|
2450
2496
|
static _isGroupOrSelection(e) {
|
|
2451
|
-
return e instanceof
|
|
2497
|
+
return e instanceof I || e instanceof Q;
|
|
2452
2498
|
}
|
|
2453
2499
|
}
|
|
2454
2500
|
class ot {
|
|
@@ -2469,8 +2515,8 @@ class ot {
|
|
|
2469
2515
|
const { canvas: s, historyManager: n } = this.editor;
|
|
2470
2516
|
n.suspendHistory();
|
|
2471
2517
|
const i = e || s.getActiveObject();
|
|
2472
|
-
if (!i || !(i instanceof
|
|
2473
|
-
const a = i.getObjects(), o = new
|
|
2518
|
+
if (!i || !(i instanceof I)) return;
|
|
2519
|
+
const a = i.getObjects(), o = new Q(a);
|
|
2474
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", {
|
|
2475
2521
|
object: i,
|
|
2476
2522
|
group: o,
|
|
@@ -2491,10 +2537,10 @@ class ot {
|
|
|
2491
2537
|
const { canvas: s, historyManager: n } = this.editor;
|
|
2492
2538
|
n.suspendHistory();
|
|
2493
2539
|
const i = e || s.getActiveObject();
|
|
2494
|
-
if (!(i instanceof
|
|
2540
|
+
if (!(i instanceof Q)) return;
|
|
2495
2541
|
const a = i.removeAll();
|
|
2496
2542
|
s.remove(i), a.forEach((d) => s.add(d));
|
|
2497
|
-
const o = new
|
|
2543
|
+
const o = new I(a, {
|
|
2498
2544
|
canvas: s
|
|
2499
2545
|
});
|
|
2500
2546
|
s.setActiveObject(o), s.renderAll(), n.resumeHistory(), t || n.saveState(), s.fire("editor:objects-ungrouped", {
|
|
@@ -2515,7 +2561,7 @@ class rt {
|
|
|
2515
2561
|
selectAll() {
|
|
2516
2562
|
const { canvas: e, canvasManager: t, objectLockManager: s } = this.editor;
|
|
2517
2563
|
e.discardActiveObject();
|
|
2518
|
-
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];
|
|
2519
2565
|
i && s.lockObject({ object: a, skipInnerObjects: !0, withoutSave: !0 }), e.setActiveObject(a), e.requestRenderAll(), e.fire("editor:all-objects-selected", { selected: a });
|
|
2520
2566
|
}
|
|
2521
2567
|
}
|
|
@@ -2609,7 +2655,7 @@ const dt = {
|
|
|
2609
2655
|
REDO_ERROR: "REDO_ERROR"
|
|
2610
2656
|
}
|
|
2611
2657
|
};
|
|
2612
|
-
class
|
|
2658
|
+
class G {
|
|
2613
2659
|
constructor({ editor: e }) {
|
|
2614
2660
|
this._buffer = [], this.editor = e;
|
|
2615
2661
|
}
|
|
@@ -2636,7 +2682,7 @@ class V {
|
|
|
2636
2682
|
* @fires editor:error
|
|
2637
2683
|
*/
|
|
2638
2684
|
emitError({ origin: e = "ImageEditor", method: t = "Unknown Method", code: s, data: n, message: i }) {
|
|
2639
|
-
if (!
|
|
2685
|
+
if (!G.isValidErrorCode(s)) {
|
|
2640
2686
|
console.warn("Неизвестный код ошибки: ", { code: s, origin: e, method: t });
|
|
2641
2687
|
return;
|
|
2642
2688
|
}
|
|
@@ -2650,7 +2696,7 @@ class V {
|
|
|
2650
2696
|
message: a,
|
|
2651
2697
|
data: n
|
|
2652
2698
|
};
|
|
2653
|
-
this._buffer.push(
|
|
2699
|
+
this._buffer.push(y({
|
|
2654
2700
|
type: "editor:error"
|
|
2655
2701
|
}, o)), this.editor.canvas.fire("editor:error", o);
|
|
2656
2702
|
}
|
|
@@ -2665,7 +2711,7 @@ class V {
|
|
|
2665
2711
|
* @fires editor:warning
|
|
2666
2712
|
*/
|
|
2667
2713
|
emitWarning({ origin: e = "ImageEditor", method: t = "Unknown Method", code: s, message: n, data: i }) {
|
|
2668
|
-
if (!
|
|
2714
|
+
if (!G.isValidErrorCode(s)) {
|
|
2669
2715
|
console.warn("Неизвестный код предупреждения: ", { code: s, origin: e, method: t });
|
|
2670
2716
|
return;
|
|
2671
2717
|
}
|
|
@@ -2678,7 +2724,7 @@ class V {
|
|
|
2678
2724
|
message: a,
|
|
2679
2725
|
data: i
|
|
2680
2726
|
};
|
|
2681
|
-
this._buffer.push(
|
|
2727
|
+
this._buffer.push(y({
|
|
2682
2728
|
type: "editor:warning"
|
|
2683
2729
|
}, o)), this.editor.canvas.fire("editor:warning", o);
|
|
2684
2730
|
}
|
|
@@ -2706,7 +2752,7 @@ class ne {
|
|
|
2706
2752
|
* @fires editor:ready
|
|
2707
2753
|
*/
|
|
2708
2754
|
init() {
|
|
2709
|
-
return
|
|
2755
|
+
return v(this, null, function* () {
|
|
2710
2756
|
const {
|
|
2711
2757
|
editorContainerWidth: e,
|
|
2712
2758
|
editorContainerHeight: t,
|
|
@@ -2719,7 +2765,7 @@ class ne {
|
|
|
2719
2765
|
scaleType: r,
|
|
2720
2766
|
_onReadyCallback: l
|
|
2721
2767
|
} = this.options;
|
|
2722
|
-
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) {
|
|
2723
2769
|
const {
|
|
2724
2770
|
source: h,
|
|
2725
2771
|
scale: g = `image-${r}`,
|
|
@@ -2884,10 +2930,11 @@ const lt = {
|
|
|
2884
2930
|
undoRedoByHotKeys: !0,
|
|
2885
2931
|
selectAllByHotkey: !0,
|
|
2886
2932
|
deleteObjectsByHotkey: !0,
|
|
2887
|
-
resetObjectFitByDoubleClick: !0
|
|
2933
|
+
resetObjectFitByDoubleClick: !0,
|
|
2934
|
+
keyboardIgnoreSelectors: []
|
|
2888
2935
|
};
|
|
2889
2936
|
function bt(c, e = {}) {
|
|
2890
|
-
const t =
|
|
2937
|
+
const t = y(y({}, lt), e), s = document.getElementById(c);
|
|
2891
2938
|
if (!s)
|
|
2892
2939
|
return Promise.reject(new Error(`Контейнер с ID "${c}" не найден.`));
|
|
2893
2940
|
const n = document.createElement("canvas");
|
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",
|
|
@@ -14,12 +18,18 @@
|
|
|
14
18
|
"build": "vite build --config vite.config.prod.js",
|
|
15
19
|
"build:docs": "vite build --config vite.config.docs.js",
|
|
16
20
|
"preview": "vite preview",
|
|
17
|
-
"lint": "eslint \"src/**/*.{js,ts}\""
|
|
21
|
+
"lint": "eslint \"src/**/*.{js,ts}\"",
|
|
22
|
+
"test": "jest --coverage",
|
|
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"
|
|
18
26
|
},
|
|
19
27
|
"devDependencies": {
|
|
20
28
|
"@babel/core": "^7.26.7",
|
|
21
|
-
"@babel/preset-env": "^7.
|
|
29
|
+
"@babel/preset-env": "^7.28.3",
|
|
22
30
|
"@eslint/js": "^9.16.0",
|
|
31
|
+
"@types/fabric": "^5.3.10",
|
|
32
|
+
"@types/jest": "^30.0.0",
|
|
23
33
|
"@typescript-eslint/eslint-plugin": "^8.36.0",
|
|
24
34
|
"@typescript-eslint/parser": "^8.36.0",
|
|
25
35
|
"eslint": "^8.57.1",
|
|
@@ -29,9 +39,13 @@
|
|
|
29
39
|
"eslint-plugin-n": "^15.7.0",
|
|
30
40
|
"eslint-plugin-promise": "^6.6.0",
|
|
31
41
|
"eslint-plugin-sort-keys-fix": "^1.1.2",
|
|
32
|
-
"eslint-plugin-vue": "^9.
|
|
33
|
-
"globals": "^15.
|
|
42
|
+
"eslint-plugin-vue": "^9.33.0",
|
|
43
|
+
"globals": "^15.15.0",
|
|
44
|
+
"jest": "^29.7.0",
|
|
45
|
+
"jest-environment-jsdom": "^29.7.0",
|
|
34
46
|
"prettier": "^3.4.2",
|
|
47
|
+
"ts-jest": "^29.4.1",
|
|
48
|
+
"ts-node": "^10.9.2",
|
|
35
49
|
"vite": "^6.3.5",
|
|
36
50
|
"vite-bundle-analyzer": "^0.21.0",
|
|
37
51
|
"vite-plugin-babel": "^1.3.0",
|
|
@@ -40,8 +54,8 @@
|
|
|
40
54
|
},
|
|
41
55
|
"dependencies": {
|
|
42
56
|
"diff-match-patch": "^1.0.5",
|
|
43
|
-
"fabric": "^6.
|
|
44
|
-
"jsondiffpatch": "^0.6.
|
|
57
|
+
"fabric": "^6.7.1",
|
|
58
|
+
"jsondiffpatch": "^0.6.2",
|
|
45
59
|
"jspdf": "^3.0.1",
|
|
46
60
|
"nanoid": "^5.0.9"
|
|
47
61
|
},
|