@jhits/plugin-blog 0.0.14 → 0.0.16

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 (208) hide show
  1. package/package.json +5 -4
  2. package/src/api/categories.ts +43 -0
  3. package/src/api/check-title.ts +60 -0
  4. package/src/api/config-handler.ts +76 -0
  5. package/src/api/handler.ts +418 -0
  6. package/src/api/index.ts +33 -0
  7. package/src/api/route.ts +116 -0
  8. package/src/api/router.ts +128 -0
  9. package/src/api-server.ts +11 -0
  10. package/src/config.ts +161 -0
  11. package/src/hooks/index.d.ts +8 -0
  12. package/src/hooks/index.d.ts.map +1 -0
  13. package/src/hooks/index.ts +9 -0
  14. package/src/hooks/useBlog.d.ts +31 -0
  15. package/src/hooks/useBlog.d.ts.map +1 -0
  16. package/src/hooks/useBlog.ts +85 -0
  17. package/src/hooks/useBlogs.d.ts +39 -0
  18. package/src/hooks/useBlogs.d.ts.map +1 -0
  19. package/src/hooks/useBlogs.ts +123 -0
  20. package/src/hooks/useCategories.d.ts +9 -0
  21. package/src/hooks/useCategories.d.ts.map +1 -0
  22. package/src/hooks/useCategories.ts +76 -0
  23. package/src/index.server.ts +14 -0
  24. package/src/index.tsx +335 -0
  25. package/src/init.tsx +63 -0
  26. package/src/lib/blocks/BlockRenderer.d.ts +54 -0
  27. package/src/lib/blocks/BlockRenderer.d.ts.map +1 -0
  28. package/src/lib/blocks/BlockRenderer.tsx +141 -0
  29. package/src/lib/blocks/index.ts +6 -0
  30. package/src/lib/config-storage.d.ts +30 -0
  31. package/src/lib/config-storage.d.ts.map +1 -0
  32. package/src/lib/config-storage.ts +65 -0
  33. package/src/lib/index.ts +9 -0
  34. package/src/lib/layouts/blocks/ColumnsBlock.d.ts +25 -0
  35. package/src/lib/layouts/blocks/ColumnsBlock.d.ts.map +1 -0
  36. package/src/lib/layouts/blocks/ColumnsBlock.tsx +298 -0
  37. package/src/lib/layouts/blocks/ColumnsBlock.tsx.tmp +81 -0
  38. package/src/lib/layouts/blocks/SectionBlock.d.ts +25 -0
  39. package/src/lib/layouts/blocks/SectionBlock.d.ts.map +1 -0
  40. package/src/lib/layouts/blocks/SectionBlock.tsx +104 -0
  41. package/src/lib/layouts/blocks/index.ts +8 -0
  42. package/src/lib/layouts/index.d.ts +23 -0
  43. package/src/lib/layouts/index.d.ts.map +1 -0
  44. package/src/lib/layouts/index.ts +52 -0
  45. package/src/lib/layouts/registerLayoutBlocks.d.ts +9 -0
  46. package/src/lib/layouts/registerLayoutBlocks.d.ts.map +1 -0
  47. package/src/lib/layouts/registerLayoutBlocks.ts +64 -0
  48. package/src/lib/mappers/apiMapper.d.ts +66 -0
  49. package/src/lib/mappers/apiMapper.d.ts.map +1 -0
  50. package/src/lib/mappers/apiMapper.ts +254 -0
  51. package/src/lib/migration/index.ts +6 -0
  52. package/src/lib/migration/mapper.ts +140 -0
  53. package/src/lib/rich-text/RichTextEditor.d.ts +45 -0
  54. package/src/lib/rich-text/RichTextEditor.d.ts.map +1 -0
  55. package/src/lib/rich-text/RichTextEditor.tsx +826 -0
  56. package/src/lib/rich-text/RichTextPreview.d.ts +16 -0
  57. package/src/lib/rich-text/RichTextPreview.d.ts.map +1 -0
  58. package/src/lib/rich-text/RichTextPreview.tsx +210 -0
  59. package/src/lib/rich-text/index.d.ts +9 -0
  60. package/src/lib/rich-text/index.d.ts.map +1 -0
  61. package/src/lib/rich-text/index.ts +10 -0
  62. package/src/lib/utils/blockHelpers.d.ts +23 -0
  63. package/src/lib/utils/blockHelpers.d.ts.map +1 -0
  64. package/src/lib/utils/blockHelpers.ts +72 -0
  65. package/src/lib/utils/configValidation.d.ts +23 -0
  66. package/src/lib/utils/configValidation.d.ts.map +1 -0
  67. package/src/lib/utils/configValidation.ts +137 -0
  68. package/src/lib/utils/index.ts +8 -0
  69. package/src/lib/utils/slugify.ts +79 -0
  70. package/src/registry/BlockRegistry.d.ts +62 -0
  71. package/src/registry/BlockRegistry.d.ts.map +1 -0
  72. package/src/registry/BlockRegistry.ts +139 -0
  73. package/src/registry/index.d.ts +6 -0
  74. package/src/registry/index.d.ts.map +1 -0
  75. package/src/registry/index.ts +11 -0
  76. package/src/state/EditorContext.d.ts +45 -0
  77. package/src/state/EditorContext.d.ts.map +1 -0
  78. package/src/state/EditorContext.tsx +283 -0
  79. package/src/state/index.d.ts +7 -0
  80. package/src/state/index.d.ts.map +1 -0
  81. package/src/state/index.ts +8 -0
  82. package/src/state/reducer.d.ts +11 -0
  83. package/src/state/reducer.d.ts.map +1 -0
  84. package/src/state/reducer.ts +694 -0
  85. package/src/state/types.d.ts +162 -0
  86. package/src/state/types.d.ts.map +1 -0
  87. package/src/state/types.ts +160 -0
  88. package/src/types/block.d.ts +221 -0
  89. package/src/types/block.d.ts.map +1 -0
  90. package/src/types/block.ts +269 -0
  91. package/src/types/index.d.ts +8 -0
  92. package/src/types/index.d.ts.map +1 -0
  93. package/src/types/index.ts +17 -0
  94. package/src/types/post.d.ts +136 -0
  95. package/src/types/post.d.ts.map +1 -0
  96. package/src/types/post.ts +169 -0
  97. package/src/utils/client.d.ts +48 -0
  98. package/src/utils/client.d.ts.map +1 -0
  99. package/src/utils/client.ts +122 -0
  100. package/src/utils/index.ts +7 -0
  101. package/src/views/CanvasEditor/BlockWrapper.d.ts +16 -0
  102. package/src/views/CanvasEditor/BlockWrapper.d.ts.map +1 -0
  103. package/src/views/CanvasEditor/BlockWrapper.tsx +522 -0
  104. package/src/views/CanvasEditor/CanvasEditorView.d.ts +14 -0
  105. package/src/views/CanvasEditor/CanvasEditorView.d.ts.map +1 -0
  106. package/src/views/CanvasEditor/CanvasEditorView.tsx +337 -0
  107. package/src/views/CanvasEditor/EditorBody.d.ts +22 -0
  108. package/src/views/CanvasEditor/EditorBody.d.ts.map +1 -0
  109. package/src/views/CanvasEditor/EditorBody.tsx +665 -0
  110. package/src/views/CanvasEditor/EditorHeader.d.ts +18 -0
  111. package/src/views/CanvasEditor/EditorHeader.d.ts.map +1 -0
  112. package/src/views/CanvasEditor/EditorHeader.tsx +268 -0
  113. package/src/views/CanvasEditor/LayoutContainer.d.ts +17 -0
  114. package/src/views/CanvasEditor/LayoutContainer.d.ts.map +1 -0
  115. package/src/views/CanvasEditor/LayoutContainer.tsx +322 -0
  116. package/src/views/CanvasEditor/SaveConfirmationModal.d.ts +13 -0
  117. package/src/views/CanvasEditor/SaveConfirmationModal.d.ts.map +1 -0
  118. package/src/views/CanvasEditor/SaveConfirmationModal.tsx +233 -0
  119. package/src/views/CanvasEditor/components/CustomBlockItem.d.ts +14 -0
  120. package/src/views/CanvasEditor/components/CustomBlockItem.d.ts.map +1 -0
  121. package/src/views/CanvasEditor/components/CustomBlockItem.tsx +92 -0
  122. package/src/views/CanvasEditor/components/EditorCanvas.d.ts +29 -0
  123. package/src/views/CanvasEditor/components/EditorCanvas.d.ts.map +1 -0
  124. package/src/views/CanvasEditor/components/EditorCanvas.tsx +160 -0
  125. package/src/views/CanvasEditor/components/EditorLibrary.d.ts +7 -0
  126. package/src/views/CanvasEditor/components/EditorLibrary.d.ts.map +1 -0
  127. package/src/views/CanvasEditor/components/EditorLibrary.tsx +122 -0
  128. package/src/views/CanvasEditor/components/EditorSidebar.d.ts +13 -0
  129. package/src/views/CanvasEditor/components/EditorSidebar.d.ts.map +1 -0
  130. package/src/views/CanvasEditor/components/EditorSidebar.tsx +181 -0
  131. package/src/views/CanvasEditor/components/ErrorBanner.d.ts +6 -0
  132. package/src/views/CanvasEditor/components/ErrorBanner.d.ts.map +1 -0
  133. package/src/views/CanvasEditor/components/ErrorBanner.tsx +31 -0
  134. package/src/views/CanvasEditor/components/FeaturedMediaSection.d.ts +25 -0
  135. package/src/views/CanvasEditor/components/FeaturedMediaSection.d.ts.map +1 -0
  136. package/src/views/CanvasEditor/components/FeaturedMediaSection.tsx +341 -0
  137. package/src/views/CanvasEditor/components/LibraryItem.d.ts +14 -0
  138. package/src/views/CanvasEditor/components/LibraryItem.d.ts.map +1 -0
  139. package/src/views/CanvasEditor/components/LibraryItem.tsx +80 -0
  140. package/src/views/CanvasEditor/components/PrivacySettingsSection.d.ts +15 -0
  141. package/src/views/CanvasEditor/components/PrivacySettingsSection.d.ts.map +1 -0
  142. package/src/views/CanvasEditor/components/PrivacySettingsSection.tsx +212 -0
  143. package/src/views/CanvasEditor/components/index.d.ts +21 -0
  144. package/src/views/CanvasEditor/components/index.d.ts.map +1 -0
  145. package/src/views/CanvasEditor/components/index.ts +28 -0
  146. package/src/views/CanvasEditor/hooks/index.d.ts +10 -0
  147. package/src/views/CanvasEditor/hooks/index.d.ts.map +1 -0
  148. package/src/views/CanvasEditor/hooks/index.ts +10 -0
  149. package/src/views/CanvasEditor/hooks/useHeroBlock.d.ts +8 -0
  150. package/src/views/CanvasEditor/hooks/useHeroBlock.d.ts.map +1 -0
  151. package/src/views/CanvasEditor/hooks/useHeroBlock.ts +103 -0
  152. package/src/views/CanvasEditor/hooks/useKeyboardShortcuts.d.ts +3 -0
  153. package/src/views/CanvasEditor/hooks/useKeyboardShortcuts.d.ts.map +1 -0
  154. package/src/views/CanvasEditor/hooks/useKeyboardShortcuts.ts +142 -0
  155. package/src/views/CanvasEditor/hooks/usePostLoader.d.ts +5 -0
  156. package/src/views/CanvasEditor/hooks/usePostLoader.d.ts.map +1 -0
  157. package/src/views/CanvasEditor/hooks/usePostLoader.ts +39 -0
  158. package/src/views/CanvasEditor/hooks/useRegisteredBlocks.d.ts +2 -0
  159. package/src/views/CanvasEditor/hooks/useRegisteredBlocks.d.ts.map +1 -0
  160. package/src/views/CanvasEditor/hooks/useRegisteredBlocks.ts +55 -0
  161. package/src/views/CanvasEditor/hooks/useUnsavedChanges.d.ts +25 -0
  162. package/src/views/CanvasEditor/hooks/useUnsavedChanges.d.ts.map +1 -0
  163. package/src/views/CanvasEditor/hooks/useUnsavedChanges.ts +339 -0
  164. package/src/views/CanvasEditor/index.d.ts +16 -0
  165. package/src/views/CanvasEditor/index.d.ts.map +1 -0
  166. package/src/views/CanvasEditor/index.ts +16 -0
  167. package/src/views/PostManager/EmptyState.d.ts +10 -0
  168. package/src/views/PostManager/EmptyState.d.ts.map +1 -0
  169. package/src/views/PostManager/EmptyState.tsx +42 -0
  170. package/src/views/PostManager/PostActionsMenu.d.ts +12 -0
  171. package/src/views/PostManager/PostActionsMenu.d.ts.map +1 -0
  172. package/src/views/PostManager/PostActionsMenu.tsx +112 -0
  173. package/src/views/PostManager/PostCards.d.ts +15 -0
  174. package/src/views/PostManager/PostCards.d.ts.map +1 -0
  175. package/src/views/PostManager/PostCards.tsx +197 -0
  176. package/src/views/PostManager/PostFilters.d.ts +16 -0
  177. package/src/views/PostManager/PostFilters.d.ts.map +1 -0
  178. package/src/views/PostManager/PostFilters.tsx +95 -0
  179. package/src/views/PostManager/PostManagerView.d.ts +11 -0
  180. package/src/views/PostManager/PostManagerView.d.ts.map +1 -0
  181. package/src/views/PostManager/PostManagerView.tsx +289 -0
  182. package/src/views/PostManager/PostStats.d.ts +11 -0
  183. package/src/views/PostManager/PostStats.d.ts.map +1 -0
  184. package/src/views/PostManager/PostStats.tsx +81 -0
  185. package/src/views/PostManager/PostTable.d.ts +15 -0
  186. package/src/views/PostManager/PostTable.d.ts.map +1 -0
  187. package/src/views/PostManager/PostTable.tsx +230 -0
  188. package/src/views/PostManager/index.d.ts +12 -0
  189. package/src/views/PostManager/index.d.ts.map +1 -0
  190. package/src/views/PostManager/index.ts +15 -0
  191. package/src/views/Preview/PreviewBridgeView.d.ts +12 -0
  192. package/src/views/Preview/PreviewBridgeView.d.ts.map +1 -0
  193. package/src/views/Preview/PreviewBridgeView.tsx +64 -0
  194. package/src/views/Preview/index.d.ts +6 -0
  195. package/src/views/Preview/index.d.ts.map +1 -0
  196. package/src/views/Preview/index.ts +7 -0
  197. package/src/views/Settings/SettingsView.d.ts +10 -0
  198. package/src/views/Settings/SettingsView.d.ts.map +1 -0
  199. package/src/views/Settings/SettingsView.tsx +298 -0
  200. package/src/views/Settings/index.d.ts +6 -0
  201. package/src/views/Settings/index.d.ts.map +1 -0
  202. package/src/views/Settings/index.ts +7 -0
  203. package/src/views/SlugSEO/SlugSEOManagerView.d.ts +12 -0
  204. package/src/views/SlugSEO/SlugSEOManagerView.d.ts.map +1 -0
  205. package/src/views/SlugSEO/SlugSEOManagerView.tsx +94 -0
  206. package/src/views/SlugSEO/index.d.ts +6 -0
  207. package/src/views/SlugSEO/index.d.ts.map +1 -0
  208. package/src/views/SlugSEO/index.ts +7 -0
