payload-canvas 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +625 -153
- package/dist/admin/AiKeyField.d.ts +8 -0
- package/dist/admin/AiKeyField.js +54 -0
- package/dist/admin/BuilderTab.js +4 -1
- package/dist/admin/DocumentEditView.d.ts +9 -0
- package/dist/admin/DocumentEditView.js +45 -0
- package/dist/admin/LayoutField.d.ts +2 -2
- package/dist/admin/LayoutField.js +10 -7
- package/dist/admin/TemplateConditionsField.d.ts +9 -0
- package/dist/admin/TemplateConditionsField.js +22 -0
- package/dist/admin/aiKeyField.scss +58 -0
- package/dist/admin/client.d.ts +3 -0
- package/dist/admin/client.js +6 -0
- package/dist/admin/diff/changes.js +5 -0
- package/dist/admin/editor/Canvas.js +20 -5
- package/dist/admin/editor/Editor.d.ts +3 -1
- package/dist/admin/editor/Editor.js +6 -3
- package/dist/admin/editor/Inspector.js +75 -28
- package/dist/admin/editor/Library.js +40 -15
- package/dist/admin/editor/Outline.js +21 -16
- package/dist/admin/editor/Overlay.js +8 -3
- package/dist/admin/editor/actions.d.ts +10 -2
- package/dist/admin/editor/actions.js +18 -3
- package/dist/admin/editor/assistant/AssistantPanel.js +3 -1
- package/dist/admin/editor/classes/ClassManager.d.ts +4 -0
- package/dist/admin/editor/classes/ClassManager.js +56 -0
- package/dist/admin/editor/classes/controller.d.ts +112 -0
- package/dist/admin/editor/classes/controller.js +326 -0
- package/dist/admin/editor/classes/manager.scss +262 -0
- package/dist/admin/editor/classes/managerModel.d.ts +5 -0
- package/dist/admin/editor/classes/managerModel.js +27 -0
- package/dist/admin/editor/comments/CommentLayer.d.ts +2 -0
- package/dist/admin/editor/comments/CommentLayer.js +143 -0
- package/dist/admin/editor/comments/CommentsPanel.d.ts +8 -0
- package/dist/admin/editor/comments/CommentsPanel.js +73 -0
- package/dist/admin/editor/comments/Thread.d.ts +26 -0
- package/dist/admin/editor/comments/Thread.js +84 -0
- package/dist/admin/editor/comments/comments.scss +539 -0
- package/dist/admin/editor/comments/controller.d.ts +48 -0
- package/dist/admin/editor/comments/controller.js +142 -0
- package/dist/admin/editor/contentMode.d.ts +17 -0
- package/dist/admin/editor/contentMode.js +37 -0
- package/dist/admin/editor/dnd/DropOutlines.d.ts +1 -0
- package/dist/admin/editor/dnd/DropOutlines.js +73 -0
- package/dist/admin/editor/dnd/dnd.scss +43 -0
- package/dist/admin/editor/dnd/mode.d.ts +4 -0
- package/dist/admin/editor/dnd/mode.js +39 -0
- package/dist/admin/editor/editor.scss +13 -58
- package/dist/admin/editor/empty/EmptyStart.js +18 -66
- package/dist/admin/editor/fields/AddButton.d.ts +15 -0
- package/dist/admin/editor/fields/AddButton.js +14 -0
- package/dist/admin/editor/fields/ArrayField.js +3 -2
- package/dist/admin/editor/fields/CheckedInputs.d.ts +1 -0
- package/dist/admin/editor/fields/ConditionRows.d.ts +19 -0
- package/dist/admin/editor/fields/ConditionRows.js +137 -0
- package/dist/admin/editor/fields/ListWhereField.d.ts +8 -0
- package/dist/admin/editor/fields/ListWhereField.js +20 -0
- package/dist/admin/editor/fields/QueryFiltersField.d.ts +18 -0
- package/dist/admin/editor/fields/QueryFiltersField.js +41 -0
- package/dist/admin/editor/fields/RelatedField.d.ts +19 -0
- package/dist/admin/editor/fields/RelatedField.js +44 -0
- package/dist/admin/editor/fields/SortField.d.ts +13 -0
- package/dist/admin/editor/fields/SortField.js +37 -0
- package/dist/admin/editor/fields/WhereField.d.ts +12 -4
- package/dist/admin/editor/fields/WhereField.js +33 -53
- package/dist/admin/editor/fields/collectionFields.d.ts +6 -0
- package/dist/admin/editor/fields/collectionFields.js +15 -0
- package/dist/admin/editor/fields/conditions.d.ts +99 -0
- package/dist/admin/editor/fields/conditions.js +339 -0
- package/dist/admin/editor/fields/fields.scss +232 -9
- package/dist/admin/editor/fields/listOptions.d.ts +44 -0
- package/dist/admin/editor/fields/listOptions.js +111 -0
- package/dist/admin/editor/fields/queryFilterRows.d.ts +8 -0
- package/dist/admin/editor/fields/queryFilterRows.js +29 -0
- package/dist/admin/editor/fields/whereRows.d.ts +11 -12
- package/dist/admin/editor/fields/whereRows.js +83 -34
- package/dist/admin/editor/icons.d.ts +16 -1
- package/dist/admin/editor/icons.js +30 -1
- package/dist/admin/editor/inline.js +9 -0
- package/dist/admin/editor/insert/InsertHandle.js +4 -1
- package/dist/admin/editor/insert/picker.d.ts +3 -1
- package/dist/admin/editor/insert/picker.js +17 -10
- package/dist/admin/editor/insert/spots.d.ts +12 -1
- package/dist/admin/editor/insert/spots.js +49 -10
- package/dist/admin/editor/layout/LeftPanel.js +11 -6
- package/dist/admin/editor/live/useMultiplayer.js +9 -1
- package/dist/admin/editor/menu/blockMenu.js +27 -17
- package/dist/admin/editor/names.js +11 -3
- package/dist/admin/editor/renderField.d.ts +3 -1
- package/dist/admin/editor/renderField.js +63 -12
- package/dist/admin/editor/runtime.d.ts +14 -0
- package/dist/admin/editor/runtime.js +67 -6
- package/dist/admin/editor/sections/ComponentFields.d.ts +8 -0
- package/dist/admin/editor/sections/ComponentFields.js +116 -0
- package/dist/admin/editor/sections/PropertyControls.d.ts +18 -0
- package/dist/admin/editor/sections/PropertyControls.js +65 -0
- package/dist/admin/editor/sections/components.d.ts +29 -0
- package/dist/admin/editor/sections/components.js +112 -0
- package/dist/admin/editor/sections/components.scss +238 -0
- package/dist/admin/editor/sections/variants.d.ts +32 -0
- package/dist/admin/editor/sections/variants.js +59 -0
- package/dist/admin/editor/sections/variants.scss +90 -0
- package/dist/admin/editor/shortcuts.d.ts +4 -1
- package/dist/admin/editor/shortcuts.js +19 -3
- package/dist/admin/editor/store.d.ts +18 -0
- package/dist/admin/editor/store.js +46 -0
- package/dist/admin/editor/styles/ClassBar.d.ts +14 -0
- package/dist/admin/editor/styles/ClassBar.js +90 -0
- package/dist/admin/editor/styles/ClassCss.d.ts +4 -0
- package/dist/admin/editor/styles/ClassCss.js +28 -0
- package/dist/admin/editor/styles/ClassDialog.d.ts +2 -0
- package/dist/admin/editor/styles/ClassDialog.js +151 -0
- package/dist/admin/editor/styles/ColorPicker.js +5 -2
- package/dist/admin/editor/styles/RawClasses.d.ts +26 -1
- package/dist/admin/editor/styles/RawClasses.js +184 -32
- package/dist/admin/editor/styles/StylesPanel.d.ts +3 -3
- package/dist/admin/editor/styles/StylesPanel.js +53 -14
- package/dist/admin/editor/styles/VariantBar.js +2 -2
- package/dist/admin/editor/styles/classEdit.d.ts +4 -0
- package/dist/admin/editor/styles/classEdit.js +20 -0
- package/dist/admin/editor/styles/classes.scss +381 -0
- package/dist/admin/editor/styles/context.d.ts +19 -6
- package/dist/admin/editor/styles/context.js +24 -6
- package/dist/admin/editor/styles/controls.d.ts +3 -1
- package/dist/admin/editor/styles/controls.js +30 -12
- package/dist/admin/editor/styles/popover.d.ts +6 -0
- package/dist/admin/editor/styles/popover.js +5 -5
- package/dist/admin/editor/styles/styles.scss +26 -104
- package/dist/admin/editor/styles/suggestions.d.ts +22 -0
- package/dist/admin/editor/styles/suggestions.js +77 -0
- package/dist/admin/editor/styles/tokens.js +14 -0
- package/dist/admin/editor/templates/Bindable.js +86 -57
- package/dist/admin/editor/templates/SamplePicker.js +1 -1
- package/dist/admin/editor/templates/Visibility.d.ts +9 -0
- package/dist/admin/editor/templates/Visibility.js +54 -0
- package/dist/admin/editor/templates/binding.d.ts +2 -2
- package/dist/admin/editor/templates/binding.js +2 -2
- package/dist/admin/editor/templates/templates.scss +27 -0
- package/dist/admin/editor/templates/visibilityRows.d.ts +22 -0
- package/dist/admin/editor/templates/visibilityRows.js +83 -0
- package/dist/admin/editor/topbar/ContentModeToggle.d.ts +5 -0
- package/dist/admin/editor/topbar/ContentModeToggle.js +26 -0
- package/dist/admin/editor/topbar/DocumentActions.d.ts +1 -1
- package/dist/admin/editor/topbar/DocumentActions.js +5 -4
- package/dist/admin/editor/topbar/DocumentTitle.js +7 -2
- package/dist/admin/editor/topbar/TopBar.js +15 -3
- package/dist/admin/editor/topbar/contentMode.scss +35 -0
- package/dist/admin/editor/topbar/topbar.scss +3 -1
- package/dist/admin/formChoice.d.ts +3 -0
- package/dist/admin/formChoice.js +10 -0
- package/dist/admin/layoutField.scss +69 -0
- package/dist/admin/screen/BuilderScreen.d.ts +6 -1
- package/dist/admin/screen/BuilderScreen.js +4 -3
- package/dist/admin/server/BuilderView.js +10 -3
- package/dist/admin/templateConditions.scss +24 -0
- package/dist/ai/adapters/anthropic.js +17 -4
- package/dist/ai/adapters/cloudflare-gateway.js +7 -1
- package/dist/ai/adapters/cloudflare-workers-ai.js +2 -0
- package/dist/ai/adapters/openai-compatible.js +1 -0
- package/dist/ai/adapters/openrouter.js +2 -0
- package/dist/ai/config.d.ts +24 -4
- package/dist/ai/config.js +27 -8
- package/dist/ai/endpoint.d.ts +5 -2
- package/dist/ai/endpoint.js +31 -26
- package/dist/ai/images/cloudflare-workers-ai.js +6 -2
- package/dist/ai/images/openai.js +8 -3
- package/dist/ai/images/openrouter.js +6 -2
- package/dist/ai/images/service.d.ts +10 -4
- package/dist/ai/images/service.js +23 -7
- package/dist/ai/openai-format.d.ts +7 -0
- package/dist/ai/openai-format.js +17 -5
- package/dist/ai/prompt.d.ts +8 -0
- package/dist/ai/prompt.js +25 -5
- package/dist/ai/settings/index.d.ts +62 -0
- package/dist/ai/settings/index.js +264 -0
- package/dist/ai/settings/secret.d.ts +11 -0
- package/dist/ai/settings/secret.js +46 -0
- package/dist/ai/settings/shared.d.ts +22 -0
- package/dist/ai/settings/shared.js +3 -0
- package/dist/ai/tools.d.ts +3 -0
- package/dist/ai/tools.js +79 -15
- package/dist/ai/types.d.ts +43 -0
- package/dist/blocks/builtins/adjacentLinks.d.ts +5 -0
- package/dist/blocks/builtins/adjacentLinks.js +76 -0
- package/dist/blocks/builtins/carousel.d.ts +2 -29
- package/dist/blocks/builtins/carousel.js +44 -51
- package/dist/blocks/builtins/disclosure.d.ts +2 -1
- package/dist/blocks/builtins/disclosure.js +22 -32
- package/dist/blocks/builtins/embed.d.ts +15 -0
- package/dist/blocks/builtins/embed.js +47 -0
- package/dist/blocks/builtins/faq.d.ts +1 -1
- package/dist/blocks/builtins/faq.js +2 -2
- package/dist/blocks/builtins/filterLink.d.ts +1 -19
- package/dist/blocks/builtins/filterLink.js +9 -50
- package/dist/blocks/builtins/icon.d.ts +2 -0
- package/dist/blocks/builtins/icon.js +8 -8
- package/dist/blocks/builtins/index.d.ts +18 -13
- package/dist/blocks/builtins/index.js +43 -22
- package/dist/blocks/builtins/marquee.d.ts +5 -0
- package/dist/blocks/builtins/marquee.js +68 -0
- package/dist/blocks/builtins/popup.d.ts +5 -0
- package/dist/blocks/builtins/popup.js +83 -0
- package/dist/blocks/builtins/sectionRef.d.ts +16 -2
- package/dist/blocks/builtins/sectionRef.js +34 -12
- package/dist/blocks/builtins/shared.d.ts +18 -23
- package/dist/blocks/builtins/shared.js +34 -42
- package/dist/blocks/builtins/tableOfContents.d.ts +4 -0
- package/dist/blocks/builtins/tableOfContents.js +12 -18
- package/dist/blocks/builtins/tabs.d.ts +6 -0
- package/dist/blocks/builtins/tabs.js +87 -0
- package/dist/blocks/client/adjacentLinks.d.ts +4 -0
- package/dist/blocks/client/adjacentLinks.js +4 -0
- package/dist/blocks/client/carousel.d.ts +45 -0
- package/dist/blocks/client/carousel.js +53 -0
- package/dist/blocks/client/embed.d.ts +21 -0
- package/dist/blocks/client/embed.js +23 -0
- package/dist/blocks/client/field.d.ts +7 -0
- package/dist/blocks/client/field.js +8 -0
- package/dist/blocks/client/filterLink.d.ts +19 -0
- package/dist/blocks/client/filterLink.js +30 -0
- package/dist/blocks/client/helpers.d.ts +21 -0
- package/dist/blocks/client/helpers.js +24 -0
- package/dist/blocks/client/marquee.d.ts +14 -0
- package/dist/blocks/client/marquee.js +25 -0
- package/dist/blocks/client/menu.d.ts +46 -0
- package/dist/blocks/client/menu.js +49 -0
- package/dist/blocks/client/popup.d.ts +15 -0
- package/dist/blocks/client/popup.js +16 -0
- package/dist/blocks/client/tabs.d.ts +10 -0
- package/dist/blocks/client/tabs.js +11 -0
- package/dist/blocks/defaults.d.ts +15 -52
- package/dist/blocks/defaults.js +203 -437
- package/dist/blocks/index.d.ts +1 -2
- package/dist/blocks/index.js +1 -2
- package/dist/classes/actions.d.ts +97 -0
- package/dist/classes/actions.js +296 -0
- package/dist/classes/collection.d.ts +5 -0
- package/dist/classes/collection.js +189 -0
- package/dist/classes/config.d.ts +34 -0
- package/dist/classes/config.js +8 -0
- package/dist/classes/endpoints.d.ts +2 -0
- package/dist/classes/endpoints.js +120 -0
- package/dist/classes/index.d.ts +36 -0
- package/dist/classes/index.js +42 -0
- package/dist/classes/mcp.d.ts +6 -0
- package/dist/classes/mcp.js +161 -0
- package/dist/classes/shared.d.ts +131 -0
- package/dist/classes/shared.js +300 -0
- package/dist/classes/sheet.d.ts +34 -0
- package/dist/classes/sheet.js +126 -0
- package/dist/classes/usage.d.ts +57 -0
- package/dist/classes/usage.js +208 -0
- package/dist/comments/collection.d.ts +38 -0
- package/dist/comments/collection.js +226 -0
- package/dist/comments/config.d.ts +15 -0
- package/dist/comments/config.js +2 -0
- package/dist/comments/index.d.ts +20 -0
- package/dist/comments/index.js +22 -0
- package/dist/comments/shared.d.ts +54 -0
- package/dist/comments/shared.js +104 -0
- package/dist/core/bindings.d.ts +77 -32
- package/dist/core/bindings.js +319 -134
- package/dist/core/blockNames.d.ts +9 -0
- package/dist/core/blockNames.js +11 -0
- package/dist/core/blocks.d.ts +21 -8
- package/dist/core/blocks.js +37 -16
- package/dist/core/classes.d.ts +16 -8
- package/dist/core/classes.js +31 -27
- package/dist/core/components.d.ts +72 -0
- package/dist/core/components.js +294 -0
- package/dist/core/contentMode.d.ts +27 -0
- package/dist/core/contentMode.js +0 -0
- package/dist/core/dropTarget.d.ts +11 -0
- package/dist/core/dropTarget.js +24 -1
- package/dist/core/fields.d.ts +5 -0
- package/dist/core/fields.js +11 -0
- package/dist/core/headings.d.ts +5 -2
- package/dist/core/headings.js +14 -6
- package/dist/core/index.d.ts +8 -3
- package/dist/core/index.js +8 -3
- package/dist/core/layers.d.ts +9 -0
- package/dist/core/layers.js +29 -0
- package/dist/core/operations.d.ts +6 -0
- package/dist/core/operations.js +85 -24
- package/dist/core/payloadBlocks.js +5 -1
- package/dist/core/references.js +28 -0
- package/dist/core/schema.js +20 -6
- package/dist/core/sectionOrigin.d.ts +6 -0
- package/dist/core/sectionOrigin.js +21 -0
- package/dist/core/sections.d.ts +72 -0
- package/dist/core/sections.js +331 -0
- package/dist/core/templateChoice.d.ts +24 -0
- package/dist/core/templateChoice.js +43 -0
- package/dist/core/tree.js +18 -6
- package/dist/core/types.d.ts +148 -18
- package/dist/core/validate.d.ts +4 -1
- package/dist/core/validate.js +28 -11
- package/dist/core/visibility.d.ts +63 -0
- package/dist/core/visibility.js +214 -0
- package/dist/core/whereValues.d.ts +22 -0
- package/dist/core/whereValues.js +43 -0
- package/dist/css/classes.d.ts +16 -0
- package/dist/css/classes.js +172 -0
- package/dist/css/index.d.ts +32 -1
- package/dist/css/index.js +64 -5
- package/dist/css/tokens.d.ts +10 -0
- package/dist/css/tokens.js +23 -10
- package/dist/index.d.ts +5 -2
- package/dist/index.js +6 -1
- package/dist/live/contentMode.d.ts +24 -0
- package/dist/live/contentMode.js +39 -0
- package/dist/live/endpoints.js +3 -0
- package/dist/live/session.d.ts +5 -0
- package/dist/live/session.js +8 -0
- package/dist/live/types.d.ts +16 -1
- package/dist/mcp/index.d.ts +10 -1
- package/dist/mcp/index.js +146 -54
- package/dist/mcp/shared.d.ts +93 -3
- package/dist/mcp/shared.js +211 -15
- package/dist/plugin/hook.d.ts +7 -1
- package/dist/plugin/hook.js +30 -4
- package/dist/plugin/index.d.ts +19 -8
- package/dist/plugin/index.js +89 -20
- package/dist/plugin/links.d.ts +24 -0
- package/dist/plugin/links.js +27 -0
- package/dist/plugin/listCollections.d.ts +9 -7
- package/dist/plugin/listCollections.js +30 -21
- package/dist/plugin/sections.d.ts +14 -7
- package/dist/plugin/sections.js +69 -23
- package/dist/plugin/sectionsUsedIn.d.ts +6 -0
- package/dist/plugin/sectionsUsedIn.js +24 -0
- package/dist/plugin/templateEndpoint.d.ts +9 -0
- package/dist/plugin/templateEndpoint.js +49 -0
- package/dist/plugin/templates.js +23 -8
- package/dist/protocol/index.d.ts +16 -1
- package/dist/react/canvas/BuilderCanvas.js +144 -21
- package/dist/react/canvas/classes.d.ts +17 -0
- package/dist/react/canvas/classes.js +102 -0
- package/dist/react/canvas/controls.d.ts +31 -0
- package/dist/react/canvas/controls.js +75 -0
- package/dist/react/canvas/fetchDocs.d.ts +2 -2
- package/dist/react/canvas/fetchDocs.js +16 -8
- package/dist/react/canvas/measure.d.ts +9 -0
- package/dist/react/canvas/measure.js +106 -7
- package/dist/react/canvas/resolveLayout.d.ts +1 -1
- package/dist/react/canvas/resolveLayout.js +4 -3
- package/dist/react/canvas/thumbnail/ThumbnailCanvas.js +17 -4
- package/dist/react/classes/ClassesStyle.d.ts +27 -0
- package/dist/react/classes/ClassesStyle.js +27 -0
- package/dist/react/components/Button.d.ts +2 -11
- package/dist/react/components/Button.js +8 -43
- package/dist/react/components/CollectionList.d.ts +4 -1
- package/dist/react/components/CollectionList.js +10 -3
- package/dist/react/components/Container.d.ts +5 -2
- package/dist/react/components/Container.js +7 -4
- package/dist/react/components/Field.js +3 -14
- package/dist/react/components/Link.d.ts +1 -1
- package/dist/react/components/Link.js +5 -3
- package/dist/react/components/List.d.ts +1 -1
- package/dist/react/components/List.js +2 -2
- package/dist/react/components/Menu.d.ts +10 -1
- package/dist/react/components/Menu.js +39 -12
- package/dist/react/components/RichText.d.ts +3 -4
- package/dist/react/components/RichText.js +5 -5
- package/dist/react/components/builtins/Accordion.d.ts +4 -3
- package/dist/react/components/builtins/Accordion.js +6 -5
- package/dist/react/components/builtins/AdjacentLinks.d.ts +11 -0
- package/dist/react/components/builtins/AdjacentLinks.js +20 -0
- package/dist/react/components/builtins/Carousel.d.ts +21 -10
- package/dist/react/components/builtins/Carousel.js +175 -100
- package/dist/react/components/builtins/Disclosure.d.ts +4 -3
- package/dist/react/components/builtins/Disclosure.js +6 -5
- package/dist/react/components/builtins/Embed.d.ts +11 -0
- package/dist/react/components/builtins/Embed.js +23 -0
- package/dist/react/components/builtins/EmbedHtml.d.ts +15 -0
- package/dist/react/components/builtins/EmbedHtml.js +51 -0
- package/dist/react/components/builtins/EmbedPreview.d.ts +34 -0
- package/dist/react/components/builtins/EmbedPreview.js +105 -0
- package/dist/react/components/builtins/FilterLink.d.ts +1 -1
- package/dist/react/components/builtins/FilterLink.js +4 -4
- package/dist/react/components/builtins/Marquee.d.ts +8 -0
- package/dist/react/components/builtins/Marquee.js +15 -0
- package/dist/react/components/builtins/Popup.d.ts +26 -0
- package/dist/react/components/builtins/Popup.js +146 -0
- package/dist/react/components/builtins/SectionRef.d.ts +4 -3
- package/dist/react/components/builtins/SectionRef.js +9 -5
- package/dist/react/components/builtins/Tab.d.ts +7 -0
- package/dist/react/components/builtins/Tab.js +21 -0
- package/dist/react/components/builtins/TableOfContents.d.ts +17 -3
- package/dist/react/components/builtins/TableOfContents.js +22 -7
- package/dist/react/components/builtins/Tabs.d.ts +17 -0
- package/dist/react/components/builtins/Tabs.js +71 -0
- package/dist/react/components/builtins/index.d.ts +37 -20
- package/dist/react/components/builtins/index.js +54 -20
- package/dist/react/components/builtins/tabsContext.d.ts +12 -0
- package/dist/react/components/builtins/tabsContext.js +6 -0
- package/dist/react/components/index.js +11 -8
- package/dist/react/components/lazy.d.ts +32 -0
- package/dist/react/components/lazy.js +20 -0
- package/dist/react/components/lazyBlock.d.ts +17 -0
- package/dist/react/components/lazyBlock.js +23 -0
- package/dist/react/index.d.ts +6 -3
- package/dist/react/index.js +5 -2
- package/dist/react/render/RenderLayout.d.ts +9 -7
- package/dist/react/render/RenderLayout.js +96 -45
- package/dist/react/render/canvasMode.d.ts +13 -0
- package/dist/react/render/canvasMode.js +13 -0
- package/dist/react/render/canvasServer.js +4 -3
- package/dist/react/render/canvasServerTypes.d.ts +5 -0
- package/dist/react/render/lists.d.ts +36 -4
- package/dist/react/render/lists.js +132 -15
- package/dist/react/render/marks.d.ts +15 -0
- package/dist/react/render/marks.js +23 -0
- package/dist/react/render/payload.d.ts +8 -1
- package/dist/react/render/payload.js +12 -3
- package/dist/react/render/preview.d.ts +11 -0
- package/dist/react/render/preview.js +13 -0
- package/dist/react/render/relations.d.ts +10 -0
- package/dist/react/render/relations.js +39 -0
- package/dist/react/render/resolve.d.ts +8 -4
- package/dist/react/render/resolve.js +11 -5
- package/dist/react/render/reveal.d.ts +17 -0
- package/dist/react/render/reveal.js +39 -0
- package/dist/react/render/sections.d.ts +11 -5
- package/dist/react/render/sections.js +52 -24
- package/dist/react/render/templates.d.ts +47 -0
- package/dist/react/render/templates.js +139 -0
- package/dist/react/render/types.d.ts +62 -5
- package/dist/react/server.d.ts +2 -37
- package/dist/react/server.js +8 -133
- package/dist/react/theme/ThemeLiveLoader.d.ts +4 -0
- package/dist/react/theme/ThemeLiveLoader.js +5 -0
- package/dist/react/theme/ThemeStyle.js +1 -1
- package/dist/theme/admin/Variables.d.ts +11 -0
- package/dist/theme/admin/Variables.js +115 -0
- package/dist/theme/admin/fields.scss +113 -0
- package/dist/theme/client.d.ts +1 -0
- package/dist/theme/client.js +2 -0
- package/dist/theme/css.d.ts +6 -1
- package/dist/theme/css.js +12 -4
- package/dist/theme/global.js +83 -0
- package/dist/theme/index.d.ts +1 -0
- package/dist/theme/index.js +1 -0
- package/dist/theme/server.d.ts +15 -0
- package/dist/theme/server.js +43 -0
- package/dist/theme/usage.d.ts +23 -0
- package/dist/theme/usage.js +68 -0
- package/dist/theme/variables.d.ts +72 -0
- package/dist/theme/variables.js +231 -0
- package/package.json +4 -2
- package/dist/admin/editor/styles/SiteClasses.d.ts +0 -9
- package/dist/admin/editor/styles/SiteClasses.js +0 -31
- package/dist/blocks/builtins/headingId.d.ts +0 -15
- package/dist/blocks/builtins/headingId.js +0 -36
- package/dist/blocks/builtins/lightbox.d.ts +0 -43
- package/dist/blocks/builtins/lightbox.js +0 -93
- package/dist/blocks/builtins/mediaBackdrop.d.ts +0 -11
- package/dist/blocks/builtins/mediaBackdrop.js +0 -79
- package/dist/react/components/Quote.d.ts +0 -3
- package/dist/react/components/Quote.js +0 -12
- package/dist/react/components/Spacer.d.ts +0 -3
- package/dist/react/components/Spacer.js +0 -6
- package/dist/react/components/builtins/BackdropVideo.d.ts +0 -13
- package/dist/react/components/builtins/BackdropVideo.js +0 -16
- package/dist/react/components/builtins/Lightbox.d.ts +0 -45
- package/dist/react/components/builtins/Lightbox.js +0 -252
- package/dist/react/components/builtins/MediaBackdrop.d.ts +0 -14
- package/dist/react/components/builtins/MediaBackdrop.js +0 -61
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
// Comments on the canvas: the open document's comments, the comment mode, the pin being placed
|
|
3
|
+
// and the open thread. Reads and writes go through Payload's REST API on the comments collection;
|
|
4
|
+
// the live channel's `comments` events keep every editor up to date. Nothing here touches the
|
|
5
|
+
// layout, its undo history or the document's saves.
|
|
6
|
+
import { commentsQuery, removeComment, toComment, upsertComment, } from '../../../comments/shared.js';
|
|
7
|
+
import { createValueStore } from '../valueStore.js';
|
|
8
|
+
/** The message of a Payload REST error answer, else a plain one. */
|
|
9
|
+
function restError(body, fallback) {
|
|
10
|
+
const errors = body?.errors;
|
|
11
|
+
const first = errors?.[0];
|
|
12
|
+
const nested = first?.data?.errors?.[0]?.message;
|
|
13
|
+
const message = typeof nested === 'string' ? nested : first?.message;
|
|
14
|
+
return typeof message === 'string' && message ? message : fallback;
|
|
15
|
+
}
|
|
16
|
+
export function createCommentsController(options) {
|
|
17
|
+
const { api, config, document, warn, notify } = options;
|
|
18
|
+
const doFetch = options.fetch ?? ((...args) => fetch(...args));
|
|
19
|
+
const base = `${api}/${encodeURIComponent(config.collection)}`;
|
|
20
|
+
const list = createValueStore([]);
|
|
21
|
+
const loaded = createValueStore(false);
|
|
22
|
+
const mode = createValueStore(false);
|
|
23
|
+
const filter = createValueStore('all');
|
|
24
|
+
const draft = createValueStore(null);
|
|
25
|
+
const open = createValueStore(null);
|
|
26
|
+
let loading = null;
|
|
27
|
+
const request = async (path, init, fallback) => {
|
|
28
|
+
try {
|
|
29
|
+
const response = await doFetch(`${base}${path}`, {
|
|
30
|
+
credentials: 'include',
|
|
31
|
+
...init,
|
|
32
|
+
headers: { 'Content-Type': 'application/json', ...init?.headers },
|
|
33
|
+
});
|
|
34
|
+
const body = (await response.json().catch(() => null));
|
|
35
|
+
if (!response.ok)
|
|
36
|
+
return { ok: false, error: restError(body, fallback) };
|
|
37
|
+
return { ok: true, body: body ?? {} };
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
return { ok: false, error: `${fallback} Check your connection.` };
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
/** Adds the comment a write returned, so the change shows before its live event arrives. */
|
|
44
|
+
const keep = (result, fallback) => {
|
|
45
|
+
if (!result.ok) {
|
|
46
|
+
warn(result.error);
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
const comment = toComment(result.body.doc);
|
|
50
|
+
if (!comment) {
|
|
51
|
+
warn(fallback);
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
list.set(upsertComment(list.get(), comment));
|
|
55
|
+
return comment;
|
|
56
|
+
};
|
|
57
|
+
const write = (body, fallback) => request('', { method: 'POST', body: JSON.stringify(body) }, fallback).then((result) => keep(result, fallback));
|
|
58
|
+
const patch = (id, body, fallback) => request(`/${encodeURIComponent(id)}`, { method: 'PATCH', body: JSON.stringify(body) }, fallback).then((result) => keep(result, fallback) !== null);
|
|
59
|
+
const controller = {
|
|
60
|
+
list,
|
|
61
|
+
loaded,
|
|
62
|
+
mode,
|
|
63
|
+
filter,
|
|
64
|
+
draft,
|
|
65
|
+
open,
|
|
66
|
+
toggle(on) {
|
|
67
|
+
const next = on ?? !mode.get();
|
|
68
|
+
if (next === mode.get())
|
|
69
|
+
return;
|
|
70
|
+
mode.set(next);
|
|
71
|
+
if (next)
|
|
72
|
+
return;
|
|
73
|
+
draft.set(null);
|
|
74
|
+
open.set(null);
|
|
75
|
+
},
|
|
76
|
+
load() {
|
|
77
|
+
if (loading)
|
|
78
|
+
return loading;
|
|
79
|
+
loading = (async () => {
|
|
80
|
+
const result = await request(`?${commentsQuery(document.collection, document.id)}`, undefined, 'Comments could not load.');
|
|
81
|
+
loading = null;
|
|
82
|
+
if (!result.ok) {
|
|
83
|
+
// A failed reload keeps what the list shows. The first load says why it is empty.
|
|
84
|
+
if (!loaded.get())
|
|
85
|
+
warn(result.error);
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
const docs = Array.isArray(result.body.docs) ? result.body.docs : [];
|
|
89
|
+
list.set(docs.map(toComment).filter((c) => c !== null));
|
|
90
|
+
loaded.set(true);
|
|
91
|
+
})();
|
|
92
|
+
return loading;
|
|
93
|
+
},
|
|
94
|
+
handleEvent(event) {
|
|
95
|
+
if (event.change === 'deleted') {
|
|
96
|
+
list.set(removeComment(list.get(), event.id));
|
|
97
|
+
if (open.get() === event.id)
|
|
98
|
+
open.set(null);
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
list.set(upsertComment(list.get(), event.comment));
|
|
102
|
+
},
|
|
103
|
+
place(cursor) {
|
|
104
|
+
if (!cursor.blockId)
|
|
105
|
+
return;
|
|
106
|
+
open.set(null);
|
|
107
|
+
draft.set({ blockId: cursor.blockId, x: cursor.x, y: cursor.y });
|
|
108
|
+
},
|
|
109
|
+
async create(body) {
|
|
110
|
+
const pin = draft.get();
|
|
111
|
+
if (!pin || !body.trim())
|
|
112
|
+
return false;
|
|
113
|
+
const comment = await write({ docCollection: document.collection, docId: document.id, blockId: pin.blockId, x: pin.x, y: pin.y, body }, 'The comment could not be saved.');
|
|
114
|
+
if (!comment)
|
|
115
|
+
return false;
|
|
116
|
+
draft.set(null);
|
|
117
|
+
open.set(comment.id);
|
|
118
|
+
return true;
|
|
119
|
+
},
|
|
120
|
+
async reply(threadId, body) {
|
|
121
|
+
if (!body.trim())
|
|
122
|
+
return false;
|
|
123
|
+
return (await write({ parent: threadId, body }, 'The reply could not be saved.')) !== null;
|
|
124
|
+
},
|
|
125
|
+
edit: (id, body) => (body.trim() ? patch(id, { body }, 'The comment could not be changed.') : Promise.resolve(false)),
|
|
126
|
+
setResolved: (id, resolved) => patch(id, { resolved }, resolved ? 'The thread could not be resolved.' : 'The thread could not be reopened.'),
|
|
127
|
+
async remove(id) {
|
|
128
|
+
const result = await request(`/${encodeURIComponent(id)}`, { method: 'DELETE' }, 'The comment could not be deleted.');
|
|
129
|
+
if (!result.ok) {
|
|
130
|
+
warn(result.error);
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
const thread = !list.get().find((c) => c.id === id)?.parent;
|
|
134
|
+
list.set(removeComment(list.get(), id));
|
|
135
|
+
if (open.get() === id)
|
|
136
|
+
open.set(null);
|
|
137
|
+
notify(thread ? 'Thread deleted' : 'Reply deleted');
|
|
138
|
+
return true;
|
|
139
|
+
},
|
|
140
|
+
};
|
|
141
|
+
return controller;
|
|
142
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Block, BlockDefinition, Layout } from '../../core/types.js';
|
|
2
|
+
import type { DataField } from '../../core/fields.js';
|
|
3
|
+
import type { LeftTab } from './layout/leftTabs.js';
|
|
4
|
+
import type { Runtime } from './runtime.js';
|
|
5
|
+
import type { EditorAction } from './shortcuts.js';
|
|
6
|
+
/** True when content mode allows a keyboard or menu action on the selected block (`id`). */
|
|
7
|
+
export declare function contentModeAllows(action: EditorAction, layout: Layout, id: string | null): boolean;
|
|
8
|
+
/** The left panel's tabs in content mode: Layers only (no adding blocks or sections). */
|
|
9
|
+
export declare function leftTabsFor<T extends {
|
|
10
|
+
id: LeftTab;
|
|
11
|
+
}>(contentMode: boolean, tabs: readonly T[]): readonly T[];
|
|
12
|
+
/** The block props content mode shows: content fields that no binding fills. */
|
|
13
|
+
export declare function contentModeFields(definition: Pick<BlockDefinition, 'fields'> | undefined, block: Pick<Block, 'bindings'>): DataField[];
|
|
14
|
+
/** True while the editor is in content mode. */
|
|
15
|
+
export declare function useContentMode(runtime: Pick<Runtime, 'contentMode'>): boolean;
|
|
16
|
+
/** "Preview as client": a designer sees and edits the page as a client does. No effect without design rights. */
|
|
17
|
+
export declare function setPreviewAsClient(runtime: Pick<Runtime, 'canEditDesign' | 'contentMode'>, on: boolean): void;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
// Content mode in the editor (core/contentMode.ts has the rule the server enforces). Clients see
|
|
3
|
+
// the Layers tab, the content fields of a block and inline text editing. Inside a block that lets
|
|
4
|
+
// editors manage its items, they also duplicate, delete and reorder those items. The store refuses
|
|
5
|
+
// any other edit (runtime.ts), so these helpers only decide what the editor shows.
|
|
6
|
+
import { contentFields, isEditableItem } from '../../core/contentMode.js';
|
|
7
|
+
import { useValue } from './valueStore.js';
|
|
8
|
+
/** The block actions content mode allows on items of a block that lets editors manage them. */
|
|
9
|
+
const ITEM_ACTIONS = new Set(['duplicate', 'delete', 'moveUp', 'moveDown']);
|
|
10
|
+
/** Actions that never change the design: they work in content mode on any block. */
|
|
11
|
+
const SAFE_ACTIONS = new Set(['undo', 'redo', 'escape', 'help', 'assistant', 'parent', 'editText', 'publish', 'menu', 'copy', 'panel:layers']);
|
|
12
|
+
/** True when content mode allows a keyboard or menu action on the selected block (`id`). */
|
|
13
|
+
export function contentModeAllows(action, layout, id) {
|
|
14
|
+
if (SAFE_ACTIONS.has(action))
|
|
15
|
+
return true;
|
|
16
|
+
if (ITEM_ACTIONS.has(action))
|
|
17
|
+
return id !== null && isEditableItem(layout, id);
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
/** The left panel's tabs in content mode: Layers only (no adding blocks or sections). */
|
|
21
|
+
export function leftTabsFor(contentMode, tabs) {
|
|
22
|
+
return contentMode ? tabs.filter((tab) => tab.id === 'layers') : tabs;
|
|
23
|
+
}
|
|
24
|
+
/** The block props content mode shows: content fields that no binding fills. */
|
|
25
|
+
export function contentModeFields(definition, block) {
|
|
26
|
+
return contentFields(definition).filter((field) => !block.bindings?.[field.name]);
|
|
27
|
+
}
|
|
28
|
+
/** True while the editor is in content mode. */
|
|
29
|
+
export function useContentMode(runtime) {
|
|
30
|
+
return useValue(runtime.contentMode);
|
|
31
|
+
}
|
|
32
|
+
/** "Preview as client": a designer sees and edits the page as a client does. No effect without design rights. */
|
|
33
|
+
export function setPreviewAsClient(runtime, on) {
|
|
34
|
+
if (!runtime.canEditDesign)
|
|
35
|
+
return;
|
|
36
|
+
runtime.contentMode.set(on);
|
|
37
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function DropOutlines(): import("react").JSX.Element | null;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
// Drop outlines: while a block is dragged, a thin dashed outline marks every slot on the canvas
|
|
4
|
+
// that takes it (`acceptingSlots`, the same rules as the drop targets). The slot the block would
|
|
5
|
+
// drop into gets a stronger outline and its name. Drawn in the overlay, so the page layout never
|
|
6
|
+
// moves. The user turns them off in the drag and drop menu (`useDropOutlines`).
|
|
7
|
+
import { useMemo } from 'react';
|
|
8
|
+
import { acceptingSlots, findBlock, getBlockDefinition } from '../../../core/index.js';
|
|
9
|
+
import { DEFAULT_SLOT } from '../../../core/tree.js';
|
|
10
|
+
import { blockName } from '../names.js';
|
|
11
|
+
import { useRuntime } from '../runtime.js';
|
|
12
|
+
import { useEditor } from '../store.js';
|
|
13
|
+
import { useValue, useValueSelector } from '../valueStore.js';
|
|
14
|
+
import { useDropOutlines } from './mode.js';
|
|
15
|
+
function outlineDrag(drag) {
|
|
16
|
+
if (!drag)
|
|
17
|
+
return null;
|
|
18
|
+
const { source } = drag;
|
|
19
|
+
const key = source.kind === 'block' ? `block:${source.id}` : `new:${source.blockType}`;
|
|
20
|
+
const target = drag.zone === 'canvas' && drag.target && !drag.target.noop ? drag.target : null;
|
|
21
|
+
return {
|
|
22
|
+
key,
|
|
23
|
+
source,
|
|
24
|
+
targetOwner: target?.to.parentId ?? null,
|
|
25
|
+
targetSlot: target ? (target.to.slot ?? DEFAULT_SLOT) : null,
|
|
26
|
+
// A box indicator already names the slot ("Into Stack"); a drop line does not.
|
|
27
|
+
line: target?.indicator.kind === 'line',
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function sameOutlineDrag(a, b) {
|
|
31
|
+
if (!a || !b)
|
|
32
|
+
return a === b;
|
|
33
|
+
return a.key === b.key && a.targetOwner === b.targetOwner && a.targetSlot === b.targetSlot && a.line === b.line;
|
|
34
|
+
}
|
|
35
|
+
const box = (rect) => ({ left: rect.x, top: rect.y, width: rect.width, height: rect.height });
|
|
36
|
+
export function DropOutlines() {
|
|
37
|
+
const runtime = useRuntime();
|
|
38
|
+
const enabled = useDropOutlines(runtime);
|
|
39
|
+
const drag = useValueSelector(runtime.drag, outlineDrag, sameOutlineDrag);
|
|
40
|
+
const measurement = useValue(runtime.measurement);
|
|
41
|
+
const layout = useEditor(runtime.store, (s) => s.layout);
|
|
42
|
+
const { blocks } = runtime.config;
|
|
43
|
+
const source = drag?.source ?? null;
|
|
44
|
+
const sourceKey = drag?.key ?? null;
|
|
45
|
+
// Once per drag: the layout does not change while a block is dragged.
|
|
46
|
+
// oxlint-disable-next-line react-hooks/exhaustive-deps -- `sourceKey` stands for `source`
|
|
47
|
+
const slots = useMemo(() => (enabled && source ? acceptingSlots(layout, blocks, source) : []), [enabled, sourceKey, layout, blocks]);
|
|
48
|
+
if (!drag || slots.length === 0 || !measurement)
|
|
49
|
+
return null;
|
|
50
|
+
const rects = new Map(measurement.slots.map((s) => [`${s.ownerId}\u0000${s.slot}`, s.rect]));
|
|
51
|
+
return (_jsx("div", { className: "builder-dnd-drops", "aria-hidden": "true", children: slots.map(({ ownerId, slot }) => {
|
|
52
|
+
// The root list is the whole page: an outline around it tells nothing.
|
|
53
|
+
if (ownerId === null)
|
|
54
|
+
return null;
|
|
55
|
+
const rect = rects.get(`${ownerId}\u0000${slot}`);
|
|
56
|
+
if (!rect || rect.width <= 0 || rect.height <= 0)
|
|
57
|
+
return null;
|
|
58
|
+
const target = drag.targetOwner === ownerId && drag.targetSlot === slot;
|
|
59
|
+
return (_jsx("div", { className: `builder-dnd-drop${target ? ' builder-dnd-drop--target' : ''}`, style: box(rect), children: target && drag.line && _jsx("span", { className: "builder-dnd-drop__label", children: slotName(ownerId, slot) }) }, `${ownerId}:${slot}`));
|
|
60
|
+
}) }));
|
|
61
|
+
/** "Stack", or "Carousel · Slides" for a block with more than one slot. */
|
|
62
|
+
function slotName(ownerId, slot) {
|
|
63
|
+
const owner = findBlock(layout, ownerId);
|
|
64
|
+
if (!owner)
|
|
65
|
+
return slot;
|
|
66
|
+
const def = getBlockDefinition(blocks, owner.type);
|
|
67
|
+
const name = blockName(owner, runtime.blockLabel(owner.type));
|
|
68
|
+
const slotDefs = def?.slots ?? {};
|
|
69
|
+
if (Object.keys(slotDefs).length < 2)
|
|
70
|
+
return name;
|
|
71
|
+
return `${name} · ${slotDefs[slot]?.label ?? slot}`;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -206,7 +206,50 @@
|
|
|
206
206
|
}
|
|
207
207
|
}
|
|
208
208
|
|
|
209
|
+
// Drop outlines (canvas overlay, iframe coordinates): every slot that takes the dragged block.
|
|
210
|
+
// Thin and faint, so they never compete with the drop indicator. `--be-px` is one screen pixel.
|
|
211
|
+
@keyframes builder-dnd-drops-in {
|
|
212
|
+
from {
|
|
213
|
+
opacity: 0;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
.builder-dnd-drops {
|
|
218
|
+
position: absolute;
|
|
219
|
+
inset: 0;
|
|
220
|
+
animation: builder-dnd-drops-in 160ms ease-out;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
.builder-dnd-drop {
|
|
224
|
+
position: absolute;
|
|
225
|
+
box-sizing: border-box;
|
|
226
|
+
border-radius: 2px;
|
|
227
|
+
outline: var(--be-px) dashed color-mix(in srgb, var(--be-accent) 40%, transparent);
|
|
228
|
+
outline-offset: calc(var(--be-px) * -1);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
.builder-dnd-drop--target {
|
|
232
|
+
outline-color: color-mix(in srgb, var(--be-accent) 75%, transparent);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
.builder-dnd-drop__label {
|
|
236
|
+
position: absolute;
|
|
237
|
+
top: 0;
|
|
238
|
+
left: 0;
|
|
239
|
+
height: 18px;
|
|
240
|
+
padding: 0 6px;
|
|
241
|
+
border-radius: 0 0 4px;
|
|
242
|
+
background: color-mix(in srgb, var(--be-accent) 16%, var(--be-panel));
|
|
243
|
+
color: var(--be-accent-text);
|
|
244
|
+
font-size: var(--be-text-s);
|
|
245
|
+
line-height: 18px;
|
|
246
|
+
white-space: nowrap;
|
|
247
|
+
transform-origin: 0 0;
|
|
248
|
+
transform: scale(var(--be-inv, 1));
|
|
249
|
+
}
|
|
250
|
+
|
|
209
251
|
@media (prefers-reduced-motion: reduce) {
|
|
252
|
+
.builder-dnd-drops,
|
|
210
253
|
.builder-dnd-outline--active .builder-editor__row,
|
|
211
254
|
.builder-dnd-gap,
|
|
212
255
|
.builder-dnd-gap-row,
|
|
@@ -10,3 +10,7 @@ export declare function prefersReducedMotion(): boolean;
|
|
|
10
10
|
export declare function dragMode(runtime: Runtime): DragMode;
|
|
11
11
|
/** The chosen mode (the user's choice or the default), for the setting's UI. */
|
|
12
12
|
export declare function useDragModeSetting(runtime: Runtime): DragMode;
|
|
13
|
+
/** The user's own choice for drop outlines, or null to follow the plugin's default. */
|
|
14
|
+
export declare function dropOutlinesChoice(runtime: Runtime): ValueStore<boolean | null>;
|
|
15
|
+
/** True when drags show drop outlines: the user's choice, else the plugin's default (on). */
|
|
16
|
+
export declare function useDropOutlines(runtime: Runtime): boolean;
|
|
@@ -51,3 +51,42 @@ export function dragMode(runtime) {
|
|
|
51
51
|
export function useDragModeSetting(runtime) {
|
|
52
52
|
return useValue(dragModeChoice(runtime)) ?? defaultDragMode(runtime);
|
|
53
53
|
}
|
|
54
|
+
// Drop outlines: while a block is dragged, thin outlines show every slot that takes it. The plugin
|
|
55
|
+
// option `editor.dropOutlines` sets the default; a user's choice overrides it in this browser.
|
|
56
|
+
const OUTLINES_KEY = 'payload-builder:drop-outlines';
|
|
57
|
+
function readOutlines() {
|
|
58
|
+
try {
|
|
59
|
+
const value = localStorage.getItem(OUTLINES_KEY);
|
|
60
|
+
return value === 'on' ? true : value === 'off' ? false : null;
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
const outlineChoices = new WeakMap();
|
|
67
|
+
/** The user's own choice for drop outlines, or null to follow the plugin's default. */
|
|
68
|
+
export function dropOutlinesChoice(runtime) {
|
|
69
|
+
let store = outlineChoices.get(runtime);
|
|
70
|
+
if (!store) {
|
|
71
|
+
store = createValueStore(typeof window === 'undefined' ? null : readOutlines());
|
|
72
|
+
const own = store;
|
|
73
|
+
own.subscribe(() => {
|
|
74
|
+
try {
|
|
75
|
+
const value = own.get();
|
|
76
|
+
if (value === null)
|
|
77
|
+
localStorage.removeItem(OUTLINES_KEY);
|
|
78
|
+
else
|
|
79
|
+
localStorage.setItem(OUTLINES_KEY, value ? 'on' : 'off');
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
// Storage blocked: the choice lasts for this session only.
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
outlineChoices.set(runtime, store);
|
|
86
|
+
}
|
|
87
|
+
return store;
|
|
88
|
+
}
|
|
89
|
+
/** True when drags show drop outlines: the user's choice, else the plugin's default (on). */
|
|
90
|
+
export function useDropOutlines(runtime) {
|
|
91
|
+
return useValue(dropOutlinesChoice(runtime)) ?? runtime.config.editor?.dropOutlines ?? true;
|
|
92
|
+
}
|
|
@@ -690,11 +690,14 @@
|
|
|
690
690
|
-webkit-line-clamp: 2;
|
|
691
691
|
}
|
|
692
692
|
|
|
693
|
-
//
|
|
693
|
+
// The thumbnail of a section: the wireframe, then the picture, in one box of a fixed shape. The
|
|
694
|
+
// box keeps its size when the picture loads, so the list never jumps. 2:1 is the top 1280 x 640 px
|
|
695
|
+
// of a section at the width pictures are made at (sections/thumbnails.ts).
|
|
694
696
|
.builder-editor__thumb {
|
|
695
697
|
position: relative;
|
|
696
|
-
display:
|
|
697
|
-
|
|
698
|
+
display: flex;
|
|
699
|
+
flex-direction: column;
|
|
700
|
+
aspect-ratio: 2 / 1;
|
|
698
701
|
overflow: hidden;
|
|
699
702
|
background: var(--theme-elevation-0);
|
|
700
703
|
transition: background-color 120ms ease;
|
|
@@ -704,6 +707,7 @@
|
|
|
704
707
|
.builder-editor__thumb-inner {
|
|
705
708
|
box-sizing: border-box;
|
|
706
709
|
display: flex;
|
|
710
|
+
flex: 1 0 auto;
|
|
707
711
|
flex-direction: column;
|
|
708
712
|
justify-content: center;
|
|
709
713
|
gap: 4px;
|
|
@@ -2064,57 +2068,7 @@
|
|
|
2064
2068
|
}
|
|
2065
2069
|
}
|
|
2066
2070
|
|
|
2067
|
-
//
|
|
2068
|
-
// Compact summary in the normal Edit tab
|
|
2069
|
-
// ---------------------------------------------------------------------------
|
|
2070
|
-
|
|
2071
|
-
.builder-summary__box {
|
|
2072
|
-
display: flex;
|
|
2073
|
-
align-items: center;
|
|
2074
|
-
justify-content: space-between;
|
|
2075
|
-
gap: var(--base);
|
|
2076
|
-
padding: calc(var(--base) * 0.75);
|
|
2077
|
-
border: 1px solid var(--theme-elevation-150);
|
|
2078
|
-
border-radius: var(--style-radius-s);
|
|
2079
|
-
background: var(--theme-elevation-50);
|
|
2080
|
-
|
|
2081
|
-
.btn {
|
|
2082
|
-
margin: 0;
|
|
2083
|
-
}
|
|
2084
|
-
}
|
|
2085
|
-
|
|
2086
|
-
.builder-summary__text {
|
|
2087
|
-
margin: 0;
|
|
2088
|
-
color: var(--theme-elevation-600);
|
|
2089
|
-
}
|
|
2090
|
-
|
|
2091
|
-
.builder-summary__body {
|
|
2092
|
-
display: flex;
|
|
2093
|
-
flex-direction: column;
|
|
2094
|
-
gap: 4px;
|
|
2095
|
-
min-width: 0;
|
|
2096
|
-
}
|
|
2097
|
-
|
|
2098
|
-
.builder-summary__list {
|
|
2099
|
-
margin: 0;
|
|
2100
|
-
padding: 0;
|
|
2101
|
-
list-style: none;
|
|
2102
|
-
color: var(--theme-text);
|
|
2103
|
-
|
|
2104
|
-
li {
|
|
2105
|
-
overflow: hidden;
|
|
2106
|
-
text-overflow: ellipsis;
|
|
2107
|
-
white-space: nowrap;
|
|
2108
|
-
}
|
|
2109
|
-
}
|
|
2110
|
-
|
|
2111
|
-
.builder-summary__more {
|
|
2112
|
-
color: var(--theme-elevation-600);
|
|
2113
|
-
}
|
|
2114
|
-
|
|
2115
|
-
.builder-summary__error {
|
|
2116
|
-
color: var(--theme-error-500);
|
|
2117
|
-
}
|
|
2071
|
+
// The layout field in Payload's edit view: admin/layoutField.scss.
|
|
2118
2072
|
|
|
2119
2073
|
// Live editing: changes from AI agents and other editors.
|
|
2120
2074
|
.builder-editor {
|
|
@@ -2608,19 +2562,20 @@
|
|
|
2608
2562
|
transition: opacity 120ms ease, background-color 120ms ease;
|
|
2609
2563
|
}
|
|
2610
2564
|
|
|
2611
|
-
// A picture of the section
|
|
2565
|
+
// A picture of the section, full width. A tall section shows its top part; a short one sits in
|
|
2566
|
+
// the middle of the box.
|
|
2612
2567
|
.builder-editor__thumb--picture {
|
|
2613
|
-
height: auto;
|
|
2614
|
-
min-height: 40px;
|
|
2615
|
-
max-height: 132px;
|
|
2616
2568
|
background: #fff;
|
|
2617
2569
|
mask-image: none;
|
|
2618
2570
|
}
|
|
2619
2571
|
|
|
2620
2572
|
.builder-editor__thumb-img {
|
|
2621
2573
|
display: block;
|
|
2574
|
+
flex: none;
|
|
2622
2575
|
width: 100%;
|
|
2623
2576
|
height: auto;
|
|
2577
|
+
// Auto margins center a short picture. A tall one overflows at the bottom, so its top shows.
|
|
2578
|
+
margin-block: auto;
|
|
2624
2579
|
animation: builder-fade-in 160ms ease both;
|
|
2625
2580
|
}
|
|
2626
2581
|
}
|
|
@@ -9,10 +9,11 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
|
|
|
9
9
|
// while something is dragged.
|
|
10
10
|
import { Button, useConfig } from '@payloadcms/ui';
|
|
11
11
|
import { useEffect, useId, useMemo, useState } from 'react';
|
|
12
|
-
import {
|
|
12
|
+
import { APPLIED_TEMPLATE_PATH } from '../../../core/templateChoice.js';
|
|
13
|
+
import { sectionVersion } from '../../../core/sections.js';
|
|
13
14
|
import { builderViewPath } from '../../../plugin/links.js';
|
|
14
|
-
import { whereParams } from '../../../react/canvas/fetchDocs.js';
|
|
15
15
|
import { insertBlocks, sectionPosition } from '../actions.js';
|
|
16
|
+
import { useContentMode } from '../contentMode.js';
|
|
16
17
|
import { Icon } from '../icons.js';
|
|
17
18
|
import { selectLeftTab } from '../layout/leftTabs.js';
|
|
18
19
|
import { SectionThumb } from '../Library.js';
|
|
@@ -25,79 +26,28 @@ import './empty.scss';
|
|
|
25
26
|
const SUGGESTED = ['Heroes', 'Features', 'Calls to action'];
|
|
26
27
|
const SUGGESTION_COUNT = 3;
|
|
27
28
|
function suggestions(all) {
|
|
28
|
-
//
|
|
29
|
-
const sections = all.
|
|
29
|
+
// Each section's own version, ready to insert: the canvas offers its variants afterwards.
|
|
30
|
+
const sections = all.map((s) => sectionVersion(s) ?? s);
|
|
30
31
|
const picked = SUGGESTED.flatMap((category) => sections.find((s) => s.category === category) ?? []);
|
|
31
32
|
const rest = sections.filter((s) => !picked.includes(s));
|
|
32
33
|
return [...picked, ...rest].slice(0, SUGGESTION_COUNT);
|
|
33
34
|
}
|
|
34
|
-
const hasBlocks = (doc) => {
|
|
35
|
-
const layout = doc?.[TEMPLATE_LAYOUT_FIELD];
|
|
36
|
-
return Boolean(layout?.blocks?.length);
|
|
37
|
-
};
|
|
38
|
-
async function getJson(url) {
|
|
39
|
-
const response = await fetch(url, { credentials: 'include', headers: { Accept: 'application/json' } });
|
|
40
|
-
return response.ok ? (await response.json()) : null;
|
|
41
|
-
}
|
|
42
35
|
/**
|
|
43
|
-
* The published template the site renders this document through
|
|
44
|
-
*
|
|
45
|
-
*
|
|
36
|
+
* The published template the site renders this document through, by the site's own rule
|
|
37
|
+
* (`loadTemplate`), with the conditions matched against the latest draft. The plugin's endpoint
|
|
38
|
+
* runs the rule on the server.
|
|
46
39
|
*/
|
|
47
40
|
async function appliedTemplate(runtime, id) {
|
|
48
41
|
const templates = runtime.config.templates;
|
|
49
|
-
// Only collections that templates can target
|
|
50
|
-
// invalid select value, which the database rejects (500).
|
|
42
|
+
// Only collections that templates can target.
|
|
51
43
|
if (!templates || !(runtime.config.collection in templates.sources))
|
|
52
44
|
return null;
|
|
53
|
-
const
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
if (!doc || !(DOCUMENT_TEMPLATE_FIELD in doc))
|
|
57
|
-
return null;
|
|
58
|
-
const own = doc[DOCUMENT_TEMPLATE_FIELD];
|
|
59
|
-
const ownId = own && typeof own === 'object' ? own.id : own;
|
|
60
|
-
if (typeof ownId === 'string' || typeof ownId === 'number') {
|
|
61
|
-
const template = await getJson(`${base}/${encodeURIComponent(String(ownId))}?depth=0`);
|
|
62
|
-
if (template && hasBlocks(template))
|
|
63
|
-
return { id: ownId, name: String(template.name ?? 'Untitled') };
|
|
64
|
-
}
|
|
65
|
-
const conditioned = await getJson(`${base}?${new URLSearchParams({
|
|
66
|
-
[`where[and][0][${TEMPLATE_TARGET_FIELD}][equals]`]: runtime.config.collection,
|
|
67
|
-
'where[and][1][_status][equals]': 'published',
|
|
68
|
-
[`select[${TEMPLATE_CONDITIONS_FIELD}]`]: 'true',
|
|
69
|
-
sort: 'name',
|
|
70
|
-
depth: '0',
|
|
71
|
-
limit: '100',
|
|
72
|
-
}).toString()}`);
|
|
73
|
-
for (const candidate of conditioned?.docs ?? []) {
|
|
74
|
-
const where = templateConditions(candidate);
|
|
75
|
-
if (!where)
|
|
76
|
-
continue;
|
|
77
|
-
const match = new URLSearchParams({ 'where[and][0][id][equals]': String(id), depth: '0', limit: '1', draft: 'true', 'select[id]': 'true' });
|
|
78
|
-
for (const [name, value] of whereParams(where, 'where[and][1]'))
|
|
79
|
-
match.append(name, value);
|
|
80
|
-
const found = await getJson(`${runtime.api}/${encodeURIComponent(runtime.config.collection)}?${match.toString()}`);
|
|
81
|
-
if (!found?.docs?.length)
|
|
82
|
-
continue;
|
|
83
|
-
const template = await getJson(`${base}/${encodeURIComponent(String(candidate.id))}?depth=0`);
|
|
84
|
-
if (template && hasBlocks(template))
|
|
85
|
-
return { id: candidate.id, name: String(template.name ?? 'Untitled') };
|
|
86
|
-
}
|
|
87
|
-
const query = new URLSearchParams({
|
|
88
|
-
[`where[and][0][${TEMPLATE_TARGET_FIELD}][equals]`]: runtime.config.collection,
|
|
89
|
-
[`where[and][1][${TEMPLATE_DEFAULT_FIELD}][equals]`]: 'true',
|
|
90
|
-
'where[and][2][_status][equals]': 'published',
|
|
91
|
-
sort: '-updatedAt',
|
|
92
|
-
depth: '0',
|
|
93
|
-
limit: '5',
|
|
94
|
-
});
|
|
95
|
-
const found = await getJson(`${base}?${query.toString()}`);
|
|
96
|
-
const docs = found?.docs ?? [];
|
|
97
|
-
const template = docs.find(hasBlocks);
|
|
98
|
-
if (!template)
|
|
45
|
+
const url = `${runtime.config.liveEndpoint}/${encodeURIComponent(runtime.config.collection)}/${encodeURIComponent(String(id))}/${APPLIED_TEMPLATE_PATH}`;
|
|
46
|
+
const response = await fetch(url, { credentials: 'include', headers: { Accept: 'application/json' } });
|
|
47
|
+
if (!response.ok)
|
|
99
48
|
return null;
|
|
100
|
-
|
|
49
|
+
const body = (await response.json());
|
|
50
|
+
return body.ok ? body.template : null;
|
|
101
51
|
}
|
|
102
52
|
/** The template that applies to this document. Null while loading, for templates themselves, and for collections without templates. */
|
|
103
53
|
function useAppliedTemplate(runtime, active) {
|
|
@@ -130,9 +80,11 @@ export function EmptyStart() {
|
|
|
130
80
|
// "Add blocks here anyway" on a document with a template.
|
|
131
81
|
const [ignoreTemplate, setIgnoreTemplate] = useState(false);
|
|
132
82
|
const titleId = useId();
|
|
83
|
+
// Content mode adds no blocks: the page waits for a designer.
|
|
84
|
+
const contentMode = useContentMode(runtime);
|
|
133
85
|
if (!empty || dragging)
|
|
134
86
|
return null;
|
|
135
|
-
return (_jsx("div", { className: "builder-empty-start", children: _jsx("section", { className: "builder-empty-start__card", "aria-labelledby": titleId, children: template && !ignoreTemplate ? (_jsx(TemplateNotice, { template: template, titleId: titleId, onIgnore: () => setIgnoreTemplate(true) })) : (_jsx(StartOptions, { titleId: titleId })) }) }));
|
|
87
|
+
return (_jsx("div", { className: "builder-empty-start", children: _jsx("section", { className: "builder-empty-start__card", "aria-labelledby": titleId, children: template && (!ignoreTemplate || contentMode) ? (_jsx(TemplateNotice, { template: template, titleId: titleId, onIgnore: contentMode ? null : () => setIgnoreTemplate(true) })) : contentMode ? (_jsxs(_Fragment, { children: [_jsx("h2", { id: titleId, className: "builder-empty-start__title", children: "This page is empty" }), _jsx("p", { className: "builder-empty-start__text", children: "A designer sets up the page. Then you can edit its text, images and links here." })] })) : (_jsx(StartOptions, { titleId: titleId })) }) }));
|
|
136
88
|
}
|
|
137
89
|
function TemplateNotice({ template, titleId, onIgnore }) {
|
|
138
90
|
const runtime = useRuntime();
|
|
@@ -140,7 +92,7 @@ function TemplateNotice({ template, titleId, onIgnore }) {
|
|
|
140
92
|
const singular = collections.find((c) => c.slug === runtime.config.collection)?.labels?.singular;
|
|
141
93
|
const noun = typeof singular === 'string' ? singular.toLowerCase() : 'document';
|
|
142
94
|
const templates = runtime.config.templates;
|
|
143
|
-
return (_jsxs(_Fragment, { children: [_jsx("span", { className: "builder-empty-start__icon", children: _jsx(Icon, { name: "template", size: 20 }) }), _jsxs("h2", { id: titleId, className: "builder-empty-start__title", children: ["This ", noun, " uses the template \u201C", template.name, "\u201D"] }), _jsxs("p", { className: "builder-empty-start__text", children: ["The site shows this ", noun, " through the template. Blocks you add here do not show while a template applies."] }), _jsxs("div", { className: "builder-empty-start__actions", children: [templates && (_jsx(Button, { el: "link", url: builderViewPath(routes.admin, templates.collection, template.id), buttonStyle: "primary", size: "small", margin: false, children: "Open the template" })), _jsx(Button, { buttonStyle: "secondary", size: "small", margin: false, onClick: onIgnore, children: "Add blocks here anyway" })] })] }));
|
|
95
|
+
return (_jsxs(_Fragment, { children: [_jsx("span", { className: "builder-empty-start__icon", children: _jsx(Icon, { name: "template", size: 20 }) }), _jsxs("h2", { id: titleId, className: "builder-empty-start__title", children: ["This ", noun, " uses the template \u201C", template.name, "\u201D"] }), _jsxs("p", { className: "builder-empty-start__text", children: ["The site shows this ", noun, " through the template. Blocks you add here do not show while a template applies."] }), _jsxs("div", { className: "builder-empty-start__actions", children: [templates && (_jsx(Button, { el: "link", url: builderViewPath(routes.admin, templates.collection, template.id), buttonStyle: "primary", size: "small", margin: false, children: "Open the template" })), onIgnore && (_jsx(Button, { buttonStyle: "secondary", size: "small", margin: false, onClick: onIgnore, children: "Add blocks here anyway" }))] })] }));
|
|
144
96
|
}
|
|
145
97
|
function StartOptions({ titleId }) {
|
|
146
98
|
const runtime = useRuntime();
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ComponentPropsWithoutRef } from 'react';
|
|
2
|
+
type Props = Omit<ComponentPropsWithoutRef<'button'>, 'type'> & {
|
|
3
|
+
readonly children: string;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* The inspector's quiet "+ Add …" action: a plus and a short label in muted text, no border.
|
|
7
|
+
* Used under array rows, condition rows and URL filter rows, so every list adds rows the same way.
|
|
8
|
+
*/
|
|
9
|
+
export declare function AddButton({ children, className, ...rest }: Props): import("react").JSX.Element;
|
|
10
|
+
/** The small "×" that removes one row (a condition, a URL filter). */
|
|
11
|
+
export declare function RemoveRowButton({ label, onClick }: {
|
|
12
|
+
readonly label: string;
|
|
13
|
+
readonly onClick: () => void;
|
|
14
|
+
}): import("react").JSX.Element;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Icon } from '../icons.js';
|
|
4
|
+
/**
|
|
5
|
+
* The inspector's quiet "+ Add …" action: a plus and a short label in muted text, no border.
|
|
6
|
+
* Used under array rows, condition rows and URL filter rows, so every list adds rows the same way.
|
|
7
|
+
*/
|
|
8
|
+
export function AddButton({ children, className, ...rest }) {
|
|
9
|
+
return (_jsxs("button", { type: "button", className: `builder-add${className ? ` ${className}` : ''}`, ...rest, children: [_jsx(Icon, { name: "plus", size: 12 }), children] }));
|
|
10
|
+
}
|
|
11
|
+
/** The small "×" that removes one row (a condition, a URL filter). */
|
|
12
|
+
export function RemoveRowButton({ label, onClick }) {
|
|
13
|
+
return (_jsx("button", { type: "button", className: "builder-where__remove", "aria-label": label, onClick: onClick, children: _jsx(Icon, { name: "close", size: 12 }) }));
|
|
14
|
+
}
|