@dotcms/client 0.0.1-alpha.2 → 0.0.1-alpha.21

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 (80) hide show
  1. package/README.md +0 -1
  2. package/package.json +4 -1
  3. package/src/index.d.ts +6 -2
  4. package/src/index.js +6 -2
  5. package/src/index.js.map +1 -1
  6. package/src/lib/client/content/builders/collection/collection.d.ts +148 -0
  7. package/src/lib/client/content/builders/collection/collection.js +264 -0
  8. package/src/lib/client/content/builders/collection/collection.js.map +1 -0
  9. package/src/lib/client/content/content-api.d.ts +78 -0
  10. package/src/lib/client/content/content-api.js +87 -0
  11. package/src/lib/client/content/content-api.js.map +1 -0
  12. package/src/lib/client/content/shared/const.d.ts +3 -0
  13. package/src/lib/client/content/shared/const.js +5 -0
  14. package/src/lib/client/content/shared/const.js.map +1 -0
  15. package/src/lib/client/content/shared/types.d.ts +62 -0
  16. package/src/lib/client/content/shared/types.js +2 -0
  17. package/src/lib/client/content/shared/types.js.map +1 -0
  18. package/src/lib/client/content/shared/utils.d.ts +12 -0
  19. package/src/lib/client/content/shared/utils.js +20 -0
  20. package/src/lib/client/content/shared/utils.js.map +1 -0
  21. package/src/lib/client/models/index.d.ts +1 -0
  22. package/src/lib/client/models/index.js +9 -0
  23. package/src/lib/client/models/index.js.map +1 -0
  24. package/src/lib/{sdk-js-client.d.ts → client/sdk-js-client.d.ts} +11 -2
  25. package/src/lib/{sdk-js-client.js → client/sdk-js-client.js} +14 -0
  26. package/src/lib/client/sdk-js-client.js.map +1 -0
  27. package/src/lib/editor/listeners/listeners.d.ts +46 -0
  28. package/src/lib/editor/listeners/listeners.js +198 -0
  29. package/src/lib/editor/listeners/listeners.js.map +1 -0
  30. package/src/lib/{postMessageToEditor.d.ts → editor/models/client.model.d.ts} +26 -1
  31. package/src/lib/editor/models/client.model.js +62 -0
  32. package/src/lib/editor/models/client.model.js.map +1 -0
  33. package/src/lib/editor/models/editor.model.d.ts +16 -0
  34. package/src/lib/editor/models/editor.model.js +2 -0
  35. package/src/lib/editor/models/editor.model.js.map +1 -0
  36. package/src/lib/editor/models/listeners.model.d.ts +47 -0
  37. package/src/lib/editor/models/listeners.model.js +26 -0
  38. package/src/lib/editor/models/listeners.model.js.map +1 -0
  39. package/src/lib/editor/sdk-editor-vtl.d.ts +6 -0
  40. package/src/lib/editor/sdk-editor-vtl.js +21 -0
  41. package/src/lib/editor/sdk-editor-vtl.js.map +1 -0
  42. package/src/lib/editor/sdk-editor.d.ts +29 -0
  43. package/src/lib/editor/sdk-editor.js +68 -0
  44. package/src/lib/editor/sdk-editor.js.map +1 -0
  45. package/src/lib/editor/utils/editor.utils.d.ts +83 -0
  46. package/src/lib/editor/utils/editor.utils.js +134 -0
  47. package/src/lib/editor/utils/editor.utils.js.map +1 -0
  48. package/src/lib/query-builder/lucene-syntax/Equals.d.ts +83 -0
  49. package/src/lib/query-builder/lucene-syntax/Equals.js +101 -0
  50. package/src/lib/query-builder/lucene-syntax/Equals.js.map +1 -0
  51. package/src/lib/query-builder/lucene-syntax/Field.d.ts +23 -0
  52. package/src/lib/query-builder/lucene-syntax/Field.js +31 -0
  53. package/src/lib/query-builder/lucene-syntax/Field.js.map +1 -0
  54. package/src/lib/query-builder/lucene-syntax/NotOperand.d.ts +22 -0
  55. package/src/lib/query-builder/lucene-syntax/NotOperand.js +30 -0
  56. package/src/lib/query-builder/lucene-syntax/NotOperand.js.map +1 -0
  57. package/src/lib/query-builder/lucene-syntax/Operand.d.ts +44 -0
  58. package/src/lib/query-builder/lucene-syntax/Operand.js +55 -0
  59. package/src/lib/query-builder/lucene-syntax/Operand.js.map +1 -0
  60. package/src/lib/query-builder/lucene-syntax/index.d.ts +4 -0
  61. package/src/lib/query-builder/lucene-syntax/index.js +5 -0
  62. package/src/lib/query-builder/lucene-syntax/index.js.map +1 -0
  63. package/src/lib/query-builder/sdk-query-builder.d.ts +42 -0
  64. package/src/lib/query-builder/sdk-query-builder.js +54 -0
  65. package/src/lib/query-builder/sdk-query-builder.js.map +1 -0
  66. package/src/lib/query-builder/utils/index.d.ts +91 -0
  67. package/src/lib/query-builder/utils/index.js +115 -0
  68. package/src/lib/query-builder/utils/index.js.map +1 -0
  69. package/src/lib/utils/graphql/transforms.d.ts +12 -0
  70. package/src/lib/utils/graphql/transforms.js +47 -0
  71. package/src/lib/utils/graphql/transforms.js.map +1 -0
  72. package/src/lib/utils/index.d.ts +2 -0
  73. package/src/lib/utils/index.js +3 -0
  74. package/src/lib/utils/index.js.map +1 -0
  75. package/src/lib/utils/page/common-utils.d.ts +14 -0
  76. package/src/lib/utils/page/common-utils.js +12 -0
  77. package/src/lib/utils/page/common-utils.js.map +1 -0
  78. package/src/lib/postMessageToEditor.js +0 -37
  79. package/src/lib/postMessageToEditor.js.map +0 -1
  80. package/src/lib/sdk-js-client.js.map +0 -1
