@anu3ev/fabric-image-editor 0.9.18 → 0.9.19
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 +988 -655
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -714,16 +714,16 @@ var de = {
|
|
|
714
714
|
try {
|
|
715
715
|
i.forEach((t) => {
|
|
716
716
|
if (o || e.normalizeFamilyName(t.family) !== a) return;
|
|
717
|
-
let n = e.getDescriptorSnapshot({
|
|
718
|
-
style:
|
|
719
|
-
weight:
|
|
720
|
-
stretch:
|
|
721
|
-
unicodeRange:
|
|
722
|
-
variant:
|
|
723
|
-
featureSettings:
|
|
724
|
-
display:
|
|
717
|
+
let n = t, i = e.getDescriptorSnapshot({
|
|
718
|
+
style: n.style,
|
|
719
|
+
weight: n.weight,
|
|
720
|
+
stretch: n.stretch,
|
|
721
|
+
unicodeRange: n.unicodeRange,
|
|
722
|
+
variant: n.variant,
|
|
723
|
+
featureSettings: n.featureSettings,
|
|
724
|
+
display: n.display
|
|
725
725
|
});
|
|
726
|
-
e.areDescriptorSnapshotsEqual(r,
|
|
726
|
+
e.areDescriptorSnapshotsEqual(r, i) && (o = !0);
|
|
727
727
|
});
|
|
728
728
|
} catch (e) {
|
|
729
729
|
return console.warn("Не удалось проверить, загружен ли шрифт ранее через FontFaceSet", e), !1;
|
|
@@ -2996,38 +2996,34 @@ var Ut = class {
|
|
|
2996
2996
|
async prepareInitialState({ state: e }) {
|
|
2997
2997
|
if (!e) return e;
|
|
2998
2998
|
let t = JSON.parse(JSON.stringify(e)), n = /* @__PURE__ */ new Map(), { objects: r = [] } = t;
|
|
2999
|
-
console.log("objects", r)
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
object: t,
|
|
3004
|
-
cache: n
|
|
3005
|
-
});
|
|
3006
|
-
}
|
|
3007
|
-
return t;
|
|
2999
|
+
return console.log("objects", r), await this._replaceImageSrcInObjects({
|
|
3000
|
+
objects: r,
|
|
3001
|
+
cache: n
|
|
3002
|
+
}), t;
|
|
3008
3003
|
}
|
|
3009
|
-
async
|
|
3010
|
-
|
|
3011
|
-
let
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
src:
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
cache: t
|
|
3028
|
-
});
|
|
3004
|
+
async _replaceImageSrcInObjects({ objects: t, cache: n }) {
|
|
3005
|
+
let r = [...t];
|
|
3006
|
+
for (let t = 0; t < r.length; t += 1) {
|
|
3007
|
+
let i = r[t];
|
|
3008
|
+
if (!e._isSerializedObject(i)) continue;
|
|
3009
|
+
let { type: a, src: o, objects: s } = i, c = typeof a == "string" ? a.toLowerCase() : "";
|
|
3010
|
+
if (console.log("_replaceImageSrcInObject", {
|
|
3011
|
+
type: a,
|
|
3012
|
+
src: o,
|
|
3013
|
+
objects: s
|
|
3014
|
+
}), c === "image" && typeof o == "string") {
|
|
3015
|
+
let e = await this._getOrCreateBlobUrl({
|
|
3016
|
+
src: o,
|
|
3017
|
+
cache: n
|
|
3018
|
+
});
|
|
3019
|
+
e && (i.src = e);
|
|
3020
|
+
}
|
|
3021
|
+
Array.isArray(s) && r.push(...s);
|
|
3029
3022
|
}
|
|
3030
3023
|
}
|
|
3024
|
+
static _isSerializedObject(e) {
|
|
3025
|
+
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
3026
|
+
}
|
|
3031
3027
|
async _getOrCreateBlobUrl({ src: t, cache: n }) {
|
|
3032
3028
|
if (e._isBlobOrDataUrl({ src: t })) return t;
|
|
3033
3029
|
if (n.has(t)) return n.get(t) ?? null;
|
|
@@ -3053,140 +3049,215 @@ var Ut = class {
|
|
|
3053
3049
|
return null;
|
|
3054
3050
|
}
|
|
3055
3051
|
}
|
|
3056
|
-
async importImage(
|
|
3057
|
-
let
|
|
3058
|
-
if (!
|
|
3059
|
-
let {
|
|
3060
|
-
|
|
3061
|
-
let e = `Неверный contentType для изображения: ${g}. Ожидается один из: ${this.acceptContentTypes.join(", ")}.`;
|
|
3062
|
-
return h.emitError({
|
|
3063
|
-
origin: "ImageManager",
|
|
3064
|
-
method: "importImage",
|
|
3065
|
-
code: "INVALID_CONTENT_TYPE",
|
|
3066
|
-
message: e,
|
|
3067
|
-
data: {
|
|
3068
|
-
source: t,
|
|
3069
|
-
format: _,
|
|
3070
|
-
contentType: g,
|
|
3071
|
-
acceptContentTypes: v,
|
|
3072
|
-
acceptFormats: y,
|
|
3073
|
-
fromClipboard: i,
|
|
3074
|
-
isBackground: o,
|
|
3075
|
-
withoutSelection: s,
|
|
3076
|
-
withoutAdding: c,
|
|
3077
|
-
customData: l
|
|
3078
|
-
}
|
|
3079
|
-
}), null;
|
|
3080
|
-
}
|
|
3081
|
-
m.suspendHistory();
|
|
3052
|
+
async importImage(t) {
|
|
3053
|
+
let n = await this._createImportImageRequest({ options: t });
|
|
3054
|
+
if (!n) return null;
|
|
3055
|
+
let { historyManager: r } = this.editor;
|
|
3056
|
+
r.suspendHistory();
|
|
3082
3057
|
try {
|
|
3083
|
-
let
|
|
3084
|
-
if (t
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3058
|
+
let { source: t } = n;
|
|
3059
|
+
if (!e._isSupportedImageSource(t)) return this._emitInvalidSourceTypeError({ request: n }), r.resumeHistory(), null;
|
|
3060
|
+
let i = {
|
|
3061
|
+
...n,
|
|
3062
|
+
source: t
|
|
3063
|
+
}, a = await this._resolveImportImageUrl({ request: i }), o = await this._loadImportImage({
|
|
3064
|
+
dataUrl: a,
|
|
3065
|
+
format: n.format
|
|
3066
|
+
}), s = await this._resizeImportImageIfNeeded({
|
|
3067
|
+
image: o,
|
|
3068
|
+
contentType: n.contentType
|
|
3069
|
+
});
|
|
3070
|
+
return this._applyImportedImageProperties({
|
|
3071
|
+
image: s,
|
|
3072
|
+
request: i
|
|
3073
|
+
}), this._placeImportedImage({
|
|
3074
|
+
image: s,
|
|
3075
|
+
request: i
|
|
3076
|
+
}), this._completeImportImage({
|
|
3077
|
+
image: s,
|
|
3078
|
+
request: i
|
|
3079
|
+
});
|
|
3080
|
+
} catch (e) {
|
|
3081
|
+
return this._emitImportFailed({
|
|
3082
|
+
error: e,
|
|
3083
|
+
request: n
|
|
3084
|
+
}), r.resumeHistory(), null;
|
|
3085
|
+
}
|
|
3086
|
+
}
|
|
3087
|
+
async _createImportImageRequest({ options: t }) {
|
|
3088
|
+
let { source: n, withoutSave: r = !1, fromClipboard: i = !1, isBackground: a = !1, withoutSelection: o = !1, withoutAdding: s = !1, customData: c = null } = t;
|
|
3089
|
+
if (!n) return null;
|
|
3090
|
+
let l = t.scale ?? (this.options.scaleType === "cover" ? "image-cover" : "image-contain"), u = e._isSupportedImageSource(n) ? await this.getContentType(n) : e._getInvalidSourceContentType({ source: n }), d = {
|
|
3091
|
+
source: n,
|
|
3092
|
+
scale: l,
|
|
3093
|
+
withoutSave: r,
|
|
3094
|
+
fromClipboard: i,
|
|
3095
|
+
isBackground: a,
|
|
3096
|
+
withoutSelection: o,
|
|
3097
|
+
withoutAdding: s,
|
|
3098
|
+
customData: c,
|
|
3099
|
+
contentType: u,
|
|
3100
|
+
format: this.getFormatFromContentType(u)
|
|
3101
|
+
};
|
|
3102
|
+
return !e._isSupportedImageSource(n) || this.isAllowedContentType(u) ? d : (this._emitInvalidContentTypeError({ request: d }), null);
|
|
3103
|
+
}
|
|
3104
|
+
static _isSupportedImageSource(e) {
|
|
3105
|
+
return e instanceof File || typeof e == "string";
|
|
3106
|
+
}
|
|
3107
|
+
static _getInvalidSourceContentType({ source: t }) {
|
|
3108
|
+
if (!e._isSerializedObject(t)) return "application/octet-stream";
|
|
3109
|
+
let { type: n } = t;
|
|
3110
|
+
return typeof n == "string" ? n : "application/octet-stream";
|
|
3111
|
+
}
|
|
3112
|
+
_emitInvalidContentTypeError({ request: e }) {
|
|
3113
|
+
let { acceptContentTypes: t, acceptFormats: n } = this, { source: r, format: i, contentType: a, fromClipboard: o, isBackground: s, withoutSelection: c, withoutAdding: l, customData: u } = e, d = `Неверный contentType для изображения: ${a}. Ожидается один из: ${t.join(", ")}.`;
|
|
3114
|
+
this.editor.errorManager.emitError({
|
|
3115
|
+
origin: "ImageManager",
|
|
3116
|
+
method: "importImage",
|
|
3117
|
+
code: "INVALID_CONTENT_TYPE",
|
|
3118
|
+
message: d,
|
|
3119
|
+
data: {
|
|
3120
|
+
source: r,
|
|
3121
|
+
format: i,
|
|
3122
|
+
contentType: a,
|
|
3123
|
+
acceptContentTypes: t,
|
|
3124
|
+
acceptFormats: n,
|
|
3125
|
+
fromClipboard: o,
|
|
3126
|
+
isBackground: s,
|
|
3127
|
+
withoutSelection: c,
|
|
3128
|
+
withoutAdding: l,
|
|
3129
|
+
customData: u
|
|
3126
3130
|
}
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3131
|
+
});
|
|
3132
|
+
}
|
|
3133
|
+
_emitInvalidSourceTypeError({ request: e }) {
|
|
3134
|
+
let { acceptContentTypes: t, acceptFormats: n } = this, { source: r, format: i, contentType: a, fromClipboard: o, isBackground: s, withoutSelection: c, withoutAdding: l, customData: u } = e;
|
|
3135
|
+
this.editor.errorManager.emitError({
|
|
3136
|
+
origin: "ImageManager",
|
|
3137
|
+
method: "importImage",
|
|
3138
|
+
code: "INVALID_SOURCE_TYPE",
|
|
3139
|
+
message: "Неверный тип источника изображения. Ожидается URL или объект File.",
|
|
3140
|
+
data: {
|
|
3141
|
+
source: r,
|
|
3142
|
+
format: i,
|
|
3143
|
+
contentType: a,
|
|
3144
|
+
acceptContentTypes: t,
|
|
3145
|
+
acceptFormats: n,
|
|
3146
|
+
fromClipboard: o,
|
|
3147
|
+
isBackground: s,
|
|
3148
|
+
withoutSelection: c,
|
|
3149
|
+
withoutAdding: l,
|
|
3150
|
+
customData: u
|
|
3151
|
+
}
|
|
3152
|
+
});
|
|
3153
|
+
}
|
|
3154
|
+
async _resolveImportImageUrl({ request: e }) {
|
|
3155
|
+
let { source: t } = e;
|
|
3156
|
+
if (t instanceof File) {
|
|
3157
|
+
let e = URL.createObjectURL(t);
|
|
3158
|
+
return this._createdBlobUrls.push(e), e;
|
|
3159
|
+
}
|
|
3160
|
+
let n = await this._fetchAsBlobUrl({ src: t });
|
|
3161
|
+
if (!n) throw Error("Не удалось загрузить изображение по URL");
|
|
3162
|
+
return n;
|
|
3163
|
+
}
|
|
3164
|
+
async _loadImportImage({ dataUrl: e, format: t }) {
|
|
3165
|
+
if (t === "svg") {
|
|
3166
|
+
let t = await C(e);
|
|
3167
|
+
return w.groupSVGElements(t.objects, t.options);
|
|
3168
|
+
}
|
|
3169
|
+
return a.fromURL(e, { crossOrigin: "anonymous" });
|
|
3170
|
+
}
|
|
3171
|
+
async _resizeImportImageIfNeeded({ image: e, contentType: t }) {
|
|
3172
|
+
if (!(e instanceof a)) return e;
|
|
3173
|
+
let { width: n, height: r } = e;
|
|
3174
|
+
return r > 4096 || n > 4096 ? this._resizeImportImageToBoundaries({
|
|
3175
|
+
image: e,
|
|
3176
|
+
contentType: t,
|
|
3177
|
+
sizeType: "max"
|
|
3178
|
+
}) : r < 16 || n < 16 ? this._resizeImportImageToBoundaries({
|
|
3179
|
+
image: e,
|
|
3180
|
+
contentType: t,
|
|
3181
|
+
sizeType: "min"
|
|
3182
|
+
}) : e;
|
|
3183
|
+
}
|
|
3184
|
+
async _resizeImportImageToBoundaries({ image: t, contentType: n, sizeType: r }) {
|
|
3185
|
+
let i = e._getImageElementSource({ image: t }), o = await this.resizeImageToBoundaries({
|
|
3186
|
+
dataURL: i,
|
|
3187
|
+
sizeType: r,
|
|
3188
|
+
contentType: n
|
|
3189
|
+
}), s = URL.createObjectURL(o);
|
|
3190
|
+
return this._createdBlobUrls.push(s), a.fromURL(s, { crossOrigin: "anonymous" });
|
|
3191
|
+
}
|
|
3192
|
+
static _getImageElementSource({ image: e }) {
|
|
3193
|
+
let t = e.getElement();
|
|
3194
|
+
if (t instanceof HTMLImageElement) return t.src;
|
|
3195
|
+
if (t instanceof HTMLCanvasElement) return t.toDataURL();
|
|
3196
|
+
throw Error("Не удалось получить источник изображения для resize");
|
|
3197
|
+
}
|
|
3198
|
+
_applyImportedImageProperties({ image: e, request: t }) {
|
|
3199
|
+
e.set({
|
|
3200
|
+
id: `${e.type}-${D()}`,
|
|
3201
|
+
format: t.format,
|
|
3202
|
+
contentType: t.contentType,
|
|
3203
|
+
customData: t.customData ?? null,
|
|
3204
|
+
originX: "left",
|
|
3205
|
+
originY: "top"
|
|
3206
|
+
});
|
|
3207
|
+
}
|
|
3208
|
+
_placeImportedImage({ image: e, request: t }) {
|
|
3209
|
+
if (t.scale === "scale-montage") {
|
|
3210
|
+
this.editor.canvasManager.scaleMontageAreaToImage({
|
|
3211
|
+
object: e,
|
|
3136
3212
|
withoutSave: !0
|
|
3137
3213
|
});
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
});
|
|
3152
|
-
}
|
|
3153
|
-
let T = {
|
|
3154
|
-
image: b,
|
|
3155
|
-
format: _,
|
|
3156
|
-
contentType: g,
|
|
3157
|
-
scale: n,
|
|
3158
|
-
withoutSave: r,
|
|
3159
|
-
source: t,
|
|
3160
|
-
fromClipboard: i,
|
|
3161
|
-
isBackground: o,
|
|
3162
|
-
withoutSelection: s,
|
|
3163
|
-
withoutAdding: c,
|
|
3164
|
-
customData: l
|
|
3165
|
-
};
|
|
3166
|
-
return c ? (m.resumeHistory(), u.fire("editor:image-imported", T), T) : (u.add(b), d.centerObjectToMontageArea({ object: b }), s || u.setActiveObject(b), u.renderAll(), m.resumeHistory(), r || m.saveState(), u.fire("editor:image-imported", T), T);
|
|
3167
|
-
} catch (e) {
|
|
3168
|
-
return h.emitError({
|
|
3169
|
-
origin: "ImageManager",
|
|
3170
|
-
method: "importImage",
|
|
3171
|
-
code: "IMPORT_FAILED",
|
|
3172
|
-
message: `Ошибка импорта изображения: ${e.message}`,
|
|
3173
|
-
data: {
|
|
3174
|
-
source: t,
|
|
3175
|
-
format: _,
|
|
3176
|
-
contentType: g,
|
|
3177
|
-
scale: n,
|
|
3178
|
-
withoutSave: r,
|
|
3179
|
-
fromClipboard: i,
|
|
3180
|
-
isBackground: o,
|
|
3181
|
-
withoutSelection: s,
|
|
3182
|
-
withoutAdding: c,
|
|
3183
|
-
customData: l
|
|
3184
|
-
}
|
|
3185
|
-
}), m.resumeHistory(), null;
|
|
3214
|
+
return;
|
|
3215
|
+
}
|
|
3216
|
+
let { montageArea: n, transformManager: r } = this.editor, { width: i, height: a } = n, { width: o, height: s } = e, c = this.calculateScaleFactor({
|
|
3217
|
+
imageObject: e,
|
|
3218
|
+
scaleType: t.scale
|
|
3219
|
+
});
|
|
3220
|
+
if (t.scale === "image-contain" && c < 1) {
|
|
3221
|
+
r.fitObject({
|
|
3222
|
+
object: e,
|
|
3223
|
+
type: "contain",
|
|
3224
|
+
withoutSave: !0
|
|
3225
|
+
});
|
|
3226
|
+
return;
|
|
3186
3227
|
}
|
|
3228
|
+
t.scale === "image-cover" && (o <= i && s <= a || r.fitObject({
|
|
3229
|
+
object: e,
|
|
3230
|
+
type: "cover",
|
|
3231
|
+
withoutSave: !0
|
|
3232
|
+
}));
|
|
3233
|
+
}
|
|
3234
|
+
_completeImportImage({ image: e, request: t }) {
|
|
3235
|
+
let { canvas: n, canvasManager: r, historyManager: i } = this.editor, { format: a, contentType: o, scale: s, withoutSave: c, source: l, fromClipboard: u, isBackground: d, withoutSelection: f, withoutAdding: p, customData: m } = t, h = {
|
|
3236
|
+
image: e,
|
|
3237
|
+
format: a,
|
|
3238
|
+
contentType: o,
|
|
3239
|
+
scale: s,
|
|
3240
|
+
withoutSave: c,
|
|
3241
|
+
source: l,
|
|
3242
|
+
fromClipboard: u,
|
|
3243
|
+
isBackground: d,
|
|
3244
|
+
withoutSelection: f,
|
|
3245
|
+
withoutAdding: p,
|
|
3246
|
+
customData: m
|
|
3247
|
+
};
|
|
3248
|
+
return p ? (i.resumeHistory(), n.fire("editor:image-imported", h), h) : (n.add(e), r.centerObjectToMontageArea({ object: e }), f || n.setActiveObject(e), n.renderAll(), i.resumeHistory(), c || i.saveState(), n.fire("editor:image-imported", h), h);
|
|
3249
|
+
}
|
|
3250
|
+
_emitImportFailed({ error: e, request: t }) {
|
|
3251
|
+
this.editor.errorManager.emitError({
|
|
3252
|
+
origin: "ImageManager",
|
|
3253
|
+
method: "importImage",
|
|
3254
|
+
code: "IMPORT_FAILED",
|
|
3255
|
+
message: `Ошибка импорта изображения: ${e.message}`,
|
|
3256
|
+
data: t
|
|
3257
|
+
});
|
|
3187
3258
|
}
|
|
3188
3259
|
async resizeImageToBoundaries(e) {
|
|
3189
|
-
let { dataURL: t, sizeType: n = "max", contentType: r = "image/png", quality: i = 1, maxWidth: a = Gt, maxHeight: o = Kt, minWidth: s = 16, minHeight: c = 16, asBase64: l = !1, emitMessage: u = !0 } = e, {
|
|
3260
|
+
let { dataURL: t, sizeType: n = "max", contentType: r = "image/png", quality: i = 1, maxWidth: a = Gt, maxHeight: o = Kt, minWidth: s = 16, minHeight: c = 16, asBase64: l = !1, emitMessage: u = !0 } = e, { workerManager: d } = this.editor, f = {
|
|
3190
3261
|
dataURL: t,
|
|
3191
3262
|
sizeType: n,
|
|
3192
3263
|
contentType: r,
|
|
@@ -3196,26 +3267,27 @@ var Ut = class {
|
|
|
3196
3267
|
minWidth: s,
|
|
3197
3268
|
minHeight: c
|
|
3198
3269
|
};
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
n === "min" && (e = `Размер изображения меньше минимального размера канваса, поэтому оно будет увеличено до минимальных размеров c сохранением пропорций: ${s}x${c}`), d.emitWarning({
|
|
3202
|
-
origin: "ImageManager",
|
|
3203
|
-
method: "resizeImageToBoundaries",
|
|
3204
|
-
code: "IMAGE_RESIZE_WARNING",
|
|
3205
|
-
message: e,
|
|
3206
|
-
data: p
|
|
3207
|
-
});
|
|
3208
|
-
}
|
|
3209
|
-
let m = await f.post("resizeImage", p);
|
|
3270
|
+
u && this._emitImageResizeWarning({ data: f });
|
|
3271
|
+
let p = await d.post("resizeImage", f);
|
|
3210
3272
|
if (l) {
|
|
3211
|
-
let e = await createImageBitmap(
|
|
3212
|
-
return await
|
|
3273
|
+
let e = await createImageBitmap(p);
|
|
3274
|
+
return await d.post("toDataURL", {
|
|
3213
3275
|
contentType: r,
|
|
3214
3276
|
quality: i,
|
|
3215
3277
|
bitmap: e
|
|
3216
3278
|
}, [e]);
|
|
3217
3279
|
}
|
|
3218
|
-
return
|
|
3280
|
+
return p;
|
|
3281
|
+
}
|
|
3282
|
+
_emitImageResizeWarning({ data: e }) {
|
|
3283
|
+
let { sizeType: t, maxWidth: n, maxHeight: r, minWidth: i, minHeight: a } = e, o = `Размер изображения больше максимального размера канваса, поэтому оно будет уменьшено до максимальных размеров c сохранением пропорций: ${n}x${r}`;
|
|
3284
|
+
t === "min" && (o = `Размер изображения меньше минимального размера канваса, поэтому оно будет увеличено до минимальных размеров c сохранением пропорций: ${i}x${a}`), this.editor.errorManager.emitWarning({
|
|
3285
|
+
origin: "ImageManager",
|
|
3286
|
+
method: "resizeImageToBoundaries",
|
|
3287
|
+
code: "IMAGE_RESIZE_WARNING",
|
|
3288
|
+
message: o,
|
|
3289
|
+
data: e
|
|
3290
|
+
});
|
|
3219
3291
|
}
|
|
3220
3292
|
async exportCanvasAsImageFile(t = {}) {
|
|
3221
3293
|
let { fileName: n = "image.png", contentType: r = "image/png", exportAsBase64: i = !1, exportAsBlob: a = !1 } = t, { canvas: o, canvasManager: s, montageArea: c, workerManager: l, interactionBlocker: u } = this.editor;
|
|
@@ -13455,23 +13527,23 @@ var go = class {
|
|
|
13455
13527
|
color: d,
|
|
13456
13528
|
lineWidth: 1
|
|
13457
13529
|
});
|
|
13458
|
-
}, is = .01, as = .1, os = 1e-6;
|
|
13459
|
-
function
|
|
13530
|
+
}, is = .01, as = .1, os = 1e-6, ss = .02, cs = 1e-6, ls = 1;
|
|
13531
|
+
function us({ target: e }) {
|
|
13460
13532
|
let t = typeof e.type == "string" ? e.type.toLowerCase() : "", n = e instanceof v || t === "textbox" || t === "background-textbox";
|
|
13461
13533
|
return !(e instanceof a) && !n;
|
|
13462
13534
|
}
|
|
13463
|
-
function
|
|
13535
|
+
function ds({ target: e, transform: t }) {
|
|
13464
13536
|
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 = {};
|
|
13465
13537
|
c && i !== n && (u.left = i), l && a !== r && (u.top = a), !(!("left" in u) && !("top" in u)) && (e.set(u), e.setCoords());
|
|
13466
13538
|
}
|
|
13467
|
-
function
|
|
13539
|
+
function fs({ target: e }) {
|
|
13468
13540
|
let { width: t = 0, height: n = 0, paddingTop: r = 0, paddingRight: i = 0, paddingBottom: a = 0, paddingLeft: o = 0, strokeWidth: s = 0 } = e;
|
|
13469
13541
|
return {
|
|
13470
13542
|
width: t + o + i + s,
|
|
13471
13543
|
height: n + r + a + s
|
|
13472
13544
|
};
|
|
13473
13545
|
}
|
|
13474
|
-
function
|
|
13546
|
+
function ps({ target: e, scaleX: t, scaleY: n }) {
|
|
13475
13547
|
let r = e.getObjectDisplaySize?.();
|
|
13476
13548
|
if (!r) return null;
|
|
13477
13549
|
let i = Math.abs(t), a = Math.abs(n);
|
|
@@ -13480,36 +13552,37 @@ function us({ target: e, scaleX: t, scaleY: n }) {
|
|
|
13480
13552
|
height: r.height / a
|
|
13481
13553
|
};
|
|
13482
13554
|
}
|
|
13483
|
-
function
|
|
13484
|
-
let r =
|
|
13555
|
+
function ms({ target: e, scaleX: t, scaleY: n }) {
|
|
13556
|
+
let r = ps({
|
|
13485
13557
|
target: e,
|
|
13486
13558
|
scaleX: t,
|
|
13487
13559
|
scaleY: n
|
|
13488
13560
|
});
|
|
13489
13561
|
if (r) return r;
|
|
13490
|
-
if (e instanceof v) return
|
|
13562
|
+
if (e instanceof v) return fs({ target: e });
|
|
13491
13563
|
let { width: i = 0, height: a = 0, strokeWidth: o = 0, strokeUniform: s = !1 } = e, c = s ? 0 : o;
|
|
13492
13564
|
return {
|
|
13493
13565
|
width: i + c,
|
|
13494
13566
|
height: a + c
|
|
13495
13567
|
};
|
|
13496
13568
|
}
|
|
13497
|
-
function
|
|
13498
|
-
let { scaleX: i = 1, scaleY: a = 1 } = e, o =
|
|
13569
|
+
function hs({ target: e, transform: t, preservePlacement: n, snapGuards: r = [] }) {
|
|
13570
|
+
let { scaleX: i = 1, scaleY: a = 1 } = e, o = gs({
|
|
13499
13571
|
transform: t,
|
|
13500
13572
|
rawScaleX: i,
|
|
13501
13573
|
rawScaleY: a
|
|
13502
13574
|
});
|
|
13503
13575
|
if (!o.shouldRoundScaleX && !o.shouldRoundScaleY) return;
|
|
13504
|
-
let { width: s, height: c } =
|
|
13576
|
+
let { width: s, height: c } = ms({
|
|
13505
13577
|
target: e,
|
|
13506
13578
|
scaleX: i,
|
|
13507
13579
|
scaleY: a
|
|
13508
|
-
}), l =
|
|
13580
|
+
}), l = _s({
|
|
13509
13581
|
rawScaleX: i,
|
|
13510
13582
|
rawScaleY: a,
|
|
13511
|
-
snappedScale:
|
|
13583
|
+
snappedScale: bs({
|
|
13512
13584
|
target: e,
|
|
13585
|
+
transform: t,
|
|
13513
13586
|
rawScaleX: i,
|
|
13514
13587
|
rawScaleY: a,
|
|
13515
13588
|
effectiveWidth: s,
|
|
@@ -13519,82 +13592,83 @@ function fs({ target: e, transform: t, preservePlacement: n, snapGuards: r = []
|
|
|
13519
13592
|
}),
|
|
13520
13593
|
roundingState: o
|
|
13521
13594
|
});
|
|
13522
|
-
l.scaleX === i && l.scaleY === a ||
|
|
13595
|
+
l.scaleX === i && l.scaleY === a || vs({
|
|
13523
13596
|
target: e,
|
|
13524
13597
|
transform: t,
|
|
13525
13598
|
preservePlacement: n,
|
|
13526
13599
|
scale: l
|
|
13527
13600
|
});
|
|
13528
13601
|
}
|
|
13529
|
-
function
|
|
13602
|
+
function gs({ transform: e, rawScaleX: t, rawScaleY: n }) {
|
|
13530
13603
|
return {
|
|
13531
|
-
shouldRoundScaleX:
|
|
13604
|
+
shouldRoundScaleX: ys({
|
|
13532
13605
|
transform: e,
|
|
13533
13606
|
axis: "x",
|
|
13534
13607
|
rawScale: t
|
|
13535
13608
|
}),
|
|
13536
|
-
shouldRoundScaleY:
|
|
13609
|
+
shouldRoundScaleY: ys({
|
|
13537
13610
|
transform: e,
|
|
13538
13611
|
axis: "y",
|
|
13539
13612
|
rawScale: n
|
|
13540
13613
|
})
|
|
13541
13614
|
};
|
|
13542
13615
|
}
|
|
13543
|
-
function
|
|
13616
|
+
function _s({ rawScaleX: e, rawScaleY: t, snappedScale: n, roundingState: r }) {
|
|
13544
13617
|
let i = { ...n };
|
|
13545
13618
|
return r.shouldRoundScaleX || (i.scaleX = e), r.shouldRoundScaleY || (i.scaleY = t), i;
|
|
13546
13619
|
}
|
|
13547
|
-
function
|
|
13620
|
+
function vs({ target: e, transform: t, preservePlacement: n, scale: r }) {
|
|
13548
13621
|
e.set({
|
|
13549
13622
|
scaleX: r.scaleX,
|
|
13550
13623
|
scaleY: r.scaleY
|
|
13551
13624
|
}), n && n.applyPlacement(n.placement), t && (t.scaleX = r.scaleX, t.scaleY = r.scaleY), e.setCoords();
|
|
13552
13625
|
}
|
|
13553
|
-
function
|
|
13626
|
+
function ys({ transform: e, axis: t, rawScale: n }) {
|
|
13554
13627
|
if (!e) return !0;
|
|
13555
13628
|
let r = t === "x" ? e.original?.scaleX : e.original?.scaleY;
|
|
13556
13629
|
return typeof r == "number" ? r !== n : !0;
|
|
13557
13630
|
}
|
|
13558
|
-
function
|
|
13559
|
-
let
|
|
13560
|
-
rawScaleX:
|
|
13561
|
-
rawScaleY:
|
|
13562
|
-
effectiveWidth:
|
|
13563
|
-
effectiveHeight:
|
|
13631
|
+
function bs({ target: e, transform: t, rawScaleX: n, rawScaleY: r, effectiveWidth: i, effectiveHeight: a, preservePlacement: o, snapGuards: s }) {
|
|
13632
|
+
let c = xs({
|
|
13633
|
+
rawScaleX: n,
|
|
13634
|
+
rawScaleY: r,
|
|
13635
|
+
effectiveWidth: i,
|
|
13636
|
+
effectiveHeight: a
|
|
13564
13637
|
});
|
|
13565
|
-
return
|
|
13638
|
+
return s.length === 0 ? c : ws({
|
|
13566
13639
|
target: e,
|
|
13567
|
-
|
|
13568
|
-
|
|
13569
|
-
|
|
13570
|
-
|
|
13571
|
-
|
|
13572
|
-
|
|
13573
|
-
|
|
13574
|
-
|
|
13640
|
+
transform: t,
|
|
13641
|
+
rawScaleX: n,
|
|
13642
|
+
rawScaleY: r,
|
|
13643
|
+
effectiveWidth: i,
|
|
13644
|
+
effectiveHeight: a,
|
|
13645
|
+
fallbackScale: c,
|
|
13646
|
+
isUniform: n === r,
|
|
13647
|
+
preservePlacement: o,
|
|
13648
|
+
snapGuards: s
|
|
13575
13649
|
});
|
|
13576
13650
|
}
|
|
13577
|
-
function
|
|
13578
|
-
return e === t ?
|
|
13651
|
+
function xs({ rawScaleX: e, rawScaleY: t, effectiveWidth: n, effectiveHeight: r }) {
|
|
13652
|
+
return e === t ? Ss({
|
|
13579
13653
|
rawScale: e,
|
|
13580
13654
|
effectiveWidth: n,
|
|
13581
13655
|
effectiveHeight: r
|
|
13582
13656
|
}) : {
|
|
13583
|
-
scaleX:
|
|
13657
|
+
scaleX: Cs({
|
|
13584
13658
|
rawScale: e,
|
|
13585
13659
|
effectiveSize: n
|
|
13586
13660
|
}),
|
|
13587
|
-
scaleY:
|
|
13661
|
+
scaleY: Cs({
|
|
13588
13662
|
rawScale: t,
|
|
13589
13663
|
effectiveSize: r
|
|
13590
13664
|
})
|
|
13591
13665
|
};
|
|
13592
13666
|
}
|
|
13593
|
-
function
|
|
13594
|
-
let r =
|
|
13667
|
+
function Ss({ rawScale: e, effectiveWidth: t, effectiveHeight: n }) {
|
|
13668
|
+
let r = Cs({
|
|
13595
13669
|
rawScale: e,
|
|
13596
13670
|
effectiveSize: t
|
|
13597
|
-
}), i =
|
|
13671
|
+
}), i = Cs({
|
|
13598
13672
|
rawScale: e,
|
|
13599
13673
|
effectiveSize: n
|
|
13600
13674
|
}), a = Math.abs(r - e) <= Math.abs(i - e) ? r : i;
|
|
@@ -13603,122 +13677,238 @@ function ys({ rawScale: e, effectiveWidth: t, effectiveHeight: n }) {
|
|
|
13603
13677
|
scaleY: a
|
|
13604
13678
|
};
|
|
13605
13679
|
}
|
|
13606
|
-
function
|
|
13680
|
+
function Cs({ rawScale: e, effectiveSize: t }) {
|
|
13607
13681
|
return t <= 0 ? e : Math.max(1, Math.round(t * e)) / t;
|
|
13608
13682
|
}
|
|
13609
|
-
function
|
|
13610
|
-
|
|
13683
|
+
function ws({ target: e, transform: t, rawScaleX: n, rawScaleY: r, effectiveWidth: i, effectiveHeight: a, fallbackScale: o, isUniform: s, preservePlacement: c, snapGuards: l }) {
|
|
13684
|
+
return Is({
|
|
13611
13685
|
target: e,
|
|
13612
|
-
snapGuards:
|
|
13613
|
-
})
|
|
13614
|
-
scaleX:
|
|
13615
|
-
scaleY:
|
|
13616
|
-
}
|
|
13617
|
-
let l = js({
|
|
13618
|
-
rawScaleX: t,
|
|
13619
|
-
rawScaleY: n,
|
|
13620
|
-
effectiveWidth: r,
|
|
13621
|
-
effectiveHeight: i,
|
|
13622
|
-
isUniform: o
|
|
13623
|
-
}), u = Ss({
|
|
13686
|
+
snapGuards: l
|
|
13687
|
+
}) ? {
|
|
13688
|
+
scaleX: n,
|
|
13689
|
+
scaleY: r
|
|
13690
|
+
} : Ts({
|
|
13624
13691
|
target: e,
|
|
13625
|
-
|
|
13626
|
-
|
|
13627
|
-
|
|
13628
|
-
|
|
13692
|
+
transform: t,
|
|
13693
|
+
effectiveWidth: i,
|
|
13694
|
+
effectiveHeight: a,
|
|
13695
|
+
preservePlacement: c,
|
|
13696
|
+
snapGuards: l
|
|
13697
|
+
}) || (Os({
|
|
13698
|
+
target: e,
|
|
13699
|
+
rawScaleX: n,
|
|
13700
|
+
rawScaleY: r,
|
|
13701
|
+
effectiveWidth: i,
|
|
13702
|
+
effectiveHeight: a,
|
|
13703
|
+
candidates: Ws({
|
|
13704
|
+
rawScaleX: n,
|
|
13705
|
+
rawScaleY: r,
|
|
13706
|
+
effectiveWidth: i,
|
|
13707
|
+
effectiveHeight: a,
|
|
13708
|
+
isUniform: s
|
|
13709
|
+
}),
|
|
13710
|
+
preservePlacement: c,
|
|
13711
|
+
shouldPreferInsideCandidate: Fs({
|
|
13712
|
+
target: e,
|
|
13713
|
+
snapGuards: l
|
|
13714
|
+
}),
|
|
13715
|
+
snapGuards: l
|
|
13716
|
+
}) ?? o);
|
|
13717
|
+
}
|
|
13718
|
+
function Ts({ target: e, transform: t, effectiveWidth: n, effectiveHeight: r, preservePlacement: i, snapGuards: a }) {
|
|
13719
|
+
if (!Fs({
|
|
13720
|
+
target: e,
|
|
13721
|
+
snapGuards: a
|
|
13722
|
+
})) return null;
|
|
13723
|
+
let { scaleX: o, scaleY: s } = t?.original ?? {};
|
|
13724
|
+
if (typeof o != "number" || typeof s != "number" || !Number.isFinite(o) || !Number.isFinite(s)) return null;
|
|
13725
|
+
let c = {
|
|
13726
|
+
scaleX: o,
|
|
13727
|
+
scaleY: s
|
|
13728
|
+
}, l = Es({
|
|
13729
|
+
target: e,
|
|
13730
|
+
candidate: c,
|
|
13731
|
+
preservePlacement: i,
|
|
13732
|
+
snapGuards: a
|
|
13733
|
+
}), u = Ds({
|
|
13734
|
+
target: e,
|
|
13735
|
+
candidate: c,
|
|
13736
|
+
effectiveWidth: n,
|
|
13737
|
+
effectiveHeight: r,
|
|
13738
|
+
snapGuards: a
|
|
13739
|
+
});
|
|
13740
|
+
return !l || !u ? null : c;
|
|
13741
|
+
}
|
|
13742
|
+
function Es({ target: e, candidate: t, preservePlacement: n, snapGuards: r }) {
|
|
13743
|
+
let i = Xs({
|
|
13744
|
+
target: e,
|
|
13745
|
+
candidate: t,
|
|
13746
|
+
preservePlacement: n
|
|
13747
|
+
});
|
|
13748
|
+
if (!i) return !1;
|
|
13749
|
+
for (let e of r) if (Qs({
|
|
13750
|
+
bounds: i,
|
|
13751
|
+
snapGuard: e
|
|
13752
|
+
}) > ls) return !1;
|
|
13753
|
+
return !0;
|
|
13754
|
+
}
|
|
13755
|
+
function Ds({ target: e, candidate: t, effectiveWidth: n, effectiveHeight: r, snapGuards: i }) {
|
|
13756
|
+
for (let a of i) if (!Ms({
|
|
13757
|
+
target: e,
|
|
13758
|
+
displaySize: a.type === "vertical" ? Math.abs(t.scaleX) * n : Math.abs(t.scaleY) * r,
|
|
13759
|
+
snapGuard: a
|
|
13760
|
+
})) return !1;
|
|
13761
|
+
return !0;
|
|
13762
|
+
}
|
|
13763
|
+
function Os({ target: e, rawScaleX: t, rawScaleY: n, effectiveWidth: r, effectiveHeight: i, candidates: a, preservePlacement: o, shouldPreferInsideCandidate: s, snapGuards: c }) {
|
|
13764
|
+
let l = null, u = null, d = Infinity;
|
|
13765
|
+
for (let t of a) {
|
|
13766
|
+
let n = Ys({
|
|
13629
13767
|
target: e,
|
|
13630
13768
|
candidate: t,
|
|
13631
|
-
preservePlacement:
|
|
13769
|
+
preservePlacement: o,
|
|
13632
13770
|
snapGuards: c
|
|
13633
13771
|
});
|
|
13634
|
-
if (n === "on-guide") {
|
|
13635
|
-
if (!
|
|
13636
|
-
|
|
13772
|
+
if (n.state === "on-guide") {
|
|
13773
|
+
if (!s) return t;
|
|
13774
|
+
l ||= t;
|
|
13637
13775
|
}
|
|
13638
|
-
n === "inside" && !
|
|
13776
|
+
n.state === "inside" && (!s && !u && (u = t), s && n.distance < d && (u = t, d = n.distance));
|
|
13639
13777
|
}
|
|
13640
|
-
return
|
|
13778
|
+
return l && ks({
|
|
13779
|
+
target: e,
|
|
13780
|
+
candidate: l,
|
|
13781
|
+
rawScaleX: t,
|
|
13782
|
+
rawScaleY: n,
|
|
13783
|
+
effectiveWidth: r,
|
|
13784
|
+
effectiveHeight: i,
|
|
13785
|
+
snapGuards: c
|
|
13786
|
+
}) ? l : u || l || null;
|
|
13787
|
+
}
|
|
13788
|
+
function ks({ target: e, candidate: t, rawScaleX: n, rawScaleY: r, effectiveWidth: i, effectiveHeight: a, snapGuards: o }) {
|
|
13789
|
+
for (let s of o) {
|
|
13790
|
+
let o = s.type === "vertical" ? Math.abs(t.scaleX) * i : Math.abs(t.scaleY) * a, c = s.type === "vertical" ? Math.abs(n) * i : Math.abs(r) * a;
|
|
13791
|
+
if (!As({ displaySize: o }) || !js({
|
|
13792
|
+
displaySize: o,
|
|
13793
|
+
rawDisplaySize: c
|
|
13794
|
+
}) || !Ms({
|
|
13795
|
+
target: e,
|
|
13796
|
+
displaySize: o,
|
|
13797
|
+
snapGuard: s
|
|
13798
|
+
})) return !1;
|
|
13799
|
+
}
|
|
13800
|
+
return !0;
|
|
13801
|
+
}
|
|
13802
|
+
function As({ displaySize: e }) {
|
|
13803
|
+
return Math.abs(e - Math.round(e)) <= os;
|
|
13804
|
+
}
|
|
13805
|
+
function js({ displaySize: e, rawDisplaySize: t }) {
|
|
13806
|
+
return Math.abs(e - t) <= ss;
|
|
13807
|
+
}
|
|
13808
|
+
function Ms({ target: e, displaySize: t, snapGuard: n }) {
|
|
13809
|
+
let r = Ns({
|
|
13810
|
+
target: e,
|
|
13811
|
+
snapGuard: n
|
|
13812
|
+
});
|
|
13813
|
+
return r === null ? !1 : Math.round(t) <= r;
|
|
13814
|
+
}
|
|
13815
|
+
function Ns({ target: e, snapGuard: t }) {
|
|
13816
|
+
let n = e, { cropSource: r } = n;
|
|
13817
|
+
if (!r) return null;
|
|
13818
|
+
let i = W({ object: r });
|
|
13819
|
+
if (!i) return null;
|
|
13820
|
+
let a = t.type === "vertical" ? Math.abs(n.cropSourceScaleX ?? 1) : Math.abs(n.cropSourceScaleY ?? 1);
|
|
13821
|
+
if (!Number.isFinite(a) || a <= 0) return null;
|
|
13822
|
+
let o = Ps({
|
|
13823
|
+
sourceBounds: i,
|
|
13824
|
+
snapGuard: t
|
|
13825
|
+
});
|
|
13826
|
+
return !Number.isFinite(o) || o <= 0 ? null : Math.floor(o / a + os);
|
|
13827
|
+
}
|
|
13828
|
+
function Ps({ sourceBounds: e, snapGuard: t }) {
|
|
13829
|
+
let { edge: n, position: r } = t;
|
|
13830
|
+
return n === "left" ? e.right - r : n === "right" ? r - e.left : n === "top" ? e.bottom - r : r - e.top;
|
|
13641
13831
|
}
|
|
13642
|
-
function
|
|
13643
|
-
return
|
|
13832
|
+
function Fs({ target: e, snapGuards: t }) {
|
|
13833
|
+
return Ls({
|
|
13644
13834
|
target: e,
|
|
13645
13835
|
snapGuards: t
|
|
13646
|
-
}) ? !
|
|
13836
|
+
}) ? !Rs({
|
|
13647
13837
|
target: e,
|
|
13648
13838
|
snapGuards: t
|
|
13649
13839
|
}) : !1;
|
|
13650
13840
|
}
|
|
13651
|
-
function
|
|
13652
|
-
if (
|
|
13841
|
+
function Is({ target: e, snapGuards: t }) {
|
|
13842
|
+
if (Ls({
|
|
13653
13843
|
target: e,
|
|
13654
13844
|
snapGuards: t
|
|
13655
13845
|
})) return !1;
|
|
13656
13846
|
let n = W({ object: e });
|
|
13657
13847
|
if (!n) return !1;
|
|
13658
|
-
for (let e of t) if (!
|
|
13848
|
+
for (let e of t) if (!Hs({ snapGuard: e }) || !ec({
|
|
13659
13849
|
bounds: n,
|
|
13660
13850
|
snapGuard: e
|
|
13661
|
-
}) || !
|
|
13851
|
+
}) || !Us({
|
|
13662
13852
|
bounds: n,
|
|
13663
13853
|
snapGuard: e
|
|
13664
13854
|
})) return !1;
|
|
13665
13855
|
return !0;
|
|
13666
13856
|
}
|
|
13667
|
-
function
|
|
13857
|
+
function Ls({ target: e, snapGuards: t }) {
|
|
13668
13858
|
if (typeof e.getObjectDisplaySize != "function") return !1;
|
|
13669
|
-
let n = e, r = t.some((e) => e.type === "vertical" && !
|
|
13859
|
+
let n = e, r = t.some((e) => e.type === "vertical" && !Vs({ scale: n.cropSourceScaleX })), i = t.some((e) => e.type === "horizontal" && !Vs({ scale: n.cropSourceScaleY }));
|
|
13670
13860
|
return r || i;
|
|
13671
13861
|
}
|
|
13672
|
-
function
|
|
13862
|
+
function Rs({ target: e, snapGuards: t }) {
|
|
13673
13863
|
let { cropSource: n } = e;
|
|
13674
13864
|
if (!n) return !1;
|
|
13675
13865
|
let r = W({ object: n });
|
|
13676
|
-
return r ? t.some((e) =>
|
|
13866
|
+
return r ? t.some((e) => zs({
|
|
13677
13867
|
snapGuard: e,
|
|
13678
13868
|
sourceBounds: r
|
|
13679
13869
|
})) : !1;
|
|
13680
13870
|
}
|
|
13681
|
-
function
|
|
13871
|
+
function zs({ snapGuard: e, sourceBounds: t }) {
|
|
13682
13872
|
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),
|
|
13873
|
+
return n === "left" && (i = t.left), n === "right" && (i = t.right), n === "top" && (i = t.top), Bs({
|
|
13684
13874
|
position: r,
|
|
13685
13875
|
boundary: i
|
|
13686
13876
|
});
|
|
13687
13877
|
}
|
|
13688
|
-
function
|
|
13878
|
+
function Bs({ position: e, boundary: t }) {
|
|
13689
13879
|
return Math.abs(e - t) <= as;
|
|
13690
13880
|
}
|
|
13691
|
-
function
|
|
13692
|
-
return Math.abs(Math.abs(e ?? 1) - 1) <=
|
|
13881
|
+
function Vs({ scale: e }) {
|
|
13882
|
+
return Math.abs(Math.abs(e ?? 1) - 1) <= cs;
|
|
13693
13883
|
}
|
|
13694
|
-
function
|
|
13884
|
+
function Hs({ snapGuard: e }) {
|
|
13695
13885
|
let t = Math.round(e.position);
|
|
13696
13886
|
return Math.abs(e.position - t) <= is;
|
|
13697
13887
|
}
|
|
13698
|
-
function
|
|
13888
|
+
function Us({ bounds: e, snapGuard: t }) {
|
|
13699
13889
|
let n = t.type === "vertical" ? e.right - e.left : e.bottom - e.top;
|
|
13700
13890
|
return !Number.isFinite(n) || n <= 0 ? !1 : Math.round(n) > 0;
|
|
13701
13891
|
}
|
|
13702
|
-
function
|
|
13703
|
-
let a =
|
|
13892
|
+
function Ws({ rawScaleX: e, rawScaleY: t, effectiveWidth: n, effectiveHeight: r, isUniform: i }) {
|
|
13893
|
+
let a = Gs({
|
|
13704
13894
|
rawScale: e,
|
|
13705
13895
|
effectiveSize: n
|
|
13706
|
-
}), o =
|
|
13896
|
+
}), o = Gs({
|
|
13707
13897
|
rawScale: t,
|
|
13708
13898
|
effectiveSize: r
|
|
13709
13899
|
});
|
|
13710
|
-
return i ?
|
|
13900
|
+
return i ? qs({
|
|
13711
13901
|
scaleXCandidates: a,
|
|
13712
13902
|
scaleYCandidates: o,
|
|
13713
13903
|
rawScale: e
|
|
13714
|
-
}) :
|
|
13904
|
+
}) : Js({
|
|
13715
13905
|
scaleXCandidates: a,
|
|
13716
13906
|
scaleYCandidates: o,
|
|
13717
13907
|
rawScaleX: e,
|
|
13718
13908
|
rawScaleY: t
|
|
13719
13909
|
});
|
|
13720
13910
|
}
|
|
13721
|
-
function
|
|
13911
|
+
function Gs({ rawScale: e, effectiveSize: t }) {
|
|
13722
13912
|
if (t <= 0) return [e];
|
|
13723
13913
|
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
13914
|
i,
|
|
@@ -13727,18 +13917,18 @@ function Ms({ rawScale: e, effectiveSize: t }) {
|
|
|
13727
13917
|
a - 1,
|
|
13728
13918
|
o + 1
|
|
13729
13919
|
], c = [];
|
|
13730
|
-
for (let e of s)
|
|
13920
|
+
for (let e of s) Ks({
|
|
13731
13921
|
candidates: c,
|
|
13732
13922
|
scale: Math.max(1, e) / t * n
|
|
13733
13923
|
});
|
|
13734
13924
|
return c.sort((t, n) => Math.abs(t - e) - Math.abs(n - e)), c;
|
|
13735
13925
|
}
|
|
13736
|
-
function
|
|
13926
|
+
function Ks({ candidates: e, scale: t }) {
|
|
13737
13927
|
Number.isFinite(t) && (e.includes(t) || e.push(t));
|
|
13738
13928
|
}
|
|
13739
|
-
function
|
|
13929
|
+
function qs({ scaleXCandidates: e, scaleYCandidates: t, rawScale: n }) {
|
|
13740
13930
|
let r = [...e];
|
|
13741
|
-
for (let e of t)
|
|
13931
|
+
for (let e of t) Ks({
|
|
13742
13932
|
candidates: r,
|
|
13743
13933
|
scale: e
|
|
13744
13934
|
});
|
|
@@ -13747,7 +13937,7 @@ function Ps({ scaleXCandidates: e, scaleYCandidates: t, rawScale: n }) {
|
|
|
13747
13937
|
scaleY: e
|
|
13748
13938
|
}));
|
|
13749
13939
|
}
|
|
13750
|
-
function
|
|
13940
|
+
function Js({ scaleXCandidates: e, scaleYCandidates: t, rawScaleX: n, rawScaleY: r }) {
|
|
13751
13941
|
let i = [];
|
|
13752
13942
|
for (let n of e) for (let e of t) i.push({
|
|
13753
13943
|
scaleX: n,
|
|
@@ -13755,45 +13945,74 @@ function Fs({ scaleXCandidates: e, scaleYCandidates: t, rawScaleX: n, rawScaleY:
|
|
|
13755
13945
|
});
|
|
13756
13946
|
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
13947
|
}
|
|
13758
|
-
function
|
|
13759
|
-
let i =
|
|
13948
|
+
function Ys({ target: e, candidate: t, preservePlacement: n, snapGuards: r }) {
|
|
13949
|
+
let i = Xs({
|
|
13950
|
+
target: e,
|
|
13951
|
+
candidate: t,
|
|
13952
|
+
preservePlacement: n
|
|
13953
|
+
});
|
|
13954
|
+
return i ? Zs({
|
|
13955
|
+
bounds: i,
|
|
13956
|
+
snapGuards: r
|
|
13957
|
+
}) : {
|
|
13958
|
+
state: "outside",
|
|
13959
|
+
distance: Infinity
|
|
13960
|
+
};
|
|
13961
|
+
}
|
|
13962
|
+
function Xs({ target: e, candidate: t, preservePlacement: n }) {
|
|
13963
|
+
let r = e.scaleX ?? 1, i = e.scaleY ?? 1, a = null;
|
|
13760
13964
|
try {
|
|
13761
13965
|
e.set({
|
|
13762
13966
|
scaleX: t.scaleX,
|
|
13763
13967
|
scaleY: t.scaleY
|
|
13764
|
-
}), n ? n.applyPlacement(n.placement) : e.setCoords(),
|
|
13968
|
+
}), n ? n.applyPlacement(n.placement) : e.setCoords(), a = W({ object: e });
|
|
13765
13969
|
} finally {
|
|
13766
13970
|
e.set({
|
|
13767
|
-
scaleX:
|
|
13768
|
-
scaleY:
|
|
13971
|
+
scaleX: r,
|
|
13972
|
+
scaleY: i
|
|
13769
13973
|
}), n ? n.applyPlacement(n.placement) : e.setCoords();
|
|
13770
13974
|
}
|
|
13771
|
-
|
|
13772
|
-
|
|
13773
|
-
|
|
13774
|
-
|
|
13775
|
-
|
|
13776
|
-
|
|
13777
|
-
|
|
13778
|
-
|
|
13779
|
-
|
|
13780
|
-
|
|
13781
|
-
|
|
13782
|
-
|
|
13783
|
-
|
|
13784
|
-
|
|
13785
|
-
|
|
13975
|
+
return a;
|
|
13976
|
+
}
|
|
13977
|
+
function Zs({ bounds: e, snapGuards: t }) {
|
|
13978
|
+
let n = !0, r = 0;
|
|
13979
|
+
for (let i of t) {
|
|
13980
|
+
if (!$s({
|
|
13981
|
+
bounds: e,
|
|
13982
|
+
snapGuard: i
|
|
13983
|
+
})) return {
|
|
13984
|
+
state: "outside",
|
|
13985
|
+
distance: Infinity
|
|
13986
|
+
};
|
|
13987
|
+
ec({
|
|
13988
|
+
bounds: e,
|
|
13989
|
+
snapGuard: i
|
|
13990
|
+
}) || (n = !1), r = Math.max(r, Qs({
|
|
13991
|
+
bounds: e,
|
|
13992
|
+
snapGuard: i
|
|
13993
|
+
}));
|
|
13994
|
+
}
|
|
13995
|
+
return {
|
|
13996
|
+
state: n ? "on-guide" : "inside",
|
|
13997
|
+
distance: r
|
|
13998
|
+
};
|
|
13999
|
+
}
|
|
14000
|
+
function Qs({ bounds: e, snapGuard: t }) {
|
|
14001
|
+
let { edge: n, position: r } = t;
|
|
14002
|
+
return Math.abs(n === "left" ? e.left - r : n === "right" ? e.right - r : n === "top" ? e.top - r : e.bottom - r);
|
|
14003
|
+
}
|
|
14004
|
+
function $s({ bounds: e, snapGuard: t }) {
|
|
13786
14005
|
let { edge: n, position: r } = t;
|
|
13787
14006
|
return n === "left" ? e.left >= r - as : n === "right" ? e.right <= r + as : n === "top" ? e.top >= r - as : e.bottom <= r + as;
|
|
13788
14007
|
}
|
|
13789
|
-
function
|
|
14008
|
+
function ec({ bounds: e, snapGuard: t }) {
|
|
13790
14009
|
let { edge: n, position: r } = t;
|
|
13791
14010
|
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;
|
|
13792
14011
|
}
|
|
13793
14012
|
//#endregion
|
|
13794
14013
|
//#region src/editor/snapping-manager/scaling.ts
|
|
13795
|
-
var
|
|
13796
|
-
function
|
|
14014
|
+
var tc = 1e-6, nc = 1;
|
|
14015
|
+
function rc({ transform: e }) {
|
|
13797
14016
|
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";
|
|
13798
14017
|
return {
|
|
13799
14018
|
isCornerHandle: a,
|
|
@@ -13801,7 +14020,7 @@ function Bs({ transform: e }) {
|
|
|
13801
14020
|
shouldSnapY: i || a
|
|
13802
14021
|
};
|
|
13803
14022
|
}
|
|
13804
|
-
function
|
|
14023
|
+
function ic({ target: e, transform: t }) {
|
|
13805
14024
|
let { originX: n, originY: r } = t, { originX: i = "left", originY: a = "top", scaleX: o = 1, scaleY: s = 1 } = e;
|
|
13806
14025
|
return {
|
|
13807
14026
|
originX: n ?? i,
|
|
@@ -13810,7 +14029,7 @@ function Vs({ target: e, transform: t }) {
|
|
|
13810
14029
|
scaleY: s
|
|
13811
14030
|
};
|
|
13812
14031
|
}
|
|
13813
|
-
function
|
|
14032
|
+
function ac({ target: e, event: t, isCornerHandle: n }) {
|
|
13814
14033
|
let r = e;
|
|
13815
14034
|
if (r.cropSource) {
|
|
13816
14035
|
let e = r.preserveAspectRatio ?? !0;
|
|
@@ -13818,22 +14037,22 @@ function Hs({ target: e, event: t, isCornerHandle: n }) {
|
|
|
13818
14037
|
}
|
|
13819
14038
|
return n;
|
|
13820
14039
|
}
|
|
13821
|
-
function
|
|
13822
|
-
let c =
|
|
14040
|
+
function oc({ bounds: e, corner: t, originX: n, originY: r, shouldSnapX: i, shouldSnapY: a, threshold: o, anchors: s }) {
|
|
14041
|
+
let c = wc({
|
|
13823
14042
|
bounds: e,
|
|
13824
14043
|
corner: t,
|
|
13825
14044
|
originX: n,
|
|
13826
14045
|
shouldSnapX: i
|
|
13827
|
-
}), l =
|
|
14046
|
+
}), l = Tc({
|
|
13828
14047
|
bounds: e,
|
|
13829
14048
|
corner: t,
|
|
13830
14049
|
originY: r,
|
|
13831
14050
|
shouldSnapY: a
|
|
13832
|
-
}), u =
|
|
14051
|
+
}), u = Oc({
|
|
13833
14052
|
anchors: s.vertical,
|
|
13834
14053
|
candidates: c,
|
|
13835
14054
|
threshold: o
|
|
13836
|
-
}), d =
|
|
14055
|
+
}), d = Oc({
|
|
13837
14056
|
anchors: s.horizontal,
|
|
13838
14057
|
candidates: l,
|
|
13839
14058
|
threshold: o
|
|
@@ -13843,13 +14062,13 @@ function Us({ bounds: e, corner: t, originX: n, originY: r, shouldSnapX: i, shou
|
|
|
13843
14062
|
horizontalSnap: d
|
|
13844
14063
|
};
|
|
13845
14064
|
}
|
|
13846
|
-
function
|
|
13847
|
-
return e.shouldUseUniformScaleSnap ?
|
|
14065
|
+
function sc(e) {
|
|
14066
|
+
return e.shouldUseUniformScaleSnap ? lc(e) : xc(e);
|
|
13848
14067
|
}
|
|
13849
|
-
function
|
|
13850
|
-
let a =
|
|
14068
|
+
function cc({ target: e, bounds: t, originX: n, verticalAnchors: r, threshold: i }) {
|
|
14069
|
+
let a = Oc({
|
|
13851
14070
|
anchors: r,
|
|
13852
|
-
candidates:
|
|
14071
|
+
candidates: wc({
|
|
13853
14072
|
bounds: t,
|
|
13854
14073
|
originX: n,
|
|
13855
14074
|
shouldSnapX: !0
|
|
@@ -13857,13 +14076,13 @@ function Gs({ target: e, bounds: t, originX: n, verticalAnchors: r, threshold: i
|
|
|
13857
14076
|
threshold: i
|
|
13858
14077
|
}), { guidePosition: o } = a;
|
|
13859
14078
|
if (o === null) return null;
|
|
13860
|
-
let s =
|
|
14079
|
+
let s = Lc({
|
|
13861
14080
|
bounds: t,
|
|
13862
14081
|
originX: n,
|
|
13863
14082
|
snap: a
|
|
13864
14083
|
});
|
|
13865
14084
|
if (s === null) return null;
|
|
13866
|
-
let c =
|
|
14085
|
+
let c = Hc({
|
|
13867
14086
|
target: e,
|
|
13868
14087
|
boundsWidth: s
|
|
13869
14088
|
});
|
|
@@ -13875,25 +14094,139 @@ function Gs({ target: e, bounds: t, originX: n, verticalAnchors: r, threshold: i
|
|
|
13875
14094
|
}
|
|
13876
14095
|
};
|
|
13877
14096
|
}
|
|
13878
|
-
function
|
|
13879
|
-
let
|
|
14097
|
+
function lc({ target: e, bounds: t, originX: n, originY: r, scaleX: i, scaleY: a, originalScaleX: o, originalScaleY: s, verticalSnap: c, horizontalSnap: l }) {
|
|
14098
|
+
let u = kc({
|
|
14099
|
+
bounds: t,
|
|
14100
|
+
originX: n,
|
|
14101
|
+
originY: r,
|
|
14102
|
+
verticalSnap: c,
|
|
14103
|
+
horizontalSnap: l
|
|
14104
|
+
});
|
|
14105
|
+
if (!u) return null;
|
|
14106
|
+
let { guide: d, scaleFactor: f, snapGuards: p } = u, m = uc({
|
|
14107
|
+
target: e,
|
|
14108
|
+
bounds: t,
|
|
14109
|
+
originX: n,
|
|
14110
|
+
originY: r,
|
|
14111
|
+
scaleX: i,
|
|
14112
|
+
scaleY: a,
|
|
14113
|
+
originalScaleX: o,
|
|
14114
|
+
originalScaleY: s,
|
|
14115
|
+
snapGuards: p
|
|
14116
|
+
}) ?? f;
|
|
14117
|
+
return {
|
|
14118
|
+
guides: [d],
|
|
14119
|
+
snapGuards: p,
|
|
14120
|
+
nextScaleX: i * m,
|
|
14121
|
+
nextScaleY: a * m
|
|
14122
|
+
};
|
|
14123
|
+
}
|
|
14124
|
+
function uc({ target: e, bounds: t, originX: n, originY: r, scaleX: i, scaleY: a, originalScaleX: o, originalScaleY: s, snapGuards: c }) {
|
|
14125
|
+
if (!dc({ target: e })) return null;
|
|
14126
|
+
let l = fc({
|
|
14127
|
+
scaleX: i,
|
|
14128
|
+
scaleY: a,
|
|
14129
|
+
originalScaleX: o,
|
|
14130
|
+
originalScaleY: s,
|
|
14131
|
+
snapGuards: c
|
|
14132
|
+
});
|
|
14133
|
+
return l === null || !yc({
|
|
14134
|
+
bounds: mc({
|
|
14135
|
+
bounds: t,
|
|
14136
|
+
originX: n,
|
|
14137
|
+
originY: r,
|
|
14138
|
+
scaleFactor: l
|
|
14139
|
+
}),
|
|
14140
|
+
snapGuards: c
|
|
14141
|
+
}) ? null : l;
|
|
14142
|
+
}
|
|
14143
|
+
function dc({ target: e }) {
|
|
14144
|
+
return !!e.cropSource;
|
|
14145
|
+
}
|
|
14146
|
+
function fc({ scaleX: e, scaleY: t, originalScaleX: n, originalScaleY: r, snapGuards: i }) {
|
|
14147
|
+
let a = [];
|
|
14148
|
+
for (let o of i) {
|
|
14149
|
+
let i = pc({
|
|
14150
|
+
snapGuard: o,
|
|
14151
|
+
scaleX: e,
|
|
14152
|
+
scaleY: t,
|
|
14153
|
+
originalScaleX: n,
|
|
14154
|
+
originalScaleY: r
|
|
14155
|
+
});
|
|
14156
|
+
if (i === null) return null;
|
|
14157
|
+
a.push(i);
|
|
14158
|
+
}
|
|
14159
|
+
let [o] = a;
|
|
14160
|
+
if (o === void 0 || !Number.isFinite(o) || o <= 0) return null;
|
|
14161
|
+
for (let e of a) if (Math.abs(e - o) > tc) return null;
|
|
14162
|
+
return o;
|
|
14163
|
+
}
|
|
14164
|
+
function pc({ snapGuard: e, scaleX: t, scaleY: n, originalScaleX: r, originalScaleY: i }) {
|
|
14165
|
+
let a = e.type === "vertical" ? t : n, o = e.type === "vertical" ? r : i;
|
|
14166
|
+
return typeof o != "number" || !Number.isFinite(o) || !Number.isFinite(a) || Math.abs(a) <= tc ? null : o / a;
|
|
14167
|
+
}
|
|
14168
|
+
function mc({ bounds: e, originX: t, originY: n, scaleFactor: r }) {
|
|
14169
|
+
let i = hc({
|
|
13880
14170
|
bounds: e,
|
|
13881
14171
|
originX: t,
|
|
14172
|
+
scaleFactor: r
|
|
14173
|
+
}), a = gc({
|
|
14174
|
+
bounds: e,
|
|
13882
14175
|
originY: n,
|
|
13883
|
-
|
|
13884
|
-
horizontalSnap: o
|
|
14176
|
+
scaleFactor: r
|
|
13885
14177
|
});
|
|
13886
|
-
if (!s) return null;
|
|
13887
|
-
let { guide: c, scaleFactor: l, snapGuards: u } = s;
|
|
13888
14178
|
return {
|
|
13889
|
-
|
|
13890
|
-
|
|
13891
|
-
|
|
13892
|
-
|
|
14179
|
+
...i,
|
|
14180
|
+
...a,
|
|
14181
|
+
centerX: i.left + (i.right - i.left) / 2,
|
|
14182
|
+
centerY: a.top + (a.bottom - a.top) / 2
|
|
14183
|
+
};
|
|
14184
|
+
}
|
|
14185
|
+
function hc({ bounds: e, originX: t, scaleFactor: n }) {
|
|
14186
|
+
let { left: r, right: i, centerX: a } = e, o = (i - r) * n, s = _c({ originX: t });
|
|
14187
|
+
return s === "right" ? {
|
|
14188
|
+
left: i - o,
|
|
14189
|
+
right: i
|
|
14190
|
+
} : s === "center" ? {
|
|
14191
|
+
left: a - o / 2,
|
|
14192
|
+
right: a + o / 2
|
|
14193
|
+
} : {
|
|
14194
|
+
left: r,
|
|
14195
|
+
right: r + o
|
|
13893
14196
|
};
|
|
13894
14197
|
}
|
|
13895
|
-
function
|
|
13896
|
-
let
|
|
14198
|
+
function gc({ bounds: e, originY: t, scaleFactor: n }) {
|
|
14199
|
+
let { top: r, bottom: i, centerY: a } = e, o = (i - r) * n, s = vc({ originY: t });
|
|
14200
|
+
return s === "bottom" ? {
|
|
14201
|
+
top: i - o,
|
|
14202
|
+
bottom: i
|
|
14203
|
+
} : s === "center" ? {
|
|
14204
|
+
top: a - o / 2,
|
|
14205
|
+
bottom: a + o / 2
|
|
14206
|
+
} : {
|
|
14207
|
+
top: r,
|
|
14208
|
+
bottom: r + o
|
|
14209
|
+
};
|
|
14210
|
+
}
|
|
14211
|
+
function _c({ originX: e }) {
|
|
14212
|
+
return e === "center" || e === "right" ? e : "left";
|
|
14213
|
+
}
|
|
14214
|
+
function vc({ originY: e }) {
|
|
14215
|
+
return e === "center" || e === "bottom" ? e : "top";
|
|
14216
|
+
}
|
|
14217
|
+
function yc({ bounds: e, snapGuards: t }) {
|
|
14218
|
+
for (let n of t) if (bc({
|
|
14219
|
+
bounds: e,
|
|
14220
|
+
snapGuard: n
|
|
14221
|
+
}) > nc) return !1;
|
|
14222
|
+
return !0;
|
|
14223
|
+
}
|
|
14224
|
+
function bc({ bounds: e, snapGuard: t }) {
|
|
14225
|
+
let { edge: n, position: r } = t;
|
|
14226
|
+
return Math.abs(n === "left" ? e.left - r : n === "right" ? e.right - r : n === "top" ? e.top - r : e.bottom - r);
|
|
14227
|
+
}
|
|
14228
|
+
function xc(e) {
|
|
14229
|
+
let t = Sc(e), n = Cc(e);
|
|
13897
14230
|
if (!t && !n) return null;
|
|
13898
14231
|
let r = [], i = [], a = null, o = null;
|
|
13899
14232
|
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), {
|
|
@@ -13903,16 +14236,16 @@ function qs(e) {
|
|
|
13903
14236
|
nextScaleY: o
|
|
13904
14237
|
};
|
|
13905
14238
|
}
|
|
13906
|
-
function
|
|
14239
|
+
function Sc({ target: e, bounds: t, originX: n, scaleX: r, scaleY: i, verticalSnap: a }) {
|
|
13907
14240
|
let { guidePosition: o } = a;
|
|
13908
14241
|
if (o === null) return null;
|
|
13909
|
-
let s =
|
|
14242
|
+
let s = Lc({
|
|
13910
14243
|
bounds: t,
|
|
13911
14244
|
originX: n,
|
|
13912
14245
|
snap: a
|
|
13913
14246
|
});
|
|
13914
14247
|
if (s === null) return null;
|
|
13915
|
-
let { angle: c = 0 } = e, { width: l, height: u } =
|
|
14248
|
+
let { angle: c = 0 } = e, { width: l, height: u } = zc({ target: e }), d = Bc({
|
|
13916
14249
|
desiredWidth: s,
|
|
13917
14250
|
baseWidth: l,
|
|
13918
14251
|
baseHeight: u,
|
|
@@ -13920,7 +14253,7 @@ function Js({ target: e, bounds: t, originX: n, scaleX: r, scaleY: i, verticalSn
|
|
|
13920
14253
|
angle: c
|
|
13921
14254
|
});
|
|
13922
14255
|
if (d === null) return null;
|
|
13923
|
-
let f =
|
|
14256
|
+
let f = Nc({
|
|
13924
14257
|
type: "vertical",
|
|
13925
14258
|
snap: a
|
|
13926
14259
|
});
|
|
@@ -13933,16 +14266,16 @@ function Js({ target: e, bounds: t, originX: n, scaleX: r, scaleY: i, verticalSn
|
|
|
13933
14266
|
}
|
|
13934
14267
|
} : null;
|
|
13935
14268
|
}
|
|
13936
|
-
function
|
|
14269
|
+
function Cc({ target: e, bounds: t, originY: n, scaleX: r, scaleY: i, horizontalSnap: a }) {
|
|
13937
14270
|
let { guidePosition: o } = a;
|
|
13938
14271
|
if (o === null) return null;
|
|
13939
|
-
let s =
|
|
14272
|
+
let s = Rc({
|
|
13940
14273
|
bounds: t,
|
|
13941
14274
|
originY: n,
|
|
13942
14275
|
snap: a
|
|
13943
14276
|
});
|
|
13944
14277
|
if (s === null) return null;
|
|
13945
|
-
let { angle: c = 0 } = e, { width: l, height: u } =
|
|
14278
|
+
let { angle: c = 0 } = e, { width: l, height: u } = zc({ target: e }), d = Vc({
|
|
13946
14279
|
desiredHeight: s,
|
|
13947
14280
|
baseWidth: l,
|
|
13948
14281
|
baseHeight: u,
|
|
@@ -13950,7 +14283,7 @@ function Ys({ target: e, bounds: t, originY: n, scaleX: r, scaleY: i, horizontal
|
|
|
13950
14283
|
angle: c
|
|
13951
14284
|
});
|
|
13952
14285
|
if (d === null) return null;
|
|
13953
|
-
let f =
|
|
14286
|
+
let f = Nc({
|
|
13954
14287
|
type: "horizontal",
|
|
13955
14288
|
snap: a
|
|
13956
14289
|
});
|
|
@@ -13963,12 +14296,12 @@ function Ys({ target: e, bounds: t, originY: n, scaleX: r, scaleY: i, horizontal
|
|
|
13963
14296
|
}
|
|
13964
14297
|
} : null;
|
|
13965
14298
|
}
|
|
13966
|
-
function
|
|
14299
|
+
function wc({ bounds: e, corner: t = "", originX: n, shouldSnapX: r }) {
|
|
13967
14300
|
let i = [];
|
|
13968
14301
|
if (!r) return i;
|
|
13969
14302
|
let { left: a, right: o } = e, s = "left";
|
|
13970
14303
|
(n === "center" || n === "right") && (s = n);
|
|
13971
|
-
let c =
|
|
14304
|
+
let c = Ec({ controlKey: t });
|
|
13972
14305
|
return c && s !== "center" ? (i.push({
|
|
13973
14306
|
edge: c,
|
|
13974
14307
|
position: c === "left" ? a : o
|
|
@@ -13986,12 +14319,12 @@ function Xs({ bounds: e, corner: t = "", originX: n, shouldSnapX: r }) {
|
|
|
13986
14319
|
position: o
|
|
13987
14320
|
})), i);
|
|
13988
14321
|
}
|
|
13989
|
-
function
|
|
14322
|
+
function Tc({ bounds: e, corner: t = "", originY: n, shouldSnapY: r }) {
|
|
13990
14323
|
let i = [];
|
|
13991
14324
|
if (!r) return i;
|
|
13992
14325
|
let { top: a, bottom: o } = e, s = "top";
|
|
13993
14326
|
(n === "center" || n === "bottom") && (s = n);
|
|
13994
|
-
let c =
|
|
14327
|
+
let c = Dc({ controlKey: t });
|
|
13995
14328
|
return c && s !== "center" ? (i.push({
|
|
13996
14329
|
edge: c,
|
|
13997
14330
|
position: c === "top" ? a : o
|
|
@@ -14009,13 +14342,13 @@ function Zs({ bounds: e, corner: t = "", originY: n, shouldSnapY: r }) {
|
|
|
14009
14342
|
position: o
|
|
14010
14343
|
})), i);
|
|
14011
14344
|
}
|
|
14012
|
-
function
|
|
14345
|
+
function Ec({ controlKey: e }) {
|
|
14013
14346
|
return e === "tl" || e === "bl" || e === "ml" ? "left" : e === "tr" || e === "br" || e === "mr" ? "right" : null;
|
|
14014
14347
|
}
|
|
14015
|
-
function
|
|
14348
|
+
function Dc({ controlKey: e }) {
|
|
14016
14349
|
return e === "tl" || e === "tr" || e === "mt" ? "top" : e === "bl" || e === "br" || e === "mb" ? "bottom" : null;
|
|
14017
14350
|
}
|
|
14018
|
-
function
|
|
14351
|
+
function Oc({ anchors: e, candidates: t, threshold: n }) {
|
|
14019
14352
|
let r = 0, i = n + 1, a = null, o = null;
|
|
14020
14353
|
for (let s of t) {
|
|
14021
14354
|
let { position: t } = s;
|
|
@@ -14030,31 +14363,31 @@ function ec({ anchors: e, candidates: t, threshold: n }) {
|
|
|
14030
14363
|
candidate: o
|
|
14031
14364
|
};
|
|
14032
14365
|
}
|
|
14033
|
-
function
|
|
14034
|
-
let a =
|
|
14366
|
+
function kc({ bounds: e, originX: t, originY: n, verticalSnap: r, horizontalSnap: i }) {
|
|
14367
|
+
let a = Pc({
|
|
14035
14368
|
bounds: e,
|
|
14036
14369
|
originX: t,
|
|
14037
14370
|
snap: r
|
|
14038
|
-
}), o =
|
|
14371
|
+
}), o = Fc({
|
|
14039
14372
|
bounds: e,
|
|
14040
14373
|
originY: n,
|
|
14041
14374
|
snap: i
|
|
14042
|
-
}), s =
|
|
14375
|
+
}), s = Ic({
|
|
14043
14376
|
scaleFactorX: a,
|
|
14044
14377
|
scaleFactorY: o,
|
|
14045
14378
|
verticalSnap: r,
|
|
14046
14379
|
horizontalSnap: i
|
|
14047
14380
|
}), c = null;
|
|
14048
|
-
if (s === "x" && (c =
|
|
14381
|
+
if (s === "x" && (c = Ac({
|
|
14049
14382
|
type: "vertical",
|
|
14050
14383
|
scaleFactor: a,
|
|
14051
14384
|
snap: r
|
|
14052
|
-
})), s === "y" && (c =
|
|
14385
|
+
})), s === "y" && (c = Ac({
|
|
14053
14386
|
type: "horizontal",
|
|
14054
14387
|
scaleFactor: o,
|
|
14055
14388
|
snap: i
|
|
14056
14389
|
})), !c) return null;
|
|
14057
|
-
let l =
|
|
14390
|
+
let l = jc({
|
|
14058
14391
|
scaleFactor: c.scaleFactor,
|
|
14059
14392
|
scaleFactorX: a,
|
|
14060
14393
|
scaleFactorY: o,
|
|
@@ -14067,10 +14400,10 @@ function tc({ bounds: e, originX: t, originY: n, verticalSnap: r, horizontalSnap
|
|
|
14067
14400
|
scaleFactor: c.scaleFactor
|
|
14068
14401
|
};
|
|
14069
14402
|
}
|
|
14070
|
-
function
|
|
14403
|
+
function Ac({ type: e, scaleFactor: t, snap: n }) {
|
|
14071
14404
|
let { guidePosition: r } = n;
|
|
14072
14405
|
if (t === null || r === null) return null;
|
|
14073
|
-
let i =
|
|
14406
|
+
let i = Nc({
|
|
14074
14407
|
type: e,
|
|
14075
14408
|
snap: n
|
|
14076
14409
|
});
|
|
@@ -14083,15 +14416,15 @@ function nc({ type: e, scaleFactor: t, snap: n }) {
|
|
|
14083
14416
|
}
|
|
14084
14417
|
} : null;
|
|
14085
14418
|
}
|
|
14086
|
-
function
|
|
14419
|
+
function jc({ scaleFactor: e, scaleFactorX: t, scaleFactorY: n, verticalSnap: r, horizontalSnap: i }) {
|
|
14087
14420
|
let a = [];
|
|
14088
|
-
return
|
|
14421
|
+
return Mc({
|
|
14089
14422
|
snapGuards: a,
|
|
14090
14423
|
scaleFactor: e,
|
|
14091
14424
|
axisScaleFactor: t,
|
|
14092
14425
|
type: "vertical",
|
|
14093
14426
|
snap: r
|
|
14094
|
-
}),
|
|
14427
|
+
}), Mc({
|
|
14095
14428
|
snapGuards: a,
|
|
14096
14429
|
scaleFactor: e,
|
|
14097
14430
|
axisScaleFactor: n,
|
|
@@ -14099,15 +14432,15 @@ function rc({ scaleFactor: e, scaleFactorX: t, scaleFactorY: n, verticalSnap: r,
|
|
|
14099
14432
|
snap: i
|
|
14100
14433
|
}), a;
|
|
14101
14434
|
}
|
|
14102
|
-
function
|
|
14103
|
-
if (n === null || Math.abs(n - t) >
|
|
14104
|
-
let a =
|
|
14435
|
+
function Mc({ snapGuards: e, scaleFactor: t, axisScaleFactor: n, type: r, snap: i }) {
|
|
14436
|
+
if (n === null || Math.abs(n - t) > tc) return;
|
|
14437
|
+
let a = Nc({
|
|
14105
14438
|
type: r,
|
|
14106
14439
|
snap: i
|
|
14107
14440
|
});
|
|
14108
14441
|
a && e.push(a);
|
|
14109
14442
|
}
|
|
14110
|
-
function
|
|
14443
|
+
function Nc({ type: e, snap: t }) {
|
|
14111
14444
|
let { candidate: n, guidePosition: r } = t;
|
|
14112
14445
|
return !n || r === null ? null : {
|
|
14113
14446
|
type: e,
|
|
@@ -14115,10 +14448,10 @@ function ac({ type: e, snap: t }) {
|
|
|
14115
14448
|
position: r
|
|
14116
14449
|
};
|
|
14117
14450
|
}
|
|
14118
|
-
function
|
|
14451
|
+
function Pc({ bounds: e, originX: t, snap: n }) {
|
|
14119
14452
|
let { left: r, right: i } = e, a = i - r;
|
|
14120
14453
|
if (n.guidePosition === null || a <= 0) return null;
|
|
14121
|
-
let o =
|
|
14454
|
+
let o = Lc({
|
|
14122
14455
|
bounds: e,
|
|
14123
14456
|
originX: t,
|
|
14124
14457
|
snap: n
|
|
@@ -14127,10 +14460,10 @@ function oc({ bounds: e, originX: t, snap: n }) {
|
|
|
14127
14460
|
let s = o / a;
|
|
14128
14461
|
return !Number.isFinite(s) || s <= 0 ? null : s;
|
|
14129
14462
|
}
|
|
14130
|
-
function
|
|
14463
|
+
function Fc({ bounds: e, originY: t, snap: n }) {
|
|
14131
14464
|
let { top: r, bottom: i } = e, a = i - r;
|
|
14132
14465
|
if (n.guidePosition === null || a <= 0) return null;
|
|
14133
|
-
let o =
|
|
14466
|
+
let o = Rc({
|
|
14134
14467
|
bounds: e,
|
|
14135
14468
|
originY: t,
|
|
14136
14469
|
snap: n
|
|
@@ -14139,10 +14472,10 @@ function sc({ bounds: e, originY: t, snap: n }) {
|
|
|
14139
14472
|
let s = o / a;
|
|
14140
14473
|
return !Number.isFinite(s) || s <= 0 ? null : s;
|
|
14141
14474
|
}
|
|
14142
|
-
function
|
|
14475
|
+
function Ic({ scaleFactorX: e, scaleFactorY: t, verticalSnap: n, horizontalSnap: r }) {
|
|
14143
14476
|
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";
|
|
14144
14477
|
}
|
|
14145
|
-
function
|
|
14478
|
+
function Lc({ bounds: e, originX: t, snap: n }) {
|
|
14146
14479
|
let { left: r, right: i, centerX: a } = e, { candidate: o, guidePosition: s } = n;
|
|
14147
14480
|
if (!o || s === null) return null;
|
|
14148
14481
|
let c = "left";
|
|
@@ -14150,7 +14483,7 @@ function lc({ bounds: e, originX: t, snap: n }) {
|
|
|
14150
14483
|
let { edge: l } = o, u = null;
|
|
14151
14484
|
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;
|
|
14152
14485
|
}
|
|
14153
|
-
function
|
|
14486
|
+
function Rc({ bounds: e, originY: t, snap: n }) {
|
|
14154
14487
|
let { top: r, bottom: i, centerY: a } = e, { candidate: o, guidePosition: s } = n;
|
|
14155
14488
|
if (!o || s === null) return null;
|
|
14156
14489
|
let c = "top";
|
|
@@ -14158,7 +14491,7 @@ function uc({ bounds: e, originY: t, snap: n }) {
|
|
|
14158
14491
|
let { edge: l } = o, u = null;
|
|
14159
14492
|
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;
|
|
14160
14493
|
}
|
|
14161
|
-
function
|
|
14494
|
+
function zc({ target: e }) {
|
|
14162
14495
|
let { width: t = 0, height: n = 0 } = e, r = t, i = n;
|
|
14163
14496
|
if (e instanceof v) {
|
|
14164
14497
|
let { paddingTop: a = 0, paddingRight: o = 0, paddingBottom: s = 0, paddingLeft: c = 0, strokeWidth: l = 0 } = e;
|
|
@@ -14169,28 +14502,28 @@ function dc({ target: e }) {
|
|
|
14169
14502
|
height: i
|
|
14170
14503
|
};
|
|
14171
14504
|
}
|
|
14172
|
-
function
|
|
14505
|
+
function Bc({ desiredWidth: e, baseWidth: t, baseHeight: n, scaleY: r, angle: i }) {
|
|
14173
14506
|
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;
|
|
14174
14507
|
if (c <= 0) return null;
|
|
14175
14508
|
let u = (e - l) / c;
|
|
14176
14509
|
return !Number.isFinite(u) || u <= 0 ? null : u;
|
|
14177
14510
|
}
|
|
14178
|
-
function
|
|
14511
|
+
function Vc({ desiredHeight: e, baseWidth: t, baseHeight: n, scaleX: r, angle: i }) {
|
|
14179
14512
|
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;
|
|
14180
14513
|
if (c <= 0) return null;
|
|
14181
14514
|
let u = (e - l) / c;
|
|
14182
14515
|
return !Number.isFinite(u) || u <= 0 ? null : u;
|
|
14183
14516
|
}
|
|
14184
|
-
function
|
|
14517
|
+
function Hc({ target: e, boundsWidth: t }) {
|
|
14185
14518
|
let { paddingLeft: n = 0, paddingRight: r = 0, strokeWidth: i = 0 } = e, a = t - n - r - i;
|
|
14186
14519
|
return !Number.isFinite(a) || a <= 0 ? null : Math.max(1, Math.round(a));
|
|
14187
14520
|
}
|
|
14188
14521
|
//#endregion
|
|
14189
14522
|
//#region src/editor/snapping-manager/utils.ts
|
|
14190
|
-
var
|
|
14523
|
+
var Uc = ({ anchors: e, bounds: t }) => {
|
|
14191
14524
|
let { left: n, right: r, centerX: i, top: a, bottom: o, centerY: s } = t;
|
|
14192
14525
|
e.vertical.push(n, i, r), e.horizontal.push(a, s, o);
|
|
14193
|
-
},
|
|
14526
|
+
}, Wc = ({ bounds: e, type: t, primaryStart: n, primaryEnd: r }) => {
|
|
14194
14527
|
let i = [], a = n === "top" ? "left" : "top", o = r === "bottom" ? "right" : "bottom", s = [...e].sort((e, t) => e[n] - t[n]);
|
|
14195
14528
|
for (let e = 0; e < s.length; e += 1) {
|
|
14196
14529
|
let c = s[e], l = null, u = Infinity;
|
|
@@ -14211,35 +14544,33 @@ var hc = ({ anchors: e, bounds: t }) => {
|
|
|
14211
14544
|
});
|
|
14212
14545
|
}
|
|
14213
14546
|
return i;
|
|
14214
|
-
},
|
|
14215
|
-
vertical:
|
|
14547
|
+
}, Gc = ({ bounds: e }) => ({
|
|
14548
|
+
vertical: Wc({
|
|
14216
14549
|
bounds: e,
|
|
14217
|
-
axis: "centerX",
|
|
14218
14550
|
type: "vertical",
|
|
14219
14551
|
primaryStart: "top",
|
|
14220
14552
|
primaryEnd: "bottom"
|
|
14221
14553
|
}),
|
|
14222
|
-
horizontal:
|
|
14554
|
+
horizontal: Wc({
|
|
14223
14555
|
bounds: e,
|
|
14224
|
-
axis: "centerY",
|
|
14225
14556
|
type: "horizontal",
|
|
14226
14557
|
primaryStart: "left",
|
|
14227
14558
|
primaryEnd: "right"
|
|
14228
14559
|
})
|
|
14229
|
-
}),
|
|
14560
|
+
}), Kc = [
|
|
14230
14561
|
"montage-area",
|
|
14231
14562
|
"background",
|
|
14232
14563
|
"interaction-blocker"
|
|
14233
|
-
],
|
|
14564
|
+
], qc = ({ activeObject: t }) => {
|
|
14234
14565
|
let n = /* @__PURE__ */ new Set();
|
|
14235
14566
|
return t ? (n.add(t), t instanceof e && t.getObjects().forEach((e) => n.add(e)), n) : n;
|
|
14236
|
-
},
|
|
14567
|
+
}, Jc = ({ object: e, excluded: t, ignoredIds: n = Kc }) => {
|
|
14237
14568
|
if (t.has(e)) return !0;
|
|
14238
14569
|
let { visible: r = !0 } = e;
|
|
14239
14570
|
if (!r) return !0;
|
|
14240
14571
|
let { id: i } = e;
|
|
14241
14572
|
return !!(i && n.includes(i));
|
|
14242
|
-
},
|
|
14573
|
+
}, Yc = class {
|
|
14243
14574
|
constructor({ editor: e }) {
|
|
14244
14575
|
this.anchors = {
|
|
14245
14576
|
vertical: [],
|
|
@@ -14283,7 +14614,7 @@ var hc = ({ anchors: e, bounds: t }) => {
|
|
|
14283
14614
|
target: t,
|
|
14284
14615
|
event: e
|
|
14285
14616
|
})) return;
|
|
14286
|
-
|
|
14617
|
+
ds({
|
|
14287
14618
|
target: t,
|
|
14288
14619
|
transform: n
|
|
14289
14620
|
}), !this.anchors.vertical.length && !this.anchors.horizontal.length && this._cacheAnchors({ activeObject: t });
|
|
@@ -14315,7 +14646,7 @@ var hc = ({ anchors: e, bounds: t }) => {
|
|
|
14315
14646
|
activeBounds: r,
|
|
14316
14647
|
deltaX: s.deltaX,
|
|
14317
14648
|
deltaY: s.deltaY
|
|
14318
|
-
}), c ||
|
|
14649
|
+
}), c || ds({
|
|
14319
14650
|
target: t,
|
|
14320
14651
|
transform: n
|
|
14321
14652
|
});
|
|
@@ -14332,7 +14663,7 @@ var hc = ({ anchors: e, bounds: t }) => {
|
|
|
14332
14663
|
this._clearGuides();
|
|
14333
14664
|
return;
|
|
14334
14665
|
}
|
|
14335
|
-
let r =
|
|
14666
|
+
let r = us({ target: t });
|
|
14336
14667
|
if (this._shouldAbortObjectScaling({
|
|
14337
14668
|
target: t,
|
|
14338
14669
|
transform: n,
|
|
@@ -14349,7 +14680,7 @@ var hc = ({ anchors: e, bounds: t }) => {
|
|
|
14349
14680
|
this._clearGuides();
|
|
14350
14681
|
return;
|
|
14351
14682
|
}
|
|
14352
|
-
let { shouldSnapX: i, shouldSnapY: a, isCornerHandle: o } =
|
|
14683
|
+
let { shouldSnapX: i, shouldSnapY: a, isCornerHandle: o } = rc({ transform: n });
|
|
14353
14684
|
if (!i && !a) {
|
|
14354
14685
|
this._finishObjectScalingWithoutSnap({
|
|
14355
14686
|
target: t,
|
|
@@ -14369,10 +14700,10 @@ var hc = ({ anchors: e, bounds: t }) => {
|
|
|
14369
14700
|
});
|
|
14370
14701
|
return;
|
|
14371
14702
|
}
|
|
14372
|
-
let d = 5 / (this.canvas.getZoom() || 1), { originX: f, originY: p, scaleX: m, scaleY: h } =
|
|
14703
|
+
let d = 5 / (this.canvas.getZoom() || 1), { originX: f, originY: p, scaleX: m, scaleY: h } = ic({
|
|
14373
14704
|
target: t,
|
|
14374
14705
|
transform: n
|
|
14375
|
-
}), g =
|
|
14706
|
+
}), g = oc({
|
|
14376
14707
|
bounds: u,
|
|
14377
14708
|
corner: n.corner,
|
|
14378
14709
|
originX: f,
|
|
@@ -14390,22 +14721,24 @@ var hc = ({ anchors: e, bounds: t }) => {
|
|
|
14390
14721
|
});
|
|
14391
14722
|
return;
|
|
14392
14723
|
}
|
|
14393
|
-
let _ =
|
|
14724
|
+
let _ = ac({
|
|
14725
|
+
target: t,
|
|
14726
|
+
event: e,
|
|
14727
|
+
isCornerHandle: o
|
|
14728
|
+
}), v = sc({
|
|
14394
14729
|
target: t,
|
|
14395
14730
|
bounds: u,
|
|
14396
14731
|
originX: f,
|
|
14397
14732
|
originY: p,
|
|
14398
14733
|
scaleX: m,
|
|
14399
14734
|
scaleY: h,
|
|
14400
|
-
|
|
14401
|
-
|
|
14402
|
-
|
|
14403
|
-
isCornerHandle: o
|
|
14404
|
-
}),
|
|
14735
|
+
originalScaleX: n.original?.scaleX,
|
|
14736
|
+
originalScaleY: n.original?.scaleY,
|
|
14737
|
+
shouldUseUniformScaleSnap: _,
|
|
14405
14738
|
verticalSnap: g.verticalSnap,
|
|
14406
14739
|
horizontalSnap: g.horizontalSnap
|
|
14407
14740
|
});
|
|
14408
|
-
if (!
|
|
14741
|
+
if (!v) {
|
|
14409
14742
|
this._finishObjectScalingWithoutSnap({
|
|
14410
14743
|
target: t,
|
|
14411
14744
|
transform: n,
|
|
@@ -14418,8 +14751,8 @@ var hc = ({ anchors: e, bounds: t }) => {
|
|
|
14418
14751
|
transform: n,
|
|
14419
14752
|
originX: f,
|
|
14420
14753
|
originY: p,
|
|
14421
|
-
plan:
|
|
14422
|
-
}), r &&
|
|
14754
|
+
plan: v
|
|
14755
|
+
}), r && hs({
|
|
14423
14756
|
target: t,
|
|
14424
14757
|
transform: n,
|
|
14425
14758
|
preservePlacement: {
|
|
@@ -14435,9 +14768,9 @@ var hc = ({ anchors: e, bounds: t }) => {
|
|
|
14435
14768
|
});
|
|
14436
14769
|
}
|
|
14437
14770
|
},
|
|
14438
|
-
snapGuards:
|
|
14771
|
+
snapGuards: v.snapGuards
|
|
14439
14772
|
}), !this._shouldHideOverflowingCropFrameGuides({ target: t }) && this._applyGuides({
|
|
14440
|
-
guides:
|
|
14773
|
+
guides: v.guides,
|
|
14441
14774
|
spacingGuides: []
|
|
14442
14775
|
});
|
|
14443
14776
|
}
|
|
@@ -14451,13 +14784,13 @@ var hc = ({ anchors: e, bounds: t }) => {
|
|
|
14451
14784
|
return this.editor.cropManager.isFrameSourceScaleClamped({
|
|
14452
14785
|
target: e,
|
|
14453
14786
|
transform: t
|
|
14454
|
-
}) ? (this._clearGuides(), !0) : n.e?.ctrlKey ? (this._clearGuides(), r &&
|
|
14787
|
+
}) ? (this._clearGuides(), !0) : n.e?.ctrlKey ? (this._clearGuides(), r && hs({
|
|
14455
14788
|
target: e,
|
|
14456
14789
|
transform: t
|
|
14457
14790
|
}), !0) : !1;
|
|
14458
14791
|
}
|
|
14459
14792
|
_finishObjectScalingWithoutSnap({ target: e, transform: t, canApplyPixelScalingStep: n }) {
|
|
14460
|
-
n &&
|
|
14793
|
+
n && hs({
|
|
14461
14794
|
target: e,
|
|
14462
14795
|
transform: t
|
|
14463
14796
|
}), this._clearGuides();
|
|
@@ -14542,7 +14875,7 @@ var hc = ({ anchors: e, bounds: t }) => {
|
|
|
14542
14875
|
this._clearGuides();
|
|
14543
14876
|
return;
|
|
14544
14877
|
}
|
|
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 =
|
|
14878
|
+
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 = cc({
|
|
14546
14879
|
target: e,
|
|
14547
14880
|
bounds: s,
|
|
14548
14881
|
originX: m,
|
|
@@ -14623,14 +14956,14 @@ var hc = ({ anchors: e, bounds: t }) => {
|
|
|
14623
14956
|
}, r = [];
|
|
14624
14957
|
for (let e of t) {
|
|
14625
14958
|
let t = W({ object: e });
|
|
14626
|
-
t && (
|
|
14959
|
+
t && (Uc({
|
|
14627
14960
|
anchors: n,
|
|
14628
14961
|
bounds: t
|
|
14629
14962
|
}), r.push(t));
|
|
14630
14963
|
}
|
|
14631
14964
|
let { montageArea: i } = this.editor, a = W({ object: i });
|
|
14632
14965
|
if (a) {
|
|
14633
|
-
|
|
14966
|
+
Uc({
|
|
14634
14967
|
anchors: n,
|
|
14635
14968
|
bounds: a
|
|
14636
14969
|
});
|
|
@@ -14642,12 +14975,12 @@ var hc = ({ anchors: e, bounds: t }) => {
|
|
|
14642
14975
|
bottom: i
|
|
14643
14976
|
};
|
|
14644
14977
|
} else this.guideBounds = this._calculateViewportBounds();
|
|
14645
|
-
this.anchors = n, this.spacingPatterns =
|
|
14978
|
+
this.anchors = n, this.spacingPatterns = Gc({ bounds: r }), this.cachedTargetBounds = r;
|
|
14646
14979
|
}
|
|
14647
14980
|
_collectTargets({ activeObject: e }) {
|
|
14648
|
-
let t =
|
|
14981
|
+
let t = qc({ activeObject: e }), n = [];
|
|
14649
14982
|
return this.canvas.forEachObject((e) => {
|
|
14650
|
-
|
|
14983
|
+
Jc({
|
|
14651
14984
|
object: e,
|
|
14652
14985
|
excluded: t
|
|
14653
14986
|
}) || n.push(e);
|
|
@@ -14670,7 +15003,7 @@ var hc = ({ anchors: e, bounds: t }) => {
|
|
|
14670
15003
|
bottom: (r - s) / a
|
|
14671
15004
|
};
|
|
14672
15005
|
}
|
|
14673
|
-
},
|
|
15006
|
+
}, Xc = "#3D8BF4", Zc = class e {
|
|
14674
15007
|
constructor({ editor: e }) {
|
|
14675
15008
|
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();
|
|
14676
15009
|
}
|
|
@@ -14763,8 +15096,8 @@ var hc = ({ anchors: e, bounds: t }) => {
|
|
|
14763
15096
|
this.isTargetMontageArea = l, this.activeGuides = d, this._hideToolbar(), n.requestRenderAll();
|
|
14764
15097
|
}
|
|
14765
15098
|
static _resolveTarget({ event: e, activeObject: t }) {
|
|
14766
|
-
let { target: n } = e, r =
|
|
14767
|
-
return n && !
|
|
15099
|
+
let { target: n } = e, r = qc({ activeObject: t });
|
|
15100
|
+
return n && !Jc({
|
|
14768
15101
|
object: n,
|
|
14769
15102
|
excluded: r
|
|
14770
15103
|
}) ? n : null;
|
|
@@ -14881,7 +15214,7 @@ var hc = ({ anchors: e, bounds: t }) => {
|
|
|
14881
15214
|
let { canvas: e } = this, t = e.getSelectionContext();
|
|
14882
15215
|
if (!t) return;
|
|
14883
15216
|
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;
|
|
14884
|
-
t.save(), Array.isArray(n) && t.transform(...n), t.lineWidth = 1 / r, t.strokeStyle =
|
|
15217
|
+
t.save(), Array.isArray(n) && t.transform(...n), t.lineWidth = 1 / r, t.strokeStyle = Xc, t.setLineDash([]);
|
|
14885
15218
|
for (let e of this.activeGuides) {
|
|
14886
15219
|
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;
|
|
14887
15220
|
t.beginPath(), n === "vertical" ? (t.moveTo(i, a), t.lineTo(i, c)) : (t.moveTo(a, i), t.lineTo(c, i)), t.stroke(), ns({
|
|
@@ -14892,7 +15225,7 @@ var hc = ({ anchors: e, bounds: t }) => {
|
|
|
14892
15225
|
end: c,
|
|
14893
15226
|
text: To({ distance: l }).toString(),
|
|
14894
15227
|
zoom: r,
|
|
14895
|
-
color:
|
|
15228
|
+
color: Xc,
|
|
14896
15229
|
lineWidth: 1,
|
|
14897
15230
|
offsetAlongAxis: d,
|
|
14898
15231
|
offsetPerpendicular: 0
|
|
@@ -14910,13 +15243,13 @@ var hc = ({ anchors: e, bounds: t }) => {
|
|
|
14910
15243
|
let { toolbar: e } = this.editor;
|
|
14911
15244
|
e?.showAfterTemporary?.(), this.isToolbarHidden = !1;
|
|
14912
15245
|
}
|
|
14913
|
-
},
|
|
14914
|
-
function
|
|
14915
|
-
return t ?
|
|
15246
|
+
}, Qc = 16, $c = 16, el = Gt, tl = Kt, nl = Qc;
|
|
15247
|
+
function rl({ sourceSize: e, size: t, aspectRatio: n, allowOverflow: r }) {
|
|
15248
|
+
return t ? ul({
|
|
14916
15249
|
size: t,
|
|
14917
15250
|
sourceSize: e,
|
|
14918
15251
|
allowOverflow: r
|
|
14919
|
-
}) : n ?
|
|
15252
|
+
}) : n ? ll({
|
|
14920
15253
|
aspectRatio: n,
|
|
14921
15254
|
sourceSize: e
|
|
14922
15255
|
}) : {
|
|
@@ -14930,29 +15263,29 @@ function Z({ source: e }) {
|
|
|
14930
15263
|
height: e.height
|
|
14931
15264
|
};
|
|
14932
15265
|
}
|
|
14933
|
-
function
|
|
15266
|
+
function il({ source: e, frame: t }) {
|
|
14934
15267
|
let n = e.calcTransformMatrix(), r = w.invertTransform(n), i = t.calcTransformMatrix();
|
|
14935
|
-
return
|
|
15268
|
+
return sl({ points: cl({ frame: t }).map((e) => e.transform(i).transform(r)) });
|
|
14936
15269
|
}
|
|
14937
|
-
function
|
|
14938
|
-
|
|
15270
|
+
function al({ source: e, frame: t }) {
|
|
15271
|
+
dl({
|
|
14939
15272
|
source: e,
|
|
14940
15273
|
frame: t
|
|
14941
|
-
}),
|
|
15274
|
+
}), pl({
|
|
14942
15275
|
source: e,
|
|
14943
15276
|
frame: t
|
|
14944
15277
|
});
|
|
14945
15278
|
}
|
|
14946
|
-
function
|
|
14947
|
-
|
|
15279
|
+
function ol({ source: e, frame: t }) {
|
|
15280
|
+
fl({
|
|
14948
15281
|
source: e,
|
|
14949
15282
|
frame: t
|
|
14950
|
-
}),
|
|
15283
|
+
}), pl({
|
|
14951
15284
|
source: e,
|
|
14952
15285
|
frame: t
|
|
14953
15286
|
});
|
|
14954
15287
|
}
|
|
14955
|
-
function
|
|
15288
|
+
function sl({ points: e }) {
|
|
14956
15289
|
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));
|
|
14957
15290
|
return {
|
|
14958
15291
|
left: t,
|
|
@@ -14961,7 +15294,7 @@ function Nc({ points: e }) {
|
|
|
14961
15294
|
height: i - n
|
|
14962
15295
|
};
|
|
14963
15296
|
}
|
|
14964
|
-
function
|
|
15297
|
+
function cl({ frame: e }) {
|
|
14965
15298
|
let t = e.width / 2, n = e.height / 2;
|
|
14966
15299
|
return [
|
|
14967
15300
|
new m(-t, -n),
|
|
@@ -14970,7 +15303,7 @@ function Pc({ frame: e }) {
|
|
|
14970
15303
|
new m(-t, n)
|
|
14971
15304
|
];
|
|
14972
15305
|
}
|
|
14973
|
-
function
|
|
15306
|
+
function ll({ sourceSize: e, aspectRatio: t }) {
|
|
14974
15307
|
let n = e.width / e.height, r = t.width / t.height;
|
|
14975
15308
|
return r >= n ? {
|
|
14976
15309
|
width: e.width,
|
|
@@ -14980,49 +15313,49 @@ function Fc({ sourceSize: e, aspectRatio: t }) {
|
|
|
14980
15313
|
height: e.height
|
|
14981
15314
|
};
|
|
14982
15315
|
}
|
|
14983
|
-
function
|
|
14984
|
-
let r = n ?
|
|
15316
|
+
function ul({ size: e, sourceSize: t, allowOverflow: n }) {
|
|
15317
|
+
let r = n ? el : Math.min(t.width, el), i = n ? tl : Math.min(t.height, tl);
|
|
14985
15318
|
return {
|
|
14986
|
-
width:
|
|
15319
|
+
width: _l({
|
|
14987
15320
|
value: e.width,
|
|
14988
|
-
min:
|
|
15321
|
+
min: Qc,
|
|
14989
15322
|
max: r
|
|
14990
15323
|
}),
|
|
14991
|
-
height:
|
|
15324
|
+
height: _l({
|
|
14992
15325
|
value: e.height,
|
|
14993
|
-
min:
|
|
15326
|
+
min: $c,
|
|
14994
15327
|
max: i
|
|
14995
15328
|
})
|
|
14996
15329
|
};
|
|
14997
15330
|
}
|
|
14998
|
-
function
|
|
14999
|
-
let n =
|
|
15331
|
+
function dl({ source: e, frame: t }) {
|
|
15332
|
+
let n = il({
|
|
15000
15333
|
source: e,
|
|
15001
15334
|
frame: t
|
|
15002
|
-
}), r = Z({ source: e }), i = r.width / Math.max(n.width,
|
|
15335
|
+
}), r = Z({ source: e }), i = r.width / Math.max(n.width, Qc), a = r.height / Math.max(n.height, $c);
|
|
15003
15336
|
i < 1 && t.set({ scaleX: (t.scaleX ?? 1) * i }), a < 1 && t.set({ scaleY: (t.scaleY ?? 1) * a }), t.setCoords();
|
|
15004
15337
|
}
|
|
15005
|
-
function
|
|
15006
|
-
let n =
|
|
15338
|
+
function fl({ source: e, frame: t }) {
|
|
15339
|
+
let n = il({
|
|
15007
15340
|
source: e,
|
|
15008
15341
|
frame: t
|
|
15009
|
-
}), r = Z({ source: e }), i = r.width / Math.max(n.width,
|
|
15342
|
+
}), r = Z({ source: e }), i = r.width / Math.max(n.width, Qc), a = r.height / Math.max(n.height, $c), o = Math.min(i, a);
|
|
15010
15343
|
o < 1 && t.set({
|
|
15011
15344
|
scaleX: (t.scaleX ?? 1) * o,
|
|
15012
15345
|
scaleY: (t.scaleY ?? 1) * o
|
|
15013
15346
|
}), t.setCoords();
|
|
15014
15347
|
}
|
|
15015
|
-
function
|
|
15016
|
-
let n =
|
|
15348
|
+
function pl({ source: e, frame: t }) {
|
|
15349
|
+
let n = il({
|
|
15017
15350
|
source: e,
|
|
15018
15351
|
frame: t
|
|
15019
|
-
}), r =
|
|
15352
|
+
}), r = ml({ sourceSize: Z({ source: e }) }), i = hl({ rect: n }), a = gl({
|
|
15020
15353
|
rect: n,
|
|
15021
15354
|
sourceBounds: r
|
|
15022
15355
|
}), o = new m(i.x + a.x, i.y + a.y).transform(e.calcTransformMatrix());
|
|
15023
15356
|
t.setPositionByOrigin(o, "center", "center"), t.setCoords();
|
|
15024
15357
|
}
|
|
15025
|
-
function
|
|
15358
|
+
function ml({ sourceSize: e }) {
|
|
15026
15359
|
return {
|
|
15027
15360
|
left: -e.width / 2,
|
|
15028
15361
|
top: -e.height / 2,
|
|
@@ -15030,19 +15363,19 @@ function Bc({ sourceSize: e }) {
|
|
|
15030
15363
|
height: e.height
|
|
15031
15364
|
};
|
|
15032
15365
|
}
|
|
15033
|
-
function
|
|
15366
|
+
function hl({ rect: e }) {
|
|
15034
15367
|
return new m(e.left + e.width / 2, e.top + e.height / 2);
|
|
15035
15368
|
}
|
|
15036
|
-
function
|
|
15369
|
+
function gl({ rect: e, sourceBounds: t }) {
|
|
15037
15370
|
let n = t.left + t.width, r = t.top + t.height, i = 0, a = 0;
|
|
15038
15371
|
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);
|
|
15039
15372
|
}
|
|
15040
|
-
function
|
|
15373
|
+
function _l({ value: e, min: t, max: n }) {
|
|
15041
15374
|
return Math.max(t, Math.min(n, e));
|
|
15042
15375
|
}
|
|
15043
15376
|
//#endregion
|
|
15044
15377
|
//#region src/editor/crop-manager/domain/crop-frame-size.ts
|
|
15045
|
-
function
|
|
15378
|
+
function vl({ frame: e, scaleX: t = e.scaleX ?? 1, scaleY: n = e.scaleY ?? 1 }) {
|
|
15046
15379
|
let r = Math.abs(e.cropSourceScaleX ?? 1) || 1, i = Math.abs(e.cropSourceScaleY ?? 1) || 1;
|
|
15047
15380
|
return {
|
|
15048
15381
|
width: Math.max(1, e.width * Math.abs(t) / r),
|
|
@@ -15051,236 +15384,236 @@ function Wc({ frame: e, scaleX: t = e.scaleX ?? 1, scaleY: n = e.scaleY ?? 1 })
|
|
|
15051
15384
|
}
|
|
15052
15385
|
//#endregion
|
|
15053
15386
|
//#region src/editor/crop-manager/domain/crop-source-scale.ts
|
|
15054
|
-
var
|
|
15055
|
-
function
|
|
15387
|
+
var yl = 1;
|
|
15388
|
+
function bl({ sourceSize: e, startRect: t, anchorX: n, anchorY: r }) {
|
|
15056
15389
|
let i = Math.max(1, t.width), a = Math.max(1, t.height);
|
|
15057
|
-
if (
|
|
15390
|
+
if (Sl({
|
|
15058
15391
|
sourceSize: e,
|
|
15059
15392
|
rect: t,
|
|
15060
15393
|
axis: "x"
|
|
15061
|
-
}) ||
|
|
15394
|
+
}) || Sl({
|
|
15062
15395
|
sourceSize: e,
|
|
15063
15396
|
rect: t,
|
|
15064
15397
|
axis: "y"
|
|
15065
15398
|
})) return 1;
|
|
15066
|
-
let o =
|
|
15399
|
+
let o = Tl({
|
|
15067
15400
|
sourceSize: e,
|
|
15068
15401
|
rect: t,
|
|
15069
15402
|
axis: "x",
|
|
15070
15403
|
anchor: n
|
|
15071
|
-
}), s =
|
|
15404
|
+
}), s = Tl({
|
|
15072
15405
|
sourceSize: e,
|
|
15073
15406
|
rect: t,
|
|
15074
15407
|
axis: "y",
|
|
15075
15408
|
anchor: r
|
|
15076
15409
|
}), 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) <=
|
|
15410
|
+
return (u - 1) * Math.min(i, a) <= yl ? 1 : Math.max(1, u);
|
|
15078
15411
|
}
|
|
15079
|
-
function
|
|
15080
|
-
let i = Math.max(1,
|
|
15412
|
+
function xl({ sourceSize: e, startRect: t, axis: n, anchor: r }) {
|
|
15413
|
+
let i = Math.max(1, wl({
|
|
15081
15414
|
rect: t,
|
|
15082
15415
|
axis: n
|
|
15083
15416
|
}));
|
|
15084
|
-
if (
|
|
15417
|
+
if (Sl({
|
|
15085
15418
|
sourceSize: e,
|
|
15086
15419
|
rect: t,
|
|
15087
15420
|
axis: n
|
|
15088
15421
|
})) return 1;
|
|
15089
|
-
let a =
|
|
15422
|
+
let a = Tl({
|
|
15090
15423
|
sourceSize: e,
|
|
15091
15424
|
rect: t,
|
|
15092
15425
|
axis: n,
|
|
15093
15426
|
anchor: r
|
|
15094
|
-
}), o =
|
|
15427
|
+
}), o = Cl({
|
|
15095
15428
|
sourceSize: e,
|
|
15096
15429
|
axis: n
|
|
15097
15430
|
}), s = Math.min(a, o) / i;
|
|
15098
|
-
return (s - 1) * i <=
|
|
15431
|
+
return (s - 1) * i <= yl ? 1 : Math.max(1, s);
|
|
15099
15432
|
}
|
|
15100
|
-
function
|
|
15101
|
-
let r =
|
|
15433
|
+
function Sl({ sourceSize: e, rect: t, axis: n }) {
|
|
15434
|
+
let r = Cl({
|
|
15102
15435
|
sourceSize: e,
|
|
15103
15436
|
axis: n
|
|
15104
|
-
}), i =
|
|
15437
|
+
}), i = wl({
|
|
15105
15438
|
rect: t,
|
|
15106
15439
|
axis: n
|
|
15107
15440
|
});
|
|
15108
15441
|
return Math.round(i) >= Math.round(r);
|
|
15109
15442
|
}
|
|
15110
|
-
function
|
|
15443
|
+
function Cl({ sourceSize: e, axis: t }) {
|
|
15111
15444
|
return t === "x" ? e.width : e.height;
|
|
15112
15445
|
}
|
|
15113
|
-
function
|
|
15446
|
+
function wl({ rect: e, axis: t }) {
|
|
15114
15447
|
return t === "x" ? e.width : e.height;
|
|
15115
15448
|
}
|
|
15116
|
-
function
|
|
15449
|
+
function Tl({ sourceSize: e, rect: t, axis: n, anchor: r }) {
|
|
15117
15450
|
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;
|
|
15118
|
-
return r === "min" ? c -
|
|
15451
|
+
return r === "min" ? c - El({
|
|
15119
15452
|
value: a,
|
|
15120
15453
|
boundary: s
|
|
15121
|
-
}) : r === "max" ?
|
|
15454
|
+
}) : r === "max" ? El({
|
|
15122
15455
|
value: l,
|
|
15123
15456
|
boundary: c
|
|
15124
15457
|
}) - s : Math.min(u - s, c - u) * 2;
|
|
15125
15458
|
}
|
|
15126
|
-
function
|
|
15127
|
-
return Math.abs(e - t) <=
|
|
15459
|
+
function El({ value: e, boundary: t }) {
|
|
15460
|
+
return Math.abs(e - t) <= yl ? t : e;
|
|
15128
15461
|
}
|
|
15129
15462
|
//#endregion
|
|
15130
15463
|
//#region src/editor/crop-manager/interaction/crop-controls.ts
|
|
15131
|
-
var
|
|
15464
|
+
var Dl = .001, Ol = 1, kl = 1e-6, Al = 1e-9, jl = [
|
|
15132
15465
|
"tl",
|
|
15133
15466
|
"tr",
|
|
15134
15467
|
"bl",
|
|
15135
15468
|
"br"
|
|
15136
|
-
],
|
|
15469
|
+
], Ml = [
|
|
15137
15470
|
"ml",
|
|
15138
15471
|
"mr",
|
|
15139
15472
|
"mt",
|
|
15140
15473
|
"mb"
|
|
15141
|
-
],
|
|
15474
|
+
], Nl = {
|
|
15142
15475
|
ml: "w-resize",
|
|
15143
15476
|
mr: "e-resize",
|
|
15144
15477
|
mt: "n-resize",
|
|
15145
15478
|
mb: "s-resize"
|
|
15146
15479
|
};
|
|
15147
|
-
function
|
|
15480
|
+
function Pl({ transform: e }) {
|
|
15148
15481
|
let { originX: t, originY: n } = e;
|
|
15149
15482
|
return (t === "center" || t === .5) && (n === "center" || n === .5);
|
|
15150
15483
|
}
|
|
15151
|
-
function
|
|
15484
|
+
function Fl({ transform: e, x: t, y: n }) {
|
|
15152
15485
|
let r = e, { target: i } = r, { scaleX: a = 1, scaleY: o = 1 } = i;
|
|
15153
|
-
if (
|
|
15486
|
+
if (zl({
|
|
15154
15487
|
transform: r,
|
|
15155
15488
|
x: t,
|
|
15156
15489
|
y: n
|
|
15157
|
-
})) return
|
|
15490
|
+
})) return Bl({ transform: r }), !0;
|
|
15158
15491
|
let s = x.getLocalPoint(r, r.originX, r.originY, t, n);
|
|
15159
|
-
return
|
|
15492
|
+
return Hl({ transform: r }), Kl({
|
|
15160
15493
|
transform: r,
|
|
15161
15494
|
localPoint: s
|
|
15162
15495
|
}), a !== i.scaleX || o !== i.scaleY;
|
|
15163
15496
|
}
|
|
15164
|
-
function
|
|
15497
|
+
function Il({ transform: e, x: t, y: n }) {
|
|
15165
15498
|
let r = e, { target: i } = r, { scaleX: a = 1, scaleY: o = 1 } = i;
|
|
15166
|
-
if (
|
|
15499
|
+
if (zl({
|
|
15167
15500
|
transform: r,
|
|
15168
15501
|
x: t,
|
|
15169
15502
|
y: n
|
|
15170
|
-
})) return
|
|
15503
|
+
})) return Bl({ transform: r }), !0;
|
|
15171
15504
|
let s = x.getLocalPoint(r, r.originX, r.originY, t, n);
|
|
15172
|
-
return
|
|
15505
|
+
return Hl({ transform: r }), ru({
|
|
15173
15506
|
transform: r,
|
|
15174
15507
|
localPoint: s
|
|
15175
15508
|
}), a !== i.scaleX || o !== i.scaleY;
|
|
15176
15509
|
}
|
|
15177
|
-
function
|
|
15510
|
+
function Ll({ transform: e, axis: t, x: n, y: r }) {
|
|
15178
15511
|
let i = e, { target: a } = i, o = t === "x" ? a.scaleX ?? 1 : a.scaleY ?? 1;
|
|
15179
|
-
if (
|
|
15512
|
+
if (zl({
|
|
15180
15513
|
transform: i,
|
|
15181
15514
|
x: n,
|
|
15182
15515
|
y: r
|
|
15183
|
-
})) return
|
|
15516
|
+
})) return Vl({
|
|
15184
15517
|
transform: i,
|
|
15185
15518
|
axis: t
|
|
15186
15519
|
}), !0;
|
|
15187
15520
|
let s = x.getLocalPoint(i, i.originX, i.originY, n, r);
|
|
15188
|
-
return
|
|
15521
|
+
return Hl({ transform: i }), ql({
|
|
15189
15522
|
transform: i,
|
|
15190
15523
|
axis: t,
|
|
15191
15524
|
localPoint: s
|
|
15192
15525
|
}), t === "x" ? o !== a.scaleX : o !== a.scaleY;
|
|
15193
15526
|
}
|
|
15194
|
-
function
|
|
15527
|
+
function Rl({ transform: e, axis: t, x: n, y: r }) {
|
|
15195
15528
|
let i = e, { target: a } = i, { scaleX: o = 1, scaleY: s = 1 } = a;
|
|
15196
|
-
if (
|
|
15529
|
+
if (zl({
|
|
15197
15530
|
transform: i,
|
|
15198
15531
|
x: n,
|
|
15199
15532
|
y: r
|
|
15200
|
-
})) return
|
|
15533
|
+
})) return Bl({ transform: i }), !0;
|
|
15201
15534
|
let c = x.getLocalPoint(i, i.originX, i.originY, n, r);
|
|
15202
|
-
return
|
|
15535
|
+
return Hl({ transform: i }), Jl({
|
|
15203
15536
|
transform: i,
|
|
15204
15537
|
axis: t,
|
|
15205
15538
|
localPoint: c
|
|
15206
15539
|
}), o !== a.scaleX || s !== a.scaleY;
|
|
15207
15540
|
}
|
|
15208
|
-
function
|
|
15209
|
-
return Math.abs(t - e.ex) <=
|
|
15541
|
+
function zl({ transform: e, x: t, y: n }) {
|
|
15542
|
+
return Math.abs(t - e.ex) <= Dl && Math.abs(n - e.ey) <= Dl;
|
|
15210
15543
|
}
|
|
15211
|
-
function
|
|
15544
|
+
function Bl({ transform: e }) {
|
|
15212
15545
|
e.target.set({
|
|
15213
15546
|
scaleX: e.original.scaleX,
|
|
15214
15547
|
scaleY: e.original.scaleY
|
|
15215
15548
|
});
|
|
15216
15549
|
}
|
|
15217
|
-
function
|
|
15550
|
+
function Vl({ transform: e, axis: t }) {
|
|
15218
15551
|
if (t === "x") {
|
|
15219
15552
|
e.target.set("scaleX", e.original.scaleX);
|
|
15220
15553
|
return;
|
|
15221
15554
|
}
|
|
15222
15555
|
e.target.set("scaleY", e.original.scaleY);
|
|
15223
15556
|
}
|
|
15224
|
-
function
|
|
15225
|
-
let { signX: t, signY: n } =
|
|
15557
|
+
function Hl({ transform: e }) {
|
|
15558
|
+
let { signX: t, signY: n } = Ul({ controlKey: e.corner });
|
|
15226
15559
|
e.signX === void 0 && (e.signX = t), e.signY === void 0 && (e.signY = n);
|
|
15227
15560
|
}
|
|
15228
|
-
function
|
|
15561
|
+
function Ul({ controlKey: e }) {
|
|
15229
15562
|
return {
|
|
15230
|
-
signX:
|
|
15231
|
-
signY:
|
|
15563
|
+
signX: Wl({ controlKey: e }),
|
|
15564
|
+
signY: Gl({ controlKey: e })
|
|
15232
15565
|
};
|
|
15233
15566
|
}
|
|
15234
|
-
function
|
|
15567
|
+
function Wl({ controlKey: e }) {
|
|
15235
15568
|
return e === "tl" || e === "bl" || e === "ml" ? -1 : 1;
|
|
15236
15569
|
}
|
|
15237
|
-
function
|
|
15570
|
+
function Gl({ controlKey: e }) {
|
|
15238
15571
|
return e === "tl" || e === "tr" || e === "mt" ? -1 : 1;
|
|
15239
15572
|
}
|
|
15240
|
-
function
|
|
15573
|
+
function Kl({ transform: e, localPoint: t }) {
|
|
15241
15574
|
let { target: n } = e;
|
|
15242
|
-
|
|
15243
|
-
let r =
|
|
15575
|
+
Xl({ transform: e });
|
|
15576
|
+
let r = Yl({
|
|
15244
15577
|
transform: e,
|
|
15245
15578
|
axis: "x",
|
|
15246
15579
|
localPoint: t
|
|
15247
|
-
}), i =
|
|
15580
|
+
}), i = Yl({
|
|
15248
15581
|
transform: e,
|
|
15249
15582
|
axis: "y",
|
|
15250
15583
|
localPoint: t
|
|
15251
15584
|
});
|
|
15252
|
-
n.lockScalingX || n.set("scaleX", r.scale), n.lockScalingY || n.set("scaleY", i.scale), (r.sourceClamped || i.sourceClamped) &&
|
|
15585
|
+
n.lockScalingX || n.set("scaleX", r.scale), n.lockScalingY || n.set("scaleY", i.scale), (r.sourceClamped || i.sourceClamped) && Zl({
|
|
15253
15586
|
transform: e,
|
|
15254
15587
|
preserveAspectRatio: !1
|
|
15255
15588
|
});
|
|
15256
15589
|
}
|
|
15257
|
-
function
|
|
15590
|
+
function ql({ transform: e, axis: t, localPoint: n }) {
|
|
15258
15591
|
let { target: r } = e;
|
|
15259
15592
|
if (t === "x" && r.lockScalingX || t === "y" && r.lockScalingY) return;
|
|
15260
|
-
|
|
15261
|
-
let i =
|
|
15593
|
+
Xl({ transform: e });
|
|
15594
|
+
let i = Yl({
|
|
15262
15595
|
transform: e,
|
|
15263
15596
|
axis: t,
|
|
15264
15597
|
localPoint: n
|
|
15265
15598
|
});
|
|
15266
|
-
t === "x" ? r.set("scaleX", i.scale) : r.set("scaleY", i.scale), i.sourceClamped &&
|
|
15599
|
+
t === "x" ? r.set("scaleX", i.scale) : r.set("scaleY", i.scale), i.sourceClamped && Zl({
|
|
15267
15600
|
transform: e,
|
|
15268
15601
|
preserveAspectRatio: !1
|
|
15269
15602
|
});
|
|
15270
15603
|
}
|
|
15271
|
-
function
|
|
15604
|
+
function Jl({ transform: e, axis: t, localPoint: n }) {
|
|
15272
15605
|
let { target: r } = e;
|
|
15273
15606
|
if (r.lockScalingX || r.lockScalingY) return;
|
|
15274
|
-
let i =
|
|
15607
|
+
let i = Yl({
|
|
15275
15608
|
transform: e,
|
|
15276
15609
|
axis: t,
|
|
15277
15610
|
localPoint: n,
|
|
15278
15611
|
constrainToSource: !1
|
|
15279
|
-
}), a = t === "x" ? e.original.scaleX : e.original.scaleY, o =
|
|
15612
|
+
}), a = t === "x" ? e.original.scaleX : e.original.scaleY, o = su({
|
|
15280
15613
|
target: r,
|
|
15281
15614
|
transform: e,
|
|
15282
15615
|
scale: a > 0 ? i.scale / a : 1,
|
|
15283
|
-
forceMinimum:
|
|
15616
|
+
forceMinimum: mu({
|
|
15284
15617
|
transform: e,
|
|
15285
15618
|
axis: t,
|
|
15286
15619
|
localPoint: n
|
|
@@ -15288,17 +15621,17 @@ function bl({ transform: e, axis: t, localPoint: n }) {
|
|
|
15288
15621
|
});
|
|
15289
15622
|
r.set("scaleX", o.scaleX), r.set("scaleY", o.scaleY);
|
|
15290
15623
|
}
|
|
15291
|
-
function
|
|
15292
|
-
let { target: i } = e, a =
|
|
15624
|
+
function Yl({ transform: e, axis: t, localPoint: n, constrainToSource: r = !0 }) {
|
|
15625
|
+
let { target: i } = e, a = ou({ target: i }), o = pu({ 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 ? tu({
|
|
15293
15626
|
target: i,
|
|
15294
15627
|
transform: e,
|
|
15295
15628
|
axis: t
|
|
15296
|
-
}) : null, p =
|
|
15629
|
+
}) : null, p = eu({
|
|
15297
15630
|
axis: t,
|
|
15298
15631
|
limits: o,
|
|
15299
15632
|
sourceMaximumScale: f
|
|
15300
15633
|
});
|
|
15301
|
-
if (
|
|
15634
|
+
if (mu({
|
|
15302
15635
|
transform: e,
|
|
15303
15636
|
axis: t,
|
|
15304
15637
|
localPoint: n
|
|
@@ -15307,11 +15640,11 @@ function xl({ transform: e, axis: t, localPoint: n, constrainToSource: r = !0 })
|
|
|
15307
15640
|
sourceClamped: !1
|
|
15308
15641
|
};
|
|
15309
15642
|
let m = Math.abs((l || 0) * s / u);
|
|
15310
|
-
|
|
15311
|
-
let h =
|
|
15643
|
+
Pl({ transform: e }) && (m *= 2);
|
|
15644
|
+
let h = $l({
|
|
15312
15645
|
target: i,
|
|
15313
15646
|
axis: t,
|
|
15314
|
-
scale:
|
|
15647
|
+
scale: yu({
|
|
15315
15648
|
value: m,
|
|
15316
15649
|
min: d,
|
|
15317
15650
|
max: p
|
|
@@ -15321,7 +15654,7 @@ function xl({ transform: e, axis: t, localPoint: n, constrainToSource: r = !0 })
|
|
|
15321
15654
|
});
|
|
15322
15655
|
return {
|
|
15323
15656
|
scale: h,
|
|
15324
|
-
sourceClamped:
|
|
15657
|
+
sourceClamped: Ql({
|
|
15325
15658
|
scale: h,
|
|
15326
15659
|
maximumScale: p,
|
|
15327
15660
|
sourceMaximumScale: f,
|
|
@@ -15329,102 +15662,102 @@ function xl({ transform: e, axis: t, localPoint: n, constrainToSource: r = !0 })
|
|
|
15329
15662
|
})
|
|
15330
15663
|
};
|
|
15331
15664
|
}
|
|
15332
|
-
function
|
|
15665
|
+
function Xl({ transform: e }) {
|
|
15333
15666
|
e.cropSourceScaleClamped = !1, e.cropSourceBoundScale = null, e.cropSourceScalePreserveAspectRatio = void 0;
|
|
15334
15667
|
}
|
|
15335
|
-
function
|
|
15668
|
+
function Zl({ transform: e, preserveAspectRatio: t }) {
|
|
15336
15669
|
let { target: n } = e;
|
|
15337
15670
|
e.cropSourceScaleClamped = !0, e.cropSourceScalePreserveAspectRatio = t, e.cropSourceBoundScale = {
|
|
15338
15671
|
scaleX: n.scaleX ?? 1,
|
|
15339
15672
|
scaleY: n.scaleY ?? 1
|
|
15340
15673
|
};
|
|
15341
15674
|
}
|
|
15342
|
-
function
|
|
15343
|
-
return n === null || Math.abs(t - n) >
|
|
15675
|
+
function Ql({ scale: e, maximumScale: t, sourceMaximumScale: n, originalScale: r }) {
|
|
15676
|
+
return n === null || Math.abs(t - n) > Al || Math.abs(e - n) > Al ? !1 : Math.abs(Math.abs(r) - n) > Al;
|
|
15344
15677
|
}
|
|
15345
|
-
function
|
|
15346
|
-
return i === null || Math.abs(r - i) >
|
|
15678
|
+
function $l({ target: e, axis: t, scale: n, maximumScale: r, sourceMaximumScale: i }) {
|
|
15679
|
+
return i === null || Math.abs(r - i) > Al ? n : nu({
|
|
15347
15680
|
target: e,
|
|
15348
15681
|
axis: t,
|
|
15349
15682
|
fromScale: n,
|
|
15350
15683
|
toScale: i
|
|
15351
|
-
}) <=
|
|
15684
|
+
}) <= Ol + kl ? i : n;
|
|
15352
15685
|
}
|
|
15353
|
-
function
|
|
15686
|
+
function eu({ axis: e, limits: t, sourceMaximumScale: n }) {
|
|
15354
15687
|
let r = e === "x" ? t.minScaleX : t.minScaleY, i = e === "x" ? t.maxScaleX : t.maxScaleY;
|
|
15355
15688
|
return n === null ? i : Math.max(r, Math.min(i, n));
|
|
15356
15689
|
}
|
|
15357
|
-
function
|
|
15358
|
-
let r =
|
|
15690
|
+
function tu({ target: e, transform: t, axis: n }) {
|
|
15691
|
+
let r = lu({
|
|
15359
15692
|
target: e,
|
|
15360
15693
|
transform: t
|
|
15361
15694
|
});
|
|
15362
15695
|
if (!r) return null;
|
|
15363
|
-
let i = n === "x" ? t.original.scaleX : t.original.scaleY, a =
|
|
15696
|
+
let i = n === "x" ? t.original.scaleX : t.original.scaleY, a = xl({
|
|
15364
15697
|
sourceSize: r.sourceSize,
|
|
15365
15698
|
startRect: r.startRect,
|
|
15366
15699
|
axis: n,
|
|
15367
|
-
anchor:
|
|
15700
|
+
anchor: uu({
|
|
15368
15701
|
transform: t,
|
|
15369
15702
|
axis: n
|
|
15370
15703
|
})
|
|
15371
15704
|
});
|
|
15372
15705
|
return Math.abs(i) * a;
|
|
15373
15706
|
}
|
|
15374
|
-
function
|
|
15707
|
+
function nu({ target: e, axis: t, fromScale: n, toScale: r }) {
|
|
15375
15708
|
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
15709
|
return Math.abs(r - n) * Math.max(1, o) / a;
|
|
15377
15710
|
}
|
|
15378
|
-
function
|
|
15711
|
+
function ru({ transform: e, localPoint: t }) {
|
|
15379
15712
|
let { target: n } = e;
|
|
15380
15713
|
if (n.lockScalingX || n.lockScalingY) return;
|
|
15381
|
-
let r =
|
|
15714
|
+
let r = su({
|
|
15382
15715
|
target: n,
|
|
15383
15716
|
transform: e,
|
|
15384
|
-
scale:
|
|
15717
|
+
scale: iu({
|
|
15385
15718
|
transform: e,
|
|
15386
15719
|
localPoint: t,
|
|
15387
|
-
dimensions:
|
|
15720
|
+
dimensions: ou({ target: n })
|
|
15388
15721
|
}),
|
|
15389
|
-
forceMinimum:
|
|
15722
|
+
forceMinimum: hu({
|
|
15390
15723
|
transform: e,
|
|
15391
15724
|
localPoint: t
|
|
15392
15725
|
})
|
|
15393
15726
|
});
|
|
15394
15727
|
n.set("scaleX", r.scaleX), n.set("scaleY", r.scaleY);
|
|
15395
15728
|
}
|
|
15396
|
-
function
|
|
15729
|
+
function iu({ transform: e, localPoint: t, dimensions: n }) {
|
|
15397
15730
|
let r = "gestureScale" in e && typeof e.gestureScale == "number" ? e.gestureScale : null;
|
|
15398
15731
|
if (r !== null) return r;
|
|
15399
|
-
let i = Math.abs(t.x) + Math.abs(t.y), a =
|
|
15732
|
+
let i = Math.abs(t.x) + Math.abs(t.y), a = au({
|
|
15400
15733
|
transform: e,
|
|
15401
15734
|
dimensions: n
|
|
15402
15735
|
}), o = a > 0 ? i / a : 1;
|
|
15403
|
-
return
|
|
15736
|
+
return Pl({ transform: e }) && (o *= 2), o;
|
|
15404
15737
|
}
|
|
15405
|
-
function
|
|
15738
|
+
function au({ transform: e, dimensions: t }) {
|
|
15406
15739
|
let { target: n, original: r } = e, i = n.scaleX ?? 1, a = n.scaleY ?? 1;
|
|
15407
15740
|
return Math.abs(t.x * r.scaleX / i) + Math.abs(t.y * r.scaleY / a);
|
|
15408
15741
|
}
|
|
15409
|
-
function
|
|
15742
|
+
function ou({ target: e }) {
|
|
15410
15743
|
let t = Math.abs(e.scaleX ?? 1), n = Math.abs(e.scaleY ?? 1);
|
|
15411
15744
|
return {
|
|
15412
15745
|
x: Math.max(1, e.width * t),
|
|
15413
15746
|
y: Math.max(1, e.height * n)
|
|
15414
15747
|
};
|
|
15415
15748
|
}
|
|
15416
|
-
function
|
|
15417
|
-
let i =
|
|
15749
|
+
function su({ target: e, transform: t, scale: n, forceMinimum: r }) {
|
|
15750
|
+
let i = vl({
|
|
15418
15751
|
frame: e,
|
|
15419
15752
|
scaleX: t.original.scaleX,
|
|
15420
15753
|
scaleY: t.original.scaleY
|
|
15421
|
-
}), a = Math.max(
|
|
15754
|
+
}), a = Math.max(Qc / i.width, $c / i.height), o = Math.min(el / i.width, tl / i.height), s = cu({
|
|
15422
15755
|
target: e,
|
|
15423
15756
|
transform: t
|
|
15424
15757
|
}), c = Math.max(a, Math.min(o, s ?? o));
|
|
15425
15758
|
t.cropSourceScaleClamped = !r && n > c, t.cropSourceScalePreserveAspectRatio = t.cropSourceScaleClamped;
|
|
15426
15759
|
let l = a;
|
|
15427
|
-
r || (l =
|
|
15760
|
+
r || (l = yu({
|
|
15428
15761
|
value: n,
|
|
15429
15762
|
min: a,
|
|
15430
15763
|
max: c
|
|
@@ -15438,104 +15771,104 @@ function Nl({ target: e, transform: t, scale: n, forceMinimum: r }) {
|
|
|
15438
15771
|
scaleY: d
|
|
15439
15772
|
};
|
|
15440
15773
|
}
|
|
15441
|
-
function
|
|
15442
|
-
let n =
|
|
15774
|
+
function cu({ target: e, transform: t }) {
|
|
15775
|
+
let n = lu({
|
|
15443
15776
|
target: e,
|
|
15444
15777
|
transform: t
|
|
15445
15778
|
});
|
|
15446
|
-
return n ?
|
|
15779
|
+
return n ? bl({
|
|
15447
15780
|
sourceSize: n.sourceSize,
|
|
15448
15781
|
startRect: n.startRect,
|
|
15449
|
-
anchorX:
|
|
15450
|
-
anchorY:
|
|
15782
|
+
anchorX: du({ transform: t }),
|
|
15783
|
+
anchorY: fu({ transform: t })
|
|
15451
15784
|
}) : null;
|
|
15452
15785
|
}
|
|
15453
|
-
function
|
|
15786
|
+
function lu({ target: e, transform: t }) {
|
|
15454
15787
|
if (t.cropSourceScaleBounds !== void 0) return t.cropSourceScaleBounds;
|
|
15455
15788
|
let n = e;
|
|
15456
15789
|
return n.cropAllowFrameOverflow !== !1 || !n.cropSource ? (t.cropSourceScaleBounds = null, null) : (t.cropSourceScaleBounds = {
|
|
15457
15790
|
sourceSize: Z({ source: n.cropSource }),
|
|
15458
|
-
startRect:
|
|
15791
|
+
startRect: il({
|
|
15459
15792
|
source: n.cropSource,
|
|
15460
15793
|
frame: n
|
|
15461
15794
|
})
|
|
15462
15795
|
}, t.cropSourceScaleBounds);
|
|
15463
15796
|
}
|
|
15464
|
-
function
|
|
15465
|
-
return t === "x" ?
|
|
15797
|
+
function uu({ transform: e, axis: t }) {
|
|
15798
|
+
return t === "x" ? du({ transform: e }) : fu({ transform: e });
|
|
15466
15799
|
}
|
|
15467
|
-
function
|
|
15800
|
+
function du({ transform: e }) {
|
|
15468
15801
|
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";
|
|
15469
15802
|
}
|
|
15470
|
-
function
|
|
15803
|
+
function fu({ transform: e }) {
|
|
15471
15804
|
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";
|
|
15472
15805
|
}
|
|
15473
|
-
function
|
|
15806
|
+
function pu({ target: e }) {
|
|
15474
15807
|
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);
|
|
15475
15808
|
return {
|
|
15476
|
-
minScaleX:
|
|
15477
|
-
maxScaleX:
|
|
15478
|
-
minScaleY:
|
|
15479
|
-
maxScaleY:
|
|
15809
|
+
minScaleX: Qc * n / i,
|
|
15810
|
+
maxScaleX: el * n / i,
|
|
15811
|
+
minScaleY: $c * r / a,
|
|
15812
|
+
maxScaleY: tl * r / a
|
|
15480
15813
|
};
|
|
15481
15814
|
}
|
|
15482
|
-
function
|
|
15815
|
+
function mu({ transform: e, axis: t, localPoint: n }) {
|
|
15483
15816
|
let { target: r } = e;
|
|
15484
15817
|
if (!r.lockScalingFlip) return !1;
|
|
15485
15818
|
let i = t === "x" ? e.signX ?? 1 : e.signY ?? 1, a = t === "x" ? n.x : n.y;
|
|
15486
15819
|
return i !== Math.sign(a || i);
|
|
15487
15820
|
}
|
|
15488
|
-
function
|
|
15489
|
-
return
|
|
15821
|
+
function hu({ transform: e, localPoint: t }) {
|
|
15822
|
+
return mu({
|
|
15490
15823
|
transform: e,
|
|
15491
15824
|
axis: "x",
|
|
15492
15825
|
localPoint: t
|
|
15493
|
-
}) ||
|
|
15826
|
+
}) || mu({
|
|
15494
15827
|
transform: e,
|
|
15495
15828
|
axis: "y",
|
|
15496
15829
|
localPoint: t
|
|
15497
15830
|
});
|
|
15498
15831
|
}
|
|
15499
|
-
function
|
|
15832
|
+
function gu({ eventData: e, target: t }) {
|
|
15500
15833
|
let n = t.preserveAspectRatio ?? !0;
|
|
15501
15834
|
return e.shiftKey ? !n : n;
|
|
15502
15835
|
}
|
|
15503
|
-
function
|
|
15504
|
-
let e = x.wrapWithFireEvent("scaling", x.wrapWithFixedAnchor((e, t, n, r) =>
|
|
15836
|
+
function _u() {
|
|
15837
|
+
let e = x.wrapWithFireEvent("scaling", x.wrapWithFixedAnchor((e, t, n, r) => Fl({
|
|
15505
15838
|
transform: t,
|
|
15506
15839
|
x: n,
|
|
15507
15840
|
y: r
|
|
15508
|
-
}))), t = x.wrapWithFireEvent("scaling", x.wrapWithFixedAnchor((e, t, n, r) =>
|
|
15841
|
+
}))), t = x.wrapWithFireEvent("scaling", x.wrapWithFixedAnchor((e, t, n, r) => Il({
|
|
15509
15842
|
transform: t,
|
|
15510
15843
|
x: n,
|
|
15511
15844
|
y: r
|
|
15512
15845
|
})));
|
|
15513
|
-
return (n, r, i, a) =>
|
|
15846
|
+
return (n, r, i, a) => gu({
|
|
15514
15847
|
eventData: n,
|
|
15515
15848
|
target: r.target
|
|
15516
15849
|
}) ? t(n, r, i, a) : e(n, r, i, a);
|
|
15517
15850
|
}
|
|
15518
|
-
function
|
|
15519
|
-
let t = x.wrapWithFireEvent("scaling", x.wrapWithFixedAnchor((t, n, r, i) =>
|
|
15851
|
+
function vu({ axis: e }) {
|
|
15852
|
+
let t = x.wrapWithFireEvent("scaling", x.wrapWithFixedAnchor((t, n, r, i) => Ll({
|
|
15520
15853
|
transform: n,
|
|
15521
15854
|
axis: e,
|
|
15522
15855
|
x: r,
|
|
15523
15856
|
y: i
|
|
15524
|
-
}))), n = x.wrapWithFireEvent("scaling", x.wrapWithFixedAnchor((t, n, r, i) =>
|
|
15857
|
+
}))), n = x.wrapWithFireEvent("scaling", x.wrapWithFixedAnchor((t, n, r, i) => Rl({
|
|
15525
15858
|
transform: n,
|
|
15526
15859
|
axis: e,
|
|
15527
15860
|
x: r,
|
|
15528
15861
|
y: i
|
|
15529
15862
|
})));
|
|
15530
|
-
return (e, r, i, a) =>
|
|
15863
|
+
return (e, r, i, a) => gu({
|
|
15531
15864
|
eventData: e,
|
|
15532
15865
|
target: r.target
|
|
15533
15866
|
}) ? n(e, r, i, a) : t(e, r, i, a);
|
|
15534
15867
|
}
|
|
15535
|
-
function
|
|
15868
|
+
function yu({ value: e, min: t, max: n }) {
|
|
15536
15869
|
return Math.max(t, Math.min(n, e));
|
|
15537
15870
|
}
|
|
15538
|
-
function
|
|
15871
|
+
function bu({ control: e, actionHandler: t, cursorStyleHandler: n, getActionName: i }) {
|
|
15539
15872
|
let a = {
|
|
15540
15873
|
...e,
|
|
15541
15874
|
actionHandler: t
|
|
@@ -15544,55 +15877,55 @@ function Kl({ control: e, actionHandler: t, cursorStyleHandler: n, getActionName
|
|
|
15544
15877
|
let o = new r(a);
|
|
15545
15878
|
return o.cropResizeControl = !0, o;
|
|
15546
15879
|
}
|
|
15547
|
-
function
|
|
15548
|
-
return
|
|
15880
|
+
function xu({ controlKey: e }) {
|
|
15881
|
+
return Nl[e];
|
|
15549
15882
|
}
|
|
15550
|
-
function
|
|
15883
|
+
function Su({ axis: e }) {
|
|
15551
15884
|
return e === "x" ? "scaleX" : "scaleY";
|
|
15552
15885
|
}
|
|
15553
|
-
function
|
|
15554
|
-
let t = { ...e.controls }, n = !1, r =
|
|
15555
|
-
|
|
15886
|
+
function Cu({ target: e }) {
|
|
15887
|
+
let t = { ...e.controls }, n = !1, r = _u(), i = vu({ axis: "x" }), a = vu({ axis: "y" });
|
|
15888
|
+
jl.forEach((i) => {
|
|
15556
15889
|
let a = e.controls[i];
|
|
15557
|
-
a && (a.cropResizeControl || (t[i] =
|
|
15890
|
+
a && (a.cropResizeControl || (t[i] = bu({
|
|
15558
15891
|
control: a,
|
|
15559
15892
|
actionHandler: r
|
|
15560
15893
|
}), n = !0));
|
|
15561
|
-
}),
|
|
15894
|
+
}), Ml.forEach((r) => {
|
|
15562
15895
|
let o = e.controls[r];
|
|
15563
15896
|
if (!o || o.cropResizeControl) return;
|
|
15564
15897
|
let s = r === "ml" || r === "mr", c = s ? i : a, l = s ? "x" : "y";
|
|
15565
|
-
t[r] =
|
|
15898
|
+
t[r] = bu({
|
|
15566
15899
|
control: o,
|
|
15567
15900
|
actionHandler: c,
|
|
15568
|
-
cursorStyleHandler: () =>
|
|
15569
|
-
getActionName: () =>
|
|
15901
|
+
cursorStyleHandler: () => xu({ controlKey: r }),
|
|
15902
|
+
getActionName: () => Su({ axis: l })
|
|
15570
15903
|
}), n = !0;
|
|
15571
15904
|
}), n && (e.controls = t);
|
|
15572
15905
|
}
|
|
15573
15906
|
//#endregion
|
|
15574
15907
|
//#region src/editor/crop-manager/domain/crop-frame.ts
|
|
15575
|
-
var
|
|
15908
|
+
var wu = "rgba(47, 128, 237, 0.42)", Tu = class extends _ {
|
|
15576
15909
|
constructor(e) {
|
|
15577
15910
|
let { showGrid: t, source: n = null, allowFrameOverflow: r = !0, sourceScaleX: i = 1, sourceScaleY: a = 1, preserveAspectRatio: o = !0, ...s } = e;
|
|
15578
15911
|
super(s), this._showGrid = t, this.cropSource = n, this.cropAllowFrameOverflow = r, this.cropSourceScaleX = i, this.cropSourceScaleY = a, this.preserveAspectRatio = o;
|
|
15579
15912
|
}
|
|
15580
15913
|
_render(e) {
|
|
15581
|
-
super._render(e), this._showGrid &&
|
|
15914
|
+
super._render(e), this._showGrid && Du({
|
|
15582
15915
|
ctx: e,
|
|
15583
15916
|
width: this.width,
|
|
15584
15917
|
height: this.height
|
|
15585
15918
|
});
|
|
15586
15919
|
}
|
|
15587
15920
|
getObjectDisplaySize() {
|
|
15588
|
-
return
|
|
15921
|
+
return vl({ frame: this });
|
|
15589
15922
|
}
|
|
15590
15923
|
getObjectSnappingBounds() {
|
|
15591
|
-
return
|
|
15924
|
+
return ku({ frame: this });
|
|
15592
15925
|
}
|
|
15593
15926
|
};
|
|
15594
|
-
function
|
|
15595
|
-
let a = e.getCenterPoint(), o = e.scaleX ?? 1, s = e.scaleY ?? 1, c = new
|
|
15927
|
+
function Eu({ source: e, cropSize: t, showGrid: n, allowFrameOverflow: r, preserveAspectRatio: i }) {
|
|
15928
|
+
let a = e.getCenterPoint(), o = e.scaleX ?? 1, s = e.scaleY ?? 1, c = new Tu({
|
|
15596
15929
|
id: `crop-frame-${D()}`,
|
|
15597
15930
|
left: a.x,
|
|
15598
15931
|
top: a.y,
|
|
@@ -15624,18 +15957,18 @@ function Ql({ source: e, cropSize: t, showGrid: n, allowFrameOverflow: r, preser
|
|
|
15624
15957
|
sourceScaleX: o,
|
|
15625
15958
|
sourceScaleY: s
|
|
15626
15959
|
});
|
|
15627
|
-
return c.setControlsVisibility({ mtr: !1 }),
|
|
15960
|
+
return c.setControlsVisibility({ mtr: !1 }), Cu({ target: c }), c;
|
|
15628
15961
|
}
|
|
15629
|
-
function
|
|
15962
|
+
function Du({ ctx: e, width: t, height: n }) {
|
|
15630
15963
|
if (!(t <= 0 || n <= 0)) {
|
|
15631
|
-
e.save(), e.strokeStyle =
|
|
15964
|
+
e.save(), e.strokeStyle = wu, e.lineWidth = 1, e.setLineDash([]);
|
|
15632
15965
|
for (let r = 1; r <= 2; r += 1) {
|
|
15633
15966
|
let i = -t / 2 + t * r / 3, a = -n / 2 + n * r / 3;
|
|
15634
|
-
|
|
15967
|
+
Ou({
|
|
15635
15968
|
ctx: e,
|
|
15636
15969
|
x: i,
|
|
15637
15970
|
height: n
|
|
15638
|
-
}),
|
|
15971
|
+
}), ju({
|
|
15639
15972
|
ctx: e,
|
|
15640
15973
|
y: a,
|
|
15641
15974
|
width: t
|
|
@@ -15644,19 +15977,19 @@ function $l({ ctx: e, width: t, height: n }) {
|
|
|
15644
15977
|
e.restore();
|
|
15645
15978
|
}
|
|
15646
15979
|
}
|
|
15647
|
-
function
|
|
15980
|
+
function Ou({ ctx: e, x: t, height: n }) {
|
|
15648
15981
|
e.beginPath(), e.moveTo(t, -n / 2), e.lineTo(t, n / 2), e.stroke();
|
|
15649
15982
|
}
|
|
15650
|
-
function
|
|
15983
|
+
function ku({ frame: e }) {
|
|
15651
15984
|
let t = e.calcTransformMatrix(), n = e.width / 2, r = e.height / 2;
|
|
15652
|
-
return
|
|
15985
|
+
return Au({ points: [
|
|
15653
15986
|
new m(-n, -r),
|
|
15654
15987
|
new m(n, -r),
|
|
15655
15988
|
new m(n, r),
|
|
15656
15989
|
new m(-n, r)
|
|
15657
15990
|
].map((e) => e.transform(t)) });
|
|
15658
15991
|
}
|
|
15659
|
-
function
|
|
15992
|
+
function Au({ points: e }) {
|
|
15660
15993
|
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));
|
|
15661
15994
|
return {
|
|
15662
15995
|
left: t,
|
|
@@ -15667,18 +16000,18 @@ function nu({ points: e }) {
|
|
|
15667
16000
|
centerY: r + (i - r) / 2
|
|
15668
16001
|
};
|
|
15669
16002
|
}
|
|
15670
|
-
function
|
|
16003
|
+
function ju({ ctx: e, y: t, width: n }) {
|
|
15671
16004
|
e.beginPath(), e.moveTo(-n / 2, t), e.lineTo(n / 2, t), e.stroke();
|
|
15672
16005
|
}
|
|
15673
16006
|
//#endregion
|
|
15674
16007
|
//#region src/editor/crop-manager/domain/crop-result.ts
|
|
15675
|
-
function
|
|
15676
|
-
return e.mode === "canvas" ?
|
|
16008
|
+
function Mu({ session: e }) {
|
|
16009
|
+
return e.mode === "canvas" ? Fu({ session: e }) : Iu({
|
|
15677
16010
|
target: e.target,
|
|
15678
16011
|
frame: e.frame
|
|
15679
16012
|
});
|
|
15680
16013
|
}
|
|
15681
|
-
function
|
|
16014
|
+
function Nu({ rect: e }) {
|
|
15682
16015
|
return {
|
|
15683
16016
|
left: Math.round(e.left),
|
|
15684
16017
|
top: Math.round(e.top),
|
|
@@ -15686,11 +16019,11 @@ function au({ rect: e }) {
|
|
|
15686
16019
|
height: Math.round(e.height)
|
|
15687
16020
|
};
|
|
15688
16021
|
}
|
|
15689
|
-
function
|
|
15690
|
-
return e.width >=
|
|
16022
|
+
function Pu({ rect: e }) {
|
|
16023
|
+
return e.width >= nl && e.height >= nl;
|
|
15691
16024
|
}
|
|
15692
|
-
function
|
|
15693
|
-
let t =
|
|
16025
|
+
function Fu({ session: e }) {
|
|
16026
|
+
let t = il({
|
|
15694
16027
|
source: e.source,
|
|
15695
16028
|
frame: e.frame
|
|
15696
16029
|
}), n = Z({ source: e.source });
|
|
@@ -15701,8 +16034,8 @@ function su({ session: e }) {
|
|
|
15701
16034
|
height: t.height
|
|
15702
16035
|
};
|
|
15703
16036
|
}
|
|
15704
|
-
function
|
|
15705
|
-
let n =
|
|
16037
|
+
function Iu({ target: e, frame: t }) {
|
|
16038
|
+
let n = il({
|
|
15706
16039
|
source: e,
|
|
15707
16040
|
frame: t
|
|
15708
16041
|
}), r = -e.width / 2, i = -e.height / 2;
|
|
@@ -15715,8 +16048,8 @@ function cu({ target: e, frame: t }) {
|
|
|
15715
16048
|
}
|
|
15716
16049
|
//#endregion
|
|
15717
16050
|
//#region src/editor/crop-manager/mutation/crop-apply.ts
|
|
15718
|
-
function
|
|
15719
|
-
return
|
|
16051
|
+
function Lu({ editor: e, frame: t, rect: n }) {
|
|
16052
|
+
return Pu({ rect: n }) ? (Gu({
|
|
15720
16053
|
editor: e,
|
|
15721
16054
|
frame: t,
|
|
15722
16055
|
offset: new m(-n.left, -n.top)
|
|
@@ -15726,9 +16059,9 @@ function lu({ editor: e, frame: t, rect: n }) {
|
|
|
15726
16059
|
rect: n
|
|
15727
16060
|
}) : null;
|
|
15728
16061
|
}
|
|
15729
|
-
function
|
|
15730
|
-
if (!
|
|
15731
|
-
let i =
|
|
16062
|
+
function Ru({ editor: e, target: t, frame: n, rect: r }) {
|
|
16063
|
+
if (!Pu({ rect: r })) return null;
|
|
16064
|
+
let i = zu({
|
|
15732
16065
|
target: t,
|
|
15733
16066
|
frame: n,
|
|
15734
16067
|
rect: r
|
|
@@ -15739,21 +16072,21 @@ function uu({ editor: e, target: t, frame: n, rect: r }) {
|
|
|
15739
16072
|
rect: i
|
|
15740
16073
|
}) : null;
|
|
15741
16074
|
}
|
|
15742
|
-
function
|
|
15743
|
-
let r = Math.max(
|
|
16075
|
+
function zu({ target: e, frame: t, rect: n }) {
|
|
16076
|
+
let r = Math.max(nl, n.width), i = Math.max(nl, n.height), a = {
|
|
15744
16077
|
width: r,
|
|
15745
16078
|
height: i
|
|
15746
16079
|
};
|
|
15747
|
-
if (
|
|
16080
|
+
if (Bu({
|
|
15748
16081
|
target: e,
|
|
15749
16082
|
rect: n
|
|
15750
|
-
}))
|
|
16083
|
+
})) Vu({
|
|
15751
16084
|
target: e,
|
|
15752
16085
|
size: a,
|
|
15753
16086
|
rect: n
|
|
15754
16087
|
});
|
|
15755
16088
|
else {
|
|
15756
|
-
let t =
|
|
16089
|
+
let t = Hu({
|
|
15757
16090
|
target: e,
|
|
15758
16091
|
size: a,
|
|
15759
16092
|
rect: n
|
|
@@ -15773,10 +16106,10 @@ function du({ target: e, frame: t, rect: n }) {
|
|
|
15773
16106
|
height: i
|
|
15774
16107
|
};
|
|
15775
16108
|
}
|
|
15776
|
-
function
|
|
16109
|
+
function Bu({ target: e, rect: t }) {
|
|
15777
16110
|
return t.left >= 0 && t.top >= 0 && t.left + t.width <= e.width && t.top + t.height <= e.height;
|
|
15778
16111
|
}
|
|
15779
|
-
function
|
|
16112
|
+
function Vu({ target: e, size: t, rect: n }) {
|
|
15780
16113
|
let r = (e.cropX ?? 0) + n.left, i = (e.cropY ?? 0) + n.top;
|
|
15781
16114
|
e.set({
|
|
15782
16115
|
cropX: r,
|
|
@@ -15785,25 +16118,25 @@ function pu({ target: e, size: t, rect: n }) {
|
|
|
15785
16118
|
height: t.height
|
|
15786
16119
|
});
|
|
15787
16120
|
}
|
|
15788
|
-
function
|
|
15789
|
-
let r = e.getElement(), i =
|
|
16121
|
+
function Hu({ target: e, size: t, rect: n }) {
|
|
16122
|
+
let r = e.getElement(), i = Uu({ target: e });
|
|
15790
16123
|
if (!r || !i) return null;
|
|
15791
16124
|
let a = i.createElement("canvas");
|
|
15792
16125
|
a.width = Math.round(t.width), a.height = Math.round(t.height);
|
|
15793
16126
|
let o = a.getContext("2d");
|
|
15794
16127
|
if (!o) return null;
|
|
15795
|
-
let s =
|
|
16128
|
+
let s = Wu({
|
|
15796
16129
|
target: e,
|
|
15797
16130
|
size: t,
|
|
15798
16131
|
rect: n
|
|
15799
16132
|
});
|
|
15800
16133
|
return s && o.drawImage(r, s.sourceX, s.sourceY, s.sourceWidth, s.sourceHeight, s.destinationX, s.destinationY, s.sourceWidth, s.sourceHeight), a;
|
|
15801
16134
|
}
|
|
15802
|
-
function
|
|
16135
|
+
function Uu({ target: e }) {
|
|
15803
16136
|
let t = e.canvas?.getElement();
|
|
15804
16137
|
return t?.ownerDocument ? t.ownerDocument : typeof document < "u" ? document : null;
|
|
15805
16138
|
}
|
|
15806
|
-
function
|
|
16139
|
+
function Wu({ target: e, size: t, rect: n }) {
|
|
15807
16140
|
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;
|
|
15808
16141
|
return s <= 0 || c <= 0 ? null : {
|
|
15809
16142
|
sourceX: (e.cropX ?? 0) + r,
|
|
@@ -15814,7 +16147,7 @@ function gu({ target: e, size: t, rect: n }) {
|
|
|
15814
16147
|
destinationY: i - n.top
|
|
15815
16148
|
};
|
|
15816
16149
|
}
|
|
15817
|
-
function
|
|
16150
|
+
function Gu({ editor: e, frame: t, offset: n }) {
|
|
15818
16151
|
e.canvasManager.getObjects().forEach((e) => {
|
|
15819
16152
|
e !== t && (e.set({
|
|
15820
16153
|
left: (e.left ?? 0) + n.x,
|
|
@@ -15824,12 +16157,12 @@ function _u({ editor: e, frame: t, offset: n }) {
|
|
|
15824
16157
|
}
|
|
15825
16158
|
//#endregion
|
|
15826
16159
|
//#region src/editor/crop-manager/index.ts
|
|
15827
|
-
var
|
|
16160
|
+
var Ku = {
|
|
15828
16161
|
allowFrameOverflow: !0,
|
|
15829
16162
|
showGrid: !0,
|
|
15830
16163
|
cancelOnSelectionClear: !0,
|
|
15831
16164
|
preserveAspectRatio: !0
|
|
15832
|
-
},
|
|
16165
|
+
}, qu = .5, Ju = class {
|
|
15833
16166
|
constructor({ editor: e }) {
|
|
15834
16167
|
this._handleCropFrameChanged = (e) => {
|
|
15835
16168
|
let { _session: t } = this;
|
|
@@ -15868,16 +16201,16 @@ var vu = {
|
|
|
15868
16201
|
frame: e.frame,
|
|
15869
16202
|
options: e.options,
|
|
15870
16203
|
target: e.target,
|
|
15871
|
-
rect:
|
|
16204
|
+
rect: Mu({ session: e })
|
|
15872
16205
|
} : null;
|
|
15873
16206
|
}
|
|
15874
16207
|
isFrameOverflowingSource({ target: e }) {
|
|
15875
16208
|
let { _session: t } = this;
|
|
15876
16209
|
if (!t || !e || t.options.allowFrameOverflow || t.frame !== e) return !1;
|
|
15877
|
-
let n =
|
|
16210
|
+
let n = il({
|
|
15878
16211
|
source: t.source,
|
|
15879
16212
|
frame: t.frame
|
|
15880
|
-
}), r = Z({ source: t.source }), i = -r.width / 2 -
|
|
16213
|
+
}), r = Z({ source: t.source }), i = -r.width / 2 - qu, a = -r.height / 2 - qu, o = r.width / 2 + qu, s = r.height / 2 + qu;
|
|
15881
16214
|
return n.left < i || n.top < a || n.left + n.width > o || n.top + n.height > s;
|
|
15882
16215
|
}
|
|
15883
16216
|
isFrameSourceScaleClamped({ target: e, transform: t }) {
|
|
@@ -15906,7 +16239,7 @@ var vu = {
|
|
|
15906
16239
|
setAspectRatio({ aspectRatio: e }) {
|
|
15907
16240
|
let { _session: t } = this;
|
|
15908
16241
|
if (!t) return null;
|
|
15909
|
-
let n =
|
|
16242
|
+
let n = rl({
|
|
15910
16243
|
sourceSize: Z({ source: t.source }),
|
|
15911
16244
|
aspectRatio: e ?? void 0,
|
|
15912
16245
|
allowOverflow: t.options.allowFrameOverflow
|
|
@@ -15919,7 +16252,7 @@ var vu = {
|
|
|
15919
16252
|
setSize({ size: e }) {
|
|
15920
16253
|
let { _session: t } = this;
|
|
15921
16254
|
if (!t) return null;
|
|
15922
|
-
let n =
|
|
16255
|
+
let n = rl({
|
|
15923
16256
|
sourceSize: Z({ source: t.source }),
|
|
15924
16257
|
size: e,
|
|
15925
16258
|
allowOverflow: t.options.allowFrameOverflow
|
|
@@ -15997,16 +16330,16 @@ var vu = {
|
|
|
15997
16330
|
}
|
|
15998
16331
|
_resolveSessionOptions({ options: e }) {
|
|
15999
16332
|
return {
|
|
16000
|
-
allowFrameOverflow: e.allowFrameOverflow ??
|
|
16001
|
-
showGrid: e.showGrid ??
|
|
16002
|
-
cancelOnSelectionClear: e.cancelOnSelectionClear ??
|
|
16003
|
-
preserveAspectRatio: e.preserveAspectRatio ??
|
|
16333
|
+
allowFrameOverflow: e.allowFrameOverflow ?? Ku.allowFrameOverflow,
|
|
16334
|
+
showGrid: e.showGrid ?? Ku.showGrid,
|
|
16335
|
+
cancelOnSelectionClear: e.cancelOnSelectionClear ?? Ku.cancelOnSelectionClear,
|
|
16336
|
+
preserveAspectRatio: e.preserveAspectRatio ?? Ku.preserveAspectRatio
|
|
16004
16337
|
};
|
|
16005
16338
|
}
|
|
16006
16339
|
_createCropFrameForSource({ source: e, options: t, sessionOptions: n }) {
|
|
16007
|
-
return
|
|
16340
|
+
return Eu({
|
|
16008
16341
|
source: e,
|
|
16009
|
-
cropSize:
|
|
16342
|
+
cropSize: rl({
|
|
16010
16343
|
sourceSize: Z({ source: e }),
|
|
16011
16344
|
size: t.size,
|
|
16012
16345
|
aspectRatio: t.aspectRatio,
|
|
@@ -16018,7 +16351,7 @@ var vu = {
|
|
|
16018
16351
|
});
|
|
16019
16352
|
}
|
|
16020
16353
|
_setFramePreserveAspectRatio({ frame: e, preserveAspectRatio: t }) {
|
|
16021
|
-
if (!(e instanceof
|
|
16354
|
+
if (!(e instanceof Tu)) throw Error("Crop session frame должен быть CropFrame");
|
|
16022
16355
|
e.preserveAspectRatio = t;
|
|
16023
16356
|
}
|
|
16024
16357
|
_activateSession({ session: e }) {
|
|
@@ -16126,25 +16459,25 @@ var vu = {
|
|
|
16126
16459
|
_clampFrameIfNeeded({ session: e, preserveAspectRatio: t = !1 }) {
|
|
16127
16460
|
if (!e.options.allowFrameOverflow) {
|
|
16128
16461
|
if (t) {
|
|
16129
|
-
|
|
16462
|
+
ol({
|
|
16130
16463
|
source: e.source,
|
|
16131
16464
|
frame: e.frame
|
|
16132
16465
|
});
|
|
16133
16466
|
return;
|
|
16134
16467
|
}
|
|
16135
|
-
|
|
16468
|
+
al({
|
|
16136
16469
|
source: e.source,
|
|
16137
16470
|
frame: e.frame
|
|
16138
16471
|
});
|
|
16139
16472
|
}
|
|
16140
16473
|
}
|
|
16141
16474
|
_applySessionCrop({ session: e }) {
|
|
16142
|
-
let t =
|
|
16143
|
-
return e.mode === "canvas" ?
|
|
16475
|
+
let t = Nu({ rect: Mu({ session: e }) });
|
|
16476
|
+
return e.mode === "canvas" ? Lu({
|
|
16144
16477
|
editor: this.editor,
|
|
16145
16478
|
frame: e.frame,
|
|
16146
16479
|
rect: t
|
|
16147
|
-
}) :
|
|
16480
|
+
}) : Ru({
|
|
16148
16481
|
editor: this.editor,
|
|
16149
16482
|
target: e.target,
|
|
16150
16483
|
frame: e.frame,
|
|
@@ -16212,13 +16545,13 @@ var vu = {
|
|
|
16212
16545
|
}
|
|
16213
16546
|
});
|
|
16214
16547
|
}
|
|
16215
|
-
},
|
|
16548
|
+
}, Yu = class e {
|
|
16216
16549
|
constructor(e, t) {
|
|
16217
16550
|
this.options = t, this.containerId = e, this.editorId = `${e}-${D()}`, this.init();
|
|
16218
16551
|
}
|
|
16219
16552
|
async init() {
|
|
16220
16553
|
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;
|
|
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
|
|
16554
|
+
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 Yc({ editor: this }), this.measurementManager = new Zc({ editor: this }), this.fontManager = new ye(this.options.fonts ?? []), this.textManager = new _o({ editor: this }), this.templateManager = new So({ editor: this }), this.cropManager = new Ju({ 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({
|
|
16222
16555
|
editor: this,
|
|
16223
16556
|
options: this.options
|
|
16224
16557
|
}), 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) {
|
|
@@ -16326,7 +16659,7 @@ var vu = {
|
|
|
16326
16659
|
"U+A640-A69F",
|
|
16327
16660
|
"U+FE2E-FE2F",
|
|
16328
16661
|
"U+2116"
|
|
16329
|
-
].join(", "),
|
|
16662
|
+
].join(", "), Xu = {
|
|
16330
16663
|
preserveObjectStacking: !0,
|
|
16331
16664
|
controlsAboveOverlay: !0,
|
|
16332
16665
|
centeredRotation: !0,
|
|
@@ -17184,20 +17517,20 @@ var vu = {
|
|
|
17184
17517
|
};
|
|
17185
17518
|
//#endregion
|
|
17186
17519
|
//#region src/main.ts
|
|
17187
|
-
function
|
|
17520
|
+
function Zu(e, t = {}) {
|
|
17188
17521
|
let n = {
|
|
17189
|
-
...
|
|
17522
|
+
...Xu,
|
|
17190
17523
|
...t
|
|
17191
17524
|
}, r = document.getElementById(e);
|
|
17192
17525
|
if (!r) return Promise.reject(/* @__PURE__ */ Error(`Контейнер с ID "${e}" не найден.`));
|
|
17193
17526
|
let i = document.createElement("canvas");
|
|
17194
17527
|
return i.id = `${e}-canvas`, r.appendChild(i), n.editorContainer = r, new Promise((t) => {
|
|
17195
17528
|
n._onReadyCallback = t;
|
|
17196
|
-
let r = new
|
|
17529
|
+
let r = new Yu(i.id, n);
|
|
17197
17530
|
window[e] = r;
|
|
17198
17531
|
});
|
|
17199
17532
|
}
|
|
17200
17533
|
//#endregion
|
|
17201
|
-
export {
|
|
17534
|
+
export { Zu as default };
|
|
17202
17535
|
|
|
17203
17536
|
//# sourceMappingURL=main.js.map
|