@dotcms/react 0.0.1-beta.27 → 0.0.1-beta.29

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.
package/next.esm.js CHANGED
@@ -2,11 +2,10 @@ import { jsxs, jsx } from 'react/jsx-runtime';
2
2
  import { createContext, useContext, useState, useEffect, useLayoutEffect, useRef, useMemo } from 'react';
3
3
  import { s as styleInject } from './web.url-search-params.size.esm.js';
4
4
  import { UVE_MODE, UVEEventType, DotCMSUVEAction } from '@dotcms/types';
5
- import { getUVEState, initUVE, createUVESubscription, sendMessageToUVE } from '@dotcms/uve';
6
- import { DEVELOPMENT_MODE, EMPTY_CONTAINER_STYLE_REACT, getDotContentletAttributes, CUSTOM_NO_COMPONENT, getContainersData, getContentletsInContainer, getDotContainerAttributes, getColumnPositionClasses, combineClasses, __DEFAULT_TINYMCE_CONFIG__, __BASE_TINYMCE_CONFIG_WITH_NO_DEFAULT__, __TINYMCE_PATH_ON_DOTCMS__ } from '@dotcms/uve/internal';
7
- import { updateNavigation } from '@dotcms/client';
5
+ import { getUVEState, initUVE, updateNavigation, createUVESubscription, sendMessageToUVE } from '@dotcms/uve';
6
+ import { DEVELOPMENT_MODE, EMPTY_CONTAINER_STYLE_REACT, getDotContentletAttributes, CUSTOM_NO_COMPONENT, getContainersData, getContentletsInContainer, getDotContainerAttributes, getColumnPositionClasses, combineClasses, __DEFAULT_TINYMCE_CONFIG__, __BASE_TINYMCE_CONFIG_WITH_NO_DEFAULT__, __TINYMCE_PATH_ON_DOTCMS__, isValidBlocks } from '@dotcms/uve/internal';
8
7
  import { Editor } from '@tinymce/tinymce-react';
9
- import { __DOTCMS_UVE_EVENT__ } from '@dotcms/types/internal';
8
+ import { __DOTCMS_UVE_EVENT__, BlockEditorDefaultBlocks } from '@dotcms/types/internal';
10
9
 
11
10
  /**
12
11
  * The `PageContext` is a React context that provides access to the DotCMS page context.
@@ -607,39 +606,39 @@ const DotCMSShow = ({
607
606
  * </div>
608
607
  * );
609
608
  * ```
610
- * @param {DotCMSEditablePage} editablePage - The initial editable page data from client.page.get().
609
+ * @param {DotCMSPageResponse} pageResponse - The initial editable page data from client.page.get().
611
610
  *
612
- * @returns {DotCMSEditablePage} The updated editable page state that reflects any changes made in the UVE.
611
+ * @returns {DotCMSPageResponse} The updated editable page state that reflects any changes made in the UVE.
613
612
  * The structure includes page data and any GraphQL content that was requested.
614
613
  */
615
- const useEditableDotCMSPage = editablePage => {
616
- const [updatedEditablePage, setUpdatedEditablePage] = useState(editablePage);
614
+ const useEditableDotCMSPage = pageResponse => {
615
+ const [updatedPageResponse, setUpdatedPageResponse] = useState(pageResponse);
617
616
  useEffect(() => {
618
- var _editablePage$page$pa, _editablePage$page;
617
+ var _pageResponse$pageAss, _pageResponse$pageAss2;
619
618
  if (!getUVEState()) {
620
619
  return;
621
620
  }
622
- const pageURI = (_editablePage$page$pa = editablePage == null || (_editablePage$page = editablePage.page) == null ? void 0 : _editablePage$page.pageURI) != null ? _editablePage$page$pa : '/';
621
+ const pageURI = (_pageResponse$pageAss = pageResponse == null || (_pageResponse$pageAss2 = pageResponse.pageAsset) == null || (_pageResponse$pageAss2 = _pageResponse$pageAss2.page) == null ? void 0 : _pageResponse$pageAss2.pageURI) != null ? _pageResponse$pageAss : '/';
623
622
  const {
624
623
  destroyUVESubscriptions
625
- } = initUVE(editablePage);
624
+ } = initUVE(pageResponse);
626
625
  // Update the navigation to the pageURI
627
626
  updateNavigation(pageURI);
628
627
  return () => {
629
628
  destroyUVESubscriptions();
630
629
  };
631
- }, [editablePage]);
630
+ }, [pageResponse]);
632
631
  useEffect(() => {
633
632
  const {
634
633
  unsubscribe
635
634
  } = createUVESubscription(UVEEventType.CONTENT_CHANGES, payload => {
636
- setUpdatedEditablePage(payload);
635
+ setUpdatedPageResponse(payload);
637
636
  });
638
637
  return () => {
639
638
  unsubscribe();
640
639
  };
641
640
  }, []);
