@@ -235,7 +235,7 @@ export default class ImageTool {
235235 // @see https://github.com/editor-js/image/pull/49
236236 const tunes = ImageTool . tunes . concat ( this . config . actions ) ;
237237
238- return tunes . map ( tune => ( {
238+ return tunes . map ( ( tune ) => ( {
239239 icon : tune . icon ,
240240 label : this . api . i18n . t ( tune . title ) ,
241241 name : tune . name ,
@@ -290,7 +290,7 @@ export default class ImageTool {
290290 * Drag n drop file from into the Editor
291291 */
292292 files : {
293- mimeTypes : [ 'image/*' ] ,
293+ mimeTypes : [ 'image/*' ] ,
294294 } ,
295295 } ;
296296 }
@@ -399,7 +399,8 @@ export default class ImageTool {
399399 if ( response . success && response . file ) {
400400 this . image = response . file ;
401401 } else {
402- this . uploadingFailed ( 'incorrect response: ' + JSON . stringify ( response ) ) ;
402+ const customErrorMessage = typeof response . message === 'string' ? response . message : undefined ;
403+ this . uploadingFailed ( 'incorrect response: ' + JSON . stringify ( response ) , customErrorMessage ) ;
403404 }
404405 }
405406
@@ -408,13 +409,14 @@ export default class ImageTool {
408409 *
409410 * @private
410411 * @param {string } errorText - uploading error text
412+ * @param {string | undefined } customErrorText - displayed error text
411413 * @returns {void }
412414 */
413- uploadingFailed ( errorText ) {
415+ uploadingFailed ( errorText , customErrorText ) {
414416 console . log ( 'Image Tool: uploading failed because of' , errorText ) ;
415417
416418 this . api . notifier . show ( {
417- message : this . api . i18n . t ( 'Couldn’t upload image. Please try another.' ) ,
419+ message : customErrorText ?? this . api . i18n . t ( 'Couldn’t upload image. Please try another.' ) ,
418420 style : 'error' ,
419421 } ) ;
420422 this . ui . hidePreloader ( ) ;
@@ -449,10 +451,11 @@ export default class ImageTool {
449451 /**
450452 * Wait until the API is ready
451453 */
452- Promise . resolve ( ) . then ( ( ) => {
453- this . block . stretched = value ;
454- } )
455- . catch ( err => {
454+ Promise . resolve ( )
455+ . then ( ( ) => {
456+ this . block . stretched = value ;
457+ } )
458+ . catch ( ( err ) => {
456459 console . error ( err ) ;
457460 } ) ;
458461 }
0 commit comments