@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,16 +0,0 @@
1
- /**
2
- * Rich Text Preview Component
3
- * Renders HTML content with client-provided styles
4
- * Also supports plain text with formatting markers using the plugin-content parser
5
- */
6
- import { RichTextFormattingConfig } from './RichTextEditor';
7
- export interface RichTextPreviewProps {
8
- /** HTML content or plain text with formatting markers to render */
9
- content: string;
10
- /** Formatting configuration (for applying client styles to HTML) */
11
- formatting?: RichTextFormattingConfig;
12
- /** Additional CSS classes */
13
- className?: string;
14
- }
15
- export declare function RichTextPreview({ content, formatting, className, }: RichTextPreviewProps): import("react/jsx-runtime").JSX.Element;
16
- //# sourceMappingURL=RichTextPreview.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"RichTextPreview.d.ts","sourceRoot":"","sources":["RichTextPreview.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAG5D,MAAM,WAAW,oBAAoB;IACjC,mEAAmE;IACnE,OAAO,EAAE,MAAM,CAAC;IAChB,oEAAoE;IACpE,UAAU,CAAC,EAAE,wBAAwB,CAAC;IACtC,6BAA6B;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAkBD,wBAAgB,eAAe,CAAC,EAC5B,OAAO,EACP,UAAU,EACV,SAAc,GACjB,EAAE,oBAAoB,2CAuKtB"}
@@ -1,144 +0,0 @@
1
- /**
2
- * Rich Text Preview Component
3
- * Renders HTML content with client-provided styles
4
- * Also supports plain text with formatting markers using the plugin-content parser
5
- */
6
- 'use client';
7
- import { jsx as _jsx } from "react/jsx-runtime";
8
- import React from 'react';
9
- import { parse, useParserConfig } from '@jhits/plugin-content';
10
- /**
11
- * Check if content is HTML or plain text with formatting markers
12
- */
13
- function isHtmlContent(content) {
14
- // If content contains HTML tags, it's HTML
15
- if (/<[a-z][\s\S]*>/i.test(content)) {
16
- return true;
17
- }
18
- // If content contains HTML entities, it's likely HTML
19
- if (/&[a-z]+;/i.test(content)) {
20
- return true;
21
- }
22
- // Otherwise, it's plain text (potentially with formatting markers)
23
- return false;
24
- }
25
- export function RichTextPreview({ content, formatting, className = '', }) {
26
- // Handle empty content
27
- if (!content || content.trim() === '') {
28
- return _jsx("div", { className: className, children: "\u00A0" });
29
- }
30
- // Get parser config from context (provided by client app)
31
- const parserConfig = useParserConfig();
32
- // Check if content is HTML or plain text
33
- const isHtml = isHtmlContent(content);
34
- // If it's plain text, use the parser from plugin-content
35
- if (!isHtml) {
36
- const parsedContent = parse(content, false, parserConfig);
37
- return (_jsx("div", { className: className, children: parsedContent }));
38
- }
39
- // Otherwise, continue with HTML rendering logic
40
- // Apply client-provided styles to HTML content
41
- const applyStyles = (html) => {
42
- if (!(formatting === null || formatting === void 0 ? void 0 : formatting.styles))
43
- return html;
44
- const styles = formatting.styles;
45
- let styledHtml = html;
46
- // Apply bold style - handle both <strong> and <b> tags
47
- if (styles.bold) {
48
- // Replace <strong> tags
49
- styledHtml = styledHtml.replace(/<strong\b([^>]*)>/gi, (match, attrs) => {
50
- // Check if class already exists
51
- if (attrs && attrs.includes('class=')) {
52
- return match.replace(/class="([^"]*)"/, `class="$1 ${styles.bold}"`);
53
- }
54
- return `<strong class="${styles.bold}">`;
55
- });
56
- // Replace <b> tags
57
- styledHtml = styledHtml.replace(/<b\b([^>]*)>/gi, (match, attrs) => {
58
- if (attrs && attrs.includes('class=')) {
59
- return match.replace(/class="([^"]*)"/, `class="$1 ${styles.bold}"`);
60
- }
61
- return `<b class="${styles.bold}">`;
62
- });
63
- }
64
- // Apply italic style - handle both <em> and <i> tags
65
- if (styles.italic) {
66
- styledHtml = styledHtml.replace(/<em\b([^>]*)>/gi, (match, attrs) => {
67
- if (attrs && attrs.includes('class=')) {
68
- return match.replace(/class="([^"]*)"/, `class="$1 ${styles.italic}"`);
69
- }
70
- return `<em class="${styles.italic}">`;
71
- });
72
- styledHtml = styledHtml.replace(/<i\b([^>]*)>/gi, (match, attrs) => {
73
- if (attrs && attrs.includes('class=')) {
74
- return match.replace(/class="([^"]*)"/, `class="$1 ${styles.italic}"`);
75
- }
76
- return `<i class="${styles.italic}">`;
77
- });
78
- }
79
- // Apply underline style
80
- if (styles.underline) {
81
- styledHtml = styledHtml.replace(/<u\b([^>]*)>/gi, (match, attrs) => {
82
- if (attrs && attrs.includes('class=')) {
83
- return match.replace(/class="([^"]*)"/, `class="$1 ${styles.underline}"`);
84
- }
85
- return `<u class="${styles.underline}">`;
86
- });
87
- }
88
- // Apply link style
89
- if (styles.link) {
90
- styledHtml = styledHtml.replace(/<a\b([^>]*)>/gi, (match, attrs) => {
91
- if (attrs && attrs.includes('class=')) {
92
- return match.replace(/class="([^"]*)"/, `class="$1 ${styles.link}"`);
93
- }
94
- return match.replace('>', ` class="${styles.link}">`);
95
- });
96
- }
97
- // Apply color classes to spans (preserve existing classes)
98
- if (styles.colorClasses) {
99
- Object.entries(styles.colorClasses).forEach(([color, colorClass]) => {
100
- // Match spans that might have the color class already or need it added
101
- const regex = new RegExp(`<span([^>]*)class="([^"]*)"([^>]*)>`, 'gi');
102
- styledHtml = styledHtml.replace(regex, (match, beforeAttrs, existingClasses, afterAttrs) => {
103
- // Don't add if class already exists
104
- if (existingClasses.includes(colorClass)) {
105
- return match;
106
- }
107
- // Add the color class
108
- return `<span${beforeAttrs}class="${existingClasses} ${colorClass}"${afterAttrs}>`;
109
- });
110
- // Also handle spans without class attribute
111
- const regexNoClass = new RegExp(`<span([^>]*)>`, 'gi');
112
- styledHtml = styledHtml.replace(regexNoClass, (match, attrs) => {
113
- // Only add if this span doesn't already have a class and we're looking for a specific color
114
- if (!attrs.includes('class=')) {
115
- return match.replace('>', ` class="${colorClass}">`);
116
- }
117
- return match;
118
- });
119
- });
120
- }
121
- return styledHtml;
122
- };
123
- const styledContent = formatting ? applyStyles(content) : content;
124
- // For rendering, we'll use a ref to set innerHTML only on the client side
125
- // This avoids SSR issues while still allowing HTML rendering
126
- const contentRef = React.useRef(null);
127
- React.useEffect(() => {
128
- if (contentRef.current && styledContent) {
129
- contentRef.current.innerHTML = styledContent;
130
- }
131
- }, [styledContent]);
132
- // For server-side rendering, render plain text
133
- if (typeof window === 'undefined') {
134
- const textContent = styledContent
135
- .replace(/<[^>]*>/g, '')
136
- .replace(/&nbsp;/g, ' ')
137
- .replace(/&amp;/g, '&')
138
- .replace(/&lt;/g, '<')
139
- .replace(/&gt;/g, '>')
140
- .replace(/&quot;/g, '"');
141
- return (_jsx("div", { className: className, children: textContent || '\u00A0' }));
142
- }
143
- return (_jsx("div", { ref: contentRef, className: className }));
144
- }
@@ -1,210 +0,0 @@
1
- /**
2
- * Rich Text Preview Component
3
- * Renders HTML content with client-provided styles
4
- * Also supports plain text with formatting markers using the plugin-content parser
5
- */
6
-
7
- 'use client';
8
-
9
- import React from 'react';
10
- import { RichTextFormattingConfig } from './RichTextEditor';
11
- import { parse, useParserConfig } from '@jhits/plugin-content';
12
-
13
- export interface RichTextPreviewProps {
14
- /** HTML content or plain text with formatting markers to render */
15
- content: string;
16
- /** Formatting configuration (for applying client styles to HTML) */
17
- formatting?: RichTextFormattingConfig;
18
- /** Additional CSS classes */
19
- className?: string;
20
- }
21
-
22
- /**
23
- * Check if content is HTML or plain text with formatting markers
24
- */
25
- function isHtmlContent(content: string): boolean {
26
- // If content contains HTML tags, it's HTML
27
- if (/<[a-z][\s\S]*>/i.test(content)) {
28
- return true;
29
- }
30
- // If content contains HTML entities, it's likely HTML
31
- if (/&[a-z]+;/i.test(content)) {
32
- return true;
33
- }
34
- // Otherwise, it's plain text (potentially with formatting markers)
35
- return false;
36
- }
37
-
38
- export function RichTextPreview({
39
- content,
40
- formatting,
41
- className = '',
42
- }: RichTextPreviewProps) {
43
- // Handle empty content
44
- if (!content || content.trim() === '') {
45
- return <div className={className}>&nbsp;</div>;
46
- }
47
-
48
- // Get parser config from context (provided by client app)
49
- const parserConfig = useParserConfig();
50
-
51
- // Check if content is HTML or plain text
52
- const isHtml = isHtmlContent(content);
53
-
54
- // If it's plain text, use the parser from plugin-content
55
- if (!isHtml) {
56
- const parsedContent = parse(content, false, parserConfig);
57
- return (
58
- <div className={className}>
59
- {parsedContent}
60
- </div>
61
- );
62
- }
63
-
64
- // Otherwise, continue with HTML rendering logic
65
- // Apply client-provided styles to HTML content
66
- const applyStyles = (html: string): string => {
67
- if (!formatting?.styles) return html;
68
-
69
- const styles = formatting.styles;
70
- let styledHtml = html;
71
-
72
- // Apply bold style - handle both <strong> and <b> tags
73
- if (styles.bold) {
74
- // Replace <strong> tags
75
- styledHtml = styledHtml.replace(
76
- /<strong\b([^>]*)>/gi,
77
- (match, attrs) => {
78
- // Check if class already exists
79
- if (attrs && attrs.includes('class=')) {
80
- return match.replace(/class="([^"]*)"/, `class="$1 ${styles.bold}"`);
81
- }
82
- return `<strong class="${styles.bold}">`;
83
- }
84
- );
85
- // Replace <b> tags
86
- styledHtml = styledHtml.replace(
87
- /<b\b([^>]*)>/gi,
88
- (match, attrs) => {
89
- if (attrs && attrs.includes('class=')) {
90
- return match.replace(/class="([^"]*)"/, `class="$1 ${styles.bold}"`);
91
- }
92
- return `<b class="${styles.bold}">`;
93
- }
94
- );
95
- }
96
-
97
- // Apply italic style - handle both <em> and <i> tags
98
- if (styles.italic) {
99
- styledHtml = styledHtml.replace(
100
- /<em\b([^>]*)>/gi,
101
- (match, attrs) => {
102
- if (attrs && attrs.includes('class=')) {
103
- return match.replace(/class="([^"]*)"/, `class="$1 ${styles.italic}"`);
104
- }
105
- return `<em class="${styles.italic}">`;
106
- }
107
- );
108
- styledHtml = styledHtml.replace(
109
- /<i\b([^>]*)>/gi,
110
- (match, attrs) => {
111
- if (attrs && attrs.includes('class=')) {
112
- return match.replace(/class="([^"]*)"/, `class="$1 ${styles.italic}"`);
113
- }
114
- return `<i class="${styles.italic}">`;
115
- }
116
- );
117
- }
118
-
119
- // Apply underline style
120
- if (styles.underline) {
121
- styledHtml = styledHtml.replace(
122
- /<u\b([^>]*)>/gi,
123
- (match, attrs) => {
124
- if (attrs && attrs.includes('class=')) {
125
- return match.replace(/class="([^"]*)"/, `class="$1 ${styles.underline}"`);
126
- }
127
- return `<u class="${styles.underline}">`;
128
- }
129
- );
130
- }
131
-
132
- // Apply link style
133
- if (styles.link) {
134
- styledHtml = styledHtml.replace(
135
- /<a\b([^>]*)>/gi,
136
- (match, attrs) => {
137
- if (attrs && attrs.includes('class=')) {
138
- return match.replace(/class="([^"]*)"/, `class="$1 ${styles.link}"`);
139
- }
140
- return match.replace('>', ` class="${styles.link}">`);
141
- }
142
- );
143
- }
144
-
145
- // Apply color classes to spans (preserve existing classes)
146
- if (styles.colorClasses) {
147
- Object.entries(styles.colorClasses).forEach(([color, colorClass]) => {
148
- // Match spans that might have the color class already or need it added
149
- const regex = new RegExp(`<span([^>]*)class="([^"]*)"([^>]*)>`, 'gi');
150
- styledHtml = styledHtml.replace(regex, (match, beforeAttrs, existingClasses, afterAttrs) => {
151
- // Don't add if class already exists
152
- if (existingClasses.includes(colorClass)) {
153
- return match;
154
- }
155
- // Add the color class
156
- return `<span${beforeAttrs}class="${existingClasses} ${colorClass}"${afterAttrs}>`;
157
- });
158
-
159
- // Also handle spans without class attribute
160
- const regexNoClass = new RegExp(`<span([^>]*)>`, 'gi');
161
- styledHtml = styledHtml.replace(regexNoClass, (match, attrs) => {
162
- // Only add if this span doesn't already have a class and we're looking for a specific color
163
- if (!attrs.includes('class=')) {
164
- return match.replace('>', ` class="${colorClass}">`);
165
- }
166
- return match;
167
- });
168
- });
169
- }
170
-
171
- return styledHtml;
172
- };
173
-
174
- const styledContent = formatting ? applyStyles(content) : content;
175
-
176
- // For rendering, we'll use a ref to set innerHTML only on the client side
177
- // This avoids SSR issues while still allowing HTML rendering
178
- const contentRef = React.useRef<HTMLDivElement>(null);
179
-
180
- React.useEffect(() => {
181
- if (contentRef.current && styledContent) {
182
- contentRef.current.innerHTML = styledContent;
183
- }
184
- }, [styledContent]);
185
-
186
- // For server-side rendering, render plain text
187
- if (typeof window === 'undefined') {
188
- const textContent = styledContent
189
- .replace(/<[^>]*>/g, '')
190
- .replace(/&nbsp;/g, ' ')
191
- .replace(/&amp;/g, '&')
192
- .replace(/&lt;/g, '<')
193
- .replace(/&gt;/g, '>')
194
- .replace(/&quot;/g, '"');
195
-
196
- return (
197
- <div className={className}>
198
- {textContent || '\u00A0'}
199
- </div>
200
- );
201
- }
202
-
203
- return (
204
- <div
205
- ref={contentRef}
206
- className={className}
207
- />
208
- );
209
- }
210
-
@@ -1,9 +0,0 @@
1
- /**
2
- * Rich Text Utilities
3
- * Export rich text editor and preview components
4
- */
5
- export { RichTextEditor } from './RichTextEditor';
6
- export { RichTextPreview } from './RichTextPreview';
7
- export type { RichTextFormattingConfig, RichTextEditorProps } from './RichTextEditor';
8
- export type { RichTextPreviewProps } from './RichTextPreview';
9
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,YAAY,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACtF,YAAY,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC"}
@@ -1,6 +0,0 @@
1
- /**
2
- * Rich Text Utilities
3
- * Export rich text editor and preview components
4
- */
5
- export { RichTextEditor } from './RichTextEditor';
6
- export { RichTextPreview } from './RichTextPreview';
@@ -1,10 +0,0 @@
1
- /**
2
- * Rich Text Utilities
3
- * Export rich text editor and preview components
4
- */
5
-
6
- export { RichTextEditor } from './RichTextEditor';
7
- export { RichTextPreview } from './RichTextPreview';
8
- export type { RichTextFormattingConfig, RichTextEditorProps } from './RichTextEditor';
9
- export type { RichTextPreviewProps } from './RichTextPreview';
10
-
@@ -1,23 +0,0 @@
1
- /**
2
- * Block Helper Utilities
3
- * Functions for working with blocks, including nested structures
4
- */
5
- import { Block } from '../../types/block';
6
- /**
7
- * Get child blocks from a container block
8
- * Handles both Block[] and string[] formats
9
- */
10
- export declare function getChildBlocks(block: Block, allBlocks?: Block[]): Block[];
11
- /**
12
- * Check if a block is a container (has children or is marked as container)
13
- */
14
- export declare function isContainerBlock(block: Block, blockRegistry: {
15
- get: (type: string) => {
16
- isContainer?: boolean;
17
- } | undefined;
18
- }): boolean;
19
- /**
20
- * Find a block by ID recursively (including nested blocks)
21
- */
22
- export declare function findBlockById(blocks: Block[], id: string): Block | null;
23
- //# sourceMappingURL=blockHelpers.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"blockHelpers.d.ts","sourceRoot":"","sources":["blockHelpers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE1C;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,GAAE,KAAK,EAAO,GAAG,KAAK,EAAE,CAiC7E;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE;IAAE,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK;QAAE,WAAW,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,SAAS,CAAA;CAAE,GAAG,OAAO,CAGvI;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,MAAM,GAAG,KAAK,GAAG,IAAI,CAavE"}
@@ -1,65 +0,0 @@
1
- /**
2
- * Block Helper Utilities
3
- * Functions for working with blocks, including nested structures
4
- */
5
- /**
6
- * Get child blocks from a container block
7
- * Handles both Block[] and string[] formats
8
- */
9
- export function getChildBlocks(block, allBlocks = []) {
10
- if (!block.children || block.children.length === 0) {
11
- return [];
12
- }
13
- // If children are Block objects, return them directly
14
- if (block.children.length > 0 && typeof block.children[0] === 'object' && 'id' in block.children[0]) {
15
- return block.children;
16
- }
17
- // If children are IDs, resolve them from allBlocks (recursively search nested blocks)
18
- const childIds = block.children;
19
- const resolvedBlocks = [];
20
- function findBlockRecursive(blocks, id) {
21
- for (const b of blocks) {
22
- if (b.id === id)
23
- return b;
24
- if (b.children && Array.isArray(b.children) && b.children.length > 0) {
25
- if (typeof b.children[0] === 'object') {
26
- const found = findBlockRecursive(b.children, id);
27
- if (found)
28
- return found;
29
- }
30
- }
31
- }
32
- return null;
33
- }
34
- childIds.forEach(id => {
35
- const found = findBlockRecursive(allBlocks, id);
36
- if (found)
37
- resolvedBlocks.push(found);
38
- });
39
- return resolvedBlocks;
40
- }
41
- /**
42
- * Check if a block is a container (has children or is marked as container)
43
- */
44
- export function isContainerBlock(block, blockRegistry) {
45
- const definition = blockRegistry.get(block.type);
46
- return (definition === null || definition === void 0 ? void 0 : definition.isContainer) === true || (block.children !== undefined && block.children.length > 0);
47
- }
48
- /**
49
- * Find a block by ID recursively (including nested blocks)
50
- */
51
- export function findBlockById(blocks, id) {
52
- for (const block of blocks) {
53
- if (block.id === id) {
54
- return block;
55
- }
56
- if (block.children && Array.isArray(block.children) && block.children.length > 0) {
57
- if (typeof block.children[0] === 'object') {
58
- const found = findBlockById(block.children, id);
59
- if (found)
60
- return found;
61
- }
62
- }
63
- }
64
- return null;
65
- }
@@ -1,72 +0,0 @@
1
- /**
2
- * Block Helper Utilities
3
- * Functions for working with blocks, including nested structures
4
- */
5
-
6
- import { Block } from '../../types/block';
7
-
8
- /**
9
- * Get child blocks from a container block
10
- * Handles both Block[] and string[] formats
11
- */
12
- export function getChildBlocks(block: Block, allBlocks: Block[] = []): Block[] {
13
- if (!block.children || block.children.length === 0) {
14
- return [];
15
- }
16
-
17
- // If children are Block objects, return them directly
18
- if (block.children.length > 0 && typeof block.children[0] === 'object' && 'id' in block.children[0]) {
19
- return block.children as Block[];
20
- }
21
-
22
- // If children are IDs, resolve them from allBlocks (recursively search nested blocks)
23
- const childIds = block.children as string[];
24
- const resolvedBlocks: Block[] = [];
25
-
26
- function findBlockRecursive(blocks: Block[], id: string): Block | null {
27
- for (const b of blocks) {
28
- if (b.id === id) return b;
29
- if (b.children && Array.isArray(b.children) && b.children.length > 0) {
30
- if (typeof b.children[0] === 'object') {
31
- const found = findBlockRecursive(b.children as Block[], id);
32
- if (found) return found;
33
- }
34
- }
35
- }
36
- return null;
37
- }
38
-
39
- childIds.forEach(id => {
40
- const found = findBlockRecursive(allBlocks, id);
41
- if (found) resolvedBlocks.push(found);
42
- });
43
-
44
- return resolvedBlocks;
45
- }
46
-
47
- /**
48
- * Check if a block is a container (has children or is marked as container)
49
- */
50
- export function isContainerBlock(block: Block, blockRegistry: { get: (type: string) => { isContainer?: boolean } | undefined }): boolean {
51
- const definition = blockRegistry.get(block.type);
52
- return definition?.isContainer === true || (block.children !== undefined && block.children.length > 0);
53
- }
54
-
55
- /**
56
- * Find a block by ID recursively (including nested blocks)
57
- */
58
- export function findBlockById(blocks: Block[], id: string): Block | null {
59
- for (const block of blocks) {
60
- if (block.id === id) {
61
- return block;
62
- }
63
- if (block.children && Array.isArray(block.children) && block.children.length > 0) {
64
- if (typeof block.children[0] === 'object') {
65
- const found = findBlockById(block.children as Block[], id);
66
- if (found) return found;
67
- }
68
- }
69
- }
70
- return null;
71
- }
72
-
@@ -1,23 +0,0 @@
1
- /**
2
- * Plugin Configuration Validation Utilities
3
- * Validates plugin configuration and custom blocks
4
- */
5
- import { ClientBlockDefinition } from '../../types/block';
6
- /**
7
- * Check if a route requires the hero block
8
- */
9
- export declare function routeRequiresHeroBlock(route: string): boolean;
10
- /**
11
- * Find hero block definition in custom blocks
12
- */
13
- export declare function findHeroBlock(customBlocks: ClientBlockDefinition[]): ClientBlockDefinition | undefined;
14
- /**
15
- * Hook to validate hero block configuration
16
- * Only validates for routes that require it, and waits for customBlocks to load
17
- *
18
- * @param route - Current route (e.g., 'posts', 'editor', 'new')
19
- * @param customBlocks - Array of custom block definitions
20
- * @param propsCustomBlocks - Custom blocks from props (for immediate validation)
21
- */
22
- export declare function useHeroBlockValidation(route: string, customBlocks: ClientBlockDefinition[], propsCustomBlocks?: ClientBlockDefinition[]): void;
23
- //# sourceMappingURL=configValidation.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"configValidation.d.ts","sourceRoot":"","sources":["configValidation.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAO1D;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAE7D;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,YAAY,EAAE,qBAAqB,EAAE,GAAG,qBAAqB,GAAG,SAAS,CAEtG;AAED;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAClC,KAAK,EAAE,MAAM,EACb,YAAY,EAAE,qBAAqB,EAAE,EACrC,iBAAiB,CAAC,EAAE,qBAAqB,EAAE,GAC5C,IAAI,CAgGN"}