642
- return updatedEditablePage;
641
+ return updatedPageResponse;
643
642
  };
644
643
 
645
644
  const DEFAULT_TINYMCE_CONFIG = Object.assign({}, __DEFAULT_TINYMCE_CONFIG__, {
@@ -814,4 +813,543 @@ function DotCMSEditableText({
814
813
  });
815
814
  }
816
815
 
817
- export { DotCMSEditableText, DotCMSLayoutBody, DotCMSShow, useDotCMSShowWhen, useEditableDotCMSPage };
816
+ /**
817
+ * Renders a code block component.
818
+ *
819
+ * @param attrs - The attributes of the code block.
820
+ * @param children - The content of the code block.
821
+ * @returns The rendered code block component.
822
+ */
823
+ const CodeBlock = ({
824
+ node,
825
+ children
826
+ }) => {
827
+ var _node$attrs;
828
+ const language = (node == null || (_node$attrs = node.attrs) == null ? void 0 : _node$attrs.language) || '';
829
+ return jsx("pre", {
830
+ "data-language": language,
831
+ children: jsx("code", {
832
+ children: children
833
+ })
834
+ });
835
+ };
836
+ /**
837
+ * Renders a blockquote component.
838
+ *
839
+ * @param children - The content to be rendered inside the blockquote.
840
+ * @returns The rendered blockquote component.
841
+ */
842
+ const BlockQuote = ({
843
+ children
844
+ }) => {
845
+ return jsx("blockquote", {
846
+ children: children
847
+ });
848
+ };
849
+
850
+ /**
851
+ * Renders a DotContent component.
852
+ *
853
+ * @param {DotContentProps} props - The props for the DotContent component.
854
+ * @returns {JSX.Element} The rendered DotContent component.
855
+ */
856
+ const DotContent = ({
857
+ customRenderers,
858
+ node
859
+ }) => {
860
+ const isDevMode = useIsDevMode();
861
+ const attrs = (node == null ? void 0 : node.attrs) || {};
862
+ const data = attrs.data;
863
+ if (!data) {
864
+ console.error('DotContent: No data provided');
865
+ return null;
866
+ }
867
+ const contentType = data.contentType || 'Unknown Content Type';
868
+ const Component = customRenderers[contentType];
869
+ // In dev mode, show a helpful message for unknown content types
870
+ if (isDevMode && !Component) {
871
+ return jsxs("div", {
872
+ children: ["Unknown ContentType: ", contentType]
873
+ });
874
+ }
875
+ // In production, use default component if no matching component found
876
+ if (!Component) {
877
+ console.error('DotContent: No matching component found for content type', contentType);
878
+ return null;
879
+ }
880
+ return jsx(Component, Object.assign({}, node));
881
+ };
882
+
883
+ /**
884
+ * Renders an image component for dotCMS.
885
+ *
886
+ * @param node - The node for the DotCMSImage component.
887
+ * @returns The rendered image component.
888
+ */
889
+ const DotCMSImage = ({
890
+ node
891
+ }) => {
892
+ const {
893
+ src,
894
+ alt
895
+ } = node.attrs;
896
+ return jsx("img", {
897
+ alt: alt,
898
+ src: src
899
+ });
900
+ };
901
+
902
+ /**
903
+ * ListItem component represents a list item in a block editor.
904
+ *
905
+ * @param children - The content of the list item.
906
+ * @returns The rendered list item element.
907
+ */
908
+ const ListItem = ({
909
+ children
910
+ }) => {
911
+ return jsx("li", {
912
+ children: children
913
+ });
914
+ };
915
+ /**
916
+ * Renders an ordered list component.
917
+ *
918
+ * @param children - The content to be rendered inside the ordered list.
919
+ * @returns The ordered list component.
920
+ */
921
+ const OrderedList = ({
922
+ children
923
+ }) => {
924
+ return jsx("ol", {
925
+ children: children
926
+ });
927
+ };
928
+ /**
929
+ * Renders a bullet list component.
930
+ *
931
+ * @param children - The content of the bullet list.
932
+ * @returns The rendered bullet list component.
933
+ */
934
+ const BulletList = ({
935
+ children
936
+ }) => {
937
+ return jsx("ul", {
938
+ children: children
939
+ });
940
+ };
941
+
942
+ /**
943
+ * Renders a table component for the Block Editor.
944
+ *
945
+ * @param content - The content of the table.
946
+ * @param blockEditorItem - The Block Editor item component.
947
+ */
948
+ const TableRenderer = ({
949
+ content,
950
+ blockEditorItem
951
+ }) => {
952
+ const BlockEditorItemComponent = blockEditorItem;
953
+ const renderTableContent = node => {
954
+ var _node$content;
955
+ return jsx(BlockEditorItemComponent, {
956
+ content: (_node$content = node.content) != null ? _node$content : []
957
+ });
958
+ };
959
+ return jsxs("table", {
960
+ children: [jsx("thead", {
961
+ children: content.slice(0, 1).map((rowNode, rowIndex) => {
962
+ var _rowNode$content;
963
+ return jsx("tr", {
964
+ children: (_rowNode$content = rowNode.content) == null ? void 0 : _rowNode$content.map((cellNode, cellIndex) => {
965
+ var _cellNode$attrs, _cellNode$attrs2;
966
+ return jsx("th", {
967
+ colSpan: Number(((_cellNode$attrs = cellNode.attrs) == null ? void 0 : _cellNode$attrs.colspan) || 1),
968
+ rowSpan: Number(((_cellNode$attrs2 = cellNode.attrs) == null ? void 0 : _cellNode$attrs2.rowspan) || 1),
969
+ children: renderTableContent(cellNode)
970
+ }, `${cellNode.type}-${cellIndex}`);
971
+ })
972
+ }, `${rowNode.type}-${rowIndex}`);
973
+ })
974
+ }), jsx("tbody", {
975
+ children: content.slice(1).map((rowNode, rowIndex) => {
976
+ var _rowNode$content2;
977
+ return jsx("tr", {
978
+ children: (_rowNode$content2 = rowNode.content) == null ? void 0 : _rowNode$content2.map((cellNode, cellIndex) => {
979
+ var _cellNode$attrs3, _cellNode$attrs4;
980
+ return jsx("td", {
981
+ colSpan: Number(((_cellNode$attrs3 = cellNode.attrs) == null ? void 0 : _cellNode$attrs3.colspan) || 1),
982
+ rowSpan: Number(((_cellNode$attrs4 = cellNode.attrs) == null ? void 0 : _cellNode$attrs4.rowspan) || 1),
983
+ children: renderTableContent(cellNode)
984
+ }, `${cellNode.type}-${cellIndex}`);
985
+ })
986
+ }, `${rowNode.type}-${rowIndex}`);
987
+ })
988
+ })]
989
+ });
990
+ };
991
+
992
+ /**
993
+ * Renders the text in bold.
994
+ *
995
+ * @param children - The content to be rendered in bold.
996
+ */
997
+ const Bold = ({
998
+ children
999
+ }) => jsx("strong", {
1000
+ children: children
1001
+ });
1002
+ /**
1003
+ * Renders the text in italic format.
1004
+ *
1005
+ * @param children - The content to be rendered in italic.
1006
+ */
1007
+ const Italic = ({
1008
+ children
1009
+ }) => jsx("em", {
1010
+ children: children
1011
+ });
1012
+ /**
1013
+ * Renders a strike-through text.
1014
+ *
1015
+ * @param children - The content to be rendered within the strike-through element.
1016
+ */
1017
+ const Strike = ({
1018
+ children
1019
+ }) => jsx("s", {
1020
+ children: children
1021
+ });
1022
+ /**
1023
+ * Renders an underline element for the given children.
1024
+ *
1025
+ * @param children - The content to be underlined.
1026
+ */
1027
+ const Underline = ({
1028
+ children
1029
+ }) => jsx("u", {
1030
+ children: children
1031
+ });
1032
+ /**
1033
+ * Renders a paragraph element.
1034
+ *
1035
+ * @param children - The content of the paragraph.
1036
+ * @param attrs - The style attributes for the paragraph.
1037
+ * @returns The rendered paragraph element.
1038
+ */
1039
+ const Paragraph = ({
1040
+ children,
1041
+ node
1042
+ }) => {
1043
+ const attrs = (node == null ? void 0 : node.attrs) || {};
1044
+ return jsx("p", {
1045
+ style: attrs,
1046
+ children: children
1047
+ });
1048
+ };
1049
+ /**
1050
+ * Renders a link component.
1051
+ *
1052
+ * @param children - The content of the link.
1053
+ * @param attrs - The attributes to be applied to the link.
1054
+ * @returns The rendered link component.
1055
+ */
1056
+ const Link = ({
1057
+ children,
1058
+ attrs
1059
+ }) => {
1060
+ return jsx("a", Object.assign({}, attrs, {
1061
+ children: children
1062
+ }));
1063
+ };
1064
+ /**
1065
+ * Renders a heading element with the specified level.
1066
+ *
1067
+ * @param children - The content of the heading.
1068
+ * @param attrs - The attributes for the heading.
1069
+ * @returns The rendered heading element.
1070
+ */
1071
+ const Heading = ({
1072
+ children,
1073
+ node
1074
+ }) => {
1075
+ const attrs = (node == null ? void 0 : node.attrs) || {};
1076
+ const level = attrs.level || 1;
1077
+ const Tag = `h${level}`;
1078
+ return jsx(Tag, {
1079
+ children: children
1080
+ });
1081
+ };
1082
+ /**
1083
+ * Renders the superscript text.
1084
+ *
1085
+ * @param children - The content to be rendered as superscript.
1086
+ */
1087
+ const Superscript = ({
1088
+ children
1089
+ }) => jsx("sup", {
1090
+ children: children
1091
+ });
1092
+ /**
1093
+ * Renders a subscript element.
1094
+ *
1095
+ * @param children - The content to be rendered as subscript.
1096
+ */
1097
+ const Subscript = ({
1098
+ children
1099
+ }) => jsx("sub", {
1100
+ children: children
1101
+ });
1102
+ const nodeMarks = {
1103
+ bold: Bold,
1104
+ link: Link,
1105
+ italic: Italic,
1106
+ strike: Strike,
1107
+ subscript: Subscript,
1108
+ underline: Underline,
1109
+ superscript: Superscript
1110
+ };
1111
+ const defaultMark = {
1112
+ type: '',
1113
+ attrs: {}
1114
+ };
1115
+ /**
1116
+ * Renders a text block with optional marks.
1117
+ *
1118
+ * @param props - The props for the TextBlock component.
1119
+ * @returns The rendered text block.
1120
+ */
1121
+ const TextBlock = (props = {}) => {
1122
+ const {
1123
+ marks = [],
1124
+ text
1125
+ } = props;
1126
+ const mark = marks[0] || defaultMark;
1127
+ const textProps = Object.assign({}, props, {
1128
+ marks: marks.slice(1)
1129
+ });
1130
+ const Component = nodeMarks[mark == null ? void 0 : mark.type];
1131
+ // In React, class is not a valid attribute name, so we need to rename it to className
1132
+ if (mark.attrs) {
1133
+ mark.attrs.className = mark.attrs.class;
1134
+ delete mark.attrs.class;
1135
+ }
1136
+ if (!Component) {
1137
+ return text;
1138
+ }
1139
+ return jsx(Component, {
1140
+ type: mark.type,
1141
+ attrs: mark.attrs,
1142
+ children: jsx(TextBlock, Object.assign({}, textProps))
1143
+ });
1144
+ };
1145
+
1146
+ /**
1147
+ * Renders a video component for displaying videos.
1148
+ *
1149
+ * @param props - The properties for the video component.
1150
+ * @returns The rendered video component.
1151
+ */
1152
+ const DotCMSVideo = ({
1153
+ node
1154
+ }) => {
1155
+ const {
1156
+ data,
1157
+ src,
1158
+ mimeType,
1159
+ width,
1160
+ height
1161
+ } = node.attrs;
1162
+ const poster = data == null ? void 0 : data.thumbnail;
1163
+ const posterAttribute = poster ? {
1164
+ poster
1165
+ } : {};
1166
+ return jsxs("video", Object.assign({
1167
+ controls: true,
1168
+ preload: "metadata",
1169
+ width: width,
1170
+ height: height
1171
+ }, posterAttribute, {
1172
+ children: [jsx("track", {
1173
+ default: true,
1174
+ kind: "captions",
1175
+ srcLang: "en"
1176
+ }), jsx("source", {
1177
+ src: src,
1178
+ type: mimeType
1179
+ }), "Your browser does not support the ", jsx("code", {
1180
+ children: "video"
1181
+ }), " element."]
1182
+ }));
1183
+ };
1184
+
1185
+ /**
1186
+ * Renders a block editor item based on the provided content and custom renderers.
1187
+ *
1188
+ * @param content - The content nodes to render.
1189
+ * @param customRenderers - Optional custom renderers for specific node types.
1190
+ * @returns The rendered block editor item.
1191
+ */
1192
+ const BlockEditorBlock = ({
1193
+ content,
1194
+ customRenderers
1195
+ }) => {
1196
+ if (!content) {
1197
+ return null;
1198
+ }
1199
+ return content == null ? void 0 : content.map((node, index) => {
1200
+ var _node$content;
1201
+ const CustomRendererComponent = customRenderers == null ? void 0 : customRenderers[node.type];
1202
+ if (CustomRendererComponent) {
1203
+ return jsx(CustomRendererComponent, {
1204
+ content: node.content,
1205
+ children: jsx(BlockEditorBlock, {
1206
+ content: node.content,
1207
+ customRenderers: customRenderers
1208
+ })
1209
+ }, `${node.type}-${index}`);
1210
+ }
1211
+ switch (node.type) {
1212
+ case BlockEditorDefaultBlocks.PARAGRAPH:
1213
+ return jsx(Paragraph, {
1214
+ node: node,
1215
+ children: jsx(BlockEditorBlock, {
1216
+ content: node.content,
1217
+ customRenderers: customRenderers
1218
+ })
1219
+ }, `${node.type}-${index}`);
1220
+ case BlockEditorDefaultBlocks.HEADING:
1221
+ return jsx(Heading, {
1222
+ node: node,
1223
+ children: jsx(BlockEditorBlock, {
1224
+ content: node.content,
1225
+ customRenderers: customRenderers
1226
+ })
1227
+ }, `${node.type}-${index}`);
1228
+ case BlockEditorDefaultBlocks.TEXT:
1229
+ return jsx(TextBlock, Object.assign({}, node), `${node.type}-${index}`);
1230
+ case BlockEditorDefaultBlocks.BULLET_LIST:
1231
+ return jsx(BulletList, {
1232
+ children: jsx(BlockEditorBlock, {
1233
+ content: node.content,
1234
+ customRenderers: customRenderers
1235
+ })
1236
+ }, `${node.type}-${index}`);
1237
+ case BlockEditorDefaultBlocks.ORDERED_LIST:
1238
+ return jsx(OrderedList, {
1239
+ children: jsx(BlockEditorBlock, {
1240
+ content: node.content,
1241
+ customRenderers: customRenderers
1242
+ })
1243
+ }, `${node.type}-${index}`);
1244
+ case BlockEditorDefaultBlocks.LIST_ITEM:
1245
+ return jsx(ListItem, {
1246
+ children: jsx(BlockEditorBlock, {
1247
+ content: node.content,
1248
+ customRenderers: customRenderers
1249
+ })
1250
+ }, `${node.type}-${index}`);
1251
+ case BlockEditorDefaultBlocks.BLOCK_QUOTE:
1252
+ return jsx(BlockQuote, {
1253
+ children: jsx(BlockEditorBlock, {
1254
+ content: node.content,
1255
+ customRenderers: customRenderers
1256
+ })
1257
+ }, `${node.type}-${index}`);
1258
+ case BlockEditorDefaultBlocks.CODE_BLOCK:
1259
+ return jsx(CodeBlock, {
1260
+ node: node,
1261
+ children: jsx(BlockEditorBlock, {
1262
+ content: node.content,
1263
+ customRenderers: customRenderers
1264
+ })
1265
+ }, `${node.type}-${index}`);
1266
+ case BlockEditorDefaultBlocks.HARDBREAK:
1267
+ return jsx("br", {}, `${node.type}-${index}`);
1268
+ case BlockEditorDefaultBlocks.HORIZONTAL_RULE:
1269
+ return jsx("hr", {}, `${node.type}-${index}`);
1270
+ case BlockEditorDefaultBlocks.DOT_IMAGE:
1271
+ return jsx(DotCMSImage, {
1272
+ node: node
1273
+ }, `${node.type}-${index}`);
1274
+ case BlockEditorDefaultBlocks.DOT_VIDEO:
1275
+ return jsx(DotCMSVideo, {
1276
+ node: node
1277
+ }, `${node.type}-${index}`);
1278
+ case BlockEditorDefaultBlocks.TABLE:
1279
+ return jsx(TableRenderer, {
1280
+ content: (_node$content = node.content) != null ? _node$content : [],
1281
+ blockEditorItem: BlockEditorBlock
1282
+ }, `${node.type}-${index}`);
1283
+ case BlockEditorDefaultBlocks.DOT_CONTENT:
1284
+ return jsx(DotContent, {
1285
+ customRenderers: customRenderers,
1286
+ node: node
1287
+ }, `${node.type}-${index}`);
1288
+ default:
1289
+ return jsxs("div", {
1290
+ children: ["Unknown Block Type ", node.type]
1291
+ }, `${node.type}-${index}`);
1292
+ }
1293
+ });
1294
+ };
1295
+
1296
+ /**
1297
+ * BlockEditorRenderer component for rendering block editor field.
1298
+ *
1299
+ * @component
1300
+ * @param {Object} props - The component props.
1301
+ * @param {BlockEditorContent} props.blocks - The blocks of content to render.
1302
+ * @param {CustomRenderer} [props.customRenderers] - Optional custom renderers for specific block types.
1303
+ * @param {string} [props.className] - Optional CSS class name for the container div.
1304
+ * @param {React.CSSProperties} [props.style] - Optional inline styles for the container div.
1305
+ * @returns {JSX.Element} A div containing the rendered blocks of content.
1306
+ */
1307
+ const DotCMSBlockEditorRenderer = ({
1308
+ blocks,
1309
+ style,
1310
+ className,
1311
+ customRenderers
1312
+ }) => {
1313
+ const [blockEditorState, setBlockEditorState] = useState({
1314
+ error: null
1315
+ });
1316
+ const isDevMode = useIsDevMode();
1317
+ /**
1318
+ * Validates the blocks structure and updates the block editor state.
1319
+ *
1320
+ * This effect:
1321
+ * 1. Validates that blocks have the correct structure (doc type, content array, etc)
1322
+ * 2. Updates the block editor state with validation result
1323
+ * 3. Logs any validation errors to console
1324
+ *
1325
+ * @dependency {Block} blocks - The content blocks to validate
1326
+ */
1327
+ useEffect(() => {
1328
+ const validationResult = isValidBlocks(blocks);
1329
+ setBlockEditorState(validationResult);
1330
+ if (validationResult.error) {
1331
+ console.error(validationResult.error);
1332
+ }
1333
+ }, [blocks]);
1334
+ if (blockEditorState.error) {
1335
+ console.error(blockEditorState.error);
1336
+ if (isDevMode) {
1337
+ return jsx("div", {
1338
+ "data-testid": "invalid-blocks-message",
1339
+ children: blockEditorState.error
1340
+ });
1341
+ }
1342
+ return null;
1343
+ }
1344
+ return jsx("div", {
1345
+ className: className,
1346
+ style: style,
1347
+ "data-testid": "dot-block-editor-container",
1348
+ children: jsx(BlockEditorBlock, {
1349
+ content: blocks == null ? void 0 : blocks.content,
1350
+ customRenderers: customRenderers
1351
+ })
1352
+ });
1353
+ };
1354
+
1355
+ export { DotCMSBlockEditorRenderer, DotCMSEditableText, DotCMSLayoutBody, DotCMSShow, useDotCMSShowWhen, useEditableDotCMSPage };
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@dotcms/react",
3
- "version": "0.0.1-beta.27",
3
+ "version": "0.0.1-beta.29",
4
4
  "peerDependencies": {
5
5
  "react": ">=18",
6
6
  "react-dom": ">=18",
7
- "@dotcms/client": "0.0.1-beta.27",
8
- "@dotcms/uve": "0.0.1-beta.27",
7
+ "@dotcms/client": "0.0.1-beta.29",
8
+ "@dotcms/uve": "0.0.1-beta.29",
9
9
  "@tinymce/tinymce-react": "^6.0.0"
10
10
  },
11
11
  "devDependencies": {
@@ -0,0 +1,27 @@
1
+ /// <reference types="react" />
2
+ import { BlockEditorContent } from '@dotcms/types';
3
+ /**
4
+ * Represents a Custom Renderer used by the Block Editor Component
5
+ *
6
+ * @export
7
+ * @interface CustomRenderer
8
+ */
9
+ export type CustomRenderer<T = any> = Record<string, React.FC<T>>;
10
+ export interface BlockEditorRendererProps {
11
+ blocks: BlockEditorContent;
12
+ style?: React.CSSProperties;
13
+ className?: string;
14
+ customRenderers?: CustomRenderer;
15
+ }
16
+ /**
17
+ * BlockEditorRenderer component for rendering block editor field.
18
+ *
19
+ * @component
20
+ * @param {Object} props - The component props.
21
+ * @param {BlockEditorContent} props.blocks - The blocks of content to render.
22
+ * @param {CustomRenderer} [props.customRenderers] - Optional custom renderers for specific block types.
23
+ * @param {string} [props.className] - Optional CSS class name for the container div.
24
+ * @param {React.CSSProperties} [props.style] - Optional inline styles for the container div.
25
+ * @returns {JSX.Element} A div containing the rendered blocks of content.
26
+ */
27
+ export declare const DotCMSBlockEditorRenderer: ({ blocks, style, className, customRenderers }: BlockEditorRendererProps) => import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,15 @@
1
+ import { BlockEditorNode } from '@dotcms/types';
2
+ import { CustomRenderer } from '../DotCMSBlockEditorRenderer';
3
+ interface BlockEditorBlockProps {
4
+ content: BlockEditorNode[] | undefined;
5
+ customRenderers?: CustomRenderer;
6
+ }
7
+ /**
8
+ * Renders a block editor item based on the provided content and custom renderers.
9
+ *
10
+ * @param content - The content nodes to render.
11
+ * @param customRenderers - Optional custom renderers for specific node types.
12
+ * @returns The rendered block editor item.
13
+ */
14
+ export declare const BlockEditorBlock: ({ content, customRenderers }: BlockEditorBlockProps) => import("react/jsx-runtime").JSX.Element[] | null;
15
+ export {};
@@ -0,0 +1,24 @@
1
+ /// <reference types="react" />
2
+ import { BlockEditorNode } from '@dotcms/types';
3
+ interface CodeBlockProps {
4
+ node: BlockEditorNode;
5
+ children: React.ReactNode;
6
+ }
7
+ /**
8
+ * Renders a code block component.
9
+ *
10
+ * @param attrs - The attributes of the code block.
11
+ * @param children - The content of the code block.
12
+ * @returns The rendered code block component.
13
+ */
14
+ export declare const CodeBlock: ({ node, children }: CodeBlockProps) => import("react/jsx-runtime").JSX.Element;
15
+ /**
16
+ * Renders a blockquote component.
17
+ *
18
+ * @param children - The content to be rendered inside the blockquote.
19
+ * @returns The rendered blockquote component.
20
+ */
21
+ export declare const BlockQuote: ({ children }: {
22
+ children: React.ReactNode;
23
+ }) => import("react/jsx-runtime").JSX.Element;
24
+ export {};
@@ -0,0 +1,14 @@
1
+ import { BlockEditorNode } from '@dotcms/types';
2
+ import { CustomRenderer } from '../../DotCMSBlockEditorRenderer';
3
+ interface DotContentProps {
4
+ customRenderers: CustomRenderer;
5
+ node: BlockEditorNode;
6
+ }
7
+ /**
8
+ * Renders a DotContent component.
9
+ *
10
+ * @param {DotContentProps} props - The props for the DotContent component.
11
+ * @returns {JSX.Element} The rendered DotContent component.
12
+ */
13
+ export declare const DotContent: ({ customRenderers, node }: DotContentProps) => import("react/jsx-runtime").JSX.Element | null;
14
+ export {};
@@ -0,0 +1,10 @@
1
+ import { BlockEditorNode } from '@dotcms/types';
2
+ /**
3
+ * Renders an image component for dotCMS.
4
+ *
5
+ * @param node - The node for the DotCMSImage component.
6
+ * @returns The rendered image component.
7
+ */
8
+ export declare const DotCMSImage: ({ node }: {
9
+ node: BlockEditorNode;
10
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,26 @@
1
+ /// <reference types="react" />
2
+ interface ListItemProps {
3
+ children: React.ReactNode;
4
+ }
5
+ /**
6
+ * ListItem component represents a list item in a block editor.
7
+ *
8
+ * @param children - The content of the list item.
9
+ * @returns The rendered list item element.
10
+ */
11
+ export declare const ListItem: ({ children }: ListItemProps) => import("react/jsx-runtime").JSX.Element;
12
+ /**
13
+ * Renders an ordered list component.
14
+ *
15
+ * @param children - The content to be rendered inside the ordered list.
16
+ * @returns The ordered list component.
17
+ */
18
+ export declare const OrderedList: ({ children }: ListItemProps) => import("react/jsx-runtime").JSX.Element;
19
+ /**
20
+ * Renders a bullet list component.
21
+ *
22
+ * @param children - The content of the bullet list.
23
+ * @returns The rendered bullet list component.
24
+ */
25
+ export declare const BulletList: ({ children }: ListItemProps) => import("react/jsx-runtime").JSX.Element;
26
+ export {};
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+ import { BlockEditorNode } from '@dotcms/types';
3
+ interface TableRendererProps {
4
+ content: BlockEditorNode[];
5
+ blockEditorItem: React.FC<{
6
+ content: BlockEditorNode[];
7
+ }>;
8
+ }
9
+ /**
10
+ * Renders a table component for the Block Editor.
11
+ *
12
+ * @param content - The content of the table.
13
+ * @param blockEditorItem - The Block Editor item component.
14
+ */
15
+ export declare const TableRenderer: React.FC<TableRendererProps>;
16
+ export {};
@@ -0,0 +1,81 @@
1
+ /// <reference types="react" />
2
+ import { BlockEditorMark, BlockEditorNode } from '@dotcms/types';
3
+ interface MarkProps extends BlockEditorMark {
4
+ children: React.ReactNode;
5
+ }
6
+ interface TextComponentProp {
7
+ children: React.ReactNode;
8
+ node: BlockEditorNode;
9
+ }
10
+ interface TextNodeProps {
11
+ marks?: BlockEditorMark[];
12
+ text?: string;
13
+ }
14
+ /**
15
+ * Renders the text in bold.
16
+ *
17
+ * @param children - The content to be rendered in bold.
18
+ */
19
+ export declare const Bold: ({ children }: MarkProps) => import("react/jsx-runtime").JSX.Element;
20
+ /**
21
+ * Renders the text in italic format.
22
+ *
23
+ * @param children - The content to be rendered in italic.
24
+ */
25
+ export declare const Italic: ({ children }: MarkProps) => import("react/jsx-runtime").JSX.Element;
26
+ /**
27
+ * Renders a strike-through text.
28
+ *
29
+ * @param children - The content to be rendered within the strike-through element.
30
+ */
31
+ export declare const Strike: ({ children }: MarkProps) => import("react/jsx-runtime").JSX.Element;
32
+ /**
33
+ * Renders an underline element for the given children.
34
+ *
35
+ * @param children - The content to be underlined.
36
+ */
37
+ export declare const Underline: ({ children }: MarkProps) => import("react/jsx-runtime").JSX.Element;
38
+ /**
39
+ * Renders a paragraph element.
40
+ *
41
+ * @param children - The content of the paragraph.
42
+ * @param attrs - The style attributes for the paragraph.
43
+ * @returns The rendered paragraph element.
44
+ */
45
+ export declare const Paragraph: ({ children, node }: TextComponentProp) => import("react/jsx-runtime").JSX.Element;
46
+ /**
47
+ * Renders a link component.
48
+ *
49
+ * @param children - The content of the link.
50
+ * @param attrs - The attributes to be applied to the link.
51
+ * @returns The rendered link component.
52
+ */
53
+ export declare const Link: ({ children, attrs }: MarkProps) => import("react/jsx-runtime").JSX.Element;
54
+ /**
55
+ * Renders a heading element with the specified level.
56
+ *
57
+ * @param children - The content of the heading.
58
+ * @param attrs - The attributes for the heading.
59
+ * @returns The rendered heading element.
60
+ */
61
+ export declare const Heading: ({ children, node }: TextComponentProp) => import("react/jsx-runtime").JSX.Element;
62
+ /**
63
+ * Renders the superscript text.
64
+ *
65
+ * @param children - The content to be rendered as superscript.
66
+ */
67
+ export declare const Superscript: ({ children }: MarkProps) => import("react/jsx-runtime").JSX.Element;
68
+ /**
69
+ * Renders a subscript element.
70
+ *
71
+ * @param children - The content to be rendered as subscript.
72
+ */
73
+ export declare const Subscript: ({ children }: MarkProps) => import("react/jsx-runtime").JSX.Element;
74
+ /**
75
+ * Renders a text block with optional marks.
76
+ *
77
+ * @param props - The props for the TextBlock component.
78
+ * @returns The rendered text block.
79
+ */
80
+ export declare const TextBlock: (props?: TextNodeProps) => string | import("react/jsx-runtime").JSX.Element | undefined;
81
+ export {};
@@ -0,0 +1,10 @@
1
+ import { BlockEditorNode } from '@dotcms/types';
2
+ /**
3
+ * Renders a video component for displaying videos.
4
+ *
5
+ * @param props - The properties for the video component.
6
+ * @returns The rendered video component.
7
+ */
8
+ export declare const DotCMSVideo: ({ node }: {
9
+ node: BlockEditorNode;
10
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -1,4 +1,4 @@
1
- import { DotCMSEditablePage } from '@dotcms/types';
1
+ import { DotCMSPageResponse } from '@dotcms/types';
2
2
  /**
3
3
  * Custom hook to manage the editable state of a DotCMS page.
4
4
  *
@@ -82,9 +82,9 @@ import { DotCMSEditablePage } from '@dotcms/types';
82
82
  * </div>
83
83
  * );
84
84
  * ```
85
- * @param {DotCMSEditablePage} editablePage - The initial editable page data from client.page.get().
85
+ * @param {DotCMSPageResponse} pageResponse - The initial editable page data from client.page.get().
86
86
  *
87
- * @returns {DotCMSEditablePage} The updated editable page state that reflects any changes made in the UVE.
87
+ * @returns {DotCMSPageResponse} The updated editable page state that reflects any changes made in the UVE.
88
88
  * The structure includes page data and any GraphQL content that was requested.
89
89
  */
90
- export declare const useEditableDotCMSPage: (editablePage: DotCMSEditablePage) => DotCMSEditablePage;
90
+ export declare const useEditableDotCMSPage: (pageResponse: DotCMSPageResponse) => DotCMSPageResponse;
package/src/next.d.ts CHANGED
@@ -3,3 +3,4 @@ export { DotCMSShow } from './lib/next/components/DotCMSShow/DotCMSShow';
3
3
  export { useDotCMSShowWhen } from './lib/next/hooks/useDotCMSShowWhen';
4
4
  export { useEditableDotCMSPage } from './lib/next/hooks/useEditableDotCMSPage';
5
5
  export { DotCMSEditableText } from './lib/next/components/DotCMSEditableText/DotCMSEditableText';
6
+ export { DotCMSBlockEditorRenderer, BlockEditorRendererProps } from './lib/next/components/DotCMSBlockEditorRenderer/DotCMSBlockEditorRenderer';