@@ -0,0 +1,13 @@
1
+ import type { Block } from '../../../types/block';
2
+ import type { PostMetadata, SEOMetadata } from '../../../types/post';
3
+ export interface EditorSidebarProps {
4
+ slug: string;
5
+ seo: SEOMetadata;
6
+ metadata: PostMetadata;
7
+ heroBlock: Block | null;
8
+ status: string;
9
+ onSEOUpdate: (seo: Partial<SEOMetadata>) => void;
10
+ onMetadataUpdate: (metadata: Partial<PostMetadata>) => void;
11
+ }
12
+ export declare function EditorSidebar({ slug, seo, metadata, heroBlock, status, onSEOUpdate, onMetadataUpdate, }: EditorSidebarProps): import("react/jsx-runtime").JSX.Element;
13
+ //# sourceMappingURL=EditorSidebar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EditorSidebar.d.ts","sourceRoot":"","sources":["EditorSidebar.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAErE,MAAM,WAAW,kBAAkB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,WAAW,CAAC;IACjB,QAAQ,EAAE,YAAY,CAAC;IACvB,SAAS,EAAE,KAAK,GAAG,IAAI,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,CAAC,GAAG,EAAE,OAAO,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC;IACjD,gBAAgB,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC,YAAY,CAAC,KAAK,IAAI,CAAC;CAC/D;AAED,wBAAgB,aAAa,CAAC,EAC1B,IAAI,EACJ,GAAG,EACH,QAAQ,EACR,SAAS,EACT,MAAM,EACN,WAAW,EACX,gBAAgB,GACnB,EAAE,kBAAkB,2CA0JpB"}
@@ -0,0 +1,181 @@
1
+ 'use client';
2
+
3
+ import React from 'react';
4
+ import { Globe, Search, Box } from 'lucide-react';
5
+ import { FeaturedMediaSection, PrivacySettingsSection } from './index';
6
+ import type { Block } from '../../../types/block';
7
+ import type { PostMetadata, SEOMetadata } from '../../../types/post';
8
+
9
+ export interface EditorSidebarProps {
10
+ slug: string;
11
+ seo: SEOMetadata;
12
+ metadata: PostMetadata;
13
+ heroBlock: Block | null;
14
+ status: string;
15
+ onSEOUpdate: (seo: Partial<SEOMetadata>) => void;
16
+ onMetadataUpdate: (metadata: Partial<PostMetadata>) => void;
17
+ }
18
+
19
+ export function EditorSidebar({
20
+ slug,
21
+ seo,
22
+ metadata,
23
+ heroBlock,
24
+ status,
25
+ onSEOUpdate,
26
+ onMetadataUpdate,
27
+ }: EditorSidebarProps) {
28
+ return (
29
+ <div className="p-8 w-80 min-w-0 max-w-full space-y-12 overflow-y-auto max-h-full">
30
+ {/* SEO Section */}
31
+ <section>
32
+ <div className="flex items-center gap-3 mb-6">
33
+ <Search size={14} className="text-neutral-500 dark:text-neutral-400" />
34
+ <label className="text-[10px] uppercase tracking-[0.2em] text-neutral-500 dark:text-neutral-400 font-black">
35
+ SEO Settings
36
+ </label>
37
+ </div>
38
+ <div className="space-y-4">
39
+ <div>
40
+ <label className="text-[10px] text-neutral-500 dark:text-neutral-400 uppercase font-bold block mb-2">
41
+ SEO Title
42
+ </label>
43
+ <input
44
+ type="text"
45
+ value={seo.title || ''}
46
+ onChange={(e) => onSEOUpdate({ title: e.target.value })}
47
+ placeholder="SEO title (defaults to post title)"
48
+ className="w-full px-3 py-2 text-xs bg-dashboard-card border border-dashboard-border rounded-lg outline-none focus:border-primary transition-all text-dashboard-text"
49
+ />
50
+ <p className="text-[9px] text-neutral-400 dark:text-neutral-500 mt-1">
51
+ {seo.title?.length || 0} / 60 characters
52
+ </p>
53
+ </div>
54
+ <div>
55
+ <label className="text-[10px] text-neutral-500 dark:text-neutral-400 uppercase font-bold block mb-2">
56
+ Meta Description
57
+ </label>
58
+ <textarea
59
+ value={seo.description || ''}
60
+ onChange={(e) => onSEOUpdate({ description: e.target.value })}
61
+ placeholder="Brief description for search engines"
62
+ rows={3}
63
+ className="w-full px-3 py-2 text-xs bg-white dark:bg-neutral-900/50 border border-neutral-300 dark:border-neutral-700 rounded-lg outline-none focus:border-primary transition-all dark:text-neutral-100 resize-none"
64
+ />
65
+ <p className="text-[9px] text-neutral-400 dark:text-neutral-500 mt-1">
66
+ {seo.description?.length || 0} / 160 characters
67
+ </p>
68
+ </div>
69
+ <div>
70
+ <label className="text-[10px] text-neutral-500 dark:text-neutral-400 uppercase font-bold block mb-2">
71
+ Keywords (comma-separated)
72
+ </label>
73
+ <input
74
+ type="text"
75
+ value={seo.keywords?.join(', ') || ''}
76
+ onChange={(e) => {
77
+ const keywords = e.target.value.split(',').map(k => k.trim()).filter(k => k);
78
+ onSEOUpdate({ keywords });
79
+ }}
80
+ placeholder="keyword1, keyword2, keyword3"
81
+ className="w-full px-3 py-2 text-xs bg-dashboard-card border border-dashboard-border rounded-lg outline-none focus:border-primary transition-all text-dashboard-text"
82
+ />
83
+ </div>
84
+ <div>
85
+ <label className="text-[10px] text-neutral-500 dark:text-neutral-400 uppercase font-bold block mb-2">
86
+ Open Graph Image URL
87
+ </label>
88
+ <input
89
+ type="url"
90
+ value={seo.ogImage || ''}
91
+ onChange={(e) => onSEOUpdate({ ogImage: e.target.value })}
92
+ placeholder="https://example.com/image.jpg"
93
+ className="w-full px-3 py-2 text-xs bg-dashboard-card border border-dashboard-border rounded-lg outline-none focus:border-primary transition-all text-dashboard-text"
94
+ />
95
+ </div>
96
+ </div>
97
+ </section>
98
+
99
+ {/* Publishing Section */}
100
+ <section className="pt-8 border-t border-neutral-200 dark:border-neutral-800">
101
+ <div className="flex items-center gap-3 mb-6">
102
+ <Globe size={14} className="text-neutral-500 dark:text-neutral-400" />
103
+ <label className="text-[10px] uppercase tracking-[0.2em] text-neutral-500 dark:text-neutral-400 font-black">
104
+ Publishing
105
+ </label>
106
+ </div>
107
+ <div className="bg-dashboard-bg p-5 rounded-2xl border border-dashboard-border">
108
+ <span className="text-[10px] text-neutral-500 dark:text-neutral-400 uppercase font-bold block mb-3">Slug / Permalink</span>
109
+ <div className="text-xs font-mono break-all text-neutral-600 dark:text-neutral-400 leading-relaxed">
110
+ /blog/<span className="text-neutral-950 dark:text-white bg-amber-50 dark:bg-amber-900/20 px-1 rounded">{slug || 'untitled-post'}</span>
111
+ </div>
112
+ </div>
113
+ </section>
114
+
115
+ {/* Category Section */}
116
+ <section className="pt-8 border-t border-neutral-200 dark:border-neutral-800">
117
+ <div className="flex items-center gap-3 mb-6">
118
+ <Box size={14} className="text-neutral-500 dark:text-neutral-400" />
119
+ <label className="text-[10px] uppercase tracking-[0.2em] text-neutral-500 dark:text-neutral-400 font-black">
120
+ Category
121
+ </label>
122
+ </div>
123
+ <div className="space-y-4">
124
+ <div>
125
+ <label className="text-[10px] text-neutral-500 dark:text-neutral-400 uppercase font-bold block mb-2">
126
+ Category
127
+ </label>
128
+ <input
129
+ type="text"
130
+ value={metadata.categories?.[0] || ''}
131
+ onChange={(e) => {
132
+ const category = e.target.value.trim();
133
+ onMetadataUpdate({
134
+ categories: category ? [category] : []
135
+ });
136
+ }}
137
+ placeholder="Enter category (required for publishing)"
138
+ className="w-full px-3 py-2 text-xs bg-dashboard-card border border-dashboard-border rounded-lg outline-none focus:border-primary transition-all text-dashboard-text"
139
+ />
140
+ <p className="text-[9px] text-neutral-400 dark:text-neutral-500 mt-1">
141
+ {metadata.categories?.[0] ? 'Category set' : 'No category set'}
142
+ </p>
143
+ </div>
144
+ </div>
145
+ </section>
146
+
147
+ {/* Featured Media Section */}
148
+ <FeaturedMediaSection
149
+ featuredImage={metadata.featuredImage}
150
+ heroBlock={heroBlock}
151
+ slug={slug}
152
+ onUpdate={(image) => onMetadataUpdate({ featuredImage: image })}
153
+ />
154
+
155
+ {/* Privacy Settings Section */}
156
+ <PrivacySettingsSection
157
+ privacy={metadata.privacy}
158
+ onUpdate={(privacy) => onMetadataUpdate({ privacy })}
159
+ />
160
+
161
+ {/* Post Status Section */}
162
+ <section className="pt-8 border-t border-neutral-200 dark:border-neutral-800">
163
+ <div className="flex items-center justify-between mb-4">
164
+ <label className="text-[10px] uppercase tracking-[0.2em] text-neutral-500 dark:text-neutral-400 font-black">
165
+ Post Status
166
+ </label>
167
+ <span className="text-[10px] font-black text-amber-700 dark:text-amber-400 bg-amber-50 dark:bg-amber-900/20 px-2.5 py-1 rounded-full uppercase tracking-tighter">
168
+ {status}
169
+ </span>
170
+ </div>
171
+ <p className="text-[11px] text-neutral-500 dark:text-neutral-400 leading-relaxed italic">
172
+ {status === 'draft'
173
+ ? 'This post is private. Only you can see it until you hit publish.'
174
+ : status === 'published'
175
+ ? 'This post is live and visible to everyone.'
176
+ : 'This post is scheduled for publication.'}
177
+ </p>
178
+ </section>
179
+ </div>
180
+ );
181
+ }
@@ -0,0 +1,6 @@
1
+ export interface ErrorBannerProps {
2
+ error: string | null;
3
+ onDismiss: () => void;
4
+ }
5
+ export declare function ErrorBanner({ error, onDismiss }: ErrorBannerProps): import("react/jsx-runtime").JSX.Element | null;
6
+ //# sourceMappingURL=ErrorBanner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ErrorBanner.d.ts","sourceRoot":"","sources":["ErrorBanner.tsx"],"names":[],"mappings":"AAKA,MAAM,WAAW,gBAAgB;IAC7B,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,SAAS,EAAE,MAAM,IAAI,CAAC;CACzB;AAED,wBAAgB,WAAW,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,gBAAgB,kDAoBjE"}
@@ -0,0 +1,31 @@
1
+ 'use client';
2
+
3
+ import React from 'react';
4
+ import { AlertTriangle, X } from 'lucide-react';
5
+
6
+ export interface ErrorBannerProps {
7
+ error: string | null;
8
+ onDismiss: () => void;
9
+ }
10
+
11
+ export function ErrorBanner({ error, onDismiss }: ErrorBannerProps) {
12
+ if (!error) return null;
13
+
14
+ return (
15
+ <div className="bg-red-50 dark:bg-red-900/20 border-b border-red-200 dark:border-red-800 px-6 py-3 flex items-center justify-between">
16
+ <div className="flex items-center gap-3 flex-1">
17
+ <AlertTriangle className="text-red-600 dark:text-red-400 flex-shrink-0" size={20} />
18
+ <p className="text-red-800 dark:text-red-300 text-sm font-medium">
19
+ {error}
20
+ </p>
21
+ </div>
22
+ <button
23
+ onClick={onDismiss}
24
+ className="text-red-600 dark:text-red-400 hover:text-red-800 dark:hover:text-red-200 transition-colors"
25
+ aria-label="Dismiss error"
26
+ >
27
+ <X size={18} />
28
+ </button>
29
+ </div>
30
+ );
31
+ }
@@ -0,0 +1,25 @@
1
+ import type { Block } from '../../../types/block';
2
+ export interface FeaturedImage {
3
+ id?: string;
4
+ alt?: string;
5
+ brightness?: number;
6
+ blur?: number;
7
+ scale?: number;
8
+ positionX?: number;
9
+ positionY?: number;
10
+ isCustom?: boolean;
11
+ }
12
+ export interface FeaturedMediaSectionProps {
13
+ featuredImage?: FeaturedImage;
14
+ heroBlock?: Block | null;
15
+ slug?: string;
16
+ onUpdate: (image: FeaturedImage | undefined) => void;
17
+ }
18
+ /**
19
+ * Featured Media Section Component
20
+ * Handles featured image selection - completely independent from hero image
21
+ * Featured image is a thumbnail used for blog post cards
22
+ * Hero image is separate and managed in the hero block
23
+ */
24
+ export declare function FeaturedMediaSection({ featuredImage, heroBlock, slug, onUpdate, }: FeaturedMediaSectionProps): import("react/jsx-runtime").JSX.Element;
25
+ //# sourceMappingURL=FeaturedMediaSection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FeaturedMediaSection.d.ts","sourceRoot":"","sources":["FeaturedMediaSection.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAElD,MAAM,WAAW,aAAa;IAE1B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,yBAAyB;IACtC,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,SAAS,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,CAAC,KAAK,EAAE,aAAa,GAAG,SAAS,KAAK,IAAI,CAAC;CACxD;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,EACjC,aAAa,EACb,SAAS,EACT,IAAI,EACJ,QAAQ,GACX,EAAE,yBAAyB,2CA0S3B"}
@@ -0,0 +1,341 @@
1
+ 'use client';
2
+
3
+ import React, { useState, useCallback, useEffect } from 'react';
4
+ import { createPortal } from 'react-dom';
5
+ import { Image as ImageIcon, Plus, X } from 'lucide-react';
6
+ import { ImagePicker, Image } from '@jhits/plugin-images';
7
+ import type { ImageMetadata } from '@jhits/plugin-images';
8
+ import type { Block } from '../../../types/block';
9
+
10
+ export interface FeaturedImage {
11
+ // Store only the semantic ID - plugin-images handles everything else
12
+ id?: string;
13
+ alt?: string;
14
+ // Transform values (stored locally for UI, but plugin-images API is source of truth)
15
+ brightness?: number;
16
+ blur?: number;
17
+ scale?: number;
18
+ positionX?: number;
19
+ positionY?: number;
20
+ // Indicates if this is a custom featured image (not synced from hero)
21
+ isCustom?: boolean;
22
+ }
23
+
24
+ export interface FeaturedMediaSectionProps {
25
+ featuredImage?: FeaturedImage;
26
+ heroBlock?: Block | null; // Hero block to get default image from
27
+ slug?: string; // Blog post slug for semantic ID
28
+ onUpdate: (image: FeaturedImage | undefined) => void;
29
+ }
30
+
31
+ /**
32
+ * Featured Media Section Component
33
+ * Handles featured image selection - completely independent from hero image
34
+ * Featured image is a thumbnail used for blog post cards
35
+ * Hero image is separate and managed in the hero block
36
+ */
37
+ export function FeaturedMediaSection({
38
+ featuredImage,
39
+ heroBlock,
40
+ slug,
41
+ onUpdate,
42
+ }: FeaturedMediaSectionProps) {
43
+ const [showImagePicker, setShowImagePicker] = useState(false);
44
+ const [openEditorDirectly, setOpenEditorDirectly] = useState(false);
45
+ const [mounted, setMounted] = useState(false);
46
+
47
+ // Handle SSR - ensure we only render portal on client
48
+ useEffect(() => {
49
+ setMounted(true);
50
+ }, []);
51
+
52
+ // Create semantic ID for this featured image - plugin-images will handle everything
53
+ const semanticId = slug ? `blog-featured-${slug}` : `blog-featured-${Date.now()}`;
54
+
55
+ // Use semantic ID from featuredImage if it exists, otherwise use generated one
56
+ // IMPORTANT: Always use the actual id from featuredImage if available, otherwise the semanticId
57
+ // This ensures the id is stable and doesn't change on re-renders
58
+ const imageId = featuredImage?.id || semanticId;
59
+
60
+ // Ensure featuredImage always has an id when it exists
61
+ // This prevents the "missing featured image" issue on save
62
+ useEffect(() => {
63
+ if (featuredImage && !featuredImage.id) {
64
+ // If featuredImage exists but has no id, set it to the semanticId
65
+ onUpdate({
66
+ ...featuredImage,
67
+ id: semanticId,
68
+ });
69
+ }
70
+ }, [featuredImage, semanticId, onUpdate]);
71
+
72
+ // Get transform values from featuredImage or use defaults
73
+ const brightness = featuredImage?.brightness ?? 100;
74
+ const blur = featuredImage?.blur ?? 0;
75
+ const scale = featuredImage?.scale ?? 1.0;
76
+ const positionX = featuredImage?.positionX ?? 0;
77
+ const positionY = featuredImage?.positionY ?? 0;
78
+
79
+ // Handle image selection - create initial mapping and update blog metadata with semantic ID
80
+ // Plugin-images Image component will automatically resolve the semantic ID when it renders
81
+ const handleImageChange = useCallback(async (image: ImageMetadata | null) => {
82
+ if (image) {
83
+ // Extract filename from image URL for reference
84
+ const isUploadedImage = image.url.startsWith('/api/uploads/');
85
+ let filename = image.filename;
86
+
87
+ if (!filename && isUploadedImage) {
88
+ // Extract filename from URL if not provided
89
+ filename = image.url.split('/api/uploads/')[1]?.split('?')[0] || image.id;
90
+ } else if (!filename) {
91
+ // For external URLs, use the image ID or extract from URL
92
+ filename = image.id || image.url.split('/').pop()?.split('?')[0] || `external-${Date.now()}`;
93
+ }
94
+
95
+ // Create initial mapping in plugin-images API immediately
96
+ // This ensures the semantic ID resolves correctly
97
+ try {
98
+ const saveData = {
99
+ id: imageId,
100
+ filename: filename,
101
+ scale: 1.0,
102
+ positionX: 0,
103
+ positionY: 0,
104
+ brightness: 100,
105
+ blur: 0,
106
+ };
107
+
108
+ await fetch('/api/plugin-images/resolve', {
109
+ method: 'POST',
110
+ headers: { 'Content-Type': 'application/json' },
111
+ body: JSON.stringify(saveData),
112
+ });
113
+ } catch (error) {
114
+ console.error('[FeaturedMediaSection] Failed to create initial mapping:', error);
115
+ // Continue anyway - the mapping might be created later
116
+ }
117
+
118
+ // Update blog metadata with semantic ID
119
+ onUpdate({
120
+ id: imageId,
121
+ alt: image.alt || image.filename,
122
+ brightness: 100,
123
+ blur: 0,
124
+ scale: 1.0,
125
+ positionX: 0,
126
+ positionY: 0,
127
+ isCustom: true,
128
+ } as FeaturedImage);
129
+ } else {
130
+ // If removed, set to undefined
131
+ onUpdate(undefined);
132
+ }
133
+ setShowImagePicker(false);
134
+ }, [imageId, onUpdate]);
135
+
136
+ // Handle editor save from ImagePicker - save to plugin-images API
137
+ const handleEditorSave = useCallback(async (
138
+ finalScale: number,
139
+ finalPositionX: number,
140
+ finalPositionY: number,
141
+ finalBrightness?: number,
142
+ finalBlur?: number
143
+ ) => {
144
+ if (!featuredImage?.id) return;
145
+
146
+ // Reset the auto-open flag immediately to prevent reopening
147
+ setOpenEditorDirectly(false);
148
+
149
+ // Get the actual filename from the API (resolve the semantic ID)
150
+ let filename = imageId; // Fallback to semantic ID
151
+ try {
152
+ const response = await fetch(`/api/plugin-images/resolve?id=${encodeURIComponent(imageId)}`);
153
+ if (response.ok) {
154
+ const data = await response.json();
155
+ filename = data.filename || imageId;
156
+ }
157
+ } catch (error) {
158
+ console.error('Failed to resolve filename:', error);
159
+ }
160
+
161
+ // Normalize position values
162
+ const normalizedPositionX = finalPositionX === -50 ? 0 : finalPositionX;
163
+ const normalizedPositionY = finalPositionY === -50 ? 0 : finalPositionY;
164
+ const finalBrightnessValue = finalBrightness ?? brightness;
165
+ const finalBlurValue = finalBlur ?? blur;
166
+
167
+ // Save to plugin-images API
168
+ try {
169
+ const saveData = {
170
+ id: imageId,
171
+ filename: filename,
172
+ scale: finalScale,
173
+ positionX: normalizedPositionX,
174
+ positionY: normalizedPositionY,
175
+ brightness: finalBrightnessValue,
176
+ blur: finalBlurValue,
177
+ };
178
+
179
+ const response = await fetch('/api/plugin-images/resolve', {
180
+ method: 'POST',
181
+ headers: { 'Content-Type': 'application/json' },
182
+ body: JSON.stringify(saveData),
183
+ });
184
+
185
+ if (response.ok) {
186
+ // Update local featured image data - ensure id is preserved
187
+ onUpdate({
188
+ ...featuredImage,
189
+ id: featuredImage.id || imageId, // Ensure id is always preserved
190
+ scale: finalScale,
191
+ positionX: normalizedPositionX,
192
+ positionY: normalizedPositionY,
193
+ brightness: finalBrightnessValue,
194
+ blur: finalBlurValue,
195
+ });
196
+
197
+ // Dispatch event to notify Image components
198
+ window.dispatchEvent(new CustomEvent('image-mapping-updated', {
199
+ detail: saveData
200
+ }));
201
+ }
202
+ } catch (error) {
203
+ console.error('Failed to save image transform:', error);
204
+ }
205
+ }, [imageId, featuredImage, brightness, blur, onUpdate]);
206
+
207
+ return (
208
+ <section>
209
+ <div className="flex items-center gap-3 mb-6">
210
+ <ImageIcon size={14} className="text-neutral-500 dark:text-neutral-400" />
211
+ <label className="text-[10px] uppercase tracking-[0.2em] text-neutral-500 dark:text-neutral-400 font-black">
212
+ Featured Media
213
+ </label>
214
+ </div>
215
+ {featuredImage?.id ? (
216
+ <div className="relative group">
217
+ {/* Use Image component from plugin-images - it handles everything automatically */}
218
+ {/* Blog component only handles the design/styling */}
219
+ <div className="relative aspect-[16/10] bg-dashboard-bg rounded-3xl overflow-hidden border border-dashboard-border group/image">
220
+ <Image
221
+ id={imageId}
222
+ alt={featuredImage?.alt || 'Featured image'}
223
+ fill
224
+ className="object-cover w-full h-full"
225
+ editable={false} // Disable Image component's overlay - we'll use our own
226
+ {...({
227
+ brightness,
228
+ blur,
229
+ scale,
230
+ positionX,
231
+ positionY,
232
+ } as any)}
233
+ />
234
+ {/* Custom edit overlay that opens ImagePicker editor */}
235
+ <button
236
+ onClick={() => {
237
+ setOpenEditorDirectly(true);
238
+ setShowImagePicker(true);
239
+ }}
240
+ className="absolute inset-0 z-30 flex items-center justify-center opacity-0 group-hover/image:opacity-100 transition-all duration-300 bg-neutral-900/40 dark:bg-neutral-900/60 backdrop-blur-[2px]"
241
+ >
242
+ <div className="flex items-center gap-2 px-4 py-2 bg-white dark:bg-neutral-800 rounded-full shadow-xl">
243
+ <ImageIcon size={14} className="text-primary" />
244
+ <span className="text-[10px] font-bold uppercase tracking-widest">Edit</span>
245
+ </div>
246
+ </button>
247
+ </div>
248
+ <div className="mt-2 flex items-center gap-3">
249
+ <button
250
+ onClick={() => setShowImagePicker(true)}
251
+ className="text-[10px] text-neutral-600 dark:text-neutral-400 hover:text-primary font-bold uppercase tracking-wider"
252
+ >
253
+ Change Image
254
+ </button>
255
+ <span className="text-[10px] text-neutral-400">•</span>
256
+ <button
257
+ onClick={() => onUpdate(undefined)}
258
+ className="text-[10px] text-red-500 dark:text-red-400 hover:text-red-700 dark:hover:text-red-300 font-bold uppercase tracking-wider"
259
+ >
260
+ Remove Image
261
+ </button>
262
+ </div>
263
+ </div>
264
+ ) : (
265
+ <div
266
+ className="group relative aspect-[16/10] bg-dashboard-bg rounded-3xl border-2 border-dashed border-dashboard-border flex flex-col items-center justify-center text-neutral-400 dark:text-neutral-500 hover:bg-dashboard-card hover:border-primary cursor-pointer transition-all duration-300"
267
+ onClick={() => setShowImagePicker(true)}
268
+ >
269
+ <Plus size={24} strokeWidth={1} className="mb-3 group-hover:scale-110 transition-transform" />
270
+ <span className="text-[9px] font-black uppercase tracking-widest">Assign Image</span>
271
+ </div>
272
+ )}
273
+
274
+ {/* Image Picker Modal */}
275
+ {showImagePicker && mounted && createPortal(
276
+ <div className="fixed inset-0 z-[100] flex items-center justify-center bg-black/50 backdrop-blur-sm" onClick={() => {
277
+ setShowImagePicker(false);
278
+ setOpenEditorDirectly(false); // Reset flag when closing
279
+ }}>
280
+ <div className="bg-white dark:bg-neutral-900 rounded-2xl w-full max-w-2xl mx-4 p-6 shadow-2xl max-h-[90vh] overflow-y-auto" onClick={(e) => e.stopPropagation()}>
281
+ <div className="flex items-center justify-between mb-6">
282
+ <h3 className="text-lg font-bold text-neutral-900 dark:text-neutral-100">
283
+ {openEditorDirectly ? 'Edit Featured Image' : 'Select Featured Image'}
284
+ </h3>
285
+ <button
286
+ onClick={() => {
287
+ setShowImagePicker(false);
288
+ setOpenEditorDirectly(false); // Reset flag when closing
289
+ }}
290
+ className="p-2 hover:bg-dashboard-bg dark:hover:bg-neutral-800 rounded-lg transition-colors text-neutral-700 dark:text-neutral-300 hover:text-neutral-900 dark:hover:text-white"
291
+ aria-label="Close"
292
+ >
293
+ <X size={20} className="transition-colors" />
294
+ </button>
295
+ </div>
296
+ <ImagePicker
297
+ value={featuredImage?.id ? imageId : undefined}
298
+ onChange={handleImageChange}
299
+ brightness={brightness}
300
+ blur={blur}
301
+ {...({
302
+ scale,
303
+ positionX,
304
+ positionY,
305
+ } as any)}
306
+ onBrightnessChange={(val) => {
307
+ // Update local state only - don't trigger save
308
+ if (featuredImage) {
309
+ onUpdate({
310
+ ...featuredImage,
311
+ id: featuredImage.id || imageId, // Ensure id is preserved
312
+ brightness: val,
313
+ });
314
+ }
315
+ }}
316
+ onBlurChange={(val) => {
317
+ // Update local state only - don't trigger save
318
+ if (featuredImage) {
319
+ onUpdate({
320
+ ...featuredImage,
321
+ id: featuredImage.id || imageId, // Ensure id is preserved
322
+ blur: val,
323
+ });
324
+ }
325
+ }}
326
+ onEditorSave={handleEditorSave}
327
+ darkMode={false}
328
+ showEffects={true} // Enable effects so editor can be used
329
+ aspectRatio="16/10" // Thumbnail aspect ratio for blog cards
330
+ borderRadius="rounded-3xl"
331
+ objectFit="cover" // Cover for thumbnails
332
+ objectPosition="center"
333
+ />
334
+ </div>
335
+ </div>,
336
+ document.body
337
+ )}
338
+ </section>
339
+ );
340
+ }
341
+
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ export interface LibraryItemProps {
3
+ icon: React.ReactNode;
4
+ label: string;
5
+ blockType: string;
6
+ description?: string;
7
+ onAddBlock?: (blockType: string) => void;
8
+ }
9
+ /**
10
+ * Reusable Library Item Component
11
+ * Makes blocks draggable from the library and clickable to add at bottom
12
+ */
13
+ export declare function LibraryItem({ icon, label, blockType, description, onAddBlock }: LibraryItemProps): import("react/jsx-runtime").JSX.Element;
14
+ //# sourceMappingURL=LibraryItem.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LibraryItem.d.ts","sourceRoot":"","sources":["LibraryItem.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA2B,MAAM,OAAO,CAAC;AAEhD,MAAM,WAAW,gBAAgB;IAC7B,IAAI,EAAE,KAAK,CAAC,SAAS,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;CAC5C;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,EACxB,IAAI,EACJ,KAAK,EACL,SAAS,EACT,WAAW,EACX,UAAU,EACb,EAAE,gBAAgB,2CAwDlB"}