@jhits/plugin-blog 0.0.10 → 0.0.12

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.
Files changed (276) hide show
  1. package/package.json +4 -5
  2. package/src/api/categories.ts +0 -43
  3. package/src/api/check-title.ts +0 -60
  4. package/src/api/config-handler.ts +0 -76
  5. package/src/api/handler.ts +0 -418
  6. package/src/api/index.ts +0 -33
  7. package/src/api/route.ts +0 -116
  8. package/src/api/router.ts +0 -128
  9. package/src/api-server.ts +0 -11
  10. package/src/config.ts +0 -161
  11. package/src/hooks/index.d.ts +0 -8
  12. package/src/hooks/index.d.ts.map +0 -1
  13. package/src/hooks/index.js +0 -7
  14. package/src/hooks/index.ts +0 -9
  15. package/src/hooks/useBlog.d.ts +0 -31
  16. package/src/hooks/useBlog.d.ts.map +0 -1
  17. package/src/hooks/useBlog.js +0 -57
  18. package/src/hooks/useBlog.ts +0 -85
  19. package/src/hooks/useBlogs.d.ts +0 -39
  20. package/src/hooks/useBlogs.d.ts.map +0 -1
  21. package/src/hooks/useBlogs.js +0 -82
  22. package/src/hooks/useBlogs.ts +0 -123
  23. package/src/hooks/useCategories.d.ts +0 -9
  24. package/src/hooks/useCategories.d.ts.map +0 -1
  25. package/src/hooks/useCategories.js +0 -70
  26. package/src/hooks/useCategories.ts +0 -76
  27. package/src/index.d.ts +0 -55
  28. package/src/index.d.ts.map +0 -1
  29. package/src/index.js +0 -228
  30. package/src/index.server.ts +0 -14
  31. package/src/index.tsx +0 -335
  32. package/src/init.d.ts +0 -40
  33. package/src/init.d.ts.map +0 -1
  34. package/src/init.js +0 -41
  35. package/src/init.tsx +0 -63
  36. package/src/lib/blocks/BlockRenderer.d.ts +0 -54
  37. package/src/lib/blocks/BlockRenderer.d.ts.map +0 -1
  38. package/src/lib/blocks/BlockRenderer.js +0 -54
  39. package/src/lib/blocks/BlockRenderer.tsx +0 -141
  40. package/src/lib/blocks/index.ts +0 -6
  41. package/src/lib/config-storage.d.ts +0 -30
  42. package/src/lib/config-storage.d.ts.map +0 -1
  43. package/src/lib/config-storage.js +0 -31
  44. package/src/lib/config-storage.ts +0 -65
  45. package/src/lib/index.ts +0 -9
  46. package/src/lib/layouts/blocks/ColumnsBlock.d.ts +0 -25
  47. package/src/lib/layouts/blocks/ColumnsBlock.d.ts.map +0 -1
  48. package/src/lib/layouts/blocks/ColumnsBlock.js +0 -182
  49. package/src/lib/layouts/blocks/ColumnsBlock.tsx +0 -298
  50. package/src/lib/layouts/blocks/ColumnsBlock.tsx.tmp +0 -81
  51. package/src/lib/layouts/blocks/SectionBlock.d.ts +0 -25
  52. package/src/lib/layouts/blocks/SectionBlock.d.ts.map +0 -1
  53. package/src/lib/layouts/blocks/SectionBlock.js +0 -44
  54. package/src/lib/layouts/blocks/SectionBlock.tsx +0 -104
  55. package/src/lib/layouts/blocks/index.ts +0 -8
  56. package/src/lib/layouts/index.d.ts +0 -23
  57. package/src/lib/layouts/index.d.ts.map +0 -1
  58. package/src/lib/layouts/index.js +0 -45
  59. package/src/lib/layouts/index.ts +0 -52
  60. package/src/lib/layouts/registerLayoutBlocks.d.ts +0 -9
  61. package/src/lib/layouts/registerLayoutBlocks.d.ts.map +0 -1
  62. package/src/lib/layouts/registerLayoutBlocks.js +0 -60
  63. package/src/lib/layouts/registerLayoutBlocks.ts +0 -64
  64. package/src/lib/mappers/apiMapper.d.ts +0 -66
  65. package/src/lib/mappers/apiMapper.d.ts.map +0 -1
  66. package/src/lib/mappers/apiMapper.js +0 -191
  67. package/src/lib/mappers/apiMapper.ts +0 -254
  68. package/src/lib/migration/index.ts +0 -6
  69. package/src/lib/migration/mapper.ts +0 -140
  70. package/src/lib/rich-text/RichTextEditor.d.ts +0 -45
  71. package/src/lib/rich-text/RichTextEditor.d.ts.map +0 -1
  72. package/src/lib/rich-text/RichTextEditor.js +0 -564
  73. package/src/lib/rich-text/RichTextEditor.tsx +0 -826
  74. package/src/lib/rich-text/RichTextPreview.d.ts +0 -16
  75. package/src/lib/rich-text/RichTextPreview.d.ts.map +0 -1
  76. package/src/lib/rich-text/RichTextPreview.js +0 -144
  77. package/src/lib/rich-text/RichTextPreview.tsx +0 -210
  78. package/src/lib/rich-text/index.d.ts +0 -9
  79. package/src/lib/rich-text/index.d.ts.map +0 -1
  80. package/src/lib/rich-text/index.js +0 -6
  81. package/src/lib/rich-text/index.ts +0 -10
  82. package/src/lib/utils/blockHelpers.d.ts +0 -23
  83. package/src/lib/utils/blockHelpers.d.ts.map +0 -1
  84. package/src/lib/utils/blockHelpers.js +0 -65
  85. package/src/lib/utils/blockHelpers.ts +0 -72
  86. package/src/lib/utils/configValidation.d.ts +0 -23
  87. package/src/lib/utils/configValidation.d.ts.map +0 -1
  88. package/src/lib/utils/configValidation.js +0 -113
  89. package/src/lib/utils/configValidation.ts +0 -137
  90. package/src/lib/utils/index.ts +0 -8
  91. package/src/lib/utils/slugify.ts +0 -79
  92. package/src/registry/BlockRegistry.d.ts +0 -62
  93. package/src/registry/BlockRegistry.d.ts.map +0 -1
  94. package/src/registry/BlockRegistry.js +0 -112
  95. package/src/registry/BlockRegistry.ts +0 -139
  96. package/src/registry/index.d.ts +0 -6
  97. package/src/registry/index.d.ts.map +0 -1
  98. package/src/registry/index.js +0 -4
  99. package/src/registry/index.ts +0 -11
  100. package/src/state/EditorContext.d.ts +0 -45
  101. package/src/state/EditorContext.d.ts.map +0 -1
  102. package/src/state/EditorContext.js +0 -215
  103. package/src/state/EditorContext.tsx +0 -283
  104. package/src/state/index.d.ts +0 -7
  105. package/src/state/index.d.ts.map +0 -1
  106. package/src/state/index.js +0 -6
  107. package/src/state/index.ts +0 -8
  108. package/src/state/reducer.d.ts +0 -11
  109. package/src/state/reducer.d.ts.map +0 -1
  110. package/src/state/reducer.js +0 -443
  111. package/src/state/reducer.ts +0 -694
  112. package/src/state/types.d.ts +0 -162
  113. package/src/state/types.d.ts.map +0 -1
  114. package/src/state/types.js +0 -27
  115. package/src/state/types.ts +0 -160
  116. package/src/types/block.d.ts +0 -221
  117. package/src/types/block.d.ts.map +0 -1
  118. package/src/types/block.js +0 -6
  119. package/src/types/block.ts +0 -269
  120. package/src/types/index.d.ts +0 -8
  121. package/src/types/index.d.ts.map +0 -1
  122. package/src/types/index.js +0 -5
  123. package/src/types/index.ts +0 -17
  124. package/src/types/post.d.ts +0 -136
  125. package/src/types/post.d.ts.map +0 -1
  126. package/src/types/post.js +0 -5
  127. package/src/types/post.ts +0 -169
  128. package/src/utils/client.d.ts +0 -48
  129. package/src/utils/client.d.ts.map +0 -1
  130. package/src/utils/client.js +0 -77
  131. package/src/utils/client.ts +0 -122
  132. package/src/utils/index.ts +0 -7
  133. package/src/views/CanvasEditor/BlockWrapper.d.ts +0 -16
  134. package/src/views/CanvasEditor/BlockWrapper.d.ts.map +0 -1
  135. package/src/views/CanvasEditor/BlockWrapper.js +0 -276
  136. package/src/views/CanvasEditor/BlockWrapper.tsx +0 -522
  137. package/src/views/CanvasEditor/CanvasEditorView.d.ts +0 -14
  138. package/src/views/CanvasEditor/CanvasEditorView.d.ts.map +0 -1
  139. package/src/views/CanvasEditor/CanvasEditorView.js +0 -209
  140. package/src/views/CanvasEditor/CanvasEditorView.tsx +0 -337
  141. package/src/views/CanvasEditor/EditorBody.d.ts +0 -22
  142. package/src/views/CanvasEditor/EditorBody.d.ts.map +0 -1
  143. package/src/views/CanvasEditor/EditorBody.js +0 -505
  144. package/src/views/CanvasEditor/EditorBody.tsx +0 -665
  145. package/src/views/CanvasEditor/EditorHeader.d.ts +0 -18
  146. package/src/views/CanvasEditor/EditorHeader.d.ts.map +0 -1
  147. package/src/views/CanvasEditor/EditorHeader.js +0 -101
  148. package/src/views/CanvasEditor/EditorHeader.tsx +0 -268
  149. package/src/views/CanvasEditor/LayoutContainer.d.ts +0 -17
  150. package/src/views/CanvasEditor/LayoutContainer.d.ts.map +0 -1
  151. package/src/views/CanvasEditor/LayoutContainer.js +0 -222
  152. package/src/views/CanvasEditor/LayoutContainer.tsx +0 -322
  153. package/src/views/CanvasEditor/SaveConfirmationModal.d.ts +0 -13
  154. package/src/views/CanvasEditor/SaveConfirmationModal.d.ts.map +0 -1
  155. package/src/views/CanvasEditor/SaveConfirmationModal.js +0 -78
  156. package/src/views/CanvasEditor/SaveConfirmationModal.tsx +0 -233
  157. package/src/views/CanvasEditor/components/CustomBlockItem.d.ts +0 -14
  158. package/src/views/CanvasEditor/components/CustomBlockItem.d.ts.map +0 -1
  159. package/src/views/CanvasEditor/components/CustomBlockItem.js +0 -44
  160. package/src/views/CanvasEditor/components/CustomBlockItem.tsx +0 -92
  161. package/src/views/CanvasEditor/components/EditorCanvas.d.ts +0 -29
  162. package/src/views/CanvasEditor/components/EditorCanvas.d.ts.map +0 -1
  163. package/src/views/CanvasEditor/components/EditorCanvas.js +0 -32
  164. package/src/views/CanvasEditor/components/EditorCanvas.tsx +0 -160
  165. package/src/views/CanvasEditor/components/EditorLibrary.d.ts +0 -7
  166. package/src/views/CanvasEditor/components/EditorLibrary.d.ts.map +0 -1
  167. package/src/views/CanvasEditor/components/EditorLibrary.js +0 -25
  168. package/src/views/CanvasEditor/components/EditorLibrary.tsx +0 -122
  169. package/src/views/CanvasEditor/components/EditorSidebar.d.ts +0 -13
  170. package/src/views/CanvasEditor/components/EditorSidebar.d.ts.map +0 -1
  171. package/src/views/CanvasEditor/components/EditorSidebar.js +0 -20
  172. package/src/views/CanvasEditor/components/EditorSidebar.tsx +0 -181
  173. package/src/views/CanvasEditor/components/ErrorBanner.d.ts +0 -6
  174. package/src/views/CanvasEditor/components/ErrorBanner.d.ts.map +0 -1
  175. package/src/views/CanvasEditor/components/ErrorBanner.js +0 -8
  176. package/src/views/CanvasEditor/components/ErrorBanner.tsx +0 -31
  177. package/src/views/CanvasEditor/components/FeaturedMediaSection.d.ts +0 -25
  178. package/src/views/CanvasEditor/components/FeaturedMediaSection.d.ts.map +0 -1
  179. package/src/views/CanvasEditor/components/FeaturedMediaSection.js +0 -182
  180. package/src/views/CanvasEditor/components/FeaturedMediaSection.tsx +0 -341
  181. package/src/views/CanvasEditor/components/LibraryItem.d.ts +0 -14
  182. package/src/views/CanvasEditor/components/LibraryItem.d.ts.map +0 -1
  183. package/src/views/CanvasEditor/components/LibraryItem.js +0 -43
  184. package/src/views/CanvasEditor/components/LibraryItem.tsx +0 -80
  185. package/src/views/CanvasEditor/components/PrivacySettingsSection.d.ts +0 -15
  186. package/src/views/CanvasEditor/components/PrivacySettingsSection.d.ts.map +0 -1
  187. package/src/views/CanvasEditor/components/PrivacySettingsSection.js +0 -63
  188. package/src/views/CanvasEditor/components/PrivacySettingsSection.tsx +0 -212
  189. package/src/views/CanvasEditor/components/index.d.ts +0 -21
  190. package/src/views/CanvasEditor/components/index.d.ts.map +0 -1
  191. package/src/views/CanvasEditor/components/index.js +0 -12
  192. package/src/views/CanvasEditor/components/index.ts +0 -28
  193. package/src/views/CanvasEditor/hooks/index.d.ts +0 -10
  194. package/src/views/CanvasEditor/hooks/index.d.ts.map +0 -1
  195. package/src/views/CanvasEditor/hooks/index.js +0 -9
  196. package/src/views/CanvasEditor/hooks/index.ts +0 -10
  197. package/src/views/CanvasEditor/hooks/useHeroBlock.d.ts +0 -8
  198. package/src/views/CanvasEditor/hooks/useHeroBlock.d.ts.map +0 -1
  199. package/src/views/CanvasEditor/hooks/useHeroBlock.js +0 -79
  200. package/src/views/CanvasEditor/hooks/useHeroBlock.ts +0 -103
  201. package/src/views/CanvasEditor/hooks/useKeyboardShortcuts.d.ts +0 -3
  202. package/src/views/CanvasEditor/hooks/useKeyboardShortcuts.d.ts.map +0 -1
  203. package/src/views/CanvasEditor/hooks/useKeyboardShortcuts.js +0 -114
  204. package/src/views/CanvasEditor/hooks/useKeyboardShortcuts.ts +0 -142
  205. package/src/views/CanvasEditor/hooks/usePostLoader.d.ts +0 -5
  206. package/src/views/CanvasEditor/hooks/usePostLoader.d.ts.map +0 -1
  207. package/src/views/CanvasEditor/hooks/usePostLoader.js +0 -32
  208. package/src/views/CanvasEditor/hooks/usePostLoader.ts +0 -39
  209. package/src/views/CanvasEditor/hooks/useRegisteredBlocks.d.ts +0 -2
  210. package/src/views/CanvasEditor/hooks/useRegisteredBlocks.d.ts.map +0 -1
  211. package/src/views/CanvasEditor/hooks/useRegisteredBlocks.js +0 -47
  212. package/src/views/CanvasEditor/hooks/useRegisteredBlocks.ts +0 -55
  213. package/src/views/CanvasEditor/hooks/useUnsavedChanges.d.ts +0 -25
  214. package/src/views/CanvasEditor/hooks/useUnsavedChanges.d.ts.map +0 -1
  215. package/src/views/CanvasEditor/hooks/useUnsavedChanges.js +0 -285
  216. package/src/views/CanvasEditor/hooks/useUnsavedChanges.ts +0 -339
  217. package/src/views/CanvasEditor/index.d.ts +0 -16
  218. package/src/views/CanvasEditor/index.d.ts.map +0 -1
  219. package/src/views/CanvasEditor/index.js +0 -9
  220. package/src/views/CanvasEditor/index.ts +0 -16
  221. package/src/views/PostManager/EmptyState.d.ts +0 -10
  222. package/src/views/PostManager/EmptyState.d.ts.map +0 -1
  223. package/src/views/PostManager/EmptyState.js +0 -12
  224. package/src/views/PostManager/EmptyState.tsx +0 -42
  225. package/src/views/PostManager/PostActionsMenu.d.ts +0 -12
  226. package/src/views/PostManager/PostActionsMenu.d.ts.map +0 -1
  227. package/src/views/PostManager/PostActionsMenu.js +0 -58
  228. package/src/views/PostManager/PostActionsMenu.tsx +0 -112
  229. package/src/views/PostManager/PostCards.d.ts +0 -15
  230. package/src/views/PostManager/PostCards.d.ts.map +0 -1
  231. package/src/views/PostManager/PostCards.js +0 -79
  232. package/src/views/PostManager/PostCards.tsx +0 -197
  233. package/src/views/PostManager/PostFilters.d.ts +0 -16
  234. package/src/views/PostManager/PostFilters.d.ts.map +0 -1
  235. package/src/views/PostManager/PostFilters.js +0 -10
  236. package/src/views/PostManager/PostFilters.tsx +0 -95
  237. package/src/views/PostManager/PostManagerView.d.ts +0 -11
  238. package/src/views/PostManager/PostManagerView.d.ts.map +0 -1
  239. package/src/views/PostManager/PostManagerView.js +0 -174
  240. package/src/views/PostManager/PostManagerView.tsx +0 -289
  241. package/src/views/PostManager/PostStats.d.ts +0 -11
  242. package/src/views/PostManager/PostStats.d.ts.map +0 -1
  243. package/src/views/PostManager/PostStats.js +0 -46
  244. package/src/views/PostManager/PostStats.tsx +0 -81
  245. package/src/views/PostManager/PostTable.d.ts +0 -15
  246. package/src/views/PostManager/PostTable.d.ts.map +0 -1
  247. package/src/views/PostManager/PostTable.js +0 -79
  248. package/src/views/PostManager/PostTable.tsx +0 -230
  249. package/src/views/PostManager/index.d.ts +0 -12
  250. package/src/views/PostManager/index.d.ts.map +0 -1
  251. package/src/views/PostManager/index.js +0 -11
  252. package/src/views/PostManager/index.ts +0 -15
  253. package/src/views/Preview/PreviewBridgeView.d.ts +0 -12
  254. package/src/views/Preview/PreviewBridgeView.d.ts.map +0 -1
  255. package/src/views/Preview/PreviewBridgeView.js +0 -11
  256. package/src/views/Preview/PreviewBridgeView.tsx +0 -64
  257. package/src/views/Preview/index.d.ts +0 -6
  258. package/src/views/Preview/index.d.ts.map +0 -1
  259. package/src/views/Preview/index.js +0 -4
  260. package/src/views/Preview/index.ts +0 -7
  261. package/src/views/Settings/SettingsView.d.ts +0 -10
  262. package/src/views/Settings/SettingsView.d.ts.map +0 -1
  263. package/src/views/Settings/SettingsView.js +0 -111
  264. package/src/views/Settings/SettingsView.tsx +0 -298
  265. package/src/views/Settings/index.d.ts +0 -6
  266. package/src/views/Settings/index.d.ts.map +0 -1
  267. package/src/views/Settings/index.js +0 -4
  268. package/src/views/Settings/index.ts +0 -7
  269. package/src/views/SlugSEO/SlugSEOManagerView.d.ts +0 -12
  270. package/src/views/SlugSEO/SlugSEOManagerView.d.ts.map +0 -1
  271. package/src/views/SlugSEO/SlugSEOManagerView.js +0 -11
  272. package/src/views/SlugSEO/SlugSEOManagerView.tsx +0 -94
  273. package/src/views/SlugSEO/index.d.ts +0 -6
  274. package/src/views/SlugSEO/index.d.ts.map +0 -1
  275. package/src/views/SlugSEO/index.js +0 -4
  276. package/src/views/SlugSEO/index.ts +0 -7
