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
|
@@ -22,6 +22,12 @@
|
|
|
22
22
|
border-left: 2px solid var(--theme-elevation-100);
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
// A group whose section already names it (the Form block's Spam protection): no heading, no indent.
|
|
26
|
+
.builder-field-group--plain {
|
|
27
|
+
padding: 0;
|
|
28
|
+
border-left: 0;
|
|
29
|
+
}
|
|
30
|
+
|
|
25
31
|
.builder-field-group__label {
|
|
26
32
|
margin: 0 0 calc(var(--base) * 0.25);
|
|
27
33
|
padding: 0;
|
|
@@ -163,6 +169,33 @@
|
|
|
163
169
|
font-size: var(--be-text-m);
|
|
164
170
|
}
|
|
165
171
|
|
|
172
|
+
// A note that needs attention: renaming a field of a form with submissions.
|
|
173
|
+
.builder-field-note--warning {
|
|
174
|
+
color: var(--theme-warning-800);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// The Form block's actions: where its answers go, "Edit form", "Move into this page".
|
|
178
|
+
.builder-form-actions {
|
|
179
|
+
display: flex;
|
|
180
|
+
flex-direction: column;
|
|
181
|
+
align-items: flex-start;
|
|
182
|
+
gap: calc(var(--base) * 0.5);
|
|
183
|
+
|
|
184
|
+
.builder-field-note {
|
|
185
|
+
margin: 0;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
.builder-form-actions--source {
|
|
190
|
+
margin-bottom: calc(var(--base) * 0.75);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
.builder-form-actions__row {
|
|
194
|
+
display: flex;
|
|
195
|
+
flex-wrap: wrap;
|
|
196
|
+
gap: calc(var(--base) * 0.25);
|
|
197
|
+
}
|
|
198
|
+
|
|
166
199
|
// The list's sort (SortField) and "Related to this page" (RelatedField): a label over selects.
|
|
167
200
|
.builder-sort,
|
|
168
201
|
.builder-related {
|
|
@@ -625,4 +658,121 @@
|
|
|
625
658
|
gap: 6px;
|
|
626
659
|
margin: 0;
|
|
627
660
|
}
|
|
661
|
+
|
|
662
|
+
// A block's Payload `tabs` field (FieldTabs): a segmented switch over the chosen tab's fields.
|
|
663
|
+
.builder-field-tabs {
|
|
664
|
+
display: flex;
|
|
665
|
+
flex-direction: column;
|
|
666
|
+
gap: calc(var(--base) * 0.75);
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
.builder-field-tabs__panel {
|
|
670
|
+
display: flex;
|
|
671
|
+
flex-direction: column;
|
|
672
|
+
gap: calc(var(--base) * 0.75);
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
// The folding sections of a settings panel, in one box without a gap: one border between rows.
|
|
676
|
+
.builder-panel-sections {
|
|
677
|
+
display: flex;
|
|
678
|
+
flex-direction: column;
|
|
679
|
+
|
|
680
|
+
&:empty {
|
|
681
|
+
display: none;
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
// A section of a settings panel (PanelSection): a full-width heading row that folds its fields.
|
|
686
|
+
.builder-panel-section {
|
|
687
|
+
margin: 0 -12px;
|
|
688
|
+
border-top: 1px solid var(--be-border);
|
|
689
|
+
|
|
690
|
+
&:last-child {
|
|
691
|
+
border-bottom: 1px solid var(--be-border);
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
.builder-panel-section__head {
|
|
696
|
+
display: flex;
|
|
697
|
+
align-items: center;
|
|
698
|
+
justify-content: space-between;
|
|
699
|
+
gap: 8px;
|
|
700
|
+
padding: 10px 12px;
|
|
701
|
+
color: var(--theme-text);
|
|
702
|
+
font-size: var(--be-text-m);
|
|
703
|
+
font-weight: var(--be-weight-strong);
|
|
704
|
+
list-style: none;
|
|
705
|
+
cursor: pointer;
|
|
706
|
+
user-select: none;
|
|
707
|
+
|
|
708
|
+
&::-webkit-details-marker {
|
|
709
|
+
display: none;
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
&:hover {
|
|
713
|
+
background: var(--be-hover);
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
&:focus-visible {
|
|
717
|
+
outline: 2px solid var(--be-accent);
|
|
718
|
+
outline-offset: -2px;
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
.builder-panel-section__chevron {
|
|
723
|
+
flex: none;
|
|
724
|
+
color: var(--be-muted);
|
|
725
|
+
transform: rotate(-90deg);
|
|
726
|
+
transition: transform 120ms var(--be-ease);
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
.builder-panel-section[open] > .builder-panel-section__head .builder-panel-section__chevron {
|
|
730
|
+
transform: none;
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
.builder-panel-section__fields {
|
|
734
|
+
display: flex;
|
|
735
|
+
flex-direction: column;
|
|
736
|
+
gap: calc(var(--base) * 0.75);
|
|
737
|
+
padding: 2px 12px 16px;
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
@media (prefers-reduced-motion: reduce) {
|
|
741
|
+
.builder-panel-section__chevron {
|
|
742
|
+
transition: none;
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
// "Insert field" over an email line or body (MergeTagsFrame), on the label's line.
|
|
747
|
+
.builder-merge-tags {
|
|
748
|
+
position: relative;
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
.builder-merge-tags__button {
|
|
752
|
+
position: absolute;
|
|
753
|
+
z-index: 1;
|
|
754
|
+
top: 0;
|
|
755
|
+
right: 0;
|
|
756
|
+
display: inline-flex;
|
|
757
|
+
align-items: center;
|
|
758
|
+
gap: 4px;
|
|
759
|
+
height: 20px;
|
|
760
|
+
padding: 0 6px;
|
|
761
|
+
border: 0;
|
|
762
|
+
border-radius: var(--be-radius);
|
|
763
|
+
background: transparent;
|
|
764
|
+
color: var(--be-accent-text);
|
|
765
|
+
font-size: var(--be-text-s);
|
|
766
|
+
font-weight: var(--be-weight-medium);
|
|
767
|
+
cursor: pointer;
|
|
768
|
+
|
|
769
|
+
&:hover,
|
|
770
|
+
&[data-popup-open] {
|
|
771
|
+
background: var(--be-accent-soft);
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
&:focus-visible {
|
|
775
|
+
outline: 2px solid var(--be-accent);
|
|
776
|
+
}
|
|
777
|
+
}
|
|
628
778
|
}
|
|
@@ -31,8 +31,6 @@ export declare function setKey(data: unknown, key: string, value: unknown): Reco
|
|
|
31
31
|
export declare function toRelationshipInput(stored: unknown, relationTo: string[], polymorphic: boolean, hasMany: boolean): ValueWithRelation | ValueWithRelation[] | null;
|
|
32
32
|
/** RelationshipInput value -> stored value. */
|
|
33
33
|
export declare function fromRelationshipInput(next: unknown, polymorphic: boolean): unknown;
|
|
34
|
-
/** First non-empty text value of an array row, for the row's label. */
|
|
35
|
-
export declare function rowLabel(row: unknown, fields: readonly FieldShape[]): string | null;
|
|
36
34
|
/** JSON text for the json field's textarea. */
|
|
37
35
|
export declare function toJsonText(value: unknown): string;
|
|
38
36
|
/** Parses the json field's text. Empty text means "no value". */
|
|
@@ -82,20 +82,6 @@ export function fromRelationshipInput(next, polymorphic) {
|
|
|
82
82
|
return next.map((pair) => fromPair(pair, polymorphic)).filter((v) => v !== null);
|
|
83
83
|
return fromPair(next, polymorphic);
|
|
84
84
|
}
|
|
85
|
-
const LABEL_TYPES = new Set(['text', 'textarea', 'email', 'select', 'number']);
|
|
86
|
-
/** First non-empty text value of an array row, for the row's label. */
|
|
87
|
-
export function rowLabel(row, fields) {
|
|
88
|
-
if (!isRecord(row))
|
|
89
|
-
return null;
|
|
90
|
-
for (const field of fields) {
|
|
91
|
-
if (!field.name || !LABEL_TYPES.has(field.type))
|
|
92
|
-
continue;
|
|
93
|
-
const value = row[field.name];
|
|
94
|
-
if ((typeof value === 'string' && value.trim()) || typeof value === 'number')
|
|
95
|
-
return String(value).trim();
|
|
96
|
-
}
|
|
97
|
-
return null;
|
|
98
|
-
}
|
|
99
85
|
/** JSON text for the json field's textarea. */
|
|
100
86
|
export function toJsonText(value) {
|
|
101
87
|
return value === undefined || value === null ? '' : JSON.stringify(value, null, 2);
|
|
@@ -36,6 +36,9 @@ declare const PATHS: {
|
|
|
36
36
|
template: import("react").JSX.Element;
|
|
37
37
|
calendar: import("react").JSX.Element;
|
|
38
38
|
mail: import("react").JSX.Element;
|
|
39
|
+
phone: import("react").JSX.Element;
|
|
40
|
+
upload: import("react").JSX.Element;
|
|
41
|
+
radio: import("react").JSX.Element;
|
|
39
42
|
relation: import("react").JSX.Element;
|
|
40
43
|
folder: import("react").JSX.Element;
|
|
41
44
|
select: import("react").JSX.Element;
|
|
@@ -56,6 +56,9 @@ const PATHS = {
|
|
|
56
56
|
template: (_jsxs(_Fragment, { children: [_jsx("rect", { x: "2", y: "2", width: "12", height: "12", rx: "1.5", strokeDasharray: "2 1.6" }), _jsx("path", { d: "M5 5.5h6M5 8h3.5" })] })),
|
|
57
57
|
calendar: (_jsxs(_Fragment, { children: [_jsx("rect", { x: "2", y: "3", width: "12", height: "11", rx: "1.5" }), _jsx("path", { d: "M2 6.5h12M5.25 1.75v2.5M10.75 1.75v2.5" })] })),
|
|
58
58
|
mail: (_jsxs(_Fragment, { children: [_jsx("rect", { x: "1.5", y: "3", width: "13", height: "10", rx: "1.5" }), _jsx("path", { d: "m2 4 6 4.75L14 4" })] })),
|
|
59
|
+
phone: _jsx("path", { d: "M3 2.5h2.5l1.25 3-1.5 1a7 7 0 0 0 3.25 3.25l1-1.5 3 1.25V12a1.5 1.5 0 0 1-1.5 1.5A10.5 10.5 0 0 1 1.5 4 1.5 1.5 0 0 1 3 2.5Z" }),
|
|
60
|
+
upload: _jsx("path", { d: "M8 10.5V2.5M4.75 5.75 8 2.5l3.25 3.25M2.5 10v2a1.5 1.5 0 0 0 1.5 1.5h8a1.5 1.5 0 0 0 1.5-1.5v-2" }),
|
|
61
|
+
radio: (_jsxs(_Fragment, { children: [_jsx("circle", { cx: "8", cy: "8", r: "5.75" }), dot(8, 8, 2.5)] })),
|
|
59
62
|
relation: (_jsxs(_Fragment, { children: [_jsx("rect", { x: "2", y: "5.5", width: "8.5", height: "8.5", rx: "1.5" }), _jsx("path", { d: "M8 2h6v6M14 2 8.5 7.5" })] })),
|
|
60
63
|
folder: _jsx("path", { d: "M1.75 4.25A1.25 1.25 0 0 1 3 3h3l1.5 1.75H13a1.25 1.25 0 0 1 1.25 1.25v6A1.25 1.25 0 0 1 13 13.25H3A1.25 1.25 0 0 1 1.75 12V4.25Z" }),
|
|
61
64
|
select: (_jsxs(_Fragment, { children: [_jsx("rect", { x: "1.5", y: "3.5", width: "13", height: "9", rx: "1.5" }), _jsx("path", { d: "m9.5 7 1.5 1.5L12.5 7" })] })),
|
|
@@ -80,7 +80,7 @@ function InsertPicker({ spot, onDone }) {
|
|
|
80
80
|
return;
|
|
81
81
|
}
|
|
82
82
|
if (item.kind === 'block') {
|
|
83
|
-
insertNewBlockAt(runtime, item.type, to);
|
|
83
|
+
insertNewBlockAt(runtime, item.type, to, item.template);
|
|
84
84
|
return;
|
|
85
85
|
}
|
|
86
86
|
if (insertBlocks(runtime, item.section.blocks, to))
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BlockDefinition, Layout, SectionDefinition } from '../../../core/types.js';
|
|
1
|
+
import type { BlockDefinition, Layout, SectionDefinition, SlotDefinition } from '../../../core/types.js';
|
|
2
2
|
export type PickerItem = {
|
|
3
3
|
kind: 'block';
|
|
4
4
|
id: string;
|
|
@@ -6,6 +6,7 @@ export type PickerItem = {
|
|
|
6
6
|
hint?: string;
|
|
7
7
|
icon: string;
|
|
8
8
|
type: string;
|
|
9
|
+
template?: SlotDefinition['newBlock'];
|
|
9
10
|
} | {
|
|
10
11
|
kind: 'section';
|
|
11
12
|
id: string;
|
|
@@ -27,7 +28,7 @@ export declare function matchScore(query: string, label: string, ...texts: (stri
|
|
|
27
28
|
* each of its top-level blocks, with everything inside, may go into the slot, and the slot has room
|
|
28
29
|
* for all of them (`max`). A section with variants is one item: it inserts the section's own
|
|
29
30
|
* version (its root block remembers the section, so the canvas offers the other versions), and
|
|
30
|
-
* its hint counts the versions.
|
|
31
|
+
* its hint counts the versions. A slot with a `newBlock` (a carousel's "Slide") lists it first.
|
|
31
32
|
*/
|
|
32
33
|
export declare function pickerItems(args: {
|
|
33
34
|
blocks: BlockDefinition[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// What the canvas insert picker offers at a spot: the block types and sections that fit there
|
|
2
2
|
// (slot `allow` / `disallow` / `max` rules), filtered by the search text. Pure: no DOM, no React.
|
|
3
|
-
import { slotAcceptsAt, slotRoom } from '../../../core/blocks.js';
|
|
3
|
+
import { getBlockDefinition, slotAcceptsAt, slotDefinitionAt, slotRoom } from '../../../core/blocks.js';
|
|
4
4
|
import { sectionVersion, sectionVersions } from '../../../core/sections.js';
|
|
5
5
|
/** Block categories in library order. Others follow A–Z. */
|
|
6
6
|
export const BLOCK_ORDER = ['Layout', 'Content', 'Media', 'Interactive', 'Dynamic'];
|
|
@@ -29,7 +29,7 @@ const rank = (category) => {
|
|
|
29
29
|
* each of its top-level blocks, with everything inside, may go into the slot, and the slot has room
|
|
30
30
|
* for all of them (`max`). A section with variants is one item: it inserts the section's own
|
|
31
31
|
* version (its root block remembers the section, so the canvas offers the other versions), and
|
|
32
|
-
* its hint counts the versions.
|
|
32
|
+
* its hint counts the versions. A slot with a `newBlock` (a carousel's "Slide") lists it first.
|
|
33
33
|
*/
|
|
34
34
|
export function pickerItems(args) {
|
|
35
35
|
const { blocks, layout, parentId, slot, query } = args;
|
|
@@ -56,5 +56,11 @@ export function pickerItems(args) {
|
|
|
56
56
|
section: sectionVersion(s) ?? s,
|
|
57
57
|
};
|
|
58
58
|
});
|
|
59
|
-
|
|
59
|
+
// The slot's own new block (a carousel's "Slide") comes first.
|
|
60
|
+
const template = slotDefinitionAt(blocks, layout, parentId, slot)?.newBlock;
|
|
61
|
+
const templateDef = template ? getBlockDefinition(blocks, template.type) : undefined;
|
|
62
|
+
const own = template && templateDef && slotAcceptsAt(blocks, layout, parentId, slot, template.type) && matchScore(query, template.label ?? templateDef.label, templateDef.label) !== null
|
|
63
|
+
? [{ kind: 'block', id: `new:${slot}`, label: template.label ?? templateDef.label, hint: templateDef.label, icon: templateDef.icon ?? templateDef.type, type: template.type, template }]
|
|
64
|
+
: [];
|
|
65
|
+
return [...own, ...blockItems, ...sectionItems];
|
|
60
66
|
}
|
|
@@ -3,7 +3,9 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
|
|
|
3
3
|
// The left sidebar: three tabs at the top (Layers, Blocks, Sections), each panel full height.
|
|
4
4
|
// Panels stay mounted once opened and hide with the `hidden` attribute: a library item that is
|
|
5
5
|
// being dragged must stay mounted (dnd-kit tracks its node) when the tab changes mid-drag.
|
|
6
|
-
//
|
|
6
|
+
// A drag from the library opens Layers when it starts (Editor.tsx), and a click that adds a block
|
|
7
|
+
// opens it after the insert (`showAddedInLayers`). Any other drag that hovers the Layers tab for a
|
|
8
|
+
// moment opens it, so the drop can go in the tree.
|
|
7
9
|
import { useEffect, useLayoutEffect, useRef, useState } from 'react';
|
|
8
10
|
import { remeasureOutline } from '../dnd/smooth.js';
|
|
9
11
|
import { Icon } from '../icons.js';
|
|
@@ -13,7 +15,7 @@ import { Outline } from '../Outline.js';
|
|
|
13
15
|
import { leftTabsFor, useContentMode } from '../contentMode.js';
|
|
14
16
|
import { useRuntime } from '../runtime.js';
|
|
15
17
|
import { useValue } from '../valueStore.js';
|
|
16
|
-
import { LEFT_TABS, leftPanelId, selectLeftTab } from './leftTabs.js';
|
|
18
|
+
import { LEFT_TABS, leftPanelId, offeredLeftTabs, selectLeftTab } from './leftTabs.js';
|
|
17
19
|
/** How long a drag must rest on the Layers tab before it opens. */
|
|
18
20
|
const DRAG_OPEN_MS = 350;
|
|
19
21
|
const tabId = (tab) => `builder-left-tab-${tab}`;
|
|
@@ -24,7 +26,7 @@ export function LeftPanel() {
|
|
|
24
26
|
const [fallback] = useState(() => (runtime.store.getState().layout.blocks.length === 0 ? 'blocks' : 'layers'));
|
|
25
27
|
// Content mode adds no blocks or sections: Layers only.
|
|
26
28
|
const contentMode = useContentMode(runtime);
|
|
27
|
-
const tabs = leftTabsFor(contentMode, LEFT_TABS);
|
|
29
|
+
const tabs = leftTabsFor(contentMode, offeredLeftTabs(runtime.config, LEFT_TABS));
|
|
28
30
|
const wanted = stored ?? fallback;
|
|
29
31
|
const tab = tabs.some(({ id }) => id === wanted) ? wanted : 'layers';
|
|
30
32
|
// Panels render the first time they open, then stay mounted.
|
|
@@ -7,12 +7,27 @@ export declare const LEFT_TABS: readonly {
|
|
|
7
7
|
icon: IconName;
|
|
8
8
|
digit: string;
|
|
9
9
|
}[];
|
|
10
|
+
/**
|
|
11
|
+
* The tabs this editor offers: Sections only when there are sections to insert or a place to save
|
|
12
|
+
* them (the form builder has neither: `sections: false`).
|
|
13
|
+
*/
|
|
14
|
+
export declare function offeredLeftTabs<T extends {
|
|
15
|
+
id: LeftTab;
|
|
16
|
+
}>(config: Pick<Runtime['config'], 'sections' | 'savedSections'>, tabs: readonly T[]): readonly T[];
|
|
10
17
|
/** The stored tab. Null when the user never picked one (or storage is blocked). */
|
|
11
18
|
export declare function readLeftTab(): LeftTab | null;
|
|
12
19
|
/** The tab for the digit of its shortcut ("1" is Layers). */
|
|
13
20
|
export declare function leftTabForDigit(digit: string): LeftTab | null;
|
|
14
21
|
/** The DOM id of a tab's panel. */
|
|
15
22
|
export declare const leftPanelId: (tab: LeftTab) => string;
|
|
23
|
+
/**
|
|
24
|
+
* After a click added blocks from the library: Layers opens with the new block selected and in view
|
|
25
|
+
* (as in Webflow). `focus` moves the focus to its row (the clicked item hides with its panel).
|
|
26
|
+
* Returns `added`.
|
|
27
|
+
*/
|
|
28
|
+
export declare function showAddedInLayers(runtime: Runtime, added: boolean, { focus }?: {
|
|
29
|
+
focus?: boolean;
|
|
30
|
+
}): boolean;
|
|
16
31
|
/**
|
|
17
32
|
* Opens a tab and keeps the choice. `focus` moves the focus into the panel: the search field of
|
|
18
33
|
* Blocks and Sections, the focusable row of Layers.
|
|
@@ -5,6 +5,14 @@ export const LEFT_TABS = [
|
|
|
5
5
|
{ id: 'blocks', label: 'Blocks', icon: 'grid', digit: '2' },
|
|
6
6
|
{ id: 'sections', label: 'Sections', icon: 'section', digit: '3' },
|
|
7
7
|
];
|
|
8
|
+
/**
|
|
9
|
+
* The tabs this editor offers: Sections only when there are sections to insert or a place to save
|
|
10
|
+
* them (the form builder has neither: `sections: false`).
|
|
11
|
+
*/
|
|
12
|
+
export function offeredLeftTabs(config, tabs) {
|
|
13
|
+
const sections = (config.sections?.length ?? 0) > 0 || Boolean(config.savedSections);
|
|
14
|
+
return sections ? tabs : tabs.filter((tab) => tab.id !== 'sections');
|
|
15
|
+
}
|
|
8
16
|
const STORAGE_KEY = 'payload-builder:left-tab';
|
|
9
17
|
const isLeftTab = (value) => LEFT_TABS.some((tab) => tab.id === value);
|
|
10
18
|
/** The stored tab. Null when the user never picked one (or storage is blocked). */
|
|
@@ -23,6 +31,16 @@ export function leftTabForDigit(digit) {
|
|
|
23
31
|
}
|
|
24
32
|
/** The DOM id of a tab's panel. */
|
|
25
33
|
export const leftPanelId = (tab) => `builder-left-${tab}`;
|
|
34
|
+
/**
|
|
35
|
+
* After a click added blocks from the library: Layers opens with the new block selected and in view
|
|
36
|
+
* (as in Webflow). `focus` moves the focus to its row (the clicked item hides with its panel).
|
|
37
|
+
* Returns `added`.
|
|
38
|
+
*/
|
|
39
|
+
export function showAddedInLayers(runtime, added, { focus = false } = {}) {
|
|
40
|
+
if (added)
|
|
41
|
+
selectLeftTab(runtime, 'layers', { focus });
|
|
42
|
+
return added;
|
|
43
|
+
}
|
|
26
44
|
/**
|
|
27
45
|
* Opens a tab and keeps the choice. `focus` moves the focus into the panel: the search field of
|
|
28
46
|
* Blocks and Sections, the focusable row of Layers.
|
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
import './media.scss';
|
|
2
|
-
/**
|
|
3
|
-
|
|
2
|
+
/**
|
|
3
|
+
* The chip, the image box and the media popover. Mounted once, in the overlay. `barRight` and
|
|
4
|
+
* `barTop`: the selected block's top right corner while its action bar sits inside it, else null.
|
|
5
|
+
*/
|
|
6
|
+
export declare const ImageEditor: import("react").MemoExoticComponent<({ barRight, barTop }: {
|
|
7
|
+
barRight: number | null;
|
|
8
|
+
barTop: number | null;
|
|
9
|
+
}) => import("react").JSX.Element | null>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
// Images on the canvas, admin side: a "Replace" chip
|
|
4
|
-
// popover (double-click or a click on the chip) with Choose from
|
|
5
|
-
// and the alt text. The chip and the image box live in the
|
|
6
|
-
// popover renders into the editor root, like the insert picker,
|
|
7
|
-
// pointer events.
|
|
3
|
+
// Images on the canvas, admin side: a "Replace" chip in the top right corner of the image under
|
|
4
|
+
// the pointer, and a media popover (double-click or a click on the chip) with Choose from
|
|
5
|
+
// library, Upload, Generate, Remove and the alt text. The chip and the image box live in the
|
|
6
|
+
// overlay (iframe coordinates); the popover renders into the editor root, like the insert picker,
|
|
7
|
+
// because the overlay takes no pointer events.
|
|
8
8
|
import { useListDrawer } from '@payloadcms/ui';
|
|
9
9
|
import { memo, useEffect, useId, useRef, useState, useSyncExternalStore } from 'react';
|
|
10
10
|
import { createPortal } from 'react-dom';
|
|
@@ -19,7 +19,7 @@ import { Popover, usePopover } from '../styles/popover.js';
|
|
|
19
19
|
import { Select } from '../ui/Select.js';
|
|
20
20
|
import { useOptionalValue, useValue, useValueSelector } from '../valueStore.js';
|
|
21
21
|
import { imageEditor, imageSpotContext, loadMedia, removeImage, saveMediaAlt, setAltProp, setImage, setImageValue, updateImageEditor, uploadImage, } from './actions.js';
|
|
22
|
-
import { altPropPath, mediaRef, propAt } from './model.js';
|
|
22
|
+
import { altPropPath, chipPlace, mediaRef, propAt } from './model.js';
|
|
23
23
|
import './media.scss';
|
|
24
24
|
const noSubscription = () => () => { };
|
|
25
25
|
const editorRoot = () => document.querySelector('.builder-editor');
|
|
@@ -36,8 +36,11 @@ function visiblePart(rect, viewport) {
|
|
|
36
36
|
const bottom = Math.min(rect.y + rect.height, viewport.height);
|
|
37
37
|
return { x, y, width: Math.max(0, right - x), height: Math.max(0, bottom - y) };
|
|
38
38
|
}
|
|
39
|
-
/**
|
|
40
|
-
|
|
39
|
+
/**
|
|
40
|
+
* The chip, the image box and the media popover. Mounted once, in the overlay. `barRight` and
|
|
41
|
+
* `barTop`: the selected block's top right corner while its action bar sits inside it, else null.
|
|
42
|
+
*/
|
|
43
|
+
export const ImageEditor = memo(function ImageEditor({ barRight, barTop }) {
|
|
41
44
|
const runtime = useRuntime();
|
|
42
45
|
const store = imageEditor(runtime);
|
|
43
46
|
const state = useValue(store);
|
|
@@ -52,6 +55,7 @@ export const ImageEditor = memo(function ImageEditor() {
|
|
|
52
55
|
const [library, setLibrary] = useState(null);
|
|
53
56
|
const host = useSyncExternalStore(noSubscription, editorRoot, noRoot);
|
|
54
57
|
const viewport = useValueSelector(runtime.measurement, (m) => m?.viewport ?? null, sameSize);
|
|
58
|
+
const { zoom } = useValue(runtime.frame);
|
|
55
59
|
const open = state.open;
|
|
56
60
|
const target = open?.target ?? held ?? state.hover;
|
|
57
61
|
const spotIndex = open && target === open.target ? Math.min(open.spot, target.spots.length - 1) : 0;
|
|
@@ -86,9 +90,11 @@ export const ImageEditor = memo(function ImageEditor() {
|
|
|
86
90
|
// The part of the image inside the canvas view: a cover image is often larger than its section.
|
|
87
91
|
const rect = spot ? visiblePart(spot.rect, viewport) : null;
|
|
88
92
|
const box = rect ? { left: rect.x, top: rect.y, width: rect.width, height: rect.height } : undefined;
|
|
89
|
-
|
|
93
|
+
// The chip's anchor is the image's top right corner; CSS moves it inside, under the bar or above.
|
|
94
|
+
const chip = rect ? { left: rect.x + rect.width, top: rect.y } : undefined;
|
|
95
|
+
const place = rect ? chipPlace(rect, zoom, barRight !== null && barTop !== null ? { right: barRight, top: barTop } : null) : 'inside';
|
|
90
96
|
const chipLabel = busy ? 'Uploading…' : state.dropping ? 'Drop to replace' : 'Replace';
|
|
91
|
-
return (_jsxs(_Fragment, { children: [visible && target && spot && (_jsxs(_Fragment, { children: [_jsx("div", { className: "builder-media__box", "data-dropping": state.dropping || undefined, "data-busy": busy || undefined, style: box }), _jsxs("button", { ref: chipRef, type: "button", className: "builder-media__chip", style: chip, "aria-haspopup": "dialog", "aria-expanded": popover.open, "data-tooltip": popover.open || state.dropping ? undefined : 'Replace the image (or double-click it, or drop a file on it)', onPointerEnter: () => setHeld(state.hover ?? held), onPointerLeave: () => setHeld(null), onClick: () => {
|
|
97
|
+
return (_jsxs(_Fragment, { children: [visible && target && spot && (_jsxs(_Fragment, { children: [_jsx("div", { className: "builder-media__box", "data-dropping": state.dropping || undefined, "data-busy": busy || undefined, style: box }), _jsxs("button", { ref: chipRef, type: "button", className: "builder-media__chip", "data-place": place, style: chip, "aria-haspopup": "dialog", "aria-expanded": popover.open, "data-tooltip": popover.open || state.dropping ? undefined : 'Replace the image (or double-click it, or drop a file on it)', onPointerEnter: () => setHeld(state.hover ?? held), onPointerLeave: () => setHeld(null), onClick: () => {
|
|
92
98
|
if (popover.isOpen()) {
|
|
93
99
|
popover.hide();
|
|
94
100
|
return;
|
|
@@ -39,9 +39,19 @@
|
|
|
39
39
|
box-shadow: 0 1px 4px rgb(0 0 0 / 0.25);
|
|
40
40
|
cursor: pointer;
|
|
41
41
|
pointer-events: auto;
|
|
42
|
+
// Anchored at the image's top right corner (ImageEditor.tsx `chipPlace`), the same screen
|
|
43
|
+
// size at any zoom: inside the corner with a small inset, under the action bar when that bar
|
|
44
|
+
// sits in the corner, or above a small image.
|
|
42
45
|
transform-origin: 0 0;
|
|
43
|
-
|
|
44
|
-
|
|
46
|
+
transform: scale(var(--be-inv, 1)) translate(calc(-100% - 6px), 6px);
|
|
47
|
+
|
|
48
|
+
&[data-place='under-bar'] {
|
|
49
|
+
transform: scale(var(--be-inv, 1)) translate(calc(-100% - 6px), 36px);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
&[data-place='above'] {
|
|
53
|
+
transform: scale(var(--be-inv, 1)) translate(-100%, calc(-100% - 4px));
|
|
54
|
+
}
|
|
45
55
|
|
|
46
56
|
&:hover,
|
|
47
57
|
&[aria-expanded='true'] {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type DataField } from '../../../core/index.js';
|
|
2
|
-
import type { Block, BlockDefinition, Operation } from '../../../core/types.js';
|
|
2
|
+
import type { Block, BlockDefinition, Operation, Rect } from '../../../core/types.js';
|
|
3
3
|
/** The upload field behind a canvas image path. */
|
|
4
4
|
export type UploadSpotField = {
|
|
5
5
|
field: DataField;
|
|
@@ -43,3 +43,12 @@ export declare function altPropPath(definition: BlockDefinition | undefined, pat
|
|
|
43
43
|
export declare function altFromFileName(name: string): string;
|
|
44
44
|
/** The stored value at a prop path ("photo", "items.3.image", "gallery.2"), or undefined. */
|
|
45
45
|
export declare function propAt(props: Record<string, unknown> | undefined, path: string): unknown;
|
|
46
|
+
/**
|
|
47
|
+
* Where the "Replace" chip goes: inside the image's top right corner (`inside`); lower down
|
|
48
|
+
* (`under-bar`) when the selected block's action bar sits in that corner; above the image when the
|
|
49
|
+
* image is too small for the chip.
|
|
50
|
+
*/
|
|
51
|
+
export declare function chipPlace(image: Rect, zoom: number, bar: {
|
|
52
|
+
right: number;
|
|
53
|
+
top: number;
|
|
54
|
+
} | null): 'inside' | 'under-bar' | 'above';
|
|
@@ -100,3 +100,22 @@ export function propAt(props, path) {
|
|
|
100
100
|
}
|
|
101
101
|
return current;
|
|
102
102
|
}
|
|
103
|
+
/** Smallest image (screen pixels) that holds the chip inside it; a smaller one gets it above. */
|
|
104
|
+
const CHIP_ROOM = { width: 96, height: 36 };
|
|
105
|
+
/** How far the selected block's action bar reaches into the block when it sits inside (screen pixels). */
|
|
106
|
+
const BAR_REACH = { width: 120, height: 32 };
|
|
107
|
+
/**
|
|
108
|
+
* Where the "Replace" chip goes: inside the image's top right corner (`inside`); lower down
|
|
109
|
+
* (`under-bar`) when the selected block's action bar sits in that corner; above the image when the
|
|
110
|
+
* image is too small for the chip.
|
|
111
|
+
*/
|
|
112
|
+
export function chipPlace(image, zoom, bar) {
|
|
113
|
+
if (image.width * zoom < CHIP_ROOM.width || image.height * zoom < CHIP_ROOM.height)
|
|
114
|
+
return image.y * zoom >= CHIP_ROOM.height ? 'above' : 'inside';
|
|
115
|
+
if (!bar)
|
|
116
|
+
return 'inside';
|
|
117
|
+
const right = image.x + image.width;
|
|
118
|
+
const nearRight = Math.abs(bar.right - right) * zoom < BAR_REACH.width;
|
|
119
|
+
const nearTop = (image.y - bar.top) * zoom < BAR_REACH.height && (bar.top - image.y) * zoom < BAR_REACH.height;
|
|
120
|
+
return nearRight && nearTop ? 'under-bar' : 'inside';
|
|
121
|
+
}
|
|
@@ -5,7 +5,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
5
5
|
import { memo, useCallback } from 'react';
|
|
6
6
|
import { SECTION_REF_BLOCK, sectionRefId } from '../../../blocks/builtins/sectionRef.js';
|
|
7
7
|
import { findBlock, findLocation } from '../../../core/index.js';
|
|
8
|
-
import { copyBlock, copyStyles, detachSection, duplicateBlock, inRow, moveBy, parseClipboard, pasteStoredBlocks, pasteStyles, removeBlock, resetStyles, siblingCount, storedClipboard, storedStyles, storesBuilderData, toggleHidden, } from '../actions.js';
|
|
8
|
+
import { copyBlock, copyStyles, detachSection, duplicateBlock, inRow, moveBy, parseClipboard, pasteStoredBlocks, pasteStyles, removeBlock, resetStyles, siblingCount, storedClipboard, storedStyles, storesBuilderData, storesClasses, toggleHidden, } from '../actions.js';
|
|
9
9
|
import { contentModeAllows } from '../contentMode.js';
|
|
10
10
|
import { useRuntime } from '../runtime.js';
|
|
11
11
|
import { requestSaveSection } from '../sections/SectionDialog.js';
|
|
@@ -38,8 +38,8 @@ export function blockMenuEntries(runtime, id, origin) {
|
|
|
38
38
|
const parentId = location?.parentId ?? null;
|
|
39
39
|
const siblings = location ? siblingCount(layout, location.parentId, location.slot) : 0;
|
|
40
40
|
const row = inRow(layout, runtime.measurement.get(), id);
|
|
41
|
-
// A Payload blocks field stores
|
|
42
|
-
const styled =
|
|
41
|
+
// A Payload blocks field stores classes only for blocks with class keys, whatever the definition says.
|
|
42
|
+
const styled = storesClasses(runtime, block.type) && hasStyles(runtime.config.blocks, block.type);
|
|
43
43
|
const selectParent = { icon: 'parent', label: 'Select parent', keys: keys('parent'), disabled: !parentId, run: () => parentId && runtime.store.select(parentId) };
|
|
44
44
|
const moveUp = {
|
|
45
45
|
icon: row ? 'left' : 'up',
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import type { Block } from '../../core/types.js';
|
|
2
2
|
export declare function childrenOf(block: Block): Block[];
|
|
3
|
+
/**
|
|
4
|
+
* The `data-component` attribute for a component (a live saved section copy). The editor draws
|
|
5
|
+
* components in their own color (`--be-component`) on the canvas and in Layers.
|
|
6
|
+
*/
|
|
7
|
+
export declare function componentMark(block: Block | null | undefined): {
|
|
8
|
+
'data-component'?: '';
|
|
9
|
+
};
|
|
10
|
+
/** True for a component: a live saved section copy (`sectionRef`). */
|
|
11
|
+
export declare function isComponent(block: Block | null | undefined): boolean;
|
|
3
12
|
/** The name the user gave the block, or null. */
|
|
4
13
|
export declare function customLabel(block: Block): string | null;
|
|
5
14
|
/** The first heading inside a container, else its first text. Depth first. */
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
// Names for blocks in the outline, the breadcrumbs, the inspector and the publish problems.
|
|
2
2
|
// Pure functions: the type label comes from the caller (the block definition's `label`).
|
|
3
|
+
import { FORM_BLOCK, isFormFieldType } from '../../forms/pageForms.js';
|
|
3
4
|
import { iconLabel } from '../../blocks/builtins/icon.js';
|
|
5
|
+
import { SECTION_REF_BLOCK } from '../../blocks/builtins/sectionRef.js';
|
|
4
6
|
import { readsComponent } from '../../core/components.js';
|
|
5
7
|
import { FIELD_BLOCK, LIST_BLOCK } from './templates/binding.js';
|
|
6
8
|
/** Longest preview text, in characters. The row cuts it with an ellipsis anyway. */
|
|
@@ -20,6 +22,17 @@ const TAG_NAMES = {
|
|
|
20
22
|
export function childrenOf(block) {
|
|
21
23
|
return Object.values(block.slots ?? {}).flat();
|
|
22
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* The `data-component` attribute for a component (a live saved section copy). The editor draws
|
|
27
|
+
* components in their own color (`--be-component`) on the canvas and in Layers.
|
|
28
|
+
*/
|
|
29
|
+
export function componentMark(block) {
|
|
30
|
+
return isComponent(block) ? { 'data-component': '' } : {};
|
|
31
|
+
}
|
|
32
|
+
/** True for a component: a live saved section copy (`sectionRef`). */
|
|
33
|
+
export function isComponent(block) {
|
|
34
|
+
return block?.type === SECTION_REF_BLOCK;
|
|
35
|
+
}
|
|
23
36
|
/** The name the user gave the block, or null. */
|
|
24
37
|
export function customLabel(block) {
|
|
25
38
|
const label = block.label?.trim();
|
|
@@ -121,6 +134,11 @@ function ownPreview(block) {
|
|
|
121
134
|
// The label for screen readers, else the icon's name ("arrowRight" -> "arrow right").
|
|
122
135
|
return clip(str('label') || iconLabel(str('name')));
|
|
123
136
|
default:
|
|
137
|
+
// A form field shows its label (else its name, the key its answers are stored under). A form shows its title.
|
|
138
|
+
if (isFormFieldType(block.type))
|
|
139
|
+
return clip(str('label') || str('name'));
|
|
140
|
+
if (block.type === FORM_BLOCK)
|
|
141
|
+
return clip(str('title'));
|
|
124
142
|
if (childrenOf(block).length > 0)
|
|
125
143
|
return innerTitle(block);
|
|
126
144
|
return clip(str('text') || str('label') || str('quote') || str('title') || str('alt'));
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { RegionConfig } from '../../../core/types.js';
|
|
2
|
+
import type { RegionsController } from './controller.js';
|
|
3
|
+
export declare function RegionFields({ regions, region }: {
|
|
4
|
+
regions: RegionsController;
|
|
5
|
+
region: RegionConfig;
|
|
6
|
+
}): import("react").JSX.Element | null;
|