Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: wrapping connected rte instead of root one with entity provider [] #1718

Merged
merged 1 commit into from
Aug 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 41 additions & 41 deletions packages/rich-text/src/RichTextEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,26 +65,28 @@ export const ConnectedRichTextEditor = (props: ConnectedProps) => {
);

return (
<SdkProvider sdk={sdk}>
<ContentfulEditorIdProvider value={id}>
<div className={styles.root} data-test-id="rich-text-editor">
<Plate
id={id}
initialValue={initialValue}
plugins={plugins as PlatePlugin[]}
disableCorePlugins={disableCorePlugins}
>
{!props.isToolbarHidden && (
<StickyToolbarWrapper isDisabled={props.isDisabled}>
<Toolbar isDisabled={props.isDisabled} />
</StickyToolbarWrapper>
)}
<SyncEditorChanges incomingValue={initialValue} onChange={props.onChange} />
<PlateContent id={id} className={classNames} readOnly={props.isDisabled} />
</Plate>
</div>
</ContentfulEditorIdProvider>
</SdkProvider>
<EntityProvider sdk={sdk}>
<SdkProvider sdk={sdk}>
<ContentfulEditorIdProvider value={id}>
<div className={styles.root} data-test-id="rich-text-editor">
<Plate
id={id}
initialValue={initialValue}
plugins={plugins as PlatePlugin[]}
disableCorePlugins={disableCorePlugins}
>
{!props.isToolbarHidden && (
<StickyToolbarWrapper isDisabled={props.isDisabled}>
<Toolbar isDisabled={props.isDisabled} />
</StickyToolbarWrapper>
)}
<SyncEditorChanges incomingValue={initialValue} onChange={props.onChange} />
<PlateContent id={id} className={classNames} readOnly={props.isDisabled} />
</Plate>
</div>
</ContentfulEditorIdProvider>
</SdkProvider>
</EntityProvider>
);
};

Expand All @@ -99,27 +101,25 @@ const RichTextEditor = (props: Props) => {

const id = getContentfulEditorId(props.sdk);
return (
<EntityProvider sdk={sdk}>
<FieldConnector
debounce={0}
field={sdk.field}
isInitiallyDisabled={isInitiallyDisabled}
isEmptyValue={isEmptyValue}
>
{({ lastRemoteValue, disabled, setValue }) => (
<ConnectedRichTextEditor
{...otherProps}
key={`rich-text-editor-${id}`}
value={lastRemoteValue}
sdk={sdk}
onAction={onAction}
isDisabled={disabled}
onChange={setValue}
restrictedMarks={restrictedMarks}
/>
)}
</FieldConnector>
</EntityProvider>
<FieldConnector
debounce={0}
field={sdk.field}
isInitiallyDisabled={isInitiallyDisabled}
isEmptyValue={isEmptyValue}
>
{({ lastRemoteValue, disabled, setValue }) => (
<ConnectedRichTextEditor
{...otherProps}
key={`rich-text-editor-${id}`}
value={lastRemoteValue}
sdk={sdk}
onAction={onAction}
isDisabled={disabled}
onChange={setValue}
restrictedMarks={restrictedMarks}
/>
)}
</FieldConnector>
);
};

Expand Down
Loading