@raketa-builder/builder 0.25.0 → 0.26.0
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/.turbo/turbo-build.log +3 -3
- package/dist/index.js +283 -554
- package/package.json +1 -1
- package/src/AdminPageRender.js +23 -14
- package/src/Canvas.js +3 -3
- package/src/PageBuilder.js +22 -13
- package/src/lib/AdminWidget.js +3 -7
- package/src/lib/AdminWidgetMinimal.js +3 -7
- package/src/lib/AdminWidgetWrapper.js +1 -4
package/package.json
CHANGED
package/src/AdminPageRender.js
CHANGED
|
@@ -2,19 +2,28 @@ import React from "react";
|
|
|
2
2
|
import ErrorBoundary from "./ErrorBoundary";
|
|
3
3
|
import AdminWidgetMinimal from "./lib/AdminWidgetMinimal";
|
|
4
4
|
|
|
5
|
-
const AdminPageRender = ({ page, library, adminLibrary, identifier }) =>
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
5
|
+
const AdminPageRender = ({ page, library, adminLibrary, identifier }) => {
|
|
6
|
+
const handleCopyWidgets = (widgets) => {
|
|
7
|
+
window.localStorage.setItem(
|
|
8
|
+
`clipboard–${identifier}`,
|
|
9
|
+
JSON.stringify(widgets)
|
|
10
|
+
);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<React.Fragment>
|
|
15
|
+
{page.widgets.map(({ widgetId, component, settings }) => (
|
|
16
|
+
<ErrorBoundary key={widgetId}>
|
|
17
|
+
<AdminWidgetMinimal
|
|
18
|
+
library={library}
|
|
19
|
+
adminLibrary={adminLibrary}
|
|
20
|
+
widget={{ widgetId, component, settings }}
|
|
21
|
+
onCopy={handleCopyWidgets}
|
|
22
|
+
/>
|
|
23
|
+
</ErrorBoundary>
|
|
24
|
+
))}
|
|
25
|
+
</React.Fragment>
|
|
26
|
+
);
|
|
27
|
+
};
|
|
19
28
|
|
|
20
29
|
export default AdminPageRender;
|
package/src/Canvas.js
CHANGED
|
@@ -10,7 +10,7 @@ const EmptyCanvas = ({ className, ...rest }) => (
|
|
|
10
10
|
);
|
|
11
11
|
|
|
12
12
|
const Canvas = React.memo(
|
|
13
|
-
function Canvas({ widgets, onReorder, onEdit, onRemove,
|
|
13
|
+
function Canvas({ widgets, onReorder, onEdit, onRemove, onCopy }) {
|
|
14
14
|
const { library, adminLibrary } = React.useContext(LibraryContext);
|
|
15
15
|
|
|
16
16
|
if (widgets.length === 0) {
|
|
@@ -39,10 +39,10 @@ const Canvas = React.memo(
|
|
|
39
39
|
<AdminWidget
|
|
40
40
|
library={library}
|
|
41
41
|
adminLibrary={adminLibrary}
|
|
42
|
-
identifier={identifier}
|
|
43
42
|
widget={widget}
|
|
44
43
|
onEdit={onEdit}
|
|
45
44
|
onDelete={onRemove}
|
|
45
|
+
onCopy={onCopy}
|
|
46
46
|
/>
|
|
47
47
|
</ErrorBoundary>
|
|
48
48
|
))}
|
|
@@ -59,7 +59,7 @@ const Canvas = React.memo(
|
|
|
59
59
|
JSON.stringify(props.widgets) === JSON.stringify(nextProps.widgets);
|
|
60
60
|
|
|
61
61
|
return themesAreEqual && spacingsAreEqual && widgetsAreEqual;
|
|
62
|
-
}
|
|
62
|
+
}
|
|
63
63
|
);
|
|
64
64
|
|
|
65
65
|
export default Canvas;
|
package/src/PageBuilder.js
CHANGED
|
@@ -81,7 +81,7 @@ const PageBuilder = ({
|
|
|
81
81
|
"settings",
|
|
82
82
|
widget.settings,
|
|
83
83
|
widget.widgetId,
|
|
84
|
-
"widgetId"
|
|
84
|
+
"widgetId"
|
|
85
85
|
);
|
|
86
86
|
const newPage = {
|
|
87
87
|
...page,
|
|
@@ -130,25 +130,34 @@ const PageBuilder = ({
|
|
|
130
130
|
setDirty(false);
|
|
131
131
|
};
|
|
132
132
|
|
|
133
|
+
const handleCopyWidgets = (widgets) => {
|
|
134
|
+
window.localStorage.setItem(
|
|
135
|
+
`clipboard–${identifier}`,
|
|
136
|
+
JSON.stringify(widgets)
|
|
137
|
+
);
|
|
138
|
+
};
|
|
139
|
+
|
|
133
140
|
const handlePasteWidget = () => {
|
|
134
|
-
const
|
|
135
|
-
window.localStorage.getItem(`clipboard–${identifier}`)
|
|
141
|
+
const clipboardWidgets = JSON.parse(
|
|
142
|
+
window.localStorage.getItem(`clipboard–${identifier}`)
|
|
136
143
|
);
|
|
137
144
|
|
|
138
|
-
if (!
|
|
145
|
+
if (!clipboardWidgets) {
|
|
146
|
+
return alert("Nothing to paste, yet");
|
|
147
|
+
}
|
|
139
148
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
settings: clipboardWidget.widget.settings,
|
|
144
|
-
};
|
|
149
|
+
if (!(Array.isArray(clipboardWidgets) && clipboardWidgets.length > 0)) {
|
|
150
|
+
console.error("Invalid widgets to paste", clipboardWidgets);
|
|
151
|
+
}
|
|
145
152
|
|
|
146
|
-
|
|
153
|
+
const newWidgets = clipboardWidgets.reduce((list, widget) => {
|
|
154
|
+
list.push({ ...widget, widgetId: randomString(6) });
|
|
155
|
+
return list;
|
|
156
|
+
}, []);
|
|
147
157
|
|
|
148
|
-
const widgets = add(page.widgets, newWidget);
|
|
149
158
|
const newPage = {
|
|
150
159
|
...page,
|
|
151
|
-
widgets,
|
|
160
|
+
widgets: [...page.widgets, ...newWidgets],
|
|
152
161
|
};
|
|
153
162
|
|
|
154
163
|
setPage(newPage);
|
|
@@ -206,10 +215,10 @@ const PageBuilder = ({
|
|
|
206
215
|
|
|
207
216
|
<Canvas
|
|
208
217
|
widgets={sortableWidgets}
|
|
209
|
-
identifier={identifier}
|
|
210
218
|
onReorder={handleReorder}
|
|
211
219
|
onEdit={setSelectedWidget}
|
|
212
220
|
onRemove={handleRemove}
|
|
221
|
+
onCopy={handleCopyWidgets}
|
|
213
222
|
/>
|
|
214
223
|
|
|
215
224
|
{selectedWidget && (
|
package/src/lib/AdminWidget.js
CHANGED
|
@@ -9,10 +9,10 @@ import widgetData from "../helpers/widgetData";
|
|
|
9
9
|
const AdminWidget = ({
|
|
10
10
|
library,
|
|
11
11
|
adminLibrary,
|
|
12
|
-
identifier,
|
|
13
12
|
widget,
|
|
14
13
|
onEdit,
|
|
15
14
|
onDelete,
|
|
15
|
+
onCopy,
|
|
16
16
|
}) => {
|
|
17
17
|
const currentWidget = library[widget.component];
|
|
18
18
|
const currentAdminWidget = adminLibrary[widget.component];
|
|
@@ -29,12 +29,8 @@ const AdminWidget = ({
|
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
const handleCopyWidget = () => {
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
widget,
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
window.localStorage.setItem(`clipboard–${identifier}`, storedWidget);
|
|
32
|
+
const widgetsToCopy = [widget];
|
|
33
|
+
onCopy(widgetsToCopy);
|
|
38
34
|
};
|
|
39
35
|
|
|
40
36
|
return (
|
|
@@ -6,7 +6,7 @@ import AdminWidgetLabel from "./AdminWidgetLabel";
|
|
|
6
6
|
import IconButton from "./IconButton";
|
|
7
7
|
import widgetData from "../helpers/widgetData";
|
|
8
8
|
|
|
9
|
-
const AdminWidgetMinimal = ({ library, adminLibrary,
|
|
9
|
+
const AdminWidgetMinimal = ({ library, adminLibrary, widget, onCopy }) => {
|
|
10
10
|
const currentWidget = library[widget.component];
|
|
11
11
|
const currentAdminWidget = adminLibrary[widget.component];
|
|
12
12
|
|
|
@@ -16,12 +16,8 @@ const AdminWidgetMinimal = ({ library, adminLibrary, identifier, widget }) => {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
const handleCopyWidget = () => {
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
widget,
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
window.localStorage.setItem(`clipboard–${identifier}`, storedWidget);
|
|
19
|
+
const widgetsToCopy = [widget];
|
|
20
|
+
onCopy(widgetsToCopy);
|
|
25
21
|
};
|
|
26
22
|
|
|
27
23
|
return (
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { cn } from "@raketa-builder/ui";
|
|
2
2
|
|
|
3
3
|
const AdminWidgetWrapper = ({ className, ...rest }) => (
|
|
4
|
-
<div
|
|
5
|
-
className={cn("r-reset", "r-admin-widget-wrapper", className)}
|
|
6
|
-
{...rest}
|
|
7
|
-
/>
|
|
4
|
+
<div className={cn("r-admin-widget-wrapper", className)} {...rest} />
|
|
8
5
|
);
|
|
9
6
|
|
|
10
7
|
export default AdminWidgetWrapper;
|