@dotcms/client 0.0.1-alpha.11 → 0.0.1-alpha.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/package.json +26 -24
  2. package/src/index.js +5 -0
  3. package/src/index.js.map +1 -0
  4. package/src/lib/client/{sdk-js-client.ts → sdk-js-client.d.ts} +13 -121
  5. package/src/lib/client/sdk-js-client.js +148 -0
  6. package/src/lib/client/sdk-js-client.js.map +1 -0
  7. package/src/lib/editor/listeners/listeners.d.ts +46 -0
  8. package/src/lib/editor/listeners/{listeners.ts → listeners.js} +18 -52
  9. package/src/lib/editor/listeners/listeners.js.map +1 -0
  10. package/src/lib/editor/models/{client.model.ts → client.model.d.ts} +9 -13
  11. package/src/lib/editor/models/client.model.js +41 -0
  12. package/src/lib/editor/models/client.model.js.map +1 -0
  13. package/src/lib/editor/models/{editor.model.ts → editor.model.d.ts} +0 -1
  14. package/src/lib/editor/models/editor.model.js +2 -0
  15. package/src/lib/editor/models/editor.model.js.map +1 -0
  16. package/src/lib/editor/models/{listeners.model.ts → listeners.model.d.ts} +5 -8
  17. package/src/lib/editor/models/listeners.model.js +22 -0
  18. package/src/lib/editor/models/listeners.model.js.map +1 -0
  19. package/src/lib/editor/sdk-editor-vtl.d.ts +6 -0
  20. package/src/lib/editor/{sdk-editor-vtl.ts → sdk-editor-vtl.js} +2 -14
  21. package/src/lib/editor/sdk-editor-vtl.js.map +1 -0
  22. package/src/lib/editor/sdk-editor.d.ts +23 -0
  23. package/src/lib/editor/{sdk-editor.ts → sdk-editor.js} +5 -19
  24. package/src/lib/editor/sdk-editor.js.map +1 -0
  25. package/src/lib/editor/utils/editor.utils.d.ts +89 -0
  26. package/src/lib/editor/utils/{editor.utils.ts → editor.utils.js} +21 -70
  27. package/src/lib/editor/utils/editor.utils.js.map +1 -0
  28. package/.eslintrc.json +0 -18
  29. package/jest.config.ts +0 -15
  30. package/project.json +0 -63
  31. package/src/lib/client/sdk-js-client.spec.ts +0 -258
  32. package/src/lib/editor/listeners/listeners.spec.ts +0 -58
  33. package/src/lib/editor/sdk-editor.spec.ts +0 -92
  34. package/src/lib/editor/utils/editor.utils.spec.ts +0 -164
  35. package/tsconfig.json +0 -22
  36. package/tsconfig.lib.json +0 -10
  37. package/tsconfig.spec.json +0 -9
  38. /package/src/{index.ts → index.d.ts} +0 -0
@@ -4,31 +4,29 @@
4
4
  * @export
5
5
  * @enum {number}
6
6
  */
