@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,298 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Columns Block
|
|
3
|
-
* Flex/grid container with configurable column layouts
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
'use client';
|
|
7
|
-
|
|
8
|
-
import React from 'react';
|
|
9
|
-
import { Plus, Trash2 } from 'lucide-react';
|
|
10
|
-
import { BlockEditProps, BlockPreviewProps } from '../../../types/block';
|
|
11
|
-
import { LayoutContainer } from '../../../views/CanvasEditor/LayoutContainer';
|
|
12
|
-
import { COLUMN_LAYOUTS, ColumnLayout } from '../index';
|
|
13
|
-
import { Block } from '../../../types/block';
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Columns Block Edit Component
|
|
17
|
-
*/
|
|
18
|
-
export const ColumnsEdit: React.FC<BlockEditProps & {
|
|
19
|
-
childBlocks: Block[];
|
|
20
|
-
onChildBlockAdd: (type: string, index: number, containerId: string) => void;
|
|
21
|
-
onChildBlockUpdate: (id: string, data: Partial<Block['data']>, containerId: string) => void;
|
|
22
|
-
onChildBlockDelete: (id: string, containerId: string) => void;
|
|
23
|
-
onChildBlockMove: (id: string, newIndex: number, containerId: string) => void;
|
|
24
|
-
}> = ({
|
|
25
|
-
block,
|
|
26
|
-
onUpdate,
|
|
27
|
-
isSelected,
|
|
28
|
-
childBlocks = [],
|
|
29
|
-
onChildBlockAdd,
|
|
30
|
-
onChildBlockUpdate,
|
|
31
|
-
onChildBlockDelete,
|
|
32
|
-
onChildBlockMove,
|
|
33
|
-
}) => {
|
|
34
|
-
// Support both old layout-based system and new dynamic column count
|
|
35
|
-
const columnCount = block.data.columnCount as number | undefined;
|
|
36
|
-
const layout: ColumnLayout | undefined = block.data.layout as ColumnLayout | undefined;
|
|
37
|
-
|
|
38
|
-
// Determine number of columns: use columnCount if set, otherwise derive from layout
|
|
39
|
-
let numColumns: number;
|
|
40
|
-
let gridClass: string;
|
|
41
|
-
let columnWidths: number[];
|
|
42
|
-
|
|
43
|
-
// Grid class mapping for Tailwind (must be explicit for dynamic classes)
|
|
44
|
-
const gridClassMap: Record<number, string> = {
|
|
45
|
-
1: 'grid-cols-1',
|
|
46
|
-
2: 'grid-cols-2',
|
|
47
|
-
3: 'grid-cols-3',
|
|
48
|
-
4: 'grid-cols-4',
|
|
49
|
-
5: 'grid-cols-5',
|
|
50
|
-
6: 'grid-cols-6',
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
if (columnCount !== undefined && columnCount > 0) {
|
|
54
|
-
// Dynamic column system
|
|
55
|
-
numColumns = columnCount;
|
|
56
|
-
// Create equal-width columns
|
|
57
|
-
const widthPercent = Math.floor(100 / numColumns);
|
|
58
|
-
columnWidths = Array(numColumns).fill(widthPercent);
|
|
59
|
-
// Use explicit grid class from map, fallback to inline style if needed
|
|
60
|
-
gridClass = gridClassMap[numColumns] || `grid-cols-${numColumns}`;
|
|
61
|
-
} else if (layout && COLUMN_LAYOUTS[layout]) {
|
|
62
|
-
// Legacy layout-based system
|
|
63
|
-
const layoutConfig = COLUMN_LAYOUTS[layout];
|
|
64
|
-
numColumns = layoutConfig.widths.length;
|
|
65
|
-
gridClass = layoutConfig.grid;
|
|
66
|
-
columnWidths = layoutConfig.widths;
|
|
67
|
-
} else {
|
|
68
|
-
// Default to 2 columns
|
|
69
|
-
numColumns = 2;
|
|
70
|
-
gridClass = 'grid-cols-2';
|
|
71
|
-
columnWidths = [50, 50];
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// Split child blocks into columns based on columnIndex in meta, or round-robin
|
|
75
|
-
const columns: Block[][] = Array.from({ length: numColumns }, () => []);
|
|
76
|
-
childBlocks.forEach((childBlock) => {
|
|
77
|
-
const columnIndex = childBlock.meta?.columnIndex;
|
|
78
|
-
if (typeof columnIndex === 'number' && columnIndex >= 0 && columnIndex < numColumns) {
|
|
79
|
-
columns[columnIndex].push(childBlock);
|
|
80
|
-
} else {
|
|
81
|
-
// Fallback to round-robin if no columnIndex specified
|
|
82
|
-
const index = childBlocks.indexOf(childBlock);
|
|
83
|
-
columns[index % numColumns].push(childBlock);
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
// Get column widths from data or use equal widths
|
|
88
|
-
const storedWidths = block.data.columnWidths as number[] | undefined;
|
|
89
|
-
const currentWidths = storedWidths && storedWidths.length === numColumns
|
|
90
|
-
? storedWidths
|
|
91
|
-
: columnWidths; // Use calculated equal widths if not set
|
|
92
|
-
|
|
93
|
-
// Add column handler
|
|
94
|
-
const addColumn = () => {
|
|
95
|
-
if (numColumns >= 4) return; // Max 4 columns
|
|
96
|
-
const newColumnCount = numColumns + 1;
|
|
97
|
-
// Calculate new equal widths
|
|
98
|
-
const newWidthPercent = Math.floor(100 / newColumnCount);
|
|
99
|
-
const newWidths = Array(newColumnCount).fill(newWidthPercent);
|
|
100
|
-
onUpdate({
|
|
101
|
-
...block.data,
|
|
102
|
-
columnCount: newColumnCount,
|
|
103
|
-
columnWidths: newWidths,
|
|
104
|
-
// Clear layout if using dynamic columns
|
|
105
|
-
layout: undefined,
|
|
106
|
-
});
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
// Delete column handler
|
|
110
|
-
const deleteColumn = (colIndex: number) => {
|
|
111
|
-
if (numColumns <= 1) return; // Don't allow deleting the last column
|
|
112
|
-
|
|
113
|
-
// Move blocks from deleted column to the last column (or previous column if deleting last)
|
|
114
|
-
const blocksToMove = columns[colIndex] || [];
|
|
115
|
-
const targetColumnIndex = colIndex === numColumns - 1 ? numColumns - 2 : numColumns - 1;
|
|
116
|
-
const targetColumn = columns[targetColumnIndex] || [];
|
|
117
|
-
|
|
118
|
-
// Move each block to the target column using moveBlock (which will update meta.columnIndex)
|
|
119
|
-
blocksToMove.forEach((blockToMove, blockIndex) => {
|
|
120
|
-
const newIndex = targetColumn.length + blockIndex;
|
|
121
|
-
onChildBlockMove(blockToMove.id, newIndex, `${block.id}-col-${targetColumnIndex}`);
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
// Update column count and widths after moving blocks
|
|
125
|
-
const newColumnCount = numColumns - 1;
|
|
126
|
-
// Remove the deleted column's width and redistribute
|
|
127
|
-
const newWidths = currentWidths.filter((_, i) => i !== colIndex);
|
|
128
|
-
// Normalize to ensure they sum to 100
|
|
129
|
-
const total = newWidths.reduce((sum, w) => sum + w, 0);
|
|
130
|
-
const normalizedWidths = newWidths.map(w => Math.round((w / total) * 100));
|
|
131
|
-
|
|
132
|
-
onUpdate({
|
|
133
|
-
...block.data,
|
|
134
|
-
columnCount: newColumnCount,
|
|
135
|
-
columnWidths: normalizedWidths,
|
|
136
|
-
layout: undefined,
|
|
137
|
-
});
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
return (
|
|
141
|
-
<div className="rounded-xl bg-white relative">
|
|
142
|
-
{/* Column Grid */}
|
|
143
|
-
<div
|
|
144
|
-
className="grid gap-8 p-6"
|
|
145
|
-
style={{
|
|
146
|
-
gridTemplateColumns: currentWidths.map(w => `${w}%`).join(' '),
|
|
147
|
-
}}
|
|
148
|
-
>
|
|
149
|
-
{Array.from({ length: numColumns }).map((_, colIndex) => (
|
|
150
|
-
<div
|
|
151
|
-
key={colIndex}
|
|
152
|
-
className={`group/col min-h-[200px] rounded-xl border border-dashed transition-all relative ${isSelected
|
|
153
|
-
? 'border-primary/20'
|
|
154
|
-
: 'border-gray-200/50'
|
|
155
|
-
}`}
|
|
156
|
-
>
|
|
157
|
-
<div className="p-4">
|
|
158
|
-
<div className="mb-3 flex items-center justify-between">
|
|
159
|
-
<span className="text-[10px] font-black uppercase tracking-widest text-gray-400">
|
|
160
|
-
Column {colIndex + 1}
|
|
161
|
-
</span>
|
|
162
|
-
<div className="flex items-center gap-2">
|
|
163
|
-
<span className="text-[9px] text-gray-500">
|
|
164
|
-
{currentWidths[colIndex]}%
|
|
165
|
-
</span>
|
|
166
|
-
{/* Delete Column Button - Similar to table, appears on column hover */}
|
|
167
|
-
{numColumns > 1 && (
|
|
168
|
-
<button
|
|
169
|
-
onClick={(e) => {
|
|
170
|
-
e.stopPropagation();
|
|
171
|
-
deleteColumn(colIndex);
|
|
172
|
-
}}
|
|
173
|
-
className="opacity-0 group-hover/col:opacity-100 p-1 text-neutral-400 hover:text-red-500 transition-all rounded"
|
|
174
|
-
title="Delete Column"
|
|
175
|
-
aria-label="Delete Column"
|
|
176
|
-
>
|
|
177
|
-
<Trash2 size={10} />
|
|
178
|
-
</button>
|
|
179
|
-
)}
|
|
180
|
-
</div>
|
|
181
|
-
</div>
|
|
182
|
-
|
|
183
|
-
<LayoutContainer
|
|
184
|
-
blocks={columns[colIndex] || []}
|
|
185
|
-
containerId={`${block.id}-col-${colIndex}`}
|
|
186
|
-
onBlockAdd={onChildBlockAdd}
|
|
187
|
-
onBlockUpdate={onChildBlockUpdate}
|
|
188
|
-
onBlockDelete={onChildBlockDelete}
|
|
189
|
-
onBlockMove={onChildBlockMove}
|
|
190
|
-
emptyLabel={`Drop blocks in column ${colIndex + 1}`}
|
|
191
|
-
/>
|
|
192
|
-
</div>
|
|
193
|
-
</div>
|
|
194
|
-
))}
|
|
195
|
-
</div>
|
|
196
|
-
|
|
197
|
-
{/* Add Column Button - Similar to table, pinned top right */}
|
|
198
|
-
{numColumns < 4 && (
|
|
199
|
-
<button
|
|
200
|
-
onClick={addColumn}
|
|
201
|
-
className="absolute top-0 right-0 h-8 w-8 flex items-center justify-center bg-white border-l border-b border-gray-200 text-primary hover:bg-primary hover:text-white transition-all z-10 rounded-br-xl"
|
|
202
|
-
title="Add Column"
|
|
203
|
-
>
|
|
204
|
-
<Plus size={16} />
|
|
205
|
-
</button>
|
|
206
|
-
)}
|
|
207
|
-
</div>
|
|
208
|
-
);
|
|
209
|
-
};
|
|
210
|
-
|
|
211
|
-
/**
|
|
212
|
-
* Columns Block Preview Component
|
|
213
|
-
*/
|
|
214
|
-
export const ColumnsPreview: React.FC<BlockPreviewProps & {
|
|
215
|
-
childBlocks?: Block[];
|
|
216
|
-
renderChild?: (block: Block) => React.ReactNode;
|
|
217
|
-
}> = ({ block, childBlocks = [], renderChild, context }) => {
|
|
218
|
-
// Support both old layout-based system and new dynamic column count
|
|
219
|
-
const columnCount = block.data.columnCount as number | undefined;
|
|
220
|
-
const layout: ColumnLayout | undefined = block.data.layout as ColumnLayout | undefined;
|
|
221
|
-
|
|
222
|
-
// Determine number of columns: use columnCount if set, otherwise derive from layout
|
|
223
|
-
let numColumns: number;
|
|
224
|
-
let gridClass: string;
|
|
225
|
-
|
|
226
|
-
// Grid class mapping for Tailwind (must be explicit for dynamic classes)
|
|
227
|
-
const gridClassMap: Record<number, string> = {
|
|
228
|
-
1: 'grid-cols-1',
|
|
229
|
-
2: 'grid-cols-2',
|
|
230
|
-
3: 'grid-cols-3',
|
|
231
|
-
4: 'grid-cols-4',
|
|
232
|
-
5: 'grid-cols-5',
|
|
233
|
-
6: 'grid-cols-6',
|
|
234
|
-
};
|
|
235
|
-
|
|
236
|
-
// Get column widths
|
|
237
|
-
const storedWidths = block.data.columnWidths as number[] | undefined;
|
|
238
|
-
|
|
239
|
-
if (columnCount !== undefined && columnCount > 0) {
|
|
240
|
-
// Dynamic column system
|
|
241
|
-
numColumns = columnCount;
|
|
242
|
-
gridClass = gridClassMap[numColumns] || `grid-cols-${numColumns}`;
|
|
243
|
-
} else if (layout && COLUMN_LAYOUTS[layout]) {
|
|
244
|
-
// Legacy layout-based system
|
|
245
|
-
const layoutConfig = COLUMN_LAYOUTS[layout];
|
|
246
|
-
numColumns = layoutConfig.widths.length;
|
|
247
|
-
gridClass = layoutConfig.grid;
|
|
248
|
-
} else {
|
|
249
|
-
// Default to 2 columns
|
|
250
|
-
numColumns = 2;
|
|
251
|
-
gridClass = 'grid-cols-2';
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
// Use stored widths if available, otherwise use equal widths
|
|
255
|
-
const columnWidths = storedWidths && storedWidths.length === numColumns
|
|
256
|
-
? storedWidths
|
|
257
|
-
: Array(numColumns).fill(Math.floor(100 / numColumns));
|
|
258
|
-
|
|
259
|
-
// If childBlocks are provided, use them; otherwise get from block.children
|
|
260
|
-
const children = childBlocks.length > 0
|
|
261
|
-
? childBlocks
|
|
262
|
-
: (block.children && Array.isArray(block.children) && typeof block.children[0] === 'object'
|
|
263
|
-
? block.children as Block[]
|
|
264
|
-
: []);
|
|
265
|
-
|
|
266
|
-
// Split child blocks into columns based on columnIndex in meta, or round-robin
|
|
267
|
-
const columns: Block[][] = Array.from({ length: numColumns }, () => []);
|
|
268
|
-
children.forEach((childBlock) => {
|
|
269
|
-
const columnIndex = childBlock.meta?.columnIndex;
|
|
270
|
-
if (typeof columnIndex === 'number' && columnIndex >= 0 && columnIndex < numColumns) {
|
|
271
|
-
columns[columnIndex].push(childBlock);
|
|
272
|
-
} else {
|
|
273
|
-
// Fallback to round-robin if no columnIndex specified
|
|
274
|
-
const index = children.indexOf(childBlock);
|
|
275
|
-
columns[index % numColumns].push(childBlock);
|
|
276
|
-
}
|
|
277
|
-
});
|
|
278
|
-
|
|
279
|
-
return (
|
|
280
|
-
<div
|
|
281
|
-
className="grid gap-8 my-8"
|
|
282
|
-
style={{
|
|
283
|
-
gridTemplateColumns: columnWidths.map(w => `${w}%`).join(' '),
|
|
284
|
-
}}
|
|
285
|
-
>
|
|
286
|
-
{Array.from({ length: numColumns }).map((_, colIndex) => (
|
|
287
|
-
<div key={colIndex} className="min-h-[100px]">
|
|
288
|
-
{columns[colIndex]?.map((childBlock) => (
|
|
289
|
-
<React.Fragment key={childBlock.id}>
|
|
290
|
-
{renderChild ? renderChild(childBlock) : null}
|
|
291
|
-
</React.Fragment>
|
|
292
|
-
))}
|
|
293
|
-
</div>
|
|
294
|
-
))}
|
|
295
|
-
</div>
|
|
296
|
-
);
|
|
297
|
-
};
|
|
298
|
-
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Columns Block
|
|
3
|
-
* Flex/grid container with configurable column layouts
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
'use client';
|
|
7
|
-
|
|
8
|
-
import React from 'react';
|
|
9
|
-
import { Plus, Trash2 } from 'lucide-react';
|
|
10
|
-
import { BlockEditProps, BlockPreviewProps } from '../../../types/block';
|
|
11
|
-
import { LayoutContainer } from '../../../views/CanvasEditor/LayoutContainer';
|
|
12
|
-
import { COLUMN_LAYOUTS, ColumnLayout } from '../index';
|
|
13
|
-
import { Block } from '../../../types/block';
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Columns Block Edit Component
|
|
17
|
-
*/
|
|
18
|
-
export const ColumnsEdit: React.FC<BlockEditProps & {
|
|
19
|
-
childBlocks: Block[];
|
|
20
|
-
onChildBlockAdd: (type: string, index: number, containerId: string) => void;
|
|
21
|
-
onChildBlockDelete: (blockId: string) => void;
|
|
22
|
-
onChildBlockMove: (blockId: string, newIndex: number) => void;
|
|
23
|
-
}> = ({
|
|
24
|
-
block,
|
|
25
|
-
childBlocks,
|
|
26
|
-
onChildBlockAdd,
|
|
27
|
-
onChildBlockDelete,
|
|
28
|
-
onChildBlockMove,
|
|
29
|
-
}) => {
|
|
30
|
-
// Support both old layout-based system and new dynamic column count
|
|
31
|
-
const columnCount = block.data.columnCount as number | undefined;
|
|
32
|
-
const layout: ColumnLayout | undefined = block.data.layout as ColumnLayout | undefined;
|
|
33
|
-
|
|
34
|
-
// Determine number of columns: use columnCount if set, otherwise derive from layout
|
|
35
|
-
let numColumns: number;
|
|
36
|
-
let gridClass: string;
|
|
37
|
-
let columnWidths: number[];
|
|
38
|
-
|
|
39
|
-
// Grid class mapping for Tailwind (must be explicit for dynamic classes)
|
|
40
|
-
const gridClassMap: Record<number, string> = {
|
|
41
|
-
1: 'grid-cols-1',
|
|
42
|
-
2: 'grid-cols-2',
|
|
43
|
-
3: 'grid-cols-3',
|
|
44
|
-
4: 'grid-cols-4',
|
|
45
|
-
5: 'grid-cols-5',
|
|
46
|
-
6: 'grid-cols-6',
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
if (columnCount !== undefined && columnCount > 0) {
|
|
50
|
-
// Dynamic column system
|
|
51
|
-
numColumns = columnCount;
|
|
52
|
-
// Create equal-width columns
|
|
53
|
-
const widthPercent = Math.floor(100 / numColumns);
|
|
54
|
-
columnWidths = Array(numColumns).fill(widthPercent);
|
|
55
|
-
// Use explicit grid class from map, fallback to inline style if needed
|
|
56
|
-
gridClass = gridClassMap[numColumns] || \`grid-cols-\${numColumns}\`;
|
|
57
|
-
} else if (layout && COLUMN_LAYOUTS[layout]) {
|
|
58
|
-
// Legacy layout-based system
|
|
59
|
-
const layoutConfig = COLUMN_LAYOUTS[layout];
|
|
60
|
-
numColumns = layoutConfig.widths.length;
|
|
61
|
-
gridClass = layoutConfig.grid;
|
|
62
|
-
columnWidths = layoutConfig.widths;
|
|
63
|
-
} else {
|
|
64
|
-
// Default to 2 columns
|
|
65
|
-
numColumns = 2;
|
|
66
|
-
gridClass = 'grid-cols-2';
|
|
67
|
-
columnWidths = [50, 50];
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// Split child blocks into columns based on columnIndex in meta, or round-robin
|
|
71
|
-
const columns: Block[][] = Array.from({ length: numColumns }, () => []);
|
|
72
|
-
childBlocks.forEach((childBlock) => {
|
|
73
|
-
const columnIndex = childBlock.meta?.columnIndex;
|
|
74
|
-
if (typeof columnIndex === 'number' && columnIndex >= 0 && columnIndex < numColumns) {
|
|
75
|
-
columns[columnIndex].push(childBlock);
|
|
76
|
-
} else {
|
|
77
|
-
// Fallback to round-robin if no columnIndex specified
|
|
78
|
-
const index = childBlocks.indexOf(childBlock);
|
|
79
|
-
columns[index % numColumns].push(childBlock);
|
|
80
|
-
}
|
|
81
|
-
});
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Section Block
|
|
3
|
-
* Full-width wrapper with configurable padding and background
|
|
4
|
-
*/
|
|
5
|
-
import React from 'react';
|
|
6
|
-
import { BlockEditProps, BlockPreviewProps } from '../../../types/block';
|
|
7
|
-
import { Block } from '../../../types/block';
|
|
8
|
-
/**
|
|
9
|
-
* Section Block Edit Component
|
|
10
|
-
*/
|
|
11
|
-
export declare const SectionEdit: React.FC<BlockEditProps & {
|
|
12
|
-
childBlocks: Block[];
|
|
13
|
-
onChildBlockAdd: (type: string, index: number, containerId: string) => void;
|
|
14
|
-
onChildBlockUpdate: (id: string, data: Partial<Block['data']>, containerId: string) => void;
|
|
15
|
-
onChildBlockDelete: (id: string, containerId: string) => void;
|
|
16
|
-
onChildBlockMove: (id: string, newIndex: number, containerId: string) => void;
|
|
17
|
-
}>;
|
|
18
|
-
/**
|
|
19
|
-
* Section Block Preview Component
|
|
20
|
-
*/
|
|
21
|
-
export declare const SectionPreview: React.FC<BlockPreviewProps & {
|
|
22
|
-
childBlocks?: Block[];
|
|
23
|
-
renderChild?: (block: Block) => React.ReactNode;
|
|
24
|
-
}>;
|
|
25
|
-
//# sourceMappingURL=SectionBlock.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SectionBlock.d.ts","sourceRoot":"","sources":["SectionBlock.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAGzE,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAE7C;;GAEG;AACH,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,GAAG;IAChD,WAAW,EAAE,KAAK,EAAE,CAAC;IACrB,eAAe,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5E,kBAAkB,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5F,kBAAkB,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9D,gBAAgB,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC;CACjF,CA+CI,CAAC;AAEN;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,GAAG;IACtD,WAAW,CAAC,EAAE,KAAK,EAAE,CAAC;IACtB,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,KAAK,CAAC,SAAS,CAAC;CACnD,CAyBA,CAAC"}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Section Block
|
|
3
|
-
* Full-width wrapper with configurable padding and background
|
|
4
|
-
*/
|
|
5
|
-
'use client';
|
|
6
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
-
import React from 'react';
|
|
8
|
-
import { LayoutContainer } from '../../../views/CanvasEditor/LayoutContainer';
|
|
9
|
-
import { LAYOUT_BACKGROUNDS } from '../index';
|
|
10
|
-
/**
|
|
11
|
-
* Section Block Edit Component
|
|
12
|
-
*/
|
|
13
|
-
export const SectionEdit = ({ block, onUpdate, isSelected, childBlocks = [], onChildBlockAdd, onChildBlockUpdate, onChildBlockDelete, onChildBlockMove, }) => {
|
|
14
|
-
const background = block.data.background || 'DEFAULT';
|
|
15
|
-
return (_jsx("div", { className: `rounded-xl transition-all ${isSelected
|
|
16
|
-
? 'bg-primary/5'
|
|
17
|
-
: ''} ${LAYOUT_BACKGROUNDS[background]}`, onDragStart: (e) => {
|
|
18
|
-
// Prevent section from being dragged when dragging nested blocks
|
|
19
|
-
// Check if the drag started on a nested block wrapper
|
|
20
|
-
const nestedBlockWrapper = e.target.closest('[data-block-wrapper]');
|
|
21
|
-
if (nestedBlockWrapper) {
|
|
22
|
-
const nestedBlockId = nestedBlockWrapper.getAttribute('data-block-id');
|
|
23
|
-
// If dragging a nested block, prevent the section's drag handler from firing
|
|
24
|
-
if (nestedBlockId && nestedBlockId !== block.id) {
|
|
25
|
-
e.stopPropagation();
|
|
26
|
-
e.preventDefault();
|
|
27
|
-
console.log('[SectionBlock] Preventing section drag, nested block is being dragged:', nestedBlockId);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}, children: _jsx("div", { className: `px-8 py-4`, children: _jsx(LayoutContainer, { blocks: childBlocks, containerId: block.id, onBlockAdd: onChildBlockAdd, onBlockUpdate: onChildBlockUpdate, onBlockDelete: onChildBlockDelete, onBlockMove: onChildBlockMove, emptyLabel: "Drop blocks into section" }) }) }));
|
|
31
|
-
};
|
|
32
|
-
/**
|
|
33
|
-
* Section Block Preview Component
|
|
34
|
-
*/
|
|
35
|
-
export const SectionPreview = ({ block, childBlocks = [], renderChild, context }) => {
|
|
36
|
-
const background = block.data.background || 'DEFAULT';
|
|
37
|
-
// If childBlocks are provided, use them; otherwise get from block.children
|
|
38
|
-
const children = childBlocks.length > 0
|
|
39
|
-
? childBlocks
|
|
40
|
-
: (block.children && Array.isArray(block.children) && typeof block.children[0] === 'object'
|
|
41
|
-
? block.children
|
|
42
|
-
: []);
|
|
43
|
-
return (_jsx("section", { className: `w-full ${LAYOUT_BACKGROUNDS[background]}`, children: _jsx("div", { className: `max-w-7xl mx-auto px-6 py-2`, children: children.length > 0 && renderChild ? (children.map((childBlock) => (_jsx(React.Fragment, { children: renderChild(childBlock) }, childBlock.id)))) : (_jsx("div", { className: "text-gray-400 text-sm italic", children: "Empty section" })) }) }));
|
|
44
|
-
};
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Section Block
|
|
3
|
-
* Full-width wrapper with configurable padding and background
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
'use client';
|
|
7
|
-
|
|
8
|
-
import React from 'react';
|
|
9
|
-
import { BlockEditProps, BlockPreviewProps } from '../../../types/block';
|
|
10
|
-
import { LayoutContainer } from '../../../views/CanvasEditor/LayoutContainer';
|
|
11
|
-
import { LAYOUT_CONSTANTS, LAYOUT_BACKGROUNDS } from '../index';
|
|
12
|
-
import { Block } from '../../../types/block';
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Section Block Edit Component
|
|
16
|
-
*/
|
|
17
|
-
export const SectionEdit: React.FC<BlockEditProps & {
|
|
18
|
-
childBlocks: Block[];
|
|
19
|
-
onChildBlockAdd: (type: string, index: number, containerId: string) => void;
|
|
20
|
-
onChildBlockUpdate: (id: string, data: Partial<Block['data']>, containerId: string) => void;
|
|
21
|
-
onChildBlockDelete: (id: string, containerId: string) => void;
|
|
22
|
-
onChildBlockMove: (id: string, newIndex: number, containerId: string) => void;
|
|
23
|
-
}> = ({
|
|
24
|
-
block,
|
|
25
|
-
onUpdate,
|
|
26
|
-
isSelected,
|
|
27
|
-
childBlocks = [],
|
|
28
|
-
onChildBlockAdd,
|
|
29
|
-
onChildBlockUpdate,
|
|
30
|
-
onChildBlockDelete,
|
|
31
|
-
onChildBlockMove,
|
|
32
|
-
}) => {
|
|
33
|
-
const background = (block.data.background as keyof typeof LAYOUT_BACKGROUNDS) || 'DEFAULT';
|
|
34
|
-
|
|
35
|
-
return (
|
|
36
|
-
<div
|
|
37
|
-
className={`rounded-xl transition-all ${isSelected
|
|
38
|
-
? 'bg-primary/5'
|
|
39
|
-
: ''
|
|
40
|
-
} ${LAYOUT_BACKGROUNDS[background]}`}
|
|
41
|
-
onDragStart={(e) => {
|
|
42
|
-
// Prevent section from being dragged when dragging nested blocks
|
|
43
|
-
// Check if the drag started on a nested block wrapper
|
|
44
|
-
const nestedBlockWrapper = (e.target as HTMLElement).closest('[data-block-wrapper]');
|
|
45
|
-
if (nestedBlockWrapper) {
|
|
46
|
-
const nestedBlockId = nestedBlockWrapper.getAttribute('data-block-id');
|
|
47
|
-
// If dragging a nested block, prevent the section's drag handler from firing
|
|
48
|
-
if (nestedBlockId && nestedBlockId !== block.id) {
|
|
49
|
-
e.stopPropagation();
|
|
50
|
-
e.preventDefault();
|
|
51
|
-
console.log('[SectionBlock] Preventing section drag, nested block is being dragged:', nestedBlockId);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}}
|
|
55
|
-
>
|
|
56
|
-
{/* Nested Content */}
|
|
57
|
-
<div className={`px-8 py-4`}>
|
|
58
|
-
<LayoutContainer
|
|
59
|
-
blocks={childBlocks}
|
|
60
|
-
containerId={block.id}
|
|
61
|
-
onBlockAdd={onChildBlockAdd}
|
|
62
|
-
onBlockUpdate={onChildBlockUpdate}
|
|
63
|
-
onBlockDelete={onChildBlockDelete}
|
|
64
|
-
onBlockMove={onChildBlockMove}
|
|
65
|
-
emptyLabel="Drop blocks into section"
|
|
66
|
-
/>
|
|
67
|
-
</div>
|
|
68
|
-
</div>
|
|
69
|
-
);
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Section Block Preview Component
|
|
74
|
-
*/
|
|
75
|
-
export const SectionPreview: React.FC<BlockPreviewProps & {
|
|
76
|
-
childBlocks?: Block[];
|
|
77
|
-
renderChild?: (block: Block) => React.ReactNode;
|
|
78
|
-
}> = ({ block, childBlocks = [], renderChild, context }) => {
|
|
79
|
-
const background = (block.data.background as keyof typeof LAYOUT_BACKGROUNDS) || 'DEFAULT';
|
|
80
|
-
|
|
81
|
-
// If childBlocks are provided, use them; otherwise get from block.children
|
|
82
|
-
const children = childBlocks.length > 0
|
|
83
|
-
? childBlocks
|
|
84
|
-
: (block.children && Array.isArray(block.children) && typeof block.children[0] === 'object'
|
|
85
|
-
? block.children as Block[]
|
|
86
|
-
: []);
|
|
87
|
-
|
|
88
|
-
return (
|
|
89
|
-
<section className={`w-full ${LAYOUT_BACKGROUNDS[background]}`}>
|
|
90
|
-
<div className={`max-w-7xl mx-auto px-6 py-2`}>
|
|
91
|
-
{children.length > 0 && renderChild ? (
|
|
92
|
-
children.map((childBlock) => (
|
|
93
|
-
<React.Fragment key={childBlock.id}>
|
|
94
|
-
{renderChild(childBlock)}
|
|
95
|
-
</React.Fragment>
|
|
96
|
-
))
|
|
97
|
-
) : (
|
|
98
|
-
<div className="text-gray-400 text-sm italic">Empty section</div>
|
|
99
|
-
)}
|
|
100
|
-
</div>
|
|
101
|
-
</section>
|
|
102
|
-
);
|
|
103
|
-
};
|
|
104
|
-
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Layout System Constants
|
|
3
|
-
* Standardized spacing and styling for layout blocks
|
|
4
|
-
*/
|
|
5
|
-
export declare const LAYOUT_CONSTANTS: {
|
|
6
|
-
readonly GUTTER: "2rem";
|
|
7
|
-
readonly SPACING: "4rem";
|
|
8
|
-
readonly SPACING_SM: "2rem";
|
|
9
|
-
readonly SPACING_LG: "6rem";
|
|
10
|
-
readonly BORDER_RADIUS: "2rem";
|
|
11
|
-
};
|
|
12
|
-
export declare const LAYOUT_BACKGROUNDS: {
|
|
13
|
-
readonly DEFAULT: "bg-white";
|
|
14
|
-
readonly NEUTRAL: "bg-neutral-50";
|
|
15
|
-
readonly SAGE: "bg-primary/5";
|
|
16
|
-
readonly CREAM: "bg-amber-50/50";
|
|
17
|
-
};
|
|
18
|
-
export type ColumnLayout = '50-50' | '33-66' | '66-33' | '25-25-25-25' | '25-75' | '75-25';
|
|
19
|
-
export declare const COLUMN_LAYOUTS: Record<ColumnLayout, {
|
|
20
|
-
grid: string;
|
|
21
|
-
widths: number[];
|
|
22
|
-
}>;
|
|
23
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,eAAO,MAAM,gBAAgB;;;;;;CAMnB,CAAC;AAGX,eAAO,MAAM,kBAAkB;;;;;CAKrB,CAAC;AAGX,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,aAAa,GAAG,OAAO,GAAG,OAAO,CAAC;AAE3F,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,YAAY,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,CAyBnF,CAAC"}
|
package/src/lib/layouts/index.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Layout System Constants
|
|
3
|
-
* Standardized spacing and styling for layout blocks
|
|
4
|
-
*/
|
|
5
|
-
// Spacing Constants (Earth-tone aligned)
|
|
6
|
-
export const LAYOUT_CONSTANTS = {
|
|
7
|
-
GUTTER: '2rem', // 32px - Space between columns
|
|
8
|
-
SPACING: '4rem', // 64px - Vertical padding for sections
|
|
9
|
-
SPACING_SM: '2rem', // 32px - Smaller vertical padding
|
|
10
|
-
SPACING_LG: '6rem', // 96px - Larger vertical padding
|
|
11
|
-
BORDER_RADIUS: '2rem', // 32px - Consistent rounded corners
|
|
12
|
-
};
|
|
13
|
-
// Background Colors (Light mode only - matches client website theme)
|
|
14
|
-
export const LAYOUT_BACKGROUNDS = {
|
|
15
|
-
DEFAULT: 'bg-white',
|
|
16
|
-
NEUTRAL: 'bg-neutral-50',
|
|
17
|
-
SAGE: 'bg-primary/5',
|
|
18
|
-
CREAM: 'bg-amber-50/50',
|
|
19
|
-
};
|
|
20
|
-
export const COLUMN_LAYOUTS = {
|
|
21
|
-
'50-50': {
|
|
22
|
-
grid: 'grid-cols-2',
|
|
23
|
-
widths: [50, 50],
|
|
24
|
-
},
|
|
25
|
-
'33-66': {
|
|
26
|
-
grid: 'grid-cols-3',
|
|
27
|
-
widths: [33, 66],
|
|
28
|
-
},
|
|
29
|
-
'66-33': {
|
|
30
|
-
grid: 'grid-cols-3',
|
|
31
|
-
widths: [66, 33],
|
|
32
|
-
},
|
|
33
|
-
'25-25-25-25': {
|
|
34
|
-
grid: 'grid-cols-4',
|
|
35
|
-
widths: [25, 25, 25, 25],
|
|
36
|
-
},
|
|
37
|
-
'25-75': {
|
|
38
|
-
grid: 'grid-cols-4',
|
|
39
|
-
widths: [25, 75],
|
|
40
|
-
},
|
|
41
|
-
'75-25': {
|
|
42
|
-
grid: 'grid-cols-4',
|
|
43
|
-
widths: [75, 25],
|
|
44
|
-
},
|
|
45
|
-
};
|