@anu3ev/fabric-image-editor 0.5.25 → 0.5.26
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 +782 -662
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var Ne = Object.prototype.hasOwnProperty,
|
|
5
|
-
var
|
|
1
|
+
var ls = Object.defineProperty, hs = Object.defineProperties;
|
|
2
|
+
var us = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var ie = Object.getOwnPropertySymbols;
|
|
4
|
+
var Ne = Object.prototype.hasOwnProperty, ke = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var Be = (h, t, e) => t in h ? ls(h, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : h[t] = e, P = (h, t) => {
|
|
6
6
|
for (var e in t || (t = {}))
|
|
7
|
-
Ne.call(t, e) &&
|
|
8
|
-
if (
|
|
9
|
-
for (var e of
|
|
10
|
-
|
|
7
|
+
Ne.call(t, e) && Be(h, e, t[e]);
|
|
8
|
+
if (ie)
|
|
9
|
+
for (var e of ie(t))
|
|
10
|
+
ke.call(t, e) && Be(h, e, t[e]);
|
|
11
11
|
return h;
|
|
12
|
-
},
|
|
12
|
+
}, St = (h, t) => hs(h, us(t));
|
|
13
13
|
var gt = (h, t) => {
|
|
14
14
|
var e = {};
|
|
15
15
|
for (var s in h)
|
|
16
16
|
Ne.call(h, s) && t.indexOf(s) < 0 && (e[s] = h[s]);
|
|
17
|
-
if (h != null &&
|
|
18
|
-
for (var s of
|
|
19
|
-
t.indexOf(s) < 0 &&
|
|
17
|
+
if (h != null && ie)
|
|
18
|
+
for (var s of ie(h))
|
|
19
|
+
t.indexOf(s) < 0 && ke.call(h, s) && (e[s] = h[s]);
|
|
20
20
|
return e;
|
|
21
21
|
};
|
|
22
|
-
var
|
|
22
|
+
var z = (h, t, e) => new Promise((s, n) => {
|
|
23
23
|
var o = (r) => {
|
|
24
24
|
try {
|
|
25
25
|
a(e.next(r));
|
|
@@ -35,15 +35,16 @@ var W = (h, t, e) => new Promise((s, n) => {
|
|
|
35
35
|
}, a = (r) => r.done ? s(r.value) : Promise.resolve(r.value).then(o, i);
|
|
36
36
|
a((e = e.apply(h, t)).next());
|
|
37
37
|
});
|
|
38
|
-
import { ActiveSelection as F, Textbox as at, util as ht, controlsUtils as
|
|
39
|
-
import { create as
|
|
38
|
+
import { ActiveSelection as F, Textbox as at, util as ht, controlsUtils as Pe, InteractiveFabricObject as ze, Point as et, FitContentLayout as We, loadSVGFromURL as fs, FabricImage as qt, Gradient as Ue, Rect as gs, Circle as ps, Triangle as ms, Group as Rt, Color as ys, classRegistry as Fe, loadSVGFromString as vs, Canvas as bs, Pattern as Ms } from "fabric";
|
|
39
|
+
import { create as Ss } from "jsondiffpatch";
|
|
40
40
|
import ws from "diff-match-patch";
|
|
41
|
-
var
|
|
41
|
+
var As = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", K = function() {
|
|
42
42
|
for (var t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 21, e = "", s = crypto.getRandomValues(new Uint8Array(t |= 0)); t--; )
|
|
43
|
-
e +=
|
|
43
|
+
e += As[s[t] & 63];
|
|
44
44
|
return e;
|
|
45
45
|
};
|
|
46
|
-
|
|
46
|
+
const Ye = 300;
|
|
47
|
+
class Ee {
|
|
47
48
|
/**
|
|
48
49
|
* Конструктор принимает редактор и опции.
|
|
49
50
|
* @param params
|
|
@@ -61,7 +62,7 @@ class $t {
|
|
|
61
62
|
* @param params.options.adaptCanvasToContainerOnResize — адаптировать канвас к размерам контейнера при изменении размеров окна
|
|
62
63
|
*/
|
|
63
64
|
constructor({ editor: t, options: e = {} }) {
|
|
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 = t, this.canvas = t.canvas, this.options = e, this.handleContainerResizeBound =
|
|
65
|
+
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 = t, this.canvas = t.canvas, this.options = e, this.handleContainerResizeBound = Ee.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 = this.handleObjectModifiedHistory.bind(this), this.handleObjectRotatingHistoryBound = this.handleObjectRotatingHistory.bind(this), this.handleObjectTransformStartBound = this.handleObjectTransformStart.bind(this), this.handleObjectTransformEndBound = this.handleObjectTransformEnd.bind(this), this.handleObjectAddedHistoryBound = this.handleObjectAddedHistory.bind(this), this.handleObjectRemovedHistoryBound = this.handleObjectRemovedHistory.bind(this), this.handleOverlayUpdateBound = this.handleOverlayUpdate.bind(this), this.handleBackgroundUpdateBound = this.handleBackgroundUpdate.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
66
|
}
|
|
66
67
|
/**
|
|
67
68
|
* Инициализация всех обработчиков согласно опциям.
|
|
@@ -79,7 +80,7 @@ class $t {
|
|
|
79
80
|
deleteObjectsByHotkey: c,
|
|
80
81
|
resetObjectFitByDoubleClick: d
|
|
81
82
|
} = this.options;
|
|
82
|
-
e && (this.canvas.on("mouse:down", this.handleCanvasDragStartBound), this.canvas.on("mouse:move", this.handleCanvasDraggingBound), this.canvas.on("mouse:up", this.handleCanvasDragEndBound), document.addEventListener("keydown", this.handleSpaceKeyDownBound, { capture: !0 }), document.addEventListener("keyup", this.handleSpaceKeyUpBound, { capture: !0 })), s && this.canvas.on("mouse:wheel", this.handleMouseWheelZoomBound), n && (this.canvas.on("selection:created", this.handleBringToFrontBound), this.canvas.on("selection:updated", this.handleBringToFrontBound)), d && this.canvas.on("mouse:dblclick", this.handleResetObjectFitBound), t && window.addEventListener("resize", this.handleContainerResizeBound, { capture: !0 }), o && document.addEventListener("keydown", this.handleCopyEventBound, { capture: !0 }), i && document.addEventListener("paste", this.handlePasteEventBound, { capture: !0 }), a && (document.addEventListener("keydown", this.handleUndoRedoEventBound, { capture: !0 }), document.addEventListener("keyup", this.handleUndoRedoKeyUpBound, { capture: !0 })), r && document.addEventListener("keydown", this.handleSelectAllEventBound, { capture: !0 }), c && document.addEventListener("keydown", this.handleDeleteObjectsEventBound, { capture: !0 }), this.canvas.on("object:modified", this.handleObjectModifiedHistoryBound), this.canvas.on("object:rotating", this.handleObjectRotatingHistoryBound), this.canvas.on("object:added", this.handleObjectAddedHistoryBound), this.canvas.on("object:removed", this.handleObjectRemovedHistoryBound), this.canvas.on("object:added", this.handleOverlayUpdateBound), this.canvas.on("selection:created", this.handleOverlayUpdateBound), this.canvas.on("selection:created", this.handleLockedSelectionBound), this.canvas.on("selection:updated", this.handleLockedSelectionBound), this.canvas.on("object:added", this.handleBackgroundUpdateBound), this.canvas.on("selection:created", this.handleBackgroundUpdateBound);
|
|
83
|
+
e && (this.canvas.on("mouse:down", this.handleCanvasDragStartBound), this.canvas.on("mouse:move", this.handleCanvasDraggingBound), this.canvas.on("mouse:up", this.handleCanvasDragEndBound), document.addEventListener("keydown", this.handleSpaceKeyDownBound, { capture: !0 }), document.addEventListener("keyup", this.handleSpaceKeyUpBound, { capture: !0 })), s && this.canvas.on("mouse:wheel", this.handleMouseWheelZoomBound), n && (this.canvas.on("selection:created", this.handleBringToFrontBound), this.canvas.on("selection:updated", this.handleBringToFrontBound)), d && this.canvas.on("mouse:dblclick", this.handleResetObjectFitBound), t && window.addEventListener("resize", this.handleContainerResizeBound, { capture: !0 }), o && document.addEventListener("keydown", this.handleCopyEventBound, { capture: !0 }), i && document.addEventListener("paste", this.handlePasteEventBound, { capture: !0 }), a && (document.addEventListener("keydown", this.handleUndoRedoEventBound, { capture: !0 }), document.addEventListener("keyup", this.handleUndoRedoKeyUpBound, { capture: !0 })), r && document.addEventListener("keydown", this.handleSelectAllEventBound, { capture: !0 }), c && document.addEventListener("keydown", this.handleDeleteObjectsEventBound, { capture: !0 }), this.canvas.on("object:modified", this.handleObjectModifiedHistoryBound), this.canvas.on("object:rotating", this.handleObjectRotatingHistoryBound), this.canvas.on("object:added", this.handleObjectAddedHistoryBound), this.canvas.on("object:removed", this.handleObjectRemovedHistoryBound), this.canvas.on("object:moving", this.handleObjectTransformStartBound), this.canvas.on("object:scaling", this.handleObjectTransformStartBound), this.canvas.on("object:rotating", this.handleObjectTransformStartBound), this.canvas.on("object:skewing", this.handleObjectTransformStartBound), this.canvas.on("object:resizing", this.handleObjectTransformStartBound), this.canvas.on("object:modified", this.handleObjectTransformEndBound), this.canvas.on("object:added", this.handleOverlayUpdateBound), this.canvas.on("selection:created", this.handleOverlayUpdateBound), this.canvas.on("selection:created", this.handleLockedSelectionBound), this.canvas.on("selection:updated", this.handleLockedSelectionBound), this.canvas.on("object:added", this.handleBackgroundUpdateBound), this.canvas.on("selection:created", this.handleBackgroundUpdateBound);
|
|
83
84
|
}
|
|
84
85
|
/**
|
|
85
86
|
* При массовом выделении объектов удаляем из него залоченные.
|
|
@@ -120,10 +121,32 @@ class $t {
|
|
|
120
121
|
* Срабатывают при изменении объектов (перемещение, изменение размера и т.д.).
|
|
121
122
|
*/
|
|
122
123
|
handleObjectModifiedHistory() {
|
|
123
|
-
|
|
124
|
+
const { historyManager: t, textManager: e } = this.editor;
|
|
125
|
+
t.skipHistory || e.isTextEditingActive || t.scheduleSaveState({
|
|
126
|
+
delayMs: Ye,
|
|
127
|
+
reason: "object-modified"
|
|
128
|
+
});
|
|
124
129
|
}
|
|
125
130
|
handleObjectRotatingHistory() {
|
|
126
|
-
|
|
131
|
+
const { historyManager: t, textManager: e } = this.editor;
|
|
132
|
+
t.skipHistory || e.isTextEditingActive || t.scheduleSaveState({
|
|
133
|
+
delayMs: Ye,
|
|
134
|
+
reason: "object-rotating"
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Фиксирует старт трансформации объекта для корректного undo.
|
|
139
|
+
* @param options - параметры события
|
|
140
|
+
* @param options.target - объект, который трансформируется
|
|
141
|
+
*/
|
|
142
|
+
handleObjectTransformStart({ target: t }) {
|
|
143
|
+
t && this.editor.historyManager.beginAction({ reason: "object-transform" });
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Завершает трансформацию объекта.
|
|
147
|
+
*/
|
|
148
|
+
handleObjectTransformEnd() {
|
|
149
|
+
this.editor.historyManager.endAction({ reason: "object-transform" });
|
|
127
150
|
}
|
|
128
151
|
handleObjectAddedHistory() {
|
|
129
152
|
this.editor.historyManager.skipHistory || this.editor.textManager.isTextEditingActive || this.editor.historyManager.saveState();
|
|
@@ -175,7 +198,7 @@ class $t {
|
|
|
175
198
|
* @param event.code — код клавиши
|
|
176
199
|
*/
|
|
177
200
|
handleUndoRedoEvent(t) {
|
|
178
|
-
return
|
|
201
|
+
return z(this, null, function* () {
|
|
179
202
|
const { ctrlKey: e, metaKey: s, code: n, repeat: o } = t;
|
|
180
203
|
this._shouldIgnoreKeyboardEvent(t) || !e && !s || o || !/Mac/i.test(navigator.userAgent) && this.isUndoRedoKeyPressed || (n === "KeyZ" ? (t.preventDefault(), this.isUndoRedoKeyPressed = !0, yield this.editor.historyManager.undo()) : n === "KeyY" && (t.preventDefault(), this.isUndoRedoKeyPressed = !0, yield this.editor.historyManager.redo()));
|
|
181
204
|
});
|
|
@@ -391,7 +414,7 @@ class $t {
|
|
|
391
414
|
* Метод для удаления всех слушателей
|
|
392
415
|
*/
|
|
393
416
|
destroy() {
|
|
394
|
-
window.removeEventListener("resize", this.handleContainerResizeBound, { capture: !0 }), document.removeEventListener("keydown", this.handleCopyEventBound, { capture: !0 }), document.removeEventListener("paste", this.handlePasteEventBound, { capture: !0 }), document.removeEventListener("keydown", this.handleUndoRedoEventBound, { capture: !0 }), document.removeEventListener("keyup", this.handleUndoRedoKeyUpBound, { capture: !0 }), document.removeEventListener("keydown", this.handleSelectAllEventBound, { capture: !0 }), document.removeEventListener("keydown", this.handleDeleteObjectsEventBound, { capture: !0 }), this.options.canvasDragging && (this.canvas.off("mouse:down", this.handleCanvasDragStartBound), this.canvas.off("mouse:move", this.handleCanvasDraggingBound), this.canvas.off("mouse:up", this.handleCanvasDragEndBound), document.removeEventListener("keydown", this.handleSpaceKeyDownBound, { capture: !0 }), document.removeEventListener("keyup", this.handleSpaceKeyUpBound, { capture: !0 })), this.options.mouseWheelZooming && this.canvas.off("mouse:wheel", this.handleMouseWheelZoomBound), this.options.bringToFrontOnSelection && (this.canvas.off("selection:created", this.handleBringToFrontBound), this.canvas.off("selection:updated", this.handleBringToFrontBound)), this.options.resetObjectFitByDoubleClick && this.canvas.off("mouse:dblclick", this.handleResetObjectFitBound), this.canvas.off("object:modified", this.handleObjectModifiedHistoryBound), this.canvas.off("object:rotating", this.handleObjectRotatingHistoryBound), this.canvas.off("object:added", this.handleObjectAddedHistoryBound), this.canvas.off("object:removed", this.handleObjectRemovedHistoryBound), this.canvas.off("object:added", this.handleOverlayUpdateBound), this.canvas.off("selection:created", this.handleOverlayUpdateBound), this.canvas.off("object:added", this.handleBackgroundUpdateBound), this.canvas.off("selection:created", this.handleBackgroundUpdateBound), this.canvas.off("selection:created", this.handleLockedSelectionBound), this.canvas.off("selection:updated", this.handleLockedSelectionBound);
|
|
417
|
+
window.removeEventListener("resize", this.handleContainerResizeBound, { capture: !0 }), document.removeEventListener("keydown", this.handleCopyEventBound, { capture: !0 }), document.removeEventListener("paste", this.handlePasteEventBound, { capture: !0 }), document.removeEventListener("keydown", this.handleUndoRedoEventBound, { capture: !0 }), document.removeEventListener("keyup", this.handleUndoRedoKeyUpBound, { capture: !0 }), document.removeEventListener("keydown", this.handleSelectAllEventBound, { capture: !0 }), document.removeEventListener("keydown", this.handleDeleteObjectsEventBound, { capture: !0 }), this.options.canvasDragging && (this.canvas.off("mouse:down", this.handleCanvasDragStartBound), this.canvas.off("mouse:move", this.handleCanvasDraggingBound), this.canvas.off("mouse:up", this.handleCanvasDragEndBound), document.removeEventListener("keydown", this.handleSpaceKeyDownBound, { capture: !0 }), document.removeEventListener("keyup", this.handleSpaceKeyUpBound, { capture: !0 })), this.options.mouseWheelZooming && this.canvas.off("mouse:wheel", this.handleMouseWheelZoomBound), this.options.bringToFrontOnSelection && (this.canvas.off("selection:created", this.handleBringToFrontBound), this.canvas.off("selection:updated", this.handleBringToFrontBound)), this.options.resetObjectFitByDoubleClick && this.canvas.off("mouse:dblclick", this.handleResetObjectFitBound), this.canvas.off("object:modified", this.handleObjectModifiedHistoryBound), this.canvas.off("object:rotating", this.handleObjectRotatingHistoryBound), this.canvas.off("object:added", this.handleObjectAddedHistoryBound), this.canvas.off("object:removed", this.handleObjectRemovedHistoryBound), this.canvas.off("object:moving", this.handleObjectTransformStartBound), this.canvas.off("object:scaling", this.handleObjectTransformStartBound), this.canvas.off("object:rotating", this.handleObjectTransformStartBound), this.canvas.off("object:skewing", this.handleObjectTransformStartBound), this.canvas.off("object:resizing", this.handleObjectTransformStartBound), this.canvas.off("object:modified", this.handleObjectTransformEndBound), this.canvas.off("object:added", this.handleOverlayUpdateBound), this.canvas.off("selection:created", this.handleOverlayUpdateBound), this.canvas.off("object:added", this.handleBackgroundUpdateBound), this.canvas.off("selection:created", this.handleBackgroundUpdateBound), this.canvas.off("selection:created", this.handleLockedSelectionBound), this.canvas.off("selection:updated", this.handleLockedSelectionBound);
|
|
395
418
|
}
|
|
396
419
|
/**
|
|
397
420
|
* Дебаунс для снижения частоты вызова функции.
|
|
@@ -408,7 +431,7 @@ class $t {
|
|
|
408
431
|
};
|
|
409
432
|
}
|
|
410
433
|
}
|
|
411
|
-
class
|
|
434
|
+
class js {
|
|
412
435
|
/**
|
|
413
436
|
* Класс для динамической загрузки внешних модулей.
|
|
414
437
|
*/
|
|
@@ -426,7 +449,7 @@ class As {
|
|
|
426
449
|
return this.loaders[t] ? (this.cache.has(t) || this.cache.set(t, this.loaders[t]()), this.cache.get(t)) : Promise.reject(new Error(`Unknown module "${t}"`));
|
|
427
450
|
}
|
|
428
451
|
}
|
|
429
|
-
function
|
|
452
|
+
function Is(h) {
|
|
430
453
|
return new Worker(
|
|
431
454
|
"" + new URL("assets/worker-CN39s7P7.js", import.meta.url).href,
|
|
432
455
|
{
|
|
@@ -440,7 +463,7 @@ class Cs {
|
|
|
440
463
|
* По-умолчанию использует DefaultWorker из соседнего файла
|
|
441
464
|
*/
|
|
442
465
|
constructor(t) {
|
|
443
|
-
t ? this.worker = new Worker(t, { type: "module" }) : this.worker = new
|
|
466
|
+
t ? this.worker = new Worker(t, { type: "module" }) : this.worker = new Is(), this._callbacks = /* @__PURE__ */ new Map(), this.worker.onmessage = this._handleMessage.bind(this);
|
|
444
467
|
}
|
|
445
468
|
/**
|
|
446
469
|
* Обработчик сообщений от воркера
|
|
@@ -480,50 +503,50 @@ class Cs {
|
|
|
480
503
|
this.worker.terminate();
|
|
481
504
|
}
|
|
482
505
|
}
|
|
483
|
-
const dt = 12,
|
|
484
|
-
function
|
|
485
|
-
const o = dt, i =
|
|
486
|
-
h.save(), h.translate(t, e), h.rotate(ht.degreesToRadians(n.angle)), h.fillStyle =
|
|
506
|
+
const dt = 12, Ts = 2, Me = 8, Se = 20, Es = 100, we = 20, Ae = 8, Os = 100, he = 32, Oe = 1, Ls = "#2B2D33", Le = "#3D8BF4", De = "#FFFFFF";
|
|
507
|
+
function ae(h, t, e, s, n) {
|
|
508
|
+
const o = dt, i = Ts;
|
|
509
|
+
h.save(), h.translate(t, e), h.rotate(ht.degreesToRadians(n.angle)), h.fillStyle = De, h.strokeStyle = Le, h.lineWidth = Oe, h.beginPath(), h.roundRect(-o / 2, -o / 2, o, o, i), h.fill(), h.stroke(), h.restore();
|
|
487
510
|
}
|
|
488
|
-
function
|
|
489
|
-
const o =
|
|
490
|
-
h.save(), h.translate(t, e), h.rotate(ht.degreesToRadians(n.angle)), h.fillStyle =
|
|
511
|
+
function He(h, t, e, s, n) {
|
|
512
|
+
const o = Me, i = Se, a = Es;
|
|
513
|
+
h.save(), h.translate(t, e), h.rotate(ht.degreesToRadians(n.angle)), h.fillStyle = De, h.strokeStyle = Le, h.lineWidth = Oe, h.beginPath(), h.roundRect(-o / 2, -i / 2, o, i, a), h.fill(), h.stroke(), h.restore();
|
|
491
514
|
}
|
|
492
|
-
function
|
|
493
|
-
const o =
|
|
494
|
-
h.save(), h.translate(t, e), h.rotate(ht.degreesToRadians(n.angle)), h.fillStyle =
|
|
515
|
+
function Ze(h, t, e, s, n) {
|
|
516
|
+
const o = we, i = Ae, a = Os;
|
|
517
|
+
h.save(), h.translate(t, e), h.rotate(ht.degreesToRadians(n.angle)), h.fillStyle = De, h.strokeStyle = Le, h.lineWidth = Oe, h.beginPath(), h.roundRect(-o / 2, -i / 2, o, i, a), h.fill(), h.stroke(), h.restore();
|
|
495
518
|
}
|
|
496
|
-
const
|
|
497
|
-
|
|
498
|
-
function
|
|
499
|
-
const i =
|
|
500
|
-
h.save(), h.translate(t, e), h.rotate(ht.degreesToRadians(n.angle)), h.fillStyle =
|
|
519
|
+
const Ds = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTE4Ljc1IDQuMzc1djMuNzVhLjYyNS42MjUgMCAwIDEtLjYyNS42MjVoLTMuNzVhLjYyNS42MjUgMCAwIDEgMC0xLjI1aDIuMTRsLTIuMDc3LTEuOTAzLS4wMi0uMDE5YTYuMjUgNi4yNSAwIDEgMC0uMTMgOC45NjcuNjI2LjYyNiAwIDAgMSAuODYuOTA5QTcuNDU2IDcuNDU2IDAgMCAxIDEwIDE3LjVoLS4xMDNhNy41IDcuNSAwIDEgMSA1LjM5Ni0xMi44MTJMMTcuNSA2LjcwM1Y0LjM3NWEuNjI1LjYyNSAwIDAgMSAxLjI1IDBaIi8+PC9zdmc+", is = new Image();
|
|
520
|
+
is.src = Ds;
|
|
521
|
+
function _s(h, t, e, s, n) {
|
|
522
|
+
const i = he / 2;
|
|
523
|
+
h.save(), h.translate(t, e), h.rotate(ht.degreesToRadians(n.angle)), h.fillStyle = Ls, h.beginPath(), h.arc(0, 0, i, 0, 2 * Math.PI), h.fill(), h.drawImage(is, -i / 2, -i / 2, i, i), h.restore();
|
|
501
524
|
}
|
|
502
525
|
const Rs = {
|
|
503
526
|
// Угловые точки
|
|
504
527
|
tl: {
|
|
505
|
-
render:
|
|
528
|
+
render: ae,
|
|
506
529
|
sizeX: dt,
|
|
507
530
|
sizeY: dt,
|
|
508
531
|
offsetX: 0,
|
|
509
532
|
offsetY: 0
|
|
510
533
|
},
|
|
511
534
|
tr: {
|
|
512
|
-
render:
|
|
535
|
+
render: ae,
|
|
513
536
|
sizeX: dt,
|
|
514
537
|
sizeY: dt,
|
|
515
538
|
offsetX: 0,
|
|
516
539
|
offsetY: 0
|
|
517
540
|
},
|
|
518
541
|
bl: {
|
|
519
|
-
render:
|
|
542
|
+
render: ae,
|
|
520
543
|
sizeX: dt,
|
|
521
544
|
sizeY: dt,
|
|
522
545
|
offsetX: 0,
|
|
523
546
|
offsetY: 0
|
|
524
547
|
},
|
|
525
548
|
br: {
|
|
526
|
-
render:
|
|
549
|
+
render: ae,
|
|
527
550
|
sizeX: dt,
|
|
528
551
|
sizeY: dt,
|
|
529
552
|
offsetX: 0,
|
|
@@ -531,41 +554,41 @@ const Rs = {
|
|
|
531
554
|
},
|
|
532
555
|
// Середина вертикалей
|
|
533
556
|
ml: {
|
|
534
|
-
render:
|
|
535
|
-
sizeX:
|
|
557
|
+
render: He,
|
|
558
|
+
sizeX: Me,
|
|
536
559
|
sizeY: Se,
|
|
537
560
|
offsetX: 0,
|
|
538
561
|
offsetY: 0
|
|
539
562
|
},
|
|
540
563
|
mr: {
|
|
541
|
-
render:
|
|
542
|
-
sizeX:
|
|
564
|
+
render: He,
|
|
565
|
+
sizeX: Me,
|
|
543
566
|
sizeY: Se,
|
|
544
567
|
offsetX: 0,
|
|
545
568
|
offsetY: 0
|
|
546
569
|
},
|
|
547
570
|
// Середина горизонталей
|
|
548
571
|
mt: {
|
|
549
|
-
render:
|
|
550
|
-
sizeX:
|
|
551
|
-
sizeY:
|
|
572
|
+
render: Ze,
|
|
573
|
+
sizeX: we,
|
|
574
|
+
sizeY: Ae,
|
|
552
575
|
offsetX: 0,
|
|
553
576
|
offsetY: 0
|
|
554
577
|
},
|
|
555
578
|
mb: {
|
|
556
|
-
render:
|
|
557
|
-
sizeX:
|
|
558
|
-
sizeY:
|
|
579
|
+
render: Ze,
|
|
580
|
+
sizeX: we,
|
|
581
|
+
sizeY: Ae,
|
|
559
582
|
offsetX: 0,
|
|
560
583
|
offsetY: 0
|
|
561
584
|
},
|
|
562
585
|
// Специальный «rotate» контрол
|
|
563
586
|
mtr: {
|
|
564
|
-
render:
|
|
565
|
-
sizeX:
|
|
566
|
-
sizeY:
|
|
587
|
+
render: _s,
|
|
588
|
+
sizeX: he,
|
|
589
|
+
sizeY: he,
|
|
567
590
|
offsetX: 0,
|
|
568
|
-
offsetY: -
|
|
591
|
+
offsetY: -he
|
|
569
592
|
}
|
|
570
593
|
};
|
|
571
594
|
class ot {
|
|
@@ -597,9 +620,9 @@ class ot {
|
|
|
597
620
|
* Регистрирует контролы и настройки поведения выделений.
|
|
598
621
|
*/
|
|
599
622
|
static apply() {
|
|
600
|
-
const t =
|
|
623
|
+
const t = Pe.createObjectDefaultControls();
|
|
601
624
|
ot.applyControlOverrides(t), ze.ownDefaults.controls = t;
|
|
602
|
-
const e =
|
|
625
|
+
const e = Pe.createTextboxDefaultControls();
|
|
603
626
|
ot.applyControlOverrides(e), e.mt && (e.mt.visible = !1), e.mb && (e.mb.visible = !1), ot.wrapWidthControl(e.ml), ot.wrapWidthControl(e.mr), at.ownDefaults.controls = e, ot.patchActiveSelectionBounds(), ze.ownDefaults.snapAngle = 1;
|
|
604
627
|
}
|
|
605
628
|
/**
|
|
@@ -647,8 +670,8 @@ class ot {
|
|
|
647
670
|
height: f
|
|
648
671
|
}), this.setPositionByOrigin(g, "center", "center"), this.setCoords(), a;
|
|
649
672
|
};
|
|
650
|
-
const n =
|
|
651
|
-
|
|
673
|
+
const n = We.prototype.calcBoundingBox;
|
|
674
|
+
We.prototype.calcBoundingBox = function(o, i) {
|
|
652
675
|
const { target: a, type: r, overrides: c } = i;
|
|
653
676
|
if (r === "imperative" && c)
|
|
654
677
|
return c;
|
|
@@ -711,7 +734,7 @@ const U = class U {
|
|
|
711
734
|
this.fonts = t;
|
|
712
735
|
}
|
|
713
736
|
loadFonts() {
|
|
714
|
-
return
|
|
737
|
+
return z(this, null, function* () {
|
|
715
738
|
var n;
|
|
716
739
|
const t = (n = this.fonts) != null ? n : [];
|
|
717
740
|
if (!t.length) return;
|
|
@@ -722,7 +745,7 @@ const U = class U {
|
|
|
722
745
|
});
|
|
723
746
|
}
|
|
724
747
|
static loadFont(t, e) {
|
|
725
|
-
return
|
|
748
|
+
return z(this, null, function* () {
|
|
726
749
|
var c, d;
|
|
727
750
|
const s = typeof FontFace != "undefined", n = (c = t.family) == null ? void 0 : c.trim(), o = (d = t.source) == null ? void 0 : d.trim();
|
|
728
751
|
if (!n || !o) return;
|
|
@@ -871,8 +894,8 @@ U.registeredFontKeys = /* @__PURE__ */ new Set(), U.descriptorDefaults = {
|
|
|
871
894
|
featureSettings: "normal",
|
|
872
895
|
display: "auto"
|
|
873
896
|
};
|
|
874
|
-
let
|
|
875
|
-
const xs = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNNi44NzUgMi41YS42MjUuNjI1IDAgMCAwLS42MjUuNjI0VjYuMjVIMy4xMjVhLjYyNS42MjUgMCAwIDAtLjYyNS42MjV2MTBjMCAuMzQ1LjI4LjYyNS42MjUuNjI1aDEwYy4zNDUgMCAuNjI1LS4yOC42MjUtLjYyNXYtMy4xMjZoMy4xMjVjLjM0NSAwIC42MjUtLjI4LjYyNS0uNjI1di0xMGEuNjI1LjYyNSAwIDAgMC0uNjI1LS42MjVoLTEwWm02Ljg3NSAxMGgyLjVWMy43NUg3LjV2Mi41aDUuNjI1Yy4zNDUgMCAuNjI1LjI4LjYyNS42MjV2NS42MjRabS0xMCAzLjc1VjcuNWg4Ljc1djguNzVIMy43NVoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPjwvc3ZnPg==",
|
|
897
|
+
let je = U;
|
|
898
|
+
const xs = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNNi44NzUgMi41YS42MjUuNjI1IDAgMCAwLS42MjUuNjI0VjYuMjVIMy4xMjVhLjYyNS42MjUgMCAwIDAtLjYyNS42MjV2MTBjMCAuMzQ1LjI4LjYyNS42MjUuNjI1aDEwYy4zNDUgMCAuNjI1LS4yOC42MjUtLjYyNXYtMy4xMjZoMy4xMjVjLjM0NSAwIC42MjUtLjI4LjYyNS0uNjI1di0xMGEuNjI1LjYyNSAwIDAgMC0uNjI1LS42MjVoLTEwWm02Ljg3NSAxMGgyLjVWMy43NUg3LjV2Mi41aDUuNjI1Yy4zNDUgMCAuNjI1LjI4LjYyNS42MjV2NS42MjRabS0xMCAzLjc1VjcuNWg4Ljc1djguNzVIMy43NVoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPjwvc3ZnPg==", Bs = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMi41IDcuNWMwLS42OS41Ni0xLjI1IDEuMjUtMS4yNWgxMi41Yy42OSAwIDEuMjUuNTYgMS4yNSAxLjI1djguNzVjMCAuNjktLjU2IDEuMjUtMS4yNSAxLjI1SDMuNzVjLS42OSAwLTEuMjUtLjU2LTEuMjUtMS4yNVY3LjVabTEzLjc1IDBIMy43NXY4Ljc1aDEyLjVWNy41WiIgY2xpcC1ydWxlPSJldmVub2RkIi8+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMTAgMS44NzVhMi4xODggMi4xODggMCAwIDAtMi4xODggMi4xODh2Mi44MTJhLjYyNS42MjUgMCAxIDEtMS4yNSAwVjQuMDYyYTMuNDM3IDMuNDM3IDAgMSAxIDYuODc1IDB2Mi44MTNhLjYyNS42MjUgMCAxIDEtMS4yNSAwVjQuMDYyQTIuMTg4IDIuMTg4IDAgMCAwIDEwIDEuODc2WiIgY2xpcC1ydWxlPSJldmVub2RkIi8+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTEwIDEyLjgxM2EuOTM3LjkzNyAwIDEgMCAwLTEuODc1LjkzNy45MzcgMCAwIDAgMCAxLjg3NFoiLz48L3N2Zz4=", Ns = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTE2LjI1IDYuMjVINy41VjQuMzc1YTIuNSAyLjUgMCAwIDEgMi41LTIuNWMxLjIgMCAyLjI4MS44NiAyLjUxMiAyYS42MjUuNjI1IDAgMCAwIDEuMjI2LS4yNWMtLjM1NC0xLjczOC0xLjkyNS0zLTMuNzM4LTNhMy43NTQgMy43NTQgMCAwIDAtMy43NSAzLjc1VjYuMjVoLTIuNUExLjI1IDEuMjUgMCAwIDAgMi41IDcuNXY4Ljc1YTEuMjUgMS4yNSAwIDAgMCAxLjI1IDEuMjVoMTIuNWExLjI1IDEuMjUgMCAwIDAgMS4yNS0xLjI1VjcuNWExLjI1IDEuMjUgMCAwIDAtMS4yNS0xLjI1Wm0wIDEwSDMuNzVWNy41aDEyLjV2OC43NVptLTUuMzEzLTQuMzc1YS45MzcuOTM3IDAgMSAxLTEuODc0IDAgLjkzNy45MzcgMCAwIDEgMS44NzQgMFoiLz48L3N2Zz4K", ks = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTIuNSA4LjEyNSAxMCAxMi41bDcuNS00LjM3NUwxMCAzLjc1IDIuNSA4LjEyNVoiLz48cGF0aCBmaWxsPSIjZmZmIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik05LjY4NSAzLjIxYS42MjUuNjI1IDAgMCAxIC42MyAwbDcuNSA0LjM3NWEuNjI1LjYyNSAwIDAgMSAwIDEuMDhsLTcuNSA0LjM3NWEuNjI1LjYyNSAwIDAgMS0uNjMgMGwtNy41LTQuMzc1YS42MjUuNjI1IDAgMCAxIDAtMS4wOGw3LjUtNC4zNzVaTTMuNzQgOC4xMjUgMTAgMTEuNzc2bDYuMjYtMy42NTFMMTAgNC40NzQgMy43NCA4LjEyNVoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPjxwYXRoIGZpbGw9IiNmZmYiIGZpbGwtcnVsZT0iZXZlbm9kZCIgZD0iTTUuNCA5LjQ2YS42MjUuNjI1IDAgMCAxIC42MyAwTDEwIDExLjc3NmwzLjk3LTIuMzE2YS42MjUuNjI1IDAgMCAxIC42MyAwbDMuMjE1IDEuODc1YS42MjUuNjI1IDAgMCAxIDAgMS4wOGwtNy41IDQuMzc1YS42MjUuNjI1IDAgMCAxLS42MyAwbC03LjUtNC4zNzVhLjYyNS42MjUgMCAwIDEgMC0xLjA4TDUuNCA5LjQ2Wm0tMS42NiAyLjQxNUwxMCAxNS41MjZsNi4yNi0zLjY1MS0xLjk3NC0xLjE1MS0zLjk3MSAyLjMxNmEuNjI1LjYyNSAwIDAgMS0uNjMgMGwtMy45Ny0yLjMxNi0xLjk3NSAxLjE1MVoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPjwvc3ZnPg==", Ps = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNOS42ODUgMy4yMWEuNjI1LjYyNSAwIDAgMSAuNjMgMGw3LjUgNC4zNzVhLjYyNS42MjUgMCAwIDEgMCAxLjA4bC03LjUgNC4zNzVhLjYyNS42MjUgMCAwIDEtLjYzIDBsLTcuNS00LjM3NWEuNjI1LjYyNSAwIDAgMSAwLTEuMDhsNy41LTQuMzc1Wk0zLjc0IDguMTI1IDEwIDExLjc3Nmw2LjI2LTMuNjUxTDEwIDQuNDc0IDMuNzQgOC4xMjVaIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiLz48cGF0aCBmaWxsPSIjZmZmIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik01LjcxNCAxMCAxMCAxMi41bDQuMjg2LTIuNSAzLjIxNCAxLjg3NUwxMCAxNi4yNWwtNy41LTQuMzc1TDUuNzE0IDEwWiIgY2xpcC1ydWxlPSJldmVub2RkIi8+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNNS40IDkuNDZhLjYyNS42MjUgMCAwIDEgLjYzIDBMMTAgMTEuNzc2bDMuOTctMi4zMTZhLjYyNS42MjUgMCAwIDEgLjYzIDBsMy4yMTUgMS44NzVhLjYyNS42MjUgMCAwIDEgMCAxLjA4bC03LjUgNC4zNzVhLjYyNS42MjUgMCAwIDEtLjYzIDBsLTcuNS00LjM3NWEuNjI1LjYyNSAwIDAgMSAwLTEuMDhMNS40IDkuNDZabS0xLjY2IDIuNDE1TDEwIDE1LjUyNmw2LjI2LTMuNjUxLTEuOTc0LTEuMTUxLTMuOTcxIDIuMzE2YS42MjUuNjI1IDAgMCAxLS42MyAwbC0zLjk3LTIuMzE2LTEuOTc1IDEuMTUxWiIgY2xpcC1ydWxlPSJldmVub2RkIi8+PC9zdmc+", zs = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZD0ibTIuNSA2LjI1IDcuNSA0LjM3NSA3LjUtNC4zNzVMMTAgMS44NzUgMi41IDYuMjVaIi8+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNOS42ODUgMS4zMzVhLjYyNS42MjUgMCAwIDEgLjYzIDBsNy41IDQuMzc1YS42MjUuNjI1IDAgMCAxIDAgMS4wOGwtNy41IDQuMzc1YS42MjUuNjI1IDAgMCAxLS42MyAwbC03LjUtNC4zNzVhLjYyNS42MjUgMCAwIDEgMC0xLjA4bDcuNS00LjM3NVpNMy43NCA2LjI1IDEwIDkuOTAxbDYuMjYtMy42NTFMMTAgMi41OTkgMy43NCA2LjI1WiIgY2xpcC1ydWxlPSJldmVub2RkIi8+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNNS40IDExLjMzNWEuNjI1LjYyNSAwIDAgMSAuNjMgMEwxMCAxMy42NTFsMy45Ny0yLjMxNmEuNjI1LjYyNSAwIDAgMSAuNjMgMGwzLjIxNSAxLjg3NWEuNjI1LjYyNSAwIDAgMSAwIDEuMDhsLTcuNSA0LjM3NWEuNjI1LjYyNSAwIDAgMS0uNjMgMGwtNy41LTQuMzc1YS42MjUuNjI1IDAgMCAxIDAtMS4wOEw1LjQgMTEuMzM1Wk0zLjc0IDEzLjc1IDEwIDE3LjQwMWw2LjI2LTMuNjUxLTEuOTc0LTEuMTUxLTMuOTcxIDIuMzE2YS42MjUuNjI1IDAgMCAxLS42MyAwbC0zLjk3LTIuMzE2TDMuNzQgMTMuNzVaIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiLz48cGF0aCBmaWxsPSIjZmZmIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik01LjQgNy41ODVhLjYyNS42MjUgMCAwIDEgLjYzIDBMMTAgOS45MDFsMy45Ny0yLjMxNmEuNjI1LjYyNSAwIDAgMSAuNjMgMGwzLjIxNSAxLjg3NWEuNjI1LjYyNSAwIDAgMSAwIDEuMDhsLTcuNSA0LjM3NWEuNjI1LjYyNSAwIDAgMS0uNjMgMGwtNy41LTQuMzc1YS42MjUuNjI1IDAgMCAxIDAtMS4wOEw1LjQgNy41ODVaTTMuNzQgMTAgMTAgMTMuNjUxIDE2LjI2IDEwbC0xLjk3NC0xLjE1MS0zLjk3MSAyLjMxNmEuNjI1LjYyNSAwIDAgMS0uNjMgMGwtMy45Ny0yLjMxNkwzLjc0IDEwWiIgY2xpcC1ydWxlPSJldmVub2RkIi8+PC9zdmc+", Ws = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMS45NiAxMy40MzVhLjYyNS42MjUgMCAwIDEgLjg1NS0uMjI1TDEwIDE3LjQwMWw3LjE4NS00LjE5YS42MjUuNjI1IDAgMCAxIC42MyAxLjA3OWwtNy41IDQuMzc1YS42MjUuNjI1IDAgMCAxLS42MyAwbC03LjUtNC4zNzVhLjYyNS42MjUgMCAwIDEtLjIyNS0uODU1Wk05LjY4NSAxLjMzNWEuNjI1LjYyNSAwIDAgMSAuNjMgMGw3LjUgNC4zNzVhLjYyNS42MjUgMCAwIDEgMCAxLjA4bC03LjUgNC4zNzVhLjYyNS42MjUgMCAwIDEtLjYzIDBsLTcuNS00LjM3NWEuNjI1LjYyNSAwIDAgMSAwLTEuMDhsNy41LTQuMzc1Wk0zLjc0IDYuMjUgMTAgOS45MDFsNi4yNi0zLjY1MUwxMCAyLjU5OSAzLjc0IDYuMjVaIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiLz48cGF0aCBmaWxsPSIjZmZmIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGQ9Im01LjcxNCAxMS44NzUgNC4yODYgMi41IDQuMjg2LTIuNUwxNy41IDEzLjc1IDEwIDE4LjEyNSAyLjUgMTMuNzVsMy4yMTQtMS44NzVaIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiLz48cGF0aCBmaWxsPSIjZmZmIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik01LjQgMTEuMzM1YS42MjUuNjI1IDAgMCAxIC42MyAwTDEwIDEzLjY1MWwzLjk3LTIuMzE2YS42MjUuNjI1IDAgMCAxIC42MyAwbDMuMjE1IDEuODc1YS42MjUuNjI1IDAgMCAxIDAgMS4wOGwtNy41IDQuMzc1YS42MjUuNjI1IDAgMCAxLS42MyAwbC03LjUtNC4zNzVhLjYyNS42MjUgMCAwIDEgMC0xLjA4TDUuNCAxMS4zMzVaTTMuNzQgMTMuNzUgMTAgMTcuNDAxbDYuMjYtMy42NTEtMS45NzQtMS4xNTEtMy45NzEgMi4zMTZhLjYyNS42MjUgMCAwIDEtLjYzIDBsLTMuOTctMi4zMTZMMy43NCAxMy43NVoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPjxwYXRoIGZpbGw9IiNmZmYiIGZpbGwtcnVsZT0iZXZlbm9kZCIgZD0iTTUuNCA3LjU4NWEuNjI1LjYyNSAwIDAgMSAuNjMgMEwxMCA5LjkwMWwzLjk3LTIuMzE2YS42MjUuNjI1IDAgMCAxIC42MyAwbDMuMjE1IDEuODc1YS42MjUuNjI1IDAgMCAxIDAgMS4wOGwtNy41IDQuMzc1YS42MjUuNjI1IDAgMCAxLS42MyAwbC03LjUtNC4zNzVhLjYyNS42MjUgMCAwIDEgMC0xLjA4TDUuNCA3LjU4NVpNMy43NCAxMCAxMCAxMy42NTEgMTYuMjYgMTBsLTEuOTc0LTEuMTUxLTMuOTcxIDIuMzE2YS42MjUuNjI1IDAgMCAxLS42MyAwbC0zLjk3LTIuMzE2TDMuNzQgMTBaIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiLz48L3N2Zz4=", Us = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI0VDNEU0MCIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNOC4xMjUgMS4yNUExLjg3NSAxLjg3NSAwIDAgMCA2LjI1IDMuMTI1di42MjVIMy4xMjVhLjYyNS42MjUgMCAwIDAgMCAxLjI1aC42MjV2MTEuMjVBMS4yNSAxLjI1IDAgMCAwIDUgMTcuNWgxMGExLjI1IDEuMjUgMCAwIDAgMS4yNS0xLjI1VjVoLjYyNWEuNjI1LjYyNSAwIDAgMCAwLTEuMjVIMTMuNzV2LS42MjVhMS44NzUgMS44NzUgMCAwIDAtMS44NzUtMS44NzVoLTMuNzVabTQuMzc1IDIuNXYtLjYyNWEuNjI1LjYyNSAwIDAgMC0uNjI1LS42MjVoLTMuNzVhLjYyNS42MjUgMCAwIDAtLjYyNS42MjV2LjYyNWg1Wk01IDE2LjI1VjVoMTB2MTEuMjVINVpNOC4xMjUgNy41Yy4zNDUgMCAuNjI1LjI4LjYyNS42MjV2NWEuNjI1LjYyNSAwIDEgMS0xLjI1IDB2LTVjMC0uMzQ1LjI4LS42MjUuNjI1LS42MjVabTQuMzc1IDUuNjI1di01YS42MjUuNjI1IDAgMCAwLTEuMjUgMHY1YS42MjUuNjI1IDAgMSAwIDEuMjUgMFoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPjwvc3ZnPg==", Jt = {
|
|
876
899
|
style: {
|
|
877
900
|
position: "absolute",
|
|
878
901
|
display: "none",
|
|
@@ -940,16 +963,16 @@ const xs = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMj
|
|
|
940
963
|
offsetTop: 50,
|
|
941
964
|
icons: {
|
|
942
965
|
copyPaste: xs,
|
|
943
|
-
delete:
|
|
944
|
-
lock:
|
|
966
|
+
delete: Us,
|
|
967
|
+
lock: Bs,
|
|
945
968
|
unlock: Ns,
|
|
946
969
|
bringToFront: zs,
|
|
947
|
-
sendToBack:
|
|
948
|
-
bringForward:
|
|
949
|
-
sendBackwards:
|
|
970
|
+
sendToBack: Ws,
|
|
971
|
+
bringForward: ks,
|
|
972
|
+
sendBackwards: Ps
|
|
950
973
|
},
|
|
951
974
|
handlers: {
|
|
952
|
-
copyPaste: (h) =>
|
|
975
|
+
copyPaste: (h) => z(null, null, function* () {
|
|
953
976
|
h.clipboardManager.copyPaste();
|
|
954
977
|
}),
|
|
955
978
|
delete: (h) => {
|
|
@@ -975,18 +998,18 @@ const xs = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMj
|
|
|
975
998
|
}
|
|
976
999
|
}
|
|
977
1000
|
};
|
|
978
|
-
class
|
|
1001
|
+
class Fs {
|
|
979
1002
|
constructor({ editor: t }) {
|
|
980
1003
|
this.currentTarget = null, this.currentLocked = !1, this.isTransforming = !1, this.isTemporarilyHidden = !1, this.editor = t, this.canvas = t.canvas, this.options = t.options, this._initToolbar();
|
|
981
1004
|
}
|
|
982
1005
|
_initToolbar() {
|
|
983
1006
|
if (!this.options.showToolbar) return;
|
|
984
1007
|
const t = this.options.toolbar || {};
|
|
985
|
-
this.config =
|
|
986
|
-
style:
|
|
987
|
-
btnStyle:
|
|
988
|
-
icons:
|
|
989
|
-
handlers:
|
|
1008
|
+
this.config = St(P(P({}, Jt), t), {
|
|
1009
|
+
style: P(P({}, Jt.style), t.style || {}),
|
|
1010
|
+
btnStyle: P(P({}, Jt.btnStyle), t.btnStyle || {}),
|
|
1011
|
+
icons: P(P({}, Jt.icons), t.icons || {}),
|
|
1012
|
+
handlers: P(P({}, Jt.handlers), t.handlers || {})
|
|
990
1013
|
}), this.currentTarget = null, this.currentLocked = !1, this.isTransforming = !1, this.isTemporarilyHidden = !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 = () => {
|
|
991
1014
|
this.el.style.display = "none";
|
|
992
1015
|
}, this._createDOM(), this._bindEvents();
|
|
@@ -1103,7 +1126,7 @@ class Us {
|
|
|
1103
1126
|
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();
|
|
1104
1127
|
}
|
|
1105
1128
|
}
|
|
1106
|
-
const
|
|
1129
|
+
const Ys = {
|
|
1107
1130
|
position: "absolute",
|
|
1108
1131
|
display: "none",
|
|
1109
1132
|
background: "#2B2D33",
|
|
@@ -1117,8 +1140,8 @@ const Fs = {
|
|
|
1117
1140
|
"pointer-events": "none",
|
|
1118
1141
|
"white-space": "nowrap",
|
|
1119
1142
|
"box-shadow": "0 2px 8px rgba(0, 0, 0, 0.2)"
|
|
1120
|
-
},
|
|
1121
|
-
class
|
|
1143
|
+
}, Ge = 16, Ve = 16, Hs = "fabric-editor-angle-indicator";
|
|
1144
|
+
class _e {
|
|
1122
1145
|
constructor({ editor: t }) {
|
|
1123
1146
|
this.isActive = !1, this.currentAngle = 0, this.editor = t, this.canvas = t.canvas, this.options = t.options, this._createDOM(), this._bindEvents();
|
|
1124
1147
|
}
|
|
@@ -1126,7 +1149,7 @@ class De {
|
|
|
1126
1149
|
* Создание DOM-элемента индикатора
|
|
1127
1150
|
*/
|
|
1128
1151
|
_createDOM() {
|
|
1129
|
-
this.el = document.createElement("div"), this.el.className =
|
|
1152
|
+
this.el = document.createElement("div"), this.el.className = Hs, Object.entries(Ys).forEach(([t, e]) => {
|
|
1130
1153
|
this.el.style.setProperty(t, e);
|
|
1131
1154
|
}), this.canvas.wrapperEl.appendChild(this.el);
|
|
1132
1155
|
}
|
|
@@ -1146,7 +1169,7 @@ class De {
|
|
|
1146
1169
|
return;
|
|
1147
1170
|
}
|
|
1148
1171
|
const s = e.angle || 0;
|
|
1149
|
-
this.currentAngle =
|
|
1172
|
+
this.currentAngle = _e._normalizeAngle(s), this.el.textContent = `${this.currentAngle}°`, this._positionIndicator(t.e), this.isActive || this._showIndicator();
|
|
1150
1173
|
}
|
|
1151
1174
|
/**
|
|
1152
1175
|
* Обработчик отпускания кнопки мыши
|
|
@@ -1177,9 +1200,9 @@ class De {
|
|
|
1177
1200
|
*/
|
|
1178
1201
|
_positionIndicator(t) {
|
|
1179
1202
|
const e = this.canvas.wrapperEl.getBoundingClientRect();
|
|
1180
|
-
let s = t.clientX - e.left +
|
|
1203
|
+
let s = t.clientX - e.left + Ge, n = t.clientY - e.top + Ve;
|
|
1181
1204
|
const o = this.el.getBoundingClientRect(), i = o.width, a = o.height;
|
|
1182
|
-
s + i > e.width && (s = t.clientX - e.left - i -
|
|
1205
|
+
s + i > e.width && (s = t.clientX - e.left - i - Ge), n + a > e.height && (n = t.clientY - e.top - a - Ve), this.el.style.left = `${s}px`, this.el.style.top = `${n}px`;
|
|
1183
1206
|
}
|
|
1184
1207
|
/**
|
|
1185
1208
|
* Показать индикатор
|
|
@@ -1210,7 +1233,7 @@ class De {
|
|
|
1210
1233
|
this.canvas && (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:cleared", this._onSelectionCleared)), (t = this.el) != null && t.parentNode && this.el.parentNode.removeChild(this.el), this.el = null, this.editor = null, this.canvas = null, this.options = null;
|
|
1211
1234
|
}
|
|
1212
1235
|
}
|
|
1213
|
-
const
|
|
1236
|
+
const Ie = [
|
|
1214
1237
|
"id",
|
|
1215
1238
|
"backgroundId",
|
|
1216
1239
|
"customData",
|
|
@@ -1249,7 +1272,7 @@ const os = [
|
|
|
1249
1272
|
];
|
|
1250
1273
|
class G {
|
|
1251
1274
|
constructor({ editor: t }) {
|
|
1252
|
-
this.editor = t, this.canvas = t.canvas, this._isSavingState = !1, this._historySuspendCount = 0, this.baseState = null, this.patches = [], this.currentIndex = 0, this.maxHistoryLength = t.options.maxHistoryLength, this.totalChangesCount = 0, this.baseStateChangesCount = 0, this._createDiffPatcher();
|
|
1275
|
+
this.editor = t, this.canvas = t.canvas, this._isSavingState = !1, this._historySuspendCount = 0, this._isActionInProgress = !1, this._actionSnapshot = null, this._actionReason = null, this._pendingSaveTimeoutId = null, this._pendingSaveReason = null, this.baseState = null, this.patches = [], this.currentIndex = 0, this.maxHistoryLength = t.options.maxHistoryLength, this.totalChangesCount = 0, this.baseStateChangesCount = 0, this._createDiffPatcher();
|
|
1253
1276
|
}
|
|
1254
1277
|
/** Проверка, нужно ли пропускать сохранение истории */
|
|
1255
1278
|
get skipHistory() {
|
|
@@ -1259,7 +1282,7 @@ class G {
|
|
|
1259
1282
|
return this.patches[this.currentIndex - 1] || null;
|
|
1260
1283
|
}
|
|
1261
1284
|
_createDiffPatcher() {
|
|
1262
|
-
this.diffPatcher =
|
|
1285
|
+
this.diffPatcher = Ss({
|
|
1263
1286
|
objectHash(t) {
|
|
1264
1287
|
return [JSON.stringify(t)].join("-");
|
|
1265
1288
|
},
|
|
@@ -1281,6 +1304,36 @@ class G {
|
|
|
1281
1304
|
resumeHistory() {
|
|
1282
1305
|
this._historySuspendCount = Math.max(0, this._historySuspendCount - 1);
|
|
1283
1306
|
}
|
|
1307
|
+
/**
|
|
1308
|
+
* Запоминает состояние для отмены активного действия.
|
|
1309
|
+
* @param reason - причина начала действия
|
|
1310
|
+
*/
|
|
1311
|
+
beginAction({ reason: t }) {
|
|
1312
|
+
this._isActionInProgress || this.skipHistory || (this._isActionInProgress = !0, this._actionReason = t, this._actionSnapshot = this._captureCurrentState());
|
|
1313
|
+
}
|
|
1314
|
+
/**
|
|
1315
|
+
* Завершает активное действие и очищает снимок.
|
|
1316
|
+
* @param reason - причина завершения (опционально)
|
|
1317
|
+
*/
|
|
1318
|
+
endAction({ reason: t } = {}) {
|
|
1319
|
+
this._isActionInProgress && (t && this._actionReason && t !== this._actionReason || this._clearPendingAction());
|
|
1320
|
+
}
|
|
1321
|
+
/**
|
|
1322
|
+
* Планирует сохранение состояния с отложенным вызовом.
|
|
1323
|
+
* @param delayMs - задержка перед сохранением
|
|
1324
|
+
* @param reason - причина сохранения
|
|
1325
|
+
*/
|
|
1326
|
+
scheduleSaveState({ delayMs: t, reason: e }) {
|
|
1327
|
+
this._clearPendingSave(), this._pendingSaveReason = e, this._pendingSaveTimeoutId = setTimeout(this._handlePendingSaveTimeout.bind(this), t);
|
|
1328
|
+
}
|
|
1329
|
+
/**
|
|
1330
|
+
* Принудительно сохраняет отложенное состояние.
|
|
1331
|
+
*/
|
|
1332
|
+
flushPendingSave() {
|
|
1333
|
+
if (this._pendingSaveTimeoutId === null) return !1;
|
|
1334
|
+
const t = this._pendingSaveReason;
|
|
1335
|
+
return this._clearPendingSave(), this._finalizePendingSave({ reason: t }), !0;
|
|
1336
|
+
}
|
|
1284
1337
|
/**
|
|
1285
1338
|
* Проверяет, есть ли в редакторе несохранённые изменения
|
|
1286
1339
|
*/
|
|
@@ -1303,6 +1356,70 @@ class G {
|
|
|
1303
1356
|
n = this.diffPatcher.patch(n, s[o].diff);
|
|
1304
1357
|
return console.log("getFullState state", n), n;
|
|
1305
1358
|
}
|
|
1359
|
+
/**
|
|
1360
|
+
* Возвращает текущее состояние канваса с учётом временной разблокировки объектов.
|
|
1361
|
+
*/
|
|
1362
|
+
_captureCurrentState() {
|
|
1363
|
+
return this._withTemporaryUnlock(this._serializeCanvasState.bind(this));
|
|
1364
|
+
}
|
|
1365
|
+
/**
|
|
1366
|
+
* Сериализует текущее состояние канваса.
|
|
1367
|
+
*/
|
|
1368
|
+
_serializeCanvasState() {
|
|
1369
|
+
const { canvas: t } = this;
|
|
1370
|
+
return t.toDatalessObject([...Ie]);
|
|
1371
|
+
}
|
|
1372
|
+
/**
|
|
1373
|
+
* Обрабатывает срабатывание отложенного сохранения.
|
|
1374
|
+
*/
|
|
1375
|
+
_handlePendingSaveTimeout() {
|
|
1376
|
+
if (this._pendingSaveTimeoutId === null) return;
|
|
1377
|
+
const t = this._pendingSaveReason;
|
|
1378
|
+
this._pendingSaveTimeoutId = null, this._pendingSaveReason = null, this._finalizePendingSave({ reason: t });
|
|
1379
|
+
}
|
|
1380
|
+
/**
|
|
1381
|
+
* Завершает отложенное сохранение и применяет состояние.
|
|
1382
|
+
* @param reason - причина сохранения
|
|
1383
|
+
*/
|
|
1384
|
+
_finalizePendingSave({ reason: t }) {
|
|
1385
|
+
t === "text-edit" && this._deactivateTextEditing(), this.saveState();
|
|
1386
|
+
}
|
|
1387
|
+
/**
|
|
1388
|
+
* Сбрасывает флаг редактирования текста, если он активен.
|
|
1389
|
+
*/
|
|
1390
|
+
_deactivateTextEditing() {
|
|
1391
|
+
const { textManager: t } = this.editor;
|
|
1392
|
+
t && t.isTextEditingActive && (t.isTextEditingActive = !1);
|
|
1393
|
+
}
|
|
1394
|
+
/**
|
|
1395
|
+
* Очищает отложенное сохранение без фиксации состояния.
|
|
1396
|
+
*/
|
|
1397
|
+
_clearPendingSave() {
|
|
1398
|
+
const { _pendingSaveTimeoutId: t } = this;
|
|
1399
|
+
t !== null && (clearTimeout(t), this._pendingSaveTimeoutId = null, this._pendingSaveReason = null);
|
|
1400
|
+
}
|
|
1401
|
+
/**
|
|
1402
|
+
* Очищает состояние активного действия.
|
|
1403
|
+
*/
|
|
1404
|
+
_clearPendingAction() {
|
|
1405
|
+
this._isActionInProgress = !1, this._actionSnapshot = null, this._actionReason = null;
|
|
1406
|
+
}
|
|
1407
|
+
/**
|
|
1408
|
+
* Отменяет активное действие и возвращает состояние на момент начала.
|
|
1409
|
+
*/
|
|
1410
|
+
_cancelPendingAction() {
|
|
1411
|
+
return z(this, null, function* () {
|
|
1412
|
+
const { _isActionInProgress: t, _actionSnapshot: e } = this;
|
|
1413
|
+
if (!t || !e) return !1;
|
|
1414
|
+
const s = this._actionReason;
|
|
1415
|
+
this._clearPendingSave(), this._clearPendingAction(), this.suspendHistory();
|
|
1416
|
+
try {
|
|
1417
|
+
return yield this.loadStateFromFullState(e), s === "text-edit" && this._deactivateTextEditing(), !0;
|
|
1418
|
+
} finally {
|
|
1419
|
+
this.resumeHistory();
|
|
1420
|
+
}
|
|
1421
|
+
});
|
|
1422
|
+
}
|
|
1306
1423
|
/**
|
|
1307
1424
|
* Сохраняем текущее состояние в виде диффа от последнего сохранённого полного состояния.
|
|
1308
1425
|
*/
|
|
@@ -1311,22 +1428,20 @@ class G {
|
|
|
1311
1428
|
this._isSavingState = !0, console.time("saveState");
|
|
1312
1429
|
try {
|
|
1313
1430
|
const t = this._withTemporaryUnlock(
|
|
1314
|
-
() => this.canvas.toDatalessObject([...
|
|
1431
|
+
() => this.canvas.toDatalessObject([...Ie])
|
|
1315
1432
|
);
|
|
1316
1433
|
if (console.timeEnd("saveState"), !this.baseState) {
|
|
1317
1434
|
this.baseState = t, this.patches = [], this.currentIndex = 0, console.log("Базовое состояние сохранено.");
|
|
1318
1435
|
return;
|
|
1319
1436
|
}
|
|
1320
|
-
const e = this.getFullState()
|
|
1321
|
-
console.log("prevState", e);
|
|
1322
|
-
const {
|
|
1437
|
+
const e = this.getFullState(), {
|
|
1323
1438
|
prevState: s,
|
|
1324
1439
|
nextState: n
|
|
1325
1440
|
} = G._prepareStatesForDiff({
|
|
1326
1441
|
prevState: e,
|
|
1327
1442
|
nextState: t
|
|
1328
1443
|
}), o = this.diffPatcher.diff(s, n);
|
|
1329
|
-
if (!o) {
|
|
1444
|
+
if (console.log("normalizedPrevState", s), console.log("normalizedCurrentState", n), !o) {
|
|
1330
1445
|
console.log("Нет изменений для сохранения.");
|
|
1331
1446
|
return;
|
|
1332
1447
|
}
|
|
@@ -1462,13 +1577,13 @@ class G {
|
|
|
1462
1577
|
f && (f.left = a, f.top = r);
|
|
1463
1578
|
const g = G._getClipPathPosition({ clipPath: n });
|
|
1464
1579
|
if (g && i && typeof i == "object") {
|
|
1465
|
-
const { left: m, top: v } = g,
|
|
1466
|
-
|
|
1580
|
+
const { left: m, top: v } = g, S = i;
|
|
1581
|
+
S.left = m, S.top = v;
|
|
1467
1582
|
}
|
|
1468
1583
|
const p = G._getTranslationIgnoredIds();
|
|
1469
1584
|
for (let m = 0; m < o.length; m += 1) {
|
|
1470
|
-
const v = o[m], { id:
|
|
1471
|
-
|
|
1585
|
+
const v = o[m], { id: S } = v;
|
|
1586
|
+
S && p.has(S) || (typeof v.left == "number" && (v.left -= l), typeof v.top == "number" && (v.top -= u));
|
|
1472
1587
|
}
|
|
1473
1588
|
}
|
|
1474
1589
|
/**
|
|
@@ -1587,7 +1702,7 @@ class G {
|
|
|
1587
1702
|
* @fires editor:history-state-loaded
|
|
1588
1703
|
*/
|
|
1589
1704
|
loadStateFromFullState(t) {
|
|
1590
|
-
return
|
|
1705
|
+
return z(this, null, function* () {
|
|
1591
1706
|
if (!t) return;
|
|
1592
1707
|
console.log("loadStateFromFullState fullState", t);
|
|
1593
1708
|
const { canvas: e, canvasManager: s, interactionBlocker: n, backgroundManager: o } = this.editor, { width: i, height: a } = e;
|
|
@@ -1614,31 +1729,31 @@ class G {
|
|
|
1614
1729
|
* @fires editor:undo
|
|
1615
1730
|
*/
|
|
1616
1731
|
undo() {
|
|
1617
|
-
return
|
|
1618
|
-
if (!this.skipHistory) {
|
|
1619
|
-
if (this.
|
|
1732
|
+
return z(this, null, function* () {
|
|
1733
|
+
if (!(this.skipHistory || (yield this._cancelPendingAction()))) {
|
|
1734
|
+
if (this.flushPendingSave(), this.currentIndex <= 0) {
|
|
1620
1735
|
console.log("Нет предыдущих состояний для отмены.");
|
|
1621
1736
|
return;
|
|
1622
1737
|
}
|
|
1623
1738
|
this.suspendHistory();
|
|
1624
1739
|
try {
|
|
1625
1740
|
this.currentIndex -= 1, this.totalChangesCount -= 1;
|
|
1626
|
-
const
|
|
1627
|
-
yield this.loadStateFromFullState(
|
|
1628
|
-
fullState:
|
|
1741
|
+
const e = this.getFullState();
|
|
1742
|
+
yield this.loadStateFromFullState(e), console.log("Undo выполнен. Текущий индекс истории:", this.currentIndex), this.canvas.fire("editor:undo", {
|
|
1743
|
+
fullState: e,
|
|
1629
1744
|
currentIndex: this.currentIndex,
|
|
1630
1745
|
totalChangesCount: this.totalChangesCount,
|
|
1631
1746
|
baseStateChangesCount: this.baseStateChangesCount,
|
|
1632
1747
|
patchesCount: this.patches.length,
|
|
1633
1748
|
patches: this.patches
|
|
1634
1749
|
});
|
|
1635
|
-
} catch (
|
|
1750
|
+
} catch (e) {
|
|
1636
1751
|
this.editor.errorManager.emitError({
|
|
1637
1752
|
origin: "HistoryManager",
|
|
1638
1753
|
method: "undo",
|
|
1639
1754
|
code: "UNDO_ERROR",
|
|
1640
1755
|
message: "Ошибка отмены действия",
|
|
1641
|
-
data:
|
|
1756
|
+
data: e
|
|
1642
1757
|
});
|
|
1643
1758
|
} finally {
|
|
1644
1759
|
this.resumeHistory();
|
|
@@ -1651,31 +1766,31 @@ class G {
|
|
|
1651
1766
|
* @fires editor:redo
|
|
1652
1767
|
*/
|
|
1653
1768
|
redo() {
|
|
1654
|
-
return
|
|
1655
|
-
if (!this.skipHistory) {
|
|
1656
|
-
if (this.currentIndex >= this.patches.length) {
|
|
1769
|
+
return z(this, null, function* () {
|
|
1770
|
+
if (!(this.skipHistory || (yield this._cancelPendingAction()))) {
|
|
1771
|
+
if (this.flushPendingSave(), this.currentIndex >= this.patches.length) {
|
|
1657
1772
|
console.log("Нет состояний для повтора.");
|
|
1658
1773
|
return;
|
|
1659
1774
|
}
|
|
1660
1775
|
this.suspendHistory();
|
|
1661
1776
|
try {
|
|
1662
1777
|
this.currentIndex += 1, this.totalChangesCount += 1;
|
|
1663
|
-
const
|
|
1664
|
-
console.log("fullState",
|
|
1665
|
-
fullState:
|
|
1778
|
+
const e = this.getFullState();
|
|
1779
|
+
console.log("fullState", e), yield this.loadStateFromFullState(e), console.log("Redo выполнен. Текущий индекс истории:", this.currentIndex), this.canvas.fire("editor:redo", {
|
|
1780
|
+
fullState: e,
|
|
1666
1781
|
currentIndex: this.currentIndex,
|
|
1667
1782
|
totalChangesCount: this.totalChangesCount,
|
|
1668
1783
|
baseStateChangesCount: this.baseStateChangesCount,
|
|
1669
1784
|
patchesCount: this.patches.length,
|
|
1670
1785
|
patches: this.patches
|
|
1671
1786
|
});
|
|
1672
|
-
} catch (
|
|
1787
|
+
} catch (e) {
|
|
1673
1788
|
this.editor.errorManager.emitError({
|
|
1674
1789
|
origin: "HistoryManager",
|
|
1675
1790
|
method: "redo",
|
|
1676
1791
|
code: "REDO_ERROR",
|
|
1677
1792
|
message: "Ошибка повтора действия",
|
|
1678
|
-
data:
|
|
1793
|
+
data: e
|
|
1679
1794
|
});
|
|
1680
1795
|
} finally {
|
|
1681
1796
|
this.resumeHistory();
|
|
@@ -1706,7 +1821,7 @@ class G {
|
|
|
1706
1821
|
}
|
|
1707
1822
|
}
|
|
1708
1823
|
}
|
|
1709
|
-
const
|
|
1824
|
+
const Zs = 0.1, Gs = 2, Xe = 0.1, Vs = 90, kt = 16, Pt = 16, At = 4096, jt = 4096, Ke = "application/image-editor:", re = [
|
|
1710
1825
|
"format",
|
|
1711
1826
|
"uppercase",
|
|
1712
1827
|
"textCaseRaw",
|
|
@@ -1720,7 +1835,7 @@ const Hs = 0.1, Zs = 2, Ge = 0.1, Gs = 90, kt = 16, zt = 16, At = 4096, jt = 409
|
|
|
1720
1835
|
"radiusTopRight",
|
|
1721
1836
|
"radiusBottomRight",
|
|
1722
1837
|
"radiusBottomLeft"
|
|
1723
|
-
],
|
|
1838
|
+
], Xs = 50;
|
|
1724
1839
|
class lt {
|
|
1725
1840
|
constructor({ editor: t }) {
|
|
1726
1841
|
this.editor = t, this.options = t.options, this._createdBlobUrls = [], this.acceptContentTypes = this.editor.options.acceptContentTypes, this.acceptFormats = this.getAllowedFormatsFromContentTypes();
|
|
@@ -1738,7 +1853,7 @@ class lt {
|
|
|
1738
1853
|
* @returns возвращает Promise с объектом изображения или null в случае ошибки
|
|
1739
1854
|
*/
|
|
1740
1855
|
importImage(t) {
|
|
1741
|
-
return
|
|
1856
|
+
return z(this, null, function* () {
|
|
1742
1857
|
const {
|
|
1743
1858
|
source: e,
|
|
1744
1859
|
scale: s = `image-${this.options.scaleType}`,
|
|
@@ -1750,7 +1865,7 @@ class lt {
|
|
|
1750
1865
|
customData: c = null
|
|
1751
1866
|
} = t;
|
|
1752
1867
|
if (!e) return null;
|
|
1753
|
-
const { canvas: d, montageArea: l, transformManager: u, historyManager: f, errorManager: g } = this.editor, p = yield this.getContentType(e), m = lt.getFormatFromContentType(p), { acceptContentTypes: v, acceptFormats:
|
|
1868
|
+
const { canvas: d, montageArea: l, transformManager: u, historyManager: f, errorManager: g } = this.editor, p = yield this.getContentType(e), m = lt.getFormatFromContentType(p), { acceptContentTypes: v, acceptFormats: S } = this;
|
|
1754
1869
|
if (!this.isAllowedContentType(p)) {
|
|
1755
1870
|
const A = `Неверный contentType для изображения: ${p}. Ожидается один из: ${this.acceptContentTypes.join(", ")}.`;
|
|
1756
1871
|
return g.emitError({
|
|
@@ -1763,7 +1878,7 @@ class lt {
|
|
|
1763
1878
|
format: m,
|
|
1764
1879
|
contentType: p,
|
|
1765
1880
|
acceptContentTypes: v,
|
|
1766
|
-
acceptFormats:
|
|
1881
|
+
acceptFormats: S,
|
|
1767
1882
|
fromClipboard: o,
|
|
1768
1883
|
isBackground: i,
|
|
1769
1884
|
withoutSelection: a,
|
|
@@ -1778,8 +1893,8 @@ class lt {
|
|
|
1778
1893
|
if (e instanceof File)
|
|
1779
1894
|
A = URL.createObjectURL(e);
|
|
1780
1895
|
else if (typeof e == "string") {
|
|
1781
|
-
const
|
|
1782
|
-
A = URL.createObjectURL(
|
|
1896
|
+
const T = yield (yield fetch(e, { mode: "cors" })).blob();
|
|
1897
|
+
A = URL.createObjectURL(T);
|
|
1783
1898
|
} else
|
|
1784
1899
|
return g.emitError({
|
|
1785
1900
|
origin: "ImageManager",
|
|
@@ -1791,7 +1906,7 @@ class lt {
|
|
|
1791
1906
|
format: m,
|
|
1792
1907
|
contentType: p,
|
|
1793
1908
|
acceptContentTypes: v,
|
|
1794
|
-
acceptFormats:
|
|
1909
|
+
acceptFormats: S,
|
|
1795
1910
|
fromClipboard: o,
|
|
1796
1911
|
isBackground: i,
|
|
1797
1912
|
withoutSelection: a,
|
|
@@ -1800,29 +1915,29 @@ class lt {
|
|
|
1800
1915
|
}
|
|
1801
1916
|
}), null;
|
|
1802
1917
|
if (this._createdBlobUrls.push(A), m === "svg") {
|
|
1803
|
-
const
|
|
1804
|
-
y = ht.groupSVGElements(
|
|
1918
|
+
const w = yield fs(A);
|
|
1919
|
+
y = ht.groupSVGElements(w.objects, w.options);
|
|
1805
1920
|
} else
|
|
1806
1921
|
y = yield qt.fromURL(A, { crossOrigin: "anonymous" });
|
|
1807
1922
|
const { width: M, height: j } = y;
|
|
1808
1923
|
if (y instanceof qt) {
|
|
1809
|
-
const
|
|
1810
|
-
let
|
|
1811
|
-
if (
|
|
1812
|
-
const b = yield this.resizeImageToBoundaries(
|
|
1813
|
-
this._createdBlobUrls.push(
|
|
1814
|
-
} else if (j <
|
|
1815
|
-
const b = yield this.resizeImageToBoundaries(
|
|
1816
|
-
this._createdBlobUrls.push(
|
|
1924
|
+
const w = y.getElement();
|
|
1925
|
+
let T = "";
|
|
1926
|
+
if (w instanceof HTMLImageElement ? T = w.src : w instanceof HTMLCanvasElement && (T = w.toDataURL()), j > jt || M > At) {
|
|
1927
|
+
const b = yield this.resizeImageToBoundaries(T, "max"), C = URL.createObjectURL(b);
|
|
1928
|
+
this._createdBlobUrls.push(C), y = yield qt.fromURL(C, { crossOrigin: "anonymous" });
|
|
1929
|
+
} else if (j < Pt || M < kt) {
|
|
1930
|
+
const b = yield this.resizeImageToBoundaries(T, "min"), C = URL.createObjectURL(b);
|
|
1931
|
+
this._createdBlobUrls.push(C), y = yield qt.fromURL(C, { crossOrigin: "anonymous" });
|
|
1817
1932
|
}
|
|
1818
1933
|
}
|
|
1819
1934
|
if (y.set("id", `${y.type}-${K()}`), y.set("format", m), y.set("customData", c || null), s === "scale-montage")
|
|
1820
1935
|
this.editor.canvasManager.scaleMontageAreaToImage({ object: y, withoutSave: !0 });
|
|
1821
1936
|
else {
|
|
1822
|
-
const { width:
|
|
1823
|
-
s === "image-contain" && b < 1 ? u.fitObject({ object: y, type: "contain", withoutSave: !0 }) : s === "image-cover" && (M >
|
|
1937
|
+
const { width: w, height: T } = l, b = this.calculateScaleFactor({ imageObject: y, scaleType: s });
|
|
1938
|
+
s === "image-contain" && b < 1 ? u.fitObject({ object: y, type: "contain", withoutSave: !0 }) : s === "image-cover" && (M > w || j > T) && u.fitObject({ object: y, type: "cover", withoutSave: !0 });
|
|
1824
1939
|
}
|
|
1825
|
-
const
|
|
1940
|
+
const I = {
|
|
1826
1941
|
image: y,
|
|
1827
1942
|
format: m,
|
|
1828
1943
|
contentType: p,
|
|
@@ -1835,7 +1950,7 @@ class lt {
|
|
|
1835
1950
|
withoutAdding: r,
|
|
1836
1951
|
customData: c
|
|
1837
1952
|
};
|
|
1838
|
-
return r ? (f.resumeHistory(), d.fire("editor:image-imported",
|
|
1953
|
+
return r ? (f.resumeHistory(), d.fire("editor:image-imported", I), I) : (d.add(y), d.centerObject(y), a || d.setActiveObject(y), d.renderAll(), f.resumeHistory(), n || f.saveState(), d.fire("editor:image-imported", I), I);
|
|
1839
1954
|
} catch (A) {
|
|
1840
1955
|
return g.emitError({
|
|
1841
1956
|
origin: "ImageManager",
|
|
@@ -1867,16 +1982,16 @@ class lt {
|
|
|
1867
1982
|
* @returns возвращает Promise с Blob-объектом уменьшенного изображения
|
|
1868
1983
|
*/
|
|
1869
1984
|
resizeImageToBoundaries(t, e = "max") {
|
|
1870
|
-
return
|
|
1985
|
+
return z(this, null, function* () {
|
|
1871
1986
|
let s = `Размер изображения больше максимального размера канваса, поэтому оно будет уменьшено до максимальных размеров c сохранением пропорций: ${At}x${jt}`;
|
|
1872
|
-
e === "min" && (s = `Размер изображения меньше минимального размера канваса, поэтому оно будет увеличено до минимальных размеров c сохранением пропорций: ${kt}x${
|
|
1987
|
+
e === "min" && (s = `Размер изображения меньше минимального размера канваса, поэтому оно будет увеличено до минимальных размеров c сохранением пропорций: ${kt}x${Pt}`);
|
|
1873
1988
|
const n = {
|
|
1874
1989
|
dataURL: t,
|
|
1875
1990
|
sizeType: e,
|
|
1876
1991
|
maxWidth: At,
|
|
1877
1992
|
maxHeight: jt,
|
|
1878
1993
|
minWidth: kt,
|
|
1879
|
-
minHeight:
|
|
1994
|
+
minHeight: Pt
|
|
1880
1995
|
};
|
|
1881
1996
|
return this.editor.errorManager.emitWarning({
|
|
1882
1997
|
origin: "ImageManager",
|
|
@@ -1899,7 +2014,7 @@ class lt {
|
|
|
1899
2014
|
* @fires editor:canvas-exported
|
|
1900
2015
|
*/
|
|
1901
2016
|
exportCanvasAsImageFile() {
|
|
1902
|
-
return
|
|
2017
|
+
return z(this, arguments, function* (t = {}) {
|
|
1903
2018
|
const {
|
|
1904
2019
|
fileName: e = "image.png",
|
|
1905
2020
|
contentType: s = "image/png",
|
|
@@ -1911,9 +2026,9 @@ class lt {
|
|
|
1911
2026
|
a.setCoords();
|
|
1912
2027
|
const { left: f, top: g, width: p, height: m } = a.getBoundingRect(), v = yield i.clone(["id", "format", "locked"]);
|
|
1913
2028
|
v.enableRetinaScaling = !1, ["image/jpg", "image/jpeg"].includes(l) && (v.backgroundColor = "#ffffff");
|
|
1914
|
-
const
|
|
1915
|
-
if (
|
|
1916
|
-
const b = v.getObjects().find((
|
|
2029
|
+
const S = v.getObjects().find((b) => b.id === a.id);
|
|
2030
|
+
if (S && (S.visible = !1), c != null && c.isBlocked) {
|
|
2031
|
+
const b = v.getObjects().find((C) => C.id === c.overlayMask.id);
|
|
1917
2032
|
b && (b.visible = !1);
|
|
1918
2033
|
}
|
|
1919
2034
|
v.viewportTransform = [1, 0, 0, 1, -f, -g], v.setDimensions({ width: p, height: m }, { backstoreOnly: !0 }), v.renderAll();
|
|
@@ -1921,7 +2036,7 @@ class lt {
|
|
|
1921
2036
|
if (u === "svg" && A) {
|
|
1922
2037
|
const b = v.toSVG();
|
|
1923
2038
|
v.dispose();
|
|
1924
|
-
const
|
|
2039
|
+
const E = {
|
|
1925
2040
|
image: lt._exportSVGStringAsFile(b, {
|
|
1926
2041
|
exportAsBase64: n,
|
|
1927
2042
|
exportAsBlob: o,
|
|
@@ -1931,11 +2046,11 @@ class lt {
|
|
|
1931
2046
|
contentType: "image/svg+xml",
|
|
1932
2047
|
fileName: e.replace(/\.[^/.]+$/, ".svg")
|
|
1933
2048
|
};
|
|
1934
|
-
return i.fire("editor:canvas-exported",
|
|
2049
|
+
return i.fire("editor:canvas-exported", E), E;
|
|
1935
2050
|
}
|
|
1936
|
-
const y = yield new Promise((b,
|
|
1937
|
-
v.getElement().toBlob((
|
|
1938
|
-
|
|
2051
|
+
const y = yield new Promise((b, C) => {
|
|
2052
|
+
v.getElement().toBlob((E) => {
|
|
2053
|
+
E ? b(E) : C(new Error("Failed to create Blob from canvas"));
|
|
1939
2054
|
});
|
|
1940
2055
|
});
|
|
1941
2056
|
if (v.dispose(), o) {
|
|
@@ -1953,22 +2068,22 @@ class lt {
|
|
|
1953
2068
|
[M]
|
|
1954
2069
|
);
|
|
1955
2070
|
if (d) {
|
|
1956
|
-
const
|
|
1957
|
-
orientation:
|
|
2071
|
+
const C = p * 0.264583, E = m * 0.264583, x = (yield this.editor.moduleLoader.loadModule("jspdf")).jsPDF, N = new x({
|
|
2072
|
+
orientation: C > E ? "landscape" : "portrait",
|
|
1958
2073
|
unit: "mm",
|
|
1959
|
-
format: [
|
|
2074
|
+
format: [C, E]
|
|
1960
2075
|
});
|
|
1961
|
-
if (
|
|
2076
|
+
if (N.addImage(String(j), "JPG", 0, 0, C, E), n) {
|
|
1962
2077
|
const Y = {
|
|
1963
|
-
image:
|
|
2078
|
+
image: N.output("datauristring"),
|
|
1964
2079
|
format: "pdf",
|
|
1965
2080
|
contentType: "application/pdf",
|
|
1966
2081
|
fileName: e
|
|
1967
2082
|
};
|
|
1968
2083
|
return i.fire("editor:canvas-exported", Y), Y;
|
|
1969
2084
|
}
|
|
1970
|
-
const
|
|
1971
|
-
image: new File([
|
|
2085
|
+
const B = N.output("blob"), Z = {
|
|
2086
|
+
image: new File([B], e, { type: "application/pdf" }),
|
|
1972
2087
|
format: "pdf",
|
|
1973
2088
|
contentType: "application/pdf",
|
|
1974
2089
|
fileName: e
|
|
@@ -1984,13 +2099,13 @@ class lt {
|
|
|
1984
2099
|
};
|
|
1985
2100
|
return i.fire("editor:canvas-exported", b), b;
|
|
1986
2101
|
}
|
|
1987
|
-
const
|
|
1988
|
-
image: new File([y],
|
|
2102
|
+
const I = u === "svg" && !A ? e.replace(/\.[^/.]+$/, ".png") : e, T = {
|
|
2103
|
+
image: new File([y], I, { type: l }),
|
|
1989
2104
|
format: u,
|
|
1990
2105
|
contentType: l,
|
|
1991
|
-
fileName:
|
|
2106
|
+
fileName: I
|
|
1992
2107
|
};
|
|
1993
|
-
return i.fire("editor:canvas-exported",
|
|
2108
|
+
return i.fire("editor:canvas-exported", T), T;
|
|
1994
2109
|
} catch (d) {
|
|
1995
2110
|
return this.editor.errorManager.emitError({
|
|
1996
2111
|
origin: "ImageManager",
|
|
@@ -2014,7 +2129,7 @@ class lt {
|
|
|
2014
2129
|
* @fires editor:object-exported
|
|
2015
2130
|
*/
|
|
2016
2131
|
exportObjectAsImageFile() {
|
|
2017
|
-
return
|
|
2132
|
+
return z(this, arguments, function* (t = {}) {
|
|
2018
2133
|
const {
|
|
2019
2134
|
object: e,
|
|
2020
2135
|
fileName: s = "image.png",
|
|
@@ -2127,7 +2242,7 @@ class lt {
|
|
|
2127
2242
|
* @public
|
|
2128
2243
|
*/
|
|
2129
2244
|
getContentType(t) {
|
|
2130
|
-
return
|
|
2245
|
+
return z(this, null, function* () {
|
|
2131
2246
|
return typeof t == "string" ? this.getContentTypeFromUrl(t) : t.type || "application/octet-stream";
|
|
2132
2247
|
});
|
|
2133
2248
|
}
|
|
@@ -2138,7 +2253,7 @@ class lt {
|
|
|
2138
2253
|
* @public
|
|
2139
2254
|
*/
|
|
2140
2255
|
getContentTypeFromUrl(t) {
|
|
2141
|
-
return
|
|
2256
|
+
return z(this, null, function* () {
|
|
2142
2257
|
if (t.startsWith("data:")) {
|
|
2143
2258
|
const e = t.match(/^data:([^;]+)/);
|
|
2144
2259
|
return e ? e[1] : "application/octet-stream";
|
|
@@ -2217,11 +2332,11 @@ class lt {
|
|
|
2217
2332
|
return e ? e[1] : "";
|
|
2218
2333
|
}
|
|
2219
2334
|
}
|
|
2220
|
-
const pt = (h, t, e) => Math.max(Math.min(h, e), t),
|
|
2221
|
-
function
|
|
2335
|
+
const pt = (h, t, e) => Math.max(Math.min(h, e), t), qe = (h, t) => h * t, Ks = (h, t) => new et(h / 2, t / 2);
|
|
2336
|
+
function qs(h) {
|
|
2222
2337
|
return ((h == null ? void 0 : h.type) === "image" || (h == null ? void 0 : h.format) === "svg") && typeof (h == null ? void 0 : h.width) == "number" && typeof (h == null ? void 0 : h.height) == "number";
|
|
2223
2338
|
}
|
|
2224
|
-
class
|
|
2339
|
+
class Js {
|
|
2225
2340
|
/**
|
|
2226
2341
|
* @param options
|
|
2227
2342
|
* @param options.editor – экземпляр редактора
|
|
@@ -2270,7 +2385,7 @@ class qs {
|
|
|
2270
2385
|
options: { canvasBackstoreWidth: a }
|
|
2271
2386
|
} = this.editor, { width: r, height: c } = i, d = pt(Number(t), kt, At);
|
|
2272
2387
|
if (!a || a === "auto" || n ? this.adaptCanvasToContainer() : a ? this.setCanvasBackstoreWidth(Number(a)) : this.setCanvasBackstoreWidth(d), i.set({ width: d }), (g = o.clipPath) == null || g.set({ width: d }), e) {
|
|
2273
|
-
const p = d / r, m =
|
|
2388
|
+
const p = d / r, m = qe(c, p);
|
|
2274
2389
|
this.setResolutionHeight(m);
|
|
2275
2390
|
return;
|
|
2276
2391
|
}
|
|
@@ -2298,9 +2413,9 @@ class qs {
|
|
|
2298
2413
|
canvas: o,
|
|
2299
2414
|
montageArea: i,
|
|
2300
2415
|
options: { canvasBackstoreHeight: a }
|
|
2301
|
-
} = this.editor, { width: r, height: c } = i, d = pt(Number(t),
|
|
2416
|
+
} = this.editor, { width: r, height: c } = i, d = pt(Number(t), Pt, jt);
|
|
2302
2417
|
if (!a || a === "auto" || n ? this.adaptCanvasToContainer() : a ? this.setCanvasBackstoreHeight(Number(a)) : this.setCanvasBackstoreHeight(d), i.set({ height: d }), (g = o.clipPath) == null || g.set({ height: d }), e) {
|
|
2303
|
-
const p = d / c, m =
|
|
2418
|
+
const p = d / c, m = qe(r, p);
|
|
2304
2419
|
this.setResolutionWidth(m);
|
|
2305
2420
|
return;
|
|
2306
2421
|
}
|
|
@@ -2318,7 +2433,7 @@ class qs {
|
|
|
2318
2433
|
*/
|
|
2319
2434
|
centerMontageArea() {
|
|
2320
2435
|
var r;
|
|
2321
|
-
const { canvas: t, montageArea: e } = this.editor, s = t.getWidth(), n = t.getHeight(), o = t.getZoom(), i =
|
|
2436
|
+
const { canvas: t, montageArea: e } = this.editor, s = t.getWidth(), n = t.getHeight(), o = t.getZoom(), i = Ks(s, n);
|
|
2322
2437
|
e.set({
|
|
2323
2438
|
left: s / 2,
|
|
2324
2439
|
top: n / 2
|
|
@@ -2360,7 +2475,7 @@ class qs {
|
|
|
2360
2475
|
*/
|
|
2361
2476
|
setCanvasBackstoreHeight(t) {
|
|
2362
2477
|
if (!t || typeof t != "number") return;
|
|
2363
|
-
const e = pt(t,
|
|
2478
|
+
const e = pt(t, Pt, jt);
|
|
2364
2479
|
this.editor.canvas.setDimensions({ height: e }, { backstoreOnly: !0 });
|
|
2365
2480
|
}
|
|
2366
2481
|
/**
|
|
@@ -2369,7 +2484,7 @@ class qs {
|
|
|
2369
2484
|
* с учётом минимальных и максимальных значений.
|
|
2370
2485
|
*/
|
|
2371
2486
|
adaptCanvasToContainer() {
|
|
2372
|
-
const { canvas: t } = this.editor, e = this.getEditorContainer(), s = e.clientWidth, n = e.clientHeight, o = pt(s, kt, At), i = pt(n,
|
|
2487
|
+
const { canvas: t } = this.editor, e = this.getEditorContainer(), s = e.clientWidth, n = e.clientHeight, o = pt(s, kt, At), i = pt(n, Pt, jt);
|
|
2373
2488
|
t.setDimensions({ width: o, height: i }, { backstoreOnly: !0 });
|
|
2374
2489
|
}
|
|
2375
2490
|
/**
|
|
@@ -2569,15 +2684,15 @@ class qs {
|
|
|
2569
2684
|
montageAreaHeight: r
|
|
2570
2685
|
}
|
|
2571
2686
|
} = this.editor, c = t || n.getActiveObject();
|
|
2572
|
-
if (!
|
|
2687
|
+
if (!qs(c)) return;
|
|
2573
2688
|
const { width: d, height: l } = c;
|
|
2574
2689
|
let u = Math.min(d, At), f = Math.min(l, jt);
|
|
2575
2690
|
if (e) {
|
|
2576
2691
|
const {
|
|
2577
2692
|
width: g,
|
|
2578
2693
|
height: p
|
|
2579
|
-
} = o, m = d / g, v = l / p,
|
|
2580
|
-
u = g *
|
|
2694
|
+
} = o, m = d / g, v = l / p, S = Math.max(m, v);
|
|
2695
|
+
u = g * S, f = p * S;
|
|
2581
2696
|
}
|
|
2582
2697
|
this.setResolutionWidth(u, { withoutSave: !0 }), this.setResolutionHeight(f, { withoutSave: !0 }), this.editor.backgroundManager.backgroundObject && this.editor.backgroundManager.refresh(), (d > a || l > r) && this.editor.zoomManager.calculateAndApplyDefaultZoom(), i.resetObject({ object: c, withoutSave: !0 }), n.centerObject(c), n.renderAll(), s || this.editor.historyManager.saveState(), n.fire("editor:montage-area-scaled-to-image", {
|
|
2583
2698
|
object: c,
|
|
@@ -2629,7 +2744,7 @@ class qs {
|
|
|
2629
2744
|
);
|
|
2630
2745
|
}
|
|
2631
2746
|
}
|
|
2632
|
-
class
|
|
2747
|
+
class Qs {
|
|
2633
2748
|
constructor({ editor: t }) {
|
|
2634
2749
|
this.editor = t, this.options = t.options;
|
|
2635
2750
|
}
|
|
@@ -2640,7 +2755,7 @@ class Js {
|
|
|
2640
2755
|
* @param options.withoutSave - Не сохранять состояние
|
|
2641
2756
|
* @fires editor:object-rotated
|
|
2642
2757
|
*/
|
|
2643
|
-
rotate(t =
|
|
2758
|
+
rotate(t = Vs, { withoutSave: e } = {}) {
|
|
2644
2759
|
const { canvas: s, historyManager: n } = this.editor, o = s.getActiveObject();
|
|
2645
2760
|
if (!o) return;
|
|
2646
2761
|
const i = o.angle + t;
|
|
@@ -2741,9 +2856,9 @@ class Js {
|
|
|
2741
2856
|
* @private
|
|
2742
2857
|
*/
|
|
2743
2858
|
_fitSingleObject(t, e) {
|
|
2744
|
-
const { canvas: s, montageArea: n } = this.editor, { width: o, height: i, scaleX: a = 1, scaleY: r = 1, angle: c = 0 } = t, d = o * Math.abs(a), l = i * Math.abs(r), u = c * Math.PI / 180, f = Math.abs(Math.cos(u)), g = Math.abs(Math.sin(u)), p = d * f + l * g, m = d * g + l * f, v = n.width,
|
|
2859
|
+
const { canvas: s, montageArea: n } = this.editor, { width: o, height: i, scaleX: a = 1, scaleY: r = 1, angle: c = 0 } = t, d = o * Math.abs(a), l = i * Math.abs(r), u = c * Math.PI / 180, f = Math.abs(Math.cos(u)), g = Math.abs(Math.sin(u)), p = d * f + l * g, m = d * g + l * f, v = n.width, S = n.height;
|
|
2745
2860
|
let A;
|
|
2746
|
-
e === "contain" ? A = Math.min(v / p,
|
|
2861
|
+
e === "contain" ? A = Math.min(v / p, S / m) : A = Math.max(v / p, S / m), t.set({
|
|
2747
2862
|
scaleX: a * A,
|
|
2748
2863
|
scaleY: r * A
|
|
2749
2864
|
}), s.centerObject(t);
|
|
@@ -2795,9 +2910,9 @@ class Js {
|
|
|
2795
2910
|
});
|
|
2796
2911
|
}
|
|
2797
2912
|
}
|
|
2798
|
-
class
|
|
2913
|
+
class $s {
|
|
2799
2914
|
constructor({ editor: t }) {
|
|
2800
|
-
this.editor = t, this.options = t.options, this.minZoom = this.options.minZoom ||
|
|
2915
|
+
this.editor = t, this.options = t.options, this.minZoom = this.options.minZoom || Zs, this.maxZoom = this.options.maxZoom || Gs, this.defaultZoom = this._normalizeDefaultZoom(this.options.defaultScale);
|
|
2801
2916
|
}
|
|
2802
2917
|
/**
|
|
2803
2918
|
* Приводит значение defaultZoom к числу с двумя знаками после запятой, а также учитывает минимальное и максимальное значения.
|
|
@@ -2863,10 +2978,10 @@ class Qs {
|
|
|
2863
2978
|
* @private
|
|
2864
2979
|
*/
|
|
2865
2980
|
_calculateEmptySpaceRatio(t) {
|
|
2866
|
-
const { canvas: e, montageArea: s } = this.editor, n = e.viewportTransform, o = e.getWidth(), i = e.getHeight(), a = s.left - s.width / 2, r = s.left + s.width / 2, c = s.top - s.height / 2, d = s.top + s.height / 2, l = -n[4] / t, u = (-n[4] + o) / t, f = -n[5] / t, g = (-n[5] + i) / t, p = l < a, m = u > r, v = f < c,
|
|
2867
|
-
if (!(p || m || v ||
|
|
2868
|
-
const y = Math.max(0, a - l), M = Math.max(0, u - r), j = Math.max(0, c - f),
|
|
2869
|
-
return Math.max(b,
|
|
2981
|
+
const { canvas: e, montageArea: s } = this.editor, n = e.viewportTransform, o = e.getWidth(), i = e.getHeight(), a = s.left - s.width / 2, r = s.left + s.width / 2, c = s.top - s.height / 2, d = s.top + s.height / 2, l = -n[4] / t, u = (-n[4] + o) / t, f = -n[5] / t, g = (-n[5] + i) / t, p = l < a, m = u > r, v = f < c, S = g > d;
|
|
2982
|
+
if (!(p || m || v || S)) return 0;
|
|
2983
|
+
const y = Math.max(0, a - l), M = Math.max(0, u - r), j = Math.max(0, c - f), I = Math.max(0, g - d), w = Math.max(y, M), T = Math.max(j, I), b = w / o, C = T / i;
|
|
2984
|
+
return Math.max(b, C);
|
|
2870
2985
|
}
|
|
2871
2986
|
/**
|
|
2872
2987
|
* Вычисляет плавный шаг перемещения viewport к центру с ускорением
|
|
@@ -2882,8 +2997,8 @@ class Qs {
|
|
|
2882
2997
|
const { canvas: i, montageArea: a } = this.editor, r = i.viewportTransform, c = i.getWidth(), d = i.getHeight(), l = t.x - r[4], u = t.y - r[5], f = Math.abs(n), g = e - s;
|
|
2883
2998
|
if (Math.abs(g) / f <= 0.1)
|
|
2884
2999
|
return { x: l, y: u };
|
|
2885
|
-
const m = c / 2, v = d / 2,
|
|
2886
|
-
return { x:
|
|
3000
|
+
const m = c / 2, v = d / 2, S = a.left, A = a.top, y = m - S * s, M = v - A * s, j = (y - r[4]) / (e - s), I = (M - r[5]) / (e - s), w = j * f, T = I * f, b = w * o, C = T * o, E = Math.abs(b) > Math.abs(l) ? l : b, x = Math.abs(C) > Math.abs(u) ? u : C;
|
|
3001
|
+
return { x: E, y: x };
|
|
2887
3002
|
}
|
|
2888
3003
|
/**
|
|
2889
3004
|
* Применяет плавное центрирование viewport при приближении к defaultZoom.
|
|
@@ -2895,7 +3010,7 @@ class Qs {
|
|
|
2895
3010
|
* @returns true если центрирование было применено
|
|
2896
3011
|
* @private
|
|
2897
3012
|
*/
|
|
2898
|
-
_applyViewportCentering(t, e = !1, s =
|
|
3013
|
+
_applyViewportCentering(t, e = !1, s = Xe) {
|
|
2899
3014
|
const { canvas: n } = this.editor, o = this._getScaledMontageDimensions(t), i = n.getWidth(), a = n.getHeight(), r = o.width > i || o.height > a, c = this._calculateFitZoom(), d = t - c;
|
|
2900
3015
|
if (!(!r || d) && !e)
|
|
2901
3016
|
return !1;
|
|
@@ -2970,7 +3085,7 @@ class Qs {
|
|
|
2970
3085
|
* @param options.pointY - Координата Y точки зума
|
|
2971
3086
|
* @fires editor:zoom-changed
|
|
2972
3087
|
*/
|
|
2973
|
-
zoom(t =
|
|
3088
|
+
zoom(t = Xe, e = {}) {
|
|
2974
3089
|
var f, g;
|
|
2975
3090
|
if (!t) return;
|
|
2976
3091
|
const { minZoom: s, maxZoom: n } = this, { canvas: o } = this.editor, i = t < 0, a = o.getZoom(), r = o.getCenterPoint(), c = (f = e.pointX) != null ? f : r.x, d = (g = e.pointY) != null ? g : r.y, l = new et(c, d);
|
|
@@ -3008,7 +3123,7 @@ class Qs {
|
|
|
3008
3123
|
}), this.editor.panConstraintManager.updateBounds();
|
|
3009
3124
|
}
|
|
3010
3125
|
}
|
|
3011
|
-
class
|
|
3126
|
+
class tn {
|
|
3012
3127
|
constructor({ editor: t }) {
|
|
3013
3128
|
this.editor = t, this.isBlocked = !1, this.overlayMask = null, this._createOverlay();
|
|
3014
3129
|
}
|
|
@@ -3065,7 +3180,7 @@ class $s {
|
|
|
3065
3180
|
}), t.upperCanvasEl.style.pointerEvents = "", t.lowerCanvasEl.style.pointerEvents = "", this.overlayMask.visible = !1, t.requestRenderAll(), t.fire("editor:enabled"), s.resumeHistory();
|
|
3066
3181
|
}
|
|
3067
3182
|
}
|
|
3068
|
-
class
|
|
3183
|
+
class xt {
|
|
3069
3184
|
constructor({ editor: t }) {
|
|
3070
3185
|
this.editor = t, this.backgroundObject = null;
|
|
3071
3186
|
}
|
|
@@ -3128,8 +3243,8 @@ class _t {
|
|
|
3128
3243
|
try {
|
|
3129
3244
|
const { historyManager: i } = this.editor, { backgroundObject: a } = this;
|
|
3130
3245
|
if (i.suspendHistory(), a && a.backgroundType === "gradient") {
|
|
3131
|
-
const r =
|
|
3132
|
-
if (
|
|
3246
|
+
const r = xt._createFabricGradient(t);
|
|
3247
|
+
if (xt._isGradientEqual(a.fill, r)) {
|
|
3133
3248
|
i.resumeHistory();
|
|
3134
3249
|
return;
|
|
3135
3250
|
}
|
|
@@ -3223,7 +3338,7 @@ class _t {
|
|
|
3223
3338
|
* @param options.withoutSave - Если true, не сохранять состояние в историю
|
|
3224
3339
|
*/
|
|
3225
3340
|
setImageBackground(o) {
|
|
3226
|
-
return
|
|
3341
|
+
return z(this, arguments, function* ({
|
|
3227
3342
|
imageSource: t,
|
|
3228
3343
|
customData: e = {},
|
|
3229
3344
|
fromTemplate: s = !1,
|
|
@@ -3312,7 +3427,7 @@ class _t {
|
|
|
3312
3427
|
backgroundType: "gradient",
|
|
3313
3428
|
backgroundId: `background-${K()}`
|
|
3314
3429
|
}, { withoutSelection: !0 }), this.refresh();
|
|
3315
|
-
const e =
|
|
3430
|
+
const e = xt._createFabricGradient(t);
|
|
3316
3431
|
this.backgroundObject.set("fill", e), this.editor.canvas.requestRenderAll();
|
|
3317
3432
|
}
|
|
3318
3433
|
/**
|
|
@@ -3320,7 +3435,7 @@ class _t {
|
|
|
3320
3435
|
* @param source - источник изображения (URL или File)
|
|
3321
3436
|
*/
|
|
3322
3437
|
_createImageBackground(t, e) {
|
|
3323
|
-
return
|
|
3438
|
+
return z(this, null, function* () {
|
|
3324
3439
|
var n;
|
|
3325
3440
|
const { image: s } = (n = yield this.editor.imageManager.importImage({
|
|
3326
3441
|
source: t,
|
|
@@ -3372,8 +3487,8 @@ class _t {
|
|
|
3372
3487
|
{ offset: 0, color: "#000000" },
|
|
3373
3488
|
{ offset: 1, color: "#ffffff" }
|
|
3374
3489
|
], t.type === "linear") {
|
|
3375
|
-
const u = t.angle * Math.PI / 180, f =
|
|
3376
|
-
return new
|
|
3490
|
+
const u = t.angle * Math.PI / 180, f = xt._angleToCoords(u);
|
|
3491
|
+
return new Ue({
|
|
3377
3492
|
type: "linear",
|
|
3378
3493
|
gradientUnits: "percentage",
|
|
3379
3494
|
coords: f,
|
|
@@ -3392,7 +3507,7 @@ class _t {
|
|
|
3392
3507
|
r1: 0,
|
|
3393
3508
|
r2: d / 100
|
|
3394
3509
|
};
|
|
3395
|
-
return new
|
|
3510
|
+
return new Ue({
|
|
3396
3511
|
type: "radial",
|
|
3397
3512
|
gradientUnits: "percentage",
|
|
3398
3513
|
coords: l,
|
|
@@ -3427,7 +3542,7 @@ class _t {
|
|
|
3427
3542
|
}) ? !1 : t.type === "linear" && e.type === "linear" ? Math.abs(t.coords.x1 - e.coords.x1) < 1e-4 && Math.abs(t.coords.y1 - e.coords.y1) < 1e-4 && Math.abs(t.coords.x2 - e.coords.x2) < 1e-4 && Math.abs(t.coords.y2 - e.coords.y2) < 1e-4 : t.type === "radial" && e.type === "radial" ? Math.abs(t.coords.x1 - e.coords.x1) < 1e-4 && Math.abs(t.coords.y1 - e.coords.y1) < 1e-4 && Math.abs(t.coords.x2 - e.coords.x2) < 1e-4 && Math.abs(t.coords.y2 - e.coords.y2) < 1e-4 && Math.abs(t.coords.r1 - e.coords.r1) < 1e-4 && Math.abs(t.coords.r2 - e.coords.r2) < 1e-4 : !1;
|
|
3428
3543
|
}
|
|
3429
3544
|
}
|
|
3430
|
-
class
|
|
3545
|
+
class ue {
|
|
3431
3546
|
constructor({ editor: t }) {
|
|
3432
3547
|
this.editor = t;
|
|
3433
3548
|
}
|
|
@@ -3460,7 +3575,7 @@ class fe {
|
|
|
3460
3575
|
const { canvas: s, historyManager: n } = this.editor;
|
|
3461
3576
|
n.suspendHistory();
|
|
3462
3577
|
const o = t || s.getActiveObject();
|
|
3463
|
-
o && (o instanceof F ?
|
|
3578
|
+
o && (o instanceof F ? ue._moveSelectionForward(s, o) : s.bringObjectForward(o), s.renderAll(), n.resumeHistory(), e || n.saveState(), s.fire("editor:object-bring-forward", {
|
|
3464
3579
|
object: o,
|
|
3465
3580
|
withoutSave: e
|
|
3466
3581
|
}));
|
|
@@ -3511,7 +3626,7 @@ class fe {
|
|
|
3511
3626
|
} = this.editor;
|
|
3512
3627
|
o.suspendHistory();
|
|
3513
3628
|
const r = t || s.getActiveObject();
|
|
3514
|
-
r && (r instanceof F ?
|
|
3629
|
+
r && (r instanceof F ? ue._moveSelectionBackwards(s, r) : s.sendObjectBackwards(r), a && s.sendObjectToBack(a), s.sendObjectToBack(n), i && s.sendObjectToBack(i), s.renderAll(), o.resumeHistory(), e || o.saveState(), s.fire("editor:object-send-backwards", {
|
|
3515
3630
|
object: r,
|
|
3516
3631
|
withoutSave: e
|
|
3517
3632
|
}));
|
|
@@ -3555,7 +3670,7 @@ class fe {
|
|
|
3555
3670
|
});
|
|
3556
3671
|
}
|
|
3557
3672
|
}
|
|
3558
|
-
class
|
|
3673
|
+
class en {
|
|
3559
3674
|
/**
|
|
3560
3675
|
* Менеджер фигур для редактора.
|
|
3561
3676
|
* @param options - Опции и настройки менеджера фигур.
|
|
@@ -3595,7 +3710,7 @@ class tn {
|
|
|
3595
3710
|
"height",
|
|
3596
3711
|
"fill"
|
|
3597
3712
|
]);
|
|
3598
|
-
const { canvas: u } = this.editor, f = new
|
|
3713
|
+
const { canvas: u } = this.editor, f = new gs(P({
|
|
3599
3714
|
id: t,
|
|
3600
3715
|
left: e,
|
|
3601
3716
|
top: s,
|
|
@@ -3635,7 +3750,7 @@ class tn {
|
|
|
3635
3750
|
"radius",
|
|
3636
3751
|
"fill"
|
|
3637
3752
|
]);
|
|
3638
|
-
const { canvas: l } = this.editor, u = new
|
|
3753
|
+
const { canvas: l } = this.editor, u = new ps(P({
|
|
3639
3754
|
id: t,
|
|
3640
3755
|
left: e,
|
|
3641
3756
|
top: s,
|
|
@@ -3677,7 +3792,7 @@ class tn {
|
|
|
3677
3792
|
"height",
|
|
3678
3793
|
"fill"
|
|
3679
3794
|
]);
|
|
3680
|
-
const { canvas: u } = this.editor, f = new
|
|
3795
|
+
const { canvas: u } = this.editor, f = new ms(P({
|
|
3681
3796
|
id: t,
|
|
3682
3797
|
left: e,
|
|
3683
3798
|
top: s,
|
|
@@ -3688,7 +3803,7 @@ class tn {
|
|
|
3688
3803
|
return !e && !s && u.centerObject(f), c || (u.add(f), r || u.setActiveObject(f), u.renderAll()), f;
|
|
3689
3804
|
}
|
|
3690
3805
|
}
|
|
3691
|
-
class
|
|
3806
|
+
class sn {
|
|
3692
3807
|
/**
|
|
3693
3808
|
* @param options
|
|
3694
3809
|
* @param options.editor - экземпляр редактора с доступом к canvas
|
|
@@ -3716,10 +3831,10 @@ class en {
|
|
|
3716
3831
|
* Асинхронное клонирование для внутреннего буфера
|
|
3717
3832
|
*/
|
|
3718
3833
|
_cloneToInternalClipboard(t) {
|
|
3719
|
-
return
|
|
3834
|
+
return z(this, null, function* () {
|
|
3720
3835
|
const { canvas: e, errorManager: s } = this.editor;
|
|
3721
3836
|
try {
|
|
3722
|
-
const n = yield t.clone(
|
|
3837
|
+
const n = yield t.clone(re);
|
|
3723
3838
|
this.clipboard = n, e.fire("editor:object-copied", { object: n });
|
|
3724
3839
|
} catch (n) {
|
|
3725
3840
|
s.emitError({
|
|
@@ -3736,7 +3851,7 @@ class en {
|
|
|
3736
3851
|
* Копирование в системный буфер обмена
|
|
3737
3852
|
*/
|
|
3738
3853
|
_copyToSystemClipboard(t) {
|
|
3739
|
-
return
|
|
3854
|
+
return z(this, null, function* () {
|
|
3740
3855
|
const { errorManager: e } = this.editor;
|
|
3741
3856
|
if (typeof ClipboardItem == "undefined" || !navigator.clipboard)
|
|
3742
3857
|
return e.emitWarning({
|
|
@@ -3746,7 +3861,7 @@ class en {
|
|
|
3746
3861
|
message: "navigator.clipboard не поддерживается в этом браузере или отсутствует HTTPS-соединение."
|
|
3747
3862
|
}), !1;
|
|
3748
3863
|
try {
|
|
3749
|
-
const s = t.toObject(
|
|
3864
|
+
const s = t.toObject(re), n = JSON.stringify(s);
|
|
3750
3865
|
return t.type === "image" ? this._copyImageToClipboard(t, n) : this._copyTextToClipboard(n);
|
|
3751
3866
|
} catch (s) {
|
|
3752
3867
|
return e.emitError({
|
|
@@ -3763,7 +3878,7 @@ class en {
|
|
|
3763
3878
|
* Копирование изображения в буфер обмена
|
|
3764
3879
|
*/
|
|
3765
3880
|
_copyImageToClipboard(t, e) {
|
|
3766
|
-
return
|
|
3881
|
+
return z(this, null, function* () {
|
|
3767
3882
|
try {
|
|
3768
3883
|
const n = t.toCanvasElement({ enableRetinaScaling: !1 }).toDataURL(), o = n.slice(5).split(";")[0], i = n.split(",")[1], a = atob(i), r = new Uint8Array(a.length);
|
|
3769
3884
|
for (let l = 0; l < a.length; l += 1)
|
|
@@ -3785,9 +3900,9 @@ class en {
|
|
|
3785
3900
|
* Копирование текста в буфер обмена
|
|
3786
3901
|
*/
|
|
3787
3902
|
_copyTextToClipboard(t) {
|
|
3788
|
-
return
|
|
3903
|
+
return z(this, null, function* () {
|
|
3789
3904
|
try {
|
|
3790
|
-
const e = `${
|
|
3905
|
+
const e = `${Ke}${t}`;
|
|
3791
3906
|
return yield navigator.clipboard.writeText(e), console.info("Text copied to clipboard successfully"), !0;
|
|
3792
3907
|
} catch (e) {
|
|
3793
3908
|
const { errorManager: s } = this.editor;
|
|
@@ -3820,7 +3935,7 @@ class en {
|
|
|
3820
3935
|
* @param source - источник изображения (data URL или URL)
|
|
3821
3936
|
*/
|
|
3822
3937
|
_handleImageImport(t) {
|
|
3823
|
-
return
|
|
3938
|
+
return z(this, null, function* () {
|
|
3824
3939
|
var s;
|
|
3825
3940
|
const { image: e } = (s = yield this.editor.imageManager.importImage({
|
|
3826
3941
|
source: t,
|
|
@@ -3836,11 +3951,11 @@ class en {
|
|
|
3836
3951
|
* @fires editor:object-pasted
|
|
3837
3952
|
*/
|
|
3838
3953
|
copyPaste(t) {
|
|
3839
|
-
return
|
|
3954
|
+
return z(this, null, function* () {
|
|
3840
3955
|
const { canvas: e } = this.editor, s = t || e.getActiveObject();
|
|
3841
3956
|
if (!s || s.locked) return !1;
|
|
3842
3957
|
try {
|
|
3843
|
-
const n = yield s.clone(
|
|
3958
|
+
const n = yield s.clone(re);
|
|
3844
3959
|
return n instanceof F && n.forEachObject((o) => {
|
|
3845
3960
|
o.set({
|
|
3846
3961
|
id: `${o.type}-${K()}`,
|
|
@@ -3871,14 +3986,14 @@ class en {
|
|
|
3871
3986
|
* @param event.clipboardData.items — элементы буфера обмена
|
|
3872
3987
|
*/
|
|
3873
3988
|
handlePasteEvent(e) {
|
|
3874
|
-
return
|
|
3989
|
+
return z(this, arguments, function* ({ clipboardData: t }) {
|
|
3875
3990
|
var r;
|
|
3876
3991
|
if (!((r = t == null ? void 0 : t.items) != null && r.length)) {
|
|
3877
3992
|
this.paste();
|
|
3878
3993
|
return;
|
|
3879
3994
|
}
|
|
3880
3995
|
const s = t.getData("text/plain");
|
|
3881
|
-
if (s && s.startsWith(
|
|
3996
|
+
if (s && s.startsWith(Ke)) {
|
|
3882
3997
|
this.paste();
|
|
3883
3998
|
return;
|
|
3884
3999
|
}
|
|
@@ -3922,11 +4037,11 @@ class en {
|
|
|
3922
4037
|
* @fires editor:object-pasted
|
|
3923
4038
|
*/
|
|
3924
4039
|
paste() {
|
|
3925
|
-
return
|
|
4040
|
+
return z(this, null, function* () {
|
|
3926
4041
|
const { canvas: t } = this.editor;
|
|
3927
4042
|
if (!this.clipboard) return !1;
|
|
3928
4043
|
try {
|
|
3929
|
-
const e = yield this.clipboard.clone(
|
|
4044
|
+
const e = yield this.clipboard.clone(re);
|
|
3930
4045
|
return t.discardActiveObject(), e instanceof F && e.forEachObject((s) => {
|
|
3931
4046
|
s.set({
|
|
3932
4047
|
id: `${s.type}-${K()}`,
|
|
@@ -3951,7 +4066,7 @@ class en {
|
|
|
3951
4066
|
});
|
|
3952
4067
|
}
|
|
3953
4068
|
}
|
|
3954
|
-
class
|
|
4069
|
+
class fe {
|
|
3955
4070
|
constructor({ editor: t }) {
|
|
3956
4071
|
this.editor = t;
|
|
3957
4072
|
}
|
|
@@ -3977,7 +4092,7 @@ class ge {
|
|
|
3977
4092
|
editable: !1,
|
|
3978
4093
|
locked: !0
|
|
3979
4094
|
};
|
|
3980
|
-
i.set(a), !e &&
|
|
4095
|
+
i.set(a), !e && fe._isGroupOrSelection(i) && i.getObjects().forEach((c) => {
|
|
3981
4096
|
c.set(a);
|
|
3982
4097
|
}), i instanceof at && i.isEditing && i.exitEditing(), n.renderAll(), s || o.saveState(), n.fire("editor:object-locked", {
|
|
3983
4098
|
object: i,
|
|
@@ -4006,7 +4121,7 @@ class ge {
|
|
|
4006
4121
|
editable: !0,
|
|
4007
4122
|
locked: !1
|
|
4008
4123
|
};
|
|
4009
|
-
o.set(i),
|
|
4124
|
+
o.set(i), fe._isGroupOrSelection(o) && o.getObjects().forEach((a) => {
|
|
4010
4125
|
a.set(i);
|
|
4011
4126
|
}), s.renderAll(), e || n.saveState(), s.fire("editor:object-unlocked", {
|
|
4012
4127
|
object: o,
|
|
@@ -4014,10 +4129,10 @@ class ge {
|
|
|
4014
4129
|
});
|
|
4015
4130
|
}
|
|
4016
4131
|
static _isGroupOrSelection(t) {
|
|
4017
|
-
return t instanceof F || t instanceof
|
|
4132
|
+
return t instanceof F || t instanceof Rt;
|
|
4018
4133
|
}
|
|
4019
4134
|
}
|
|
4020
|
-
class
|
|
4135
|
+
class nn {
|
|
4021
4136
|
constructor({ editor: t }) {
|
|
4022
4137
|
this.editor = t;
|
|
4023
4138
|
}
|
|
@@ -4037,20 +4152,20 @@ class sn {
|
|
|
4037
4152
|
*/
|
|
4038
4153
|
_getGroupsToUngroup(t) {
|
|
4039
4154
|
if (Array.isArray(t)) {
|
|
4040
|
-
const s = t.filter((n) => n instanceof
|
|
4155
|
+
const s = t.filter((n) => n instanceof Rt);
|
|
4041
4156
|
return s.length > 0 ? s : null;
|
|
4042
4157
|
}
|
|
4043
4158
|
if (t instanceof F) {
|
|
4044
|
-
const s = t.getObjects().filter((n) => n instanceof
|
|
4159
|
+
const s = t.getObjects().filter((n) => n instanceof Rt);
|
|
4045
4160
|
return s.length > 0 ? s : null;
|
|
4046
4161
|
}
|
|
4047
4162
|
const e = t || this.editor.canvas.getActiveObject();
|
|
4048
4163
|
if (!e) return null;
|
|
4049
4164
|
if (e instanceof F) {
|
|
4050
|
-
const s = e.getObjects().filter((n) => n instanceof
|
|
4165
|
+
const s = e.getObjects().filter((n) => n instanceof Rt);
|
|
4051
4166
|
return s.length > 0 ? s : null;
|
|
4052
4167
|
}
|
|
4053
|
-
return e instanceof
|
|
4168
|
+
return e instanceof Rt ? [e] : null;
|
|
4054
4169
|
}
|
|
4055
4170
|
/**
|
|
4056
4171
|
* Группировка объектов
|
|
@@ -4067,7 +4182,7 @@ class sn {
|
|
|
4067
4182
|
if (!o) return null;
|
|
4068
4183
|
try {
|
|
4069
4184
|
n.suspendHistory();
|
|
4070
|
-
const i = new
|
|
4185
|
+
const i = new Rt(o, {
|
|
4071
4186
|
id: `group-${K()}`
|
|
4072
4187
|
});
|
|
4073
4188
|
o.forEach((r) => s.remove(r)), s.add(i), s.setActiveObject(i), s.requestRenderAll();
|
|
@@ -4118,7 +4233,7 @@ class sn {
|
|
|
4118
4233
|
}
|
|
4119
4234
|
}
|
|
4120
4235
|
}
|
|
4121
|
-
class
|
|
4236
|
+
class on {
|
|
4122
4237
|
constructor({ editor: t }) {
|
|
4123
4238
|
this.editor = t;
|
|
4124
4239
|
}
|
|
@@ -4195,7 +4310,7 @@ class Re {
|
|
|
4195
4310
|
return n.fire("editor:objects-deleted", c), c;
|
|
4196
4311
|
}
|
|
4197
4312
|
}
|
|
4198
|
-
const
|
|
4313
|
+
const wt = {
|
|
4199
4314
|
IMAGE_MANAGER: {
|
|
4200
4315
|
/**
|
|
4201
4316
|
* Некорректный Content-Type изображения
|
|
@@ -4300,7 +4415,7 @@ const St = {
|
|
|
4300
4415
|
APPLY_FAILED: "TEMPLATE_APPLY_FAILED"
|
|
4301
4416
|
}
|
|
4302
4417
|
};
|
|
4303
|
-
class
|
|
4418
|
+
class $t {
|
|
4304
4419
|
constructor({ editor: t }) {
|
|
4305
4420
|
this._buffer = [], this.editor = t;
|
|
4306
4421
|
}
|
|
@@ -4327,7 +4442,7 @@ class te {
|
|
|
4327
4442
|
* @fires editor:error
|
|
4328
4443
|
*/
|
|
4329
4444
|
emitError({ origin: t = "ImageEditor", method: e = "Unknown Method", code: s, data: n, message: o }) {
|
|
4330
|
-
if (
|
|
4445
|
+
if (!$t.isValidErrorCode(s)) {
|
|
4331
4446
|
console.warn("Неизвестный код ошибки: ", { code: s, origin: t, method: e });
|
|
4332
4447
|
return;
|
|
4333
4448
|
}
|
|
@@ -4341,7 +4456,7 @@ class te {
|
|
|
4341
4456
|
message: i,
|
|
4342
4457
|
data: n
|
|
4343
4458
|
};
|
|
4344
|
-
this._buffer.push(
|
|
4459
|
+
this._buffer.push(P({
|
|
4345
4460
|
type: "editor:error"
|
|
4346
4461
|
}, a)), this.editor.canvas.fire("editor:error", a);
|
|
4347
4462
|
}
|
|
@@ -4356,7 +4471,7 @@ class te {
|
|
|
4356
4471
|
* @fires editor:warning
|
|
4357
4472
|
*/
|
|
4358
4473
|
emitWarning({ origin: t = "ImageEditor", method: e = "Unknown Method", code: s, message: n, data: o }) {
|
|
4359
|
-
if (
|
|
4474
|
+
if (!$t.isValidErrorCode(s)) {
|
|
4360
4475
|
console.warn("Неизвестный код предупреждения: ", { code: s, origin: t, method: e });
|
|
4361
4476
|
return;
|
|
4362
4477
|
}
|
|
@@ -4369,7 +4484,7 @@ class te {
|
|
|
4369
4484
|
message: i,
|
|
4370
4485
|
data: o
|
|
4371
4486
|
};
|
|
4372
|
-
this._buffer.push(
|
|
4487
|
+
this._buffer.push(P({
|
|
4373
4488
|
type: "editor:warning"
|
|
4374
4489
|
}, a)), this.editor.canvas.fire("editor:warning", a);
|
|
4375
4490
|
}
|
|
@@ -4379,10 +4494,10 @@ class te {
|
|
|
4379
4494
|
* @returns true, если код допустим, иначе false
|
|
4380
4495
|
*/
|
|
4381
4496
|
static isValidErrorCode(t) {
|
|
4382
|
-
return t ? Object.values(
|
|
4497
|
+
return t ? Object.values(wt).some((e) => Object.values(e).includes(t)) : !1;
|
|
4383
4498
|
}
|
|
4384
4499
|
}
|
|
4385
|
-
class
|
|
4500
|
+
class an {
|
|
4386
4501
|
constructor({ editor: t }) {
|
|
4387
4502
|
this.currentBounds = null, this.editor = t;
|
|
4388
4503
|
}
|
|
@@ -4471,7 +4586,7 @@ const ct = ({
|
|
|
4471
4586
|
value: h,
|
|
4472
4587
|
min: t,
|
|
4473
4588
|
max: e
|
|
4474
|
-
}) => Math.min(Math.max(h, t), e),
|
|
4589
|
+
}) => Math.min(Math.max(h, t), e), Nt = class Nt extends at {
|
|
4475
4590
|
constructor(t, e = {}) {
|
|
4476
4591
|
var s, n, o, i, a, r, c, d, l;
|
|
4477
4592
|
super(t, e), this.backgroundOpacity = (s = e.backgroundOpacity) != null ? s : 1, this.paddingTop = (n = e.paddingTop) != null ? n : 0, this.paddingRight = (o = e.paddingRight) != null ? o : 0, this.paddingBottom = (i = e.paddingBottom) != null ? i : 0, this.paddingLeft = (a = e.paddingLeft) != null ? a : 0, this.radiusTopLeft = (r = e.radiusTopLeft) != null ? r : 0, this.radiusTopRight = (c = e.radiusTopRight) != null ? c : 0, this.radiusBottomRight = (d = e.radiusBottomRight) != null ? d : 0, this.radiusBottomLeft = (l = e.radiusBottomLeft) != null ? l : 0, this._roundDimensions();
|
|
@@ -4496,7 +4611,7 @@ const ct = ({
|
|
|
4496
4611
|
}
|
|
4497
4612
|
_getTransformedDimensions(t = {}) {
|
|
4498
4613
|
const { width: e, height: s } = this._getBackgroundDimensions();
|
|
4499
|
-
return super._getTransformedDimensions(
|
|
4614
|
+
return super._getTransformedDimensions(St(P({}, t), {
|
|
4500
4615
|
width: e,
|
|
4501
4616
|
height: s
|
|
4502
4617
|
}));
|
|
@@ -4506,7 +4621,7 @@ const ct = ({
|
|
|
4506
4621
|
*/
|
|
4507
4622
|
toObject(t = []) {
|
|
4508
4623
|
const e = super.toObject(t);
|
|
4509
|
-
return
|
|
4624
|
+
return St(P({}, e), {
|
|
4510
4625
|
backgroundOpacity: this.backgroundOpacity,
|
|
4511
4626
|
paddingTop: this.paddingTop,
|
|
4512
4627
|
paddingRight: this.paddingRight,
|
|
@@ -4523,7 +4638,7 @@ const ct = ({
|
|
|
4523
4638
|
const e = this._getEffectiveBackgroundFill();
|
|
4524
4639
|
if (e && e) {
|
|
4525
4640
|
const o = this._getPadding(), i = (s = this.width) != null ? s : 0, a = (n = this.height) != null ? n : 0, r = i + o.left + o.right, c = a + o.top + o.bottom, d = this._getCornerRadii({ width: r, height: c }), l = this._getLeftOffset() - o.left, u = this._getTopOffset() - o.top;
|
|
4526
|
-
t.save(),
|
|
4641
|
+
t.save(), Nt._renderRoundedRect({
|
|
4527
4642
|
ctx: t,
|
|
4528
4643
|
height: c,
|
|
4529
4644
|
left: l,
|
|
@@ -4567,9 +4682,9 @@ const ct = ({
|
|
|
4567
4682
|
const e = ct({ value: (n = this.backgroundOpacity) != null ? n : 1, min: 0, max: 1 });
|
|
4568
4683
|
let s;
|
|
4569
4684
|
try {
|
|
4570
|
-
s = new
|
|
4685
|
+
s = new ys(t);
|
|
4571
4686
|
} catch (o) {
|
|
4572
|
-
return
|
|
4687
|
+
return $t.emitError({
|
|
4573
4688
|
origin: "BackgroundTextbox",
|
|
4574
4689
|
method: "_getEffectiveBackgroundFill",
|
|
4575
4690
|
code: "INVALID_COLOR_VALUE",
|
|
@@ -4606,7 +4721,7 @@ const ct = ({
|
|
|
4606
4721
|
s !== t && (this.width = Math.max(0, s)), n !== e && (this.height = Math.max(0, n));
|
|
4607
4722
|
}
|
|
4608
4723
|
};
|
|
4609
|
-
|
|
4724
|
+
Nt.type = "background-textbox", Nt.cacheProperties = [
|
|
4610
4725
|
...Array.isArray(at.cacheProperties) ? at.cacheProperties : [],
|
|
4611
4726
|
"backgroundColor",
|
|
4612
4727
|
"backgroundOpacity",
|
|
@@ -4618,7 +4733,7 @@ Bt.type = "background-textbox", Bt.cacheProperties = [
|
|
|
4618
4733
|
"radiusTopRight",
|
|
4619
4734
|
"radiusBottomRight",
|
|
4620
4735
|
"radiusBottomLeft"
|
|
4621
|
-
],
|
|
4736
|
+
], Nt.stateProperties = [
|
|
4622
4737
|
...Array.isArray(at.stateProperties) ? at.stateProperties : [],
|
|
4623
4738
|
"backgroundColor",
|
|
4624
4739
|
"backgroundOpacity",
|
|
@@ -4631,11 +4746,11 @@ Bt.type = "background-textbox", Bt.cacheProperties = [
|
|
|
4631
4746
|
"radiusBottomRight",
|
|
4632
4747
|
"radiusBottomLeft"
|
|
4633
4748
|
];
|
|
4634
|
-
let
|
|
4635
|
-
const
|
|
4749
|
+
let ge = Nt;
|
|
4750
|
+
const rn = () => {
|
|
4636
4751
|
var h;
|
|
4637
|
-
(h =
|
|
4638
|
-
},
|
|
4752
|
+
(h = Fe) != null && h.setClass && Fe.setClass(ge, "background-textbox");
|
|
4753
|
+
}, cn = ({ textbox: h }) => {
|
|
4639
4754
|
var s, n;
|
|
4640
4755
|
if (!h.isEditing) return null;
|
|
4641
4756
|
const t = (s = h.selectionStart) != null ? s : 0, e = (n = h.selectionEnd) != null ? n : t;
|
|
@@ -4643,16 +4758,16 @@ const an = () => {
|
|
|
4643
4758
|
start: Math.min(t, e),
|
|
4644
4759
|
end: Math.max(t, e)
|
|
4645
4760
|
};
|
|
4646
|
-
},
|
|
4761
|
+
}, dn = ({ textbox: h }) => {
|
|
4647
4762
|
var e, s;
|
|
4648
4763
|
const t = (s = (e = h.text) == null ? void 0 : e.length) != null ? s : 0;
|
|
4649
4764
|
return t <= 0 ? null : { start: 0, end: t };
|
|
4650
|
-
},
|
|
4765
|
+
}, ln = ({ textbox: h, range: t }) => {
|
|
4651
4766
|
var s, n;
|
|
4652
4767
|
if (!t) return !1;
|
|
4653
4768
|
const e = (n = (s = h.text) == null ? void 0 : s.length) != null ? n : 0;
|
|
4654
4769
|
return e <= 0 ? !1 : t.start <= 0 && t.end >= e;
|
|
4655
|
-
},
|
|
4770
|
+
}, me = ({
|
|
4656
4771
|
textbox: h,
|
|
4657
4772
|
styles: t,
|
|
4658
4773
|
range: e
|
|
@@ -4660,7 +4775,7 @@ const an = () => {
|
|
|
4660
4775
|
if (!t || !Object.keys(t).length) return !1;
|
|
4661
4776
|
const { start: s, end: n } = e;
|
|
4662
4777
|
return n <= s ? !1 : (h.setSelectionStyles(t, s, n), !0);
|
|
4663
|
-
},
|
|
4778
|
+
}, Je = ({
|
|
4664
4779
|
textbox: h,
|
|
4665
4780
|
range: t,
|
|
4666
4781
|
property: e
|
|
@@ -4674,27 +4789,29 @@ const an = () => {
|
|
|
4674
4789
|
);
|
|
4675
4790
|
if (s.length)
|
|
4676
4791
|
return (n = s[0]) == null ? void 0 : n[e];
|
|
4677
|
-
},
|
|
4678
|
-
class
|
|
4792
|
+
}, Qe = ({ strokeColor: h, width: t }) => t <= 0 ? null : h != null ? h : "#000000", $e = ({ width: h = 0 }) => h ? Math.max(0, h) : 0, ye = ({ value: h }) => typeof h == "string" ? h.toLocaleUpperCase() : "", tt = 0.01;
|
|
4793
|
+
class W {
|
|
4679
4794
|
constructor({ editor: t }) {
|
|
4680
4795
|
var e;
|
|
4681
4796
|
this._handleTextEditingEntered = (s) => {
|
|
4682
|
-
var
|
|
4797
|
+
var c;
|
|
4683
4798
|
this.isTextEditingActive = !0;
|
|
4684
4799
|
const { target: n } = s;
|
|
4685
|
-
if (!
|
|
4686
|
-
const
|
|
4800
|
+
if (!W._isTextbox(n)) return;
|
|
4801
|
+
const { historyManager: o } = this.editor;
|
|
4802
|
+
o.beginAction({ reason: "text-edit" });
|
|
4803
|
+
const i = (c = n.originY) != null ? c : "top", a = n.getPointByOrigin("center", i);
|
|
4687
4804
|
this._ensureEditingAnchorState().set(n, {
|
|
4688
|
-
originY:
|
|
4689
|
-
x:
|
|
4690
|
-
y:
|
|
4805
|
+
originY: i,
|
|
4806
|
+
x: a.x,
|
|
4807
|
+
y: a.y
|
|
4691
4808
|
});
|
|
4692
4809
|
}, this._handleTextChanged = (s) => {
|
|
4693
4810
|
const { target: n } = s;
|
|
4694
|
-
if (!
|
|
4811
|
+
if (!W._isTextbox(n)) return;
|
|
4695
4812
|
const { text: o = "", uppercase: i, autoExpand: a } = n, r = !!i, c = a !== !1, d = o.toLocaleLowerCase();
|
|
4696
4813
|
if (r) {
|
|
4697
|
-
const f =
|
|
4814
|
+
const f = ye({ value: d });
|
|
4698
4815
|
f !== o && n.set({ text: f }), n.textCaseRaw = d;
|
|
4699
4816
|
} else
|
|
4700
4817
|
n.textCaseRaw = o;
|
|
@@ -4702,28 +4819,31 @@ class P {
|
|
|
4702
4819
|
let l = !1;
|
|
4703
4820
|
c && (l = this._autoExpandTextboxWidth(n));
|
|
4704
4821
|
let u = !1;
|
|
4705
|
-
l || (u =
|
|
4822
|
+
l || (u = W._roundTextboxDimensions({ textbox: n })), (l || u) && (n.setCoords(), n.dirty = !0);
|
|
4706
4823
|
}, this._handleTextEditingExited = (s) => {
|
|
4707
|
-
var
|
|
4824
|
+
var c, d, l;
|
|
4708
4825
|
const { target: n } = s;
|
|
4709
|
-
if (!
|
|
4710
|
-
(
|
|
4711
|
-
const o = (
|
|
4826
|
+
if (!W._isTextbox(n)) return;
|
|
4827
|
+
(c = this.editingAnchorState) == null || c.delete(n);
|
|
4828
|
+
const o = (d = n.text) != null ? d : "";
|
|
4712
4829
|
if (!!n.uppercase) {
|
|
4713
|
-
const
|
|
4714
|
-
n.textCaseRaw =
|
|
4830
|
+
const u = (l = n.textCaseRaw) != null ? l : o.toLocaleLowerCase();
|
|
4831
|
+
n.textCaseRaw = u;
|
|
4715
4832
|
} else
|
|
4716
4833
|
n.textCaseRaw = o;
|
|
4717
|
-
|
|
4834
|
+
W._roundTextboxDimensions({ textbox: n }) && (n.setCoords(), n.dirty = !0, this.canvas.requestRenderAll()), n.locked || n.set({
|
|
4718
4835
|
lockMovementX: !1,
|
|
4719
4836
|
lockMovementY: !1
|
|
4720
|
-
})
|
|
4721
|
-
|
|
4722
|
-
},
|
|
4837
|
+
});
|
|
4838
|
+
const { historyManager: r } = this.editor;
|
|
4839
|
+
r.endAction({ reason: "text-edit" }), r.scheduleSaveState({
|
|
4840
|
+
delayMs: Xs,
|
|
4841
|
+
reason: "text-edit"
|
|
4842
|
+
});
|
|
4723
4843
|
}, this._handleObjectScaling = (s) => {
|
|
4724
|
-
var se, ne,
|
|
4844
|
+
var ee, se, ne, Tt, pe, oe, Ft, Yt, Ht, Zt, Gt, Vt, Xt;
|
|
4725
4845
|
const { target: n, transform: o } = s;
|
|
4726
|
-
if (n instanceof F || !
|
|
4846
|
+
if (n instanceof F || !W._isTextbox(n) || !o) return;
|
|
4727
4847
|
n.isScaling = !0;
|
|
4728
4848
|
const i = this._ensureScalingState(n), {
|
|
4729
4849
|
baseWidth: a,
|
|
@@ -4732,52 +4852,52 @@ class P {
|
|
|
4732
4852
|
basePadding: d,
|
|
4733
4853
|
baseRadii: l,
|
|
4734
4854
|
baseStyles: u
|
|
4735
|
-
} = i, f = typeof ((
|
|
4855
|
+
} = i, f = typeof ((ee = o.original) == null ? void 0 : ee.width) == "number" ? o.original.width : void 0, g = typeof ((se = o.original) == null ? void 0 : se.left) == "number" ? o.original.left : void 0, p = f != null ? f : a, m = g != null ? g : r, v = (ne = o.corner) != null ? ne : "", S = (Tt = o.action) != null ? Tt : "", A = ["ml", "mr"].includes(v) || S === "scaleX", y = ["mt", "mb"].includes(v) || S === "scaleY", M = ["tl", "tr", "bl", "br"].includes(v) || S === "scale", j = M || y;
|
|
4736
4856
|
if (!A && !y && !M) return;
|
|
4737
|
-
const
|
|
4738
|
-
paddingTop:
|
|
4739
|
-
paddingRight:
|
|
4740
|
-
paddingBottom:
|
|
4741
|
-
paddingLeft:
|
|
4857
|
+
const I = Math.abs((oe = (pe = n.scaleX) != null ? pe : o.scaleX) != null ? oe : 1) || 1, w = Math.abs((Yt = (Ft = n.scaleY) != null ? Ft : o.scaleY) != null ? Yt : 1) || 1, T = Math.max(1, p * I), b = Math.max(1, Math.round(T)), C = Math.max(1, c * w), {
|
|
4858
|
+
paddingTop: E = 0,
|
|
4859
|
+
paddingRight: x = 0,
|
|
4860
|
+
paddingBottom: N = 0,
|
|
4861
|
+
paddingLeft: B = 0,
|
|
4742
4862
|
radiusTopLeft: H = 0,
|
|
4743
4863
|
radiusTopRight: Z = 0,
|
|
4744
4864
|
radiusBottomRight: $ = 0,
|
|
4745
4865
|
radiusBottomLeft: Y = 0,
|
|
4746
4866
|
fontSize: st,
|
|
4747
|
-
width:
|
|
4867
|
+
width: _,
|
|
4748
4868
|
originX: O = "left"
|
|
4749
4869
|
} = n, it = M || y, X = M || y, V = it ? {
|
|
4750
|
-
top: Math.max(0, d.top *
|
|
4751
|
-
right: Math.max(0, d.right *
|
|
4752
|
-
bottom: Math.max(0, d.bottom *
|
|
4753
|
-
left: Math.max(0, d.left *
|
|
4870
|
+
top: Math.max(0, d.top * w),
|
|
4871
|
+
right: Math.max(0, d.right * w),
|
|
4872
|
+
bottom: Math.max(0, d.bottom * w),
|
|
4873
|
+
left: Math.max(0, d.left * w)
|
|
4754
4874
|
} : d, k = X ? {
|
|
4755
|
-
topLeft: Math.max(0, l.topLeft *
|
|
4756
|
-
topRight: Math.max(0, l.topRight *
|
|
4757
|
-
bottomRight: Math.max(0, l.bottomRight *
|
|
4758
|
-
bottomLeft: Math.max(0, l.bottomLeft *
|
|
4759
|
-
} : l,
|
|
4875
|
+
topLeft: Math.max(0, l.topLeft * w),
|
|
4876
|
+
topRight: Math.max(0, l.topRight * w),
|
|
4877
|
+
bottomRight: Math.max(0, l.bottomRight * w),
|
|
4878
|
+
bottomLeft: Math.max(0, l.bottomLeft * w)
|
|
4879
|
+
} : l, zt = Object.keys(u).length > 0;
|
|
4760
4880
|
let Q;
|
|
4761
|
-
if (j &&
|
|
4762
|
-
const
|
|
4881
|
+
if (j && zt) {
|
|
4882
|
+
const Et = {};
|
|
4763
4883
|
Object.entries(u).forEach(([q, Ot]) => {
|
|
4764
4884
|
if (!Ot) return;
|
|
4765
4885
|
const Kt = {};
|
|
4766
4886
|
Object.entries(Ot).forEach(([Lt, Dt]) => {
|
|
4767
4887
|
if (!Dt) return;
|
|
4768
|
-
const
|
|
4769
|
-
typeof Dt.fontSize == "number" && (
|
|
4770
|
-
}), Object.keys(Kt).length && (
|
|
4771
|
-
}), Object.keys(
|
|
4888
|
+
const _t = P({}, Dt);
|
|
4889
|
+
typeof Dt.fontSize == "number" && (_t.fontSize = Math.max(1, Dt.fontSize * w)), Kt[Lt] = _t;
|
|
4890
|
+
}), Object.keys(Kt).length && (Et[q] = Kt);
|
|
4891
|
+
}), Object.keys(Et).length && (Q = Et);
|
|
4772
4892
|
}
|
|
4773
|
-
const nt = (Zt = (Ht = o.originX) != null ? Ht : O) != null ? Zt : "left",
|
|
4774
|
-
if (!rt && !
|
|
4893
|
+
const nt = (Zt = (Ht = o.originX) != null ? Ht : O) != null ? Zt : "left", It = m + p, ut = m + p / 2, ft = _ != null ? _ : p, rt = b !== ft, Ct = Math.abs(C - (st != null ? st : c)) > tt, Wt = Math.abs(V.top - E) > tt || Math.abs(V.right - x) > tt || Math.abs(V.bottom - N) > tt || Math.abs(V.left - B) > tt, yt = Math.abs(k.topLeft - H) > tt || Math.abs(k.topRight - Z) > tt || Math.abs(k.bottomRight - $) > tt || Math.abs(k.bottomLeft - Y) > tt;
|
|
4894
|
+
if (!rt && !Ct && !Wt && !yt) {
|
|
4775
4895
|
n.set({ scaleX: 1, scaleY: 1 }), o.scaleX = 1, o.scaleY = 1;
|
|
4776
4896
|
return;
|
|
4777
4897
|
}
|
|
4778
4898
|
Q && (n.styles = Q), n.set({
|
|
4779
4899
|
width: b,
|
|
4780
|
-
fontSize: j ?
|
|
4900
|
+
fontSize: j ? C : c,
|
|
4781
4901
|
paddingTop: V.top,
|
|
4782
4902
|
paddingRight: V.right,
|
|
4783
4903
|
paddingBottom: V.bottom,
|
|
@@ -4789,13 +4909,13 @@ class P {
|
|
|
4789
4909
|
scaleX: 1,
|
|
4790
4910
|
scaleY: 1
|
|
4791
4911
|
});
|
|
4792
|
-
const
|
|
4793
|
-
|
|
4912
|
+
const te = W._roundTextboxDimensions({ textbox: n });
|
|
4913
|
+
te && (n.dirty = !0);
|
|
4794
4914
|
const vt = (Gt = n.width) != null ? Gt : b, Ut = vt !== ft;
|
|
4795
4915
|
let bt = m;
|
|
4796
|
-
Ut && (A || M) && (nt === "right" ? bt =
|
|
4916
|
+
Ut && (A || M) && (nt === "right" ? bt = It - vt : nt === "center" && (bt = ut - vt / 2)), n.set({ left: bt }), i.baseLeft = bt, o.scaleX = 1, o.scaleY = 1;
|
|
4797
4917
|
const { original: Mt } = o;
|
|
4798
|
-
Mt && (Mt.scaleX = 1, Mt.scaleY = 1, Mt.width = vt, Mt.height = n.height, Mt.left = bt), n.setCoords(), this.canvas.requestRenderAll(), i.baseWidth = vt, i.baseFontSize = (Vt = n.fontSize) != null ? Vt :
|
|
4918
|
+
Mt && (Mt.scaleX = 1, Mt.scaleY = 1, Mt.width = vt, Mt.height = n.height, Mt.left = bt), n.setCoords(), this.canvas.requestRenderAll(), i.baseWidth = vt, i.baseFontSize = (Vt = n.fontSize) != null ? Vt : C, i.baseStyles = JSON.parse(JSON.stringify((Xt = n.styles) != null ? Xt : {})), i.basePadding = {
|
|
4799
4919
|
top: V.top,
|
|
4800
4920
|
right: V.right,
|
|
4801
4921
|
bottom: V.bottom,
|
|
@@ -4805,66 +4925,66 @@ class P {
|
|
|
4805
4925
|
topRight: k.topRight,
|
|
4806
4926
|
bottomRight: k.bottomRight,
|
|
4807
4927
|
bottomLeft: k.bottomLeft
|
|
4808
|
-
}, i.hasWidthChange = Ut ||
|
|
4928
|
+
}, i.hasWidthChange = Ut || Ct || Wt || yt || te;
|
|
4809
4929
|
}, this._handleObjectModified = (s) => {
|
|
4810
|
-
var
|
|
4930
|
+
var S, A, y;
|
|
4811
4931
|
const { target: n } = s;
|
|
4812
4932
|
if (n instanceof F) {
|
|
4813
4933
|
const M = n.getObjects();
|
|
4814
|
-
if (!M.some((b) =>
|
|
4815
|
-
const { scaleX:
|
|
4816
|
-
if (Math.abs(
|
|
4934
|
+
if (!M.some((b) => W._isTextbox(b))) return;
|
|
4935
|
+
const { scaleX: I = 1, scaleY: w = 1 } = n;
|
|
4936
|
+
if (Math.abs(I - 1) < tt && Math.abs(w - 1) < tt) return;
|
|
4817
4937
|
this.canvas.discardActiveObject(), M.forEach((b) => {
|
|
4818
|
-
var
|
|
4819
|
-
if (
|
|
4820
|
-
const
|
|
4938
|
+
var C, E, x, N;
|
|
4939
|
+
if (W._isTextbox(b)) {
|
|
4940
|
+
const B = (C = b.scaleX) != null ? C : 1, H = (E = b.scaleY) != null ? E : 1, Z = ((x = b.fontSize) != null ? x : 16) * H, $ = ((N = b.width) != null ? N : 0) * B, Y = H, {
|
|
4821
4941
|
paddingTop: st = 0,
|
|
4822
|
-
paddingRight:
|
|
4942
|
+
paddingRight: _ = 0,
|
|
4823
4943
|
paddingBottom: O = 0,
|
|
4824
4944
|
paddingLeft: it = 0,
|
|
4825
4945
|
radiusTopLeft: X = 0,
|
|
4826
4946
|
radiusTopRight: V = 0,
|
|
4827
4947
|
radiusBottomRight: k = 0,
|
|
4828
|
-
radiusBottomLeft:
|
|
4948
|
+
radiusBottomLeft: zt = 0,
|
|
4829
4949
|
styles: Q
|
|
4830
4950
|
} = b, nt = {
|
|
4831
4951
|
paddingTop: Math.max(0, st * Y),
|
|
4832
|
-
paddingRight: Math.max(0,
|
|
4952
|
+
paddingRight: Math.max(0, _ * Y),
|
|
4833
4953
|
paddingBottom: Math.max(0, O * Y),
|
|
4834
4954
|
paddingLeft: Math.max(0, it * Y)
|
|
4835
|
-
},
|
|
4955
|
+
}, It = {
|
|
4836
4956
|
radiusTopLeft: Math.max(0, X * Y),
|
|
4837
4957
|
radiusTopRight: Math.max(0, V * Y),
|
|
4838
4958
|
radiusBottomRight: Math.max(0, k * Y),
|
|
4839
|
-
radiusBottomLeft: Math.max(0,
|
|
4959
|
+
radiusBottomLeft: Math.max(0, zt * Y)
|
|
4840
4960
|
};
|
|
4841
4961
|
let ut = Q;
|
|
4842
4962
|
Q && Object.keys(Q).length > 0 && (ut = JSON.parse(JSON.stringify(Q)), Object.values(ut).forEach((ft) => {
|
|
4843
4963
|
Object.values(ft).forEach((rt) => {
|
|
4844
4964
|
typeof rt.fontSize == "number" && (rt.fontSize = Math.max(1, rt.fontSize * Y));
|
|
4845
4965
|
});
|
|
4846
|
-
})), b.set(
|
|
4966
|
+
})), b.set(St(P(P({
|
|
4847
4967
|
fontSize: Z,
|
|
4848
4968
|
width: $,
|
|
4849
4969
|
scaleX: 1,
|
|
4850
4970
|
scaleY: 1
|
|
4851
|
-
}, nt),
|
|
4971
|
+
}, nt), It), {
|
|
4852
4972
|
styles: ut
|
|
4853
|
-
})),
|
|
4973
|
+
})), W._roundTextboxDimensions({ textbox: b });
|
|
4854
4974
|
}
|
|
4855
4975
|
b.setCoords();
|
|
4856
4976
|
});
|
|
4857
|
-
const
|
|
4977
|
+
const T = new F(M, {
|
|
4858
4978
|
canvas: this.canvas
|
|
4859
4979
|
});
|
|
4860
|
-
this.canvas.setActiveObject(
|
|
4980
|
+
this.canvas.setActiveObject(T), this.canvas.requestRenderAll();
|
|
4861
4981
|
return;
|
|
4862
4982
|
}
|
|
4863
|
-
if (!
|
|
4983
|
+
if (!W._isTextbox(n)) return;
|
|
4864
4984
|
n.isScaling = !1;
|
|
4865
4985
|
const o = this.scalingState.get(n);
|
|
4866
4986
|
if (this.scalingState.delete(n), !(o != null && o.hasWidthChange)) return;
|
|
4867
|
-
const i = (
|
|
4987
|
+
const i = (S = n.width) != null ? S : n.calcTextWidth(), a = (y = (A = n.fontSize) != null ? A : o == null ? void 0 : o.baseFontSize) != null ? y : 16, r = !!(o.baseStyles && Object.keys(o.baseStyles).length), {
|
|
4868
4988
|
paddingTop: c = 0,
|
|
4869
4989
|
paddingRight: d = 0,
|
|
4870
4990
|
paddingBottom: l = 0,
|
|
@@ -4888,15 +5008,15 @@ class P {
|
|
|
4888
5008
|
target: n,
|
|
4889
5009
|
style: v
|
|
4890
5010
|
}), n.set({ scaleX: 1, scaleY: 1 }), n.setCoords();
|
|
4891
|
-
}, this.editor = t, this.canvas = t.canvas, this.fonts = (e = t.options.fonts) != null ? e : [], this.scalingState = /* @__PURE__ */ new WeakMap(), this.editingAnchorState = /* @__PURE__ */ new WeakMap(), this.isTextEditingActive = !1, this._bindEvents(),
|
|
5011
|
+
}, this.editor = t, this.canvas = t.canvas, this.fonts = (e = t.options.fonts) != null ? e : [], this.scalingState = /* @__PURE__ */ new WeakMap(), this.editingAnchorState = /* @__PURE__ */ new WeakMap(), this.isTextEditingActive = !1, this._bindEvents(), rn();
|
|
4892
5012
|
}
|
|
4893
5013
|
/**
|
|
4894
5014
|
* Добавляет новый текстовый объект на канвас.
|
|
4895
5015
|
* @param options — настройки текста
|
|
4896
5016
|
* @param flags — флаги поведения
|
|
4897
5017
|
*/
|
|
4898
|
-
addText(
|
|
4899
|
-
var
|
|
5018
|
+
addText(N = {}, { withoutSelection: C = !1, withoutSave: E = !1, withoutAdding: x = !1 } = {}) {
|
|
5019
|
+
var B = N, {
|
|
4900
5020
|
id: t = `text-${K()}`,
|
|
4901
5021
|
text: e = "Новый текст",
|
|
4902
5022
|
autoExpand: s = !0,
|
|
@@ -4914,15 +5034,15 @@ class P {
|
|
|
4914
5034
|
opacity: p = 1,
|
|
4915
5035
|
backgroundColor: m,
|
|
4916
5036
|
backgroundOpacity: v = 1,
|
|
4917
|
-
paddingTop:
|
|
5037
|
+
paddingTop: S = 0,
|
|
4918
5038
|
paddingRight: A = 0,
|
|
4919
5039
|
paddingBottom: y = 0,
|
|
4920
5040
|
paddingLeft: M = 0,
|
|
4921
5041
|
radiusTopLeft: j = 0,
|
|
4922
|
-
radiusTopRight:
|
|
4923
|
-
radiusBottomRight:
|
|
4924
|
-
radiusBottomLeft:
|
|
4925
|
-
} =
|
|
5042
|
+
radiusTopRight: I = 0,
|
|
5043
|
+
radiusBottomRight: w = 0,
|
|
5044
|
+
radiusBottomLeft: T = 0
|
|
5045
|
+
} = B, b = gt(B, [
|
|
4926
5046
|
"id",
|
|
4927
5047
|
"text",
|
|
4928
5048
|
"autoExpand",
|
|
@@ -4952,10 +5072,10 @@ class P {
|
|
|
4952
5072
|
var V;
|
|
4953
5073
|
const { historyManager: H } = this.editor, { canvas: Z } = this;
|
|
4954
5074
|
H.suspendHistory();
|
|
4955
|
-
const $ = n != null ? n : this._getDefaultFontFamily(), Y =
|
|
5075
|
+
const $ = n != null ? n : this._getDefaultFontFamily(), Y = $e({ width: g }), st = Qe({
|
|
4956
5076
|
strokeColor: f,
|
|
4957
5077
|
width: Y
|
|
4958
|
-
}),
|
|
5078
|
+
}), _ = P({
|
|
4959
5079
|
id: t,
|
|
4960
5080
|
fontFamily: $,
|
|
4961
5081
|
fontSize: o,
|
|
@@ -4972,22 +5092,22 @@ class P {
|
|
|
4972
5092
|
opacity: p,
|
|
4973
5093
|
backgroundColor: m,
|
|
4974
5094
|
backgroundOpacity: v,
|
|
4975
|
-
paddingTop:
|
|
5095
|
+
paddingTop: S,
|
|
4976
5096
|
paddingRight: A,
|
|
4977
5097
|
paddingBottom: y,
|
|
4978
5098
|
paddingLeft: M,
|
|
4979
5099
|
radiusTopLeft: j,
|
|
4980
|
-
radiusTopRight:
|
|
4981
|
-
radiusBottomRight:
|
|
4982
|
-
radiusBottomLeft:
|
|
4983
|
-
}, b), O = new
|
|
5100
|
+
radiusTopRight: I,
|
|
5101
|
+
radiusBottomRight: w,
|
|
5102
|
+
radiusBottomLeft: T
|
|
5103
|
+
}, b), O = new ge(e, _), it = s !== !1;
|
|
4984
5104
|
if (O.autoExpand = it, O.textCaseRaw = (V = O.text) != null ? V : "", c) {
|
|
4985
|
-
const k =
|
|
5105
|
+
const k = ye({ value: O.textCaseRaw });
|
|
4986
5106
|
k !== O.text && O.set({ text: k });
|
|
4987
5107
|
}
|
|
4988
|
-
return
|
|
5108
|
+
return W._roundTextboxDimensions({ textbox: O }) && (O.dirty = !0), b.left === void 0 && b.top === void 0 && Z.centerObject(O), x || Z.add(O), C || Z.setActiveObject(O), Z.requestRenderAll(), H.resumeHistory(), E || H.saveState(), Z.fire("editor:text-added", {
|
|
4989
5109
|
textbox: O,
|
|
4990
|
-
options:
|
|
5110
|
+
options: St(P({}, _), {
|
|
4991
5111
|
text: e,
|
|
4992
5112
|
bold: i,
|
|
4993
5113
|
italic: a,
|
|
@@ -4998,9 +5118,9 @@ class P {
|
|
|
4998
5118
|
strokeWidth: Y
|
|
4999
5119
|
}),
|
|
5000
5120
|
flags: {
|
|
5001
|
-
withoutSelection: !!
|
|
5002
|
-
withoutSave: !!
|
|
5003
|
-
withoutAdding: !!
|
|
5121
|
+
withoutSelection: !!C,
|
|
5122
|
+
withoutSave: !!E,
|
|
5123
|
+
withoutAdding: !!x
|
|
5004
5124
|
}
|
|
5005
5125
|
}), O;
|
|
5006
5126
|
}
|
|
@@ -5018,12 +5138,12 @@ class P {
|
|
|
5018
5138
|
withoutSave: s,
|
|
5019
5139
|
skipRender: n
|
|
5020
5140
|
} = {}) {
|
|
5021
|
-
var Ft, Ht, Zt, Gt, Vt, Xt,
|
|
5141
|
+
var Ft, Ht, Zt, Gt, Vt, Xt, Et;
|
|
5022
5142
|
const o = this._resolveTextObject(t);
|
|
5023
5143
|
if (!o) return null;
|
|
5024
5144
|
const { historyManager: i } = this.editor, { canvas: a } = this;
|
|
5025
5145
|
i.suspendHistory();
|
|
5026
|
-
const r =
|
|
5146
|
+
const r = W._getSnapshot(o), c = (Ft = o.originY) != null ? Ft : "top", d = o.getPointByOrigin("center", c), l = {
|
|
5027
5147
|
originY: c,
|
|
5028
5148
|
x: d.x,
|
|
5029
5149
|
y: d.y
|
|
@@ -5034,20 +5154,20 @@ class P {
|
|
|
5034
5154
|
fontSize: p,
|
|
5035
5155
|
bold: m,
|
|
5036
5156
|
italic: v,
|
|
5037
|
-
underline:
|
|
5157
|
+
underline: S,
|
|
5038
5158
|
uppercase: A,
|
|
5039
5159
|
strikethrough: y,
|
|
5040
5160
|
align: M,
|
|
5041
5161
|
color: j,
|
|
5042
|
-
strokeColor:
|
|
5043
|
-
strokeWidth:
|
|
5044
|
-
opacity:
|
|
5162
|
+
strokeColor: I,
|
|
5163
|
+
strokeWidth: w,
|
|
5164
|
+
opacity: T,
|
|
5045
5165
|
backgroundColor: b,
|
|
5046
|
-
backgroundOpacity:
|
|
5047
|
-
paddingTop:
|
|
5048
|
-
paddingRight:
|
|
5049
|
-
paddingBottom:
|
|
5050
|
-
paddingLeft:
|
|
5166
|
+
backgroundOpacity: C,
|
|
5167
|
+
paddingTop: E,
|
|
5168
|
+
paddingRight: x,
|
|
5169
|
+
paddingBottom: N,
|
|
5170
|
+
paddingLeft: B,
|
|
5051
5171
|
radiusTopLeft: H,
|
|
5052
5172
|
radiusTopRight: Z,
|
|
5053
5173
|
radiusBottomRight: $,
|
|
@@ -5077,60 +5197,60 @@ class P {
|
|
|
5077
5197
|
"radiusTopRight",
|
|
5078
5198
|
"radiusBottomRight",
|
|
5079
5199
|
"radiusBottomLeft"
|
|
5080
|
-
]),
|
|
5081
|
-
if (g !== void 0 && (it && (V.fontFamily = g), Q && (
|
|
5200
|
+
]), _ = P({}, st), O = cn({ textbox: o }), it = O ? W._expandRangeToFullLines({ textbox: o, range: O }) : null, X = {}, V = {}, k = {}, zt = ln({ textbox: o, range: O }), Q = !O || zt, nt = !O;
|
|
5201
|
+
if (g !== void 0 && (it && (V.fontFamily = g), Q && (_.fontFamily = g, nt && (k.fontFamily = g))), p !== void 0 && (it && (V.fontSize = p), Q && (_.fontSize = p, nt && (k.fontSize = p))), m !== void 0) {
|
|
5082
5202
|
const q = m ? "bold" : "normal";
|
|
5083
|
-
O && (X.fontWeight = q), Q && (
|
|
5203
|
+
O && (X.fontWeight = q), Q && (_.fontWeight = q, nt && (k.fontWeight = q));
|
|
5084
5204
|
}
|
|
5085
5205
|
if (v !== void 0) {
|
|
5086
5206
|
const q = v ? "italic" : "normal";
|
|
5087
|
-
O && (X.fontStyle = q), Q && (
|
|
5207
|
+
O && (X.fontStyle = q), Q && (_.fontStyle = q, nt && (k.fontStyle = q));
|
|
5088
5208
|
}
|
|
5089
|
-
if (
|
|
5090
|
-
const q = O ?
|
|
5209
|
+
if (S !== void 0 && (O && (X.underline = S), Q && (_.underline = S, nt && (k.underline = S))), y !== void 0 && (O && (X.linethrough = y), Q && (_.linethrough = y, nt && (k.linethrough = y))), M !== void 0 && (_.textAlign = M), j !== void 0 && (O && (X.fill = j), Q && (_.fill = j, nt && (k.fill = j))), I !== void 0 || w !== void 0) {
|
|
5210
|
+
const q = O ? Je({ textbox: o, range: O, property: "strokeWidth" }) : void 0, Ot = O ? Je({ textbox: o, range: O, property: "stroke" }) : void 0, Kt = (Zt = (Ht = w != null ? w : q) != null ? Ht : o.strokeWidth) != null ? Zt : 0, Lt = $e({ width: Kt }), Dt = (Vt = (Gt = I != null ? I : Ot) != null ? Gt : o.stroke) != null ? Vt : void 0, _t = Qe({
|
|
5091
5211
|
strokeColor: Dt,
|
|
5092
5212
|
width: Lt
|
|
5093
5213
|
});
|
|
5094
|
-
O && (X.stroke =
|
|
5214
|
+
O && (X.stroke = _t, X.strokeWidth = Lt), Q && (_.stroke = _t, _.strokeWidth = Lt, nt && (k.stroke = _t, k.strokeWidth = Lt));
|
|
5095
5215
|
}
|
|
5096
|
-
|
|
5097
|
-
const
|
|
5216
|
+
T !== void 0 && (_.opacity = T), b !== void 0 && (_.backgroundColor = b), C !== void 0 && (_.backgroundOpacity = C), E !== void 0 && (_.paddingTop = E), x !== void 0 && (_.paddingRight = x), N !== void 0 && (_.paddingBottom = N), B !== void 0 && (_.paddingLeft = B), H !== void 0 && (_.radiusTopLeft = H), Z !== void 0 && (_.radiusTopRight = Z), $ !== void 0 && (_.radiusBottomRight = $), Y !== void 0 && (_.radiusBottomLeft = Y);
|
|
5217
|
+
const It = (Et = o.textCaseRaw) != null ? Et : (Xt = o.text) != null ? Xt : "", ut = !!o.uppercase, ft = u !== void 0, rt = ft ? u != null ? u : "" : It, Ct = A != null ? A : ut, Wt = Ct !== ut;
|
|
5098
5218
|
if (ft || Wt) {
|
|
5099
|
-
const q =
|
|
5100
|
-
|
|
5101
|
-
} else o.textCaseRaw === void 0 && (o.textCaseRaw =
|
|
5102
|
-
o.uppercase =
|
|
5219
|
+
const q = Ct ? ye({ value: rt }) : rt;
|
|
5220
|
+
_.text = q, o.textCaseRaw = rt;
|
|
5221
|
+
} else o.textCaseRaw === void 0 && (o.textCaseRaw = It);
|
|
5222
|
+
o.uppercase = Ct, o.set(_);
|
|
5103
5223
|
let yt = !1;
|
|
5104
5224
|
if (O) {
|
|
5105
|
-
const q =
|
|
5225
|
+
const q = me({ textbox: o, styles: X, range: O }), Ot = it ? me({ textbox: o, styles: V, range: it }) : !1;
|
|
5106
5226
|
yt = q || Ot;
|
|
5107
5227
|
} else if (Object.keys(k).length) {
|
|
5108
|
-
const q =
|
|
5109
|
-
q && (yt =
|
|
5228
|
+
const q = dn({ textbox: o });
|
|
5229
|
+
q && (yt = me({ textbox: o, styles: k, range: q }));
|
|
5110
5230
|
}
|
|
5111
|
-
const
|
|
5231
|
+
const te = yt && W._hasLayoutAffectingStyles({
|
|
5112
5232
|
stylesList: [
|
|
5113
5233
|
X,
|
|
5114
5234
|
V,
|
|
5115
5235
|
k
|
|
5116
5236
|
]
|
|
5117
5237
|
});
|
|
5118
|
-
yt && (o.dirty = !0),
|
|
5119
|
-
const vt =
|
|
5238
|
+
yt && (o.dirty = !0), te && (o.initDimensions(), o.dirty = !0), (b !== void 0 || C !== void 0 || E !== void 0 || x !== void 0 || N !== void 0 || B !== void 0 || H !== void 0 || Z !== void 0 || $ !== void 0 || Y !== void 0) && (o.dirty = !0);
|
|
5239
|
+
const vt = W._hasLayoutAffectingStyles({
|
|
5120
5240
|
stylesList: [
|
|
5121
|
-
|
|
5241
|
+
_,
|
|
5122
5242
|
X,
|
|
5123
5243
|
V,
|
|
5124
5244
|
k
|
|
5125
5245
|
]
|
|
5126
|
-
}), { autoExpand: Ut } = o, bt = f !== void 0,
|
|
5246
|
+
}), { autoExpand: Ut } = o, bt = f !== void 0, ee = (f != null ? f : Ut) !== !1;
|
|
5127
5247
|
bt ? o.autoExpand = f !== !1 : Ut === void 0 && (o.autoExpand = !0);
|
|
5128
|
-
const
|
|
5129
|
-
let
|
|
5130
|
-
|
|
5248
|
+
const se = Object.prototype.hasOwnProperty.call(_, "width"), ne = ee && !se && (ft || Wt || vt);
|
|
5249
|
+
let Tt = !1;
|
|
5250
|
+
ne && (Tt = this._autoExpandTextboxWidth(o, {
|
|
5131
5251
|
anchor: l
|
|
5132
|
-
}),
|
|
5133
|
-
const
|
|
5252
|
+
}), Tt && (o.dirty = !0)), (Tt ? !1 : W._roundTextboxDimensions({ textbox: o })) && (o.dirty = !0), o.setCoords(), n || a.requestRenderAll(), i.resumeHistory(), s || i.saveState();
|
|
5253
|
+
const oe = W._getSnapshot(o);
|
|
5134
5254
|
return a.fire("editor:text-updated", {
|
|
5135
5255
|
textbox: o,
|
|
5136
5256
|
target: t,
|
|
@@ -5139,9 +5259,9 @@ class P {
|
|
|
5139
5259
|
withoutSave: !!s,
|
|
5140
5260
|
skipRender: !!n
|
|
5141
5261
|
},
|
|
5142
|
-
updates:
|
|
5262
|
+
updates: _,
|
|
5143
5263
|
before: r,
|
|
5144
|
-
after:
|
|
5264
|
+
after: oe,
|
|
5145
5265
|
selectionRange: O != null ? O : void 0,
|
|
5146
5266
|
selectionStyles: O && Object.keys(X).length ? X : void 0
|
|
5147
5267
|
}), o;
|
|
@@ -5151,7 +5271,7 @@ class P {
|
|
|
5151
5271
|
*/
|
|
5152
5272
|
destroy() {
|
|
5153
5273
|
const { canvas: t } = this;
|
|
5154
|
-
t.off("object:scaling", this._handleObjectScaling), t.off("object:resizing",
|
|
5274
|
+
t.off("object:scaling", this._handleObjectScaling), t.off("object:resizing", W._handleObjectResizing), t.off("object:modified", this._handleObjectModified), t.off("text:editing:exited", this._handleTextEditingExited), t.off("text:editing:entered", this._handleTextEditingEntered), t.off("text:changed", this._handleTextChanged);
|
|
5155
5275
|
}
|
|
5156
5276
|
/**
|
|
5157
5277
|
* Возвращает активный текст или ищет по id.
|
|
@@ -5161,10 +5281,10 @@ class P {
|
|
|
5161
5281
|
const { canvas: e } = this;
|
|
5162
5282
|
if (!t) {
|
|
5163
5283
|
const s = e.getActiveObject();
|
|
5164
|
-
return
|
|
5284
|
+
return W._isTextbox(s) ? s : null;
|
|
5165
5285
|
}
|
|
5166
5286
|
if (typeof t == "string") {
|
|
5167
|
-
const s = e.getObjects().find((n) =>
|
|
5287
|
+
const s = e.getObjects().find((n) => W._isTextbox(n) && n.id === t);
|
|
5168
5288
|
return s != null ? s : null;
|
|
5169
5289
|
}
|
|
5170
5290
|
return null;
|
|
@@ -5180,22 +5300,22 @@ class P {
|
|
|
5180
5300
|
*/
|
|
5181
5301
|
_bindEvents() {
|
|
5182
5302
|
const { canvas: t } = this;
|
|
5183
|
-
t.on("object:scaling", this._handleObjectScaling), t.on("object:resizing",
|
|
5303
|
+
t.on("object:scaling", this._handleObjectScaling), t.on("object:resizing", W._handleObjectResizing), t.on("object:modified", this._handleObjectModified), t.on("text:editing:entered", this._handleTextEditingEntered), t.on("text:editing:exited", this._handleTextEditingExited), t.on("text:changed", this._handleTextChanged);
|
|
5184
5304
|
}
|
|
5185
5305
|
/**
|
|
5186
5306
|
* Автоматически увеличивает ширину текстового объекта до ширины текста,
|
|
5187
5307
|
* но не шире монтажной области, и удерживает объект в её пределах.
|
|
5188
5308
|
*/
|
|
5189
5309
|
_autoExpandTextboxWidth(t, { anchor: e } = {}) {
|
|
5190
|
-
var
|
|
5310
|
+
var I, w, T, b, C, E, x, N, B, H, Z, $, Y;
|
|
5191
5311
|
const { montageArea: s } = this.editor;
|
|
5192
5312
|
if (!s) return !1;
|
|
5193
5313
|
const n = typeof t.text == "string" ? t.text : "";
|
|
5194
5314
|
if (!n.length) return !1;
|
|
5195
5315
|
s.setCoords();
|
|
5196
|
-
const o = s.getBoundingRect(!1, !0), i = (
|
|
5316
|
+
const o = s.getBoundingRect(!1, !0), i = (I = o.width) != null ? I : 0;
|
|
5197
5317
|
if (!Number.isFinite(i) || i <= 0) return !1;
|
|
5198
|
-
const a = e != null ? e : (
|
|
5318
|
+
const a = e != null ? e : (w = this.editingAnchorState) == null ? void 0 : w.get(t), r = (b = (T = a == null ? void 0 : a.originY) != null ? T : t.originY) != null ? b : "top", c = Math.abs((C = t.scaleX) != null ? C : 1) || 1, d = (E = t.paddingLeft) != null ? E : 0, l = (x = t.paddingRight) != null ? x : 0, u = (N = t.strokeWidth) != null ? N : 0, f = Math.max(
|
|
5199
5319
|
1,
|
|
5200
5320
|
i / c - d - l - u
|
|
5201
5321
|
);
|
|
@@ -5203,16 +5323,16 @@ class P {
|
|
|
5203
5323
|
const g = n.split(`
|
|
5204
5324
|
`).length;
|
|
5205
5325
|
let p = !1;
|
|
5206
|
-
Math.abs(((
|
|
5207
|
-
const { textLines: m } = t, v = Array.isArray(m) && m.length > g,
|
|
5208
|
-
|
|
5326
|
+
Math.abs(((B = t.width) != null ? B : 0) - f) > tt && (t.set({ width: f }), p = !0), t.initDimensions();
|
|
5327
|
+
const { textLines: m } = t, v = Array.isArray(m) && m.length > g, S = Math.ceil(
|
|
5328
|
+
W._getLongestLineWidth({ textbox: t, text: n })
|
|
5209
5329
|
), A = Math.min((H = t.minWidth) != null ? H : 1, f);
|
|
5210
5330
|
let y = Math.min(
|
|
5211
5331
|
f,
|
|
5212
|
-
Math.max(
|
|
5332
|
+
Math.max(S, A)
|
|
5213
5333
|
);
|
|
5214
|
-
v && (y = f), Math.abs(((Z = t.width) != null ? Z : 0) - y) > tt && (t.set({ width: y }), t.initDimensions(), p = !0),
|
|
5215
|
-
const j =
|
|
5334
|
+
v && (y = f), Math.abs(((Z = t.width) != null ? Z : 0) - y) > tt && (t.set({ width: y }), t.initDimensions(), p = !0), W._roundTextboxDimensions({ textbox: t }) && (p = !0), a && (t.setPositionByOrigin(new et(a.x, a.y), "center", r), p = !0);
|
|
5335
|
+
const j = W._clampTextboxToMontage({
|
|
5216
5336
|
textbox: t,
|
|
5217
5337
|
montageLeft: ($ = o.left) != null ? $ : 0,
|
|
5218
5338
|
montageRight: ((Y = o.left) != null ? Y : 0) + i
|
|
@@ -5260,7 +5380,7 @@ class P {
|
|
|
5260
5380
|
static _handleObjectResizing(t) {
|
|
5261
5381
|
var l, u, f, g, p, m;
|
|
5262
5382
|
const { target: e, transform: s } = t;
|
|
5263
|
-
if (!
|
|
5383
|
+
if (!W._isTextbox(e)) return;
|
|
5264
5384
|
const {
|
|
5265
5385
|
paddingLeft: n = 0,
|
|
5266
5386
|
paddingRight: o = 0
|
|
@@ -5271,7 +5391,7 @@ class P {
|
|
|
5271
5391
|
e.set({ width: r });
|
|
5272
5392
|
const c = (u = e.width) != null ? u : 0, d = a - c;
|
|
5273
5393
|
if (d !== 0 && s && s.corner === "ml") {
|
|
5274
|
-
const
|
|
5394
|
+
const S = ((f = e.angle) != null ? f : 0) * Math.PI / 180, A = Math.cos(S), y = Math.sin(S), M = (g = e.scaleX) != null ? g : 1, j = d * M;
|
|
5275
5395
|
e.set({
|
|
5276
5396
|
left: ((p = e.left) != null ? p : 0) + j * A,
|
|
5277
5397
|
top: ((m = e.top) != null ? m : 0) + j * y
|
|
@@ -5306,7 +5426,7 @@ class P {
|
|
|
5306
5426
|
textbox: t,
|
|
5307
5427
|
range: e
|
|
5308
5428
|
}) {
|
|
5309
|
-
const s =
|
|
5429
|
+
const s = W._getLineRanges({ textbox: t });
|
|
5310
5430
|
if (!s.length) return e;
|
|
5311
5431
|
let { start: n } = e, { end: o } = e;
|
|
5312
5432
|
return s.forEach(({ start: i, end: a }) => {
|
|
@@ -5391,10 +5511,10 @@ class P {
|
|
|
5391
5511
|
static _roundTextboxDimensions({
|
|
5392
5512
|
textbox: t
|
|
5393
5513
|
}) {
|
|
5394
|
-
const { width: e, height: s, calcTextWidth: n, calcTextHeight: o } = t, i = typeof n == "function" ? n.call(t) : void 0, a = typeof o == "function" ? o.call(t) : void 0, r =
|
|
5514
|
+
const { width: e, height: s, calcTextWidth: n, calcTextHeight: o } = t, i = typeof n == "function" ? n.call(t) : void 0, a = typeof o == "function" ? o.call(t) : void 0, r = W._resolveDimension({
|
|
5395
5515
|
rawValue: e,
|
|
5396
5516
|
calculatedValue: i
|
|
5397
|
-
}), c =
|
|
5517
|
+
}), c = W._resolveDimension({
|
|
5398
5518
|
rawValue: s,
|
|
5399
5519
|
calculatedValue: a
|
|
5400
5520
|
}), d = Number.isFinite(r) ? Math.round(r) : null, l = Number.isFinite(c) ? Math.round(c) : null, u = {};
|
|
@@ -5405,11 +5525,11 @@ class P {
|
|
|
5405
5525
|
*/
|
|
5406
5526
|
static _getSnapshot(t) {
|
|
5407
5527
|
const e = ({
|
|
5408
|
-
snapshot:
|
|
5528
|
+
snapshot: _,
|
|
5409
5529
|
entries: O
|
|
5410
5530
|
}) => {
|
|
5411
5531
|
Object.entries(O).forEach(([it, X]) => {
|
|
5412
|
-
X != null && (
|
|
5532
|
+
X != null && (_[it] = X);
|
|
5413
5533
|
});
|
|
5414
5534
|
}, {
|
|
5415
5535
|
id: s,
|
|
@@ -5427,20 +5547,20 @@ class P {
|
|
|
5427
5547
|
fill: p,
|
|
5428
5548
|
stroke: m,
|
|
5429
5549
|
strokeWidth: v,
|
|
5430
|
-
opacity:
|
|
5550
|
+
opacity: S,
|
|
5431
5551
|
backgroundColor: A,
|
|
5432
5552
|
backgroundOpacity: y,
|
|
5433
5553
|
paddingTop: M,
|
|
5434
5554
|
paddingRight: j,
|
|
5435
|
-
paddingBottom:
|
|
5436
|
-
paddingLeft:
|
|
5437
|
-
radiusTopLeft:
|
|
5555
|
+
paddingBottom: I,
|
|
5556
|
+
paddingLeft: w,
|
|
5557
|
+
radiusTopLeft: T,
|
|
5438
5558
|
radiusTopRight: b,
|
|
5439
|
-
radiusBottomRight:
|
|
5440
|
-
radiusBottomLeft:
|
|
5441
|
-
left:
|
|
5442
|
-
top:
|
|
5443
|
-
width:
|
|
5559
|
+
radiusBottomRight: C,
|
|
5560
|
+
radiusBottomLeft: E,
|
|
5561
|
+
left: x,
|
|
5562
|
+
top: N,
|
|
5563
|
+
width: B,
|
|
5444
5564
|
height: H,
|
|
5445
5565
|
angle: Z,
|
|
5446
5566
|
scaleX: $,
|
|
@@ -5465,20 +5585,20 @@ class P {
|
|
|
5465
5585
|
fill: p,
|
|
5466
5586
|
stroke: m,
|
|
5467
5587
|
strokeWidth: v,
|
|
5468
|
-
opacity:
|
|
5588
|
+
opacity: S,
|
|
5469
5589
|
backgroundColor: A,
|
|
5470
5590
|
backgroundOpacity: y,
|
|
5471
5591
|
paddingTop: M,
|
|
5472
5592
|
paddingRight: j,
|
|
5473
|
-
paddingBottom:
|
|
5474
|
-
paddingLeft:
|
|
5475
|
-
radiusTopLeft:
|
|
5593
|
+
paddingBottom: I,
|
|
5594
|
+
paddingLeft: w,
|
|
5595
|
+
radiusTopLeft: T,
|
|
5476
5596
|
radiusTopRight: b,
|
|
5477
|
-
radiusBottomRight:
|
|
5478
|
-
radiusBottomLeft:
|
|
5479
|
-
left:
|
|
5480
|
-
top:
|
|
5481
|
-
width:
|
|
5597
|
+
radiusBottomRight: C,
|
|
5598
|
+
radiusBottomLeft: E,
|
|
5599
|
+
left: x,
|
|
5600
|
+
top: N,
|
|
5601
|
+
width: B,
|
|
5482
5602
|
height: H,
|
|
5483
5603
|
angle: Z,
|
|
5484
5604
|
scaleX: $,
|
|
@@ -5497,14 +5617,14 @@ class P {
|
|
|
5497
5617
|
const J = ({
|
|
5498
5618
|
value: h,
|
|
5499
5619
|
fallback: t = 0
|
|
5500
|
-
}) => typeof h == "number" && Number.isFinite(h) ? h : typeof t == "number" && Number.isFinite(t) ? t : 0,
|
|
5620
|
+
}) => typeof h == "number" && Number.isFinite(h) ? h : typeof t == "number" && Number.isFinite(t) ? t : 0, ce = ({
|
|
5501
5621
|
value: h,
|
|
5502
5622
|
dimension: t,
|
|
5503
5623
|
useRelativePositions: e
|
|
5504
5624
|
}) => {
|
|
5505
5625
|
const s = J({ value: h });
|
|
5506
5626
|
return e ? s : s / (t || 1);
|
|
5507
|
-
},
|
|
5627
|
+
}, hn = ({
|
|
5508
5628
|
object: h,
|
|
5509
5629
|
baseWidth: t,
|
|
5510
5630
|
baseHeight: e,
|
|
@@ -5514,22 +5634,22 @@ const J = ({
|
|
|
5514
5634
|
const o = h;
|
|
5515
5635
|
if (typeof o[n.x] == "number" && typeof o[n.y] == "number")
|
|
5516
5636
|
return {
|
|
5517
|
-
x:
|
|
5637
|
+
x: ce({
|
|
5518
5638
|
value: o[n.x],
|
|
5519
5639
|
dimension: t,
|
|
5520
5640
|
useRelativePositions: s
|
|
5521
5641
|
}),
|
|
5522
|
-
y:
|
|
5642
|
+
y: ce({
|
|
5523
5643
|
value: o[n.y],
|
|
5524
5644
|
dimension: e,
|
|
5525
5645
|
useRelativePositions: s
|
|
5526
5646
|
})
|
|
5527
5647
|
};
|
|
5528
|
-
const { left: a, top: r, width: c, height: d } = h, l =
|
|
5648
|
+
const { left: a, top: r, width: c, height: d } = h, l = ce({
|
|
5529
5649
|
value: a,
|
|
5530
5650
|
dimension: t,
|
|
5531
5651
|
useRelativePositions: s
|
|
5532
|
-
}), u =
|
|
5652
|
+
}), u = ce({
|
|
5533
5653
|
value: r,
|
|
5534
5654
|
dimension: e,
|
|
5535
5655
|
useRelativePositions: s
|
|
@@ -5538,7 +5658,7 @@ const J = ({
|
|
|
5538
5658
|
x: l + f / 2,
|
|
5539
5659
|
y: u + g / 2
|
|
5540
5660
|
};
|
|
5541
|
-
},
|
|
5661
|
+
}, un = ({
|
|
5542
5662
|
normalizedX: h,
|
|
5543
5663
|
normalizedY: t,
|
|
5544
5664
|
bounds: e,
|
|
@@ -5552,7 +5672,7 @@ const J = ({
|
|
|
5552
5672
|
}
|
|
5553
5673
|
const c = o + h * a, d = i + t * r;
|
|
5554
5674
|
return new et(c, d);
|
|
5555
|
-
},
|
|
5675
|
+
}, fn = ({
|
|
5556
5676
|
object: h,
|
|
5557
5677
|
montageArea: t,
|
|
5558
5678
|
bounds: e
|
|
@@ -5590,12 +5710,12 @@ const J = ({
|
|
|
5590
5710
|
} catch (t) {
|
|
5591
5711
|
return null;
|
|
5592
5712
|
}
|
|
5593
|
-
},
|
|
5713
|
+
}, gn = ({
|
|
5594
5714
|
x1: h,
|
|
5595
5715
|
y1: t,
|
|
5596
5716
|
x2: e,
|
|
5597
5717
|
y2: s
|
|
5598
|
-
}) => (Math.atan2(s - t, e - h) * 180 / Math.PI + 360) % 360,
|
|
5718
|
+
}) => (Math.atan2(s - t, e - h) * 180 / Math.PI + 360) % 360, pn = (h) => {
|
|
5599
5719
|
if (!h || typeof h != "object") return null;
|
|
5600
5720
|
const { type: t, coords: e, colorStops: s } = h, n = Array.isArray(s) ? s : [], o = n[0], i = n[n.length - 1], a = typeof (o == null ? void 0 : o.color) == "string" ? o.color : void 0, r = typeof (i == null ? void 0 : i.color) == "string" ? i.color : a, c = typeof (o == null ? void 0 : o.offset) == "number" ? o.offset * 100 : void 0, d = typeof (i == null ? void 0 : i.offset) == "number" ? i.offset * 100 : void 0, l = n.map((u) => ({
|
|
5601
5721
|
color: typeof u.color == "string" ? u.color : "#000000",
|
|
@@ -5607,7 +5727,7 @@ const J = ({
|
|
|
5607
5727
|
if (typeof u == "number" && typeof f == "number" && typeof g == "number" && typeof p == "number")
|
|
5608
5728
|
return {
|
|
5609
5729
|
type: "linear",
|
|
5610
|
-
angle:
|
|
5730
|
+
angle: gn({ x1: u, y1: f, x2: g, y2: p }),
|
|
5611
5731
|
startColor: a,
|
|
5612
5732
|
endColor: r,
|
|
5613
5733
|
startPosition: c,
|
|
@@ -5631,8 +5751,8 @@ const J = ({
|
|
|
5631
5751
|
};
|
|
5632
5752
|
}
|
|
5633
5753
|
return null;
|
|
5634
|
-
}, Qt = "_templateCenterX",
|
|
5635
|
-
class
|
|
5754
|
+
}, Qt = "_templateCenterX", ve = "_templateCenterY", de = "_templateAnchorX", be = "_templateAnchorY";
|
|
5755
|
+
class R {
|
|
5636
5756
|
constructor({ editor: t }) {
|
|
5637
5757
|
this.editor = t;
|
|
5638
5758
|
}
|
|
@@ -5651,21 +5771,21 @@ class x {
|
|
|
5651
5771
|
montageArea: i,
|
|
5652
5772
|
errorManager: a,
|
|
5653
5773
|
backgroundManager: r
|
|
5654
|
-
} = this.editor, c = o.getActiveObject(), d =
|
|
5774
|
+
} = this.editor, c = o.getActiveObject(), d = R._collectObjects(c), { backgroundObject: l } = r != null ? r : {}, u = n && l ? [l] : [], f = [...d, ...u];
|
|
5655
5775
|
if (!f.length)
|
|
5656
5776
|
return a.emitWarning({
|
|
5657
5777
|
origin: "TemplateManager",
|
|
5658
5778
|
method: "serializeSelection",
|
|
5659
|
-
code:
|
|
5779
|
+
code: wt.TEMPLATE_MANAGER.NO_OBJECTS_SELECTED,
|
|
5660
5780
|
message: "Нет объектов для сериализации шаблона"
|
|
5661
5781
|
}), null;
|
|
5662
|
-
const g =
|
|
5782
|
+
const g = R._getBounds(i), p = R._getMontageSize({ montageArea: i, bounds: g }), m = p.width, v = p.height, S = f.map((M) => R._serializeObject({
|
|
5663
5783
|
object: M,
|
|
5664
5784
|
bounds: g,
|
|
5665
5785
|
baseWidth: m,
|
|
5666
5786
|
baseHeight: v,
|
|
5667
5787
|
montageArea: i != null ? i : null
|
|
5668
|
-
})), A =
|
|
5788
|
+
})), A = St(P({}, s), {
|
|
5669
5789
|
baseWidth: m,
|
|
5670
5790
|
baseHeight: v,
|
|
5671
5791
|
positionsNormalized: !0,
|
|
@@ -5674,7 +5794,7 @@ class x {
|
|
|
5674
5794
|
return {
|
|
5675
5795
|
id: t != null ? t : `template-${K()}`,
|
|
5676
5796
|
meta: A,
|
|
5677
|
-
objects:
|
|
5797
|
+
objects: S
|
|
5678
5798
|
};
|
|
5679
5799
|
}
|
|
5680
5800
|
/**
|
|
@@ -5684,7 +5804,7 @@ class x {
|
|
|
5684
5804
|
* @param options.data - данные для заполнения текстов по customData.templateField
|
|
5685
5805
|
*/
|
|
5686
5806
|
applyTemplate(s) {
|
|
5687
|
-
return
|
|
5807
|
+
return z(this, arguments, function* ({
|
|
5688
5808
|
template: t,
|
|
5689
5809
|
data: e
|
|
5690
5810
|
}) {
|
|
@@ -5699,40 +5819,40 @@ class x {
|
|
|
5699
5819
|
return a.emitWarning({
|
|
5700
5820
|
origin: "TemplateManager",
|
|
5701
5821
|
method: "applyTemplate",
|
|
5702
|
-
code:
|
|
5822
|
+
code: wt.TEMPLATE_MANAGER.INVALID_TEMPLATE,
|
|
5703
5823
|
message: "Шаблон не содержит объектов"
|
|
5704
5824
|
}), null;
|
|
5705
|
-
const u =
|
|
5825
|
+
const u = R._getBounds(o);
|
|
5706
5826
|
if (!u)
|
|
5707
5827
|
return a.emitWarning({
|
|
5708
5828
|
origin: "TemplateManager",
|
|
5709
5829
|
method: "applyTemplate",
|
|
5710
|
-
code:
|
|
5830
|
+
code: wt.TEMPLATE_MANAGER.INVALID_TARGET,
|
|
5711
5831
|
message: "Не удалось определить границы монтажной области"
|
|
5712
5832
|
}), null;
|
|
5713
|
-
const f =
|
|
5714
|
-
let v = !1,
|
|
5833
|
+
const f = R._getMontageSize({ montageArea: o, bounds: u }), g = R._normalizeMeta({ meta: d, fallback: f }), p = R._calculateScale({ meta: g, target: f }), m = !!g.positionsNormalized;
|
|
5834
|
+
let v = !1, S = !1;
|
|
5715
5835
|
i.suspendHistory();
|
|
5716
5836
|
try {
|
|
5717
|
-
const A = yield
|
|
5837
|
+
const A = yield R._enlivenObjects(c);
|
|
5718
5838
|
if (!A.length)
|
|
5719
5839
|
return a.emitWarning({
|
|
5720
5840
|
origin: "TemplateManager",
|
|
5721
5841
|
method: "applyTemplate",
|
|
5722
|
-
code:
|
|
5842
|
+
code: wt.TEMPLATE_MANAGER.INVALID_TEMPLATE,
|
|
5723
5843
|
message: "Не удалось создать объекты шаблона"
|
|
5724
5844
|
}), null;
|
|
5725
|
-
const { backgroundObject: y, contentObjects: M } =
|
|
5726
|
-
y && (
|
|
5845
|
+
const { backgroundObject: y, contentObjects: M } = R._extractBackgroundObject(A);
|
|
5846
|
+
y && (S = yield R._applyBackgroundFromObject({
|
|
5727
5847
|
backgroundObject: y,
|
|
5728
5848
|
backgroundManager: r,
|
|
5729
5849
|
errorManager: a
|
|
5730
5850
|
}));
|
|
5731
|
-
const j = M.map((
|
|
5732
|
-
object:
|
|
5851
|
+
const j = M.map((I) => (this._adaptTextboxWidth({
|
|
5852
|
+
object: I,
|
|
5733
5853
|
baseWidth: g.baseWidth
|
|
5734
|
-
}),
|
|
5735
|
-
object:
|
|
5854
|
+
}), R._transformObject({
|
|
5855
|
+
object: I,
|
|
5736
5856
|
scale: p,
|
|
5737
5857
|
bounds: u,
|
|
5738
5858
|
targetSize: f,
|
|
@@ -5740,11 +5860,11 @@ class x {
|
|
|
5740
5860
|
baseHeight: g.baseHeight,
|
|
5741
5861
|
montageArea: o,
|
|
5742
5862
|
useRelativePositions: m
|
|
5743
|
-
}),
|
|
5744
|
-
id: `${
|
|
5863
|
+
}), I.set({
|
|
5864
|
+
id: `${I.type}-${K()}`,
|
|
5745
5865
|
evented: !0
|
|
5746
|
-
}), n.add(
|
|
5747
|
-
return !j.length && !
|
|
5866
|
+
}), n.add(I), I));
|
|
5867
|
+
return !j.length && !S ? null : (v = j.length > 0 || S, j.length && R._activateObjects({ canvas: n, objects: j }), n.requestRenderAll(), n.fire("editor:template-applied", {
|
|
5748
5868
|
template: t,
|
|
5749
5869
|
objects: j,
|
|
5750
5870
|
bounds: u
|
|
@@ -5753,7 +5873,7 @@ class x {
|
|
|
5753
5873
|
return a.emitError({
|
|
5754
5874
|
origin: "TemplateManager",
|
|
5755
5875
|
method: "applyTemplate",
|
|
5756
|
-
code:
|
|
5876
|
+
code: wt.TEMPLATE_MANAGER.APPLY_FAILED,
|
|
5757
5877
|
message: "Ошибка применения шаблона",
|
|
5758
5878
|
data: {
|
|
5759
5879
|
templateId: l,
|
|
@@ -5793,15 +5913,15 @@ class x {
|
|
|
5793
5913
|
* Превращает plain-описание объектов в Fabric объекты.
|
|
5794
5914
|
*/
|
|
5795
5915
|
static _enlivenObjects(t) {
|
|
5796
|
-
return
|
|
5797
|
-
return (yield Promise.all(t.map((s) =>
|
|
5798
|
-
if (
|
|
5799
|
-
const i = yield
|
|
5916
|
+
return z(this, null, function* () {
|
|
5917
|
+
return (yield Promise.all(t.map((s) => z(null, null, function* () {
|
|
5918
|
+
if (R._hasSerializedSvgMarkup(s)) {
|
|
5919
|
+
const i = yield R._reviveSvgObject(s);
|
|
5800
5920
|
if (i)
|
|
5801
|
-
return
|
|
5921
|
+
return R._restoreImageScale({ revived: i, serialized: s }), i;
|
|
5802
5922
|
}
|
|
5803
5923
|
const n = yield ht.enlivenObjects([s]), o = n == null ? void 0 : n[0];
|
|
5804
|
-
return o ? (
|
|
5924
|
+
return o ? (R._restoreImageScale({ revived: o, serialized: s }), o) : null;
|
|
5805
5925
|
})))).filter((s) => !!s);
|
|
5806
5926
|
});
|
|
5807
5927
|
}
|
|
@@ -5829,22 +5949,22 @@ class x {
|
|
|
5829
5949
|
naturalHeight: 0,
|
|
5830
5950
|
width: 0,
|
|
5831
5951
|
height: 0
|
|
5832
|
-
}, p = J({ value: l || f || c.width, fallback: 0 }), m = J({ value: u || g || c.height, fallback: 0 }), v = J({ value: n, fallback: p }),
|
|
5833
|
-
if (
|
|
5834
|
-
c.set(
|
|
5952
|
+
}, p = J({ value: l || f || c.width, fallback: 0 }), m = J({ value: u || g || c.height, fallback: 0 }), v = J({ value: n, fallback: p }), S = J({ value: o, fallback: m }), A = J({ value: i, fallback: c.scaleX || 1 }), y = J({ value: a, fallback: c.scaleY || 1 }), M = v * A, j = S * y, I = p > 0, w = m > 0, T = M > 0, b = j > 0, C = R._resolveImageFit({ customData: r }), E = {};
|
|
5953
|
+
if (I && (E.width = p), w && (E.height = m), !I || !w) {
|
|
5954
|
+
c.set(E);
|
|
5835
5955
|
return;
|
|
5836
5956
|
}
|
|
5837
|
-
if (
|
|
5838
|
-
const
|
|
5839
|
-
|
|
5957
|
+
if (C === "stretch") {
|
|
5958
|
+
const N = T ? M / p : null, B = b ? j / m : null;
|
|
5959
|
+
N && N > 0 && (E.scaleX = N), B && B > 0 && (E.scaleY = B), c.set(E);
|
|
5840
5960
|
return;
|
|
5841
5961
|
}
|
|
5842
|
-
if (!
|
|
5843
|
-
c.set(
|
|
5962
|
+
if (!T || !b) {
|
|
5963
|
+
c.set(E);
|
|
5844
5964
|
return;
|
|
5845
5965
|
}
|
|
5846
|
-
const
|
|
5847
|
-
Number.isFinite(
|
|
5966
|
+
const x = Math.min(M / p, j / m);
|
|
5967
|
+
Number.isFinite(x) && x > 0 && (E.scaleX = x, E.scaleY = x), c.set(E);
|
|
5848
5968
|
}
|
|
5849
5969
|
/**
|
|
5850
5970
|
* Определяет режим вписывания изображения при восстановлении.
|
|
@@ -5866,12 +5986,12 @@ class x {
|
|
|
5866
5986
|
* Восстанавливает SVG-объект из компактного описания.
|
|
5867
5987
|
*/
|
|
5868
5988
|
static _reviveSvgObject(t) {
|
|
5869
|
-
return
|
|
5989
|
+
return z(this, null, function* () {
|
|
5870
5990
|
const e = typeof t.svgMarkup == "string" ? t.svgMarkup : null;
|
|
5871
5991
|
if (!e) return null;
|
|
5872
5992
|
try {
|
|
5873
|
-
const s = yield
|
|
5874
|
-
|
|
5993
|
+
const s = yield vs(e), n = ht.groupSVGElements(s.objects, s.options), o = yield ht.enlivenObjectEnlivables(
|
|
5994
|
+
R._prepareSerializableProps(t)
|
|
5875
5995
|
);
|
|
5876
5996
|
return n.set(o), n.setCoords(), n;
|
|
5877
5997
|
} catch (s) {
|
|
@@ -5883,7 +6003,7 @@ class x {
|
|
|
5883
6003
|
* Убирает технические поля сериализации, оставляя только применимые свойства.
|
|
5884
6004
|
*/
|
|
5885
6005
|
static _prepareSerializableProps(t) {
|
|
5886
|
-
const e =
|
|
6006
|
+
const e = P({}, t);
|
|
5887
6007
|
return delete e.svgMarkup, delete e.objects, delete e.path, delete e.paths, delete e.type, delete e.version, e;
|
|
5888
6008
|
}
|
|
5889
6009
|
/**
|
|
@@ -5929,34 +6049,34 @@ class x {
|
|
|
5929
6049
|
montageArea: a,
|
|
5930
6050
|
useRelativePositions: r
|
|
5931
6051
|
}) {
|
|
5932
|
-
const c = t, { x: d, y: l } =
|
|
6052
|
+
const c = t, { x: d, y: l } = hn({
|
|
5933
6053
|
object: t,
|
|
5934
6054
|
baseWidth: o,
|
|
5935
6055
|
baseHeight: i,
|
|
5936
6056
|
useRelativePositions: r,
|
|
5937
6057
|
centerKeys: {
|
|
5938
6058
|
x: Qt,
|
|
5939
|
-
y:
|
|
6059
|
+
y: ve
|
|
5940
6060
|
}
|
|
5941
|
-
}), { scaleX: u, scaleY: f } = t, g = J({ value: u, fallback: 1 }), p = J({ value: f, fallback: 1 }), m =
|
|
6061
|
+
}), { scaleX: u, scaleY: f } = t, g = J({ value: u, fallback: 1 }), p = J({ value: f, fallback: 1 }), m = R._getPositioningBounds({
|
|
5942
6062
|
bounds: s,
|
|
5943
6063
|
baseWidth: o,
|
|
5944
6064
|
baseHeight: i,
|
|
5945
6065
|
scale: e,
|
|
5946
6066
|
useRelativePositions: r,
|
|
5947
|
-
anchorX:
|
|
5948
|
-
anchorY:
|
|
5949
|
-
}), v =
|
|
6067
|
+
anchorX: R._resolveAnchor(c, de),
|
|
6068
|
+
anchorY: R._resolveAnchor(c, be)
|
|
6069
|
+
}), v = un({
|
|
5950
6070
|
normalizedX: d,
|
|
5951
6071
|
normalizedY: l,
|
|
5952
6072
|
bounds: m,
|
|
5953
6073
|
targetSize: n,
|
|
5954
6074
|
montageArea: a
|
|
5955
|
-
}),
|
|
6075
|
+
}), S = g * e, A = p * e;
|
|
5956
6076
|
t.set({
|
|
5957
|
-
scaleX:
|
|
6077
|
+
scaleX: S,
|
|
5958
6078
|
scaleY: A
|
|
5959
|
-
}), t.setPositionByOrigin(v, "center", "center"), t.setCoords(), delete c[Qt], delete c[
|
|
6079
|
+
}), t.setPositionByOrigin(v, "center", "center"), t.setCoords(), delete c[Qt], delete c[ve], delete c[de], delete c[be];
|
|
5960
6080
|
}
|
|
5961
6081
|
/**
|
|
5962
6082
|
* Возвращает bounds, в которых должны позиционироваться нормализованные объекты.
|
|
@@ -5972,7 +6092,7 @@ class x {
|
|
|
5972
6092
|
anchorY: a
|
|
5973
6093
|
}) {
|
|
5974
6094
|
if (!o) return t;
|
|
5975
|
-
const r = (e || t.width) * n, c = (s || t.height) * n, d = t.width - r, l = t.height - c, u = t.left +
|
|
6095
|
+
const r = (e || t.width) * n, c = (s || t.height) * n, d = t.width - r, l = t.height - c, u = t.left + R._calculateAnchorOffset(i, d), f = t.top + R._calculateAnchorOffset(a, l);
|
|
5976
6096
|
return {
|
|
5977
6097
|
left: u,
|
|
5978
6098
|
top: f,
|
|
@@ -6004,7 +6124,7 @@ class x {
|
|
|
6004
6124
|
fallback: e
|
|
6005
6125
|
}) {
|
|
6006
6126
|
const { width: s, height: n } = e, r = t || {}, { baseWidth: o = s, baseHeight: i = n } = r, a = gt(r, ["baseWidth", "baseHeight"]);
|
|
6007
|
-
return
|
|
6127
|
+
return P({
|
|
6008
6128
|
baseWidth: o,
|
|
6009
6129
|
baseHeight: i
|
|
6010
6130
|
}, a);
|
|
@@ -6052,19 +6172,19 @@ class x {
|
|
|
6052
6172
|
width: o = 0,
|
|
6053
6173
|
scaleX: i = 1,
|
|
6054
6174
|
strokeWidth: a = 0
|
|
6055
|
-
} = t, r = J({ value: e, fallback: 0 }), c = t, d = J({ value: c.paddingLeft, fallback: 0 }), l = J({ value: c.paddingRight, fallback: 0 }), u = J({ value: i, fallback: 1 }), f = J({ value: a, fallback: 0 }) * u, g = J({ value: o, fallback: 0 }), p = g * u, m = d * u, v = l * u,
|
|
6175
|
+
} = t, r = J({ value: e, fallback: 0 }), c = t, d = J({ value: c.paddingLeft, fallback: 0 }), l = J({ value: c.paddingRight, fallback: 0 }), u = J({ value: i, fallback: 1 }), f = J({ value: a, fallback: 0 }) * u, g = J({ value: o, fallback: 0 }), p = g * u, m = d * u, v = l * u, S = p + m + v + f;
|
|
6056
6176
|
if (!n || !g || !r) return;
|
|
6057
6177
|
t.setCoords();
|
|
6058
|
-
const A = t, y = A[Qt], M = typeof y == "number" ? y : null, j =
|
|
6178
|
+
const A = t, y = A[Qt], M = typeof y == "number" ? y : null, j = R._resolveAnchor(A, de), I = S / r, w = M !== null ? M - I / 2 : null, T = M !== null ? M + I / 2 : null, b = t.getCenterPoint();
|
|
6059
6179
|
t.set("width", n), t.initDimensions();
|
|
6060
|
-
const
|
|
6180
|
+
const C = R._getLongestLineWidth({
|
|
6061
6181
|
textbox: t,
|
|
6062
6182
|
text: s
|
|
6063
|
-
}),
|
|
6064
|
-
t.set("width",
|
|
6065
|
-
const
|
|
6066
|
-
let
|
|
6067
|
-
j === "start" &&
|
|
6183
|
+
}), E = C > g ? C + 1 : g;
|
|
6184
|
+
t.set("width", E), t.initDimensions(), t.setPositionByOrigin(b, "center", "center"), t.setCoords();
|
|
6185
|
+
const N = (E * u + m + v + f) / r;
|
|
6186
|
+
let B = M;
|
|
6187
|
+
j === "start" && w !== null ? B = Math.max(0, w) + N / 2 : j === "end" && T !== null && (B = Math.min(1, T) - N / 2), typeof B == "number" && (A[Qt] = B);
|
|
6068
6188
|
}
|
|
6069
6189
|
/**
|
|
6070
6190
|
* Возвращает ширину самой длинной строки текстового объекта.
|
|
@@ -6094,9 +6214,9 @@ class x {
|
|
|
6094
6214
|
baseHeight: n,
|
|
6095
6215
|
montageArea: o
|
|
6096
6216
|
}) {
|
|
6097
|
-
const i = t.toDatalessObject([...
|
|
6098
|
-
if (
|
|
6099
|
-
const y =
|
|
6217
|
+
const i = t.toDatalessObject([...Ie]);
|
|
6218
|
+
if (R._isSvgObject(t)) {
|
|
6219
|
+
const y = R._extractSvgMarkup(t);
|
|
6100
6220
|
y && (i.svgMarkup = y, delete i.objects, delete i.path);
|
|
6101
6221
|
}
|
|
6102
6222
|
if (!e) return i;
|
|
@@ -6105,7 +6225,7 @@ class x {
|
|
|
6105
6225
|
top: r,
|
|
6106
6226
|
width: c,
|
|
6107
6227
|
height: d
|
|
6108
|
-
} = e, l = t.getBoundingRect(!1, !0), u = s || c || 1, f = n || d || 1, g =
|
|
6228
|
+
} = e, l = t.getBoundingRect(!1, !0), u = s || c || 1, f = n || d || 1, g = fn({
|
|
6109
6229
|
object: t,
|
|
6110
6230
|
montageArea: o,
|
|
6111
6231
|
bounds: e
|
|
@@ -6115,12 +6235,12 @@ class x {
|
|
|
6115
6235
|
x: (y.x - a) / u,
|
|
6116
6236
|
y: (y.y - r) / f
|
|
6117
6237
|
};
|
|
6118
|
-
})(), m = (l.left - a) / u, v = (l.top - r) / f,
|
|
6119
|
-
return i[Qt] = p.x, i[
|
|
6238
|
+
})(), m = (l.left - a) / u, v = (l.top - r) / f, S = m + l.width / u, A = v + l.height / f;
|
|
6239
|
+
return i[Qt] = p.x, i[ve] = p.y, i[de] = R._detectAnchor({
|
|
6120
6240
|
center: p.x,
|
|
6121
6241
|
start: m,
|
|
6122
|
-
end:
|
|
6123
|
-
}), i[
|
|
6242
|
+
end: S
|
|
6243
|
+
}), i[be] = R._detectAnchor({
|
|
6124
6244
|
center: p.y,
|
|
6125
6245
|
start: v,
|
|
6126
6246
|
end: A
|
|
@@ -6140,13 +6260,13 @@ class x {
|
|
|
6140
6260
|
* Применяет фоновый объект шаблона к текущему холсту через BackgroundManager.
|
|
6141
6261
|
*/
|
|
6142
6262
|
static _applyBackgroundFromObject(n) {
|
|
6143
|
-
return
|
|
6263
|
+
return z(this, arguments, function* ({
|
|
6144
6264
|
backgroundObject: t,
|
|
6145
6265
|
backgroundManager: e,
|
|
6146
6266
|
errorManager: s
|
|
6147
6267
|
}) {
|
|
6148
6268
|
try {
|
|
6149
|
-
const { fill: o, customData: i } = t, { backgroundType: a } = t, r =
|
|
6269
|
+
const { fill: o, customData: i } = t, { backgroundType: a } = t, r = R._cloneCustomData(i);
|
|
6150
6270
|
if (a === "color" && typeof o == "string")
|
|
6151
6271
|
return e.setColorBackground({
|
|
6152
6272
|
color: o,
|
|
@@ -6155,7 +6275,7 @@ class x {
|
|
|
6155
6275
|
withoutSave: !0
|
|
6156
6276
|
}), !0;
|
|
6157
6277
|
if (a === "gradient") {
|
|
6158
|
-
const c =
|
|
6278
|
+
const c = pn(o);
|
|
6159
6279
|
if (c)
|
|
6160
6280
|
return e.setGradientBackground({
|
|
6161
6281
|
gradient: c,
|
|
@@ -6165,7 +6285,7 @@ class x {
|
|
|
6165
6285
|
}), !0;
|
|
6166
6286
|
}
|
|
6167
6287
|
if (a === "image") {
|
|
6168
|
-
const c =
|
|
6288
|
+
const c = R._getImageSource(t);
|
|
6169
6289
|
if (c)
|
|
6170
6290
|
return yield e.setImageBackground({
|
|
6171
6291
|
imageSource: c,
|
|
@@ -6178,7 +6298,7 @@ class x {
|
|
|
6178
6298
|
s.emitWarning({
|
|
6179
6299
|
origin: "TemplateManager",
|
|
6180
6300
|
method: "applyTemplate",
|
|
6181
|
-
code:
|
|
6301
|
+
code: wt.TEMPLATE_MANAGER.APPLY_FAILED,
|
|
6182
6302
|
message: "Не удалось применить фон из шаблона",
|
|
6183
6303
|
data: o
|
|
6184
6304
|
});
|
|
@@ -6208,7 +6328,7 @@ class x {
|
|
|
6208
6328
|
*/
|
|
6209
6329
|
static _cloneCustomData(t) {
|
|
6210
6330
|
if (!(!t || typeof t != "object"))
|
|
6211
|
-
return
|
|
6331
|
+
return P({}, t);
|
|
6212
6332
|
}
|
|
6213
6333
|
/**
|
|
6214
6334
|
* Извлекает src изображения из FabricImage или его исходного элемента.
|
|
@@ -6237,7 +6357,7 @@ class x {
|
|
|
6237
6357
|
return ht.enlivenObjectEnlivables(t);
|
|
6238
6358
|
}
|
|
6239
6359
|
}
|
|
6240
|
-
const
|
|
6360
|
+
const mn = 5, as = "#3D8BF4", Ce = 1, le = 1, ts = ({
|
|
6241
6361
|
anchors: h,
|
|
6242
6362
|
positions: t,
|
|
6243
6363
|
threshold: e
|
|
@@ -6252,16 +6372,16 @@ const pn = 5, is = "#3D8BF4", Ie = 1, he = 1, Qe = ({
|
|
|
6252
6372
|
delta: s,
|
|
6253
6373
|
guidePosition: o
|
|
6254
6374
|
};
|
|
6255
|
-
},
|
|
6375
|
+
}, yn = ({
|
|
6256
6376
|
activeBounds: h,
|
|
6257
6377
|
threshold: t,
|
|
6258
6378
|
anchors: e
|
|
6259
6379
|
}) => {
|
|
6260
|
-
const { left: s, right: n, centerX: o, top: i, bottom: a, centerY: r } = h, c =
|
|
6380
|
+
const { left: s, right: n, centerX: o, top: i, bottom: a, centerY: r } = h, c = ts({
|
|
6261
6381
|
anchors: e.vertical,
|
|
6262
6382
|
positions: [s, o, n],
|
|
6263
6383
|
threshold: t
|
|
6264
|
-
}), d =
|
|
6384
|
+
}), d = ts({
|
|
6265
6385
|
anchors: e.horizontal,
|
|
6266
6386
|
positions: [i, r, a],
|
|
6267
6387
|
threshold: t
|
|
@@ -6277,7 +6397,7 @@ const pn = 5, is = "#3D8BF4", Ie = 1, he = 1, Qe = ({
|
|
|
6277
6397
|
deltaY: d.delta,
|
|
6278
6398
|
guides: l
|
|
6279
6399
|
};
|
|
6280
|
-
},
|
|
6400
|
+
}, rs = ({
|
|
6281
6401
|
activeBounds: h,
|
|
6282
6402
|
aligned: t,
|
|
6283
6403
|
threshold: e,
|
|
@@ -6349,7 +6469,7 @@ const pn = 5, is = "#3D8BF4", Ie = 1, he = 1, Qe = ({
|
|
|
6349
6469
|
}
|
|
6350
6470
|
}
|
|
6351
6471
|
return c;
|
|
6352
|
-
},
|
|
6472
|
+
}, vn = ({
|
|
6353
6473
|
activeBounds: h,
|
|
6354
6474
|
candidates: t,
|
|
6355
6475
|
threshold: e,
|
|
@@ -6374,9 +6494,9 @@ const pn = 5, is = "#3D8BF4", Ie = 1, he = 1, Qe = ({
|
|
|
6374
6494
|
return { delta: 0, guide: null };
|
|
6375
6495
|
const u = d[l - 1], f = d[l - 2], g = d[l + 1], p = d[l + 2], m = [], v = i - o;
|
|
6376
6496
|
if (u && f) {
|
|
6377
|
-
const { bounds: y } = u, { bounds: M } = f, j = y.top - M.bottom,
|
|
6378
|
-
if (
|
|
6379
|
-
const
|
|
6497
|
+
const { bounds: y } = u, { bounds: M } = f, j = y.top - M.bottom, I = o - y.bottom, w = Math.abs(I - j);
|
|
6498
|
+
if (w <= e) {
|
|
6499
|
+
const T = j - I, b = o + T, C = {
|
|
6380
6500
|
type: "vertical",
|
|
6381
6501
|
axis: n,
|
|
6382
6502
|
refStart: M.bottom,
|
|
@@ -6385,13 +6505,13 @@ const pn = 5, is = "#3D8BF4", Ie = 1, he = 1, Qe = ({
|
|
|
6385
6505
|
activeEnd: b,
|
|
6386
6506
|
distance: j
|
|
6387
6507
|
};
|
|
6388
|
-
m.push({ delta:
|
|
6508
|
+
m.push({ delta: T, guide: C, diff: w });
|
|
6389
6509
|
}
|
|
6390
6510
|
}
|
|
6391
6511
|
if (g && p) {
|
|
6392
|
-
const { bounds: y } = g, { bounds: M } = p, j = M.top - y.bottom,
|
|
6393
|
-
if (
|
|
6394
|
-
const
|
|
6512
|
+
const { bounds: y } = g, { bounds: M } = p, j = M.top - y.bottom, I = y.top - i, w = Math.abs(I - j);
|
|
6513
|
+
if (w <= e) {
|
|
6514
|
+
const T = I - j, b = i + T, C = {
|
|
6395
6515
|
type: "vertical",
|
|
6396
6516
|
axis: n,
|
|
6397
6517
|
refStart: y.bottom,
|
|
@@ -6400,42 +6520,42 @@ const pn = 5, is = "#3D8BF4", Ie = 1, he = 1, Qe = ({
|
|
|
6400
6520
|
activeEnd: y.top,
|
|
6401
6521
|
distance: j
|
|
6402
6522
|
};
|
|
6403
|
-
m.push({ delta:
|
|
6523
|
+
m.push({ delta: T, guide: C, diff: w });
|
|
6404
6524
|
}
|
|
6405
6525
|
}
|
|
6406
6526
|
if (u && g) {
|
|
6407
|
-
const { bounds: y } = u, { bounds: M } = g,
|
|
6408
|
-
if (
|
|
6409
|
-
const
|
|
6410
|
-
if (
|
|
6411
|
-
const
|
|
6527
|
+
const { bounds: y } = u, { bounds: M } = g, I = M.top - y.bottom - v;
|
|
6528
|
+
if (I >= 0) {
|
|
6529
|
+
const w = I / 2, T = o - y.bottom, b = M.top - i, C = Math.abs(T - w), E = Math.abs(b - w), x = Math.max(C, E);
|
|
6530
|
+
if (x <= e) {
|
|
6531
|
+
const N = w - T, B = i + N, H = {
|
|
6412
6532
|
type: "vertical",
|
|
6413
6533
|
axis: n,
|
|
6414
6534
|
refStart: y.bottom,
|
|
6415
|
-
refEnd: y.bottom +
|
|
6416
|
-
activeStart:
|
|
6417
|
-
activeEnd:
|
|
6418
|
-
distance:
|
|
6535
|
+
refEnd: y.bottom + w,
|
|
6536
|
+
activeStart: B,
|
|
6537
|
+
activeEnd: B + w,
|
|
6538
|
+
distance: w
|
|
6419
6539
|
};
|
|
6420
|
-
m.push({ delta:
|
|
6540
|
+
m.push({ delta: N, guide: H, diff: x });
|
|
6421
6541
|
}
|
|
6422
6542
|
}
|
|
6423
6543
|
}
|
|
6424
|
-
const
|
|
6544
|
+
const S = rs({
|
|
6425
6545
|
activeBounds: h,
|
|
6426
6546
|
aligned: c,
|
|
6427
6547
|
threshold: e,
|
|
6428
6548
|
patterns: s,
|
|
6429
6549
|
type: "vertical"
|
|
6430
6550
|
});
|
|
6431
|
-
if (m.push(...
|
|
6551
|
+
if (m.push(...S), !m.length)
|
|
6432
6552
|
return { delta: 0, guide: null };
|
|
6433
6553
|
const A = m.reduce((y, M) => M.diff < y.diff ? M : y, m[0]);
|
|
6434
6554
|
return {
|
|
6435
6555
|
delta: A.delta,
|
|
6436
6556
|
guide: A.guide
|
|
6437
6557
|
};
|
|
6438
|
-
},
|
|
6558
|
+
}, bn = ({
|
|
6439
6559
|
activeBounds: h,
|
|
6440
6560
|
candidates: t,
|
|
6441
6561
|
threshold: e,
|
|
@@ -6460,9 +6580,9 @@ const pn = 5, is = "#3D8BF4", Ie = 1, he = 1, Qe = ({
|
|
|
6460
6580
|
return { delta: 0, guide: null };
|
|
6461
6581
|
const u = d[l - 1], f = d[l - 2], g = d[l + 1], p = d[l + 2], m = [], v = i - o;
|
|
6462
6582
|
if (u && f) {
|
|
6463
|
-
const { bounds: y } = u, { bounds: M } = f, j = y.left - M.right,
|
|
6464
|
-
if (
|
|
6465
|
-
const
|
|
6583
|
+
const { bounds: y } = u, { bounds: M } = f, j = y.left - M.right, I = o - y.right, w = Math.abs(I - j);
|
|
6584
|
+
if (w <= e) {
|
|
6585
|
+
const T = j - I, b = o + T, C = {
|
|
6466
6586
|
type: "horizontal",
|
|
6467
6587
|
axis: n,
|
|
6468
6588
|
refStart: M.right,
|
|
@@ -6471,13 +6591,13 @@ const pn = 5, is = "#3D8BF4", Ie = 1, he = 1, Qe = ({
|
|
|
6471
6591
|
activeEnd: b,
|
|
6472
6592
|
distance: j
|
|
6473
6593
|
};
|
|
6474
|
-
m.push({ delta:
|
|
6594
|
+
m.push({ delta: T, guide: C, diff: w });
|
|
6475
6595
|
}
|
|
6476
6596
|
}
|
|
6477
6597
|
if (g && p) {
|
|
6478
|
-
const { bounds: y } = g, { bounds: M } = p, j = M.left - y.right,
|
|
6479
|
-
if (
|
|
6480
|
-
const
|
|
6598
|
+
const { bounds: y } = g, { bounds: M } = p, j = M.left - y.right, I = y.left - i, w = Math.abs(I - j);
|
|
6599
|
+
if (w <= e) {
|
|
6600
|
+
const T = I - j, b = i + T, C = {
|
|
6481
6601
|
type: "horizontal",
|
|
6482
6602
|
axis: n,
|
|
6483
6603
|
refStart: y.right,
|
|
@@ -6486,53 +6606,53 @@ const pn = 5, is = "#3D8BF4", Ie = 1, he = 1, Qe = ({
|
|
|
6486
6606
|
activeEnd: y.left,
|
|
6487
6607
|
distance: j
|
|
6488
6608
|
};
|
|
6489
|
-
m.push({ delta:
|
|
6609
|
+
m.push({ delta: T, guide: C, diff: w });
|
|
6490
6610
|
}
|
|
6491
6611
|
}
|
|
6492
6612
|
if (u && g) {
|
|
6493
|
-
const { bounds: y } = u, { bounds: M } = g,
|
|
6494
|
-
if (
|
|
6495
|
-
const
|
|
6496
|
-
if (
|
|
6497
|
-
const
|
|
6613
|
+
const { bounds: y } = u, { bounds: M } = g, I = M.left - y.right - v;
|
|
6614
|
+
if (I >= 0) {
|
|
6615
|
+
const w = I / 2, T = o - y.right, b = M.left - i, C = Math.abs(T - w), E = Math.abs(b - w), x = Math.max(C, E);
|
|
6616
|
+
if (x <= e) {
|
|
6617
|
+
const N = w - T, B = i + N, H = {
|
|
6498
6618
|
type: "horizontal",
|
|
6499
6619
|
axis: n,
|
|
6500
6620
|
refStart: y.right,
|
|
6501
|
-
refEnd: y.right +
|
|
6502
|
-
activeStart:
|
|
6503
|
-
activeEnd:
|
|
6504
|
-
distance:
|
|
6621
|
+
refEnd: y.right + w,
|
|
6622
|
+
activeStart: B,
|
|
6623
|
+
activeEnd: B + w,
|
|
6624
|
+
distance: w
|
|
6505
6625
|
};
|
|
6506
|
-
m.push({ delta:
|
|
6626
|
+
m.push({ delta: N, guide: H, diff: x });
|
|
6507
6627
|
}
|
|
6508
6628
|
}
|
|
6509
6629
|
}
|
|
6510
|
-
const
|
|
6630
|
+
const S = rs({
|
|
6511
6631
|
activeBounds: h,
|
|
6512
6632
|
aligned: c,
|
|
6513
6633
|
threshold: e,
|
|
6514
6634
|
patterns: s,
|
|
6515
6635
|
type: "horizontal"
|
|
6516
6636
|
});
|
|
6517
|
-
if (m.push(...
|
|
6637
|
+
if (m.push(...S), !m.length)
|
|
6518
6638
|
return { delta: 0, guide: null };
|
|
6519
6639
|
const A = m.reduce((y, M) => M.diff < y.diff ? M : y, m[0]);
|
|
6520
6640
|
return {
|
|
6521
6641
|
delta: A.delta,
|
|
6522
6642
|
guide: A.guide
|
|
6523
6643
|
};
|
|
6524
|
-
},
|
|
6644
|
+
}, Mn = ({
|
|
6525
6645
|
activeBounds: h,
|
|
6526
6646
|
candidates: t,
|
|
6527
6647
|
threshold: e,
|
|
6528
6648
|
spacingPatterns: s
|
|
6529
6649
|
}) => {
|
|
6530
|
-
const n =
|
|
6650
|
+
const n = vn({
|
|
6531
6651
|
activeBounds: h,
|
|
6532
6652
|
candidates: t,
|
|
6533
6653
|
threshold: e,
|
|
6534
6654
|
patterns: s.vertical
|
|
6535
|
-
}), o =
|
|
6655
|
+
}), o = bn({
|
|
6536
6656
|
activeBounds: h,
|
|
6537
6657
|
candidates: t,
|
|
6538
6658
|
threshold: e,
|
|
@@ -6543,7 +6663,7 @@ const pn = 5, is = "#3D8BF4", Ie = 1, he = 1, Qe = ({
|
|
|
6543
6663
|
deltaY: n.delta,
|
|
6544
6664
|
guides: i
|
|
6545
6665
|
};
|
|
6546
|
-
},
|
|
6666
|
+
}, Sn = ({
|
|
6547
6667
|
context: h,
|
|
6548
6668
|
x: t,
|
|
6549
6669
|
y: e,
|
|
@@ -6553,7 +6673,7 @@ const pn = 5, is = "#3D8BF4", Ie = 1, he = 1, Qe = ({
|
|
|
6553
6673
|
}) => {
|
|
6554
6674
|
const i = Math.min(o, s / 2, n / 2);
|
|
6555
6675
|
h.moveTo(t + i, e), h.lineTo(t + s - i, e), h.quadraticCurveTo(t + s, e, t + s, e + i), h.lineTo(t + s, e + n - i), h.quadraticCurveTo(t + s, e + n, t + s - i, e + n), h.lineTo(t + i, e + n), h.quadraticCurveTo(t, e + n, t, e + n - i), h.lineTo(t, e + i), h.quadraticCurveTo(t, e, t + i, e), h.closePath();
|
|
6556
|
-
},
|
|
6676
|
+
}, Te = ({
|
|
6557
6677
|
context: h,
|
|
6558
6678
|
type: t,
|
|
6559
6679
|
axis: e,
|
|
@@ -6570,16 +6690,16 @@ const pn = 5, is = "#3D8BF4", Ie = 1, he = 1, Qe = ({
|
|
|
6570
6690
|
offsetAlongAxis: f = 0,
|
|
6571
6691
|
offsetPerpendicular: g = 0
|
|
6572
6692
|
}) => {
|
|
6573
|
-
const p = i || 1, m = 12 / p, v = l / p,
|
|
6693
|
+
const p = i || 1, m = 12 / p, v = l / p, S = u / p, A = (s + n) / 2 + f, y = t === "vertical" ? e + g : A, M = t === "vertical" ? A : e + g;
|
|
6574
6694
|
h.save(), h.setLineDash([]), h.fillStyle = a, h.strokeStyle = a, h.lineWidth = d / p, h.font = `${m}px ${c}`, h.textAlign = "center", h.textBaseline = "middle";
|
|
6575
|
-
const
|
|
6576
|
-
h.beginPath(),
|
|
6695
|
+
const I = h.measureText(o).width + v * 2, w = m + v * 2, T = y - I / 2, b = M - w / 2;
|
|
6696
|
+
h.beginPath(), Sn({
|
|
6577
6697
|
context: h,
|
|
6578
|
-
x:
|
|
6698
|
+
x: T,
|
|
6579
6699
|
y: b,
|
|
6580
|
-
width:
|
|
6581
|
-
height:
|
|
6582
|
-
radius:
|
|
6700
|
+
width: I,
|
|
6701
|
+
height: w,
|
|
6702
|
+
radius: S
|
|
6583
6703
|
}), h.fill(), h.fillStyle = r, h.fillText(o, y, M), h.restore();
|
|
6584
6704
|
}, wn = ({
|
|
6585
6705
|
context: h,
|
|
@@ -6596,8 +6716,8 @@ const pn = 5, is = "#3D8BF4", Ie = 1, he = 1, Qe = ({
|
|
|
6596
6716
|
distance: c
|
|
6597
6717
|
} = t, d = Math.round(c).toString();
|
|
6598
6718
|
h.beginPath(), s === "vertical" ? (h.moveTo(n, o), h.lineTo(n, i), h.moveTo(n, a), h.lineTo(n, r)) : (h.moveTo(o, n), h.lineTo(i, n), h.moveTo(a, n), h.lineTo(r, n)), h.stroke();
|
|
6599
|
-
const l =
|
|
6600
|
-
|
|
6719
|
+
const l = as;
|
|
6720
|
+
Te({
|
|
6601
6721
|
context: h,
|
|
6602
6722
|
type: s,
|
|
6603
6723
|
axis: n,
|
|
@@ -6606,8 +6726,8 @@ const pn = 5, is = "#3D8BF4", Ie = 1, he = 1, Qe = ({
|
|
|
6606
6726
|
text: d,
|
|
6607
6727
|
zoom: e,
|
|
6608
6728
|
color: l,
|
|
6609
|
-
lineWidth:
|
|
6610
|
-
}),
|
|
6729
|
+
lineWidth: Ce
|
|
6730
|
+
}), Te({
|
|
6611
6731
|
context: h,
|
|
6612
6732
|
type: s,
|
|
6613
6733
|
axis: n,
|
|
@@ -6616,9 +6736,9 @@ const pn = 5, is = "#3D8BF4", Ie = 1, he = 1, Qe = ({
|
|
|
6616
6736
|
text: d,
|
|
6617
6737
|
zoom: e,
|
|
6618
6738
|
color: l,
|
|
6619
|
-
lineWidth:
|
|
6739
|
+
lineWidth: Ce
|
|
6620
6740
|
});
|
|
6621
|
-
},
|
|
6741
|
+
}, es = ({
|
|
6622
6742
|
anchors: h,
|
|
6623
6743
|
bounds: t
|
|
6624
6744
|
}) => {
|
|
@@ -6631,7 +6751,7 @@ const pn = 5, is = "#3D8BF4", Ie = 1, he = 1, Qe = ({
|
|
|
6631
6751
|
centerY: a
|
|
6632
6752
|
} = t;
|
|
6633
6753
|
h.vertical.push(e, n, s), h.horizontal.push(o, a, i);
|
|
6634
|
-
},
|
|
6754
|
+
}, ss = ({
|
|
6635
6755
|
bounds: h,
|
|
6636
6756
|
type: t,
|
|
6637
6757
|
primaryStart: e,
|
|
@@ -6644,8 +6764,8 @@ const pn = 5, is = "#3D8BF4", Ie = 1, he = 1, Qe = ({
|
|
|
6644
6764
|
for (let p = r + 1; p < a.length; p += 1) {
|
|
6645
6765
|
const m = a[p];
|
|
6646
6766
|
if (Math.min(c[i], m[i]) - Math.max(c[o], m[o]) < 0) continue;
|
|
6647
|
-
const
|
|
6648
|
-
|
|
6767
|
+
const S = m[e] - c[s];
|
|
6768
|
+
S < 0 || S < l && (l = S, d = m);
|
|
6649
6769
|
}
|
|
6650
6770
|
if (!d || l === Number.POSITIVE_INFINITY) continue;
|
|
6651
6771
|
const u = Math.max(c[o], d[o]), f = Math.min(c[i], d[i]), g = (u + f) / 2;
|
|
@@ -6658,30 +6778,30 @@ const pn = 5, is = "#3D8BF4", Ie = 1, he = 1, Qe = ({
|
|
|
6658
6778
|
});
|
|
6659
6779
|
}
|
|
6660
6780
|
return n;
|
|
6661
|
-
},
|
|
6781
|
+
}, An = ({
|
|
6662
6782
|
bounds: h
|
|
6663
6783
|
}) => {
|
|
6664
|
-
const t =
|
|
6784
|
+
const t = ss({
|
|
6665
6785
|
bounds: h,
|
|
6666
6786
|
type: "vertical",
|
|
6667
6787
|
primaryStart: "top",
|
|
6668
6788
|
primaryEnd: "bottom"
|
|
6669
|
-
}), e =
|
|
6789
|
+
}), e = ss({
|
|
6670
6790
|
bounds: h,
|
|
6671
6791
|
type: "horizontal",
|
|
6672
6792
|
primaryStart: "left",
|
|
6673
6793
|
primaryEnd: "right"
|
|
6674
6794
|
});
|
|
6675
6795
|
return { vertical: t, horizontal: e };
|
|
6676
|
-
},
|
|
6796
|
+
}, jn = ["montage-area", "background", "interaction-blocker"], cs = ({
|
|
6677
6797
|
activeObject: h
|
|
6678
6798
|
}) => {
|
|
6679
6799
|
const t = /* @__PURE__ */ new Set();
|
|
6680
6800
|
return h && (t.add(h), h instanceof F && h.getObjects().forEach((e) => t.add(e))), t;
|
|
6681
|
-
},
|
|
6801
|
+
}, ds = ({
|
|
6682
6802
|
object: h,
|
|
6683
6803
|
excluded: t,
|
|
6684
|
-
ignoredIds: e =
|
|
6804
|
+
ignoredIds: e = jn
|
|
6685
6805
|
}) => {
|
|
6686
6806
|
if (t.has(h)) return !0;
|
|
6687
6807
|
const { visible: s = !0 } = h;
|
|
@@ -6689,7 +6809,7 @@ const pn = 5, is = "#3D8BF4", Ie = 1, he = 1, Qe = ({
|
|
|
6689
6809
|
const { id: n } = h;
|
|
6690
6810
|
return !!(n && e.includes(n));
|
|
6691
6811
|
};
|
|
6692
|
-
class
|
|
6812
|
+
class In {
|
|
6693
6813
|
/**
|
|
6694
6814
|
* Создаёт менеджер прилипания и инициализирует слушатели событий.
|
|
6695
6815
|
*/
|
|
@@ -6752,29 +6872,29 @@ class jn {
|
|
|
6752
6872
|
this._clearGuides();
|
|
6753
6873
|
return;
|
|
6754
6874
|
}
|
|
6755
|
-
const { canvas: i } = this, a = i.getZoom() || 1, r =
|
|
6875
|
+
const { canvas: i } = this, a = i.getZoom() || 1, r = mn / a, c = yn({
|
|
6756
6876
|
activeBounds: o,
|
|
6757
6877
|
threshold: r,
|
|
6758
6878
|
anchors: this.anchors
|
|
6759
6879
|
}), { deltaX: d, deltaY: l, guides: u } = c;
|
|
6760
6880
|
if (d !== 0 || l !== 0) {
|
|
6761
|
-
const { left: v = 0, top:
|
|
6881
|
+
const { left: v = 0, top: S = 0 } = e;
|
|
6762
6882
|
e.set({
|
|
6763
6883
|
left: v + d,
|
|
6764
|
-
top:
|
|
6884
|
+
top: S + l
|
|
6765
6885
|
}), e.setCoords(), o = (p = mt({ object: e })) != null ? p : o;
|
|
6766
6886
|
}
|
|
6767
|
-
const f = this.cachedTargetBounds.length ? this.cachedTargetBounds : this._collectTargets({ activeObject: e }).map((v) => mt({ object: v })).filter((v) => !!v), g =
|
|
6887
|
+
const f = this.cachedTargetBounds.length ? this.cachedTargetBounds : this._collectTargets({ activeObject: e }).map((v) => mt({ object: v })).filter((v) => !!v), g = Mn({
|
|
6768
6888
|
activeBounds: o,
|
|
6769
6889
|
candidates: f,
|
|
6770
6890
|
threshold: r,
|
|
6771
6891
|
spacingPatterns: this.spacingPatterns
|
|
6772
6892
|
});
|
|
6773
6893
|
if (g.deltaX !== 0 || g.deltaY !== 0) {
|
|
6774
|
-
const { left: v = 0, top:
|
|
6894
|
+
const { left: v = 0, top: S = 0 } = e;
|
|
6775
6895
|
e.set({
|
|
6776
6896
|
left: v + g.deltaX,
|
|
6777
|
-
top:
|
|
6897
|
+
top: S + g.deltaY
|
|
6778
6898
|
}), e.setCoords(), o = (m = mt({ object: e })) != null ? m : o;
|
|
6779
6899
|
}
|
|
6780
6900
|
this._applyGuides({
|
|
@@ -6803,7 +6923,7 @@ class jn {
|
|
|
6803
6923
|
const { canvas: t, guideBounds: e } = this, s = t.getSelectionContext();
|
|
6804
6924
|
if (!s) return;
|
|
6805
6925
|
const n = e != null ? e : this._calculateViewportBounds(), { left: o, right: i, top: a, bottom: r } = n, { viewportTransform: c } = t, d = t.getZoom() || 1;
|
|
6806
|
-
s.save(), Array.isArray(c) && s.transform(...c), s.lineWidth =
|
|
6926
|
+
s.save(), Array.isArray(c) && s.transform(...c), s.lineWidth = Ce / d, s.strokeStyle = as, s.setLineDash([4, 4]);
|
|
6807
6927
|
for (const l of this.activeGuides)
|
|
6808
6928
|
s.beginPath(), l.type === "vertical" ? (s.moveTo(l.position, a), s.lineTo(l.position, r)) : (s.moveTo(o, l.position), s.lineTo(i, l.position)), s.stroke();
|
|
6809
6929
|
for (const l of this.activeSpacingGuides)
|
|
@@ -6843,7 +6963,7 @@ class jn {
|
|
|
6843
6963
|
* Применяет шаг перемещения, округляя координаты объекта к сетке MOVE_SNAP_STEP.
|
|
6844
6964
|
*/
|
|
6845
6965
|
_applyMovementStep({ target: t }) {
|
|
6846
|
-
const { left: e = 0, top: s = 0 } = t, n = Math.round(e /
|
|
6966
|
+
const { left: e = 0, top: s = 0 } = t, n = Math.round(e / le) * le, o = Math.round(s / le) * le;
|
|
6847
6967
|
n === e && o === s || (t.set({
|
|
6848
6968
|
left: n,
|
|
6849
6969
|
top: o
|
|
@@ -6856,11 +6976,11 @@ class jn {
|
|
|
6856
6976
|
const e = this._collectTargets({ activeObject: t }), s = { vertical: [], horizontal: [] }, n = [];
|
|
6857
6977
|
for (const a of e) {
|
|
6858
6978
|
const r = mt({ object: a });
|
|
6859
|
-
r && (
|
|
6979
|
+
r && (es({ anchors: s, bounds: r }), n.push(r));
|
|
6860
6980
|
}
|
|
6861
6981
|
const { montageArea: o } = this.editor, i = mt({ object: o });
|
|
6862
6982
|
if (i) {
|
|
6863
|
-
|
|
6983
|
+
es({ anchors: s, bounds: i });
|
|
6864
6984
|
const { left: a, right: r, top: c, bottom: d } = i;
|
|
6865
6985
|
this.guideBounds = {
|
|
6866
6986
|
left: a,
|
|
@@ -6870,15 +6990,15 @@ class jn {
|
|
|
6870
6990
|
};
|
|
6871
6991
|
} else
|
|
6872
6992
|
this.guideBounds = this._calculateViewportBounds();
|
|
6873
|
-
this.anchors = s, this.spacingPatterns =
|
|
6993
|
+
this.anchors = s, this.spacingPatterns = An({ bounds: n }), this.cachedTargetBounds = n;
|
|
6874
6994
|
}
|
|
6875
6995
|
/**
|
|
6876
6996
|
* Собирает объекты, подходящие для прилипания, исключая активный объект и запрещённые id.
|
|
6877
6997
|
*/
|
|
6878
6998
|
_collectTargets({ activeObject: t }) {
|
|
6879
|
-
const e =
|
|
6999
|
+
const e = cs({ activeObject: t }), s = [];
|
|
6880
7000
|
return this.canvas.forEachObject((n) => {
|
|
6881
|
-
|
|
7001
|
+
ds({ object: n, excluded: e }) || s.push(n);
|
|
6882
7002
|
}), s;
|
|
6883
7003
|
}
|
|
6884
7004
|
/**
|
|
@@ -6901,8 +7021,8 @@ class jn {
|
|
|
6901
7021
|
};
|
|
6902
7022
|
}
|
|
6903
7023
|
}
|
|
6904
|
-
const
|
|
6905
|
-
class
|
|
7024
|
+
const ns = "#3D8BF4", os = 1;
|
|
7025
|
+
class Bt {
|
|
6906
7026
|
/**
|
|
6907
7027
|
* Создаёт менеджер измерений и инициализирует события.
|
|
6908
7028
|
*/
|
|
@@ -7012,7 +7132,7 @@ class Nt {
|
|
|
7012
7132
|
this._clearGuides();
|
|
7013
7133
|
return;
|
|
7014
7134
|
}
|
|
7015
|
-
const i =
|
|
7135
|
+
const i = Bt._resolveTarget({
|
|
7016
7136
|
event: t,
|
|
7017
7137
|
activeObject: n
|
|
7018
7138
|
}), { montageArea: a } = s, r = i != null ? i : a, c = r === a, d = mt({ object: r });
|
|
@@ -7024,7 +7144,7 @@ class Nt {
|
|
|
7024
7144
|
this._clearGuides();
|
|
7025
7145
|
return;
|
|
7026
7146
|
}
|
|
7027
|
-
const u =
|
|
7147
|
+
const u = Bt._buildGuides({
|
|
7028
7148
|
activeBounds: o,
|
|
7029
7149
|
targetBounds: d,
|
|
7030
7150
|
targetIsMontageArea: c
|
|
@@ -7042,8 +7162,8 @@ class Nt {
|
|
|
7042
7162
|
event: t,
|
|
7043
7163
|
activeObject: e
|
|
7044
7164
|
}) {
|
|
7045
|
-
const { target: s } = t, n =
|
|
7046
|
-
return s && !
|
|
7165
|
+
const { target: s } = t, n = cs({ activeObject: e });
|
|
7166
|
+
return s && !ds({ object: s, excluded: n }) ? s : null;
|
|
7047
7167
|
}
|
|
7048
7168
|
/**
|
|
7049
7169
|
* Собирает вертикальные и горизонтальные направляющие расстояний.
|
|
@@ -7053,11 +7173,11 @@ class Nt {
|
|
|
7053
7173
|
targetBounds: e,
|
|
7054
7174
|
targetIsMontageArea: s
|
|
7055
7175
|
}) {
|
|
7056
|
-
const n =
|
|
7176
|
+
const n = Bt._buildHorizontalGuides({
|
|
7057
7177
|
activeBounds: t,
|
|
7058
7178
|
targetBounds: e,
|
|
7059
7179
|
targetIsMontageArea: s
|
|
7060
|
-
}), o =
|
|
7180
|
+
}), o = Bt._buildVerticalGuides({
|
|
7061
7181
|
activeBounds: t,
|
|
7062
7182
|
targetBounds: e,
|
|
7063
7183
|
targetIsMontageArea: s
|
|
@@ -7084,44 +7204,44 @@ class Nt {
|
|
|
7084
7204
|
top: u = 0,
|
|
7085
7205
|
bottom: f = 0,
|
|
7086
7206
|
centerY: g = 0
|
|
7087
|
-
} = e, p = Math.max(a, u), m = Math.min(r, f),
|
|
7207
|
+
} = e, p = Math.max(a, u), m = Math.min(r, f), S = m >= p ? (p + m) / 2 : (c + g) / 2;
|
|
7088
7208
|
if (d >= i) {
|
|
7089
7209
|
if (s) return n;
|
|
7090
|
-
const
|
|
7091
|
-
return
|
|
7210
|
+
const C = d - i;
|
|
7211
|
+
return C > 0 && n.push({
|
|
7092
7212
|
type: "horizontal",
|
|
7093
|
-
axis:
|
|
7213
|
+
axis: S,
|
|
7094
7214
|
start: i,
|
|
7095
7215
|
end: d,
|
|
7096
|
-
distance:
|
|
7216
|
+
distance: C
|
|
7097
7217
|
}), n;
|
|
7098
7218
|
}
|
|
7099
7219
|
if (l <= o) {
|
|
7100
7220
|
if (s) return n;
|
|
7101
|
-
const
|
|
7102
|
-
return
|
|
7221
|
+
const C = o - l;
|
|
7222
|
+
return C > 0 && n.push({
|
|
7103
7223
|
type: "horizontal",
|
|
7104
|
-
axis:
|
|
7224
|
+
axis: S,
|
|
7105
7225
|
start: l,
|
|
7106
7226
|
end: o,
|
|
7107
|
-
distance:
|
|
7227
|
+
distance: C
|
|
7108
7228
|
}), n;
|
|
7109
7229
|
}
|
|
7110
7230
|
if (!s) return n;
|
|
7111
|
-
const A = o < d, y = i > l, M = Math.min(o, d), j = Math.max(o, d),
|
|
7112
|
-
|
|
7231
|
+
const A = o < d, y = i > l, M = Math.min(o, d), j = Math.max(o, d), I = j - M;
|
|
7232
|
+
I > 0 && !A && n.push({
|
|
7113
7233
|
type: "horizontal",
|
|
7114
|
-
axis:
|
|
7234
|
+
axis: S,
|
|
7115
7235
|
start: M,
|
|
7116
7236
|
end: j,
|
|
7117
|
-
distance:
|
|
7237
|
+
distance: I
|
|
7118
7238
|
});
|
|
7119
|
-
const
|
|
7239
|
+
const w = Math.min(i, l), T = Math.max(i, l), b = T - w;
|
|
7120
7240
|
return b > 0 && !y && n.push({
|
|
7121
7241
|
type: "horizontal",
|
|
7122
|
-
axis:
|
|
7123
|
-
start:
|
|
7124
|
-
end:
|
|
7242
|
+
axis: S,
|
|
7243
|
+
start: w,
|
|
7244
|
+
end: T,
|
|
7125
7245
|
distance: b
|
|
7126
7246
|
}), n;
|
|
7127
7247
|
}
|
|
@@ -7145,44 +7265,44 @@ class Nt {
|
|
|
7145
7265
|
left: u = 0,
|
|
7146
7266
|
right: f = 0,
|
|
7147
7267
|
centerX: g = 0
|
|
7148
|
-
} = e, p = Math.max(a, u), m = Math.min(r, f),
|
|
7268
|
+
} = e, p = Math.max(a, u), m = Math.min(r, f), S = m >= p ? (p + m) / 2 : (c + g) / 2;
|
|
7149
7269
|
if (d >= i) {
|
|
7150
7270
|
if (s) return n;
|
|
7151
|
-
const
|
|
7152
|
-
return
|
|
7271
|
+
const C = d - i;
|
|
7272
|
+
return C > 0 && n.push({
|
|
7153
7273
|
type: "vertical",
|
|
7154
|
-
axis:
|
|
7274
|
+
axis: S,
|
|
7155
7275
|
start: i,
|
|
7156
7276
|
end: d,
|
|
7157
|
-
distance:
|
|
7277
|
+
distance: C
|
|
7158
7278
|
}), n;
|
|
7159
7279
|
}
|
|
7160
7280
|
if (l <= o) {
|
|
7161
7281
|
if (s) return n;
|
|
7162
|
-
const
|
|
7163
|
-
return
|
|
7282
|
+
const C = o - l;
|
|
7283
|
+
return C > 0 && n.push({
|
|
7164
7284
|
type: "vertical",
|
|
7165
|
-
axis:
|
|
7285
|
+
axis: S,
|
|
7166
7286
|
start: l,
|
|
7167
7287
|
end: o,
|
|
7168
|
-
distance:
|
|
7288
|
+
distance: C
|
|
7169
7289
|
}), n;
|
|
7170
7290
|
}
|
|
7171
7291
|
if (!s) return n;
|
|
7172
|
-
const A = o < d, y = i > l, M = Math.min(o, d), j = Math.max(o, d),
|
|
7173
|
-
|
|
7292
|
+
const A = o < d, y = i > l, M = Math.min(o, d), j = Math.max(o, d), I = j - M;
|
|
7293
|
+
I > 0 && !A && n.push({
|
|
7174
7294
|
type: "vertical",
|
|
7175
|
-
axis:
|
|
7295
|
+
axis: S,
|
|
7176
7296
|
start: M,
|
|
7177
7297
|
end: j,
|
|
7178
|
-
distance:
|
|
7298
|
+
distance: I
|
|
7179
7299
|
});
|
|
7180
|
-
const
|
|
7300
|
+
const w = Math.min(i, l), T = Math.max(i, l), b = T - w;
|
|
7181
7301
|
return b > 0 && !y && n.push({
|
|
7182
7302
|
type: "vertical",
|
|
7183
|
-
axis:
|
|
7184
|
-
start:
|
|
7185
|
-
end:
|
|
7303
|
+
axis: S,
|
|
7304
|
+
start: w,
|
|
7305
|
+
end: T,
|
|
7186
7306
|
distance: b
|
|
7187
7307
|
}), n;
|
|
7188
7308
|
}
|
|
@@ -7211,10 +7331,10 @@ class Nt {
|
|
|
7211
7331
|
const { canvas: t } = this, e = t.getSelectionContext();
|
|
7212
7332
|
if (!e) return;
|
|
7213
7333
|
const { viewportTransform: s } = t, n = t.getZoom() || 1, o = this.activeGuides.some((c) => c.type === "vertical"), i = this.activeGuides.some((c) => c.type === "horizontal"), a = o && i && !this.isTargetMontageArea, r = a ? 12 / n : 0;
|
|
7214
|
-
e.save(), Array.isArray(s) && e.transform(...s), e.lineWidth =
|
|
7334
|
+
e.save(), Array.isArray(s) && e.transform(...s), e.lineWidth = os / n, e.strokeStyle = ns, e.setLineDash([]);
|
|
7215
7335
|
for (const c of this.activeGuides) {
|
|
7216
|
-
const { type: d, axis: l, start: u, end: f, distance: g } = c, p = Math.abs(f - u), m = u <= f ? -1 : 1, v = a ? m * (p / 2 + r) : 0,
|
|
7217
|
-
e.beginPath(), d === "vertical" ? (e.moveTo(l, u), e.lineTo(l, f)) : (e.moveTo(u, l), e.lineTo(f, l)), e.stroke(),
|
|
7336
|
+
const { type: d, axis: l, start: u, end: f, distance: g } = c, p = Math.abs(f - u), m = u <= f ? -1 : 1, v = a ? m * (p / 2 + r) : 0, S = 0;
|
|
7337
|
+
e.beginPath(), d === "vertical" ? (e.moveTo(l, u), e.lineTo(l, f)) : (e.moveTo(u, l), e.lineTo(f, l)), e.stroke(), Te({
|
|
7218
7338
|
context: e,
|
|
7219
7339
|
type: d,
|
|
7220
7340
|
axis: l,
|
|
@@ -7222,10 +7342,10 @@ class Nt {
|
|
|
7222
7342
|
end: f,
|
|
7223
7343
|
text: Math.round(g).toString(),
|
|
7224
7344
|
zoom: n,
|
|
7225
|
-
color:
|
|
7226
|
-
lineWidth:
|
|
7345
|
+
color: ns,
|
|
7346
|
+
lineWidth: os,
|
|
7227
7347
|
offsetAlongAxis: v,
|
|
7228
|
-
offsetPerpendicular:
|
|
7348
|
+
offsetPerpendicular: S
|
|
7229
7349
|
});
|
|
7230
7350
|
}
|
|
7231
7351
|
e.restore();
|
|
@@ -7264,7 +7384,7 @@ class xe {
|
|
|
7264
7384
|
* @fires editor:ready
|
|
7265
7385
|
*/
|
|
7266
7386
|
init() {
|
|
7267
|
-
return
|
|
7387
|
+
return z(this, null, function* () {
|
|
7268
7388
|
var u;
|
|
7269
7389
|
const {
|
|
7270
7390
|
editorContainerWidth: t,
|
|
@@ -7279,7 +7399,7 @@ class xe {
|
|
|
7279
7399
|
showRotationAngle: d,
|
|
7280
7400
|
_onReadyCallback: l
|
|
7281
7401
|
} = this.options;
|
|
7282
|
-
if (ot.apply(), this.canvas = new
|
|
7402
|
+
if (ot.apply(), this.canvas = new bs(this.containerId, this.options), this.moduleLoader = new js(), this.workerManager = new Cs(), this.errorManager = new $t({ editor: this }), this.historyManager = new G({ editor: this }), this.toolbar = new Fs({ editor: this }), this.transformManager = new Qs({ editor: this }), this.zoomManager = new $s({ editor: this }), this.canvasManager = new Js({ editor: this }), this.imageManager = new lt({ editor: this }), this.layerManager = new ue({ editor: this }), this.shapeManager = new en({ editor: this }), this.interactionBlocker = new tn({ editor: this }), this.backgroundManager = new xt({ editor: this }), this.clipboardManager = new sn({ editor: this }), this.objectLockManager = new fe({ editor: this }), this.groupingManager = new nn({ editor: this }), this.selectionManager = new on({ editor: this }), this.deletionManager = new Re({ editor: this }), this.panConstraintManager = new an({ editor: this }), this.snappingManager = new In({ editor: this }), this.measurementManager = new Bt({ editor: this }), this.fontManager = new je((u = this.options.fonts) != null ? u : []), this.textManager = new W({ editor: this }), this.templateManager = new R({ editor: this }), d && (this.angleIndicator = new _e({ editor: this })), this._createMontageArea(), this._createClippingArea(), this.listeners = new Ee({ editor: this, options: this.options }), this.canvasManager.setEditorContainerWidth(t), this.canvasManager.setEditorContainerHeight(e), this.canvasManager.setCanvasWrapperWidth(s), this.canvasManager.setCanvasWrapperHeight(n), this.canvasManager.setCanvasCSSWidth(o), this.canvasManager.setCanvasCSSHeight(i), this.canvasManager.updateCanvas(), this.zoomManager.calculateAndApplyDefaultZoom(), yield this.fontManager.loadFonts(), a != null && a.source) {
|
|
7283
7403
|
const f = a, {
|
|
7284
7404
|
source: g,
|
|
7285
7405
|
scale: p = `image-${c}`,
|
|
@@ -7289,7 +7409,7 @@ class xe {
|
|
|
7289
7409
|
"scale",
|
|
7290
7410
|
"withoutSave"
|
|
7291
7411
|
]);
|
|
7292
|
-
yield this.imageManager.importImage(
|
|
7412
|
+
yield this.imageManager.importImage(P({ source: g, scale: p, withoutSave: m }, v));
|
|
7293
7413
|
}
|
|
7294
7414
|
r && this.historyManager.loadStateFromFullState(r), this.historyManager.saveState(), console.log("editor:ready"), this.canvas.fire("editor:ready", this), typeof l == "function" && l(this);
|
|
7295
7415
|
});
|
|
@@ -7356,7 +7476,7 @@ class xe {
|
|
|
7356
7476
|
const t = document.createElement("canvas");
|
|
7357
7477
|
t.width = 20, t.height = 20;
|
|
7358
7478
|
const e = t.getContext("2d");
|
|
7359
|
-
return e.fillStyle = "#ddd", e.fillRect(0, 0, 40, 40), e.fillStyle = "#ccc", e.fillRect(0, 0, 10, 10), e.fillRect(10, 10, 10, 10), new
|
|
7479
|
+
return e.fillStyle = "#ddd", e.fillRect(0, 0, 40, 40), e.fillStyle = "#ccc", e.fillRect(0, 0, 10, 10), e.fillRect(10, 10, 10, 10), new Ms({
|
|
7360
7480
|
source: t,
|
|
7361
7481
|
repeat: "repeat"
|
|
7362
7482
|
});
|
|
@@ -8191,7 +8311,7 @@ const L = [
|
|
|
8191
8311
|
unicodeRange: L
|
|
8192
8312
|
}
|
|
8193
8313
|
}
|
|
8194
|
-
],
|
|
8314
|
+
], Tn = {
|
|
8195
8315
|
/**
|
|
8196
8316
|
* Опции редактора
|
|
8197
8317
|
*/
|
|
@@ -8285,8 +8405,8 @@ const L = [
|
|
|
8285
8405
|
*/
|
|
8286
8406
|
fonts: Cn
|
|
8287
8407
|
};
|
|
8288
|
-
function
|
|
8289
|
-
const e =
|
|
8408
|
+
function _n(h, t = {}) {
|
|
8409
|
+
const e = P(P({}, Tn), t), s = document.getElementById(h);
|
|
8290
8410
|
if (!s)
|
|
8291
8411
|
return Promise.reject(new Error(`Контейнер с ID "${h}" не найден.`));
|
|
8292
8412
|
const n = document.createElement("canvas");
|
|
@@ -8297,6 +8417,6 @@ function Dn(h, t = {}) {
|
|
|
8297
8417
|
});
|
|
8298
8418
|
}
|
|
8299
8419
|
export {
|
|
8300
|
-
|
|
8420
|
+
_n as default
|
|
8301
8421
|
};
|
|
8302
8422
|
//# sourceMappingURL=main.js.map
|