7
- export enum CUSTOMER_ACTIONS {
7
+ export declare enum CUSTOMER_ACTIONS {
8
8
  /**
9
9
  * Tell the dotcms editor that page change
10
10
  */
11
- NAVIGATION_UPDATE = 'set-url',
11
+ NAVIGATION_UPDATE = "set-url",
12
12
  /**
13
13
  * Send the element position of the rows, columnsm containers and contentlets
14
14
  */
15
- SET_BOUNDS = 'set-bounds',
15
+ SET_BOUNDS = "set-bounds",
16
16
  /**
17
17
  * Send the information of the hovered contentlet
18
18
  */
19
- SET_CONTENTLET = 'set-contentlet',
19
+ SET_CONTENTLET = "set-contentlet",
20
20
  /**
21
21
  * Tell the editor that the page is being scrolled
22
22
  */
23
- IFRAME_SCROLL = 'scroll',
23
+ IFRAME_SCROLL = "scroll",
24
24
  /**
25
25
  * Ping the editor to see if the page is inside the editor
26
26
  */
27
- PING_EDITOR = 'ping-editor',
28
-
29
- NOOP = 'noop'
27
+ PING_EDITOR = "ping-editor",
28
+ NOOP = "noop"
30
29
  }
31
-
32
30
  /**
33
31
  * Post message props
34
32
  *
@@ -40,7 +38,6 @@ type PostMessageProps<T> = {
40
38
  action: CUSTOMER_ACTIONS;
41
39
  payload?: T;
42
40
  };
43
-
44
41
  /**
45
42
  * Post message to dotcms page editor
46
43
  *
@@ -48,6 +45,5 @@ type PostMessageProps<T> = {
48
45
  * @template T
49
46
  * @param {PostMessageProps<T>} message
50
47
  */
51
- export function postMessageToEditor<T = unknown>(message: PostMessageProps<T>) {
52
- window.parent.postMessage(message, '*');
53
- }
48
+ export declare function postMessageToEditor<T = unknown>(message: PostMessageProps<T>): void;
49
+ export {};
@@ -0,0 +1,41 @@
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
+ * Ping the editor to see if the page is inside the editor
27
+ */
28
+ CUSTOMER_ACTIONS["PING_EDITOR"] = "ping-editor";
29
+ CUSTOMER_ACTIONS["NOOP"] = "noop";
30
+ })(CUSTOMER_ACTIONS || (CUSTOMER_ACTIONS = {}));
31
+ /**
32
+ * Post message to dotcms page editor
33
+ *
34
+ * @export
35
+ * @template T
36
+ * @param {PostMessageProps<T>} message
37
+ */
38
+ export function postMessageToEditor(message) {
39
+ window.parent.postMessage(message, '*');
40
+ }
41
+ //# 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,gBAuBX;AAvBD,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,+CAA2B,CAAA;IAE3B,iCAAa,CAAA;AACjB,CAAC,EAvBW,gBAAgB,KAAhB,gBAAgB,QAuB3B;AAcD;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CAAc,OAA4B;IACzE,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;AAC5C,CAAC"}
@@ -9,7 +9,6 @@ export interface DotCMSPageEditorConfig {
9
9
  * A callback function that will be called when the page editor needs to be reloaded.
10
10
  */
11
11
  onReload: () => void;
12
-
13
12
  /**
14
13
  * The pathname of the page being edited. Optional.
15
14
  */
@@ -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":""}
@@ -4,24 +4,22 @@
4
4
  * @export
5
5
  * @enum {number}
6
6
  */
7
- export enum NOTIFY_CUSTOMER {
7
+ export declare enum NOTIFY_CUSTOMER {
8
8
  /**
9
9
  * Request to page to reload
10
10
  */
11
- EMA_RELOAD_PAGE = 'ema-reload-page',
11
+ EMA_RELOAD_PAGE = "ema-reload-page",
12
12
  /**
13
13
  * Request the bounds for the elements
14
14
  */
15
- EMA_REQUEST_BOUNDS = 'ema-request-bounds',
15
+ EMA_REQUEST_BOUNDS = "ema-request-bounds",
16
16
  /**
17
17
  * Received pong from the editor
18
18
  */
19
- EMA_EDITOR_PONG = 'ema-editor-pong'
19
+ EMA_EDITOR_PONG = "ema-editor-pong"
20
20
  }
21
-
22
21
  type ListenerCallbackMessage = (event: MessageEvent) => void;
23
22
  type ListenerCallbackPointer = (event: PointerEvent) => void;
24
-
25
23
  /**
26
24
  * Listener for the dotcms editor
27
25
  *
@@ -32,7 +30,6 @@ interface DotCMSPageEditorListener {
32
30
  event: string;
33
31
  callback: ListenerCallbackMessage | ListenerCallbackPointer;
34
32
  }
35
-
36
33
  /**
37
34
  * Observer for the dotcms editor
38
35
  *
@@ -42,5 +39,5 @@ interface DotCMSPageEditorObserver {
42
39
  type: 'observer';
43
40
  observer: MutationObserver;
44
41
  }
45
-
46
42
  export type DotCMSPageEditorSubscription = DotCMSPageEditorListener | DotCMSPageEditorObserver;
43
+ export {};
@@ -0,0 +1,22 @@
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
+ })(NOTIFY_CUSTOMER || (NOTIFY_CUSTOMER = {}));
22
+ //# sourceMappingURL=listeners.model.js.map
@@ -0,0 +1 @@
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,eAaX;AAbD,WAAY,eAAe;IACvB;;OAEG;IACH,sDAAmC,CAAA;IACnC;;OAEG;IACH,4DAAyC,CAAA;IACzC;;OAEG;IACH,sDAAmC,CAAA;AACvC,CAAC,EAbW,eAAe,KAAf,eAAe,QAa1B"}
@@ -0,0 +1,6 @@
1
+ declare global {
2
+ interface Window {
3
+ lastScrollYPosition: number;
4
+ }
5
+ }
6
+ export {};
@@ -1,18 +1,5 @@
1
- import {
2
- listenEditorMessages,
3
- listenHoveredContentlet,
4
- pingEditor,
5
- preserveScrollOnIframe,
6
- scrollHandler
7
- } from './listeners/listeners';
1
+ import { listenEditorMessages, listenHoveredContentlet, pingEditor, preserveScrollOnIframe, scrollHandler } from './listeners/listeners';
8
2
  import { isInsideEditor } from './sdk-editor';
9
-
10
- declare global {
11
- interface Window {
12
- lastScrollYPosition: number;
13
- }
14
- }
15
-
16
3
  /**
17
4
  * This is the main entry point for the SDK VTL.
18
5
  * This is added to VTL Script in the EditPage
@@ -30,3 +17,4 @@ if (isInsideEditor()) {
30
17
  preserveScrollOnIframe();
31
18
  listenHoveredContentlet();
32
19
  }
20
+ //# sourceMappingURL=sdk-editor-vtl.js.map
@@ -0,0 +1 @@
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,UAAU,EACV,sBAAsB,EACtB,aAAa,EAChB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAQ9C;;;;;;;;;GASG;AACH,IAAI,cAAc,EAAE,EAAE,CAAC;IACnB,UAAU,EAAE,CAAC;IACb,oBAAoB,EAAE,CAAC;IACvB,aAAa,EAAE,CAAC;IAChB,sBAAsB,EAAE,CAAC;IACzB,uBAAuB,EAAE,CAAC;AAC9B,CAAC"}
@@ -0,0 +1,23 @@
1
+ import { DotCMSPageEditorConfig } from './models/editor.model';
2
+ /**
3
+ *
4
+ * Updates the navigation in the editor.
5
+ * @param {string} pathname - The pathname to update the navigation with.
6
+ * @memberof DotCMSPageEditor
7
+ */
8
+ export declare function updateNavigation(pathname: string): void;
9
+ /**
10
+ * Checks if the code is running inside an editor.
11
+ * @returns {boolean} Returns true if the code is running inside an editor, otherwise false.
12
+ */
13
+ export declare function isInsideEditor(): boolean;
14
+ /**
15
+ * Initializes the DotCMS page editor.
16
+ *
17
+ * @param conf - Optional configuration for the editor.
18
+ */
19
+ export declare function initEditor(config?: DotCMSPageEditorConfig): void;
20
+ /**
21
+ * Destroys the editor by removing event listeners and disconnecting observers.
22
+ */
23
+ export declare function destroyEditor(): void;
@@ -1,21 +1,12 @@
1
- import {
2
- listenEditorMessages,
3
- listenHoveredContentlet,
4
- pingEditor,
5
- scrollHandler,
6
- subscriptions,
7
- setPageEditorConfig
8
- } from './listeners/listeners';
1
+ import { listenEditorMessages, listenHoveredContentlet, pingEditor, scrollHandler, subscriptions, setPageEditorConfig } from './listeners/listeners';
9
2
  import { CUSTOMER_ACTIONS, postMessageToEditor } from './models/client.model';
10
- import { DotCMSPageEditorConfig } from './models/editor.model';
11
-
12
3
  /**
13
4
  *
14
5
  * Updates the navigation in the editor.
15
6
  * @param {string} pathname - The pathname to update the navigation with.
16
7
  * @memberof DotCMSPageEditor
17
8
  */
18
- export function updateNavigation(pathname: string) {
9
+ export function updateNavigation(pathname) {
19
10
  postMessageToEditor({
20
11
  action: CUSTOMER_ACTIONS.NAVIGATION_UPDATE,
21
12
  payload: {
@@ -23,7 +14,6 @@ export function updateNavigation(pathname: string) {
23
14
  }
24
15
  });
25
16
  }
26
-
27
17
  /**
28
18
  * Checks if the code is running inside an editor.
29
19
  * @returns {boolean} Returns true if the code is running inside an editor, otherwise false.
@@ -32,37 +22,33 @@ export function isInsideEditor() {
32
22
  if (window.parent === window) {
33
23
  return false;
34
24
  }
35
-
36
25
  return true;
37
26
  }
38
-
39
27
  /**
40
28
  * Initializes the DotCMS page editor.
41
29
  *
42
30
  * @param conf - Optional configuration for the editor.
43
31
  */
44
- export function initEditor(config?: DotCMSPageEditorConfig) {
32
+ export function initEditor(config) {
45
33
  if (config) {
46
34
  setPageEditorConfig(config);
47
35
  }
48
-
49
36
  pingEditor();
50
37
  listenEditorMessages();
51
38
  listenHoveredContentlet();
52
39
  scrollHandler();
53
40
  }
54
-
55
41
  /**
56
42
  * Destroys the editor by removing event listeners and disconnecting observers.
57
43
  */
58
44
  export function destroyEditor() {
59
45
  subscriptions.forEach((subscription) => {
60
46
  if (subscription.type === 'listener') {
61
- window.removeEventListener(subscription.event, subscription.callback as EventListener);
47
+ window.removeEventListener(subscription.event, subscription.callback);
62
48
  }
63
-
64
49
  if (subscription.type === 'observer') {
65
50
  subscription.observer.disconnect();
66
51
  }
67
52
  });
68
53
  }
54
+ //# sourceMappingURL=sdk-editor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sdk-editor.js","sourceRoot":"","sources":["../../../../../../../libs/sdk/client/src/lib/editor/sdk-editor.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,oBAAoB,EACpB,uBAAuB,EACvB,UAAU,EACV,aAAa,EACb,aAAa,EACb,mBAAmB,EACtB,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,MAAM,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;QAC3B,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,OAAO,IAAI,CAAC;AAChB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAC,MAA+B;IACtD,IAAI,MAAM,EAAE,CAAC;QACT,mBAAmB,CAAC,MAAM,CAAC,CAAC;IAChC,CAAC;IAED,UAAU,EAAE,CAAC;IACb,oBAAoB,EAAE,CAAC;IACvB,uBAAuB,EAAE,CAAC;IAC1B,aAAa,EAAE,CAAC;AACpB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa;IACzB,aAAa,CAAC,OAAO,CAAC,CAAC,YAAY,EAAE,EAAE;QACnC,IAAI,YAAY,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;YACnC,MAAM,CAAC,mBAAmB,CAAC,YAAY,CAAC,KAAK,EAAE,YAAY,CAAC,QAAyB,CAAC,CAAC;QAC3F,CAAC;QAED,IAAI,YAAY,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;YACnC,YAAY,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;QACvC,CAAC;IACL,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Bound information for a contentlet.
3
+ *
4
+ * @interface ContentletBound
5
+ */
6
+ interface ContentletBound {
7
+ x: number;
8
+ y: number;
9
+ width: number;
10
+ height: number;
11
+ payload: string;
12
+ }
13
+ /**
14
+ * Bound information for a container.
15
+ *
16
+ * @interface ContenainerBound
17
+ */
18
+ interface ContenainerBound {
19
+ x: number;
20
+ y: number;
21
+ width: number;
22
+ height: number;
23
+ payload: {
24
+ container: {
25
+ acceptTypes: string;
26
+ identifier: string;
27
+ maxContentlets: string;
28
+ uuid: string;
29
+ };
30
+ };
31
+ contentlets: ContentletBound[];
32
+ }
33
+ /**
34
+ * Calculates the bounding information for each page element within the given containers.
35
+ *
36
+ * @export
37
+ * @param {HTMLDivElement[]} containers
38
+ * @return {*} An array of objects containing the bounding information for each page element.
39
+ */
40
+ export declare function getPageElementBound(containers: HTMLDivElement[]): ContenainerBound[];
41
+ /**
42
+ * An array of objects containing the bounding information for each contentlet inside a container.
43
+ *
44
+ * @export
45
+ * @param {DOMRect} containerRect
46
+ * @param {HTMLDivElement[]} contentlets
47
+ * @return {*}
48
+ */
49
+ export declare function getContentletsBound(containerRect: DOMRect, contentlets: HTMLDivElement[]): ContentletBound[];
50
+ /**
51
+ * Get container data from VTLS.
52
+ *
53
+ * @export
54
+ * @param {HTMLElement} container
55
+ * @return {*}
56
+ */
57
+ export declare function getContainerData(container: HTMLElement): {
58
+ acceptTypes: string;
59
+ identifier: string;
60
+ maxContentlets: string;
61
+ uuid: string;
62
+ };
63
+ /**
64
+ * Get the closest container data from the contentlet.
65
+ *
66
+ * @export
67
+ * @param {Element} element
68
+ * @return {*}
69
+ */
70
+ export declare function getClosestContainerData(element: Element): {
71
+ acceptTypes: string;
72
+ identifier: string;
73
+ maxContentlets: string;
74
+ uuid: string;
75
+ } | null;
76
+ /**
77
+ * Find the closest contentlet element based on HTMLElement.
78
+ *
79
+ * @export
80
+ * @param {(HTMLElement | null)} element
81
+ * @return {*}
82
+ */
83
+ export declare function findContentletElement(element: HTMLElement | null): HTMLElement | null;
84
+ export declare function findVTLElement(element: HTMLElement | null): HTMLElement | null;
85
+ export declare function findVTLData(target: HTMLElement): {
86
+ inode: string | undefined;
87
+ name: string | undefined;
88
+ }[] | null;
89
+ export {};
@@ -1,37 +1,3 @@
1
- /**
2
- * Bound information for a contentlet.
3
- *
4
- * @interface ContentletBound
5
- */
6
- interface ContentletBound {
7
- x: number;
8
- y: number;
9
- width: number;
10
- height: number;
11
- payload: string;
12
- }
13
-
14
- /**
15
- * Bound information for a container.
16
- *
17
- * @interface ContenainerBound
18
- */
19
- interface ContenainerBound {
20
- x: number;
21
- y: number;
22
- width: number;
23
- height: number;
24
- payload: {
25
- container: {
26
- acceptTypes: string;
27
- identifier: string;
28
- maxContentlets: string;
29
- uuid: string;
30
- };
31
- };
32
- contentlets: ContentletBound[];
33
- }
34
-
35
1
  /**
36
2
  * Calculates the bounding information for each page element within the given containers.
37
3
  *
@@ -39,13 +5,10 @@ interface ContenainerBound {
39
5
  * @param {HTMLDivElement[]} containers
40
6
  * @return {*} An array of objects containing the bounding information for each page element.
41
7
  */
42
- export function getPageElementBound(containers: HTMLDivElement[]): ContenainerBound[] {
8
+ export function getPageElementBound(containers) {
43
9
  return containers.map((container) => {
44
10
  const containerRect = container.getBoundingClientRect();
45
- const contentlets = Array.from(
46
- container.querySelectorAll('[data-dot-object="contentlet"]')
47
- ) as HTMLDivElement[];
48
-
11
+ const contentlets = Array.from(container.querySelectorAll('[data-dot-object="contentlet"]'));
49
12
  return {
50
13
  x: containerRect.x,
51
14
  y: containerRect.y,
@@ -58,7 +21,6 @@ export function getPageElementBound(containers: HTMLDivElement[]): ContenainerBo
58
21
  };
59
22
  });
60
23
  }
61
-
62
24
  /**
63
25
  * An array of objects containing the bounding information for each contentlet inside a container.
64
26
  *
@@ -67,13 +29,9 @@ export function getPageElementBound(containers: HTMLDivElement[]): ContenainerBo
67
29
  * @param {HTMLDivElement[]} contentlets
68
30
  * @return {*}
69
31
  */
70
- export function getContentletsBound(
71
- containerRect: DOMRect,
72
- contentlets: HTMLDivElement[]
73
- ): ContentletBound[] {
32
+ export function getContentletsBound(containerRect, contentlets) {
74
33
  return contentlets.map((contentlet) => {
75
34
  const contentletRect = contentlet.getBoundingClientRect();
76
-
77
35
  return {
78
36
  x: 0,
79
37
  y: contentletRect.y - containerRect.y,
@@ -93,7 +51,6 @@ export function getContentletsBound(
93
51
  };
94
52
  });
95
53
  }
96
-
97
54
  /**
98
55
  * Get container data from VTLS.
99
56
  *
@@ -101,7 +58,7 @@ export function getContentletsBound(
101
58
  * @param {HTMLElement} container
102
59
  * @return {*}
103
60
  */
104
- export function getContainerData(container: HTMLElement) {
61
+ export function getContainerData(container) {
105
62
  return {
106
63
  acceptTypes: container.dataset?.['dotAcceptTypes'] || '',
107
64
  identifier: container.dataset?.['dotIdentifier'] || '',
@@ -109,7 +66,6 @@ export function getContainerData(container: HTMLElement) {
109
66
  uuid: container.dataset?.['dotUuid'] || ''
110
67
  };
111
68
  }
112
-
113
69
  /**
114
70
  * Get the closest container data from the contentlet.
115
71
  *
@@ -117,22 +73,20 @@ export function getContainerData(container: HTMLElement) {
117
73
  * @param {Element} element
118
74
  * @return {*}
119
75
  */
120
- export function getClosestContainerData(element: Element) {
76
+ export function getClosestContainerData(element) {
121
77
  // Find the closest ancestor element with data-dot-object="container" attribute
122
- const container = element.closest('[data-dot-object="container"]') as HTMLElement;
123
-
78
+ const container = element.closest('[data-dot-object="container"]');
124
79
  // If a container element is found
125
80
  if (container) {
126
81
  // Return the dataset of the container element
127
82
  return getContainerData(container);
128
- } else {
83
+ }
84
+ else {
129
85
  // If no container element is found, return null
130
86
  console.warn('No container found for the contentlet');
131
-
132
87
  return null;
133
88
  }
134
89
  }
135
-
136
90
  /**
137
91
  * Find the closest contentlet element based on HTMLElement.
138
92
  *
@@ -140,35 +94,31 @@ export function getClosestContainerData(element: Element) {
140
94
  * @param {(HTMLElement | null)} element
141
95
  * @return {*}
142
96
  */
143
- export function findContentletElement(element: HTMLElement | null): HTMLElement | null {
144
- if (!element) return null;
145
-
97
+ export function findContentletElement(element) {
98
+ if (!element)
99
+ return null;
146
100
  if (element.dataset && element.dataset?.['dotObject'] === 'contentlet') {
147
101
  return element;
148
- } else {
102
+ }
103
+ else {
149
104
  return findContentletElement(element?.['parentElement']);
150
105
  }
151
106
  }
152
-
153
- export function findVTLElement(element: HTMLElement | null): HTMLElement | null {
154
- if (!element) return null;
155
-
107
+ export function findVTLElement(element) {
108
+ if (!element)
109
+ return null;
156
110
  if (element.dataset && element.dataset?.['dotObject'] === 'vtl-file') {
157
111
  return element;
158
- } else {
112
+ }
113
+ else {
159
114
  return findContentletElement(element?.['parentElement']);
160
115
  }
161
116
  }
162
-
163
- export function findVTLData(target: HTMLElement) {
164
- const vltElements = target.querySelectorAll(
165
- '[data-dot-object="vtl-file"]'
166
- ) as NodeListOf<HTMLElement>;
167
-
117
+ export function findVTLData(target) {
118
+ const vltElements = target.querySelectorAll('[data-dot-object="vtl-file"]');
168
119
  if (!vltElements.length) {
169
120
  return null;
170
121
  }
171
-
172
122
  return Array.from(vltElements).map((vltElement) => {
173
123
  return {
174
124
  inode: vltElement.dataset?.['dotInode'],
@@ -176,3 +126,4 @@ export function findVTLData(target: HTMLElement) {
176
126
  };
177
127
  });
178
128
  }
129
+ //# sourceMappingURL=editor.utils.js.map
@@ -0,0 +1 @@
1
+ {"version":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7
- "rules": {}
8
- },
9
- {
10
- "files": ["*.ts", "*.tsx"],
11
- "rules": {}
12
- },
13
- {
14
- "files": ["*.js", "*.jsx"],
15
- "rules": {}
16
- }
17
- ]
18
- }
package/jest.config.ts DELETED
@@ -1,15 +0,0 @@
1
- /* eslint-disable */
2
- export default {
3
- displayName: 'sdk-client',
4
- preset: '../../../jest.preset.js',
5
- globals: {
6
- 'ts-jest': {
7
- tsconfig: '<rootDir>/tsconfig.spec.json'
8
- }
9
- },
10
- transform: {
11
- '^.+\\.[tj]s$': 'ts-jest'
12
- },
13
- moduleFileExtensions: ['ts', 'js', 'html'],
14
- coverageDirectory: '../../../coverage/libs/sdk/client'
15
- };