@@ -473,7 +473,9 @@ class ProjectData {
473473 * @return {result }
474474 */
475475 setText : function ( text ) {
476- checkAreaType ( area , 'text' ) ( NotTextAreaError . of ( `Area with id: ${ id } is not text.` ) )
476+ const areaChecker = checkAreaType ( area , 'text' )
477+ areaChecker ( NotTextAreaError . of ( `Area with id: ${ id } is not text.` ) )
478+
477479 area . value = text
478480 self . patchProperties . push ( 'screens' )
479481 return this
@@ -484,7 +486,9 @@ class ProjectData {
484486 * @return {result }
485487 */
486488 setTextScale : function ( scale ) {
487- checkAreaType ( area , 'text' ) ( NotTextAreaError . of ( `Area with id: ${ id } is not text.` ) )
489+ const areaChecker = checkAreaType ( area , 'text' )
490+ areaChecker ( NotTextAreaError . of ( `Area with id: ${ id } is not text.` ) )
491+
488492 if ( scale < 80 || scale > 120 ) {
489493 throw new InvalidTextScaleValue ( 'The text scale value must be between 80 and 120.' )
490494 }
@@ -498,34 +502,42 @@ class ProjectData {
498502 * @throws {NotTextAreaError }
499503 */
500504 getRecommendedCharacterCount : ( ) => {
501- checkAreaType ( area , 'text' ) ( NotTextAreaError . of ( `Area with id: ${ id } is not text.` ) )
505+ const areaChecker = checkAreaType ( area , 'text' )
506+ areaChecker ( NotTextAreaError . of ( `Area with id: ${ id } is not text.` ) )
507+
502508 return Math . floor ( parseInt ( wordCount ) * AVERAGE_CHARS_IN_WORD )
503509 } ,
504510 /**
505511 * Checks if area is `image`, then sets the new image.
506512 * @param {Object } image - The image properties.
507513 * @throws {NotImageAreaError }
508514 */
509- setImage : ( image ) => {
510- checkAreaType ( area , 'image' ) ( NotImageAreaError . of ( `Area with id: ${ id } is not image.` ) )
515+ setImage : function ( image ) {
516+ const areaChecker = checkAreaType ( area , 'image' )
517+ areaChecker ( NotImageAreaError . of ( `Area with id: ${ id } is not image.` ) )
518+
511519 Object . assign ( result , {
512520 fileName, originalHeight, originalWidth, mimeType, webpPath, fileType, thumbnailPath, imageCropParams
513521 } )
514522 ProjectData . setAreaImage ( area , image )
515- this . patchProperties . push ( 'screens' )
523+ self . patchProperties . push ( 'screens' )
524+ return this
516525 } ,
517526 /**
518527 * Checks if area is `video`, then sets the new video.
519528 * @param {Object } video - The image properties.
520529 * @throws {NotImageAreaError }
521530 */
522- setVideo : ( video ) => {
523- checkAreaType ( area , 'video' ) ( NotVideoAreaError . of ( `Area with id: ${ id } is not video.` ) )
531+ setVideo : function ( video ) {
532+ const areaChecker = checkAreaType ( area , 'video' )
533+ areaChecker ( NotVideoAreaError . of ( `Area with id: ${ id } is not video.` ) )
534+
524535 Object . assign ( result , {
525536 fileName, originalHeight, originalWidth, mimeType, webpPath, fileType, thumbnailPath, videoCropParams
526537 } )
527538 ProjectData . setAreaVideo ( area , video )
528- this . patchProperties . push ( 'screens' )
539+ self . patchProperties . push ( 'screens' )
540+ return this
529541 } ,
530542 /**
531543 * Returns project data instance for further development.
0 commit comments