@dotcms/react 1.2.5 → 1.2.6-next.2

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 (49) hide show
  1. package/README.md +71 -17
  2. package/_virtual/_style-inject.esm.js +30 -0
  3. package/index.esm.js +9 -7097
  4. package/index.server.d.ts +1 -0
  5. package/index.server.esm.js +8 -0
  6. package/lib/next/components/Column/Column.esm.js +48 -0
  7. package/lib/next/components/Column/Column.module.css.esm.js +8 -0
  8. package/lib/next/components/Container/Container.esm.js +54 -0
  9. package/lib/next/components/Container/ContainerFallbacks.esm.js +60 -0
  10. package/lib/next/components/Contentlet/Contentlet.esm.js +87 -0
  11. package/lib/next/components/DotCMSBlockEditorRenderer/DotCMSBlockEditorRenderer.esm.js +46 -0
  12. package/lib/next/components/DotCMSBlockEditorRenderer/components/BlockEditorBlock.esm.js +179 -0
  13. package/lib/next/components/DotCMSBlockEditorRenderer/components/blocks/Code.esm.js +37 -0
  14. package/lib/next/components/DotCMSBlockEditorRenderer/components/blocks/DotContent.esm.js +47 -0
  15. package/lib/next/components/DotCMSBlockEditorRenderer/components/blocks/GridBlock.esm.js +44 -0
  16. package/lib/next/components/DotCMSBlockEditorRenderer/components/blocks/Image.esm.js +22 -0
  17. package/lib/next/components/DotCMSBlockEditorRenderer/components/blocks/Lists.esm.js +43 -0
  18. package/lib/next/components/DotCMSBlockEditorRenderer/components/blocks/NoComponentProvided.esm.js +40 -0
  19. package/lib/next/components/DotCMSBlockEditorRenderer/components/blocks/Table.esm.js +53 -0
  20. package/lib/next/components/DotCMSBlockEditorRenderer/components/blocks/Texts.esm.js +157 -0
  21. package/lib/next/components/DotCMSBlockEditorRenderer/components/blocks/Video.esm.js +42 -0
  22. package/lib/next/components/DotCMSEditableText/DotCMSEditableText.esm.js +181 -0
  23. package/lib/next/components/DotCMSEditableText/utils.esm.js +12 -0
  24. package/lib/next/components/DotCMSLayoutBody/DotCMSLayoutBody.esm.js +42 -0
  25. package/lib/next/components/DotCMSLayoutBody/DotCMSPageProvider.esm.js +30 -0
  26. package/lib/next/components/DotCMSLayoutBody/components/ErrorMessage.esm.js +43 -0
  27. package/lib/next/components/DotCMSShow/DotCMSShow.esm.js +49 -0
  28. package/lib/next/components/FallbackComponent/FallbackComponent.esm.js +54 -0
  29. package/lib/next/components/Row/Row.esm.js +30 -0
  30. package/lib/next/components/Row/Row.module.css.esm.js +8 -0
  31. package/lib/next/contexts/DotCMSPageContext.esm.js +16 -0
  32. package/lib/next/hooks/useAISearch.esm.js +119 -0
  33. package/lib/next/hooks/useCheckVisibleContent.esm.js +40 -0
  34. package/lib/next/hooks/useDotCMSShowWhen.esm.js +42 -0
  35. package/lib/next/hooks/useEditableDotCMSPage.esm.js +131 -0
  36. package/lib/next/hooks/useIsDevMode.esm.js +35 -0
  37. package/lib/next/hooks/useStyleEditorSchemas.esm.js +15 -0
  38. package/lib/next/utils/buildSlots.esm.js +43 -0
  39. package/package.json +3 -2
  40. package/src/index.d.ts +1 -0
  41. package/src/index.server.d.ts +11 -0
  42. package/src/lib/next/components/DotCMSBlockEditorRenderer/DotCMSBlockEditorRenderer.d.ts +2 -1
  43. package/src/lib/next/components/DotCMSBlockEditorRenderer/components/BlockEditorBlock.d.ts +2 -1
  44. package/src/lib/next/components/DotCMSBlockEditorRenderer/components/blocks/DotContent.d.ts +2 -1
  45. package/src/lib/next/components/DotCMSBlockEditorRenderer/components/blocks/GridBlock.d.ts +19 -0
  46. package/src/lib/next/components/DotCMSLayoutBody/DotCMSLayoutBody.d.ts +20 -1
  47. package/src/lib/next/components/DotCMSLayoutBody/DotCMSPageProvider.d.ts +18 -0
  48. package/src/lib/next/contexts/DotCMSPageContext.d.ts +3 -0
  49. package/src/lib/next/utils/buildSlots.d.ts +24 -0
