@anu3ev/fabric-image-editor 0.7.10 → 0.7.12
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 +1635 -911
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -252,87 +252,87 @@ var M = class {
|
|
|
252
252
|
}, N = "#2B2D33", P = "#3D8BF4", F = "#FFFFFF";
|
|
253
253
|
//#endregion
|
|
254
254
|
//#region src/editor/customized-controls/renderers.ts
|
|
255
|
-
function
|
|
255
|
+
function I(e, t, n, r, i) {
|
|
256
256
|
e.save(), e.translate(t, n), e.rotate(C.degreesToRadians(i.angle)), e.fillStyle = F, e.strokeStyle = P, e.lineWidth = 1, e.beginPath(), e.roundRect(-12 / 2, -12 / 2, 12, 12, 2), e.fill(), e.stroke(), e.restore();
|
|
257
257
|
}
|
|
258
|
-
function
|
|
258
|
+
function ee(e, t, n, r, i) {
|
|
259
259
|
e.save(), e.translate(t, n), e.rotate(C.degreesToRadians(i.angle)), e.fillStyle = F, e.strokeStyle = P, e.lineWidth = 1, e.beginPath(), e.roundRect(-8 / 2, -20 / 2, 8, 20, 100), e.fill(), e.stroke(), e.restore();
|
|
260
260
|
}
|
|
261
|
-
function
|
|
261
|
+
function te(e, t, n, r, i) {
|
|
262
262
|
e.save(), e.translate(t, n), e.rotate(C.degreesToRadians(i.angle)), e.fillStyle = F, e.strokeStyle = P, e.lineWidth = 1, e.beginPath(), e.roundRect(-20 / 2, -8 / 2, 20, 8, 100), e.fill(), e.stroke(), e.restore();
|
|
263
263
|
}
|
|
264
|
-
var
|
|
265
|
-
|
|
266
|
-
function
|
|
267
|
-
e.save(), e.translate(t, n), e.rotate(C.degreesToRadians(i.angle)), e.fillStyle = N, e.beginPath(), e.arc(0, 0, 16, 0, 2 * Math.PI), e.fill(), e.drawImage(
|
|
264
|
+
var L = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTE4Ljc1IDQuMzc1djMuNzVhLjYyNS42MjUgMCAwIDEtLjYyNS42MjVoLTMuNzVhLjYyNS42MjUgMCAwIDEgMC0xLjI1aDIuMTRsLTIuMDc3LTEuOTAzLS4wMi0uMDE5YTYuMjUgNi4yNSAwIDEgMC0uMTMgOC45NjcuNjI2LjYyNiAwIDAgMSAuODYuOTA5QTcuNDU2IDcuNDU2IDAgMCAxIDEwIDE3LjVoLS4xMDNhNy41IDcuNSAwIDEgMSA1LjM5Ni0xMi44MTJMMTcuNSA2LjcwM1Y0LjM3NWEuNjI1LjYyNSAwIDAgMSAxLjI1IDBaIi8+PC9zdmc+", ne = new Image();
|
|
265
|
+
ne.src = L;
|
|
266
|
+
function re(e, t, n, r, i) {
|
|
267
|
+
e.save(), e.translate(t, n), e.rotate(C.degreesToRadians(i.angle)), e.fillStyle = N, e.beginPath(), e.arc(0, 0, 16, 0, 2 * Math.PI), e.fill(), e.drawImage(ne, -16 / 2, -16 / 2, 16, 16), e.restore();
|
|
268
268
|
}
|
|
269
269
|
//#endregion
|
|
270
270
|
//#region src/editor/customized-controls/default-controls.ts
|
|
271
|
-
var
|
|
271
|
+
var R = {
|
|
272
272
|
tl: {
|
|
273
|
-
render:
|
|
273
|
+
render: I,
|
|
274
274
|
sizeX: 12,
|
|
275
275
|
sizeY: 12,
|
|
276
276
|
offsetX: 0,
|
|
277
277
|
offsetY: 0
|
|
278
278
|
},
|
|
279
279
|
tr: {
|
|
280
|
-
render:
|
|
280
|
+
render: I,
|
|
281
281
|
sizeX: 12,
|
|
282
282
|
sizeY: 12,
|
|
283
283
|
offsetX: 0,
|
|
284
284
|
offsetY: 0
|
|
285
285
|
},
|
|
286
286
|
bl: {
|
|
287
|
-
render:
|
|
287
|
+
render: I,
|
|
288
288
|
sizeX: 12,
|
|
289
289
|
sizeY: 12,
|
|
290
290
|
offsetX: 0,
|
|
291
291
|
offsetY: 0
|
|
292
292
|
},
|
|
293
293
|
br: {
|
|
294
|
-
render:
|
|
294
|
+
render: I,
|
|
295
295
|
sizeX: 12,
|
|
296
296
|
sizeY: 12,
|
|
297
297
|
offsetX: 0,
|
|
298
298
|
offsetY: 0
|
|
299
299
|
},
|
|
300
300
|
ml: {
|
|
301
|
-
render:
|
|
301
|
+
render: ee,
|
|
302
302
|
sizeX: 8,
|
|
303
303
|
sizeY: 20,
|
|
304
304
|
offsetX: 0,
|
|
305
305
|
offsetY: 0
|
|
306
306
|
},
|
|
307
307
|
mr: {
|
|
308
|
-
render:
|
|
308
|
+
render: ee,
|
|
309
309
|
sizeX: 8,
|
|
310
310
|
sizeY: 20,
|
|
311
311
|
offsetX: 0,
|
|
312
312
|
offsetY: 0
|
|
313
313
|
},
|
|
314
314
|
mt: {
|
|
315
|
-
render:
|
|
315
|
+
render: te,
|
|
316
316
|
sizeX: 20,
|
|
317
317
|
sizeY: 8,
|
|
318
318
|
offsetX: 0,
|
|
319
319
|
offsetY: 0
|
|
320
320
|
},
|
|
321
321
|
mb: {
|
|
322
|
-
render:
|
|
322
|
+
render: te,
|
|
323
323
|
sizeX: 20,
|
|
324
324
|
sizeY: 8,
|
|
325
325
|
offsetX: 0,
|
|
326
326
|
offsetY: 0
|
|
327
327
|
},
|
|
328
328
|
mtr: {
|
|
329
|
-
render:
|
|
329
|
+
render: re,
|
|
330
330
|
sizeX: 32,
|
|
331
331
|
sizeY: 32,
|
|
332
332
|
offsetX: 0,
|
|
333
333
|
offsetY: -32
|
|
334
334
|
}
|
|
335
|
-
},
|
|
335
|
+
}, ie = class t {
|
|
336
336
|
static wrapWidthControl(e) {
|
|
337
337
|
if (!e?.actionHandler) return;
|
|
338
338
|
let t = e.actionHandler;
|
|
@@ -342,7 +342,7 @@ var ie = {
|
|
|
342
342
|
};
|
|
343
343
|
}
|
|
344
344
|
static applyControlOverrides(e) {
|
|
345
|
-
Object.entries(
|
|
345
|
+
Object.entries(R).forEach(([t, n]) => {
|
|
346
346
|
let r = e[t];
|
|
347
347
|
r && (Object.assign(r, n), t === "mtr" && (r.cursorStyle = "grab", r.mouseDownHandler = (e, t, n, r) => {
|
|
348
348
|
let i = t?.target;
|
|
@@ -432,7 +432,7 @@ var ie = {
|
|
|
432
432
|
mr: !0
|
|
433
433
|
});
|
|
434
434
|
}
|
|
435
|
-
},
|
|
435
|
+
}, z = class e {
|
|
436
436
|
static {
|
|
437
437
|
this.registeredFontKeys = /* @__PURE__ */ new Set();
|
|
438
438
|
}
|
|
@@ -585,7 +585,7 @@ var ie = {
|
|
|
585
585
|
};
|
|
586
586
|
return Object.entries(e).filter(([, e]) => e != null && `${e}`.length > 0).map(([e, n]) => `${t[e] ?? e}: ${n};`);
|
|
587
587
|
}
|
|
588
|
-
},
|
|
588
|
+
}, B = {
|
|
589
589
|
style: {
|
|
590
590
|
position: "absolute",
|
|
591
591
|
display: "none",
|
|
@@ -687,7 +687,7 @@ var ie = {
|
|
|
687
687
|
e.layerManager.sendBackwards();
|
|
688
688
|
}
|
|
689
689
|
}
|
|
690
|
-
},
|
|
690
|
+
}, V = class {
|
|
691
691
|
constructor({ editor: e }) {
|
|
692
692
|
this.currentTarget = null, this.currentLocked = !1, this.isTransforming = !1, this.isTemporarilyHidden = !1, this.editor = e, this.canvas = e.canvas, this.options = e.options, this._initToolbar();
|
|
693
693
|
}
|
|
@@ -695,22 +695,22 @@ var ie = {
|
|
|
695
695
|
if (!this.options.showToolbar) return;
|
|
696
696
|
let e = this.options.toolbar || {};
|
|
697
697
|
this.config = {
|
|
698
|
-
...
|
|
698
|
+
...B,
|
|
699
699
|
...e,
|
|
700
700
|
style: {
|
|
701
|
-
...
|
|
701
|
+
...B.style,
|
|
702
702
|
...e.style || {}
|
|
703
703
|
},
|
|
704
704
|
btnStyle: {
|
|
705
|
-
...
|
|
705
|
+
...B.btnStyle,
|
|
706
706
|
...e.btnStyle || {}
|
|
707
707
|
},
|
|
708
708
|
icons: {
|
|
709
|
-
...
|
|
709
|
+
...B.icons,
|
|
710
710
|
...e.icons || {}
|
|
711
711
|
},
|
|
712
712
|
handlers: {
|
|
713
|
-
...
|
|
713
|
+
...B.handlers,
|
|
714
714
|
...e.handlers || {}
|
|
715
715
|
}
|
|
716
716
|
}, 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 = () => {
|
|
@@ -788,7 +788,7 @@ var ie = {
|
|
|
788
788
|
destroy() {
|
|
789
789
|
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();
|
|
790
790
|
}
|
|
791
|
-
},
|
|
791
|
+
}, H = {
|
|
792
792
|
position: "absolute",
|
|
793
793
|
display: "none",
|
|
794
794
|
background: "#2B2D33",
|
|
@@ -802,12 +802,12 @@ var ie = {
|
|
|
802
802
|
"pointer-events": "none",
|
|
803
803
|
"white-space": "nowrap",
|
|
804
804
|
"box-shadow": "0 2px 8px rgba(0, 0, 0, 0.2)"
|
|
805
|
-
},
|
|
805
|
+
}, U = "fabric-editor-angle-indicator", ae = class e {
|
|
806
806
|
constructor({ editor: e }) {
|
|
807
807
|
this.isActive = !1, this.currentAngle = 0, this.editor = e, this.canvas = e.canvas, this.options = e.options, this._createDOM(), this._bindEvents();
|
|
808
808
|
}
|
|
809
809
|
_createDOM() {
|
|
810
|
-
this.el = document.createElement("div"), this.el.className =
|
|
810
|
+
this.el = document.createElement("div"), this.el.className = U, Object.entries(H).forEach(([e, t]) => {
|
|
811
811
|
this.el.style.setProperty(e, t);
|
|
812
812
|
}), this.canvas.wrapperEl.appendChild(this.el);
|
|
813
813
|
}
|
|
@@ -852,44 +852,44 @@ var ie = {
|
|
|
852
852
|
destroy() {
|
|
853
853
|
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)), this.el?.parentNode && this.el.parentNode.removeChild(this.el), this.el = null, this.editor = null, this.canvas = null, this.options = null;
|
|
854
854
|
}
|
|
855
|
-
},
|
|
855
|
+
}, oe = /* @__PURE__ */ "id.backgroundId.customData.backgroundType.format.contentType.width.height.originX.originY.locked.editable.evented.selectable.lockMovementX.lockMovementY.lockRotation.lockScalingX.lockScalingY.lockSkewingX.lockSkewingY.styles.lineFontDefaults.textCaseRaw.uppercase.autoExpand.linethrough.underline.fontStyle.fontWeight.backgroundOpacity.paddingTop.paddingRight.paddingBottom.paddingLeft.radiusTopLeft.radiusTopRight.radiusBottomRight.radiusBottomLeft.shapeComposite.shapePresetKey.shapeBaseWidth.shapeBaseHeight.shapeManualBaseWidth.shapeManualBaseHeight.shapeReplaceBoxWidth.shapeReplaceBoxHeight.shapeTextAutoExpand.shapeAlignHorizontal.shapeAlignVertical.shapePaddingTop.shapePaddingRight.shapePaddingBottom.shapePaddingLeft.shapeFill.shapeStroke.shapeStrokeWidth.shapeStrokeDashArray.shapeOpacity.shapeRounding.shapeNodeType".split(".");
|
|
856
856
|
//#endregion
|
|
857
857
|
//#region src/editor/history-manager/diff-normalization.ts
|
|
858
|
-
function
|
|
858
|
+
function se({ state: e }) {
|
|
859
859
|
return JSON.parse(JSON.stringify(e));
|
|
860
860
|
}
|
|
861
|
-
function
|
|
861
|
+
function ce({ value: e }) {
|
|
862
862
|
if (Array.isArray(e)) {
|
|
863
863
|
let t = [];
|
|
864
|
-
for (let n = 0; n < e.length; n += 1) t.push(
|
|
864
|
+
for (let n = 0; n < e.length; n += 1) t.push(ce({ value: e[n] }));
|
|
865
865
|
return t;
|
|
866
866
|
}
|
|
867
867
|
if (e && typeof e == "object") {
|
|
868
868
|
let t = {}, n = Object.keys(e).sort();
|
|
869
869
|
for (let r = 0; r < n.length; r += 1) {
|
|
870
870
|
let i = n[r];
|
|
871
|
-
t[i] =
|
|
871
|
+
t[i] = ce({ value: e[i] });
|
|
872
872
|
}
|
|
873
873
|
return t;
|
|
874
874
|
}
|
|
875
875
|
return e;
|
|
876
876
|
}
|
|
877
|
-
function
|
|
878
|
-
let t =
|
|
877
|
+
function le({ value: e }) {
|
|
878
|
+
let t = ce({ value: e });
|
|
879
879
|
return JSON.stringify(t);
|
|
880
880
|
}
|
|
881
|
-
function
|
|
882
|
-
return
|
|
881
|
+
function ue({ prevState: e, nextState: t }) {
|
|
882
|
+
return le({ value: e }) === le({ value: t });
|
|
883
883
|
}
|
|
884
|
-
function
|
|
884
|
+
function de({ objects: e, id: t }) {
|
|
885
885
|
for (let n = 0; n < e.length; n += 1) {
|
|
886
886
|
let r = e[n];
|
|
887
887
|
if (r.id === t) return r;
|
|
888
888
|
}
|
|
889
889
|
return null;
|
|
890
890
|
}
|
|
891
|
-
function
|
|
892
|
-
let t =
|
|
891
|
+
function fe({ objects: e }) {
|
|
892
|
+
let t = de({
|
|
893
893
|
objects: e,
|
|
894
894
|
id: "montage-area"
|
|
895
895
|
});
|
|
@@ -903,7 +903,7 @@ function pe({ objects: e }) {
|
|
|
903
903
|
height: r
|
|
904
904
|
};
|
|
905
905
|
}
|
|
906
|
-
function
|
|
906
|
+
function pe({ objects: e }) {
|
|
907
907
|
let t = [], n = [...e];
|
|
908
908
|
for (let e = 0; e < n.length; e += 1) {
|
|
909
909
|
let r = n[e];
|
|
@@ -913,20 +913,20 @@ function me({ objects: e }) {
|
|
|
913
913
|
}
|
|
914
914
|
return t;
|
|
915
915
|
}
|
|
916
|
-
function
|
|
917
|
-
let t =
|
|
916
|
+
function me({ objects: e }) {
|
|
917
|
+
let t = pe({ objects: e });
|
|
918
918
|
for (let e = 0; e < t.length; e += 1) {
|
|
919
919
|
let n = t[e], { type: r, backgroundOpacity: i, backgroundColor: a, textBackgroundColor: o } = n, s = typeof i == "number" ? i : 0, c = typeof a == "string" ? a : "", l = typeof o == "string" ? o : "", u = r === "textbox" || r === "background-textbox", d = c.length > 0 || l.length > 0;
|
|
920
920
|
u && (s > 0 && d || (n.backgroundColor = null, n.textBackgroundColor = null));
|
|
921
921
|
}
|
|
922
922
|
}
|
|
923
|
-
function
|
|
924
|
-
let { width: n, height: r, objects: i } = e, { objects: a } = t, { width: o, height: s } =
|
|
923
|
+
function he({ prevState: e, nextState: t }) {
|
|
924
|
+
let { width: n, height: r, objects: i } = e, { objects: a } = t, { width: o, height: s } = fe({ objects: i }), { width: c, height: l } = fe({ objects: a });
|
|
925
925
|
o !== c || s !== l || (t.width = n, t.height = r);
|
|
926
926
|
}
|
|
927
|
-
function
|
|
928
|
-
let n =
|
|
929
|
-
return
|
|
927
|
+
function ge({ prevState: e, nextState: t }) {
|
|
928
|
+
let n = se({ state: e }), r = se({ state: t });
|
|
929
|
+
return me({ objects: n.objects }), me({ objects: r.objects }), he({
|
|
930
930
|
prevState: n,
|
|
931
931
|
nextState: r
|
|
932
932
|
}), {
|
|
@@ -936,10 +936,10 @@ function _e({ prevState: e, nextState: t }) {
|
|
|
936
936
|
}
|
|
937
937
|
//#endregion
|
|
938
938
|
//#region src/editor/history-manager/load-state.ts
|
|
939
|
-
function
|
|
939
|
+
function _e({ customData: e }) {
|
|
940
940
|
return JSON.parse(JSON.stringify(e));
|
|
941
941
|
}
|
|
942
|
-
function
|
|
942
|
+
function ve({ state: e }) {
|
|
943
943
|
let t = JSON.parse(JSON.stringify(e)), n = (t.objects ?? []).filter((e) => e.id !== "overlay-mask");
|
|
944
944
|
t.objects = n;
|
|
945
945
|
for (let e = 0; e < n.length; e += 1) {
|
|
@@ -948,7 +948,7 @@ function ye({ state: e }) {
|
|
|
948
948
|
}
|
|
949
949
|
return t;
|
|
950
950
|
}
|
|
951
|
-
function
|
|
951
|
+
function ye({ state: e, canvas: t }) {
|
|
952
952
|
let { objects: n = [] } = e, r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
|
|
953
953
|
for (let e = 0; e < n.length; e += 1) {
|
|
954
954
|
let { customData: t, id: a } = n[e];
|
|
@@ -963,23 +963,23 @@ function be({ state: e, canvas: t }) {
|
|
|
963
963
|
let a = t.getObjects?.() ?? [];
|
|
964
964
|
for (let e = 0; e < a.length; e += 1) {
|
|
965
965
|
let t = a[e], { id: n } = t, o;
|
|
966
|
-
typeof n == "string" && (o = r.get(n)), o ||= i.get(e), o && (t.customData =
|
|
966
|
+
typeof n == "string" && (o = r.get(n)), o ||= i.get(e), o && (t.customData = _e({ customData: o }));
|
|
967
967
|
}
|
|
968
968
|
}
|
|
969
969
|
//#endregion
|
|
970
970
|
//#region src/editor/history-manager/snapshot-interactivity.ts
|
|
971
|
-
function
|
|
971
|
+
function be({ object: e }) {
|
|
972
972
|
return typeof e.getObjects == "function" ? e.getObjects() : [];
|
|
973
973
|
}
|
|
974
|
-
function
|
|
974
|
+
function xe({ objects: e }) {
|
|
975
975
|
for (let t = 0; t < e.length; t += 1) if (e[t].isEditing) return !0;
|
|
976
976
|
return !1;
|
|
977
977
|
}
|
|
978
|
-
function
|
|
978
|
+
function Se({ object: e }) {
|
|
979
979
|
let t = typeof e.type == "string" ? e.type.toLowerCase() : "";
|
|
980
980
|
return t === "textbox" || t === "background-textbox" || typeof e.isEditing == "boolean";
|
|
981
981
|
}
|
|
982
|
-
function
|
|
982
|
+
function Ce({ object: e, withEvented: t = !1 }) {
|
|
983
983
|
let n = {
|
|
984
984
|
object: e,
|
|
985
985
|
lockMovementX: e.lockMovementX,
|
|
@@ -988,66 +988,66 @@ function we({ object: e, withEvented: t = !1 }) {
|
|
|
988
988
|
};
|
|
989
989
|
return t && (n.evented = e.evented), n;
|
|
990
990
|
}
|
|
991
|
-
function
|
|
992
|
-
return e.shapeComposite !== !0 || !
|
|
991
|
+
function we({ object: e, snapshotStates: t }) {
|
|
992
|
+
return e.shapeComposite !== !0 || !xe({ objects: be({ object: e }) }) ? !1 : (t.push(Ce({ object: e })), e.lockMovementX = !1, e.lockMovementY = !1, e.selectable = !0, !0);
|
|
993
993
|
}
|
|
994
|
-
function
|
|
995
|
-
if (!
|
|
994
|
+
function Te({ object: e, snapshotStates: t }) {
|
|
995
|
+
if (!Se({ object: e })) return !1;
|
|
996
996
|
let n = e.group, { isEditing: r } = e, i = n?.shapeComposite === !0, a = !!n?.locked;
|
|
997
|
-
return !i || a || !r ? !1 : (t.push(
|
|
997
|
+
return !i || a || !r ? !1 : (t.push(Ce({
|
|
998
998
|
object: e,
|
|
999
999
|
withEvented: !0
|
|
1000
1000
|
})), e.lockMovementX = !1, e.lockMovementY = !1, e.selectable = !1, e.evented = !1, !0);
|
|
1001
1001
|
}
|
|
1002
|
-
function
|
|
1003
|
-
if (!
|
|
1002
|
+
function Ee({ object: e, snapshotStates: t }) {
|
|
1003
|
+
if (!Se({ object: e })) return !1;
|
|
1004
1004
|
let n = !!e.lockMovementX, r = !!e.lockMovementY;
|
|
1005
|
-
return !n && !r ? !1 : (t.push(
|
|
1005
|
+
return !n && !r ? !1 : (t.push(Ce({ object: e })), e.lockMovementX = !1, e.lockMovementY = !1, e.selectable = !0, !0);
|
|
1006
1006
|
}
|
|
1007
|
-
function
|
|
1007
|
+
function De({ objects: e }) {
|
|
1008
1008
|
let t = [];
|
|
1009
1009
|
for (let n = 0; n < e.length; n += 1) {
|
|
1010
1010
|
let r = e[n];
|
|
1011
|
-
r.locked ||
|
|
1011
|
+
r.locked || we({
|
|
1012
1012
|
object: r,
|
|
1013
1013
|
snapshotStates: t
|
|
1014
|
-
}) ||
|
|
1014
|
+
}) || Te({
|
|
1015
1015
|
object: r,
|
|
1016
1016
|
snapshotStates: t
|
|
1017
|
-
}) ||
|
|
1017
|
+
}) || Ee({
|
|
1018
1018
|
object: r,
|
|
1019
1019
|
snapshotStates: t
|
|
1020
1020
|
});
|
|
1021
1021
|
}
|
|
1022
1022
|
return t;
|
|
1023
1023
|
}
|
|
1024
|
-
function
|
|
1024
|
+
function Oe({ canvas: e }) {
|
|
1025
1025
|
let t = [...e.getObjects?.() ?? []], n = [];
|
|
1026
1026
|
for (let e = 0; e < t.length; e += 1) {
|
|
1027
1027
|
let r = t[e];
|
|
1028
1028
|
n.push(r);
|
|
1029
|
-
let i =
|
|
1029
|
+
let i = be({ object: r });
|
|
1030
1030
|
for (let e = 0; e < i.length; e += 1) t.push(i[e]);
|
|
1031
1031
|
}
|
|
1032
1032
|
return n;
|
|
1033
1033
|
}
|
|
1034
|
-
function
|
|
1034
|
+
function ke({ snapshotStates: e }) {
|
|
1035
1035
|
for (let t = 0; t < e.length; t += 1) {
|
|
1036
1036
|
let { object: n, lockMovementX: r, lockMovementY: i, selectable: a, evented: o } = e[t];
|
|
1037
1037
|
n.lockMovementX = r, n.lockMovementY = i, n.selectable = a, o !== void 0 && (n.evented = o);
|
|
1038
1038
|
}
|
|
1039
1039
|
}
|
|
1040
|
-
function
|
|
1041
|
-
let n =
|
|
1040
|
+
function Ae({ canvas: e, callback: t }) {
|
|
1041
|
+
let n = De({ objects: Oe({ canvas: e }) });
|
|
1042
1042
|
try {
|
|
1043
1043
|
return t();
|
|
1044
1044
|
} finally {
|
|
1045
|
-
|
|
1045
|
+
ke({ snapshotStates: n });
|
|
1046
1046
|
}
|
|
1047
1047
|
}
|
|
1048
1048
|
//#endregion
|
|
1049
1049
|
//#region src/editor/history-manager/index.ts
|
|
1050
|
-
var
|
|
1050
|
+
var je = class {
|
|
1051
1051
|
constructor({ editor: e }) {
|
|
1052
1052
|
this.editor = e, this.canvas = e.canvas, this._isSavingState = !1, this._historySuspendCount = 0, this._isActionInProgress = !1, this._actionSnapshot = null, this._actionReason = null, this._pendingSaveTimeoutId = null, this._pendingSaveReason = null, this._pendingCommittedState = null, this._pendingCommittedStateReason = null, this._hasDeferredSaveAfterUnblock = !1, this.baseState = null, this.patches = [], this.currentIndex = 0, this.maxHistoryLength = e.options.maxHistoryLength, this.totalChangesCount = 0, this.baseStateChangesCount = 0, this._createDiffPatcher();
|
|
1053
1053
|
}
|
|
@@ -1115,14 +1115,14 @@ var Me = class {
|
|
|
1115
1115
|
return console.log("getFullState state", r), r;
|
|
1116
1116
|
}
|
|
1117
1117
|
_captureCurrentState() {
|
|
1118
|
-
return
|
|
1118
|
+
return Ae({
|
|
1119
1119
|
canvas: this.canvas,
|
|
1120
1120
|
callback: () => this._serializeCanvasState()
|
|
1121
1121
|
});
|
|
1122
1122
|
}
|
|
1123
1123
|
_serializeCanvasState() {
|
|
1124
1124
|
let { canvas: e } = this;
|
|
1125
|
-
return e.toDatalessObject([...
|
|
1125
|
+
return e.toDatalessObject([...oe]);
|
|
1126
1126
|
}
|
|
1127
1127
|
_handlePendingSaveTimeout() {
|
|
1128
1128
|
this._pendingSaveTimeoutId !== null && (this._pendingSaveTimeoutId = null, this._pendingSaveReason = null, this.saveState());
|
|
@@ -1165,7 +1165,7 @@ var Me = class {
|
|
|
1165
1165
|
this.baseState = e, this.patches = [], this.currentIndex = 0, console.log("Базовое состояние сохранено.");
|
|
1166
1166
|
return;
|
|
1167
1167
|
}
|
|
1168
|
-
let { prevState: t, nextState: n } =
|
|
1168
|
+
let { prevState: t, nextState: n } = ge({
|
|
1169
1169
|
prevState: this.getFullState(),
|
|
1170
1170
|
nextState: e
|
|
1171
1171
|
}), r = this.diffPatcher.diff(t, n);
|
|
@@ -1173,7 +1173,7 @@ var Me = class {
|
|
|
1173
1173
|
console.log("Нет изменений для сохранения.");
|
|
1174
1174
|
return;
|
|
1175
1175
|
}
|
|
1176
|
-
if (
|
|
1176
|
+
if (ue({
|
|
1177
1177
|
prevState: t,
|
|
1178
1178
|
nextState: n
|
|
1179
1179
|
})) {
|
|
@@ -1195,9 +1195,9 @@ var Me = class {
|
|
|
1195
1195
|
try {
|
|
1196
1196
|
let e = this._consumePendingCommittedState();
|
|
1197
1197
|
e && (this._pendingSaveTimeoutId !== null && this._pendingSaveReason === e.reason && this._clearPendingSave(), e.reason === "text-edit" && this._deactivateTextEditing(), this._saveSerializedState({ currentStateObj: e.state }));
|
|
1198
|
-
let t =
|
|
1198
|
+
let t = Ae({
|
|
1199
1199
|
canvas: this.canvas,
|
|
1200
|
-
callback: () => this.canvas.toDatalessObject([...
|
|
1200
|
+
callback: () => this.canvas.toDatalessObject([...oe])
|
|
1201
1201
|
});
|
|
1202
1202
|
console.timeEnd("saveState"), this._saveSerializedState({ currentStateObj: t });
|
|
1203
1203
|
} finally {
|
|
@@ -1210,8 +1210,8 @@ var Me = class {
|
|
|
1210
1210
|
console.log("loadStateFromFullState fullState", e);
|
|
1211
1211
|
let { canvas: t, canvasManager: n, interactionBlocker: r, backgroundManager: i, zoomManager: a, panConstraintManager: o } = this.editor, { width: s, height: c } = t, { width: l, height: u } = this.editor.montageArea;
|
|
1212
1212
|
r.overlayMask = null;
|
|
1213
|
-
let d =
|
|
1214
|
-
await t.loadFromJSON(d),
|
|
1213
|
+
let d = ve({ state: e });
|
|
1214
|
+
await t.loadFromJSON(d), ye({
|
|
1215
1215
|
state: e,
|
|
1216
1216
|
canvas: t
|
|
1217
1217
|
});
|
|
@@ -1293,7 +1293,7 @@ var Me = class {
|
|
|
1293
1293
|
}
|
|
1294
1294
|
}
|
|
1295
1295
|
}
|
|
1296
|
-
},
|
|
1296
|
+
}, Me = .1, Ne = 4096, Pe = 4096, Fe = "application/image-editor:", Ie = /* @__PURE__ */ "customData.backgroundType.format.contentType.width.height.originX.originY.locked.editable.evented.selectable.lockMovementX.lockMovementY.lockRotation.lockScalingX.lockScalingY.lockSkewingX.lockSkewingY.styles.lineFontDefaults.textCaseRaw.uppercase.autoExpand.linethrough.underline.fontStyle.fontWeight.backgroundOpacity.paddingTop.paddingRight.paddingBottom.paddingLeft.radiusTopLeft.radiusTopRight.radiusBottomRight.radiusBottomLeft.shapeComposite.shapePresetKey.shapeBaseWidth.shapeBaseHeight.shapeManualBaseWidth.shapeManualBaseHeight.shapeReplaceBoxWidth.shapeReplaceBoxHeight.shapeTextAutoExpand.shapeAlignHorizontal.shapeAlignVertical.shapePaddingTop.shapePaddingRight.shapePaddingBottom.shapePaddingLeft.shapeFill.shapeStroke.shapeStrokeWidth.shapeStrokeDashArray.shapeOpacity.shapeRounding.shapeNodeType".split("."), Le = class e {
|
|
1297
1297
|
constructor({ editor: e }) {
|
|
1298
1298
|
this.editor = e, this.options = e.options, this._createdBlobUrls = [], this.acceptContentTypes = this.editor.options.acceptContentTypes, this.acceptFormats = this.getAllowedFormatsFromContentTypes();
|
|
1299
1299
|
}
|
|
@@ -1490,7 +1490,7 @@ var Me = class {
|
|
|
1490
1490
|
}
|
|
1491
1491
|
}
|
|
1492
1492
|
async resizeImageToBoundaries(e) {
|
|
1493
|
-
let { dataURL: t, sizeType: n = "max", contentType: r = "image/png", quality: i = 1, maxWidth: a =
|
|
1493
|
+
let { dataURL: t, sizeType: n = "max", contentType: r = "image/png", quality: i = 1, maxWidth: a = Ne, maxHeight: o = Pe, minWidth: s = 16, minHeight: c = 16, asBase64: l = !1, emitMessage: u = !0 } = e, { errorManager: d, workerManager: f } = this.editor, p = {
|
|
1494
1494
|
dataURL: t,
|
|
1495
1495
|
sizeType: n,
|
|
1496
1496
|
contentType: r,
|
|
@@ -1766,11 +1766,11 @@ var Me = class {
|
|
|
1766
1766
|
let t = e.match(/^[^/]+\/([^+;]+)/);
|
|
1767
1767
|
return t ? t[1] : "";
|
|
1768
1768
|
}
|
|
1769
|
-
},
|
|
1770
|
-
function
|
|
1769
|
+
}, Re = (e, t, n) => Math.max(Math.min(e, n), t), ze = (e, t) => e * t;
|
|
1770
|
+
function Be(e) {
|
|
1771
1771
|
return (e?.type === "image" || e?.format === "svg") && typeof e?.width == "number" && typeof e?.height == "number";
|
|
1772
1772
|
}
|
|
1773
|
-
var
|
|
1773
|
+
var Ve = class {
|
|
1774
1774
|
constructor({ editor: e }) {
|
|
1775
1775
|
this.editor = e;
|
|
1776
1776
|
}
|
|
@@ -1780,7 +1780,7 @@ var He = class {
|
|
|
1780
1780
|
}
|
|
1781
1781
|
getVisibleCenterPoint() {
|
|
1782
1782
|
let { canvas: e } = this.editor, t = e.getZoom(), n = e.viewportTransform, r = e.getWidth(), i = e.getHeight(), a = this.getMontageAreaSceneBounds(), o = (r / 2 - n[4]) / t, s = (i / 2 - n[5]) / t;
|
|
1783
|
-
return new p(
|
|
1783
|
+
return new p(Re(o, a.left, a.right), Re(s, a.top, a.bottom));
|
|
1784
1784
|
}
|
|
1785
1785
|
getMontageAreaSceneCenter() {
|
|
1786
1786
|
let { montageArea: e } = this.editor;
|
|
@@ -1859,9 +1859,9 @@ var He = class {
|
|
|
1859
1859
|
}
|
|
1860
1860
|
setResolutionWidth(e, { preserveProportional: t, withoutSave: n, adaptCanvasToContainer: r } = {}) {
|
|
1861
1861
|
if (!e) return;
|
|
1862
|
-
let { canvas: i, montageArea: a, options: { canvasBackstoreWidth: o } } = this.editor, { width: s, height: c } = a, l =
|
|
1862
|
+
let { canvas: i, montageArea: a, options: { canvasBackstoreWidth: o } } = this.editor, { width: s, height: c } = a, l = Re(Number(e), 16, Ne);
|
|
1863
1863
|
if (!o || o === "auto" || r ? this.adaptCanvasToContainer() : o ? this.setCanvasBackstoreWidth(Number(o)) : this.setCanvasBackstoreWidth(l), a.set({ width: l }), this.placeMontageAreaAtCanonicalScenePosition(), t) {
|
|
1864
|
-
let e =
|
|
1864
|
+
let e = ze(c, l / s);
|
|
1865
1865
|
this.setResolutionHeight(e, {
|
|
1866
1866
|
withoutSave: n,
|
|
1867
1867
|
adaptCanvasToContainer: r
|
|
@@ -1877,9 +1877,9 @@ var He = class {
|
|
|
1877
1877
|
}
|
|
1878
1878
|
setResolutionHeight(e, { preserveProportional: t, withoutSave: n, adaptCanvasToContainer: r } = {}) {
|
|
1879
1879
|
if (!e) return;
|
|
1880
|
-
let { canvas: i, montageArea: a, options: { canvasBackstoreHeight: o } } = this.editor, { width: s, height: c } = a, l =
|
|
1880
|
+
let { canvas: i, montageArea: a, options: { canvasBackstoreHeight: o } } = this.editor, { width: s, height: c } = a, l = Re(Number(e), 16, Pe);
|
|
1881
1881
|
if (!o || o === "auto" || r ? this.adaptCanvasToContainer() : o ? this.setCanvasBackstoreHeight(Number(o)) : this.setCanvasBackstoreHeight(l), a.set({ height: l }), this.placeMontageAreaAtCanonicalScenePosition(), t) {
|
|
1882
|
-
let e =
|
|
1882
|
+
let e = ze(s, l / c);
|
|
1883
1883
|
this.setResolutionWidth(e, {
|
|
1884
1884
|
withoutSave: n,
|
|
1885
1885
|
adaptCanvasToContainer: r
|
|
@@ -1906,16 +1906,16 @@ var He = class {
|
|
|
1906
1906
|
}
|
|
1907
1907
|
setCanvasBackstoreWidth(e) {
|
|
1908
1908
|
if (!e || typeof e != "number") return;
|
|
1909
|
-
let t =
|
|
1909
|
+
let t = Re(e, 16, Ne);
|
|
1910
1910
|
this.editor.canvas.setDimensions({ width: t }, { backstoreOnly: !0 });
|
|
1911
1911
|
}
|
|
1912
1912
|
setCanvasBackstoreHeight(e) {
|
|
1913
1913
|
if (!e || typeof e != "number") return;
|
|
1914
|
-
let t =
|
|
1914
|
+
let t = Re(e, 16, Pe);
|
|
1915
1915
|
this.editor.canvas.setDimensions({ height: t }, { backstoreOnly: !0 });
|
|
1916
1916
|
}
|
|
1917
1917
|
adaptCanvasToContainer() {
|
|
1918
|
-
let { canvas: e } = this.editor, t = this.getEditorContainer(), n = t.clientWidth, r = t.clientHeight, i =
|
|
1918
|
+
let { canvas: e } = this.editor, t = this.getEditorContainer(), n = t.clientWidth, r = t.clientHeight, i = Re(n, 16, Ne), a = Re(r, 16, Pe);
|
|
1919
1919
|
e.setDimensions({
|
|
1920
1920
|
width: i,
|
|
1921
1921
|
height: a
|
|
@@ -2003,8 +2003,8 @@ var He = class {
|
|
|
2003
2003
|
}
|
|
2004
2004
|
scaleMontageAreaToImage({ object: e, preserveAspectRatio: t, withoutSave: n } = {}) {
|
|
2005
2005
|
let { canvas: r, montageArea: i, transformManager: a } = this.editor, o = e || r.getActiveObject();
|
|
2006
|
-
if (!
|
|
2007
|
-
let { width: s, height: c } = o, l = Math.min(s,
|
|
2006
|
+
if (!Be(o)) return;
|
|
2007
|
+
let { width: s, height: c } = o, l = Math.min(s, Ne), u = Math.min(c, Pe);
|
|
2008
2008
|
if (t) {
|
|
2009
2009
|
let { width: e, height: t } = i, n = s / e, r = c / t, a = Math.max(n, r);
|
|
2010
2010
|
l = e * a, u = t * a;
|
|
@@ -2032,7 +2032,7 @@ var He = class {
|
|
|
2032
2032
|
let { canvas: e, montageArea: t, interactionBlocker: { overlayMask: n }, backgroundManager: { backgroundObject: r } } = this.editor;
|
|
2033
2033
|
return e.getObjects().filter((e) => e.id !== t.id && e.id !== n?.id && e.id !== r?.id);
|
|
2034
2034
|
}
|
|
2035
|
-
},
|
|
2035
|
+
}, He = class {
|
|
2036
2036
|
constructor({ editor: e }) {
|
|
2037
2037
|
this.editor = e, this.options = e.options;
|
|
2038
2038
|
}
|
|
@@ -2140,7 +2140,7 @@ var He = class {
|
|
|
2140
2140
|
});
|
|
2141
2141
|
}
|
|
2142
2142
|
}
|
|
2143
|
-
},
|
|
2143
|
+
}, Ue = class {
|
|
2144
2144
|
constructor({ editor: e }) {
|
|
2145
2145
|
this.editor = e, this.options = e.options, this.minZoom = this.options.minZoom || .1, this.maxZoom = this.options.maxZoom || 2, this.defaultZoom = this._normalizeDefaultZoom(this.options.defaultScale);
|
|
2146
2146
|
}
|
|
@@ -2194,7 +2194,7 @@ var He = class {
|
|
|
2194
2194
|
y: Math.abs(T) > Math.abs(d) ? d : T
|
|
2195
2195
|
};
|
|
2196
2196
|
}
|
|
2197
|
-
_applyViewportCentering(e, t = !1, n =
|
|
2197
|
+
_applyViewportCentering(e, t = !1, n = Me) {
|
|
2198
2198
|
let { canvas: r } = this.editor, i = this._getScaledMontageDimensions(e), a = r.getWidth(), o = r.getHeight(), s = i.width > a || i.height > o, c = this._calculateFitZoom(), l = e - c;
|
|
2199
2199
|
if (!(!s || l) && !t) return !1;
|
|
2200
2200
|
let u = r.viewportTransform, d = this._calculateTargetViewportPosition(e);
|
|
@@ -2243,7 +2243,7 @@ var He = class {
|
|
|
2243
2243
|
pointY: u.y
|
|
2244
2244
|
});
|
|
2245
2245
|
}
|
|
2246
|
-
zoom(e =
|
|
2246
|
+
zoom(e = Me, t = {}) {
|
|
2247
2247
|
if (!e) return;
|
|
2248
2248
|
let { minZoom: n, maxZoom: r } = this, { canvas: i } = this.editor, a = e < 0, o = i.getZoom(), s = i.getCenterPoint(), c = new p(t.pointX ?? s.x, t.pointY ?? s.y);
|
|
2249
2249
|
this.editor.montageArea.setCoords(), this.editor.canvas.requestRenderAll();
|
|
@@ -2269,8 +2269,8 @@ var He = class {
|
|
|
2269
2269
|
point: r
|
|
2270
2270
|
}), this.editor.panConstraintManager.updateBounds();
|
|
2271
2271
|
}
|
|
2272
|
-
},
|
|
2273
|
-
let r =
|
|
2272
|
+
}, We = ({ value: e, fallback: t = 0 }) => typeof e == "number" && Number.isFinite(e) ? e : typeof t == "number" && Number.isFinite(t) ? t : 0, Ge = ({ value: e, dimension: t, useRelativePositions: n }) => {
|
|
2273
|
+
let r = We({ value: e });
|
|
2274
2274
|
return n ? r : r / (t || 1);
|
|
2275
2275
|
}, Ke = ({ object: e, baseWidth: t, baseHeight: n, useRelativePositions: r }) => ({
|
|
2276
2276
|
x: Ge({
|
|
@@ -2292,7 +2292,7 @@ var He = class {
|
|
|
2292
2292
|
top: Math.round(n)
|
|
2293
2293
|
};
|
|
2294
2294
|
u || (f > 0 && (m.scaleX = Math.max(1, Math.round(f * a)) / f), p > 0 && (m.scaleY = Math.max(1, Math.round(p * o)) / p)), e.set(m), e.setCoords();
|
|
2295
|
-
},
|
|
2295
|
+
}, Ye = ({ object: e }) => {
|
|
2296
2296
|
if (!e) return null;
|
|
2297
2297
|
try {
|
|
2298
2298
|
e.setCoords();
|
|
@@ -2311,7 +2311,7 @@ var He = class {
|
|
|
2311
2311
|
};
|
|
2312
2312
|
//#endregion
|
|
2313
2313
|
//#region src/editor/utils/primitive-shapes.ts
|
|
2314
|
-
function
|
|
2314
|
+
function Xe({ canvas: e, object: t, left: n, top: r, centerPoint: i, flags: a }) {
|
|
2315
2315
|
let { withoutSelection: o, withoutAdding: s } = a;
|
|
2316
2316
|
if (n === void 0 && r === void 0) {
|
|
2317
2317
|
let n = i ?? e.getCenterPoint();
|
|
@@ -2319,9 +2319,9 @@ function Ye({ canvas: e, object: t, left: n, top: r, centerPoint: i, flags: a })
|
|
|
2319
2319
|
}
|
|
2320
2320
|
return Je({ object: t }), s ? t : (e.add(t), o || e.setActiveObject(t), e.renderAll(), t);
|
|
2321
2321
|
}
|
|
2322
|
-
var
|
|
2322
|
+
var Ze = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
|
|
2323
2323
|
let { id: i = `rect-${D()}`, left: a, top: o, width: s = 100, height: c = 100, fill: l = "blue", ...u } = t;
|
|
2324
|
-
return
|
|
2324
|
+
return Xe({
|
|
2325
2325
|
canvas: e,
|
|
2326
2326
|
object: new g({
|
|
2327
2327
|
id: i,
|
|
@@ -2337,7 +2337,7 @@ var Xe = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
|
|
|
2337
2337
|
centerPoint: n,
|
|
2338
2338
|
flags: r
|
|
2339
2339
|
});
|
|
2340
|
-
},
|
|
2340
|
+
}, Qe = class {
|
|
2341
2341
|
constructor({ editor: e }) {
|
|
2342
2342
|
this.editor = e, this.isBlocked = !1, this.overlayMask = null;
|
|
2343
2343
|
}
|
|
@@ -2359,7 +2359,7 @@ var Xe = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
|
|
|
2359
2359
|
}
|
|
2360
2360
|
_createOverlay() {
|
|
2361
2361
|
let { historyManager: e, options: { overlayMaskColor: t = "rgba(0,0,0,0.5)" } } = this.editor;
|
|
2362
|
-
e.suspendHistory(), this.overlayMask =
|
|
2362
|
+
e.suspendHistory(), this.overlayMask = Ze({
|
|
2363
2363
|
canvas: this.editor.canvas,
|
|
2364
2364
|
options: {
|
|
2365
2365
|
...this._getOverlayGeometry(),
|
|
@@ -2397,7 +2397,7 @@ var Xe = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
|
|
|
2397
2397
|
e.evented = !0, e.selectable = !0;
|
|
2398
2398
|
}), e.upperCanvasEl.style.pointerEvents = "", e.lowerCanvasEl.style.pointerEvents = "", this.overlayMask.visible = !1, e.requestRenderAll(), e.fire("editor:enabled"), n.resumeHistory(), n.flushDeferredSaveAfterUnblock();
|
|
2399
2399
|
}
|
|
2400
|
-
},
|
|
2400
|
+
}, $e = class e {
|
|
2401
2401
|
constructor({ editor: e }) {
|
|
2402
2402
|
this.editor = e, this.backgroundObject = null;
|
|
2403
2403
|
}
|
|
@@ -2589,7 +2589,7 @@ var Xe = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
|
|
|
2589
2589
|
this.backgroundObject && a !== i + 1 && e.moveObjectTo(this.backgroundObject, i + 1), e.requestRenderAll(), n.resumeHistory();
|
|
2590
2590
|
}
|
|
2591
2591
|
_createColorBackground(e) {
|
|
2592
|
-
this.backgroundObject =
|
|
2592
|
+
this.backgroundObject = Ze({
|
|
2593
2593
|
canvas: this.editor.canvas,
|
|
2594
2594
|
options: {
|
|
2595
2595
|
...this._getMontageBackgroundRectOptions(),
|
|
@@ -2606,7 +2606,7 @@ var Xe = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
|
|
|
2606
2606
|
}), this.refresh();
|
|
2607
2607
|
}
|
|
2608
2608
|
_createGradientBackground(t) {
|
|
2609
|
-
this.backgroundObject =
|
|
2609
|
+
this.backgroundObject = Ze({
|
|
2610
2610
|
canvas: this.editor.canvas,
|
|
2611
2611
|
options: {
|
|
2612
2612
|
...this._getMontageBackgroundRectOptions(),
|
|
@@ -2705,7 +2705,7 @@ var Xe = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
|
|
|
2705
2705
|
return e.color === n.color && Math.abs(e.offset - n.offset) < 1e-4;
|
|
2706
2706
|
}) ? !1 : e.type === "linear" && t.type === "linear" ? Math.abs(e.coords.x1 - t.coords.x1) < 1e-4 && Math.abs(e.coords.y1 - t.coords.y1) < 1e-4 && Math.abs(e.coords.x2 - t.coords.x2) < 1e-4 && Math.abs(e.coords.y2 - t.coords.y2) < 1e-4 : e.type === "radial" && t.type === "radial" ? Math.abs(e.coords.x1 - t.coords.x1) < 1e-4 && Math.abs(e.coords.y1 - t.coords.y1) < 1e-4 && Math.abs(e.coords.x2 - t.coords.x2) < 1e-4 && Math.abs(e.coords.y2 - t.coords.y2) < 1e-4 && Math.abs(e.coords.r1 - t.coords.r1) < 1e-4 && Math.abs(e.coords.r2 - t.coords.r2) < 1e-4 : !1;
|
|
2707
2707
|
}
|
|
2708
|
-
},
|
|
2708
|
+
}, et = class t {
|
|
2709
2709
|
constructor({ editor: e }) {
|
|
2710
2710
|
this.editor = e;
|
|
2711
2711
|
}
|
|
@@ -2779,28 +2779,24 @@ var Xe = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
|
|
|
2779
2779
|
e.sendObjectBackwards(t.obj);
|
|
2780
2780
|
});
|
|
2781
2781
|
}
|
|
2782
|
-
},
|
|
2782
|
+
}, W = 180, tt = {
|
|
2783
2783
|
top: 0,
|
|
2784
2784
|
right: 0,
|
|
2785
2785
|
bottom: 0,
|
|
2786
2786
|
left: 0
|
|
2787
|
-
},
|
|
2788
|
-
let
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
y: nt({ value: r + t * Math.sin(s) })
|
|
2794
|
-
});
|
|
2795
|
-
}
|
|
2796
|
-
return a;
|
|
2787
|
+
}, nt = .45, rt = ({ value: e }) => Number(e.toFixed(4)), G = ({ width: e, height: t }) => {
|
|
2788
|
+
let n = W / Math.max(e, t);
|
|
2789
|
+
return {
|
|
2790
|
+
width: rt({ value: e * n }),
|
|
2791
|
+
height: rt({ value: t * n })
|
|
2792
|
+
};
|
|
2797
2793
|
}, it = ({ spikes: e, outerRadius: t = 50, innerRadius: n = 22, centerX: r = 50, centerY: i = 50, rotation: a = -Math.PI / 2 }) => {
|
|
2798
2794
|
let o = [], s = e * 2;
|
|
2799
2795
|
for (let c = 0; c < s; c += 1) {
|
|
2800
2796
|
let s = c % 2 == 0 ? t : n, l = a + c * Math.PI / e;
|
|
2801
2797
|
o.push({
|
|
2802
|
-
x:
|
|
2803
|
-
y:
|
|
2798
|
+
x: rt({ value: r + s * Math.cos(l) }),
|
|
2799
|
+
y: rt({ value: i + s * Math.sin(l) })
|
|
2804
2800
|
});
|
|
2805
2801
|
}
|
|
2806
2802
|
return o;
|
|
@@ -2808,8 +2804,8 @@ var Xe = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
|
|
|
2808
2804
|
{
|
|
2809
2805
|
key: "circle",
|
|
2810
2806
|
type: "ellipse",
|
|
2811
|
-
width:
|
|
2812
|
-
height:
|
|
2807
|
+
width: W,
|
|
2808
|
+
height: W,
|
|
2813
2809
|
internalTextInset: {
|
|
2814
2810
|
top: .24,
|
|
2815
2811
|
right: .24,
|
|
@@ -2817,29 +2813,46 @@ var Xe = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
|
|
|
2817
2813
|
left: .24
|
|
2818
2814
|
}
|
|
2819
2815
|
},
|
|
2816
|
+
{
|
|
2817
|
+
key: "pie",
|
|
2818
|
+
type: "path",
|
|
2819
|
+
...G({
|
|
2820
|
+
width: 34,
|
|
2821
|
+
height: 34
|
|
2822
|
+
}),
|
|
2823
|
+
path: "M34 17A17 17 0 1 1 17 0v17z",
|
|
2824
|
+
internalTextInset: {
|
|
2825
|
+
top: .22,
|
|
2826
|
+
right: .26,
|
|
2827
|
+
bottom: .14,
|
|
2828
|
+
left: .14
|
|
2829
|
+
}
|
|
2830
|
+
},
|
|
2820
2831
|
{
|
|
2821
2832
|
key: "triangle",
|
|
2822
2833
|
type: "triangle",
|
|
2823
|
-
|
|
2824
|
-
|
|
2834
|
+
...G({
|
|
2835
|
+
width: 38,
|
|
2836
|
+
height: 31
|
|
2837
|
+
}),
|
|
2825
2838
|
internalTextInset: {
|
|
2826
|
-
top: .
|
|
2827
|
-
right: .
|
|
2828
|
-
bottom: .
|
|
2829
|
-
left: .
|
|
2839
|
+
top: .34,
|
|
2840
|
+
right: .18,
|
|
2841
|
+
bottom: .12,
|
|
2842
|
+
left: .18
|
|
2830
2843
|
}
|
|
2831
2844
|
},
|
|
2832
2845
|
{
|
|
2833
2846
|
key: "square",
|
|
2834
2847
|
type: "rect",
|
|
2835
|
-
width:
|
|
2836
|
-
height:
|
|
2848
|
+
width: W,
|
|
2849
|
+
height: W
|
|
2837
2850
|
},
|
|
2838
2851
|
{
|
|
2839
2852
|
key: "diamond",
|
|
2840
2853
|
type: "polygon",
|
|
2841
|
-
width:
|
|
2842
|
-
height:
|
|
2854
|
+
width: W,
|
|
2855
|
+
height: W,
|
|
2843
2856
|
points: [
|
|
2844
2857
|
{
|
|
2845
2858
|
x: 50,
|
|
@@ -2868,95 +2881,194 @@ var Xe = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
|
|
|
2868
2881
|
{
|
|
2869
2882
|
key: "pentagon",
|
|
2870
2883
|
type: "polygon",
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
sides: 5,
|
|
2875
|
-
radius: 50,
|
|
2876
|
-
rotation: -Math.PI / 2
|
|
2884
|
+
...G({
|
|
2885
|
+
width: 36,
|
|
2886
|
+
height: 33
|
|
2877
2887
|
}),
|
|
2888
|
+
points: [
|
|
2889
|
+
{
|
|
2890
|
+
x: 50,
|
|
2891
|
+
y: 0
|
|
2892
|
+
},
|
|
2893
|
+
{
|
|
2894
|
+
x: 100,
|
|
2895
|
+
y: 38.197
|
|
2896
|
+
},
|
|
2897
|
+
{
|
|
2898
|
+
x: 80.9028,
|
|
2899
|
+
y: 100
|
|
2900
|
+
},
|
|
2901
|
+
{
|
|
2902
|
+
x: 19.0972,
|
|
2903
|
+
y: 100
|
|
2904
|
+
},
|
|
2905
|
+
{
|
|
2906
|
+
x: 0,
|
|
2907
|
+
y: 38.197
|
|
2908
|
+
}
|
|
2909
|
+
],
|
|
2878
2910
|
internalTextInset: {
|
|
2879
|
-
top: .
|
|
2880
|
-
right: .
|
|
2881
|
-
bottom: .
|
|
2882
|
-
left: .
|
|
2911
|
+
top: .24,
|
|
2912
|
+
right: .18,
|
|
2913
|
+
bottom: .18,
|
|
2914
|
+
left: .18
|
|
2883
2915
|
}
|
|
2884
2916
|
},
|
|
2885
2917
|
{
|
|
2886
2918
|
key: "hexagon",
|
|
2887
2919
|
type: "polygon",
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
sides: 6,
|
|
2892
|
-
radius: 50,
|
|
2893
|
-
rotation: 0
|
|
2920
|
+
...G({
|
|
2921
|
+
width: 32,
|
|
2922
|
+
height: 36
|
|
2894
2923
|
}),
|
|
2924
|
+
points: [
|
|
2925
|
+
{
|
|
2926
|
+
x: 50,
|
|
2927
|
+
y: 0
|
|
2928
|
+
},
|
|
2929
|
+
{
|
|
2930
|
+
x: 100,
|
|
2931
|
+
y: 25
|
|
2932
|
+
},
|
|
2933
|
+
{
|
|
2934
|
+
x: 100,
|
|
2935
|
+
y: 75
|
|
2936
|
+
},
|
|
2937
|
+
{
|
|
2938
|
+
x: 50,
|
|
2939
|
+
y: 100
|
|
2940
|
+
},
|
|
2941
|
+
{
|
|
2942
|
+
x: 0,
|
|
2943
|
+
y: 75
|
|
2944
|
+
},
|
|
2945
|
+
{
|
|
2946
|
+
x: 0,
|
|
2947
|
+
y: 25
|
|
2948
|
+
}
|
|
2949
|
+
],
|
|
2895
2950
|
internalTextInset: {
|
|
2896
|
-
top: .
|
|
2897
|
-
right: .
|
|
2898
|
-
bottom: .
|
|
2899
|
-
left: .
|
|
2951
|
+
top: .22,
|
|
2952
|
+
right: .18,
|
|
2953
|
+
bottom: .22,
|
|
2954
|
+
left: .18
|
|
2900
2955
|
}
|
|
2901
2956
|
},
|
|
2902
2957
|
{
|
|
2903
2958
|
key: "star",
|
|
2904
2959
|
type: "polygon",
|
|
2905
|
-
|
|
2906
|
-
|
|
2960
|
+
...G({
|
|
2961
|
+
width: 38,
|
|
2962
|
+
height: 36
|
|
2963
|
+
}),
|
|
2964
|
+
points: [
|
|
2965
|
+
{
|
|
2966
|
+
x: 50,
|
|
2967
|
+
y: 0
|
|
2968
|
+
},
|
|
2969
|
+
{
|
|
2970
|
+
x: 61.8026,
|
|
2971
|
+
y: 38.1944
|
|
2972
|
+
},
|
|
2973
|
+
{
|
|
2974
|
+
x: 100,
|
|
2975
|
+
y: 38.1944
|
|
2976
|
+
},
|
|
2977
|
+
{
|
|
2978
|
+
x: 69.0974,
|
|
2979
|
+
y: 61.8056
|
|
2980
|
+
},
|
|
2981
|
+
{
|
|
2982
|
+
x: 80.9026,
|
|
2983
|
+
y: 100
|
|
2984
|
+
},
|
|
2985
|
+
{
|
|
2986
|
+
x: 50,
|
|
2987
|
+
y: 76.3944
|
|
2988
|
+
},
|
|
2989
|
+
{
|
|
2990
|
+
x: 19.0974,
|
|
2991
|
+
y: 100
|
|
2992
|
+
},
|
|
2993
|
+
{
|
|
2994
|
+
x: 30.9026,
|
|
2995
|
+
y: 61.8056
|
|
2996
|
+
},
|
|
2997
|
+
{
|
|
2998
|
+
x: 0,
|
|
2999
|
+
y: 38.1944
|
|
3000
|
+
},
|
|
3001
|
+
{
|
|
3002
|
+
x: 38.1974,
|
|
3003
|
+
y: 38.1944
|
|
3004
|
+
}
|
|
3005
|
+
],
|
|
3006
|
+
internalTextInset: {
|
|
3007
|
+
top: .3,
|
|
3008
|
+
right: .3,
|
|
3009
|
+
bottom: .3,
|
|
3010
|
+
left: .3
|
|
3011
|
+
}
|
|
3012
|
+
},
|
|
3013
|
+
{
|
|
3014
|
+
key: "star-16",
|
|
3015
|
+
type: "polygon",
|
|
3016
|
+
width: W,
|
|
3017
|
+
height: W,
|
|
2907
3018
|
points: it({
|
|
2908
|
-
spikes:
|
|
3019
|
+
spikes: 16,
|
|
2909
3020
|
outerRadius: 50,
|
|
2910
|
-
innerRadius:
|
|
3021
|
+
innerRadius: 45,
|
|
2911
3022
|
rotation: -Math.PI / 2
|
|
2912
3023
|
}),
|
|
2913
3024
|
internalTextInset: {
|
|
2914
|
-
top: .
|
|
2915
|
-
right: .
|
|
2916
|
-
bottom: .
|
|
2917
|
-
left: .
|
|
3025
|
+
top: .24,
|
|
3026
|
+
right: .24,
|
|
3027
|
+
bottom: .24,
|
|
3028
|
+
left: .24
|
|
2918
3029
|
}
|
|
2919
3030
|
},
|
|
2920
3031
|
{
|
|
2921
3032
|
key: "sparkle",
|
|
2922
3033
|
type: "polygon",
|
|
2923
|
-
width:
|
|
2924
|
-
height:
|
|
3034
|
+
width: W,
|
|
3035
|
+
height: W,
|
|
2925
3036
|
points: it({
|
|
2926
3037
|
spikes: 4,
|
|
2927
3038
|
outerRadius: 50,
|
|
2928
|
-
innerRadius:
|
|
3039
|
+
innerRadius: 19.1,
|
|
2929
3040
|
rotation: -Math.PI / 2
|
|
2930
3041
|
}),
|
|
2931
3042
|
internalTextInset: {
|
|
2932
|
-
top: .
|
|
2933
|
-
right: .
|
|
2934
|
-
bottom: .
|
|
2935
|
-
left: .
|
|
3043
|
+
top: .32,
|
|
3044
|
+
right: .32,
|
|
3045
|
+
bottom: .32,
|
|
3046
|
+
left: .32
|
|
2936
3047
|
}
|
|
2937
3048
|
},
|
|
2938
3049
|
{
|
|
2939
3050
|
key: "heart",
|
|
2940
3051
|
type: "path",
|
|
2941
|
-
|
|
2942
|
-
|
|
3052
|
+
...G({
|
|
3053
|
+
width: 36,
|
|
3054
|
+
height: 34
|
|
3055
|
+
}),
|
|
2943
3056
|
path: [
|
|
2944
|
-
"
|
|
2945
|
-
"
|
|
2946
|
-
"
|
|
2947
|
-
"C96 56 80 74 50 92 Z"
|
|
3057
|
+
"M26 0c5.523 0 10 4.477 10 10l-.013.586",
|
|
3058
|
+
"C35.443 22.876 18.003 33.998 18 34c-.004-.003-18-11.48-18-24",
|
|
3059
|
+
"C0 4.477 4.477 0 10 0a9.99 9.99 0 0 1 8 3.999A9.99 9.99 0 0 1 26 0"
|
|
2948
3060
|
].join(" "),
|
|
2949
3061
|
internalTextInset: {
|
|
2950
|
-
top: .
|
|
2951
|
-
right: .
|
|
2952
|
-
bottom: .
|
|
2953
|
-
left: .
|
|
3062
|
+
top: .22,
|
|
3063
|
+
right: .22,
|
|
3064
|
+
bottom: .16,
|
|
3065
|
+
left: .22
|
|
2954
3066
|
}
|
|
2955
3067
|
},
|
|
2956
3068
|
{
|
|
2957
3069
|
key: "arrow-right-fat",
|
|
2958
3070
|
type: "polygon",
|
|
2959
|
-
width:
|
|
3071
|
+
width: W,
|
|
2960
3072
|
height: 130,
|
|
2961
3073
|
points: [
|
|
2962
3074
|
{
|
|
@@ -2999,7 +3111,7 @@ var Xe = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
|
|
|
2999
3111
|
key: "arrow-up-fat",
|
|
3000
3112
|
type: "polygon",
|
|
3001
3113
|
width: 130,
|
|
3002
|
-
height:
|
|
3114
|
+
height: W,
|
|
3003
3115
|
points: [
|
|
3004
3116
|
{
|
|
3005
3117
|
x: 38,
|
|
@@ -3040,50 +3152,140 @@ var Xe = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
|
|
|
3040
3152
|
{
|
|
3041
3153
|
key: "arrow-right",
|
|
3042
3154
|
type: "polygon",
|
|
3043
|
-
|
|
3044
|
-
|
|
3155
|
+
...G({
|
|
3156
|
+
width: 36,
|
|
3157
|
+
height: 28
|
|
3158
|
+
}),
|
|
3045
3159
|
points: [
|
|
3160
|
+
{
|
|
3161
|
+
x: 100,
|
|
3162
|
+
y: 50
|
|
3163
|
+
},
|
|
3164
|
+
{
|
|
3165
|
+
x: 61.1111,
|
|
3166
|
+
y: 100
|
|
3167
|
+
},
|
|
3168
|
+
{
|
|
3169
|
+
x: 61.1111,
|
|
3170
|
+
y: 71.4286
|
|
3171
|
+
},
|
|
3046
3172
|
{
|
|
3047
3173
|
x: 0,
|
|
3048
|
-
y:
|
|
3174
|
+
y: 71.4286
|
|
3049
3175
|
},
|
|
3050
3176
|
{
|
|
3051
|
-
x:
|
|
3052
|
-
y:
|
|
3177
|
+
x: 0,
|
|
3178
|
+
y: 28.5714
|
|
3179
|
+
},
|
|
3180
|
+
{
|
|
3181
|
+
x: 61.1111,
|
|
3182
|
+
y: 28.5714
|
|
3183
|
+
},
|
|
3184
|
+
{
|
|
3185
|
+
x: 61.1111,
|
|
3186
|
+
y: 0
|
|
3187
|
+
}
|
|
3188
|
+
],
|
|
3189
|
+
internalTextInset: {
|
|
3190
|
+
top: .2,
|
|
3191
|
+
right: .38,
|
|
3192
|
+
bottom: .2,
|
|
3193
|
+
left: .1
|
|
3194
|
+
}
|
|
3195
|
+
},
|
|
3196
|
+
{
|
|
3197
|
+
key: "arrow-left",
|
|
3198
|
+
type: "polygon",
|
|
3199
|
+
...G({
|
|
3200
|
+
width: 36,
|
|
3201
|
+
height: 28
|
|
3202
|
+
}),
|
|
3203
|
+
points: [
|
|
3204
|
+
{
|
|
3205
|
+
x: 38.8889,
|
|
3206
|
+
y: 28.5714
|
|
3053
3207
|
},
|
|
3054
3208
|
{
|
|
3055
|
-
x:
|
|
3056
|
-
y:
|
|
3209
|
+
x: 100,
|
|
3210
|
+
y: 28.5714
|
|
3057
3211
|
},
|
|
3058
3212
|
{
|
|
3059
3213
|
x: 100,
|
|
3214
|
+
y: 71.4286
|
|
3215
|
+
},
|
|
3216
|
+
{
|
|
3217
|
+
x: 38.8889,
|
|
3218
|
+
y: 71.4286
|
|
3219
|
+
},
|
|
3220
|
+
{
|
|
3221
|
+
x: 38.8889,
|
|
3222
|
+
y: 100
|
|
3223
|
+
},
|
|
3224
|
+
{
|
|
3225
|
+
x: 0,
|
|
3060
3226
|
y: 50
|
|
3061
3227
|
},
|
|
3062
3228
|
{
|
|
3063
|
-
x:
|
|
3064
|
-
y:
|
|
3229
|
+
x: 38.8889,
|
|
3230
|
+
y: 0
|
|
3231
|
+
}
|
|
3232
|
+
],
|
|
3233
|
+
internalTextInset: {
|
|
3234
|
+
top: .2,
|
|
3235
|
+
right: .1,
|
|
3236
|
+
bottom: .2,
|
|
3237
|
+
left: .38
|
|
3238
|
+
}
|
|
3239
|
+
},
|
|
3240
|
+
{
|
|
3241
|
+
key: "arrow-up",
|
|
3242
|
+
type: "polygon",
|
|
3243
|
+
...G({
|
|
3244
|
+
width: 28,
|
|
3245
|
+
height: 36
|
|
3246
|
+
}),
|
|
3247
|
+
points: [
|
|
3248
|
+
{
|
|
3249
|
+
x: 71.4286,
|
|
3250
|
+
y: 100
|
|
3065
3251
|
},
|
|
3066
3252
|
{
|
|
3067
|
-
x:
|
|
3068
|
-
y:
|
|
3253
|
+
x: 28.5714,
|
|
3254
|
+
y: 100
|
|
3255
|
+
},
|
|
3256
|
+
{
|
|
3257
|
+
x: 28.5714,
|
|
3258
|
+
y: 38.8889
|
|
3069
3259
|
},
|
|
3070
3260
|
{
|
|
3071
3261
|
x: 0,
|
|
3072
|
-
y:
|
|
3262
|
+
y: 38.8889
|
|
3263
|
+
},
|
|
3264
|
+
{
|
|
3265
|
+
x: 50,
|
|
3266
|
+
y: 0
|
|
3267
|
+
},
|
|
3268
|
+
{
|
|
3269
|
+
x: 100,
|
|
3270
|
+
y: 38.8889
|
|
3271
|
+
},
|
|
3272
|
+
{
|
|
3273
|
+
x: 71.4286,
|
|
3274
|
+
y: 38.8889
|
|
3073
3275
|
}
|
|
3074
3276
|
],
|
|
3075
3277
|
internalTextInset: {
|
|
3076
|
-
top: .
|
|
3077
|
-
right: .
|
|
3078
|
-
bottom: .
|
|
3079
|
-
left: .
|
|
3278
|
+
top: .38,
|
|
3279
|
+
right: .2,
|
|
3280
|
+
bottom: .1,
|
|
3281
|
+
left: .2
|
|
3080
3282
|
}
|
|
3081
3283
|
},
|
|
3082
3284
|
{
|
|
3083
3285
|
key: "arrow-down-fat",
|
|
3084
3286
|
type: "polygon",
|
|
3085
3287
|
width: 130,
|
|
3086
|
-
height:
|
|
3288
|
+
height: W,
|
|
3087
3289
|
points: [
|
|
3088
3290
|
{
|
|
3089
3291
|
x: 38,
|
|
@@ -3121,194 +3323,316 @@ var Xe = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
|
|
|
3121
3323
|
left: .24
|
|
3122
3324
|
}
|
|
3123
3325
|
},
|
|
3326
|
+
{
|
|
3327
|
+
key: "arrow-down",
|
|
3328
|
+
type: "polygon",
|
|
3329
|
+
...G({
|
|
3330
|
+
width: 28,
|
|
3331
|
+
height: 36
|
|
3332
|
+
}),
|
|
3333
|
+
points: [
|
|
3334
|
+
{
|
|
3335
|
+
x: 0,
|
|
3336
|
+
y: 61.1111
|
|
3337
|
+
},
|
|
3338
|
+
{
|
|
3339
|
+
x: 28.5714,
|
|
3340
|
+
y: 61.1111
|
|
3341
|
+
},
|
|
3342
|
+
{
|
|
3343
|
+
x: 28.5714,
|
|
3344
|
+
y: 0
|
|
3345
|
+
},
|
|
3346
|
+
{
|
|
3347
|
+
x: 71.4286,
|
|
3348
|
+
y: 0
|
|
3349
|
+
},
|
|
3350
|
+
{
|
|
3351
|
+
x: 71.4286,
|
|
3352
|
+
y: 61.1111
|
|
3353
|
+
},
|
|
3354
|
+
{
|
|
3355
|
+
x: 100,
|
|
3356
|
+
y: 61.1111
|
|
3357
|
+
},
|
|
3358
|
+
{
|
|
3359
|
+
x: 50,
|
|
3360
|
+
y: 100
|
|
3361
|
+
}
|
|
3362
|
+
],
|
|
3363
|
+
internalTextInset: {
|
|
3364
|
+
top: .1,
|
|
3365
|
+
right: .2,
|
|
3366
|
+
bottom: .38,
|
|
3367
|
+
left: .2
|
|
3368
|
+
}
|
|
3369
|
+
},
|
|
3124
3370
|
{
|
|
3125
3371
|
key: "arrow-up-down",
|
|
3126
3372
|
type: "polygon",
|
|
3127
|
-
|
|
3128
|
-
|
|
3373
|
+
...G({
|
|
3374
|
+
width: 20,
|
|
3375
|
+
height: 38
|
|
3376
|
+
}),
|
|
3129
3377
|
points: [
|
|
3378
|
+
{
|
|
3379
|
+
x: 70,
|
|
3380
|
+
y: 73.6842
|
|
3381
|
+
},
|
|
3382
|
+
{
|
|
3383
|
+
x: 100,
|
|
3384
|
+
y: 73.6842
|
|
3385
|
+
},
|
|
3130
3386
|
{
|
|
3131
3387
|
x: 50,
|
|
3132
|
-
y:
|
|
3388
|
+
y: 100
|
|
3133
3389
|
},
|
|
3134
3390
|
{
|
|
3135
|
-
x:
|
|
3136
|
-
y:
|
|
3391
|
+
x: 0,
|
|
3392
|
+
y: 73.6842
|
|
3137
3393
|
},
|
|
3138
3394
|
{
|
|
3139
|
-
x:
|
|
3140
|
-
y:
|
|
3395
|
+
x: 30,
|
|
3396
|
+
y: 73.6842
|
|
3141
3397
|
},
|
|
3142
3398
|
{
|
|
3143
|
-
x:
|
|
3144
|
-
y:
|
|
3399
|
+
x: 30,
|
|
3400
|
+
y: 26.3158
|
|
3145
3401
|
},
|
|
3146
3402
|
{
|
|
3147
|
-
x:
|
|
3148
|
-
y:
|
|
3403
|
+
x: 0,
|
|
3404
|
+
y: 26.3158
|
|
3149
3405
|
},
|
|
3150
3406
|
{
|
|
3151
3407
|
x: 50,
|
|
3408
|
+
y: 0
|
|
3409
|
+
},
|
|
3410
|
+
{
|
|
3411
|
+
x: 100,
|
|
3412
|
+
y: 26.3158
|
|
3413
|
+
},
|
|
3414
|
+
{
|
|
3415
|
+
x: 70,
|
|
3416
|
+
y: 26.3158
|
|
3417
|
+
}
|
|
3418
|
+
],
|
|
3419
|
+
internalTextInset: {
|
|
3420
|
+
top: .34,
|
|
3421
|
+
right: .2,
|
|
3422
|
+
bottom: .34,
|
|
3423
|
+
left: .2
|
|
3424
|
+
}
|
|
3425
|
+
},
|
|
3426
|
+
{
|
|
3427
|
+
key: "arrow-left-right",
|
|
3428
|
+
type: "polygon",
|
|
3429
|
+
...G({
|
|
3430
|
+
width: 38,
|
|
3431
|
+
height: 20
|
|
3432
|
+
}),
|
|
3433
|
+
points: [
|
|
3434
|
+
{
|
|
3435
|
+
x: 100,
|
|
3436
|
+
y: 50
|
|
3437
|
+
},
|
|
3438
|
+
{
|
|
3439
|
+
x: 73.6842,
|
|
3152
3440
|
y: 100
|
|
3153
3441
|
},
|
|
3154
3442
|
{
|
|
3155
|
-
x:
|
|
3156
|
-
y:
|
|
3443
|
+
x: 73.6842,
|
|
3444
|
+
y: 70
|
|
3157
3445
|
},
|
|
3158
3446
|
{
|
|
3159
|
-
x:
|
|
3160
|
-
y:
|
|
3447
|
+
x: 26.3158,
|
|
3448
|
+
y: 70
|
|
3449
|
+
},
|
|
3450
|
+
{
|
|
3451
|
+
x: 26.3158,
|
|
3452
|
+
y: 100
|
|
3453
|
+
},
|
|
3454
|
+
{
|
|
3455
|
+
x: 0,
|
|
3456
|
+
y: 50
|
|
3457
|
+
},
|
|
3458
|
+
{
|
|
3459
|
+
x: 26.3158,
|
|
3460
|
+
y: 0
|
|
3461
|
+
},
|
|
3462
|
+
{
|
|
3463
|
+
x: 26.3158,
|
|
3464
|
+
y: 30
|
|
3161
3465
|
},
|
|
3162
3466
|
{
|
|
3163
|
-
x:
|
|
3164
|
-
y:
|
|
3467
|
+
x: 73.6842,
|
|
3468
|
+
y: 30
|
|
3165
3469
|
},
|
|
3166
3470
|
{
|
|
3167
|
-
x:
|
|
3168
|
-
y:
|
|
3471
|
+
x: 73.6842,
|
|
3472
|
+
y: 0
|
|
3169
3473
|
}
|
|
3170
3474
|
],
|
|
3171
3475
|
internalTextInset: {
|
|
3172
|
-
top: .
|
|
3173
|
-
right: .
|
|
3174
|
-
bottom: .
|
|
3175
|
-
left: .
|
|
3476
|
+
top: .2,
|
|
3477
|
+
right: .32,
|
|
3478
|
+
bottom: .2,
|
|
3479
|
+
left: .32
|
|
3176
3480
|
}
|
|
3177
3481
|
},
|
|
3178
3482
|
{
|
|
3179
|
-
key: "
|
|
3483
|
+
key: "banner",
|
|
3180
3484
|
type: "polygon",
|
|
3181
|
-
|
|
3182
|
-
|
|
3485
|
+
...G({
|
|
3486
|
+
width: 36,
|
|
3487
|
+
height: 24
|
|
3488
|
+
}),
|
|
3183
3489
|
points: [
|
|
3184
3490
|
{
|
|
3185
3491
|
x: 0,
|
|
3186
|
-
y:
|
|
3187
|
-
},
|
|
3188
|
-
{
|
|
3189
|
-
x: 30,
|
|
3190
|
-
y: 18
|
|
3191
|
-
},
|
|
3192
|
-
{
|
|
3193
|
-
x: 30,
|
|
3194
|
-
y: 38
|
|
3492
|
+
y: 100
|
|
3195
3493
|
},
|
|
3196
3494
|
{
|
|
3197
|
-
x:
|
|
3198
|
-
y:
|
|
3495
|
+
x: 0,
|
|
3496
|
+
y: 0
|
|
3199
3497
|
},
|
|
3200
3498
|
{
|
|
3201
|
-
x:
|
|
3202
|
-
y:
|
|
3499
|
+
x: 77.7778,
|
|
3500
|
+
y: 0
|
|
3203
3501
|
},
|
|
3204
3502
|
{
|
|
3205
3503
|
x: 100,
|
|
3206
3504
|
y: 50
|
|
3207
3505
|
},
|
|
3208
3506
|
{
|
|
3209
|
-
x:
|
|
3210
|
-
y:
|
|
3211
|
-
},
|
|
3212
|
-
{
|
|
3213
|
-
x: 70,
|
|
3214
|
-
y: 62
|
|
3215
|
-
},
|
|
3216
|
-
{
|
|
3217
|
-
x: 30,
|
|
3218
|
-
y: 62
|
|
3219
|
-
},
|
|
3220
|
-
{
|
|
3221
|
-
x: 30,
|
|
3222
|
-
y: 82
|
|
3507
|
+
x: 77.7778,
|
|
3508
|
+
y: 100
|
|
3223
3509
|
}
|
|
3224
3510
|
],
|
|
3225
3511
|
internalTextInset: {
|
|
3226
|
-
top: .
|
|
3227
|
-
right: .
|
|
3228
|
-
bottom: .
|
|
3229
|
-
left: .
|
|
3512
|
+
top: .14,
|
|
3513
|
+
right: .26,
|
|
3514
|
+
bottom: .14,
|
|
3515
|
+
left: .12
|
|
3230
3516
|
}
|
|
3231
3517
|
},
|
|
3232
3518
|
{
|
|
3233
3519
|
key: "drop",
|
|
3234
3520
|
type: "path",
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3521
|
+
...G({
|
|
3522
|
+
width: 26,
|
|
3523
|
+
height: 36
|
|
3524
|
+
}),
|
|
3525
|
+
path: "M0 23C0 11 13 0 13 0s13 11 13 23c0 7.18-5.82 13-13 13S0 30.18 0 23",
|
|
3238
3526
|
internalTextInset: {
|
|
3239
|
-
top: .
|
|
3240
|
-
right: .
|
|
3241
|
-
bottom: .
|
|
3242
|
-
left: .
|
|
3527
|
+
top: .28,
|
|
3528
|
+
right: .26,
|
|
3529
|
+
bottom: .18,
|
|
3530
|
+
left: .26
|
|
3243
3531
|
}
|
|
3244
3532
|
},
|
|
3245
3533
|
{
|
|
3246
3534
|
key: "cross",
|
|
3247
3535
|
type: "polygon",
|
|
3248
|
-
width:
|
|
3249
|
-
height:
|
|
3536
|
+
width: W,
|
|
3537
|
+
height: W,
|
|
3250
3538
|
points: [
|
|
3251
3539
|
{
|
|
3252
|
-
x:
|
|
3253
|
-
y:
|
|
3254
|
-
},
|
|
3255
|
-
{
|
|
3256
|
-
x: 64,
|
|
3257
|
-
y: 0
|
|
3258
|
-
},
|
|
3259
|
-
{
|
|
3260
|
-
x: 64,
|
|
3261
|
-
y: 36
|
|
3540
|
+
x: 67.6471,
|
|
3541
|
+
y: 32.3529
|
|
3262
3542
|
},
|
|
3263
3543
|
{
|
|
3264
3544
|
x: 100,
|
|
3265
|
-
y:
|
|
3545
|
+
y: 32.3529
|
|
3266
3546
|
},
|
|
3267
3547
|
{
|
|
3268
3548
|
x: 100,
|
|
3269
|
-
y:
|
|
3549
|
+
y: 67.6471
|
|
3270
3550
|
},
|
|
3271
3551
|
{
|
|
3272
|
-
x:
|
|
3273
|
-
y:
|
|
3552
|
+
x: 67.6471,
|
|
3553
|
+
y: 67.6471
|
|
3274
3554
|
},
|
|
3275
3555
|
{
|
|
3276
|
-
x:
|
|
3556
|
+
x: 67.6471,
|
|
3277
3557
|
y: 100
|
|
3278
3558
|
},
|
|
3279
3559
|
{
|
|
3280
|
-
x:
|
|
3560
|
+
x: 32.3529,
|
|
3281
3561
|
y: 100
|
|
3282
3562
|
},
|
|
3283
3563
|
{
|
|
3284
|
-
x:
|
|
3285
|
-
y:
|
|
3564
|
+
x: 32.3529,
|
|
3565
|
+
y: 67.6471
|
|
3286
3566
|
},
|
|
3287
3567
|
{
|
|
3288
3568
|
x: 0,
|
|
3289
|
-
y:
|
|
3569
|
+
y: 67.6471
|
|
3290
3570
|
},
|
|
3291
3571
|
{
|
|
3292
3572
|
x: 0,
|
|
3293
|
-
y:
|
|
3573
|
+
y: 32.3529
|
|
3574
|
+
},
|
|
3575
|
+
{
|
|
3576
|
+
x: 32.3529,
|
|
3577
|
+
y: 32.3529
|
|
3578
|
+
},
|
|
3579
|
+
{
|
|
3580
|
+
x: 32.3529,
|
|
3581
|
+
y: 0
|
|
3294
3582
|
},
|
|
3295
3583
|
{
|
|
3296
|
-
x:
|
|
3297
|
-
y:
|
|
3584
|
+
x: 67.6471,
|
|
3585
|
+
y: 0
|
|
3298
3586
|
}
|
|
3299
3587
|
],
|
|
3300
3588
|
internalTextInset: {
|
|
3301
|
-
top: .
|
|
3302
|
-
right: .
|
|
3303
|
-
bottom: .
|
|
3304
|
-
left: .
|
|
3589
|
+
top: .32,
|
|
3590
|
+
right: .32,
|
|
3591
|
+
bottom: .32,
|
|
3592
|
+
left: .32
|
|
3593
|
+
}
|
|
3594
|
+
},
|
|
3595
|
+
{
|
|
3596
|
+
key: "ribbon",
|
|
3597
|
+
type: "polygon",
|
|
3598
|
+
...G({
|
|
3599
|
+
width: 24,
|
|
3600
|
+
height: 34
|
|
3601
|
+
}),
|
|
3602
|
+
points: [
|
|
3603
|
+
{
|
|
3604
|
+
x: 0,
|
|
3605
|
+
y: 0
|
|
3606
|
+
},
|
|
3607
|
+
{
|
|
3608
|
+
x: 100,
|
|
3609
|
+
y: 0
|
|
3610
|
+
},
|
|
3611
|
+
{
|
|
3612
|
+
x: 100,
|
|
3613
|
+
y: 100
|
|
3614
|
+
},
|
|
3615
|
+
{
|
|
3616
|
+
x: 50,
|
|
3617
|
+
y: 76.4706
|
|
3618
|
+
},
|
|
3619
|
+
{
|
|
3620
|
+
x: 0,
|
|
3621
|
+
y: 100
|
|
3622
|
+
}
|
|
3623
|
+
],
|
|
3624
|
+
internalTextInset: {
|
|
3625
|
+
top: .16,
|
|
3626
|
+
right: .18,
|
|
3627
|
+
bottom: .28,
|
|
3628
|
+
left: .18
|
|
3305
3629
|
}
|
|
3306
3630
|
},
|
|
3307
3631
|
{
|
|
3308
3632
|
key: "gear",
|
|
3309
3633
|
type: "polygon",
|
|
3310
|
-
width:
|
|
3311
|
-
height:
|
|
3634
|
+
width: W,
|
|
3635
|
+
height: W,
|
|
3312
3636
|
points: it({
|
|
3313
3637
|
spikes: 14,
|
|
3314
3638
|
outerRadius: 50,
|
|
@@ -3325,8 +3649,8 @@ var Xe = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
|
|
|
3325
3649
|
{
|
|
3326
3650
|
key: "badge",
|
|
3327
3651
|
type: "path",
|
|
3328
|
-
width:
|
|
3329
|
-
height:
|
|
3652
|
+
width: W,
|
|
3653
|
+
height: W,
|
|
3330
3654
|
path: "M24 6 H76 L94 24 V76 L76 94 H24 L6 76 V24 Z",
|
|
3331
3655
|
internalTextInset: {
|
|
3332
3656
|
top: .24,
|
|
@@ -3339,7 +3663,7 @@ var Xe = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
|
|
|
3339
3663
|
key: "bookmark",
|
|
3340
3664
|
type: "polygon",
|
|
3341
3665
|
width: 130,
|
|
3342
|
-
height:
|
|
3666
|
+
height: W,
|
|
3343
3667
|
points: [
|
|
3344
3668
|
{
|
|
3345
3669
|
x: 18,
|
|
@@ -3372,7 +3696,7 @@ var Xe = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
|
|
|
3372
3696
|
{
|
|
3373
3697
|
key: "tag",
|
|
3374
3698
|
type: "path",
|
|
3375
|
-
width:
|
|
3699
|
+
width: W,
|
|
3376
3700
|
height: 130,
|
|
3377
3701
|
path: "M4 20 L64 20 L96 50 L64 80 L4 80 Z",
|
|
3378
3702
|
internalTextInset: {
|
|
@@ -3386,7 +3710,7 @@ var Xe = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
|
|
|
3386
3710
|
key: "moon",
|
|
3387
3711
|
type: "path",
|
|
3388
3712
|
width: 150,
|
|
3389
|
-
height:
|
|
3713
|
+
height: W,
|
|
3390
3714
|
path: [
|
|
3391
3715
|
"M68 4 C36 4 10 30 10 62",
|
|
3392
3716
|
"C10 94 36 120 68 120 C85 120 100 112 111 100",
|
|
@@ -3407,26 +3731,26 @@ for (let e = 0; e < at.length; e += 1) {
|
|
|
3407
3731
|
}
|
|
3408
3732
|
var ut = lt, dt = ({ presetKey: e }) => ut[e] ?? null, ft = ({ preset: e, rounding: t }) => (typeof t == "number" ? t : 0) <= 0 || e.type === "rect" ? e.key : e.roundedVariant ?? e.key;
|
|
3409
3733
|
function pt({ value: e, size: t }) {
|
|
3410
|
-
let n = Number.isFinite(e) ? Math.min(Math.max(e, 0),
|
|
3734
|
+
let n = Number.isFinite(e) ? Math.min(Math.max(e, 0), nt) : 0;
|
|
3411
3735
|
return (Number.isFinite(t) && t > 0 ? t : 0) * n;
|
|
3412
3736
|
}
|
|
3413
3737
|
var mt = ({ preset: e, width: t, height: n }) => {
|
|
3414
3738
|
let r = e.internalTextInset ?? {};
|
|
3415
3739
|
return {
|
|
3416
3740
|
top: pt({
|
|
3417
|
-
value: r.top ??
|
|
3741
|
+
value: r.top ?? tt.top,
|
|
3418
3742
|
size: n
|
|
3419
3743
|
}),
|
|
3420
3744
|
right: pt({
|
|
3421
|
-
value: r.right ??
|
|
3745
|
+
value: r.right ?? tt.right,
|
|
3422
3746
|
size: t
|
|
3423
3747
|
}),
|
|
3424
3748
|
bottom: pt({
|
|
3425
|
-
value: r.bottom ??
|
|
3749
|
+
value: r.bottom ?? tt.bottom,
|
|
3426
3750
|
size: n
|
|
3427
3751
|
}),
|
|
3428
3752
|
left: pt({
|
|
3429
|
-
value: r.left ??
|
|
3753
|
+
value: r.left ?? tt.left,
|
|
3430
3754
|
size: t
|
|
3431
3755
|
})
|
|
3432
3756
|
};
|
|
@@ -4816,7 +5140,7 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4816
5140
|
width: D,
|
|
4817
5141
|
height: O
|
|
4818
5142
|
})
|
|
4819
|
-
}), f.set({
|
|
5143
|
+
}), r.shapeReplaceBoxWidth = Math.max(1, r.shapeBaseWidth ?? D), r.shapeReplaceBoxHeight = Math.max(1, r.shapeBaseHeight ?? O), f.set({
|
|
4820
5144
|
scaleX: 1,
|
|
4821
5145
|
scaleY: 1
|
|
4822
5146
|
}), r.set({
|
|
@@ -5085,7 +5409,7 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5085
5409
|
width: u,
|
|
5086
5410
|
height: d
|
|
5087
5411
|
})
|
|
5088
|
-
}), t.set({
|
|
5412
|
+
}), t.shapeReplaceBoxWidth = Math.max(1, t.shapeBaseWidth ?? u), t.shapeReplaceBoxHeight = Math.max(1, t.shapeBaseHeight ?? d), t.set({
|
|
5089
5413
|
left: i.lastAllowedLeft,
|
|
5090
5414
|
top: i.lastAllowedTop,
|
|
5091
5415
|
flipX: i.lastAllowedFlipX,
|
|
@@ -5232,44 +5556,268 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5232
5556
|
lockMovementY: n.textLockMovementY
|
|
5233
5557
|
}), this.editingInteractionState.delete(e), e.setCoords(), t.setCoords());
|
|
5234
5558
|
}
|
|
5235
|
-
}, ar =
|
|
5559
|
+
}, ar = class e {
|
|
5560
|
+
constructor({ canvas: e }) {
|
|
5561
|
+
this.canvas = e, this.textEditingSnapshots = /* @__PURE__ */ new WeakMap(), this.pendingTextUpdates = /* @__PURE__ */ new WeakMap(), this.resizeStartSnapshots = /* @__PURE__ */ new Map(), this.pendingResizeUpdates = /* @__PURE__ */ new WeakMap();
|
|
5562
|
+
}
|
|
5563
|
+
createContext({ group: t, source: n, target: r, presetKey: i, options: a, withoutSave: o }) {
|
|
5564
|
+
return this._createContextFromBefore({
|
|
5565
|
+
group: t,
|
|
5566
|
+
before: e.getSnapshot({ group: t }),
|
|
5567
|
+
source: n,
|
|
5568
|
+
target: r,
|
|
5569
|
+
presetKey: i,
|
|
5570
|
+
options: a,
|
|
5571
|
+
withoutSave: o
|
|
5572
|
+
});
|
|
5573
|
+
}
|
|
5574
|
+
fireBefore({ lifecycle: e }) {
|
|
5575
|
+
this.canvas.fire("editor:before:shape-updated", e.payload);
|
|
5576
|
+
}
|
|
5577
|
+
fireUpdated({ lifecycle: t, after: n }) {
|
|
5578
|
+
let r = n ?? e.getSnapshot({ group: t.payload.shape }), i = {
|
|
5579
|
+
...t.payload,
|
|
5580
|
+
before: t.before,
|
|
5581
|
+
after: r
|
|
5582
|
+
};
|
|
5583
|
+
return this.canvas.fire("editor:shape-updated", i), r;
|
|
5584
|
+
}
|
|
5585
|
+
beginTextEditing({ group: t }) {
|
|
5586
|
+
this.textEditingSnapshots.set(t, e.getSnapshot({ group: t }));
|
|
5587
|
+
}
|
|
5588
|
+
finishTextEditing({ group: t, textNode: n }) {
|
|
5589
|
+
let r = this.textEditingSnapshots.get(t);
|
|
5590
|
+
if (this.textEditingSnapshots.delete(t), !r) return null;
|
|
5591
|
+
let i = e.getSnapshot({ group: t });
|
|
5592
|
+
if (e.areSnapshotsEqual({
|
|
5593
|
+
before: r,
|
|
5594
|
+
after: i
|
|
5595
|
+
})) return null;
|
|
5596
|
+
let a = this._createContextFromBefore({
|
|
5597
|
+
group: t,
|
|
5598
|
+
before: r,
|
|
5599
|
+
source: "text-edit",
|
|
5600
|
+
target: n
|
|
5601
|
+
});
|
|
5602
|
+
return this.fireBefore({ lifecycle: a }), this.fireUpdated({
|
|
5603
|
+
lifecycle: a,
|
|
5604
|
+
after: i
|
|
5605
|
+
});
|
|
5606
|
+
}
|
|
5607
|
+
beginTextUpdate({ group: e, textNode: t, withoutSave: n }) {
|
|
5608
|
+
let r = this.createContext({
|
|
5609
|
+
group: e,
|
|
5610
|
+
source: "text-update",
|
|
5611
|
+
target: t,
|
|
5612
|
+
withoutSave: n
|
|
5613
|
+
});
|
|
5614
|
+
return this.pendingTextUpdates.set(t, r), r;
|
|
5615
|
+
}
|
|
5616
|
+
cancelTextUpdate({ textNode: e }) {
|
|
5617
|
+
this.pendingTextUpdates.delete(e);
|
|
5618
|
+
}
|
|
5619
|
+
finishTextUpdate({ textNode: e }) {
|
|
5620
|
+
let t = this.pendingTextUpdates.get(e);
|
|
5621
|
+
if (!t) return null;
|
|
5622
|
+
this.pendingTextUpdates.delete(e);
|
|
5623
|
+
let n = this.fireUpdated({ lifecycle: t }), { group: r } = e;
|
|
5624
|
+
return J(r) && this.textEditingSnapshots.has(r) && this.textEditingSnapshots.set(r, n), n;
|
|
5625
|
+
}
|
|
5626
|
+
captureResizeStart({ group: t }) {
|
|
5627
|
+
this.resizeStartSnapshots.has(t) || this.resizeStartSnapshots.set(t, e.getSnapshot({ group: t }));
|
|
5628
|
+
}
|
|
5629
|
+
beginResize({ group: t }) {
|
|
5630
|
+
if (this.pendingResizeUpdates.has(t)) return;
|
|
5631
|
+
let n = this.resizeStartSnapshots.get(t) ?? e.getSnapshot({ group: t });
|
|
5632
|
+
this.resizeStartSnapshots.delete(t), this.pendingResizeUpdates.set(t, this._createContextFromBefore({
|
|
5633
|
+
group: t,
|
|
5634
|
+
before: n,
|
|
5635
|
+
source: "resize",
|
|
5636
|
+
target: t
|
|
5637
|
+
}));
|
|
5638
|
+
}
|
|
5639
|
+
clearResizeStarts() {
|
|
5640
|
+
this.resizeStartSnapshots.clear();
|
|
5641
|
+
}
|
|
5642
|
+
finishResize({ group: t }) {
|
|
5643
|
+
let n = this.pendingResizeUpdates.get(t);
|
|
5644
|
+
if (!n) return null;
|
|
5645
|
+
this.pendingResizeUpdates.delete(t);
|
|
5646
|
+
let r = e.getSnapshot({ group: t });
|
|
5647
|
+
return e.areSnapshotsEqual({
|
|
5648
|
+
before: n.before,
|
|
5649
|
+
after: r
|
|
5650
|
+
}) ? null : (this.fireBefore({ lifecycle: n }), this.fireUpdated({
|
|
5651
|
+
lifecycle: n,
|
|
5652
|
+
after: r
|
|
5653
|
+
}));
|
|
5654
|
+
}
|
|
5655
|
+
static getSnapshot({ group: t }) {
|
|
5656
|
+
let { id: n, shapePresetKey: r, shapeBaseWidth: i, shapeBaseHeight: a, shapeManualBaseWidth: o, shapeManualBaseHeight: s, shapeTextAutoExpand: c, shapeAlignHorizontal: l, shapeAlignVertical: u, shapePaddingTop: d, shapePaddingRight: f, shapePaddingBottom: p, shapePaddingLeft: m, shapeFill: h, shapeStroke: g, shapeStrokeWidth: _, shapeStrokeDashArray: v, shapeOpacity: y, shapeRounding: b, left: x, top: S, originX: C, originY: w, angle: T, flipX: E, flipY: D, scaleX: O, scaleY: k } = t, { text: A } = Y({ group: t });
|
|
5657
|
+
return {
|
|
5658
|
+
id: n,
|
|
5659
|
+
presetKey: r,
|
|
5660
|
+
baseWidth: i,
|
|
5661
|
+
baseHeight: a,
|
|
5662
|
+
manualBaseWidth: o,
|
|
5663
|
+
manualBaseHeight: s,
|
|
5664
|
+
currentWidth: Math.max(1, (i ?? t.width ?? 1) * (Math.abs(O ?? 1) || 1)),
|
|
5665
|
+
currentHeight: Math.max(1, (a ?? t.height ?? 1) * (Math.abs(k ?? 1) || 1)),
|
|
5666
|
+
shapeTextAutoExpand: c !== !1,
|
|
5667
|
+
alignH: l ?? "center",
|
|
5668
|
+
alignV: u ?? "middle",
|
|
5669
|
+
padding: {
|
|
5670
|
+
top: d ?? 0,
|
|
5671
|
+
right: f ?? 0,
|
|
5672
|
+
bottom: p ?? 0,
|
|
5673
|
+
left: m ?? 0
|
|
5674
|
+
},
|
|
5675
|
+
fill: h,
|
|
5676
|
+
stroke: g,
|
|
5677
|
+
strokeWidth: _,
|
|
5678
|
+
strokeDashArray: v ? v.slice() : v ?? null,
|
|
5679
|
+
opacity: y,
|
|
5680
|
+
rounding: b,
|
|
5681
|
+
left: x,
|
|
5682
|
+
top: S,
|
|
5683
|
+
originX: C,
|
|
5684
|
+
originY: w,
|
|
5685
|
+
angle: T,
|
|
5686
|
+
flipX: !!E,
|
|
5687
|
+
flipY: !!D,
|
|
5688
|
+
scaleX: O,
|
|
5689
|
+
scaleY: k,
|
|
5690
|
+
text: A ? e._getTextNodeSnapshot({ textNode: A }) : void 0
|
|
5691
|
+
};
|
|
5692
|
+
}
|
|
5693
|
+
static areSnapshotsEqual({ before: e, after: t }) {
|
|
5694
|
+
return JSON.stringify(e) === JSON.stringify(t);
|
|
5695
|
+
}
|
|
5696
|
+
_createContextFromBefore({ group: e, before: t, source: n, target: r, presetKey: i, options: a, withoutSave: o }) {
|
|
5697
|
+
return {
|
|
5698
|
+
before: t,
|
|
5699
|
+
payload: {
|
|
5700
|
+
shape: e,
|
|
5701
|
+
source: n,
|
|
5702
|
+
target: r,
|
|
5703
|
+
presetKey: i,
|
|
5704
|
+
options: a,
|
|
5705
|
+
withoutSave: o
|
|
5706
|
+
}
|
|
5707
|
+
};
|
|
5708
|
+
}
|
|
5709
|
+
static _getTextNodeSnapshot({ textNode: e }) {
|
|
5710
|
+
let t = e, n = ({ snapshot: e, entries: t }) => {
|
|
5711
|
+
Object.entries(t).forEach(([t, n]) => {
|
|
5712
|
+
n != null && (e[t] = n);
|
|
5713
|
+
});
|
|
5714
|
+
}, { id: r, text: i, textCaseRaw: a, uppercase: o, autoExpand: s, fontFamily: c, fontSize: l, fontWeight: u, fontStyle: d, underline: f, linethrough: p, textAlign: m, fill: h, stroke: g, strokeWidth: _, opacity: v, backgroundColor: y, backgroundOpacity: b, paddingTop: x, paddingRight: S, paddingBottom: C, paddingLeft: w, radiusTopLeft: T, radiusTopRight: E, radiusBottomRight: D, radiusBottomLeft: O, left: k, top: A, width: j, height: M, angle: N, scaleX: P, scaleY: F } = t, I = {
|
|
5715
|
+
id: r,
|
|
5716
|
+
uppercase: !!o,
|
|
5717
|
+
textAlign: m
|
|
5718
|
+
};
|
|
5719
|
+
return n({
|
|
5720
|
+
snapshot: I,
|
|
5721
|
+
entries: {
|
|
5722
|
+
text: i,
|
|
5723
|
+
textCaseRaw: a,
|
|
5724
|
+
autoExpand: s,
|
|
5725
|
+
fontFamily: c,
|
|
5726
|
+
fontSize: l,
|
|
5727
|
+
fontWeight: u,
|
|
5728
|
+
fontStyle: d,
|
|
5729
|
+
underline: f,
|
|
5730
|
+
linethrough: p,
|
|
5731
|
+
fill: h,
|
|
5732
|
+
stroke: g,
|
|
5733
|
+
strokeWidth: _,
|
|
5734
|
+
opacity: v,
|
|
5735
|
+
backgroundColor: y,
|
|
5736
|
+
backgroundOpacity: b,
|
|
5737
|
+
paddingTop: x,
|
|
5738
|
+
paddingRight: S,
|
|
5739
|
+
paddingBottom: C,
|
|
5740
|
+
paddingLeft: w,
|
|
5741
|
+
radiusTopLeft: T,
|
|
5742
|
+
radiusTopRight: E,
|
|
5743
|
+
radiusBottomRight: D,
|
|
5744
|
+
radiusBottomLeft: O,
|
|
5745
|
+
left: k,
|
|
5746
|
+
top: A,
|
|
5747
|
+
width: j,
|
|
5748
|
+
height: M,
|
|
5749
|
+
angle: N,
|
|
5750
|
+
scaleX: P,
|
|
5751
|
+
scaleY: F
|
|
5752
|
+
}
|
|
5753
|
+
}), I;
|
|
5754
|
+
}
|
|
5755
|
+
}, or = "#B4B7BD", sr = 0, cr = 1, lr = class {
|
|
5236
5756
|
constructor({ editor: e }) {
|
|
5237
5757
|
this._handleObjectScaling = (e) => {
|
|
5238
|
-
|
|
5758
|
+
let t = e.target && J(e.target) ? e.target : null;
|
|
5759
|
+
t && this.lifecycleController.beginResize({ group: t }), this.scalingController.handleObjectScaling(e);
|
|
5239
5760
|
}, this._handleObjectModified = (e) => {
|
|
5240
5761
|
this.scalingController.handleObjectModified(e);
|
|
5762
|
+
let t = e.target && J(e.target) ? e.target : null;
|
|
5763
|
+
t && this.lifecycleController.finishResize({ group: t });
|
|
5241
5764
|
}, this._handleMouseMove = (e) => {
|
|
5242
5765
|
this.scalingController.handleCanvasMouseMove(e);
|
|
5243
5766
|
}, this._handleMouseDown = (e) => {
|
|
5244
|
-
this.
|
|
5767
|
+
this._collectShapeGroupsFromTarget({
|
|
5768
|
+
target: e.target,
|
|
5769
|
+
subTargets: e.subTargets
|
|
5770
|
+
}).forEach((e) => {
|
|
5771
|
+
this.lifecycleController.captureResizeStart({ group: e });
|
|
5772
|
+
}), this.editingController.handleMouseDown(e);
|
|
5773
|
+
}, this._handleMouseUp = () => {
|
|
5774
|
+
this.lifecycleController.clearResizeStarts();
|
|
5245
5775
|
}, this._handleTextEditingExited = (e) => {
|
|
5246
|
-
let { target:
|
|
5247
|
-
if (
|
|
5248
|
-
let { group:
|
|
5249
|
-
J(
|
|
5776
|
+
let t = null, { target: n } = e;
|
|
5777
|
+
if (n instanceof _) {
|
|
5778
|
+
let e = n, { group: r } = e;
|
|
5779
|
+
J(r) && (this.editingPlacements.delete(r), t = {
|
|
5780
|
+
group: r,
|
|
5781
|
+
textNode: e
|
|
5782
|
+
});
|
|
5250
5783
|
}
|
|
5251
|
-
this.editingController.handleTextEditingExited(e);
|
|
5784
|
+
this.editingController.handleTextEditingExited(e), t && this.lifecycleController.finishTextEditing(t);
|
|
5252
5785
|
}, this._handleTextEditingEntered = (e) => {
|
|
5253
5786
|
let { target: t } = e;
|
|
5254
5787
|
if (t instanceof _) {
|
|
5255
5788
|
let { group: e } = t;
|
|
5256
|
-
J(e) && (this._detachShapeGroupAutoLayout({ group: e }), this.editingPlacements.set(e, this.editor.canvasManager.getObjectPlacement({ object: e })));
|
|
5789
|
+
J(e) && (this._detachShapeGroupAutoLayout({ group: e }), this.lifecycleController.beginTextEditing({ group: e }), this.editingPlacements.set(e, this.editor.canvasManager.getObjectPlacement({ object: e })));
|
|
5257
5790
|
}
|
|
5258
5791
|
this.editingController.handleTextEditingEntered(e);
|
|
5259
5792
|
}, this._handleTextChanged = (e) => {
|
|
5260
5793
|
let { target: t } = e;
|
|
5261
5794
|
if (!(t instanceof _)) return;
|
|
5262
|
-
let n = t;
|
|
5263
|
-
this._syncShapeTextLayoutAfterTextMutation({ textNode: n }) && this.editor.canvas.requestRenderAll();
|
|
5795
|
+
let n = t, { group: r } = n;
|
|
5796
|
+
J(r) && this._syncShapeTextLayoutAfterTextMutation({ textNode: n }) && this.editor.canvas.requestRenderAll();
|
|
5264
5797
|
}, this._handleBeforeTextUpdated = (e) => {
|
|
5265
5798
|
let { textbox: t, style: n } = e;
|
|
5266
5799
|
if (!(t instanceof _)) return;
|
|
5267
|
-
let r = t;
|
|
5268
|
-
this.internalTextUpdates.has(r)
|
|
5800
|
+
let r = t, { group: i } = r;
|
|
5801
|
+
if (!J(i) || this.internalTextUpdates.has(r)) return;
|
|
5802
|
+
let a = this.lifecycleController.beginTextUpdate({
|
|
5803
|
+
group: i,
|
|
5269
5804
|
textNode: r,
|
|
5270
|
-
|
|
5805
|
+
withoutSave: e.options.withoutSave
|
|
5271
5806
|
});
|
|
5272
|
-
|
|
5807
|
+
if (!this._syncShapeTextLayoutAfterTextMutation({
|
|
5808
|
+
textNode: r,
|
|
5809
|
+
textStyle: n
|
|
5810
|
+
})) {
|
|
5811
|
+
this.lifecycleController.cancelTextUpdate({ textNode: r });
|
|
5812
|
+
return;
|
|
5813
|
+
}
|
|
5814
|
+
this.lifecycleController.fireBefore({ lifecycle: a });
|
|
5815
|
+
}, this._handleTextUpdated = (e) => {
|
|
5816
|
+
let { textbox: t } = e;
|
|
5817
|
+
if (!(t instanceof _)) return;
|
|
5818
|
+
let n = t;
|
|
5819
|
+
this.lifecycleController.finishTextUpdate({ textNode: n });
|
|
5820
|
+
}, this.editor = e, zn(), this.scalingController = new rr({ canvas: e.canvas }), this.editingController = new ir({ canvas: e.canvas }), this.editingPlacements = /* @__PURE__ */ new WeakMap(), this.lifecycleController = new ar({ canvas: e.canvas }), this.internalTextUpdates = /* @__PURE__ */ new WeakSet(), this._bindEvents();
|
|
5273
5821
|
}
|
|
5274
5822
|
async add({ presetKey: e = ot, options: t = {} } = {}) {
|
|
5275
5823
|
let n = dt({ presetKey: e });
|
|
@@ -5330,7 +5878,11 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5330
5878
|
changedPadding: j,
|
|
5331
5879
|
style: E,
|
|
5332
5880
|
rounding: h
|
|
5333
|
-
})
|
|
5881
|
+
}), I = {
|
|
5882
|
+
shape: F,
|
|
5883
|
+
presetKey: b.key,
|
|
5884
|
+
options: t
|
|
5885
|
+
};
|
|
5334
5886
|
if (o === void 0 && s === void 0) this.editor.canvasManager.centerObjectToMontageArea({ object: F });
|
|
5335
5887
|
else {
|
|
5336
5888
|
let e = this.editor.canvasManager.resolveObjectPlacement({
|
|
@@ -5346,51 +5898,69 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5346
5898
|
placement: e
|
|
5347
5899
|
});
|
|
5348
5900
|
}
|
|
5349
|
-
if (g) return F;
|
|
5901
|
+
if (g) return this.editor.canvas.fire("editor:shape-added", I), F;
|
|
5350
5902
|
this._beginMutation();
|
|
5351
5903
|
try {
|
|
5352
5904
|
this.editor.canvas.add(F), _ || this.editor.canvas.setActiveObject(F), this.editor.canvas.requestRenderAll();
|
|
5353
5905
|
} finally {
|
|
5354
5906
|
this._endMutation({ withoutSave: v });
|
|
5355
5907
|
}
|
|
5356
|
-
return F;
|
|
5908
|
+
return this.editor.canvas.fire("editor:shape-added", I), F;
|
|
5357
5909
|
}
|
|
5358
5910
|
async update({ target: e, presetKey: t, options: n = {} } = {}) {
|
|
5359
5911
|
let r = this._resolveShapeGroup({ target: e });
|
|
5360
5912
|
if (!r) return null;
|
|
5361
5913
|
let i = dt({ presetKey: t ?? r.shapePresetKey ?? "circle" });
|
|
5362
5914
|
if (!i) return null;
|
|
5363
|
-
let { left: a, top: o, originX: s, originY: c, width: l, height: u,
|
|
5915
|
+
let { left: a, top: o, originX: s, originY: c, width: l, height: u, preserveCurrentAspectRatio: d, shapeTextAutoExpand: f, text: p, textStyle: m, alignH: h, alignV: g, textPadding: _, rounding: v, withoutSelection: y, withoutSave: b } = n, x = this.editor.canvasManager.resolveObjectPlacement({
|
|
5364
5916
|
object: r,
|
|
5365
5917
|
left: a,
|
|
5366
5918
|
top: o,
|
|
5367
5919
|
originX: s,
|
|
5368
5920
|
originY: c
|
|
5369
|
-
}),
|
|
5921
|
+
}), S = this._resolveCurrentDimensions({ group: r }), C = this._resolveManualDimensions({ group: r }), w = this._resolveReplaceBoxDimensions({ group: r }), T = this._isShapeTextAutoExpandEnabled({ group: r }), E = f === void 0 ? T : f !== !1, D = v ?? r.shapeRounding ?? 0, O = dt({ presetKey: ft({
|
|
5370
5922
|
preset: i,
|
|
5371
|
-
rounding:
|
|
5372
|
-
}) }) ?? i,
|
|
5373
|
-
|
|
5374
|
-
|
|
5375
|
-
}
|
|
5923
|
+
rounding: D
|
|
5924
|
+
}) }) ?? i, { width: k, height: A } = O, j = !!d, M = t !== void 0, N = M && !j ? {
|
|
5925
|
+
width: Math.max(1, l ?? w.width),
|
|
5926
|
+
height: Math.max(1, u ?? w.height)
|
|
5927
|
+
} : null, { width: P, height: F } = N ? this._resolveAspectRatioFittedDimensions({
|
|
5928
|
+
targetWidth: N.width,
|
|
5929
|
+
targetHeight: N.height,
|
|
5930
|
+
aspectWidth: k,
|
|
5931
|
+
aspectHeight: A
|
|
5932
|
+
}) : {
|
|
5933
|
+
width: Math.max(1, l ?? S.width),
|
|
5934
|
+
height: Math.max(1, u ?? S.height)
|
|
5935
|
+
}, I = h ?? r.shapeAlignHorizontal ?? "center", ee = g ?? r.shapeAlignVertical ?? "middle", te = this._resolveGroupUserPadding({ group: r }), L = Wt({ padding: _ }), ne = Vt({
|
|
5936
|
+
base: te,
|
|
5937
|
+
override: _
|
|
5938
|
+
}), re = this._resolveShapeStyle({
|
|
5376
5939
|
options: n,
|
|
5377
5940
|
fallback: r
|
|
5378
|
-
}),
|
|
5941
|
+
}), R = Ut({
|
|
5379
5942
|
baseInset: mt({
|
|
5380
|
-
preset:
|
|
5381
|
-
width:
|
|
5382
|
-
height:
|
|
5943
|
+
preset: O,
|
|
5944
|
+
width: P,
|
|
5945
|
+
height: F
|
|
5383
5946
|
}),
|
|
5384
|
-
stroke:
|
|
5385
|
-
strokeWidth:
|
|
5386
|
-
}),
|
|
5387
|
-
base:
|
|
5388
|
-
addition:
|
|
5389
|
-
}),
|
|
5390
|
-
l !== void 0 && (
|
|
5391
|
-
let
|
|
5392
|
-
if (!
|
|
5393
|
-
let
|
|
5947
|
+
stroke: re.stroke,
|
|
5948
|
+
strokeWidth: re.strokeWidth
|
|
5949
|
+
}), ie = Ht({
|
|
5950
|
+
base: R,
|
|
5951
|
+
addition: ne
|
|
5952
|
+
}), z = C.width, B = C.height;
|
|
5953
|
+
M && (z = P, B = F), !M && l !== void 0 && (z = Math.max(1, l)), !M && u !== void 0 && (B = Math.max(1, u)), !M && l === void 0 && T && !E && (z = S.width);
|
|
5954
|
+
let { shape: V, text: H } = Y({ group: r });
|
|
5955
|
+
if (!V || !H) return null;
|
|
5956
|
+
let U = this.lifecycleController.createContext({
|
|
5957
|
+
group: r,
|
|
5958
|
+
source: "update",
|
|
5959
|
+
target: e,
|
|
5960
|
+
presetKey: O.key,
|
|
5961
|
+
options: n,
|
|
5962
|
+
withoutSave: b
|
|
5963
|
+
}), ae = {
|
|
5394
5964
|
angle: 0,
|
|
5395
5965
|
skewX: 0,
|
|
5396
5966
|
skewY: 0,
|
|
@@ -5403,74 +5973,97 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5403
5973
|
top: 0,
|
|
5404
5974
|
originX: "left",
|
|
5405
5975
|
originY: "top"
|
|
5406
|
-
},
|
|
5407
|
-
text:
|
|
5408
|
-
textStyle: this._resolveCurrentTextStyle({ textNode:
|
|
5409
|
-
width: Math.max(1,
|
|
5410
|
-
align:
|
|
5976
|
+
}, oe = H, se = this._createTextNode({
|
|
5977
|
+
text: oe.textCaseRaw ?? H.text ?? "",
|
|
5978
|
+
textStyle: this._resolveCurrentTextStyle({ textNode: H }),
|
|
5979
|
+
width: Math.max(1, H.width ?? S.width),
|
|
5980
|
+
align: I
|
|
5411
5981
|
});
|
|
5412
|
-
|
|
5413
|
-
textNode:
|
|
5414
|
-
text:
|
|
5415
|
-
textStyle:
|
|
5416
|
-
align:
|
|
5982
|
+
se.set(ae), this._applyTextUpdates({
|
|
5983
|
+
textNode: se,
|
|
5984
|
+
text: p,
|
|
5985
|
+
textStyle: m,
|
|
5986
|
+
align: I
|
|
5417
5987
|
});
|
|
5418
|
-
let
|
|
5419
|
-
text:
|
|
5420
|
-
currentWidth:
|
|
5421
|
-
manualWidth:
|
|
5422
|
-
shapeTextAutoExpandEnabled:
|
|
5423
|
-
padding:
|
|
5424
|
-
}),
|
|
5425
|
-
preset:
|
|
5426
|
-
width:
|
|
5427
|
-
height:
|
|
5428
|
-
style:
|
|
5429
|
-
rounding:
|
|
5430
|
-
}),
|
|
5431
|
-
if (
|
|
5432
|
-
let
|
|
5433
|
-
this._detachShapeGroupAutoLayout({ group: r }),
|
|
5434
|
-
textNode:
|
|
5435
|
-
text:
|
|
5436
|
-
textStyle:
|
|
5437
|
-
align:
|
|
5438
|
-
}), r.remove(
|
|
5988
|
+
let ce = l === void 0 && u === void 0 && t === void 0 && f === void 0 && v === void 0 && p === void 0 && !this._hasShapeTextSizeAffectingStyleChanges({ textStyle: m }), le = _ !== void 0 && ce, ue = ce ? S.width : this._resolveShapeLayoutWidth({
|
|
5989
|
+
text: se,
|
|
5990
|
+
currentWidth: P,
|
|
5991
|
+
manualWidth: z,
|
|
5992
|
+
shapeTextAutoExpandEnabled: E,
|
|
5993
|
+
padding: ie
|
|
5994
|
+
}), de = await Pt({
|
|
5995
|
+
preset: O,
|
|
5996
|
+
width: ue,
|
|
5997
|
+
height: F,
|
|
5998
|
+
style: re,
|
|
5999
|
+
rounding: D
|
|
6000
|
+
}), fe = r.getObjects().indexOf(V);
|
|
6001
|
+
if (fe < 0) return null;
|
|
6002
|
+
let pe = () => {
|
|
6003
|
+
this._detachShapeGroupAutoLayout({ group: r }), H.set(ae), this._applyTextUpdates({
|
|
6004
|
+
textNode: H,
|
|
6005
|
+
text: p,
|
|
6006
|
+
textStyle: m,
|
|
6007
|
+
align: I
|
|
6008
|
+
}), r.remove(V), r.insertAt(fe, de), this._applyShapeGroupMetadata({
|
|
5439
6009
|
group: r,
|
|
5440
|
-
presetKey:
|
|
5441
|
-
presetCanRound: gt({ preset:
|
|
5442
|
-
width:
|
|
5443
|
-
height:
|
|
5444
|
-
manualWidth:
|
|
5445
|
-
manualHeight:
|
|
5446
|
-
|
|
5447
|
-
|
|
5448
|
-
|
|
5449
|
-
|
|
5450
|
-
|
|
5451
|
-
|
|
6010
|
+
presetKey: O.key,
|
|
6011
|
+
presetCanRound: gt({ preset: O }),
|
|
6012
|
+
width: ue,
|
|
6013
|
+
height: F,
|
|
6014
|
+
manualWidth: z,
|
|
6015
|
+
manualHeight: B,
|
|
6016
|
+
replaceBoxWidth: N?.width,
|
|
6017
|
+
replaceBoxHeight: N?.height,
|
|
6018
|
+
shapeTextAutoExpand: E,
|
|
6019
|
+
alignH: I,
|
|
6020
|
+
alignV: ee,
|
|
6021
|
+
padding: ne,
|
|
6022
|
+
style: re,
|
|
6023
|
+
rounding: D
|
|
5452
6024
|
}), this._applyCurrentLayout({
|
|
5453
6025
|
group: r,
|
|
5454
|
-
shape:
|
|
5455
|
-
text:
|
|
5456
|
-
placement:
|
|
5457
|
-
width:
|
|
5458
|
-
height:
|
|
5459
|
-
alignH:
|
|
5460
|
-
alignV:
|
|
5461
|
-
internalShapeTextInset:
|
|
5462
|
-
|
|
5463
|
-
|
|
5464
|
-
|
|
6026
|
+
shape: de,
|
|
6027
|
+
text: H,
|
|
6028
|
+
placement: x,
|
|
6029
|
+
width: ue,
|
|
6030
|
+
height: F,
|
|
6031
|
+
alignH: I,
|
|
6032
|
+
alignV: ee,
|
|
6033
|
+
internalShapeTextInset: R,
|
|
6034
|
+
minimumReplaceBox: N ?? void 0,
|
|
6035
|
+
expandShapeHeightToFitText: !le,
|
|
6036
|
+
changedPadding: L
|
|
6037
|
+
}), H.isEditing && this.editingPlacements.set(r, x);
|
|
5465
6038
|
};
|
|
5466
|
-
if (!this._isOnCanvas({ object: r })) return
|
|
6039
|
+
if (!this._isOnCanvas({ object: r })) return pe(), this.lifecycleController.fireBefore({ lifecycle: U }), this.lifecycleController.fireUpdated({ lifecycle: U }), r;
|
|
5467
6040
|
this._beginMutation();
|
|
5468
6041
|
try {
|
|
5469
|
-
|
|
6042
|
+
pe(), !H.isEditing && !y && this.editor.canvas.setActiveObject(r), this.lifecycleController.fireBefore({ lifecycle: U }), this.editor.canvas.requestRenderAll();
|
|
5470
6043
|
} finally {
|
|
5471
|
-
this._endMutation({ withoutSave:
|
|
6044
|
+
this._endMutation({ withoutSave: b });
|
|
5472
6045
|
}
|
|
5473
|
-
return r;
|
|
6046
|
+
return this.lifecycleController.fireUpdated({ lifecycle: U }), r;
|
|
6047
|
+
}
|
|
6048
|
+
_resolveAspectRatioFittedDimensions({ targetWidth: e, targetHeight: t, aspectWidth: n, aspectHeight: r }) {
|
|
6049
|
+
let i = Math.max(1, n), a = Math.max(1, r), o = e === void 0 ? void 0 : Math.max(1, e), s = t === void 0 ? void 0 : Math.max(1, t);
|
|
6050
|
+
if (o !== void 0 && s === void 0) return {
|
|
6051
|
+
width: o,
|
|
6052
|
+
height: o / i * a
|
|
6053
|
+
};
|
|
6054
|
+
if (o === void 0 && s !== void 0) return {
|
|
6055
|
+
width: s / a * i,
|
|
6056
|
+
height: s
|
|
6057
|
+
};
|
|
6058
|
+
if (o === void 0 || s === void 0) return {
|
|
6059
|
+
width: i,
|
|
6060
|
+
height: a
|
|
6061
|
+
};
|
|
6062
|
+
let c = Math.min(o / i, s / a);
|
|
6063
|
+
return {
|
|
6064
|
+
width: i * c,
|
|
6065
|
+
height: a * c
|
|
6066
|
+
};
|
|
5474
6067
|
}
|
|
5475
6068
|
remove({ target: e, withoutSave: t } = {}) {
|
|
5476
6069
|
let n = this._resolveShapeGroup({ target: e });
|
|
@@ -5488,22 +6081,34 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5488
6081
|
if (!r) return null;
|
|
5489
6082
|
let { shape: i } = Y({ group: r });
|
|
5490
6083
|
if (!i) return null;
|
|
6084
|
+
let a = this.lifecycleController.createContext({
|
|
6085
|
+
group: r,
|
|
6086
|
+
source: "fill",
|
|
6087
|
+
target: e,
|
|
6088
|
+
withoutSave: n
|
|
6089
|
+
});
|
|
5491
6090
|
this._beginMutation();
|
|
5492
6091
|
try {
|
|
5493
6092
|
St({
|
|
5494
6093
|
shape: i,
|
|
5495
6094
|
style: { fill: t }
|
|
5496
|
-
}), r.shapeFill = t, r.setCoords(), this.editor.canvas.requestRenderAll();
|
|
6095
|
+
}), r.shapeFill = t, r.setCoords(), this.lifecycleController.fireBefore({ lifecycle: a }), this.editor.canvas.requestRenderAll();
|
|
5497
6096
|
} finally {
|
|
5498
6097
|
this._endMutation({ withoutSave: n });
|
|
5499
6098
|
}
|
|
5500
|
-
return r;
|
|
6099
|
+
return this.lifecycleController.fireUpdated({ lifecycle: a }), r;
|
|
5501
6100
|
}
|
|
5502
6101
|
setStroke({ target: e, stroke: t, strokeWidth: n, dash: r, withoutSave: i }) {
|
|
5503
6102
|
let a = this._resolveShapeGroup({ target: e });
|
|
5504
6103
|
if (!a) return null;
|
|
5505
6104
|
let { shape: o, text: s } = Y({ group: a });
|
|
5506
6105
|
if (!o) return null;
|
|
6106
|
+
let c = this.lifecycleController.createContext({
|
|
6107
|
+
group: a,
|
|
6108
|
+
source: "stroke",
|
|
6109
|
+
target: e,
|
|
6110
|
+
withoutSave: i
|
|
6111
|
+
});
|
|
5507
6112
|
this._beginMutation();
|
|
5508
6113
|
try {
|
|
5509
6114
|
if (St({
|
|
@@ -5523,27 +6128,33 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5523
6128
|
height: e.height
|
|
5524
6129
|
});
|
|
5525
6130
|
}
|
|
5526
|
-
a.setCoords(), this.editor.canvas.requestRenderAll();
|
|
6131
|
+
a.setCoords(), this.lifecycleController.fireBefore({ lifecycle: c }), this.editor.canvas.requestRenderAll();
|
|
5527
6132
|
} finally {
|
|
5528
6133
|
this._endMutation({ withoutSave: i });
|
|
5529
6134
|
}
|
|
5530
|
-
return a;
|
|
6135
|
+
return this.lifecycleController.fireUpdated({ lifecycle: c }), a;
|
|
5531
6136
|
}
|
|
5532
6137
|
setOpacity({ target: e, opacity: t, withoutSave: n }) {
|
|
5533
6138
|
let r = this._resolveShapeGroup({ target: e });
|
|
5534
6139
|
if (!r) return null;
|
|
5535
6140
|
let { shape: i, text: a } = Y({ group: r });
|
|
5536
6141
|
if (!i) return null;
|
|
6142
|
+
let o = this.lifecycleController.createContext({
|
|
6143
|
+
group: r,
|
|
6144
|
+
source: "opacity",
|
|
6145
|
+
target: e,
|
|
6146
|
+
withoutSave: n
|
|
6147
|
+
});
|
|
5537
6148
|
this._beginMutation();
|
|
5538
6149
|
try {
|
|
5539
6150
|
St({
|
|
5540
6151
|
shape: i,
|
|
5541
6152
|
style: { opacity: t }
|
|
5542
|
-
}), a && (a.set({ opacity: t }), a.setCoords()), r.shapeOpacity = t, r.setCoords(), this.editor.canvas.requestRenderAll();
|
|
6153
|
+
}), a && (a.set({ opacity: t }), a.setCoords()), r.shapeOpacity = t, r.setCoords(), this.lifecycleController.fireBefore({ lifecycle: o }), this.editor.canvas.requestRenderAll();
|
|
5543
6154
|
} finally {
|
|
5544
6155
|
this._endMutation({ withoutSave: n });
|
|
5545
6156
|
}
|
|
5546
|
-
return r;
|
|
6157
|
+
return this.lifecycleController.fireUpdated({ lifecycle: o }), r;
|
|
5547
6158
|
}
|
|
5548
6159
|
getTextNode({ target: e } = {}) {
|
|
5549
6160
|
let t = this._resolveShapeGroup({ target: e });
|
|
@@ -5560,6 +6171,11 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5560
6171
|
let o = this._resolveManualDimensions({ group: r }), s = this.editor.canvasManager.getObjectPlacement({ object: r }), c = this._resolveShapeTextHorizontalAlign({
|
|
5561
6172
|
group: r,
|
|
5562
6173
|
textStyle: t
|
|
6174
|
+
}), l = this.lifecycleController.createContext({
|
|
6175
|
+
group: r,
|
|
6176
|
+
source: "text-style",
|
|
6177
|
+
target: e,
|
|
6178
|
+
withoutSave: n
|
|
5563
6179
|
});
|
|
5564
6180
|
this._beginMutation();
|
|
5565
6181
|
try {
|
|
@@ -5574,18 +6190,23 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5574
6190
|
placement: s,
|
|
5575
6191
|
height: o.height,
|
|
5576
6192
|
alignH: c
|
|
5577
|
-
}), this.editor.canvas.requestRenderAll();
|
|
6193
|
+
}), this.lifecycleController.fireBefore({ lifecycle: l }), this.editor.canvas.requestRenderAll();
|
|
5578
6194
|
} finally {
|
|
5579
6195
|
this._endMutation({ withoutSave: n });
|
|
5580
6196
|
}
|
|
5581
|
-
return r;
|
|
6197
|
+
return this.lifecycleController.fireUpdated({ lifecycle: l }), r;
|
|
5582
6198
|
}
|
|
5583
6199
|
setTextAlign({ target: e, horizontal: t, vertical: n, withoutSave: r }) {
|
|
5584
6200
|
let i = this._resolveShapeGroup({ target: e });
|
|
5585
6201
|
if (!i) return null;
|
|
5586
6202
|
let { shape: a, text: o } = Y({ group: i });
|
|
5587
6203
|
if (!a || !o) return null;
|
|
5588
|
-
let s = this._resolveCurrentDimensions({ group: i }), c = t ?? i.shapeAlignHorizontal ?? "center", l = n ?? i.shapeAlignVertical ?? "middle"
|
|
6204
|
+
let s = this._resolveCurrentDimensions({ group: i }), c = t ?? i.shapeAlignHorizontal ?? "center", l = n ?? i.shapeAlignVertical ?? "middle", u = this.lifecycleController.createContext({
|
|
6205
|
+
group: i,
|
|
6206
|
+
source: "text-align",
|
|
6207
|
+
target: e,
|
|
6208
|
+
withoutSave: r
|
|
6209
|
+
});
|
|
5589
6210
|
this._beginMutation();
|
|
5590
6211
|
try {
|
|
5591
6212
|
this._applyTextUpdates({
|
|
@@ -5599,11 +6220,11 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5599
6220
|
width: s.width,
|
|
5600
6221
|
alignH: c,
|
|
5601
6222
|
alignV: l
|
|
5602
|
-
}), this.editor.canvas.requestRenderAll();
|
|
6223
|
+
}), this.lifecycleController.fireBefore({ lifecycle: u }), this.editor.canvas.requestRenderAll();
|
|
5603
6224
|
} finally {
|
|
5604
6225
|
this._endMutation({ withoutSave: r });
|
|
5605
6226
|
}
|
|
5606
|
-
return i;
|
|
6227
|
+
return this.lifecycleController.fireUpdated({ lifecycle: u }), i;
|
|
5607
6228
|
}
|
|
5608
6229
|
async setRounding({ target: e, rounding: t, withoutSave: n }) {
|
|
5609
6230
|
let r = this._resolveShapeGroup({ target: e });
|
|
@@ -5622,15 +6243,14 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5622
6243
|
}
|
|
5623
6244
|
destroy() {
|
|
5624
6245
|
let { canvas: e } = this.editor;
|
|
5625
|
-
e.off("object:scaling", this._handleObjectScaling), e.off("object:modified", this._handleObjectModified), e.off("mouse:move", this._handleMouseMove), e.off("mouse:down", this._handleMouseDown), e.off("text:editing:entered", this._handleTextEditingEntered), e.off("text:editing:exited", this._handleTextEditingExited), e.off("text:changed", this._handleTextChanged), e.off("editor:before:text-updated", this._handleBeforeTextUpdated);
|
|
6246
|
+
e.off("object:scaling", this._handleObjectScaling), e.off("object:modified", this._handleObjectModified), e.off("mouse:move", this._handleMouseMove), e.off("mouse:down", this._handleMouseDown), e.off("mouse:up", this._handleMouseUp), e.off("text:editing:entered", this._handleTextEditingEntered), e.off("text:editing:exited", this._handleTextEditingExited), e.off("text:changed", this._handleTextChanged), e.off("editor:before:text-updated", this._handleBeforeTextUpdated), e.off("editor:text-updated", this._handleTextUpdated);
|
|
5626
6247
|
}
|
|
5627
6248
|
_bindEvents() {
|
|
5628
6249
|
let { canvas: e } = this.editor;
|
|
5629
|
-
e.on("object:scaling", this._handleObjectScaling), e.on("object:modified", this._handleObjectModified), e.on("mouse:move", this._handleMouseMove), e.on("mouse:down", this._handleMouseDown), e.on("text:editing:entered", this._handleTextEditingEntered), e.on("text:editing:exited", this._handleTextEditingExited), e.on("text:changed", this._handleTextChanged), e.on("editor:before:text-updated", this._handleBeforeTextUpdated);
|
|
6250
|
+
e.on("object:scaling", this._handleObjectScaling), e.on("object:modified", this._handleObjectModified), e.on("mouse:move", this._handleMouseMove), e.on("mouse:down", this._handleMouseDown), e.on("mouse:up", this._handleMouseUp), e.on("text:editing:entered", this._handleTextEditingEntered), e.on("text:editing:exited", this._handleTextEditingExited), e.on("text:changed", this._handleTextChanged), e.on("editor:before:text-updated", this._handleBeforeTextUpdated), e.on("editor:text-updated", this._handleTextUpdated);
|
|
5630
6251
|
}
|
|
5631
6252
|
_createShapeGroup({ id: e, presetKey: t, presetCanRound: n, shape: r, text: i, width: a, height: o, manualWidth: s, manualHeight: c, shapeTextAutoExpand: l, alignH: u, alignV: d, padding: f, internalShapeTextInset: p, changedPadding: m, style: h, rounding: g }) {
|
|
5632
6253
|
let _ = new Rn([r, i], {
|
|
5633
|
-
id: e,
|
|
5634
6254
|
originX: "center",
|
|
5635
6255
|
originY: "center",
|
|
5636
6256
|
left: 0,
|
|
@@ -5638,8 +6258,8 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5638
6258
|
lockScalingFlip: !0,
|
|
5639
6259
|
centeredScaling: !1,
|
|
5640
6260
|
objectCaching: !1
|
|
5641
|
-
});
|
|
5642
|
-
return this._applyShapeGroupMetadata({
|
|
6261
|
+
}), v = _;
|
|
6262
|
+
return v.id = e, this._applyShapeGroupMetadata({
|
|
5643
6263
|
group: _,
|
|
5644
6264
|
presetKey: t,
|
|
5645
6265
|
presetCanRound: n,
|
|
@@ -5664,10 +6284,10 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5664
6284
|
padding: f,
|
|
5665
6285
|
internalShapeTextInset: p,
|
|
5666
6286
|
changedPadding: m
|
|
5667
|
-
}), this._detachShapeGroupAutoLayout({ group: _ }), _;
|
|
6287
|
+
}), _.shapeReplaceBoxWidth = Math.max(1, _.shapeBaseWidth ?? a), _.shapeReplaceBoxHeight = Math.max(1, _.shapeBaseHeight ?? o), this._detachShapeGroupAutoLayout({ group: _ }), _;
|
|
5668
6288
|
}
|
|
5669
|
-
_applyShapeGroupMetadata({ group: e, presetKey: t, presetCanRound: n, width: r, height: i, manualWidth: a, manualHeight: o,
|
|
5670
|
-
let
|
|
6289
|
+
_applyShapeGroupMetadata({ group: e, presetKey: t, presetCanRound: n, width: r, height: i, manualWidth: a, manualHeight: o, replaceBoxWidth: s, replaceBoxHeight: c, shapeTextAutoExpand: l, alignH: u, alignV: d, padding: f, style: p, rounding: m }) {
|
|
6290
|
+
let h = p.strokeDashArray ? p.strokeDashArray.slice() : p.strokeDashArray ?? null;
|
|
5671
6291
|
e.set({
|
|
5672
6292
|
shapeComposite: !0,
|
|
5673
6293
|
shapePresetKey: t,
|
|
@@ -5675,19 +6295,21 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5675
6295
|
shapeBaseHeight: i,
|
|
5676
6296
|
shapeManualBaseWidth: Math.max(1, a ?? r),
|
|
5677
6297
|
shapeManualBaseHeight: Math.max(1, o ?? i),
|
|
5678
|
-
|
|
5679
|
-
|
|
5680
|
-
|
|
5681
|
-
|
|
5682
|
-
|
|
5683
|
-
|
|
5684
|
-
|
|
5685
|
-
|
|
5686
|
-
|
|
5687
|
-
|
|
5688
|
-
|
|
5689
|
-
|
|
5690
|
-
|
|
6298
|
+
shapeReplaceBoxWidth: Math.max(1, s ?? r),
|
|
6299
|
+
shapeReplaceBoxHeight: Math.max(1, c ?? i),
|
|
6300
|
+
shapeTextAutoExpand: l,
|
|
6301
|
+
shapeAlignHorizontal: u,
|
|
6302
|
+
shapeAlignVertical: d,
|
|
6303
|
+
shapePaddingTop: f.top,
|
|
6304
|
+
shapePaddingRight: f.right,
|
|
6305
|
+
shapePaddingBottom: f.bottom,
|
|
6306
|
+
shapePaddingLeft: f.left,
|
|
6307
|
+
shapeFill: p.fill,
|
|
6308
|
+
shapeStroke: p.stroke,
|
|
6309
|
+
shapeStrokeWidth: p.strokeWidth,
|
|
6310
|
+
shapeStrokeDashArray: h,
|
|
6311
|
+
shapeOpacity: p.opacity,
|
|
6312
|
+
shapeRounding: Math.max(0, m ?? 0),
|
|
5691
6313
|
shapeCanRound: n
|
|
5692
6314
|
});
|
|
5693
6315
|
}
|
|
@@ -5706,7 +6328,8 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5706
6328
|
let s = this.editor.textManager.addText(o, {
|
|
5707
6329
|
withoutAdding: !0,
|
|
5708
6330
|
withoutSave: !0,
|
|
5709
|
-
withoutSelection: !0
|
|
6331
|
+
withoutSelection: !0,
|
|
6332
|
+
emitLifecycleEvents: !1
|
|
5710
6333
|
});
|
|
5711
6334
|
return s.set({
|
|
5712
6335
|
shapeNodeType: "text",
|
|
@@ -5729,7 +6352,8 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5729
6352
|
target: e,
|
|
5730
6353
|
style: i,
|
|
5731
6354
|
skipRender: !0,
|
|
5732
|
-
withoutSave: !0
|
|
6355
|
+
withoutSave: !0,
|
|
6356
|
+
emitLifecycleEvents: !1
|
|
5733
6357
|
});
|
|
5734
6358
|
} finally {
|
|
5735
6359
|
this.internalTextUpdates.delete(e);
|
|
@@ -5738,11 +6362,11 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5738
6362
|
}
|
|
5739
6363
|
}
|
|
5740
6364
|
_resolveCurrentTextStyle({ textNode: e }) {
|
|
5741
|
-
let { backgroundColor: t, backgroundOpacity: n, fill: r, fontFamily: i, fontSize: a, fontStyle: o, fontWeight: s, lineFontDefaults: c, linethrough: l, opacity: u, paddingBottom: d, paddingLeft: f, paddingRight: p, paddingTop: m, radiusBottomLeft: h, radiusBottomRight: g, radiusTopLeft: _, radiusTopRight: v, stroke: y, strokeWidth: b, styles: x, textAlign: S, underline: C, uppercase: w } = e;
|
|
6365
|
+
let { backgroundColor: t, backgroundOpacity: n, fill: r, fontFamily: i, fontSize: a, fontStyle: o, fontWeight: s, lineFontDefaults: c, linethrough: l, opacity: u, paddingBottom: d, paddingLeft: f, paddingRight: p, paddingTop: m, radiusBottomLeft: h, radiusBottomRight: g, radiusTopLeft: _, radiusTopRight: v, stroke: y, strokeWidth: b, styles: x, textAlign: S, underline: C, uppercase: w } = e, T = S === "left" || S === "center" || S === "right" || S === "justify" ? { align: S } : void 0;
|
|
5742
6366
|
return {
|
|
5743
6367
|
align: this._resolveShapeTextHorizontalAlign({
|
|
5744
6368
|
group: e.group,
|
|
5745
|
-
textStyle:
|
|
6369
|
+
textStyle: T
|
|
5746
6370
|
}),
|
|
5747
6371
|
backgroundColor: typeof t == "string" ? t : void 0,
|
|
5748
6372
|
backgroundOpacity: n,
|
|
@@ -5782,6 +6406,13 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5782
6406
|
height: Math.max(1, e.shapeManualBaseHeight ?? e.shapeBaseHeight ?? e.height ?? 1)
|
|
5783
6407
|
};
|
|
5784
6408
|
}
|
|
6409
|
+
_resolveReplaceBoxDimensions({ group: e }) {
|
|
6410
|
+
let t = this._resolveCurrentDimensions({ group: e });
|
|
6411
|
+
return {
|
|
6412
|
+
width: Math.max(1, e.shapeReplaceBoxWidth ?? t.width),
|
|
6413
|
+
height: Math.max(1, e.shapeReplaceBoxHeight ?? t.height)
|
|
6414
|
+
};
|
|
6415
|
+
}
|
|
5785
6416
|
_resolveGroupUserPadding({ group: e }) {
|
|
5786
6417
|
return zt({ padding: {
|
|
5787
6418
|
top: e.shapePaddingTop,
|
|
@@ -5833,42 +6464,42 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5833
6464
|
let n = t?.align;
|
|
5834
6465
|
return n === "left" || n === "center" || n === "right" || n === "justify" ? n : e.shapeAlignHorizontal ?? "center";
|
|
5835
6466
|
}
|
|
5836
|
-
_applyCurrentLayout({ group: e, shape: t, text: n, placement: r, width: i, height: a, alignH: o, alignV: s, internalShapeTextInset: c,
|
|
5837
|
-
let
|
|
5838
|
-
|
|
6467
|
+
_applyCurrentLayout({ group: e, shape: t, text: n, placement: r, width: i, height: a, alignH: o, alignV: s, internalShapeTextInset: c, minimumReplaceBox: l, expandShapeHeightToFitText: u = !0, changedPadding: d }) {
|
|
6468
|
+
let f = this._resolveCurrentDimensions({ group: e }), p = this._resolveManualDimensions({ group: e }), m = this._resolveGroupUserPadding({ group: e }), h = f.width;
|
|
6469
|
+
h = i === void 0 ? this._resolveShapeLayoutWidth({
|
|
5839
6470
|
text: n,
|
|
5840
|
-
currentWidth:
|
|
5841
|
-
manualWidth:
|
|
6471
|
+
currentWidth: f.width,
|
|
6472
|
+
manualWidth: p.width,
|
|
5842
6473
|
shapeTextAutoExpandEnabled: this._isShapeTextAutoExpandEnabled({ group: e }),
|
|
5843
6474
|
padding: Ht({
|
|
5844
6475
|
base: c ?? this._resolveGroupInternalShapeTextInset({
|
|
5845
6476
|
group: e,
|
|
5846
|
-
width:
|
|
5847
|
-
height: Math.max(1, a ??
|
|
6477
|
+
width: h,
|
|
6478
|
+
height: Math.max(1, a ?? f.height)
|
|
5848
6479
|
}),
|
|
5849
|
-
addition:
|
|
6480
|
+
addition: m
|
|
5850
6481
|
})
|
|
5851
6482
|
}) : Math.max(1, i);
|
|
5852
|
-
let
|
|
6483
|
+
let g = Math.max(1, a ?? f.height), _ = c ?? this._resolveGroupInternalShapeTextInset({
|
|
5853
6484
|
group: e,
|
|
5854
|
-
width:
|
|
5855
|
-
height:
|
|
5856
|
-
}),
|
|
6485
|
+
width: h,
|
|
6486
|
+
height: g
|
|
6487
|
+
}), v = r ?? this.editor.canvasManager.getObjectPlacement({ object: e });
|
|
5857
6488
|
rn({
|
|
5858
6489
|
group: e,
|
|
5859
6490
|
shape: t,
|
|
5860
6491
|
text: n,
|
|
5861
|
-
width:
|
|
5862
|
-
height:
|
|
6492
|
+
width: h,
|
|
6493
|
+
height: g,
|
|
5863
6494
|
alignH: o ?? e.shapeAlignHorizontal ?? "center",
|
|
5864
6495
|
alignV: s ?? e.shapeAlignVertical ?? "middle",
|
|
5865
|
-
padding:
|
|
5866
|
-
internalShapeTextInset:
|
|
5867
|
-
expandShapeHeightToFitText:
|
|
5868
|
-
changedPadding:
|
|
5869
|
-
}), this.editor.canvasManager.applyObjectPlacement({
|
|
6496
|
+
padding: m,
|
|
6497
|
+
internalShapeTextInset: _,
|
|
6498
|
+
expandShapeHeightToFitText: u,
|
|
6499
|
+
changedPadding: d
|
|
6500
|
+
}), e.shapeReplaceBoxWidth = Math.max(1, l?.width ?? 0, e.shapeBaseWidth ?? h), e.shapeReplaceBoxHeight = Math.max(1, l?.height ?? 0, e.shapeBaseHeight ?? g), this.editor.canvasManager.applyObjectPlacement({
|
|
5870
6501
|
object: e,
|
|
5871
|
-
placement:
|
|
6502
|
+
placement: v
|
|
5872
6503
|
});
|
|
5873
6504
|
}
|
|
5874
6505
|
_syncShapeTextLayoutAfterTextMutation({ textNode: e, textStyle: t }) {
|
|
@@ -5913,12 +6544,32 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5913
6544
|
_resolveShapeStyle({ options: e, fallback: t }) {
|
|
5914
6545
|
let { fill: n, stroke: r, strokeWidth: i, strokeDashArray: a, opacity: o } = e, s = a === void 0 ? t?.shapeStrokeDashArray : a;
|
|
5915
6546
|
return {
|
|
5916
|
-
fill: n ?? t?.shapeFill ??
|
|
6547
|
+
fill: n ?? t?.shapeFill ?? or,
|
|
5917
6548
|
stroke: r ?? t?.shapeStroke ?? null,
|
|
5918
|
-
strokeWidth: i ?? t?.shapeStrokeWidth ??
|
|
6549
|
+
strokeWidth: i ?? t?.shapeStrokeWidth ?? sr,
|
|
5919
6550
|
strokeDashArray: s ?? null,
|
|
5920
|
-
opacity: o ?? t?.shapeOpacity ??
|
|
6551
|
+
opacity: o ?? t?.shapeOpacity ?? cr
|
|
6552
|
+
};
|
|
6553
|
+
}
|
|
6554
|
+
_collectShapeGroupsFromTarget({ target: t, subTargets: n = [] }) {
|
|
6555
|
+
let r = [], i = (t) => {
|
|
6556
|
+
if (!t) return;
|
|
6557
|
+
if (t instanceof e) {
|
|
6558
|
+
t.getObjects().forEach((e) => {
|
|
6559
|
+
i(e);
|
|
6560
|
+
});
|
|
6561
|
+
return;
|
|
6562
|
+
}
|
|
6563
|
+
if (J(t)) {
|
|
6564
|
+
r.includes(t) || r.push(t);
|
|
6565
|
+
return;
|
|
6566
|
+
}
|
|
6567
|
+
let { group: n } = t;
|
|
6568
|
+
!n || !J(n) || r.includes(n) || r.push(n);
|
|
5921
6569
|
};
|
|
6570
|
+
return i(t), n.forEach((e) => {
|
|
6571
|
+
i(e);
|
|
6572
|
+
}), r;
|
|
5922
6573
|
}
|
|
5923
6574
|
_beginMutation() {
|
|
5924
6575
|
this.editor.historyManager.suspendHistory();
|
|
@@ -5953,7 +6604,7 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5953
6604
|
}
|
|
5954
6605
|
return null;
|
|
5955
6606
|
}
|
|
5956
|
-
},
|
|
6607
|
+
}, ur = class {
|
|
5957
6608
|
constructor({ editor: e }) {
|
|
5958
6609
|
this.editor = e, this.clipboard = null;
|
|
5959
6610
|
}
|
|
@@ -5972,7 +6623,7 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5972
6623
|
async _cloneToInternalClipboard(e) {
|
|
5973
6624
|
let { canvas: t, errorManager: n } = this.editor;
|
|
5974
6625
|
try {
|
|
5975
|
-
let n = await e.clone(
|
|
6626
|
+
let n = await e.clone(Ie);
|
|
5976
6627
|
this.clipboard = n, t.fire("editor:object-copied", { object: n });
|
|
5977
6628
|
} catch (e) {
|
|
5978
6629
|
n.emitError({
|
|
@@ -5993,7 +6644,7 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5993
6644
|
message: "navigator.clipboard не поддерживается в этом браузере или отсутствует HTTPS-соединение."
|
|
5994
6645
|
}), !1;
|
|
5995
6646
|
try {
|
|
5996
|
-
let t = e.toObject(
|
|
6647
|
+
let t = e.toObject(Ie), n = JSON.stringify(t);
|
|
5997
6648
|
return e.type === "image" ? this._copyImageToClipboard(e, n) : this._copyTextToClipboard(n);
|
|
5998
6649
|
} catch (e) {
|
|
5999
6650
|
return t.emitError({
|
|
@@ -6023,7 +6674,7 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6023
6674
|
}
|
|
6024
6675
|
async _copyTextToClipboard(e) {
|
|
6025
6676
|
try {
|
|
6026
|
-
let t = `${
|
|
6677
|
+
let t = `${Fe}${e}`;
|
|
6027
6678
|
return await navigator.clipboard.writeText(t), console.info("Text copied to clipboard successfully"), !0;
|
|
6028
6679
|
} catch (e) {
|
|
6029
6680
|
let { errorManager: t } = this.editor;
|
|
@@ -6108,7 +6759,7 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6108
6759
|
let { canvas: n } = this.editor, r = t || n.getActiveObject();
|
|
6109
6760
|
if (!r || r.locked) return !1;
|
|
6110
6761
|
try {
|
|
6111
|
-
let t = await r.clone(
|
|
6762
|
+
let t = await r.clone(Ie);
|
|
6112
6763
|
return t instanceof e && t.forEachObject((e) => {
|
|
6113
6764
|
e.set({
|
|
6114
6765
|
id: `${e.type}-${D()}`,
|
|
@@ -6182,7 +6833,7 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6182
6833
|
let { canvas: t } = this.editor;
|
|
6183
6834
|
if (!this.clipboard) return !1;
|
|
6184
6835
|
try {
|
|
6185
|
-
let n = await this.clipboard.clone(
|
|
6836
|
+
let n = await this.clipboard.clone(Ie);
|
|
6186
6837
|
return t.discardActiveObject(), n instanceof e && n.forEachObject((e) => {
|
|
6187
6838
|
e.set({
|
|
6188
6839
|
id: `${e.type}-${D()}`,
|
|
@@ -6209,7 +6860,7 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6209
6860
|
}), !1;
|
|
6210
6861
|
}
|
|
6211
6862
|
}
|
|
6212
|
-
},
|
|
6863
|
+
}, dr = class t {
|
|
6213
6864
|
constructor({ editor: e }) {
|
|
6214
6865
|
this.editor = e;
|
|
6215
6866
|
}
|
|
@@ -6274,7 +6925,7 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6274
6925
|
!(n instanceof _) || !n.isEditing || n.exitEditing();
|
|
6275
6926
|
}
|
|
6276
6927
|
}
|
|
6277
|
-
},
|
|
6928
|
+
}, fr = class {
|
|
6278
6929
|
constructor({ editor: e }) {
|
|
6279
6930
|
this.editor = e;
|
|
6280
6931
|
}
|
|
@@ -6340,7 +6991,7 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6340
6991
|
i.resumeHistory(), n || i.saveState();
|
|
6341
6992
|
}
|
|
6342
6993
|
}
|
|
6343
|
-
},
|
|
6994
|
+
}, pr = class t {
|
|
6344
6995
|
constructor({ editor: e }) {
|
|
6345
6996
|
this.lastSelection = [], this.isCtrlSelectionBoxActive = !1, this.isSelectionMergeInProgress = !1, this.editor = e, 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();
|
|
6346
6997
|
}
|
|
@@ -6534,7 +7185,7 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6534
7185
|
let { options: e } = this.editor, { selectionKey: t } = e;
|
|
6535
7186
|
return t === void 0 ? ["ctrlKey", "metaKey"] : t;
|
|
6536
7187
|
}
|
|
6537
|
-
},
|
|
7188
|
+
}, mr = class e {
|
|
6538
7189
|
constructor({ editor: e }) {
|
|
6539
7190
|
this.editor = e;
|
|
6540
7191
|
}
|
|
@@ -6574,7 +7225,7 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6574
7225
|
};
|
|
6575
7226
|
return i.fire("editor:objects-deleted", l), l;
|
|
6576
7227
|
}
|
|
6577
|
-
},
|
|
7228
|
+
}, hr = {
|
|
6578
7229
|
IMAGE_MANAGER: {
|
|
6579
7230
|
INVALID_CONTENT_TYPE: "INVALID_CONTENT_TYPE",
|
|
6580
7231
|
INVALID_SOURCE_TYPE: "INVALID_SOURCE_TYPE",
|
|
@@ -6612,7 +7263,7 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6612
7263
|
INVALID_TARGET: "TEMPLATE_INVALID_TARGET",
|
|
6613
7264
|
APPLY_FAILED: "TEMPLATE_APPLY_FAILED"
|
|
6614
7265
|
}
|
|
6615
|
-
},
|
|
7266
|
+
}, gr = class e {
|
|
6616
7267
|
constructor({ editor: e }) {
|
|
6617
7268
|
this._buffer = [], this.editor = e;
|
|
6618
7269
|
}
|
|
@@ -6670,9 +7321,9 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6670
7321
|
}), this.editor.canvas.fire("editor:warning", s);
|
|
6671
7322
|
}
|
|
6672
7323
|
static isValidErrorCode(e) {
|
|
6673
|
-
return e ? Object.values(
|
|
7324
|
+
return e ? Object.values(hr).some((t) => Object.values(t).includes(e)) : !1;
|
|
6674
7325
|
}
|
|
6675
|
-
},
|
|
7326
|
+
}, _r = class {
|
|
6676
7327
|
constructor({ editor: e }) {
|
|
6677
7328
|
this.currentBounds = null, this.editor = e;
|
|
6678
7329
|
}
|
|
@@ -6721,32 +7372,32 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6721
7372
|
updateBounds() {
|
|
6722
7373
|
this.currentBounds = this.calculatePanBounds();
|
|
6723
7374
|
}
|
|
6724
|
-
},
|
|
7375
|
+
}, vr = ({ textbox: e }) => {
|
|
6725
7376
|
if (!e.isEditing) return null;
|
|
6726
7377
|
let t = e.selectionStart ?? 0, n = e.selectionEnd ?? t;
|
|
6727
7378
|
return t === n ? null : {
|
|
6728
7379
|
start: Math.min(t, n),
|
|
6729
7380
|
end: Math.max(t, n)
|
|
6730
7381
|
};
|
|
6731
|
-
},
|
|
7382
|
+
}, yr = ({ textbox: e }) => {
|
|
6732
7383
|
let t = e.text?.length ?? 0;
|
|
6733
7384
|
return t <= 0 ? null : {
|
|
6734
7385
|
start: 0,
|
|
6735
7386
|
end: t
|
|
6736
7387
|
};
|
|
6737
|
-
},
|
|
7388
|
+
}, br = ({ textbox: e, range: t }) => {
|
|
6738
7389
|
if (!t) return !1;
|
|
6739
7390
|
let n = e.text?.length ?? 0;
|
|
6740
7391
|
return n <= 0 ? !1 : t.start <= 0 && t.end >= n;
|
|
6741
|
-
},
|
|
7392
|
+
}, xr = ({ textbox: e, styles: t, range: n }) => {
|
|
6742
7393
|
if (!t || !Object.keys(t).length) return !1;
|
|
6743
7394
|
let { start: r, end: i } = n;
|
|
6744
7395
|
return i <= r ? !1 : (e.setSelectionStyles(t, r, i), !0);
|
|
6745
|
-
},
|
|
7396
|
+
}, Sr = ({ textbox: e, range: t, property: n }) => {
|
|
6746
7397
|
if (!t) return;
|
|
6747
7398
|
let r = e.getSelectionStyles(t.start, t.end, !0);
|
|
6748
7399
|
if (r.length) return r[0]?.[n];
|
|
6749
|
-
},
|
|
7400
|
+
}, Cr = ({ strokeColor: e, width: t }) => t <= 0 ? null : e ?? "#000000", wr = ({ width: e = 0 }) => e ? Math.max(0, e) : 0, Tr = ({ value: e }) => typeof e == "string" ? e.toLocaleUpperCase() : "", Er = ({ value: e, min: t, max: n }) => Math.min(Math.max(e, t), n), Dr = class e extends _ {
|
|
6750
7401
|
static {
|
|
6751
7402
|
this.type = "background-textbox";
|
|
6752
7403
|
}
|
|
@@ -6788,6 +7439,15 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6788
7439
|
initDimensions() {
|
|
6789
7440
|
super.initDimensions(), this.shouldRoundDimensionsOnInit !== !1 && this._roundDimensions();
|
|
6790
7441
|
}
|
|
7442
|
+
transformMatrixKey(e = !1) {
|
|
7443
|
+
return [
|
|
7444
|
+
...super.transformMatrixKey(e),
|
|
7445
|
+
this.paddingTop ?? 0,
|
|
7446
|
+
this.paddingRight ?? 0,
|
|
7447
|
+
this.paddingBottom ?? 0,
|
|
7448
|
+
this.paddingLeft ?? 0
|
|
7449
|
+
];
|
|
7450
|
+
}
|
|
6791
7451
|
_getLeftOffset() {
|
|
6792
7452
|
let { width: e } = this._getBackgroundDimensions(), { left: t } = this._getPadding();
|
|
6793
7453
|
return -e / 2 + t;
|
|
@@ -6871,7 +7531,7 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6871
7531
|
this._removeShadow(e);
|
|
6872
7532
|
}
|
|
6873
7533
|
_getDecorationColorAt(e, t) {
|
|
6874
|
-
let n = this.getValueOfPropertyAt(e, t, "strokeWidth"), r =
|
|
7534
|
+
let n = this.getValueOfPropertyAt(e, t, "strokeWidth"), r = wr({ width: typeof n == "number" && Number.isFinite(n) ? n : 0 }), i = this.getValueOfPropertyAt(e, t, "stroke"), a = i == null ? null : Cr({
|
|
6875
7535
|
strokeColor: i,
|
|
6876
7536
|
width: r
|
|
6877
7537
|
});
|
|
@@ -6887,22 +7547,22 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6887
7547
|
_getCornerRadii({ width: e, height: t }) {
|
|
6888
7548
|
let n = e / 2, r = t / 2, i = Math.min(n, r);
|
|
6889
7549
|
return {
|
|
6890
|
-
bottomLeft:
|
|
7550
|
+
bottomLeft: Er({
|
|
6891
7551
|
value: this.radiusBottomLeft ?? 0,
|
|
6892
7552
|
min: 0,
|
|
6893
7553
|
max: i
|
|
6894
7554
|
}),
|
|
6895
|
-
bottomRight:
|
|
7555
|
+
bottomRight: Er({
|
|
6896
7556
|
value: this.radiusBottomRight ?? 0,
|
|
6897
7557
|
min: 0,
|
|
6898
7558
|
max: i
|
|
6899
7559
|
}),
|
|
6900
|
-
topLeft:
|
|
7560
|
+
topLeft: Er({
|
|
6901
7561
|
value: this.radiusTopLeft ?? 0,
|
|
6902
7562
|
min: 0,
|
|
6903
7563
|
max: i
|
|
6904
7564
|
}),
|
|
6905
|
-
topRight:
|
|
7565
|
+
topRight: Er({
|
|
6906
7566
|
value: this.radiusTopRight ?? 0,
|
|
6907
7567
|
min: 0,
|
|
6908
7568
|
max: i
|
|
@@ -6920,7 +7580,7 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6920
7580
|
_getEffectiveBackgroundFill() {
|
|
6921
7581
|
let e = this.backgroundColor;
|
|
6922
7582
|
if (!e) return null;
|
|
6923
|
-
let t =
|
|
7583
|
+
let t = Er({
|
|
6924
7584
|
value: this.backgroundOpacity ?? 1,
|
|
6925
7585
|
min: 0,
|
|
6926
7586
|
max: 1
|
|
@@ -6928,7 +7588,7 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6928
7588
|
try {
|
|
6929
7589
|
r = new n(e);
|
|
6930
7590
|
} catch (t) {
|
|
6931
|
-
return
|
|
7591
|
+
return gr.emitError({
|
|
6932
7592
|
origin: "BackgroundTextbox",
|
|
6933
7593
|
method: "_getEffectiveBackgroundFill",
|
|
6934
7594
|
code: "INVALID_COLOR_VALUE",
|
|
@@ -6942,19 +7602,19 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6942
7602
|
return r.setAlpha(t), r.toRgba();
|
|
6943
7603
|
}
|
|
6944
7604
|
static _renderRoundedRect({ ctx: e, height: t, left: n, radii: r, top: i, width: a }) {
|
|
6945
|
-
let o = n + a, s = i + t, { topLeft: c, topRight: l, bottomRight: u, bottomLeft: d } = r, f =
|
|
7605
|
+
let o = n + a, s = i + t, { topLeft: c, topRight: l, bottomRight: u, bottomLeft: d } = r, f = Er({
|
|
6946
7606
|
value: c,
|
|
6947
7607
|
min: 0,
|
|
6948
7608
|
max: a
|
|
6949
|
-
}), p =
|
|
7609
|
+
}), p = Er({
|
|
6950
7610
|
value: l,
|
|
6951
7611
|
min: 0,
|
|
6952
7612
|
max: a
|
|
6953
|
-
}), m =
|
|
7613
|
+
}), m = Er({
|
|
6954
7614
|
value: u,
|
|
6955
7615
|
min: 0,
|
|
6956
7616
|
max: a
|
|
6957
|
-
}), h =
|
|
7617
|
+
}), h = Er({
|
|
6958
7618
|
value: d,
|
|
6959
7619
|
min: 0,
|
|
6960
7620
|
max: a
|
|
@@ -6965,9 +7625,9 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6965
7625
|
let { width: e = 0, height: t = 0 } = this, n = Math.round(e), r = Math.round(t);
|
|
6966
7626
|
n !== e && (this.width = Math.max(0, n)), r !== t && (this.height = Math.max(0, r));
|
|
6967
7627
|
}
|
|
6968
|
-
},
|
|
6969
|
-
y?.setClass && y.setClass(
|
|
6970
|
-
},
|
|
7628
|
+
}, Or = () => {
|
|
7629
|
+
y?.setClass && y.setClass(Dr, "background-textbox");
|
|
7630
|
+
}, kr = .01, Ar = ({ textbox: e, lineIndices: t, updates: n }) => {
|
|
6971
7631
|
if (!t.length) return !1;
|
|
6972
7632
|
let { fontFamily: r, fontSize: i, fill: a, stroke: o } = n;
|
|
6973
7633
|
if (!(r !== void 0 || i !== void 0 || a !== void 0 || o !== void 0)) return !1;
|
|
@@ -6979,7 +7639,7 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6979
7639
|
r !== void 0 && d?.fontFamily !== r && (f.fontFamily = r, p = !0), i !== void 0 && d?.fontSize !== i && (f.fontSize = i, p = !0), a !== void 0 && d?.fill !== a && (f.fill = a, p = !0), o !== void 0 && (o === null && d?.stroke !== void 0 && (delete f.stroke, p = !0), o !== null && d?.stroke !== o && (f.stroke = o, p = !0)), p && (u ||= (c = { ...c }, !0), c[n] = f, l = !0);
|
|
6980
7640
|
}
|
|
6981
7641
|
return l && (e.lineFontDefaults = c), l;
|
|
6982
|
-
},
|
|
7642
|
+
}, jr = ({ lineText: e, lineStyles: t, lineDefaults: n }) => {
|
|
6983
7643
|
let r = e.length;
|
|
6984
7644
|
if (r === 0) return {
|
|
6985
7645
|
lineStyles: t,
|
|
@@ -7011,7 +7671,7 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
7011
7671
|
lineStyles: l,
|
|
7012
7672
|
changed: u
|
|
7013
7673
|
};
|
|
7014
|
-
},
|
|
7674
|
+
}, Mr = ({ lineFontDefaults: e }) => {
|
|
7015
7675
|
if (!e) return;
|
|
7016
7676
|
let t = {};
|
|
7017
7677
|
for (let n in e) {
|
|
@@ -7022,7 +7682,7 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
7022
7682
|
i && (t[r] = { ...i });
|
|
7023
7683
|
}
|
|
7024
7684
|
return t;
|
|
7025
|
-
},
|
|
7685
|
+
}, Nr = ({ lineFontDefaults: e, scale: t }) => {
|
|
7026
7686
|
if (!e || !Number.isFinite(t) || Math.abs(t - 1) < .01) return;
|
|
7027
7687
|
let n = {}, r = !1, i = !1;
|
|
7028
7688
|
for (let a in e) {
|
|
@@ -7039,20 +7699,34 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
7039
7699
|
n[o] = c, r = !0;
|
|
7040
7700
|
}
|
|
7041
7701
|
if (!(!r || !i)) return n;
|
|
7042
|
-
},
|
|
7702
|
+
}, Pr = ({ textbox: e, text: t }) => {
|
|
7043
7703
|
let { textLines: n } = e, r = Array.isArray(n) && n.length > 0 ? n.length : Math.max(t.split("\n").length, 1), i = 0;
|
|
7044
7704
|
for (let t = 0; t < r; t += 1) {
|
|
7045
7705
|
let n = e.getLineWidth(t);
|
|
7046
7706
|
n > i && (i = n);
|
|
7047
7707
|
}
|
|
7048
7708
|
return i;
|
|
7049
|
-
},
|
|
7709
|
+
}, Fr = ({ origin: e, size: t }) => e === "left" || e === "top" || e === "start" || e === 0 ? 0 : e === "right" || e === "bottom" || e === "end" || e === 1 ? t : t / 2, Ir = ({ textbox: e, originX: t = e.originX ?? "center", originY: n = e.originY ?? "center" }) => {
|
|
7710
|
+
let r = e.width ?? e.calcTextWidth() ?? 0, i = e.height ?? e.calcTextHeight() ?? 0, a = e.paddingTop ?? 0, o = e.paddingRight ?? 0, s = e.paddingBottom ?? 0, c = e.paddingLeft ?? 0, l = -r / 2 + (c - o) / 2, u = -i / 2 + (a - s) / 2, d = new p(l + Fr({
|
|
7711
|
+
origin: t,
|
|
7712
|
+
size: r
|
|
7713
|
+
}), u + Fr({
|
|
7714
|
+
origin: n,
|
|
7715
|
+
size: i
|
|
7716
|
+
})), f = e.getPointByOrigin("center", "center"), m = e, h = typeof m.calcTransformMatrix == "function" ? m.calcTransformMatrix() : null, g = Array.isArray(h) ? new p(d.x * h[0] + d.y * h[2] + f.x, d.x * h[1] + d.y * h[3] + f.y) : new p(f.x + d.x, f.y + d.y);
|
|
7717
|
+
return {
|
|
7718
|
+
left: g.x,
|
|
7719
|
+
top: g.y,
|
|
7720
|
+
originX: t,
|
|
7721
|
+
originY: n
|
|
7722
|
+
};
|
|
7723
|
+
}, Lr = ({ textbox: e, montageLeft: t, montageRight: n }) => {
|
|
7050
7724
|
e.setCoords();
|
|
7051
7725
|
let r = e.getBoundingRect(!1, !0), i = r.left ?? 0, a = i + (r.width ?? 0), o = n - t;
|
|
7052
7726
|
if (o > 0 && (r.width ?? 0) >= o - .01) return !1;
|
|
7053
7727
|
let s = 0;
|
|
7054
7728
|
return i < t ? s = t - i : a > n && (s = n - a), Math.abs(s) <= .01 ? !1 : (e.set({ left: (e.left ?? 0) + s }), !0);
|
|
7055
|
-
},
|
|
7729
|
+
}, Rr = ({ rawValue: e, calculatedValue: t }) => typeof e == "number" ? e : typeof t == "number" ? t : 0, zr = ({ stylesList: e }) => {
|
|
7056
7730
|
let t = e.length;
|
|
7057
7731
|
if (!t) return !1;
|
|
7058
7732
|
for (let n = 0; n < t; n += 1) {
|
|
@@ -7062,16 +7736,16 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
7062
7736
|
if (r !== void 0 || i !== void 0 || a !== void 0 || o !== void 0 || s !== void 0 || c !== void 0) return !0;
|
|
7063
7737
|
}
|
|
7064
7738
|
return !1;
|
|
7065
|
-
},
|
|
7066
|
-
let { width: t, height: n, calcTextWidth: r, calcTextHeight: i } = e, a = typeof r == "function" ? r.call(e) : void 0, o = typeof i == "function" ? i.call(e) : void 0, s =
|
|
7739
|
+
}, Br = ({ textbox: e }) => {
|
|
7740
|
+
let { width: t, height: n, calcTextWidth: r, calcTextHeight: i } = e, a = typeof r == "function" ? r.call(e) : void 0, o = typeof i == "function" ? i.call(e) : void 0, s = Rr({
|
|
7067
7741
|
rawValue: t,
|
|
7068
7742
|
calculatedValue: a
|
|
7069
|
-
}), c =
|
|
7743
|
+
}), c = Rr({
|
|
7070
7744
|
rawValue: n,
|
|
7071
7745
|
calculatedValue: o
|
|
7072
7746
|
}), l = Number.isFinite(s) ? Math.round(s) : null, u = Number.isFinite(c) ? Math.round(c) : null, d = {};
|
|
7073
7747
|
return l !== null && l !== s && (d.width = Math.max(0, l)), u !== null && u !== c && (d.height = Math.max(0, u)), Object.keys(d).length ? (e.set(d), !0) : !1;
|
|
7074
|
-
},
|
|
7748
|
+
}, Vr = ({ textbox: e }) => {
|
|
7075
7749
|
let t = e.width ?? e.calcTextWidth(), n = e.fontSize ?? 16, { styles: r = {} } = e, { lineFontDefaults: i } = e, { paddingTop: a = 0, paddingRight: o = 0, paddingBottom: s = 0, paddingLeft: c = 0 } = e, { radiusTopLeft: l = 0, radiusTopRight: u = 0, radiusBottomRight: d = 0, radiusBottomLeft: f = 0 } = e;
|
|
7076
7750
|
return {
|
|
7077
7751
|
width: t,
|
|
@@ -7089,9 +7763,9 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
7089
7763
|
bottomLeft: f
|
|
7090
7764
|
},
|
|
7091
7765
|
styles: JSON.parse(JSON.stringify(r)),
|
|
7092
|
-
lineFontDefaults:
|
|
7766
|
+
lineFontDefaults: Mr({ lineFontDefaults: i })
|
|
7093
7767
|
};
|
|
7094
|
-
},
|
|
7768
|
+
}, Hr = ({ base: e }) => {
|
|
7095
7769
|
let t = 1 / Math.max(1, e.width), n = [e.fontSize];
|
|
7096
7770
|
Object.values(e.styles).forEach((e) => {
|
|
7097
7771
|
Object.values(e).forEach((e) => {
|
|
@@ -7108,11 +7782,11 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
7108
7782
|
fontScale: r,
|
|
7109
7783
|
proportionalScale: Math.max(t, r)
|
|
7110
7784
|
};
|
|
7111
|
-
},
|
|
7112
|
-
let { width:
|
|
7113
|
-
if (
|
|
7785
|
+
}, Ur = ({ textbox: e, canvasManager: t, base: n, widthScale: r, heightScale: i, placement: a, anchorPlacement: o, shouldScaleFontSize: s, shouldScalePadding: c, shouldScaleRadii: l, shouldDisableAutoExpandOnHorizontalChange: u = !1, shouldRoundDimensions: d = !0 }) => {
|
|
7786
|
+
let { width: f, fontSize: m, padding: h, radii: g, styles: _, lineFontDefaults: v } = n, y = Math.max(1, f * r), b = d ? Math.max(1, Math.round(y)) : y, x = Math.max(Math.min(8, m), m * i), S = Object.keys(_).length > 0, C;
|
|
7787
|
+
if (s && S) {
|
|
7114
7788
|
let e = {};
|
|
7115
|
-
Object.entries(
|
|
7789
|
+
Object.entries(_).forEach(([t, n]) => {
|
|
7116
7790
|
if (!n) return;
|
|
7117
7791
|
let r = {};
|
|
7118
7792
|
Object.entries(n).forEach(([e, t]) => {
|
|
@@ -7124,65 +7798,71 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
7124
7798
|
}
|
|
7125
7799
|
r[e] = n;
|
|
7126
7800
|
}), Object.keys(r).length && (e[t] = r);
|
|
7127
|
-
}), Object.keys(e).length && (
|
|
7801
|
+
}), Object.keys(e).length && (C = e);
|
|
7128
7802
|
}
|
|
7129
|
-
let
|
|
7130
|
-
|
|
7131
|
-
lineFontDefaults:
|
|
7803
|
+
let w;
|
|
7804
|
+
s && (w = Nr({
|
|
7805
|
+
lineFontDefaults: v,
|
|
7132
7806
|
scale: i
|
|
7133
7807
|
}));
|
|
7134
|
-
let
|
|
7135
|
-
top: Math.max(0,
|
|
7136
|
-
right: Math.max(0,
|
|
7137
|
-
bottom: Math.max(0,
|
|
7138
|
-
left: Math.max(0,
|
|
7139
|
-
} :
|
|
7140
|
-
topLeft: Math.max(0,
|
|
7141
|
-
topRight: Math.max(0,
|
|
7142
|
-
bottomRight: Math.max(0,
|
|
7143
|
-
bottomLeft: Math.max(0,
|
|
7144
|
-
} :
|
|
7145
|
-
|
|
7146
|
-
width:
|
|
7147
|
-
fontSize:
|
|
7148
|
-
paddingTop:
|
|
7149
|
-
paddingRight:
|
|
7150
|
-
paddingBottom:
|
|
7151
|
-
paddingLeft:
|
|
7152
|
-
radiusTopLeft:
|
|
7153
|
-
radiusTopRight:
|
|
7154
|
-
radiusBottomRight:
|
|
7155
|
-
radiusBottomLeft:
|
|
7808
|
+
let T = c ? {
|
|
7809
|
+
top: Math.max(0, h.top * i),
|
|
7810
|
+
right: Math.max(0, h.right * i),
|
|
7811
|
+
bottom: Math.max(0, h.bottom * i),
|
|
7812
|
+
left: Math.max(0, h.left * i)
|
|
7813
|
+
} : h, E = l ? {
|
|
7814
|
+
topLeft: Math.max(0, g.topLeft * i),
|
|
7815
|
+
topRight: Math.max(0, g.topRight * i),
|
|
7816
|
+
bottomRight: Math.max(0, g.bottomRight * i),
|
|
7817
|
+
bottomLeft: Math.max(0, g.bottomLeft * i)
|
|
7818
|
+
} : g, D = e.width ?? f, O = Math.abs(b - D) > kr;
|
|
7819
|
+
u && O && (e.autoExpand = !1), C && (e.styles = C), w && (e.lineFontDefaults = w), e.set({
|
|
7820
|
+
width: b,
|
|
7821
|
+
fontSize: s ? x : m,
|
|
7822
|
+
paddingTop: T.top,
|
|
7823
|
+
paddingRight: T.right,
|
|
7824
|
+
paddingBottom: T.bottom,
|
|
7825
|
+
paddingLeft: T.left,
|
|
7826
|
+
radiusTopLeft: E.topLeft,
|
|
7827
|
+
radiusTopRight: E.topRight,
|
|
7828
|
+
radiusBottomRight: E.bottomRight,
|
|
7829
|
+
radiusBottomLeft: E.bottomLeft,
|
|
7156
7830
|
scaleX: 1,
|
|
7157
7831
|
scaleY: 1
|
|
7158
7832
|
});
|
|
7159
|
-
let
|
|
7160
|
-
e.shouldRoundDimensionsOnInit =
|
|
7833
|
+
let k = e.shouldRoundDimensionsOnInit;
|
|
7834
|
+
e.shouldRoundDimensionsOnInit = d;
|
|
7161
7835
|
try {
|
|
7162
7836
|
e.initDimensions();
|
|
7163
7837
|
} finally {
|
|
7164
|
-
e.shouldRoundDimensionsOnInit =
|
|
7165
|
-
}
|
|
7166
|
-
let
|
|
7167
|
-
return
|
|
7838
|
+
e.shouldRoundDimensionsOnInit = k;
|
|
7839
|
+
}
|
|
7840
|
+
let A = d ? Br({ textbox: e }) : !1;
|
|
7841
|
+
return A && (e.dirty = !0), o ? (e.set({
|
|
7842
|
+
originX: a.originX,
|
|
7843
|
+
originY: a.originY
|
|
7844
|
+
}), e.setPositionByOrigin(new p(o.left, o.top), o.originX, o.originY), e.setCoords(), {
|
|
7845
|
+
appliedWidth: e.width ?? b,
|
|
7846
|
+
dimensionsRounded: A
|
|
7847
|
+
}) : (t.applyObjectPlacement({
|
|
7168
7848
|
object: e,
|
|
7169
7849
|
placement: a
|
|
7170
7850
|
}), e.setCoords(), {
|
|
7171
|
-
appliedWidth: e.width ??
|
|
7172
|
-
dimensionsRounded:
|
|
7173
|
-
};
|
|
7174
|
-
},
|
|
7851
|
+
appliedWidth: e.width ?? b,
|
|
7852
|
+
dimensionsRounded: A
|
|
7853
|
+
});
|
|
7854
|
+
}, Wr = ({ transform: e }) => {
|
|
7175
7855
|
let { corner: t = "", action: n = "" } = e;
|
|
7176
7856
|
return {
|
|
7177
7857
|
isCornerHandle: t === "tl" || t === "tr" || t === "bl" || t === "br" || n === "scale",
|
|
7178
7858
|
isHorizontalHandle: t === "ml" || t === "mr" || n === "scaleX",
|
|
7179
7859
|
isVerticalHandle: t === "mt" || t === "mb" || n === "scaleY"
|
|
7180
7860
|
};
|
|
7181
|
-
},
|
|
7861
|
+
}, Gr = ({ textbox: e, transform: t, appliedWidth: n }) => {
|
|
7182
7862
|
t.scaleX = 1, t.scaleY = 1;
|
|
7183
7863
|
let { original: r } = t;
|
|
7184
7864
|
r && (r.scaleX = 1, r.scaleY = 1, r.width = n, r.height = e.height, r.left = e.left, r.top = e.top);
|
|
7185
|
-
},
|
|
7865
|
+
}, Kr = ({ textbox: e, transform: t, scenePoint: n }) => {
|
|
7186
7866
|
let { x: r, y: i } = e._getTransformedDimensions();
|
|
7187
7867
|
if (r <= 0 || i <= 0) return null;
|
|
7188
7868
|
let a = b.getLocalPoint(t, t.originX, t.originY, n.x, n.y), o = t, s = typeof o.signX == "number" && a.x * o.signX <= 0, c = typeof o.signY == "number" && a.y * o.signY <= 0, l = Math.abs(a.x / r), u = Math.abs(a.y / i);
|
|
@@ -7192,27 +7872,27 @@ var tr = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
7192
7872
|
stepScaleX: l,
|
|
7193
7873
|
stepScaleY: u
|
|
7194
7874
|
};
|
|
7195
|
-
},
|
|
7196
|
-
function
|
|
7875
|
+
}, qr = 1e-4;
|
|
7876
|
+
function Jr(e) {
|
|
7197
7877
|
return !!e && e instanceof _;
|
|
7198
7878
|
}
|
|
7199
|
-
function
|
|
7200
|
-
if (!
|
|
7879
|
+
function Yr(e) {
|
|
7880
|
+
if (!Jr(e)) return !1;
|
|
7201
7881
|
let t = e.group;
|
|
7202
7882
|
return e.shapeNodeType === "text" && t?.shapeComposite === !0;
|
|
7203
7883
|
}
|
|
7204
|
-
var
|
|
7884
|
+
var Xr = class {
|
|
7205
7885
|
constructor({ canvas: t, canvasManager: n, persistScaledTextbox: r }) {
|
|
7206
7886
|
this.handleMouseMove = (e) => {
|
|
7207
7887
|
let t = this.canvas._currentTransform;
|
|
7208
7888
|
if (!t) return;
|
|
7209
7889
|
let { target: n } = t;
|
|
7210
|
-
if (!
|
|
7890
|
+
if (!Jr(n) || Yr(n)) return;
|
|
7211
7891
|
let r = this.scalingState.get(n);
|
|
7212
7892
|
if (!r || !e.e) return;
|
|
7213
|
-
let { isCornerHandle: i, isHorizontalHandle: a, isVerticalHandle: o } =
|
|
7893
|
+
let { isCornerHandle: i, isHorizontalHandle: a, isVerticalHandle: o } = Wr({ transform: t });
|
|
7214
7894
|
if (!a && !o && !i) return;
|
|
7215
|
-
let s =
|
|
7895
|
+
let s = Kr({
|
|
7216
7896
|
textbox: n,
|
|
7217
7897
|
transform: t,
|
|
7218
7898
|
scenePoint: this.canvas.getScenePoint(e.e)
|
|
@@ -7235,33 +7915,34 @@ var qr = class {
|
|
|
7235
7915
|
}, j = r.lastAllowedScaleX, M = r.lastAllowedScaleY;
|
|
7236
7916
|
if (i) {
|
|
7237
7917
|
let e = Math.max(r.minimumProportionalScale, r.lastAllowedScaleX * Math.sqrt(u * d)), t = c || l ? r.minimumProportionalScale : e;
|
|
7238
|
-
if (Math.abs(t - r.lastAllowedScaleX) <=
|
|
7918
|
+
if (Math.abs(t - r.lastAllowedScaleX) <= qr) return;
|
|
7239
7919
|
j = t, M = t;
|
|
7240
7920
|
} else {
|
|
7241
7921
|
if (a) {
|
|
7242
7922
|
let e = r.lastAllowedScaleX * u, t = c ? r.minimumWidthScale : Math.max(r.minimumWidthScale, e);
|
|
7243
|
-
Math.abs(t - r.lastAllowedScaleX) >
|
|
7923
|
+
Math.abs(t - r.lastAllowedScaleX) > qr && (j = t);
|
|
7244
7924
|
}
|
|
7245
7925
|
if (o) {
|
|
7246
7926
|
let e = r.lastAllowedScaleY * d, t = l ? r.minimumFontScale : Math.max(r.minimumFontScale, e);
|
|
7247
|
-
Math.abs(t - r.lastAllowedScaleY) >
|
|
7927
|
+
Math.abs(t - r.lastAllowedScaleY) > qr && (M = t);
|
|
7248
7928
|
}
|
|
7249
|
-
if (Math.abs(j - r.lastAllowedScaleX) <=
|
|
7929
|
+
if (Math.abs(j - r.lastAllowedScaleX) <= qr && Math.abs(M - r.lastAllowedScaleY) <= qr) return;
|
|
7250
7930
|
}
|
|
7251
|
-
let { appliedWidth: N, dimensionsRounded: P } =
|
|
7931
|
+
let { appliedWidth: N, dimensionsRounded: P } = Ur({
|
|
7252
7932
|
textbox: n,
|
|
7253
7933
|
canvasManager: this.canvasManager,
|
|
7254
7934
|
base: r.startBase,
|
|
7935
|
+
placement: r.startObjectPlacement,
|
|
7936
|
+
anchorPlacement: m,
|
|
7255
7937
|
widthScale: j,
|
|
7256
7938
|
heightScale: M,
|
|
7257
|
-
placement: m,
|
|
7258
7939
|
shouldScaleFontSize: i || o,
|
|
7259
7940
|
shouldScalePadding: i || o,
|
|
7260
7941
|
shouldScaleRadii: i || o,
|
|
7261
7942
|
shouldDisableAutoExpandOnHorizontalChange: a,
|
|
7262
7943
|
shouldRoundDimensions: !i
|
|
7263
7944
|
});
|
|
7264
|
-
|
|
7945
|
+
Gr({
|
|
7265
7946
|
textbox: n,
|
|
7266
7947
|
transform: t,
|
|
7267
7948
|
appliedWidth: N
|
|
@@ -7282,47 +7963,48 @@ var qr = class {
|
|
|
7282
7963
|
}), this.canvas.requestRenderAll();
|
|
7283
7964
|
}, this.handleObjectScaling = (t) => {
|
|
7284
7965
|
let { target: n, transform: r } = t;
|
|
7285
|
-
if (n instanceof e || !
|
|
7966
|
+
if (n instanceof e || !Jr(n) || Yr(n) || !r) return;
|
|
7286
7967
|
n.isScaling = !0;
|
|
7287
7968
|
let i = this._ensureScalingState({
|
|
7288
7969
|
textbox: n,
|
|
7289
7970
|
transform: r
|
|
7290
|
-
}), { startBase: a } = i, { width: o, fontSize: s } = a, { isCornerHandle: c, isHorizontalHandle: l, isVerticalHandle: u } =
|
|
7971
|
+
}), { startBase: a } = i, { width: o, fontSize: s } = a, { isCornerHandle: c, isHorizontalHandle: l, isVerticalHandle: u } = Wr({ transform: r }), d = r.corner ?? "", f = c || u;
|
|
7291
7972
|
if (!l && !u && !c) return;
|
|
7292
7973
|
let p = n.scaleX ?? r.scaleX ?? 1, m = n.scaleY ?? r.scaleY ?? 1, h = Math.abs(p) || 1, g = Math.abs(m) || 1, _ = r.originX ?? n.originX ?? "center", v = r.originY ?? n.originY ?? "center", y = this.canvasManager.getObjectPlacement({
|
|
7293
7974
|
object: n,
|
|
7294
7975
|
originX: _,
|
|
7295
7976
|
originY: v
|
|
7296
|
-
}), { paddingTop: b = 0, paddingRight: x = 0, paddingBottom: S = 0, paddingLeft: C = 0, radiusTopLeft: w = 0, radiusTopRight: T = 0, radiusBottomRight: E = 0, radiusBottomLeft: D = 0, fontSize: O, width: k } = n, A = c || u, j = c || u, M = k ?? o, N = i.lastAllowedScaleX, P = i.lastAllowedScaleY, F = y,
|
|
7977
|
+
}), { paddingTop: b = 0, paddingRight: x = 0, paddingBottom: S = 0, paddingLeft: C = 0, radiusTopLeft: w = 0, radiusTopRight: T = 0, radiusBottomRight: E = 0, radiusBottomLeft: D = 0, fontSize: O, width: k } = n, A = c || u, j = c || u, M = k ?? o, N = i.lastAllowedScaleX, P = i.lastAllowedScaleY, F = y, I = !0;
|
|
7297
7978
|
if (c) {
|
|
7298
7979
|
let e = Math.sqrt(h * g), t = i.lastAllowedScaleX * e, n = p < 0 || m < 0, r = _ !== i.startTransformOriginX || v !== i.startTransformOriginY, a = d !== i.startTransformCorner;
|
|
7299
|
-
if (n || r || a) N = i.lastAllowedScaleX, P = i.lastAllowedScaleY, F = i.
|
|
7980
|
+
if (n || r || a) N = i.lastAllowedScaleX, P = i.lastAllowedScaleY, F = i.lastAllowedAnchorPlacement, I = !1;
|
|
7300
7981
|
else {
|
|
7301
7982
|
let e = Math.max(i.minimumProportionalScale, t);
|
|
7302
7983
|
N = e, P = e;
|
|
7303
7984
|
}
|
|
7304
7985
|
} else l && (N = Math.max(i.minimumWidthScale, i.lastAllowedScaleX * h)), u && (P = Math.max(i.minimumFontScale, i.lastAllowedScaleY * g));
|
|
7305
|
-
let { appliedWidth:
|
|
7986
|
+
let { appliedWidth: ee, dimensionsRounded: te } = Ur({
|
|
7306
7987
|
textbox: n,
|
|
7307
7988
|
canvasManager: this.canvasManager,
|
|
7308
7989
|
base: a,
|
|
7990
|
+
placement: i.startObjectPlacement,
|
|
7991
|
+
anchorPlacement: F,
|
|
7309
7992
|
widthScale: N,
|
|
7310
7993
|
heightScale: P,
|
|
7311
|
-
placement: F,
|
|
7312
7994
|
shouldScaleFontSize: f,
|
|
7313
7995
|
shouldScalePadding: A,
|
|
7314
7996
|
shouldScaleRadii: j,
|
|
7315
7997
|
shouldDisableAutoExpandOnHorizontalChange: l,
|
|
7316
7998
|
shouldRoundDimensions: !c
|
|
7317
7999
|
});
|
|
7318
|
-
|
|
8000
|
+
Gr({
|
|
7319
8001
|
textbox: n,
|
|
7320
8002
|
transform: r,
|
|
7321
|
-
appliedWidth:
|
|
7322
|
-
}), this.canvas.requestRenderAll(),
|
|
8003
|
+
appliedWidth: ee
|
|
8004
|
+
}), this.canvas.requestRenderAll(), I && this._updateScalingStateAfterLiveCommit({
|
|
7323
8005
|
textbox: n,
|
|
7324
8006
|
state: i,
|
|
7325
|
-
appliedWidth:
|
|
8007
|
+
appliedWidth: ee,
|
|
7326
8008
|
previousFontSize: O ?? s,
|
|
7327
8009
|
previousPadding: {
|
|
7328
8010
|
top: b,
|
|
@@ -7337,7 +8019,7 @@ var qr = class {
|
|
|
7337
8019
|
bottomLeft: D
|
|
7338
8020
|
},
|
|
7339
8021
|
previousWidth: M,
|
|
7340
|
-
dimensionsRounded:
|
|
8022
|
+
dimensionsRounded: te,
|
|
7341
8023
|
isCornerHandle: c,
|
|
7342
8024
|
isHorizontalHandle: l,
|
|
7343
8025
|
isVerticalHandle: u,
|
|
@@ -7348,7 +8030,7 @@ var qr = class {
|
|
|
7348
8030
|
let { target: n } = t;
|
|
7349
8031
|
if (n instanceof e) {
|
|
7350
8032
|
let t = n.getObjects();
|
|
7351
|
-
if (!t.some((e) =>
|
|
8033
|
+
if (!t.some((e) => Jr(e))) return;
|
|
7352
8034
|
let { scaleX: r = 1, scaleY: i = 1 } = n;
|
|
7353
8035
|
if (Math.abs(r - 1) < .01 && Math.abs(i - 1) < .01) return;
|
|
7354
8036
|
this.canvas.discardActiveObject(), t.forEach((e) => {
|
|
@@ -7358,7 +8040,7 @@ var qr = class {
|
|
|
7358
8040
|
this.canvas.setActiveObject(a), this.canvas.requestRenderAll();
|
|
7359
8041
|
return;
|
|
7360
8042
|
}
|
|
7361
|
-
if (!
|
|
8043
|
+
if (!Jr(n) || Yr(n)) return;
|
|
7362
8044
|
n.isScaling = !1;
|
|
7363
8045
|
let r = this.scalingState.get(n);
|
|
7364
8046
|
if (this.scalingState.delete(n), !r?.hasScalingChange) return;
|
|
@@ -7383,11 +8065,11 @@ var qr = class {
|
|
|
7383
8065
|
}, this.canvas = t, this.canvasManager = n, this.persistScaledTextbox = r, this.scalingState = /* @__PURE__ */ new WeakMap();
|
|
7384
8066
|
}
|
|
7385
8067
|
commitStandaloneTextScale({ target: e, shouldDisableAutoExpandOnHorizontalChange: t = !1 }) {
|
|
7386
|
-
if (!
|
|
8068
|
+
if (!Jr(e) || Yr(e)) return !1;
|
|
7387
8069
|
let n = Math.abs(e.scaleX ?? 1) || 1, r = Math.abs(e.scaleY ?? 1) || 1;
|
|
7388
8070
|
if (!(Math.abs(n - 1) > .01 || Math.abs(r - 1) > .01)) return !1;
|
|
7389
|
-
let i =
|
|
7390
|
-
return
|
|
8071
|
+
let i = Vr({ textbox: e }), a = this.canvasManager.getObjectPlacement({ object: e });
|
|
8072
|
+
return Ur({
|
|
7391
8073
|
textbox: e,
|
|
7392
8074
|
canvasManager: this.canvasManager,
|
|
7393
8075
|
base: i,
|
|
@@ -7403,22 +8085,23 @@ var qr = class {
|
|
|
7403
8085
|
_ensureScalingState({ textbox: e, transform: t }) {
|
|
7404
8086
|
let n = this.scalingState.get(e);
|
|
7405
8087
|
if (!n) {
|
|
7406
|
-
let r =
|
|
8088
|
+
let r = Vr({ textbox: e }), i = this.canvasManager.getObjectPlacement({ object: e }), a = Hr({ base: r }), o = t.original?.originX ?? t.originX ?? e.originX ?? "center", s = t.original?.originY ?? t.originY ?? e.originY ?? "center";
|
|
7407
8089
|
n = {
|
|
7408
8090
|
startBase: r,
|
|
8091
|
+
startObjectPlacement: i,
|
|
7409
8092
|
startTransformCorner: typeof t.corner == "string" ? t.corner : null,
|
|
7410
|
-
startTransformOriginX:
|
|
7411
|
-
startTransformOriginY:
|
|
8093
|
+
startTransformOriginX: o,
|
|
8094
|
+
startTransformOriginY: s,
|
|
7412
8095
|
lastAllowedScaleX: 1,
|
|
7413
8096
|
lastAllowedScaleY: 1,
|
|
7414
|
-
|
|
8097
|
+
lastAllowedAnchorPlacement: this.canvasManager.getObjectPlacement({
|
|
7415
8098
|
object: e,
|
|
7416
|
-
originX:
|
|
7417
|
-
originY:
|
|
8099
|
+
originX: o,
|
|
8100
|
+
originY: s
|
|
7418
8101
|
}),
|
|
7419
|
-
minimumWidthScale:
|
|
7420
|
-
minimumFontScale:
|
|
7421
|
-
minimumProportionalScale:
|
|
8102
|
+
minimumWidthScale: a.widthScale,
|
|
8103
|
+
minimumFontScale: a.fontScale,
|
|
8104
|
+
minimumProportionalScale: a.proportionalScale,
|
|
7422
8105
|
hasScalingChange: !1
|
|
7423
8106
|
}, this.scalingState.set(e, n);
|
|
7424
8107
|
}
|
|
@@ -7435,7 +8118,7 @@ var qr = class {
|
|
|
7435
8118
|
topRight: e.radiusTopRight ?? 0,
|
|
7436
8119
|
bottomRight: e.radiusBottomRight ?? 0,
|
|
7437
8120
|
bottomLeft: e.radiusBottomLeft ?? 0
|
|
7438
|
-
}, v = Math.abs(n - o) >
|
|
8121
|
+
}, v = Math.abs(n - o) > kr, y = Math.abs(h - r) > kr, b = Math.abs(g.top - i.top) > .01 || Math.abs(g.right - i.right) > .01 || Math.abs(g.bottom - i.bottom) > .01 || Math.abs(g.left - i.left) > .01, x = Math.abs(_.topLeft - a.topLeft) > .01 || Math.abs(_.topRight - a.topRight) > .01 || Math.abs(_.bottomRight - a.bottomRight) > .01 || Math.abs(_.bottomLeft - a.bottomLeft) > .01, S = t.lastAllowedScaleX, C = t.lastAllowedScaleY;
|
|
7439
8122
|
if (c) {
|
|
7440
8123
|
let e = h / Math.max(1, m);
|
|
7441
8124
|
S = e, C = e;
|
|
@@ -7450,13 +8133,13 @@ var qr = class {
|
|
|
7450
8133
|
}), t.hasScalingChange = t.hasScalingChange || v || y || b || x || s;
|
|
7451
8134
|
}
|
|
7452
8135
|
_storeLastAllowedScalingState({ textbox: e, state: t, widthScale: n, heightScale: r, originX: i, originY: a }) {
|
|
7453
|
-
t.lastAllowedScaleX = n, t.lastAllowedScaleY = r, t.
|
|
8136
|
+
t.lastAllowedScaleX = n, t.lastAllowedScaleY = r, t.lastAllowedAnchorPlacement = this.canvasManager.getObjectPlacement({
|
|
7454
8137
|
object: e,
|
|
7455
8138
|
originX: i,
|
|
7456
8139
|
originY: a
|
|
7457
8140
|
});
|
|
7458
8141
|
}
|
|
7459
|
-
},
|
|
8142
|
+
}, Zr = ({ textbox: e }) => {
|
|
7460
8143
|
let t = e.text ?? "";
|
|
7461
8144
|
if (!t.length) return [];
|
|
7462
8145
|
let n = t.split("\n"), r = [], i = 0;
|
|
@@ -7468,7 +8151,7 @@ var qr = class {
|
|
|
7468
8151
|
});
|
|
7469
8152
|
}
|
|
7470
8153
|
return r;
|
|
7471
|
-
},
|
|
8154
|
+
}, Qr = ({ range: e, text: t }) => {
|
|
7472
8155
|
if (!e) return null;
|
|
7473
8156
|
let n = t.length;
|
|
7474
8157
|
if (n <= 0) return null;
|
|
@@ -7477,8 +8160,8 @@ var qr = class {
|
|
|
7477
8160
|
start: l,
|
|
7478
8161
|
end: u
|
|
7479
8162
|
};
|
|
7480
|
-
},
|
|
7481
|
-
let n =
|
|
8163
|
+
}, $r = ({ textbox: e, range: t }) => {
|
|
8164
|
+
let n = Zr({ textbox: e });
|
|
7482
8165
|
if (!n.length) return t;
|
|
7483
8166
|
let { start: r } = t, { end: i } = t;
|
|
7484
8167
|
for (let e = 0; e < n.length; e += 1) {
|
|
@@ -7491,7 +8174,7 @@ var qr = class {
|
|
|
7491
8174
|
start: r,
|
|
7492
8175
|
end: i
|
|
7493
8176
|
};
|
|
7494
|
-
},
|
|
8177
|
+
}, ei = ({ textbox: e, range: t }) => {
|
|
7495
8178
|
let n = e.text ?? "";
|
|
7496
8179
|
if (!n.length) return [];
|
|
7497
8180
|
let { start: r, end: i } = t, a = n.split("\n"), o = [], s = 0;
|
|
@@ -7500,7 +8183,7 @@ var qr = class {
|
|
|
7500
8183
|
i > n && r < c && o.push(e), s = c + 1;
|
|
7501
8184
|
}
|
|
7502
8185
|
return o;
|
|
7503
|
-
},
|
|
8186
|
+
}, ti = ({ textbox: e, range: t }) => {
|
|
7504
8187
|
let n = e.text ?? "";
|
|
7505
8188
|
if (!n.length) return [];
|
|
7506
8189
|
let { start: r, end: i } = t, a = n.split("\n"), o = [], s = 0;
|
|
@@ -7509,20 +8192,20 @@ var qr = class {
|
|
|
7509
8192
|
r <= n && i >= c && o.push(e), s = c + 1;
|
|
7510
8193
|
}
|
|
7511
8194
|
return o;
|
|
7512
|
-
},
|
|
8195
|
+
}, ni = ({ previous: e, next: t }) => {
|
|
7513
8196
|
let n = Math.min(e.length, t.length);
|
|
7514
8197
|
for (let r = 0; r < n; r += 1) if (e[r] !== t[r]) return r;
|
|
7515
8198
|
return n;
|
|
7516
|
-
},
|
|
8199
|
+
}, ri = ({ text: e, charIndex: t }) => {
|
|
7517
8200
|
let n = Math.max(0, Math.min(t, e.length)), r = 0;
|
|
7518
8201
|
for (let t = 0; t < n; t += 1) e[t] === "\n" && (r += 1);
|
|
7519
8202
|
return r;
|
|
7520
|
-
},
|
|
8203
|
+
}, ii = ({ text: e, lineIndex: t }) => {
|
|
7521
8204
|
if (t <= 0) return 0;
|
|
7522
8205
|
let n = 0;
|
|
7523
8206
|
for (let r = 0; r < e.length; r += 1) if (e[r] === "\n" && (n += 1, n === t)) return r + 1;
|
|
7524
8207
|
return e.length;
|
|
7525
|
-
},
|
|
8208
|
+
}, ai = class e {
|
|
7526
8209
|
constructor({ editor: t }) {
|
|
7527
8210
|
this._handleTextEditingEntered = (t) => {
|
|
7528
8211
|
this.isTextEditingActive = !0;
|
|
@@ -7535,7 +8218,7 @@ var qr = class {
|
|
|
7535
8218
|
if (!e._isTextbox(n) || this.lineDefaultsSyncing.has(n)) return;
|
|
7536
8219
|
let r = e._isShapeOwnedTextbox(n), { text: i = "", uppercase: a, autoExpand: o } = n, s = !!a, c = o !== !1, l = i.toLocaleLowerCase(), u = r ? null : this.editingPlacementState?.get(n) ?? this.editor.canvasManager.getObjectPlacement({ object: n });
|
|
7537
8220
|
if (s) {
|
|
7538
|
-
let e =
|
|
8221
|
+
let e = Tr({ value: l });
|
|
7539
8222
|
e !== i && n.set({ text: e }), n.textCaseRaw = l;
|
|
7540
8223
|
} else n.textCaseRaw = i;
|
|
7541
8224
|
if (!r && o === void 0 && (n.autoExpand = !0), r) {
|
|
@@ -7553,7 +8236,7 @@ var qr = class {
|
|
|
7553
8236
|
let r = e._isShapeOwnedTextbox(n);
|
|
7554
8237
|
this.editingPlacementState?.delete(n);
|
|
7555
8238
|
let i = n.text ?? "";
|
|
7556
|
-
n.uppercase ? n.textCaseRaw = n.textCaseRaw ?? i.toLocaleLowerCase() : n.textCaseRaw = i, r || (
|
|
8239
|
+
n.uppercase ? n.textCaseRaw = n.textCaseRaw ?? i.toLocaleLowerCase() : n.textCaseRaw = i, r || (Br({ textbox: n }) && (n.setCoords(), n.dirty = !0, this.canvas.requestRenderAll()), n.locked || n.set({
|
|
7557
8240
|
lockMovementX: !1,
|
|
7558
8241
|
lockMovementY: !1
|
|
7559
8242
|
}));
|
|
@@ -7580,7 +8263,7 @@ var qr = class {
|
|
|
7580
8263
|
transform: r,
|
|
7581
8264
|
event: i ?? null
|
|
7582
8265
|
});
|
|
7583
|
-
}, this.editor = t, this.canvas = t.canvas, this.fonts = t.options.fonts ?? [], this.scalingController = new
|
|
8266
|
+
}, this.editor = t, this.canvas = t.canvas, this.fonts = t.options.fonts ?? [], this.scalingController = new Xr({
|
|
7584
8267
|
canvas: t.canvas,
|
|
7585
8268
|
canvasManager: t.canvasManager,
|
|
7586
8269
|
persistScaledTextbox: ({ target: e, style: t }) => {
|
|
@@ -7589,17 +8272,17 @@ var qr = class {
|
|
|
7589
8272
|
style: t
|
|
7590
8273
|
});
|
|
7591
8274
|
}
|
|
7592
|
-
}), this.editingPlacementState = /* @__PURE__ */ new WeakMap(), this.lineDefaultsSyncing = /* @__PURE__ */ new WeakSet(), this.isTextEditingActive = !1, this._bindEvents(),
|
|
8275
|
+
}), this.editingPlacementState = /* @__PURE__ */ new WeakMap(), this.lineDefaultsSyncing = /* @__PURE__ */ new WeakSet(), this.isTextEditingActive = !1, this._bindEvents(), Or();
|
|
7593
8276
|
}
|
|
7594
|
-
addText({ id: t = `text-${D()}`, text: n = "Новый текст", autoExpand: r = !0, fontFamily: i, fontSize: a = 48, bold: o = !1, italic: s = !1, underline: c = !1, uppercase: l = !1, strikethrough: u = !1, align: d = "left", color: f = "#000000", strokeColor: p, strokeWidth: m = 0, opacity: h = 1, backgroundColor: g, backgroundOpacity: _ = 1, paddingTop: v = 0, paddingRight: y = 0, paddingBottom: b = 0, paddingLeft: x = 0, radiusTopLeft: S = 0, radiusTopRight: C = 0, radiusBottomRight: w = 0, radiusBottomLeft: T = 0, ...E } = {}, { withoutSelection: O = !1, withoutSave: k = !1, withoutAdding: A = !1 } = {}) {
|
|
7595
|
-
let { canvasManager:
|
|
7596
|
-
|
|
7597
|
-
let
|
|
8277
|
+
addText({ id: t = `text-${D()}`, text: n = "Новый текст", autoExpand: r = !0, fontFamily: i, fontSize: a = 48, bold: o = !1, italic: s = !1, underline: c = !1, uppercase: l = !1, strikethrough: u = !1, align: d = "left", color: f = "#000000", strokeColor: p, strokeWidth: m = 0, opacity: h = 1, backgroundColor: g, backgroundOpacity: _ = 1, paddingTop: v = 0, paddingRight: y = 0, paddingBottom: b = 0, paddingLeft: x = 0, radiusTopLeft: S = 0, radiusTopRight: C = 0, radiusBottomRight: w = 0, radiusBottomLeft: T = 0, ...E } = {}, { withoutSelection: O = !1, withoutSave: k = !1, withoutAdding: A = !1, emitLifecycleEvents: j = !0 } = {}) {
|
|
8278
|
+
let { canvasManager: M, historyManager: N } = this.editor, { canvas: P } = this;
|
|
8279
|
+
N.suspendHistory();
|
|
8280
|
+
let F = i ?? this._getDefaultFontFamily(), I = wr({ width: m }), ee = Cr({
|
|
7598
8281
|
strokeColor: p,
|
|
7599
|
-
width:
|
|
8282
|
+
width: I
|
|
7600
8283
|
}), te = {
|
|
7601
8284
|
id: t,
|
|
7602
|
-
fontFamily:
|
|
8285
|
+
fontFamily: F,
|
|
7603
8286
|
fontSize: a,
|
|
7604
8287
|
fontWeight: o ? "bold" : "normal",
|
|
7605
8288
|
fontStyle: s ? "italic" : "normal",
|
|
@@ -7609,7 +8292,7 @@ var qr = class {
|
|
|
7609
8292
|
textAlign: d,
|
|
7610
8293
|
fill: f,
|
|
7611
8294
|
stroke: ee,
|
|
7612
|
-
strokeWidth:
|
|
8295
|
+
strokeWidth: I,
|
|
7613
8296
|
strokeUniform: !0,
|
|
7614
8297
|
opacity: h,
|
|
7615
8298
|
backgroundColor: g,
|
|
@@ -7623,31 +8306,31 @@ var qr = class {
|
|
|
7623
8306
|
radiusBottomRight: w,
|
|
7624
8307
|
radiusBottomLeft: T,
|
|
7625
8308
|
...E
|
|
7626
|
-
},
|
|
7627
|
-
|
|
8309
|
+
}, L = new Dr(n, te), ne = r !== !1;
|
|
8310
|
+
L.autoExpand = ne;
|
|
7628
8311
|
let re = E.left !== void 0 || E.top !== void 0;
|
|
7629
|
-
if (
|
|
7630
|
-
let e =
|
|
7631
|
-
e !==
|
|
7632
|
-
}
|
|
7633
|
-
|
|
7634
|
-
let
|
|
7635
|
-
re && (
|
|
7636
|
-
object:
|
|
8312
|
+
if (L.textCaseRaw = L.text ?? "", l) {
|
|
8313
|
+
let e = Tr({ value: L.textCaseRaw });
|
|
8314
|
+
e !== L.text && L.set({ text: e });
|
|
8315
|
+
}
|
|
8316
|
+
Br({ textbox: L }) && (L.dirty = !0);
|
|
8317
|
+
let R;
|
|
8318
|
+
re && (R = M.resolveObjectPlacement({
|
|
8319
|
+
object: L,
|
|
7637
8320
|
left: E.left,
|
|
7638
8321
|
top: E.top,
|
|
7639
8322
|
originX: E.originX,
|
|
7640
8323
|
originY: E.originY,
|
|
7641
|
-
fallbackPoint:
|
|
8324
|
+
fallbackPoint: M.getMontageAreaSceneCenter()
|
|
7642
8325
|
}));
|
|
7643
|
-
let ie = ne && e._hasWrappedLinesBeyondExplicitBreaks(
|
|
8326
|
+
let ie = ne && e._hasWrappedLinesBeyondExplicitBreaks(L);
|
|
7644
8327
|
return (re || ie) && this._normalizeTextboxAfterContentChange({
|
|
7645
|
-
textbox:
|
|
7646
|
-
placement:
|
|
8328
|
+
textbox: L,
|
|
8329
|
+
placement: R,
|
|
7647
8330
|
shouldAutoExpand: ie,
|
|
7648
8331
|
clampToMontage: re
|
|
7649
|
-
}),
|
|
7650
|
-
textbox:
|
|
8332
|
+
}), R || M.centerObjectToMontageArea({ object: L }), A || P.add(L), O || P.setActiveObject(L), P.requestRenderAll(), N.resumeHistory(), k || N.saveState(), j && P.fire("editor:text-added", {
|
|
8333
|
+
textbox: L,
|
|
7651
8334
|
options: {
|
|
7652
8335
|
...te,
|
|
7653
8336
|
text: n,
|
|
@@ -7657,144 +8340,171 @@ var qr = class {
|
|
|
7657
8340
|
align: d,
|
|
7658
8341
|
color: f,
|
|
7659
8342
|
strokeColor: ee,
|
|
7660
|
-
strokeWidth:
|
|
8343
|
+
strokeWidth: I
|
|
7661
8344
|
},
|
|
7662
8345
|
flags: {
|
|
7663
8346
|
withoutSelection: !!O,
|
|
7664
8347
|
withoutSave: !!k,
|
|
7665
8348
|
withoutAdding: !!A
|
|
7666
8349
|
}
|
|
7667
|
-
}),
|
|
8350
|
+
}), L;
|
|
7668
8351
|
}
|
|
7669
|
-
updateText({ target: t, style: n = {}, withoutSave: r, skipRender: i, selectionRange: a } = {}) {
|
|
7670
|
-
let
|
|
7671
|
-
if (!
|
|
7672
|
-
let { text:
|
|
7673
|
-
|
|
7674
|
-
let
|
|
7675
|
-
object:
|
|
8352
|
+
updateText({ target: t, style: n = {}, withoutSave: r, skipRender: i, selectionRange: a, emitLifecycleEvents: o = !0 } = {}) {
|
|
8353
|
+
let s = this._resolveTextObject(t);
|
|
8354
|
+
if (!s) return null;
|
|
8355
|
+
let { text: c = "" } = s, { historyManager: l } = this.editor, { canvasManager: u } = this.editor, { canvas: d } = this;
|
|
8356
|
+
l.suspendHistory();
|
|
8357
|
+
let f = e._getSnapshot(s), { text: p, autoExpand: m, fontFamily: h, fontSize: g, bold: _, italic: v, underline: y, uppercase: b, strikethrough: x, align: S, color: C, strokeColor: w, strokeWidth: T, opacity: E, backgroundColor: D, backgroundOpacity: O, paddingTop: k, paddingRight: A, paddingBottom: j, paddingLeft: M, radiusTopLeft: N, radiusTopRight: P, radiusBottomRight: F, radiusBottomLeft: I, left: ee, top: te, originX: L, originY: ne, ...re } = n, R = { ...re }, ie = u.resolveObjectPlacement({
|
|
8358
|
+
object: s,
|
|
7676
8359
|
left: ee,
|
|
7677
8360
|
top: te,
|
|
7678
|
-
originX:
|
|
8361
|
+
originX: L,
|
|
7679
8362
|
originY: ne
|
|
7680
|
-
}),
|
|
7681
|
-
text:
|
|
8363
|
+
}), z = a === void 0 ? vr({ textbox: s }) : Qr({
|
|
8364
|
+
text: c,
|
|
7682
8365
|
range: a
|
|
7683
|
-
}),
|
|
7684
|
-
textbox:
|
|
7685
|
-
range:
|
|
7686
|
-
}) : null,
|
|
7687
|
-
textbox:
|
|
7688
|
-
range:
|
|
7689
|
-
}),
|
|
7690
|
-
if (
|
|
7691
|
-
let e =
|
|
7692
|
-
|
|
7693
|
-
}
|
|
7694
|
-
if (
|
|
7695
|
-
let e =
|
|
7696
|
-
|
|
7697
|
-
}
|
|
7698
|
-
if (
|
|
7699
|
-
let e =
|
|
7700
|
-
textbox:
|
|
7701
|
-
range:
|
|
8366
|
+
}), B = z ? $r({
|
|
8367
|
+
textbox: s,
|
|
8368
|
+
range: z
|
|
8369
|
+
}) : null, V = {}, H = {}, U = {}, ae, oe, se = br({
|
|
8370
|
+
textbox: s,
|
|
8371
|
+
range: z
|
|
8372
|
+
}), ce = !z || se, le = !z;
|
|
8373
|
+
if (h !== void 0 && (B && (H.fontFamily = h), ce && (R.fontFamily = h, le && (U.fontFamily = h))), g !== void 0 && (B && (H.fontSize = g), ce && (R.fontSize = g, le && (U.fontSize = g))), _ !== void 0) {
|
|
8374
|
+
let e = _ ? "bold" : "normal";
|
|
8375
|
+
z && (V.fontWeight = e), ce && (R.fontWeight = e, le && (U.fontWeight = e));
|
|
8376
|
+
}
|
|
8377
|
+
if (v !== void 0) {
|
|
8378
|
+
let e = v ? "italic" : "normal";
|
|
8379
|
+
z && (V.fontStyle = e), ce && (R.fontStyle = e, le && (U.fontStyle = e));
|
|
8380
|
+
}
|
|
8381
|
+
if (y !== void 0 && (z && (V.underline = y), ce && (R.underline = y, le && (U.underline = y))), x !== void 0 && (z && (V.linethrough = x), ce && (R.linethrough = x, le && (U.linethrough = x))), S !== void 0 && (R.textAlign = S), C !== void 0 && (z && (V.fill = C), ce && (R.fill = C, le && (U.fill = C))), w !== void 0 || T !== void 0) {
|
|
8382
|
+
let e = z ? Sr({
|
|
8383
|
+
textbox: s,
|
|
8384
|
+
range: z,
|
|
7702
8385
|
property: "strokeWidth"
|
|
7703
|
-
}) : void 0, t =
|
|
7704
|
-
textbox:
|
|
7705
|
-
range:
|
|
8386
|
+
}) : void 0, t = z ? Sr({
|
|
8387
|
+
textbox: s,
|
|
8388
|
+
range: z,
|
|
7706
8389
|
property: "stroke"
|
|
7707
8390
|
}) : void 0;
|
|
7708
|
-
|
|
7709
|
-
strokeColor:
|
|
7710
|
-
width:
|
|
7711
|
-
}),
|
|
7712
|
-
}
|
|
7713
|
-
|
|
7714
|
-
let ue =
|
|
7715
|
-
fe || he ? (
|
|
7716
|
-
let ge =
|
|
7717
|
-
|
|
7718
|
-
|
|
7719
|
-
|
|
7720
|
-
|
|
7721
|
-
|
|
7722
|
-
|
|
7723
|
-
|
|
7724
|
-
|
|
7725
|
-
|
|
8391
|
+
oe = wr({ width: T ?? e ?? s.strokeWidth ?? 0 }), ae = Cr({
|
|
8392
|
+
strokeColor: w ?? t ?? s.stroke ?? void 0,
|
|
8393
|
+
width: oe
|
|
8394
|
+
}), z && (V.stroke = ae, V.strokeWidth = oe), ce && (R.stroke = ae, R.strokeWidth = oe, le && (U.stroke = ae, U.strokeWidth = oe));
|
|
8395
|
+
}
|
|
8396
|
+
E !== void 0 && (R.opacity = E), D !== void 0 && (R.backgroundColor = D), O !== void 0 && (R.backgroundOpacity = O), k !== void 0 && (R.paddingTop = k), A !== void 0 && (R.paddingRight = A), j !== void 0 && (R.paddingBottom = j), M !== void 0 && (R.paddingLeft = M), N !== void 0 && (R.radiusTopLeft = N), P !== void 0 && (R.radiusTopRight = P), F !== void 0 && (R.radiusBottomRight = F), I !== void 0 && (R.radiusBottomLeft = I);
|
|
8397
|
+
let ue = s.textCaseRaw ?? c, de = !!s.uppercase, fe = p !== void 0, pe = fe ? p ?? "" : ue, me = b ?? de, he = me !== de;
|
|
8398
|
+
fe || he ? (R.text = me ? Tr({ value: pe }) : pe, s.textCaseRaw = pe) : s.textCaseRaw === void 0 && (s.textCaseRaw = ue);
|
|
8399
|
+
let ge = zr({ stylesList: [
|
|
8400
|
+
R,
|
|
8401
|
+
V,
|
|
8402
|
+
H,
|
|
8403
|
+
U
|
|
8404
|
+
] }), _e = [
|
|
8405
|
+
ee,
|
|
8406
|
+
te,
|
|
8407
|
+
L,
|
|
8408
|
+
ne
|
|
8409
|
+
], ve = [
|
|
8410
|
+
k,
|
|
8411
|
+
A,
|
|
8412
|
+
j,
|
|
8413
|
+
M
|
|
8414
|
+
], ye = _e.some((e) => e !== void 0), be = ve.some((e) => e !== void 0), xe = Object.prototype.hasOwnProperty.call(R, "width"), Se = be && !ye && !fe && !he && !ge && !xe, Ce = null;
|
|
8415
|
+
Se && (Ce = Ir({
|
|
8416
|
+
textbox: s,
|
|
8417
|
+
originX: ie.originX,
|
|
8418
|
+
originY: ie.originY
|
|
8419
|
+
})), s.uppercase = me, s.set(R);
|
|
8420
|
+
let we = !1;
|
|
8421
|
+
if (z) {
|
|
8422
|
+
let e = xr({
|
|
8423
|
+
textbox: s,
|
|
8424
|
+
styles: V,
|
|
8425
|
+
range: z
|
|
8426
|
+
}), t = B ? xr({
|
|
8427
|
+
textbox: s,
|
|
8428
|
+
styles: H,
|
|
8429
|
+
range: B
|
|
7726
8430
|
}) : !1;
|
|
7727
|
-
|
|
7728
|
-
} else if (Object.keys(
|
|
7729
|
-
let e =
|
|
7730
|
-
e && (
|
|
7731
|
-
textbox:
|
|
7732
|
-
styles:
|
|
8431
|
+
we = e || t;
|
|
8432
|
+
} else if (Object.keys(U).length) {
|
|
8433
|
+
let e = yr({ textbox: s });
|
|
8434
|
+
e && (we = xr({
|
|
8435
|
+
textbox: s,
|
|
8436
|
+
styles: U,
|
|
7733
8437
|
range: e
|
|
7734
8438
|
}));
|
|
7735
8439
|
}
|
|
7736
|
-
let
|
|
7737
|
-
|
|
7738
|
-
|
|
7739
|
-
|
|
8440
|
+
let Te = we && zr({ stylesList: [
|
|
8441
|
+
V,
|
|
8442
|
+
H,
|
|
8443
|
+
U
|
|
7740
8444
|
] });
|
|
7741
|
-
if (
|
|
7742
|
-
let e =
|
|
7743
|
-
textbox:
|
|
7744
|
-
range:
|
|
8445
|
+
if (we && (s.dirty = !0), B && (h !== void 0 || g !== void 0)) {
|
|
8446
|
+
let e = ei({
|
|
8447
|
+
textbox: s,
|
|
8448
|
+
range: B
|
|
7745
8449
|
}), t = {};
|
|
7746
|
-
|
|
7747
|
-
textbox:
|
|
8450
|
+
h !== void 0 && (t.fontFamily = h), g !== void 0 && (t.fontSize = g), Ar({
|
|
8451
|
+
textbox: s,
|
|
7748
8452
|
lineIndices: e,
|
|
7749
8453
|
updates: t
|
|
7750
8454
|
});
|
|
7751
8455
|
}
|
|
7752
|
-
if (
|
|
7753
|
-
let e =
|
|
7754
|
-
textbox:
|
|
7755
|
-
range:
|
|
8456
|
+
if (z && (C !== void 0 || w !== void 0 || T !== void 0)) {
|
|
8457
|
+
let e = ti({
|
|
8458
|
+
textbox: s,
|
|
8459
|
+
range: z
|
|
7756
8460
|
}), t = {};
|
|
7757
|
-
|
|
7758
|
-
textbox:
|
|
8461
|
+
C !== void 0 && (t.fill = C), (w !== void 0 || T !== void 0) && (ae === null && (t.stroke = null), ae != null && (t.stroke = ae)), Ar({
|
|
8462
|
+
textbox: s,
|
|
7759
8463
|
lineIndices: e,
|
|
7760
8464
|
updates: t
|
|
7761
8465
|
});
|
|
7762
8466
|
}
|
|
7763
|
-
|
|
7764
|
-
|
|
7765
|
-
|
|
7766
|
-
|
|
7767
|
-
|
|
7768
|
-
|
|
7769
|
-
|
|
7770
|
-
|
|
7771
|
-
|
|
8467
|
+
Te && (s.initDimensions(), s.dirty = !0), [
|
|
8468
|
+
D,
|
|
8469
|
+
O,
|
|
8470
|
+
...ve,
|
|
8471
|
+
N,
|
|
8472
|
+
P,
|
|
8473
|
+
F,
|
|
8474
|
+
I
|
|
8475
|
+
].some((e) => e !== void 0) && (s.dirty = !0);
|
|
8476
|
+
let { autoExpand: Ee } = s, De = m !== void 0, Oe = (m ?? Ee) !== !1;
|
|
8477
|
+
De ? s.autoExpand = m !== !1 : Ee === void 0 && (s.autoExpand = !0);
|
|
8478
|
+
let ke = Oe && !xe && (fe || he || ge);
|
|
7772
8479
|
this._normalizeTextboxAfterContentChange({
|
|
7773
|
-
textbox:
|
|
8480
|
+
textbox: s,
|
|
7774
8481
|
placement: ie,
|
|
7775
|
-
shouldAutoExpand:
|
|
7776
|
-
}),
|
|
7777
|
-
|
|
8482
|
+
shouldAutoExpand: ke
|
|
8483
|
+
}), Ce && this._restoreTextboxContentPlacement({
|
|
8484
|
+
textbox: s,
|
|
8485
|
+
contentPlacement: Ce
|
|
8486
|
+
}), s.setCoords();
|
|
8487
|
+
let Ae = {
|
|
7778
8488
|
withoutSave: !!r,
|
|
7779
8489
|
skipRender: !!i
|
|
7780
|
-
},
|
|
7781
|
-
textbox:
|
|
8490
|
+
}, je = !!z && Object.keys(V).length > 0, Me = {
|
|
8491
|
+
textbox: s,
|
|
7782
8492
|
target: t,
|
|
7783
8493
|
style: n,
|
|
7784
|
-
options:
|
|
7785
|
-
updates:
|
|
7786
|
-
selectionRange:
|
|
7787
|
-
selectionStyles:
|
|
8494
|
+
options: Ae,
|
|
8495
|
+
updates: R,
|
|
8496
|
+
selectionRange: z ?? void 0,
|
|
8497
|
+
selectionStyles: je ? V : void 0
|
|
7788
8498
|
};
|
|
7789
|
-
|
|
7790
|
-
let
|
|
7791
|
-
|
|
7792
|
-
let
|
|
7793
|
-
...
|
|
7794
|
-
before:
|
|
7795
|
-
after:
|
|
8499
|
+
o && d.fire("editor:before:text-updated", Me), i || d.requestRenderAll();
|
|
8500
|
+
let Ne = e._getSnapshot(s);
|
|
8501
|
+
l.resumeHistory(), r || l.saveState();
|
|
8502
|
+
let Pe = {
|
|
8503
|
+
...Me,
|
|
8504
|
+
before: f,
|
|
8505
|
+
after: Ne
|
|
7796
8506
|
};
|
|
7797
|
-
return
|
|
8507
|
+
return o && d.fire("editor:text-updated", Pe), s;
|
|
7798
8508
|
}
|
|
7799
8509
|
stylesFromArray(e, t) {
|
|
7800
8510
|
return C.stylesFromArray(e, t);
|
|
@@ -7843,13 +8553,27 @@ var qr = class {
|
|
|
7843
8553
|
clampToMontage: r
|
|
7844
8554
|
}));
|
|
7845
8555
|
let a = !1;
|
|
7846
|
-
i || (a =
|
|
8556
|
+
i || (a = Br({ textbox: e }));
|
|
7847
8557
|
let o = !1;
|
|
7848
8558
|
return !i && t && (this.editor.canvasManager.applyObjectPlacement({
|
|
7849
8559
|
object: e,
|
|
7850
8560
|
placement: t
|
|
7851
8561
|
}), o = !0), (i || a) && (e.dirty = !0), (i || a || o) && e.setCoords(), i || a;
|
|
7852
8562
|
}
|
|
8563
|
+
_restoreTextboxContentPlacement({ textbox: e, contentPlacement: t }) {
|
|
8564
|
+
let n = Ir({
|
|
8565
|
+
textbox: e,
|
|
8566
|
+
originX: t.originX,
|
|
8567
|
+
originY: t.originY
|
|
8568
|
+
}), r = this.editor.canvasManager.getObjectPlacement({
|
|
8569
|
+
object: e,
|
|
8570
|
+
originX: "center",
|
|
8571
|
+
originY: "center"
|
|
8572
|
+
}), i = t.left - n.left, a = t.top - n.top;
|
|
8573
|
+
if (Math.abs(i) <= .01 && Math.abs(a) <= .01) return !1;
|
|
8574
|
+
let o = new p(r.left + i, r.top + a), s = e;
|
|
8575
|
+
return typeof s.setXY == "function" ? s.setXY(o, "center", "center") : e.setPositionByOrigin(o, "center", "center"), e.setCoords(), !0;
|
|
8576
|
+
}
|
|
7853
8577
|
_bindEvents() {
|
|
7854
8578
|
let { canvas: e } = this;
|
|
7855
8579
|
e.on("object:scaling", this.scalingController.handleObjectScaling), e.on("object:resizing", this._handleObjectResizing), e.on("object:modified", this.scalingController.handleObjectModified), e.on("mouse:move", this.scalingController.handleMouseMove), e.on("text:editing:entered", this._handleTextEditingEntered), e.on("text:editing:exited", this._handleTextEditingExited), e.on("text:changed", this._handleTextChanged);
|
|
@@ -7857,15 +8581,15 @@ var qr = class {
|
|
|
7857
8581
|
_syncLineFontDefaultsOnTextChanged({ textbox: e }) {
|
|
7858
8582
|
let { text: t = "", lineFontDefaults: n, styles: r, fontFamily: i, fontSize: a, fill: o, stroke: s, selectionStart: c, isEditing: l } = e, u = t, d = e.__lineDefaultsPrevText ?? u, f = d.split("\n"), p = u.split("\n"), m = f.length, h = p.length - m, g = n, _ = !1, v = !1, y = typeof o == "string" ? o : void 0, b = typeof s == "string" ? s : void 0;
|
|
7859
8583
|
if (h !== 0 && n && Object.keys(n).length) {
|
|
7860
|
-
let e =
|
|
8584
|
+
let e = ni({
|
|
7861
8585
|
previous: d,
|
|
7862
8586
|
next: u
|
|
7863
|
-
}), t =
|
|
8587
|
+
}), t = ri({
|
|
7864
8588
|
text: d,
|
|
7865
8589
|
charIndex: e
|
|
7866
8590
|
});
|
|
7867
8591
|
if (h > 0) {
|
|
7868
|
-
let r =
|
|
8592
|
+
let r = ii({
|
|
7869
8593
|
text: d,
|
|
7870
8594
|
lineIndex: t
|
|
7871
8595
|
}), i = t + 1;
|
|
@@ -7906,7 +8630,7 @@ var qr = class {
|
|
|
7906
8630
|
let t = p[e] ?? "", n = g ? g[e] : void 0;
|
|
7907
8631
|
if (n && (T = n), t.length !== 0) {
|
|
7908
8632
|
if (n) {
|
|
7909
|
-
let r =
|
|
8633
|
+
let r = jr({
|
|
7910
8634
|
lineText: t,
|
|
7911
8635
|
lineStyles: S ? S[e] : void 0,
|
|
7912
8636
|
lineDefaults: n
|
|
@@ -7946,16 +8670,16 @@ var qr = class {
|
|
|
7946
8670
|
if (!Number.isFinite(f) || f <= 0) return !1;
|
|
7947
8671
|
let p = a.split("\n").length, m = !1;
|
|
7948
8672
|
Math.abs((e.width ?? 0) - f) > .01 && (e.set({ width: f }), m = !0), e.initDimensions();
|
|
7949
|
-
let { textLines: h } = e, g = Array.isArray(h) && h.length > p, _ = Math.ceil(
|
|
8673
|
+
let { textLines: h } = e, g = Array.isArray(h) && h.length > p, _ = Math.ceil(Pr({
|
|
7950
8674
|
textbox: e,
|
|
7951
8675
|
text: a
|
|
7952
8676
|
})), v = Math.min(e.minWidth ?? 1, f), y = Math.min(f, Math.max(_, v));
|
|
7953
|
-
g && (y = f), Math.abs((e.width ?? 0) - y) > .01 && (e.set({ width: y }), e.initDimensions(), m = !0),
|
|
8677
|
+
g && (y = f), Math.abs((e.width ?? 0) - y) > .01 && (e.set({ width: y }), e.initDimensions(), m = !0), Br({ textbox: e }) && (m = !0), t && r.applyObjectPlacement({
|
|
7954
8678
|
object: e,
|
|
7955
8679
|
placement: t
|
|
7956
8680
|
});
|
|
7957
8681
|
let b = !1;
|
|
7958
|
-
return n && (b =
|
|
8682
|
+
return n && (b = Lr({
|
|
7959
8683
|
textbox: e,
|
|
7960
8684
|
montageLeft: o,
|
|
7961
8685
|
montageRight: o + s
|
|
@@ -8013,7 +8737,7 @@ var qr = class {
|
|
|
8013
8737
|
_getDefaultFontFamily() {
|
|
8014
8738
|
return this.fonts[0]?.family ?? "Arial";
|
|
8015
8739
|
}
|
|
8016
|
-
},
|
|
8740
|
+
}, oi = ({ x1: e, y1: t, x2: n, y2: r }) => (Math.atan2(r - t, n - e) * 180 / Math.PI + 360) % 360, si = (e) => {
|
|
8017
8741
|
if (!e || typeof e != "object") return null;
|
|
8018
8742
|
let { type: t, coords: n, colorStops: r } = e, i = Array.isArray(r) ? r : [], a = i[0], o = i[i.length - 1], s = typeof a?.color == "string" ? a.color : void 0, c = typeof o?.color == "string" ? o.color : s, l = typeof a?.offset == "number" ? a.offset * 100 : void 0, u = typeof o?.offset == "number" ? o.offset * 100 : void 0, d = i.map((e) => ({
|
|
8019
8743
|
color: typeof e.color == "string" ? e.color : "#000000",
|
|
@@ -8024,7 +8748,7 @@ var qr = class {
|
|
|
8024
8748
|
let { x1: e, y1: t, x2: r, y2: i } = n;
|
|
8025
8749
|
if (typeof e == "number" && typeof t == "number" && typeof r == "number" && typeof i == "number") return {
|
|
8026
8750
|
type: "linear",
|
|
8027
|
-
angle:
|
|
8751
|
+
angle: oi({
|
|
8028
8752
|
x1: e,
|
|
8029
8753
|
y1: t,
|
|
8030
8754
|
x2: r,
|
|
@@ -8052,7 +8776,7 @@ var qr = class {
|
|
|
8052
8776
|
};
|
|
8053
8777
|
}
|
|
8054
8778
|
return null;
|
|
8055
|
-
},
|
|
8779
|
+
}, ci = "_templateAnchorX", li = "_templateAnchorY", ui = class t {
|
|
8056
8780
|
constructor({ editor: e }) {
|
|
8057
8781
|
this.editor = e;
|
|
8058
8782
|
}
|
|
@@ -8061,7 +8785,7 @@ var qr = class {
|
|
|
8061
8785
|
if (!p.length) return s.emitWarning({
|
|
8062
8786
|
origin: "TemplateManager",
|
|
8063
8787
|
method: "serializeSelection",
|
|
8064
|
-
code:
|
|
8788
|
+
code: hr.TEMPLATE_MANAGER.NO_OBJECTS_SELECTED,
|
|
8065
8789
|
message: "Нет объектов для сериализации шаблона"
|
|
8066
8790
|
}), null;
|
|
8067
8791
|
let m = t._getBounds(o), h = t._getMontageSize({
|
|
@@ -8090,14 +8814,14 @@ var qr = class {
|
|
|
8090
8814
|
if (!s?.length) return a.emitWarning({
|
|
8091
8815
|
origin: "TemplateManager",
|
|
8092
8816
|
method: "applyTemplate",
|
|
8093
|
-
code:
|
|
8817
|
+
code: hr.TEMPLATE_MANAGER.INVALID_TEMPLATE,
|
|
8094
8818
|
message: "Шаблон не содержит объектов"
|
|
8095
8819
|
}), null;
|
|
8096
8820
|
let u = t._getBounds(r);
|
|
8097
8821
|
if (!u) return a.emitWarning({
|
|
8098
8822
|
origin: "TemplateManager",
|
|
8099
8823
|
method: "applyTemplate",
|
|
8100
|
-
code:
|
|
8824
|
+
code: hr.TEMPLATE_MANAGER.INVALID_TARGET,
|
|
8101
8825
|
message: "Не удалось определить границы монтажной области"
|
|
8102
8826
|
}), null;
|
|
8103
8827
|
let d = t._getMontageSize({
|
|
@@ -8116,7 +8840,7 @@ var qr = class {
|
|
|
8116
8840
|
if (!r.length) return a.emitWarning({
|
|
8117
8841
|
origin: "TemplateManager",
|
|
8118
8842
|
method: "applyTemplate",
|
|
8119
|
-
code:
|
|
8843
|
+
code: hr.TEMPLATE_MANAGER.INVALID_TEMPLATE,
|
|
8120
8844
|
message: "Не удалось создать объекты шаблона"
|
|
8121
8845
|
}), null;
|
|
8122
8846
|
let { backgroundObject: i, contentObjects: c } = t._extractBackgroundObject(r);
|
|
@@ -8151,7 +8875,7 @@ var qr = class {
|
|
|
8151
8875
|
return a.emitError({
|
|
8152
8876
|
origin: "TemplateManager",
|
|
8153
8877
|
method: "applyTemplate",
|
|
8154
|
-
code:
|
|
8878
|
+
code: hr.TEMPLATE_MANAGER.APPLY_FAILED,
|
|
8155
8879
|
message: "Ошибка применения шаблона",
|
|
8156
8880
|
data: {
|
|
8157
8881
|
templateId: l,
|
|
@@ -8203,22 +8927,22 @@ var qr = class {
|
|
|
8203
8927
|
naturalHeight: 0,
|
|
8204
8928
|
width: 0,
|
|
8205
8929
|
height: 0
|
|
8206
|
-
}, m =
|
|
8930
|
+
}, m = We({
|
|
8207
8931
|
value: u || f || c.width,
|
|
8208
8932
|
fallback: 0
|
|
8209
|
-
}), h =
|
|
8933
|
+
}), h = We({
|
|
8210
8934
|
value: d || p || c.height,
|
|
8211
8935
|
fallback: 0
|
|
8212
|
-
}), g =
|
|
8936
|
+
}), g = We({
|
|
8213
8937
|
value: r,
|
|
8214
8938
|
fallback: m
|
|
8215
|
-
}), _ =
|
|
8939
|
+
}), _ = We({
|
|
8216
8940
|
value: i,
|
|
8217
8941
|
fallback: h
|
|
8218
|
-
}), v =
|
|
8942
|
+
}), v = We({
|
|
8219
8943
|
value: a,
|
|
8220
8944
|
fallback: c.scaleX || 1
|
|
8221
|
-
}), y =
|
|
8945
|
+
}), y = We({
|
|
8222
8946
|
value: o,
|
|
8223
8947
|
fallback: c.scaleY || 1
|
|
8224
8948
|
}), b = g * v, x = _ * y, S = m > 0, C = h > 0, w = b > 0, T = x > 0, E = t._resolveImageFit({ customData: s }), D = {};
|
|
@@ -8290,10 +9014,10 @@ var qr = class {
|
|
|
8290
9014
|
baseWidth: i,
|
|
8291
9015
|
baseHeight: a,
|
|
8292
9016
|
useRelativePositions: o
|
|
8293
|
-
}), { scaleX: u, scaleY: d } = e, f =
|
|
9017
|
+
}), { scaleX: u, scaleY: d } = e, f = We({
|
|
8294
9018
|
value: u,
|
|
8295
9019
|
fallback: 1
|
|
8296
|
-
}), p =
|
|
9020
|
+
}), p = We({
|
|
8297
9021
|
value: d,
|
|
8298
9022
|
fallback: 1
|
|
8299
9023
|
}), m = qe({
|
|
@@ -8305,8 +9029,8 @@ var qr = class {
|
|
|
8305
9029
|
baseHeight: a,
|
|
8306
9030
|
scale: n,
|
|
8307
9031
|
useRelativePositions: o,
|
|
8308
|
-
anchorX: t._resolveAnchor(s,
|
|
8309
|
-
anchorY: t._resolveAnchor(s,
|
|
9032
|
+
anchorX: t._resolveAnchor(s, ci),
|
|
9033
|
+
anchorY: t._resolveAnchor(s, li)
|
|
8310
9034
|
})
|
|
8311
9035
|
}), h = f * n, g = p * n, _ = e.originX ?? "center", v = e.originY ?? "center";
|
|
8312
9036
|
e.set({
|
|
@@ -8320,7 +9044,7 @@ var qr = class {
|
|
|
8320
9044
|
originX: _,
|
|
8321
9045
|
originY: v
|
|
8322
9046
|
}
|
|
8323
|
-
}), delete s[
|
|
9047
|
+
}), delete s[ci], delete s[li];
|
|
8324
9048
|
}
|
|
8325
9049
|
static _getPositioningBounds({ bounds: e, baseWidth: n, baseHeight: r, scale: i, useRelativePositions: a, anchorX: o, anchorY: s }) {
|
|
8326
9050
|
if (!a) return e;
|
|
@@ -8372,19 +9096,19 @@ var qr = class {
|
|
|
8372
9096
|
if (!(e instanceof _)) return;
|
|
8373
9097
|
let r = typeof e.text == "string" ? e.text : "";
|
|
8374
9098
|
if (!r) return;
|
|
8375
|
-
let i =
|
|
9099
|
+
let i = We({
|
|
8376
9100
|
value: this.editor?.montageArea?.width,
|
|
8377
9101
|
fallback: 0
|
|
8378
|
-
}), { width: a = 0 } = e, o =
|
|
9102
|
+
}), { width: a = 0 } = e, o = We({
|
|
8379
9103
|
value: n,
|
|
8380
9104
|
fallback: 0
|
|
8381
|
-
}), s =
|
|
9105
|
+
}), s = We({
|
|
8382
9106
|
value: a,
|
|
8383
9107
|
fallback: 0
|
|
8384
9108
|
});
|
|
8385
9109
|
if (!i || !s || !o) return;
|
|
8386
9110
|
e.setCoords();
|
|
8387
|
-
let c = e, l = t._resolveAnchor(c,
|
|
9111
|
+
let c = e, l = t._resolveAnchor(c, ci), u = typeof c.left == "number" ? c.left : null, d = e.originX ?? "center", f = e.originY ?? "center", p = e.getPointByOrigin(d, f), m = e.getBoundingRect(!1, !0), h = m.left + m.width;
|
|
8388
9112
|
e.set("width", i), e.initDimensions();
|
|
8389
9113
|
let g = t._getLongestLineWidth({
|
|
8390
9114
|
textbox: e,
|
|
@@ -8403,7 +9127,7 @@ var qr = class {
|
|
|
8403
9127
|
return i;
|
|
8404
9128
|
}
|
|
8405
9129
|
_serializeObject({ object: e, bounds: n, baseWidth: r, baseHeight: i }) {
|
|
8406
|
-
let a = e.toDatalessObject([...
|
|
9130
|
+
let a = e.toDatalessObject([...oe]);
|
|
8407
9131
|
if (t._isSvgObject(e)) {
|
|
8408
9132
|
let n = t._extractSvgMarkup(e);
|
|
8409
9133
|
n && (a.svgMarkup = n, delete a.objects, delete a.path);
|
|
@@ -8413,10 +9137,10 @@ var qr = class {
|
|
|
8413
9137
|
x: (p.left - o) / d,
|
|
8414
9138
|
y: (p.top - s) / f
|
|
8415
9139
|
}, h = (u.left - o) / d, g = (u.top - s) / f, _ = h + u.width / d, v = g + u.height / f;
|
|
8416
|
-
return a[
|
|
9140
|
+
return a[ci] = t._detectAnchor({
|
|
8417
9141
|
start: h,
|
|
8418
9142
|
end: _
|
|
8419
|
-
}), a[
|
|
9143
|
+
}), a[li] = t._detectAnchor({
|
|
8420
9144
|
start: g,
|
|
8421
9145
|
end: v
|
|
8422
9146
|
}), a.left = m.x, a.top = m.y, a;
|
|
@@ -8441,7 +9165,7 @@ var qr = class {
|
|
|
8441
9165
|
withoutSave: !0
|
|
8442
9166
|
}), !0;
|
|
8443
9167
|
if (a === "gradient") {
|
|
8444
|
-
let e =
|
|
9168
|
+
let e = si(r);
|
|
8445
9169
|
if (e) return n.setGradientBackground({
|
|
8446
9170
|
gradient: e,
|
|
8447
9171
|
customData: o,
|
|
@@ -8462,7 +9186,7 @@ var qr = class {
|
|
|
8462
9186
|
r.emitWarning({
|
|
8463
9187
|
origin: "TemplateManager",
|
|
8464
9188
|
method: "applyTemplate",
|
|
8465
|
-
code:
|
|
9189
|
+
code: hr.TEMPLATE_MANAGER.APPLY_FAILED,
|
|
8466
9190
|
message: "Не удалось применить фон из шаблона",
|
|
8467
9191
|
data: e
|
|
8468
9192
|
});
|
|
@@ -8498,29 +9222,29 @@ var qr = class {
|
|
|
8498
9222
|
enlivenObjectEnlivables(e) {
|
|
8499
9223
|
return C.enlivenObjectEnlivables(e);
|
|
8500
9224
|
}
|
|
8501
|
-
},
|
|
8502
|
-
let n =
|
|
9225
|
+
}, di = "#3D8BF4", fi = .5, pi = ({ distance: e }) => Number.isFinite(e) ? Math.round(Math.max(0, e)) : 0, mi = ({ firstDistance: e, secondDistance: t }) => {
|
|
9226
|
+
let n = pi({ distance: e }), r = pi({ distance: t });
|
|
8503
9227
|
return {
|
|
8504
9228
|
firstDisplayDistance: n,
|
|
8505
9229
|
secondDisplayDistance: r,
|
|
8506
9230
|
displayDistanceDiff: Math.abs(n - r),
|
|
8507
9231
|
commonDisplayDistance: Math.max(n, r)
|
|
8508
9232
|
};
|
|
8509
|
-
},
|
|
9233
|
+
}, hi = ({ firstStart: e, firstEnd: t, secondStart: n, secondEnd: r }) => Math.min(t, r) - Math.max(e, n), gi = ({ step: e }) => {
|
|
8510
9234
|
let t = Math.abs(e).toString(), n = t.indexOf(".");
|
|
8511
9235
|
return n === -1 ? 0 : t.slice(n + 1).length;
|
|
8512
|
-
},
|
|
9236
|
+
}, _i = ({ value: e, step: t }) => {
|
|
8513
9237
|
if (t === 0) return e;
|
|
8514
|
-
let n =
|
|
9238
|
+
let n = gi({ step: t }), r = Math.round(e / t) * t;
|
|
8515
9239
|
return Number(r.toFixed(n));
|
|
8516
|
-
},
|
|
9240
|
+
}, vi = ({ value: e, step: t }) => {
|
|
8517
9241
|
if (t === 0) return !0;
|
|
8518
|
-
let n =
|
|
9242
|
+
let n = _i({
|
|
8519
9243
|
value: e,
|
|
8520
9244
|
step: t
|
|
8521
|
-
}), r = 10 ** -(
|
|
9245
|
+
}), r = 10 ** -(gi({ step: t }) + 4);
|
|
8522
9246
|
return Math.abs(n - e) <= r;
|
|
8523
|
-
},
|
|
9247
|
+
}, yi = ({ bounds: e, axis: t }) => {
|
|
8524
9248
|
let { left: n = 0, right: r = 0, top: i = 0, bottom: a = 0 } = e;
|
|
8525
9249
|
return t === "vertical" ? {
|
|
8526
9250
|
start: i,
|
|
@@ -8529,7 +9253,7 @@ var qr = class {
|
|
|
8529
9253
|
start: n,
|
|
8530
9254
|
end: r
|
|
8531
9255
|
};
|
|
8532
|
-
},
|
|
9256
|
+
}, bi = ({ items: e, axis: t }) => {
|
|
8533
9257
|
for (let n = 1; n < e.length; n += 1) {
|
|
8534
9258
|
let r = e[n], { bounds: i } = r, a = i[t], o = n - 1;
|
|
8535
9259
|
for (; o >= 0;) {
|
|
@@ -8539,10 +9263,10 @@ var qr = class {
|
|
|
8539
9263
|
}
|
|
8540
9264
|
e[o + 1] = r;
|
|
8541
9265
|
}
|
|
8542
|
-
},
|
|
9266
|
+
}, xi = ({ items: e, index: t, axis: n, direction: r }) => {
|
|
8543
9267
|
let i = e[t];
|
|
8544
9268
|
if (!i) return null;
|
|
8545
|
-
let { bounds: a } = i, { start: o, end: s } =
|
|
9269
|
+
let { bounds: a } = i, { start: o, end: s } = yi({
|
|
8546
9270
|
bounds: a,
|
|
8547
9271
|
axis: n
|
|
8548
9272
|
});
|
|
@@ -8550,7 +9274,7 @@ var qr = class {
|
|
|
8550
9274
|
for (let r = t - 1; r >= 0; --r) {
|
|
8551
9275
|
let t = e[r];
|
|
8552
9276
|
if (!t) continue;
|
|
8553
|
-
let { bounds: i } = t, { end: a } =
|
|
9277
|
+
let { bounds: i } = t, { end: a } = yi({
|
|
8554
9278
|
bounds: i,
|
|
8555
9279
|
axis: n
|
|
8556
9280
|
});
|
|
@@ -8561,26 +9285,26 @@ var qr = class {
|
|
|
8561
9285
|
for (let r = t + 1; r < e.length; r += 1) {
|
|
8562
9286
|
let t = e[r];
|
|
8563
9287
|
if (!t) continue;
|
|
8564
|
-
let { bounds: i } = t, { start: a } =
|
|
9288
|
+
let { bounds: i } = t, { start: a } = yi({
|
|
8565
9289
|
bounds: i,
|
|
8566
9290
|
axis: n
|
|
8567
9291
|
});
|
|
8568
9292
|
if (a - s >= 0) return r;
|
|
8569
9293
|
}
|
|
8570
9294
|
return null;
|
|
8571
|
-
},
|
|
9295
|
+
}, Si = ({ items: e }) => {
|
|
8572
9296
|
for (let t = 0; t < e.length; t += 1) {
|
|
8573
9297
|
let { isActive: n } = e[t];
|
|
8574
9298
|
if (n) return t;
|
|
8575
9299
|
}
|
|
8576
9300
|
return -1;
|
|
8577
|
-
},
|
|
9301
|
+
}, Ci = ({ patternAxis: e, activeRangeStart: t, activeRangeEnd: n, tolerance: r = 0 }) => {
|
|
8578
9302
|
let i = Math.min(t, n), a = Math.max(t, n);
|
|
8579
9303
|
return e >= i - r && e <= a + r;
|
|
8580
|
-
},
|
|
9304
|
+
}, wi = ({ patternStart: e, patternEnd: t, activeStart: n, activeEnd: r }) => t <= n ? "before" : e >= r ? "after" : null, Ti = ({ baseOption: e, candidateOption: t }) => {
|
|
8581
9305
|
let { delta: n, guide: { distance: r } } = e, { delta: i, guide: { distance: a } } = t;
|
|
8582
9306
|
return n === i && r === a;
|
|
8583
|
-
},
|
|
9307
|
+
}, Ei = ({ options: e }) => {
|
|
8584
9308
|
let t = e[0];
|
|
8585
9309
|
for (let n = 1; n < e.length; n += 1) {
|
|
8586
9310
|
let r = e[n];
|
|
@@ -8591,11 +9315,11 @@ var qr = class {
|
|
|
8591
9315
|
r.diff === t.diff && Math.abs(r.delta) < Math.abs(t.delta) && (t = r);
|
|
8592
9316
|
}
|
|
8593
9317
|
return t;
|
|
8594
|
-
},
|
|
9318
|
+
}, Di = ({ currentOption: e, nextOption: t }) => {
|
|
8595
9319
|
if (!e) return !0;
|
|
8596
9320
|
let { contextDistance: n, diff: r, delta: i } = e, { contextDistance: a, diff: o, delta: s } = t;
|
|
8597
9321
|
return a < n ? !0 : a > n ? !1 : o < r ? !0 : o > r ? !1 : Math.abs(s) < Math.abs(i);
|
|
8598
|
-
},
|
|
9322
|
+
}, Oi = ({ options: e }) => {
|
|
8599
9323
|
let t = [], n = null, r = null;
|
|
8600
9324
|
for (let i of e) {
|
|
8601
9325
|
let { kind: e, side: a } = i;
|
|
@@ -8603,18 +9327,18 @@ var qr = class {
|
|
|
8603
9327
|
t.push(i);
|
|
8604
9328
|
continue;
|
|
8605
9329
|
}
|
|
8606
|
-
a === "before" &&
|
|
9330
|
+
a === "before" && Di({
|
|
8607
9331
|
currentOption: n,
|
|
8608
9332
|
nextOption: i
|
|
8609
|
-
}) && (n = i), a === "after" &&
|
|
9333
|
+
}) && (n = i), a === "after" && Di({
|
|
8610
9334
|
currentOption: r,
|
|
8611
9335
|
nextOption: i
|
|
8612
9336
|
}) && (r = i);
|
|
8613
9337
|
}
|
|
8614
9338
|
return n && t.push(n), r && t.push(r), t;
|
|
8615
|
-
},
|
|
9339
|
+
}, ki = ({ options: e, side: t, baseOption: n }) => {
|
|
8616
9340
|
let r = null;
|
|
8617
|
-
for (let i of e) if (i.side === t &&
|
|
9341
|
+
for (let i of e) if (i.side === t && Ti({
|
|
8618
9342
|
baseOption: n,
|
|
8619
9343
|
candidateOption: i
|
|
8620
9344
|
})) {
|
|
@@ -8625,63 +9349,63 @@ var qr = class {
|
|
|
8625
9349
|
!r || i.diff !== r.diff || Math.abs(i.delta) < Math.abs(r.delta) && (r = i);
|
|
8626
9350
|
}
|
|
8627
9351
|
return r;
|
|
8628
|
-
},
|
|
9352
|
+
}, Ai = ({ option: e }) => {
|
|
8629
9353
|
let { side: t, kind: n, guide: { distance: r } } = e;
|
|
8630
9354
|
return {
|
|
8631
9355
|
side: t,
|
|
8632
9356
|
kind: n,
|
|
8633
9357
|
distance: r
|
|
8634
9358
|
};
|
|
8635
|
-
},
|
|
9359
|
+
}, ji = ({ option: e, context: t }) => {
|
|
8636
9360
|
let { side: n, kind: r, distance: i } = t, { side: a, kind: o, guide: { distance: s } } = e;
|
|
8637
9361
|
return n !== a || r !== o ? !1 : Math.abs(s - i) <= 1;
|
|
8638
|
-
},
|
|
9362
|
+
}, Mi = ({ options: e, context: t }) => {
|
|
8639
9363
|
if (!t) return null;
|
|
8640
|
-
for (let n of e) if (
|
|
9364
|
+
for (let n of e) if (ji({
|
|
8641
9365
|
option: n,
|
|
8642
9366
|
context: t
|
|
8643
9367
|
})) return n;
|
|
8644
9368
|
return null;
|
|
8645
|
-
},
|
|
8646
|
-
let i =
|
|
9369
|
+
}, Ni = ({ options: e, bestOption: t, previousContext: n, switchDistance: r = 0 }) => {
|
|
9370
|
+
let i = Mi({
|
|
8647
9371
|
options: e,
|
|
8648
9372
|
context: n
|
|
8649
9373
|
});
|
|
8650
9374
|
if (!i) return t;
|
|
8651
9375
|
let a = Math.max(0, r);
|
|
8652
9376
|
return a === 0 || Math.abs(t.delta - i.delta) >= a ? t : i;
|
|
8653
|
-
},
|
|
9377
|
+
}, Pi = ({ guides: e, seenGuideKeys: t, guide: n }) => {
|
|
8654
9378
|
let { type: r, axis: i, refStart: a, refEnd: o, activeStart: s, activeEnd: c, distance: l } = n, u = `${r}:${i}:${a}:${o}:${s}:${c}:${l}`;
|
|
8655
9379
|
t.has(u) || (t.add(u), e.push(n));
|
|
8656
|
-
},
|
|
9380
|
+
}, Fi = ({ options: e, previousContext: t = null, switchDistance: n = 0 }) => {
|
|
8657
9381
|
if (!e.length) return {
|
|
8658
9382
|
delta: 0,
|
|
8659
9383
|
guides: [],
|
|
8660
9384
|
context: null
|
|
8661
9385
|
};
|
|
8662
|
-
let r =
|
|
9386
|
+
let r = Oi({ options: e }), i = [];
|
|
8663
9387
|
for (let e of r) e.kind === "reference" && i.push(e);
|
|
8664
|
-
let a = i.length > 0, o = a ? i : r, s =
|
|
9388
|
+
let a = i.length > 0, o = a ? i : r, s = Ni({
|
|
8665
9389
|
options: o,
|
|
8666
|
-
bestOption:
|
|
9390
|
+
bestOption: Ei({ options: o }),
|
|
8667
9391
|
previousContext: t,
|
|
8668
9392
|
switchDistance: n
|
|
8669
|
-
}), c =
|
|
9393
|
+
}), c = ki({
|
|
8670
9394
|
options: o,
|
|
8671
9395
|
side: "before",
|
|
8672
9396
|
baseOption: s
|
|
8673
|
-
}), l =
|
|
9397
|
+
}), l = ki({
|
|
8674
9398
|
options: o,
|
|
8675
9399
|
side: "after",
|
|
8676
9400
|
baseOption: s
|
|
8677
|
-
}), u =
|
|
9401
|
+
}), u = ki({
|
|
8678
9402
|
options: a ? r : o,
|
|
8679
9403
|
side: "center",
|
|
8680
9404
|
baseOption: s
|
|
8681
9405
|
}), d = [];
|
|
8682
9406
|
c && l ? d.push(c, l) : (d.push(s), s.side === "before" && l && d.push(l), s.side === "after" && c && d.push(c), s.side === "center" && (c && !l && d.push(c), l && !c && d.push(l)), a && s.side === "before" && !l && u && d.push(u), a && s.side === "after" && !c && u && d.push(u)), !d.length && u && d.push(u);
|
|
8683
9407
|
let f = [], p = /* @__PURE__ */ new Set();
|
|
8684
|
-
for (let e of d)
|
|
9408
|
+
for (let e of d) Pi({
|
|
8685
9409
|
guides: f,
|
|
8686
9410
|
seenGuideKeys: p,
|
|
8687
9411
|
guide: e.guide
|
|
@@ -8689,15 +9413,15 @@ var qr = class {
|
|
|
8689
9413
|
return {
|
|
8690
9414
|
delta: s.delta,
|
|
8691
9415
|
guides: f,
|
|
8692
|
-
context:
|
|
9416
|
+
context: Ai({ option: s })
|
|
8693
9417
|
};
|
|
8694
|
-
},
|
|
8695
|
-
let s = n - (e - r), c =
|
|
9418
|
+
}, Ii = ({ activeStart: e, activeEnd: t, targetGap: n, beforeEdge: r, afterEdge: i, threshold: a, step: o }) => {
|
|
9419
|
+
let s = n - (e - r), c = _i({
|
|
8696
9420
|
value: s,
|
|
8697
9421
|
step: o
|
|
8698
9422
|
}), l = Math.max(1, Math.ceil(a / Math.max(o, 1))), u = null;
|
|
8699
9423
|
for (let d = -l; d <= l; d += 1) {
|
|
8700
|
-
let l = c + d * o, f = e + l, p = t + l, m = f - r, h = i - p, { displayDistanceDiff: g, commonDisplayDistance: _ } =
|
|
9424
|
+
let l = c + d * o, f = e + l, p = t + l, m = f - r, h = i - p, { displayDistanceDiff: g, commonDisplayDistance: _ } = mi({
|
|
8701
9425
|
firstDistance: m,
|
|
8702
9426
|
secondDistance: h
|
|
8703
9427
|
});
|
|
@@ -8712,13 +9436,13 @@ var qr = class {
|
|
|
8712
9436
|
});
|
|
8713
9437
|
}
|
|
8714
9438
|
return u;
|
|
8715
|
-
},
|
|
8716
|
-
let { secondDisplayDistance: n, displayDistanceDiff: r } =
|
|
9439
|
+
}, Li = ({ currentGap: e, referenceGap: t }) => {
|
|
9440
|
+
let { secondDisplayDistance: n, displayDistanceDiff: r } = mi({
|
|
8717
9441
|
firstDistance: e,
|
|
8718
9442
|
secondDistance: t
|
|
8719
9443
|
});
|
|
8720
9444
|
return r > 1 ? null : n;
|
|
8721
|
-
},
|
|
9445
|
+
}, Ri = ({ anchors: e, positions: t, threshold: n }) => {
|
|
8722
9446
|
let r = 0, i = n + 1, a = null;
|
|
8723
9447
|
for (let o of t) for (let t of e) {
|
|
8724
9448
|
let e = Math.abs(t - o);
|
|
@@ -8728,8 +9452,8 @@ var qr = class {
|
|
|
8728
9452
|
delta: r,
|
|
8729
9453
|
guidePosition: a
|
|
8730
9454
|
};
|
|
8731
|
-
},
|
|
8732
|
-
let { left: r, right: i, centerX: a, top: o, bottom: s, centerY: c } = e, l =
|
|
9455
|
+
}, zi = ({ activeBounds: e, threshold: t, anchors: n }) => {
|
|
9456
|
+
let { left: r, right: i, centerX: a, top: o, bottom: s, centerY: c } = e, l = Ri({
|
|
8733
9457
|
anchors: n.vertical,
|
|
8734
9458
|
positions: [
|
|
8735
9459
|
r,
|
|
@@ -8737,7 +9461,7 @@ var qr = class {
|
|
|
8737
9461
|
i
|
|
8738
9462
|
],
|
|
8739
9463
|
threshold: t
|
|
8740
|
-
}), u =
|
|
9464
|
+
}), u = Ri({
|
|
8741
9465
|
anchors: n.horizontal,
|
|
8742
9466
|
positions: [
|
|
8743
9467
|
o,
|
|
@@ -8757,11 +9481,11 @@ var qr = class {
|
|
|
8757
9481
|
deltaY: u.delta,
|
|
8758
9482
|
guides: d
|
|
8759
9483
|
};
|
|
8760
|
-
},
|
|
9484
|
+
}, Bi = ({ activeBounds: e, candidates: t, threshold: n, patterns: r, previousContext: i = null, switchDistance: a = 0 }) => {
|
|
8761
9485
|
let { centerX: o, top: s, bottom: c, left: l, right: u } = e, d = [];
|
|
8762
9486
|
for (let e of t) {
|
|
8763
9487
|
let { left: t, right: n } = e;
|
|
8764
|
-
|
|
9488
|
+
hi({
|
|
8765
9489
|
firstStart: t,
|
|
8766
9490
|
firstEnd: n,
|
|
8767
9491
|
secondStart: l,
|
|
@@ -8781,22 +9505,22 @@ var qr = class {
|
|
|
8781
9505
|
f.push({
|
|
8782
9506
|
bounds: e,
|
|
8783
9507
|
isActive: !0
|
|
8784
|
-
}),
|
|
9508
|
+
}), bi({
|
|
8785
9509
|
items: f,
|
|
8786
9510
|
axis: "top"
|
|
8787
9511
|
});
|
|
8788
|
-
let p =
|
|
9512
|
+
let p = Si({ items: f });
|
|
8789
9513
|
if (p === -1) return {
|
|
8790
9514
|
delta: 0,
|
|
8791
9515
|
guides: [],
|
|
8792
9516
|
context: null
|
|
8793
9517
|
};
|
|
8794
|
-
let m = [], h = c - s, g =
|
|
9518
|
+
let m = [], h = c - s, g = xi({
|
|
8795
9519
|
items: f,
|
|
8796
9520
|
index: p,
|
|
8797
9521
|
axis: "vertical",
|
|
8798
9522
|
direction: "prev"
|
|
8799
|
-
}), _ =
|
|
9523
|
+
}), _ = xi({
|
|
8800
9524
|
items: f,
|
|
8801
9525
|
index: p,
|
|
8802
9526
|
axis: "vertical",
|
|
@@ -8805,19 +9529,19 @@ var qr = class {
|
|
|
8805
9529
|
if (v && y) {
|
|
8806
9530
|
let { bounds: e } = v, { bounds: t } = y, { bottom: r } = e, { top: i } = t, a = i - r - h;
|
|
8807
9531
|
if (a >= 0) {
|
|
8808
|
-
let e =
|
|
9532
|
+
let e = _i({
|
|
8809
9533
|
value: a / 2,
|
|
8810
9534
|
step: 1
|
|
8811
9535
|
}), t = s - r, l = i - c, u = Math.abs(t - e), d = Math.abs(l - e);
|
|
8812
9536
|
if (Math.max(u, d) <= n) {
|
|
8813
|
-
let t =
|
|
9537
|
+
let t = Ii({
|
|
8814
9538
|
activeStart: s,
|
|
8815
9539
|
activeEnd: c,
|
|
8816
9540
|
targetGap: e,
|
|
8817
9541
|
beforeEdge: r,
|
|
8818
9542
|
afterEdge: i,
|
|
8819
9543
|
threshold: n,
|
|
8820
|
-
step:
|
|
9544
|
+
step: fi
|
|
8821
9545
|
});
|
|
8822
9546
|
if (t) {
|
|
8823
9547
|
let { delta: e, distance: n, diff: i, activeStart: a, activeEnd: s } = t, c = {
|
|
@@ -8854,16 +9578,16 @@ var qr = class {
|
|
|
8854
9578
|
}
|
|
8855
9579
|
for (let e of r) {
|
|
8856
9580
|
let { axis: t, start: r, end: i, distance: a } = e;
|
|
8857
|
-
if (!
|
|
9581
|
+
if (!vi({
|
|
8858
9582
|
value: a,
|
|
8859
9583
|
step: .5
|
|
8860
|
-
}) || !
|
|
9584
|
+
}) || !Ci({
|
|
8861
9585
|
patternAxis: t,
|
|
8862
9586
|
activeRangeStart: l,
|
|
8863
9587
|
activeRangeEnd: u,
|
|
8864
9588
|
tolerance: n
|
|
8865
9589
|
})) continue;
|
|
8866
|
-
let d =
|
|
9590
|
+
let d = wi({
|
|
8867
9591
|
patternStart: r,
|
|
8868
9592
|
patternEnd: i,
|
|
8869
9593
|
activeStart: s,
|
|
@@ -8871,12 +9595,12 @@ var qr = class {
|
|
|
8871
9595
|
});
|
|
8872
9596
|
if (d) {
|
|
8873
9597
|
if (b !== null && S && d === "before" && Math.abs(b - a) <= n) {
|
|
8874
|
-
let e =
|
|
9598
|
+
let e = _i({
|
|
8875
9599
|
value: a - b,
|
|
8876
9600
|
step: 1
|
|
8877
9601
|
}), t = s + e, { bottom: c } = S, l = t - c, u = Math.abs(l - a);
|
|
8878
9602
|
if (u > n) continue;
|
|
8879
|
-
let d =
|
|
9603
|
+
let d = Li({
|
|
8880
9604
|
currentGap: l,
|
|
8881
9605
|
referenceGap: a
|
|
8882
9606
|
});
|
|
@@ -8900,12 +9624,12 @@ var qr = class {
|
|
|
8900
9624
|
});
|
|
8901
9625
|
}
|
|
8902
9626
|
if (x !== null && C && d === "after" && Math.abs(x - a) <= n) {
|
|
8903
|
-
let e =
|
|
9627
|
+
let e = _i({
|
|
8904
9628
|
value: x - a,
|
|
8905
9629
|
step: 1
|
|
8906
9630
|
}), t = c + e, { top: s } = C, l = s - t, u = Math.abs(l - a);
|
|
8907
9631
|
if (u > n) continue;
|
|
8908
|
-
let d =
|
|
9632
|
+
let d = Li({
|
|
8909
9633
|
currentGap: l,
|
|
8910
9634
|
referenceGap: a
|
|
8911
9635
|
});
|
|
@@ -8930,16 +9654,16 @@ var qr = class {
|
|
|
8930
9654
|
}
|
|
8931
9655
|
}
|
|
8932
9656
|
}
|
|
8933
|
-
return
|
|
9657
|
+
return Fi({
|
|
8934
9658
|
options: m,
|
|
8935
9659
|
previousContext: i,
|
|
8936
9660
|
switchDistance: a
|
|
8937
9661
|
});
|
|
8938
|
-
},
|
|
9662
|
+
}, Vi = ({ activeBounds: e, candidates: t, threshold: n, patterns: r, previousContext: i = null, switchDistance: a = 0 }) => {
|
|
8939
9663
|
let { centerY: o, left: s, right: c, top: l, bottom: u } = e, d = [];
|
|
8940
9664
|
for (let e of t) {
|
|
8941
9665
|
let { top: t, bottom: n } = e;
|
|
8942
|
-
|
|
9666
|
+
hi({
|
|
8943
9667
|
firstStart: t,
|
|
8944
9668
|
firstEnd: n,
|
|
8945
9669
|
secondStart: l,
|
|
@@ -8959,22 +9683,22 @@ var qr = class {
|
|
|
8959
9683
|
f.push({
|
|
8960
9684
|
bounds: e,
|
|
8961
9685
|
isActive: !0
|
|
8962
|
-
}),
|
|
9686
|
+
}), bi({
|
|
8963
9687
|
items: f,
|
|
8964
9688
|
axis: "left"
|
|
8965
9689
|
});
|
|
8966
|
-
let p =
|
|
9690
|
+
let p = Si({ items: f });
|
|
8967
9691
|
if (p === -1) return {
|
|
8968
9692
|
delta: 0,
|
|
8969
9693
|
guides: [],
|
|
8970
9694
|
context: null
|
|
8971
9695
|
};
|
|
8972
|
-
let m = [], h = c - s, g =
|
|
9696
|
+
let m = [], h = c - s, g = xi({
|
|
8973
9697
|
items: f,
|
|
8974
9698
|
index: p,
|
|
8975
9699
|
axis: "horizontal",
|
|
8976
9700
|
direction: "prev"
|
|
8977
|
-
}), _ =
|
|
9701
|
+
}), _ = xi({
|
|
8978
9702
|
items: f,
|
|
8979
9703
|
index: p,
|
|
8980
9704
|
axis: "horizontal",
|
|
@@ -8983,19 +9707,19 @@ var qr = class {
|
|
|
8983
9707
|
if (v && y) {
|
|
8984
9708
|
let { bounds: e } = v, { bounds: t } = y, { right: r } = e, { left: i } = t, a = i - r - h;
|
|
8985
9709
|
if (a >= 0) {
|
|
8986
|
-
let e =
|
|
9710
|
+
let e = _i({
|
|
8987
9711
|
value: a / 2,
|
|
8988
9712
|
step: 1
|
|
8989
9713
|
}), t = s - r, l = i - c, u = Math.abs(t - e), d = Math.abs(l - e);
|
|
8990
9714
|
if (Math.max(u, d) <= n) {
|
|
8991
|
-
let t =
|
|
9715
|
+
let t = Ii({
|
|
8992
9716
|
activeStart: s,
|
|
8993
9717
|
activeEnd: c,
|
|
8994
9718
|
targetGap: e,
|
|
8995
9719
|
beforeEdge: r,
|
|
8996
9720
|
afterEdge: i,
|
|
8997
9721
|
threshold: n,
|
|
8998
|
-
step:
|
|
9722
|
+
step: fi
|
|
8999
9723
|
});
|
|
9000
9724
|
if (t) {
|
|
9001
9725
|
let { delta: e, distance: n, diff: i, activeStart: a, activeEnd: s } = t, c = {
|
|
@@ -9032,16 +9756,16 @@ var qr = class {
|
|
|
9032
9756
|
}
|
|
9033
9757
|
for (let e of r) {
|
|
9034
9758
|
let { axis: t, start: r, end: i, distance: a } = e;
|
|
9035
|
-
if (!
|
|
9759
|
+
if (!vi({
|
|
9036
9760
|
value: a,
|
|
9037
9761
|
step: .5
|
|
9038
|
-
}) || !
|
|
9762
|
+
}) || !Ci({
|
|
9039
9763
|
patternAxis: t,
|
|
9040
9764
|
activeRangeStart: l,
|
|
9041
9765
|
activeRangeEnd: u,
|
|
9042
9766
|
tolerance: n
|
|
9043
9767
|
})) continue;
|
|
9044
|
-
let d =
|
|
9768
|
+
let d = wi({
|
|
9045
9769
|
patternStart: r,
|
|
9046
9770
|
patternEnd: i,
|
|
9047
9771
|
activeStart: s,
|
|
@@ -9049,12 +9773,12 @@ var qr = class {
|
|
|
9049
9773
|
});
|
|
9050
9774
|
if (d) {
|
|
9051
9775
|
if (b !== null && S && d === "before" && Math.abs(b - a) <= n) {
|
|
9052
|
-
let e =
|
|
9776
|
+
let e = _i({
|
|
9053
9777
|
value: a - b,
|
|
9054
9778
|
step: 1
|
|
9055
9779
|
}), t = s + e, { right: c } = S, l = t - c, u = Math.abs(l - a);
|
|
9056
9780
|
if (u > n) continue;
|
|
9057
|
-
let d =
|
|
9781
|
+
let d = Li({
|
|
9058
9782
|
currentGap: l,
|
|
9059
9783
|
referenceGap: a
|
|
9060
9784
|
});
|
|
@@ -9078,12 +9802,12 @@ var qr = class {
|
|
|
9078
9802
|
});
|
|
9079
9803
|
}
|
|
9080
9804
|
if (x !== null && C && d === "after" && Math.abs(x - a) <= n) {
|
|
9081
|
-
let e =
|
|
9805
|
+
let e = _i({
|
|
9082
9806
|
value: x - a,
|
|
9083
9807
|
step: 1
|
|
9084
9808
|
}), t = c + e, { left: s } = C, l = s - t, u = Math.abs(l - a);
|
|
9085
9809
|
if (u > n) continue;
|
|
9086
|
-
let d =
|
|
9810
|
+
let d = Li({
|
|
9087
9811
|
currentGap: l,
|
|
9088
9812
|
referenceGap: a
|
|
9089
9813
|
});
|
|
@@ -9108,20 +9832,20 @@ var qr = class {
|
|
|
9108
9832
|
}
|
|
9109
9833
|
}
|
|
9110
9834
|
}
|
|
9111
|
-
return
|
|
9835
|
+
return Fi({
|
|
9112
9836
|
options: m,
|
|
9113
9837
|
previousContext: i,
|
|
9114
9838
|
switchDistance: a
|
|
9115
9839
|
});
|
|
9116
|
-
},
|
|
9117
|
-
let { vertical: o = null, horizontal: s = null } = i ?? {}, c =
|
|
9840
|
+
}, Hi = ({ activeBounds: e, candidates: t, threshold: n, spacingPatterns: r, previousContexts: i, switchDistance: a = 0 }) => {
|
|
9841
|
+
let { vertical: o = null, horizontal: s = null } = i ?? {}, c = Bi({
|
|
9118
9842
|
activeBounds: e,
|
|
9119
9843
|
candidates: t,
|
|
9120
9844
|
threshold: n,
|
|
9121
9845
|
patterns: r.vertical,
|
|
9122
9846
|
previousContext: o,
|
|
9123
9847
|
switchDistance: a
|
|
9124
|
-
}), l =
|
|
9848
|
+
}), l = Vi({
|
|
9125
9849
|
activeBounds: e,
|
|
9126
9850
|
candidates: t,
|
|
9127
9851
|
threshold: n,
|
|
@@ -9140,14 +9864,14 @@ var qr = class {
|
|
|
9140
9864
|
horizontal: l.context
|
|
9141
9865
|
}
|
|
9142
9866
|
};
|
|
9143
|
-
},
|
|
9867
|
+
}, Ui = ({ context: e, x: t, y: n, width: r, height: i, radius: a }) => {
|
|
9144
9868
|
let o = Math.min(a, r / 2, i / 2);
|
|
9145
9869
|
e.moveTo(t + o, n), e.lineTo(t + r - o, n), e.quadraticCurveTo(t + r, n, t + r, n + o), e.lineTo(t + r, n + i - o), e.quadraticCurveTo(t + r, n + i, t + r - o, n + i), e.lineTo(t + o, n + i), e.quadraticCurveTo(t, n + i, t, n + i - o), e.lineTo(t, n + o), e.quadraticCurveTo(t, n, t + o, n), e.closePath();
|
|
9146
|
-
},
|
|
9870
|
+
}, Wi = ({ context: e, type: t, axis: n, start: r, end: i, text: a, zoom: o, color: s, textColor: c = "#ffffff", fontFamily: l = "sans-serif", lineWidth: u = 1, padding: d = 4, radius: f = 4, offsetAlongAxis: p = 0, offsetPerpendicular: m = 0 }) => {
|
|
9147
9871
|
let h = o || 1, g = 12 / h, _ = d / h, v = f / h, y = (r + i) / 2 + p, b = t === "vertical" ? n + m : y, x = t === "vertical" ? y : n + m;
|
|
9148
9872
|
e.save(), e.setLineDash([]), e.fillStyle = s, e.strokeStyle = s, e.lineWidth = u / h, e.font = `${g}px ${l}`, e.textAlign = "center", e.textBaseline = "middle";
|
|
9149
9873
|
let S = e.measureText(a).width + _ * 2, C = g + _ * 2, w = b - S / 2, T = x - C / 2;
|
|
9150
|
-
e.beginPath(),
|
|
9874
|
+
e.beginPath(), Ui({
|
|
9151
9875
|
context: e,
|
|
9152
9876
|
x: w,
|
|
9153
9877
|
y: T,
|
|
@@ -9155,11 +9879,11 @@ var qr = class {
|
|
|
9155
9879
|
height: C,
|
|
9156
9880
|
radius: v
|
|
9157
9881
|
}), e.fill(), e.fillStyle = c, e.fillText(a, b, x), e.restore();
|
|
9158
|
-
},
|
|
9159
|
-
let { type: r, axis: i, refStart: a, refEnd: o, activeStart: s, activeEnd: c, distance: l } = t, u =
|
|
9882
|
+
}, Gi = ({ context: e, guide: t, zoom: n }) => {
|
|
9883
|
+
let { type: r, axis: i, refStart: a, refEnd: o, activeStart: s, activeEnd: c, distance: l } = t, u = pi({ distance: l }).toString();
|
|
9160
9884
|
e.beginPath(), r === "vertical" ? (e.moveTo(i, a), e.lineTo(i, o), e.moveTo(i, s), e.lineTo(i, c)) : (e.moveTo(a, i), e.lineTo(o, i), e.moveTo(s, i), e.lineTo(c, i)), e.stroke();
|
|
9161
|
-
let d =
|
|
9162
|
-
|
|
9885
|
+
let d = di;
|
|
9886
|
+
Wi({
|
|
9163
9887
|
context: e,
|
|
9164
9888
|
type: r,
|
|
9165
9889
|
axis: i,
|
|
@@ -9169,7 +9893,7 @@ var qr = class {
|
|
|
9169
9893
|
zoom: n,
|
|
9170
9894
|
color: d,
|
|
9171
9895
|
lineWidth: 1
|
|
9172
|
-
}),
|
|
9896
|
+
}), Wi({
|
|
9173
9897
|
context: e,
|
|
9174
9898
|
type: r,
|
|
9175
9899
|
axis: i,
|
|
@@ -9180,10 +9904,10 @@ var qr = class {
|
|
|
9180
9904
|
color: d,
|
|
9181
9905
|
lineWidth: 1
|
|
9182
9906
|
});
|
|
9183
|
-
},
|
|
9907
|
+
}, Ki = ({ anchors: e, bounds: t }) => {
|
|
9184
9908
|
let { left: n, right: r, centerX: i, top: a, bottom: o, centerY: s } = t;
|
|
9185
9909
|
e.vertical.push(n, i, r), e.horizontal.push(a, s, o);
|
|
9186
|
-
},
|
|
9910
|
+
}, qi = ({ bounds: e, type: t, primaryStart: n, primaryEnd: r }) => {
|
|
9187
9911
|
let i = [], a = n === "top" ? "left" : "top", o = r === "bottom" ? "right" : "bottom", s = [...e].sort((e, t) => e[n] - t[n]);
|
|
9188
9912
|
for (let e = 0; e < s.length; e += 1) {
|
|
9189
9913
|
let c = s[e], l = null, u = Infinity;
|
|
@@ -9204,35 +9928,35 @@ var qr = class {
|
|
|
9204
9928
|
});
|
|
9205
9929
|
}
|
|
9206
9930
|
return i;
|
|
9207
|
-
},
|
|
9208
|
-
vertical:
|
|
9931
|
+
}, Ji = ({ bounds: e }) => ({
|
|
9932
|
+
vertical: qi({
|
|
9209
9933
|
bounds: e,
|
|
9210
9934
|
axis: "centerX",
|
|
9211
9935
|
type: "vertical",
|
|
9212
9936
|
primaryStart: "top",
|
|
9213
9937
|
primaryEnd: "bottom"
|
|
9214
9938
|
}),
|
|
9215
|
-
horizontal:
|
|
9939
|
+
horizontal: qi({
|
|
9216
9940
|
bounds: e,
|
|
9217
9941
|
axis: "centerY",
|
|
9218
9942
|
type: "horizontal",
|
|
9219
9943
|
primaryStart: "left",
|
|
9220
9944
|
primaryEnd: "right"
|
|
9221
9945
|
})
|
|
9222
|
-
}),
|
|
9946
|
+
}), Yi = [
|
|
9223
9947
|
"montage-area",
|
|
9224
9948
|
"background",
|
|
9225
9949
|
"interaction-blocker"
|
|
9226
|
-
],
|
|
9950
|
+
], Xi = ({ activeObject: t }) => {
|
|
9227
9951
|
let n = /* @__PURE__ */ new Set();
|
|
9228
9952
|
return t ? (n.add(t), t instanceof e && t.getObjects().forEach((e) => n.add(e)), n) : n;
|
|
9229
|
-
},
|
|
9953
|
+
}, Zi = ({ object: e, excluded: t, ignoredIds: n = Yi }) => {
|
|
9230
9954
|
if (t.has(e)) return !0;
|
|
9231
9955
|
let { visible: r = !0 } = e;
|
|
9232
9956
|
if (!r) return !0;
|
|
9233
9957
|
let { id: i } = e;
|
|
9234
9958
|
return !!(i && n.includes(i));
|
|
9235
|
-
},
|
|
9959
|
+
}, Qi = class e {
|
|
9236
9960
|
constructor({ editor: e }) {
|
|
9237
9961
|
this.anchors = {
|
|
9238
9962
|
vertical: [],
|
|
@@ -9280,12 +10004,12 @@ var qr = class {
|
|
|
9280
10004
|
target: n,
|
|
9281
10005
|
transform: i
|
|
9282
10006
|
}), !this.anchors.vertical.length && !this.anchors.horizontal.length && this._cacheAnchors({ activeObject: n });
|
|
9283
|
-
let a =
|
|
10007
|
+
let a = Ye({ object: n });
|
|
9284
10008
|
if (!a) {
|
|
9285
10009
|
this._clearSpacingContexts(), this._clearGuides();
|
|
9286
10010
|
return;
|
|
9287
10011
|
}
|
|
9288
|
-
let { canvas: o } = this, s = o.getZoom() || 1, c = 5 / s, { deltaX: l, deltaY: u } =
|
|
10012
|
+
let { canvas: o } = this, s = o.getZoom() || 1, c = 5 / s, { deltaX: l, deltaY: u } = zi({
|
|
9289
10013
|
activeBounds: a,
|
|
9290
10014
|
threshold: c,
|
|
9291
10015
|
anchors: this.anchors
|
|
@@ -9295,9 +10019,9 @@ var qr = class {
|
|
|
9295
10019
|
n.set({
|
|
9296
10020
|
left: e + l,
|
|
9297
10021
|
top: t + u
|
|
9298
|
-
}), n.setCoords(), a =
|
|
10022
|
+
}), n.setCoords(), a = Ye({ object: n }) ?? a;
|
|
9299
10023
|
}
|
|
9300
|
-
let d = this._resolveCurrentTargetBounds({ activeObject: n }), f = this.spacingContexts.vertical || this.spacingContexts.horizontal ? 10 / s : c, p =
|
|
10024
|
+
let d = this._resolveCurrentTargetBounds({ activeObject: n }), f = this.spacingContexts.vertical || this.spacingContexts.horizontal ? 10 / s : c, p = Hi({
|
|
9301
10025
|
activeBounds: a,
|
|
9302
10026
|
candidates: d,
|
|
9303
10027
|
threshold: f,
|
|
@@ -9312,17 +10036,17 @@ var qr = class {
|
|
|
9312
10036
|
n.set({
|
|
9313
10037
|
left: e + p.deltaX,
|
|
9314
10038
|
top: t + p.deltaY
|
|
9315
|
-
}), n.setCoords(), a =
|
|
10039
|
+
}), n.setCoords(), a = Ye({ object: n }) ?? a;
|
|
9316
10040
|
}
|
|
9317
10041
|
m || e._applyMovementStep({
|
|
9318
10042
|
target: n,
|
|
9319
10043
|
transform: i
|
|
9320
10044
|
});
|
|
9321
|
-
let h =
|
|
10045
|
+
let h = Ye({ object: n }) ?? a, g = zi({
|
|
9322
10046
|
activeBounds: h,
|
|
9323
10047
|
threshold: c,
|
|
9324
10048
|
anchors: this.anchors
|
|
9325
|
-
}), _ =
|
|
10049
|
+
}), _ = Hi({
|
|
9326
10050
|
activeBounds: h,
|
|
9327
10051
|
candidates: d,
|
|
9328
10052
|
threshold: c,
|
|
@@ -9362,7 +10086,7 @@ var qr = class {
|
|
|
9362
10086
|
}
|
|
9363
10087
|
let { anchors: l } = this, { vertical: u, horizontal: d } = l;
|
|
9364
10088
|
!u.length && !d.length && this._cacheAnchors({ activeObject: n });
|
|
9365
|
-
let f =
|
|
10089
|
+
let f = Ye({ object: n });
|
|
9366
10090
|
if (!f) {
|
|
9367
10091
|
this._clearGuides();
|
|
9368
10092
|
return;
|
|
@@ -9486,7 +10210,7 @@ var qr = class {
|
|
|
9486
10210
|
}
|
|
9487
10211
|
let { anchors: a } = this, { vertical: o, horizontal: s } = a;
|
|
9488
10212
|
!o.length && !s.length && this._cacheAnchors({ activeObject: t });
|
|
9489
|
-
let c =
|
|
10213
|
+
let c = Ye({ object: t });
|
|
9490
10214
|
if (!c) {
|
|
9491
10215
|
this._clearGuides();
|
|
9492
10216
|
return;
|
|
@@ -9553,9 +10277,9 @@ var qr = class {
|
|
|
9553
10277
|
let { canvas: e, guideBounds: t } = this, n = e.getSelectionContext();
|
|
9554
10278
|
if (!n) return;
|
|
9555
10279
|
let { left: r, right: i, top: a, bottom: o } = t ?? this._calculateViewportBounds(), { viewportTransform: s } = e, c = e.getZoom() || 1;
|
|
9556
|
-
n.save(), Array.isArray(s) && n.transform(...s), n.lineWidth = 1 / c, n.strokeStyle =
|
|
10280
|
+
n.save(), Array.isArray(s) && n.transform(...s), n.lineWidth = 1 / c, n.strokeStyle = di, n.setLineDash([4, 4]);
|
|
9557
10281
|
for (let e of this.activeGuides) n.beginPath(), e.type === "vertical" ? (n.moveTo(e.position, a), n.lineTo(e.position, o)) : (n.moveTo(r, e.position), n.lineTo(i, e.position)), n.stroke();
|
|
9558
|
-
for (let e of this.activeSpacingGuides)
|
|
10282
|
+
for (let e of this.activeSpacingGuides) Gi({
|
|
9559
10283
|
context: n,
|
|
9560
10284
|
guide: e,
|
|
9561
10285
|
zoom: c
|
|
@@ -9765,15 +10489,15 @@ var qr = class {
|
|
|
9765
10489
|
horizontal: []
|
|
9766
10490
|
}, r = [];
|
|
9767
10491
|
for (let e of t) {
|
|
9768
|
-
let t =
|
|
9769
|
-
t && (
|
|
10492
|
+
let t = Ye({ object: e });
|
|
10493
|
+
t && (Ki({
|
|
9770
10494
|
anchors: n,
|
|
9771
10495
|
bounds: t
|
|
9772
10496
|
}), r.push(t));
|
|
9773
10497
|
}
|
|
9774
|
-
let { montageArea: i } = this.editor, a =
|
|
10498
|
+
let { montageArea: i } = this.editor, a = Ye({ object: i });
|
|
9775
10499
|
if (a) {
|
|
9776
|
-
|
|
10500
|
+
Ki({
|
|
9777
10501
|
anchors: n,
|
|
9778
10502
|
bounds: a
|
|
9779
10503
|
});
|
|
@@ -9785,12 +10509,12 @@ var qr = class {
|
|
|
9785
10509
|
bottom: i
|
|
9786
10510
|
};
|
|
9787
10511
|
} else this.guideBounds = this._calculateViewportBounds();
|
|
9788
|
-
this.anchors = n, this.spacingPatterns =
|
|
10512
|
+
this.anchors = n, this.spacingPatterns = Ji({ bounds: r }), this.cachedTargetBounds = r;
|
|
9789
10513
|
}
|
|
9790
10514
|
_collectTargets({ activeObject: e }) {
|
|
9791
|
-
let t =
|
|
10515
|
+
let t = Xi({ activeObject: e }), n = [];
|
|
9792
10516
|
return this.canvas.forEachObject((e) => {
|
|
9793
|
-
|
|
10517
|
+
Zi({
|
|
9794
10518
|
object: e,
|
|
9795
10519
|
excluded: t
|
|
9796
10520
|
}) || n.push(e);
|
|
@@ -9799,7 +10523,7 @@ var qr = class {
|
|
|
9799
10523
|
_resolveCurrentTargetBounds({ activeObject: e }) {
|
|
9800
10524
|
let t = this._collectTargets({ activeObject: e }), n = [];
|
|
9801
10525
|
for (let e of t) {
|
|
9802
|
-
let t =
|
|
10526
|
+
let t = Ye({ object: e });
|
|
9803
10527
|
t && n.push(t);
|
|
9804
10528
|
}
|
|
9805
10529
|
return n;
|
|
@@ -9813,7 +10537,7 @@ var qr = class {
|
|
|
9813
10537
|
bottom: (r - s) / a
|
|
9814
10538
|
};
|
|
9815
10539
|
}
|
|
9816
|
-
},
|
|
10540
|
+
}, $i = "#3D8BF4", ea = class e {
|
|
9817
10541
|
constructor({ editor: e }) {
|
|
9818
10542
|
this.activeGuides = [], this.isAltPressed = !1, this.pendingEvent = null, this.frameRequest = null, this.isToolbarHidden = !1, this.isTargetMontageArea = !1, this.lastMouseEvent = null, this.editor = e, this.canvas = e.canvas, this._onMouseMove = this._handleMouseMove.bind(this), this._onBeforeRender = this._handleBeforeRender.bind(this), this._onAfterRender = this._handleAfterRender.bind(this), this._onSelectionCleared = this._handleSelectionCleared.bind(this), this._onKeyDown = this._handleKeyDown.bind(this), this._onKeyUp = this._handleKeyUp.bind(this), this._onWindowBlur = this._handleWindowBlur.bind(this), this._bindEvents();
|
|
9819
10543
|
}
|
|
@@ -9877,7 +10601,7 @@ var qr = class {
|
|
|
9877
10601
|
this._clearGuides();
|
|
9878
10602
|
return;
|
|
9879
10603
|
}
|
|
9880
|
-
let a =
|
|
10604
|
+
let a = Ye({ object: i });
|
|
9881
10605
|
if (!a) {
|
|
9882
10606
|
this._clearGuides();
|
|
9883
10607
|
return;
|
|
@@ -9885,7 +10609,7 @@ var qr = class {
|
|
|
9885
10609
|
let o = e._resolveTarget({
|
|
9886
10610
|
event: t,
|
|
9887
10611
|
activeObject: i
|
|
9888
|
-
}), { montageArea: s } = r, c = o ?? s, l = c === s, u =
|
|
10612
|
+
}), { montageArea: s } = r, c = o ?? s, l = c === s, u = Ye({ object: c });
|
|
9889
10613
|
if (!u) {
|
|
9890
10614
|
this._clearGuides();
|
|
9891
10615
|
return;
|
|
@@ -9906,8 +10630,8 @@ var qr = class {
|
|
|
9906
10630
|
this.isTargetMontageArea = l, this.activeGuides = d, this._hideToolbar(), n.requestRenderAll();
|
|
9907
10631
|
}
|
|
9908
10632
|
static _resolveTarget({ event: e, activeObject: t }) {
|
|
9909
|
-
let { target: n } = e, r =
|
|
9910
|
-
return n && !
|
|
10633
|
+
let { target: n } = e, r = Xi({ activeObject: t });
|
|
10634
|
+
return n && !Zi({
|
|
9911
10635
|
object: n,
|
|
9912
10636
|
excluded: r
|
|
9913
10637
|
}) ? n : null;
|
|
@@ -10024,18 +10748,18 @@ var qr = class {
|
|
|
10024
10748
|
let { canvas: e } = this, t = e.getSelectionContext();
|
|
10025
10749
|
if (!t) return;
|
|
10026
10750
|
let { viewportTransform: n } = e, r = e.getZoom() || 1, i = this.activeGuides.some((e) => e.type === "vertical"), a = this.activeGuides.some((e) => e.type === "horizontal"), o = i && a && !this.isTargetMontageArea, s = o ? 12 / r : 0;
|
|
10027
|
-
t.save(), Array.isArray(n) && t.transform(...n), t.lineWidth = 1 / r, t.strokeStyle =
|
|
10751
|
+
t.save(), Array.isArray(n) && t.transform(...n), t.lineWidth = 1 / r, t.strokeStyle = $i, t.setLineDash([]);
|
|
10028
10752
|
for (let e of this.activeGuides) {
|
|
10029
10753
|
let { type: n, axis: i, start: a, end: c, distance: l } = e, u = Math.abs(c - a), d = o ? (a <= c ? -1 : 1) * (u / 2 + s) : 0;
|
|
10030
|
-
t.beginPath(), n === "vertical" ? (t.moveTo(i, a), t.lineTo(i, c)) : (t.moveTo(a, i), t.lineTo(c, i)), t.stroke(),
|
|
10754
|
+
t.beginPath(), n === "vertical" ? (t.moveTo(i, a), t.lineTo(i, c)) : (t.moveTo(a, i), t.lineTo(c, i)), t.stroke(), Wi({
|
|
10031
10755
|
context: t,
|
|
10032
10756
|
type: n,
|
|
10033
10757
|
axis: i,
|
|
10034
10758
|
start: a,
|
|
10035
10759
|
end: c,
|
|
10036
|
-
text:
|
|
10760
|
+
text: pi({ distance: l }).toString(),
|
|
10037
10761
|
zoom: r,
|
|
10038
|
-
color:
|
|
10762
|
+
color: $i,
|
|
10039
10763
|
lineWidth: 1,
|
|
10040
10764
|
offsetAlongAxis: d,
|
|
10041
10765
|
offsetPerpendicular: 0
|
|
@@ -10053,13 +10777,13 @@ var qr = class {
|
|
|
10053
10777
|
let { toolbar: e } = this.editor;
|
|
10054
10778
|
e?.showAfterTemporary?.(), this.isToolbarHidden = !1;
|
|
10055
10779
|
}
|
|
10056
|
-
},
|
|
10780
|
+
}, ta = class e {
|
|
10057
10781
|
constructor(e, t) {
|
|
10058
10782
|
this.options = t, this.containerId = e, this.editorId = `${e}-${D()}`, this.init();
|
|
10059
10783
|
}
|
|
10060
10784
|
async init() {
|
|
10061
10785
|
let { editorContainerWidth: e, editorContainerHeight: n, canvasWrapperWidth: r, canvasWrapperHeight: i, canvasCSSWidth: a, canvasCSSHeight: o, initialImage: s, initialState: c, scaleType: l, showRotationAngle: u, _onReadyCallback: d } = this.options;
|
|
10062
|
-
if (
|
|
10786
|
+
if (ie.apply(), this.canvas = new t(this.containerId, this.options), this.moduleLoader = new A(), this.workerManager = new M(), this.errorManager = new gr({ editor: this }), this.historyManager = new je({ editor: this }), this.toolbar = new V({ editor: this }), this.transformManager = new He({ editor: this }), this.zoomManager = new Ue({ editor: this }), this.canvasManager = new Ve({ editor: this }), this.imageManager = new Le({ editor: this }), this.layerManager = new et({ editor: this }), this.shapeManager = new lr({ editor: this }), this.interactionBlocker = new Qe({ editor: this }), this.backgroundManager = new $e({ editor: this }), this.clipboardManager = new ur({ editor: this }), this.objectLockManager = new dr({ editor: this }), this.groupingManager = new fr({ editor: this }), this.selectionManager = new pr({ editor: this }), this.deletionManager = new mr({ editor: this }), this.panConstraintManager = new _r({ editor: this }), this.snappingManager = new Qi({ editor: this }), this.measurementManager = new ea({ editor: this }), this.fontManager = new z(this.options.fonts ?? []), this.textManager = new ai({ editor: this }), this.templateManager = new ui({ editor: this }), u && (this.angleIndicator = new ae({ editor: this })), this._createMontageArea(), this._createClippingArea(), this.interactionBlocker.ensureOverlay(), this.listeners = new k({
|
|
10063
10787
|
editor: this,
|
|
10064
10788
|
options: this.options
|
|
10065
10789
|
}), this.canvasManager.setEditorContainerWidth(e), this.canvasManager.setEditorContainerHeight(n), this.canvasManager.setCanvasWrapperWidth(r), this.canvasManager.setCanvasWrapperHeight(i), this.canvasManager.setCanvasCSSWidth(a), this.canvasManager.setCanvasCSSHeight(o), this.canvasManager.updateCanvas(), this.zoomManager.calculateAndApplyDefaultZoom(), await this.fontManager.loadFonts(), c) {
|
|
@@ -10100,7 +10824,7 @@ var qr = class {
|
|
|
10100
10824
|
}
|
|
10101
10825
|
_createMontageArea() {
|
|
10102
10826
|
let { montageAreaWidth: t, montageAreaHeight: n } = this.options, r = new p(t / 2, n / 2);
|
|
10103
|
-
this.montageArea =
|
|
10827
|
+
this.montageArea = Ze({
|
|
10104
10828
|
canvas: this.canvas,
|
|
10105
10829
|
centerPoint: r,
|
|
10106
10830
|
options: {
|
|
@@ -10124,7 +10848,7 @@ var qr = class {
|
|
|
10124
10848
|
}
|
|
10125
10849
|
_createClippingArea() {
|
|
10126
10850
|
let { montageAreaWidth: e, montageAreaHeight: t } = this.options, n = new p(e / 2, t / 2);
|
|
10127
|
-
this.canvas.clipPath =
|
|
10851
|
+
this.canvas.clipPath = Ze({
|
|
10128
10852
|
canvas: this.canvas,
|
|
10129
10853
|
centerPoint: n,
|
|
10130
10854
|
options: {
|
|
@@ -10167,7 +10891,7 @@ var qr = class {
|
|
|
10167
10891
|
"U+A640-A69F",
|
|
10168
10892
|
"U+FE2E-FE2F",
|
|
10169
10893
|
"U+2116"
|
|
10170
|
-
].join(", "),
|
|
10894
|
+
].join(", "), na = {
|
|
10171
10895
|
preserveObjectStacking: !0,
|
|
10172
10896
|
controlsAboveOverlay: !0,
|
|
10173
10897
|
centeredRotation: !0,
|
|
@@ -11021,20 +11745,20 @@ var qr = class {
|
|
|
11021
11745
|
};
|
|
11022
11746
|
//#endregion
|
|
11023
11747
|
//#region src/main.ts
|
|
11024
|
-
function
|
|
11748
|
+
function ra(e, t = {}) {
|
|
11025
11749
|
let n = {
|
|
11026
|
-
|
|
11750
|
+
...na,
|
|
11027
11751
|
...t
|
|
11028
11752
|
}, r = document.getElementById(e);
|
|
11029
11753
|
if (!r) return Promise.reject(/* @__PURE__ */ Error(`Контейнер с ID "${e}" не найден.`));
|
|
11030
11754
|
let i = document.createElement("canvas");
|
|
11031
11755
|
return i.id = `${e}-canvas`, r.appendChild(i), n.editorContainer = r, new Promise((t) => {
|
|
11032
11756
|
n._onReadyCallback = t;
|
|
11033
|
-
let r = new
|
|
11757
|
+
let r = new ta(i.id, n);
|
|
11034
11758
|
window[e] = r;
|
|
11035
11759
|
});
|
|
11036
11760
|
}
|
|
11037
11761
|
//#endregion
|
|
11038
|
-
export {
|
|
11762
|
+
export { ra as default };
|
|
11039
11763
|
|
|
11040
11764
|
//# sourceMappingURL=main.js.map
|