@dotcms/uve 0.0.1-beta.2 → 0.0.1-beta.21

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 (40) hide show
  1. package/README.md +321 -4
  2. package/index.cjs.d.ts +1 -1
  3. package/index.cjs.js +10 -54
  4. package/index.cjs2.js +1151 -0
  5. package/index.esm.d.ts +1 -1
  6. package/index.esm.js +2 -56
  7. package/index.esm2.js +1119 -0
  8. package/internal.cjs.d.ts +1 -0
  9. package/internal.cjs.default.js +1 -0
  10. package/internal.cjs.js +39 -0
  11. package/internal.cjs.mjs +2 -0
  12. package/internal.esm.d.ts +1 -0
  13. package/internal.esm.js +2 -0
  14. package/package.json +26 -7
  15. package/src/index.d.ts +2 -0
  16. package/src/internal/constants.d.ts +76 -0
  17. package/src/internal/events.d.ts +66 -0
  18. package/src/internal/index.d.ts +1 -0
  19. package/src/internal.d.ts +6 -0
  20. package/src/lib/{utils.d.ts → core/core.utils.d.ts} +20 -1
  21. package/src/lib/dom/dom.utils.d.ts +206 -0
  22. package/src/lib/editor/internal.d.ts +23 -0
  23. package/src/lib/editor/public.d.ts +62 -0
  24. package/src/lib/types/block-editor-renderer/internal.d.ts +46 -0
  25. package/src/lib/types/block-editor-renderer/public.d.ts +38 -0
  26. package/src/lib/types/editor/internal.d.ts +119 -0
  27. package/src/lib/types/editor/public.d.ts +271 -0
  28. package/src/lib/types/events/internal.d.ts +34 -0
  29. package/src/lib/types/events/public.d.ts +18 -0
  30. package/src/lib/types/page/public.d.ts +485 -0
  31. package/src/script/sdk-editor.d.ts +6 -0
  32. package/src/script/utils.d.ts +53 -0
  33. package/src/types.d.ts +4 -0
  34. package/types.cjs.d.ts +1 -1
  35. package/types.cjs.js +97 -4
  36. package/types.esm.d.ts +1 -1
  37. package/types.esm.js +98 -5
  38. package/src/lib/types.d.ts +0 -33
  39. package/src/public/index.d.ts +0 -2
  40. package/src/public/types.d.ts +0 -2
