@backmatter/studio 0.0.19 → 0.0.21
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/chunks/{UiKitApp-B1ANqCac.js → UiKitApp-CMMcsaX4.js} +2 -2
- package/dist/chunks/{WorkspaceRoutes-BHNGrf-j.js → WorkspaceRoutes-DW0sLdpJ.js} +27141 -26236
- package/dist/chunks/dashboard-By0P4Yny.js +1879 -0
- package/dist/chunks/{index-HYioDjux.js → index-DTPUqaHE.js} +1 -1
- package/dist/dashboard.js +2 -2
- package/dist/index.js +205 -194
- package/dist/site-widget.css +208 -0
- package/dist/site-widget.js +10495 -9947
- package/dist/studio.css +280 -24
- package/package.json +2 -2
- package/src/App.tsx +7 -1
- package/src/api.ts +113 -13
- package/src/chat/ChatFiles.tsx +261 -0
- package/src/chat/ChatMessage.tsx +5 -0
- package/src/chat/ChatPanel.tsx +218 -14
- package/src/chat/ChatProvider.tsx +72 -22
- package/src/chat/Composer.tsx +83 -6
- package/src/chat/PendingFileRow.tsx +188 -0
- package/src/chat/chat-context.ts +7 -1
- package/src/chat/chat-helpers.ts +49 -0
- package/src/chat/chat-state.ts +17 -6
- package/src/chat/icons.tsx +28 -0
- package/src/chat/model-copy.ts +41 -0
- package/src/chat/pending-files.ts +236 -0
- package/src/chat/side-width.ts +48 -0
- package/src/chrome/AppShell.tsx +9 -1
- package/src/chrome/CommandPalette.tsx +7 -0
- package/src/chrome/ContentExplorerSidebar.tsx +43 -74
- package/src/chrome/folder-create-context.ts +56 -11
- package/src/chrome/hotkeys.ts +8 -0
- package/src/fields/FieldControl.tsx +331 -115
- package/src/fields/LinkFieldInput.tsx +13 -6
- package/src/fields/array-item-title.ts +28 -0
- package/src/fields/field-label.ts +8 -0
- package/src/host-pointer.ts +2 -0
- package/src/install-preview-pointer.ts +1 -0
- package/src/pages/BlockPicker.tsx +362 -0
- package/src/pages/BlocksList.tsx +57 -50
- package/src/pages/CliAuthorizePage.tsx +138 -25
- package/src/pages/DocEditorPage.tsx +95 -18
- package/src/pages/EmbedPublishPage.tsx +40 -2
- package/src/pages/LoginPage.tsx +118 -31
- package/src/pages/SettingsSchemaPage.tsx +19 -3
- package/src/pages/WorkspaceLayout.tsx +16 -1
- package/src/pages/block-picker.ts +116 -0
- package/src/pages/editor-grab.ts +61 -13
- package/src/pages/preview-split.ts +24 -0
- package/src/pages/session-preview.ts +1 -0
- package/src/replica/types.ts +2 -0
- package/src/sign-in-link.ts +45 -0
- package/src/site-pointer.ts +14 -1
- package/src/site-widget.tsx +12 -1
- package/src/ui/Field.tsx +26 -0
- package/src/workspace/schema-source.tsx +126 -0
- package/dist/chunks/dashboard-b-W6dGm5.js +0 -1779
- package/src/site-devbar-overlay-inject.ts +0 -15
- package/src/site-publish-menu.tsx +0 -33
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
// packages/studio/src/pages/BlockPicker.tsx
|
|
2
|
+
// "Add block" menu: one card per block with a picture of what it looks like.
|
|
3
|
+
// Picture order: the block's declared `preview` image, then the site's
|
|
4
|
+
// `defineStudio` preview component with placeholder props, then a wireframe
|
|
5
|
+
// sketched from the block's fields.
|
|
6
|
+
import { Component, useState, type ReactNode } from "react";
|
|
7
|
+
import { Menu } from "@base-ui/react/menu";
|
|
8
|
+
import * as stylex from "@stylexjs/stylex";
|
|
9
|
+
import type { BlockSnapshot } from "../api";
|
|
10
|
+
import { useStudioDefinition } from "../define-studio";
|
|
11
|
+
import { Button } from "../ui/Button";
|
|
12
|
+
import { cx, popup, popupClassName } from "../ui/popup";
|
|
13
|
+
import { colors, radius, space, type } from "../styles/tokens.stylex";
|
|
14
|
+
import {
|
|
15
|
+
blockPreviewSrc,
|
|
16
|
+
blockWireframe,
|
|
17
|
+
sampleBlockProps,
|
|
18
|
+
type WireShape,
|
|
19
|
+
} from "./block-picker";
|
|
20
|
+
|
|
21
|
+
const hover = "@media (hover: hover)";
|
|
22
|
+
const narrow = "@media (max-width: 520px)";
|
|
23
|
+
|
|
24
|
+
class PreviewBoundary extends Component<
|
|
25
|
+
{ fallback: ReactNode; children: ReactNode },
|
|
26
|
+
{ failed: boolean }
|
|
27
|
+
> {
|
|
28
|
+
state = { failed: false };
|
|
29
|
+
static getDerivedStateFromError() {
|
|
30
|
+
return { failed: true };
|
|
31
|
+
}
|
|
32
|
+
render() {
|
|
33
|
+
return this.state.failed ? this.props.fallback : this.props.children;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function Shape({ shape }: { shape: WireShape }) {
|
|
38
|
+
switch (shape.kind) {
|
|
39
|
+
case "chip":
|
|
40
|
+
return <span data-wire="chip" {...stylex.props(styles.wireChip)} />;
|
|
41
|
+
case "heading":
|
|
42
|
+
return <span data-wire="heading" {...stylex.props(styles.wireHeading)} />;
|
|
43
|
+
case "text":
|
|
44
|
+
return (
|
|
45
|
+
<span data-wire="text" {...stylex.props(styles.wireLines)}>
|
|
46
|
+
<span {...stylex.props(styles.wireLine)} />
|
|
47
|
+
<span {...stylex.props(styles.wireLine, styles.wireLineShort)} />
|
|
48
|
+
</span>
|
|
49
|
+
);
|
|
50
|
+
case "image":
|
|
51
|
+
return <span data-wire="image" {...stylex.props(styles.wireImage)} />;
|
|
52
|
+
case "button":
|
|
53
|
+
return <span data-wire="button" {...stylex.props(styles.wireButton)} />;
|
|
54
|
+
case "cards":
|
|
55
|
+
return (
|
|
56
|
+
<span data-wire="cards" {...stylex.props(styles.wireCards)}>
|
|
57
|
+
{Array.from({ length: shape.count }, (_, i) => (
|
|
58
|
+
<span key={i} {...stylex.props(styles.wireCard)} />
|
|
59
|
+
))}
|
|
60
|
+
</span>
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function BlockWireframe({ block }: { block: Pick<BlockSnapshot, "fields"> }) {
|
|
66
|
+
const { layout, shapes } = blockWireframe(block);
|
|
67
|
+
if (layout === "split") {
|
|
68
|
+
const rest = shapes.filter((s) => s.kind !== "image");
|
|
69
|
+
return (
|
|
70
|
+
<span data-wireframe="split" {...stylex.props(styles.wireframe, styles.wireSplit)}>
|
|
71
|
+
<span {...stylex.props(styles.wireColumn)}>
|
|
72
|
+
{rest.map((shape, i) => (
|
|
73
|
+
<Shape key={i} shape={shape} />
|
|
74
|
+
))}
|
|
75
|
+
</span>
|
|
76
|
+
<Shape shape={{ kind: "image" }} />
|
|
77
|
+
</span>
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
return (
|
|
81
|
+
<span data-wireframe="stack" {...stylex.props(styles.wireframe, styles.wireColumn)}>
|
|
82
|
+
{shapes.map((shape, i) => (
|
|
83
|
+
<Shape key={i} shape={shape} />
|
|
84
|
+
))}
|
|
85
|
+
</span>
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export function BlockThumbnail({
|
|
90
|
+
block,
|
|
91
|
+
siteUrl,
|
|
92
|
+
}: {
|
|
93
|
+
block: BlockSnapshot;
|
|
94
|
+
siteUrl?: string | null;
|
|
95
|
+
}) {
|
|
96
|
+
const definition = useStudioDefinition();
|
|
97
|
+
const Preview = definition.blocks?.[block.name]?.preview;
|
|
98
|
+
const src = blockPreviewSrc(block.preview, siteUrl);
|
|
99
|
+
const [imageFailed, setImageFailed] = useState(false);
|
|
100
|
+
const wireframe = <BlockWireframe block={block} />;
|
|
101
|
+
|
|
102
|
+
let content: ReactNode = wireframe;
|
|
103
|
+
if (src && !imageFailed) {
|
|
104
|
+
content = (
|
|
105
|
+
<img
|
|
106
|
+
src={src}
|
|
107
|
+
alt=""
|
|
108
|
+
loading="lazy"
|
|
109
|
+
decoding="async"
|
|
110
|
+
draggable={false}
|
|
111
|
+
onError={() => setImageFailed(true)}
|
|
112
|
+
{...stylex.props(styles.image)}
|
|
113
|
+
/>
|
|
114
|
+
);
|
|
115
|
+
} else if (Preview) {
|
|
116
|
+
content = (
|
|
117
|
+
<span data-site-preview="" {...stylex.props(styles.sitePreview)}>
|
|
118
|
+
<PreviewBoundary fallback={wireframe}>
|
|
119
|
+
<Preview type={block.name} props={sampleBlockProps(block.fields)} />
|
|
120
|
+
</PreviewBoundary>
|
|
121
|
+
</span>
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
return (
|
|
125
|
+
<span data-block-thumbnail={block.name} aria-hidden {...stylex.props(styles.thumb)}>
|
|
126
|
+
{content}
|
|
127
|
+
</span>
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export function BlockPicker({
|
|
132
|
+
catalog,
|
|
133
|
+
siteUrl,
|
|
134
|
+
disabled,
|
|
135
|
+
onPick,
|
|
136
|
+
}: {
|
|
137
|
+
catalog: BlockSnapshot[];
|
|
138
|
+
siteUrl?: string | null;
|
|
139
|
+
disabled?: boolean;
|
|
140
|
+
onPick: (type: string) => void;
|
|
141
|
+
}) {
|
|
142
|
+
const definition = useStudioDefinition();
|
|
143
|
+
return (
|
|
144
|
+
<Menu.Root>
|
|
145
|
+
<Menu.Trigger
|
|
146
|
+
disabled={disabled}
|
|
147
|
+
render={
|
|
148
|
+
<Button variant="secondary" disabled={disabled}>
|
|
149
|
+
Add block
|
|
150
|
+
</Button>
|
|
151
|
+
}
|
|
152
|
+
/>
|
|
153
|
+
<Menu.Portal>
|
|
154
|
+
<Menu.Positioner
|
|
155
|
+
side="bottom"
|
|
156
|
+
align="start"
|
|
157
|
+
sideOffset={6}
|
|
158
|
+
collisionPadding={16}
|
|
159
|
+
className={cx(popup.positioner)}
|
|
160
|
+
>
|
|
161
|
+
<Menu.Popup
|
|
162
|
+
aria-label="Add block"
|
|
163
|
+
className={(state) => popupClassName(state, styles.menu)}
|
|
164
|
+
>
|
|
165
|
+
<div {...stylex.props(styles.grid)}>
|
|
166
|
+
{catalog.map((block) => {
|
|
167
|
+
const label = definition.blocks?.[block.name]?.label ?? block.name;
|
|
168
|
+
return (
|
|
169
|
+
<Menu.Item
|
|
170
|
+
key={block.name}
|
|
171
|
+
label={label}
|
|
172
|
+
onClick={() => onPick(block.name)}
|
|
173
|
+
className={(state) =>
|
|
174
|
+
cx(styles.card, state.highlighted && styles.cardHighlighted)
|
|
175
|
+
}
|
|
176
|
+
>
|
|
177
|
+
<BlockThumbnail block={block} siteUrl={siteUrl} />
|
|
178
|
+
<span {...stylex.props(styles.cardText)}>
|
|
179
|
+
<span {...stylex.props(styles.cardName)}>{label}</span>
|
|
180
|
+
{block.description ? (
|
|
181
|
+
<span {...stylex.props(styles.cardDescription)}>
|
|
182
|
+
{block.description}
|
|
183
|
+
</span>
|
|
184
|
+
) : null}
|
|
185
|
+
</span>
|
|
186
|
+
</Menu.Item>
|
|
187
|
+
);
|
|
188
|
+
})}
|
|
189
|
+
</div>
|
|
190
|
+
</Menu.Popup>
|
|
191
|
+
</Menu.Positioner>
|
|
192
|
+
</Menu.Portal>
|
|
193
|
+
</Menu.Root>
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
const wireTone = "rgba(24, 24, 27, 0.12)";
|
|
198
|
+
const wireToneStrong = "rgba(24, 24, 27, 0.22)";
|
|
199
|
+
|
|
200
|
+
const styles = stylex.create({
|
|
201
|
+
menu: {
|
|
202
|
+
width: "34rem",
|
|
203
|
+
maxWidth: "calc(100vw - 32px)",
|
|
204
|
+
},
|
|
205
|
+
grid: {
|
|
206
|
+
display: "grid",
|
|
207
|
+
gridTemplateColumns: {
|
|
208
|
+
default: "repeat(2, minmax(0, 1fr))",
|
|
209
|
+
[narrow]: "minmax(0, 1fr)",
|
|
210
|
+
},
|
|
211
|
+
gap: space.sm,
|
|
212
|
+
padding: space.sm,
|
|
213
|
+
},
|
|
214
|
+
card: {
|
|
215
|
+
display: "flex",
|
|
216
|
+
flexDirection: "column",
|
|
217
|
+
gap: space.sm,
|
|
218
|
+
minWidth: 0,
|
|
219
|
+
padding: space.sm,
|
|
220
|
+
borderWidth: 1,
|
|
221
|
+
borderStyle: "solid",
|
|
222
|
+
borderColor: colors.border,
|
|
223
|
+
borderRadius: radius.md,
|
|
224
|
+
backgroundColor: colors.bgSurface,
|
|
225
|
+
color: colors.text,
|
|
226
|
+
cursor: "pointer",
|
|
227
|
+
outline: "none",
|
|
228
|
+
userSelect: "none",
|
|
229
|
+
transitionProperty: "border-color, background-color",
|
|
230
|
+
transitionDuration: "120ms",
|
|
231
|
+
[hover]: {
|
|
232
|
+
":hover": {
|
|
233
|
+
borderColor: colors.textMuted,
|
|
234
|
+
},
|
|
235
|
+
},
|
|
236
|
+
},
|
|
237
|
+
cardHighlighted: {
|
|
238
|
+
borderColor: colors.focus,
|
|
239
|
+
backgroundColor: colors.bgHover,
|
|
240
|
+
},
|
|
241
|
+
thumb: {
|
|
242
|
+
position: "relative",
|
|
243
|
+
display: "block",
|
|
244
|
+
aspectRatio: "16 / 10",
|
|
245
|
+
overflow: "hidden",
|
|
246
|
+
borderRadius: radius.sm,
|
|
247
|
+
backgroundColor: colors.bgPanel,
|
|
248
|
+
},
|
|
249
|
+
image: {
|
|
250
|
+
display: "block",
|
|
251
|
+
width: "100%",
|
|
252
|
+
height: "100%",
|
|
253
|
+
objectFit: "cover",
|
|
254
|
+
objectPosition: "top center",
|
|
255
|
+
},
|
|
256
|
+
sitePreview: {
|
|
257
|
+
position: "absolute",
|
|
258
|
+
inset: 0,
|
|
259
|
+
display: "block",
|
|
260
|
+
overflow: "hidden",
|
|
261
|
+
pointerEvents: "none",
|
|
262
|
+
backgroundColor: colors.bgSurface,
|
|
263
|
+
},
|
|
264
|
+
cardText: {
|
|
265
|
+
display: "flex",
|
|
266
|
+
flexDirection: "column",
|
|
267
|
+
gap: "2px",
|
|
268
|
+
minWidth: 0,
|
|
269
|
+
},
|
|
270
|
+
cardName: {
|
|
271
|
+
fontSize: type.md,
|
|
272
|
+
fontWeight: 500,
|
|
273
|
+
overflow: "hidden",
|
|
274
|
+
textOverflow: "ellipsis",
|
|
275
|
+
whiteSpace: "nowrap",
|
|
276
|
+
},
|
|
277
|
+
cardDescription: {
|
|
278
|
+
display: "-webkit-box",
|
|
279
|
+
WebkitBoxOrient: "vertical",
|
|
280
|
+
WebkitLineClamp: 2,
|
|
281
|
+
overflow: "hidden",
|
|
282
|
+
color: colors.textMuted,
|
|
283
|
+
fontSize: type.sm,
|
|
284
|
+
lineHeight: 1.35,
|
|
285
|
+
},
|
|
286
|
+
wireframe: {
|
|
287
|
+
position: "absolute",
|
|
288
|
+
inset: 0,
|
|
289
|
+
boxSizing: "border-box",
|
|
290
|
+
padding: "10%",
|
|
291
|
+
display: "flex",
|
|
292
|
+
gap: "6%",
|
|
293
|
+
},
|
|
294
|
+
wireSplit: {
|
|
295
|
+
flexDirection: "row",
|
|
296
|
+
alignItems: "stretch",
|
|
297
|
+
},
|
|
298
|
+
wireColumn: {
|
|
299
|
+
flex: 1,
|
|
300
|
+
minWidth: 0,
|
|
301
|
+
display: "flex",
|
|
302
|
+
flexDirection: "column",
|
|
303
|
+
justifyContent: "center",
|
|
304
|
+
gap: "7%",
|
|
305
|
+
},
|
|
306
|
+
wireChip: {
|
|
307
|
+
display: "block",
|
|
308
|
+
width: "22%",
|
|
309
|
+
height: 6,
|
|
310
|
+
borderRadius: 999,
|
|
311
|
+
backgroundColor: wireTone,
|
|
312
|
+
},
|
|
313
|
+
wireHeading: {
|
|
314
|
+
display: "block",
|
|
315
|
+
width: "70%",
|
|
316
|
+
height: 10,
|
|
317
|
+
borderRadius: 2,
|
|
318
|
+
backgroundColor: wireToneStrong,
|
|
319
|
+
},
|
|
320
|
+
wireLines: {
|
|
321
|
+
display: "flex",
|
|
322
|
+
flexDirection: "column",
|
|
323
|
+
gap: 4,
|
|
324
|
+
},
|
|
325
|
+
wireLine: {
|
|
326
|
+
display: "block",
|
|
327
|
+
width: "90%",
|
|
328
|
+
height: 5,
|
|
329
|
+
borderRadius: 2,
|
|
330
|
+
backgroundColor: wireTone,
|
|
331
|
+
},
|
|
332
|
+
wireLineShort: {
|
|
333
|
+
width: "60%",
|
|
334
|
+
},
|
|
335
|
+
wireImage: {
|
|
336
|
+
display: "block",
|
|
337
|
+
flex: 1,
|
|
338
|
+
minHeight: 18,
|
|
339
|
+
minWidth: "38%",
|
|
340
|
+
borderRadius: 3,
|
|
341
|
+
backgroundColor: wireTone,
|
|
342
|
+
},
|
|
343
|
+
wireButton: {
|
|
344
|
+
display: "block",
|
|
345
|
+
width: "28%",
|
|
346
|
+
height: 10,
|
|
347
|
+
borderRadius: 3,
|
|
348
|
+
backgroundColor: wireToneStrong,
|
|
349
|
+
},
|
|
350
|
+
wireCards: {
|
|
351
|
+
display: "grid",
|
|
352
|
+
gridTemplateColumns: "repeat(3, minmax(0, 1fr))",
|
|
353
|
+
gap: "6%",
|
|
354
|
+
minHeight: 18,
|
|
355
|
+
flex: 1,
|
|
356
|
+
},
|
|
357
|
+
wireCard: {
|
|
358
|
+
display: "block",
|
|
359
|
+
borderRadius: 3,
|
|
360
|
+
backgroundColor: wireTone,
|
|
361
|
+
},
|
|
362
|
+
});
|
package/src/pages/BlocksList.tsx
CHANGED
|
@@ -3,17 +3,23 @@ import { useEffect, useRef, useState } from "react";
|
|
|
3
3
|
import { RestrictToVerticalAxis } from "@dnd-kit/abstract/modifiers";
|
|
4
4
|
import { DragDropProvider } from "@dnd-kit/react";
|
|
5
5
|
import { isSortable, useSortable } from "@dnd-kit/react/sortable";
|
|
6
|
-
import { Menu } from "@base-ui/react/menu";
|
|
7
6
|
import * as stylex from "@stylexjs/stylex";
|
|
8
7
|
import type { BlockSnapshot, SchemaField } from "../api";
|
|
9
8
|
import { useBlockConfig } from "../define-studio";
|
|
10
9
|
import { FieldControl } from "../fields/FieldControl";
|
|
10
|
+
import { fieldLabel } from "../fields/field-label";
|
|
11
11
|
import { omitField } from "../fields/omit-field";
|
|
12
12
|
import { Button } from "../ui/Button";
|
|
13
13
|
import { Field } from "../ui/Field";
|
|
14
14
|
import { Text } from "../ui/Text";
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
15
|
+
import { colors, radius, space, type } from "../styles/tokens.stylex";
|
|
16
|
+
import { BlockPicker } from "./BlockPicker";
|
|
17
|
+
import {
|
|
18
|
+
SchemaFailureList,
|
|
19
|
+
SchemaSourceNote,
|
|
20
|
+
blockFailures,
|
|
21
|
+
useSchemaSource,
|
|
22
|
+
} from "../workspace/schema-source";
|
|
17
23
|
import {
|
|
18
24
|
addBlock,
|
|
19
25
|
removeBlock,
|
|
@@ -38,11 +44,6 @@ function sortTransition() {
|
|
|
38
44
|
: SORT_TRANSITION;
|
|
39
45
|
}
|
|
40
46
|
|
|
41
|
-
function fieldLabel(name: string, field: SchemaField) {
|
|
42
|
-
if ("label" in field && typeof field.label === "string" && field.label) return field.label;
|
|
43
|
-
return name.charAt(0).toUpperCase() + name.slice(1);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
47
|
type ModelRef = { type: string; external?: boolean; fields?: Record<string, SchemaField> };
|
|
47
48
|
type RelationDocumentLists = Record<
|
|
48
49
|
string,
|
|
@@ -148,6 +149,11 @@ function BlockItem({
|
|
|
148
149
|
</div>
|
|
149
150
|
{open ? (
|
|
150
151
|
<div {...stylex.props(styles.itemBody)}>
|
|
152
|
+
{def?.description ? (
|
|
153
|
+
<Text tone="muted" size="sm">
|
|
154
|
+
{def.description}
|
|
155
|
+
</Text>
|
|
156
|
+
) : null}
|
|
151
157
|
{Preview ? (
|
|
152
158
|
<div {...stylex.props(styles.preview)}>
|
|
153
159
|
<Preview type={block.type} props={block.props} />
|
|
@@ -161,7 +167,15 @@ function BlockItem({
|
|
|
161
167
|
</Text>
|
|
162
168
|
) : (
|
|
163
169
|
fieldEntries.map(([name, field]) => (
|
|
164
|
-
<Field
|
|
170
|
+
<Field
|
|
171
|
+
key={name}
|
|
172
|
+
label={fieldLabel(name, field)}
|
|
173
|
+
hint={
|
|
174
|
+
field.description ? (
|
|
175
|
+
<span {...stylex.props(styles.fieldGuidance)}>{field.description}</span>
|
|
176
|
+
) : undefined
|
|
177
|
+
}
|
|
178
|
+
>
|
|
165
179
|
<FieldControl
|
|
166
180
|
name={name}
|
|
167
181
|
field={field}
|
|
@@ -189,6 +203,7 @@ export function BlocksList({
|
|
|
189
203
|
documentLists,
|
|
190
204
|
readOnly,
|
|
191
205
|
focusBlock,
|
|
206
|
+
siteUrl,
|
|
192
207
|
onChange,
|
|
193
208
|
}: {
|
|
194
209
|
blocks: BlockInstance[];
|
|
@@ -198,9 +213,13 @@ export function BlocksList({
|
|
|
198
213
|
documentLists?: RelationDocumentLists;
|
|
199
214
|
readOnly?: boolean;
|
|
200
215
|
focusBlock?: { id: string; nonce: number } | null;
|
|
216
|
+
/** Resolves site-path block previews (`/block-previews/hero.png`). */
|
|
217
|
+
siteUrl?: string | null;
|
|
201
218
|
onChange: (next: BlockInstance[]) => void;
|
|
202
219
|
}) {
|
|
203
220
|
const [openId, setOpenId] = useState<string | null>(null);
|
|
221
|
+
const schemaSource = useSchemaSource();
|
|
222
|
+
const failures = blockFailures(schemaSource);
|
|
204
223
|
const listRef = useRef<HTMLDivElement>(null);
|
|
205
224
|
|
|
206
225
|
useEffect(() => {
|
|
@@ -222,9 +241,12 @@ export function BlocksList({
|
|
|
222
241
|
|
|
223
242
|
return (
|
|
224
243
|
<div {...stylex.props(styles.root)}>
|
|
225
|
-
<
|
|
226
|
-
|
|
227
|
-
|
|
244
|
+
<div {...stylex.props(styles.header)}>
|
|
245
|
+
<Text as="h2" size="sm" tone="muted" weight="medium">
|
|
246
|
+
Blocks
|
|
247
|
+
</Text>
|
|
248
|
+
<SchemaSourceNote source={schemaSource} />
|
|
249
|
+
</div>
|
|
228
250
|
{blocks.length === 0 ? (
|
|
229
251
|
<Text tone="muted" size="sm">
|
|
230
252
|
No blocks yet.
|
|
@@ -264,47 +286,25 @@ export function BlocksList({
|
|
|
264
286
|
</div>
|
|
265
287
|
</DragDropProvider>
|
|
266
288
|
)}
|
|
289
|
+
<SchemaFailureList
|
|
290
|
+
failures={failures}
|
|
291
|
+
title={
|
|
292
|
+
failures.length === 1
|
|
293
|
+
? "A block file failed to load. It is missing or out of date in Add block."
|
|
294
|
+
: `${failures.length} block files failed to load. They are missing or out of date in Add block.`
|
|
295
|
+
}
|
|
296
|
+
/>
|
|
267
297
|
{catalog.length === 0 ? (
|
|
268
298
|
<Text tone="muted" size="sm">
|
|
269
299
|
No blocks in the schema.
|
|
270
300
|
</Text>
|
|
271
301
|
) : (
|
|
272
|
-
<
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
</Button>
|
|
279
|
-
}
|
|
280
|
-
/>
|
|
281
|
-
<Menu.Portal>
|
|
282
|
-
<Menu.Positioner
|
|
283
|
-
side="bottom"
|
|
284
|
-
align="start"
|
|
285
|
-
sideOffset={6}
|
|
286
|
-
className={cx(popup.positioner)}
|
|
287
|
-
>
|
|
288
|
-
<Menu.Popup
|
|
289
|
-
aria-label="Add block"
|
|
290
|
-
className={(state) => popupClassName(state, styles.menu)}
|
|
291
|
-
>
|
|
292
|
-
{catalog.map((block) => (
|
|
293
|
-
<Menu.Item
|
|
294
|
-
key={block.name}
|
|
295
|
-
label={block.name}
|
|
296
|
-
onClick={() => add(block.name)}
|
|
297
|
-
className={(state) =>
|
|
298
|
-
cx(popup.item, state.highlighted && popup.itemHighlighted)
|
|
299
|
-
}
|
|
300
|
-
>
|
|
301
|
-
{block.name}
|
|
302
|
-
</Menu.Item>
|
|
303
|
-
))}
|
|
304
|
-
</Menu.Popup>
|
|
305
|
-
</Menu.Positioner>
|
|
306
|
-
</Menu.Portal>
|
|
307
|
-
</Menu.Root>
|
|
302
|
+
<BlockPicker
|
|
303
|
+
catalog={catalog}
|
|
304
|
+
siteUrl={siteUrl}
|
|
305
|
+
disabled={readOnly}
|
|
306
|
+
onPick={add}
|
|
307
|
+
/>
|
|
308
308
|
)}
|
|
309
309
|
</div>
|
|
310
310
|
);
|
|
@@ -316,6 +316,12 @@ const styles = stylex.create({
|
|
|
316
316
|
flexDirection: "column",
|
|
317
317
|
gap: space.md,
|
|
318
318
|
},
|
|
319
|
+
header: {
|
|
320
|
+
display: "flex",
|
|
321
|
+
alignItems: "baseline",
|
|
322
|
+
justifyContent: "space-between",
|
|
323
|
+
gap: space.md,
|
|
324
|
+
},
|
|
319
325
|
list: {
|
|
320
326
|
display: "flex",
|
|
321
327
|
flexDirection: "column",
|
|
@@ -419,7 +425,8 @@ const styles = stylex.create({
|
|
|
419
425
|
paddingInline: space.md,
|
|
420
426
|
paddingBottom: space.md,
|
|
421
427
|
},
|
|
422
|
-
|
|
423
|
-
|
|
428
|
+
fieldGuidance: {
|
|
429
|
+
fontFamily: type.sans,
|
|
430
|
+
fontSize: type.sm,
|
|
424
431
|
},
|
|
425
432
|
});
|