@dotcms/uve 0.0.1-beta.9 → 1.0.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 +586 -4
- package/index.cjs.js +13 -82
- package/index.esm.js +3 -83
- package/internal.cjs.js +87 -60
- package/internal.esm.js +61 -59
- package/package.json +4 -10
- package/public.cjs.js +1132 -0
- package/public.esm.js +1098 -0
- package/src/index.d.ts +2 -1
- package/src/internal/constants.d.ts +61 -3
- package/src/internal/events.d.ts +66 -0
- package/src/internal/index.d.ts +1 -0
- package/src/internal/tinymce.config.d.ts +45 -0
- package/src/internal.d.ts +2 -2
- package/src/lib/{utils.d.ts → core/core.utils.d.ts} +11 -7
- package/src/lib/dom/dom.utils.d.ts +205 -0
- package/src/lib/editor/internal.d.ts +23 -0
- package/src/lib/editor/public.d.ts +86 -0
- package/src/script/sdk-editor.d.ts +6 -0
- package/src/script/utils.d.ts +53 -0
- package/src/lib/types/editor/internal.d.ts +0 -44
- package/src/lib/types/editor/public.d.ts +0 -138
- package/src/lib/types/events/internal.d.ts +0 -32
- package/src/lib/types/events/public.d.ts +0 -18
- package/src/types.d.ts +0 -2
- package/types.cjs.d.ts +0 -1
- package/types.cjs.default.js +0 -1
- package/types.cjs.js +0 -84
- package/types.cjs.mjs +0 -2
- package/types.esm.d.ts +0 -1
- package/types.esm.js +0 -84
package/src/index.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export * from './lib/utils';
|
|
1
|
+
export * from './lib/core/core.utils';
|
|
2
|
+
export * from './lib/editor/public';
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { UVEEventSubscriber, UVEEventType } from '@dotcms/types';
|
|
2
2
|
/**
|
|
3
3
|
* Events that can be subscribed to in the UVE
|
|
4
4
|
*
|
|
5
5
|
* @internal
|
|
6
|
-
* @type {Record<
|
|
6
|
+
* @type {Record<UVEEventType, UVEEventSubscriber>}
|
|
7
7
|
*/
|
|
8
|
-
export declare const __UVE_EVENTS__: Record<
|
|
8
|
+
export declare const __UVE_EVENTS__: Record<UVEEventType, UVEEventSubscriber>;
|
|
9
9
|
/**
|
|
10
10
|
* Default UVE event
|
|
11
11
|
*
|
|
@@ -16,3 +16,61 @@ export declare const __UVE_EVENT_ERROR_FALLBACK__: (event: string) => {
|
|
|
16
16
|
unsubscribe: () => void;
|
|
17
17
|
event: string;
|
|
18
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 '@dotcms/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
|
+
};
|
package/src/internal/index.d.ts
CHANGED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TinyMCE default config across all versions
|
|
3
|
+
*
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
6
|
+
export declare const __DEFAULT_TINYMCE_CONFIG__: {
|
|
7
|
+
menubar: boolean;
|
|
8
|
+
inline: boolean;
|
|
9
|
+
valid_styles: {
|
|
10
|
+
'*': string;
|
|
11
|
+
};
|
|
12
|
+
powerpaste_word_import: string;
|
|
13
|
+
powerpaste_html_import: string;
|
|
14
|
+
suffix: string;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* TinyMCE config to use per mode
|
|
18
|
+
*
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
21
|
+
export declare const __BASE_TINYMCE_CONFIG_WITH_NO_DEFAULT__: {
|
|
22
|
+
full: {
|
|
23
|
+
plugins: string;
|
|
24
|
+
toolbar: string[];
|
|
25
|
+
style_formats: {
|
|
26
|
+
title: string;
|
|
27
|
+
format: string;
|
|
28
|
+
}[];
|
|
29
|
+
};
|
|
30
|
+
plain: {
|
|
31
|
+
plugins: string;
|
|
32
|
+
toolbar: string;
|
|
33
|
+
};
|
|
34
|
+
minimal: {
|
|
35
|
+
plugins: string;
|
|
36
|
+
toolbar: string;
|
|
37
|
+
valid_elements: string;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* TinyMCE path
|
|
42
|
+
*
|
|
43
|
+
* @internal
|
|
44
|
+
*/
|
|
45
|
+
export declare const __TINYMCE_PATH_ON_DOTCMS__ = "/ext/tinymcev7/tinymce.min.js";
|
package/src/internal.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export * from './internal/index';
|
|
2
|
-
export * from './lib/
|
|
3
|
-
export * from './lib/
|
|
2
|
+
export * from './lib/dom/dom.utils';
|
|
3
|
+
export * from './lib/editor/internal';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { UVEState, UVEEventSubscription, UVEEventType, UVEEventPayloadMap } from '@dotcms/types';
|
|
2
2
|
/**
|
|
3
3
|
* Gets the current state of the Universal Visual Editor (UVE).
|
|
4
4
|
*
|
|
@@ -31,15 +31,19 @@ export declare function getUVEState(): UVEState | undefined;
|
|
|
31
31
|
/**
|
|
32
32
|
* Creates a subscription to a UVE event.
|
|
33
33
|
*
|
|
34
|
-
* @param
|
|
35
|
-
* @param
|
|
36
|
-
* @
|
|
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
37
|
*
|
|
38
38
|
* @example
|
|
39
39
|
* ```ts
|
|
40
|
-
*
|
|
41
|
-
*
|
|
40
|
+
* // Subscribe to page changes
|
|
41
|
+
* const subscription = createUVESubscription(UVEEventType.CONTENT_CHANGES, (changes) => {
|
|
42
|
+
* console.log('Content changes:', changes);
|
|
42
43
|
* });
|
|
44
|
+
*
|
|
45
|
+
* // Later, unsubscribe when no longer needed
|
|
46
|
+
* subscription.unsubscribe();
|
|
43
47
|
* ```
|
|
44
48
|
*/
|
|
45
|
-
export declare function createUVESubscription(
|
|
49
|
+
export declare function createUVESubscription<T extends UVEEventType>(eventType: T, callback: (payload: UVEEventPayloadMap[T] extends undefined ? void : UVEEventPayloadMap[T]) => void): UVEEventSubscription;
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import { EditableContainerData, DotCMSColumnContainer, DotCMSBasicContentlet, DotCMSPageAsset, DotPageAssetLayoutColumn } from '@dotcms/types';
|
|
2
|
+
import { DotCMSContainerBound, DotCMSContentletBound, DotContainerAttributes, DotContentletAttributes } from '@dotcms/types/internal';
|
|
3
|
+
/**
|
|
4
|
+
* Calculates the bounding information for each page element within the given containers.
|
|
5
|
+
*
|
|
6
|
+
* @export
|
|
7
|
+
* @param {HTMLDivElement[]} containers - An array of HTMLDivElement representing the containers.
|
|
8
|
+
* @return {DotCMSContainerBound[]} An array of objects containing the bounding information for each page element.
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* const containers = document.querySelectorAll('.container');
|
|
12
|
+
* const bounds = getDotCMSPageBounds(containers);
|
|
13
|
+
* console.log(bounds);
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare function getDotCMSPageBounds(containers: HTMLDivElement[]): DotCMSContainerBound[];
|
|
17
|
+
/**
|
|
18
|
+
* Calculates the bounding information for each contentlet inside a container.
|
|
19
|
+
*
|
|
20
|
+
* @export
|
|
21
|
+
* @param {DOMRect} containerRect - The bounding rectangle of the container.
|
|
22
|
+
* @param {HTMLDivElement[]} contentlets - An array of HTMLDivElement representing the contentlets.
|
|
23
|
+
* @return {DotCMSContentletBound[]} An array of objects containing the bounding information for each contentlet.
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* const containerRect = container.getBoundingClientRect();
|
|
27
|
+
* const contentlets = container.querySelectorAll('.contentlet');
|
|
28
|
+
* const bounds = getDotCMSContentletsBound(containerRect, contentlets);
|
|
29
|
+
* console.log(bounds); // Element bounds within the container
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare function getDotCMSContentletsBound(containerRect: DOMRect, contentlets: HTMLDivElement[]): DotCMSContentletBound[];
|
|
33
|
+
/**
|
|
34
|
+
* Get container data from VTLS.
|
|
35
|
+
*
|
|
36
|
+
* @export
|
|
37
|
+
* @param {HTMLElement} container - The container element.
|
|
38
|
+
* @return {object} An object containing the container data.
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* const container = document.querySelector('.container');
|
|
42
|
+
* const data = getContainerData(container);
|
|
43
|
+
* console.log(data);
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export declare function getDotCMSContainerData(container: HTMLElement): {
|
|
47
|
+
acceptTypes: string;
|
|
48
|
+
identifier: string;
|
|
49
|
+
maxContentlets: string;
|
|
50
|
+
uuid: string;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Get the closest container data from the contentlet.
|
|
54
|
+
*
|
|
55
|
+
* @export
|
|
56
|
+
* @param {Element} element - The contentlet element.
|
|
57
|
+
* @return {object | null} An object containing the closest container data or null if no container is found.
|
|
58
|
+
* @example
|
|
59
|
+
* ```ts
|
|
60
|
+
* const contentlet = document.querySelector('.contentlet');
|
|
61
|
+
* const data = getClosestDotCMSContainerData(contentlet);
|
|
62
|
+
* console.log(data);
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
export declare function getClosestDotCMSContainerData(element: Element): {
|
|
66
|
+
acceptTypes: string;
|
|
67
|
+
identifier: string;
|
|
68
|
+
maxContentlets: string;
|
|
69
|
+
uuid: string;
|
|
70
|
+
} | null;
|
|
71
|
+
/**
|
|
72
|
+
* Find the closest contentlet element based on HTMLElement.
|
|
73
|
+
*
|
|
74
|
+
* @export
|
|
75
|
+
* @param {HTMLElement | null} element - The starting element.
|
|
76
|
+
* @return {HTMLElement | null} The closest contentlet element or null if not found.
|
|
77
|
+
* @example
|
|
78
|
+
* const element = document.querySelector('.some-element');
|
|
79
|
+
* const contentlet = findDotCMSElement(element);
|
|
80
|
+
* console.log(contentlet);
|
|
81
|
+
*/
|
|
82
|
+
export declare function findDotCMSElement(element: HTMLElement | null): HTMLElement | null;
|
|
83
|
+
/**
|
|
84
|
+
* Find VTL data within a target element.
|
|
85
|
+
*
|
|
86
|
+
* @export
|
|
87
|
+
* @param {HTMLElement} target - The target element to search within.
|
|
88
|
+
* @return {Array<{ inode: string, name: string }> | null} An array of objects containing VTL data or null if none found.
|
|
89
|
+
* @example
|
|
90
|
+
* ```ts
|
|
91
|
+
* const target = document.querySelector('.target-element');
|
|
92
|
+
* const vtlData = findDotCMSVTLData(target);
|
|
93
|
+
* console.log(vtlData);
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
export declare function findDotCMSVTLData(target: HTMLElement): {
|
|
97
|
+
inode: string | undefined;
|
|
98
|
+
name: string | undefined;
|
|
99
|
+
}[] | null;
|
|
100
|
+
/**
|
|
101
|
+
* Check if the scroll position is at the bottom of the page.
|
|
102
|
+
*
|
|
103
|
+
* @export
|
|
104
|
+
* @return {boolean} True if the scroll position is at the bottom, otherwise false.
|
|
105
|
+
* @example
|
|
106
|
+
* ```ts
|
|
107
|
+
* if (dotCMSScrollIsInBottom()) {
|
|
108
|
+
* console.log('Scrolled to the bottom');
|
|
109
|
+
* }
|
|
110
|
+
* ```
|
|
111
|
+
*/
|
|
112
|
+
export declare function computeScrollIsInBottom(): boolean;
|
|
113
|
+
/**
|
|
114
|
+
*
|
|
115
|
+
*
|
|
116
|
+
* Combine classes into a single string.
|
|
117
|
+
*
|
|
118
|
+
* @param {string[]} classes
|
|
119
|
+
* @returns {string} Combined classes
|
|
120
|
+
*/
|
|
121
|
+
export declare const combineClasses: (classes: string[]) => string;
|
|
122
|
+
/**
|
|
123
|
+
*
|
|
124
|
+
*
|
|
125
|
+
* Calculates and returns the CSS Grid positioning classes for a column based on its configuration.
|
|
126
|
+
* Uses a 12-column grid system where columns are positioned using grid-column-start and grid-column-end.
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
* ```typescript
|
|
130
|
+
* const classes = getColumnPositionClasses({
|
|
131
|
+
* leftOffset: 1, // Starts at the first column
|
|
132
|
+
* width: 6 // Spans 6 columns
|
|
133
|
+
* });
|
|
134
|
+
* // Returns: { startClass: 'col-start-1', endClass: 'col-end-7' }
|
|
135
|
+
* ```
|
|
136
|
+
*
|
|
137
|
+
* @param {DotPageAssetLayoutColumn} column - Column configuration object
|
|
138
|
+
* @param {number} column.leftOffset - Starting position (0-based) in the grid
|
|
139
|
+
* @param {number} column.width - Number of columns to span
|
|
140
|
+
* @returns {{ startClass: string, endClass: string }} Object containing CSS class names for grid positioning
|
|
141
|
+
*/
|
|
142
|
+
export declare const getColumnPositionClasses: (column: DotPageAssetLayoutColumn) => {
|
|
143
|
+
startClass: string;
|
|
144
|
+
endClass: string;
|
|
145
|
+
};
|
|
146
|
+
/**
|
|
147
|
+
*
|
|
148
|
+
*
|
|
149
|
+
* Helper function that returns an object containing the dotCMS data attributes.
|
|
150
|
+
* @param {DotCMSBasicContentlet} contentlet - The contentlet to get the attributes for
|
|
151
|
+
* @param {string} container - The container to get the attributes for
|
|
152
|
+
* @returns {DotContentletAttributes} The dotCMS data attributes
|
|
153
|
+
*/
|
|
154
|
+
export declare function getDotContentletAttributes(contentlet: DotCMSBasicContentlet, container: string): DotContentletAttributes;
|
|
155
|
+
/**
|
|
156
|
+
*
|
|
157
|
+
*
|
|
158
|
+
* Retrieves container data from a DotCMS page asset using the container reference.
|
|
159
|
+
* This function processes the container information and returns a standardized format
|
|
160
|
+
* for container editing.
|
|
161
|
+
*
|
|
162
|
+
* @param {DotCMSPageAsset} dotCMSPageAsset - The page asset containing all containers data
|
|
163
|
+
* @param {DotCMSColumnContainer} columContainer - The container reference from the layout
|
|
164
|
+
* @throws {Error} When page asset is invalid or container is not found
|
|
165
|
+
* @returns {EditableContainerData} Formatted container data for editing
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
* const containerData = getContainersData(pageAsset, containerRef);
|
|
169
|
+
* // Returns: { uuid: '123', identifier: 'cont1', acceptTypes: 'type1,type2', maxContentlets: 5 }
|
|
170
|
+
*/
|
|
171
|
+
export declare const getContainersData: (dotCMSPageAsset: DotCMSPageAsset, columContainer: DotCMSColumnContainer) => EditableContainerData | null;
|
|
172
|
+
/**
|
|
173
|
+
*
|
|
174
|
+
*
|
|
175
|
+
* Retrieves the contentlets (content items) associated with a specific container.
|
|
176
|
+
* Handles different UUID formats and provides warning for missing contentlets.
|
|
177
|
+
*
|
|
178
|
+
* @param {DotCMSPageAsset} dotCMSPageAsset - The page asset containing all containers data
|
|
179
|
+
* @param {DotCMSColumnContainer} columContainer - The container reference from the layout
|
|
180
|
+
* @returns {DotCMSBasicContentlet[]} Array of contentlets in the container
|
|
181
|
+
*
|
|
182
|
+
* @example
|
|
183
|
+
* const contentlets = getContentletsInContainer(pageAsset, containerRef);
|
|
184
|
+
* // Returns: [{ identifier: 'cont1', ... }, { identifier: 'cont2', ... }]
|
|
185
|
+
*/
|
|
186
|
+
export declare const getContentletsInContainer: (dotCMSPageAsset: DotCMSPageAsset, columContainer: DotCMSColumnContainer) => DotCMSBasicContentlet[];
|
|
187
|
+
/**
|
|
188
|
+
*
|
|
189
|
+
*
|
|
190
|
+
* Generates the required DotCMS data attributes for a container element.
|
|
191
|
+
* These attributes are used by DotCMS for container identification and functionality.
|
|
192
|
+
*
|
|
193
|
+
* @param {EditableContainerData} params - Container data including uuid, identifier, acceptTypes, and maxContentlets
|
|
194
|
+
* @returns {DotContainerAttributes} Object containing all necessary data attributes
|
|
195
|
+
*
|
|
196
|
+
* @example
|
|
197
|
+
* const attributes = getDotContainerAttributes({
|
|
198
|
+
* uuid: '123',
|
|
199
|
+
* identifier: 'cont1',
|
|
200
|
+
* acceptTypes: 'type1,type2',
|
|
201
|
+
* maxContentlets: 5
|
|
202
|
+
* });
|
|
203
|
+
* // Returns: { 'data-dot-object': 'container', 'data-dot-identifier': 'cont1', ... }
|
|
204
|
+
*/
|
|
205
|
+
export declare function getDotContainerAttributes({ uuid, identifier, acceptTypes, maxContentlets }: EditableContainerData): DotContainerAttributes;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { BlockEditorContent } from '@dotcms/types';
|
|
2
|
+
import { BlockEditorState, DotCMSContainerBound } from '@dotcms/types/internal';
|
|
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: BlockEditorContent) => BlockEditorState;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { Contentlet, DotCMSInlineEditingPayload, DotCMSInlineEditingType, DotCMSBasicContentlet, DotCMSPageResponse } from '@dotcms/types';
|
|
2
|
+
import { DotCMSReorderMenuConfig, DotCMSUVEMessage } from '@dotcms/types/internal';
|
|
3
|
+
/**
|
|
4
|
+
* Updates the navigation in the editor.
|
|
5
|
+
*
|
|
6
|
+
* @param {string} pathname - The pathname to update the navigation with.
|
|
7
|
+
* @memberof DotCMSPageEditor
|
|
8
|
+
* @example
|
|
9
|
+
* updateNavigation('/home'); // Sends a message to the editor to update the navigation to '/home'
|
|
10
|
+
*/
|
|
11
|
+
export declare function updateNavigation(pathname: string): void;
|
|
12
|
+
/**
|
|
13
|
+
* Post message to dotcms page editor
|
|
14
|
+
*
|
|
15
|
+
* @export
|
|
16
|
+
* @template T
|
|
17
|
+
* @param {DotCMSUVEMessage<T>} message
|
|
18
|
+
*/
|
|
19
|
+
export declare function sendMessageToUVE<T = unknown>(message: DotCMSUVEMessage<T>): void;
|
|
20
|
+
/**
|
|
21
|
+
* You can use this function to edit a contentlet in the editor.
|
|
22
|
+
*
|
|
23
|
+
* Calling this function inside the editor, will prompt the UVE to open a dialog to edit the contentlet.
|
|
24
|
+
*
|
|
25
|
+
* @export
|
|
26
|
+
* @template T
|
|
27
|
+
* @param {Contentlet<T>} contentlet - The contentlet to edit.
|
|
28
|
+
*/
|
|
29
|
+
export declare function editContentlet<T>(contentlet: Contentlet<T>): void;
|
|
30
|
+
export declare function reorderMenu(config?: DotCMSReorderMenuConfig): void;
|
|
31
|
+
/**
|
|
32
|
+
* Initializes the inline editing in the editor.
|
|
33
|
+
*
|
|
34
|
+
* @export
|
|
35
|
+
* @param {INLINE_EDITING_EVENT_KEY} type
|
|
36
|
+
* @param {InlineEditEventData} eventData
|
|
37
|
+
* @return {*}
|
|
38
|
+
*
|
|
39
|
+
* * @example
|
|
40
|
+
* ```html
|
|
41
|
+
* <div onclick="initInlineEditing('BLOCK_EDITOR', { inode, languageId, contentType, fieldName, content })">
|
|
42
|
+
* ${My Content}
|
|
43
|
+
* </div>
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export declare function initInlineEditing(type: DotCMSInlineEditingType, data?: DotCMSInlineEditingPayload): void;
|
|
47
|
+
/**
|
|
48
|
+
* Initializes the block editor inline editing for a contentlet field.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```html
|
|
52
|
+
* <div onclick="enableBlockEditorInline(contentlet, 'MY_BLOCK_EDITOR_FIELD_VARIABLE')">
|
|
53
|
+
* ${My Content}
|
|
54
|
+
* </div>
|
|
55
|
+
* ```
|
|
56
|
+
*
|
|
57
|
+
* @export
|
|
58
|
+
* @param {DotCMSBasicContentlet} contentlet
|
|
59
|
+
* @param {string} fieldName
|
|
60
|
+
* @return {*} {void}
|
|
61
|
+
*/
|
|
62
|
+
export declare function enableBlockEditorInline<T extends DotCMSBasicContentlet>(contentlet: T extends DotCMSBasicContentlet ? T : never, fieldName: keyof T): void;
|
|
63
|
+
/**
|
|
64
|
+
* Initializes the Universal Visual Editor (UVE) with required handlers and event listeners.
|
|
65
|
+
*
|
|
66
|
+
* This function sets up:
|
|
67
|
+
* - Scroll handling
|
|
68
|
+
* - Empty contentlet styling
|
|
69
|
+
* - Block editor inline event listening
|
|
70
|
+
* - Client ready state
|
|
71
|
+
* - UVE event subscriptions
|
|
72
|
+
*
|
|
73
|
+
* @returns {Object} An object containing the cleanup function
|
|
74
|
+
* @returns {Function} destroyUVESubscriptions - Function to clean up all UVE event subscriptions
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```typescript
|
|
78
|
+
* const { destroyUVESubscriptions } = initUVE();
|
|
79
|
+
*
|
|
80
|
+
* // When done with UVE
|
|
81
|
+
* destroyUVESubscriptions();
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
export declare function initUVE(config?: DotCMSPageResponse): {
|
|
85
|
+
destroyUVESubscriptions: () => void;
|
|
86
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { DotCMSPageResponse } from '@dotcms/types';
|
|
2
|
+
/**
|
|
3
|
+
* Sets up scroll event handlers for the window to notify the editor about scroll events.
|
|
4
|
+
* Adds listeners for both 'scroll' and 'scrollend' events, sending appropriate messages
|
|
5
|
+
* to the editor when these events occur.
|
|
6
|
+
*/
|
|
7
|
+
export declare function scrollHandler(): {
|
|
8
|
+
destroyScrollHandler: () => void;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Adds 'empty-contentlet' class to contentlet elements that have no height.
|
|
12
|
+
* This helps identify and style empty contentlets in the editor view.
|
|
13
|
+
*
|
|
14
|
+
* @remarks
|
|
15
|
+
* The function queries all elements with data-dot-object="contentlet" attribute
|
|
16
|
+
* and checks their clientHeight. If an element has no height (clientHeight = 0),
|
|
17
|
+
* it adds the 'empty-contentlet' class to that element.
|
|
18
|
+
*/
|
|
19
|
+
export declare function addClassToEmptyContentlets(): void;
|
|
20
|
+
/**
|
|
21
|
+
* Registers event handlers for various UVE (Universal Visual Editor) events.
|
|
22
|
+
*
|
|
23
|
+
* This function sets up subscriptions for:
|
|
24
|
+
* - Page reload events that refresh the window
|
|
25
|
+
* - Bounds request events to update editor boundaries
|
|
26
|
+
* - Iframe scroll events to handle smooth scrolling within bounds
|
|
27
|
+
* - Contentlet hover events to notify the editor
|
|
28
|
+
*
|
|
29
|
+
* @remarks
|
|
30
|
+
* For scroll events, the function includes logic to prevent scrolling beyond
|
|
31
|
+
* the top or bottom boundaries of the iframe, which helps maintain proper
|
|
32
|
+
* scroll event handling.
|
|
33
|
+
*/
|
|
34
|
+
export declare function registerUVEEvents(): {
|
|
35
|
+
subscriptions: import("@dotcms/types").UVEEventSubscription[];
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Notifies the editor that the UVE client is ready to receive messages.
|
|
39
|
+
*
|
|
40
|
+
* This function sends a message to the editor indicating that the client-side
|
|
41
|
+
* initialization is complete and it's ready to handle editor interactions.
|
|
42
|
+
*
|
|
43
|
+
* @remarks
|
|
44
|
+
* This is typically called after all UVE event handlers and DOM listeners
|
|
45
|
+
* have been set up successfully.
|
|
46
|
+
*/
|
|
47
|
+
export declare function setClientIsReady(config?: DotCMSPageResponse): void;
|
|
48
|
+
/**
|
|
49
|
+
* Listen for block editor inline event.
|
|
50
|
+
*/
|
|
51
|
+
export declare function listenBlockEditorInlineEvent(): {
|
|
52
|
+
destroyListenBlockEditorInlineEvent: () => void;
|
|
53
|
+
};
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { DotCMSUVEAction } from './public';
|
|
2
|
-
/**
|
|
3
|
-
* @description Custom client parameters for fetching data.
|
|
4
|
-
*/
|
|
5
|
-
export type DotCMSCustomerParams = {
|
|
6
|
-
depth: string;
|
|
7
|
-
};
|
|
8
|
-
/**
|
|
9
|
-
* Configuration for reordering a menu.
|
|
10
|
-
*/
|
|
11
|
-
export interface DotCMSReorderMenuConfig {
|
|
12
|
-
/**
|
|
13
|
-
* The starting level of the menu to be reordered.
|
|
14
|
-
*/
|
|
15
|
-
startLevel: number;
|
|
16
|
-
/**
|
|
17
|
-
* The depth of the menu levels to be reordered.
|
|
18
|
-
*/
|
|
19
|
-
depth: number;
|
|
20
|
-
}
|
|
21
|
-
declare global {
|
|
22
|
-
interface Window {
|
|
23
|
-
dotCMSUVE: DotCMSUVE;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Post message props
|
|
28
|
-
*
|
|
29
|
-
* @export
|
|
30
|
-
* @template T
|
|
31
|
-
* @interface DotCMSUVEMessage
|
|
32
|
-
*/
|
|
33
|
-
export type DotCMSUVEMessage<T> = {
|
|
34
|
-
action: DotCMSUVEAction;
|
|
35
|
-
payload?: T;
|
|
36
|
-
};
|
|
37
|
-
type DotCMSUVEFunction = (...args: any[]) => void;
|
|
38
|
-
export interface DotCMSUVE {
|
|
39
|
-
editContentlet: DotCMSUVEFunction;
|
|
40
|
-
initInlineEditing: DotCMSUVEFunction;
|
|
41
|
-
reorderMenu: DotCMSUVEFunction;
|
|
42
|
-
lastScrollYPosition: number;
|
|
43
|
-
}
|
|
44
|
-
export {};
|