@dotcms/types 0.0.1-beta.25
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 +29 -0
- package/index.cjs.d.ts +1 -0
- package/index.cjs.default.js +1 -0
- package/index.cjs.js +126 -0
- package/index.cjs.mjs +2 -0
- package/index.esm.d.ts +1 -0
- package/index.esm.js +123 -0
- package/internal.cjs.d.ts +1 -0
- package/internal.cjs.default.js +1 -0
- package/internal.cjs.js +75 -0
- package/internal.cjs.mjs +2 -0
- package/internal.esm.d.ts +1 -0
- package/internal.esm.js +75 -0
- package/package.json +39 -0
- package/src/index.d.ts +4 -0
- package/src/internal.d.ts +3 -0
- package/src/lib/components/block-editor-renderer/internal.d.ts +46 -0
- package/src/lib/components/block-editor-renderer/public.d.ts +38 -0
- package/src/lib/editor/internal.d.ts +103 -0
- package/src/lib/editor/public.d.ts +210 -0
- package/src/lib/events/internal.d.ts +34 -0
- package/src/lib/events/public.d.ts +18 -0
- package/src/lib/page/public.d.ts +1149 -0
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { DotCMSUVEAction } from './public';
|
|
2
|
+
/**
|
|
3
|
+
* Configuration for reordering a menu.
|
|
4
|
+
*/
|
|
5
|
+
export interface DotCMSReorderMenuConfig {
|
|
6
|
+
/**
|
|
7
|
+
* The starting level of the menu to be reordered.
|
|
8
|
+
*/
|
|
9
|
+
startLevel: number;
|
|
10
|
+
/**
|
|
11
|
+
* The depth of the menu levels to be reordered.
|
|
12
|
+
*/
|
|
13
|
+
depth: number;
|
|
14
|
+
}
|
|
15
|
+
declare global {
|
|
16
|
+
interface Window {
|
|
17
|
+
dotCMSUVE: DotCMSUVE;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Post message props
|
|
22
|
+
*
|
|
23
|
+
* @export
|
|
24
|
+
* @template T
|
|
25
|
+
* @interface DotCMSUVEMessage
|
|
26
|
+
*/
|
|
27
|
+
export type DotCMSUVEMessage<T> = {
|
|
28
|
+
action: DotCMSUVEAction;
|
|
29
|
+
payload?: T;
|
|
30
|
+
};
|
|
31
|
+
type DotCMSUVEFunction = (...args: any[]) => void;
|
|
32
|
+
export interface DotCMSUVE {
|
|
33
|
+
editContentlet: DotCMSUVEFunction;
|
|
34
|
+
initInlineEditing: DotCMSUVEFunction;
|
|
35
|
+
reorderMenu: DotCMSUVEFunction;
|
|
36
|
+
lastScrollYPosition: number;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Bound information for a contentlet.
|
|
40
|
+
*
|
|
41
|
+
* @interface ContentletBound
|
|
42
|
+
* Bound information for a contentlet.
|
|
43
|
+
*
|
|
44
|
+
* @interface DotCMSContentletBound
|
|
45
|
+
* @property {number} x - The x-coordinate of the contentlet.
|
|
46
|
+
* @property {number} y - The y-coordinate of the contentlet.
|
|
47
|
+
* @property {number} width - The width of the contentlet.
|
|
48
|
+
* @property {number} height - The height of the contentlet.
|
|
49
|
+
* @property {string} payload - The payload data of the contentlet in stringified JSON format.
|
|
50
|
+
*/
|
|
51
|
+
export interface DotCMSContentletBound {
|
|
52
|
+
x: number;
|
|
53
|
+
y: number;
|
|
54
|
+
width: number;
|
|
55
|
+
height: number;
|
|
56
|
+
payload: string;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Bound information for a container.
|
|
60
|
+
*
|
|
61
|
+
* @interface DotCMSContainerBound
|
|
62
|
+
* @property {number} x - The x-coordinate of the container.
|
|
63
|
+
* @property {number} y - The y-coordinate of the container.
|
|
64
|
+
* @property {number} width - The width of the container.
|
|
65
|
+
* @property {number} height - The height of the container.
|
|
66
|
+
* @property {string} payload - The payload data of the container in JSON format.
|
|
67
|
+
* @property {DotCMSContentletBound[]} contentlets - An array of contentlets within the container.
|
|
68
|
+
*/
|
|
69
|
+
export interface DotCMSContainerBound {
|
|
70
|
+
x: number;
|
|
71
|
+
y: number;
|
|
72
|
+
width: number;
|
|
73
|
+
height: number;
|
|
74
|
+
payload: string;
|
|
75
|
+
contentlets: DotCMSContentletBound[];
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
*
|
|
79
|
+
* Interface representing the data attributes of a DotCMS container.
|
|
80
|
+
* @interface DotContainerAttributes
|
|
81
|
+
*/
|
|
82
|
+
export interface DotContainerAttributes {
|
|
83
|
+
'data-dot-object': string;
|
|
84
|
+
'data-dot-accept-types': string;
|
|
85
|
+
'data-dot-identifier': string;
|
|
86
|
+
'data-max-contentlets': string;
|
|
87
|
+
'data-dot-uuid': string;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
*
|
|
91
|
+
* Interface representing the data attributes of a DotCMS contentlet.
|
|
92
|
+
* @interface DotContentletAttributes
|
|
93
|
+
*/
|
|
94
|
+
export interface DotContentletAttributes {
|
|
95
|
+
'data-dot-identifier': string;
|
|
96
|
+
'data-dot-basetype': string;
|
|
97
|
+
'data-dot-title': string;
|
|
98
|
+
'data-dot-inode': string;
|
|
99
|
+
'data-dot-type': string;
|
|
100
|
+
'data-dot-container': string;
|
|
101
|
+
'data-dot-on-number-of-pages': string;
|
|
102
|
+
}
|
|
103
|
+
export {};
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { DotCMSContainerBound } from './internal';
|
|
2
|
+
import { DotCMSBasicContentlet, DotCMSEditablePage } from '../page/public';
|
|
3
|
+
/**
|
|
4
|
+
* Development mode
|
|
5
|
+
*
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
export declare const DEVELOPMENT_MODE = "development";
|
|
9
|
+
/**
|
|
10
|
+
* Production mode
|
|
11
|
+
*
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
export declare const PRODUCTION_MODE = "production";
|
|
15
|
+
/**
|
|
16
|
+
* Represents the state of the Universal Visual Editor (UVE)
|
|
17
|
+
* @interface
|
|
18
|
+
* @property {UVE_MODE} mode - The current mode of operation for UVE (EDIT, PREVIEW, LIVE, or UNKNOWN)
|
|
19
|
+
* @property {string | null} persona - The selected persona for content personalization
|
|
20
|
+
* @property {string | null} variantName - The name of the current content variant
|
|
21
|
+
* @property {string | null} experimentId - The identifier for the current A/B testing experiment
|
|
22
|
+
* @property {string | null} publishDate - The scheduled publish date for content
|
|
23
|
+
* @property {string | null} languageId - The identifier for the current language selection
|
|
24
|
+
* @property {string | null} dotCMSHost - The host of the dotCMS instance
|
|
25
|
+
*/
|
|
26
|
+
export interface UVEState {
|
|
27
|
+
mode: UVE_MODE;
|
|
28
|
+
persona: string | null;
|
|
29
|
+
variantName: string | null;
|
|
30
|
+
experimentId: string | null;
|
|
31
|
+
publishDate: string | null;
|
|
32
|
+
languageId: string | null;
|
|
33
|
+
dotCMSHost: string | null;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The mode of the page renderer component
|
|
37
|
+
* @enum {string}
|
|
38
|
+
*/
|
|
39
|
+
export type DotCMSPageRendererMode = typeof PRODUCTION_MODE | typeof DEVELOPMENT_MODE;
|
|
40
|
+
/**
|
|
41
|
+
* Possible modes of UVE (Universal Visual Editor)
|
|
42
|
+
* @enum {string}
|
|
43
|
+
*
|
|
44
|
+
* @property {string} LIVE - Shows published and future content
|
|
45
|
+
* @property {string} PREVIEW - Shows published and working content
|
|
46
|
+
* @property {string} EDIT - Enables content editing functionality in UVE
|
|
47
|
+
* @property {string} UNKNOWN - Error state, UVE should not remain in this mode
|
|
48
|
+
*/
|
|
49
|
+
export declare enum UVE_MODE {
|
|
50
|
+
EDIT = "EDIT_MODE",
|
|
51
|
+
PREVIEW = "PREVIEW_MODE",
|
|
52
|
+
LIVE = "LIVE",
|
|
53
|
+
UNKNOWN = "UNKNOWN"
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Callback function for UVE events
|
|
57
|
+
* @callback UVEEventHandler
|
|
58
|
+
* @param {unknown} eventData - The event data
|
|
59
|
+
*/
|
|
60
|
+
export type UVEEventHandler<T = unknown> = (eventData?: T) => void;
|
|
61
|
+
/**
|
|
62
|
+
* Unsubscribe function for UVE events
|
|
63
|
+
* @callback UVEUnsubscribeFunction
|
|
64
|
+
*/
|
|
65
|
+
export type UVEUnsubscribeFunction = () => void;
|
|
66
|
+
/**
|
|
67
|
+
* UVE event subscription type
|
|
68
|
+
* @typedef {Object} UVEEventSubscription
|
|
69
|
+
* @property {UVEUnsubscribeFunction} unsubscribe - The unsubscribe function for the UVE event
|
|
70
|
+
* @property {string} event - The event name
|
|
71
|
+
*/
|
|
72
|
+
export type UVEEventSubscription = {
|
|
73
|
+
unsubscribe: UVEUnsubscribeFunction;
|
|
74
|
+
event: string;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* UVE event type
|
|
78
|
+
* @typedef {function} UVEEventSubscriber
|
|
79
|
+
*/
|
|
80
|
+
export type UVEEventSubscriber = (callback: UVEEventHandler) => UVEEventSubscription;
|
|
81
|
+
/**
|
|
82
|
+
* Actions send to the dotcms editor
|
|
83
|
+
*
|
|
84
|
+
* @export
|
|
85
|
+
* @enum {number}
|
|
86
|
+
*/
|
|
87
|
+
export declare enum DotCMSUVEAction {
|
|
88
|
+
/**
|
|
89
|
+
* Tell the dotcms editor that page change
|
|
90
|
+
*/
|
|
91
|
+
NAVIGATION_UPDATE = "set-url",
|
|
92
|
+
/**
|
|
93
|
+
* Send the element position of the rows, columnsm containers and contentlets
|
|
94
|
+
*/
|
|
95
|
+
SET_BOUNDS = "set-bounds",
|
|
96
|
+
/**
|
|
97
|
+
* Send the information of the hovered contentlet
|
|
98
|
+
*/
|
|
99
|
+
SET_CONTENTLET = "set-contentlet",
|
|
100
|
+
/**
|
|
101
|
+
* Tell the editor that the page is being scrolled
|
|
102
|
+
*/
|
|
103
|
+
IFRAME_SCROLL = "scroll",
|
|
104
|
+
/**
|
|
105
|
+
* Tell the editor that the page has stopped scrolling
|
|
106
|
+
*/
|
|
107
|
+
IFRAME_SCROLL_END = "scroll-end",
|
|
108
|
+
/**
|
|
109
|
+
* Ping the editor to see if the page is inside the editor
|
|
110
|
+
*/
|
|
111
|
+
PING_EDITOR = "ping-editor",
|
|
112
|
+
/**
|
|
113
|
+
* Tell the editor to init the inline editing editor.
|
|
114
|
+
*/
|
|
115
|
+
INIT_INLINE_EDITING = "init-inline-editing",
|
|
116
|
+
/**
|
|
117
|
+
* Tell the editor to open the Copy-contentlet dialog
|
|
118
|
+
* To copy a content and then edit it inline.
|
|
119
|
+
*/
|
|
120
|
+
COPY_CONTENTLET_INLINE_EDITING = "copy-contentlet-inline-editing",
|
|
121
|
+
/**
|
|
122
|
+
* Tell the editor to save inline edited contentlet
|
|
123
|
+
*/
|
|
124
|
+
UPDATE_CONTENTLET_INLINE_EDITING = "update-contentlet-inline-editing",
|
|
125
|
+
/**
|
|
126
|
+
* Tell the editor to trigger a menu reorder
|
|
127
|
+
*/
|
|
128
|
+
REORDER_MENU = "reorder-menu",
|
|
129
|
+
/**
|
|
130
|
+
* Tell the editor to send the page info to iframe
|
|
131
|
+
*/
|
|
132
|
+
GET_PAGE_DATA = "get-page-data",
|
|
133
|
+
/**
|
|
134
|
+
* Tell the editor an user send a graphql query
|
|
135
|
+
*/
|
|
136
|
+
CLIENT_READY = "client-ready",
|
|
137
|
+
/**
|
|
138
|
+
* Tell the editor to edit a contentlet
|
|
139
|
+
*/
|
|
140
|
+
EDIT_CONTENTLET = "edit-contentlet",
|
|
141
|
+
/**
|
|
142
|
+
* Tell the editor to do nothing
|
|
143
|
+
*/
|
|
144
|
+
NOOP = "noop"
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* The contentlet has the main fields and the custom fields of the content type.
|
|
148
|
+
*
|
|
149
|
+
* @template T - The custom fields of the content type.
|
|
150
|
+
*/
|
|
151
|
+
export type Contentlet<T> = T & DotCMSBasicContentlet;
|
|
152
|
+
/**
|
|
153
|
+
* Available events in the Universal Visual Editor
|
|
154
|
+
* @enum {string}
|
|
155
|
+
*/
|
|
156
|
+
export declare enum UVEEventType {
|
|
157
|
+
/**
|
|
158
|
+
* Triggered when page data changes from the editor
|
|
159
|
+
*/
|
|
160
|
+
CONTENT_CHANGES = "changes",
|
|
161
|
+
/**
|
|
162
|
+
* Triggered when the page needs to be reloaded
|
|
163
|
+
*/
|
|
164
|
+
PAGE_RELOAD = "page-reload",
|
|
165
|
+
/**
|
|
166
|
+
* Triggered when the editor requests container bounds
|
|
167
|
+
*/
|
|
168
|
+
REQUEST_BOUNDS = "request-bounds",
|
|
169
|
+
/**
|
|
170
|
+
* Triggered when scroll action is needed inside the iframe
|
|
171
|
+
*/
|
|
172
|
+
IFRAME_SCROLL = "iframe-scroll",
|
|
173
|
+
/**
|
|
174
|
+
* Triggered when a contentlet is hovered
|
|
175
|
+
*/
|
|
176
|
+
CONTENTLET_HOVERED = "contentlet-hovered"
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Type definitions for each event's payload
|
|
180
|
+
*/
|
|
181
|
+
export type UVEEventPayloadMap = {
|
|
182
|
+
[UVEEventType.CONTENT_CHANGES]: DotCMSEditablePage;
|
|
183
|
+
[UVEEventType.PAGE_RELOAD]: undefined;
|
|
184
|
+
[UVEEventType.REQUEST_BOUNDS]: DotCMSContainerBound[];
|
|
185
|
+
[UVEEventType.IFRAME_SCROLL]: 'up' | 'down';
|
|
186
|
+
[UVEEventType.CONTENTLET_HOVERED]: unknown;
|
|
187
|
+
};
|
|
188
|
+
/**
|
|
189
|
+
*
|
|
190
|
+
* Interface representing the data needed for container editing
|
|
191
|
+
* @interface EditableContainerData
|
|
192
|
+
*/
|
|
193
|
+
export interface EditableContainerData {
|
|
194
|
+
uuid: string;
|
|
195
|
+
identifier: string;
|
|
196
|
+
acceptTypes: string;
|
|
197
|
+
maxContentlets: number;
|
|
198
|
+
variantId?: string;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Configuration for the UVE
|
|
202
|
+
* @interface DotCMSUVEConfig
|
|
203
|
+
*/
|
|
204
|
+
export interface DotCMSUVEConfig {
|
|
205
|
+
graphql?: {
|
|
206
|
+
query: string;
|
|
207
|
+
variables: Record<string, unknown>;
|
|
208
|
+
};
|
|
209
|
+
params?: Record<string, unknown>;
|
|
210
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Actions received from the dotcms editor
|
|
3
|
+
*
|
|
4
|
+
* @export
|
|
5
|
+
* @enum {number}
|
|
6
|
+
*/
|
|
7
|
+
export declare enum __DOTCMS_UVE_EVENT__ {
|
|
8
|
+
/**
|
|
9
|
+
* Request to page to reload
|
|
10
|
+
*/
|
|
11
|
+
UVE_RELOAD_PAGE = "uve-reload-page",
|
|
12
|
+
/**
|
|
13
|
+
* Request the bounds for the elements
|
|
14
|
+
*/
|
|
15
|
+
UVE_REQUEST_BOUNDS = "uve-request-bounds",
|
|
16
|
+
/**
|
|
17
|
+
* Received pong from the editor
|
|
18
|
+
*/
|
|
19
|
+
UVE_EDITOR_PONG = "uve-editor-pong",
|
|
20
|
+
/**
|
|
21
|
+
* Received scroll event trigger from the editor
|
|
22
|
+
*/
|
|
23
|
+
UVE_SCROLL_INSIDE_IFRAME = "uve-scroll-inside-iframe",
|
|
24
|
+
/**
|
|
25
|
+
* TODO:
|
|
26
|
+
* Set the page data - This is used to catch the "changes" event.
|
|
27
|
+
* We must to re-check the name late.
|
|
28
|
+
*/
|
|
29
|
+
UVE_SET_PAGE_DATA = "uve-set-page-data",
|
|
30
|
+
/**
|
|
31
|
+
* Copy contentlet inline editing success
|
|
32
|
+
*/
|
|
33
|
+
UVE_COPY_CONTENTLET_INLINE_EDITING_SUCCESS = "uve-copy-contentlet-inline-editing-success"
|
|
34
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type DotCMSInlineEditingType = 'BLOCK_EDITOR' | 'WYSIWYG';
|
|
2
|
+
/**
|
|
3
|
+
* Interface representing the data needed for inline editing in DotCMS
|
|
4
|
+
*
|
|
5
|
+
* @interface DotCMSInlineEditorData
|
|
6
|
+
* @property {string} inode - The inode identifier of the content being edited
|
|
7
|
+
* @property {number} language - The language ID of the content
|
|
8
|
+
* @property {string} contentType - The content type identifier
|
|
9
|
+
* @property {string} fieldName - The name of the field being edited
|
|
10
|
+
* @property {Record<string, unknown>} content - The content data as key-value pairs
|
|
11
|
+
*/
|
|
12
|
+
export interface DotCMSInlineEditingPayload {
|
|
13
|
+
inode: string;
|
|
14
|
+
language: number;
|
|
15
|
+
contentType: string;
|
|
16
|
+
fieldName: string;
|
|
17
|
+
content: Record<string, unknown>;
|
|
18
|
+
}
|