@dotcms/client 0.0.1-alpha.30 → 0.0.1-alpha.32

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 (61) hide show
  1. package/index.cjs.d.ts +1 -0
  2. package/index.cjs.default.js +1 -0
  3. package/index.cjs.js +1480 -0
  4. package/index.cjs.mjs +2 -0
  5. package/index.esm.d.ts +1 -0
  6. package/index.esm.js +1471 -0
  7. package/package.json +13 -5
  8. package/src/index.d.ts +6 -6
  9. package/README.md +0 -110
  10. package/src/index.js +0 -7
  11. package/src/index.js.map +0 -1
  12. package/src/lib/client/content/builders/collection/collection.js +0 -264
  13. package/src/lib/client/content/builders/collection/collection.js.map +0 -1
  14. package/src/lib/client/content/content-api.js +0 -87
  15. package/src/lib/client/content/content-api.js.map +0 -1
  16. package/src/lib/client/content/shared/const.js +0 -5
  17. package/src/lib/client/content/shared/const.js.map +0 -1
  18. package/src/lib/client/content/shared/types.js +0 -2
  19. package/src/lib/client/content/shared/types.js.map +0 -1
  20. package/src/lib/client/content/shared/utils.js +0 -20
  21. package/src/lib/client/content/shared/utils.js.map +0 -1
  22. package/src/lib/client/models/index.js +0 -9
  23. package/src/lib/client/models/index.js.map +0 -1
  24. package/src/lib/client/models/types.js +0 -2
  25. package/src/lib/client/models/types.js.map +0 -1
  26. package/src/lib/client/sdk-js-client.js +0 -194
  27. package/src/lib/client/sdk-js-client.js.map +0 -1
  28. package/src/lib/editor/listeners/listeners.js +0 -180
  29. package/src/lib/editor/listeners/listeners.js.map +0 -1
  30. package/src/lib/editor/models/client.model.js +0 -73
  31. package/src/lib/editor/models/client.model.js.map +0 -1
  32. package/src/lib/editor/models/editor.model.js +0 -2
  33. package/src/lib/editor/models/editor.model.js.map +0 -1
  34. package/src/lib/editor/models/listeners.model.js +0 -26
  35. package/src/lib/editor/models/listeners.model.js.map +0 -1
  36. package/src/lib/editor/sdk-editor-vtl.js +0 -20
  37. package/src/lib/editor/sdk-editor-vtl.js.map +0 -1
  38. package/src/lib/editor/sdk-editor.js +0 -65
  39. package/src/lib/editor/sdk-editor.js.map +0 -1
  40. package/src/lib/editor/utils/editor.utils.js +0 -134
  41. package/src/lib/editor/utils/editor.utils.js.map +0 -1
  42. package/src/lib/query-builder/lucene-syntax/Equals.js +0 -101
  43. package/src/lib/query-builder/lucene-syntax/Equals.js.map +0 -1
  44. package/src/lib/query-builder/lucene-syntax/Field.js +0 -31
  45. package/src/lib/query-builder/lucene-syntax/Field.js.map +0 -1
  46. package/src/lib/query-builder/lucene-syntax/NotOperand.js +0 -30
  47. package/src/lib/query-builder/lucene-syntax/NotOperand.js.map +0 -1
  48. package/src/lib/query-builder/lucene-syntax/Operand.js +0 -55
  49. package/src/lib/query-builder/lucene-syntax/Operand.js.map +0 -1
  50. package/src/lib/query-builder/lucene-syntax/index.js +0 -5
  51. package/src/lib/query-builder/lucene-syntax/index.js.map +0 -1
  52. package/src/lib/query-builder/sdk-query-builder.js +0 -54
  53. package/src/lib/query-builder/sdk-query-builder.js.map +0 -1
  54. package/src/lib/query-builder/utils/index.js +0 -115
  55. package/src/lib/query-builder/utils/index.js.map +0 -1
  56. package/src/lib/utils/graphql/transforms.js +0 -52
  57. package/src/lib/utils/graphql/transforms.js.map +0 -1
  58. package/src/lib/utils/index.js +0 -3
  59. package/src/lib/utils/index.js.map +0 -1
  60. package/src/lib/utils/page/common-utils.js +0 -12
  61. package/src/lib/utils/page/common-utils.js.map +0 -1
