@dotcms/client 0.0.1-alpha.3 → 0.0.1-alpha.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -1
- package/package.json +7 -3
- package/src/index.d.ts +6 -2
- package/src/index.js +6 -2
- package/src/index.js.map +1 -1
- package/src/lib/client/content/builders/collection/collection.d.ts +148 -0
- package/src/lib/client/content/builders/collection/collection.js +264 -0
- package/src/lib/client/content/builders/collection/collection.js.map +1 -0
- package/src/lib/client/content/content-api.d.ts +78 -0
- package/src/lib/client/content/content-api.js +87 -0
- package/src/lib/client/content/content-api.js.map +1 -0
- package/src/lib/client/content/shared/const.d.ts +3 -0
- package/src/lib/client/content/shared/const.js +5 -0
- package/src/lib/client/content/shared/const.js.map +1 -0
- package/src/lib/client/content/shared/types.d.ts +62 -0
- package/src/lib/client/content/shared/types.js +2 -0
- package/src/lib/client/content/shared/types.js.map +1 -0
- package/src/lib/client/content/shared/utils.d.ts +12 -0
- package/src/lib/client/content/shared/utils.js +20 -0
- package/src/lib/client/content/shared/utils.js.map +1 -0
- package/src/lib/client/models/index.d.ts +1 -0
- package/src/lib/client/models/index.js +9 -0
- package/src/lib/client/models/index.js.map +1 -0
- package/src/lib/client/models/types.d.ts +5 -0
- package/src/lib/client/models/types.js +2 -0
- package/src/lib/client/models/types.js.map +1 -0
- package/src/lib/{sdk-js-client.d.ts → client/sdk-js-client.d.ts} +33 -23
- package/src/lib/{sdk-js-client.js → client/sdk-js-client.js} +87 -38
- package/src/lib/client/sdk-js-client.js.map +1 -0
- package/src/lib/editor/listeners/listeners.d.ts +46 -0
- package/src/lib/editor/listeners/listeners.js +180 -0
- package/src/lib/editor/listeners/listeners.js.map +1 -0
- package/src/lib/{postMessageToEditor.d.ts → editor/models/client.model.d.ts} +33 -1
- package/src/lib/editor/models/client.model.js +73 -0
- package/src/lib/editor/models/client.model.js.map +1 -0
- package/src/lib/editor/models/editor.model.d.ts +49 -0
- package/src/lib/editor/models/editor.model.js +2 -0
- package/src/lib/editor/models/editor.model.js.map +1 -0
- package/src/lib/editor/models/listeners.model.d.ts +47 -0
- package/src/lib/editor/models/listeners.model.js +26 -0
- package/src/lib/editor/models/listeners.model.js.map +1 -0
- package/src/lib/editor/sdk-editor-vtl.d.ts +6 -0
- package/src/lib/editor/sdk-editor-vtl.js +20 -0
- package/src/lib/editor/sdk-editor-vtl.js.map +1 -0
- package/src/lib/editor/sdk-editor.d.ts +29 -0
- package/src/lib/editor/sdk-editor.js +65 -0
- package/src/lib/editor/sdk-editor.js.map +1 -0
- package/src/lib/editor/utils/editor.utils.d.ts +83 -0
- package/src/lib/editor/utils/editor.utils.js +134 -0
- package/src/lib/editor/utils/editor.utils.js.map +1 -0
- package/src/lib/query-builder/lucene-syntax/Equals.d.ts +83 -0
- package/src/lib/query-builder/lucene-syntax/Equals.js +101 -0
- package/src/lib/query-builder/lucene-syntax/Equals.js.map +1 -0
- package/src/lib/query-builder/lucene-syntax/Field.d.ts +23 -0
- package/src/lib/query-builder/lucene-syntax/Field.js +31 -0
- package/src/lib/query-builder/lucene-syntax/Field.js.map +1 -0
- package/src/lib/query-builder/lucene-syntax/NotOperand.d.ts +22 -0
- package/src/lib/query-builder/lucene-syntax/NotOperand.js +30 -0
- package/src/lib/query-builder/lucene-syntax/NotOperand.js.map +1 -0
- package/src/lib/query-builder/lucene-syntax/Operand.d.ts +44 -0
- package/src/lib/query-builder/lucene-syntax/Operand.js +55 -0
- package/src/lib/query-builder/lucene-syntax/Operand.js.map +1 -0
- package/src/lib/query-builder/lucene-syntax/index.d.ts +4 -0
- package/src/lib/query-builder/lucene-syntax/index.js +5 -0
- package/src/lib/query-builder/lucene-syntax/index.js.map +1 -0
- package/src/lib/query-builder/sdk-query-builder.d.ts +42 -0
- package/src/lib/query-builder/sdk-query-builder.js +54 -0
- package/src/lib/query-builder/sdk-query-builder.js.map +1 -0
- package/src/lib/query-builder/utils/index.d.ts +91 -0
- package/src/lib/query-builder/utils/index.js +115 -0
- package/src/lib/query-builder/utils/index.js.map +1 -0
- package/src/lib/utils/graphql/transforms.d.ts +11 -0
- package/src/lib/utils/graphql/transforms.js +52 -0
- package/src/lib/utils/graphql/transforms.js.map +1 -0
- package/src/lib/utils/index.d.ts +2 -0
- package/src/lib/utils/index.js +3 -0
- package/src/lib/utils/index.js.map +1 -0
- package/src/lib/utils/page/common-utils.d.ts +14 -0
- package/src/lib/utils/page/common-utils.js +12 -0
- package/src/lib/utils/page/common-utils.js.map +1 -0
- package/src/lib/postMessageToEditor.js +0 -41
- package/src/lib/postMessageToEditor.js.map +0 -1
- package/src/lib/sdk-js-client.js.map +0 -1
|
@@ -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;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,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;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB;IAChC,MAAM,eAAe,GAAG,CAAC,KAAmB,EAAE,EAAE;QAC5C,QAAQ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AC,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"}
|
|
@@ -8,7 +8,7 @@ export declare enum CUSTOMER_ACTIONS {
|
|
|
8
8
|
/**
|
|
9
9
|
* Tell the dotcms editor that page change
|
|
10
10
|
*/
|
|
11
|
-
|
|
11
|
+
NAVIGATION_UPDATE = "set-url",
|
|
12
12
|
/**
|
|
13
13
|
* Send the element position of the rows, columnsm containers and contentlets
|
|
14
14
|
*/
|
|
@@ -21,10 +21,42 @@ 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",
|
|
24
28
|
/**
|
|
25
29
|
* Ping the editor to see if the page is inside the editor
|
|
26
30
|
*/
|
|
27
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",
|
|
49
|
+
/**
|
|
50
|
+
* Tell the editor to send the page info to iframe
|
|
51
|
+
*/
|
|
52
|
+
GET_PAGE_DATA = "get-page-data",
|
|
53
|
+
/**
|
|
54
|
+
* Tell the editor an user send a graphql query
|
|
55
|
+
*/
|
|
56
|
+
CLIENT_READY = "client-ready",
|
|
57
|
+
/**
|
|
58
|
+
* Tell the editor to do nothing
|
|
59
|
+
*/
|
|
28
60
|
NOOP = "noop"
|
|
29
61
|
}
|
|
30
62
|
/**
|
|
@@ -0,0 +1,73 @@
|
|
|
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
|
|
@@ -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,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"}
|
|
@@ -0,0 +1,49 @@
|
|
|
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
|
+
}
|
|
@@ -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 {};
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
|
@@ -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,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"}
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
|
@@ -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,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"}
|
|
@@ -0,0 +1,29 @@
|
|
|
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;
|
|
24
|
+
/**
|
|
25
|
+
* Adds a class to empty contentlets.
|
|
26
|
+
*
|
|
27
|
+
* @export
|
|
28
|
+
*/
|
|
29
|
+
export declare function addClassToEmptyContentlets(): void;
|
|
@@ -0,0 +1,65 @@
|
|
|
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
|
|
@@ -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,0BAA0B,E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H,MAAM,UAAU,0BAA0B;IACtC,MAAM,WAAW,GAAG,QAAQ,CAAC,gBAAgB,CAAC,gCAAgC,CAAC,CAAC;IAEhF,WAAW,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE;QAC/B,IAAI,UAAU,CAAC,YAAY,EAAE,CAAC;YAC1B,OAAO;QACX,CAAC;QAED,UAAU,CAAC,SAAS,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;IACjD,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
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 ContainerBound
|
|
17
|
+
*/
|
|
18
|
+
interface ContainerBound {
|
|
19
|
+
x: number;
|
|
20
|
+
y: number;
|
|
21
|
+
width: number;
|
|
22
|
+
height: number;
|
|
23
|
+
payload: string;
|
|
24
|
+
contentlets: ContentletBound[];
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Calculates the bounding information for each page element within the given containers.
|
|
28
|
+
*
|
|
29
|
+
* @export
|
|
30
|
+
* @param {HTMLDivElement[]} containers
|
|
31
|
+
* @return {*} An array of objects containing the bounding information for each page element.
|
|
32
|
+
*/
|
|
33
|
+
export declare function getPageElementBound(containers: HTMLDivElement[]): ContainerBound[];
|
|
34
|
+
/**
|
|
35
|
+
* An array of objects containing the bounding information for each contentlet inside a container.
|
|
36
|
+
*
|
|
37
|
+
* @export
|
|
38
|
+
* @param {DOMRect} containerRect
|
|
39
|
+
* @param {HTMLDivElement[]} contentlets
|
|
40
|
+
* @return {*}
|
|
41
|
+
*/
|
|
42
|
+
export declare function getContentletsBound(containerRect: DOMRect, contentlets: HTMLDivElement[]): ContentletBound[];
|
|
43
|
+
/**
|
|
44
|
+
* Get container data from VTLS.
|
|
45
|
+
*
|
|
46
|
+
* @export
|
|
47
|
+
* @param {HTMLElement} container
|
|
48
|
+
* @return {*}
|
|
49
|
+
*/
|
|
50
|
+
export declare function getContainerData(container: HTMLElement): {
|
|
51
|
+
acceptTypes: string;
|
|
52
|
+
identifier: string;
|
|
53
|
+
maxContentlets: string;
|
|
54
|
+
uuid: string;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Get the closest container data from the contentlet.
|
|
58
|
+
*
|
|
59
|
+
* @export
|
|
60
|
+
* @param {Element} element
|
|
61
|
+
* @return {*}
|
|
62
|
+
*/
|
|
63
|
+
export declare function getClosestContainerData(element: Element): {
|
|
64
|
+
acceptTypes: string;
|
|
65
|
+
identifier: string;
|
|
66
|
+
maxContentlets: string;
|
|
67
|
+
uuid: string;
|
|
68
|
+
} | null;
|
|
69
|
+
/**
|
|
70
|
+
* Find the closest contentlet element based on HTMLElement.
|
|
71
|
+
*
|
|
72
|
+
* @export
|
|
73
|
+
* @param {(HTMLElement | null)} element
|
|
74
|
+
* @return {*}
|
|
75
|
+
*/
|
|
76
|
+
export declare function findDotElement(element: HTMLElement | null): HTMLElement | null;
|
|
77
|
+
export declare function findDotVTLElement(element: HTMLElement | null): HTMLElement | null;
|
|
78
|
+
export declare function findVTLData(target: HTMLElement): {
|
|
79
|
+
inode: string | undefined;
|
|
80
|
+
name: string | undefined;
|
|
81
|
+
}[] | null;
|
|
82
|
+
export declare function scrollIsInBottom(): boolean;
|
|
83
|
+
export {};
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calculates the bounding information for each page element within the given containers.
|
|
3
|
+
*
|
|
4
|
+
* @export
|
|
5
|
+
* @param {HTMLDivElement[]} containers
|
|
6
|
+
* @return {*} An array of objects containing the bounding information for each page element.
|
|
7
|
+
*/
|
|
8
|
+
export function getPageElementBound(containers) {
|
|
9
|
+
return containers.map((container) => {
|
|
10
|
+
const containerRect = container.getBoundingClientRect();
|
|
11
|
+
const contentlets = Array.from(container.querySelectorAll('[data-dot-object="contentlet"]'));
|
|
12
|
+
return {
|
|
13
|
+
x: containerRect.x,
|
|
14
|
+
y: containerRect.y,
|
|
15
|
+
width: containerRect.width,
|
|
16
|
+
height: containerRect.height,
|
|
17
|
+
payload: JSON.stringify({
|
|
18
|
+
container: getContainerData(container)
|
|
19
|
+
}),
|
|
20
|
+
contentlets: getContentletsBound(containerRect, contentlets)
|
|
21
|
+
};
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* An array of objects containing the bounding information for each contentlet inside a container.
|
|
26
|
+
*
|
|
27
|
+
* @export
|
|
28
|
+
* @param {DOMRect} containerRect
|
|
29
|
+
* @param {HTMLDivElement[]} contentlets
|
|
30
|
+
* @return {*}
|
|
31
|
+
*/
|
|
32
|
+
export function getContentletsBound(containerRect, contentlets) {
|
|
33
|
+
return contentlets.map((contentlet) => {
|
|
34
|
+
const contentletRect = contentlet.getBoundingClientRect();
|
|
35
|
+
return {
|
|
36
|
+
x: 0,
|
|
37
|
+
y: contentletRect.y - containerRect.y,
|
|
38
|
+
width: contentletRect.width,
|
|
39
|
+
height: contentletRect.height,
|
|
40
|
+
payload: JSON.stringify({
|
|
41
|
+
container: contentlet.dataset?.['dotContainer']
|
|
42
|
+
? JSON.parse(contentlet.dataset?.['dotContainer'])
|
|
43
|
+
: getClosestContainerData(contentlet),
|
|
44
|
+
contentlet: {
|
|
45
|
+
identifier: contentlet.dataset?.['dotIdentifier'],
|
|
46
|
+
title: contentlet.dataset?.['dotTitle'],
|
|
47
|
+
inode: contentlet.dataset?.['dotInode'],
|
|
48
|
+
contentType: contentlet.dataset?.['dotType']
|
|
49
|
+
}
|
|
50
|
+
})
|
|
51
|
+
};
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Get container data from VTLS.
|
|
56
|
+
*
|
|
57
|
+
* @export
|
|
58
|
+
* @param {HTMLElement} container
|
|
59
|
+
* @return {*}
|
|
60
|
+
*/
|
|
61
|
+
export function getContainerData(container) {
|
|
62
|
+
return {
|
|
63
|
+
acceptTypes: container.dataset?.['dotAcceptTypes'] || '',
|
|
64
|
+
identifier: container.dataset?.['dotIdentifier'] || '',
|
|
65
|
+
maxContentlets: container.dataset?.['maxContentlets'] || '',
|
|
66
|
+
uuid: container.dataset?.['dotUuid'] || ''
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Get the closest container data from the contentlet.
|
|
71
|
+
*
|
|
72
|
+
* @export
|
|
73
|
+
* @param {Element} element
|
|
74
|
+
* @return {*}
|
|
75
|
+
*/
|
|
76
|
+
export function getClosestContainerData(element) {
|
|
77
|
+
// Find the closest ancestor element with data-dot-object="container" attribute
|
|
78
|
+
const container = element.closest('[data-dot-object="container"]');
|
|
79
|
+
// If a container element is found
|
|
80
|
+
if (container) {
|
|
81
|
+
// Return the dataset of the container element
|
|
82
|
+
return getContainerData(container);
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
// If no container element is found, return null
|
|
86
|
+
console.warn('No container found for the contentlet');
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Find the closest contentlet element based on HTMLElement.
|
|
92
|
+
*
|
|
93
|
+
* @export
|
|
94
|
+
* @param {(HTMLElement | null)} element
|
|
95
|
+
* @return {*}
|
|
96
|
+
*/
|
|
97
|
+
export function findDotElement(element) {
|
|
98
|
+
if (!element)
|
|
99
|
+
return null;
|
|
100
|
+
if (element?.dataset?.['dotObject'] === 'contentlet' ||
|
|
101
|
+
(element?.dataset?.['dotObject'] === 'container' && element.children.length === 0)) {
|
|
102
|
+
return element;
|
|
103
|
+
}
|
|
104
|
+
return findDotElement(element?.['parentElement']);
|
|
105
|
+
}
|
|
106
|
+
export function findDotVTLElement(element) {
|
|
107
|
+
if (!element)
|
|
108
|
+
return null;
|
|
109
|
+
if (element.dataset && element.dataset?.['dotObject'] === 'vtl-file') {
|
|
110
|
+
return element;
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
return findDotElement(element?.['parentElement']);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
export function findVTLData(target) {
|
|
117
|
+
const vltElements = target.querySelectorAll('[data-dot-object="vtl-file"]');
|
|
118
|
+
if (!vltElements.length) {
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
return Array.from(vltElements).map((vltElement) => {
|
|
122
|
+
return {
|
|
123
|
+
inode: vltElement.dataset?.['dotInode'],
|
|
124
|
+
name: vltElement.dataset?.['dotUrl']
|
|
125
|
+
};
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
export function scrollIsInBottom() {
|
|
129
|
+
const documentHeight = document.documentElement.scrollHeight;
|
|
130
|
+
const viewportHeight = window.innerHeight;
|
|
131
|
+
const scrollY = window.scrollY;
|
|
132
|
+
return scrollY + viewportHeight >= documentHeight;
|
|
133
|
+
}
|
|
134
|
+
//# sourceMappingURL=editor.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editor.utils.js","sourceRoot":"","sources":["../../../../../../../../libs/sdk/client/src/lib/editor/utils/editor.utils.ts"],"names":[],"mappings":"AA2BA;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CAAC,UAA4B;IAC5D,OAAO,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE;QAChC,MAAM,aAAa,GAAG,SAAS,CAAC,qBAAqB,EAAE,CAAC;QACxD,MAAM,WAAW,GAAG,KAAK,CAAC,IAAI,CAC1B,SAAS,CAAC,gBAAgB,CAAC,gCAAgC,CAAC,CAC3C,CAAC;QAEtB,OAAO;YACH,CAAC,EAAE,aAAa,CAAC,CAAC;Y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