@@ -0,0 +1,62 @@
1
+ import { Equals } from '../../../query-builder/lucene-syntax';
2
+ import { QueryBuilder } from '../../../query-builder/sdk-query-builder';
3
+ export type SortBy = {
4
+ field: string;
5
+ order: 'asc' | 'desc';
6
+ };
7
+ export type BuildQuery = (qb: QueryBuilder) => Equals;
8
+ export interface ContentTypeMainFields {
9
+ hostName: string;
10
+ modDate: string;
11
+ publishDate: string;
12
+ title: string;
13
+ baseType: string;
14
+ inode: string;
15
+ archived: boolean;
16
+ ownerName: string;
17
+ host: string;
18
+ working: boolean;
19
+ locked: boolean;
20
+ stInode: string;
21
+ contentType: string;
22
+ live: boolean;
23
+ owner: string;
24
+ identifier: string;
25
+ publishUserName: string;
26
+ publishUser: string;
27
+ languageId: number;
28
+ creationDate: string;
29
+ url: string;
30
+ titleImage: string;
31
+ modUserName: string;
32
+ hasLiveVersion: boolean;
33
+ folder: string;
34
+ hasTitleImage: boolean;
35
+ sortOrder: number;
36
+ modUser: string;
37
+ __icon__: string;
38
+ contentTypeIcon: string;
39
+ variant: string;
40
+ }
41
+ export type Contentlet<T> = T & ContentTypeMainFields;
42
+ export type OnFullfilled<T> = ((value: GetCollectionResponse<T>) => GetCollectionResponse<T> | PromiseLike<GetCollectionResponse<T>> | void) | undefined | null;
43
+ export type OnRejected = ((error: GetCollectionError) => GetCollectionError | PromiseLike<GetCollectionError> | void) | undefined | null;
44
+ export interface GetCollectionResponse<T> {
45
+ contentlets: Contentlet<T>[];
46
+ page: number;
47
+ size: number;
48
+ total: number;
49
+ sortedBy?: SortBy[];
50
+ }
51
+ export interface GetCollectionRawResponse<T> {
52
+ entity: {
53
+ jsonObjectView: {
54
+ contentlets: Contentlet<T>[];
55
+ };
56
+ resultsSize: number;
57
+ };
58
+ }
59
+ export interface GetCollectionError {
60
+ status: number;
61
+ [key: string]: unknown;
62
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../../../../libs/sdk/client/src/lib/client/content/shared/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Sanitizes the query for the given content type.
3
+ * It replaces the fields that are not contentType fields with the correct format.
4
+ * Example: +field: -> +contentTypeVar.field:
5
+ *
6
+ *
7
+ * @export
8
+ * @param {string} query
9
+ * @param {string} contentType
10
+ * @return {*} {string}
11
+ */
12
+ export declare function sanitizeQueryForContentType(query: string, contentType: string): string;
@@ -0,0 +1,20 @@
1
+ import { CONTENT_TYPE_MAIN_FIELDS } from './const';
2
+ /**
3
+ * Sanitizes the query for the given content type.
4
+ * It replaces the fields that are not contentType fields with the correct format.
5
+ * Example: +field: -> +contentTypeVar.field:
6
+ *
7
+ *
8
+ * @export
9
+ * @param {string} query
10
+ * @param {string} contentType
11
+ * @return {*} {string}
12
+ */
13
+ export function sanitizeQueryForContentType(query, contentType) {
14
+ return query.replace(/\+([^+:]*?):/g, (original, field) => {
15
+ return !CONTENT_TYPE_MAIN_FIELDS.includes(field) // Fields that are not contentType fields
16
+ ? `+${contentType}.${field}:` // Should have this format: +contentTypeVar.field:
17
+ : original; // Return the field if it is a contentType field
18
+ });
19
+ }
20
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../../../../../libs/sdk/client/src/lib/client/content/shared/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAEnD;;;;;;;;;;GAUG;AACH,MAAM,UAAU,2BAA2B,CAAC,KAAa,EAAE,WAAmB;IAC1E,OAAO,KAAK,CAAC,OAAO,CAAC,eAAe,EAAE,CAAC,QAAQ,EAAE,KAAK,EAAE,EAAE;QACtD,OAAO,CAAC,wBAAwB,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,yCAAyC;YACtF,CAAC,CAAC,IAAI,WAAW,IAAI,KAAK,GAAG,CAAC,kDAAkD;YAChF,CAAC,CAAC,QAAQ,CAAC,CAAC,gDAAgD;IACpE,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -0,0 +1 @@
1
+ export declare const ErrorMessages: Record<number, string>;
@@ -0,0 +1,9 @@
1
+ export const ErrorMessages = {
2
+ 401: 'Unauthorized. Check the token and try again.',
3
+ 403: 'Forbidden. Check the permissions and try again.',
4
+ 404: 'Not Found. Check the URL and try again.',
5
+ 500: 'Internal Server Error. Try again later.',
6
+ 502: 'Bad Gateway. Try again later.',
7
+ 503: 'Service Unavailable. Try again later.'
8
+ };
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../libs/sdk/client/src/lib/client/models/index.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,aAAa,GAA2B;IACjD,GAAG,EAAE,8CAA8C;IACnD,GAAG,EAAE,iDAAiD;IACtD,GAAG,EAAE,yCAAyC;IAC9C,GAAG,EAAE,yCAAyC;IAC9C,GAAG,EAAE,+BAA+B;IACpC,GAAG,EAAE,uCAAuC;CAC/C,CAAC"}
@@ -1,3 +1,5 @@
1
+ import { Content } from './content/content-api';
2
+ export type ClientOptions = Omit<RequestInit, 'body' | 'method'>;
1
3
  export interface ClientConfig {
2
4
  /**
3
5
  * The URL of the dotCMS instance.
@@ -31,10 +33,10 @@ export interface ClientConfig {
31
33
  *
32
34
  * @description These options will be used in the fetch request. Any option can be specified except for 'body' and 'method' which are omitted.
33
35
  * @example `{ headers: { 'Content-Type': 'application/json' } }`
34
- * @type {Omit<RequestInit, 'body' | 'method'>}
36
+ * @type {ClientOptions}
35
37
  * @optional
36
38
  */
37
- requestOptions?: Omit<RequestInit, 'body' | 'method'>;
39
+ requestOptions?: ClientOptions;
38
40
  }
39
41
  type PageApiOptions = {
40
42
  /**
@@ -49,6 +51,12 @@ type PageApiOptions = {
49
51
  * @type {number}
50
52
  */
51
53
  siteId?: string;
54
+ /**
55
+ * The mode of the page you want to retrieve. If not provided will use the default mode of the site.
56
+ *
57
+ * @type {number}
58
+ */
59
+ mode?: string;
52
60
  /**
53
61
  * The language id of the page you want to retrieve. If not provided will use the default language of the site.
54
62
  *
@@ -127,6 +135,7 @@ type NavApiOptions = {
127
135
  export declare class DotCmsClient {
128
136
  private config;
129
137
  private requestOptions;
138
+ content: Content;
130
139
  constructor(config?: ClientConfig);
131
140
  page: {
132
141
  /**
@@ -1,3 +1,5 @@
1
+ import { Content } from './content/content-api';
2
+ import { ErrorMessages } from './models';
1
3
  function isValidUrl(url) {
2
4
  try {
3
5
  new URL(url);
@@ -47,6 +49,9 @@ export class DotCmsClient {
47
49
  if (key === 'personaId') {
48
50
  queryParamsObj['com.dotmarketing.persona.id'] = String(value);
49
51
  }
52
+ else if (key === 'mode' && value) {
53
+ queryParamsObj['mode'] = String(value);
54
+ }
50
55
  else {
51
56
  queryParamsObj[key] = String(value);
52
57
  }
@@ -59,6 +64,14 @@ export class DotCmsClient {
59
64
  const formattedPath = options.path.startsWith('/') ? options.path : `/${options.path}`;
60
65
  const url = `${this.config.dotcmsUrl}/api/v1/page/json${formattedPath}${queryParams ? `?${queryParams}` : ''}`;
61
66
  const response = await fetch(url, this.requestOptions);
67
+ if (!response.ok) {
68
+ const error = {
69
+ status: response.status,
70
+ message: ErrorMessages[response.status] || response.statusText
71
+ };
72
+ console.error(error);
73
+ throw error;
74
+ }
62
75
  return response.json();
63
76
  }
64
77
  };
@@ -109,6 +122,7 @@ export class DotCmsClient {
109
122
  ...this.config.requestOptions?.headers
110
123
  }
111
124
  };
125
+ this.content = new Content(this.requestOptions, this.config.dotcmsUrl);
112
126
  }
113
127
  validatePageOptions(options) {
114
128
  if (!options.path) {
@@ -0,0 +1 @@
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;AA4HzC,SAAS,UAAU,CAAC,GAAW;IAC3B,IAAI,CAAC;QACD,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;QAEb,OAAO,IAAI,CAAC;IAChB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,OAAO,KAAK,CAAC;IACjB,CAAC;AACL,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,YAAY;IAMrB,YACI,SAAuB,EAAE,SAAS,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,cAAc,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;QA2B3F,SAAI,GAAG;YACH;;;;;;;;;;;;eAYG;YACH,GAAG,EAAE,KAAK,EAAE,OAAuB,EAAoB,EAAE;gBACrD,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC;gBAElC,MAAM,cAAc,GAA2B,EAAE,CAAC;gBAClD,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,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AC;CACJ;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IACxB;;;;;;;OAOG;IACH,IAAI,EAAE,CAAC,MAAoB,EAAgB,EAAE;QACzC,OAAO,IAAI,YAAY,CAAC,MAAM,CAAC,CAAC;IACpC,CAAC;CACJ,CAAC"}
@@ -0,0 +1,46 @@
1
+ import { DotCMSPageEditorConfig } from '../models/editor.model';
2
+ import { DotCMSPageEditorSubscription } from '../models/listeners.model';
3
+ declare global {
4
+ interface Window {
5
+ lastScrollYPosition: number;
6
+ }
7
+ }
8
+ export declare function setPageEditorConfig(config: DotCMSPageEditorConfig): void;
9
+ /**
10
+ * Represents an array of DotCMSPageEditorSubscription objects.
11
+ * Used to store the subscriptions for the editor and unsubscribe later.
12
+ */
13
+ export declare const subscriptions: DotCMSPageEditorSubscription[];
14
+ /**
15
+ * Listens for editor messages and performs corresponding actions based on the received message.
16
+ *
17
+ * @private
18
+ * @memberof DotCMSPageEditor
19
+ */
20
+ export declare function listenEditorMessages(): void;
21
+ /**
22
+ * Listens for pointer move events and extracts information about the hovered contentlet.
23
+ *
24
+ * @private
25
+ * @memberof DotCMSPageEditor
26
+ */
27
+ export declare function listenHoveredContentlet(): void;
28
+ /**
29
+ * Attaches a scroll event listener to the window
30
+ * and sends a message to the editor when the window is scrolled.
31
+ *
32
+ * @private
33
+ * @memberof DotCMSPageEditor
34
+ */
35
+ export declare function scrollHandler(): void;
36
+ /**
37
+ * Restores the scroll position of the window when an iframe is loaded.
38
+ * Only used in VTL Pages.
39
+ * @export
40
+ */
41
+ export declare function preserveScrollOnIframe(): void;
42
+ /**
43
+ * Sends a ping message to the editor.
44
+ *
45
+ */
46
+ export declare function pingEditor(): void;
@@ -0,0 +1,198 @@
1
+ import { CUSTOMER_ACTIONS, postMessageToEditor } from '../models/client.model';
2
+ import { NOTIFY_CUSTOMER } from '../models/listeners.model';
3
+ import { findVTLData, findDotElement, getClosestContainerData, getPageElementBound, scrollIsInBottom } from '../utils/editor.utils';
4
+ /**
5
+ * Default reload function that reloads the current window.
6
+ */
7
+ const defaultReloadFn = () => window.location.reload();
8
+ /**
9
+ * Configuration object for the DotCMSPageEditor.
10
+ */
11
+ let pageEditorConfig = {
12
+ onReload: defaultReloadFn
13
+ };
14
+ export function setPageEditorConfig(config) {
15
+ pageEditorConfig = config;
16
+ }
17
+ /**
18
+ * Represents an array of DotCMSPageEditorSubscription objects.
19
+ * Used to store the subscriptions for the editor and unsubscribe later.
20
+ */
21
+ export const subscriptions = [];
22
+ /**
23
+ * Sets the bounds of the containers in the editor.
24
+ * Retrieves the containers from the DOM and sends their position data to the editor.
25
+ * @private
26
+ * @memberof DotCMSPageEditor
27
+ */
28
+ function setBounds() {
29
+ const containers = Array.from(document.querySelectorAll('[data-dot-object="container"]'));
30
+ const positionData = getPageElementBound(containers);
31
+ postMessageToEditor({
32
+ action: CUSTOMER_ACTIONS.SET_BOUNDS,
33
+ payload: positionData
34
+ });
35
+ }
36
+ /**
37
+ * Reloads the page and triggers the onReload callback if it exists in the config object.
38
+ */
39
+ function reloadPage() {
40
+ pageEditorConfig?.onReload();
41
+ }
42
+ /**
43
+ * Listens for editor messages and performs corresponding actions based on the received message.
44
+ *
45
+ * @private
46
+ * @memberof DotCMSPageEditor
47
+ */
48
+ export function listenEditorMessages() {
49
+ const messageCallback = (event) => {
50
+ switch (event.data) {
51
+ case NOTIFY_CUSTOMER.EMA_REQUEST_BOUNDS: {
52
+ setBounds();
53
+ break;
54
+ }
55
+ case NOTIFY_CUSTOMER.EMA_RELOAD_PAGE: {
56
+ reloadPage();
57
+ break;
58
+ }
59
+ }
60
+ if (event.data.name === NOTIFY_CUSTOMER.EMA_SCROLL_INSIDE_IFRAME) {
61
+ const direction = event.data.direction;
62
+ if ((window.scrollY === 0 && direction === 'up') ||
63
+ (scrollIsInBottom() && direction === 'down')) {
64
+ /**
65
+ * If the iframe scroll is in the top of bottom, we dont send anything.
66
+ * This to avoid the lost of scrollend event
67
+ **/
68
+ return;
69
+ }
70
+ const scrollY = direction === 'up' ? -120 : 120;
71
+ window.scrollBy({ left: 0, top: scrollY, behavior: 'smooth' });
72
+ }
73
+ };
74
+ window.addEventListener('message', messageCallback);
75
+ subscriptions.push({
76
+ type: 'listener',
77
+ event: 'message',
78
+ callback: messageCallback
79
+ });
80
+ }
81
+ /**
82
+ * Listens for pointer move events and extracts information about the hovered contentlet.
83
+ *
84
+ * @private
85
+ * @memberof DotCMSPageEditor
86
+ */
87
+ export function listenHoveredContentlet() {
88
+ const pointerMoveCallback = (event) => {
89
+ const foundElement = findDotElement(event.target);
90
+ if (!foundElement)
91
+ return;
92
+ const { x, y, width, height } = foundElement.getBoundingClientRect();
93
+ const isContainer = foundElement.dataset?.['dotObject'] === 'container';
94
+ const contentletForEmptyContainer = {
95
+ identifier: 'TEMP_EMPTY_CONTENTLET',
96
+ title: 'TEMP_EMPTY_CONTENTLET',
97
+ contentType: 'TEMP_EMPTY_CONTENTLET_TYPE',
98
+ inode: 'TEMPY_EMPTY_CONTENTLET_INODE',
99
+ widgetTitle: 'TEMP_EMPTY_CONTENTLET',
100
+ baseType: 'TEMP_EMPTY_CONTENTLET',
101
+ onNumberOfPages: 1
102
+ };
103
+ const contentlet = {
104
+ identifier: foundElement.dataset?.['dotIdentifier'],
105
+ title: foundElement.dataset?.['dotTitle'],
106
+ inode: foundElement.dataset?.['dotInode'],
107
+ contentType: foundElement.dataset?.['dotType'],
108
+ baseType: foundElement.dataset?.['dotBasetype'],
109
+ widgetTitle: foundElement.dataset?.['dotWidgetTitle'],
110
+ onNumberOfPages: foundElement.dataset?.['dotOnNumberOfPages']
111
+ };
112
+ const vtlFiles = findVTLData(foundElement);
113
+ const contentletPayload = {
114
+ container:
115
+ // Here extract dot-container from contentlet if is Headless
116
+ // or search in parent container if is VTL
117
+ foundElement.dataset?.['dotContainer']
118
+ ? JSON.parse(foundElement.dataset?.['dotContainer'])
119
+ : getClosestContainerData(foundElement),
120
+ contentlet: isContainer ? contentletForEmptyContainer : contentlet,
121
+ vtlFiles
122
+ };
123
+ postMessageToEditor({
124
+ action: CUSTOMER_ACTIONS.SET_CONTENTLET,
125
+ payload: {
126
+ x,
127
+ y,
128
+ width,
129
+ height,
130
+ payload: contentletPayload
131
+ }
132
+ });
133
+ };
134
+ document.addEventListener('pointermove', pointerMoveCallback);
135
+ subscriptions.push({
136
+ type: 'listener',
137
+ event: 'pointermove',
138
+ callback: pointerMoveCallback
139
+ });
140
+ }
141
+ /**
142
+ * Attaches a scroll event listener to the window
143
+ * and sends a message to the editor when the window is scrolled.
144
+ *
145
+ * @private
146
+ * @memberof DotCMSPageEditor
147
+ */
148
+ export function scrollHandler() {
149
+ const scrollCallback = () => {
150
+ postMessageToEditor({
151
+ action: CUSTOMER_ACTIONS.IFRAME_SCROLL
152
+ });
153
+ window.lastScrollYPosition = window.scrollY;
154
+ };
155
+ const scrollEndCallback = () => {
156
+ postMessageToEditor({
157
+ action: CUSTOMER_ACTIONS.IFRAME_SCROLL_END
158
+ });
159
+ };
160
+ window.addEventListener('scroll', scrollCallback);
161
+ window.addEventListener('scrollend', scrollEndCallback);
162
+ subscriptions.push({
163
+ type: 'listener',
164
+ event: 'scroll',
165
+ callback: scrollEndCallback
166
+ });
167
+ subscriptions.push({
168
+ type: 'listener',
169
+ event: 'scroll',
170
+ callback: scrollCallback
171
+ });
172
+ }
173
+ /**
174
+ * Restores the scroll position of the window when an iframe is loaded.
175
+ * Only used in VTL Pages.
176
+ * @export
177
+ */
178
+ export function preserveScrollOnIframe() {
179
+ const preserveScrollCallback = () => {
180
+ window.scrollTo(0, window.lastScrollYPosition);
181
+ };
182
+ window.addEventListener('load', preserveScrollCallback);
183
+ subscriptions.push({
184
+ type: 'listener',
185
+ event: 'scroll',
186
+ callback: preserveScrollCallback
187
+ });
188
+ }
189
+ /**
190
+ * Sends a ping message to the editor.
191
+ *
192
+ */
193
+ export function pingEditor() {
194
+ postMessageToEditor({
195
+ action: CUSTOMER_ACTIONS.PING_EDITOR
196
+ });
197
+ }
198
+ //# sourceMappingURL=listeners.js.map
@@ -0,0 +1 @@
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;AAE/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;;GAEG;AACH,MAAM,eAAe,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;AAEvD;;GAEG;AACH,IAAI,gBAAgB,GAA2B;IAC3C,QAAQ,EAAE,eAAe;CAC5B,CAAC;AAEF,MAAM,UAAU,mBAAmB,CAAC,MAA8B;IAC9D,gBAAgB,GAAG,MAAM,CAAC;AAC9B,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAmC,EAAE,CAAC;AAEhE;;;;;GAKG;AACH,SAAS,SAAS;IACd,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,CACzB,QAAQ,CAAC,gBAAgB,CAAC,+BAA+B,CAAC,CACzC,CAAC;IACtB,MAAM,YAAY,GAAG,mBAAmB,CAAC,UAAU,CAAC,CAAC;IAErD,mBAAmB,CAAC;QAChB,MAAM,EAAE,gBAAgB,CAAC,UAAU;QACnC,OAAO,EAAE,YAAY;KACxB,CAAC,CAAC;AACP,CAAC;AAED;;GAEG;AACH,SAAS,UAAU;IACf,gBAAgB,EAAE,QAAQ,EAAE,CAAC;AACjC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB;IAChC,MAAM,eAAe,GAAG,CAAC,KAAmB,EAAE,EAAE;QAC5C,QAAQ,KAAK,CAAC,IAAI,EAAE,CAAC;YACjB,KAA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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;;;GAGG;AACH,MAAM,UAAU,UAAU;IACtB,mBAAmB,CAAC;QAChB,MAAM,EAAE,gBAAgB,CAAC,WAAW;KACvC,CAAC,CAAC;AACP,CAAC"}
@@ -8,7 +8,7 @@ export declare enum CUSTOMER_ACTIONS {
8
8
  /**
9
9
  * Tell the dotcms editor that page change
10
10
  */
11
- SET_URL = "set-url",
11
+ NAVIGATION_UPDATE = "set-url",
12
12
  /**
13
13
  * Send the element position of the rows, columnsm containers and contentlets
14
14
  */
@@ -21,6 +21,31 @@ export declare enum CUSTOMER_ACTIONS {
21
21
  * Tell the editor that the page is being scrolled
22
22
  */
23
23
  IFRAME_SCROLL = "scroll",
24
+ /**
25
+ * Tell the editor that the page has stopped scrolling
26
+ */
27
+ IFRAME_SCROLL_END = "scroll-end",
28
+ /**
29
+ * Ping the editor to see if the page is inside the editor
30
+ */
31
+ PING_EDITOR = "ping-editor",
32
+ /**
33
+ * Tell the editor to init the inline editing editor.
34
+ */
35
+ INIT_INLINE_EDITING = "init-inline-editing",
36
+ /**
37
+ * Tell the editor to open the Copy-contentlet dialog
38
+ * To copy a content and then edit it inline.
39
+ */
40
+ COPY_CONTENTLET_INLINE_EDITING = "copy-contentlet-inline-editing",
41
+ /**
42
+ * Tell the editor to save inline edited contentlet
43
+ */
44
+ UPDATE_CONTENTLET_INLINE_EDITING = "update-contentlet-inline-editing",
45
+ /**
46
+ * Tell the editor to trigger a menu reorder
47
+ */
48
+ REORDER_MENU = "reorder-menu",
24
49
  NOOP = "noop"
25
50
  }
26
51
  /**
@@ -0,0 +1,62 @@
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
+ CUSTOMER_ACTIONS["NOOP"] = "noop";
51
+ })(CUSTOMER_ACTIONS || (CUSTOMER_ACTIONS = {}));
52
+ /**
53
+ * Post message to dotcms page editor
54
+ *
55
+ * @export
56
+ * @template T
57
+ * @param {PostMessageProps<T>} message
58
+ */
59
+ export function postMessageToEditor(message) {
60
+ window.parent.postMessage(message, '*');
61
+ }
62
+ //# sourceMappingURL=client.model.js.map
@@ -0,0 +1 @@
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,gBA6CX;AA7CD,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;IAErE;;OAEG;IACH,iDAA6B,CAAA;IAE7B,iCAAa,CAAA;AACjB,CAAC,EA7CW,gBAAgB,KAAhB,gBAAgB,QA6C3B;AAcD;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CAAc,OAA4B;IACzE,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;AAC5C,CAAC"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ *
3
+ * Represents the configuration options for the DotCMS page editor.
4
+ * @export
5
+ * @interface DotCMSPageEditorConfig
6
+ */
7
+ export interface DotCMSPageEditorConfig {
8
+ /**
9
+ * A callback function that will be called when the page editor needs to be reloaded.
10
+ */
11
+ onReload: () => void;
12
+ /**
13
+ * The pathname of the page being edited. Optional.
14
+ */
15
+ pathname?: string;
16
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=editor.model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"editor.model.js","sourceRoot":"","sources":["../../../../../../../../libs/sdk/client/src/lib/editor/models/editor.model.ts"],"names":[],"mappings":""}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Actions received from the dotcms editor
3
+ *
4
+ * @export
5
+ * @enum {number}
6
+ */
7
+ export declare enum NOTIFY_CUSTOMER {
8
+ /**
9
+ * Request to page to reload
10
+ */
11
+ EMA_RELOAD_PAGE = "ema-reload-page",
12
+ /**
13
+ * Request the bounds for the elements
14
+ */
15
+ EMA_REQUEST_BOUNDS = "ema-request-bounds",
16
+ /**
17
+ * Received pong from the editor
18
+ */
19
+ EMA_EDITOR_PONG = "ema-editor-pong",
20
+ /**
21
+ * Received scroll event trigger from the editor
22
+ */
23
+ EMA_SCROLL_INSIDE_IFRAME = "scroll-inside-iframe"
24
+ }
25
+ type ListenerCallbackMessage = (event: MessageEvent) => void;
26
+ type ListenerCallbackPointer = (event: PointerEvent) => void;
27
+ /**
28
+ * Listener for the dotcms editor
29
+ *
30
+ * @interface DotCMSPageEditorListener
31
+ */
32
+ interface DotCMSPageEditorListener {
33
+ type: 'listener';
34
+ event: string;
35
+ callback: ListenerCallbackMessage | ListenerCallbackPointer;
36
+ }
37
+ /**
38
+ * Observer for the dotcms editor
39
+ *
40
+ * @interface DotCMSPageEditorObserver
41
+ */
42
+ interface DotCMSPageEditorObserver {
43
+ type: 'observer';
44
+ observer: MutationObserver;
45
+ }
46
+ export type DotCMSPageEditorSubscription = DotCMSPageEditorListener | DotCMSPageEditorObserver;
47
+ export {};