@@ -1,194 +0,0 @@
1
- var _DotCmsClient_config, _DotCmsClient_requestOptions, _DotCmsClient_listeners;
2
- import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
3
- import { Content } from './content/content-api';
4
- import { ErrorMessages } from './models';
5
- import { isInsideEditor } from '../editor/sdk-editor';
6
- function getHostURL(url) {
7
- try {
8
- return new URL(url);
9
- }
10
- catch (error) {
11
- return undefined;
12
- }
13
- }
14
- /**
15
- * `DotCmsClient` is a TypeScript class that provides methods to interact with the DotCMS REST API.
16
- * It requires a configuration object on instantiation, which includes the DotCMS URL, site ID, and authentication token.
17
- *
18
- * @class DotCmsClient
19
- *
20
- * @property {ClientConfig} config - The configuration object for the DotCMS client.
21
- *
22
- * @method constructor(config: ClientConfig) - Constructs a new instance of the DotCmsClient class.
23
- *
24
- * @method page.get(options: PageApiOptions): Promise<unknown> - Retrieves all the elements of any Page in your dotCMS system in JSON format.
25
- *
26
- * @method nav.get(options: NavApiOptions = { depth: 0, path: '/', languageId: 1 }): Promise<unknown> - Retrieves information about the dotCMS file and folder tree.
27
- *
28
- */
29
- export class DotCmsClient {
30
- constructor(config = { dotcmsUrl: '', authToken: '', requestOptions: {}, siteId: '' }) {
31
- _DotCmsClient_config.set(this, void 0);
32
- _DotCmsClient_requestOptions.set(this, void 0);
33
- _DotCmsClient_listeners.set(this, []);
34
- this.page = {
35
- /**
36
- * `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.
37
- * It takes a `PageApiOptions` object as a parameter and returns a Promise that resolves to the response from the DotCMS API.
38
- *
39
- * The Page API enables you to retrieve all the elements of any Page in your dotCMS system.
40
- * The elements may be retrieved in JSON format.
41
- *
42
- * @link https://www.dotcms.com/docs/latest/page-rest-api-layout-as-a-service-laas
43
- * @async
44
- * @param {PageApiOptions} options - The options for the Page API call.
45
- * @returns {Promise<unknown>} - A Promise that resolves to the response from the DotCMS API.
46
- * @throws {Error} - Throws an error if the options are not valid.
47
- */
48
- get: async (options) => {
49
- this.validatePageOptions(options);
50
- const queryParamsObj = {};
51
- for (const [key, value] of Object.entries(options)) {
52
- if (value === undefined || key === 'path' || key === 'siteId')
53
- continue;
54
- if (key === 'personaId') {
55
- queryParamsObj['com.dotmarketing.persona.id'] = String(value);
56
- }
57
- else if (key === 'mode' && value) {
58
- queryParamsObj['mode'] = String(value);
59
- }
60
- else {
61
- queryParamsObj[key] = String(value);
62
- }
63
- }
64
- const queryHostId = options.siteId ?? __classPrivateFieldGet(this, _DotCmsClient_config, "f").siteId ?? '';
65
- if (queryHostId) {
66
- queryParamsObj['host_id'] = queryHostId;
67
- }
68
- const queryParams = new URLSearchParams(queryParamsObj).toString();
69
- const formattedPath = options.path.startsWith('/') ? options.path : `/${options.path}`;
70
- const url = `${__classPrivateFieldGet(this, _DotCmsClient_config, "f").dotcmsUrl}/api/v1/page/json${formattedPath}${queryParams ? `?${queryParams}` : ''}`;
71
- const response = await fetch(url, __classPrivateFieldGet(this, _DotCmsClient_requestOptions, "f"));
72
- if (!response.ok) {
73
- const error = {
74
- status: response.status,
75
- message: ErrorMessages[response.status] || response.statusText
76
- };
77
- console.error(error);
78
- throw error;
79
- }
80
- return response.json().then((data) => data.entity);
81
- }
82
- };
83
- this.editor = {
84
- /**
85
- * `editor.on` is an asynchronous method of the `DotCmsClient` class that allows you to react to actions issued by the UVE.
86
- *
87
- * NOTE: This is being used by the development team - This logic is probably varied or moved to another function/object.
88
- * @param action - The name of the name emitted by UVE
89
- * @param callbackFn - The function to execute when the UVE emits the action
90
- */
91
- on: (action, callbackFn) => {
92
- if (!isInsideEditor()) {
93
- return;
94
- }
95
- if (action === 'changes') {
96
- const messageCallback = (event) => {
97
- if (event.data.name === 'SET_PAGE_DATA') {
98
- callbackFn(event.data.payload);
99
- }
100
- };
101
- window.addEventListener('message', messageCallback);
102
- __classPrivateFieldGet(this, _DotCmsClient_listeners, "f").push({ event: 'message', callback: messageCallback, action });
103
- }
104
- },
105
- /**
106
- * `editor.off` is an synchronous method of the `DotCmsClient` class that allows you to stop listening and reacting to an action issued by UVE.
107
- *
108
- * NOTE: This is being used by the development team - This logic is probably varied or moved to another function/object.
109
- * @param action
110
- */
111
- off: (action) => {
112
- const listenerIndex = __classPrivateFieldGet(this, _DotCmsClient_listeners, "f").findIndex((listener) => listener.action === action);
113
- if (listenerIndex !== -1) {
114
- const listener = __classPrivateFieldGet(this, _DotCmsClient_listeners, "f")[listenerIndex];
115
- window.removeEventListener(listener.event, listener.callback);
116
- __classPrivateFieldGet(this, _DotCmsClient_listeners, "f").splice(listenerIndex, 1);
117
- }
118
- }
119
- };
120
- this.nav = {
121
- /**
122
- * `nav.get` is an asynchronous method of the `DotCmsClient` class that retrieves information about the dotCMS file and folder tree.
123
- * It takes a `NavApiOptions` object as a parameter (with default values) and returns a Promise that resolves to the response from the DotCMS API.
124
- *
125
- * The navigation REST API enables you to retrieve information about the dotCMS file and folder tree through REST API calls.
126
- * @link https://www.dotcms.com/docs/latest/navigation-rest-api
127
- * @async
128
- * @param {NavApiOptions} options - The options for the Nav API call. Defaults to `{ depth: 0, path: '/', languageId: 1 }`.
129
- * @returns {Promise<unknown>} - A Promise that resolves to the response from the DotCMS API.
130
- * @throws {Error} - Throws an error if the options are not valid.
131
- */
132
- get: async (options = { depth: 0, path: '/', languageId: 1 }) => {
133
- this.validateNavOptions(options);
134
- // Extract the 'path' from the options and prepare the rest as query parameters
135
- const { path, ...queryParamsOptions } = options;
136
- const queryParamsObj = {};
137
- Object.entries(queryParamsOptions).forEach(([key, value]) => {
138
- if (value !== undefined) {
139
- queryParamsObj[key] = String(value);
140
- }
141
- });
142
- const queryParams = new URLSearchParams(queryParamsObj).toString();
143
- // Format the URL correctly depending on the 'path' value
144
- const formattedPath = path === '/' ? '/' : `/${path}`;
145
- const url = `${__classPrivateFieldGet(this, _DotCmsClient_config, "f").dotcmsUrl}/api/v1/nav${formattedPath}${queryParams ? `?${queryParams}` : ''}`;
146
- const response = await fetch(url, __classPrivateFieldGet(this, _DotCmsClient_requestOptions, "f"));
147
- return response.json();
148
- }
149
- };
150
- if (!config.dotcmsUrl) {
151
- throw new Error("Invalid configuration - 'dotcmsUrl' is required");
152
- }
153
- this.dotcmsUrl = getHostURL(config.dotcmsUrl)?.origin;
154
- if (!this.dotcmsUrl) {
155
- throw new Error("Invalid configuration - 'dotcmsUrl' must be a valid URL");
156
- }
157
- if (!config.authToken) {
158
- throw new Error("Invalid configuration - 'authToken' is required");
159
- }
160
- __classPrivateFieldSet(this, _DotCmsClient_config, {
161
- ...config,
162
- dotcmsUrl: this.dotcmsUrl
163
- }, "f");
164
- __classPrivateFieldSet(this, _DotCmsClient_requestOptions, {
165
- ...__classPrivateFieldGet(this, _DotCmsClient_config, "f").requestOptions,
166
- headers: {
167
- Authorization: `Bearer ${__classPrivateFieldGet(this, _DotCmsClient_config, "f").authToken}`,
168
- ...__classPrivateFieldGet(this, _DotCmsClient_config, "f").requestOptions?.headers
169
- }
170
- }, "f");
171
- this.content = new Content(__classPrivateFieldGet(this, _DotCmsClient_requestOptions, "f"), __classPrivateFieldGet(this, _DotCmsClient_config, "f").dotcmsUrl);
172
- }
173
- static init(config) {
174
- if (this.instance) {
175
- console.warn('DotCmsClient has already been initialized. Please use the instance to interact with the DotCMS API.');
176
- }
177
- return this.instance ?? (this.instance = new DotCmsClient(config));
178
- }
179
- static get dotcmsUrl() {
180
- return (this.instance && __classPrivateFieldGet(this.instance, _DotCmsClient_config, "f").dotcmsUrl) || '';
181
- }
182
- validatePageOptions(options) {
183
- if (!options.path) {
184
- throw new Error("The 'path' parameter is required for the Page API");
185
- }
186
- }
187
- validateNavOptions(options) {
188
- if (!options.path) {
189
- throw new Error("The 'path' parameter is required for the Nav API");
190
- }
191
- }
192
- }
193
- _DotCmsClient_config = new WeakMap(), _DotCmsClient_requestOptions = new WeakMap(), _DotCmsClient_listeners = new WeakMap();
194
- //# sourceMappingURL=sdk-js-client.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sdk-js-client.js","sourceRoot":"","sources":["../../../../../../../libs/sdk/client/src/lib/client/sdk-js-client.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAGzC,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AA4HtD,SAAS,UAAU,CAAC,GAAW;IAC3B,IAAI,CAAC;QACD,OAAO,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;IACx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Y_CUSTOMER } from '../models/listeners.model';
3
- import { findVTLData, findDotElement, getClosestContainerData, getPageElementBound, scrollIsInBottom } from '../utils/editor.utils';
4
- /**
5
- * Represents an array of DotCMSPageEditorSubscription objects.
6
- * Used to store the subscriptions for the editor and unsubscribe later.
7
- */
8
- export const subscriptions = [];
9
- /**
10
- * Sets the bounds of the containers in the editor.
11
- * Retrieves the containers from the DOM and sends their position data to the editor.
12
- * @private
13
- * @memberof DotCMSPageEditor
14
- */
15
- function setBounds() {
16
- const containers = Array.from(document.querySelectorAll('[data-dot-object="container"]'));
17
- const positionData = getPageElementBound(containers);
18
- postMessageToEditor({
19
- action: CUSTOMER_ACTIONS.SET_BOUNDS,
20
- payload: positionData
21
- });
22
- }
23
- /**
24
- * Listens for editor messages and performs corresding actions based on the received message.
25
- *
26
- * @private
27
- * @memberof DotCMSPageEditor
28
- */
29
- export function listenEditorMessages() {
30
- const messageCallback = (event) => {
31
- switch (event.data) {
32
- case NOTIFY_CUSTOMER.EMA_REQUEST_BOUNDS: {
33
- setBounds();
34
- break;
35
- }
36
- }
37
- if (event.data.name === NOTIFY_CUSTOMER.EMA_SCROLL_INSIDE_IFRAME) {
38
- const direction = event.data.direction;
39
- if ((window.scrollY === 0 && direction === 'up') ||
40
- (scrollIsInBottom() && direction === 'down')) {
41
- /**
42
- * If the iframe scroll is in the top of bottom, we dont send anything.
43
- * This to avoid the lost of scrollend event
44
- **/
45
- return;
46
- }
47
- const scrollY = direction === 'up' ? -120 : 120;
48
- window.scrollBy({ left: 0, top: scrollY, behavior: 'smooth' });
49
- }
50
- };
51
- window.addEventListener('message', messageCallback);
52
- subscriptions.push({
53
- type: 'listener',
54
- event: 'message',
55
- callback: messageCallback
56
- });
57
- }
58
- /**
59
- * Listens for pointer move events and extracts information about the hovered contentlet.
60
- *
61
- * @private
62
- * @memberof DotCMSPageEditor
63
- */
64
- export function listenHoveredContentlet() {
65
- const pointerMoveCallback = (event) => {
66
- const foundElement = findDotElement(event.target);
67
- if (!foundElement)
68
- return;
69
- const { x, y, width, height } = foundElement.getBoundingClientRect();
70
- const isContainer = foundElement.dataset?.['dotObject'] === 'container';
71
- const contentletForEmptyContainer = {
72
- identifier: 'TEMP_EMPTY_CONTENTLET',
73
- title: 'TEMP_EMPTY_CONTENTLET',
74
- contentType: 'TEMP_EMPTY_CONTENTLET_TYPE',
75
- inode: 'TEMPY_EMPTY_CONTENTLET_INODE',
76
- widgetTitle: 'TEMP_EMPTY_CONTENTLET',
77
- baseType: 'TEMP_EMPTY_CONTENTLET',
78
- onNumberOfPages: 1
79
- };
80
- const contentlet = {
81
- identifier: foundElement.dataset?.['dotIdentifier'],
82
- title: foundElement.dataset?.['dotTitle'],
83
- inode: foundElement.dataset?.['dotInode'],
84
- contentType: foundElement.dataset?.['dotType'],
85
- baseType: foundElement.dataset?.['dotBasetype'],
86
- widgetTitle: foundElement.dataset?.['dotWidgetTitle'],
87
- onNumberOfPages: foundElement.dataset?.['dotOnNumberOfPages']
88
- };
89
- const vtlFiles = findVTLData(foundElement);
90
- const contentletPayload = {
91
- container:
92
- // Here extract dot-container from contentlet if is Headless
93
- // or search in parent container if is VTL
94
- foundElement.dataset?.['dotContainer']
95
- ? JSON.parse(foundElement.dataset?.['dotContainer'])
96
- : getClosestContainerData(foundElement),
97
- contentlet: isContainer ? contentletForEmptyContainer : contentlet,
98
- vtlFiles
99
- };
100
- postMessageToEditor({
101
- action: CUSTOMER_ACTIONS.SET_CONTENTLET,
102
- payload: {
103
- x,
104
- y,
105
- width,
106
- height,
107
- payload: contentletPayload
108
- }
109
- });
110
- };
111
- document.addEventListener('pointermove', pointerMoveCallback);
112
- subscriptions.push({
113
- type: 'listener',
114
- event: 'pointermove',
115
- callback: pointerMoveCallback
116
- });
117
- }
118
- /**
119
- * Attaches a scroll event listener to the window
120
- * and sends a message to the editor when the window is scrolled.
121
- *
122
- * @private
123
- * @memberof DotCMSPageEditor
124
- */
125
- export function scrollHandler() {
126
- const scrollCallback = () => {
127
- postMessageToEditor({
128
- action: CUSTOMER_ACTIONS.IFRAME_SCROLL
129
- });
130
- window.lastScrollYPosition = window.scrollY;
131
- };
132
- const scrollEndCallback = () => {
133
- postMessageToEditor({
134
- action: CUSTOMER_ACTIONS.IFRAME_SCROLL_END
135
- });
136
- };
137
- window.addEventListener('scroll', scrollCallback);
138
- window.addEventListener('scrollend', scrollEndCallback);
139
- subscriptions.push({
140
- type: 'listener',
141
- event: 'scroll',
142
- callback: scrollEndCallback
143
- });
144
- subscriptions.push({
145
- type: 'listener',
146
- event: 'scroll',
147
- callback: scrollCallback
148
- });
149
- }
150
- /**
151
- * Restores the scroll position of the window when an iframe is loaded.
152
- * Only used in VTL Pages.
153
- * @export
154
- */
155
- export function preserveScrollOnIframe() {
156
- const preserveScrollCallback = () => {
157
- window.scrollTo(0, window.lastScrollYPosition);
158
- };
159
- window.addEventListener('load', preserveScrollCallback);
160
- subscriptions.push({
161
- type: 'listener',
162
- event: 'scroll',
163
- callback: preserveScrollCallback
164
- });
165
- }
166
- /**
167
- * Sends a message to the editor to get the page data.
168
- * @param {string} pathname - The pathname of the page.
169
- * @private
170
- * @memberof DotCMSPageEditor
171
- */
172
- export function fetchPageDataFromInsideUVE(pathname) {
173
- postMessageToEditor({
174
- action: CUSTOMER_ACTIONS.GET_PAGE_DATA,
175
- payload: {
176
- pathname
177
- }
178
- });
179
- }
180
- //# sourceMappingURL=listeners.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"listeners.js","sourceRoot":"","sources":["../../../../../../../../libs/sdk/client/src/lib/editor/listeners/listeners.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC/E,OAAO,EAAgC,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC1F,OAAO,EACH,WAAW,EACX,cAAc,EACd,uBAAuB,EACvB,mBAAmB,EACnB,gBAAgB,EACnB,MAAM,uBAAuB,CAAC;AAQ/B;;;GAGG;AACH,MAAM,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AAgB,CAAC,WAAW,EAAE,iBAAiB,CAAC,CAAC;IAExD,aAAa,CAAC,IAAI,CAAC;QACf,IAAI,EAAE,UAAU;QAChB,KAAK,EAAE,QAAQ;QACf,QAAQ,EAAE,iBAAiB;KAC9B,CAAC,CAAC;IAEH,aAAa,CAAC,IAAI,CAAC;QACf,IAAI,EAAE,UAAU;QAChB,KAAK,EAAE,QAAQ;QACf,QAAQ,EAAE,cAAc;KAC3B,CAAC,CAAC;AACP,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,sBAAsB;IAClC,MAAM,sBAAsB,GAAG,GAAG,EAAE;QAChC,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC,mBAAmB,CAAC,CAAC;IACnD,CAAC,CAAC;IAEF,MAAM,CAAC,gBAAgB,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAC;IACxD,aAAa,CAAC,IAAI,CAAC;QACf,IAAI,EAAE,UAAU;QAChB,KAAK,EAAE,QAAQ;QACf,QAAQ,EAAE,sBAAsB;KACnC,CAAC,CAAC;AACP,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,0BAA0B,CAAC,QAAgB;IACvD,mBAAmB,CAAC;QAChB,MAAM,EAAE,gBAAgB,CAAC,aAAa;QACtC,OAAO,EAAE;YACL,QAAQ;SACX;KACJ,CAAC,CAAC;AACP,CAAC"}
@@ -1,73 +0,0 @@
1
- /**
2
- * Actions send to the dotcms editor
3
- *
4
- * @export
5
- * @enum {number}
6
- */
7
- export var CUSTOMER_ACTIONS;
8
- (function (CUSTOMER_ACTIONS) {
9
- /**
10
- * Tell the dotcms editor that page change
11
- */
12
- CUSTOMER_ACTIONS["NAVIGATION_UPDATE"] = "set-url";
13
- /**
14
- * Send the element position of the rows, columnsm containers and contentlets
15
- */
16
- CUSTOMER_ACTIONS["SET_BOUNDS"] = "set-bounds";
17
- /**
18
- * Send the information of the hovered contentlet
19
- */
20
- CUSTOMER_ACTIONS["SET_CONTENTLET"] = "set-contentlet";
21
- /**
22
- * Tell the editor that the page is being scrolled
23
- */
24
- CUSTOMER_ACTIONS["IFRAME_SCROLL"] = "scroll";
25
- /**
26
- * Tell the editor that the page has stopped scrolling
27
- */
28
- CUSTOMER_ACTIONS["IFRAME_SCROLL_END"] = "scroll-end";
29
- /**
30
- * Ping the editor to see if the page is inside the editor
31
- */
32
- CUSTOMER_ACTIONS["PING_EDITOR"] = "ping-editor";
33
- /**
34
- * Tell the editor to init the inline editing editor.
35
- */
36
- CUSTOMER_ACTIONS["INIT_INLINE_EDITING"] = "init-inline-editing";
37
- /**
38
- * Tell the editor to open the Copy-contentlet dialog
39
- * To copy a content and then edit it inline.
40
- */
41
- CUSTOMER_ACTIONS["COPY_CONTENTLET_INLINE_EDITING"] = "copy-contentlet-inline-editing";
42
- /**
43
- * Tell the editor to save inline edited contentlet
44
- */
45
- CUSTOMER_ACTIONS["UPDATE_CONTENTLET_INLINE_EDITING"] = "update-contentlet-inline-editing";
46
- /**
47
- * Tell the editor to trigger a menu reorder
48
- */
49
- CUSTOMER_ACTIONS["REORDER_MENU"] = "reorder-menu";
50
- /**
51
- * Tell the editor to send the page info to iframe
52
- */
53
- CUSTOMER_ACTIONS["GET_PAGE_DATA"] = "get-page-data";
54
- /**
55
- * Tell the editor an user send a graphql query
56
- */
57
- CUSTOMER_ACTIONS["CLIENT_READY"] = "client-ready";
58
- /**
59
- * Tell the editor to do nothing
60
- */
61
- CUSTOMER_ACTIONS["NOOP"] = "noop";
62
- })(CUSTOMER_ACTIONS || (CUSTOMER_ACTIONS = {}));
63
- /**
64
- * Post message to dotcms page editor
65
- *
66
- * @export
67
- * @template T
68
- * @param {PostMessageProps<T>} message
69
- */
70
- export function postMessageToEditor(message) {
71
- window.parent.postMessage(message, '*');
72
- }
73
- //# sourceMappingURL=client.model.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"client.model.js","sourceRoot":"","sources":["../../../../../../../../libs/sdk/client/src/lib/editor/models/client.model.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAN,IAAY,gBAsDX;AAtDD,WAAY,gBAAgB;IACxB;;OAEG;IACH,iDAA6B,CAAA;IAC7B;;OAEG;IACH,6CAAyB,CAAA;IACzB;;OAEG;IACH,qDAAiC,CAAA;IACjC;;OAEG;IACH,4CAAwB,CAAA;IACxB;;OAEG;IACH,oDAAgC,CAAA;IAChC;;OAEG;IACH,+CAA2B,CAAA;IAC3B;;OAEG;IACH,+DAA2C,CAAA;IAC3C;;;OAGG;IACH,qFAAiE,CAAA;IACjE;;OAEG;IACH,yFAAqE,CAAA;IACrE;;OAEG;IACH,iDAA6B,CAAA;IAC7B;;OAEG;IACH,mDAA+B,CAAA;IAC/B;;OAEG;IACH,iDAA6B,CAAA;IAC7B;;OAEG;IACH,iCAAa,CAAA;AACjB,CAAC,EAtDW,gBAAgB,KAAhB,gBAAgB,QAsD3B;AAcD;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CAAc,OAA4B;IACzE,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;AAC5C,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=editor.model.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"editor.model.js","sourceRoot":"","sources":["../../../../../../../../libs/sdk/client/src/lib/editor/models/editor.model.ts"],"names":[],"mappings":""}
@@ -1,26 +0,0 @@
1
- /**
2
- * Actions received from the dotcms editor
3
- *
4
- * @export
5
- * @enum {number}
6
- */
7
- export var NOTIFY_CUSTOMER;
8
- (function (NOTIFY_CUSTOMER) {
9
- /**
10
- * Request to page to reload
11
- */
12
- NOTIFY_CUSTOMER["EMA_RELOAD_PAGE"] = "ema-reload-page";
13
- /**
14
- * Request the bounds for the elements
15
- */
16
- NOTIFY_CUSTOMER["EMA_REQUEST_BOUNDS"] = "ema-request-bounds";
17
- /**
18
- * Received pong from the editor
19
- */
20
- NOTIFY_CUSTOMER["EMA_EDITOR_PONG"] = "ema-editor-pong";
21
- /**
22
- * Received scroll event trigger from the editor
23
- */
24
- NOTIFY_CUSTOMER["EMA_SCROLL_INSIDE_IFRAME"] = "scroll-inside-iframe";
25
- })(NOTIFY_CUSTOMER || (NOTIFY_CUSTOMER = {}));
26
- //# sourceMappingURL=listeners.model.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"listeners.model.js","sourceRoot":"","sources":["../../../../../../../../libs/sdk/client/src/lib/editor/models/listeners.model.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAN,IAAY,eAkBX;AAlBD,WAAY,eAAe;IACvB;;OAEG;IACH,sDAAmC,CAAA;IACnC;;OAEG;IACH,4DAAyC,CAAA;IACzC;;OAEG;IACH,sDAAmC,CAAA;IACnC;;OAEG;IAEH,oEAAiD,CAAA;AACrD,CAAC,EAlBW,eAAe,KAAf,eAAe,QAkB1B"}
@@ -1,20 +0,0 @@
1
- import { listenEditorMessages, listenHoveredContentlet, preserveScrollOnIframe, scrollHandler } from './listeners/listeners';
2
- import { isInsideEditor, addClassToEmptyContentlets } from './sdk-editor';
3
- /**
4
- * This is the main entry point for the SDK VTL.
5
- * This is added to VTL Script in the EditPage
6
- *
7
- * @remarks
8
- * This module sets up the necessary listeners and functionality for the SDK VTL.
9
- * It checks if the script is running inside the editor and then initializes the client by pinging the editor,
10
- * listening for editor messages, hovered contentlet changes, and content changes.
11
- *
12
- */
13
- if (isInsideEditor()) {
14
- listenEditorMessages();
15
- scrollHandler();
16
- preserveScrollOnIframe();
17
- listenHoveredContentlet();
18
- addClassToEmptyContentlets();
19
- }
20
- //# sourceMappingURL=sdk-editor-vtl.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sdk-editor-vtl.js","sourceRoot":"","sources":["../../../../../../../libs/sdk/client/src/lib/editor/sdk-editor-vtl.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,oBAAoB,EACpB,uBAAuB,EACvB,sBAAsB,EACtB,aAAa,EAChB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,cAAc,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC;AAQ1E;;;;;;;;;GASG;AACH,IAAI,cAAc,EAAE,EAAE,CAAC;IACnB,oBAAoB,EAAE,CAAC;IACvB,aAAa,EAAE,CAAC;IAChB,sBAAsB,EAAE,CAAC;IACzB,uBAAuB,EAAE,CAAC;IAC1B,0BAA0B,EAAE,CAAC;AACjC,CAAC"}
@@ -1,65 +0,0 @@
1
- import { fetchPageDataFromInsideUVE, listenEditorMessages, listenHoveredContentlet, scrollHandler, subscriptions } from './listeners/listeners';
2
- import { CUSTOMER_ACTIONS, postMessageToEditor } from './models/client.model';
3
- /**
4
- *
5
- * Updates the navigation in the editor.
6
- * @param {string} pathname - The pathname to update the navigation with.
7
- * @memberof DotCMSPageEditor
8
- */
9
- export function updateNavigation(pathname) {
10
- postMessageToEditor({
11
- action: CUSTOMER_ACTIONS.NAVIGATION_UPDATE,
12
- payload: {
13
- url: pathname === '/' ? 'index' : pathname?.replace('/', '')
14
- }
15
- });
16
- }
17
- /**
18
- * Checks if the code is running inside an editor.
19
- * @returns {boolean} Returns true if the code is running inside an editor, otherwise false.
20
- */
21
- export function isInsideEditor() {
22
- if (typeof window === 'undefined') {
23
- return false;
24
- }
25
- return window.parent !== window;
26
- }
27
- /**
28
- * Initializes the DotCMS page editor.
29
- *
30
- * @param conf - Optional configuration for the editor.
31
- */
32
- export function initEditor(config) {
33
- fetchPageDataFromInsideUVE(config.pathname);
34
- listenEditorMessages();
35
- listenHoveredContentlet();
36
- scrollHandler();
37
- }
38
- /**
39
- * Destroys the editor by removing event listeners and disconnecting observers.
40
- */
41
- export function destroyEditor() {
42
- subscriptions.forEach((subscription) => {
43
- if (subscription.type === 'listener') {
44
- window.removeEventListener(subscription.event, subscription.callback);
45
- }
46
- if (subscription.type === 'observer') {
47
- subscription.observer.disconnect();
48
- }
49
- });
50
- }
51
- /**
52
- * Adds a class to empty contentlets.
53
- *
54
- * @export
55
- */
56
- export function addClassToEmptyContentlets() {
57
- const contentlets = document.querySelectorAll('[data-dot-object="contentlet"]');
58
- contentlets.forEach((contentlet) => {
59
- if (contentlet.clientHeight) {
60
- return;
61
- }
62
- contentlet.classList.add('empty-contentlet');
63
- });
64
- }
65
- //# sourceMappingURL=sdk-editor.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sdk-editor.js","sourceRoot":"","sources":["../../../../../../../libs/sdk/client/src/lib/editor/sdk-editor.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,0BAA0B,EAC1B,oBAAoB,EACpB,uBAAuB,EACvB,aAAa,EACb,aAAa,EAChB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAG9E;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,QAAgB;IAC7C,mBAAmB,CAAC;QAChB,MAAM,EAAE,gBAAgB,CAAC,iBAAiB;QAC1C,OAAO,EAAE;YACL,GAAG,EAAE,QAAQ,KAAK,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,EAAE,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC;SAC/D;KACJ,CAAC,CAAC;AACP,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,cAAc;IAC1B,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;QAChC,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,OAAO,MAAM,CAAC,MAAM,KAAK,MAAM,CAAC;AACpC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAC,MAA8B;IACrD,0BAA0B,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC5C,oBAAoB,EAAE,CAAC;IACvB,uBAAuB,EAAE,CAAC;IAC1B,aAAa,EAAE,CAAC;AACpB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa;IACzB,aAAa,CAAC,OAAO,CA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