@@ -28,6 +28,8 @@ type RichTextEditorContainerProps = {
2828 withStickyToolbar ?: boolean ;
2929 /** Version of the editor */
3030 version : 'default' | 'simplified' ;
31+ /** If true, the image upload button will be displayed - even in simplified mode */
32+ imageUploadEnabled ?: boolean ;
3133 /** If position is sticky, this prop defines the `top` property. Support responsive arrays */
3234 toolbarTop ?: number | string | number [ ] | string [ ] ;
3335 /** Useful to compensate the height of the toolbar when editing inline */
@@ -75,6 +77,7 @@ type RichTextEditorProps = RichTextEditorContainerProps & {
7577 disabled ?: boolean ;
7678
7779 videoEmbedEnabled ?: boolean ;
80+ imageUploadEnabled ?: boolean ;
7881 'data-cy' : string ;
7982 /** Called when an image is being uploaded to set a boolean */
8083 setUploading ?: ( uploading : boolean ) => void ;
@@ -179,9 +182,11 @@ const TrixEditorContainer = styled.div<RichTextEditorContainerProps>`
179182 ${ props =>
180183 props . version === 'simplified' &&
181184 css ( {
182- '.trix-button-group--file-tools' : {
183- display : 'none' ,
184- } ,
185+ ...( ! props . imageUploadEnabled && {
186+ '.trix-button-group--file-tools' : {
187+ display : 'none' ,
188+ } ,
189+ } ) ,
185190 '.trix-button-group--block-tools .trix-button:not(.trix-button--icon-number-list):not(.trix-button--icon-bullet-list)' :
186191 {
187192 display : 'none' ,
@@ -548,7 +553,7 @@ export default class RichTextEditor extends React.Component<RichTextEditorProps,
548553 }
549554
550555 return ;
551- } else if ( this . props . version === 'simplified' ) {
556+ } else if ( this . props . version === 'simplified' && ! this . props . imageUploadEnabled ) {
552557 // Don't upload files in simplified mode
553558 attachment . remove ( ) ;
554559 return ;
@@ -698,6 +703,7 @@ export default class RichTextEditor extends React.Component<RichTextEditorProps,
698703 showCount,
699704 maxLength,
700705 editorMaxHeight,
706+ imageUploadEnabled,
701707 } = this . props ;
702708
703709 return ! this . state . id ? (
@@ -715,6 +721,7 @@ export default class RichTextEditor extends React.Component<RichTextEditorProps,
715721 editorMaxHeight = { editorMaxHeight }
716722 withBorders = { withBorders }
717723 version = { version }
724+ imageUploadEnabled = { imageUploadEnabled }
718725 isDisabled = { disabled }
719726 error = { error }
720727 data-cy = { this . props [ 'data-cy' ] }
0 commit comments