@contentful/field-editor-rich-text 3.27.2 → 3.27.4

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.
@@ -130,8 +130,17 @@ const ConnectedRichTextEditor = (props)=>{
130
130
  }))))));
131
131
  };
132
132
  const RichTextEditor = (props)=>{
133
- const { sdk, isInitiallyDisabled, onAction, restrictedMarks, ...otherProps } = props;
133
+ const { sdk, isInitiallyDisabled, onAction, restrictedMarks, onChange, ...otherProps } = props;
134
134
  const isEmptyValue = _react.useCallback((value)=>!value || (0, _fastdeepequal.default)(value, _richtexttypes.EMPTY_DOCUMENT), []);
135
+ _react.useEffect(()=>{
136
+ if (!onChange) {
137
+ return;
138
+ }
139
+ return sdk.field.onValueChanged(onChange);
140
+ }, [
141
+ onChange,
142
+ sdk.field
143
+ ]);
135
144
  const id = (0, _ContentfulEditorProvider.getContentfulEditorId)(props.sdk);
136
145
  return _react.createElement(_fieldeditorshared.FieldConnector, {
137
146
  debounce: 0,
@@ -66,8 +66,17 @@ export const ConnectedRichTextEditor = (props)=>{
66
66
  }))))));
67
67
  };
68
68
  const RichTextEditor = (props)=>{
69
- const { sdk, isInitiallyDisabled, onAction, restrictedMarks, ...otherProps } = props;
69
+ const { sdk, isInitiallyDisabled, onAction, restrictedMarks, onChange, ...otherProps } = props;
70
70
  const isEmptyValue = React.useCallback((value)=>!value || deepEquals(value, Contentful.EMPTY_DOCUMENT), []);
71
+ React.useEffect(()=>{
72
+ if (!onChange) {
73
+ return;
74
+ }
75
+ return sdk.field.onValueChanged(onChange);
76
+ }, [
77
+ onChange,
78
+ sdk.field
79
+ ]);
71
80
  const id = getContentfulEditorId(props.sdk);
72
81
  return React.createElement(FieldConnector, {
73
82
  debounce: 0,
@@ -1,21 +1,34 @@
1
1
  import { FieldAppSDK } from '@contentful/app-sdk';
2
2
  import * as Contentful from '@contentful/rich-text-types';
3
3
  import { RichTextTrackingActionHandler } from './plugins/Tracking';
4
- type ConnectedProps = {
4
+ type RichTextProps = {
5
5
  sdk: FieldAppSDK;
6
+ isInitiallyDisabled: boolean;
6
7
  onAction?: RichTextTrackingActionHandler;
8
+ restrictedMarks?: string[];
7
9
  minHeight?: string | number;
8
10
  maxHeight?: string | number;
9
11
  value?: Contentful.Document;
10
12
  isDisabled?: boolean;
11
- onChange?: (doc: Contentful.Document) => unknown;
12
13
  isToolbarHidden?: boolean;
13
14
  actionsDisabled?: boolean;
14
- restrictedMarks?: string[];
15
+ /**
16
+ * @deprecated Use `sdk.field.onValueChanged` instead
17
+ */
18
+ onChange?: (doc: Contentful.Document) => unknown;
15
19
  };
16
- export declare const ConnectedRichTextEditor: (props: ConnectedProps) => JSX.Element;
17
- type Props = ConnectedProps & {
18
- isInitiallyDisabled: boolean;
20
+ type ConnectedRichTextProps = {
21
+ sdk: FieldAppSDK;
22
+ onAction?: RichTextTrackingActionHandler;
23
+ onChange?: (doc: Contentful.Document) => unknown;
24
+ restrictedMarks?: string[];
25
+ minHeight?: string | number;
26
+ maxHeight?: string | number;
27
+ value?: Contentful.Document;
28
+ isDisabled?: boolean;
29
+ isToolbarHidden?: boolean;
30
+ actionsDisabled?: boolean;
19
31
  };
20
- declare const RichTextEditor: (props: Props) => JSX.Element;
32
+ export declare const ConnectedRichTextEditor: (props: ConnectedRichTextProps) => JSX.Element;
33
+ declare const RichTextEditor: (props: RichTextProps) => JSX.Element;
21
34
  export default RichTextEditor;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentful/field-editor-rich-text",
3
- "version": "3.27.2",
3
+ "version": "3.27.4",
4
4
  "source": "./src/index.tsx",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -80,11 +80,11 @@
80
80
  "@contentful/rich-text-react-renderer": "^15.16.4",
81
81
  "@types/is-hotkey": "^0.1.6",
82
82
  "@udecode/plate-test-utils": "^3.2.0",
83
- "prism-react-renderer": "2.0.5",
83
+ "prism-react-renderer": "2.4.0",
84
84
  "react": ">=16.14.0"
85
85
  },
86
86
  "publishConfig": {
87
87
  "registry": "https://npm.pkg.github.com/"
88
88
  },
89
- "gitHead": "472a50eb61c357a51526f7f93e820fc7964f8b11"
89
+ "gitHead": "b9471fc997182d448ec327854c98c78119b359ff"
90
90
  }