-
diff --git a/frontend/src/Editor/DraggableBox.jsx b/frontend/src/Editor/DraggableBox.jsx
index 28b6582552..9cf7315684 100644
--- a/frontend/src/Editor/DraggableBox.jsx
+++ b/frontend/src/Editor/DraggableBox.jsx
@@ -66,7 +66,9 @@ export const DraggableBox = function DraggableBox({
zoomLevel,
containerProps,
configHandleClicked,
- removeComponent
+ removeComponent,
+ currentLayout,
+ layouts
}) {
const [isResizing, setResizing] = useState(false);
const [canDrag, setCanDrag] = useState(true);
@@ -76,13 +78,13 @@ export const DraggableBox = function DraggableBox({
() => ({
type: ItemTypes.BOX,
item: {
- id, left, top, width, height, title, component, zoomLevel, parent
+ id, title, component, zoomLevel, parent, layouts
},
collect: (monitor) => ({
isDragging: monitor.isDragging()
})
}),
- [id, left, top, height, width, title, component, index, zoomLevel, parent]
+ [id, title, component, index, zoomLevel, parent, layouts]
);
useEffect(() => {
@@ -114,6 +116,49 @@ export const DraggableBox = function DraggableBox({
setCanDrag(newState);
}
+ const defaultData = {
+ top: 100,
+ left: 0,
+ width: 445,
+ height: 500
+ }
+
+ const layoutData = inCanvas ? layouts[currentLayout] || defaultData : defaultData;
+ const [currentLayoutOptions, setCurrentLayoutOptions] = useState(layoutData);
+
+ useEffect(() => {
+ console.log(layoutData)
+ setCurrentLayoutOptions(layoutData);
+ }, [layoutData.height, layoutData.width, layoutData.left, layoutData.top]);
+
+ // const [currentLayoutOptions, setCurrentLayoutOptions] = useState(layoutData);
+
+ // if(inCanvas && Object.keys(currentLayoutOptions).length === 0 ) {
+ // setCurrentLayoutOptions({
+ // top: 100,
+ // left: 0,
+ // width: 445,
+ // height: 500
+ // })
+ // }
+
+ // useEffect(() => {
+ // if(inCanvas) {
+
+ // if(Object.keys(layoutData).length === 0 ) {
+ // setCurrentLayoutOptions({
+ // top: 100,
+ // left: 0,
+ // width: 445,
+ // height: 500
+ // })
+ // } else {
+ // setCurrentLayoutOptions(layoutData);
+ // }
+
+ // }
+ // }, [layoutData]);
+
return (
{inCanvas ? (
@@ -126,8 +171,8 @@ export const DraggableBox = function DraggableBox({
setResizing(true)}
@@ -153,9 +198,9 @@ export const DraggableBox = function DraggableBox({
+
+
+
+
+
+
+
{app
@@ -631,13 +652,14 @@ class Editor extends React.Component {
-
+
onEvent(this, eventName, options)}
onComponentOptionChanged={(component, optionName, value) => onComponentOptionChanged(this, component, optionName, value)
@@ -653,7 +675,10 @@ class Editor extends React.Component {
onComponentClick(this, id, component);
}}
/>
-
+