@dotcms/uve 0.0.1-beta.10 → 0.0.1-beta.12
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 +92 -11
- package/index.esm.js +89 -12
- package/internal.cjs.js +360 -16
- package/internal.esm.js +354 -17
- package/package.json +1 -1
- package/src/index.d.ts +2 -1
- package/src/internal/constants.d.ts +3 -3
- package/src/internal/events.d.ts +66 -0
- package/src/internal.d.ts +1 -0
- package/src/lib/{utils.d.ts → core/core.utils.d.ts} +11 -7
- package/src/lib/dom/dom.utils.d.ts +111 -0
- package/src/lib/editor/internal.d.ts +8 -0
- package/src/lib/editor/public.d.ts +38 -0
- package/src/lib/types/editor/internal.d.ts +75 -0
- package/src/lib/types/editor/public.d.ts +55 -12
- package/src/lib/types/events/internal.d.ts +3 -1
- package/src/script/sdk-editor.d.ts +6 -0
- package/src/script/utils.d.ts +4 -0
- package/types.cjs.js +27 -0
- package/types.esm.js +28 -1
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { DotCMSReorderMenuConfig, DotCMSUVEMessage } from '../types/editor/internal';
|
|
2
|
+
import { Contentlet } 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 sendMessageToEditor<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;
|
|
@@ -41,4 +41,79 @@ export interface DotCMSUVE {
|
|
|
41
41
|
reorderMenu: DotCMSUVEFunction;
|
|
42
42
|
lastScrollYPosition: number;
|
|
43
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* Main fields of a Contentlet (Inherited from the Content Type).
|
|
46
|
+
*/
|
|
47
|
+
export interface ContentTypeMainFields {
|
|
48
|
+
hostName: string;
|
|
49
|
+
modDate: string;
|
|
50
|
+
publishDate: string;
|
|
51
|
+
title: string;
|
|
52
|
+
baseType: string;
|
|
53
|
+
inode: string;
|
|
54
|
+
archived: boolean;
|
|
55
|
+
ownerName: string;
|
|
56
|
+
host: string;
|
|
57
|
+
working: boolean;
|
|
58
|
+
locked: boolean;
|
|
59
|
+
stInode: string;
|
|
60
|
+
contentType: string;
|
|
61
|
+
live: boolean;
|
|
62
|
+
owner: string;
|
|
63
|
+
identifier: string;
|
|
64
|
+
publishUserName: string;
|
|
65
|
+
publishUser: string;
|
|
66
|
+
languageId: number;
|
|
67
|
+
creationDate: string;
|
|
68
|
+
url: string;
|
|
69
|
+
titleImage: string;
|
|
70
|
+
modUserName: string;
|
|
71
|
+
hasLiveVersion: boolean;
|
|
72
|
+
folder: string;
|
|
73
|
+
hasTitleImage: boolean;
|
|
74
|
+
sortOrder: number;
|
|
75
|
+
modUser: string;
|
|
76
|
+
__icon__: string;
|
|
77
|
+
contentTypeIcon: string;
|
|
78
|
+
variant: string;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Bound information for a contentlet.
|
|
82
|
+
*
|
|
83
|
+
* @interface ContentletBound
|
|
84
|
+
* Bound information for a contentlet.
|
|
85
|
+
*
|
|
86
|
+
* @interface DotCMSContentletBound
|
|
87
|
+
* @property {number} x - The x-coordinate of the contentlet.
|
|
88
|
+
* @property {number} y - The y-coordinate of the contentlet.
|
|
89
|
+
* @property {number} width - The width of the contentlet.
|
|
90
|
+
* @property {number} height - The height of the contentlet.
|
|
91
|
+
* @property {string} payload - The payload data of the contentlet in JSON format.
|
|
92
|
+
*/
|
|
93
|
+
export interface DotCMSContentletBound {
|
|
94
|
+
x: number;
|
|
95
|
+
y: number;
|
|
96
|
+
width: number;
|
|
97
|
+
height: number;
|
|
98
|
+
payload: string;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Bound information for a container.
|
|
102
|
+
*
|
|
103
|
+
* @interface DotCMSContainerBound
|
|
104
|
+
* @property {number} x - The x-coordinate of the container.
|
|
105
|
+
* @property {number} y - The y-coordinate of the container.
|
|
106
|
+
* @property {number} width - The width of the container.
|
|
107
|
+
* @property {number} height - The height of the container.
|
|
108
|
+
* @property {string} payload - The payload data of the container in JSON format.
|
|
109
|
+
* @property {DotCMSContentletBound[]} contentlets - An array of contentlets within the container.
|
|
110
|
+
*/
|
|
111
|
+
export interface DotCMSContainerBound {
|
|
112
|
+
x: number;
|
|
113
|
+
y: number;
|
|
114
|
+
width: number;
|
|
115
|
+
height: number;
|
|
116
|
+
payload: string;
|
|
117
|
+
contentlets: DotCMSContentletBound[];
|
|
118
|
+
}
|
|
44
119
|
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ContentTypeMainFields, DotCMSContainerBound } from './internal';
|
|
1
2
|
/**
|
|
2
3
|
* Represents the state of the Universal Visual Editor (UVE)
|
|
3
4
|
* @interface
|
|
@@ -33,30 +34,30 @@ export declare enum UVE_MODE {
|
|
|
33
34
|
}
|
|
34
35
|
/**
|
|
35
36
|
* Callback function for UVE events
|
|
36
|
-
* @callback
|
|
37
|
-
* @param {unknown}
|
|
37
|
+
* @callback UVEEventHandler
|
|
38
|
+
* @param {unknown} eventData - The event data
|
|
38
39
|
*/
|
|
39
|
-
export type
|
|
40
|
+
export type UVEEventHandler = (eventData?: unknown) => void;
|
|
40
41
|
/**
|
|
41
42
|
* Unsubscribe function for UVE events
|
|
42
|
-
* @callback
|
|
43
|
+
* @callback UVEUnsubscribeFunction
|
|
43
44
|
*/
|
|
44
|
-
export type
|
|
45
|
+
export type UVEUnsubscribeFunction = () => void;
|
|
45
46
|
/**
|
|
46
|
-
*
|
|
47
|
-
* @typedef {Object}
|
|
48
|
-
* @property {
|
|
47
|
+
* UVE event subscription type
|
|
48
|
+
* @typedef {Object} UVEEventSubscription
|
|
49
|
+
* @property {UVEUnsubscribeFunction} unsubscribe - The unsubscribe function for the UVE event
|
|
49
50
|
* @property {string} event - The event name
|
|
50
51
|
*/
|
|
51
|
-
export type
|
|
52
|
-
unsubscribe:
|
|
52
|
+
export type UVEEventSubscription = {
|
|
53
|
+
unsubscribe: UVEUnsubscribeFunction;
|
|
53
54
|
event: string;
|
|
54
55
|
};
|
|
55
56
|
/**
|
|
56
57
|
* UVE event type
|
|
57
|
-
* @typedef {function}
|
|
58
|
+
* @typedef {function} UVEEventSubscriber
|
|
58
59
|
*/
|
|
59
|
-
export type
|
|
60
|
+
export type UVEEventSubscriber = (callback: UVEEventHandler) => UVEEventSubscription;
|
|
60
61
|
/**
|
|
61
62
|
* Configuration type for DotCMS Editor
|
|
62
63
|
* @typedef {Object} DotCMSEditoConfig
|
|
@@ -136,3 +137,45 @@ export declare enum DotCMSUVEAction {
|
|
|
136
137
|
*/
|
|
137
138
|
NOOP = "noop"
|
|
138
139
|
}
|
|
140
|
+
/**
|
|
141
|
+
* The contentlet has the main fields and the custom fields of the content type.
|
|
142
|
+
*
|
|
143
|
+
* @template T - The custom fields of the content type.
|
|
144
|
+
*/
|
|
145
|
+
export type Contentlet<T> = T & ContentTypeMainFields;
|
|
146
|
+
/**
|
|
147
|
+
* Available events in the Universal Visual Editor
|
|
148
|
+
* @enum {string}
|
|
149
|
+
*/
|
|
150
|
+
export declare enum UVEEventType {
|
|
151
|
+
/**
|
|
152
|
+
* Triggered when page data changes from the editor
|
|
153
|
+
*/
|
|
154
|
+
CONTENT_CHANGES = "changes",
|
|
155
|
+
/**
|
|
156
|
+
* Triggered when the page needs to be reloaded
|
|
157
|
+
*/
|
|
158
|
+
PAGE_RELOAD = "page-reload",
|
|
159
|
+
/**
|
|
160
|
+
* Triggered when the editor requests container bounds
|
|
161
|
+
*/
|
|
162
|
+
REQUEST_BOUNDS = "request-bounds",
|
|
163
|
+
/**
|
|
164
|
+
* Triggered when scroll action is needed inside the iframe
|
|
165
|
+
*/
|
|
166
|
+
IFRAME_SCROLL = "iframe-scroll",
|
|
167
|
+
/**
|
|
168
|
+
* Triggered when a contentlet is hovered
|
|
169
|
+
*/
|
|
170
|
+
CONTENTLET_HOVERED = "contentlet-hovered"
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Type definitions for each event's payload
|
|
174
|
+
*/
|
|
175
|
+
export type UVEEventPayloadMap = {
|
|
176
|
+
[UVEEventType.CONTENT_CHANGES]: unknown;
|
|
177
|
+
[UVEEventType.PAGE_RELOAD]: undefined;
|
|
178
|
+
[UVEEventType.REQUEST_BOUNDS]: DotCMSContainerBound[];
|
|
179
|
+
[UVEEventType.IFRAME_SCROLL]: 'up' | 'down';
|
|
180
|
+
[UVEEventType.CONTENTLET_HOVERED]: unknown;
|
|
181
|
+
};
|
|
@@ -22,7 +22,9 @@ export declare enum __DOTCMS_UVE_EVENT__ {
|
|
|
22
22
|
*/
|
|
23
23
|
UVE_SCROLL_INSIDE_IFRAME = "uve-scroll-inside-iframe",
|
|
24
24
|
/**
|
|
25
|
-
*
|
|
25
|
+
* TODO:
|
|
26
|
+
* Set the page data - This is used to catch the "changes" event.
|
|
27
|
+
* We must to re-check the name late.
|
|
26
28
|
*/
|
|
27
29
|
UVE_SET_PAGE_DATA = "uve-set-page-data",
|
|
28
30
|
/**
|
package/types.cjs.js
CHANGED
|
@@ -82,3 +82,30 @@ exports.DotCMSUVEAction = void 0;
|
|
|
82
82
|
*/
|
|
83
83
|
DotCMSUVEAction["NOOP"] = "noop";
|
|
84
84
|
})(exports.DotCMSUVEAction || (exports.DotCMSUVEAction = {}));
|
|
85
|
+
/**
|
|
86
|
+
* Available events in the Universal Visual Editor
|
|
87
|
+
* @enum {string}
|
|
88
|
+
*/
|
|
89
|
+
exports.UVEEventType = void 0;
|
|
90
|
+
(function (UVEEventType) {
|
|
91
|
+
/**
|
|
92
|
+
* Triggered when page data changes from the editor
|
|
93
|
+
*/
|
|
94
|
+
UVEEventType["CONTENT_CHANGES"] = "changes";
|
|
95
|
+
/**
|
|
96
|
+
* Triggered when the page needs to be reloaded
|
|
97
|
+
*/
|
|
98
|
+
UVEEventType["PAGE_RELOAD"] = "page-reload";
|
|
99
|
+
/**
|
|
100
|
+
* Triggered when the editor requests container bounds
|
|
101
|
+
*/
|
|
102
|
+
UVEEventType["REQUEST_BOUNDS"] = "request-bounds";
|
|
103
|
+
/**
|
|
104
|
+
* Triggered when scroll action is needed inside the iframe
|
|
105
|
+
*/
|
|
106
|
+
UVEEventType["IFRAME_SCROLL"] = "iframe-scroll";
|
|
107
|
+
/**
|
|
108
|
+
* Triggered when a contentlet is hovered
|
|
109
|
+
*/
|
|
110
|
+
UVEEventType["CONTENTLET_HOVERED"] = "contentlet-hovered";
|
|
111
|
+
})(exports.UVEEventType || (exports.UVEEventType = {}));
|
package/types.esm.js
CHANGED
|
@@ -80,5 +80,32 @@ var DotCMSUVEAction;
|
|
|
80
80
|
*/
|
|
81
81
|
DotCMSUVEAction["NOOP"] = "noop";
|
|
82
82
|
})(DotCMSUVEAction || (DotCMSUVEAction = {}));
|
|
83
|
+
/**
|
|
84
|
+
* Available events in the Universal Visual Editor
|
|
85
|
+
* @enum {string}
|
|
86
|
+
*/
|
|
87
|
+
var UVEEventType;
|
|
88
|
+
(function (UVEEventType) {
|
|
89
|
+
/**
|
|
90
|
+
* Triggered when page data changes from the editor
|
|
91
|
+
*/
|
|
92
|
+
UVEEventType["CONTENT_CHANGES"] = "changes";
|
|
93
|
+
/**
|
|
94
|
+
* Triggered when the page needs to be reloaded
|
|
95
|
+
*/
|
|
96
|
+
UVEEventType["PAGE_RELOAD"] = "page-reload";
|
|
97
|
+
/**
|
|
98
|
+
* Triggered when the editor requests container bounds
|
|
99
|
+
*/
|
|
100
|
+
UVEEventType["REQUEST_BOUNDS"] = "request-bounds";
|
|
101
|
+
/**
|
|
102
|
+
* Triggered when scroll action is needed inside the iframe
|
|
103
|
+
*/
|
|
104
|
+
UVEEventType["IFRAME_SCROLL"] = "iframe-scroll";
|
|
105
|
+
/**
|
|
106
|
+
* Triggered when a contentlet is hovered
|
|
107
|
+
*/
|
|
108
|
+
UVEEventType["CONTENTLET_HOVERED"] = "contentlet-hovered";
|
|
109
|
+
})(UVEEventType || (UVEEventType = {}));
|
|
83
110
|
|
|
84
|
-
export { DotCMSUVEAction, UVE_MODE };
|
|
111
|
+
export { DotCMSUVEAction, UVEEventType, UVE_MODE };
|