payload-canvas 0.4.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +626 -154
- package/dist/admin/AiKeyField.d.ts +8 -0
- package/dist/admin/AiKeyField.js +54 -0
- package/dist/admin/BuilderTab.js +4 -1
- package/dist/admin/DocumentEditView.d.ts +9 -0
- package/dist/admin/DocumentEditView.js +45 -0
- package/dist/admin/LayoutField.d.ts +2 -2
- package/dist/admin/LayoutField.js +10 -7
- package/dist/admin/TemplateConditionsField.d.ts +9 -0
- package/dist/admin/TemplateConditionsField.js +22 -0
- package/dist/admin/aiKeyField.scss +58 -0
- package/dist/admin/client.d.ts +3 -0
- package/dist/admin/client.js +6 -0
- package/dist/admin/diff/changes.js +5 -0
- package/dist/admin/editor/Canvas.js +20 -5
- package/dist/admin/editor/Editor.d.ts +3 -1
- package/dist/admin/editor/Editor.js +6 -3
- package/dist/admin/editor/Inspector.js +75 -28
- package/dist/admin/editor/Library.js +40 -15
- package/dist/admin/editor/Outline.js +21 -16
- package/dist/admin/editor/Overlay.js +8 -3
- package/dist/admin/editor/actions.d.ts +10 -2
- package/dist/admin/editor/actions.js +18 -3
- package/dist/admin/editor/assistant/AssistantPanel.js +3 -1
- package/dist/admin/editor/classes/ClassManager.d.ts +4 -0
- package/dist/admin/editor/classes/ClassManager.js +56 -0
- package/dist/admin/editor/classes/controller.d.ts +112 -0
- package/dist/admin/editor/classes/controller.js +326 -0
- package/dist/admin/editor/classes/manager.scss +262 -0
- package/dist/admin/editor/classes/managerModel.d.ts +5 -0
- package/dist/admin/editor/classes/managerModel.js +27 -0
- package/dist/admin/editor/comments/CommentLayer.d.ts +2 -0
- package/dist/admin/editor/comments/CommentLayer.js +143 -0
- package/dist/admin/editor/comments/CommentsPanel.d.ts +8 -0
- package/dist/admin/editor/comments/CommentsPanel.js +73 -0
- package/dist/admin/editor/comments/Thread.d.ts +26 -0
- package/dist/admin/editor/comments/Thread.js +84 -0
- package/dist/admin/editor/comments/comments.scss +539 -0
- package/dist/admin/editor/comments/controller.d.ts +48 -0
- package/dist/admin/editor/comments/controller.js +142 -0
- package/dist/admin/editor/contentMode.d.ts +17 -0
- package/dist/admin/editor/contentMode.js +37 -0
- package/dist/admin/editor/dnd/DropOutlines.d.ts +1 -0
- package/dist/admin/editor/dnd/DropOutlines.js +73 -0
- package/dist/admin/editor/dnd/dnd.scss +43 -0
- package/dist/admin/editor/dnd/mode.d.ts +4 -0
- package/dist/admin/editor/dnd/mode.js +39 -0
- package/dist/admin/editor/editor.scss +13 -58
- package/dist/admin/editor/empty/EmptyStart.js +18 -66
- package/dist/admin/editor/fields/AddButton.d.ts +15 -0
- package/dist/admin/editor/fields/AddButton.js +14 -0
- package/dist/admin/editor/fields/ArrayField.js +3 -2
- package/dist/admin/editor/fields/CheckedInputs.d.ts +1 -0
- package/dist/admin/editor/fields/ConditionRows.d.ts +19 -0
- package/dist/admin/editor/fields/ConditionRows.js +137 -0
- package/dist/admin/editor/fields/ListWhereField.d.ts +8 -0
- package/dist/admin/editor/fields/ListWhereField.js +20 -0
- package/dist/admin/editor/fields/QueryFiltersField.d.ts +18 -0
- package/dist/admin/editor/fields/QueryFiltersField.js +41 -0
- package/dist/admin/editor/fields/RelatedField.d.ts +19 -0
- package/dist/admin/editor/fields/RelatedField.js +44 -0
- package/dist/admin/editor/fields/SortField.d.ts +13 -0
- package/dist/admin/editor/fields/SortField.js +37 -0
- package/dist/admin/editor/fields/WhereField.d.ts +12 -4
- package/dist/admin/editor/fields/WhereField.js +33 -53
- package/dist/admin/editor/fields/collectionFields.d.ts +6 -0
- package/dist/admin/editor/fields/collectionFields.js +15 -0
- package/dist/admin/editor/fields/conditions.d.ts +99 -0
- package/dist/admin/editor/fields/conditions.js +339 -0
- package/dist/admin/editor/fields/fields.scss +232 -9
- package/dist/admin/editor/fields/listOptions.d.ts +44 -0
- package/dist/admin/editor/fields/listOptions.js +111 -0
- package/dist/admin/editor/fields/queryFilterRows.d.ts +8 -0
- package/dist/admin/editor/fields/queryFilterRows.js +29 -0
- package/dist/admin/editor/fields/whereRows.d.ts +11 -12
- package/dist/admin/editor/fields/whereRows.js +83 -34
- package/dist/admin/editor/icons.d.ts +16 -1
- package/dist/admin/editor/icons.js +30 -1
- package/dist/admin/editor/inline.js +9 -0
- package/dist/admin/editor/insert/InsertHandle.js +4 -1
- package/dist/admin/editor/insert/picker.d.ts +3 -1
- package/dist/admin/editor/insert/picker.js +17 -10
- package/dist/admin/editor/insert/spots.d.ts +12 -1
- package/dist/admin/editor/insert/spots.js +49 -10
- package/dist/admin/editor/layout/LeftPanel.js +11 -6
- package/dist/admin/editor/live/useMultiplayer.js +9 -1
- package/dist/admin/editor/menu/blockMenu.js +27 -17
- package/dist/admin/editor/names.js +11 -3
- package/dist/admin/editor/renderField.d.ts +3 -1
- package/dist/admin/editor/renderField.js +63 -12
- package/dist/admin/editor/runtime.d.ts +14 -0
- package/dist/admin/editor/runtime.js +67 -6
- package/dist/admin/editor/sections/ComponentFields.d.ts +8 -0
- package/dist/admin/editor/sections/ComponentFields.js +116 -0
- package/dist/admin/editor/sections/PropertyControls.d.ts +18 -0
- package/dist/admin/editor/sections/PropertyControls.js +65 -0
- package/dist/admin/editor/sections/components.d.ts +29 -0
- package/dist/admin/editor/sections/components.js +112 -0
- package/dist/admin/editor/sections/components.scss +238 -0
- package/dist/admin/editor/sections/variants.d.ts +32 -0
- package/dist/admin/editor/sections/variants.js +59 -0
- package/dist/admin/editor/sections/variants.scss +90 -0
- package/dist/admin/editor/shortcuts.d.ts +4 -1
- package/dist/admin/editor/shortcuts.js +19 -3
- package/dist/admin/editor/store.d.ts +18 -0
- package/dist/admin/editor/store.js +46 -0
- package/dist/admin/editor/styles/ClassBar.d.ts +14 -0
- package/dist/admin/editor/styles/ClassBar.js +90 -0
- package/dist/admin/editor/styles/ClassCss.d.ts +4 -0
- package/dist/admin/editor/styles/ClassCss.js +28 -0
- package/dist/admin/editor/styles/ClassDialog.d.ts +2 -0
- package/dist/admin/editor/styles/ClassDialog.js +151 -0
- package/dist/admin/editor/styles/ColorPicker.js +5 -2
- package/dist/admin/editor/styles/RawClasses.d.ts +26 -1
- package/dist/admin/editor/styles/RawClasses.js +184 -32
- package/dist/admin/editor/styles/StylesPanel.d.ts +3 -3
- package/dist/admin/editor/styles/StylesPanel.js +53 -14
- package/dist/admin/editor/styles/VariantBar.js +2 -2
- package/dist/admin/editor/styles/classEdit.d.ts +4 -0
- package/dist/admin/editor/styles/classEdit.js +20 -0
- package/dist/admin/editor/styles/classes.scss +381 -0
- package/dist/admin/editor/styles/context.d.ts +19 -6
- package/dist/admin/editor/styles/context.js +24 -6
- package/dist/admin/editor/styles/controls.d.ts +3 -1
- package/dist/admin/editor/styles/controls.js +30 -12
- package/dist/admin/editor/styles/popover.d.ts +6 -0
- package/dist/admin/editor/styles/popover.js +5 -5
- package/dist/admin/editor/styles/styles.scss +26 -104
- package/dist/admin/editor/styles/suggestions.d.ts +22 -0
- package/dist/admin/editor/styles/suggestions.js +77 -0
- package/dist/admin/editor/styles/tokens.js +14 -0
- package/dist/admin/editor/templates/Bindable.js +86 -57
- package/dist/admin/editor/templates/SamplePicker.js +1 -1
- package/dist/admin/editor/templates/Visibility.d.ts +9 -0
- package/dist/admin/editor/templates/Visibility.js +54 -0
- package/dist/admin/editor/templates/binding.d.ts +2 -2
- package/dist/admin/editor/templates/binding.js +2 -2
- package/dist/admin/editor/templates/templates.scss +27 -0
- package/dist/admin/editor/templates/visibilityRows.d.ts +22 -0
- package/dist/admin/editor/templates/visibilityRows.js +83 -0
- package/dist/admin/editor/topbar/ContentModeToggle.d.ts +5 -0
- package/dist/admin/editor/topbar/ContentModeToggle.js +26 -0
- package/dist/admin/editor/topbar/DocumentActions.d.ts +1 -1
- package/dist/admin/editor/topbar/DocumentActions.js +5 -4
- package/dist/admin/editor/topbar/DocumentTitle.js +7 -2
- package/dist/admin/editor/topbar/TopBar.js +15 -3
- package/dist/admin/editor/topbar/contentMode.scss +35 -0
- package/dist/admin/editor/topbar/topbar.scss +3 -1
- package/dist/admin/formChoice.d.ts +3 -0
- package/dist/admin/formChoice.js +10 -0
- package/dist/admin/layoutField.scss +69 -0
- package/dist/admin/screen/BuilderScreen.d.ts +6 -1
- package/dist/admin/screen/BuilderScreen.js +4 -3
- package/dist/admin/server/BuilderView.js +10 -3
- package/dist/admin/templateConditions.scss +24 -0
- package/dist/ai/adapters/anthropic.js +17 -4
- package/dist/ai/adapters/cloudflare-gateway.js +7 -1
- package/dist/ai/adapters/cloudflare-workers-ai.js +2 -0
- package/dist/ai/adapters/openai-compatible.js +1 -0
- package/dist/ai/adapters/openrouter.js +2 -0
- package/dist/ai/config.d.ts +24 -4
- package/dist/ai/config.js +27 -8
- package/dist/ai/endpoint.d.ts +5 -2
- package/dist/ai/endpoint.js +31 -26
- package/dist/ai/images/cloudflare-workers-ai.js +6 -2
- package/dist/ai/images/openai.js +8 -3
- package/dist/ai/images/openrouter.js +6 -2
- package/dist/ai/images/service.d.ts +10 -4
- package/dist/ai/images/service.js +23 -7
- package/dist/ai/openai-format.d.ts +7 -0
- package/dist/ai/openai-format.js +17 -5
- package/dist/ai/prompt.d.ts +8 -0
- package/dist/ai/prompt.js +25 -5
- package/dist/ai/settings/index.d.ts +62 -0
- package/dist/ai/settings/index.js +264 -0
- package/dist/ai/settings/secret.d.ts +11 -0
- package/dist/ai/settings/secret.js +46 -0
- package/dist/ai/settings/shared.d.ts +22 -0
- package/dist/ai/settings/shared.js +3 -0
- package/dist/ai/tools.d.ts +3 -0
- package/dist/ai/tools.js +79 -15
- package/dist/ai/types.d.ts +43 -0
- package/dist/blocks/builtins/adjacentLinks.d.ts +5 -0
- package/dist/blocks/builtins/adjacentLinks.js +76 -0
- package/dist/blocks/builtins/carousel.d.ts +2 -29
- package/dist/blocks/builtins/carousel.js +44 -51
- package/dist/blocks/builtins/disclosure.d.ts +2 -1
- package/dist/blocks/builtins/disclosure.js +22 -32
- package/dist/blocks/builtins/embed.d.ts +15 -0
- package/dist/blocks/builtins/embed.js +47 -0
- package/dist/blocks/builtins/faq.d.ts +1 -1
- package/dist/blocks/builtins/faq.js +2 -2
- package/dist/blocks/builtins/filterLink.d.ts +1 -19
- package/dist/blocks/builtins/filterLink.js +9 -50
- package/dist/blocks/builtins/icon.d.ts +2 -0
- package/dist/blocks/builtins/icon.js +8 -8
- package/dist/blocks/builtins/index.d.ts +18 -13
- package/dist/blocks/builtins/index.js +43 -22
- package/dist/blocks/builtins/marquee.d.ts +5 -0
- package/dist/blocks/builtins/marquee.js +68 -0
- package/dist/blocks/builtins/popup.d.ts +5 -0
- package/dist/blocks/builtins/popup.js +83 -0
- package/dist/blocks/builtins/sectionRef.d.ts +16 -2
- package/dist/blocks/builtins/sectionRef.js +34 -12
- package/dist/blocks/builtins/shared.d.ts +18 -23
- package/dist/blocks/builtins/shared.js +34 -42
- package/dist/blocks/builtins/tableOfContents.d.ts +4 -0
- package/dist/blocks/builtins/tableOfContents.js +12 -18
- package/dist/blocks/builtins/tabs.d.ts +6 -0
- package/dist/blocks/builtins/tabs.js +87 -0
- package/dist/blocks/client/adjacentLinks.d.ts +4 -0
- package/dist/blocks/client/adjacentLinks.js +4 -0
- package/dist/blocks/client/carousel.d.ts +45 -0
- package/dist/blocks/client/carousel.js +53 -0
- package/dist/blocks/client/embed.d.ts +21 -0
- package/dist/blocks/client/embed.js +23 -0
- package/dist/blocks/client/field.d.ts +7 -0
- package/dist/blocks/client/field.js +8 -0
- package/dist/blocks/client/filterLink.d.ts +19 -0
- package/dist/blocks/client/filterLink.js +30 -0
- package/dist/blocks/client/helpers.d.ts +21 -0
- package/dist/blocks/client/helpers.js +24 -0
- package/dist/blocks/client/marquee.d.ts +14 -0
- package/dist/blocks/client/marquee.js +25 -0
- package/dist/blocks/client/menu.d.ts +46 -0
- package/dist/blocks/client/menu.js +49 -0
- package/dist/blocks/client/popup.d.ts +15 -0
- package/dist/blocks/client/popup.js +16 -0
- package/dist/blocks/client/tabs.d.ts +10 -0
- package/dist/blocks/client/tabs.js +11 -0
- package/dist/blocks/defaults.d.ts +15 -52
- package/dist/blocks/defaults.js +203 -437
- package/dist/blocks/index.d.ts +1 -1
- package/dist/blocks/index.js +2 -1
- package/dist/classes/actions.d.ts +97 -0
- package/dist/classes/actions.js +296 -0
- package/dist/classes/collection.d.ts +5 -0
- package/dist/classes/collection.js +189 -0
- package/dist/classes/config.d.ts +34 -0
- package/dist/classes/config.js +8 -0
- package/dist/classes/endpoints.d.ts +2 -0
- package/dist/classes/endpoints.js +120 -0
- package/dist/classes/index.d.ts +36 -0
- package/dist/classes/index.js +42 -0
- package/dist/classes/mcp.d.ts +6 -0
- package/dist/classes/mcp.js +161 -0
- package/dist/classes/shared.d.ts +131 -0
- package/dist/classes/shared.js +300 -0
- package/dist/classes/sheet.d.ts +34 -0
- package/dist/classes/sheet.js +126 -0
- package/dist/classes/usage.d.ts +57 -0
- package/dist/classes/usage.js +208 -0
- package/dist/comments/collection.d.ts +38 -0
- package/dist/comments/collection.js +226 -0
- package/dist/comments/config.d.ts +15 -0
- package/dist/comments/config.js +2 -0
- package/dist/comments/index.d.ts +20 -0
- package/dist/comments/index.js +22 -0
- package/dist/comments/shared.d.ts +54 -0
- package/dist/comments/shared.js +104 -0
- package/dist/core/bindings.d.ts +77 -32
- package/dist/core/bindings.js +319 -134
- package/dist/core/blockNames.d.ts +9 -0
- package/dist/core/blockNames.js +11 -0
- package/dist/core/blocks.d.ts +21 -8
- package/dist/core/blocks.js +37 -16
- package/dist/core/classes.d.ts +16 -8
- package/dist/core/classes.js +31 -27
- package/dist/core/components.d.ts +72 -0
- package/dist/core/components.js +294 -0
- package/dist/core/contentMode.d.ts +27 -0
- package/dist/core/contentMode.js +0 -0
- package/dist/core/dropTarget.d.ts +11 -0
- package/dist/core/dropTarget.js +24 -1
- package/dist/core/fields.d.ts +5 -0
- package/dist/core/fields.js +11 -0
- package/dist/core/headings.d.ts +5 -2
- package/dist/core/headings.js +14 -6
- package/dist/core/index.d.ts +8 -3
- package/dist/core/index.js +8 -3
- package/dist/core/layers.d.ts +9 -0
- package/dist/core/layers.js +29 -0
- package/dist/core/operations.d.ts +6 -0
- package/dist/core/operations.js +85 -24
- package/dist/core/payloadBlocks.js +5 -1
- package/dist/core/references.js +28 -0
- package/dist/core/schema.js +20 -6
- package/dist/core/sectionOrigin.d.ts +6 -0
- package/dist/core/sectionOrigin.js +21 -0
- package/dist/core/sections.d.ts +72 -0
- package/dist/core/sections.js +331 -0
- package/dist/core/templateChoice.d.ts +24 -0
- package/dist/core/templateChoice.js +43 -0
- package/dist/core/tree.js +18 -6
- package/dist/core/types.d.ts +148 -18
- package/dist/core/validate.d.ts +4 -1
- package/dist/core/validate.js +28 -11
- package/dist/core/visibility.d.ts +63 -0
- package/dist/core/visibility.js +214 -0
- package/dist/core/whereValues.d.ts +22 -0
- package/dist/core/whereValues.js +43 -0
- package/dist/css/classes.d.ts +16 -0
- package/dist/css/classes.js +172 -0
- package/dist/css/index.d.ts +32 -1
- package/dist/css/index.js +64 -5
- package/dist/css/tokens.d.ts +10 -0
- package/dist/css/tokens.js +23 -10
- package/dist/index.d.ts +5 -2
- package/dist/index.js +6 -1
- package/dist/live/contentMode.d.ts +24 -0
- package/dist/live/contentMode.js +39 -0
- package/dist/live/endpoints.js +3 -0
- package/dist/live/session.d.ts +5 -0
- package/dist/live/session.js +8 -0
- package/dist/live/types.d.ts +16 -1
- package/dist/mcp/index.d.ts +10 -1
- package/dist/mcp/index.js +146 -54
- package/dist/mcp/shared.d.ts +93 -3
- package/dist/mcp/shared.js +211 -15
- package/dist/plugin/hook.d.ts +7 -1
- package/dist/plugin/hook.js +30 -4
- package/dist/plugin/index.d.ts +19 -8
- package/dist/plugin/index.js +89 -20
- package/dist/plugin/links.d.ts +24 -0
- package/dist/plugin/links.js +27 -0
- package/dist/plugin/listCollections.d.ts +9 -7
- package/dist/plugin/listCollections.js +30 -21
- package/dist/plugin/sections.d.ts +14 -7
- package/dist/plugin/sections.js +69 -23
- package/dist/plugin/sectionsUsedIn.d.ts +6 -0
- package/dist/plugin/sectionsUsedIn.js +24 -0
- package/dist/plugin/templateEndpoint.d.ts +9 -0
- package/dist/plugin/templateEndpoint.js +49 -0
- package/dist/plugin/templates.js +23 -8
- package/dist/protocol/index.d.ts +16 -1
- package/dist/react/canvas/BuilderCanvas.js +144 -21
- package/dist/react/canvas/classes.d.ts +17 -0
- package/dist/react/canvas/classes.js +102 -0
- package/dist/react/canvas/controls.d.ts +31 -0
- package/dist/react/canvas/controls.js +75 -0
- package/dist/react/canvas/fetchDocs.d.ts +2 -2
- package/dist/react/canvas/fetchDocs.js +16 -8
- package/dist/react/canvas/measure.d.ts +9 -0
- package/dist/react/canvas/measure.js +106 -7
- package/dist/react/canvas/resolveLayout.d.ts +1 -1
- package/dist/react/canvas/resolveLayout.js +4 -3
- package/dist/react/canvas/thumbnail/ThumbnailCanvas.js +17 -4
- package/dist/react/classes/ClassesStyle.d.ts +27 -0
- package/dist/react/classes/ClassesStyle.js +27 -0
- package/dist/react/components/Button.d.ts +2 -11
- package/dist/react/components/Button.js +8 -43
- package/dist/react/components/CollectionList.d.ts +4 -1
- package/dist/react/components/CollectionList.js +10 -3
- package/dist/react/components/Container.d.ts +5 -2
- package/dist/react/components/Container.js +7 -4
- package/dist/react/components/Field.js +3 -14
- package/dist/react/components/Link.d.ts +1 -1
- package/dist/react/components/Link.js +5 -3
- package/dist/react/components/List.d.ts +1 -1
- package/dist/react/components/List.js +2 -2
- package/dist/react/components/Menu.d.ts +10 -1
- package/dist/react/components/Menu.js +39 -12
- package/dist/react/components/RichText.d.ts +3 -4
- package/dist/react/components/RichText.js +5 -5
- package/dist/react/components/builtins/Accordion.d.ts +4 -3
- package/dist/react/components/builtins/Accordion.js +6 -5
- package/dist/react/components/builtins/AdjacentLinks.d.ts +11 -0
- package/dist/react/components/builtins/AdjacentLinks.js +20 -0
- package/dist/react/components/builtins/Carousel.d.ts +21 -10
- package/dist/react/components/builtins/Carousel.js +175 -100
- package/dist/react/components/builtins/Disclosure.d.ts +4 -3
- package/dist/react/components/builtins/Disclosure.js +6 -5
- package/dist/react/components/builtins/Embed.d.ts +11 -0
- package/dist/react/components/builtins/Embed.js +23 -0
- package/dist/react/components/builtins/EmbedHtml.d.ts +15 -0
- package/dist/react/components/builtins/EmbedHtml.js +51 -0
- package/dist/react/components/builtins/EmbedPreview.d.ts +34 -0
- package/dist/react/components/builtins/EmbedPreview.js +105 -0
- package/dist/react/components/builtins/FilterLink.d.ts +1 -1
- package/dist/react/components/builtins/FilterLink.js +4 -4
- package/dist/react/components/builtins/Marquee.d.ts +8 -0
- package/dist/react/components/builtins/Marquee.js +15 -0
- package/dist/react/components/builtins/Popup.d.ts +26 -0
- package/dist/react/components/builtins/Popup.js +146 -0
- package/dist/react/components/builtins/SectionRef.d.ts +4 -3
- package/dist/react/components/builtins/SectionRef.js +9 -5
- package/dist/react/components/builtins/Tab.d.ts +7 -0
- package/dist/react/components/builtins/Tab.js +21 -0
- package/dist/react/components/builtins/TableOfContents.d.ts +17 -3
- package/dist/react/components/builtins/TableOfContents.js +22 -7
- package/dist/react/components/builtins/Tabs.d.ts +17 -0
- package/dist/react/components/builtins/Tabs.js +71 -0
- package/dist/react/components/builtins/index.d.ts +37 -20
- package/dist/react/components/builtins/index.js +54 -20
- package/dist/react/components/builtins/tabsContext.d.ts +12 -0
- package/dist/react/components/builtins/tabsContext.js +6 -0
- package/dist/react/components/index.js +11 -8
- package/dist/react/components/lazy.d.ts +32 -0
- package/dist/react/components/lazy.js +20 -0
- package/dist/react/components/lazyBlock.d.ts +17 -0
- package/dist/react/components/lazyBlock.js +23 -0
- package/dist/react/index.d.ts +6 -3
- package/dist/react/index.js +5 -2
- package/dist/react/render/RenderLayout.d.ts +9 -7
- package/dist/react/render/RenderLayout.js +96 -45
- package/dist/react/render/canvasMode.d.ts +13 -0
- package/dist/react/render/canvasMode.js +13 -0
- package/dist/react/render/canvasServer.js +4 -3
- package/dist/react/render/canvasServerTypes.d.ts +5 -0
- package/dist/react/render/lists.d.ts +36 -4
- package/dist/react/render/lists.js +132 -15
- package/dist/react/render/marks.d.ts +15 -0
- package/dist/react/render/marks.js +23 -0
- package/dist/react/render/payload.d.ts +8 -1
- package/dist/react/render/payload.js +12 -3
- package/dist/react/render/preview.d.ts +11 -0
- package/dist/react/render/preview.js +13 -0
- package/dist/react/render/relations.d.ts +10 -0
- package/dist/react/render/relations.js +39 -0
- package/dist/react/render/resolve.d.ts +8 -4
- package/dist/react/render/resolve.js +11 -5
- package/dist/react/render/reveal.d.ts +17 -0
- package/dist/react/render/reveal.js +39 -0
- package/dist/react/render/sections.d.ts +11 -5
- package/dist/react/render/sections.js +52 -24
- package/dist/react/render/templates.d.ts +47 -0
- package/dist/react/render/templates.js +139 -0
- package/dist/react/render/types.d.ts +62 -5
- package/dist/react/server.d.ts +2 -37
- package/dist/react/server.js +8 -133
- package/dist/react/theme/ThemeLiveLoader.d.ts +4 -0
- package/dist/react/theme/ThemeLiveLoader.js +5 -0
- package/dist/react/theme/ThemeStyle.js +1 -1
- package/dist/theme/admin/Variables.d.ts +11 -0
- package/dist/theme/admin/Variables.js +115 -0
- package/dist/theme/admin/fields.scss +113 -0
- package/dist/theme/client.d.ts +1 -0
- package/dist/theme/client.js +2 -0
- package/dist/theme/css.d.ts +6 -1
- package/dist/theme/css.js +12 -4
- package/dist/theme/global.js +83 -0
- package/dist/theme/index.d.ts +1 -0
- package/dist/theme/index.js +1 -0
- package/dist/theme/server.d.ts +15 -0
- package/dist/theme/server.js +43 -0
- package/dist/theme/usage.d.ts +23 -0
- package/dist/theme/usage.js +68 -0
- package/dist/theme/variables.d.ts +72 -0
- package/dist/theme/variables.js +231 -0
- package/package.json +4 -2
- package/dist/admin/editor/styles/SiteClasses.d.ts +0 -9
- package/dist/admin/editor/styles/SiteClasses.js +0 -31
- package/dist/blocks/builtins/headingId.d.ts +0 -15
- package/dist/blocks/builtins/headingId.js +0 -36
- package/dist/blocks/builtins/lightbox.d.ts +0 -43
- package/dist/blocks/builtins/lightbox.js +0 -93
- package/dist/blocks/builtins/mediaBackdrop.d.ts +0 -11
- package/dist/blocks/builtins/mediaBackdrop.js +0 -79
- package/dist/react/components/Quote.d.ts +0 -3
- package/dist/react/components/Quote.js +0 -12
- package/dist/react/components/Spacer.d.ts +0 -3
- package/dist/react/components/Spacer.js +0 -6
- package/dist/react/components/builtins/BackdropVideo.d.ts +0 -13
- package/dist/react/components/builtins/BackdropVideo.js +0 -16
- package/dist/react/components/builtins/Lightbox.d.ts +0 -45
- package/dist/react/components/builtins/Lightbox.js +0 -252
- package/dist/react/components/builtins/MediaBackdrop.d.ts +0 -14
- package/dist/react/components/builtins/MediaBackdrop.js +0 -61
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
// The class manager drawer. Payload CSS variables and the editor's type scale only, no Tailwind.
|
|
2
|
+
|
|
3
|
+
@layer payload-default {
|
|
4
|
+
.builder-class-manager {
|
|
5
|
+
&__body {
|
|
6
|
+
display: flex;
|
|
7
|
+
flex-direction: column;
|
|
8
|
+
gap: calc(var(--base) * 0.5);
|
|
9
|
+
max-width: 720px;
|
|
10
|
+
padding-bottom: calc(var(--base) * 2);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
&__toolbar {
|
|
14
|
+
display: flex;
|
|
15
|
+
align-items: center;
|
|
16
|
+
gap: calc(var(--base) * 0.5);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
&__search {
|
|
20
|
+
display: flex;
|
|
21
|
+
flex: 1;
|
|
22
|
+
align-items: center;
|
|
23
|
+
gap: 6px;
|
|
24
|
+
height: calc(var(--base) * 2);
|
|
25
|
+
padding: 0 calc(var(--base) * 0.5);
|
|
26
|
+
border: 1px solid var(--theme-elevation-150);
|
|
27
|
+
border-radius: var(--style-radius-s, 4px);
|
|
28
|
+
background: var(--theme-input-bg, var(--theme-elevation-0));
|
|
29
|
+
color: var(--theme-elevation-500);
|
|
30
|
+
|
|
31
|
+
&:focus-within {
|
|
32
|
+
border-color: var(--theme-elevation-400);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
input {
|
|
36
|
+
flex: 1;
|
|
37
|
+
min-width: 0;
|
|
38
|
+
height: 100%;
|
|
39
|
+
padding: 0;
|
|
40
|
+
border: 0;
|
|
41
|
+
background: none;
|
|
42
|
+
color: var(--theme-text);
|
|
43
|
+
font: inherit;
|
|
44
|
+
font-size: var(--be-text-m, 13px);
|
|
45
|
+
outline: none;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
&__button {
|
|
50
|
+
flex-shrink: 0;
|
|
51
|
+
height: calc(var(--base) * 2);
|
|
52
|
+
padding: 0 calc(var(--base) * 0.75);
|
|
53
|
+
border: 1px solid var(--theme-elevation-150);
|
|
54
|
+
border-radius: var(--style-radius-s, 4px);
|
|
55
|
+
background: var(--theme-elevation-0);
|
|
56
|
+
color: var(--theme-text);
|
|
57
|
+
font: inherit;
|
|
58
|
+
font-size: var(--be-text-m, 13px);
|
|
59
|
+
cursor: pointer;
|
|
60
|
+
|
|
61
|
+
&:hover:not(:disabled) {
|
|
62
|
+
border-color: var(--theme-elevation-300);
|
|
63
|
+
background: var(--theme-elevation-50);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
&:disabled {
|
|
67
|
+
color: var(--theme-elevation-400);
|
|
68
|
+
cursor: default;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
&:focus-visible {
|
|
72
|
+
outline: 2px solid var(--theme-elevation-500);
|
|
73
|
+
outline-offset: 1px;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
&__summary {
|
|
78
|
+
margin: 0;
|
|
79
|
+
color: var(--theme-elevation-500);
|
|
80
|
+
font-size: var(--be-text-s, 11px);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
&__empty {
|
|
84
|
+
margin: calc(var(--base) * 1.5) 0;
|
|
85
|
+
color: var(--theme-elevation-600);
|
|
86
|
+
font-size: var(--be-text-m, 13px);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
&__list {
|
|
90
|
+
margin: 0;
|
|
91
|
+
padding: 0;
|
|
92
|
+
border-top: 1px solid var(--theme-elevation-100);
|
|
93
|
+
list-style: none;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
&__row {
|
|
97
|
+
border-bottom: 1px solid var(--theme-elevation-100);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
&__line {
|
|
101
|
+
display: flex;
|
|
102
|
+
align-items: center;
|
|
103
|
+
gap: 4px;
|
|
104
|
+
min-height: 36px;
|
|
105
|
+
|
|
106
|
+
&:hover,
|
|
107
|
+
&:focus-within {
|
|
108
|
+
.builder-class-manager__actions {
|
|
109
|
+
opacity: 1;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
&__main {
|
|
115
|
+
display: flex;
|
|
116
|
+
flex: 1;
|
|
117
|
+
align-items: baseline;
|
|
118
|
+
gap: calc(var(--base) * 0.5);
|
|
119
|
+
min-width: 0;
|
|
120
|
+
padding: 8px 6px;
|
|
121
|
+
border: 0;
|
|
122
|
+
border-radius: var(--style-radius-s, 4px);
|
|
123
|
+
background: none;
|
|
124
|
+
color: var(--theme-text);
|
|
125
|
+
font: inherit;
|
|
126
|
+
font-size: var(--be-text-m, 13px);
|
|
127
|
+
text-align: left;
|
|
128
|
+
cursor: pointer;
|
|
129
|
+
|
|
130
|
+
&:hover:not(:disabled) {
|
|
131
|
+
background: var(--theme-elevation-50);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
&:disabled {
|
|
135
|
+
cursor: default;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
&:focus-visible {
|
|
139
|
+
outline: 2px solid var(--theme-elevation-500);
|
|
140
|
+
outline-offset: -2px;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
&__name {
|
|
145
|
+
flex-shrink: 0;
|
|
146
|
+
font-family: var(--font-mono, monospace);
|
|
147
|
+
font-weight: var(--be-weight-medium, 500);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
&__label {
|
|
151
|
+
overflow: hidden;
|
|
152
|
+
color: var(--theme-elevation-600);
|
|
153
|
+
text-overflow: ellipsis;
|
|
154
|
+
white-space: nowrap;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
&__usage {
|
|
158
|
+
flex-shrink: 0;
|
|
159
|
+
margin-left: auto;
|
|
160
|
+
color: var(--theme-elevation-600);
|
|
161
|
+
font-size: var(--be-text-s, 11px);
|
|
162
|
+
font-variant-numeric: tabular-nums;
|
|
163
|
+
|
|
164
|
+
&[data-unused] {
|
|
165
|
+
color: var(--theme-elevation-400);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
&__badge {
|
|
170
|
+
flex-shrink: 0;
|
|
171
|
+
padding: 1px 6px;
|
|
172
|
+
border-radius: 999px;
|
|
173
|
+
background: var(--theme-warning-100);
|
|
174
|
+
color: var(--theme-warning-800);
|
|
175
|
+
font-size: var(--be-text-s, 11px);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
&__actions {
|
|
179
|
+
display: flex;
|
|
180
|
+
flex-shrink: 0;
|
|
181
|
+
gap: 2px;
|
|
182
|
+
opacity: 0;
|
|
183
|
+
transition: opacity 120ms ease-out;
|
|
184
|
+
|
|
185
|
+
@media (hover: none) {
|
|
186
|
+
opacity: 1;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
button {
|
|
190
|
+
display: grid;
|
|
191
|
+
place-items: center;
|
|
192
|
+
width: 26px;
|
|
193
|
+
height: 26px;
|
|
194
|
+
padding: 0;
|
|
195
|
+
border: 0;
|
|
196
|
+
border-radius: var(--style-radius-s, 4px);
|
|
197
|
+
background: none;
|
|
198
|
+
color: var(--theme-elevation-600);
|
|
199
|
+
cursor: pointer;
|
|
200
|
+
|
|
201
|
+
&:hover {
|
|
202
|
+
background: var(--theme-elevation-100);
|
|
203
|
+
color: var(--theme-text);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
&[data-danger]:hover {
|
|
207
|
+
background: var(--theme-error-50);
|
|
208
|
+
color: var(--theme-error-600);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
&:focus-visible {
|
|
212
|
+
outline: 2px solid var(--theme-elevation-500);
|
|
213
|
+
outline-offset: 1px;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
&__docs {
|
|
219
|
+
margin: 0 0 8px;
|
|
220
|
+
padding: 0 0 0 calc(var(--base) * 0.75);
|
|
221
|
+
list-style: none;
|
|
222
|
+
|
|
223
|
+
a {
|
|
224
|
+
display: flex;
|
|
225
|
+
align-items: center;
|
|
226
|
+
gap: calc(var(--base) * 0.5);
|
|
227
|
+
padding: 5px 6px;
|
|
228
|
+
border-radius: var(--style-radius-s, 4px);
|
|
229
|
+
color: var(--theme-text);
|
|
230
|
+
font-size: var(--be-text-m, 13px);
|
|
231
|
+
text-decoration: none;
|
|
232
|
+
|
|
233
|
+
&:hover {
|
|
234
|
+
background: var(--theme-elevation-50);
|
|
235
|
+
|
|
236
|
+
.builder-class-manager__doc-title {
|
|
237
|
+
text-decoration: underline;
|
|
238
|
+
text-underline-offset: 2px;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
svg {
|
|
243
|
+
flex-shrink: 0;
|
|
244
|
+
color: var(--theme-elevation-500);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
&__doc-title {
|
|
250
|
+
overflow: hidden;
|
|
251
|
+
text-overflow: ellipsis;
|
|
252
|
+
white-space: nowrap;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
&__doc-meta {
|
|
256
|
+
flex-shrink: 0;
|
|
257
|
+
margin-left: auto;
|
|
258
|
+
color: var(--theme-elevation-500);
|
|
259
|
+
font-size: var(--be-text-s, 11px);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { BuilderClass, ClassUsage } from '../../../classes/shared.js';
|
|
2
|
+
/** Usage of a class under its name and its former names, one entry per document. */
|
|
3
|
+
export declare function usageOf(item: BuilderClass, usage: Record<string, ClassUsage> | null): ClassUsage | null;
|
|
4
|
+
/** Classes whose name, label or group contains the query. */
|
|
5
|
+
export declare function filterClasses(list: readonly BuilderClass[], query: string): BuilderClass[];
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// The class manager's pure helpers: usage per class (with former names) and search.
|
|
2
|
+
/** Usage of a class under its name and its former names, one entry per document. */
|
|
3
|
+
export function usageOf(item, usage) {
|
|
4
|
+
if (!usage)
|
|
5
|
+
return null;
|
|
6
|
+
const documents = new Map();
|
|
7
|
+
let blocks = 0;
|
|
8
|
+
for (const name of [item.name, ...(item.previousNames ?? [])]) {
|
|
9
|
+
const entry = usage[name];
|
|
10
|
+
if (!entry)
|
|
11
|
+
continue;
|
|
12
|
+
blocks += entry.blocks;
|
|
13
|
+
for (const doc of entry.documents) {
|
|
14
|
+
const key = `${doc.collection}:${doc.id}`;
|
|
15
|
+
const known = documents.get(key);
|
|
16
|
+
documents.set(key, known ? { ...known, blocks: known.blocks + doc.blocks } : doc);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return { blocks, documents: [...documents.values()] };
|
|
20
|
+
}
|
|
21
|
+
/** Classes whose name, label or group contains the query. */
|
|
22
|
+
export function filterClasses(list, query) {
|
|
23
|
+
const q = query.trim().toLowerCase().replace(/^\./, '');
|
|
24
|
+
if (!q)
|
|
25
|
+
return [...list];
|
|
26
|
+
return list.filter((c) => [c.name, c.label, c.group].some((text) => text?.toLowerCase().includes(q)));
|
|
27
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
// Comment mode on the canvas: a layer over the iframe that takes the pointer (a click places a
|
|
4
|
+
// pin on the block under it, the wheel still scrolls the page), the pins of the threads, and the
|
|
5
|
+
// popover with the composer or the open thread. Renders nothing outside comment mode, so the
|
|
6
|
+
// canvas does no comment work while people edit.
|
|
7
|
+
import { useEffect, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from 'react';
|
|
8
|
+
import { createPortal } from 'react-dom';
|
|
9
|
+
import { deepestBlockAt } from '../../../core/index.js';
|
|
10
|
+
import { threadsOf } from '../../../comments/shared.js';
|
|
11
|
+
import { Icon } from '../icons.js';
|
|
12
|
+
import { cursorAt, cursorPoint } from '../live/presence.js';
|
|
13
|
+
import { toCanvasPoint, useRuntime } from '../runtime.js';
|
|
14
|
+
import { useEditor } from '../store.js';
|
|
15
|
+
import { useValue } from '../valueStore.js';
|
|
16
|
+
import { Avatar, CommentInput, Thread } from './Thread.js';
|
|
17
|
+
import './comments.scss';
|
|
18
|
+
const noSubscription = () => () => { };
|
|
19
|
+
const editorRoot = () => document.querySelector('.builder-editor');
|
|
20
|
+
const noRoot = () => null;
|
|
21
|
+
/** Space between the pin and its popover, and from the window edge, in screen pixels. */
|
|
22
|
+
const GAP = 10;
|
|
23
|
+
/** The pin's size on screen (`.builder-comment-pin`): the popover sits beside it, never over it. */
|
|
24
|
+
const PIN = 30;
|
|
25
|
+
const POPOVER_WIDTH = 300;
|
|
26
|
+
export function CommentLayer() {
|
|
27
|
+
const { comments } = useRuntime();
|
|
28
|
+
if (!comments)
|
|
29
|
+
return null;
|
|
30
|
+
return _jsx(ModeGate, { comments: comments });
|
|
31
|
+
}
|
|
32
|
+
function ModeGate({ comments }) {
|
|
33
|
+
const on = useValue(comments.mode);
|
|
34
|
+
return on ? _jsx(ModeLayer, { comments: comments }) : null;
|
|
35
|
+
}
|
|
36
|
+
function ModeLayer({ comments }) {
|
|
37
|
+
const runtime = useRuntime();
|
|
38
|
+
const measurement = useValue(runtime.measurement);
|
|
39
|
+
const list = useValue(comments.list);
|
|
40
|
+
const filter = useValue(comments.filter);
|
|
41
|
+
const draft = useValue(comments.draft);
|
|
42
|
+
const openId = useValue(comments.open);
|
|
43
|
+
const layout = useEditor(runtime.store, (s) => s.layout);
|
|
44
|
+
// The block under the pointer, by id: its outline follows the block when the page scrolls or changes.
|
|
45
|
+
const [hoveredId, setHoveredId] = useState(null);
|
|
46
|
+
const hovered = hoveredId ? (measurement?.blocks.find((b) => b.id === hoveredId)?.rect ?? null) : null;
|
|
47
|
+
const threads = useMemo(() => threadsOf(list, filter), [list, filter]);
|
|
48
|
+
const openThread = useMemo(() => (openId ? threadsOf(list).find((t) => t.root.id === openId) : undefined), [list, openId]);
|
|
49
|
+
const pointAt = (e) => {
|
|
50
|
+
const iframe = runtime.iframeRef.current;
|
|
51
|
+
return iframe ? toCanvasPoint(iframe, { x: e.clientX, y: e.clientY }) : null;
|
|
52
|
+
};
|
|
53
|
+
const onMove = (e) => {
|
|
54
|
+
const p = pointAt(e);
|
|
55
|
+
setHoveredId(p && measurement ? deepestBlockAt(layout, measurement, p) : null);
|
|
56
|
+
};
|
|
57
|
+
const onClick = (e) => {
|
|
58
|
+
const p = pointAt(e);
|
|
59
|
+
if (!p || !measurement)
|
|
60
|
+
return;
|
|
61
|
+
const cursor = cursorAt(layout, measurement, p);
|
|
62
|
+
// Over the page background, not a block: close what is open.
|
|
63
|
+
if (!cursor.blockId) {
|
|
64
|
+
comments.draft.set(null);
|
|
65
|
+
comments.open.set(null);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
// A click while a thread or the composer is open only closes it.
|
|
69
|
+
if (comments.draft.get() || comments.open.get()) {
|
|
70
|
+
comments.draft.set(null);
|
|
71
|
+
comments.open.set(null);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
comments.place(cursor);
|
|
75
|
+
};
|
|
76
|
+
const pinAt = (blockId, x, y) => (measurement && blockId ? cursorPoint(measurement, { blockId, x, y }) : null);
|
|
77
|
+
const draftPoint = draft ? pinAt(draft.blockId, draft.x, draft.y) : null;
|
|
78
|
+
const openPoint = openThread ? pinAt(openThread.root.blockId, openThread.root.x, openThread.root.y) : null;
|
|
79
|
+
return (_jsxs("div", { className: "builder-comments-layer", children: [_jsx("div", { className: "builder-comments-layer__capture", "aria-label": "Click a block to comment", onPointerMove: onMove, onPointerLeave: () => setHoveredId(null), onPointerDown: (e) => {
|
|
80
|
+
if (e.button !== 0)
|
|
81
|
+
return;
|
|
82
|
+
// The composer focuses its text box as it opens; the default mousedown would take focus back.
|
|
83
|
+
e.preventDefault();
|
|
84
|
+
onClick(e);
|
|
85
|
+
}, onWheel: (e) => runtime.postToCanvas({ type: 'scrollBy', dx: e.deltaX, dy: e.deltaY }) }), hovered && (_jsx("div", { className: "builder-comments-layer__hover", style: { left: hovered.x, top: hovered.y, width: hovered.width, height: hovered.height } })), threads.map((thread) => {
|
|
86
|
+
const point = pinAt(thread.root.blockId, thread.root.x, thread.root.y);
|
|
87
|
+
if (!point)
|
|
88
|
+
return null;
|
|
89
|
+
return _jsx(Pin, { thread: thread, point: point, open: thread.root.id === openId, comments: comments }, thread.root.id);
|
|
90
|
+
}), draftPoint && (_jsx("span", { className: "builder-comment-pin builder-comment-pin--draft", style: { left: draftPoint.x, top: draftPoint.y }, "aria-hidden": true, children: _jsx(Icon, { name: "plus", size: 12 }) })), draft && draftPoint && (_jsx(Popover, { runtime: runtime, point: draftPoint, label: "New comment", onClose: () => comments.draft.set(null), children: _jsx("div", { className: "builder-thread builder-thread--new", children: _jsx(CommentInput, { placeholder: "Add a comment", submitLabel: "Comment", focusOnMount: true, onCancel: () => comments.draft.set(null), onSubmit: (body) => comments.create(body) }) }) })), openThread && openPoint && (_jsx(Popover, { runtime: runtime, point: openPoint, label: "Comment thread", onClose: () => comments.open.set(null), children: _jsx(Thread, { thread: openThread, comments: comments, onClose: () => comments.open.set(null) }) }))] }));
|
|
91
|
+
}
|
|
92
|
+
function Pin({ thread, point, open, comments }) {
|
|
93
|
+
const { root, replies } = thread;
|
|
94
|
+
const classes = ['builder-comment-pin', open && 'builder-comment-pin--open', root.resolved && 'builder-comment-pin--resolved'].filter(Boolean).join(' ');
|
|
95
|
+
return (_jsx("button", { type: "button", className: classes, style: { left: point.x, top: point.y }, "aria-label": `Comment by ${root.authorName}${replies.length ? `, ${replies.length} ${replies.length === 1 ? 'reply' : 'replies'}` : ''}`, "aria-expanded": open, onClick: () => {
|
|
96
|
+
comments.draft.set(null);
|
|
97
|
+
comments.open.set(open ? null : root.id);
|
|
98
|
+
}, children: root.resolved ? _jsx(Icon, { name: "check", size: 12 }) : _jsx(Avatar, { name: root.authorName }) }));
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* The composer or the thread next to its pin, in the editor root (outside the zoomed frame, so it
|
|
102
|
+
* keeps its size). Hidden while the pin is scrolled out of the canvas.
|
|
103
|
+
*/
|
|
104
|
+
function Popover({ runtime, point, label, onClose, children }) {
|
|
105
|
+
const host = useSyncExternalStore(noSubscription, editorRoot, noRoot);
|
|
106
|
+
const ref = useRef(null);
|
|
107
|
+
// Escape inside the popover closes it (a text box that cancels an edit handles it first).
|
|
108
|
+
useEffect(() => {
|
|
109
|
+
const el = ref.current;
|
|
110
|
+
if (!el)
|
|
111
|
+
return;
|
|
112
|
+
const onKey = (e) => {
|
|
113
|
+
if (e.key !== 'Escape' || e.defaultPrevented)
|
|
114
|
+
return;
|
|
115
|
+
e.preventDefault();
|
|
116
|
+
e.stopPropagation();
|
|
117
|
+
onClose();
|
|
118
|
+
};
|
|
119
|
+
el.addEventListener('keydown', onKey);
|
|
120
|
+
return () => el.removeEventListener('keydown', onKey);
|
|
121
|
+
}, [onClose]);
|
|
122
|
+
const iframe = runtime.iframeRef.current;
|
|
123
|
+
const box = iframe?.getBoundingClientRect();
|
|
124
|
+
const scale = iframe && box && iframe.offsetWidth ? box.width / iframe.offsetWidth : 1;
|
|
125
|
+
const screen = box ? { x: box.left + point.x * scale, y: box.top + point.y * scale } : null;
|
|
126
|
+
const visible = Boolean(box && screen && screen.y >= box.top && screen.y <= box.bottom && screen.x >= box.left && screen.x <= box.right);
|
|
127
|
+
// Right of the pin when it fits, else left. Kept inside the window vertically.
|
|
128
|
+
useLayoutEffect(() => {
|
|
129
|
+
const el = ref.current;
|
|
130
|
+
if (!el || !screen)
|
|
131
|
+
return;
|
|
132
|
+
const right = screen.x + PIN + GAP + POPOVER_WIDTH <= window.innerWidth - GAP;
|
|
133
|
+
const left = right ? screen.x + PIN + GAP : screen.x - GAP - POPOVER_WIDTH;
|
|
134
|
+
// The popover's top lines up with the pin's top.
|
|
135
|
+
const top = Math.min(Math.max(GAP, screen.y - PIN), window.innerHeight - el.offsetHeight - GAP);
|
|
136
|
+
el.style.left = `${Math.max(GAP, left)}px`;
|
|
137
|
+
el.style.top = `${Math.max(GAP, top)}px`;
|
|
138
|
+
});
|
|
139
|
+
if (!host || !visible)
|
|
140
|
+
return null;
|
|
141
|
+
const style = { width: POPOVER_WIDTH };
|
|
142
|
+
return createPortal(_jsx("dialog", { ref: ref, open: true, className: "builder-comments-popover", "aria-label": label, style: style, children: children }), host);
|
|
143
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import './comments.scss';
|
|
3
|
+
/** Top bar: comment mode on or off, with the number of open threads. */
|
|
4
|
+
export declare function CommentsButton(): import("react").JSX.Element | null;
|
|
5
|
+
/** In comment mode the panel takes the inspector's place. The inspector stays mounted. */
|
|
6
|
+
export declare function CommentsOrInspector({ children }: {
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
// The comments panel (the right sidebar in comment mode) and the top bar button with the count of
|
|
4
|
+
// open threads.
|
|
5
|
+
import { useMemo } from 'react';
|
|
6
|
+
import { findBlock } from '../../../core/index.js';
|
|
7
|
+
import { openCount, threadsOf } from '../../../comments/shared.js';
|
|
8
|
+
import { Icon } from '../icons.js';
|
|
9
|
+
import { blockName } from '../names.js';
|
|
10
|
+
import { useRuntime } from '../runtime.js';
|
|
11
|
+
import { useEditor } from '../store.js';
|
|
12
|
+
import { formatSaveTime } from '../topbar/saveTime.js';
|
|
13
|
+
import { useOptionalValue, useValue, useValueSelector } from '../valueStore.js';
|
|
14
|
+
import { Avatar, Thread } from './Thread.js';
|
|
15
|
+
import './comments.scss';
|
|
16
|
+
/** Top bar: comment mode on or off, with the number of open threads. */
|
|
17
|
+
export function CommentsButton() {
|
|
18
|
+
const { comments } = useRuntime();
|
|
19
|
+
if (!comments)
|
|
20
|
+
return null;
|
|
21
|
+
return _jsx(CommentsToggle, { comments: comments });
|
|
22
|
+
}
|
|
23
|
+
function CommentsToggle({ comments }) {
|
|
24
|
+
const on = useValue(comments.mode);
|
|
25
|
+
const count = useValueSelector(comments.list, openCount);
|
|
26
|
+
const label = count > 0 ? `Comments, ${count} open` : 'Comments';
|
|
27
|
+
return (_jsxs("button", { type: "button", className: "builder-editor__icon-button builder-comments-button", "aria-pressed": on, "aria-label": label, "aria-keyshortcuts": "C", "data-tooltip": `${on ? 'Leave comment mode' : 'Comments'} · C`, onClick: () => comments.toggle(), children: [_jsx(Icon, { name: "comment" }), count > 0 && _jsx("span", { className: "builder-comments-button__badge", children: count > 99 ? '99+' : count })] }));
|
|
28
|
+
}
|
|
29
|
+
/** In comment mode the panel takes the inspector's place. The inspector stays mounted. */
|
|
30
|
+
export function CommentsOrInspector({ children }) {
|
|
31
|
+
const { comments } = useRuntime();
|
|
32
|
+
const on = useOptionalValue(comments?.mode ?? null) === true;
|
|
33
|
+
return (_jsxs(_Fragment, { children: [on && comments && _jsx(CommentsPanel, { comments: comments }), _jsx("div", { className: "builder-comments-keep", hidden: on, children: children })] }));
|
|
34
|
+
}
|
|
35
|
+
const FILTERS = [
|
|
36
|
+
{ id: 'all', label: 'All' },
|
|
37
|
+
{ id: 'open', label: 'Open' },
|
|
38
|
+
{ id: 'resolved', label: 'Resolved' },
|
|
39
|
+
];
|
|
40
|
+
function CommentsPanel({ comments }) {
|
|
41
|
+
const runtime = useRuntime();
|
|
42
|
+
const list = useValue(comments.list);
|
|
43
|
+
const loaded = useValue(comments.loaded);
|
|
44
|
+
const filter = useValue(comments.filter);
|
|
45
|
+
const openId = useValue(comments.open);
|
|
46
|
+
const threads = useMemo(() => threadsOf(list, filter), [list, filter]);
|
|
47
|
+
const counts = useMemo(() => {
|
|
48
|
+
const all = threadsOf(list);
|
|
49
|
+
const open = all.filter((t) => !t.root.resolved).length;
|
|
50
|
+
return { all: all.length, open, resolved: all.length - open };
|
|
51
|
+
}, [list]);
|
|
52
|
+
return (_jsxs("section", { className: "builder-comments-panel", "aria-label": "Comments", children: [_jsxs("header", { className: "builder-comments-panel__head", children: [_jsx("h2", { className: "builder-comments-panel__title", children: "Comments" }), _jsx("button", { type: "button", className: "builder-editor__icon-button builder-editor__icon-button--small", "aria-label": "Close comments", "data-tooltip": "Close \u00B7 C", onClick: () => comments.toggle(false), children: _jsx(Icon, { name: "close", size: 14 }) })] }), _jsx("div", { className: "builder-comments-panel__filter", children: _jsx("div", { className: "builder-editor__segmented builder-editor__segmented--full builder-editor__segmented--small", role: "tablist", "aria-label": "Show", children: FILTERS.map((option) => (_jsxs("button", { type: "button", role: "tab", "aria-selected": filter === option.id, className: "builder-editor__segment", onClick: () => comments.filter.set(option.id), children: [option.label, counts[option.id] > 0 && _jsx("span", { className: "builder-editor__segment-count", children: counts[option.id] })] }, option.id))) }) }), _jsx("div", { className: "builder-comments-panel__list", children: threads.length === 0 ? (_jsxs("div", { className: "builder-editor__empty", children: [_jsx(Icon, { name: "comment", size: 20 }), _jsx("p", { children: !loaded ? 'Loading comments' : filter === 'resolved' ? 'No resolved comments' : filter === 'open' && counts.all > 0 ? 'All resolved' : 'No comments yet' }), loaded && filter !== 'resolved' && _jsx("p", { className: "builder-editor__hint", children: "Click a block on the canvas to comment on it." })] })) : (threads.map((thread) => _jsx(ThreadCard, { thread: thread, open: openId === thread.root.id, runtime: runtime, comments: comments }, thread.root.id))) })] }));
|
|
53
|
+
}
|
|
54
|
+
function ThreadCard({ thread, open, runtime, comments }) {
|
|
55
|
+
const { root, replies } = thread;
|
|
56
|
+
const block = useEditor(runtime.store, (s) => (root.blockId ? findBlock(s.view, root.blockId) : null));
|
|
57
|
+
const where = block ? blockName(block, runtime.blockLabel(block.type)) : null;
|
|
58
|
+
const last = replies.at(-1);
|
|
59
|
+
const show = () => {
|
|
60
|
+
comments.draft.set(null);
|
|
61
|
+
if (open) {
|
|
62
|
+
comments.open.set(null);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
comments.open.set(root.id);
|
|
66
|
+
if (!block)
|
|
67
|
+
return;
|
|
68
|
+
runtime.store.select(block.id);
|
|
69
|
+
runtime.postToCanvas({ type: 'scrollIntoView', id: block.id });
|
|
70
|
+
};
|
|
71
|
+
const classes = ['builder-comment-card', open && 'builder-comment-card--open', root.resolved && 'builder-comment-card--resolved'].filter(Boolean).join(' ');
|
|
72
|
+
return (_jsxs("div", { className: classes, children: [_jsxs("button", { type: "button", className: "builder-comment-card__summary", "aria-expanded": open, onClick: show, children: [_jsx(Avatar, { name: root.authorName }), _jsxs("span", { className: "builder-comment-card__main", children: [_jsxs("span", { className: "builder-comment__head", children: [_jsx("span", { className: "builder-comment__name", children: root.authorName }), _jsx("time", { className: "builder-comment__time", dateTime: root.createdAt, children: formatSaveTime(root.createdAt) }), root.resolved && (_jsx("span", { className: "builder-comment-card__resolved", "aria-label": "Resolved", children: _jsx(Icon, { name: "check", size: 12 }) }))] }), _jsx("span", { className: "builder-comment-card__body", children: root.body }), _jsxs("span", { className: "builder-comment-card__meta", children: [where ? (_jsx("span", { className: "builder-comment-card__where", children: where })) : (_jsx("span", { className: "builder-comment-card__deleted", children: "Block deleted" })), replies.length > 0 && (_jsxs("span", { children: [replies.length, " ", replies.length === 1 ? 'reply' : 'replies', last && ` · ${last.authorName}`] }))] })] })] }), open && !block && _jsx(Thread, { thread: thread, comments: comments })] }));
|
|
73
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type CommentThread } from '../../../comments/shared.js';
|
|
2
|
+
import type { CommentsController } from './controller.js';
|
|
3
|
+
/** The signed-in user's author key, to tell their own comments. */
|
|
4
|
+
export declare function useAuthorKey(): string | null;
|
|
5
|
+
export declare function Avatar({ name }: {
|
|
6
|
+
name: string;
|
|
7
|
+
}): import("react").JSX.Element;
|
|
8
|
+
type InputProps = {
|
|
9
|
+
placeholder: string;
|
|
10
|
+
submitLabel: string;
|
|
11
|
+
initial?: string;
|
|
12
|
+
focusOnMount?: boolean;
|
|
13
|
+
/** Shows Cancel, and Escape cancels. */
|
|
14
|
+
onCancel?: () => void;
|
|
15
|
+
/** True when the text was saved: the box empties. */
|
|
16
|
+
onSubmit: (body: string) => Promise<boolean>;
|
|
17
|
+
};
|
|
18
|
+
/** A text box that grows with its text. Enter sends, Shift+Enter adds a line, Escape cancels. */
|
|
19
|
+
export declare function CommentInput({ placeholder, submitLabel, initial, focusOnMount, onCancel, onSubmit }: InputProps): import("react").JSX.Element;
|
|
20
|
+
/** The thread: resolve and close in the head, the comments, and a reply box. */
|
|
21
|
+
export declare function Thread({ thread, comments, onClose }: {
|
|
22
|
+
thread: CommentThread;
|
|
23
|
+
comments: CommentsController;
|
|
24
|
+
onClose?: () => void;
|
|
25
|
+
}): import("react").JSX.Element;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
// A comment thread (the popover at a pin, and the panel for threads whose block is gone) and the
|
|
4
|
+
// text box that writes comments and replies.
|
|
5
|
+
import { useAuth, useConfig } from '@payloadcms/ui';
|
|
6
|
+
import { useEffect, useRef, useState } from 'react';
|
|
7
|
+
import { authorKeyOf, COMMENT_MAX } from '../../../comments/shared.js';
|
|
8
|
+
import { Icon } from '../icons.js';
|
|
9
|
+
import { initials } from '../live/presence.js';
|
|
10
|
+
import { formatSaveTime } from '../topbar/saveTime.js';
|
|
11
|
+
/** The signed-in user's author key, to tell their own comments. */
|
|
12
|
+
export function useAuthorKey() {
|
|
13
|
+
const { user } = useAuth();
|
|
14
|
+
const { config } = useConfig();
|
|
15
|
+
if (!user)
|
|
16
|
+
return null;
|
|
17
|
+
const u = user;
|
|
18
|
+
return authorKeyOf({ ...user, collection: typeof u.collection === 'string' ? u.collection : config.admin.user });
|
|
19
|
+
}
|
|
20
|
+
export function Avatar({ name }) {
|
|
21
|
+
return (_jsx("span", { className: "builder-comment__avatar", "aria-hidden": true, children: initials(name) }));
|
|
22
|
+
}
|
|
23
|
+
/** A text box that grows with its text. Enter sends, Shift+Enter adds a line, Escape cancels. */
|
|
24
|
+
export function CommentInput({ placeholder, submitLabel, initial = '', focusOnMount, onCancel, onSubmit }) {
|
|
25
|
+
const [text, setText] = useState(initial);
|
|
26
|
+
const [busy, setBusy] = useState(false);
|
|
27
|
+
const ref = useRef(null);
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
if (!focusOnMount)
|
|
30
|
+
return;
|
|
31
|
+
const el = ref.current;
|
|
32
|
+
el?.focus();
|
|
33
|
+
el?.setSelectionRange(el.value.length, el.value.length);
|
|
34
|
+
}, [focusOnMount]);
|
|
35
|
+
const submit = async () => {
|
|
36
|
+
if (busy || !text.trim())
|
|
37
|
+
return;
|
|
38
|
+
setBusy(true);
|
|
39
|
+
const saved = await onSubmit(text);
|
|
40
|
+
setBusy(false);
|
|
41
|
+
if (saved)
|
|
42
|
+
setText('');
|
|
43
|
+
ref.current?.focus();
|
|
44
|
+
};
|
|
45
|
+
const onKeyDown = (e) => {
|
|
46
|
+
if (e.key === 'Enter' && !e.shiftKey && !e.nativeEvent.isComposing) {
|
|
47
|
+
e.preventDefault();
|
|
48
|
+
void submit();
|
|
49
|
+
}
|
|
50
|
+
if (e.key === 'Escape' && onCancel) {
|
|
51
|
+
e.preventDefault();
|
|
52
|
+
e.stopPropagation();
|
|
53
|
+
onCancel();
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
return (_jsxs("div", { className: "builder-comment-input", children: [_jsx("textarea", { ref: ref, rows: 1, value: text, maxLength: COMMENT_MAX, placeholder: placeholder, "aria-label": placeholder, onChange: (e) => setText(e.target.value), onKeyDown: onKeyDown }), _jsxs("div", { className: "builder-comment-input__actions", children: [onCancel && (_jsx("button", { type: "button", className: "builder-comment__text-button", onClick: onCancel, children: "Cancel" })), _jsx("button", { type: "button", className: "builder-comment__send", disabled: busy || !text.trim(), "aria-label": submitLabel, "data-tooltip": `${submitLabel} · Enter`, onClick: () => void submit(), children: _jsx(Icon, { name: "arrowUp", size: 14 }) })] })] }));
|
|
57
|
+
}
|
|
58
|
+
/** One comment: author, time, text, and Edit / Delete for its author. */
|
|
59
|
+
function CommentItem({ comment, own, comments, isRoot }) {
|
|
60
|
+
const [editing, setEditing] = useState(false);
|
|
61
|
+
const [confirming, setConfirming] = useState(false);
|
|
62
|
+
const time = formatSaveTime(comment.createdAt);
|
|
63
|
+
return (_jsxs("article", { className: "builder-comment", children: [_jsx(Avatar, { name: comment.authorName }), _jsxs("div", { className: "builder-comment__main", children: [_jsxs("header", { className: "builder-comment__head", children: [_jsx("span", { className: "builder-comment__name", children: comment.authorName }), _jsxs("time", { className: "builder-comment__time", dateTime: comment.createdAt, children: [time, comment.editedAt && ' · edited'] }), own && !editing && (_jsxs("span", { className: "builder-comment__tools", children: [_jsx("button", { type: "button", className: "builder-editor__icon-button builder-editor__icon-button--small", "aria-label": "Edit", "data-tooltip": "Edit", onClick: () => setEditing(true), children: _jsx(Icon, { name: "rename", size: 13 }) }), _jsx("button", { type: "button", className: "builder-editor__icon-button builder-editor__icon-button--small", "aria-label": "Delete", "data-tooltip": "Delete", onClick: () => setConfirming(true), children: _jsx(Icon, { name: "delete", size: 13 }) })] }))] }), editing ? (_jsx(CommentInput, { placeholder: "Edit comment", submitLabel: "Save", initial: comment.body, focusOnMount: true, onCancel: () => setEditing(false), onSubmit: async (body) => {
|
|
64
|
+
const saved = await comments.edit(comment.id, body);
|
|
65
|
+
if (saved)
|
|
66
|
+
setEditing(false);
|
|
67
|
+
return saved;
|
|
68
|
+
} })) : (_jsx("p", { className: "builder-comment__body", children: comment.body })), confirming && (_jsxs("div", { className: "builder-comment__confirm", role: "alert", children: [_jsx("span", { children: isRoot ? 'Delete this thread and its replies?' : 'Delete this reply?' }), _jsx("button", { type: "button", className: "builder-comment__text-button", onClick: () => setConfirming(false), children: "Cancel" }), _jsx("button", { type: "button", className: "builder-comment__text-button builder-comment__text-button--danger", onClick: () => void comments.remove(comment.id), children: "Delete" })] }))] })] }));
|
|
69
|
+
}
|
|
70
|
+
/** The thread: resolve and close in the head, the comments, and a reply box. */
|
|
71
|
+
export function Thread({ thread, comments, onClose }) {
|
|
72
|
+
const me = useAuthorKey();
|
|
73
|
+
const { root, replies } = thread;
|
|
74
|
+
const [busy, setBusy] = useState(false);
|
|
75
|
+
const toggleResolved = async () => {
|
|
76
|
+
setBusy(true);
|
|
77
|
+
const done = await comments.setResolved(root.id, !root.resolved);
|
|
78
|
+
setBusy(false);
|
|
79
|
+
// Resolving closes the thread, as in Figma: it leaves the open list.
|
|
80
|
+
if (done && !root.resolved)
|
|
81
|
+
onClose?.();
|
|
82
|
+
};
|
|
83
|
+
return (_jsxs("div", { className: "builder-thread", children: [_jsxs("div", { className: "builder-thread__head", children: [_jsx("span", { className: "builder-thread__status", children: root.resolved ? `Resolved${root.resolvedByName ? ` by ${root.resolvedByName}` : ''}` : replies.length > 0 ? `${replies.length + 1} comments` : 'Comment' }), _jsx("button", { type: "button", className: "builder-editor__icon-button builder-editor__icon-button--small", "aria-pressed": root.resolved, "aria-label": root.resolved ? 'Reopen' : 'Resolve', "data-tooltip": root.resolved ? 'Reopen' : 'Resolve', disabled: busy, onClick: () => void toggleResolved(), children: _jsx(Icon, { name: root.resolved ? 'undo' : 'check', size: 14 }) }), onClose && (_jsx("button", { type: "button", className: "builder-editor__icon-button builder-editor__icon-button--small", "aria-label": "Close", "data-tooltip": "Close \u00B7 Esc", onClick: onClose, children: _jsx(Icon, { name: "close", size: 14 }) }))] }), _jsx("div", { className: "builder-thread__items", children: [root, ...replies].map((comment) => (_jsx(CommentItem, { comment: comment, own: comment.authorKey === me, comments: comments, isRoot: comment === root }, comment.id))) }), _jsx("div", { className: "builder-thread__reply", children: _jsx(CommentInput, { placeholder: "Reply", submitLabel: "Reply", focusOnMount: Boolean(onClose), onSubmit: (body) => comments.reply(root.id, body) }, root.id) })] }));
|
|
84
|
+
}
|