@dotcms/client 0.0.1-alpha.9 → 0.0.1-beta.2

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 (54) hide show
  1. package/README.md +166 -19
  2. package/index.cjs.d.ts +1 -0
  3. package/index.cjs.default.js +1 -0
  4. package/index.cjs.js +2050 -0
  5. package/index.cjs.mjs +2 -0
  6. package/index.esm.d.ts +1 -0
  7. package/index.esm.js +2038 -0
  8. package/package.json +36 -25
  9. package/src/index.d.ts +8 -0
  10. package/src/lib/client/content/builders/collection/collection.d.ts +226 -0
  11. package/src/lib/client/content/content-api.d.ts +129 -0
  12. package/src/lib/client/content/shared/const.d.ts +13 -0
  13. package/src/lib/client/content/shared/types.d.ts +138 -0
  14. package/src/lib/client/content/shared/utils.d.ts +20 -0
  15. package/src/lib/client/models/index.d.ts +12 -0
  16. package/src/lib/client/models/types.d.ts +13 -0
  17. package/src/lib/client/sdk-js-client.d.ts +276 -0
  18. package/src/lib/editor/listeners/listeners.d.ts +45 -0
  19. package/src/lib/editor/models/client.model.d.ts +98 -0
  20. package/src/lib/editor/models/editor.model.d.ts +62 -0
  21. package/src/lib/editor/models/inline-event.model.d.ts +9 -0
  22. package/src/lib/editor/models/{listeners.model.ts → listeners.model.d.ts} +17 -8
  23. package/src/lib/editor/sdk-editor-vtl.d.ts +1 -0
  24. package/src/lib/editor/sdk-editor.d.ts +92 -0
  25. package/src/lib/editor/utils/editor.utils.d.ts +159 -0
  26. package/src/lib/editor/utils/traditional-vtl.utils.d.ts +4 -0
  27. package/src/lib/query-builder/lucene-syntax/Equals.d.ts +114 -0
  28. package/src/lib/query-builder/lucene-syntax/Field.d.ts +32 -0
  29. package/src/lib/query-builder/lucene-syntax/NotOperand.d.ts +26 -0
  30. package/src/lib/query-builder/lucene-syntax/Operand.d.ts +44 -0
  31. package/src/lib/query-builder/lucene-syntax/index.d.ts +4 -0
  32. package/src/lib/query-builder/sdk-query-builder.d.ts +76 -0
  33. package/src/lib/query-builder/utils/index.d.ts +142 -0
  34. package/src/lib/utils/graphql/transforms.d.ts +24 -0
  35. package/src/lib/utils/index.d.ts +2 -0
  36. package/src/lib/utils/page/common-utils.d.ts +33 -0
  37. package/.eslintrc.json +0 -18
  38. package/jest.config.ts +0 -15
  39. package/project.json +0 -63
  40. package/src/index.ts +0 -4
  41. package/src/lib/client/sdk-js-client.spec.ts +0 -258
  42. package/src/lib/client/sdk-js-client.ts +0 -297
  43. package/src/lib/editor/listeners/listeners.spec.ts +0 -55
  44. package/src/lib/editor/listeners/listeners.ts +0 -200
  45. package/src/lib/editor/models/client.model.ts +0 -55
  46. package/src/lib/editor/models/editor.model.ts +0 -17
  47. package/src/lib/editor/sdk-editor-vtl.ts +0 -24
  48. package/src/lib/editor/sdk-editor.spec.ts +0 -95
  49. package/src/lib/editor/sdk-editor.ts +0 -70
  50. package/src/lib/editor/utils/editor.utils.spec.ts +0 -164
  51. package/src/lib/editor/utils/editor.utils.ts +0 -151
  52. package/tsconfig.json +0 -22
  53. package/tsconfig.lib.json +0 -10
  54. package/tsconfig.spec.json +0 -9
