@@ -11,6 +11,7 @@ import noop from 'lodash/noop';
1111
1212import { ContentfulEditorIdProvider , getContentfulEditorId } from './ContentfulEditorProvider' ;
1313import { toSlateValue } from './helpers/toSlateValue' ;
14+ import { PlatePlugin } from './internal' ;
1415import { normalizeInitialValue } from './internal/misc' ;
1516import { getPlugins , disableCorePlugins } from './plugins' ;
1617import { RichTextTrackingActionHandler } from './plugins/Tracking' ;
@@ -31,15 +32,20 @@ type ConnectedProps = {
3132 isToolbarHidden ?: boolean ;
3233 actionsDisabled ?: boolean ;
3334 restrictedMarks ?: string [ ] ;
35+ customPlugins ?: PlatePlugin [ ] ;
36+ customToolbars ?: React . JSXElementConstructor < {
37+ isDisabled ?: boolean ;
38+ [ index : string ] : unknown ;
39+ } > [ ] ;
3440} ;
3541
3642export const ConnectedRichTextEditor = ( props : ConnectedProps ) => {
3743 const { sdk, onAction, restrictedMarks } = props ;
3844
3945 const id = getContentfulEditorId ( sdk ) ;
4046 const plugins = React . useMemo (
41- ( ) => getPlugins ( sdk , onAction ?? noop , restrictedMarks ) ,
42- [ sdk , onAction , restrictedMarks ]
47+ ( ) => getPlugins ( sdk , onAction ?? noop , restrictedMarks , props ?. customPlugins ?? [ ] ) ,
48+ [ sdk , onAction , restrictedMarks , props ?. customPlugins ]
4349 ) ;
4450
4551 const initialValue = React . useMemo ( ( ) => {
@@ -73,6 +79,15 @@ export const ConnectedRichTextEditor = (props: ConnectedProps) => {
7379 { ! props . isToolbarHidden && (
7480 < StickyToolbarWrapper isDisabled = { props . isDisabled } >
7581 < Toolbar isDisabled = { props . isDisabled } />
82+ { /* Custom toolbars are placed underneath Contentful's built-in one */ }
83+ { props ?. customToolbars ?. length &&
84+ props . customToolbars . map ( ( ToolbarComponent , index ) => {
85+ return (
86+ < React . Fragment key = { index } >
87+ < ToolbarComponent isDisabled = { props . isDisabled } />
88+ </ React . Fragment >
89+ ) ;
90+ } ) }
7691 </ StickyToolbarWrapper >
7792 ) }
7893 < SyncEditorChanges incomingValue = { initialValue } onChange = { props . onChange } />
0 commit comments