payload-canvas 0.4.0 → 0.5.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 +625 -153
- package/dist/admin/AiKeyField.d.ts +8 -0
- package/dist/admin/AiKeyField.js +54 -0
- package/dist/admin/BuilderTab.js +4 -1
- package/dist/admin/DocumentEditView.d.ts +9 -0
- package/dist/admin/DocumentEditView.js +45 -0
- package/dist/admin/LayoutField.d.ts +2 -2
- package/dist/admin/LayoutField.js +10 -7
- package/dist/admin/TemplateConditionsField.d.ts +9 -0
- package/dist/admin/TemplateConditionsField.js +22 -0
- package/dist/admin/aiKeyField.scss +58 -0
- package/dist/admin/client.d.ts +3 -0
- package/dist/admin/client.js +6 -0
- package/dist/admin/diff/changes.js +5 -0
- package/dist/admin/editor/Canvas.js +20 -5
- package/dist/admin/editor/Editor.d.ts +3 -1
- package/dist/admin/editor/Editor.js +6 -3
- package/dist/admin/editor/Inspector.js +75 -28
- package/dist/admin/editor/Library.js +40 -15
- package/dist/admin/editor/Outline.js +21 -16
- package/dist/admin/editor/Overlay.js +8 -3
- package/dist/admin/editor/actions.d.ts +10 -2
- package/dist/admin/editor/actions.js +18 -3
- package/dist/admin/editor/assistant/AssistantPanel.js +3 -1
- package/dist/admin/editor/classes/ClassManager.d.ts +4 -0
- package/dist/admin/editor/classes/ClassManager.js +56 -0
- package/dist/admin/editor/classes/controller.d.ts +112 -0
- package/dist/admin/editor/classes/controller.js +326 -0
- package/dist/admin/editor/classes/manager.scss +262 -0
- package/dist/admin/editor/classes/managerModel.d.ts +5 -0
- package/dist/admin/editor/classes/managerModel.js +27 -0
- package/dist/admin/editor/comments/CommentLayer.d.ts +2 -0
- package/dist/admin/editor/comments/CommentLayer.js +143 -0
- package/dist/admin/editor/comments/CommentsPanel.d.ts +8 -0
- package/dist/admin/editor/comments/CommentsPanel.js +73 -0
- package/dist/admin/editor/comments/Thread.d.ts +26 -0
- package/dist/admin/editor/comments/Thread.js +84 -0
- package/dist/admin/editor/comments/comments.scss +539 -0
- package/dist/admin/editor/comments/controller.d.ts +48 -0
- package/dist/admin/editor/comments/controller.js +142 -0
- package/dist/admin/editor/contentMode.d.ts +17 -0
- package/dist/admin/editor/contentMode.js +37 -0
- package/dist/admin/editor/dnd/DropOutlines.d.ts +1 -0
- package/dist/admin/editor/dnd/DropOutlines.js +73 -0
- package/dist/admin/editor/dnd/dnd.scss +43 -0
- package/dist/admin/editor/dnd/mode.d.ts +4 -0
- package/dist/admin/editor/dnd/mode.js +39 -0
- package/dist/admin/editor/editor.scss +13 -58
- package/dist/admin/editor/empty/EmptyStart.js +18 -66
- package/dist/admin/editor/fields/AddButton.d.ts +15 -0
- package/dist/admin/editor/fields/AddButton.js +14 -0
- package/dist/admin/editor/fields/ArrayField.js +3 -2
- package/dist/admin/editor/fields/CheckedInputs.d.ts +1 -0
- package/dist/admin/editor/fields/ConditionRows.d.ts +19 -0
- package/dist/admin/editor/fields/ConditionRows.js +137 -0
- package/dist/admin/editor/fields/ListWhereField.d.ts +8 -0
- package/dist/admin/editor/fields/ListWhereField.js +20 -0
- package/dist/admin/editor/fields/QueryFiltersField.d.ts +18 -0
- package/dist/admin/editor/fields/QueryFiltersField.js +41 -0
- package/dist/admin/editor/fields/RelatedField.d.ts +19 -0
- package/dist/admin/editor/fields/RelatedField.js +44 -0
- package/dist/admin/editor/fields/SortField.d.ts +13 -0
- package/dist/admin/editor/fields/SortField.js +37 -0
- package/dist/admin/editor/fields/WhereField.d.ts +12 -4
- package/dist/admin/editor/fields/WhereField.js +33 -53
- package/dist/admin/editor/fields/collectionFields.d.ts +6 -0
- package/dist/admin/editor/fields/collectionFields.js +15 -0
- package/dist/admin/editor/fields/conditions.d.ts +99 -0
- package/dist/admin/editor/fields/conditions.js +339 -0
- package/dist/admin/editor/fields/fields.scss +232 -9
- package/dist/admin/editor/fields/listOptions.d.ts +44 -0
- package/dist/admin/editor/fields/listOptions.js +111 -0
- package/dist/admin/editor/fields/queryFilterRows.d.ts +8 -0
- package/dist/admin/editor/fields/queryFilterRows.js +29 -0
- package/dist/admin/editor/fields/whereRows.d.ts +11 -12
- package/dist/admin/editor/fields/whereRows.js +83 -34
- package/dist/admin/editor/icons.d.ts +16 -1
- package/dist/admin/editor/icons.js +30 -1
- package/dist/admin/editor/inline.js +9 -0
- package/dist/admin/editor/insert/InsertHandle.js +4 -1
- package/dist/admin/editor/insert/picker.d.ts +3 -1
- package/dist/admin/editor/insert/picker.js +17 -10
- package/dist/admin/editor/insert/spots.d.ts +12 -1
- package/dist/admin/editor/insert/spots.js +49 -10
- package/dist/admin/editor/layout/LeftPanel.js +11 -6
- package/dist/admin/editor/live/useMultiplayer.js +9 -1
- package/dist/admin/editor/menu/blockMenu.js +27 -17
- package/dist/admin/editor/names.js +11 -3
- package/dist/admin/editor/renderField.d.ts +3 -1
- package/dist/admin/editor/renderField.js +63 -12
- package/dist/admin/editor/runtime.d.ts +14 -0
- package/dist/admin/editor/runtime.js +67 -6
- package/dist/admin/editor/sections/ComponentFields.d.ts +8 -0
- package/dist/admin/editor/sections/ComponentFields.js +116 -0
- package/dist/admin/editor/sections/PropertyControls.d.ts +18 -0
- package/dist/admin/editor/sections/PropertyControls.js +65 -0
- package/dist/admin/editor/sections/components.d.ts +29 -0
- package/dist/admin/editor/sections/components.js +112 -0
- package/dist/admin/editor/sections/components.scss +238 -0
- package/dist/admin/editor/sections/variants.d.ts +32 -0
- package/dist/admin/editor/sections/variants.js +59 -0
- package/dist/admin/editor/sections/variants.scss +90 -0
- package/dist/admin/editor/shortcuts.d.ts +4 -1
- package/dist/admin/editor/shortcuts.js +19 -3
- package/dist/admin/editor/store.d.ts +18 -0
- package/dist/admin/editor/store.js +46 -0
- package/dist/admin/editor/styles/ClassBar.d.ts +14 -0
- package/dist/admin/editor/styles/ClassBar.js +90 -0
- package/dist/admin/editor/styles/ClassCss.d.ts +4 -0
- package/dist/admin/editor/styles/ClassCss.js +28 -0
- package/dist/admin/editor/styles/ClassDialog.d.ts +2 -0
- package/dist/admin/editor/styles/ClassDialog.js +151 -0
- package/dist/admin/editor/styles/ColorPicker.js +5 -2
- package/dist/admin/editor/styles/RawClasses.d.ts +26 -1
- package/dist/admin/editor/styles/RawClasses.js +184 -32
- package/dist/admin/editor/styles/StylesPanel.d.ts +3 -3
- package/dist/admin/editor/styles/StylesPanel.js +53 -14
- package/dist/admin/editor/styles/VariantBar.js +2 -2
- package/dist/admin/editor/styles/classEdit.d.ts +4 -0
- package/dist/admin/editor/styles/classEdit.js +20 -0
- package/dist/admin/editor/styles/classes.scss +381 -0
- package/dist/admin/editor/styles/context.d.ts +19 -6
- package/dist/admin/editor/styles/context.js +24 -6
- package/dist/admin/editor/styles/controls.d.ts +3 -1
- package/dist/admin/editor/styles/controls.js +30 -12
- package/dist/admin/editor/styles/popover.d.ts +6 -0
- package/dist/admin/editor/styles/popover.js +5 -5
- package/dist/admin/editor/styles/styles.scss +26 -104
- package/dist/admin/editor/styles/suggestions.d.ts +22 -0
- package/dist/admin/editor/styles/suggestions.js +77 -0
- package/dist/admin/editor/styles/tokens.js +14 -0
- package/dist/admin/editor/templates/Bindable.js +86 -57
- package/dist/admin/editor/templates/SamplePicker.js +1 -1
- package/dist/admin/editor/templates/Visibility.d.ts +9 -0
- package/dist/admin/editor/templates/Visibility.js +54 -0
- package/dist/admin/editor/templates/binding.d.ts +2 -2
- package/dist/admin/editor/templates/binding.js +2 -2
- package/dist/admin/editor/templates/templates.scss +27 -0
- package/dist/admin/editor/templates/visibilityRows.d.ts +22 -0
- package/dist/admin/editor/templates/visibilityRows.js +83 -0
- package/dist/admin/editor/topbar/ContentModeToggle.d.ts +5 -0
- package/dist/admin/editor/topbar/ContentModeToggle.js +26 -0
- package/dist/admin/editor/topbar/DocumentActions.d.ts +1 -1
- package/dist/admin/editor/topbar/DocumentActions.js +5 -4
- package/dist/admin/editor/topbar/DocumentTitle.js +7 -2
- package/dist/admin/editor/topbar/TopBar.js +15 -3
- package/dist/admin/editor/topbar/contentMode.scss +35 -0
- package/dist/admin/editor/topbar/topbar.scss +3 -1
- package/dist/admin/formChoice.d.ts +3 -0
- package/dist/admin/formChoice.js +10 -0
- package/dist/admin/layoutField.scss +69 -0
- package/dist/admin/screen/BuilderScreen.d.ts +6 -1
- package/dist/admin/screen/BuilderScreen.js +4 -3
- package/dist/admin/server/BuilderView.js +10 -3
- package/dist/admin/templateConditions.scss +24 -0
- package/dist/ai/adapters/anthropic.js +17 -4
- package/dist/ai/adapters/cloudflare-gateway.js +7 -1
- package/dist/ai/adapters/cloudflare-workers-ai.js +2 -0
- package/dist/ai/adapters/openai-compatible.js +1 -0
- package/dist/ai/adapters/openrouter.js +2 -0
- package/dist/ai/config.d.ts +24 -4
- package/dist/ai/config.js +27 -8
- package/dist/ai/endpoint.d.ts +5 -2
- package/dist/ai/endpoint.js +31 -26
- package/dist/ai/images/cloudflare-workers-ai.js +6 -2
- package/dist/ai/images/openai.js +8 -3
- package/dist/ai/images/openrouter.js +6 -2
- package/dist/ai/images/service.d.ts +10 -4
- package/dist/ai/images/service.js +23 -7
- package/dist/ai/openai-format.d.ts +7 -0
- package/dist/ai/openai-format.js +17 -5
- package/dist/ai/prompt.d.ts +8 -0
- package/dist/ai/prompt.js +25 -5
- package/dist/ai/settings/index.d.ts +62 -0
- package/dist/ai/settings/index.js +264 -0
- package/dist/ai/settings/secret.d.ts +11 -0
- package/dist/ai/settings/secret.js +46 -0
- package/dist/ai/settings/shared.d.ts +22 -0
- package/dist/ai/settings/shared.js +3 -0
- package/dist/ai/tools.d.ts +3 -0
- package/dist/ai/tools.js +79 -15
- package/dist/ai/types.d.ts +43 -0
- package/dist/blocks/builtins/adjacentLinks.d.ts +5 -0
- package/dist/blocks/builtins/adjacentLinks.js +76 -0
- package/dist/blocks/builtins/carousel.d.ts +2 -29
- package/dist/blocks/builtins/carousel.js +44 -51
- package/dist/blocks/builtins/disclosure.d.ts +2 -1
- package/dist/blocks/builtins/disclosure.js +22 -32
- package/dist/blocks/builtins/embed.d.ts +15 -0
- package/dist/blocks/builtins/embed.js +47 -0
- package/dist/blocks/builtins/faq.d.ts +1 -1
- package/dist/blocks/builtins/faq.js +2 -2
- package/dist/blocks/builtins/filterLink.d.ts +1 -19
- package/dist/blocks/builtins/filterLink.js +9 -50
- package/dist/blocks/builtins/icon.d.ts +2 -0
- package/dist/blocks/builtins/icon.js +8 -8
- package/dist/blocks/builtins/index.d.ts +18 -13
- package/dist/blocks/builtins/index.js +43 -22
- package/dist/blocks/builtins/marquee.d.ts +5 -0
- package/dist/blocks/builtins/marquee.js +68 -0
- package/dist/blocks/builtins/popup.d.ts +5 -0
- package/dist/blocks/builtins/popup.js +83 -0
- package/dist/blocks/builtins/sectionRef.d.ts +16 -2
- package/dist/blocks/builtins/sectionRef.js +34 -12
- package/dist/blocks/builtins/shared.d.ts +18 -23
- package/dist/blocks/builtins/shared.js +34 -42
- package/dist/blocks/builtins/tableOfContents.d.ts +4 -0
- package/dist/blocks/builtins/tableOfContents.js +12 -18
- package/dist/blocks/builtins/tabs.d.ts +6 -0
- package/dist/blocks/builtins/tabs.js +87 -0
- package/dist/blocks/client/adjacentLinks.d.ts +4 -0
- package/dist/blocks/client/adjacentLinks.js +4 -0
- package/dist/blocks/client/carousel.d.ts +45 -0
- package/dist/blocks/client/carousel.js +53 -0
- package/dist/blocks/client/embed.d.ts +21 -0
- package/dist/blocks/client/embed.js +23 -0
- package/dist/blocks/client/field.d.ts +7 -0
- package/dist/blocks/client/field.js +8 -0
- package/dist/blocks/client/filterLink.d.ts +19 -0
- package/dist/blocks/client/filterLink.js +30 -0
- package/dist/blocks/client/helpers.d.ts +21 -0
- package/dist/blocks/client/helpers.js +24 -0
- package/dist/blocks/client/marquee.d.ts +14 -0
- package/dist/blocks/client/marquee.js +25 -0
- package/dist/blocks/client/menu.d.ts +46 -0
- package/dist/blocks/client/menu.js +49 -0
- package/dist/blocks/client/popup.d.ts +15 -0
- package/dist/blocks/client/popup.js +16 -0
- package/dist/blocks/client/tabs.d.ts +10 -0
- package/dist/blocks/client/tabs.js +11 -0
- package/dist/blocks/defaults.d.ts +15 -52
- package/dist/blocks/defaults.js +203 -437
- package/dist/blocks/index.d.ts +1 -2
- package/dist/blocks/index.js +1 -2
- package/dist/classes/actions.d.ts +97 -0
- package/dist/classes/actions.js +296 -0
- package/dist/classes/collection.d.ts +5 -0
- package/dist/classes/collection.js +189 -0
- package/dist/classes/config.d.ts +34 -0
- package/dist/classes/config.js +8 -0
- package/dist/classes/endpoints.d.ts +2 -0
- package/dist/classes/endpoints.js +120 -0
- package/dist/classes/index.d.ts +36 -0
- package/dist/classes/index.js +42 -0
- package/dist/classes/mcp.d.ts +6 -0
- package/dist/classes/mcp.js +161 -0
- package/dist/classes/shared.d.ts +131 -0
- package/dist/classes/shared.js +300 -0
- package/dist/classes/sheet.d.ts +34 -0
- package/dist/classes/sheet.js +126 -0
- package/dist/classes/usage.d.ts +57 -0
- package/dist/classes/usage.js +208 -0
- package/dist/comments/collection.d.ts +38 -0
- package/dist/comments/collection.js +226 -0
- package/dist/comments/config.d.ts +15 -0
- package/dist/comments/config.js +2 -0
- package/dist/comments/index.d.ts +20 -0
- package/dist/comments/index.js +22 -0
- package/dist/comments/shared.d.ts +54 -0
- package/dist/comments/shared.js +104 -0
- package/dist/core/bindings.d.ts +77 -32
- package/dist/core/bindings.js +319 -134
- package/dist/core/blockNames.d.ts +9 -0
- package/dist/core/blockNames.js +11 -0
- package/dist/core/blocks.d.ts +21 -8
- package/dist/core/blocks.js +37 -16
- package/dist/core/classes.d.ts +16 -8
- package/dist/core/classes.js +31 -27
- package/dist/core/components.d.ts +72 -0
- package/dist/core/components.js +294 -0
- package/dist/core/contentMode.d.ts +27 -0
- package/dist/core/contentMode.js +0 -0
- package/dist/core/dropTarget.d.ts +11 -0
- package/dist/core/dropTarget.js +24 -1
- package/dist/core/fields.d.ts +5 -0
- package/dist/core/fields.js +11 -0
- package/dist/core/headings.d.ts +5 -2
- package/dist/core/headings.js +14 -6
- package/dist/core/index.d.ts +8 -3
- package/dist/core/index.js +8 -3
- package/dist/core/layers.d.ts +9 -0
- package/dist/core/layers.js +29 -0
- package/dist/core/operations.d.ts +6 -0
- package/dist/core/operations.js +85 -24
- package/dist/core/payloadBlocks.js +5 -1
- package/dist/core/references.js +28 -0
- package/dist/core/schema.js +20 -6
- package/dist/core/sectionOrigin.d.ts +6 -0
- package/dist/core/sectionOrigin.js +21 -0
- package/dist/core/sections.d.ts +72 -0
- package/dist/core/sections.js +331 -0
- package/dist/core/templateChoice.d.ts +24 -0
- package/dist/core/templateChoice.js +43 -0
- package/dist/core/tree.js +18 -6
- package/dist/core/types.d.ts +148 -18
- package/dist/core/validate.d.ts +4 -1
- package/dist/core/validate.js +28 -11
- package/dist/core/visibility.d.ts +63 -0
- package/dist/core/visibility.js +214 -0
- package/dist/core/whereValues.d.ts +22 -0
- package/dist/core/whereValues.js +43 -0
- package/dist/css/classes.d.ts +16 -0
- package/dist/css/classes.js +172 -0
- package/dist/css/index.d.ts +32 -1
- package/dist/css/index.js +64 -5
- package/dist/css/tokens.d.ts +10 -0
- package/dist/css/tokens.js +23 -10
- package/dist/index.d.ts +5 -2
- package/dist/index.js +6 -1
- package/dist/live/contentMode.d.ts +24 -0
- package/dist/live/contentMode.js +39 -0
- package/dist/live/endpoints.js +3 -0
- package/dist/live/session.d.ts +5 -0
- package/dist/live/session.js +8 -0
- package/dist/live/types.d.ts +16 -1
- package/dist/mcp/index.d.ts +10 -1
- package/dist/mcp/index.js +146 -54
- package/dist/mcp/shared.d.ts +93 -3
- package/dist/mcp/shared.js +211 -15
- package/dist/plugin/hook.d.ts +7 -1
- package/dist/plugin/hook.js +30 -4
- package/dist/plugin/index.d.ts +19 -8
- package/dist/plugin/index.js +89 -20
- package/dist/plugin/links.d.ts +24 -0
- package/dist/plugin/links.js +27 -0
- package/dist/plugin/listCollections.d.ts +9 -7
- package/dist/plugin/listCollections.js +30 -21
- package/dist/plugin/sections.d.ts +14 -7
- package/dist/plugin/sections.js +69 -23
- package/dist/plugin/sectionsUsedIn.d.ts +6 -0
- package/dist/plugin/sectionsUsedIn.js +24 -0
- package/dist/plugin/templateEndpoint.d.ts +9 -0
- package/dist/plugin/templateEndpoint.js +49 -0
- package/dist/plugin/templates.js +23 -8
- package/dist/protocol/index.d.ts +16 -1
- package/dist/react/canvas/BuilderCanvas.js +144 -21
- package/dist/react/canvas/classes.d.ts +17 -0
- package/dist/react/canvas/classes.js +102 -0
- package/dist/react/canvas/controls.d.ts +31 -0
- package/dist/react/canvas/controls.js +75 -0
- package/dist/react/canvas/fetchDocs.d.ts +2 -2
- package/dist/react/canvas/fetchDocs.js +16 -8
- package/dist/react/canvas/measure.d.ts +9 -0
- package/dist/react/canvas/measure.js +106 -7
- package/dist/react/canvas/resolveLayout.d.ts +1 -1
- package/dist/react/canvas/resolveLayout.js +4 -3
- package/dist/react/canvas/thumbnail/ThumbnailCanvas.js +17 -4
- package/dist/react/classes/ClassesStyle.d.ts +27 -0
- package/dist/react/classes/ClassesStyle.js +27 -0
- package/dist/react/components/Button.d.ts +2 -11
- package/dist/react/components/Button.js +8 -43
- package/dist/react/components/CollectionList.d.ts +4 -1
- package/dist/react/components/CollectionList.js +10 -3
- package/dist/react/components/Container.d.ts +5 -2
- package/dist/react/components/Container.js +7 -4
- package/dist/react/components/Field.js +3 -14
- package/dist/react/components/Link.d.ts +1 -1
- package/dist/react/components/Link.js +5 -3
- package/dist/react/components/List.d.ts +1 -1
- package/dist/react/components/List.js +2 -2
- package/dist/react/components/Menu.d.ts +10 -1
- package/dist/react/components/Menu.js +39 -12
- package/dist/react/components/RichText.d.ts +3 -4
- package/dist/react/components/RichText.js +5 -5
- package/dist/react/components/builtins/Accordion.d.ts +4 -3
- package/dist/react/components/builtins/Accordion.js +6 -5
- package/dist/react/components/builtins/AdjacentLinks.d.ts +11 -0
- package/dist/react/components/builtins/AdjacentLinks.js +20 -0
- package/dist/react/components/builtins/Carousel.d.ts +21 -10
- package/dist/react/components/builtins/Carousel.js +175 -100
- package/dist/react/components/builtins/Disclosure.d.ts +4 -3
- package/dist/react/components/builtins/Disclosure.js +6 -5
- package/dist/react/components/builtins/Embed.d.ts +11 -0
- package/dist/react/components/builtins/Embed.js +23 -0
- package/dist/react/components/builtins/EmbedHtml.d.ts +15 -0
- package/dist/react/components/builtins/EmbedHtml.js +51 -0
- package/dist/react/components/builtins/EmbedPreview.d.ts +34 -0
- package/dist/react/components/builtins/EmbedPreview.js +105 -0
- package/dist/react/components/builtins/FilterLink.d.ts +1 -1
- package/dist/react/components/builtins/FilterLink.js +4 -4
- package/dist/react/components/builtins/Marquee.d.ts +8 -0
- package/dist/react/components/builtins/Marquee.js +15 -0
- package/dist/react/components/builtins/Popup.d.ts +26 -0
- package/dist/react/components/builtins/Popup.js +146 -0
- package/dist/react/components/builtins/SectionRef.d.ts +4 -3
- package/dist/react/components/builtins/SectionRef.js +9 -5
- package/dist/react/components/builtins/Tab.d.ts +7 -0
- package/dist/react/components/builtins/Tab.js +21 -0
- package/dist/react/components/builtins/TableOfContents.d.ts +17 -3
- package/dist/react/components/builtins/TableOfContents.js +22 -7
- package/dist/react/components/builtins/Tabs.d.ts +17 -0
- package/dist/react/components/builtins/Tabs.js +71 -0
- package/dist/react/components/builtins/index.d.ts +37 -20
- package/dist/react/components/builtins/index.js +54 -20
- package/dist/react/components/builtins/tabsContext.d.ts +12 -0
- package/dist/react/components/builtins/tabsContext.js +6 -0
- package/dist/react/components/index.js +11 -8
- package/dist/react/components/lazy.d.ts +32 -0
- package/dist/react/components/lazy.js +20 -0
- package/dist/react/components/lazyBlock.d.ts +17 -0
- package/dist/react/components/lazyBlock.js +23 -0
- package/dist/react/index.d.ts +6 -3
- package/dist/react/index.js +5 -2
- package/dist/react/render/RenderLayout.d.ts +9 -7
- package/dist/react/render/RenderLayout.js +96 -45
- package/dist/react/render/canvasMode.d.ts +13 -0
- package/dist/react/render/canvasMode.js +13 -0
- package/dist/react/render/canvasServer.js +4 -3
- package/dist/react/render/canvasServerTypes.d.ts +5 -0
- package/dist/react/render/lists.d.ts +36 -4
- package/dist/react/render/lists.js +132 -15
- package/dist/react/render/marks.d.ts +15 -0
- package/dist/react/render/marks.js +23 -0
- package/dist/react/render/payload.d.ts +8 -1
- package/dist/react/render/payload.js +12 -3
- package/dist/react/render/preview.d.ts +11 -0
- package/dist/react/render/preview.js +13 -0
- package/dist/react/render/relations.d.ts +10 -0
- package/dist/react/render/relations.js +39 -0
- package/dist/react/render/resolve.d.ts +8 -4
- package/dist/react/render/resolve.js +11 -5
- package/dist/react/render/reveal.d.ts +17 -0
- package/dist/react/render/reveal.js +39 -0
- package/dist/react/render/sections.d.ts +11 -5
- package/dist/react/render/sections.js +52 -24
- package/dist/react/render/templates.d.ts +47 -0
- package/dist/react/render/templates.js +139 -0
- package/dist/react/render/types.d.ts +62 -5
- package/dist/react/server.d.ts +2 -37
- package/dist/react/server.js +8 -133
- package/dist/react/theme/ThemeLiveLoader.d.ts +4 -0
- package/dist/react/theme/ThemeLiveLoader.js +5 -0
- package/dist/react/theme/ThemeStyle.js +1 -1
- package/dist/theme/admin/Variables.d.ts +11 -0
- package/dist/theme/admin/Variables.js +115 -0
- package/dist/theme/admin/fields.scss +113 -0
- package/dist/theme/client.d.ts +1 -0
- package/dist/theme/client.js +2 -0
- package/dist/theme/css.d.ts +6 -1
- package/dist/theme/css.js +12 -4
- package/dist/theme/global.js +83 -0
- package/dist/theme/index.d.ts +1 -0
- package/dist/theme/index.js +1 -0
- package/dist/theme/server.d.ts +15 -0
- package/dist/theme/server.js +43 -0
- package/dist/theme/usage.d.ts +23 -0
- package/dist/theme/usage.js +68 -0
- package/dist/theme/variables.d.ts +72 -0
- package/dist/theme/variables.js +231 -0
- package/package.json +4 -2
- package/dist/admin/editor/styles/SiteClasses.d.ts +0 -9
- package/dist/admin/editor/styles/SiteClasses.js +0 -31
- package/dist/blocks/builtins/headingId.d.ts +0 -15
- package/dist/blocks/builtins/headingId.js +0 -36
- package/dist/blocks/builtins/lightbox.d.ts +0 -43
- package/dist/blocks/builtins/lightbox.js +0 -93
- package/dist/blocks/builtins/mediaBackdrop.d.ts +0 -11
- package/dist/blocks/builtins/mediaBackdrop.js +0 -79
- package/dist/react/components/Quote.d.ts +0 -3
- package/dist/react/components/Quote.js +0 -12
- package/dist/react/components/Spacer.d.ts +0 -3
- package/dist/react/components/Spacer.js +0 -6
- package/dist/react/components/builtins/BackdropVideo.d.ts +0 -13
- package/dist/react/components/builtins/BackdropVideo.js +0 -16
- package/dist/react/components/builtins/Lightbox.d.ts +0 -45
- package/dist/react/components/builtins/Lightbox.js +0 -252
- package/dist/react/components/builtins/MediaBackdrop.d.ts +0 -14
- package/dist/react/components/builtins/MediaBackdrop.js +0 -61
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type TabsState = {
|
|
2
|
+
/** The id of the block of the open tab. */
|
|
3
|
+
active: string | null;
|
|
4
|
+
/** The id of a tab's button, by the tab block's id. */
|
|
5
|
+
tabId: (blockId: string) => string;
|
|
6
|
+
/** The id of a tab's panel, by the tab block's id. */
|
|
7
|
+
panelId: (blockId: string) => string;
|
|
8
|
+
/** The classes of the tabs block's `panel` part, for every panel. */
|
|
9
|
+
panelClassName?: string;
|
|
10
|
+
};
|
|
11
|
+
/** Set by the tabs block for the tab blocks in its slot. Null outside a tabs block. */
|
|
12
|
+
export declare const TabsContext: import("react").Context<TabsState | null>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
// Shared by the tabs block and its tab blocks. Its own module, so both lazy chunks get the same
|
|
3
|
+
// context.
|
|
4
|
+
import { createContext } from 'react';
|
|
5
|
+
/** Set by the tabs block for the tab blocks in its slot. Null outside a tabs block. */
|
|
6
|
+
export const TabsContext = createContext(null);
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { withClientLinks, withLinkComponent } from '../render/marks.js';
|
|
2
|
+
import { SectionRef } from './builtins/SectionRef.js';
|
|
1
3
|
import { Button } from './Button.js';
|
|
2
4
|
import { CollectionList } from './CollectionList.js';
|
|
3
5
|
import { Container } from './Container.js';
|
|
@@ -7,10 +9,9 @@ import { Heading } from './Heading.js';
|
|
|
7
9
|
import { Image } from './Image.js';
|
|
8
10
|
import { Link } from './Link.js';
|
|
9
11
|
import { List, ListItem } from './List.js';
|
|
10
|
-
|
|
11
|
-
import {
|
|
12
|
+
// The menu's JavaScript loads only on pages that render a menu.
|
|
13
|
+
import { Menu } from './lazy.js';
|
|
12
14
|
import { RichText } from './RichText.js';
|
|
13
|
-
import { Spacer } from './Spacer.js';
|
|
14
15
|
import { Text } from './Text.js';
|
|
15
16
|
import { Video } from './Video.js';
|
|
16
17
|
export const defaultComponents = {
|
|
@@ -20,17 +21,19 @@ export const defaultComponents = {
|
|
|
20
21
|
text: Text,
|
|
21
22
|
richText: RichText,
|
|
22
23
|
image: Image,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
// They render links with RenderLayout's `linkComponent` (for example `next/link`). The menu is a
|
|
25
|
+
// client component: it gets `clientLinks` and renders `next/link` itself.
|
|
26
|
+
button: withLinkComponent(Button),
|
|
27
|
+
link: withLinkComponent(Link),
|
|
28
|
+
menu: withClientLinks(Menu),
|
|
26
29
|
list: List,
|
|
27
30
|
listItem: ListItem,
|
|
28
|
-
quote: Quote,
|
|
29
31
|
divider: Divider,
|
|
30
|
-
spacer: Spacer,
|
|
31
32
|
video: Video,
|
|
32
33
|
field: Field,
|
|
33
34
|
collectionList: CollectionList,
|
|
34
35
|
// A repeat wraps its rows the same way.
|
|
35
36
|
repeat: CollectionList,
|
|
37
|
+
// The live saved section block: the plugin adds its definition when saved sections are on.
|
|
38
|
+
sectionRef: SectionRef,
|
|
36
39
|
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { BlockComponentProps } from '../render/types.js';
|
|
2
|
+
import type { CarouselLabels } from './builtins/Carousel.js';
|
|
3
|
+
import type { PopupLabels } from './builtins/Popup.js';
|
|
4
|
+
import type { TabsLabels } from './builtins/Tabs.js';
|
|
5
|
+
import type { MenuLabels } from './Menu.js';
|
|
6
|
+
export declare const Menu: import("react").ComponentType<BlockComponentProps & {
|
|
7
|
+
labels?: MenuLabels;
|
|
8
|
+
}>;
|
|
9
|
+
export declare const Accordion: import("react").ComponentType<BlockComponentProps>;
|
|
10
|
+
export declare const Carousel: import("react").ComponentType<BlockComponentProps & {
|
|
11
|
+
labels?: CarouselLabels;
|
|
12
|
+
}>;
|
|
13
|
+
export declare const FilterLink: import("react").ComponentType<BlockComponentProps>;
|
|
14
|
+
export declare const Popup: import("react").ComponentType<BlockComponentProps & {
|
|
15
|
+
labels?: PopupLabels;
|
|
16
|
+
}>;
|
|
17
|
+
export declare const Tabs: import("react").ComponentType<BlockComponentProps & {
|
|
18
|
+
labels?: TabsLabels;
|
|
19
|
+
}>;
|
|
20
|
+
export declare const EmbedHtml: import("react").ComponentType<{
|
|
21
|
+
html: string;
|
|
22
|
+
className?: string;
|
|
23
|
+
attributes: Record<string, string>;
|
|
24
|
+
}>;
|
|
25
|
+
export declare const EmbedPreview: import("react").ComponentType<{
|
|
26
|
+
code: string;
|
|
27
|
+
mode: import("../../blocks/client/embed.js").EmbedMode;
|
|
28
|
+
title: string;
|
|
29
|
+
className?: string;
|
|
30
|
+
attributes: Record<string, string>;
|
|
31
|
+
}>;
|
|
32
|
+
export declare const Tab: import("react").ComponentType<BlockComponentProps>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
// The interactive block components, each in its own chunk. A route ships every client component
|
|
3
|
+
// its modules import, rendered or not, so a static import would put the carousel's JavaScript on
|
|
4
|
+
// every page. `next/dynamic` in a client module splits each one out: the server renders its HTML
|
|
5
|
+
// as usual (and preloads its chunk), and the browser loads it only on pages that render it.
|
|
6
|
+
//
|
|
7
|
+
// The implementations stay in their own files (`./Menu`, `./builtins/Carousel`, …); import those
|
|
8
|
+
// directly only where the chunk does not matter.
|
|
9
|
+
import dynamic from 'next/dynamic';
|
|
10
|
+
import { lazyBlock } from './lazyBlock.js';
|
|
11
|
+
export const Menu = lazyBlock(dynamic(() => import('./Menu.js').then((module) => module.Menu)));
|
|
12
|
+
export const Accordion = lazyBlock(dynamic(() => import('./builtins/Accordion.js').then((module) => module.Accordion)));
|
|
13
|
+
export const Carousel = lazyBlock(dynamic(() => import('./builtins/Carousel.js').then((module) => module.Carousel)));
|
|
14
|
+
export const FilterLink = lazyBlock(dynamic(() => import('./builtins/FilterLink.js').then((module) => module.FilterLink)));
|
|
15
|
+
export const Popup = lazyBlock(dynamic(() => import('./builtins/Popup.js').then((module) => module.Popup)));
|
|
16
|
+
export const Tabs = lazyBlock(dynamic(() => import('./builtins/Tabs.js').then((module) => module.Tabs)));
|
|
17
|
+
// Not blocks: the parts of the embed block that need JavaScript (`./builtins/Embed`).
|
|
18
|
+
export const EmbedHtml = dynamic(() => import('./builtins/EmbedHtml.js').then((module) => module.EmbedHtml));
|
|
19
|
+
export const EmbedPreview = dynamic(() => import('./builtins/EmbedPreview.js').then((module) => module.EmbedPreview));
|
|
20
|
+
export const Tab = lazyBlock(dynamic(() => import('./builtins/Tab.js').then((module) => module.Tab)));
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type ComponentType } from 'react';
|
|
2
|
+
import type { BlockComponentProps } from '../render/types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Wraps a block component that loads its code on demand (`next/dynamic` in a client module), so
|
|
5
|
+
* the browser loads it only on pages that render the block:
|
|
6
|
+
*
|
|
7
|
+
* ```tsx
|
|
8
|
+
* 'use client'
|
|
9
|
+
* import dynamic from 'next/dynamic'
|
|
10
|
+
* export const FormBlock = lazyBlock(dynamic(() => import('@/components/blocks/Form').then((m) => m.FormBlock)))
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* On the site the block renders in the server's HTML and hydrates once its code loads. On the
|
|
14
|
+
* canvas a block can mount after the page (a new block, an edit), so it waits for its code in a
|
|
15
|
+
* Suspense boundary of its own and shows nothing until then.
|
|
16
|
+
*/
|
|
17
|
+
export declare function lazyBlock<P extends BlockComponentProps>(Loaded: ComponentType<P>): ComponentType<P>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// No 'use client': the site's own client modules wrap their `next/dynamic` blocks with it too.
|
|
2
|
+
import { createElement, Suspense } from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* Wraps a block component that loads its code on demand (`next/dynamic` in a client module), so
|
|
5
|
+
* the browser loads it only on pages that render the block:
|
|
6
|
+
*
|
|
7
|
+
* ```tsx
|
|
8
|
+
* 'use client'
|
|
9
|
+
* import dynamic from 'next/dynamic'
|
|
10
|
+
* export const FormBlock = lazyBlock(dynamic(() => import('@/components/blocks/Form').then((m) => m.FormBlock)))
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* On the site the block renders in the server's HTML and hydrates once its code loads. On the
|
|
14
|
+
* canvas a block can mount after the page (a new block, an edit), so it waits for its code in a
|
|
15
|
+
* Suspense boundary of its own and shows nothing until then.
|
|
16
|
+
*/
|
|
17
|
+
export function lazyBlock(Loaded) {
|
|
18
|
+
function LazyBlock(props) {
|
|
19
|
+
const element = createElement(Loaded, props);
|
|
20
|
+
return props.mode === 'canvas' ? createElement(Suspense, { fallback: null }, element) : element;
|
|
21
|
+
}
|
|
22
|
+
return LazyBlock;
|
|
23
|
+
}
|
package/dist/react/index.d.ts
CHANGED
|
@@ -1,21 +1,24 @@
|
|
|
1
|
-
export type { BlockComponentProps, BlockComponents, FetchDocs, LinkValue, PageData, RenderLayoutProps, RenderMode, ResolvedLink, ResolveLink, } from './render/types.js';
|
|
1
|
+
export type { BlockComponentProps, BlockComponents, FetchDocs, LinkComponent, LinkComponentProps, LinkValue, PageData, RenderLayoutProps, RenderMode, ResolvedLink, ResolveLink, } from './render/types.js';
|
|
2
2
|
export { defaultResolveLink, linkAttributes, resolveLinkValue, toLinkValue, type LinkAttributes, } from './render/link.js';
|
|
3
3
|
export { parseVideoUrl, type VideoEmbed } from './components/videoUrl.js';
|
|
4
4
|
export { editableImage, editableText, EDITABLE_IMAGE_ATTRIBUTE, EDITABLE_TEXT_ATTRIBUTE } from './render/editable.js';
|
|
5
5
|
export { defaultComponents } from './components/index.js';
|
|
6
|
+
export { lazyBlock } from './components/lazyBlock.js';
|
|
6
7
|
export * from './components/builtins/index.js';
|
|
7
8
|
export { BuilderStyle, RenderLayout } from './render/RenderLayout.js';
|
|
9
|
+
export { useCanvasMode, type CanvasMode } from './render/canvasMode.js';
|
|
10
|
+
export { CANVAS_CONTROL_ATTRIBUTE, REVEAL_EVENT, useCanvasReveal } from './render/reveal.js';
|
|
8
11
|
export { MotionRuntime } from './motion/MotionRuntime.js';
|
|
9
12
|
export { MotionStyle, MOTION_CSS } from './motion/style.js';
|
|
10
13
|
export { previewMotion, startMotion, type MotionOptions } from './motion/runtime.js';
|
|
11
14
|
export { fromPayloadComponent, fromPayloadComponents, PayloadSlot, type AnyPayloadComponent, type FromPayloadComponentOptions, type PayloadBlockData, type PayloadBlockProps, type PayloadBuilderProps, } from './render/payload.js';
|
|
12
|
-
export { renderOnServer, withPageData } from './render/marks.js';
|
|
15
|
+
export { renderOnServer, withClientLinks, withLinkComponent, withPageData } from './render/marks.js';
|
|
13
16
|
export { LAYOUT_ROOT_ATTRIBUTE, REGION_ATTRIBUTE, siteRegion, type RegionMark } from './render/regions.js';
|
|
14
17
|
export { LayoutOutlet } from './render/LayoutOutlet.js';
|
|
15
18
|
export type { CanvasDocumentRef, CanvasScope, CanvasServer, CanvasServerRequest, CanvasServerResponse, CanvasServerResult, } from './render/canvasServerTypes.js';
|
|
16
19
|
export { loadLayoutData, resolveLayoutData, urlResolver, type LoadLayoutOptions } from './render/resolve.js';
|
|
17
20
|
export { attachSections } from './render/sections.js';
|
|
18
|
-
export { attachListItems, LIST_PAGE_PARAMS_PROP, LIST_PAGES_PROP, listItemsOf, listQueries, loadedLists, PAGE_PARAM, pageLinks, pageOf, pageParamOf, pageWindow, RANDOM_SORT, withDateTokens, withPageParams, type ListPages, type ListQuery, type LoadedList, type ListQueryParams, } from './render/lists.js';
|
|
21
|
+
export { attachListItems, LIST_PAGE_PARAMS_PROP, LIST_PAGES_PROP, listItemsOf, listQueries, loadedLists, PAGE_PARAM, pageLinks, pageOf, pageParamOf, pageWindow, queryFiltersOf, RANDOM_SORT, withDateTokens, withPageParams, type ListPages, type ListQueriesOptions, type ListQuery, type LoadedList, type ListQueryParams, } from './render/lists.js';
|
|
19
22
|
export { fieldFor } from './components/Field.js';
|
|
20
23
|
export { renderRichText } from './components/RichText.js';
|
|
21
24
|
export { applyThemeOutput, ThemeLive } from './theme/ThemeLive.js';
|
package/dist/react/index.js
CHANGED
|
@@ -5,18 +5,21 @@ export { defaultResolveLink, linkAttributes, resolveLinkValue, toLinkValue, } fr
|
|
|
5
5
|
export { parseVideoUrl } from './components/videoUrl.js';
|
|
6
6
|
export { editableImage, editableText, EDITABLE_IMAGE_ATTRIBUTE, EDITABLE_TEXT_ATTRIBUTE } from './render/editable.js';
|
|
7
7
|
export { defaultComponents } from './components/index.js';
|
|
8
|
+
export { lazyBlock } from './components/lazyBlock.js';
|
|
8
9
|
export * from './components/builtins/index.js';
|
|
9
10
|
export { BuilderStyle, RenderLayout } from './render/RenderLayout.js';
|
|
11
|
+
export { useCanvasMode } from './render/canvasMode.js';
|
|
12
|
+
export { CANVAS_CONTROL_ATTRIBUTE, REVEAL_EVENT, useCanvasReveal } from './render/reveal.js';
|
|
10
13
|
export { MotionRuntime } from './motion/MotionRuntime.js';
|
|
11
14
|
export { MotionStyle, MOTION_CSS } from './motion/style.js';
|
|
12
15
|
export { previewMotion, startMotion } from './motion/runtime.js';
|
|
13
16
|
export { fromPayloadComponent, fromPayloadComponents, PayloadSlot, } from './render/payload.js';
|
|
14
|
-
export { renderOnServer, withPageData } from './render/marks.js';
|
|
17
|
+
export { renderOnServer, withClientLinks, withLinkComponent, withPageData } from './render/marks.js';
|
|
15
18
|
export { LAYOUT_ROOT_ATTRIBUTE, REGION_ATTRIBUTE, siteRegion } from './render/regions.js';
|
|
16
19
|
export { LayoutOutlet } from './render/LayoutOutlet.js';
|
|
17
20
|
export { loadLayoutData, resolveLayoutData, urlResolver } from './render/resolve.js';
|
|
18
21
|
export { attachSections } from './render/sections.js';
|
|
19
|
-
export { attachListItems, LIST_PAGE_PARAMS_PROP, LIST_PAGES_PROP, listItemsOf, listQueries, loadedLists, PAGE_PARAM, pageLinks, pageOf, pageParamOf, pageWindow, RANDOM_SORT, withDateTokens, withPageParams, } from './render/lists.js';
|
|
22
|
+
export { attachListItems, LIST_PAGE_PARAMS_PROP, LIST_PAGES_PROP, listItemsOf, listQueries, loadedLists, PAGE_PARAM, pageLinks, pageOf, pageParamOf, pageWindow, queryFiltersOf, RANDOM_SORT, withDateTokens, withPageParams, } from './render/lists.js';
|
|
20
23
|
export { fieldFor } from './components/Field.js';
|
|
21
24
|
export { renderRichText } from './components/RichText.js';
|
|
22
25
|
export { applyThemeOutput, ThemeLive } from './theme/ThemeLive.js';
|
|
@@ -7,15 +7,17 @@ import type { RenderLayoutProps } from './types.js';
|
|
|
7
7
|
* With `context`, bound props and Field blocks read that document. Collection lists render their
|
|
8
8
|
* `item` slot once per document (load them with `loadLayoutData`).
|
|
9
9
|
*/
|
|
10
|
-
export declare function RenderLayout({ layout, components, css, mode, blocks, resolveLink, context, pageData, relations, }: RenderLayoutProps): ReactNode;
|
|
11
|
-
export type PreviewBlockOptions = Pick<RenderLayoutProps, 'components' | 'blocks' | 'resolveLink' | 'context' | 'pageData'
|
|
10
|
+
export declare function RenderLayout({ layout, components, css, mode, blocks, resolveLink, context, pageData, relations, linkComponent, priorityImages, faqJsonLd: faqMarkup, }: RenderLayoutProps): ReactNode;
|
|
11
|
+
export type PreviewBlockOptions = Pick<RenderLayoutProps, 'components' | 'blocks' | 'resolveLink' | 'context' | 'pageData'> & {
|
|
12
|
+
/** Which canvas the block renders for. Default `'canvas'`. The component gets it as `canvasMode`. */
|
|
13
|
+
canvasMode?: 'canvas' | 'thumbnail';
|
|
14
|
+
};
|
|
12
15
|
/**
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* editable. Its slot containers get the editor's slot attributes, as on the canvas.
|
|
16
|
+
* One block rendered as the canvas would, with `slotOutlet` for each slot's children. Use
|
|
17
|
+
* `renderPreviewBlock` (`preview.tsx`): this module must not import the client `SlotOutlet`, or
|
|
18
|
+
* every site page would ship it.
|
|
17
19
|
*/
|
|
18
|
-
export declare function
|
|
20
|
+
export declare function renderBlockPreview(block: Block, options: PreviewBlockOptions, slotOutlet: (slot: string) => ReactNode): ReactNode;
|
|
19
21
|
/**
|
|
20
22
|
* The generated CSS in a `<style data-builder-css>` tag (nothing without CSS). When a page renders
|
|
21
23
|
* several layouts (header, page, footer), output it once with `compilePageCss` (`/server`) and
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Fragment, memo } from 'react';
|
|
3
|
-
import { blocksHaveMotion, COLLECTION_LIST_BLOCK, htmlAttributes, isRepeatSlot, LIST_EMPTY_SLOT, listItemContext, motionAttributes, staggersChildren, LIST_ITEM_SLOT, LIST_ITEMS_PROP, repeatRowContext, resolveBlockBindings, } from '../../core/index.js';
|
|
4
|
-
import { defaultBlocks, isLinkField, SECTION_REF_SLOT, withBuilderCssClass } from '../../blocks/index.js';
|
|
5
|
-
import { classFields } from '../../core/classes.js';
|
|
3
|
+
import { blockParts, blocksHaveMotion, COLLECTION_LIST_BLOCK, htmlAttributes, isRepeatSlot, LIST_EMPTY_SLOT, listItemContext, motionAttributes, staggersChildren, LIST_ITEM_SLOT, LIST_ITEMS_PROP, repeatRowContext, resolveBindings, resolveBlockBindings, } from '../../core/index.js';
|
|
4
|
+
import { ACCORDION_BLOCK, defaultBlocks, faqItems, faqJsonLd, isLinkField, SECTION_REF_SLOT, withBuilderCssClass } from '../../blocks/index.js';
|
|
6
5
|
import { defaultComponents } from '../components/index.js';
|
|
7
6
|
import { fieldFor } from '../components/Field.js';
|
|
8
7
|
import { richTextFor } from '../components/RichText.js';
|
|
@@ -11,9 +10,9 @@ import { defaultResolveLink, resolveLinkValue } from './link.js';
|
|
|
11
10
|
import { listItemsOf } from './lists.js';
|
|
12
11
|
import { MotionRuntime } from '../motion/MotionRuntime.js';
|
|
13
12
|
import { MotionStyle } from '../motion/style.js';
|
|
14
|
-
import { readsPageData } from './marks.js';
|
|
13
|
+
import { readsClientLinks, readsLinkComponent, readsPageData } from './marks.js';
|
|
14
|
+
import { relationsIn, RELATIONS_PROP } from './relations.js';
|
|
15
15
|
import { urlResolver } from './resolve.js';
|
|
16
|
-
import { SlotOutlet } from './SlotOutlet.js';
|
|
17
16
|
const PLACEHOLDER_STYLE = { minHeight: 48, minWidth: 48 };
|
|
18
17
|
const UNKNOWN_STYLE = {
|
|
19
18
|
padding: 8,
|
|
@@ -75,6 +74,9 @@ const showsEmpty = (block) => block.type === COLLECTION_LIST_BLOCK && listItemsO
|
|
|
75
74
|
*/
|
|
76
75
|
function renderListItems(block, ctx) {
|
|
77
76
|
const contexts = repeatContexts(block, ctx.context);
|
|
77
|
+
// `loadLayoutData` gives lists the relationship map their items' `<path>.$url` bindings need.
|
|
78
|
+
const relations = relationsIn(block.props);
|
|
79
|
+
const binding = relations ? { ...ctx.binding, relations } : ctx.binding;
|
|
78
80
|
const children = block.slots?.[LIST_ITEM_SLOT] ?? [];
|
|
79
81
|
if (contexts.length === 0) {
|
|
80
82
|
if (ctx.mode !== 'canvas')
|
|
@@ -87,6 +89,7 @@ function renderListItems(block, ctx) {
|
|
|
87
89
|
return contexts.map((context, i) => (_jsx(Fragment, { children: renderBlocks(children, {
|
|
88
90
|
...ctx,
|
|
89
91
|
context,
|
|
92
|
+
binding,
|
|
90
93
|
repeat: ctx.repeat || (ctx.mode === 'canvas' && i > 0),
|
|
91
94
|
copy: ctx.copy || i > 0,
|
|
92
95
|
}, staggersChildren(block.motion)) }, typeof context.doc.id === 'string' || typeof context.doc.id === 'number' ? context.doc.id : i)));
|
|
@@ -95,30 +98,33 @@ function renderListItems(block, ctx) {
|
|
|
95
98
|
function componentPropsOf(block, ctx) {
|
|
96
99
|
let props = block.props ?? {};
|
|
97
100
|
// List documents stay with the renderer: components get rendered items, not data.
|
|
98
|
-
if (LIST_ITEMS_PROP in props) {
|
|
99
|
-
const { [LIST_ITEMS_PROP]: _items, ...rest } = props;
|
|
101
|
+
if (LIST_ITEMS_PROP in props || RELATIONS_PROP in props) {
|
|
102
|
+
const { [LIST_ITEMS_PROP]: _items, [RELATIONS_PROP]: _relations, ...rest } = props;
|
|
100
103
|
props = rest;
|
|
101
104
|
}
|
|
102
105
|
const definition = ctx.definitions.get(block.type);
|
|
103
106
|
const fields = definition?.fields;
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
107
|
+
return fields ? mapFieldValues(props, fields, ctx.resolveLinks) : props;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* True when the block's image loads first: its `priority` prop is on, or not set while the
|
|
111
|
+
* first section still has images to give priority to (`priorityImages`). Each one counts.
|
|
112
|
+
*/
|
|
113
|
+
function takesPriority(block, ctx) {
|
|
114
|
+
const own = block.props?.priority;
|
|
115
|
+
if (!ctx.priority || ctx.priority.left <= 0 || own === false)
|
|
116
|
+
return own === true;
|
|
117
|
+
const definition = ctx.definitions.get(block.type);
|
|
118
|
+
const hasPriority = definition?.fields?.some((field) => 'name' in field && field.name === 'priority');
|
|
119
|
+
if (!hasPriority)
|
|
120
|
+
return own === true;
|
|
121
|
+
ctx.priority.left -= 1;
|
|
122
|
+
return true;
|
|
117
123
|
}
|
|
118
124
|
/**
|
|
119
125
|
* One block. `preview`: the block renders on the server for the canvas (`renderPreviewBlock`).
|
|
120
|
-
* It gets no editor attributes (the canvas adds them to its first element), and each slot is
|
|
121
|
-
* `
|
|
126
|
+
* It gets no editor attributes (the canvas adds them to its first element), and each slot is
|
|
127
|
+
* `ctx.slotOutlet`, where the canvas shows the children it rendered itself.
|
|
122
128
|
*/
|
|
123
129
|
function renderBlock(stored, ctx, preview = false, item = false) {
|
|
124
130
|
const canvas = ctx.mode === 'canvas';
|
|
@@ -128,7 +134,7 @@ function renderBlock(stored, ctx, preview = false, item = false) {
|
|
|
128
134
|
const block = ctx.context
|
|
129
135
|
? resolveBlockBindings(stored, ctx.context, ctx.definitions.get(stored.type), ctx.binding)
|
|
130
136
|
: stored;
|
|
131
|
-
//
|
|
137
|
+
// Visibility conditions that do not match hide the block (the canvas shows it dimmed).
|
|
132
138
|
if (block.hidden && !editor)
|
|
133
139
|
return null;
|
|
134
140
|
const attributes = preview
|
|
@@ -159,51 +165,65 @@ function renderBlock(stored, ctx, preview = false, item = false) {
|
|
|
159
165
|
const definition = ctx.definitions.get(block.type);
|
|
160
166
|
return (_jsx("div", { ...attributes, "data-builder-unknown": "", style: UNKNOWN_STYLE, children: definition ? `${definition.label}: no preview in the editor` : `Unknown block: ${block.type}` }, block.id));
|
|
161
167
|
}
|
|
168
|
+
// Before the slots: a block's own image comes before the images of its children.
|
|
169
|
+
const priority = takesPriority(block, ctx);
|
|
162
170
|
const slots = {};
|
|
163
|
-
const
|
|
171
|
+
const partAttributes = {};
|
|
172
|
+
const definition = ctx.definitions.get(block.type);
|
|
164
173
|
const isList = isRepeatSlot(block.type, LIST_ITEM_SLOT);
|
|
165
174
|
for (const slot of slotNamesOf(block, ctx)) {
|
|
166
175
|
if (slot === SECTION_REF_SLOT) {
|
|
167
176
|
// A live saved section: its blocks render as repeats on the canvas (the ref is what the
|
|
168
177
|
// editor selects), and its runtime slot is never a drop target.
|
|
169
178
|
slots[slot] = renderBlocks(block.slots?.[slot] ?? [], { ...ctx, repeat: ctx.repeat || canvas });
|
|
170
|
-
|
|
179
|
+
partAttributes[slot] = {};
|
|
171
180
|
continue;
|
|
172
181
|
}
|
|
173
182
|
if (preview)
|
|
174
|
-
slots[slot] =
|
|
183
|
+
slots[slot] = ctx.slotOutlet?.(slot) ?? null;
|
|
175
184
|
else if (isRepeatSlot(block.type, slot))
|
|
176
185
|
slots[slot] = renderListItems(block, ctx);
|
|
177
186
|
else if (block.type === COLLECTION_LIST_BLOCK && slot === LIST_EMPTY_SLOT)
|
|
178
187
|
slots[slot] = showsEmpty(block) ? renderSlot(block, slot, ctx) : null;
|
|
179
188
|
else
|
|
180
189
|
slots[slot] = renderSlot(block, slot, ctx);
|
|
181
|
-
|
|
182
|
-
// A slot with its own element takes its own classes (`styles: true` on the slot).
|
|
183
|
-
const slotClass = ctx.definitions.get(block.type)?.slots?.[slot]?.styles ? withBuilderCssClass(stored.slotClassName?.[slot]) : undefined;
|
|
184
|
-
if (slotClass)
|
|
185
|
-
slotAttributes[slot].className = slotClass;
|
|
190
|
+
partAttributes[slot] = editor ? { 'data-slot-owner': block.id, 'data-slot': slot } : {};
|
|
186
191
|
}
|
|
187
192
|
if (isList && !(LIST_ITEM_SLOT in slots)) {
|
|
188
193
|
slots[LIST_ITEM_SLOT] = renderListItems(block, ctx);
|
|
189
|
-
|
|
194
|
+
partAttributes[LIST_ITEM_SLOT] = {};
|
|
190
195
|
}
|
|
196
|
+
// Parts (styled slots and `parts`) carry their own classes, with the marker class.
|
|
197
|
+
for (const part of blockParts(definition)) {
|
|
198
|
+
const own = (partAttributes[part.name] ??= {});
|
|
199
|
+
const partClass = withBuilderCssClass(stored.partClassName?.[part.name]);
|
|
200
|
+
if (partClass)
|
|
201
|
+
own.className = partClass;
|
|
202
|
+
}
|
|
203
|
+
const props = componentPropsOf(block, ctx);
|
|
191
204
|
// Plain data only: a component may be a client component rendered from the server.
|
|
192
205
|
const componentProps = {
|
|
193
206
|
block: stored,
|
|
194
|
-
props:
|
|
207
|
+
props: priority && props.priority !== true ? { ...props, priority: true } : props,
|
|
195
208
|
// The marker class: the generated CSS styles only elements that have it.
|
|
196
209
|
className: withBuilderCssClass(block.className),
|
|
197
210
|
slots,
|
|
198
211
|
attributes,
|
|
199
|
-
|
|
212
|
+
partAttributes,
|
|
213
|
+
slotAttributes: partAttributes,
|
|
200
214
|
mode: ctx.mode,
|
|
201
215
|
};
|
|
202
216
|
if (ctx.pageData && readsPageData(Component))
|
|
203
217
|
componentProps.pageData = ctx.pageData;
|
|
218
|
+
if (ctx.canvasMode)
|
|
219
|
+
componentProps.canvasMode = ctx.canvasMode;
|
|
220
|
+
if (ctx.linkComponent && readsLinkComponent(Component))
|
|
221
|
+
componentProps.linkComponent = ctx.linkComponent;
|
|
222
|
+
if (ctx.linkComponent && readsClientLinks(Component))
|
|
223
|
+
componentProps.clientLinks = true;
|
|
204
224
|
return _jsx(Component, { ...componentProps }, block.id);
|
|
205
225
|
}
|
|
206
|
-
function createContext(mode, components, blocks, resolveLink, context, pageData, relations = null) {
|
|
226
|
+
function createContext(mode, components, blocks, resolveLink, context, pageData, relations = null, linkComponent = null) {
|
|
207
227
|
return {
|
|
208
228
|
mode,
|
|
209
229
|
// The built-in rich text and Field blocks get the resolver through a closure, never through props.
|
|
@@ -215,6 +235,9 @@ function createContext(mode, components, blocks, resolveLink, context, pageData,
|
|
|
215
235
|
repeat: false,
|
|
216
236
|
copy: false,
|
|
217
237
|
pageData,
|
|
238
|
+
// The editor keeps plain links: a client-side router link would navigate the canvas.
|
|
239
|
+
linkComponent: mode === 'site' ? linkComponent : null,
|
|
240
|
+
priority: null,
|
|
218
241
|
};
|
|
219
242
|
}
|
|
220
243
|
/** The canvas's last render context and the inputs it was made from. */
|
|
@@ -223,9 +246,9 @@ let canvasContext = null;
|
|
|
223
246
|
* The render context. On the canvas it stays the same object while its inputs stay the same, so
|
|
224
247
|
* memoized blocks can skip. The site builds a fresh one per render (nothing is kept between requests).
|
|
225
248
|
*/
|
|
226
|
-
function contextFor(mode, components, blocks, resolveLink, context, pageData, relations) {
|
|
249
|
+
function contextFor(mode, components, blocks, resolveLink, context, pageData, relations, linkComponent) {
|
|
227
250
|
if (mode !== 'canvas')
|
|
228
|
-
return createContext(mode, components, blocks, resolveLink, context, pageData, relations);
|
|
251
|
+
return createContext(mode, components, blocks, resolveLink, context, pageData, relations, linkComponent);
|
|
229
252
|
const inputs = [components, blocks, resolveLink, context, pageData, relations];
|
|
230
253
|
if (canvasContext && canvasContext.inputs.every((input, i) => input === inputs[i]))
|
|
231
254
|
return canvasContext.ctx;
|
|
@@ -235,25 +258,53 @@ function contextFor(mode, components, blocks, resolveLink, context, pageData, re
|
|
|
235
258
|
function linkVisitor(resolveLink) {
|
|
236
259
|
return (field, value) => (isLinkField(field) ? resolveLinkValue(value, resolveLink) : value);
|
|
237
260
|
}
|
|
261
|
+
/**
|
|
262
|
+
* The site's top-level blocks. The first shown one (the first section) gives its first
|
|
263
|
+
* `priorityImages` images priority: it is the part of the page a visitor sees first.
|
|
264
|
+
*/
|
|
265
|
+
function renderSections(blocks, ctx, priorityImages) {
|
|
266
|
+
const first = blocks.findIndex((block) => !block.hidden);
|
|
267
|
+
return blocks.map((block, i) => renderBlock(block, i === first ? { ...ctx, priority: { left: priorityImages } } : ctx));
|
|
268
|
+
}
|
|
238
269
|
/**
|
|
239
270
|
* Renders a layout. No hooks, so it works as a server component and inside the client canvas.
|
|
240
271
|
* Block components get plain data only (see `BlockComponentProps`): links are resolved here.
|
|
241
272
|
* With `context`, bound props and Field blocks read that document. Collection lists render their
|
|
242
273
|
* `item` slot once per document (load them with `loadLayoutData`).
|
|
243
274
|
*/
|
|
244
|
-
export function RenderLayout({ layout, components, css, mode = 'site', blocks, resolveLink = defaultResolveLink, context, pageData, relations, }) {
|
|
245
|
-
const ctx = contextFor(mode, components, blocks, resolveLink, context ?? null, pageData ?? null, relations ?? null);
|
|
275
|
+
export function RenderLayout({ layout, components, css, mode = 'site', blocks, resolveLink = defaultResolveLink, context, pageData, relations, linkComponent, priorityImages = 1, faqJsonLd: faqMarkup = true, }) {
|
|
276
|
+
const ctx = contextFor(mode, components, blocks, resolveLink, context ?? null, pageData ?? null, relations ?? null, linkComponent ?? null);
|
|
246
277
|
const motion = mode === 'site' && blocksHaveMotion(layout.blocks);
|
|
247
|
-
return (_jsxs(_Fragment, { children: [_jsx(BuilderStyle, { css: css }), motion && _jsx(MotionStyle, { blocks: layout.blocks }), renderBlocks(layout.blocks, ctx), motion && _jsx(MotionRuntime, {})] }));
|
|
278
|
+
return (_jsxs(_Fragment, { children: [_jsx(BuilderStyle, { css: css }), motion && _jsx(MotionStyle, { blocks: layout.blocks }), mode === 'site' && priorityImages > 0 ? renderSections(layout.blocks, ctx, priorityImages) : renderBlocks(layout.blocks, ctx), motion && _jsx(MotionRuntime, {}), mode === 'site' && faqMarkup && _jsx(FaqJsonLd, { layout: layout, definitions: [...ctx.definitions.values()], context: ctx.context, binding: ctx.binding })] }));
|
|
279
|
+
}
|
|
280
|
+
/** True when a block in the list (children included) is an accordion with `faqSchema` on. */
|
|
281
|
+
function hasFaqAccordion(list) {
|
|
282
|
+
return list.some((block) => (block.type === ACCORDION_BLOCK && block.props?.faqSchema === true) || Object.values(block.slots ?? {}).some(hasFaqAccordion));
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* FAQPage JSON-LD for the accordions with `faqSchema` on: one `<script>` per layout, nothing when
|
|
286
|
+
* no accordion opts in or no item has a question and an answer. Bindings resolve against the
|
|
287
|
+
* layout's document first, so a layout that skipped `loadLayoutData` still gets the values.
|
|
288
|
+
*/
|
|
289
|
+
function FaqJsonLd({ layout, definitions, context, binding }) {
|
|
290
|
+
if (!hasFaqAccordion(layout.blocks))
|
|
291
|
+
return null;
|
|
292
|
+
const resolved = context ? resolveBindings(layout, context, definitions, binding) : layout;
|
|
293
|
+
const data = faqJsonLd(faqItems(resolved, definitions));
|
|
294
|
+
if (!data)
|
|
295
|
+
return null;
|
|
296
|
+
// `<` escaped, so a "</script>" in an answer cannot end the element.
|
|
297
|
+
return _jsx("script", { type: "application/ld+json", dangerouslySetInnerHTML: { __html: JSON.stringify(data).replace(/</g, '\\u003c') } });
|
|
248
298
|
}
|
|
249
299
|
/**
|
|
250
|
-
*
|
|
251
|
-
*
|
|
252
|
-
*
|
|
253
|
-
* editable. Its slot containers get the editor's slot attributes, as on the canvas.
|
|
300
|
+
* One block rendered as the canvas would, with `slotOutlet` for each slot's children. Use
|
|
301
|
+
* `renderPreviewBlock` (`preview.tsx`): this module must not import the client `SlotOutlet`, or
|
|
302
|
+
* every site page would ship it.
|
|
254
303
|
*/
|
|
255
|
-
export function
|
|
304
|
+
export function renderBlockPreview(block, options, slotOutlet) {
|
|
256
305
|
const ctx = createContext('canvas', options.components, options.blocks, options.resolveLink ?? defaultResolveLink, options.context ?? null, options.pageData ?? null);
|
|
306
|
+
ctx.canvasMode = options.canvasMode ?? 'canvas';
|
|
307
|
+
ctx.slotOutlet = slotOutlet;
|
|
257
308
|
return renderBlock(block, ctx, true);
|
|
258
309
|
}
|
|
259
310
|
/**
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* - `'site'`: the live website (also any page without the canvas around it).
|
|
3
|
+
* - `'canvas'`: the editor's canvas iframe.
|
|
4
|
+
* - `'thumbnail'`: the hidden canvas that takes the pictures of the section library (`?mode=thumbnail`).
|
|
5
|
+
*/
|
|
6
|
+
export type CanvasMode = 'site' | 'canvas' | 'thumbnail';
|
|
7
|
+
/** `BuilderCanvas` provides it. Without a provider (the site) the mode is `'site'`. */
|
|
8
|
+
export declare const CanvasModeContext: import("react").Context<CanvasMode>;
|
|
9
|
+
/**
|
|
10
|
+
* Where the block renders: `'site'`, `'canvas'` or `'thumbnail'`. For client components. A server
|
|
11
|
+
* component gets the same value as its `canvasMode` prop (see `BlockComponentProps`).
|
|
12
|
+
*/
|
|
13
|
+
export declare function useCanvasMode(): CanvasMode;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
// Where a block renders: on the site, on the editor's canvas, or in the hidden renderer of the
|
|
3
|
+
// section thumbnails. Custom block components read it with `useCanvasMode()`.
|
|
4
|
+
import { createContext, useContext } from 'react';
|
|
5
|
+
/** `BuilderCanvas` provides it. Without a provider (the site) the mode is `'site'`. */
|
|
6
|
+
export const CanvasModeContext = createContext('site');
|
|
7
|
+
/**
|
|
8
|
+
* Where the block renders: `'site'`, `'canvas'` or `'thumbnail'`. For client components. A server
|
|
9
|
+
* component gets the same value as its `canvasMode` prop (see `BlockComponentProps`).
|
|
10
|
+
*/
|
|
11
|
+
export function useCanvasMode() {
|
|
12
|
+
return useContext(CanvasModeContext);
|
|
13
|
+
}
|
|
@@ -8,7 +8,7 @@ import { defaultComponents } from '../components/index.js';
|
|
|
8
8
|
import { renderCanvasFrame } from './canvasFrame.js';
|
|
9
9
|
import { isRecord } from './fields.js';
|
|
10
10
|
import { defaultResolveLink } from './link.js';
|
|
11
|
-
import { renderPreviewBlock } from './
|
|
11
|
+
import { renderPreviewBlock } from './preview.js';
|
|
12
12
|
import { localeArgs } from './locale.js';
|
|
13
13
|
import { loadLayoutData } from './resolve.js';
|
|
14
14
|
/** At most this many blocks per request. */
|
|
@@ -21,6 +21,7 @@ function scopeOf(value) {
|
|
|
21
21
|
document: isDocumentRef(scope.document) ? scope.document : null,
|
|
22
22
|
context: isDocumentRef(scope.context) ? scope.context : null,
|
|
23
23
|
locale: typeof scope.locale === 'string' && scope.locale ? scope.locale : null,
|
|
24
|
+
mode: scope.mode === 'thumbnail' ? 'thumbnail' : 'canvas',
|
|
24
25
|
};
|
|
25
26
|
}
|
|
26
27
|
/** The scope's locale, when the Payload config has it. Unknown codes and sites without localization give null. */
|
|
@@ -127,7 +128,7 @@ export function createCanvasServer(options) {
|
|
|
127
128
|
try {
|
|
128
129
|
// One load for every block: one `find` per collection.
|
|
129
130
|
const layout = normalizeLayout({ version: 1, blocks: items.map((item) => item.block) });
|
|
130
|
-
loaded = (await loadLayoutData(layout, blocks, payload, { draft: true, context, resolveLink, user, ...localeOptions })).blocks;
|
|
131
|
+
loaded = (await loadLayoutData(layout, blocks, payload, { draft: true, context, resolveLink, user, includeHidden: true, ...localeOptions })).blocks;
|
|
131
132
|
}
|
|
132
133
|
catch (error) {
|
|
133
134
|
for (const item of items)
|
|
@@ -146,7 +147,7 @@ export function createCanvasServer(options) {
|
|
|
146
147
|
results[item.key] = { error: `No component for "${block.type}". Add it to the components of createCanvasServer.` };
|
|
147
148
|
continue;
|
|
148
149
|
}
|
|
149
|
-
results[item.key] = { node: renderPreviewBlock(block, { components, blocks, resolveLink, context, pageData }) };
|
|
150
|
+
results[item.key] = { node: renderPreviewBlock(block, { components, blocks, resolveLink, context, pageData, canvasMode: scope.mode }) };
|
|
150
151
|
}
|
|
151
152
|
return { kind: 'blocks', results };
|
|
152
153
|
};
|
|
@@ -17,6 +17,11 @@ export type CanvasScope = {
|
|
|
17
17
|
* site loads them in the page's locale. Missing or null: the default locale.
|
|
18
18
|
*/
|
|
19
19
|
locale?: string | null;
|
|
20
|
+
/**
|
|
21
|
+
* Which canvas asks: the editor (`'canvas'`, the default) or the hidden renderer of the section
|
|
22
|
+
* thumbnails (`'thumbnail'`). Server blocks get it as their `canvasMode` prop.
|
|
23
|
+
*/
|
|
24
|
+
mode?: 'canvas' | 'thumbnail';
|
|
20
25
|
};
|
|
21
26
|
export type CanvasServerRequest =
|
|
22
27
|
/** The page data for this scope (the `pageData` loader). */
|