@@ -0,0 +1,276 @@
1
+ import { Content } from './content/content-api';
2
+ export type ClientOptions = Omit<RequestInit, 'body' | 'method'>;
3
+ export interface ClientConfig {
4
+ /**
5
+ * The URL of the dotCMS instance.
6
+ *
7
+ * @description This is the URL of the dotCMS instance you want to interact with. Ensure to include the protocol (http or https).
8
+ * @example `https://demo.dotcms.com`
9
+ * @type {string}
10
+ * @required
11
+ */
12
+ dotcmsUrl: string;
13
+ /**
14
+ * The id of the site you want to interact with. If not provided, it will use the default site.
15
+ *
16
+ * More information here: {@link https://www.dotcms.com/docs/latest/multi-site-management}
17
+ *
18
+ * @description To get the site id, go to the site you want to interact with and copy the id from the History tab.
19
+ * @type {string}
20
+ * @optional
21
+ */
22
+ siteId?: string;
23
+ /**
24
+ * The authentication token to use for the requests.
25
+ *
26
+ * @description You can get the auth token from our UI {@link https://www.dotcms.com/docs/latest/rest-api-authentication#creating-an-api-token-in-the-ui}
27
+ * @type {string}
28
+ * @required
29
+ */
30
+ authToken: string;
31
+ /**
32
+ * Additional options to pass to the fetch request.
33
+ *
34
+ * @description These options will be used in the fetch request. Any option can be specified except for 'body' and 'method' which are omitted.
35
+ * @example `{ headers: { 'Content-Type': 'application/json' } }`
36
+ * @type {ClientOptions}
37
+ * @optional
38
+ */
39
+ requestOptions?: ClientOptions;
40
+ }
41
+ export type PageApiOptions = {
42
+ /**
43
+ * The path of the page you want to retrieve.
44
+ * @type {string}
45
+ */
46
+ path: string;
47
+ /**
48
+ * The id of the site you want to interact with. If not provided, the one from the config will be used.
49
+ *
50
+ * More information here: {@link https://www.dotcms.com/docs/latest/multi-site-management}
51
+ * @type {string}
52
+ * @optional
53
+ */
54
+ siteId?: string;
55
+ /**
56
+ * The mode of the page you want to retrieve. If not provided, will use the default mode of the site.
57
+ *
58
+ * More information here: {@link https://www.dotcms.com/docs/latest/page-viewing-modes}
59
+ * @type {string}
60
+ * @optional
61
+ */
62
+ mode?: 'EDIT_MODE' | 'PREVIEW_MODE' | 'LIVE';
63
+ /**
64
+ * The language id of the page you want to retrieve. If not provided, will use the default language of the site.
65
+ * @type {number}
66
+ * @optional
67
+ */
68
+ language_id?: number;
69
+ /**
70
+ * The id of the persona you want to retrieve the page for.
71
+ *
72
+ * More information here: {@link https://www.dotcms.com/docs/latest/personas}
73
+ * @type {string}
74
+ * @optional
75
+ */
76
+ personaId?: string;
77
+ /**
78
+ * If you want to fire the rules set on the page.
79
+ *
80
+ * More information here: {@link https://www.dotcms.com/docs/latest/adding-rules-to-pages}
81
+ *
82
+ * @type {boolean}
83
+ * @optional
84
+ */
85
+ fireRules?: boolean;
86
+ /**
87
+ * Allows access to related content via the Relationship fields of contentlets on a Page; 0 (default).
88
+ * @type {number}
89
+ * @optional
90
+ */
91
+ depth?: number;
92
+ };
93
+ type NavApiOptions = {
94
+ /**
95
+ * The root path to begin traversing the folder tree.
96
+ * @example
97
+ * `/api/v1/nav/` starts from the root of the site
98
+ * @example
99
+ * `/about-us` starts from the "About Us" folder
100
+ * @type {string}
101
+ */
102
+ path: string;
103
+ /**
104
+ * The depth of the folder tree to return.
105
+ * @example
106
+ * `1` returns only the element specified in the path.
107
+ * @example
108
+ * `2` returns the element specified in the path, and if that element is a folder, returns all direct children of that folder.
109
+ * @example
110
+ * `3` returns all children and grandchildren of the element specified in the path.
111
+ * @type {number}
112
+ * @optional
113
+ */
114
+ depth?: number;
115
+ /**
116
+ * The language ID of content to return.
117
+ * @example
118
+ * `1` (or unspecified) returns content in the default language of the site.
119
+ * @link https://www.dotcms.com/docs/latest/system-language-properties#DefaultLanguage
120
+ * @link https://www.dotcms.com/docs/latest/adding-and-editing-languages#LanguageID
121
+ * @type {number}
122
+ * @optional
123
+ */
124
+ languageId?: number;
125
+ };
126
+ /**
127
+ * `DotCmsClient` is a TypeScript class that provides methods to interact with the DotCMS REST API.
128
+ * DotCMS is a hybrid-headless CMS and digital experience platform.
129
+ *
130
+ * @class DotCmsClient
131
+ * @property {ClientConfig} config - The configuration object for the DotCMS client.
132
+ * @property {Content} content - Provides methods to interact with content in DotCMS.
133
+ *
134
+ * @method constructor(config: ClientConfig) - Constructs a new instance of the DotCmsClient class.
135
+ *
136
+ * @method page.get(options: PageApiOptions): Promise<PageApiResponse> - Retrieves all the elements of any Page in your dotCMS system in JSON format.
137
+ * The Page API enables you to retrieve page information, layout, template, content blocks, and more.
138
+ * @see {@link https://www.dotcms.com/docs/latest/page-rest-api-layout-as-a-service-laas}
139
+ *
140
+ * @method nav.get(options: NavApiOptions = { depth: 0, path: '/', languageId: 1 }): Promise<NavApiResponse> - Retrieves information about the dotCMS file and folder tree.
141
+ * The Navigation API allows you to fetch the site structure and menu items.
142
+ * @see {@link https://www.dotcms.com/docs/latest/navigation-rest-api}
143
+ *
144
+ * @method content.get(options: ContentApiOptions): Promise<ContentApiResponse> - Retrieves content items based on specified criteria.
145
+ * The Content API allows you to query and retrieve content by ID, inode, or using Lucene queries.
146
+ * @see {@link https://www.dotcms.com/docs/latest/content-api-retrieval-and-querying}
147
+ *
148
+ * @method editor.on(action: string, callbackFn: (payload: unknown) => void) - Allows you to react to actions issued by the Universal Visual Editor (UVE).
149
+ * @method editor.off(action: string) - Stops listening to an action issued by UVE.
150
+ *
151
+ * @static
152
+ * @method init(config: ClientConfig): DotCmsClient - Initializes and returns a DotCmsClient instance.
153
+ * @method dotcmsUrl: string - Retrieves the DotCMS URL from the instance configuration.
154
+ *
155
+ * @example <caption>Basic usage</caption>
156
+ * ```javascript
157
+ * const client = DotCmsClient.init({ dotcmsUrl: 'https://demo.dotcms.com', authToken: 'your-auth-token' });
158
+ *
159
+ * // Get a page
160
+ * client.page.get({ path: '/about-us' }).then(response => console.log(response));
161
+ *
162
+ * // Get navigation
163
+ * client.nav.get({ path: '/about-us', depth: 2 }).then(response => console.log(response));
164
+ *
165
+ * // Get content
166
+ * client.content.get({ query: '+contentType:Blog +languageId:1', limit: 10 }).then(response => console.log(response));
167
+ *
168
+ * // Listen to editor changes
169
+ * client.editor.on('changes', (payload) => console.log('Changes detected:', payload));
170
+ * ```
171
+ */
172
+ export declare class DotCmsClient {
173
+ #private;
174
+ static instance: DotCmsClient;
175
+ dotcmsUrl?: string;
176
+ content: Content;
177
+ constructor(config?: ClientConfig);
178
+ page: {
179
+ /**
180
+ * `page.get` is an asynchronous method of the `DotCmsClient` class that retrieves all the elements of any Page in your dotCMS system in JSON format.
181
+ * It takes a `PageApiOptions` object as a parameter and returns a Promise that resolves to the response from the DotCMS API.
182
+ *
183
+ * The Page API enables you to retrieve all the elements of any Page in your dotCMS system.
184
+ * The elements may be retrieved in JSON format.
185
+ *
186
+ * @link https://www.dotcms.com/docs/latest/page-rest-api-layout-as-a-service-laas
187
+ * @async
188
+ * @param {PageApiOptions} options - The options for the Page API call.
189
+ * @returns {Promise<unknown>} - A Promise that resolves to the response from the DotCMS API.
190
+ * @throws {Error} - Throws an error if the options are not valid.
191
+ * @example
192
+ * ```ts
193
+ * const client = new DotCmsClient({ dotcmsUrl: 'https://your.dotcms.com', authToken: 'your-auth-token', siteId: 'your-site-id' });
194
+ * client.page.get({ path: '/about-us' }).then(response => console.log(response));
195
+ * ```
196
+ */
197
+ get: (options: PageApiOptions) => Promise<unknown>;
198
+ };
199
+ editor: {
200
+ /**
201
+ * `editor.on` is an asynchronous method of the `DotCmsClient` class that allows you to react to actions issued by the UVE.
202
+ *
203
+ * NOTE: This is being used by the development team - This logic is probably varied or moved to another function/object.
204
+ * @param {string} action - The name of the action emitted by UVE.
205
+ * @param {function} callbackFn - The function to execute when the UVE emits the action.
206
+ * @example
207
+ * ```ts
208
+ * client.editor.on('changes', (payload) => {
209
+ * console.log('Changes detected:', payload);
210
+ * });
211
+ * ```
212
+ */
213
+ on: (action: string, callbackFn: (payload: unknown) => void) => void;
214
+ /**
215
+ * `editor.off` is a synchronous method of the `DotCmsClient` class that allows you to stop listening and reacting to an action issued by UVE.
216
+ *
217
+ * NOTE: This is being used by the development team - This logic is probably varied or moved to another function/object.
218
+ * @param {string} action - The name of the action to stop listening to.
219
+ * @example
220
+ * ```ts
221
+ * client.editor.off('changes');
222
+ * ```
223
+ */
224
+ off: (action: string) => void;
225
+ };
226
+ nav: {
227
+ /**
228
+ * `nav.get` is an asynchronous method of the `DotCmsClient` class that retrieves information about the dotCMS file and folder tree.
229
+ * It takes a `NavApiOptions` object as a parameter (with default values) and returns a Promise that resolves to the response from the DotCMS API.
230
+ *
231
+ * The navigation REST API enables you to retrieve information about the dotCMS file and folder tree through REST API calls.
232
+ * @link https://www.dotcms.com/docs/latest/navigation-rest-api
233
+ * @async
234
+ * @param {NavApiOptions} options - The options for the Nav API call. Defaults to `{ depth: 0, path: '/', languageId: 1 }`.
235
+ * @returns {Promise<unknown>} - A Promise that resolves to the response from the DotCMS API.
236
+ * @throws {Error} - Throws an error if the options are not valid.
237
+ * @example
238
+ * ```ts
239
+ * const client = new DotCmsClient({ dotcmsUrl: 'https://your.dotcms.com', authToken: 'your-auth-token', siteId: 'your-site-id' }});
240
+ * client.nav.get({ path: '/about-us', depth: 2 }).then(response => console.log(response));
241
+ * ```
242
+ */
243
+ get: (options?: NavApiOptions) => Promise<unknown>;
244
+ };
245
+ /**
246
+ * Initializes the DotCmsClient instance with the provided configuration.
247
+ * If an instance already exists, it returns the existing instance.
248
+ *
249
+ * @param {ClientConfig} config - The configuration object for the DotCMS client.
250
+ * @returns {DotCmsClient} - The initialized DotCmsClient instance.
251
+ * @example
252
+ * ```ts
253
+ * const client = DotCmsClient.init({ dotcmsUrl: 'https://demo.dotcms.com', authToken: 'your-auth-token' });
254
+ * ```
255
+ */
256
+ static init(config: ClientConfig): DotCmsClient;
257
+ /**
258
+ * Retrieves the DotCMS URL from the instance configuration.
259
+ *
260
+ * @returns {string} - The DotCMS URL.
261
+ */
262
+ static get dotcmsUrl(): string;
263
+ /**
264
+ * Throws an error if the path is not valid.
265
+ *
266
+ * @returns {string} - The authentication token.
267
+ */
268
+ private validatePageOptions;
269
+ /**
270
+ * Throws an error if the path is not valid.
271
+ *
272
+ * @returns {string} - The authentication token.
273
+ */
274
+ private validateNavOptions;
275
+ }
276
+ export {};
@@ -0,0 +1,45 @@
1
+ import { DotCMSPageEditorSubscription } from '../models/listeners.model';
2
+ /**
3
+ * Represents an array of DotCMSPageEditorSubscription objects.
4
+ * Used to store the subscriptions for the editor and unsubscribe later.
5
+ */
6
+ export declare const subscriptions: DotCMSPageEditorSubscription[];
7
+ /**
8
+ * Listens for editor messages and performs corresponding actions based on the received message.
9
+ *
10
+ * @private
11
+ * @memberof DotCMSPageEditor
12
+ */
13
+ export declare function listenEditorMessages(): void;
14
+ /**
15
+ * Listens for pointer move events and extracts information about the hovered contentlet.
16
+ *
17
+ * @private
18
+ * @memberof DotCMSPageEditor
19
+ */
20
+ export declare function listenHoveredContentlet(): void;
21
+ /**
22
+ * Attaches a scroll event listener to the window
23
+ * and sends a message to the editor when the window is scrolled.
24
+ *
25
+ * @private
26
+ * @memberof DotCMSPageEditor
27
+ */
28
+ export declare function scrollHandler(): void;
29
+ /**
30
+ * Restores the scroll position of the window when an iframe is loaded.
31
+ * Only used in VTL Pages.
32
+ * @export
33
+ * @example
34
+ * ```ts
35
+ * preserveScrollOnIframe();
36
+ * ```
37
+ */
38
+ export declare function preserveScrollOnIframe(): void;
39
+ /**
40
+ * Sends a message to the editor to get the page data.
41
+ * @param {string} pathname - The pathname of the page.
42
+ * @private
43
+ * @memberof DotCMSPageEditor
44
+ */
45
+ export declare function fetchPageDataFromInsideUVE(pathname: string): void;
@@ -0,0 +1,98 @@
1
+ import { editContentlet, initInlineEditing, reorderMenu } from '../sdk-editor';
2
+ declare global {
3
+ interface Window {
4
+ dotUVE: DotUVE;
5
+ }
6
+ }
7
+ export declare const INITIAL_DOT_UVE: DotUVE;
8
+ /**
9
+ * Actions send to the dotcms editor
10
+ *
11
+ * @export
12
+ * @enum {number}
13
+ */
14
+ export declare enum CLIENT_ACTIONS {
15
+ /**
16
+ * Tell the dotcms editor that page change
17
+ */
18
+ NAVIGATION_UPDATE = "set-url",
19
+ /**
20
+ * Send the element position of the rows, columnsm containers and contentlets
21
+ */
22
+ SET_BOUNDS = "set-bounds",
23
+ /**
24
+ * Send the information of the hovered contentlet
25
+ */
26
+ SET_CONTENTLET = "set-contentlet",
27
+ /**
28
+ * Tell the editor that the page is being scrolled
29
+ */
30
+ IFRAME_SCROLL = "scroll",
31
+ /**
32
+ * Tell the editor that the page has stopped scrolling
33
+ */
34
+ IFRAME_SCROLL_END = "scroll-end",
35
+ /**
36
+ * Ping the editor to see if the page is inside the editor
37
+ */
38
+ PING_EDITOR = "ping-editor",
39
+ /**
40
+ * Tell the editor to init the inline editing editor.
41
+ */
42
+ INIT_INLINE_EDITING = "init-inline-editing",
43
+ /**
44
+ * Tell the editor to open the Copy-contentlet dialog
45
+ * To copy a content and then edit it inline.
46
+ */
47
+ COPY_CONTENTLET_INLINE_EDITING = "copy-contentlet-inline-editing",
48
+ /**
49
+ * Tell the editor to save inline edited contentlet
50
+ */
51
+ UPDATE_CONTENTLET_INLINE_EDITING = "update-contentlet-inline-editing",
52
+ /**
53
+ * Tell the editor to trigger a menu reorder
54
+ */
55
+ REORDER_MENU = "reorder-menu",
56
+ /**
57
+ * Tell the editor to send the page info to iframe
58
+ */
59
+ GET_PAGE_DATA = "get-page-data",
60
+ /**
61
+ * Tell the editor an user send a graphql query
62
+ */
63
+ CLIENT_READY = "client-ready",
64
+ /**
65
+ * Tell the editor to edit a contentlet
66
+ */
67
+ EDIT_CONTENTLET = "edit-contentlet",
68
+ /**
69
+ * Tell the editor to do nothing
70
+ */
71
+ NOOP = "noop"
72
+ }
73
+ /**
74
+ * Post message props
75
+ *
76
+ * @export
77
+ * @template T
78
+ * @interface PostMessageProps
79
+ */
80
+ type PostMessageProps<T> = {
81
+ action: CLIENT_ACTIONS;
82
+ payload?: T;
83
+ };
84
+ /**
85
+ * Post message to dotcms page editor
86
+ *
87
+ * @export
88
+ * @template T
89
+ * @param {PostMessageProps<T>} message
90
+ */
91
+ export declare function postMessageToEditor<T = unknown>(message: PostMessageProps<T>): void;
92
+ export interface DotUVE {
93
+ editContentlet: typeof editContentlet;
94
+ initInlineEditing: typeof initInlineEditing;
95
+ reorderMenu: typeof reorderMenu;
96
+ lastScrollYPosition: number;
97
+ }
98
+ export {};
@@ -0,0 +1,62 @@
1
+ /**
2
+ * @description Custom client parameters for fetching data.
3
+ */
4
+ export type CustomClientParams = {
5
+ depth: string;
6
+ };
7
+ /**
8
+ * @description Union type for fetch configurations.
9
+ * @typedef {GraphQLFetchConfig | PageAPIFetchConfig} DotCMSFetchConfig
10
+ */
11
+ export type EditorConfig = {
12
+ params: CustomClientParams;
13
+ } | {
14
+ query: string;
15
+ };
16
+ /**
17
+ * Represents the configuration options for the DotCMS page editor.
18
+ * @export
19
+ * @interface DotCMSPageEditorConfig
20
+ */
21
+ export interface DotCMSPageEditorConfig {
22
+ /**
23
+ * The pathname of the page being edited. Optional.
24
+ * @type {string}
25
+ */
26
+ pathname: string;
27
+ /**
28
+ *
29
+ * @type {DotCMSFetchConfig}
30
+ * @memberof DotCMSPageEditorConfig
31
+ * @description The configuration custom params for data fetching on Edit Mode.
32
+ * @example <caption>Example with Custom GraphQL query</caption>
33
+ * const config: DotCMSPageEditorConfig = {
34
+ * editor: { query: 'query { ... }' }
35
+ * };
36
+ *
37
+ * @example <caption>Example usage with Custom Page API parameters</caption>
38
+ * const config: DotCMSPageEditorConfig = {
39
+ * editor: { params: { depth: '2' } }
40
+ * };
41
+ */
42
+ editor?: EditorConfig;
43
+ /**
44
+ * The reload function to call when the page is reloaded.
45
+ * @deprecated In future implementation we will be listening for the changes from the editor to update the page state so reload will not be needed.
46
+ * @type {Function}
47
+ */
48
+ onReload?: () => void;
49
+ }
50
+ /**
51
+ * Configuration for reordering a menu.
52
+ */
53
+ export interface ReorderMenuConfig {
54
+ /**
55
+ * The starting level of the menu to be reordered.
56
+ */
57
+ startLevel: number;
58
+ /**
59
+ * The depth of the menu levels to be reordered.
60
+ */
61
+ depth: number;
62
+ }
@@ -0,0 +1,9 @@
1
+ export type INLINE_EDITING_EVENT_KEY = 'BLOCK_EDITOR' | 'WYSIWYG';
2
+ export interface InlineEditorData {
3
+ inode: string;
4
+ language: number;
5
+ contentType: string;
6
+ fieldName: string;
7
+ content: Record<string, unknown>;
8
+ }
9
+ export type InlineEditEventData = InlineEditorData;
@@ -4,24 +4,34 @@
4
4
  * @export
