@dotcms/uve 1.1.1-next.7 → 1.1.1-next.8

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/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-next.7",
3
+ "version": "1.1.1-next.8",
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.
@@ -1100,6 +1172,8 @@ function initUVE(config = {}) {
1100
1172
  };
1101
1173
  }
1102
1174
 
1175
+ exports.ANALYTICS_WINDOWS_ACTIVE_KEY = ANALYTICS_WINDOWS_ACTIVE_KEY;
1176
+ exports.ANALYTICS_WINDOWS_CLEANUP_KEY = ANALYTICS_WINDOWS_CLEANUP_KEY;
1103
1177
  exports.CUSTOM_NO_COMPONENT = CUSTOM_NO_COMPONENT;
1104
1178
  exports.DEVELOPMENT_MODE = DEVELOPMENT_MODE;
1105
1179
  exports.EMPTY_CONTAINER_STYLE_ANGULAR = EMPTY_CONTAINER_STYLE_ANGULAR;
@@ -1120,6 +1194,7 @@ exports.getClosestDotCMSContainerData = getClosestDotCMSContainerData;
1120
1194
  exports.getColumnPositionClasses = getColumnPositionClasses;
1121
1195
  exports.getContainersData = getContainersData;
1122
1196
  exports.getContentletsInContainer = getContentletsInContainer;
1197
+ exports.getDotAnalyticsAttributes = getDotAnalyticsAttributes;
1123
1198
  exports.getDotCMSContainerData = getDotCMSContainerData;
1124
1199
  exports.getDotCMSContentletsBound = getDotCMSContentletsBound;
1125
1200
  exports.getDotCMSPageBounds = getDotCMSPageBounds;
@@ -1128,6 +1203,7 @@ exports.getDotContentletAttributes = getDotContentletAttributes;
1128
1203
  exports.getUVEState = getUVEState;
1129
1204
  exports.initInlineEditing = initInlineEditing;
1130
1205
  exports.initUVE = initUVE;
1206
+ exports.isAnalyticsActive = isAnalyticsActive;
1131
1207
  exports.isValidBlocks = isValidBlocks;
1132
1208
  exports.reorderMenu = reorderMenu;
1133
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.
@@ -1098,4 +1170,4 @@ function initUVE(config = {}) {
1098
1170
  };
1099
1171
  }
1100
1172
 
1101
- 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
  *