@@ -0,0 +1 @@
1
+ export * from "./src/internal";
@@ -0,0 +1 @@
1
+ exports._default = require('./internal.cjs.js').default;
@@ -0,0 +1,39 @@
1
+ 'use strict';
2
+
3
+ var internal = require('./index.cjs2.js');
4
+ require('./types.cjs.js');
5
+
6
+
7
+
8
+ Object.defineProperty(exports, "Blocks", {
9
+ enumerable: true,
10
+ get: function () { return internal.Blocks; }
11
+ });
12
+ exports.CUSTOM_NO_COMPONENT = internal.CUSTOM_NO_COMPONENT;
13
+ exports.DEVELOPMENT_MODE = internal.DEVELOPMENT_MODE;
14
+ exports.EMPTY_CONTAINER_STYLE_ANGULAR = internal.EMPTY_CONTAINER_STYLE_ANGULAR;
15
+ exports.EMPTY_CONTAINER_STYLE_REACT = internal.EMPTY_CONTAINER_STYLE_REACT;
16
+ exports.END_CLASS = internal.END_CLASS;
17
+ exports.PRODUCTION_MODE = internal.PRODUCTION_MODE;
18
+ exports.START_CLASS = internal.START_CLASS;
19
+ Object.defineProperty(exports, "__DOTCMS_UVE_EVENT__", {
20
+ enumerable: true,
21
+ get: function () { return internal.__DOTCMS_UVE_EVENT__; }
22
+ });
23
+ exports.__UVE_EVENTS__ = internal.__UVE_EVENTS__;
24
+ exports.__UVE_EVENT_ERROR_FALLBACK__ = internal.__UVE_EVENT_ERROR_FALLBACK__;
25
+ exports.combineClasses = internal.combineClasses;
26
+ exports.computeScrollIsInBottom = internal.computeScrollIsInBottom;
27
+ exports.findDotCMSElement = internal.findDotCMSElement;
28
+ exports.findDotCMSVTLData = internal.findDotCMSVTLData;
29
+ exports.getClosestDotCMSContainerData = internal.getClosestDotCMSContainerData;
30
+ exports.getColumnPositionClasses = internal.getColumnPositionClasses;
31
+ exports.getContainersData = internal.getContainersData;
32
+ exports.getContentletsInContainer = internal.getContentletsInContainer;
33
+ exports.getDotCMSContainerData = internal.getDotCMSContainerData;
34
+ exports.getDotCMSContentletsBound = internal.getDotCMSContentletsBound;
35
+ exports.getDotCMSPageBounds = internal.getDotCMSPageBounds;
36
+ exports.getDotContainerAttributes = internal.getDotContainerAttributes;
37
+ exports.getDotContentletAttributes = internal.getDotContentletAttributes;
38
+ exports.isValidBlocks = internal.isValidBlocks;
39
+ exports.setBounds = internal.setBounds;
@@ -0,0 +1,2 @@
1
+ export * from './internal.cjs.js';
2
+ export { _default as default } from './internal.cjs.default.js';
@@ -0,0 +1 @@
1
+ export * from "./src/internal";
@@ -0,0 +1,2 @@
1
+ export { B as Blocks, C as CUSTOM_NO_COMPONENT, D as DEVELOPMENT_MODE, c as EMPTY_CONTAINER_STYLE_ANGULAR, b as EMPTY_CONTAINER_STYLE_REACT, E as END_CLASS, P as PRODUCTION_MODE, S as START_CLASS, d as __DOTCMS_UVE_EVENT__, _ as __UVE_EVENTS__, a as __UVE_EVENT_ERROR_FALLBACK__, l as combineClasses, k as computeScrollIsInBottom, i as findDotCMSElement, j as findDotCMSVTLData, h as getClosestDotCMSContainerData, m as getColumnPositionClasses, o as getContainersData, p as getContentletsInContainer, f as getDotCMSContainerData, e as getDotCMSContentletsBound, g as getDotCMSPageBounds, q as getDotContainerAttributes, n as getDotContentletAttributes, r as isValidBlocks, s as setBounds } from './index.esm2.js';
2
+ import './types.esm.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dotcms/uve",
3
- "version": "0.0.1-beta.2",
3
+ "version": "0.0.1-beta.21",
4
4
  "description": "Official JavaScript library for interacting with Universal Visual Editor (UVE)",
5
5
  "repository": {
6
6
  "type": "git",
@@ -13,12 +13,6 @@
13
13
  "UVE",
14
14
  "Universal Visual Editor"
15
15
  ],
16
- "author": "dotcms <dev@dotcms.com>",
17
- "license": "MIT",
18
- "bugs": {
19
- "url": "https://github.com/dotCMS/core/issues"
20
- },
21
- "homepage": "https://github.com/dotCMS/core/tree/main/core-web/libs/sdk/client/README.md",
22
16
  "exports": {
23
17
  "./package.json": "./package.json",
24
18
  ".": {
@@ -32,8 +26,33 @@
32
26
  "types": "./types.esm.d.ts",
33
27
  "import": "./types.cjs.mjs",
34
28
  "default": "./types.cjs.js"
29
+ },
30
+ "./internal": {
31
+ "module": "./internal.esm.js",
32
+ "types": "./internal.esm.d.ts",
33
+ "import": "./internal.cjs.mjs",
34
+ "default": "./internal.cjs.js"
35
35
  }
36
36
  },
