@jhits/plugin-blog 0.0.9 → 0.0.11
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/package.json +58 -59
- package/src/api/categories.ts +0 -43
- package/src/api/check-title.ts +0 -60
- package/src/api/config-handler.ts +0 -76
- package/src/api/handler.ts +0 -418
- package/src/api/index.ts +0 -33
- package/src/api/route.ts +0 -116
- package/src/api/router.ts +0 -128
- package/src/api-server.ts +0 -11
- package/src/config.ts +0 -161
- package/src/hooks/index.d.ts +0 -8
- package/src/hooks/index.d.ts.map +0 -1
- package/src/hooks/index.js +0 -7
- package/src/hooks/index.ts +0 -9
- package/src/hooks/useBlog.d.ts +0 -31
- package/src/hooks/useBlog.d.ts.map +0 -1
- package/src/hooks/useBlog.js +0 -57
- package/src/hooks/useBlog.ts +0 -85
- package/src/hooks/useBlogs.d.ts +0 -39
- package/src/hooks/useBlogs.d.ts.map +0 -1
- package/src/hooks/useBlogs.js +0 -82
- package/src/hooks/useBlogs.ts +0 -123
- package/src/hooks/useCategories.d.ts +0 -9
- package/src/hooks/useCategories.d.ts.map +0 -1
- package/src/hooks/useCategories.js +0 -70
- package/src/hooks/useCategories.ts +0 -76
- package/src/index.d.ts +0 -55
- package/src/index.d.ts.map +0 -1
- package/src/index.js +0 -228
- package/src/index.server.ts +0 -14
- package/src/index.tsx +0 -335
- package/src/init.d.ts +0 -40
- package/src/init.d.ts.map +0 -1
- package/src/init.js +0 -41
- package/src/init.tsx +0 -63
- package/src/lib/blocks/BlockRenderer.d.ts +0 -54
- package/src/lib/blocks/BlockRenderer.d.ts.map +0 -1
- package/src/lib/blocks/BlockRenderer.js +0 -54
- package/src/lib/blocks/BlockRenderer.tsx +0 -141
- package/src/lib/blocks/index.ts +0 -6
- package/src/lib/config-storage.d.ts +0 -30
- package/src/lib/config-storage.d.ts.map +0 -1
- package/src/lib/config-storage.js +0 -31
- package/src/lib/config-storage.ts +0 -65
- package/src/lib/index.ts +0 -9
- package/src/lib/layouts/blocks/ColumnsBlock.d.ts +0 -25
- package/src/lib/layouts/blocks/ColumnsBlock.d.ts.map +0 -1
- package/src/lib/layouts/blocks/ColumnsBlock.js +0 -182
- package/src/lib/layouts/blocks/ColumnsBlock.tsx +0 -298
- package/src/lib/layouts/blocks/ColumnsBlock.tsx.tmp +0 -81
- package/src/lib/layouts/blocks/SectionBlock.d.ts +0 -25
- package/src/lib/layouts/blocks/SectionBlock.d.ts.map +0 -1
- package/src/lib/layouts/blocks/SectionBlock.js +0 -44
- package/src/lib/layouts/blocks/SectionBlock.tsx +0 -104
- package/src/lib/layouts/blocks/index.ts +0 -8
- package/src/lib/layouts/index.d.ts +0 -23
- package/src/lib/layouts/index.d.ts.map +0 -1
- package/src/lib/layouts/index.js +0 -45
- package/src/lib/layouts/index.ts +0 -52
- package/src/lib/layouts/registerLayoutBlocks.d.ts +0 -9
- package/src/lib/layouts/registerLayoutBlocks.d.ts.map +0 -1
- package/src/lib/layouts/registerLayoutBlocks.js +0 -60
- package/src/lib/layouts/registerLayoutBlocks.ts +0 -64
- package/src/lib/mappers/apiMapper.d.ts +0 -66
- package/src/lib/mappers/apiMapper.d.ts.map +0 -1
- package/src/lib/mappers/apiMapper.js +0 -191
- package/src/lib/mappers/apiMapper.ts +0 -254
- package/src/lib/migration/index.ts +0 -6
- package/src/lib/migration/mapper.ts +0 -140
- package/src/lib/rich-text/RichTextEditor.d.ts +0 -45
- package/src/lib/rich-text/RichTextEditor.d.ts.map +0 -1
- package/src/lib/rich-text/RichTextEditor.js +0 -564
- package/src/lib/rich-text/RichTextEditor.tsx +0 -826
- package/src/lib/rich-text/RichTextPreview.d.ts +0 -16
- package/src/lib/rich-text/RichTextPreview.d.ts.map +0 -1
- package/src/lib/rich-text/RichTextPreview.js +0 -144
- package/src/lib/rich-text/RichTextPreview.tsx +0 -210
- package/src/lib/rich-text/index.d.ts +0 -9
- package/src/lib/rich-text/index.d.ts.map +0 -1
- package/src/lib/rich-text/index.js +0 -6
- package/src/lib/rich-text/index.ts +0 -10
- package/src/lib/utils/blockHelpers.d.ts +0 -23
- package/src/lib/utils/blockHelpers.d.ts.map +0 -1
- package/src/lib/utils/blockHelpers.js +0 -65
- package/src/lib/utils/blockHelpers.ts +0 -72
- package/src/lib/utils/configValidation.d.ts +0 -23
- package/src/lib/utils/configValidation.d.ts.map +0 -1
- package/src/lib/utils/configValidation.js +0 -113
- package/src/lib/utils/configValidation.ts +0 -137
- package/src/lib/utils/index.ts +0 -8
- package/src/lib/utils/slugify.ts +0 -79
- package/src/registry/BlockRegistry.d.ts +0 -62
- package/src/registry/BlockRegistry.d.ts.map +0 -1
- package/src/registry/BlockRegistry.js +0 -112
- package/src/registry/BlockRegistry.ts +0 -139
- package/src/registry/index.d.ts +0 -6
- package/src/registry/index.d.ts.map +0 -1
- package/src/registry/index.js +0 -4
- package/src/registry/index.ts +0 -11
- package/src/state/EditorContext.d.ts +0 -45
- package/src/state/EditorContext.d.ts.map +0 -1
- package/src/state/EditorContext.js +0 -215
- package/src/state/EditorContext.tsx +0 -283
- package/src/state/index.d.ts +0 -7
- package/src/state/index.d.ts.map +0 -1
- package/src/state/index.js +0 -6
- package/src/state/index.ts +0 -8
- package/src/state/reducer.d.ts +0 -11
- package/src/state/reducer.d.ts.map +0 -1
- package/src/state/reducer.js +0 -443
- package/src/state/reducer.ts +0 -694
- package/src/state/types.d.ts +0 -162
- package/src/state/types.d.ts.map +0 -1
- package/src/state/types.js +0 -27
- package/src/state/types.ts +0 -160
- package/src/types/block.d.ts +0 -221
- package/src/types/block.d.ts.map +0 -1
- package/src/types/block.js +0 -6
- package/src/types/block.ts +0 -269
- package/src/types/index.d.ts +0 -8
- package/src/types/index.d.ts.map +0 -1
- package/src/types/index.js +0 -5
- package/src/types/index.ts +0 -17
- package/src/types/post.d.ts +0 -136
- package/src/types/post.d.ts.map +0 -1
- package/src/types/post.js +0 -5
- package/src/types/post.ts +0 -169
- package/src/utils/client.d.ts +0 -48
- package/src/utils/client.d.ts.map +0 -1
- package/src/utils/client.js +0 -77
- package/src/utils/client.ts +0 -122
- package/src/utils/index.ts +0 -7
- package/src/views/CanvasEditor/BlockWrapper.d.ts +0 -16
- package/src/views/CanvasEditor/BlockWrapper.d.ts.map +0 -1
- package/src/views/CanvasEditor/BlockWrapper.js +0 -276
- package/src/views/CanvasEditor/BlockWrapper.tsx +0 -522
- package/src/views/CanvasEditor/CanvasEditorView.d.ts +0 -14
- package/src/views/CanvasEditor/CanvasEditorView.d.ts.map +0 -1
- package/src/views/CanvasEditor/CanvasEditorView.js +0 -209
- package/src/views/CanvasEditor/CanvasEditorView.tsx +0 -337
- package/src/views/CanvasEditor/EditorBody.d.ts +0 -22
- package/src/views/CanvasEditor/EditorBody.d.ts.map +0 -1
- package/src/views/CanvasEditor/EditorBody.js +0 -505
- package/src/views/CanvasEditor/EditorBody.tsx +0 -665
- package/src/views/CanvasEditor/EditorHeader.d.ts +0 -18
- package/src/views/CanvasEditor/EditorHeader.d.ts.map +0 -1
- package/src/views/CanvasEditor/EditorHeader.js +0 -101
- package/src/views/CanvasEditor/EditorHeader.tsx +0 -268
- package/src/views/CanvasEditor/LayoutContainer.d.ts +0 -17
- package/src/views/CanvasEditor/LayoutContainer.d.ts.map +0 -1
- package/src/views/CanvasEditor/LayoutContainer.js +0 -222
- package/src/views/CanvasEditor/LayoutContainer.tsx +0 -322
- package/src/views/CanvasEditor/SaveConfirmationModal.d.ts +0 -13
- package/src/views/CanvasEditor/SaveConfirmationModal.d.ts.map +0 -1
- package/src/views/CanvasEditor/SaveConfirmationModal.js +0 -78
- package/src/views/CanvasEditor/SaveConfirmationModal.tsx +0 -233
- package/src/views/CanvasEditor/components/CustomBlockItem.d.ts +0 -14
- package/src/views/CanvasEditor/components/CustomBlockItem.d.ts.map +0 -1
- package/src/views/CanvasEditor/components/CustomBlockItem.js +0 -44
- package/src/views/CanvasEditor/components/CustomBlockItem.tsx +0 -92
- package/src/views/CanvasEditor/components/EditorCanvas.d.ts +0 -29
- package/src/views/CanvasEditor/components/EditorCanvas.d.ts.map +0 -1
- package/src/views/CanvasEditor/components/EditorCanvas.js +0 -32
- package/src/views/CanvasEditor/components/EditorCanvas.tsx +0 -160
- package/src/views/CanvasEditor/components/EditorLibrary.d.ts +0 -7
- package/src/views/CanvasEditor/components/EditorLibrary.d.ts.map +0 -1
- package/src/views/CanvasEditor/components/EditorLibrary.js +0 -25
- package/src/views/CanvasEditor/components/EditorLibrary.tsx +0 -122
- package/src/views/CanvasEditor/components/EditorSidebar.d.ts +0 -13
- package/src/views/CanvasEditor/components/EditorSidebar.d.ts.map +0 -1
- package/src/views/CanvasEditor/components/EditorSidebar.js +0 -20
- package/src/views/CanvasEditor/components/EditorSidebar.tsx +0 -181
- package/src/views/CanvasEditor/components/ErrorBanner.d.ts +0 -6
- package/src/views/CanvasEditor/components/ErrorBanner.d.ts.map +0 -1
- package/src/views/CanvasEditor/components/ErrorBanner.js +0 -8
- package/src/views/CanvasEditor/components/ErrorBanner.tsx +0 -31
- package/src/views/CanvasEditor/components/FeaturedMediaSection.d.ts +0 -25
- package/src/views/CanvasEditor/components/FeaturedMediaSection.d.ts.map +0 -1
- package/src/views/CanvasEditor/components/FeaturedMediaSection.js +0 -182
- package/src/views/CanvasEditor/components/FeaturedMediaSection.tsx +0 -341
- package/src/views/CanvasEditor/components/LibraryItem.d.ts +0 -14
- package/src/views/CanvasEditor/components/LibraryItem.d.ts.map +0 -1
- package/src/views/CanvasEditor/components/LibraryItem.js +0 -43
- package/src/views/CanvasEditor/components/LibraryItem.tsx +0 -80
- package/src/views/CanvasEditor/components/PrivacySettingsSection.d.ts +0 -15
- package/src/views/CanvasEditor/components/PrivacySettingsSection.d.ts.map +0 -1
- package/src/views/CanvasEditor/components/PrivacySettingsSection.js +0 -63
- package/src/views/CanvasEditor/components/PrivacySettingsSection.tsx +0 -212
- package/src/views/CanvasEditor/components/index.d.ts +0 -21
- package/src/views/CanvasEditor/components/index.d.ts.map +0 -1
- package/src/views/CanvasEditor/components/index.js +0 -12
- package/src/views/CanvasEditor/components/index.ts +0 -28
- package/src/views/CanvasEditor/hooks/index.d.ts +0 -10
- package/src/views/CanvasEditor/hooks/index.d.ts.map +0 -1
- package/src/views/CanvasEditor/hooks/index.js +0 -9
- package/src/views/CanvasEditor/hooks/index.ts +0 -10
- package/src/views/CanvasEditor/hooks/useHeroBlock.d.ts +0 -8
- package/src/views/CanvasEditor/hooks/useHeroBlock.d.ts.map +0 -1
- package/src/views/CanvasEditor/hooks/useHeroBlock.js +0 -79
- package/src/views/CanvasEditor/hooks/useHeroBlock.ts +0 -103
- package/src/views/CanvasEditor/hooks/useKeyboardShortcuts.d.ts +0 -3
- package/src/views/CanvasEditor/hooks/useKeyboardShortcuts.d.ts.map +0 -1
- package/src/views/CanvasEditor/hooks/useKeyboardShortcuts.js +0 -114
- package/src/views/CanvasEditor/hooks/useKeyboardShortcuts.ts +0 -142
- package/src/views/CanvasEditor/hooks/usePostLoader.d.ts +0 -5
- package/src/views/CanvasEditor/hooks/usePostLoader.d.ts.map +0 -1
- package/src/views/CanvasEditor/hooks/usePostLoader.js +0 -32
- package/src/views/CanvasEditor/hooks/usePostLoader.ts +0 -39
- package/src/views/CanvasEditor/hooks/useRegisteredBlocks.d.ts +0 -2
- package/src/views/CanvasEditor/hooks/useRegisteredBlocks.d.ts.map +0 -1
- package/src/views/CanvasEditor/hooks/useRegisteredBlocks.js +0 -47
- package/src/views/CanvasEditor/hooks/useRegisteredBlocks.ts +0 -55
- package/src/views/CanvasEditor/hooks/useUnsavedChanges.d.ts +0 -25
- package/src/views/CanvasEditor/hooks/useUnsavedChanges.d.ts.map +0 -1
- package/src/views/CanvasEditor/hooks/useUnsavedChanges.js +0 -285
- package/src/views/CanvasEditor/hooks/useUnsavedChanges.ts +0 -339
- package/src/views/CanvasEditor/index.d.ts +0 -16
- package/src/views/CanvasEditor/index.d.ts.map +0 -1
- package/src/views/CanvasEditor/index.js +0 -9
- package/src/views/CanvasEditor/index.ts +0 -16
- package/src/views/PostManager/EmptyState.d.ts +0 -10
- package/src/views/PostManager/EmptyState.d.ts.map +0 -1
- package/src/views/PostManager/EmptyState.js +0 -12
- package/src/views/PostManager/EmptyState.tsx +0 -42
- package/src/views/PostManager/PostActionsMenu.d.ts +0 -12
- package/src/views/PostManager/PostActionsMenu.d.ts.map +0 -1
- package/src/views/PostManager/PostActionsMenu.js +0 -58
- package/src/views/PostManager/PostActionsMenu.tsx +0 -112
- package/src/views/PostManager/PostCards.d.ts +0 -15
- package/src/views/PostManager/PostCards.d.ts.map +0 -1
- package/src/views/PostManager/PostCards.js +0 -79
- package/src/views/PostManager/PostCards.tsx +0 -197
- package/src/views/PostManager/PostFilters.d.ts +0 -16
- package/src/views/PostManager/PostFilters.d.ts.map +0 -1
- package/src/views/PostManager/PostFilters.js +0 -10
- package/src/views/PostManager/PostFilters.tsx +0 -95
- package/src/views/PostManager/PostManagerView.d.ts +0 -11
- package/src/views/PostManager/PostManagerView.d.ts.map +0 -1
- package/src/views/PostManager/PostManagerView.js +0 -174
- package/src/views/PostManager/PostManagerView.tsx +0 -289
- package/src/views/PostManager/PostStats.d.ts +0 -11
- package/src/views/PostManager/PostStats.d.ts.map +0 -1
- package/src/views/PostManager/PostStats.js +0 -46
- package/src/views/PostManager/PostStats.tsx +0 -81
- package/src/views/PostManager/PostTable.d.ts +0 -15
- package/src/views/PostManager/PostTable.d.ts.map +0 -1
- package/src/views/PostManager/PostTable.js +0 -79
- package/src/views/PostManager/PostTable.tsx +0 -230
- package/src/views/PostManager/index.d.ts +0 -12
- package/src/views/PostManager/index.d.ts.map +0 -1
- package/src/views/PostManager/index.js +0 -11
- package/src/views/PostManager/index.ts +0 -15
- package/src/views/Preview/PreviewBridgeView.d.ts +0 -12
- package/src/views/Preview/PreviewBridgeView.d.ts.map +0 -1
- package/src/views/Preview/PreviewBridgeView.js +0 -11
- package/src/views/Preview/PreviewBridgeView.tsx +0 -64
- package/src/views/Preview/index.d.ts +0 -6
- package/src/views/Preview/index.d.ts.map +0 -1
- package/src/views/Preview/index.js +0 -4
- package/src/views/Preview/index.ts +0 -7
- package/src/views/Settings/SettingsView.d.ts +0 -10
- package/src/views/Settings/SettingsView.d.ts.map +0 -1
- package/src/views/Settings/SettingsView.js +0 -111
- package/src/views/Settings/SettingsView.tsx +0 -298
- package/src/views/Settings/index.d.ts +0 -6
- package/src/views/Settings/index.d.ts.map +0 -1
- package/src/views/Settings/index.js +0 -4
- package/src/views/Settings/index.ts +0 -7
- package/src/views/SlugSEO/SlugSEOManagerView.d.ts +0 -12
- package/src/views/SlugSEO/SlugSEOManagerView.d.ts.map +0 -1
- package/src/views/SlugSEO/SlugSEOManagerView.js +0 -11
- package/src/views/SlugSEO/SlugSEOManagerView.tsx +0 -94
- package/src/views/SlugSEO/index.d.ts +0 -6
- package/src/views/SlugSEO/index.d.ts.map +0 -1
- package/src/views/SlugSEO/index.js +0 -4
- package/src/views/SlugSEO/index.ts +0 -7
|
@@ -1,322 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Layout Container Component
|
|
3
|
-
* Recursive drop zone for nested blocks
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
'use client';
|
|
7
|
-
|
|
8
|
-
import React, { useState, useEffect, useRef } from 'react';
|
|
9
|
-
import { Plus } from 'lucide-react';
|
|
10
|
-
import { Block } from '../../types/block';
|
|
11
|
-
import { BlockWrapper } from './BlockWrapper';
|
|
12
|
-
import { useEditor } from '../../state/EditorContext';
|
|
13
|
-
|
|
14
|
-
export interface LayoutContainerProps {
|
|
15
|
-
blocks: Block[];
|
|
16
|
-
containerId: string;
|
|
17
|
-
onBlockAdd: (type: string, index: number, containerId: string) => void;
|
|
18
|
-
onBlockUpdate: (id: string, data: Partial<Block['data']>, containerId: string) => void;
|
|
19
|
-
onBlockDelete: (id: string, containerId: string) => void;
|
|
20
|
-
onBlockMove: (id: string, newIndex: number, containerId: string) => void;
|
|
21
|
-
className?: string;
|
|
22
|
-
emptyLabel?: string;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export function LayoutContainer({
|
|
26
|
-
blocks,
|
|
27
|
-
containerId,
|
|
28
|
-
onBlockAdd,
|
|
29
|
-
onBlockUpdate,
|
|
30
|
-
onBlockDelete,
|
|
31
|
-
onBlockMove,
|
|
32
|
-
className = '',
|
|
33
|
-
emptyLabel = 'Drop blocks here',
|
|
34
|
-
}: LayoutContainerProps) {
|
|
35
|
-
const { darkMode } = useEditor();
|
|
36
|
-
|
|
37
|
-
// --- State ---
|
|
38
|
-
const [dragOverIndex, setDragOverIndex] = useState<number | null>(null);
|
|
39
|
-
const [dropAtEnd, setDropAtEnd] = useState(false);
|
|
40
|
-
const [isDragging, setIsDragging] = useState(false);
|
|
41
|
-
const [dropIndicatorPosition, setDropIndicatorPosition] = useState<{ top: number; left: number; width: number } | null>(null);
|
|
42
|
-
|
|
43
|
-
const containerRef = useRef<HTMLDivElement>(null);
|
|
44
|
-
const blockRefs = useRef<Map<string, HTMLDivElement>>(new Map());
|
|
45
|
-
// Use ref to ensure we always have the latest dropAtEnd value (React state updates are async)
|
|
46
|
-
const dropAtEndRef = useRef(false);
|
|
47
|
-
|
|
48
|
-
// --- Cleanup & Event Listeners ---
|
|
49
|
-
useEffect(() => {
|
|
50
|
-
const resetState = () => {
|
|
51
|
-
setDropIndicatorPosition(null);
|
|
52
|
-
setDragOverIndex(null);
|
|
53
|
-
setDropAtEnd(false);
|
|
54
|
-
dropAtEndRef.current = false; // Reset ref too
|
|
55
|
-
setIsDragging(false);
|
|
56
|
-
// Clear global dragged block ID on dragend (in case drag was cancelled)
|
|
57
|
-
if (typeof window !== 'undefined') {
|
|
58
|
-
(window as any).__DRAGGED_BLOCK_ID__ = null;
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
const container = containerRef.current;
|
|
63
|
-
if (container) {
|
|
64
|
-
container.addEventListener('clear-drop-indicator', resetState);
|
|
65
|
-
document.addEventListener('dragend', resetState);
|
|
66
|
-
return () => {
|
|
67
|
-
container.removeEventListener('clear-drop-indicator', resetState);
|
|
68
|
-
document.removeEventListener('dragend', resetState);
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
}, []);
|
|
72
|
-
|
|
73
|
-
// --- Drag & Drop Logic ---
|
|
74
|
-
|
|
75
|
-
const handleDragOverBlock = (e: React.DragEvent, index: number, element: HTMLElement) => {
|
|
76
|
-
e.preventDefault();
|
|
77
|
-
e.stopPropagation();
|
|
78
|
-
|
|
79
|
-
// 1. Check for deeper nested containers
|
|
80
|
-
const target = e.target as HTMLElement;
|
|
81
|
-
const deeperContainer = target.closest('[data-layout-container]');
|
|
82
|
-
if (deeperContainer && deeperContainer !== containerRef.current) {
|
|
83
|
-
setDropIndicatorPosition(null);
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
// 2. Notify parent containers to hide their indicators
|
|
88
|
-
e.currentTarget.dispatchEvent(new CustomEvent('clear-drop-indicator', { bubbles: true }));
|
|
89
|
-
|
|
90
|
-
// 3. Calculate "Above" vs "Below" and position indicator between blocks
|
|
91
|
-
const containerRect = containerRef.current!.getBoundingClientRect();
|
|
92
|
-
const elementRect = element.getBoundingClientRect();
|
|
93
|
-
const mouseRelativeToBlock = e.clientY - elementRect.top;
|
|
94
|
-
const isBottomHalf = mouseRelativeToBlock > (elementRect.height / 2);
|
|
95
|
-
|
|
96
|
-
setDragOverIndex(index);
|
|
97
|
-
setDropAtEnd(isBottomHalf);
|
|
98
|
-
dropAtEndRef.current = isBottomHalf; // Update ref immediately
|
|
99
|
-
setIsDragging(true);
|
|
100
|
-
|
|
101
|
-
// 4. Update Visual Indicator - always show between blocks
|
|
102
|
-
const elementTop = elementRect.top - containerRect.top;
|
|
103
|
-
const elementBottom = elementRect.bottom - containerRect.top;
|
|
104
|
-
let indicatorTop: number;
|
|
105
|
-
|
|
106
|
-
if (isBottomHalf) {
|
|
107
|
-
// Show below this block - position between current block and next block
|
|
108
|
-
if (index === blocks.length - 1) {
|
|
109
|
-
// Last block - show after it
|
|
110
|
-
indicatorTop = elementBottom;
|
|
111
|
-
} else {
|
|
112
|
-
// Get next block to find the gap
|
|
113
|
-
const nextBlock = blocks[index + 1];
|
|
114
|
-
const nextBlockEl = blockRefs.current.get(nextBlock.id);
|
|
115
|
-
if (nextBlockEl) {
|
|
116
|
-
const nextBlockRect = nextBlockEl.getBoundingClientRect();
|
|
117
|
-
const nextBlockTop = nextBlockRect.top - containerRect.top;
|
|
118
|
-
// Position in the middle of the gap (mb-4 = 16px margin)
|
|
119
|
-
indicatorTop = elementBottom + (nextBlockTop - elementBottom) / 2;
|
|
120
|
-
} else {
|
|
121
|
-
indicatorTop = elementBottom;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
} else {
|
|
125
|
-
// Show above this block - position between previous block and current block
|
|
126
|
-
if (index === 0) {
|
|
127
|
-
// First block - show at top of container (before first block)
|
|
128
|
-
indicatorTop = 0;
|
|
129
|
-
} else {
|
|
130
|
-
// Get previous block to find the gap
|
|
131
|
-
const prevBlock = blocks[index - 1];
|
|
132
|
-
const prevBlockEl = blockRefs.current.get(prevBlock.id);
|
|
133
|
-
if (prevBlockEl) {
|
|
134
|
-
const prevBlockRect = prevBlockEl.getBoundingClientRect();
|
|
135
|
-
const prevBlockBottom = prevBlockRect.bottom - containerRect.top;
|
|
136
|
-
// Position in the middle of the gap (mb-4 = 16px margin)
|
|
137
|
-
indicatorTop = prevBlockBottom + (elementTop - prevBlockBottom) / 2;
|
|
138
|
-
} else {
|
|
139
|
-
indicatorTop = elementTop;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
setDropIndicatorPosition({
|
|
145
|
-
top: indicatorTop,
|
|
146
|
-
left: 0,
|
|
147
|
-
width: containerRect.width,
|
|
148
|
-
});
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
const handleDrop = (e: React.DragEvent, index: number | null) => {
|
|
152
|
-
e.preventDefault();
|
|
153
|
-
e.stopPropagation();
|
|
154
|
-
|
|
155
|
-
const blockId = e.dataTransfer.getData('block-id') || (window as any).__DRAGGED_BLOCK_ID__;
|
|
156
|
-
const blockType = e.dataTransfer.getData('block-type');
|
|
157
|
-
|
|
158
|
-
// Clear the global dragged block ID immediately to prevent it from being used for new blocks
|
|
159
|
-
if (typeof window !== 'undefined') {
|
|
160
|
-
(window as any).__DRAGGED_BLOCK_ID__ = null;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
// Logic: index is null when dropping on the container background (appends to end)
|
|
164
|
-
// When dropAtEnd is true, we want to place it AFTER the block at index, so targetIndex = index + 1
|
|
165
|
-
// When dropAtEnd is false, we want to place it BEFORE the block at index, so targetIndex = index
|
|
166
|
-
// Use ref to get the latest value (React state updates are async)
|
|
167
|
-
const isDropAtEnd = dropAtEndRef.current;
|
|
168
|
-
let targetIndex = index === null ? blocks.length : (isDropAtEnd ? index + 1 : index);
|
|
169
|
-
|
|
170
|
-
if (blockId) {
|
|
171
|
-
const currentIndex = blocks.findIndex(b => b.id === blockId);
|
|
172
|
-
if (currentIndex !== -1) {
|
|
173
|
-
// Moving within the same array - need to adjust for removal
|
|
174
|
-
let finalMoveIndex = targetIndex;
|
|
175
|
-
|
|
176
|
-
if (currentIndex < targetIndex) {
|
|
177
|
-
// Moving forward: when we remove the item from currentIndex, everything after it shifts down by 1.
|
|
178
|
-
if (isDropAtEnd) {
|
|
179
|
-
// Dropping below: we want it at index + 1 in the original array
|
|
180
|
-
// If currentIndex <= index: after removal, block at index stays at index, so we want index + 1 = targetIndex
|
|
181
|
-
// If index < currentIndex < targetIndex: after removal, we still want index + 1, but since we removed
|
|
182
|
-
// an item before targetIndex, the position targetIndex in original = targetIndex - 1 in new array
|
|
183
|
-
if (index !== null && currentIndex <= index) {
|
|
184
|
-
// Item is at or before target block - no adjustment needed
|
|
185
|
-
finalMoveIndex = targetIndex;
|
|
186
|
-
} else {
|
|
187
|
-
// Item is after target block but before targetIndex - need to adjust
|
|
188
|
-
finalMoveIndex = targetIndex - 1;
|
|
189
|
-
}
|
|
190
|
-
} else {
|
|
191
|
-
// Dropping above: targetIndex = index means "before the block at index"
|
|
192
|
-
// After removal, if currentIndex < index, the block at index shifts to index - 1,
|
|
193
|
-
// so we want it at index - 1 in the new array.
|
|
194
|
-
finalMoveIndex = targetIndex - 1;
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
// If currentIndex >= targetIndex, no adjustment needed (moving backward or same position)
|
|
198
|
-
|
|
199
|
-
console.log('[LayoutContainer] Drop calculation:', {
|
|
200
|
-
blockId,
|
|
201
|
-
index,
|
|
202
|
-
dropAtEnd: isDropAtEnd,
|
|
203
|
-
currentIndex,
|
|
204
|
-
targetIndex,
|
|
205
|
-
finalMoveIndex,
|
|
206
|
-
blocksCount: blocks.length
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
onBlockMove(blockId, Math.max(0, finalMoveIndex), containerId);
|
|
210
|
-
} else {
|
|
211
|
-
// Moving from another container - no adjustment needed
|
|
212
|
-
onBlockMove(blockId, targetIndex, containerId);
|
|
213
|
-
}
|
|
214
|
-
} else if (blockType) {
|
|
215
|
-
// Adding new block - use targetIndex as-is
|
|
216
|
-
onBlockAdd(blockType, targetIndex, containerId);
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
// Clean up
|
|
220
|
-
setDropIndicatorPosition(null);
|
|
221
|
-
setDragOverIndex(null);
|
|
222
|
-
setDropAtEnd(false);
|
|
223
|
-
};
|
|
224
|
-
|
|
225
|
-
const setBlockRef = (id: string) => (el: HTMLDivElement | null) => {
|
|
226
|
-
if (el) blockRefs.current.set(id, el); else blockRefs.current.delete(id);
|
|
227
|
-
};
|
|
228
|
-
|
|
229
|
-
return (
|
|
230
|
-
<div
|
|
231
|
-
ref={containerRef}
|
|
232
|
-
data-layout-container={containerId}
|
|
233
|
-
className={`relative flex flex-col min-h-[40px] transition-colors ${className}`}
|
|
234
|
-
onDragOver={(e) => { e.preventDefault(); setIsDragging(true); }}
|
|
235
|
-
onDrop={(e) => handleDrop(e, null)}
|
|
236
|
-
onDragLeave={(e) => {
|
|
237
|
-
if (!e.currentTarget.contains(e.relatedTarget as Node)) {
|
|
238
|
-
setDropIndicatorPosition(null);
|
|
239
|
-
}
|
|
240
|
-
}}
|
|
241
|
-
>
|
|
242
|
-
{/* 1. Visual Indicator Overlay */}
|
|
243
|
-
{dropIndicatorPosition && isDragging && (
|
|
244
|
-
<DropIndicator position={dropIndicatorPosition} darkMode={darkMode} />
|
|
245
|
-
)}
|
|
246
|
-
|
|
247
|
-
{/* 2. Content Area */}
|
|
248
|
-
{blocks.length === 0 ? (
|
|
249
|
-
<EmptyState isDragging={isDragging} darkMode={darkMode} label={emptyLabel} />
|
|
250
|
-
) : (
|
|
251
|
-
blocks.map((block, index) => (
|
|
252
|
-
<div
|
|
253
|
-
key={block.id}
|
|
254
|
-
ref={setBlockRef(block.id)}
|
|
255
|
-
onDragOver={(e) => handleDragOverBlock(e, index, blockRefs.current.get(block.id)!)}
|
|
256
|
-
onDrop={(e) => handleDrop(e, index)}
|
|
257
|
-
className="relative mb-4 last:mb-0"
|
|
258
|
-
>
|
|
259
|
-
<BlockWrapper
|
|
260
|
-
block={block}
|
|
261
|
-
onUpdate={(data) => onBlockUpdate(block.id, data, containerId)}
|
|
262
|
-
onDelete={() => onBlockDelete(block.id, containerId)}
|
|
263
|
-
onMoveUp={index > 0 ? () => onBlockMove(block.id, index - 1, containerId) : undefined}
|
|
264
|
-
onMoveDown={index < blocks.length - 1 ? () => onBlockMove(block.id, index + 1, containerId) : undefined}
|
|
265
|
-
/>
|
|
266
|
-
</div>
|
|
267
|
-
))
|
|
268
|
-
)}
|
|
269
|
-
</div>
|
|
270
|
-
);
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
/**
|
|
274
|
-
* Visual Line that shows where the block will land
|
|
275
|
-
*/
|
|
276
|
-
function DropIndicator({ position, darkMode }: { position: any; darkMode: boolean }) {
|
|
277
|
-
return (
|
|
278
|
-
<div
|
|
279
|
-
className="absolute z-50 pointer-events-none"
|
|
280
|
-
style={{
|
|
281
|
-
top: `${position.top - 12}px`,
|
|
282
|
-
left: `${position.left}px`,
|
|
283
|
-
width: `${position.width}px`,
|
|
284
|
-
height: '24px',
|
|
285
|
-
}}
|
|
286
|
-
>
|
|
287
|
-
<div className={`absolute inset-0 rounded-lg border border-dashed backdrop-blur-sm
|
|
288
|
-
${darkMode ? 'bg-primary/20 border-primary/40' : 'bg-primary/10 border-primary/30'}`}
|
|
289
|
-
/>
|
|
290
|
-
<div className={`absolute top-1/2 left-0 right-0 h-0.5 transform -translate-y-1/2
|
|
291
|
-
${darkMode ? 'bg-primary' : 'bg-primary'}`}
|
|
292
|
-
/>
|
|
293
|
-
<div className="absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2">
|
|
294
|
-
<div className="w-6 h-6 rounded-full flex items-center justify-center bg-primary shadow-lg">
|
|
295
|
-
<div className="w-2 h-2 rounded-full bg-white" />
|
|
296
|
-
</div>
|
|
297
|
-
</div>
|
|
298
|
-
</div>
|
|
299
|
-
);
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
/**
|
|
303
|
-
* Placeholder when the container is empty
|
|
304
|
-
*/
|
|
305
|
-
function EmptyState({ isDragging, darkMode, label }: { isDragging: boolean; darkMode: boolean; label: string }) {
|
|
306
|
-
return (
|
|
307
|
-
<div className={`flex flex-col items-center justify-center py-12 px-6 rounded-2xl border border-dashed transition-all
|
|
308
|
-
${darkMode
|
|
309
|
-
? isDragging ? 'border-primary/50 bg-primary/10' : 'border-neutral-700 bg-neutral-800/20'
|
|
310
|
-
: isDragging ? 'border-primary/50 bg-primary/5' : 'border-neutral-200 bg-neutral-50/30'
|
|
311
|
-
}`}
|
|
312
|
-
>
|
|
313
|
-
<div className={`p-3 rounded-full mb-3 ${darkMode ? 'bg-neutral-800' : 'bg-neutral-100'}`}>
|
|
314
|
-
<Plus size={20} className={isDragging ? 'text-primary' : 'text-neutral-400'} />
|
|
315
|
-
</div>
|
|
316
|
-
<p className={`text-xs font-black uppercase tracking-wider
|
|
317
|
-
${isDragging ? 'text-primary' : 'text-neutral-500'}`}>
|
|
318
|
-
{isDragging ? 'Drop Block Here' : label}
|
|
319
|
-
</p>
|
|
320
|
-
</div>
|
|
321
|
-
);
|
|
322
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
export interface SaveConfirmationModalProps {
|
|
3
|
-
isOpen: boolean;
|
|
4
|
-
onClose: () => void;
|
|
5
|
-
onConfirm: () => Promise<void>;
|
|
6
|
-
isSaving: boolean;
|
|
7
|
-
postTitle?: string;
|
|
8
|
-
isPublished?: boolean;
|
|
9
|
-
saveAsDraft?: boolean;
|
|
10
|
-
error?: string | null;
|
|
11
|
-
}
|
|
12
|
-
export declare function SaveConfirmationModal({ isOpen, onClose, onConfirm, isSaving, postTitle, isPublished, saveAsDraft, error, }: SaveConfirmationModalProps): React.ReactPortal | null;
|
|
13
|
-
//# sourceMappingURL=SaveConfirmationModal.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SaveConfirmationModal.d.ts","sourceRoot":"","sources":["SaveConfirmationModal.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAKnD,MAAM,WAAW,0BAA0B;IACvC,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,SAAS,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/B,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AAED,wBAAgB,qBAAqB,CAAC,EAClC,MAAM,EACN,OAAO,EACP,SAAS,EACT,QAAQ,EACR,SAAS,EACT,WAAW,EACX,WAAmB,EACnB,KAAK,GACR,EAAE,0BAA0B,4BA4M5B"}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
-
import { useEffect, useState } from 'react';
|
|
4
|
-
import { createPortal } from 'react-dom';
|
|
5
|
-
import { X, AlertTriangle, CheckCircle2 } from 'lucide-react';
|
|
6
|
-
import { motion, AnimatePresence } from 'framer-motion';
|
|
7
|
-
export function SaveConfirmationModal({ isOpen, onClose, onConfirm, isSaving, postTitle, isPublished, saveAsDraft = false, error, }) {
|
|
8
|
-
const [mounted, setMounted] = useState(false);
|
|
9
|
-
const [showSuccess, setShowSuccess] = useState(false);
|
|
10
|
-
const [saveError, setSaveError] = useState(null);
|
|
11
|
-
useEffect(() => {
|
|
12
|
-
setMounted(true);
|
|
13
|
-
}, []);
|
|
14
|
-
// Reset states when modal opens
|
|
15
|
-
useEffect(() => {
|
|
16
|
-
if (isOpen) {
|
|
17
|
-
setShowSuccess(false);
|
|
18
|
-
setSaveError(null);
|
|
19
|
-
}
|
|
20
|
-
}, [isOpen]);
|
|
21
|
-
// Update error state when error prop changes
|
|
22
|
-
useEffect(() => {
|
|
23
|
-
if (error) {
|
|
24
|
-
setSaveError(error);
|
|
25
|
-
setShowSuccess(false);
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
setSaveError(null);
|
|
29
|
-
}
|
|
30
|
-
}, [error]);
|
|
31
|
-
if (!mounted)
|
|
32
|
-
return null;
|
|
33
|
-
const handleConfirm = async () => {
|
|
34
|
-
// Clear any previous errors
|
|
35
|
-
setSaveError(null);
|
|
36
|
-
try {
|
|
37
|
-
await onConfirm();
|
|
38
|
-
// Only show success if onConfirm completes without error
|
|
39
|
-
setShowSuccess(true);
|
|
40
|
-
// Close modal after showing success for 1.5 seconds
|
|
41
|
-
setTimeout(() => {
|
|
42
|
-
onClose();
|
|
43
|
-
setShowSuccess(false);
|
|
44
|
-
setSaveError(null);
|
|
45
|
-
}, 1500);
|
|
46
|
-
}
|
|
47
|
-
catch (error) {
|
|
48
|
-
// Display error in modal
|
|
49
|
-
const errorMessage = error.message || 'Failed to save post. Please try again.';
|
|
50
|
-
setSaveError(errorMessage);
|
|
51
|
-
console.error('[SaveConfirmationModal] Save failed:', error);
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
const modalContent = (_jsx(AnimatePresence, { children: isOpen && (_jsxs("div", { className: "fixed inset-0 z-[9999] flex items-center justify-center p-4", children: [_jsx(motion.div, { initial: { opacity: 0 }, animate: { opacity: 1 }, exit: { opacity: 0 }, onClick: onClose, className: "absolute inset-0 bg-black/60 backdrop-blur-md" }), _jsxs(motion.div, { initial: { scale: 0.9, opacity: 0, y: 20 }, animate: { scale: 1, opacity: 1, y: 0 }, exit: { scale: 0.9, opacity: 0, y: 20 }, onClick: (e) => e.stopPropagation(), className: "relative w-full font-sans max-w-md bg-dashboard-card rounded-[2.5rem] p-8 shadow-2xl border border-dashboard-border", children: [_jsx("button", { onClick: onClose, disabled: isSaving, className: "absolute top-6 right-6 text-neutral-400 hover:text-neutral-900 dark:hover:text-white transition-colors disabled:opacity-50 disabled:cursor-not-allowed", children: _jsx(X, { size: 24 }) }), _jsx("div", { className: `w-16 h-16 rounded-full flex items-center justify-center mx-auto mb-6 transition-all ${saveError
|
|
55
|
-
? 'bg-red-100 dark:bg-red-900/20'
|
|
56
|
-
: showSuccess
|
|
57
|
-
? 'bg-green-100 dark:bg-green-900/20'
|
|
58
|
-
: 'bg-amber-100 dark:bg-amber-900/20'}`, children: saveError ? (_jsx(AlertTriangle, { size: 32, className: "text-red-600 dark:text-red-400" })) : showSuccess ? (_jsx(CheckCircle2, { size: 32, className: "text-green-600 dark:text-green-400" })) : (_jsx(AlertTriangle, { size: 32, className: "text-amber-600 dark:text-amber-400" })) }), _jsx("h3", { className: "text-2xl font-black text-center mb-4 text-neutral-950 dark:text-white", children: saveError
|
|
59
|
-
? 'Error'
|
|
60
|
-
: showSuccess
|
|
61
|
-
? 'Success!'
|
|
62
|
-
: saveAsDraft
|
|
63
|
-
? 'Save Draft'
|
|
64
|
-
: `Confirm ${isPublished ? 'Update' : 'Publish'}` }), _jsx("div", { className: "text-center mb-8", children: saveError ? (_jsxs("div", { className: "space-y-3", children: [_jsx("p", { className: "text-red-700 dark:text-red-300 font-semibold", children: saveError }), _jsx("p", { className: "text-sm text-neutral-600 dark:text-neutral-400", children: "Please fix the issues above and try again." })] })) : showSuccess ? (_jsx("p", { className: "text-green-700 dark:text-green-300 font-semibold", children: saveAsDraft ? 'Draft saved successfully!' : 'Post saved successfully!' })) : (_jsxs(_Fragment, { children: [_jsx("p", { className: "text-neutral-700 dark:text-neutral-300 mb-2", children: saveAsDraft
|
|
65
|
-
? 'Save this post as a draft? You can continue editing and publish it later.'
|
|
66
|
-
: isPublished
|
|
67
|
-
? 'You are about to update this post. Changes cannot be undone.'
|
|
68
|
-
: 'You are about to publish this post. This action cannot be undone.' }), postTitle && (_jsxs("p", { className: "text-sm text-neutral-500 dark:text-neutral-400 italic", children: ["\"", postTitle, "\""] }))] })) }), showSuccess ? (_jsx("div", { className: "flex justify-center", children: _jsx("button", { onClick: onClose, className: "px-6 py-3 rounded-full bg-green-600 text-white font-bold uppercase text-[10px] tracking-widest transition-all hover:bg-green-700 shadow-lg shadow-green-600/20", children: "Close" }) })) : saveError ? (_jsxs("div", { className: "flex gap-4", children: [_jsx("button", { onClick: onClose, className: "flex-1 px-6 py-3 rounded-full border-2 border-dashboard-border text-dashboard-text font-bold uppercase text-[10px] tracking-widest transition-all hover:bg-dashboard-bg", children: "Close" }), _jsx("button", { onClick: handleConfirm, disabled: isSaving, className: "flex-1 px-6 py-3 rounded-full bg-primary text-white font-bold uppercase text-[10px] tracking-widest transition-all hover:bg-primary/90 disabled:opacity-50 disabled:cursor-not-allowed shadow-lg shadow-primary/20", children: isSaving
|
|
69
|
-
? 'Retrying...'
|
|
70
|
-
: 'Try Again' })] })) : (_jsxs("div", { className: "flex gap-4", children: [_jsx("button", { onClick: onClose, disabled: isSaving, className: "flex-1 px-6 py-3 rounded-full border-2 border-dashboard-border text-dashboard-text font-bold uppercase text-[10px] tracking-widest transition-all hover:bg-dashboard-bg disabled:opacity-50 disabled:cursor-not-allowed", children: "Cancel" }), _jsx("button", { onClick: handleConfirm, disabled: isSaving, className: "flex-1 px-6 py-3 rounded-full bg-primary text-white font-bold uppercase text-[10px] tracking-widest transition-all hover:bg-primary/90 disabled:opacity-50 disabled:cursor-not-allowed shadow-lg shadow-primary/20", children: isSaving
|
|
71
|
-
? 'Saving...'
|
|
72
|
-
: saveAsDraft
|
|
73
|
-
? 'Save Draft'
|
|
74
|
-
: isPublished
|
|
75
|
-
? 'Update Post'
|
|
76
|
-
: 'Publish Post' })] }))] })] })) }));
|
|
77
|
-
return createPortal(modalContent, document.body);
|
|
78
|
-
}
|
|
@@ -1,233 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import React, { useEffect, useState } from 'react';
|
|
4
|
-
import { createPortal } from 'react-dom';
|
|
5
|
-
import { X, AlertTriangle, CheckCircle2 } from 'lucide-react';
|
|
6
|
-
import { motion, AnimatePresence } from 'framer-motion';
|
|
7
|
-
|
|
8
|
-
export interface SaveConfirmationModalProps {
|
|
9
|
-
isOpen: boolean;
|
|
10
|
-
onClose: () => void;
|
|
11
|
-
onConfirm: () => Promise<void>;
|
|
12
|
-
isSaving: boolean;
|
|
13
|
-
postTitle?: string;
|
|
14
|
-
isPublished?: boolean;
|
|
15
|
-
saveAsDraft?: boolean;
|
|
16
|
-
error?: string | null;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export function SaveConfirmationModal({
|
|
20
|
-
isOpen,
|
|
21
|
-
onClose,
|
|
22
|
-
onConfirm,
|
|
23
|
-
isSaving,
|
|
24
|
-
postTitle,
|
|
25
|
-
isPublished,
|
|
26
|
-
saveAsDraft = false,
|
|
27
|
-
error,
|
|
28
|
-
}: SaveConfirmationModalProps) {
|
|
29
|
-
const [mounted, setMounted] = useState(false);
|
|
30
|
-
const [showSuccess, setShowSuccess] = useState(false);
|
|
31
|
-
const [saveError, setSaveError] = useState<string | null>(null);
|
|
32
|
-
|
|
33
|
-
useEffect(() => {
|
|
34
|
-
setMounted(true);
|
|
35
|
-
}, []);
|
|
36
|
-
|
|
37
|
-
// Reset states when modal opens
|
|
38
|
-
useEffect(() => {
|
|
39
|
-
if (isOpen) {
|
|
40
|
-
setShowSuccess(false);
|
|
41
|
-
setSaveError(null);
|
|
42
|
-
}
|
|
43
|
-
}, [isOpen]);
|
|
44
|
-
|
|
45
|
-
// Update error state when error prop changes
|
|
46
|
-
useEffect(() => {
|
|
47
|
-
if (error) {
|
|
48
|
-
setSaveError(error);
|
|
49
|
-
setShowSuccess(false);
|
|
50
|
-
} else {
|
|
51
|
-
setSaveError(null);
|
|
52
|
-
}
|
|
53
|
-
}, [error]);
|
|
54
|
-
|
|
55
|
-
if (!mounted) return null;
|
|
56
|
-
|
|
57
|
-
const handleConfirm = async () => {
|
|
58
|
-
// Clear any previous errors
|
|
59
|
-
setSaveError(null);
|
|
60
|
-
try {
|
|
61
|
-
await onConfirm();
|
|
62
|
-
// Only show success if onConfirm completes without error
|
|
63
|
-
setShowSuccess(true);
|
|
64
|
-
// Close modal after showing success for 1.5 seconds
|
|
65
|
-
setTimeout(() => {
|
|
66
|
-
onClose();
|
|
67
|
-
setShowSuccess(false);
|
|
68
|
-
setSaveError(null);
|
|
69
|
-
}, 1500);
|
|
70
|
-
} catch (error: any) {
|
|
71
|
-
// Display error in modal
|
|
72
|
-
const errorMessage = error.message || 'Failed to save post. Please try again.';
|
|
73
|
-
setSaveError(errorMessage);
|
|
74
|
-
console.error('[SaveConfirmationModal] Save failed:', error);
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
const modalContent = (
|
|
79
|
-
<AnimatePresence>
|
|
80
|
-
{isOpen && (
|
|
81
|
-
<div className="fixed inset-0 z-[9999] flex items-center justify-center p-4">
|
|
82
|
-
{/* Backdrop */}
|
|
83
|
-
<motion.div
|
|
84
|
-
initial={{ opacity: 0 }}
|
|
85
|
-
animate={{ opacity: 1 }}
|
|
86
|
-
exit={{ opacity: 0 }}
|
|
87
|
-
onClick={onClose}
|
|
88
|
-
className="absolute inset-0 bg-black/60 backdrop-blur-md"
|
|
89
|
-
/>
|
|
90
|
-
|
|
91
|
-
{/* Modal */}
|
|
92
|
-
<motion.div
|
|
93
|
-
initial={{ scale: 0.9, opacity: 0, y: 20 }}
|
|
94
|
-
animate={{ scale: 1, opacity: 1, y: 0 }}
|
|
95
|
-
exit={{ scale: 0.9, opacity: 0, y: 20 }}
|
|
96
|
-
onClick={(e) => e.stopPropagation()}
|
|
97
|
-
className="relative w-full font-sans max-w-md bg-dashboard-card rounded-[2.5rem] p-8 shadow-2xl border border-dashboard-border"
|
|
98
|
-
>
|
|
99
|
-
{/* Close Button */}
|
|
100
|
-
<button
|
|
101
|
-
onClick={onClose}
|
|
102
|
-
disabled={isSaving}
|
|
103
|
-
className="absolute top-6 right-6 text-neutral-400 hover:text-neutral-900 dark:hover:text-white transition-colors disabled:opacity-50 disabled:cursor-not-allowed"
|
|
104
|
-
>
|
|
105
|
-
<X size={24} />
|
|
106
|
-
</button>
|
|
107
|
-
|
|
108
|
-
{/* Icon */}
|
|
109
|
-
<div className={`w-16 h-16 rounded-full flex items-center justify-center mx-auto mb-6 transition-all ${
|
|
110
|
-
saveError
|
|
111
|
-
? 'bg-red-100 dark:bg-red-900/20'
|
|
112
|
-
: showSuccess
|
|
113
|
-
? 'bg-green-100 dark:bg-green-900/20'
|
|
114
|
-
: 'bg-amber-100 dark:bg-amber-900/20'
|
|
115
|
-
}`}>
|
|
116
|
-
{saveError ? (
|
|
117
|
-
<AlertTriangle size={32} className="text-red-600 dark:text-red-400" />
|
|
118
|
-
) : showSuccess ? (
|
|
119
|
-
<CheckCircle2 size={32} className="text-green-600 dark:text-green-400" />
|
|
120
|
-
) : (
|
|
121
|
-
<AlertTriangle size={32} className="text-amber-600 dark:text-amber-400" />
|
|
122
|
-
)}
|
|
123
|
-
</div>
|
|
124
|
-
|
|
125
|
-
{/* Title */}
|
|
126
|
-
<h3 className="text-2xl font-black text-center mb-4 text-neutral-950 dark:text-white">
|
|
127
|
-
{saveError
|
|
128
|
-
? 'Error'
|
|
129
|
-
: showSuccess
|
|
130
|
-
? 'Success!'
|
|
131
|
-
: saveAsDraft
|
|
132
|
-
? 'Save Draft'
|
|
133
|
-
: `Confirm ${isPublished ? 'Update' : 'Publish'}`
|
|
134
|
-
}
|
|
135
|
-
</h3>
|
|
136
|
-
|
|
137
|
-
{/* Message */}
|
|
138
|
-
<div className="text-center mb-8">
|
|
139
|
-
{saveError ? (
|
|
140
|
-
<div className="space-y-3">
|
|
141
|
-
<p className="text-red-700 dark:text-red-300 font-semibold">
|
|
142
|
-
{saveError}
|
|
143
|
-
</p>
|
|
144
|
-
<p className="text-sm text-neutral-600 dark:text-neutral-400">
|
|
145
|
-
Please fix the issues above and try again.
|
|
146
|
-
</p>
|
|
147
|
-
</div>
|
|
148
|
-
) : showSuccess ? (
|
|
149
|
-
<p className="text-green-700 dark:text-green-300 font-semibold">
|
|
150
|
-
{saveAsDraft ? 'Draft saved successfully!' : 'Post saved successfully!'}
|
|
151
|
-
</p>
|
|
152
|
-
) : (
|
|
153
|
-
<>
|
|
154
|
-
<p className="text-neutral-700 dark:text-neutral-300 mb-2">
|
|
155
|
-
{saveAsDraft
|
|
156
|
-
? 'Save this post as a draft? You can continue editing and publish it later.'
|
|
157
|
-
: isPublished
|
|
158
|
-
? 'You are about to update this post. Changes cannot be undone.'
|
|
159
|
-
: 'You are about to publish this post. This action cannot be undone.'
|
|
160
|
-
}
|
|
161
|
-
</p>
|
|
162
|
-
{postTitle && (
|
|
163
|
-
<p className="text-sm text-neutral-500 dark:text-neutral-400 italic">
|
|
164
|
-
"{postTitle}"
|
|
165
|
-
</p>
|
|
166
|
-
)}
|
|
167
|
-
</>
|
|
168
|
-
)}
|
|
169
|
-
</div>
|
|
170
|
-
|
|
171
|
-
{/* Actions */}
|
|
172
|
-
{showSuccess ? (
|
|
173
|
-
<div className="flex justify-center">
|
|
174
|
-
<button
|
|
175
|
-
onClick={onClose}
|
|
176
|
-
className="px-6 py-3 rounded-full bg-green-600 text-white font-bold uppercase text-[10px] tracking-widest transition-all hover:bg-green-700 shadow-lg shadow-green-600/20"
|
|
177
|
-
>
|
|
178
|
-
Close
|
|
179
|
-
</button>
|
|
180
|
-
</div>
|
|
181
|
-
) : saveError ? (
|
|
182
|
-
<div className="flex gap-4">
|
|
183
|
-
<button
|
|
184
|
-
onClick={onClose}
|
|
185
|
-
className="flex-1 px-6 py-3 rounded-full border-2 border-dashboard-border text-dashboard-text font-bold uppercase text-[10px] tracking-widest transition-all hover:bg-dashboard-bg"
|
|
186
|
-
>
|
|
187
|
-
Close
|
|
188
|
-
</button>
|
|
189
|
-
<button
|
|
190
|
-
onClick={handleConfirm}
|
|
191
|
-
disabled={isSaving}
|
|
192
|
-
className="flex-1 px-6 py-3 rounded-full bg-primary text-white font-bold uppercase text-[10px] tracking-widest transition-all hover:bg-primary/90 disabled:opacity-50 disabled:cursor-not-allowed shadow-lg shadow-primary/20"
|
|
193
|
-
>
|
|
194
|
-
{isSaving
|
|
195
|
-
? 'Retrying...'
|
|
196
|
-
: 'Try Again'
|
|
197
|
-
}
|
|
198
|
-
</button>
|
|
199
|
-
</div>
|
|
200
|
-
) : (
|
|
201
|
-
<div className="flex gap-4">
|
|
202
|
-
<button
|
|
203
|
-
onClick={onClose}
|
|
204
|
-
disabled={isSaving}
|
|
205
|
-
className="flex-1 px-6 py-3 rounded-full border-2 border-dashboard-border text-dashboard-text font-bold uppercase text-[10px] tracking-widest transition-all hover:bg-dashboard-bg disabled:opacity-50 disabled:cursor-not-allowed"
|
|
206
|
-
>
|
|
207
|
-
Cancel
|
|
208
|
-
</button>
|
|
209
|
-
<button
|
|
210
|
-
onClick={handleConfirm}
|
|
211
|
-
disabled={isSaving}
|
|
212
|
-
className="flex-1 px-6 py-3 rounded-full bg-primary text-white font-bold uppercase text-[10px] tracking-widest transition-all hover:bg-primary/90 disabled:opacity-50 disabled:cursor-not-allowed shadow-lg shadow-primary/20"
|
|
213
|
-
>
|
|
214
|
-
{isSaving
|
|
215
|
-
? 'Saving...'
|
|
216
|
-
: saveAsDraft
|
|
217
|
-
? 'Save Draft'
|
|
218
|
-
: isPublished
|
|
219
|
-
? 'Update Post'
|
|
220
|
-
: 'Publish Post'
|
|
221
|
-
}
|
|
222
|
-
</button>
|
|
223
|
-
</div>
|
|
224
|
-
)}
|
|
225
|
-
</motion.div>
|
|
226
|
-
</div>
|
|
227
|
-
)}
|
|
228
|
-
</AnimatePresence>
|
|
229
|
-
);
|
|
230
|
-
|
|
231
|
-
return createPortal(modalContent, document.body);
|
|
232
|
-
}
|
|
233
|
-
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
export interface CustomBlockItemProps {
|
|
3
|
-
blockType: string;
|
|
4
|
-
name: string;
|
|
5
|
-
description?: string;
|
|
6
|
-
icon: React.ReactNode;
|
|
7
|
-
onAddBlock?: (blockType: string) => void;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Custom Block Item Component
|
|
11
|
-
* Draggable custom block from client registry and clickable to add at bottom
|
|
12
|
-
*/
|
|
13
|
-
export declare function CustomBlockItem({ blockType, name, description, icon, onAddBlock }: CustomBlockItemProps): import("react/jsx-runtime").JSX.Element;
|
|
14
|
-
//# sourceMappingURL=CustomBlockItem.d.ts.map
|