@dotcms/react 0.0.1-alpha.26 → 0.0.1-alpha.28
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.esm.js +20 -13
- package/package.json +2 -2
- package/src/lib/hooks/useDotcmsEditor.d.ts +1 -1
package/index.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
2
2
|
import { useState, useEffect, createContext, useContext, createElement as createElement$1, forwardRef } from 'react';
|
|
3
|
-
import { isInsideEditor, initEditor, updateNavigation, destroyEditor } from '@dotcms/client';
|
|
3
|
+
import { isInsideEditor, initEditor, updateNavigation, destroyEditor, DotCmsClient } from '@dotcms/client';
|
|
4
4
|
|
|
5
5
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
6
6
|
|
|
@@ -1617,24 +1617,31 @@ for (var COLLECTION_NAME in DOMIterables) {
|
|
|
1617
1617
|
handlePrototype(DOMTokenListPrototype, 'DOMTokenList');
|
|
1618
1618
|
|
|
1619
1619
|
const useDotcmsEditor = ({
|
|
1620
|
-
pathname
|
|
1620
|
+
pathname,
|
|
1621
|
+
onReload
|
|
1621
1622
|
}) => {
|
|
1622
1623
|
const [isInsideEditor$1, setIsInsideEditor] = useState(false);
|
|
1623
1624
|
useEffect(() => {
|
|
1624
1625
|
const insideEditor = isInsideEditor();
|
|
1625
|
-
if (insideEditor) {
|
|
1626
|
-
|
|
1627
|
-
pathname
|
|
1628
|
-
});
|
|
1629
|
-
updateNavigation(pathname || '/');
|
|
1630
|
-
setIsInsideEditor(insideEditor);
|
|
1626
|
+
if (!insideEditor) {
|
|
1627
|
+
return;
|
|
1631
1628
|
}
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1629
|
+
initEditor({
|
|
1630
|
+
pathname
|
|
1631
|
+
});
|
|
1632
|
+
updateNavigation(pathname || '/');
|
|
1633
|
+
setIsInsideEditor(insideEditor);
|
|
1634
|
+
return () => destroyEditor();
|
|
1637
1635
|
}, [pathname]);
|
|
1636
|
+
useEffect(() => {
|
|
1637
|
+
const insideEditor = isInsideEditor();
|
|
1638
|
+
const client = DotCmsClient.instance;
|
|
1639
|
+
if (!insideEditor || !onReload) {
|
|
1640
|
+
return;
|
|
1641
|
+
}
|
|
1642
|
+
client.editor.on('changes', () => onReload == null ? void 0 : onReload());
|
|
1643
|
+
return () => client.editor.off('changes');
|
|
1644
|
+
}, [onReload]);
|
|
1638
1645
|
return {
|
|
1639
1646
|
isInsideEditor: isInsideEditor$1
|
|
1640
1647
|
};
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dotcms/react",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.28",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"react": ">=18",
|
|
6
6
|
"react-dom": ">=18",
|
|
7
|
-
"@dotcms/client": "0.0.1-alpha.
|
|
7
|
+
"@dotcms/client": "0.0.1-alpha.28"
|
|
8
8
|
},
|
|
9
9
|
"description": "Official React Components library to render a dotCMS page.",
|
|
10
10
|
"repository": {
|