payload-canvas 0.5.1 → 0.6.0
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 +333 -28
- package/dist/admin/ArrayRowLabel.d.ts +12 -0
- package/dist/admin/ArrayRowLabel.js +21 -0
- package/dist/admin/DocumentEditView.js +9 -2
- package/dist/admin/client.d.ts +1 -0
- package/dist/admin/client.js +2 -0
- package/dist/admin/editor/Editor.js +8 -1
- package/dist/admin/editor/Inspector.js +23 -17
- package/dist/admin/editor/Library.d.ts +2 -2
- package/dist/admin/editor/Library.js +7 -5
- package/dist/admin/editor/Outline.js +20 -12
- package/dist/admin/editor/Overlay.js +6 -4
- package/dist/admin/editor/actions.d.ts +7 -2
- package/dist/admin/editor/actions.js +44 -12
- package/dist/admin/editor/assistant/AssistantPanel.js +32 -20
- package/dist/admin/editor/comments/controller.d.ts +7 -0
- package/dist/admin/editor/comments/controller.js +12 -0
- package/dist/admin/editor/comments/useCommentFromURL.d.ts +2 -0
- package/dist/admin/editor/comments/useCommentFromURL.js +36 -0
- package/dist/admin/editor/dnd/smooth.js +1 -1
- package/dist/admin/editor/editor.scss +28 -0
- package/dist/admin/editor/fields/ArrayField.js +3 -3
- package/dist/admin/editor/fields/FormBlock.d.ts +20 -0
- package/dist/admin/editor/fields/FormBlock.js +167 -0
- package/dist/admin/editor/fields/FormFieldName.d.ts +25 -0
- package/dist/admin/editor/fields/FormFieldName.js +58 -0
- package/dist/admin/editor/fields/GroupField.d.ts +22 -2
- package/dist/admin/editor/fields/GroupField.js +30 -1
- package/dist/admin/editor/fields/MergeTags.d.ts +8 -0
- package/dist/admin/editor/fields/MergeTags.js +62 -0
- package/dist/admin/editor/fields/arrayRows.d.ts +0 -2
- package/dist/admin/editor/fields/arrayRows.js +0 -4
- package/dist/admin/editor/fields/fields.scss +150 -0
- package/dist/admin/editor/fields/values.d.ts +0 -2
- package/dist/admin/editor/fields/values.js +0 -14
- package/dist/admin/editor/icons.d.ts +3 -0
- package/dist/admin/editor/icons.js +3 -0
- package/dist/admin/editor/insert/InsertHandle.js +1 -1
- package/dist/admin/editor/insert/picker.d.ts +3 -2
- package/dist/admin/editor/insert/picker.js +9 -3
- package/dist/admin/editor/layout/LeftPanel.js +5 -3
- package/dist/admin/editor/layout/leftTabs.d.ts +15 -0
- package/dist/admin/editor/layout/leftTabs.js +18 -0
- package/dist/admin/editor/media/ImageEditor.d.ts +8 -2
- package/dist/admin/editor/media/ImageEditor.js +16 -10
- package/dist/admin/editor/media/media.scss +12 -2
- package/dist/admin/editor/media/model.d.ts +10 -1
- package/dist/admin/editor/media/model.js +19 -0
- package/dist/admin/editor/menu/blockMenu.js +3 -3
- package/dist/admin/editor/names.d.ts +9 -0
- package/dist/admin/editor/names.js +18 -0
- package/dist/admin/editor/regions/RegionFields.d.ts +6 -0
- package/dist/admin/editor/regions/RegionFields.js +122 -0
- package/dist/admin/editor/regions/RegionPane.js +5 -3
- package/dist/admin/editor/regions/RegionRows.js +2 -2
- package/dist/admin/editor/regions/required.d.ts +16 -0
- package/dist/admin/editor/regions/required.js +43 -0
- package/dist/admin/editor/renderField.d.ts +9 -2
- package/dist/admin/editor/renderField.js +86 -32
- package/dist/admin/editor/runtime.d.ts +3 -2
- package/dist/admin/editor/runtime.js +12 -18
- package/dist/admin/editor/styles/StylesPanel.js +4 -2
- package/dist/admin/editor/styles/context.js +9 -4
- package/dist/admin/editor/topbar/ContentModeToggle.js +1 -1
- package/dist/admin/editor/topbar/DocumentActions.js +4 -3
- package/dist/admin/editor/topbar/contentMode.scss +0 -9
- package/dist/admin/editor/topbar/topbar.scss +1 -41
- package/dist/admin/editor/ui/Tabs.d.ts +17 -0
- package/dist/admin/editor/ui/Tabs.js +17 -0
- package/dist/admin/forms/SubmissionCells.d.ts +6 -0
- package/dist/admin/forms/SubmissionCells.js +31 -0
- package/dist/admin/forms/SubmissionView.d.ts +5 -0
- package/dist/admin/forms/SubmissionView.js +106 -0
- package/dist/admin/forms/submissionData.d.ts +32 -0
- package/dist/admin/forms/submissionData.js +63 -0
- package/dist/admin/forms/submissions.scss +197 -0
- package/dist/admin/rsc.d.ts +2 -0
- package/dist/admin/rsc.js +5 -0
- package/dist/ai/endpoint.d.ts +5 -0
- package/dist/ai/endpoint.js +18 -8
- package/dist/ai/prompt.d.ts +8 -0
- package/dist/ai/prompt.js +30 -0
- package/dist/ai/tools.d.ts +6 -1
- package/dist/ai/tools.js +90 -6
- package/dist/blocks/builtins/carousel.js +10 -1
- package/dist/blocks/index.d.ts +1 -1
- package/dist/blocks/index.js +1 -1
- package/dist/blocks/payload.d.ts +7 -0
- package/dist/blocks/payload.js +16 -2
- package/dist/comments/shared.d.ts +5 -0
- package/dist/comments/shared.js +5 -0
- package/dist/core/blocks.d.ts +17 -3
- package/dist/core/blocks.js +92 -10
- package/dist/core/classes.d.ts +5 -0
- package/dist/core/classes.js +26 -1
- package/dist/core/conditions.d.ts +7 -0
- package/dist/core/conditions.js +22 -0
- package/dist/core/dropTarget.d.ts +3 -2
- package/dist/core/dropTarget.js +7 -1
- package/dist/core/index.d.ts +6 -3
- package/dist/core/index.js +6 -3
- package/dist/core/payloadBlocks.js +25 -3
- package/dist/core/references.d.ts +7 -0
- package/dist/core/references.js +29 -11
- package/dist/core/regions.d.ts +14 -0
- package/dist/core/regions.js +17 -1
- package/dist/core/rowLabel.d.ts +8 -0
- package/dist/core/rowLabel.js +98 -0
- package/dist/core/starter.d.ts +10 -0
- package/dist/core/starter.js +40 -0
- package/dist/core/tree.js +4 -0
- package/dist/core/types.d.ts +96 -0
- package/dist/core/uniqueProps.d.ts +40 -0
- package/dist/core/uniqueProps.js +156 -0
- package/dist/core/validate.js +43 -3
- package/dist/forms/answers.d.ts +21 -0
- package/dist/forms/answers.js +82 -0
- package/dist/forms/blocks.d.ts +33 -0
- package/dist/forms/blocks.js +178 -0
- package/dist/forms/conditions.d.ts +78 -0
- package/dist/forms/conditions.js +184 -0
- package/dist/forms/emails.d.ts +23 -0
- package/dist/forms/emails.js +64 -0
- package/dist/forms/fieldConfigs.d.ts +35 -0
- package/dist/forms/fieldConfigs.js +167 -0
- package/dist/forms/fieldOps.d.ts +78 -0
- package/dist/forms/fieldOps.js +378 -0
- package/dist/forms/fieldSettings.d.ts +81 -0
- package/dist/forms/fieldSettings.js +239 -0
- package/dist/forms/files.d.ts +54 -0
- package/dist/forms/files.js +128 -0
- package/dist/forms/index.d.ts +16 -0
- package/dist/forms/index.js +18 -0
- package/dist/forms/mergeTags.d.ts +103 -0
- package/dist/forms/mergeTags.js +150 -0
- package/dist/forms/noScript.d.ts +60 -0
- package/dist/forms/noScript.js +109 -0
- package/dist/forms/pageForms.d.ts +99 -0
- package/dist/forms/pageForms.js +294 -0
- package/dist/forms/pageSync.d.ts +91 -0
- package/dist/forms/pageSync.js +325 -0
- package/dist/forms/rateLimit.d.ts +21 -0
- package/dist/forms/rateLimit.js +50 -0
- package/dist/forms/settings.d.ts +13 -0
- package/dist/forms/settings.js +92 -0
- package/dist/forms/spam.d.ts +100 -0
- package/dist/forms/spam.js +218 -0
- package/dist/forms/spamSettings.d.ts +43 -0
- package/dist/forms/spamSettings.js +25 -0
- package/dist/forms/submission.d.ts +34 -0
- package/dist/forms/submission.js +89 -0
- package/dist/forms/submissionsAdmin.d.ts +26 -0
- package/dist/forms/submissionsAdmin.js +108 -0
- package/dist/forms/summary.d.ts +60 -0
- package/dist/forms/summary.js +113 -0
- package/dist/forms/uploads.d.ts +41 -0
- package/dist/forms/uploads.js +132 -0
- package/dist/index.d.ts +8 -2
- package/dist/index.js +8 -2
- package/dist/live/document.d.ts +12 -0
- package/dist/live/document.js +8 -1
- package/dist/live/endpoints.d.ts +1 -0
- package/dist/live/session.js +3 -1
- package/dist/live/storage.d.ts +13 -2
- package/dist/live/storage.js +18 -7
- package/dist/mcp/forms.d.ts +26 -0
- package/dist/mcp/forms.js +280 -0
- package/dist/mcp/index.d.ts +7 -0
- package/dist/mcp/index.js +29 -10
- package/dist/mcp/shared.d.ts +1 -0
- package/dist/mcp/shared.js +1 -0
- package/dist/plugin/forms.d.ts +30 -0
- package/dist/plugin/forms.js +63 -0
- package/dist/plugin/formsSync.d.ts +138 -0
- package/dist/plugin/formsSync.js +345 -0
- package/dist/plugin/hook.d.ts +22 -0
- package/dist/plugin/hook.js +19 -7
- package/dist/plugin/index.d.ts +14 -0
- package/dist/plugin/index.js +99 -28
- package/dist/plugin/links.d.ts +21 -2
- package/dist/plugin/links.js +32 -3
- package/dist/plugin/references.d.ts +6 -0
- package/dist/plugin/references.js +12 -0
- package/dist/react/canvas/BuilderCanvas.d.ts +2 -0
- package/dist/react/canvas/BuilderCanvas.js +29 -6
- package/dist/react/canvas/inline/mapper.d.ts +6 -1
- package/dist/react/canvas/inline/mapper.js +35 -4
- package/dist/react/render/LayoutOutlet.d.ts +7 -3
- package/dist/react/render/LayoutOutlet.js +9 -4
- package/dist/react/render/RenderLayout.js +13 -7
- package/dist/react/render/resolve.d.ts +1 -0
- package/dist/react/render/resolve.js +5 -1
- package/dist/react/server.js +19 -0
- package/package.json +5 -1
package/dist/core/types.d.ts
CHANGED
|
@@ -123,6 +123,26 @@ export type SlotDefinition = {
|
|
|
123
123
|
styles?: boolean;
|
|
124
124
|
/** With `styles`: the classes a newly inserted block starts with on the slot's element. */
|
|
125
125
|
defaultClassName?: string;
|
|
126
|
+
/**
|
|
127
|
+
* What the slot holds, in one short sentence, e.g. "Each block here is one slide". The canvas
|
|
128
|
+
* shows it in the slot while it is empty; the AI reads it.
|
|
129
|
+
*/
|
|
130
|
+
description?: string;
|
|
131
|
+
/**
|
|
132
|
+
* The name of one direct child, e.g. "Slide". Layers shows "Slide 1", "Slide 2" after each
|
|
133
|
+
* child that has no name of its own.
|
|
134
|
+
*/
|
|
135
|
+
itemLabel?: string;
|
|
136
|
+
/**
|
|
137
|
+
* The block the "+" picker offers first in this slot, e.g. a Stack named "Slide". It starts
|
|
138
|
+
* with the block type's defaults, then these `label`, `className` and `props`.
|
|
139
|
+
*/
|
|
140
|
+
newBlock?: {
|
|
141
|
+
type: string;
|
|
142
|
+
label?: string;
|
|
143
|
+
className?: string;
|
|
144
|
+
props?: Record<string, unknown>;
|
|
145
|
+
};
|
|
126
146
|
};
|
|
127
147
|
/**
|
|
128
148
|
* A styled inner element of a block that is not a slot: a carousel's arrows, a pager's links.
|
|
@@ -135,6 +155,16 @@ export type PartDefinition = {
|
|
|
135
155
|
label: string;
|
|
136
156
|
/** Classes a newly inserted block starts with on this part (like `defaultClassName`). */
|
|
137
157
|
defaultClassName?: string;
|
|
158
|
+
/**
|
|
159
|
+
* Until the block sets classes of its own for this part, the part uses the classes of `part`
|
|
160
|
+
* (default: the same name) of the nearest block above it of type `ancestor`. A form field's label
|
|
161
|
+
* uses its Form block's label classes. The Styles panel starts from those classes, so the first
|
|
162
|
+
* edit copies them and changes only what was edited. Clearing the part's classes inherits again.
|
|
163
|
+
*/
|
|
164
|
+
inherits?: {
|
|
165
|
+
ancestor: string;
|
|
166
|
+
part?: string;
|
|
167
|
+
};
|
|
138
168
|
};
|
|
139
169
|
export type BlockDefinition = {
|
|
140
170
|
type: string;
|
|
@@ -147,6 +177,28 @@ export type BlockDefinition = {
|
|
|
147
177
|
* the root list included. Example: a list item goes only inside a list.
|
|
148
178
|
*/
|
|
149
179
|
parents?: string[];
|
|
180
|
+
/**
|
|
181
|
+
* Block types this block must sit inside, at any depth (not only directly). Undefined means
|
|
182
|
+
* anywhere. Example: a form field goes anywhere inside a Form block (also in a grid inside it),
|
|
183
|
+
* never outside one. Checked with `parents` by `placementError` and `validateLayout`.
|
|
184
|
+
*/
|
|
185
|
+
ancestors?: string[];
|
|
186
|
+
/**
|
|
187
|
+
* The block is a scope for `uniqueProps`: the unique props of the blocks inside it must differ
|
|
188
|
+
* from each other only, not from blocks outside it. A Form block is one: two forms may each have
|
|
189
|
+
* a field named `email`. Default false (the whole layout is one scope).
|
|
190
|
+
*/
|
|
191
|
+
uniqueScope?: boolean;
|
|
192
|
+
/**
|
|
193
|
+
* What a new block of this type starts with when the editor adds it (the library, drag and drop,
|
|
194
|
+
* the "+" picker): props over the field defaults, and child blocks per slot (ids are made at
|
|
195
|
+
* insert; children get their own default classes and field defaults). A new Form block starts
|
|
196
|
+
* as a ready contact form. Not used by operations from MCP or the assistant: they send whole blocks.
|
|
197
|
+
*/
|
|
198
|
+
starter?: {
|
|
199
|
+
props?: Record<string, unknown>;
|
|
200
|
+
slots?: Record<string, StarterBlock[]>;
|
|
201
|
+
};
|
|
150
202
|
/** Adds `className` and the style controls. Default true. */
|
|
151
203
|
styles?: boolean;
|
|
152
204
|
/**
|
|
@@ -156,6 +208,11 @@ export type BlockDefinition = {
|
|
|
156
208
|
inline?: boolean;
|
|
157
209
|
/** Classes a newly inserted block starts with (e.g. "flex flex-col gap-4" for a stack). */
|
|
158
210
|
defaultClassName?: string;
|
|
211
|
+
/**
|
|
212
|
+
* Text props that no two blocks of a layout may share, such as a form field's `name`. A block
|
|
213
|
+
* the editor adds, duplicates or pastes gets a free value: `text`, then `text2`, `text3`.
|
|
214
|
+
*/
|
|
215
|
+
uniqueProps?: string[];
|
|
159
216
|
/**
|
|
160
217
|
* Inner elements that take classes of their own, by name (`PartDefinition`). Slots with
|
|
161
218
|
* `styles: true` are parts too. A name must not be a slot name.
|
|
@@ -166,6 +223,14 @@ export type BlockDefinition = {
|
|
|
166
223
|
* CSS (save hook and canvas) whenever the block type appears in a layout.
|
|
167
224
|
*/
|
|
168
225
|
classes?: string[];
|
|
226
|
+
/**
|
|
227
|
+
* Turns a block stored in an older shape into the current one (for example a setting that became
|
|
228
|
+
* classes). The builder runs it when it opens a stored layout (editor, MCP tools), so the next
|
|
229
|
+
* save stores the new shape; until then the block's component must still read the old shape.
|
|
230
|
+
* Pure; returns the same block when there is nothing to change. Server only: the client config
|
|
231
|
+
* leaves functions out.
|
|
232
|
+
*/
|
|
233
|
+
upgrade?: (block: Block) => Block;
|
|
169
234
|
/** Icon name from the editor's built-in icon set (e.g. "heading", "image"). Falls back to a generic icon. */
|
|
170
235
|
icon?: string;
|
|
171
236
|
/** Group in the block library, e.g. "Layout", "Content", "Media", "Interactive". */
|
|
@@ -184,8 +249,21 @@ export type BlockDefinition = {
|
|
|
184
249
|
*/
|
|
185
250
|
payload?: {
|
|
186
251
|
slug: string;
|
|
252
|
+
/**
|
|
253
|
+
* Set by `fromPayloadBlocks` from fields marked `admin.custom.builderBlockKey`: the row keys
|
|
254
|
+
* that store the block's `className` (a text field) and `partClassName` (a json field). A Payload
|
|
255
|
+
* blocks field can then keep a block's classes, and the editor offers its Styles tab.
|
|
256
|
+
*/
|
|
257
|
+
classKeys?: {
|
|
258
|
+
className?: string;
|
|
259
|
+
partClassName?: string;
|
|
260
|
+
};
|
|
187
261
|
};
|
|
188
262
|
};
|
|
263
|
+
/** A child of `BlockDefinition.starter`: a block without an id, with children of the same shape. */
|
|
264
|
+
export type StarterBlock = Omit<Block, 'id' | 'slots'> & {
|
|
265
|
+
slots?: Record<string, StarterBlock[]>;
|
|
266
|
+
};
|
|
189
267
|
export type SectionDefinition = {
|
|
190
268
|
/** Stable id, e.g. "hero". */
|
|
191
269
|
id: string;
|
|
@@ -343,6 +421,14 @@ export type BuilderClientConfig = {
|
|
|
343
421
|
storage?: 'payload-blocks';
|
|
344
422
|
/** With `storage: 'payload-blocks'`: the block types the field allows at its top level. */
|
|
345
423
|
payloadRootTypes?: string[];
|
|
424
|
+
/**
|
|
425
|
+
* The form builder is on (`websiteBuilder({ forms })`): the forms collection and the form
|
|
426
|
+
* submissions collection (null when not found), for the Form block's actions and the rename warning.
|
|
427
|
+
*/
|
|
428
|
+
forms?: {
|
|
429
|
+
collection: string;
|
|
430
|
+
submissions: string | null;
|
|
431
|
+
};
|
|
346
432
|
/**
|
|
347
433
|
* Collection -> relationship field path -> related collection (`bindingRelations`), so the
|
|
348
434
|
* canvas resolves `<path>.$url` bindings as the site does.
|
|
@@ -374,6 +460,16 @@ export type RegionConfig = {
|
|
|
374
460
|
name: string;
|
|
375
461
|
label: string;
|
|
376
462
|
fields: RegionField[];
|
|
463
|
+
/**
|
|
464
|
+
* The inspector edits the region's fields itself, with Payload's inputs, and shows them when no
|
|
465
|
+
* block is selected (form settings in the form builder). Other regions edit in the settings drawer.
|
|
466
|
+
*/
|
|
467
|
+
panel?: boolean;
|
|
468
|
+
/** Panel regions: sections that fold, each with the paths of its fields (`RegionOption.sections`). */
|
|
469
|
+
sections?: Array<{
|
|
470
|
+
label: string;
|
|
471
|
+
fields: string[];
|
|
472
|
+
}>;
|
|
377
473
|
};
|
|
378
474
|
/** A region on the canvas: its name and its box, in iframe viewport coordinates. */
|
|
379
475
|
export type RegionRect = {
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { Block, BlockDefinition, Layout, Operation } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* The values in use, per prop name, of every unique prop in `blocks` (at every depth), without
|
|
4
|
+
* the blocks inside a nested scope (a Form block's fields belong to that form).
|
|
5
|
+
*/
|
|
6
|
+
export declare function uniquePropValues(blocks: readonly Block[], definitions: readonly BlockDefinition[], taken?: Map<string, Set<string>>): Map<string, Set<string>>;
|
|
7
|
+
/**
|
|
8
|
+
* The id of the scope a block placed in `parentId` belongs to: the nearest block with `uniqueScope`
|
|
9
|
+
* from `parentId` up (itself included), else null (the layout's own scope).
|
|
10
|
+
*/
|
|
11
|
+
export declare function uniqueScopeOf(layout: Layout, parentId: string | null, definitions: readonly BlockDefinition[]): string | null;
|
|
12
|
+
/**
|
|
13
|
+
* The values in use in the scope of a position: a block placed in `parentId` must not reuse them.
|
|
14
|
+
* Inside a Form block: that form's fields only.
|
|
15
|
+
*/
|
|
16
|
+
export declare function uniquePropValuesAt(layout: Layout, parentId: string | null, definitions: readonly BlockDefinition[]): Map<string, Set<string>>;
|
|
17
|
+
/** `value`, or the first of `value2`, `value3`, … that is not in `taken`. */
|
|
18
|
+
export declare function freeValue(value: string, taken: ReadonlySet<string>): string;
|
|
19
|
+
/**
|
|
20
|
+
* The block with a free value for each of its unique props (inside its slots too) that `taken`
|
|
21
|
+
* already holds. Adds the values it keeps to `taken`. Returns the same block when nothing clashes.
|
|
22
|
+
* The children of a block with `uniqueScope` only need to differ from each other.
|
|
23
|
+
*/
|
|
24
|
+
export declare function withUniqueProps(block: Block, definitions: readonly BlockDefinition[], taken: Map<string, Set<string>>): Block;
|
|
25
|
+
/** One block whose unique prop repeats the value of an earlier block in its scope. */
|
|
26
|
+
export type UniquePropClash = {
|
|
27
|
+
blockId: string;
|
|
28
|
+
prop: string;
|
|
29
|
+
value: string;
|
|
30
|
+
};
|
|
31
|
+
/** The blocks that repeat a unique prop's value in their scope (the second and later ones), in tree order. */
|
|
32
|
+
export declare function uniquePropClashes(layout: Layout, definitions: readonly BlockDefinition[]): UniquePropClash[];
|
|
33
|
+
/**
|
|
34
|
+
* The operation that duplicates block `id` as one undo step: an `insert` of a copy right after it,
|
|
35
|
+
* with new ids (`newId` for the copy, fresh ones inside), without the HTML ids the layout already
|
|
36
|
+
* uses, and with free values for the unique props of the copy and of every block inside it (a
|
|
37
|
+
* Stack of form fields inside a form gets `email2`). A copied Form block is a scope of its own: its
|
|
38
|
+
* fields keep their names. Null when the block is not in the layout.
|
|
39
|
+
*/
|
|
40
|
+
export declare function duplicateOperation(layout: Layout, id: string, newId: string, definitions: readonly BlockDefinition[], makeId?: () => string): Operation | null;
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
// Text props that must differ between the blocks of one scope (`BlockDefinition.uniqueProps`), such
|
|
2
|
+
// as the `name` of a form field: two fields with one name would overwrite each other's answers. A
|
|
3
|
+
// block with `uniqueScope` (a Form block) is a scope of its own: its fields differ from each other,
|
|
4
|
+
// not from the fields of another form. The rest of the layout is one scope.
|
|
5
|
+
import { htmlIdsOf, withoutTakenHtmlIds } from './attrs.js';
|
|
6
|
+
import { getBlockDefinition } from './blocks.js';
|
|
7
|
+
import { createId } from './ids.js';
|
|
8
|
+
import { findBlock, findLocation, indexLayout } from './tree.js';
|
|
9
|
+
const isScope = (definitions, type) => getBlockDefinition(definitions, type)?.uniqueScope === true;
|
|
10
|
+
/**
|
|
11
|
+
* The values in use, per prop name, of every unique prop in `blocks` (at every depth), without
|
|
12
|
+
* the blocks inside a nested scope (a Form block's fields belong to that form).
|
|
13
|
+
*/
|
|
14
|
+
export function uniquePropValues(blocks, definitions, taken = new Map()) {
|
|
15
|
+
for (const block of blocks) {
|
|
16
|
+
for (const prop of getBlockDefinition(definitions, block.type)?.uniqueProps ?? []) {
|
|
17
|
+
const value = block.props?.[prop];
|
|
18
|
+
if (typeof value !== 'string' || !value)
|
|
19
|
+
continue;
|
|
20
|
+
if (!taken.has(prop))
|
|
21
|
+
taken.set(prop, new Set());
|
|
22
|
+
taken.get(prop).add(value);
|
|
23
|
+
}
|
|
24
|
+
if (isScope(definitions, block.type))
|
|
25
|
+
continue;
|
|
26
|
+
for (const list of Object.values(block.slots ?? {}))
|
|
27
|
+
uniquePropValues(list, definitions, taken);
|
|
28
|
+
}
|
|
29
|
+
return taken;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The id of the scope a block placed in `parentId` belongs to: the nearest block with `uniqueScope`
|
|
33
|
+
* from `parentId` up (itself included), else null (the layout's own scope).
|
|
34
|
+
*/
|
|
35
|
+
export function uniqueScopeOf(layout, parentId, definitions) {
|
|
36
|
+
const index = indexLayout(layout);
|
|
37
|
+
for (let id = parentId; id !== null;) {
|
|
38
|
+
const entry = index.get(id);
|
|
39
|
+
if (!entry)
|
|
40
|
+
return null;
|
|
41
|
+
if (isScope(definitions, entry.block.type))
|
|
42
|
+
return id;
|
|
43
|
+
id = entry.parentId;
|
|
44
|
+
}
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* The values in use in the scope of a position: a block placed in `parentId` must not reuse them.
|
|
49
|
+
* Inside a Form block: that form's fields only.
|
|
50
|
+
*/
|
|
51
|
+
export function uniquePropValuesAt(layout, parentId, definitions) {
|
|
52
|
+
const scope = uniqueScopeOf(layout, parentId, definitions);
|
|
53
|
+
if (scope === null)
|
|
54
|
+
return uniquePropValues(layout.blocks, definitions);
|
|
55
|
+
const owner = indexLayout(layout).get(scope)?.block;
|
|
56
|
+
const taken = new Map();
|
|
57
|
+
for (const list of Object.values(owner?.slots ?? {}))
|
|
58
|
+
uniquePropValues(list, definitions, taken);
|
|
59
|
+
return taken;
|
|
60
|
+
}
|
|
61
|
+
/** `value`, or the first of `value2`, `value3`, … that is not in `taken`. */
|
|
62
|
+
export function freeValue(value, taken) {
|
|
63
|
+
if (!taken.has(value))
|
|
64
|
+
return value;
|
|
65
|
+
const base = value.replace(/\d+$/, '');
|
|
66
|
+
for (let n = 2;; n++)
|
|
67
|
+
if (!taken.has(`${base}${n}`))
|
|
68
|
+
return `${base}${n}`;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* The block with a free value for each of its unique props (inside its slots too) that `taken`
|
|
72
|
+
* already holds. Adds the values it keeps to `taken`. Returns the same block when nothing clashes.
|
|
73
|
+
* The children of a block with `uniqueScope` only need to differ from each other.
|
|
74
|
+
*/
|
|
75
|
+
export function withUniqueProps(block, definitions, taken) {
|
|
76
|
+
let result = block;
|
|
77
|
+
for (const prop of getBlockDefinition(definitions, block.type)?.uniqueProps ?? []) {
|
|
78
|
+
const value = result.props?.[prop];
|
|
79
|
+
if (typeof value !== 'string' || !value)
|
|
80
|
+
continue;
|
|
81
|
+
if (!taken.has(prop))
|
|
82
|
+
taken.set(prop, new Set());
|
|
83
|
+
const used = taken.get(prop);
|
|
84
|
+
const free = freeValue(value, used);
|
|
85
|
+
used.add(free);
|
|
86
|
+
if (free !== value)
|
|
87
|
+
result = { ...result, props: { ...result.props, [prop]: free } };
|
|
88
|
+
}
|
|
89
|
+
if (result.slots) {
|
|
90
|
+
const inner = isScope(definitions, block.type) ? new Map() : taken;
|
|
91
|
+
let changed = false;
|
|
92
|
+
const slots = Object.fromEntries(Object.entries(result.slots).map(([name, list]) => {
|
|
93
|
+
const next = list.map((child) => withUniqueProps(child, definitions, inner));
|
|
94
|
+
if (next.some((child, i) => child !== list[i]))
|
|
95
|
+
changed = true;
|
|
96
|
+
return [name, next];
|
|
97
|
+
}));
|
|
98
|
+
if (changed)
|
|
99
|
+
result = { ...result, slots };
|
|
100
|
+
}
|
|
101
|
+
return result;
|
|
102
|
+
}
|
|
103
|
+
/** The blocks that repeat a unique prop's value in their scope (the second and later ones), in tree order. */
|
|
104
|
+
export function uniquePropClashes(layout, definitions) {
|
|
105
|
+
const out = [];
|
|
106
|
+
const visit = (list, taken) => {
|
|
107
|
+
for (const block of list) {
|
|
108
|
+
for (const prop of getBlockDefinition(definitions, block.type)?.uniqueProps ?? []) {
|
|
109
|
+
const value = block.props?.[prop];
|
|
110
|
+
if (typeof value !== 'string' || !value)
|
|
111
|
+
continue;
|
|
112
|
+
if (!taken.has(prop))
|
|
113
|
+
taken.set(prop, new Set());
|
|
114
|
+
if (taken.get(prop).has(value))
|
|
115
|
+
out.push({ blockId: block.id, prop, value });
|
|
116
|
+
else
|
|
117
|
+
taken.get(prop).add(value);
|
|
118
|
+
}
|
|
119
|
+
const inner = isScope(definitions, block.type) ? new Map() : taken;
|
|
120
|
+
for (const children of Object.values(block.slots ?? {}))
|
|
121
|
+
visit(children, inner);
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
visit(layout.blocks, new Map());
|
|
125
|
+
return out;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* The operation that duplicates block `id` as one undo step: an `insert` of a copy right after it,
|
|
129
|
+
* with new ids (`newId` for the copy, fresh ones inside), without the HTML ids the layout already
|
|
130
|
+
* uses, and with free values for the unique props of the copy and of every block inside it (a
|
|
131
|
+
* Stack of form fields inside a form gets `email2`). A copied Form block is a scope of its own: its
|
|
132
|
+
* fields keep their names. Null when the block is not in the layout.
|
|
133
|
+
*/
|
|
134
|
+
export function duplicateOperation(layout, id, newId, definitions, makeId = createId) {
|
|
135
|
+
const block = findBlock(layout, id);
|
|
136
|
+
const location = findLocation(layout, id);
|
|
137
|
+
if (!block || !location)
|
|
138
|
+
return null;
|
|
139
|
+
const used = new Set([...indexLayout(layout).keys(), newId]);
|
|
140
|
+
const fresh = () => {
|
|
141
|
+
let next = makeId();
|
|
142
|
+
while (used.has(next))
|
|
143
|
+
next = makeId();
|
|
144
|
+
used.add(next);
|
|
145
|
+
return next;
|
|
146
|
+
};
|
|
147
|
+
const withIds = (source, blockId) => {
|
|
148
|
+
const copy = { ...structuredClone(source), id: blockId };
|
|
149
|
+
if (source.slots)
|
|
150
|
+
copy.slots = Object.fromEntries(Object.entries(source.slots).map(([name, list]) => [name, list.map((child) => withIds(child, fresh()))]));
|
|
151
|
+
return copy;
|
|
152
|
+
};
|
|
153
|
+
const taken = uniquePropValuesAt(layout, location.parentId, definitions);
|
|
154
|
+
const copy = withUniqueProps(withoutTakenHtmlIds(withIds(block, newId), htmlIdsOf(layout.blocks)), definitions, taken);
|
|
155
|
+
return { type: 'insert', block: copy, to: { parentId: location.parentId, ...(location.parentId === null ? {} : { slot: location.slot }), index: location.index + 1 } };
|
|
156
|
+
}
|
package/dist/core/validate.js
CHANGED
|
@@ -12,6 +12,7 @@ import { motionProblems } from './motion.js';
|
|
|
12
12
|
import { checkSectionOrigin } from './sectionOrigin.js';
|
|
13
13
|
import { checkVisibility } from './visibility.js';
|
|
14
14
|
import { fallbackChain, localizedKeys } from './locale.js';
|
|
15
|
+
import { uniquePropClashes } from './uniqueProps.js';
|
|
15
16
|
/** Codes that block publishing but not draft saves. */
|
|
16
17
|
export const PUBLISH_ONLY_CODES = new Set(['required', 'format', 'constraint', 'validate', 'nesting', 'binding']);
|
|
17
18
|
/** True when the error never blocks a save (only logged or shown). */
|
|
@@ -41,11 +42,42 @@ export function validateLayout(layout, blocks, options = {}) {
|
|
|
41
42
|
const htmlIds = new Map();
|
|
42
43
|
// Inline blocks may go into `allowInline` slots, as in the editor, also with a site's own list.
|
|
43
44
|
const definitions = withInlineBlocks(blocks);
|
|
44
|
-
layout.blocks.forEach((block, i) => checkBlock(block, `blocks[${i}]`, null, [], definitions, seen, errors, localization, htmlIds));
|
|
45
|
+
layout.blocks.forEach((block, i) => checkBlock(block, `blocks[${i}]`, null, [], definitions, seen, errors, localization, htmlIds, []));
|
|
46
|
+
// Unique props (a form field's name) repeated in one scope. Publish-only: a copy may clash for a moment.
|
|
47
|
+
if (errors.every((e) => e.code !== 'invalid')) {
|
|
48
|
+
for (const clash of uniquePropClashes(layout, definitions)) {
|
|
49
|
+
errors.push({
|
|
50
|
+
blockId: clash.blockId,
|
|
51
|
+
path: `${pathOfBlock(layout, clash.blockId)}.props.${clash.prop}`,
|
|
52
|
+
message: `Another block here already uses the ${clash.prop} "${clash.value}". Each one must be different.`,
|
|
53
|
+
code: 'constraint',
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
45
57
|
return errors;
|
|
46
58
|
}
|
|
59
|
+
/** The data path of a block (`blocks[0].slots.children[2]`), or '' when it is not in the layout. */
|
|
60
|
+
function pathOfBlock(layout, id) {
|
|
61
|
+
const visit = (list, at) => {
|
|
62
|
+
for (let i = 0; i < list.length; i++) {
|
|
63
|
+
const block = list[i];
|
|
64
|
+
const here = `${at}[${i}]`;
|
|
65
|
+
if (block.id === id)
|
|
66
|
+
return here;
|
|
67
|
+
for (const [name, children] of Object.entries(block.slots ?? {})) {
|
|
68
|
+
const found = visit(children, `${here}.slots.${name}`);
|
|
69
|
+
if (found)
|
|
70
|
+
return found;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return null;
|
|
74
|
+
};
|
|
75
|
+
return visit(layout.blocks, 'blocks') ?? '';
|
|
76
|
+
}
|
|
47
77
|
const nameOf = (value, def, type) => (typeof value.label === 'string' && value.label.trim()) || def?.label || type;
|
|
48
|
-
function checkBlock(value, path, owner, banned, blocks, seen, errors, localization, htmlIds
|
|
78
|
+
function checkBlock(value, path, owner, banned, blocks, seen, errors, localization, htmlIds,
|
|
79
|
+
/** The types of the blocks above this one, outermost first (`ancestors` rules). */
|
|
80
|
+
above) {
|
|
49
81
|
if (!isPlainObject(value)) {
|
|
50
82
|
errors.push({ path, message: 'Block must be an object', code: 'invalid' });
|
|
51
83
|
return;
|
|
@@ -79,6 +111,10 @@ function checkBlock(value, path, owner, banned, blocks, seen, errors, localizati
|
|
|
79
111
|
const parents = def.parents.map((t) => getBlockDefinition(blocks, t)?.label ?? t).join(' or ');
|
|
80
112
|
report(path, `${typeLabel} can only go inside ${parents}`, 'nesting');
|
|
81
113
|
}
|
|
114
|
+
if (type && def?.ancestors && !def.ancestors.some((t) => above.includes(t))) {
|
|
115
|
+
const ancestors = def.ancestors.map((t) => getBlockDefinition(blocks, t)?.label ?? t).join(' or ');
|
|
116
|
+
report(path, `${typeLabel} can only go inside ${ancestors}`, 'nesting');
|
|
117
|
+
}
|
|
82
118
|
const refusedBy = type ? banned.find((b) => b.type === type) : undefined;
|
|
83
119
|
if (refusedBy)
|
|
84
120
|
report(path, `${typeLabel} cannot go inside ${refusedBy.by}`, 'nesting');
|
|
@@ -178,7 +214,7 @@ function checkBlock(value, path, owner, banned, blocks, seen, errors, localizati
|
|
|
178
214
|
const label = nameOf(value, def, type ?? '');
|
|
179
215
|
const childOwner = slotDef && type ? { type, label, slot: name, def: slotDef } : null;
|
|
180
216
|
const childBanned = slotDef?.disallow?.length ? [...banned, ...slotDef.disallow.map((t) => ({ type: t, by: label }))] : banned;
|
|
181
|
-
children.forEach((child, i) => checkBlock(child, `${slotPath}[${i}]`, childOwner, childBanned, blocks, seen, errors, localization, htmlIds));
|
|
217
|
+
children.forEach((child, i) => checkBlock(child, `${slotPath}[${i}]`, childOwner, childBanned, blocks, seen, errors, localization, htmlIds, type ? [...above, type] : above));
|
|
182
218
|
}
|
|
183
219
|
}
|
|
184
220
|
/**
|
|
@@ -295,6 +331,10 @@ function checkFields(fields, data, path, report, extra = []) {
|
|
|
295
331
|
if (value === undefined || value === null)
|
|
296
332
|
continue;
|
|
297
333
|
}
|
|
334
|
+
// A group or array its condition hides is not checked inside: a leftover value there is never
|
|
335
|
+
// shown or used (Payload skips hidden fields too). A form's redirect group while it shows a message.
|
|
336
|
+
if ((field.type === 'group' || field.type === 'array') && !shown(field, data, list))
|
|
337
|
+
continue;
|
|
298
338
|
checkValue(field, value, at, report);
|
|
299
339
|
checkFormat(field, value, data, list, at, report);
|
|
300
340
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { FormFieldLike, FormValue } from './conditions.js';
|
|
2
|
+
/** A form field with what its checks read. */
|
|
3
|
+
export type FormAnswerField = FormFieldLike & {
|
|
4
|
+
label?: string | null;
|
|
5
|
+
options?: ReadonlyArray<{
|
|
6
|
+
value?: string | null;
|
|
7
|
+
}> | null;
|
|
8
|
+
};
|
|
9
|
+
/** Field types whose answer is a tick (true or false). */
|
|
10
|
+
export declare const TICK_FIELD_TYPES: ReadonlySet<string>;
|
|
11
|
+
/** True for "+1 (555) 123-4567" and other phone numbers with 6 to 15 digits. */
|
|
12
|
+
export declare function isPhoneNumber(text: string): boolean;
|
|
13
|
+
/** True for "https://example.com/page" and "example.com". Only http and https. */
|
|
14
|
+
export declare function isWebAddress(text: string): boolean;
|
|
15
|
+
/** True for a real calendar date written as YYYY-MM-DD (the value of `<input type="date">`). */
|
|
16
|
+
export declare function isDateText(text: string): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* The message for an answer, or '' when it is fine. `value` is what the visitor entered: text,
|
|
19
|
+
* or a boolean for a checkbox or consent box. A file field's value is the file name.
|
|
20
|
+
*/
|
|
21
|
+
export declare function formAnswerProblem(field: FormAnswerField, value: FormValue): string;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// The checks of one form answer: required, and the format of email, number, phone, web address,
|
|
2
|
+
// date, choice and file fields. Pure and client-safe: the site's form shows these messages under
|
|
3
|
+
// the field, and the submissions hook (`formSubmissionConditions`) runs the same checks again.
|
|
4
|
+
import { isEmptyFormValue } from './conditions.js';
|
|
5
|
+
const EMAIL = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
6
|
+
/** Digits, spaces, "+", "-", ".", "(" and ")". At least 6 and at most 15 digits (E.164). */
|
|
7
|
+
const PHONE = /^\+?[\d\s().-]+$/;
|
|
8
|
+
const DATE = /^(\d{4})-(\d{2})-(\d{2})$/;
|
|
9
|
+
/** Field types whose answer is a tick (true or false). */
|
|
10
|
+
export const TICK_FIELD_TYPES = new Set(['checkbox', 'consent']);
|
|
11
|
+
/** Field types that take no answer from the visitor. */
|
|
12
|
+
const NO_ANSWER = new Set(['message']);
|
|
13
|
+
/** True for "+1 (555) 123-4567" and other phone numbers with 6 to 15 digits. */
|
|
14
|
+
export function isPhoneNumber(text) {
|
|
15
|
+
if (!PHONE.test(text))
|
|
16
|
+
return false;
|
|
17
|
+
const digits = text.replace(/\D/g, '').length;
|
|
18
|
+
return digits >= 6 && digits <= 15;
|
|
19
|
+
}
|
|
20
|
+
/** True for "https://example.com/page" and "example.com". Only http and https. */
|
|
21
|
+
export function isWebAddress(text) {
|
|
22
|
+
if (/\s/.test(text))
|
|
23
|
+
return false;
|
|
24
|
+
const withScheme = /^[a-z][a-z\d+.-]*:/i.test(text) ? text : `https://${text}`;
|
|
25
|
+
try {
|
|
26
|
+
const url = new URL(withScheme);
|
|
27
|
+
return (url.protocol === 'https:' || url.protocol === 'http:') && /^[^.]+(\.[^.]+)+$/.test(url.hostname);
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/** True for a real calendar date written as YYYY-MM-DD (the value of `<input type="date">`). */
|
|
34
|
+
export function isDateText(text) {
|
|
35
|
+
const match = DATE.exec(text);
|
|
36
|
+
if (!match)
|
|
37
|
+
return false;
|
|
38
|
+
const [year, month, day] = [Number(match[1]), Number(match[2]), Number(match[3])];
|
|
39
|
+
const date = new Date(Date.UTC(year, month - 1, day));
|
|
40
|
+
return date.getUTCFullYear() === year && date.getUTCMonth() === month - 1 && date.getUTCDate() === day;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* The message for an answer, or '' when it is fine. `value` is what the visitor entered: text,
|
|
44
|
+
* or a boolean for a checkbox or consent box. A file field's value is the file name.
|
|
45
|
+
*/
|
|
46
|
+
export function formAnswerProblem(field, value) {
|
|
47
|
+
const type = field.blockType ?? 'text';
|
|
48
|
+
if (NO_ANSWER.has(type))
|
|
49
|
+
return '';
|
|
50
|
+
const label = String(field.label || field.name || 'this field').toLowerCase();
|
|
51
|
+
if (TICK_FIELD_TYPES.has(type))
|
|
52
|
+
return field.required && value !== true ? 'Tick this box to continue.' : '';
|
|
53
|
+
const text = value === null || value === undefined || typeof value === 'boolean' ? '' : String(value).trim();
|
|
54
|
+
if (isEmptyFormValue(text)) {
|
|
55
|
+
if (!field.required)
|
|
56
|
+
return '';
|
|
57
|
+
if (type === 'select' || type === 'radio' || type === 'country' || type === 'state')
|
|
58
|
+
return `Choose a ${label}.`;
|
|
59
|
+
if (type === 'file')
|
|
60
|
+
return `Choose a file for ${label}.`;
|
|
61
|
+
return `Enter your ${label}.`;
|
|
62
|
+
}
|
|
63
|
+
switch (type) {
|
|
64
|
+
case 'email':
|
|
65
|
+
return EMAIL.test(text) ? '' : 'Enter an email address like name@example.com.';
|
|
66
|
+
case 'number':
|
|
67
|
+
return Number.isFinite(Number(text)) ? '' : `Enter a number for ${label}.`;
|
|
68
|
+
case 'phone':
|
|
69
|
+
return isPhoneNumber(text) ? '' : 'Enter a phone number, for example +1 555 123 4567.';
|
|
70
|
+
case 'url':
|
|
71
|
+
return isWebAddress(text) ? '' : 'Enter a web address like https://example.com.';
|
|
72
|
+
case 'date':
|
|
73
|
+
return isDateText(text) ? '' : 'Enter a date.';
|
|
74
|
+
case 'select':
|
|
75
|
+
case 'radio': {
|
|
76
|
+
const options = (field.options ?? []).map((o) => o?.value).filter((v) => typeof v === 'string');
|
|
77
|
+
return options.length === 0 || options.includes(text) ? '' : `Choose one of the options for ${label}.`;
|
|
78
|
+
}
|
|
79
|
+
default:
|
|
80
|
+
return '';
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { Block as PayloadBlockConfig } from 'payload';
|
|
2
|
+
import type { BlockDefinition, PartDefinition } from '../core/types.js';
|
|
3
|
+
/** `admin.custom.builderFieldName` on a field's `name`: the builder warns when a form with submissions renames it. */
|
|
4
|
+
export declare const FIELD_NAME_MARKER = "builderFieldName";
|
|
5
|
+
/** Prefix of the builder types: the form-builder block `text` is the builder type `formText`. */
|
|
6
|
+
export declare const FORM_FIELD_PREFIX = "form";
|
|
7
|
+
/** Name of the form settings region. The app's form frame marks the submit button with it. */
|
|
8
|
+
export declare const FORM_SETTINGS_REGION = "settings";
|
|
9
|
+
/** Library category of the form field blocks. */
|
|
10
|
+
export declare const FORM_FIELD_CATEGORY = "Fields";
|
|
11
|
+
/** The builder type of a form-builder field block: `text` -> `formText`. */
|
|
12
|
+
export declare function formFieldType(slug: string): string;
|
|
13
|
+
/** The form-builder block slug of a builder type: `formText` -> `text`. Null for other types. */
|
|
14
|
+
export declare function formFieldSlug(type: string): string | null;
|
|
15
|
+
/** The parts of a field block (its own classes win over the form's). */
|
|
16
|
+
export declare const FORM_FIELD_PARTS: {
|
|
17
|
+
readonly label: 'Label';
|
|
18
|
+
readonly input: 'Input';
|
|
19
|
+
readonly help: 'Help text';
|
|
20
|
+
readonly error: 'Error message';
|
|
21
|
+
readonly options: 'Options';
|
|
22
|
+
};
|
|
23
|
+
export type FormFieldPartName = keyof typeof FORM_FIELD_PARTS;
|
|
24
|
+
/** The `parts` of a field block of the plugin's type `slug`. Undefined when it has none. */
|
|
25
|
+
export declare function formFieldParts(slug: string): Record<string, PartDefinition> | undefined;
|
|
26
|
+
/** The classes of the old width presets: the generated CSS has them wherever form fields are. */
|
|
27
|
+
export declare const FORM_FIELD_CLASSES: string[];
|
|
28
|
+
/**
|
|
29
|
+
* One definition per block of the form's `fields` blocks field. Types get the `form` prefix
|
|
30
|
+
* (`formText`), so they never clash with page blocks; the stored data keeps the plugin's
|
|
31
|
+
* `blockType`. The plugin's `forms` option calls this with the forms collection's own blocks.
|
|
32
|
+
*/
|
|
33
|
+
export declare function formFieldBlocks(blocks: readonly PayloadBlockConfig[]): BlockDefinition[];
|