@dotcms/client 0.0.1-alpha.55 → 0.0.1-alpha.56
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/index.cjs.js +22 -8
- package/index.esm.js +23 -9
- package/package.json +1 -1
- package/src/index.d.ts +2 -2
- package/src/lib/editor/models/editor.model.d.ts +4 -0
- package/src/lib/editor/sdk-editor.d.ts +10 -4
package/index.cjs.js
CHANGED
|
@@ -1599,6 +1599,12 @@ const parseContentletsToUuidMap = (containerContentlets = []) => {
|
|
|
1599
1599
|
}, {});
|
|
1600
1600
|
};
|
|
1601
1601
|
|
|
1602
|
+
exports.UVE_MODE = void 0;
|
|
1603
|
+
(function (UVE_MODE) {
|
|
1604
|
+
UVE_MODE["EDIT"] = "edit";
|
|
1605
|
+
UVE_MODE["PREVIEW"] = "preview";
|
|
1606
|
+
})(exports.UVE_MODE || (exports.UVE_MODE = {}));
|
|
1607
|
+
|
|
1602
1608
|
/**
|
|
1603
1609
|
* Generates the page request parameters to be used in the API call.
|
|
1604
1610
|
*
|
|
@@ -1625,6 +1631,9 @@ const getPageRequestParams = ({ path = '', params = {} }) => {
|
|
|
1625
1631
|
if (copiedParams['personaId'] || dotMarketingPersonaId) {
|
|
1626
1632
|
finalParams['personaId'] = copiedParams['personaId'] || dotMarketingPersonaId;
|
|
1627
1633
|
}
|
|
1634
|
+
if (copiedParams['publishDate']) {
|
|
1635
|
+
finalParams['publishDate'] = copiedParams['publishDate'];
|
|
1636
|
+
}
|
|
1628
1637
|
return {
|
|
1629
1638
|
path,
|
|
1630
1639
|
...finalParams
|
|
@@ -1637,8 +1646,8 @@ const getPageRequestParams = ({ path = '', params = {} }) => {
|
|
|
1637
1646
|
*/
|
|
1638
1647
|
const isPreviewMode = () => {
|
|
1639
1648
|
const queryParams = new URLSearchParams(window.location.search);
|
|
1640
|
-
const
|
|
1641
|
-
return
|
|
1649
|
+
const editorMode = queryParams.get('editorMode');
|
|
1650
|
+
return editorMode === exports.UVE_MODE.PREVIEW;
|
|
1642
1651
|
};
|
|
1643
1652
|
|
|
1644
1653
|
/**
|
|
@@ -1714,15 +1723,21 @@ function reorderMenu(config) {
|
|
|
1714
1723
|
});
|
|
1715
1724
|
}
|
|
1716
1725
|
/**
|
|
1717
|
-
* Checks if the code is running inside
|
|
1726
|
+
* Checks if the code is running inside the DotCMS Universal Visual Editor (UVE).
|
|
1727
|
+
*
|
|
1728
|
+
* The function checks three conditions:
|
|
1729
|
+
* 1. If window is defined (for SSR environments)
|
|
1730
|
+
* 2. If the page is not in preview mode
|
|
1731
|
+
* 3. If the current window is embedded in a parent frame
|
|
1718
1732
|
*
|
|
1719
|
-
* @returns {boolean} Returns true if the
|
|
1733
|
+
* @returns {boolean} Returns true if running inside the UVE editor, false if running standalone or in preview mode
|
|
1720
1734
|
* @example
|
|
1721
1735
|
* ```ts
|
|
1736
|
+
* // Check if code is running in editor before initializing editor-specific features
|
|
1722
1737
|
* if (isInsideEditor()) {
|
|
1723
|
-
*
|
|
1738
|
+
* initEditor(config);
|
|
1724
1739
|
* } else {
|
|
1725
|
-
*
|
|
1740
|
+
* initStandaloneMode();
|
|
1726
1741
|
* }
|
|
1727
1742
|
* ```
|
|
1728
1743
|
*/
|
|
@@ -1730,8 +1745,7 @@ function isInsideEditor() {
|
|
|
1730
1745
|
if (typeof window === 'undefined') {
|
|
1731
1746
|
return false;
|
|
1732
1747
|
}
|
|
1733
|
-
|
|
1734
|
-
if (preview) {
|
|
1748
|
+
if (isPreviewMode()) {
|
|
1735
1749
|
return false;
|
|
1736
1750
|
}
|
|
1737
1751
|
return window.parent !== window;
|
package/index.esm.js
CHANGED
|
@@ -1597,6 +1597,12 @@ const parseContentletsToUuidMap = (containerContentlets = []) => {
|
|
|
1597
1597
|
}, {});
|
|
1598
1598
|
};
|
|
1599
1599
|
|
|
1600
|
+
var UVE_MODE;
|
|
1601
|
+
(function (UVE_MODE) {
|
|
1602
|
+
UVE_MODE["EDIT"] = "edit";
|
|
1603
|
+
UVE_MODE["PREVIEW"] = "preview";
|
|
1604
|
+
})(UVE_MODE || (UVE_MODE = {}));
|
|
1605
|
+
|
|
1600
1606
|
/**
|
|
1601
1607
|
* Generates the page request parameters to be used in the API call.
|
|
1602
1608
|
*
|
|
@@ -1623,6 +1629,9 @@ const getPageRequestParams = ({ path = '', params = {} }) => {
|
|
|
1623
1629
|
if (copiedParams['personaId'] || dotMarketingPersonaId) {
|
|
1624
1630
|
finalParams['personaId'] = copiedParams['personaId'] || dotMarketingPersonaId;
|
|
1625
1631
|
}
|
|
1632
|
+
if (copiedParams['publishDate']) {
|
|
1633
|
+
finalParams['publishDate'] = copiedParams['publishDate'];
|
|
1634
|
+
}
|
|
1626
1635
|
return {
|
|
1627
1636
|
path,
|
|
1628
1637
|
...finalParams
|
|
@@ -1635,8 +1644,8 @@ const getPageRequestParams = ({ path = '', params = {} }) => {
|
|
|
1635
1644
|
*/
|
|
1636
1645
|
const isPreviewMode = () => {
|
|
1637
1646
|
const queryParams = new URLSearchParams(window.location.search);
|
|
1638
|
-
const
|
|
1639
|
-
return
|
|
1647
|
+
const editorMode = queryParams.get('editorMode');
|
|
1648
|
+
return editorMode === UVE_MODE.PREVIEW;
|
|
1640
1649
|
};
|
|
1641
1650
|
|
|
1642
1651
|
/**
|
|
@@ -1712,15 +1721,21 @@ function reorderMenu(config) {
|
|
|
1712
1721
|
});
|
|
1713
1722
|
}
|
|
1714
1723
|
/**
|
|
1715
|
-
* Checks if the code is running inside
|
|
1724
|
+
* Checks if the code is running inside the DotCMS Universal Visual Editor (UVE).
|
|
1725
|
+
*
|
|
1726
|
+
* The function checks three conditions:
|
|
1727
|
+
* 1. If window is defined (for SSR environments)
|
|
1728
|
+
* 2. If the page is not in preview mode
|
|
1729
|
+
* 3. If the current window is embedded in a parent frame
|
|
1716
1730
|
*
|
|
1717
|
-
* @returns {boolean} Returns true if the
|
|
1731
|
+
* @returns {boolean} Returns true if running inside the UVE editor, false if running standalone or in preview mode
|
|
1718
1732
|
* @example
|
|
1719
1733
|
* ```ts
|
|
1734
|
+
* // Check if code is running in editor before initializing editor-specific features
|
|
1720
1735
|
* if (isInsideEditor()) {
|
|
1721
|
-
*
|
|
1736
|
+
* initEditor(config);
|
|
1722
1737
|
* } else {
|
|
1723
|
-
*
|
|
1738
|
+
* initStandaloneMode();
|
|
1724
1739
|
* }
|
|
1725
1740
|
* ```
|
|
1726
1741
|
*/
|
|
@@ -1728,8 +1743,7 @@ function isInsideEditor() {
|
|
|
1728
1743
|
if (typeof window === 'undefined') {
|
|
1729
1744
|
return false;
|
|
1730
1745
|
}
|
|
1731
|
-
|
|
1732
|
-
if (preview) {
|
|
1746
|
+
if (isPreviewMode()) {
|
|
1733
1747
|
return false;
|
|
1734
1748
|
}
|
|
1735
1749
|
return window.parent !== window;
|
|
@@ -2040,4 +2054,4 @@ class DotCmsClient {
|
|
|
2040
2054
|
}
|
|
2041
2055
|
_DotCmsClient_config = new WeakMap(), _DotCmsClient_requestOptions = new WeakMap(), _DotCmsClient_listeners = new WeakMap();
|
|
2042
2056
|
|
|
2043
|
-
export { CLIENT_ACTIONS, DotCmsClient, NOTIFY_CLIENT, destroyEditor, editContentlet, getPageRequestParams, graphqlToPageEntity, initEditor, initInlineEditing, isInsideEditor, postMessageToEditor, reorderMenu, updateNavigation };
|
|
2057
|
+
export { CLIENT_ACTIONS, DotCmsClient, NOTIFY_CLIENT, UVE_MODE, destroyEditor, editContentlet, getPageRequestParams, graphqlToPageEntity, initEditor, initInlineEditing, isInsideEditor, postMessageToEditor, reorderMenu, updateNavigation };
|
package/package.json
CHANGED
package/src/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ClientConfig, DotCmsClient } from './lib/client/sdk-js-client';
|
|
2
2
|
import { CLIENT_ACTIONS, postMessageToEditor } from './lib/editor/models/client.model';
|
|
3
|
-
import { CustomClientParams, DotCMSPageEditorConfig, EditorConfig } from './lib/editor/models/editor.model';
|
|
3
|
+
import { CustomClientParams, DotCMSPageEditorConfig, EditorConfig, UVE_MODE } from './lib/editor/models/editor.model';
|
|
4
4
|
import { InlineEditorData, INLINE_EDITING_EVENT_KEY, InlineEditEventData } from './lib/editor/models/inline-event.model';
|
|
5
5
|
import { NOTIFY_CLIENT } from './lib/editor/models/listeners.model';
|
|
6
6
|
import { destroyEditor, editContentlet, reorderMenu, initEditor, isInsideEditor, updateNavigation, initInlineEditing } from './lib/editor/sdk-editor';
|
|
7
7
|
import { getPageRequestParams, graphqlToPageEntity } from './lib/utils';
|
|
8
|
-
export { graphqlToPageEntity, getPageRequestParams, isInsideEditor, editContentlet, reorderMenu, DotCmsClient, DotCMSPageEditorConfig, CLIENT_ACTIONS, NOTIFY_CLIENT, CustomClientParams, postMessageToEditor, EditorConfig, initEditor, updateNavigation, destroyEditor, ClientConfig, initInlineEditing, InlineEditEventData, InlineEditorData, INLINE_EDITING_EVENT_KEY };
|
|
8
|
+
export { graphqlToPageEntity, getPageRequestParams, isInsideEditor, editContentlet, reorderMenu, DotCmsClient, DotCMSPageEditorConfig, CLIENT_ACTIONS, NOTIFY_CLIENT, CustomClientParams, postMessageToEditor, EditorConfig, initEditor, updateNavigation, destroyEditor, ClientConfig, initInlineEditing, InlineEditEventData, InlineEditorData, INLINE_EDITING_EVENT_KEY, UVE_MODE };
|
|
@@ -38,15 +38,21 @@ export declare function editContentlet<T>(contentlet: Contentlet<T>): void;
|
|
|
38
38
|
export declare function initInlineEditing(type: INLINE_EDITING_EVENT_KEY, data?: InlineEditEventData): void;
|
|
39
39
|
export declare function reorderMenu(config?: ReorderMenuConfig): void;
|
|
40
40
|
/**
|
|
41
|
-
* Checks if the code is running inside
|
|
41
|
+
* Checks if the code is running inside the DotCMS Universal Visual Editor (UVE).
|
|
42
42
|
*
|
|
43
|
-
*
|
|
43
|
+
* The function checks three conditions:
|
|
44
|
+
* 1. If window is defined (for SSR environments)
|
|
45
|
+
* 2. If the page is not in preview mode
|
|
46
|
+
* 3. If the current window is embedded in a parent frame
|
|
47
|
+
*
|
|
48
|
+
* @returns {boolean} Returns true if running inside the UVE editor, false if running standalone or in preview mode
|
|
44
49
|
* @example
|
|
45
50
|
* ```ts
|
|
51
|
+
* // Check if code is running in editor before initializing editor-specific features
|
|
46
52
|
* if (isInsideEditor()) {
|
|
47
|
-
*
|
|
53
|
+
* initEditor(config);
|
|
48
54
|
* } else {
|
|
49
|
-
*
|
|
55
|
+
* initStandaloneMode();
|
|
50
56
|
* }
|
|
51
57
|
* ```
|
|
52
58
|
*/
|