5
5
  * @enum {number}
6
6
  */
7
- export enum NOTIFY_CUSTOMER {
7
+ export declare enum NOTIFY_CLIENT {
8
8
  /**
9
9
  * Request to page to reload
10
10
  */
11
- EMA_RELOAD_PAGE = 'ema-reload-page',
11
+ UVE_RELOAD_PAGE = "uve-reload-page",
12
12
  /**
13
13
  * Request the bounds for the elements
14
14
  */
15
- EMA_REQUEST_BOUNDS = 'ema-request-bounds',
15
+ UVE_REQUEST_BOUNDS = "uve-request-bounds",
16
16
  /**
17
17
  * Received pong from the editor
18
18
  */
19
- EMA_EDITOR_PONG = 'ema-editor-pong'
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
+ * Set the page data
26
+ */
27
+ UVE_SET_PAGE_DATA = "uve-set-page-data",
28
+ /**
29
+ * Copy contentlet inline editing success
30
+ */
31
+ UVE_COPY_CONTENTLET_INLINE_EDITING_SUCCESS = "uve-copy-contentlet-inline-editing-success"
20
32
  }
21
-
22
33
  type ListenerCallbackMessage = (event: MessageEvent) => void;
23
34
  type ListenerCallbackPointer = (event: PointerEvent) => void;
24
-
25
35
  /**
26
36
  * Listener for the dotcms editor
27
37
  *
@@ -32,7 +42,6 @@ interface DotCMSPageEditorListener {
32
42
  event: string;
33
43
  callback: ListenerCallbackMessage | ListenerCallbackPointer;
34
44
  }
35
-
36
45
  /**
37
46
  * Observer for the dotcms editor
38
47
  *
@@ -42,5 +51,5 @@ interface DotCMSPageEditorObserver {
42
51
  type: 'observer';
43
52
  observer: MutationObserver;
44
53
  }
45
-
46
54
  export type DotCMSPageEditorSubscription = DotCMSPageEditorListener | DotCMSPageEditorObserver;
55
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,92 @@
1
+ import { DotCMSPageEditorConfig, ReorderMenuConfig } from './models/editor.model';
2
+ import { INLINE_EDITING_EVENT_KEY, InlineEditEventData } from './models/inline-event.model';
3
+ import { Contentlet } from '../client/content/shared/types';
4
+ /**
5
+ * Updates the navigation in the editor.
6
+ *
7
+ * @param {string} pathname - The pathname to update the navigation with.
8
+ * @memberof DotCMSPageEditor
9
+ * @example
10
+ * updateNavigation('/home'); // Sends a message to the editor to update the navigation to '/home'
11
+ */
12
+ export declare function updateNavigation(pathname: string): void;
13
+ /**
14
+ * You can use this function to edit a contentlet in the editor.
15
+ *
16
+ * Calling this function inside the editor, will prompt the UVE to open a dialog to edit the contentlet.
17
+ *
18
+ * @export
19
+ * @template T
20
+ * @param {Contentlet<T>} contentlet - The contentlet to edit.
21
+ */
22
+ export declare function editContentlet<T>(contentlet: Contentlet<T>): 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: INLINE_EDITING_EVENT_KEY, data?: InlineEditEventData): void;
39
+ export declare function reorderMenu(config?: ReorderMenuConfig): void;
40
+ /**
41
+ * @deprecated Use `getUVEState` function on {@link https://npmjs.com/package/@dotcms/uve|@dotcms/uve} instead, this function will be removed on future versions.
42
+ *
43
+ * Checks if the code is running inside the DotCMS Universal Visual Editor (UVE).
44
+ *
45
+ * The function checks three conditions:
46
+ * 1. If window is defined (for SSR environments)
47
+ * 2. If the page is not in preview mode
48
+ * 3. If the current window is embedded in a parent frame
49
+ *
50
+ * @returns {boolean} Returns true if running inside the UVE editor, false if running standalone or in preview mode
51
+ * @example
52
+ * ```ts
53
+ * // Check if code is running in editor before initializing editor-specific features
54
+ * if (isInsideEditor()) {
55
+ * initEditor(config);
56
+ * } else {
57
+ * initStandaloneMode();
58
+ * }
59
+ * ```
60
+ */
61
+ export declare function isInsideEditor(): boolean;
62
+ export declare function initDotUVE(): void;
63
+ /**
64
+ * Initializes the DotCMS page editor.
65
+ *
66
+ * @param {DotCMSPageEditorConfig} config - Optional configuration for the editor.
67
+ * @example
68
+ * ```ts
69
+ * const config = { pathname: '/home' };
70
+ * initEditor(config); // Initializes the editor with the provided configuration
71
+ * ```
72
+ */
73
+ export declare function initEditor(config: DotCMSPageEditorConfig): void;
74
+ /**
75
+ * Destroys the editor by removing event listeners and disconnecting observers.
76
+ *
77
+ * @example
78
+ * ```ts
79
+ * destroyEditor(); // Cleans up the editor by removing all event listeners and disconnecting observers
80
+ * ```
81
+ */
82
+ export declare function destroyEditor(): void;
83
+ /**
84
+ * Adds a style class to empty contentlets.
85
+ *
86
+ * @export
87
+ * @example
88
+ * ```ts
89
+ * addClassToEmptyContentlets(); // Adds the 'empty-contentlet' class to all contentlets that have no height
90
+ * ```
91
+ */
92
+ export declare function addClassToEmptyContentlets(): void;