@drawnagency/primitives 0.1.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 +28 -0
- package/dist/auth/cookies.d.ts +8 -0
- package/dist/auth/cookies.d.ts.map +1 -0
- package/dist/auth/cookies.js +44 -0
- package/dist/auth/errors.d.ts +8 -0
- package/dist/auth/errors.d.ts.map +1 -0
- package/dist/auth/errors.js +10 -0
- package/dist/auth/index.d.ts +5 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +3 -0
- package/dist/auth/security.d.ts +13 -0
- package/dist/auth/security.d.ts.map +1 -0
- package/dist/auth/security.js +48 -0
- package/dist/auth/types.d.ts +64 -0
- package/dist/auth/types.d.ts.map +1 -0
- package/dist/auth/types.js +1 -0
- package/dist/components/brandguide/ColorSwatchSettings.d.ts +8 -0
- package/dist/components/brandguide/ColorSwatchSettings.d.ts.map +1 -0
- package/dist/components/brandguide/ColorSwatchSettings.js +10 -0
- package/dist/components/brandguide/Colors.d.ts +15 -0
- package/dist/components/brandguide/Colors.d.ts.map +1 -0
- package/dist/components/brandguide/Colors.js +79 -0
- package/dist/components/brandguide/DoDontList.d.ts +16 -0
- package/dist/components/brandguide/DoDontList.d.ts.map +1 -0
- package/dist/components/brandguide/DoDontList.js +22 -0
- package/dist/components/brandguide/DoDontMediaGrid.d.ts +16 -0
- package/dist/components/brandguide/DoDontMediaGrid.d.ts.map +1 -0
- package/dist/components/brandguide/DoDontMediaGrid.js +5 -0
- package/dist/components/editor/AudiencePicker.d.ts +9 -0
- package/dist/components/editor/AudiencePicker.d.ts.map +1 -0
- package/dist/components/editor/AudiencePicker.js +24 -0
- package/dist/components/editor/DeleteButton.d.ts +6 -0
- package/dist/components/editor/DeleteButton.d.ts.map +1 -0
- package/dist/components/editor/DeleteButton.js +6 -0
- package/dist/components/editor/DragHandle.d.ts +2 -0
- package/dist/components/editor/DragHandle.d.ts.map +1 -0
- package/dist/components/editor/DragHandle.js +8 -0
- package/dist/components/editor/InsertButton.d.ts +7 -0
- package/dist/components/editor/InsertButton.d.ts.map +1 -0
- package/dist/components/editor/InsertButton.js +7 -0
- package/dist/components/editor/SectionWrapper.d.ts +3 -0
- package/dist/components/editor/SectionWrapper.d.ts.map +1 -0
- package/dist/components/editor/SectionWrapper.js +135 -0
- package/dist/components/editor/SettingsButton.d.ts +6 -0
- package/dist/components/editor/SettingsButton.d.ts.map +1 -0
- package/dist/components/editor/SettingsButton.js +6 -0
- package/dist/components/editor/SettingsForm.d.ts +13 -0
- package/dist/components/editor/SettingsForm.d.ts.map +1 -0
- package/dist/components/editor/SettingsForm.js +64 -0
- package/dist/components/editor/StatusBadge.d.ts +7 -0
- package/dist/components/editor/StatusBadge.d.ts.map +1 -0
- package/dist/components/editor/StatusBadge.js +10 -0
- package/dist/components/editor/StatusPicker.d.ts +9 -0
- package/dist/components/editor/StatusPicker.d.ts.map +1 -0
- package/dist/components/editor/StatusPicker.js +30 -0
- package/dist/components/editor/index.d.ts +8 -0
- package/dist/components/editor/index.d.ts.map +1 -0
- package/dist/components/editor/index.js +7 -0
- package/dist/components/primitives/CustomParagraph.d.ts +2 -0
- package/dist/components/primitives/CustomParagraph.d.ts.map +1 -0
- package/dist/components/primitives/CustomParagraph.js +24 -0
- package/dist/components/primitives/EditableGrid.d.ts +19 -0
- package/dist/components/primitives/EditableGrid.d.ts.map +1 -0
- package/dist/components/primitives/EditableGrid.js +90 -0
- package/dist/components/primitives/EditableList.d.ts +15 -0
- package/dist/components/primitives/EditableList.d.ts.map +1 -0
- package/dist/components/primitives/EditableList.js +54 -0
- package/dist/components/primitives/EditablePlainText.d.ts +12 -0
- package/dist/components/primitives/EditablePlainText.d.ts.map +1 -0
- package/dist/components/primitives/EditablePlainText.js +52 -0
- package/dist/components/primitives/EditableRichText.d.ts +11 -0
- package/dist/components/primitives/EditableRichText.d.ts.map +1 -0
- package/dist/components/primitives/EditableRichText.js +86 -0
- package/dist/components/primitives/HeadingSection.d.ts +10 -0
- package/dist/components/primitives/HeadingSection.d.ts.map +1 -0
- package/dist/components/primitives/HeadingSection.js +7 -0
- package/dist/components/primitives/IconPicker.d.ts +9 -0
- package/dist/components/primitives/IconPicker.d.ts.map +1 -0
- package/dist/components/primitives/IconPicker.js +21 -0
- package/dist/components/primitives/LinkPopover.d.ts +8 -0
- package/dist/components/primitives/LinkPopover.d.ts.map +1 -0
- package/dist/components/primitives/LinkPopover.js +48 -0
- package/dist/components/primitives/MediaSettingsForms.d.ts +19 -0
- package/dist/components/primitives/MediaSettingsForms.d.ts.map +1 -0
- package/dist/components/primitives/MediaSettingsForms.js +42 -0
- package/dist/components/primitives/ResolvedMedia.d.ts +8 -0
- package/dist/components/primitives/ResolvedMedia.d.ts.map +1 -0
- package/dist/components/primitives/ResolvedMedia.js +9 -0
- package/dist/components/primitives/RichTextToolbar.d.ts +9 -0
- package/dist/components/primitives/RichTextToolbar.d.ts.map +1 -0
- package/dist/components/primitives/RichTextToolbar.js +26 -0
- package/dist/components/primitives/tiptap-presets.d.ts +4 -0
- package/dist/components/primitives/tiptap-presets.d.ts.map +1 -0
- package/dist/components/primitives/tiptap-presets.js +44 -0
- package/dist/components/primitives/useEditableCollection.d.ts +19 -0
- package/dist/components/primitives/useEditableCollection.d.ts.map +1 -0
- package/dist/components/primitives/useEditableCollection.js +61 -0
- package/dist/components/primitives/useEditablePlainText.d.ts +14 -0
- package/dist/components/primitives/useEditablePlainText.d.ts.map +1 -0
- package/dist/components/primitives/useEditablePlainText.js +27 -0
- package/dist/components/primitives/useEditableRichText.d.ts +16 -0
- package/dist/components/primitives/useEditableRichText.d.ts.map +1 -0
- package/dist/components/primitives/useEditableRichText.js +52 -0
- package/dist/components/sections/Button/CTAButton.d.ts +11 -0
- package/dist/components/sections/Button/CTAButton.d.ts.map +1 -0
- package/dist/components/sections/Button/CTAButton.js +18 -0
- package/dist/components/sections/Button/index.d.ts +11 -0
- package/dist/components/sections/Button/index.d.ts.map +1 -0
- package/dist/components/sections/Button/index.js +28 -0
- package/dist/components/sections/Colors/index.d.ts +22 -0
- package/dist/components/sections/Colors/index.d.ts.map +1 -0
- package/dist/components/sections/Colors/index.js +34 -0
- package/dist/components/sections/DoDontList/index.d.ts +21 -0
- package/dist/components/sections/DoDontList/index.d.ts.map +1 -0
- package/dist/components/sections/DoDontList/index.js +33 -0
- package/dist/components/sections/DoDontMediaGrid/index.d.ts +55 -0
- package/dist/components/sections/DoDontMediaGrid/index.d.ts.map +1 -0
- package/dist/components/sections/DoDontMediaGrid/index.js +41 -0
- package/dist/components/sections/IconList/IconList.d.ts +20 -0
- package/dist/components/sections/IconList/IconList.d.ts.map +1 -0
- package/dist/components/sections/IconList/IconList.js +131 -0
- package/dist/components/sections/IconList/IconListSettings.d.ts +11 -0
- package/dist/components/sections/IconList/IconListSettings.d.ts.map +1 -0
- package/dist/components/sections/IconList/IconListSettings.js +22 -0
- package/dist/components/sections/IconList/index.d.ts +17 -0
- package/dist/components/sections/IconList/index.d.ts.map +1 -0
- package/dist/components/sections/IconList/index.js +27 -0
- package/dist/components/sections/LinkHeading/index.d.ts +8 -0
- package/dist/components/sections/LinkHeading/index.d.ts.map +1 -0
- package/dist/components/sections/LinkHeading/index.js +15 -0
- package/dist/components/sections/MediaGrid/MediaGrid.d.ts +17 -0
- package/dist/components/sections/MediaGrid/MediaGrid.d.ts.map +1 -0
- package/dist/components/sections/MediaGrid/MediaGrid.js +62 -0
- package/dist/components/sections/MediaGrid/index.d.ts +55 -0
- package/dist/components/sections/MediaGrid/index.d.ts.map +1 -0
- package/dist/components/sections/MediaGrid/index.js +35 -0
- package/dist/components/sections/Prose/Prose.d.ts +8 -0
- package/dist/components/sections/Prose/Prose.d.ts.map +1 -0
- package/dist/components/sections/Prose/Prose.js +11 -0
- package/dist/components/sections/Prose/index.d.ts +8 -0
- package/dist/components/sections/Prose/index.d.ts.map +1 -0
- package/dist/components/sections/Prose/index.js +15 -0
- package/dist/components/sections/SectionLayout.d.ts +11 -0
- package/dist/components/sections/SectionLayout.d.ts.map +1 -0
- package/dist/components/sections/SectionLayout.js +15 -0
- package/dist/components/sections/SplitContent/SplitContent.d.ts +11 -0
- package/dist/components/sections/SplitContent/SplitContent.d.ts.map +1 -0
- package/dist/components/sections/SplitContent/SplitContent.js +31 -0
- package/dist/components/sections/SplitContent/SplitContentSettings.d.ts +9 -0
- package/dist/components/sections/SplitContent/SplitContentSettings.d.ts.map +1 -0
- package/dist/components/sections/SplitContent/SplitContentSettings.js +17 -0
- package/dist/components/sections/SplitContent/index.d.ts +13 -0
- package/dist/components/sections/SplitContent/index.d.ts.map +1 -0
- package/dist/components/sections/SplitContent/index.js +27 -0
- package/dist/components/sections/SubHeading/index.d.ts +9 -0
- package/dist/components/sections/SubHeading/index.d.ts.map +1 -0
- package/dist/components/sections/SubHeading/index.js +18 -0
- package/dist/components/sections/SubSubHeading/index.d.ts +9 -0
- package/dist/components/sections/SubSubHeading/index.d.ts.map +1 -0
- package/dist/components/sections/SubSubHeading/index.js +18 -0
- package/dist/components/sections/ViewRenderer.d.ts +8 -0
- package/dist/components/sections/ViewRenderer.d.ts.map +1 -0
- package/dist/components/sections/ViewRenderer.js +13 -0
- package/dist/components/sections/register-schemas.d.ts +2 -0
- package/dist/components/sections/register-schemas.d.ts.map +1 -0
- package/dist/components/sections/register-schemas.js +15 -0
- package/dist/components/sections/register.d.ts +2 -0
- package/dist/components/sections/register.d.ts.map +1 -0
- package/dist/components/sections/register.js +15 -0
- package/dist/components/shared/Button.d.ts +15 -0
- package/dist/components/shared/Button.d.ts.map +1 -0
- package/dist/components/shared/Button.js +27 -0
- package/dist/components/shared/Checkbox.d.ts +14 -0
- package/dist/components/shared/Checkbox.d.ts.map +1 -0
- package/dist/components/shared/Checkbox.js +10 -0
- package/dist/components/shared/ColorPicker.d.ts +9 -0
- package/dist/components/shared/ColorPicker.d.ts.map +1 -0
- package/dist/components/shared/ColorPicker.js +5 -0
- package/dist/components/shared/ErrorBoundary.d.ts +24 -0
- package/dist/components/shared/ErrorBoundary.d.ts.map +1 -0
- package/dist/components/shared/ErrorBoundary.js +30 -0
- package/dist/components/shared/FontPicker.d.ts +8 -0
- package/dist/components/shared/FontPicker.d.ts.map +1 -0
- package/dist/components/shared/FontPicker.js +190 -0
- package/dist/components/shared/FormLabel.d.ts +8 -0
- package/dist/components/shared/FormLabel.d.ts.map +1 -0
- package/dist/components/shared/FormLabel.js +5 -0
- package/dist/components/shared/IconButton.d.ts +12 -0
- package/dist/components/shared/IconButton.d.ts.map +1 -0
- package/dist/components/shared/IconButton.js +16 -0
- package/dist/components/shared/Input.d.ts +8 -0
- package/dist/components/shared/Input.d.ts.map +1 -0
- package/dist/components/shared/Input.js +8 -0
- package/dist/components/shared/Navigation.d.ts +9 -0
- package/dist/components/shared/Navigation.d.ts.map +1 -0
- package/dist/components/shared/Navigation.js +71 -0
- package/dist/components/shared/PasswordInput.d.ts +13 -0
- package/dist/components/shared/PasswordInput.d.ts.map +1 -0
- package/dist/components/shared/PasswordInput.js +11 -0
- package/dist/components/shared/Popover.d.ts +12 -0
- package/dist/components/shared/Popover.d.ts.map +1 -0
- package/dist/components/shared/Popover.js +33 -0
- package/dist/components/shared/PopoverItem.d.ts +7 -0
- package/dist/components/shared/PopoverItem.d.ts.map +1 -0
- package/dist/components/shared/PopoverItem.js +6 -0
- package/dist/components/shared/Select.d.ts +16 -0
- package/dist/components/shared/Select.d.ts.map +1 -0
- package/dist/components/shared/Select.js +9 -0
- package/dist/components/shared/Textarea.d.ts +8 -0
- package/dist/components/shared/Textarea.d.ts.map +1 -0
- package/dist/components/shared/Textarea.js +8 -0
- package/dist/components/shared/Toggle.d.ts +10 -0
- package/dist/components/shared/Toggle.d.ts.map +1 -0
- package/dist/components/shared/Toggle.js +5 -0
- package/dist/components/shared/Tooltip.d.ts +12 -0
- package/dist/components/shared/Tooltip.d.ts.map +1 -0
- package/dist/components/shared/Tooltip.js +8 -0
- package/dist/components/shared/icons.d.ts +17 -0
- package/dist/components/shared/icons.d.ts.map +1 -0
- package/dist/components/shared/icons.js +23 -0
- package/dist/components/shell/AudienceAddForm.d.ts +11 -0
- package/dist/components/shell/AudienceAddForm.d.ts.map +1 -0
- package/dist/components/shell/AudienceAddForm.js +43 -0
- package/dist/components/shell/AudienceRow.d.ts +15 -0
- package/dist/components/shell/AudienceRow.d.ts.map +1 -0
- package/dist/components/shell/AudienceRow.js +74 -0
- package/dist/components/shell/EditorContext.d.ts +14 -0
- package/dist/components/shell/EditorContext.d.ts.map +1 -0
- package/dist/components/shell/EditorContext.js +24 -0
- package/dist/components/shell/EditorLoginForm.d.ts +13 -0
- package/dist/components/shell/EditorLoginForm.d.ts.map +1 -0
- package/dist/components/shell/EditorLoginForm.js +46 -0
- package/dist/components/shell/EditorModal.d.ts +13 -0
- package/dist/components/shell/EditorModal.d.ts.map +1 -0
- package/dist/components/shell/EditorModal.js +43 -0
- package/dist/components/shell/EditorModalContext.d.ts +16 -0
- package/dist/components/shell/EditorModalContext.d.ts.map +1 -0
- package/dist/components/shell/EditorModalContext.js +20 -0
- package/dist/components/shell/EditorShell.d.ts +22 -0
- package/dist/components/shell/EditorShell.d.ts.map +1 -0
- package/dist/components/shell/EditorShell.js +483 -0
- package/dist/components/shell/MediaLibraryContext.d.ts +14 -0
- package/dist/components/shell/MediaLibraryContext.d.ts.map +1 -0
- package/dist/components/shell/MediaLibraryContext.js +5 -0
- package/dist/components/shell/MediaLibraryModal.d.ts +14 -0
- package/dist/components/shell/MediaLibraryModal.d.ts.map +1 -0
- package/dist/components/shell/MediaLibraryModal.js +145 -0
- package/dist/components/shell/ProcessingIndicator.d.ts +7 -0
- package/dist/components/shell/ProcessingIndicator.d.ts.map +1 -0
- package/dist/components/shell/ProcessingIndicator.js +15 -0
- package/dist/components/shell/SectionSkeleton.d.ts +9 -0
- package/dist/components/shell/SectionSkeleton.d.ts.map +1 -0
- package/dist/components/shell/SectionSkeleton.js +22 -0
- package/dist/components/shell/SectionTypePicker.d.ts +14 -0
- package/dist/components/shell/SectionTypePicker.d.ts.map +1 -0
- package/dist/components/shell/SectionTypePicker.js +15 -0
- package/dist/components/shell/SiteSettingsDisplay.d.ts +8 -0
- package/dist/components/shell/SiteSettingsDisplay.d.ts.map +1 -0
- package/dist/components/shell/SiteSettingsDisplay.js +28 -0
- package/dist/components/shell/SiteSettingsModal.d.ts +24 -0
- package/dist/components/shell/SiteSettingsModal.d.ts.map +1 -0
- package/dist/components/shell/SiteSettingsModal.js +40 -0
- package/dist/components/shell/SiteSettingsUsers.d.ts +9 -0
- package/dist/components/shell/SiteSettingsUsers.d.ts.map +1 -0
- package/dist/components/shell/SiteSettingsUsers.js +87 -0
- package/dist/components/shell/SiteSettingsViewerAccess.d.ts +9 -0
- package/dist/components/shell/SiteSettingsViewerAccess.d.ts.map +1 -0
- package/dist/components/shell/SiteSettingsViewerAccess.js +94 -0
- package/dist/components/shell/ViewerLoginForm.d.ts +10 -0
- package/dist/components/shell/ViewerLoginForm.d.ts.map +1 -0
- package/dist/components/shell/ViewerLoginForm.js +40 -0
- package/dist/data/google-fonts.json +7718 -0
- package/dist/hooks/index.d.ts +7 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +6 -0
- package/dist/hooks/useActiveHeadings.d.ts +7 -0
- package/dist/hooks/useActiveHeadings.d.ts.map +1 -0
- package/dist/hooks/useActiveHeadings.js +99 -0
- package/dist/hooks/useEditorPersistence.d.ts +13 -0
- package/dist/hooks/useEditorPersistence.d.ts.map +1 -0
- package/dist/hooks/useEditorPersistence.js +73 -0
- package/dist/hooks/useEditorPublish.d.ts +24 -0
- package/dist/hooks/useEditorPublish.d.ts.map +1 -0
- package/dist/hooks/useEditorPublish.js +145 -0
- package/dist/hooks/useFocusTrap.d.ts +3 -0
- package/dist/hooks/useFocusTrap.d.ts.map +1 -0
- package/dist/hooks/useFocusTrap.js +51 -0
- package/dist/hooks/useMediaPipeline.d.ts +65 -0
- package/dist/hooks/useMediaPipeline.d.ts.map +1 -0
- package/dist/hooks/useMediaPipeline.js +253 -0
- package/dist/hooks/useResolvedMedia.d.ts +9 -0
- package/dist/hooks/useResolvedMedia.d.ts.map +1 -0
- package/dist/hooks/useResolvedMedia.js +39 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/lib/cn.d.ts +3 -0
- package/dist/lib/cn.d.ts.map +1 -0
- package/dist/lib/cn.js +5 -0
- package/dist/lib/contrast.d.ts +2 -0
- package/dist/lib/contrast.d.ts.map +1 -0
- package/dist/lib/contrast.js +11 -0
- package/dist/lib/dexie.d.ts +41 -0
- package/dist/lib/dexie.d.ts.map +1 -0
- package/dist/lib/dexie.js +236 -0
- package/dist/lib/events.d.ts +12 -0
- package/dist/lib/events.d.ts.map +1 -0
- package/dist/lib/events.js +15 -0
- package/dist/lib/google-fonts.d.ts +2 -0
- package/dist/lib/google-fonts.d.ts.map +1 -0
- package/dist/lib/google-fonts.js +11 -0
- package/dist/lib/grid.d.ts +2 -0
- package/dist/lib/grid.d.ts.map +1 -0
- package/dist/lib/grid.js +7 -0
- package/dist/lib/icons.d.ts +9 -0
- package/dist/lib/icons.d.ts.map +1 -0
- package/dist/lib/icons.js +27 -0
- package/dist/lib/index.d.ts +13 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/index.js +12 -0
- package/dist/lib/loader.d.ts +28 -0
- package/dist/lib/loader.d.ts.map +1 -0
- package/dist/lib/loader.js +57 -0
- package/dist/lib/nav.d.ts +15 -0
- package/dist/lib/nav.d.ts.map +1 -0
- package/dist/lib/nav.js +58 -0
- package/dist/lib/registry.d.ts +110 -0
- package/dist/lib/registry.d.ts.map +1 -0
- package/dist/lib/registry.js +64 -0
- package/dist/lib/safeRedirect.d.ts +7 -0
- package/dist/lib/safeRedirect.d.ts.map +1 -0
- package/dist/lib/safeRedirect.js +11 -0
- package/dist/lib/sanitize.d.ts +2 -0
- package/dist/lib/sanitize.d.ts.map +1 -0
- package/dist/lib/sanitize.js +6 -0
- package/dist/lib/timestamp.d.ts +2 -0
- package/dist/lib/timestamp.d.ts.map +1 -0
- package/dist/lib/timestamp.js +28 -0
- package/dist/media/github.d.ts +3 -0
- package/dist/media/github.d.ts.map +1 -0
- package/dist/media/github.js +60 -0
- package/dist/media/index.d.ts +8 -0
- package/dist/media/index.d.ts.map +1 -0
- package/dist/media/index.js +9 -0
- package/dist/media/queue.d.ts +74 -0
- package/dist/media/queue.d.ts.map +1 -0
- package/dist/media/queue.js +116 -0
- package/dist/media/resolve.d.ts +14 -0
- package/dist/media/resolve.d.ts.map +1 -0
- package/dist/media/resolve.js +50 -0
- package/dist/media/types.d.ts +42 -0
- package/dist/media/types.d.ts.map +1 -0
- package/dist/media/types.js +1 -0
- package/dist/media/utils.d.ts +7 -0
- package/dist/media/utils.d.ts.map +1 -0
- package/dist/media/utils.js +41 -0
- package/dist/media/videoPoster.d.ts +6 -0
- package/dist/media/videoPoster.d.ts.map +1 -0
- package/dist/media/videoPoster.js +44 -0
- package/dist/media/worker.d.ts +36 -0
- package/dist/media/worker.d.ts.map +1 -0
- package/dist/media/worker.js +73 -0
- package/dist/schemas/audience.d.ts +12 -0
- package/dist/schemas/audience.d.ts.map +1 -0
- package/dist/schemas/audience.js +19 -0
- package/dist/schemas/auth.d.ts +36 -0
- package/dist/schemas/auth.d.ts.map +1 -0
- package/dist/schemas/auth.js +22 -0
- package/dist/schemas/index.d.ts +8 -0
- package/dist/schemas/index.d.ts.map +1 -0
- package/dist/schemas/index.js +7 -0
- package/dist/schemas/media-grid-options.d.ts +8 -0
- package/dist/schemas/media-grid-options.d.ts.map +1 -0
- package/dist/schemas/media-grid-options.js +7 -0
- package/dist/schemas/media.d.ts +63 -0
- package/dist/schemas/media.d.ts.map +1 -0
- package/dist/schemas/media.js +28 -0
- package/dist/schemas/sections.d.ts +12 -0
- package/dist/schemas/sections.d.ts.map +1 -0
- package/dist/schemas/sections.js +12 -0
- package/dist/schemas/shared.d.ts +98 -0
- package/dist/schemas/shared.d.ts.map +1 -0
- package/dist/schemas/shared.js +71 -0
- package/dist/schemas/site-config.d.ts +48 -0
- package/dist/schemas/site-config.d.ts.map +1 -0
- package/dist/schemas/site-config.js +26 -0
- package/package.json +57 -0
- package/src/auth/cookies.ts +51 -0
- package/src/auth/errors.ts +10 -0
- package/src/auth/index.ts +15 -0
- package/src/auth/security.ts +44 -0
- package/src/auth/types.ts +61 -0
- package/src/components/brandguide/ColorSwatchSettings.tsx +34 -0
- package/src/components/brandguide/Colors.tsx +277 -0
- package/src/components/brandguide/DoDontList.tsx +67 -0
- package/src/components/brandguide/DoDontMediaGrid.tsx +19 -0
- package/src/components/editor/AudiencePicker.tsx +103 -0
- package/src/components/editor/DeleteButton.tsx +18 -0
- package/src/components/editor/DragHandle.tsx +18 -0
- package/src/components/editor/InsertButton.tsx +22 -0
- package/src/components/editor/SectionWrapper.tsx +279 -0
- package/src/components/editor/SettingsButton.tsx +17 -0
- package/src/components/editor/SettingsForm.tsx +159 -0
- package/src/components/editor/StatusBadge.tsx +30 -0
- package/src/components/editor/StatusPicker.tsx +86 -0
- package/src/components/editor/index.ts +7 -0
- package/src/components/primitives/CustomParagraph.ts +25 -0
- package/src/components/primitives/EditableGrid.tsx +260 -0
- package/src/components/primitives/EditableList.tsx +160 -0
- package/src/components/primitives/EditablePlainText.tsx +99 -0
- package/src/components/primitives/EditableRichText.tsx +132 -0
- package/src/components/primitives/HeadingSection.tsx +25 -0
- package/src/components/primitives/IconPicker.tsx +60 -0
- package/src/components/primitives/LinkPopover.tsx +109 -0
- package/src/components/primitives/MediaSettingsForms.tsx +109 -0
- package/src/components/primitives/ResolvedMedia.tsx +36 -0
- package/src/components/primitives/RichTextToolbar.tsx +149 -0
- package/src/components/primitives/tiptap-presets.ts +50 -0
- package/src/components/primitives/useEditableCollection.ts +104 -0
- package/src/components/primitives/useEditablePlainText.ts +49 -0
- package/src/components/primitives/useEditableRichText.ts +74 -0
- package/src/components/sections/Button/CTAButton.tsx +50 -0
- package/src/components/sections/Button/index.tsx +37 -0
- package/src/components/sections/Colors/index.tsx +45 -0
- package/src/components/sections/DoDontList/index.tsx +43 -0
- package/src/components/sections/DoDontMediaGrid/index.tsx +53 -0
- package/src/components/sections/IconList/IconList.tsx +462 -0
- package/src/components/sections/IconList/IconListSettings.tsx +81 -0
- package/src/components/sections/IconList/index.tsx +36 -0
- package/src/components/sections/LinkHeading/index.tsx +24 -0
- package/src/components/sections/MediaGrid/MediaGrid.tsx +219 -0
- package/src/components/sections/MediaGrid/index.tsx +47 -0
- package/src/components/sections/Prose/Prose.tsx +34 -0
- package/src/components/sections/Prose/index.tsx +18 -0
- package/src/components/sections/SectionLayout.tsx +31 -0
- package/src/components/sections/SplitContent/SplitContent.tsx +77 -0
- package/src/components/sections/SplitContent/SplitContentSettings.tsx +42 -0
- package/src/components/sections/SplitContent/index.tsx +36 -0
- package/src/components/sections/SubHeading/index.tsx +27 -0
- package/src/components/sections/SubSubHeading/index.tsx +27 -0
- package/src/components/sections/ViewRenderer.tsx +29 -0
- package/src/components/sections/register-schemas.ts +16 -0
- package/src/components/sections/register.ts +16 -0
- package/src/components/shared/Button.tsx +77 -0
- package/src/components/shared/Checkbox.tsx +73 -0
- package/src/components/shared/ColorPicker.tsx +28 -0
- package/src/components/shared/ErrorBoundary.tsx +92 -0
- package/src/components/shared/FontPicker.tsx +300 -0
- package/src/components/shared/FormLabel.tsx +18 -0
- package/src/components/shared/IconButton.tsx +45 -0
- package/src/components/shared/Input.tsx +34 -0
- package/src/components/shared/Navigation.tsx +196 -0
- package/src/components/shared/PasswordInput.tsx +64 -0
- package/src/components/shared/Popover.tsx +61 -0
- package/src/components/shared/PopoverItem.tsx +24 -0
- package/src/components/shared/Select.tsx +60 -0
- package/src/components/shared/Textarea.tsx +34 -0
- package/src/components/shared/Toggle.tsx +35 -0
- package/src/components/shared/Tooltip.tsx +28 -0
- package/src/components/shared/icons.tsx +28 -0
- package/src/components/shell/AudienceAddForm.tsx +94 -0
- package/src/components/shell/AudienceRow.tsx +171 -0
- package/src/components/shell/EditorContext.tsx +44 -0
- package/src/components/shell/EditorLoginForm.tsx +130 -0
- package/src/components/shell/EditorModal.tsx +93 -0
- package/src/components/shell/EditorModalContext.tsx +40 -0
- package/src/components/shell/EditorShell.tsx +910 -0
- package/src/components/shell/MediaLibraryContext.tsx +19 -0
- package/src/components/shell/MediaLibraryModal.tsx +371 -0
- package/src/components/shell/ProcessingIndicator.tsx +84 -0
- package/src/components/shell/SectionSkeleton.tsx +54 -0
- package/src/components/shell/SectionTypePicker.tsx +47 -0
- package/src/components/shell/SiteSettingsDisplay.tsx +78 -0
- package/src/components/shell/SiteSettingsModal.tsx +129 -0
- package/src/components/shell/SiteSettingsUsers.tsx +190 -0
- package/src/components/shell/SiteSettingsViewerAccess.tsx +171 -0
- package/src/components/shell/ViewerLoginForm.tsx +95 -0
- package/src/data/google-fonts.json +7718 -0
- package/src/env.d.ts +3 -0
- package/src/hooks/index.ts +6 -0
- package/src/hooks/useActiveHeadings.ts +120 -0
- package/src/hooks/useEditorPersistence.ts +103 -0
- package/src/hooks/useEditorPublish.ts +187 -0
- package/src/hooks/useFocusTrap.ts +57 -0
- package/src/hooks/useMediaPipeline.ts +309 -0
- package/src/hooks/useResolvedMedia.ts +54 -0
- package/src/index.ts +4 -0
- package/src/lib/cn.ts +6 -0
- package/src/lib/contrast.ts +11 -0
- package/src/lib/dexie.ts +347 -0
- package/src/lib/events.ts +23 -0
- package/src/lib/google-fonts.ts +10 -0
- package/src/lib/grid.ts +7 -0
- package/src/lib/icons.ts +58 -0
- package/src/lib/index.ts +35 -0
- package/src/lib/loader.ts +81 -0
- package/src/lib/nav.ts +64 -0
- package/src/lib/registry.ts +202 -0
- package/src/lib/safeRedirect.ts +11 -0
- package/src/lib/sanitize.ts +6 -0
- package/src/lib/timestamp.ts +31 -0
- package/src/media/github.ts +72 -0
- package/src/media/index.ts +12 -0
- package/src/media/queue.ts +166 -0
- package/src/media/resolve.ts +63 -0
- package/src/media/types.ts +58 -0
- package/src/media/utils.ts +48 -0
- package/src/media/videoPoster.ts +53 -0
- package/src/media/worker.ts +122 -0
- package/src/schemas/audience.ts +28 -0
- package/src/schemas/auth.ts +31 -0
- package/src/schemas/index.ts +7 -0
- package/src/schemas/media-grid-options.ts +8 -0
- package/src/schemas/media.ts +40 -0
- package/src/schemas/sections.ts +24 -0
- package/src/schemas/shared.ts +96 -0
- package/src/schemas/site-config.ts +38 -0
package/src/env.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { useActiveHeadings } from "./useActiveHeadings";
|
|
2
|
+
export { useEditorPersistence } from "./useEditorPersistence";
|
|
3
|
+
export { useEditorPublish } from "./useEditorPublish";
|
|
4
|
+
export { useFocusTrap } from "./useFocusTrap";
|
|
5
|
+
export { useMediaPipeline } from "./useMediaPipeline";
|
|
6
|
+
export { useResolvedMedia } from "./useResolvedMedia";
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { useEffect, useMemo, useRef, useState, useCallback } from "react";
|
|
2
|
+
|
|
3
|
+
export function useActiveHeadings(
|
|
4
|
+
parentIds: string[],
|
|
5
|
+
childIdsByParent: Record<string, string[]>,
|
|
6
|
+
grandchildIdsByChild: Record<string, string[]>,
|
|
7
|
+
headerOffset: number = 80,
|
|
8
|
+
) {
|
|
9
|
+
const [activeParentId, setActiveParentId] = useState<string>("");
|
|
10
|
+
const [activeChildId, setActiveChildId] = useState<string>("");
|
|
11
|
+
const [activeGrandchildId, setActiveGrandchildId] = useState<string>("");
|
|
12
|
+
|
|
13
|
+
const childKey = useMemo(
|
|
14
|
+
() => Object.entries(childIdsByParent).map(([k, v]) => `${k}:${v.join(",")}`).join("|"),
|
|
15
|
+
[childIdsByParent],
|
|
16
|
+
);
|
|
17
|
+
const grandchildKey = useMemo(
|
|
18
|
+
() => Object.entries(grandchildIdsByChild).map(([k, v]) => `${k}:${v.join(",")}`).join("|"),
|
|
19
|
+
[grandchildIdsByChild],
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
// Use refs for comparison inside the effect to avoid re-render loops
|
|
23
|
+
const activeParentRef = useRef("");
|
|
24
|
+
const activeChildRef = useRef("");
|
|
25
|
+
const activeGrandchildRef = useRef("");
|
|
26
|
+
const ticking = useRef(false);
|
|
27
|
+
const transitionTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
28
|
+
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
if (parentIds.length === 0) return;
|
|
31
|
+
|
|
32
|
+
let parentEls: { id: string; el: HTMLElement }[] = [];
|
|
33
|
+
|
|
34
|
+
const collect = () => {
|
|
35
|
+
parentEls = parentIds
|
|
36
|
+
.map((id) => ({ id, el: document.getElementById(id) as HTMLElement }))
|
|
37
|
+
.filter((x) => !!x.el);
|
|
38
|
+
};
|
|
39
|
+
collect();
|
|
40
|
+
|
|
41
|
+
const findActive = (ids: string[]): string => {
|
|
42
|
+
let active = "";
|
|
43
|
+
for (const id of ids) {
|
|
44
|
+
const el = document.getElementById(id);
|
|
45
|
+
if (!el) continue;
|
|
46
|
+
if (el.getBoundingClientRect().top - headerOffset <= 0) active = id;
|
|
47
|
+
else break;
|
|
48
|
+
}
|
|
49
|
+
return active;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const computeActive = () => {
|
|
53
|
+
const parent = findActive(parentIds) || parentEls[0]?.id || "";
|
|
54
|
+
if (!parent) return;
|
|
55
|
+
|
|
56
|
+
if (activeParentRef.current !== parent) {
|
|
57
|
+
if (transitionTimeoutRef.current) clearTimeout(transitionTimeoutRef.current);
|
|
58
|
+
if (activeParentRef.current) {
|
|
59
|
+
// Delay parent transitions to prevent flashing
|
|
60
|
+
transitionTimeoutRef.current = setTimeout(() => {
|
|
61
|
+
activeParentRef.current = parent;
|
|
62
|
+
setActiveParentId(parent);
|
|
63
|
+
}, 250);
|
|
64
|
+
} else {
|
|
65
|
+
activeParentRef.current = parent;
|
|
66
|
+
setActiveParentId(parent);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const child = findActive(childIdsByParent[parent] || []);
|
|
71
|
+
if (activeChildRef.current !== child) {
|
|
72
|
+
activeChildRef.current = child;
|
|
73
|
+
setActiveChildId(child);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const grandchild = findActive(grandchildIdsByChild[child] || []);
|
|
77
|
+
if (activeGrandchildRef.current !== grandchild) {
|
|
78
|
+
activeGrandchildRef.current = grandchild;
|
|
79
|
+
setActiveGrandchildId(grandchild);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const onScroll = () => {
|
|
84
|
+
if (!ticking.current) {
|
|
85
|
+
ticking.current = true;
|
|
86
|
+
requestAnimationFrame(() => {
|
|
87
|
+
computeActive();
|
|
88
|
+
ticking.current = false;
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
const onResize = () => {
|
|
94
|
+
collect();
|
|
95
|
+
computeActive();
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
window.addEventListener("scroll", onScroll, { passive: true });
|
|
99
|
+
window.addEventListener("resize", onResize);
|
|
100
|
+
|
|
101
|
+
// Initial compute
|
|
102
|
+
computeActive();
|
|
103
|
+
|
|
104
|
+
return () => {
|
|
105
|
+
window.removeEventListener("scroll", onScroll);
|
|
106
|
+
window.removeEventListener("resize", onResize);
|
|
107
|
+
if (transitionTimeoutRef.current) clearTimeout(transitionTimeoutRef.current);
|
|
108
|
+
};
|
|
109
|
+
// Only stable values in dep array — NO state variables
|
|
110
|
+
}, [parentIds.join("|"), childKey, grandchildKey, headerOffset]);
|
|
111
|
+
|
|
112
|
+
const setActiveSection = useCallback((id: string) => {
|
|
113
|
+
const newHash = `#${id}`;
|
|
114
|
+
if (window.location.hash !== newHash) {
|
|
115
|
+
window.history.replaceState(null, "", newHash);
|
|
116
|
+
}
|
|
117
|
+
}, []);
|
|
118
|
+
|
|
119
|
+
return { activeParentId, activeChildId, activeGrandchildId, setActiveSection };
|
|
120
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { useCallback, useRef, useEffect } from "react";
|
|
2
|
+
import type { SectionContent } from "../schemas/sections";
|
|
3
|
+
import type { SiteIndex } from "../schemas/site-config";
|
|
4
|
+
import { persistAll, persistSiteConfig } from "../lib/dexie";
|
|
5
|
+
|
|
6
|
+
interface PersistenceState {
|
|
7
|
+
pendingSections: Map<string, SectionContent>;
|
|
8
|
+
pendingDeletes: Set<string>;
|
|
9
|
+
indexDirty: boolean;
|
|
10
|
+
configDirty: boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function useEditorPersistence(siteIndexRef: React.RefObject<SiteIndex>) {
|
|
14
|
+
const state = useRef<PersistenceState>({
|
|
15
|
+
pendingSections: new Map(),
|
|
16
|
+
pendingDeletes: new Set(),
|
|
17
|
+
indexDirty: false,
|
|
18
|
+
configDirty: false,
|
|
19
|
+
});
|
|
20
|
+
const flushTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
21
|
+
|
|
22
|
+
const flushToDexie = useCallback(async () => {
|
|
23
|
+
const s = state.current;
|
|
24
|
+
if (s.pendingSections.size === 0 && !s.indexDirty && s.pendingDeletes.size === 0) return;
|
|
25
|
+
|
|
26
|
+
const entries = Array.from(s.pendingSections.entries()).map(([sectionId, content]) => ({
|
|
27
|
+
sectionId,
|
|
28
|
+
content,
|
|
29
|
+
}));
|
|
30
|
+
const deletedIds = Array.from(s.pendingDeletes);
|
|
31
|
+
|
|
32
|
+
s.pendingSections = new Map();
|
|
33
|
+
s.pendingDeletes = new Set();
|
|
34
|
+
const wasIndexDirty = s.indexDirty;
|
|
35
|
+
s.indexDirty = false;
|
|
36
|
+
|
|
37
|
+
await persistAll(
|
|
38
|
+
entries,
|
|
39
|
+
wasIndexDirty ? siteIndexRef.current : undefined,
|
|
40
|
+
deletedIds.length > 0 ? deletedIds : undefined,
|
|
41
|
+
);
|
|
42
|
+
}, [siteIndexRef]);
|
|
43
|
+
|
|
44
|
+
const scheduleFlush = useCallback(() => {
|
|
45
|
+
if (flushTimerRef.current) clearTimeout(flushTimerRef.current);
|
|
46
|
+
flushTimerRef.current = setTimeout(flushToDexie, 500);
|
|
47
|
+
}, [flushToDexie]);
|
|
48
|
+
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
return () => {
|
|
51
|
+
if (flushTimerRef.current) clearTimeout(flushTimerRef.current);
|
|
52
|
+
};
|
|
53
|
+
}, []);
|
|
54
|
+
|
|
55
|
+
const markSectionDirty = useCallback(
|
|
56
|
+
(sectionId: string, content: SectionContent) => {
|
|
57
|
+
state.current.pendingSections.set(sectionId, content);
|
|
58
|
+
scheduleFlush();
|
|
59
|
+
},
|
|
60
|
+
[scheduleFlush],
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
const markSectionDeleted = useCallback(
|
|
64
|
+
(sectionId: string) => {
|
|
65
|
+
state.current.pendingSections.delete(sectionId);
|
|
66
|
+
state.current.pendingDeletes.add(sectionId);
|
|
67
|
+
state.current.indexDirty = true;
|
|
68
|
+
scheduleFlush();
|
|
69
|
+
},
|
|
70
|
+
[scheduleFlush],
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
const markIndexDirty = useCallback(() => {
|
|
74
|
+
state.current.indexDirty = true;
|
|
75
|
+
scheduleFlush();
|
|
76
|
+
}, [scheduleFlush]);
|
|
77
|
+
|
|
78
|
+
const persistConfig = useCallback(async (config: Record<string, unknown>) => {
|
|
79
|
+
state.current.configDirty = true;
|
|
80
|
+
await persistSiteConfig(config);
|
|
81
|
+
}, []);
|
|
82
|
+
|
|
83
|
+
const cancelPendingFlush = useCallback(() => {
|
|
84
|
+
if (flushTimerRef.current) {
|
|
85
|
+
clearTimeout(flushTimerRef.current);
|
|
86
|
+
flushTimerRef.current = null;
|
|
87
|
+
}
|
|
88
|
+
}, []);
|
|
89
|
+
|
|
90
|
+
const isConfigDirty = useCallback(() => state.current.configDirty, []);
|
|
91
|
+
const clearConfigDirty = useCallback(() => { state.current.configDirty = false; }, []);
|
|
92
|
+
|
|
93
|
+
return {
|
|
94
|
+
markSectionDirty,
|
|
95
|
+
markSectionDeleted,
|
|
96
|
+
markIndexDirty,
|
|
97
|
+
persistConfig,
|
|
98
|
+
flushNow: flushToDexie,
|
|
99
|
+
cancelPendingFlush,
|
|
100
|
+
isConfigDirty,
|
|
101
|
+
clearConfigDirty,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { useState, useCallback, useRef, useEffect } from "react";
|
|
2
|
+
import type { SiteIndex, SiteConfig } from "../schemas/site-config";
|
|
3
|
+
import type { LoadedSection } from "../lib/loader";
|
|
4
|
+
import type { MediaManifest, MediaItem } from "../media/types";
|
|
5
|
+
import { getDirtySections, hasLocalChanges, discardLocalChanges, cacheContent, getPendingMediaLocalUrls, clearPendingMedia } from "../lib/dexie";
|
|
6
|
+
|
|
7
|
+
function blobToBase64(blob: Blob): Promise<string> {
|
|
8
|
+
return new Promise((resolve, reject) => {
|
|
9
|
+
const reader = new FileReader();
|
|
10
|
+
reader.onload = () => {
|
|
11
|
+
const dataUrl = reader.result as string;
|
|
12
|
+
resolve(dataUrl.split(",")[1]);
|
|
13
|
+
};
|
|
14
|
+
reader.onerror = reject;
|
|
15
|
+
reader.readAsDataURL(blob);
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
interface PublishDeps {
|
|
20
|
+
flushNow: () => Promise<void>;
|
|
21
|
+
cancelPendingFlush: () => void;
|
|
22
|
+
isConfigDirty: () => boolean;
|
|
23
|
+
clearConfigDirty: () => void;
|
|
24
|
+
siteIndexRef: React.RefObject<SiteIndex>;
|
|
25
|
+
siteConfig: SiteConfig | null;
|
|
26
|
+
sections: LoadedSection[];
|
|
27
|
+
onSuccess: () => void;
|
|
28
|
+
mediaManifest: MediaManifest;
|
|
29
|
+
pendingMediaItems: MediaItem[];
|
|
30
|
+
pendingMediaDeletions: string[];
|
|
31
|
+
onMediaPublished: (publishedItems: MediaItem[], publishedDeletions: string[]) => void;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function useEditorPublish({
|
|
35
|
+
flushNow,
|
|
36
|
+
cancelPendingFlush,
|
|
37
|
+
isConfigDirty,
|
|
38
|
+
clearConfigDirty,
|
|
39
|
+
siteIndexRef,
|
|
40
|
+
siteConfig,
|
|
41
|
+
sections,
|
|
42
|
+
onSuccess,
|
|
43
|
+
mediaManifest,
|
|
44
|
+
pendingMediaItems,
|
|
45
|
+
pendingMediaDeletions,
|
|
46
|
+
onMediaPublished,
|
|
47
|
+
}: PublishDeps) {
|
|
48
|
+
const [isPublishing, setIsPublishing] = useState(false);
|
|
49
|
+
const [publishFeedback, setPublishFeedback] = useState<string | null>(null);
|
|
50
|
+
const feedbackTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
51
|
+
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
return () => {
|
|
54
|
+
if (feedbackTimerRef.current) clearTimeout(feedbackTimerRef.current);
|
|
55
|
+
};
|
|
56
|
+
}, []);
|
|
57
|
+
|
|
58
|
+
const handlePublish = useCallback(async () => {
|
|
59
|
+
if (!siteConfig) return;
|
|
60
|
+
|
|
61
|
+
setIsPublishing(true);
|
|
62
|
+
setPublishFeedback(null);
|
|
63
|
+
|
|
64
|
+
try {
|
|
65
|
+
cancelPendingFlush();
|
|
66
|
+
await flushNow();
|
|
67
|
+
|
|
68
|
+
const hasChanges = await hasLocalChanges();
|
|
69
|
+
const hasMediaChanges = pendingMediaItems.length > 0 || pendingMediaDeletions.length > 0;
|
|
70
|
+
if (!hasChanges && !isConfigDirty() && !hasMediaChanges) {
|
|
71
|
+
setIsPublishing(false);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const dirty = await getDirtySections();
|
|
76
|
+
|
|
77
|
+
// Gather pending media for the commit
|
|
78
|
+
const mediaUploads: { item: MediaItem; blobs: { path: string; base64: string }[] }[] = [];
|
|
79
|
+
const blobUrlsToRevoke: string[] = [];
|
|
80
|
+
|
|
81
|
+
for (const item of pendingMediaItems) {
|
|
82
|
+
const localUrls = await getPendingMediaLocalUrls(item.id);
|
|
83
|
+
if (!localUrls) continue;
|
|
84
|
+
|
|
85
|
+
for (const url of Object.values(localUrls)) {
|
|
86
|
+
blobUrlsToRevoke.push(url);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const blobs: { path: string; base64: string }[] = [];
|
|
90
|
+
const failedBlobFetches: string[] = [];
|
|
91
|
+
const mimeExt: Record<string, string> = {
|
|
92
|
+
"image/gif": "gif", "image/apng": "apng", "video/mp4": "mp4", "video/webm": "webm",
|
|
93
|
+
};
|
|
94
|
+
for (const [key, url] of Object.entries(localUrls)) {
|
|
95
|
+
if (key === "primary" && item.kind === "image") continue;
|
|
96
|
+
try {
|
|
97
|
+
const resp = await fetch(url);
|
|
98
|
+
const blob = await resp.blob();
|
|
99
|
+
const base64 = await blobToBase64(blob);
|
|
100
|
+
if (key === "primary") {
|
|
101
|
+
const ext = mimeExt[item.mimeType] ?? "bin";
|
|
102
|
+
blobs.push({ path: `assets/images/${item.folder}/original.${ext}`, base64 });
|
|
103
|
+
} else {
|
|
104
|
+
blobs.push({ path: `assets/images/${item.folder}/${key}.webp`, base64 });
|
|
105
|
+
}
|
|
106
|
+
} catch {
|
|
107
|
+
failedBlobFetches.push(`${item.id}/${key}`);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (failedBlobFetches.length > 0) {
|
|
112
|
+
throw new Error(`Media upload failed: could not read blob data for ${failedBlobFetches.join(", ")}`);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (blobs.length > 0) {
|
|
116
|
+
mediaUploads.push({ item, blobs });
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// Build updated manifest
|
|
121
|
+
let updatedManifest: MediaManifest | undefined;
|
|
122
|
+
if (hasMediaChanges) {
|
|
123
|
+
const images = { ...mediaManifest.images };
|
|
124
|
+
for (const upload of mediaUploads) {
|
|
125
|
+
images[upload.item.id] = upload.item;
|
|
126
|
+
}
|
|
127
|
+
for (const id of pendingMediaDeletions) {
|
|
128
|
+
delete images[id];
|
|
129
|
+
}
|
|
130
|
+
updatedManifest = { images };
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const response = await fetch("/api/save", {
|
|
134
|
+
method: "POST",
|
|
135
|
+
headers: { "Content-Type": "application/json" },
|
|
136
|
+
body: JSON.stringify({
|
|
137
|
+
sections: dirty.map(({ sectionId, content }) => ({
|
|
138
|
+
id: sectionId,
|
|
139
|
+
content,
|
|
140
|
+
})),
|
|
141
|
+
siteIndex: siteIndexRef.current,
|
|
142
|
+
...(isConfigDirty() ? { siteConfig } : {}),
|
|
143
|
+
...(hasMediaChanges ? {
|
|
144
|
+
media: {
|
|
145
|
+
uploads: mediaUploads.map(({ item, blobs }) => ({ item, blobs })),
|
|
146
|
+
deletions: pendingMediaDeletions.map((id) => ({
|
|
147
|
+
id,
|
|
148
|
+
folder: mediaManifest.images[id]?.folder,
|
|
149
|
+
})).filter((d) => d.folder),
|
|
150
|
+
manifest: updatedManifest,
|
|
151
|
+
},
|
|
152
|
+
} : {}),
|
|
153
|
+
}),
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
if (!response.ok) {
|
|
157
|
+
const errorBody = await response.json().catch(() => ({}));
|
|
158
|
+
throw new Error(errorBody.error || "Publish failed");
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const { sha } = await response.json();
|
|
162
|
+
|
|
163
|
+
await discardLocalChanges();
|
|
164
|
+
await clearPendingMedia();
|
|
165
|
+
await cacheContent(sha, sections, siteIndexRef.current, siteConfig);
|
|
166
|
+
clearConfigDirty();
|
|
167
|
+
onSuccess();
|
|
168
|
+
onMediaPublished(pendingMediaItems, pendingMediaDeletions);
|
|
169
|
+
for (const url of blobUrlsToRevoke) {
|
|
170
|
+
URL.revokeObjectURL(url);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
setPublishFeedback("Published");
|
|
174
|
+
if (feedbackTimerRef.current) clearTimeout(feedbackTimerRef.current);
|
|
175
|
+
feedbackTimerRef.current = setTimeout(() => setPublishFeedback(null), 3000);
|
|
176
|
+
} catch (error) {
|
|
177
|
+
console.error("Publish failed:", error);
|
|
178
|
+
setPublishFeedback("Publish failed");
|
|
179
|
+
if (feedbackTimerRef.current) clearTimeout(feedbackTimerRef.current);
|
|
180
|
+
feedbackTimerRef.current = setTimeout(() => setPublishFeedback(null), 5000);
|
|
181
|
+
} finally {
|
|
182
|
+
setIsPublishing(false);
|
|
183
|
+
}
|
|
184
|
+
}, [flushNow, cancelPendingFlush, isConfigDirty, clearConfigDirty, siteIndexRef, siteConfig, sections, onSuccess, mediaManifest, pendingMediaItems, pendingMediaDeletions, onMediaPublished]);
|
|
185
|
+
|
|
186
|
+
return { isPublishing, publishFeedback, handlePublish };
|
|
187
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { useEffect, type RefObject } from "react";
|
|
2
|
+
|
|
3
|
+
const FOCUSABLE_SELECTOR = [
|
|
4
|
+
"a[href]",
|
|
5
|
+
"button:not([disabled])",
|
|
6
|
+
"input:not([disabled])",
|
|
7
|
+
"select:not([disabled])",
|
|
8
|
+
"textarea:not([disabled])",
|
|
9
|
+
'[tabindex]:not([tabindex="-1"])',
|
|
10
|
+
].join(", ");
|
|
11
|
+
|
|
12
|
+
export function useFocusTrap(ref: RefObject<HTMLElement | null>, active: boolean) {
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
if (!active || !ref.current) return;
|
|
15
|
+
|
|
16
|
+
const container = ref.current;
|
|
17
|
+
const previouslyFocused = document.activeElement as HTMLElement | null;
|
|
18
|
+
const getFocusable = () =>
|
|
19
|
+
Array.from(container.querySelectorAll<HTMLElement>(FOCUSABLE_SELECTOR));
|
|
20
|
+
|
|
21
|
+
// Focus first element on activation
|
|
22
|
+
const focusable = getFocusable();
|
|
23
|
+
if (focusable.length > 0) {
|
|
24
|
+
focusable[0].focus();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const handleKeyDown = (e: KeyboardEvent) => {
|
|
28
|
+
if (e.key !== "Tab") return;
|
|
29
|
+
|
|
30
|
+
const elements = getFocusable();
|
|
31
|
+
if (elements.length === 0) return;
|
|
32
|
+
|
|
33
|
+
const first = elements[0];
|
|
34
|
+
const last = elements[elements.length - 1];
|
|
35
|
+
|
|
36
|
+
if (e.shiftKey) {
|
|
37
|
+
if (document.activeElement === first) {
|
|
38
|
+
e.preventDefault();
|
|
39
|
+
last.focus();
|
|
40
|
+
}
|
|
41
|
+
} else {
|
|
42
|
+
if (document.activeElement === last) {
|
|
43
|
+
e.preventDefault();
|
|
44
|
+
first.focus();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
container.addEventListener("keydown", handleKeyDown);
|
|
50
|
+
return () => {
|
|
51
|
+
container.removeEventListener("keydown", handleKeyDown);
|
|
52
|
+
if (previouslyFocused && document.body.contains(previouslyFocused)) {
|
|
53
|
+
previouslyFocused.focus();
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
}, [active, ref]);
|
|
57
|
+
}
|