File tree Expand file tree Collapse file tree 2 files changed +12
-7
lines changed
admin/src/components/ReactMdEditor Expand file tree Collapse file tree 2 files changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -74,19 +74,24 @@ const Editor = ({
7474 let newValue = value ? value : "" ;
7575 assets . map ( ( asset ) => {
7676 if ( asset . mime . includes ( "image" ) ) {
77- const imgTag = `  ` ;
77+ const imgTag = `` ;
7878 if ( mediaLibSelection > - 1 ) {
79- newValue =
80- value . substring ( 0 , mediaLibSelection ) +
81- imgTag +
82- value . substring ( mediaLibSelection ) ;
79+ const preValue = value ?. substring ( 0 , mediaLibSelection ) ?? "" ;
80+ const postValue = value ?. substring ( mediaLibSelection ) ?? "" ;
81+ newValue = `${
82+ preValue && ! preValue . endsWith ( " " ) ? preValue + " " : preValue
83+ } ${ imgTag } ${
84+ postValue && ! postValue . startsWith ( " " )
85+ ? " " + postValue
86+ : postValue
87+ } `;
8388 } else {
8489 newValue = `${ newValue } ${ imgTag } ` ;
8590 }
8691 }
8792 // Handle videos and other type of files by adding some code
8893 } ) ;
89- onChange ( { target : { name, value : newValue || "" } } ) ;
94+ onChange ( { target : { name, value : newValue ?? "" } } ) ;
9095 handleToggleMediaLib ( ) ;
9196 } ;
9297
Original file line number Diff line number Diff line change 11{
22 "name" : " strapi-plugin-wysiwyg-react-md-editor" ,
3- "version" : " 4.4.0 " ,
3+ "version" : " 4.4.1 " ,
44 "description" : " Replaces the default Strapi WYSIWYG editor with react md editor." ,
55 "strapi" : {
66 "name" : " wysiwyg-react-md-editor" ,
You can’t perform that action at this time.
0 commit comments