@1urso/generic-editor 0.1.38 → 0.1.39
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/editor/context.d.ts +18 -0
- package/dist/generic-editor.js +451 -226
- package/dist/generic-editor.umd.cjs +5 -5
- package/package.json +1 -1
package/dist/generic-editor.js
CHANGED
|
@@ -8644,7 +8644,13 @@ const EditorProvider = ({ children: n, isList: E = !1, availableProps: O = [], t
|
|
|
8644
8644
|
history: [[]],
|
|
8645
8645
|
historyIndex: 0,
|
|
8646
8646
|
clipboard: [],
|
|
8647
|
-
gridSize: 0
|
|
8647
|
+
gridSize: 0,
|
|
8648
|
+
zoom: 1,
|
|
8649
|
+
pan: {
|
|
8650
|
+
x: 0,
|
|
8651
|
+
y: 0
|
|
8652
|
+
},
|
|
8653
|
+
snapLines: []
|
|
8648
8654
|
});
|
|
8649
8655
|
React.useEffect(() => {
|
|
8650
8656
|
j.availableFonts.forEach((n) => {
|
|
@@ -8678,6 +8684,21 @@ const EditorProvider = ({ children: n, isList: E = !1, availableProps: O = [], t
|
|
|
8678
8684
|
gridSize: n
|
|
8679
8685
|
}));
|
|
8680
8686
|
}, []), z = React.useCallback((n) => {
|
|
8687
|
+
M((_) => ({
|
|
8688
|
+
..._,
|
|
8689
|
+
zoom: n
|
|
8690
|
+
}));
|
|
8691
|
+
}, []), B = React.useCallback((n) => {
|
|
8692
|
+
M((_) => ({
|
|
8693
|
+
..._,
|
|
8694
|
+
pan: n
|
|
8695
|
+
}));
|
|
8696
|
+
}, []), H = React.useCallback((n) => {
|
|
8697
|
+
M((_) => ({
|
|
8698
|
+
..._,
|
|
8699
|
+
snapLines: n
|
|
8700
|
+
}));
|
|
8701
|
+
}, []), U = React.useCallback((n) => {
|
|
8681
8702
|
M((_) => {
|
|
8682
8703
|
let E = n.elements || _.elements;
|
|
8683
8704
|
return {
|
|
@@ -8692,7 +8713,7 @@ const EditorProvider = ({ children: n, isList: E = !1, availableProps: O = [], t
|
|
|
8692
8713
|
clipboard: []
|
|
8693
8714
|
};
|
|
8694
8715
|
});
|
|
8695
|
-
}, []),
|
|
8716
|
+
}, []), W = React.useCallback(() => {
|
|
8696
8717
|
M((n) => {
|
|
8697
8718
|
if (n.historyIndex > 0) {
|
|
8698
8719
|
let _ = n.historyIndex - 1;
|
|
@@ -8705,7 +8726,7 @@ const EditorProvider = ({ children: n, isList: E = !1, availableProps: O = [], t
|
|
|
8705
8726
|
}
|
|
8706
8727
|
return n;
|
|
8707
8728
|
});
|
|
8708
|
-
}, []),
|
|
8729
|
+
}, []), G = React.useCallback(() => {
|
|
8709
8730
|
M((n) => {
|
|
8710
8731
|
if (n.historyIndex < n.history.length - 1) {
|
|
8711
8732
|
let _ = n.historyIndex + 1;
|
|
@@ -8718,7 +8739,7 @@ const EditorProvider = ({ children: n, isList: E = !1, availableProps: O = [], t
|
|
|
8718
8739
|
}
|
|
8719
8740
|
return n;
|
|
8720
8741
|
});
|
|
8721
|
-
}, []),
|
|
8742
|
+
}, []), Z = React.useCallback(() => {
|
|
8722
8743
|
M((n) => {
|
|
8723
8744
|
if (n.selectedElementIds.length > 0) {
|
|
8724
8745
|
let _ = n.elements.filter((_) => n.selectedElementIds.includes(_.id));
|
|
@@ -8729,7 +8750,7 @@ const EditorProvider = ({ children: n, isList: E = !1, availableProps: O = [], t
|
|
|
8729
8750
|
}
|
|
8730
8751
|
return n;
|
|
8731
8752
|
});
|
|
8732
|
-
}, []),
|
|
8753
|
+
}, []), Lj = React.useCallback(() => {
|
|
8733
8754
|
M((n) => {
|
|
8734
8755
|
if (n.clipboard.length > 0) {
|
|
8735
8756
|
let _ = n.clipboard.map((n) => ({
|
|
@@ -8748,7 +8769,7 @@ const EditorProvider = ({ children: n, isList: E = !1, availableProps: O = [], t
|
|
|
8748
8769
|
}
|
|
8749
8770
|
return n;
|
|
8750
8771
|
});
|
|
8751
|
-
}, []),
|
|
8772
|
+
}, []), Rj = React.useCallback((n) => {
|
|
8752
8773
|
let _ = {};
|
|
8753
8774
|
n.type === "box" && (_.backgroundColor = "var(--gray-4)");
|
|
8754
8775
|
let E = {
|
|
@@ -8773,7 +8794,7 @@ const EditorProvider = ({ children: n, isList: E = !1, availableProps: O = [], t
|
|
|
8773
8794
|
selectedElementIds: [E.id]
|
|
8774
8795
|
};
|
|
8775
8796
|
});
|
|
8776
|
-
}, []),
|
|
8797
|
+
}, []), zj = React.useCallback((n) => {
|
|
8777
8798
|
M((_) => {
|
|
8778
8799
|
let E = _.elements.filter((_) => _.id !== n), O = _.history.slice(0, _.historyIndex + 1);
|
|
8779
8800
|
return O.push(E), {
|
|
@@ -8784,7 +8805,7 @@ const EditorProvider = ({ children: n, isList: E = !1, availableProps: O = [], t
|
|
|
8784
8805
|
historyIndex: O.length - 1
|
|
8785
8806
|
};
|
|
8786
8807
|
});
|
|
8787
|
-
}, []),
|
|
8808
|
+
}, []), Bj = React.useCallback(() => {
|
|
8788
8809
|
M((n) => {
|
|
8789
8810
|
if (n.selectedElementIds.length === 0) return n;
|
|
8790
8811
|
let _ = n.elements.filter((_) => !n.selectedElementIds.includes(_.id)), E = n.history.slice(0, n.historyIndex + 1);
|
|
@@ -8796,7 +8817,7 @@ const EditorProvider = ({ children: n, isList: E = !1, availableProps: O = [], t
|
|
|
8796
8817
|
historyIndex: E.length - 1
|
|
8797
8818
|
};
|
|
8798
8819
|
});
|
|
8799
|
-
}, []),
|
|
8820
|
+
}, []), Hj = React.useCallback((n, _ = !1) => {
|
|
8800
8821
|
M((E) => {
|
|
8801
8822
|
if (n === null) return {
|
|
8802
8823
|
...E,
|
|
@@ -8813,12 +8834,12 @@ const EditorProvider = ({ children: n, isList: E = !1, availableProps: O = [], t
|
|
|
8813
8834
|
selectedElementIds: [n]
|
|
8814
8835
|
};
|
|
8815
8836
|
});
|
|
8816
|
-
}, []),
|
|
8837
|
+
}, []), Uj = React.useCallback((n) => {
|
|
8817
8838
|
M((_) => ({
|
|
8818
8839
|
..._,
|
|
8819
8840
|
selectedElementIds: n
|
|
8820
8841
|
}));
|
|
8821
|
-
}, []),
|
|
8842
|
+
}, []), Wj = React.useCallback((n, _) => {
|
|
8822
8843
|
M((E) => {
|
|
8823
8844
|
let O = [...E.elements], A = O[n];
|
|
8824
8845
|
O.splice(n, 1), O.splice(_, 0, A);
|
|
@@ -8830,7 +8851,7 @@ const EditorProvider = ({ children: n, isList: E = !1, availableProps: O = [], t
|
|
|
8830
8851
|
historyIndex: j.length - 1
|
|
8831
8852
|
};
|
|
8832
8853
|
});
|
|
8833
|
-
}, []),
|
|
8854
|
+
}, []), Gj = React.useCallback((n, _, E = !0) => {
|
|
8834
8855
|
M((O) => {
|
|
8835
8856
|
let A = O.elements.map((E) => E.id === n ? {
|
|
8836
8857
|
...E,
|
|
@@ -8843,7 +8864,7 @@ const EditorProvider = ({ children: n, isList: E = !1, availableProps: O = [], t
|
|
|
8843
8864
|
historyIndex: M
|
|
8844
8865
|
};
|
|
8845
8866
|
});
|
|
8846
|
-
}, []),
|
|
8867
|
+
}, []), qj = React.useCallback((n, _ = !0) => {
|
|
8847
8868
|
M((E) => {
|
|
8848
8869
|
let O = [...E.elements], A = [], j = /* @__PURE__ */ new Set();
|
|
8849
8870
|
n.forEach(({ id: n, changes: _ }) => {
|
|
@@ -8897,7 +8918,7 @@ const EditorProvider = ({ children: n, isList: E = !1, availableProps: O = [], t
|
|
|
8897
8918
|
historyIndex: P
|
|
8898
8919
|
};
|
|
8899
8920
|
});
|
|
8900
|
-
}, []),
|
|
8921
|
+
}, []), Jj = React.useCallback((n) => {
|
|
8901
8922
|
M((_) => {
|
|
8902
8923
|
let E = _.elements.filter((_) => n.includes(_.id));
|
|
8903
8924
|
if (E.length === 0) return _;
|
|
@@ -8925,7 +8946,7 @@ const EditorProvider = ({ children: n, isList: E = !1, availableProps: O = [], t
|
|
|
8925
8946
|
historyIndex: z.length - 1
|
|
8926
8947
|
};
|
|
8927
8948
|
});
|
|
8928
|
-
}, []),
|
|
8949
|
+
}, []), Yj = React.useCallback((n) => {
|
|
8929
8950
|
M((_) => {
|
|
8930
8951
|
let E = _.elements.find((_) => _.id === n);
|
|
8931
8952
|
if (!E || E.type !== "group") return _;
|
|
@@ -8941,7 +8962,7 @@ const EditorProvider = ({ children: n, isList: E = !1, availableProps: O = [], t
|
|
|
8941
8962
|
historyIndex: j.length - 1
|
|
8942
8963
|
};
|
|
8943
8964
|
});
|
|
8944
|
-
}, []),
|
|
8965
|
+
}, []), Xj = React.useCallback((n, _) => {
|
|
8945
8966
|
M((E) => {
|
|
8946
8967
|
let O = E.elements.map((E) => E.id === n ? {
|
|
8947
8968
|
...E,
|
|
@@ -8952,7 +8973,7 @@ const EditorProvider = ({ children: n, isList: E = !1, availableProps: O = [], t
|
|
|
8952
8973
|
elements: O
|
|
8953
8974
|
};
|
|
8954
8975
|
});
|
|
8955
|
-
}, []),
|
|
8976
|
+
}, []), Zj = React.useCallback((n, _) => {
|
|
8956
8977
|
if (!n.find((n) => n.id === _ && n.type === "group")) return n;
|
|
8957
8978
|
let E = n.filter((n) => n.groupId === _);
|
|
8958
8979
|
if (E.length === 0) return n;
|
|
@@ -8964,7 +8985,7 @@ const EditorProvider = ({ children: n, isList: E = !1, availableProps: O = [], t
|
|
|
8964
8985
|
width: j - O,
|
|
8965
8986
|
height: M - A
|
|
8966
8987
|
} : n);
|
|
8967
|
-
}, []),
|
|
8988
|
+
}, []), Qj = React.useCallback((n, _) => {
|
|
8968
8989
|
M((E) => {
|
|
8969
8990
|
let O = E.elements.find((_) => _.id === n), A = E.elements.find((n) => n.id === _ && n.type === "group");
|
|
8970
8991
|
if (!O || !A) return E;
|
|
@@ -8972,7 +8993,7 @@ const EditorProvider = ({ children: n, isList: E = !1, availableProps: O = [], t
|
|
|
8972
8993
|
...E,
|
|
8973
8994
|
groupId: _
|
|
8974
8995
|
} : E);
|
|
8975
|
-
j =
|
|
8996
|
+
j = Zj(j, _);
|
|
8976
8997
|
let M = E.history.slice(0, E.historyIndex + 1);
|
|
8977
8998
|
return M.push(j), {
|
|
8978
8999
|
...E,
|
|
@@ -8981,7 +9002,7 @@ const EditorProvider = ({ children: n, isList: E = !1, availableProps: O = [], t
|
|
|
8981
9002
|
historyIndex: M.length - 1
|
|
8982
9003
|
};
|
|
8983
9004
|
});
|
|
8984
|
-
}, [
|
|
9005
|
+
}, [Zj]), $j = React.useCallback((n) => {
|
|
8985
9006
|
M((_) => {
|
|
8986
9007
|
let E = _.elements.find((_) => _.id === n);
|
|
8987
9008
|
if (!E || !E.groupId) return _;
|
|
@@ -8989,7 +9010,7 @@ const EditorProvider = ({ children: n, isList: E = !1, availableProps: O = [], t
|
|
|
8989
9010
|
..._,
|
|
8990
9011
|
groupId: void 0
|
|
8991
9012
|
} : _);
|
|
8992
|
-
A =
|
|
9013
|
+
A = Zj(A, O);
|
|
8993
9014
|
let j = _.history.slice(0, _.historyIndex + 1);
|
|
8994
9015
|
return j.push(A), {
|
|
8995
9016
|
..._,
|
|
@@ -8998,7 +9019,7 @@ const EditorProvider = ({ children: n, isList: E = !1, availableProps: O = [], t
|
|
|
8998
9019
|
historyIndex: j.length - 1
|
|
8999
9020
|
};
|
|
9000
9021
|
});
|
|
9001
|
-
}, [
|
|
9022
|
+
}, [Zj]), eM = React.useCallback((n, _, E) => {
|
|
9002
9023
|
M((O) => {
|
|
9003
9024
|
let A = O.elements.find((_) => _.id === n && _.type === "group");
|
|
9004
9025
|
if (!A) return O;
|
|
@@ -9027,13 +9048,13 @@ const EditorProvider = ({ children: n, isList: E = !1, availableProps: O = [], t
|
|
|
9027
9048
|
historyIndex: B.length - 1
|
|
9028
9049
|
};
|
|
9029
9050
|
});
|
|
9030
|
-
}, []),
|
|
9051
|
+
}, []), tM = React.useCallback((n, _) => {
|
|
9031
9052
|
M((E) => ({
|
|
9032
9053
|
...E,
|
|
9033
9054
|
mockData: n,
|
|
9034
9055
|
singleMockData: _
|
|
9035
9056
|
}));
|
|
9036
|
-
}, []),
|
|
9057
|
+
}, []), nM = React.useCallback((n) => {
|
|
9037
9058
|
M((_) => ({
|
|
9038
9059
|
..._,
|
|
9039
9060
|
listSettings: {
|
|
@@ -9041,36 +9062,36 @@ const EditorProvider = ({ children: n, isList: E = !1, availableProps: O = [], t
|
|
|
9041
9062
|
...n
|
|
9042
9063
|
}
|
|
9043
9064
|
}));
|
|
9044
|
-
}, []),
|
|
9065
|
+
}, []), rM = React.useMemo(() => ({
|
|
9045
9066
|
state: j,
|
|
9046
|
-
addElement:
|
|
9047
|
-
removeElement:
|
|
9048
|
-
removeSelected:
|
|
9049
|
-
selectElement:
|
|
9050
|
-
setSelectedElements:
|
|
9051
|
-
moveElement:
|
|
9052
|
-
updateElement:
|
|
9053
|
-
updateElements:
|
|
9054
|
-
groupElements:
|
|
9055
|
-
ungroupElements:
|
|
9056
|
-
renameElement:
|
|
9057
|
-
addToGroup:
|
|
9058
|
-
removeFromGroup:
|
|
9059
|
-
resizeGroup:
|
|
9060
|
-
setMockData:
|
|
9061
|
-
updateListSettings:
|
|
9067
|
+
addElement: Rj,
|
|
9068
|
+
removeElement: zj,
|
|
9069
|
+
removeSelected: Bj,
|
|
9070
|
+
selectElement: Hj,
|
|
9071
|
+
setSelectedElements: Uj,
|
|
9072
|
+
moveElement: Wj,
|
|
9073
|
+
updateElement: Gj,
|
|
9074
|
+
updateElements: qj,
|
|
9075
|
+
groupElements: Jj,
|
|
9076
|
+
ungroupElements: Yj,
|
|
9077
|
+
renameElement: Xj,
|
|
9078
|
+
addToGroup: Qj,
|
|
9079
|
+
removeFromGroup: $j,
|
|
9080
|
+
resizeGroup: eM,
|
|
9081
|
+
setMockData: tM,
|
|
9082
|
+
updateListSettings: nM,
|
|
9062
9083
|
setCanvasHeight: N,
|
|
9063
|
-
loadState:
|
|
9064
|
-
undo:
|
|
9065
|
-
redo:
|
|
9066
|
-
copy:
|
|
9067
|
-
paste:
|
|
9068
|
-
setGridSize: P
|
|
9084
|
+
loadState: U,
|
|
9085
|
+
undo: W,
|
|
9086
|
+
redo: G,
|
|
9087
|
+
copy: Z,
|
|
9088
|
+
paste: Lj,
|
|
9089
|
+
setGridSize: P,
|
|
9090
|
+
setZoom: z,
|
|
9091
|
+
setPan: B,
|
|
9092
|
+
setSnapLines: H
|
|
9069
9093
|
}), [
|
|
9070
9094
|
j,
|
|
9071
|
-
G,
|
|
9072
|
-
Z,
|
|
9073
|
-
Lj,
|
|
9074
9095
|
Rj,
|
|
9075
9096
|
zj,
|
|
9076
9097
|
Bj,
|
|
@@ -9079,21 +9100,27 @@ const EditorProvider = ({ children: n, isList: E = !1, availableProps: O = [], t
|
|
|
9079
9100
|
Wj,
|
|
9080
9101
|
Gj,
|
|
9081
9102
|
qj,
|
|
9103
|
+
Jj,
|
|
9082
9104
|
Yj,
|
|
9083
9105
|
Xj,
|
|
9084
|
-
Zj,
|
|
9085
9106
|
Qj,
|
|
9086
9107
|
$j,
|
|
9108
|
+
eM,
|
|
9109
|
+
tM,
|
|
9110
|
+
nM,
|
|
9087
9111
|
N,
|
|
9088
|
-
z,
|
|
9089
|
-
B,
|
|
9090
|
-
H,
|
|
9091
9112
|
U,
|
|
9092
9113
|
W,
|
|
9093
|
-
|
|
9114
|
+
G,
|
|
9115
|
+
Z,
|
|
9116
|
+
Lj,
|
|
9117
|
+
P,
|
|
9118
|
+
z,
|
|
9119
|
+
B,
|
|
9120
|
+
H
|
|
9094
9121
|
]);
|
|
9095
9122
|
return /* @__PURE__ */ jsx(EditorContext.Provider, {
|
|
9096
|
-
value:
|
|
9123
|
+
value: rM,
|
|
9097
9124
|
children: n
|
|
9098
9125
|
});
|
|
9099
9126
|
}, useEditor = () => {
|
|
@@ -11838,55 +11865,55 @@ const ElementContextMenu = ({ children: n, element: _ }) => {
|
|
|
11838
11865
|
}) })] })
|
|
11839
11866
|
] });
|
|
11840
11867
|
}, DraggableElement = React.memo(({ element: n, isSelected: _ }) => {
|
|
11841
|
-
let { selectElement: E, updateElement: O, updateElements: A, state: j, resizeGroup: M } = useEditor(), [
|
|
11868
|
+
let { selectElement: E, updateElement: O, updateElements: A, state: j, resizeGroup: M, setSnapLines: N } = useEditor(), [P, z] = useState(!1), [B, H] = useState(!1), U = useRef({
|
|
11842
11869
|
x: 0,
|
|
11843
11870
|
y: 0
|
|
11844
|
-
}),
|
|
11871
|
+
}), G = useRef({}), Z = useRef(!1), Lj = useRef(!1), Rj = useRef(0), zj = useRef(0), Hj = useRef({
|
|
11845
11872
|
x: 0,
|
|
11846
11873
|
y: 0
|
|
11847
|
-
}),
|
|
11848
|
-
if (
|
|
11849
|
-
if (n.type === "text")
|
|
11850
|
-
let O =
|
|
11874
|
+
}), Uj = useRef(!1), Wj = j.canvasHeight || 150, Gj = j.isList ? j.mockData.length > 0 ? j.mockData[0] : null : j.singleMockData, Jj = n.content, Yj = {};
|
|
11875
|
+
if (Gj) {
|
|
11876
|
+
if (n.type === "text") Jj = Jj.replace(/\{\{(.*?)\}\}/g, (_, E) => {
|
|
11877
|
+
let O = Gj[E.trim()];
|
|
11851
11878
|
return O == null ? _ : n.formatting ? formatValue(O, n.formatting) : String(O);
|
|
11852
11879
|
});
|
|
11853
11880
|
else if (n.type === "image") if (n.dataBinding) {
|
|
11854
|
-
let _ =
|
|
11855
|
-
_ != null && (
|
|
11856
|
-
} else
|
|
11857
|
-
let E =
|
|
11881
|
+
let _ = Gj[n.dataBinding];
|
|
11882
|
+
_ != null && (Jj = String(_));
|
|
11883
|
+
} else Jj = Jj.replace(/\{\{(.*?)\}\}/g, (n, _) => {
|
|
11884
|
+
let E = Gj[_.trim()];
|
|
11858
11885
|
return E == null ? n : String(E);
|
|
11859
11886
|
});
|
|
11860
11887
|
n.styleBindings && Object.entries(n.styleBindings).forEach(([n, _]) => {
|
|
11861
|
-
let E =
|
|
11862
|
-
E != null && (
|
|
11863
|
-
...
|
|
11888
|
+
let E = Gj[_];
|
|
11889
|
+
E != null && (Yj = {
|
|
11890
|
+
...Yj,
|
|
11864
11891
|
[n]: String(E)
|
|
11865
11892
|
});
|
|
11866
11893
|
}), n.conditions && n.conditions.forEach((n) => {
|
|
11867
|
-
let _ =
|
|
11868
|
-
checkCondition(_, n.operator, n.value) && (
|
|
11869
|
-
...
|
|
11894
|
+
let _ = Gj[n.property];
|
|
11895
|
+
checkCondition(_, n.operator, n.value) && (Yj = {
|
|
11896
|
+
...Yj,
|
|
11870
11897
|
...n.style
|
|
11871
11898
|
});
|
|
11872
11899
|
});
|
|
11873
11900
|
}
|
|
11874
|
-
let
|
|
11875
|
-
if (
|
|
11876
|
-
let { display: n, ..._ } =
|
|
11877
|
-
|
|
11901
|
+
let Xj = Yj.display === "none";
|
|
11902
|
+
if (Xj && _) {
|
|
11903
|
+
let { display: n, ..._ } = Yj;
|
|
11904
|
+
Yj = _;
|
|
11878
11905
|
}
|
|
11879
|
-
let
|
|
11880
|
-
_.stopPropagation(), !
|
|
11881
|
-
},
|
|
11906
|
+
let Zj = (_) => {
|
|
11907
|
+
_.stopPropagation(), !Z.current && !Lj.current && !P && (_.shiftKey ? E(n.id, !0) : E(n.id, !1));
|
|
11908
|
+
}, Qj = (O) => {
|
|
11882
11909
|
if (O.button !== 0) return;
|
|
11883
11910
|
O.stopPropagation();
|
|
11884
11911
|
let A = O.shiftKey;
|
|
11885
|
-
if (
|
|
11912
|
+
if (Z.current = !1, Lj.current = !1, n.groupId && !_) {
|
|
11886
11913
|
E(n.groupId, A);
|
|
11887
11914
|
return;
|
|
11888
11915
|
}
|
|
11889
|
-
_ || (E(n.id, A),
|
|
11916
|
+
_ || (E(n.id, A), Lj.current = !0), z(!0), U.current = {
|
|
11890
11917
|
x: O.clientX,
|
|
11891
11918
|
y: O.clientY
|
|
11892
11919
|
};
|
|
@@ -11898,55 +11925,90 @@ const ElementContextMenu = ({ children: n, element: _ }) => {
|
|
|
11898
11925
|
x: n.x,
|
|
11899
11926
|
y: n.y
|
|
11900
11927
|
});
|
|
11901
|
-
}),
|
|
11902
|
-
},
|
|
11903
|
-
_.stopPropagation(), _.preventDefault(),
|
|
11928
|
+
}), G.current = N;
|
|
11929
|
+
}, $j = (_) => {
|
|
11930
|
+
_.stopPropagation(), _.preventDefault(), H(!0);
|
|
11904
11931
|
let E = _.target.closest(".resizable-element");
|
|
11905
11932
|
if (E) {
|
|
11906
11933
|
let O = E.getBoundingClientRect();
|
|
11907
|
-
|
|
11934
|
+
Hj.current = {
|
|
11908
11935
|
x: O.left + O.width / 2,
|
|
11909
11936
|
y: O.top + O.height / 2
|
|
11910
11937
|
};
|
|
11911
|
-
let A = _.clientX -
|
|
11912
|
-
|
|
11938
|
+
let A = _.clientX - Hj.current.x, j = _.clientY - Hj.current.y;
|
|
11939
|
+
Rj.current = Math.atan2(j, A) * (180 / Math.PI), zj.current = n.rotation || 0;
|
|
11913
11940
|
}
|
|
11914
11941
|
};
|
|
11915
11942
|
useEffect(() => {
|
|
11916
11943
|
let _ = (_) => {
|
|
11917
|
-
if (
|
|
11918
|
-
let
|
|
11919
|
-
(Math.abs(
|
|
11920
|
-
|
|
11921
|
-
|
|
11944
|
+
if (P) {
|
|
11945
|
+
let E = j.zoom || 1, O = (_.clientX - U.current.x) / E, M = (_.clientY - U.current.y) / E;
|
|
11946
|
+
(Math.abs(O) > 2 || Math.abs(M) > 2) && (Z.current = !0);
|
|
11947
|
+
let P = 5 / E, z = [], B = Object.entries(G.current).map(([_, E]) => {
|
|
11948
|
+
let A = E.x + O, N = E.y + M;
|
|
11949
|
+
if (j.gridSize > 0) A = Math.round(A / j.gridSize) * j.gridSize, N = Math.round(N / j.gridSize) * j.gridSize;
|
|
11950
|
+
else {
|
|
11951
|
+
let E = !1, O = !1, M = n.width ?? 100, B = n.height ?? 100;
|
|
11952
|
+
Object.keys(G.current).length === 1 && j.elements.forEach((n) => {
|
|
11953
|
+
if (n.id === _) return;
|
|
11954
|
+
let j = n.width ?? 100, H = n.height ?? 100;
|
|
11955
|
+
E || (Math.abs(A - n.x) < P ? (A = n.x, E = !0, z.push({
|
|
11956
|
+
orientation: "vertical",
|
|
11957
|
+
position: n.x
|
|
11958
|
+
})) : Math.abs(A - (n.x + j)) < P ? (A = n.x + j, E = !0, z.push({
|
|
11959
|
+
orientation: "vertical",
|
|
11960
|
+
position: n.x + j
|
|
11961
|
+
})) : Math.abs(A + M - n.x) < P ? (A = n.x - M, E = !0, z.push({
|
|
11962
|
+
orientation: "vertical",
|
|
11963
|
+
position: n.x
|
|
11964
|
+
})) : Math.abs(A + M - (n.x + j)) < P && (A = n.x + j - M, E = !0, z.push({
|
|
11965
|
+
orientation: "vertical",
|
|
11966
|
+
position: n.x + j
|
|
11967
|
+
}))), O || (Math.abs(N - n.y) < P ? (N = n.y, O = !0, z.push({
|
|
11968
|
+
orientation: "horizontal",
|
|
11969
|
+
position: n.y
|
|
11970
|
+
})) : Math.abs(N - (n.y + H)) < P ? (N = n.y + H, O = !0, z.push({
|
|
11971
|
+
orientation: "horizontal",
|
|
11972
|
+
position: n.y + H
|
|
11973
|
+
})) : Math.abs(N + B - n.y) < P ? (N = n.y - B, O = !0, z.push({
|
|
11974
|
+
orientation: "horizontal",
|
|
11975
|
+
position: n.y
|
|
11976
|
+
})) : Math.abs(N + B - (n.y + H)) < P && (N = n.y + H - B, O = !0, z.push({
|
|
11977
|
+
orientation: "horizontal",
|
|
11978
|
+
position: n.y + H
|
|
11979
|
+
})));
|
|
11980
|
+
});
|
|
11981
|
+
}
|
|
11982
|
+
return j.isList && (N = Math.max(0, N)), {
|
|
11922
11983
|
id: _,
|
|
11923
11984
|
changes: {
|
|
11924
11985
|
x: A,
|
|
11925
|
-
y:
|
|
11986
|
+
y: N
|
|
11926
11987
|
}
|
|
11927
11988
|
};
|
|
11928
|
-
})
|
|
11989
|
+
});
|
|
11990
|
+
N && N(z), A(B, !1);
|
|
11929
11991
|
}
|
|
11930
|
-
if (
|
|
11931
|
-
let E = _.clientX -
|
|
11992
|
+
if (B) {
|
|
11993
|
+
let E = _.clientX - Hj.current.x, A = _.clientY - Hj.current.y, j = Math.atan2(A, E) * (180 / Math.PI) - Rj.current, M = (zj.current + j) % 360;
|
|
11932
11994
|
O(n.id, { rotation: M }, !1);
|
|
11933
11995
|
}
|
|
11934
11996
|
}, E = () => {
|
|
11935
|
-
|
|
11997
|
+
P && (z(!1), A([], !0), N && N([])), B && (H(!1), O(n.id, { rotation: n.rotation }, !0));
|
|
11936
11998
|
};
|
|
11937
|
-
return (
|
|
11999
|
+
return (P || B) && (window.addEventListener("mousemove", _), window.addEventListener("mouseup", E)), () => {
|
|
11938
12000
|
window.removeEventListener("mousemove", _), window.removeEventListener("mouseup", E);
|
|
11939
12001
|
};
|
|
11940
12002
|
}, [
|
|
11941
|
-
|
|
11942
|
-
|
|
12003
|
+
P,
|
|
12004
|
+
B,
|
|
11943
12005
|
n.id,
|
|
11944
12006
|
O,
|
|
11945
12007
|
A,
|
|
11946
12008
|
j.isList,
|
|
11947
12009
|
j.selectedElementIds
|
|
11948
12010
|
]);
|
|
11949
|
-
let
|
|
12011
|
+
let eM = {
|
|
11950
12012
|
position: "absolute",
|
|
11951
12013
|
left: 0,
|
|
11952
12014
|
top: 0,
|
|
@@ -11956,14 +12018,14 @@ const ElementContextMenu = ({ children: n, element: _ }) => {
|
|
|
11956
12018
|
padding: n.type === "image" || n.type === "text" ? 0 : "8px",
|
|
11957
12019
|
border: _ ? "2px solid var(--accent-9)" : "1px dashed transparent",
|
|
11958
12020
|
outline: _ ? "none" : "1px solid transparent",
|
|
11959
|
-
cursor:
|
|
12021
|
+
cursor: P ? "grabbing" : "grab",
|
|
11960
12022
|
borderRadius: "var(--radius-2)",
|
|
11961
12023
|
overflow: n.autoGrow ? "visible" : "hidden",
|
|
11962
12024
|
whiteSpace: n.autoGrow ? "pre-wrap" : void 0,
|
|
11963
12025
|
wordBreak: n.autoGrow ? "break-word" : void 0,
|
|
11964
12026
|
userSelect: "none",
|
|
11965
12027
|
...n.style,
|
|
11966
|
-
...
|
|
12028
|
+
...Yj
|
|
11967
12029
|
};
|
|
11968
12030
|
return /* @__PURE__ */ jsx(Resizable, {
|
|
11969
12031
|
className: "resizable-element",
|
|
@@ -11971,9 +12033,9 @@ const ElementContextMenu = ({ children: n, element: _ }) => {
|
|
|
11971
12033
|
width: n.width ?? 100,
|
|
11972
12034
|
height: n.autoGrow ? "auto" : n.height ?? 100
|
|
11973
12035
|
},
|
|
11974
|
-
maxHeight: j.isList ? Math.max(10,
|
|
12036
|
+
maxHeight: j.isList ? Math.max(10, Wj - n.y) : void 0,
|
|
11975
12037
|
onResizeStart: (n) => {
|
|
11976
|
-
|
|
12038
|
+
Uj.current = !!n.shiftKey;
|
|
11977
12039
|
},
|
|
11978
12040
|
onResizeStop: (_, E, A, j) => {
|
|
11979
12041
|
let N = (n.width ?? 100) + j.width, P = (n.height ?? 100) + j.height;
|
|
@@ -11986,8 +12048,8 @@ const ElementContextMenu = ({ children: n, element: _ }) => {
|
|
|
11986
12048
|
position: "absolute",
|
|
11987
12049
|
transform: `translate(${n.x ?? 0}px, ${n.y ?? 0}px) rotate(${n.rotation || 0}deg)`,
|
|
11988
12050
|
height: n.autoGrow ? "auto" : void 0,
|
|
11989
|
-
display:
|
|
11990
|
-
opacity:
|
|
12051
|
+
display: Xj && !_ ? "none" : void 0,
|
|
12052
|
+
opacity: Xj && _ ? .4 : 1
|
|
11991
12053
|
},
|
|
11992
12054
|
enable: _ && !n.autoGrow ? void 0 : {
|
|
11993
12055
|
top: !1,
|
|
@@ -11999,7 +12061,7 @@ const ElementContextMenu = ({ children: n, element: _ }) => {
|
|
|
11999
12061
|
bottomLeft: !1,
|
|
12000
12062
|
topLeft: !1
|
|
12001
12063
|
},
|
|
12002
|
-
lockAspectRatio:
|
|
12064
|
+
lockAspectRatio: Uj.current === !0,
|
|
12003
12065
|
grid: j.gridSize > 0 ? [j.gridSize, j.gridSize] : void 0,
|
|
12004
12066
|
children: /* @__PURE__ */ jsx(ElementContextMenu, {
|
|
12005
12067
|
element: n,
|
|
@@ -12010,9 +12072,9 @@ const ElementContextMenu = ({ children: n, element: _ }) => {
|
|
|
12010
12072
|
position: "relative"
|
|
12011
12073
|
},
|
|
12012
12074
|
children: [/* @__PURE__ */ jsxs(p, {
|
|
12013
|
-
style:
|
|
12014
|
-
onMouseDown:
|
|
12015
|
-
onClick:
|
|
12075
|
+
style: eM,
|
|
12076
|
+
onMouseDown: Qj,
|
|
12077
|
+
onClick: Zj,
|
|
12016
12078
|
title: n.name,
|
|
12017
12079
|
onMouseEnter: (n) => {
|
|
12018
12080
|
_ || (n.currentTarget.style.borderColor = "var(--gray-6)");
|
|
@@ -12026,10 +12088,10 @@ const ElementContextMenu = ({ children: n, element: _ }) => {
|
|
|
12026
12088
|
width: "100%",
|
|
12027
12089
|
height: "100%"
|
|
12028
12090
|
},
|
|
12029
|
-
children:
|
|
12091
|
+
children: Jj
|
|
12030
12092
|
}),
|
|
12031
|
-
n.type === "image" && (
|
|
12032
|
-
src:
|
|
12093
|
+
n.type === "image" && (Jj ? /* @__PURE__ */ jsx("img", {
|
|
12094
|
+
src: Jj,
|
|
12033
12095
|
alt: "Element",
|
|
12034
12096
|
style: {
|
|
12035
12097
|
width: "100%",
|
|
@@ -12094,7 +12156,7 @@ const ElementContextMenu = ({ children: n, element: _ }) => {
|
|
|
12094
12156
|
zIndex: 50,
|
|
12095
12157
|
boxShadow: "0 0 0 2px white"
|
|
12096
12158
|
},
|
|
12097
|
-
onMouseDown:
|
|
12159
|
+
onMouseDown: $j,
|
|
12098
12160
|
children: /* @__PURE__ */ jsx(p, { style: {
|
|
12099
12161
|
position: "absolute",
|
|
12100
12162
|
top: 12,
|
|
@@ -12109,53 +12171,131 @@ const ElementContextMenu = ({ children: n, element: _ }) => {
|
|
|
12109
12171
|
})
|
|
12110
12172
|
});
|
|
12111
12173
|
}), Canvas = () => {
|
|
12112
|
-
let { state: n, selectElement: _, setSelectedElements: E, addElement: O } = useEditor(),
|
|
12174
|
+
let { state: n, selectElement: _, setSelectedElements: E, addElement: O, setZoom: A, setPan: j, undo: M, redo: N, copy: P, paste: z, removeSelected: B, updateElements: U } = useEditor(), G = useRef(null), [Z, Lj] = useState(null), Rj = useRef(!1), zj = useRef(!1), Hj = useRef(!1), Uj = useRef({
|
|
12113
12175
|
x: 0,
|
|
12114
12176
|
y: 0
|
|
12115
|
-
}),
|
|
12116
|
-
|
|
12117
|
-
|
|
12118
|
-
|
|
12119
|
-
|
|
12120
|
-
|
|
12121
|
-
|
|
12122
|
-
|
|
12123
|
-
|
|
12124
|
-
|
|
12125
|
-
|
|
12126
|
-
|
|
12127
|
-
|
|
12128
|
-
|
|
12129
|
-
|
|
12130
|
-
|
|
12131
|
-
|
|
12177
|
+
}), Wj = useRef({
|
|
12178
|
+
x: 0,
|
|
12179
|
+
y: 0
|
|
12180
|
+
}), Gj = useRef([]), Jj = (E) => {
|
|
12181
|
+
if (E.target !== G.current && E.target !== E.currentTarget) return;
|
|
12182
|
+
if (E.button === 1 || E.button === 0 && Hj.current) {
|
|
12183
|
+
E.preventDefault(), zj.current = !0, Wj.current = {
|
|
12184
|
+
x: E.clientX,
|
|
12185
|
+
y: E.clientY
|
|
12186
|
+
};
|
|
12187
|
+
return;
|
|
12188
|
+
}
|
|
12189
|
+
Rj.current = !0;
|
|
12190
|
+
let O = G.current?.getBoundingClientRect();
|
|
12191
|
+
if (!O) return;
|
|
12192
|
+
let A = O.left, j = O.top;
|
|
12193
|
+
Uj.current = {
|
|
12194
|
+
x: (E.clientX - A - n.pan.x) / n.zoom,
|
|
12195
|
+
y: (E.clientY - j - n.pan.y) / n.zoom
|
|
12196
|
+
}, Gj.current = n.selectedElementIds, E.shiftKey || (_(null), Gj.current = []), window.addEventListener("mousemove", Yj), window.addEventListener("mouseup", Xj);
|
|
12197
|
+
}, Yj = useCallback((_) => {
|
|
12198
|
+
if (!G.current) return;
|
|
12199
|
+
if (zj.current) {
|
|
12200
|
+
let E = _.clientX - Wj.current.x, O = _.clientY - Wj.current.y;
|
|
12201
|
+
j({
|
|
12202
|
+
x: n.pan.x + E,
|
|
12203
|
+
y: n.pan.y + O
|
|
12204
|
+
}), Wj.current = {
|
|
12205
|
+
x: _.clientX,
|
|
12206
|
+
y: _.clientY
|
|
12207
|
+
};
|
|
12208
|
+
return;
|
|
12209
|
+
}
|
|
12210
|
+
if (!Rj.current) return;
|
|
12211
|
+
let O = G.current.getBoundingClientRect(), A = (_.clientX - O.left - n.pan.x) / n.zoom, M = (_.clientY - O.top - n.pan.y) / n.zoom, N = Math.min(Uj.current.x, A), P = Math.min(Uj.current.y, M), z = Math.abs(A - Uj.current.x), B = Math.abs(M - Uj.current.y);
|
|
12212
|
+
if (Lj({
|
|
12213
|
+
x: N,
|
|
12214
|
+
y: P,
|
|
12215
|
+
width: z,
|
|
12216
|
+
height: B
|
|
12217
|
+
}), z > 2 || B > 2) {
|
|
12132
12218
|
let _ = [];
|
|
12133
12219
|
n.elements.forEach((n) => {
|
|
12134
|
-
let E = n.x ?? 0, O = n.y ?? 0, A = n.width ?? 100, j = n.height ?? 100, M = E + A,
|
|
12135
|
-
E <
|
|
12136
|
-
}), E(Array.from(new Set([...
|
|
12220
|
+
let E = n.x ?? 0, O = n.y ?? 0, A = n.width ?? 100, j = n.height ?? 100, M = E + A, H = O + j, U = N + z, W = P + B;
|
|
12221
|
+
E < U && M > N && O < W && H > P && _.push(n.id);
|
|
12222
|
+
}), E(Array.from(new Set([...Gj.current, ..._])));
|
|
12137
12223
|
}
|
|
12138
|
-
}, [
|
|
12139
|
-
|
|
12140
|
-
|
|
12141
|
-
|
|
12142
|
-
|
|
12143
|
-
|
|
12144
|
-
|
|
12145
|
-
|
|
12146
|
-
},
|
|
12147
|
-
if (
|
|
12148
|
-
|
|
12149
|
-
|
|
12150
|
-
|
|
12151
|
-
|
|
12152
|
-
|
|
12224
|
+
}, [
|
|
12225
|
+
n.elements,
|
|
12226
|
+
n.pan,
|
|
12227
|
+
n.zoom,
|
|
12228
|
+
E,
|
|
12229
|
+
j
|
|
12230
|
+
]), Xj = useCallback(() => {
|
|
12231
|
+
Rj.current = !1, zj.current = !1, Lj(null), window.removeEventListener("mousemove", Yj), window.removeEventListener("mouseup", Xj);
|
|
12232
|
+
}, [Yj]), Zj = (_) => {
|
|
12233
|
+
if (_.ctrlKey || _.metaKey) _.preventDefault(), A(Math.min(Math.max(.1, n.zoom - _.deltaY * .001), 5));
|
|
12234
|
+
else {
|
|
12235
|
+
let E = _.shiftKey ? _.deltaY : _.deltaX, O = _.shiftKey ? _.deltaX : _.deltaY;
|
|
12236
|
+
j({
|
|
12237
|
+
x: n.pan.x - E * 1,
|
|
12238
|
+
y: n.pan.y - O * 1
|
|
12239
|
+
});
|
|
12240
|
+
}
|
|
12241
|
+
};
|
|
12242
|
+
useEffect(() => {
|
|
12243
|
+
let _ = (_) => {
|
|
12244
|
+
if (_.code === "Space" && !_.repeat && !(_.target instanceof HTMLInputElement || _.target instanceof HTMLTextAreaElement) && (Hj.current = !0, G.current && (G.current.style.cursor = "grab")), !(_.target instanceof HTMLInputElement || _.target instanceof HTMLTextAreaElement) && ((_.ctrlKey || _.metaKey) && _.key.toLowerCase() === "z" && (_.preventDefault(), _.shiftKey ? N() : M()), (_.ctrlKey || _.metaKey) && _.key.toLowerCase() === "y" && (_.preventDefault(), N()), (_.ctrlKey || _.metaKey) && _.key.toLowerCase() === "c" && (_.preventDefault(), P()), (_.ctrlKey || _.metaKey) && _.key.toLowerCase() === "v" && (_.preventDefault(), z()), (_.key === "Delete" || _.key === "Backspace") && (_.preventDefault(), B()), [
|
|
12245
|
+
"ArrowUp",
|
|
12246
|
+
"ArrowDown",
|
|
12247
|
+
"ArrowLeft",
|
|
12248
|
+
"ArrowRight"
|
|
12249
|
+
].includes(_.key))) {
|
|
12250
|
+
_.preventDefault();
|
|
12251
|
+
let E = _.shiftKey ? 10 : 1, O = [];
|
|
12252
|
+
n.selectedElementIds.forEach((A) => {
|
|
12253
|
+
let j = n.elements.find((n) => n.id === A);
|
|
12254
|
+
if (j) {
|
|
12255
|
+
let { x: n = 0, y: M = 0 } = j;
|
|
12256
|
+
_.key === "ArrowUp" && (M -= E), _.key === "ArrowDown" && (M += E), _.key === "ArrowLeft" && (n -= E), _.key === "ArrowRight" && (n += E), O.push({
|
|
12257
|
+
id: A,
|
|
12258
|
+
changes: {
|
|
12259
|
+
x: n,
|
|
12260
|
+
y: M
|
|
12261
|
+
}
|
|
12262
|
+
});
|
|
12263
|
+
}
|
|
12264
|
+
}), O.length > 0 && U(O);
|
|
12265
|
+
}
|
|
12266
|
+
}, E = (n) => {
|
|
12267
|
+
n.code === "Space" && (Hj.current = !1, G.current && !zj.current && (G.current.style.cursor = "default"));
|
|
12268
|
+
};
|
|
12269
|
+
return window.addEventListener("keydown", _), window.addEventListener("keyup", E), () => {
|
|
12270
|
+
window.removeEventListener("keydown", _), window.removeEventListener("keyup", E), window.removeEventListener("mousemove", Yj), window.removeEventListener("mouseup", Xj);
|
|
12271
|
+
};
|
|
12272
|
+
}, [
|
|
12273
|
+
M,
|
|
12274
|
+
N,
|
|
12275
|
+
P,
|
|
12276
|
+
z,
|
|
12277
|
+
B,
|
|
12278
|
+
U,
|
|
12279
|
+
n.selectedElementIds,
|
|
12280
|
+
n.elements,
|
|
12281
|
+
Yj,
|
|
12282
|
+
Xj
|
|
12283
|
+
]);
|
|
12284
|
+
let Qj = useRef(!1), { setCanvasHeight: $j } = useEditor(), eM = (n) => {
|
|
12285
|
+
n.stopPropagation(), n.preventDefault(), Qj.current = !0, window.addEventListener("mousemove", tM), window.addEventListener("mouseup", nM);
|
|
12286
|
+
}, tM = useCallback((n) => {
|
|
12287
|
+
if (!Qj.current || !G.current) return;
|
|
12288
|
+
let _ = G.current.getBoundingClientRect(), E = n.clientY - _.top, O = Math.max(50, Math.min(E, 2e3));
|
|
12289
|
+
$j(Math.round(O));
|
|
12290
|
+
}, [$j]), nM = useCallback(() => {
|
|
12291
|
+
Qj.current = !1, window.removeEventListener("mousemove", tM), window.removeEventListener("mouseup", nM);
|
|
12292
|
+
}, [tM]);
|
|
12153
12293
|
useEffect(() => () => {
|
|
12154
|
-
window.removeEventListener("mousemove",
|
|
12155
|
-
}, [
|
|
12156
|
-
let
|
|
12294
|
+
window.removeEventListener("mousemove", tM), window.removeEventListener("mouseup", nM);
|
|
12295
|
+
}, [tM, nM]);
|
|
12296
|
+
let rM = (n) => {
|
|
12157
12297
|
n.preventDefault(), n.dataTransfer.dropEffect = "copy";
|
|
12158
|
-
},
|
|
12298
|
+
}, iM = (n) => {
|
|
12159
12299
|
n.preventDefault();
|
|
12160
12300
|
let _ = n.dataTransfer.getData("application/x-editor-prop");
|
|
12161
12301
|
if (_) {
|
|
@@ -12170,92 +12310,177 @@ const ElementContextMenu = ({ children: n, element: _ }) => {
|
|
|
12170
12310
|
dataBinding: _
|
|
12171
12311
|
});
|
|
12172
12312
|
}
|
|
12173
|
-
},
|
|
12313
|
+
}, aM = n.canvasHeight || 150;
|
|
12174
12314
|
return /* @__PURE__ */ jsxs(p, {
|
|
12175
|
-
ref:
|
|
12176
|
-
onMouseDown:
|
|
12177
|
-
onDragOver:
|
|
12178
|
-
onDrop:
|
|
12315
|
+
ref: G,
|
|
12316
|
+
onMouseDown: Jj,
|
|
12317
|
+
onDragOver: rM,
|
|
12318
|
+
onDrop: iM,
|
|
12319
|
+
onWheel: Zj,
|
|
12179
12320
|
style: {
|
|
12180
12321
|
width: "100%",
|
|
12181
12322
|
height: "100%",
|
|
12182
12323
|
position: "relative",
|
|
12183
12324
|
overflow: "hidden",
|
|
12184
12325
|
backgroundColor: "var(--color-background)",
|
|
12185
|
-
|
|
12186
|
-
backgroundSize: "20px 20px"
|
|
12326
|
+
cursor: zj.current ? "grabbing" : "default"
|
|
12187
12327
|
},
|
|
12188
|
-
children: [
|
|
12189
|
-
|
|
12328
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
12329
|
+
style: {
|
|
12330
|
+
transform: `translate(${n.pan.x}px, ${n.pan.y}px) scale(${n.zoom})`,
|
|
12331
|
+
transformOrigin: "0 0",
|
|
12332
|
+
width: "100%",
|
|
12333
|
+
height: "100%",
|
|
12190
12334
|
position: "absolute",
|
|
12191
|
-
|
|
12192
|
-
|
|
12193
|
-
|
|
12194
|
-
|
|
12195
|
-
|
|
12196
|
-
border: "1px solid rgba(0, 120, 255, 0.5)",
|
|
12197
|
-
pointerEvents: "none",
|
|
12198
|
-
zIndex: 9999
|
|
12199
|
-
} }),
|
|
12200
|
-
n.isList && /* @__PURE__ */ jsxs("div", {
|
|
12201
|
-
style: {
|
|
12335
|
+
top: 0,
|
|
12336
|
+
left: 0
|
|
12337
|
+
},
|
|
12338
|
+
children: [
|
|
12339
|
+
/* @__PURE__ */ jsx("div", { style: {
|
|
12202
12340
|
position: "absolute",
|
|
12203
|
-
top:
|
|
12204
|
-
left:
|
|
12205
|
-
|
|
12206
|
-
height: "
|
|
12207
|
-
|
|
12208
|
-
|
|
12209
|
-
|
|
12210
|
-
|
|
12211
|
-
|
|
12212
|
-
|
|
12213
|
-
|
|
12214
|
-
|
|
12215
|
-
|
|
12216
|
-
|
|
12217
|
-
|
|
12218
|
-
|
|
12219
|
-
|
|
12220
|
-
|
|
12221
|
-
|
|
12222
|
-
|
|
12223
|
-
|
|
12341
|
+
top: -n.pan.y / n.zoom,
|
|
12342
|
+
left: -n.pan.x / n.zoom,
|
|
12343
|
+
width: "200vw",
|
|
12344
|
+
height: "200vh",
|
|
12345
|
+
backgroundImage: "radial-gradient(var(--gray-5) 1px, transparent 1px)",
|
|
12346
|
+
backgroundSize: "20px 20px",
|
|
12347
|
+
pointerEvents: "none",
|
|
12348
|
+
transform: "scale(1)"
|
|
12349
|
+
} }),
|
|
12350
|
+
Z && /* @__PURE__ */ jsx("div", { style: {
|
|
12351
|
+
position: "absolute",
|
|
12352
|
+
left: Z.x,
|
|
12353
|
+
top: Z.y,
|
|
12354
|
+
width: Z.width,
|
|
12355
|
+
height: Z.height,
|
|
12356
|
+
backgroundColor: "rgba(0, 120, 255, 0.1)",
|
|
12357
|
+
border: "1px solid rgba(0, 120, 255, 0.5)",
|
|
12358
|
+
pointerEvents: "none",
|
|
12359
|
+
zIndex: 9999
|
|
12360
|
+
} }),
|
|
12361
|
+
n.snapLines.map((n, _) => /* @__PURE__ */ jsx("div", { style: {
|
|
12362
|
+
position: "absolute",
|
|
12363
|
+
left: n.orientation === "vertical" ? n.position : 0,
|
|
12364
|
+
top: n.orientation === "horizontal" ? n.position : 0,
|
|
12365
|
+
width: n.orientation === "vertical" ? "1px" : "100%",
|
|
12366
|
+
height: n.orientation === "horizontal" ? "1px" : "100%",
|
|
12367
|
+
backgroundColor: "red",
|
|
12368
|
+
zIndex: 9999,
|
|
12369
|
+
pointerEvents: "none"
|
|
12370
|
+
} }, _)),
|
|
12371
|
+
n.isList && /* @__PURE__ */ jsxs("div", {
|
|
12224
12372
|
style: {
|
|
12225
12373
|
position: "absolute",
|
|
12226
|
-
|
|
12227
|
-
|
|
12374
|
+
top: aM,
|
|
12375
|
+
left: 0,
|
|
12376
|
+
right: 0,
|
|
12377
|
+
height: "10px",
|
|
12378
|
+
marginTop: "-5px",
|
|
12379
|
+
cursor: "ns-resize",
|
|
12380
|
+
zIndex: 100,
|
|
12381
|
+
display: "flex",
|
|
12382
|
+
alignItems: "center",
|
|
12383
|
+
justifyContent: "center",
|
|
12384
|
+
group: "resize-handle"
|
|
12385
|
+
},
|
|
12386
|
+
onMouseDown: eM,
|
|
12387
|
+
children: [/* @__PURE__ */ jsx("div", { style: {
|
|
12388
|
+
width: "100%",
|
|
12389
|
+
height: "2px",
|
|
12228
12390
|
backgroundColor: "var(--accent-9)",
|
|
12229
|
-
|
|
12230
|
-
|
|
12231
|
-
|
|
12232
|
-
|
|
12233
|
-
|
|
12391
|
+
borderBottom: "none",
|
|
12392
|
+
opacity: .8,
|
|
12393
|
+
boxShadow: "0 1px 4px rgba(0,0,0,0.2)"
|
|
12394
|
+
} }), /* @__PURE__ */ jsxs("div", {
|
|
12395
|
+
style: {
|
|
12396
|
+
position: "absolute",
|
|
12397
|
+
right: 10,
|
|
12398
|
+
top: -20,
|
|
12399
|
+
backgroundColor: "var(--accent-9)",
|
|
12400
|
+
color: "white",
|
|
12401
|
+
fontSize: "11px",
|
|
12402
|
+
padding: "2px 6px",
|
|
12403
|
+
borderRadius: "4px",
|
|
12404
|
+
fontWeight: 500,
|
|
12405
|
+
pointerEvents: "none",
|
|
12406
|
+
boxShadow: "0 2px 5px rgba(0,0,0,0.1)"
|
|
12407
|
+
},
|
|
12408
|
+
children: [
|
|
12409
|
+
"Altura do Item: ",
|
|
12410
|
+
aM,
|
|
12411
|
+
"px"
|
|
12412
|
+
]
|
|
12413
|
+
})]
|
|
12414
|
+
}),
|
|
12415
|
+
n.elements.length === 0 && /* @__PURE__ */ jsx(p$1, {
|
|
12416
|
+
align: "center",
|
|
12417
|
+
justify: "center",
|
|
12418
|
+
style: {
|
|
12419
|
+
height: "100%",
|
|
12420
|
+
color: "var(--gray-8)",
|
|
12234
12421
|
pointerEvents: "none",
|
|
12235
|
-
|
|
12422
|
+
transform: `scale(${1 / n.zoom})`
|
|
12236
12423
|
},
|
|
12237
|
-
children:
|
|
12238
|
-
|
|
12239
|
-
|
|
12240
|
-
|
|
12241
|
-
|
|
12242
|
-
})
|
|
12243
|
-
|
|
12244
|
-
|
|
12245
|
-
|
|
12246
|
-
|
|
12247
|
-
|
|
12248
|
-
|
|
12249
|
-
|
|
12250
|
-
|
|
12251
|
-
|
|
12252
|
-
|
|
12253
|
-
|
|
12254
|
-
|
|
12255
|
-
|
|
12256
|
-
|
|
12257
|
-
|
|
12258
|
-
|
|
12424
|
+
children: /* @__PURE__ */ jsx(p$2, { children: "Adicione elementos e arraste livremente" })
|
|
12425
|
+
}),
|
|
12426
|
+
n.elements.map((_) => /* @__PURE__ */ jsx(DraggableElement, {
|
|
12427
|
+
element: _,
|
|
12428
|
+
isSelected: n.selectedElementIds.includes(_.id)
|
|
12429
|
+
}, _.id))
|
|
12430
|
+
]
|
|
12431
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
12432
|
+
style: {
|
|
12433
|
+
position: "absolute",
|
|
12434
|
+
bottom: 20,
|
|
12435
|
+
right: 20,
|
|
12436
|
+
display: "flex",
|
|
12437
|
+
gap: "8px",
|
|
12438
|
+
backgroundColor: "var(--color-panel-solid)",
|
|
12439
|
+
padding: "4px",
|
|
12440
|
+
borderRadius: "8px",
|
|
12441
|
+
boxShadow: "0 2px 10px rgba(0,0,0,0.1)",
|
|
12442
|
+
zIndex: 1e3
|
|
12443
|
+
},
|
|
12444
|
+
children: [
|
|
12445
|
+
/* @__PURE__ */ jsx("button", {
|
|
12446
|
+
onClick: () => A(Math.max(.1, n.zoom - .1)),
|
|
12447
|
+
style: {
|
|
12448
|
+
padding: "4px 8px",
|
|
12449
|
+
cursor: "pointer"
|
|
12450
|
+
},
|
|
12451
|
+
children: "-"
|
|
12452
|
+
}),
|
|
12453
|
+
/* @__PURE__ */ jsxs("span", {
|
|
12454
|
+
style: {
|
|
12455
|
+
padding: "4px 8px",
|
|
12456
|
+
minWidth: "50px",
|
|
12457
|
+
textAlign: "center"
|
|
12458
|
+
},
|
|
12459
|
+
children: [Math.round(n.zoom * 100), "%"]
|
|
12460
|
+
}),
|
|
12461
|
+
/* @__PURE__ */ jsx("button", {
|
|
12462
|
+
onClick: () => A(Math.min(5, n.zoom + .1)),
|
|
12463
|
+
style: {
|
|
12464
|
+
padding: "4px 8px",
|
|
12465
|
+
cursor: "pointer"
|
|
12466
|
+
},
|
|
12467
|
+
children: "+"
|
|
12468
|
+
}),
|
|
12469
|
+
/* @__PURE__ */ jsx("button", {
|
|
12470
|
+
onClick: () => {
|
|
12471
|
+
A(1), j({
|
|
12472
|
+
x: 0,
|
|
12473
|
+
y: 0
|
|
12474
|
+
});
|
|
12475
|
+
},
|
|
12476
|
+
style: {
|
|
12477
|
+
padding: "4px 8px",
|
|
12478
|
+
cursor: "pointer"
|
|
12479
|
+
},
|
|
12480
|
+
children: "Reset"
|
|
12481
|
+
})
|
|
12482
|
+
]
|
|
12483
|
+
})]
|
|
12259
12484
|
});
|
|
12260
12485
|
}, EditorSettings = () => {
|
|
12261
12486
|
let { state: n, updateListSettings: _, setCanvasHeight: E, setGridSize: O } = useEditor(), [A, j] = useState(!1), [M, N] = useState(""), [P, z] = useState("asc"), [B, H] = useState("bottom"), [U, G] = useState("down"), [Z, Lj] = useState("150"), [Rj, zj] = useState(""), [Bj, Hj] = useState("0"), [Uj, Wj] = useState("slideIn"), [Gj, Jj] = useState(.3), [Yj, Xj] = useState("ease-out");
|