@dotcms/uve 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 CHANGED
@@ -34,10 +34,9 @@ With `@dotcms/uve`, framework SDKs are able to:
34
34
  - [Common Issues & Solutions](#common-issues--solutions)
35
35
  - [Debugging Tips](#debugging-tips)
36
36
  - [Still Having Issues?](#still-having-issues)
37
- - [dotCMS Support](#dotcms-support)
38
- - [How To Contribute](#how-to-contribute)
39
- - [Licensing Information](#licensing-information)
40
- - [Troubleshooting](#troubleshooting)
37
+ - [Support](#support)
38
+ - [Contributing](#contributing)
39
+ - [Licensing](#licensing)
41
40
 
42
41
  ## Before You Use @dotcms/uve
43
42
 
@@ -551,13 +550,14 @@ If you're still experiencing problems after trying these solutions:
551
550
  - Error messages
552
551
  - Code samples
553
552
 
554
- ## dotCMS Support
553
+ ## Support
555
554
 
556
555
  We offer multiple channels to get help with the dotCMS UVE SDK:
557
556
 
558
- - **GitHub Issues**: For bug reports and feature requests, please [open an issue](https://github.com/dotCMS/core/issues/new/choose) in the GitHub repository.
559
- - **Community Forum**: Join our [community discussions](https://community.dotcms.com/) to ask questions and share solutions.
560
- - **Stack Overflow**: Use the tag `dotcms-uve` when posting questions.
557
+ - **GitHub Issues**: For bug reports and feature requests, please [open an issue](https://github.com/dotCMS/core/issues/new/choose) in the GitHub repository
558
+ - **Community Forum**: Join our [community discussions](https://community.dotcms.com/) to ask questions and share solutions
559
+ - **Stack Overflow**: Use the tag `dotcms-uve` when posting questions
560
+ - **Enterprise Support**: Enterprise customers can access premium support through the [dotCMS Support Portal](https://helpdesk.dotcms.com/support/)
561
561
 
562
562
  When reporting issues, please include:
563
563
 
@@ -566,11 +566,9 @@ When reporting issues, please include:
566
566
  - Minimal reproduction steps
567
567
  - Expected vs. actual behavior
568
568
 
569
- Enterprise customers can access premium support through the [dotCMS Support Portal](https://dev.dotcms.com/docs/help).
570
-
571
- ## How To Contribute
569
+ ## Contributing
572
570
 
573
- GitHub pull requests are the preferred method to contribute code to dotCMS. We welcome contributions to the DotCMS UVE SDK! If you'd like to contribute, please follow these steps:
571
+ GitHub pull requests are the preferred method to contribute code to dotCMS. We welcome contributions to the dotCMS UVE SDK! If you'd like to contribute, please follow these steps:
574
572
 
575
573
  1. Fork the repository [dotCMS/core](https://github.com/dotCMS/core)
576
574
  2. Create a feature branch (`git checkout -b feature/amazing-feature`)
@@ -580,7 +578,7 @@ GitHub pull requests are the preferred method to contribute code to dotCMS. We w
580
578
 
581
579
  Please ensure your code follows the existing style and includes appropriate tests.
582
580
 
583
- ## Licensing Information
581
+ ## Licensing
584
582
 
585
583
  dotCMS comes in multiple editions and as such is dual-licensed. The dotCMS Community Edition is licensed under the GPL 3.0 and is freely available for download, customization, and deployment for use within organizations of all stripes. dotCMS Enterprise Editions (EE) adds several enterprise features and is available via a supported, indemnified commercial license from dotCMS. For the differences between the editions, see [the feature page](http://www.dotcms.com/cms-platform/features).
586
584
 
package/index.cjs.js CHANGED
@@ -12,6 +12,7 @@ exports.enableBlockEditorInline = _public.enableBlockEditorInline;
12
12
  exports.getUVEState = _public.getUVEState;
13
13
  exports.initInlineEditing = _public.initInlineEditing;
14
14
  exports.initUVE = _public.initUVE;
15
+ exports.isAnalyticsActive = _public.isAnalyticsActive;
15
16
  exports.reorderMenu = _public.reorderMenu;
16
17
  exports.sendMessageToUVE = _public.sendMessageToUVE;
17
18
  exports.updateNavigation = _public.updateNavigation;
package/index.esm.js CHANGED
@@ -1,3 +1,3 @@
1
- export { c as createUVESubscription, e as editContentlet, a as enableBlockEditorInline, g as getUVEState, i as initInlineEditing, b as initUVE, r as reorderMenu, s as sendMessageToUVE, u as updateNavigation } from './public.esm.js';
1
+ export { c as createUVESubscription, e as editContentlet, b as enableBlockEditorInline, g as getUVEState, a as initInlineEditing, d as initUVE, i as isAnalyticsActive, r as reorderMenu, s as sendMessageToUVE, u as updateNavigation } from './public.esm.js';
2
2
  import '@dotcms/types';
3
3
  import '@dotcms/types/internal';
package/internal.cjs.js CHANGED
@@ -74,6 +74,8 @@ const __BASE_TINYMCE_CONFIG_WITH_NO_DEFAULT__ = {
74
74
  */
75
75
  const __TINYMCE_PATH_ON_DOTCMS__ = '/ext/tinymcev7/tinymce.min.js';
76
76
 
77
+ exports.ANALYTICS_WINDOWS_ACTIVE_KEY = _public.ANALYTICS_WINDOWS_ACTIVE_KEY;
78
+ exports.ANALYTICS_WINDOWS_CLEANUP_KEY = _public.ANALYTICS_WINDOWS_CLEANUP_KEY;
77
79
  exports.CUSTOM_NO_COMPONENT = _public.CUSTOM_NO_COMPONENT;
78
80
  exports.DEVELOPMENT_MODE = _public.DEVELOPMENT_MODE;
79
81
  exports.EMPTY_CONTAINER_STYLE_ANGULAR = _public.EMPTY_CONTAINER_STYLE_ANGULAR;
@@ -85,17 +87,21 @@ exports.__UVE_EVENTS__ = _public.__UVE_EVENTS__;
85
87
  exports.__UVE_EVENT_ERROR_FALLBACK__ = _public.__UVE_EVENT_ERROR_FALLBACK__;
86
88
  exports.combineClasses = _public.combineClasses;
87
89
  exports.computeScrollIsInBottom = _public.computeScrollIsInBottom;
90
+ exports.createUVESubscription = _public.createUVESubscription;
88
91
  exports.findDotCMSElement = _public.findDotCMSElement;
89
92
  exports.findDotCMSVTLData = _public.findDotCMSVTLData;
90
93
  exports.getClosestDotCMSContainerData = _public.getClosestDotCMSContainerData;
91
94
  exports.getColumnPositionClasses = _public.getColumnPositionClasses;
92
95
  exports.getContainersData = _public.getContainersData;
93
96
  exports.getContentletsInContainer = _public.getContentletsInContainer;
97
+ exports.getDotAnalyticsAttributes = _public.getDotAnalyticsAttributes;
94
98
  exports.getDotCMSContainerData = _public.getDotCMSContainerData;
95
99
  exports.getDotCMSContentletsBound = _public.getDotCMSContentletsBound;
96
100
  exports.getDotCMSPageBounds = _public.getDotCMSPageBounds;
97
101
  exports.getDotContainerAttributes = _public.getDotContainerAttributes;
98
102
  exports.getDotContentletAttributes = _public.getDotContentletAttributes;
103
+ exports.getUVEState = _public.getUVEState;
104
+ exports.isAnalyticsActive = _public.isAnalyticsActive;
99
105
  exports.isValidBlocks = _public.isValidBlocks;
100
106
  exports.setBounds = _public.setBounds;
101
107
  exports.__BASE_TINYMCE_CONFIG_WITH_NO_DEFAULT__ = __BASE_TINYMCE_CONFIG_WITH_NO_DEFAULT__;
package/internal.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- export { C as CUSTOM_NO_COMPONENT, D as DEVELOPMENT_MODE, h as EMPTY_CONTAINER_STYLE_ANGULAR, f as EMPTY_CONTAINER_STYLE_REACT, E as END_CLASS, P as PRODUCTION_MODE, S as START_CLASS, _ as __UVE_EVENTS__, d as __UVE_EVENT_ERROR_FALLBACK__, q as combineClasses, p as computeScrollIsInBottom, n as findDotCMSElement, o as findDotCMSVTLData, m as getClosestDotCMSContainerData, t as getColumnPositionClasses, w as getContainersData, x as getContentletsInContainer, l as getDotCMSContainerData, k as getDotCMSContentletsBound, j as getDotCMSPageBounds, y as getDotContainerAttributes, v as getDotContentletAttributes, A as isValidBlocks, z as setBounds } from './public.esm.js';
1
+ export { A as ANALYTICS_WINDOWS_ACTIVE_KEY, k as ANALYTICS_WINDOWS_CLEANUP_KEY, C as CUSTOM_NO_COMPONENT, D as DEVELOPMENT_MODE, j as EMPTY_CONTAINER_STYLE_ANGULAR, h as EMPTY_CONTAINER_STYLE_REACT, E as END_CLASS, P as PRODUCTION_MODE, S as START_CLASS, _ as __UVE_EVENTS__, f as __UVE_EVENT_ERROR_FALLBACK__, v as combineClasses, t as computeScrollIsInBottom, c as createUVESubscription, p as findDotCMSElement, q as findDotCMSVTLData, o as getClosestDotCMSContainerData, w as getColumnPositionClasses, z as getContainersData, B as getContentletsInContainer, y as getDotAnalyticsAttributes, n as getDotCMSContainerData, m as getDotCMSContentletsBound, l as getDotCMSPageBounds, F as getDotContainerAttributes, x as getDotContentletAttributes, g as getUVEState, i as isAnalyticsActive, H as isValidBlocks, G as setBounds } from './public.esm.js';
2
2
  import '@dotcms/types';
3
3
  import '@dotcms/types/internal';
4
4
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dotcms/uve",
3
- "version": "1.1.1",
3
+ "version": "1.2.0",
4
4
  "description": "Official JavaScript library for interacting with Universal Visual Editor (UVE)",
5
5
  "repository": {
6
6
  "type": "git",
package/public.cjs.js CHANGED
@@ -240,6 +240,23 @@ function getDotContentletAttributes(contentlet, container) {
240
240
  'data-dot-on-number-of-pages': contentlet?.['onNumberOfPages'] || '1'
241
241
  };
242
242
  }
243
+ /**
244
+ * Helper function that returns an object containing analytics-specific data attributes.
245
+ * These attributes are used by the DotCMS Analytics SDK to track content interactions.
246
+ *
247
+ * @param {DotCMSBasicContentlet} contentlet - The contentlet to get the analytics attributes for
248
+ * @returns {DotAnalyticsAttributes} The analytics data attributes
249
+ * @internal
250
+ */
251
+ function getDotAnalyticsAttributes(contentlet) {
252
+ return {
253
+ 'data-dot-analytics-identifier': contentlet?.identifier,
254
+ 'data-dot-analytics-inode': contentlet?.inode,
255
+ 'data-dot-analytics-basetype': contentlet?.baseType,
256
+ 'data-dot-analytics-contenttype': contentlet?.contentType,
257
+ 'data-dot-analytics-title': contentlet?.['widgetTitle'] || contentlet?.title
258
+ };
259
+ }
243
260
  /**
244
261
  *
245
262
  *
@@ -597,6 +614,10 @@ const EMPTY_CONTAINER_STYLE_ANGULAR = {
597
614
  * @internal
598
615
  */
599
616
  const CUSTOM_NO_COMPONENT = 'CustomNoComponent';
617
+ // Analytics active flag key
618
+ const ANALYTICS_WINDOWS_ACTIVE_KEY = '__dotAnalyticsActive__';
619
+ // Analytics cleanup function key
620
+ const ANALYTICS_WINDOWS_CLEANUP_KEY = '__dotAnalyticsCleanup';
600
621
 
601
622
  /**
602
623
  * Gets the current state of the Universal Visual Editor (UVE).
@@ -682,6 +703,57 @@ function createUVESubscription(eventType, callback) {
682
703
  }
683
704
  return eventCallback(callback);
684
705
  }
706
+ /**
707
+ * Checks if DotCMS Analytics is active by verifying the global window flag.
708
+ *
709
+ * This function checks for the presence of the `__dotAnalyticsActive__` flag on the window object,
710
+ * which is set by the `@dotcms/analytics` SDK when Analytics is successfully initialized.
711
+ *
712
+ * This utility can be used in any JavaScript framework (React, Angular, Vue, etc.) to conditionally
713
+ * enable analytics-related features or data attributes.
714
+ *
715
+ * @export
716
+ * @returns {boolean} true if Analytics is initialized and active, false otherwise
717
+ *
718
+ * @example
719
+ * ```ts
720
+ * // React example
721
+ * import { isAnalyticsActive } from '@dotcms/uve/internal';
722
+ *
723
+ * function MyComponent() {
724
+ * const shouldTrack = isAnalyticsActive();
725
+ *
726
+ * if (shouldTrack) {
727
+ * // Add analytics tracking
728
+ * }
729
+ * }
730
+ * ```
731
+ *
732
+ * @example
733
+ * ```ts
734
+ * // Angular example
735
+ * import { isAnalyticsActive } from '@dotcms/uve/internal';
736
+ *
737
+ * if (isAnalyticsActive()) {
738
+ * // Apply analytics attributes to elements
739
+ * element.setAttribute('data-dot-object', 'contentlet');
740
+ * }
741
+ * ```
742
+ *
743
+ * @example
744
+ * ```ts
745
+ * // Vanilla JavaScript / Any framework
746
+ * import { isAnalyticsActive } from '@dotcms/uve/internal';
747
+ *
748
+ * if (isAnalyticsActive()) {
749
+ * console.log('DotCMS Analytics is active');
750
+ * }
751
+ * ```
752
+ */
753
+ function isAnalyticsActive() {
754
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
755
+ return typeof window !== 'undefined' && window[ANALYTICS_WINDOWS_ACTIVE_KEY] === true;
756
+ }
685
757
 
686
758
  /**
687
759
  * Sets the bounds of the containers in the editor.
@@ -696,17 +768,20 @@ function setBounds(bounds) {
696
768
  });
697
769
  }
698
770
  /**
699
- * Validates the structure of a Block Editor block.
700
- *
701
- * This function checks that:
702
- * 1. The blocks parameter is a valid object
703
- * 2. The block has a 'doc' type
704
- * 3. The block has a valid content array that is not empty
705
- *
706
- * @param {Block} blocks - The blocks structure to validate
707
- * @returns {BlockEditorState} Object containing validation state and any error message
708
- * @property {boolean} BlockEditorState.isValid - Whether the blocks structure is valid
709
- * @property {string | null} BlockEditorState.error - Error message if invalid, null if valid
771
+ * Validates the structure of a Block Editor node.
772
+ *
773
+ * This function performs validation checks on a BlockEditorNode object to ensure:
774
+ * - The node exists and is a valid object
775
+ * - The node has a 'doc' type
776
+ * - The node has a valid content array containing at least one block
777
+ * - Each block in the content array:
778
+ * - Has a valid string type property
779
+ * - Has valid object attributes (if present)
780
+ * - Has valid nested content (if present)
781
+ *
782
+ * @param {BlockEditorNode} blocks - The BlockEditorNode structure to validate
783
+ * @returns {BlockEditorState} The validation result
784
+ * @property {string | null} BlockEditorState.error - Error message if validation fails, null if valid
710
785
  */
711
786
  const isValidBlocks = blocks => {
712
787
  if (!blocks) {
@@ -1097,6 +1172,8 @@ function initUVE(config = {}) {
1097
1172
  };
1098
1173
  }
1099
1174
 
1175
+ exports.ANALYTICS_WINDOWS_ACTIVE_KEY = ANALYTICS_WINDOWS_ACTIVE_KEY;
1176
+ exports.ANALYTICS_WINDOWS_CLEANUP_KEY = ANALYTICS_WINDOWS_CLEANUP_KEY;
1100
1177
  exports.CUSTOM_NO_COMPONENT = CUSTOM_NO_COMPONENT;
1101
1178
  exports.DEVELOPMENT_MODE = DEVELOPMENT_MODE;
1102
1179
  exports.EMPTY_CONTAINER_STYLE_ANGULAR = EMPTY_CONTAINER_STYLE_ANGULAR;
@@ -1117,6 +1194,7 @@ exports.getClosestDotCMSContainerData = getClosestDotCMSContainerData;
1117
1194
  exports.getColumnPositionClasses = getColumnPositionClasses;
1118
1195
  exports.getContainersData = getContainersData;
1119
1196
  exports.getContentletsInContainer = getContentletsInContainer;
1197
+ exports.getDotAnalyticsAttributes = getDotAnalyticsAttributes;
1120
1198
  exports.getDotCMSContainerData = getDotCMSContainerData;
1121
1199
  exports.getDotCMSContentletsBound = getDotCMSContentletsBound;
1122
1200
  exports.getDotCMSPageBounds = getDotCMSPageBounds;
@@ -1125,6 +1203,7 @@ exports.getDotContentletAttributes = getDotContentletAttributes;
1125
1203
  exports.getUVEState = getUVEState;
1126
1204
  exports.initInlineEditing = initInlineEditing;
1127
1205
  exports.initUVE = initUVE;
1206
+ exports.isAnalyticsActive = isAnalyticsActive;
1128
1207
  exports.isValidBlocks = isValidBlocks;
1129
1208
  exports.reorderMenu = reorderMenu;
1130
1209
  exports.sendMessageToUVE = sendMessageToUVE;
package/public.esm.js CHANGED
@@ -238,6 +238,23 @@ function getDotContentletAttributes(contentlet, container) {
238
238
  'data-dot-on-number-of-pages': contentlet?.['onNumberOfPages'] || '1'
239
239
  };
240
240
  }
241
+ /**
242
+ * Helper function that returns an object containing analytics-specific data attributes.
243
+ * These attributes are used by the DotCMS Analytics SDK to track content interactions.
244
+ *
245
+ * @param {DotCMSBasicContentlet} contentlet - The contentlet to get the analytics attributes for
246
+ * @returns {DotAnalyticsAttributes} The analytics data attributes
247
+ * @internal
248
+ */
249
+ function getDotAnalyticsAttributes(contentlet) {
250
+ return {
251
+ 'data-dot-analytics-identifier': contentlet?.identifier,
252
+ 'data-dot-analytics-inode': contentlet?.inode,
253
+ 'data-dot-analytics-basetype': contentlet?.baseType,
254
+ 'data-dot-analytics-contenttype': contentlet?.contentType,
255
+ 'data-dot-analytics-title': contentlet?.['widgetTitle'] || contentlet?.title
256
+ };
257
+ }
241
258
  /**
242
259
  *
243
260
  *
@@ -595,6 +612,10 @@ const EMPTY_CONTAINER_STYLE_ANGULAR = {
595
612
  * @internal
596
613
  */
597
614
  const CUSTOM_NO_COMPONENT = 'CustomNoComponent';
615
+ // Analytics active flag key
616
+ const ANALYTICS_WINDOWS_ACTIVE_KEY = '__dotAnalyticsActive__';
617
+ // Analytics cleanup function key
618
+ const ANALYTICS_WINDOWS_CLEANUP_KEY = '__dotAnalyticsCleanup';
598
619
 
599
620
  /**
600
621
  * Gets the current state of the Universal Visual Editor (UVE).
@@ -680,6 +701,57 @@ function createUVESubscription(eventType, callback) {
680
701
  }
681
702
  return eventCallback(callback);
682
703
  }
704
+ /**
705
+ * Checks if DotCMS Analytics is active by verifying the global window flag.
706
+ *
707
+ * This function checks for the presence of the `__dotAnalyticsActive__` flag on the window object,
708
+ * which is set by the `@dotcms/analytics` SDK when Analytics is successfully initialized.
709
+ *
710
+ * This utility can be used in any JavaScript framework (React, Angular, Vue, etc.) to conditionally
711
+ * enable analytics-related features or data attributes.
712
+ *
713
+ * @export
714
+ * @returns {boolean} true if Analytics is initialized and active, false otherwise
715
+ *
716
+ * @example
717
+ * ```ts
718
+ * // React example
719
+ * import { isAnalyticsActive } from '@dotcms/uve/internal';
720
+ *
721
+ * function MyComponent() {
722
+ * const shouldTrack = isAnalyticsActive();
723
+ *
724
+ * if (shouldTrack) {
725
+ * // Add analytics tracking
726
+ * }
727
+ * }
728
+ * ```
729
+ *
730
+ * @example
731
+ * ```ts
732
+ * // Angular example
733
+ * import { isAnalyticsActive } from '@dotcms/uve/internal';
734
+ *
735
+ * if (isAnalyticsActive()) {
736
+ * // Apply analytics attributes to elements
737
+ * element.setAttribute('data-dot-object', 'contentlet');
738
+ * }
739
+ * ```
740
+ *
741
+ * @example
742
+ * ```ts
743
+ * // Vanilla JavaScript / Any framework
744
+ * import { isAnalyticsActive } from '@dotcms/uve/internal';
745
+ *
746
+ * if (isAnalyticsActive()) {
747
+ * console.log('DotCMS Analytics is active');
748
+ * }
749
+ * ```
750
+ */
751
+ function isAnalyticsActive() {
752
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
753
+ return typeof window !== 'undefined' && window[ANALYTICS_WINDOWS_ACTIVE_KEY] === true;
754
+ }
683
755
 
684
756
  /**
685
757
  * Sets the bounds of the containers in the editor.
@@ -694,17 +766,20 @@ function setBounds(bounds) {
694
766
  });
695
767
  }
696
768
  /**
697
- * Validates the structure of a Block Editor block.
698
- *
699
- * This function checks that:
700
- * 1. The blocks parameter is a valid object
701
- * 2. The block has a 'doc' type
702
- * 3. The block has a valid content array that is not empty
703
- *
704
- * @param {Block} blocks - The blocks structure to validate
705
- * @returns {BlockEditorState} Object containing validation state and any error message
706
- * @property {boolean} BlockEditorState.isValid - Whether the blocks structure is valid
707
- * @property {string | null} BlockEditorState.error - Error message if invalid, null if valid
769
+ * Validates the structure of a Block Editor node.
770
+ *
771
+ * This function performs validation checks on a BlockEditorNode object to ensure:
772
+ * - The node exists and is a valid object
773
+ * - The node has a 'doc' type
774
+ * - The node has a valid content array containing at least one block
775
+ * - Each block in the content array:
776
+ * - Has a valid string type property
777
+ * - Has valid object attributes (if present)
778
+ * - Has valid nested content (if present)
779
+ *
780
+ * @param {BlockEditorNode} blocks - The BlockEditorNode structure to validate
781
+ * @returns {BlockEditorState} The validation result
782
+ * @property {string | null} BlockEditorState.error - Error message if validation fails, null if valid
708
783
  */
709
784
  const isValidBlocks = blocks => {
710
785
  if (!blocks) {
@@ -1095,4 +1170,4 @@ function initUVE(config = {}) {
1095
1170
  };
1096
1171
  }
1097
1172
 
1098
- export { isValidBlocks as A, CUSTOM_NO_COMPONENT as C, DEVELOPMENT_MODE as D, END_CLASS as E, PRODUCTION_MODE as P, START_CLASS as S, __UVE_EVENTS__ as _, enableBlockEditorInline as a, initUVE as b, createUVESubscription as c, __UVE_EVENT_ERROR_FALLBACK__ as d, editContentlet as e, EMPTY_CONTAINER_STYLE_REACT as f, getUVEState as g, EMPTY_CONTAINER_STYLE_ANGULAR as h, initInlineEditing as i, getDotCMSPageBounds as j, getDotCMSContentletsBound as k, getDotCMSContainerData as l, getClosestDotCMSContainerData as m, findDotCMSElement as n, findDotCMSVTLData as o, computeScrollIsInBottom as p, combineClasses as q, reorderMenu as r, sendMessageToUVE as s, getColumnPositionClasses as t, updateNavigation as u, getDotContentletAttributes as v, getContainersData as w, getContentletsInContainer as x, getDotContainerAttributes as y, setBounds as z };
1173
+ export { ANALYTICS_WINDOWS_ACTIVE_KEY as A, getContentletsInContainer as B, CUSTOM_NO_COMPONENT as C, DEVELOPMENT_MODE as D, END_CLASS as E, getDotContainerAttributes as F, setBounds as G, isValidBlocks as H, PRODUCTION_MODE as P, START_CLASS as S, __UVE_EVENTS__ as _, initInlineEditing as a, enableBlockEditorInline as b, createUVESubscription as c, initUVE as d, editContentlet as e, __UVE_EVENT_ERROR_FALLBACK__ as f, getUVEState as g, EMPTY_CONTAINER_STYLE_REACT as h, isAnalyticsActive as i, EMPTY_CONTAINER_STYLE_ANGULAR as j, ANALYTICS_WINDOWS_CLEANUP_KEY as k, getDotCMSPageBounds as l, getDotCMSContentletsBound as m, getDotCMSContainerData as n, getClosestDotCMSContainerData as o, findDotCMSElement as p, findDotCMSVTLData as q, reorderMenu as r, sendMessageToUVE as s, computeScrollIsInBottom as t, updateNavigation as u, combineClasses as v, getColumnPositionClasses as w, getDotContentletAttributes as x, getDotAnalyticsAttributes as y, getContainersData as z };
@@ -74,3 +74,5 @@ export declare const EMPTY_CONTAINER_STYLE_ANGULAR: {
74
74
  * @internal
75
75
  */
76
76
  export declare const CUSTOM_NO_COMPONENT = "CustomNoComponent";
77
+ export declare const ANALYTICS_WINDOWS_ACTIVE_KEY = "__dotAnalyticsActive__";
78
+ export declare const ANALYTICS_WINDOWS_CLEANUP_KEY = "__dotAnalyticsCleanup";
package/src/internal.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './internal/index';
2
+ export * from './lib/core/core.utils';
2
3
  export * from './lib/dom/dom.utils';
3
4
  export * from './lib/editor/internal';
@@ -1,4 +1,4 @@
1
- import { UVEState, UVEEventSubscription, UVEEventType, UVEEventPayloadMap } from '@dotcms/types';
1
+ import { UVEEventPayloadMap, UVEEventSubscription, UVEEventType, UVEState } from '@dotcms/types';
2
2
  /**
3
3
  * Gets the current state of the Universal Visual Editor (UVE).
4
4
  *
@@ -47,3 +47,51 @@ export declare function getUVEState(): UVEState | undefined;
47
47
  * ```
48
48
  */
49
49
  export declare function createUVESubscription<T extends UVEEventType>(eventType: T, callback: (payload: UVEEventPayloadMap[T] extends undefined ? void : UVEEventPayloadMap[T]) => void): UVEEventSubscription;
50
+ /**
51
+ * Checks if DotCMS Analytics is active by verifying the global window flag.
52
+ *
53
+ * This function checks for the presence of the `__dotAnalyticsActive__` flag on the window object,
54
+ * which is set by the `@dotcms/analytics` SDK when Analytics is successfully initialized.
55
+ *
56
+ * This utility can be used in any JavaScript framework (React, Angular, Vue, etc.) to conditionally
57
+ * enable analytics-related features or data attributes.
58
+ *
59
+ * @export
60
+ * @returns {boolean} true if Analytics is initialized and active, false otherwise
61
+ *
62
+ * @example
63
+ * ```ts
64
+ * // React example
65
+ * import { isAnalyticsActive } from '@dotcms/uve/internal';
66
+ *
67
+ * function MyComponent() {
68
+ * const shouldTrack = isAnalyticsActive();
69
+ *
70
+ * if (shouldTrack) {
71
+ * // Add analytics tracking
72
+ * }
73
+ * }
74
+ * ```
75
+ *
76
+ * @example
77
+ * ```ts
78
+ * // Angular example
79
+ * import { isAnalyticsActive } from '@dotcms/uve/internal';
80
+ *
81
+ * if (isAnalyticsActive()) {
82
+ * // Apply analytics attributes to elements
83
+ * element.setAttribute('data-dot-object', 'contentlet');
84
+ * }
85
+ * ```
86
+ *
87
+ * @example
88
+ * ```ts
89
+ * // Vanilla JavaScript / Any framework
90
+ * import { isAnalyticsActive } from '@dotcms/uve/internal';
91
+ *
92
+ * if (isAnalyticsActive()) {
93
+ * console.log('DotCMS Analytics is active');
94
+ * }
95
+ * ```
96
+ */
97
+ export declare function isAnalyticsActive(): boolean;
@@ -1,5 +1,5 @@
1
- import { EditableContainerData, DotCMSColumnContainer, DotCMSBasicContentlet, DotCMSPageAsset, DotPageAssetLayoutColumn } from '@dotcms/types';
2
- import { DotCMSContainerBound, DotCMSContentletBound, DotContainerAttributes, DotContentletAttributes } from '@dotcms/types/internal';
1
+ import { DotCMSBasicContentlet, DotCMSColumnContainer, DotCMSPageAsset, DotPageAssetLayoutColumn, EditableContainerData } from '@dotcms/types';
2
+ import { DotAnalyticsAttributes, DotCMSContainerBound, DotCMSContentletBound, DotContainerAttributes, DotContentletAttributes } from '@dotcms/types/internal';
3
3
  /**
4
4
  * Calculates the bounding information for each page element within the given containers.
5
5
  *
@@ -152,6 +152,15 @@ export declare const getColumnPositionClasses: (column: DotPageAssetLayoutColumn
152
152
  * @returns {DotContentletAttributes} The dotCMS data attributes
153
153
  */
154
154
  export declare function getDotContentletAttributes(contentlet: DotCMSBasicContentlet, container: string): DotContentletAttributes;
155
+ /**
156
+ * Helper function that returns an object containing analytics-specific data attributes.
157
+ * These attributes are used by the DotCMS Analytics SDK to track content interactions.
158
+ *
159
+ * @param {DotCMSBasicContentlet} contentlet - The contentlet to get the analytics attributes for
160
+ * @returns {DotAnalyticsAttributes} The analytics data attributes
161
+ * @internal
162
+ */
163
+ export declare function getDotAnalyticsAttributes(contentlet: DotCMSBasicContentlet): DotAnalyticsAttributes;
155
164
  /**
156
165
  *
157
166
  *
@@ -1,4 +1,4 @@
1
- import { BlockEditorContent } from '@dotcms/types';
1
+ import { BlockEditorNode } from '@dotcms/types';
2
2
  import { BlockEditorState, DotCMSContainerBound } from '@dotcms/types/internal';
3
3
  /**
4
4
  * Sets the bounds of the containers in the editor.
@@ -8,16 +8,19 @@ import { BlockEditorState, DotCMSContainerBound } from '@dotcms/types/internal';
8
8
  */
9
9
  export declare function setBounds(bounds: DotCMSContainerBound[]): void;
10
10
  /**
11
- * Validates the structure of a Block Editor block.
11
+ * Validates the structure of a Block Editor node.
12
12
  *
13
- * This function checks that:
14
- * 1. The blocks parameter is a valid object
15
- * 2. The block has a 'doc' type
16
- * 3. The block has a valid content array that is not empty
13
+ * This function performs validation checks on a BlockEditorNode object to ensure:
14
+ * - The node exists and is a valid object
15
+ * - The node has a 'doc' type
16
+ * - The node has a valid content array containing at least one block
17
+ * - Each block in the content array:
18
+ * - Has a valid string type property
19
+ * - Has valid object attributes (if present)
20
+ * - Has valid nested content (if present)
17
21
  *
18
- * @param {Block} blocks - The blocks structure to validate
19
- * @returns {BlockEditorState} Object containing validation state and any error message
20
- * @property {boolean} BlockEditorState.isValid - Whether the blocks structure is valid
21
- * @property {string | null} BlockEditorState.error - Error message if invalid, null if valid
22
+ * @param {BlockEditorNode} blocks - The BlockEditorNode structure to validate
23
+ * @returns {BlockEditorState} The validation result
24
+ * @property {string | null} BlockEditorState.error - Error message if validation fails, null if valid
22
25
  */
23
- export declare const isValidBlocks: (blocks: BlockEditorContent) => BlockEditorState;
26
+ export declare const isValidBlocks: (blocks: BlockEditorNode) => BlockEditorState;