payload-canvas 0.4.0 → 0.5.1
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 +626 -154
- 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 -1
- package/dist/blocks/index.js +2 -1
- 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
package/dist/ai/tools.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// and saves as usual. Inputs are validated here, because eager input streaming skips the API's
|
|
4
4
|
// own validation.
|
|
5
5
|
import { isRichText, richTextToPlain, withoutBoundRequired } from '../core/bindings.js';
|
|
6
|
+
import { contentModeProblem } from '../core/contentMode.js';
|
|
6
7
|
import { createId } from '../core/ids.js';
|
|
7
8
|
import { MOTION_KINDS, MOTION_SPECS } from '../core/motion.js';
|
|
8
9
|
import { blockJsonSchema } from '../core/schema.js';
|
|
@@ -13,8 +14,8 @@ import { IMAGE_ASPECT_RATIOS } from './images/shared.js';
|
|
|
13
14
|
import { IMAGES_NOT_CONFIGURED } from './images/service.js';
|
|
14
15
|
import { validateLayout } from '../core/validate.js';
|
|
15
16
|
import { resolveOperations, splitLayoutErrors } from '../live/apply.js';
|
|
16
|
-
import { isRootParentId, sectionInsertOps } from '../mcp/shared.js';
|
|
17
|
-
import {
|
|
17
|
+
import { componentListing, isRootParentId, missingContent, sectionInsertOps, sectionToInsert, variantsListing } from '../mcp/shared.js';
|
|
18
|
+
import { findSectionVersion } from '../core/sections.js';
|
|
18
19
|
// ---------------------------------------------------------------------------
|
|
19
20
|
// Working copy
|
|
20
21
|
// ---------------------------------------------------------------------------
|
|
@@ -34,9 +35,12 @@ export class Workspace {
|
|
|
34
35
|
#localization;
|
|
35
36
|
/** The locale the assistant reads and writes. Null without localization. */
|
|
36
37
|
locale;
|
|
38
|
+
/** The user has no design rights: only content changes apply (core/contentMode.ts). */
|
|
39
|
+
contentOnly;
|
|
37
40
|
constructor(layout, blocks, options = {}) {
|
|
38
41
|
this.layout = layout;
|
|
39
42
|
this.#blocks = blocks;
|
|
43
|
+
this.contentOnly = options.contentOnly === true;
|
|
40
44
|
this.#localization = options.localization ?? null;
|
|
41
45
|
this.locale = this.#localization ? (options.locale ?? this.#localization.defaultLocale) : null;
|
|
42
46
|
this.#baseline = new Set(this.#errors(layout).blocking.map(errorKey));
|
|
@@ -68,6 +72,10 @@ export class Workspace {
|
|
|
68
72
|
const resolved = resolveOperations(this.layout, prepared, this.#blocks, this.#localization);
|
|
69
73
|
if (!resolved.ok)
|
|
70
74
|
return { ok: false, error: resolved.error };
|
|
75
|
+
// Content mode: the user's own rights. The live session checks the same rule again.
|
|
76
|
+
const design = this.contentOnly ? contentModeProblem(this.layout, resolved.layout, this.#blocks) : null;
|
|
77
|
+
if (design)
|
|
78
|
+
return { ok: false, error: design };
|
|
71
79
|
const { blocking, warnings } = this.#errors(resolved.layout);
|
|
72
80
|
const added = blocking.filter((e) => !this.#baseline.has(errorKey(e)));
|
|
73
81
|
if (added.length > 0) {
|
|
@@ -155,10 +163,11 @@ const MOTION_TEXT = 'Animations: { enter?, hover?, press?, scroll?, loop? }, eac
|
|
|
155
163
|
MOTION_KINDS.map((kind) => `${kind} ${MOTION_SPECS[kind].presets.join('|')}`).join('; ') +
|
|
156
164
|
'. Example: { "enter": { "preset": "fade-up", "stagger": 80 } }.';
|
|
157
165
|
const ATTRS_TEXT = 'HTML attributes { id?, ariaLabel?, ariaHidden? }: id is an anchor for "#id" links, unique in the layout (letters, digits, - and _, starting with a letter); ariaLabel is the name screen readers read; ariaHidden true hides a decorative block from screen readers.';
|
|
158
|
-
const
|
|
166
|
+
const VISIBILITY_TEXT = 'Visibility conditions (templates and list or repeat items only; on a normal page they do nothing) { match?: "all" | "any", conditions: [{ field, operator, value?, valueField?, count? }] }: the block shows only when they match the document. Operators: is_set, is_empty, equals, not_equals, in, not_in (list value), greater_than, greater_than_equal, less_than, less_than_equal, like, contains. valueField compares with another field instead of value. count: true compares the number of items. With match "any", an entry may be a group { all: [conditions] } ("or" of "and" groups). Example: { "conditions": [{ "field": "price", "operator": "greater_than", "value": 100 }] }.';
|
|
167
|
+
const PART_CLASS_TEXT = 'Tailwind classes of the block\'s inner elements, by part name, e.g. { "empty": "col-span-full" }. Only the "parts" listed in the block catalog take them.';
|
|
159
168
|
const BLOCK_SCHEMA = {
|
|
160
169
|
type: 'object',
|
|
161
|
-
description: 'A block: { id?, type, props?, className?, slots?, bindings?, hidden?, label?, motion?, attrs?,
|
|
170
|
+
description: 'A block: { id?, type, props?, className?, slots?, bindings?, visibility?, hidden?, label?, motion?, attrs?, partClassName? }. Children in slots have the same shape. `label` names the block for editors (e.g. "Hero"); give each top-level section one. Ids you leave out are generated; the tool result lists them.',
|
|
162
171
|
properties: {
|
|
163
172
|
id: { type: 'string' },
|
|
164
173
|
type: { type: 'string' },
|
|
@@ -167,10 +176,12 @@ const BLOCK_SCHEMA = {
|
|
|
167
176
|
slots: { type: 'object', description: 'Slot name -> array of child blocks.' },
|
|
168
177
|
bindings: { type: 'object' },
|
|
169
178
|
hidden: { type: 'boolean' },
|
|
179
|
+
editableItems: { type: 'boolean', description: 'Content mode: editors without design rights may duplicate, delete and reorder the direct children.' },
|
|
170
180
|
label: { type: 'string', description: 'Name for editors (outline). Never rendered.' },
|
|
171
181
|
motion: { type: 'object', description: MOTION_TEXT },
|
|
172
182
|
attrs: { type: 'object', description: ATTRS_TEXT },
|
|
173
|
-
|
|
183
|
+
visibility: { type: 'object', description: VISIBILITY_TEXT },
|
|
184
|
+
partClassName: { type: 'object', description: PART_CLASS_TEXT },
|
|
174
185
|
},
|
|
175
186
|
required: ['type'],
|
|
176
187
|
};
|
|
@@ -199,7 +210,10 @@ const FLAT_OPERATIONS_SCHEMA = {
|
|
|
199
210
|
props: { type: 'object', description: 'update: props to merge.' },
|
|
200
211
|
unsetProps: { type: 'array', items: { type: 'string' } },
|
|
201
212
|
className: { type: 'string', description: 'update: the FULL class list (replaces all classes).' },
|
|
213
|
+
addClassName: { type: 'string', description: 'update: classes to add, space-separated. Other classes stay.' },
|
|
214
|
+
removeClassName: { type: 'string', description: 'update: classes to remove, space-separated (exact match). Other classes stay.' },
|
|
202
215
|
hidden: { type: 'boolean' },
|
|
216
|
+
editableItems: { type: 'boolean', description: 'Content mode: editors without design rights may duplicate, delete and reorder the direct children.' },
|
|
203
217
|
bindings: { type: 'object' },
|
|
204
218
|
label: { type: ['string', 'null'], description: 'update: name for editors (outline). null removes it.' },
|
|
205
219
|
motion: {
|
|
@@ -207,7 +221,8 @@ const FLAT_OPERATIONS_SCHEMA = {
|
|
|
207
221
|
description: `insert (inside block) and update: ${MOTION_TEXT} update merges per kind: a kind replaces that kind, null removes it, kinds left out stay. null removes all.`,
|
|
208
222
|
},
|
|
209
223
|
attrs: { type: ['object', 'null'], description: `update: ${ATTRS_TEXT} A key replaces that key, null removes it; attrs: null removes all.` },
|
|
210
|
-
|
|
224
|
+
visibility: { type: ['object', 'null'], description: `update: ${VISIBILITY_TEXT} Replaces all conditions; null removes them.` },
|
|
225
|
+
partClassName: { type: 'object', description: `update: ${PART_CLASS_TEXT} Merges per part; null removes a part's classes.` },
|
|
211
226
|
newId: { type: 'string' },
|
|
212
227
|
},
|
|
213
228
|
required: ['type'],
|
|
@@ -265,9 +280,31 @@ export function toolDefinitions(env) {
|
|
|
265
280
|
sectionId: saved
|
|
266
281
|
? { type: 'string', description: 'A section catalog id, a saved section id ("saved:<id>") or a section name.' }
|
|
267
282
|
: { type: 'string', enum: sectionIds, description: 'Section id from the section catalog.' },
|
|
283
|
+
variant: { type: ['string', 'null'], description: 'A variant id the catalog lists under the section (e.g. "split"), or null for the section itself.' },
|
|
268
284
|
parentId: { type: ['string', 'null'], description: 'Parent block id, or null for the page root.' },
|
|
269
285
|
slot: { type: ['string', 'null'], description: 'Slot of the parent, or null for "children".' },
|
|
270
286
|
index: { type: ['integer', 'null'], description: 'Final index in the target list, or null to append.' },
|
|
287
|
+
...(saved
|
|
288
|
+
? {
|
|
289
|
+
values: {
|
|
290
|
+
type: ['array', 'null'],
|
|
291
|
+
description: 'Components only (component: true in listSections): values for this copy. Text and rich text as text, an image as its upload id, a link as a URL, visible as true or false. Left out: the default.',
|
|
292
|
+
items: {
|
|
293
|
+
type: 'object',
|
|
294
|
+
properties: {
|
|
295
|
+
name: { type: 'string', description: 'Property name from listSections.' },
|
|
296
|
+
value: { type: ['string', 'number', 'boolean', 'null'] },
|
|
297
|
+
},
|
|
298
|
+
required: ['name', 'value'],
|
|
299
|
+
additionalProperties: false,
|
|
300
|
+
},
|
|
301
|
+
},
|
|
302
|
+
linked: {
|
|
303
|
+
type: ['boolean', 'null'],
|
|
304
|
+
description: 'Saved sections only. true: a copy that stays in sync (default for components). false: plain blocks. null: the default.',
|
|
305
|
+
},
|
|
306
|
+
}
|
|
307
|
+
: {}),
|
|
271
308
|
},
|
|
272
309
|
required: ['sectionId'],
|
|
273
310
|
additionalProperties: false,
|
|
@@ -286,7 +323,7 @@ export function toolDefinitions(env) {
|
|
|
286
323
|
'- move { id, to }: move a block (with children).',
|
|
287
324
|
'- remove { id }: delete a block and its children.',
|
|
288
325
|
'- duplicate { id, newId? }: copy a block right after itself.',
|
|
289
|
-
'- update { id, props?, unsetProps?, className?, hidden?, bindings?, label?, motion?, attrs?,
|
|
326
|
+
'- update { id, props?, unsetProps?, className?, addClassName?, removeClassName?, hidden?, bindings?, visibility?, label?, motion?, attrs?, partClassName? }: props and bindings are merged (shallow); className REPLACES all classes, so send the full list; null removes it; addClassName and removeClassName (space-separated) add or remove single classes and keep the rest; a null binding removes that binding; visibility replaces all conditions (null removes them); label renames the block for editors (null removes it); motion merges per kind (a kind you send replaces that kind, null removes a kind, null alone removes all animations); attrs (HTML id, ariaLabel, ariaHidden) merges per key, null removes a key; partClassName merges per slot (null removes).',
|
|
290
327
|
'Position: { parentId (null = page root), slot? (default "children"), index (final index in the target list) }.',
|
|
291
328
|
'On success the result lists the changed ids and any warnings (e.g. a required prop is empty). On error nothing changes and the error names the failing operation; fix it and call again.',
|
|
292
329
|
'Example (ids come from the layout; block types and props from the block catalog): change a heading, then add a text block after it in the same section:',
|
|
@@ -312,7 +349,10 @@ export function toolDefinitions(env) {
|
|
|
312
349
|
props: { type: 'object', description: 'Merged into the existing props.' },
|
|
313
350
|
unsetProps: { type: 'array', items: { type: 'string' } },
|
|
314
351
|
className: { type: ['string', 'null'], description: 'Replaces ALL classes.' },
|
|
352
|
+
addClassName: { type: 'string', description: 'Classes to add, space-separated. Other classes stay.' },
|
|
353
|
+
removeClassName: { type: 'string', description: 'Classes to remove, space-separated (exact match). Other classes stay.' },
|
|
315
354
|
hidden: { type: 'boolean' },
|
|
355
|
+
editableItems: { type: 'boolean' },
|
|
316
356
|
bindings: { type: 'object', description: 'Prop path -> document field path; null removes.' },
|
|
317
357
|
label: { type: ['string', 'null'], description: 'Name for editors. null removes it.' },
|
|
318
358
|
motion: {
|
|
@@ -320,7 +360,8 @@ export function toolDefinitions(env) {
|
|
|
320
360
|
description: `${MOTION_TEXT} Merges per kind: a kind replaces that kind, null removes it, kinds left out stay. null removes all.`,
|
|
321
361
|
},
|
|
322
362
|
attrs: { type: ['object', 'null'], description: `${ATTRS_TEXT} A key replaces that key, null removes it. null removes all.` },
|
|
323
|
-
|
|
363
|
+
visibility: { type: ['object', 'null'], description: `${VISIBILITY_TEXT} Replaces all conditions; null removes them.` },
|
|
364
|
+
partClassName: { type: 'object', description: `${PART_CLASS_TEXT} Merges per part; null removes a part's classes.` },
|
|
324
365
|
},
|
|
325
366
|
required: ['type', 'id'],
|
|
326
367
|
},
|
|
@@ -594,9 +635,12 @@ hasBlock) {
|
|
|
594
635
|
});
|
|
595
636
|
}
|
|
596
637
|
if (op.type === 'update') {
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
638
|
+
for (const key of ['className', 'addClassName', 'removeClassName']) {
|
|
639
|
+
const classes = op[key];
|
|
640
|
+
if (!Array.isArray(classes))
|
|
641
|
+
continue;
|
|
642
|
+
op[key] = classes.filter((c) => typeof c === 'string').join(' ');
|
|
643
|
+
fix(`"${key}" is one string of classes separated by spaces.`);
|
|
600
644
|
}
|
|
601
645
|
if (typeof op.props === 'string')
|
|
602
646
|
op.props = parseJson(op.props);
|
|
@@ -634,17 +678,27 @@ export async function runTool(name, rawInput, workspace, env) {
|
|
|
634
678
|
id: s.id,
|
|
635
679
|
label: s.label,
|
|
636
680
|
...(s.savedId !== undefined ? { saved: true } : {}),
|
|
637
|
-
...(s.variantOf ? { variantOf: s.variantOf } : {}),
|
|
638
681
|
...(s.category ? { category: s.category } : {}),
|
|
639
682
|
...(input.full === true ? { blocks: s.blocks } : {}),
|
|
683
|
+
...variantsListing(s, input.full === true),
|
|
684
|
+
...componentListing(s, env.blocks),
|
|
640
685
|
})), `Looked at ${list.length} section${list.length === 1 ? '' : 's'}`);
|
|
641
686
|
}
|
|
642
687
|
case 'insertSection': {
|
|
643
|
-
const
|
|
644
|
-
|
|
688
|
+
const variant = typeof input.variant === 'string' ? input.variant : undefined;
|
|
689
|
+
const found = typeof input.sectionId === 'string' ? findSectionVersion(env.sections, input.sectionId, variant) : undefined;
|
|
690
|
+
if (typeof found === 'string')
|
|
691
|
+
return fail(found, 'Section not inserted');
|
|
692
|
+
if (!found) {
|
|
645
693
|
const known = env.sections.map((s) => (s.savedId !== undefined ? `${s.id} (${s.label})` : s.id));
|
|
646
694
|
return fail(`Unknown section "${String(input.sectionId)}"`, 'Section not inserted', { known });
|
|
647
695
|
}
|
|
696
|
+
const values = Array.isArray(input.values)
|
|
697
|
+
? Object.fromEntries(input.values.flatMap((entry) => (isPlainObject(entry) && typeof entry.name === 'string' ? [[entry.name, entry.value]] : [])))
|
|
698
|
+
: undefined;
|
|
699
|
+
const section = sectionToInsert(found, env.blocks, { values, linked: typeof input.linked === 'boolean' ? input.linked : null });
|
|
700
|
+
if (typeof section === 'string')
|
|
701
|
+
return fail(section, 'Section not inserted');
|
|
648
702
|
const parentId = optionalString(input, 'parentId');
|
|
649
703
|
const slot = optionalString(input, 'slot');
|
|
650
704
|
if (parentId instanceof Error || slot instanceof Error)
|
|
@@ -663,7 +717,17 @@ export async function runTool(name, rawInput, workspace, env) {
|
|
|
663
717
|
if (!result.ok)
|
|
664
718
|
return fail(result.error, `Could not insert ${section.label}`, result.errors);
|
|
665
719
|
const inserted = result.ops.flatMap((op) => (op.type === 'insert' ? [op.block] : []));
|
|
666
|
-
|
|
720
|
+
const needsContent = missingContent(inserted, env.blocks);
|
|
721
|
+
return ok({
|
|
722
|
+
ok: true,
|
|
723
|
+
section: section.id,
|
|
724
|
+
...(section.blocks[0]?.section?.variant ? { variant: section.blocks[0].section.variant } : {}),
|
|
725
|
+
inserted,
|
|
726
|
+
...(needsContent.length > 0 ? { needsContent, needsContentHint: env.generateImage
|
|
727
|
+
? 'Empty images render nothing on the site: fill them with generateImage (blockId places the image). Tell the user about other empty fields, such as a form to pick.'
|
|
728
|
+
: 'Empty images and other empty fields render nothing on the site: tell the user which ones need content.' } : {}),
|
|
729
|
+
...(result.warnings.length > 0 ? { warnings: result.warnings } : {}),
|
|
730
|
+
}, `Inserted ${section.label}`, result.ops);
|
|
667
731
|
}
|
|
668
732
|
case 'applyOperations': {
|
|
669
733
|
const known = indexLayout(workspace.layout);
|
package/dist/ai/types.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { PayloadRequest } from 'payload';
|
|
1
2
|
import type { Layout, Operation, TemplateContext } from '../core/types.js';
|
|
2
3
|
/** How hard the model thinks. Adapters map it to their API, or ignore it. */
|
|
3
4
|
export type AiEffort = 'low' | 'medium' | 'high' | 'xhigh' | 'max';
|
|
@@ -54,6 +55,11 @@ export type AiModelRequest = {
|
|
|
54
55
|
effort?: AiEffort;
|
|
55
56
|
/** Aborts the request (Stop button, closed tab). */
|
|
56
57
|
signal?: AbortSignal;
|
|
58
|
+
/**
|
|
59
|
+
* An API key from the admin's AI settings, read for this request. When set, the adapter uses it
|
|
60
|
+
* instead of the key from its options. Only sent to adapters with `acceptsApiKey`.
|
|
61
|
+
*/
|
|
62
|
+
apiKey?: string;
|
|
57
63
|
};
|
|
58
64
|
/**
|
|
59
65
|
* What an adapter yields while one model call streams, in order:
|
|
@@ -114,6 +120,13 @@ export type AiAdapter = {
|
|
|
114
120
|
keyEnv?: string | null;
|
|
115
121
|
/** Where to create a key, for the setup card. */
|
|
116
122
|
keyUrl?: string | null;
|
|
123
|
+
/**
|
|
124
|
+
* The adapter reads `AiModelRequest.apiKey`. The AI settings global then has a key field for it,
|
|
125
|
+
* so an admin can paste a key without a deploy.
|
|
126
|
+
*/
|
|
127
|
+
acceptsApiKey?: boolean;
|
|
128
|
+
/** `ready` is false only because the API key is missing: a key from the AI settings makes the adapter ready. */
|
|
129
|
+
missingKey?: boolean;
|
|
117
130
|
/** Streams one model call. Must not throw for API errors: yield an `error` event instead. */
|
|
118
131
|
stream(request: AiModelRequest): AsyncIterable<AiModelEvent>;
|
|
119
132
|
};
|
|
@@ -127,6 +140,8 @@ export type AiImageRequest = {
|
|
|
127
140
|
/** How many images. The plugin asks for 1. Adapters may return fewer. */
|
|
128
141
|
n: number;
|
|
129
142
|
signal?: AbortSignal;
|
|
143
|
+
/** An API key from the admin's AI settings. When set, it replaces the key from the options. See `AiModelRequest.apiKey`. */
|
|
144
|
+
apiKey?: string;
|
|
130
145
|
};
|
|
131
146
|
/** One generated image: the file bytes. */
|
|
132
147
|
export type AiGeneratedImage = {
|
|
@@ -169,6 +184,10 @@ export type AiImageAdapter = {
|
|
|
169
184
|
keyEnv?: string | null;
|
|
170
185
|
/** Where to create a key. */
|
|
171
186
|
keyUrl?: string | null;
|
|
187
|
+
/** The adapter reads `AiImageRequest.apiKey`: the AI settings global has a key field for it. */
|
|
188
|
+
acceptsApiKey?: boolean;
|
|
189
|
+
/** `ready` is false only because the API key is missing: a key from the AI settings makes the adapter ready. */
|
|
190
|
+
missingKey?: boolean;
|
|
172
191
|
/** Generates images. Throws `AiImageError` (or any Error) with a readable message on failure. */
|
|
173
192
|
generate(request: AiImageRequest): Promise<AiImageResult>;
|
|
174
193
|
};
|
|
@@ -218,6 +237,25 @@ export type AiOptions = {
|
|
|
218
237
|
* "generatedBy". `false` turns it off.
|
|
219
238
|
*/
|
|
220
239
|
imageMarkerField?: string | false;
|
|
240
|
+
/**
|
|
241
|
+
* The "AI settings" global, where an admin pastes API keys without a deploy. A key set there
|
|
242
|
+
* wins over the key in the adapter options (env). Keys are stored encrypted and never sent to
|
|
243
|
+
* the browser. On by default; `false` turns it off. See docs/ai/providers.md, "API keys in the admin".
|
|
244
|
+
*/
|
|
245
|
+
settings?: AiSettingsOptions | false;
|
|
246
|
+
};
|
|
247
|
+
/** Plugin option `ai.settings`. */
|
|
248
|
+
export type AiSettingsOptions = {
|
|
249
|
+
/** Slug of the global. Default "builder-ai-settings". */
|
|
250
|
+
slug?: string;
|
|
251
|
+
/**
|
|
252
|
+
* Who may read and change the settings (the global's read and update access). Default: signed-in
|
|
253
|
+
* users of the admin user collection (`admin.user`). The assistant also needs a signed-in user.
|
|
254
|
+
* Sites with roles should allow admins only.
|
|
255
|
+
*/
|
|
256
|
+
access?: (args: {
|
|
257
|
+
req: PayloadRequest;
|
|
258
|
+
}) => boolean | Promise<boolean>;
|
|
221
259
|
};
|
|
222
260
|
/** Set on BuilderClientConfig.ai when the assistant is enabled. */
|
|
223
261
|
export type AiClientConfig = {
|
|
@@ -238,6 +276,11 @@ export type AiClientConfig = {
|
|
|
238
276
|
keyUrl: string | null;
|
|
239
277
|
/** Image generation. Null when no image adapter is ready: the editor hides the Generate action. */
|
|
240
278
|
images: AiImagesClientConfig | null;
|
|
279
|
+
/**
|
|
280
|
+
* The admin page of the AI settings global, when a key there makes the assistant work and the
|
|
281
|
+
* user may open the page. Else null.
|
|
282
|
+
*/
|
|
283
|
+
settingsUrl: string | null;
|
|
241
284
|
};
|
|
242
285
|
/** Token usage of one turn (all model calls). `cost` in USD when the provider reports it (OpenRouter). */
|
|
243
286
|
export type AiUsage = {
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { BlockDefinition } from '../../core/types.js';
|
|
2
|
+
import { ADJACENT_LINKS_LABELS } from '../client/adjacentLinks.js';
|
|
3
|
+
export { ADJACENT_LINKS_LABELS };
|
|
4
|
+
export declare const ADJACENT_LINKS_BLOCK = "adjacentLinks";
|
|
5
|
+
export declare function adjacentLinksBlock(): BlockDefinition;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { COLLECTION_LIST_BLOCK } from '../../core/blockNames.js';
|
|
2
|
+
import { defineBlock } from '../../core/blocks.js';
|
|
3
|
+
import { ADJACENT_LINKS_LABELS } from '../client/adjacentLinks.js';
|
|
4
|
+
import { labelField, labelsHelp } from './shared.js';
|
|
5
|
+
export { ADJACENT_LINKS_LABELS };
|
|
6
|
+
export const ADJACENT_LINKS_BLOCK = 'adjacentLinks';
|
|
7
|
+
const ADJACENT_CLASS = 'flex flex-wrap justify-between gap-6';
|
|
8
|
+
/** A side: one collection list that finds the document before or after this one. */
|
|
9
|
+
const side = (label, defaultClassName) => ({
|
|
10
|
+
label,
|
|
11
|
+
allow: [COLLECTION_LIST_BLOCK],
|
|
12
|
+
max: 1,
|
|
13
|
+
styles: true,
|
|
14
|
+
...(defaultClassName ? { defaultClassName } : {}),
|
|
15
|
+
});
|
|
16
|
+
/** The collection list of one side: the newest document before this one, or the oldest after it. */
|
|
17
|
+
function sideList(which, at, field = 'publishedAt') {
|
|
18
|
+
const before = which === 'previous';
|
|
19
|
+
return {
|
|
20
|
+
id: `b_example_${at}`,
|
|
21
|
+
type: COLLECTION_LIST_BLOCK,
|
|
22
|
+
props: {
|
|
23
|
+
collection: 'posts',
|
|
24
|
+
limit: 1,
|
|
25
|
+
sort: before ? `-${field}` : field,
|
|
26
|
+
where: { [field]: { [before ? 'less_than' : 'greater_than']: `$page.${field}` } },
|
|
27
|
+
},
|
|
28
|
+
className: 'flex',
|
|
29
|
+
slots: {
|
|
30
|
+
item: [
|
|
31
|
+
{
|
|
32
|
+
id: `b_example_${at + 1}`,
|
|
33
|
+
type: 'link',
|
|
34
|
+
className: `flex flex-col gap-1${before ? '' : ' text-end'}`,
|
|
35
|
+
bindings: { link: '$url' },
|
|
36
|
+
slots: {
|
|
37
|
+
children: [
|
|
38
|
+
{ id: `b_example_${at + 2}`, type: 'text', props: { text: before ? '← Previous' : 'Next →' }, className: 'text-sm opacity-70' },
|
|
39
|
+
{ id: `b_example_${at + 3}`, type: 'heading', props: { level: '3' }, bindings: { text: 'title' }, className: 'text-lg font-semibold' },
|
|
40
|
+
],
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
export function adjacentLinksBlock() {
|
|
48
|
+
return defineBlock({
|
|
49
|
+
type: ADJACENT_LINKS_BLOCK,
|
|
50
|
+
label: 'Previous / next',
|
|
51
|
+
description: 'Links to the previous and the next post, at the end of a template.',
|
|
52
|
+
icon: 'adjacentLinks',
|
|
53
|
+
category: 'Dynamic',
|
|
54
|
+
fields: [labelField('label', ADJACENT_LINKS_LABELS.label, 'Name for screen readers')],
|
|
55
|
+
slots: { previous: side('Previous'), next: side('Next', 'ms-auto') },
|
|
56
|
+
defaultClassName: ADJACENT_CLASS,
|
|
57
|
+
ai: {
|
|
58
|
+
description: 'A <nav> with a link to the previous and the next document of the same collection, for the end of a template ' +
|
|
59
|
+
'(blog posts, case studies). Each of its two slots, "previous" and "next", holds ONE collection list that finds ' +
|
|
60
|
+
'that document with the page\'s own value: "previous" sorts by "-publishedAt" with where ' +
|
|
61
|
+
'{ "publishedAt": { "less_than": "$page.publishedAt" } }, "next" sorts by "publishedAt" with where ' +
|
|
62
|
+
'{ "publishedAt": { "greater_than": "$page.publishedAt" } }; both with "limit": 1 and the collection of the ' +
|
|
63
|
+
'template. Use "createdAt" (or any date or number field) the same way. The list\'s "item" slot is the link: a ' +
|
|
64
|
+
'link bound to "$url" around a text ("← Previous") and a heading bound to "title". On the site a side with no ' +
|
|
65
|
+
'document renders nothing, and with no document on either side the whole block renders nothing. Style the sides ' +
|
|
66
|
+
'with "partClassName": "previous" and "next".' +
|
|
67
|
+
labelsHelp(ADJACENT_LINKS_LABELS),
|
|
68
|
+
example: {
|
|
69
|
+
type: ADJACENT_LINKS_BLOCK,
|
|
70
|
+
className: ADJACENT_CLASS,
|
|
71
|
+
partClassName: { next: 'ms-auto' },
|
|
72
|
+
slots: { previous: [sideList('previous', 1)], next: [sideList('next', 5)] },
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
}
|
|
@@ -1,32 +1,5 @@
|
|
|
1
1
|
import type { BlockDefinition } from '../../core/types.js';
|
|
2
|
+
import { CAROUSEL_CLASS_MAP, CAROUSEL_LABELS, CAROUSEL_PART_CLASSES } from '../client/carousel.js';
|
|
3
|
+
export { CAROUSEL_CLASS_MAP, CAROUSEL_LABELS, CAROUSEL_PART_CLASSES };
|
|
2
4
|
export declare const CAROUSEL_BLOCK = "carousel";
|
|
3
|
-
/**
|
|
4
|
-
* Classes the carousel component adds itself: how the track moves its slides and where the
|
|
5
|
-
* controls sit. A single child of the track (a collection list or a repeat) is unwrapped with
|
|
6
|
-
* `display: contents`, so its items are the slides. No colours or sizes: those come from the
|
|
7
|
-
* block's className (see `CAROUSEL_CLASS`).
|
|
8
|
-
*/
|
|
9
|
-
export declare const CAROUSEL_CLASS_MAP: {
|
|
10
|
-
scroll: string;
|
|
11
|
-
fade: string;
|
|
12
|
-
/** Until the script has counted the slides, only the first one shows. */
|
|
13
|
-
fadeBefore: string;
|
|
14
|
-
fadeReady: string;
|
|
15
|
-
controls: string;
|
|
16
|
-
dots: string;
|
|
17
|
-
arrows: string;
|
|
18
|
-
button: string;
|
|
19
|
-
icon: string;
|
|
20
|
-
};
|
|
21
|
-
/** The carousel's control labels and their English defaults. */
|
|
22
|
-
export declare const CAROUSEL_LABELS: {
|
|
23
|
-
previousLabel: string;
|
|
24
|
-
nextLabel: string;
|
|
25
|
-
pauseLabel: string;
|
|
26
|
-
playLabel: string;
|
|
27
|
-
dotLabel: string;
|
|
28
|
-
slideLabel: string;
|
|
29
|
-
carouselRole: string;
|
|
30
|
-
slideRole: string;
|
|
31
|
-
};
|
|
32
5
|
export declare function carouselBlock(): BlockDefinition;
|
|
@@ -1,42 +1,18 @@
|
|
|
1
1
|
import { defineBlock } from '../../core/blocks.js';
|
|
2
|
-
import {
|
|
2
|
+
import { CAROUSEL_CLASS_MAP, CAROUSEL_LABELS, CAROUSEL_PART_CLASSES } from '../client/carousel.js';
|
|
3
|
+
import { classesOf, labelField, labelsField, labelsHelp } from './shared.js';
|
|
4
|
+
export { CAROUSEL_CLASS_MAP, CAROUSEL_LABELS, CAROUSEL_PART_CLASSES };
|
|
3
5
|
export const CAROUSEL_BLOCK = 'carousel';
|
|
6
|
+
const CAROUSEL_CLASS = 'flex flex-col gap-4';
|
|
4
7
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* `display: contents`, so its items are the slides. No colours or sizes: those come from the
|
|
8
|
-
* block's className (see `CAROUSEL_CLASS`).
|
|
8
|
+
* The carousel's inner elements that take classes (`block.partClassName`), with the classes a new
|
|
9
|
+
* carousel starts with. The "slides" slot (the track) is a part too.
|
|
9
10
|
*/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
'[&>*:only-child>*]:transition-opacity [&>*:only-child>*]:duration-500 motion-reduce:[&>*:only-child>*]:transition-none',
|
|
16
|
-
/** Until the script has counted the slides, only the first one shows. */
|
|
17
|
-
fadeBefore: '[&>*:not(:first-child)]:opacity-0 [&>*:only-child>*:not(:first-child)]:opacity-0',
|
|
18
|
-
fadeReady: '[&_[data-slide-off]]:pointer-events-none [&_[data-slide-off]]:opacity-0',
|
|
19
|
-
controls: 'flex flex-wrap items-center justify-between gap-4',
|
|
20
|
-
dots: 'flex flex-wrap items-center',
|
|
21
|
-
arrows: 'ms-auto flex items-center gap-2',
|
|
22
|
-
button: 'inline-flex cursor-pointer items-center justify-center disabled:cursor-default',
|
|
23
|
-
icon: 'size-5',
|
|
24
|
-
});
|
|
25
|
-
const CAROUSEL_CLASS = 'flex flex-col gap-4 [&_[data-carousel-track]]:gap-4 [&_[data-carousel-arrow]]:size-11 [&_[data-carousel-arrow]]:rounded-full ' +
|
|
26
|
-
'[&_[data-carousel-arrow]]:border [&_[data-carousel-arrow]:disabled]:opacity-30 [&_[data-carousel-dot]]:size-6 ' +
|
|
27
|
-
'[&_[data-carousel-dot]]:after:size-2 [&_[data-carousel-dot]]:after:rounded-full [&_[data-carousel-dot]]:after:bg-current ' +
|
|
28
|
-
'[&_[data-carousel-dot]]:after:opacity-30 [&_[data-carousel-dot][aria-current=true]]:after:opacity-100 ' +
|
|
29
|
-
'[&_[data-carousel-pause]]:text-sm [&_[data-carousel-pause]]:underline';
|
|
30
|
-
/** The carousel's control labels and their English defaults. */
|
|
31
|
-
export const CAROUSEL_LABELS = {
|
|
32
|
-
previousLabel: 'Previous slide',
|
|
33
|
-
nextLabel: 'Next slide',
|
|
34
|
-
pauseLabel: 'Pause',
|
|
35
|
-
playLabel: 'Play',
|
|
36
|
-
dotLabel: 'Slide {n}',
|
|
37
|
-
slideLabel: '{n} of {count}',
|
|
38
|
-
carouselRole: 'carousel',
|
|
39
|
-
slideRole: 'slide',
|
|
11
|
+
const CAROUSEL_PARTS = {
|
|
12
|
+
controls: { label: 'Controls row' },
|
|
13
|
+
arrow: { label: 'Arrows', defaultClassName: CAROUSEL_PART_CLASSES.arrow },
|
|
14
|
+
dot: { label: 'Dots', defaultClassName: CAROUSEL_PART_CLASSES.dot },
|
|
15
|
+
pause: { label: 'Pause button', defaultClassName: CAROUSEL_PART_CLASSES.pause },
|
|
40
16
|
};
|
|
41
17
|
const LABEL_NAMES = {
|
|
42
18
|
previousLabel: 'Previous button',
|
|
@@ -54,8 +30,9 @@ export function carouselBlock() {
|
|
|
54
30
|
return defineBlock({
|
|
55
31
|
type: CAROUSEL_BLOCK,
|
|
56
32
|
label: 'Carousel',
|
|
57
|
-
icon: '
|
|
33
|
+
icon: 'carousel',
|
|
58
34
|
category: 'Interactive',
|
|
35
|
+
description: 'Slides that visitors move through with arrows, dots or a swipe.',
|
|
59
36
|
fields: [
|
|
60
37
|
{
|
|
61
38
|
name: 'mode',
|
|
@@ -63,13 +40,24 @@ export function carouselBlock() {
|
|
|
63
40
|
label: 'Movement',
|
|
64
41
|
defaultValue: 'scroll',
|
|
65
42
|
options: [
|
|
66
|
-
{ label: '
|
|
43
|
+
{ label: 'Slide sideways', value: 'scroll' },
|
|
67
44
|
{ label: 'Fade, one slide at a time', value: 'fade' },
|
|
68
45
|
],
|
|
69
46
|
},
|
|
47
|
+
{
|
|
48
|
+
name: 'align',
|
|
49
|
+
type: 'select',
|
|
50
|
+
label: 'Slide position',
|
|
51
|
+
defaultValue: 'start',
|
|
52
|
+
options: [
|
|
53
|
+
{ label: 'Start', value: 'start' },
|
|
54
|
+
{ label: 'Center', value: 'center' },
|
|
55
|
+
],
|
|
56
|
+
admin: { description: 'Where the current slide sits when the slides are narrower than the carousel.' },
|
|
57
|
+
},
|
|
70
58
|
{ name: 'arrows', type: 'checkbox', label: 'Arrows', defaultValue: true },
|
|
71
59
|
{ name: 'dots', type: 'checkbox', label: 'Dots', defaultValue: false },
|
|
72
|
-
{ name: 'loop', type: 'checkbox', label: '
|
|
60
|
+
{ name: 'loop', type: 'checkbox', label: 'Loop: the first slide follows the last', defaultValue: false },
|
|
73
61
|
{
|
|
74
62
|
name: 'autoplay',
|
|
75
63
|
type: 'number',
|
|
@@ -77,41 +65,46 @@ export function carouselBlock() {
|
|
|
77
65
|
defaultValue: 0,
|
|
78
66
|
min: 0,
|
|
79
67
|
admin: {
|
|
80
|
-
description: '0 is off. With autoplay the carousel shows a pause button. It
|
|
81
|
-
'
|
|
68
|
+
description: '0 is off. With autoplay the carousel shows a pause button. It pauses while the pointer is over it or it has focus, ' +
|
|
69
|
+
'stops when the visitor swipes, and never runs when the visitor asks for less motion. The editor never autoplays.',
|
|
82
70
|
},
|
|
83
71
|
},
|
|
84
|
-
|
|
72
|
+
labelField('label', CAROUSEL_LABELS.label, 'Label for screen readers'),
|
|
85
73
|
labelsField(CAROUSEL_LABELS, LABEL_NAMES),
|
|
86
74
|
],
|
|
87
75
|
slots: {
|
|
88
|
-
slides: { label: 'Slides', styles: true },
|
|
76
|
+
slides: { label: 'Slides', styles: true, defaultClassName: CAROUSEL_PART_CLASSES.slides },
|
|
89
77
|
previous: { label: 'Previous button', allow: ARROW_CONTENT, max: 1 },
|
|
90
78
|
next: { label: 'Next button', allow: ARROW_CONTENT, max: 1 },
|
|
91
79
|
},
|
|
80
|
+
parts: CAROUSEL_PARTS,
|
|
92
81
|
defaultClassName: CAROUSEL_CLASS,
|
|
93
82
|
classes: classesOf(CAROUSEL_CLASS_MAP),
|
|
94
83
|
ai: {
|
|
95
|
-
description: 'Slides that
|
|
96
|
-
'autoplay. Each direct child of the "slides" slot is one slide;
|
|
97
|
-
'
|
|
98
|
-
'
|
|
99
|
-
'
|
|
100
|
-
'
|
|
101
|
-
'
|
|
102
|
-
'
|
|
84
|
+
description: 'Slides that move sideways (mode "scroll": swipe, drag, arrows, dots, arrow keys) or fade one into the next (mode "fade"), ' +
|
|
85
|
+
'with optional arrows, dots, loop and autoplay. Each direct child of the "slides" slot is one slide; set how many show at ' +
|
|
86
|
+
'once with the className of each slide, e.g. "basis-full md:basis-1/2 lg:basis-1/3" (or a width like "w-[85%]"). A ' +
|
|
87
|
+
'single collectionList or repeat child makes each of its items a slide (set the basis on the item); any other single ' +
|
|
88
|
+
'child is one slide. "align" "start" or "center" places the current slide. Dots: one per stop, so fewer dots than slides ' +
|
|
89
|
+
'when several slides show at once. The optional "previous" and "next" slots hold the arrow content (an icon); empty, they ' +
|
|
90
|
+
'show a chevron. Style the inner elements with "partClassName": "slides" for the track (the gap between slides), "arrow" ' +
|
|
91
|
+
'for both arrows, "dot" for each dot (the current dot has aria-current="true"; its mark is its ::after), "controls" for ' +
|
|
92
|
+
'the row of controls, "pause" for the pause button that autoplay adds. It is a <section> region with ' +
|
|
93
|
+
'aria-roledescription "carousel"; each slide gets an "i of n" label. In the editor the controls work, slides do not drag, ' +
|
|
94
|
+
'fade shows as sliding and autoplay is off; selecting a block in a slide moves the carousel to it.' +
|
|
103
95
|
labelsHelp(CAROUSEL_LABELS) +
|
|
104
96
|
' {n} is the slide number and {count} the number of slides. "carouselRole" and "slideRole" are the aria-roledescription values.',
|
|
105
97
|
example: {
|
|
106
98
|
type: CAROUSEL_BLOCK,
|
|
107
99
|
props: { mode: 'scroll', arrows: true, dots: true, label: 'Reviews' },
|
|
108
100
|
className: CAROUSEL_CLASS,
|
|
101
|
+
partClassName: { slides: CAROUSEL_PART_CLASSES.slides, arrow: CAROUSEL_PART_CLASSES.arrow, dot: CAROUSEL_PART_CLASSES.dot },
|
|
109
102
|
slots: {
|
|
110
103
|
slides: [
|
|
111
104
|
{
|
|
112
105
|
id: 'b_example_1',
|
|
113
106
|
type: 'stack',
|
|
114
|
-
className: 'flex
|
|
107
|
+
className: 'flex basis-[85%] flex-col gap-2 rounded-lg border p-6 md:basis-1/3',
|
|
115
108
|
slots: { children: [{ id: 'b_example_2', type: 'text', props: { text: 'A slide.' } }] },
|
|
116
109
|
},
|
|
117
110
|
],
|
|
@@ -3,7 +3,8 @@ export declare const DISCLOSURE_BLOCK = "disclosure";
|
|
|
3
3
|
export declare const ACCORDION_BLOCK = "accordion";
|
|
4
4
|
/**
|
|
5
5
|
* Classes the disclosure component adds itself. `animate`: the browser animates the content box
|
|
6
|
-
* (`::details-content`) to `height: auto
|
|
6
|
+
* (`::details-content`) to `height: auto` and fades it in, in 200 ms, close to the fades of the
|
|
7
|
+
* tabs and the popup; off with reduced motion and in browsers without it.
|
|
7
8
|
*/
|
|
8
9
|
export declare const DISCLOSURE_CLASS_MAP: {
|
|
9
10
|
summary: string;
|