@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.
@@ -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 UVECallback
37
- * @param {unknown} payload - The payload of the event
37
+ * @callback UVEEventHandler
38
+ * @param {unknown} eventData - The event data
38
39
  */
39
- export type UVECallback = (payload: unknown) => void;
40
+ export type UVEEventHandler = (eventData?: unknown) => void;
40
41
  /**
41
42
  * Unsubscribe function for UVE events
42
- * @callback UnsubscribeUVE
43
+ * @callback UVEUnsubscribeFunction
43
44
  */
44
- export type UnsubscribeUVE = () => void;
45
+ export type UVEUnsubscribeFunction = () => void;
45
46
  /**
46
- * UVESubscription type
47
- * @typedef {Object} UVESubscription
48
- * @property {UnsubscribeUVE} unsubscribe - The unsubscribe function for the UVE event
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 UVESubscription = {
52
- unsubscribe: UnsubscribeUVE;
52
+ export type UVEEventSubscription = {
53
+ unsubscribe: UVEUnsubscribeFunction;
53
54
  event: string;
54
55
  };
55
56
  /**
56
57
  * UVE event type
57
- * @typedef {function} UVEEvent
58
+ * @typedef {function} UVEEventSubscriber
58
59
  */
59
- export type UVEEvent = (callback: UVECallback) => UVESubscription;
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
- * Set the page data
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
  /**
@@ -0,0 +1,6 @@
1
+ declare global {
2
+ interface Window {
3
+ dotUVE: unknown;
4
+ }
5
+ }
6
+ export {};
@@ -0,0 +1,4 @@
1
+ export declare function scrollHandler(): void;
2
+ export declare function addClassToEmptyContentlets(): void;
3
+ export declare function registerUVEEvents(): void;
4
+ export declare function setClientIsReady(): void;
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 };