@dotcms/react 1.1.1 → 1.2.0
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/README.md +7 -7
- package/index.esm.js +958 -334
- package/package.json +1 -1
- package/src/index.d.ts +1 -1
- package/src/lib/next/components/DotCMSBlockEditorRenderer/DotCMSBlockEditorRenderer.d.ts +32 -5
- package/src/lib/next/components/DotCMSBlockEditorRenderer/components/blocks/DotContent.d.ts +1 -1
- package/src/lib/next/hooks/useIsAnalyticsActive.d.ts +27 -0
package/package.json
CHANGED
package/src/index.d.ts
CHANGED
|
@@ -3,5 +3,5 @@ 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';
|
|
6
|
+
export { DotCMSBlockEditorRenderer, BlockEditorRendererProps, CustomRenderer, CustomRendererProps } from './lib/next/components/DotCMSBlockEditorRenderer/DotCMSBlockEditorRenderer';
|
|
7
7
|
export { DotCMSLayoutBodyProps } from './lib/next/components/DotCMSLayoutBody/DotCMSLayoutBody';
|
|
@@ -1,13 +1,40 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BlockEditorNode } from '@dotcms/types';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Props that all custom renderers must accept.
|
|
4
|
+
*
|
|
5
|
+
* @export
|
|
6
|
+
* @interface CustomRendererProps
|
|
7
|
+
* @template TData - The type of data stored in node.attrs.data (for contentlet blocks)
|
|
8
|
+
*/
|
|
9
|
+
export interface CustomRendererProps<TData = any> {
|
|
10
|
+
/** The full BlockEditorNode with attrs, marks, content, etc. */
|
|
11
|
+
node: BlockEditorNode & {
|
|
12
|
+
attrs?: {
|
|
13
|
+
data?: TData;
|
|
14
|
+
[key: string]: any;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
/** Rendered children from nested content (if any) */
|
|
18
|
+
children?: React.ReactNode;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Custom renderer component type - must accept node and optional children.
|
|
22
|
+
* Can be specialized with a specific data type for node.attrs.data.
|
|
23
|
+
*
|
|
24
|
+
* @export
|
|
25
|
+
* @template TData - The type of contentlet data in node.attrs.data
|
|
26
|
+
*/
|
|
27
|
+
export type CustomRendererComponent<TData = any> = React.FC<CustomRendererProps<TData>>;
|
|
28
|
+
/**
|
|
29
|
+
* Map of block type names to custom renderer components.
|
|
30
|
+
* Use the generic parameter to type specific contentlet data.
|
|
4
31
|
*
|
|
5
32
|
* @export
|
|
6
33
|
* @interface CustomRenderer
|
|
7
34
|
*/
|
|
8
|
-
export type CustomRenderer
|
|
35
|
+
export type CustomRenderer = Record<string, CustomRendererComponent<any>>;
|
|
9
36
|
export interface BlockEditorRendererProps {
|
|
10
|
-
blocks:
|
|
37
|
+
blocks: BlockEditorNode;
|
|
11
38
|
style?: React.CSSProperties;
|
|
12
39
|
className?: string;
|
|
13
40
|
customRenderers?: CustomRenderer;
|
|
@@ -17,7 +44,7 @@ export interface BlockEditorRendererProps {
|
|
|
17
44
|
*
|
|
18
45
|
* @component
|
|
19
46
|
* @param {Object} props - The component props.
|
|
20
|
-
* @param {
|
|
47
|
+
* @param {BlockEditorNode} props.blocks - The blocks of content to render.
|
|
21
48
|
* @param {CustomRenderer} [props.customRenderers] - Optional custom renderers for specific block types.
|
|
22
49
|
* @param {string} [props.className] - Optional CSS class name for the container div.
|
|
23
50
|
* @param {React.CSSProperties} [props.style] - Optional inline styles for the container div.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @internal
|
|
3
|
+
* React hook that checks whether DotCMS Analytics is active.
|
|
4
|
+
*
|
|
5
|
+
* Uses useSyncExternalStore to subscribe to analytics state changes via custom events:
|
|
6
|
+
* - `dotcms:analytics:ready`: Fired when Analytics initializes
|
|
7
|
+
* - `dotcms:analytics:cleanup`: Fired on page unload
|
|
8
|
+
*
|
|
9
|
+
* Components automatically re-render when analytics state changes. Works regardless
|
|
10
|
+
* of initialization order and returns false during SSR.
|
|
11
|
+
*
|
|
12
|
+
* @returns {boolean} True if analytics is active, false otherwise
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```tsx
|
|
16
|
+
* function Contentlet({ item }) {
|
|
17
|
+
* const isAnalyticsActive = useIsAnalyticsActive()
|
|
18
|
+
*
|
|
19
|
+
* const attrs = isAnalyticsActive
|
|
20
|
+
* ? { 'data-dot-analytics-id': item.id }
|
|
21
|
+
* : {}
|
|
22
|
+
*
|
|
23
|
+
* return <div {...attrs}>{item.title}</div>
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare const useIsAnalyticsActive: () => boolean;
|