@@ -0,0 +1 @@
1
+ export * from "./src/index.server";
@@ -0,0 +1,8 @@
1
+ export { DotCMSLayoutBody } from './lib/next/components/DotCMSLayoutBody/DotCMSLayoutBody.esm.js';
2
+ export { DotCMSShow } from './lib/next/components/DotCMSShow/DotCMSShow.esm.js';
3
+ export { useDotCMSShowWhen } from './lib/next/hooks/useDotCMSShowWhen.esm.js';
4
+ export { useEditableDotCMSPage } from './lib/next/hooks/useEditableDotCMSPage.esm.js';
5
+ export { DotCMSBlockEditorRenderer } from './lib/next/components/DotCMSBlockEditorRenderer/DotCMSBlockEditorRenderer.esm.js';
6
+ export { useAISearch } from './lib/next/hooks/useAISearch.esm.js';
7
+ export { useStyleEditorSchemas } from './lib/next/hooks/useStyleEditorSchemas.esm.js';
8
+ export { buildSlots } from './lib/next/utils/buildSlots.esm.js';
@@ -0,0 +1,48 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { getColumnPositionClasses, combineClasses } from '@dotcms/uve/internal';
3
+ import styles from './Column.module.css.esm.js';
4
+ import { Container } from '../Container/Container.esm.js';
5
+
6
+ /**
7
+ * @internal
8
+ *
9
+ * Renders a Column component that represents a single column in a 12-column grid system.
10
+ * The column's position and width are determined by the leftOffset and width properties
11
+ * from the dotCMS Page API. Uses CSS Grid classes for positioning.
12
+ *
13
+ * @example
14
+ * ```tsx
15
+ * <Column column={{
16
+ * leftOffset: 0,
17
+ * width: 6,
18
+ * styleClass: "custom-class",
19
+ * containers: []
20
+ * }} />
21
+ * ```
22
+ *
23
+ * @see {@link https://www.dotcms.com/docs/latest/page-rest-api-layout-as-a-service-laas}
24
+ * @export
25
+ * @param {ColumnProps} { column } - Column configuration object
26
+ * @return {JSX.Element} Rendered column with its containers positioned in the grid
27
+ */
28
+ function Column({
29
+ column
30
+ }) {
31
+ const {
32
+ startClass,
33
+ endClass
34
+ } = getColumnPositionClasses(column);
35
+ const combinedClasses = combineClasses([styles[endClass], styles[startClass]]);
36
+ return jsx("div", {
37
+ "data-dot": "column",
38
+ className: combinedClasses,
39
+ children: jsx("div", {
40
+ className: column.styleClass,
41
+ children: column.containers.map(container => jsx(Container, {
42
+ container: container
43
+ }, `${container.identifier}-${container.uuid}`))
44
+ })
45
+ });
46
+ }
47
+
48
+ export { Column };
@@ -0,0 +1,8 @@
1
+ import styleInject from '../../../../_virtual/_style-inject.esm.js';
2
+
3
+ var css = "._col-start-1_1myqa_1 {\n grid-column-start: 1;\n}\n\n._col-start-2_1myqa_5 {\n grid-column-start: 2;\n}\n\n._col-start-3_1myqa_9 {\n grid-column-start: 3;\n}\n\n._col-start-4_1myqa_13 {\n grid-column-start: 4;\n}\n\n._col-start-5_1myqa_17 {\n grid-column-start: 5;\n}\n\n._col-start-6_1myqa_21 {\n grid-column-start: 6;\n}\n\n._col-start-7_1myqa_25 {\n grid-column-start: 7;\n}\n\n._col-start-8_1myqa_29 {\n grid-column-start: 8;\n}\n\n._col-start-9_1myqa_33 {\n grid-column-start: 9;\n}\n\n._col-start-10_1myqa_37 {\n grid-column-start: 10;\n}\n\n._col-start-11_1myqa_41 {\n grid-column-start: 11;\n}\n\n._col-start-12_1myqa_45 {\n grid-column-start: 12;\n}\n\n._col-end-1_1myqa_49 {\n grid-column-end: 1;\n}\n\n._col-end-2_1myqa_53 {\n grid-column-end: 2;\n}\n\n._col-end-3_1myqa_57 {\n grid-column-end: 3;\n}\n\n._col-end-4_1myqa_61 {\n grid-column-end: 4;\n}\n\n._col-end-5_1myqa_65 {\n grid-column-end: 5;\n}\n\n._col-end-6_1myqa_69 {\n grid-column-end: 6;\n}\n\n._col-end-7_1myqa_73 {\n grid-column-end: 7;\n}\n\n._col-end-8_1myqa_77 {\n grid-column-end: 8;\n}\n\n._col-end-9_1myqa_81 {\n grid-column-end: 9;\n}\n\n._col-end-10_1myqa_85 {\n grid-column-end: 10;\n}\n\n._col-end-11_1myqa_89 {\n grid-column-end: 11;\n}\n\n._col-end-12_1myqa_93 {\n grid-column-end: 12;\n}\n\n._col-end-13_1myqa_97 {\n grid-column-end: 13;\n}\n";
4
+
5
+ styleInject(css);
6
+ var styles = {"col-start-1":"_col-start-1_1myqa_1","col-start-2":"_col-start-2_1myqa_5","col-start-3":"_col-start-3_1myqa_9","col-start-4":"_col-start-4_1myqa_13","col-start-5":"_col-start-5_1myqa_17","col-start-6":"_col-start-6_1myqa_21","col-start-7":"_col-start-7_1myqa_25","col-start-8":"_col-start-8_1myqa_29","col-start-9":"_col-start-9_1myqa_33","col-start-10":"_col-start-10_1myqa_37","col-start-11":"_col-start-11_1myqa_41","col-start-12":"_col-start-12_1myqa_45","col-end-1":"_col-end-1_1myqa_49","col-end-2":"_col-end-2_1myqa_53","col-end-3":"_col-end-3_1myqa_57","col-end-4":"_col-end-4_1myqa_61","col-end-5":"_col-end-5_1myqa_65","col-end-6":"_col-end-6_1myqa_69","col-end-7":"_col-end-7_1myqa_73","col-end-8":"_col-end-8_1myqa_77","col-end-9":"_col-end-9_1myqa_81","col-end-10":"_col-end-10_1myqa_85","col-end-11":"_col-end-11_1myqa_89","col-end-12":"_col-end-12_1myqa_93","col-end-13":"_col-end-13_1myqa_97"};
7
+
8
+ export { styles as default };
@@ -0,0 +1,54 @@
1
+ "use client";
2
+ import { jsx } from 'react/jsx-runtime';
3
+ import { useContext, useMemo } from 'react';
4
+ import { getContainersData, getContentletsInContainer, getDotContainerAttributes } from '@dotcms/uve/internal';
5
+ import { ContainerNotFound, EmptyContainer } from './ContainerFallbacks.esm.js';
6
+ import { DotCMSPageContext } from '../../contexts/DotCMSPageContext.esm.js';
7
+ import { Contentlet } from '../Contentlet/Contentlet.esm.js';
8
+
9
+ /**
10
+ * @internal
11
+ *
12
+ * Container component that renders DotCMS containers and their contentlets.
13
+ * This component is responsible for:
14
+ * - Rendering container content based on DotCMS Page API data
15
+ * - Handling empty container states
16
+ * - Providing proper data attributes for DotCMS functionality
17
+ * - Managing container contentlets rendering
18
+ *
19
+ * @component
20
+ * @param {DotCMSContainerRendererProps} props - Component properties
21
+ * @returns {JSX.Element} Rendered container with its contentlets or empty state message
22
+ *
23
+ * @example
24
+ * ```tsx
25
+ * <Container container={containerData} />
26
+ * ```
27
+ */
28
+ function Container({
29
+ container
30
+ }) {
31
+ const {
32
+ pageAsset
33
+ } = useContext(DotCMSPageContext);
34
+ const containerData = useMemo(() => getContainersData(pageAsset, container), [pageAsset, container]);
35
+ const contentlets = useMemo(() => getContentletsInContainer(pageAsset, container), [pageAsset, container]);
36
+ if (!containerData) {
37
+ return jsx(ContainerNotFound, {
38
+ identifier: container.identifier
39
+ });
40
+ }
41
+ const isEmpty = contentlets.length === 0;
42
+ const dotAttributes = getDotContainerAttributes(containerData);
43
+ if (isEmpty) {
44
+ return jsx(EmptyContainer, Object.assign({}, dotAttributes));
45
+ }
46
+ return jsx("div", Object.assign({}, dotAttributes, {
47
+ children: contentlets.map(contentlet => jsx(Contentlet, {
48
+ contentlet: contentlet,
49
+ container: JSON.stringify(containerData)
50
+ }, contentlet.identifier))
51
+ }));
52
+ }
53
+
54
+ export { Container };
@@ -0,0 +1,60 @@
1
+ "use client";
2
+ import { jsxs, jsx } from 'react/jsx-runtime';
3
+ import { useEffect } from 'react';
4
+ import { EMPTY_CONTAINER_STYLE_REACT } from '@dotcms/uve/internal';
5
+ import { useIsDevMode } from '../../hooks/useIsDevMode.esm.js';
6
+
7
+ /**
8
+ * @internal
9
+ *
10
+ * Component to display when a container is not found in the system.
11
+ * Only renders in development mode for debugging purposes.
12
+ *
13
+ * @component
14
+ * @param {Object} props - Component properties
15
+ * @param {string} props.identifier - Container identifier
16
+ * @returns {JSX.Element | null} Message about missing container or null in production
17
+ */
18
+ const ContainerNotFound = ({
19
+ identifier
20
+ }) => {
21
+ const isDevMode = useIsDevMode();
22
+ useEffect(() => {
23
+ if (!isDevMode) {
24
+ return;
25
+ }
26
+ console.error(`Container with identifier ${identifier} not found`);
27
+ }, [identifier, isDevMode]);
28
+ if (!isDevMode) {
29
+ return null;
30
+ }
31
+ return jsxs("div", {
32
+ "data-testid": "container-not-found",
33
+ style: EMPTY_CONTAINER_STYLE_REACT,
34
+ children: ["This container with identifier ", identifier, " was not found."]
35
+ });
36
+ };
37
+ /**
38
+ * @internal
39
+ *
40
+ * Component to display when a container is empty.
41
+ *
42
+ * @param {DotContainerAttributes} dotAttributes
43
+ * @return {*}
44
+ */
45
+ const EmptyContainer = dotAttributes => {
46
+ const isDevMode = useIsDevMode();
47
+ if (!isDevMode) {
48
+ return null;
49
+ }
50
+ return jsx("div", Object.assign({}, dotAttributes, {
51
+ style: EMPTY_CONTAINER_STYLE_REACT,
52
+ children: jsx("span", {
53
+ "data-testid": "empty-container-message",
54
+ "data-dot-object": "empty-content",
55
+ children: "This container is empty."
56
+ })
57
+ }));
58
+ };
59
+
60
+ export { ContainerNotFound, EmptyContainer };
@@ -0,0 +1,87 @@
1
+ "use client";
2
+ import { jsx, Fragment } from 'react/jsx-runtime';
3
+ import { useRef, useMemo, useContext } from 'react';
4
+ import { getDotContentletAttributes, CUSTOM_NO_COMPONENT } from '@dotcms/uve/internal';
5
+ import { DotCMSPageContext } from '../../contexts/DotCMSPageContext.esm.js';
6
+ import { useCheckVisibleContent } from '../../hooks/useCheckVisibleContent.esm.js';
7
+ import { useIsDevMode } from '../../hooks/useIsDevMode.esm.js';
8
+ import { FallbackComponent } from '../FallbackComponent/FallbackComponent.esm.js';
9
+
10
+ /**
11
+ * CSS class name for contentlet elements
12
+ */
13
+ const CONTENTLET_CLASS = 'dotcms-contentlet';
14
+ /**
15
+ * Contentlet component that renders DotCMS content with development mode support
16
+ *
17
+ * @component
18
+ * @param {DotCMSContentletRendererProps} props - Component properties
19
+ * @param {DotCMSContentlet} props.contentlet - The contentlet to be rendered
20
+ * @param {string} props.container - The container identifier
21
+ * @returns {JSX.Element} Rendered contentlet with appropriate wrapper and attributes
22
+ *
23
+ * @example
24
+ * ```tsx
25
+ * <Contentlet
26
+ * contentlet={myContentlet}
27
+ * container="container-1"
28
+ * />
29
+ * ```
30
+ */
31
+ function Contentlet({
32
+ contentlet,
33
+ container
34
+ }) {
35
+ const ref = useRef(null);
36
+ const isDevMode = useIsDevMode();
37
+ const haveContent = useCheckVisibleContent(ref);
38
+ const style = useMemo(() => isDevMode ? {
39
+ minHeight: haveContent ? undefined : '4rem'
40
+ } : {}, [isDevMode, haveContent]);
41
+ // UVE attributes - always applied
42
+ const dotAttributes = useMemo(() => getDotContentletAttributes(contentlet, container), [contentlet, container]);
43
+ return jsx("div", Object.assign({}, dotAttributes, {
44
+ "data-dot-object": "contentlet",
45
+ className: CONTENTLET_CLASS,
46
+ ref: ref,
47
+ style: style,
48
+ children: jsx(CustomComponent, {
49
+ contentlet: contentlet
50
+ })
51
+ }));
52
+ }
53
+ /**
54
+ * Renders a custom component based on the contentlet type or falls back to a default component
55
+ *
56
+ * @component
57
+ * @param {CustomComponentProps} props - Component properties
58
+ * @param {DotCMSContentlet} props.contentlet - The contentlet data to render
59
+ * @returns {JSX.Element} The rendered custom component or fallback component
60
+ *
61
+ * @internal
62
+ */
63
+ function CustomComponent({
64
+ contentlet
65
+ }) {
66
+ const {
67
+ userComponents,
68
+ slots
69
+ } = useContext(DotCMSPageContext);
70
+ const slotNode = slots == null ? void 0 : slots[contentlet == null ? void 0 : contentlet.identifier];
71
+ if (slotNode !== undefined) {
72
+ return jsx(Fragment, {
73
+ children: slotNode
74
+ });
75
+ }
76
+ const UserComponent = userComponents[contentlet == null ? void 0 : contentlet.contentType];
77
+ if (UserComponent) {
78
+ return jsx(UserComponent, Object.assign({}, contentlet));
79
+ }
80
+ const UserNoComponent = userComponents[CUSTOM_NO_COMPONENT];
81
+ return jsx(FallbackComponent, {
82
+ UserNoComponent: UserNoComponent,
83
+ contentlet: contentlet
84
+ });
85
+ }
86
+
87
+ export { CONTENTLET_CLASS, Contentlet };
@@ -0,0 +1,46 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { isValidBlocks } from '@dotcms/uve/internal';
3
+ import { BlockEditorBlock } from './components/BlockEditorBlock.esm.js';
4
+
5
+ /**
6
+ * BlockEditorRenderer component for rendering block editor field.
7
+ *
8
+ * @component
9
+ * @param {Object} props - The component props.
10
+ * @param {BlockEditorNode} props.blocks - The blocks of content to render.
11
+ * @param {CustomRenderer} [props.customRenderers] - Optional custom renderers for specific block types.
12
+ * @param {string} [props.className] - Optional CSS class name for the container div.
13
+ * @param {React.CSSProperties} [props.style] - Optional inline styles for the container div.
14
+ * @returns {JSX.Element} A div containing the rendered blocks of content.
15
+ */
16
+ const DotCMSBlockEditorRenderer = ({
17
+ blocks,
18
+ style,
19
+ className,
20
+ customRenderers,
21
+ isDevMode: _isDevMode = false
22
+ }) => {
23
+ const validationResult = isValidBlocks(blocks);
24
+ if (validationResult.error) {
25
+ console.error(validationResult.error);
26
+ if (_isDevMode) {
27
+ return jsx("div", {
28
+ "data-testid": "invalid-blocks-message",
29
+ children: validationResult.error
30
+ });
31
+ }
32
+ return null;
33
+ }
34
+ return jsx("div", {
35
+ className: className,
36
+ style: style,
37
+ "data-testid": "dot-block-editor-container",
38
+ children: jsx(BlockEditorBlock, {
39
+ content: blocks == null ? void 0 : blocks.content,
40
+ customRenderers: customRenderers,
41
+ isDevMode: _isDevMode
42
+ })
43
+ });
44
+ };
45
+
46
+ export { DotCMSBlockEditorRenderer };
@@ -0,0 +1,179 @@
1
+ import { jsx, jsxs } from 'react/jsx-runtime';
2
+ import { BlockEditorDefaultBlocks } from '@dotcms/types/internal';
3
+ import { getUVEState } from '@dotcms/uve';
4
+ import { CodeBlock, BlockQuote } from './blocks/Code.esm.js';
5
+ import { DotContent } from './blocks/DotContent.esm.js';
6
+ import { GridBlock } from './blocks/GridBlock.esm.js';
7
+ import { DotCMSImage } from './blocks/Image.esm.js';
8
+ import { ListItem, OrderedList, BulletList } from './blocks/Lists.esm.js';
9
+ import { TableRenderer } from './blocks/Table.esm.js';
10
+ import { TextBlock, Heading, Paragraph } from './blocks/Texts.esm.js';
11
+ import { DotCMSVideo } from './blocks/Video.esm.js';
12
+
13
+ /**
14
+ * Renders a block editor item based on the provided content and custom renderers.
15
+ *
16
+ * @param content - The content nodes to render.
17
+ * @param customRenderers - Optional custom renderers for specific node types.
18
+ * @returns The rendered block editor item.
19
+ */
20
+ const BlockEditorBlock = ({
21
+ content,
22
+ customRenderers,
23
+ isDevMode
24
+ }) => {
25
+ if (!content) {
26
+ return null;
27
+ }
28
+ return content == null ? void 0 : content.map((node, index) => {
29
+ var _node$content;
30
+ const CustomRendererComponent = customRenderers == null ? void 0 : customRenderers[node.type];
31
+ const key = `${node.type}-${index}`;
32
+ if (CustomRendererComponent) {
33
+ return jsx(CustomRendererComponent, {
34
+ node: node,
35
+ children: jsx(BlockEditorBlock, {
36
+ content: node.content,
37
+ customRenderers: customRenderers,
38
+ isDevMode: isDevMode
39
+ })
40
+ }, key);
41
+ }
42
+ switch (node.type) {
43
+ case BlockEditorDefaultBlocks.PARAGRAPH:
44
+ return jsx(Paragraph, {
45
+ node: node,
46
+ children: jsx(BlockEditorBlock, {
47
+ content: node.content,
48
+ customRenderers: customRenderers,
49
+ isDevMode: isDevMode
50
+ })
51
+ }, key);
52
+ case BlockEditorDefaultBlocks.HEADING:
53
+ return jsx(Heading, {
54
+ node: node,
55
+ children: jsx(BlockEditorBlock, {
56
+ content: node.content,
57
+ customRenderers: customRenderers,
58
+ isDevMode: isDevMode
59
+ })
60
+ }, key);
61
+ case BlockEditorDefaultBlocks.TEXT:
62
+ return jsx(TextBlock, Object.assign({}, node), key);
63
+ case BlockEditorDefaultBlocks.BULLET_LIST:
64
+ return jsx(BulletList, {
65
+ children: jsx(BlockEditorBlock, {
66
+ content: node.content,
67
+ customRenderers: customRenderers,
68
+ isDevMode: isDevMode
69
+ })
70
+ }, key);
71
+ case BlockEditorDefaultBlocks.ORDERED_LIST:
72
+ return jsx(OrderedList, {
73
+ children: jsx(BlockEditorBlock, {
74
+ content: node.content,
75
+ customRenderers: customRenderers,
76
+ isDevMode: isDevMode
77
+ })
78
+ }, key);
79
+ case BlockEditorDefaultBlocks.LIST_ITEM:
80
+ return jsx(ListItem, {
81
+ children: jsx(BlockEditorBlock, {
82
+ content: node.content,
83
+ customRenderers: customRenderers,
84
+ isDevMode: isDevMode
85
+ })
86
+ }, key);
87
+ case BlockEditorDefaultBlocks.BLOCK_QUOTE:
88
+ return jsx(BlockQuote, {
89
+ children: jsx(BlockEditorBlock, {
90
+ content: node.content,
91
+ customRenderers: customRenderers,
92
+ isDevMode: isDevMode
93
+ })
94
+ }, key);
95
+ case BlockEditorDefaultBlocks.CODE_BLOCK:
96
+ return jsx(CodeBlock, {
97
+ node: node,
98
+ children: jsx(BlockEditorBlock, {
99
+ content: node.content,
100
+ customRenderers: customRenderers,
101
+ isDevMode: isDevMode
102
+ })
103
+ }, key);
104
+ case BlockEditorDefaultBlocks.HARDBREAK:
105
+ return jsx("br", {}, key);
106
+ case BlockEditorDefaultBlocks.HORIZONTAL_RULE:
107
+ return jsx("hr", {}, key);
108
+ case BlockEditorDefaultBlocks.DOT_IMAGE:
109
+ return jsx(DotCMSImage, {
110
+ node: node
111
+ }, key);
112
+ case BlockEditorDefaultBlocks.DOT_VIDEO:
113
+ return jsx(DotCMSVideo, {
114
+ node: node
115
+ }, key);
116
+ case BlockEditorDefaultBlocks.TABLE:
117
+ return jsx(TableRenderer, {
118
+ content: (_node$content = node.content) != null ? _node$content : [],
119
+ blockEditorItem: BlockEditorBlock
120
+ }, key);
121
+ case BlockEditorDefaultBlocks.GRID_BLOCK:
122
+ return jsx(GridBlock, {
123
+ node: node,
124
+ blockEditorBlock: BlockEditorBlock,
125
+ customRenderers: customRenderers
126
+ }, key);
127
+ case BlockEditorDefaultBlocks.DOT_CONTENT:
128
+ return jsx(DotContent, {
129
+ customRenderers: customRenderers,
130
+ node: node,
131
+ isDevMode: isDevMode
132
+ }, key);
133
+ default:
134
+ return jsx(UnknownBlock, {
135
+ node: node
136
+ }, key);
137
+ }
138
+ });
139
+ };
140
+ /**
141
+ * Renders an unknown block type with a warning message in development mode.
142
+ *
143
+ * @param node - The block editor node to render.
144
+ * @returns The rendered block or null if in production mode.
145
+ */
146
+ const UnknownBlock = ({
147
+ node
148
+ }) => {
149
+ const style = {
150
+ backgroundColor: '#fff5f5',
151
+ color: '#333',
152
+ padding: '1rem',
153
+ borderRadius: '0.5rem',
154
+ marginBottom: '1rem',
155
+ marginTop: '1rem',
156
+ border: '1px solid #fc8181'
157
+ };
158
+ if (getUVEState()) {
159
+ return jsxs("div", {
160
+ style: style,
161
+ children: [jsx("strong", {
162
+ style: {
163
+ color: '#c53030'
164
+ },
165
+ children: "Warning:"
166
+ }), " The block type", ' ', jsx("strong", {
167
+ children: node.type
168
+ }), " is not recognized. Please check your", ' ', jsx("a", {
169
+ href: "https://dev.dotcms.com/docs/block-editor",
170
+ target: "_blank",
171
+ rel: "noopener noreferrer",
172
+ children: "configuration"
173
+ }), ' ', "or contact support for assistance."]
174
+ });
175
+ }
176
+ return null;
177
+ };
178
+
179
+ export { BlockEditorBlock };
@@ -0,0 +1,37 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+
3
+ /**
4
+ * Renders a code block component.
5
+ *
6
+ * @param attrs - The attributes of the code block.
7
+ * @param children - The content of the code block.
8
+ * @returns The rendered code block component.
9
+ */
10
+ const CodeBlock = ({
11
+ node,
12
+ children
13
+ }) => {
14
+ var _node$attrs;
15
+ const language = (node == null || (_node$attrs = node.attrs) == null ? void 0 : _node$attrs.language) || '';
16
+ return jsx("pre", {
17
+ "data-language": language,
18
+ children: jsx("code", {
19
+ children: children
20
+ })
21
+ });
22
+ };
23
+ /**
24
+ * Renders a blockquote component.
25
+ *
26
+ * @param children - The content to be rendered inside the blockquote.
27
+ * @returns The rendered blockquote component.
28
+ */
29
+ const BlockQuote = ({
30
+ children
31
+ }) => {
32
+ return jsx("blockquote", {
33
+ children: children
34
+ });
35
+ };
36
+
37
+ export { BlockQuote, CodeBlock };
@@ -0,0 +1,47 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { NoComponentProvided } from './NoComponentProvided.esm.js';
3
+
4
+ const DOT_CONTENT_NO_DATA_MESSAGE = '[DotCMSBlockEditorRenderer]: No data provided for Contentlet Block. Try to add a contentlet to the block editor. If the error persists, please contact the DotCMS support team.';
5
+ const DOT_CONTENT_NO_MATCHING_COMPONENT_MESSAGE = contentType => `[DotCMSBlockEditorRenderer]: No matching component found for content type: ${contentType}. Provide a custom renderer for this content type to fix this error.`;
6
+ /**
7
+ * Renders a DotContent component.
8
+ *
9
+ * @param {DotContentProps} props - The props for the DotContent component.
10
+ * @returns {JSX.Element} The rendered DotContent component.
11
+ */
12
+ const DotContent = ({
13
+ customRenderers,
14
+ node,
15
+ isDevMode: _isDevMode = false
16
+ }) => {
17
+ const {
18
+ attrs = {}
19
+ } = node;
20
+ const {
21
+ data
22
+ } = attrs;
23
+ if (!data) {
24
+ console.error(DOT_CONTENT_NO_DATA_MESSAGE);
25
+ return null;
26
+ }
27
+ const {
28
+ contentType = 'Unknown Content Type'
29
+ } = data;
30
+ const Component = customRenderers == null ? void 0 : customRenderers[contentType];
31
+ /* In dev mode, show a helpful message for unknown content types */
32
+ if (_isDevMode && !Component) {
33
+ return jsx(NoComponentProvided, {
34
+ contentType: contentType
35
+ });
36
+ }
37
+ /* In production, use default component if no matching component found */
38
+ if (!Component) {
39
+ console.warn(DOT_CONTENT_NO_MATCHING_COMPONENT_MESSAGE(contentType));
40
+ return null;
41
+ }
42
+ return jsx(Component, {
43
+ node: node
44
+ });
45
+ };
46
+
47
+ export { DotContent };
@@ -0,0 +1,44 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+
3
+ /**
4
+ * Renders a grid block with two columns using a 12-column grid system.
5
+ *
6
+ * @param node - The grid block node containing column configuration.
7
+ * @param blockEditorBlock - The block editor component for rendering nested content.
8
+ * @param customRenderers - Optional custom renderers for nested blocks.
9
+ */
10
+ const GridBlock = ({
11
+ node,
12
+ blockEditorBlock,
13
+ customRenderers
14
+ }) => {
15
+ var _node$attrs, _node$content;
16
+ const BlockEditorBlockComponent = blockEditorBlock;
17
+ const rawCols = Array.isArray((_node$attrs = node.attrs) == null ? void 0 : _node$attrs.columns) ? node.attrs.columns : [6, 6];
18
+ const cols = rawCols.length === 2 && rawCols.every(v => typeof v === 'number' && Number.isFinite(v)) ? rawCols : [6, 6];
19
+ return jsx("div", {
20
+ "data-type": "gridBlock",
21
+ className: "grid-block",
22
+ style: {
23
+ display: 'grid',
24
+ gridTemplateColumns: 'repeat(12, 1fr)',
25
+ gap: '1rem'
26
+ },
27
+ children: (_node$content = node.content) == null ? void 0 : _node$content.map((column, index) => {
28
+ var _cols$index;
29
+ return jsx("div", {
30
+ "data-type": "gridColumn",
31
+ className: "grid-block__column",
32
+ style: {
33
+ gridColumn: `span ${(_cols$index = cols[index]) != null ? _cols$index : 6}`
34
+ },
35
+ children: jsx(BlockEditorBlockComponent, {
36
+ content: column.content,
37
+ customRenderers: customRenderers
38
+ })
39
+ }, `gridColumn-${index}`);
40
+ })
41
+ });
42
+ };
43
+
44
+ export { GridBlock };
@@ -0,0 +1,22 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+
3
+ /**
4
+ * Renders an image component for dotCMS.
5
+ *
6
+ * @param node - The node for the DotCMSImage component.
7
+ * @returns The rendered image component.
8
+ */
9
+ const DotCMSImage = ({
10
+ node
11
+ }) => {
12
+ const {
13
+ src,
14
+ alt
15
+ } = node.attrs;
16
+ return jsx("img", {
17
+ alt: alt,
18
+ src: src
19
+ });
20
+ };
21
+
22
+ export { DotCMSImage };