payload-canvas 0.3.0-next.1 → 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 +1010 -55
- 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/LayoutDiff.js +3 -3
- package/dist/admin/diff/changes.js +13 -0
- package/dist/admin/diff/layoutDiff.scss +48 -48
- package/dist/admin/editor/Canvas.js +20 -5
- package/dist/admin/editor/DragLayer.js +1 -1
- package/dist/admin/editor/Editor.d.ts +3 -1
- package/dist/admin/editor/Editor.js +6 -3
- package/dist/admin/editor/InlineToolbar.js +1 -1
- package/dist/admin/editor/Inspector.js +115 -23
- package/dist/admin/editor/Library.js +40 -15
- package/dist/admin/editor/Outline.js +26 -19
- package/dist/admin/editor/Overlay.js +9 -4
- package/dist/admin/editor/actions.d.ts +18 -2
- package/dist/admin/editor/actions.js +53 -3
- package/dist/admin/editor/assistant/AssistantPanel.js +4 -2
- package/dist/admin/editor/assistant/ConnectAgents.js +1 -1
- package/dist/admin/editor/assistant/assistant.scss +65 -65
- 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 +45 -2
- 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 +138 -183
- package/dist/admin/editor/empty/EmptyStart.js +21 -43
- package/dist/admin/editor/empty/empty.scss +3 -3
- 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 +4 -3
- 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/GroupField.d.ts +5 -2
- package/dist/admin/editor/fields/GroupField.js +6 -2
- 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 +25 -0
- package/dist/admin/editor/fields/WhereField.js +47 -0
- package/dist/admin/editor/fields/access.d.ts +1 -1
- 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 +346 -34
- 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 +27 -0
- package/dist/admin/editor/fields/whereRows.js +167 -0
- package/dist/admin/editor/generate/GenerateImage.js +1 -1
- package/dist/admin/editor/generate/generate.scss +48 -48
- package/dist/admin/editor/icons.d.ts +17 -1
- package/dist/admin/editor/icons.js +33 -2
- package/dist/admin/editor/inline.js +9 -0
- package/dist/admin/editor/insert/InsertHandle.js +5 -2
- 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/FrameResize.js +1 -1
- package/dist/admin/editor/layout/LeftPanel.js +12 -7
- package/dist/admin/editor/layout/layout.scss +4 -4
- package/dist/admin/editor/live/PresenceUI.js +1 -1
- package/dist/admin/editor/live/presence.scss +1 -1
- package/dist/admin/editor/live/useMultiplayer.js +9 -1
- package/dist/admin/editor/locale/LocaleField.d.ts +2 -2
- package/dist/admin/editor/locale/LocaleField.js +4 -2
- package/dist/admin/editor/locale/locale.scss +12 -12
- package/dist/admin/editor/media/ImageEditor.js +1 -1
- package/dist/admin/editor/media/media.scss +23 -23
- package/dist/admin/editor/menu/Menu.js +1 -1
- package/dist/admin/editor/menu/blockMenu.js +32 -18
- package/dist/admin/editor/menu/menu.scss +16 -16
- package/dist/admin/editor/motion/MotionPanel.js +2 -2
- package/dist/admin/editor/motion/model.d.ts +2 -2
- package/dist/admin/editor/motion/model.js +2 -2
- package/dist/admin/editor/motion/motion.scss +2 -2
- package/dist/admin/editor/names.js +11 -3
- package/dist/admin/editor/regions/RegionOverlay.js +1 -1
- package/dist/admin/editor/regions/RegionPane.js +1 -1
- package/dist/admin/editor/renderField.d.ts +5 -1
- package/dist/admin/editor/renderField.js +73 -13
- package/dist/admin/editor/runtime.d.ts +14 -0
- package/dist/admin/editor/runtime.js +68 -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 +6 -3
- 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 -1
- package/dist/admin/editor/styles/StylesPanel.js +53 -11
- package/dist/admin/editor/styles/VariantBar.js +3 -3
- 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 +24 -4
- package/dist/admin/editor/styles/context.js +32 -9
- package/dist/admin/editor/styles/controls.d.ts +3 -1
- package/dist/admin/editor/styles/controls.js +31 -13
- package/dist/admin/editor/styles/popover.d.ts +6 -0
- package/dist/admin/editor/styles/popover.js +5 -5
- package/dist/admin/editor/styles/sections.js +2 -2
- package/dist/admin/editor/styles/styles.scss +115 -139
- 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.d.ts +14 -6
- package/dist/admin/editor/templates/Bindable.js +146 -61
- package/dist/admin/editor/templates/SamplePicker.js +2 -2
- 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 +11 -4
- package/dist/admin/editor/templates/binding.js +23 -3
- package/dist/admin/editor/templates/templates.scss +117 -90
- package/dist/admin/editor/templates/visibilityRows.d.ts +22 -0
- package/dist/admin/editor/templates/visibilityRows.js +83 -0
- package/dist/admin/editor/tooltip/tooltip.scss +4 -4
- 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 +6 -5
- package/dist/admin/editor/topbar/DocumentTitle.js +8 -3
- package/dist/admin/editor/topbar/TopBar.js +15 -3
- package/dist/admin/editor/topbar/contentMode.scss +35 -0
- package/dist/admin/editor/topbar/screens/DrawerRouter.d.ts +1 -1
- package/dist/admin/editor/topbar/screens/ScreenDrawer.js +1 -1
- package/dist/admin/editor/topbar/screens/drawerRouterSupport.d.ts +1 -1
- package/dist/admin/editor/topbar/screens/screens.scss +20 -20
- package/dist/admin/editor/topbar/settingsDrawer.js +3 -3
- package/dist/admin/editor/topbar/settingsDrawer.scss +7 -7
- package/dist/admin/editor/topbar/topbar.scss +50 -48
- package/dist/admin/editor/ui/Select.js +1 -1
- package/dist/admin/editor/ui/controls.scss +26 -26
- 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 +5 -4
- package/dist/admin/server/BuilderView.js +10 -3
- package/dist/admin/templateConditions.scss +24 -0
- package/dist/ai/adapters/anthropic.d.ts +2 -2
- 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 +24 -8
- package/dist/ai/loop.d.ts +5 -5
- 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 +30 -4
- 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 +83 -10
- 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 +5 -0
- package/dist/blocks/builtins/carousel.js +115 -0
- package/dist/blocks/builtins/disclosure.d.ts +14 -0
- package/dist/blocks/builtins/disclosure.js +97 -0
- package/dist/blocks/builtins/embed.d.ts +15 -0
- package/dist/blocks/builtins/embed.js +47 -0
- package/dist/blocks/builtins/faq.d.ts +17 -0
- package/dist/blocks/builtins/faq.js +88 -0
- package/dist/blocks/builtins/filterLink.d.ts +4 -0
- package/dist/blocks/builtins/filterLink.js +35 -0
- package/dist/blocks/builtins/icon.d.ts +10 -0
- package/dist/blocks/builtins/icon.js +45 -0
- package/dist/blocks/builtins/index.d.ts +40 -0
- package/dist/blocks/builtins/index.js +71 -0
- 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 +40 -0
- package/dist/blocks/builtins/sectionRef.js +100 -0
- package/dist/blocks/builtins/shared.d.ts +28 -0
- package/dist/blocks/builtins/shared.js +62 -0
- package/dist/blocks/builtins/tableOfContents.d.ts +7 -0
- package/dist/blocks/builtins/tableOfContents.js +38 -0
- 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 -34
- package/dist/blocks/defaults.js +339 -180
- package/dist/blocks/index.d.ts +4 -3
- package/dist/blocks/index.js +3 -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/attrs.d.ts +27 -0
- package/dist/core/attrs.js +132 -0
- package/dist/core/bindings.d.ts +171 -15
- package/dist/core/bindings.js +697 -27
- package/dist/core/blockNames.d.ts +9 -0
- package/dist/core/blockNames.js +11 -0
- package/dist/core/blocks.d.ts +62 -4
- package/dist/core/blocks.js +164 -7
- package/dist/core/classes.d.ts +18 -2
- package/dist/core/classes.js +37 -4
- 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/fieldAccess.js +1 -1
- package/dist/core/fieldHooks.d.ts +1 -1
- package/dist/core/fields.d.ts +5 -0
- package/dist/core/fields.js +11 -0
- package/dist/core/headings.d.ts +24 -0
- package/dist/core/headings.js +55 -0
- package/dist/core/index.d.ts +10 -3
- package/dist/core/index.js +10 -3
- package/dist/core/layers.d.ts +9 -0
- package/dist/core/layers.js +29 -0
- package/dist/core/motion.d.ts +24 -15
- package/dist/core/motion.js +20 -12
- package/dist/core/operations.d.ts +6 -0
- package/dist/core/operations.js +124 -6
- package/dist/core/payloadBlocks.js +7 -1
- package/dist/core/references.js +28 -0
- package/dist/core/schema.js +35 -1
- 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 +37 -2
- package/dist/core/types.d.ts +219 -2
- package/dist/core/validate.d.ts +4 -1
- package/dist/core/validate.js +48 -6
- 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 +14 -1
- package/dist/css/tokens.js +61 -2
- package/dist/index.d.ts +6 -3
- package/dist/index.js +7 -2
- package/dist/live/contentMode.d.ts +24 -0
- package/dist/live/contentMode.js +39 -0
- package/dist/live/draftAccess.js +1 -1
- package/dist/live/endpoints.js +3 -0
- package/dist/live/session.d.ts +6 -1
- package/dist/live/session.js +8 -0
- package/dist/live/storage.js +4 -2
- package/dist/live/types.d.ts +16 -1
- package/dist/mcp/index.d.ts +12 -1
- package/dist/mcp/index.js +177 -48
- package/dist/mcp/shared.d.ts +123 -30
- package/dist/mcp/shared.js +222 -11
- package/dist/plugin/hook.d.ts +7 -1
- package/dist/plugin/hook.js +30 -4
- package/dist/plugin/index.d.ts +27 -8
- package/dist/plugin/index.js +113 -26
- package/dist/plugin/links.d.ts +24 -0
- package/dist/plugin/links.js +27 -0
- package/dist/plugin/listCollections.d.ts +20 -3
- package/dist/plugin/listCollections.js +54 -8
- package/dist/plugin/references.d.ts +5 -0
- package/dist/plugin/references.js +1 -1
- 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.d.ts +4 -0
- package/dist/plugin/templates.js +42 -12
- package/dist/protocol/index.d.ts +19 -2
- package/dist/react/canvas/BuilderCanvas.js +149 -24
- 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 +17 -3
- package/dist/react/canvas/fetchDocs.js +51 -10
- package/dist/react/canvas/inline/rich/editor.js +1 -6
- package/dist/react/canvas/measure.d.ts +12 -1
- package/dist/react/canvas/measure.js +130 -7
- package/dist/react/canvas/resolveLayout.d.ts +1 -1
- package/dist/react/canvas/resolveLayout.js +19 -7
- package/dist/react/canvas/serverBlocks.d.ts +11 -0
- package/dist/react/canvas/serverBlocks.js +28 -1
- package/dist/react/canvas/thumbnail/ThumbnailCanvas.js +18 -5
- package/dist/react/classes/ClassesStyle.d.ts +27 -0
- package/dist/react/classes/ClassesStyle.js +27 -0
- package/dist/react/components/Button.d.ts +1 -1
- package/dist/react/components/Button.js +4 -2
- package/dist/react/components/CollectionList.d.ts +9 -3
- package/dist/react/components/CollectionList.js +28 -7
- package/dist/react/components/Container.d.ts +5 -2
- package/dist/react/components/Container.js +10 -4
- package/dist/react/components/Field.js +2 -2
- package/dist/react/components/Heading.js +9 -2
- package/dist/react/components/Image.d.ts +9 -0
- package/dist/react/components/Image.js +16 -1
- package/dist/react/components/Link.d.ts +1 -1
- package/dist/react/components/Link.js +5 -3
- package/dist/react/components/List.d.ts +2 -1
- package/dist/react/components/List.js +8 -2
- package/dist/react/components/Menu.d.ts +26 -1
- package/dist/react/components/Menu.js +116 -25
- package/dist/react/components/RichText.d.ts +6 -2
- package/dist/react/components/RichText.js +23 -2
- package/dist/react/components/builtins/Accordion.d.ts +10 -0
- package/dist/react/components/builtins/Accordion.js +38 -0
- 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 +24 -0
- package/dist/react/components/builtins/Carousel.js +209 -0
- package/dist/react/components/builtins/Disclosure.d.ts +8 -0
- package/dist/react/components/builtins/Disclosure.js +14 -0
- 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 +8 -0
- package/dist/react/components/builtins/FilterLink.js +30 -0
- package/dist/react/components/builtins/Icon.d.ts +14 -0
- package/dist/react/components/builtins/Icon.js +28 -0
- 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 +8 -0
- package/dist/react/components/builtins/SectionRef.js +21 -0
- 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 +21 -0
- package/dist/react/components/builtins/TableOfContents.js +36 -0
- package/dist/react/components/builtins/Tabs.d.ts +17 -0
- package/dist/react/components/builtins/Tabs.js +71 -0
- package/dist/react/components/builtins/glyphs.d.ts +8 -0
- package/dist/react/components/builtins/glyphs.js +7 -0
- package/dist/react/components/builtins/index.d.ts +49 -0
- package/dist/react/components/builtins/index.js +70 -0
- 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 +13 -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 +8 -3
- package/dist/react/index.js +7 -2
- package/dist/react/motion/runtime.js +10 -6
- package/dist/react/motion/style.js +1 -1
- package/dist/react/render/PayloadRoot.js +1 -1
- package/dist/react/render/RenderLayout.d.ts +9 -7
- package/dist/react/render/RenderLayout.js +145 -41
- 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 +139 -5
- package/dist/react/render/lists.js +401 -9
- 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 +26 -2
- package/dist/react/render/resolve.js +52 -25
- package/dist/react/render/reveal.d.ts +17 -0
- package/dist/react/render/reveal.js +39 -0
- package/dist/react/render/sections.d.ts +15 -0
- package/dist/react/render/sections.js +79 -0
- package/dist/react/render/templates.d.ts +47 -0
- package/dist/react/render/templates.js +139 -0
- package/dist/react/render/types.d.ts +66 -4
- package/dist/react/server.d.ts +3 -38
- package/dist/react/server.js +9 -86
- package/dist/react/theme/ThemeLiveLoader.d.ts +4 -0
- package/dist/react/theme/ThemeLiveLoader.js +5 -0
- package/dist/react/theme/ThemeStyle.d.ts +13 -2
- package/dist/react/theme/ThemeStyle.js +14 -4
- package/dist/theme/admin/ColorField.d.ts +2 -2
- package/dist/theme/admin/ColorField.js +2 -2
- package/dist/theme/admin/FontField.d.ts +2 -2
- package/dist/theme/admin/FontField.js +2 -2
- package/dist/theme/admin/SaveSignal.js +2 -2
- package/dist/theme/admin/Variables.d.ts +11 -0
- package/dist/theme/admin/Variables.js +115 -0
- package/dist/theme/admin/fields.scss +161 -48
- 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 +25 -28
- 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
|
@@ -4,7 +4,7 @@ import { useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
|
|
|
4
4
|
import { deepestBlockAt } from '../../core/index.js';
|
|
5
5
|
import { unwrap } from '../../protocol/index.js';
|
|
6
6
|
import { ancestors } from './actions.js';
|
|
7
|
-
import { dragModeChoice, prefersReducedMotion, useDragModeSetting } from './dnd/mode.js';
|
|
7
|
+
import { dragModeChoice, dropOutlinesChoice, prefersReducedMotion, useDragModeSetting, useDropOutlines } from './dnd/mode.js';
|
|
8
8
|
import { dropAt } from './dnd/smooth.js';
|
|
9
9
|
import { BlockIcon, Icon } from './icons.js';
|
|
10
10
|
import { applyInlineChange, applyInlineJoin, applyInlineSplit, boundHint, endRegionInline, inlineEditing, noteInlineStart, refuseLockedInline, stopInlineEditing, } from './inline.js';
|
|
@@ -18,8 +18,9 @@ import { FollowFrame } from './live/PresenceUI.js';
|
|
|
18
18
|
import { FrameResize } from './layout/FrameResize.js';
|
|
19
19
|
import { imageEditor, updateImageEditor, uploadImage } from './media/actions.js';
|
|
20
20
|
import { EmptyStart } from './empty/EmptyStart.js';
|
|
21
|
-
import { EDGE_BAND, insertSpotAt, sameSpot } from './insert/spots.js';
|
|
21
|
+
import { EDGE_BAND, INSERT_BUTTON, insertSpotAt, sameSpot } from './insert/spots.js';
|
|
22
22
|
import { Overlay } from './Overlay.js';
|
|
23
|
+
import { CommentLayer } from './comments/CommentLayer.js';
|
|
23
24
|
import { useRuntime } from './runtime.js';
|
|
24
25
|
import { bindShortcuts } from './shortcuts.js';
|
|
25
26
|
import { useEditor } from './store.js';
|
|
@@ -137,6 +138,13 @@ export function Canvas() {
|
|
|
137
138
|
spotTimer = window.setTimeout(() => runtime.insertSpot.set(null), SPOT_LINGER_MS);
|
|
138
139
|
return;
|
|
139
140
|
}
|
|
141
|
+
// Over a canvas control (a carousel's arrow): it acts as on the site, so no hover and no "+".
|
|
142
|
+
if (message.control) {
|
|
143
|
+
store.hover(null);
|
|
144
|
+
runtime.regions?.hovered.set(null);
|
|
145
|
+
setSpot(null);
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
140
148
|
const m = measurement.get();
|
|
141
149
|
if (!m)
|
|
142
150
|
return;
|
|
@@ -152,7 +160,8 @@ export function Canvas() {
|
|
|
152
160
|
// Not on the selected block's own edges, where its frame, name tag and action bar are.
|
|
153
161
|
const { selectedId } = store.getState();
|
|
154
162
|
const selected = selectedId ? { id: selectedId, tolerance: SELECTED_EDGE_PX / (runtime.frame.get().zoom || 1) } : undefined;
|
|
155
|
-
|
|
163
|
+
const button = INSERT_BUTTON / (runtime.frame.get().zoom || 1);
|
|
164
|
+
setSpot(inline.get() ? null : insertSpotAt(layout, runtime.config.blocks, m, message, { band, selected, button }));
|
|
156
165
|
}
|
|
157
166
|
if (message.kind === 'click') {
|
|
158
167
|
if (region && runtime.regions)
|
|
@@ -361,7 +370,7 @@ export function Canvas() {
|
|
|
361
370
|
};
|
|
362
371
|
return (_jsxs("section", { className: "builder-editor__stage", children: [error && (_jsxs("output", { className: "builder-editor__canvas-error", children: [error, _jsx("button", { type: "button", onClick: () => runtime.canvasError.set(null), children: "Dismiss" })] })), _jsxs("div", { ref: viewportRef, className: "builder-editor__viewport", "data-scroll": scrolls || undefined, style: { padding: STAGE_PADDING }, children: [_jsxs("div", { ref: wrapRef, className: "builder-editor__frame-wrap", "data-device": fluid ? 'fluid' : 'fixed', style: { width: frameWidth * zoom || '100%', height: stage.height || '100%' }, children: [_jsxs("div", { ref: frameRef, className: "builder-editor__frame", style: frameStyle,
|
|
363
372
|
// While dragging, the iframe ignores the pointer, so forward the wheel to keep scrolling.
|
|
364
|
-
onWheel: locked ? (e) => runtime.postToCanvas({ type: 'scrollBy', dx: e.deltaX, dy: e.deltaY }) : undefined, children: [_jsx("iframe", { ref: iframeRef, src: config.canvasPath, title: "Canvas", className: "builder-editor__iframe", style: { pointerEvents: locked ? 'none' : undefined } }), _jsx(Overlay, {})] }), _jsx(FrameResize, { wrapRef: wrapRef, frameRef: frameRef, frameWidth: frameWidth, zoom: zoom, space: stage.width }), _jsx(EmptyStart, {})] }), _jsx(FollowFrame, {}), _jsx(Notice, {})] }), _jsx(StatusBar, { frameWidth: frameWidth, zoom: zoom, fit: fit, zoomMode: fluid ? 'fit' : zoomMode, fluid: fluid, onZoom: setZoomMode })] }));
|
|
373
|
+
onWheel: locked ? (e) => runtime.postToCanvas({ type: 'scrollBy', dx: e.deltaX, dy: e.deltaY }) : undefined, children: [_jsx("iframe", { ref: iframeRef, src: config.canvasPath, title: "Canvas", className: "builder-editor__iframe", style: { pointerEvents: locked ? 'none' : undefined } }), _jsx(Overlay, {}), _jsx(CommentLayer, {})] }), _jsx(FrameResize, { wrapRef: wrapRef, frameRef: frameRef, frameWidth: frameWidth, zoom: zoom, space: stage.width }), _jsx(EmptyStart, {})] }), _jsx(FollowFrame, {}), _jsx(Notice, {})] }), _jsx(StatusBar, { frameWidth: frameWidth, zoom: zoom, fit: fit, zoomMode: fluid ? 'fit' : zoomMode, fluid: fluid, onZoom: setZoomMode })] }));
|
|
365
374
|
}
|
|
366
375
|
const ZOOM_STEPS = [0.25, 0.33, 0.5, 0.67, 0.75, 1];
|
|
367
376
|
/** Zoom out, the current zoom (click to fit), zoom in. Fluid always shows 100 %: no zoom there. */
|
|
@@ -404,9 +413,13 @@ function PlayMotionToggle({ runtime }) {
|
|
|
404
413
|
const on = useValue(store);
|
|
405
414
|
return (_jsx("button", { type: "button", className: "builder-editor__icon-button builder-editor__icon-button--small", "aria-pressed": on, "aria-label": "Play animations", "data-tooltip": on ? 'Stop animations' : 'Play animations', onClick: () => store.set(!on), children: _jsx(Icon, { name: "motion", size: 14 }) }));
|
|
406
415
|
}
|
|
407
|
-
/**
|
|
416
|
+
/**
|
|
417
|
+
* Drag and drop style: the drop indicator or the smooth mode, and the drop outlines on or off.
|
|
418
|
+
* The choices stay in this browser.
|
|
419
|
+
*/
|
|
408
420
|
function DragModeMenu({ runtime }) {
|
|
409
421
|
const mode = useDragModeSetting(runtime);
|
|
422
|
+
const outlines = useDropOutlines(runtime);
|
|
410
423
|
const reduced = prefersReducedMotion();
|
|
411
424
|
const choose = (next) => dragModeChoice(runtime).set(next);
|
|
412
425
|
return (_jsx(MenuButton, { className: "builder-editor__icon-button builder-editor__icon-button--small",
|
|
@@ -414,5 +427,7 @@ function DragModeMenu({ runtime }) {
|
|
|
414
427
|
triggerLabel: `Drag and drop style: ${mode === 'smooth' ? 'move blocks out of the way' : 'show a drop line'}`, tooltip: `Drag and drop: ${mode === 'smooth' ? 'blocks move out of the way' : 'a drop line shows'}`, label: "Drag and drop style", side: "top", align: "end", footer: reduced ? 'Your system asks for less motion, so dragging shows the drop line.' : undefined, items: () => [
|
|
415
428
|
{ label: 'Show a drop line', icon: 'drag', checked: mode === 'indicator', run: () => choose('indicator') },
|
|
416
429
|
{ label: 'Move blocks out of the way', icon: 'layers', checked: mode === 'smooth', disabled: reduced, run: () => choose('smooth') },
|
|
430
|
+
'separator',
|
|
431
|
+
{ label: 'Outline where blocks can drop', icon: 'grid', checked: outlines, run: () => dropOutlinesChoice(runtime).set(!outlines) },
|
|
417
432
|
], children: _jsx(Icon, { name: "drag", size: 14 }) }));
|
|
418
433
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import {
|
|
2
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useCallback } from 'react';
|
|
4
4
|
import { registerGhost, smoothView } from './dnd/smooth.js';
|
|
5
5
|
import { BlockIcon } from './icons.js';
|
|
@@ -11,10 +11,12 @@ type EditorProps = {
|
|
|
11
11
|
icon: ReactNode;
|
|
12
12
|
/** The locale to open a localized layout in. */
|
|
13
13
|
locale?: string | null;
|
|
14
|
+
/** The user may change the design. False: content mode (text, images and links only). Default true. */
|
|
15
|
+
canEditDesign?: boolean;
|
|
14
16
|
};
|
|
15
17
|
/**
|
|
16
18
|
* The full-screen editor. The document's live session is the source of truth for the layout: the
|
|
17
19
|
* server loads the draft into it, and every edit goes through it (docs/architecture.md section 12).
|
|
18
20
|
*/
|
|
19
|
-
export declare function Editor({ config, meta, icon, locale }: EditorProps): import("react").JSX.Element;
|
|
21
|
+
export declare function Editor({ config, meta, icon, locale, canEditDesign }: EditorProps): import("react").JSX.Element;
|
|
20
22
|
export {};
|
|
@@ -8,6 +8,7 @@ import { Canvas } from './Canvas.js';
|
|
|
8
8
|
import { DragLayer } from './DragLayer.js';
|
|
9
9
|
import { dropAt, endSmoothDrag, isSmoothDrag, MAKE_ROOM_EASING, SETTLE_EASING, startSmoothDrag } from './dnd/smooth.js';
|
|
10
10
|
import { Inspector } from './Inspector.js';
|
|
11
|
+
import { CommentsOrInspector } from './comments/CommentsPanel.js';
|
|
11
12
|
import { LeftPanel } from './layout/LeftPanel.js';
|
|
12
13
|
import { applySizes, readSizes } from './layout/panels.js';
|
|
13
14
|
import { Splitter } from './layout/Splitter.js';
|
|
@@ -21,6 +22,7 @@ import { useFollow } from './live/useFollow.js';
|
|
|
21
22
|
import { useTemplateController } from './templates/useTemplate.js';
|
|
22
23
|
import { TopBar } from './topbar/TopBar.js';
|
|
23
24
|
import { useValueSelector } from './valueStore.js';
|
|
25
|
+
import { useComponentRefresh } from './sections/components.js';
|
|
24
26
|
const COLLISION_ID = 'builder-drop';
|
|
25
27
|
/** Distance from the canvas top or bottom edge where auto-scroll starts. */
|
|
26
28
|
const AUTO_SCROLL_EDGE = 56;
|
|
@@ -49,9 +51,9 @@ function startAutoScroll(runtime) {
|
|
|
49
51
|
* The full-screen editor. The document's live session is the source of truth for the layout: the
|
|
50
52
|
* server loads the draft into it, and every edit goes through it (docs/architecture.md section 12).
|
|
51
53
|
*/
|
|
52
|
-
export function Editor({ config, meta, icon, locale }) {
|
|
54
|
+
export function Editor({ config, meta, icon, locale, canEditDesign }) {
|
|
53
55
|
const { config: payloadConfig } = useConfig();
|
|
54
|
-
const [runtime] = useState(() => createRuntime(config, payloadConfig.routes.api, meta, { locale }));
|
|
56
|
+
const [runtime] = useState(() => createRuntime(config, payloadConfig.routes.api, meta, { locale, canEditDesign }));
|
|
55
57
|
const docId = meta.id;
|
|
56
58
|
useMultiplayer(runtime, { docId });
|
|
57
59
|
// Ready once the first session arrived. A reconnect keeps the editor open.
|
|
@@ -59,6 +61,7 @@ export function Editor({ config, meta, icon, locale }) {
|
|
|
59
61
|
const ready = useValueSelector(runtime.live, (live) => Boolean(live?.self));
|
|
60
62
|
useFollow(runtime);
|
|
61
63
|
useTemplateController(runtime);
|
|
64
|
+
useComponentRefresh(runtime);
|
|
62
65
|
useEffect(() => runtime.assistant?.setDocument(config.collection, docId), [runtime, config.collection, docId]);
|
|
63
66
|
useEffect(() => () => runtime.assistant?.stop(), [runtime]);
|
|
64
67
|
// The hidden thumbnail iframe goes with the editor.
|
|
@@ -173,5 +176,5 @@ export function Editor({ config, meta, icon, locale }) {
|
|
|
173
176
|
// A stable id keeps dnd-kit's aria ids equal on server and client (no hydration mismatch).
|
|
174
177
|
id: dndId, sensors: sensors, collisionDetection: collisionDetection, autoScroll: false,
|
|
175
178
|
// Before the drag starts: otherwise the iframe swallows pointer moves and dnd-kit never sees them.
|
|
176
|
-
onDragPending: () => runtime.pointerLock.set(true), onDragAbort: () => runtime.pointerLock.set(false), onDragStart: onDragStart, onDragMove: onDragMove, onDragEnd: onDragEnd, onDragCancel: onDragCancel, children: _jsxs("div", { ref: rootRef, className: "builder-editor", children: [_jsx(TopBar, { icon: icon }), ready ? (_jsxs("div", { className: "builder-editor__body", children: [_jsx("aside", { className: "builder-editor__left", children: _jsx(LeftPanel, {}) }), _jsx(Splitter, { panel: "left", side: "before", onActive: lockPointer }), _jsx(Canvas, {}), _jsx(Splitter, { panel: "right", side: "after", onActive: lockPointer }), _jsx("aside", { className: "builder-editor__right", children: _jsx(Inspector, {}) })] })) : (_jsxs("div", { className: "builder-editor__body builder-editor__body--loading", "aria-busy": "true", "aria-label": "Loading the editor", children: [_jsxs("aside", { className: "builder-editor__left", children: [_jsx(ShimmerEffect, { height: "30px" }), _jsx(ShimmerEffect, { height: "240px" })] }), _jsx("div", { className: "builder-editor__stage", children: _jsx(ShimmerEffect, { height: "100%" }) }), _jsxs("aside", { className: "builder-editor__right", children: [_jsx(ShimmerEffect, { height: "34px" }), _jsx(ShimmerEffect, { height: "240px" })] })] })), _jsx(DragLayer, {}), _jsx(SectionDialog, {})] }) }) }));
|
|
179
|
+
onDragPending: () => runtime.pointerLock.set(true), onDragAbort: () => runtime.pointerLock.set(false), onDragStart: onDragStart, onDragMove: onDragMove, onDragEnd: onDragEnd, onDragCancel: onDragCancel, children: _jsxs("div", { ref: rootRef, className: "builder-editor", children: [_jsx(TopBar, { icon: icon }), ready ? (_jsxs("div", { className: "builder-editor__body", children: [_jsx("aside", { className: "builder-editor__left", children: _jsx(LeftPanel, {}) }), _jsx(Splitter, { panel: "left", side: "before", onActive: lockPointer }), _jsx(Canvas, {}), _jsx(Splitter, { panel: "right", side: "after", onActive: lockPointer }), _jsx("aside", { className: "builder-editor__right", children: _jsx(CommentsOrInspector, { children: _jsx(Inspector, {}) }) })] })) : (_jsxs("div", { className: "builder-editor__body builder-editor__body--loading", "aria-busy": "true", "aria-label": "Loading the editor", children: [_jsxs("aside", { className: "builder-editor__left", children: [_jsx(ShimmerEffect, { height: "30px" }), _jsx(ShimmerEffect, { height: "240px" })] }), _jsx("div", { className: "builder-editor__stage", children: _jsx(ShimmerEffect, { height: "100%" }) }), _jsxs("aside", { className: "builder-editor__right", children: [_jsx(ShimmerEffect, { height: "34px" }), _jsx(ShimmerEffect, { height: "240px" })] })] })), _jsx(DragLayer, {}), _jsx(SectionDialog, {})] }) }) }));
|
|
177
180
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import {
|
|
2
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
// The rich text toolbar shown over a rich text block while it is edited on the canvas. It lives
|
|
4
4
|
// in the admin overlay (Payload's look, never the site's CSS) and sends commands to the Lexical
|
|
5
5
|
// editor in the canvas iframe. Buttons keep the keyboard focus in the iframe (no focus on press).
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import {
|
|
3
|
-
import { CheckboxInput } from '@payloadcms/ui';
|
|
2
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { CheckboxInput, TextInput } from '@payloadcms/ui';
|
|
4
4
|
import { useDeferredValue, useEffect, useState } from 'react';
|
|
5
|
-
import { findBlock, getBlockDefinition } from '../../core/index.js';
|
|
5
|
+
import { blockParts, findBlock, getBlockDefinition, htmlIdProblem, htmlIdsOf } from '../../core/index.js';
|
|
6
6
|
import { BlockIcon, Icon } from './icons.js';
|
|
7
|
+
import { useContentMode } from './contentMode.js';
|
|
7
8
|
import { blockMenuEntries } from './menu/blockMenu.js';
|
|
8
9
|
import { MenuButton } from './menu/Menu.js';
|
|
9
10
|
import { renameRequest } from './menu/requests.js';
|
|
@@ -14,15 +15,19 @@ import { LocaleNote } from './locale/LocaleField.js';
|
|
|
14
15
|
import { MotionPanel } from './motion/MotionPanel.js';
|
|
15
16
|
import { AssistantPanel } from './assistant/AssistantPanel.js';
|
|
16
17
|
import { useAccessRefresh } from './fields/access.js';
|
|
18
|
+
import { InputError } from './fields/CheckedInputs.js';
|
|
17
19
|
import { BlockContentFields } from './renderField.js';
|
|
18
20
|
import { useRuntime } from './runtime.js';
|
|
19
21
|
import { storesBuilderData } from './actions.js';
|
|
20
22
|
import { shortcutList } from './shortcuts.js';
|
|
21
23
|
import { useEditor } from './store.js';
|
|
22
24
|
import { StylesPanel } from './styles/StylesPanel.js';
|
|
25
|
+
import { Select } from './ui/Select.js';
|
|
23
26
|
import { usePayloadControlNames } from './ui/payloadA11y.js';
|
|
24
27
|
import { useOptionalValue, useValue, useValueSelector } from './valueStore.js';
|
|
25
28
|
import { RegionPane } from './regions/RegionPane.js';
|
|
29
|
+
import { SECTION_REF_BLOCK } from '../../blocks/builtins/sectionRef.js';
|
|
30
|
+
import { ComponentBanner, ComponentValuesPanel } from './sections/ComponentFields.js';
|
|
26
31
|
function Tabs({ value, options, onChange, variant = 'underline' }) {
|
|
27
32
|
return (_jsx("div", { className: variant === 'segmented' ? 'builder-editor__segmented builder-editor__segmented--full' : 'builder-editor__tabs', role: "tablist", children: options.map((option) => (_jsxs("button", { type: "button", role: "tab", "aria-selected": value === option.id, className: variant === 'segmented' ? 'builder-editor__segment' : 'builder-editor__tab', onClick: () => onChange(option.id), children: [option.icon && _jsx(Icon, { name: option.icon, size: 13 }), option.label] }, option.id))) }));
|
|
28
33
|
}
|
|
@@ -39,7 +44,7 @@ export function Inspector() {
|
|
|
39
44
|
return (_jsxs("div", { ref: inspectorRef, className: "builder-editor__inspector", children: [runtime.assistant && (_jsx("div", { className: "builder-editor__inspector-head", children: _jsx(Tabs, { value: tab, onChange: setTab, variant: "segmented", options: [
|
|
40
45
|
{ id: 'block', label: 'Block' },
|
|
41
46
|
{ id: 'assistant', label: 'Assistant', icon: 'sparkle' },
|
|
42
|
-
] }) })),
|
|
47
|
+
] }) })), _jsxs("div", { className: "builder-editor__inspector-body", hidden: tab !== 'block', children: [_jsx(ComponentBanner, {}), _jsx(BlockPane, {})] }), runtime.assistant && _jsx(AssistantPanel, { hidden: tab !== 'assistant' })] }));
|
|
43
48
|
}
|
|
44
49
|
const TIP_LABELS = {
|
|
45
50
|
'Publish changes': 'Publish',
|
|
@@ -49,11 +54,48 @@ const TIP_LABELS = {
|
|
|
49
54
|
Undo: 'Undo',
|
|
50
55
|
'Show this list': 'All shortcuts',
|
|
51
56
|
};
|
|
57
|
+
/** The tips content mode keeps: the others add, copy or paste blocks. */
|
|
58
|
+
const CONTENT_TIPS = new Set(['Publish changes', 'Open or close the AI assistant', 'Undo', 'Show this list']);
|
|
52
59
|
function EmptyState() {
|
|
53
60
|
const runtime = useRuntime();
|
|
54
61
|
const drafts = useValueSelector(runtime.doc.meta, (meta) => meta.drafts);
|
|
55
|
-
const
|
|
56
|
-
|
|
62
|
+
const contentMode = useContentMode(runtime);
|
|
63
|
+
const tips = shortcutList({ ai: Boolean(runtime.assistant), publish: drafts }).filter((s) => s.label in TIP_LABELS && (!contentMode || s.label in CONTENT_TIPS));
|
|
64
|
+
return (_jsxs("div", { className: "builder-editor__empty builder-editor__empty--inspector", children: [_jsx(Icon, { name: "cursor", size: 20 }), _jsx("p", { children: "No block selected" }), _jsx("p", { className: "builder-editor__hint", children: contentMode
|
|
65
|
+
? 'Click a text, image or link on the canvas or in Layers to edit it.'
|
|
66
|
+
: 'Click a block on the canvas or in Layers to edit its content and styles. Drag blocks from the Blocks tab to build the page.' }), _jsx("dl", { className: "builder-editor__tips", children: tips.map(({ keys, label }) => (_jsxs("div", { className: "builder-editor__help-row", children: [_jsx("dt", { children: TIP_LABELS[label] }), _jsx("dd", { children: keys.map((k) => (_jsx("kbd", { children: k }, k))) })] }, label))) })] }));
|
|
67
|
+
}
|
|
68
|
+
const TAB_STORAGE_KEY = 'payload-builder:inspector-tab';
|
|
69
|
+
const BLOCK_TABS = ['content', 'styles', 'motion', 'advanced'];
|
|
70
|
+
/** The tab the user last chose, kept in this browser. Styles first, as in Webflow. */
|
|
71
|
+
function readTabChoice() {
|
|
72
|
+
try {
|
|
73
|
+
const value = localStorage.getItem(TAB_STORAGE_KEY);
|
|
74
|
+
return BLOCK_TABS.includes(value) ? value : 'styles';
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
return 'styles';
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
function saveTabChoice(tab) {
|
|
81
|
+
try {
|
|
82
|
+
localStorage.setItem(TAB_STORAGE_KEY, tab);
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
// Storage blocked: the choice lasts until the editor closes.
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
/** The tab a block opens on: the chosen tab, unless the block has nothing to show there. */
|
|
89
|
+
function tabFor(chosen, def, justAdded) {
|
|
90
|
+
const hasFields = (def?.fields.length ?? 0) > 0;
|
|
91
|
+
// A block that was just added opens on its content, so typing starts at once.
|
|
92
|
+
if (justAdded && hasFields)
|
|
93
|
+
return 'content';
|
|
94
|
+
if (chosen !== 'content' && def?.styles === false)
|
|
95
|
+
return 'content';
|
|
96
|
+
if (chosen === 'content' && !hasFields && def?.styles !== false)
|
|
97
|
+
return 'styles';
|
|
98
|
+
return chosen;
|
|
57
99
|
}
|
|
58
100
|
function BlockPane() {
|
|
59
101
|
const runtime = useRuntime();
|
|
@@ -64,21 +106,25 @@ function BlockPane() {
|
|
|
64
106
|
const shownId = useDeferredValue(selectedId);
|
|
65
107
|
// The block in the editor's locale: the inspector shows and edits that locale's values.
|
|
66
108
|
const block = useEditor(runtime.store, (s) => (shownId ? findBlock(s.view, shownId) : null));
|
|
67
|
-
|
|
68
|
-
const [
|
|
109
|
+
// The user's tab stays chosen across blocks and visits, like Webflow's Style panel.
|
|
110
|
+
const [chosen, setChosen] = useState(() => (typeof window === 'undefined' ? 'styles' : readTabChoice()));
|
|
69
111
|
const focusRequest = useValue(runtime.focusRequest);
|
|
70
112
|
// A selected page region shows its own pane.
|
|
71
113
|
const region = useOptionalValue(runtime.regions?.selected ?? null);
|
|
72
|
-
//
|
|
73
|
-
//
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
114
|
+
// A block that was just added keeps its content open while it stays selected, also after the
|
|
115
|
+
// focus request clears.
|
|
116
|
+
const [addedId, setAddedId] = useState(null);
|
|
117
|
+
if (block && focusRequest === block.id && addedId !== block.id)
|
|
118
|
+
setAddedId(block.id);
|
|
119
|
+
const def = block ? getBlockDefinition(runtime.config.blocks, block.type) : undefined;
|
|
120
|
+
// Content mode edits content only: no Styles, Motion or Advanced tab.
|
|
121
|
+
const contentMode = useContentMode(runtime);
|
|
122
|
+
const tab = storesBuilderData(runtime) && !contentMode ? tabFor(chosen, def, block !== null && block.id === addedId) : 'content';
|
|
123
|
+
const setTab = (next) => {
|
|
124
|
+
setAddedId(null);
|
|
125
|
+
setChosen(next);
|
|
126
|
+
saveTabChoice(next);
|
|
127
|
+
};
|
|
82
128
|
// A block that was just added: focus its first content field.
|
|
83
129
|
useEffect(() => {
|
|
84
130
|
if (!block || focusRequest !== block.id)
|
|
@@ -94,14 +140,15 @@ function BlockPane() {
|
|
|
94
140
|
}, [block, focusRequest, runtime]);
|
|
95
141
|
if (!block)
|
|
96
142
|
return region && runtime.regions ? _jsx(RegionPane, { regions: runtime.regions, name: region }, region) : _jsx(EmptyState, {});
|
|
97
|
-
return (_jsxs("div", { className: "builder-editor__block-pane", children: [_jsx(BlockHeader, { block: block }), _jsx(BlockProblems, { blockId: block.id }), _jsx(EditingBanner, { blockId: block.id }), _jsx(LocaleNote, { blockId: block.id, tab: tab }), _jsx(Tabs, { value: tab, onChange: setTab, options: storesBuilderData(runtime)
|
|
143
|
+
return (_jsxs("div", { className: "builder-editor__block-pane", children: [_jsx(BlockHeader, { block: block }), _jsx(BlockProblems, { blockId: block.id }), _jsx(EditingBanner, { blockId: block.id }), _jsx(LocaleNote, { blockId: block.id, tab: tab }), !contentMode && (_jsx(Tabs, { value: tab, onChange: setTab, options: storesBuilderData(runtime)
|
|
98
144
|
? [
|
|
99
145
|
{ id: 'content', label: 'Content' },
|
|
100
146
|
{ id: 'styles', label: 'Styles' },
|
|
101
147
|
{ id: 'motion', label: 'Motion' },
|
|
148
|
+
{ id: 'advanced', label: 'Advanced' },
|
|
102
149
|
]
|
|
103
150
|
: // A Payload blocks field holds the blocks' own fields only.
|
|
104
|
-
[{ id: 'content', label: 'Content' }] }), tab === 'content' && _jsx(BlockContentFields, { block: block }), tab === 'styles' && storesBuilderData(runtime) && _jsx(StyleFields, { block: block }), tab === 'motion' && storesBuilderData(runtime) && _jsx(MotionPanel, { blockId: block.id, blockType: block.type, motion: block.motion })] }, block.id));
|
|
151
|
+
[{ id: 'content', label: 'Content' }] })), tab === 'content' && _jsx(BlockContentFields, { block: block }), tab === 'content' && block.type === SECTION_REF_BLOCK && _jsx(ComponentValuesPanel, { block: block }), tab === 'styles' && storesBuilderData(runtime) && _jsx(StyleFields, { block: block }), tab === 'motion' && storesBuilderData(runtime) && _jsx(MotionPanel, { blockId: block.id, blockType: block.type, motion: block.motion }), tab === 'advanced' && storesBuilderData(runtime) && _jsx(AdvancedFields, { block: block })] }, block.id));
|
|
105
152
|
}
|
|
106
153
|
/** What stopped the last publish, for this block. */
|
|
107
154
|
function BlockProblems({ blockId }) {
|
|
@@ -116,7 +163,9 @@ function BlockHeader({ block }) {
|
|
|
116
163
|
const [renamingHere, setRenaming] = useState(false);
|
|
117
164
|
// "Rename" in a block menu (or F2 outside the outline) renames here.
|
|
118
165
|
const requested = useValueSelector(renameRequest(runtime), (r) => r?.where === 'inspector' && r.id === block.id);
|
|
119
|
-
|
|
166
|
+
// Content mode does not rename blocks.
|
|
167
|
+
const contentMode = useContentMode(runtime);
|
|
168
|
+
const renaming = !contentMode && (renamingHere || requested);
|
|
120
169
|
const endRename = () => {
|
|
121
170
|
setRenaming(false);
|
|
122
171
|
if (requested)
|
|
@@ -129,10 +178,53 @@ function BlockHeader({ block }) {
|
|
|
129
178
|
// repeat the "Content" tab right below.
|
|
130
179
|
const sub = block.label ? kind : null;
|
|
131
180
|
const tag = typeof block.props?.as === 'string' && block.props.as !== 'div' ? `<${block.props.as}>` : null;
|
|
132
|
-
return (_jsxs("div", { className: "builder-editor__block-head", children: [_jsx("span", { className: "builder-editor__block-icon", children: _jsx(BlockIcon, { name: runtime.blockIcon(block.type), size: 16 }) }), _jsxs("span", { className: "builder-editor__block-name", children: [renaming ? (_jsx(RenameInput, { block: block, placeholder: kind, onDone: endRename })) : (_jsx("button", { type: "button", className: "builder-editor__block-title", "aria-label": `${name}. Rename the block`, "data-tooltip": "Rename", onClick: () => setRenaming(true), children: name })), (sub || tag) && (_jsxs("span", { className: "builder-editor__block-sub", children: [sub, sub && tag ? ' · ' : '', tag && _jsx("code", { children: tag })] }))] }), block.hidden && (_jsxs("span", { className: "builder-editor__pill", "data-tooltip": "Hidden on the site", children: [_jsx(Icon, { name: "eyeOff", size: 12 }), " Hidden"] })), _jsx(MenuButton, { className: "builder-editor__icon-button", triggerLabel: "More actions", tooltip: "More actions", label: "Block actions", items: () => blockMenuEntries(runtime, block.id, 'inspector'), footer: _jsxs(_Fragment, { children: ["Block ID ", _jsx("code", { children: block.id })] }), children: _jsx(Icon, { name: "more" }) })] }));
|
|
181
|
+
return (_jsxs("div", { className: "builder-editor__block-head", children: [_jsx("span", { className: "builder-editor__block-icon", children: _jsx(BlockIcon, { name: runtime.blockIcon(block.type), size: 16 }) }), _jsxs("span", { className: "builder-editor__block-name", children: [renaming ? (_jsx(RenameInput, { block: block, placeholder: kind, onDone: endRename })) : contentMode ? (_jsx("span", { className: "builder-editor__block-title", children: name })) : (_jsx("button", { type: "button", className: "builder-editor__block-title", "aria-label": `${name}. Rename the block`, "data-tooltip": "Rename", onClick: () => setRenaming(true), children: name })), (sub || tag) && (_jsxs("span", { className: "builder-editor__block-sub", children: [sub, sub && tag ? ' · ' : '', tag && _jsx("code", { children: tag })] }))] }), block.hidden && (_jsxs("span", { className: "builder-editor__pill", "data-tooltip": "Hidden on the site", children: [_jsx(Icon, { name: "eyeOff", size: 12 }), " Hidden"] })), _jsx(MenuButton, { className: "builder-editor__icon-button", triggerLabel: "More actions", tooltip: "More actions", label: "Block actions", items: () => blockMenuEntries(runtime, block.id, 'inspector'), footer: _jsxs(_Fragment, { children: ["Block ID ", _jsx("code", { children: block.id })] }), children: _jsx(Icon, { name: "more" }) })] }));
|
|
133
182
|
}
|
|
134
183
|
function StyleFields({ block }) {
|
|
135
184
|
const runtime = useRuntime();
|
|
136
185
|
const def = getBlockDefinition(runtime.config.blocks, block.type);
|
|
137
|
-
|
|
186
|
+
// The block's parts (styled slots and `parts` entries) are style targets next to the block.
|
|
187
|
+
const parts = blockParts(def);
|
|
188
|
+
const [target, setTarget] = useState(null);
|
|
189
|
+
const part = target && parts.some(({ name }) => name === target) ? target : null;
|
|
190
|
+
const blockStyles = def?.styles !== false;
|
|
191
|
+
return (_jsxs("div", { className: "builder-editor__fields", children: [parts.length > 0 && (_jsx(Select, { "aria-label": "Style target", emptyLabel: blockStyles ? 'This block' : undefined, placeholder: "Pick a part", value: part, onValueChange: setTarget, options: parts.map(({ name, label }) => ({
|
|
192
|
+
value: name,
|
|
193
|
+
label,
|
|
194
|
+
...(block.partClassName?.[name] ? { suffix: _jsx("span", { className: "builder-styles__dot", "aria-label": "has classes" }) } : {}),
|
|
195
|
+
})) })), part ? (_jsx(StylesPanel, { block: block, part: part }, part)) : !blockStyles ? (_jsx("p", { className: "builder-editor__hint", children: "This block has no style controls." })) : (_jsx(StylesPanel, { block: block }))] }));
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* The block's HTML attributes (`block.attrs`): an id for "#id" links, an ARIA label and
|
|
199
|
+
* aria-hidden. The id is stored only when it is valid and no other block of the page has it.
|
|
200
|
+
*/
|
|
201
|
+
function AdvancedFields({ block }) {
|
|
202
|
+
const runtime = useRuntime();
|
|
203
|
+
const def = getBlockDefinition(runtime.config.blocks, block.type);
|
|
204
|
+
const layout = useEditor(runtime.store, (s) => s.layout);
|
|
205
|
+
const stored = block.attrs?.id ?? '';
|
|
206
|
+
// `source` is the stored id the draft belongs to: another stored id (undo, AI edit) replaces the draft.
|
|
207
|
+
const [draft, setDraft] = useState({ text: stored, source: stored });
|
|
208
|
+
if (draft.source !== stored)
|
|
209
|
+
setDraft({ text: stored, source: stored });
|
|
210
|
+
const idProblem = (text) => {
|
|
211
|
+
if (!text)
|
|
212
|
+
return null;
|
|
213
|
+
const owner = htmlIdsOf(layout.blocks).get(text);
|
|
214
|
+
if (owner && owner !== block.id)
|
|
215
|
+
return `Another block of this page has the id "${text}".`;
|
|
216
|
+
return htmlIdProblem(text);
|
|
217
|
+
};
|
|
218
|
+
const problem = idProblem(draft.text.trim());
|
|
219
|
+
const setAttr = (attrs) => runtime.store.apply({ type: 'update', id: block.id, attrs });
|
|
220
|
+
return (_jsxs("div", { className: "builder-editor__fields", children: [_jsxs("div", { children: [_jsx(TextInput, { description: 'Links to this block with "#id", for example "contact".', label: "HTML id", onChange: (e) => {
|
|
221
|
+
const text = e.target.value;
|
|
222
|
+
const id = text.trim();
|
|
223
|
+
if (id === stored || idProblem(id)) {
|
|
224
|
+
setDraft({ text, source: stored });
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
setDraft({ text, source: id });
|
|
228
|
+
setAttr({ id: id || null });
|
|
229
|
+
}, path: `builder.${block.id}.attrs.id`, showError: problem !== null, value: draft.text }), problem && _jsx(InputError, { children: problem })] }), _jsx(TextInput, { description: "The name screen readers read, for example for a link that shows only an icon.", label: "ARIA label", onChange: (e) => setAttr({ ariaLabel: e.target.value || null }), path: `builder.${block.id}.attrs.ariaLabel`, value: block.attrs?.ariaLabel ?? '' }), _jsxs("div", { children: [_jsx(CheckboxInput, { id: `builder-${block.id}-hidden`, name: `builder.${block.id}.hidden`, label: "Hide at all screen sizes", checked: block.hidden === true, onToggle: (e) => runtime.store.apply({ type: 'update', id: block.id, hidden: e.target.checked }) }), _jsx("p", { className: "field-description", children: "The site does not show this block. To hide it on some screens only, open Styles, pick a screen size, and set Display to Hidden. That hides it at this size and wider." })] }), def?.slots && Object.keys(def.slots).length > 0 && (_jsxs("div", { children: [_jsx(CheckboxInput, { id: `builder-${block.id}-editable-items`, name: `builder.${block.id}.editableItems`, label: "Editors can add, remove and reorder its items", checked: block.editableItems === true, onToggle: (e) => runtime.store.apply({ type: 'update', id: block.id, editableItems: e.target.checked }) }), _jsx("p", { className: "field-description", children: "For lists like FAQs or team cards. Editors can copy, delete and reorder the items, but not restyle them." })] })), _jsx(CheckboxInput, { id: `builder-${block.id}-aria-hidden`, name: `builder.${block.id}.attrs.ariaHidden`, label: "Hide from screen readers", checked: block.attrs?.ariaHidden === true, onToggle: (e) => setAttr({ ariaHidden: e.target.checked || null }) })] }));
|
|
138
230
|
}
|
|
@@ -4,13 +4,16 @@ import { useDraggable } from '@dnd-kit/core';
|
|
|
4
4
|
import { useConfig, useRouteTransition } from '@payloadcms/ui';
|
|
5
5
|
import { useRouter } from 'next/navigation';
|
|
6
6
|
import { memo, useDeferredValue, useEffect, useMemo, useRef, useState } from 'react';
|
|
7
|
+
import { isComponent } from '../../core/components.js';
|
|
8
|
+
import { sectionVersion, sectionVersions } from '../../core/sections.js';
|
|
7
9
|
import { builderViewPath } from '../../plugin/links.js';
|
|
8
|
-
import { insertBlocks, insertNewBlock, sectionPosition } from './actions.js';
|
|
10
|
+
import { componentCopy, insertBlocks, insertNewBlock, plainSectionBlocks, sectionPosition } from './actions.js';
|
|
9
11
|
import { BlockIcon, Icon } from './icons.js';
|
|
10
12
|
import { MenuButton } from './menu/Menu.js';
|
|
11
13
|
import { useRuntime } from './runtime.js';
|
|
12
14
|
import { requestDeleteSection, requestRenameSection } from './sections/SectionDialog.js';
|
|
13
15
|
import { useSectionThumbnail } from './sections/useThumbnail.js';
|
|
16
|
+
import { VariantArrows } from './sections/variants.js';
|
|
14
17
|
import { useValue } from './valueStore.js';
|
|
15
18
|
const BLOCK_CATEGORIES = ['Layout', 'Content', 'Media', 'Interactive', 'Dynamic'];
|
|
16
19
|
const SECTION_CATEGORIES = ['Heroes', 'Features', 'Content', 'Social proof', 'Calls to action', 'Contact', 'Navigation'];
|
|
@@ -62,7 +65,7 @@ const BlockList = memo(function BlockList({ query }) {
|
|
|
62
65
|
const groups = useMemo(() => groupBy(
|
|
63
66
|
// Blocks with `parents` (e.g. a list item) only fit inside their parent: the "+" picker
|
|
64
67
|
// offers them there, so the library leaves them out.
|
|
65
|
-
config.blocks.filter((def) => !def.parents && matches(query, def.label, def.type, def.category, def.ai?.description)), BLOCK_CATEGORIES), [config.blocks, query]);
|
|
68
|
+
config.blocks.filter((def) => !def.parents && matches(query, def.label, def.type, def.category, def.description, def.ai?.description)), BLOCK_CATEGORIES), [config.blocks, query]);
|
|
66
69
|
if (groups.length === 0)
|
|
67
70
|
return _jsx(NoMatches, { query: query });
|
|
68
71
|
return groups.map(([category, defs]) => (_jsx(Group, { title: category, children: _jsx("div", { className: "builder-editor__tiles", children: defs.map((def) => (_jsx(BlockTile, { def: def }, def.type))) }) }, category)));
|
|
@@ -73,7 +76,7 @@ function BlockTile({ def }) {
|
|
|
73
76
|
const data = { source: { kind: 'new', blockType: def.type }, label: def.label, icon };
|
|
74
77
|
const { setNodeRef, listeners, attributes } = useDraggable({ id: `library:${def.type}`, data });
|
|
75
78
|
const insert = () => insertNewBlock(runtime, def.type);
|
|
76
|
-
return (_jsxs("button", { ref: setNodeRef, type: "button", className: "builder-editor__tile", "data-tooltip": def.
|
|
79
|
+
return (_jsxs("button", { ref: setNodeRef, type: "button", className: "builder-editor__tile", "data-tooltip": def.description ?? def.label, onClick: insert, ...listeners, ...attributes, children: [_jsx("span", { className: "builder-editor__tile-icon", children: _jsx(BlockIcon, { name: icon, size: 18 }) }), _jsx("span", { className: "builder-editor__tile-label", children: def.label })] }));
|
|
77
80
|
}
|
|
78
81
|
const SectionList = memo(function SectionList({ query }) {
|
|
79
82
|
const { config, sections: controller } = useRuntime();
|
|
@@ -89,7 +92,7 @@ const SectionList = memo(function SectionList({ query }) {
|
|
|
89
92
|
}, [controller]);
|
|
90
93
|
const groups = useMemo(() => {
|
|
91
94
|
const own = (saved ?? []).filter((s) => matches(query, s.label, s.category, SAVED));
|
|
92
|
-
const rest = groupBy(builtIn.filter((s) => matches(query, s.label, s.description, s.category)), SECTION_CATEGORIES);
|
|
95
|
+
const rest = groupBy(builtIn.filter((s) => matches(query, s.label, s.description, s.category, ...(s.variants ?? []).map((v) => v.label))), SECTION_CATEGORIES);
|
|
93
96
|
return own.length > 0 ? [[SAVED, own], ...rest] : rest;
|
|
94
97
|
}, [builtIn, saved, query]);
|
|
95
98
|
if (builtIn.length === 0 && (saved?.length ?? 0) === 0) {
|
|
@@ -105,44 +108,66 @@ export function SectionThumb({ section }) {
|
|
|
105
108
|
const picture = useSectionThumbnail(section, thumbRef);
|
|
106
109
|
return (_jsx("span", { ref: thumbRef, className: `builder-editor__thumb${picture ? ' builder-editor__thumb--picture' : ''}`, "aria-hidden": "true", children: picture ? (_jsx("img", { className: "builder-editor__thumb-img", src: picture, alt: "", draggable: false })) : (_jsx("span", { className: "builder-editor__thumb-inner", children: section.blocks.map((block) => (_jsx(Wire, { block: block }, block.id))) })) }));
|
|
107
110
|
}
|
|
111
|
+
/**
|
|
112
|
+
* One card per section. A section with variants gets ‹ 2 / 3 › arrows that flip the card between
|
|
113
|
+
* its versions; a click or a drag inserts the version shown.
|
|
114
|
+
*/
|
|
108
115
|
function SectionCard({ section }) {
|
|
109
116
|
const runtime = useRuntime();
|
|
110
|
-
const
|
|
117
|
+
const versions = useMemo(() => sectionVersions(section), [section]);
|
|
118
|
+
const [index, setIndex] = useState(0);
|
|
119
|
+
const at = Math.min(index, versions.length - 1);
|
|
120
|
+
// The version shown, ready to insert: its root block remembers the section and the variant.
|
|
121
|
+
const shown = useMemo(() => sectionVersion(section, versions[at]?.variant) ?? section, [section, versions, at]);
|
|
111
122
|
const isSaved = section.savedId !== undefined;
|
|
123
|
+
// A saved section with properties is a component: it goes in as a copy that stays in sync.
|
|
124
|
+
const copy = useMemo(() => (isComponent(section.blocks) ? componentCopy(section) : null), [section]);
|
|
125
|
+
const blocks = useMemo(() => (copy ? [copy] : isSaved ? plainSectionBlocks(runtime, shown.blocks) : shown.blocks), [copy, isSaved, runtime, shown.blocks]);
|
|
126
|
+
const root = blocks[0];
|
|
112
127
|
const data = {
|
|
113
128
|
// Drop rules check the root block's type.
|
|
114
129
|
source: { kind: 'new', blockType: root?.type ?? 'stack' },
|
|
115
|
-
label:
|
|
116
|
-
icon: 'section',
|
|
117
|
-
blocks
|
|
130
|
+
label: shown.label,
|
|
131
|
+
icon: copy ? 'component' : 'section',
|
|
132
|
+
blocks,
|
|
118
133
|
};
|
|
119
134
|
const { setNodeRef, listeners, attributes } = useDraggable({ id: `section:${section.id}`, data, disabled: !root });
|
|
120
135
|
const insert = () => {
|
|
121
|
-
if (insertBlocks(runtime,
|
|
122
|
-
runtime.notify(`Added ${
|
|
136
|
+
if (insertBlocks(runtime, blocks, sectionPosition(runtime)))
|
|
137
|
+
runtime.notify(`Added ${shown.label}`);
|
|
123
138
|
};
|
|
124
|
-
|
|
139
|
+
// Versions flip in place: the card keeps one height (one label line, two description lines).
|
|
140
|
+
const flips = versions.length > 1;
|
|
141
|
+
const description = isSaved ? section.category : shown.description;
|
|
142
|
+
return (_jsxs("div", { className: "builder-editor__card-wrap", "data-versions": flips || undefined, children: [_jsxs("button", { ref: setNodeRef, type: "button", className: "builder-editor__card", "data-tooltip": `Add ${shown.label}`, onClick: insert, ...listeners, ...attributes, children: [_jsx(SectionThumb, { section: shown }), _jsxs("span", { className: "builder-editor__card-text", children: [_jsxs("span", { className: "builder-editor__card-label", children: [copy && _jsx(Icon, { name: "component", size: 12, className: "builder-editor__card-component" }), shown.label] }), (description || copy || (flips && versions.some((v) => v.description))) && (_jsx("span", { className: "builder-editor__card-desc", children: description ?? (copy ? 'Component' : undefined) }))] })] }), flips && (_jsx(VariantArrows, { count: versions.length, index: at, text: `${at + 1} / ${versions.length}`, label: `${section.label} versions`, className: "builder-variants--card", onChange: setIndex })), isSaved && _jsx(SavedSectionMenu, { section: section, component: copy !== null })] }));
|
|
125
143
|
}
|
|
126
144
|
/** The builder URL that edits a saved section, with `from` (this page) for its Back button. */
|
|
127
145
|
export function editSectionPath(adminRoute, collection, id, from) {
|
|
128
146
|
return `${builderViewPath(adminRoute, collection, id)}?from=${encodeURIComponent(from)}`;
|
|
129
147
|
}
|
|
130
148
|
/** Edit, rename and delete for a saved section. */
|
|
131
|
-
function SavedSectionMenu({ section }) {
|
|
149
|
+
function SavedSectionMenu({ section, component }) {
|
|
132
150
|
const runtime = useRuntime();
|
|
133
151
|
const router = useRouter();
|
|
134
152
|
const { startRouteTransition } = useRouteTransition();
|
|
135
153
|
const { config: { routes }, } = useConfig();
|
|
136
154
|
const collection = runtime.config.savedSections?.collection;
|
|
137
|
-
|
|
155
|
+
const addSaved = (blocks) => {
|
|
156
|
+
if (insertBlocks(runtime, blocks, sectionPosition(runtime)))
|
|
157
|
+
runtime.notify(`Added ${section.label}`);
|
|
158
|
+
};
|
|
159
|
+
// Opens the section in the full-screen builder, like a page.
|
|
138
160
|
const edit = () => {
|
|
139
161
|
if (!collection || section.savedId === undefined)
|
|
140
162
|
return;
|
|
141
163
|
const href = editSectionPath(routes.admin, collection, section.savedId, `${window.location.pathname}${window.location.search}`);
|
|
142
164
|
startRouteTransition(() => router.push(href));
|
|
143
165
|
};
|
|
144
|
-
return (_jsx(MenuButton, { className: "builder-editor__icon-button builder-editor__icon-button--small builder-editor__card-more", triggerLabel: `Actions for ${section.label}`, tooltip: "Edit, rename or delete", label: "Saved section actions", footer:
|
|
145
|
-
...(collection ? [{ icon: 'compose', label: 'Edit section', run: edit }] : []),
|
|
166
|
+
return (_jsx(MenuButton, { className: "builder-editor__icon-button builder-editor__icon-button--small builder-editor__card-more", triggerLabel: `Actions for ${section.label}`, tooltip: "Edit, rename or delete", label: "Saved section actions", footer: component ? 'Changes show on every copy.' : 'Pages that use this section keep their own copy.', items: () => [
|
|
167
|
+
...(collection ? [{ icon: 'compose', label: component ? 'Edit component' : 'Edit section', run: edit }] : []),
|
|
168
|
+
component
|
|
169
|
+
? { icon: 'section', label: 'Add as plain blocks', run: () => addSaved(plainSectionBlocks(runtime, section.blocks)) }
|
|
170
|
+
: { icon: 'sectionRef', label: 'Add a copy that stays in sync', run: () => addSaved([componentCopy(section)]) },
|
|
146
171
|
{ icon: 'rename', label: 'Rename…', ownFocus: true, run: () => requestRenameSection(runtime, section) },
|
|
147
172
|
{ icon: 'delete', label: 'Delete…', ownFocus: true, danger: true, run: () => requestDeleteSection(runtime, section) },
|
|
148
173
|
], children: _jsx(Icon, { name: "more", size: 14 }) }));
|