@anu3ev/fabric-image-editor 0.7.2 → 0.7.3
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 +294 -289
- package/dist/stats.html +1 -1
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -801,12 +801,12 @@ var re = {
|
|
|
801
801
|
"pointer-events": "none",
|
|
802
802
|
"white-space": "nowrap",
|
|
803
803
|
"box-shadow": "0 2px 8px rgba(0, 0, 0, 0.2)"
|
|
804
|
-
},
|
|
804
|
+
}, H = "fabric-editor-angle-indicator", U = class e {
|
|
805
805
|
constructor({ editor: e }) {
|
|
806
806
|
this.isActive = !1, this.currentAngle = 0, this.editor = e, this.canvas = e.canvas, this.options = e.options, this._createDOM(), this._bindEvents();
|
|
807
807
|
}
|
|
808
808
|
_createDOM() {
|
|
809
|
-
this.el = document.createElement("div"), this.el.className =
|
|
809
|
+
this.el = document.createElement("div"), this.el.className = H, Object.entries(V).forEach(([e, t]) => {
|
|
810
810
|
this.el.style.setProperty(e, t);
|
|
811
811
|
}), this.canvas.wrapperEl.appendChild(this.el);
|
|
812
812
|
}
|
|
@@ -851,44 +851,44 @@ var re = {
|
|
|
851
851
|
destroy() {
|
|
852
852
|
this.canvas && (this.canvas.off("object:rotating", this._onObjectRotating), this.canvas.off("mouse:up", this._onMouseUp), this.canvas.off("object:modified", this._onObjectModified), this.canvas.off("selection:cleared", this._onSelectionCleared)), this.el?.parentNode && this.el.parentNode.removeChild(this.el), this.el = null, this.editor = null, this.canvas = null, this.options = null;
|
|
853
853
|
}
|
|
854
|
-
},
|
|
854
|
+
}, oe = /* @__PURE__ */ "id.backgroundId.customData.backgroundType.format.contentType.width.height.originX.originY.locked.editable.evented.selectable.lockMovementX.lockMovementY.lockRotation.lockScalingX.lockScalingY.lockSkewingX.lockSkewingY.styles.lineFontDefaults.textCaseRaw.uppercase.autoExpand.linethrough.underline.fontStyle.fontWeight.backgroundOpacity.paddingTop.paddingRight.paddingBottom.paddingLeft.radiusTopLeft.radiusTopRight.radiusBottomRight.radiusBottomLeft.shapeComposite.shapePresetKey.shapeBaseWidth.shapeBaseHeight.shapeManualBaseWidth.shapeManualBaseHeight.shapeTextAutoExpand.shapeAlignHorizontal.shapeAlignVertical.shapePaddingTop.shapePaddingRight.shapePaddingBottom.shapePaddingLeft.shapeFill.shapeStroke.shapeStrokeWidth.shapeStrokeDashArray.shapeOpacity.shapeRounding.shapeNodeType".split(".");
|
|
855
855
|
//#endregion
|
|
856
856
|
//#region src/editor/history-manager/diff-normalization.ts
|
|
857
|
-
function
|
|
857
|
+
function se({ state: e }) {
|
|
858
858
|
return JSON.parse(JSON.stringify(e));
|
|
859
859
|
}
|
|
860
|
-
function
|
|
860
|
+
function ce({ value: e }) {
|
|
861
861
|
if (Array.isArray(e)) {
|
|
862
862
|
let t = [];
|
|
863
|
-
for (let n = 0; n < e.length; n += 1) t.push(
|
|
863
|
+
for (let n = 0; n < e.length; n += 1) t.push(ce({ value: e[n] }));
|
|
864
864
|
return t;
|
|
865
865
|
}
|
|
866
866
|
if (e && typeof e == "object") {
|
|
867
867
|
let t = {}, n = Object.keys(e).sort();
|
|
868
868
|
for (let r = 0; r < n.length; r += 1) {
|
|
869
869
|
let i = n[r];
|
|
870
|
-
t[i] =
|
|
870
|
+
t[i] = ce({ value: e[i] });
|
|
871
871
|
}
|
|
872
872
|
return t;
|
|
873
873
|
}
|
|
874
874
|
return e;
|
|
875
875
|
}
|
|
876
|
-
function
|
|
877
|
-
let t =
|
|
876
|
+
function le({ value: e }) {
|
|
877
|
+
let t = ce({ value: e });
|
|
878
878
|
return JSON.stringify(t);
|
|
879
879
|
}
|
|
880
|
-
function
|
|
881
|
-
return
|
|
880
|
+
function ue({ prevState: e, nextState: t }) {
|
|
881
|
+
return le({ value: e }) === le({ value: t });
|
|
882
882
|
}
|
|
883
|
-
function
|
|
883
|
+
function de({ objects: e, id: t }) {
|
|
884
884
|
for (let n = 0; n < e.length; n += 1) {
|
|
885
885
|
let r = e[n];
|
|
886
886
|
if (r.id === t) return r;
|
|
887
887
|
}
|
|
888
888
|
return null;
|
|
889
889
|
}
|
|
890
|
-
function
|
|
891
|
-
let t =
|
|
890
|
+
function fe({ objects: e }) {
|
|
891
|
+
let t = de({
|
|
892
892
|
objects: e,
|
|
893
893
|
id: "montage-area"
|
|
894
894
|
});
|
|
@@ -902,7 +902,7 @@ function pe({ objects: e }) {
|
|
|
902
902
|
height: r
|
|
903
903
|
};
|
|
904
904
|
}
|
|
905
|
-
function
|
|
905
|
+
function pe({ objects: e }) {
|
|
906
906
|
let t = [], n = [...e];
|
|
907
907
|
for (let e = 0; e < n.length; e += 1) {
|
|
908
908
|
let r = n[e];
|
|
@@ -912,20 +912,20 @@ function me({ objects: e }) {
|
|
|
912
912
|
}
|
|
913
913
|
return t;
|
|
914
914
|
}
|
|
915
|
-
function
|
|
916
|
-
let t =
|
|
915
|
+
function me({ objects: e }) {
|
|
916
|
+
let t = pe({ objects: e });
|
|
917
917
|
for (let e = 0; e < t.length; e += 1) {
|
|
918
918
|
let n = t[e], { type: r, backgroundOpacity: i, backgroundColor: a, textBackgroundColor: o } = n, s = typeof i == "number" ? i : 0, c = typeof a == "string" ? a : "", l = typeof o == "string" ? o : "", u = r === "textbox" || r === "background-textbox", d = c.length > 0 || l.length > 0;
|
|
919
919
|
u && (s > 0 && d || (n.backgroundColor = null, n.textBackgroundColor = null));
|
|
920
920
|
}
|
|
921
921
|
}
|
|
922
|
-
function
|
|
923
|
-
let { width: n, height: r, objects: i } = e, { objects: a } = t, { width: o, height: s } =
|
|
922
|
+
function he({ prevState: e, nextState: t }) {
|
|
923
|
+
let { width: n, height: r, objects: i } = e, { objects: a } = t, { width: o, height: s } = fe({ objects: i }), { width: c, height: l } = fe({ objects: a });
|
|
924
924
|
o !== c || s !== l || (t.width = n, t.height = r);
|
|
925
925
|
}
|
|
926
|
-
function
|
|
927
|
-
let n =
|
|
928
|
-
return
|
|
926
|
+
function ge({ prevState: e, nextState: t }) {
|
|
927
|
+
let n = se({ state: e }), r = se({ state: t });
|
|
928
|
+
return me({ objects: n.objects }), me({ objects: r.objects }), he({
|
|
929
929
|
prevState: n,
|
|
930
930
|
nextState: r
|
|
931
931
|
}), {
|
|
@@ -935,10 +935,10 @@ function _e({ prevState: e, nextState: t }) {
|
|
|
935
935
|
}
|
|
936
936
|
//#endregion
|
|
937
937
|
//#region src/editor/history-manager/load-state.ts
|
|
938
|
-
function
|
|
938
|
+
function _e({ customData: e }) {
|
|
939
939
|
return JSON.parse(JSON.stringify(e));
|
|
940
940
|
}
|
|
941
|
-
function
|
|
941
|
+
function ve({ state: e }) {
|
|
942
942
|
let t = JSON.parse(JSON.stringify(e)), n = (t.objects ?? []).filter((e) => e.id !== "overlay-mask");
|
|
943
943
|
t.objects = n;
|
|
944
944
|
for (let e = 0; e < n.length; e += 1) {
|
|
@@ -947,7 +947,7 @@ function ye({ state: e }) {
|
|
|
947
947
|
}
|
|
948
948
|
return t;
|
|
949
949
|
}
|
|
950
|
-
function
|
|
950
|
+
function ye({ state: e, canvas: t }) {
|
|
951
951
|
let { objects: n = [] } = e, r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
|
|
952
952
|
for (let e = 0; e < n.length; e += 1) {
|
|
953
953
|
let { customData: t, id: a } = n[e];
|
|
@@ -962,23 +962,23 @@ function be({ state: e, canvas: t }) {
|
|
|
962
962
|
let a = t.getObjects?.() ?? [];
|
|
963
963
|
for (let e = 0; e < a.length; e += 1) {
|
|
964
964
|
let t = a[e], { id: n } = t, o;
|
|
965
|
-
typeof n == "string" && (o = r.get(n)), o ||= i.get(e), o && (t.customData =
|
|
965
|
+
typeof n == "string" && (o = r.get(n)), o ||= i.get(e), o && (t.customData = _e({ customData: o }));
|
|
966
966
|
}
|
|
967
967
|
}
|
|
968
968
|
//#endregion
|
|
969
969
|
//#region src/editor/history-manager/snapshot-interactivity.ts
|
|
970
|
-
function
|
|
970
|
+
function be({ object: e }) {
|
|
971
971
|
return typeof e.getObjects == "function" ? e.getObjects() : [];
|
|
972
972
|
}
|
|
973
|
-
function
|
|
973
|
+
function xe({ objects: e }) {
|
|
974
974
|
for (let t = 0; t < e.length; t += 1) if (e[t].isEditing) return !0;
|
|
975
975
|
return !1;
|
|
976
976
|
}
|
|
977
|
-
function
|
|
977
|
+
function Se({ object: e }) {
|
|
978
978
|
let t = typeof e.type == "string" ? e.type.toLowerCase() : "";
|
|
979
979
|
return t === "textbox" || t === "background-textbox" || typeof e.isEditing == "boolean";
|
|
980
980
|
}
|
|
981
|
-
function
|
|
981
|
+
function Ce({ object: e, withEvented: t = !1 }) {
|
|
982
982
|
let n = {
|
|
983
983
|
object: e,
|
|
984
984
|
lockMovementX: e.lockMovementX,
|
|
@@ -987,66 +987,66 @@ function we({ object: e, withEvented: t = !1 }) {
|
|
|
987
987
|
};
|
|
988
988
|
return t && (n.evented = e.evented), n;
|
|
989
989
|
}
|
|
990
|
-
function
|
|
991
|
-
return e.shapeComposite !== !0 || !
|
|
990
|
+
function we({ object: e, snapshotStates: t }) {
|
|
991
|
+
return e.shapeComposite !== !0 || !xe({ objects: be({ object: e }) }) ? !1 : (t.push(Ce({ object: e })), e.lockMovementX = !1, e.lockMovementY = !1, e.selectable = !0, !0);
|
|
992
992
|
}
|
|
993
|
-
function
|
|
994
|
-
if (!
|
|
993
|
+
function Te({ object: e, snapshotStates: t }) {
|
|
994
|
+
if (!Se({ object: e })) return !1;
|
|
995
995
|
let n = e.group, { isEditing: r } = e, i = n?.shapeComposite === !0, a = !!n?.locked;
|
|
996
|
-
return !i || a || !r ? !1 : (t.push(
|
|
996
|
+
return !i || a || !r ? !1 : (t.push(Ce({
|
|
997
997
|
object: e,
|
|
998
998
|
withEvented: !0
|
|
999
999
|
})), e.lockMovementX = !1, e.lockMovementY = !1, e.selectable = !1, e.evented = !1, !0);
|
|
1000
1000
|
}
|
|
1001
|
-
function
|
|
1002
|
-
if (!
|
|
1001
|
+
function Ee({ object: e, snapshotStates: t }) {
|
|
1002
|
+
if (!Se({ object: e })) return !1;
|
|
1003
1003
|
let n = !!e.lockMovementX, r = !!e.lockMovementY;
|
|
1004
|
-
return !n && !r ? !1 : (t.push(
|
|
1004
|
+
return !n && !r ? !1 : (t.push(Ce({ object: e })), e.lockMovementX = !1, e.lockMovementY = !1, e.selectable = !0, !0);
|
|
1005
1005
|
}
|
|
1006
|
-
function
|
|
1006
|
+
function De({ objects: e }) {
|
|
1007
1007
|
let t = [];
|
|
1008
1008
|
for (let n = 0; n < e.length; n += 1) {
|
|
1009
1009
|
let r = e[n];
|
|
1010
|
-
r.locked ||
|
|
1010
|
+
r.locked || we({
|
|
1011
1011
|
object: r,
|
|
1012
1012
|
snapshotStates: t
|
|
1013
|
-
}) ||
|
|
1013
|
+
}) || Te({
|
|
1014
1014
|
object: r,
|
|
1015
1015
|
snapshotStates: t
|
|
1016
|
-
}) ||
|
|
1016
|
+
}) || Ee({
|
|
1017
1017
|
object: r,
|
|
1018
1018
|
snapshotStates: t
|
|
1019
1019
|
});
|
|
1020
1020
|
}
|
|
1021
1021
|
return t;
|
|
1022
1022
|
}
|
|
1023
|
-
function
|
|
1023
|
+
function Oe({ canvas: e }) {
|
|
1024
1024
|
let t = [...e.getObjects?.() ?? []], n = [];
|
|
1025
1025
|
for (let e = 0; e < t.length; e += 1) {
|
|
1026
1026
|
let r = t[e];
|
|
1027
1027
|
n.push(r);
|
|
1028
|
-
let i =
|
|
1028
|
+
let i = be({ object: r });
|
|
1029
1029
|
for (let e = 0; e < i.length; e += 1) t.push(i[e]);
|
|
1030
1030
|
}
|
|
1031
1031
|
return n;
|
|
1032
1032
|
}
|
|
1033
|
-
function
|
|
1033
|
+
function ke({ snapshotStates: e }) {
|
|
1034
1034
|
for (let t = 0; t < e.length; t += 1) {
|
|
1035
1035
|
let { object: n, lockMovementX: r, lockMovementY: i, selectable: a, evented: o } = e[t];
|
|
1036
1036
|
n.lockMovementX = r, n.lockMovementY = i, n.selectable = a, o !== void 0 && (n.evented = o);
|
|
1037
1037
|
}
|
|
1038
1038
|
}
|
|
1039
|
-
function
|
|
1040
|
-
let n =
|
|
1039
|
+
function Ae({ canvas: e, callback: t }) {
|
|
1040
|
+
let n = De({ objects: Oe({ canvas: e }) });
|
|
1041
1041
|
try {
|
|
1042
1042
|
return t();
|
|
1043
1043
|
} finally {
|
|
1044
|
-
|
|
1044
|
+
ke({ snapshotStates: n });
|
|
1045
1045
|
}
|
|
1046
1046
|
}
|
|
1047
1047
|
//#endregion
|
|
1048
1048
|
//#region src/editor/history-manager/index.ts
|
|
1049
|
-
var
|
|
1049
|
+
var je = class {
|
|
1050
1050
|
constructor({ editor: e }) {
|
|
1051
1051
|
this.editor = e, this.canvas = e.canvas, this._isSavingState = !1, this._historySuspendCount = 0, this._isActionInProgress = !1, this._actionSnapshot = null, this._actionReason = null, this._pendingSaveTimeoutId = null, this._pendingSaveReason = null, this._hasDeferredSaveAfterUnblock = !1, this.baseState = null, this.patches = [], this.currentIndex = 0, this.maxHistoryLength = e.options.maxHistoryLength, this.totalChangesCount = 0, this.baseStateChangesCount = 0, this._createDiffPatcher();
|
|
1052
1052
|
}
|
|
@@ -1113,14 +1113,14 @@ var Me = class {
|
|
|
1113
1113
|
return console.log("getFullState state", r), r;
|
|
1114
1114
|
}
|
|
1115
1115
|
_captureCurrentState() {
|
|
1116
|
-
return
|
|
1116
|
+
return Ae({
|
|
1117
1117
|
canvas: this.canvas,
|
|
1118
1118
|
callback: () => this._serializeCanvasState()
|
|
1119
1119
|
});
|
|
1120
1120
|
}
|
|
1121
1121
|
_serializeCanvasState() {
|
|
1122
1122
|
let { canvas: e } = this;
|
|
1123
|
-
return e.toDatalessObject([...
|
|
1123
|
+
return e.toDatalessObject([...oe]);
|
|
1124
1124
|
}
|
|
1125
1125
|
_handlePendingSaveTimeout() {
|
|
1126
1126
|
if (this._pendingSaveTimeoutId === null) return;
|
|
@@ -1160,15 +1160,15 @@ var Me = class {
|
|
|
1160
1160
|
}
|
|
1161
1161
|
this._isSavingState = !0, console.time("saveState");
|
|
1162
1162
|
try {
|
|
1163
|
-
let e =
|
|
1163
|
+
let e = Ae({
|
|
1164
1164
|
canvas: this.canvas,
|
|
1165
|
-
callback: () => this.canvas.toDatalessObject([...
|
|
1165
|
+
callback: () => this.canvas.toDatalessObject([...oe])
|
|
1166
1166
|
});
|
|
1167
1167
|
if (console.timeEnd("saveState"), !this.baseState) {
|
|
1168
1168
|
this.baseState = e, this.patches = [], this.currentIndex = 0, console.log("Базовое состояние сохранено.");
|
|
1169
1169
|
return;
|
|
1170
1170
|
}
|
|
1171
|
-
let { prevState: t, nextState: n } =
|
|
1171
|
+
let { prevState: t, nextState: n } = ge({
|
|
1172
1172
|
prevState: this.getFullState(),
|
|
1173
1173
|
nextState: e
|
|
1174
1174
|
}), r = this.diffPatcher.diff(t, n);
|
|
@@ -1176,7 +1176,7 @@ var Me = class {
|
|
|
1176
1176
|
console.log("Нет изменений для сохранения.");
|
|
1177
1177
|
return;
|
|
1178
1178
|
}
|
|
1179
|
-
if (
|
|
1179
|
+
if (ue({
|
|
1180
1180
|
prevState: t,
|
|
1181
1181
|
nextState: n
|
|
1182
1182
|
})) {
|
|
@@ -1197,15 +1197,19 @@ var Me = class {
|
|
|
1197
1197
|
console.log("loadStateFromFullState fullState", e);
|
|
1198
1198
|
let { canvas: t, canvasManager: n, interactionBlocker: r, backgroundManager: i, zoomManager: a, panConstraintManager: o } = this.editor, { width: s, height: c } = t, { width: l, height: u } = this.editor.montageArea;
|
|
1199
1199
|
r.overlayMask = null;
|
|
1200
|
-
let d =
|
|
1201
|
-
await t.loadFromJSON(d),
|
|
1200
|
+
let d = ve({ state: e });
|
|
1201
|
+
await t.loadFromJSON(d), ye({
|
|
1202
1202
|
state: e,
|
|
1203
1203
|
canvas: t
|
|
1204
1204
|
});
|
|
1205
1205
|
let f = t.getObjects().find((e) => e.id === "montage-area"), p = !1, m = !1;
|
|
1206
1206
|
f && (this.editor.montageArea = f, n.placeMontageAreaAtCanonicalScenePosition(), p = f.width !== l || f.height !== u, m = s !== t.getWidth() || c !== t.getHeight());
|
|
1207
1207
|
let h = t.getObjects().find((e) => e.id === "background");
|
|
1208
|
-
h ? i.backgroundObject = h : i.removeBackground({ withoutSave: !0 })
|
|
1208
|
+
h ? i.backgroundObject = h : i.removeBackground({ withoutSave: !0 });
|
|
1209
|
+
let { textManager: g } = this.editor;
|
|
1210
|
+
g && t.getObjects().forEach((e) => {
|
|
1211
|
+
g.commitStandaloneTextScale({ target: e });
|
|
1212
|
+
}), f && (r.ensureOverlay(), m ? n.updateCanvas() : p ? (a.calculateAndApplyDefaultZoom(), n.refreshMontageDerivedState()) : (a.updateDefaultZoom(), n.centerViewportToMontageArea(), n.refreshMontageDerivedState(), o.updateBounds())), t.renderAll(), t.fire("editor:history-state-loaded", {
|
|
1209
1213
|
fullState: e,
|
|
1210
1214
|
currentIndex: this.currentIndex,
|
|
1211
1215
|
totalChangesCount: this.totalChangesCount,
|
|
@@ -1276,7 +1280,7 @@ var Me = class {
|
|
|
1276
1280
|
}
|
|
1277
1281
|
}
|
|
1278
1282
|
}
|
|
1279
|
-
},
|
|
1283
|
+
}, Me = .1, Ne = 4096, Pe = 4096, Fe = "application/image-editor:", Ie = /* @__PURE__ */ "customData.backgroundType.format.contentType.width.height.originX.originY.locked.editable.evented.selectable.lockMovementX.lockMovementY.lockRotation.lockScalingX.lockScalingY.lockSkewingX.lockSkewingY.styles.lineFontDefaults.textCaseRaw.uppercase.autoExpand.linethrough.underline.fontStyle.fontWeight.backgroundOpacity.paddingTop.paddingRight.paddingBottom.paddingLeft.radiusTopLeft.radiusTopRight.radiusBottomRight.radiusBottomLeft.shapeComposite.shapePresetKey.shapeBaseWidth.shapeBaseHeight.shapeManualBaseWidth.shapeManualBaseHeight.shapeTextAutoExpand.shapeAlignHorizontal.shapeAlignVertical.shapePaddingTop.shapePaddingRight.shapePaddingBottom.shapePaddingLeft.shapeFill.shapeStroke.shapeStrokeWidth.shapeStrokeDashArray.shapeOpacity.shapeRounding.shapeNodeType".split("."), Le = class e {
|
|
1280
1284
|
constructor({ editor: e }) {
|
|
1281
1285
|
this.editor = e, this.options = e.options, this._createdBlobUrls = [], this.acceptContentTypes = this.editor.options.acceptContentTypes, this.acceptFormats = this.getAllowedFormatsFromContentTypes();
|
|
1282
1286
|
}
|
|
@@ -1473,7 +1477,7 @@ var Me = class {
|
|
|
1473
1477
|
}
|
|
1474
1478
|
}
|
|
1475
1479
|
async resizeImageToBoundaries(e) {
|
|
1476
|
-
let { dataURL: t, sizeType: n = "max", contentType: r = "image/png", quality: i = 1, maxWidth: a =
|
|
1480
|
+
let { dataURL: t, sizeType: n = "max", contentType: r = "image/png", quality: i = 1, maxWidth: a = Ne, maxHeight: o = Pe, minWidth: s = 16, minHeight: c = 16, asBase64: l = !1, emitMessage: u = !0 } = e, { errorManager: d, workerManager: f } = this.editor, p = {
|
|
1477
1481
|
dataURL: t,
|
|
1478
1482
|
sizeType: n,
|
|
1479
1483
|
contentType: r,
|
|
@@ -1749,11 +1753,11 @@ var Me = class {
|
|
|
1749
1753
|
let t = e.match(/^[^/]+\/([^+;]+)/);
|
|
1750
1754
|
return t ? t[1] : "";
|
|
1751
1755
|
}
|
|
1752
|
-
},
|
|
1753
|
-
function
|
|
1756
|
+
}, Re = (e, t, n) => Math.max(Math.min(e, n), t), ze = (e, t) => e * t;
|
|
1757
|
+
function Be(e) {
|
|
1754
1758
|
return (e?.type === "image" || e?.format === "svg") && typeof e?.width == "number" && typeof e?.height == "number";
|
|
1755
1759
|
}
|
|
1756
|
-
var
|
|
1760
|
+
var Ve = class {
|
|
1757
1761
|
constructor({ editor: e }) {
|
|
1758
1762
|
this.editor = e;
|
|
1759
1763
|
}
|
|
@@ -1763,7 +1767,7 @@ var He = class {
|
|
|
1763
1767
|
}
|
|
1764
1768
|
getVisibleCenterPoint() {
|
|
1765
1769
|
let { canvas: e } = this.editor, t = e.getZoom(), n = e.viewportTransform, r = e.getWidth(), i = e.getHeight(), a = this.getMontageAreaSceneBounds(), o = (r / 2 - n[4]) / t, s = (i / 2 - n[5]) / t;
|
|
1766
|
-
return new p(
|
|
1770
|
+
return new p(Re(o, a.left, a.right), Re(s, a.top, a.bottom));
|
|
1767
1771
|
}
|
|
1768
1772
|
getMontageAreaSceneCenter() {
|
|
1769
1773
|
let { montageArea: e } = this.editor;
|
|
@@ -1842,9 +1846,9 @@ var He = class {
|
|
|
1842
1846
|
}
|
|
1843
1847
|
setResolutionWidth(e, { preserveProportional: t, withoutSave: n, adaptCanvasToContainer: r } = {}) {
|
|
1844
1848
|
if (!e) return;
|
|
1845
|
-
let { canvas: i, montageArea: a, options: { canvasBackstoreWidth: o } } = this.editor, { width: s, height: c } = a, l =
|
|
1849
|
+
let { canvas: i, montageArea: a, options: { canvasBackstoreWidth: o } } = this.editor, { width: s, height: c } = a, l = Re(Number(e), 16, Ne);
|
|
1846
1850
|
if (!o || o === "auto" || r ? this.adaptCanvasToContainer() : o ? this.setCanvasBackstoreWidth(Number(o)) : this.setCanvasBackstoreWidth(l), a.set({ width: l }), this.placeMontageAreaAtCanonicalScenePosition(), t) {
|
|
1847
|
-
let e =
|
|
1851
|
+
let e = ze(c, l / s);
|
|
1848
1852
|
this.setResolutionHeight(e, {
|
|
1849
1853
|
withoutSave: n,
|
|
1850
1854
|
adaptCanvasToContainer: r
|
|
@@ -1860,9 +1864,9 @@ var He = class {
|
|
|
1860
1864
|
}
|
|
1861
1865
|
setResolutionHeight(e, { preserveProportional: t, withoutSave: n, adaptCanvasToContainer: r } = {}) {
|
|
1862
1866
|
if (!e) return;
|
|
1863
|
-
let { canvas: i, montageArea: a, options: { canvasBackstoreHeight: o } } = this.editor, { width: s, height: c } = a, l =
|
|
1867
|
+
let { canvas: i, montageArea: a, options: { canvasBackstoreHeight: o } } = this.editor, { width: s, height: c } = a, l = Re(Number(e), 16, Pe);
|
|
1864
1868
|
if (!o || o === "auto" || r ? this.adaptCanvasToContainer() : o ? this.setCanvasBackstoreHeight(Number(o)) : this.setCanvasBackstoreHeight(l), a.set({ height: l }), this.placeMontageAreaAtCanonicalScenePosition(), t) {
|
|
1865
|
-
let e =
|
|
1869
|
+
let e = ze(s, l / c);
|
|
1866
1870
|
this.setResolutionWidth(e, {
|
|
1867
1871
|
withoutSave: n,
|
|
1868
1872
|
adaptCanvasToContainer: r
|
|
@@ -1889,16 +1893,16 @@ var He = class {
|
|
|
1889
1893
|
}
|
|
1890
1894
|
setCanvasBackstoreWidth(e) {
|
|
1891
1895
|
if (!e || typeof e != "number") return;
|
|
1892
|
-
let t =
|
|
1896
|
+
let t = Re(e, 16, Ne);
|
|
1893
1897
|
this.editor.canvas.setDimensions({ width: t }, { backstoreOnly: !0 });
|
|
1894
1898
|
}
|
|
1895
1899
|
setCanvasBackstoreHeight(e) {
|
|
1896
1900
|
if (!e || typeof e != "number") return;
|
|
1897
|
-
let t =
|
|
1901
|
+
let t = Re(e, 16, Pe);
|
|
1898
1902
|
this.editor.canvas.setDimensions({ height: t }, { backstoreOnly: !0 });
|
|
1899
1903
|
}
|
|
1900
1904
|
adaptCanvasToContainer() {
|
|
1901
|
-
let { canvas: e } = this.editor, t = this.getEditorContainer(), n = t.clientWidth, r = t.clientHeight, i =
|
|
1905
|
+
let { canvas: e } = this.editor, t = this.getEditorContainer(), n = t.clientWidth, r = t.clientHeight, i = Re(n, 16, Ne), a = Re(r, 16, Pe);
|
|
1902
1906
|
e.setDimensions({
|
|
1903
1907
|
width: i,
|
|
1904
1908
|
height: a
|
|
@@ -1986,8 +1990,8 @@ var He = class {
|
|
|
1986
1990
|
}
|
|
1987
1991
|
scaleMontageAreaToImage({ object: e, preserveAspectRatio: t, withoutSave: n } = {}) {
|
|
1988
1992
|
let { canvas: r, montageArea: i, transformManager: a } = this.editor, o = e || r.getActiveObject();
|
|
1989
|
-
if (!
|
|
1990
|
-
let { width: s, height: c } = o, l = Math.min(s,
|
|
1993
|
+
if (!Be(o)) return;
|
|
1994
|
+
let { width: s, height: c } = o, l = Math.min(s, Ne), u = Math.min(c, Pe);
|
|
1991
1995
|
if (t) {
|
|
1992
1996
|
let { width: e, height: t } = i, n = s / e, r = c / t, a = Math.max(n, r);
|
|
1993
1997
|
l = e * a, u = t * a;
|
|
@@ -2015,7 +2019,7 @@ var He = class {
|
|
|
2015
2019
|
let { canvas: e, montageArea: t, interactionBlocker: { overlayMask: n }, backgroundManager: { backgroundObject: r } } = this.editor;
|
|
2016
2020
|
return e.getObjects().filter((e) => e.id !== t.id && e.id !== n?.id && e.id !== r?.id);
|
|
2017
2021
|
}
|
|
2018
|
-
},
|
|
2022
|
+
}, He = class {
|
|
2019
2023
|
constructor({ editor: e }) {
|
|
2020
2024
|
this.editor = e, this.options = e.options;
|
|
2021
2025
|
}
|
|
@@ -2123,7 +2127,7 @@ var He = class {
|
|
|
2123
2127
|
});
|
|
2124
2128
|
}
|
|
2125
2129
|
}
|
|
2126
|
-
},
|
|
2130
|
+
}, Ue = class {
|
|
2127
2131
|
constructor({ editor: e }) {
|
|
2128
2132
|
this.editor = e, this.options = e.options, this.minZoom = this.options.minZoom || .1, this.maxZoom = this.options.maxZoom || 2, this.defaultZoom = this._normalizeDefaultZoom(this.options.defaultScale);
|
|
2129
2133
|
}
|
|
@@ -2177,7 +2181,7 @@ var He = class {
|
|
|
2177
2181
|
y: Math.abs(T) > Math.abs(d) ? d : T
|
|
2178
2182
|
};
|
|
2179
2183
|
}
|
|
2180
|
-
_applyViewportCentering(e, t = !1, n =
|
|
2184
|
+
_applyViewportCentering(e, t = !1, n = Me) {
|
|
2181
2185
|
let { canvas: r } = this.editor, i = this._getScaledMontageDimensions(e), a = r.getWidth(), o = r.getHeight(), s = i.width > a || i.height > o, c = this._calculateFitZoom(), l = e - c;
|
|
2182
2186
|
if (!(!s || l) && !t) return !1;
|
|
2183
2187
|
let u = r.viewportTransform, d = this._calculateTargetViewportPosition(e);
|
|
@@ -2226,7 +2230,7 @@ var He = class {
|
|
|
2226
2230
|
pointY: u.y
|
|
2227
2231
|
});
|
|
2228
2232
|
}
|
|
2229
|
-
zoom(e =
|
|
2233
|
+
zoom(e = Me, t = {}) {
|
|
2230
2234
|
if (!e) return;
|
|
2231
2235
|
let { minZoom: n, maxZoom: r } = this, { canvas: i } = this.editor, a = e < 0, o = i.getZoom(), s = i.getCenterPoint(), c = new p(t.pointX ?? s.x, t.pointY ?? s.y);
|
|
2232
2236
|
this.editor.montageArea.setCoords(), this.editor.canvas.requestRenderAll();
|
|
@@ -2252,30 +2256,30 @@ var He = class {
|
|
|
2252
2256
|
point: r
|
|
2253
2257
|
}), this.editor.panConstraintManager.updateBounds();
|
|
2254
2258
|
}
|
|
2255
|
-
},
|
|
2256
|
-
let r =
|
|
2259
|
+
}, W = ({ value: e, fallback: t = 0 }) => typeof e == "number" && Number.isFinite(e) ? e : typeof t == "number" && Number.isFinite(t) ? t : 0, We = ({ value: e, dimension: t, useRelativePositions: n }) => {
|
|
2260
|
+
let r = W({ value: e });
|
|
2257
2261
|
return n ? r : r / (t || 1);
|
|
2258
|
-
},
|
|
2259
|
-
x:
|
|
2262
|
+
}, Ge = ({ object: e, baseWidth: t, baseHeight: n, useRelativePositions: r }) => ({
|
|
2263
|
+
x: We({
|
|
2260
2264
|
value: e.left,
|
|
2261
2265
|
dimension: t,
|
|
2262
2266
|
useRelativePositions: r
|
|
2263
2267
|
}),
|
|
2264
|
-
y:
|
|
2268
|
+
y: We({
|
|
2265
2269
|
value: e.top,
|
|
2266
2270
|
dimension: n,
|
|
2267
2271
|
useRelativePositions: r
|
|
2268
2272
|
})
|
|
2269
|
-
}),
|
|
2273
|
+
}), Ke = ({ normalizedX: e, normalizedY: t, bounds: n }) => {
|
|
2270
2274
|
let { left: r, top: i, width: a, height: o } = n;
|
|
2271
2275
|
return new p(r + e * a, i + t * o);
|
|
2272
|
-
},
|
|
2273
|
-
let { left: t = 0, top: n = 0, width: r = 0, height: i = 0, scaleX: a = 1, scaleY: o = 1, strokeWidth: s = 0, strokeUniform: c = !1 } = e, l = e.type
|
|
2276
|
+
}, qe = ({ object: e }) => {
|
|
2277
|
+
let { left: t = 0, top: n = 0, width: r = 0, height: i = 0, scaleX: a = 1, scaleY: o = 1, strokeWidth: s = 0, strokeUniform: c = !1 } = e, l = typeof e.type == "string" ? e.type.toLowerCase() : "", u = e instanceof _ || l === "textbox" || l === "background-textbox", d = c ? 0 : s, f = r + d, p = i + d, m = {
|
|
2274
2278
|
left: Math.round(t),
|
|
2275
2279
|
top: Math.round(n)
|
|
2276
2280
|
};
|
|
2277
|
-
|
|
2278
|
-
},
|
|
2281
|
+
u || (f > 0 && (m.scaleX = Math.max(1, Math.round(f * a)) / f), p > 0 && (m.scaleY = Math.max(1, Math.round(p * o)) / p)), e.set(m), e.setCoords();
|
|
2282
|
+
}, Je = ({ object: e }) => {
|
|
2279
2283
|
if (!e) return null;
|
|
2280
2284
|
try {
|
|
2281
2285
|
e.setCoords();
|
|
@@ -2300,7 +2304,7 @@ function Ye({ canvas: e, object: t, left: n, top: r, centerPoint: i, flags: a })
|
|
|
2300
2304
|
let n = i ?? e.getCenterPoint();
|
|
2301
2305
|
t.setPositionByOrigin(n, "center", "center"), t.setCoords();
|
|
2302
2306
|
}
|
|
2303
|
-
return
|
|
2307
|
+
return qe({ object: t }), s ? t : (e.add(t), o || e.setActiveObject(t), e.renderAll(), t);
|
|
2304
2308
|
}
|
|
2305
2309
|
var Xe = ({ canvas: e, options: t = {}, centerPoint: n, flags: r = {} }) => {
|
|
2306
2310
|
let { id: i = `rect-${D()}`, left: a, top: o, width: s = 100, height: c = 100, fill: l = "blue", ...u } = t;
|
|
@@ -5617,7 +5621,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5617
5621
|
async _cloneToInternalClipboard(e) {
|
|
5618
5622
|
let { canvas: t, errorManager: n } = this.editor;
|
|
5619
5623
|
try {
|
|
5620
|
-
let n = await e.clone(
|
|
5624
|
+
let n = await e.clone(Ie);
|
|
5621
5625
|
this.clipboard = n, t.fire("editor:object-copied", { object: n });
|
|
5622
5626
|
} catch (e) {
|
|
5623
5627
|
n.emitError({
|
|
@@ -5638,7 +5642,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5638
5642
|
message: "navigator.clipboard не поддерживается в этом браузере или отсутствует HTTPS-соединение."
|
|
5639
5643
|
}), !1;
|
|
5640
5644
|
try {
|
|
5641
|
-
let t = e.toObject(
|
|
5645
|
+
let t = e.toObject(Ie), n = JSON.stringify(t);
|
|
5642
5646
|
return e.type === "image" ? this._copyImageToClipboard(e, n) : this._copyTextToClipboard(n);
|
|
5643
5647
|
} catch (e) {
|
|
5644
5648
|
return t.emitError({
|
|
@@ -5668,7 +5672,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5668
5672
|
}
|
|
5669
5673
|
async _copyTextToClipboard(e) {
|
|
5670
5674
|
try {
|
|
5671
|
-
let t = `${
|
|
5675
|
+
let t = `${Fe}${e}`;
|
|
5672
5676
|
return await navigator.clipboard.writeText(t), console.info("Text copied to clipboard successfully"), !0;
|
|
5673
5677
|
} catch (e) {
|
|
5674
5678
|
let { errorManager: t } = this.editor;
|
|
@@ -5691,6 +5695,18 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5691
5695
|
}
|
|
5692
5696
|
n.add(t), n.setActiveObject(t), n.requestRenderAll();
|
|
5693
5697
|
}
|
|
5698
|
+
_commitStandaloneTextScaleOnClone({ clonedObject: t }) {
|
|
5699
|
+
let { textManager: n } = this.editor;
|
|
5700
|
+
if (n) {
|
|
5701
|
+
if (t instanceof e) {
|
|
5702
|
+
t.forEachObject((e) => {
|
|
5703
|
+
n.commitStandaloneTextScale({ target: e });
|
|
5704
|
+
}), t.setCoords();
|
|
5705
|
+
return;
|
|
5706
|
+
}
|
|
5707
|
+
n.commitStandaloneTextScale({ target: t });
|
|
5708
|
+
}
|
|
5709
|
+
}
|
|
5694
5710
|
async _handleImageImport(e) {
|
|
5695
5711
|
let { canvas: t, errorManager: n } = this.editor, r = !1, i = !1, a = null, o = null, s = new Promise((e, t) => {
|
|
5696
5712
|
a = (t) => {
|
|
@@ -5741,7 +5757,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5741
5757
|
let { canvas: n } = this.editor, r = t || n.getActiveObject();
|
|
5742
5758
|
if (!r || r.locked) return !1;
|
|
5743
5759
|
try {
|
|
5744
|
-
let t = await r.clone(
|
|
5760
|
+
let t = await r.clone(Ie);
|
|
5745
5761
|
return t instanceof e && t.forEachObject((e) => {
|
|
5746
5762
|
e.set({
|
|
5747
5763
|
id: `${e.type}-${D()}`,
|
|
@@ -5752,7 +5768,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5752
5768
|
left: t.left + 10,
|
|
5753
5769
|
top: t.top + 10,
|
|
5754
5770
|
evented: !0
|
|
5755
|
-
}), this._addClonedObjectToCanvas(t), n.fire("editor:object-duplicated", {
|
|
5771
|
+
}), this._commitStandaloneTextScaleOnClone({ clonedObject: t }), this._addClonedObjectToCanvas(t), n.fire("editor:object-duplicated", {
|
|
5756
5772
|
targetObject: r,
|
|
5757
5773
|
clonedObject: t
|
|
5758
5774
|
}), !0;
|
|
@@ -5815,7 +5831,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5815
5831
|
let { canvas: t } = this.editor;
|
|
5816
5832
|
if (!this.clipboard) return !1;
|
|
5817
5833
|
try {
|
|
5818
|
-
let n = await this.clipboard.clone(
|
|
5834
|
+
let n = await this.clipboard.clone(Ie);
|
|
5819
5835
|
return t.discardActiveObject(), n instanceof e && n.forEachObject((e) => {
|
|
5820
5836
|
e.set({
|
|
5821
5837
|
id: `${e.type}-${D()}`,
|
|
@@ -5826,7 +5842,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
5826
5842
|
left: n.left + 10,
|
|
5827
5843
|
top: n.top + 10,
|
|
5828
5844
|
evented: !0
|
|
5829
|
-
}), this._addClonedObjectToCanvas(n), t.fire("editor:object-pasted", {
|
|
5845
|
+
}), this._commitStandaloneTextScaleOnClone({ clonedObject: n }), this._addClonedObjectToCanvas(n), t.fire("editor:object-pasted", {
|
|
5830
5846
|
fromInternalClipboard: !0,
|
|
5831
5847
|
clipboardObject: this.clipboard,
|
|
5832
5848
|
object: n
|
|
@@ -6829,74 +6845,41 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6829
6845
|
topRight: Math.max(0, u.topRight * x),
|
|
6830
6846
|
bottomRight: Math.max(0, u.bottomRight * x),
|
|
6831
6847
|
bottomLeft: Math.max(0, u.bottomLeft * x)
|
|
6832
|
-
} : u, te =
|
|
6833
|
-
if (y && te) {
|
|
6834
|
-
let e = {};
|
|
6835
|
-
Object.entries(d).forEach(([t, n]) => {
|
|
6836
|
-
if (!n) return;
|
|
6837
|
-
let r = {};
|
|
6838
|
-
Object.entries(n).forEach(([e, t]) => {
|
|
6839
|
-
if (!t) return;
|
|
6840
|
-
let n = { ...t };
|
|
6841
|
-
typeof t.fontSize == "number" && (n.fontSize = Math.max(1, t.fontSize * x)), r[e] = n;
|
|
6842
|
-
}), Object.keys(r).length && (e[t] = r);
|
|
6843
|
-
}), Object.keys(e).length && (ne = e);
|
|
6844
|
-
}
|
|
6845
|
-
let R;
|
|
6846
|
-
y && (R = vr({
|
|
6847
|
-
lineFontDefaults: f,
|
|
6848
|
-
scale: x
|
|
6849
|
-
}));
|
|
6850
|
-
let re = a.getObjectPlacement({
|
|
6848
|
+
} : u, te = a.getObjectPlacement({
|
|
6851
6849
|
object: r,
|
|
6852
6850
|
originX: i.originX ?? r.originX,
|
|
6853
6851
|
originY: i.originY ?? r.originY
|
|
6854
|
-
}),
|
|
6855
|
-
if (!
|
|
6852
|
+
}), ne = P ?? p, R = C !== ne, re = Math.abs(w - (N ?? c)) > mr, z = Math.abs(I.top - T) > .01 || Math.abs(I.right - E) > .01 || Math.abs(I.bottom - D) > .01 || Math.abs(I.left - O) > .01, ie = Math.abs(L.topLeft - k) > .01 || Math.abs(L.topRight - A) > .01 || Math.abs(L.bottomRight - j) > .01 || Math.abs(L.bottomLeft - M) > .01;
|
|
6853
|
+
if (!R && !re && !z && !ie) {
|
|
6856
6854
|
r.set({
|
|
6857
6855
|
scaleX: 1,
|
|
6858
6856
|
scaleY: 1
|
|
6859
6857
|
}), i.scaleX = 1, i.scaleY = 1;
|
|
6860
6858
|
return;
|
|
6861
6859
|
}
|
|
6862
|
-
|
|
6863
|
-
|
|
6864
|
-
|
|
6865
|
-
|
|
6866
|
-
|
|
6867
|
-
|
|
6868
|
-
|
|
6869
|
-
|
|
6870
|
-
|
|
6871
|
-
|
|
6872
|
-
|
|
6873
|
-
|
|
6874
|
-
|
|
6875
|
-
|
|
6876
|
-
|
|
6877
|
-
|
|
6878
|
-
|
|
6879
|
-
|
|
6880
|
-
} else r.initDimensions();
|
|
6881
|
-
let se = jr({ textbox: r });
|
|
6882
|
-
(se || oe) && (r.dirty = !0), a.applyObjectPlacement({
|
|
6883
|
-
object: r,
|
|
6884
|
-
placement: re
|
|
6885
|
-
});
|
|
6886
|
-
let ce = r.width ?? C, le = ce !== z;
|
|
6860
|
+
let { appliedWidth: B, dimensionsRounded: ae } = this._commitStandaloneTextboxScale({
|
|
6861
|
+
textbox: r,
|
|
6862
|
+
base: {
|
|
6863
|
+
baseWidth: p,
|
|
6864
|
+
baseFontSize: c,
|
|
6865
|
+
basePadding: l,
|
|
6866
|
+
baseRadii: u,
|
|
6867
|
+
baseStyles: d,
|
|
6868
|
+
baseLineFontDefaults: f
|
|
6869
|
+
},
|
|
6870
|
+
widthScale: b,
|
|
6871
|
+
heightScale: x,
|
|
6872
|
+
placement: te,
|
|
6873
|
+
shouldScaleFontSize: y,
|
|
6874
|
+
shouldScalePadding: F,
|
|
6875
|
+
shouldScaleRadii: ee,
|
|
6876
|
+
shouldDisableAutoExpandOnHorizontalChange: g
|
|
6877
|
+
}), V = B !== ne;
|
|
6887
6878
|
i.scaleX = 1, i.scaleY = 1;
|
|
6888
6879
|
let { original: H } = i;
|
|
6889
|
-
H && (H.scaleX = 1, H.scaleY = 1, H.width =
|
|
6890
|
-
|
|
6891
|
-
|
|
6892
|
-
bottom: I.bottom,
|
|
6893
|
-
left: I.left
|
|
6894
|
-
}, o.baseRadii = {
|
|
6895
|
-
topLeft: L.topLeft,
|
|
6896
|
-
topRight: L.topRight,
|
|
6897
|
-
bottomRight: L.bottomRight,
|
|
6898
|
-
bottomLeft: L.bottomLeft
|
|
6899
|
-
}, o.hasWidthChange = le || B || ae || V || oe || se;
|
|
6880
|
+
H && (H.scaleX = 1, H.scaleY = 1, H.width = B, H.height = r.height, H.left = r.left, H.top = r.top), this.canvas.requestRenderAll();
|
|
6881
|
+
let U = t._captureTextScaleBase({ textbox: r });
|
|
6882
|
+
o.baseWidth = U.baseWidth, o.baseFontSize = U.baseFontSize, o.baseStyles = U.baseStyles, o.baseLineFontDefaults = U.baseLineFontDefaults, o.basePadding = U.basePadding, o.baseRadii = U.baseRadii, o.hasWidthChange = V || re || z || ie || ae;
|
|
6900
6883
|
}, this._handleObjectModified = (n) => {
|
|
6901
6884
|
let { target: r } = n;
|
|
6902
6885
|
if (r instanceof e) {
|
|
@@ -6905,38 +6888,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
6905
6888
|
let { scaleX: i = 1, scaleY: a = 1 } = r;
|
|
6906
6889
|
if (Math.abs(i - 1) < .01 && Math.abs(a - 1) < .01) return;
|
|
6907
6890
|
this.canvas.discardActiveObject(), n.forEach((e) => {
|
|
6908
|
-
|
|
6909
|
-
let t = e.scaleX ?? 1, n = e.scaleY ?? 1, r = (e.fontSize ?? 16) * n, i = (e.width ?? 0) * t, a = n, { paddingTop: o = 0, paddingRight: s = 0, paddingBottom: c = 0, paddingLeft: l = 0, radiusTopLeft: u = 0, radiusTopRight: d = 0, radiusBottomRight: f = 0, radiusBottomLeft: p = 0, styles: m } = e, h = {
|
|
6910
|
-
paddingTop: Math.max(0, o * a),
|
|
6911
|
-
paddingRight: Math.max(0, s * a),
|
|
6912
|
-
paddingBottom: Math.max(0, c * a),
|
|
6913
|
-
paddingLeft: Math.max(0, l * a)
|
|
6914
|
-
}, g = {
|
|
6915
|
-
radiusTopLeft: Math.max(0, u * a),
|
|
6916
|
-
radiusTopRight: Math.max(0, d * a),
|
|
6917
|
-
radiusBottomRight: Math.max(0, f * a),
|
|
6918
|
-
radiusBottomLeft: Math.max(0, p * a)
|
|
6919
|
-
}, _ = m;
|
|
6920
|
-
m && Object.keys(m).length > 0 && (_ = JSON.parse(JSON.stringify(m)), Object.values(_).forEach((e) => {
|
|
6921
|
-
Object.values(e).forEach((e) => {
|
|
6922
|
-
typeof e.fontSize == "number" && (e.fontSize = Math.max(1, e.fontSize * a));
|
|
6923
|
-
});
|
|
6924
|
-
}));
|
|
6925
|
-
let v = vr({
|
|
6926
|
-
lineFontDefaults: e.lineFontDefaults,
|
|
6927
|
-
scale: a
|
|
6928
|
-
}), y = {
|
|
6929
|
-
fontSize: r,
|
|
6930
|
-
width: i,
|
|
6931
|
-
scaleX: 1,
|
|
6932
|
-
scaleY: 1,
|
|
6933
|
-
...h,
|
|
6934
|
-
...g,
|
|
6935
|
-
styles: _
|
|
6936
|
-
};
|
|
6937
|
-
v && (y.lineFontDefaults = v), e.set(y), jr({ textbox: e });
|
|
6938
|
-
}
|
|
6939
|
-
e.setCoords();
|
|
6891
|
+
this.commitStandaloneTextScale({ target: e }), e.setCoords();
|
|
6940
6892
|
});
|
|
6941
6893
|
let o = new e(n, { canvas: this.canvas });
|
|
6942
6894
|
this.canvas.setActiveObject(o), this.canvas.requestRenderAll();
|
|
@@ -7058,19 +7010,19 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
7058
7010
|
}), ie = z ? xr({
|
|
7059
7011
|
textbox: o,
|
|
7060
7012
|
range: z
|
|
7061
|
-
}) : null, B = {}, ae = {}, V = {},
|
|
7013
|
+
}) : null, B = {}, ae = {}, V = {}, H, U, oe = ar({
|
|
7062
7014
|
textbox: o,
|
|
7063
7015
|
range: z
|
|
7064
|
-
}),
|
|
7065
|
-
if (m !== void 0 && (ie && (ae.fontFamily = m),
|
|
7016
|
+
}), se = !z || oe, ce = !z;
|
|
7017
|
+
if (m !== void 0 && (ie && (ae.fontFamily = m), se && (R.fontFamily = m, ce && (V.fontFamily = m))), h !== void 0 && (ie && (ae.fontSize = h), se && (R.fontSize = h, ce && (V.fontSize = h))), g !== void 0) {
|
|
7066
7018
|
let e = g ? "bold" : "normal";
|
|
7067
|
-
z && (B.fontWeight = e),
|
|
7019
|
+
z && (B.fontWeight = e), se && (R.fontWeight = e, ce && (V.fontWeight = e));
|
|
7068
7020
|
}
|
|
7069
7021
|
if (_ !== void 0) {
|
|
7070
7022
|
let e = _ ? "italic" : "normal";
|
|
7071
|
-
z && (B.fontStyle = e),
|
|
7023
|
+
z && (B.fontStyle = e), se && (R.fontStyle = e, ce && (V.fontStyle = e));
|
|
7072
7024
|
}
|
|
7073
|
-
if (v !== void 0 && (z && (B.underline = v),
|
|
7025
|
+
if (v !== void 0 && (z && (B.underline = v), se && (R.underline = v, ce && (V.underline = v))), b !== void 0 && (z && (B.linethrough = b), se && (R.linethrough = b, ce && (V.linethrough = b))), x !== void 0 && (R.textAlign = x), S !== void 0 && (z && (B.fill = S), se && (R.fill = S, ce && (V.fill = S))), C !== void 0 || w !== void 0) {
|
|
7074
7026
|
let e = z ? sr({
|
|
7075
7027
|
textbox: o,
|
|
7076
7028
|
range: z,
|
|
@@ -7080,15 +7032,15 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
7080
7032
|
range: z,
|
|
7081
7033
|
property: "stroke"
|
|
7082
7034
|
}) : void 0;
|
|
7083
|
-
|
|
7035
|
+
U = lr({ width: w ?? e ?? o.strokeWidth ?? 0 }), H = cr({
|
|
7084
7036
|
strokeColor: C ?? t ?? o.stroke ?? void 0,
|
|
7085
|
-
width:
|
|
7086
|
-
}), z && (B.stroke =
|
|
7037
|
+
width: U
|
|
7038
|
+
}), z && (B.stroke = H, B.strokeWidth = U), se && (R.stroke = H, R.strokeWidth = U, ce && (V.stroke = H, V.strokeWidth = U));
|
|
7087
7039
|
}
|
|
7088
7040
|
T !== void 0 && (R.opacity = T), E !== void 0 && (R.backgroundColor = E), D !== void 0 && (R.backgroundOpacity = D), O !== void 0 && (R.paddingTop = O), k !== void 0 && (R.paddingRight = k), A !== void 0 && (R.paddingBottom = A), j !== void 0 && (R.paddingLeft = j), M !== void 0 && (R.radiusTopLeft = M), N !== void 0 && (R.radiusTopRight = N), P !== void 0 && (R.radiusBottomRight = P), F !== void 0 && (R.radiusBottomLeft = F);
|
|
7089
|
-
let
|
|
7090
|
-
|
|
7091
|
-
let
|
|
7041
|
+
let le = o.textCaseRaw ?? s, ue = !!o.uppercase, de = f !== void 0, fe = de ? f ?? "" : le, pe = y ?? ue, me = pe !== ue;
|
|
7042
|
+
de || me ? (R.text = pe ? ur({ value: fe }) : fe, o.textCaseRaw = fe) : o.textCaseRaw === void 0 && (o.textCaseRaw = le), o.uppercase = pe, o.set(R);
|
|
7043
|
+
let he = !1;
|
|
7092
7044
|
if (z) {
|
|
7093
7045
|
let e = or({
|
|
7094
7046
|
textbox: o,
|
|
@@ -7099,21 +7051,21 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
7099
7051
|
styles: ae,
|
|
7100
7052
|
range: ie
|
|
7101
7053
|
}) : !1;
|
|
7102
|
-
|
|
7054
|
+
he = e || t;
|
|
7103
7055
|
} else if (Object.keys(V).length) {
|
|
7104
7056
|
let e = ir({ textbox: o });
|
|
7105
|
-
e && (
|
|
7057
|
+
e && (he = or({
|
|
7106
7058
|
textbox: o,
|
|
7107
7059
|
styles: V,
|
|
7108
7060
|
range: e
|
|
7109
7061
|
}));
|
|
7110
7062
|
}
|
|
7111
|
-
let
|
|
7063
|
+
let ge = he && Ar({ stylesList: [
|
|
7112
7064
|
B,
|
|
7113
7065
|
ae,
|
|
7114
7066
|
V
|
|
7115
7067
|
] });
|
|
7116
|
-
if (
|
|
7068
|
+
if (he && (o.dirty = !0), ie && (m !== void 0 || h !== void 0)) {
|
|
7117
7069
|
let e = Sr({
|
|
7118
7070
|
textbox: o,
|
|
7119
7071
|
range: ie
|
|
@@ -7129,47 +7081,47 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
7129
7081
|
textbox: o,
|
|
7130
7082
|
range: z
|
|
7131
7083
|
}), t = {};
|
|
7132
|
-
S !== void 0 && (t.fill = S), (C !== void 0 || w !== void 0) && (
|
|
7084
|
+
S !== void 0 && (t.fill = S), (C !== void 0 || w !== void 0) && (H === null && (t.stroke = null), H != null && (t.stroke = H)), hr({
|
|
7133
7085
|
textbox: o,
|
|
7134
7086
|
lineIndices: e,
|
|
7135
7087
|
updates: t
|
|
7136
7088
|
});
|
|
7137
7089
|
}
|
|
7138
|
-
|
|
7139
|
-
let
|
|
7090
|
+
ge && (o.initDimensions(), o.dirty = !0), (E !== void 0 || D !== void 0 || O !== void 0 || k !== void 0 || A !== void 0 || j !== void 0 || M !== void 0 || N !== void 0 || P !== void 0 || F !== void 0) && (o.dirty = !0);
|
|
7091
|
+
let _e = Ar({ stylesList: [
|
|
7140
7092
|
R,
|
|
7141
7093
|
B,
|
|
7142
7094
|
ae,
|
|
7143
7095
|
V
|
|
7144
|
-
] }), { autoExpand:
|
|
7145
|
-
|
|
7146
|
-
let
|
|
7096
|
+
] }), { autoExpand: ve } = o, ye = p !== void 0, be = Object.prototype.hasOwnProperty.call(R, "width"), xe = (p ?? ve) !== !1;
|
|
7097
|
+
ye ? o.autoExpand = p !== !1 : ve === void 0 && (o.autoExpand = !0);
|
|
7098
|
+
let Se = xe && !be && (de || me || _e);
|
|
7147
7099
|
this._normalizeTextboxAfterContentChange({
|
|
7148
7100
|
textbox: o,
|
|
7149
7101
|
placement: re,
|
|
7150
|
-
shouldAutoExpand:
|
|
7102
|
+
shouldAutoExpand: Se
|
|
7151
7103
|
}), o.setCoords();
|
|
7152
|
-
let
|
|
7104
|
+
let Ce = {
|
|
7153
7105
|
withoutSave: !!r,
|
|
7154
7106
|
skipRender: !!i
|
|
7155
|
-
},
|
|
7107
|
+
}, we = !!z && Object.keys(B).length > 0, Te = {
|
|
7156
7108
|
textbox: o,
|
|
7157
7109
|
target: e,
|
|
7158
7110
|
style: n,
|
|
7159
|
-
options:
|
|
7111
|
+
options: Ce,
|
|
7160
7112
|
updates: R,
|
|
7161
7113
|
selectionRange: z ?? void 0,
|
|
7162
|
-
selectionStyles:
|
|
7114
|
+
selectionStyles: we ? B : void 0
|
|
7163
7115
|
};
|
|
7164
|
-
u.fire("editor:before:text-updated",
|
|
7165
|
-
let
|
|
7116
|
+
u.fire("editor:before:text-updated", Te), i || u.requestRenderAll();
|
|
7117
|
+
let Ee = t._getSnapshot(o);
|
|
7166
7118
|
c.resumeHistory(), r || c.saveState();
|
|
7167
|
-
let
|
|
7168
|
-
...
|
|
7119
|
+
let De = {
|
|
7120
|
+
...Te,
|
|
7169
7121
|
before: d,
|
|
7170
|
-
after:
|
|
7122
|
+
after: Ee
|
|
7171
7123
|
};
|
|
7172
|
-
return u.fire("editor:text-updated",
|
|
7124
|
+
return u.fire("editor:text-updated", De), o;
|
|
7173
7125
|
}
|
|
7174
7126
|
stylesFromArray(e, t) {
|
|
7175
7127
|
return C.stylesFromArray(e, t);
|
|
@@ -7178,6 +7130,23 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
7178
7130
|
let { canvas: e } = this;
|
|
7179
7131
|
e.off("object:scaling", this._handleObjectScaling), e.off("object:resizing", this._handleObjectResizing), e.off("object:modified", this._handleObjectModified), e.off("text:editing:exited", this._handleTextEditingExited), e.off("text:editing:entered", this._handleTextEditingEntered), e.off("text:changed", this._handleTextChanged);
|
|
7180
7132
|
}
|
|
7133
|
+
commitStandaloneTextScale({ target: e, shouldDisableAutoExpandOnHorizontalChange: n = !1 }) {
|
|
7134
|
+
if (!t._isTextbox(e) || t._isShapeOwnedTextbox(e)) return !1;
|
|
7135
|
+
let r = Math.abs(e.scaleX ?? 1) || 1, i = Math.abs(e.scaleY ?? 1) || 1;
|
|
7136
|
+
if (!(Math.abs(r - 1) > .01 || Math.abs(i - 1) > .01)) return !1;
|
|
7137
|
+
let a = t._captureTextScaleBase({ textbox: e }), o = this.editor.canvasManager.getObjectPlacement({ object: e });
|
|
7138
|
+
return this._commitStandaloneTextboxScale({
|
|
7139
|
+
textbox: e,
|
|
7140
|
+
base: a,
|
|
7141
|
+
widthScale: r,
|
|
7142
|
+
heightScale: i,
|
|
7143
|
+
placement: o,
|
|
7144
|
+
shouldScaleFontSize: !0,
|
|
7145
|
+
shouldScalePadding: !0,
|
|
7146
|
+
shouldScaleRadii: !0,
|
|
7147
|
+
shouldDisableAutoExpandOnHorizontalChange: n
|
|
7148
|
+
}), !0;
|
|
7149
|
+
}
|
|
7181
7150
|
_resolveTextObject(e) {
|
|
7182
7151
|
if (e instanceof _) return e;
|
|
7183
7152
|
let { canvas: n } = this;
|
|
@@ -7201,6 +7170,80 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
7201
7170
|
let n = t.split("\n").length, { textLines: r } = e;
|
|
7202
7171
|
return Array.isArray(r) && r.length > n;
|
|
7203
7172
|
}
|
|
7173
|
+
static _captureTextScaleBase({ textbox: e }) {
|
|
7174
|
+
let t = e.width ?? e.calcTextWidth(), n = e.fontSize ?? 16, { styles: r = {} } = e, { lineFontDefaults: i } = e, { paddingTop: a = 0, paddingRight: o = 0, paddingBottom: s = 0, paddingLeft: c = 0 } = e, { radiusTopLeft: l = 0, radiusTopRight: u = 0, radiusBottomRight: d = 0, radiusBottomLeft: f = 0 } = e;
|
|
7175
|
+
return {
|
|
7176
|
+
baseWidth: t,
|
|
7177
|
+
baseFontSize: n,
|
|
7178
|
+
basePadding: {
|
|
7179
|
+
top: a,
|
|
7180
|
+
right: o,
|
|
7181
|
+
bottom: s,
|
|
7182
|
+
left: c
|
|
7183
|
+
},
|
|
7184
|
+
baseRadii: {
|
|
7185
|
+
topLeft: l,
|
|
7186
|
+
topRight: u,
|
|
7187
|
+
bottomRight: d,
|
|
7188
|
+
bottomLeft: f
|
|
7189
|
+
},
|
|
7190
|
+
baseStyles: JSON.parse(JSON.stringify(r)),
|
|
7191
|
+
baseLineFontDefaults: _r({ lineFontDefaults: i })
|
|
7192
|
+
};
|
|
7193
|
+
}
|
|
7194
|
+
_commitStandaloneTextboxScale({ textbox: e, base: t, widthScale: n, heightScale: r, placement: i, shouldScaleFontSize: a, shouldScalePadding: o, shouldScaleRadii: s, shouldDisableAutoExpandOnHorizontalChange: c = !1 }) {
|
|
7195
|
+
let { baseWidth: l, baseFontSize: u, basePadding: d, baseRadii: f, baseStyles: p, baseLineFontDefaults: m } = t, h = Math.max(1, l * n), g = Math.max(1, Math.round(h)), _ = Math.max(1, u * r), v = Object.keys(p).length > 0, y;
|
|
7196
|
+
if (a && v) {
|
|
7197
|
+
let e = {};
|
|
7198
|
+
Object.entries(p).forEach(([t, n]) => {
|
|
7199
|
+
if (!n) return;
|
|
7200
|
+
let i = {};
|
|
7201
|
+
Object.entries(n).forEach(([e, t]) => {
|
|
7202
|
+
if (!t) return;
|
|
7203
|
+
let n = { ...t };
|
|
7204
|
+
typeof t.fontSize == "number" && (n.fontSize = Math.max(1, t.fontSize * r)), i[e] = n;
|
|
7205
|
+
}), Object.keys(i).length && (e[t] = i);
|
|
7206
|
+
}), Object.keys(e).length && (y = e);
|
|
7207
|
+
}
|
|
7208
|
+
let b;
|
|
7209
|
+
a && (b = vr({
|
|
7210
|
+
lineFontDefaults: m,
|
|
7211
|
+
scale: r
|
|
7212
|
+
}));
|
|
7213
|
+
let x = o ? {
|
|
7214
|
+
top: Math.max(0, d.top * r),
|
|
7215
|
+
right: Math.max(0, d.right * r),
|
|
7216
|
+
bottom: Math.max(0, d.bottom * r),
|
|
7217
|
+
left: Math.max(0, d.left * r)
|
|
7218
|
+
} : d, S = s ? {
|
|
7219
|
+
topLeft: Math.max(0, f.topLeft * r),
|
|
7220
|
+
topRight: Math.max(0, f.topRight * r),
|
|
7221
|
+
bottomRight: Math.max(0, f.bottomRight * r),
|
|
7222
|
+
bottomLeft: Math.max(0, f.bottomLeft * r)
|
|
7223
|
+
} : f, C = g !== (e.width ?? l);
|
|
7224
|
+
c && C && (e.autoExpand = !1), y && (e.styles = y), b && (e.lineFontDefaults = b), e.set({
|
|
7225
|
+
width: g,
|
|
7226
|
+
fontSize: a ? _ : u,
|
|
7227
|
+
paddingTop: x.top,
|
|
7228
|
+
paddingRight: x.right,
|
|
7229
|
+
paddingBottom: x.bottom,
|
|
7230
|
+
paddingLeft: x.left,
|
|
7231
|
+
radiusTopLeft: S.topLeft,
|
|
7232
|
+
radiusTopRight: S.topRight,
|
|
7233
|
+
radiusBottomRight: S.bottomRight,
|
|
7234
|
+
radiusBottomLeft: S.bottomLeft,
|
|
7235
|
+
scaleX: 1,
|
|
7236
|
+
scaleY: 1
|
|
7237
|
+
}), e.initDimensions();
|
|
7238
|
+
let w = jr({ textbox: e });
|
|
7239
|
+
return w && (e.dirty = !0), this.editor.canvasManager.applyObjectPlacement({
|
|
7240
|
+
object: e,
|
|
7241
|
+
placement: i
|
|
7242
|
+
}), e.setCoords(), {
|
|
7243
|
+
appliedWidth: e.width ?? g,
|
|
7244
|
+
dimensionsRounded: w
|
|
7245
|
+
};
|
|
7246
|
+
}
|
|
7204
7247
|
_normalizeTextboxAfterContentChange({ textbox: e, placement: t, shouldAutoExpand: n, clampToMontage: r = !0 }) {
|
|
7205
7248
|
let i = !1;
|
|
7206
7249
|
n && (i = this._autoExpandTextboxWidth(e, {
|
|
@@ -7215,26 +7258,6 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
7215
7258
|
placement: t
|
|
7216
7259
|
}), o = !0), (i || a) && (e.dirty = !0), (i || a || o) && e.setCoords(), i || a;
|
|
7217
7260
|
}
|
|
7218
|
-
_getTextboxUnwrappedWidth({ textbox: e }) {
|
|
7219
|
-
let t = typeof e.text == "string" ? e.text : "";
|
|
7220
|
-
if (!t.length) return null;
|
|
7221
|
-
e.initDimensions();
|
|
7222
|
-
let n = e, { _textLines: r, _unwrappedTextLines: i, __lineWidths: a, __charBounds: o } = n;
|
|
7223
|
-
if (!Array.isArray(i) || i.length === 0) {
|
|
7224
|
-
let n = Math.ceil(Dr({
|
|
7225
|
-
textbox: e,
|
|
7226
|
-
text: t
|
|
7227
|
-
}));
|
|
7228
|
-
return Number.isFinite(n) ? Math.max(n, e.minWidth ?? 1) : null;
|
|
7229
|
-
}
|
|
7230
|
-
n._textLines = i, n.__lineWidths = [], n.__charBounds = [];
|
|
7231
|
-
try {
|
|
7232
|
-
let t = Math.ceil(e.calcTextWidth());
|
|
7233
|
-
return Number.isFinite(t) ? Math.max(t, e.minWidth ?? 1) : null;
|
|
7234
|
-
} finally {
|
|
7235
|
-
n._textLines = r, n.__lineWidths = a ?? [], n.__charBounds = o ?? [];
|
|
7236
|
-
}
|
|
7237
|
-
}
|
|
7238
7261
|
_bindEvents() {
|
|
7239
7262
|
let { canvas: e } = this;
|
|
7240
7263
|
e.on("object:scaling", this._handleObjectScaling), e.on("object:resizing", this._handleObjectResizing), e.on("object:modified", this._handleObjectModified), e.on("text:editing:entered", this._handleTextEditingEntered), e.on("text:editing:exited", this._handleTextEditingExited), e.on("text:changed", this._handleTextChanged);
|
|
@@ -7350,30 +7373,11 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
7350
7373
|
return this.editingPlacementState ||= /* @__PURE__ */ new WeakMap(), this.editingPlacementState;
|
|
7351
7374
|
}
|
|
7352
7375
|
_ensureScalingState(e) {
|
|
7353
|
-
let
|
|
7354
|
-
|
|
7355
|
-
|
|
7356
|
-
|
|
7357
|
-
|
|
7358
|
-
baseFontSize: r,
|
|
7359
|
-
basePadding: {
|
|
7360
|
-
top: o,
|
|
7361
|
-
right: s,
|
|
7362
|
-
bottom: c,
|
|
7363
|
-
left: l
|
|
7364
|
-
},
|
|
7365
|
-
baseRadii: {
|
|
7366
|
-
topLeft: u,
|
|
7367
|
-
topRight: d,
|
|
7368
|
-
bottomRight: f,
|
|
7369
|
-
bottomLeft: p
|
|
7370
|
-
},
|
|
7371
|
-
baseStyles: JSON.parse(JSON.stringify(i)),
|
|
7372
|
-
baseLineFontDefaults: _r({ lineFontDefaults: a }),
|
|
7373
|
-
hasWidthChange: !1
|
|
7374
|
-
}, this.scalingState.set(e, t);
|
|
7375
|
-
}
|
|
7376
|
-
return t;
|
|
7376
|
+
let n = this.scalingState.get(e);
|
|
7377
|
+
return n || (n = {
|
|
7378
|
+
...t._captureTextScaleBase({ textbox: e }),
|
|
7379
|
+
hasWidthChange: !1
|
|
7380
|
+
}, this.scalingState.set(e, n)), n;
|
|
7377
7381
|
}
|
|
7378
7382
|
static _getSnapshot(e) {
|
|
7379
7383
|
let t = ({ snapshot: e, entries: t }) => {
|
|
@@ -7546,7 +7550,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
7546
7550
|
baseWidth: f.baseWidth,
|
|
7547
7551
|
baseHeight: f.baseHeight,
|
|
7548
7552
|
useRelativePositions: m
|
|
7549
|
-
}),
|
|
7553
|
+
}), this.editor.textManager?.commitStandaloneTextScale({ target: e }), qe({ object: e }), e.set({
|
|
7550
7554
|
id: `${e.type}-${D()}`,
|
|
7551
7555
|
evented: !0
|
|
7552
7556
|
}), n.add(e), e));
|
|
@@ -7614,22 +7618,22 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
7614
7618
|
naturalHeight: 0,
|
|
7615
7619
|
width: 0,
|
|
7616
7620
|
height: 0
|
|
7617
|
-
}, m =
|
|
7621
|
+
}, m = W({
|
|
7618
7622
|
value: u || f || c.width,
|
|
7619
7623
|
fallback: 0
|
|
7620
|
-
}), h =
|
|
7624
|
+
}), h = W({
|
|
7621
7625
|
value: d || p || c.height,
|
|
7622
7626
|
fallback: 0
|
|
7623
|
-
}), g =
|
|
7627
|
+
}), g = W({
|
|
7624
7628
|
value: r,
|
|
7625
7629
|
fallback: m
|
|
7626
|
-
}), _ =
|
|
7630
|
+
}), _ = W({
|
|
7627
7631
|
value: i,
|
|
7628
7632
|
fallback: h
|
|
7629
|
-
}), v =
|
|
7633
|
+
}), v = W({
|
|
7630
7634
|
value: a,
|
|
7631
7635
|
fallback: c.scaleX || 1
|
|
7632
|
-
}), y =
|
|
7636
|
+
}), y = W({
|
|
7633
7637
|
value: o,
|
|
7634
7638
|
fallback: c.scaleY || 1
|
|
7635
7639
|
}), b = g * v, x = _ * y, S = m > 0, C = h > 0, w = b > 0, T = x > 0, E = t._resolveImageFit({ customData: s }), D = {};
|
|
@@ -7696,18 +7700,18 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
7696
7700
|
}
|
|
7697
7701
|
}
|
|
7698
7702
|
_transformObject({ object: e, scale: n, bounds: r, baseWidth: i, baseHeight: a, useRelativePositions: o }) {
|
|
7699
|
-
let s = e, { x: c, y: l } =
|
|
7703
|
+
let s = e, { x: c, y: l } = Ge({
|
|
7700
7704
|
object: e,
|
|
7701
7705
|
baseWidth: i,
|
|
7702
7706
|
baseHeight: a,
|
|
7703
7707
|
useRelativePositions: o
|
|
7704
|
-
}), { scaleX: u, scaleY: d } = e, f =
|
|
7708
|
+
}), { scaleX: u, scaleY: d } = e, f = W({
|
|
7705
7709
|
value: u,
|
|
7706
7710
|
fallback: 1
|
|
7707
|
-
}), p =
|
|
7711
|
+
}), p = W({
|
|
7708
7712
|
value: d,
|
|
7709
7713
|
fallback: 1
|
|
7710
|
-
}), m =
|
|
7714
|
+
}), m = Ke({
|
|
7711
7715
|
normalizedX: c,
|
|
7712
7716
|
normalizedY: l,
|
|
7713
7717
|
bounds: t._getPositioningBounds({
|
|
@@ -7783,13 +7787,13 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
7783
7787
|
if (!(e instanceof _)) return;
|
|
7784
7788
|
let r = typeof e.text == "string" ? e.text : "";
|
|
7785
7789
|
if (!r) return;
|
|
7786
|
-
let i =
|
|
7790
|
+
let i = W({
|
|
7787
7791
|
value: this.editor?.montageArea?.width,
|
|
7788
7792
|
fallback: 0
|
|
7789
|
-
}), { width: a = 0 } = e, o =
|
|
7793
|
+
}), { width: a = 0 } = e, o = W({
|
|
7790
7794
|
value: n,
|
|
7791
7795
|
fallback: 0
|
|
7792
|
-
}), s =
|
|
7796
|
+
}), s = W({
|
|
7793
7797
|
value: a,
|
|
7794
7798
|
fallback: 0
|
|
7795
7799
|
});
|
|
@@ -7814,7 +7818,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
7814
7818
|
return i;
|
|
7815
7819
|
}
|
|
7816
7820
|
_serializeObject({ object: e, bounds: n, baseWidth: r, baseHeight: i }) {
|
|
7817
|
-
let a = e.toDatalessObject([...
|
|
7821
|
+
let a = e.toDatalessObject([...oe]);
|
|
7818
7822
|
if (t._isSvgObject(e)) {
|
|
7819
7823
|
let n = t._extractSvgMarkup(e);
|
|
7820
7824
|
n && (a.svgMarkup = n, delete a.objects, delete a.path);
|
|
@@ -8691,7 +8695,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
8691
8695
|
target: n,
|
|
8692
8696
|
transform: i
|
|
8693
8697
|
}), !this.anchors.vertical.length && !this.anchors.horizontal.length && this._cacheAnchors({ activeObject: n });
|
|
8694
|
-
let a =
|
|
8698
|
+
let a = Je({ object: n });
|
|
8695
8699
|
if (!a) {
|
|
8696
8700
|
this._clearSpacingContexts(), this._clearGuides();
|
|
8697
8701
|
return;
|
|
@@ -8706,7 +8710,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
8706
8710
|
n.set({
|
|
8707
8711
|
left: e + l,
|
|
8708
8712
|
top: t + u
|
|
8709
|
-
}), n.setCoords(), a =
|
|
8713
|
+
}), n.setCoords(), a = Je({ object: n }) ?? a;
|
|
8710
8714
|
}
|
|
8711
8715
|
let d = this._resolveCurrentTargetBounds({ activeObject: n }), f = this.spacingContexts.vertical || this.spacingContexts.horizontal ? 10 / s : c, p = hi({
|
|
8712
8716
|
activeBounds: a,
|
|
@@ -8723,13 +8727,13 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
8723
8727
|
n.set({
|
|
8724
8728
|
left: e + p.deltaX,
|
|
8725
8729
|
top: t + p.deltaY
|
|
8726
|
-
}), n.setCoords(), a =
|
|
8730
|
+
}), n.setCoords(), a = Je({ object: n }) ?? a;
|
|
8727
8731
|
}
|
|
8728
8732
|
m || e._applyMovementStep({
|
|
8729
8733
|
target: n,
|
|
8730
8734
|
transform: i
|
|
8731
8735
|
});
|
|
8732
|
-
let h =
|
|
8736
|
+
let h = Je({ object: n }) ?? a, g = fi({
|
|
8733
8737
|
activeBounds: h,
|
|
8734
8738
|
threshold: c,
|
|
8735
8739
|
anchors: this.anchors
|
|
@@ -8773,7 +8777,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
8773
8777
|
}
|
|
8774
8778
|
let { anchors: l } = this, { vertical: u, horizontal: d } = l;
|
|
8775
8779
|
!u.length && !d.length && this._cacheAnchors({ activeObject: n });
|
|
8776
|
-
let f =
|
|
8780
|
+
let f = Je({ object: n });
|
|
8777
8781
|
if (!f) {
|
|
8778
8782
|
this._clearGuides();
|
|
8779
8783
|
return;
|
|
@@ -8897,7 +8901,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
8897
8901
|
}
|
|
8898
8902
|
let { anchors: a } = this, { vertical: o, horizontal: s } = a;
|
|
8899
8903
|
!o.length && !s.length && this._cacheAnchors({ activeObject: t });
|
|
8900
|
-
let c =
|
|
8904
|
+
let c = Je({ object: t });
|
|
8901
8905
|
if (!c) {
|
|
8902
8906
|
this._clearGuides();
|
|
8903
8907
|
return;
|
|
@@ -9144,7 +9148,8 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
9144
9148
|
return !Number.isFinite(a) || a <= 0 ? null : Math.max(1, Math.round(a));
|
|
9145
9149
|
}
|
|
9146
9150
|
static _shouldApplyPixelScalingStep({ target: e }) {
|
|
9147
|
-
|
|
9151
|
+
let t = typeof e.type == "string" ? e.type.toLowerCase() : "", n = e instanceof _ || t === "textbox" || t === "background-textbox";
|
|
9152
|
+
return !(e instanceof a) && !n;
|
|
9148
9153
|
}
|
|
9149
9154
|
static _applyMovementStep({ target: e, transform: t }) {
|
|
9150
9155
|
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 = {};
|
|
@@ -9175,13 +9180,13 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
9175
9180
|
horizontal: []
|
|
9176
9181
|
}, r = [];
|
|
9177
9182
|
for (let e of t) {
|
|
9178
|
-
let t =
|
|
9183
|
+
let t = Je({ object: e });
|
|
9179
9184
|
t && (yi({
|
|
9180
9185
|
anchors: n,
|
|
9181
9186
|
bounds: t
|
|
9182
9187
|
}), r.push(t));
|
|
9183
9188
|
}
|
|
9184
|
-
let { montageArea: i } = this.editor, a =
|
|
9189
|
+
let { montageArea: i } = this.editor, a = Je({ object: i });
|
|
9185
9190
|
if (a) {
|
|
9186
9191
|
yi({
|
|
9187
9192
|
anchors: n,
|
|
@@ -9209,7 +9214,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
9209
9214
|
_resolveCurrentTargetBounds({ activeObject: e }) {
|
|
9210
9215
|
let t = this._collectTargets({ activeObject: e }), n = [];
|
|
9211
9216
|
for (let e of t) {
|
|
9212
|
-
let t =
|
|
9217
|
+
let t = Je({ object: e });
|
|
9213
9218
|
t && n.push(t);
|
|
9214
9219
|
}
|
|
9215
9220
|
return n;
|
|
@@ -9287,7 +9292,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
9287
9292
|
this._clearGuides();
|
|
9288
9293
|
return;
|
|
9289
9294
|
}
|
|
9290
|
-
let a =
|
|
9295
|
+
let a = Je({ object: i });
|
|
9291
9296
|
if (!a) {
|
|
9292
9297
|
this._clearGuides();
|
|
9293
9298
|
return;
|
|
@@ -9295,7 +9300,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
9295
9300
|
let o = e._resolveTarget({
|
|
9296
9301
|
event: t,
|
|
9297
9302
|
activeObject: i
|
|
9298
|
-
}), { montageArea: s } = r, c = o ?? s, l = c === s, u =
|
|
9303
|
+
}), { montageArea: s } = r, c = o ?? s, l = c === s, u = Je({ object: c });
|
|
9299
9304
|
if (!u) {
|
|
9300
9305
|
this._clearGuides();
|
|
9301
9306
|
return;
|
|
@@ -9469,7 +9474,7 @@ var Vn = ({ group: e, shape: t, text: n, width: r, height: i, padding: a, alignH
|
|
|
9469
9474
|
}
|
|
9470
9475
|
async init() {
|
|
9471
9476
|
let { editorContainerWidth: e, editorContainerHeight: n, canvasWrapperWidth: r, canvasWrapperHeight: i, canvasCSSWidth: a, canvasCSSHeight: o, initialImage: s, initialState: c, scaleType: l, showRotationAngle: u, _onReadyCallback: d } = this.options;
|
|
9472
|
-
if (z.apply(), this.canvas = new t(this.containerId, this.options), this.moduleLoader = new A(), this.workerManager = new M(), this.errorManager = new tr({ editor: this }), this.historyManager = new
|
|
9477
|
+
if (z.apply(), this.canvas = new t(this.containerId, this.options), this.moduleLoader = new A(), this.workerManager = new M(), this.errorManager = new tr({ editor: this }), this.historyManager = new je({ editor: this }), this.toolbar = new ae({ editor: this }), this.transformManager = new He({ editor: this }), this.zoomManager = new Ue({ editor: this }), this.canvasManager = new Ve({ editor: this }), this.imageManager = new Le({ editor: this }), this.layerManager = new $e({ editor: this }), this.shapeManager = new Jn({ editor: this }), this.interactionBlocker = new Ze({ editor: this }), this.backgroundManager = new Qe({ editor: this }), this.clipboardManager = new Yn({ editor: this }), this.objectLockManager = new Xn({ editor: this }), this.groupingManager = new Zn({ editor: this }), this.selectionManager = new Qn({ editor: this }), this.deletionManager = new $n({ editor: this }), this.panConstraintManager = new nr({ editor: this }), this.snappingManager = new Ti({ editor: this }), this.measurementManager = new Di({ editor: this }), this.fontManager = new ie(this.options.fonts ?? []), this.textManager = new Mr({ editor: this }), this.templateManager = new Lr({ editor: this }), u && (this.angleIndicator = new U({ editor: this })), this._createMontageArea(), this._createClippingArea(), this.interactionBlocker.ensureOverlay(), this.listeners = new k({
|
|
9473
9478
|
editor: this,
|
|
9474
9479
|
options: this.options
|
|
9475
9480
|
}), this.canvasManager.setEditorContainerWidth(e), this.canvasManager.setEditorContainerHeight(n), this.canvasManager.setCanvasWrapperWidth(r), this.canvasManager.setCanvasWrapperHeight(i), this.canvasManager.setCanvasCSSWidth(a), this.canvasManager.setCanvasCSSHeight(o), this.canvasManager.updateCanvas(), this.zoomManager.calculateAndApplyDefaultZoom(), await this.fontManager.loadFonts(), c) {
|