37
+ "typesVersions": {
38
+ "*": {
39
+ ".": [
40
+ "./src/index.d.ts"
41
+ ],
42
+ "types": [
43
+ "./src/types.d.ts"
44
+ ],
45
+ "internal": [
46
+ "./src/internal.d.ts"
47
+ ]
48
+ }
49
+ },
50
+ "author": "dotcms <dev@dotcms.com>",
51
+ "license": "MIT",
52
+ "bugs": {
53
+ "url": "https://github.com/dotCMS/core/issues"
54
+ },
55
+ "homepage": "https://github.com/dotCMS/core/tree/main/core-web/libs/sdk/uve/README.md",
37
56
  "module": "./index.esm.js",
38
57
  "main": "./index.cjs.js",
39
58
  "types": "./index.esm.d.ts"
package/src/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './lib/core/core.utils';
2
+ export * from './lib/editor/public';
@@ -0,0 +1,76 @@
1
+ import { UVEEventSubscriber, UVEEventType } from '../lib/types/editor/public';
2
+ /**
3
+ * Events that can be subscribed to in the UVE
4
+ *
5
+ * @internal
6
+ * @type {Record<UVEEventType, UVEEventSubscriber>}
7
+ */
8
+ export declare const __UVE_EVENTS__: Record<UVEEventType, UVEEventSubscriber>;
9
+ /**
10
+ * Default UVE event
11
+ *
12
+ * @param {string} event - The event to subscribe to.
13
+ * @internal
14
+ */
15
+ export declare const __UVE_EVENT_ERROR_FALLBACK__: (event: string) => {
16
+ unsubscribe: () => void;
17
+ event: string;
18
+ };
19
+ /**
20
+ * Development mode
21
+ *
22
+ * @internal
23
+ */
24
+ export declare const DEVELOPMENT_MODE = "development";
25
+ /**
26
+ * Production mode
27
+ *
28
+ * @internal
29
+ */
30
+ export declare const PRODUCTION_MODE = "production";
31
+ /**
32
+ * End class
33
+ *
34
+ * @internal
35
+ */
36
+ export declare const END_CLASS = "col-end-";
37
+ /**
38
+ * Start class
39
+ *
40
+ * @internal
41
+ */
42
+ export declare const START_CLASS = "col-start-";
43
+ /**
44
+ * Empty container style for React
45
+ *
46
+ * @internal
47
+ */
48
+ export declare const EMPTY_CONTAINER_STYLE_REACT: {
49
+ width: string;
50
+ backgroundColor: string;
51
+ display: string;
52
+ justifyContent: string;
53
+ alignItems: string;
54
+ color: string;
55
+ height: string;
56
+ };
57
+ /**
58
+ * Empty container style for Angular
59
+ *
60
+ * @internal
61
+ */
62
+ export declare const EMPTY_CONTAINER_STYLE_ANGULAR: {
63
+ width: string;
64
+ 'background-color': string;
65
+ display: string;
66
+ 'justify-content': string;
67
+ 'align-items': string;
68
+ color: string;
69
+ height: string;
70
+ };
71
+ /**
72
+ * Custom no component
73
+ *
74
+ * @internal
75
+ */
76
+ export declare const CUSTOM_NO_COMPONENT = "CustomNoComponent";
@@ -0,0 +1,66 @@
1
+ import { UVEEventHandler, UVEEventType } from '../types';
2
+ /**
3
+ * Subscribes to content changes in the UVE editor
4
+ *
5
+ * @param {UVEEventHandler} callback - Function to be called when content changes are detected
6
+ * @returns {Object} Object containing unsubscribe function and event type
7
+ * @returns {Function} .unsubscribe - Function to remove the event listener
8
+ * @returns {UVEEventType} .event - The event type being subscribed to
9
+ * @internal
10
+ */
11
+ export declare function onContentChanges(callback: UVEEventHandler): {
12
+ unsubscribe: () => void;
13
+ event: UVEEventType;
14
+ };
15
+ /**
16
+ * Subscribes to page reload events in the UVE editor
17
+ *
18
+ * @param {UVEEventHandler} callback - Function to be called when page reload is triggered
19
+ * @returns {Object} Object containing unsubscribe function and event type
20
+ * @returns {Function} .unsubscribe - Function to remove the event listener
21
+ * @returns {UVEEventType} .event - The event type being subscribed to
22
+ * @internal
23
+ */
24
+ export declare function onPageReload(callback: UVEEventHandler): {
25
+ unsubscribe: () => void;
26
+ event: UVEEventType;
27
+ };
28
+ /**
29
+ * Subscribes to request bounds events in the UVE editor
30
+ *
31
+ * @param {UVEEventHandler} callback - Function to be called when bounds are requested
32
+ * @returns {Object} Object containing unsubscribe function and event type
33
+ * @returns {Function} .unsubscribe - Function to remove the event listener
34
+ * @returns {UVEEventType} .event - The event type being subscribed to
35
+ * @internal
36
+ */
37
+ export declare function onRequestBounds(callback: UVEEventHandler): {
38
+ unsubscribe: () => void;
39
+ event: UVEEventType;
40
+ };
41
+ /**
42
+ * Subscribes to iframe scroll events in the UVE editor
43
+ *
44
+ * @param {UVEEventHandler} callback - Function to be called when iframe scroll occurs
45
+ * @returns {Object} Object containing unsubscribe function and event type
46
+ * @returns {Function} .unsubscribe - Function to remove the event listener
47
+ * @returns {UVEEventType} .event - The event type being subscribed to
48
+ * @internal
49
+ */
50
+ export declare function onIframeScroll(callback: UVEEventHandler): {
51
+ unsubscribe: () => void;
52
+ event: UVEEventType;
53
+ };
54
+ /**
55
+ * Subscribes to contentlet hover events in the UVE editor
56
+ *
57
+ * @param {UVEEventHandler} callback - Function to be called when a contentlet is hovered
58
+ * @returns {Object} Object containing unsubscribe function and event type
59
+ * @returns {Function} .unsubscribe - Function to remove the event listener
60
+ * @returns {UVEEventType} .event - The event type being subscribed to
61
+ * @internal
62
+ */
63
+ export declare function onContentletHovered(callback: UVEEventHandler): {
64
+ unsubscribe: () => void;
65
+ event: UVEEventType;
66
+ };
@@ -0,0 +1 @@
1
+ export * from './constants';
@@ -0,0 +1,6 @@
1
+ export * from './internal/index';
2
+ export * from './lib/types/editor/internal';
3
+ export * from './lib/types/events/internal';
4
+ export * from './lib/dom/dom.utils';
5
+ export * from './lib/editor/internal';
6
+ export * from './lib/types/block-editor-renderer/internal';
@@ -1,4 +1,4 @@
1
- import { UVEState } from './types';
1
+ import { UVEState, UVEEventSubscription, UVEEventType, UVEEventPayloadMap } from '../types/editor/public';
2
2
  /**
3
3
  * Gets the current state of the Universal Visual Editor (UVE).
4
4
  *
@@ -28,3 +28,22 @@ import { UVEState } from './types';
28
28
  * ```
29
29
  */
