@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.
Files changed (276) hide show
  1. package/package.json +58 -59
  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,45 +0,0 @@
1
- /**
2
- * Editor Context
3
- * React Context for managing editor state
4
- * Multi-Tenant: Accepts custom blocks from client applications
5
- */
6
- import React from 'react';
7
- import { EditorContextValue, EditorState } from './types';
8
- import { Block } from '../types/block';
9
- import { ClientBlockDefinition } from '../types/block';
10
- /**
11
- * Editor Provider Props
12
- */
13
- export interface EditorProviderProps {
14
- children: React.ReactNode;
15
- /** Initial state (optional) */
16
- initialState?: Partial<EditorState>;
17
- /** Callback when save is triggered */
18
- onSave?: (state: EditorState, heroBlock?: Block | null) => Promise<void>;
19
- /**
20
- * Custom blocks from client application
21
- * These blocks will be registered in the BlockRegistry on mount
22
- */
23
- customBlocks?: ClientBlockDefinition[];
24
- /** Enable dark mode for content area and wrappers (default: true) */
25
- darkMode?: boolean;
26
- /** Background colors for the editor */
27
- backgroundColors?: {
28
- /** Background color for light mode (REQUIRED) */
29
- light: string;
30
- /** Background color for dark mode (optional) */
31
- dark?: string;
32
- };
33
- }
34
- /**
35
- * Editor Provider
36
- * Provides editor state and actions to child components
37
- * Automatically registers client-provided blocks on mount
38
- */
39
- export declare function EditorProvider({ children, initialState, onSave, customBlocks, darkMode, backgroundColors }: EditorProviderProps): import("react/jsx-runtime").JSX.Element;
40
- /**
41
- * Hook to access editor context
42
- * @throws Error if used outside EditorProvider
43
- */
44
- export declare function useEditor(): EditorContextValue;
45
- //# sourceMappingURL=EditorContext.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"EditorContext.d.ts","sourceRoot":"","sources":["EditorContext.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAmG,MAAM,OAAO,CAAC;AAExH,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAoC,MAAM,SAAS,CAAC;AAC5F,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAGvC,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAMvD;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAChC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,+BAA+B;IAC/B,YAAY,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;IACpC,sCAAsC;IACtC,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,EAAE,SAAS,CAAC,EAAE,KAAK,GAAG,IAAI,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACzE;;;OAGG;IACH,YAAY,CAAC,EAAE,qBAAqB,EAAE,CAAC;IACvC,qEAAqE;IACrE,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,uCAAuC;IACvC,gBAAgB,CAAC,EAAE;QACf,iDAAiD;QACjD,KAAK,EAAE,MAAM,CAAC;QACd,gDAAgD;QAChD,IAAI,CAAC,EAAE,MAAM,CAAC;KACjB,CAAC;CACL;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,EAC3B,QAAQ,EACR,YAAY,EACZ,MAAM,EACN,YAAiB,EACjB,QAAe,EACf,gBAAgB,EACnB,EAAE,mBAAmB,2CAqNrB;AAED;;;GAGG;AACH,wBAAgB,SAAS,IAAI,kBAAkB,CAM9C"}
@@ -1,215 +0,0 @@
1
- /**
2
- * Editor Context
3
- * React Context for managing editor state
4
- * Multi-Tenant: Accepts custom blocks from client applications
5
- */
6
- 'use client';
7
- import { jsx as _jsx } from "react/jsx-runtime";
8
- import { createContext, useContext, useReducer, useCallback, useMemo, useEffect, useRef, useState } from 'react';
9
- import { editorReducer } from './reducer';
10
- import { initialEditorState } from './types';
11
- import { blockRegistry } from '../registry/BlockRegistry';
12
- import { registerLayoutBlocks } from '../lib/layouts/registerLayoutBlocks';
13
- // Create the context
14
- const EditorContext = createContext(null);
15
- /**
16
- * Editor Provider
17
- * Provides editor state and actions to child components
18
- * Automatically registers client-provided blocks on mount
19
- */
20
- export function EditorProvider({ children, initialState, onSave, customBlocks = [], darkMode = true, backgroundColors }) {
21
- // Register core layout blocks on mount
22
- useEffect(() => {
23
- registerLayoutBlocks();
24
- }, []);
25
- // Register client blocks on mount
26
- useEffect(() => {
27
- if (customBlocks && customBlocks.length > 0) {
28
- try {
29
- blockRegistry.registerClientBlocks(customBlocks);
30
- }
31
- catch (error) {
32
- console.error('[EditorContext] Failed to register custom blocks:', error);
33
- }
34
- }
35
- }, [customBlocks]);
36
- const [state, dispatch] = useReducer(editorReducer, Object.assign(Object.assign({}, initialEditorState), initialState));
37
- // Use a ref to always have access to the latest state in callbacks
38
- const stateRef = useRef(state);
39
- stateRef.current = state;
40
- // History state for undo/redo
41
- const [history, setHistory] = useState([]);
42
- const [historyIndex, setHistoryIndex] = useState(-1);
43
- const isRestoringRef = useRef(false);
44
- const MAX_HISTORY = 50; // Limit history to prevent memory issues
45
- // Save current state to history after state changes (but not during undo/redo)
46
- // Debounce history updates to avoid excessive re-renders
47
- const historyTimeoutRef = useRef(null);
48
- useEffect(() => {
49
- if (isRestoringRef.current) {
50
- isRestoringRef.current = false;
51
- return;
52
- }
53
- // Clear existing timeout
54
- if (historyTimeoutRef.current) {
55
- clearTimeout(historyTimeoutRef.current);
56
- }
57
- // Debounce history updates to reduce re-renders
58
- historyTimeoutRef.current = setTimeout(() => {
59
- // Save current state to history
60
- setHistory(prev => {
61
- const newHistory = [...prev];
62
- // Remove any future history if we're not at the end
63
- if (historyIndex < newHistory.length - 1) {
64
- newHistory.splice(historyIndex + 1);
65
- }
66
- // Add current state
67
- newHistory.push(Object.assign({}, state));
68
- // Limit history size
69
- if (newHistory.length > MAX_HISTORY) {
70
- newHistory.shift();
71
- return newHistory;
72
- }
73
- return newHistory;
74
- });
75
- setHistoryIndex(prev => {
76
- const newIndex = prev + 1;
77
- return newIndex >= MAX_HISTORY ? MAX_HISTORY - 1 : newIndex;
78
- });
79
- }, 300); // Debounce by 300ms
80
- return () => {
81
- if (historyTimeoutRef.current) {
82
- clearTimeout(historyTimeoutRef.current);
83
- }
84
- };
85
- }, [state.blocks, state.title, state.slug, state.seo, state.metadata, state.status, historyIndex]);
86
- // Helper: Add a new block (supports nested containers)
87
- const addBlock = useCallback((type, index, containerId) => {
88
- const blockDefinition = blockRegistry.get(type);
89
- if (!blockDefinition) {
90
- console.warn(`Block type "${type}" not found in registry. Available types:`, blockRegistry.getAll().map(b => b.type).join(', '));
91
- return;
92
- }
93
- const newBlock = {
94
- id: `block-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`,
95
- type,
96
- data: Object.assign({}, blockDefinition.defaultData),
97
- };
98
- dispatch({ type: 'ADD_BLOCK', payload: { block: newBlock, index, containerId } });
99
- }, []);
100
- // Helper: Update a block
101
- const updateBlock = useCallback((id, data) => {
102
- dispatch({ type: 'UPDATE_BLOCK', payload: { id, data } });
103
- }, []);
104
- // Helper: Delete a block
105
- const deleteBlock = useCallback((id) => {
106
- dispatch({ type: 'DELETE_BLOCK', payload: { id } });
107
- }, []);
108
- // Helper: Duplicate a block
109
- const duplicateBlock = useCallback((id) => {
110
- dispatch({ type: 'DUPLICATE_BLOCK', payload: { id } });
111
- }, []);
112
- // Helper: Move a block (supports nested containers)
113
- const moveBlock = useCallback((id, newIndex, containerId) => {
114
- dispatch({ type: 'MOVE_BLOCK', payload: { id, newIndex, containerId } });
115
- }, []);
116
- // Helper: Load a post
117
- const loadPost = useCallback((post) => {
118
- dispatch({ type: 'LOAD_POST', payload: post });
119
- }, []);
120
- // Helper: Reset editor
121
- const resetEditor = useCallback(() => {
122
- dispatch({ type: 'RESET_EDITOR' });
123
- }, []);
124
- // Helper: Save
125
- // Uses stateRef to always get the latest state, avoiding stale closure issues
126
- const save = useCallback(async (heroBlock) => {
127
- if (onSave) {
128
- // Use stateRef.current to get the absolute latest state
129
- // This ensures we don't have stale closure issues with React state updates
130
- await onSave(stateRef.current, heroBlock);
131
- dispatch({ type: 'MARK_CLEAN' });
132
- }
133
- }, [onSave]);
134
- // Helper: Undo
135
- const undo = useCallback(() => {
136
- if (historyIndex > 0 && history.length > 0) {
137
- const previousState = history[historyIndex - 1];
138
- if (previousState) {
139
- isRestoringRef.current = true;
140
- setHistoryIndex(prev => prev - 1);
141
- dispatch({ type: 'LOAD_POST', payload: {
142
- id: previousState.postId || '',
143
- title: previousState.title,
144
- slug: previousState.slug,
145
- blocks: previousState.blocks,
146
- seo: previousState.seo,
147
- publication: {
148
- status: previousState.status,
149
- authorId: undefined,
150
- },
151
- metadata: previousState.metadata,
152
- createdAt: new Date().toISOString(),
153
- updatedAt: new Date().toISOString(),
154
- } });
155
- }
156
- }
157
- }, [history, historyIndex, dispatch]);
158
- // Helper: Redo
159
- const redo = useCallback(() => {
160
- if (historyIndex < history.length - 1) {
161
- const nextState = history[historyIndex + 1];
162
- if (nextState) {
163
- isRestoringRef.current = true;
164
- setHistoryIndex(prev => prev + 1);
165
- dispatch({ type: 'LOAD_POST', payload: {
166
- id: nextState.postId || '',
167
- title: nextState.title,
168
- slug: nextState.slug,
169
- blocks: nextState.blocks,
170
- seo: nextState.seo,
171
- publication: {
172
- status: nextState.status,
173
- authorId: undefined,
174
- },
175
- metadata: nextState.metadata,
176
- createdAt: new Date().toISOString(),
177
- updatedAt: new Date().toISOString(),
178
- } });
179
- }
180
- }
181
- }, [history, historyIndex, dispatch]);
182
- // Memoize the context value
183
- const value = useMemo(() => ({
184
- state,
185
- dispatch,
186
- darkMode,
187
- backgroundColors,
188
- helpers: {
189
- addBlock,
190
- updateBlock,
191
- deleteBlock,
192
- duplicateBlock,
193
- moveBlock,
194
- loadPost,
195
- resetEditor,
196
- save,
197
- undo,
198
- redo,
199
- },
200
- canUndo: historyIndex > 0 && history.length > 0,
201
- canRedo: historyIndex < history.length - 1,
202
- }), [state, dispatch, darkMode, backgroundColors, addBlock, updateBlock, deleteBlock, duplicateBlock, moveBlock, loadPost, resetEditor, save, undo, redo, historyIndex, history.length]);
203
- return _jsx(EditorContext.Provider, { value: value, children: children });
204
- }
205
- /**
206
- * Hook to access editor context
207
- * @throws Error if used outside EditorProvider
208
- */
209
- export function useEditor() {
210
- const context = useContext(EditorContext);
211
- if (!context) {
212
- throw new Error('useEditor must be used within an EditorProvider');
213
- }
214
- return context;
215
- }
@@ -1,283 +0,0 @@
1
- /**
2
- * Editor Context
3
- * React Context for managing editor state
4
- * Multi-Tenant: Accepts custom blocks from client applications
5
- */
6
-
7
- 'use client';
8
-
9
- import React, { createContext, useContext, useReducer, useCallback, useMemo, useEffect, useRef, useState } from 'react';
10
- import { editorReducer } from './reducer';
11
- import { EditorContextValue, EditorState, EditorAction, initialEditorState } from './types';
12
- import { Block } from '../types/block';
13
- import { BlogPost } from '../types/post';
14
- import { blockRegistry } from '../registry/BlockRegistry';
15
- import { ClientBlockDefinition } from '../types/block';
16
- import { registerLayoutBlocks } from '../lib/layouts/registerLayoutBlocks';
17
-
18
- // Create the context
19
- const EditorContext = createContext<EditorContextValue | null>(null);
20
-
21
- /**
22
- * Editor Provider Props
23
- */
24
- export interface EditorProviderProps {
25
- children: React.ReactNode;
26
- /** Initial state (optional) */
27
- initialState?: Partial<EditorState>;
28
- /** Callback when save is triggered */
29
- onSave?: (state: EditorState, heroBlock?: Block | null) => Promise<void>;
30
- /**
31
- * Custom blocks from client application
32
- * These blocks will be registered in the BlockRegistry on mount
33
- */
34
- customBlocks?: ClientBlockDefinition[];
35
- /** Enable dark mode for content area and wrappers (default: true) */
36
- darkMode?: boolean;
37
- /** Background colors for the editor */
38
- backgroundColors?: {
39
- /** Background color for light mode (REQUIRED) */
40
- light: string;
41
- /** Background color for dark mode (optional) */
42
- dark?: string;
43
- };
44
- }
45
-
46
- /**
47
- * Editor Provider
48
- * Provides editor state and actions to child components
49
- * Automatically registers client-provided blocks on mount
50
- */
51
- export function EditorProvider({
52
- children,
53
- initialState,
54
- onSave,
55
- customBlocks = [],
56
- darkMode = true,
57
- backgroundColors
58
- }: EditorProviderProps) {
59
- // Register core layout blocks on mount
60
- useEffect(() => {
61
- registerLayoutBlocks();
62
- }, []);
63
-
64
- // Register client blocks on mount
65
- useEffect(() => {
66
- if (customBlocks && customBlocks.length > 0) {
67
- try {
68
- blockRegistry.registerClientBlocks(customBlocks);
69
- } catch (error) {
70
- console.error('[EditorContext] Failed to register custom blocks:', error);
71
- }
72
- }
73
- }, [customBlocks]);
74
-
75
- const [state, dispatch] = useReducer(
76
- editorReducer,
77
- { ...initialEditorState, ...initialState }
78
- );
79
-
80
- // Use a ref to always have access to the latest state in callbacks
81
- const stateRef = useRef(state);
82
- stateRef.current = state;
83
-
84
- // History state for undo/redo
85
- const [history, setHistory] = useState<EditorState[]>([]);
86
- const [historyIndex, setHistoryIndex] = useState(-1);
87
- const isRestoringRef = useRef(false);
88
- const MAX_HISTORY = 50; // Limit history to prevent memory issues
89
-
90
- // Save current state to history after state changes (but not during undo/redo)
91
- // Debounce history updates to avoid excessive re-renders
92
- const historyTimeoutRef = useRef<NodeJS.Timeout | null>(null);
93
-
94
- useEffect(() => {
95
- if (isRestoringRef.current) {
96
- isRestoringRef.current = false;
97
- return;
98
- }
99
-
100
- // Clear existing timeout
101
- if (historyTimeoutRef.current) {
102
- clearTimeout(historyTimeoutRef.current);
103
- }
104
-
105
- // Debounce history updates to reduce re-renders
106
- historyTimeoutRef.current = setTimeout(() => {
107
- // Save current state to history
108
- setHistory(prev => {
109
- const newHistory = [...prev];
110
- // Remove any future history if we're not at the end
111
- if (historyIndex < newHistory.length - 1) {
112
- newHistory.splice(historyIndex + 1);
113
- }
114
- // Add current state
115
- newHistory.push({ ...state });
116
- // Limit history size
117
- if (newHistory.length > MAX_HISTORY) {
118
- newHistory.shift();
119
- return newHistory;
120
- }
121
- return newHistory;
122
- });
123
- setHistoryIndex(prev => {
124
- const newIndex = prev + 1;
125
- return newIndex >= MAX_HISTORY ? MAX_HISTORY - 1 : newIndex;
126
- });
127
- }, 300); // Debounce by 300ms
128
-
129
- return () => {
130
- if (historyTimeoutRef.current) {
131
- clearTimeout(historyTimeoutRef.current);
132
- }
133
- };
134
- }, [state.blocks, state.title, state.slug, state.seo, state.metadata, state.status, historyIndex]);
135
-
136
- // Helper: Add a new block (supports nested containers)
137
- const addBlock = useCallback((type: string, index?: number, containerId?: string) => {
138
- const blockDefinition = blockRegistry.get(type);
139
- if (!blockDefinition) {
140
- console.warn(`Block type "${type}" not found in registry. Available types:`,
141
- blockRegistry.getAll().map(b => b.type).join(', '));
142
- return;
143
- }
144
-
145
- const newBlock: Block = {
146
- id: `block-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`,
147
- type,
148
- data: { ...blockDefinition.defaultData },
149
- };
150
-
151
- dispatch({ type: 'ADD_BLOCK', payload: { block: newBlock, index, containerId } });
152
- }, []);
153
-
154
- // Helper: Update a block
155
- const updateBlock = useCallback((id: string, data: Partial<Block['data']>) => {
156
- dispatch({ type: 'UPDATE_BLOCK', payload: { id, data } });
157
- }, []);
158
-
159
- // Helper: Delete a block
160
- const deleteBlock = useCallback((id: string) => {
161
- dispatch({ type: 'DELETE_BLOCK', payload: { id } });
162
- }, []);
163
-
164
- // Helper: Duplicate a block
165
- const duplicateBlock = useCallback((id: string) => {
166
- dispatch({ type: 'DUPLICATE_BLOCK', payload: { id } });
167
- }, []);
168
-
169
- // Helper: Move a block (supports nested containers)
170
- const moveBlock = useCallback((id: string, newIndex: number, containerId?: string) => {
171
- dispatch({ type: 'MOVE_BLOCK', payload: { id, newIndex, containerId } });
172
- }, []);
173
-
174
- // Helper: Load a post
175
- const loadPost = useCallback((post: BlogPost) => {
176
- dispatch({ type: 'LOAD_POST', payload: post });
177
- }, []);
178
-
179
- // Helper: Reset editor
180
- const resetEditor = useCallback(() => {
181
- dispatch({ type: 'RESET_EDITOR' });
182
- }, []);
183
-
184
- // Helper: Save
185
- // Uses stateRef to always get the latest state, avoiding stale closure issues
186
- const save = useCallback(async (heroBlock?: Block | null) => {
187
- if (onSave) {
188
- // Use stateRef.current to get the absolute latest state
189
- // This ensures we don't have stale closure issues with React state updates
190
- await onSave(stateRef.current, heroBlock);
191
- dispatch({ type: 'MARK_CLEAN' });
192
- }
193
- }, [onSave]);
194
-
195
- // Helper: Undo
196
- const undo = useCallback(() => {
197
- if (historyIndex > 0 && history.length > 0) {
198
- const previousState = history[historyIndex - 1];
199
- if (previousState) {
200
- isRestoringRef.current = true;
201
- setHistoryIndex(prev => prev - 1);
202
- dispatch({ type: 'LOAD_POST', payload: {
203
- id: previousState.postId || '',
204
- title: previousState.title,
205
- slug: previousState.slug,
206
- blocks: previousState.blocks,
207
- seo: previousState.seo,
208
- publication: {
209
- status: previousState.status,
210
- authorId: undefined,
211
- },
212
- metadata: previousState.metadata,
213
- createdAt: new Date().toISOString(),
214
- updatedAt: new Date().toISOString(),
215
- } });
216
- }
217
- }
218
- }, [history, historyIndex, dispatch]);
219
-
220
- // Helper: Redo
221
- const redo = useCallback(() => {
222
- if (historyIndex < history.length - 1) {
223
- const nextState = history[historyIndex + 1];
224
- if (nextState) {
225
- isRestoringRef.current = true;
226
- setHistoryIndex(prev => prev + 1);
227
- dispatch({ type: 'LOAD_POST', payload: {
228
- id: nextState.postId || '',
229
- title: nextState.title,
230
- slug: nextState.slug,
231
- blocks: nextState.blocks,
232
- seo: nextState.seo,
233
- publication: {
234
- status: nextState.status,
235
- authorId: undefined,
236
- },
237
- metadata: nextState.metadata,
238
- createdAt: new Date().toISOString(),
239
- updatedAt: new Date().toISOString(),
240
- } });
241
- }
242
- }
243
- }, [history, historyIndex, dispatch]);
244
-
245
- // Memoize the context value
246
- const value = useMemo<EditorContextValue>(
247
- () => ({
248
- state,
249
- dispatch,
250
- darkMode,
251
- backgroundColors,
252
- helpers: {
253
- addBlock,
254
- updateBlock,
255
- deleteBlock,
256
- duplicateBlock,
257
- moveBlock,
258
- loadPost,
259
- resetEditor,
260
- save,
261
- undo,
262
- redo,
263
- },
264
- canUndo: historyIndex > 0 && history.length > 0,
265
- canRedo: historyIndex < history.length - 1,
266
- }),
267
- [state, dispatch, darkMode, backgroundColors, addBlock, updateBlock, deleteBlock, duplicateBlock, moveBlock, loadPost, resetEditor, save, undo, redo, historyIndex, history.length]
268
- );
269
-
270
- return <EditorContext.Provider value={value}>{children}</EditorContext.Provider>;
271
- }
272
-
273
- /**
274
- * Hook to access editor context
275
- * @throws Error if used outside EditorProvider
276
- */
277
- export function useEditor(): EditorContextValue {
278
- const context = useContext(EditorContext);
279
- if (!context) {
280
- throw new Error('useEditor must be used within an EditorProvider');
281
- }
282
- return context;
283
- }
@@ -1,7 +0,0 @@
1
- /**
2
- * State management exports
3
- */
4
- export * from './types';
5
- export * from './reducer';
6
- export * from './EditorContext';
7
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC"}
@@ -1,6 +0,0 @@
1
- /**
2
- * State management exports
3
- */
4
- export * from './types';
5
- export * from './reducer';
6
- export * from './EditorContext';
@@ -1,8 +0,0 @@
1
- /**
2
- * State management exports
3
- */
4
-
5
- export * from './types';
6
- export * from './reducer';
7
- export * from './EditorContext';
8
-
@@ -1,11 +0,0 @@
1
- /**
2
- * Editor Reducer
3
- * Pure function that handles state transitions
4
- */
5
- import { EditorState, EditorAction } from './types';
6
- /**
7
- * Editor Reducer
8
- * Handles all state transitions for the editor
9
- */
10
- export declare function editorReducer(state: EditorState, action: EditorAction): EditorState;
11
- //# sourceMappingURL=reducer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"reducer.d.ts","sourceRoot":"","sources":["reducer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,YAAY,EAAsB,MAAM,SAAS,CAAC;AAqUxE;;;GAGG;AACH,wBAAgB,aAAa,CACzB,KAAK,EAAE,WAAW,EAClB,MAAM,EAAE,YAAY,GACrB,WAAW,CAmWb"}