@anu3ev/fabric-image-editor 0.5.33 → 0.5.34
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 +1023 -791
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
1
|
+
var On = Object.defineProperty, Tn = Object.defineProperties;
|
|
2
|
+
var En = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var le = Object.getOwnPropertySymbols;
|
|
4
|
+
var Ve = Object.prototype.hasOwnProperty, Xe = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var Ge = (h, t, e) => t in h ? On(h, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : h[t] = e, F = (h, t) => {
|
|
6
6
|
for (var e in t || (t = {}))
|
|
7
|
-
|
|
8
|
-
if (
|
|
9
|
-
for (var e of
|
|
10
|
-
|
|
7
|
+
Ve.call(t, e) && Ge(h, e, t[e]);
|
|
8
|
+
if (le)
|
|
9
|
+
for (var e of le(t))
|
|
10
|
+
Xe.call(t, e) && Ge(h, e, t[e]);
|
|
11
11
|
return h;
|
|
12
|
-
},
|
|
13
|
-
var
|
|
12
|
+
}, Et = (h, t) => Tn(h, En(t));
|
|
13
|
+
var Ct = (h, t) => {
|
|
14
14
|
var e = {};
|
|
15
15
|
for (var n in h)
|
|
16
|
-
|
|
17
|
-
if (h != null &&
|
|
18
|
-
for (var n of
|
|
19
|
-
t.indexOf(n) < 0 &&
|
|
16
|
+
Ve.call(h, n) && t.indexOf(n) < 0 && (e[n] = h[n]);
|
|
17
|
+
if (h != null && le)
|
|
18
|
+
for (var n of le(h))
|
|
19
|
+
t.indexOf(n) < 0 && Xe.call(h, n) && (e[n] = h[n]);
|
|
20
20
|
return e;
|
|
21
21
|
};
|
|
22
22
|
var G = (h, t, e) => new Promise((n, s) => {
|
|
@@ -35,16 +35,16 @@ var G = (h, t, e) => new Promise((n, s) => {
|
|
|
35
35
|
}, a = (r) => r.done ? n(r.value) : Promise.resolve(r.value).then(o, i);
|
|
36
36
|
a((e = e.apply(h, t)).next());
|
|
37
37
|
});
|
|
38
|
-
import { ActiveSelection as X, Textbox as ct, util as
|
|
39
|
-
import { create as
|
|
38
|
+
import { ActiveSelection as X, Textbox as ct, util as bt, controlsUtils as Ke, InteractiveFabricObject as qe, Point as lt, FitContentLayout as Je, loadSVGFromURL as _n, FabricImage as qt, Gradient as Qe, Rect as Ln, Circle as Dn, Triangle as xn, Group as Pt, Color as Rn, classRegistry as $e, loadSVGFromString as kn, Canvas as Bn, Pattern as Nn } from "fabric";
|
|
39
|
+
import { create as Pn } from "jsondiffpatch";
|
|
40
40
|
import zn from "diff-match-patch";
|
|
41
|
-
var
|
|
41
|
+
var Fn = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", et = function() {
|
|
42
42
|
for (var t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 21, e = "", n = crypto.getRandomValues(new Uint8Array(t |= 0)); t--; )
|
|
43
|
-
e +=
|
|
43
|
+
e += Fn[n[t] & 63];
|
|
44
44
|
return e;
|
|
45
45
|
};
|
|
46
|
-
const
|
|
47
|
-
class
|
|
46
|
+
const tn = 300;
|
|
47
|
+
class Ne {
|
|
48
48
|
/**
|
|
49
49
|
* Конструктор принимает редактор и опции.
|
|
50
50
|
* @param params
|
|
@@ -52,7 +52,6 @@ class Be {
|
|
|
52
52
|
* @param params.options — настройки редактора (см. defaults.js)
|
|
53
53
|
* @param params.options.canvasDragging — включить перетаскивание канваса
|
|
54
54
|
* @param params.options.mouseWheelZooming — включить зум колесом мыши
|
|
55
|
-
* @param params.options.bringToFrontOnSelection — поднимать объект на передний план при выборе
|
|
56
55
|
* @param params.options.copyObjectsByHotkey — копировать объекты по Ctrl+C
|
|
57
56
|
* @param params.options.pasteImageFromClipboard — вставлять изображения и объекты из буфера обмена
|
|
58
57
|
* @param params.options.undoRedoByHotKeys — отмена/повтор по Ctrl+Z/Ctrl+Y
|
|
@@ -62,7 +61,7 @@ class Be {
|
|
|
62
61
|
* @param params.options.adaptCanvasToContainerOnResize — адаптировать канвас к размерам контейнера при изменении размеров окна
|
|
63
62
|
*/
|
|
64
63
|
constructor({ editor: t, options: e = {} }) {
|
|
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.
|
|
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.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 = Ne.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.handleResetObjectFitBound = this.handleResetObjectFit.bind(this), this.init();
|
|
66
65
|
}
|
|
67
66
|
/**
|
|
68
67
|
* Инициализация всех обработчиков согласно опциям.
|
|
@@ -72,49 +71,14 @@ class Be {
|
|
|
72
71
|
adaptCanvasToContainerOnResize: t,
|
|
73
72
|
canvasDragging: e,
|
|
74
73
|
mouseWheelZooming: n,
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
resetObjectFitByDoubleClick: l
|
|
74
|
+
copyObjectsByHotkey: s,
|
|
75
|
+
pasteImageFromClipboard: o,
|
|
76
|
+
undoRedoByHotKeys: i,
|
|
77
|
+
selectAllByHotkey: a,
|
|
78
|
+
deleteObjectsByHotkey: r,
|
|
79
|
+
resetObjectFitByDoubleClick: c
|
|
82
80
|
} = this.options;
|
|
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 })), n && this.canvas.on("mouse:wheel", this.handleMouseWheelZoomBound),
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* При массовом выделении объектов удаляем из него залоченные.
|
|
87
|
-
* @param params - параметры события
|
|
88
|
-
* @param params.selected - массив выделенных объектов
|
|
89
|
-
* @param params.e - событие указателя (опционально)
|
|
90
|
-
*/
|
|
91
|
-
_filterLockedSelection({ selected: t, e }) {
|
|
92
|
-
if (!(t != null && t.length) || !(e instanceof MouseEvent) || t.length === 1) return;
|
|
93
|
-
const { lockedObjects: n, unlockedObjects: s } = t.reduce(
|
|
94
|
-
(i, a) => a.locked ? (i.lockedObjects.push(a), i) : (i.unlockedObjects.push(a), i),
|
|
95
|
-
{ lockedObjects: [], unlockedObjects: [] }
|
|
96
|
-
);
|
|
97
|
-
if (n.length === 0) return;
|
|
98
|
-
if (s.length > 0) {
|
|
99
|
-
if (s.length === 1)
|
|
100
|
-
this.canvas.setActiveObject(s[0]);
|
|
101
|
-
else {
|
|
102
|
-
const i = new X(s, {
|
|
103
|
-
canvas: this.canvas
|
|
104
|
-
});
|
|
105
|
-
this.canvas.setActiveObject(i);
|
|
106
|
-
}
|
|
107
|
-
this.canvas.requestRenderAll();
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
const o = new X(t, {
|
|
111
|
-
canvas: this.canvas
|
|
112
|
-
});
|
|
113
|
-
this.editor.objectLockManager.lockObject({
|
|
114
|
-
object: o,
|
|
115
|
-
skipInnerObjects: !0,
|
|
116
|
-
withoutSave: !0
|
|
117
|
-
}), this.canvas.setActiveObject(o), this.canvas.requestRenderAll();
|
|
81
|
+
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 })), n && this.canvas.on("mouse:wheel", this.handleMouseWheelZoomBound), c && this.canvas.on("mouse:dblclick", this.handleResetObjectFitBound), t && window.addEventListener("resize", this.handleContainerResizeBound, { capture: !0 }), s && document.addEventListener("keydown", this.handleCopyEventBound, { capture: !0 }), o && document.addEventListener("paste", this.handlePasteEventBound, { capture: !0 }), i && (document.addEventListener("keydown", this.handleUndoRedoEventBound, { capture: !0 }), document.addEventListener("keyup", this.handleUndoRedoKeyUpBound, { capture: !0 })), a && document.addEventListener("keydown", this.handleSelectAllEventBound, { capture: !0 }), r && 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("object:added", this.handleBackgroundUpdateBound), this.canvas.on("selection:created", this.handleBackgroundUpdateBound);
|
|
118
82
|
}
|
|
119
83
|
/**
|
|
120
84
|
* Обработчики для сохранения состояния редактора в истории.
|
|
@@ -123,14 +87,14 @@ class Be {
|
|
|
123
87
|
handleObjectModifiedHistory() {
|
|
124
88
|
const { historyManager: t, textManager: e } = this.editor;
|
|
125
89
|
t.skipHistory || e.isTextEditingActive || t.scheduleSaveState({
|
|
126
|
-
delayMs:
|
|
90
|
+
delayMs: tn,
|
|
127
91
|
reason: "object-modified"
|
|
128
92
|
});
|
|
129
93
|
}
|
|
130
94
|
handleObjectRotatingHistory() {
|
|
131
95
|
const { historyManager: t, textManager: e } = this.editor;
|
|
132
96
|
t.skipHistory || e.isTextEditingActive || t.scheduleSaveState({
|
|
133
|
-
delayMs:
|
|
97
|
+
delayMs: tn,
|
|
134
98
|
reason: "object-rotating"
|
|
135
99
|
});
|
|
136
100
|
}
|
|
@@ -354,23 +318,13 @@ class Be {
|
|
|
354
318
|
const e = this._calculateAdaptiveZoomStep(t.deltaY);
|
|
355
319
|
this.editor.zoomManager.handleMouseWheelZoom(e, t), t.preventDefault(), t.stopPropagation();
|
|
356
320
|
}
|
|
357
|
-
/**
|
|
358
|
-
* Обработчик, поднимающий выделенные объекты на передний план.
|
|
359
|
-
* @param event - объект события выделения
|
|
360
|
-
* @param event.selected - массив выбранных объектов
|
|
361
|
-
*/
|
|
362
|
-
handleBringToFront({ selected: t }) {
|
|
363
|
-
t != null && t.length && t.forEach((e) => {
|
|
364
|
-
this.editor.layerManager.bringToFront(e);
|
|
365
|
-
});
|
|
366
|
-
}
|
|
367
321
|
/**
|
|
368
322
|
* Обработчик сброса объекта по двойному клику.
|
|
369
323
|
* @param options - объект события fabric
|
|
370
324
|
*/
|
|
371
325
|
handleResetObjectFit(t) {
|
|
372
|
-
const
|
|
373
|
-
!e || e instanceof ct || this.editor.transformManager.resetObject({ object: e });
|
|
326
|
+
const { target: e, e: n } = t;
|
|
327
|
+
n && (n.ctrlKey || n.metaKey) || !e || e instanceof ct || this.editor.transformManager.resetObject({ object: e });
|
|
374
328
|
}
|
|
375
329
|
/**
|
|
376
330
|
* Проверяет, должно ли событие клавиатуры быть проигнорировано
|
|
@@ -414,7 +368,7 @@ class Be {
|
|
|
414
368
|
* Метод для удаления всех слушателей
|
|
415
369
|
*/
|
|
416
370
|
destroy() {
|
|
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.
|
|
371
|
+
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.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);
|
|
418
372
|
}
|
|
419
373
|
/**
|
|
420
374
|
* Дебаунс для снижения частоты вызова функции.
|
|
@@ -431,7 +385,7 @@ class Be {
|
|
|
431
385
|
};
|
|
432
386
|
}
|
|
433
387
|
}
|
|
434
|
-
class
|
|
388
|
+
class Wn {
|
|
435
389
|
/**
|
|
436
390
|
* Класс для динамической загрузки внешних модулей.
|
|
437
391
|
*/
|
|
@@ -449,7 +403,7 @@ class Fn {
|
|
|
449
403
|
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}"`));
|
|
450
404
|
}
|
|
451
405
|
}
|
|
452
|
-
function
|
|
406
|
+
function Un(h) {
|
|
453
407
|
return new Worker(
|
|
454
408
|
"" + new URL("assets/worker-2TM2HcqM.js", import.meta.url).href,
|
|
455
409
|
{
|
|
@@ -457,13 +411,13 @@ function Wn(h) {
|
|
|
457
411
|
}
|
|
458
412
|
);
|
|
459
413
|
}
|
|
460
|
-
class
|
|
414
|
+
class Yn {
|
|
461
415
|
/**
|
|
462
416
|
* @param scriptUrl — URL скрипта воркера.
|
|
463
417
|
* По-умолчанию использует DefaultWorker из соседнего файла
|
|
464
418
|
*/
|
|
465
419
|
constructor(t) {
|
|
466
|
-
t ? this.worker = new Worker(t, { type: "module" }) : this.worker = new
|
|
420
|
+
t ? this.worker = new Worker(t, { type: "module" }) : this.worker = new Un(), this._callbacks = /* @__PURE__ */ new Map(), this.worker.onmessage = this._handleMessage.bind(this);
|
|
467
421
|
}
|
|
468
422
|
/**
|
|
469
423
|
* Обработчик сообщений от воркера
|
|
@@ -503,92 +457,92 @@ class Un {
|
|
|
503
457
|
this.worker.terminate();
|
|
504
458
|
}
|
|
505
459
|
}
|
|
506
|
-
const
|
|
507
|
-
function
|
|
508
|
-
const o =
|
|
509
|
-
h.save(), h.translate(t, e), h.rotate(
|
|
510
|
-
}
|
|
511
|
-
function tn(h, t, e, n, s) {
|
|
512
|
-
const o = Ie, i = Te, a = Hn;
|
|
513
|
-
h.save(), h.translate(t, e), h.rotate(vt.degreesToRadians(s.angle)), h.fillStyle = Pe, h.strokeStyle = ze, h.lineWidth = Ne, h.beginPath(), h.roundRect(-o / 2, -i / 2, o, i, a), h.fill(), h.stroke(), h.restore();
|
|
460
|
+
const wt = 12, Hn = 2, Oe = 8, Te = 20, Zn = 100, Ee = 20, _e = 8, Gn = 100, pe = 32, Pe = 1, Vn = "#2B2D33", ze = "#3D8BF4", Fe = "#FFFFFF";
|
|
461
|
+
function de(h, t, e, n, s) {
|
|
462
|
+
const o = wt, i = Hn;
|
|
463
|
+
h.save(), h.translate(t, e), h.rotate(bt.degreesToRadians(s.angle)), h.fillStyle = Fe, h.strokeStyle = ze, h.lineWidth = Pe, h.beginPath(), h.roundRect(-o / 2, -o / 2, o, o, i), h.fill(), h.stroke(), h.restore();
|
|
514
464
|
}
|
|
515
465
|
function en(h, t, e, n, s) {
|
|
516
|
-
const o = Oe, i =
|
|
517
|
-
h.save(), h.translate(t, e), h.rotate(
|
|
466
|
+
const o = Oe, i = Te, a = Zn;
|
|
467
|
+
h.save(), h.translate(t, e), h.rotate(bt.degreesToRadians(s.angle)), h.fillStyle = Fe, h.strokeStyle = ze, h.lineWidth = Pe, h.beginPath(), h.roundRect(-o / 2, -i / 2, o, i, a), h.fill(), h.stroke(), h.restore();
|
|
518
468
|
}
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
const i = ge / 2;
|
|
523
|
-
h.save(), h.translate(t, e), h.rotate(vt.degreesToRadians(s.angle)), h.fillStyle = Gn, h.beginPath(), h.arc(0, 0, i, 0, 2 * Math.PI), h.fill(), h.drawImage(bn, -i / 2, -i / 2, i, i), h.restore();
|
|
469
|
+
function nn(h, t, e, n, s) {
|
|
470
|
+
const o = Ee, i = _e, a = Gn;
|
|
471
|
+
h.save(), h.translate(t, e), h.rotate(bt.degreesToRadians(s.angle)), h.fillStyle = Fe, h.strokeStyle = ze, h.lineWidth = Pe, h.beginPath(), h.roundRect(-o / 2, -i / 2, o, i, a), h.fill(), h.stroke(), h.restore();
|
|
524
472
|
}
|
|
525
|
-
const
|
|
473
|
+
const Xn = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTE4Ljc1IDQuMzc1djMuNzVhLjYyNS42MjUgMCAwIDEtLjYyNS42MjVoLTMuNzVhLjYyNS42MjUgMCAwIDEgMC0xLjI1aDIuMTRsLTIuMDc3LTEuOTAzLS4wMi0uMDE5YTYuMjUgNi4yNSAwIDEgMC0uMTMgOC45NjcuNjI2LjYyNiAwIDAgMSAuODYuOTA5QTcuNDU2IDcuNDU2IDAgMCAxIDEwIDE3LjVoLS4xMDNhNy41IDcuNSAwIDEgMSA1LjM5Ni0xMi44MTJMMTcuNSA2LjcwM1Y0LjM3NWEuNjI1LjYyNSAwIDAgMSAxLjI1IDBaIi8+PC9zdmc+", Mn = new Image();
|
|
474
|
+
Mn.src = Xn;
|
|
475
|
+
function Kn(h, t, e, n, s) {
|
|
476
|
+
const i = pe / 2;
|
|
477
|
+
h.save(), h.translate(t, e), h.rotate(bt.degreesToRadians(s.angle)), h.fillStyle = Vn, h.beginPath(), h.arc(0, 0, i, 0, 2 * Math.PI), h.fill(), h.drawImage(Mn, -i / 2, -i / 2, i, i), h.restore();
|
|
478
|
+
}
|
|
479
|
+
const qn = {
|
|
526
480
|
// Угловые точки
|
|
527
481
|
tl: {
|
|
528
|
-
render:
|
|
529
|
-
sizeX:
|
|
530
|
-
sizeY:
|
|
482
|
+
render: de,
|
|
483
|
+
sizeX: wt,
|
|
484
|
+
sizeY: wt,
|
|
531
485
|
offsetX: 0,
|
|
532
486
|
offsetY: 0
|
|
533
487
|
},
|
|
534
488
|
tr: {
|
|
535
|
-
render:
|
|
536
|
-
sizeX:
|
|
537
|
-
sizeY:
|
|
489
|
+
render: de,
|
|
490
|
+
sizeX: wt,
|
|
491
|
+
sizeY: wt,
|
|
538
492
|
offsetX: 0,
|
|
539
493
|
offsetY: 0
|
|
540
494
|
},
|
|
541
495
|
bl: {
|
|
542
|
-
render:
|
|
543
|
-
sizeX:
|
|
544
|
-
sizeY:
|
|
496
|
+
render: de,
|
|
497
|
+
sizeX: wt,
|
|
498
|
+
sizeY: wt,
|
|
545
499
|
offsetX: 0,
|
|
546
500
|
offsetY: 0
|
|
547
501
|
},
|
|
548
502
|
br: {
|
|
549
|
-
render:
|
|
550
|
-
sizeX:
|
|
551
|
-
sizeY:
|
|
503
|
+
render: de,
|
|
504
|
+
sizeX: wt,
|
|
505
|
+
sizeY: wt,
|
|
552
506
|
offsetX: 0,
|
|
553
507
|
offsetY: 0
|
|
554
508
|
},
|
|
555
509
|
// Середина вертикалей
|
|
556
510
|
ml: {
|
|
557
|
-
render:
|
|
558
|
-
sizeX:
|
|
511
|
+
render: en,
|
|
512
|
+
sizeX: Oe,
|
|
559
513
|
sizeY: Te,
|
|
560
514
|
offsetX: 0,
|
|
561
515
|
offsetY: 0
|
|
562
516
|
},
|
|
563
517
|
mr: {
|
|
564
|
-
render:
|
|
565
|
-
sizeX:
|
|
518
|
+
render: en,
|
|
519
|
+
sizeX: Oe,
|
|
566
520
|
sizeY: Te,
|
|
567
521
|
offsetX: 0,
|
|
568
522
|
offsetY: 0
|
|
569
523
|
},
|
|
570
524
|
// Середина горизонталей
|
|
571
525
|
mt: {
|
|
572
|
-
render:
|
|
573
|
-
sizeX:
|
|
574
|
-
sizeY:
|
|
526
|
+
render: nn,
|
|
527
|
+
sizeX: Ee,
|
|
528
|
+
sizeY: _e,
|
|
575
529
|
offsetX: 0,
|
|
576
530
|
offsetY: 0
|
|
577
531
|
},
|
|
578
532
|
mb: {
|
|
579
|
-
render:
|
|
580
|
-
sizeX:
|
|
581
|
-
sizeY:
|
|
533
|
+
render: nn,
|
|
534
|
+
sizeX: Ee,
|
|
535
|
+
sizeY: _e,
|
|
582
536
|
offsetX: 0,
|
|
583
537
|
offsetY: 0
|
|
584
538
|
},
|
|
585
539
|
// Специальный «rotate» контрол
|
|
586
540
|
mtr: {
|
|
587
|
-
render:
|
|
588
|
-
sizeX:
|
|
589
|
-
sizeY:
|
|
541
|
+
render: Kn,
|
|
542
|
+
sizeX: pe,
|
|
543
|
+
sizeY: pe,
|
|
590
544
|
offsetX: 0,
|
|
591
|
-
offsetY: -
|
|
545
|
+
offsetY: -pe
|
|
592
546
|
}
|
|
593
547
|
};
|
|
594
548
|
class ut {
|
|
@@ -607,7 +561,7 @@ class ut {
|
|
|
607
561
|
* Применяет конфигурацию контролов к набору по ключам из DEFAULT_CONTROLS.
|
|
608
562
|
*/
|
|
609
563
|
static applyControlOverrides(t) {
|
|
610
|
-
Object.entries(
|
|
564
|
+
Object.entries(qn).forEach(([e, n]) => {
|
|
611
565
|
const s = t[e];
|
|
612
566
|
s && (Object.assign(s, n), e === "mtr" && (s.cursorStyle = "grab", s.mouseDownHandler = (o, i, a, r) => {
|
|
613
567
|
var l;
|
|
@@ -620,10 +574,10 @@ class ut {
|
|
|
620
574
|
* Регистрирует контролы и настройки поведения выделений.
|
|
621
575
|
*/
|
|
622
576
|
static apply() {
|
|
623
|
-
const t =
|
|
624
|
-
ut.applyControlOverrides(t),
|
|
625
|
-
const e =
|
|
626
|
-
ut.applyControlOverrides(e), e.mt && (e.mt.visible = !1), e.mb && (e.mb.visible = !1), ut.wrapWidthControl(e.ml), ut.wrapWidthControl(e.mr), ct.ownDefaults.controls = e, ut.patchActiveSelectionBounds(),
|
|
577
|
+
const t = Ke.createObjectDefaultControls();
|
|
578
|
+
ut.applyControlOverrides(t), qe.ownDefaults.controls = t;
|
|
579
|
+
const e = Ke.createTextboxDefaultControls();
|
|
580
|
+
ut.applyControlOverrides(e), e.mt && (e.mt.visible = !1), e.mb && (e.mb.visible = !1), ut.wrapWidthControl(e.ml), ut.wrapWidthControl(e.mr), ct.ownDefaults.controls = e, ut.patchActiveSelectionBounds(), qe.ownDefaults.snapAngle = 1;
|
|
627
581
|
}
|
|
628
582
|
/**
|
|
629
583
|
* Обновляет алгоритм расчёта границ ActiveSelection, чтобы учитывать фон и отступы текстовых объектов.
|
|
@@ -670,8 +624,8 @@ class ut {
|
|
|
670
624
|
height: f
|
|
671
625
|
}), this.setPositionByOrigin(g, "center", "center"), this.setCoords(), a;
|
|
672
626
|
};
|
|
673
|
-
const s =
|
|
674
|
-
|
|
627
|
+
const s = Je.prototype.calcBoundingBox;
|
|
628
|
+
Je.prototype.calcBoundingBox = function(o, i) {
|
|
675
629
|
const { target: a, type: r, overrides: c } = i;
|
|
676
630
|
if (r === "imperative" && c)
|
|
677
631
|
return c;
|
|
@@ -894,8 +848,8 @@ V.registeredFontKeys = /* @__PURE__ */ new Set(), V.descriptorDefaults = {
|
|
|
894
848
|
featureSettings: "normal",
|
|
895
849
|
display: "auto"
|
|
896
850
|
};
|
|
897
|
-
let
|
|
898
|
-
const
|
|
851
|
+
let Le = V;
|
|
852
|
+
const Jn = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNNi44NzUgMi41YS42MjUuNjI1IDAgMCAwLS42MjUuNjI0VjYuMjVIMy4xMjVhLjYyNS42MjUgMCAwIDAtLjYyNS42MjV2MTBjMCAuMzQ1LjI4LjYyNS42MjUuNjI1aDEwYy4zNDUgMCAuNjI1LS4yOC42MjUtLjYyNXYtMy4xMjZoMy4xMjVjLjM0NSAwIC42MjUtLjI4LjYyNS0uNjI1di0xMGEuNjI1LjYyNSAwIDAgMC0uNjI1LS42MjVoLTEwWm02Ljg3NSAxMGgyLjVWMy43NUg3LjV2Mi41aDUuNjI1Yy4zNDUgMCAuNjI1LjI4LjYyNS42MjV2NS42MjRabS0xMCAzLjc1VjcuNWg4Ljc1djguNzVIMy43NVoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPjwvc3ZnPg==", Qn = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMi41IDcuNWMwLS42OS41Ni0xLjI1IDEuMjUtMS4yNWgxMi41Yy42OSAwIDEuMjUuNTYgMS4yNSAxLjI1djguNzVjMCAuNjktLjU2IDEuMjUtMS4yNSAxLjI1SDMuNzVjLS42OSAwLTEuMjUtLjU2LTEuMjUtMS4yNVY3LjVabTEzLjc1IDBIMy43NXY4Ljc1aDEyLjVWNy41WiIgY2xpcC1ydWxlPSJldmVub2RkIi8+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMTAgMS44NzVhMi4xODggMi4xODggMCAwIDAtMi4xODggMi4xODh2Mi44MTJhLjYyNS42MjUgMCAxIDEtMS4yNSAwVjQuMDYyYTMuNDM3IDMuNDM3IDAgMSAxIDYuODc1IDB2Mi44MTNhLjYyNS42MjUgMCAxIDEtMS4yNSAwVjQuMDYyQTIuMTg4IDIuMTg4IDAgMCAwIDEwIDEuODc2WiIgY2xpcC1ydWxlPSJldmVub2RkIi8+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTEwIDEyLjgxM2EuOTM3LjkzNyAwIDEgMCAwLTEuODc1LjkzNy45MzcgMCAwIDAgMCAxLjg3NFoiLz48L3N2Zz4=", $n = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTE2LjI1IDYuMjVINy41VjQuMzc1YTIuNSAyLjUgMCAwIDEgMi41LTIuNWMxLjIgMCAyLjI4MS44NiAyLjUxMiAyYS42MjUuNjI1IDAgMCAwIDEuMjI2LS4yNWMtLjM1NC0xLjczOC0xLjkyNS0zLTMuNzM4LTNhMy43NTQgMy43NTQgMCAwIDAtMy43NSAzLjc1VjYuMjVoLTIuNUExLjI1IDEuMjUgMCAwIDAgMi41IDcuNXY4Ljc1YTEuMjUgMS4yNSAwIDAgMCAxLjI1IDEuMjVoMTIuNWExLjI1IDEuMjUgMCAwIDAgMS4yNS0xLjI1VjcuNWExLjI1IDEuMjUgMCAwIDAtMS4yNS0xLjI1Wm0wIDEwSDMuNzVWNy41aDEyLjV2OC43NVptLTUuMzEzLTQuMzc1YS45MzcuOTM3IDAgMSAxLTEuODc0IDAgLjkzNy45MzcgMCAwIDEgMS44NzQgMFoiLz48L3N2Zz4K", ts = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTIuNSA4LjEyNSAxMCAxMi41bDcuNS00LjM3NUwxMCAzLjc1IDIuNSA4LjEyNVoiLz48cGF0aCBmaWxsPSIjZmZmIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik05LjY4NSAzLjIxYS42MjUuNjI1IDAgMCAxIC42MyAwbDcuNSA0LjM3NWEuNjI1LjYyNSAwIDAgMSAwIDEuMDhsLTcuNSA0LjM3NWEuNjI1LjYyNSAwIDAgMS0uNjMgMGwtNy41LTQuMzc1YS42MjUuNjI1IDAgMCAxIDAtMS4wOGw3LjUtNC4zNzVaTTMuNzQgOC4xMjUgMTAgMTEuNzc2bDYuMjYtMy42NTFMMTAgNC40NzQgMy43NCA4LjEyNVoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPjxwYXRoIGZpbGw9IiNmZmYiIGZpbGwtcnVsZT0iZXZlbm9kZCIgZD0iTTUuNCA5LjQ2YS42MjUuNjI1IDAgMCAxIC42MyAwTDEwIDExLjc3NmwzLjk3LTIuMzE2YS42MjUuNjI1IDAgMCAxIC42MyAwbDMuMjE1IDEuODc1YS42MjUuNjI1IDAgMCAxIDAgMS4wOGwtNy41IDQuMzc1YS42MjUuNjI1IDAgMCAxLS42MyAwbC03LjUtNC4zNzVhLjYyNS42MjUgMCAwIDEgMC0xLjA4TDUuNCA5LjQ2Wm0tMS42NiAyLjQxNUwxMCAxNS41MjZsNi4yNi0zLjY1MS0xLjk3NC0xLjE1MS0zLjk3MSAyLjMxNmEuNjI1LjYyNSAwIDAgMS0uNjMgMGwtMy45Ny0yLjMxNi0xLjk3NSAxLjE1MVoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPjwvc3ZnPg==", es = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNOS42ODUgMy4yMWEuNjI1LjYyNSAwIDAgMSAuNjMgMGw3LjUgNC4zNzVhLjYyNS42MjUgMCAwIDEgMCAxLjA4bC03LjUgNC4zNzVhLjYyNS42MjUgMCAwIDEtLjYzIDBsLTcuNS00LjM3NWEuNjI1LjYyNSAwIDAgMSAwLTEuMDhsNy41LTQuMzc1Wk0zLjc0IDguMTI1IDEwIDExLjc3Nmw2LjI2LTMuNjUxTDEwIDQuNDc0IDMuNzQgOC4xMjVaIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiLz48cGF0aCBmaWxsPSIjZmZmIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik01LjcxNCAxMCAxMCAxMi41bDQuMjg2LTIuNSAzLjIxNCAxLjg3NUwxMCAxNi4yNWwtNy41LTQuMzc1TDUuNzE0IDEwWiIgY2xpcC1ydWxlPSJldmVub2RkIi8+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNNS40IDkuNDZhLjYyNS42MjUgMCAwIDEgLjYzIDBMMTAgMTEuNzc2bDMuOTctMi4zMTZhLjYyNS42MjUgMCAwIDEgLjYzIDBsMy4yMTUgMS44NzVhLjYyNS42MjUgMCAwIDEgMCAxLjA4bC03LjUgNC4zNzVhLjYyNS42MjUgMCAwIDEtLjYzIDBsLTcuNS00LjM3NWEuNjI1LjYyNSAwIDAgMSAwLTEuMDhMNS40IDkuNDZabS0xLjY2IDIuNDE1TDEwIDE1LjUyNmw2LjI2LTMuNjUxLTEuOTc0LTEuMTUxLTMuOTcxIDIuMzE2YS42MjUuNjI1IDAgMCAxLS42MyAwbC0zLjk3LTIuMzE2LTEuOTc1IDEuMTUxWiIgY2xpcC1ydWxlPSJldmVub2RkIi8+PC9zdmc+", ns = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZD0ibTIuNSA2LjI1IDcuNSA0LjM3NSA3LjUtNC4zNzVMMTAgMS44NzUgMi41IDYuMjVaIi8+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNOS42ODUgMS4zMzVhLjYyNS42MjUgMCAwIDEgLjYzIDBsNy41IDQuMzc1YS42MjUuNjI1IDAgMCAxIDAgMS4wOGwtNy41IDQuMzc1YS42MjUuNjI1IDAgMCAxLS42MyAwbC03LjUtNC4zNzVhLjYyNS42MjUgMCAwIDEgMC0xLjA4bDcuNS00LjM3NVpNMy43NCA2LjI1IDEwIDkuOTAxbDYuMjYtMy42NTFMMTAgMi41OTkgMy43NCA2LjI1WiIgY2xpcC1ydWxlPSJldmVub2RkIi8+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNNS40IDExLjMzNWEuNjI1LjYyNSAwIDAgMSAuNjMgMEwxMCAxMy42NTFsMy45Ny0yLjMxNmEuNjI1LjYyNSAwIDAgMSAuNjMgMGwzLjIxNSAxLjg3NWEuNjI1LjYyNSAwIDAgMSAwIDEuMDhsLTcuNSA0LjM3NWEuNjI1LjYyNSAwIDAgMS0uNjMgMGwtNy41LTQuMzc1YS42MjUuNjI1IDAgMCAxIDAtMS4wOEw1LjQgMTEuMzM1Wk0zLjc0IDEzLjc1IDEwIDE3LjQwMWw2LjI2LTMuNjUxLTEuOTc0LTEuMTUxLTMuOTcxIDIuMzE2YS42MjUuNjI1IDAgMCAxLS42MyAwbC0zLjk3LTIuMzE2TDMuNzQgMTMuNzVaIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiLz48cGF0aCBmaWxsPSIjZmZmIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik01LjQgNy41ODVhLjYyNS42MjUgMCAwIDEgLjYzIDBMMTAgOS45MDFsMy45Ny0yLjMxNmEuNjI1LjYyNSAwIDAgMSAuNjMgMGwzLjIxNSAxLjg3NWEuNjI1LjYyNSAwIDAgMSAwIDEuMDhsLTcuNSA0LjM3NWEuNjI1LjYyNSAwIDAgMS0uNjMgMGwtNy41LTQuMzc1YS42MjUuNjI1IDAgMCAxIDAtMS4wOEw1LjQgNy41ODVaTTMuNzQgMTAgMTAgMTMuNjUxIDE2LjI2IDEwbC0xLjk3NC0xLjE1MS0zLjk3MSAyLjMxNmEuNjI1LjYyNSAwIDAgMS0uNjMgMGwtMy45Ny0yLjMxNkwzLjc0IDEwWiIgY2xpcC1ydWxlPSJldmVub2RkIi8+PC9zdmc+", ss = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMS45NiAxMy40MzVhLjYyNS42MjUgMCAwIDEgLjg1NS0uMjI1TDEwIDE3LjQwMWw3LjE4NS00LjE5YS42MjUuNjI1IDAgMCAxIC42MyAxLjA3OWwtNy41IDQuMzc1YS42MjUuNjI1IDAgMCAxLS42MyAwbC03LjUtNC4zNzVhLjYyNS42MjUgMCAwIDEtLjIyNS0uODU1Wk05LjY4NSAxLjMzNWEuNjI1LjYyNSAwIDAgMSAuNjMgMGw3LjUgNC4zNzVhLjYyNS42MjUgMCAwIDEgMCAxLjA4bC03LjUgNC4zNzVhLjYyNS42MjUgMCAwIDEtLjYzIDBsLTcuNS00LjM3NWEuNjI1LjYyNSAwIDAgMSAwLTEuMDhsNy41LTQuMzc1Wk0zLjc0IDYuMjUgMTAgOS45MDFsNi4yNi0zLjY1MUwxMCAyLjU5OSAzLjc0IDYuMjVaIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiLz48cGF0aCBmaWxsPSIjZmZmIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGQ9Im01LjcxNCAxMS44NzUgNC4yODYgMi41IDQuMjg2LTIuNUwxNy41IDEzLjc1IDEwIDE4LjEyNSAyLjUgMTMuNzVsMy4yMTQtMS44NzVaIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiLz48cGF0aCBmaWxsPSIjZmZmIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik01LjQgMTEuMzM1YS42MjUuNjI1IDAgMCAxIC42MyAwTDEwIDEzLjY1MWwzLjk3LTIuMzE2YS42MjUuNjI1IDAgMCAxIC42MyAwbDMuMjE1IDEuODc1YS42MjUuNjI1IDAgMCAxIDAgMS4wOGwtNy41IDQuMzc1YS42MjUuNjI1IDAgMCAxLS42MyAwbC03LjUtNC4zNzVhLjYyNS42MjUgMCAwIDEgMC0xLjA4TDUuNCAxMS4zMzVaTTMuNzQgMTMuNzUgMTAgMTcuNDAxbDYuMjYtMy42NTEtMS45NzQtMS4xNTEtMy45NzEgMi4zMTZhLjYyNS42MjUgMCAwIDEtLjYzIDBsLTMuOTctMi4zMTZMMy43NCAxMy43NVoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPjxwYXRoIGZpbGw9IiNmZmYiIGZpbGwtcnVsZT0iZXZlbm9kZCIgZD0iTTUuNCA3LjU4NWEuNjI1LjYyNSAwIDAgMSAuNjMgMEwxMCA5LjkwMWwzLjk3LTIuMzE2YS42MjUuNjI1IDAgMCAxIC42MyAwbDMuMjE1IDEuODc1YS42MjUuNjI1IDAgMCAxIDAgMS4wOGwtNy41IDQuMzc1YS42MjUuNjI1IDAgMCAxLS42MyAwbC03LjUtNC4zNzVhLjYyNS42MjUgMCAwIDEgMC0xLjA4TDUuNCA3LjU4NVpNMy43NCAxMCAxMCAxMy42NTEgMTYuMjYgMTBsLTEuOTc0LTEuMTUxLTMuOTcxIDIuMzE2YS42MjUuNjI1IDAgMCAxLS42MyAwbC0zLjk3LTIuMzE2TDMuNzQgMTBaIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiLz48L3N2Zz4=", is = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI0VDNEU0MCIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNOC4xMjUgMS4yNUExLjg3NSAxLjg3NSAwIDAgMCA2LjI1IDMuMTI1di42MjVIMy4xMjVhLjYyNS42MjUgMCAwIDAgMCAxLjI1aC42MjV2MTEuMjVBMS4yNSAxLjI1IDAgMCAwIDUgMTcuNWgxMGExLjI1IDEuMjUgMCAwIDAgMS4yNS0xLjI1VjVoLjYyNWEuNjI1LjYyNSAwIDAgMCAwLTEuMjVIMTMuNzV2LS42MjVhMS44NzUgMS44NzUgMCAwIDAtMS44NzUtMS44NzVoLTMuNzVabTQuMzc1IDIuNXYtLjYyNWEuNjI1LjYyNSAwIDAgMC0uNjI1LS42MjVoLTMuNzVhLjYyNS42MjUgMCAwIDAtLjYyNS42MjV2LjYyNWg1Wk01IDE2LjI1VjVoMTB2MTEuMjVINVpNOC4xMjUgNy41Yy4zNDUgMCAuNjI1LjI4LjYyNS42MjV2NWEuNjI1LjYyNSAwIDEgMS0xLjI1IDB2LTVjMC0uMzQ1LjI4LS42MjUuNjI1LS42MjVabTQuMzc1IDUuNjI1di01YS42MjUuNjI1IDAgMCAwLTEuMjUgMHY1YS42MjUuNjI1IDAgMSAwIDEuMjUgMFoiIGNsaXAtcnVsZT0iZXZlbm9kZCIvPjwvc3ZnPg==", Jt = {
|
|
899
853
|
style: {
|
|
900
854
|
position: "absolute",
|
|
901
855
|
display: "none",
|
|
@@ -962,14 +916,14 @@ const qn = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMj
|
|
|
962
916
|
],
|
|
963
917
|
offsetTop: 50,
|
|
964
918
|
icons: {
|
|
965
|
-
copyPaste:
|
|
966
|
-
delete:
|
|
967
|
-
lock:
|
|
968
|
-
unlock:
|
|
969
|
-
bringToFront:
|
|
970
|
-
sendToBack:
|
|
971
|
-
bringForward:
|
|
972
|
-
sendBackwards:
|
|
919
|
+
copyPaste: Jn,
|
|
920
|
+
delete: is,
|
|
921
|
+
lock: Qn,
|
|
922
|
+
unlock: $n,
|
|
923
|
+
bringToFront: ns,
|
|
924
|
+
sendToBack: ss,
|
|
925
|
+
bringForward: ts,
|
|
926
|
+
sendBackwards: es
|
|
973
927
|
},
|
|
974
928
|
handlers: {
|
|
975
929
|
copyPaste: (h) => G(null, null, function* () {
|
|
@@ -998,18 +952,18 @@ const qn = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMj
|
|
|
998
952
|
}
|
|
999
953
|
}
|
|
1000
954
|
};
|
|
1001
|
-
class
|
|
955
|
+
class os {
|
|
1002
956
|
constructor({ editor: t }) {
|
|
1003
957
|
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();
|
|
1004
958
|
}
|
|
1005
959
|
_initToolbar() {
|
|
1006
960
|
if (!this.options.showToolbar) return;
|
|
1007
961
|
const t = this.options.toolbar || {};
|
|
1008
|
-
this.config =
|
|
1009
|
-
style: F(F({},
|
|
1010
|
-
btnStyle: F(F({},
|
|
1011
|
-
icons: F(F({},
|
|
1012
|
-
handlers: F(F({},
|
|
962
|
+
this.config = Et(F(F({}, Jt), t), {
|
|
963
|
+
style: F(F({}, Jt.style), t.style || {}),
|
|
964
|
+
btnStyle: F(F({}, Jt.btnStyle), t.btnStyle || {}),
|
|
965
|
+
icons: F(F({}, Jt.icons), t.icons || {}),
|
|
966
|
+
handlers: F(F({}, Jt.handlers), t.handlers || {})
|
|
1013
967
|
}), 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 = () => {
|
|
1014
968
|
this.el.style.display = "none";
|
|
1015
969
|
}, this._createDOM(), this._bindEvents();
|
|
@@ -1126,7 +1080,7 @@ class is {
|
|
|
1126
1080
|
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();
|
|
1127
1081
|
}
|
|
1128
1082
|
}
|
|
1129
|
-
const
|
|
1083
|
+
const as = {
|
|
1130
1084
|
position: "absolute",
|
|
1131
1085
|
display: "none",
|
|
1132
1086
|
background: "#2B2D33",
|
|
@@ -1140,8 +1094,8 @@ const os = {
|
|
|
1140
1094
|
"pointer-events": "none",
|
|
1141
1095
|
"white-space": "nowrap",
|
|
1142
1096
|
"box-shadow": "0 2px 8px rgba(0, 0, 0, 0.2)"
|
|
1143
|
-
},
|
|
1144
|
-
class
|
|
1097
|
+
}, sn = 16, on = 16, rs = "fabric-editor-angle-indicator";
|
|
1098
|
+
class We {
|
|
1145
1099
|
constructor({ editor: t }) {
|
|
1146
1100
|
this.isActive = !1, this.currentAngle = 0, this.editor = t, this.canvas = t.canvas, this.options = t.options, this._createDOM(), this._bindEvents();
|
|
1147
1101
|
}
|
|
@@ -1149,7 +1103,7 @@ class Fe {
|
|
|
1149
1103
|
* Создание DOM-элемента индикатора
|
|
1150
1104
|
*/
|
|
1151
1105
|
_createDOM() {
|
|
1152
|
-
this.el = document.createElement("div"), this.el.className =
|
|
1106
|
+
this.el = document.createElement("div"), this.el.className = rs, Object.entries(as).forEach(([t, e]) => {
|
|
1153
1107
|
this.el.style.setProperty(t, e);
|
|
1154
1108
|
}), this.canvas.wrapperEl.appendChild(this.el);
|
|
1155
1109
|
}
|
|
@@ -1169,7 +1123,7 @@ class Fe {
|
|
|
1169
1123
|
return;
|
|
1170
1124
|
}
|
|
1171
1125
|
const n = e.angle || 0;
|
|
1172
|
-
this.currentAngle =
|
|
1126
|
+
this.currentAngle = We._normalizeAngle(n), this.el.textContent = `${this.currentAngle}°`, this._positionIndicator(t.e), this.isActive || this._showIndicator();
|
|
1173
1127
|
}
|
|
1174
1128
|
/**
|
|
1175
1129
|
* Обработчик отпускания кнопки мыши
|
|
@@ -1200,9 +1154,9 @@ class Fe {
|
|
|
1200
1154
|
*/
|
|
1201
1155
|
_positionIndicator(t) {
|
|
1202
1156
|
const e = this.canvas.wrapperEl.getBoundingClientRect();
|
|
1203
|
-
let n = t.clientX - e.left +
|
|
1157
|
+
let n = t.clientX - e.left + sn, s = t.clientY - e.top + on;
|
|
1204
1158
|
const o = this.el.getBoundingClientRect(), i = o.width, a = o.height;
|
|
1205
|
-
n + i > e.width && (n = t.clientX - e.left - i -
|
|
1159
|
+
n + i > e.width && (n = t.clientX - e.left - i - sn), s + a > e.height && (s = t.clientY - e.top - a - on), this.el.style.left = `${n}px`, this.el.style.top = `${s}px`;
|
|
1206
1160
|
}
|
|
1207
1161
|
/**
|
|
1208
1162
|
* Показать индикатор
|
|
@@ -1233,7 +1187,7 @@ class Fe {
|
|
|
1233
1187
|
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;
|
|
1234
1188
|
}
|
|
1235
1189
|
}
|
|
1236
|
-
const
|
|
1190
|
+
const De = [
|
|
1237
1191
|
"id",
|
|
1238
1192
|
"backgroundId",
|
|
1239
1193
|
"customData",
|
|
@@ -1284,7 +1238,7 @@ class J {
|
|
|
1284
1238
|
return this.patches[this.currentIndex - 1] || null;
|
|
1285
1239
|
}
|
|
1286
1240
|
_createDiffPatcher() {
|
|
1287
|
-
this.diffPatcher =
|
|
1241
|
+
this.diffPatcher = Pn({
|
|
1288
1242
|
objectHash(t) {
|
|
1289
1243
|
return [JSON.stringify(t)].join("-");
|
|
1290
1244
|
},
|
|
@@ -1369,7 +1323,7 @@ class J {
|
|
|
1369
1323
|
*/
|
|
1370
1324
|
_serializeCanvasState() {
|
|
1371
1325
|
const { canvas: t } = this;
|
|
1372
|
-
return t.toDatalessObject([...
|
|
1326
|
+
return t.toDatalessObject([...De]);
|
|
1373
1327
|
}
|
|
1374
1328
|
/**
|
|
1375
1329
|
* Обрабатывает срабатывание отложенного сохранения.
|
|
@@ -1430,7 +1384,7 @@ class J {
|
|
|
1430
1384
|
this._isSavingState = !0, console.time("saveState");
|
|
1431
1385
|
try {
|
|
1432
1386
|
const t = this._withTemporaryUnlock(
|
|
1433
|
-
() => this.canvas.toDatalessObject([...
|
|
1387
|
+
() => this.canvas.toDatalessObject([...De])
|
|
1434
1388
|
);
|
|
1435
1389
|
if (console.timeEnd("saveState"), !this.baseState) {
|
|
1436
1390
|
this.baseState = t, this.patches = [], this.currentIndex = 0, console.log("Базовое состояние сохранено.");
|
|
@@ -1823,7 +1777,7 @@ class J {
|
|
|
1823
1777
|
}
|
|
1824
1778
|
}
|
|
1825
1779
|
}
|
|
1826
|
-
const
|
|
1780
|
+
const cs = 0.1, ls = 2, an = 0.1, ds = 90, $t = 16, te = 16, zt = 4096, Ft = 4096, rn = "application/image-editor:", he = [
|
|
1827
1781
|
"format",
|
|
1828
1782
|
"uppercase",
|
|
1829
1783
|
"textCaseRaw",
|
|
@@ -1838,8 +1792,8 @@ const rs = 0.1, cs = 2, on = 0.1, ls = 90, Qt = 16, $t = 16, zt = 4096, Pt = 409
|
|
|
1838
1792
|
"radiusBottomRight",
|
|
1839
1793
|
"radiusBottomLeft",
|
|
1840
1794
|
"lineFontDefaults"
|
|
1841
|
-
],
|
|
1842
|
-
class
|
|
1795
|
+
], hs = 50;
|
|
1796
|
+
class mt {
|
|
1843
1797
|
constructor({ editor: t }) {
|
|
1844
1798
|
this.editor = t, this.options = t.options, this._createdBlobUrls = [], this.acceptContentTypes = this.editor.options.acceptContentTypes, this.acceptFormats = this.getAllowedFormatsFromContentTypes();
|
|
1845
1799
|
}
|
|
@@ -1868,14 +1822,14 @@ class pt {
|
|
|
1868
1822
|
customData: c = null
|
|
1869
1823
|
} = t;
|
|
1870
1824
|
if (!e) return null;
|
|
1871
|
-
const { canvas: l, montageArea: d, transformManager: u, historyManager: f, errorManager: g } = this.editor, m = yield this.getContentType(e), p =
|
|
1825
|
+
const { canvas: l, montageArea: d, transformManager: u, historyManager: f, errorManager: g } = this.editor, m = yield this.getContentType(e), p = mt.getFormatFromContentType(m), { acceptContentTypes: y, acceptFormats: v } = this;
|
|
1872
1826
|
if (!this.isAllowedContentType(m)) {
|
|
1873
|
-
const
|
|
1827
|
+
const A = `Неверный contentType для изображения: ${m}. Ожидается один из: ${this.acceptContentTypes.join(", ")}.`;
|
|
1874
1828
|
return g.emitError({
|
|
1875
1829
|
origin: "ImageManager",
|
|
1876
1830
|
method: "importImage",
|
|
1877
1831
|
code: "INVALID_CONTENT_TYPE",
|
|
1878
|
-
message:
|
|
1832
|
+
message: A,
|
|
1879
1833
|
data: {
|
|
1880
1834
|
source: e,
|
|
1881
1835
|
format: p,
|
|
@@ -1892,12 +1846,12 @@ class pt {
|
|
|
1892
1846
|
}
|
|
1893
1847
|
f.suspendHistory();
|
|
1894
1848
|
try {
|
|
1895
|
-
let
|
|
1849
|
+
let A, b;
|
|
1896
1850
|
if (e instanceof File)
|
|
1897
|
-
|
|
1851
|
+
A = URL.createObjectURL(e);
|
|
1898
1852
|
else if (typeof e == "string") {
|
|
1899
1853
|
const C = yield (yield fetch(e, { mode: "cors" })).blob();
|
|
1900
|
-
|
|
1854
|
+
A = URL.createObjectURL(C);
|
|
1901
1855
|
} else
|
|
1902
1856
|
return g.emitError({
|
|
1903
1857
|
origin: "ImageManager",
|
|
@@ -1917,36 +1871,36 @@ class pt {
|
|
|
1917
1871
|
customData: c
|
|
1918
1872
|
}
|
|
1919
1873
|
}), f.resumeHistory(), null;
|
|
1920
|
-
if (this._createdBlobUrls.push(
|
|
1921
|
-
const w = yield
|
|
1922
|
-
b =
|
|
1874
|
+
if (this._createdBlobUrls.push(A), p === "svg") {
|
|
1875
|
+
const w = yield _n(A);
|
|
1876
|
+
b = bt.groupSVGElements(w.objects, w.options);
|
|
1923
1877
|
} else
|
|
1924
|
-
b = yield
|
|
1925
|
-
const { width:
|
|
1926
|
-
if (b instanceof
|
|
1878
|
+
b = yield qt.fromURL(A, { crossOrigin: "anonymous" });
|
|
1879
|
+
const { width: O, height: S } = b;
|
|
1880
|
+
if (b instanceof qt) {
|
|
1927
1881
|
const w = b.getElement();
|
|
1928
1882
|
let C = "";
|
|
1929
|
-
if (w instanceof HTMLImageElement ? C = w.src : w instanceof HTMLCanvasElement && (C = w.toDataURL()), S >
|
|
1930
|
-
const
|
|
1883
|
+
if (w instanceof HTMLImageElement ? C = w.src : w instanceof HTMLCanvasElement && (C = w.toDataURL()), S > Ft || O > zt) {
|
|
1884
|
+
const j = yield this.resizeImageToBoundaries({
|
|
1931
1885
|
dataURL: C,
|
|
1932
1886
|
sizeType: "max",
|
|
1933
1887
|
contentType: m
|
|
1934
|
-
}), I = URL.createObjectURL(
|
|
1935
|
-
this._createdBlobUrls.push(I), b = yield
|
|
1936
|
-
} else if (S <
|
|
1937
|
-
const
|
|
1888
|
+
}), I = URL.createObjectURL(j);
|
|
1889
|
+
this._createdBlobUrls.push(I), b = yield qt.fromURL(I, { crossOrigin: "anonymous" });
|
|
1890
|
+
} else if (S < te || O < $t) {
|
|
1891
|
+
const j = yield this.resizeImageToBoundaries({
|
|
1938
1892
|
dataURL: C,
|
|
1939
1893
|
sizeType: "min",
|
|
1940
1894
|
contentType: m
|
|
1941
|
-
}), I = URL.createObjectURL(
|
|
1942
|
-
this._createdBlobUrls.push(I), b = yield
|
|
1895
|
+
}), I = URL.createObjectURL(j);
|
|
1896
|
+
this._createdBlobUrls.push(I), b = yield qt.fromURL(I, { crossOrigin: "anonymous" });
|
|
1943
1897
|
}
|
|
1944
1898
|
}
|
|
1945
1899
|
if (b.set("id", `${b.type}-${et()}`), b.set("format", p), b.set("contentType", m), b.set("customData", c || null), n === "scale-montage")
|
|
1946
1900
|
this.editor.canvasManager.scaleMontageAreaToImage({ object: b, withoutSave: !0 });
|
|
1947
1901
|
else {
|
|
1948
|
-
const { width: w, height: C } = d,
|
|
1949
|
-
n === "image-contain" &&
|
|
1902
|
+
const { width: w, height: C } = d, j = this.calculateScaleFactor({ imageObject: b, scaleType: n });
|
|
1903
|
+
n === "image-contain" && j < 1 ? u.fitObject({ object: b, type: "contain", withoutSave: !0 }) : n === "image-cover" && (O > w || S > C) && u.fitObject({ object: b, type: "cover", withoutSave: !0 });
|
|
1950
1904
|
}
|
|
1951
1905
|
const M = {
|
|
1952
1906
|
image: b,
|
|
@@ -1962,12 +1916,12 @@ class pt {
|
|
|
1962
1916
|
customData: c
|
|
1963
1917
|
};
|
|
1964
1918
|
return r ? (f.resumeHistory(), l.fire("editor:image-imported", M), M) : (l.add(b), l.centerObject(b), a || l.setActiveObject(b), l.renderAll(), f.resumeHistory(), s || f.saveState(), l.fire("editor:image-imported", M), M);
|
|
1965
|
-
} catch (
|
|
1919
|
+
} catch (A) {
|
|
1966
1920
|
return g.emitError({
|
|
1967
1921
|
origin: "ImageManager",
|
|
1968
1922
|
method: "importImage",
|
|
1969
1923
|
code: "IMPORT_FAILED",
|
|
1970
|
-
message: `Ошибка импорта изображения: ${
|
|
1924
|
+
message: `Ошибка импорта изображения: ${A.message}`,
|
|
1971
1925
|
data: {
|
|
1972
1926
|
source: e,
|
|
1973
1927
|
format: p,
|
|
@@ -2009,9 +1963,9 @@ class pt {
|
|
|
2009
1963
|
contentType: s = "image/png",
|
|
2010
1964
|
quality: o = 1,
|
|
2011
1965
|
maxWidth: i = zt,
|
|
2012
|
-
maxHeight: a =
|
|
2013
|
-
minWidth: r =
|
|
2014
|
-
minHeight: c =
|
|
1966
|
+
maxHeight: a = Ft,
|
|
1967
|
+
minWidth: r = $t,
|
|
1968
|
+
minHeight: c = te,
|
|
2015
1969
|
asBase64: l = !1,
|
|
2016
1970
|
emitMessage: d = !0
|
|
2017
1971
|
} = t, { errorManager: u, workerManager: f } = this.editor, g = {
|
|
@@ -2066,22 +2020,22 @@ class pt {
|
|
|
2066
2020
|
exportAsBlob: o = !1
|
|
2067
2021
|
} = t, { canvas: i, montageArea: a, workerManager: r, interactionBlocker: c } = this.editor;
|
|
2068
2022
|
try {
|
|
2069
|
-
const l = n === "application/pdf", d = l ? "image/jpg" : n, u =
|
|
2023
|
+
const l = n === "application/pdf", d = l ? "image/jpg" : n, u = mt.getFormatFromContentType(d);
|
|
2070
2024
|
a.setCoords();
|
|
2071
2025
|
const { left: f, top: g, width: m, height: p } = a.getBoundingRect(), y = yield i.clone(["id", "format", "locked"]);
|
|
2072
2026
|
y.enableRetinaScaling = !1, ["image/jpg", "image/jpeg"].includes(d) && (y.backgroundColor = "#ffffff");
|
|
2073
|
-
const v = y.getObjects().find((
|
|
2027
|
+
const v = y.getObjects().find((j) => j.id === a.id);
|
|
2074
2028
|
if (v && (v.visible = !1), c != null && c.isBlocked) {
|
|
2075
|
-
const
|
|
2076
|
-
|
|
2029
|
+
const j = y.getObjects().find((I) => I.id === c.overlayMask.id);
|
|
2030
|
+
j && (j.visible = !1);
|
|
2077
2031
|
}
|
|
2078
2032
|
y.viewportTransform = [1, 0, 0, 1, -f, -g], y.setDimensions({ width: m, height: p }, { backstoreOnly: !0 }), y.renderAll();
|
|
2079
|
-
const
|
|
2080
|
-
if (u === "svg" &&
|
|
2081
|
-
const
|
|
2033
|
+
const A = y.getObjects().filter((j) => j.format).every((j) => j.format === "svg");
|
|
2034
|
+
if (u === "svg" && A) {
|
|
2035
|
+
const j = y.toSVG();
|
|
2082
2036
|
y.dispose();
|
|
2083
|
-
const
|
|
2084
|
-
image:
|
|
2037
|
+
const T = {
|
|
2038
|
+
image: mt._exportSVGStringAsFile(j, {
|
|
2085
2039
|
exportAsBase64: s,
|
|
2086
2040
|
exportAsBlob: o,
|
|
2087
2041
|
fileName: e
|
|
@@ -2090,51 +2044,51 @@ class pt {
|
|
|
2090
2044
|
contentType: "image/svg+xml",
|
|
2091
2045
|
fileName: e.replace(/\.[^/.]+$/, ".svg")
|
|
2092
2046
|
};
|
|
2093
|
-
return i.fire("editor:canvas-exported",
|
|
2047
|
+
return i.fire("editor:canvas-exported", T), T;
|
|
2094
2048
|
}
|
|
2095
|
-
const b = yield new Promise((
|
|
2049
|
+
const b = yield new Promise((j, I) => {
|
|
2096
2050
|
y.getElement().toBlob(
|
|
2097
|
-
(
|
|
2098
|
-
|
|
2051
|
+
(T) => {
|
|
2052
|
+
T ? j(T) : I(new Error("Failed to create Blob from canvas"));
|
|
2099
2053
|
},
|
|
2100
2054
|
d,
|
|
2101
2055
|
1
|
|
2102
2056
|
);
|
|
2103
2057
|
});
|
|
2104
2058
|
if (y.dispose(), o) {
|
|
2105
|
-
const
|
|
2059
|
+
const j = {
|
|
2106
2060
|
image: b,
|
|
2107
2061
|
format: u,
|
|
2108
2062
|
contentType: d,
|
|
2109
2063
|
fileName: e
|
|
2110
2064
|
};
|
|
2111
|
-
return i.fire("editor:canvas-exported",
|
|
2065
|
+
return i.fire("editor:canvas-exported", j), j;
|
|
2112
2066
|
}
|
|
2113
|
-
const
|
|
2067
|
+
const O = yield createImageBitmap(b), S = yield r.post(
|
|
2114
2068
|
"toDataURL",
|
|
2115
2069
|
{
|
|
2116
2070
|
contentType: d,
|
|
2117
2071
|
quality: 1,
|
|
2118
|
-
bitmap:
|
|
2072
|
+
bitmap: O
|
|
2119
2073
|
},
|
|
2120
|
-
[
|
|
2074
|
+
[O]
|
|
2121
2075
|
);
|
|
2122
2076
|
if (l) {
|
|
2123
|
-
const I = m * 0.264583,
|
|
2124
|
-
orientation: I >
|
|
2077
|
+
const I = m * 0.264583, T = p * 0.264583, k = (yield this.editor.moduleLoader.loadModule("jspdf")).jsPDF, _ = new k({
|
|
2078
|
+
orientation: I > T ? "landscape" : "portrait",
|
|
2125
2079
|
unit: "mm",
|
|
2126
|
-
format: [I,
|
|
2080
|
+
format: [I, T]
|
|
2127
2081
|
});
|
|
2128
|
-
if (
|
|
2082
|
+
if (_.addImage(String(S), "JPG", 0, 0, I, T), s) {
|
|
2129
2083
|
const B = {
|
|
2130
|
-
image:
|
|
2084
|
+
image: _.output("datauristring"),
|
|
2131
2085
|
format: "pdf",
|
|
2132
2086
|
contentType: "application/pdf",
|
|
2133
2087
|
fileName: e
|
|
2134
2088
|
};
|
|
2135
2089
|
return i.fire("editor:canvas-exported", B), B;
|
|
2136
2090
|
}
|
|
2137
|
-
const W =
|
|
2091
|
+
const W = _.output("blob"), L = {
|
|
2138
2092
|
image: new File([W], e, { type: "application/pdf" }),
|
|
2139
2093
|
format: "pdf",
|
|
2140
2094
|
contentType: "application/pdf",
|
|
@@ -2143,15 +2097,15 @@ class pt {
|
|
|
2143
2097
|
return i.fire("editor:canvas-exported", L), L;
|
|
2144
2098
|
}
|
|
2145
2099
|
if (s) {
|
|
2146
|
-
const
|
|
2100
|
+
const j = {
|
|
2147
2101
|
image: S,
|
|
2148
2102
|
format: u,
|
|
2149
2103
|
contentType: d,
|
|
2150
2104
|
fileName: e
|
|
2151
2105
|
};
|
|
2152
|
-
return i.fire("editor:canvas-exported",
|
|
2106
|
+
return i.fire("editor:canvas-exported", j), j;
|
|
2153
2107
|
}
|
|
2154
|
-
const M = u === "svg" && !
|
|
2108
|
+
const M = u === "svg" && !A ? e.replace(/\.[^/.]+$/, ".png") : e, C = {
|
|
2155
2109
|
image: new File([b], M, { type: d }),
|
|
2156
2110
|
format: u,
|
|
2157
2111
|
contentType: d,
|
|
@@ -2189,7 +2143,7 @@ class pt {
|
|
|
2189
2143
|
contentType: s,
|
|
2190
2144
|
exportAsBase64: o = !1,
|
|
2191
2145
|
exportAsBlob: i = !1
|
|
2192
|
-
} = t, { canvas: a, workerManager: r } = this.editor, c = e || a.getActiveObject(), l = s != null ? s : "image/png", d =
|
|
2146
|
+
} = t, { canvas: a, workerManager: r } = this.editor, c = e || a.getActiveObject(), l = s != null ? s : "image/png", d = mt.getFormatFromContentType(l) || "png", u = n != null ? n : `image.${d}`;
|
|
2193
2147
|
if (!c)
|
|
2194
2148
|
return this.editor.errorManager.emitError({
|
|
2195
2149
|
origin: "ImageManager",
|
|
@@ -2198,10 +2152,10 @@ class pt {
|
|
|
2198
2152
|
message: "Не выбран объект для экспорта",
|
|
2199
2153
|
data: { contentType: l, fileName: u, exportAsBase64: o, exportAsBlob: i }
|
|
2200
2154
|
}), null;
|
|
2201
|
-
const { contentType: f, format: g = "" } = c, m = (v = s != null ? s : f) != null ? v : "image/png", p =
|
|
2155
|
+
const { contentType: f, format: g = "" } = c, m = (v = s != null ? s : f) != null ? v : "image/png", p = mt.getFormatFromContentType(m) || g || "png", y = n != null ? n : `image.${p}`;
|
|
2202
2156
|
try {
|
|
2203
2157
|
if (p === "svg") {
|
|
2204
|
-
const M = c.toSVG(), w =
|
|
2158
|
+
const M = c.toSVG(), w = mt._exportSVGStringAsFile(M, {
|
|
2205
2159
|
exportAsBase64: o,
|
|
2206
2160
|
exportAsBlob: i,
|
|
2207
2161
|
fileName: y
|
|
@@ -2214,7 +2168,7 @@ class pt {
|
|
|
2214
2168
|
};
|
|
2215
2169
|
return a.fire("editor:object-exported", C), C;
|
|
2216
2170
|
}
|
|
2217
|
-
if (o && c instanceof
|
|
2171
|
+
if (o && c instanceof qt) {
|
|
2218
2172
|
const M = yield createImageBitmap(c.getElement()), w = yield r.post(
|
|
2219
2173
|
"toDataURL",
|
|
2220
2174
|
{
|
|
@@ -2232,10 +2186,10 @@ class pt {
|
|
|
2232
2186
|
};
|
|
2233
2187
|
return a.fire("editor:object-exported", C), C;
|
|
2234
2188
|
}
|
|
2235
|
-
const
|
|
2189
|
+
const A = c.toCanvasElement({
|
|
2236
2190
|
enableRetinaScaling: !1
|
|
2237
2191
|
}), b = yield new Promise((M, w) => {
|
|
2238
|
-
|
|
2192
|
+
A.toBlob((C) => {
|
|
2239
2193
|
C ? M(C) : w(new Error("Failed to create Blob from canvas"));
|
|
2240
2194
|
});
|
|
2241
2195
|
});
|
|
@@ -2249,20 +2203,20 @@ class pt {
|
|
|
2249
2203
|
};
|
|
2250
2204
|
return a.fire("editor:object-exported", M), M;
|
|
2251
2205
|
}
|
|
2252
|
-
const
|
|
2206
|
+
const O = new File([b], y, { type: m }), S = {
|
|
2253
2207
|
object: c,
|
|
2254
|
-
image:
|
|
2208
|
+
image: O,
|
|
2255
2209
|
format: p,
|
|
2256
2210
|
contentType: m,
|
|
2257
2211
|
fileName: y
|
|
2258
2212
|
};
|
|
2259
2213
|
return a.fire("editor:object-exported", S), S;
|
|
2260
|
-
} catch (
|
|
2214
|
+
} catch (A) {
|
|
2261
2215
|
return this.editor.errorManager.emitError({
|
|
2262
2216
|
origin: "ImageManager",
|
|
2263
2217
|
method: "exportObjectAsImageFile",
|
|
2264
2218
|
code: "IMAGE_EXPORT_FAILED",
|
|
2265
|
-
message: `Ошибка экспорта объекта: ${
|
|
2219
|
+
message: `Ошибка экспорта объекта: ${A.message}`,
|
|
2266
2220
|
data: {
|
|
2267
2221
|
contentType: m,
|
|
2268
2222
|
fileName: y,
|
|
@@ -2284,7 +2238,7 @@ class pt {
|
|
|
2284
2238
|
* @returns массив допустимых форматов изображений
|
|
2285
2239
|
*/
|
|
2286
2240
|
getAllowedFormatsFromContentTypes() {
|
|
2287
|
-
return this.acceptContentTypes.map((t) =>
|
|
2241
|
+
return this.acceptContentTypes.map((t) => mt.getFormatFromContentType(t)).filter((t) => t);
|
|
2288
2242
|
}
|
|
2289
2243
|
/**
|
|
2290
2244
|
* Проверяет, является ли contentType допустимым типом изображения.
|
|
@@ -2337,7 +2291,7 @@ class pt {
|
|
|
2337
2291
|
try {
|
|
2338
2292
|
const s = (e = new URL(t).pathname.split(".").pop()) == null ? void 0 : e.toLowerCase(), o = {};
|
|
2339
2293
|
return this.acceptContentTypes.forEach((i) => {
|
|
2340
|
-
const a =
|
|
2294
|
+
const a = mt.getFormatFromContentType(i);
|
|
2341
2295
|
a && (o[a] = i);
|
|
2342
2296
|
}), s && o[s] || "application/octet-stream";
|
|
2343
2297
|
} catch (n) {
|
|
@@ -2390,11 +2344,11 @@ class pt {
|
|
|
2390
2344
|
return e ? e[1] : "";
|
|
2391
2345
|
}
|
|
2392
2346
|
}
|
|
2393
|
-
const
|
|
2394
|
-
function
|
|
2347
|
+
const It = (h, t, e) => Math.max(Math.min(h, e), t), cn = (h, t) => h * t, us = (h, t) => new lt(h / 2, t / 2);
|
|
2348
|
+
function fs(h) {
|
|
2395
2349
|
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";
|
|
2396
2350
|
}
|
|
2397
|
-
class
|
|
2351
|
+
class gs {
|
|
2398
2352
|
/**
|
|
2399
2353
|
* @param options
|
|
2400
2354
|
* @param options.editor – экземпляр редактора
|
|
@@ -2414,11 +2368,11 @@ class fs {
|
|
|
2414
2368
|
* Если точка находится за пределами монтажной области, она проецируется на ближайшую границу монтажной области.
|
|
2415
2369
|
*/
|
|
2416
2370
|
getVisibleCenterPoint() {
|
|
2417
|
-
const { canvas: t, montageArea: e } = this.editor, n = t.getZoom(), s = t.viewportTransform, o = t.getWidth(), i = t.getHeight(), a = (o / 2 - s[4]) / n, r = (i / 2 - s[5]) / n, c = e.width / 2, l = e.height / 2, d =
|
|
2371
|
+
const { canvas: t, montageArea: e } = this.editor, n = t.getZoom(), s = t.viewportTransform, o = t.getWidth(), i = t.getHeight(), a = (o / 2 - s[4]) / n, r = (i / 2 - s[5]) / n, c = e.width / 2, l = e.height / 2, d = It(
|
|
2418
2372
|
a,
|
|
2419
2373
|
e.left - c,
|
|
2420
2374
|
e.left + c
|
|
2421
|
-
), u =
|
|
2375
|
+
), u = It(
|
|
2422
2376
|
r,
|
|
2423
2377
|
e.top - l,
|
|
2424
2378
|
e.top + l
|
|
@@ -2441,9 +2395,9 @@ class fs {
|
|
|
2441
2395
|
canvas: o,
|
|
2442
2396
|
montageArea: i,
|
|
2443
2397
|
options: { canvasBackstoreWidth: a }
|
|
2444
|
-
} = this.editor, { width: r, height: c } = i, l =
|
|
2398
|
+
} = this.editor, { width: r, height: c } = i, l = It(Number(t), $t, zt);
|
|
2445
2399
|
if (!a || a === "auto" || s ? this.adaptCanvasToContainer() : a ? this.setCanvasBackstoreWidth(Number(a)) : this.setCanvasBackstoreWidth(l), i.set({ width: l }), (g = o.clipPath) == null || g.set({ width: l }), e) {
|
|
2446
|
-
const m = l / r, p =
|
|
2400
|
+
const m = l / r, p = cn(c, m);
|
|
2447
2401
|
this.setResolutionHeight(p);
|
|
2448
2402
|
return;
|
|
2449
2403
|
}
|
|
@@ -2471,9 +2425,9 @@ class fs {
|
|
|
2471
2425
|
canvas: o,
|
|
2472
2426
|
montageArea: i,
|
|
2473
2427
|
options: { canvasBackstoreHeight: a }
|
|
2474
|
-
} = this.editor, { width: r, height: c } = i, l =
|
|
2428
|
+
} = this.editor, { width: r, height: c } = i, l = It(Number(t), te, Ft);
|
|
2475
2429
|
if (!a || a === "auto" || s ? this.adaptCanvasToContainer() : a ? this.setCanvasBackstoreHeight(Number(a)) : this.setCanvasBackstoreHeight(l), i.set({ height: l }), (g = o.clipPath) == null || g.set({ height: l }), e) {
|
|
2476
|
-
const m = l / c, p =
|
|
2430
|
+
const m = l / c, p = cn(r, m);
|
|
2477
2431
|
this.setResolutionWidth(p);
|
|
2478
2432
|
return;
|
|
2479
2433
|
}
|
|
@@ -2491,7 +2445,7 @@ class fs {
|
|
|
2491
2445
|
*/
|
|
2492
2446
|
centerMontageArea() {
|
|
2493
2447
|
var r;
|
|
2494
|
-
const { canvas: t, montageArea: e } = this.editor, n = t.getWidth(), s = t.getHeight(), o = t.getZoom(), i =
|
|
2448
|
+
const { canvas: t, montageArea: e } = this.editor, n = t.getWidth(), s = t.getHeight(), o = t.getZoom(), i = us(n, s);
|
|
2495
2449
|
e.set({
|
|
2496
2450
|
left: n / 2,
|
|
2497
2451
|
top: s / 2
|
|
@@ -2524,7 +2478,7 @@ class fs {
|
|
|
2524
2478
|
*/
|
|
2525
2479
|
setCanvasBackstoreWidth(t) {
|
|
2526
2480
|
if (!t || typeof t != "number") return;
|
|
2527
|
-
const e =
|
|
2481
|
+
const e = It(t, $t, zt);
|
|
2528
2482
|
this.editor.canvas.setDimensions({ width: e }, { backstoreOnly: !0 });
|
|
2529
2483
|
}
|
|
2530
2484
|
/**
|
|
@@ -2533,7 +2487,7 @@ class fs {
|
|
|
2533
2487
|
*/
|
|
2534
2488
|
setCanvasBackstoreHeight(t) {
|
|
2535
2489
|
if (!t || typeof t != "number") return;
|
|
2536
|
-
const e =
|
|
2490
|
+
const e = It(t, te, Ft);
|
|
2537
2491
|
this.editor.canvas.setDimensions({ height: e }, { backstoreOnly: !0 });
|
|
2538
2492
|
}
|
|
2539
2493
|
/**
|
|
@@ -2542,7 +2496,7 @@ class fs {
|
|
|
2542
2496
|
* с учётом минимальных и максимальных значений.
|
|
2543
2497
|
*/
|
|
2544
2498
|
adaptCanvasToContainer() {
|
|
2545
|
-
const { canvas: t } = this.editor, e = this.getEditorContainer(), n = e.clientWidth, s = e.clientHeight, o =
|
|
2499
|
+
const { canvas: t } = this.editor, e = this.getEditorContainer(), n = e.clientWidth, s = e.clientHeight, o = It(n, $t, zt), i = It(s, te, Ft);
|
|
2546
2500
|
t.setDimensions({ width: o, height: i }, { backstoreOnly: !0 });
|
|
2547
2501
|
}
|
|
2548
2502
|
/**
|
|
@@ -2742,9 +2696,9 @@ class fs {
|
|
|
2742
2696
|
montageAreaHeight: r
|
|
2743
2697
|
}
|
|
2744
2698
|
} = this.editor, c = t || s.getActiveObject();
|
|
2745
|
-
if (!
|
|
2699
|
+
if (!fs(c)) return;
|
|
2746
2700
|
const { width: l, height: d } = c;
|
|
2747
|
-
let u = Math.min(l, zt), f = Math.min(d,
|
|
2701
|
+
let u = Math.min(l, zt), f = Math.min(d, Ft);
|
|
2748
2702
|
if (e) {
|
|
2749
2703
|
const {
|
|
2750
2704
|
width: g,
|
|
@@ -2802,7 +2756,7 @@ class fs {
|
|
|
2802
2756
|
);
|
|
2803
2757
|
}
|
|
2804
2758
|
}
|
|
2805
|
-
class
|
|
2759
|
+
class ps {
|
|
2806
2760
|
constructor({ editor: t }) {
|
|
2807
2761
|
this.editor = t, this.options = t.options;
|
|
2808
2762
|
}
|
|
@@ -2813,7 +2767,7 @@ class gs {
|
|
|
2813
2767
|
* @param options.withoutSave - Не сохранять состояние
|
|
2814
2768
|
* @fires editor:object-rotated
|
|
2815
2769
|
*/
|
|
2816
|
-
rotate(t =
|
|
2770
|
+
rotate(t = ds, { withoutSave: e } = {}) {
|
|
2817
2771
|
const { canvas: n, historyManager: s } = this.editor, o = n.getActiveObject();
|
|
2818
2772
|
if (!o) return;
|
|
2819
2773
|
const i = o.angle + t;
|
|
@@ -2915,10 +2869,10 @@ class gs {
|
|
|
2915
2869
|
*/
|
|
2916
2870
|
_fitSingleObject(t, e) {
|
|
2917
2871
|
const { canvas: n, montageArea: s } = this.editor, { width: o, height: i, scaleX: a = 1, scaleY: r = 1, angle: c = 0 } = t, l = o * Math.abs(a), d = i * Math.abs(r), u = c * Math.PI / 180, f = Math.abs(Math.cos(u)), g = Math.abs(Math.sin(u)), m = l * f + d * g, p = l * g + d * f, y = s.width, v = s.height;
|
|
2918
|
-
let
|
|
2919
|
-
e === "contain" ?
|
|
2920
|
-
scaleX: a *
|
|
2921
|
-
scaleY: r *
|
|
2872
|
+
let A;
|
|
2873
|
+
e === "contain" ? A = Math.min(y / m, v / p) : A = Math.max(y / m, v / p), t.set({
|
|
2874
|
+
scaleX: a * A,
|
|
2875
|
+
scaleY: r * A
|
|
2922
2876
|
}), n.centerObject(t);
|
|
2923
2877
|
}
|
|
2924
2878
|
/**
|
|
@@ -2968,9 +2922,9 @@ class gs {
|
|
|
2968
2922
|
});
|
|
2969
2923
|
}
|
|
2970
2924
|
}
|
|
2971
|
-
class
|
|
2925
|
+
class ms {
|
|
2972
2926
|
constructor({ editor: t }) {
|
|
2973
|
-
this.editor = t, this.options = t.options, this.minZoom = this.options.minZoom ||
|
|
2927
|
+
this.editor = t, this.options = t.options, this.minZoom = this.options.minZoom || cs, this.maxZoom = this.options.maxZoom || ls, this.defaultZoom = this._normalizeDefaultZoom(this.options.defaultScale);
|
|
2974
2928
|
}
|
|
2975
2929
|
/**
|
|
2976
2930
|
* Приводит значение defaultZoom к числу с двумя знаками после запятой, а также учитывает минимальное и максимальное значения.
|
|
@@ -3038,8 +2992,8 @@ class ps {
|
|
|
3038
2992
|
_calculateEmptySpaceRatio(t) {
|
|
3039
2993
|
const { canvas: e, montageArea: n } = this.editor, s = e.viewportTransform, o = e.getWidth(), i = e.getHeight(), a = n.left - n.width / 2, r = n.left + n.width / 2, c = n.top - n.height / 2, l = n.top + n.height / 2, d = -s[4] / t, u = (-s[4] + o) / t, f = -s[5] / t, g = (-s[5] + i) / t, m = d < a, p = u > r, y = f < c, v = g > l;
|
|
3040
2994
|
if (!(m || p || y || v)) return 0;
|
|
3041
|
-
const b = Math.max(0, a - d),
|
|
3042
|
-
return Math.max(
|
|
2995
|
+
const b = Math.max(0, a - d), O = Math.max(0, u - r), S = Math.max(0, c - f), M = Math.max(0, g - l), w = Math.max(b, O), C = Math.max(S, M), j = w / o, I = C / i;
|
|
2996
|
+
return Math.max(j, I);
|
|
3043
2997
|
}
|
|
3044
2998
|
/**
|
|
3045
2999
|
* Вычисляет плавный шаг перемещения viewport к центру с ускорением
|
|
@@ -3055,8 +3009,8 @@ class ps {
|
|
|
3055
3009
|
const { canvas: i, montageArea: a } = this.editor, r = i.viewportTransform, c = i.getWidth(), l = i.getHeight(), d = t.x - r[4], u = t.y - r[5], f = Math.abs(s), g = e - n;
|
|
3056
3010
|
if (Math.abs(g) / f <= 0.1)
|
|
3057
3011
|
return { x: d, y: u };
|
|
3058
|
-
const p = c / 2, y = l / 2, v = a.left,
|
|
3059
|
-
return { x:
|
|
3012
|
+
const p = c / 2, y = l / 2, v = a.left, A = a.top, b = p - v * n, O = y - A * n, S = (b - r[4]) / (e - n), M = (O - r[5]) / (e - n), w = S * f, C = M * f, j = w * o, I = C * o, T = Math.abs(j) > Math.abs(d) ? d : j, k = Math.abs(I) > Math.abs(u) ? u : I;
|
|
3013
|
+
return { x: T, y: k };
|
|
3060
3014
|
}
|
|
3061
3015
|
/**
|
|
3062
3016
|
* Применяет плавное центрирование viewport при приближении к defaultZoom.
|
|
@@ -3068,7 +3022,7 @@ class ps {
|
|
|
3068
3022
|
* @returns true если центрирование было применено
|
|
3069
3023
|
* @private
|
|
3070
3024
|
*/
|
|
3071
|
-
_applyViewportCentering(t, e = !1, n =
|
|
3025
|
+
_applyViewportCentering(t, e = !1, n = an) {
|
|
3072
3026
|
const { canvas: s } = this.editor, o = this._getScaledMontageDimensions(t), i = s.getWidth(), a = s.getHeight(), r = o.width > i || o.height > a, c = this._calculateFitZoom(), l = t - c;
|
|
3073
3027
|
if (!(!r || l) && !e)
|
|
3074
3028
|
return !1;
|
|
@@ -3143,7 +3097,7 @@ class ps {
|
|
|
3143
3097
|
* @param options.pointY - Координата Y точки зума
|
|
3144
3098
|
* @fires editor:zoom-changed
|
|
3145
3099
|
*/
|
|
3146
|
-
zoom(t =
|
|
3100
|
+
zoom(t = an, e = {}) {
|
|
3147
3101
|
var f, g;
|
|
3148
3102
|
if (!t) return;
|
|
3149
3103
|
const { minZoom: n, maxZoom: s } = this, { canvas: o } = this.editor, i = t < 0, a = o.getZoom(), r = o.getCenterPoint(), c = (f = e.pointX) != null ? f : r.x, l = (g = e.pointY) != null ? g : r.y, d = new lt(c, l);
|
|
@@ -3181,7 +3135,7 @@ class ps {
|
|
|
3181
3135
|
}), this.editor.panConstraintManager.updateBounds();
|
|
3182
3136
|
}
|
|
3183
3137
|
}
|
|
3184
|
-
class
|
|
3138
|
+
class ys {
|
|
3185
3139
|
constructor({ editor: t }) {
|
|
3186
3140
|
this.editor = t, this.isBlocked = !1, this.overlayMask = null, this._createOverlay();
|
|
3187
3141
|
}
|
|
@@ -3238,7 +3192,7 @@ class ms {
|
|
|
3238
3192
|
}), t.upperCanvasEl.style.pointerEvents = "", t.lowerCanvasEl.style.pointerEvents = "", this.overlayMask.visible = !1, t.requestRenderAll(), t.fire("editor:enabled"), n.resumeHistory();
|
|
3239
3193
|
}
|
|
3240
3194
|
}
|
|
3241
|
-
class
|
|
3195
|
+
class Wt {
|
|
3242
3196
|
constructor({ editor: t }) {
|
|
3243
3197
|
this.editor = t, this.backgroundObject = null;
|
|
3244
3198
|
}
|
|
@@ -3301,8 +3255,8 @@ class Ft {
|
|
|
3301
3255
|
try {
|
|
3302
3256
|
const { historyManager: i } = this.editor, { backgroundObject: a } = this;
|
|
3303
3257
|
if (i.suspendHistory(), a && a.backgroundType === "gradient") {
|
|
3304
|
-
const r =
|
|
3305
|
-
if (
|
|
3258
|
+
const r = Wt._createFabricGradient(t);
|
|
3259
|
+
if (Wt._isGradientEqual(a.fill, r)) {
|
|
3306
3260
|
i.resumeHistory();
|
|
3307
3261
|
return;
|
|
3308
3262
|
}
|
|
@@ -3485,7 +3439,7 @@ class Ft {
|
|
|
3485
3439
|
backgroundType: "gradient",
|
|
3486
3440
|
backgroundId: `background-${et()}`
|
|
3487
3441
|
}, { withoutSelection: !0 }), this.refresh();
|
|
3488
|
-
const e =
|
|
3442
|
+
const e = Wt._createFabricGradient(t);
|
|
3489
3443
|
this.backgroundObject.set("fill", e), this.editor.canvas.requestRenderAll();
|
|
3490
3444
|
}
|
|
3491
3445
|
/**
|
|
@@ -3545,8 +3499,8 @@ class Ft {
|
|
|
3545
3499
|
{ offset: 0, color: "#000000" },
|
|
3546
3500
|
{ offset: 1, color: "#ffffff" }
|
|
3547
3501
|
], t.type === "linear") {
|
|
3548
|
-
const u = t.angle * Math.PI / 180, f =
|
|
3549
|
-
return new
|
|
3502
|
+
const u = t.angle * Math.PI / 180, f = Wt._angleToCoords(u);
|
|
3503
|
+
return new Qe({
|
|
3550
3504
|
type: "linear",
|
|
3551
3505
|
gradientUnits: "percentage",
|
|
3552
3506
|
coords: f,
|
|
@@ -3565,7 +3519,7 @@ class Ft {
|
|
|
3565
3519
|
r1: 0,
|
|
3566
3520
|
r2: l / 100
|
|
3567
3521
|
};
|
|
3568
|
-
return new
|
|
3522
|
+
return new Qe({
|
|
3569
3523
|
type: "radial",
|
|
3570
3524
|
gradientUnits: "percentage",
|
|
3571
3525
|
coords: d,
|
|
@@ -3600,7 +3554,7 @@ class Ft {
|
|
|
3600
3554
|
}) ? !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;
|
|
3601
3555
|
}
|
|
3602
3556
|
}
|
|
3603
|
-
class
|
|
3557
|
+
class me {
|
|
3604
3558
|
constructor({ editor: t }) {
|
|
3605
3559
|
this.editor = t;
|
|
3606
3560
|
}
|
|
@@ -3633,7 +3587,7 @@ class pe {
|
|
|
3633
3587
|
const { canvas: n, historyManager: s } = this.editor;
|
|
3634
3588
|
s.suspendHistory();
|
|
3635
3589
|
const o = t || n.getActiveObject();
|
|
3636
|
-
o && (o instanceof X ?
|
|
3590
|
+
o && (o instanceof X ? me._moveSelectionForward(n, o) : n.bringObjectForward(o), n.renderAll(), s.resumeHistory(), e || s.saveState(), n.fire("editor:object-bring-forward", {
|
|
3637
3591
|
object: o,
|
|
3638
3592
|
withoutSave: e
|
|
3639
3593
|
}));
|
|
@@ -3684,7 +3638,7 @@ class pe {
|
|
|
3684
3638
|
} = this.editor;
|
|
3685
3639
|
o.suspendHistory();
|
|
3686
3640
|
const r = t || n.getActiveObject();
|
|
3687
|
-
r && (r instanceof X ?
|
|
3641
|
+
r && (r instanceof X ? me._moveSelectionBackwards(n, r) : n.sendObjectBackwards(r), a && n.sendObjectToBack(a), n.sendObjectToBack(s), i && n.sendObjectToBack(i), n.renderAll(), o.resumeHistory(), e || o.saveState(), n.fire("editor:object-send-backwards", {
|
|
3688
3642
|
object: r,
|
|
3689
3643
|
withoutSave: e
|
|
3690
3644
|
}));
|
|
@@ -3728,7 +3682,7 @@ class pe {
|
|
|
3728
3682
|
});
|
|
3729
3683
|
}
|
|
3730
3684
|
}
|
|
3731
|
-
class
|
|
3685
|
+
class vs {
|
|
3732
3686
|
/**
|
|
3733
3687
|
* Менеджер фигур для редактора.
|
|
3734
3688
|
* @param options - Опции и настройки менеджера фигур.
|
|
@@ -3760,7 +3714,7 @@ class ys {
|
|
|
3760
3714
|
width: s = 100,
|
|
3761
3715
|
height: o = 100,
|
|
3762
3716
|
fill: i = "blue"
|
|
3763
|
-
} = d, a =
|
|
3717
|
+
} = d, a = Ct(d, [
|
|
3764
3718
|
"id",
|
|
3765
3719
|
"left",
|
|
3766
3720
|
"top",
|
|
@@ -3768,7 +3722,7 @@ class ys {
|
|
|
3768
3722
|
"height",
|
|
3769
3723
|
"fill"
|
|
3770
3724
|
]);
|
|
3771
|
-
const { canvas: u } = this.editor, f = new
|
|
3725
|
+
const { canvas: u } = this.editor, f = new Ln(F({
|
|
3772
3726
|
id: t,
|
|
3773
3727
|
left: e,
|
|
3774
3728
|
top: n,
|
|
@@ -3801,14 +3755,14 @@ class ys {
|
|
|
3801
3755
|
top: n,
|
|
3802
3756
|
radius: s = 50,
|
|
3803
3757
|
fill: o = "green"
|
|
3804
|
-
} = l, i =
|
|
3758
|
+
} = l, i = Ct(l, [
|
|
3805
3759
|
"id",
|
|
3806
3760
|
"left",
|
|
3807
3761
|
"top",
|
|
3808
3762
|
"radius",
|
|
3809
3763
|
"fill"
|
|
3810
3764
|
]);
|
|
3811
|
-
const { canvas: d } = this.editor, u = new
|
|
3765
|
+
const { canvas: d } = this.editor, u = new Dn(F({
|
|
3812
3766
|
id: t,
|
|
3813
3767
|
left: e,
|
|
3814
3768
|
top: n,
|
|
@@ -3842,7 +3796,7 @@ class ys {
|
|
|
3842
3796
|
width: s = 100,
|
|
3843
3797
|
height: o = 100,
|
|
3844
3798
|
fill: i = "yellow"
|
|
3845
|
-
} = d, a =
|
|
3799
|
+
} = d, a = Ct(d, [
|
|
3846
3800
|
"id",
|
|
3847
3801
|
"left",
|
|
3848
3802
|
"top",
|
|
@@ -3850,7 +3804,7 @@ class ys {
|
|
|
3850
3804
|
"height",
|
|
3851
3805
|
"fill"
|
|
3852
3806
|
]);
|
|
3853
|
-
const { canvas: u } = this.editor, f = new
|
|
3807
|
+
const { canvas: u } = this.editor, f = new xn(F({
|
|
3854
3808
|
id: t,
|
|
3855
3809
|
left: e,
|
|
3856
3810
|
top: n,
|
|
@@ -3861,7 +3815,7 @@ class ys {
|
|
|
3861
3815
|
return !e && !n && u.centerObject(f), c || (u.add(f), r || u.setActiveObject(f), u.renderAll()), f;
|
|
3862
3816
|
}
|
|
3863
3817
|
}
|
|
3864
|
-
class
|
|
3818
|
+
class bs {
|
|
3865
3819
|
/**
|
|
3866
3820
|
* @param options
|
|
3867
3821
|
* @param options.editor - экземпляр редактора с доступом к canvas
|
|
@@ -3892,7 +3846,7 @@ class vs {
|
|
|
3892
3846
|
return G(this, null, function* () {
|
|
3893
3847
|
const { canvas: e, errorManager: n } = this.editor;
|
|
3894
3848
|
try {
|
|
3895
|
-
const s = yield t.clone(
|
|
3849
|
+
const s = yield t.clone(he);
|
|
3896
3850
|
this.clipboard = s, e.fire("editor:object-copied", { object: s });
|
|
3897
3851
|
} catch (s) {
|
|
3898
3852
|
n.emitError({
|
|
@@ -3919,7 +3873,7 @@ class vs {
|
|
|
3919
3873
|
message: "navigator.clipboard не поддерживается в этом браузере или отсутствует HTTPS-соединение."
|
|
3920
3874
|
}), !1;
|
|
3921
3875
|
try {
|
|
3922
|
-
const n = t.toObject(
|
|
3876
|
+
const n = t.toObject(he), s = JSON.stringify(n);
|
|
3923
3877
|
return t.type === "image" ? this._copyImageToClipboard(t, s) : this._copyTextToClipboard(s);
|
|
3924
3878
|
} catch (n) {
|
|
3925
3879
|
return e.emitError({
|
|
@@ -3960,7 +3914,7 @@ class vs {
|
|
|
3960
3914
|
_copyTextToClipboard(t) {
|
|
3961
3915
|
return G(this, null, function* () {
|
|
3962
3916
|
try {
|
|
3963
|
-
const e = `${
|
|
3917
|
+
const e = `${rn}${t}`;
|
|
3964
3918
|
return yield navigator.clipboard.writeText(e), console.info("Text copied to clipboard successfully"), !0;
|
|
3965
3919
|
} catch (e) {
|
|
3966
3920
|
const { errorManager: n } = this.editor;
|
|
@@ -4013,7 +3967,7 @@ class vs {
|
|
|
4013
3967
|
const { canvas: e } = this.editor, n = t || e.getActiveObject();
|
|
4014
3968
|
if (!n || n.locked) return !1;
|
|
4015
3969
|
try {
|
|
4016
|
-
const s = yield n.clone(
|
|
3970
|
+
const s = yield n.clone(he);
|
|
4017
3971
|
return s instanceof X && s.forEachObject((o) => {
|
|
4018
3972
|
o.set({
|
|
4019
3973
|
id: `${o.type}-${et()}`,
|
|
@@ -4051,7 +4005,7 @@ class vs {
|
|
|
4051
4005
|
return;
|
|
4052
4006
|
}
|
|
4053
4007
|
const n = t.getData("text/plain");
|
|
4054
|
-
if (n && n.startsWith(
|
|
4008
|
+
if (n && n.startsWith(rn)) {
|
|
4055
4009
|
this.paste();
|
|
4056
4010
|
return;
|
|
4057
4011
|
}
|
|
@@ -4099,7 +4053,7 @@ class vs {
|
|
|
4099
4053
|
const { canvas: t } = this.editor;
|
|
4100
4054
|
if (!this.clipboard) return !1;
|
|
4101
4055
|
try {
|
|
4102
|
-
const e = yield this.clipboard.clone(
|
|
4056
|
+
const e = yield this.clipboard.clone(he);
|
|
4103
4057
|
return t.discardActiveObject(), e instanceof X && e.forEachObject((n) => {
|
|
4104
4058
|
n.set({
|
|
4105
4059
|
id: `${n.type}-${et()}`,
|
|
@@ -4124,7 +4078,7 @@ class vs {
|
|
|
4124
4078
|
});
|
|
4125
4079
|
}
|
|
4126
4080
|
}
|
|
4127
|
-
class
|
|
4081
|
+
class ye {
|
|
4128
4082
|
constructor({ editor: t }) {
|
|
4129
4083
|
this.editor = t;
|
|
4130
4084
|
}
|
|
@@ -4150,7 +4104,7 @@ class me {
|
|
|
4150
4104
|
editable: !1,
|
|
4151
4105
|
locked: !0
|
|
4152
4106
|
};
|
|
4153
|
-
i.set(a), !e &&
|
|
4107
|
+
i.set(a), !e && ye._isGroupOrSelection(i) && i.getObjects().forEach((c) => {
|
|
4154
4108
|
c.set(a);
|
|
4155
4109
|
}), i instanceof ct && i.isEditing && i.exitEditing(), s.renderAll(), n || o.saveState(), s.fire("editor:object-locked", {
|
|
4156
4110
|
object: i,
|
|
@@ -4179,7 +4133,7 @@ class me {
|
|
|
4179
4133
|
editable: !0,
|
|
4180
4134
|
locked: !1
|
|
4181
4135
|
};
|
|
4182
|
-
o.set(i),
|
|
4136
|
+
o.set(i), ye._isGroupOrSelection(o) && o.getObjects().forEach((a) => {
|
|
4183
4137
|
a.set(i);
|
|
4184
4138
|
}), n.renderAll(), e || s.saveState(), n.fire("editor:object-unlocked", {
|
|
4185
4139
|
object: o,
|
|
@@ -4187,10 +4141,10 @@ class me {
|
|
|
4187
4141
|
});
|
|
4188
4142
|
}
|
|
4189
4143
|
static _isGroupOrSelection(t) {
|
|
4190
|
-
return t instanceof X || t instanceof
|
|
4144
|
+
return t instanceof X || t instanceof Pt;
|
|
4191
4145
|
}
|
|
4192
4146
|
}
|
|
4193
|
-
class
|
|
4147
|
+
class Ms {
|
|
4194
4148
|
constructor({ editor: t }) {
|
|
4195
4149
|
this.editor = t;
|
|
4196
4150
|
}
|
|
@@ -4210,20 +4164,20 @@ class bs {
|
|
|
4210
4164
|
*/
|
|
4211
4165
|
_getGroupsToUngroup(t) {
|
|
4212
4166
|
if (Array.isArray(t)) {
|
|
4213
|
-
const n = t.filter((s) => s instanceof
|
|
4167
|
+
const n = t.filter((s) => s instanceof Pt);
|
|
4214
4168
|
return n.length > 0 ? n : null;
|
|
4215
4169
|
}
|
|
4216
4170
|
if (t instanceof X) {
|
|
4217
|
-
const n = t.getObjects().filter((s) => s instanceof
|
|
4171
|
+
const n = t.getObjects().filter((s) => s instanceof Pt);
|
|
4218
4172
|
return n.length > 0 ? n : null;
|
|
4219
4173
|
}
|
|
4220
4174
|
const e = t || this.editor.canvas.getActiveObject();
|
|
4221
4175
|
if (!e) return null;
|
|
4222
4176
|
if (e instanceof X) {
|
|
4223
|
-
const n = e.getObjects().filter((s) => s instanceof
|
|
4177
|
+
const n = e.getObjects().filter((s) => s instanceof Pt);
|
|
4224
4178
|
return n.length > 0 ? n : null;
|
|
4225
4179
|
}
|
|
4226
|
-
return e instanceof
|
|
4180
|
+
return e instanceof Pt ? [e] : null;
|
|
4227
4181
|
}
|
|
4228
4182
|
/**
|
|
4229
4183
|
* Группировка объектов
|
|
@@ -4240,7 +4194,7 @@ class bs {
|
|
|
4240
4194
|
if (!o) return null;
|
|
4241
4195
|
try {
|
|
4242
4196
|
s.suspendHistory();
|
|
4243
|
-
const i = new
|
|
4197
|
+
const i = new Pt(o, {
|
|
4244
4198
|
id: `group-${et()}`
|
|
4245
4199
|
});
|
|
4246
4200
|
o.forEach((r) => n.remove(r)), n.add(i), n.setActiveObject(i), n.requestRenderAll();
|
|
@@ -4291,9 +4245,9 @@ class bs {
|
|
|
4291
4245
|
}
|
|
4292
4246
|
}
|
|
4293
4247
|
}
|
|
4294
|
-
class
|
|
4248
|
+
class ft {
|
|
4295
4249
|
constructor({ editor: t }) {
|
|
4296
|
-
this.editor = t;
|
|
4250
|
+
this.lastSelection = [], this.isCtrlSelectionBoxActive = !1, this.isSelectionMergeInProgress = !1, this.editor = t, this.selectionKey = this._resolveSelectionKey(), this.handleTextEditingEnteredBound = this._handleTextEditingEntered.bind(this), this.handleTextEditingExitedBound = this._handleTextEditingExited.bind(this), this.handleLockedSelectionBound = this._filterLockedSelection.bind(this), this.handleSelectionMergeBound = this._handleSelectionMerge.bind(this), this.handleSelectionChangeBound = this._handleSelectionChange.bind(this), this.handleSelectionClearedBound = this._handleSelectionCleared.bind(this), this.handleSelectionBoxStartBound = this._handleSelectionBoxStart.bind(this), this.handleSelectionBoxEndBound = this._handleSelectionBoxEnd.bind(this), this._applySelectionKey({ selectionKey: this.selectionKey }), this._bindEvents();
|
|
4297
4251
|
}
|
|
4298
4252
|
/**
|
|
4299
4253
|
* Выделить все объекты
|
|
@@ -4305,8 +4259,286 @@ class Ms {
|
|
|
4305
4259
|
const s = e.getObjects(), o = s.some((a) => a.locked), i = s.length > 1 ? new X(e.getObjects(), { canvas: t }) : s[0];
|
|
4306
4260
|
o && n.lockObject({ object: i, skipInnerObjects: !0, withoutSave: !0 }), t.setActiveObject(i), t.requestRenderAll(), t.fire("editor:all-objects-selected", { selected: i });
|
|
4307
4261
|
}
|
|
4262
|
+
/**
|
|
4263
|
+
* Снимает подписки SelectionManager.
|
|
4264
|
+
*/
|
|
4265
|
+
destroy() {
|
|
4266
|
+
const { canvas: t } = this.editor;
|
|
4267
|
+
t.off("mouse:down", this.handleSelectionBoxStartBound), t.off("mouse:up", this.handleSelectionBoxEndBound), t.off("text:editing:entered", this.handleTextEditingEnteredBound), t.off("text:editing:exited", this.handleTextEditingExitedBound), t.off("selection:created", this.handleSelectionMergeBound), t.off("selection:updated", this.handleSelectionMergeBound), t.off("selection:created", this.handleLockedSelectionBound), t.off("selection:updated", this.handleLockedSelectionBound), t.off("selection:created", this.handleSelectionChangeBound), t.off("selection:updated", this.handleSelectionChangeBound), t.off("selection:cleared", this.handleSelectionClearedBound);
|
|
4268
|
+
}
|
|
4269
|
+
/**
|
|
4270
|
+
* Назначает ключ для мультивыделения.
|
|
4271
|
+
*/
|
|
4272
|
+
_applySelectionKey({ selectionKey: t }) {
|
|
4273
|
+
const { canvas: e } = this.editor;
|
|
4274
|
+
e.selectionKey = t;
|
|
4275
|
+
}
|
|
4276
|
+
/**
|
|
4277
|
+
* Подписывается на события редактирования текста и выделения объектов.
|
|
4278
|
+
*/
|
|
4279
|
+
_bindEvents() {
|
|
4280
|
+
const { canvas: t } = this.editor;
|
|
4281
|
+
t.on("text:editing:entered", this.handleTextEditingEnteredBound), t.on("text:editing:exited", this.handleTextEditingExitedBound), t.on("mouse:down", this.handleSelectionBoxStartBound), t.on("mouse:up", this.handleSelectionBoxEndBound), t.on("selection:created", this.handleSelectionMergeBound), t.on("selection:updated", this.handleSelectionMergeBound), t.on("selection:created", this.handleLockedSelectionBound), t.on("selection:updated", this.handleLockedSelectionBound), t.on("selection:created", this.handleSelectionChangeBound), t.on("selection:updated", this.handleSelectionChangeBound), t.on("selection:cleared", this.handleSelectionClearedBound);
|
|
4282
|
+
}
|
|
4283
|
+
/**
|
|
4284
|
+
* Отключает мультивыделение при входе в режим редактирования текста.
|
|
4285
|
+
*/
|
|
4286
|
+
_handleTextEditingEntered(t) {
|
|
4287
|
+
this._applySelectionKey({ selectionKey: null });
|
|
4288
|
+
}
|
|
4289
|
+
/**
|
|
4290
|
+
* Восстанавливает мультивыделение после выхода из редактирования текста.
|
|
4291
|
+
*/
|
|
4292
|
+
_handleTextEditingExited(t) {
|
|
4293
|
+
const { selectionKey: e } = this;
|
|
4294
|
+
this._applySelectionKey({ selectionKey: e });
|
|
4295
|
+
}
|
|
4296
|
+
/**
|
|
4297
|
+
* При массовом выделении объектов удаляет из него залоченные.
|
|
4298
|
+
* @param params - параметры события
|
|
4299
|
+
* @param params.selected - массив выделенных объектов
|
|
4300
|
+
* @param params.e - событие указателя (опционально)
|
|
4301
|
+
*/
|
|
4302
|
+
_filterLockedSelection({ selected: t, e }) {
|
|
4303
|
+
const { editor: n } = this, { canvas: s } = n;
|
|
4304
|
+
if (!(e instanceof MouseEvent)) return;
|
|
4305
|
+
const o = s.getActiveObject();
|
|
4306
|
+
if (!o) return;
|
|
4307
|
+
const i = ft._collectSelectionObjects({ activeObject: o });
|
|
4308
|
+
if (i.length <= 1) return;
|
|
4309
|
+
const { lockedObjects: a, unlockedObjects: r } = ft._splitLockedObjects({ objects: i });
|
|
4310
|
+
if (a.length !== 0) {
|
|
4311
|
+
if (r.length > 0) {
|
|
4312
|
+
const c = t != null ? t : [];
|
|
4313
|
+
if (ft._shouldKeepLockedSelection({
|
|
4314
|
+
addedObjects: c,
|
|
4315
|
+
currentSelection: i,
|
|
4316
|
+
pointerEvent: e
|
|
4317
|
+
})) {
|
|
4318
|
+
this._applySelectionObjects({ objects: a }), s.requestRenderAll();
|
|
4319
|
+
return;
|
|
4320
|
+
}
|
|
4321
|
+
this._applySelectionObjects({ objects: r }), s.requestRenderAll();
|
|
4322
|
+
return;
|
|
4323
|
+
}
|
|
4324
|
+
this._applySelectionObjects({ objects: a }), s.requestRenderAll();
|
|
4325
|
+
}
|
|
4326
|
+
}
|
|
4327
|
+
/**
|
|
4328
|
+
* Объединяет выделение при выделении областью с зажатым Ctrl/Cmd.
|
|
4329
|
+
* @param params - параметры события
|
|
4330
|
+
* @param params.selected - массив новых объектов выделения
|
|
4331
|
+
* @param params.e - событие указателя (опционально)
|
|
4332
|
+
*/
|
|
4333
|
+
_handleSelectionMerge({
|
|
4334
|
+
selected: t,
|
|
4335
|
+
e
|
|
4336
|
+
}) {
|
|
4337
|
+
const { canvas: n } = this.editor, { lastSelection: s, isCtrlSelectionBoxActive: o, isSelectionMergeInProgress: i } = this;
|
|
4338
|
+
if (i || !o || !(e instanceof MouseEvent)) return;
|
|
4339
|
+
const { ctrlKey: a, metaKey: r } = e;
|
|
4340
|
+
if (!!!(a || r) || s.length === 0 || t.length === 0) return;
|
|
4341
|
+
const l = n.getActiveObject(), d = ft._collectSelectionObjects({ activeObject: l });
|
|
4342
|
+
if (d.length === 0) return;
|
|
4343
|
+
const u = s, g = ft._isSelectionLockedOnly({ objects: u }) ? ft._filterLockedSelectionObjects({ objects: d }) : d, m = ft._mergeSelections({
|
|
4344
|
+
baseSelection: u,
|
|
4345
|
+
addedSelection: g
|
|
4346
|
+
});
|
|
4347
|
+
if (ft._areSelectionsEqual({
|
|
4348
|
+
left: m,
|
|
4349
|
+
right: d
|
|
4350
|
+
})) {
|
|
4351
|
+
this.isCtrlSelectionBoxActive = !1;
|
|
4352
|
+
return;
|
|
4353
|
+
}
|
|
4354
|
+
this.isSelectionMergeInProgress = !0, this._applySelectionObjects({ objects: m }), n.requestRenderAll(), this.isSelectionMergeInProgress = !1, this.isCtrlSelectionBoxActive = !1;
|
|
4355
|
+
}
|
|
4356
|
+
/**
|
|
4357
|
+
* Обрабатывает начало выделения областью при зажатом Ctrl/Cmd.
|
|
4358
|
+
* @param options - объект события fabric
|
|
4359
|
+
*/
|
|
4360
|
+
_handleSelectionBoxStart({ e: t, target: e }) {
|
|
4361
|
+
if (!(t instanceof MouseEvent) || e) return;
|
|
4362
|
+
const { editor: n } = this, { canvas: s, textManager: o } = n;
|
|
4363
|
+
if (!s.selection || o.isTextEditingActive) return;
|
|
4364
|
+
const { ctrlKey: i, metaKey: a } = t;
|
|
4365
|
+
if (!!!(i || a)) return;
|
|
4366
|
+
const c = s.getActiveObject(), l = ft._collectSelectionObjects({ activeObject: c });
|
|
4367
|
+
this.lastSelection = l.slice(), this.isCtrlSelectionBoxActive = l.length > 0;
|
|
4368
|
+
}
|
|
4369
|
+
/**
|
|
4370
|
+
* Сбрасывает флаг выделения областью при зажатом Ctrl/Cmd.
|
|
4371
|
+
* @param options - объект события fabric
|
|
4372
|
+
*/
|
|
4373
|
+
_handleSelectionBoxEnd({ e: t }) {
|
|
4374
|
+
t instanceof MouseEvent && (this.isCtrlSelectionBoxActive = !1);
|
|
4375
|
+
}
|
|
4376
|
+
/**
|
|
4377
|
+
* Сохраняет текущее выделение для возможного восстановления.
|
|
4378
|
+
*/
|
|
4379
|
+
_handleSelectionChange() {
|
|
4380
|
+
const { canvas: t } = this.editor, e = t.getActiveObject(), n = ft._collectSelectionObjects({ activeObject: e });
|
|
4381
|
+
this.lastSelection = n.slice();
|
|
4382
|
+
}
|
|
4383
|
+
/**
|
|
4384
|
+
* Восстанавливает выделение при клике по пустой области с зажатым Ctrl/Cmd.
|
|
4385
|
+
* @param params - параметры события
|
|
4386
|
+
* @param params.e - событие указателя (опционально)
|
|
4387
|
+
*/
|
|
4388
|
+
_handleSelectionCleared({ e: t }) {
|
|
4389
|
+
const { lastSelection: e } = this;
|
|
4390
|
+
if (e.length === 0) return;
|
|
4391
|
+
if (!(t instanceof MouseEvent)) {
|
|
4392
|
+
this.lastSelection = [];
|
|
4393
|
+
return;
|
|
4394
|
+
}
|
|
4395
|
+
const { ctrlKey: n, metaKey: s } = t;
|
|
4396
|
+
if (!!!(n || s)) {
|
|
4397
|
+
this.lastSelection = [];
|
|
4398
|
+
return;
|
|
4399
|
+
}
|
|
4400
|
+
const i = this._filterExistingObjects({ objects: e });
|
|
4401
|
+
if (i.length === 0) {
|
|
4402
|
+
this.lastSelection = [];
|
|
4403
|
+
return;
|
|
4404
|
+
}
|
|
4405
|
+
this._applySelectionObjects({ objects: i });
|
|
4406
|
+
}
|
|
4407
|
+
/**
|
|
4408
|
+
* Собирает объекты активного выделения.
|
|
4409
|
+
*/
|
|
4410
|
+
static _collectSelectionObjects({ activeObject: t }) {
|
|
4411
|
+
return t ? t instanceof X ? t.getObjects() : [t] : [];
|
|
4412
|
+
}
|
|
4413
|
+
/**
|
|
4414
|
+
* Проверяет, что выборка состоит только из заблокированных объектов.
|
|
4415
|
+
*/
|
|
4416
|
+
static _isSelectionLockedOnly({ objects: t }) {
|
|
4417
|
+
if (t.length === 0) return !1;
|
|
4418
|
+
for (const e of t)
|
|
4419
|
+
if (!e.locked) return !1;
|
|
4420
|
+
return !0;
|
|
4421
|
+
}
|
|
4422
|
+
/**
|
|
4423
|
+
* Оставляет только заблокированные объекты в выборке.
|
|
4424
|
+
*/
|
|
4425
|
+
static _filterLockedSelectionObjects({ objects: t }) {
|
|
4426
|
+
const e = [];
|
|
4427
|
+
for (const n of t)
|
|
4428
|
+
n.locked && e.push(n);
|
|
4429
|
+
return e;
|
|
4430
|
+
}
|
|
4431
|
+
/**
|
|
4432
|
+
* Фильтрует объекты, которые ещё существуют на канвасе.
|
|
4433
|
+
*/
|
|
4434
|
+
_filterExistingObjects({ objects: t }) {
|
|
4435
|
+
const { canvasManager: e } = this.editor, n = e.getObjects(), s = [];
|
|
4436
|
+
for (const o of t)
|
|
4437
|
+
n.includes(o) && s.push(o);
|
|
4438
|
+
return s;
|
|
4439
|
+
}
|
|
4440
|
+
/**
|
|
4441
|
+
* Проверяет равенство двух выборок без учёта порядка.
|
|
4442
|
+
*/
|
|
4443
|
+
static _areSelectionsEqual({
|
|
4444
|
+
left: t,
|
|
4445
|
+
right: e
|
|
4446
|
+
}) {
|
|
4447
|
+
if (t.length !== e.length) return !1;
|
|
4448
|
+
if (t.length === 0) return !0;
|
|
4449
|
+
for (const n of t)
|
|
4450
|
+
if (!e.includes(n)) return !1;
|
|
4451
|
+
return !0;
|
|
4452
|
+
}
|
|
4453
|
+
/**
|
|
4454
|
+
* Объединяет список объектов без дубликатов.
|
|
4455
|
+
*/
|
|
4456
|
+
static _mergeSelections({
|
|
4457
|
+
baseSelection: t,
|
|
4458
|
+
addedSelection: e
|
|
4459
|
+
}) {
|
|
4460
|
+
const n = [];
|
|
4461
|
+
for (const s of t)
|
|
4462
|
+
n.includes(s) || n.push(s);
|
|
4463
|
+
for (const s of e)
|
|
4464
|
+
n.includes(s) || n.push(s);
|
|
4465
|
+
return n;
|
|
4466
|
+
}
|
|
4467
|
+
/**
|
|
4468
|
+
* Делит объекты на заблокированные и доступные для редактирования.
|
|
4469
|
+
*/
|
|
4470
|
+
static _splitLockedObjects({
|
|
4471
|
+
objects: t
|
|
4472
|
+
}) {
|
|
4473
|
+
const e = [], n = [];
|
|
4474
|
+
for (const s of t) {
|
|
4475
|
+
if (s.locked) {
|
|
4476
|
+
e.push(s);
|
|
4477
|
+
continue;
|
|
4478
|
+
}
|
|
4479
|
+
n.push(s);
|
|
4480
|
+
}
|
|
4481
|
+
return { lockedObjects: e, unlockedObjects: n };
|
|
4482
|
+
}
|
|
4483
|
+
/**
|
|
4484
|
+
* Определяет, нужно ли сохранить только заблокированное выделение при попытке добавить обычные объекты.
|
|
4485
|
+
*/
|
|
4486
|
+
static _shouldKeepLockedSelection({
|
|
4487
|
+
addedObjects: t,
|
|
4488
|
+
currentSelection: e,
|
|
4489
|
+
pointerEvent: n
|
|
4490
|
+
}) {
|
|
4491
|
+
const { ctrlKey: s, metaKey: o } = n;
|
|
4492
|
+
if (!!!(s || o) || t.length === 0) return !1;
|
|
4493
|
+
let a = !1;
|
|
4494
|
+
for (const c of t)
|
|
4495
|
+
if (!c.locked) {
|
|
4496
|
+
a = !0;
|
|
4497
|
+
break;
|
|
4498
|
+
}
|
|
4499
|
+
if (!a) return !1;
|
|
4500
|
+
const r = [];
|
|
4501
|
+
for (const c of e)
|
|
4502
|
+
t.includes(c) || r.push(c);
|
|
4503
|
+
if (r.length === 0) return !1;
|
|
4504
|
+
for (const c of r)
|
|
4505
|
+
if (!c.locked) return !1;
|
|
4506
|
+
return !0;
|
|
4507
|
+
}
|
|
4508
|
+
/**
|
|
4509
|
+
* Применяет выделение и блокирует его, если в нём есть заблокированные объекты.
|
|
4510
|
+
*/
|
|
4511
|
+
_applySelectionObjects({ objects: t }) {
|
|
4512
|
+
const { editor: e } = this, { canvas: n, objectLockManager: s } = e, o = this._filterExistingObjects({ objects: t });
|
|
4513
|
+
if (o.length === 0) return;
|
|
4514
|
+
if (o.length === 1) {
|
|
4515
|
+
n.setActiveObject(o[0]);
|
|
4516
|
+
return;
|
|
4517
|
+
}
|
|
4518
|
+
const i = new X(o, { canvas: n });
|
|
4519
|
+
ft._hasLockedObjects({ objects: o }) && s.lockObject({
|
|
4520
|
+
object: i,
|
|
4521
|
+
skipInnerObjects: !0,
|
|
4522
|
+
withoutSave: !0
|
|
4523
|
+
}), n.setActiveObject(i);
|
|
4524
|
+
}
|
|
4525
|
+
/**
|
|
4526
|
+
* Проверяет, есть ли среди объектов заблокированные.
|
|
4527
|
+
*/
|
|
4528
|
+
static _hasLockedObjects({ objects: t }) {
|
|
4529
|
+
for (const e of t)
|
|
4530
|
+
if (e.locked) return !0;
|
|
4531
|
+
return !1;
|
|
4532
|
+
}
|
|
4533
|
+
/**
|
|
4534
|
+
* Определяет ключи для мультивыделения.
|
|
4535
|
+
*/
|
|
4536
|
+
_resolveSelectionKey() {
|
|
4537
|
+
const { options: t } = this.editor, { selectionKey: e } = t;
|
|
4538
|
+
return e !== void 0 ? e : ["ctrlKey", "metaKey"];
|
|
4539
|
+
}
|
|
4308
4540
|
}
|
|
4309
|
-
class
|
|
4541
|
+
class Ue {
|
|
4310
4542
|
constructor({ editor: t }) {
|
|
4311
4543
|
this.editor = t;
|
|
4312
4544
|
}
|
|
@@ -4353,7 +4585,7 @@ class We {
|
|
|
4353
4585
|
n || o.suspendHistory();
|
|
4354
4586
|
const r = [];
|
|
4355
4587
|
if (a.forEach((l) => {
|
|
4356
|
-
if (
|
|
4588
|
+
if (Ue._isUngroupableGroup(l)) {
|
|
4357
4589
|
const d = this._handleGroupDeletion(l);
|
|
4358
4590
|
r.push(...d);
|
|
4359
4591
|
return;
|
|
@@ -4368,7 +4600,7 @@ class We {
|
|
|
4368
4600
|
return s.fire("editor:objects-deleted", c), c;
|
|
4369
4601
|
}
|
|
4370
4602
|
}
|
|
4371
|
-
const
|
|
4603
|
+
const Lt = {
|
|
4372
4604
|
IMAGE_MANAGER: {
|
|
4373
4605
|
/**
|
|
4374
4606
|
* Некорректный Content-Type изображения
|
|
@@ -4473,7 +4705,7 @@ const Dt = {
|
|
|
4473
4705
|
APPLY_FAILED: "TEMPLATE_APPLY_FAILED"
|
|
4474
4706
|
}
|
|
4475
4707
|
};
|
|
4476
|
-
class
|
|
4708
|
+
class ee {
|
|
4477
4709
|
constructor({ editor: t }) {
|
|
4478
4710
|
this._buffer = [], this.editor = t;
|
|
4479
4711
|
}
|
|
@@ -4500,7 +4732,7 @@ class te {
|
|
|
4500
4732
|
* @fires editor:error
|
|
4501
4733
|
*/
|
|
4502
4734
|
emitError({ origin: t = "ImageEditor", method: e = "Unknown Method", code: n, data: s, message: o }) {
|
|
4503
|
-
if (!
|
|
4735
|
+
if (!ee.isValidErrorCode(n)) {
|
|
4504
4736
|
console.warn("Неизвестный код ошибки: ", { code: n, origin: t, method: e });
|
|
4505
4737
|
return;
|
|
4506
4738
|
}
|
|
@@ -4529,7 +4761,7 @@ class te {
|
|
|
4529
4761
|
* @fires editor:warning
|
|
4530
4762
|
*/
|
|
4531
4763
|
emitWarning({ origin: t = "ImageEditor", method: e = "Unknown Method", code: n, message: s, data: o }) {
|
|
4532
|
-
if (!
|
|
4764
|
+
if (!ee.isValidErrorCode(n)) {
|
|
4533
4765
|
console.warn("Неизвестный код предупреждения: ", { code: n, origin: t, method: e });
|
|
4534
4766
|
return;
|
|
4535
4767
|
}
|
|
@@ -4552,7 +4784,7 @@ class te {
|
|
|
4552
4784
|
* @returns true, если код допустим, иначе false
|
|
4553
4785
|
*/
|
|
4554
4786
|
static isValidErrorCode(t) {
|
|
4555
|
-
return t ? Object.values(
|
|
4787
|
+
return t ? Object.values(Lt).some((e) => Object.values(e).includes(t)) : !1;
|
|
4556
4788
|
}
|
|
4557
4789
|
}
|
|
4558
4790
|
class Ss {
|
|
@@ -4648,16 +4880,16 @@ const ws = ({ textbox: h }) => {
|
|
|
4648
4880
|
start: Math.min(t, e),
|
|
4649
4881
|
end: Math.max(t, e)
|
|
4650
4882
|
};
|
|
4651
|
-
},
|
|
4883
|
+
}, js = ({ textbox: h }) => {
|
|
4652
4884
|
var e, n;
|
|
4653
4885
|
const t = (n = (e = h.text) == null ? void 0 : e.length) != null ? n : 0;
|
|
4654
4886
|
return t <= 0 ? null : { start: 0, end: t };
|
|
4655
|
-
},
|
|
4887
|
+
}, As = ({ textbox: h, range: t }) => {
|
|
4656
4888
|
var n, s;
|
|
4657
4889
|
if (!t) return !1;
|
|
4658
4890
|
const e = (s = (n = h.text) == null ? void 0 : n.length) != null ? s : 0;
|
|
4659
4891
|
return e <= 0 ? !1 : t.start <= 0 && t.end >= e;
|
|
4660
|
-
},
|
|
4892
|
+
}, we = ({
|
|
4661
4893
|
textbox: h,
|
|
4662
4894
|
styles: t,
|
|
4663
4895
|
range: e
|
|
@@ -4665,7 +4897,7 @@ const ws = ({ textbox: h }) => {
|
|
|
4665
4897
|
if (!t || !Object.keys(t).length) return !1;
|
|
4666
4898
|
const { start: n, end: s } = e;
|
|
4667
4899
|
return s <= n ? !1 : (h.setSelectionStyles(t, n, s), !0);
|
|
4668
|
-
},
|
|
4900
|
+
}, ln = ({
|
|
4669
4901
|
textbox: h,
|
|
4670
4902
|
range: t,
|
|
4671
4903
|
property: e
|
|
@@ -4679,11 +4911,11 @@ const ws = ({ textbox: h }) => {
|
|
|
4679
4911
|
);
|
|
4680
4912
|
if (n.length)
|
|
4681
4913
|
return (s = n[0]) == null ? void 0 : s[e];
|
|
4682
|
-
},
|
|
4914
|
+
}, xe = ({ strokeColor: h, width: t }) => t <= 0 ? null : h != null ? h : "#000000", Re = ({ width: h = 0 }) => h ? Math.max(0, h) : 0, je = ({ value: h }) => typeof h == "string" ? h.toLocaleUpperCase() : "", St = ({
|
|
4683
4915
|
value: h,
|
|
4684
4916
|
min: t,
|
|
4685
4917
|
max: e
|
|
4686
|
-
}) => Math.min(Math.max(h, t), e),
|
|
4918
|
+
}) => Math.min(Math.max(h, t), e), Yt = class Yt extends ct {
|
|
4687
4919
|
constructor(t, e = {}) {
|
|
4688
4920
|
var n, s, o, i, a, r, c, l, d, u;
|
|
4689
4921
|
super(t, e), this.backgroundOpacity = (n = e.backgroundOpacity) != null ? n : 1, this.lineFontDefaults = (s = e.lineFontDefaults) != null ? s : void 0, this.paddingTop = (o = e.paddingTop) != null ? o : 0, this.paddingRight = (i = e.paddingRight) != null ? i : 0, this.paddingBottom = (a = e.paddingBottom) != null ? a : 0, this.paddingLeft = (r = e.paddingLeft) != null ? r : 0, this.radiusTopLeft = (c = e.radiusTopLeft) != null ? c : 0, this.radiusTopRight = (l = e.radiusTopRight) != null ? l : 0, this.radiusBottomRight = (d = e.radiusBottomRight) != null ? d : 0, this.radiusBottomLeft = (u = e.radiusBottomLeft) != null ? u : 0, this._roundDimensions();
|
|
@@ -4708,7 +4940,7 @@ const ws = ({ textbox: h }) => {
|
|
|
4708
4940
|
}
|
|
4709
4941
|
_getTransformedDimensions(t = {}) {
|
|
4710
4942
|
const { width: e, height: n } = this._getBackgroundDimensions();
|
|
4711
|
-
return super._getTransformedDimensions(
|
|
4943
|
+
return super._getTransformedDimensions(Et(F({}, t), {
|
|
4712
4944
|
width: e,
|
|
4713
4945
|
height: n
|
|
4714
4946
|
}));
|
|
@@ -4718,7 +4950,7 @@ const ws = ({ textbox: h }) => {
|
|
|
4718
4950
|
*/
|
|
4719
4951
|
toObject(t = []) {
|
|
4720
4952
|
const e = super.toObject(t);
|
|
4721
|
-
return
|
|
4953
|
+
return Et(F({}, e), {
|
|
4722
4954
|
backgroundOpacity: this.backgroundOpacity,
|
|
4723
4955
|
lineFontDefaults: this.lineFontDefaults,
|
|
4724
4956
|
paddingTop: this.paddingTop,
|
|
@@ -4736,7 +4968,7 @@ const ws = ({ textbox: h }) => {
|
|
|
4736
4968
|
const e = this._getEffectiveBackgroundFill();
|
|
4737
4969
|
if (e && e) {
|
|
4738
4970
|
const o = this._getPadding(), i = (n = this.width) != null ? n : 0, a = (s = this.height) != null ? s : 0, r = i + o.left + o.right, c = a + o.top + o.bottom, l = this._getCornerRadii({ width: r, height: c }), d = this._getLeftOffset() - o.left, u = this._getTopOffset() - o.top;
|
|
4739
|
-
t.save(),
|
|
4971
|
+
t.save(), Yt._renderRoundedRect({
|
|
4740
4972
|
ctx: t,
|
|
4741
4973
|
height: c,
|
|
4742
4974
|
left: d,
|
|
@@ -4771,42 +5003,42 @@ const ws = ({ textbox: h }) => {
|
|
|
4771
5003
|
l += v;
|
|
4772
5004
|
continue;
|
|
4773
5005
|
}
|
|
4774
|
-
const
|
|
4775
|
-
let S = 0, M = 0, w = this.getValueOfPropertyAt(p, 0, e), C = this._getDecorationColorAt(p, 0),
|
|
4776
|
-
const
|
|
5006
|
+
const A = c[p], b = v / o, O = this._getLineLeftOffset(p);
|
|
5007
|
+
let S = 0, M = 0, w = this.getValueOfPropertyAt(p, 0, e), C = this._getDecorationColorAt(p, 0), j = this.getValueOfPropertyAt(p, 0, "textDecorationThickness"), I = w, T = C, k = j;
|
|
5008
|
+
const _ = l + b * (1 - r);
|
|
4777
5009
|
let W = this.getHeightOfChar(p, 0), E = this.getValueOfPropertyAt(p, 0, "deltaY");
|
|
4778
|
-
for (let B = 0,
|
|
5010
|
+
for (let B = 0, z = A.length; B < z; B += 1) {
|
|
4779
5011
|
const x = this.__charBounds[p][B];
|
|
4780
|
-
I = this.getValueOfPropertyAt(p, B, e),
|
|
4781
|
-
const
|
|
4782
|
-
if (u && I &&
|
|
5012
|
+
I = this.getValueOfPropertyAt(p, B, e), T = this._getDecorationColorAt(p, B), k = this.getValueOfPropertyAt(p, B, "textDecorationThickness");
|
|
5013
|
+
const D = this.getHeightOfChar(p, B), R = this.getValueOfPropertyAt(p, B, "deltaY");
|
|
5014
|
+
if (u && I && T) {
|
|
4783
5015
|
const N = s * k / 1e3;
|
|
4784
5016
|
t.save(), t.fillStyle = C, t.translate(x.renderLeft, x.renderTop), t.rotate(x.angle), t.fillRect(
|
|
4785
5017
|
-x.kernedWidth / 2,
|
|
4786
|
-
g *
|
|
5018
|
+
g * D + R - m * N,
|
|
4787
5019
|
x.kernedWidth,
|
|
4788
5020
|
N
|
|
4789
5021
|
), t.restore();
|
|
4790
|
-
} else if ((I !== w ||
|
|
4791
|
-
const N = s *
|
|
4792
|
-
let K = d +
|
|
4793
|
-
n === "rtl" && (K = a - K - M), w && C &&
|
|
5022
|
+
} else if ((I !== w || T !== C || D !== W || k !== j || R !== E) && M > 0) {
|
|
5023
|
+
const N = s * j / 1e3;
|
|
5024
|
+
let K = d + O + S;
|
|
5025
|
+
n === "rtl" && (K = a - K - M), w && C && j && (t.fillStyle = C, t.fillRect(
|
|
4794
5026
|
K,
|
|
4795
|
-
|
|
5027
|
+
_ + g * W + E - m * N,
|
|
4796
5028
|
M,
|
|
4797
5029
|
N
|
|
4798
|
-
)), S = x.left, M = x.width, w = I,
|
|
5030
|
+
)), S = x.left, M = x.width, w = I, j = k, C = T, W = D, E = R;
|
|
4799
5031
|
} else
|
|
4800
5032
|
M += x.kernedWidth;
|
|
4801
5033
|
}
|
|
4802
|
-
let L = d +
|
|
4803
|
-
n === "rtl" && (L = a - L - M), t.fillStyle =
|
|
4804
|
-
const
|
|
4805
|
-
I &&
|
|
5034
|
+
let L = d + O + S;
|
|
5035
|
+
n === "rtl" && (L = a - L - M), t.fillStyle = T;
|
|
5036
|
+
const P = s * k / 1e3;
|
|
5037
|
+
I && T && k && t.fillRect(
|
|
4806
5038
|
L,
|
|
4807
|
-
|
|
5039
|
+
_ + g * W + E - m * P,
|
|
4808
5040
|
M - f,
|
|
4809
|
-
|
|
5041
|
+
P
|
|
4810
5042
|
), l += v;
|
|
4811
5043
|
}
|
|
4812
5044
|
this._removeShadow(t);
|
|
@@ -4815,9 +5047,9 @@ const ws = ({ textbox: h }) => {
|
|
|
4815
5047
|
* Возвращает цвет линии декорации для символа, учитывая обводку и заливку.
|
|
4816
5048
|
*/
|
|
4817
5049
|
_getDecorationColorAt(t, e) {
|
|
4818
|
-
const n = this.getValueOfPropertyAt(t, e, "strokeWidth"), s =
|
|
5050
|
+
const n = this.getValueOfPropertyAt(t, e, "strokeWidth"), s = Re({
|
|
4819
5051
|
width: typeof n == "number" && Number.isFinite(n) ? n : 0
|
|
4820
|
-
}), o = this.getValueOfPropertyAt(t, e, "stroke"), i = o == null ? null :
|
|
5052
|
+
}), o = this.getValueOfPropertyAt(t, e, "stroke"), i = o == null ? null : xe({ strokeColor: o, width: s });
|
|
4821
5053
|
if (s > 0 && i != null)
|
|
4822
5054
|
return i;
|
|
4823
5055
|
const a = this.getValueOfPropertyAt(t, e, "fill");
|
|
@@ -4835,10 +5067,10 @@ const ws = ({ textbox: h }) => {
|
|
|
4835
5067
|
var i, a, r, c;
|
|
4836
5068
|
const n = t / 2, s = e / 2, o = Math.min(n, s);
|
|
4837
5069
|
return {
|
|
4838
|
-
bottomLeft:
|
|
4839
|
-
bottomRight:
|
|
4840
|
-
topLeft:
|
|
4841
|
-
topRight:
|
|
5070
|
+
bottomLeft: St({ value: (i = this.radiusBottomLeft) != null ? i : 0, min: 0, max: o }),
|
|
5071
|
+
bottomRight: St({ value: (a = this.radiusBottomRight) != null ? a : 0, min: 0, max: o }),
|
|
5072
|
+
topLeft: St({ value: (r = this.radiusTopLeft) != null ? r : 0, min: 0, max: o }),
|
|
5073
|
+
topRight: St({ value: (c = this.radiusTopRight) != null ? c : 0, min: 0, max: o })
|
|
4842
5074
|
};
|
|
4843
5075
|
}
|
|
4844
5076
|
_getPadding() {
|
|
@@ -4854,12 +5086,12 @@ const ws = ({ textbox: h }) => {
|
|
|
4854
5086
|
var s;
|
|
4855
5087
|
const t = this.backgroundColor;
|
|
4856
5088
|
if (!t) return null;
|
|
4857
|
-
const e =
|
|
5089
|
+
const e = St({ value: (s = this.backgroundOpacity) != null ? s : 1, min: 0, max: 1 });
|
|
4858
5090
|
let n;
|
|
4859
5091
|
try {
|
|
4860
|
-
n = new
|
|
5092
|
+
n = new Rn(t);
|
|
4861
5093
|
} catch (o) {
|
|
4862
|
-
return
|
|
5094
|
+
return ee.emitError({
|
|
4863
5095
|
origin: "BackgroundTextbox",
|
|
4864
5096
|
method: "_getEffectiveBackgroundFill",
|
|
4865
5097
|
code: "INVALID_COLOR_VALUE",
|
|
@@ -4882,7 +5114,7 @@ const ws = ({ textbox: h }) => {
|
|
|
4882
5114
|
topRight: l,
|
|
4883
5115
|
bottomRight: d,
|
|
4884
5116
|
bottomLeft: u
|
|
4885
|
-
} = s, f =
|
|
5117
|
+
} = s, f = St({ value: c, min: 0, max: i }), g = St({ value: l, min: 0, max: i }), m = St({ value: d, min: 0, max: i }), p = St({ value: u, min: 0, max: i });
|
|
4886
5118
|
t.beginPath(), t.moveTo(n + f, o), t.lineTo(a - g, o), t.quadraticCurveTo(a, o, a, o + g), t.lineTo(a, r - m), t.quadraticCurveTo(a, r, a - m, r), t.lineTo(n + p, r), t.quadraticCurveTo(n, r, n, r - p), t.lineTo(n, o + f), t.quadraticCurveTo(n, o, n + f, o), t.closePath();
|
|
4887
5119
|
}
|
|
4888
5120
|
/**
|
|
@@ -4896,7 +5128,7 @@ const ws = ({ textbox: h }) => {
|
|
|
4896
5128
|
n !== t && (this.width = Math.max(0, n)), s !== e && (this.height = Math.max(0, s));
|
|
4897
5129
|
}
|
|
4898
5130
|
};
|
|
4899
|
-
|
|
5131
|
+
Yt.type = "background-textbox", Yt.cacheProperties = [
|
|
4900
5132
|
...Array.isArray(ct.cacheProperties) ? ct.cacheProperties : [],
|
|
4901
5133
|
"backgroundColor",
|
|
4902
5134
|
"backgroundOpacity",
|
|
@@ -4909,7 +5141,7 @@ Ut.type = "background-textbox", Ut.cacheProperties = [
|
|
|
4909
5141
|
"radiusTopRight",
|
|
4910
5142
|
"radiusBottomRight",
|
|
4911
5143
|
"radiusBottomLeft"
|
|
4912
|
-
],
|
|
5144
|
+
], Yt.stateProperties = [
|
|
4913
5145
|
...Array.isArray(ct.stateProperties) ? ct.stateProperties : [],
|
|
4914
5146
|
"backgroundColor",
|
|
4915
5147
|
"backgroundOpacity",
|
|
@@ -4923,11 +5155,11 @@ Ut.type = "background-textbox", Ut.cacheProperties = [
|
|
|
4923
5155
|
"radiusBottomRight",
|
|
4924
5156
|
"radiusBottomLeft"
|
|
4925
5157
|
];
|
|
4926
|
-
let
|
|
5158
|
+
let ve = Yt;
|
|
4927
5159
|
const Cs = () => {
|
|
4928
5160
|
var h;
|
|
4929
|
-
(h =
|
|
4930
|
-
}, it = 0.01,
|
|
5161
|
+
(h = $e) != null && h.setClass && $e.setClass(ve, "background-textbox");
|
|
5162
|
+
}, it = 0.01, dn = ({
|
|
4931
5163
|
textbox: h,
|
|
4932
5164
|
lineIndices: t,
|
|
4933
5165
|
updates: e
|
|
@@ -4988,7 +5220,7 @@ const Cs = () => {
|
|
|
4988
5220
|
lineStyles: l,
|
|
4989
5221
|
changed: d
|
|
4990
5222
|
};
|
|
4991
|
-
},
|
|
5223
|
+
}, hn = ({
|
|
4992
5224
|
lineFontDefaults: h
|
|
4993
5225
|
}) => {
|
|
4994
5226
|
if (!h) return;
|
|
@@ -5001,7 +5233,7 @@ const Cs = () => {
|
|
|
5001
5233
|
s && (t[n] = F({}, s));
|
|
5002
5234
|
}
|
|
5003
5235
|
return t;
|
|
5004
|
-
},
|
|
5236
|
+
}, un = ({
|
|
5005
5237
|
lineFontDefaults: h,
|
|
5006
5238
|
scale: t
|
|
5007
5239
|
}) => {
|
|
@@ -5019,7 +5251,7 @@ const Cs = () => {
|
|
|
5019
5251
|
}
|
|
5020
5252
|
if (!(!n || !s))
|
|
5021
5253
|
return e;
|
|
5022
|
-
},
|
|
5254
|
+
}, Os = ({
|
|
5023
5255
|
textbox: h
|
|
5024
5256
|
}) => {
|
|
5025
5257
|
var o, i;
|
|
@@ -5033,7 +5265,7 @@ const Cs = () => {
|
|
|
5033
5265
|
s = l + 1, n.push({ start: c, end: l });
|
|
5034
5266
|
}
|
|
5035
5267
|
return n;
|
|
5036
|
-
},
|
|
5268
|
+
}, Ts = ({
|
|
5037
5269
|
range: h,
|
|
5038
5270
|
text: t
|
|
5039
5271
|
}) => {
|
|
@@ -5046,7 +5278,7 @@ const Cs = () => {
|
|
|
5046
5278
|
textbox: h,
|
|
5047
5279
|
range: t
|
|
5048
5280
|
}) => {
|
|
5049
|
-
const e =
|
|
5281
|
+
const e = Os({ textbox: h });
|
|
5050
5282
|
if (!e.length) return t;
|
|
5051
5283
|
let { start: n } = t, { end: s } = t;
|
|
5052
5284
|
for (let o = 0; o < e.length; o += 1) {
|
|
@@ -5056,7 +5288,7 @@ const Cs = () => {
|
|
|
5056
5288
|
t.end > a && t.start < r && (n = Math.min(n, a), s = Math.max(s, r));
|
|
5057
5289
|
}
|
|
5058
5290
|
return { start: n, end: s };
|
|
5059
|
-
},
|
|
5291
|
+
}, _s = ({
|
|
5060
5292
|
textbox: h,
|
|
5061
5293
|
range: t
|
|
5062
5294
|
}) => {
|
|
@@ -5086,7 +5318,7 @@ const Cs = () => {
|
|
|
5086
5318
|
n <= u && s >= f && i.push(l), a = f + 1;
|
|
5087
5319
|
}
|
|
5088
5320
|
return i;
|
|
5089
|
-
},
|
|
5321
|
+
}, Ds = ({
|
|
5090
5322
|
previous: h,
|
|
5091
5323
|
next: t
|
|
5092
5324
|
}) => {
|
|
@@ -5139,10 +5371,10 @@ const Cs = () => {
|
|
|
5139
5371
|
return !1;
|
|
5140
5372
|
let a = 0;
|
|
5141
5373
|
return s < t ? a = t - s : o > e && (a = e - o), Math.abs(a) <= it ? !1 : (h.set({ left: ((d = h.left) != null ? d : 0) + a }), !0);
|
|
5142
|
-
},
|
|
5374
|
+
}, fn = ({
|
|
5143
5375
|
rawValue: h,
|
|
5144
5376
|
calculatedValue: t
|
|
5145
|
-
}) => typeof h == "number" ? h : typeof t == "number" ? t : 0,
|
|
5377
|
+
}) => typeof h == "number" ? h : typeof t == "number" ? t : 0, gn = ({
|
|
5146
5378
|
stylesList: h
|
|
5147
5379
|
}) => {
|
|
5148
5380
|
const t = h.length;
|
|
@@ -5161,13 +5393,13 @@ const Cs = () => {
|
|
|
5161
5393
|
if (s !== void 0 || o !== void 0 || i !== void 0 || a !== void 0 || r !== void 0 || c !== void 0) return !0;
|
|
5162
5394
|
}
|
|
5163
5395
|
return !1;
|
|
5164
|
-
},
|
|
5396
|
+
}, _t = ({
|
|
5165
5397
|
textbox: h
|
|
5166
5398
|
}) => {
|
|
5167
|
-
const { width: t, height: e, calcTextWidth: n, calcTextHeight: s } = h, o = typeof n == "function" ? n.call(h) : void 0, i = typeof s == "function" ? s.call(h) : void 0, a =
|
|
5399
|
+
const { width: t, height: e, calcTextWidth: n, calcTextHeight: s } = h, o = typeof n == "function" ? n.call(h) : void 0, i = typeof s == "function" ? s.call(h) : void 0, a = fn({
|
|
5168
5400
|
rawValue: t,
|
|
5169
5401
|
calculatedValue: o
|
|
5170
|
-
}), r =
|
|
5402
|
+
}), r = fn({
|
|
5171
5403
|
rawValue: e,
|
|
5172
5404
|
calculatedValue: i
|
|
5173
5405
|
}), c = Number.isFinite(a) ? Math.round(a) : null, l = Number.isFinite(r) ? Math.round(r) : null, d = {};
|
|
@@ -5194,7 +5426,7 @@ class rt {
|
|
|
5194
5426
|
if (!rt._isTextbox(s) || this.lineDefaultsSyncing.has(s)) return;
|
|
5195
5427
|
const { text: o = "", uppercase: i, autoExpand: a } = s, r = !!i, c = a !== !1, l = o.toLocaleLowerCase();
|
|
5196
5428
|
if (r) {
|
|
5197
|
-
const f =
|
|
5429
|
+
const f = je({ value: l });
|
|
5198
5430
|
f !== o && s.set({ text: f }), s.textCaseRaw = l;
|
|
5199
5431
|
} else
|
|
5200
5432
|
s.textCaseRaw = o;
|
|
@@ -5202,7 +5434,7 @@ class rt {
|
|
|
5202
5434
|
let d = !1;
|
|
5203
5435
|
c && (d = this._autoExpandTextboxWidth(s));
|
|
5204
5436
|
let u = !1;
|
|
5205
|
-
d || (u =
|
|
5437
|
+
d || (u = _t({ textbox: s })), (d || u) && (s.setCoords(), s.dirty = !0), this._syncLineFontDefaultsOnTextChanged({ textbox: s });
|
|
5206
5438
|
}, this._handleTextEditingExited = (n) => {
|
|
5207
5439
|
var c, l, d;
|
|
5208
5440
|
const { target: s } = n;
|
|
@@ -5214,13 +5446,13 @@ class rt {
|
|
|
5214
5446
|
s.textCaseRaw = u;
|
|
5215
5447
|
} else
|
|
5216
5448
|
s.textCaseRaw = o;
|
|
5217
|
-
|
|
5449
|
+
_t({ textbox: s }) && (s.setCoords(), s.dirty = !0, this.canvas.requestRenderAll()), s.locked || s.set({
|
|
5218
5450
|
lockMovementX: !1,
|
|
5219
5451
|
lockMovementY: !1
|
|
5220
5452
|
});
|
|
5221
5453
|
const { historyManager: r } = this.editor;
|
|
5222
5454
|
r.endAction({ reason: "text-edit" }), r.scheduleSaveState({
|
|
5223
|
-
delayMs:
|
|
5455
|
+
delayMs: hs,
|
|
5224
5456
|
reason: "text-edit"
|
|
5225
5457
|
});
|
|
5226
5458
|
}, this._handleObjectResizing = (n) => {
|
|
@@ -5237,10 +5469,10 @@ class rt {
|
|
|
5237
5469
|
s.set({ width: m });
|
|
5238
5470
|
const { width: p = 0 } = s, y = g - p;
|
|
5239
5471
|
if (y !== 0 && o && o.corner === "ml") {
|
|
5240
|
-
const
|
|
5472
|
+
const A = ((l = s.angle) != null ? l : 0) * Math.PI / 180, b = Math.cos(A), O = Math.sin(A), S = (d = s.scaleX) != null ? d : 1, M = y * S;
|
|
5241
5473
|
s.set({
|
|
5242
5474
|
left: ((u = s.left) != null ? u : 0) + M * b,
|
|
5243
|
-
top: ((f = s.top) != null ? f : 0) + M *
|
|
5475
|
+
top: ((f = s.top) != null ? f : 0) + M * O
|
|
5244
5476
|
});
|
|
5245
5477
|
}
|
|
5246
5478
|
}
|
|
@@ -5251,7 +5483,7 @@ class rt {
|
|
|
5251
5483
|
event: i != null ? i : null
|
|
5252
5484
|
});
|
|
5253
5485
|
}, this._handleObjectScaling = (n) => {
|
|
5254
|
-
var
|
|
5486
|
+
var se, be, ie, oe, ae, kt, Me, re, Zt, Gt, Vt, Xt, Kt;
|
|
5255
5487
|
const { target: s, transform: o } = n;
|
|
5256
5488
|
if (s instanceof X || !rt._isTextbox(s) || !o) return;
|
|
5257
5489
|
s.isScaling = !0;
|
|
@@ -5263,21 +5495,21 @@ class rt {
|
|
|
5263
5495
|
baseRadii: d,
|
|
5264
5496
|
baseStyles: u,
|
|
5265
5497
|
baseLineFontDefaults: f
|
|
5266
|
-
} = i, g = typeof ((
|
|
5267
|
-
if (!b && !
|
|
5268
|
-
const w = Math.abs((
|
|
5498
|
+
} = i, g = typeof ((se = o.original) == null ? void 0 : se.width) == "number" ? o.original.width : void 0, m = typeof ((be = o.original) == null ? void 0 : be.left) == "number" ? o.original.left : void 0, p = g != null ? g : a, y = m != null ? m : r, v = (ie = o.corner) != null ? ie : "", A = (oe = o.action) != null ? oe : "", b = ["ml", "mr"].includes(v) || A === "scaleX", O = ["mt", "mb"].includes(v) || A === "scaleY", S = ["tl", "tr", "bl", "br"].includes(v) || A === "scale", M = S || O;
|
|
5499
|
+
if (!b && !O && !S) return;
|
|
5500
|
+
const w = Math.abs((kt = (ae = s.scaleX) != null ? ae : o.scaleX) != null ? kt : 1) || 1, C = Math.abs((re = (Me = s.scaleY) != null ? Me : o.scaleY) != null ? re : 1) || 1, j = Math.max(1, p * w), I = Math.max(1, Math.round(j)), T = Math.max(1, c * C), {
|
|
5269
5501
|
paddingTop: k = 0,
|
|
5270
|
-
paddingRight:
|
|
5502
|
+
paddingRight: _ = 0,
|
|
5271
5503
|
paddingBottom: W = 0,
|
|
5272
5504
|
paddingLeft: E = 0,
|
|
5273
5505
|
radiusTopLeft: L = 0,
|
|
5274
|
-
radiusTopRight:
|
|
5506
|
+
radiusTopRight: P = 0,
|
|
5275
5507
|
radiusBottomRight: B = 0,
|
|
5276
|
-
radiusBottomLeft:
|
|
5508
|
+
radiusBottomLeft: z = 0,
|
|
5277
5509
|
fontSize: x,
|
|
5278
|
-
width:
|
|
5510
|
+
width: D,
|
|
5279
5511
|
originX: R = "left"
|
|
5280
|
-
} = s, N = S ||
|
|
5512
|
+
} = s, N = S || O, K = S || O, H = N ? {
|
|
5281
5513
|
top: Math.max(0, l.top * C),
|
|
5282
5514
|
right: Math.max(0, l.right * C),
|
|
5283
5515
|
bottom: Math.max(0, l.bottom * C),
|
|
@@ -5290,30 +5522,30 @@ class rt {
|
|
|
5290
5522
|
} : d, tt = Object.keys(u).length > 0;
|
|
5291
5523
|
let at;
|
|
5292
5524
|
if (M && tt) {
|
|
5293
|
-
const
|
|
5294
|
-
Object.entries(u).forEach(([
|
|
5525
|
+
const Bt = {};
|
|
5526
|
+
Object.entries(u).forEach(([ce, Q]) => {
|
|
5295
5527
|
if (!Q) return;
|
|
5296
5528
|
const st = {};
|
|
5297
|
-
Object.entries(Q).forEach(([
|
|
5298
|
-
if (!
|
|
5299
|
-
const
|
|
5300
|
-
typeof
|
|
5301
|
-
}), Object.keys(st).length && (
|
|
5302
|
-
}), Object.keys(
|
|
5529
|
+
Object.entries(Q).forEach(([Se, Nt]) => {
|
|
5530
|
+
if (!Nt) return;
|
|
5531
|
+
const Ze = F({}, Nt);
|
|
5532
|
+
typeof Nt.fontSize == "number" && (Ze.fontSize = Math.max(1, Nt.fontSize * C)), st[Se] = Ze;
|
|
5533
|
+
}), Object.keys(st).length && (Bt[ce] = st);
|
|
5534
|
+
}), Object.keys(Bt).length && (at = Bt);
|
|
5303
5535
|
}
|
|
5304
|
-
let
|
|
5305
|
-
M && (
|
|
5536
|
+
let gt;
|
|
5537
|
+
M && (gt = un({
|
|
5306
5538
|
lineFontDefaults: f,
|
|
5307
5539
|
scale: C
|
|
5308
5540
|
}));
|
|
5309
|
-
const
|
|
5310
|
-
if (!At && !
|
|
5541
|
+
const jt = (Gt = (Zt = o.originX) != null ? Zt : R) != null ? Gt : "left", dt = y + p, ht = y + p / 2, Ot = D != null ? D : p, At = I !== Ot, Dt = Math.abs(T - (x != null ? x : c)) > it, xt = Math.abs(H.top - k) > it || Math.abs(H.right - _) > it || Math.abs(H.bottom - W) > it || Math.abs(H.left - E) > it, Rt = Math.abs(q.topLeft - L) > it || Math.abs(q.topRight - P) > it || Math.abs(q.bottomRight - B) > it || Math.abs(q.bottomLeft - z) > it;
|
|
5542
|
+
if (!At && !Dt && !xt && !Rt) {
|
|
5311
5543
|
s.set({ scaleX: 1, scaleY: 1 }), o.scaleX = 1, o.scaleY = 1;
|
|
5312
5544
|
return;
|
|
5313
5545
|
}
|
|
5314
|
-
at && (s.styles = at),
|
|
5546
|
+
at && (s.styles = at), gt && (s.lineFontDefaults = gt), s.set({
|
|
5315
5547
|
width: I,
|
|
5316
|
-
fontSize: M ?
|
|
5548
|
+
fontSize: M ? T : c,
|
|
5317
5549
|
paddingTop: H.top,
|
|
5318
5550
|
paddingRight: H.right,
|
|
5319
5551
|
paddingBottom: H.bottom,
|
|
@@ -5325,13 +5557,13 @@ class rt {
|
|
|
5325
5557
|
scaleX: 1,
|
|
5326
5558
|
scaleY: 1
|
|
5327
5559
|
});
|
|
5328
|
-
const
|
|
5329
|
-
|
|
5330
|
-
const
|
|
5560
|
+
const Ht = _t({ textbox: s });
|
|
5561
|
+
Ht && (s.dirty = !0);
|
|
5562
|
+
const pt = (Vt = s.width) != null ? Vt : I, ne = pt !== Ot;
|
|
5331
5563
|
let Tt = y;
|
|
5332
|
-
|
|
5333
|
-
const { original:
|
|
5334
|
-
|
|
5564
|
+
ne && (b || S) && (jt === "right" ? Tt = dt - pt : jt === "center" && (Tt = ht - pt / 2)), s.set({ left: Tt }), i.baseLeft = Tt, o.scaleX = 1, o.scaleY = 1;
|
|
5565
|
+
const { original: Mt } = o;
|
|
5566
|
+
Mt && (Mt.scaleX = 1, Mt.scaleY = 1, Mt.width = pt, Mt.height = s.height, Mt.left = Tt), s.setCoords(), this.canvas.requestRenderAll(), i.baseWidth = pt, i.baseFontSize = (Xt = s.fontSize) != null ? Xt : T, i.baseStyles = JSON.parse(JSON.stringify((Kt = s.styles) != null ? Kt : {})), i.baseLineFontDefaults = hn({
|
|
5335
5567
|
lineFontDefaults: s.lineFontDefaults
|
|
5336
5568
|
}), i.basePadding = {
|
|
5337
5569
|
top: H.top,
|
|
@@ -5343,61 +5575,61 @@ class rt {
|
|
|
5343
5575
|
topRight: q.topRight,
|
|
5344
5576
|
bottomRight: q.bottomRight,
|
|
5345
5577
|
bottomLeft: q.bottomLeft
|
|
5346
|
-
}, i.hasWidthChange =
|
|
5578
|
+
}, i.hasWidthChange = ne || Dt || xt || Rt || Ht;
|
|
5347
5579
|
}, this._handleObjectModified = (n) => {
|
|
5348
|
-
var v,
|
|
5580
|
+
var v, A, b;
|
|
5349
5581
|
const { target: s } = n;
|
|
5350
5582
|
if (s instanceof X) {
|
|
5351
|
-
const
|
|
5352
|
-
if (!
|
|
5583
|
+
const O = s.getObjects();
|
|
5584
|
+
if (!O.some((j) => rt._isTextbox(j))) return;
|
|
5353
5585
|
const { scaleX: M = 1, scaleY: w = 1 } = s;
|
|
5354
5586
|
if (Math.abs(M - 1) < it && Math.abs(w - 1) < it) return;
|
|
5355
|
-
this.canvas.discardActiveObject(),
|
|
5356
|
-
var I,
|
|
5357
|
-
if (rt._isTextbox(
|
|
5358
|
-
const W = (I =
|
|
5359
|
-
paddingTop:
|
|
5587
|
+
this.canvas.discardActiveObject(), O.forEach((j) => {
|
|
5588
|
+
var I, T, k, _;
|
|
5589
|
+
if (rt._isTextbox(j)) {
|
|
5590
|
+
const W = (I = j.scaleX) != null ? I : 1, E = (T = j.scaleY) != null ? T : 1, L = ((k = j.fontSize) != null ? k : 16) * E, P = ((_ = j.width) != null ? _ : 0) * W, B = E, {
|
|
5591
|
+
paddingTop: z = 0,
|
|
5360
5592
|
paddingRight: x = 0,
|
|
5361
|
-
paddingBottom:
|
|
5593
|
+
paddingBottom: D = 0,
|
|
5362
5594
|
paddingLeft: R = 0,
|
|
5363
5595
|
radiusTopLeft: N = 0,
|
|
5364
5596
|
radiusTopRight: K = 0,
|
|
5365
5597
|
radiusBottomRight: H = 0,
|
|
5366
5598
|
radiusBottomLeft: q = 0,
|
|
5367
5599
|
styles: tt
|
|
5368
|
-
} =
|
|
5369
|
-
paddingTop: Math.max(0,
|
|
5600
|
+
} = j, at = {
|
|
5601
|
+
paddingTop: Math.max(0, z * B),
|
|
5370
5602
|
paddingRight: Math.max(0, x * B),
|
|
5371
|
-
paddingBottom: Math.max(0,
|
|
5603
|
+
paddingBottom: Math.max(0, D * B),
|
|
5372
5604
|
paddingLeft: Math.max(0, R * B)
|
|
5373
|
-
},
|
|
5605
|
+
}, gt = {
|
|
5374
5606
|
radiusTopLeft: Math.max(0, N * B),
|
|
5375
5607
|
radiusTopRight: Math.max(0, K * B),
|
|
5376
5608
|
radiusBottomRight: Math.max(0, H * B),
|
|
5377
5609
|
radiusBottomLeft: Math.max(0, q * B)
|
|
5378
5610
|
};
|
|
5379
|
-
let
|
|
5380
|
-
tt && Object.keys(tt).length > 0 && (
|
|
5381
|
-
Object.values(
|
|
5611
|
+
let jt = tt;
|
|
5612
|
+
tt && Object.keys(tt).length > 0 && (jt = JSON.parse(JSON.stringify(tt)), Object.values(jt).forEach((Ot) => {
|
|
5613
|
+
Object.values(Ot).forEach((At) => {
|
|
5382
5614
|
typeof At.fontSize == "number" && (At.fontSize = Math.max(1, At.fontSize * B));
|
|
5383
5615
|
});
|
|
5384
5616
|
}));
|
|
5385
|
-
const dt =
|
|
5386
|
-
lineFontDefaults:
|
|
5617
|
+
const dt = un({
|
|
5618
|
+
lineFontDefaults: j.lineFontDefaults,
|
|
5387
5619
|
scale: B
|
|
5388
|
-
}), ht =
|
|
5620
|
+
}), ht = Et(F(F({
|
|
5389
5621
|
fontSize: L,
|
|
5390
|
-
width:
|
|
5622
|
+
width: P,
|
|
5391
5623
|
scaleX: 1,
|
|
5392
5624
|
scaleY: 1
|
|
5393
|
-
}, at),
|
|
5394
|
-
styles:
|
|
5625
|
+
}, at), gt), {
|
|
5626
|
+
styles: jt
|
|
5395
5627
|
});
|
|
5396
|
-
dt && (ht.lineFontDefaults = dt),
|
|
5628
|
+
dt && (ht.lineFontDefaults = dt), j.set(ht), _t({ textbox: j });
|
|
5397
5629
|
}
|
|
5398
|
-
|
|
5630
|
+
j.setCoords();
|
|
5399
5631
|
});
|
|
5400
|
-
const C = new X(
|
|
5632
|
+
const C = new X(O, {
|
|
5401
5633
|
canvas: this.canvas
|
|
5402
5634
|
});
|
|
5403
5635
|
this.canvas.setActiveObject(C), this.canvas.requestRenderAll();
|
|
@@ -5407,7 +5639,7 @@ class rt {
|
|
|
5407
5639
|
s.isScaling = !1;
|
|
5408
5640
|
const o = this.scalingState.get(s);
|
|
5409
5641
|
if (this.scalingState.delete(s), !(o != null && o.hasWidthChange)) return;
|
|
5410
|
-
const i = (v = s.width) != null ? v : s.calcTextWidth(), a = (b = (
|
|
5642
|
+
const i = (v = s.width) != null ? v : s.calcTextWidth(), a = (b = (A = s.fontSize) != null ? A : o == null ? void 0 : o.baseFontSize) != null ? b : 16, r = !!(o.baseStyles && Object.keys(o.baseStyles).length), {
|
|
5411
5643
|
paddingTop: c = 0,
|
|
5412
5644
|
paddingRight: l = 0,
|
|
5413
5645
|
paddingBottom: d = 0,
|
|
@@ -5438,8 +5670,8 @@ class rt {
|
|
|
5438
5670
|
* @param options — настройки текста
|
|
5439
5671
|
* @param flags — флаги поведения
|
|
5440
5672
|
*/
|
|
5441
|
-
addText(
|
|
5442
|
-
var W =
|
|
5673
|
+
addText(_ = {}, { withoutSelection: I = !1, withoutSave: T = !1, withoutAdding: k = !1 } = {}) {
|
|
5674
|
+
var W = _, {
|
|
5443
5675
|
id: t = `text-${et()}`,
|
|
5444
5676
|
text: e = "Новый текст",
|
|
5445
5677
|
autoExpand: n = !0,
|
|
@@ -5458,14 +5690,14 @@ class rt {
|
|
|
5458
5690
|
backgroundColor: p,
|
|
5459
5691
|
backgroundOpacity: y = 1,
|
|
5460
5692
|
paddingTop: v = 0,
|
|
5461
|
-
paddingRight:
|
|
5693
|
+
paddingRight: A = 0,
|
|
5462
5694
|
paddingBottom: b = 0,
|
|
5463
|
-
paddingLeft:
|
|
5695
|
+
paddingLeft: O = 0,
|
|
5464
5696
|
radiusTopLeft: S = 0,
|
|
5465
5697
|
radiusTopRight: M = 0,
|
|
5466
5698
|
radiusBottomRight: w = 0,
|
|
5467
5699
|
radiusBottomLeft: C = 0
|
|
5468
|
-
} = W,
|
|
5700
|
+
} = W, j = Ct(W, [
|
|
5469
5701
|
"id",
|
|
5470
5702
|
"text",
|
|
5471
5703
|
"autoExpand",
|
|
@@ -5495,12 +5727,12 @@ class rt {
|
|
|
5495
5727
|
var K;
|
|
5496
5728
|
const { historyManager: E } = this.editor, { canvas: L } = this;
|
|
5497
5729
|
E.suspendHistory();
|
|
5498
|
-
const
|
|
5730
|
+
const P = s != null ? s : this._getDefaultFontFamily(), B = Re({ width: g }), z = xe({
|
|
5499
5731
|
strokeColor: f,
|
|
5500
5732
|
width: B
|
|
5501
5733
|
}), x = F({
|
|
5502
5734
|
id: t,
|
|
5503
|
-
fontFamily:
|
|
5735
|
+
fontFamily: P,
|
|
5504
5736
|
fontSize: o,
|
|
5505
5737
|
fontWeight: i ? "bold" : "normal",
|
|
5506
5738
|
fontStyle: a ? "italic" : "normal",
|
|
@@ -5509,43 +5741,43 @@ class rt {
|
|
|
5509
5741
|
linethrough: l,
|
|
5510
5742
|
textAlign: d,
|
|
5511
5743
|
fill: u,
|
|
5512
|
-
stroke:
|
|
5744
|
+
stroke: z,
|
|
5513
5745
|
strokeWidth: B,
|
|
5514
5746
|
strokeUniform: !0,
|
|
5515
5747
|
opacity: m,
|
|
5516
5748
|
backgroundColor: p,
|
|
5517
5749
|
backgroundOpacity: y,
|
|
5518
5750
|
paddingTop: v,
|
|
5519
|
-
paddingRight:
|
|
5751
|
+
paddingRight: A,
|
|
5520
5752
|
paddingBottom: b,
|
|
5521
|
-
paddingLeft:
|
|
5753
|
+
paddingLeft: O,
|
|
5522
5754
|
radiusTopLeft: S,
|
|
5523
5755
|
radiusTopRight: M,
|
|
5524
5756
|
radiusBottomRight: w,
|
|
5525
5757
|
radiusBottomLeft: C
|
|
5526
|
-
},
|
|
5527
|
-
if (
|
|
5528
|
-
const H =
|
|
5529
|
-
H !==
|
|
5530
|
-
}
|
|
5531
|
-
return
|
|
5532
|
-
textbox:
|
|
5533
|
-
options:
|
|
5758
|
+
}, j), D = new ve(e, x), R = n !== !1;
|
|
5759
|
+
if (D.autoExpand = R, D.textCaseRaw = (K = D.text) != null ? K : "", c) {
|
|
5760
|
+
const H = je({ value: D.textCaseRaw });
|
|
5761
|
+
H !== D.text && D.set({ text: H });
|
|
5762
|
+
}
|
|
5763
|
+
return _t({ textbox: D }) && (D.dirty = !0), j.left === void 0 && j.top === void 0 && L.centerObject(D), k || L.add(D), I || L.setActiveObject(D), L.requestRenderAll(), E.resumeHistory(), T || E.saveState(), L.fire("editor:text-added", {
|
|
5764
|
+
textbox: D,
|
|
5765
|
+
options: Et(F({}, x), {
|
|
5534
5766
|
text: e,
|
|
5535
5767
|
bold: i,
|
|
5536
5768
|
italic: a,
|
|
5537
5769
|
strikethrough: l,
|
|
5538
5770
|
align: d,
|
|
5539
5771
|
color: u,
|
|
5540
|
-
strokeColor:
|
|
5772
|
+
strokeColor: z,
|
|
5541
5773
|
strokeWidth: B
|
|
5542
5774
|
}),
|
|
5543
5775
|
flags: {
|
|
5544
5776
|
withoutSelection: !!I,
|
|
5545
|
-
withoutSave: !!
|
|
5777
|
+
withoutSave: !!T,
|
|
5546
5778
|
withoutAdding: !!k
|
|
5547
5779
|
}
|
|
5548
|
-
}),
|
|
5780
|
+
}), D;
|
|
5549
5781
|
}
|
|
5550
5782
|
/**
|
|
5551
5783
|
* Обновляет текстовый объект.
|
|
@@ -5563,41 +5795,41 @@ class rt {
|
|
|
5563
5795
|
skipRender: s,
|
|
5564
5796
|
selectionRange: o
|
|
5565
5797
|
} = {}) {
|
|
5566
|
-
var
|
|
5798
|
+
var Zt, Vt, Xt, Kt, Bt, ce;
|
|
5567
5799
|
const i = this._resolveTextObject(t);
|
|
5568
5800
|
if (!i) return null;
|
|
5569
5801
|
const { text: a = "" } = i, { historyManager: r } = this.editor, { canvas: c } = this;
|
|
5570
5802
|
r.suspendHistory();
|
|
5571
|
-
const l = rt._getSnapshot(i), d = (
|
|
5803
|
+
const l = rt._getSnapshot(i), d = (Zt = i.originY) != null ? Zt : "top", u = i.getPointByOrigin("center", d), f = {
|
|
5572
5804
|
originY: d,
|
|
5573
5805
|
x: u.x,
|
|
5574
5806
|
y: u.y
|
|
5575
|
-
},
|
|
5807
|
+
}, Gt = e, {
|
|
5576
5808
|
text: g,
|
|
5577
5809
|
autoExpand: m,
|
|
5578
5810
|
fontFamily: p,
|
|
5579
5811
|
fontSize: y,
|
|
5580
5812
|
bold: v,
|
|
5581
|
-
italic:
|
|
5813
|
+
italic: A,
|
|
5582
5814
|
underline: b,
|
|
5583
|
-
uppercase:
|
|
5815
|
+
uppercase: O,
|
|
5584
5816
|
strikethrough: S,
|
|
5585
5817
|
align: M,
|
|
5586
5818
|
color: w,
|
|
5587
5819
|
strokeColor: C,
|
|
5588
|
-
strokeWidth:
|
|
5820
|
+
strokeWidth: j,
|
|
5589
5821
|
opacity: I,
|
|
5590
|
-
backgroundColor:
|
|
5822
|
+
backgroundColor: T,
|
|
5591
5823
|
backgroundOpacity: k,
|
|
5592
|
-
paddingTop:
|
|
5824
|
+
paddingTop: _,
|
|
5593
5825
|
paddingRight: W,
|
|
5594
5826
|
paddingBottom: E,
|
|
5595
5827
|
paddingLeft: L,
|
|
5596
|
-
radiusTopLeft:
|
|
5828
|
+
radiusTopLeft: P,
|
|
5597
5829
|
radiusTopRight: B,
|
|
5598
|
-
radiusBottomRight:
|
|
5830
|
+
radiusBottomRight: z,
|
|
5599
5831
|
radiusBottomLeft: x
|
|
5600
|
-
} =
|
|
5832
|
+
} = Gt, D = Ct(Gt, [
|
|
5601
5833
|
"text",
|
|
5602
5834
|
"autoExpand",
|
|
5603
5835
|
"fontFamily",
|
|
@@ -5622,89 +5854,89 @@ class rt {
|
|
|
5622
5854
|
"radiusTopRight",
|
|
5623
5855
|
"radiusBottomRight",
|
|
5624
5856
|
"radiusBottomLeft"
|
|
5625
|
-
]), R = F({},
|
|
5857
|
+
]), R = F({}, D), N = o !== void 0 ? Ts({
|
|
5626
5858
|
text: a,
|
|
5627
5859
|
range: o
|
|
5628
5860
|
}) : ws({ textbox: i }), K = N ? Es({ textbox: i, range: N }) : null, H = {}, q = {}, tt = {};
|
|
5629
|
-
let at,
|
|
5630
|
-
const
|
|
5861
|
+
let at, gt;
|
|
5862
|
+
const jt = As({ textbox: i, range: N }), dt = !N || jt, ht = !N;
|
|
5631
5863
|
if (p !== void 0 && (K && (q.fontFamily = p), dt && (R.fontFamily = p, ht && (tt.fontFamily = p))), y !== void 0 && (K && (q.fontSize = y), dt && (R.fontSize = y, ht && (tt.fontSize = y))), v !== void 0) {
|
|
5632
5864
|
const Q = v ? "bold" : "normal";
|
|
5633
5865
|
N && (H.fontWeight = Q), dt && (R.fontWeight = Q, ht && (tt.fontWeight = Q));
|
|
5634
5866
|
}
|
|
5635
|
-
if (
|
|
5636
|
-
const Q =
|
|
5867
|
+
if (A !== void 0) {
|
|
5868
|
+
const Q = A ? "italic" : "normal";
|
|
5637
5869
|
N && (H.fontStyle = Q), dt && (R.fontStyle = Q, ht && (tt.fontStyle = Q));
|
|
5638
5870
|
}
|
|
5639
|
-
if (b !== void 0 && (N && (H.underline = b), dt && (R.underline = b, ht && (tt.underline = b))), S !== void 0 && (N && (H.linethrough = S), dt && (R.linethrough = S, ht && (tt.linethrough = S))), M !== void 0 && (R.textAlign = M), w !== void 0 && (N && (H.fill = w), dt && (R.fill = w, ht && (tt.fill = w))), C !== void 0 ||
|
|
5640
|
-
const Q = N ?
|
|
5641
|
-
|
|
5642
|
-
const
|
|
5643
|
-
at =
|
|
5644
|
-
strokeColor:
|
|
5645
|
-
width:
|
|
5646
|
-
}), N && (H.stroke = at, H.strokeWidth =
|
|
5647
|
-
}
|
|
5648
|
-
I !== void 0 && (R.opacity = I),
|
|
5649
|
-
const
|
|
5650
|
-
if (
|
|
5651
|
-
const Q =
|
|
5652
|
-
R.text = Q, i.textCaseRaw =
|
|
5653
|
-
} else i.textCaseRaw === void 0 && (i.textCaseRaw =
|
|
5654
|
-
i.uppercase =
|
|
5655
|
-
let
|
|
5871
|
+
if (b !== void 0 && (N && (H.underline = b), dt && (R.underline = b, ht && (tt.underline = b))), S !== void 0 && (N && (H.linethrough = S), dt && (R.linethrough = S, ht && (tt.linethrough = S))), M !== void 0 && (R.textAlign = M), w !== void 0 && (N && (H.fill = w), dt && (R.fill = w, ht && (tt.fill = w))), C !== void 0 || j !== void 0) {
|
|
5872
|
+
const Q = N ? ln({ textbox: i, range: N, property: "strokeWidth" }) : void 0, st = N ? ln({ textbox: i, range: N, property: "stroke" }) : void 0, Se = (Xt = (Vt = j != null ? j : Q) != null ? Vt : i.strokeWidth) != null ? Xt : 0;
|
|
5873
|
+
gt = Re({ width: Se });
|
|
5874
|
+
const Nt = (Bt = (Kt = C != null ? C : st) != null ? Kt : i.stroke) != null ? Bt : void 0;
|
|
5875
|
+
at = xe({
|
|
5876
|
+
strokeColor: Nt,
|
|
5877
|
+
width: gt
|
|
5878
|
+
}), N && (H.stroke = at, H.strokeWidth = gt), dt && (R.stroke = at, R.strokeWidth = gt, ht && (tt.stroke = at, tt.strokeWidth = gt));
|
|
5879
|
+
}
|
|
5880
|
+
I !== void 0 && (R.opacity = I), T !== void 0 && (R.backgroundColor = T), k !== void 0 && (R.backgroundOpacity = k), _ !== void 0 && (R.paddingTop = _), W !== void 0 && (R.paddingRight = W), E !== void 0 && (R.paddingBottom = E), L !== void 0 && (R.paddingLeft = L), P !== void 0 && (R.radiusTopLeft = P), B !== void 0 && (R.radiusTopRight = B), z !== void 0 && (R.radiusBottomRight = z), x !== void 0 && (R.radiusBottomLeft = x);
|
|
5881
|
+
const Ot = (ce = i.textCaseRaw) != null ? ce : a, At = !!i.uppercase, Dt = g !== void 0, xt = Dt ? g != null ? g : "" : Ot, Rt = O != null ? O : At, Ht = Rt !== At;
|
|
5882
|
+
if (Dt || Ht) {
|
|
5883
|
+
const Q = Rt ? je({ value: xt }) : xt;
|
|
5884
|
+
R.text = Q, i.textCaseRaw = xt;
|
|
5885
|
+
} else i.textCaseRaw === void 0 && (i.textCaseRaw = Ot);
|
|
5886
|
+
i.uppercase = Rt, i.set(R);
|
|
5887
|
+
let pt = !1;
|
|
5656
5888
|
if (N) {
|
|
5657
|
-
const Q =
|
|
5658
|
-
|
|
5889
|
+
const Q = we({ textbox: i, styles: H, range: N }), st = K ? we({ textbox: i, styles: q, range: K }) : !1;
|
|
5890
|
+
pt = Q || st;
|
|
5659
5891
|
} else if (Object.keys(tt).length) {
|
|
5660
|
-
const Q =
|
|
5661
|
-
Q && (
|
|
5892
|
+
const Q = js({ textbox: i });
|
|
5893
|
+
Q && (pt = we({ textbox: i, styles: tt, range: Q }));
|
|
5662
5894
|
}
|
|
5663
|
-
const
|
|
5895
|
+
const ne = pt && gn({
|
|
5664
5896
|
stylesList: [
|
|
5665
5897
|
H,
|
|
5666
5898
|
q,
|
|
5667
5899
|
tt
|
|
5668
5900
|
]
|
|
5669
5901
|
});
|
|
5670
|
-
if (
|
|
5671
|
-
const Q =
|
|
5902
|
+
if (pt && (i.dirty = !0), K && (p !== void 0 || y !== void 0)) {
|
|
5903
|
+
const Q = _s({
|
|
5672
5904
|
textbox: i,
|
|
5673
5905
|
range: K
|
|
5674
5906
|
}), st = {};
|
|
5675
|
-
p !== void 0 && (st.fontFamily = p), y !== void 0 && (st.fontSize = y),
|
|
5907
|
+
p !== void 0 && (st.fontFamily = p), y !== void 0 && (st.fontSize = y), dn({
|
|
5676
5908
|
textbox: i,
|
|
5677
5909
|
lineIndices: Q,
|
|
5678
5910
|
updates: st
|
|
5679
5911
|
});
|
|
5680
5912
|
}
|
|
5681
|
-
if (N && (w !== void 0 || C !== void 0 ||
|
|
5913
|
+
if (N && (w !== void 0 || C !== void 0 || j !== void 0)) {
|
|
5682
5914
|
const Q = Ls({
|
|
5683
5915
|
textbox: i,
|
|
5684
5916
|
range: N
|
|
5685
5917
|
}), st = {};
|
|
5686
|
-
w !== void 0 && (st.fill = w), (C !== void 0 ||
|
|
5918
|
+
w !== void 0 && (st.fill = w), (C !== void 0 || j !== void 0) && (at === null && (st.stroke = null), at != null && (st.stroke = at)), dn({
|
|
5687
5919
|
textbox: i,
|
|
5688
5920
|
lineIndices: Q,
|
|
5689
5921
|
updates: st
|
|
5690
5922
|
});
|
|
5691
5923
|
}
|
|
5692
|
-
|
|
5693
|
-
const Tt =
|
|
5924
|
+
ne && (i.initDimensions(), i.dirty = !0), (T !== void 0 || k !== void 0 || _ !== void 0 || W !== void 0 || E !== void 0 || L !== void 0 || P !== void 0 || B !== void 0 || z !== void 0 || x !== void 0) && (i.dirty = !0);
|
|
5925
|
+
const Tt = gn({
|
|
5694
5926
|
stylesList: [
|
|
5695
5927
|
R,
|
|
5696
5928
|
H,
|
|
5697
5929
|
q,
|
|
5698
5930
|
tt
|
|
5699
5931
|
]
|
|
5700
|
-
}), { autoExpand:
|
|
5701
|
-
|
|
5702
|
-
const
|
|
5703
|
-
let
|
|
5704
|
-
|
|
5932
|
+
}), { autoExpand: Mt } = i, se = m !== void 0, ie = (m != null ? m : Mt) !== !1;
|
|
5933
|
+
se ? i.autoExpand = m !== !1 : Mt === void 0 && (i.autoExpand = !0);
|
|
5934
|
+
const oe = Object.prototype.hasOwnProperty.call(R, "width"), ae = ie && !oe && (Dt || Ht || Tt);
|
|
5935
|
+
let kt = !1;
|
|
5936
|
+
ae && (kt = this._autoExpandTextboxWidth(i, {
|
|
5705
5937
|
anchor: f
|
|
5706
|
-
}),
|
|
5707
|
-
const
|
|
5938
|
+
}), kt && (i.dirty = !0)), (kt ? !1 : _t({ textbox: i })) && (i.dirty = !0), i.setCoords(), s || c.requestRenderAll(), r.resumeHistory(), n || r.saveState();
|
|
5939
|
+
const re = rt._getSnapshot(i);
|
|
5708
5940
|
return c.fire("editor:text-updated", {
|
|
5709
5941
|
textbox: i,
|
|
5710
5942
|
target: t,
|
|
@@ -5715,7 +5947,7 @@ class rt {
|
|
|
5715
5947
|
},
|
|
5716
5948
|
updates: R,
|
|
5717
5949
|
before: l,
|
|
5718
|
-
after:
|
|
5950
|
+
after: re,
|
|
5719
5951
|
selectionRange: N != null ? N : void 0,
|
|
5720
5952
|
selectionStyles: N && Object.keys(H).length ? H : void 0
|
|
5721
5953
|
}), i;
|
|
@@ -5725,7 +5957,7 @@ class rt {
|
|
|
5725
5957
|
*/
|
|
5726
5958
|
// eslint-disable-next-line class-methods-use-this
|
|
5727
5959
|
stylesFromArray(t, e) {
|
|
5728
|
-
return
|
|
5960
|
+
return bt.stylesFromArray(t, e);
|
|
5729
5961
|
}
|
|
5730
5962
|
/**
|
|
5731
5963
|
* Уничтожает менеджер и снимает слушатели.
|
|
@@ -5767,7 +5999,7 @@ class rt {
|
|
|
5767
5999
|
* Синхронизирует lineFontDefaults при изменении текста и сохраняет typing style для пустых строк.
|
|
5768
6000
|
*/
|
|
5769
6001
|
_syncLineFontDefaultsOnTextChanged({ textbox: t }) {
|
|
5770
|
-
var k,
|
|
6002
|
+
var k, _, W;
|
|
5771
6003
|
const {
|
|
5772
6004
|
text: e = "",
|
|
5773
6005
|
lineFontDefaults: n,
|
|
@@ -5781,10 +6013,10 @@ class rt {
|
|
|
5781
6013
|
} = t, d = e, u = (k = t.__lineDefaultsPrevText) != null ? k : d, f = u.split(`
|
|
5782
6014
|
`), g = d.split(`
|
|
5783
6015
|
`), m = f.length, y = g.length - m;
|
|
5784
|
-
let v = n,
|
|
5785
|
-
const
|
|
6016
|
+
let v = n, A = !1, b = !1;
|
|
6017
|
+
const O = typeof a == "string" ? a : void 0, S = typeof r == "string" ? r : void 0;
|
|
5786
6018
|
if (y !== 0 && n && Object.keys(n).length) {
|
|
5787
|
-
const E =
|
|
6019
|
+
const E = Ds({
|
|
5788
6020
|
previous: u,
|
|
5789
6021
|
next: d
|
|
5790
6022
|
}), L = xs({
|
|
@@ -5792,38 +6024,38 @@ class rt {
|
|
|
5792
6024
|
charIndex: E
|
|
5793
6025
|
});
|
|
5794
6026
|
if (y > 0) {
|
|
5795
|
-
const
|
|
6027
|
+
const P = Rs({
|
|
5796
6028
|
text: u,
|
|
5797
6029
|
lineIndex: L
|
|
5798
6030
|
});
|
|
5799
6031
|
let B = L + 1;
|
|
5800
|
-
E ===
|
|
5801
|
-
const
|
|
6032
|
+
E === P && (B = L);
|
|
6033
|
+
const z = {};
|
|
5802
6034
|
for (const x in n) {
|
|
5803
6035
|
if (!Object.prototype.hasOwnProperty.call(n, x)) continue;
|
|
5804
|
-
const
|
|
5805
|
-
if (!Number.isFinite(
|
|
5806
|
-
const R = n[
|
|
6036
|
+
const D = Number(x);
|
|
6037
|
+
if (!Number.isFinite(D)) continue;
|
|
6038
|
+
const R = n[D];
|
|
5807
6039
|
if (!R) continue;
|
|
5808
|
-
const N =
|
|
5809
|
-
|
|
6040
|
+
const N = D >= B ? D + y : D;
|
|
6041
|
+
z[N] = F({}, R);
|
|
5810
6042
|
}
|
|
5811
|
-
v =
|
|
6043
|
+
v = z, A = !0, b = !0;
|
|
5812
6044
|
}
|
|
5813
6045
|
if (y < 0) {
|
|
5814
|
-
const
|
|
6046
|
+
const P = Math.abs(y);
|
|
5815
6047
|
let B = L;
|
|
5816
6048
|
u[E] === `
|
|
5817
|
-
` && ((
|
|
5818
|
-
const x = B +
|
|
6049
|
+
` && ((_ = f[L]) != null ? _ : "").length > 0 && (B = L + 1);
|
|
6050
|
+
const x = B + P - 1, D = {};
|
|
5819
6051
|
for (const R in n) {
|
|
5820
6052
|
if (!Object.prototype.hasOwnProperty.call(n, R)) continue;
|
|
5821
6053
|
const N = Number(R);
|
|
5822
6054
|
if (!Number.isFinite(N)) continue;
|
|
5823
6055
|
const K = n[N];
|
|
5824
|
-
K && (N < B && (
|
|
6056
|
+
K && (N < B && (D[N] = F({}, K)), N > x && (D[N + y] = F({}, K)));
|
|
5825
6057
|
}
|
|
5826
|
-
v =
|
|
6058
|
+
v = D, A = !0, b = !0;
|
|
5827
6059
|
}
|
|
5828
6060
|
}
|
|
5829
6061
|
let M = null;
|
|
@@ -5831,30 +6063,30 @@ class rt {
|
|
|
5831
6063
|
const E = t.get2DCursorLocation(c), { lineIndex: L } = E;
|
|
5832
6064
|
Number.isFinite(L) && (M = L);
|
|
5833
6065
|
}
|
|
5834
|
-
let w = s, C = !1,
|
|
6066
|
+
let w = s, C = !1, j = !1, I, T = null;
|
|
5835
6067
|
for (let E = 0; E < g.length; E += 1) {
|
|
5836
|
-
const L = (W = g[E]) != null ? W : "",
|
|
5837
|
-
if (
|
|
5838
|
-
if (
|
|
6068
|
+
const L = (W = g[E]) != null ? W : "", P = v ? v[E] : void 0;
|
|
6069
|
+
if (P && (I = P), L.length !== 0) {
|
|
6070
|
+
if (P) {
|
|
5839
6071
|
const N = Is({
|
|
5840
6072
|
lineText: L,
|
|
5841
6073
|
lineStyles: w ? w[E] : void 0,
|
|
5842
|
-
lineDefaults:
|
|
6074
|
+
lineDefaults: P
|
|
5843
6075
|
});
|
|
5844
|
-
N.changed && (w || (w = {},
|
|
6076
|
+
N.changed && (w || (w = {}, j = !0), j || (w = F({}, w), j = !0), N.lineStyles && (w[E] = N.lineStyles), !N.lineStyles && w[E] && delete w[E], C = !0);
|
|
5845
6077
|
}
|
|
5846
6078
|
continue;
|
|
5847
6079
|
}
|
|
5848
|
-
const
|
|
5849
|
-
(
|
|
5850
|
-
const
|
|
5851
|
-
x.fontFamily !== void 0 && (
|
|
5852
|
-
const R = Object.keys(
|
|
5853
|
-
(R || w && w[E]) && (w || (w = {},
|
|
5854
|
-
}
|
|
5855
|
-
if (
|
|
6080
|
+
const z = P != null ? P : I, x = {};
|
|
6081
|
+
(z == null ? void 0 : z.fontFamily) !== void 0 ? x.fontFamily = z.fontFamily : o !== void 0 && (x.fontFamily = o), (z == null ? void 0 : z.fontSize) !== void 0 ? x.fontSize = z.fontSize : i !== void 0 && (x.fontSize = i), (z == null ? void 0 : z.fill) !== void 0 ? x.fill = z.fill : O !== void 0 && (x.fill = O), (z == null ? void 0 : z.stroke) !== void 0 ? x.stroke = z.stroke : S !== void 0 && (x.stroke = S), !P && Object.keys(x).length && (v || (v = {}, b = !0), b || (v = F({}, v), b = !0), v[E] = x, A = !0, I = x), P && (I = P), M !== null && M === E && (T = x);
|
|
6082
|
+
const D = {};
|
|
6083
|
+
x.fontFamily !== void 0 && (D.fontFamily = x.fontFamily), x.fontSize !== void 0 && (D.fontSize = x.fontSize), x.fill !== void 0 && (D.fill = x.fill), x.stroke !== void 0 && (D.stroke = x.stroke);
|
|
6084
|
+
const R = Object.keys(D).length > 0;
|
|
6085
|
+
(R || w && w[E]) && (w || (w = {}, j = !0), j || (w = F({}, w), j = !0), R && (w[E] = { 0: D }), !R && w[E] && delete w[E], C = !0);
|
|
6086
|
+
}
|
|
6087
|
+
if (A && v && (t.lineFontDefaults = v), C && (t.styles = w, t.dirty = !0), T && typeof c == "number") {
|
|
5856
6088
|
const E = {};
|
|
5857
|
-
if (
|
|
6089
|
+
if (T.fontFamily !== void 0 && (E.fontFamily = T.fontFamily), T.fontSize !== void 0 && (E.fontSize = T.fontSize), T.fill !== void 0 && (E.fill = T.fill), T.stroke !== void 0 && (E.stroke = T.stroke), Object.keys(E).length) {
|
|
5858
6090
|
this.lineDefaultsSyncing.add(t);
|
|
5859
6091
|
try {
|
|
5860
6092
|
t.setSelectionStyles(E, c, c);
|
|
@@ -5870,7 +6102,7 @@ class rt {
|
|
|
5870
6102
|
* но не шире монтажной области, и удерживает объект в её пределах.
|
|
5871
6103
|
*/
|
|
5872
6104
|
_autoExpandTextboxWidth(t, { anchor: e } = {}) {
|
|
5873
|
-
var M, w, C,
|
|
6105
|
+
var M, w, C, j, I, T, k, _, W, E, L, P, B;
|
|
5874
6106
|
const { montageArea: n } = this.editor;
|
|
5875
6107
|
if (!n) return !1;
|
|
5876
6108
|
const s = typeof t.text == "string" ? t.text : "";
|
|
@@ -5878,7 +6110,7 @@ class rt {
|
|
|
5878
6110
|
n.setCoords();
|
|
5879
6111
|
const o = n.getBoundingRect(!1, !0), i = (M = o.width) != null ? M : 0;
|
|
5880
6112
|
if (!Number.isFinite(i) || i <= 0) return !1;
|
|
5881
|
-
const a = e != null ? e : (w = this.editingAnchorState) == null ? void 0 : w.get(t), r = (
|
|
6113
|
+
const a = e != null ? e : (w = this.editingAnchorState) == null ? void 0 : w.get(t), r = (j = (C = a == null ? void 0 : a.originY) != null ? C : t.originY) != null ? j : "top", c = Math.abs((I = t.scaleX) != null ? I : 1) || 1, l = (T = t.paddingLeft) != null ? T : 0, d = (k = t.paddingRight) != null ? k : 0, u = (_ = t.strokeWidth) != null ? _ : 0, f = Math.max(
|
|
5882
6114
|
1,
|
|
5883
6115
|
i / c - l - d - u
|
|
5884
6116
|
);
|
|
@@ -5889,15 +6121,15 @@ class rt {
|
|
|
5889
6121
|
Math.abs(((W = t.width) != null ? W : 0) - f) > it && (t.set({ width: f }), m = !0), t.initDimensions();
|
|
5890
6122
|
const { textLines: p } = t, y = Array.isArray(p) && p.length > g, v = Math.ceil(
|
|
5891
6123
|
ks({ textbox: t, text: s })
|
|
5892
|
-
),
|
|
6124
|
+
), A = Math.min((E = t.minWidth) != null ? E : 1, f);
|
|
5893
6125
|
let b = Math.min(
|
|
5894
6126
|
f,
|
|
5895
|
-
Math.max(v,
|
|
6127
|
+
Math.max(v, A)
|
|
5896
6128
|
);
|
|
5897
|
-
y && (b = f), Math.abs(((L = t.width) != null ? L : 0) - b) > it && (t.set({ width: b }), t.initDimensions(), m = !0),
|
|
6129
|
+
y && (b = f), Math.abs(((L = t.width) != null ? L : 0) - b) > it && (t.set({ width: b }), t.initDimensions(), m = !0), _t({ textbox: t }) && (m = !0), a && (t.setPositionByOrigin(new lt(a.x, a.y), "center", r), m = !0);
|
|
5898
6130
|
const S = Bs({
|
|
5899
6131
|
textbox: t,
|
|
5900
|
-
montageLeft: (
|
|
6132
|
+
montageLeft: (P = o.left) != null ? P : 0,
|
|
5901
6133
|
montageRight: ((B = o.left) != null ? B : 0) + i
|
|
5902
6134
|
});
|
|
5903
6135
|
return m || S;
|
|
@@ -5943,7 +6175,7 @@ class rt {
|
|
|
5943
6175
|
bottomLeft: v
|
|
5944
6176
|
},
|
|
5945
6177
|
baseStyles: JSON.parse(JSON.stringify(c)),
|
|
5946
|
-
baseLineFontDefaults:
|
|
6178
|
+
baseLineFontDefaults: hn({ lineFontDefaults: l }),
|
|
5947
6179
|
hasWidthChange: !1
|
|
5948
6180
|
}, this.scalingState.set(t, e);
|
|
5949
6181
|
}
|
|
@@ -5955,9 +6187,9 @@ class rt {
|
|
|
5955
6187
|
static _getSnapshot(t) {
|
|
5956
6188
|
const e = ({
|
|
5957
6189
|
snapshot: x,
|
|
5958
|
-
entries:
|
|
6190
|
+
entries: D
|
|
5959
6191
|
}) => {
|
|
5960
|
-
Object.entries(
|
|
6192
|
+
Object.entries(D).forEach(([R, N]) => {
|
|
5961
6193
|
N != null && (x[R] = N);
|
|
5962
6194
|
});
|
|
5963
6195
|
}, {
|
|
@@ -5977,30 +6209,30 @@ class rt {
|
|
|
5977
6209
|
stroke: p,
|
|
5978
6210
|
strokeWidth: y,
|
|
5979
6211
|
opacity: v,
|
|
5980
|
-
backgroundColor:
|
|
6212
|
+
backgroundColor: A,
|
|
5981
6213
|
backgroundOpacity: b,
|
|
5982
|
-
paddingTop:
|
|
6214
|
+
paddingTop: O,
|
|
5983
6215
|
paddingRight: S,
|
|
5984
6216
|
paddingBottom: M,
|
|
5985
6217
|
paddingLeft: w,
|
|
5986
6218
|
radiusTopLeft: C,
|
|
5987
|
-
radiusTopRight:
|
|
6219
|
+
radiusTopRight: j,
|
|
5988
6220
|
radiusBottomRight: I,
|
|
5989
|
-
radiusBottomLeft:
|
|
6221
|
+
radiusBottomLeft: T,
|
|
5990
6222
|
left: k,
|
|
5991
|
-
top:
|
|
6223
|
+
top: _,
|
|
5992
6224
|
width: W,
|
|
5993
6225
|
height: E,
|
|
5994
6226
|
angle: L,
|
|
5995
|
-
scaleX:
|
|
6227
|
+
scaleX: P,
|
|
5996
6228
|
scaleY: B
|
|
5997
|
-
} = t,
|
|
6229
|
+
} = t, z = {
|
|
5998
6230
|
id: n,
|
|
5999
6231
|
uppercase: !!i,
|
|
6000
6232
|
textAlign: g
|
|
6001
6233
|
};
|
|
6002
6234
|
return e({
|
|
6003
|
-
snapshot:
|
|
6235
|
+
snapshot: z,
|
|
6004
6236
|
entries: {
|
|
6005
6237
|
text: s,
|
|
6006
6238
|
textCaseRaw: o,
|
|
@@ -6015,25 +6247,25 @@ class rt {
|
|
|
6015
6247
|
stroke: p,
|
|
6016
6248
|
strokeWidth: y,
|
|
6017
6249
|
opacity: v,
|
|
6018
|
-
backgroundColor:
|
|
6250
|
+
backgroundColor: A,
|
|
6019
6251
|
backgroundOpacity: b,
|
|
6020
|
-
paddingTop:
|
|
6252
|
+
paddingTop: O,
|
|
6021
6253
|
paddingRight: S,
|
|
6022
6254
|
paddingBottom: M,
|
|
6023
6255
|
paddingLeft: w,
|
|
6024
6256
|
radiusTopLeft: C,
|
|
6025
|
-
radiusTopRight:
|
|
6257
|
+
radiusTopRight: j,
|
|
6026
6258
|
radiusBottomRight: I,
|
|
6027
|
-
radiusBottomLeft:
|
|
6259
|
+
radiusBottomLeft: T,
|
|
6028
6260
|
left: k,
|
|
6029
|
-
top:
|
|
6261
|
+
top: _,
|
|
6030
6262
|
width: W,
|
|
6031
6263
|
height: E,
|
|
6032
6264
|
angle: L,
|
|
6033
|
-
scaleX:
|
|
6265
|
+
scaleX: P,
|
|
6034
6266
|
scaleY: B
|
|
6035
6267
|
}
|
|
6036
|
-
}),
|
|
6268
|
+
}), z;
|
|
6037
6269
|
}
|
|
6038
6270
|
/**
|
|
6039
6271
|
* Возвращает первый доступный шрифт или дефолтный Arial.
|
|
@@ -6043,12 +6275,12 @@ class rt {
|
|
|
6043
6275
|
return (e = (t = this.fonts[0]) == null ? void 0 : t.family) != null ? e : "Arial";
|
|
6044
6276
|
}
|
|
6045
6277
|
}
|
|
6046
|
-
const
|
|
6278
|
+
const ue = ({
|
|
6047
6279
|
value: h
|
|
6048
6280
|
}) => Math.round(h / 2) * 2, nt = ({
|
|
6049
6281
|
value: h,
|
|
6050
6282
|
fallback: t = 0
|
|
6051
|
-
}) => typeof h == "number" && Number.isFinite(h) ? h : typeof t == "number" && Number.isFinite(t) ? t : 0,
|
|
6283
|
+
}) => typeof h == "number" && Number.isFinite(h) ? h : typeof t == "number" && Number.isFinite(t) ? t : 0, fe = ({
|
|
6052
6284
|
value: h,
|
|
6053
6285
|
dimension: t,
|
|
6054
6286
|
useRelativePositions: e
|
|
@@ -6065,22 +6297,22 @@ const he = ({
|
|
|
6065
6297
|
const o = h;
|
|
6066
6298
|
if (typeof o[s.x] == "number" && typeof o[s.y] == "number")
|
|
6067
6299
|
return {
|
|
6068
|
-
x:
|
|
6300
|
+
x: fe({
|
|
6069
6301
|
value: o[s.x],
|
|
6070
6302
|
dimension: t,
|
|
6071
6303
|
useRelativePositions: n
|
|
6072
6304
|
}),
|
|
6073
|
-
y:
|
|
6305
|
+
y: fe({
|
|
6074
6306
|
value: o[s.y],
|
|
6075
6307
|
dimension: e,
|
|
6076
6308
|
useRelativePositions: n
|
|
6077
6309
|
})
|
|
6078
6310
|
};
|
|
6079
|
-
const { left: a, top: r, width: c, height: l } = h, d =
|
|
6311
|
+
const { left: a, top: r, width: c, height: l } = h, d = fe({
|
|
6080
6312
|
value: a,
|
|
6081
6313
|
dimension: t,
|
|
6082
6314
|
useRelativePositions: n
|
|
6083
|
-
}), u =
|
|
6315
|
+
}), u = fe({
|
|
6084
6316
|
value: r,
|
|
6085
6317
|
dimension: e,
|
|
6086
6318
|
useRelativePositions: n
|
|
@@ -6089,7 +6321,7 @@ const he = ({
|
|
|
6089
6321
|
x: d + f / 2,
|
|
6090
6322
|
y: u + g / 2
|
|
6091
6323
|
};
|
|
6092
|
-
},
|
|
6324
|
+
}, Ps = ({
|
|
6093
6325
|
normalizedX: h,
|
|
6094
6326
|
normalizedY: t,
|
|
6095
6327
|
bounds: e,
|
|
@@ -6103,7 +6335,7 @@ const he = ({
|
|
|
6103
6335
|
}
|
|
6104
6336
|
const c = o + h * a, l = i + t * r;
|
|
6105
6337
|
return new lt(c, l);
|
|
6106
|
-
},
|
|
6338
|
+
}, zs = ({
|
|
6107
6339
|
object: h,
|
|
6108
6340
|
montageArea: t,
|
|
6109
6341
|
bounds: e
|
|
@@ -6118,7 +6350,7 @@ const he = ({
|
|
|
6118
6350
|
} catch (n) {
|
|
6119
6351
|
return null;
|
|
6120
6352
|
}
|
|
6121
|
-
},
|
|
6353
|
+
}, yt = ({
|
|
6122
6354
|
object: h
|
|
6123
6355
|
}) => {
|
|
6124
6356
|
if (!h) return null;
|
|
@@ -6129,7 +6361,7 @@ const he = ({
|
|
|
6129
6361
|
top: n = 0,
|
|
6130
6362
|
width: s = 0,
|
|
6131
6363
|
height: o = 0
|
|
6132
|
-
} = t, i = e + s, a = n + o, r =
|
|
6364
|
+
} = t, i = e + s, a = n + o, r = ue({ value: e }), c = ue({ value: n }), l = ue({ value: i }), d = ue({ value: a }), u = l - r, f = d - c, g = r + u / 2, m = c + f / 2;
|
|
6133
6365
|
return {
|
|
6134
6366
|
left: r,
|
|
6135
6367
|
right: l,
|
|
@@ -6182,7 +6414,7 @@ const he = ({
|
|
|
6182
6414
|
};
|
|
6183
6415
|
}
|
|
6184
6416
|
return null;
|
|
6185
|
-
},
|
|
6417
|
+
}, Qt = "_templateCenterX", Ae = "_templateCenterY", ge = "_templateAnchorX", Ce = "_templateAnchorY";
|
|
6186
6418
|
class Z {
|
|
6187
6419
|
constructor({ editor: t }) {
|
|
6188
6420
|
this.editor = t;
|
|
@@ -6207,16 +6439,16 @@ class Z {
|
|
|
6207
6439
|
return a.emitWarning({
|
|
6208
6440
|
origin: "TemplateManager",
|
|
6209
6441
|
method: "serializeSelection",
|
|
6210
|
-
code:
|
|
6442
|
+
code: Lt.TEMPLATE_MANAGER.NO_OBJECTS_SELECTED,
|
|
6211
6443
|
message: "Нет объектов для сериализации шаблона"
|
|
6212
6444
|
}), null;
|
|
6213
|
-
const g = Z._getBounds(i), m = Z._getMontageSize({ montageArea: i, bounds: g }), p = m.width, y = m.height, v = f.map((
|
|
6214
|
-
object:
|
|
6445
|
+
const g = Z._getBounds(i), m = Z._getMontageSize({ montageArea: i, bounds: g }), p = m.width, y = m.height, v = f.map((O) => Z._serializeObject({
|
|
6446
|
+
object: O,
|
|
6215
6447
|
bounds: g,
|
|
6216
6448
|
baseWidth: p,
|
|
6217
6449
|
baseHeight: y,
|
|
6218
6450
|
montageArea: i != null ? i : null
|
|
6219
|
-
})),
|
|
6451
|
+
})), A = Et(F({}, n), {
|
|
6220
6452
|
baseWidth: p,
|
|
6221
6453
|
baseHeight: y,
|
|
6222
6454
|
positionsNormalized: !0,
|
|
@@ -6224,7 +6456,7 @@ class Z {
|
|
|
6224
6456
|
});
|
|
6225
6457
|
return {
|
|
6226
6458
|
id: t != null ? t : `template-${et()}`,
|
|
6227
|
-
meta:
|
|
6459
|
+
meta: A,
|
|
6228
6460
|
objects: v
|
|
6229
6461
|
};
|
|
6230
6462
|
}
|
|
@@ -6248,7 +6480,7 @@ class Z {
|
|
|
6248
6480
|
return i.emitWarning({
|
|
6249
6481
|
origin: "TemplateManager",
|
|
6250
6482
|
method: "applyTemplate",
|
|
6251
|
-
code:
|
|
6483
|
+
code: Lt.TEMPLATE_MANAGER.INVALID_TEMPLATE,
|
|
6252
6484
|
message: "Шаблон не содержит объектов"
|
|
6253
6485
|
}), null;
|
|
6254
6486
|
const d = Z._getBounds(s);
|
|
@@ -6256,7 +6488,7 @@ class Z {
|
|
|
6256
6488
|
return i.emitWarning({
|
|
6257
6489
|
origin: "TemplateManager",
|
|
6258
6490
|
method: "applyTemplate",
|
|
6259
|
-
code:
|
|
6491
|
+
code: Lt.TEMPLATE_MANAGER.INVALID_TARGET,
|
|
6260
6492
|
message: "Не удалось определить границы монтажной области"
|
|
6261
6493
|
}), null;
|
|
6262
6494
|
const u = Z._getMontageSize({ montageArea: s, bounds: d }), f = Z._normalizeMeta({ meta: c, fallback: u }), g = Z._calculateScale({ meta: f, target: u }), m = !!f.positionsNormalized;
|
|
@@ -6268,16 +6500,16 @@ class Z {
|
|
|
6268
6500
|
return i.emitWarning({
|
|
6269
6501
|
origin: "TemplateManager",
|
|
6270
6502
|
method: "applyTemplate",
|
|
6271
|
-
code:
|
|
6503
|
+
code: Lt.TEMPLATE_MANAGER.INVALID_TEMPLATE,
|
|
6272
6504
|
message: "Не удалось создать объекты шаблона"
|
|
6273
6505
|
}), null;
|
|
6274
|
-
const { backgroundObject:
|
|
6275
|
-
|
|
6276
|
-
backgroundObject:
|
|
6506
|
+
const { backgroundObject: A, contentObjects: b } = Z._extractBackgroundObject(v);
|
|
6507
|
+
A && (y = yield Z._applyBackgroundFromObject({
|
|
6508
|
+
backgroundObject: A,
|
|
6277
6509
|
backgroundManager: a,
|
|
6278
6510
|
errorManager: i
|
|
6279
6511
|
}));
|
|
6280
|
-
const
|
|
6512
|
+
const O = b.map((S) => (this._adaptTextboxWidth({
|
|
6281
6513
|
object: S,
|
|
6282
6514
|
baseWidth: f.baseWidth
|
|
6283
6515
|
}), Z._transformObject({
|
|
@@ -6293,16 +6525,16 @@ class Z {
|
|
|
6293
6525
|
id: `${S.type}-${et()}`,
|
|
6294
6526
|
evented: !0
|
|
6295
6527
|
}), n.add(S), S));
|
|
6296
|
-
return !
|
|
6528
|
+
return !O.length && !y ? null : (p = O.length > 0 || y, O.length && Z._activateObjects({ canvas: n, objects: O }), n.requestRenderAll(), n.fire("editor:template-applied", {
|
|
6297
6529
|
template: t,
|
|
6298
|
-
objects:
|
|
6530
|
+
objects: O,
|
|
6299
6531
|
bounds: d
|
|
6300
|
-
}),
|
|
6532
|
+
}), O);
|
|
6301
6533
|
} catch (v) {
|
|
6302
6534
|
return i.emitError({
|
|
6303
6535
|
origin: "TemplateManager",
|
|
6304
6536
|
method: "applyTemplate",
|
|
6305
|
-
code:
|
|
6537
|
+
code: Lt.TEMPLATE_MANAGER.APPLY_FAILED,
|
|
6306
6538
|
message: "Ошибка применения шаблона",
|
|
6307
6539
|
data: {
|
|
6308
6540
|
templateId: l,
|
|
@@ -6349,7 +6581,7 @@ class Z {
|
|
|
6349
6581
|
if (i)
|
|
6350
6582
|
return Z._restoreImageScale({ revived: i, serialized: n }), i;
|
|
6351
6583
|
}
|
|
6352
|
-
const s = yield
|
|
6584
|
+
const s = yield bt.enlivenObjects([n]), o = s == null ? void 0 : s[0];
|
|
6353
6585
|
return o ? (Z._restoreImageScale({ revived: o, serialized: n }), o) : null;
|
|
6354
6586
|
})))).filter((n) => !!n);
|
|
6355
6587
|
});
|
|
@@ -6378,22 +6610,22 @@ class Z {
|
|
|
6378
6610
|
naturalHeight: 0,
|
|
6379
6611
|
width: 0,
|
|
6380
6612
|
height: 0
|
|
6381
|
-
}, m = nt({ value: d || f || c.width, fallback: 0 }), p = nt({ value: u || g || c.height, fallback: 0 }), y = nt({ value: s, fallback: m }), v = nt({ value: o, fallback: p }),
|
|
6382
|
-
if (M && (
|
|
6383
|
-
c.set(
|
|
6613
|
+
}, m = nt({ value: d || f || c.width, fallback: 0 }), p = nt({ value: u || g || c.height, fallback: 0 }), y = nt({ value: s, fallback: m }), v = nt({ value: o, fallback: p }), A = nt({ value: i, fallback: c.scaleX || 1 }), b = nt({ value: a, fallback: c.scaleY || 1 }), O = y * A, S = v * b, M = m > 0, w = p > 0, C = O > 0, j = S > 0, I = Z._resolveImageFit({ customData: r }), T = {};
|
|
6614
|
+
if (M && (T.width = m), w && (T.height = p), !M || !w) {
|
|
6615
|
+
c.set(T);
|
|
6384
6616
|
return;
|
|
6385
6617
|
}
|
|
6386
6618
|
if (I === "stretch") {
|
|
6387
|
-
const
|
|
6388
|
-
|
|
6619
|
+
const _ = C ? O / m : null, W = j ? S / p : null;
|
|
6620
|
+
_ && _ > 0 && (T.scaleX = _), W && W > 0 && (T.scaleY = W), c.set(T);
|
|
6389
6621
|
return;
|
|
6390
6622
|
}
|
|
6391
|
-
if (!C || !
|
|
6392
|
-
c.set(
|
|
6623
|
+
if (!C || !j) {
|
|
6624
|
+
c.set(T);
|
|
6393
6625
|
return;
|
|
6394
6626
|
}
|
|
6395
|
-
const k = Math.min(
|
|
6396
|
-
Number.isFinite(k) && k > 0 && (
|
|
6627
|
+
const k = Math.min(O / m, S / p);
|
|
6628
|
+
Number.isFinite(k) && k > 0 && (T.scaleX = k, T.scaleY = k), c.set(T);
|
|
6397
6629
|
}
|
|
6398
6630
|
/**
|
|
6399
6631
|
* Определяет режим вписывания изображения при восстановлении.
|
|
@@ -6419,7 +6651,7 @@ class Z {
|
|
|
6419
6651
|
const e = typeof t.svgMarkup == "string" ? t.svgMarkup : null;
|
|
6420
6652
|
if (!e) return null;
|
|
6421
6653
|
try {
|
|
6422
|
-
const n = yield
|
|
6654
|
+
const n = yield kn(e), s = bt.groupSVGElements(n.objects, n.options), o = yield bt.enlivenObjectEnlivables(
|
|
6423
6655
|
Z._prepareSerializableProps(t)
|
|
6424
6656
|
);
|
|
6425
6657
|
return s.set(o), s.setCoords(), s;
|
|
@@ -6484,7 +6716,7 @@ class Z {
|
|
|
6484
6716
|
baseHeight: i,
|
|
6485
6717
|
useRelativePositions: r,
|
|
6486
6718
|
centerKeys: {
|
|
6487
|
-
x:
|
|
6719
|
+
x: Qt,
|
|
6488
6720
|
y: Ae
|
|
6489
6721
|
}
|
|
6490
6722
|
}), { scaleX: u, scaleY: f } = t, g = nt({ value: u, fallback: 1 }), m = nt({ value: f, fallback: 1 }), p = Z._getPositioningBounds({
|
|
@@ -6493,19 +6725,19 @@ class Z {
|
|
|
6493
6725
|
baseHeight: i,
|
|
6494
6726
|
scale: e,
|
|
6495
6727
|
useRelativePositions: r,
|
|
6496
|
-
anchorX: Z._resolveAnchor(c,
|
|
6497
|
-
anchorY: Z._resolveAnchor(c,
|
|
6498
|
-
}), y =
|
|
6728
|
+
anchorX: Z._resolveAnchor(c, ge),
|
|
6729
|
+
anchorY: Z._resolveAnchor(c, Ce)
|
|
6730
|
+
}), y = Ps({
|
|
6499
6731
|
normalizedX: l,
|
|
6500
6732
|
normalizedY: d,
|
|
6501
6733
|
bounds: p,
|
|
6502
6734
|
targetSize: s,
|
|
6503
6735
|
montageArea: a
|
|
6504
|
-
}), v = g * e,
|
|
6736
|
+
}), v = g * e, A = m * e;
|
|
6505
6737
|
t.set({
|
|
6506
6738
|
scaleX: v,
|
|
6507
|
-
scaleY:
|
|
6508
|
-
}), t.setPositionByOrigin(y, "center", "center"), t.setCoords(), delete c[
|
|
6739
|
+
scaleY: A
|
|
6740
|
+
}), t.setPositionByOrigin(y, "center", "center"), t.setCoords(), delete c[Qt], delete c[Ae], delete c[ge], delete c[Ce];
|
|
6509
6741
|
}
|
|
6510
6742
|
/**
|
|
6511
6743
|
* Возвращает bounds, в которых должны позиционироваться нормализованные объекты.
|
|
@@ -6552,7 +6784,7 @@ class Z {
|
|
|
6552
6784
|
meta: t,
|
|
6553
6785
|
fallback: e
|
|
6554
6786
|
}) {
|
|
6555
|
-
const { width: n, height: s } = e, r = t || {}, { baseWidth: o = n, baseHeight: i = s } = r, a =
|
|
6787
|
+
const { width: n, height: s } = e, r = t || {}, { baseWidth: o = n, baseHeight: i = s } = r, a = Ct(r, ["baseWidth", "baseHeight"]);
|
|
6556
6788
|
return F({
|
|
6557
6789
|
baseWidth: o,
|
|
6558
6790
|
baseHeight: i
|
|
@@ -6604,16 +6836,16 @@ class Z {
|
|
|
6604
6836
|
} = t, r = nt({ value: e, fallback: 0 }), c = t, l = nt({ value: c.paddingLeft, fallback: 0 }), d = nt({ value: c.paddingRight, fallback: 0 }), u = nt({ value: i, fallback: 1 }), f = nt({ value: a, fallback: 0 }) * u, g = nt({ value: o, fallback: 0 }), m = g * u, p = l * u, y = d * u, v = m + p + y + f;
|
|
6605
6837
|
if (!s || !g || !r) return;
|
|
6606
6838
|
t.setCoords();
|
|
6607
|
-
const
|
|
6839
|
+
const A = t, b = A[Qt], O = typeof b == "number" ? b : null, S = Z._resolveAnchor(A, ge), M = v / r, w = O !== null ? O - M / 2 : null, C = O !== null ? O + M / 2 : null, j = t.getCenterPoint();
|
|
6608
6840
|
t.set("width", s), t.initDimensions();
|
|
6609
6841
|
const I = Z._getLongestLineWidth({
|
|
6610
6842
|
textbox: t,
|
|
6611
6843
|
text: n
|
|
6612
|
-
}),
|
|
6613
|
-
t.set("width",
|
|
6614
|
-
const
|
|
6615
|
-
let W =
|
|
6616
|
-
S === "start" && w !== null ? W = Math.max(0, w) +
|
|
6844
|
+
}), T = I > g ? I + 1 : g;
|
|
6845
|
+
t.set("width", T), t.initDimensions(), t.setPositionByOrigin(j, "center", "center"), t.setCoords();
|
|
6846
|
+
const _ = (T * u + p + y + f) / r;
|
|
6847
|
+
let W = O;
|
|
6848
|
+
S === "start" && w !== null ? W = Math.max(0, w) + _ / 2 : S === "end" && C !== null && (W = Math.min(1, C) - _ / 2), typeof W == "number" && (A[Qt] = W);
|
|
6617
6849
|
}
|
|
6618
6850
|
/**
|
|
6619
6851
|
* Возвращает ширину самой длинной строки текстового объекта.
|
|
@@ -6643,7 +6875,7 @@ class Z {
|
|
|
6643
6875
|
baseHeight: s,
|
|
6644
6876
|
montageArea: o
|
|
6645
6877
|
}) {
|
|
6646
|
-
const i = t.toDatalessObject([...
|
|
6878
|
+
const i = t.toDatalessObject([...De]);
|
|
6647
6879
|
if (Z._isSvgObject(t)) {
|
|
6648
6880
|
const b = Z._extractSvgMarkup(t);
|
|
6649
6881
|
b && (i.svgMarkup = b, delete i.objects, delete i.path);
|
|
@@ -6654,7 +6886,7 @@ class Z {
|
|
|
6654
6886
|
top: r,
|
|
6655
6887
|
width: c,
|
|
6656
6888
|
height: l
|
|
6657
|
-
} = e, d = t.getBoundingRect(!1, !0), u = n || c || 1, f = s || l || 1, g =
|
|
6889
|
+
} = e, d = t.getBoundingRect(!1, !0), u = n || c || 1, f = s || l || 1, g = zs({
|
|
6658
6890
|
object: t,
|
|
6659
6891
|
montageArea: o,
|
|
6660
6892
|
bounds: e
|
|
@@ -6664,15 +6896,15 @@ class Z {
|
|
|
6664
6896
|
x: (b.x - a) / u,
|
|
6665
6897
|
y: (b.y - r) / f
|
|
6666
6898
|
};
|
|
6667
|
-
})(), p = (d.left - a) / u, y = (d.top - r) / f, v = p + d.width / u,
|
|
6668
|
-
return i[
|
|
6899
|
+
})(), p = (d.left - a) / u, y = (d.top - r) / f, v = p + d.width / u, A = y + d.height / f;
|
|
6900
|
+
return i[Qt] = m.x, i[Ae] = m.y, i[ge] = Z._detectAnchor({
|
|
6669
6901
|
center: m.x,
|
|
6670
6902
|
start: p,
|
|
6671
6903
|
end: v
|
|
6672
|
-
}), i[
|
|
6904
|
+
}), i[Ce] = Z._detectAnchor({
|
|
6673
6905
|
center: m.y,
|
|
6674
6906
|
start: y,
|
|
6675
|
-
end:
|
|
6907
|
+
end: A
|
|
6676
6908
|
}), i.left = p, i.top = y, i;
|
|
6677
6909
|
}
|
|
6678
6910
|
/**
|
|
@@ -6727,7 +6959,7 @@ class Z {
|
|
|
6727
6959
|
n.emitWarning({
|
|
6728
6960
|
origin: "TemplateManager",
|
|
6729
6961
|
method: "applyTemplate",
|
|
6730
|
-
code:
|
|
6962
|
+
code: Lt.TEMPLATE_MANAGER.APPLY_FAILED,
|
|
6731
6963
|
message: "Не удалось применить фон из шаблона",
|
|
6732
6964
|
data: o
|
|
6733
6965
|
});
|
|
@@ -6783,16 +7015,16 @@ class Z {
|
|
|
6783
7015
|
*/
|
|
6784
7016
|
// eslint-disable-next-line class-methods-use-this
|
|
6785
7017
|
enlivenObjectEnlivables(t) {
|
|
6786
|
-
return
|
|
7018
|
+
return bt.enlivenObjectEnlivables(t);
|
|
6787
7019
|
}
|
|
6788
7020
|
}
|
|
6789
|
-
const
|
|
7021
|
+
const Ie = 5, Sn = "#3D8BF4", ke = 1, ot = 2, Ye = ({
|
|
6790
7022
|
value: h,
|
|
6791
7023
|
step: t
|
|
6792
|
-
}) => Math.round(h / t) * t,
|
|
7024
|
+
}) => Math.round(h / t) * t, vt = ({
|
|
6793
7025
|
value: h,
|
|
6794
7026
|
step: t
|
|
6795
|
-
}) =>
|
|
7027
|
+
}) => Ye({ value: h, step: t }) === h, wn = ({
|
|
6796
7028
|
items: h,
|
|
6797
7029
|
axis: t
|
|
6798
7030
|
}) => {
|
|
@@ -6806,7 +7038,7 @@ const Ce = 5, Mn = "#3D8BF4", Re = 1, ot = 2, Ue = ({
|
|
|
6806
7038
|
}
|
|
6807
7039
|
h[i + 1] = n;
|
|
6808
7040
|
}
|
|
6809
|
-
},
|
|
7041
|
+
}, jn = ({
|
|
6810
7042
|
items: h
|
|
6811
7043
|
}) => {
|
|
6812
7044
|
for (let t = 0; t < h.length; t += 1) {
|
|
@@ -6830,7 +7062,7 @@ const Ce = 5, Mn = "#3D8BF4", Re = 1, ot = 2, Ue = ({
|
|
|
6830
7062
|
});
|
|
6831
7063
|
}
|
|
6832
7064
|
return e;
|
|
6833
|
-
},
|
|
7065
|
+
}, pn = ({
|
|
6834
7066
|
anchors: h,
|
|
6835
7067
|
positions: t,
|
|
6836
7068
|
threshold: e
|
|
@@ -6850,11 +7082,11 @@ const Ce = 5, Mn = "#3D8BF4", Re = 1, ot = 2, Ue = ({
|
|
|
6850
7082
|
threshold: t,
|
|
6851
7083
|
anchors: e
|
|
6852
7084
|
}) => {
|
|
6853
|
-
const { left: n, right: s, centerX: o, top: i, bottom: a, centerY: r } = h, c =
|
|
7085
|
+
const { left: n, right: s, centerX: o, top: i, bottom: a, centerY: r } = h, c = pn({
|
|
6854
7086
|
anchors: e.vertical,
|
|
6855
7087
|
positions: [n, o, s],
|
|
6856
7088
|
threshold: t
|
|
6857
|
-
}), l =
|
|
7089
|
+
}), l = pn({
|
|
6858
7090
|
anchors: e.horizontal,
|
|
6859
7091
|
positions: [i, r, a],
|
|
6860
7092
|
threshold: t
|
|
@@ -6892,40 +7124,40 @@ const Ce = 5, Mn = "#3D8BF4", Re = 1, ot = 2, Ue = ({
|
|
|
6892
7124
|
const l = [];
|
|
6893
7125
|
for (const S of c)
|
|
6894
7126
|
l.push({ bounds: S, isActive: !1 });
|
|
6895
|
-
l.push({ bounds: h, isActive: !0 }),
|
|
6896
|
-
const d =
|
|
7127
|
+
l.push({ bounds: h, isActive: !0 }), wn({ items: l, axis: "top" });
|
|
7128
|
+
const d = jn({ items: l });
|
|
6897
7129
|
if (d === -1)
|
|
6898
7130
|
return { delta: 0, guide: null };
|
|
6899
7131
|
const u = [], f = i - o, g = l[d - 1], m = l[d + 1];
|
|
6900
7132
|
if (g && m) {
|
|
6901
7133
|
const { bounds: S } = g, { bounds: M } = m, { bottom: w } = S, { top: C } = M, I = C - w - f;
|
|
6902
7134
|
if (I >= 0) {
|
|
6903
|
-
const
|
|
6904
|
-
if (
|
|
6905
|
-
const
|
|
7135
|
+
const T = I / 2;
|
|
7136
|
+
if (vt({ value: T, step: ot })) {
|
|
7137
|
+
const _ = Ye({ value: T, step: ot }), W = o - w, E = C - i, L = Math.abs(W - _), P = Math.abs(E - _), B = Math.max(L, P);
|
|
6906
7138
|
if (B <= e) {
|
|
6907
|
-
const
|
|
6908
|
-
if (
|
|
6909
|
-
const
|
|
7139
|
+
const z = _ - W;
|
|
7140
|
+
if (vt({ value: z, step: ot })) {
|
|
7141
|
+
const D = i + z, R = {
|
|
6910
7142
|
type: "vertical",
|
|
6911
7143
|
axis: s,
|
|
6912
7144
|
refStart: w,
|
|
6913
|
-
refEnd: w +
|
|
6914
|
-
activeStart:
|
|
6915
|
-
activeEnd:
|
|
6916
|
-
distance:
|
|
7145
|
+
refEnd: w + _,
|
|
7146
|
+
activeStart: D,
|
|
7147
|
+
activeEnd: D + _,
|
|
7148
|
+
distance: _
|
|
6917
7149
|
};
|
|
6918
|
-
u.push({ delta:
|
|
7150
|
+
u.push({ delta: z, guide: R, diff: B });
|
|
6919
7151
|
}
|
|
6920
7152
|
}
|
|
6921
7153
|
}
|
|
6922
7154
|
}
|
|
6923
7155
|
}
|
|
6924
7156
|
const p = An({ items: l, axis: "vertical" });
|
|
6925
|
-
let y = null, v = null,
|
|
7157
|
+
let y = null, v = null, A = null, b = null;
|
|
6926
7158
|
if (g) {
|
|
6927
|
-
|
|
6928
|
-
const { bottom: S } =
|
|
7159
|
+
A = g.bounds;
|
|
7160
|
+
const { bottom: S } = A, M = o - S;
|
|
6929
7161
|
M >= 0 && (y = M);
|
|
6930
7162
|
}
|
|
6931
7163
|
if (m) {
|
|
@@ -6938,56 +7170,56 @@ const Ce = 5, Mn = "#3D8BF4", Re = 1, ot = 2, Ue = ({
|
|
|
6938
7170
|
beforeIndex: M,
|
|
6939
7171
|
afterIndex: w,
|
|
6940
7172
|
start: C,
|
|
6941
|
-
end:
|
|
7173
|
+
end: j,
|
|
6942
7174
|
distance: I
|
|
6943
7175
|
} = S;
|
|
6944
|
-
if (!(M === d || w === d || !
|
|
6945
|
-
if (y !== null &&
|
|
7176
|
+
if (!(M === d || w === d || !vt({ value: I, step: ot }))) {
|
|
7177
|
+
if (y !== null && A) {
|
|
6946
7178
|
const k = Math.abs(y - I);
|
|
6947
7179
|
if (k <= e) {
|
|
6948
|
-
const
|
|
6949
|
-
if (!
|
|
6950
|
-
const E = o +
|
|
7180
|
+
const _ = I - y;
|
|
7181
|
+
if (!vt({ value: _, step: ot })) continue;
|
|
7182
|
+
const E = o + _, { bottom: L } = A, P = {
|
|
6951
7183
|
type: "vertical",
|
|
6952
7184
|
axis: s,
|
|
6953
7185
|
refStart: C,
|
|
6954
|
-
refEnd:
|
|
7186
|
+
refEnd: j,
|
|
6955
7187
|
activeStart: L,
|
|
6956
7188
|
activeEnd: E,
|
|
6957
7189
|
distance: I
|
|
6958
7190
|
};
|
|
6959
|
-
u.push({ delta:
|
|
7191
|
+
u.push({ delta: _, guide: P, diff: k });
|
|
6960
7192
|
}
|
|
6961
7193
|
}
|
|
6962
7194
|
if (v !== null && b) {
|
|
6963
7195
|
const k = Math.abs(v - I);
|
|
6964
7196
|
if (k <= e) {
|
|
6965
|
-
const
|
|
6966
|
-
if (!
|
|
6967
|
-
const E = i +
|
|
7197
|
+
const _ = v - I;
|
|
7198
|
+
if (!vt({ value: _, step: ot })) continue;
|
|
7199
|
+
const E = i + _, { top: L } = b, P = {
|
|
6968
7200
|
type: "vertical",
|
|
6969
7201
|
axis: s,
|
|
6970
7202
|
refStart: C,
|
|
6971
|
-
refEnd:
|
|
7203
|
+
refEnd: j,
|
|
6972
7204
|
activeStart: E,
|
|
6973
7205
|
activeEnd: L,
|
|
6974
7206
|
distance: I
|
|
6975
7207
|
};
|
|
6976
|
-
u.push({ delta:
|
|
7208
|
+
u.push({ delta: _, guide: P, diff: k });
|
|
6977
7209
|
}
|
|
6978
7210
|
}
|
|
6979
7211
|
}
|
|
6980
7212
|
}
|
|
6981
7213
|
if (!u.length)
|
|
6982
7214
|
return { delta: 0, guide: null };
|
|
6983
|
-
let
|
|
7215
|
+
let O = u[0];
|
|
6984
7216
|
for (let S = 1; S < u.length; S += 1) {
|
|
6985
7217
|
const M = u[S];
|
|
6986
|
-
M.diff <
|
|
7218
|
+
M.diff < O.diff && (O = M);
|
|
6987
7219
|
}
|
|
6988
7220
|
return {
|
|
6989
|
-
delta:
|
|
6990
|
-
guide:
|
|
7221
|
+
delta: O.delta,
|
|
7222
|
+
guide: O.guide
|
|
6991
7223
|
};
|
|
6992
7224
|
}, Hs = ({
|
|
6993
7225
|
activeBounds: h,
|
|
@@ -7011,40 +7243,40 @@ const Ce = 5, Mn = "#3D8BF4", Re = 1, ot = 2, Ue = ({
|
|
|
7011
7243
|
const l = [];
|
|
7012
7244
|
for (const S of c)
|
|
7013
7245
|
l.push({ bounds: S, isActive: !1 });
|
|
7014
|
-
l.push({ bounds: h, isActive: !0 }),
|
|
7015
|
-
const d =
|
|
7246
|
+
l.push({ bounds: h, isActive: !0 }), wn({ items: l, axis: "left" });
|
|
7247
|
+
const d = jn({ items: l });
|
|
7016
7248
|
if (d === -1)
|
|
7017
7249
|
return { delta: 0, guide: null };
|
|
7018
7250
|
const u = [], f = i - o, g = l[d - 1], m = l[d + 1];
|
|
7019
7251
|
if (g && m) {
|
|
7020
7252
|
const { bounds: S } = g, { bounds: M } = m, { right: w } = S, { left: C } = M, I = C - w - f;
|
|
7021
7253
|
if (I >= 0) {
|
|
7022
|
-
const
|
|
7023
|
-
if (
|
|
7024
|
-
const
|
|
7254
|
+
const T = I / 2;
|
|
7255
|
+
if (vt({ value: T, step: ot })) {
|
|
7256
|
+
const _ = Ye({ value: T, step: ot }), W = o - w, E = C - i, L = Math.abs(W - _), P = Math.abs(E - _), B = Math.max(L, P);
|
|
7025
7257
|
if (B <= e) {
|
|
7026
|
-
const
|
|
7027
|
-
if (
|
|
7028
|
-
const
|
|
7258
|
+
const z = _ - W;
|
|
7259
|
+
if (vt({ value: z, step: ot })) {
|
|
7260
|
+
const D = i + z, R = {
|
|
7029
7261
|
type: "horizontal",
|
|
7030
7262
|
axis: s,
|
|
7031
7263
|
refStart: w,
|
|
7032
|
-
refEnd: w +
|
|
7033
|
-
activeStart:
|
|
7034
|
-
activeEnd:
|
|
7035
|
-
distance:
|
|
7264
|
+
refEnd: w + _,
|
|
7265
|
+
activeStart: D,
|
|
7266
|
+
activeEnd: D + _,
|
|
7267
|
+
distance: _
|
|
7036
7268
|
};
|
|
7037
|
-
u.push({ delta:
|
|
7269
|
+
u.push({ delta: z, guide: R, diff: B });
|
|
7038
7270
|
}
|
|
7039
7271
|
}
|
|
7040
7272
|
}
|
|
7041
7273
|
}
|
|
7042
7274
|
}
|
|
7043
7275
|
const p = An({ items: l, axis: "horizontal" });
|
|
7044
|
-
let y = null, v = null,
|
|
7276
|
+
let y = null, v = null, A = null, b = null;
|
|
7045
7277
|
if (g) {
|
|
7046
|
-
|
|
7047
|
-
const { right: S } =
|
|
7278
|
+
A = g.bounds;
|
|
7279
|
+
const { right: S } = A, M = o - S;
|
|
7048
7280
|
M >= 0 && (y = M);
|
|
7049
7281
|
}
|
|
7050
7282
|
if (m) {
|
|
@@ -7057,56 +7289,56 @@ const Ce = 5, Mn = "#3D8BF4", Re = 1, ot = 2, Ue = ({
|
|
|
7057
7289
|
beforeIndex: M,
|
|
7058
7290
|
afterIndex: w,
|
|
7059
7291
|
start: C,
|
|
7060
|
-
end:
|
|
7292
|
+
end: j,
|
|
7061
7293
|
distance: I
|
|
7062
7294
|
} = S;
|
|
7063
|
-
if (!(M === d || w === d || !
|
|
7064
|
-
if (y !== null &&
|
|
7295
|
+
if (!(M === d || w === d || !vt({ value: I, step: ot }))) {
|
|
7296
|
+
if (y !== null && A) {
|
|
7065
7297
|
const k = Math.abs(y - I);
|
|
7066
7298
|
if (k <= e) {
|
|
7067
|
-
const
|
|
7068
|
-
if (!
|
|
7069
|
-
const E = o +
|
|
7299
|
+
const _ = I - y;
|
|
7300
|
+
if (!vt({ value: _, step: ot })) continue;
|
|
7301
|
+
const E = o + _, { right: L } = A, P = {
|
|
7070
7302
|
type: "horizontal",
|
|
7071
7303
|
axis: s,
|
|
7072
7304
|
refStart: C,
|
|
7073
|
-
refEnd:
|
|
7305
|
+
refEnd: j,
|
|
7074
7306
|
activeStart: L,
|
|
7075
7307
|
activeEnd: E,
|
|
7076
7308
|
distance: I
|
|
7077
7309
|
};
|
|
7078
|
-
u.push({ delta:
|
|
7310
|
+
u.push({ delta: _, guide: P, diff: k });
|
|
7079
7311
|
}
|
|
7080
7312
|
}
|
|
7081
7313
|
if (v !== null && b) {
|
|
7082
7314
|
const k = Math.abs(v - I);
|
|
7083
7315
|
if (k <= e) {
|
|
7084
|
-
const
|
|
7085
|
-
if (!
|
|
7086
|
-
const E = i +
|
|
7316
|
+
const _ = v - I;
|
|
7317
|
+
if (!vt({ value: _, step: ot })) continue;
|
|
7318
|
+
const E = i + _, { left: L } = b, P = {
|
|
7087
7319
|
type: "horizontal",
|
|
7088
7320
|
axis: s,
|
|
7089
7321
|
refStart: C,
|
|
7090
|
-
refEnd:
|
|
7322
|
+
refEnd: j,
|
|
7091
7323
|
activeStart: E,
|
|
7092
7324
|
activeEnd: L,
|
|
7093
7325
|
distance: I
|
|
7094
7326
|
};
|
|
7095
|
-
u.push({ delta:
|
|
7327
|
+
u.push({ delta: _, guide: P, diff: k });
|
|
7096
7328
|
}
|
|
7097
7329
|
}
|
|
7098
7330
|
}
|
|
7099
7331
|
}
|
|
7100
7332
|
if (!u.length)
|
|
7101
7333
|
return { delta: 0, guide: null };
|
|
7102
|
-
let
|
|
7334
|
+
let O = u[0];
|
|
7103
7335
|
for (let S = 1; S < u.length; S += 1) {
|
|
7104
7336
|
const M = u[S];
|
|
7105
|
-
M.diff <
|
|
7337
|
+
M.diff < O.diff && (O = M);
|
|
7106
7338
|
}
|
|
7107
7339
|
return {
|
|
7108
|
-
delta:
|
|
7109
|
-
guide:
|
|
7340
|
+
delta: O.delta,
|
|
7341
|
+
guide: O.guide
|
|
7110
7342
|
};
|
|
7111
7343
|
}, Zs = ({
|
|
7112
7344
|
activeBounds: h,
|
|
@@ -7140,7 +7372,7 @@ const Ce = 5, Mn = "#3D8BF4", Re = 1, ot = 2, Ue = ({
|
|
|
7140
7372
|
}) => {
|
|
7141
7373
|
const i = Math.min(o, n / 2, s / 2);
|
|
7142
7374
|
h.moveTo(t + i, e), h.lineTo(t + n - i, e), h.quadraticCurveTo(t + n, e, t + n, e + i), h.lineTo(t + n, e + s - i), h.quadraticCurveTo(t + n, e + s, t + n - i, e + s), h.lineTo(t + i, e + s), h.quadraticCurveTo(t, e + s, t, e + s - i), h.lineTo(t, e + i), h.quadraticCurveTo(t, e, t + i, e), h.closePath();
|
|
7143
|
-
},
|
|
7375
|
+
}, Be = ({
|
|
7144
7376
|
context: h,
|
|
7145
7377
|
type: t,
|
|
7146
7378
|
axis: e,
|
|
@@ -7157,17 +7389,17 @@ const Ce = 5, Mn = "#3D8BF4", Re = 1, ot = 2, Ue = ({
|
|
|
7157
7389
|
offsetAlongAxis: f = 0,
|
|
7158
7390
|
offsetPerpendicular: g = 0
|
|
7159
7391
|
}) => {
|
|
7160
|
-
const m = i || 1, p = 12 / m, y = d / m, v = u / m,
|
|
7392
|
+
const m = i || 1, p = 12 / m, y = d / m, v = u / m, A = (n + s) / 2 + f, b = t === "vertical" ? e + g : A, O = t === "vertical" ? A : e + g;
|
|
7161
7393
|
h.save(), h.setLineDash([]), h.fillStyle = a, h.strokeStyle = a, h.lineWidth = l / m, h.font = `${p}px ${c}`, h.textAlign = "center", h.textBaseline = "middle";
|
|
7162
|
-
const M = h.measureText(o).width + y * 2, w = p + y * 2, C = b - M / 2,
|
|
7394
|
+
const M = h.measureText(o).width + y * 2, w = p + y * 2, C = b - M / 2, j = O - w / 2;
|
|
7163
7395
|
h.beginPath(), Gs({
|
|
7164
7396
|
context: h,
|
|
7165
7397
|
x: C,
|
|
7166
|
-
y:
|
|
7398
|
+
y: j,
|
|
7167
7399
|
width: M,
|
|
7168
7400
|
height: w,
|
|
7169
7401
|
radius: v
|
|
7170
|
-
}), h.fill(), h.fillStyle = r, h.fillText(o, b,
|
|
7402
|
+
}), h.fill(), h.fillStyle = r, h.fillText(o, b, O), h.restore();
|
|
7171
7403
|
}, Vs = ({
|
|
7172
7404
|
context: h,
|
|
7173
7405
|
guide: t,
|
|
@@ -7183,8 +7415,8 @@ const Ce = 5, Mn = "#3D8BF4", Re = 1, ot = 2, Ue = ({
|
|
|
7183
7415
|
distance: c
|
|
7184
7416
|
} = t, l = Math.round(c).toString();
|
|
7185
7417
|
h.beginPath(), n === "vertical" ? (h.moveTo(s, o), h.lineTo(s, i), h.moveTo(s, a), h.lineTo(s, r)) : (h.moveTo(o, s), h.lineTo(i, s), h.moveTo(a, s), h.lineTo(r, s)), h.stroke();
|
|
7186
|
-
const d =
|
|
7187
|
-
|
|
7418
|
+
const d = Sn;
|
|
7419
|
+
Be({
|
|
7188
7420
|
context: h,
|
|
7189
7421
|
type: n,
|
|
7190
7422
|
axis: s,
|
|
@@ -7193,8 +7425,8 @@ const Ce = 5, Mn = "#3D8BF4", Re = 1, ot = 2, Ue = ({
|
|
|
7193
7425
|
text: l,
|
|
7194
7426
|
zoom: e,
|
|
7195
7427
|
color: d,
|
|
7196
|
-
lineWidth:
|
|
7197
|
-
}),
|
|
7428
|
+
lineWidth: ke
|
|
7429
|
+
}), Be({
|
|
7198
7430
|
context: h,
|
|
7199
7431
|
type: n,
|
|
7200
7432
|
axis: s,
|
|
@@ -7203,9 +7435,9 @@ const Ce = 5, Mn = "#3D8BF4", Re = 1, ot = 2, Ue = ({
|
|
|
7203
7435
|
text: l,
|
|
7204
7436
|
zoom: e,
|
|
7205
7437
|
color: d,
|
|
7206
|
-
lineWidth:
|
|
7438
|
+
lineWidth: ke
|
|
7207
7439
|
});
|
|
7208
|
-
},
|
|
7440
|
+
}, mn = ({
|
|
7209
7441
|
anchors: h,
|
|
7210
7442
|
bounds: t
|
|
7211
7443
|
}) => {
|
|
@@ -7218,7 +7450,7 @@ const Ce = 5, Mn = "#3D8BF4", Re = 1, ot = 2, Ue = ({
|
|
|
7218
7450
|
centerY: a
|
|
7219
7451
|
} = t;
|
|
7220
7452
|
h.vertical.push(e, s, n), h.horizontal.push(o, a, i);
|
|
7221
|
-
},
|
|
7453
|
+
}, yn = ({
|
|
7222
7454
|
bounds: h,
|
|
7223
7455
|
type: t,
|
|
7224
7456
|
primaryStart: e,
|
|
@@ -7248,24 +7480,24 @@ const Ce = 5, Mn = "#3D8BF4", Re = 1, ot = 2, Ue = ({
|
|
|
7248
7480
|
}, Xs = ({
|
|
7249
7481
|
bounds: h
|
|
7250
7482
|
}) => {
|
|
7251
|
-
const t =
|
|
7483
|
+
const t = yn({
|
|
7252
7484
|
bounds: h,
|
|
7253
7485
|
type: "vertical",
|
|
7254
7486
|
primaryStart: "top",
|
|
7255
7487
|
primaryEnd: "bottom"
|
|
7256
|
-
}), e =
|
|
7488
|
+
}), e = yn({
|
|
7257
7489
|
bounds: h,
|
|
7258
7490
|
type: "horizontal",
|
|
7259
7491
|
primaryStart: "left",
|
|
7260
7492
|
primaryEnd: "right"
|
|
7261
7493
|
});
|
|
7262
7494
|
return { vertical: t, horizontal: e };
|
|
7263
|
-
}, Ks = ["montage-area", "background", "interaction-blocker"],
|
|
7495
|
+
}, Ks = ["montage-area", "background", "interaction-blocker"], Cn = ({
|
|
7264
7496
|
activeObject: h
|
|
7265
7497
|
}) => {
|
|
7266
7498
|
const t = /* @__PURE__ */ new Set();
|
|
7267
7499
|
return h && (t.add(h), h instanceof X && h.getObjects().forEach((e) => t.add(e))), t;
|
|
7268
|
-
},
|
|
7500
|
+
}, In = ({
|
|
7269
7501
|
object: h,
|
|
7270
7502
|
excluded: t,
|
|
7271
7503
|
ignoredIds: e = Ks
|
|
@@ -7334,12 +7566,12 @@ class $ {
|
|
|
7334
7566
|
return;
|
|
7335
7567
|
}
|
|
7336
7568
|
$._applyMovementStep({ target: e }), !this.anchors.vertical.length && !this.anchors.horizontal.length && this._cacheAnchors({ activeObject: e });
|
|
7337
|
-
let o =
|
|
7569
|
+
let o = yt({ object: e });
|
|
7338
7570
|
if (!o) {
|
|
7339
7571
|
this._clearGuides();
|
|
7340
7572
|
return;
|
|
7341
7573
|
}
|
|
7342
|
-
const { canvas: i } = this, a = i.getZoom() || 1, r =
|
|
7574
|
+
const { canvas: i } = this, a = i.getZoom() || 1, r = Ie / a, c = Us({
|
|
7343
7575
|
activeBounds: o,
|
|
7344
7576
|
threshold: r,
|
|
7345
7577
|
anchors: this.anchors
|
|
@@ -7349,9 +7581,9 @@ class $ {
|
|
|
7349
7581
|
e.set({
|
|
7350
7582
|
left: y + l,
|
|
7351
7583
|
top: v + d
|
|
7352
|
-
}), e.setCoords(), o = (m =
|
|
7584
|
+
}), e.setCoords(), o = (m = yt({ object: e })) != null ? m : o;
|
|
7353
7585
|
}
|
|
7354
|
-
const f = this.cachedTargetBounds.length ? this.cachedTargetBounds : this._collectTargets({ activeObject: e }).map((y) =>
|
|
7586
|
+
const f = this.cachedTargetBounds.length ? this.cachedTargetBounds : this._collectTargets({ activeObject: e }).map((y) => yt({ object: y })).filter((y) => !!y), g = Zs({
|
|
7355
7587
|
activeBounds: o,
|
|
7356
7588
|
candidates: f,
|
|
7357
7589
|
threshold: r,
|
|
@@ -7362,7 +7594,7 @@ class $ {
|
|
|
7362
7594
|
e.set({
|
|
7363
7595
|
left: y + g.deltaX,
|
|
7364
7596
|
top: v + g.deltaY
|
|
7365
|
-
}), e.setCoords(), o = (p =
|
|
7597
|
+
}), e.setCoords(), o = (p = yt({ object: e })) != null ? p : o;
|
|
7366
7598
|
}
|
|
7367
7599
|
this._applyGuides({
|
|
7368
7600
|
guides: u,
|
|
@@ -7396,20 +7628,20 @@ class $ {
|
|
|
7396
7628
|
horizontal: d
|
|
7397
7629
|
} = c;
|
|
7398
7630
|
!l.length && !d.length && this._cacheAnchors({ activeObject: e });
|
|
7399
|
-
const u =
|
|
7631
|
+
const u = yt({ object: e });
|
|
7400
7632
|
if (!u) {
|
|
7401
7633
|
this._clearGuides();
|
|
7402
7634
|
return;
|
|
7403
7635
|
}
|
|
7404
|
-
const { canvas: f } = this, g = f.getZoom() || 1, m =
|
|
7636
|
+
const { canvas: f } = this, g = f.getZoom() || 1, m = Ie / g, {
|
|
7405
7637
|
originX: p,
|
|
7406
7638
|
originY: y
|
|
7407
7639
|
} = s, {
|
|
7408
7640
|
originX: v = "left",
|
|
7409
|
-
originY:
|
|
7641
|
+
originY: A = "top",
|
|
7410
7642
|
scaleX: b = 1,
|
|
7411
|
-
scaleY:
|
|
7412
|
-
} = e, S = p != null ? p : v, M = y != null ? y :
|
|
7643
|
+
scaleY: O = 1
|
|
7644
|
+
} = e, S = p != null ? p : v, M = y != null ? y : A, w = $._collectVerticalSnapCandidates({
|
|
7413
7645
|
bounds: u,
|
|
7414
7646
|
originX: S,
|
|
7415
7647
|
shouldSnapX: i
|
|
@@ -7417,7 +7649,7 @@ class $ {
|
|
|
7417
7649
|
bounds: u,
|
|
7418
7650
|
originY: M,
|
|
7419
7651
|
shouldSnapY: a
|
|
7420
|
-
}),
|
|
7652
|
+
}), j = $._findAxisSnapCandidate({
|
|
7421
7653
|
anchors: l,
|
|
7422
7654
|
candidates: w,
|
|
7423
7655
|
threshold: m
|
|
@@ -7425,47 +7657,47 @@ class $ {
|
|
|
7425
7657
|
anchors: d,
|
|
7426
7658
|
candidates: C,
|
|
7427
7659
|
threshold: m
|
|
7428
|
-
}), { guidePosition:
|
|
7429
|
-
if (!
|
|
7660
|
+
}), { guidePosition: T } = j, { guidePosition: k } = I, _ = T !== null, W = k !== null;
|
|
7661
|
+
if (!_ && !W) {
|
|
7430
7662
|
this._clearGuides();
|
|
7431
7663
|
return;
|
|
7432
7664
|
}
|
|
7433
7665
|
const E = [];
|
|
7434
|
-
let L = null,
|
|
7666
|
+
let L = null, P = null;
|
|
7435
7667
|
if (r) {
|
|
7436
|
-
const
|
|
7668
|
+
const z = $._resolveUniformScale({
|
|
7437
7669
|
bounds: u,
|
|
7438
7670
|
originX: S,
|
|
7439
7671
|
originY: M,
|
|
7440
|
-
verticalSnap:
|
|
7672
|
+
verticalSnap: j,
|
|
7441
7673
|
horizontalSnap: I
|
|
7442
7674
|
});
|
|
7443
|
-
if (
|
|
7444
|
-
const { scaleFactor: x, guide:
|
|
7445
|
-
L = b * x,
|
|
7675
|
+
if (z) {
|
|
7676
|
+
const { scaleFactor: x, guide: D } = z;
|
|
7677
|
+
L = b * x, P = O * x, E.push(D);
|
|
7446
7678
|
}
|
|
7447
7679
|
}
|
|
7448
7680
|
if (!r) {
|
|
7449
|
-
const { angle:
|
|
7450
|
-
if (
|
|
7681
|
+
const { angle: z = 0 } = e, { width: x, height: D } = $._resolveBaseDimensions({ target: e }), R = Math.abs(b) || 1, N = Math.abs(O) || 1;
|
|
7682
|
+
if (_) {
|
|
7451
7683
|
const K = $._resolveDesiredWidth({
|
|
7452
7684
|
bounds: u,
|
|
7453
7685
|
originX: S,
|
|
7454
|
-
snap:
|
|
7686
|
+
snap: j
|
|
7455
7687
|
});
|
|
7456
7688
|
if (K !== null) {
|
|
7457
7689
|
const H = $._resolveScaleForWidth({
|
|
7458
7690
|
desiredWidth: K,
|
|
7459
7691
|
baseWidth: x,
|
|
7460
|
-
baseHeight:
|
|
7692
|
+
baseHeight: D,
|
|
7461
7693
|
scaleY: N,
|
|
7462
|
-
angle:
|
|
7694
|
+
angle: z
|
|
7463
7695
|
});
|
|
7464
7696
|
if (H !== null) {
|
|
7465
7697
|
const q = b < 0 ? -1 : 1;
|
|
7466
|
-
L = H * q,
|
|
7698
|
+
L = H * q, T !== null && E.push({
|
|
7467
7699
|
type: "vertical",
|
|
7468
|
-
position:
|
|
7700
|
+
position: T
|
|
7469
7701
|
});
|
|
7470
7702
|
}
|
|
7471
7703
|
}
|
|
@@ -7480,13 +7712,13 @@ class $ {
|
|
|
7480
7712
|
const H = $._resolveScaleForHeight({
|
|
7481
7713
|
desiredHeight: K,
|
|
7482
7714
|
baseWidth: x,
|
|
7483
|
-
baseHeight:
|
|
7715
|
+
baseHeight: D,
|
|
7484
7716
|
scaleX: R,
|
|
7485
|
-
angle:
|
|
7717
|
+
angle: z
|
|
7486
7718
|
});
|
|
7487
7719
|
if (H !== null) {
|
|
7488
|
-
const q =
|
|
7489
|
-
|
|
7720
|
+
const q = O < 0 ? -1 : 1;
|
|
7721
|
+
P = H * q, k !== null && E.push({
|
|
7490
7722
|
type: "horizontal",
|
|
7491
7723
|
position: k
|
|
7492
7724
|
});
|
|
@@ -7494,14 +7726,14 @@ class $ {
|
|
|
7494
7726
|
}
|
|
7495
7727
|
}
|
|
7496
7728
|
}
|
|
7497
|
-
const B = L !== null ||
|
|
7729
|
+
const B = L !== null || P !== null;
|
|
7498
7730
|
if (!B && !E.length) {
|
|
7499
7731
|
this._clearGuides();
|
|
7500
7732
|
return;
|
|
7501
7733
|
}
|
|
7502
7734
|
if (B) {
|
|
7503
|
-
const
|
|
7504
|
-
L !== null && (
|
|
7735
|
+
const z = e.getRelativeCenterPoint(), x = e.translateToOriginPoint(z, S, M), D = {};
|
|
7736
|
+
L !== null && (D.scaleX = L, s.scaleX = L), P !== null && (D.scaleY = P, s.scaleY = P), Object.keys(D).length && (e.set(D), e.setPositionByOrigin(x, S, M), e.setCoords());
|
|
7505
7737
|
}
|
|
7506
7738
|
this._applyGuides({
|
|
7507
7739
|
guides: E,
|
|
@@ -7535,23 +7767,23 @@ class $ {
|
|
|
7535
7767
|
horizontal: c
|
|
7536
7768
|
} = a;
|
|
7537
7769
|
!r.length && !c.length && this._cacheAnchors({ activeObject: t });
|
|
7538
|
-
const l =
|
|
7770
|
+
const l = yt({ object: t });
|
|
7539
7771
|
if (!l) {
|
|
7540
7772
|
this._clearGuides();
|
|
7541
7773
|
return;
|
|
7542
7774
|
}
|
|
7543
|
-
const { canvas: d } = this, u = d.getZoom() || 1, f =
|
|
7775
|
+
const { canvas: d } = this, u = d.getZoom() || 1, f = Ie / u, { originX: g, originY: m } = e, {
|
|
7544
7776
|
originX: p = "left",
|
|
7545
7777
|
originY: y = "top"
|
|
7546
|
-
} = t, v = g != null ? g : p,
|
|
7778
|
+
} = t, v = g != null ? g : p, A = m != null ? m : y, b = $._collectVerticalSnapCandidates({
|
|
7547
7779
|
bounds: l,
|
|
7548
7780
|
originX: v,
|
|
7549
7781
|
shouldSnapX: !0
|
|
7550
|
-
}),
|
|
7782
|
+
}), O = $._findAxisSnapCandidate({
|
|
7551
7783
|
anchors: r,
|
|
7552
7784
|
candidates: b,
|
|
7553
7785
|
threshold: f
|
|
7554
|
-
}), { guidePosition: S } =
|
|
7786
|
+
}), { guidePosition: S } = O;
|
|
7555
7787
|
if (S === null) {
|
|
7556
7788
|
this._clearGuides();
|
|
7557
7789
|
return;
|
|
@@ -7559,7 +7791,7 @@ class $ {
|
|
|
7559
7791
|
const M = $._resolveDesiredWidth({
|
|
7560
7792
|
bounds: l,
|
|
7561
7793
|
originX: v,
|
|
7562
|
-
snap:
|
|
7794
|
+
snap: O
|
|
7563
7795
|
});
|
|
7564
7796
|
if (M === null) {
|
|
7565
7797
|
this._clearGuides();
|
|
@@ -7575,8 +7807,8 @@ class $ {
|
|
|
7575
7807
|
}
|
|
7576
7808
|
const { width: C = 0 } = t;
|
|
7577
7809
|
if (w !== C) {
|
|
7578
|
-
const
|
|
7579
|
-
t.set({ width: w }), t.setPositionByOrigin(I, v,
|
|
7810
|
+
const j = t.getRelativeCenterPoint(), I = t.translateToOriginPoint(j, v, A);
|
|
7811
|
+
t.set({ width: w }), t.setPositionByOrigin(I, v, A), t.setCoords();
|
|
7580
7812
|
}
|
|
7581
7813
|
this._applyGuides({
|
|
7582
7814
|
guides: [
|
|
@@ -7609,7 +7841,7 @@ class $ {
|
|
|
7609
7841
|
const { canvas: t, guideBounds: e } = this, n = t.getSelectionContext();
|
|
7610
7842
|
if (!n) return;
|
|
7611
7843
|
const s = e != null ? e : this._calculateViewportBounds(), { left: o, right: i, top: a, bottom: r } = s, { viewportTransform: c } = t, l = t.getZoom() || 1;
|
|
7612
|
-
n.save(), Array.isArray(c) && n.transform(...c), n.lineWidth =
|
|
7844
|
+
n.save(), Array.isArray(c) && n.transform(...c), n.lineWidth = ke / l, n.strokeStyle = Sn, n.setLineDash([4, 4]);
|
|
7613
7845
|
for (const d of this.activeGuides)
|
|
7614
7846
|
n.beginPath(), d.type === "vertical" ? (n.moveTo(d.position, a), n.lineTo(d.position, r)) : (n.moveTo(o, d.position), n.lineTo(i, d.position)), n.stroke();
|
|
7615
7847
|
for (const d of this.activeSpacingGuides)
|
|
@@ -7754,31 +7986,31 @@ class $ {
|
|
|
7754
7986
|
} = o;
|
|
7755
7987
|
let p = null, y = null;
|
|
7756
7988
|
if (u !== null && l > 0) {
|
|
7757
|
-
const
|
|
7989
|
+
const A = $._resolveDesiredWidth({
|
|
7758
7990
|
bounds: t,
|
|
7759
7991
|
originX: e,
|
|
7760
7992
|
snap: s
|
|
7761
7993
|
});
|
|
7762
|
-
if (
|
|
7763
|
-
const b =
|
|
7994
|
+
if (A !== null) {
|
|
7995
|
+
const b = A / l;
|
|
7764
7996
|
Number.isFinite(b) && b > 0 && (p = b);
|
|
7765
7997
|
}
|
|
7766
7998
|
}
|
|
7767
7999
|
if (g !== null && d > 0) {
|
|
7768
|
-
const
|
|
8000
|
+
const A = $._resolveDesiredHeight({
|
|
7769
8001
|
bounds: t,
|
|
7770
8002
|
originY: n,
|
|
7771
8003
|
snap: o
|
|
7772
8004
|
});
|
|
7773
|
-
if (
|
|
7774
|
-
const b =
|
|
8005
|
+
if (A !== null) {
|
|
8006
|
+
const b = A / d;
|
|
7775
8007
|
Number.isFinite(b) && b > 0 && (y = b);
|
|
7776
8008
|
}
|
|
7777
8009
|
}
|
|
7778
8010
|
let v = null;
|
|
7779
8011
|
if (p !== null && y === null && (v = "x"), y !== null && p === null && (v = "y"), p !== null && y !== null) {
|
|
7780
|
-
const
|
|
7781
|
-
|
|
8012
|
+
const A = Math.abs(f), b = Math.abs(m);
|
|
8013
|
+
A <= b && (v = "x"), A > b && (v = "y");
|
|
7782
8014
|
}
|
|
7783
8015
|
return v === "x" && p !== null && u !== null ? {
|
|
7784
8016
|
scaleFactor: p,
|
|
@@ -7910,12 +8142,12 @@ class $ {
|
|
|
7910
8142
|
_cacheAnchors({ activeObject: t }) {
|
|
7911
8143
|
const e = this._collectTargets({ activeObject: t }), n = { vertical: [], horizontal: [] }, s = [];
|
|
7912
8144
|
for (const a of e) {
|
|
7913
|
-
const r =
|
|
7914
|
-
r && (
|
|
8145
|
+
const r = yt({ object: a });
|
|
8146
|
+
r && (mn({ anchors: n, bounds: r }), s.push(r));
|
|
7915
8147
|
}
|
|
7916
|
-
const { montageArea: o } = this.editor, i =
|
|
8148
|
+
const { montageArea: o } = this.editor, i = yt({ object: o });
|
|
7917
8149
|
if (i) {
|
|
7918
|
-
|
|
8150
|
+
mn({ anchors: n, bounds: i });
|
|
7919
8151
|
const { left: a, right: r, top: c, bottom: l } = i;
|
|
7920
8152
|
this.guideBounds = {
|
|
7921
8153
|
left: a,
|
|
@@ -7931,9 +8163,9 @@ class $ {
|
|
|
7931
8163
|
* Собирает объекты, подходящие для прилипания, исключая активный объект и запрещённые id.
|
|
7932
8164
|
*/
|
|
7933
8165
|
_collectTargets({ activeObject: t }) {
|
|
7934
|
-
const e =
|
|
8166
|
+
const e = Cn({ activeObject: t }), n = [];
|
|
7935
8167
|
return this.canvas.forEachObject((s) => {
|
|
7936
|
-
|
|
8168
|
+
In({ object: s, excluded: e }) || n.push(s);
|
|
7937
8169
|
}), n;
|
|
7938
8170
|
}
|
|
7939
8171
|
/**
|
|
@@ -7956,8 +8188,8 @@ class $ {
|
|
|
7956
8188
|
};
|
|
7957
8189
|
}
|
|
7958
8190
|
}
|
|
7959
|
-
const
|
|
7960
|
-
class
|
|
8191
|
+
const vn = "#3D8BF4", bn = 1;
|
|
8192
|
+
class Ut {
|
|
7961
8193
|
/**
|
|
7962
8194
|
* Создаёт менеджер измерений и инициализирует события.
|
|
7963
8195
|
*/
|
|
@@ -8062,15 +8294,15 @@ class Wt {
|
|
|
8062
8294
|
this._clearGuides();
|
|
8063
8295
|
return;
|
|
8064
8296
|
}
|
|
8065
|
-
const o =
|
|
8297
|
+
const o = yt({ object: s });
|
|
8066
8298
|
if (!o) {
|
|
8067
8299
|
this._clearGuides();
|
|
8068
8300
|
return;
|
|
8069
8301
|
}
|
|
8070
|
-
const i =
|
|
8302
|
+
const i = Ut._resolveTarget({
|
|
8071
8303
|
event: t,
|
|
8072
8304
|
activeObject: s
|
|
8073
|
-
}), { montageArea: a } = n, r = i != null ? i : a, c = r === a, l =
|
|
8305
|
+
}), { montageArea: a } = n, r = i != null ? i : a, c = r === a, l = yt({ object: r });
|
|
8074
8306
|
if (!l) {
|
|
8075
8307
|
this._clearGuides();
|
|
8076
8308
|
return;
|
|
@@ -8079,7 +8311,7 @@ class Wt {
|
|
|
8079
8311
|
this._clearGuides();
|
|
8080
8312
|
return;
|
|
8081
8313
|
}
|
|
8082
|
-
const u =
|
|
8314
|
+
const u = Ut._buildGuides({
|
|
8083
8315
|
activeBounds: o,
|
|
8084
8316
|
targetBounds: l,
|
|
8085
8317
|
targetIsMontageArea: c
|
|
@@ -8097,8 +8329,8 @@ class Wt {
|
|
|
8097
8329
|
event: t,
|
|
8098
8330
|
activeObject: e
|
|
8099
8331
|
}) {
|
|
8100
|
-
const { target: n } = t, s =
|
|
8101
|
-
return n && !
|
|
8332
|
+
const { target: n } = t, s = Cn({ activeObject: e });
|
|
8333
|
+
return n && !In({ object: n, excluded: s }) ? n : null;
|
|
8102
8334
|
}
|
|
8103
8335
|
/**
|
|
8104
8336
|
* Собирает вертикальные и горизонтальные направляющие расстояний.
|
|
@@ -8108,11 +8340,11 @@ class Wt {
|
|
|
8108
8340
|
targetBounds: e,
|
|
8109
8341
|
targetIsMontageArea: n
|
|
8110
8342
|
}) {
|
|
8111
|
-
const s =
|
|
8343
|
+
const s = Ut._buildHorizontalGuides({
|
|
8112
8344
|
activeBounds: t,
|
|
8113
8345
|
targetBounds: e,
|
|
8114
8346
|
targetIsMontageArea: n
|
|
8115
|
-
}), o =
|
|
8347
|
+
}), o = Ut._buildVerticalGuides({
|
|
8116
8348
|
activeBounds: t,
|
|
8117
8349
|
targetBounds: e,
|
|
8118
8350
|
targetIsMontageArea: n
|
|
@@ -8163,21 +8395,21 @@ class Wt {
|
|
|
8163
8395
|
}), s;
|
|
8164
8396
|
}
|
|
8165
8397
|
if (!n) return s;
|
|
8166
|
-
const
|
|
8167
|
-
M > 0 && !
|
|
8398
|
+
const A = o < l, b = i > d, O = Math.min(o, l), S = Math.max(o, l), M = S - O;
|
|
8399
|
+
M > 0 && !A && s.push({
|
|
8168
8400
|
type: "horizontal",
|
|
8169
8401
|
axis: v,
|
|
8170
|
-
start:
|
|
8402
|
+
start: O,
|
|
8171
8403
|
end: S,
|
|
8172
8404
|
distance: M
|
|
8173
8405
|
});
|
|
8174
|
-
const w = Math.min(i, d), C = Math.max(i, d),
|
|
8175
|
-
return
|
|
8406
|
+
const w = Math.min(i, d), C = Math.max(i, d), j = C - w;
|
|
8407
|
+
return j > 0 && !b && s.push({
|
|
8176
8408
|
type: "horizontal",
|
|
8177
8409
|
axis: v,
|
|
8178
8410
|
start: w,
|
|
8179
8411
|
end: C,
|
|
8180
|
-
distance:
|
|
8412
|
+
distance: j
|
|
8181
8413
|
}), s;
|
|
8182
8414
|
}
|
|
8183
8415
|
/**
|
|
@@ -8224,21 +8456,21 @@ class Wt {
|
|
|
8224
8456
|
}), s;
|
|
8225
8457
|
}
|
|
8226
8458
|
if (!n) return s;
|
|
8227
|
-
const
|
|
8228
|
-
M > 0 && !
|
|
8459
|
+
const A = o < l, b = i > d, O = Math.min(o, l), S = Math.max(o, l), M = S - O;
|
|
8460
|
+
M > 0 && !A && s.push({
|
|
8229
8461
|
type: "vertical",
|
|
8230
8462
|
axis: v,
|
|
8231
|
-
start:
|
|
8463
|
+
start: O,
|
|
8232
8464
|
end: S,
|
|
8233
8465
|
distance: M
|
|
8234
8466
|
});
|
|
8235
|
-
const w = Math.min(i, d), C = Math.max(i, d),
|
|
8236
|
-
return
|
|
8467
|
+
const w = Math.min(i, d), C = Math.max(i, d), j = C - w;
|
|
8468
|
+
return j > 0 && !b && s.push({
|
|
8237
8469
|
type: "vertical",
|
|
8238
8470
|
axis: v,
|
|
8239
8471
|
start: w,
|
|
8240
8472
|
end: C,
|
|
8241
|
-
distance:
|
|
8473
|
+
distance: j
|
|
8242
8474
|
}), s;
|
|
8243
8475
|
}
|
|
8244
8476
|
/**
|
|
@@ -8266,10 +8498,10 @@ class Wt {
|
|
|
8266
8498
|
const { canvas: t } = this, e = t.getSelectionContext();
|
|
8267
8499
|
if (!e) return;
|
|
8268
8500
|
const { viewportTransform: n } = t, s = 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 / s : 0;
|
|
8269
|
-
e.save(), Array.isArray(n) && e.transform(...n), e.lineWidth =
|
|
8501
|
+
e.save(), Array.isArray(n) && e.transform(...n), e.lineWidth = bn / s, e.strokeStyle = vn, e.setLineDash([]);
|
|
8270
8502
|
for (const c of this.activeGuides) {
|
|
8271
8503
|
const { type: l, axis: d, start: u, end: f, distance: g } = c, m = Math.abs(f - u), p = u <= f ? -1 : 1, y = a ? p * (m / 2 + r) : 0, v = 0;
|
|
8272
|
-
e.beginPath(), l === "vertical" ? (e.moveTo(d, u), e.lineTo(d, f)) : (e.moveTo(u, d), e.lineTo(f, d)), e.stroke(),
|
|
8504
|
+
e.beginPath(), l === "vertical" ? (e.moveTo(d, u), e.lineTo(d, f)) : (e.moveTo(u, d), e.lineTo(f, d)), e.stroke(), Be({
|
|
8273
8505
|
context: e,
|
|
8274
8506
|
type: l,
|
|
8275
8507
|
axis: d,
|
|
@@ -8277,8 +8509,8 @@ class Wt {
|
|
|
8277
8509
|
end: f,
|
|
8278
8510
|
text: Math.round(g).toString(),
|
|
8279
8511
|
zoom: s,
|
|
8280
|
-
color:
|
|
8281
|
-
lineWidth:
|
|
8512
|
+
color: vn,
|
|
8513
|
+
lineWidth: bn,
|
|
8282
8514
|
offsetAlongAxis: y,
|
|
8283
8515
|
offsetPerpendicular: v
|
|
8284
8516
|
});
|
|
@@ -8304,7 +8536,7 @@ class Wt {
|
|
|
8304
8536
|
(e = t == null ? void 0 : t.showAfterTemporary) == null || e.call(t), this.isToolbarHidden = !1;
|
|
8305
8537
|
}
|
|
8306
8538
|
}
|
|
8307
|
-
class
|
|
8539
|
+
class He {
|
|
8308
8540
|
/**
|
|
8309
8541
|
* Конструктор класса ImageEditor.
|
|
8310
8542
|
* @param canvasId - идентификатор канваса, в котором будет создан редактор
|
|
@@ -8334,12 +8566,12 @@ class Ye {
|
|
|
8334
8566
|
showRotationAngle: l,
|
|
8335
8567
|
_onReadyCallback: d
|
|
8336
8568
|
} = this.options;
|
|
8337
|
-
if (ut.apply(), this.canvas = new
|
|
8569
|
+
if (ut.apply(), this.canvas = new Bn(this.containerId, this.options), this.moduleLoader = new Wn(), this.workerManager = new Yn(), this.errorManager = new ee({ editor: this }), this.historyManager = new J({ editor: this }), this.toolbar = new os({ editor: this }), this.transformManager = new ps({ editor: this }), this.zoomManager = new ms({ editor: this }), this.canvasManager = new gs({ editor: this }), this.imageManager = new mt({ editor: this }), this.layerManager = new me({ editor: this }), this.shapeManager = new vs({ editor: this }), this.interactionBlocker = new ys({ editor: this }), this.backgroundManager = new Wt({ editor: this }), this.clipboardManager = new bs({ editor: this }), this.objectLockManager = new ye({ editor: this }), this.groupingManager = new Ms({ editor: this }), this.selectionManager = new ft({ editor: this }), this.deletionManager = new Ue({ editor: this }), this.panConstraintManager = new Ss({ editor: this }), this.snappingManager = new $({ editor: this }), this.measurementManager = new Ut({ editor: this }), this.fontManager = new Le((u = this.options.fonts) != null ? u : []), this.textManager = new rt({ editor: this }), this.templateManager = new Z({ editor: this }), l && (this.angleIndicator = new We({ editor: this })), this._createMontageArea(), this._createClippingArea(), this.listeners = new Ne({ editor: this, options: this.options }), this.canvasManager.setEditorContainerWidth(t), this.canvasManager.setEditorContainerHeight(e), this.canvasManager.setCanvasWrapperWidth(n), this.canvasManager.setCanvasWrapperHeight(s), this.canvasManager.setCanvasCSSWidth(o), this.canvasManager.setCanvasCSSHeight(i), this.canvasManager.updateCanvas(), this.zoomManager.calculateAndApplyDefaultZoom(), yield this.fontManager.loadFonts(), a != null && a.source) {
|
|
8338
8570
|
const f = a, {
|
|
8339
8571
|
source: g,
|
|
8340
8572
|
scale: m = `image-${c}`,
|
|
8341
8573
|
withoutSave: p = !0
|
|
8342
|
-
} = f, y =
|
|
8574
|
+
} = f, y = Ct(f, [
|
|
8343
8575
|
"source",
|
|
8344
8576
|
"scale",
|
|
8345
8577
|
"withoutSave"
|
|
@@ -8360,7 +8592,7 @@ class Ye {
|
|
|
8360
8592
|
this.montageArea = this.shapeManager.addRectangle({
|
|
8361
8593
|
width: t,
|
|
8362
8594
|
height: e,
|
|
8363
|
-
fill:
|
|
8595
|
+
fill: He._createMosaicPattern(),
|
|
8364
8596
|
stroke: null,
|
|
8365
8597
|
strokeWidth: 0,
|
|
8366
8598
|
selectable: !1,
|
|
@@ -8401,7 +8633,7 @@ class Ye {
|
|
|
8401
8633
|
*/
|
|
8402
8634
|
destroy() {
|
|
8403
8635
|
var t, e, n, s;
|
|
8404
|
-
this.listeners.destroy(), (t = this.snappingManager) == null || t.destroy(), (e = this.measurementManager) == null || e.destroy(), this.toolbar.destroy(), (n = this.angleIndicator) == null || n.destroy(), (s = this.textManager) == null || s.destroy(), this.canvas.dispose(), this.workerManager.worker.terminate(), this.imageManager.revokeBlobUrls(), this.errorManager.cleanBuffer();
|
|
8636
|
+
this.listeners.destroy(), (t = this.snappingManager) == null || t.destroy(), (e = this.measurementManager) == null || e.destroy(), this.toolbar.destroy(), (n = this.angleIndicator) == null || n.destroy(), (s = this.textManager) == null || s.destroy(), this.selectionManager.destroy(), this.canvas.dispose(), this.workerManager.worker.terminate(), this.imageManager.revokeBlobUrls(), this.errorManager.cleanBuffer();
|
|
8405
8637
|
}
|
|
8406
8638
|
/**
|
|
8407
8639
|
* Создает паттерн мозаики.
|
|
@@ -8411,7 +8643,7 @@ class Ye {
|
|
|
8411
8643
|
const t = document.createElement("canvas");
|
|
8412
8644
|
t.width = 20, t.height = 20;
|
|
8413
8645
|
const e = t.getContext("2d");
|
|
8414
|
-
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
|
|
8646
|
+
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 Nn({
|
|
8415
8647
|
source: t,
|
|
8416
8648
|
repeat: "repeat"
|
|
8417
8649
|
});
|
|
@@ -9254,6 +9486,7 @@ const U = [
|
|
|
9254
9486
|
controlsAboveOverlay: !0,
|
|
9255
9487
|
centeredRotation: !0,
|
|
9256
9488
|
enableRetinaScaling: !1,
|
|
9489
|
+
selectionKey: ["ctrlKey", "metaKey"],
|
|
9257
9490
|
/*
|
|
9258
9491
|
* Кастомные опции
|
|
9259
9492
|
*/
|
|
@@ -9325,7 +9558,6 @@ const U = [
|
|
|
9325
9558
|
* Настройки слушателей событий
|
|
9326
9559
|
*/
|
|
9327
9560
|
adaptCanvasToContainerOnResize: !0,
|
|
9328
|
-
bringToFrontOnSelection: !1,
|
|
9329
9561
|
mouseWheelZooming: !0,
|
|
9330
9562
|
canvasDragging: !0,
|
|
9331
9563
|
copyObjectsByHotkey: !0,
|
|
@@ -9347,7 +9579,7 @@ function ni(h, t = {}) {
|
|
|
9347
9579
|
const s = document.createElement("canvas");
|
|
9348
9580
|
return s.id = `${h}-canvas`, n.appendChild(s), e.editorContainer = n, new Promise((o) => {
|
|
9349
9581
|
e._onReadyCallback = o;
|
|
9350
|
-
const i = new
|
|
9582
|
+
const i = new He(s.id, e);
|
|
9351
9583
|
window[h] = i;
|
|
9352
9584
|
});
|
|
9353
9585
|
}
|