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,27 @@
|
|
|
1
|
+
import { type DataField } from './fields.js';
|
|
2
|
+
import { type IndexedBlock } from './tree.js';
|
|
3
|
+
import type { BlockDefinition, Layout } from './types.js';
|
|
4
|
+
/** `admin.custom` key that marks a block prop as content (`true`) or design (`false`). */
|
|
5
|
+
export declare const CONTENT_FIELD_MARKER = "builderContent";
|
|
6
|
+
/** The prefix of every content mode error, so people know why the change was refused. */
|
|
7
|
+
export declare const CONTENT_MODE_MESSAGE = "In content mode you can change only text, images and links.";
|
|
8
|
+
/**
|
|
9
|
+
* True when a block prop is content: text, textarea, rich text, upload, email and link groups
|
|
10
|
+
* (`linkField()`), and groups, rows and arrays made only of content. `admin.custom.builderContent`
|
|
11
|
+
* overrides the type (`false` for a text field that holds a setting, such as image sizes).
|
|
12
|
+
*/
|
|
13
|
+
export declare function isContentField(field: unknown): boolean;
|
|
14
|
+
/** The block's props that content mode shows and edits (top level, in order). */
|
|
15
|
+
export declare function contentFields(definition: Pick<BlockDefinition, 'fields'> | undefined): DataField[];
|
|
16
|
+
/** True when the block has a prop that content mode edits. */
|
|
17
|
+
export declare function hasContentFields(definition: Pick<BlockDefinition, 'fields'> | undefined): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* True when content mode may duplicate, delete and reorder the block: its parent block lets
|
|
20
|
+
* editors manage its items (`editableItems`).
|
|
21
|
+
*/
|
|
22
|
+
export declare function isEditableItem(layout: Layout, id: string, index?: Map<string, IndexedBlock>): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Why `after` is not a content-only change of `before`, or null when it is. Both layouts in
|
|
25
|
+
* canonical form. `before` is the layout as stored (or as the session holds it).
|
|
26
|
+
*/
|
|
27
|
+
export declare function contentModeProblem(before: Layout, after: Layout, blocks: readonly BlockDefinition[]): string | null;
|
|
Binary file
|
|
@@ -21,3 +21,14 @@ export declare function canvasDropTarget(layout: Layout, blocks: BlockDefinition
|
|
|
21
21
|
* Below the last row: appended to the root list.
|
|
22
22
|
*/
|
|
23
23
|
export declare function outlineDropTarget(layout: Layout, blocks: BlockDefinition[], rows: OutlineRow[], p: Point, source: DragSource, indent: number): DropTarget | null;
|
|
24
|
+
/** A slot that takes the dragged block. `ownerId` null is the root list. */
|
|
25
|
+
export type AcceptingSlot = {
|
|
26
|
+
ownerId: string | null;
|
|
27
|
+
slot: string;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Every slot the dragged block may drop into, by the same rules as the drop targets (`allow`,
|
|
31
|
+
* `disallow`, `max`, `parents`). Slots of the dragged block and its descendants are left out.
|
|
32
|
+
* The root list comes first when it accepts the block; then the slots in layout order.
|
|
33
|
+
*/
|
|
34
|
+
export declare function acceptingSlots(layout: Layout, blocks: BlockDefinition[], source: DragSource): AcceptingSlot[];
|
package/dist/core/dropTarget.js
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
// The functions then fall through to the next valid option (see each function).
|
|
9
9
|
// The root list accepts every type without a `parents` rule (a list item goes only in a list).
|
|
10
10
|
import { getBlockDefinition, placementError, slotNames } from './blocks.js';
|
|
11
|
+
import { reachableAt } from './layers.js';
|
|
11
12
|
import { DEFAULT_SLOT, indexLayout, subtreeIds } from './tree.js';
|
|
12
13
|
const LINE = 4;
|
|
13
14
|
const EDGE_ZONE = 12;
|
|
@@ -101,7 +102,7 @@ function deepestEntry(index, measurement, p, excluded) {
|
|
|
101
102
|
}
|
|
102
103
|
/** The deepest block whose rect contains the point. Ties go to the smaller rect. */
|
|
103
104
|
export function deepestBlockAt(layout, measurement, p, excluded) {
|
|
104
|
-
return deepestEntry(indexLayout(layout), measurement, p, excluded ?? new Set())?.block.id ?? null;
|
|
105
|
+
return deepestEntry(indexLayout(layout), reachableAt(measurement, p), p, excluded ?? new Set())?.block.id ?? null;
|
|
105
106
|
}
|
|
106
107
|
/**
|
|
107
108
|
* Where a dragged block lands on the canvas. Respects slot `allow` rules from `blocks`.
|
|
@@ -114,6 +115,8 @@ export function deepestBlockAt(layout, measurement, p, excluded) {
|
|
|
114
115
|
* 5. Over no block: into the root list.
|
|
115
116
|
*/
|
|
116
117
|
export function canvasDropTarget(layout, blocks, measurement, p, source) {
|
|
118
|
+
// Over an open popup only its blocks count (see `reachableAt`).
|
|
119
|
+
measurement = reachableAt(measurement, p);
|
|
117
120
|
const { index, type, excluded, slotsOf, accepts, parentOf } = context(layout, blocks, source);
|
|
118
121
|
if (type === null)
|
|
119
122
|
return null;
|
|
@@ -268,3 +271,23 @@ export function outlineDropTarget(layout, blocks, rows, p, source, indent) {
|
|
|
268
271
|
const hasChildren = names.some((name) => countOf(name) > 0);
|
|
269
272
|
return (hasChildren ? firstChild() : beside('after')) ?? inside();
|
|
270
273
|
}
|
|
274
|
+
/**
|
|
275
|
+
* Every slot the dragged block may drop into, by the same rules as the drop targets (`allow`,
|
|
276
|
+
* `disallow`, `max`, `parents`). Slots of the dragged block and its descendants are left out.
|
|
277
|
+
* The root list comes first when it accepts the block; then the slots in layout order.
|
|
278
|
+
*/
|
|
279
|
+
export function acceptingSlots(layout, blocks, source) {
|
|
280
|
+
const { index, type, excluded, slotsOf, accepts } = context(layout, blocks, source);
|
|
281
|
+
if (type === null)
|
|
282
|
+
return [];
|
|
283
|
+
const result = accepts(null, DEFAULT_SLOT) ? [{ ownerId: null, slot: DEFAULT_SLOT }] : [];
|
|
284
|
+
for (const entry of index.values()) {
|
|
285
|
+
if (excluded.has(entry.block.id))
|
|
286
|
+
continue;
|
|
287
|
+
for (const slot of slotsOf(entry)) {
|
|
288
|
+
if (accepts(entry.block.id, slot))
|
|
289
|
+
result.push({ ownerId: entry.block.id, slot });
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
return result;
|
|
293
|
+
}
|
package/dist/core/fields.d.ts
CHANGED
|
@@ -55,6 +55,11 @@ export declare function hasStaticDefault(field: {
|
|
|
55
55
|
}): boolean;
|
|
56
56
|
/** Allowed values of a select or radio field. Options are strings or `{ label, value }`. */
|
|
57
57
|
export declare function optionValues(field: LooseField): string[];
|
|
58
|
+
/** Options of a select or radio field as `{ label, value }`. A string option is its own label. */
|
|
59
|
+
export declare function optionList(field: LooseField): Array<{
|
|
60
|
+
label: string;
|
|
61
|
+
value: string;
|
|
62
|
+
}>;
|
|
58
63
|
/** Blocks of a Payload `blocks` field. Block references (plain slugs) are skipped. */
|
|
59
64
|
export declare function fieldBlocks(field: LooseField): LooseBlock[];
|
|
60
65
|
/** A label or description as text. Localized objects use "en" or the first string. */
|
package/dist/core/fields.js
CHANGED
|
@@ -56,6 +56,17 @@ export function optionValues(field) {
|
|
|
56
56
|
}
|
|
57
57
|
return values;
|
|
58
58
|
}
|
|
59
|
+
/** Options of a select or radio field as `{ label, value }`. A string option is its own label. */
|
|
60
|
+
export function optionList(field) {
|
|
61
|
+
const out = [];
|
|
62
|
+
for (const option of field.options ?? []) {
|
|
63
|
+
if (typeof option === 'string')
|
|
64
|
+
out.push({ label: option, value: option });
|
|
65
|
+
else if (isPlainObject(option) && typeof option.value === 'string')
|
|
66
|
+
out.push({ label: textOf(option.label) ?? option.value, value: option.value });
|
|
67
|
+
}
|
|
68
|
+
return out;
|
|
69
|
+
}
|
|
59
70
|
/** Blocks of a Payload `blocks` field. Block references (plain slugs) are skipped. */
|
|
60
71
|
export function fieldBlocks(field) {
|
|
61
72
|
return (field.blocks ?? []).filter((b) => isPlainObject(b) && typeof b.slug === 'string' && Array.isArray(b.fields));
|
package/dist/core/headings.d.ts
CHANGED
|
@@ -7,15 +7,18 @@ export declare function headingId(text: string): string;
|
|
|
7
7
|
export type RichTextHeading = {
|
|
8
8
|
/** The heading's id: `headingId` of its text, with "-2", "-3", … for repeated texts. */
|
|
9
9
|
id: string;
|
|
10
|
+
/** The heading's plain text, with each run of whitespace as one space. */
|
|
10
11
|
text: string;
|
|
11
12
|
/** 1 to 6, from the tag (`h2` is 2). */
|
|
12
13
|
level: number;
|
|
13
14
|
/** The Lexical heading node, as stored. */
|
|
14
15
|
node: Record<string, unknown>;
|
|
15
16
|
};
|
|
17
|
+
/** The plain text of a Lexical node and its children, with each run of whitespace as one space. */
|
|
18
|
+
export declare function lexicalText(node: unknown): string;
|
|
16
19
|
/**
|
|
17
|
-
* The headings of a Lexical rich text value, in document order, each with a unique id. The
|
|
18
|
-
*
|
|
20
|
+
* The headings of a Lexical rich text value, in document order, each with a unique id. The richText
|
|
21
|
+
* and field blocks put the same ids on the headings they render. A heading without letters or
|
|
19
22
|
* digits gets "section".
|
|
20
23
|
*/
|
|
21
24
|
export declare function richTextHeadings(value: unknown): RichTextHeading[];
|
package/dist/core/headings.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
// Ids for rich text headings, so a table of contents can link to them (`#id`).
|
|
1
|
+
// Ids for rich text headings, so a table of contents can link to them (`#id`). The richText and
|
|
2
|
+
// field blocks put these ids on the headings they render; the tableOfContents block links to them.
|
|
3
|
+
// Pure: no React.
|
|
2
4
|
/**
|
|
3
5
|
* An id from a heading's text: accents removed, lowercase, every run of other characters than
|
|
4
6
|
* letters and digits (any script) turned into "-", no "-" at the ends. "Über uns & Preise" gives
|
|
@@ -13,14 +15,20 @@ export function headingId(text) {
|
|
|
13
15
|
.replace(/^-+|-+$/g, '');
|
|
14
16
|
}
|
|
15
17
|
const childrenOf = (node) => Array.isArray(node.children) ? node.children.filter((c) => typeof c === 'object' && c !== null) : [];
|
|
16
|
-
function
|
|
18
|
+
function rawText(node) {
|
|
17
19
|
if (typeof node.text === 'string')
|
|
18
20
|
return node.text;
|
|
19
|
-
return childrenOf(node).map(
|
|
21
|
+
return childrenOf(node).map(rawText).join('');
|
|
22
|
+
}
|
|
23
|
+
/** The plain text of a Lexical node and its children, with each run of whitespace as one space. */
|
|
24
|
+
export function lexicalText(node) {
|
|
25
|
+
if (typeof node !== 'object' || node === null)
|
|
26
|
+
return '';
|
|
27
|
+
return rawText(node).replace(/\s+/g, ' ').trim();
|
|
20
28
|
}
|
|
21
29
|
/**
|
|
22
|
-
* The headings of a Lexical rich text value, in document order, each with a unique id. The
|
|
23
|
-
*
|
|
30
|
+
* The headings of a Lexical rich text value, in document order, each with a unique id. The richText
|
|
31
|
+
* and field blocks put the same ids on the headings they render. A heading without letters or
|
|
24
32
|
* digits gets "section".
|
|
25
33
|
*/
|
|
26
34
|
export function richTextHeadings(value) {
|
|
@@ -31,7 +39,7 @@ export function richTextHeadings(value) {
|
|
|
31
39
|
const used = new Map();
|
|
32
40
|
const visit = (node) => {
|
|
33
41
|
if (node.type === 'heading') {
|
|
34
|
-
const text =
|
|
42
|
+
const text = lexicalText(node);
|
|
35
43
|
const base = headingId(text) || 'section';
|
|
36
44
|
const seen = (used.get(base) ?? 0) + 1;
|
|
37
45
|
used.set(base, seen);
|
package/dist/core/index.d.ts
CHANGED
|
@@ -3,8 +3,9 @@ export { checkAttrs, htmlAttributes, htmlIdClash, htmlIdProblem, htmlIdsOf, patc
|
|
|
3
3
|
export { createId } from './ids.js';
|
|
4
4
|
export { findBlock, findLocation, walkBlocks, isSelfOrDescendant, normalizeLayout, type BlockLocation } from './tree.js';
|
|
5
5
|
export { applyOperation, applyOperations, type ApplyOptions } from './operations.js';
|
|
6
|
-
export {
|
|
7
|
-
export {
|
|
6
|
+
export { layerAt, reachableAt } from './layers.js';
|
|
7
|
+
export { acceptingSlots, type AcceptingSlot, deepestBlockAt, canvasDropTarget, outlineDropTarget } from './dropTarget.js';
|
|
8
|
+
export { blockParts, type BlockPart, collectClasses, defaultPartClassNames } from './classes.js';
|
|
8
9
|
export { headingId, richTextHeadings, type RichTextHeading } from './headings.js';
|
|
9
10
|
export { blockJsonSchema, layoutJsonSchema } from './schema.js';
|
|
10
11
|
export { validateLayout, isBlockingError, isLayoutWarning, PUBLISH_ONLY_CODES, type LayoutError, type LayoutErrorCode, type ValidateOptions } from './validate.js';
|
|
@@ -12,8 +13,12 @@ export { blockInLocale, createLocaleView, fallbackChain, hasLocaleValues, hasLoc
|
|
|
12
13
|
export * from './styles.js';
|
|
13
14
|
export * from './motion.js';
|
|
14
15
|
export * from './bindings.js';
|
|
16
|
+
export * from './visibility.js';
|
|
17
|
+
export * from './components.js';
|
|
15
18
|
export { TEXT_LIST_BLOCK, TEXT_LIST_ITEM_BLOCK, TEXT_LIST_SLOT, joinListItem, splitListItem, type ListItemEdit } from './textList.js';
|
|
16
|
-
export { blockName, defineBlock, defineSection, type SectionBlockInput, type SectionInput, fitsParent, getBlockDefinition, placementError, sectionsWithDefaultClassNames, sectionsWithVariants, slotAccepts, slotAcceptsAt, slotNames, starterSlots, withDefaultClassNames, withInlineBlocks } from './blocks.js';
|
|
19
|
+
export { blockName, defineBlock, defineSection, type SectionBlockInput, type SectionInput, fitsParent, getBlockDefinition, placementError, checkSectionVariants, sectionsWithDefaultClassNames, sectionsWithVariants, slotAccepts, slotAcceptsAt, slotNames, starterSlots, withDefaultClasses, withDefaultClassNames, withInlineBlocks } from './blocks.js';
|
|
20
|
+
export { carryContent, DEFAULT_VARIANT_LABEL, findSection, findSectionVersion, hasVariants, listedVariants, sectionVersion, sectionVersions, switchSectionVariant, versionIndex, withoutSectionOrigin, withSectionOrigin, type SectionVersion, type VariantSwitch, } from './sections.js';
|
|
21
|
+
export { checkSectionOrigin } from './sectionOrigin.js';
|
|
17
22
|
export { FORMATS, formatProblem, isPlayableVideoUrl, parseVideoUrl, videoUrlProblem, type FormatCheck, type VideoEmbed, type VideoOptions } from './formats.js';
|
|
18
23
|
export { describeLayoutErrors, summarizeProblems, type LayoutIssue } from './issues.js';
|
|
19
24
|
export { conditionFromFunction, conditionMet, readCondition, type BuilderCondition } from './conditions.js';
|
package/dist/core/index.js
CHANGED
|
@@ -5,8 +5,9 @@ export { checkAttrs, htmlAttributes, htmlIdClash, htmlIdProblem, htmlIdsOf, patc
|
|
|
5
5
|
export { createId } from './ids.js';
|
|
6
6
|
export { findBlock, findLocation, walkBlocks, isSelfOrDescendant, normalizeLayout } from './tree.js';
|
|
7
7
|
export { applyOperation, applyOperations } from './operations.js';
|
|
8
|
-
export {
|
|
9
|
-
export {
|
|
8
|
+
export { layerAt, reachableAt } from './layers.js';
|
|
9
|
+
export { acceptingSlots, deepestBlockAt, canvasDropTarget, outlineDropTarget } from './dropTarget.js';
|
|
10
|
+
export { blockParts, collectClasses, defaultPartClassNames } from './classes.js';
|
|
10
11
|
export { headingId, richTextHeadings } from './headings.js';
|
|
11
12
|
export { blockJsonSchema, layoutJsonSchema } from './schema.js';
|
|
12
13
|
export { validateLayout, isBlockingError, isLayoutWarning, PUBLISH_ONLY_CODES } from './validate.js';
|
|
@@ -14,8 +15,12 @@ export { blockInLocale, createLocaleView, fallbackChain, hasLocaleValues, hasLoc
|
|
|
14
15
|
export * from './styles.js';
|
|
15
16
|
export * from './motion.js';
|
|
16
17
|
export * from './bindings.js';
|
|
18
|
+
export * from './visibility.js';
|
|
19
|
+
export * from './components.js';
|
|
17
20
|
export { TEXT_LIST_BLOCK, TEXT_LIST_ITEM_BLOCK, TEXT_LIST_SLOT, joinListItem, splitListItem } from './textList.js';
|
|
18
|
-
export { blockName, defineBlock, defineSection, fitsParent, getBlockDefinition, placementError, sectionsWithDefaultClassNames, sectionsWithVariants, slotAccepts, slotAcceptsAt, slotNames, starterSlots, withDefaultClassNames, withInlineBlocks } from './blocks.js';
|
|
21
|
+
export { blockName, defineBlock, defineSection, fitsParent, getBlockDefinition, placementError, checkSectionVariants, sectionsWithDefaultClassNames, sectionsWithVariants, slotAccepts, slotAcceptsAt, slotNames, starterSlots, withDefaultClasses, withDefaultClassNames, withInlineBlocks } from './blocks.js';
|
|
22
|
+
export { carryContent, DEFAULT_VARIANT_LABEL, findSection, findSectionVersion, hasVariants, listedVariants, sectionVersion, sectionVersions, switchSectionVariant, versionIndex, withoutSectionOrigin, withSectionOrigin, } from './sections.js';
|
|
23
|
+
export { checkSectionOrigin } from './sectionOrigin.js';
|
|
19
24
|
export { FORMATS, formatProblem, isPlayableVideoUrl, parseVideoUrl, videoUrlProblem } from './formats.js';
|
|
20
25
|
export { describeLayoutErrors, summarizeProblems } from './issues.js';
|
|
21
26
|
export { conditionFromFunction, conditionMet, readCondition } from './conditions.js';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { CanvasMeasurement, Point } from './types.js';
|
|
2
|
+
/** The index of the top layer whose box holds the point, or -1. Later layers show above earlier ones. */
|
|
3
|
+
export declare function layerAt(measurement: CanvasMeasurement, p: Point): number;
|
|
4
|
+
/**
|
|
5
|
+
* The blocks and slots the pointer at `p` can reach. Over a layer: only those in it, and its
|
|
6
|
+
* owner block with the layer's box (a click on the box's padding selects the popup). Elsewhere:
|
|
7
|
+
* only those on the page. Without layers: the measurement itself.
|
|
8
|
+
*/
|
|
9
|
+
export declare function reachableAt(measurement: CanvasMeasurement, p: Point): CanvasMeasurement;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// Boxes over the page on the canvas (an open popup). The page's blocks lie under such a box, and
|
|
2
|
+
// the box's own blocks may be less deep in the layout than the page's. So over a box, the pointer
|
|
3
|
+
// must reach only the box's blocks. No DOM, no React.
|
|
4
|
+
const contains = (r, p) => p.x >= r.x && p.x <= r.x + r.width && p.y >= r.y && p.y <= r.y + r.height;
|
|
5
|
+
/** The index of the top layer whose box holds the point, or -1. Later layers show above earlier ones. */
|
|
6
|
+
export function layerAt(measurement, p) {
|
|
7
|
+
const layers = measurement.layers ?? [];
|
|
8
|
+
for (let i = layers.length - 1; i >= 0; i--)
|
|
9
|
+
if (contains(layers[i].rect, p))
|
|
10
|
+
return i;
|
|
11
|
+
return -1;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The blocks and slots the pointer at `p` can reach. Over a layer: only those in it, and its
|
|
15
|
+
* owner block with the layer's box (a click on the box's padding selects the popup). Elsewhere:
|
|
16
|
+
* only those on the page. Without layers: the measurement itself.
|
|
17
|
+
*/
|
|
18
|
+
export function reachableAt(measurement, p) {
|
|
19
|
+
const layers = measurement.layers;
|
|
20
|
+
if (!layers?.length)
|
|
21
|
+
return measurement;
|
|
22
|
+
const index = layerAt(measurement, p);
|
|
23
|
+
const inLayer = (item) => (index < 0 ? item.layer === undefined : item.layer === index);
|
|
24
|
+
const blocks = measurement.blocks.filter(inLayer);
|
|
25
|
+
const owner = index < 0 ? null : layers[index].ownerId;
|
|
26
|
+
if (owner && !blocks.some((b) => b.id === owner))
|
|
27
|
+
blocks.unshift({ id: owner, rect: layers[index].rect, layer: index });
|
|
28
|
+
return { ...measurement, blocks, slots: measurement.slots.filter(inLayer) };
|
|
29
|
+
}
|
|
@@ -11,3 +11,9 @@ export type ApplyOptions = {
|
|
|
11
11
|
export declare function applyOperation(layout: Layout, op: Operation, options?: ApplyOptions): ApplyResult;
|
|
12
12
|
/** Applies operations in order. Fails as a whole if any fails. `inverse` undoes all of them. */
|
|
13
13
|
export declare function applyOperations(layout: Layout, ops: Operation[], options?: ApplyOptions): ApplyResult;
|
|
14
|
+
/**
|
|
15
|
+
* The class list after `update`: `base` (the new `className`, else the old one), minus the classes
|
|
16
|
+
* in `drop`, plus the classes in `add` that are not there yet (at the end). Without `add` and
|
|
17
|
+
* `drop`, `base` as it is. An empty result is null (no className).
|
|
18
|
+
*/
|
|
19
|
+
export declare function patchClassName(base: string | null | undefined, add?: string, drop?: string): string | null;
|
package/dist/core/operations.js
CHANGED
|
@@ -8,6 +8,8 @@ import { checkAttrs, htmlIdClash, htmlIdsOf, patchAttrs, withoutTakenHtmlIds } f
|
|
|
8
8
|
import { placementError, slotFullError } from './blocks.js';
|
|
9
9
|
import { createId } from './ids.js';
|
|
10
10
|
import { checkMotion, motionInverse, patchMotion } from './motion.js';
|
|
11
|
+
import { checkSectionOrigin } from './sectionOrigin.js';
|
|
12
|
+
import { checkVisibility } from './visibility.js';
|
|
11
13
|
import { DEFAULT_SLOT, indexLayout, isPlainObject, subtreeIds } from './tree.js';
|
|
12
14
|
const fail = (error) => ({ ok: false, error });
|
|
13
15
|
/** Applies one operation. Never mutates the input. Returns the inverse operations for undo. */
|
|
@@ -182,14 +184,20 @@ function update(layout, op) {
|
|
|
182
184
|
delete next.locales;
|
|
183
185
|
}
|
|
184
186
|
}
|
|
185
|
-
if (op.className !== undefined) {
|
|
186
|
-
if (op.className !== null && typeof op.className !== 'string')
|
|
187
|
+
if (op.className !== undefined || op.addClassName !== undefined || op.removeClassName !== undefined) {
|
|
188
|
+
if (op.className !== undefined && op.className !== null && typeof op.className !== 'string')
|
|
187
189
|
return fail('`className` must be a string or null');
|
|
190
|
+
if (op.addClassName !== undefined && typeof op.addClassName !== 'string')
|
|
191
|
+
return fail('`addClassName` must be a string of classes separated by spaces');
|
|
192
|
+
if (op.removeClassName !== undefined && typeof op.removeClassName !== 'string')
|
|
193
|
+
return fail('`removeClassName` must be a string of classes separated by spaces');
|
|
194
|
+
// The inverse sets the whole old list, so undo restores the exact string (order and spaces).
|
|
188
195
|
inverse.className = before.className ?? null;
|
|
189
|
-
|
|
196
|
+
const className = patchClassName(op.className === undefined ? before.className : op.className, op.addClassName, op.removeClassName);
|
|
197
|
+
if (className === null)
|
|
190
198
|
delete next.className;
|
|
191
199
|
else
|
|
192
|
-
next.className =
|
|
200
|
+
next.className = className;
|
|
193
201
|
}
|
|
194
202
|
if (op.hidden !== undefined) {
|
|
195
203
|
if (typeof op.hidden !== 'boolean')
|
|
@@ -200,6 +208,15 @@ function update(layout, op) {
|
|
|
200
208
|
else
|
|
201
209
|
delete next.hidden;
|
|
202
210
|
}
|
|
211
|
+
if (op.editableItems !== undefined) {
|
|
212
|
+
if (typeof op.editableItems !== 'boolean')
|
|
213
|
+
return fail('`editableItems` must be a boolean');
|
|
214
|
+
inverse.editableItems = before.editableItems === true;
|
|
215
|
+
if (op.editableItems)
|
|
216
|
+
next.editableItems = true;
|
|
217
|
+
else
|
|
218
|
+
delete next.editableItems;
|
|
219
|
+
}
|
|
203
220
|
if (op.label !== undefined) {
|
|
204
221
|
if (op.label !== null && typeof op.label !== 'string')
|
|
205
222
|
return fail('`label` must be a string or null');
|
|
@@ -231,6 +248,16 @@ function update(layout, op) {
|
|
|
231
248
|
else
|
|
232
249
|
delete next.bindings;
|
|
233
250
|
}
|
|
251
|
+
if (op.visibility !== undefined) {
|
|
252
|
+
const visibility = checkVisibility(op.visibility);
|
|
253
|
+
if (typeof visibility === 'string')
|
|
254
|
+
return fail(visibility);
|
|
255
|
+
inverse.visibility = before.visibility ? structuredClone(before.visibility) : null;
|
|
256
|
+
if (visibility)
|
|
257
|
+
next.visibility = visibility;
|
|
258
|
+
else
|
|
259
|
+
delete next.visibility;
|
|
260
|
+
}
|
|
234
261
|
if (op.motion !== undefined) {
|
|
235
262
|
const motion = patchMotion(before.motion, op.motion);
|
|
236
263
|
if (typeof motion === 'string')
|
|
@@ -241,26 +268,26 @@ function update(layout, op) {
|
|
|
241
268
|
else
|
|
242
269
|
delete next.motion;
|
|
243
270
|
}
|
|
244
|
-
if (op.
|
|
245
|
-
if (!isPlainObject(op.
|
|
246
|
-
return fail('`
|
|
247
|
-
const old = before.
|
|
271
|
+
if (op.partClassName !== undefined) {
|
|
272
|
+
if (!isPlainObject(op.partClassName))
|
|
273
|
+
return fail('`partClassName` must be an object of part name -> classes');
|
|
274
|
+
const old = before.partClassName ?? {};
|
|
248
275
|
const merged = { ...old };
|
|
249
276
|
const inv = {};
|
|
250
|
-
for (const [
|
|
277
|
+
for (const [part, value] of Object.entries(op.partClassName)) {
|
|
251
278
|
if (value !== null && typeof value !== 'string')
|
|
252
|
-
return fail(`
|
|
253
|
-
setOwn(inv,
|
|
279
|
+
return fail(`partClassName.${part} must be a string or null`);
|
|
280
|
+
setOwn(inv, part, Object.hasOwn(old, part) ? old[part] : null);
|
|
254
281
|
if (value?.trim())
|
|
255
|
-
setOwn(merged,
|
|
282
|
+
setOwn(merged, part, value);
|
|
256
283
|
else
|
|
257
|
-
delete merged[
|
|
284
|
+
delete merged[part];
|
|
258
285
|
}
|
|
259
|
-
inverse.
|
|
286
|
+
inverse.partClassName = inv;
|
|
260
287
|
if (Object.keys(merged).length > 0)
|
|
261
|
-
next.
|
|
288
|
+
next.partClassName = merged;
|
|
262
289
|
else
|
|
263
|
-
delete next.
|
|
290
|
+
delete next.partClassName;
|
|
264
291
|
}
|
|
265
292
|
if (op.attrs !== undefined) {
|
|
266
293
|
const patched = patchAttrs(before.attrs, op.attrs);
|
|
@@ -282,6 +309,22 @@ function update(layout, op) {
|
|
|
282
309
|
// ---------------------------------------------------------------------------
|
|
283
310
|
// Helpers
|
|
284
311
|
// ---------------------------------------------------------------------------
|
|
312
|
+
/**
|
|
313
|
+
* The class list after `update`: `base` (the new `className`, else the old one), minus the classes
|
|
314
|
+
* in `drop`, plus the classes in `add` that are not there yet (at the end). Without `add` and
|
|
315
|
+
* `drop`, `base` as it is. An empty result is null (no className).
|
|
316
|
+
*/
|
|
317
|
+
export function patchClassName(base, add, drop) {
|
|
318
|
+
if (add === undefined && drop === undefined)
|
|
319
|
+
return base ?? null;
|
|
320
|
+
const removed = new Set(splitClasses(drop));
|
|
321
|
+
const tokens = splitClasses(base).filter((token) => !removed.has(token));
|
|
322
|
+
for (const token of splitClasses(add))
|
|
323
|
+
if (!tokens.includes(token))
|
|
324
|
+
tokens.push(token);
|
|
325
|
+
return tokens.length > 0 ? tokens.join(' ') : null;
|
|
326
|
+
}
|
|
327
|
+
const splitClasses = (value) => (value ?? '').split(/\s+/).filter(Boolean);
|
|
285
328
|
function ok(layout, inverse) {
|
|
286
329
|
return { ok: true, layout, inverse };
|
|
287
330
|
}
|
|
@@ -383,8 +426,10 @@ function cloneWithNewIds(block, id, used) {
|
|
|
383
426
|
clone.bindings = { ...block.bindings };
|
|
384
427
|
if (block.attrs)
|
|
385
428
|
clone.attrs = { ...block.attrs };
|
|
386
|
-
if (block.
|
|
387
|
-
clone.
|
|
429
|
+
if (block.visibility)
|
|
430
|
+
clone.visibility = structuredClone(block.visibility);
|
|
431
|
+
if (block.partClassName)
|
|
432
|
+
clone.partClassName = { ...block.partClassName };
|
|
388
433
|
if (block.slots) {
|
|
389
434
|
clone.slots = Object.fromEntries(Object.entries(block.slots).map(([name, children]) => [
|
|
390
435
|
name,
|
|
@@ -407,7 +452,7 @@ function freshId(used) {
|
|
|
407
452
|
function checkBlock(value, used, path = 'block') {
|
|
408
453
|
if (!isPlainObject(value))
|
|
409
454
|
return `${path} must be an object`;
|
|
410
|
-
const { id, type, props, className, slots, bindings, hidden, label, locales, motion, attrs,
|
|
455
|
+
const { id, type, props, className, slots, bindings, hidden, label, locales, motion, attrs, visibility, partClassName, section, editableItems } = value;
|
|
411
456
|
if (typeof id !== 'string' || id === '')
|
|
412
457
|
return `${path}.id must be a non-empty string`;
|
|
413
458
|
if (used.has(id))
|
|
@@ -461,6 +506,12 @@ function checkBlock(value, used, path = 'block') {
|
|
|
461
506
|
if (hidden)
|
|
462
507
|
block.hidden = true;
|
|
463
508
|
}
|
|
509
|
+
if (editableItems !== undefined) {
|
|
510
|
+
if (typeof editableItems !== 'boolean')
|
|
511
|
+
return `${path}.editableItems must be a boolean`;
|
|
512
|
+
if (editableItems)
|
|
513
|
+
block.editableItems = true;
|
|
514
|
+
}
|
|
464
515
|
if (label !== undefined && label !== null) {
|
|
465
516
|
if (typeof label !== 'string')
|
|
466
517
|
return `${path}.label must be a string`;
|
|
@@ -488,18 +539,28 @@ function checkBlock(value, used, path = 'block') {
|
|
|
488
539
|
if (checked)
|
|
489
540
|
block.motion = checked;
|
|
490
541
|
}
|
|
491
|
-
if (
|
|
492
|
-
if (!isPlainObject(
|
|
493
|
-
return `${path}.
|
|
542
|
+
if (partClassName !== undefined) {
|
|
543
|
+
if (!isPlainObject(partClassName) || !Object.values(partClassName).every((v) => typeof v === 'string')) {
|
|
544
|
+
return `${path}.partClassName must be an object of part name -> classes`;
|
|
494
545
|
}
|
|
495
|
-
const kept = Object.fromEntries(Object.entries(
|
|
546
|
+
const kept = Object.fromEntries(Object.entries(partClassName).filter(([, v]) => v.trim()));
|
|
496
547
|
if (Object.keys(kept).length > 0)
|
|
497
|
-
block.
|
|
548
|
+
block.partClassName = kept;
|
|
498
549
|
}
|
|
499
550
|
const checkedAttrs = checkAttrs(attrs);
|
|
500
551
|
if (typeof checkedAttrs === 'string')
|
|
501
552
|
return `${path}.${checkedAttrs}`;
|
|
502
553
|
if (checkedAttrs)
|
|
503
554
|
block.attrs = checkedAttrs;
|
|
555
|
+
const checkedVisibility = checkVisibility(visibility);
|
|
556
|
+
if (typeof checkedVisibility === 'string')
|
|
557
|
+
return `${path}.${checkedVisibility}`;
|
|
558
|
+
if (checkedVisibility)
|
|
559
|
+
block.visibility = checkedVisibility;
|
|
560
|
+
const origin = checkSectionOrigin(section);
|
|
561
|
+
if (typeof origin === 'string')
|
|
562
|
+
return `${path}.${origin}`;
|
|
563
|
+
if (origin)
|
|
564
|
+
block.section = origin;
|
|
504
565
|
return block;
|
|
505
566
|
}
|
|
@@ -105,7 +105,7 @@ export function payloadBlocksProblems(layout, storage) {
|
|
|
105
105
|
}
|
|
106
106
|
if (allowed && !allowed.includes(block.type))
|
|
107
107
|
problems.push(`${name} blocks are not allowed here.`);
|
|
108
|
-
if (block.className || block.
|
|
108
|
+
if (block.className || block.partClassName)
|
|
109
109
|
problems.push(`${name}: this field cannot store Tailwind classes.`);
|
|
110
110
|
if (block.motion)
|
|
111
111
|
problems.push(`${name}: this field cannot store animations.`);
|
|
@@ -115,6 +115,10 @@ export function payloadBlocksProblems(layout, storage) {
|
|
|
115
115
|
problems.push(`${name}: this field cannot store bindings.`);
|
|
116
116
|
if (block.hidden)
|
|
117
117
|
problems.push(`${name}: this field cannot store hidden blocks.`);
|
|
118
|
+
if (block.editableItems)
|
|
119
|
+
problems.push(`${name}: this field cannot store "Editors can add, remove and reorder its items".`);
|
|
120
|
+
if (block.visibility)
|
|
121
|
+
problems.push(`${name}: this field cannot store visibility conditions.`);
|
|
118
122
|
if (block.locales)
|
|
119
123
|
problems.push(`${name}: translations are edited in Payload's editor for this field.`);
|
|
120
124
|
for (const [slot, children] of Object.entries(block.slots ?? {})) {
|
package/dist/core/references.js
CHANGED
|
@@ -47,6 +47,31 @@ function visitLexical(node, add) {
|
|
|
47
47
|
for (const child of node.children)
|
|
48
48
|
visitLexical(child, add);
|
|
49
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* JSON props (a component copy's values): `{ relationTo, value }` pairs (images, a link's
|
|
52
|
+
* document) and rich text, at any depth up to 8.
|
|
53
|
+
*/
|
|
54
|
+
function visitJson(value, add, depth) {
|
|
55
|
+
if (depth > 8)
|
|
56
|
+
return;
|
|
57
|
+
if (Array.isArray(value)) {
|
|
58
|
+
for (const item of value)
|
|
59
|
+
visitJson(item, add, depth + 1);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (!isPlainObject(value))
|
|
63
|
+
return;
|
|
64
|
+
if (typeof value.relationTo === 'string' && 'value' in value) {
|
|
65
|
+
add(value.relationTo, value.value);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
if (isPlainObject(value.root)) {
|
|
69
|
+
visitLexical(value.root, add);
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
for (const child of Object.values(value))
|
|
73
|
+
visitJson(child, add, depth + 1);
|
|
74
|
+
}
|
|
50
75
|
/** The link type the renderer uses: a group without `type` is a URL link unless only a document is set. */
|
|
51
76
|
function linkType(value) {
|
|
52
77
|
if (value.type === 'url' || value.type === 'reference')
|
|
@@ -85,6 +110,9 @@ function visitFields(fields, props, add) {
|
|
|
85
110
|
if (isPlainObject(row))
|
|
86
111
|
visitFields(field.fields, row, add);
|
|
87
112
|
break;
|
|
113
|
+
case 'json':
|
|
114
|
+
visitJson(value, add, 0);
|
|
115
|
+
break;
|
|
88
116
|
case 'blocks': {
|
|
89
117
|
if (!Array.isArray(value))
|
|
90
118
|
break;
|
package/dist/core/schema.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
// JSON Schema (draft 2020-12) generated from block definitions and their Payload field configs.
|
|
2
2
|
// AI tools read these schemas to write layouts, so they must match what validateLayout accepts.
|
|
3
3
|
import { slotAccepts } from './blocks.js';
|
|
4
|
+
import { blockParts } from './classes.js';
|
|
4
5
|
import { dataFields, fieldBlocks, optionValues, textOf } from './fields.js';
|
|
5
6
|
import { isPlainObject } from './tree.js';
|
|
6
7
|
import { motionJsonSchema } from './motion.js';
|
|
8
|
+
import { visibilityJsonSchema } from './visibility.js';
|
|
7
9
|
const DRAFT = 'https://json-schema.org/draft/2020-12/schema';
|
|
8
10
|
const ID = { type: ['string', 'number'] };
|
|
9
11
|
/** `$defs` key of the shared motion schema. Block types never start with "$". */
|
|
@@ -119,21 +121,26 @@ function blockSchema(def, all) {
|
|
|
119
121
|
additionalProperties: false,
|
|
120
122
|
};
|
|
121
123
|
}
|
|
122
|
-
const
|
|
123
|
-
if (
|
|
124
|
-
properties.
|
|
124
|
+
const parts = blockParts(def);
|
|
125
|
+
if (parts.length > 0) {
|
|
126
|
+
properties.partClassName = {
|
|
125
127
|
type: 'object',
|
|
126
|
-
description: `Tailwind classes of
|
|
127
|
-
properties: Object.fromEntries(
|
|
128
|
+
description: `Tailwind classes of the block's inner elements, by part name. Only these parts take classes: ${parts.map((part) => part.name).join(', ')}.`,
|
|
129
|
+
properties: Object.fromEntries(parts.map((part) => [part.name, { type: 'string', description: part.slot ? `${part.label} (the slot's own element)` : part.label }])),
|
|
128
130
|
additionalProperties: false,
|
|
129
131
|
};
|
|
130
132
|
}
|
|
131
133
|
properties.bindings = {
|
|
132
134
|
type: 'object',
|
|
133
|
-
description: 'Prop path ->
|
|
135
|
+
description: 'Prop path -> binding: a field path ("title"), a fallback chain ("subtitle|title"), formatters ("price|currency:EUR") or a template ("Read {{title}}"). Bound props take the document\'s value at render time.',
|
|
134
136
|
additionalProperties: { type: 'string' },
|
|
135
137
|
};
|
|
136
138
|
properties.hidden = { type: 'boolean', description: 'Hidden blocks stay in the data but do not render.' };
|
|
139
|
+
properties.editableItems = {
|
|
140
|
+
type: 'boolean',
|
|
141
|
+
description: 'Content mode: true lets editors without design rights duplicate, delete and reorder the direct children. Stored only when true.',
|
|
142
|
+
};
|
|
143
|
+
properties.visibility = visibilityJsonSchema();
|
|
137
144
|
properties.motion = { $ref: `#/$defs/${encodeURIComponent(MOTION_DEF)}` };
|
|
138
145
|
properties.attrs = {
|
|
139
146
|
type: 'object',
|
|
@@ -150,6 +157,13 @@ function blockSchema(def, all) {
|
|
|
150
157
|
type: 'string',
|
|
151
158
|
description: 'Optional name for editors, shown in the outline (e.g. "Hero", "Pricing"). Never rendered on the site.',
|
|
152
159
|
};
|
|
160
|
+
properties.section = {
|
|
161
|
+
type: 'object',
|
|
162
|
+
description: 'Set by insertSection on the root block of a ready-made section: the section id and its variant. Keep it as it is; never rendered.',
|
|
163
|
+
properties: { id: { type: 'string', minLength: 1 }, variant: { type: 'string' } },
|
|
164
|
+
required: ['id'],
|
|
165
|
+
additionalProperties: false,
|
|
166
|
+
};
|
|
153
167
|
const required = ['id', 'type'];
|
|
154
168
|
if (dataFields(def.fields).some((f) => f.required))
|
|
155
169
|
required.push('props');
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { SectionOrigin } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* `value` as a canonical `SectionOrigin` (trimmed, no empty `variant`). Undefined when it is left
|
|
4
|
+
* out (undefined or null), an error message when its shape is wrong.
|
|
5
|
+
*/
|
|
6
|
+
export declare function checkSectionOrigin(value: unknown): SectionOrigin | undefined | string;
|