@jhits/plugin-blog 0.0.8 → 0.0.9
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/dist/api/categories.d.ts +8 -0
- package/dist/api/categories.d.ts.map +1 -0
- package/dist/api/categories.js +30 -0
- package/dist/api/check-title.d.ts +8 -0
- package/dist/api/check-title.d.ts.map +1 -0
- package/dist/api/check-title.js +47 -0
- package/dist/api/config-handler.d.ts +21 -0
- package/dist/api/config-handler.d.ts.map +1 -0
- package/dist/api/config-handler.js +46 -0
- package/dist/api/handler.d.ts +42 -0
- package/dist/api/handler.d.ts.map +1 -0
- package/dist/api/handler.js +331 -0
- package/dist/api/index.d.ts +12 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/index.js +12 -0
- package/dist/api/route.d.ts +50 -0
- package/dist/api/route.d.ts.map +1 -0
- package/dist/api/route.js +69 -0
- package/dist/api/router.d.ts +27 -0
- package/dist/api/router.d.ts.map +1 -0
- package/dist/api/router.js +98 -0
- package/dist/api-server.d.ts +9 -0
- package/dist/api-server.d.ts.map +1 -0
- package/dist/api-server.js +9 -0
- package/dist/config.d.ts +14 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +156 -0
- package/dist/hooks/index.d.ts +8 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +7 -0
- package/dist/hooks/useBlog.d.ts +31 -0
- package/dist/hooks/useBlog.d.ts.map +1 -0
- package/dist/hooks/useBlog.js +57 -0
- package/dist/hooks/useBlogs.d.ts +39 -0
- package/dist/hooks/useBlogs.d.ts.map +1 -0
- package/dist/hooks/useBlogs.js +82 -0
- package/dist/hooks/useCategories.d.ts +9 -0
- package/dist/hooks/useCategories.d.ts.map +1 -0
- package/dist/hooks/useCategories.js +70 -0
- package/dist/index.d.ts +55 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +228 -0
- package/dist/index.server.d.ts +12 -0
- package/dist/index.server.d.ts.map +1 -0
- package/dist/index.server.js +10 -0
- package/dist/init.d.ts +40 -0
- package/dist/init.d.ts.map +1 -0
- package/dist/init.js +41 -0
- package/dist/lib/blocks/BlockRenderer.d.ts +54 -0
- package/dist/lib/blocks/BlockRenderer.d.ts.map +1 -0
- package/dist/lib/blocks/BlockRenderer.js +54 -0
- package/dist/lib/blocks/index.d.ts +5 -0
- package/dist/lib/blocks/index.d.ts.map +1 -0
- package/dist/lib/blocks/index.js +4 -0
- package/dist/lib/config-storage.d.ts +30 -0
- package/dist/lib/config-storage.d.ts.map +1 -0
- package/dist/lib/config-storage.js +31 -0
- package/dist/lib/index.d.ts +8 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/index.js +7 -0
- package/dist/lib/layouts/blocks/ColumnsBlock.d.ts +25 -0
- package/dist/lib/layouts/blocks/ColumnsBlock.d.ts.map +1 -0
- package/dist/lib/layouts/blocks/ColumnsBlock.js +186 -0
- package/dist/lib/layouts/blocks/SectionBlock.d.ts +25 -0
- package/dist/lib/layouts/blocks/SectionBlock.d.ts.map +1 -0
- package/dist/lib/layouts/blocks/SectionBlock.js +44 -0
- package/dist/lib/layouts/blocks/index.d.ts +7 -0
- package/dist/lib/layouts/blocks/index.d.ts.map +1 -0
- package/dist/lib/layouts/blocks/index.js +6 -0
- package/dist/lib/layouts/index.d.ts +23 -0
- package/dist/lib/layouts/index.d.ts.map +1 -0
- package/dist/lib/layouts/index.js +45 -0
- package/dist/lib/layouts/registerLayoutBlocks.d.ts +9 -0
- package/dist/lib/layouts/registerLayoutBlocks.d.ts.map +1 -0
- package/dist/lib/layouts/registerLayoutBlocks.js +60 -0
- package/dist/lib/mappers/apiMapper.d.ts +66 -0
- package/dist/lib/mappers/apiMapper.d.ts.map +1 -0
- package/dist/lib/mappers/apiMapper.js +188 -0
- package/dist/lib/migration/index.d.ts +5 -0
- package/dist/lib/migration/index.d.ts.map +1 -0
- package/dist/lib/migration/index.js +4 -0
- package/dist/lib/migration/mapper.d.ts +37 -0
- package/dist/lib/migration/mapper.d.ts.map +1 -0
- package/dist/lib/migration/mapper.js +98 -0
- package/dist/lib/rich-text/RichTextEditor.d.ts +45 -0
- package/dist/lib/rich-text/RichTextEditor.d.ts.map +1 -0
- package/dist/lib/rich-text/RichTextEditor.js +556 -0
- package/dist/lib/rich-text/RichTextPreview.d.ts +16 -0
- package/dist/lib/rich-text/RichTextPreview.d.ts.map +1 -0
- package/dist/lib/rich-text/RichTextPreview.js +144 -0
- package/dist/lib/rich-text/index.d.ts +9 -0
- package/dist/lib/rich-text/index.d.ts.map +1 -0
- package/dist/lib/rich-text/index.js +6 -0
- package/dist/lib/utils/blockHelpers.d.ts +23 -0
- package/dist/lib/utils/blockHelpers.d.ts.map +1 -0
- package/dist/lib/utils/blockHelpers.js +65 -0
- package/dist/lib/utils/configValidation.d.ts +23 -0
- package/dist/lib/utils/configValidation.d.ts.map +1 -0
- package/dist/lib/utils/configValidation.js +111 -0
- package/dist/lib/utils/index.d.ts +7 -0
- package/dist/lib/utils/index.d.ts.map +1 -0
- package/dist/lib/utils/index.js +6 -0
- package/dist/lib/utils/slugify.d.ts +25 -0
- package/dist/lib/utils/slugify.d.ts.map +1 -0
- package/dist/lib/utils/slugify.js +65 -0
- package/dist/registry/BlockRegistry.d.ts +62 -0
- package/dist/registry/BlockRegistry.d.ts.map +1 -0
- package/dist/registry/BlockRegistry.js +112 -0
- package/dist/registry/index.d.ts +6 -0
- package/dist/registry/index.d.ts.map +1 -0
- package/dist/registry/index.js +4 -0
- package/dist/state/EditorContext.d.ts +45 -0
- package/dist/state/EditorContext.d.ts.map +1 -0
- package/dist/state/EditorContext.js +215 -0
- package/dist/state/index.d.ts +7 -0
- package/dist/state/index.d.ts.map +1 -0
- package/dist/state/index.js +6 -0
- package/dist/state/reducer.d.ts +11 -0
- package/dist/state/reducer.d.ts.map +1 -0
- package/dist/state/reducer.js +599 -0
- package/dist/state/types.d.ts +162 -0
- package/dist/state/types.d.ts.map +1 -0
- package/dist/state/types.js +27 -0
- package/dist/types/block.d.ts +221 -0
- package/dist/types/block.d.ts.map +1 -0
- package/dist/types/block.js +6 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +5 -0
- package/dist/types/post.d.ts +136 -0
- package/dist/types/post.d.ts.map +1 -0
- package/dist/types/post.js +5 -0
- package/dist/utils/client.d.ts +48 -0
- package/dist/utils/client.d.ts.map +1 -0
- package/dist/utils/client.js +77 -0
- package/dist/utils/index.d.ts +6 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +5 -0
- package/dist/views/CanvasEditor/BlockWrapper.d.ts +16 -0
- package/dist/views/CanvasEditor/BlockWrapper.d.ts.map +1 -0
- package/dist/views/CanvasEditor/BlockWrapper.js +285 -0
- package/dist/views/CanvasEditor/CanvasEditorView.d.ts +14 -0
- package/dist/views/CanvasEditor/CanvasEditorView.d.ts.map +1 -0
- package/dist/views/CanvasEditor/CanvasEditorView.js +215 -0
- package/dist/views/CanvasEditor/EditorBody.d.ts +22 -0
- package/dist/views/CanvasEditor/EditorBody.d.ts.map +1 -0
- package/dist/views/CanvasEditor/EditorBody.js +505 -0
- package/dist/views/CanvasEditor/EditorHeader.d.ts +18 -0
- package/dist/views/CanvasEditor/EditorHeader.d.ts.map +1 -0
- package/dist/views/CanvasEditor/EditorHeader.js +101 -0
- package/dist/views/CanvasEditor/LayoutContainer.d.ts +17 -0
- package/dist/views/CanvasEditor/LayoutContainer.d.ts.map +1 -0
- package/dist/views/CanvasEditor/LayoutContainer.js +222 -0
- package/dist/views/CanvasEditor/SaveConfirmationModal.d.ts +13 -0
- package/dist/views/CanvasEditor/SaveConfirmationModal.d.ts.map +1 -0
- package/dist/views/CanvasEditor/SaveConfirmationModal.js +78 -0
- package/dist/views/CanvasEditor/components/CustomBlockItem.d.ts +14 -0
- package/dist/views/CanvasEditor/components/CustomBlockItem.d.ts.map +1 -0
- package/dist/views/CanvasEditor/components/CustomBlockItem.js +44 -0
- package/dist/views/CanvasEditor/components/EditorCanvas.d.ts +29 -0
- package/dist/views/CanvasEditor/components/EditorCanvas.d.ts.map +1 -0
- package/dist/views/CanvasEditor/components/EditorCanvas.js +32 -0
- package/dist/views/CanvasEditor/components/EditorLibrary.d.ts +7 -0
- package/dist/views/CanvasEditor/components/EditorLibrary.d.ts.map +1 -0
- package/dist/views/CanvasEditor/components/EditorLibrary.js +25 -0
- package/dist/views/CanvasEditor/components/EditorSidebar.d.ts +13 -0
- package/dist/views/CanvasEditor/components/EditorSidebar.d.ts.map +1 -0
- package/dist/views/CanvasEditor/components/EditorSidebar.js +19 -0
- package/dist/views/CanvasEditor/components/ErrorBanner.d.ts +6 -0
- package/dist/views/CanvasEditor/components/ErrorBanner.d.ts.map +1 -0
- package/dist/views/CanvasEditor/components/ErrorBanner.js +8 -0
- package/dist/views/CanvasEditor/components/FeaturedMediaSection.d.ts +25 -0
- package/dist/views/CanvasEditor/components/FeaturedMediaSection.d.ts.map +1 -0
- package/dist/views/CanvasEditor/components/FeaturedMediaSection.js +199 -0
- package/dist/views/CanvasEditor/components/LibraryItem.d.ts +14 -0
- package/dist/views/CanvasEditor/components/LibraryItem.d.ts.map +1 -0
- package/dist/views/CanvasEditor/components/LibraryItem.js +43 -0
- package/dist/views/CanvasEditor/components/PrivacySettingsSection.d.ts +15 -0
- package/dist/views/CanvasEditor/components/PrivacySettingsSection.d.ts.map +1 -0
- package/dist/views/CanvasEditor/components/PrivacySettingsSection.js +70 -0
- package/dist/views/CanvasEditor/components/index.d.ts +21 -0
- package/dist/views/CanvasEditor/components/index.d.ts.map +1 -0
- package/dist/views/CanvasEditor/components/index.js +12 -0
- package/dist/views/CanvasEditor/hooks/index.d.ts +10 -0
- package/dist/views/CanvasEditor/hooks/index.d.ts.map +1 -0
- package/dist/views/CanvasEditor/hooks/index.js +9 -0
- package/dist/views/CanvasEditor/hooks/useHeroBlock.d.ts +8 -0
- package/dist/views/CanvasEditor/hooks/useHeroBlock.d.ts.map +1 -0
- package/dist/views/CanvasEditor/hooks/useHeroBlock.js +90 -0
- package/dist/views/CanvasEditor/hooks/useKeyboardShortcuts.d.ts +3 -0
- package/dist/views/CanvasEditor/hooks/useKeyboardShortcuts.d.ts.map +1 -0
- package/dist/views/CanvasEditor/hooks/useKeyboardShortcuts.js +119 -0
- package/dist/views/CanvasEditor/hooks/usePostLoader.d.ts +5 -0
- package/dist/views/CanvasEditor/hooks/usePostLoader.d.ts.map +1 -0
- package/dist/views/CanvasEditor/hooks/usePostLoader.js +32 -0
- package/dist/views/CanvasEditor/hooks/useRegisteredBlocks.d.ts +2 -0
- package/dist/views/CanvasEditor/hooks/useRegisteredBlocks.d.ts.map +1 -0
- package/dist/views/CanvasEditor/hooks/useRegisteredBlocks.js +47 -0
- package/dist/views/CanvasEditor/hooks/useUnsavedChanges.d.ts +25 -0
- package/dist/views/CanvasEditor/hooks/useUnsavedChanges.d.ts.map +1 -0
- package/dist/views/CanvasEditor/hooks/useUnsavedChanges.js +285 -0
- package/dist/views/CanvasEditor/index.d.ts +16 -0
- package/dist/views/CanvasEditor/index.d.ts.map +1 -0
- package/dist/views/CanvasEditor/index.js +9 -0
- package/dist/views/PostManager/EmptyState.d.ts +10 -0
- package/dist/views/PostManager/EmptyState.d.ts.map +1 -0
- package/dist/views/PostManager/EmptyState.js +12 -0
- package/dist/views/PostManager/PostActionsMenu.d.ts +12 -0
- package/dist/views/PostManager/PostActionsMenu.d.ts.map +1 -0
- package/dist/views/PostManager/PostActionsMenu.js +58 -0
- package/dist/views/PostManager/PostCards.d.ts +15 -0
- package/dist/views/PostManager/PostCards.d.ts.map +1 -0
- package/dist/views/PostManager/PostCards.js +77 -0
- package/dist/views/PostManager/PostFilters.d.ts +16 -0
- package/dist/views/PostManager/PostFilters.d.ts.map +1 -0
- package/dist/views/PostManager/PostFilters.js +10 -0
- package/dist/views/PostManager/PostManagerView.d.ts +11 -0
- package/dist/views/PostManager/PostManagerView.d.ts.map +1 -0
- package/dist/views/PostManager/PostManagerView.js +179 -0
- package/dist/views/PostManager/PostStats.d.ts +11 -0
- package/dist/views/PostManager/PostStats.d.ts.map +1 -0
- package/dist/views/PostManager/PostStats.js +46 -0
- package/dist/views/PostManager/PostTable.d.ts +15 -0
- package/dist/views/PostManager/PostTable.d.ts.map +1 -0
- package/dist/views/PostManager/PostTable.js +77 -0
- package/dist/views/PostManager/index.d.ts +12 -0
- package/dist/views/PostManager/index.d.ts.map +1 -0
- package/dist/views/PostManager/index.js +11 -0
- package/dist/views/Preview/PreviewBridgeView.d.ts +12 -0
- package/dist/views/Preview/PreviewBridgeView.d.ts.map +1 -0
- package/dist/views/Preview/PreviewBridgeView.js +11 -0
- package/dist/views/Preview/index.d.ts +6 -0
- package/dist/views/Preview/index.d.ts.map +1 -0
- package/dist/views/Preview/index.js +4 -0
- package/dist/views/Settings/SettingsView.d.ts +10 -0
- package/dist/views/Settings/SettingsView.d.ts.map +1 -0
- package/dist/views/Settings/SettingsView.js +113 -0
- package/dist/views/Settings/index.d.ts +6 -0
- package/dist/views/Settings/index.d.ts.map +1 -0
- package/dist/views/Settings/index.js +4 -0
- package/dist/views/SlugSEO/SlugSEOManagerView.d.ts +12 -0
- package/dist/views/SlugSEO/SlugSEOManagerView.d.ts.map +1 -0
- package/dist/views/SlugSEO/SlugSEOManagerView.js +11 -0
- package/dist/views/SlugSEO/index.d.ts +6 -0
- package/dist/views/SlugSEO/index.d.ts.map +1 -0
- package/dist/views/SlugSEO/index.js +4 -0
- package/package.json +59 -59
- package/src/hooks/index.d.ts +8 -0
- package/src/hooks/index.d.ts.map +1 -0
- package/src/hooks/index.js +7 -0
- package/src/hooks/useBlog.d.ts +31 -0
- package/src/hooks/useBlog.d.ts.map +1 -0
- package/src/hooks/useBlog.js +57 -0
- package/src/hooks/useBlogs.d.ts +39 -0
- package/src/hooks/useBlogs.d.ts.map +1 -0
- package/src/hooks/useBlogs.js +82 -0
- package/src/hooks/useCategories.d.ts +9 -0
- package/src/hooks/useCategories.d.ts.map +1 -0
- package/src/hooks/useCategories.js +70 -0
- package/src/index.d.ts +55 -0
- package/src/index.d.ts.map +1 -0
- package/src/index.js +228 -0
- package/src/init.d.ts +40 -0
- package/src/init.d.ts.map +1 -0
- package/src/init.js +41 -0
- package/src/lib/blocks/BlockRenderer.d.ts +54 -0
- package/src/lib/blocks/BlockRenderer.d.ts.map +1 -0
- package/src/lib/blocks/BlockRenderer.js +54 -0
- package/src/lib/config-storage.d.ts +30 -0
- package/src/lib/config-storage.d.ts.map +1 -0
- package/src/lib/config-storage.js +31 -0
- package/src/lib/layouts/blocks/ColumnsBlock.d.ts +25 -0
- package/src/lib/layouts/blocks/ColumnsBlock.d.ts.map +1 -0
- package/src/lib/layouts/blocks/ColumnsBlock.js +182 -0
- package/src/lib/layouts/blocks/SectionBlock.d.ts +25 -0
- package/src/lib/layouts/blocks/SectionBlock.d.ts.map +1 -0
- package/src/lib/layouts/blocks/SectionBlock.js +44 -0
- package/src/lib/layouts/index.d.ts +23 -0
- package/src/lib/layouts/index.d.ts.map +1 -0
- package/src/lib/layouts/index.js +45 -0
- package/src/lib/layouts/registerLayoutBlocks.d.ts +9 -0
- package/src/lib/layouts/registerLayoutBlocks.d.ts.map +1 -0
- package/src/lib/layouts/registerLayoutBlocks.js +60 -0
- package/src/lib/mappers/apiMapper.d.ts +66 -0
- package/src/lib/mappers/apiMapper.d.ts.map +1 -0
- package/src/lib/mappers/apiMapper.js +191 -0
- package/src/lib/rich-text/RichTextEditor.d.ts +45 -0
- package/src/lib/rich-text/RichTextEditor.d.ts.map +1 -0
- package/src/lib/rich-text/RichTextEditor.js +564 -0
- package/src/lib/rich-text/RichTextPreview.d.ts +16 -0
- package/src/lib/rich-text/RichTextPreview.d.ts.map +1 -0
- package/src/lib/rich-text/RichTextPreview.js +144 -0
- package/src/lib/rich-text/index.d.ts +9 -0
- package/src/lib/rich-text/index.d.ts.map +1 -0
- package/src/lib/rich-text/index.js +6 -0
- package/src/lib/utils/blockHelpers.d.ts +23 -0
- package/src/lib/utils/blockHelpers.d.ts.map +1 -0
- package/src/lib/utils/blockHelpers.js +65 -0
- package/src/lib/utils/configValidation.d.ts +23 -0
- package/src/lib/utils/configValidation.d.ts.map +1 -0
- package/src/lib/utils/configValidation.js +113 -0
- package/src/registry/BlockRegistry.d.ts +62 -0
- package/src/registry/BlockRegistry.d.ts.map +1 -0
- package/src/registry/BlockRegistry.js +112 -0
- package/src/registry/index.d.ts +6 -0
- package/src/registry/index.d.ts.map +1 -0
- package/src/registry/index.js +4 -0
- package/src/state/EditorContext.d.ts +45 -0
- package/src/state/EditorContext.d.ts.map +1 -0
- package/src/state/EditorContext.js +215 -0
- package/src/state/index.d.ts +7 -0
- package/src/state/index.d.ts.map +1 -0
- package/src/state/index.js +6 -0
- package/src/state/reducer.d.ts +11 -0
- package/src/state/reducer.d.ts.map +1 -0
- package/src/state/reducer.js +443 -0
- package/src/state/types.d.ts +162 -0
- package/src/state/types.d.ts.map +1 -0
- package/src/state/types.js +27 -0
- package/src/types/block.d.ts +221 -0
- package/src/types/block.d.ts.map +1 -0
- package/src/types/block.js +6 -0
- package/src/types/index.d.ts +8 -0
- package/src/types/index.d.ts.map +1 -0
- package/src/types/index.js +5 -0
- package/src/types/post.d.ts +136 -0
- package/src/types/post.d.ts.map +1 -0
- package/src/types/post.js +5 -0
- package/src/utils/client.d.ts +48 -0
- package/src/utils/client.d.ts.map +1 -0
- package/src/utils/client.js +77 -0
- package/src/views/CanvasEditor/BlockWrapper.d.ts +16 -0
- package/src/views/CanvasEditor/BlockWrapper.d.ts.map +1 -0
- package/src/views/CanvasEditor/BlockWrapper.js +276 -0
- package/src/views/CanvasEditor/CanvasEditorView.d.ts +14 -0
- package/src/views/CanvasEditor/CanvasEditorView.d.ts.map +1 -0
- package/src/views/CanvasEditor/CanvasEditorView.js +209 -0
- package/src/views/CanvasEditor/EditorBody.d.ts +22 -0
- package/src/views/CanvasEditor/EditorBody.d.ts.map +1 -0
- package/src/views/CanvasEditor/EditorBody.js +505 -0
- package/src/views/CanvasEditor/EditorHeader.d.ts +18 -0
- package/src/views/CanvasEditor/EditorHeader.d.ts.map +1 -0
- package/src/views/CanvasEditor/EditorHeader.js +101 -0
- package/src/views/CanvasEditor/LayoutContainer.d.ts +17 -0
- package/src/views/CanvasEditor/LayoutContainer.d.ts.map +1 -0
- package/src/views/CanvasEditor/LayoutContainer.js +222 -0
- package/src/views/CanvasEditor/SaveConfirmationModal.d.ts +13 -0
- package/src/views/CanvasEditor/SaveConfirmationModal.d.ts.map +1 -0
- package/src/views/CanvasEditor/SaveConfirmationModal.js +78 -0
- package/src/views/CanvasEditor/components/CustomBlockItem.d.ts +14 -0
- package/src/views/CanvasEditor/components/CustomBlockItem.d.ts.map +1 -0
- package/src/views/CanvasEditor/components/CustomBlockItem.js +44 -0
- package/src/views/CanvasEditor/components/EditorCanvas.d.ts +29 -0
- package/src/views/CanvasEditor/components/EditorCanvas.d.ts.map +1 -0
- package/src/views/CanvasEditor/components/EditorCanvas.js +32 -0
- package/src/views/CanvasEditor/components/EditorLibrary.d.ts +7 -0
- package/src/views/CanvasEditor/components/EditorLibrary.d.ts.map +1 -0
- package/src/views/CanvasEditor/components/EditorLibrary.js +25 -0
- package/src/views/CanvasEditor/components/EditorSidebar.d.ts +13 -0
- package/src/views/CanvasEditor/components/EditorSidebar.d.ts.map +1 -0
- package/src/views/CanvasEditor/components/EditorSidebar.js +20 -0
- package/src/views/CanvasEditor/components/ErrorBanner.d.ts +6 -0
- package/src/views/CanvasEditor/components/ErrorBanner.d.ts.map +1 -0
- package/src/views/CanvasEditor/components/ErrorBanner.js +8 -0
- package/src/views/CanvasEditor/components/FeaturedMediaSection.d.ts +25 -0
- package/src/views/CanvasEditor/components/FeaturedMediaSection.d.ts.map +1 -0
- package/src/views/CanvasEditor/components/FeaturedMediaSection.js +182 -0
- package/src/views/CanvasEditor/components/LibraryItem.d.ts +14 -0
- package/src/views/CanvasEditor/components/LibraryItem.d.ts.map +1 -0
- package/src/views/CanvasEditor/components/LibraryItem.js +43 -0
- package/src/views/CanvasEditor/components/PrivacySettingsSection.d.ts +15 -0
- package/src/views/CanvasEditor/components/PrivacySettingsSection.d.ts.map +1 -0
- package/src/views/CanvasEditor/components/PrivacySettingsSection.js +63 -0
- package/src/views/CanvasEditor/components/index.d.ts +21 -0
- package/src/views/CanvasEditor/components/index.d.ts.map +1 -0
- package/src/views/CanvasEditor/components/index.js +12 -0
- package/src/views/CanvasEditor/hooks/index.d.ts +10 -0
- package/src/views/CanvasEditor/hooks/index.d.ts.map +1 -0
- package/src/views/CanvasEditor/hooks/index.js +9 -0
- package/src/views/CanvasEditor/hooks/useHeroBlock.d.ts +8 -0
- package/src/views/CanvasEditor/hooks/useHeroBlock.d.ts.map +1 -0
- package/src/views/CanvasEditor/hooks/useHeroBlock.js +79 -0
- package/src/views/CanvasEditor/hooks/useKeyboardShortcuts.d.ts +3 -0
- package/src/views/CanvasEditor/hooks/useKeyboardShortcuts.d.ts.map +1 -0
- package/src/views/CanvasEditor/hooks/useKeyboardShortcuts.js +114 -0
- package/src/views/CanvasEditor/hooks/usePostLoader.d.ts +5 -0
- package/src/views/CanvasEditor/hooks/usePostLoader.d.ts.map +1 -0
- package/src/views/CanvasEditor/hooks/usePostLoader.js +32 -0
- package/src/views/CanvasEditor/hooks/useRegisteredBlocks.d.ts +2 -0
- package/src/views/CanvasEditor/hooks/useRegisteredBlocks.d.ts.map +1 -0
- package/src/views/CanvasEditor/hooks/useRegisteredBlocks.js +47 -0
- package/src/views/CanvasEditor/hooks/useUnsavedChanges.d.ts +25 -0
- package/src/views/CanvasEditor/hooks/useUnsavedChanges.d.ts.map +1 -0
- package/src/views/CanvasEditor/hooks/useUnsavedChanges.js +285 -0
- package/src/views/CanvasEditor/index.d.ts +16 -0
- package/src/views/CanvasEditor/index.d.ts.map +1 -0
- package/src/views/CanvasEditor/index.js +9 -0
- package/src/views/PostManager/EmptyState.d.ts +10 -0
- package/src/views/PostManager/EmptyState.d.ts.map +1 -0
- package/src/views/PostManager/EmptyState.js +12 -0
- package/src/views/PostManager/PostActionsMenu.d.ts +12 -0
- package/src/views/PostManager/PostActionsMenu.d.ts.map +1 -0
- package/src/views/PostManager/PostActionsMenu.js +58 -0
- package/src/views/PostManager/PostCards.d.ts +15 -0
- package/src/views/PostManager/PostCards.d.ts.map +1 -0
- package/src/views/PostManager/PostCards.js +79 -0
- package/src/views/PostManager/PostFilters.d.ts +16 -0
- package/src/views/PostManager/PostFilters.d.ts.map +1 -0
- package/src/views/PostManager/PostFilters.js +10 -0
- package/src/views/PostManager/PostManagerView.d.ts +11 -0
- package/src/views/PostManager/PostManagerView.d.ts.map +1 -0
- package/src/views/PostManager/PostManagerView.js +174 -0
- package/src/views/PostManager/PostStats.d.ts +11 -0
- package/src/views/PostManager/PostStats.d.ts.map +1 -0
- package/src/views/PostManager/PostStats.js +46 -0
- package/src/views/PostManager/PostTable.d.ts +15 -0
- package/src/views/PostManager/PostTable.d.ts.map +1 -0
- package/src/views/PostManager/PostTable.js +79 -0
- package/src/views/PostManager/index.d.ts +12 -0
- package/src/views/PostManager/index.d.ts.map +1 -0
- package/src/views/PostManager/index.js +11 -0
- package/src/views/Preview/PreviewBridgeView.d.ts +12 -0
- package/src/views/Preview/PreviewBridgeView.d.ts.map +1 -0
- package/src/views/Preview/PreviewBridgeView.js +11 -0
- package/src/views/Preview/index.d.ts +6 -0
- package/src/views/Preview/index.d.ts.map +1 -0
- package/src/views/Preview/index.js +4 -0
- package/src/views/Settings/SettingsView.d.ts +10 -0
- package/src/views/Settings/SettingsView.d.ts.map +1 -0
- package/src/views/Settings/SettingsView.js +111 -0
- package/src/views/Settings/index.d.ts +6 -0
- package/src/views/Settings/index.d.ts.map +1 -0
- package/src/views/Settings/index.js +4 -0
- package/src/views/SlugSEO/SlugSEOManagerView.d.ts +12 -0
- package/src/views/SlugSEO/SlugSEOManagerView.d.ts.map +1 -0
- package/src/views/SlugSEO/SlugSEOManagerView.js +11 -0
- package/src/views/SlugSEO/index.d.ts +6 -0
- package/src/views/SlugSEO/index.d.ts.map +1 -0
- package/src/views/SlugSEO/index.js +4 -0
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useState, useCallback, useEffect } from 'react';
|
|
4
|
+
import { createPortal } from 'react-dom';
|
|
5
|
+
import { Image as ImageIcon, Plus, X } from 'lucide-react';
|
|
6
|
+
import { ImagePicker, Image } from '@jhits/plugin-images';
|
|
7
|
+
/**
|
|
8
|
+
* Featured Media Section Component
|
|
9
|
+
* Handles featured image selection - completely independent from hero image
|
|
10
|
+
* Featured image is a thumbnail used for blog post cards
|
|
11
|
+
* Hero image is separate and managed in the hero block
|
|
12
|
+
*/
|
|
13
|
+
export function FeaturedMediaSection({ featuredImage, heroBlock, slug, onUpdate, }) {
|
|
14
|
+
var _a, _b, _c, _d, _e;
|
|
15
|
+
const [showImagePicker, setShowImagePicker] = useState(false);
|
|
16
|
+
const [openEditorDirectly, setOpenEditorDirectly] = useState(false);
|
|
17
|
+
const [mounted, setMounted] = useState(false);
|
|
18
|
+
// Handle SSR - ensure we only render portal on client
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
setMounted(true);
|
|
21
|
+
}, []);
|
|
22
|
+
// Create semantic ID for this featured image - plugin-images will handle everything
|
|
23
|
+
const semanticId = slug ? `blog-featured-${slug}` : `blog-featured-${Date.now()}`;
|
|
24
|
+
// Use semantic ID from featuredImage if it exists, otherwise use generated one
|
|
25
|
+
// IMPORTANT: Always use the actual id from featuredImage if available, otherwise the semanticId
|
|
26
|
+
// This ensures the id is stable and doesn't change on re-renders
|
|
27
|
+
const imageId = (featuredImage === null || featuredImage === void 0 ? void 0 : featuredImage.id) || semanticId;
|
|
28
|
+
// Ensure featuredImage always has an id when it exists
|
|
29
|
+
// This prevents the "missing featured image" issue on save
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
if (featuredImage && !featuredImage.id) {
|
|
32
|
+
// If featuredImage exists but has no id, set it to the semanticId
|
|
33
|
+
onUpdate(Object.assign(Object.assign({}, featuredImage), { id: semanticId }));
|
|
34
|
+
}
|
|
35
|
+
}, [featuredImage, semanticId, onUpdate]);
|
|
36
|
+
// Get transform values from featuredImage or use defaults
|
|
37
|
+
const brightness = (_a = featuredImage === null || featuredImage === void 0 ? void 0 : featuredImage.brightness) !== null && _a !== void 0 ? _a : 100;
|
|
38
|
+
const blur = (_b = featuredImage === null || featuredImage === void 0 ? void 0 : featuredImage.blur) !== null && _b !== void 0 ? _b : 0;
|
|
39
|
+
const scale = (_c = featuredImage === null || featuredImage === void 0 ? void 0 : featuredImage.scale) !== null && _c !== void 0 ? _c : 1.0;
|
|
40
|
+
const positionX = (_d = featuredImage === null || featuredImage === void 0 ? void 0 : featuredImage.positionX) !== null && _d !== void 0 ? _d : 0;
|
|
41
|
+
const positionY = (_e = featuredImage === null || featuredImage === void 0 ? void 0 : featuredImage.positionY) !== null && _e !== void 0 ? _e : 0;
|
|
42
|
+
// Handle image selection - create initial mapping and update blog metadata with semantic ID
|
|
43
|
+
// Plugin-images Image component will automatically resolve the semantic ID when it renders
|
|
44
|
+
const handleImageChange = useCallback(async (image) => {
|
|
45
|
+
var _a, _b;
|
|
46
|
+
if (image) {
|
|
47
|
+
// Extract filename from image URL for reference
|
|
48
|
+
const isUploadedImage = image.url.startsWith('/api/uploads/');
|
|
49
|
+
let filename = image.filename;
|
|
50
|
+
if (!filename && isUploadedImage) {
|
|
51
|
+
// Extract filename from URL if not provided
|
|
52
|
+
filename = ((_a = image.url.split('/api/uploads/')[1]) === null || _a === void 0 ? void 0 : _a.split('?')[0]) || image.id;
|
|
53
|
+
}
|
|
54
|
+
else if (!filename) {
|
|
55
|
+
// For external URLs, use the image ID or extract from URL
|
|
56
|
+
filename = image.id || ((_b = image.url.split('/').pop()) === null || _b === void 0 ? void 0 : _b.split('?')[0]) || `external-${Date.now()}`;
|
|
57
|
+
}
|
|
58
|
+
// Create initial mapping in plugin-images API immediately
|
|
59
|
+
// This ensures the semantic ID resolves correctly
|
|
60
|
+
try {
|
|
61
|
+
const saveData = {
|
|
62
|
+
id: imageId,
|
|
63
|
+
filename: filename,
|
|
64
|
+
scale: 1.0,
|
|
65
|
+
positionX: 0,
|
|
66
|
+
positionY: 0,
|
|
67
|
+
brightness: 100,
|
|
68
|
+
blur: 0,
|
|
69
|
+
};
|
|
70
|
+
await fetch('/api/plugin-images/resolve', {
|
|
71
|
+
method: 'POST',
|
|
72
|
+
headers: { 'Content-Type': 'application/json' },
|
|
73
|
+
body: JSON.stringify(saveData),
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
console.error('[FeaturedMediaSection] Failed to create initial mapping:', error);
|
|
78
|
+
// Continue anyway - the mapping might be created later
|
|
79
|
+
}
|
|
80
|
+
// Update blog metadata with semantic ID
|
|
81
|
+
onUpdate({
|
|
82
|
+
id: imageId,
|
|
83
|
+
alt: image.alt || image.filename,
|
|
84
|
+
brightness: 100,
|
|
85
|
+
blur: 0,
|
|
86
|
+
scale: 1.0,
|
|
87
|
+
positionX: 0,
|
|
88
|
+
positionY: 0,
|
|
89
|
+
isCustom: true,
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
// If removed, set to undefined
|
|
94
|
+
onUpdate(undefined);
|
|
95
|
+
}
|
|
96
|
+
setShowImagePicker(false);
|
|
97
|
+
}, [imageId, onUpdate]);
|
|
98
|
+
// Handle editor save from ImagePicker - save to plugin-images API
|
|
99
|
+
const handleEditorSave = useCallback(async (finalScale, finalPositionX, finalPositionY, finalBrightness, finalBlur) => {
|
|
100
|
+
if (!(featuredImage === null || featuredImage === void 0 ? void 0 : featuredImage.id))
|
|
101
|
+
return;
|
|
102
|
+
// Reset the auto-open flag immediately to prevent reopening
|
|
103
|
+
setOpenEditorDirectly(false);
|
|
104
|
+
// Get the actual filename from the API (resolve the semantic ID)
|
|
105
|
+
let filename = imageId; // Fallback to semantic ID
|
|
106
|
+
try {
|
|
107
|
+
const response = await fetch(`/api/plugin-images/resolve?id=${encodeURIComponent(imageId)}`);
|
|
108
|
+
if (response.ok) {
|
|
109
|
+
const data = await response.json();
|
|
110
|
+
filename = data.filename || imageId;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
catch (error) {
|
|
114
|
+
console.error('Failed to resolve filename:', error);
|
|
115
|
+
}
|
|
116
|
+
// Normalize position values
|
|
117
|
+
const normalizedPositionX = finalPositionX === -50 ? 0 : finalPositionX;
|
|
118
|
+
const normalizedPositionY = finalPositionY === -50 ? 0 : finalPositionY;
|
|
119
|
+
const finalBrightnessValue = finalBrightness !== null && finalBrightness !== void 0 ? finalBrightness : brightness;
|
|
120
|
+
const finalBlurValue = finalBlur !== null && finalBlur !== void 0 ? finalBlur : blur;
|
|
121
|
+
// Save to plugin-images API
|
|
122
|
+
try {
|
|
123
|
+
const saveData = {
|
|
124
|
+
id: imageId,
|
|
125
|
+
filename: filename,
|
|
126
|
+
scale: finalScale,
|
|
127
|
+
positionX: normalizedPositionX,
|
|
128
|
+
positionY: normalizedPositionY,
|
|
129
|
+
brightness: finalBrightnessValue,
|
|
130
|
+
blur: finalBlurValue,
|
|
131
|
+
};
|
|
132
|
+
const response = await fetch('/api/plugin-images/resolve', {
|
|
133
|
+
method: 'POST',
|
|
134
|
+
headers: { 'Content-Type': 'application/json' },
|
|
135
|
+
body: JSON.stringify(saveData),
|
|
136
|
+
});
|
|
137
|
+
if (response.ok) {
|
|
138
|
+
// Update local featured image data - ensure id is preserved
|
|
139
|
+
onUpdate(Object.assign(Object.assign({}, featuredImage), { id: featuredImage.id || imageId, scale: finalScale, positionX: normalizedPositionX, positionY: normalizedPositionY, brightness: finalBrightnessValue, blur: finalBlurValue }));
|
|
140
|
+
// Dispatch event to notify Image components
|
|
141
|
+
window.dispatchEvent(new CustomEvent('image-mapping-updated', {
|
|
142
|
+
detail: saveData
|
|
143
|
+
}));
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
catch (error) {
|
|
147
|
+
console.error('Failed to save image transform:', error);
|
|
148
|
+
}
|
|
149
|
+
}, [imageId, featuredImage, brightness, blur, onUpdate]);
|
|
150
|
+
return (_jsxs("section", { children: [_jsxs("div", { className: "flex items-center gap-3 mb-6", children: [_jsx(ImageIcon, { size: 14, className: "text-neutral-500 dark:text-neutral-400" }), _jsx("label", { className: "text-[10px] uppercase tracking-[0.2em] text-neutral-500 dark:text-neutral-400 font-black", children: "Featured Media" })] }), (featuredImage === null || featuredImage === void 0 ? void 0 : featuredImage.id) ? (_jsxs("div", { className: "relative group", children: [_jsxs("div", { className: "relative aspect-[16/10] bg-dashboard-bg rounded-3xl overflow-hidden border border-dashboard-border group/image", children: [_jsx(Image, Object.assign({ id: imageId, alt: (featuredImage === null || featuredImage === void 0 ? void 0 : featuredImage.alt) || 'Featured image', fill: true, className: "object-cover w-full h-full", editable: false }, {
|
|
151
|
+
brightness,
|
|
152
|
+
blur,
|
|
153
|
+
scale,
|
|
154
|
+
positionX,
|
|
155
|
+
positionY,
|
|
156
|
+
})), _jsx("button", { onClick: () => {
|
|
157
|
+
setOpenEditorDirectly(true);
|
|
158
|
+
setShowImagePicker(true);
|
|
159
|
+
}, className: "absolute inset-0 z-30 flex items-center justify-center opacity-0 group-hover/image:opacity-100 transition-all duration-300 bg-neutral-900/40 dark:bg-neutral-900/60 backdrop-blur-[2px]", children: _jsxs("div", { className: "flex items-center gap-2 px-4 py-2 bg-white dark:bg-neutral-800 rounded-full shadow-xl", children: [_jsx(ImageIcon, { size: 14, className: "text-primary" }), _jsx("span", { className: "text-[10px] font-bold uppercase tracking-widest", children: "Edit" })] }) })] }), _jsxs("div", { className: "mt-2 flex items-center gap-3", children: [_jsx("button", { onClick: () => setShowImagePicker(true), className: "text-[10px] text-neutral-600 dark:text-neutral-400 hover:text-primary font-bold uppercase tracking-wider", children: "Change Image" }), _jsx("span", { className: "text-[10px] text-neutral-400", children: "\u2022" }), _jsx("button", { onClick: () => onUpdate(undefined), className: "text-[10px] text-red-500 dark:text-red-400 hover:text-red-700 dark:hover:text-red-300 font-bold uppercase tracking-wider", children: "Remove Image" })] })] })) : (_jsxs("div", { className: "group relative aspect-[16/10] bg-dashboard-bg rounded-3xl border-2 border-dashed border-dashboard-border flex flex-col items-center justify-center text-neutral-400 dark:text-neutral-500 hover:bg-dashboard-card hover:border-primary cursor-pointer transition-all duration-300", onClick: () => setShowImagePicker(true), children: [_jsx(Plus, { size: 24, strokeWidth: 1, className: "mb-3 group-hover:scale-110 transition-transform" }), _jsx("span", { className: "text-[9px] font-black uppercase tracking-widest", children: "Assign Image" })] })), showImagePicker && mounted && createPortal(_jsx("div", { className: "fixed inset-0 z-[100] flex items-center justify-center bg-black/50 backdrop-blur-sm", onClick: () => {
|
|
160
|
+
setShowImagePicker(false);
|
|
161
|
+
setOpenEditorDirectly(false); // Reset flag when closing
|
|
162
|
+
}, children: _jsxs("div", { className: "bg-white dark:bg-neutral-900 rounded-2xl w-full max-w-2xl mx-4 p-6 shadow-2xl max-h-[90vh] overflow-y-auto", onClick: (e) => e.stopPropagation(), children: [_jsxs("div", { className: "flex items-center justify-between mb-6", children: [_jsx("h3", { className: "text-lg font-bold text-neutral-900 dark:text-neutral-100", children: openEditorDirectly ? 'Edit Featured Image' : 'Select Featured Image' }), _jsx("button", { onClick: () => {
|
|
163
|
+
setShowImagePicker(false);
|
|
164
|
+
setOpenEditorDirectly(false); // Reset flag when closing
|
|
165
|
+
}, className: "p-2 hover:bg-dashboard-bg dark:hover:bg-neutral-800 rounded-lg transition-colors text-neutral-700 dark:text-neutral-300 hover:text-neutral-900 dark:hover:text-white", "aria-label": "Close", children: _jsx(X, { size: 20, className: "transition-colors" }) })] }), _jsx(ImagePicker, Object.assign({ value: (featuredImage === null || featuredImage === void 0 ? void 0 : featuredImage.id) ? imageId : undefined, onChange: handleImageChange, brightness: brightness, blur: blur }, {
|
|
166
|
+
scale,
|
|
167
|
+
positionX,
|
|
168
|
+
positionY,
|
|
169
|
+
}, { onBrightnessChange: (val) => {
|
|
170
|
+
// Update local state only - don't trigger save
|
|
171
|
+
if (featuredImage) {
|
|
172
|
+
onUpdate(Object.assign(Object.assign({}, featuredImage), { id: featuredImage.id || imageId, brightness: val }));
|
|
173
|
+
}
|
|
174
|
+
}, onBlurChange: (val) => {
|
|
175
|
+
// Update local state only - don't trigger save
|
|
176
|
+
if (featuredImage) {
|
|
177
|
+
onUpdate(Object.assign(Object.assign({}, featuredImage), { id: featuredImage.id || imageId, blur: val }));
|
|
178
|
+
}
|
|
179
|
+
}, onEditorSave: handleEditorSave, darkMode: false, showEffects: true, aspectRatio: "16/10" // Thumbnail aspect ratio for blog cards
|
|
180
|
+
, borderRadius: "rounded-3xl", objectFit: "cover" // Cover for thumbnails
|
|
181
|
+
, objectPosition: "center" }))] }) }), document.body)] }));
|
|
182
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface LibraryItemProps {
|
|
3
|
+
icon: React.ReactNode;
|
|
4
|
+
label: string;
|
|
5
|
+
blockType: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
onAddBlock?: (blockType: string) => void;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Reusable Library Item Component
|
|
11
|
+
* Makes blocks draggable from the library and clickable to add at bottom
|
|
12
|
+
*/
|
|
13
|
+
export declare function LibraryItem({ icon, label, blockType, description, onAddBlock }: LibraryItemProps): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
//# sourceMappingURL=LibraryItem.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LibraryItem.d.ts","sourceRoot":"","sources":["LibraryItem.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA2B,MAAM,OAAO,CAAC;AAEhD,MAAM,WAAW,gBAAgB;IAC7B,IAAI,EAAE,KAAK,CAAC,SAAS,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;CAC5C;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,EACxB,IAAI,EACJ,KAAK,EACL,SAAS,EACT,WAAW,EACX,UAAU,EACb,EAAE,gBAAgB,2CAwDlB"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import React, { useState, useRef } from 'react';
|
|
4
|
+
/**
|
|
5
|
+
* Reusable Library Item Component
|
|
6
|
+
* Makes blocks draggable from the library and clickable to add at bottom
|
|
7
|
+
*/
|
|
8
|
+
export function LibraryItem({ icon, label, blockType, description, onAddBlock }) {
|
|
9
|
+
const [hasDragged, setHasDragged] = useState(false);
|
|
10
|
+
const mouseDownRef = useRef(null);
|
|
11
|
+
const handleDragStart = (e) => {
|
|
12
|
+
e.dataTransfer.setData('block-type', blockType);
|
|
13
|
+
e.dataTransfer.effectAllowed = 'move';
|
|
14
|
+
setHasDragged(true); // Mark as dragged when drag starts
|
|
15
|
+
};
|
|
16
|
+
const handleMouseDown = (e) => {
|
|
17
|
+
// Track mouse position on mousedown
|
|
18
|
+
mouseDownRef.current = { x: e.clientX, y: e.clientY };
|
|
19
|
+
setHasDragged(false); // Reset drag state
|
|
20
|
+
};
|
|
21
|
+
const handleMouseMove = (e) => {
|
|
22
|
+
// If mouse moved more than 5px, consider it a drag
|
|
23
|
+
if (mouseDownRef.current) {
|
|
24
|
+
const dx = Math.abs(e.clientX - mouseDownRef.current.x);
|
|
25
|
+
const dy = Math.abs(e.clientY - mouseDownRef.current.y);
|
|
26
|
+
if (dx > 5 || dy > 5) {
|
|
27
|
+
setHasDragged(true);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
const handleClick = (e) => {
|
|
32
|
+
// Only add block if we didn't drag
|
|
33
|
+
if (!hasDragged && onAddBlock) {
|
|
34
|
+
e.preventDefault();
|
|
35
|
+
e.stopPropagation();
|
|
36
|
+
onAddBlock(blockType);
|
|
37
|
+
}
|
|
38
|
+
// Reset state
|
|
39
|
+
mouseDownRef.current = null;
|
|
40
|
+
setTimeout(() => setHasDragged(false), 100);
|
|
41
|
+
};
|
|
42
|
+
return (_jsxs("div", { draggable: true, onDragStart: handleDragStart, onMouseDown: handleMouseDown, onMouseMove: handleMouseMove, onClick: handleClick, className: "flex flex-col items-center justify-center p-5 rounded-2xl border border-dashboard-border bg-dashboard-card hover:border-primary hover:shadow-xl hover:shadow-primary/5 transition-all cursor-pointer group", children: [_jsx("div", { className: "text-neutral-400 dark:text-neutral-500 group-hover:text-primary dark:group-hover:text-primary mb-3 transition-colors duration-300", children: React.cloneElement(icon, { strokeWidth: 1.5 }) }), _jsx("span", { className: "text-[9px] font-black uppercase tracking-[0.15em] text-neutral-600 dark:text-neutral-400 group-hover:text-neutral-950 dark:group-hover:text-white transition-colors", children: label })] }));
|
|
43
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface PrivacySettings {
|
|
2
|
+
isPrivate?: boolean;
|
|
3
|
+
password?: string;
|
|
4
|
+
sharedWithUsers?: string[];
|
|
5
|
+
}
|
|
6
|
+
export interface PrivacySettingsSectionProps {
|
|
7
|
+
privacy?: PrivacySettings;
|
|
8
|
+
onUpdate: (privacy: PrivacySettings) => void;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Privacy Settings Section Component
|
|
12
|
+
* Handles privacy settings: private, password-protected, share with users
|
|
13
|
+
*/
|
|
14
|
+
export declare function PrivacySettingsSection({ privacy, onUpdate, }: PrivacySettingsSectionProps): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
//# sourceMappingURL=PrivacySettingsSection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PrivacySettingsSection.d.ts","sourceRoot":"","sources":["PrivacySettingsSection.tsx"],"names":[],"mappings":"AAKA,MAAM,WAAW,eAAe;IAC5B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;CAC9B;AAED,MAAM,WAAW,2BAA2B;IACxC,OAAO,CAAC,EAAE,eAAe,CAAC;IAC1B,QAAQ,EAAE,CAAC,OAAO,EAAE,eAAe,KAAK,IAAI,CAAC;CAChD;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,EACnC,OAAO,EACP,QAAQ,GACX,EAAE,2BAA2B,2CA2L7B"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useState, useEffect } from 'react';
|
|
4
|
+
import { Shield, Key, Users } from 'lucide-react';
|
|
5
|
+
/**
|
|
6
|
+
* Privacy Settings Section Component
|
|
7
|
+
* Handles privacy settings: private, password-protected, share with users
|
|
8
|
+
*/
|
|
9
|
+
export function PrivacySettingsSection({ privacy, onUpdate, }) {
|
|
10
|
+
var _a;
|
|
11
|
+
const [users, setUsers] = useState([]);
|
|
12
|
+
const [loadingUsers, setLoadingUsers] = useState(false);
|
|
13
|
+
const [showPasswordInput, setShowPasswordInput] = useState(false);
|
|
14
|
+
const [passwordValue, setPasswordValue] = useState((privacy === null || privacy === void 0 ? void 0 : privacy.password) || '');
|
|
15
|
+
const [showUserSelector, setShowUserSelector] = useState(false);
|
|
16
|
+
// Fetch users from plugin-users
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
const fetchUsers = async () => {
|
|
19
|
+
try {
|
|
20
|
+
setLoadingUsers(true);
|
|
21
|
+
const res = await fetch('/api/users');
|
|
22
|
+
const data = await res.json();
|
|
23
|
+
if (Array.isArray(data)) {
|
|
24
|
+
setUsers(data);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
catch (err) {
|
|
28
|
+
console.error('Failed to load users', err);
|
|
29
|
+
}
|
|
30
|
+
finally {
|
|
31
|
+
setLoadingUsers(false);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
fetchUsers();
|
|
35
|
+
}, []);
|
|
36
|
+
const handlePrivacyToggle = (isPrivate) => {
|
|
37
|
+
onUpdate(Object.assign(Object.assign(Object.assign({}, privacy), { isPrivate }), (isPrivate ? {} : { password: undefined, sharedWithUsers: undefined })));
|
|
38
|
+
};
|
|
39
|
+
const handlePasswordChange = (password) => {
|
|
40
|
+
setPasswordValue(password);
|
|
41
|
+
onUpdate(Object.assign(Object.assign({}, privacy), { password: password || undefined }));
|
|
42
|
+
};
|
|
43
|
+
const handleUserToggle = (userId) => {
|
|
44
|
+
const currentUsers = (privacy === null || privacy === void 0 ? void 0 : privacy.sharedWithUsers) || [];
|
|
45
|
+
const newUsers = currentUsers.includes(userId)
|
|
46
|
+
? currentUsers.filter(id => id !== userId)
|
|
47
|
+
: [...currentUsers, userId];
|
|
48
|
+
onUpdate(Object.assign(Object.assign({}, privacy), { sharedWithUsers: newUsers.length > 0 ? newUsers : undefined }));
|
|
49
|
+
};
|
|
50
|
+
return (_jsxs("section", { className: "pt-8 border-t border-neutral-200 dark:border-neutral-800", children: [_jsxs("div", { className: "flex items-center gap-3 mb-6", children: [_jsx(Shield, { size: 14, className: "text-neutral-500 dark:text-neutral-400" }), _jsx("label", { className: "text-[10px] uppercase tracking-[0.2em] text-neutral-500 dark:text-neutral-400 font-black", children: "Privacy Settings" })] }), _jsxs("div", { className: "space-y-4", children: [_jsxs("div", { className: "flex items-center justify-between", children: [_jsxs("div", { children: [_jsx("label", { className: "text-[10px] text-neutral-700 dark:text-neutral-300 font-bold block mb-1", children: "Make Private" }), _jsx("p", { className: "text-[9px] text-neutral-500 dark:text-neutral-400", children: "Hide from public view" })] }), _jsx("button", { onClick: () => handlePrivacyToggle(!(privacy === null || privacy === void 0 ? void 0 : privacy.isPrivate)), className: `relative w-12 h-6 rounded-full transition-colors ${(privacy === null || privacy === void 0 ? void 0 : privacy.isPrivate) ? 'bg-primary' : 'bg-neutral-300 dark:bg-neutral-700'}`, children: _jsx("div", { className: `absolute top-1 left-1 w-4 h-4 bg-white rounded-full transition-transform ${(privacy === null || privacy === void 0 ? void 0 : privacy.isPrivate) ? 'translate-x-6' : 'translate-x-0'}` }) })] }), (privacy === null || privacy === void 0 ? void 0 : privacy.isPrivate) && (_jsxs("div", { className: "space-y-2", children: [_jsxs("div", { className: "flex items-center justify-between", children: [_jsxs("div", { children: [_jsx("label", { className: "text-[10px] text-neutral-700 dark:text-neutral-300 font-bold block mb-1", children: "Password Protection" }), _jsx("p", { className: "text-[9px] text-neutral-500 dark:text-neutral-400", children: "Require password to view" })] }), _jsx("button", { onClick: () => {
|
|
51
|
+
setShowPasswordInput(!showPasswordInput);
|
|
52
|
+
if (!showPasswordInput && !privacy.password) {
|
|
53
|
+
setPasswordValue('');
|
|
54
|
+
}
|
|
55
|
+
}, className: `p-1.5 rounded-lg transition-colors ${privacy.password || showPasswordInput
|
|
56
|
+
? 'bg-primary/10 text-primary'
|
|
57
|
+
: 'bg-neutral-100 dark:bg-neutral-800 text-neutral-400'}`, children: _jsx(Key, { size: 14 }) })] }), (showPasswordInput || privacy.password) && (_jsx("input", { type: "password", value: passwordValue, onChange: (e) => handlePasswordChange(e.target.value), placeholder: "Enter password", className: "w-full px-3 py-2 text-xs bg-white dark:bg-neutral-900/50 border border-neutral-300 dark:border-neutral-700 rounded-lg outline-none focus:border-primary transition-all dark:text-neutral-100" }))] })), (privacy === null || privacy === void 0 ? void 0 : privacy.isPrivate) && (_jsxs("div", { className: "space-y-2", children: [_jsxs("div", { className: "flex items-center justify-between", children: [_jsxs("div", { children: [_jsx("label", { className: "text-[10px] text-neutral-700 dark:text-neutral-300 font-bold block mb-1", children: "Share with Users" }), _jsx("p", { className: "text-[9px] text-neutral-500 dark:text-neutral-400", children: "Grant access to specific users" })] }), _jsx("button", { onClick: () => setShowUserSelector(!showUserSelector), className: `p-1.5 rounded-lg transition-colors ${(((_a = privacy.sharedWithUsers) === null || _a === void 0 ? void 0 : _a.length) || 0) > 0 || showUserSelector
|
|
58
|
+
? 'bg-primary/10 text-primary'
|
|
59
|
+
: 'bg-neutral-100 dark:bg-neutral-800 text-neutral-400'}`, children: _jsx(Users, { size: 14 }) })] }), showUserSelector && (_jsx("div", { className: "bg-dashboard-bg rounded-lg p-3 border border-dashboard-border max-h-48 overflow-y-auto", children: loadingUsers ? (_jsx("p", { className: "text-[10px] text-neutral-500 dark:text-neutral-400", children: "Loading users..." })) : users.length === 0 ? (_jsx("p", { className: "text-[10px] text-neutral-500 dark:text-neutral-400", children: "No users found" })) : (_jsx("div", { className: "space-y-2", children: users.map((user) => {
|
|
60
|
+
var _a;
|
|
61
|
+
return (_jsxs("label", { className: "flex items-center gap-2 cursor-pointer hover:bg-dashboard-bg p-2 rounded transition-colors", children: [_jsx("input", { type: "checkbox", checked: ((_a = privacy.sharedWithUsers) === null || _a === void 0 ? void 0 : _a.includes(user._id)) || false, onChange: () => handleUserToggle(user._id), className: "rounded border-neutral-300 dark:border-neutral-700 text-primary focus:ring-primary" }), _jsxs("div", { className: "flex-1 min-w-0", children: [_jsx("p", { className: "text-[10px] font-bold text-neutral-700 dark:text-neutral-300 truncate", children: user.name }), _jsx("p", { className: "text-[9px] text-neutral-500 dark:text-neutral-400 truncate", children: user.email })] })] }, user._id));
|
|
62
|
+
}) })) })), privacy.sharedWithUsers && privacy.sharedWithUsers.length > 0 && (_jsxs("p", { className: "text-[9px] text-neutral-500 dark:text-neutral-400", children: ["Shared with ", privacy.sharedWithUsers.length, " user", privacy.sharedWithUsers.length !== 1 ? 's' : ''] }))] }))] })] }));
|
|
63
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canvas Editor Components
|
|
3
|
+
* Exports all components used in the Canvas Editor
|
|
4
|
+
*/
|
|
5
|
+
export { LibraryItem } from './LibraryItem';
|
|
6
|
+
export type { LibraryItemProps } from './LibraryItem';
|
|
7
|
+
export { CustomBlockItem } from './CustomBlockItem';
|
|
8
|
+
export type { CustomBlockItemProps } from './CustomBlockItem';
|
|
9
|
+
export { FeaturedMediaSection } from './FeaturedMediaSection';
|
|
10
|
+
export type { FeaturedMediaSectionProps, FeaturedImage } from './FeaturedMediaSection';
|
|
11
|
+
export { PrivacySettingsSection } from './PrivacySettingsSection';
|
|
12
|
+
export type { PrivacySettingsSectionProps, PrivacySettings } from './PrivacySettingsSection';
|
|
13
|
+
export { ErrorBanner } from './ErrorBanner';
|
|
14
|
+
export type { ErrorBannerProps } from './ErrorBanner';
|
|
15
|
+
export { EditorLibrary } from './EditorLibrary';
|
|
16
|
+
export type { EditorLibraryProps } from './EditorLibrary';
|
|
17
|
+
export { EditorCanvas } from './EditorCanvas';
|
|
18
|
+
export type { EditorCanvasProps } from './EditorCanvas';
|
|
19
|
+
export { EditorSidebar } from './EditorSidebar';
|
|
20
|
+
export type { EditorSidebarProps } from './EditorSidebar';
|
|
21
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,YAAY,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEtD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,YAAY,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAE9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,YAAY,EAAE,yBAAyB,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvF,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,YAAY,EAAE,2BAA2B,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAE7F,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,YAAY,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEtD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,YAAY,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAE1D,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAExD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,YAAY,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canvas Editor Components
|
|
3
|
+
* Exports all components used in the Canvas Editor
|
|
4
|
+
*/
|
|
5
|
+
export { LibraryItem } from './LibraryItem';
|
|
6
|
+
export { CustomBlockItem } from './CustomBlockItem';
|
|
7
|
+
export { FeaturedMediaSection } from './FeaturedMediaSection';
|
|
8
|
+
export { PrivacySettingsSection } from './PrivacySettingsSection';
|
|
9
|
+
export { ErrorBanner } from './ErrorBanner';
|
|
10
|
+
export { EditorLibrary } from './EditorLibrary';
|
|
11
|
+
export { EditorCanvas } from './EditorCanvas';
|
|
12
|
+
export { EditorSidebar } from './EditorSidebar';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canvas Editor Hooks
|
|
3
|
+
* Exports all custom hooks used in the Canvas Editor
|
|
4
|
+
*/
|
|
5
|
+
export { usePostLoader } from './usePostLoader';
|
|
6
|
+
export { useHeroBlock } from './useHeroBlock';
|
|
7
|
+
export { useRegisteredBlocks } from './useRegisteredBlocks';
|
|
8
|
+
export { useKeyboardShortcuts } from './useKeyboardShortcuts';
|
|
9
|
+
export { useUnsavedChanges } from './useUnsavedChanges';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canvas Editor Hooks
|
|
3
|
+
* Exports all custom hooks used in the Canvas Editor
|
|
4
|
+
*/
|
|
5
|
+
export { usePostLoader } from './usePostLoader';
|
|
6
|
+
export { useHeroBlock } from './useHeroBlock';
|
|
7
|
+
export { useRegisteredBlocks } from './useRegisteredBlocks';
|
|
8
|
+
export { useKeyboardShortcuts } from './useKeyboardShortcuts';
|
|
9
|
+
export { useUnsavedChanges } from './useUnsavedChanges';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Block } from '../../../types/block';
|
|
2
|
+
import type { EditorState } from '../../../state/types';
|
|
3
|
+
export declare function useHeroBlock(state: EditorState, registeredBlocks: any[]): {
|
|
4
|
+
heroBlock: Block | null;
|
|
5
|
+
setHeroBlock: import("react").Dispatch<import("react").SetStateAction<Block | null>>;
|
|
6
|
+
heroBlockDefinition: import("../../..").BlockTypeDefinition | undefined;
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=useHeroBlock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useHeroBlock.d.ts","sourceRoot":"","sources":["useHeroBlock.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAUxD,wBAAgB,YAAY,CAAC,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,GAAG,EAAE;;;;EAyFvE"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { useState, useEffect, useMemo } from 'react';
|
|
2
|
+
import { blockRegistry } from '../../../registry/BlockRegistry';
|
|
3
|
+
// Generate a unique block ID
|
|
4
|
+
function generateBlockId() {
|
|
5
|
+
if (typeof crypto !== 'undefined' && crypto.randomUUID) {
|
|
6
|
+
return crypto.randomUUID();
|
|
7
|
+
}
|
|
8
|
+
return `block-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
9
|
+
}
|
|
10
|
+
export function useHeroBlock(state, registeredBlocks) {
|
|
11
|
+
const [heroBlock, setHeroBlock] = useState(null);
|
|
12
|
+
// Get Hero block definition from registered blocks (REQUIRED)
|
|
13
|
+
const heroBlockDefinition = useMemo(() => {
|
|
14
|
+
return blockRegistry.get('hero');
|
|
15
|
+
}, [registeredBlocks]);
|
|
16
|
+
// Initialize hero block if Hero block definition exists
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
if (heroBlockDefinition) {
|
|
19
|
+
// Get default data from block definition
|
|
20
|
+
const heroData = heroBlockDefinition.defaultData || {};
|
|
21
|
+
// Initialize hero block only if it doesn't exist yet
|
|
22
|
+
setHeroBlock(prev => {
|
|
23
|
+
if (!prev) {
|
|
24
|
+
// First, try to find hero block in contentBlocks (from loaded post)
|
|
25
|
+
const heroBlockFromContent = state.blocks.find(block => block.type === 'hero');
|
|
26
|
+
if (heroBlockFromContent) {
|
|
27
|
+
return heroBlockFromContent;
|
|
28
|
+
}
|
|
29
|
+
// If no hero block in contentBlocks, initialize from defaults
|
|
30
|
+
// Hero image and featured image are completely independent - no syncing
|
|
31
|
+
const initialData = Object.assign(Object.assign({}, heroData), { title: state.title || heroData.title || '', summary: state.metadata.excerpt || heroData.summary || '', image: heroData.image });
|
|
32
|
+
return {
|
|
33
|
+
id: generateBlockId(),
|
|
34
|
+
type: 'hero',
|
|
35
|
+
data: initialData,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
// Keep existing hero block data - let the Edit component manage it
|
|
39
|
+
return prev;
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
setHeroBlock(null);
|
|
44
|
+
}
|
|
45
|
+
}, [heroBlockDefinition, state.blocks, state.title, state.metadata.excerpt]);
|
|
46
|
+
// Sync hero block with editor state when post is loaded (for existing posts)
|
|
47
|
+
// BUT: Never sync image from featured image to hero - they are independent
|
|
48
|
+
// Only sync title, summary, and category
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
51
|
+
if (heroBlock && heroBlockDefinition && state.postId) {
|
|
52
|
+
// Only update if the hero block data doesn't match the editor state
|
|
53
|
+
// This prevents overwriting user edits with stale data
|
|
54
|
+
const currentTitle = ((_a = heroBlock.data) === null || _a === void 0 ? void 0 : _a.title) || '';
|
|
55
|
+
const currentSummary = ((_b = heroBlock.data) === null || _b === void 0 ? void 0 : _b.summary) || '';
|
|
56
|
+
const currentCategory = ((_c = heroBlock.data) === null || _c === void 0 ? void 0 : _c.category) || '';
|
|
57
|
+
const stateTitle = state.title || '';
|
|
58
|
+
const stateSummary = state.metadata.excerpt || '';
|
|
59
|
+
const stateCategory = ((_d = state.metadata.categories) === null || _d === void 0 ? void 0 : _d[0]) || '';
|
|
60
|
+
// Check if hero block is out of sync with editor state
|
|
61
|
+
// NOTE: We do NOT sync image anymore - hero and featured image are independent
|
|
62
|
+
const titleMismatch = currentTitle !== stateTitle;
|
|
63
|
+
const summaryMismatch = currentSummary !== stateSummary;
|
|
64
|
+
const categoryMismatch = currentCategory !== stateCategory;
|
|
65
|
+
// Only update title, summary, and category - NEVER update image
|
|
66
|
+
// The hero block image should come from contentBlocks, not from featured image
|
|
67
|
+
if ((titleMismatch || summaryMismatch || categoryMismatch) && (stateTitle || stateSummary || stateCategory)) {
|
|
68
|
+
setHeroBlock(Object.assign(Object.assign({}, heroBlock), { data: Object.assign(Object.assign({}, heroBlock.data), { title: stateTitle || ((_e = heroBlock.data) === null || _e === void 0 ? void 0 : _e.title) || '', summary: stateSummary || ((_f = heroBlock.data) === null || _f === void 0 ? void 0 : _f.summary) || '',
|
|
69
|
+
// DO NOT sync image - keep hero block's own image
|
|
70
|
+
category: stateCategory || ((_g = heroBlock.data) === null || _g === void 0 ? void 0 : _g.category) || '' }) }));
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}, [state.postId, state.title, state.metadata.excerpt, state.metadata.categories, heroBlockDefinition, heroBlock]);
|
|
74
|
+
return {
|
|
75
|
+
heroBlock,
|
|
76
|
+
setHeroBlock,
|
|
77
|
+
heroBlockDefinition,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { EditorState } from '../../../state/types';
|
|
2
|
+
export declare function useKeyboardShortcuts(state: EditorState, dispatch: (action: any) => void, canUndo: boolean, canRedo: boolean, undo: () => void, redo: () => void): void;
|
|
3
|
+
//# sourceMappingURL=useKeyboardShortcuts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useKeyboardShortcuts.d.ts","sourceRoot":"","sources":["useKeyboardShortcuts.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAUxD,wBAAgB,oBAAoB,CAChC,KAAK,EAAE,WAAW,EAClB,QAAQ,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,EAC/B,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,MAAM,IAAI,EAChB,IAAI,EAAE,MAAM,IAAI,QA2HnB"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
// Generate a unique block ID
|
|
3
|
+
function generateBlockId() {
|
|
4
|
+
if (typeof crypto !== 'undefined' && crypto.randomUUID) {
|
|
5
|
+
return crypto.randomUUID();
|
|
6
|
+
}
|
|
7
|
+
return `block-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
8
|
+
}
|
|
9
|
+
export function useKeyboardShortcuts(state, dispatch, canUndo, canRedo, undo, redo) {
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
const handleKeyDown = (e) => {
|
|
12
|
+
// Don't handle shortcuts if user is typing in an input/textarea/contentEditable
|
|
13
|
+
const target = e.target;
|
|
14
|
+
const isEditableElement = target.tagName === 'INPUT' ||
|
|
15
|
+
target.tagName === 'TEXTAREA' ||
|
|
16
|
+
target.isContentEditable ||
|
|
17
|
+
target.closest('input, textarea, [contenteditable="true"]');
|
|
18
|
+
// Check for Ctrl+Z / Cmd+Z (Undo)
|
|
19
|
+
if ((e.ctrlKey || e.metaKey) && e.key === 'z' && !e.shiftKey) {
|
|
20
|
+
if (!isEditableElement) {
|
|
21
|
+
e.preventDefault();
|
|
22
|
+
e.stopPropagation();
|
|
23
|
+
if (canUndo) {
|
|
24
|
+
undo();
|
|
25
|
+
}
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
// Check for Ctrl+Shift+Z / Cmd+Shift+Z or Ctrl+Y / Cmd+Y (Redo)
|
|
30
|
+
if (((e.ctrlKey || e.metaKey) && e.shiftKey && e.key === 'z') || ((e.ctrlKey || e.metaKey) && e.key === 'y')) {
|
|
31
|
+
if (!isEditableElement) {
|
|
32
|
+
e.preventDefault();
|
|
33
|
+
e.stopPropagation();
|
|
34
|
+
if (canRedo) {
|
|
35
|
+
redo();
|
|
36
|
+
}
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
// Check for Ctrl+V (Windows/Linux) or Cmd+V (Mac)
|
|
41
|
+
if ((e.ctrlKey || e.metaKey) && e.key === 'v') {
|
|
42
|
+
// Don't paste if user is typing in an input/textarea/contentEditable
|
|
43
|
+
const target = e.target;
|
|
44
|
+
const isEditableElement = target.tagName === 'INPUT' ||
|
|
45
|
+
target.tagName === 'TEXTAREA' ||
|
|
46
|
+
target.isContentEditable ||
|
|
47
|
+
target.closest('input, textarea, [contenteditable="true"]');
|
|
48
|
+
if (isEditableElement) {
|
|
49
|
+
return; // Let the browser handle paste in editable elements
|
|
50
|
+
}
|
|
51
|
+
// Check if there's a copied block
|
|
52
|
+
if (typeof window !== 'undefined') {
|
|
53
|
+
const copiedBlockJson = localStorage.getItem('__BLOG_EDITOR_COPIED_BLOCK__');
|
|
54
|
+
if (copiedBlockJson) {
|
|
55
|
+
try {
|
|
56
|
+
e.preventDefault();
|
|
57
|
+
e.stopPropagation();
|
|
58
|
+
const copiedBlock = JSON.parse(copiedBlockJson);
|
|
59
|
+
// Clone a block with new IDs (recursive for nested blocks)
|
|
60
|
+
const cloneBlock = (blockToClone) => {
|
|
61
|
+
const cloned = Object.assign(Object.assign({}, blockToClone), { id: generateBlockId(), data: Object.assign({}, blockToClone.data), meta: blockToClone.meta ? Object.assign({}, blockToClone.meta) : undefined });
|
|
62
|
+
// Handle children if they exist
|
|
63
|
+
if (blockToClone.children) {
|
|
64
|
+
if (Array.isArray(blockToClone.children) && blockToClone.children.length > 0) {
|
|
65
|
+
if (typeof blockToClone.children[0] === 'object') {
|
|
66
|
+
cloned.children = blockToClone.children.map(cloneBlock);
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
// If children are IDs, find and clone the actual blocks
|
|
70
|
+
const allBlocks = state.blocks;
|
|
71
|
+
const childIds = blockToClone.children;
|
|
72
|
+
const childBlocks = childIds
|
|
73
|
+
.map((childId) => allBlocks.find(b => b.id === childId))
|
|
74
|
+
.filter((b) => b !== undefined);
|
|
75
|
+
cloned.children = childBlocks.map(cloneBlock);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return cloned;
|
|
80
|
+
};
|
|
81
|
+
const pastedBlock = cloneBlock(copiedBlock);
|
|
82
|
+
// Find where to paste - use hovered block or selected block, or paste at end
|
|
83
|
+
const hoveredBlockId = window.__BLOG_EDITOR_HOVERED_BLOCK_ID__;
|
|
84
|
+
const targetBlockId = hoveredBlockId || state.selectedBlockId;
|
|
85
|
+
let pasteIndex;
|
|
86
|
+
if (targetBlockId) {
|
|
87
|
+
const targetIndex = state.blocks.findIndex(b => b.id === targetBlockId);
|
|
88
|
+
if (targetIndex !== -1) {
|
|
89
|
+
pasteIndex = targetIndex + 1;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
// Dispatch ADD_BLOCK with the full block structure
|
|
93
|
+
dispatch({
|
|
94
|
+
type: 'ADD_BLOCK',
|
|
95
|
+
payload: {
|
|
96
|
+
block: pastedBlock,
|
|
97
|
+
index: pasteIndex,
|
|
98
|
+
containerId: undefined
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
console.error('Failed to paste block:', error);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
window.addEventListener('keydown', handleKeyDown);
|
|
110
|
+
return () => {
|
|
111
|
+
window.removeEventListener('keydown', handleKeyDown);
|
|
112
|
+
};
|
|
113
|
+
}, [state.blocks, state.selectedBlockId, dispatch, canUndo, canRedo, undo, redo]);
|
|
114
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { BlogPost } from '../../../types/post';
|
|
2
|
+
export declare function usePostLoader(postId: string | undefined, currentPostId: string | null, loadPost: (post: BlogPost) => void, resetHeroBlock: () => void): {
|
|
3
|
+
isLoadingPost: boolean;
|
|
4
|
+
};
|
|
5
|
+
//# sourceMappingURL=usePostLoader.d.ts.map
|