@saltcorn/builder 1.3.0-beta.10 → 1.3.0-beta.12
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/builder_bundle.js +1 -1
- package/package.json +2 -2
- package/src/components/Builder.js +58 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@saltcorn/builder",
|
|
3
|
-
"version": "1.3.0-beta.
|
|
3
|
+
"version": "1.3.0-beta.12",
|
|
4
4
|
"description": "Drag and drop view builder for Saltcorn, open-source no-code platform",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"homepage": "https://saltcorn.com",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"@babel/preset-react": "7.24.7",
|
|
21
21
|
"@craftjs/core": "0.1.0-beta.20",
|
|
22
22
|
"@craftjs/utils": "0.1.0-beta.20",
|
|
23
|
-
"@saltcorn/common-code": "1.3.0-beta.
|
|
23
|
+
"@saltcorn/common-code": "1.3.0-beta.12",
|
|
24
24
|
"saltcorn-craft-layers-noeye": "0.1.0-beta.22",
|
|
25
25
|
"@fonticonpicker/react-fonticonpicker": "1.2.0",
|
|
26
26
|
"@fortawesome/fontawesome-svg-core": "1.2.34",
|
|
@@ -78,6 +78,8 @@ const { Provider } = optionsCtx;
|
|
|
78
78
|
* @namespace
|
|
79
79
|
*/
|
|
80
80
|
const SettingsPanel = () => {
|
|
81
|
+
const options = useContext(optionsCtx);
|
|
82
|
+
|
|
81
83
|
const { actions, selected, query } = useEditor((state, query) => {
|
|
82
84
|
const currentNodeId = state.events.selected;
|
|
83
85
|
let selected;
|
|
@@ -170,6 +172,48 @@ const SettingsPanel = () => {
|
|
|
170
172
|
if (nextSib) actions.selectNode(nextSib);
|
|
171
173
|
event.preventDefault();
|
|
172
174
|
}
|
|
175
|
+
// Ctrl+C or Cmd+C pressed?
|
|
176
|
+
if ((event.ctrlKey || event.metaKey) && event.keyCode == 67 && selected) {
|
|
177
|
+
// copy elem in json format to clipboard
|
|
178
|
+
const { layout } = craftToSaltcorn(
|
|
179
|
+
JSON.parse(query.serialize()),
|
|
180
|
+
selected?.id,
|
|
181
|
+
options
|
|
182
|
+
);
|
|
183
|
+
navigator.clipboard.writeText(JSON.stringify(layout, null, 2));
|
|
184
|
+
}
|
|
185
|
+
if ((event.ctrlKey || event.metaKey) && event.keyCode == 88 && selected) {
|
|
186
|
+
// cut elem in json format to clipboard
|
|
187
|
+
const { layout } = craftToSaltcorn(
|
|
188
|
+
JSON.parse(query.serialize()),
|
|
189
|
+
selected?.id,
|
|
190
|
+
options
|
|
191
|
+
);
|
|
192
|
+
navigator.clipboard.writeText(JSON.stringify(layout, null, 2));
|
|
193
|
+
deleteThis();
|
|
194
|
+
}
|
|
195
|
+
if ((event.ctrlKey || event.metaKey) && event.keyCode == 86) {
|
|
196
|
+
// paste elem from clipboard into container element
|
|
197
|
+
|
|
198
|
+
navigator.clipboard.readText().then((clipText) => {
|
|
199
|
+
const layout = JSON.parse(clipText);
|
|
200
|
+
layoutToNodes(
|
|
201
|
+
layout,
|
|
202
|
+
query,
|
|
203
|
+
actions,
|
|
204
|
+
selected?.id || "ROOT",
|
|
205
|
+
options
|
|
206
|
+
);
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
if ((event.ctrlKey || event.metaKey) && event.keyCode == 90) {
|
|
210
|
+
// undo
|
|
211
|
+
actions.history.undo();
|
|
212
|
+
}
|
|
213
|
+
if ((event.ctrlKey || event.metaKey) && event.keyCode == 89) {
|
|
214
|
+
// redo
|
|
215
|
+
actions.history.redo();
|
|
216
|
+
}
|
|
173
217
|
}
|
|
174
218
|
};
|
|
175
219
|
useEffect(() => {
|
|
@@ -223,7 +267,10 @@ const SettingsPanel = () => {
|
|
|
223
267
|
{selected ? (
|
|
224
268
|
<Fragment>
|
|
225
269
|
{selected.isDeletable && (
|
|
226
|
-
<button
|
|
270
|
+
<button
|
|
271
|
+
className="btn btn-sm btn-danger delete-element-builder"
|
|
272
|
+
onClick={deleteThis}
|
|
273
|
+
>
|
|
227
274
|
<FontAwesomeIcon icon={faTrashAlt} className="me-1" />
|
|
228
275
|
Delete
|
|
229
276
|
</button>
|
|
@@ -293,7 +340,10 @@ const AddColumnButton = () => {
|
|
|
293
340
|
);
|
|
294
341
|
};
|
|
295
342
|
return (
|
|
296
|
-
<button
|
|
343
|
+
<button
|
|
344
|
+
className="btn btn-primary mt-2 add-column-builder"
|
|
345
|
+
onClick={addColumn}
|
|
346
|
+
>
|
|
297
347
|
<FontAwesomeIcon icon={faPlus} className="me-2" />
|
|
298
348
|
Add column
|
|
299
349
|
</button>
|
|
@@ -471,7 +521,9 @@ const Builder = ({ options, layout, mode }) => {
|
|
|
471
521
|
? faCaretSquareLeft
|
|
472
522
|
: faCaretSquareRight
|
|
473
523
|
}
|
|
474
|
-
className={
|
|
524
|
+
className={
|
|
525
|
+
"float-end fa-lg builder-expand-toggle-left"
|
|
526
|
+
}
|
|
475
527
|
onClick={() => setIsLeftEnlarged(!isLeftEnlarged)}
|
|
476
528
|
title={isLeftEnlarged ? "Shrink" : "Enlarge"}
|
|
477
529
|
/>
|
|
@@ -545,7 +597,9 @@ const Builder = ({ options, layout, mode }) => {
|
|
|
545
597
|
icon={
|
|
546
598
|
isEnlarged ? faCaretSquareRight : faCaretSquareLeft
|
|
547
599
|
}
|
|
548
|
-
className={
|
|
600
|
+
className={
|
|
601
|
+
"float-end me-2 mt-1 fa-lg builder-expand-toggle-right"
|
|
602
|
+
}
|
|
549
603
|
onClick={() => setIsEnlarged(!isEnlarged)}
|
|
550
604
|
title={isEnlarged ? "Shrink" : "Enlarge"}
|
|
551
605
|
/>
|