@@ -1,665 +0,0 @@
1
- /**
2
- * Editor Body Component
3
- * Primary root container for the editor canvas
4
- * Acts as the main drop zone for blocks
5
- */
6
-
7
- 'use client';
8
-
9
- import React, { useState, useRef, Fragment, useEffect } from 'react';
10
- import { Plus } from 'lucide-react';
11
- import { Block } from '../../types/block';
12
- import { BlockWrapper } from './BlockWrapper';
13
-
14
- export interface EditorBodyProps {
15
- blocks: Block[];
16
- onBlockAdd: (type: string, index: number, containerId?: string) => void;
17
- onBlockUpdate: (id: string, data: Partial<Block['data']>) => void;
18
- onBlockDelete: (id: string) => void;
19
- onBlockMove: (id: string, newIndex: number, containerId?: string) => void;
20
- /** Enable dark mode for content area and wrappers (default: true) */
21
- darkMode?: boolean;
22
- /** Background colors for the editor */
23
- backgroundColors?: {
24
- light: string;
25
- dark?: string;
26
- };
27
- }
28
-
29
- export function EditorBody({
30
- blocks,
31
- onBlockAdd,
32
- onBlockUpdate,
33
- onBlockDelete,
34
- onBlockMove,
35
- darkMode = true,
36
- backgroundColors,
37
- }: EditorBodyProps) {
38
- // --- State ---
39
- const [dragOverIndex, setDragOverIndex] = useState<number | null>(null);
40
- const [isDragging, setIsDragging] = useState(false);
41
- const [draggedBlockId, setDraggedBlockId] = useState<string | null>(null);
42
- const [dropIndicatorPosition, setDropIndicatorPosition] = useState<{ top: number; left: number; width: number } | null>(null);
43
- const [calculatedInsertIndex, setCalculatedInsertIndex] = useState<number | null>(null);
44
-
45
- // --- Refs ---
46
- const containerRef = useRef<HTMLDivElement>(null);
47
- const blockRefs = useRef<Map<string, HTMLDivElement>>(new Map());
48
-
49
- // --- Cleanup & Event Listeners ---
50
- useEffect(() => {
51
- const handleClearIndicator = () => {
52
- setDropIndicatorPosition(null);
53
- setDragOverIndex(null);
54
- };
55
-
56
- const container = containerRef.current;
57
- if (container) {
58
- container.addEventListener('clear-drop-indicator', handleClearIndicator);
59
- return () => {
60
- container.removeEventListener('clear-drop-indicator', handleClearIndicator);
61
- };
62
- }
63
- }, []);
64
-
65
- useEffect(() => {
66
- const handleGlobalDragEnd = () => {
67
- setDropIndicatorPosition(null);
68
- setDragOverIndex(null);
69
- setIsDragging(false);
70
- setDraggedBlockId(null);
71
- setCalculatedInsertIndex(null);
72
- };
73
-
74
- document.addEventListener('dragend', handleGlobalDragEnd);
75
- return () => {
76
- document.removeEventListener('dragend', handleGlobalDragEnd);
77
- };
78
- }, []);
79
-
80
- // --- Helper Functions ---
81
- const setBlockRef = (blockId: string) => (el: HTMLDivElement | null) => {
82
- if (el) {
83
- blockRefs.current.set(blockId, el);
84
- } else {
85
- blockRefs.current.delete(blockId);
86
- }
87
- };
88
-
89
- // --- Drag & Drop Logic ---
90
-
91
- const handleDragStart = (e: React.DragEvent) => {
92
- // This is called when dragging starts from the container
93
- // The actual block drag start is handled in BlockWrapper
94
- setIsDragging(true);
95
- };
96
-
97
- const handleDragOver = (e: React.DragEvent, index: number, element?: HTMLElement) => {
98
- e.preventDefault();
99
- e.stopPropagation();
100
-
101
- // Check if we're dragging over a nested container - if so, clear our indicator
102
- const target = e.target as HTMLElement;
103
- const nestedContainer = target.closest('[data-layout-container]');
104
- if (nestedContainer && nestedContainer !== containerRef.current) {
105
- // We're over a nested container, clear our indicator
106
- setDropIndicatorPosition(null);
107
- setDragOverIndex(null);
108
- return;
109
- }
110
-
111
- setDragOverIndex(index);
112
-
113
- // Calculate position for absolute drop indicator - always show between blocks
114
- const container = containerRef.current;
115
- if (container && element) {
116
- requestAnimationFrame(() => {
117
- // Double-check refs are still valid inside RAF callback
118
- if (!containerRef.current) return;
119
-
120
- const containerRect = containerRef.current.getBoundingClientRect();
121
- const elementRect = element.getBoundingClientRect();
122
- const mouseY = e.clientY;
123
- const relativeTop = mouseY - containerRect.top;
124
-
125
- const elementTop = elementRect.top - containerRect.top;
126
- const elementBottom = elementRect.bottom - containerRect.top;
127
- const elementCenter = elementTop + elementRect.height / 2;
128
-
129
- // Calculate width - use container width minus padding (32px on each side)
130
- const padding = 32;
131
- const width = containerRect.width - (padding * 2);
132
-
133
- let finalTop: number;
134
-
135
- // Determine if we should show above or below the element
136
- if (relativeTop < elementCenter) {
137
- // Show above this block - position between previous block and current block
138
- if (index === 0) {
139
- // First block - show at top of container (before first block)
140
- finalTop = 0;
141
- } else {
142
- // Get previous block to find the gap
143
- const prevBlock = blocks[index - 1];
144
- const prevBlockEl = blockRefs.current.get(prevBlock.id);
145
- if (prevBlockEl) {
146
- const prevBlockRect = prevBlockEl.getBoundingClientRect();
147
- const prevBlockBottom = prevBlockRect.bottom - containerRect.top;
148
- // Position in the middle of the gap (mb-6 = 24px margin)
149
- finalTop = prevBlockBottom + 12; // Half of the 24px gap
150
- } else {
151
- finalTop = elementTop;
152
- }
153
- }
154
- } else {
155
- // Show below this block - position between current block and next block
156
- if (index === blocks.length - 1) {
157
- // Last block - show after it
158
- finalTop = elementBottom;
159
- } else {
160
- // Get next block to find the gap
161
- const nextBlock = blocks[index + 1];
162
- const nextBlockEl = blockRefs.current.get(nextBlock.id);
163
- if (nextBlockEl) {
164
- const nextBlockRect = nextBlockEl.getBoundingClientRect();
165
- const nextBlockTop = nextBlockRect.top - containerRect.top;
166
- // Position in the middle of the gap
167
- finalTop = elementBottom + (nextBlockTop - elementBottom) / 2;
168
- } else {
169
- finalTop = elementBottom;
170
- }
171
- }
172
- }
173
-
174
- setDropIndicatorPosition({
175
- top: finalTop,
176
- left: padding,
177
- width: width,
178
- });
179
- });
180
- }
181
- };
182
-
183
- const handleDragLeave = (e: React.DragEvent) => {
184
- // Only clear if we're actually leaving the container
185
- // Check if we're moving to a child element (nested container)
186
- const relatedTarget = e.relatedTarget as Node;
187
- if (!e.currentTarget.contains(relatedTarget)) {
188
- // Check if relatedTarget is inside a nested LayoutContainer
189
- const isMovingToNested = relatedTarget && (relatedTarget as HTMLElement).closest('[data-layout-container]');
190
- if (!isMovingToNested) {
191
- setDragOverIndex(null);
192
- setDropIndicatorPosition(null);
193
- setCalculatedInsertIndex(null);
194
- setIsDragging(false);
195
- }
196
- }
197
- };
198
-
199
- const handleDrop = (e: React.DragEvent, index: number, containerId?: string) => {
200
- e.preventDefault();
201
- e.stopPropagation();
202
-
203
- const dataTransferBlockId = e.dataTransfer.getData('block-id');
204
- const globalBlockId = typeof window !== 'undefined' ? (window as any).__DRAGGED_BLOCK_ID__ : null;
205
- const blockId = dataTransferBlockId || globalBlockId;
206
- const blockType = e.dataTransfer.getData('block-type');
207
-
208
- console.log('[EditorBody] Drop Event:', {
209
- index,
210
- containerId,
211
- dataTransferBlockId,
212
- globalBlockId,
213
- resolvedBlockId: blockId,
214
- blockType,
215
- currentBlocks: blocks.map(b => ({ id: b.id, type: b.type })),
216
- rootBlockIds: blocks.map(b => b.id),
217
- });
218
-
219
- // Clear the global dragged block ID
220
- if (typeof window !== 'undefined') {
221
- (window as any).__DRAGGED_BLOCK_ID__ = null;
222
- }
223
-
224
- if (blockId) {
225
- // Moving existing block - check if it's in root or nested
226
- const currentIndex = blocks.findIndex(b => b.id === blockId);
227
- console.log('[EditorBody] Block location check:', {
228
- blockId,
229
- currentIndex,
230
- isInRoot: currentIndex !== -1,
231
- targetIndex: index,
232
- containerId,
233
- });
234
-
235
- if (currentIndex !== -1) {
236
- // Block is in root level - move to container or within root
237
- if (containerId) {
238
- // Moving from root to container
239
- console.log('[EditorBody] Moving from root to container:', { blockId, index, containerId });
240
- onBlockMove(blockId, index, containerId);
241
- } else if (currentIndex !== index) {
242
- // Moving within root level
243
- const targetIndex = currentIndex < index ? index - 1 : index;
244
- console.log('[EditorBody] Moving within root:', { blockId, currentIndex, targetIndex });
245
- onBlockMove(blockId, targetIndex);
246
- } else {
247
- console.log('[EditorBody] Block already at target position, no move needed');
248
- }
249
- } else {
250
- // Block is nested somewhere - need to move it to this location
251
- console.log('[EditorBody] Moving nested block to root:', { blockId, index, containerId: containerId || 'root' });
252
- // Pass undefined containerId to move to root
253
- onBlockMove(blockId, index, undefined);
254
- }
255
- } else if (blockType) {
256
- // Adding new block from library
257
- console.log('[EditorBody] Adding new block from library:', { blockType, index, containerId });
258
- onBlockAdd(blockType, index, containerId);
259
- } else {
260
- console.warn('[EditorBody] Drop event with no block ID or type!');
261
- }
262
-
263
- setDragOverIndex(null);
264
- setIsDragging(false);
265
- setDraggedBlockId(null);
266
- setDropIndicatorPosition(null);
267
- setCalculatedInsertIndex(null);
268
- };
269
-
270
- const handleBodyDragOver = (e: React.DragEvent) => {
271
- e.preventDefault();
272
- e.stopPropagation();
273
-
274
- // Check if we're dragging over a nested container - if so, clear our indicator
275
- const target = e.target as HTMLElement;
276
- const nestedContainer = target.closest('[data-layout-container]');
277
- if (nestedContainer && nestedContainer !== containerRef.current) {
278
- // We're over a nested container, clear our indicator
279
- setDropIndicatorPosition(null);
280
- setDragOverIndex(null);
281
- setCalculatedInsertIndex(null);
282
- setIsDragging(false);
283
- return;
284
- }
285
-
286
- setIsDragging(true);
287
-
288
- // Calculate drop indicator position based on mouse Y position relative to blocks
289
- const container = containerRef.current;
290
- if (container && blocks.length > 0) {
291
- requestAnimationFrame(() => {
292
- if (!containerRef.current) return;
293
-
294
- const containerRect = containerRef.current.getBoundingClientRect();
295
- const mouseY = e.clientY;
296
- const relativeTop = mouseY - containerRect.top;
297
- const padding = 32;
298
- const width = containerRect.width - (padding * 2);
299
-
300
- // Find the closest insertion point based on block positions - always between blocks
301
- let insertIndex = blocks.length; // Default to end
302
- let indicatorTop = containerRect.height; // Default to bottom
303
-
304
- // Check each block to find where to insert
305
- for (let i = 0; i < blocks.length; i++) {
306
- const blockEl = blockRefs.current.get(blocks[i].id);
307
- if (blockEl) {
308
- const blockRect = blockEl.getBoundingClientRect();
309
- const blockTop = blockRect.top - containerRect.top;
310
- const blockBottom = blockRect.bottom - containerRect.top;
311
- const blockCenter = blockTop + blockRect.height / 2;
312
-
313
- // If mouse is above this block's center, insert before it
314
- if (relativeTop < blockCenter) {
315
- insertIndex = i;
316
- if (i === 0) {
317
- // First block - show at top
318
- indicatorTop = 0;
319
- } else {
320
- // Get previous block to find the gap
321
- const prevBlock = blocks[i - 1];
322
- const prevBlockEl = blockRefs.current.get(prevBlock.id);
323
- if (prevBlockEl) {
324
- const prevBlockRect = prevBlockEl.getBoundingClientRect();
325
- const prevBlockBottom = prevBlockRect.bottom - containerRect.top;
326
- // Position in the middle of the gap
327
- indicatorTop = prevBlockBottom + (blockTop - prevBlockBottom) / 2;
328
- } else {
329
- indicatorTop = blockTop;
330
- }
331
- }
332
- break;
333
- }
334
- // If mouse is below this block's center, check if we should insert after it
335
- else if (i === blocks.length - 1 || relativeTop < blockBottom) {
336
- insertIndex = i + 1;
337
- if (i === blocks.length - 1) {
338
- // Last block - show after it
339
- indicatorTop = blockBottom;
340
- } else {
341
- // Get next block to find the gap
342
- const nextBlock = blocks[i + 1];
343
- const nextBlockEl = blockRefs.current.get(nextBlock.id);
344
- if (nextBlockEl) {
345
- const nextBlockRect = nextBlockEl.getBoundingClientRect();
346
- const nextBlockTop = nextBlockRect.top - containerRect.top;
347
- // Position in the middle of the gap
348
- indicatorTop = blockBottom + (nextBlockTop - blockBottom) / 2;
349
- } else {
350
- indicatorTop = blockBottom;
351
- }
352
- }
353
- break;
354
- }
355
- }
356
- }
357
-
358
- // If we didn't find a position, use the last block's bottom
359
- if (insertIndex === blocks.length) {
360
- const lastBlockEl = blockRefs.current.get(blocks[blocks.length - 1].id);
361
- if (lastBlockEl) {
362
- const lastBlockRect = lastBlockEl.getBoundingClientRect();
363
- indicatorTop = lastBlockRect.bottom - containerRect.top;
364
- }
365
- }
366
-
367
- setCalculatedInsertIndex(insertIndex);
368
- setDropIndicatorPosition({
369
- top: indicatorTop,
370
- left: padding,
371
- width: width,
372
- });
373
- });
374
- } else if (container) {
375
- // No blocks, show indicator at top
376
- requestAnimationFrame(() => {
377
- if (!containerRef.current) return;
378
- const containerRect = containerRef.current.getBoundingClientRect();
379
- const padding = 32;
380
- const width = containerRect.width - (padding * 2);
381
- setCalculatedInsertIndex(0);
382
- setDropIndicatorPosition({
383
- top: 0,
384
- left: padding,
385
- width: width,
386
- });
387
- });
388
- }
389
- };
390
-
391
- const handleBodyDrop = (e: React.DragEvent) => {
392
- e.preventDefault();
393
- e.stopPropagation();
394
-
395
- const dataTransferBlockId = e.dataTransfer.getData('block-id');
396
- const globalBlockId = typeof window !== 'undefined' ? (window as any).__DRAGGED_BLOCK_ID__ : null;
397
- const blockId = dataTransferBlockId || globalBlockId;
398
- const blockType = e.dataTransfer.getData('block-type');
399
-
400
- // Use the calculated insert index if available, otherwise calculate it now
401
- let targetIndex = calculatedInsertIndex !== null ? calculatedInsertIndex : blocks.length;
402
-
403
- // If we don't have a calculated index, calculate it based on mouse position
404
- if (calculatedInsertIndex === null && containerRef.current && blocks.length > 0) {
405
- const containerRect = containerRef.current.getBoundingClientRect();
406
- const mouseY = e.clientY;
407
- const relativeTop = mouseY - containerRect.top;
408
-
409
- for (let i = 0; i < blocks.length; i++) {
410
- const blockEl = blockRefs.current.get(blocks[i].id);
411
- if (blockEl) {
412
- const blockRect = blockEl.getBoundingClientRect();
413
- const blockTop = blockRect.top - containerRect.top;
414
- const blockCenter = blockTop + blockRect.height / 2;
415
-
416
- if (relativeTop < blockCenter) {
417
- targetIndex = i;
418
- break;
419
- } else if (i === blocks.length - 1) {
420
- targetIndex = blocks.length;
421
- break;
422
- }
423
- }
424
- }
425
- }
426
-
427
- console.log('[EditorBody] Body Drop Event:', {
428
- dataTransferBlockId,
429
- globalBlockId,
430
- resolvedBlockId: blockId,
431
- blockType,
432
- calculatedInsertIndex,
433
- targetIndex,
434
- currentBlocksCount: blocks.length,
435
- rootBlockIds: blocks.map(b => b.id),
436
- });
437
-
438
- // Clear the global dragged block ID
439
- if (typeof window !== 'undefined') {
440
- (window as any).__DRAGGED_BLOCK_ID__ = null;
441
- }
442
-
443
- if (blockId) {
444
- // Moving existing block to calculated position
445
- const currentIndex = blocks.findIndex(b => b.id === blockId);
446
- console.log('[EditorBody] Body drop - block location:', {
447
- blockId,
448
- currentIndex,
449
- isInRoot: currentIndex !== -1,
450
- targetIndex,
451
- });
452
-
453
- if (currentIndex !== -1) {
454
- // Already in root, move to target position
455
- if (currentIndex !== targetIndex) {
456
- // Adjust for removal if moving forward
457
- const adjustedIndex = currentIndex < targetIndex ? targetIndex - 1 : targetIndex;
458
- console.log('[EditorBody] Moving within root:', { blockId, currentIndex, adjustedIndex });
459
- onBlockMove(blockId, Math.max(0, adjustedIndex));
460
- }
461
- } else {
462
- // Block is nested - move it to root level at target position
463
- console.log('[EditorBody] Moving nested block to root:', { blockId, targetIndex });
464
- onBlockMove(blockId, targetIndex, undefined);
465
- }
466
- } else if (blockType) {
467
- // Adding new block at calculated position
468
- console.log('[EditorBody] Adding new block:', { blockType, index: targetIndex });
469
- onBlockAdd(blockType, targetIndex);
470
- } else {
471
- console.warn('[EditorBody] Body drop with no block ID or type!');
472
- }
473
-
474
- setIsDragging(false);
475
- setDragOverIndex(null);
476
- setDraggedBlockId(null);
477
- setDropIndicatorPosition(null);
478
- setCalculatedInsertIndex(null);
479
- };
480
-
481
- return (
482
- <div
483
- ref={containerRef}
484
- className={`relative w-full rounded-[2.5rem] border shadow-lg min-h-[400px] transition-all bg-transparent ${darkMode
485
- ? 'border-neutral-200 dark:border-neutral-800 shadow-neutral-200/50 dark:shadow-neutral-900/50'
486
- : 'border-neutral-200 shadow-neutral-200/50'
487
- }`}
488
- onDragOver={handleBodyDragOver}
489
- onDrop={handleBodyDrop}
490
- onDragLeave={handleDragLeave}
491
- onDragStart={handleDragStart}
492
- onDragEnd={() => {
493
- setDropIndicatorPosition(null);
494
- setDragOverIndex(null);
495
- setIsDragging(false);
496
- setDraggedBlockId(null);
497
- setCalculatedInsertIndex(null);
498
- }}
499
- >
500
- {/* 1. Visual Indicator Overlay */}
501
- {dropIndicatorPosition && isDragging && (
502
- <DropIndicator position={dropIndicatorPosition} darkMode={darkMode} />
503
- )}
504
-
505
- <div
506
- className="flex flex-col p-8"
507
- onDragOver={(e) => {
508
- // Only handle if not over a block or nested container
509
- const target = e.target as HTMLElement;
510
- const isOverBlock = target.closest('[data-block-wrapper]');
511
- const isOverNestedContainer = target.closest('[data-layout-container]') && target.closest('[data-layout-container]') !== containerRef.current;
512
-
513
- if (!isOverBlock && !isOverNestedContainer) {
514
- handleBodyDragOver(e);
515
- }
516
- }}
517
- onDrop={(e) => {
518
- // Only handle if not over a block or nested container
519
- const target = e.target as HTMLElement;
520
- const isOverBlock = target.closest('[data-block-wrapper]');
521
- const isOverNestedContainer = target.closest('[data-layout-container]') && target.closest('[data-layout-container]') !== containerRef.current;
522
-
523
- if (!isOverBlock && !isOverNestedContainer) {
524
- handleBodyDrop(e);
525
- }
526
- }}
527
- >
528
- {/* 2. Content Area */}
529
- {blocks.length === 0 ? (
530
- <EmptyState isDragging={isDragging} darkMode={darkMode} />
531
- ) : (
532
- blocks.map((block, index) => (
533
- <Fragment key={block.id}>
534
- {/* Visual Drop Zone - appears between blocks when dragging */}
535
- {index > 0 && (
536
- <div
537
- className={`h-6 transition-all duration-200 ${isDragging && dragOverIndex === index
538
- ? 'bg-primary/5 border-y border-dashed border-primary/20 rounded-lg'
539
- : 'bg-transparent'
540
- }`}
541
- />
542
- )}
543
-
544
- {/* Block Container */}
545
- <div
546
- ref={setBlockRef(block.id)}
547
- onDragOver={(e) => {
548
- const blockEl = blockRefs.current.get(block.id);
549
- if (blockEl) {
550
- handleDragOver(e, index, blockEl);
551
- }
552
- }}
553
- onDragLeave={handleDragLeave}
554
- onDrop={(e) => handleDrop(e, index)}
555
- className="relative mb-6 last:mb-0"
556
- >
557
- <BlockWrapper
558
- block={block}
559
- onUpdate={(data) => onBlockUpdate(block.id, data)}
560
- onDelete={() => onBlockDelete(block.id)}
561
- onMoveUp={index > 0 ? () => onBlockMove(block.id, index - 1) : undefined}
562
- onMoveDown={index < blocks.length - 1 ? () => onBlockMove(block.id, index + 1) : undefined}
563
- allBlocks={blocks}
564
- />
565
- </div>
566
- </Fragment>
567
- ))
568
- )}
569
- </div>
570
- </div>
571
- );
572
- }
573
-
574
- /**
575
- * Visual Line that shows where the block will land
576
- */
577
- function DropIndicator({ position, darkMode }: { position: { top: number; left: number; width: number }; darkMode: boolean }) {
578
- return (
579
- <div
580
- className="absolute z-50 pointer-events-none"
581
- style={{
582
- top: `${position.top - 12}px`,
583
- left: `${position.left}px`,
584
- width: `${position.width}px`,
585
- height: '24px',
586
- }}
587
- >
588
- {/* Drop zone background */}
589
- <div className={`absolute inset-0 rounded-lg border border-dashed backdrop-blur-sm ${darkMode
590
- ? 'bg-primary/10 dark:bg-primary/20 border-primary dark:border-primary/60'
591
- : 'bg-primary/10 border-primary'
592
- }`} />
593
-
594
- {/* Center line indicator */}
595
- <div className={`absolute top-1/2 left-0 right-0 h-0.5 rounded-full transform -translate-y-1/2 ${darkMode ? 'bg-primary dark:bg-primary/80' : 'bg-primary'
596
- }`} />
597
-
598
- {/* Drop icon indicator */}
599
- <div className="absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2">
600
- <div className={`w-6 h-6 rounded-full flex items-center justify-center shadow-lg shadow-primary/30 ${darkMode ? 'bg-primary dark:bg-primary/90' : 'bg-primary'
601
- }`}>
602
- <div className={`w-2 h-2 rounded-full ${darkMode ? 'bg-white dark:bg-neutral-900' : 'bg-white'
603
- }`} />
604
- </div>
605
- </div>
606
- </div>
607
- );
608
- }
609
-
610
- /**
611
- * Placeholder when the editor is empty
612
- */
613
- function EmptyState({ isDragging, darkMode }: { isDragging: boolean; darkMode: boolean }) {
614
- return (
615
- <div
616
- className={`flex flex-col items-center justify-center py-20 px-8 rounded-2xl border border-dashed transition-all ${darkMode
617
- ? isDragging
618
- ? 'border-primary/30 bg-primary/5 dark:bg-primary/10'
619
- : 'border-gray-200/50 dark:border-neutral-700/50 bg-neutral-50/50 dark:bg-neutral-800/30'
620
- : isDragging
621
- ? 'border-primary/30 bg-primary/5'
622
- : 'border-gray-200/50 bg-neutral-50/50'
623
- }`}
624
- >
625
- <div
626
- className={`p-4 rounded-full mb-4 transition-colors ${darkMode
627
- ? isDragging
628
- ? 'bg-primary/10 dark:bg-primary/20'
629
- : 'bg-neutral-100 dark:bg-neutral-800'
630
- : isDragging
631
- ? 'bg-primary/10'
632
- : 'bg-neutral-100'
633
- }`}
634
- >
635
- <Plus
636
- size={24}
637
- className={`transition-colors ${darkMode
638
- ? isDragging
639
- ? 'text-primary'
640
- : 'text-neutral-400 dark:text-neutral-500'
641
- : isDragging
642
- ? 'text-primary'
643
- : 'text-neutral-400'
644
- }`}
645
- />
646
- </div>
647
- <p
648
- className={`text-sm font-black uppercase tracking-wider transition-colors ${darkMode
649
- ? isDragging
650
- ? 'text-primary'
651
- : 'text-neutral-500 dark:text-neutral-400'
652
- : isDragging
653
- ? 'text-primary'
654
- : 'text-neutral-500'
655
- }`}
656
- >
657
- {isDragging ? 'Drop Block Here' : 'Drop a component here'}
658
- </p>
659
- <p className={`text-xs mt-2 ${darkMode ? 'text-neutral-400 dark:text-neutral-500' : 'text-neutral-400'
660
- }`}>
661
- Drag blocks from the library to get started
662
- </p>
663
- </div>
664
- );
665
- }
@@ -1,18 +0,0 @@
1
- export interface EditorHeaderProps {
2
- isLibraryOpen: boolean;
3
- onLibraryToggle: () => void;
4
- isPreviewMode: boolean;
5
- onPreviewToggle: () => void;
6
- isSidebarOpen: boolean;
7
- onSidebarToggle: () => void;
8
- isSaving: boolean;
9
- onSave: (publish?: boolean) => Promise<void>;
10
- onSaveError: (error: string | null) => void;
11
- autoSaveEnabled?: boolean;
12
- onAutoSaveToggle?: (enabled: boolean) => void;
13
- isDirty?: boolean;
14
- autoSaveCountdown?: number | null;
15
- autoSaveStatus?: 'idle' | 'saving' | 'saved' | 'error';
16
- }
17
- export declare function EditorHeader({ isLibraryOpen, onLibraryToggle, isPreviewMode, onPreviewToggle, isSidebarOpen, onSidebarToggle, isSaving, onSave, onSaveError, autoSaveEnabled, onAutoSaveToggle, isDirty, autoSaveCountdown, autoSaveStatus, }: EditorHeaderProps): import("react/jsx-runtime").JSX.Element;
18
- //# sourceMappingURL=EditorHeader.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"EditorHeader.d.ts","sourceRoot":"","sources":["EditorHeader.tsx"],"names":[],"mappings":"AAOA,MAAM,WAAW,iBAAiB;IAC9B,aAAa,EAAE,OAAO,CAAC;IACvB,eAAe,EAAE,MAAM,IAAI,CAAC;IAC5B,aAAa,EAAE,OAAO,CAAC;IACvB,eAAe,EAAE,MAAM,IAAI,CAAC;IAC5B,aAAa,EAAE,OAAO,CAAC;IACvB,eAAe,EAAE,MAAM,IAAI,CAAC;IAC5B,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,CAAC,OAAO,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7C,WAAW,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IAC5C,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,gBAAgB,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IAC9C,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,cAAc,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,GAAG,OAAO,CAAC;CAC1D;AAED,wBAAgB,YAAY,CAAC,EACzB,aAAa,EACb,eAAe,EACf,aAAa,EACb,eAAe,EACf,aAAa,EACb,eAAe,EACf,QAAQ,EACR,MAAM,EACN,WAAW,EACX,eAAuB,EACvB,gBAAgB,EAChB,OAAe,EACf,iBAAwB,EACxB,cAAuB,GAC1B,EAAE,iBAAiB,2CAmOnB"}