@dotcms/react 0.0.1-beta.31 → 0.0.1-beta.33
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/next.esm.js
CHANGED
|
@@ -689,26 +689,29 @@ function DotCMSEditableText({
|
|
|
689
689
|
mode = 'plain',
|
|
690
690
|
format = 'text',
|
|
691
691
|
contentlet,
|
|
692
|
-
fieldName
|
|
692
|
+
fieldName
|
|
693
693
|
}) {
|
|
694
694
|
const editorRef = useRef(null);
|
|
695
695
|
const [scriptSrc, setScriptSrc] = useState('');
|
|
696
696
|
const [initEditor, setInitEditor] = useState(false);
|
|
697
697
|
const [content, setContent] = useState((contentlet == null ? void 0 : contentlet[fieldName]) || '');
|
|
698
|
+
useEffect(() => {
|
|
699
|
+
setContent((contentlet == null ? void 0 : contentlet[fieldName]) || '');
|
|
700
|
+
}, [fieldName, contentlet]);
|
|
698
701
|
useEffect(() => {
|
|
699
702
|
var _state$dotCMSHost, _editorRef$current;
|
|
700
703
|
const state = getUVEState();
|
|
701
704
|
setInitEditor((state == null ? void 0 : state.mode) === UVE_MODE.EDIT && !!(state != null && (_state$dotCMSHost = state.dotCMSHost) != null && _state$dotCMSHost.length));
|
|
702
705
|
if (!contentlet || !fieldName) {
|
|
703
|
-
console.error('DotCMSEditableText: contentlet or fieldName is missing', 'Ensure that all needed props are passed to view and edit the content');
|
|
706
|
+
console.error('[DotCMSEditableText]: contentlet or fieldName is missing', 'Ensure that all needed props are passed to view and edit the content');
|
|
704
707
|
return;
|
|
705
708
|
}
|
|
706
709
|
if (state && state.mode !== UVE_MODE.EDIT) {
|
|
707
|
-
console.warn('DotCMSEditableText: TinyMCE is not available in the current mode');
|
|
710
|
+
console.warn('[DotCMSEditableText]: TinyMCE is not available in the current mode');
|
|
708
711
|
return;
|
|
709
712
|
}
|
|
710
713
|
if (!(state != null && state.dotCMSHost)) {
|
|
711
|
-
console.warn('The `dotCMSHost` parameter is not defined. Check that the UVE is sending the correct parameters.');
|
|
714
|
+
console.warn('[DotCMSEditableText]: The `dotCMSHost` parameter is not defined. Check that the UVE is sending the correct parameters.');
|
|
712
715
|
return;
|
|
713
716
|
}
|
|
714
717
|
const createURL = new URL(__TINYMCE_PATH_ON_DOTCMS__, state.dotCMSHost);
|
|
@@ -717,8 +720,7 @@ function DotCMSEditableText({
|
|
|
717
720
|
(_editorRef$current = editorRef.current) == null || _editorRef$current.setContent(content, {
|
|
718
721
|
format
|
|
719
722
|
});
|
|
720
|
-
|
|
721
|
-
}, [format, fieldName, contentlet]);
|
|
723
|
+
}, [format, fieldName, contentlet, content]);
|
|
722
724
|
useEffect(() => {
|
|
723
725
|
var _getUVEState;
|
|
724
726
|
if (((_getUVEState = getUVEState()) == null ? void 0 : _getUVEState.mode) !== UVE_MODE.EDIT) {
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dotcms/react",
|
|
3
|
-
"version": "0.0.1-beta.
|
|
3
|
+
"version": "0.0.1-beta.33",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"react": ">=18",
|
|
6
6
|
"react-dom": ">=18",
|
|
7
|
-
"@dotcms/client": "0.0.1-beta.
|
|
8
|
-
"@dotcms/uve": "0.0.1-beta.
|
|
7
|
+
"@dotcms/client": "0.0.1-beta.33",
|
|
8
|
+
"@dotcms/uve": "0.0.1-beta.33",
|
|
9
9
|
"@tinymce/tinymce-react": "^6.0.0"
|
|
10
10
|
},
|
|
11
11
|
"devDependencies": {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import { DotCMSBasicContentlet } from '@dotcms/types';
|
|
2
3
|
import { DotCMSEditableTextProps } from './utils';
|
|
3
4
|
/**
|
|
4
5
|
* Allows inline edit content pulled from dotCMS API using TinyMCE editor
|
|
@@ -27,5 +28,5 @@ import { DotCMSEditableTextProps } from './utils';
|
|
|
27
28
|
* ```
|
|
28
29
|
* @returns {JSX.Element} A component to edit content inline
|
|
29
30
|
*/
|
|
30
|
-
export declare function DotCMSEditableText({ mode, format, contentlet, fieldName }: Readonly<DotCMSEditableTextProps
|
|
31
|
+
export declare function DotCMSEditableText<T extends DotCMSBasicContentlet>({ mode, format, contentlet, fieldName }: Readonly<DotCMSEditableTextProps<T>>): JSX.Element;
|
|
31
32
|
export default DotCMSEditableText;
|
|
@@ -2,13 +2,13 @@ import { IAllProps } from '@tinymce/tinymce-react';
|
|
|
2
2
|
import { DotCMSBasicContentlet } from '@dotcms/types';
|
|
3
3
|
export type DOT_EDITABLE_TEXT_FORMAT = 'html' | 'text';
|
|
4
4
|
export type DOT_EDITABLE_TEXT_MODE = 'minimal' | 'full' | 'plain';
|
|
5
|
-
export interface DotCMSEditableTextProps {
|
|
5
|
+
export interface DotCMSEditableTextProps<T extends DotCMSBasicContentlet> {
|
|
6
6
|
/**
|
|
7
7
|
* Represents the field name of the `contentlet` that can be edited
|
|
8
8
|
*
|
|
9
9
|
* @memberof DotCMSEditableTextProps
|
|
10
10
|
*/
|
|
11
|
-
fieldName:
|
|
11
|
+
fieldName: keyof T;
|
|
12
12
|
/**
|
|
13
13
|
* Represents the format of the editor which can be `text` or `html`
|
|
14
14
|
*
|
|
@@ -29,7 +29,7 @@ export interface DotCMSEditableTextProps {
|
|
|
29
29
|
* @type {DotCMSBasicContentlet}
|
|
30
30
|
* @memberof DotCMSEditableTextProps
|
|
31
31
|
*/
|
|
32
|
-
contentlet:
|
|
32
|
+
contentlet: T;
|
|
33
33
|
}
|
|
34
34
|
export declare const TINYMCE_CONFIG: {
|
|
35
35
|
[key in DOT_EDITABLE_TEXT_MODE]: IAllProps['init'];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DotCMSComposedPageResponse } from '@dotcms/types';
|
|
2
2
|
/**
|
|
3
3
|
* Custom hook to manage the editable state of a DotCMS page.
|
|
4
4
|
*
|
|
@@ -87,4 +87,4 @@ import { DotCMSPageResponse } from '@dotcms/types';
|
|
|
87
87
|
* @returns {DotCMSPageResponse} The updated editable page state that reflects any changes made in the UVE.
|
|
88
88
|
* The structure includes page data and any GraphQL content that was requested.
|
|
89
89
|
*/
|
|
90
|
-
export declare const useEditableDotCMSPage: (pageResponse:
|
|
90
|
+
export declare const useEditableDotCMSPage: <T extends Partial<Pick<import("@dotcms/types").DotCMSPageResponse, "pageAsset" | "content">>>(pageResponse: DotCMSComposedPageResponse<T>) => DotCMSComposedPageResponse<T>;
|