payload-canvas 0.1.1 → 0.3.0-next.1
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/README.md +201 -48
- package/dist/admin/BuilderTab.js +1 -1
- package/dist/admin/diff/LayoutDiff.js +3 -3
- package/dist/admin/diff/layoutDiff.scss +48 -48
- package/dist/admin/editor/Canvas.js +30 -8
- package/dist/admin/editor/DragLayer.js +1 -1
- package/dist/admin/editor/Editor.js +2 -0
- package/dist/admin/editor/InlineToolbar.js +1 -1
- package/dist/admin/editor/Inspector.js +15 -8
- package/dist/admin/editor/Outline.js +16 -10
- package/dist/admin/editor/Overlay.js +3 -2
- package/dist/admin/editor/actions.d.ts +5 -0
- package/dist/admin/editor/actions.js +23 -1
- package/dist/admin/editor/assistant/AssistantPanel.js +1 -1
- package/dist/admin/editor/assistant/ConnectAgents.js +1 -1
- package/dist/admin/editor/assistant/assistant.scss +65 -65
- package/dist/admin/editor/counts.d.ts +6 -0
- package/dist/admin/editor/counts.js +10 -0
- package/dist/admin/editor/dnd/displace.js +3 -1
- package/dist/admin/editor/dnd/dnd.scss +2 -2
- package/dist/admin/editor/editor.scss +186 -133
- package/dist/admin/editor/empty/EmptyStart.js +3 -3
- package/dist/admin/editor/empty/empty.scss +3 -3
- package/dist/admin/editor/fields/ArrayField.js +2 -2
- package/dist/admin/editor/fields/access.d.ts +1 -1
- package/dist/admin/editor/fields/fields.scss +33 -33
- package/dist/admin/editor/generate/GenerateImage.js +1 -1
- package/dist/admin/editor/generate/generate.scss +48 -48
- package/dist/admin/editor/icons.js +1 -1
- package/dist/admin/editor/inline.d.ts +12 -0
- package/dist/admin/editor/inline.js +48 -3
- package/dist/admin/editor/insert/InsertHandle.js +1 -1
- package/dist/admin/editor/insert/spots.js +4 -2
- package/dist/admin/editor/layout/FrameResize.js +1 -1
- package/dist/admin/editor/layout/LeftPanel.js +1 -1
- package/dist/admin/editor/layout/layout.scss +4 -4
- package/dist/admin/editor/live/PresenceUI.js +1 -1
- package/dist/admin/editor/live/presence.scss +1 -1
- package/dist/admin/editor/live/useMultiplayer.js +8 -2
- package/dist/admin/editor/locale/LocaleField.d.ts +1 -1
- package/dist/admin/editor/locale/LocaleField.js +1 -1
- package/dist/admin/editor/locale/locale.scss +12 -12
- package/dist/admin/editor/media/ImageEditor.js +22 -16
- package/dist/admin/editor/media/actions.d.ts +13 -9
- package/dist/admin/editor/media/actions.js +67 -28
- package/dist/admin/editor/media/media.scss +23 -23
- package/dist/admin/editor/media/model.d.ts +8 -0
- package/dist/admin/editor/media/model.js +14 -6
- package/dist/admin/editor/menu/Menu.js +1 -1
- package/dist/admin/editor/menu/blockMenu.js +13 -8
- package/dist/admin/editor/menu/menu.scss +16 -16
- package/dist/admin/editor/motion/MotionPanel.js +1 -1
- package/dist/admin/editor/motion/model.d.ts +2 -2
- package/dist/admin/editor/motion/motion.scss +2 -2
- package/dist/admin/editor/regions/RegionOverlay.d.ts +18 -0
- package/dist/admin/editor/regions/RegionOverlay.js +44 -0
- package/dist/admin/editor/regions/RegionPane.d.ts +5 -0
- package/dist/admin/editor/regions/RegionPane.js +26 -0
- package/dist/admin/editor/regions/RegionRows.d.ts +1 -0
- package/dist/admin/editor/regions/RegionRows.js +23 -0
- package/dist/admin/editor/regions/controller.d.ts +73 -0
- package/dist/admin/editor/regions/controller.js +231 -0
- package/dist/admin/editor/regions/select.d.ts +17 -0
- package/dist/admin/editor/regions/select.js +31 -0
- package/dist/admin/editor/renderField.js +1 -1
- package/dist/admin/editor/runtime.d.ts +6 -0
- package/dist/admin/editor/runtime.js +49 -4
- package/dist/admin/editor/sections/controller.d.ts +6 -2
- package/dist/admin/editor/sections/controller.js +9 -3
- package/dist/admin/editor/shortcuts.js +11 -4
- package/dist/admin/editor/storage.d.ts +7 -0
- package/dist/admin/editor/storage.js +15 -0
- package/dist/admin/editor/store.d.ts +39 -0
- package/dist/admin/editor/store.js +106 -2
- package/dist/admin/editor/styles/ColorPicker.js +1 -1
- package/dist/admin/editor/styles/VariantBar.js +1 -1
- package/dist/admin/editor/styles/controls.js +1 -1
- package/dist/admin/editor/styles/sections.js +1 -1
- package/dist/admin/editor/styles/styles.scss +93 -93
- package/dist/admin/editor/templates/Bindable.d.ts +1 -1
- package/dist/admin/editor/templates/Bindable.js +2 -2
- package/dist/admin/editor/templates/SamplePicker.js +2 -2
- package/dist/admin/editor/templates/templates.scss +90 -90
- package/dist/admin/editor/tooltip/tooltip.scss +4 -4
- package/dist/admin/editor/topbar/DocumentActions.js +39 -6
- package/dist/admin/editor/topbar/DocumentTitle.js +1 -1
- package/dist/admin/editor/topbar/closeSave.d.ts +50 -0
- package/dist/admin/editor/topbar/closeSave.js +90 -0
- package/dist/admin/editor/topbar/document.d.ts +10 -2
- package/dist/admin/editor/topbar/document.js +9 -1
- package/dist/admin/editor/topbar/drawerLabels.d.ts +22 -0
- package/dist/admin/editor/topbar/drawerLabels.js +69 -0
- package/dist/admin/editor/topbar/problems.d.ts +9 -0
- package/dist/admin/editor/topbar/problems.js +15 -1
- package/dist/admin/editor/topbar/screens/DrawerRouter.d.ts +1 -1
- package/dist/admin/editor/topbar/screens/ScreenDrawer.js +1 -1
- package/dist/admin/editor/topbar/screens/drawerRouterSupport.d.ts +1 -1
- package/dist/admin/editor/topbar/screens/screens.scss +20 -20
- package/dist/admin/editor/topbar/settingsDrawer.js +90 -6
- package/dist/admin/editor/topbar/settingsDrawer.scss +7 -7
- package/dist/admin/editor/topbar/settingsFocus.d.ts +11 -0
- package/dist/admin/editor/topbar/settingsFocus.js +46 -0
- package/dist/admin/editor/topbar/topbar.scss +47 -47
- package/dist/admin/editor/ui/Select.js +1 -1
- package/dist/admin/editor/ui/controls.scss +26 -26
- package/dist/admin/editor/ui/payloadA11y.d.ts +17 -0
- package/dist/admin/editor/ui/payloadA11y.js +12 -5
- package/dist/admin/editor/valueStore.d.ts +2 -0
- package/dist/admin/editor/valueStore.js +6 -0
- package/dist/admin/screen/BuilderScreen.js +1 -1
- package/dist/ai/adapters/anthropic.d.ts +2 -2
- package/dist/ai/images/service.js +1 -1
- package/dist/ai/loop.d.ts +5 -5
- package/dist/blocks/defaults.d.ts +9 -9
- package/dist/core/bindings.d.ts +1 -1
- package/dist/core/dropTarget.js +3 -1
- package/dist/core/fieldAccess.js +1 -1
- package/dist/core/fieldHooks.d.ts +1 -1
- package/dist/core/index.d.ts +2 -0
- package/dist/core/index.js +2 -0
- package/dist/core/motion.d.ts +7 -7
- package/dist/core/payloadBlocks.d.ts +53 -0
- package/dist/core/payloadBlocks.js +391 -0
- package/dist/core/regions.d.ts +63 -0
- package/dist/core/regions.js +239 -0
- package/dist/core/types.d.ts +53 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/live/document.d.ts +9 -1
- package/dist/live/document.js +57 -17
- package/dist/live/draftAccess.d.ts +36 -0
- package/dist/live/draftAccess.js +146 -0
- package/dist/live/endpoints.d.ts +11 -2
- package/dist/live/endpoints.js +120 -10
- package/dist/live/fieldChecks.d.ts +3 -3
- package/dist/live/fieldsGuard.d.ts +56 -2
- package/dist/live/fieldsGuard.js +107 -11
- package/dist/live/index.d.ts +2 -0
- package/dist/live/index.js +2 -0
- package/dist/live/regions.d.ts +89 -0
- package/dist/live/regions.js +401 -0
- package/dist/live/runtime.d.ts +1 -1
- package/dist/live/runtime.js +5 -2
- package/dist/live/session.d.ts +75 -10
- package/dist/live/session.js +655 -123
- package/dist/live/storage.d.ts +97 -0
- package/dist/live/storage.js +267 -0
- package/dist/live/types.d.ts +64 -0
- package/dist/live/writeGate.d.ts +72 -0
- package/dist/live/writeGate.js +478 -0
- package/dist/mcp/index.js +56 -12
- package/dist/mcp/shared.d.ts +31 -31
- package/dist/plugin/hook.d.ts +44 -6
- package/dist/plugin/hook.js +176 -20
- package/dist/plugin/index.d.ts +23 -1
- package/dist/plugin/index.js +175 -13
- package/dist/plugin/references.d.ts +4 -2
- package/dist/plugin/references.js +2 -0
- package/dist/plugin/sectionsBuilder.js +3 -3
- package/dist/plugin/templates.js +5 -1
- package/dist/protocol/index.d.ts +29 -3
- package/dist/react/canvas/BuilderCanvas.js +199 -9
- package/dist/react/canvas/frame.d.ts +70 -0
- package/dist/react/canvas/frame.js +66 -0
- package/dist/react/canvas/inline/dom.d.ts +7 -1
- package/dist/react/canvas/inline/dom.js +19 -9
- package/dist/react/canvas/inline/mapper.d.ts +26 -0
- package/dist/react/canvas/inline/mapper.js +59 -32
- package/dist/react/canvas/inline/rich/editor.js +6 -1
- package/dist/react/canvas/inline/session.d.ts +7 -1
- package/dist/react/canvas/inline/session.js +6 -2
- package/dist/react/canvas/measure.js +26 -1
- package/dist/react/canvas/thumbnail/ThumbnailCanvas.js +1 -1
- package/dist/react/index.d.ts +2 -0
- package/dist/react/index.js +2 -0
- package/dist/react/motion/style.js +1 -1
- package/dist/react/render/LayoutOutlet.d.ts +11 -0
- package/dist/react/render/LayoutOutlet.js +16 -0
- package/dist/react/render/PayloadRoot.js +1 -1
- package/dist/react/render/RenderLayout.js +1 -1
- package/dist/react/render/canvasFrame.d.ts +46 -0
- package/dist/react/render/canvasFrame.js +59 -0
- package/dist/react/render/canvasServer.d.ts +13 -0
- package/dist/react/render/canvasServer.js +3 -0
- package/dist/react/render/canvasServerTypes.d.ts +17 -0
- package/dist/react/render/regions.d.ts +13 -0
- package/dist/react/render/regions.js +8 -0
- package/dist/react/render/resolve.js +2 -0
- package/dist/react/server.d.ts +5 -2
- package/dist/react/server.js +6 -2
- package/dist/react/theme/ThemeStyle.js +1 -1
- package/dist/theme/admin/ColorField.d.ts +2 -2
- package/dist/theme/admin/ColorField.js +2 -2
- package/dist/theme/admin/FontField.d.ts +2 -2
- package/dist/theme/admin/FontField.js +2 -2
- package/dist/theme/admin/SaveSignal.js +2 -2
- package/dist/theme/admin/fields.scss +48 -48
- package/package.json +28 -23
|
@@ -9,14 +9,14 @@
|
|
|
9
9
|
&__content {
|
|
10
10
|
display: flex;
|
|
11
11
|
flex-direction: column;
|
|
12
|
-
gap: calc(var(--
|
|
13
|
-
background: var(--
|
|
14
|
-
padding: calc(var(--
|
|
12
|
+
gap: calc(var(--spacer-3) * 0.5);
|
|
13
|
+
background: var(--color-bg-secondary);
|
|
14
|
+
padding: calc(var(--spacer-3) * 0.5);
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
&__summary {
|
|
18
18
|
margin: 0;
|
|
19
|
-
color: var(--
|
|
19
|
+
color: var(--color-text);
|
|
20
20
|
font-weight: 500;
|
|
21
21
|
}
|
|
22
22
|
|
|
@@ -30,47 +30,47 @@
|
|
|
30
30
|
&__list {
|
|
31
31
|
display: flex;
|
|
32
32
|
flex-direction: column;
|
|
33
|
-
gap: calc(var(--
|
|
33
|
+
gap: calc(var(--spacer-3) * 0.25);
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
&__change {
|
|
37
|
-
padding: calc(var(--
|
|
38
|
-
border: 1px solid var(--
|
|
39
|
-
border-radius: var(--
|
|
40
|
-
background: var(--
|
|
37
|
+
padding: calc(var(--spacer-3) * 0.4) calc(var(--spacer-3) * 0.5);
|
|
38
|
+
border: 1px solid var(--color-bg-hover);
|
|
39
|
+
border-radius: var(--radius-medium);
|
|
40
|
+
background: var(--color-bg);
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
&__head {
|
|
44
44
|
display: flex;
|
|
45
45
|
flex-wrap: wrap;
|
|
46
46
|
align-items: baseline;
|
|
47
|
-
gap: calc(var(--
|
|
47
|
+
gap: calc(var(--spacer-3) * 0.3);
|
|
48
48
|
min-width: 0;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
&__pill {
|
|
52
52
|
flex: none;
|
|
53
|
-
padding: 0 calc(var(--
|
|
54
|
-
border: 1px solid var(--
|
|
55
|
-
border-radius: var(--
|
|
56
|
-
background: var(--
|
|
57
|
-
color: var(--
|
|
58
|
-
font-size: calc(var(--
|
|
53
|
+
padding: 0 calc(var(--spacer-3) * 0.25);
|
|
54
|
+
border: 1px solid var(--color-border);
|
|
55
|
+
border-radius: var(--radius-medium);
|
|
56
|
+
background: var(--color-bg-hover);
|
|
57
|
+
color: var(--color-text);
|
|
58
|
+
font-size: calc(var(--spacer-3) * 0.55);
|
|
59
59
|
font-weight: 600;
|
|
60
60
|
line-height: 1.6;
|
|
61
61
|
text-transform: uppercase;
|
|
62
62
|
letter-spacing: 0.04em;
|
|
63
63
|
|
|
64
64
|
&--added {
|
|
65
|
-
border-color: var(--diff-create-pill-border, var(--
|
|
66
|
-
background: var(--diff-create-pill-bg, var(--
|
|
67
|
-
color: var(--diff-create-pill-color, var(--
|
|
65
|
+
border-color: var(--diff-create-pill-border, var(--color-border-success-strong));
|
|
66
|
+
background: var(--diff-create-pill-bg, var(--color-border-success));
|
|
67
|
+
color: var(--diff-create-pill-color, var(--color-text-success));
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
&--removed {
|
|
71
|
-
border-color: var(--diff-delete-pill-border, var(--
|
|
72
|
-
background: var(--diff-delete-pill-bg, var(--
|
|
73
|
-
color: var(--diff-delete-pill-color, var(--
|
|
71
|
+
border-color: var(--diff-delete-pill-border, var(--color-border-danger-strong));
|
|
72
|
+
background: var(--diff-delete-pill-bg, var(--color-border-danger));
|
|
73
|
+
color: var(--diff-delete-pill-color, var(--color-text-danger));
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
|
|
@@ -80,31 +80,31 @@
|
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
&__where {
|
|
83
|
-
color: var(--
|
|
83
|
+
color: var(--color-text-secondary);
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
&__details {
|
|
87
87
|
display: flex;
|
|
88
88
|
flex-direction: column;
|
|
89
|
-
gap: calc(var(--
|
|
90
|
-
margin-top: calc(var(--
|
|
91
|
-
padding-inline-start: calc(var(--
|
|
92
|
-
border-inline-start: 2px solid var(--
|
|
89
|
+
gap: calc(var(--spacer-3) * 0.2);
|
|
90
|
+
margin-top: calc(var(--spacer-3) * 0.3);
|
|
91
|
+
padding-inline-start: calc(var(--spacer-3) * 0.5);
|
|
92
|
+
border-inline-start: 2px solid var(--color-bg-hover);
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
&__detail {
|
|
96
96
|
display: flex;
|
|
97
97
|
flex-wrap: wrap;
|
|
98
98
|
align-items: baseline;
|
|
99
|
-
gap: calc(var(--
|
|
99
|
+
gap: calc(var(--spacer-3) * 0.25);
|
|
100
100
|
min-width: 0;
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
&__detail-label {
|
|
104
104
|
display: inline-flex;
|
|
105
105
|
align-items: baseline;
|
|
106
|
-
gap: calc(var(--
|
|
107
|
-
color: var(--
|
|
106
|
+
gap: calc(var(--spacer-3) * 0.2);
|
|
107
|
+
color: var(--color-text-secondary);
|
|
108
108
|
|
|
109
109
|
&::after {
|
|
110
110
|
content: ':';
|
|
@@ -117,59 +117,59 @@
|
|
|
117
117
|
|
|
118
118
|
&__value,
|
|
119
119
|
&__class {
|
|
120
|
-
padding: 0 calc(var(--
|
|
121
|
-
border-radius: var(--
|
|
120
|
+
padding: 0 calc(var(--spacer-3) * 0.15);
|
|
121
|
+
border-radius: var(--radius-medium);
|
|
122
122
|
text-decoration: none;
|
|
123
123
|
overflow-wrap: anywhere;
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
&__value--del {
|
|
127
|
-
background: var(--diff-delete-parent-bg, var(--
|
|
128
|
-
color: var(--diff-delete-parent-color, var(--
|
|
127
|
+
background: var(--diff-delete-parent-bg, var(--color-bg-danger-tertiary));
|
|
128
|
+
color: var(--diff-delete-parent-color, var(--color-text-danger));
|
|
129
129
|
text-decoration: line-through;
|
|
130
|
-
text-decoration-color: var(--diff-delete-pill-border, var(--
|
|
130
|
+
text-decoration-color: var(--diff-delete-pill-border, var(--color-border-danger-strong));
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
&__value--ins {
|
|
134
|
-
background: var(--diff-create-parent-bg, var(--
|
|
135
|
-
color: var(--diff-create-parent-color, var(--
|
|
134
|
+
background: var(--diff-create-parent-bg, var(--color-bg-success-tertiary));
|
|
135
|
+
color: var(--diff-create-parent-color, var(--color-text-success));
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
&__class {
|
|
139
|
-
font-family: var(--
|
|
140
|
-
font-size: calc(var(--
|
|
139
|
+
font-family: var(--text-mono-family, ui-monospace, monospace);
|
|
140
|
+
font-size: calc(var(--spacer-3) * 0.55);
|
|
141
141
|
}
|
|
142
142
|
|
|
143
143
|
&__empty {
|
|
144
|
-
color: var(--
|
|
144
|
+
color: var(--color-text-tertiary);
|
|
145
145
|
font-style: italic;
|
|
146
146
|
}
|
|
147
147
|
|
|
148
148
|
&__arrow {
|
|
149
|
-
color: var(--
|
|
149
|
+
color: var(--color-text-tertiary);
|
|
150
150
|
}
|
|
151
151
|
|
|
152
152
|
&__json {
|
|
153
|
-
border-top: 1px solid var(--
|
|
154
|
-
padding-top: calc(var(--
|
|
153
|
+
border-top: 1px solid var(--color-bg-hover);
|
|
154
|
+
padding-top: calc(var(--spacer-3) * 0.4);
|
|
155
155
|
}
|
|
156
156
|
|
|
157
157
|
&__json-summary {
|
|
158
158
|
cursor: pointer;
|
|
159
|
-
color: var(--
|
|
159
|
+
color: var(--color-text-secondary);
|
|
160
160
|
width: fit-content;
|
|
161
161
|
|
|
162
162
|
&:hover {
|
|
163
|
-
color: var(--
|
|
163
|
+
color: var(--color-text);
|
|
164
164
|
}
|
|
165
165
|
}
|
|
166
166
|
|
|
167
167
|
&__json-content {
|
|
168
168
|
display: grid;
|
|
169
169
|
// Same columns as Payload's field diffs: old on the left, new on the right.
|
|
170
|
-
grid-template-columns: calc(50% - var(--
|
|
171
|
-
gap: var(--
|
|
172
|
-
margin-top: calc(var(--
|
|
170
|
+
grid-template-columns: calc(50% - var(--spacer-3) * 0.5) calc(50% - var(--spacer-3) * 0.5);
|
|
171
|
+
gap: var(--spacer-3);
|
|
172
|
+
margin-top: calc(var(--spacer-3) * 0.5);
|
|
173
173
|
overflow-x: auto;
|
|
174
174
|
|
|
175
175
|
pre {
|
|
@@ -7,7 +7,8 @@ import { ancestors } from './actions.js';
|
|
|
7
7
|
import { dragModeChoice, prefersReducedMotion, useDragModeSetting } from './dnd/mode.js';
|
|
8
8
|
import { dropAt } from './dnd/smooth.js';
|
|
9
9
|
import { BlockIcon, Icon } from './icons.js';
|
|
10
|
-
import { applyInlineChange, applyInlineJoin, applyInlineSplit, boundHint, inlineEditing, noteInlineStart, refuseLockedInline, stopInlineEditing } from './inline.js';
|
|
10
|
+
import { applyInlineChange, applyInlineJoin, applyInlineSplit, boundHint, endRegionInline, inlineEditing, noteInlineStart, refuseLockedInline, stopInlineEditing, } from './inline.js';
|
|
11
|
+
import { regionAt, selectOwner } from './regions/select.js';
|
|
11
12
|
import { blockName } from './names.js';
|
|
12
13
|
import { MenuButton } from './menu/Menu.js';
|
|
13
14
|
import { playMotion } from './motion/play.js';
|
|
@@ -131,6 +132,7 @@ export function Canvas() {
|
|
|
131
132
|
}
|
|
132
133
|
if (message.kind === 'leave') {
|
|
133
134
|
store.hover(null);
|
|
135
|
+
runtime.regions?.hovered.set(null);
|
|
134
136
|
window.clearTimeout(spotTimer);
|
|
135
137
|
spotTimer = window.setTimeout(() => runtime.insertSpot.set(null), SPOT_LINGER_MS);
|
|
136
138
|
return;
|
|
@@ -140,6 +142,10 @@ export function Canvas() {
|
|
|
140
142
|
return;
|
|
141
143
|
const { layout } = store.getState();
|
|
142
144
|
const hit = deepestBlockAt(layout, m, message);
|
|
145
|
+
// Over no block: maybe over a fixed region of the page frame.
|
|
146
|
+
const region = !hit && runtime.regions ? regionAt(m, message) : null;
|
|
147
|
+
if (runtime.regions && runtime.regions.hovered.get() !== region)
|
|
148
|
+
runtime.regions.hovered.set(region);
|
|
143
149
|
if (message.kind === 'move') {
|
|
144
150
|
store.hover(hit);
|
|
145
151
|
const band = Math.max(EDGE_BAND, SPOT_BAND_PX / (runtime.frame.get().zoom || 1));
|
|
@@ -148,8 +154,14 @@ export function Canvas() {
|
|
|
148
154
|
const selected = selectedId ? { id: selectedId, tolerance: SELECTED_EDGE_PX / (runtime.frame.get().zoom || 1) } : undefined;
|
|
149
155
|
setSpot(inline.get() ? null : insertSpotAt(layout, runtime.config.blocks, m, message, { band, selected }));
|
|
150
156
|
}
|
|
151
|
-
if (message.kind === 'click')
|
|
152
|
-
|
|
157
|
+
if (message.kind === 'click') {
|
|
158
|
+
if (region && runtime.regions)
|
|
159
|
+
runtime.regions.selected.set(region);
|
|
160
|
+
else {
|
|
161
|
+
runtime.regions?.selected.set(null);
|
|
162
|
+
store.select(hit);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
153
165
|
return;
|
|
154
166
|
}
|
|
155
167
|
case 'key':
|
|
@@ -164,11 +176,19 @@ export function Canvas() {
|
|
|
164
176
|
runtime.canvasError.set(message.message);
|
|
165
177
|
return;
|
|
166
178
|
case 'inlineStart':
|
|
167
|
-
|
|
179
|
+
selectOwner(runtime, message);
|
|
168
180
|
if (refuseLockedInline(runtime, message))
|
|
169
181
|
return;
|
|
170
182
|
noteInlineStart(runtime, message);
|
|
171
|
-
inline.set({
|
|
183
|
+
inline.set({
|
|
184
|
+
session: message.session,
|
|
185
|
+
id: message.id,
|
|
186
|
+
path: message.path,
|
|
187
|
+
kind: message.kind,
|
|
188
|
+
format: null,
|
|
189
|
+
linkRequest: 0,
|
|
190
|
+
...(message.region ? { region: message.region } : {}),
|
|
191
|
+
});
|
|
172
192
|
store.hover(null);
|
|
173
193
|
return;
|
|
174
194
|
case 'inlineChange':
|
|
@@ -177,6 +197,8 @@ export function Canvas() {
|
|
|
177
197
|
case 'inlineEnd':
|
|
178
198
|
if (inline.get()?.session === message.session)
|
|
179
199
|
inline.set(null);
|
|
200
|
+
if (message.region)
|
|
201
|
+
endRegionInline(runtime, message);
|
|
180
202
|
return;
|
|
181
203
|
case 'inlineSplit':
|
|
182
204
|
applyInlineSplit(runtime, message);
|
|
@@ -211,7 +233,7 @@ export function Canvas() {
|
|
|
211
233
|
return;
|
|
212
234
|
}
|
|
213
235
|
case 'imageEdit':
|
|
214
|
-
|
|
236
|
+
selectOwner(runtime, message.target);
|
|
215
237
|
updateImageEditor(runtime, { hover: message.target, open: { target: message.target, spot: 0, at: Date.now() } });
|
|
216
238
|
return;
|
|
217
239
|
case 'imageDrop': {
|
|
@@ -223,8 +245,8 @@ export function Canvas() {
|
|
|
223
245
|
runtime.warn(spot.kind === 'video' ? 'Drop a video file to replace this video.' : 'Drop an image file to replace this image.');
|
|
224
246
|
return;
|
|
225
247
|
}
|
|
226
|
-
|
|
227
|
-
void uploadImage(runtime, message.target
|
|
248
|
+
selectOwner(runtime, message.target);
|
|
249
|
+
void uploadImage(runtime, message.target, spot.path, message.file);
|
|
228
250
|
}
|
|
229
251
|
}
|
|
230
252
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import {
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { useCallback } from 'react';
|
|
4
4
|
import { registerGhost, smoothView } from './dnd/smooth.js';
|
|
5
5
|
import { BlockIcon } from './icons.js';
|
|
@@ -63,6 +63,8 @@ export function Editor({ config, meta, icon, locale }) {
|
|
|
63
63
|
useEffect(() => () => runtime.assistant?.stop(), [runtime]);
|
|
64
64
|
// The hidden thumbnail iframe goes with the editor.
|
|
65
65
|
useEffect(() => () => runtime.thumbnails.dispose(), [runtime]);
|
|
66
|
+
// The page's fixed regions: their values and the user's access, once the editor runs in the browser.
|
|
67
|
+
useEffect(() => void runtime.regions?.load(), [runtime]);
|
|
66
68
|
const stopAutoScroll = useRef(null);
|
|
67
69
|
const dndId = useId();
|
|
68
70
|
const sensors = useSensors(useSensor(PointerSensor, { activationConstraint: { distance: 4 } }));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import {
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
// The rich text toolbar shown over a rich text block while it is edited on the canvas. It lives
|
|
4
4
|
// in the admin overlay (Payload's look, never the site's CSS) and sends commands to the Lexical
|
|
5
5
|
// editor in the canvas iframe. Buttons keep the keyboard focus in the iframe (no focus on press).
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import {
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { CheckboxInput } from '@payloadcms/ui';
|
|
4
4
|
import { useDeferredValue, useEffect, useState } from 'react';
|
|
5
5
|
import { findBlock, getBlockDefinition } from '../../core/index.js';
|
|
@@ -16,11 +16,13 @@ import { AssistantPanel } from './assistant/AssistantPanel.js';
|
|
|
16
16
|
import { useAccessRefresh } from './fields/access.js';
|
|
17
17
|
import { BlockContentFields } from './renderField.js';
|
|
18
18
|
import { useRuntime } from './runtime.js';
|
|
19
|
+
import { storesBuilderData } from './actions.js';
|
|
19
20
|
import { shortcutList } from './shortcuts.js';
|
|
20
21
|
import { useEditor } from './store.js';
|
|
21
22
|
import { StylesPanel } from './styles/StylesPanel.js';
|
|
22
23
|
import { usePayloadControlNames } from './ui/payloadA11y.js';
|
|
23
|
-
import { useValue, useValueSelector } from './valueStore.js';
|
|
24
|
+
import { useOptionalValue, useValue, useValueSelector } from './valueStore.js';
|
|
25
|
+
import { RegionPane } from './regions/RegionPane.js';
|
|
24
26
|
function Tabs({ value, options, onChange, variant = 'underline' }) {
|
|
25
27
|
return (_jsx("div", { className: variant === 'segmented' ? 'builder-editor__segmented builder-editor__segmented--full' : 'builder-editor__tabs', role: "tablist", children: options.map((option) => (_jsxs("button", { type: "button", role: "tab", "aria-selected": value === option.id, className: variant === 'segmented' ? 'builder-editor__segment' : 'builder-editor__tab', onClick: () => onChange(option.id), children: [option.icon && _jsx(Icon, { name: option.icon, size: 13 }), option.label] }, option.id))) }));
|
|
26
28
|
}
|
|
@@ -65,6 +67,8 @@ function BlockPane() {
|
|
|
65
67
|
const [tab, setTab] = useState('content');
|
|
66
68
|
const [shownType, setShownType] = useState(null);
|
|
67
69
|
const focusRequest = useValue(runtime.focusRequest);
|
|
70
|
+
// A selected page region shows its own pane.
|
|
71
|
+
const region = useOptionalValue(runtime.regions?.selected ?? null);
|
|
68
72
|
// Styles and Motion stay open while the user edits blocks of one type. Another type opens its content,
|
|
69
73
|
// so its fields never seem to vanish.
|
|
70
74
|
if (block && block.type !== shownType) {
|
|
@@ -89,12 +93,15 @@ function BlockPane() {
|
|
|
89
93
|
return () => cancelAnimationFrame(frame);
|
|
90
94
|
}, [block, focusRequest, runtime]);
|
|
91
95
|
if (!block)
|
|
92
|
-
return _jsx(EmptyState, {});
|
|
93
|
-
return (_jsxs("div", { className: "builder-editor__block-pane", children: [_jsx(BlockHeader, { block: block }), _jsx(BlockProblems, { blockId: block.id }), _jsx(EditingBanner, { blockId: block.id }), _jsx(LocaleNote, { blockId: block.id, tab: tab }), _jsx(Tabs, { value: tab, onChange: setTab, options:
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
96
|
+
return region && runtime.regions ? _jsx(RegionPane, { regions: runtime.regions, name: region }, region) : _jsx(EmptyState, {});
|
|
97
|
+
return (_jsxs("div", { className: "builder-editor__block-pane", children: [_jsx(BlockHeader, { block: block }), _jsx(BlockProblems, { blockId: block.id }), _jsx(EditingBanner, { blockId: block.id }), _jsx(LocaleNote, { blockId: block.id, tab: tab }), _jsx(Tabs, { value: tab, onChange: setTab, options: storesBuilderData(runtime)
|
|
98
|
+
? [
|
|
99
|
+
{ id: 'content', label: 'Content' },
|
|
100
|
+
{ id: 'styles', label: 'Styles' },
|
|
101
|
+
{ id: 'motion', label: 'Motion' },
|
|
102
|
+
]
|
|
103
|
+
: // A Payload blocks field holds the blocks' own fields only.
|
|
104
|
+
[{ id: 'content', label: 'Content' }] }), tab === 'content' && _jsx(BlockContentFields, { block: block }), tab === 'styles' && storesBuilderData(runtime) && _jsx(StyleFields, { block: block }), tab === 'motion' && storesBuilderData(runtime) && _jsx(MotionPanel, { blockId: block.id, blockType: block.type, motion: block.motion })] }, block.id));
|
|
98
105
|
}
|
|
99
106
|
/** What stopped the last publish, for this block. */
|
|
100
107
|
function BlockProblems({ blockId }) {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import {
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { useDraggable } from '@dnd-kit/core';
|
|
4
4
|
import { memo, useCallback, useEffect, useMemo, useRef, useState, } from 'react';
|
|
5
5
|
import { describeMotion, findLocation, getBlockDefinition, slotNames, walkBlocks } from '../../core/index.js';
|
|
6
|
-
import { ancestors, renameBlock, toggleHidden } from './actions.js';
|
|
6
|
+
import { ancestors, renameBlock, storesBuilderData, toggleHidden } from './actions.js';
|
|
7
|
+
import { countText } from './counts.js';
|
|
7
8
|
import { BlockIcon, Icon } from './icons.js';
|
|
8
9
|
import { PeerDots } from './live/PresenceUI.js';
|
|
9
10
|
import { missingWords, useUntranslated } from './locale/locale.js';
|
|
@@ -11,6 +12,7 @@ import { BLOCK_KEYS, keyText } from './menu/keys.js';
|
|
|
11
12
|
import { openBlockMenu, renameRequest } from './menu/requests.js';
|
|
12
13
|
import { blockPreview, blockSummary, childrenOf, customLabel, typeName } from './names.js';
|
|
13
14
|
import { OUTLINE_INDENT, useRuntime } from './runtime.js';
|
|
15
|
+
import { RegionRows } from './regions/RegionRows.js';
|
|
14
16
|
import { useEditor } from './store.js';
|
|
15
17
|
import { findBindingField, listAncestor, URL_PATH } from './templates/binding.js';
|
|
16
18
|
import { useValue, useValueSelector } from './valueStore.js';
|
|
@@ -226,14 +228,14 @@ export function Outline() {
|
|
|
226
228
|
}
|
|
227
229
|
}
|
|
228
230
|
};
|
|
229
|
-
return (_jsxs("div", { className: "builder-editor__panel builder-editor__panel--grow builder-editor__outline-panel", children: [_jsxs("div", { className: "builder-editor__panel-head builder-left__tools", children: [_jsx("span", { className: "builder-left__note", children: total
|
|
231
|
+
return (_jsxs("div", { className: "builder-editor__panel builder-editor__panel--grow builder-editor__outline-panel", children: [_jsxs("div", { className: "builder-editor__panel-head builder-left__tools", children: [_jsx("span", { className: "builder-left__note", children: countText(total, { none: 'No blocks', one: 'block', many: 'blocks' }) }), _jsxs("span", { className: "builder-editor__panel-tools", children: [_jsx("button", { type: "button", className: "builder-editor__icon-button builder-editor__icon-button--small", "aria-label": "Collapse all", "data-tooltip": "Collapse all", onClick: () => {
|
|
230
232
|
const ids = new Set(runtime.collapsed.get());
|
|
231
233
|
walkBlocks(layout, (b) => {
|
|
232
234
|
if (childrenOf(b).length > 0)
|
|
233
235
|
ids.add(b.id);
|
|
234
236
|
});
|
|
235
237
|
runtime.collapsed.set(ids);
|
|
236
|
-
}, children: _jsx(Icon, { name: "chevronRight", size: 14 }) }), _jsx("button", { type: "button", className: "builder-editor__icon-button builder-editor__icon-button--small", "aria-label": "Expand all", "data-tooltip": "Expand all", onClick: () => runtime.collapsed.set(new Set()), children: _jsx(Icon, { name: "chevronDown", size: 14 }) })] })] }), rows.length === 0 ? (_jsx("div", { ref: outlineRef, className: "builder-editor__outline", children: _jsxs("div", { className: "builder-editor__empty", children: [_jsx(Icon, { name: "layers", size: 20 }), _jsx("p", { children: "The page is empty." }), _jsx("p", { className: "builder-editor__hint", children: "Add blocks from the Blocks or Sections tab: drag them onto the canvas, or click one." })] }) })) : (_jsx("div", { ref: outlineRef, className: "builder-editor__outline", role: "tree", "aria-label": "Layers", tabIndex: -1, onKeyDown: onKeyDown, children: rows.map((row) => (_jsx(OutlineRow, { block: row.block, depth: row.depth, container: row.container, open: row.open, childCount: row.childCount, text: row.text, issues: issues.get(row.block.id) ?? NO_ISSUES, untranslated: untranslated.get(row.block.id)?.length ?? 0, missing: missing, broken: broken.has(row.block.id), focusable: noSelectedRow && row.block.id === firstId, renaming: renaming === row.block.id, onRename: onRename }, row.block.id))) }))] }));
|
|
238
|
+
}, children: _jsx(Icon, { name: "chevronRight", size: 14 }) }), _jsx("button", { type: "button", className: "builder-editor__icon-button builder-editor__icon-button--small", "aria-label": "Expand all", "data-tooltip": "Expand all", onClick: () => runtime.collapsed.set(new Set()), children: _jsx(Icon, { name: "chevronDown", size: 14 }) })] })] }), _jsx(RegionRows, {}), rows.length === 0 ? (_jsx("div", { ref: outlineRef, className: "builder-editor__outline", children: _jsxs("div", { className: "builder-editor__empty", children: [_jsx(Icon, { name: "layers", size: 20 }), _jsx("p", { children: "The page is empty." }), _jsx("p", { className: "builder-editor__hint", children: "Add blocks from the Blocks or Sections tab: drag them onto the canvas, or click one." })] }) })) : (_jsx("div", { ref: outlineRef, className: "builder-editor__outline", role: "tree", "aria-label": "Layers", tabIndex: -1, onKeyDown: onKeyDown, children: rows.map((row) => (_jsx(OutlineRow, { block: row.block, depth: row.depth, container: row.container, open: row.open, childCount: row.childCount, text: row.text, issues: issues.get(row.block.id) ?? NO_ISSUES, untranslated: untranslated.get(row.block.id)?.length ?? 0, missing: missing, broken: broken.has(row.block.id), focusable: noSelectedRow && row.block.id === firstId, renaming: renaming === row.block.id, onRename: onRename }, row.block.id))) }))] }));
|
|
237
239
|
}
|
|
238
240
|
/** Inline actions must not start a drag or select the row. */
|
|
239
241
|
const stop = (e) => e.stopPropagation();
|
|
@@ -271,12 +273,16 @@ const OutlineRow = memo(function OutlineRow({ block, depth, container, open, chi
|
|
|
271
273
|
// Two hover actions, so the row keeps room for its name. Rename, duplicate and delete are in
|
|
272
274
|
// the menu and on their keys.
|
|
273
275
|
const actions = [
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
276
|
+
...(storesBuilderData(runtime)
|
|
277
|
+
? [
|
|
278
|
+
{
|
|
279
|
+
icon: (block.hidden ? 'eye' : 'eyeOff'),
|
|
280
|
+
label: block.hidden ? 'Show on the site' : 'Hide on the site',
|
|
281
|
+
tooltip: `${block.hidden ? 'Show on the site' : 'Hide on the site'} · ${keyText(BLOCK_KEYS.hide)}`,
|
|
282
|
+
run: () => toggleHidden(runtime, block.id),
|
|
283
|
+
},
|
|
284
|
+
]
|
|
285
|
+
: []),
|
|
280
286
|
{
|
|
281
287
|
icon: 'more',
|
|
282
288
|
label: 'More actions',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import {
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { useDraggable } from '@dnd-kit/core';
|
|
4
4
|
import { findBlock, findLocation } from '../../core/index.js';
|
|
5
5
|
import { smoothView } from './dnd/smooth.js';
|
|
@@ -12,6 +12,7 @@ import { BlockContextMenu, blockMenuEntries } from './menu/blockMenu.js';
|
|
|
12
12
|
import { MenuButton } from './menu/Menu.js';
|
|
13
13
|
import { blockName } from './names.js';
|
|
14
14
|
import { PeerCursors, PeerSelections } from './live/PresenceUI.js';
|
|
15
|
+
import { RegionOverlay } from './regions/RegionOverlay.js';
|
|
15
16
|
import { shortName } from './live/presence.js';
|
|
16
17
|
import { toRect, useRuntime } from './runtime.js';
|
|
17
18
|
import { useEditor } from './store.js';
|
|
@@ -124,7 +125,7 @@ export function Overlay() {
|
|
|
124
125
|
transform: `translate3d(${smooth.placeholder.x}px, ${smooth.placeholder.y}px, 0)`,
|
|
125
126
|
width: smooth.placeholder.width,
|
|
126
127
|
height: smooth.placeholder.height,
|
|
127
|
-
}, children: _jsx("span", { className: "builder-editor__drop-label builder-dnd-gap__label", hidden: !smooth.into, "data-label": smooth.into ? `Into ${smooth.into}` : '', children: _jsx(Icon, { name: "plus", size: 12 }) }) }) })), hovered && hoverRect && (_jsx("div", { className: "builder-editor__hover", style: box(hoverRect), children: _jsxs("span", { ...tagProps(hoverRect, 'hover'), children: [_jsx(BlockIcon, { name: runtime.blockIcon(hovered.type), size: 12 }), blockName(hovered, runtime.blockLabel(hovered.type))] }) })), sourceRect && _jsx("div", { className: "builder-editor__source", style: box(sourceRect) }), selected && selectedRect && (_jsxs(_Fragment, { children: [_jsxs("div", { hidden: Boolean(smooth), className: `builder-editor__selection${selected.hidden ? ' builder-editor__selection--hidden' : ''}${editing ? ' builder-editor__selection--editing' : ''}`, style: box(editing && editRect ? editRect : selectedRect), children: [editing && editRect && inline?.kind !== 'rich' && (_jsxs("span", { ...tagProps(editRect, 'editing'), children: [_jsx(Icon, { name: "rename", size: 12 }), "Editing text \u00B7 Esc to finish"] })), !drag && !editing && (_jsxs("span", { ...tagProps(selectedRect, undefined, selectedRect.width * zoom < NARROW_BLOCK), children: [_jsx(BlockIcon, { name: runtime.blockIcon(selected.type), size: 12 }), blockName(selected, runtime.blockLabel(selected.type)), selected.bindings && Object.keys(selected.bindings).length > 0 && (_jsx("span", { className: "builder-editor__tag-bound", "data-tooltip": "Shows data from a document", children: _jsx(Icon, { name: "bind", size: 11 }) })), selected.hidden && _jsx(Icon, { name: "eyeOff", size: 12 })] }))] }), _jsx(ActionBar, { id: selected.id, label: runtime.blockLabel(selected.type), icon: runtime.blockIcon(selected.type), parentId: findLocation(layout, selected.id)?.parentId ?? null, rect: selectedRect, inside: !roomAbove(selectedRect), below: selectedRect.width * zoom < NARROW_BLOCK, hidden: Boolean(drag) || Boolean(smooth) || editing }), editing && editRect && inline?.kind === 'rich' && _jsx(InlineToolbar, { inline: inline, rect: editRect, zoom: zoom })] })), _jsx(InsertHandle, {}), _jsx(ImageEditor, {}), _jsx(BlockContextMenu, {}), _jsx(Tooltips, {}), _jsx(PeerCursors, {}), indicator && (_jsx("div", { className: `builder-editor__drop builder-editor__drop--${indicator.kind}`, style: box(indicator.rect), children: dropParent && (_jsxs("span", { className: "builder-editor__drop-label", children: [_jsx(Icon, { name: "plus", size: 12 }), " Into ", runtime.blockLabel(dropParent.type)] })) })), _jsx(PeerSelections, {}), [...(live?.changes ?? [])].map(([id, change]) => {
|
|
128
|
+
}, children: _jsx("span", { className: "builder-editor__drop-label builder-dnd-gap__label", hidden: !smooth.into, "data-label": smooth.into ? `Into ${smooth.into}` : '', children: _jsx(Icon, { name: "plus", size: 12 }) }) }) })), hovered && hoverRect && (_jsx("div", { className: "builder-editor__hover", style: box(hoverRect), children: _jsxs("span", { ...tagProps(hoverRect, 'hover'), children: [_jsx(BlockIcon, { name: runtime.blockIcon(hovered.type), size: 12 }), blockName(hovered, runtime.blockLabel(hovered.type))] }) })), sourceRect && _jsx("div", { className: "builder-editor__source", style: box(sourceRect) }), selected && selectedRect && (_jsxs(_Fragment, { children: [_jsxs("div", { hidden: Boolean(smooth), className: `builder-editor__selection${selected.hidden ? ' builder-editor__selection--hidden' : ''}${editing ? ' builder-editor__selection--editing' : ''}`, style: box(editing && editRect ? editRect : selectedRect), children: [editing && editRect && inline?.kind !== 'rich' && (_jsxs("span", { ...tagProps(editRect, 'editing'), children: [_jsx(Icon, { name: "rename", size: 12 }), "Editing text \u00B7 Esc to finish"] })), !drag && !editing && (_jsxs("span", { ...tagProps(selectedRect, undefined, selectedRect.width * zoom < NARROW_BLOCK), children: [_jsx(BlockIcon, { name: runtime.blockIcon(selected.type), size: 12 }), blockName(selected, runtime.blockLabel(selected.type)), selected.bindings && Object.keys(selected.bindings).length > 0 && (_jsx("span", { className: "builder-editor__tag-bound", "data-tooltip": "Shows data from a document", children: _jsx(Icon, { name: "bind", size: 11 }) })), selected.hidden && _jsx(Icon, { name: "eyeOff", size: 12 })] }))] }), _jsx(ActionBar, { id: selected.id, label: runtime.blockLabel(selected.type), icon: runtime.blockIcon(selected.type), parentId: findLocation(layout, selected.id)?.parentId ?? null, rect: selectedRect, inside: !roomAbove(selectedRect), below: selectedRect.width * zoom < NARROW_BLOCK, hidden: Boolean(drag) || Boolean(smooth) || editing }), editing && editRect && inline?.kind === 'rich' && _jsx(InlineToolbar, { inline: inline, rect: editRect, zoom: zoom })] })), _jsx(RegionOverlay, { tagProps: tagProps, editedRect: inline?.region ? editedRect(runtime.iframeRef.current) : null, zoom: zoom }), _jsx(InsertHandle, {}), _jsx(ImageEditor, {}), _jsx(BlockContextMenu, {}), _jsx(Tooltips, {}), _jsx(PeerCursors, {}), indicator && (_jsx("div", { className: `builder-editor__drop builder-editor__drop--${indicator.kind}`, style: box(indicator.rect), children: dropParent && (_jsxs("span", { className: "builder-editor__drop-label", children: [_jsx(Icon, { name: "plus", size: 12 }), " Into ", runtime.blockLabel(dropParent.type)] })) })), _jsx(PeerSelections, {}), [...(live?.changes ?? [])].map(([id, change]) => {
|
|
128
129
|
const rect = rectOf(id);
|
|
129
130
|
if (!rect)
|
|
130
131
|
return null;
|
|
@@ -32,6 +32,11 @@ export declare function insertBlocks(runtime: Runtime, blocks: Block[], to: Posi
|
|
|
32
32
|
export declare function duplicateBlock(runtime: Runtime, id: string): void;
|
|
33
33
|
export declare function removeBlock(runtime: Runtime, id: string): void;
|
|
34
34
|
export declare function toggleHidden(runtime: Runtime, id: string): void;
|
|
35
|
+
/**
|
|
36
|
+
* True when the layout field stores the builder's own block data (Tailwind classes, animations,
|
|
37
|
+
* bindings, hidden blocks). False for a Payload blocks field: its blocks hold their fields only.
|
|
38
|
+
*/
|
|
39
|
+
export declare function storesBuilderData(runtime: Pick<Runtime, 'config'>): boolean;
|
|
35
40
|
/** Gives a block its own name in the outline and the breadcrumbs. An empty name removes it. */
|
|
36
41
|
export declare function renameBlock(runtime: Runtime, id: string, label: string): void;
|
|
37
42
|
/** How many blocks are in the list `slot` of `parentId` (the page itself when `parentId` is null). */
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// shortcuts: insert, duplicate, remove, hide, move, copy and paste (blocks and styles).
|
|
4
4
|
import { createId, findBlock, findLocation, getBlockDefinition, slotAcceptsAt, slotNames } from '../../core/index.js';
|
|
5
5
|
import { normalizeClasses, parseStyles, setStylesOps, stylesText } from './menu/styleClipboard.js';
|
|
6
|
+
import { countText } from './counts.js';
|
|
6
7
|
/**
|
|
7
8
|
* Where a click-inserted block goes: into the selected container's first slot, else after the
|
|
8
9
|
* selected block, else at the end of the page. Each choice must pass the nesting rules (a form
|
|
@@ -112,10 +113,22 @@ export function removeBlock(runtime, id) {
|
|
|
112
113
|
runtime.store.apply({ type: 'remove', id }, { select: selectedId === id ? parentId : undefined });
|
|
113
114
|
}
|
|
114
115
|
export function toggleHidden(runtime, id) {
|
|
116
|
+
// A Payload blocks field has no "hidden" for a block: the change would not survive a reload.
|
|
117
|
+
if (!storesBuilderData(runtime)) {
|
|
118
|
+
runtime.notify('Blocks of this page cannot be hidden: its blocks field has no place for it.');
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
115
121
|
const block = findBlock(runtime.store.getState().layout, id);
|
|
116
122
|
if (block)
|
|
117
123
|
runtime.store.apply({ type: 'update', id, hidden: !block.hidden });
|
|
118
124
|
}
|
|
125
|
+
/**
|
|
126
|
+
* True when the layout field stores the builder's own block data (Tailwind classes, animations,
|
|
127
|
+
* bindings, hidden blocks). False for a Payload blocks field: its blocks hold their fields only.
|
|
128
|
+
*/
|
|
129
|
+
export function storesBuilderData(runtime) {
|
|
130
|
+
return runtime.config.storage !== 'payload-blocks';
|
|
131
|
+
}
|
|
119
132
|
/** Gives a block its own name in the outline and the breadcrumbs. An empty name removes it. */
|
|
120
133
|
export function renameBlock(runtime, id, label) {
|
|
121
134
|
const block = findBlock(runtime.store.getState().layout, id);
|
|
@@ -245,7 +258,7 @@ export function pasteBlocks(runtime, blocks) {
|
|
|
245
258
|
return false;
|
|
246
259
|
const done = insertBlocks(runtime, blocks, insertPosition(runtime, first));
|
|
247
260
|
if (done)
|
|
248
|
-
runtime.notify(blocks.length === 1 ? `Pasted ${runtime.blockLabel(first.type)}` : `Pasted ${blocks.length
|
|
261
|
+
runtime.notify(blocks.length === 1 ? `Pasted ${runtime.blockLabel(first.type)}` : `Pasted ${countText(blocks.length, { one: 'block', many: 'blocks' })}`);
|
|
249
262
|
return done;
|
|
250
263
|
}
|
|
251
264
|
// ---------------------------------------------------------------------------
|
|
@@ -265,6 +278,10 @@ export function storedStyles() {
|
|
|
265
278
|
}
|
|
266
279
|
/** Copies the block's classes (all breakpoints and states) and animations. Other tabs and pages can paste them. */
|
|
267
280
|
export function copyStyles(runtime, id) {
|
|
281
|
+
if (!storesBuilderData(runtime)) {
|
|
282
|
+
runtime.notify('Blocks of this page have no styles: their blocks field has no place for them.');
|
|
283
|
+
return false;
|
|
284
|
+
}
|
|
268
285
|
const block = findBlock(runtime.store.getState().layout, id);
|
|
269
286
|
if (!block)
|
|
270
287
|
return false;
|
|
@@ -300,6 +317,11 @@ export function resetStyles(runtime, ids) {
|
|
|
300
317
|
return applyStyles(runtime, ids, { className: '' }, 'Styles reset');
|
|
301
318
|
}
|
|
302
319
|
function applyStyles(runtime, ids, styles, notice) {
|
|
320
|
+
// A Payload blocks field stores no classes or animations: the change would not be saved.
|
|
321
|
+
if (!storesBuilderData(runtime)) {
|
|
322
|
+
runtime.notify('Blocks of this page have no styles: their blocks field has no place for them.');
|
|
323
|
+
return false;
|
|
324
|
+
}
|
|
303
325
|
const ops = setStylesOps(runtime.store.getState().layout, runtime.config.blocks, ids, styles);
|
|
304
326
|
if (ops.length === 0) {
|
|
305
327
|
runtime.notify('The styles are the same already.');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import {
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
// The Assistant tab of the inspector: the chat with the AI that edits this layout.
|
|
4
4
|
// State lives in the runtime's assistant controller; this file only renders it.
|
|
5
5
|
import { useEffect, useLayoutEffect, useRef, useState } from 'react';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import {
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
// "Use Claude Code or Codex": connect the official CLIs (signed in with a Claude Pro/Max or
|
|
4
4
|
// ChatGPT plan) to this site's MCP endpoint. They edit pages through the live channel, so changes
|
|
5
5
|
// appear in the open editor. Subscriptions are never used as API keys: the CLIs are the MCP clients.
|