@@ -473,7 +473,9 @@ class ProjectData {
473
473
* @return {result }
474
474
*/
475
475
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
+
477
479
area . value = text
478
480
self . patchProperties . push ( 'screens' )
479
481
return this
@@ -484,7 +486,9 @@ class ProjectData {
484
486
* @return {result }
485
487
*/
486
488
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
+
488
492
if ( scale < 80 || scale > 120 ) {
489
493
throw new InvalidTextScaleValue ( 'The text scale value must be between 80 and 120.' )
490
494
}
@@ -498,34 +502,42 @@ class ProjectData {
498
502
* @throws {NotTextAreaError }
499
503
*/
500
504
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
+
502
508
return Math . floor ( parseInt ( wordCount ) * AVERAGE_CHARS_IN_WORD )
503
509
} ,
504
510
/**
505
511
* Checks if area is `image`, then sets the new image.
506
512
* @param {Object } image - The image properties.
507
513
* @throws {NotImageAreaError }
508
514
*/
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
+
511
519
Object . assign ( result , {
512
520
fileName, originalHeight, originalWidth, mimeType, webpPath, fileType, thumbnailPath, imageCropParams
513
521
} )
514
522
ProjectData . setAreaImage ( area , image )
515
- this . patchProperties . push ( 'screens' )
523
+ self . patchProperties . push ( 'screens' )
524
+ return this
516
525
} ,
517
526
/**
518
527
* Checks if area is `video`, then sets the new video.
519
528
* @param {Object } video - The image properties.
520
529
* @throws {NotImageAreaError }
521
530
*/
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
+
524
535
Object . assign ( result , {
525
536
fileName, originalHeight, originalWidth, mimeType, webpPath, fileType, thumbnailPath, videoCropParams
526
537
} )
527
538
ProjectData . setAreaVideo ( area , video )
528
- this . patchProperties . push ( 'screens' )
539
+ self . patchProperties . push ( 'screens' )
540
+ return this
529
541
} ,
530
542
/**
531
543
* Returns project data instance for further development.
0 commit comments