@backmatter/studio 0.0.20 → 0.0.22
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-C269OA8v.js → UiKitApp-CgGyJiC4.js} +2 -2
- package/dist/chunks/{WorkspaceRoutes-B4B5jjje.js → WorkspaceRoutes-CzCBnhNt.js} +26364 -25362
- package/dist/chunks/dashboard-w-mlsGky.js +1879 -0
- package/dist/chunks/{index-7-TtXaMq.js → index-_XfFuFSU.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 +304 -32
- package/package.json +2 -2
- package/src/App.tsx +7 -1
- package/src/api.ts +106 -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 +185 -29
- 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 +39 -67
- 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/MediaFieldInput.tsx +1 -1
- package/src/pages/MediaGalleryPage.tsx +36 -3
- 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/ui/Input.tsx +134 -35
- package/src/workspace/schema-source.tsx +126 -0
- package/dist/chunks/dashboard-DeNgythd.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 { cx, popup, popupClassName } from "../ui/popup";
|
|
16
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,
|
|
@@ -202,6 +203,7 @@ export function BlocksList({
|
|
|
202
203
|
documentLists,
|
|
203
204
|
readOnly,
|
|
204
205
|
focusBlock,
|
|
206
|
+
siteUrl,
|
|
205
207
|
onChange,
|
|
206
208
|
}: {
|
|
207
209
|
blocks: BlockInstance[];
|
|
@@ -211,9 +213,13 @@ export function BlocksList({
|
|
|
211
213
|
documentLists?: RelationDocumentLists;
|
|
212
214
|
readOnly?: boolean;
|
|
213
215
|
focusBlock?: { id: string; nonce: number } | null;
|
|
216
|
+
/** Resolves site-path block previews (`/block-previews/hero.png`). */
|
|
217
|
+
siteUrl?: string | null;
|
|
214
218
|
onChange: (next: BlockInstance[]) => void;
|
|
215
219
|
}) {
|
|
216
220
|
const [openId, setOpenId] = useState<string | null>(null);
|
|
221
|
+
const schemaSource = useSchemaSource();
|
|
222
|
+
const failures = blockFailures(schemaSource);
|
|
217
223
|
const listRef = useRef<HTMLDivElement>(null);
|
|
218
224
|
|
|
219
225
|
useEffect(() => {
|
|
@@ -235,9 +241,12 @@ export function BlocksList({
|
|
|
235
241
|
|
|
236
242
|
return (
|
|
237
243
|
<div {...stylex.props(styles.root)}>
|
|
238
|
-
<
|
|
239
|
-
|
|
240
|
-
|
|
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>
|
|
241
250
|
{blocks.length === 0 ? (
|
|
242
251
|
<Text tone="muted" size="sm">
|
|
243
252
|
No blocks yet.
|
|
@@ -277,52 +286,25 @@ export function BlocksList({
|
|
|
277
286
|
</div>
|
|
278
287
|
</DragDropProvider>
|
|
279
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
|
+
/>
|
|
280
297
|
{catalog.length === 0 ? (
|
|
281
298
|
<Text tone="muted" size="sm">
|
|
282
299
|
No blocks in the schema.
|
|
283
300
|
</Text>
|
|
284
301
|
) : (
|
|
285
|
-
<
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
</Button>
|
|
292
|
-
}
|
|
293
|
-
/>
|
|
294
|
-
<Menu.Portal>
|
|
295
|
-
<Menu.Positioner
|
|
296
|
-
side="bottom"
|
|
297
|
-
align="start"
|
|
298
|
-
sideOffset={6}
|
|
299
|
-
className={cx(popup.positioner)}
|
|
300
|
-
>
|
|
301
|
-
<Menu.Popup
|
|
302
|
-
aria-label="Add block"
|
|
303
|
-
className={(state) => popupClassName(state, styles.menu)}
|
|
304
|
-
>
|
|
305
|
-
{catalog.map((block) => (
|
|
306
|
-
<Menu.Item
|
|
307
|
-
key={block.name}
|
|
308
|
-
label={block.name}
|
|
309
|
-
onClick={() => add(block.name)}
|
|
310
|
-
className={(state) =>
|
|
311
|
-
cx(popup.item, state.highlighted && popup.itemHighlighted)
|
|
312
|
-
}
|
|
313
|
-
>
|
|
314
|
-
<span {...stylex.props(styles.menuEntry)}>
|
|
315
|
-
<span>{block.name}</span>
|
|
316
|
-
{block.description ? (
|
|
317
|
-
<span {...stylex.props(styles.menuDescription)}>{block.description}</span>
|
|
318
|
-
) : null}
|
|
319
|
-
</span>
|
|
320
|
-
</Menu.Item>
|
|
321
|
-
))}
|
|
322
|
-
</Menu.Popup>
|
|
323
|
-
</Menu.Positioner>
|
|
324
|
-
</Menu.Portal>
|
|
325
|
-
</Menu.Root>
|
|
302
|
+
<BlockPicker
|
|
303
|
+
catalog={catalog}
|
|
304
|
+
siteUrl={siteUrl}
|
|
305
|
+
disabled={readOnly}
|
|
306
|
+
onPick={add}
|
|
307
|
+
/>
|
|
326
308
|
)}
|
|
327
309
|
</div>
|
|
328
310
|
);
|
|
@@ -334,6 +316,12 @@ const styles = stylex.create({
|
|
|
334
316
|
flexDirection: "column",
|
|
335
317
|
gap: space.md,
|
|
336
318
|
},
|
|
319
|
+
header: {
|
|
320
|
+
display: "flex",
|
|
321
|
+
alignItems: "baseline",
|
|
322
|
+
justifyContent: "space-between",
|
|
323
|
+
gap: space.md,
|
|
324
|
+
},
|
|
337
325
|
list: {
|
|
338
326
|
display: "flex",
|
|
339
327
|
flexDirection: "column",
|
|
@@ -437,22 +425,6 @@ const styles = stylex.create({
|
|
|
437
425
|
paddingInline: space.md,
|
|
438
426
|
paddingBottom: space.md,
|
|
439
427
|
},
|
|
440
|
-
menu: {
|
|
441
|
-
minWidth: "12rem",
|
|
442
|
-
maxWidth: "22rem",
|
|
443
|
-
},
|
|
444
|
-
menuEntry: {
|
|
445
|
-
display: "flex",
|
|
446
|
-
flexDirection: "column",
|
|
447
|
-
gap: "2px",
|
|
448
|
-
minWidth: 0,
|
|
449
|
-
},
|
|
450
|
-
menuDescription: {
|
|
451
|
-
color: colors.textMuted,
|
|
452
|
-
fontSize: type.sm,
|
|
453
|
-
lineHeight: 1.35,
|
|
454
|
-
whiteSpace: "normal",
|
|
455
|
-
},
|
|
456
428
|
fieldGuidance: {
|
|
457
429
|
fontFamily: type.sans,
|
|
458
430
|
fontSize: type.sm,
|