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
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
// Comments on the canvas (the `builder-comments` collection): shared types, keys and pure helpers.
|
|
2
|
+
// Browser-safe: no Node built-ins and no Payload runtime imports. The editor, the server and the
|
|
3
|
+
// live channel use these. See the README section "Comments on the canvas".
|
|
4
|
+
/** Default slug of the comments collection. */
|
|
5
|
+
export const DEFAULT_COMMENTS_SLUG = 'builder-comments';
|
|
6
|
+
/** Server-only key in `config.custom` that holds `CommentsServerConfig`. */
|
|
7
|
+
export const COMMENTS_CONFIG_KEY = 'websiteBuilderComments';
|
|
8
|
+
/** Longest comment text, in characters. */
|
|
9
|
+
export const COMMENT_MAX = 5000;
|
|
10
|
+
const text = (value) => (typeof value === 'string' && value ? value : null);
|
|
11
|
+
const idOf = (value) => {
|
|
12
|
+
if (typeof value === 'string' || typeof value === 'number')
|
|
13
|
+
return String(value);
|
|
14
|
+
if (value && typeof value === 'object' && 'id' in value)
|
|
15
|
+
return idOf(value.id);
|
|
16
|
+
return null;
|
|
17
|
+
};
|
|
18
|
+
const unit = (value) => (typeof value === 'number' && Number.isFinite(value) ? Math.min(1, Math.max(0, value)) : 0.5);
|
|
19
|
+
/** A stored comment document (depth 0 or more) as a `BuilderComment`. Null when it is not one. */
|
|
20
|
+
export function toComment(doc) {
|
|
21
|
+
if (!doc || typeof doc !== 'object')
|
|
22
|
+
return null;
|
|
23
|
+
const d = doc;
|
|
24
|
+
const id = idOf(d.id);
|
|
25
|
+
if (!id)
|
|
26
|
+
return null;
|
|
27
|
+
return {
|
|
28
|
+
id,
|
|
29
|
+
parent: idOf(d.parent),
|
|
30
|
+
blockId: text(d.blockId),
|
|
31
|
+
x: unit(d.x),
|
|
32
|
+
y: unit(d.y),
|
|
33
|
+
body: typeof d.body === 'string' ? d.body : '',
|
|
34
|
+
authorKey: typeof d.authorKey === 'string' ? d.authorKey : '',
|
|
35
|
+
authorName: text(d.authorName) ?? 'Someone',
|
|
36
|
+
resolved: d.resolved === true,
|
|
37
|
+
resolvedByName: text(d.resolvedByName),
|
|
38
|
+
resolvedAt: text(d.resolvedAt),
|
|
39
|
+
createdAt: text(d.createdAt) ?? new Date(0).toISOString(),
|
|
40
|
+
editedAt: text(d.editedAt),
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/** The user's author key, as the server stores it: `<auth collection>:<id>`. */
|
|
44
|
+
export function authorKeyOf(user) {
|
|
45
|
+
if (!user || typeof user !== 'object')
|
|
46
|
+
return null;
|
|
47
|
+
const u = user;
|
|
48
|
+
const id = idOf(u.id);
|
|
49
|
+
return id ? `${typeof u.collection === 'string' ? u.collection : ''}:${id}` : null;
|
|
50
|
+
}
|
|
51
|
+
/** Adds the comment, or replaces the one with its id. Keeps the list in creation order. */
|
|
52
|
+
export function upsertComment(list, comment) {
|
|
53
|
+
const index = list.findIndex((c) => c.id === comment.id);
|
|
54
|
+
if (index === -1)
|
|
55
|
+
return [...list, comment].toSorted(byCreated);
|
|
56
|
+
const next = [...list];
|
|
57
|
+
next[index] = comment;
|
|
58
|
+
return next;
|
|
59
|
+
}
|
|
60
|
+
/** Removes the comment and, for a thread, its replies. */
|
|
61
|
+
export function removeComment(list, id) {
|
|
62
|
+
return list.filter((c) => c.id !== id && c.parent !== id);
|
|
63
|
+
}
|
|
64
|
+
function byCreated(a, b) {
|
|
65
|
+
return a.createdAt.localeCompare(b.createdAt) || a.id.localeCompare(b.id, undefined, { numeric: true });
|
|
66
|
+
}
|
|
67
|
+
/** Open threads sort by their start, resolved ones by when they were resolved. */
|
|
68
|
+
const sortTime = (t) => (t.root.resolved ? (t.root.resolvedAt ?? t.root.createdAt) : t.root.createdAt);
|
|
69
|
+
/** Open threads first (newest first), then resolved ones (newest resolved first). */
|
|
70
|
+
export function threadsOf(list, filter = 'all') {
|
|
71
|
+
const replies = new Map();
|
|
72
|
+
for (const c of list) {
|
|
73
|
+
if (!c.parent)
|
|
74
|
+
continue;
|
|
75
|
+
const group = replies.get(c.parent) ?? [];
|
|
76
|
+
group.push(c);
|
|
77
|
+
replies.set(c.parent, group);
|
|
78
|
+
}
|
|
79
|
+
const threads = list
|
|
80
|
+
.filter((c) => !c.parent)
|
|
81
|
+
.filter((c) => filter === 'all' || (filter === 'resolved') === c.resolved)
|
|
82
|
+
.map((root) => ({ root, replies: (replies.get(root.id) ?? []).toSorted(byCreated) }));
|
|
83
|
+
return threads.toSorted((a, b) => {
|
|
84
|
+
if (a.root.resolved !== b.root.resolved)
|
|
85
|
+
return a.root.resolved ? 1 : -1;
|
|
86
|
+
return sortTime(b).localeCompare(sortTime(a));
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
/** Number of open threads: the top bar's badge. */
|
|
90
|
+
export function openCount(list) {
|
|
91
|
+
return list.reduce((n, c) => (!c.parent && !c.resolved ? n + 1 : n), 0);
|
|
92
|
+
}
|
|
93
|
+
/** The REST query that lists one document's comments, oldest first. */
|
|
94
|
+
export function commentsQuery(collection, docId) {
|
|
95
|
+
const params = new URLSearchParams({
|
|
96
|
+
'where[docCollection][equals]': collection,
|
|
97
|
+
'where[docId][equals]': String(docId),
|
|
98
|
+
sort: 'createdAt',
|
|
99
|
+
depth: '0',
|
|
100
|
+
limit: '0',
|
|
101
|
+
pagination: 'false',
|
|
102
|
+
});
|
|
103
|
+
return params.toString();
|
|
104
|
+
}
|
package/dist/core/bindings.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { COLLECTION_LIST_BLOCK, PAGE_PARAM, REPEAT_BLOCK } from './blockNames.js';
|
|
1
2
|
import { type DataField } from './fields.js';
|
|
2
3
|
import type { Block, BindingField, BlockDefinition, BlockProps, Layout, TemplateContext } from './types.js';
|
|
3
4
|
import type { LayoutError } from './validate.js';
|
|
5
|
+
import { type BlockVisibility } from './visibility.js';
|
|
4
6
|
/** Default slug of the templates collection. */
|
|
5
7
|
export declare const DEFAULT_TEMPLATES_SLUG = "builder-templates";
|
|
6
8
|
/** Templates collection: the field that holds the target collection slug. */
|
|
@@ -13,10 +15,15 @@ export declare const TEMPLATE_PREVIEW_FIELD = "previewDocument";
|
|
|
13
15
|
export declare const TEMPLATE_LAYOUT_FIELD = "layout";
|
|
14
16
|
/**
|
|
15
17
|
* Templates collection: an optional Payload `where` query against the document. A document
|
|
16
|
-
* without a template of its own uses the
|
|
17
|
-
*
|
|
18
|
+
* without a template of its own uses the matching template with the highest priority
|
|
19
|
+
* (`TEMPLATE_PRIORITY_FIELD`), before the default template.
|
|
18
20
|
*/
|
|
19
21
|
export declare const TEMPLATE_CONDITIONS_FIELD = "conditions";
|
|
22
|
+
/**
|
|
23
|
+
* Templates collection: a number that orders templates with conditions. When several match a
|
|
24
|
+
* document, the highest priority wins; on equal priority the older template wins.
|
|
25
|
+
*/
|
|
26
|
+
export declare const TEMPLATE_PRIORITY_FIELD = "priority";
|
|
20
27
|
/** Template-enabled collections: the relationship to the document's own template. */
|
|
21
28
|
export declare const DOCUMENT_TEMPLATE_FIELD = "template";
|
|
22
29
|
/**
|
|
@@ -24,12 +31,11 @@ export declare const DOCUMENT_TEMPLATE_FIELD = "template";
|
|
|
24
31
|
* with at least one key counts (an empty object would match every document).
|
|
25
32
|
*/
|
|
26
33
|
export declare function templateConditions(template: Record<string, unknown> | null | undefined): Record<string, unknown> | null;
|
|
34
|
+
export { COLLECTION_LIST_BLOCK, PAGE_PARAM, REPEAT_BLOCK };
|
|
27
35
|
/** Virtual binding path: the frontend URL of the context document (from the link resolver). */
|
|
28
36
|
export declare const URL_PATH = "$url";
|
|
29
37
|
/** The Field block: shows the context document's value at `props.path`. */
|
|
30
38
|
export declare const FIELD_BLOCK = "field";
|
|
31
|
-
/** The collection list block: renders its `item` slot once per loaded document. */
|
|
32
|
-
export declare const COLLECTION_LIST_BLOCK = "collectionList";
|
|
33
39
|
/** Slot of the collection list block that holds the template for one item. */
|
|
34
40
|
export declare const LIST_ITEM_SLOT = "item";
|
|
35
41
|
/**
|
|
@@ -39,15 +45,8 @@ export declare const LIST_ITEM_SLOT = "item";
|
|
|
39
45
|
export declare const LIST_ITEMS_PROP = "$items";
|
|
40
46
|
/** Runtime-only prop of the Field block: the resolved value. It is never stored. */
|
|
41
47
|
export declare const FIELD_VALUE_PROP = "value";
|
|
42
|
-
/**
|
|
43
|
-
* The repeat block: renders its `item` slot once per row of an array or hasMany field of the
|
|
44
|
-
* current document (`props.path`). The rows are its runtime-only `$items` prop.
|
|
45
|
-
*/
|
|
46
|
-
export declare const REPEAT_BLOCK = "repeat";
|
|
47
48
|
/** Collection list slot shown when the list has no documents. */
|
|
48
49
|
export declare const LIST_EMPTY_SLOT = "empty";
|
|
49
|
-
/** The URL query parameter of a paginated list's page (`?page=3`). Filter links drop it. */
|
|
50
|
-
export declare const PAGE_PARAM = "page";
|
|
51
50
|
/** Virtual binding path inside a repeat item: the row value itself (a document, an upload, a text). */
|
|
52
51
|
export declare const ITEM_PATH = "$item";
|
|
53
52
|
/** Virtual binding path inside a collection list or repeat item: the item number, from 1. */
|
|
@@ -56,11 +55,6 @@ export declare const INDEX_PATH = "$index";
|
|
|
56
55
|
export declare const PARENT_PATH = "$parent";
|
|
57
56
|
/** Virtual path prefix: the page's own document (`$page.title`), also inside list and repeat items. */
|
|
58
57
|
export declare const PAGE_PATH = "$page";
|
|
59
|
-
/**
|
|
60
|
-
* Binding key that shows or hides the block: `"field"` shows it when the field is filled,
|
|
61
|
-
* `"!field"` when it is empty, `"field=value"` when it equals the value, `"field!=value"` when not.
|
|
62
|
-
*/
|
|
63
|
-
export declare const VISIBLE_BINDING = "$visible";
|
|
64
58
|
/** True for the slot that repeats per item: the `item` slot of a collection list or a repeat. */
|
|
65
59
|
export declare function isRepeatSlot(type: string, slot: string): boolean;
|
|
66
60
|
type Doc = Record<string, unknown>;
|
|
@@ -149,35 +143,87 @@ export declare function bindingRelations(collections: ReadonlyArray<{
|
|
|
149
143
|
fields: readonly unknown[];
|
|
150
144
|
}>): BindingRelations;
|
|
151
145
|
/**
|
|
152
|
-
* Formatters for binding expressions (`price|currency:
|
|
153
|
-
* missing and returns text, or undefined when it cannot format the value.
|
|
146
|
+
* Formatters for binding expressions (`price|currency:EUR`). Each takes a value that is not
|
|
147
|
+
* missing and returns text, or undefined when it cannot format the value. Arguments follow the
|
|
148
|
+
* name, separated by ":". The editor's format picker lists them (`BINDING_FORMATTER_INFO`).
|
|
154
149
|
*/
|
|
155
150
|
export declare const BINDING_FORMATTERS: Record<string, (value: unknown, args: string[]) => string | undefined>;
|
|
151
|
+
/** One argument of a formatter, for the editor's format picker. */
|
|
152
|
+
export type BindingFormatterArg = {
|
|
153
|
+
label: string;
|
|
154
|
+
/** An example value, shown as the input's placeholder. */
|
|
155
|
+
placeholder?: string;
|
|
156
|
+
/** A fixed choice instead of free text. */
|
|
157
|
+
options?: ReadonlyArray<{
|
|
158
|
+
value: string;
|
|
159
|
+
label: string;
|
|
160
|
+
}>;
|
|
161
|
+
};
|
|
162
|
+
/** The formatters the editor offers: a label and the arguments in order. */
|
|
163
|
+
export declare const BINDING_FORMATTER_INFO: Record<string, {
|
|
164
|
+
label: string;
|
|
165
|
+
args: BindingFormatterArg[];
|
|
166
|
+
}>;
|
|
156
167
|
/**
|
|
157
|
-
* A value through one formatter, written as in a binding: "currency:
|
|
158
|
-
* "number" or "
|
|
168
|
+
* A value through one formatter, written as in a binding: "currency:EUR", "date:en-GB:Europe/London",
|
|
169
|
+
* "number" or "truncate:160". Undefined for an unknown formatter, a missing value or a value the
|
|
159
170
|
* formatter cannot read. The field block's `format` prop uses it.
|
|
160
171
|
*/
|
|
161
172
|
export declare function formatBindingValue(value: unknown, format: string): string | undefined;
|
|
173
|
+
/** A formatter with its arguments, e.g. `{ name: 'currency', args: ['EUR'] }` for "currency:EUR". */
|
|
174
|
+
export type BindingFormat = {
|
|
175
|
+
name: string;
|
|
176
|
+
args: string[];
|
|
177
|
+
};
|
|
178
|
+
type Formatter = BindingFormat;
|
|
179
|
+
/** The text of a formatter: the name and the arguments joined by ":", without trailing empty arguments. */
|
|
180
|
+
export declare function bindingFormatText(format: BindingFormat): string;
|
|
181
|
+
/**
|
|
182
|
+
* A binding as the editor shows it: one or more paths (a fallback chain) and at most one
|
|
183
|
+
* formatter, e.g. `publishedAt|date:en-GB`. Null for templates (`{{ }}`) and for several
|
|
184
|
+
* formatters: the editor shows those as text.
|
|
185
|
+
*/
|
|
186
|
+
export type BindingParts = {
|
|
187
|
+
paths: string[];
|
|
188
|
+
format: Formatter | null;
|
|
189
|
+
};
|
|
190
|
+
export declare function bindingParts(binding: string): BindingParts | null;
|
|
191
|
+
/** The binding string of `BindingParts`. Trailing empty arguments are left out. */
|
|
192
|
+
export declare function bindingFromParts(parts: BindingParts): string;
|
|
162
193
|
/** True when a binding is more than one plain path: a template string, a fallback chain or a formatter. */
|
|
163
194
|
export declare function isBindingExpression(binding: string): boolean;
|
|
164
195
|
/**
|
|
165
|
-
* The value of a binding:
|
|
196
|
+
* The value of a binding. The syntax is fixed to these forms:
|
|
166
197
|
* - a path: `title`, `author.name`, or a virtual path (`$url`, `$item`, `$index`, `$parent.name`, `$page.title`);
|
|
167
|
-
* - a fallback chain: `
|
|
168
|
-
* - formatters after the paths: `publishedAt|date:en-
|
|
198
|
+
* - a fallback chain: `subtitle|title` (the first value that is not missing);
|
|
199
|
+
* - formatters after the paths: `publishedAt|date:en-GB:Europe/London`, `price|currency:EUR`, `summary|truncate:160`
|
|
200
|
+
* (after the first part, a name that is a formatter is always a formatter, see `expressionValue`);
|
|
169
201
|
* - a template string: `Enquire about {{name}}`. Each `{{expression}}` becomes text; a missing one
|
|
170
202
|
* becomes empty. When every one is missing, the value is missing (the literal prop stays).
|
|
171
203
|
*/
|
|
172
204
|
export declare function bindingValue(context: TemplateContext, binding: string, options?: BindingOptions): unknown;
|
|
173
205
|
/** The plain field paths a binding reads (no formatters, no virtual `$url`, `$item`, `$index`). */
|
|
174
|
-
export declare function bindingPaths(
|
|
175
|
-
/**
|
|
176
|
-
export declare function
|
|
206
|
+
export declare function bindingPaths(binding: string): string[];
|
|
207
|
+
/** The field paths a block's visibility conditions read (no virtual `$item`, `$index`). */
|
|
208
|
+
export declare function visibilityFieldPaths(visibility: BlockVisibility | undefined): string[];
|
|
209
|
+
/**
|
|
210
|
+
* True when the block's visibility conditions match the context: all of them, or any entry with
|
|
211
|
+
* `match: "any"` (a group entry matches when all its conditions match). No conditions: true.
|
|
212
|
+
*/
|
|
213
|
+
export declare function isVisible(context: TemplateContext, visibility: BlockVisibility | undefined, options?: BindingOptions): boolean;
|
|
214
|
+
/**
|
|
215
|
+
* Puts the values of `bindings` (prop path -> binding) into `props`. Bindings without a value
|
|
216
|
+
* stay in `left`, and their props keep the literal value. Never mutates.
|
|
217
|
+
*/
|
|
218
|
+
export declare function bindProps(props: BlockProps, bindings: Record<string, string>, context: TemplateContext, definition: BlockDefinition | undefined, options?: BindingOptions): {
|
|
219
|
+
props: BlockProps;
|
|
220
|
+
left: Record<string, string>;
|
|
221
|
+
changed: boolean;
|
|
222
|
+
};
|
|
177
223
|
/**
|
|
178
224
|
* Resolves one block's bindings (not its children). Bound props with a value take it; applied
|
|
179
|
-
* bindings are removed from the result, unresolved ones stay.
|
|
180
|
-
*
|
|
225
|
+
* bindings are removed from the result, unresolved ones stay. Visibility conditions that do not
|
|
226
|
+
* match make the block `hidden`. A Field block gets `props.value`, a repeat its rows (`$items`).
|
|
181
227
|
* Returns the same block when nothing changes.
|
|
182
228
|
*/
|
|
183
229
|
export declare function resolveBlockBindings(block: Block, context: TemplateContext, definition: BlockDefinition | undefined, options?: BindingOptions): Block;
|
|
@@ -216,8 +262,8 @@ export declare function itemSources(block: Block, fields: readonly BindingField[
|
|
|
216
262
|
/** The collection lists and repeats whose `item` slot holds the block, outermost first. */
|
|
217
263
|
export declare function repeatAncestors(layout: Layout, id: string): Block[];
|
|
218
264
|
/**
|
|
219
|
-
* The bindable fields a block reads: the template collection's sources
|
|
220
|
-
* collection list and repeat around it. Undefined when unknown (no collection, or a repeat path
|
|
265
|
+
* The bindable fields a block reads: the template collection's sources (with a `$page` group),
|
|
266
|
+
* narrowed by every collection list and repeat around it. Undefined when unknown (no collection, or a repeat path
|
|
221
267
|
* missing from the sources).
|
|
222
268
|
*/
|
|
223
269
|
export declare function scopeSources(layout: Layout, id: string, sources: Record<string, readonly BindingField[]>, collection: string | null): BindingField[] | undefined;
|
|
@@ -226,7 +272,6 @@ export declare function scopeSources(layout: Layout, id: string, sources: Record
|
|
|
226
272
|
* target collection, inside a collection list's `item` slot the listed collection, and inside a
|
|
227
273
|
* repeat's `item` slot the row (`itemSources`). Problems have the code `binding` (they block
|
|
228
274
|
* publishing only). Paths missing from `sources` are left alone: the renderer keeps the literal
|
|
229
|
-
* value. `$item`, `$index
|
|
275
|
+
* value. `$item`, `$index` and expressions are always allowed.
|
|
230
276
|
*/
|
|
231
277
|
export declare function validateBindings(layout: Layout, blocks: readonly BlockDefinition[], sources: Record<string, readonly BindingField[]>, collection: string | null): LayoutError[];
|
|
232
|
-
export {};
|