30
30
  export declare function getUVEState(): UVEState | undefined;
31
+ /**
32
+ * Creates a subscription to a UVE event.
33
+ *
34
+ * @param eventType - The type of event to subscribe to
35
+ * @param callback - The callback function that will be called when the event occurs
36
+ * @returns An event subscription that can be used to unsubscribe
37
+ *
38
+ * @example
39
+ * ```ts
40
+ * // Subscribe to page changes
41
+ * const subscription = createUVESubscription(UVEEventType.CONTENT_CHANGES, (changes) => {
42
+ * console.log('Content changes:', changes);
43
+ * });
44
+ *
45
+ * // Later, unsubscribe when no longer needed
46
+ * subscription.unsubscribe();
47
+ * ```
48
+ */
49
+ export declare function createUVESubscription<T extends UVEEventType>(eventType: T, callback: (payload: UVEEventPayloadMap[T] extends undefined ? void : UVEEventPayloadMap[T]) => void): UVEEventSubscription;
@@ -0,0 +1,206 @@
1
+ import { DotCMSContainerBound, DotCMSContentletBound } from '../types/editor/internal';
2
+ import { DotContainerAttributes, DotContentletAttributes, EditableContainerData } from '../types/editor/public';
3
+ import { DotCMSColumnContainer, DotCMSContentlet, DotCMSPageAsset, DotPageAssetLayoutColumn } from '../types/page/public';
4
+ /**
5
+ * Calculates the bounding information for each page element within the given containers.
6
+ *
7
+ * @export
8
+ * @param {HTMLDivElement[]} containers - An array of HTMLDivElement representing the containers.
9
+ * @return {DotCMSContainerBound[]} An array of objects containing the bounding information for each page element.
10
+ * @example
11
+ * ```ts
12
+ * const containers = document.querySelectorAll('.container');
13
+ * const bounds = getDotCMSPageBounds(containers);
14
+ * console.log(bounds);
15
+ * ```
16
+ */
17
+ export declare function getDotCMSPageBounds(containers: HTMLDivElement[]): DotCMSContainerBound[];
18
+ /**
19
+ * Calculates the bounding information for each contentlet inside a container.
20
+ *
21
+ * @export
22
+ * @param {DOMRect} containerRect - The bounding rectangle of the container.
23
+ * @param {HTMLDivElement[]} contentlets - An array of HTMLDivElement representing the contentlets.
24
+ * @return {DotCMSContentletBound[]} An array of objects containing the bounding information for each contentlet.
25
+ * @example
26
+ * ```ts
27
+ * const containerRect = container.getBoundingClientRect();
28
+ * const contentlets = container.querySelectorAll('.contentlet');
29
+ * const bounds = getDotCMSContentletsBound(containerRect, contentlets);
30
+ * console.log(bounds); // Element bounds within the container
31
+ * ```
32
+ */
33
+ export declare function getDotCMSContentletsBound(containerRect: DOMRect, contentlets: HTMLDivElement[]): DotCMSContentletBound[];
34
+ /**
35
+ * Get container data from VTLS.
36
+ *
37
+ * @export
38
+ * @param {HTMLElement} container - The container element.
39
+ * @return {object} An object containing the container data.
40
+ * @example
41
+ * ```ts
42
+ * const container = document.querySelector('.container');
43
+ * const data = getContainerData(container);
44
+ * console.log(data);
45
+ * ```
46
+ */
47
+ export declare function getDotCMSContainerData(container: HTMLElement): {
48
+ acceptTypes: string;
49
+ identifier: string;
50
+ maxContentlets: string;
51
+ uuid: string;
52
+ };
53
+ /**
54
+ * Get the closest container data from the contentlet.
55
+ *
56
+ * @export
57
+ * @param {Element} element - The contentlet element.
58
+ * @return {object | null} An object containing the closest container data or null if no container is found.
59
+ * @example
60
+ * ```ts
61
+ * const contentlet = document.querySelector('.contentlet');
62
+ * const data = getClosestDotCMSContainerData(contentlet);
63
+ * console.log(data);
64
+ * ```
65
+ */
66
+ export declare function getClosestDotCMSContainerData(element: Element): {
67
+ acceptTypes: string;
68
+ identifier: string;
69
+ maxContentlets: string;
70
+ uuid: string;
71
+ } | null;
72
+ /**
73
+ * Find the closest contentlet element based on HTMLElement.
74
+ *
75
+ * @export
76
+ * @param {HTMLElement | null} element - The starting element.
77
+ * @return {HTMLElement | null} The closest contentlet element or null if not found.
78
+ * @example
79
+ * const element = document.querySelector('.some-element');
80
+ * const contentlet = findDotCMSElement(element);
81
+ * console.log(contentlet);
82
+ */
83
+ export declare function findDotCMSElement(element: HTMLElement | null): HTMLElement | null;
84
+ /**
85
+ * Find VTL data within a target element.
86
+ *
87
+ * @export
88
+ * @param {HTMLElement} target - The target element to search within.
89
+ * @return {Array<{ inode: string, name: string }> | null} An array of objects containing VTL data or null if none found.
90
+ * @example
91
+ * ```ts
92
+ * const target = document.querySelector('.target-element');
93
+ * const vtlData = findDotCMSVTLData(target);
94
+ * console.log(vtlData);
95
+ * ```
96
+ */
97
+ export declare function findDotCMSVTLData(target: HTMLElement): {
98
+ inode: string | undefined;
99
+ name: string | undefined;
100
+ }[] | null;
101
+ /**
102
+ * Check if the scroll position is at the bottom of the page.
103
+ *
104
+ * @export
105
+ * @return {boolean} True if the scroll position is at the bottom, otherwise false.
106
+ * @example
107
+ * ```ts
108
+ * if (dotCMSScrollIsInBottom()) {
109
+ * console.log('Scrolled to the bottom');
110
+ * }
111
+ * ```
112
+ */
113
+ export declare function computeScrollIsInBottom(): boolean;
114
+ /**
115
+ *
116
+ *
117
+ * Combine classes into a single string.
118
+ *
119
+ * @param {string[]} classes
120
+ * @returns {string} Combined classes
121
+ */
122
+ export declare const combineClasses: (classes: string[]) => string;
123
+ /**
124
+ *
125
+ *
126
+ * Calculates and returns the CSS Grid positioning classes for a column based on its configuration.
127
+ * Uses a 12-column grid system where columns are positioned using grid-column-start and grid-column-end.
128
+ *
129
+ * @example
130
+ * ```typescript
131
+ * const classes = getColumnPositionClasses({
132
+ * leftOffset: 1, // Starts at the first column
133
+ * width: 6 // Spans 6 columns
134
+ * });
135
+ * // Returns: { startClass: 'col-start-1', endClass: 'col-end-7' }
136
+ * ```
137
+ *
138
+ * @param {DotPageAssetLayoutColumn} column - Column configuration object
139
+ * @param {number} column.leftOffset - Starting position (0-based) in the grid
140
+ * @param {number} column.width - Number of columns to span
141
+ * @returns {{ startClass: string, endClass: string }} Object containing CSS class names for grid positioning
142
+ */
143
+ export declare const getColumnPositionClasses: (column: DotPageAssetLayoutColumn) => {
144
+ startClass: string;
145
+ endClass: string;
146
+ };
147
+ /**
148
+ *
149
+ *
150
+ * Helper function that returns an object containing the dotCMS data attributes.
151
+ * @param {DotCMSContentlet} contentlet - The contentlet to get the attributes for
152
+ * @param {string} container - The container to get the attributes for
153
+ * @returns {DotContentletAttributes} The dotCMS data attributes
154
+ */
155
+ export declare function getDotContentletAttributes(contentlet: DotCMSContentlet, container: string): DotContentletAttributes;
156
+ /**
157
+ *
158
+ *
159
+ * Retrieves container data from a DotCMS page asset using the container reference.
160
+ * This function processes the container information and returns a standardized format
161
+ * for container editing.
162
+ *
163
+ * @param {DotCMSPageAsset} dotCMSPageAsset - The page asset containing all containers data
164
+ * @param {DotCMSColumnContainer} columContainer - The container reference from the layout
165
+ * @throws {Error} When page asset is invalid or container is not found
166
+ * @returns {EditableContainerData} Formatted container data for editing
167
+ *
168
+ * @example
169
+ * const containerData = getContainersData(pageAsset, containerRef);
170
+ * // Returns: { uuid: '123', identifier: 'cont1', acceptTypes: 'type1,type2', maxContentlets: 5 }
171
+ */
172
+ export declare const getContainersData: (dotCMSPageAsset: DotCMSPageAsset, columContainer: DotCMSColumnContainer) => EditableContainerData | null;
173
+ /**
174
+ *
175
+ *
176
+ * Retrieves the contentlets (content items) associated with a specific container.
177
+ * Handles different UUID formats and provides warning for missing contentlets.
178
+ *
179
+ * @param {DotCMSPageAsset} dotCMSPageAsset - The page asset containing all containers data
180
+ * @param {DotCMSColumnContainer} columContainer - The container reference from the layout
181
+ * @returns {DotCMSContentlet[]} Array of contentlets in the container
182
+ *
183
+ * @example
184
+ * const contentlets = getContentletsInContainer(pageAsset, containerRef);
185
+ * // Returns: [{ identifier: 'cont1', ... }, { identifier: 'cont2', ... }]
186
+ */
187
+ export declare const getContentletsInContainer: (dotCMSPageAsset: DotCMSPageAsset, columContainer: DotCMSColumnContainer) => DotCMSContentlet[];
188
+ /**
189
+ *
190
+ *
191
+ * Generates the required DotCMS data attributes for a container element.
192
+ * These attributes are used by DotCMS for container identification and functionality.
193
+ *
194
+ * @param {EditableContainerData} params - Container data including uuid, identifier, acceptTypes, and maxContentlets
195
+ * @returns {DotContainerAttributes} Object containing all necessary data attributes
196
+ *
197
+ * @example
198
+ * const attributes = getDotContainerAttributes({
199
+ * uuid: '123',
200
+ * identifier: 'cont1',
201
+ * acceptTypes: 'type1,type2',
202
+ * maxContentlets: 5
203
+ * });
204
+ * // Returns: { 'data-dot-object': 'container', 'data-dot-identifier': 'cont1', ... }
205
+ */
206
+ export declare function getDotContainerAttributes({ uuid, identifier, acceptTypes, maxContentlets }: EditableContainerData): DotContainerAttributes;
@@ -0,0 +1,23 @@
1
+ import { BlockEditorState, DotCMSContainerBound } from '@dotcms/uve/internal';
2
+ import { Block } from '@dotcms/uve/types';
3
+ /**
4
+ * Sets the bounds of the containers in the editor.
5
+ * Retrieves the containers from the DOM and sends their position data to the editor.
6
+ * @private
7
+ * @memberof DotCMSPageEditor
8
+ */
9
+ export declare function setBounds(bounds: DotCMSContainerBound[]): void;
10
+ /**
11
+ * Validates the structure of a Block Editor block.
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
17
+ *
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
+ */
23
+ export declare const isValidBlocks: (blocks: Block) => BlockEditorState;
@@ -0,0 +1,62 @@
1
+ import { DotCMSReorderMenuConfig, DotCMSUVEMessage } from '../types/editor/internal';
2
+ import { Contentlet, DotCMSUVEConfig } from '../types/editor/public';
3
+ import { DotCMSInlineEditingPayload, DotCMSInlineEditingType } from '../types/events/public';
4
+ /**
5
+ * Post message to dotcms page editor
6
+ *
7
+ * @export
8
+ * @template T
9
+ * @param {DotCMSUVEMessage<T>} message
10
+ */
11
+ export declare function sendMessageToUVE<T = unknown>(message: DotCMSUVEMessage<T>): void;
12
+ /**
13
+ * You can use this function to edit a contentlet in the editor.
14
+ *
15
+ * Calling this function inside the editor, will prompt the UVE to open a dialog to edit the contentlet.
16
+ *
17
+ * @export
18
+ * @template T
19
+ * @param {Contentlet<T>} contentlet - The contentlet to edit.
20
+ */
21
+ export declare function editContentlet<T>(contentlet: Contentlet<T>): void;
22
+ export declare function reorderMenu(config?: DotCMSReorderMenuConfig): void;
23
+ /**
24
+ * Initializes the inline editing in the editor.
25
+ *
26
+ * @export
27
+ * @param {INLINE_EDITING_EVENT_KEY} type
28
+ * @param {InlineEditEventData} eventData
29
+ * @return {*}
30
+ *
31
+ * * @example
32
+ * ```html
33
+ * <div onclick="initInlineEditing('BLOCK_EDITOR', { inode, languageId, contentType, fieldName, content })">
34
+ * ${My Content}
35
+ * </div>
36
+ * ```
37
+ */
38
+ export declare function initInlineEditing(type: DotCMSInlineEditingType, data?: DotCMSInlineEditingPayload): void;
39
+ /**
40
+ * Initializes the Universal Visual Editor (UVE) with required handlers and event listeners.
41
+ *
42
+ * This function sets up:
43
+ * - Scroll handling
44
+ * - Empty contentlet styling
45
+ * - Block editor inline event listening
46
+ * - Client ready state
47
+ * - UVE event subscriptions
48
+ *
49
+ * @returns {Object} An object containing the cleanup function
50
+ * @returns {Function} destroyUVESubscriptions - Function to clean up all UVE event subscriptions
51
+ *
52
+ * @example
53
+ * ```typescript
54
+ * const { destroyUVESubscriptions } = initUVE();
55
+ *
56
+ * // When done with UVE
57
+ * destroyUVESubscriptions();
58
+ * ```
59
+ */
60
+ export declare function initUVE(config?: DotCMSUVEConfig): {
61
+ destroyUVESubscriptions: () => void;
62
+ };
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Enum representing the different types of blocks available in the Block Editor
3
+ *
4
+ * @export
5
+ * @enum {string}
6
+ */
7
+ export declare enum Blocks {
8
+ /** Represents a paragraph block */
9
+ PARAGRAPH = "paragraph",
10
+ /** Represents a heading block */
11
+ HEADING = "heading",
12
+ /** Represents a text block */
13
+ TEXT = "text",
14
+ /** Represents a bullet/unordered list block */
15
+ BULLET_LIST = "bulletList",
16
+ /** Represents an ordered/numbered list block */
17
+ ORDERED_LIST = "orderedList",
18
+ /** Represents a list item within a list block */
19
+ LIST_ITEM = "listItem",
20
+ /** Represents a blockquote block */
21
+ BLOCK_QUOTE = "blockquote",
22
+ /** Represents a code block */
23
+ CODE_BLOCK = "codeBlock",
24
+ /** Represents a hard break (line break) */
25
+ HARDBREAK = "hardBreak",
26
+ /** Represents a horizontal rule/divider */
27
+ HORIZONTAL_RULE = "horizontalRule",
28
+ /** Represents a DotCMS image block */
29
+ DOT_IMAGE = "dotImage",
30
+ /** Represents a DotCMS video block */
31
+ DOT_VIDEO = "dotVideo",
32
+ /** Represents a table block */
33
+ TABLE = "table",
34
+ /** Represents a DotCMS content block */
35
+ DOT_CONTENT = "dotContent"
36
+ }
37
+ /**
38
+ * Represents the validation state of a Block Editor instance
39
+ *
40
+ * @interface BlockEditorState
41
+ * @property {boolean} isValid - Whether the blocks structure is valid
42
+ * @property {string | null} error - Error message if blocks are invalid, null otherwise
43
+ */
44
+ export interface BlockEditorState {
45
+ error: string | null;
46
+ }
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Represents a Mark used by text content in the Block Editor
3
+ *
4
+ * @export
5
+ * @interface Mark
6
+ */
7
+ export interface Mark {
8
+ type: string;
9
+ attrs: Record<string, string>;
10
+ }
11
+ /**
12
+ * Represents a Content Node used by the Block Editor
13
+ *
14
+ * @export
15
+ * @interface ContentNode
16
+ */
17
+ export interface ContentNode {
18
+ /** The type of content node */
19
+ type: string;
20
+ /** Child content nodes */
21
+ content?: ContentNode[];
22
+ /** Optional attributes for the node */
23
+ attrs?: Record<string, any>;
24
+ /** Optional marks applied to text content */
25
+ marks?: Mark[];
26
+ /** Optional text content */
27
+ text?: string;
28
+ }
29
+ /**
30
+ * Represents a Block in the Block Editor
31
+ *
32
+ * @export
33
+ * @interface Block
34
+ */
35
+ export interface Block {
36
+ content?: ContentNode[];
37
+ type: string;
38
+ }