@anu3ev/fabric-image-editor 0.7.4 → 0.7.5
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 +1365 -1079
- package/dist/stats.html +1 -1
- 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 ee(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 te(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 I(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 ne = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTE4Ljc1IDQuMzc1djMuNzVhLjYyNS42MjUgMCAwIDEtLjYyNS42MjVoLTMuNzVhLjYyNS42MjUgMCAwIDEgMC0xLjI1aDIuMTRsLTIuMDc3LTEuOTAzLS4wMi0uMDE5YTYuMjUgNi4yNSAwIDEgMC0uMTMgOC45NjcuNjI2LjYyNiAwIDAgMSAuODYuOTA5QTcuNDU2IDcuNDU2IDAgMCAxIDEwIDE3LjVoLS4xMDNhNy41IDcuNSAwIDEgMSA1LjM5Ni0xMi44MTJMMTcuNSA2LjcwM1Y0LjM3NWEuNjI1LjYyNSAwIDAgMSAxLjI1IDBaIi8+PC9zdmc+", re = new Image();
|
|
265
|
+
re.src = ne;
|
|
266
|
+
function L(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(re, -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 ie = {
|
|
272
272
|
tl: {
|
|
273
|
-
render:
|
|
273
|
+
render: ee,
|
|
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: ee,
|
|
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: ee,
|
|
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: ee,
|
|
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: te,
|
|
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: te,
|
|
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: I,
|
|
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: I,
|
|
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: L,
|
|
330
330
|
sizeX: 32,
|
|
331
331
|
sizeY: 32,
|
|
332
332
|
offsetX: 0,
|
|
333
333
|
offsetY: -32
|
|
334
334
|
}
|
|
335
|
-
},
|
|
335
|
+
}, R = class t {
|
|
336
336
|
static wrapWidthControl(e) {
|
|
337
337
|
if (!e?.actionHandler) return;
|
|
338
338
|
let t = e.actionHandler;
|
|
@@ -342,7 +342,7 @@ var re = {
|
|
|
342
342
|
};
|
|
343
343
|
}
|
|
344
344
|
static applyControlOverrides(e) {
|
|
345
|
-
Object.entries(
|
|
345
|
+
Object.entries(ie).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 re = {
|
|
|
432
432
|
mr: !0
|
|
433
433
|
});
|
|
434
434
|
}
|
|
435
|
-
},
|
|
435
|
+
}, ae = class e {
|
|
436
436
|
static {
|
|
437
437
|
this.registeredFontKeys = /* @__PURE__ */ new Set();
|
|
438
438
|
}
|
|
@@ -585,7 +585,7 @@ var re = {
|
|
|
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
|
+
}, z = {
|
|
589
589
|
style: {
|
|
590
590
|
position: "absolute",
|
|
591
591
|
display: "none",
|
|
@@ -687,7 +687,7 @@ var re = {
|
|
|
687
687
|
e.layerManager.sendBackwards();
|
|
688
688
|
}
|
|
689
689
|
}
|
|
690
|
-
},
|
|
690
|
+
}, oe = 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 re = {
|
|
|
695
695
|
if (!this.options.showToolbar) return;
|
|
696
696
|
let e = this.options.toolbar || {};
|
|
697
697
|
this.config = {
|
|
698
|
-
...
|
|
698
|
+
...z,
|
|
699
699
|
...e,
|
|
700
700
|
style: {
|
|
701
|
-
...
|
|
701
|
+
...z.style,
|
|
702
702
|
...e.style || {}
|
|
703
703
|
},
|
|
704
704
|
btnStyle: {
|
|
705
|
-
...
|
|
705
|
+
...z.btnStyle,
|
|
706
706
|
...e.btnStyle || {}
|
|
707
707
|
},
|
|
708
708
|
icons: {
|
|
709
|
-
...
|
|
709
|
+
...z.icons,
|
|
710
710
|
...e.icons || {}
|
|
711
711
|
},
|
|
712
712
|
handlers: {
|
|
713
|
-
...
|
|
713
|
+
...z.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 re = {
|
|
|
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
|
+
}, B = {
|
|
792
792
|
position: "absolute",
|
|
793
793
|
display: "none",
|
|
794
794
|
background: "#2B2D33",
|
|
@@ -802,12 +802,12 @@ var re = {
|
|
|
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
|
+
}, se = "fabric-editor-angle-indicator", ce = 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 = se, Object.entries(B).forEach(([e, t]) => {
|
|
811
811
|
this.el.style.setProperty(e, t);
|
|
812
812
|
}), this.canvas.wrapperEl.appendChild(this.el);
|
|
813
813
|
}
|
|
@@ -852,10 +852,10 @@ var re = {
|
|
|
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
|
+
}, le = /* @__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.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 V({ state: e }) {
|
|
859
859
|
return JSON.parse(JSON.stringify(e));
|
|
860
860
|
}
|
|
861
861
|
function H({ value: e }) {
|
|
@@ -925,7 +925,7 @@ function ge({ prevState: e, nextState: t }) {
|
|
|
925
925
|
o !== c || s !== l || (t.width = n, t.height = r);
|
|
926
926
|
}
|
|
927
927
|
function _e({ prevState: e, nextState: t }) {
|
|
928
|
-
let n =
|
|
928
|
+
let n = V({ state: e }), r = V({ state: t });
|
|
929
929
|
return he({ objects: n.objects }), he({ objects: r.objects }), ge({
|
|
930
930
|
prevState: n,
|
|
931
931
|
nextState: r
|
|
@@ -1122,7 +1122,7 @@ var Me = class {
|
|
|
1122
1122
|
}
|
|
1123
1123
|
_serializeCanvasState() {
|
|
1124
1124
|
let { canvas: e } = this;
|
|
1125
|
-
return e.toDatalessObject([...
|
|
1125
|
+
return e.toDatalessObject([...le]);
|
|
1126
1126
|
}
|
|
1127
1127
|
_handlePendingSaveTimeout() {
|
|
1128
1128
|
this._pendingSaveTimeoutId !== null && (this._pendingSaveTimeoutId = null, this._pendingSaveReason = null, this.saveState());
|
|
@@ -1197,7 +1197,7 @@ var Me = class {
|
|
|
1197
1197
|
e && (this._pendingSaveTimeoutId !== null && this._pendingSaveReason === e.reason && this._clearPendingSave(), e.reason === "text-edit" && this._deactivateTextEditing(), this._saveSerializedState({ currentStateObj: e.state }));
|
|
1198
1198
|
let t = je({
|
|
1199
1199
|
canvas: this.canvas,
|
|
1200
|
-
callback: () => this.canvas.toDatalessObject([...
|
|
1200
|
+
callback: () => this.canvas.toDatalessObject([...le])
|
|
1201
1201
|
});
|
|
1202
1202
|
console.timeEnd("saveState"), this._saveSerializedState({ currentStateObj: t });
|
|
1203
1203
|
} finally {
|
|
@@ -2780,37 +2780,37 @@ var Xe = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
|
|
|
2780
2780
|
});
|
|
2781
2781
|
}
|
|
2782
2782
|
}, G = 180, et = {
|
|
2783
|
-
top:
|
|
2784
|
-
right:
|
|
2785
|
-
bottom:
|
|
2786
|
-
left:
|
|
2787
|
-
}, tt = ({ value: e }) => Number(e.toFixed(4)),
|
|
2783
|
+
top: 0,
|
|
2784
|
+
right: 0,
|
|
2785
|
+
bottom: 0,
|
|
2786
|
+
left: 0
|
|
2787
|
+
}, tt = .45, nt = ({ value: e }) => Number(e.toFixed(4)), rt = ({ sides: e, radius: t = 50, centerX: n = 50, centerY: r = 50, rotation: i = -Math.PI / 2 }) => {
|
|
2788
2788
|
let a = [];
|
|
2789
2789
|
for (let o = 0; o < e; o += 1) {
|
|
2790
2790
|
let s = i + o * Math.PI * 2 / e;
|
|
2791
2791
|
a.push({
|
|
2792
|
-
x:
|
|
2793
|
-
y:
|
|
2792
|
+
x: nt({ value: n + t * Math.cos(s) }),
|
|
2793
|
+
y: nt({ value: r + t * Math.sin(s) })
|
|
2794
2794
|
});
|
|
2795
2795
|
}
|
|
2796
2796
|
return a;
|
|
2797
|
-
},
|
|
2797
|
+
}, it = ({ spikes: e, outerRadius: t = 50, innerRadius: n = 22, centerX: r = 50, centerY: i = 50, rotation: a = -Math.PI / 2 }) => {
|
|
2798
2798
|
let o = [], s = e * 2;
|
|
2799
2799
|
for (let c = 0; c < s; c += 1) {
|
|
2800
2800
|
let s = c % 2 == 0 ? t : n, l = a + c * Math.PI / e;
|
|
2801
2801
|
o.push({
|
|
2802
|
-
x:
|
|
2803
|
-
y:
|
|
2802
|
+
x: nt({ value: r + s * Math.cos(l) }),
|
|
2803
|
+
y: nt({ value: i + s * Math.sin(l) })
|
|
2804
2804
|
});
|
|
2805
2805
|
}
|
|
2806
2806
|
return o;
|
|
2807
|
-
},
|
|
2807
|
+
}, at = [
|
|
2808
2808
|
{
|
|
2809
2809
|
key: "circle",
|
|
2810
2810
|
type: "ellipse",
|
|
2811
2811
|
width: G,
|
|
2812
2812
|
height: G,
|
|
2813
|
-
|
|
2813
|
+
internalTextInset: {
|
|
2814
2814
|
top: .24,
|
|
2815
2815
|
right: .24,
|
|
2816
2816
|
bottom: .24,
|
|
@@ -2822,7 +2822,7 @@ var Xe = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
|
|
|
2822
2822
|
type: "triangle",
|
|
2823
2823
|
width: G,
|
|
2824
2824
|
height: G,
|
|
2825
|
-
|
|
2825
|
+
internalTextInset: {
|
|
2826
2826
|
top: .38,
|
|
2827
2827
|
right: .2,
|
|
2828
2828
|
bottom: .14,
|
|
@@ -2858,7 +2858,7 @@ var Xe = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
|
|
|
2858
2858
|
y: 50
|
|
2859
2859
|
}
|
|
2860
2860
|
],
|
|
2861
|
-
|
|
2861
|
+
internalTextInset: {
|
|
2862
2862
|
top: .3,
|
|
2863
2863
|
right: .3,
|
|
2864
2864
|
bottom: .3,
|
|
@@ -2870,12 +2870,12 @@ var Xe = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
|
|
|
2870
2870
|
type: "polygon",
|
|
2871
2871
|
width: G,
|
|
2872
2872
|
height: G,
|
|
2873
|
-
points:
|
|
2873
|
+
points: rt({
|
|
2874
2874
|
sides: 5,
|
|
2875
2875
|
radius: 50,
|
|
2876
2876
|
rotation: -Math.PI / 2
|
|
2877
2877
|
}),
|
|
2878
|
-
|
|
2878
|
+
internalTextInset: {
|
|
2879
2879
|
top: .28,
|
|
2880
2880
|
right: .2,
|
|
2881
2881
|
bottom: .2,
|
|
@@ -2887,12 +2887,12 @@ var Xe = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
|
|
|
2887
2887
|
type: "polygon",
|
|
2888
2888
|
width: G,
|
|
2889
2889
|
height: G,
|
|
2890
|
-
points:
|
|
2890
|
+
points: rt({
|
|
2891
2891
|
sides: 6,
|
|
2892
2892
|
radius: 50,
|
|
2893
2893
|
rotation: 0
|
|
2894
2894
|
}),
|
|
2895
|
-
|
|
2895
|
+
internalTextInset: {
|
|
2896
2896
|
top: .24,
|
|
2897
2897
|
right: .2,
|
|
2898
2898
|
bottom: .24,
|
|
@@ -2904,13 +2904,13 @@ var Xe = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
|
|
|
2904
2904
|
type: "polygon",
|
|
2905
2905
|
width: G,
|
|
2906
2906
|
height: G,
|
|
2907
|
-
points:
|
|
2907
|
+
points: it({
|
|
2908
2908
|
spikes: 5,
|
|
2909
2909
|
outerRadius: 50,
|
|
2910
2910
|
innerRadius: 21,
|
|
2911
2911
|
rotation: -Math.PI / 2
|
|
2912
2912
|
}),
|
|
2913
|
-
|
|
2913
|
+
internalTextInset: {
|
|
2914
2914
|
top: .32,
|
|
2915
2915
|
right: .32,
|
|
2916
2916
|
bottom: .32,
|
|
@@ -2922,13 +2922,13 @@ var Xe = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
|
|
|
2922
2922
|
type: "polygon",
|
|
2923
2923
|
width: G,
|
|
2924
2924
|
height: G,
|
|
2925
|
-
points:
|
|
2925
|
+
points: it({
|
|
2926
2926
|
spikes: 4,
|
|
2927
2927
|
outerRadius: 50,
|
|
2928
2928
|
innerRadius: 16,
|
|
2929
2929
|
rotation: -Math.PI / 2
|
|
2930
2930
|
}),
|
|
2931
|
-
|
|
2931
|
+
internalTextInset: {
|
|
2932
2932
|
top: .34,
|
|
2933
2933
|
right: .34,
|
|
2934
2934
|
bottom: .34,
|
|
@@ -2946,7 +2946,7 @@ var Xe = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
|
|
|
2946
2946
|
"C53 12 60 8 70 8 C84 8 96 19 96 35",
|
|
2947
2947
|
"C96 56 80 74 50 92 Z"
|
|
2948
2948
|
].join(" "),
|
|
2949
|
-
|
|
2949
|
+
internalTextInset: {
|
|
2950
2950
|
top: .3,
|
|
2951
2951
|
right: .28,
|
|
2952
2952
|
bottom: .22,
|
|
@@ -2988,7 +2988,7 @@ var Xe = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
|
|
|
2988
2988
|
y: 62
|
|
2989
2989
|
}
|
|
2990
2990
|
],
|
|
2991
|
-
|
|
2991
|
+
internalTextInset: {
|
|
2992
2992
|
top: .24,
|
|
2993
2993
|
right: .42,
|
|
2994
2994
|
bottom: .24,
|
|
@@ -3030,7 +3030,7 @@ var Xe = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
|
|
|
3030
3030
|
y: 100
|
|
3031
3031
|
}
|
|
3032
3032
|
],
|
|
3033
|
-
|
|
3033
|
+
internalTextInset: {
|
|
3034
3034
|
top: .4,
|
|
3035
3035
|
right: .24,
|
|
3036
3036
|
bottom: .16,
|
|
@@ -3072,7 +3072,7 @@ var Xe = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
|
|
|
3072
3072
|
y: 58
|
|
3073
3073
|
}
|
|
3074
3074
|
],
|
|
3075
|
-
|
|
3075
|
+
internalTextInset: {
|
|
3076
3076
|
top: .24,
|
|
3077
3077
|
right: .4,
|
|
3078
3078
|
bottom: .24,
|
|
@@ -3114,7 +3114,7 @@ var Xe = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
|
|
|
3114
3114
|
y: 0
|
|
3115
3115
|
}
|
|
3116
3116
|
],
|
|
3117
|
-
|
|
3117
|
+
internalTextInset: {
|
|
3118
3118
|
top: .16,
|
|
3119
3119
|
right: .24,
|
|
3120
3120
|
bottom: .4,
|
|
@@ -3168,7 +3168,7 @@ var Xe = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
|
|
|
3168
3168
|
y: 34
|
|
3169
3169
|
}
|
|
3170
3170
|
],
|
|
3171
|
-
|
|
3171
|
+
internalTextInset: {
|
|
3172
3172
|
top: .38,
|
|
3173
3173
|
right: .26,
|
|
3174
3174
|
bottom: .38,
|
|
@@ -3222,7 +3222,7 @@ var Xe = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
|
|
|
3222
3222
|
y: 82
|
|
3223
3223
|
}
|
|
3224
3224
|
],
|
|
3225
|
-
|
|
3225
|
+
internalTextInset: {
|
|
3226
3226
|
top: .26,
|
|
3227
3227
|
right: .34,
|
|
3228
3228
|
bottom: .26,
|
|
@@ -3235,7 +3235,7 @@ var Xe = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
|
|
|
3235
3235
|
width: 140,
|
|
3236
3236
|
height: G,
|
|
3237
3237
|
path: "M50 0 C68 18 88 41 88 62 C88 84 71 100 50 100 C29 100 12 84 12 62 C12 41 32 18 50 0 Z",
|
|
3238
|
-
|
|
3238
|
+
internalTextInset: {
|
|
3239
3239
|
top: .3,
|
|
3240
3240
|
right: .27,
|
|
3241
3241
|
bottom: .2,
|
|
@@ -3297,7 +3297,7 @@ var Xe = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
|
|
|
3297
3297
|
y: 36
|
|
3298
3298
|
}
|
|
3299
3299
|
],
|
|
3300
|
-
|
|
3300
|
+
internalTextInset: {
|
|
3301
3301
|
top: .34,
|
|
3302
3302
|
right: .34,
|
|
3303
3303
|
bottom: .34,
|
|
@@ -3309,13 +3309,13 @@ var Xe = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
|
|
|
3309
3309
|
type: "polygon",
|
|
3310
3310
|
width: G,
|
|
3311
3311
|
height: G,
|
|
3312
|
-
points:
|
|
3312
|
+
points: it({
|
|
3313
3313
|
spikes: 14,
|
|
3314
3314
|
outerRadius: 50,
|
|
3315
3315
|
innerRadius: 40,
|
|
3316
3316
|
rotation: -Math.PI / 2
|
|
3317
3317
|
}),
|
|
3318
|
-
|
|
3318
|
+
internalTextInset: {
|
|
3319
3319
|
top: .28,
|
|
3320
3320
|
right: .28,
|
|
3321
3321
|
bottom: .28,
|
|
@@ -3328,7 +3328,7 @@ var Xe = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
|
|
|
3328
3328
|
width: G,
|
|
3329
3329
|
height: G,
|
|
3330
3330
|
path: "M24 6 H76 L94 24 V76 L76 94 H24 L6 76 V24 Z",
|
|
3331
|
-
|
|
3331
|
+
internalTextInset: {
|
|
3332
3332
|
top: .24,
|
|
3333
3333
|
right: .24,
|
|
3334
3334
|
bottom: .24,
|
|
@@ -3362,7 +3362,7 @@ var Xe = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
|
|
|
3362
3362
|
y: 100
|
|
3363
3363
|
}
|
|
3364
3364
|
],
|
|
3365
|
-
|
|
3365
|
+
internalTextInset: {
|
|
3366
3366
|
top: .2,
|
|
3367
3367
|
right: .22,
|
|
3368
3368
|
bottom: .34,
|
|
@@ -3375,7 +3375,7 @@ var Xe = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
|
|
|
3375
3375
|
width: G,
|
|
3376
3376
|
height: 130,
|
|
3377
3377
|
path: "M4 20 L64 20 L96 50 L64 80 L4 80 Z",
|
|
3378
|
-
|
|
3378
|
+
internalTextInset: {
|
|
3379
3379
|
top: .24,
|
|
3380
3380
|
right: .34,
|
|
3381
3381
|
bottom: .24,
|
|
@@ -3393,28 +3393,45 @@ var Xe = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
|
|
|
3393
3393
|
"C82 102 58 78 58 48 C58 28 68 12 84 4",
|
|
3394
3394
|
"C79 4 74 4 68 4 Z"
|
|
3395
3395
|
].join(" "),
|
|
3396
|
-
|
|
3396
|
+
internalTextInset: {
|
|
3397
3397
|
top: .28,
|
|
3398
3398
|
right: .34,
|
|
3399
3399
|
bottom: .28,
|
|
3400
3400
|
left: .2
|
|
3401
3401
|
}
|
|
3402
3402
|
}
|
|
3403
|
-
],
|
|
3404
|
-
for (let e = 0; e <
|
|
3405
|
-
let t =
|
|
3406
|
-
|
|
3403
|
+
], ot = "circle", st = "center", ct = {};
|
|
3404
|
+
for (let e = 0; e < at.length; e += 1) {
|
|
3405
|
+
let t = at[e];
|
|
3406
|
+
ct[t.key] = t;
|
|
3407
3407
|
}
|
|
3408
|
-
var
|
|
3409
|
-
|
|
3408
|
+
var lt = ct, ut = ({ presetKey: e }) => lt[e] ?? null, dt = ({ preset: e, rounding: t }) => (typeof t == "number" ? t : 0) <= 0 || e.type === "rect" ? e.key : e.roundedVariant ?? e.key;
|
|
3409
|
+
function ft({ value: e, size: t }) {
|
|
3410
|
+
let n = Number.isFinite(e) ? Math.min(Math.max(e, 0), tt) : 0;
|
|
3411
|
+
return (Number.isFinite(t) && t > 0 ? t : 0) * n;
|
|
3412
|
+
}
|
|
3413
|
+
var pt = ({ preset: e, width: t, height: n }) => {
|
|
3414
|
+
let r = e.internalTextInset ?? {};
|
|
3410
3415
|
return {
|
|
3411
|
-
top:
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
|
|
3416
|
+
top: ft({
|
|
3417
|
+
value: r.top ?? et.top,
|
|
3418
|
+
size: n
|
|
3419
|
+
}),
|
|
3420
|
+
right: ft({
|
|
3421
|
+
value: r.right ?? et.right,
|
|
3422
|
+
size: t
|
|
3423
|
+
}),
|
|
3424
|
+
bottom: ft({
|
|
3425
|
+
value: r.bottom ?? et.bottom,
|
|
3426
|
+
size: n
|
|
3427
|
+
}),
|
|
3428
|
+
left: ft({
|
|
3429
|
+
value: r.left ?? et.left,
|
|
3430
|
+
size: t
|
|
3431
|
+
})
|
|
3415
3432
|
};
|
|
3416
|
-
}
|
|
3417
|
-
function
|
|
3433
|
+
};
|
|
3434
|
+
function mt({ path: e }) {
|
|
3418
3435
|
let t = e.match(/[a-zA-Z]/g) ?? [], n = new Set([
|
|
3419
3436
|
"M",
|
|
3420
3437
|
"L",
|
|
@@ -3428,13 +3445,24 @@ function pt({ path: e }) {
|
|
|
3428
3445
|
}
|
|
3429
3446
|
return t.length > 0;
|
|
3430
3447
|
}
|
|
3431
|
-
|
|
3432
|
-
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
|
|
3448
|
+
var ht = ({ preset: e }) => e.type === "rect" || e.type === "triangle" || e.type === "polygon" || e.type === "polyline" ? !0 : e.type === "ellipse" || e.type === "svg" ? !1 : mt({ path: e.path }), gt = 1, _t = 1e-4;
|
|
3449
|
+
function K({ value: e }) {
|
|
3450
|
+
return Number(e.toFixed(4));
|
|
3451
|
+
}
|
|
3452
|
+
function vt({ rounding: e }) {
|
|
3453
|
+
return Math.max(0, e ?? 0) > 0;
|
|
3454
|
+
}
|
|
3455
|
+
function yt({ width: e, height: t, strokeWidth: n }) {
|
|
3456
|
+
let r = Math.max(0, n ?? 0);
|
|
3457
|
+
return {
|
|
3458
|
+
width: Math.max(gt, e - r),
|
|
3459
|
+
height: Math.max(gt, t - r)
|
|
3460
|
+
};
|
|
3461
|
+
}
|
|
3462
|
+
function bt({ shape: e, width: t, height: n, rounding: r, strokeWidth: i }) {
|
|
3463
|
+
let a = yt({
|
|
3464
|
+
width: Math.max(gt, t),
|
|
3465
|
+
height: Math.max(gt, n),
|
|
3438
3466
|
strokeWidth: i
|
|
3439
3467
|
});
|
|
3440
3468
|
if (e instanceof g) {
|
|
@@ -3453,7 +3481,7 @@ function gt({ shape: e, width: t, height: n, rounding: r, strokeWidth: i }) {
|
|
|
3453
3481
|
}), e.setCoords();
|
|
3454
3482
|
return;
|
|
3455
3483
|
}
|
|
3456
|
-
let { width: o =
|
|
3484
|
+
let { width: o = gt, height: s = gt } = e, c = Math.max(gt, o), l = Math.max(gt, s);
|
|
3457
3485
|
e.set({
|
|
3458
3486
|
scaleX: a.width / c,
|
|
3459
3487
|
scaleY: a.height / l,
|
|
@@ -3463,33 +3491,11 @@ function gt({ shape: e, width: t, height: n, rounding: r, strokeWidth: i }) {
|
|
|
3463
3491
|
originY: "center"
|
|
3464
3492
|
}), e.setCoords();
|
|
3465
3493
|
}
|
|
3466
|
-
|
|
3467
|
-
let a = await yt({
|
|
3468
|
-
preset: e,
|
|
3469
|
-
rounding: i
|
|
3470
|
-
});
|
|
3471
|
-
return vt({
|
|
3472
|
-
shape: a,
|
|
3473
|
-
style: r
|
|
3474
|
-
}), gt({
|
|
3475
|
-
shape: a,
|
|
3476
|
-
width: t,
|
|
3477
|
-
height: n,
|
|
3478
|
-
rounding: i,
|
|
3479
|
-
strokeWidth: r.strokeWidth
|
|
3480
|
-
}), a.set({
|
|
3481
|
-
selectable: !1,
|
|
3482
|
-
evented: !1,
|
|
3483
|
-
hasControls: !1,
|
|
3484
|
-
hasBorders: !1,
|
|
3485
|
-
shapeNodeType: "shape"
|
|
3486
|
-
}), a;
|
|
3487
|
-
}
|
|
3488
|
-
function vt({ shape: e, style: t }) {
|
|
3494
|
+
function xt({ shape: e, style: t }) {
|
|
3489
3495
|
let { fill: n, stroke: r, strokeWidth: i, strokeDashArray: a, opacity: o } = t;
|
|
3490
3496
|
if (e instanceof l) {
|
|
3491
3497
|
let n = e.getObjects();
|
|
3492
|
-
for (let e = 0; e < n.length; e += 1)
|
|
3498
|
+
for (let e = 0; e < n.length; e += 1) xt({
|
|
3493
3499
|
shape: n[e],
|
|
3494
3500
|
style: t
|
|
3495
3501
|
});
|
|
@@ -3503,50 +3509,106 @@ function vt({ shape: e, style: t }) {
|
|
|
3503
3509
|
};
|
|
3504
3510
|
n !== void 0 && (s.fill = n), r !== void 0 && (s.stroke = r), i !== void 0 && (s.strokeWidth = i), a !== void 0 && (s.strokeDashArray = a), o !== void 0 && (s.opacity = o), e.set(s), e.setCoords();
|
|
3505
3511
|
}
|
|
3506
|
-
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
|
|
3510
|
-
|
|
3511
|
-
|
|
3512
|
-
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
|
|
3520
|
-
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
|
|
3531
|
-
|
|
3532
|
-
}
|
|
3533
|
-
|
|
3534
|
-
|
|
3512
|
+
function St({ points: e, closed: t }) {
|
|
3513
|
+
if (e.length === 0) return "";
|
|
3514
|
+
let n = `M ${K({ value: e[0].x })} ${K({ value: e[0].y })}`;
|
|
3515
|
+
for (let t = 1; t < e.length; t += 1) {
|
|
3516
|
+
let r = e[t];
|
|
3517
|
+
n += ` L ${K({ value: r.x })} ${K({ value: r.y })}`;
|
|
3518
|
+
}
|
|
3519
|
+
return t && (n += " Z"), n;
|
|
3520
|
+
}
|
|
3521
|
+
function Ct({ previous: e, current: t, next: n, radius: r }) {
|
|
3522
|
+
let i = {
|
|
3523
|
+
x: e.x - t.x,
|
|
3524
|
+
y: e.y - t.y
|
|
3525
|
+
}, a = {
|
|
3526
|
+
x: n.x - t.x,
|
|
3527
|
+
y: n.y - t.y
|
|
3528
|
+
}, o = Math.hypot(i.x, i.y), s = Math.hypot(a.x, a.y);
|
|
3529
|
+
if (o <= _t || s <= _t) return {
|
|
3530
|
+
start: {
|
|
3531
|
+
x: K({ value: t.x }),
|
|
3532
|
+
y: K({ value: t.y })
|
|
3533
|
+
},
|
|
3534
|
+
end: {
|
|
3535
|
+
x: K({ value: t.x }),
|
|
3536
|
+
y: K({ value: t.y })
|
|
3537
|
+
}
|
|
3538
|
+
};
|
|
3539
|
+
let c = Math.min(Math.max(0, r), o / 2, s / 2);
|
|
3540
|
+
return {
|
|
3541
|
+
start: {
|
|
3542
|
+
x: K({ value: t.x + i.x / o * c }),
|
|
3543
|
+
y: K({ value: t.y + i.y / o * c })
|
|
3544
|
+
},
|
|
3545
|
+
end: {
|
|
3546
|
+
x: K({ value: t.x + a.x / s * c }),
|
|
3547
|
+
y: K({ value: t.y + a.y / s * c })
|
|
3548
|
+
}
|
|
3549
|
+
};
|
|
3550
|
+
}
|
|
3551
|
+
function wt({ points: e, radius: t, closed: n }) {
|
|
3552
|
+
let r = e.length;
|
|
3553
|
+
if (r === 0) return "";
|
|
3554
|
+
if (!n && r === 1) {
|
|
3555
|
+
let t = e[0];
|
|
3556
|
+
return `M ${K({ value: t.x })} ${K({ value: t.y })}`;
|
|
3557
|
+
}
|
|
3558
|
+
let i = Math.max(0, t);
|
|
3559
|
+
if (i <= 0) return St({
|
|
3560
|
+
points: e,
|
|
3561
|
+
closed: n
|
|
3562
|
+
});
|
|
3563
|
+
if (n) {
|
|
3564
|
+
let t = [];
|
|
3565
|
+
for (let n = 0; n < r; n += 1) {
|
|
3566
|
+
let a = n === 0 ? r - 1 : n - 1, o = n === r - 1 ? 0 : n + 1;
|
|
3567
|
+
t.push(Ct({
|
|
3568
|
+
previous: e[a],
|
|
3569
|
+
current: e[n],
|
|
3570
|
+
next: e[o],
|
|
3571
|
+
radius: i
|
|
3572
|
+
}));
|
|
3573
|
+
}
|
|
3574
|
+
let n = t[0], a = `M ${n.start.x} ${n.start.y}`;
|
|
3575
|
+
for (let n = 0; n < r; n += 1) {
|
|
3576
|
+
let i = e[n], o = t[n], s = t[n === r - 1 ? 0 : n + 1];
|
|
3577
|
+
a += ` Q ${i.x} ${i.y} ${o.end.x} ${o.end.y}`, a += ` L ${s.start.x} ${s.start.y}`;
|
|
3578
|
+
}
|
|
3579
|
+
return a += " Z", a;
|
|
3580
|
+
}
|
|
3581
|
+
if (r === 2) return St({
|
|
3582
|
+
points: e,
|
|
3583
|
+
closed: !1
|
|
3584
|
+
});
|
|
3585
|
+
let a = `M ${K({ value: e[0].x })} ${K({ value: e[0].y })}`;
|
|
3586
|
+
for (let t = 1; t < r - 1; t += 1) {
|
|
3587
|
+
let n = Ct({
|
|
3588
|
+
previous: e[t - 1],
|
|
3589
|
+
current: e[t],
|
|
3590
|
+
next: e[t + 1],
|
|
3591
|
+
radius: i
|
|
3592
|
+
});
|
|
3593
|
+
a += ` L ${n.start.x} ${n.start.y}`, a += ` Q ${e[t].x} ${e[t].y} ${n.end.x} ${n.end.y}`;
|
|
3594
|
+
}
|
|
3595
|
+
let o = e[r - 1];
|
|
3596
|
+
return a += ` L ${K({ value: o.x })} ${K({ value: o.y })}`, a;
|
|
3597
|
+
}
|
|
3598
|
+
function Tt({ points: e, rounding: t, closed: n }) {
|
|
3599
|
+
return new d(wt({
|
|
3600
|
+
points: e,
|
|
3601
|
+
radius: t,
|
|
3602
|
+
closed: n
|
|
3603
|
+
}), {
|
|
3535
3604
|
originX: "center",
|
|
3536
3605
|
originY: "center",
|
|
3537
3606
|
left: 0,
|
|
3538
3607
|
top: 0
|
|
3539
3608
|
});
|
|
3540
3609
|
}
|
|
3541
|
-
function
|
|
3542
|
-
|
|
3543
|
-
return {
|
|
3544
|
-
width: Math.max(mt, e - r),
|
|
3545
|
-
height: Math.max(mt, t - r)
|
|
3546
|
-
};
|
|
3547
|
-
}
|
|
3548
|
-
function xt({ rounding: e }) {
|
|
3549
|
-
return At({ rounding: e }) ? Et({
|
|
3610
|
+
function Et({ rounding: e }) {
|
|
3611
|
+
return vt({ rounding: e }) ? Tt({
|
|
3550
3612
|
points: [
|
|
3551
3613
|
{
|
|
3552
3614
|
x: 50,
|
|
@@ -3572,52 +3634,7 @@ function xt({ rounding: e }) {
|
|
|
3572
3634
|
top: 0
|
|
3573
3635
|
});
|
|
3574
3636
|
}
|
|
3575
|
-
function
|
|
3576
|
-
return At({ rounding: t }) && Tt({
|
|
3577
|
-
path: e,
|
|
3578
|
-
rounding: Math.max(0, t ?? 0)
|
|
3579
|
-
}) || wt({ path: e });
|
|
3580
|
-
}
|
|
3581
|
-
function Ct({ points: e, type: t, rounding: n }) {
|
|
3582
|
-
let r = e.length > 0 ? e : [
|
|
3583
|
-
{
|
|
3584
|
-
x: 0,
|
|
3585
|
-
y: 0
|
|
3586
|
-
},
|
|
3587
|
-
{
|
|
3588
|
-
x: 100,
|
|
3589
|
-
y: 0
|
|
3590
|
-
},
|
|
3591
|
-
{
|
|
3592
|
-
x: 100,
|
|
3593
|
-
y: 100
|
|
3594
|
-
}
|
|
3595
|
-
];
|
|
3596
|
-
if (At({ rounding: n })) {
|
|
3597
|
-
if (t === "polygon" && r.length >= 3) return Et({
|
|
3598
|
-
points: r,
|
|
3599
|
-
rounding: Math.max(0, n ?? 0),
|
|
3600
|
-
closed: !0
|
|
3601
|
-
});
|
|
3602
|
-
if (t === "polyline" && r.length >= 2) return Et({
|
|
3603
|
-
points: r,
|
|
3604
|
-
rounding: Math.max(0, n ?? 0),
|
|
3605
|
-
closed: !1
|
|
3606
|
-
});
|
|
3607
|
-
}
|
|
3608
|
-
return t === "polyline" ? new h(r, {
|
|
3609
|
-
originX: "center",
|
|
3610
|
-
originY: "center",
|
|
3611
|
-
left: 0,
|
|
3612
|
-
top: 0
|
|
3613
|
-
}) : new m(r, {
|
|
3614
|
-
originX: "center",
|
|
3615
|
-
originY: "center",
|
|
3616
|
-
left: 0,
|
|
3617
|
-
top: 0
|
|
3618
|
-
});
|
|
3619
|
-
}
|
|
3620
|
-
function wt({ path: e }) {
|
|
3637
|
+
function Dt({ path: e }) {
|
|
3621
3638
|
return new d(e, {
|
|
3622
3639
|
originX: "center",
|
|
3623
3640
|
originY: "center",
|
|
@@ -3625,8 +3642,8 @@ function wt({ path: e }) {
|
|
|
3625
3642
|
top: 0
|
|
3626
3643
|
});
|
|
3627
3644
|
}
|
|
3628
|
-
function
|
|
3629
|
-
let n =
|
|
3645
|
+
function Ot({ path: e, rounding: t }) {
|
|
3646
|
+
let n = Dt({ path: e }).path ?? [], r = C.makePathSimpler(n), i = [], a = !1;
|
|
3630
3647
|
for (let e = 0; e < r.length; e += 1) {
|
|
3631
3648
|
let t = r[e];
|
|
3632
3649
|
if (!t) return null;
|
|
@@ -3646,154 +3663,383 @@ function Tt({ path: e, rounding: t }) {
|
|
|
3646
3663
|
}
|
|
3647
3664
|
return null;
|
|
3648
3665
|
}
|
|
3649
|
-
return i.length < 2 || a && i.length < 3 ? null :
|
|
3666
|
+
return i.length < 2 || a && i.length < 3 ? null : Tt({
|
|
3650
3667
|
points: i,
|
|
3651
3668
|
rounding: t,
|
|
3652
3669
|
closed: a
|
|
3653
3670
|
});
|
|
3654
3671
|
}
|
|
3655
|
-
function
|
|
3656
|
-
return
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
3672
|
+
function kt({ path: e, rounding: t }) {
|
|
3673
|
+
return vt({ rounding: t }) && Ot({
|
|
3674
|
+
path: e,
|
|
3675
|
+
rounding: Math.max(0, t ?? 0)
|
|
3676
|
+
}) || Dt({ path: e });
|
|
3677
|
+
}
|
|
3678
|
+
function At({ points: e, type: t, rounding: n }) {
|
|
3679
|
+
let r = e.length > 0 ? e : [
|
|
3680
|
+
{
|
|
3681
|
+
x: 0,
|
|
3682
|
+
y: 0
|
|
3683
|
+
},
|
|
3684
|
+
{
|
|
3685
|
+
x: 100,
|
|
3686
|
+
y: 0
|
|
3687
|
+
},
|
|
3688
|
+
{
|
|
3689
|
+
x: 100,
|
|
3690
|
+
y: 100
|
|
3691
|
+
}
|
|
3692
|
+
], i = Math.max(0, n ?? 0);
|
|
3693
|
+
if (vt({ rounding: n })) {
|
|
3694
|
+
if (t === "polygon" && r.length >= 3) return Tt({
|
|
3695
|
+
points: r,
|
|
3696
|
+
rounding: i,
|
|
3697
|
+
closed: !0
|
|
3698
|
+
});
|
|
3699
|
+
if (t === "polyline" && r.length >= 2) return Tt({
|
|
3700
|
+
points: r,
|
|
3701
|
+
rounding: i,
|
|
3702
|
+
closed: !1
|
|
3703
|
+
});
|
|
3704
|
+
}
|
|
3705
|
+
return new (t === "polyline" ? h : m)(r, {
|
|
3661
3706
|
originX: "center",
|
|
3662
3707
|
originY: "center",
|
|
3663
3708
|
left: 0,
|
|
3664
3709
|
top: 0
|
|
3665
3710
|
});
|
|
3666
3711
|
}
|
|
3667
|
-
function
|
|
3668
|
-
let
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3712
|
+
async function jt({ svg: e }) {
|
|
3713
|
+
let t = await x(e), n = C.groupSVGElements(t.objects, t.options);
|
|
3714
|
+
return n.set({
|
|
3715
|
+
originX: "center",
|
|
3716
|
+
originY: "center",
|
|
3717
|
+
left: 0,
|
|
3718
|
+
top: 0
|
|
3719
|
+
}), n.setCoords(), n;
|
|
3720
|
+
}
|
|
3721
|
+
async function Mt({ preset: e, rounding: t }) {
|
|
3722
|
+
switch (e.type) {
|
|
3723
|
+
case "rect": return new g({
|
|
3724
|
+
width: 100,
|
|
3725
|
+
height: 100,
|
|
3726
|
+
originX: "center",
|
|
3727
|
+
originY: "center",
|
|
3728
|
+
left: 0,
|
|
3729
|
+
top: 0
|
|
3730
|
+
});
|
|
3731
|
+
case "ellipse": return new i({
|
|
3732
|
+
rx: 50,
|
|
3733
|
+
ry: 50,
|
|
3734
|
+
originX: "center",
|
|
3735
|
+
originY: "center",
|
|
3736
|
+
left: 0,
|
|
3737
|
+
top: 0
|
|
3738
|
+
});
|
|
3739
|
+
case "triangle": return Et({ rounding: t });
|
|
3740
|
+
case "polygon": return At({
|
|
3741
|
+
points: e.points,
|
|
3742
|
+
type: "polygon",
|
|
3743
|
+
rounding: t
|
|
3744
|
+
});
|
|
3745
|
+
case "polyline": return At({
|
|
3746
|
+
points: e.points,
|
|
3747
|
+
type: "polyline",
|
|
3748
|
+
rounding: t
|
|
3749
|
+
});
|
|
3750
|
+
case "path": return kt({
|
|
3751
|
+
path: e.path,
|
|
3752
|
+
rounding: t
|
|
3753
|
+
});
|
|
3754
|
+
case "svg": return jt({ svg: e.svg });
|
|
3755
|
+
default: return new g({
|
|
3756
|
+
width: 100,
|
|
3757
|
+
height: 100,
|
|
3758
|
+
originX: "center",
|
|
3759
|
+
originY: "center",
|
|
3760
|
+
left: 0,
|
|
3761
|
+
top: 0
|
|
3762
|
+
});
|
|
3673
3763
|
}
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3764
|
+
}
|
|
3765
|
+
async function Nt({ preset: e, width: t, height: n, style: r, rounding: i }) {
|
|
3766
|
+
let a = await Mt({
|
|
3767
|
+
preset: e,
|
|
3768
|
+
rounding: i
|
|
3678
3769
|
});
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
|
|
3689
|
-
|
|
3690
|
-
|
|
3691
|
-
|
|
3692
|
-
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
|
|
3770
|
+
return xt({
|
|
3771
|
+
shape: a,
|
|
3772
|
+
style: r
|
|
3773
|
+
}), bt({
|
|
3774
|
+
shape: a,
|
|
3775
|
+
width: t,
|
|
3776
|
+
height: n,
|
|
3777
|
+
rounding: i,
|
|
3778
|
+
strokeWidth: r.strokeWidth
|
|
3779
|
+
}), a.set({
|
|
3780
|
+
selectable: !1,
|
|
3781
|
+
evented: !1,
|
|
3782
|
+
hasControls: !1,
|
|
3783
|
+
hasBorders: !1,
|
|
3784
|
+
shapeNodeType: "shape"
|
|
3785
|
+
}), a;
|
|
3786
|
+
}
|
|
3787
|
+
//#endregion
|
|
3788
|
+
//#region src/editor/shape-manager/layout/shape-padding.ts
|
|
3789
|
+
function Pt({ value: e }) {
|
|
3790
|
+
return Number.isFinite(e) ? Math.max(0, e ?? 0) : 0;
|
|
3791
|
+
}
|
|
3792
|
+
function Ft({ value: e }) {
|
|
3793
|
+
return Number.isFinite(e) ? Math.max(0, Math.floor(e ?? 0)) : 0;
|
|
3794
|
+
}
|
|
3795
|
+
function It({ padding: e }) {
|
|
3796
|
+
return {
|
|
3797
|
+
top: Pt({ value: e?.top }),
|
|
3798
|
+
right: Pt({ value: e?.right }),
|
|
3799
|
+
bottom: Pt({ value: e?.bottom }),
|
|
3800
|
+
left: Pt({ value: e?.left })
|
|
3801
|
+
};
|
|
3802
|
+
}
|
|
3803
|
+
function Lt({ padding: e }) {
|
|
3804
|
+
return {
|
|
3805
|
+
top: Ft({ value: e?.top }),
|
|
3806
|
+
right: Ft({ value: e?.right }),
|
|
3807
|
+
bottom: Ft({ value: e?.bottom }),
|
|
3808
|
+
left: Ft({ value: e?.left })
|
|
3809
|
+
};
|
|
3810
|
+
}
|
|
3811
|
+
function Rt({ base: e, override: t }) {
|
|
3812
|
+
return t ? Lt({ padding: {
|
|
3813
|
+
top: t.top ?? e.top,
|
|
3814
|
+
right: t.right ?? e.right,
|
|
3815
|
+
bottom: t.bottom ?? e.bottom,
|
|
3816
|
+
left: t.left ?? e.left
|
|
3817
|
+
} }) : e;
|
|
3818
|
+
}
|
|
3819
|
+
function zt({ base: e, addition: t }) {
|
|
3820
|
+
let n = It({ padding: e }), r = It({ padding: t });
|
|
3821
|
+
return {
|
|
3822
|
+
top: n.top + r.top,
|
|
3823
|
+
right: n.right + r.right,
|
|
3824
|
+
bottom: n.bottom + r.bottom,
|
|
3825
|
+
left: n.left + r.left
|
|
3826
|
+
};
|
|
3827
|
+
}
|
|
3828
|
+
function Bt({ padding: e }) {
|
|
3829
|
+
if (!e) return {};
|
|
3830
|
+
let t = {}, n = Object.keys(e);
|
|
3831
|
+
for (let r = 0; r < n.length; r += 1) {
|
|
3832
|
+
let i = n[r];
|
|
3833
|
+
e[i] !== void 0 && (t[i] = !0);
|
|
3696
3834
|
}
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3835
|
+
return t;
|
|
3836
|
+
}
|
|
3837
|
+
//#endregion
|
|
3838
|
+
//#region src/editor/shape-manager/layout/shape-layout-padding.ts
|
|
3839
|
+
var Vt = .5, Ht = 12;
|
|
3840
|
+
function Ut({ width: e, padding: t }) {
|
|
3841
|
+
let n = Math.max(0, t.left), r = Math.max(0, t.right);
|
|
3842
|
+
return Math.max(1, e - n - r);
|
|
3843
|
+
}
|
|
3844
|
+
function Wt({ text: e }) {
|
|
3845
|
+
return (e.text ?? "").trim().length > 0;
|
|
3846
|
+
}
|
|
3847
|
+
function Gt({ start: e, end: t, maxTotalPadding: n, startChanged: r, endChanged: i }) {
|
|
3848
|
+
let a = Math.max(0, e), o = Math.max(0, t), s = Math.max(0, n);
|
|
3849
|
+
if (a + o <= s + Vt) return {
|
|
3850
|
+
start: a,
|
|
3851
|
+
end: o
|
|
3852
|
+
};
|
|
3853
|
+
if (r && !i) {
|
|
3854
|
+
let e = Math.min(o, s);
|
|
3855
|
+
return {
|
|
3856
|
+
start: Math.min(a, Math.max(0, s - e)),
|
|
3857
|
+
end: e
|
|
3858
|
+
};
|
|
3710
3859
|
}
|
|
3711
|
-
|
|
3712
|
-
|
|
3860
|
+
if (i && !r) {
|
|
3861
|
+
let e = Math.min(a, s);
|
|
3862
|
+
return {
|
|
3863
|
+
start: e,
|
|
3864
|
+
end: Math.min(o, Math.max(0, s - e))
|
|
3865
|
+
};
|
|
3866
|
+
}
|
|
3867
|
+
let c = a + o;
|
|
3868
|
+
if (c <= 0) return {
|
|
3869
|
+
start: 0,
|
|
3870
|
+
end: 0
|
|
3871
|
+
};
|
|
3872
|
+
let l = s / c;
|
|
3873
|
+
return {
|
|
3874
|
+
start: a * l,
|
|
3875
|
+
end: o * l
|
|
3876
|
+
};
|
|
3713
3877
|
}
|
|
3714
|
-
function
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
|
|
3878
|
+
function Kt({ start: e, end: t, insetStart: n, insetEnd: r, maxTotalPadding: i, startChanged: a, endChanged: o }) {
|
|
3879
|
+
let s = Gt({
|
|
3880
|
+
start: n + Math.max(0, e),
|
|
3881
|
+
end: r + Math.max(0, t),
|
|
3882
|
+
maxTotalPadding: i,
|
|
3883
|
+
startChanged: a,
|
|
3884
|
+
endChanged: o
|
|
3885
|
+
}), c = Math.max(0, Math.floor(s.start - n)), l = Math.max(0, Math.floor(s.end - r));
|
|
3886
|
+
return {
|
|
3887
|
+
appliedPaddingStart: n + c,
|
|
3888
|
+
appliedPaddingEnd: r + l,
|
|
3889
|
+
appliedUserPaddingStart: c,
|
|
3890
|
+
appliedUserPaddingEnd: l
|
|
3891
|
+
};
|
|
3892
|
+
}
|
|
3893
|
+
function qt({ text: e, minFrameWidth: t, maxFrameWidth: n, frameHeight: r, measureTextboxHeightForFrame: i }) {
|
|
3894
|
+
let a = Math.max(1, t), o = Math.max(a, n), s = Math.max(1, r);
|
|
3895
|
+
if (!Wt({ text: e }) || i({
|
|
3896
|
+
text: e,
|
|
3897
|
+
frameWidth: a
|
|
3898
|
+
}) <= s + Vt) return a;
|
|
3899
|
+
if (i({
|
|
3900
|
+
text: e,
|
|
3901
|
+
frameWidth: o
|
|
3902
|
+
}) > s + Vt) return o;
|
|
3903
|
+
let c = a, l = o;
|
|
3904
|
+
for (let t = 0; t < Ht; t += 1) {
|
|
3905
|
+
let t = (c + l) / 2;
|
|
3906
|
+
if (i({
|
|
3907
|
+
text: e,
|
|
3908
|
+
frameWidth: t
|
|
3909
|
+
}) <= s + Vt) {
|
|
3910
|
+
l = t;
|
|
3911
|
+
continue;
|
|
3912
|
+
}
|
|
3913
|
+
c = t;
|
|
3720
3914
|
}
|
|
3721
|
-
return
|
|
3915
|
+
return l;
|
|
3722
3916
|
}
|
|
3723
|
-
function
|
|
3724
|
-
let i =
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
3917
|
+
function Jt({ text: e, width: t, height: n, padding: r, internalShapeTextInset: i, expandShapeHeightToFitText: a, changedPadding: o, measureTextboxHeightForFrame: s, resolveMinimumTextFrameWidth: c }) {
|
|
3918
|
+
let l = Math.max(1, t), u = Math.max(1, n), d = Wt({ text: e }) ? c({ text: e }) : 1, f = i.top + i.bottom, p = Math.max(1, u - f), m = d;
|
|
3919
|
+
a || (m = qt({
|
|
3920
|
+
text: e,
|
|
3921
|
+
minFrameWidth: d,
|
|
3922
|
+
maxFrameWidth: l,
|
|
3923
|
+
frameHeight: p,
|
|
3924
|
+
measureTextboxHeightForFrame: s
|
|
3925
|
+
}));
|
|
3926
|
+
let h = Math.max(0, l - m), g = Kt({
|
|
3927
|
+
start: r.left,
|
|
3928
|
+
end: r.right,
|
|
3929
|
+
insetStart: i.left,
|
|
3930
|
+
insetEnd: i.right,
|
|
3931
|
+
maxTotalPadding: h,
|
|
3932
|
+
startChanged: !!o?.left,
|
|
3933
|
+
endChanged: !!o?.right
|
|
3934
|
+
});
|
|
3935
|
+
return {
|
|
3936
|
+
appliedPadding: {
|
|
3937
|
+
left: g.appliedPaddingStart,
|
|
3938
|
+
right: g.appliedPaddingEnd
|
|
3735
3939
|
},
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
3940
|
+
appliedUserPadding: {
|
|
3941
|
+
left: g.appliedUserPaddingStart,
|
|
3942
|
+
right: g.appliedUserPaddingEnd
|
|
3739
3943
|
}
|
|
3740
3944
|
};
|
|
3741
|
-
|
|
3945
|
+
}
|
|
3946
|
+
function Yt({ padding: e, internalShapeTextInset: t, height: n, textHeight: r, changedPadding: i }) {
|
|
3947
|
+
let a = Math.max(0, Math.max(1, n) - Math.max(1, r)), o = Kt({
|
|
3948
|
+
start: e.top,
|
|
3949
|
+
end: e.bottom,
|
|
3950
|
+
insetStart: t.top,
|
|
3951
|
+
insetEnd: t.bottom,
|
|
3952
|
+
maxTotalPadding: a,
|
|
3953
|
+
startChanged: !!i?.top,
|
|
3954
|
+
endChanged: !!i?.bottom
|
|
3955
|
+
});
|
|
3742
3956
|
return {
|
|
3743
|
-
|
|
3744
|
-
|
|
3745
|
-
|
|
3957
|
+
appliedPadding: {
|
|
3958
|
+
top: o.appliedPaddingStart,
|
|
3959
|
+
bottom: o.appliedPaddingEnd
|
|
3746
3960
|
},
|
|
3747
|
-
|
|
3748
|
-
|
|
3749
|
-
|
|
3961
|
+
appliedUserPadding: {
|
|
3962
|
+
top: o.appliedUserPaddingStart,
|
|
3963
|
+
bottom: o.appliedUserPaddingEnd
|
|
3750
3964
|
}
|
|
3751
3965
|
};
|
|
3752
3966
|
}
|
|
3753
|
-
function
|
|
3754
|
-
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
|
|
3758
|
-
|
|
3759
|
-
|
|
3760
|
-
|
|
3761
|
-
|
|
3762
|
-
|
|
3763
|
-
|
|
3764
|
-
|
|
3765
|
-
|
|
3766
|
-
|
|
3967
|
+
function Xt({ text: e, width: t, height: n, padding: r, internalShapeTextInset: i, expandShapeHeightToFitText: a, changedPadding: o, measureTextboxHeightForFrame: s, resolveMinimumTextFrameWidth: c }) {
|
|
3968
|
+
let l = Math.max(1, t), u = Math.max(1, n), d = It({ padding: r }), f = It({ padding: i }), p = Jt({
|
|
3969
|
+
text: e,
|
|
3970
|
+
width: l,
|
|
3971
|
+
height: u,
|
|
3972
|
+
padding: d,
|
|
3973
|
+
internalShapeTextInset: f,
|
|
3974
|
+
expandShapeHeightToFitText: a,
|
|
3975
|
+
changedPadding: o,
|
|
3976
|
+
measureTextboxHeightForFrame: s,
|
|
3977
|
+
resolveMinimumTextFrameWidth: c
|
|
3978
|
+
}), m = Ut({
|
|
3979
|
+
width: l,
|
|
3980
|
+
padding: {
|
|
3981
|
+
top: 0,
|
|
3982
|
+
right: p.appliedPadding.right,
|
|
3983
|
+
bottom: 0,
|
|
3984
|
+
left: p.appliedPadding.left
|
|
3985
|
+
}
|
|
3986
|
+
}), h = Wt({ text: e }) ? s({
|
|
3987
|
+
text: e,
|
|
3988
|
+
frameWidth: m
|
|
3989
|
+
}) : 1, g = f.top + f.bottom, _ = a ? Math.max(u, h + g) : u, v = Yt({
|
|
3990
|
+
padding: d,
|
|
3991
|
+
internalShapeTextInset: f,
|
|
3992
|
+
height: _,
|
|
3993
|
+
textHeight: h,
|
|
3994
|
+
changedPadding: o
|
|
3995
|
+
});
|
|
3996
|
+
return {
|
|
3997
|
+
appliedPadding: {
|
|
3998
|
+
top: v.appliedPadding.top,
|
|
3999
|
+
right: p.appliedPadding.right,
|
|
4000
|
+
bottom: v.appliedPadding.bottom,
|
|
4001
|
+
left: p.appliedPadding.left
|
|
4002
|
+
},
|
|
4003
|
+
appliedUserPadding: {
|
|
4004
|
+
top: v.appliedUserPadding.top,
|
|
4005
|
+
right: p.appliedUserPadding.right,
|
|
4006
|
+
bottom: v.appliedUserPadding.bottom,
|
|
4007
|
+
left: p.appliedUserPadding.left
|
|
4008
|
+
},
|
|
4009
|
+
requiredHeight: _
|
|
4010
|
+
};
|
|
3767
4011
|
}
|
|
3768
4012
|
//#endregion
|
|
3769
|
-
//#region src/editor/shape-manager/shape-layout.ts
|
|
3770
|
-
var q = 1,
|
|
3771
|
-
let
|
|
4013
|
+
//#region src/editor/shape-manager/layout/shape-layout.ts
|
|
4014
|
+
var q = 1, Zt = .5, Qt = 8, $t = ({ group: e, shape: t, text: n, width: r, height: i, alignH: a, alignV: o, padding: s, internalShapeTextInset: c, expandShapeHeightToFitText: l = !0, changedPadding: u }) => {
|
|
4015
|
+
let d = Lt({ padding: s }), f = It({ padding: c }), p = Math.max(q, e.shapeManualBaseWidth ?? r), m = Math.max(q, e.shapeManualBaseHeight ?? i), h = un({ text: n }), g = Math.max(q, r, h), { appliedPadding: _, appliedUserPadding: v, requiredHeight: y } = Xt({
|
|
3772
4016
|
text: n,
|
|
3773
|
-
|
|
3774
|
-
}), f = Math.max(q, r, d), p = Ht({
|
|
3775
|
-
text: n,
|
|
3776
|
-
width: f,
|
|
4017
|
+
width: g,
|
|
3777
4018
|
height: i,
|
|
3778
|
-
padding:
|
|
3779
|
-
|
|
3780
|
-
|
|
4019
|
+
padding: d,
|
|
4020
|
+
internalShapeTextInset: f,
|
|
4021
|
+
expandShapeHeightToFitText: l,
|
|
4022
|
+
changedPadding: u,
|
|
4023
|
+
measureTextboxHeightForFrame: ln,
|
|
4024
|
+
resolveMinimumTextFrameWidth: un
|
|
4025
|
+
}), b = Math.max(q, y);
|
|
4026
|
+
bt({
|
|
3781
4027
|
shape: t,
|
|
3782
|
-
width:
|
|
3783
|
-
height:
|
|
4028
|
+
width: g,
|
|
4029
|
+
height: b,
|
|
3784
4030
|
rounding: e.shapeRounding,
|
|
3785
4031
|
strokeWidth: e.shapeStrokeWidth
|
|
3786
4032
|
});
|
|
3787
|
-
let { frame:
|
|
4033
|
+
let { frame: x, splitByGrapheme: S, textTop: C } = nn({
|
|
3788
4034
|
text: n,
|
|
3789
|
-
width:
|
|
3790
|
-
height:
|
|
4035
|
+
width: g,
|
|
4036
|
+
height: b,
|
|
3791
4037
|
alignV: o,
|
|
3792
|
-
padding:
|
|
4038
|
+
padding: _
|
|
3793
4039
|
});
|
|
3794
4040
|
n.set({
|
|
3795
4041
|
autoExpand: !1,
|
|
3796
|
-
width:
|
|
4042
|
+
width: x.width,
|
|
3797
4043
|
textAlign: a,
|
|
3798
4044
|
scaleX: 1,
|
|
3799
4045
|
scaleY: 1,
|
|
@@ -3802,145 +4048,97 @@ var q = 1, Mt = .5, Nt = 12, Pt = 12, Ft = .45, It = 8, Lt = 8, Rt = ({ group: e
|
|
|
3802
4048
|
skewY: 0,
|
|
3803
4049
|
flipX: !1,
|
|
3804
4050
|
flipY: !1,
|
|
3805
|
-
left:
|
|
3806
|
-
top:
|
|
4051
|
+
left: x.left,
|
|
4052
|
+
top: C,
|
|
3807
4053
|
originX: "left",
|
|
3808
4054
|
originY: "top",
|
|
3809
|
-
splitByGrapheme:
|
|
3810
|
-
}), n.initDimensions(), n.setCoords(), t.setCoords(), e.shapeBaseWidth =
|
|
3811
|
-
width:
|
|
3812
|
-
height:
|
|
4055
|
+
splitByGrapheme: S
|
|
4056
|
+
}), n.initDimensions(), n.setCoords(), t.setCoords(), e.shapeBaseWidth = g, e.shapeBaseHeight = b, e.shapeManualBaseWidth = p, e.shapeManualBaseHeight = m, e.shapePaddingTop = v.top, e.shapePaddingRight = v.right, e.shapePaddingBottom = v.bottom, e.shapePaddingLeft = v.left, e.shapeAlignHorizontal = a, e.shapeAlignVertical = o, e.set({
|
|
4057
|
+
width: g,
|
|
4058
|
+
height: b,
|
|
3813
4059
|
scaleX: 1,
|
|
3814
4060
|
scaleY: 1
|
|
3815
4061
|
}), e.set("dirty", !0), e.setCoords();
|
|
3816
|
-
},
|
|
4062
|
+
}, en = ({ text: e, currentWidth: t, minimumWidth: n, padding: r, strokeWidth: i, montageAreaWidth: a }) => {
|
|
3817
4063
|
let o = Math.max(q, t), s = Math.max(q, n);
|
|
3818
|
-
if (!
|
|
3819
|
-
let c = Number.isFinite(a) && a > 0 ? Math.max(q, a) : Math.max(o, s), l = Math.max(0, i ?? 0), u = Math.max(s, c)
|
|
3820
|
-
|
|
3821
|
-
|
|
4064
|
+
if (!an({ text: e })) return s;
|
|
4065
|
+
let c = Number.isFinite(a) && a > 0 ? Math.max(q, a) : Math.max(o, s), l = Math.max(0, i ?? 0), u = It({ padding: r }), d = Math.max(s, c), f = Ut({
|
|
4066
|
+
width: d,
|
|
4067
|
+
padding: u
|
|
4068
|
+
});
|
|
4069
|
+
if (l >= d) return Math.max(o, s);
|
|
4070
|
+
let p = d, m = cn({
|
|
3822
4071
|
text: e,
|
|
3823
|
-
frameWidth:
|
|
3824
|
-
width: f,
|
|
3825
|
-
padding: d
|
|
3826
|
-
})
|
|
4072
|
+
frameWidth: f
|
|
3827
4073
|
});
|
|
3828
|
-
if (
|
|
3829
|
-
let
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
width: h,
|
|
3836
|
-
padding: d
|
|
3837
|
-
}), n = Xt({
|
|
4074
|
+
if (m.hasWrappedLines) return p;
|
|
4075
|
+
let h = Math.max(q, m.longestLineWidth), g = Math.max(q, h + u.left + u.right), _ = Math.min(p, Math.max(s, g));
|
|
4076
|
+
for (let t = 0; t < Qt; t += 1) {
|
|
4077
|
+
let t = Ut({
|
|
4078
|
+
width: _,
|
|
4079
|
+
padding: u
|
|
4080
|
+
}), n = cn({
|
|
3838
4081
|
text: e,
|
|
3839
4082
|
frameWidth: t
|
|
3840
|
-
}), r = t >=
|
|
3841
|
-
if (!n.hasWrappedLines && r) return
|
|
3842
|
-
if (
|
|
3843
|
-
let i = n.hasWrappedLines ? Math.max(
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
}
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
let
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
|
|
3861
|
-
|
|
3862
|
-
|
|
4083
|
+
}), r = t >= h - Zt;
|
|
4084
|
+
if (!n.hasWrappedLines && r) return _;
|
|
4085
|
+
if (_ >= p - Zt) return p;
|
|
4086
|
+
let i = n.hasWrappedLines ? Math.max(g + 1, _ + 1) : h;
|
|
4087
|
+
_ = Math.min(p, Math.max(_ + 1, n.hasWrappedLines ? i : g));
|
|
4088
|
+
}
|
|
4089
|
+
return _;
|
|
4090
|
+
}, tn = ({ text: e, padding: t }) => {
|
|
4091
|
+
if (!an({ text: e })) return q;
|
|
4092
|
+
let n = It({ padding: t });
|
|
4093
|
+
return un({ text: e }) + n.left + n.right;
|
|
4094
|
+
}, nn = ({ text: e, width: t, height: n, alignV: r, padding: i }) => {
|
|
4095
|
+
let a = Math.max(q, t), o = Math.max(q, n), { appliedPadding: s } = Xt({
|
|
4096
|
+
text: e,
|
|
4097
|
+
width: a,
|
|
4098
|
+
height: o,
|
|
4099
|
+
padding: It({ padding: i }),
|
|
4100
|
+
expandShapeHeightToFitText: !1,
|
|
4101
|
+
measureTextboxHeightForFrame: ln,
|
|
4102
|
+
resolveMinimumTextFrameWidth: un
|
|
4103
|
+
}), c = on({
|
|
4104
|
+
width: a,
|
|
4105
|
+
height: o,
|
|
4106
|
+
padding: s
|
|
4107
|
+
}), l = pn({
|
|
3863
4108
|
text: e,
|
|
3864
|
-
frameWidth:
|
|
3865
|
-
}),
|
|
4109
|
+
frameWidth: c.width
|
|
4110
|
+
}), u = ln({
|
|
3866
4111
|
text: e,
|
|
3867
|
-
frameWidth:
|
|
3868
|
-
splitByGrapheme:
|
|
4112
|
+
frameWidth: c.width,
|
|
4113
|
+
splitByGrapheme: l
|
|
3869
4114
|
});
|
|
3870
4115
|
return {
|
|
3871
|
-
frame:
|
|
3872
|
-
splitByGrapheme:
|
|
3873
|
-
textTop:
|
|
4116
|
+
frame: c,
|
|
4117
|
+
splitByGrapheme: l,
|
|
4118
|
+
textTop: fn({
|
|
3874
4119
|
alignV: r,
|
|
3875
|
-
frameHeight:
|
|
3876
|
-
frameTop:
|
|
3877
|
-
textHeight:
|
|
4120
|
+
frameHeight: c.height,
|
|
4121
|
+
frameTop: c.top,
|
|
4122
|
+
textHeight: u
|
|
3878
4123
|
})
|
|
3879
4124
|
};
|
|
3880
|
-
},
|
|
4125
|
+
}, rn = ({ text: e, width: t, height: n, padding: r }) => {
|
|
3881
4126
|
let i = Math.max(q, n);
|
|
3882
|
-
if (!
|
|
3883
|
-
let a = Math.max(q, t), o =
|
|
3884
|
-
|
|
3885
|
-
|
|
4127
|
+
if (!an({ text: e })) return i;
|
|
4128
|
+
let a = Math.max(q, t), o = It({ padding: r }), s = ln({
|
|
4129
|
+
text: e,
|
|
4130
|
+
frameWidth: Ut({
|
|
3886
4131
|
width: a,
|
|
3887
|
-
height: s,
|
|
3888
4132
|
padding: o
|
|
3889
|
-
})
|
|
3890
|
-
|
|
3891
|
-
|
|
3892
|
-
});
|
|
3893
|
-
if (n <= t.height + Mt) return s;
|
|
3894
|
-
let r = n - t.height;
|
|
3895
|
-
s = Math.max(s + r, s * 1.05);
|
|
3896
|
-
}
|
|
3897
|
-
return s;
|
|
4133
|
+
})
|
|
4134
|
+
});
|
|
4135
|
+
return Math.max(i, s + o.top + o.bottom);
|
|
3898
4136
|
};
|
|
3899
|
-
function
|
|
3900
|
-
let n = Math.max(q, e), r = n;
|
|
3901
|
-
for (let e = 0; e < It; e += 1) {
|
|
3902
|
-
let e = Jt({
|
|
3903
|
-
width: r,
|
|
3904
|
-
padding: t
|
|
3905
|
-
});
|
|
3906
|
-
if (e >= n - Mt) return r;
|
|
3907
|
-
let i = n - e;
|
|
3908
|
-
r = Math.max(r + i, r * 1.05);
|
|
3909
|
-
}
|
|
3910
|
-
return r;
|
|
3911
|
-
}
|
|
3912
|
-
function Wt({ padding: e }) {
|
|
3913
|
-
return {
|
|
3914
|
-
top: Kt({ value: e.top }),
|
|
3915
|
-
right: Kt({ value: e.right }),
|
|
3916
|
-
bottom: Kt({ value: e.bottom }),
|
|
3917
|
-
left: Kt({ value: e.left })
|
|
3918
|
-
};
|
|
3919
|
-
}
|
|
3920
|
-
function Gt({ text: e }) {
|
|
4137
|
+
function an({ text: e }) {
|
|
3921
4138
|
return (e.text ?? "").trim().length > 0;
|
|
3922
4139
|
}
|
|
3923
|
-
function
|
|
3924
|
-
|
|
3925
|
-
}
|
|
3926
|
-
function qt({ width: e, height: t, padding: n }) {
|
|
3927
|
-
let r = tn({
|
|
3928
|
-
size: e,
|
|
3929
|
-
ratio: n.left,
|
|
3930
|
-
axis: "horizontal"
|
|
3931
|
-
}), i = tn({
|
|
3932
|
-
size: e,
|
|
3933
|
-
ratio: n.right,
|
|
3934
|
-
axis: "horizontal"
|
|
3935
|
-
}), a = tn({
|
|
3936
|
-
size: t,
|
|
3937
|
-
ratio: n.top,
|
|
3938
|
-
axis: "vertical"
|
|
3939
|
-
}), o = tn({
|
|
3940
|
-
size: t,
|
|
3941
|
-
ratio: n.bottom,
|
|
3942
|
-
axis: "vertical"
|
|
3943
|
-
});
|
|
4140
|
+
function on({ width: e, height: t, padding: n }) {
|
|
4141
|
+
let r = Math.max(0, n.left), i = Math.max(0, n.right), a = Math.max(0, n.top), o = Math.max(0, n.bottom);
|
|
3944
4142
|
return {
|
|
3945
4143
|
left: -e / 2 + r,
|
|
3946
4144
|
top: -t / 2 + a,
|
|
@@ -3948,19 +4146,7 @@ function qt({ width: e, height: t, padding: n }) {
|
|
|
3948
4146
|
height: Math.max(q, t - a - o)
|
|
3949
4147
|
};
|
|
3950
4148
|
}
|
|
3951
|
-
function
|
|
3952
|
-
let n = tn({
|
|
3953
|
-
size: e,
|
|
3954
|
-
ratio: t.left,
|
|
3955
|
-
axis: "horizontal"
|
|
3956
|
-
}), r = tn({
|
|
3957
|
-
size: e,
|
|
3958
|
-
ratio: t.right,
|
|
3959
|
-
axis: "horizontal"
|
|
3960
|
-
});
|
|
3961
|
-
return Math.max(q, e - n - r);
|
|
3962
|
-
}
|
|
3963
|
-
function Yt({ text: e }) {
|
|
4149
|
+
function sn({ text: e }) {
|
|
3964
4150
|
let { height: t } = e;
|
|
3965
4151
|
if (typeof t == "number" && Number.isFinite(t)) return t;
|
|
3966
4152
|
if (typeof e.calcTextHeight == "function") {
|
|
@@ -3969,18 +4155,18 @@ function Yt({ text: e }) {
|
|
|
3969
4155
|
}
|
|
3970
4156
|
return q;
|
|
3971
4157
|
}
|
|
3972
|
-
function
|
|
3973
|
-
let n =
|
|
4158
|
+
function cn({ text: e, frameWidth: t }) {
|
|
4159
|
+
let n = hn({ text: e }), r = pn({
|
|
3974
4160
|
text: e,
|
|
3975
4161
|
frameWidth: t
|
|
3976
|
-
}), i =
|
|
4162
|
+
}), i = vn({ text: e });
|
|
3977
4163
|
e.set({
|
|
3978
4164
|
autoExpand: !1,
|
|
3979
4165
|
width: Math.max(q, t),
|
|
3980
4166
|
splitByGrapheme: r
|
|
3981
4167
|
}), e.initDimensions();
|
|
3982
|
-
let a =
|
|
3983
|
-
return
|
|
4168
|
+
let a = gn({ text: e }) > n, o = Math.ceil(mn({ text: e }));
|
|
4169
|
+
return yn({
|
|
3984
4170
|
text: e,
|
|
3985
4171
|
state: i
|
|
3986
4172
|
}), {
|
|
@@ -3988,8 +4174,8 @@ function Xt({ text: e, frameWidth: t }) {
|
|
|
3988
4174
|
longestLineWidth: o
|
|
3989
4175
|
};
|
|
3990
4176
|
}
|
|
3991
|
-
function
|
|
3992
|
-
let r =
|
|
4177
|
+
function ln({ text: e, frameWidth: t, splitByGrapheme: n }) {
|
|
4178
|
+
let r = vn({ text: e }), i = n ?? pn({
|
|
3993
4179
|
text: e,
|
|
3994
4180
|
frameWidth: t
|
|
3995
4181
|
});
|
|
@@ -3998,75 +4184,71 @@ function Zt({ text: e, frameWidth: t, splitByGrapheme: n }) {
|
|
|
3998
4184
|
width: Math.max(q, t),
|
|
3999
4185
|
splitByGrapheme: i
|
|
4000
4186
|
}), e.initDimensions();
|
|
4001
|
-
let a =
|
|
4002
|
-
return
|
|
4187
|
+
let a = sn({ text: e });
|
|
4188
|
+
return yn({
|
|
4003
4189
|
text: e,
|
|
4004
4190
|
state: r
|
|
4005
4191
|
}), a;
|
|
4006
4192
|
}
|
|
4007
|
-
function
|
|
4008
|
-
let t =
|
|
4193
|
+
function un({ text: e }) {
|
|
4194
|
+
let t = dn({
|
|
4009
4195
|
text: e,
|
|
4010
4196
|
frameWidth: q,
|
|
4011
4197
|
splitByGrapheme: !0
|
|
4012
4198
|
});
|
|
4013
4199
|
return Math.max(q, t);
|
|
4014
4200
|
}
|
|
4015
|
-
function
|
|
4016
|
-
let r =
|
|
4201
|
+
function dn({ text: e, frameWidth: t, splitByGrapheme: n }) {
|
|
4202
|
+
let r = vn({ text: e });
|
|
4017
4203
|
e.set({
|
|
4018
4204
|
autoExpand: !1,
|
|
4019
4205
|
width: Math.max(q, t),
|
|
4020
4206
|
splitByGrapheme: n
|
|
4021
4207
|
}), e.initDimensions();
|
|
4022
|
-
let i =
|
|
4023
|
-
return
|
|
4208
|
+
let i = mn({ text: e });
|
|
4209
|
+
return yn({
|
|
4024
4210
|
text: e,
|
|
4025
4211
|
state: r
|
|
4026
4212
|
}), i;
|
|
4027
4213
|
}
|
|
4028
|
-
function
|
|
4214
|
+
function fn({ alignV: e, frameHeight: t, frameTop: n, textHeight: r }) {
|
|
4029
4215
|
let i = Math.max(0, t - r);
|
|
4030
4216
|
return e === "top" ? n : e === "bottom" ? n + i : n + i / 2;
|
|
4031
4217
|
}
|
|
4032
|
-
function
|
|
4033
|
-
let
|
|
4034
|
-
return Math.max(0, Math.min(i, r));
|
|
4035
|
-
}
|
|
4036
|
-
function nn({ text: e, frameWidth: t }) {
|
|
4037
|
-
let n = Math.max(q, t), r = cn({ text: e });
|
|
4218
|
+
function pn({ text: e, frameWidth: t }) {
|
|
4219
|
+
let n = Math.max(q, t), r = vn({ text: e });
|
|
4038
4220
|
e.set({
|
|
4039
4221
|
autoExpand: !1,
|
|
4040
4222
|
width: n,
|
|
4041
4223
|
splitByGrapheme: !1
|
|
4042
4224
|
}), e.initDimensions();
|
|
4043
|
-
let i =
|
|
4044
|
-
return
|
|
4225
|
+
let i = bn({ text: e }) > n + Zt;
|
|
4226
|
+
return yn({
|
|
4045
4227
|
text: e,
|
|
4046
4228
|
state: r
|
|
4047
4229
|
}), i;
|
|
4048
4230
|
}
|
|
4049
|
-
function
|
|
4050
|
-
let t =
|
|
4051
|
-
if (t > 0) return
|
|
4231
|
+
function mn({ text: e }) {
|
|
4232
|
+
let t = gn({ text: e });
|
|
4233
|
+
if (t > 0) return _n({
|
|
4052
4234
|
text: e,
|
|
4053
4235
|
lineCount: t
|
|
4054
4236
|
});
|
|
4055
4237
|
let n = e.text ?? "";
|
|
4056
|
-
return
|
|
4238
|
+
return _n({
|
|
4057
4239
|
text: e,
|
|
4058
4240
|
lineCount: Math.max(n.split("\n").length, 1)
|
|
4059
4241
|
});
|
|
4060
4242
|
}
|
|
4061
|
-
function
|
|
4243
|
+
function hn({ text: e }) {
|
|
4062
4244
|
let t = e.text ?? "";
|
|
4063
4245
|
return Math.max(t.split("\n").length, 1);
|
|
4064
4246
|
}
|
|
4065
|
-
function
|
|
4247
|
+
function gn({ text: e }) {
|
|
4066
4248
|
let t = e;
|
|
4067
4249
|
return Array.isArray(t.textLines) ? t.textLines.length : 0;
|
|
4068
4250
|
}
|
|
4069
|
-
function
|
|
4251
|
+
function _n({ text: e, lineCount: t }) {
|
|
4070
4252
|
let n = q;
|
|
4071
4253
|
for (let r = 0; r < t; r += 1) {
|
|
4072
4254
|
let t = e.getLineWidth(r);
|
|
@@ -4074,7 +4256,7 @@ function sn({ text: e, lineCount: t }) {
|
|
|
4074
4256
|
}
|
|
4075
4257
|
return n;
|
|
4076
4258
|
}
|
|
4077
|
-
function
|
|
4259
|
+
function vn({ text: e }) {
|
|
4078
4260
|
let { autoExpand: t, splitByGrapheme: n, width: r } = e;
|
|
4079
4261
|
return {
|
|
4080
4262
|
autoExpand: t,
|
|
@@ -4082,23 +4264,23 @@ function cn({ text: e }) {
|
|
|
4082
4264
|
width: typeof r == "number" ? r : void 0
|
|
4083
4265
|
};
|
|
4084
4266
|
}
|
|
4085
|
-
function
|
|
4267
|
+
function yn({ text: e, state: t }) {
|
|
4086
4268
|
let { autoExpand: n, splitByGrapheme: r, width: i } = t, a = {};
|
|
4087
4269
|
n !== void 0 && (a.autoExpand = n), r !== void 0 && (a.splitByGrapheme = r), typeof i == "number" && (a.width = i), Object.keys(a).length > 0 && (e.set(a), e.initDimensions());
|
|
4088
4270
|
}
|
|
4089
|
-
function
|
|
4271
|
+
function bn({ text: e }) {
|
|
4090
4272
|
let { dynamicMinWidth: t } = e;
|
|
4091
4273
|
return typeof t == "number" && Number.isFinite(t) ? t : 0;
|
|
4092
4274
|
}
|
|
4093
4275
|
//#endregion
|
|
4094
4276
|
//#region src/editor/shape-manager/shape-runtime.ts
|
|
4095
|
-
var
|
|
4277
|
+
var xn = ({ group: e }) => {
|
|
4096
4278
|
let t = e;
|
|
4097
4279
|
typeof t.setInteractive == "function" && t.setInteractive(!0), t.set({
|
|
4098
4280
|
interactive: !0,
|
|
4099
4281
|
subTargetCheck: !0
|
|
4100
4282
|
});
|
|
4101
|
-
},
|
|
4283
|
+
}, Sn = ({ text: e }) => {
|
|
4102
4284
|
let t = !!(e.locked || e.group?.locked);
|
|
4103
4285
|
e.set({
|
|
4104
4286
|
hasBorders: !1,
|
|
@@ -4111,7 +4293,7 @@ var dn = ({ group: e }) => {
|
|
|
4111
4293
|
autoExpand: !1,
|
|
4112
4294
|
shapeNodeType: "text"
|
|
4113
4295
|
}), e.setCoords();
|
|
4114
|
-
},
|
|
4296
|
+
}, Cn = ({ group: e }) => {
|
|
4115
4297
|
let { layoutManager: t } = e;
|
|
4116
4298
|
if (!t || typeof t.unsubscribeTargets != "function") return;
|
|
4117
4299
|
let n = e.getObjects();
|
|
@@ -4119,7 +4301,7 @@ var dn = ({ group: e }) => {
|
|
|
4119
4301
|
target: e,
|
|
4120
4302
|
targets: n
|
|
4121
4303
|
});
|
|
4122
|
-
},
|
|
4304
|
+
}, wn = ({ group: e }) => {
|
|
4123
4305
|
let t = e.getObjects();
|
|
4124
4306
|
for (let e = 0; e < t.length; e += 1) {
|
|
4125
4307
|
let n = t[e];
|
|
@@ -4130,23 +4312,23 @@ var dn = ({ group: e }) => {
|
|
|
4130
4312
|
if (n instanceof _) return n;
|
|
4131
4313
|
}
|
|
4132
4314
|
return null;
|
|
4133
|
-
},
|
|
4315
|
+
}, Tn = [
|
|
4134
4316
|
"tl",
|
|
4135
4317
|
"tr",
|
|
4136
4318
|
"bl",
|
|
4137
4319
|
"br"
|
|
4138
|
-
],
|
|
4320
|
+
], En = ({ transform: e }) => {
|
|
4139
4321
|
let { originX: t, originY: n } = e;
|
|
4140
4322
|
return (t === "center" || t === .5) && (n === "center" || n === .5);
|
|
4141
|
-
},
|
|
4323
|
+
}, Dn = ({ transform: e, x: t, y: n }) => {
|
|
4142
4324
|
let r = e, { target: i } = r, { scaleX: a = 1, scaleY: o = 1 } = i, s = b.getLocalPoint(r, r.originX, r.originY, t, n), c = Math.sign(s.x || r.signX || 1), l = Math.sign(s.y || r.signY || 1);
|
|
4143
4325
|
r.signX === void 0 && (r.signX = c), r.signY === void 0 && (r.signY = l);
|
|
4144
4326
|
let u = i._getTransformedDimensions(), d = Math.abs(s.x * a / u.x), f = Math.abs(s.y * o / u.y);
|
|
4145
|
-
|
|
4327
|
+
En({ transform: r }) && (d *= 2, f *= 2);
|
|
4146
4328
|
let p = !i.lockScalingX && (!i.lockScalingFlip || r.signX === c), m = !i.lockScalingY && (!i.lockScalingFlip || r.signY === l);
|
|
4147
4329
|
return p && i.set("scaleX", d), m && i.set("scaleY", f), a !== i.scaleX || o !== i.scaleY;
|
|
4148
|
-
},
|
|
4149
|
-
let e = b.wrapWithFireEvent("scaling", b.wrapWithFixedAnchor((e, t, n, r) =>
|
|
4330
|
+
}, On = () => {
|
|
4331
|
+
let e = b.wrapWithFireEvent("scaling", b.wrapWithFixedAnchor((e, t, n, r) => Dn({
|
|
4150
4332
|
transform: t,
|
|
4151
4333
|
x: n,
|
|
4152
4334
|
y: r
|
|
@@ -4162,31 +4344,31 @@ var dn = ({ group: e }) => {
|
|
|
4162
4344
|
a.uniformScaling = s;
|
|
4163
4345
|
}
|
|
4164
4346
|
};
|
|
4165
|
-
},
|
|
4347
|
+
}, kn = ({ control: e }) => {
|
|
4166
4348
|
let t = new r({
|
|
4167
4349
|
...e,
|
|
4168
|
-
actionHandler:
|
|
4350
|
+
actionHandler: On()
|
|
4169
4351
|
});
|
|
4170
4352
|
return t.shapeFreeScaleCornerControl = !0, t;
|
|
4171
|
-
},
|
|
4353
|
+
}, An = ({ group: e }) => {
|
|
4172
4354
|
let t = { ...e.controls };
|
|
4173
|
-
|
|
4355
|
+
Tn.forEach((n) => {
|
|
4174
4356
|
let r = e.controls[n];
|
|
4175
|
-
r && (r.shapeFreeScaleCornerControl || (t[n] =
|
|
4357
|
+
r && (r.shapeFreeScaleCornerControl || (t[n] = kn({ control: r })));
|
|
4176
4358
|
}), e.controls = t;
|
|
4177
|
-
},
|
|
4178
|
-
function
|
|
4359
|
+
}, jn = "shape-group";
|
|
4360
|
+
function Mn() {
|
|
4179
4361
|
return { performLayout() {} };
|
|
4180
4362
|
}
|
|
4181
|
-
function
|
|
4363
|
+
function Nn({ layoutManager: e }) {
|
|
4182
4364
|
let t = y.getClass("layoutManager");
|
|
4183
4365
|
if (!e) return new t();
|
|
4184
4366
|
let { strategy: n, type: r } = e, i = y.getClass(r);
|
|
4185
4367
|
return n ? new i(new (y.getClass(n))()) : new i();
|
|
4186
4368
|
}
|
|
4187
|
-
var
|
|
4369
|
+
var Pn = class e extends l {
|
|
4188
4370
|
static {
|
|
4189
|
-
this.type =
|
|
4371
|
+
this.type = jn;
|
|
4190
4372
|
}
|
|
4191
4373
|
constructor(e = [], t = {}) {
|
|
4192
4374
|
let { layoutManager: n, objectCaching: r, centeredScaling: i, lockScalingFlip: a, ...o } = t;
|
|
@@ -4202,17 +4384,24 @@ var wn = class e extends l {
|
|
|
4202
4384
|
this.set({
|
|
4203
4385
|
objectCaching: !1,
|
|
4204
4386
|
shapeComposite: !0
|
|
4205
|
-
}), this.shapeTextAutoExpand === void 0 && (this.shapeTextAutoExpand = !0)
|
|
4206
|
-
let e =
|
|
4207
|
-
|
|
4387
|
+
}), this.shapeTextAutoExpand === void 0 && (this.shapeTextAutoExpand = !0);
|
|
4388
|
+
let e = Lt({ padding: {
|
|
4389
|
+
top: this.shapePaddingTop,
|
|
4390
|
+
right: this.shapePaddingRight,
|
|
4391
|
+
bottom: this.shapePaddingBottom,
|
|
4392
|
+
left: this.shapePaddingLeft
|
|
4393
|
+
} });
|
|
4394
|
+
this.shapePaddingTop = e.top, this.shapePaddingRight = e.right, this.shapePaddingBottom = e.bottom, this.shapePaddingLeft = e.left, this._syncRoundability(), xn({ group: this }), An({ group: this });
|
|
4395
|
+
let t = wn({ group: this });
|
|
4396
|
+
t && Sn({ text: t }), Cn({ group: this }), this.setCoords();
|
|
4208
4397
|
}
|
|
4209
4398
|
static async fromObject({ type: t, objects: n = [], layoutManager: r, ...i }, a) {
|
|
4210
4399
|
let [o, s] = await Promise.all([C.enlivenObjects(n, a), C.enlivenObjectEnlivables(i, a)]), c = new e(o, {
|
|
4211
4400
|
...i,
|
|
4212
4401
|
...s,
|
|
4213
|
-
layoutManager:
|
|
4402
|
+
layoutManager: Mn()
|
|
4214
4403
|
});
|
|
4215
|
-
return c.layoutManager =
|
|
4404
|
+
return c.layoutManager = Nn({ layoutManager: r }), c.layoutManager.subscribeTargets({
|
|
4216
4405
|
type: "initialization",
|
|
4217
4406
|
target: c,
|
|
4218
4407
|
targets: c.getObjects()
|
|
@@ -4222,12 +4411,12 @@ var wn = class e extends l {
|
|
|
4222
4411
|
if (typeof this.shapeCanRound == "boolean") return;
|
|
4223
4412
|
let e = this.shapePresetKey;
|
|
4224
4413
|
if (!e) return;
|
|
4225
|
-
let t =
|
|
4226
|
-
t && (this.shapeCanRound =
|
|
4414
|
+
let t = ut({ presetKey: e });
|
|
4415
|
+
t && (this.shapeCanRound = ht({ preset: t }));
|
|
4227
4416
|
}
|
|
4228
|
-
},
|
|
4229
|
-
y?.setClass && y.setClass(
|
|
4230
|
-
}, J = (e) => e instanceof
|
|
4417
|
+
}, Fn = () => {
|
|
4418
|
+
y?.setClass && y.setClass(Pn, jn);
|
|
4419
|
+
}, J = (e) => e instanceof Pn || e instanceof l && e.shapeComposite === !0, In = ({ target: e, subTargets: t = [] }) => {
|
|
4231
4420
|
if (J(e)) return e;
|
|
4232
4421
|
if (e?.group && J(e.group)) return e.group;
|
|
4233
4422
|
for (let e = 0; e < t.length; e += 1) {
|
|
@@ -4237,7 +4426,7 @@ var wn = class e extends l {
|
|
|
4237
4426
|
if (r && J(r)) return r;
|
|
4238
4427
|
}
|
|
4239
4428
|
return null;
|
|
4240
|
-
},
|
|
4429
|
+
}, Ln = ({ group: e }) => {
|
|
4241
4430
|
let t = e.getObjects();
|
|
4242
4431
|
for (let e = 0; e < t.length; e += 1) {
|
|
4243
4432
|
let n = t[e];
|
|
@@ -4248,7 +4437,7 @@ var wn = class e extends l {
|
|
|
4248
4437
|
if (!(n instanceof _)) return n;
|
|
4249
4438
|
}
|
|
4250
4439
|
return null;
|
|
4251
|
-
},
|
|
4440
|
+
}, Rn = ({ group: e }) => {
|
|
4252
4441
|
let t = e.getObjects();
|
|
4253
4442
|
for (let e = 0; e < t.length; e += 1) {
|
|
4254
4443
|
let n = t[e];
|
|
@@ -4260,16 +4449,16 @@ var wn = class e extends l {
|
|
|
4260
4449
|
}
|
|
4261
4450
|
return null;
|
|
4262
4451
|
}, Y = ({ group: e }) => ({
|
|
4263
|
-
shape:
|
|
4264
|
-
text:
|
|
4265
|
-
}),
|
|
4266
|
-
|
|
4267
|
-
},
|
|
4452
|
+
shape: Ln({ group: e }),
|
|
4453
|
+
text: Rn({ group: e })
|
|
4454
|
+
}), zn = ({ group: e }) => {
|
|
4455
|
+
xn({ group: e });
|
|
4456
|
+
}, Bn = ({ transform: e, key: t }) => {
|
|
4268
4457
|
let n = e?.original;
|
|
4269
4458
|
if (!n || typeof n != "object") return null;
|
|
4270
4459
|
let r = n[t];
|
|
4271
4460
|
return typeof r != "number" || !Number.isFinite(r) ? null : r;
|
|
4272
|
-
},
|
|
4461
|
+
}, Vn = ({ value: e }) => e === "left" || e === "center" || e === "right" || typeof e == "number" && Number.isFinite(e) ? e : null, Hn = ({ value: e }) => e === "top" || e === "center" || e === "bottom" || typeof e == "number" && Number.isFinite(e) ? e : null, Un = ({ transform: e }) => {
|
|
4273
4462
|
let t = e?.action ?? "", n = typeof e?.corner == "string" ? e.corner : "", r = n === "tl" || n === "tr" || n === "bl" || n === "br", i = t === "scaleX" || n === "ml" || n === "mr", a = t === "scaleY" || n === "mt" || n === "mb", o = i || r, s = a || r;
|
|
4274
4463
|
return {
|
|
4275
4464
|
canScaleWidth: o,
|
|
@@ -4277,37 +4466,37 @@ var wn = class e extends l {
|
|
|
4277
4466
|
isCornerScaleAction: r,
|
|
4278
4467
|
isVerticalOnlyScale: s && !o
|
|
4279
4468
|
};
|
|
4280
|
-
},
|
|
4469
|
+
}, Wn = ({ event: e, group: t, transform: n, canvas: r }) => {
|
|
4281
4470
|
if (!e) return null;
|
|
4282
4471
|
let i = t.canvas ?? r, a = i.getScenePoint(e), o = t.getRelativeCenterPoint(), s = t.translateToGivenOrigin(o, "center", "center", n.originX, n.originY), c = t.angle ?? 0, l = (c === 0 ? a : a.rotate(-c * Math.PI / 180, o)).subtract(s), u = t.controls[n.corner], d = i.getZoom() || 1, f = (t.padding ?? 0) / d;
|
|
4283
4472
|
return l.x >= f && (l.x -= f), l.x <= -f && (l.x += f), l.y >= f && (l.y -= f), l.y <= -f && (l.y += f), l.x -= u?.offsetX ?? 0, l.y -= u?.offsetY ?? 0, l;
|
|
4284
|
-
},
|
|
4473
|
+
}, Gn = ({ group: e, originX: t, originY: n }) => {
|
|
4285
4474
|
if (t === null || n === null) return null;
|
|
4286
4475
|
let r = e, i = typeof r.getRelativeCenterPoint == "function" ? r.getRelativeCenterPoint() : e.getCenterPoint();
|
|
4287
4476
|
return typeof r.translateToOriginPoint == "function" ? r.translateToOriginPoint(i, t, n) : i;
|
|
4288
|
-
},
|
|
4477
|
+
}, Kn = ({ state: e, transform: t }) => {
|
|
4289
4478
|
if (!t || e.startTransformOriginX === null && e.startTransformOriginY === null) return !1;
|
|
4290
|
-
let n =
|
|
4479
|
+
let n = Vn({ value: t.originX }), r = Hn({ value: t.originY });
|
|
4291
4480
|
return n !== e.startTransformOriginX || r !== e.startTransformOriginY;
|
|
4292
|
-
},
|
|
4481
|
+
}, qn = ({ state: e, transform: t }) => !t || !e.startTransformCorner ? !1 : t.corner !== e.startTransformCorner;
|
|
4293
4482
|
//#endregion
|
|
4294
4483
|
//#region src/editor/shape-manager/scaling/shape-scaling-preview.ts
|
|
4295
|
-
function
|
|
4484
|
+
function Jn({ size: e, scale: t, strokeWidth: n, minSize: r, scaleEpsilon: i }) {
|
|
4296
4485
|
let a = Math.max(i, Math.abs(t) || 1), o = Math.max(0, n);
|
|
4297
4486
|
return o <= 0 ? Math.max(r, e / a) : Math.max(r, e / a + o - o / a);
|
|
4298
4487
|
}
|
|
4299
|
-
function
|
|
4488
|
+
function Yn({ group: e, shape: t, width: n, height: r, scaleX: i, scaleY: a, minSize: o, scaleEpsilon: s }) {
|
|
4300
4489
|
let c = Math.max(0, e.shapeStrokeWidth ?? 0);
|
|
4301
|
-
|
|
4490
|
+
bt({
|
|
4302
4491
|
shape: t,
|
|
4303
|
-
width:
|
|
4492
|
+
width: Jn({
|
|
4304
4493
|
size: n,
|
|
4305
4494
|
scale: i,
|
|
4306
4495
|
strokeWidth: c,
|
|
4307
4496
|
minSize: o,
|
|
4308
4497
|
scaleEpsilon: s
|
|
4309
4498
|
}),
|
|
4310
|
-
height:
|
|
4499
|
+
height: Jn({
|
|
4311
4500
|
size: r,
|
|
4312
4501
|
scale: a,
|
|
4313
4502
|
strokeWidth: c,
|
|
@@ -4318,8 +4507,8 @@ function zn({ group: e, shape: t, width: n, height: r, scaleX: i, scaleY: a, min
|
|
|
4318
4507
|
strokeWidth: c
|
|
4319
4508
|
});
|
|
4320
4509
|
}
|
|
4321
|
-
function
|
|
4322
|
-
let l = Math.max(c, Math.abs(o) || 1), u = Math.max(c, Math.abs(s) || 1), d = i ?? "center", { frame: f, splitByGrapheme: p, textTop: m } =
|
|
4510
|
+
function Xn({ text: e, width: t, height: n, padding: r, alignH: i, alignV: a, scaleX: o, scaleY: s, scaleEpsilon: c }) {
|
|
4511
|
+
let l = Math.max(c, Math.abs(o) || 1), u = Math.max(c, Math.abs(s) || 1), d = i ?? "center", { frame: f, splitByGrapheme: p, textTop: m } = nn({
|
|
4323
4512
|
text: e,
|
|
4324
4513
|
width: t,
|
|
4325
4514
|
height: n,
|
|
@@ -4339,13 +4528,13 @@ function Bn({ text: e, width: t, height: n, padding: r, alignH: i, alignV: a, sc
|
|
|
4339
4528
|
scaleY: 1 / u
|
|
4340
4529
|
}), e.initDimensions(), e.setCoords();
|
|
4341
4530
|
}
|
|
4342
|
-
var
|
|
4531
|
+
var Zn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH: o, alignV: s, scaleX: c, scaleY: l, minSize: u, scaleEpsilon: d }) => {
|
|
4343
4532
|
let f = Math.max(d, Math.abs(c) || 1), p = Math.max(d, Math.abs(l) || 1);
|
|
4344
4533
|
e.set({
|
|
4345
4534
|
width: r / f,
|
|
4346
4535
|
height: i / p,
|
|
4347
4536
|
dirty: !0
|
|
4348
|
-
}),
|
|
4537
|
+
}), Yn({
|
|
4349
4538
|
group: e,
|
|
4350
4539
|
shape: t,
|
|
4351
4540
|
width: r,
|
|
@@ -4354,7 +4543,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4354
4543
|
scaleY: l,
|
|
4355
4544
|
minSize: u,
|
|
4356
4545
|
scaleEpsilon: d
|
|
4357
|
-
}),
|
|
4546
|
+
}), Xn({
|
|
4358
4547
|
text: n,
|
|
4359
4548
|
width: r,
|
|
4360
4549
|
height: i,
|
|
@@ -4365,7 +4554,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4365
4554
|
scaleY: l,
|
|
4366
4555
|
scaleEpsilon: d
|
|
4367
4556
|
});
|
|
4368
|
-
}, X = 1, Z = 1e-4,
|
|
4557
|
+
}, X = 1, Z = 1e-4, Qn = .5, $n = class e {
|
|
4369
4558
|
constructor({ canvas: t }) {
|
|
4370
4559
|
this.handleObjectScaling = (t) => {
|
|
4371
4560
|
let { target: n, transform: r } = t;
|
|
@@ -4376,117 +4565,117 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4376
4565
|
lockScalingFlip: !0,
|
|
4377
4566
|
centeredScaling: !1
|
|
4378
4567
|
});
|
|
4379
|
-
let s = e.
|
|
4568
|
+
let s = e._resolveEffectivePadding({ group: i }), c = e._resolveScalingConstraintPadding({ group: i }), l = this._ensureScalingState({
|
|
4380
4569
|
group: i,
|
|
4381
4570
|
text: o,
|
|
4382
|
-
|
|
4571
|
+
constraintPadding: c,
|
|
4383
4572
|
transform: r
|
|
4384
|
-
}), { isCornerScaleAction:
|
|
4385
|
-
|
|
4386
|
-
let
|
|
4573
|
+
}), { isCornerScaleAction: u } = Un({ transform: r }), d = !!(t.e && "shiftKey" in t.e && t.e.shiftKey);
|
|
4574
|
+
l.isProportionalScaling = u && d;
|
|
4575
|
+
let f = i.left ?? 0, p = i.top ?? 0, m = !!i.flipX, h = !!i.flipY, g = i.shapeAlignHorizontal ?? "center", _ = i.shapeAlignVertical ?? "middle", v = this._resolveScalingDecision({
|
|
4387
4576
|
group: i,
|
|
4388
4577
|
text: o,
|
|
4389
|
-
|
|
4390
|
-
state:
|
|
4578
|
+
constraintPadding: c,
|
|
4579
|
+
state: l,
|
|
4391
4580
|
transform: r
|
|
4392
|
-
}),
|
|
4393
|
-
(
|
|
4581
|
+
}), y = Math.abs(i.scaleX ?? 1) || 1, b = Math.abs(i.scaleY ?? 1) || 1;
|
|
4582
|
+
(v.shouldHandleAsNoop || v.shouldRestoreLastAllowedTransform || Math.abs(v.appliedScaleX - y) > Z || Math.abs(v.appliedScaleY - b) > Z) && this._applyResolvedScalingState({
|
|
4394
4583
|
group: i,
|
|
4395
|
-
state:
|
|
4396
|
-
shouldHandleAsNoop:
|
|
4397
|
-
scaleX:
|
|
4398
|
-
scaleY:
|
|
4399
|
-
}),
|
|
4584
|
+
state: l,
|
|
4585
|
+
shouldHandleAsNoop: v.shouldHandleAsNoop,
|
|
4586
|
+
scaleX: v.appliedScaleX,
|
|
4587
|
+
scaleY: v.appliedScaleY
|
|
4588
|
+
}), Zn({
|
|
4400
4589
|
group: i,
|
|
4401
4590
|
shape: a,
|
|
4402
4591
|
text: o,
|
|
4403
|
-
width:
|
|
4404
|
-
height:
|
|
4592
|
+
width: v.previewWidth,
|
|
4593
|
+
height: v.previewHeight,
|
|
4405
4594
|
padding: s,
|
|
4406
|
-
alignH:
|
|
4407
|
-
alignV:
|
|
4408
|
-
scaleX:
|
|
4409
|
-
scaleY:
|
|
4595
|
+
alignH: g,
|
|
4596
|
+
alignV: _,
|
|
4597
|
+
scaleX: v.appliedScaleX,
|
|
4598
|
+
scaleY: v.appliedScaleY,
|
|
4410
4599
|
minSize: X,
|
|
4411
4600
|
scaleEpsilon: Z
|
|
4412
4601
|
}), this._restoreScalingAnchorPosition({
|
|
4413
4602
|
group: i,
|
|
4414
|
-
state:
|
|
4415
|
-
}), !
|
|
4603
|
+
state: l
|
|
4604
|
+
}), !v.shouldHandleAsNoop && !v.shouldRestoreLastAllowedTransform && this._storeLastAllowedTransform({
|
|
4416
4605
|
group: i,
|
|
4417
|
-
state:
|
|
4606
|
+
state: l,
|
|
4418
4607
|
scaleX: i.scaleX ?? 1,
|
|
4419
4608
|
scaleY: i.scaleY ?? 1,
|
|
4420
|
-
currentLeft:
|
|
4421
|
-
currentTop:
|
|
4422
|
-
currentFlipX:
|
|
4423
|
-
currentFlipY:
|
|
4609
|
+
currentLeft: f,
|
|
4610
|
+
currentTop: p,
|
|
4611
|
+
currentFlipX: m,
|
|
4612
|
+
currentFlipY: h
|
|
4424
4613
|
}), this.canvas.requestRenderAll();
|
|
4425
4614
|
}, this.handleCanvasMouseMove = (t) => {
|
|
4426
4615
|
let n = this.canvas._currentTransform;
|
|
4427
4616
|
if (!n) return;
|
|
4428
4617
|
let { target: r } = n;
|
|
4429
4618
|
if (!J(r)) return;
|
|
4430
|
-
let { canScaleHeight: i, canScaleWidth: a } =
|
|
4619
|
+
let { canScaleHeight: i, canScaleWidth: a } = Un({ transform: n });
|
|
4431
4620
|
if (!a && !i) return;
|
|
4432
4621
|
let o = r, s = this.scalingState.get(o);
|
|
4433
4622
|
if (!s || s.isProportionalScaling) return;
|
|
4434
4623
|
let { shape: c, text: l } = Y({ group: o });
|
|
4435
4624
|
if (!c || !l) return;
|
|
4436
|
-
let u = e.
|
|
4625
|
+
let u = e._resolveEffectivePadding({ group: o }), d = e._resolveScalingConstraintPadding({ group: o }), f = o.shapeAlignHorizontal ?? "center", p = o.shapeAlignVertical ?? "middle", m = Math.abs(o.scaleX ?? s.lastAllowedScaleX ?? 1) || 1, h = Math.abs(o.scaleY ?? s.lastAllowedScaleY ?? 1) || 1, g = {
|
|
4437
4626
|
...t,
|
|
4438
4627
|
transform: n
|
|
4439
|
-
},
|
|
4628
|
+
}, _ = m, v = h, y = null, b = !1, x = !1;
|
|
4440
4629
|
if (a && this._hasPointerReachedScaleOrigin({
|
|
4441
|
-
event:
|
|
4630
|
+
event: g,
|
|
4442
4631
|
group: o,
|
|
4443
4632
|
axis: "x"
|
|
4444
4633
|
})) {
|
|
4445
|
-
let e =
|
|
4634
|
+
let e = tn({
|
|
4446
4635
|
text: l,
|
|
4447
|
-
padding:
|
|
4636
|
+
padding: d
|
|
4448
4637
|
}), t = Math.max(X / s.startWidth, e / s.startWidth);
|
|
4449
|
-
s.lastAllowedScaleX > t + Z && (
|
|
4638
|
+
s.lastAllowedScaleX > t + Z && (_ = t, b = !0, x = !0);
|
|
4450
4639
|
}
|
|
4451
4640
|
if (i && this._hasPointerReachedScaleOrigin({
|
|
4452
|
-
event:
|
|
4641
|
+
event: g,
|
|
4453
4642
|
group: o,
|
|
4454
4643
|
axis: "y"
|
|
4455
4644
|
})) {
|
|
4456
|
-
|
|
4645
|
+
y = this._resolveMinimumTextFitHeight({
|
|
4457
4646
|
text: l,
|
|
4458
|
-
width: Math.max(X, s.startWidth *
|
|
4459
|
-
padding:
|
|
4647
|
+
width: Math.max(X, s.startWidth * _),
|
|
4648
|
+
padding: d
|
|
4460
4649
|
});
|
|
4461
|
-
let e = Math.max(X / s.startHeight,
|
|
4462
|
-
s.lastAllowedScaleY > e + Z && (
|
|
4650
|
+
let e = Math.max(X / s.startHeight, y / s.startHeight);
|
|
4651
|
+
s.lastAllowedScaleY > e + Z && (v = e, x = !0);
|
|
4463
4652
|
}
|
|
4464
|
-
if (!
|
|
4465
|
-
let
|
|
4653
|
+
if (!x) return;
|
|
4654
|
+
let S = this._resolvePreviewDimensions({
|
|
4466
4655
|
text: l,
|
|
4467
|
-
|
|
4656
|
+
constraintPadding: d,
|
|
4468
4657
|
state: s,
|
|
4469
|
-
appliedScaleX:
|
|
4470
|
-
appliedScaleY:
|
|
4471
|
-
minimumHeight:
|
|
4658
|
+
appliedScaleX: _,
|
|
4659
|
+
appliedScaleY: v,
|
|
4660
|
+
minimumHeight: b ? null : y
|
|
4472
4661
|
});
|
|
4473
4662
|
this._applyResolvedScalingState({
|
|
4474
4663
|
group: o,
|
|
4475
4664
|
state: s,
|
|
4476
4665
|
shouldHandleAsNoop: !1,
|
|
4477
|
-
scaleX:
|
|
4478
|
-
scaleY:
|
|
4479
|
-
}),
|
|
4666
|
+
scaleX: _,
|
|
4667
|
+
scaleY: v
|
|
4668
|
+
}), Zn({
|
|
4480
4669
|
group: o,
|
|
4481
4670
|
shape: c,
|
|
4482
4671
|
text: l,
|
|
4483
|
-
width:
|
|
4484
|
-
height:
|
|
4672
|
+
width: S.previewWidth,
|
|
4673
|
+
height: S.previewHeight,
|
|
4485
4674
|
padding: u,
|
|
4486
|
-
alignH:
|
|
4487
|
-
alignV:
|
|
4488
|
-
scaleX:
|
|
4489
|
-
scaleY:
|
|
4675
|
+
alignH: f,
|
|
4676
|
+
alignV: p,
|
|
4677
|
+
scaleX: _,
|
|
4678
|
+
scaleY: v,
|
|
4490
4679
|
minSize: X,
|
|
4491
4680
|
scaleEpsilon: Z
|
|
4492
4681
|
}), this._restoreScalingAnchorPosition({
|
|
@@ -4495,8 +4684,8 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4495
4684
|
}), this._storeLastAllowedTransform({
|
|
4496
4685
|
group: o,
|
|
4497
4686
|
state: s,
|
|
4498
|
-
scaleX:
|
|
4499
|
-
scaleY:
|
|
4687
|
+
scaleX: _,
|
|
4688
|
+
scaleY: v,
|
|
4500
4689
|
currentLeft: s.lastAllowedLeft,
|
|
4501
4690
|
currentTop: s.lastAllowedTop,
|
|
4502
4691
|
currentFlipX: s.lastAllowedFlipX,
|
|
@@ -4523,7 +4712,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4523
4712
|
this.scalingState.delete(r);
|
|
4524
4713
|
return;
|
|
4525
4714
|
}
|
|
4526
|
-
let p = r.shapeAlignHorizontal ?? "center", m = r.shapeAlignVertical ?? "middle", h = e.
|
|
4715
|
+
let p = r.shapeAlignHorizontal ?? "center", m = r.shapeAlignVertical ?? "middle", h = e._resolveScalingConstraintPadding({ group: r }), g = t.transform ? Un({ transform: t.transform }) : null, _ = i?.canScaleWidth ?? g?.canScaleWidth ?? Math.abs(a - 1) > Z, v = i?.canScaleHeight ?? g?.canScaleHeight ?? Math.abs(o - 1) > Z, y = tn({
|
|
4527
4716
|
text: f,
|
|
4528
4717
|
padding: h
|
|
4529
4718
|
}), b = i?.lastAllowedScaleX ?? a, x = i?.lastAllowedScaleY ?? o;
|
|
@@ -4546,7 +4735,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4546
4735
|
state: i
|
|
4547
4736
|
}) && (x = Math.max(X / c, e / c));
|
|
4548
4737
|
}
|
|
4549
|
-
let S = _ ? Math.max(X, s * b) : s, C = v ? Math.max(X, c * x) : u, w = Math.abs(S - s) >
|
|
4738
|
+
let S = _ ? Math.max(X, s * b) : s, C = v ? Math.max(X, c * x) : u, w = Math.abs(S - s) > Qn, T = Math.abs(C - c) > Qn, E = w || T, D = S, O = C;
|
|
4550
4739
|
if (!E && i) {
|
|
4551
4740
|
this._restoreShapeStateWithoutResize({
|
|
4552
4741
|
group: r,
|
|
@@ -4557,7 +4746,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4557
4746
|
startHeight: c,
|
|
4558
4747
|
alignH: p,
|
|
4559
4748
|
alignV: m,
|
|
4560
|
-
|
|
4749
|
+
userPadding: e._resolveUserPadding({ group: r })
|
|
4561
4750
|
}), this.scalingState.delete(r), this.canvas.requestRenderAll();
|
|
4562
4751
|
return;
|
|
4563
4752
|
}
|
|
@@ -4575,7 +4764,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4575
4764
|
});
|
|
4576
4765
|
r.shapeManualBaseWidth = k.width, r.shapeManualBaseHeight = k.height;
|
|
4577
4766
|
let A = i?.baseRounding ?? Math.max(0, r.shapeRounding ?? 0);
|
|
4578
|
-
r.shapeRounding = Math.max(0, A * Math.min(b, x)),
|
|
4767
|
+
r.shapeRounding = Math.max(0, A * Math.min(b, x)), $t({
|
|
4579
4768
|
group: r,
|
|
4580
4769
|
shape: d,
|
|
4581
4770
|
text: f,
|
|
@@ -4583,7 +4772,12 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4583
4772
|
height: O,
|
|
4584
4773
|
alignH: p,
|
|
4585
4774
|
alignV: m,
|
|
4586
|
-
padding:
|
|
4775
|
+
padding: e._resolveUserPadding({ group: r }),
|
|
4776
|
+
internalShapeTextInset: e._resolveInternalShapeTextInset({
|
|
4777
|
+
group: r,
|
|
4778
|
+
width: D,
|
|
4779
|
+
height: O
|
|
4780
|
+
})
|
|
4587
4781
|
}), f.set({
|
|
4588
4782
|
scaleX: 1,
|
|
4589
4783
|
scaleY: 1
|
|
@@ -4596,18 +4790,18 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4596
4790
|
}), r.setCoords(), f.setCoords(), d.setCoords(), this.scalingState.delete(r), r.shapeScalingNoopTransform = !1, this.canvas.requestRenderAll();
|
|
4597
4791
|
}, this.canvas = t, this.scalingState = /* @__PURE__ */ new WeakMap();
|
|
4598
4792
|
}
|
|
4599
|
-
_resolveScalingDecision({ group: e, text: t,
|
|
4600
|
-
let a = e.scaleX ?? 1, o = e.scaleY ?? 1, s = Math.abs(a) || 1, c = Math.abs(o) || 1, l = a < 0 || o < 0, u =
|
|
4793
|
+
_resolveScalingDecision({ group: e, text: t, constraintPadding: n, state: r, transform: i }) {
|
|
4794
|
+
let a = e.scaleX ?? 1, o = e.scaleY ?? 1, s = Math.abs(a) || 1, c = Math.abs(o) || 1, l = a < 0 || o < 0, u = Kn({
|
|
4601
4795
|
state: r,
|
|
4602
4796
|
transform: i
|
|
4603
|
-
}), d =
|
|
4797
|
+
}), d = qn({
|
|
4604
4798
|
state: r,
|
|
4605
4799
|
transform: i
|
|
4606
4800
|
});
|
|
4607
4801
|
(l || u || d) && (r.crossedOppositeCorner = !0);
|
|
4608
4802
|
let f = this._resolveScalingConstraintState({
|
|
4609
4803
|
text: t,
|
|
4610
|
-
|
|
4804
|
+
constraintPadding: n,
|
|
4611
4805
|
state: r,
|
|
4612
4806
|
transform: i,
|
|
4613
4807
|
scaleX: s,
|
|
@@ -4616,7 +4810,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4616
4810
|
f.shouldRestoreLastAllowedTransform && (h = r.lastAllowedScaleX, g = r.lastAllowedScaleY), f.shouldHandleAsNoop && (h = r.startScaleX, g = r.startScaleY);
|
|
4617
4811
|
let _ = !f.shouldHandleAsNoop && !f.shouldRestoreLastAllowedTransform && f.clampedScaleX === null, v = this._resolvePreviewDimensions({
|
|
4618
4812
|
text: t,
|
|
4619
|
-
|
|
4813
|
+
constraintPadding: n,
|
|
4620
4814
|
state: r,
|
|
4621
4815
|
appliedScaleX: h,
|
|
4622
4816
|
appliedScaleY: g,
|
|
@@ -4631,8 +4825,8 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4631
4825
|
shouldRestoreLastAllowedTransform: f.shouldRestoreLastAllowedTransform
|
|
4632
4826
|
};
|
|
4633
4827
|
}
|
|
4634
|
-
_resolveScalingConstraintState({ text: e,
|
|
4635
|
-
let { startHeight: o, startWidth: s, cannotScaleDownAtStart: c, crossedOppositeCorner: l, isProportionalScaling: u, lastAllowedScaleX: d, lastAllowedScaleY: f, startScaleY: p } = n, m = Math.max(X, s * i), h = Math.max(X, o * a), g = i < d - Z, _ = a < f - Z, v = a < p - Z, { canScaleHeight: y, canScaleWidth: b, isVerticalOnlyScale: x } =
|
|
4828
|
+
_resolveScalingConstraintState({ text: e, constraintPadding: t, state: n, transform: r, scaleX: i, scaleY: a }) {
|
|
4829
|
+
let { startHeight: o, startWidth: s, cannotScaleDownAtStart: c, crossedOppositeCorner: l, isProportionalScaling: u, lastAllowedScaleX: d, lastAllowedScaleY: f, startScaleY: p } = n, m = Math.max(X, s * i), h = Math.max(X, o * a), g = i < d - Z, _ = a < f - Z, v = a < p - Z, { canScaleHeight: y, canScaleWidth: b, isVerticalOnlyScale: x } = Un({ transform: r }), S = b && g ? tn({
|
|
4636
4830
|
text: e,
|
|
4637
4831
|
padding: t
|
|
4638
4832
|
}) : null, C = y && _ ? this._resolveMinimumTextFitHeight({
|
|
@@ -4650,8 +4844,8 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4650
4844
|
resolvedMinimumHeight: C
|
|
4651
4845
|
};
|
|
4652
4846
|
}
|
|
4653
|
-
_resolvePreviewDimensions({ text: e,
|
|
4654
|
-
let o = n.canScaleWidth ? Math.max(X, n.startWidth * r) : n.startWidth, s = n.canScaleHeight ? Math.max(X, n.startHeight * i) : n.startManualBaseHeight, c = a ??
|
|
4847
|
+
_resolvePreviewDimensions({ text: e, constraintPadding: t, state: n, appliedScaleX: r, appliedScaleY: i, minimumHeight: a }) {
|
|
4848
|
+
let o = n.canScaleWidth ? Math.max(X, n.startWidth * r) : n.startWidth, s = n.canScaleHeight ? Math.max(X, n.startHeight * i) : n.startManualBaseHeight, c = a ?? rn({
|
|
4655
4849
|
text: e,
|
|
4656
4850
|
width: o,
|
|
4657
4851
|
height: s,
|
|
@@ -4684,7 +4878,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4684
4878
|
if (!r) return !1;
|
|
4685
4879
|
let { transform: i } = e;
|
|
4686
4880
|
if (!i) return !1;
|
|
4687
|
-
let { canScaleWidth: a } =
|
|
4881
|
+
let { canScaleWidth: a } = Un({ transform: i });
|
|
4688
4882
|
if (!a || !this._hasPointerReachedScaleOrigin({
|
|
4689
4883
|
event: e,
|
|
4690
4884
|
group: t,
|
|
@@ -4697,7 +4891,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4697
4891
|
if (!r) return !1;
|
|
4698
4892
|
let { transform: i } = e;
|
|
4699
4893
|
if (!i) return !1;
|
|
4700
|
-
let { canScaleHeight: a } =
|
|
4894
|
+
let { canScaleHeight: a } = Un({ transform: i });
|
|
4701
4895
|
if (!a || !this._hasPointerReachedScaleOrigin({
|
|
4702
4896
|
event: e,
|
|
4703
4897
|
group: t,
|
|
@@ -4711,7 +4905,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4711
4905
|
if (!r) return !1;
|
|
4712
4906
|
let i = r, a = n === "x" ? i.signX : i.signY;
|
|
4713
4907
|
if (typeof a != "number" || !Number.isFinite(a)) return !1;
|
|
4714
|
-
let o =
|
|
4908
|
+
let o = Wn({
|
|
4715
4909
|
event: e.e,
|
|
4716
4910
|
group: t,
|
|
4717
4911
|
transform: r,
|
|
@@ -4722,25 +4916,25 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4722
4916
|
clearState({ group: e }) {
|
|
4723
4917
|
this.scalingState.delete(e);
|
|
4724
4918
|
}
|
|
4725
|
-
_ensureScalingState({ group: e, text: t,
|
|
4919
|
+
_ensureScalingState({ group: e, text: t, constraintPadding: n, transform: r }) {
|
|
4726
4920
|
let i = this.scalingState.get(e);
|
|
4727
4921
|
if (!i) {
|
|
4728
4922
|
let a = this._resolveScalingStartDimensions({
|
|
4729
4923
|
group: e,
|
|
4730
4924
|
transform: r
|
|
4731
|
-
}), o =
|
|
4925
|
+
}), o = Bn({
|
|
4732
4926
|
transform: r,
|
|
4733
4927
|
key: "scaleX"
|
|
4734
|
-
}), s =
|
|
4928
|
+
}), s = Bn({
|
|
4735
4929
|
transform: r,
|
|
4736
4930
|
key: "scaleY"
|
|
4737
|
-
}), c =
|
|
4931
|
+
}), c = Bn({
|
|
4738
4932
|
transform: r,
|
|
4739
4933
|
key: "left"
|
|
4740
|
-
}), l =
|
|
4934
|
+
}), l = Bn({
|
|
4741
4935
|
transform: r,
|
|
4742
4936
|
key: "top"
|
|
4743
|
-
}), u = Math.abs(o ?? e.scaleX ?? 1) || 1, d = Math.abs(s ?? e.scaleY ?? 1) || 1, f = c ?? e.left ?? 0, p = l ?? e.top ?? 0, m =
|
|
4937
|
+
}), u = Math.abs(o ?? e.scaleX ?? 1) || 1, d = Math.abs(s ?? e.scaleY ?? 1) || 1, f = c ?? e.left ?? 0, p = l ?? e.top ?? 0, m = Vn({ value: r?.original?.originX ?? r?.originX }), h = Hn({ value: r?.original?.originY ?? r?.originY }), g = typeof r?.corner == "string" ? r.corner : null, _ = Gn({
|
|
4744
4938
|
group: e,
|
|
4745
4939
|
originX: m,
|
|
4746
4940
|
originY: h
|
|
@@ -4783,21 +4977,53 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4783
4977
|
return i;
|
|
4784
4978
|
}
|
|
4785
4979
|
_resolveMinimumTextFitHeight({ text: e, width: t, padding: n }) {
|
|
4786
|
-
return
|
|
4980
|
+
return rn({
|
|
4787
4981
|
text: e,
|
|
4788
4982
|
width: t,
|
|
4789
4983
|
height: X,
|
|
4790
4984
|
padding: n
|
|
4791
4985
|
});
|
|
4792
4986
|
}
|
|
4793
|
-
static
|
|
4794
|
-
return {
|
|
4795
|
-
top: e.shapePaddingTop
|
|
4796
|
-
right: e.shapePaddingRight
|
|
4797
|
-
bottom: e.shapePaddingBottom
|
|
4798
|
-
left: e.shapePaddingLeft
|
|
4987
|
+
static _resolveUserPadding({ group: e }) {
|
|
4988
|
+
return Lt({ padding: {
|
|
4989
|
+
top: e.shapePaddingTop,
|
|
4990
|
+
right: e.shapePaddingRight,
|
|
4991
|
+
bottom: e.shapePaddingBottom,
|
|
4992
|
+
left: e.shapePaddingLeft
|
|
4993
|
+
} });
|
|
4994
|
+
}
|
|
4995
|
+
static _resolveInternalShapeTextInset({ group: e, width: t, height: n }) {
|
|
4996
|
+
let r = e.shapePresetKey ?? "", i = r ? ut({ presetKey: r }) : null;
|
|
4997
|
+
return i ? pt({
|
|
4998
|
+
preset: i,
|
|
4999
|
+
width: t,
|
|
5000
|
+
height: n
|
|
5001
|
+
}) : {
|
|
5002
|
+
top: 0,
|
|
5003
|
+
right: 0,
|
|
5004
|
+
bottom: 0,
|
|
5005
|
+
left: 0
|
|
4799
5006
|
};
|
|
4800
5007
|
}
|
|
5008
|
+
static _resolveEffectivePadding({ group: t }) {
|
|
5009
|
+
let n = Math.max(X, t.shapeBaseWidth ?? t.width ?? t.shapeManualBaseWidth ?? X), r = Math.max(X, t.shapeBaseHeight ?? t.height ?? t.shapeManualBaseHeight ?? X), i = e._resolveUserPadding({ group: t });
|
|
5010
|
+
return zt({
|
|
5011
|
+
base: e._resolveInternalShapeTextInset({
|
|
5012
|
+
group: t,
|
|
5013
|
+
width: n,
|
|
5014
|
+
height: r
|
|
5015
|
+
}),
|
|
5016
|
+
addition: i
|
|
5017
|
+
});
|
|
5018
|
+
}
|
|
5019
|
+
static _resolveScalingConstraintPadding({ group: t }) {
|
|
5020
|
+
let n = Math.max(X, t.shapeBaseWidth ?? t.width ?? t.shapeManualBaseWidth ?? X), r = Math.max(X, t.shapeBaseHeight ?? t.height ?? t.shapeManualBaseHeight ?? X);
|
|
5021
|
+
return e._resolveInternalShapeTextInset({
|
|
5022
|
+
group: t,
|
|
5023
|
+
width: n,
|
|
5024
|
+
height: r
|
|
5025
|
+
});
|
|
5026
|
+
}
|
|
4801
5027
|
_restoreScalingAnchorPosition({ group: e, state: t }) {
|
|
4802
5028
|
let { scalingAnchorX: n, scalingAnchorY: r, scalingAnchorOriginX: i, scalingAnchorOriginY: a } = t;
|
|
4803
5029
|
if (n === null || r === null || i === null || a === null) {
|
|
@@ -4806,31 +5032,37 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4806
5032
|
}
|
|
4807
5033
|
e.setPositionByOrigin(new p(n, r), i, a), e.setCoords();
|
|
4808
5034
|
}
|
|
4809
|
-
_restoreShapeStateWithoutResize({ group:
|
|
4810
|
-
|
|
4811
|
-
|
|
4812
|
-
|
|
4813
|
-
|
|
4814
|
-
|
|
4815
|
-
|
|
4816
|
-
|
|
4817
|
-
|
|
4818
|
-
|
|
4819
|
-
|
|
4820
|
-
|
|
4821
|
-
|
|
4822
|
-
|
|
4823
|
-
|
|
5035
|
+
_restoreShapeStateWithoutResize({ group: t, shape: n, text: r, state: i, startWidth: a, startHeight: o, alignH: s, alignV: c, userPadding: l }) {
|
|
5036
|
+
let u = Math.max(X, t.shapeBaseWidth ?? t.width ?? a), d = Math.max(X, t.shapeBaseHeight ?? t.height ?? o);
|
|
5037
|
+
$t({
|
|
5038
|
+
group: t,
|
|
5039
|
+
shape: n,
|
|
5040
|
+
text: r,
|
|
5041
|
+
width: u,
|
|
5042
|
+
height: d,
|
|
5043
|
+
alignH: s,
|
|
5044
|
+
alignV: c,
|
|
5045
|
+
padding: l,
|
|
5046
|
+
internalShapeTextInset: e._resolveInternalShapeTextInset({
|
|
5047
|
+
group: t,
|
|
5048
|
+
width: u,
|
|
5049
|
+
height: d
|
|
5050
|
+
})
|
|
5051
|
+
}), t.set({
|
|
5052
|
+
left: i.lastAllowedLeft,
|
|
5053
|
+
top: i.lastAllowedTop,
|
|
5054
|
+
flipX: i.lastAllowedFlipX,
|
|
5055
|
+
flipY: i.lastAllowedFlipY,
|
|
4824
5056
|
scaleX: 1,
|
|
4825
5057
|
scaleY: 1
|
|
4826
5058
|
}), this._restoreScalingAnchorPosition({
|
|
4827
|
-
group:
|
|
4828
|
-
state:
|
|
5059
|
+
group: t,
|
|
5060
|
+
state: i
|
|
4829
5061
|
});
|
|
4830
5062
|
}
|
|
4831
5063
|
_restoreGroupTransformOnly({ group: e, shape: t, text: n, state: r }) {
|
|
4832
5064
|
let i = Math.max(X, e.shapeBaseWidth ?? e.width ?? r.startWidth), a = Math.max(X, e.shapeBaseHeight ?? e.height ?? r.startHeight);
|
|
4833
|
-
t && (
|
|
5065
|
+
t && (bt({
|
|
4834
5066
|
shape: t,
|
|
4835
5067
|
width: i,
|
|
4836
5068
|
height: a,
|
|
@@ -4854,7 +5086,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4854
5086
|
});
|
|
4855
5087
|
}
|
|
4856
5088
|
_resolveScalingStartDimensions({ group: e, transform: t }) {
|
|
4857
|
-
let { canScaleWidth: n, canScaleHeight: r } =
|
|
5089
|
+
let { canScaleWidth: n, canScaleHeight: r } = Un({ transform: t }), i = Math.max(X, e.shapeBaseWidth ?? e.width ?? e.shapeManualBaseWidth ?? X), a = Math.max(X, e.shapeBaseHeight ?? e.height ?? e.shapeManualBaseHeight ?? X);
|
|
4858
5090
|
return {
|
|
4859
5091
|
startWidth: i,
|
|
4860
5092
|
startHeight: a,
|
|
@@ -4873,10 +5105,10 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4873
5105
|
height: s
|
|
4874
5106
|
};
|
|
4875
5107
|
}
|
|
4876
|
-
},
|
|
5108
|
+
}, er = class {
|
|
4877
5109
|
constructor({ canvas: e }) {
|
|
4878
5110
|
this.handleMouseDown = (e) => {
|
|
4879
|
-
let { target: t, e: n, subTargets: r = [] } = e, i =
|
|
5111
|
+
let { target: t, e: n, subTargets: r = [] } = e, i = In({
|
|
4880
5112
|
target: t,
|
|
4881
5113
|
subTargets: r
|
|
4882
5114
|
});
|
|
@@ -4886,7 +5118,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4886
5118
|
let o = this.canvas.getActiveObject(), s = o === i;
|
|
4887
5119
|
if (!(o === a && a.isEditing)) {
|
|
4888
5120
|
if (!s) {
|
|
4889
|
-
a.isEditing ||
|
|
5121
|
+
a.isEditing || Sn({ text: a });
|
|
4890
5122
|
return;
|
|
4891
5123
|
}
|
|
4892
5124
|
n instanceof MouseEvent && (n.detail < 2 || this.enterTextEditing({ group: i }));
|
|
@@ -4906,14 +5138,14 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4906
5138
|
J(r) && (this._restoreTextEditingInteractionMode({
|
|
4907
5139
|
group: r,
|
|
4908
5140
|
text: n
|
|
4909
|
-
}),
|
|
5141
|
+
}), Sn({ text: n }), this.canvas.getActiveObject() === n && this.canvas.setActiveObject(r), this.canvas.requestRenderAll());
|
|
4910
5142
|
}, this.canvas = e, this.editingInteractionState = /* @__PURE__ */ new WeakMap();
|
|
4911
5143
|
}
|
|
4912
5144
|
enterTextEditing({ group: e }) {
|
|
4913
5145
|
let { text: t } = Y({ group: e });
|
|
4914
5146
|
if (t) {
|
|
4915
5147
|
if (e.locked || t.locked) {
|
|
4916
|
-
|
|
5148
|
+
Sn({ text: t }), this.canvas.requestRenderAll();
|
|
4917
5149
|
return;
|
|
4918
5150
|
}
|
|
4919
5151
|
this._enterTextEditingInteractionMode({
|
|
@@ -4963,7 +5195,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
4963
5195
|
lockMovementY: n.textLockMovementY
|
|
4964
5196
|
}), this.editingInteractionState.delete(e), e.setCoords(), t.setCoords());
|
|
4965
5197
|
}
|
|
4966
|
-
},
|
|
5198
|
+
}, tr = "#B0B5BF", nr = 0, rr = 1, ir = class {
|
|
4967
5199
|
constructor({ editor: e }) {
|
|
4968
5200
|
this._handleObjectScaling = (e) => {
|
|
4969
5201
|
this.scalingController.handleObjectScaling(e);
|
|
@@ -5000,49 +5232,53 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5000
5232
|
textNode: r,
|
|
5001
5233
|
textStyle: n
|
|
5002
5234
|
});
|
|
5003
|
-
}, this.editor = e,
|
|
5235
|
+
}, this.editor = e, Fn(), this.scalingController = new $n({ canvas: e.canvas }), this.editingController = new er({ canvas: e.canvas }), this.editingPlacements = /* @__PURE__ */ new WeakMap(), this.internalTextUpdates = /* @__PURE__ */ new WeakSet(), this._bindEvents();
|
|
5004
5236
|
}
|
|
5005
|
-
async add({ presetKey: e =
|
|
5006
|
-
let n =
|
|
5237
|
+
async add({ presetKey: e = ot, options: t = {} } = {}) {
|
|
5238
|
+
let n = ut({ presetKey: e });
|
|
5007
5239
|
if (!n) return null;
|
|
5008
|
-
let { width: r, height: i, shapeTextAutoExpand: a, left: o, top: s, originX: c, originY: l, text: u, textStyle: d, alignH: f, alignV: p, textPadding: m, rounding: h, withoutAdding: g, withoutSelection: _, withoutSave: v, id: y } = t, b =
|
|
5240
|
+
let { width: r, height: i, shapeTextAutoExpand: a, left: o, top: s, originX: c, originY: l, text: u, textStyle: d, alignH: f, alignV: p, textPadding: m, rounding: h, withoutAdding: g, withoutSelection: _, withoutSave: v, id: y } = t, b = ut({ presetKey: dt({
|
|
5009
5241
|
preset: n,
|
|
5010
5242
|
rounding: h
|
|
5011
5243
|
}) }) ?? n, x = Math.max(1, r ?? b.width), S = Math.max(1, i ?? b.height), C = a !== !1, w = this._resolveHorizontalAlign({
|
|
5012
5244
|
explicitAlign: f,
|
|
5013
5245
|
textStyle: d
|
|
5014
|
-
}), T = p ?? "middle", E =
|
|
5246
|
+
}), T = p ?? "middle", E = Lt({ padding: m }), O = pt({
|
|
5015
5247
|
preset: b,
|
|
5016
|
-
|
|
5017
|
-
|
|
5248
|
+
width: x,
|
|
5249
|
+
height: S
|
|
5250
|
+
}), k = zt({
|
|
5251
|
+
base: O,
|
|
5252
|
+
addition: E
|
|
5253
|
+
}), A = Bt({ padding: m }), j = this._resolveShapeStyle({
|
|
5018
5254
|
options: t,
|
|
5019
5255
|
fallback: null
|
|
5020
|
-
}),
|
|
5256
|
+
}), M = this._createTextNode({
|
|
5021
5257
|
text: u,
|
|
5022
5258
|
textStyle: d,
|
|
5023
5259
|
width: x,
|
|
5024
5260
|
align: w,
|
|
5025
|
-
opacity:
|
|
5026
|
-
}),
|
|
5027
|
-
text:
|
|
5261
|
+
opacity: j.opacity
|
|
5262
|
+
}), N = this._resolveShapeLayoutWidth({
|
|
5263
|
+
text: M,
|
|
5028
5264
|
currentWidth: x,
|
|
5029
5265
|
manualWidth: x,
|
|
5030
5266
|
shapeTextAutoExpandEnabled: C,
|
|
5031
|
-
padding:
|
|
5032
|
-
strokeWidth:
|
|
5033
|
-
}),
|
|
5267
|
+
padding: k,
|
|
5268
|
+
strokeWidth: j.strokeWidth
|
|
5269
|
+
}), P = await Nt({
|
|
5034
5270
|
preset: b,
|
|
5035
|
-
width:
|
|
5271
|
+
width: N,
|
|
5036
5272
|
height: S,
|
|
5037
|
-
style:
|
|
5273
|
+
style: j,
|
|
5038
5274
|
rounding: h
|
|
5039
|
-
}),
|
|
5275
|
+
}), F = this._createShapeGroup({
|
|
5040
5276
|
id: y ?? `shape-${D()}`,
|
|
5041
5277
|
presetKey: b.key,
|
|
5042
|
-
presetCanRound:
|
|
5043
|
-
shape:
|
|
5044
|
-
text:
|
|
5045
|
-
width:
|
|
5278
|
+
presetCanRound: ht({ preset: b }),
|
|
5279
|
+
shape: P,
|
|
5280
|
+
text: M,
|
|
5281
|
+
width: N,
|
|
5046
5282
|
height: S,
|
|
5047
5283
|
manualWidth: x,
|
|
5048
5284
|
manualHeight: S,
|
|
@@ -5050,13 +5286,15 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5050
5286
|
alignH: w,
|
|
5051
5287
|
alignV: T,
|
|
5052
5288
|
padding: E,
|
|
5053
|
-
|
|
5289
|
+
internalShapeTextInset: O,
|
|
5290
|
+
changedPadding: A,
|
|
5291
|
+
style: j,
|
|
5054
5292
|
rounding: h
|
|
5055
5293
|
});
|
|
5056
|
-
if (o === void 0 && s === void 0) this.editor.canvasManager.centerObjectToMontageArea({ object:
|
|
5294
|
+
if (o === void 0 && s === void 0) this.editor.canvasManager.centerObjectToMontageArea({ object: F });
|
|
5057
5295
|
else {
|
|
5058
5296
|
let e = this.editor.canvasManager.resolveObjectPlacement({
|
|
5059
|
-
object:
|
|
5297
|
+
object: F,
|
|
5060
5298
|
left: o,
|
|
5061
5299
|
top: s,
|
|
5062
5300
|
originX: c,
|
|
@@ -5064,23 +5302,23 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5064
5302
|
fallbackPoint: this.editor.canvasManager.getMontageAreaSceneCenter()
|
|
5065
5303
|
});
|
|
5066
5304
|
this.editor.canvasManager.applyObjectPlacement({
|
|
5067
|
-
object:
|
|
5305
|
+
object: F,
|
|
5068
5306
|
placement: e
|
|
5069
5307
|
});
|
|
5070
5308
|
}
|
|
5071
|
-
if (g) return
|
|
5309
|
+
if (g) return F;
|
|
5072
5310
|
this._beginMutation();
|
|
5073
5311
|
try {
|
|
5074
|
-
this.editor.canvas.add(
|
|
5312
|
+
this.editor.canvas.add(F), _ || this.editor.canvas.setActiveObject(F), this.editor.canvas.requestRenderAll();
|
|
5075
5313
|
} finally {
|
|
5076
5314
|
this._endMutation({ withoutSave: v });
|
|
5077
5315
|
}
|
|
5078
|
-
return
|
|
5316
|
+
return F;
|
|
5079
5317
|
}
|
|
5080
5318
|
async update({ target: e, presetKey: t, options: n = {} } = {}) {
|
|
5081
5319
|
let r = this._resolveShapeGroup({ target: e });
|
|
5082
5320
|
if (!r) return null;
|
|
5083
|
-
let i =
|
|
5321
|
+
let i = ut({ presetKey: t ?? r.shapePresetKey ?? "circle" });
|
|
5084
5322
|
if (!i) return null;
|
|
5085
5323
|
let { left: a, top: o, originX: s, originY: c, width: l, height: u, shapeTextAutoExpand: d, text: f, textStyle: p, alignH: m, alignV: h, textPadding: g, rounding: _, withoutSelection: v, withoutSave: y } = n, b = this.editor.canvasManager.resolveObjectPlacement({
|
|
5086
5324
|
object: r,
|
|
@@ -5088,20 +5326,27 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5088
5326
|
top: o,
|
|
5089
5327
|
originX: s,
|
|
5090
5328
|
originY: c
|
|
5091
|
-
}), x = this._resolveCurrentDimensions({ group: r }), S = Math.max(1, u ?? x.height), C = this._isShapeTextAutoExpandEnabled({ group: r }), w = d === void 0 ? C : d !== !1, T = _ ?? r.shapeRounding ?? 0, E =
|
|
5329
|
+
}), x = this._resolveCurrentDimensions({ group: r }), S = Math.max(1, u ?? x.height), C = this._isShapeTextAutoExpandEnabled({ group: r }), w = d === void 0 ? C : d !== !1, T = _ ?? r.shapeRounding ?? 0, E = ut({ presetKey: dt({
|
|
5092
5330
|
preset: i,
|
|
5093
5331
|
rounding: T
|
|
5094
|
-
}) }) ?? i, D = m ?? r.shapeAlignHorizontal ?? "center", O = h ?? r.shapeAlignVertical ?? "middle", k = this.
|
|
5332
|
+
}) }) ?? i, D = m ?? r.shapeAlignHorizontal ?? "center", O = h ?? r.shapeAlignVertical ?? "middle", k = this._resolveGroupUserPadding({ group: r }), A = Bt({ padding: g }), j = Rt({
|
|
5333
|
+
base: k,
|
|
5334
|
+
override: g
|
|
5335
|
+
}), M = pt({
|
|
5095
5336
|
preset: E,
|
|
5096
|
-
|
|
5097
|
-
|
|
5337
|
+
width: x.width,
|
|
5338
|
+
height: S
|
|
5339
|
+
}), N = zt({
|
|
5340
|
+
base: M,
|
|
5341
|
+
addition: j
|
|
5342
|
+
}), P = this._resolveShapeStyle({
|
|
5098
5343
|
options: n,
|
|
5099
5344
|
fallback: r
|
|
5100
|
-
}),
|
|
5101
|
-
l !== void 0 && (
|
|
5102
|
-
let
|
|
5103
|
-
if (!
|
|
5104
|
-
let
|
|
5345
|
+
}), F = Math.max(1, r.shapeManualBaseWidth ?? x.width);
|
|
5346
|
+
l !== void 0 && (F = Math.max(1, l)), l === void 0 && C && !w && (F = Math.max(1, x.width));
|
|
5347
|
+
let ee = Math.max(1, u ?? r.shapeManualBaseHeight ?? S), { shape: te, text: I } = Y({ group: r });
|
|
5348
|
+
if (!te || !I) return null;
|
|
5349
|
+
let ne = {
|
|
5105
5350
|
angle: 0,
|
|
5106
5351
|
skewX: 0,
|
|
5107
5352
|
skewY: 0,
|
|
@@ -5114,68 +5359,71 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5114
5359
|
top: 0,
|
|
5115
5360
|
originX: "left",
|
|
5116
5361
|
originY: "top"
|
|
5117
|
-
},
|
|
5118
|
-
text:
|
|
5119
|
-
textStyle: this._resolveCurrentTextStyle({ textNode:
|
|
5120
|
-
width: Math.max(1,
|
|
5362
|
+
}, re = this._createTextNode({
|
|
5363
|
+
text: I.textCaseRaw ?? I.text ?? "",
|
|
5364
|
+
textStyle: this._resolveCurrentTextStyle({ textNode: I }),
|
|
5365
|
+
width: Math.max(1, I.width ?? x.width),
|
|
5121
5366
|
align: D
|
|
5122
5367
|
});
|
|
5123
|
-
|
|
5124
|
-
textNode:
|
|
5368
|
+
re.set(ne), this._applyTextUpdates({
|
|
5369
|
+
textNode: re,
|
|
5125
5370
|
text: f,
|
|
5126
5371
|
textStyle: p,
|
|
5127
5372
|
align: D
|
|
5128
5373
|
});
|
|
5129
|
-
let L = this._resolveShapeLayoutWidth({
|
|
5130
|
-
text:
|
|
5374
|
+
let L = g !== void 0 && l === void 0 && u === void 0 && t === void 0 && d === void 0 && _ === void 0 && f === void 0 && !this._hasShapeTextSizeAffectingStyleChanges({ textStyle: p }), ie = L ? x.width : this._resolveShapeLayoutWidth({
|
|
5375
|
+
text: re,
|
|
5131
5376
|
currentWidth: x.width,
|
|
5132
|
-
manualWidth:
|
|
5377
|
+
manualWidth: F,
|
|
5133
5378
|
shapeTextAutoExpandEnabled: w,
|
|
5134
|
-
padding:
|
|
5135
|
-
strokeWidth:
|
|
5136
|
-
}),
|
|
5379
|
+
padding: N,
|
|
5380
|
+
strokeWidth: P.strokeWidth
|
|
5381
|
+
}), R = await Nt({
|
|
5137
5382
|
preset: E,
|
|
5138
|
-
width:
|
|
5383
|
+
width: ie,
|
|
5139
5384
|
height: S,
|
|
5140
|
-
style:
|
|
5385
|
+
style: P,
|
|
5141
5386
|
rounding: T
|
|
5142
|
-
}),
|
|
5143
|
-
if (
|
|
5144
|
-
let
|
|
5145
|
-
this._detachShapeGroupAutoLayout({ group: r }),
|
|
5146
|
-
textNode:
|
|
5387
|
+
}), ae = r.getObjects().indexOf(te);
|
|
5388
|
+
if (ae < 0) return null;
|
|
5389
|
+
let z = () => {
|
|
5390
|
+
this._detachShapeGroupAutoLayout({ group: r }), I.set(ne), this._applyTextUpdates({
|
|
5391
|
+
textNode: I,
|
|
5147
5392
|
text: f,
|
|
5148
5393
|
textStyle: p,
|
|
5149
5394
|
align: D
|
|
5150
|
-
}), r.remove(
|
|
5395
|
+
}), r.remove(te), r.insertAt(ae, R), this._applyShapeGroupMetadata({
|
|
5151
5396
|
group: r,
|
|
5152
5397
|
presetKey: E.key,
|
|
5153
|
-
presetCanRound:
|
|
5154
|
-
width:
|
|
5398
|
+
presetCanRound: ht({ preset: E }),
|
|
5399
|
+
width: ie,
|
|
5155
5400
|
height: S,
|
|
5156
|
-
manualWidth:
|
|
5157
|
-
manualHeight:
|
|
5401
|
+
manualWidth: F,
|
|
5402
|
+
manualHeight: ee,
|
|
5158
5403
|
shapeTextAutoExpand: w,
|
|
5159
5404
|
alignH: D,
|
|
5160
5405
|
alignV: O,
|
|
5161
|
-
padding:
|
|
5162
|
-
style:
|
|
5406
|
+
padding: j,
|
|
5407
|
+
style: P,
|
|
5163
5408
|
rounding: T
|
|
5164
5409
|
}), this._applyCurrentLayout({
|
|
5165
5410
|
group: r,
|
|
5166
|
-
shape:
|
|
5167
|
-
text:
|
|
5411
|
+
shape: R,
|
|
5412
|
+
text: I,
|
|
5168
5413
|
placement: b,
|
|
5169
|
-
width:
|
|
5414
|
+
width: ie,
|
|
5170
5415
|
height: S,
|
|
5171
5416
|
alignH: D,
|
|
5172
|
-
alignV: O
|
|
5173
|
-
|
|
5417
|
+
alignV: O,
|
|
5418
|
+
internalShapeTextInset: M,
|
|
5419
|
+
expandShapeHeightToFitText: !L,
|
|
5420
|
+
changedPadding: A
|
|
5421
|
+
}), I.isEditing && this.editingPlacements.set(r, b);
|
|
5174
5422
|
};
|
|
5175
|
-
if (!this._isOnCanvas({ object: r })) return
|
|
5423
|
+
if (!this._isOnCanvas({ object: r })) return z(), r;
|
|
5176
5424
|
this._beginMutation();
|
|
5177
5425
|
try {
|
|
5178
|
-
|
|
5426
|
+
z(), !I.isEditing && !v && this.editor.canvas.setActiveObject(r), this.editor.canvas.requestRenderAll();
|
|
5179
5427
|
} finally {
|
|
5180
5428
|
this._endMutation({ withoutSave: y });
|
|
5181
5429
|
}
|
|
@@ -5199,7 +5447,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5199
5447
|
if (!i) return null;
|
|
5200
5448
|
this._beginMutation();
|
|
5201
5449
|
try {
|
|
5202
|
-
|
|
5450
|
+
xt({
|
|
5203
5451
|
shape: i,
|
|
5204
5452
|
style: { fill: t }
|
|
5205
5453
|
}), r.shapeFill = t, r.setCoords(), this.editor.canvas.requestRenderAll();
|
|
@@ -5215,7 +5463,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5215
5463
|
if (!o) return null;
|
|
5216
5464
|
this._beginMutation();
|
|
5217
5465
|
try {
|
|
5218
|
-
|
|
5466
|
+
xt({
|
|
5219
5467
|
shape: o,
|
|
5220
5468
|
style: {
|
|
5221
5469
|
stroke: t,
|
|
@@ -5239,7 +5487,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5239
5487
|
if (!i) return null;
|
|
5240
5488
|
this._beginMutation();
|
|
5241
5489
|
try {
|
|
5242
|
-
|
|
5490
|
+
xt({
|
|
5243
5491
|
shape: i,
|
|
5244
5492
|
style: { opacity: t }
|
|
5245
5493
|
}), a && (a.set({ opacity: t }), a.setCoords()), r.shapeOpacity = t, r.setCoords(), this.editor.canvas.requestRenderAll();
|
|
@@ -5331,8 +5579,8 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5331
5579
|
let { canvas: e } = this.editor;
|
|
5332
5580
|
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);
|
|
5333
5581
|
}
|
|
5334
|
-
_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,
|
|
5335
|
-
let
|
|
5582
|
+
_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 }) {
|
|
5583
|
+
let _ = new Pn([r, i], {
|
|
5336
5584
|
id: e,
|
|
5337
5585
|
originX: "center",
|
|
5338
5586
|
originY: "center",
|
|
@@ -5343,7 +5591,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5343
5591
|
objectCaching: !1
|
|
5344
5592
|
});
|
|
5345
5593
|
return this._applyShapeGroupMetadata({
|
|
5346
|
-
group:
|
|
5594
|
+
group: _,
|
|
5347
5595
|
presetKey: t,
|
|
5348
5596
|
presetCanRound: n,
|
|
5349
5597
|
width: a,
|
|
@@ -5354,18 +5602,20 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5354
5602
|
alignH: u,
|
|
5355
5603
|
alignV: d,
|
|
5356
5604
|
padding: f,
|
|
5357
|
-
style:
|
|
5358
|
-
rounding:
|
|
5359
|
-
}),
|
|
5360
|
-
group:
|
|
5605
|
+
style: h,
|
|
5606
|
+
rounding: g
|
|
5607
|
+
}), _.rehydrateRuntimeState(), zn({ group: _ }), Sn({ text: i }), $t({
|
|
5608
|
+
group: _,
|
|
5361
5609
|
shape: r,
|
|
5362
5610
|
text: i,
|
|
5363
5611
|
width: a,
|
|
5364
5612
|
height: o,
|
|
5365
5613
|
alignH: u,
|
|
5366
5614
|
alignV: d,
|
|
5367
|
-
padding: f
|
|
5368
|
-
|
|
5615
|
+
padding: f,
|
|
5616
|
+
internalShapeTextInset: p,
|
|
5617
|
+
changedPadding: m
|
|
5618
|
+
}), this._detachShapeGroupAutoLayout({ group: _ }), _;
|
|
5369
5619
|
}
|
|
5370
5620
|
_applyShapeGroupMetadata({ group: e, presetKey: t, presetCanRound: n, width: r, height: i, manualWidth: a, manualHeight: o, shapeTextAutoExpand: s, alignH: c, alignV: l, padding: u, style: d, rounding: f }) {
|
|
5371
5621
|
let p = d.strokeDashArray ? d.strokeDashArray.slice() : d.strokeDashArray ?? null;
|
|
@@ -5412,7 +5662,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5412
5662
|
return s.set({
|
|
5413
5663
|
shapeNodeType: "text",
|
|
5414
5664
|
splitByGrapheme: !1
|
|
5415
|
-
}),
|
|
5665
|
+
}), Sn({ text: s }), s;
|
|
5416
5666
|
}
|
|
5417
5667
|
_applyTextUpdates({ textNode: e, text: t, textStyle: n, align: r }) {
|
|
5418
5668
|
let i = {};
|
|
@@ -5483,12 +5733,25 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5483
5733
|
height: Math.max(1, e.shapeManualBaseHeight ?? e.shapeBaseHeight ?? e.height ?? 1)
|
|
5484
5734
|
};
|
|
5485
5735
|
}
|
|
5486
|
-
|
|
5487
|
-
return {
|
|
5488
|
-
top: e.shapePaddingTop
|
|
5489
|
-
right: e.shapePaddingRight
|
|
5490
|
-
bottom: e.shapePaddingBottom
|
|
5491
|
-
left: e.shapePaddingLeft
|
|
5736
|
+
_resolveGroupUserPadding({ group: e }) {
|
|
5737
|
+
return Lt({ padding: {
|
|
5738
|
+
top: e.shapePaddingTop,
|
|
5739
|
+
right: e.shapePaddingRight,
|
|
5740
|
+
bottom: e.shapePaddingBottom,
|
|
5741
|
+
left: e.shapePaddingLeft
|
|
5742
|
+
} });
|
|
5743
|
+
}
|
|
5744
|
+
_resolveGroupInternalShapeTextInset({ group: e, width: t, height: n }) {
|
|
5745
|
+
let r = ut({ presetKey: e.shapePresetKey ?? "circle" });
|
|
5746
|
+
return r ? pt({
|
|
5747
|
+
preset: r,
|
|
5748
|
+
width: t,
|
|
5749
|
+
height: n
|
|
5750
|
+
}) : {
|
|
5751
|
+
top: 0,
|
|
5752
|
+
right: 0,
|
|
5753
|
+
bottom: 0,
|
|
5754
|
+
left: 0
|
|
5492
5755
|
};
|
|
5493
5756
|
}
|
|
5494
5757
|
_isShapeTextAutoExpandEnabled({ group: e }) {
|
|
@@ -5502,7 +5765,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5502
5765
|
}
|
|
5503
5766
|
_resolveAutoExpandShapeWidth({ text: e, currentWidth: t, minimumWidth: n, padding: r, strokeWidth: i }) {
|
|
5504
5767
|
let a = this._resolveMontageAreaWidth();
|
|
5505
|
-
return a ?
|
|
5768
|
+
return a ? en({
|
|
5506
5769
|
text: e,
|
|
5507
5770
|
currentWidth: t,
|
|
5508
5771
|
minimumWidth: n,
|
|
@@ -5524,29 +5787,43 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5524
5787
|
let n = t?.align;
|
|
5525
5788
|
return n === "left" || n === "center" || n === "right" ? n : e.shapeAlignHorizontal ?? "center";
|
|
5526
5789
|
}
|
|
5527
|
-
_applyCurrentLayout({ group: e, shape: t, text: n, placement: r, width: i, height: a, alignH: o, alignV: s }) {
|
|
5528
|
-
let
|
|
5529
|
-
|
|
5790
|
+
_applyCurrentLayout({ group: e, shape: t, text: n, placement: r, width: i, height: a, alignH: o, alignV: s, internalShapeTextInset: c, expandShapeHeightToFitText: l = !0, changedPadding: u }) {
|
|
5791
|
+
let d = this._resolveCurrentDimensions({ group: e }), f = this._resolveManualDimensions({ group: e }), p = this._resolveGroupUserPadding({ group: e }), m = d.width;
|
|
5792
|
+
m = i === void 0 ? this._resolveShapeLayoutWidth({
|
|
5530
5793
|
text: n,
|
|
5531
|
-
currentWidth:
|
|
5532
|
-
manualWidth:
|
|
5794
|
+
currentWidth: d.width,
|
|
5795
|
+
manualWidth: f.width,
|
|
5533
5796
|
shapeTextAutoExpandEnabled: this._isShapeTextAutoExpandEnabled({ group: e }),
|
|
5534
|
-
padding:
|
|
5797
|
+
padding: zt({
|
|
5798
|
+
base: c ?? this._resolveGroupInternalShapeTextInset({
|
|
5799
|
+
group: e,
|
|
5800
|
+
width: m,
|
|
5801
|
+
height: Math.max(1, a ?? d.height)
|
|
5802
|
+
}),
|
|
5803
|
+
addition: p
|
|
5804
|
+
}),
|
|
5535
5805
|
strokeWidth: e.shapeStrokeWidth
|
|
5536
5806
|
}) : Math.max(1, i);
|
|
5537
|
-
let
|
|
5538
|
-
|
|
5807
|
+
let h = Math.max(1, a ?? d.height), g = c ?? this._resolveGroupInternalShapeTextInset({
|
|
5808
|
+
group: e,
|
|
5809
|
+
width: m,
|
|
5810
|
+
height: h
|
|
5811
|
+
}), _ = r ?? this.editor.canvasManager.getObjectPlacement({ object: e });
|
|
5812
|
+
$t({
|
|
5539
5813
|
group: e,
|
|
5540
5814
|
shape: t,
|
|
5541
5815
|
text: n,
|
|
5542
|
-
width:
|
|
5543
|
-
height:
|
|
5816
|
+
width: m,
|
|
5817
|
+
height: h,
|
|
5544
5818
|
alignH: o ?? e.shapeAlignHorizontal ?? "center",
|
|
5545
5819
|
alignV: s ?? e.shapeAlignVertical ?? "middle",
|
|
5546
|
-
padding:
|
|
5820
|
+
padding: p,
|
|
5821
|
+
internalShapeTextInset: g,
|
|
5822
|
+
expandShapeHeightToFitText: l,
|
|
5823
|
+
changedPadding: u
|
|
5547
5824
|
}), this.editor.canvasManager.applyObjectPlacement({
|
|
5548
5825
|
object: e,
|
|
5549
|
-
placement:
|
|
5826
|
+
placement: _
|
|
5550
5827
|
});
|
|
5551
5828
|
}
|
|
5552
5829
|
_syncShapeTextLayoutAfterTextMutation({ textNode: e, textStyle: t }) {
|
|
@@ -5572,21 +5849,30 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5572
5849
|
return this.editingPlacements.get(e) || this.editor.canvasManager.getObjectPlacement({ object: e });
|
|
5573
5850
|
}
|
|
5574
5851
|
_detachShapeGroupAutoLayout({ group: e }) {
|
|
5575
|
-
|
|
5852
|
+
Cn({ group: e });
|
|
5576
5853
|
}
|
|
5577
5854
|
_resolveHorizontalAlign({ explicitAlign: e, textStyle: t }) {
|
|
5578
5855
|
if (e) return e;
|
|
5579
5856
|
let n = t?.align;
|
|
5580
|
-
return n === "left" || n === "center" || n === "right" ? n :
|
|
5857
|
+
return n === "left" || n === "center" || n === "right" ? n : st;
|
|
5858
|
+
}
|
|
5859
|
+
_hasShapeTextSizeAffectingStyleChanges({ textStyle: e }) {
|
|
5860
|
+
if (!e) return !1;
|
|
5861
|
+
let t = Object.keys(e);
|
|
5862
|
+
for (let e = 0; e < t.length; e += 1) {
|
|
5863
|
+
let n = t[e];
|
|
5864
|
+
if (!(n === "align" || n === "color" || n === "strokeColor" || n === "strokeWidth" || n === "underline" || n === "strikethrough" || n === "opacity")) return !0;
|
|
5865
|
+
}
|
|
5866
|
+
return !1;
|
|
5581
5867
|
}
|
|
5582
5868
|
_resolveShapeStyle({ options: e, fallback: t }) {
|
|
5583
5869
|
let { fill: n, stroke: r, strokeWidth: i, strokeDashArray: a, opacity: o } = e, s = a === void 0 ? t?.shapeStrokeDashArray : a;
|
|
5584
5870
|
return {
|
|
5585
|
-
fill: n ?? t?.shapeFill ??
|
|
5871
|
+
fill: n ?? t?.shapeFill ?? tr,
|
|
5586
5872
|
stroke: r ?? t?.shapeStroke ?? null,
|
|
5587
|
-
strokeWidth: i ?? t?.shapeStrokeWidth ??
|
|
5873
|
+
strokeWidth: i ?? t?.shapeStrokeWidth ?? nr,
|
|
5588
5874
|
strokeDashArray: s ?? null,
|
|
5589
|
-
opacity: o ?? t?.shapeOpacity ??
|
|
5875
|
+
opacity: o ?? t?.shapeOpacity ?? rr
|
|
5590
5876
|
};
|
|
5591
5877
|
}
|
|
5592
5878
|
_beginMutation() {
|
|
@@ -5622,7 +5908,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5622
5908
|
}
|
|
5623
5909
|
return null;
|
|
5624
5910
|
}
|
|
5625
|
-
},
|
|
5911
|
+
}, ar = class {
|
|
5626
5912
|
constructor({ editor: e }) {
|
|
5627
5913
|
this.editor = e, this.clipboard = null;
|
|
5628
5914
|
}
|
|
@@ -5878,12 +6164,12 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5878
6164
|
}), !1;
|
|
5879
6165
|
}
|
|
5880
6166
|
}
|
|
5881
|
-
},
|
|
6167
|
+
}, or = class t {
|
|
5882
6168
|
constructor({ editor: e }) {
|
|
5883
6169
|
this.editor = e;
|
|
5884
6170
|
}
|
|
5885
6171
|
lockObject({ object: e, skipInnerObjects: n, withoutSave: r } = {}) {
|
|
5886
|
-
let { canvas: i, historyManager: a } = this.editor, o = e || i.getActiveObject(), s =
|
|
6172
|
+
let { canvas: i, historyManager: a } = this.editor, o = e || i.getActiveObject(), s = In({ target: o }) ?? o;
|
|
5887
6173
|
if (!s || s.locked) return;
|
|
5888
6174
|
let c = {
|
|
5889
6175
|
lockMovementX: !0,
|
|
@@ -5905,7 +6191,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5905
6191
|
});
|
|
5906
6192
|
}
|
|
5907
6193
|
unlockObject({ object: e, withoutSave: n } = {}) {
|
|
5908
|
-
let { canvas: r, historyManager: i } = this.editor, a = e || r.getActiveObject(), o =
|
|
6194
|
+
let { canvas: r, historyManager: i } = this.editor, a = e || r.getActiveObject(), o = In({ target: a }) ?? a;
|
|
5909
6195
|
if (!o) return;
|
|
5910
6196
|
let s = {
|
|
5911
6197
|
lockMovementX: !1,
|
|
@@ -5943,7 +6229,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5943
6229
|
!(n instanceof _) || !n.isEditing || n.exitEditing();
|
|
5944
6230
|
}
|
|
5945
6231
|
}
|
|
5946
|
-
},
|
|
6232
|
+
}, sr = class {
|
|
5947
6233
|
constructor({ editor: e }) {
|
|
5948
6234
|
this.editor = e;
|
|
5949
6235
|
}
|
|
@@ -6009,7 +6295,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6009
6295
|
i.resumeHistory(), n || i.saveState();
|
|
6010
6296
|
}
|
|
6011
6297
|
}
|
|
6012
|
-
},
|
|
6298
|
+
}, cr = class t {
|
|
6013
6299
|
constructor({ editor: e }) {
|
|
6014
6300
|
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();
|
|
6015
6301
|
}
|
|
@@ -6203,7 +6489,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6203
6489
|
let { options: e } = this.editor, { selectionKey: t } = e;
|
|
6204
6490
|
return t === void 0 ? ["ctrlKey", "metaKey"] : t;
|
|
6205
6491
|
}
|
|
6206
|
-
},
|
|
6492
|
+
}, lr = class e {
|
|
6207
6493
|
constructor({ editor: e }) {
|
|
6208
6494
|
this.editor = e;
|
|
6209
6495
|
}
|
|
@@ -6243,7 +6529,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6243
6529
|
};
|
|
6244
6530
|
return i.fire("editor:objects-deleted", l), l;
|
|
6245
6531
|
}
|
|
6246
|
-
},
|
|
6532
|
+
}, ur = {
|
|
6247
6533
|
IMAGE_MANAGER: {
|
|
6248
6534
|
INVALID_CONTENT_TYPE: "INVALID_CONTENT_TYPE",
|
|
6249
6535
|
INVALID_SOURCE_TYPE: "INVALID_SOURCE_TYPE",
|
|
@@ -6281,7 +6567,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6281
6567
|
INVALID_TARGET: "TEMPLATE_INVALID_TARGET",
|
|
6282
6568
|
APPLY_FAILED: "TEMPLATE_APPLY_FAILED"
|
|
6283
6569
|
}
|
|
6284
|
-
},
|
|
6570
|
+
}, dr = class e {
|
|
6285
6571
|
constructor({ editor: e }) {
|
|
6286
6572
|
this._buffer = [], this.editor = e;
|
|
6287
6573
|
}
|
|
@@ -6339,9 +6625,9 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6339
6625
|
}), this.editor.canvas.fire("editor:warning", s);
|
|
6340
6626
|
}
|
|
6341
6627
|
static isValidErrorCode(e) {
|
|
6342
|
-
return e ? Object.values(
|
|
6628
|
+
return e ? Object.values(ur).some((t) => Object.values(t).includes(e)) : !1;
|
|
6343
6629
|
}
|
|
6344
|
-
},
|
|
6630
|
+
}, fr = class {
|
|
6345
6631
|
constructor({ editor: e }) {
|
|
6346
6632
|
this.currentBounds = null, this.editor = e;
|
|
6347
6633
|
}
|
|
@@ -6390,32 +6676,32 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6390
6676
|
updateBounds() {
|
|
6391
6677
|
this.currentBounds = this.calculatePanBounds();
|
|
6392
6678
|
}
|
|
6393
|
-
},
|
|
6679
|
+
}, pr = ({ textbox: e }) => {
|
|
6394
6680
|
if (!e.isEditing) return null;
|
|
6395
6681
|
let t = e.selectionStart ?? 0, n = e.selectionEnd ?? t;
|
|
6396
6682
|
return t === n ? null : {
|
|
6397
6683
|
start: Math.min(t, n),
|
|
6398
6684
|
end: Math.max(t, n)
|
|
6399
6685
|
};
|
|
6400
|
-
},
|
|
6686
|
+
}, mr = ({ textbox: e }) => {
|
|
6401
6687
|
let t = e.text?.length ?? 0;
|
|
6402
6688
|
return t <= 0 ? null : {
|
|
6403
6689
|
start: 0,
|
|
6404
6690
|
end: t
|
|
6405
6691
|
};
|
|
6406
|
-
},
|
|
6692
|
+
}, hr = ({ textbox: e, range: t }) => {
|
|
6407
6693
|
if (!t) return !1;
|
|
6408
6694
|
let n = e.text?.length ?? 0;
|
|
6409
6695
|
return n <= 0 ? !1 : t.start <= 0 && t.end >= n;
|
|
6410
|
-
},
|
|
6696
|
+
}, gr = ({ textbox: e, styles: t, range: n }) => {
|
|
6411
6697
|
if (!t || !Object.keys(t).length) return !1;
|
|
6412
6698
|
let { start: r, end: i } = n;
|
|
6413
6699
|
return i <= r ? !1 : (e.setSelectionStyles(t, r, i), !0);
|
|
6414
|
-
},
|
|
6700
|
+
}, _r = ({ textbox: e, range: t, property: n }) => {
|
|
6415
6701
|
if (!t) return;
|
|
6416
6702
|
let r = e.getSelectionStyles(t.start, t.end, !0);
|
|
6417
6703
|
if (r.length) return r[0]?.[n];
|
|
6418
|
-
},
|
|
6704
|
+
}, vr = ({ strokeColor: e, width: t }) => t <= 0 ? null : e ?? "#000000", yr = ({ width: e = 0 }) => e ? Math.max(0, e) : 0, br = ({ value: e }) => typeof e == "string" ? e.toLocaleUpperCase() : "", xr = ({ value: e, min: t, max: n }) => Math.min(Math.max(e, t), n), Sr = class e extends _ {
|
|
6419
6705
|
static {
|
|
6420
6706
|
this.type = "background-textbox";
|
|
6421
6707
|
}
|
|
@@ -6540,7 +6826,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6540
6826
|
this._removeShadow(e);
|
|
6541
6827
|
}
|
|
6542
6828
|
_getDecorationColorAt(e, t) {
|
|
6543
|
-
let n = this.getValueOfPropertyAt(e, t, "strokeWidth"), r =
|
|
6829
|
+
let n = this.getValueOfPropertyAt(e, t, "strokeWidth"), r = yr({ width: typeof n == "number" && Number.isFinite(n) ? n : 0 }), i = this.getValueOfPropertyAt(e, t, "stroke"), a = i == null ? null : vr({
|
|
6544
6830
|
strokeColor: i,
|
|
6545
6831
|
width: r
|
|
6546
6832
|
});
|
|
@@ -6556,22 +6842,22 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6556
6842
|
_getCornerRadii({ width: e, height: t }) {
|
|
6557
6843
|
let n = e / 2, r = t / 2, i = Math.min(n, r);
|
|
6558
6844
|
return {
|
|
6559
|
-
bottomLeft:
|
|
6845
|
+
bottomLeft: xr({
|
|
6560
6846
|
value: this.radiusBottomLeft ?? 0,
|
|
6561
6847
|
min: 0,
|
|
6562
6848
|
max: i
|
|
6563
6849
|
}),
|
|
6564
|
-
bottomRight:
|
|
6850
|
+
bottomRight: xr({
|
|
6565
6851
|
value: this.radiusBottomRight ?? 0,
|
|
6566
6852
|
min: 0,
|
|
6567
6853
|
max: i
|
|
6568
6854
|
}),
|
|
6569
|
-
topLeft:
|
|
6855
|
+
topLeft: xr({
|
|
6570
6856
|
value: this.radiusTopLeft ?? 0,
|
|
6571
6857
|
min: 0,
|
|
6572
6858
|
max: i
|
|
6573
6859
|
}),
|
|
6574
|
-
topRight:
|
|
6860
|
+
topRight: xr({
|
|
6575
6861
|
value: this.radiusTopRight ?? 0,
|
|
6576
6862
|
min: 0,
|
|
6577
6863
|
max: i
|
|
@@ -6589,7 +6875,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6589
6875
|
_getEffectiveBackgroundFill() {
|
|
6590
6876
|
let e = this.backgroundColor;
|
|
6591
6877
|
if (!e) return null;
|
|
6592
|
-
let t =
|
|
6878
|
+
let t = xr({
|
|
6593
6879
|
value: this.backgroundOpacity ?? 1,
|
|
6594
6880
|
min: 0,
|
|
6595
6881
|
max: 1
|
|
@@ -6597,7 +6883,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6597
6883
|
try {
|
|
6598
6884
|
r = new n(e);
|
|
6599
6885
|
} catch (t) {
|
|
6600
|
-
return
|
|
6886
|
+
return dr.emitError({
|
|
6601
6887
|
origin: "BackgroundTextbox",
|
|
6602
6888
|
method: "_getEffectiveBackgroundFill",
|
|
6603
6889
|
code: "INVALID_COLOR_VALUE",
|
|
@@ -6611,19 +6897,19 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6611
6897
|
return r.setAlpha(t), r.toRgba();
|
|
6612
6898
|
}
|
|
6613
6899
|
static _renderRoundedRect({ ctx: e, height: t, left: n, radii: r, top: i, width: a }) {
|
|
6614
|
-
let o = n + a, s = i + t, { topLeft: c, topRight: l, bottomRight: u, bottomLeft: d } = r, f =
|
|
6900
|
+
let o = n + a, s = i + t, { topLeft: c, topRight: l, bottomRight: u, bottomLeft: d } = r, f = xr({
|
|
6615
6901
|
value: c,
|
|
6616
6902
|
min: 0,
|
|
6617
6903
|
max: a
|
|
6618
|
-
}), p =
|
|
6904
|
+
}), p = xr({
|
|
6619
6905
|
value: l,
|
|
6620
6906
|
min: 0,
|
|
6621
6907
|
max: a
|
|
6622
|
-
}), m =
|
|
6908
|
+
}), m = xr({
|
|
6623
6909
|
value: u,
|
|
6624
6910
|
min: 0,
|
|
6625
6911
|
max: a
|
|
6626
|
-
}), h =
|
|
6912
|
+
}), h = xr({
|
|
6627
6913
|
value: d,
|
|
6628
6914
|
min: 0,
|
|
6629
6915
|
max: a
|
|
@@ -6634,9 +6920,9 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6634
6920
|
let { width: e = 0, height: t = 0 } = this, n = Math.round(e), r = Math.round(t);
|
|
6635
6921
|
n !== e && (this.width = Math.max(0, n)), r !== t && (this.height = Math.max(0, r));
|
|
6636
6922
|
}
|
|
6637
|
-
},
|
|
6638
|
-
y?.setClass && y.setClass(
|
|
6639
|
-
},
|
|
6923
|
+
}, Cr = () => {
|
|
6924
|
+
y?.setClass && y.setClass(Sr, "background-textbox");
|
|
6925
|
+
}, wr = .01, Tr = ({ textbox: e, lineIndices: t, updates: n }) => {
|
|
6640
6926
|
if (!t.length) return !1;
|
|
6641
6927
|
let { fontFamily: r, fontSize: i, fill: a, stroke: o } = n;
|
|
6642
6928
|
if (!(r !== void 0 || i !== void 0 || a !== void 0 || o !== void 0)) return !1;
|
|
@@ -6648,7 +6934,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6648
6934
|
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);
|
|
6649
6935
|
}
|
|
6650
6936
|
return l && (e.lineFontDefaults = c), l;
|
|
6651
|
-
},
|
|
6937
|
+
}, Er = ({ lineText: e, lineStyles: t, lineDefaults: n }) => {
|
|
6652
6938
|
let r = e.length;
|
|
6653
6939
|
if (r === 0) return {
|
|
6654
6940
|
lineStyles: t,
|
|
@@ -6680,7 +6966,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6680
6966
|
lineStyles: l,
|
|
6681
6967
|
changed: u
|
|
6682
6968
|
};
|
|
6683
|
-
},
|
|
6969
|
+
}, Dr = ({ lineFontDefaults: e }) => {
|
|
6684
6970
|
if (!e) return;
|
|
6685
6971
|
let t = {};
|
|
6686
6972
|
for (let n in e) {
|
|
@@ -6691,7 +6977,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6691
6977
|
i && (t[r] = { ...i });
|
|
6692
6978
|
}
|
|
6693
6979
|
return t;
|
|
6694
|
-
},
|
|
6980
|
+
}, Or = ({ lineFontDefaults: e, scale: t }) => {
|
|
6695
6981
|
if (!e || !Number.isFinite(t) || Math.abs(t - 1) < .01) return;
|
|
6696
6982
|
let n = {}, r = !1, i = !1;
|
|
6697
6983
|
for (let a in e) {
|
|
@@ -6708,20 +6994,20 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6708
6994
|
n[o] = c, r = !0;
|
|
6709
6995
|
}
|
|
6710
6996
|
if (!(!r || !i)) return n;
|
|
6711
|
-
},
|
|
6997
|
+
}, kr = ({ textbox: e, text: t }) => {
|
|
6712
6998
|
let { textLines: n } = e, r = Array.isArray(n) && n.length > 0 ? n.length : Math.max(t.split("\n").length, 1), i = 0;
|
|
6713
6999
|
for (let t = 0; t < r; t += 1) {
|
|
6714
7000
|
let n = e.getLineWidth(t);
|
|
6715
7001
|
n > i && (i = n);
|
|
6716
7002
|
}
|
|
6717
7003
|
return i;
|
|
6718
|
-
},
|
|
7004
|
+
}, Ar = ({ textbox: e, montageLeft: t, montageRight: n }) => {
|
|
6719
7005
|
e.setCoords();
|
|
6720
7006
|
let r = e.getBoundingRect(!1, !0), i = r.left ?? 0, a = i + (r.width ?? 0), o = n - t;
|
|
6721
7007
|
if (o > 0 && (r.width ?? 0) >= o - .01) return !1;
|
|
6722
7008
|
let s = 0;
|
|
6723
7009
|
return i < t ? s = t - i : a > n && (s = n - a), Math.abs(s) <= .01 ? !1 : (e.set({ left: (e.left ?? 0) + s }), !0);
|
|
6724
|
-
},
|
|
7010
|
+
}, jr = ({ rawValue: e, calculatedValue: t }) => typeof e == "number" ? e : typeof t == "number" ? t : 0, Mr = ({ stylesList: e }) => {
|
|
6725
7011
|
let t = e.length;
|
|
6726
7012
|
if (!t) return !1;
|
|
6727
7013
|
for (let n = 0; n < t; n += 1) {
|
|
@@ -6731,16 +7017,16 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6731
7017
|
if (r !== void 0 || i !== void 0 || a !== void 0 || o !== void 0 || s !== void 0 || c !== void 0) return !0;
|
|
6732
7018
|
}
|
|
6733
7019
|
return !1;
|
|
6734
|
-
},
|
|
6735
|
-
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 =
|
|
7020
|
+
}, Nr = ({ textbox: e }) => {
|
|
7021
|
+
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 = jr({
|
|
6736
7022
|
rawValue: t,
|
|
6737
7023
|
calculatedValue: a
|
|
6738
|
-
}), c =
|
|
7024
|
+
}), c = jr({
|
|
6739
7025
|
rawValue: n,
|
|
6740
7026
|
calculatedValue: o
|
|
6741
7027
|
}), l = Number.isFinite(s) ? Math.round(s) : null, u = Number.isFinite(c) ? Math.round(c) : null, d = {};
|
|
6742
7028
|
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;
|
|
6743
|
-
},
|
|
7029
|
+
}, Pr = ({ textbox: e }) => {
|
|
6744
7030
|
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;
|
|
6745
7031
|
return {
|
|
6746
7032
|
width: t,
|
|
@@ -6758,9 +7044,9 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6758
7044
|
bottomLeft: f
|
|
6759
7045
|
},
|
|
6760
7046
|
styles: JSON.parse(JSON.stringify(r)),
|
|
6761
|
-
lineFontDefaults:
|
|
7047
|
+
lineFontDefaults: Dr({ lineFontDefaults: i })
|
|
6762
7048
|
};
|
|
6763
|
-
},
|
|
7049
|
+
}, Fr = ({ base: e }) => {
|
|
6764
7050
|
let t = 1 / Math.max(1, e.width), n = [e.fontSize];
|
|
6765
7051
|
Object.values(e.styles).forEach((e) => {
|
|
6766
7052
|
Object.values(e).forEach((e) => {
|
|
@@ -6777,7 +7063,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6777
7063
|
fontScale: r,
|
|
6778
7064
|
proportionalScale: Math.max(t, r)
|
|
6779
7065
|
};
|
|
6780
|
-
},
|
|
7066
|
+
}, Ir = ({ textbox: e, canvasManager: t, base: n, widthScale: r, heightScale: i, placement: a, shouldScaleFontSize: o, shouldScalePadding: s, shouldScaleRadii: c, shouldDisableAutoExpandOnHorizontalChange: l = !1, shouldRoundDimensions: u = !0 }) => {
|
|
6781
7067
|
let { width: d, fontSize: f, padding: p, radii: m, styles: h, lineFontDefaults: g } = n, _ = Math.max(1, d * r), v = u ? Math.max(1, Math.round(_)) : _, y = Math.max(Math.min(8, f), f * i), b = Object.keys(h).length > 0, x;
|
|
6782
7068
|
if (o && b) {
|
|
6783
7069
|
let e = {};
|
|
@@ -6796,7 +7082,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6796
7082
|
}), Object.keys(e).length && (x = e);
|
|
6797
7083
|
}
|
|
6798
7084
|
let S;
|
|
6799
|
-
o && (S =
|
|
7085
|
+
o && (S = Or({
|
|
6800
7086
|
lineFontDefaults: g,
|
|
6801
7087
|
scale: i
|
|
6802
7088
|
}));
|
|
@@ -6810,7 +7096,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6810
7096
|
topRight: Math.max(0, m.topRight * i),
|
|
6811
7097
|
bottomRight: Math.max(0, m.bottomRight * i),
|
|
6812
7098
|
bottomLeft: Math.max(0, m.bottomLeft * i)
|
|
6813
|
-
} : m, T = e.width ?? d, E = Math.abs(v - T) >
|
|
7099
|
+
} : m, T = e.width ?? d, E = Math.abs(v - T) > wr;
|
|
6814
7100
|
l && E && (e.autoExpand = !1), x && (e.styles = x), S && (e.lineFontDefaults = S), e.set({
|
|
6815
7101
|
width: v,
|
|
6816
7102
|
fontSize: o ? y : f,
|
|
@@ -6832,7 +7118,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6832
7118
|
} finally {
|
|
6833
7119
|
e.shouldRoundDimensionsOnInit = D;
|
|
6834
7120
|
}
|
|
6835
|
-
let O = u ?
|
|
7121
|
+
let O = u ? Nr({ textbox: e }) : !1;
|
|
6836
7122
|
return O && (e.dirty = !0), t.applyObjectPlacement({
|
|
6837
7123
|
object: e,
|
|
6838
7124
|
placement: a
|
|
@@ -6840,18 +7126,18 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6840
7126
|
appliedWidth: e.width ?? v,
|
|
6841
7127
|
dimensionsRounded: O
|
|
6842
7128
|
};
|
|
6843
|
-
},
|
|
7129
|
+
}, Lr = ({ transform: e }) => {
|
|
6844
7130
|
let { corner: t = "", action: n = "" } = e;
|
|
6845
7131
|
return {
|
|
6846
7132
|
isCornerHandle: t === "tl" || t === "tr" || t === "bl" || t === "br" || n === "scale",
|
|
6847
7133
|
isHorizontalHandle: t === "ml" || t === "mr" || n === "scaleX",
|
|
6848
7134
|
isVerticalHandle: t === "mt" || t === "mb" || n === "scaleY"
|
|
6849
7135
|
};
|
|
6850
|
-
},
|
|
7136
|
+
}, Rr = ({ textbox: e, transform: t, appliedWidth: n }) => {
|
|
6851
7137
|
t.scaleX = 1, t.scaleY = 1;
|
|
6852
7138
|
let { original: r } = t;
|
|
6853
7139
|
r && (r.scaleX = 1, r.scaleY = 1, r.width = n, r.height = e.height, r.left = e.left, r.top = e.top);
|
|
6854
|
-
},
|
|
7140
|
+
}, zr = ({ textbox: e, transform: t, scenePoint: n }) => {
|
|
6855
7141
|
let { x: r, y: i } = e._getTransformedDimensions();
|
|
6856
7142
|
if (r <= 0 || i <= 0) return null;
|
|
6857
7143
|
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);
|
|
@@ -6861,27 +7147,27 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6861
7147
|
stepScaleX: l,
|
|
6862
7148
|
stepScaleY: u
|
|
6863
7149
|
};
|
|
6864
|
-
},
|
|
6865
|
-
function
|
|
7150
|
+
}, Br = 1e-4;
|
|
7151
|
+
function Vr(e) {
|
|
6866
7152
|
return !!e && e instanceof _;
|
|
6867
7153
|
}
|
|
6868
|
-
function
|
|
6869
|
-
if (!
|
|
7154
|
+
function Hr(e) {
|
|
7155
|
+
if (!Vr(e)) return !1;
|
|
6870
7156
|
let t = e.group;
|
|
6871
7157
|
return e.shapeNodeType === "text" && t?.shapeComposite === !0;
|
|
6872
7158
|
}
|
|
6873
|
-
var
|
|
7159
|
+
var Ur = class {
|
|
6874
7160
|
constructor({ canvas: t, canvasManager: n, persistScaledTextbox: r }) {
|
|
6875
7161
|
this.handleMouseMove = (e) => {
|
|
6876
7162
|
let t = this.canvas._currentTransform;
|
|
6877
7163
|
if (!t) return;
|
|
6878
7164
|
let { target: n } = t;
|
|
6879
|
-
if (!
|
|
7165
|
+
if (!Vr(n) || Hr(n)) return;
|
|
6880
7166
|
let r = this.scalingState.get(n);
|
|
6881
7167
|
if (!r || !e.e) return;
|
|
6882
|
-
let { isCornerHandle: i, isHorizontalHandle: a, isVerticalHandle: o } =
|
|
7168
|
+
let { isCornerHandle: i, isHorizontalHandle: a, isVerticalHandle: o } = Lr({ transform: t });
|
|
6883
7169
|
if (!a && !o && !i) return;
|
|
6884
|
-
let s =
|
|
7170
|
+
let s = zr({
|
|
6885
7171
|
textbox: n,
|
|
6886
7172
|
transform: t,
|
|
6887
7173
|
scenePoint: this.canvas.getScenePoint(e.e)
|
|
@@ -6904,20 +7190,20 @@ var Nr = class {
|
|
|
6904
7190
|
}, j = r.lastAllowedScaleX, M = r.lastAllowedScaleY;
|
|
6905
7191
|
if (i) {
|
|
6906
7192
|
let e = Math.max(r.minimumProportionalScale, r.lastAllowedScaleX * Math.sqrt(u * d)), t = c || l ? r.minimumProportionalScale : e;
|
|
6907
|
-
if (Math.abs(t - r.lastAllowedScaleX) <=
|
|
7193
|
+
if (Math.abs(t - r.lastAllowedScaleX) <= Br) return;
|
|
6908
7194
|
j = t, M = t;
|
|
6909
7195
|
} else {
|
|
6910
7196
|
if (a) {
|
|
6911
7197
|
let e = r.lastAllowedScaleX * u, t = c ? r.minimumWidthScale : Math.max(r.minimumWidthScale, e);
|
|
6912
|
-
Math.abs(t - r.lastAllowedScaleX) >
|
|
7198
|
+
Math.abs(t - r.lastAllowedScaleX) > Br && (j = t);
|
|
6913
7199
|
}
|
|
6914
7200
|
if (o) {
|
|
6915
7201
|
let e = r.lastAllowedScaleY * d, t = l ? r.minimumFontScale : Math.max(r.minimumFontScale, e);
|
|
6916
|
-
Math.abs(t - r.lastAllowedScaleY) >
|
|
7202
|
+
Math.abs(t - r.lastAllowedScaleY) > Br && (M = t);
|
|
6917
7203
|
}
|
|
6918
|
-
if (Math.abs(j - r.lastAllowedScaleX) <=
|
|
7204
|
+
if (Math.abs(j - r.lastAllowedScaleX) <= Br && Math.abs(M - r.lastAllowedScaleY) <= Br) return;
|
|
6919
7205
|
}
|
|
6920
|
-
let { appliedWidth: N, dimensionsRounded: P } =
|
|
7206
|
+
let { appliedWidth: N, dimensionsRounded: P } = Ir({
|
|
6921
7207
|
textbox: n,
|
|
6922
7208
|
canvasManager: this.canvasManager,
|
|
6923
7209
|
base: r.startBase,
|
|
@@ -6930,7 +7216,7 @@ var Nr = class {
|
|
|
6930
7216
|
shouldDisableAutoExpandOnHorizontalChange: a,
|
|
6931
7217
|
shouldRoundDimensions: !i
|
|
6932
7218
|
});
|
|
6933
|
-
|
|
7219
|
+
Rr({
|
|
6934
7220
|
textbox: n,
|
|
6935
7221
|
transform: t,
|
|
6936
7222
|
appliedWidth: N
|
|
@@ -6951,27 +7237,27 @@ var Nr = class {
|
|
|
6951
7237
|
}), this.canvas.requestRenderAll();
|
|
6952
7238
|
}, this.handleObjectScaling = (t) => {
|
|
6953
7239
|
let { target: n, transform: r } = t;
|
|
6954
|
-
if (n instanceof e || !
|
|
7240
|
+
if (n instanceof e || !Vr(n) || Hr(n) || !r) return;
|
|
6955
7241
|
n.isScaling = !0;
|
|
6956
7242
|
let i = this._ensureScalingState({
|
|
6957
7243
|
textbox: n,
|
|
6958
7244
|
transform: r
|
|
6959
|
-
}), { startBase: a } = i, { width: o, fontSize: s } = a, { isCornerHandle: c, isHorizontalHandle: l, isVerticalHandle: u } =
|
|
7245
|
+
}), { startBase: a } = i, { width: o, fontSize: s } = a, { isCornerHandle: c, isHorizontalHandle: l, isVerticalHandle: u } = Lr({ transform: r }), d = r.corner ?? "", f = c || u;
|
|
6960
7246
|
if (!l && !u && !c) return;
|
|
6961
7247
|
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({
|
|
6962
7248
|
object: n,
|
|
6963
7249
|
originX: _,
|
|
6964
7250
|
originY: v
|
|
6965
|
-
}), { 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,
|
|
7251
|
+
}), { 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, ee = !0;
|
|
6966
7252
|
if (c) {
|
|
6967
7253
|
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;
|
|
6968
|
-
if (n || r || a) N = i.lastAllowedScaleX, P = i.lastAllowedScaleY, F = i.lastAllowedPlacement,
|
|
7254
|
+
if (n || r || a) N = i.lastAllowedScaleX, P = i.lastAllowedScaleY, F = i.lastAllowedPlacement, ee = !1;
|
|
6969
7255
|
else {
|
|
6970
7256
|
let e = Math.max(i.minimumProportionalScale, t);
|
|
6971
7257
|
N = e, P = e;
|
|
6972
7258
|
}
|
|
6973
7259
|
} else l && (N = Math.max(i.minimumWidthScale, i.lastAllowedScaleX * h)), u && (P = Math.max(i.minimumFontScale, i.lastAllowedScaleY * g));
|
|
6974
|
-
let { appliedWidth:
|
|
7260
|
+
let { appliedWidth: te, dimensionsRounded: I } = Ir({
|
|
6975
7261
|
textbox: n,
|
|
6976
7262
|
canvasManager: this.canvasManager,
|
|
6977
7263
|
base: a,
|
|
@@ -6984,14 +7270,14 @@ var Nr = class {
|
|
|
6984
7270
|
shouldDisableAutoExpandOnHorizontalChange: l,
|
|
6985
7271
|
shouldRoundDimensions: !c
|
|
6986
7272
|
});
|
|
6987
|
-
|
|
7273
|
+
Rr({
|
|
6988
7274
|
textbox: n,
|
|
6989
7275
|
transform: r,
|
|
6990
|
-
appliedWidth:
|
|
6991
|
-
}), this.canvas.requestRenderAll(),
|
|
7276
|
+
appliedWidth: te
|
|
7277
|
+
}), this.canvas.requestRenderAll(), ee && this._updateScalingStateAfterLiveCommit({
|
|
6992
7278
|
textbox: n,
|
|
6993
7279
|
state: i,
|
|
6994
|
-
appliedWidth:
|
|
7280
|
+
appliedWidth: te,
|
|
6995
7281
|
previousFontSize: O ?? s,
|
|
6996
7282
|
previousPadding: {
|
|
6997
7283
|
top: b,
|
|
@@ -7006,7 +7292,7 @@ var Nr = class {
|
|
|
7006
7292
|
bottomLeft: D
|
|
7007
7293
|
},
|
|
7008
7294
|
previousWidth: M,
|
|
7009
|
-
dimensionsRounded:
|
|
7295
|
+
dimensionsRounded: I,
|
|
7010
7296
|
isCornerHandle: c,
|
|
7011
7297
|
isHorizontalHandle: l,
|
|
7012
7298
|
isVerticalHandle: u,
|
|
@@ -7017,7 +7303,7 @@ var Nr = class {
|
|
|
7017
7303
|
let { target: n } = t;
|
|
7018
7304
|
if (n instanceof e) {
|
|
7019
7305
|
let t = n.getObjects();
|
|
7020
|
-
if (!t.some((e) =>
|
|
7306
|
+
if (!t.some((e) => Vr(e))) return;
|
|
7021
7307
|
let { scaleX: r = 1, scaleY: i = 1 } = n;
|
|
7022
7308
|
if (Math.abs(r - 1) < .01 && Math.abs(i - 1) < .01) return;
|
|
7023
7309
|
this.canvas.discardActiveObject(), t.forEach((e) => {
|
|
@@ -7027,7 +7313,7 @@ var Nr = class {
|
|
|
7027
7313
|
this.canvas.setActiveObject(a), this.canvas.requestRenderAll();
|
|
7028
7314
|
return;
|
|
7029
7315
|
}
|
|
7030
|
-
if (!
|
|
7316
|
+
if (!Vr(n) || Hr(n)) return;
|
|
7031
7317
|
n.isScaling = !1;
|
|
7032
7318
|
let r = this.scalingState.get(n);
|
|
7033
7319
|
if (this.scalingState.delete(n), !r?.hasScalingChange) return;
|
|
@@ -7052,11 +7338,11 @@ var Nr = class {
|
|
|
7052
7338
|
}, this.canvas = t, this.canvasManager = n, this.persistScaledTextbox = r, this.scalingState = /* @__PURE__ */ new WeakMap();
|
|
7053
7339
|
}
|
|
7054
7340
|
commitStandaloneTextScale({ target: e, shouldDisableAutoExpandOnHorizontalChange: t = !1 }) {
|
|
7055
|
-
if (!
|
|
7341
|
+
if (!Vr(e) || Hr(e)) return !1;
|
|
7056
7342
|
let n = Math.abs(e.scaleX ?? 1) || 1, r = Math.abs(e.scaleY ?? 1) || 1;
|
|
7057
7343
|
if (!(Math.abs(n - 1) > .01 || Math.abs(r - 1) > .01)) return !1;
|
|
7058
|
-
let i =
|
|
7059
|
-
return
|
|
7344
|
+
let i = Pr({ textbox: e }), a = this.canvasManager.getObjectPlacement({ object: e });
|
|
7345
|
+
return Ir({
|
|
7060
7346
|
textbox: e,
|
|
7061
7347
|
canvasManager: this.canvasManager,
|
|
7062
7348
|
base: i,
|
|
@@ -7072,7 +7358,7 @@ var Nr = class {
|
|
|
7072
7358
|
_ensureScalingState({ textbox: e, transform: t }) {
|
|
7073
7359
|
let n = this.scalingState.get(e);
|
|
7074
7360
|
if (!n) {
|
|
7075
|
-
let r =
|
|
7361
|
+
let r = Pr({ textbox: e }), i = Fr({ base: r }), a = t.original?.originX ?? t.originX ?? e.originX ?? "center", o = t.original?.originY ?? t.originY ?? e.originY ?? "center";
|
|
7076
7362
|
n = {
|
|
7077
7363
|
startBase: r,
|
|
7078
7364
|
startTransformCorner: typeof t.corner == "string" ? t.corner : null,
|
|
@@ -7104,7 +7390,7 @@ var Nr = class {
|
|
|
7104
7390
|
topRight: e.radiusTopRight ?? 0,
|
|
7105
7391
|
bottomRight: e.radiusBottomRight ?? 0,
|
|
7106
7392
|
bottomLeft: e.radiusBottomLeft ?? 0
|
|
7107
|
-
}, v = Math.abs(n - o) >
|
|
7393
|
+
}, v = Math.abs(n - o) > wr, y = Math.abs(h - r) > wr, 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;
|
|
7108
7394
|
if (c) {
|
|
7109
7395
|
let e = h / Math.max(1, m);
|
|
7110
7396
|
S = e, C = e;
|
|
@@ -7125,7 +7411,7 @@ var Nr = class {
|
|
|
7125
7411
|
originY: a
|
|
7126
7412
|
});
|
|
7127
7413
|
}
|
|
7128
|
-
},
|
|
7414
|
+
}, Wr = ({ textbox: e }) => {
|
|
7129
7415
|
let t = e.text ?? "";
|
|
7130
7416
|
if (!t.length) return [];
|
|
7131
7417
|
let n = t.split("\n"), r = [], i = 0;
|
|
@@ -7137,7 +7423,7 @@ var Nr = class {
|
|
|
7137
7423
|
});
|
|
7138
7424
|
}
|
|
7139
7425
|
return r;
|
|
7140
|
-
},
|
|
7426
|
+
}, Gr = ({ range: e, text: t }) => {
|
|
7141
7427
|
if (!e) return null;
|
|
7142
7428
|
let n = t.length;
|
|
7143
7429
|
if (n <= 0) return null;
|
|
@@ -7146,8 +7432,8 @@ var Nr = class {
|
|
|
7146
7432
|
start: l,
|
|
7147
7433
|
end: u
|
|
7148
7434
|
};
|
|
7149
|
-
},
|
|
7150
|
-
let n =
|
|
7435
|
+
}, Kr = ({ textbox: e, range: t }) => {
|
|
7436
|
+
let n = Wr({ textbox: e });
|
|
7151
7437
|
if (!n.length) return t;
|
|
7152
7438
|
let { start: r } = t, { end: i } = t;
|
|
7153
7439
|
for (let e = 0; e < n.length; e += 1) {
|
|
@@ -7160,7 +7446,7 @@ var Nr = class {
|
|
|
7160
7446
|
start: r,
|
|
7161
7447
|
end: i
|
|
7162
7448
|
};
|
|
7163
|
-
},
|
|
7449
|
+
}, qr = ({ textbox: e, range: t }) => {
|
|
7164
7450
|
let n = e.text ?? "";
|
|
7165
7451
|
if (!n.length) return [];
|
|
7166
7452
|
let { start: r, end: i } = t, a = n.split("\n"), o = [], s = 0;
|
|
@@ -7169,7 +7455,7 @@ var Nr = class {
|
|
|
7169
7455
|
i > n && r < c && o.push(e), s = c + 1;
|
|
7170
7456
|
}
|
|
7171
7457
|
return o;
|
|
7172
|
-
},
|
|
7458
|
+
}, Jr = ({ textbox: e, range: t }) => {
|
|
7173
7459
|
let n = e.text ?? "";
|
|
7174
7460
|
if (!n.length) return [];
|
|
7175
7461
|
let { start: r, end: i } = t, a = n.split("\n"), o = [], s = 0;
|
|
@@ -7178,20 +7464,20 @@ var Nr = class {
|
|
|
7178
7464
|
r <= n && i >= c && o.push(e), s = c + 1;
|
|
7179
7465
|
}
|
|
7180
7466
|
return o;
|
|
7181
|
-
},
|
|
7467
|
+
}, Yr = ({ previous: e, next: t }) => {
|
|
7182
7468
|
let n = Math.min(e.length, t.length);
|
|
7183
7469
|
for (let r = 0; r < n; r += 1) if (e[r] !== t[r]) return r;
|
|
7184
7470
|
return n;
|
|
7185
|
-
},
|
|
7471
|
+
}, Xr = ({ text: e, charIndex: t }) => {
|
|
7186
7472
|
let n = Math.max(0, Math.min(t, e.length)), r = 0;
|
|
7187
7473
|
for (let t = 0; t < n; t += 1) e[t] === "\n" && (r += 1);
|
|
7188
7474
|
return r;
|
|
7189
|
-
},
|
|
7475
|
+
}, Zr = ({ text: e, lineIndex: t }) => {
|
|
7190
7476
|
if (t <= 0) return 0;
|
|
7191
7477
|
let n = 0;
|
|
7192
7478
|
for (let r = 0; r < e.length; r += 1) if (e[r] === "\n" && (n += 1, n === t)) return r + 1;
|
|
7193
7479
|
return e.length;
|
|
7194
|
-
},
|
|
7480
|
+
}, Qr = class e {
|
|
7195
7481
|
constructor({ editor: t }) {
|
|
7196
7482
|
this._handleTextEditingEntered = (t) => {
|
|
7197
7483
|
this.isTextEditingActive = !0;
|
|
@@ -7204,7 +7490,7 @@ var Nr = class {
|
|
|
7204
7490
|
if (!e._isTextbox(n) || this.lineDefaultsSyncing.has(n)) return;
|
|
7205
7491
|
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 });
|
|
7206
7492
|
if (s) {
|
|
7207
|
-
let e =
|
|
7493
|
+
let e = br({ value: l });
|
|
7208
7494
|
e !== i && n.set({ text: e }), n.textCaseRaw = l;
|
|
7209
7495
|
} else n.textCaseRaw = i;
|
|
7210
7496
|
if (!r && o === void 0 && (n.autoExpand = !0), r) {
|
|
@@ -7222,7 +7508,7 @@ var Nr = class {
|
|
|
7222
7508
|
let r = e._isShapeOwnedTextbox(n);
|
|
7223
7509
|
this.editingPlacementState?.delete(n);
|
|
7224
7510
|
let i = n.text ?? "";
|
|
7225
|
-
n.uppercase ? n.textCaseRaw = n.textCaseRaw ?? i.toLocaleLowerCase() : n.textCaseRaw = i, r || (
|
|
7511
|
+
n.uppercase ? n.textCaseRaw = n.textCaseRaw ?? i.toLocaleLowerCase() : n.textCaseRaw = i, r || (Nr({ textbox: n }) && (n.setCoords(), n.dirty = !0, this.canvas.requestRenderAll()), n.locked || n.set({
|
|
7226
7512
|
lockMovementX: !1,
|
|
7227
7513
|
lockMovementY: !1
|
|
7228
7514
|
}));
|
|
@@ -7249,7 +7535,7 @@ var Nr = class {
|
|
|
7249
7535
|
transform: r,
|
|
7250
7536
|
event: i ?? null
|
|
7251
7537
|
});
|
|
7252
|
-
}, this.editor = t, this.canvas = t.canvas, this.fonts = t.options.fonts ?? [], this.scalingController = new
|
|
7538
|
+
}, this.editor = t, this.canvas = t.canvas, this.fonts = t.options.fonts ?? [], this.scalingController = new Ur({
|
|
7253
7539
|
canvas: t.canvas,
|
|
7254
7540
|
canvasManager: t.canvasManager,
|
|
7255
7541
|
persistScaledTextbox: ({ target: e, style: t }) => {
|
|
@@ -7258,15 +7544,15 @@ var Nr = class {
|
|
|
7258
7544
|
style: t
|
|
7259
7545
|
});
|
|
7260
7546
|
}
|
|
7261
|
-
}), this.editingPlacementState = /* @__PURE__ */ new WeakMap(), this.lineDefaultsSyncing = /* @__PURE__ */ new WeakSet(), this.isTextEditingActive = !1, this._bindEvents(),
|
|
7547
|
+
}), this.editingPlacementState = /* @__PURE__ */ new WeakMap(), this.lineDefaultsSyncing = /* @__PURE__ */ new WeakSet(), this.isTextEditingActive = !1, this._bindEvents(), Cr();
|
|
7262
7548
|
}
|
|
7263
7549
|
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 } = {}) {
|
|
7264
7550
|
let { canvasManager: j, historyManager: M } = this.editor, { canvas: N } = this;
|
|
7265
7551
|
M.suspendHistory();
|
|
7266
|
-
let P = i ?? this._getDefaultFontFamily(), F =
|
|
7552
|
+
let P = i ?? this._getDefaultFontFamily(), F = yr({ width: m }), ee = vr({
|
|
7267
7553
|
strokeColor: p,
|
|
7268
7554
|
width: F
|
|
7269
|
-
}),
|
|
7555
|
+
}), te = {
|
|
7270
7556
|
id: t,
|
|
7271
7557
|
fontFamily: P,
|
|
7272
7558
|
fontSize: a,
|
|
@@ -7277,7 +7563,7 @@ var Nr = class {
|
|
|
7277
7563
|
linethrough: u,
|
|
7278
7564
|
textAlign: d,
|
|
7279
7565
|
fill: f,
|
|
7280
|
-
stroke:
|
|
7566
|
+
stroke: ee,
|
|
7281
7567
|
strokeWidth: F,
|
|
7282
7568
|
strokeUniform: !0,
|
|
7283
7569
|
opacity: h,
|
|
@@ -7292,40 +7578,40 @@ var Nr = class {
|
|
|
7292
7578
|
radiusBottomRight: w,
|
|
7293
7579
|
radiusBottomLeft: T,
|
|
7294
7580
|
...E
|
|
7295
|
-
},
|
|
7296
|
-
|
|
7297
|
-
let
|
|
7298
|
-
if (
|
|
7299
|
-
let e =
|
|
7300
|
-
e !==
|
|
7301
|
-
}
|
|
7302
|
-
|
|
7303
|
-
let
|
|
7304
|
-
|
|
7305
|
-
object:
|
|
7581
|
+
}, I = new Sr(n, te), ne = r !== !1;
|
|
7582
|
+
I.autoExpand = ne;
|
|
7583
|
+
let re = E.left !== void 0 || E.top !== void 0;
|
|
7584
|
+
if (I.textCaseRaw = I.text ?? "", l) {
|
|
7585
|
+
let e = br({ value: I.textCaseRaw });
|
|
7586
|
+
e !== I.text && I.set({ text: e });
|
|
7587
|
+
}
|
|
7588
|
+
Nr({ textbox: I }) && (I.dirty = !0);
|
|
7589
|
+
let L;
|
|
7590
|
+
re && (L = j.resolveObjectPlacement({
|
|
7591
|
+
object: I,
|
|
7306
7592
|
left: E.left,
|
|
7307
7593
|
top: E.top,
|
|
7308
7594
|
originX: E.originX,
|
|
7309
7595
|
originY: E.originY,
|
|
7310
7596
|
fallbackPoint: j.getMontageAreaSceneCenter()
|
|
7311
7597
|
}));
|
|
7312
|
-
let
|
|
7313
|
-
return (
|
|
7314
|
-
textbox:
|
|
7315
|
-
placement:
|
|
7316
|
-
shouldAutoExpand:
|
|
7317
|
-
clampToMontage:
|
|
7318
|
-
}),
|
|
7319
|
-
textbox:
|
|
7598
|
+
let ie = ne && e._hasWrappedLinesBeyondExplicitBreaks(I);
|
|
7599
|
+
return (re || ie) && this._normalizeTextboxAfterContentChange({
|
|
7600
|
+
textbox: I,
|
|
7601
|
+
placement: L,
|
|
7602
|
+
shouldAutoExpand: ie,
|
|
7603
|
+
clampToMontage: re
|
|
7604
|
+
}), L || j.centerObjectToMontageArea({ object: I }), A || N.add(I), O || N.setActiveObject(I), N.requestRenderAll(), M.resumeHistory(), k || M.saveState(), N.fire("editor:text-added", {
|
|
7605
|
+
textbox: I,
|
|
7320
7606
|
options: {
|
|
7321
|
-
...
|
|
7607
|
+
...te,
|
|
7322
7608
|
text: n,
|
|
7323
7609
|
bold: o,
|
|
7324
7610
|
italic: s,
|
|
7325
7611
|
strikethrough: u,
|
|
7326
7612
|
align: d,
|
|
7327
7613
|
color: f,
|
|
7328
|
-
strokeColor:
|
|
7614
|
+
strokeColor: ee,
|
|
7329
7615
|
strokeWidth: F
|
|
7330
7616
|
},
|
|
7331
7617
|
flags: {
|
|
@@ -7333,127 +7619,127 @@ var Nr = class {
|
|
|
7333
7619
|
withoutSave: !!k,
|
|
7334
7620
|
withoutAdding: !!A
|
|
7335
7621
|
}
|
|
7336
|
-
}),
|
|
7622
|
+
}), I;
|
|
7337
7623
|
}
|
|
7338
7624
|
updateText({ target: t, style: n = {}, withoutSave: r, skipRender: i, selectionRange: a } = {}) {
|
|
7339
7625
|
let o = this._resolveTextObject(t);
|
|
7340
7626
|
if (!o) return null;
|
|
7341
7627
|
let { text: s = "" } = o, { historyManager: c } = this.editor, { canvasManager: l } = this.editor, { canvas: u } = this;
|
|
7342
7628
|
c.suspendHistory();
|
|
7343
|
-
let d = e._getSnapshot(o), { text: f, autoExpand: p, fontFamily: m, fontSize: h, bold: g, italic: _, underline: v, uppercase: y, strikethrough: b, align: x, color: S, strokeColor: C, strokeWidth: w, opacity: T, backgroundColor: E, backgroundOpacity: D, paddingTop: O, paddingRight: k, paddingBottom: A, paddingLeft: j, radiusTopLeft: M, radiusTopRight: N, radiusBottomRight: P, radiusBottomLeft: F, left:
|
|
7629
|
+
let d = e._getSnapshot(o), { text: f, autoExpand: p, fontFamily: m, fontSize: h, bold: g, italic: _, underline: v, uppercase: y, strikethrough: b, align: x, color: S, strokeColor: C, strokeWidth: w, opacity: T, backgroundColor: E, backgroundOpacity: D, paddingTop: O, paddingRight: k, paddingBottom: A, paddingLeft: j, radiusTopLeft: M, radiusTopRight: N, radiusBottomRight: P, radiusBottomLeft: F, left: ee, top: te, originX: I, originY: ne, ...re } = n, L = { ...re }, ie = l.resolveObjectPlacement({
|
|
7344
7630
|
object: o,
|
|
7345
|
-
left:
|
|
7346
|
-
top:
|
|
7347
|
-
originX:
|
|
7348
|
-
originY:
|
|
7349
|
-
}),
|
|
7631
|
+
left: ee,
|
|
7632
|
+
top: te,
|
|
7633
|
+
originX: I,
|
|
7634
|
+
originY: ne
|
|
7635
|
+
}), R = a === void 0 ? pr({ textbox: o }) : Gr({
|
|
7350
7636
|
text: s,
|
|
7351
7637
|
range: a
|
|
7352
|
-
}),
|
|
7638
|
+
}), ae = R ? Kr({
|
|
7353
7639
|
textbox: o,
|
|
7354
|
-
range:
|
|
7355
|
-
}) : null,
|
|
7640
|
+
range: R
|
|
7641
|
+
}) : null, z = {}, oe = {}, B = {}, se, ce, le = hr({
|
|
7356
7642
|
textbox: o,
|
|
7357
|
-
range:
|
|
7358
|
-
}),
|
|
7359
|
-
if (m !== void 0 && (
|
|
7643
|
+
range: R
|
|
7644
|
+
}), V = !R || le, H = !R;
|
|
7645
|
+
if (m !== void 0 && (ae && (oe.fontFamily = m), V && (L.fontFamily = m, H && (B.fontFamily = m))), h !== void 0 && (ae && (oe.fontSize = h), V && (L.fontSize = h, H && (B.fontSize = h))), g !== void 0) {
|
|
7360
7646
|
let e = g ? "bold" : "normal";
|
|
7361
|
-
|
|
7647
|
+
R && (z.fontWeight = e), V && (L.fontWeight = e, H && (B.fontWeight = e));
|
|
7362
7648
|
}
|
|
7363
7649
|
if (_ !== void 0) {
|
|
7364
7650
|
let e = _ ? "italic" : "normal";
|
|
7365
|
-
|
|
7651
|
+
R && (z.fontStyle = e), V && (L.fontStyle = e, H && (B.fontStyle = e));
|
|
7366
7652
|
}
|
|
7367
|
-
if (v !== void 0 && (
|
|
7368
|
-
let e =
|
|
7653
|
+
if (v !== void 0 && (R && (z.underline = v), V && (L.underline = v, H && (B.underline = v))), b !== void 0 && (R && (z.linethrough = b), V && (L.linethrough = b, H && (B.linethrough = b))), x !== void 0 && (L.textAlign = x), S !== void 0 && (R && (z.fill = S), V && (L.fill = S, H && (B.fill = S))), C !== void 0 || w !== void 0) {
|
|
7654
|
+
let e = R ? _r({
|
|
7369
7655
|
textbox: o,
|
|
7370
|
-
range:
|
|
7656
|
+
range: R,
|
|
7371
7657
|
property: "strokeWidth"
|
|
7372
|
-
}) : void 0, t =
|
|
7658
|
+
}) : void 0, t = R ? _r({
|
|
7373
7659
|
textbox: o,
|
|
7374
|
-
range:
|
|
7660
|
+
range: R,
|
|
7375
7661
|
property: "stroke"
|
|
7376
7662
|
}) : void 0;
|
|
7377
|
-
|
|
7663
|
+
ce = yr({ width: w ?? e ?? o.strokeWidth ?? 0 }), se = vr({
|
|
7378
7664
|
strokeColor: C ?? t ?? o.stroke ?? void 0,
|
|
7379
|
-
width:
|
|
7380
|
-
}),
|
|
7665
|
+
width: ce
|
|
7666
|
+
}), R && (z.stroke = se, z.strokeWidth = ce), V && (L.stroke = se, L.strokeWidth = ce, H && (B.stroke = se, B.strokeWidth = ce));
|
|
7381
7667
|
}
|
|
7382
|
-
T !== void 0 && (
|
|
7668
|
+
T !== void 0 && (L.opacity = T), E !== void 0 && (L.backgroundColor = E), D !== void 0 && (L.backgroundOpacity = D), O !== void 0 && (L.paddingTop = O), k !== void 0 && (L.paddingRight = k), A !== void 0 && (L.paddingBottom = A), j !== void 0 && (L.paddingLeft = j), M !== void 0 && (L.radiusTopLeft = M), N !== void 0 && (L.radiusTopRight = N), P !== void 0 && (L.radiusBottomRight = P), F !== void 0 && (L.radiusBottomLeft = F);
|
|
7383
7669
|
let ue = o.textCaseRaw ?? s, de = !!o.uppercase, fe = f !== void 0, pe = fe ? f ?? "" : ue, me = y ?? de, he = me !== de;
|
|
7384
|
-
fe || he ? (
|
|
7670
|
+
fe || he ? (L.text = me ? br({ value: pe }) : pe, o.textCaseRaw = pe) : o.textCaseRaw === void 0 && (o.textCaseRaw = ue), o.uppercase = me, o.set(L);
|
|
7385
7671
|
let ge = !1;
|
|
7386
|
-
if (
|
|
7387
|
-
let e =
|
|
7672
|
+
if (R) {
|
|
7673
|
+
let e = gr({
|
|
7388
7674
|
textbox: o,
|
|
7389
|
-
styles:
|
|
7390
|
-
range:
|
|
7391
|
-
}), t =
|
|
7675
|
+
styles: z,
|
|
7676
|
+
range: R
|
|
7677
|
+
}), t = ae ? gr({
|
|
7392
7678
|
textbox: o,
|
|
7393
|
-
styles:
|
|
7394
|
-
range:
|
|
7679
|
+
styles: oe,
|
|
7680
|
+
range: ae
|
|
7395
7681
|
}) : !1;
|
|
7396
7682
|
ge = e || t;
|
|
7397
|
-
} else if (Object.keys(
|
|
7398
|
-
let e =
|
|
7399
|
-
e && (ge =
|
|
7683
|
+
} else if (Object.keys(B).length) {
|
|
7684
|
+
let e = mr({ textbox: o });
|
|
7685
|
+
e && (ge = gr({
|
|
7400
7686
|
textbox: o,
|
|
7401
|
-
styles:
|
|
7687
|
+
styles: B,
|
|
7402
7688
|
range: e
|
|
7403
7689
|
}));
|
|
7404
7690
|
}
|
|
7405
|
-
let _e = ge &&
|
|
7406
|
-
|
|
7407
|
-
|
|
7408
|
-
|
|
7691
|
+
let _e = ge && Mr({ stylesList: [
|
|
7692
|
+
z,
|
|
7693
|
+
oe,
|
|
7694
|
+
B
|
|
7409
7695
|
] });
|
|
7410
|
-
if (ge && (o.dirty = !0),
|
|
7411
|
-
let e =
|
|
7696
|
+
if (ge && (o.dirty = !0), ae && (m !== void 0 || h !== void 0)) {
|
|
7697
|
+
let e = qr({
|
|
7412
7698
|
textbox: o,
|
|
7413
|
-
range:
|
|
7699
|
+
range: ae
|
|
7414
7700
|
}), t = {};
|
|
7415
|
-
m !== void 0 && (t.fontFamily = m), h !== void 0 && (t.fontSize = h),
|
|
7701
|
+
m !== void 0 && (t.fontFamily = m), h !== void 0 && (t.fontSize = h), Tr({
|
|
7416
7702
|
textbox: o,
|
|
7417
7703
|
lineIndices: e,
|
|
7418
7704
|
updates: t
|
|
7419
7705
|
});
|
|
7420
7706
|
}
|
|
7421
|
-
if (
|
|
7422
|
-
let e =
|
|
7707
|
+
if (R && (S !== void 0 || C !== void 0 || w !== void 0)) {
|
|
7708
|
+
let e = Jr({
|
|
7423
7709
|
textbox: o,
|
|
7424
|
-
range:
|
|
7710
|
+
range: R
|
|
7425
7711
|
}), t = {};
|
|
7426
|
-
S !== void 0 && (t.fill = S), (C !== void 0 || w !== void 0) && (
|
|
7712
|
+
S !== void 0 && (t.fill = S), (C !== void 0 || w !== void 0) && (se === null && (t.stroke = null), se != null && (t.stroke = se)), Tr({
|
|
7427
7713
|
textbox: o,
|
|
7428
7714
|
lineIndices: e,
|
|
7429
7715
|
updates: t
|
|
7430
7716
|
});
|
|
7431
7717
|
}
|
|
7432
7718
|
_e && (o.initDimensions(), o.dirty = !0), (E !== void 0 || D !== void 0 || O !== void 0 || k !== void 0 || A !== void 0 || j !== void 0 || M !== void 0 || N !== void 0 || P !== void 0 || F !== void 0) && (o.dirty = !0);
|
|
7433
|
-
let ve =
|
|
7434
|
-
|
|
7435
|
-
|
|
7436
|
-
|
|
7437
|
-
|
|
7438
|
-
] }), { autoExpand: ye } = o, be = p !== void 0, xe = Object.prototype.hasOwnProperty.call(
|
|
7719
|
+
let ve = Mr({ stylesList: [
|
|
7720
|
+
L,
|
|
7721
|
+
z,
|
|
7722
|
+
oe,
|
|
7723
|
+
B
|
|
7724
|
+
] }), { autoExpand: ye } = o, be = p !== void 0, xe = Object.prototype.hasOwnProperty.call(L, "width"), Se = (p ?? ye) !== !1;
|
|
7439
7725
|
be ? o.autoExpand = p !== !1 : ye === void 0 && (o.autoExpand = !0);
|
|
7440
7726
|
let Ce = Se && !xe && (fe || he || ve);
|
|
7441
7727
|
this._normalizeTextboxAfterContentChange({
|
|
7442
7728
|
textbox: o,
|
|
7443
|
-
placement:
|
|
7729
|
+
placement: ie,
|
|
7444
7730
|
shouldAutoExpand: Ce
|
|
7445
7731
|
}), o.setCoords();
|
|
7446
7732
|
let we = {
|
|
7447
7733
|
withoutSave: !!r,
|
|
7448
7734
|
skipRender: !!i
|
|
7449
|
-
}, Te = !!
|
|
7735
|
+
}, Te = !!R && Object.keys(z).length > 0, Ee = {
|
|
7450
7736
|
textbox: o,
|
|
7451
7737
|
target: t,
|
|
7452
7738
|
style: n,
|
|
7453
7739
|
options: we,
|
|
7454
|
-
updates:
|
|
7455
|
-
selectionRange:
|
|
7456
|
-
selectionStyles: Te ?
|
|
7740
|
+
updates: L,
|
|
7741
|
+
selectionRange: R ?? void 0,
|
|
7742
|
+
selectionStyles: Te ? z : void 0
|
|
7457
7743
|
};
|
|
7458
7744
|
u.fire("editor:before:text-updated", Ee), i || u.requestRenderAll();
|
|
7459
7745
|
let De = e._getSnapshot(o);
|
|
@@ -7512,7 +7798,7 @@ var Nr = class {
|
|
|
7512
7798
|
clampToMontage: r
|
|
7513
7799
|
}));
|
|
7514
7800
|
let a = !1;
|
|
7515
|
-
i || (a =
|
|
7801
|
+
i || (a = Nr({ textbox: e }));
|
|
7516
7802
|
let o = !1;
|
|
7517
7803
|
return !i && t && (this.editor.canvasManager.applyObjectPlacement({
|
|
7518
7804
|
object: e,
|
|
@@ -7526,15 +7812,15 @@ var Nr = class {
|
|
|
7526
7812
|
_syncLineFontDefaultsOnTextChanged({ textbox: e }) {
|
|
7527
7813
|
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;
|
|
7528
7814
|
if (h !== 0 && n && Object.keys(n).length) {
|
|
7529
|
-
let e =
|
|
7815
|
+
let e = Yr({
|
|
7530
7816
|
previous: d,
|
|
7531
7817
|
next: u
|
|
7532
|
-
}), t =
|
|
7818
|
+
}), t = Xr({
|
|
7533
7819
|
text: d,
|
|
7534
7820
|
charIndex: e
|
|
7535
7821
|
});
|
|
7536
7822
|
if (h > 0) {
|
|
7537
|
-
let r =
|
|
7823
|
+
let r = Zr({
|
|
7538
7824
|
text: d,
|
|
7539
7825
|
lineIndex: t
|
|
7540
7826
|
}), i = t + 1;
|
|
@@ -7575,7 +7861,7 @@ var Nr = class {
|
|
|
7575
7861
|
let t = p[e] ?? "", n = g ? g[e] : void 0;
|
|
7576
7862
|
if (n && (T = n), t.length !== 0) {
|
|
7577
7863
|
if (n) {
|
|
7578
|
-
let r =
|
|
7864
|
+
let r = Er({
|
|
7579
7865
|
lineText: t,
|
|
7580
7866
|
lineStyles: S ? S[e] : void 0,
|
|
7581
7867
|
lineDefaults: n
|
|
@@ -7615,16 +7901,16 @@ var Nr = class {
|
|
|
7615
7901
|
if (!Number.isFinite(f) || f <= 0) return !1;
|
|
7616
7902
|
let p = a.split("\n").length, m = !1;
|
|
7617
7903
|
Math.abs((e.width ?? 0) - f) > .01 && (e.set({ width: f }), m = !0), e.initDimensions();
|
|
7618
|
-
let { textLines: h } = e, g = Array.isArray(h) && h.length > p, _ = Math.ceil(
|
|
7904
|
+
let { textLines: h } = e, g = Array.isArray(h) && h.length > p, _ = Math.ceil(kr({
|
|
7619
7905
|
textbox: e,
|
|
7620
7906
|
text: a
|
|
7621
7907
|
})), v = Math.min(e.minWidth ?? 1, f), y = Math.min(f, Math.max(_, v));
|
|
7622
|
-
g && (y = f), Math.abs((e.width ?? 0) - y) > .01 && (e.set({ width: y }), e.initDimensions(), m = !0),
|
|
7908
|
+
g && (y = f), Math.abs((e.width ?? 0) - y) > .01 && (e.set({ width: y }), e.initDimensions(), m = !0), Nr({ textbox: e }) && (m = !0), t && r.applyObjectPlacement({
|
|
7623
7909
|
object: e,
|
|
7624
7910
|
placement: t
|
|
7625
7911
|
});
|
|
7626
7912
|
let b = !1;
|
|
7627
|
-
return n && (b =
|
|
7913
|
+
return n && (b = Ar({
|
|
7628
7914
|
textbox: e,
|
|
7629
7915
|
montageLeft: o,
|
|
7630
7916
|
montageRight: o + s
|
|
@@ -7682,7 +7968,7 @@ var Nr = class {
|
|
|
7682
7968
|
_getDefaultFontFamily() {
|
|
7683
7969
|
return this.fonts[0]?.family ?? "Arial";
|
|
7684
7970
|
}
|
|
7685
|
-
},
|
|
7971
|
+
}, $r = ({ x1: e, y1: t, x2: n, y2: r }) => (Math.atan2(r - t, n - e) * 180 / Math.PI + 360) % 360, ei = (e) => {
|
|
7686
7972
|
if (!e || typeof e != "object") return null;
|
|
7687
7973
|
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) => ({
|
|
7688
7974
|
color: typeof e.color == "string" ? e.color : "#000000",
|
|
@@ -7693,7 +7979,7 @@ var Nr = class {
|
|
|
7693
7979
|
let { x1: e, y1: t, x2: r, y2: i } = n;
|
|
7694
7980
|
if (typeof e == "number" && typeof t == "number" && typeof r == "number" && typeof i == "number") return {
|
|
7695
7981
|
type: "linear",
|
|
7696
|
-
angle:
|
|
7982
|
+
angle: $r({
|
|
7697
7983
|
x1: e,
|
|
7698
7984
|
y1: t,
|
|
7699
7985
|
x2: r,
|
|
@@ -7721,7 +8007,7 @@ var Nr = class {
|
|
|
7721
8007
|
};
|
|
7722
8008
|
}
|
|
7723
8009
|
return null;
|
|
7724
|
-
},
|
|
8010
|
+
}, ti = "_templateAnchorX", ni = "_templateAnchorY", ri = class t {
|
|
7725
8011
|
constructor({ editor: e }) {
|
|
7726
8012
|
this.editor = e;
|
|
7727
8013
|
}
|
|
@@ -7730,7 +8016,7 @@ var Nr = class {
|
|
|
7730
8016
|
if (!p.length) return s.emitWarning({
|
|
7731
8017
|
origin: "TemplateManager",
|
|
7732
8018
|
method: "serializeSelection",
|
|
7733
|
-
code:
|
|
8019
|
+
code: ur.TEMPLATE_MANAGER.NO_OBJECTS_SELECTED,
|
|
7734
8020
|
message: "Нет объектов для сериализации шаблона"
|
|
7735
8021
|
}), null;
|
|
7736
8022
|
let m = t._getBounds(o), h = t._getMontageSize({
|
|
@@ -7759,14 +8045,14 @@ var Nr = class {
|
|
|
7759
8045
|
if (!s?.length) return a.emitWarning({
|
|
7760
8046
|
origin: "TemplateManager",
|
|
7761
8047
|
method: "applyTemplate",
|
|
7762
|
-
code:
|
|
8048
|
+
code: ur.TEMPLATE_MANAGER.INVALID_TEMPLATE,
|
|
7763
8049
|
message: "Шаблон не содержит объектов"
|
|
7764
8050
|
}), null;
|
|
7765
8051
|
let u = t._getBounds(r);
|
|
7766
8052
|
if (!u) return a.emitWarning({
|
|
7767
8053
|
origin: "TemplateManager",
|
|
7768
8054
|
method: "applyTemplate",
|
|
7769
|
-
code:
|
|
8055
|
+
code: ur.TEMPLATE_MANAGER.INVALID_TARGET,
|
|
7770
8056
|
message: "Не удалось определить границы монтажной области"
|
|
7771
8057
|
}), null;
|
|
7772
8058
|
let d = t._getMontageSize({
|
|
@@ -7785,7 +8071,7 @@ var Nr = class {
|
|
|
7785
8071
|
if (!r.length) return a.emitWarning({
|
|
7786
8072
|
origin: "TemplateManager",
|
|
7787
8073
|
method: "applyTemplate",
|
|
7788
|
-
code:
|
|
8074
|
+
code: ur.TEMPLATE_MANAGER.INVALID_TEMPLATE,
|
|
7789
8075
|
message: "Не удалось создать объекты шаблона"
|
|
7790
8076
|
}), null;
|
|
7791
8077
|
let { backgroundObject: i, contentObjects: c } = t._extractBackgroundObject(r);
|
|
@@ -7820,7 +8106,7 @@ var Nr = class {
|
|
|
7820
8106
|
return a.emitError({
|
|
7821
8107
|
origin: "TemplateManager",
|
|
7822
8108
|
method: "applyTemplate",
|
|
7823
|
-
code:
|
|
8109
|
+
code: ur.TEMPLATE_MANAGER.APPLY_FAILED,
|
|
7824
8110
|
message: "Ошибка применения шаблона",
|
|
7825
8111
|
data: {
|
|
7826
8112
|
templateId: l,
|
|
@@ -7974,8 +8260,8 @@ var Nr = class {
|
|
|
7974
8260
|
baseHeight: a,
|
|
7975
8261
|
scale: n,
|
|
7976
8262
|
useRelativePositions: o,
|
|
7977
|
-
anchorX: t._resolveAnchor(s,
|
|
7978
|
-
anchorY: t._resolveAnchor(s,
|
|
8263
|
+
anchorX: t._resolveAnchor(s, ti),
|
|
8264
|
+
anchorY: t._resolveAnchor(s, ni)
|
|
7979
8265
|
})
|
|
7980
8266
|
}), h = f * n, g = p * n, _ = e.originX ?? "center", v = e.originY ?? "center";
|
|
7981
8267
|
e.set({
|
|
@@ -7989,7 +8275,7 @@ var Nr = class {
|
|
|
7989
8275
|
originX: _,
|
|
7990
8276
|
originY: v
|
|
7991
8277
|
}
|
|
7992
|
-
}), delete s[
|
|
8278
|
+
}), delete s[ti], delete s[ni];
|
|
7993
8279
|
}
|
|
7994
8280
|
static _getPositioningBounds({ bounds: e, baseWidth: n, baseHeight: r, scale: i, useRelativePositions: a, anchorX: o, anchorY: s }) {
|
|
7995
8281
|
if (!a) return e;
|
|
@@ -8053,7 +8339,7 @@ var Nr = class {
|
|
|
8053
8339
|
});
|
|
8054
8340
|
if (!i || !s || !o) return;
|
|
8055
8341
|
e.setCoords();
|
|
8056
|
-
let c = e, l = t._resolveAnchor(c,
|
|
8342
|
+
let c = e, l = t._resolveAnchor(c, ti), 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;
|
|
8057
8343
|
e.set("width", i), e.initDimensions();
|
|
8058
8344
|
let g = t._getLongestLineWidth({
|
|
8059
8345
|
textbox: e,
|
|
@@ -8072,7 +8358,7 @@ var Nr = class {
|
|
|
8072
8358
|
return i;
|
|
8073
8359
|
}
|
|
8074
8360
|
_serializeObject({ object: e, bounds: n, baseWidth: r, baseHeight: i }) {
|
|
8075
|
-
let a = e.toDatalessObject([...
|
|
8361
|
+
let a = e.toDatalessObject([...le]);
|
|
8076
8362
|
if (t._isSvgObject(e)) {
|
|
8077
8363
|
let n = t._extractSvgMarkup(e);
|
|
8078
8364
|
n && (a.svgMarkup = n, delete a.objects, delete a.path);
|
|
@@ -8082,10 +8368,10 @@ var Nr = class {
|
|
|
8082
8368
|
x: (p.left - o) / d,
|
|
8083
8369
|
y: (p.top - s) / f
|
|
8084
8370
|
}, h = (u.left - o) / d, g = (u.top - s) / f, _ = h + u.width / d, v = g + u.height / f;
|
|
8085
|
-
return a[
|
|
8371
|
+
return a[ti] = t._detectAnchor({
|
|
8086
8372
|
start: h,
|
|
8087
8373
|
end: _
|
|
8088
|
-
}), a[
|
|
8374
|
+
}), a[ni] = t._detectAnchor({
|
|
8089
8375
|
start: g,
|
|
8090
8376
|
end: v
|
|
8091
8377
|
}), a.left = m.x, a.top = m.y, a;
|
|
@@ -8110,7 +8396,7 @@ var Nr = class {
|
|
|
8110
8396
|
withoutSave: !0
|
|
8111
8397
|
}), !0;
|
|
8112
8398
|
if (a === "gradient") {
|
|
8113
|
-
let e =
|
|
8399
|
+
let e = ei(r);
|
|
8114
8400
|
if (e) return n.setGradientBackground({
|
|
8115
8401
|
gradient: e,
|
|
8116
8402
|
customData: o,
|
|
@@ -8131,7 +8417,7 @@ var Nr = class {
|
|
|
8131
8417
|
r.emitWarning({
|
|
8132
8418
|
origin: "TemplateManager",
|
|
8133
8419
|
method: "applyTemplate",
|
|
8134
|
-
code:
|
|
8420
|
+
code: ur.TEMPLATE_MANAGER.APPLY_FAILED,
|
|
8135
8421
|
message: "Не удалось применить фон из шаблона",
|
|
8136
8422
|
data: e
|
|
8137
8423
|
});
|
|
@@ -8167,29 +8453,29 @@ var Nr = class {
|
|
|
8167
8453
|
enlivenObjectEnlivables(e) {
|
|
8168
8454
|
return C.enlivenObjectEnlivables(e);
|
|
8169
8455
|
}
|
|
8170
|
-
},
|
|
8171
|
-
let n =
|
|
8456
|
+
}, ii = "#3D8BF4", ai = .5, oi = ({ distance: e }) => Number.isFinite(e) ? Math.round(Math.max(0, e)) : 0, si = ({ firstDistance: e, secondDistance: t }) => {
|
|
8457
|
+
let n = oi({ distance: e }), r = oi({ distance: t });
|
|
8172
8458
|
return {
|
|
8173
8459
|
firstDisplayDistance: n,
|
|
8174
8460
|
secondDisplayDistance: r,
|
|
8175
8461
|
displayDistanceDiff: Math.abs(n - r),
|
|
8176
8462
|
commonDisplayDistance: Math.max(n, r)
|
|
8177
8463
|
};
|
|
8178
|
-
},
|
|
8464
|
+
}, ci = ({ firstStart: e, firstEnd: t, secondStart: n, secondEnd: r }) => Math.min(t, r) - Math.max(e, n), li = ({ step: e }) => {
|
|
8179
8465
|
let t = Math.abs(e).toString(), n = t.indexOf(".");
|
|
8180
8466
|
return n === -1 ? 0 : t.slice(n + 1).length;
|
|
8181
|
-
},
|
|
8467
|
+
}, ui = ({ value: e, step: t }) => {
|
|
8182
8468
|
if (t === 0) return e;
|
|
8183
|
-
let n =
|
|
8469
|
+
let n = li({ step: t }), r = Math.round(e / t) * t;
|
|
8184
8470
|
return Number(r.toFixed(n));
|
|
8185
|
-
},
|
|
8471
|
+
}, di = ({ value: e, step: t }) => {
|
|
8186
8472
|
if (t === 0) return !0;
|
|
8187
|
-
let n =
|
|
8473
|
+
let n = ui({
|
|
8188
8474
|
value: e,
|
|
8189
8475
|
step: t
|
|
8190
|
-
}), r = 10 ** -(
|
|
8476
|
+
}), r = 10 ** -(li({ step: t }) + 4);
|
|
8191
8477
|
return Math.abs(n - e) <= r;
|
|
8192
|
-
},
|
|
8478
|
+
}, fi = ({ bounds: e, axis: t }) => {
|
|
8193
8479
|
let { left: n = 0, right: r = 0, top: i = 0, bottom: a = 0 } = e;
|
|
8194
8480
|
return t === "vertical" ? {
|
|
8195
8481
|
start: i,
|
|
@@ -8198,7 +8484,7 @@ var Nr = class {
|
|
|
8198
8484
|
start: n,
|
|
8199
8485
|
end: r
|
|
8200
8486
|
};
|
|
8201
|
-
},
|
|
8487
|
+
}, pi = ({ items: e, axis: t }) => {
|
|
8202
8488
|
for (let n = 1; n < e.length; n += 1) {
|
|
8203
8489
|
let r = e[n], { bounds: i } = r, a = i[t], o = n - 1;
|
|
8204
8490
|
for (; o >= 0;) {
|
|
@@ -8208,10 +8494,10 @@ var Nr = class {
|
|
|
8208
8494
|
}
|
|
8209
8495
|
e[o + 1] = r;
|
|
8210
8496
|
}
|
|
8211
|
-
},
|
|
8497
|
+
}, mi = ({ items: e, index: t, axis: n, direction: r }) => {
|
|
8212
8498
|
let i = e[t];
|
|
8213
8499
|
if (!i) return null;
|
|
8214
|
-
let { bounds: a } = i, { start: o, end: s } =
|
|
8500
|
+
let { bounds: a } = i, { start: o, end: s } = fi({
|
|
8215
8501
|
bounds: a,
|
|
8216
8502
|
axis: n
|
|
8217
8503
|
});
|
|
@@ -8219,7 +8505,7 @@ var Nr = class {
|
|
|
8219
8505
|
for (let r = t - 1; r >= 0; --r) {
|
|
8220
8506
|
let t = e[r];
|
|
8221
8507
|
if (!t) continue;
|
|
8222
|
-
let { bounds: i } = t, { end: a } =
|
|
8508
|
+
let { bounds: i } = t, { end: a } = fi({
|
|
8223
8509
|
bounds: i,
|
|
8224
8510
|
axis: n
|
|
8225
8511
|
});
|
|
@@ -8230,26 +8516,26 @@ var Nr = class {
|
|
|
8230
8516
|
for (let r = t + 1; r < e.length; r += 1) {
|
|
8231
8517
|
let t = e[r];
|
|
8232
8518
|
if (!t) continue;
|
|
8233
|
-
let { bounds: i } = t, { start: a } =
|
|
8519
|
+
let { bounds: i } = t, { start: a } = fi({
|
|
8234
8520
|
bounds: i,
|
|
8235
8521
|
axis: n
|
|
8236
8522
|
});
|
|
8237
8523
|
if (a - s >= 0) return r;
|
|
8238
8524
|
}
|
|
8239
8525
|
return null;
|
|
8240
|
-
},
|
|
8526
|
+
}, hi = ({ items: e }) => {
|
|
8241
8527
|
for (let t = 0; t < e.length; t += 1) {
|
|
8242
8528
|
let { isActive: n } = e[t];
|
|
8243
8529
|
if (n) return t;
|
|
8244
8530
|
}
|
|
8245
8531
|
return -1;
|
|
8246
|
-
},
|
|
8532
|
+
}, gi = ({ patternAxis: e, activeRangeStart: t, activeRangeEnd: n, tolerance: r = 0 }) => {
|
|
8247
8533
|
let i = Math.min(t, n), a = Math.max(t, n);
|
|
8248
8534
|
return e >= i - r && e <= a + r;
|
|
8249
|
-
},
|
|
8535
|
+
}, _i = ({ patternStart: e, patternEnd: t, activeStart: n, activeEnd: r }) => t <= n ? "before" : e >= r ? "after" : null, vi = ({ baseOption: e, candidateOption: t }) => {
|
|
8250
8536
|
let { delta: n, guide: { distance: r } } = e, { delta: i, guide: { distance: a } } = t;
|
|
8251
8537
|
return n === i && r === a;
|
|
8252
|
-
},
|
|
8538
|
+
}, yi = ({ options: e }) => {
|
|
8253
8539
|
let t = e[0];
|
|
8254
8540
|
for (let n = 1; n < e.length; n += 1) {
|
|
8255
8541
|
let r = e[n];
|
|
@@ -8260,11 +8546,11 @@ var Nr = class {
|
|
|
8260
8546
|
r.diff === t.diff && Math.abs(r.delta) < Math.abs(t.delta) && (t = r);
|
|
8261
8547
|
}
|
|
8262
8548
|
return t;
|
|
8263
|
-
},
|
|
8549
|
+
}, bi = ({ currentOption: e, nextOption: t }) => {
|
|
8264
8550
|
if (!e) return !0;
|
|
8265
8551
|
let { contextDistance: n, diff: r, delta: i } = e, { contextDistance: a, diff: o, delta: s } = t;
|
|
8266
8552
|
return a < n ? !0 : a > n ? !1 : o < r ? !0 : o > r ? !1 : Math.abs(s) < Math.abs(i);
|
|
8267
|
-
},
|
|
8553
|
+
}, xi = ({ options: e }) => {
|
|
8268
8554
|
let t = [], n = null, r = null;
|
|
8269
8555
|
for (let i of e) {
|
|
8270
8556
|
let { kind: e, side: a } = i;
|
|
@@ -8272,18 +8558,18 @@ var Nr = class {
|
|
|
8272
8558
|
t.push(i);
|
|
8273
8559
|
continue;
|
|
8274
8560
|
}
|
|
8275
|
-
a === "before" &&
|
|
8561
|
+
a === "before" && bi({
|
|
8276
8562
|
currentOption: n,
|
|
8277
8563
|
nextOption: i
|
|
8278
|
-
}) && (n = i), a === "after" &&
|
|
8564
|
+
}) && (n = i), a === "after" && bi({
|
|
8279
8565
|
currentOption: r,
|
|
8280
8566
|
nextOption: i
|
|
8281
8567
|
}) && (r = i);
|
|
8282
8568
|
}
|
|
8283
8569
|
return n && t.push(n), r && t.push(r), t;
|
|
8284
|
-
},
|
|
8570
|
+
}, Si = ({ options: e, side: t, baseOption: n }) => {
|
|
8285
8571
|
let r = null;
|
|
8286
|
-
for (let i of e) if (i.side === t &&
|
|
8572
|
+
for (let i of e) if (i.side === t && vi({
|
|
8287
8573
|
baseOption: n,
|
|
8288
8574
|
candidateOption: i
|
|
8289
8575
|
})) {
|
|
@@ -8294,63 +8580,63 @@ var Nr = class {
|
|
|
8294
8580
|
!r || i.diff !== r.diff || Math.abs(i.delta) < Math.abs(r.delta) && (r = i);
|
|
8295
8581
|
}
|
|
8296
8582
|
return r;
|
|
8297
|
-
},
|
|
8583
|
+
}, Ci = ({ option: e }) => {
|
|
8298
8584
|
let { side: t, kind: n, guide: { distance: r } } = e;
|
|
8299
8585
|
return {
|
|
8300
8586
|
side: t,
|
|
8301
8587
|
kind: n,
|
|
8302
8588
|
distance: r
|
|
8303
8589
|
};
|
|
8304
|
-
},
|
|
8590
|
+
}, wi = ({ option: e, context: t }) => {
|
|
8305
8591
|
let { side: n, kind: r, distance: i } = t, { side: a, kind: o, guide: { distance: s } } = e;
|
|
8306
8592
|
return n !== a || r !== o ? !1 : Math.abs(s - i) <= 1;
|
|
8307
|
-
},
|
|
8593
|
+
}, Ti = ({ options: e, context: t }) => {
|
|
8308
8594
|
if (!t) return null;
|
|
8309
|
-
for (let n of e) if (
|
|
8595
|
+
for (let n of e) if (wi({
|
|
8310
8596
|
option: n,
|
|
8311
8597
|
context: t
|
|
8312
8598
|
})) return n;
|
|
8313
8599
|
return null;
|
|
8314
|
-
},
|
|
8315
|
-
let i =
|
|
8600
|
+
}, Ei = ({ options: e, bestOption: t, previousContext: n, switchDistance: r = 0 }) => {
|
|
8601
|
+
let i = Ti({
|
|
8316
8602
|
options: e,
|
|
8317
8603
|
context: n
|
|
8318
8604
|
});
|
|
8319
8605
|
if (!i) return t;
|
|
8320
8606
|
let a = Math.max(0, r);
|
|
8321
8607
|
return a === 0 || Math.abs(t.delta - i.delta) >= a ? t : i;
|
|
8322
|
-
},
|
|
8608
|
+
}, Di = ({ guides: e, seenGuideKeys: t, guide: n }) => {
|
|
8323
8609
|
let { type: r, axis: i, refStart: a, refEnd: o, activeStart: s, activeEnd: c, distance: l } = n, u = `${r}:${i}:${a}:${o}:${s}:${c}:${l}`;
|
|
8324
8610
|
t.has(u) || (t.add(u), e.push(n));
|
|
8325
|
-
},
|
|
8611
|
+
}, Oi = ({ options: e, previousContext: t = null, switchDistance: n = 0 }) => {
|
|
8326
8612
|
if (!e.length) return {
|
|
8327
8613
|
delta: 0,
|
|
8328
8614
|
guides: [],
|
|
8329
8615
|
context: null
|
|
8330
8616
|
};
|
|
8331
|
-
let r =
|
|
8617
|
+
let r = xi({ options: e }), i = [];
|
|
8332
8618
|
for (let e of r) e.kind === "reference" && i.push(e);
|
|
8333
|
-
let a = i.length > 0, o = a ? i : r, s =
|
|
8619
|
+
let a = i.length > 0, o = a ? i : r, s = Ei({
|
|
8334
8620
|
options: o,
|
|
8335
|
-
bestOption:
|
|
8621
|
+
bestOption: yi({ options: o }),
|
|
8336
8622
|
previousContext: t,
|
|
8337
8623
|
switchDistance: n
|
|
8338
|
-
}), c =
|
|
8624
|
+
}), c = Si({
|
|
8339
8625
|
options: o,
|
|
8340
8626
|
side: "before",
|
|
8341
8627
|
baseOption: s
|
|
8342
|
-
}), l =
|
|
8628
|
+
}), l = Si({
|
|
8343
8629
|
options: o,
|
|
8344
8630
|
side: "after",
|
|
8345
8631
|
baseOption: s
|
|
8346
|
-
}), u =
|
|
8632
|
+
}), u = Si({
|
|
8347
8633
|
options: a ? r : o,
|
|
8348
8634
|
side: "center",
|
|
8349
8635
|
baseOption: s
|
|
8350
8636
|
}), d = [];
|
|
8351
8637
|
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);
|
|
8352
8638
|
let f = [], p = /* @__PURE__ */ new Set();
|
|
8353
|
-
for (let e of d)
|
|
8639
|
+
for (let e of d) Di({
|
|
8354
8640
|
guides: f,
|
|
8355
8641
|
seenGuideKeys: p,
|
|
8356
8642
|
guide: e.guide
|
|
@@ -8358,15 +8644,15 @@ var Nr = class {
|
|
|
8358
8644
|
return {
|
|
8359
8645
|
delta: s.delta,
|
|
8360
8646
|
guides: f,
|
|
8361
|
-
context:
|
|
8647
|
+
context: Ci({ option: s })
|
|
8362
8648
|
};
|
|
8363
|
-
},
|
|
8364
|
-
let s = n - (e - r), c =
|
|
8649
|
+
}, ki = ({ activeStart: e, activeEnd: t, targetGap: n, beforeEdge: r, afterEdge: i, threshold: a, step: o }) => {
|
|
8650
|
+
let s = n - (e - r), c = ui({
|
|
8365
8651
|
value: s,
|
|
8366
8652
|
step: o
|
|
8367
8653
|
}), l = Math.max(1, Math.ceil(a / Math.max(o, 1))), u = null;
|
|
8368
8654
|
for (let d = -l; d <= l; d += 1) {
|
|
8369
|
-
let l = c + d * o, f = e + l, p = t + l, m = f - r, h = i - p, { displayDistanceDiff: g, commonDisplayDistance: _ } =
|
|
8655
|
+
let l = c + d * o, f = e + l, p = t + l, m = f - r, h = i - p, { displayDistanceDiff: g, commonDisplayDistance: _ } = si({
|
|
8370
8656
|
firstDistance: m,
|
|
8371
8657
|
secondDistance: h
|
|
8372
8658
|
});
|
|
@@ -8381,13 +8667,13 @@ var Nr = class {
|
|
|
8381
8667
|
});
|
|
8382
8668
|
}
|
|
8383
8669
|
return u;
|
|
8384
|
-
},
|
|
8385
|
-
let { secondDisplayDistance: n, displayDistanceDiff: r } =
|
|
8670
|
+
}, Ai = ({ currentGap: e, referenceGap: t }) => {
|
|
8671
|
+
let { secondDisplayDistance: n, displayDistanceDiff: r } = si({
|
|
8386
8672
|
firstDistance: e,
|
|
8387
8673
|
secondDistance: t
|
|
8388
8674
|
});
|
|
8389
8675
|
return r > 1 ? null : n;
|
|
8390
|
-
},
|
|
8676
|
+
}, ji = ({ anchors: e, positions: t, threshold: n }) => {
|
|
8391
8677
|
let r = 0, i = n + 1, a = null;
|
|
8392
8678
|
for (let o of t) for (let t of e) {
|
|
8393
8679
|
let e = Math.abs(t - o);
|
|
@@ -8397,8 +8683,8 @@ var Nr = class {
|
|
|
8397
8683
|
delta: r,
|
|
8398
8684
|
guidePosition: a
|
|
8399
8685
|
};
|
|
8400
|
-
},
|
|
8401
|
-
let { left: r, right: i, centerX: a, top: o, bottom: s, centerY: c } = e, l =
|
|
8686
|
+
}, Mi = ({ activeBounds: e, threshold: t, anchors: n }) => {
|
|
8687
|
+
let { left: r, right: i, centerX: a, top: o, bottom: s, centerY: c } = e, l = ji({
|
|
8402
8688
|
anchors: n.vertical,
|
|
8403
8689
|
positions: [
|
|
8404
8690
|
r,
|
|
@@ -8406,7 +8692,7 @@ var Nr = class {
|
|
|
8406
8692
|
i
|
|
8407
8693
|
],
|
|
8408
8694
|
threshold: t
|
|
8409
|
-
}), u =
|
|
8695
|
+
}), u = ji({
|
|
8410
8696
|
anchors: n.horizontal,
|
|
8411
8697
|
positions: [
|
|
8412
8698
|
o,
|
|
@@ -8426,11 +8712,11 @@ var Nr = class {
|
|
|
8426
8712
|
deltaY: u.delta,
|
|
8427
8713
|
guides: d
|
|
8428
8714
|
};
|
|
8429
|
-
},
|
|
8715
|
+
}, Ni = ({ activeBounds: e, candidates: t, threshold: n, patterns: r, previousContext: i = null, switchDistance: a = 0 }) => {
|
|
8430
8716
|
let { centerX: o, top: s, bottom: c, left: l, right: u } = e, d = [];
|
|
8431
8717
|
for (let e of t) {
|
|
8432
8718
|
let { left: t, right: n } = e;
|
|
8433
|
-
|
|
8719
|
+
ci({
|
|
8434
8720
|
firstStart: t,
|
|
8435
8721
|
firstEnd: n,
|
|
8436
8722
|
secondStart: l,
|
|
@@ -8450,22 +8736,22 @@ var Nr = class {
|
|
|
8450
8736
|
f.push({
|
|
8451
8737
|
bounds: e,
|
|
8452
8738
|
isActive: !0
|
|
8453
|
-
}),
|
|
8739
|
+
}), pi({
|
|
8454
8740
|
items: f,
|
|
8455
8741
|
axis: "top"
|
|
8456
8742
|
});
|
|
8457
|
-
let p =
|
|
8743
|
+
let p = hi({ items: f });
|
|
8458
8744
|
if (p === -1) return {
|
|
8459
8745
|
delta: 0,
|
|
8460
8746
|
guides: [],
|
|
8461
8747
|
context: null
|
|
8462
8748
|
};
|
|
8463
|
-
let m = [], h = c - s, g =
|
|
8749
|
+
let m = [], h = c - s, g = mi({
|
|
8464
8750
|
items: f,
|
|
8465
8751
|
index: p,
|
|
8466
8752
|
axis: "vertical",
|
|
8467
8753
|
direction: "prev"
|
|
8468
|
-
}), _ =
|
|
8754
|
+
}), _ = mi({
|
|
8469
8755
|
items: f,
|
|
8470
8756
|
index: p,
|
|
8471
8757
|
axis: "vertical",
|
|
@@ -8474,19 +8760,19 @@ var Nr = class {
|
|
|
8474
8760
|
if (v && y) {
|
|
8475
8761
|
let { bounds: e } = v, { bounds: t } = y, { bottom: r } = e, { top: i } = t, a = i - r - h;
|
|
8476
8762
|
if (a >= 0) {
|
|
8477
|
-
let e =
|
|
8763
|
+
let e = ui({
|
|
8478
8764
|
value: a / 2,
|
|
8479
8765
|
step: 1
|
|
8480
8766
|
}), t = s - r, l = i - c, u = Math.abs(t - e), d = Math.abs(l - e);
|
|
8481
8767
|
if (Math.max(u, d) <= n) {
|
|
8482
|
-
let t =
|
|
8768
|
+
let t = ki({
|
|
8483
8769
|
activeStart: s,
|
|
8484
8770
|
activeEnd: c,
|
|
8485
8771
|
targetGap: e,
|
|
8486
8772
|
beforeEdge: r,
|
|
8487
8773
|
afterEdge: i,
|
|
8488
8774
|
threshold: n,
|
|
8489
|
-
step:
|
|
8775
|
+
step: ai
|
|
8490
8776
|
});
|
|
8491
8777
|
if (t) {
|
|
8492
8778
|
let { delta: e, distance: n, diff: i, activeStart: a, activeEnd: s } = t, c = {
|
|
@@ -8523,16 +8809,16 @@ var Nr = class {
|
|
|
8523
8809
|
}
|
|
8524
8810
|
for (let e of r) {
|
|
8525
8811
|
let { axis: t, start: r, end: i, distance: a } = e;
|
|
8526
|
-
if (!
|
|
8812
|
+
if (!di({
|
|
8527
8813
|
value: a,
|
|
8528
8814
|
step: .5
|
|
8529
|
-
}) || !
|
|
8815
|
+
}) || !gi({
|
|
8530
8816
|
patternAxis: t,
|
|
8531
8817
|
activeRangeStart: l,
|
|
8532
8818
|
activeRangeEnd: u,
|
|
8533
8819
|
tolerance: n
|
|
8534
8820
|
})) continue;
|
|
8535
|
-
let d =
|
|
8821
|
+
let d = _i({
|
|
8536
8822
|
patternStart: r,
|
|
8537
8823
|
patternEnd: i,
|
|
8538
8824
|
activeStart: s,
|
|
@@ -8540,12 +8826,12 @@ var Nr = class {
|
|
|
8540
8826
|
});
|
|
8541
8827
|
if (d) {
|
|
8542
8828
|
if (b !== null && S && d === "before" && Math.abs(b - a) <= n) {
|
|
8543
|
-
let e =
|
|
8829
|
+
let e = ui({
|
|
8544
8830
|
value: a - b,
|
|
8545
8831
|
step: 1
|
|
8546
8832
|
}), t = s + e, { bottom: c } = S, l = t - c, u = Math.abs(l - a);
|
|
8547
8833
|
if (u > n) continue;
|
|
8548
|
-
let d =
|
|
8834
|
+
let d = Ai({
|
|
8549
8835
|
currentGap: l,
|
|
8550
8836
|
referenceGap: a
|
|
8551
8837
|
});
|
|
@@ -8569,12 +8855,12 @@ var Nr = class {
|
|
|
8569
8855
|
});
|
|
8570
8856
|
}
|
|
8571
8857
|
if (x !== null && C && d === "after" && Math.abs(x - a) <= n) {
|
|
8572
|
-
let e =
|
|
8858
|
+
let e = ui({
|
|
8573
8859
|
value: x - a,
|
|
8574
8860
|
step: 1
|
|
8575
8861
|
}), t = c + e, { top: s } = C, l = s - t, u = Math.abs(l - a);
|
|
8576
8862
|
if (u > n) continue;
|
|
8577
|
-
let d =
|
|
8863
|
+
let d = Ai({
|
|
8578
8864
|
currentGap: l,
|
|
8579
8865
|
referenceGap: a
|
|
8580
8866
|
});
|
|
@@ -8599,16 +8885,16 @@ var Nr = class {
|
|
|
8599
8885
|
}
|
|
8600
8886
|
}
|
|
8601
8887
|
}
|
|
8602
|
-
return
|
|
8888
|
+
return Oi({
|
|
8603
8889
|
options: m,
|
|
8604
8890
|
previousContext: i,
|
|
8605
8891
|
switchDistance: a
|
|
8606
8892
|
});
|
|
8607
|
-
},
|
|
8893
|
+
}, Pi = ({ activeBounds: e, candidates: t, threshold: n, patterns: r, previousContext: i = null, switchDistance: a = 0 }) => {
|
|
8608
8894
|
let { centerY: o, left: s, right: c, top: l, bottom: u } = e, d = [];
|
|
8609
8895
|
for (let e of t) {
|
|
8610
8896
|
let { top: t, bottom: n } = e;
|
|
8611
|
-
|
|
8897
|
+
ci({
|
|
8612
8898
|
firstStart: t,
|
|
8613
8899
|
firstEnd: n,
|
|
8614
8900
|
secondStart: l,
|
|
@@ -8628,22 +8914,22 @@ var Nr = class {
|
|
|
8628
8914
|
f.push({
|
|
8629
8915
|
bounds: e,
|
|
8630
8916
|
isActive: !0
|
|
8631
|
-
}),
|
|
8917
|
+
}), pi({
|
|
8632
8918
|
items: f,
|
|
8633
8919
|
axis: "left"
|
|
8634
8920
|
});
|
|
8635
|
-
let p =
|
|
8921
|
+
let p = hi({ items: f });
|
|
8636
8922
|
if (p === -1) return {
|
|
8637
8923
|
delta: 0,
|
|
8638
8924
|
guides: [],
|
|
8639
8925
|
context: null
|
|
8640
8926
|
};
|
|
8641
|
-
let m = [], h = c - s, g =
|
|
8927
|
+
let m = [], h = c - s, g = mi({
|
|
8642
8928
|
items: f,
|
|
8643
8929
|
index: p,
|
|
8644
8930
|
axis: "horizontal",
|
|
8645
8931
|
direction: "prev"
|
|
8646
|
-
}), _ =
|
|
8932
|
+
}), _ = mi({
|
|
8647
8933
|
items: f,
|
|
8648
8934
|
index: p,
|
|
8649
8935
|
axis: "horizontal",
|
|
@@ -8652,19 +8938,19 @@ var Nr = class {
|
|
|
8652
8938
|
if (v && y) {
|
|
8653
8939
|
let { bounds: e } = v, { bounds: t } = y, { right: r } = e, { left: i } = t, a = i - r - h;
|
|
8654
8940
|
if (a >= 0) {
|
|
8655
|
-
let e =
|
|
8941
|
+
let e = ui({
|
|
8656
8942
|
value: a / 2,
|
|
8657
8943
|
step: 1
|
|
8658
8944
|
}), t = s - r, l = i - c, u = Math.abs(t - e), d = Math.abs(l - e);
|
|
8659
8945
|
if (Math.max(u, d) <= n) {
|
|
8660
|
-
let t =
|
|
8946
|
+
let t = ki({
|
|
8661
8947
|
activeStart: s,
|
|
8662
8948
|
activeEnd: c,
|
|
8663
8949
|
targetGap: e,
|
|
8664
8950
|
beforeEdge: r,
|
|
8665
8951
|
afterEdge: i,
|
|
8666
8952
|
threshold: n,
|
|
8667
|
-
step:
|
|
8953
|
+
step: ai
|
|
8668
8954
|
});
|
|
8669
8955
|
if (t) {
|
|
8670
8956
|
let { delta: e, distance: n, diff: i, activeStart: a, activeEnd: s } = t, c = {
|
|
@@ -8701,16 +8987,16 @@ var Nr = class {
|
|
|
8701
8987
|
}
|
|
8702
8988
|
for (let e of r) {
|
|
8703
8989
|
let { axis: t, start: r, end: i, distance: a } = e;
|
|
8704
|
-
if (!
|
|
8990
|
+
if (!di({
|
|
8705
8991
|
value: a,
|
|
8706
8992
|
step: .5
|
|
8707
|
-
}) || !
|
|
8993
|
+
}) || !gi({
|
|
8708
8994
|
patternAxis: t,
|
|
8709
8995
|
activeRangeStart: l,
|
|
8710
8996
|
activeRangeEnd: u,
|
|
8711
8997
|
tolerance: n
|
|
8712
8998
|
})) continue;
|
|
8713
|
-
let d =
|
|
8999
|
+
let d = _i({
|
|
8714
9000
|
patternStart: r,
|
|
8715
9001
|
patternEnd: i,
|
|
8716
9002
|
activeStart: s,
|
|
@@ -8718,12 +9004,12 @@ var Nr = class {
|
|
|
8718
9004
|
});
|
|
8719
9005
|
if (d) {
|
|
8720
9006
|
if (b !== null && S && d === "before" && Math.abs(b - a) <= n) {
|
|
8721
|
-
let e =
|
|
9007
|
+
let e = ui({
|
|
8722
9008
|
value: a - b,
|
|
8723
9009
|
step: 1
|
|
8724
9010
|
}), t = s + e, { right: c } = S, l = t - c, u = Math.abs(l - a);
|
|
8725
9011
|
if (u > n) continue;
|
|
8726
|
-
let d =
|
|
9012
|
+
let d = Ai({
|
|
8727
9013
|
currentGap: l,
|
|
8728
9014
|
referenceGap: a
|
|
8729
9015
|
});
|
|
@@ -8747,12 +9033,12 @@ var Nr = class {
|
|
|
8747
9033
|
});
|
|
8748
9034
|
}
|
|
8749
9035
|
if (x !== null && C && d === "after" && Math.abs(x - a) <= n) {
|
|
8750
|
-
let e =
|
|
9036
|
+
let e = ui({
|
|
8751
9037
|
value: x - a,
|
|
8752
9038
|
step: 1
|
|
8753
9039
|
}), t = c + e, { left: s } = C, l = s - t, u = Math.abs(l - a);
|
|
8754
9040
|
if (u > n) continue;
|
|
8755
|
-
let d =
|
|
9041
|
+
let d = Ai({
|
|
8756
9042
|
currentGap: l,
|
|
8757
9043
|
referenceGap: a
|
|
8758
9044
|
});
|
|
@@ -8777,20 +9063,20 @@ var Nr = class {
|
|
|
8777
9063
|
}
|
|
8778
9064
|
}
|
|
8779
9065
|
}
|
|
8780
|
-
return
|
|
9066
|
+
return Oi({
|
|
8781
9067
|
options: m,
|
|
8782
9068
|
previousContext: i,
|
|
8783
9069
|
switchDistance: a
|
|
8784
9070
|
});
|
|
8785
|
-
},
|
|
8786
|
-
let { vertical: o = null, horizontal: s = null } = i ?? {}, c =
|
|
9071
|
+
}, Fi = ({ activeBounds: e, candidates: t, threshold: n, spacingPatterns: r, previousContexts: i, switchDistance: a = 0 }) => {
|
|
9072
|
+
let { vertical: o = null, horizontal: s = null } = i ?? {}, c = Ni({
|
|
8787
9073
|
activeBounds: e,
|
|
8788
9074
|
candidates: t,
|
|
8789
9075
|
threshold: n,
|
|
8790
9076
|
patterns: r.vertical,
|
|
8791
9077
|
previousContext: o,
|
|
8792
9078
|
switchDistance: a
|
|
8793
|
-
}), l =
|
|
9079
|
+
}), l = Pi({
|
|
8794
9080
|
activeBounds: e,
|
|
8795
9081
|
candidates: t,
|
|
8796
9082
|
threshold: n,
|
|
@@ -8809,14 +9095,14 @@ var Nr = class {
|
|
|
8809
9095
|
horizontal: l.context
|
|
8810
9096
|
}
|
|
8811
9097
|
};
|
|
8812
|
-
},
|
|
9098
|
+
}, Ii = ({ context: e, x: t, y: n, width: r, height: i, radius: a }) => {
|
|
8813
9099
|
let o = Math.min(a, r / 2, i / 2);
|
|
8814
9100
|
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();
|
|
8815
|
-
},
|
|
9101
|
+
}, Li = ({ 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 }) => {
|
|
8816
9102
|
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;
|
|
8817
9103
|
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";
|
|
8818
9104
|
let S = e.measureText(a).width + _ * 2, C = g + _ * 2, w = b - S / 2, T = x - C / 2;
|
|
8819
|
-
e.beginPath(),
|
|
9105
|
+
e.beginPath(), Ii({
|
|
8820
9106
|
context: e,
|
|
8821
9107
|
x: w,
|
|
8822
9108
|
y: T,
|
|
@@ -8824,11 +9110,11 @@ var Nr = class {
|
|
|
8824
9110
|
height: C,
|
|
8825
9111
|
radius: v
|
|
8826
9112
|
}), e.fill(), e.fillStyle = c, e.fillText(a, b, x), e.restore();
|
|
8827
|
-
},
|
|
8828
|
-
let { type: r, axis: i, refStart: a, refEnd: o, activeStart: s, activeEnd: c, distance: l } = t, u =
|
|
9113
|
+
}, Ri = ({ context: e, guide: t, zoom: n }) => {
|
|
9114
|
+
let { type: r, axis: i, refStart: a, refEnd: o, activeStart: s, activeEnd: c, distance: l } = t, u = oi({ distance: l }).toString();
|
|
8829
9115
|
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();
|
|
8830
|
-
let d =
|
|
8831
|
-
|
|
9116
|
+
let d = ii;
|
|
9117
|
+
Li({
|
|
8832
9118
|
context: e,
|
|
8833
9119
|
type: r,
|
|
8834
9120
|
axis: i,
|
|
@@ -8838,7 +9124,7 @@ var Nr = class {
|
|
|
8838
9124
|
zoom: n,
|
|
8839
9125
|
color: d,
|
|
8840
9126
|
lineWidth: 1
|
|
8841
|
-
}),
|
|
9127
|
+
}), Li({
|
|
8842
9128
|
context: e,
|
|
8843
9129
|
type: r,
|
|
8844
9130
|
axis: i,
|
|
@@ -8849,10 +9135,10 @@ var Nr = class {
|
|
|
8849
9135
|
color: d,
|
|
8850
9136
|
lineWidth: 1
|
|
8851
9137
|
});
|
|
8852
|
-
},
|
|
9138
|
+
}, zi = ({ anchors: e, bounds: t }) => {
|
|
8853
9139
|
let { left: n, right: r, centerX: i, top: a, bottom: o, centerY: s } = t;
|
|
8854
9140
|
e.vertical.push(n, i, r), e.horizontal.push(a, s, o);
|
|
8855
|
-
},
|
|
9141
|
+
}, Bi = ({ bounds: e, type: t, primaryStart: n, primaryEnd: r }) => {
|
|
8856
9142
|
let i = [], a = n === "top" ? "left" : "top", o = r === "bottom" ? "right" : "bottom", s = [...e].sort((e, t) => e[n] - t[n]);
|
|
8857
9143
|
for (let e = 0; e < s.length; e += 1) {
|
|
8858
9144
|
let c = s[e], l = null, u = Infinity;
|
|
@@ -8873,35 +9159,35 @@ var Nr = class {
|
|
|
8873
9159
|
});
|
|
8874
9160
|
}
|
|
8875
9161
|
return i;
|
|
8876
|
-
},
|
|
8877
|
-
vertical:
|
|
9162
|
+
}, Vi = ({ bounds: e }) => ({
|
|
9163
|
+
vertical: Bi({
|
|
8878
9164
|
bounds: e,
|
|
8879
9165
|
axis: "centerX",
|
|
8880
9166
|
type: "vertical",
|
|
8881
9167
|
primaryStart: "top",
|
|
8882
9168
|
primaryEnd: "bottom"
|
|
8883
9169
|
}),
|
|
8884
|
-
horizontal:
|
|
9170
|
+
horizontal: Bi({
|
|
8885
9171
|
bounds: e,
|
|
8886
9172
|
axis: "centerY",
|
|
8887
9173
|
type: "horizontal",
|
|
8888
9174
|
primaryStart: "left",
|
|
8889
9175
|
primaryEnd: "right"
|
|
8890
9176
|
})
|
|
8891
|
-
}),
|
|
9177
|
+
}), Hi = [
|
|
8892
9178
|
"montage-area",
|
|
8893
9179
|
"background",
|
|
8894
9180
|
"interaction-blocker"
|
|
8895
|
-
],
|
|
9181
|
+
], Ui = ({ activeObject: t }) => {
|
|
8896
9182
|
let n = /* @__PURE__ */ new Set();
|
|
8897
9183
|
return t ? (n.add(t), t instanceof e && t.getObjects().forEach((e) => n.add(e)), n) : n;
|
|
8898
|
-
},
|
|
9184
|
+
}, Wi = ({ object: e, excluded: t, ignoredIds: n = Hi }) => {
|
|
8899
9185
|
if (t.has(e)) return !0;
|
|
8900
9186
|
let { visible: r = !0 } = e;
|
|
8901
9187
|
if (!r) return !0;
|
|
8902
9188
|
let { id: i } = e;
|
|
8903
9189
|
return !!(i && n.includes(i));
|
|
8904
|
-
},
|
|
9190
|
+
}, Gi = class e {
|
|
8905
9191
|
constructor({ editor: e }) {
|
|
8906
9192
|
this.anchors = {
|
|
8907
9193
|
vertical: [],
|
|
@@ -8954,7 +9240,7 @@ var Nr = class {
|
|
|
8954
9240
|
this._clearSpacingContexts(), this._clearGuides();
|
|
8955
9241
|
return;
|
|
8956
9242
|
}
|
|
8957
|
-
let { canvas: o } = this, s = o.getZoom() || 1, c = 5 / s, { deltaX: l, deltaY: u } =
|
|
9243
|
+
let { canvas: o } = this, s = o.getZoom() || 1, c = 5 / s, { deltaX: l, deltaY: u } = Mi({
|
|
8958
9244
|
activeBounds: a,
|
|
8959
9245
|
threshold: c,
|
|
8960
9246
|
anchors: this.anchors
|
|
@@ -8966,7 +9252,7 @@ var Nr = class {
|
|
|
8966
9252
|
top: t + u
|
|
8967
9253
|
}), n.setCoords(), a = W({ object: n }) ?? a;
|
|
8968
9254
|
}
|
|
8969
|
-
let d = this._resolveCurrentTargetBounds({ activeObject: n }), f = this.spacingContexts.vertical || this.spacingContexts.horizontal ? 10 / s : c, p =
|
|
9255
|
+
let d = this._resolveCurrentTargetBounds({ activeObject: n }), f = this.spacingContexts.vertical || this.spacingContexts.horizontal ? 10 / s : c, p = Fi({
|
|
8970
9256
|
activeBounds: a,
|
|
8971
9257
|
candidates: d,
|
|
8972
9258
|
threshold: f,
|
|
@@ -8987,11 +9273,11 @@ var Nr = class {
|
|
|
8987
9273
|
target: n,
|
|
8988
9274
|
transform: i
|
|
8989
9275
|
});
|
|
8990
|
-
let h = W({ object: n }) ?? a, g =
|
|
9276
|
+
let h = W({ object: n }) ?? a, g = Mi({
|
|
8991
9277
|
activeBounds: h,
|
|
8992
9278
|
threshold: c,
|
|
8993
9279
|
anchors: this.anchors
|
|
8994
|
-
}), _ =
|
|
9280
|
+
}), _ = Fi({
|
|
8995
9281
|
activeBounds: h,
|
|
8996
9282
|
candidates: d,
|
|
8997
9283
|
threshold: c,
|
|
@@ -9222,9 +9508,9 @@ var Nr = class {
|
|
|
9222
9508
|
let { canvas: e, guideBounds: t } = this, n = e.getSelectionContext();
|
|
9223
9509
|
if (!n) return;
|
|
9224
9510
|
let { left: r, right: i, top: a, bottom: o } = t ?? this._calculateViewportBounds(), { viewportTransform: s } = e, c = e.getZoom() || 1;
|
|
9225
|
-
n.save(), Array.isArray(s) && n.transform(...s), n.lineWidth = 1 / c, n.strokeStyle =
|
|
9511
|
+
n.save(), Array.isArray(s) && n.transform(...s), n.lineWidth = 1 / c, n.strokeStyle = ii, n.setLineDash([4, 4]);
|
|
9226
9512
|
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();
|
|
9227
|
-
for (let e of this.activeSpacingGuides)
|
|
9513
|
+
for (let e of this.activeSpacingGuides) Ri({
|
|
9228
9514
|
context: n,
|
|
9229
9515
|
guide: e,
|
|
9230
9516
|
zoom: c
|
|
@@ -9435,14 +9721,14 @@ var Nr = class {
|
|
|
9435
9721
|
}, r = [];
|
|
9436
9722
|
for (let e of t) {
|
|
9437
9723
|
let t = W({ object: e });
|
|
9438
|
-
t && (
|
|
9724
|
+
t && (zi({
|
|
9439
9725
|
anchors: n,
|
|
9440
9726
|
bounds: t
|
|
9441
9727
|
}), r.push(t));
|
|
9442
9728
|
}
|
|
9443
9729
|
let { montageArea: i } = this.editor, a = W({ object: i });
|
|
9444
9730
|
if (a) {
|
|
9445
|
-
|
|
9731
|
+
zi({
|
|
9446
9732
|
anchors: n,
|
|
9447
9733
|
bounds: a
|
|
9448
9734
|
});
|
|
@@ -9454,12 +9740,12 @@ var Nr = class {
|
|
|
9454
9740
|
bottom: i
|
|
9455
9741
|
};
|
|
9456
9742
|
} else this.guideBounds = this._calculateViewportBounds();
|
|
9457
|
-
this.anchors = n, this.spacingPatterns =
|
|
9743
|
+
this.anchors = n, this.spacingPatterns = Vi({ bounds: r }), this.cachedTargetBounds = r;
|
|
9458
9744
|
}
|
|
9459
9745
|
_collectTargets({ activeObject: e }) {
|
|
9460
|
-
let t =
|
|
9746
|
+
let t = Ui({ activeObject: e }), n = [];
|
|
9461
9747
|
return this.canvas.forEachObject((e) => {
|
|
9462
|
-
|
|
9748
|
+
Wi({
|
|
9463
9749
|
object: e,
|
|
9464
9750
|
excluded: t
|
|
9465
9751
|
}) || n.push(e);
|
|
@@ -9482,7 +9768,7 @@ var Nr = class {
|
|
|
9482
9768
|
bottom: (r - s) / a
|
|
9483
9769
|
};
|
|
9484
9770
|
}
|
|
9485
|
-
},
|
|
9771
|
+
}, Ki = "#3D8BF4", qi = class e {
|
|
9486
9772
|
constructor({ editor: e }) {
|
|
9487
9773
|
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();
|
|
9488
9774
|
}
|
|
@@ -9575,8 +9861,8 @@ var Nr = class {
|
|
|
9575
9861
|
this.isTargetMontageArea = l, this.activeGuides = d, this._hideToolbar(), n.requestRenderAll();
|
|
9576
9862
|
}
|
|
9577
9863
|
static _resolveTarget({ event: e, activeObject: t }) {
|
|
9578
|
-
let { target: n } = e, r =
|
|
9579
|
-
return n && !
|
|
9864
|
+
let { target: n } = e, r = Ui({ activeObject: t });
|
|
9865
|
+
return n && !Wi({
|
|
9580
9866
|
object: n,
|
|
9581
9867
|
excluded: r
|
|
9582
9868
|
}) ? n : null;
|
|
@@ -9693,18 +9979,18 @@ var Nr = class {
|
|
|
9693
9979
|
let { canvas: e } = this, t = e.getSelectionContext();
|
|
9694
9980
|
if (!t) return;
|
|
9695
9981
|
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;
|
|
9696
|
-
t.save(), Array.isArray(n) && t.transform(...n), t.lineWidth = 1 / r, t.strokeStyle =
|
|
9982
|
+
t.save(), Array.isArray(n) && t.transform(...n), t.lineWidth = 1 / r, t.strokeStyle = Ki, t.setLineDash([]);
|
|
9697
9983
|
for (let e of this.activeGuides) {
|
|
9698
9984
|
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;
|
|
9699
|
-
t.beginPath(), n === "vertical" ? (t.moveTo(i, a), t.lineTo(i, c)) : (t.moveTo(a, i), t.lineTo(c, i)), t.stroke(),
|
|
9985
|
+
t.beginPath(), n === "vertical" ? (t.moveTo(i, a), t.lineTo(i, c)) : (t.moveTo(a, i), t.lineTo(c, i)), t.stroke(), Li({
|
|
9700
9986
|
context: t,
|
|
9701
9987
|
type: n,
|
|
9702
9988
|
axis: i,
|
|
9703
9989
|
start: a,
|
|
9704
9990
|
end: c,
|
|
9705
|
-
text:
|
|
9991
|
+
text: oi({ distance: l }).toString(),
|
|
9706
9992
|
zoom: r,
|
|
9707
|
-
color:
|
|
9993
|
+
color: Ki,
|
|
9708
9994
|
lineWidth: 1,
|
|
9709
9995
|
offsetAlongAxis: d,
|
|
9710
9996
|
offsetPerpendicular: 0
|
|
@@ -9722,13 +10008,13 @@ var Nr = class {
|
|
|
9722
10008
|
let { toolbar: e } = this.editor;
|
|
9723
10009
|
e?.showAfterTemporary?.(), this.isToolbarHidden = !1;
|
|
9724
10010
|
}
|
|
9725
|
-
},
|
|
10011
|
+
}, Ji = class e {
|
|
9726
10012
|
constructor(e, t) {
|
|
9727
10013
|
this.options = t, this.containerId = e, this.editorId = `${e}-${D()}`, this.init();
|
|
9728
10014
|
}
|
|
9729
10015
|
async init() {
|
|
9730
10016
|
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;
|
|
9731
|
-
if (
|
|
10017
|
+
if (R.apply(), this.canvas = new t(this.containerId, this.options), this.moduleLoader = new A(), this.workerManager = new M(), this.errorManager = new dr({ editor: this }), this.historyManager = new Me({ editor: this }), this.toolbar = new oe({ editor: this }), this.transformManager = new Ue({ editor: this }), this.zoomManager = new We({ editor: this }), this.canvasManager = new He({ editor: this }), this.imageManager = new Re({ editor: this }), this.layerManager = new $e({ editor: this }), this.shapeManager = new ir({ editor: this }), this.interactionBlocker = new Ze({ editor: this }), this.backgroundManager = new Qe({ editor: this }), this.clipboardManager = new ar({ editor: this }), this.objectLockManager = new or({ editor: this }), this.groupingManager = new sr({ editor: this }), this.selectionManager = new cr({ editor: this }), this.deletionManager = new lr({ editor: this }), this.panConstraintManager = new fr({ editor: this }), this.snappingManager = new Gi({ editor: this }), this.measurementManager = new qi({ editor: this }), this.fontManager = new ae(this.options.fonts ?? []), this.textManager = new Qr({ editor: this }), this.templateManager = new ri({ editor: this }), u && (this.angleIndicator = new ce({ editor: this })), this._createMontageArea(), this._createClippingArea(), this.interactionBlocker.ensureOverlay(), this.listeners = new k({
|
|
9732
10018
|
editor: this,
|
|
9733
10019
|
options: this.options
|
|
9734
10020
|
}), 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) {
|
|
@@ -9836,7 +10122,7 @@ var Nr = class {
|
|
|
9836
10122
|
"U+A640-A69F",
|
|
9837
10123
|
"U+FE2E-FE2F",
|
|
9838
10124
|
"U+2116"
|
|
9839
|
-
].join(", "),
|
|
10125
|
+
].join(", "), Yi = {
|
|
9840
10126
|
preserveObjectStacking: !0,
|
|
9841
10127
|
controlsAboveOverlay: !0,
|
|
9842
10128
|
centeredRotation: !0,
|
|
@@ -10690,20 +10976,20 @@ var Nr = class {
|
|
|
10690
10976
|
};
|
|
10691
10977
|
//#endregion
|
|
10692
10978
|
//#region src/main.ts
|
|
10693
|
-
function
|
|
10979
|
+
function Xi(e, t = {}) {
|
|
10694
10980
|
let n = {
|
|
10695
|
-
...
|
|
10981
|
+
...Yi,
|
|
10696
10982
|
...t
|
|
10697
10983
|
}, r = document.getElementById(e);
|
|
10698
10984
|
if (!r) return Promise.reject(/* @__PURE__ */ Error(`Контейнер с ID "${e}" не найден.`));
|
|
10699
10985
|
let i = document.createElement("canvas");
|
|
10700
10986
|
return i.id = `${e}-canvas`, r.appendChild(i), n.editorContainer = r, new Promise((t) => {
|
|
10701
10987
|
n._onReadyCallback = t;
|
|
10702
|
-
let r = new
|
|
10988
|
+
let r = new Ji(i.id, n);
|
|
10703
10989
|
window[e] = r;
|
|
10704
10990
|
});
|
|
10705
10991
|
}
|
|
10706
10992
|
//#endregion
|
|
10707
|
-
export {
|
|
10993
|
+
export { Xi as default };
|
|
10708
10994
|
|
|
10709
10995
|
//# sourceMappingURL=main.js.map
|