@anu3ev/fabric-image-editor 0.9.16 → 0.9.18
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 +1043 -440
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -10652,7 +10652,7 @@ var Ra = {
|
|
|
10652
10652
|
};
|
|
10653
10653
|
return i.fire("editor:objects-deleted", l), l;
|
|
10654
10654
|
}
|
|
10655
|
-
},
|
|
10655
|
+
}, Ja = {
|
|
10656
10656
|
IMAGE_MANAGER: {
|
|
10657
10657
|
INVALID_CONTENT_TYPE: "INVALID_CONTENT_TYPE",
|
|
10658
10658
|
INVALID_SOURCE_TYPE: "INVALID_SOURCE_TYPE",
|
|
@@ -10695,7 +10695,7 @@ var Ra = {
|
|
|
10695
10695
|
INVALID_TARGET: "TEMPLATE_INVALID_TARGET",
|
|
10696
10696
|
APPLY_FAILED: "TEMPLATE_APPLY_FAILED"
|
|
10697
10697
|
}
|
|
10698
|
-
},
|
|
10698
|
+
}, Ya = class e {
|
|
10699
10699
|
constructor({ editor: e }) {
|
|
10700
10700
|
this._buffer = [], this.editor = e;
|
|
10701
10701
|
}
|
|
@@ -10753,9 +10753,9 @@ var Ra = {
|
|
|
10753
10753
|
}), this.editor.canvas.fire("editor:warning", s);
|
|
10754
10754
|
}
|
|
10755
10755
|
static isValidErrorCode(e) {
|
|
10756
|
-
return e ? Object.values(
|
|
10756
|
+
return e ? Object.values(Ja).some((t) => Object.values(t).includes(e)) : !1;
|
|
10757
10757
|
}
|
|
10758
|
-
},
|
|
10758
|
+
}, Xa = 48, Za = class e {
|
|
10759
10759
|
constructor({ editor: e }) {
|
|
10760
10760
|
this.currentBounds = null, this.editor = e;
|
|
10761
10761
|
}
|
|
@@ -10859,7 +10859,7 @@ var Ra = {
|
|
|
10859
10859
|
};
|
|
10860
10860
|
}
|
|
10861
10861
|
static _getScrollDistance({ contentSize: e, viewportSize: t }) {
|
|
10862
|
-
let n = Math.max(1, t -
|
|
10862
|
+
let n = Math.max(1, t - Xa * 2);
|
|
10863
10863
|
return Math.max(0, e - n);
|
|
10864
10864
|
}
|
|
10865
10865
|
static _createLockedAxisState({ contentSize: e, current: t, viewportSize: n }) {
|
|
@@ -10891,32 +10891,32 @@ var Ra = {
|
|
|
10891
10891
|
updateBounds() {
|
|
10892
10892
|
this.currentBounds = this.calculatePanBounds();
|
|
10893
10893
|
}
|
|
10894
|
-
},
|
|
10894
|
+
}, Qa = ({ textbox: e }) => {
|
|
10895
10895
|
if (!e.isEditing) return null;
|
|
10896
10896
|
let t = e.selectionStart ?? 0, n = e.selectionEnd ?? t;
|
|
10897
10897
|
return t === n ? null : {
|
|
10898
10898
|
start: Math.min(t, n),
|
|
10899
10899
|
end: Math.max(t, n)
|
|
10900
10900
|
};
|
|
10901
|
-
},
|
|
10901
|
+
}, $a = ({ textbox: e }) => {
|
|
10902
10902
|
let t = e.text?.length ?? 0;
|
|
10903
10903
|
return t <= 0 ? null : {
|
|
10904
10904
|
start: 0,
|
|
10905
10905
|
end: t
|
|
10906
10906
|
};
|
|
10907
|
-
},
|
|
10907
|
+
}, eo = ({ textbox: e, range: t }) => {
|
|
10908
10908
|
if (!t) return !1;
|
|
10909
10909
|
let n = e.text?.length ?? 0;
|
|
10910
10910
|
return n <= 0 ? !1 : t.start <= 0 && t.end >= n;
|
|
10911
|
-
},
|
|
10911
|
+
}, to = ({ textbox: e, styles: t, range: n }) => {
|
|
10912
10912
|
if (!t || !Object.keys(t).length) return !1;
|
|
10913
10913
|
let { start: r, end: i } = n;
|
|
10914
10914
|
return i <= r ? !1 : (e.setSelectionStyles(t, r, i), !0);
|
|
10915
|
-
},
|
|
10915
|
+
}, no = ({ textbox: e, range: t, property: n }) => {
|
|
10916
10916
|
if (!t) return;
|
|
10917
10917
|
let r = e.getSelectionStyles(t.start, t.end, !0);
|
|
10918
10918
|
if (r.length) return r[0]?.[n];
|
|
10919
|
-
},
|
|
10919
|
+
}, ro = ({ strokeColor: e, width: t }) => t <= 0 ? null : e ?? "#000000", io = ({ width: e = 0 }) => e ? Math.max(0, e) : 0, ao = ({ value: e }) => typeof e == "string" ? e.toLocaleUpperCase() : "", X = ({ value: e, min: t, max: n }) => Math.min(Math.max(e, t), n), oo = class e extends v {
|
|
10920
10920
|
static {
|
|
10921
10921
|
this.type = "background-textbox";
|
|
10922
10922
|
}
|
|
@@ -11060,7 +11060,7 @@ var Ra = {
|
|
|
11060
11060
|
this._removeShadow(e);
|
|
11061
11061
|
}
|
|
11062
11062
|
_getDecorationColorAt(e, t) {
|
|
11063
|
-
let n = this.getValueOfPropertyAt(e, t, "strokeWidth"), r =
|
|
11063
|
+
let n = this.getValueOfPropertyAt(e, t, "strokeWidth"), r = io({ width: typeof n == "number" && Number.isFinite(n) ? n : 0 }), i = this.getValueOfPropertyAt(e, t, "stroke"), a = i == null ? null : ro({
|
|
11064
11064
|
strokeColor: i,
|
|
11065
11065
|
width: r
|
|
11066
11066
|
});
|
|
@@ -11076,22 +11076,22 @@ var Ra = {
|
|
|
11076
11076
|
_getCornerRadii({ width: e, height: t }) {
|
|
11077
11077
|
let n = e / 2, r = t / 2, i = Math.min(n, r);
|
|
11078
11078
|
return {
|
|
11079
|
-
bottomLeft:
|
|
11079
|
+
bottomLeft: X({
|
|
11080
11080
|
value: this.radiusBottomLeft ?? 0,
|
|
11081
11081
|
min: 0,
|
|
11082
11082
|
max: i
|
|
11083
11083
|
}),
|
|
11084
|
-
bottomRight:
|
|
11084
|
+
bottomRight: X({
|
|
11085
11085
|
value: this.radiusBottomRight ?? 0,
|
|
11086
11086
|
min: 0,
|
|
11087
11087
|
max: i
|
|
11088
11088
|
}),
|
|
11089
|
-
topLeft:
|
|
11089
|
+
topLeft: X({
|
|
11090
11090
|
value: this.radiusTopLeft ?? 0,
|
|
11091
11091
|
min: 0,
|
|
11092
11092
|
max: i
|
|
11093
11093
|
}),
|
|
11094
|
-
topRight:
|
|
11094
|
+
topRight: X({
|
|
11095
11095
|
value: this.radiusTopRight ?? 0,
|
|
11096
11096
|
min: 0,
|
|
11097
11097
|
max: i
|
|
@@ -11109,7 +11109,7 @@ var Ra = {
|
|
|
11109
11109
|
_getEffectiveBackgroundFill() {
|
|
11110
11110
|
let e = this.backgroundColor;
|
|
11111
11111
|
if (!e) return null;
|
|
11112
|
-
let t =
|
|
11112
|
+
let t = X({
|
|
11113
11113
|
value: this.backgroundOpacity ?? 1,
|
|
11114
11114
|
min: 0,
|
|
11115
11115
|
max: 1
|
|
@@ -11122,19 +11122,19 @@ var Ra = {
|
|
|
11122
11122
|
return r.setAlpha(t), r.toRgba();
|
|
11123
11123
|
}
|
|
11124
11124
|
static _renderRoundedRect({ ctx: e, height: t, left: n, radii: r, top: i, width: a }) {
|
|
11125
|
-
let o = n + a, s = i + t, { topLeft: c, topRight: l, bottomRight: u, bottomLeft: d } = r, f =
|
|
11125
|
+
let o = n + a, s = i + t, { topLeft: c, topRight: l, bottomRight: u, bottomLeft: d } = r, f = X({
|
|
11126
11126
|
value: c,
|
|
11127
11127
|
min: 0,
|
|
11128
11128
|
max: a
|
|
11129
|
-
}), p =
|
|
11129
|
+
}), p = X({
|
|
11130
11130
|
value: l,
|
|
11131
11131
|
min: 0,
|
|
11132
11132
|
max: a
|
|
11133
|
-
}), m =
|
|
11133
|
+
}), m = X({
|
|
11134
11134
|
value: u,
|
|
11135
11135
|
min: 0,
|
|
11136
11136
|
max: a
|
|
11137
|
-
}), h =
|
|
11137
|
+
}), h = X({
|
|
11138
11138
|
value: d,
|
|
11139
11139
|
min: 0,
|
|
11140
11140
|
max: a
|
|
@@ -11211,16 +11211,16 @@ var Ra = {
|
|
|
11211
11211
|
};
|
|
11212
11212
|
}
|
|
11213
11213
|
_createSelectionContext({ textbox: e, currentText: t, selectionRangeOverride: n }) {
|
|
11214
|
-
let r = n === void 0 ?
|
|
11214
|
+
let r = n === void 0 ? Qa({ textbox: e }) : Zi({
|
|
11215
11215
|
text: t,
|
|
11216
11216
|
range: n
|
|
11217
11217
|
}), i = r ? Qi({
|
|
11218
11218
|
textbox: e,
|
|
11219
11219
|
range: r
|
|
11220
|
-
}) : null, a =
|
|
11220
|
+
}) : null, a = eo({
|
|
11221
11221
|
textbox: e,
|
|
11222
11222
|
range: r
|
|
11223
|
-
}), o =
|
|
11223
|
+
}), o = eo({
|
|
11224
11224
|
textbox: e,
|
|
11225
11225
|
range: i
|
|
11226
11226
|
}), s = !r || a;
|
|
@@ -11308,17 +11308,17 @@ var Ra = {
|
|
|
11308
11308
|
t.resolvedStrokeColor = i.stroke, t.resolvedStrokeWidth = i.strokeWidth, r.selectionRange && (t.selectionStyles.stroke = i.stroke, t.selectionStyles.strokeWidth = i.strokeWidth), r.shouldUpdateWholeObject && (t.updates.stroke = i.stroke, t.updates.strokeWidth = i.strokeWidth, r.shouldApplyWholeTextStyles && (t.wholeTextStyles.stroke = i.stroke, t.wholeTextStyles.strokeWidth = i.strokeWidth));
|
|
11309
11309
|
}
|
|
11310
11310
|
_resolveStrokeUpdate({ textbox: e, selectionRange: t, strokeColor: n, strokeWidth: r }) {
|
|
11311
|
-
let i = t ?
|
|
11311
|
+
let i = t ? no({
|
|
11312
11312
|
textbox: e,
|
|
11313
11313
|
range: t,
|
|
11314
11314
|
property: "strokeWidth"
|
|
11315
|
-
}) : void 0, a = t ?
|
|
11315
|
+
}) : void 0, a = t ? no({
|
|
11316
11316
|
textbox: e,
|
|
11317
11317
|
range: t,
|
|
11318
11318
|
property: "stroke"
|
|
11319
|
-
}) : void 0, o = typeof i == "number" ? i : void 0, s = typeof a == "string" ? a : void 0, c = typeof e.stroke == "string" ? e.stroke : void 0, l =
|
|
11319
|
+
}) : void 0, o = typeof i == "number" ? i : void 0, s = typeof a == "string" ? a : void 0, c = typeof e.stroke == "string" ? e.stroke : void 0, l = io({ width: r ?? o ?? e.strokeWidth ?? 0 });
|
|
11320
11320
|
return {
|
|
11321
|
-
stroke:
|
|
11321
|
+
stroke: ro({
|
|
11322
11322
|
strokeColor: n ?? s ?? c,
|
|
11323
11323
|
width: l
|
|
11324
11324
|
}) ?? null,
|
|
@@ -11330,7 +11330,7 @@ var Ra = {
|
|
|
11330
11330
|
}
|
|
11331
11331
|
_applyTextContentUpdate({ textbox: e, style: t, updates: n, currentText: r }) {
|
|
11332
11332
|
let i = e.textCaseRaw ?? r, a = !!e.uppercase, o = t.text !== void 0, s = o ? t.text ?? "" : i, c = t.uppercase ?? a, l = c !== a, u = e.text ?? "";
|
|
11333
|
-
return o || l ? (n.text = c ?
|
|
11333
|
+
return o || l ? (n.text = c ? ao({ value: s }) : s, e.textCaseRaw = s) : e.textCaseRaw === void 0 && (e.textCaseRaw = i), e.uppercase = c, {
|
|
11334
11334
|
hasTextUpdate: o,
|
|
11335
11335
|
uppercaseChanged: l,
|
|
11336
11336
|
previousRenderedText: u
|
|
@@ -11386,8 +11386,8 @@ var Ra = {
|
|
|
11386
11386
|
}
|
|
11387
11387
|
_applyWholeTextStyles({ textbox: e, selection: t, styleMaps: n }) {
|
|
11388
11388
|
if (t.selectionRange || Object.keys(n.wholeTextStyles).length === 0) return;
|
|
11389
|
-
let r =
|
|
11390
|
-
r &&
|
|
11389
|
+
let r = $a({ textbox: e });
|
|
11390
|
+
r && to({
|
|
11391
11391
|
textbox: e,
|
|
11392
11392
|
styles: n.wholeTextStyles,
|
|
11393
11393
|
range: r
|
|
@@ -11395,11 +11395,11 @@ var Ra = {
|
|
|
11395
11395
|
}
|
|
11396
11396
|
_applySelectionStyles({ textbox: e, selection: t, styleMaps: n }) {
|
|
11397
11397
|
if (!t.selectionRange) return;
|
|
11398
|
-
let r =
|
|
11398
|
+
let r = to({
|
|
11399
11399
|
textbox: e,
|
|
11400
11400
|
styles: n.selectionStyles,
|
|
11401
11401
|
range: t.selectionRange
|
|
11402
|
-
}), i = t.fontSelectionRange ?
|
|
11402
|
+
}), i = t.fontSelectionRange ? to({
|
|
11403
11403
|
textbox: e,
|
|
11404
11404
|
styles: n.lineSelectionStyles,
|
|
11405
11405
|
range: t.fontSelectionRange
|
|
@@ -11837,7 +11837,7 @@ var go = class {
|
|
|
11837
11837
|
if (!e._isTextbox(n)) return;
|
|
11838
11838
|
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 });
|
|
11839
11839
|
if (s) {
|
|
11840
|
-
let e =
|
|
11840
|
+
let e = ao({ value: l });
|
|
11841
11841
|
e !== i && n.set({ text: e }), n.textCaseRaw = l;
|
|
11842
11842
|
} else n.textCaseRaw = i;
|
|
11843
11843
|
if (!r && o === void 0 && (n.autoExpand = !0), r) {
|
|
@@ -11906,7 +11906,7 @@ var go = class {
|
|
|
11906
11906
|
addText({ id: t = `background-textbox-${D()}`, text: n = "Новый текст", autoExpand: r = !0, fontFamily: i, fontSize: a = 48, bold: o = !1, italic: s = !1, underline: c = !1, uppercase: l = !1, strikethrough: u = !1, align: d = "left", color: f = "#000000", strokeColor: p, strokeWidth: m = 0, opacity: h = 1, backgroundColor: g, backgroundOpacity: _ = 1, paddingTop: v = 0, paddingRight: y = 0, paddingBottom: b = 0, paddingLeft: x = 0, radiusTopLeft: S = 0, radiusTopRight: C = 0, radiusBottomRight: w = 0, radiusBottomLeft: T = 0, ...E } = {}, { withoutSelection: O = !1, withoutSave: k = !1, withoutAdding: A = !1, emitLifecycleEvents: j = !0 } = {}) {
|
|
11907
11907
|
let { canvasManager: M, historyManager: N } = this.editor, { canvas: P } = this;
|
|
11908
11908
|
N.suspendHistory();
|
|
11909
|
-
let F = i ?? this._getDefaultFontFamily(), ee =
|
|
11909
|
+
let F = i ?? this._getDefaultFontFamily(), ee = io({ width: m }), te = ro({
|
|
11910
11910
|
strokeColor: p,
|
|
11911
11911
|
width: ee
|
|
11912
11912
|
}), ne = {
|
|
@@ -11939,7 +11939,7 @@ var go = class {
|
|
|
11939
11939
|
I.autoExpand = re;
|
|
11940
11940
|
let ie = E.left !== void 0 || E.top !== void 0;
|
|
11941
11941
|
if (I.textCaseRaw = I.text ?? "", l) {
|
|
11942
|
-
let e =
|
|
11942
|
+
let e = ao({ value: I.textCaseRaw });
|
|
11943
11943
|
e !== I.text && I.set({ text: e });
|
|
11944
11944
|
}
|
|
11945
11945
|
Ea({ textbox: I }) && (I.dirty = !0);
|
|
@@ -12210,7 +12210,7 @@ var go = class {
|
|
|
12210
12210
|
if (!p.length) return s.emitWarning({
|
|
12211
12211
|
origin: "TemplateManager",
|
|
12212
12212
|
method: "serializeSelection",
|
|
12213
|
-
code:
|
|
12213
|
+
code: Ja.TEMPLATE_MANAGER.NO_OBJECTS_SELECTED,
|
|
12214
12214
|
message: "Нет объектов для сериализации шаблона"
|
|
12215
12215
|
}), null;
|
|
12216
12216
|
let m = t._getBounds(o), h = t._getMontageSize({
|
|
@@ -12239,14 +12239,14 @@ var go = class {
|
|
|
12239
12239
|
if (!l?.length) return a.emitWarning({
|
|
12240
12240
|
origin: "TemplateManager",
|
|
12241
12241
|
method: "applyTemplate",
|
|
12242
|
-
code:
|
|
12242
|
+
code: Ja.TEMPLATE_MANAGER.INVALID_TEMPLATE,
|
|
12243
12243
|
message: "Шаблон не содержит объектов"
|
|
12244
12244
|
}), null;
|
|
12245
12245
|
let f = t._getBounds(r);
|
|
12246
12246
|
if (!f) return a.emitWarning({
|
|
12247
12247
|
origin: "TemplateManager",
|
|
12248
12248
|
method: "applyTemplate",
|
|
12249
|
-
code:
|
|
12249
|
+
code: Ja.TEMPLATE_MANAGER.INVALID_TARGET,
|
|
12250
12250
|
message: "Не удалось определить границы монтажной области"
|
|
12251
12251
|
}), null;
|
|
12252
12252
|
let p = t._getMontageSize({
|
|
@@ -12270,7 +12270,7 @@ var go = class {
|
|
|
12270
12270
|
if (!r.length) return a.emitWarning({
|
|
12271
12271
|
origin: "TemplateManager",
|
|
12272
12272
|
method: "applyTemplate",
|
|
12273
|
-
code:
|
|
12273
|
+
code: Ja.TEMPLATE_MANAGER.INVALID_TEMPLATE,
|
|
12274
12274
|
message: "Не удалось создать объекты шаблона"
|
|
12275
12275
|
}), null;
|
|
12276
12276
|
let { backgroundObject: i, contentObjects: u } = t._extractBackgroundObject(r);
|
|
@@ -12305,7 +12305,7 @@ var go = class {
|
|
|
12305
12305
|
return a.emitError({
|
|
12306
12306
|
origin: "TemplateManager",
|
|
12307
12307
|
method: "applyTemplate",
|
|
12308
|
-
code:
|
|
12308
|
+
code: Ja.TEMPLATE_MANAGER.APPLY_FAILED,
|
|
12309
12309
|
message: "Ошибка применения шаблона",
|
|
12310
12310
|
data: {
|
|
12311
12311
|
templateId: d,
|
|
@@ -12737,7 +12737,7 @@ var go = class {
|
|
|
12737
12737
|
r.emitWarning({
|
|
12738
12738
|
origin: "TemplateManager",
|
|
12739
12739
|
method: "applyTemplate",
|
|
12740
|
-
code:
|
|
12740
|
+
code: Ja.TEMPLATE_MANAGER.APPLY_FAILED,
|
|
12741
12741
|
message: "Не удалось применить фон из шаблона",
|
|
12742
12742
|
data: e
|
|
12743
12743
|
});
|
|
@@ -13455,46 +13455,345 @@ var go = class {
|
|
|
13455
13455
|
color: d,
|
|
13456
13456
|
lineWidth: 1
|
|
13457
13457
|
});
|
|
13458
|
-
};
|
|
13459
|
-
|
|
13460
|
-
//#region src/editor/snapping-manager/pixel-grid.ts
|
|
13461
|
-
function is({ target: e }) {
|
|
13458
|
+
}, is = .01, as = .1, os = 1e-6;
|
|
13459
|
+
function ss({ target: e }) {
|
|
13462
13460
|
let t = typeof e.type == "string" ? e.type.toLowerCase() : "", n = e instanceof v || t === "textbox" || t === "background-textbox";
|
|
13463
13461
|
return !(e instanceof a) && !n;
|
|
13464
13462
|
}
|
|
13465
|
-
function
|
|
13463
|
+
function cs({ target: e, transform: t }) {
|
|
13466
13464
|
let { left: n = 0, top: r = 0 } = e, i = Math.round(n / 1) * 1, a = Math.round(r / 1) * 1, o = typeof t?.original?.left == "number" ? t.original.left : null, s = typeof t?.original?.top == "number" ? t.original.top : null, c = o === null || o !== n, l = s === null || s !== r, u = {};
|
|
13467
13465
|
c && i !== n && (u.left = i), l && a !== r && (u.top = a), !(!("left" in u) && !("top" in u)) && (e.set(u), e.setCoords());
|
|
13468
13466
|
}
|
|
13469
|
-
function
|
|
13467
|
+
function ls({ target: e }) {
|
|
13470
13468
|
let { width: t = 0, height: n = 0, paddingTop: r = 0, paddingRight: i = 0, paddingBottom: a = 0, paddingLeft: o = 0, strokeWidth: s = 0 } = e;
|
|
13471
13469
|
return {
|
|
13472
13470
|
width: t + o + i + s,
|
|
13473
13471
|
height: n + r + a + s
|
|
13474
13472
|
};
|
|
13475
13473
|
}
|
|
13476
|
-
function
|
|
13477
|
-
|
|
13478
|
-
|
|
13474
|
+
function us({ target: e, scaleX: t, scaleY: n }) {
|
|
13475
|
+
let r = e.getObjectDisplaySize?.();
|
|
13476
|
+
if (!r) return null;
|
|
13477
|
+
let i = Math.abs(t), a = Math.abs(n);
|
|
13478
|
+
return i <= 0 || a <= 0 || !Number.isFinite(r.width) || !Number.isFinite(r.height) || r.width <= 0 || r.height <= 0 ? null : {
|
|
13479
|
+
width: r.width / i,
|
|
13480
|
+
height: r.height / a
|
|
13481
|
+
};
|
|
13482
|
+
}
|
|
13483
|
+
function ds({ target: e, scaleX: t, scaleY: n }) {
|
|
13484
|
+
let r = us({
|
|
13485
|
+
target: e,
|
|
13486
|
+
scaleX: t,
|
|
13487
|
+
scaleY: n
|
|
13488
|
+
});
|
|
13489
|
+
if (r) return r;
|
|
13490
|
+
if (e instanceof v) return ls({ target: e });
|
|
13491
|
+
let { width: i = 0, height: a = 0, strokeWidth: o = 0, strokeUniform: s = !1 } = e, c = s ? 0 : o;
|
|
13479
13492
|
return {
|
|
13480
|
-
width:
|
|
13481
|
-
height:
|
|
13493
|
+
width: i + c,
|
|
13494
|
+
height: a + c
|
|
13482
13495
|
};
|
|
13483
13496
|
}
|
|
13484
|
-
function
|
|
13485
|
-
let { scaleX:
|
|
13486
|
-
|
|
13487
|
-
|
|
13488
|
-
|
|
13497
|
+
function fs({ target: e, transform: t, preservePlacement: n, snapGuards: r = [] }) {
|
|
13498
|
+
let { scaleX: i = 1, scaleY: a = 1 } = e, o = ps({
|
|
13499
|
+
transform: t,
|
|
13500
|
+
rawScaleX: i,
|
|
13501
|
+
rawScaleY: a
|
|
13502
|
+
});
|
|
13503
|
+
if (!o.shouldRoundScaleX && !o.shouldRoundScaleY) return;
|
|
13504
|
+
let { width: s, height: c } = ds({
|
|
13505
|
+
target: e,
|
|
13506
|
+
scaleX: i,
|
|
13507
|
+
scaleY: a
|
|
13508
|
+
}), l = ms({
|
|
13509
|
+
rawScaleX: i,
|
|
13510
|
+
rawScaleY: a,
|
|
13511
|
+
snappedScale: _s({
|
|
13512
|
+
target: e,
|
|
13513
|
+
rawScaleX: i,
|
|
13514
|
+
rawScaleY: a,
|
|
13515
|
+
effectiveWidth: s,
|
|
13516
|
+
effectiveHeight: c,
|
|
13517
|
+
preservePlacement: n,
|
|
13518
|
+
snapGuards: r
|
|
13519
|
+
}),
|
|
13520
|
+
roundingState: o
|
|
13521
|
+
});
|
|
13522
|
+
l.scaleX === i && l.scaleY === a || hs({
|
|
13523
|
+
target: e,
|
|
13524
|
+
transform: t,
|
|
13525
|
+
preservePlacement: n,
|
|
13526
|
+
scale: l
|
|
13527
|
+
});
|
|
13528
|
+
}
|
|
13529
|
+
function ps({ transform: e, rawScaleX: t, rawScaleY: n }) {
|
|
13530
|
+
return {
|
|
13531
|
+
shouldRoundScaleX: gs({
|
|
13532
|
+
transform: e,
|
|
13533
|
+
axis: "x",
|
|
13534
|
+
rawScale: t
|
|
13535
|
+
}),
|
|
13536
|
+
shouldRoundScaleY: gs({
|
|
13537
|
+
transform: e,
|
|
13538
|
+
axis: "y",
|
|
13539
|
+
rawScale: n
|
|
13540
|
+
})
|
|
13541
|
+
};
|
|
13542
|
+
}
|
|
13543
|
+
function ms({ rawScaleX: e, rawScaleY: t, snappedScale: n, roundingState: r }) {
|
|
13544
|
+
let i = { ...n };
|
|
13545
|
+
return r.shouldRoundScaleX || (i.scaleX = e), r.shouldRoundScaleY || (i.scaleY = t), i;
|
|
13546
|
+
}
|
|
13547
|
+
function hs({ target: e, transform: t, preservePlacement: n, scale: r }) {
|
|
13548
|
+
e.set({
|
|
13549
|
+
scaleX: r.scaleX,
|
|
13550
|
+
scaleY: r.scaleY
|
|
13551
|
+
}), n && n.applyPlacement(n.placement), t && (t.scaleX = r.scaleX, t.scaleY = r.scaleY), e.setCoords();
|
|
13552
|
+
}
|
|
13553
|
+
function gs({ transform: e, axis: t, rawScale: n }) {
|
|
13554
|
+
if (!e) return !0;
|
|
13555
|
+
let r = t === "x" ? e.original?.scaleX : e.original?.scaleY;
|
|
13556
|
+
return typeof r == "number" ? r !== n : !0;
|
|
13557
|
+
}
|
|
13558
|
+
function _s({ target: e, rawScaleX: t, rawScaleY: n, effectiveWidth: r, effectiveHeight: i, preservePlacement: a, snapGuards: o }) {
|
|
13559
|
+
let s = vs({
|
|
13560
|
+
rawScaleX: t,
|
|
13561
|
+
rawScaleY: n,
|
|
13562
|
+
effectiveWidth: r,
|
|
13563
|
+
effectiveHeight: i
|
|
13564
|
+
});
|
|
13565
|
+
return o.length === 0 ? s : xs({
|
|
13566
|
+
target: e,
|
|
13567
|
+
rawScaleX: t,
|
|
13568
|
+
rawScaleY: n,
|
|
13569
|
+
effectiveWidth: r,
|
|
13570
|
+
effectiveHeight: i,
|
|
13571
|
+
fallbackScale: s,
|
|
13572
|
+
isUniform: t === n,
|
|
13573
|
+
preservePlacement: a,
|
|
13574
|
+
snapGuards: o
|
|
13575
|
+
});
|
|
13576
|
+
}
|
|
13577
|
+
function vs({ rawScaleX: e, rawScaleY: t, effectiveWidth: n, effectiveHeight: r }) {
|
|
13578
|
+
return e === t ? ys({
|
|
13579
|
+
rawScale: e,
|
|
13580
|
+
effectiveWidth: n,
|
|
13581
|
+
effectiveHeight: r
|
|
13582
|
+
}) : {
|
|
13583
|
+
scaleX: bs({
|
|
13584
|
+
rawScale: e,
|
|
13585
|
+
effectiveSize: n
|
|
13586
|
+
}),
|
|
13587
|
+
scaleY: bs({
|
|
13588
|
+
rawScale: t,
|
|
13589
|
+
effectiveSize: r
|
|
13590
|
+
})
|
|
13591
|
+
};
|
|
13592
|
+
}
|
|
13593
|
+
function ys({ rawScale: e, effectiveWidth: t, effectiveHeight: n }) {
|
|
13594
|
+
let r = bs({
|
|
13595
|
+
rawScale: e,
|
|
13596
|
+
effectiveSize: t
|
|
13597
|
+
}), i = bs({
|
|
13598
|
+
rawScale: e,
|
|
13599
|
+
effectiveSize: n
|
|
13600
|
+
}), a = Math.abs(r - e) <= Math.abs(i - e) ? r : i;
|
|
13601
|
+
return {
|
|
13602
|
+
scaleX: a,
|
|
13603
|
+
scaleY: a
|
|
13604
|
+
};
|
|
13605
|
+
}
|
|
13606
|
+
function bs({ rawScale: e, effectiveSize: t }) {
|
|
13607
|
+
return t <= 0 ? e : Math.max(1, Math.round(t * e)) / t;
|
|
13608
|
+
}
|
|
13609
|
+
function xs({ target: e, rawScaleX: t, rawScaleY: n, effectiveWidth: r, effectiveHeight: i, fallbackScale: a, isUniform: o, preservePlacement: s, snapGuards: c }) {
|
|
13610
|
+
if (Cs({
|
|
13611
|
+
target: e,
|
|
13612
|
+
snapGuards: c
|
|
13613
|
+
})) return {
|
|
13614
|
+
scaleX: t,
|
|
13615
|
+
scaleY: n
|
|
13616
|
+
};
|
|
13617
|
+
let l = js({
|
|
13618
|
+
rawScaleX: t,
|
|
13619
|
+
rawScaleY: n,
|
|
13620
|
+
effectiveWidth: r,
|
|
13621
|
+
effectiveHeight: i,
|
|
13622
|
+
isUniform: o
|
|
13623
|
+
}), u = Ss({
|
|
13624
|
+
target: e,
|
|
13625
|
+
snapGuards: c
|
|
13626
|
+
}), d = null, f = null;
|
|
13627
|
+
for (let t of l) {
|
|
13628
|
+
let n = Is({
|
|
13629
|
+
target: e,
|
|
13630
|
+
candidate: t,
|
|
13631
|
+
preservePlacement: s,
|
|
13632
|
+
snapGuards: c
|
|
13633
|
+
});
|
|
13634
|
+
if (n === "on-guide") {
|
|
13635
|
+
if (!u) return t;
|
|
13636
|
+
d ||= t;
|
|
13637
|
+
}
|
|
13638
|
+
n === "inside" && !f && (f = t);
|
|
13489
13639
|
}
|
|
13490
|
-
|
|
13491
|
-
|
|
13492
|
-
|
|
13493
|
-
|
|
13640
|
+
return f || d || a;
|
|
13641
|
+
}
|
|
13642
|
+
function Ss({ target: e, snapGuards: t }) {
|
|
13643
|
+
return ws({
|
|
13644
|
+
target: e,
|
|
13645
|
+
snapGuards: t
|
|
13646
|
+
}) ? !Ts({
|
|
13647
|
+
target: e,
|
|
13648
|
+
snapGuards: t
|
|
13649
|
+
}) : !1;
|
|
13650
|
+
}
|
|
13651
|
+
function Cs({ target: e, snapGuards: t }) {
|
|
13652
|
+
if (ws({
|
|
13653
|
+
target: e,
|
|
13654
|
+
snapGuards: t
|
|
13655
|
+
})) return !1;
|
|
13656
|
+
let n = W({ object: e });
|
|
13657
|
+
if (!n) return !1;
|
|
13658
|
+
for (let e of t) if (!ks({ snapGuard: e }) || !Rs({
|
|
13659
|
+
bounds: n,
|
|
13660
|
+
snapGuard: e
|
|
13661
|
+
}) || !As({
|
|
13662
|
+
bounds: n,
|
|
13663
|
+
snapGuard: e
|
|
13664
|
+
})) return !1;
|
|
13665
|
+
return !0;
|
|
13666
|
+
}
|
|
13667
|
+
function ws({ target: e, snapGuards: t }) {
|
|
13668
|
+
if (typeof e.getObjectDisplaySize != "function") return !1;
|
|
13669
|
+
let n = e, r = t.some((e) => e.type === "vertical" && !Os({ scale: n.cropSourceScaleX })), i = t.some((e) => e.type === "horizontal" && !Os({ scale: n.cropSourceScaleY }));
|
|
13670
|
+
return r || i;
|
|
13671
|
+
}
|
|
13672
|
+
function Ts({ target: e, snapGuards: t }) {
|
|
13673
|
+
let { cropSource: n } = e;
|
|
13674
|
+
if (!n) return !1;
|
|
13675
|
+
let r = W({ object: n });
|
|
13676
|
+
return r ? t.some((e) => Es({
|
|
13677
|
+
snapGuard: e,
|
|
13678
|
+
sourceBounds: r
|
|
13679
|
+
})) : !1;
|
|
13680
|
+
}
|
|
13681
|
+
function Es({ snapGuard: e, sourceBounds: t }) {
|
|
13682
|
+
let { edge: n, position: r } = e, i = t.bottom;
|
|
13683
|
+
return n === "left" && (i = t.left), n === "right" && (i = t.right), n === "top" && (i = t.top), Ds({
|
|
13684
|
+
position: r,
|
|
13685
|
+
boundary: i
|
|
13686
|
+
});
|
|
13687
|
+
}
|
|
13688
|
+
function Ds({ position: e, boundary: t }) {
|
|
13689
|
+
return Math.abs(e - t) <= as;
|
|
13690
|
+
}
|
|
13691
|
+
function Os({ scale: e }) {
|
|
13692
|
+
return Math.abs(Math.abs(e ?? 1) - 1) <= os;
|
|
13693
|
+
}
|
|
13694
|
+
function ks({ snapGuard: e }) {
|
|
13695
|
+
let t = Math.round(e.position);
|
|
13696
|
+
return Math.abs(e.position - t) <= is;
|
|
13697
|
+
}
|
|
13698
|
+
function As({ bounds: e, snapGuard: t }) {
|
|
13699
|
+
let n = t.type === "vertical" ? e.right - e.left : e.bottom - e.top;
|
|
13700
|
+
return !Number.isFinite(n) || n <= 0 ? !1 : Math.round(n) > 0;
|
|
13701
|
+
}
|
|
13702
|
+
function js({ rawScaleX: e, rawScaleY: t, effectiveWidth: n, effectiveHeight: r, isUniform: i }) {
|
|
13703
|
+
let a = Ms({
|
|
13704
|
+
rawScale: e,
|
|
13705
|
+
effectiveSize: n
|
|
13706
|
+
}), o = Ms({
|
|
13707
|
+
rawScale: t,
|
|
13708
|
+
effectiveSize: r
|
|
13709
|
+
});
|
|
13710
|
+
return i ? Ps({
|
|
13711
|
+
scaleXCandidates: a,
|
|
13712
|
+
scaleYCandidates: o,
|
|
13713
|
+
rawScale: e
|
|
13714
|
+
}) : Fs({
|
|
13715
|
+
scaleXCandidates: a,
|
|
13716
|
+
scaleYCandidates: o,
|
|
13717
|
+
rawScaleX: e,
|
|
13718
|
+
rawScaleY: t
|
|
13719
|
+
});
|
|
13720
|
+
}
|
|
13721
|
+
function Ms({ rawScale: e, effectiveSize: t }) {
|
|
13722
|
+
if (t <= 0) return [e];
|
|
13723
|
+
let n = e < 0 ? -1 : 1, r = Math.abs(e) * t, i = Math.round(r), a = Math.floor(r), o = Math.ceil(r), s = [
|
|
13724
|
+
i,
|
|
13725
|
+
a,
|
|
13726
|
+
o,
|
|
13727
|
+
a - 1,
|
|
13728
|
+
o + 1
|
|
13729
|
+
], c = [];
|
|
13730
|
+
for (let e of s) Ns({
|
|
13731
|
+
candidates: c,
|
|
13732
|
+
scale: Math.max(1, e) / t * n
|
|
13733
|
+
});
|
|
13734
|
+
return c.sort((t, n) => Math.abs(t - e) - Math.abs(n - e)), c;
|
|
13735
|
+
}
|
|
13736
|
+
function Ns({ candidates: e, scale: t }) {
|
|
13737
|
+
Number.isFinite(t) && (e.includes(t) || e.push(t));
|
|
13738
|
+
}
|
|
13739
|
+
function Ps({ scaleXCandidates: e, scaleYCandidates: t, rawScale: n }) {
|
|
13740
|
+
let r = [...e];
|
|
13741
|
+
for (let e of t) Ns({
|
|
13742
|
+
candidates: r,
|
|
13743
|
+
scale: e
|
|
13744
|
+
});
|
|
13745
|
+
return r.sort((e, t) => Math.abs(e - n) - Math.abs(t - n)), r.map((e) => ({
|
|
13746
|
+
scaleX: e,
|
|
13747
|
+
scaleY: e
|
|
13748
|
+
}));
|
|
13749
|
+
}
|
|
13750
|
+
function Fs({ scaleXCandidates: e, scaleYCandidates: t, rawScaleX: n, rawScaleY: r }) {
|
|
13751
|
+
let i = [];
|
|
13752
|
+
for (let n of e) for (let e of t) i.push({
|
|
13753
|
+
scaleX: n,
|
|
13754
|
+
scaleY: e
|
|
13755
|
+
});
|
|
13756
|
+
return i.sort((e, t) => Math.abs(e.scaleX - n) + Math.abs(e.scaleY - r) - (Math.abs(t.scaleX - n) + Math.abs(t.scaleY - r))), i;
|
|
13757
|
+
}
|
|
13758
|
+
function Is({ target: e, candidate: t, preservePlacement: n, snapGuards: r }) {
|
|
13759
|
+
let i = e.scaleX ?? 1, a = e.scaleY ?? 1, o = null;
|
|
13760
|
+
try {
|
|
13761
|
+
e.set({
|
|
13762
|
+
scaleX: t.scaleX,
|
|
13763
|
+
scaleY: t.scaleY
|
|
13764
|
+
}), n ? n.applyPlacement(n.placement) : e.setCoords(), o = W({ object: e });
|
|
13765
|
+
} finally {
|
|
13766
|
+
e.set({
|
|
13767
|
+
scaleX: i,
|
|
13768
|
+
scaleY: a
|
|
13769
|
+
}), n ? n.applyPlacement(n.placement) : e.setCoords();
|
|
13770
|
+
}
|
|
13771
|
+
if (!o) return "outside";
|
|
13772
|
+
let s = !0;
|
|
13773
|
+
for (let e of r) {
|
|
13774
|
+
if (!Ls({
|
|
13775
|
+
bounds: o,
|
|
13776
|
+
snapGuard: e
|
|
13777
|
+
})) return "outside";
|
|
13778
|
+
Rs({
|
|
13779
|
+
bounds: o,
|
|
13780
|
+
snapGuard: e
|
|
13781
|
+
}) || (s = !1);
|
|
13782
|
+
}
|
|
13783
|
+
return s ? "on-guide" : "inside";
|
|
13784
|
+
}
|
|
13785
|
+
function Ls({ bounds: e, snapGuard: t }) {
|
|
13786
|
+
let { edge: n, position: r } = t;
|
|
13787
|
+
return n === "left" ? e.left >= r - as : n === "right" ? e.right <= r + as : n === "top" ? e.top >= r - as : e.bottom <= r + as;
|
|
13788
|
+
}
|
|
13789
|
+
function Rs({ bounds: e, snapGuard: t }) {
|
|
13790
|
+
let { edge: n, position: r } = t;
|
|
13791
|
+
return n === "left" ? Math.abs(e.left - r) <= as : n === "right" ? Math.abs(e.right - r) <= as : n === "top" ? Math.abs(e.top - r) <= as : Math.abs(e.bottom - r) <= as;
|
|
13494
13792
|
}
|
|
13495
13793
|
//#endregion
|
|
13496
13794
|
//#region src/editor/snapping-manager/scaling.ts
|
|
13497
|
-
|
|
13795
|
+
var zs = 1e-6;
|
|
13796
|
+
function Bs({ transform: e }) {
|
|
13498
13797
|
let { corner: t = "", action: n = "" } = e, r = t === "ml" || t === "mr" || n === "scaleX", i = t === "mt" || t === "mb" || n === "scaleY", a = t === "tl" || t === "tr" || t === "bl" || t === "br" || n === "scale";
|
|
13499
13798
|
return {
|
|
13500
13799
|
isCornerHandle: a,
|
|
@@ -13502,7 +13801,7 @@ function ls({ transform: e }) {
|
|
|
13502
13801
|
shouldSnapY: i || a
|
|
13503
13802
|
};
|
|
13504
13803
|
}
|
|
13505
|
-
function
|
|
13804
|
+
function Vs({ target: e, transform: t }) {
|
|
13506
13805
|
let { originX: n, originY: r } = t, { originX: i = "left", originY: a = "top", scaleX: o = 1, scaleY: s = 1 } = e;
|
|
13507
13806
|
return {
|
|
13508
13807
|
originX: n ?? i,
|
|
@@ -13511,43 +13810,46 @@ function us({ target: e, transform: t }) {
|
|
|
13511
13810
|
scaleY: s
|
|
13512
13811
|
};
|
|
13513
13812
|
}
|
|
13514
|
-
function
|
|
13515
|
-
if (n) return !0;
|
|
13813
|
+
function Hs({ target: e, event: t, isCornerHandle: n }) {
|
|
13516
13814
|
let r = e;
|
|
13517
|
-
if (
|
|
13518
|
-
|
|
13519
|
-
|
|
13815
|
+
if (r.cropSource) {
|
|
13816
|
+
let e = r.preserveAspectRatio ?? !0;
|
|
13817
|
+
return t.e?.shiftKey ? !e : e;
|
|
13818
|
+
}
|
|
13819
|
+
return n;
|
|
13520
13820
|
}
|
|
13521
|
-
function
|
|
13522
|
-
let
|
|
13821
|
+
function Us({ bounds: e, corner: t, originX: n, originY: r, shouldSnapX: i, shouldSnapY: a, threshold: o, anchors: s }) {
|
|
13822
|
+
let c = Xs({
|
|
13523
13823
|
bounds: e,
|
|
13524
|
-
|
|
13525
|
-
|
|
13526
|
-
|
|
13824
|
+
corner: t,
|
|
13825
|
+
originX: n,
|
|
13826
|
+
shouldSnapX: i
|
|
13827
|
+
}), l = Zs({
|
|
13527
13828
|
bounds: e,
|
|
13528
|
-
|
|
13529
|
-
|
|
13530
|
-
|
|
13531
|
-
|
|
13532
|
-
|
|
13533
|
-
threshold: a
|
|
13534
|
-
}), u = xs({
|
|
13535
|
-
anchors: o.horizontal,
|
|
13829
|
+
corner: t,
|
|
13830
|
+
originY: r,
|
|
13831
|
+
shouldSnapY: a
|
|
13832
|
+
}), u = ec({
|
|
13833
|
+
anchors: s.vertical,
|
|
13536
13834
|
candidates: c,
|
|
13537
|
-
threshold:
|
|
13835
|
+
threshold: o
|
|
13836
|
+
}), d = ec({
|
|
13837
|
+
anchors: s.horizontal,
|
|
13838
|
+
candidates: l,
|
|
13839
|
+
threshold: o
|
|
13538
13840
|
});
|
|
13539
|
-
return
|
|
13540
|
-
verticalSnap:
|
|
13541
|
-
horizontalSnap:
|
|
13841
|
+
return u.guidePosition === null && d.guidePosition === null ? null : {
|
|
13842
|
+
verticalSnap: u,
|
|
13843
|
+
horizontalSnap: d
|
|
13542
13844
|
};
|
|
13543
13845
|
}
|
|
13544
|
-
function
|
|
13545
|
-
return e.shouldUseUniformScaleSnap ?
|
|
13846
|
+
function Ws(e) {
|
|
13847
|
+
return e.shouldUseUniformScaleSnap ? Ks(e) : qs(e);
|
|
13546
13848
|
}
|
|
13547
|
-
function
|
|
13548
|
-
let a =
|
|
13849
|
+
function Gs({ target: e, bounds: t, originX: n, verticalAnchors: r, threshold: i }) {
|
|
13850
|
+
let a = ec({
|
|
13549
13851
|
anchors: r,
|
|
13550
|
-
candidates:
|
|
13852
|
+
candidates: Xs({
|
|
13551
13853
|
bounds: t,
|
|
13552
13854
|
originX: n,
|
|
13553
13855
|
shouldSnapX: !0
|
|
@@ -13555,13 +13857,13 @@ function ms({ target: e, bounds: t, originX: n, verticalAnchors: r, threshold: i
|
|
|
13555
13857
|
threshold: i
|
|
13556
13858
|
}), { guidePosition: o } = a;
|
|
13557
13859
|
if (o === null) return null;
|
|
13558
|
-
let s =
|
|
13860
|
+
let s = lc({
|
|
13559
13861
|
bounds: t,
|
|
13560
13862
|
originX: n,
|
|
13561
13863
|
snap: a
|
|
13562
13864
|
});
|
|
13563
13865
|
if (s === null) return null;
|
|
13564
|
-
let c =
|
|
13866
|
+
let c = mc({
|
|
13565
13867
|
target: e,
|
|
13566
13868
|
boundsWidth: s
|
|
13567
13869
|
});
|
|
@@ -13573,8 +13875,8 @@ function ms({ target: e, bounds: t, originX: n, verticalAnchors: r, threshold: i
|
|
|
13573
13875
|
}
|
|
13574
13876
|
};
|
|
13575
13877
|
}
|
|
13576
|
-
function
|
|
13577
|
-
let s =
|
|
13878
|
+
function Ks({ bounds: e, originX: t, originY: n, scaleX: r, scaleY: i, verticalSnap: a, horizontalSnap: o }) {
|
|
13879
|
+
let s = tc({
|
|
13578
13880
|
bounds: e,
|
|
13579
13881
|
originX: t,
|
|
13580
13882
|
originY: n,
|
|
@@ -13582,108 +13884,138 @@ function hs({ bounds: e, originX: t, originY: n, scaleX: r, scaleY: i, verticalS
|
|
|
13582
13884
|
horizontalSnap: o
|
|
13583
13885
|
});
|
|
13584
13886
|
if (!s) return null;
|
|
13585
|
-
let { guide: c, scaleFactor: l } = s;
|
|
13887
|
+
let { guide: c, scaleFactor: l, snapGuards: u } = s;
|
|
13586
13888
|
return {
|
|
13587
13889
|
guides: [c],
|
|
13890
|
+
snapGuards: u,
|
|
13588
13891
|
nextScaleX: r * l,
|
|
13589
13892
|
nextScaleY: i * l
|
|
13590
13893
|
};
|
|
13591
13894
|
}
|
|
13592
|
-
function
|
|
13593
|
-
let t =
|
|
13895
|
+
function qs(e) {
|
|
13896
|
+
let t = Js(e), n = Ys(e);
|
|
13594
13897
|
if (!t && !n) return null;
|
|
13595
|
-
let r = [], i =
|
|
13596
|
-
return t && (r.push(t.guide), i = t.nextScale), n && (r.push(n.guide),
|
|
13898
|
+
let r = [], i = [], a = null, o = null;
|
|
13899
|
+
return t && (r.push(t.guide), i.push(t.snapGuard), a = t.nextScale), n && (r.push(n.guide), i.push(n.snapGuard), o = n.nextScale), {
|
|
13597
13900
|
guides: r,
|
|
13598
|
-
|
|
13599
|
-
|
|
13901
|
+
snapGuards: i,
|
|
13902
|
+
nextScaleX: a,
|
|
13903
|
+
nextScaleY: o
|
|
13600
13904
|
};
|
|
13601
13905
|
}
|
|
13602
|
-
function
|
|
13906
|
+
function Js({ target: e, bounds: t, originX: n, scaleX: r, scaleY: i, verticalSnap: a }) {
|
|
13603
13907
|
let { guidePosition: o } = a;
|
|
13604
13908
|
if (o === null) return null;
|
|
13605
|
-
let s =
|
|
13909
|
+
let s = lc({
|
|
13606
13910
|
bounds: t,
|
|
13607
13911
|
originX: n,
|
|
13608
13912
|
snap: a
|
|
13609
13913
|
});
|
|
13610
13914
|
if (s === null) return null;
|
|
13611
|
-
let { angle: c = 0 } = e, { width: l, height: u } =
|
|
13915
|
+
let { angle: c = 0 } = e, { width: l, height: u } = dc({ target: e }), d = fc({
|
|
13612
13916
|
desiredWidth: s,
|
|
13613
13917
|
baseWidth: l,
|
|
13614
13918
|
baseHeight: u,
|
|
13615
13919
|
scaleY: Math.abs(i) || 1,
|
|
13616
13920
|
angle: c
|
|
13617
13921
|
});
|
|
13618
|
-
|
|
13922
|
+
if (d === null) return null;
|
|
13923
|
+
let f = ac({
|
|
13924
|
+
type: "vertical",
|
|
13925
|
+
snap: a
|
|
13926
|
+
});
|
|
13927
|
+
return f ? {
|
|
13619
13928
|
nextScale: d * (r < 0 ? -1 : 1),
|
|
13929
|
+
snapGuard: f,
|
|
13620
13930
|
guide: {
|
|
13621
13931
|
type: "vertical",
|
|
13622
13932
|
position: o
|
|
13623
13933
|
}
|
|
13624
|
-
};
|
|
13934
|
+
} : null;
|
|
13625
13935
|
}
|
|
13626
|
-
function
|
|
13936
|
+
function Ys({ target: e, bounds: t, originY: n, scaleX: r, scaleY: i, horizontalSnap: a }) {
|
|
13627
13937
|
let { guidePosition: o } = a;
|
|
13628
13938
|
if (o === null) return null;
|
|
13629
|
-
let s =
|
|
13939
|
+
let s = uc({
|
|
13630
13940
|
bounds: t,
|
|
13631
13941
|
originY: n,
|
|
13632
13942
|
snap: a
|
|
13633
13943
|
});
|
|
13634
13944
|
if (s === null) return null;
|
|
13635
|
-
let { angle: c = 0 } = e, { width: l, height: u } =
|
|
13945
|
+
let { angle: c = 0 } = e, { width: l, height: u } = dc({ target: e }), d = pc({
|
|
13636
13946
|
desiredHeight: s,
|
|
13637
13947
|
baseWidth: l,
|
|
13638
13948
|
baseHeight: u,
|
|
13639
13949
|
scaleX: Math.abs(r) || 1,
|
|
13640
13950
|
angle: c
|
|
13641
13951
|
});
|
|
13642
|
-
|
|
13952
|
+
if (d === null) return null;
|
|
13953
|
+
let f = ac({
|
|
13954
|
+
type: "horizontal",
|
|
13955
|
+
snap: a
|
|
13956
|
+
});
|
|
13957
|
+
return f ? {
|
|
13643
13958
|
nextScale: d * (i < 0 ? -1 : 1),
|
|
13959
|
+
snapGuard: f,
|
|
13644
13960
|
guide: {
|
|
13645
13961
|
type: "horizontal",
|
|
13646
13962
|
position: o
|
|
13647
13963
|
}
|
|
13648
|
-
};
|
|
13964
|
+
} : null;
|
|
13649
13965
|
}
|
|
13650
|
-
function
|
|
13651
|
-
let
|
|
13652
|
-
if (!
|
|
13653
|
-
let { left:
|
|
13654
|
-
|
|
13966
|
+
function Xs({ bounds: e, corner: t = "", originX: n, shouldSnapX: r }) {
|
|
13967
|
+
let i = [];
|
|
13968
|
+
if (!r) return i;
|
|
13969
|
+
let { left: a, right: o } = e, s = "left";
|
|
13970
|
+
(n === "center" || n === "right") && (s = n);
|
|
13971
|
+
let c = Qs({ controlKey: t });
|
|
13972
|
+
return c && s !== "center" ? (i.push({
|
|
13973
|
+
edge: c,
|
|
13974
|
+
position: c === "left" ? a : o
|
|
13975
|
+
}), i) : (s === "left" && i.push({
|
|
13655
13976
|
edge: "right",
|
|
13656
|
-
position:
|
|
13657
|
-
}),
|
|
13977
|
+
position: o
|
|
13978
|
+
}), s === "right" && i.push({
|
|
13658
13979
|
edge: "left",
|
|
13659
|
-
position:
|
|
13660
|
-
}),
|
|
13980
|
+
position: a
|
|
13981
|
+
}), s === "center" && (i.push({
|
|
13661
13982
|
edge: "left",
|
|
13662
|
-
position: i
|
|
13663
|
-
}), r.push({
|
|
13664
|
-
edge: "right",
|
|
13665
13983
|
position: a
|
|
13666
|
-
})
|
|
13984
|
+
}), i.push({
|
|
13985
|
+
edge: "right",
|
|
13986
|
+
position: o
|
|
13987
|
+
})), i);
|
|
13667
13988
|
}
|
|
13668
|
-
function
|
|
13669
|
-
let
|
|
13670
|
-
if (!
|
|
13671
|
-
let { top:
|
|
13672
|
-
|
|
13989
|
+
function Zs({ bounds: e, corner: t = "", originY: n, shouldSnapY: r }) {
|
|
13990
|
+
let i = [];
|
|
13991
|
+
if (!r) return i;
|
|
13992
|
+
let { top: a, bottom: o } = e, s = "top";
|
|
13993
|
+
(n === "center" || n === "bottom") && (s = n);
|
|
13994
|
+
let c = $s({ controlKey: t });
|
|
13995
|
+
return c && s !== "center" ? (i.push({
|
|
13996
|
+
edge: c,
|
|
13997
|
+
position: c === "top" ? a : o
|
|
13998
|
+
}), i) : (s === "top" && i.push({
|
|
13673
13999
|
edge: "bottom",
|
|
13674
|
-
position:
|
|
13675
|
-
}),
|
|
14000
|
+
position: o
|
|
14001
|
+
}), s === "bottom" && i.push({
|
|
13676
14002
|
edge: "top",
|
|
13677
|
-
position:
|
|
13678
|
-
}),
|
|
14003
|
+
position: a
|
|
14004
|
+
}), s === "center" && (i.push({
|
|
13679
14005
|
edge: "top",
|
|
13680
|
-
position: i
|
|
13681
|
-
}), r.push({
|
|
13682
|
-
edge: "bottom",
|
|
13683
14006
|
position: a
|
|
13684
|
-
})
|
|
14007
|
+
}), i.push({
|
|
14008
|
+
edge: "bottom",
|
|
14009
|
+
position: o
|
|
14010
|
+
})), i);
|
|
13685
14011
|
}
|
|
13686
|
-
function
|
|
14012
|
+
function Qs({ controlKey: e }) {
|
|
14013
|
+
return e === "tl" || e === "bl" || e === "ml" ? "left" : e === "tr" || e === "br" || e === "mr" ? "right" : null;
|
|
14014
|
+
}
|
|
14015
|
+
function $s({ controlKey: e }) {
|
|
14016
|
+
return e === "tl" || e === "tr" || e === "mt" ? "top" : e === "bl" || e === "br" || e === "mb" ? "bottom" : null;
|
|
14017
|
+
}
|
|
14018
|
+
function ec({ anchors: e, candidates: t, threshold: n }) {
|
|
13687
14019
|
let r = 0, i = n + 1, a = null, o = null;
|
|
13688
14020
|
for (let s of t) {
|
|
13689
14021
|
let { position: t } = s;
|
|
@@ -13698,39 +14030,95 @@ function xs({ anchors: e, candidates: t, threshold: n }) {
|
|
|
13698
14030
|
candidate: o
|
|
13699
14031
|
};
|
|
13700
14032
|
}
|
|
13701
|
-
function
|
|
13702
|
-
let a =
|
|
14033
|
+
function tc({ bounds: e, originX: t, originY: n, verticalSnap: r, horizontalSnap: i }) {
|
|
14034
|
+
let a = oc({
|
|
13703
14035
|
bounds: e,
|
|
13704
14036
|
originX: t,
|
|
13705
14037
|
snap: r
|
|
13706
|
-
}), o =
|
|
14038
|
+
}), o = sc({
|
|
13707
14039
|
bounds: e,
|
|
13708
14040
|
originY: n,
|
|
13709
14041
|
snap: i
|
|
13710
|
-
}), s =
|
|
14042
|
+
}), s = cc({
|
|
13711
14043
|
scaleFactorX: a,
|
|
13712
14044
|
scaleFactorY: o,
|
|
13713
14045
|
verticalSnap: r,
|
|
13714
14046
|
horizontalSnap: i
|
|
13715
|
-
});
|
|
13716
|
-
|
|
14047
|
+
}), c = null;
|
|
14048
|
+
if (s === "x" && (c = nc({
|
|
14049
|
+
type: "vertical",
|
|
13717
14050
|
scaleFactor: a,
|
|
13718
|
-
|
|
13719
|
-
|
|
13720
|
-
|
|
13721
|
-
}
|
|
13722
|
-
} : s === "y" && o !== null && i.guidePosition !== null ? {
|
|
14051
|
+
snap: r
|
|
14052
|
+
})), s === "y" && (c = nc({
|
|
14053
|
+
type: "horizontal",
|
|
13723
14054
|
scaleFactor: o,
|
|
14055
|
+
snap: i
|
|
14056
|
+
})), !c) return null;
|
|
14057
|
+
let l = rc({
|
|
14058
|
+
scaleFactor: c.scaleFactor,
|
|
14059
|
+
scaleFactorX: a,
|
|
14060
|
+
scaleFactorY: o,
|
|
14061
|
+
verticalSnap: r,
|
|
14062
|
+
horizontalSnap: i
|
|
14063
|
+
});
|
|
14064
|
+
return l.length === 0 ? null : {
|
|
14065
|
+
guide: c.guide,
|
|
14066
|
+
snapGuards: l,
|
|
14067
|
+
scaleFactor: c.scaleFactor
|
|
14068
|
+
};
|
|
14069
|
+
}
|
|
14070
|
+
function nc({ type: e, scaleFactor: t, snap: n }) {
|
|
14071
|
+
let { guidePosition: r } = n;
|
|
14072
|
+
if (t === null || r === null) return null;
|
|
14073
|
+
let i = ac({
|
|
14074
|
+
type: e,
|
|
14075
|
+
snap: n
|
|
14076
|
+
});
|
|
14077
|
+
return i ? {
|
|
14078
|
+
scaleFactor: t,
|
|
14079
|
+
snapGuard: i,
|
|
13724
14080
|
guide: {
|
|
13725
|
-
type:
|
|
13726
|
-
position:
|
|
14081
|
+
type: e,
|
|
14082
|
+
position: r
|
|
13727
14083
|
}
|
|
13728
14084
|
} : null;
|
|
13729
14085
|
}
|
|
13730
|
-
function
|
|
14086
|
+
function rc({ scaleFactor: e, scaleFactorX: t, scaleFactorY: n, verticalSnap: r, horizontalSnap: i }) {
|
|
14087
|
+
let a = [];
|
|
14088
|
+
return ic({
|
|
14089
|
+
snapGuards: a,
|
|
14090
|
+
scaleFactor: e,
|
|
14091
|
+
axisScaleFactor: t,
|
|
14092
|
+
type: "vertical",
|
|
14093
|
+
snap: r
|
|
14094
|
+
}), ic({
|
|
14095
|
+
snapGuards: a,
|
|
14096
|
+
scaleFactor: e,
|
|
14097
|
+
axisScaleFactor: n,
|
|
14098
|
+
type: "horizontal",
|
|
14099
|
+
snap: i
|
|
14100
|
+
}), a;
|
|
14101
|
+
}
|
|
14102
|
+
function ic({ snapGuards: e, scaleFactor: t, axisScaleFactor: n, type: r, snap: i }) {
|
|
14103
|
+
if (n === null || Math.abs(n - t) > zs) return;
|
|
14104
|
+
let a = ac({
|
|
14105
|
+
type: r,
|
|
14106
|
+
snap: i
|
|
14107
|
+
});
|
|
14108
|
+
a && e.push(a);
|
|
14109
|
+
}
|
|
14110
|
+
function ac({ type: e, snap: t }) {
|
|
14111
|
+
let { candidate: n, guidePosition: r } = t;
|
|
14112
|
+
return !n || r === null ? null : {
|
|
14113
|
+
type: e,
|
|
14114
|
+
edge: n.edge,
|
|
14115
|
+
position: r
|
|
14116
|
+
};
|
|
14117
|
+
}
|
|
14118
|
+
function oc({ bounds: e, originX: t, snap: n }) {
|
|
13731
14119
|
let { left: r, right: i } = e, a = i - r;
|
|
13732
14120
|
if (n.guidePosition === null || a <= 0) return null;
|
|
13733
|
-
let o =
|
|
14121
|
+
let o = lc({
|
|
13734
14122
|
bounds: e,
|
|
13735
14123
|
originX: t,
|
|
13736
14124
|
snap: n
|
|
@@ -13739,10 +14127,10 @@ function Cs({ bounds: e, originX: t, snap: n }) {
|
|
|
13739
14127
|
let s = o / a;
|
|
13740
14128
|
return !Number.isFinite(s) || s <= 0 ? null : s;
|
|
13741
14129
|
}
|
|
13742
|
-
function
|
|
14130
|
+
function sc({ bounds: e, originY: t, snap: n }) {
|
|
13743
14131
|
let { top: r, bottom: i } = e, a = i - r;
|
|
13744
14132
|
if (n.guidePosition === null || a <= 0) return null;
|
|
13745
|
-
let o =
|
|
14133
|
+
let o = uc({
|
|
13746
14134
|
bounds: e,
|
|
13747
14135
|
originY: t,
|
|
13748
14136
|
snap: n
|
|
@@ -13751,26 +14139,26 @@ function ws({ bounds: e, originY: t, snap: n }) {
|
|
|
13751
14139
|
let s = o / a;
|
|
13752
14140
|
return !Number.isFinite(s) || s <= 0 ? null : s;
|
|
13753
14141
|
}
|
|
13754
|
-
function
|
|
14142
|
+
function cc({ scaleFactorX: e, scaleFactorY: t, verticalSnap: n, horizontalSnap: r }) {
|
|
13755
14143
|
return e !== null && t === null ? "x" : t !== null && e === null ? "y" : e === null || t === null ? null : Math.abs(n.delta) <= Math.abs(r.delta) ? "x" : "y";
|
|
13756
14144
|
}
|
|
13757
|
-
function
|
|
14145
|
+
function lc({ bounds: e, originX: t, snap: n }) {
|
|
13758
14146
|
let { left: r, right: i, centerX: a } = e, { candidate: o, guidePosition: s } = n;
|
|
13759
14147
|
if (!o || s === null) return null;
|
|
13760
14148
|
let c = "left";
|
|
13761
14149
|
(t === "center" || t === "right") && (c = t);
|
|
13762
14150
|
let { edge: l } = o, u = null;
|
|
13763
|
-
return c
|
|
14151
|
+
return c !== "center" && l === "left" && (u = i - s), c !== "center" && l === "right" && (u = s - r), c === "center" && l === "left" && (u = (a - s) * 2), c === "center" && l === "right" && (u = (s - a) * 2), u === null || !Number.isFinite(u) || u <= 0 ? null : u;
|
|
13764
14152
|
}
|
|
13765
|
-
function
|
|
14153
|
+
function uc({ bounds: e, originY: t, snap: n }) {
|
|
13766
14154
|
let { top: r, bottom: i, centerY: a } = e, { candidate: o, guidePosition: s } = n;
|
|
13767
14155
|
if (!o || s === null) return null;
|
|
13768
14156
|
let c = "top";
|
|
13769
14157
|
(t === "center" || t === "bottom") && (c = t);
|
|
13770
14158
|
let { edge: l } = o, u = null;
|
|
13771
|
-
return c
|
|
14159
|
+
return c !== "center" && l === "top" && (u = i - s), c !== "center" && l === "bottom" && (u = s - r), c === "center" && l === "top" && (u = (a - s) * 2), c === "center" && l === "bottom" && (u = (s - a) * 2), u === null || !Number.isFinite(u) || u <= 0 ? null : u;
|
|
13772
14160
|
}
|
|
13773
|
-
function
|
|
14161
|
+
function dc({ target: e }) {
|
|
13774
14162
|
let { width: t = 0, height: n = 0 } = e, r = t, i = n;
|
|
13775
14163
|
if (e instanceof v) {
|
|
13776
14164
|
let { paddingTop: a = 0, paddingRight: o = 0, paddingBottom: s = 0, paddingLeft: c = 0, strokeWidth: l = 0 } = e;
|
|
@@ -13781,28 +14169,28 @@ function Os({ target: e }) {
|
|
|
13781
14169
|
height: i
|
|
13782
14170
|
};
|
|
13783
14171
|
}
|
|
13784
|
-
function
|
|
14172
|
+
function fc({ desiredWidth: e, baseWidth: t, baseHeight: n, scaleY: r, angle: i }) {
|
|
13785
14173
|
let a = i * Math.PI / 180, o = Math.abs(Math.cos(a)), s = Math.abs(Math.sin(a)), c = t * o, l = n * r * s;
|
|
13786
14174
|
if (c <= 0) return null;
|
|
13787
14175
|
let u = (e - l) / c;
|
|
13788
14176
|
return !Number.isFinite(u) || u <= 0 ? null : u;
|
|
13789
14177
|
}
|
|
13790
|
-
function
|
|
14178
|
+
function pc({ desiredHeight: e, baseWidth: t, baseHeight: n, scaleX: r, angle: i }) {
|
|
13791
14179
|
let a = i * Math.PI / 180, o = Math.abs(Math.cos(a)), s = Math.abs(Math.sin(a)), c = n * o, l = t * r * s;
|
|
13792
14180
|
if (c <= 0) return null;
|
|
13793
14181
|
let u = (e - l) / c;
|
|
13794
14182
|
return !Number.isFinite(u) || u <= 0 ? null : u;
|
|
13795
14183
|
}
|
|
13796
|
-
function
|
|
14184
|
+
function mc({ target: e, boundsWidth: t }) {
|
|
13797
14185
|
let { paddingLeft: n = 0, paddingRight: r = 0, strokeWidth: i = 0 } = e, a = t - n - r - i;
|
|
13798
14186
|
return !Number.isFinite(a) || a <= 0 ? null : Math.max(1, Math.round(a));
|
|
13799
14187
|
}
|
|
13800
14188
|
//#endregion
|
|
13801
14189
|
//#region src/editor/snapping-manager/utils.ts
|
|
13802
|
-
var
|
|
14190
|
+
var hc = ({ anchors: e, bounds: t }) => {
|
|
13803
14191
|
let { left: n, right: r, centerX: i, top: a, bottom: o, centerY: s } = t;
|
|
13804
14192
|
e.vertical.push(n, i, r), e.horizontal.push(a, s, o);
|
|
13805
|
-
},
|
|
14193
|
+
}, gc = ({ bounds: e, type: t, primaryStart: n, primaryEnd: r }) => {
|
|
13806
14194
|
let i = [], a = n === "top" ? "left" : "top", o = r === "bottom" ? "right" : "bottom", s = [...e].sort((e, t) => e[n] - t[n]);
|
|
13807
14195
|
for (let e = 0; e < s.length; e += 1) {
|
|
13808
14196
|
let c = s[e], l = null, u = Infinity;
|
|
@@ -13823,35 +14211,35 @@ var Ms = ({ anchors: e, bounds: t }) => {
|
|
|
13823
14211
|
});
|
|
13824
14212
|
}
|
|
13825
14213
|
return i;
|
|
13826
|
-
},
|
|
13827
|
-
vertical:
|
|
14214
|
+
}, _c = ({ bounds: e }) => ({
|
|
14215
|
+
vertical: gc({
|
|
13828
14216
|
bounds: e,
|
|
13829
14217
|
axis: "centerX",
|
|
13830
14218
|
type: "vertical",
|
|
13831
14219
|
primaryStart: "top",
|
|
13832
14220
|
primaryEnd: "bottom"
|
|
13833
14221
|
}),
|
|
13834
|
-
horizontal:
|
|
14222
|
+
horizontal: gc({
|
|
13835
14223
|
bounds: e,
|
|
13836
14224
|
axis: "centerY",
|
|
13837
14225
|
type: "horizontal",
|
|
13838
14226
|
primaryStart: "left",
|
|
13839
14227
|
primaryEnd: "right"
|
|
13840
14228
|
})
|
|
13841
|
-
}),
|
|
14229
|
+
}), vc = [
|
|
13842
14230
|
"montage-area",
|
|
13843
14231
|
"background",
|
|
13844
14232
|
"interaction-blocker"
|
|
13845
|
-
],
|
|
14233
|
+
], yc = ({ activeObject: t }) => {
|
|
13846
14234
|
let n = /* @__PURE__ */ new Set();
|
|
13847
14235
|
return t ? (n.add(t), t instanceof e && t.getObjects().forEach((e) => n.add(e)), n) : n;
|
|
13848
|
-
},
|
|
14236
|
+
}, bc = ({ object: e, excluded: t, ignoredIds: n = vc }) => {
|
|
13849
14237
|
if (t.has(e)) return !0;
|
|
13850
14238
|
let { visible: r = !0 } = e;
|
|
13851
14239
|
if (!r) return !0;
|
|
13852
14240
|
let { id: i } = e;
|
|
13853
14241
|
return !!(i && n.includes(i));
|
|
13854
|
-
},
|
|
14242
|
+
}, xc = class {
|
|
13855
14243
|
constructor({ editor: e }) {
|
|
13856
14244
|
this.anchors = {
|
|
13857
14245
|
vertical: [],
|
|
@@ -13895,7 +14283,7 @@ var Ms = ({ anchors: e, bounds: t }) => {
|
|
|
13895
14283
|
target: t,
|
|
13896
14284
|
event: e
|
|
13897
14285
|
})) return;
|
|
13898
|
-
|
|
14286
|
+
cs({
|
|
13899
14287
|
target: t,
|
|
13900
14288
|
transform: n
|
|
13901
14289
|
}), !this.anchors.vertical.length && !this.anchors.horizontal.length && this._cacheAnchors({ activeObject: t });
|
|
@@ -13927,7 +14315,7 @@ var Ms = ({ anchors: e, bounds: t }) => {
|
|
|
13927
14315
|
activeBounds: r,
|
|
13928
14316
|
deltaX: s.deltaX,
|
|
13929
14317
|
deltaY: s.deltaY
|
|
13930
|
-
}), c ||
|
|
14318
|
+
}), c || cs({
|
|
13931
14319
|
target: t,
|
|
13932
14320
|
transform: n
|
|
13933
14321
|
});
|
|
@@ -13944,7 +14332,7 @@ var Ms = ({ anchors: e, bounds: t }) => {
|
|
|
13944
14332
|
this._clearGuides();
|
|
13945
14333
|
return;
|
|
13946
14334
|
}
|
|
13947
|
-
let r =
|
|
14335
|
+
let r = ss({ target: t });
|
|
13948
14336
|
if (this._shouldAbortObjectScaling({
|
|
13949
14337
|
target: t,
|
|
13950
14338
|
transform: n,
|
|
@@ -13954,23 +14342,39 @@ var Ms = ({ anchors: e, bounds: t }) => {
|
|
|
13954
14342
|
this._clearGuides();
|
|
13955
14343
|
return;
|
|
13956
14344
|
}
|
|
13957
|
-
|
|
13958
|
-
|
|
14345
|
+
if (!this._hasObjectScaleChanged({
|
|
14346
|
+
target: t,
|
|
14347
|
+
transform: n
|
|
14348
|
+
})) {
|
|
13959
14349
|
this._clearGuides();
|
|
13960
14350
|
return;
|
|
13961
14351
|
}
|
|
14352
|
+
let { shouldSnapX: i, shouldSnapY: a, isCornerHandle: o } = Bs({ transform: n });
|
|
14353
|
+
if (!i && !a) {
|
|
14354
|
+
this._finishObjectScalingWithoutSnap({
|
|
14355
|
+
target: t,
|
|
14356
|
+
transform: n,
|
|
14357
|
+
canApplyPixelScalingStep: r
|
|
14358
|
+
});
|
|
14359
|
+
return;
|
|
14360
|
+
}
|
|
13962
14361
|
let { anchors: s } = this, { vertical: c, horizontal: l } = s;
|
|
13963
14362
|
!c.length && !l.length && this._cacheAnchors({ activeObject: t });
|
|
13964
14363
|
let u = W({ object: t });
|
|
13965
14364
|
if (!u) {
|
|
13966
|
-
this.
|
|
14365
|
+
this._finishObjectScalingWithoutSnap({
|
|
14366
|
+
target: t,
|
|
14367
|
+
transform: n,
|
|
14368
|
+
canApplyPixelScalingStep: r
|
|
14369
|
+
});
|
|
13967
14370
|
return;
|
|
13968
14371
|
}
|
|
13969
|
-
let d = 5 / (this.canvas.getZoom() || 1), { originX: f, originY: p, scaleX: m, scaleY: h } =
|
|
14372
|
+
let d = 5 / (this.canvas.getZoom() || 1), { originX: f, originY: p, scaleX: m, scaleY: h } = Vs({
|
|
13970
14373
|
target: t,
|
|
13971
14374
|
transform: n
|
|
13972
|
-
}), g =
|
|
14375
|
+
}), g = Us({
|
|
13973
14376
|
bounds: u,
|
|
14377
|
+
corner: n.corner,
|
|
13974
14378
|
originX: f,
|
|
13975
14379
|
originY: p,
|
|
13976
14380
|
shouldSnapX: i,
|
|
@@ -13979,17 +14383,21 @@ var Ms = ({ anchors: e, bounds: t }) => {
|
|
|
13979
14383
|
anchors: this.anchors
|
|
13980
14384
|
});
|
|
13981
14385
|
if (!g) {
|
|
13982
|
-
this.
|
|
14386
|
+
this._finishObjectScalingWithoutSnap({
|
|
14387
|
+
target: t,
|
|
14388
|
+
transform: n,
|
|
14389
|
+
canApplyPixelScalingStep: r
|
|
14390
|
+
});
|
|
13983
14391
|
return;
|
|
13984
14392
|
}
|
|
13985
|
-
let _ =
|
|
14393
|
+
let _ = Ws({
|
|
13986
14394
|
target: t,
|
|
13987
14395
|
bounds: u,
|
|
13988
14396
|
originX: f,
|
|
13989
14397
|
originY: p,
|
|
13990
14398
|
scaleX: m,
|
|
13991
14399
|
scaleY: h,
|
|
13992
|
-
shouldUseUniformScaleSnap:
|
|
14400
|
+
shouldUseUniformScaleSnap: Hs({
|
|
13993
14401
|
target: t,
|
|
13994
14402
|
event: e,
|
|
13995
14403
|
isCornerHandle: o
|
|
@@ -13998,7 +14406,11 @@ var Ms = ({ anchors: e, bounds: t }) => {
|
|
|
13998
14406
|
horizontalSnap: g.horizontalSnap
|
|
13999
14407
|
});
|
|
14000
14408
|
if (!_) {
|
|
14001
|
-
this.
|
|
14409
|
+
this._finishObjectScalingWithoutSnap({
|
|
14410
|
+
target: t,
|
|
14411
|
+
transform: n,
|
|
14412
|
+
canApplyPixelScalingStep: r
|
|
14413
|
+
});
|
|
14002
14414
|
return;
|
|
14003
14415
|
}
|
|
14004
14416
|
this._applyScaleUpdatePlan({
|
|
@@ -14007,10 +14419,24 @@ var Ms = ({ anchors: e, bounds: t }) => {
|
|
|
14007
14419
|
originX: f,
|
|
14008
14420
|
originY: p,
|
|
14009
14421
|
plan: _
|
|
14010
|
-
}), r &&
|
|
14422
|
+
}), r && fs({
|
|
14011
14423
|
target: t,
|
|
14012
|
-
transform: n
|
|
14013
|
-
|
|
14424
|
+
transform: n,
|
|
14425
|
+
preservePlacement: {
|
|
14426
|
+
placement: this.editor.canvasManager.getObjectPlacement({
|
|
14427
|
+
object: t,
|
|
14428
|
+
originX: f,
|
|
14429
|
+
originY: p
|
|
14430
|
+
}),
|
|
14431
|
+
applyPlacement: (e) => {
|
|
14432
|
+
this.editor.canvasManager.applyObjectPlacement({
|
|
14433
|
+
object: t,
|
|
14434
|
+
placement: e
|
|
14435
|
+
});
|
|
14436
|
+
}
|
|
14437
|
+
},
|
|
14438
|
+
snapGuards: _.snapGuards
|
|
14439
|
+
}), !this._shouldHideOverflowingCropFrameGuides({ target: t }) && this._applyGuides({
|
|
14014
14440
|
guides: _.guides,
|
|
14015
14441
|
spacingGuides: []
|
|
14016
14442
|
});
|
|
@@ -14022,13 +14448,23 @@ var Ms = ({ anchors: e, bounds: t }) => {
|
|
|
14022
14448
|
});
|
|
14023
14449
|
}
|
|
14024
14450
|
_shouldAbortObjectScaling({ target: e, transform: t, event: n, canApplyPixelScalingStep: r }) {
|
|
14025
|
-
return
|
|
14451
|
+
return this.editor.cropManager.isFrameSourceScaleClamped({
|
|
14452
|
+
target: e,
|
|
14453
|
+
transform: t
|
|
14454
|
+
}) ? (this._clearGuides(), !0) : n.e?.ctrlKey ? (this._clearGuides(), r && fs({
|
|
14026
14455
|
target: e,
|
|
14027
14456
|
transform: t
|
|
14028
|
-
}), !0) :
|
|
14457
|
+
}), !0) : !1;
|
|
14458
|
+
}
|
|
14459
|
+
_finishObjectScalingWithoutSnap({ target: e, transform: t, canApplyPixelScalingStep: n }) {
|
|
14460
|
+
n && fs({
|
|
14029
14461
|
target: e,
|
|
14030
14462
|
transform: t
|
|
14031
|
-
}), this.
|
|
14463
|
+
}), this._clearGuides();
|
|
14464
|
+
}
|
|
14465
|
+
_hasObjectScaleChanged({ target: e, transform: t }) {
|
|
14466
|
+
let n = t.original?.scaleX, r = t.original?.scaleY;
|
|
14467
|
+
return typeof n != "number" || typeof r != "number" ? !0 : e.scaleX !== n || e.scaleY !== r;
|
|
14032
14468
|
}
|
|
14033
14469
|
_shouldHideOverflowingCropFrameGuides({ target: e, clearSpacingContexts: t = !1 }) {
|
|
14034
14470
|
return this.editor.cropManager.isFrameOverflowingSource({ target: e }) ? (t && this._clearSpacingContexts(), this._clearGuides(), !0) : !1;
|
|
@@ -14106,7 +14542,7 @@ var Ms = ({ anchors: e, bounds: t }) => {
|
|
|
14106
14542
|
this._clearGuides();
|
|
14107
14543
|
return;
|
|
14108
14544
|
}
|
|
14109
|
-
let { canvas: c } = this, l = 5 / (c.getZoom() || 1), { originX: u, originY: d } = t, { originX: f = "left", originY: p = "top" } = e, m = u ?? f, h = d ?? p, g =
|
|
14545
|
+
let { canvas: c } = this, l = 5 / (c.getZoom() || 1), { originX: u, originY: d } = t, { originX: f = "left", originY: p = "top" } = e, m = u ?? f, h = d ?? p, g = Gs({
|
|
14110
14546
|
target: e,
|
|
14111
14547
|
bounds: s,
|
|
14112
14548
|
originX: m,
|
|
@@ -14187,14 +14623,14 @@ var Ms = ({ anchors: e, bounds: t }) => {
|
|
|
14187
14623
|
}, r = [];
|
|
14188
14624
|
for (let e of t) {
|
|
14189
14625
|
let t = W({ object: e });
|
|
14190
|
-
t && (
|
|
14626
|
+
t && (hc({
|
|
14191
14627
|
anchors: n,
|
|
14192
14628
|
bounds: t
|
|
14193
14629
|
}), r.push(t));
|
|
14194
14630
|
}
|
|
14195
14631
|
let { montageArea: i } = this.editor, a = W({ object: i });
|
|
14196
14632
|
if (a) {
|
|
14197
|
-
|
|
14633
|
+
hc({
|
|
14198
14634
|
anchors: n,
|
|
14199
14635
|
bounds: a
|
|
14200
14636
|
});
|
|
@@ -14206,12 +14642,12 @@ var Ms = ({ anchors: e, bounds: t }) => {
|
|
|
14206
14642
|
bottom: i
|
|
14207
14643
|
};
|
|
14208
14644
|
} else this.guideBounds = this._calculateViewportBounds();
|
|
14209
|
-
this.anchors = n, this.spacingPatterns =
|
|
14645
|
+
this.anchors = n, this.spacingPatterns = _c({ bounds: r }), this.cachedTargetBounds = r;
|
|
14210
14646
|
}
|
|
14211
14647
|
_collectTargets({ activeObject: e }) {
|
|
14212
|
-
let t =
|
|
14648
|
+
let t = yc({ activeObject: e }), n = [];
|
|
14213
14649
|
return this.canvas.forEachObject((e) => {
|
|
14214
|
-
|
|
14650
|
+
bc({
|
|
14215
14651
|
object: e,
|
|
14216
14652
|
excluded: t
|
|
14217
14653
|
}) || n.push(e);
|
|
@@ -14234,7 +14670,7 @@ var Ms = ({ anchors: e, bounds: t }) => {
|
|
|
14234
14670
|
bottom: (r - s) / a
|
|
14235
14671
|
};
|
|
14236
14672
|
}
|
|
14237
|
-
},
|
|
14673
|
+
}, Sc = "#3D8BF4", Cc = class e {
|
|
14238
14674
|
constructor({ editor: e }) {
|
|
14239
14675
|
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();
|
|
14240
14676
|
}
|
|
@@ -14327,8 +14763,8 @@ var Ms = ({ anchors: e, bounds: t }) => {
|
|
|
14327
14763
|
this.isTargetMontageArea = l, this.activeGuides = d, this._hideToolbar(), n.requestRenderAll();
|
|
14328
14764
|
}
|
|
14329
14765
|
static _resolveTarget({ event: e, activeObject: t }) {
|
|
14330
|
-
let { target: n } = e, r =
|
|
14331
|
-
return n && !
|
|
14766
|
+
let { target: n } = e, r = yc({ activeObject: t });
|
|
14767
|
+
return n && !bc({
|
|
14332
14768
|
object: n,
|
|
14333
14769
|
excluded: r
|
|
14334
14770
|
}) ? n : null;
|
|
@@ -14445,7 +14881,7 @@ var Ms = ({ anchors: e, bounds: t }) => {
|
|
|
14445
14881
|
let { canvas: e } = this, t = e.getSelectionContext();
|
|
14446
14882
|
if (!t) return;
|
|
14447
14883
|
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;
|
|
14448
|
-
t.save(), Array.isArray(n) && t.transform(...n), t.lineWidth = 1 / r, t.strokeStyle =
|
|
14884
|
+
t.save(), Array.isArray(n) && t.transform(...n), t.lineWidth = 1 / r, t.strokeStyle = Sc, t.setLineDash([]);
|
|
14449
14885
|
for (let e of this.activeGuides) {
|
|
14450
14886
|
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;
|
|
14451
14887
|
t.beginPath(), n === "vertical" ? (t.moveTo(i, a), t.lineTo(i, c)) : (t.moveTo(a, i), t.lineTo(c, i)), t.stroke(), ns({
|
|
@@ -14456,7 +14892,7 @@ var Ms = ({ anchors: e, bounds: t }) => {
|
|
|
14456
14892
|
end: c,
|
|
14457
14893
|
text: To({ distance: l }).toString(),
|
|
14458
14894
|
zoom: r,
|
|
14459
|
-
color:
|
|
14895
|
+
color: Sc,
|
|
14460
14896
|
lineWidth: 1,
|
|
14461
14897
|
offsetAlongAxis: d,
|
|
14462
14898
|
offsetPerpendicular: 0
|
|
@@ -14474,13 +14910,13 @@ var Ms = ({ anchors: e, bounds: t }) => {
|
|
|
14474
14910
|
let { toolbar: e } = this.editor;
|
|
14475
14911
|
e?.showAfterTemporary?.(), this.isToolbarHidden = !1;
|
|
14476
14912
|
}
|
|
14477
|
-
},
|
|
14478
|
-
function
|
|
14479
|
-
return t ?
|
|
14913
|
+
}, wc = 16, Tc = 16, Ec = Gt, Dc = Kt, Oc = wc;
|
|
14914
|
+
function kc({ sourceSize: e, size: t, aspectRatio: n, allowOverflow: r }) {
|
|
14915
|
+
return t ? Ic({
|
|
14480
14916
|
size: t,
|
|
14481
14917
|
sourceSize: e,
|
|
14482
14918
|
allowOverflow: r
|
|
14483
|
-
}) : n ?
|
|
14919
|
+
}) : n ? Fc({
|
|
14484
14920
|
aspectRatio: n,
|
|
14485
14921
|
sourceSize: e
|
|
14486
14922
|
}) : {
|
|
@@ -14494,29 +14930,29 @@ function Z({ source: e }) {
|
|
|
14494
14930
|
height: e.height
|
|
14495
14931
|
};
|
|
14496
14932
|
}
|
|
14497
|
-
function
|
|
14933
|
+
function Ac({ source: e, frame: t }) {
|
|
14498
14934
|
let n = e.calcTransformMatrix(), r = w.invertTransform(n), i = t.calcTransformMatrix();
|
|
14499
|
-
return
|
|
14935
|
+
return Nc({ points: Pc({ frame: t }).map((e) => e.transform(i).transform(r)) });
|
|
14500
14936
|
}
|
|
14501
|
-
function
|
|
14502
|
-
|
|
14937
|
+
function jc({ source: e, frame: t }) {
|
|
14938
|
+
Lc({
|
|
14503
14939
|
source: e,
|
|
14504
14940
|
frame: t
|
|
14505
|
-
}),
|
|
14941
|
+
}), zc({
|
|
14506
14942
|
source: e,
|
|
14507
14943
|
frame: t
|
|
14508
14944
|
});
|
|
14509
14945
|
}
|
|
14510
|
-
function
|
|
14511
|
-
|
|
14946
|
+
function Mc({ source: e, frame: t }) {
|
|
14947
|
+
Rc({
|
|
14512
14948
|
source: e,
|
|
14513
14949
|
frame: t
|
|
14514
|
-
}),
|
|
14950
|
+
}), zc({
|
|
14515
14951
|
source: e,
|
|
14516
14952
|
frame: t
|
|
14517
14953
|
});
|
|
14518
14954
|
}
|
|
14519
|
-
function
|
|
14955
|
+
function Nc({ points: e }) {
|
|
14520
14956
|
let t = Math.min(...e.map((e) => e.x)), n = Math.min(...e.map((e) => e.y)), r = Math.max(...e.map((e) => e.x)), i = Math.max(...e.map((e) => e.y));
|
|
14521
14957
|
return {
|
|
14522
14958
|
left: t,
|
|
@@ -14525,7 +14961,7 @@ function Xs({ points: e }) {
|
|
|
14525
14961
|
height: i - n
|
|
14526
14962
|
};
|
|
14527
14963
|
}
|
|
14528
|
-
function
|
|
14964
|
+
function Pc({ frame: e }) {
|
|
14529
14965
|
let t = e.width / 2, n = e.height / 2;
|
|
14530
14966
|
return [
|
|
14531
14967
|
new m(-t, -n),
|
|
@@ -14534,7 +14970,7 @@ function Zs({ frame: e }) {
|
|
|
14534
14970
|
new m(-t, n)
|
|
14535
14971
|
];
|
|
14536
14972
|
}
|
|
14537
|
-
function
|
|
14973
|
+
function Fc({ sourceSize: e, aspectRatio: t }) {
|
|
14538
14974
|
let n = e.width / e.height, r = t.width / t.height;
|
|
14539
14975
|
return r >= n ? {
|
|
14540
14976
|
width: e.width,
|
|
@@ -14544,49 +14980,49 @@ function Qs({ sourceSize: e, aspectRatio: t }) {
|
|
|
14544
14980
|
height: e.height
|
|
14545
14981
|
};
|
|
14546
14982
|
}
|
|
14547
|
-
function
|
|
14548
|
-
let r = n ?
|
|
14983
|
+
function Ic({ size: e, sourceSize: t, allowOverflow: n }) {
|
|
14984
|
+
let r = n ? Ec : Math.min(t.width, Ec), i = n ? Dc : Math.min(t.height, Dc);
|
|
14549
14985
|
return {
|
|
14550
|
-
width:
|
|
14986
|
+
width: Uc({
|
|
14551
14987
|
value: e.width,
|
|
14552
|
-
min:
|
|
14988
|
+
min: wc,
|
|
14553
14989
|
max: r
|
|
14554
14990
|
}),
|
|
14555
|
-
height:
|
|
14991
|
+
height: Uc({
|
|
14556
14992
|
value: e.height,
|
|
14557
|
-
min:
|
|
14993
|
+
min: Tc,
|
|
14558
14994
|
max: i
|
|
14559
14995
|
})
|
|
14560
14996
|
};
|
|
14561
14997
|
}
|
|
14562
|
-
function
|
|
14563
|
-
let n =
|
|
14998
|
+
function Lc({ source: e, frame: t }) {
|
|
14999
|
+
let n = Ac({
|
|
14564
15000
|
source: e,
|
|
14565
15001
|
frame: t
|
|
14566
|
-
}), r = Z({ source: e }), i = r.width / Math.max(n.width,
|
|
15002
|
+
}), r = Z({ source: e }), i = r.width / Math.max(n.width, wc), a = r.height / Math.max(n.height, Tc);
|
|
14567
15003
|
i < 1 && t.set({ scaleX: (t.scaleX ?? 1) * i }), a < 1 && t.set({ scaleY: (t.scaleY ?? 1) * a }), t.setCoords();
|
|
14568
15004
|
}
|
|
14569
|
-
function
|
|
14570
|
-
let n =
|
|
15005
|
+
function Rc({ source: e, frame: t }) {
|
|
15006
|
+
let n = Ac({
|
|
14571
15007
|
source: e,
|
|
14572
15008
|
frame: t
|
|
14573
|
-
}), r = Z({ source: e }), i = r.width / Math.max(n.width,
|
|
15009
|
+
}), r = Z({ source: e }), i = r.width / Math.max(n.width, wc), a = r.height / Math.max(n.height, Tc), o = Math.min(i, a);
|
|
14574
15010
|
o < 1 && t.set({
|
|
14575
15011
|
scaleX: (t.scaleX ?? 1) * o,
|
|
14576
15012
|
scaleY: (t.scaleY ?? 1) * o
|
|
14577
15013
|
}), t.setCoords();
|
|
14578
15014
|
}
|
|
14579
|
-
function
|
|
14580
|
-
let n =
|
|
15015
|
+
function zc({ source: e, frame: t }) {
|
|
15016
|
+
let n = Ac({
|
|
14581
15017
|
source: e,
|
|
14582
15018
|
frame: t
|
|
14583
|
-
}), r =
|
|
15019
|
+
}), r = Bc({ sourceSize: Z({ source: e }) }), i = Vc({ rect: n }), a = Hc({
|
|
14584
15020
|
rect: n,
|
|
14585
15021
|
sourceBounds: r
|
|
14586
15022
|
}), o = new m(i.x + a.x, i.y + a.y).transform(e.calcTransformMatrix());
|
|
14587
15023
|
t.setPositionByOrigin(o, "center", "center"), t.setCoords();
|
|
14588
15024
|
}
|
|
14589
|
-
function
|
|
15025
|
+
function Bc({ sourceSize: e }) {
|
|
14590
15026
|
return {
|
|
14591
15027
|
left: -e.width / 2,
|
|
14592
15028
|
top: -e.height / 2,
|
|
@@ -14594,19 +15030,19 @@ function rc({ sourceSize: e }) {
|
|
|
14594
15030
|
height: e.height
|
|
14595
15031
|
};
|
|
14596
15032
|
}
|
|
14597
|
-
function
|
|
15033
|
+
function Vc({ rect: e }) {
|
|
14598
15034
|
return new m(e.left + e.width / 2, e.top + e.height / 2);
|
|
14599
15035
|
}
|
|
14600
|
-
function
|
|
15036
|
+
function Hc({ rect: e, sourceBounds: t }) {
|
|
14601
15037
|
let n = t.left + t.width, r = t.top + t.height, i = 0, a = 0;
|
|
14602
15038
|
return e.left < t.left && (i = t.left - e.left), e.left + e.width > n && (i = n - e.left - e.width), e.top < t.top && (a = t.top - e.top), e.top + e.height > r && (a = r - e.top - e.height), new m(i, a);
|
|
14603
15039
|
}
|
|
14604
|
-
function
|
|
15040
|
+
function Uc({ value: e, min: t, max: n }) {
|
|
14605
15041
|
return Math.max(t, Math.min(n, e));
|
|
14606
15042
|
}
|
|
14607
15043
|
//#endregion
|
|
14608
15044
|
//#region src/editor/crop-manager/domain/crop-frame-size.ts
|
|
14609
|
-
function
|
|
15045
|
+
function Wc({ frame: e, scaleX: t = e.scaleX ?? 1, scaleY: n = e.scaleY ?? 1 }) {
|
|
14610
15046
|
let r = Math.abs(e.cropSourceScaleX ?? 1) || 1, i = Math.abs(e.cropSourceScaleY ?? 1) || 1;
|
|
14611
15047
|
return {
|
|
14612
15048
|
width: Math.max(1, e.width * Math.abs(t) / r),
|
|
@@ -14614,175 +15050,237 @@ function sc({ frame: e, scaleX: t = e.scaleX ?? 1, scaleY: n = e.scaleY ?? 1 })
|
|
|
14614
15050
|
};
|
|
14615
15051
|
}
|
|
14616
15052
|
//#endregion
|
|
14617
|
-
//#region src/editor/crop-manager/domain/crop-
|
|
14618
|
-
var
|
|
14619
|
-
function
|
|
14620
|
-
let i =
|
|
15053
|
+
//#region src/editor/crop-manager/domain/crop-source-scale.ts
|
|
15054
|
+
var Gc = 1;
|
|
15055
|
+
function Kc({ sourceSize: e, startRect: t, anchorX: n, anchorY: r }) {
|
|
15056
|
+
let i = Math.max(1, t.width), a = Math.max(1, t.height);
|
|
15057
|
+
if (Jc({
|
|
15058
|
+
sourceSize: e,
|
|
15059
|
+
rect: t,
|
|
15060
|
+
axis: "x"
|
|
15061
|
+
}) || Jc({
|
|
15062
|
+
sourceSize: e,
|
|
15063
|
+
rect: t,
|
|
15064
|
+
axis: "y"
|
|
15065
|
+
})) return 1;
|
|
15066
|
+
let o = Zc({
|
|
14621
15067
|
sourceSize: e,
|
|
14622
15068
|
rect: t,
|
|
14623
15069
|
axis: "x",
|
|
14624
15070
|
anchor: n
|
|
14625
|
-
}),
|
|
15071
|
+
}), s = Zc({
|
|
14626
15072
|
sourceSize: e,
|
|
14627
15073
|
rect: t,
|
|
14628
15074
|
axis: "y",
|
|
14629
15075
|
anchor: r
|
|
14630
|
-
}),
|
|
14631
|
-
return (u - 1) * Math.min(
|
|
15076
|
+
}), c = Math.min(o / i, s / a), l = Math.min(e.width / i, e.height / a), u = Math.min(c, l);
|
|
15077
|
+
return (u - 1) * Math.min(i, a) <= Gc ? 1 : Math.max(1, u);
|
|
14632
15078
|
}
|
|
14633
|
-
function
|
|
15079
|
+
function qc({ sourceSize: e, startRect: t, axis: n, anchor: r }) {
|
|
15080
|
+
let i = Math.max(1, Xc({
|
|
15081
|
+
rect: t,
|
|
15082
|
+
axis: n
|
|
15083
|
+
}));
|
|
15084
|
+
if (Jc({
|
|
15085
|
+
sourceSize: e,
|
|
15086
|
+
rect: t,
|
|
15087
|
+
axis: n
|
|
15088
|
+
})) return 1;
|
|
15089
|
+
let a = Zc({
|
|
15090
|
+
sourceSize: e,
|
|
15091
|
+
rect: t,
|
|
15092
|
+
axis: n,
|
|
15093
|
+
anchor: r
|
|
15094
|
+
}), o = Yc({
|
|
15095
|
+
sourceSize: e,
|
|
15096
|
+
axis: n
|
|
15097
|
+
}), s = Math.min(a, o) / i;
|
|
15098
|
+
return (s - 1) * i <= Gc ? 1 : Math.max(1, s);
|
|
15099
|
+
}
|
|
15100
|
+
function Jc({ sourceSize: e, rect: t, axis: n }) {
|
|
15101
|
+
let r = Yc({
|
|
15102
|
+
sourceSize: e,
|
|
15103
|
+
axis: n
|
|
15104
|
+
}), i = Xc({
|
|
15105
|
+
rect: t,
|
|
15106
|
+
axis: n
|
|
15107
|
+
});
|
|
15108
|
+
return Math.round(i) >= Math.round(r);
|
|
15109
|
+
}
|
|
15110
|
+
function Yc({ sourceSize: e, axis: t }) {
|
|
15111
|
+
return t === "x" ? e.width : e.height;
|
|
15112
|
+
}
|
|
15113
|
+
function Xc({ rect: e, axis: t }) {
|
|
15114
|
+
return t === "x" ? e.width : e.height;
|
|
15115
|
+
}
|
|
15116
|
+
function Zc({ sourceSize: e, rect: t, axis: n, anchor: r }) {
|
|
14634
15117
|
let i = n === "x" ? e.width : e.height, a = n === "x" ? t.left : t.top, o = n === "x" ? t.width : t.height, s = -i / 2, c = i / 2, l = a + o, u = a + o / 2;
|
|
14635
|
-
return r === "min" ? c -
|
|
15118
|
+
return r === "min" ? c - Qc({
|
|
15119
|
+
value: a,
|
|
15120
|
+
boundary: s
|
|
15121
|
+
}) : r === "max" ? Qc({
|
|
15122
|
+
value: l,
|
|
15123
|
+
boundary: c
|
|
15124
|
+
}) - s : Math.min(u - s, c - u) * 2;
|
|
15125
|
+
}
|
|
15126
|
+
function Qc({ value: e, boundary: t }) {
|
|
15127
|
+
return Math.abs(e - t) <= Gc ? t : e;
|
|
14636
15128
|
}
|
|
14637
15129
|
//#endregion
|
|
14638
15130
|
//#region src/editor/crop-manager/interaction/crop-controls.ts
|
|
14639
|
-
var
|
|
15131
|
+
var $c = .001, el = 1, tl = 1e-6, nl = 1e-9, rl = [
|
|
14640
15132
|
"tl",
|
|
14641
15133
|
"tr",
|
|
14642
15134
|
"bl",
|
|
14643
15135
|
"br"
|
|
14644
|
-
],
|
|
15136
|
+
], il = [
|
|
14645
15137
|
"ml",
|
|
14646
15138
|
"mr",
|
|
14647
15139
|
"mt",
|
|
14648
15140
|
"mb"
|
|
14649
|
-
],
|
|
15141
|
+
], al = {
|
|
14650
15142
|
ml: "w-resize",
|
|
14651
15143
|
mr: "e-resize",
|
|
14652
15144
|
mt: "n-resize",
|
|
14653
15145
|
mb: "s-resize"
|
|
14654
15146
|
};
|
|
14655
|
-
function
|
|
15147
|
+
function ol({ transform: e }) {
|
|
14656
15148
|
let { originX: t, originY: n } = e;
|
|
14657
15149
|
return (t === "center" || t === .5) && (n === "center" || n === .5);
|
|
14658
15150
|
}
|
|
14659
|
-
function
|
|
15151
|
+
function sl({ transform: e, x: t, y: n }) {
|
|
14660
15152
|
let r = e, { target: i } = r, { scaleX: a = 1, scaleY: o = 1 } = i;
|
|
14661
|
-
if (
|
|
15153
|
+
if (dl({
|
|
14662
15154
|
transform: r,
|
|
14663
15155
|
x: t,
|
|
14664
15156
|
y: n
|
|
14665
|
-
})) return
|
|
15157
|
+
})) return fl({ transform: r }), !0;
|
|
14666
15158
|
let s = x.getLocalPoint(r, r.originX, r.originY, t, n);
|
|
14667
|
-
return
|
|
15159
|
+
return ml({ transform: r }), vl({
|
|
14668
15160
|
transform: r,
|
|
14669
15161
|
localPoint: s
|
|
14670
15162
|
}), a !== i.scaleX || o !== i.scaleY;
|
|
14671
15163
|
}
|
|
14672
|
-
function
|
|
15164
|
+
function cl({ transform: e, x: t, y: n }) {
|
|
14673
15165
|
let r = e, { target: i } = r, { scaleX: a = 1, scaleY: o = 1 } = i;
|
|
14674
|
-
if (
|
|
15166
|
+
if (dl({
|
|
14675
15167
|
transform: r,
|
|
14676
15168
|
x: t,
|
|
14677
15169
|
y: n
|
|
14678
|
-
})) return
|
|
15170
|
+
})) return fl({ transform: r }), !0;
|
|
14679
15171
|
let s = x.getLocalPoint(r, r.originX, r.originY, t, n);
|
|
14680
|
-
return
|
|
15172
|
+
return ml({ transform: r }), kl({
|
|
14681
15173
|
transform: r,
|
|
14682
15174
|
localPoint: s
|
|
14683
15175
|
}), a !== i.scaleX || o !== i.scaleY;
|
|
14684
15176
|
}
|
|
14685
|
-
function
|
|
15177
|
+
function ll({ transform: e, axis: t, x: n, y: r }) {
|
|
14686
15178
|
let i = e, { target: a } = i, o = t === "x" ? a.scaleX ?? 1 : a.scaleY ?? 1;
|
|
14687
|
-
if (
|
|
15179
|
+
if (dl({
|
|
14688
15180
|
transform: i,
|
|
14689
15181
|
x: n,
|
|
14690
15182
|
y: r
|
|
14691
|
-
})) return
|
|
15183
|
+
})) return pl({
|
|
14692
15184
|
transform: i,
|
|
14693
15185
|
axis: t
|
|
14694
15186
|
}), !0;
|
|
14695
15187
|
let s = x.getLocalPoint(i, i.originX, i.originY, n, r);
|
|
14696
|
-
return
|
|
15188
|
+
return ml({ transform: i }), yl({
|
|
14697
15189
|
transform: i,
|
|
14698
15190
|
axis: t,
|
|
14699
15191
|
localPoint: s
|
|
14700
15192
|
}), t === "x" ? o !== a.scaleX : o !== a.scaleY;
|
|
14701
15193
|
}
|
|
14702
|
-
function
|
|
15194
|
+
function ul({ transform: e, axis: t, x: n, y: r }) {
|
|
14703
15195
|
let i = e, { target: a } = i, { scaleX: o = 1, scaleY: s = 1 } = a;
|
|
14704
|
-
if (
|
|
15196
|
+
if (dl({
|
|
14705
15197
|
transform: i,
|
|
14706
15198
|
x: n,
|
|
14707
15199
|
y: r
|
|
14708
|
-
})) return
|
|
15200
|
+
})) return fl({ transform: i }), !0;
|
|
14709
15201
|
let c = x.getLocalPoint(i, i.originX, i.originY, n, r);
|
|
14710
|
-
return
|
|
15202
|
+
return ml({ transform: i }), bl({
|
|
14711
15203
|
transform: i,
|
|
14712
15204
|
axis: t,
|
|
14713
15205
|
localPoint: c
|
|
14714
15206
|
}), o !== a.scaleX || s !== a.scaleY;
|
|
14715
15207
|
}
|
|
14716
|
-
function
|
|
14717
|
-
return Math.abs(t - e.ex) <=
|
|
15208
|
+
function dl({ transform: e, x: t, y: n }) {
|
|
15209
|
+
return Math.abs(t - e.ex) <= $c && Math.abs(n - e.ey) <= $c;
|
|
14718
15210
|
}
|
|
14719
|
-
function
|
|
15211
|
+
function fl({ transform: e }) {
|
|
14720
15212
|
e.target.set({
|
|
14721
15213
|
scaleX: e.original.scaleX,
|
|
14722
15214
|
scaleY: e.original.scaleY
|
|
14723
15215
|
});
|
|
14724
15216
|
}
|
|
14725
|
-
function
|
|
15217
|
+
function pl({ transform: e, axis: t }) {
|
|
14726
15218
|
if (t === "x") {
|
|
14727
15219
|
e.target.set("scaleX", e.original.scaleX);
|
|
14728
15220
|
return;
|
|
14729
15221
|
}
|
|
14730
15222
|
e.target.set("scaleY", e.original.scaleY);
|
|
14731
15223
|
}
|
|
14732
|
-
function
|
|
14733
|
-
let { signX: t, signY: n } =
|
|
15224
|
+
function ml({ transform: e }) {
|
|
15225
|
+
let { signX: t, signY: n } = hl({ controlKey: e.corner });
|
|
14734
15226
|
e.signX === void 0 && (e.signX = t), e.signY === void 0 && (e.signY = n);
|
|
14735
15227
|
}
|
|
14736
|
-
function
|
|
15228
|
+
function hl({ controlKey: e }) {
|
|
14737
15229
|
return {
|
|
14738
|
-
signX:
|
|
14739
|
-
signY:
|
|
15230
|
+
signX: gl({ controlKey: e }),
|
|
15231
|
+
signY: _l({ controlKey: e })
|
|
14740
15232
|
};
|
|
14741
15233
|
}
|
|
14742
|
-
function
|
|
15234
|
+
function gl({ controlKey: e }) {
|
|
14743
15235
|
return e === "tl" || e === "bl" || e === "ml" ? -1 : 1;
|
|
14744
15236
|
}
|
|
14745
|
-
function
|
|
15237
|
+
function _l({ controlKey: e }) {
|
|
14746
15238
|
return e === "tl" || e === "tr" || e === "mt" ? -1 : 1;
|
|
14747
15239
|
}
|
|
14748
|
-
function
|
|
14749
|
-
let { target: n } = e
|
|
15240
|
+
function vl({ transform: e, localPoint: t }) {
|
|
15241
|
+
let { target: n } = e;
|
|
15242
|
+
Sl({ transform: e });
|
|
15243
|
+
let r = xl({
|
|
14750
15244
|
transform: e,
|
|
14751
15245
|
axis: "x",
|
|
14752
15246
|
localPoint: t
|
|
14753
|
-
}), i =
|
|
15247
|
+
}), i = xl({
|
|
14754
15248
|
transform: e,
|
|
14755
15249
|
axis: "y",
|
|
14756
15250
|
localPoint: t
|
|
14757
15251
|
});
|
|
14758
|
-
n.lockScalingX || n.set("scaleX", r), n.lockScalingY || n.set("scaleY", i)
|
|
15252
|
+
n.lockScalingX || n.set("scaleX", r.scale), n.lockScalingY || n.set("scaleY", i.scale), (r.sourceClamped || i.sourceClamped) && Cl({
|
|
15253
|
+
transform: e,
|
|
15254
|
+
preserveAspectRatio: !1
|
|
15255
|
+
});
|
|
14759
15256
|
}
|
|
14760
|
-
function
|
|
15257
|
+
function yl({ transform: e, axis: t, localPoint: n }) {
|
|
14761
15258
|
let { target: r } = e;
|
|
14762
15259
|
if (t === "x" && r.lockScalingX || t === "y" && r.lockScalingY) return;
|
|
14763
|
-
|
|
15260
|
+
Sl({ transform: e });
|
|
15261
|
+
let i = xl({
|
|
14764
15262
|
transform: e,
|
|
14765
15263
|
axis: t,
|
|
14766
15264
|
localPoint: n
|
|
14767
15265
|
});
|
|
14768
|
-
|
|
14769
|
-
|
|
14770
|
-
|
|
14771
|
-
}
|
|
14772
|
-
r.set("scaleY", i);
|
|
15266
|
+
t === "x" ? r.set("scaleX", i.scale) : r.set("scaleY", i.scale), i.sourceClamped && Cl({
|
|
15267
|
+
transform: e,
|
|
15268
|
+
preserveAspectRatio: !1
|
|
15269
|
+
});
|
|
14773
15270
|
}
|
|
14774
|
-
function
|
|
15271
|
+
function bl({ transform: e, axis: t, localPoint: n }) {
|
|
14775
15272
|
let { target: r } = e;
|
|
14776
15273
|
if (r.lockScalingX || r.lockScalingY) return;
|
|
14777
|
-
let i =
|
|
15274
|
+
let i = xl({
|
|
14778
15275
|
transform: e,
|
|
14779
15276
|
axis: t,
|
|
14780
|
-
localPoint: n
|
|
14781
|
-
|
|
15277
|
+
localPoint: n,
|
|
15278
|
+
constrainToSource: !1
|
|
15279
|
+
}), a = t === "x" ? e.original.scaleX : e.original.scaleY, o = Nl({
|
|
14782
15280
|
target: r,
|
|
14783
15281
|
transform: e,
|
|
14784
|
-
scale: a > 0 ? i / a : 1,
|
|
14785
|
-
forceMinimum:
|
|
15282
|
+
scale: a > 0 ? i.scale / a : 1,
|
|
15283
|
+
forceMinimum: Bl({
|
|
14786
15284
|
transform: e,
|
|
14787
15285
|
axis: t,
|
|
14788
15286
|
localPoint: n
|
|
@@ -14790,173 +15288,254 @@ function kc({ transform: e, axis: t, localPoint: n }) {
|
|
|
14790
15288
|
});
|
|
14791
15289
|
r.set("scaleX", o.scaleX), r.set("scaleY", o.scaleY);
|
|
14792
15290
|
}
|
|
14793
|
-
function
|
|
14794
|
-
let { target:
|
|
14795
|
-
|
|
15291
|
+
function xl({ transform: e, axis: t, localPoint: n, constrainToSource: r = !0 }) {
|
|
15292
|
+
let { target: i } = e, a = Ml({ target: i }), o = zl({ target: i }), s = t === "x" ? i.scaleX ?? 1 : i.scaleY ?? 1, c = t === "x" ? e.original.scaleX : e.original.scaleY, l = t === "x" ? n.x : n.y, u = t === "x" ? a.x : a.y, d = t === "x" ? o.minScaleX : o.minScaleY, f = r ? Dl({
|
|
15293
|
+
target: i,
|
|
15294
|
+
transform: e,
|
|
15295
|
+
axis: t
|
|
15296
|
+
}) : null, p = El({
|
|
15297
|
+
axis: t,
|
|
15298
|
+
limits: o,
|
|
15299
|
+
sourceMaximumScale: f
|
|
15300
|
+
});
|
|
15301
|
+
if (Bl({
|
|
14796
15302
|
transform: e,
|
|
14797
15303
|
axis: t,
|
|
14798
15304
|
localPoint: n
|
|
14799
|
-
})) return
|
|
14800
|
-
|
|
14801
|
-
|
|
14802
|
-
|
|
14803
|
-
|
|
14804
|
-
|
|
15305
|
+
})) return {
|
|
15306
|
+
scale: d,
|
|
15307
|
+
sourceClamped: !1
|
|
15308
|
+
};
|
|
15309
|
+
let m = Math.abs((l || 0) * s / u);
|
|
15310
|
+
ol({ transform: e }) && (m *= 2);
|
|
15311
|
+
let h = Tl({
|
|
15312
|
+
target: i,
|
|
15313
|
+
axis: t,
|
|
15314
|
+
scale: Gl({
|
|
15315
|
+
value: m,
|
|
15316
|
+
min: d,
|
|
15317
|
+
max: p
|
|
15318
|
+
}),
|
|
15319
|
+
maximumScale: p,
|
|
15320
|
+
sourceMaximumScale: f
|
|
14805
15321
|
});
|
|
15322
|
+
return {
|
|
15323
|
+
scale: h,
|
|
15324
|
+
sourceClamped: wl({
|
|
15325
|
+
scale: h,
|
|
15326
|
+
maximumScale: p,
|
|
15327
|
+
sourceMaximumScale: f,
|
|
15328
|
+
originalScale: c
|
|
15329
|
+
})
|
|
15330
|
+
};
|
|
14806
15331
|
}
|
|
14807
|
-
function
|
|
15332
|
+
function Sl({ transform: e }) {
|
|
15333
|
+
e.cropSourceScaleClamped = !1, e.cropSourceBoundScale = null, e.cropSourceScalePreserveAspectRatio = void 0;
|
|
15334
|
+
}
|
|
15335
|
+
function Cl({ transform: e, preserveAspectRatio: t }) {
|
|
15336
|
+
let { target: n } = e;
|
|
15337
|
+
e.cropSourceScaleClamped = !0, e.cropSourceScalePreserveAspectRatio = t, e.cropSourceBoundScale = {
|
|
15338
|
+
scaleX: n.scaleX ?? 1,
|
|
15339
|
+
scaleY: n.scaleY ?? 1
|
|
15340
|
+
};
|
|
15341
|
+
}
|
|
15342
|
+
function wl({ scale: e, maximumScale: t, sourceMaximumScale: n, originalScale: r }) {
|
|
15343
|
+
return n === null || Math.abs(t - n) > nl || Math.abs(e - n) > nl ? !1 : Math.abs(Math.abs(r) - n) > nl;
|
|
15344
|
+
}
|
|
15345
|
+
function Tl({ target: e, axis: t, scale: n, maximumScale: r, sourceMaximumScale: i }) {
|
|
15346
|
+
return i === null || Math.abs(r - i) > nl ? n : Ol({
|
|
15347
|
+
target: e,
|
|
15348
|
+
axis: t,
|
|
15349
|
+
fromScale: n,
|
|
15350
|
+
toScale: i
|
|
15351
|
+
}) <= el + tl ? i : n;
|
|
15352
|
+
}
|
|
15353
|
+
function El({ axis: e, limits: t, sourceMaximumScale: n }) {
|
|
15354
|
+
let r = e === "x" ? t.minScaleX : t.minScaleY, i = e === "x" ? t.maxScaleX : t.maxScaleY;
|
|
15355
|
+
return n === null ? i : Math.max(r, Math.min(i, n));
|
|
15356
|
+
}
|
|
15357
|
+
function Dl({ target: e, transform: t, axis: n }) {
|
|
15358
|
+
let r = Fl({
|
|
15359
|
+
target: e,
|
|
15360
|
+
transform: t
|
|
15361
|
+
});
|
|
15362
|
+
if (!r) return null;
|
|
15363
|
+
let i = n === "x" ? t.original.scaleX : t.original.scaleY, a = qc({
|
|
15364
|
+
sourceSize: r.sourceSize,
|
|
15365
|
+
startRect: r.startRect,
|
|
15366
|
+
axis: n,
|
|
15367
|
+
anchor: Il({
|
|
15368
|
+
transform: t,
|
|
15369
|
+
axis: n
|
|
15370
|
+
})
|
|
15371
|
+
});
|
|
15372
|
+
return Math.abs(i) * a;
|
|
15373
|
+
}
|
|
15374
|
+
function Ol({ target: e, axis: t, fromScale: n, toScale: r }) {
|
|
15375
|
+
let i = e, a = t === "x" ? Math.abs(i.cropSourceScaleX ?? 1) || 1 : Math.abs(i.cropSourceScaleY ?? 1) || 1, o = t === "x" ? e.width : e.height;
|
|
15376
|
+
return Math.abs(r - n) * Math.max(1, o) / a;
|
|
15377
|
+
}
|
|
15378
|
+
function kl({ transform: e, localPoint: t }) {
|
|
14808
15379
|
let { target: n } = e;
|
|
14809
15380
|
if (n.lockScalingX || n.lockScalingY) return;
|
|
14810
|
-
let r =
|
|
15381
|
+
let r = Nl({
|
|
14811
15382
|
target: n,
|
|
14812
15383
|
transform: e,
|
|
14813
|
-
scale:
|
|
15384
|
+
scale: Al({
|
|
14814
15385
|
transform: e,
|
|
14815
15386
|
localPoint: t,
|
|
14816
|
-
dimensions:
|
|
15387
|
+
dimensions: Ml({ target: n })
|
|
14817
15388
|
}),
|
|
14818
|
-
forceMinimum:
|
|
15389
|
+
forceMinimum: Vl({
|
|
14819
15390
|
transform: e,
|
|
14820
15391
|
localPoint: t
|
|
14821
15392
|
})
|
|
14822
15393
|
});
|
|
14823
15394
|
n.set("scaleX", r.scaleX), n.set("scaleY", r.scaleY);
|
|
14824
15395
|
}
|
|
14825
|
-
function
|
|
15396
|
+
function Al({ transform: e, localPoint: t, dimensions: n }) {
|
|
14826
15397
|
let r = "gestureScale" in e && typeof e.gestureScale == "number" ? e.gestureScale : null;
|
|
14827
15398
|
if (r !== null) return r;
|
|
14828
|
-
let i = Math.abs(t.x) + Math.abs(t.y), a =
|
|
15399
|
+
let i = Math.abs(t.x) + Math.abs(t.y), a = jl({
|
|
14829
15400
|
transform: e,
|
|
14830
15401
|
dimensions: n
|
|
14831
15402
|
}), o = a > 0 ? i / a : 1;
|
|
14832
|
-
return
|
|
15403
|
+
return ol({ transform: e }) && (o *= 2), o;
|
|
14833
15404
|
}
|
|
14834
|
-
function
|
|
15405
|
+
function jl({ transform: e, dimensions: t }) {
|
|
14835
15406
|
let { target: n, original: r } = e, i = n.scaleX ?? 1, a = n.scaleY ?? 1;
|
|
14836
15407
|
return Math.abs(t.x * r.scaleX / i) + Math.abs(t.y * r.scaleY / a);
|
|
14837
15408
|
}
|
|
14838
|
-
function
|
|
15409
|
+
function Ml({ target: e }) {
|
|
14839
15410
|
let t = Math.abs(e.scaleX ?? 1), n = Math.abs(e.scaleY ?? 1);
|
|
14840
15411
|
return {
|
|
14841
15412
|
x: Math.max(1, e.width * t),
|
|
14842
15413
|
y: Math.max(1, e.height * n)
|
|
14843
15414
|
};
|
|
14844
15415
|
}
|
|
14845
|
-
function
|
|
14846
|
-
let i =
|
|
15416
|
+
function Nl({ target: e, transform: t, scale: n, forceMinimum: r }) {
|
|
15417
|
+
let i = Wc({
|
|
14847
15418
|
frame: e,
|
|
14848
15419
|
scaleX: t.original.scaleX,
|
|
14849
15420
|
scaleY: t.original.scaleY
|
|
14850
|
-
}), a = Math.max(
|
|
15421
|
+
}), a = Math.max(wc / i.width, Tc / i.height), o = Math.min(Ec / i.width, Dc / i.height), s = Pl({
|
|
14851
15422
|
target: e,
|
|
14852
15423
|
transform: t
|
|
14853
15424
|
}), c = Math.max(a, Math.min(o, s ?? o));
|
|
14854
|
-
t.cropSourceScaleClamped = !r && n > c;
|
|
15425
|
+
t.cropSourceScaleClamped = !r && n > c, t.cropSourceScalePreserveAspectRatio = t.cropSourceScaleClamped;
|
|
14855
15426
|
let l = a;
|
|
14856
|
-
|
|
15427
|
+
r || (l = Gl({
|
|
14857
15428
|
value: n,
|
|
14858
15429
|
min: a,
|
|
14859
15430
|
max: c
|
|
14860
|
-
}))
|
|
14861
|
-
|
|
14862
|
-
|
|
15431
|
+
}));
|
|
15432
|
+
let u = t.original.scaleX * l, d = t.original.scaleY * l;
|
|
15433
|
+
return t.cropSourceScaleClamped ? t.cropSourceBoundScale = {
|
|
15434
|
+
scaleX: u,
|
|
15435
|
+
scaleY: d
|
|
15436
|
+
} : (t.cropSourceBoundScale = null, t.cropSourceScalePreserveAspectRatio = void 0), {
|
|
15437
|
+
scaleX: u,
|
|
15438
|
+
scaleY: d
|
|
14863
15439
|
};
|
|
14864
15440
|
}
|
|
14865
|
-
function
|
|
14866
|
-
let n =
|
|
15441
|
+
function Pl({ target: e, transform: t }) {
|
|
15442
|
+
let n = Fl({
|
|
14867
15443
|
target: e,
|
|
14868
15444
|
transform: t
|
|
14869
15445
|
});
|
|
14870
|
-
return n ?
|
|
15446
|
+
return n ? Kc({
|
|
14871
15447
|
sourceSize: n.sourceSize,
|
|
14872
15448
|
startRect: n.startRect,
|
|
14873
|
-
anchorX:
|
|
14874
|
-
anchorY:
|
|
15449
|
+
anchorX: Ll({ transform: t }),
|
|
15450
|
+
anchorY: Rl({ transform: t })
|
|
14875
15451
|
}) : null;
|
|
14876
15452
|
}
|
|
14877
|
-
function
|
|
14878
|
-
if (t.
|
|
15453
|
+
function Fl({ target: e, transform: t }) {
|
|
15454
|
+
if (t.cropSourceScaleBounds !== void 0) return t.cropSourceScaleBounds;
|
|
14879
15455
|
let n = e;
|
|
14880
|
-
return n.cropAllowFrameOverflow !== !1 || !n.cropSource ? (t.
|
|
15456
|
+
return n.cropAllowFrameOverflow !== !1 || !n.cropSource ? (t.cropSourceScaleBounds = null, null) : (t.cropSourceScaleBounds = {
|
|
14881
15457
|
sourceSize: Z({ source: n.cropSource }),
|
|
14882
|
-
startRect:
|
|
15458
|
+
startRect: Ac({
|
|
14883
15459
|
source: n.cropSource,
|
|
14884
15460
|
frame: n
|
|
14885
15461
|
})
|
|
14886
|
-
}, t.
|
|
15462
|
+
}, t.cropSourceScaleBounds);
|
|
15463
|
+
}
|
|
15464
|
+
function Il({ transform: e, axis: t }) {
|
|
15465
|
+
return t === "x" ? Ll({ transform: e }) : Rl({ transform: e });
|
|
14887
15466
|
}
|
|
14888
|
-
function
|
|
15467
|
+
function Ll({ transform: e }) {
|
|
14889
15468
|
return e.corner === "tl" || e.corner === "bl" || e.corner === "ml" ? "max" : e.corner === "tr" || e.corner === "br" || e.corner === "mr" || e.originX === "left" || e.originX === 0 ? "min" : e.originX === "right" || e.originX === 1 ? "max" : "center";
|
|
14890
15469
|
}
|
|
14891
|
-
function
|
|
15470
|
+
function Rl({ transform: e }) {
|
|
14892
15471
|
return e.corner === "tl" || e.corner === "tr" || e.corner === "mt" ? "max" : e.corner === "bl" || e.corner === "br" || e.corner === "mb" || e.originY === "top" || e.originY === 0 ? "min" : e.originY === "bottom" || e.originY === 1 ? "max" : "center";
|
|
14893
15472
|
}
|
|
14894
|
-
function
|
|
15473
|
+
function zl({ target: e }) {
|
|
14895
15474
|
let t = e, n = Math.abs(t.cropSourceScaleX ?? 1) || 1, r = Math.abs(t.cropSourceScaleY ?? 1) || 1, i = Math.max(1, e.width), a = Math.max(1, e.height);
|
|
14896
15475
|
return {
|
|
14897
|
-
minScaleX:
|
|
14898
|
-
maxScaleX:
|
|
14899
|
-
minScaleY:
|
|
14900
|
-
maxScaleY:
|
|
15476
|
+
minScaleX: wc * n / i,
|
|
15477
|
+
maxScaleX: Ec * n / i,
|
|
15478
|
+
minScaleY: Tc * r / a,
|
|
15479
|
+
maxScaleY: Dc * r / a
|
|
14901
15480
|
};
|
|
14902
15481
|
}
|
|
14903
|
-
function
|
|
15482
|
+
function Bl({ transform: e, axis: t, localPoint: n }) {
|
|
14904
15483
|
let { target: r } = e;
|
|
14905
15484
|
if (!r.lockScalingFlip) return !1;
|
|
14906
15485
|
let i = t === "x" ? e.signX ?? 1 : e.signY ?? 1, a = t === "x" ? n.x : n.y;
|
|
14907
15486
|
return i !== Math.sign(a || i);
|
|
14908
15487
|
}
|
|
14909
|
-
function
|
|
14910
|
-
return
|
|
15488
|
+
function Vl({ transform: e, localPoint: t }) {
|
|
15489
|
+
return Bl({
|
|
14911
15490
|
transform: e,
|
|
14912
15491
|
axis: "x",
|
|
14913
15492
|
localPoint: t
|
|
14914
|
-
}) ||
|
|
15493
|
+
}) || Bl({
|
|
14915
15494
|
transform: e,
|
|
14916
15495
|
axis: "y",
|
|
14917
15496
|
localPoint: t
|
|
14918
15497
|
});
|
|
14919
15498
|
}
|
|
14920
|
-
function
|
|
15499
|
+
function Hl({ eventData: e, target: t }) {
|
|
14921
15500
|
let n = t.preserveAspectRatio ?? !0;
|
|
14922
15501
|
return e.shiftKey ? !n : n;
|
|
14923
15502
|
}
|
|
14924
|
-
function
|
|
14925
|
-
let e = x.wrapWithFireEvent("scaling", x.wrapWithFixedAnchor((e, t, n, r) =>
|
|
15503
|
+
function Ul() {
|
|
15504
|
+
let e = x.wrapWithFireEvent("scaling", x.wrapWithFixedAnchor((e, t, n, r) => sl({
|
|
14926
15505
|
transform: t,
|
|
14927
15506
|
x: n,
|
|
14928
15507
|
y: r
|
|
14929
|
-
}))), t = x.wrapWithFireEvent("scaling", x.wrapWithFixedAnchor((e, t, n, r) =>
|
|
15508
|
+
}))), t = x.wrapWithFireEvent("scaling", x.wrapWithFixedAnchor((e, t, n, r) => cl({
|
|
14930
15509
|
transform: t,
|
|
14931
15510
|
x: n,
|
|
14932
15511
|
y: r
|
|
14933
15512
|
})));
|
|
14934
|
-
return (n, r, i, a) =>
|
|
15513
|
+
return (n, r, i, a) => Hl({
|
|
14935
15514
|
eventData: n,
|
|
14936
15515
|
target: r.target
|
|
14937
15516
|
}) ? t(n, r, i, a) : e(n, r, i, a);
|
|
14938
15517
|
}
|
|
14939
|
-
function
|
|
14940
|
-
let t = x.wrapWithFireEvent("scaling", x.wrapWithFixedAnchor((t, n, r, i) =>
|
|
15518
|
+
function Wl({ axis: e }) {
|
|
15519
|
+
let t = x.wrapWithFireEvent("scaling", x.wrapWithFixedAnchor((t, n, r, i) => ll({
|
|
14941
15520
|
transform: n,
|
|
14942
15521
|
axis: e,
|
|
14943
15522
|
x: r,
|
|
14944
15523
|
y: i
|
|
14945
|
-
}))), n = x.wrapWithFireEvent("scaling", x.wrapWithFixedAnchor((t, n, r, i) =>
|
|
15524
|
+
}))), n = x.wrapWithFireEvent("scaling", x.wrapWithFixedAnchor((t, n, r, i) => ul({
|
|
14946
15525
|
transform: n,
|
|
14947
15526
|
axis: e,
|
|
14948
15527
|
x: r,
|
|
14949
15528
|
y: i
|
|
14950
15529
|
})));
|
|
14951
|
-
return (e, r, i, a) =>
|
|
15530
|
+
return (e, r, i, a) => Hl({
|
|
14952
15531
|
eventData: e,
|
|
14953
15532
|
target: r.target
|
|
14954
15533
|
}) ? n(e, r, i, a) : t(e, r, i, a);
|
|
14955
15534
|
}
|
|
14956
|
-
function
|
|
15535
|
+
function Gl({ value: e, min: t, max: n }) {
|
|
14957
15536
|
return Math.max(t, Math.min(n, e));
|
|
14958
15537
|
}
|
|
14959
|
-
function
|
|
15538
|
+
function Kl({ control: e, actionHandler: t, cursorStyleHandler: n, getActionName: i }) {
|
|
14960
15539
|
let a = {
|
|
14961
15540
|
...e,
|
|
14962
15541
|
actionHandler: t
|
|
@@ -14965,55 +15544,55 @@ function qc({ control: e, actionHandler: t, cursorStyleHandler: n, getActionName
|
|
|
14965
15544
|
let o = new r(a);
|
|
14966
15545
|
return o.cropResizeControl = !0, o;
|
|
14967
15546
|
}
|
|
14968
|
-
function
|
|
14969
|
-
return
|
|
15547
|
+
function ql({ controlKey: e }) {
|
|
15548
|
+
return al[e];
|
|
14970
15549
|
}
|
|
14971
|
-
function
|
|
15550
|
+
function Jl({ axis: e }) {
|
|
14972
15551
|
return e === "x" ? "scaleX" : "scaleY";
|
|
14973
15552
|
}
|
|
14974
|
-
function
|
|
14975
|
-
let t = { ...e.controls }, n = !1, r =
|
|
14976
|
-
|
|
15553
|
+
function Yl({ target: e }) {
|
|
15554
|
+
let t = { ...e.controls }, n = !1, r = Ul(), i = Wl({ axis: "x" }), a = Wl({ axis: "y" });
|
|
15555
|
+
rl.forEach((i) => {
|
|
14977
15556
|
let a = e.controls[i];
|
|
14978
|
-
a && (a.cropResizeControl || (t[i] =
|
|
15557
|
+
a && (a.cropResizeControl || (t[i] = Kl({
|
|
14979
15558
|
control: a,
|
|
14980
15559
|
actionHandler: r
|
|
14981
15560
|
}), n = !0));
|
|
14982
|
-
}),
|
|
15561
|
+
}), il.forEach((r) => {
|
|
14983
15562
|
let o = e.controls[r];
|
|
14984
15563
|
if (!o || o.cropResizeControl) return;
|
|
14985
15564
|
let s = r === "ml" || r === "mr", c = s ? i : a, l = s ? "x" : "y";
|
|
14986
|
-
t[r] =
|
|
15565
|
+
t[r] = Kl({
|
|
14987
15566
|
control: o,
|
|
14988
15567
|
actionHandler: c,
|
|
14989
|
-
cursorStyleHandler: () =>
|
|
14990
|
-
getActionName: () =>
|
|
15568
|
+
cursorStyleHandler: () => ql({ controlKey: r }),
|
|
15569
|
+
getActionName: () => Jl({ axis: l })
|
|
14991
15570
|
}), n = !0;
|
|
14992
15571
|
}), n && (e.controls = t);
|
|
14993
15572
|
}
|
|
14994
15573
|
//#endregion
|
|
14995
15574
|
//#region src/editor/crop-manager/domain/crop-frame.ts
|
|
14996
|
-
var
|
|
15575
|
+
var Xl = "rgba(47, 128, 237, 0.42)", Zl = class extends _ {
|
|
14997
15576
|
constructor(e) {
|
|
14998
15577
|
let { showGrid: t, source: n = null, allowFrameOverflow: r = !0, sourceScaleX: i = 1, sourceScaleY: a = 1, preserveAspectRatio: o = !0, ...s } = e;
|
|
14999
15578
|
super(s), this._showGrid = t, this.cropSource = n, this.cropAllowFrameOverflow = r, this.cropSourceScaleX = i, this.cropSourceScaleY = a, this.preserveAspectRatio = o;
|
|
15000
15579
|
}
|
|
15001
15580
|
_render(e) {
|
|
15002
|
-
super._render(e), this._showGrid &&
|
|
15581
|
+
super._render(e), this._showGrid && $l({
|
|
15003
15582
|
ctx: e,
|
|
15004
15583
|
width: this.width,
|
|
15005
15584
|
height: this.height
|
|
15006
15585
|
});
|
|
15007
15586
|
}
|
|
15008
15587
|
getObjectDisplaySize() {
|
|
15009
|
-
return
|
|
15588
|
+
return Wc({ frame: this });
|
|
15010
15589
|
}
|
|
15011
15590
|
getObjectSnappingBounds() {
|
|
15012
|
-
return
|
|
15591
|
+
return tu({ frame: this });
|
|
15013
15592
|
}
|
|
15014
15593
|
};
|
|
15015
|
-
function
|
|
15016
|
-
let a = e.getCenterPoint(), o = e.scaleX ?? 1, s = e.scaleY ?? 1, c = new
|
|
15594
|
+
function Ql({ source: e, cropSize: t, showGrid: n, allowFrameOverflow: r, preserveAspectRatio: i }) {
|
|
15595
|
+
let a = e.getCenterPoint(), o = e.scaleX ?? 1, s = e.scaleY ?? 1, c = new Zl({
|
|
15017
15596
|
id: `crop-frame-${D()}`,
|
|
15018
15597
|
left: a.x,
|
|
15019
15598
|
top: a.y,
|
|
@@ -15045,18 +15624,18 @@ function $c({ source: e, cropSize: t, showGrid: n, allowFrameOverflow: r, preser
|
|
|
15045
15624
|
sourceScaleX: o,
|
|
15046
15625
|
sourceScaleY: s
|
|
15047
15626
|
});
|
|
15048
|
-
return c.setControlsVisibility({ mtr: !1 }),
|
|
15627
|
+
return c.setControlsVisibility({ mtr: !1 }), Yl({ target: c }), c;
|
|
15049
15628
|
}
|
|
15050
|
-
function
|
|
15629
|
+
function $l({ ctx: e, width: t, height: n }) {
|
|
15051
15630
|
if (!(t <= 0 || n <= 0)) {
|
|
15052
|
-
e.save(), e.strokeStyle =
|
|
15631
|
+
e.save(), e.strokeStyle = Xl, e.lineWidth = 1, e.setLineDash([]);
|
|
15053
15632
|
for (let r = 1; r <= 2; r += 1) {
|
|
15054
15633
|
let i = -t / 2 + t * r / 3, a = -n / 2 + n * r / 3;
|
|
15055
|
-
|
|
15634
|
+
eu({
|
|
15056
15635
|
ctx: e,
|
|
15057
15636
|
x: i,
|
|
15058
15637
|
height: n
|
|
15059
|
-
}),
|
|
15638
|
+
}), ru({
|
|
15060
15639
|
ctx: e,
|
|
15061
15640
|
y: a,
|
|
15062
15641
|
width: t
|
|
@@ -15065,19 +15644,19 @@ function el({ ctx: e, width: t, height: n }) {
|
|
|
15065
15644
|
e.restore();
|
|
15066
15645
|
}
|
|
15067
15646
|
}
|
|
15068
|
-
function
|
|
15647
|
+
function eu({ ctx: e, x: t, height: n }) {
|
|
15069
15648
|
e.beginPath(), e.moveTo(t, -n / 2), e.lineTo(t, n / 2), e.stroke();
|
|
15070
15649
|
}
|
|
15071
|
-
function
|
|
15650
|
+
function tu({ frame: e }) {
|
|
15072
15651
|
let t = e.calcTransformMatrix(), n = e.width / 2, r = e.height / 2;
|
|
15073
|
-
return
|
|
15652
|
+
return nu({ points: [
|
|
15074
15653
|
new m(-n, -r),
|
|
15075
15654
|
new m(n, -r),
|
|
15076
15655
|
new m(n, r),
|
|
15077
15656
|
new m(-n, r)
|
|
15078
15657
|
].map((e) => e.transform(t)) });
|
|
15079
15658
|
}
|
|
15080
|
-
function
|
|
15659
|
+
function nu({ points: e }) {
|
|
15081
15660
|
let t = Math.min(...e.map((e) => e.x)), n = Math.max(...e.map((e) => e.x)), r = Math.min(...e.map((e) => e.y)), i = Math.max(...e.map((e) => e.y));
|
|
15082
15661
|
return {
|
|
15083
15662
|
left: t,
|
|
@@ -15088,18 +15667,18 @@ function rl({ points: e }) {
|
|
|
15088
15667
|
centerY: r + (i - r) / 2
|
|
15089
15668
|
};
|
|
15090
15669
|
}
|
|
15091
|
-
function
|
|
15670
|
+
function ru({ ctx: e, y: t, width: n }) {
|
|
15092
15671
|
e.beginPath(), e.moveTo(-n / 2, t), e.lineTo(n / 2, t), e.stroke();
|
|
15093
15672
|
}
|
|
15094
15673
|
//#endregion
|
|
15095
15674
|
//#region src/editor/crop-manager/domain/crop-result.ts
|
|
15096
|
-
function
|
|
15097
|
-
return e.mode === "canvas" ?
|
|
15675
|
+
function iu({ session: e }) {
|
|
15676
|
+
return e.mode === "canvas" ? su({ session: e }) : cu({
|
|
15098
15677
|
target: e.target,
|
|
15099
15678
|
frame: e.frame
|
|
15100
15679
|
});
|
|
15101
15680
|
}
|
|
15102
|
-
function
|
|
15681
|
+
function au({ rect: e }) {
|
|
15103
15682
|
return {
|
|
15104
15683
|
left: Math.round(e.left),
|
|
15105
15684
|
top: Math.round(e.top),
|
|
@@ -15107,11 +15686,11 @@ function ol({ rect: e }) {
|
|
|
15107
15686
|
height: Math.round(e.height)
|
|
15108
15687
|
};
|
|
15109
15688
|
}
|
|
15110
|
-
function
|
|
15111
|
-
return e.width >=
|
|
15689
|
+
function ou({ rect: e }) {
|
|
15690
|
+
return e.width >= Oc && e.height >= Oc;
|
|
15112
15691
|
}
|
|
15113
|
-
function
|
|
15114
|
-
let t =
|
|
15692
|
+
function su({ session: e }) {
|
|
15693
|
+
let t = Ac({
|
|
15115
15694
|
source: e.source,
|
|
15116
15695
|
frame: e.frame
|
|
15117
15696
|
}), n = Z({ source: e.source });
|
|
@@ -15122,8 +15701,8 @@ function cl({ session: e }) {
|
|
|
15122
15701
|
height: t.height
|
|
15123
15702
|
};
|
|
15124
15703
|
}
|
|
15125
|
-
function
|
|
15126
|
-
let n =
|
|
15704
|
+
function cu({ target: e, frame: t }) {
|
|
15705
|
+
let n = Ac({
|
|
15127
15706
|
source: e,
|
|
15128
15707
|
frame: t
|
|
15129
15708
|
}), r = -e.width / 2, i = -e.height / 2;
|
|
@@ -15136,8 +15715,8 @@ function ll({ target: e, frame: t }) {
|
|
|
15136
15715
|
}
|
|
15137
15716
|
//#endregion
|
|
15138
15717
|
//#region src/editor/crop-manager/mutation/crop-apply.ts
|
|
15139
|
-
function
|
|
15140
|
-
return
|
|
15718
|
+
function lu({ editor: e, frame: t, rect: n }) {
|
|
15719
|
+
return ou({ rect: n }) ? (_u({
|
|
15141
15720
|
editor: e,
|
|
15142
15721
|
frame: t,
|
|
15143
15722
|
offset: new m(-n.left, -n.top)
|
|
@@ -15147,9 +15726,9 @@ function ul({ editor: e, frame: t, rect: n }) {
|
|
|
15147
15726
|
rect: n
|
|
15148
15727
|
}) : null;
|
|
15149
15728
|
}
|
|
15150
|
-
function
|
|
15151
|
-
if (!
|
|
15152
|
-
let i =
|
|
15729
|
+
function uu({ editor: e, target: t, frame: n, rect: r }) {
|
|
15730
|
+
if (!ou({ rect: r })) return null;
|
|
15731
|
+
let i = du({
|
|
15153
15732
|
target: t,
|
|
15154
15733
|
frame: n,
|
|
15155
15734
|
rect: r
|
|
@@ -15160,21 +15739,21 @@ function dl({ editor: e, target: t, frame: n, rect: r }) {
|
|
|
15160
15739
|
rect: i
|
|
15161
15740
|
}) : null;
|
|
15162
15741
|
}
|
|
15163
|
-
function
|
|
15164
|
-
let r = Math.max(
|
|
15742
|
+
function du({ target: e, frame: t, rect: n }) {
|
|
15743
|
+
let r = Math.max(Oc, n.width), i = Math.max(Oc, n.height), a = {
|
|
15165
15744
|
width: r,
|
|
15166
15745
|
height: i
|
|
15167
15746
|
};
|
|
15168
|
-
if (
|
|
15747
|
+
if (fu({
|
|
15169
15748
|
target: e,
|
|
15170
15749
|
rect: n
|
|
15171
|
-
}))
|
|
15750
|
+
})) pu({
|
|
15172
15751
|
target: e,
|
|
15173
15752
|
size: a,
|
|
15174
15753
|
rect: n
|
|
15175
15754
|
});
|
|
15176
15755
|
else {
|
|
15177
|
-
let t =
|
|
15756
|
+
let t = mu({
|
|
15178
15757
|
target: e,
|
|
15179
15758
|
size: a,
|
|
15180
15759
|
rect: n
|
|
@@ -15194,10 +15773,10 @@ function fl({ target: e, frame: t, rect: n }) {
|
|
|
15194
15773
|
height: i
|
|
15195
15774
|
};
|
|
15196
15775
|
}
|
|
15197
|
-
function
|
|
15776
|
+
function fu({ target: e, rect: t }) {
|
|
15198
15777
|
return t.left >= 0 && t.top >= 0 && t.left + t.width <= e.width && t.top + t.height <= e.height;
|
|
15199
15778
|
}
|
|
15200
|
-
function
|
|
15779
|
+
function pu({ target: e, size: t, rect: n }) {
|
|
15201
15780
|
let r = (e.cropX ?? 0) + n.left, i = (e.cropY ?? 0) + n.top;
|
|
15202
15781
|
e.set({
|
|
15203
15782
|
cropX: r,
|
|
@@ -15206,25 +15785,25 @@ function ml({ target: e, size: t, rect: n }) {
|
|
|
15206
15785
|
height: t.height
|
|
15207
15786
|
});
|
|
15208
15787
|
}
|
|
15209
|
-
function
|
|
15210
|
-
let r = e.getElement(), i =
|
|
15788
|
+
function mu({ target: e, size: t, rect: n }) {
|
|
15789
|
+
let r = e.getElement(), i = hu({ target: e });
|
|
15211
15790
|
if (!r || !i) return null;
|
|
15212
15791
|
let a = i.createElement("canvas");
|
|
15213
15792
|
a.width = Math.round(t.width), a.height = Math.round(t.height);
|
|
15214
15793
|
let o = a.getContext("2d");
|
|
15215
15794
|
if (!o) return null;
|
|
15216
|
-
let s =
|
|
15795
|
+
let s = gu({
|
|
15217
15796
|
target: e,
|
|
15218
15797
|
size: t,
|
|
15219
15798
|
rect: n
|
|
15220
15799
|
});
|
|
15221
15800
|
return s && o.drawImage(r, s.sourceX, s.sourceY, s.sourceWidth, s.sourceHeight, s.destinationX, s.destinationY, s.sourceWidth, s.sourceHeight), a;
|
|
15222
15801
|
}
|
|
15223
|
-
function
|
|
15802
|
+
function hu({ target: e }) {
|
|
15224
15803
|
let t = e.canvas?.getElement();
|
|
15225
15804
|
return t?.ownerDocument ? t.ownerDocument : typeof document < "u" ? document : null;
|
|
15226
15805
|
}
|
|
15227
|
-
function
|
|
15806
|
+
function gu({ target: e, size: t, rect: n }) {
|
|
15228
15807
|
let r = Math.max(0, n.left), i = Math.max(0, n.top), a = Math.min(e.width, n.left + t.width), o = Math.min(e.height, n.top + t.height), s = a - r, c = o - i;
|
|
15229
15808
|
return s <= 0 || c <= 0 ? null : {
|
|
15230
15809
|
sourceX: (e.cropX ?? 0) + r,
|
|
@@ -15235,7 +15814,7 @@ function _l({ target: e, size: t, rect: n }) {
|
|
|
15235
15814
|
destinationY: i - n.top
|
|
15236
15815
|
};
|
|
15237
15816
|
}
|
|
15238
|
-
function
|
|
15817
|
+
function _u({ editor: e, frame: t, offset: n }) {
|
|
15239
15818
|
e.canvasManager.getObjects().forEach((e) => {
|
|
15240
15819
|
e !== t && (e.set({
|
|
15241
15820
|
left: (e.left ?? 0) + n.x,
|
|
@@ -15245,12 +15824,12 @@ function vl({ editor: e, frame: t, offset: n }) {
|
|
|
15245
15824
|
}
|
|
15246
15825
|
//#endregion
|
|
15247
15826
|
//#region src/editor/crop-manager/index.ts
|
|
15248
|
-
var
|
|
15827
|
+
var vu = {
|
|
15249
15828
|
allowFrameOverflow: !0,
|
|
15250
15829
|
showGrid: !0,
|
|
15251
15830
|
cancelOnSelectionClear: !0,
|
|
15252
15831
|
preserveAspectRatio: !0
|
|
15253
|
-
},
|
|
15832
|
+
}, yu = .5, bu = class {
|
|
15254
15833
|
constructor({ editor: e }) {
|
|
15255
15834
|
this._handleCropFrameChanged = (e) => {
|
|
15256
15835
|
let { _session: t } = this;
|
|
@@ -15261,7 +15840,10 @@ var yl = {
|
|
|
15261
15840
|
});
|
|
15262
15841
|
this._clampFrameIfNeeded({
|
|
15263
15842
|
session: t,
|
|
15264
|
-
preserveAspectRatio: this.
|
|
15843
|
+
preserveAspectRatio: this._shouldPreserveAspectRatioOnFrameClamp({
|
|
15844
|
+
session: t,
|
|
15845
|
+
event: e
|
|
15846
|
+
})
|
|
15265
15847
|
}), n || this._rememberSourceBoundFrameIfNeeded({
|
|
15266
15848
|
session: t,
|
|
15267
15849
|
event: e
|
|
@@ -15286,18 +15868,22 @@ var yl = {
|
|
|
15286
15868
|
frame: e.frame,
|
|
15287
15869
|
options: e.options,
|
|
15288
15870
|
target: e.target,
|
|
15289
|
-
rect:
|
|
15871
|
+
rect: iu({ session: e })
|
|
15290
15872
|
} : null;
|
|
15291
15873
|
}
|
|
15292
15874
|
isFrameOverflowingSource({ target: e }) {
|
|
15293
15875
|
let { _session: t } = this;
|
|
15294
15876
|
if (!t || !e || t.options.allowFrameOverflow || t.frame !== e) return !1;
|
|
15295
|
-
let n =
|
|
15877
|
+
let n = Ac({
|
|
15296
15878
|
source: t.source,
|
|
15297
15879
|
frame: t.frame
|
|
15298
|
-
}), r = Z({ source: t.source }), i = -r.width / 2, a = -r.height / 2, o = r.width / 2, s = r.height / 2;
|
|
15880
|
+
}), r = Z({ source: t.source }), i = -r.width / 2 - yu, a = -r.height / 2 - yu, o = r.width / 2 + yu, s = r.height / 2 + yu;
|
|
15299
15881
|
return n.left < i || n.top < a || n.left + n.width > o || n.top + n.height > s;
|
|
15300
15882
|
}
|
|
15883
|
+
isFrameSourceScaleClamped({ target: e, transform: t }) {
|
|
15884
|
+
let { _session: n } = this;
|
|
15885
|
+
return !n || !e || !t || n.frame !== e ? !1 : t.cropSourceScaleClamped === !0;
|
|
15886
|
+
}
|
|
15301
15887
|
startCanvasCrop(e = {}) {
|
|
15302
15888
|
this.cancel();
|
|
15303
15889
|
let t = this._createCanvasSession({
|
|
@@ -15320,7 +15906,7 @@ var yl = {
|
|
|
15320
15906
|
setAspectRatio({ aspectRatio: e }) {
|
|
15321
15907
|
let { _session: t } = this;
|
|
15322
15908
|
if (!t) return null;
|
|
15323
|
-
let n =
|
|
15909
|
+
let n = kc({
|
|
15324
15910
|
sourceSize: Z({ source: t.source }),
|
|
15325
15911
|
aspectRatio: e ?? void 0,
|
|
15326
15912
|
allowOverflow: t.options.allowFrameOverflow
|
|
@@ -15333,7 +15919,7 @@ var yl = {
|
|
|
15333
15919
|
setSize({ size: e }) {
|
|
15334
15920
|
let { _session: t } = this;
|
|
15335
15921
|
if (!t) return null;
|
|
15336
|
-
let n =
|
|
15922
|
+
let n = kc({
|
|
15337
15923
|
sourceSize: Z({ source: t.source }),
|
|
15338
15924
|
size: e,
|
|
15339
15925
|
allowOverflow: t.options.allowFrameOverflow
|
|
@@ -15411,16 +15997,16 @@ var yl = {
|
|
|
15411
15997
|
}
|
|
15412
15998
|
_resolveSessionOptions({ options: e }) {
|
|
15413
15999
|
return {
|
|
15414
|
-
allowFrameOverflow: e.allowFrameOverflow ??
|
|
15415
|
-
showGrid: e.showGrid ??
|
|
15416
|
-
cancelOnSelectionClear: e.cancelOnSelectionClear ??
|
|
15417
|
-
preserveAspectRatio: e.preserveAspectRatio ??
|
|
16000
|
+
allowFrameOverflow: e.allowFrameOverflow ?? vu.allowFrameOverflow,
|
|
16001
|
+
showGrid: e.showGrid ?? vu.showGrid,
|
|
16002
|
+
cancelOnSelectionClear: e.cancelOnSelectionClear ?? vu.cancelOnSelectionClear,
|
|
16003
|
+
preserveAspectRatio: e.preserveAspectRatio ?? vu.preserveAspectRatio
|
|
15418
16004
|
};
|
|
15419
16005
|
}
|
|
15420
16006
|
_createCropFrameForSource({ source: e, options: t, sessionOptions: n }) {
|
|
15421
|
-
return
|
|
16007
|
+
return Ql({
|
|
15422
16008
|
source: e,
|
|
15423
|
-
cropSize:
|
|
16009
|
+
cropSize: kc({
|
|
15424
16010
|
sourceSize: Z({ source: e }),
|
|
15425
16011
|
size: t.size,
|
|
15426
16012
|
aspectRatio: t.aspectRatio,
|
|
@@ -15432,7 +16018,7 @@ var yl = {
|
|
|
15432
16018
|
});
|
|
15433
16019
|
}
|
|
15434
16020
|
_setFramePreserveAspectRatio({ frame: e, preserveAspectRatio: t }) {
|
|
15435
|
-
if (!(e instanceof
|
|
16021
|
+
if (!(e instanceof Zl)) throw Error("Crop session frame должен быть CropFrame");
|
|
15436
16022
|
e.preserveAspectRatio = t;
|
|
15437
16023
|
}
|
|
15438
16024
|
_activateSession({ session: e }) {
|
|
@@ -15452,10 +16038,24 @@ var yl = {
|
|
|
15452
16038
|
this.editor.canvas.off("mouse:down:before", this._handleCanvasMouseDownBefore), this.editor.canvas.off("selection:cleared", this._handleCanvasSelectionChanged), this.editor.canvas.off("selection:updated", this._handleCanvasSelectionChanged);
|
|
15453
16039
|
}
|
|
15454
16040
|
_restoreSourceBoundFrameIfNeeded({ session: e, event: t }) {
|
|
15455
|
-
|
|
16041
|
+
if (!this._isSourceScaleClamped({ event: t })) return e.sourceBoundFrameState = null, !1;
|
|
16042
|
+
let n = e.sourceBoundFrameState ?? this._getSourceBoundFrameStateFromEvent({
|
|
15456
16043
|
session: e,
|
|
15457
|
-
|
|
15458
|
-
})
|
|
16044
|
+
event: t
|
|
16045
|
+
});
|
|
16046
|
+
return n ? (this._applyFrameTransformState({
|
|
16047
|
+
session: e,
|
|
16048
|
+
state: n
|
|
16049
|
+
}), !0) : !1;
|
|
16050
|
+
}
|
|
16051
|
+
_getSourceBoundFrameStateFromEvent({ session: e, event: t }) {
|
|
16052
|
+
let n = t?.transform?.cropSourceBoundScale;
|
|
16053
|
+
return !n || !Number.isFinite(n.scaleX) || !Number.isFinite(n.scaleY) ? null : {
|
|
16054
|
+
left: e.frame.left,
|
|
16055
|
+
top: e.frame.top,
|
|
16056
|
+
scaleX: n.scaleX,
|
|
16057
|
+
scaleY: n.scaleY
|
|
16058
|
+
};
|
|
15459
16059
|
}
|
|
15460
16060
|
_rememberSourceBoundFrameIfNeeded({ session: e, event: t }) {
|
|
15461
16061
|
if (!this._isSourceScaleClamped({ event: t })) {
|
|
@@ -15467,6 +16067,9 @@ var yl = {
|
|
|
15467
16067
|
_isSourceScaleClamped({ event: e }) {
|
|
15468
16068
|
return e?.transform?.cropSourceScaleClamped === !0;
|
|
15469
16069
|
}
|
|
16070
|
+
_shouldPreserveAspectRatioOnFrameClamp({ session: e, event: t }) {
|
|
16071
|
+
return this._isSourceScaleClamped({ event: t }) ? t?.transform?.cropSourceScalePreserveAspectRatio ?? !0 : t?.e?.shiftKey ? !e.options.preserveAspectRatio : e.options.preserveAspectRatio;
|
|
16072
|
+
}
|
|
15470
16073
|
_getFrameTransformState({ session: e }) {
|
|
15471
16074
|
return {
|
|
15472
16075
|
left: e.frame.left,
|
|
@@ -15523,25 +16126,25 @@ var yl = {
|
|
|
15523
16126
|
_clampFrameIfNeeded({ session: e, preserveAspectRatio: t = !1 }) {
|
|
15524
16127
|
if (!e.options.allowFrameOverflow) {
|
|
15525
16128
|
if (t) {
|
|
15526
|
-
|
|
16129
|
+
Mc({
|
|
15527
16130
|
source: e.source,
|
|
15528
16131
|
frame: e.frame
|
|
15529
16132
|
});
|
|
15530
16133
|
return;
|
|
15531
16134
|
}
|
|
15532
|
-
|
|
16135
|
+
jc({
|
|
15533
16136
|
source: e.source,
|
|
15534
16137
|
frame: e.frame
|
|
15535
16138
|
});
|
|
15536
16139
|
}
|
|
15537
16140
|
}
|
|
15538
16141
|
_applySessionCrop({ session: e }) {
|
|
15539
|
-
let t =
|
|
15540
|
-
return e.mode === "canvas" ?
|
|
16142
|
+
let t = au({ rect: iu({ session: e }) });
|
|
16143
|
+
return e.mode === "canvas" ? lu({
|
|
15541
16144
|
editor: this.editor,
|
|
15542
16145
|
frame: e.frame,
|
|
15543
16146
|
rect: t
|
|
15544
|
-
}) :
|
|
16147
|
+
}) : uu({
|
|
15545
16148
|
editor: this.editor,
|
|
15546
16149
|
target: e.target,
|
|
15547
16150
|
frame: e.frame,
|
|
@@ -15589,7 +16192,7 @@ var yl = {
|
|
|
15589
16192
|
this.editor.errorManager.emitError({
|
|
15590
16193
|
origin: "CropManager",
|
|
15591
16194
|
method: "startImageCrop",
|
|
15592
|
-
code:
|
|
16195
|
+
code: Ja.CROP_MANAGER.INVALID_IMAGE_TARGET,
|
|
15593
16196
|
message: "Для кропа изображения нужно выбрать raster image объект.",
|
|
15594
16197
|
data: {
|
|
15595
16198
|
targetType: e?.type,
|
|
@@ -15601,7 +16204,7 @@ var yl = {
|
|
|
15601
16204
|
this.editor.errorManager.emitError({
|
|
15602
16205
|
origin: "CropManager",
|
|
15603
16206
|
method: "startImageCrop",
|
|
15604
|
-
code:
|
|
16207
|
+
code: Ja.CROP_MANAGER.LOCKED_IMAGE_TARGET,
|
|
15605
16208
|
message: "Заблокированное изображение нельзя обрезать.",
|
|
15606
16209
|
data: {
|
|
15607
16210
|
targetType: e.type,
|
|
@@ -15609,13 +16212,13 @@ var yl = {
|
|
|
15609
16212
|
}
|
|
15610
16213
|
});
|
|
15611
16214
|
}
|
|
15612
|
-
},
|
|
16215
|
+
}, xu = class e {
|
|
15613
16216
|
constructor(e, t) {
|
|
15614
16217
|
this.options = t, this.containerId = e, this.editorId = `${e}-${D()}`, this.init();
|
|
15615
16218
|
}
|
|
15616
16219
|
async init() {
|
|
15617
16220
|
let { editorContainerWidth: e, editorContainerHeight: n, canvasWrapperWidth: r, canvasWrapperHeight: i, canvasCSSWidth: a, canvasCSSHeight: o, initialImage: s, initialState: c, scaleType: l, showRotationAngle: u, showObjectSizeOnScale: d, showViewportScrollbars: f, _onReadyCallback: p } = this.options;
|
|
15618
|
-
if (ve.apply(), this.canvas = new t(this.containerId, this.options), this.moduleLoader = new ee(), this.workerManager = new ne(), this.errorManager = new
|
|
16221
|
+
if (ve.apply(), this.canvas = new t(this.containerId, this.options), this.moduleLoader = new ee(), this.workerManager = new ne(), this.errorManager = new Ya({ editor: this }), this.historyManager = new Ut({ editor: this }), this.toolbar = new at({ editor: this }), this.transformManager = new en({ editor: this }), this.zoomManager = new tn({ editor: this }), this.canvasManager = new $t({ editor: this }), this.imageManager = new Yt({ editor: this }), this.layerManager = new Vn({ editor: this }), this.shapeManager = new Va({ editor: this }), this.interactionBlocker = new zn({ editor: this }), this.backgroundManager = new Bn({ editor: this }), this.clipboardManager = new Ua({ editor: this }), this.objectLockManager = new Wa({ editor: this }), this.groupingManager = new Ga({ editor: this }), this.selectionManager = new Ka({ editor: this }), this.deletionManager = new qa({ editor: this }), this.panConstraintManager = new Za({ editor: this }), this.snappingManager = new xc({ editor: this }), this.measurementManager = new Cc({ editor: this }), this.fontManager = new ye(this.options.fonts ?? []), this.textManager = new _o({ editor: this }), this.templateManager = new So({ editor: this }), this.cropManager = new bu({ editor: this }), u && (this.angleIndicator = new lt({ editor: this })), d && (this.objectSizeIndicator = new dt({ editor: this })), this._createMontageArea(), this._createClippingArea(), this.interactionBlocker.ensureOverlay(), this.listeners = new F({
|
|
15619
16222
|
editor: this,
|
|
15620
16223
|
options: this.options
|
|
15621
16224
|
}), 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(), f && (this.viewportScrollbars = new _t({ editor: this })), await this.fontManager.loadFonts(), c) {
|
|
@@ -15723,7 +16326,7 @@ var yl = {
|
|
|
15723
16326
|
"U+A640-A69F",
|
|
15724
16327
|
"U+FE2E-FE2F",
|
|
15725
16328
|
"U+2116"
|
|
15726
|
-
].join(", "),
|
|
16329
|
+
].join(", "), Su = {
|
|
15727
16330
|
preserveObjectStacking: !0,
|
|
15728
16331
|
controlsAboveOverlay: !0,
|
|
15729
16332
|
centeredRotation: !0,
|
|
@@ -16581,20 +17184,20 @@ var yl = {
|
|
|
16581
17184
|
};
|
|
16582
17185
|
//#endregion
|
|
16583
17186
|
//#region src/main.ts
|
|
16584
|
-
function
|
|
17187
|
+
function Cu(e, t = {}) {
|
|
16585
17188
|
let n = {
|
|
16586
|
-
...
|
|
17189
|
+
...Su,
|
|
16587
17190
|
...t
|
|
16588
17191
|
}, r = document.getElementById(e);
|
|
16589
17192
|
if (!r) return Promise.reject(/* @__PURE__ */ Error(`Контейнер с ID "${e}" не найден.`));
|
|
16590
17193
|
let i = document.createElement("canvas");
|
|
16591
17194
|
return i.id = `${e}-canvas`, r.appendChild(i), n.editorContainer = r, new Promise((t) => {
|
|
16592
17195
|
n._onReadyCallback = t;
|
|
16593
|
-
let r = new
|
|
17196
|
+
let r = new xu(i.id, n);
|
|
16594
17197
|
window[e] = r;
|
|
16595
17198
|
});
|
|
16596
17199
|
}
|
|
16597
17200
|
//#endregion
|
|
16598
|
-
export {
|
|
17201
|
+
export { Cu as default };
|
|
16599
17202
|
|
|
16600
17203
|
//# sourceMappingURL=main.js.map
|