payload-canvas 0.6.4 → 0.6.5

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.
@@ -22,6 +22,7 @@ import { DocumentTitle, documentTitle, SectionNote, StatusChip } from './Documen
22
22
  import { PageSettings, PreviewButton, PublishButton, SaveState } from './DocumentActions.js';
23
23
  import { ContentModeLabel, PreviewAsClientToggle } from './ContentModeToggle.js';
24
24
  import { ScreenDrawer } from './screens/ScreenDrawer.js';
25
+ import { tabTitle } from './tabTitle.js';
25
26
  import { useDismiss } from './useDismiss.js';
26
27
  import { editViewPath, listViewPath } from '../../../plugin/links.js';
27
28
  import { forgetForm } from '../../formChoice.js';
@@ -71,7 +72,7 @@ export function TopBar({ icon }) {
71
72
  // refreshes, so the title is applied again whenever the head changes.
72
73
  const isSection = doc.section !== null;
73
74
  useEffect(() => {
74
- const wanted = isSection ? `Section: ${title} · Builder` : `${title} · Builder`;
75
+ const wanted = tabTitle(title, isSection);
75
76
  const apply = () => {
76
77
  if (document.title !== wanted)
77
78
  document.title = wanted;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * The browser tab title for the builder. Whitespace is collapsed and trimmed the way
3
+ * `document.title` reads it back: the top bar compares the two on every head change, and a title
4
+ * with extra spaces ("Home ") would never match, so it would set the title again forever.
5
+ */
6
+ export declare function tabTitle(title: string, isSection: boolean): string;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * The browser tab title for the builder. Whitespace is collapsed and trimmed the way
3
+ * `document.title` reads it back: the top bar compares the two on every head change, and a title
4
+ * with extra spaces ("Home ") would never match, so it would set the title again forever.
5
+ */
6
+ export function tabTitle(title, isSection) {
7
+ const name = title.replace(/\s+/g, ' ').trim();
8
+ return isSection ? `Section: ${name} · Builder` : `${name} · Builder`;
9
+ }
@@ -302,7 +302,16 @@ export function payloadBlocksStorage(topSlugs, definitions, where) {
302
302
  for (const child of slot.allow ?? [])
303
303
  queue.push(child);
304
304
  }
305
- return { blocks: [...found.values()], rootTypes };
305
+ // A type the field holds only inside other blocks goes only there: the editor and the layout
306
+ // check read `parents`, and a type without them would be offered at the top level too.
307
+ const roots = new Set(rootTypes);
308
+ const list = [...found.values()].map((def) => {
309
+ if (def.parents || roots.has(def.type))
310
+ return def;
311
+ const parents = [...found.values()].filter((owner) => Object.values(owner.slots ?? {}).some((slot) => slot.allow?.includes(def.type))).map((owner) => owner.type);
312
+ return parents.length > 0 ? { ...def, parents } : def;
313
+ });
314
+ return { blocks: list, rootTypes };
306
315
  }
307
316
  /**
308
317
  * Calls `visit` for every row of an array field and every block of a blocks field inside `data`,
@@ -1,4 +1,6 @@
1
1
  import type { Block, Layout, Operation, SectionDefinition, SectionOrigin } from './types.js';
2
+ /** The sections, and their variants, whose blocks `fits` accepts (a Payload blocks field stores only some). */
3
+ export declare function sectionsThatFit(sections: SectionDefinition[], fits: (blocks: Block[]) => boolean): SectionDefinition[];
2
4
  /** The name of a section's own version when it sets no `variantLabel`. */
3
5
  export declare const DEFAULT_VARIANT_LABEL = "Default";
4
6
  /** One version of a section: the section itself (`variant` undefined) or one of its variants. */
@@ -8,6 +8,14 @@
8
8
  import { htmlIdsOf, withoutTakenHtmlIds } from './attrs.js';
9
9
  import { createId } from './ids.js';
10
10
  import { findBlock, findLocation, walkBlocks } from './tree.js';
11
+ /** The sections, and their variants, whose blocks `fits` accepts (a Payload blocks field stores only some). */
12
+ export function sectionsThatFit(sections, fits) {
13
+ return sections.flatMap((section) => {
14
+ if (!fits(section.blocks))
15
+ return [];
16
+ return [section.variants ? { ...section, variants: section.variants.filter((v) => fits(v.blocks)) } : section];
17
+ });
18
+ }
11
19
  /** The name of a section's own version when it sets no `variantLabel`. */
12
20
  export const DEFAULT_VARIANT_LABEL = 'Default';
13
21
  /**
package/dist/mcp/index.js CHANGED
@@ -14,7 +14,8 @@ import { createId } from '../core/ids.js';
14
14
  import { VISIBILITY_OPERATORS } from '../core/visibility.js';
15
15
  import { blockJsonSchema } from '../core/schema.js';
16
16
  import { checkSectionVariants, getBlockDefinition, sectionsWithDefaultClassNames } from '../core/blocks.js';
17
- import { findSectionVersion } from '../core/sections.js';
17
+ import { findSectionVersion, sectionsThatFit } from '../core/sections.js';
18
+ import { payloadBlocksProblems } from '../core/payloadBlocks.js';
18
19
  import { localeSettingsOf, localizedKeys, resolveLayoutLocale, stampLocale, untranslatedKeys } from '../core/locale.js';
19
20
  import { normalizeLayout, subtreeIds, walkBlocks } from '../core/tree.js';
20
21
  import { runPropValidators } from '../core/fieldValidate.js';
@@ -242,6 +243,19 @@ async function variablesOf(req) {
242
243
  const list = variableTokens(await themeVariablesOf(req.payload));
243
244
  return list.length > 0 ? { variables: describeVariables(list), variablesNote: VARIABLES_NOTE } : {};
244
245
  }
246
+ /** The collection's own Payload blocks field (the block types it holds), or undefined for a JSON layout. */
247
+ function storageOf(req, collection) {
248
+ return req?.payload?.config ? builderConfigOf(req.payload)?.collections[collection]?.payloadBlocks : undefined;
249
+ }
250
+ /** Why a Payload blocks field cannot store `list` (the first problem), else null. JSON layouts store everything. */
251
+ function sectionProblem(req, collection, list) {
252
+ const storage = storageOf(req, collection);
253
+ return storage ? (payloadBlocksProblems({ version: 1, blocks: list }, storage)[0] ?? null) : null;
254
+ }
255
+ /** The sections, and their variants, the collection's layout can store. */
256
+ function sectionsFor(req, collection, list) {
257
+ return storageOf(req, collection) ? sectionsThatFit(list, (b) => sectionProblem(req, collection, b) === null) : list;
258
+ }
245
259
  export function builderMcpTools(options) {
246
260
  const templateTargets = Object.entries(options.collections).filter(([, c]) => c.templates).map(([slug]) => slug);
247
261
  const templatesSlug = templateTargets.length > 0 ? (options.templates?.slug ?? DEFAULT_TEMPLATES_SLUG) : null;
@@ -254,6 +268,8 @@ export function builderMcpTools(options) {
254
268
  * settings and the field blocks of the forms collection), else the app's list.
255
269
  */
256
270
  const blocksOf = (req) => (req?.payload?.config ? builderConfigOf(req.payload)?.blocks : undefined) ?? appBlocks;
271
+ /** The block types a collection's layout can hold: a Payload blocks field's own, else the whole list. */
272
+ const blocksFor = (req, collection) => storageOf(req, collection)?.blocks ?? blocksOf(req);
257
273
  // A section block without a className gets its type's default classes, as in the plugin.
258
274
  // Variants stay under their section (core/sections.ts); insertSection takes `variant`.
259
275
  checkSectionVariants(options.sections ?? []);
@@ -415,23 +431,30 @@ export function builderMcpTools(options) {
415
431
  name: 'listBlocks',
416
432
  routing: { kind: 'collection', action: 'read' },
417
433
  description: [
418
- 'Lists every block type you can use in page layouts: label, description, props, slots (which child types they accept), parts and an example, plus the site\'s own classes and design variables (named colors, sizes and fonts). Call it once before you build or edit a layout: its `guide` is the layout format (block keys, ids, positions, classes, motion presets, HTML attrs, canonical form) and `bindings` the binding and VISIBILITY format.',
434
+ 'Lists every block type you can use in the layouts of `collection`: label, description, props, slots (which child types they accept), parts and an example, plus the site\'s own classes and design variables (named colors, sizes and fonts). Call it once before you build or edit a layout: its `guide` is the layout format (block keys, ids, positions, classes, motion presets, HTML attrs, canonical form) and `bindings` the binding and VISIBILITY format.',
419
435
  'For whole page parts (hero, features, pricing, call to action, footer), PREFER ready-made sections: listSections, then insertSection. Use single blocks for small additions and edits.',
436
+ 'A collection whose layout is its own Payload blocks field holds only the block types listed for it: `rootTypes` go at the page root, the others only in the slots that accept them. Other collections differ: call it again for each collection.',
420
437
  `Dynamic blocks: "${FIELD_BLOCK}" shows one field of the current document (templates), "${COLLECTION_LIST_BLOCK}" lists documents of a collection and repeats its "item" slot per document, "${REPEAT_BLOCK}" repeats its "item" slot per row of an array or hasMany field of the current document.`,
421
438
  `Forms on pages (when the list has a "${FORM_BLOCK}" block): build a form right on the page. A "${FORM_BLOCK}" block in mode "build" holds its own field blocks (formText, formEmail, formTextarea, formSelect, formRadio, formCheckbox, …), one "${FORM_SUBMIT_BLOCK}" block and layout blocks in its "${FORM_SLOT}" slot. Field blocks and "${FORM_SUBMIT_BLOCK}" go only inside a Form block (at any depth). Each field's \`name\` is unique in its form. The form's settings (title, submitButtonLabel, confirmationType, confirmationMessage, redirect, emails, spamProtection) are props of the Form block. Publishing the page saves the form to the forms collection. Mode "saved" shows an existing form instead (\`form\`: its id).`,
422
439
  ].join('\n\n'),
423
440
  parameters: { collection: collectionArg },
424
- handler: async (_args, req) => text({
425
- guide: LAYOUT_GUIDE,
426
- blocks: blocksOf(req).map(describeBlock),
427
- ...(await siteClassesOf(req)),
428
- ...(await variablesOf(req)),
429
- sections: sections.length,
430
- bindings: BINDINGS_GUIDE,
431
- ...(templatesSlug ? { templates: { collection: templatesSlug, targets: templateTargets } } : {}),
432
- next: 'getBlockSchema for exact prop shapes. listSections for ready-made sections. getLayout to read a page.' +
433
- (templatesSlug ? ' listTemplates and getBindingSources for templates.' : ''),
434
- }),
441
+ handler: async (args, req) => {
442
+ const collection = String(args.collection);
443
+ const storage = storageOf(req, collection);
444
+ return text({
445
+ guide: LAYOUT_GUIDE,
446
+ // A Payload blocks field: only its own block types, and the ones it allows at the page root.
447
+ blocks: blocksFor(req, collection).map(describeBlock),
448
+ ...(storage ? { rootTypes: [...storage.rootTypes] } : {}),
449
+ ...(await siteClassesOf(req)),
450
+ ...(await variablesOf(req)),
451
+ sections: sectionsFor(req, collection, sections).length,
452
+ bindings: BINDINGS_GUIDE,
453
+ ...(templatesSlug ? { templates: { collection: templatesSlug, targets: templateTargets } } : {}),
454
+ next: 'getBlockSchema for exact prop shapes. listSections for ready-made sections. getLayout to read a page.' +
455
+ (templatesSlug ? ' listTemplates and getBindingSources for templates.' : ''),
456
+ });
457
+ },
435
458
  };
436
459
  const getBlockSchema = {
437
460
  name: 'getBlockSchema',
@@ -439,7 +462,7 @@ export function builderMcpTools(options) {
439
462
  description: 'Returns the JSON Schema (draft 2020-12) of one block type: its props, className, slots and motion (animations, under $defs.$motion), with nested child block schemas under $defs. Use it to write valid props.',
440
463
  parameters: { collection: collectionArg, type: z.string().min(1).describe('Block type from listBlocks.') },
441
464
  handler: async (args, req) => {
442
- const blocks = blocksOf(req);
465
+ const blocks = blocksFor(req, String(args.collection));
443
466
  const def = blocks.find((b) => b.type === args.type);
444
467
  if (!def)
445
468
  return fail(`Unknown block type "${String(args.type)}". Known types: ${blocks.map((b) => b.type).join(', ')}.`);
@@ -461,8 +484,8 @@ export function builderMcpTools(options) {
461
484
  full: z.boolean().optional().describe('Include the full block JSON. Default false.'),
462
485
  },
463
486
  handler: async (args, req) => {
464
- const blocks = blocksOf(req);
465
- const all = await allSections(req);
487
+ const blocks = blocksFor(req, String(args.collection));
488
+ const all = sectionsFor(req, String(args.collection), await allSections(req));
466
489
  const list = all.filter((s) => !args.category || s.category === args.category);
467
490
  return text({
468
491
  categories: [...new Set(all.map((s) => s.category).filter(Boolean))],
@@ -509,19 +532,23 @@ export function builderMcpTools(options) {
509
532
  .describe('Saved sections only. true: a copy that stays in sync with the saved section (default for components). false: plain blocks.'),
510
533
  },
511
534
  handler: async (args, req) => {
512
- const blocks = blocksOf(req);
535
+ const collection = String(args.collection);
536
+ const blocks = blocksFor(req, collection);
513
537
  const all = await allSections(req);
514
538
  const found = findSectionVersion(all, String(args.sectionId), typeof args.variant === 'string' ? args.variant : undefined);
515
539
  if (typeof found === 'string')
516
540
  return fail(found);
517
541
  if (!found) {
518
- const known = all.map((s) => (s.savedId !== undefined ? `${s.id} ("${s.label}")` : s.id));
542
+ const known = sectionsFor(req, collection, all).map((s) => (s.savedId !== undefined ? `${s.id} ("${s.label}")` : s.id));
519
543
  return fail(`Unknown section "${String(args.sectionId)}". Known sections: ${known.join(', ') || 'none'}.`);
520
544
  }
545
+ // A Payload blocks field: refused before the commit, with the reason (listSections leaves it out).
546
+ const unfit = sectionProblem(req, collection, found.blocks);
547
+ if (unfit)
548
+ return fail(`Section "${found.label}" cannot go in "${collection}": ${unfit} listSections lists the sections this collection can hold.`);
521
549
  const section = sectionToInsert(found, blocks, { values: args.values, linked: typeof args.linked === 'boolean' ? args.linked : null });
522
550
  if (typeof section === 'string')
523
551
  return fail(section);
524
- const collection = String(args.collection);
525
552
  const result = await apply(req, collection, String(args.id), (layout) => sectionInsertOps(layout, section, {
526
553
  parentId: args.parentId,
527
554
  slot: args.slot,
@@ -199,6 +199,13 @@ export declare const BUILDER_VIEW_KEY = "websiteBuilder";
199
199
  export declare const BUILDER_VIEW_PATH = "/builder/:collection/:id";
200
200
  /** Name of the hidden field that stores the generated CSS (`{ hash, css }`) for a layout field. */
201
201
  export declare function cssFieldName(field: string): string;
202
+ /**
203
+ * The website builder plugin. Put it LAST in `plugins`: plugins such as SEO with `tabbedUI`
204
+ * move all fields into tabs, and the layout field must stay a top-level field.
205
+ *
206
+ * Editors open the builder full screen at `{admin}/builder/:collection/:id` (a root admin view
207
+ * without Payload's nav and header). The document's "Builder" tab and the layout field link there.
208
+ */
202
209
  /**
203
210
  * `css` of websiteBuilder() as the compile needs it: the entry as an absolute path. Throws a
204
211
  * message that says what to pass when `css.entry` is missing.
@@ -8,6 +8,7 @@ import { checkSectionVariants, richTextFieldName, sectionsWithDefaultClassNames
8
8
  import { bindingRelations, DEFAULT_TEMPLATES_SLUG, DOCUMENT_TEMPLATE_FIELD, TEMPLATE_TARGET_FIELD } from '../core/bindings.js';
9
9
  import { localeSettingsOf } from '../core/locale.js';
10
10
  import { resolveRegions } from '../core/regions.js';
11
+ import { sectionsThatFit } from '../core/sections.js';
11
12
  import { decodePayloadBlocks, payloadBlocksProblems, payloadBlocksStorage } from '../core/payloadBlocks.js';
12
13
  import { EMPTY_LAYOUT, } from '../core/types.js';
13
14
  import { applyFontFamilies, cssEntryProblems, getCanvasCssInput, getStyleTokens } from '../css/index.js';
@@ -73,14 +74,6 @@ export function cssFieldName(field) {
73
74
  * Editors open the builder full screen at `{admin}/builder/:collection/:id` (a root admin view
74
75
  * without Payload's nav and header). The document's "Builder" tab and the layout field link there.
75
76
  */
76
- /** The sections, and their variants, whose blocks `fits` accepts (a Payload blocks field stores only some). */
77
- function sectionsThatFit(sections, fits) {
78
- return sections.flatMap((section) => {
79
- if (!fits(section.blocks))
80
- return [];
81
- return [section.variants ? { ...section, variants: section.variants.filter((v) => fits(v.blocks)) } : section];
82
- });
83
- }
84
77
  /**
85
78
  * `css` of websiteBuilder() as the compile needs it: the entry as an absolute path. Throws a
86
79
  * message that says what to pass when `css.entry` is missing.
@@ -33,78 +33,78 @@ import { withServerBlocks } from './serverComponents.js';
33
33
  import { shareStructure } from './share.js';
34
34
  import { ThumbnailCanvas } from './thumbnail/ThumbnailCanvas.js';
35
35
  /** Editor-only styles: visible empty slots and dimmed hidden blocks. Never part of the site CSS. */
36
- const EDITOR_CSS = `
37
- [data-builder-root] { min-height: 100vh; display: flow-root; user-select: none; }
38
- [data-slot-empty] {
39
- min-height: 48px;
40
- min-width: 48px;
41
- border: 1px dashed rgb(0 0 0 / 0.2);
42
- border-radius: 4px;
43
- background: repeating-linear-gradient(45deg, rgb(0 0 0 / 0.03) 0 6px, transparent 6px 12px);
44
- }
45
- /* An empty slot with a description: the description, centered. */
46
- [data-slot-empty][data-slot-hint] { display: grid; place-items: center; padding: 8px; }
47
- [data-slot-empty][data-slot-hint]::before {
48
- content: attr(data-slot-hint);
49
- font: 12px/1.4 system-ui, sans-serif;
50
- color: rgb(0 0 0 / 0.55);
51
- text-align: center;
52
- pointer-events: none;
53
- }
54
- [data-builder-hidden] { opacity: 0.35; }
55
- /* Repeated collection list items (2nd, 3rd, …): shown dimmed, never selectable. A component's
56
- blocks are not selectable either (the component is), but they show as on the site. */
57
- [data-builder-repeat] { pointer-events: none; }
58
- [data-builder-repeat]:not([data-builder-component]):not([data-builder-repeat] [data-builder-repeat]) { opacity: 0.6; }
59
- [data-builder-empty-page] { min-height: 240px; }
60
- /* The layout inside the page frame: the same box the canvas root gives a layout without a frame.
61
- A frame that gives the box its own classes (\`<LayoutOutlet className>\`) styles it itself. */
62
- [data-builder-layout]:not([class]) { display: flow-root; }
63
- /* Fixed regions of the page frame: text and images edit in place, but they never drag. */
64
- [data-builder-region] { user-select: none; }
65
- /* Inline text editing. The admin overlay draws the editing outline. */
66
- [data-builder-editing] { user-select: text; -webkit-user-select: text; cursor: text; outline: none; }
67
- [data-builder-editing='lines'] { white-space: pre-wrap; }
68
- [data-builder-editing][data-builder-blank]::before { content: attr(data-builder-hint); opacity: 0.4; pointer-events: none; }
69
- /* Text that a double-click edits in place: a text cursor and a faint outline on hover. */
70
- :is([data-builder-text], [data-builder-text-auto]):not([data-builder-editing]):hover {
71
- cursor: text;
72
- outline: 1px dashed color-mix(in srgb, currentColor 55%, transparent);
73
- outline-offset: 2px;
74
- }
75
- .builder-lx-underline { text-decoration: underline; }
76
- .builder-lx-strike { text-decoration: line-through; }
77
- .builder-lx-underline-strike { text-decoration: underline line-through; }
78
- [data-builder-passthrough] {
79
- display: block;
80
- margin: 0.5em 0;
81
- padding: 6px 10px;
82
- border: 1px dashed rgb(128 128 128 / 0.6);
83
- border-radius: 4px;
84
- font: 12px/1.4 system-ui, sans-serif;
85
- opacity: 0.7;
86
- user-select: none;
87
- }
88
- span[data-builder-passthrough] { display: inline-block; margin: 0 2px; padding: 0 6px; }
89
- /* Smooth drag mode: the dragged block hides while a lifted copy follows the pointer. */
90
- [data-builder-drag-source] { opacity: 0 !important; }
91
- /* Blocks rendered on the server: a placeholder while the first render loads, and a short dim
92
- (only when an update takes longer than 300 ms) while a newer one loads. */
93
- [data-builder-server] {
94
- font: 12px/1.4 system-ui, sans-serif;
95
- color: rgb(0 0 0 / 0.5);
96
- border: 1px dashed rgb(128 128 128 / 0.5);
97
- border-radius: 4px;
98
- }
99
- [data-builder-server='loading'] {
100
- min-height: 96px;
101
- background: linear-gradient(90deg, rgb(0 0 0 / 0.03) 25%, rgb(0 0 0 / 0.07) 50%, rgb(0 0 0 / 0.03) 75%) 0 0 / 200% 100%;
102
- animation: builder-server-loading 1.4s linear infinite;
103
- }
104
- [data-builder-server='error'] { color: rgb(180 30 30); border-color: rgb(180 30 30 / 0.5); }
105
- [data-builder-loading] { opacity: 0.7; transition: opacity 0.2s ease 0.3s; }
106
- @keyframes builder-server-loading { to { background-position: -200% 0; } }
107
- @media (prefers-reduced-motion: reduce) { [data-builder-server='loading'] { animation: none; } }
36
+ const EDITOR_CSS = `
37
+ [data-builder-root] { min-height: 100vh; display: flow-root; user-select: none; }
38
+ [data-slot-empty] {
39
+ min-height: 48px;
40
+ min-width: 48px;
41
+ border: 1px dashed rgb(0 0 0 / 0.2);
42
+ border-radius: 4px;
43
+ background: repeating-linear-gradient(45deg, rgb(0 0 0 / 0.03) 0 6px, transparent 6px 12px);
44
+ }
45
+ /* An empty slot with a description: the description, centered. */
46
+ [data-slot-empty][data-slot-hint] { display: grid; place-items: center; padding: 8px; }
47
+ [data-slot-empty][data-slot-hint]::before {
48
+ content: attr(data-slot-hint);
49
+ font: 12px/1.4 system-ui, sans-serif;
50
+ color: rgb(0 0 0 / 0.55);
51
+ text-align: center;
52
+ pointer-events: none;
53
+ }
54
+ [data-builder-hidden] { opacity: 0.35; }
55
+ /* Repeated collection list items (2nd, 3rd, …): shown dimmed, never selectable. A component's
56
+ blocks are not selectable either (the component is), but they show as on the site. */
57
+ [data-builder-repeat] { pointer-events: none; }
58
+ [data-builder-repeat]:not([data-builder-component]):not([data-builder-repeat] [data-builder-repeat]) { opacity: 0.6; }
59
+ [data-builder-empty-page] { min-height: 240px; }
60
+ /* The layout inside the page frame: the same box the canvas root gives a layout without a frame.
61
+ A frame that gives the box its own classes (\`<LayoutOutlet className>\`) styles it itself. */
62
+ [data-builder-layout]:not([class]) { display: flow-root; }
63
+ /* Fixed regions of the page frame: text and images edit in place, but they never drag. */
64
+ [data-builder-region] { user-select: none; }
65
+ /* Inline text editing. The admin overlay draws the editing outline. */
66
+ [data-builder-editing] { user-select: text; -webkit-user-select: text; cursor: text; outline: none; }
67
+ [data-builder-editing='lines'] { white-space: pre-wrap; }
68
+ [data-builder-editing][data-builder-blank]::before { content: attr(data-builder-hint); opacity: 0.4; pointer-events: none; }
69
+ /* Text that a double-click edits in place: a text cursor and a faint outline on hover. */
70
+ :is([data-builder-text], [data-builder-text-auto]):not([data-builder-editing]):hover {
71
+ cursor: text;
72
+ outline: 1px dashed color-mix(in srgb, currentColor 55%, transparent);
73
+ outline-offset: 2px;
74
+ }
75
+ .builder-lx-underline { text-decoration: underline; }
76
+ .builder-lx-strike { text-decoration: line-through; }
77
+ .builder-lx-underline-strike { text-decoration: underline line-through; }
78
+ [data-builder-passthrough] {
79
+ display: block;
80
+ margin: 0.5em 0;
81
+ padding: 6px 10px;
82
+ border: 1px dashed rgb(128 128 128 / 0.6);
83
+ border-radius: 4px;
84
+ font: 12px/1.4 system-ui, sans-serif;
85
+ opacity: 0.7;
86
+ user-select: none;
87
+ }
88
+ span[data-builder-passthrough] { display: inline-block; margin: 0 2px; padding: 0 6px; }
89
+ /* Smooth drag mode: the dragged block hides while a lifted copy follows the pointer. */
90
+ [data-builder-drag-source] { opacity: 0 !important; }
91
+ /* Blocks rendered on the server: a placeholder while the first render loads, and a short dim
92
+ (only when an update takes longer than 300 ms) while a newer one loads. */
93
+ [data-builder-server] {
94
+ font: 12px/1.4 system-ui, sans-serif;
95
+ color: rgb(0 0 0 / 0.5);
96
+ border: 1px dashed rgb(128 128 128 / 0.5);
97
+ border-radius: 4px;
98
+ }
99
+ [data-builder-server='loading'] {
100
+ min-height: 96px;
101
+ background: linear-gradient(90deg, rgb(0 0 0 / 0.03) 25%, rgb(0 0 0 / 0.07) 50%, rgb(0 0 0 / 0.03) 75%) 0 0 / 200% 100%;
102
+ animation: builder-server-loading 1.4s linear infinite;
103
+ }
104
+ [data-builder-server='error'] { color: rgb(180 30 30); border-color: rgb(180 30 30 / 0.5); }
105
+ [data-builder-loading] { opacity: 0.7; transition: opacity 0.2s ease 0.3s; }
106
+ @keyframes builder-server-loading { to { background-position: -200% 0; } }
107
+ @media (prefers-reduced-motion: reduce) { [data-builder-server='loading'] { animation: none; } }
108
108
  `;
109
109
  /** Room kept above and below a block scrolled into view (the toolbar sits above it). */
110
110
  const SCROLL_MARGIN = 48;
@@ -18,11 +18,11 @@ import { createServerBlocks } from '../serverBlocks.js';
18
18
  import { withServerBlocks } from '../serverComponents.js';
19
19
  import { captureElement } from './capture.js';
20
20
  /** No scrollbar (it would narrow the page), hidden blocks left out, empty slots outlined. */
21
- const THUMBNAIL_CSS = `
22
- html { overflow: hidden; scrollbar-width: none; }
23
- [data-builder-thumbnail] { display: flow-root; }
24
- [data-builder-hidden] { display: none !important; }
25
- [data-slot-empty] { border: 1px dashed rgb(128 128 128 / 0.35); border-radius: 4px; }
21
+ const THUMBNAIL_CSS = `
22
+ html { overflow: hidden; scrollbar-width: none; }
23
+ [data-builder-thumbnail] { display: flow-root; }
24
+ [data-builder-hidden] { display: none !important; }
25
+ [data-slot-empty] { border: 1px dashed rgb(128 128 128 / 0.35); border-radius: 4px; }
26
26
  `;
27
27
  /** Time for late layout (fonts, images with a size) before the picture. */
28
28
  const SETTLE_MS = 40;
@@ -114,7 +114,7 @@ export function ThumbnailCanvas({ blocks, components, plugins, resolveLink, serv
114
114
  const stored = { version: 1, blocks: request.blocks };
115
115
  const layout = await resolveCanvasLayout(stored, null, init.api, definitions, linkResolver);
116
116
  const sheet = await classes;
117
- const css = `${sheet.css}
117
+ const css = `${sheet.css}
118
118
  ${(await compiler).build(withoutClassNames(collectClasses(layout, definitions), new Set(sheet.names)))}`;
119
119
  const done = new Promise((resolve) => {
120
120
  rendered.current = resolve;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "payload-canvas",
3
- "version": "0.6.4",
3
+ "version": "0.6.5",
4
4
  "description": "Payload Canvas: a visual drag-and-drop website builder for Payload CMS 3. Nested layout blocks, Tailwind styling, sections, templates, live AI editing over MCP, and the React renderer for your site.",
5
5
  "keywords": [
6
6
  "payload",