@syncfusion/ej2-image-editor 22.2.10 → 23.1.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/ej2-image-editor.umd.min.js +2 -2
  3. package/dist/ej2-image-editor.umd.min.js.map +1 -1
  4. package/dist/es6/ej2-image-editor.es2015.js +4272 -687
  5. package/dist/es6/ej2-image-editor.es2015.js.map +1 -1
  6. package/dist/es6/ej2-image-editor.es5.js +4234 -640
  7. package/dist/es6/ej2-image-editor.es5.js.map +1 -1
  8. package/dist/global/ej2-image-editor.min.js +2 -2
  9. package/dist/global/ej2-image-editor.min.js.map +1 -1
  10. package/dist/global/index.d.ts +1 -1
  11. package/package.json +12 -12
  12. package/src/image-editor/action/crop.js +47 -30
  13. package/src/image-editor/action/draw.d.ts +16 -0
  14. package/src/image-editor/action/draw.js +827 -81
  15. package/src/image-editor/action/export.d.ts +3 -0
  16. package/src/image-editor/action/export.js +84 -20
  17. package/src/image-editor/action/filter.d.ts +0 -1
  18. package/src/image-editor/action/filter.js +28 -41
  19. package/src/image-editor/action/freehand-draw.js +45 -32
  20. package/src/image-editor/action/selection.d.ts +6 -0
  21. package/src/image-editor/action/selection.js +380 -66
  22. package/src/image-editor/action/shape.d.ts +8 -0
  23. package/src/image-editor/action/shape.js +286 -91
  24. package/src/image-editor/action/transform.d.ts +9 -0
  25. package/src/image-editor/action/transform.js +402 -52
  26. package/src/image-editor/action/undo-redo.d.ts +1 -0
  27. package/src/image-editor/action/undo-redo.js +138 -10
  28. package/src/image-editor/base/enum.d.ts +38 -1
  29. package/src/image-editor/base/enum.js +39 -0
  30. package/src/image-editor/base/image-editor-model.d.ts +16 -2
  31. package/src/image-editor/base/image-editor.d.ts +134 -7
  32. package/src/image-editor/base/image-editor.js +611 -69
  33. package/src/image-editor/base/interface.d.ts +233 -2
  34. package/src/image-editor/renderer/toolbar.d.ts +25 -0
  35. package/src/image-editor/renderer/toolbar.js +1273 -72
  36. package/styles/bootstrap-dark.css +68 -1
  37. package/styles/bootstrap.css +68 -1
  38. package/styles/bootstrap4.css +68 -1
  39. package/styles/bootstrap5-dark.css +68 -1
  40. package/styles/bootstrap5.css +68 -1
  41. package/styles/fabric-dark.css +68 -1
  42. package/styles/fabric.css +68 -1
  43. package/styles/fluent-dark.css +68 -1
  44. package/styles/fluent.css +68 -1
  45. package/styles/highcontrast-light.css +70 -3
  46. package/styles/highcontrast.css +69 -7
  47. package/styles/image-editor/_bootstrap-dark-definition.scss +1 -0
  48. package/styles/image-editor/_bootstrap-definition.scss +1 -0
  49. package/styles/image-editor/_bootstrap4-definition.scss +1 -0
  50. package/styles/image-editor/_bootstrap5-definition.scss +1 -0
  51. package/styles/image-editor/_fabric-dark-definition.scss +1 -0
  52. package/styles/image-editor/_fabric-definition.scss +1 -0
  53. package/styles/image-editor/_fluent-definition.scss +1 -0
  54. package/styles/image-editor/_fusionnew-definition.scss +1 -0
  55. package/styles/image-editor/_highcontrast-definition.scss +2 -1
  56. package/styles/image-editor/_highcontrast-light-definition.scss +2 -1
  57. package/styles/image-editor/_layout.scss +92 -0
  58. package/styles/image-editor/_material-dark-definition.scss +1 -0
  59. package/styles/image-editor/_material-definition.scss +1 -0
  60. package/styles/image-editor/_material3-definition.scss +2 -1
  61. package/styles/image-editor/_tailwind-definition.scss +1 -0
  62. package/styles/image-editor/_theme.scss +4 -2
  63. package/styles/image-editor/bootstrap-dark.css +68 -1
  64. package/styles/image-editor/bootstrap-dark.scss +1 -1
  65. package/styles/image-editor/bootstrap.css +68 -1
  66. package/styles/image-editor/bootstrap.scss +1 -1
  67. package/styles/image-editor/bootstrap4.css +68 -1
  68. package/styles/image-editor/bootstrap4.scss +1 -1
  69. package/styles/image-editor/bootstrap5-dark.css +68 -1
  70. package/styles/image-editor/bootstrap5-dark.scss +1 -1
  71. package/styles/image-editor/bootstrap5.css +68 -1
  72. package/styles/image-editor/bootstrap5.scss +1 -1
  73. package/styles/image-editor/fabric-dark.css +68 -1
  74. package/styles/image-editor/fabric-dark.scss +1 -1
  75. package/styles/image-editor/fabric.css +68 -1
  76. package/styles/image-editor/fabric.scss +1 -1
  77. package/styles/image-editor/fluent-dark.css +68 -1
  78. package/styles/image-editor/fluent-dark.scss +1 -1
  79. package/styles/image-editor/fluent.css +68 -1
  80. package/styles/image-editor/fluent.scss +1 -1
  81. package/styles/image-editor/highcontrast-light.css +70 -3
  82. package/styles/image-editor/highcontrast-light.scss +1 -1
  83. package/styles/image-editor/highcontrast.css +69 -7
  84. package/styles/image-editor/highcontrast.scss +1 -1
  85. package/styles/image-editor/icons/_bootstrap-dark.scss +1 -0
  86. package/styles/image-editor/icons/_bootstrap.scss +1 -0
  87. package/styles/image-editor/icons/_bootstrap4.scss +1 -0
  88. package/styles/image-editor/icons/_bootstrap5.scss +1 -0
  89. package/styles/image-editor/icons/_fabric-dark.scss +1 -0
  90. package/styles/image-editor/icons/_fabric.scss +1 -0
  91. package/styles/image-editor/icons/_fluent.scss +1 -0
  92. package/styles/image-editor/icons/_fusionnew.scss +1 -0
  93. package/styles/image-editor/icons/_highcontrast-light.scss +1 -0
  94. package/styles/image-editor/icons/_highcontrast.scss +1 -0
  95. package/styles/image-editor/icons/_material-dark.scss +1 -0
  96. package/styles/image-editor/icons/_material.scss +1 -0
  97. package/styles/image-editor/icons/_material3.scss +1 -0
  98. package/styles/image-editor/icons/_tailwind.scss +1 -0
  99. package/styles/image-editor/material-dark.css +68 -2
  100. package/styles/image-editor/material-dark.scss +1 -1
  101. package/styles/image-editor/material.css +68 -2
  102. package/styles/image-editor/material.scss +1 -1
  103. package/styles/image-editor/material3-dark.css +73 -4
  104. package/styles/image-editor/material3-dark.scss +1 -1
  105. package/styles/image-editor/material3.css +73 -4
  106. package/styles/image-editor/material3.scss +1 -1
  107. package/styles/image-editor/tailwind-dark.css +68 -2
  108. package/styles/image-editor/tailwind-dark.scss +1 -1
  109. package/styles/image-editor/tailwind.css +68 -2
  110. package/styles/image-editor/tailwind.scss +1 -1
  111. package/styles/material-dark.css +68 -2
  112. package/styles/material.css +68 -2
  113. package/styles/material3-dark.css +73 -4
  114. package/styles/material3-dark.scss +1 -1
  115. package/styles/material3.css +73 -4
  116. package/styles/material3.scss +1 -1
  117. package/styles/tailwind-dark.css +68 -2
  118. package/styles/tailwind.css +68 -2
@@ -7,6 +7,7 @@ export declare class Shape {
7
7
  private strokeSettings;
8
8
  private keyHistory;
9
9
  private prevObj;
10
+ private shapeImg;
10
11
  constructor(parent: ImageEditor);
11
12
  destroy(): void;
12
13
  private addEventListener;
@@ -30,8 +31,10 @@ export declare class Shape {
30
31
  private setPointCollForLineAndArrow;
31
32
  private prevObjColl;
32
33
  private drawShapeText;
34
+ private drawShapeImageEvent;
33
35
  private drawShapeTextEvent;
34
36
  private initializeTextShape;
37
+ private drawImage;
35
38
  private redrawActObj;
36
39
  private apply;
37
40
  private setCenterPoints;
@@ -57,6 +60,11 @@ export declare class Shape {
57
60
  private updatePathRatio;
58
61
  private stopPathDrawing;
59
62
  private findTextTarget;
63
+ private fileChanged;
64
+ private onLoadImgShape;
65
+ private updateImgCanvas;
66
+ private updateObj;
67
+ private resizeImage;
60
68
  private setTextBoxPos;
61
69
  private setTextBoxPoints;
62
70
  private selectedText;
@@ -24,9 +24,10 @@ var Shape = /** @class */ (function () {
24
24
  };
25
25
  Shape.prototype.shape = function (args) {
26
26
  this.initShapePvtProps();
27
+ var uploader;
27
28
  switch (args.prop) {
28
29
  case 'drawEllipse':
29
- this.drawEllipse(args.value['x'], args.value['y'], args.value['radiusX'], args.value['radiusY'], args.value['strokeWidth'], args.value['strokeColor'], args.value['fillColor']);
30
+ this.drawEllipse(args.value['x'], args.value['y'], args.value['radiusX'], args.value['radiusY'], args.value['strokeWidth'], args.value['strokeColor'], args.value['fillColor'], args.value['degree']);
30
31
  break;
31
32
  case 'drawLine':
32
33
  this.drawLine(args.value['startX'], args.value['startY'], args.value['endX'], args.value['endY'], args.value['strokeWidth'], args.value['strokeColor']);
@@ -38,7 +39,7 @@ var Shape = /** @class */ (function () {
38
39
  this.drawPath(args.value['pointColl'], args.value['strokeWidth'], args.value['strokeColor']);
39
40
  break;
40
41
  case 'drawRectangle':
41
- this.drawRectangle(args.value['x'], args.value['y'], args.value['width'], args.value['height'], args.value['strokeWidth'], args.value['strokeColor'], args.value['fillColor']);
42
+ this.drawRectangle(args.value['x'], args.value['y'], args.value['width'], args.value['height'], args.value['strokeWidth'], args.value['strokeColor'], args.value['fillColor'], args.value['degree']);
42
43
  break;
43
44
  case 'drawText':
44
45
  this.drawText(args.value['x'], args.value['y'], args.value['text'], args.value['fontFamily'], args.value['fontSize'], args.value['bold'], args.value['italic'], args.value['color']);
@@ -121,10 +122,16 @@ var Shape = /** @class */ (function () {
121
122
  case 'wireEvent':
122
123
  EventHandler.add(this.parent.upperCanvas, 'dblclick', this.findTextTarget, this);
123
124
  EventHandler.add(this.parent.textArea, 'mousedown', this.findTextTarget, this);
125
+ uploader = document.getElementById(this.parent.element.id + '_fileUpload');
126
+ if (uploader) {
127
+ EventHandler.add(uploader, 'change', this.fileChanged, this);
128
+ }
124
129
  break;
125
130
  case 'unWireEvent':
126
131
  EventHandler.remove(this.parent.upperCanvas, 'dblclick', this.findTextTarget);
127
132
  EventHandler.remove(this.parent.textArea, 'mousedown', this.findTextTarget);
133
+ uploader = document.getElementById(this.parent.element.id + '_fileUpload');
134
+ EventHandler.remove(uploader, 'change', this.fileChanged);
128
135
  break;
129
136
  case 'getShapeSetting':
130
137
  this.getShapeSetting(args.value['id'], args.value['obj']);
@@ -200,7 +207,7 @@ var Shape = /** @class */ (function () {
200
207
  this.initializeTextShape(args.value['text'], args.value['fontFamily'], args.value['fontSize'], args.value['bold'], args.value['italic'], args.value['strokeColor']);
201
208
  break;
202
209
  case 'stopPathDrawing':
203
- this.stopPathDrawing(args.value['e']);
210
+ this.stopPathDrawing(args.value['e'], args.value['isApply']);
204
211
  break;
205
212
  case 'updateArrowRatio':
206
213
  this.updateArrowRatio(args.value['obj']);
@@ -208,9 +215,18 @@ var Shape = /** @class */ (function () {
208
215
  case 'getSquarePointForRotatedShape':
209
216
  this.getSquarePointForRotatedShape(args.value['obj'], args.value['object']);
210
217
  break;
218
+ case 'drawImage':
219
+ this.drawImage(args.value['x'], args.value['y'], args.value['width'], args.value['height'], args.value['src'], args.value['degree'], args.value['isAspectRatio']);
220
+ break;
211
221
  case 'reset':
212
222
  this.reset();
213
223
  break;
224
+ case 'fileChanged':
225
+ this.fileChanged(args.value['e']);
226
+ break;
227
+ case 'updateObj':
228
+ this.updateObj(args.value['dimObj'], args.value['x'], args.value['y']);
229
+ break;
214
230
  }
215
231
  };
216
232
  Shape.prototype.getModuleName = function () {
@@ -223,6 +239,11 @@ var Shape = /** @class */ (function () {
223
239
  if (this.parent.upperCanvas) {
224
240
  this.upperContext = this.parent.upperCanvas.getContext('2d');
225
241
  }
242
+ if (isNullOrUndefined(this.shapeImg)) {
243
+ this.shapeImg = this.parent.createElement('img', {
244
+ id: this.parent.element.id + '_shapeImg', attrs: { name: 'Image', crossorigin: 'anonymous' }
245
+ });
246
+ }
226
247
  };
227
248
  Shape.prototype.reset = function () {
228
249
  this.textSettings =
@@ -481,15 +502,8 @@ var Shape = /** @class */ (function () {
481
502
  this.initializeTextShape(text, fontFamily, fontSize, bold, italic, strokeColor);
482
503
  parent.currObjType.isText = parent.currObjType.isInitialText = true;
483
504
  if (isNullOrUndefined(parent.activeObj.textSettings.fontSize)) {
484
- if (parent.img.destWidth > parent.img.destHeight) {
485
- parent.activeObj.textSettings.fontSize = (parent.img.destWidth / 15);
486
- }
487
- else {
488
- parent.activeObj.textSettings.fontSize = (parent.img.destHeight / 15);
489
- }
490
- if (parent.activeObj.textSettings.fontSize < 20) {
491
- parent.activeObj.textSettings.fontSize = 20;
492
- }
505
+ parent.getFontSizes();
506
+ parent.activeObj.textSettings.fontSize = parseInt(parent.fontSizeColl[(parseInt('3', 10) - 1)].text, 10);
493
507
  }
494
508
  if (parent.img.destWidth < 100) {
495
509
  parent.activeObj.textSettings.fontSize = Math.floor((parent.img.destWidth / 20));
@@ -538,6 +552,36 @@ var Shape = /** @class */ (function () {
538
552
  }
539
553
  }
540
554
  };
555
+ Shape.prototype.drawShapeImageEvent = function (shapeChangingArgs, isSelect) {
556
+ var parent = this.parent;
557
+ this.updateShapeChangeEventArgs(shapeChangingArgs.currentShapeSettings);
558
+ parent.notify('draw', { prop: 'drawObject', onPropertyChange: false, value: { canvas: 'duplicate' } });
559
+ parent.objColl.push(parent.activeObj);
560
+ var prevCropObj = extend({}, parent.cropObj, {}, true);
561
+ parent.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false,
562
+ value: { operation: 'shapeTransform', previousObj: this.prevObj, previousObjColl: this.prevObj.objColl,
563
+ previousPointColl: this.prevObj.pointColl, previousSelPointColl: this.prevObj.selPointColl,
564
+ previousCropObj: prevCropObj, previousText: null,
565
+ currentText: null, previousFilter: null, isCircleCrop: null } });
566
+ parent.notify('selection', { prop: 'redrawShape', onPropertyChange: false,
567
+ value: { obj: parent.objColl[parent.objColl.length - 1] } });
568
+ if (isSelect) {
569
+ if (!isBlazor()) {
570
+ parent.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: { type: 'shapes',
571
+ isApplyBtn: null, isCropping: null, isZooming: null, cType: null } });
572
+ parent.notify('toolbar', { prop: 'update-toolbar-items', onPropertyChange: false });
573
+ parent.notify('toolbar', { prop: 'renderQAT', onPropertyChange: false, value: { isPenEdit: null } });
574
+ }
575
+ else {
576
+ parent.updateToolbar(parent.element, parent.activeObj.shape);
577
+ parent.updateToolbar(parent.element, 'quickAccessToolbar', parent.activeObj.shape);
578
+ }
579
+ }
580
+ else {
581
+ parent.okBtn();
582
+ }
583
+ parent.notify('selection', { prop: 'isShapeInserted', onPropertyChange: false, value: { bool: true } });
584
+ };
541
585
  Shape.prototype.drawShapeTextEvent = function (shapeChangingArgs) {
542
586
  var parent = this.parent;
543
587
  this.updateShapeChangeEventArgs(shapeChangingArgs.currentShapeSettings);
@@ -586,6 +630,10 @@ var Shape = /** @class */ (function () {
586
630
  parent.activeObj.textSettings.bold = bold || parent.activeObj.textSettings.bold;
587
631
  parent.activeObj.textSettings.italic = italic || parent.activeObj.textSettings.italic;
588
632
  };
633
+ Shape.prototype.drawImage = function (x, y, width, height, src, degree, isAspectRatio) {
634
+ this.initializeShape('image');
635
+ this.onLoadImgShape(x, y, width, height, src, null, degree, isAspectRatio);
636
+ };
589
637
  Shape.prototype.redrawActObj = function (x, y, isMouseDown) {
590
638
  var splitWords;
591
639
  var parent = this.parent;
@@ -707,6 +755,7 @@ var Shape = /** @class */ (function () {
707
755
  switch (parent.activeObj.shape) {
708
756
  case 'ellipse':
709
757
  parent.activeObj.activePoint.width = shapeSettings.radius * 2;
758
+ parent.activeObj.rotatedAngle = shapeSettings.degree * (Math.PI / 180);
710
759
  break;
711
760
  case 'line':
712
761
  case 'arrow':
@@ -719,6 +768,10 @@ var Shape = /** @class */ (function () {
719
768
  parent.activeObj.textSettings.fontFamily = shapeSettings.fontFamily;
720
769
  break;
721
770
  case 'rectangle':
771
+ case 'image':
772
+ if (shapeSettings.degree) {
773
+ parent.activeObj.rotatedAngle = shapeSettings.degree * (Math.PI / 180);
774
+ }
722
775
  break;
723
776
  }
724
777
  if (parent.activeObj.shape === 'text' && parent.activeObj.textSettings) {
@@ -835,9 +888,12 @@ var Shape = /** @class */ (function () {
835
888
  };
836
889
  Shape.prototype.iterateObjColl = function () {
837
890
  var parent = this.parent;
838
- for (var i = 0, len = parent.objColl.length; i < len; i++) {
839
- this.apply(parent.objColl[i].shape, parent.objColl[i]);
840
- this.refreshActiveObj();
891
+ if (parent.objColl.length > 0) {
892
+ for (var i = 0, len = parent.objColl.length; i < len; i++) {
893
+ this.apply(parent.objColl[i].shape, parent.objColl[i]);
894
+ this.refreshActiveObj();
895
+ }
896
+ parent.notify('draw', { prop: 'applyFrame', value: { ctx: this.lowerContext, frame: parent.frameObj.type, preventImg: true } });
841
897
  }
842
898
  };
843
899
  Shape.prototype.updImgRatioForActObj = function () {
@@ -903,6 +959,7 @@ var Shape = /** @class */ (function () {
903
959
  this.apply(currObj.shape, currObj);
904
960
  this.refreshActiveObj();
905
961
  this.lowerContext.filter = temp;
962
+ parent.notify('draw', { prop: 'applyFrame', value: { ctx: this.lowerContext, frame: parent.frameObj.type, preventImg: true } });
906
963
  }
907
964
  if (currObj.shape !== 'line' && currObj.shape !== 'arrow' && currObj.shape !== 'path' && currObj.rotatedAngle !== 0) {
908
965
  this.setPointCollForShapeRotation(currObj);
@@ -921,6 +978,7 @@ var Shape = /** @class */ (function () {
921
978
  };
922
979
  Shape.prototype.redrawObj = function (degree) {
923
980
  var parent = this.parent;
981
+ var isShape = false;
924
982
  if (this.parent.objColl.length > 0) {
925
983
  if (degree === 'horizontal' || degree === 'vertical' || degree === 'Horizontal' || degree === 'Vertical' ||
926
984
  degree === 'horizontalVertical' || degree === 'verticalHorizontal') {
@@ -935,8 +993,12 @@ var Shape = /** @class */ (function () {
935
993
  var splitWords = parent.objColl[i].shape.split('-');
936
994
  if (splitWords[0] !== 'crop') {
937
995
  this.apply(parent.objColl[i].shape, parent.objColl[i]);
996
+ isShape = true;
938
997
  }
939
998
  }
999
+ if (isShape) {
1000
+ parent.notify('draw', { prop: 'applyFrame', value: { ctx: this.lowerContext, frame: parent.frameObj.type, preventImg: true } });
1001
+ }
940
1002
  this.lowerContext.filter = tempFilter;
941
1003
  }
942
1004
  }
@@ -1477,7 +1539,7 @@ var Shape = /** @class */ (function () {
1477
1539
  currPoint.ratioY = (currPoint.y - parent.img.destTop) / parent.img.destHeight;
1478
1540
  }
1479
1541
  };
1480
- Shape.prototype.stopPathDrawing = function (e) {
1542
+ Shape.prototype.stopPathDrawing = function (e, isApply) {
1481
1543
  var parent = this.parent;
1482
1544
  if (parent.activeObj.shape === 'path') {
1483
1545
  var obj = { shape: null };
@@ -1496,7 +1558,7 @@ var Shape = /** @class */ (function () {
1496
1558
  prevObj.selPointColl = extend([], selPointCollObj['selPointColl'], [], true);
1497
1559
  parent.notify('selection', { prop: 'setCurrentDrawingShape', value: { value: '' } });
1498
1560
  parent.currObjType.isDragging = false;
1499
- if (e.type !== 'touchstart') {
1561
+ if (e && e.type !== 'touchstart' && isNullOrUndefined(isApply)) {
1500
1562
  parent.activeObj.pointColl.pop();
1501
1563
  }
1502
1564
  this.updatePathRatio(parent.activeObj);
@@ -1507,7 +1569,9 @@ var Shape = /** @class */ (function () {
1507
1569
  previousCropObj: prevCropObj, previousText: null,
1508
1570
  currentText: null, previousFilter: null, isCircleCrop: null } });
1509
1571
  parent.objColl.pop();
1510
- parent.notify('selection', { prop: 'mouseUpEventHandler', value: { e: e } });
1572
+ if (e) {
1573
+ parent.notify('selection', { prop: 'mouseUpEventHandler', value: { e: e } });
1574
+ }
1511
1575
  parent.notify('draw', { prop: 'setNewPath', value: { bool: true } });
1512
1576
  if (parent.objColl[parent.objColl.length - 1]) {
1513
1577
  parent.selectShape(parent.objColl[parent.objColl.length - 1].currIndex);
@@ -1524,7 +1588,7 @@ var Shape = /** @class */ (function () {
1524
1588
  Shape.prototype.findTextTarget = function (e) {
1525
1589
  var parent = this.parent;
1526
1590
  if (parent.activeObj.shape !== 'text') {
1527
- this.stopPathDrawing(e);
1591
+ this.stopPathDrawing(e, null);
1528
1592
  return;
1529
1593
  }
1530
1594
  var x;
@@ -1539,11 +1603,16 @@ var Shape = /** @class */ (function () {
1539
1603
  parent.notify('selection', { prop: 'setTouchEndPoint', onPropertyChange: false,
1540
1604
  value: { x: e.touches[0].clientX, y: e.touches[0].clientY } });
1541
1605
  }
1542
- parent.notify('toolbar', { prop: 'setPreventZoomBtn', onPropertyChange: false, value: { isPrevent: true } });
1543
- parent.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: { type: 'text',
1544
- isApplyBtn: null, isCropping: null, isZooming: null, cType: null } });
1545
- parent.notify('toolbar', { prop: 'setPreventZoomBtn', onPropertyChange: false, value: { isPrevent: false } });
1546
- parent.notify('toolbar', { prop: 'update-toolbar-items', onPropertyChange: false });
1606
+ if (!isBlazor()) {
1607
+ parent.notify('toolbar', { prop: 'setPreventZoomBtn', onPropertyChange: false, value: { isPrevent: true } });
1608
+ parent.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: { type: 'text',
1609
+ isApplyBtn: null, isCropping: null, isZooming: null, cType: null } });
1610
+ parent.notify('toolbar', { prop: 'setPreventZoomBtn', onPropertyChange: false, value: { isPrevent: false } });
1611
+ parent.notify('toolbar', { prop: 'update-toolbar-items', onPropertyChange: false });
1612
+ }
1613
+ else {
1614
+ parent.updateToolbar(parent.element, 'enableDisableToolbarBtn', 'textAreaClicked');
1615
+ }
1547
1616
  if (!isNullOrUndefined(x) && !isNullOrUndefined(y)) {
1548
1617
  var bbox = this.parent.lowerCanvas.getBoundingClientRect();
1549
1618
  x -= bbox.left;
@@ -1581,6 +1650,8 @@ var Shape = /** @class */ (function () {
1581
1650
  this.upperContext.clearRect(0, 0, this.parent.upperCanvas.width, this.parent.upperCanvas.height);
1582
1651
  this.lowerContext.clearRect(0, 0, this.parent.upperCanvas.width, this.parent.upperCanvas.height);
1583
1652
  parent.notify('draw', { prop: 'redrawImgWithObj', onPropertyChange: false });
1653
+ this.parent.notify('draw', { prop: 'clearOuterCanvas', onPropertyChange: false, value: { context: this.lowerContext } });
1654
+ this.parent.notify('draw', { prop: 'clearOuterCanvas', onPropertyChange: false, value: { context: this.upperContext } });
1584
1655
  if ((parent.currSelectionPoint && parent.currSelectionPoint.shape === 'crop-circle') || parent.isCircleCrop) {
1585
1656
  parent.notify('crop', { prop: 'cropCircle', onPropertyChange: false,
1586
1657
  value: { context: this.lowerContext, isSave: null, isFlip: null } });
@@ -1631,6 +1702,127 @@ var Shape = /** @class */ (function () {
1631
1702
  parent.textArea.style.display = 'block';
1632
1703
  }
1633
1704
  };
1705
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1706
+ Shape.prototype.fileChanged = function (e) {
1707
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
1708
+ var filesData = e.target.files[0];
1709
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
1710
+ var fileData = filesData;
1711
+ var fileExtension = fileData.name && fileData.name.split('.')[1].toLowerCase();
1712
+ if (fileExtension && ['jpg', 'jpeg', 'png', 'svg'].indexOf(fileExtension) === -1) {
1713
+ this.refreshActiveObj();
1714
+ return;
1715
+ }
1716
+ // eslint-disable-next-line @typescript-eslint/tslint/config, @typescript-eslint/no-explicit-any
1717
+ var URL = window.URL;
1718
+ var url = URL.createObjectURL(e.target.files[0]);
1719
+ this.onLoadImgShape(null, null, null, null, url.toString(), true);
1720
+ if (!isBlazor()) {
1721
+ document.getElementById(this.parent.element.id + '_fileUpload').value = '';
1722
+ }
1723
+ };
1724
+ Shape.prototype.onLoadImgShape = function (x, y, width, height, url, isSelect, degree, isAspectRatio) {
1725
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
1726
+ var proxy = this;
1727
+ if (typeof (url) === 'string') {
1728
+ this.shapeImg.src = url;
1729
+ }
1730
+ else {
1731
+ this.parent.inMemoryCanvas.width = url.width;
1732
+ this.parent.inMemoryCanvas.height = url.height;
1733
+ this.parent.inMemoryCanvas.getContext('2d').putImageData(url, 0, 0);
1734
+ this.shapeImg.src = this.parent.inMemoryCanvas.toDataURL();
1735
+ }
1736
+ this.prevObjColl();
1737
+ this.parent.activeObj.shape = 'image';
1738
+ this.initShapeProps();
1739
+ this.shapeImg.onload = function () {
1740
+ proxy.upperContext.drawImage(proxy.shapeImg, 0, 0, proxy.shapeImg.width, proxy.shapeImg.height);
1741
+ proxy.updateImgCanvas(isSelect, x, y, width, height, degree, isAspectRatio);
1742
+ };
1743
+ };
1744
+ Shape.prototype.updateImgCanvas = function (isSelect, x, y, width, height, degree, isAspectRatio) {
1745
+ var _this = this;
1746
+ var parent = this.parent;
1747
+ parent.activeObj.imageElement = this.shapeImg;
1748
+ parent.activeObj.imageCanvas = parent.createElement('canvas');
1749
+ var dimObj = { width: 0, height: 0 };
1750
+ parent.notify('transform', { prop: 'calcMaxDimension', onPropertyChange: false,
1751
+ value: { width: this.shapeImg.width, height: this.shapeImg.height, obj: dimObj, isImgShape: null } });
1752
+ if (width && height) {
1753
+ if (isAspectRatio) {
1754
+ var obj_1 = { ratio: null };
1755
+ parent.notify('selection', { prop: 'findImageRatio', onPropertyChange: false,
1756
+ value: { width: this.shapeImg.width, height: this.shapeImg.height, obj: obj_1 } });
1757
+ dimObj = this.resizeImage(width, obj_1['ratio']);
1758
+ }
1759
+ else {
1760
+ dimObj = { width: width, height: height };
1761
+ }
1762
+ }
1763
+ this.updateObj(dimObj, x, y);
1764
+ parent.notify('draw', { prop: 'downScaleImgCanvas', onPropertyChange: false,
1765
+ value: { ctx: parent.activeObj.imageCanvas.getContext('2d'), isImgAnnotation: true, isHFlip: null, isVFlip: null } });
1766
+ parent.notify('transform', { prop: 'calcMaxDimension', onPropertyChange: false,
1767
+ value: { width: this.shapeImg.width, height: this.shapeImg.height, obj: dimObj, isImgShape: true } });
1768
+ if (width && height) {
1769
+ if (isAspectRatio) {
1770
+ var obj_2 = { ratio: null };
1771
+ parent.notify('selection', { prop: 'findImageRatio', onPropertyChange: false,
1772
+ value: { width: this.shapeImg.width, height: this.shapeImg.height, obj: obj_2 } });
1773
+ dimObj = this.resizeImage(width, obj_2['ratio']);
1774
+ }
1775
+ else {
1776
+ dimObj = { width: width, height: height };
1777
+ }
1778
+ }
1779
+ this.updateObj(dimObj, x, y);
1780
+ parent.notify('draw', { prop: 'drawObject', onPropertyChange: false, value: { canvas: 'duplicate' } });
1781
+ this.shapeImg = null;
1782
+ if (degree) {
1783
+ parent.activeObj.rotatedAngle = degree * (Math.PI / 180);
1784
+ parent.notify('selection', { prop: 'updPtCollForShpRot', onPropertyChange: false, value: { obj: parent.activeObj } });
1785
+ }
1786
+ var obj = { shapeSettingsObj: {} };
1787
+ parent.notify('selection', { prop: 'updatePrevShapeSettings', onPropertyChange: false, value: { obj: obj } });
1788
+ var shapeSettings = obj['shapeSettingsObj'];
1789
+ var shapeChangingArgs = { action: 'insert', previousShapeSettings: shapeSettings,
1790
+ currentShapeSettings: shapeSettings };
1791
+ if (isBlazor() && parent.events && parent.events.shapeChanging.hasDelegate === true) {
1792
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
1793
+ parent.dotNetRef.invokeMethodAsync('ShapeEventAsync', 'OnShape', shapeChangingArgs).then(function (shapeChangingArgs) {
1794
+ _this.drawShapeImageEvent(shapeChangingArgs, isSelect);
1795
+ if (parent.isPublicMethod) {
1796
+ parent.notify('undo-redo', { prop: 'updateUndoRedo', onPropertyChange: false });
1797
+ }
1798
+ parent.isPublicMethod = false;
1799
+ });
1800
+ }
1801
+ else {
1802
+ parent.trigger('shapeChanging', shapeChangingArgs);
1803
+ this.drawShapeImageEvent(shapeChangingArgs, isSelect);
1804
+ if (parent.isPublicMethod) {
1805
+ parent.notify('undo-redo', { prop: 'updateUndoRedo', onPropertyChange: false });
1806
+ }
1807
+ parent.isPublicMethod = false;
1808
+ }
1809
+ };
1810
+ Shape.prototype.updateObj = function (dimObj, x, y) {
1811
+ var parent = this.parent;
1812
+ parent.activeObj.activePoint.width = dimObj['width'];
1813
+ parent.activeObj.activePoint.height = dimObj['height'];
1814
+ parent.activeObj.activePoint.startX = x ? x : (parent.lowerCanvas.width / 2) - (dimObj['width'] / 2);
1815
+ parent.activeObj.activePoint.startY = y ? y : (parent.lowerCanvas.height / 2) - (dimObj['height'] / 2);
1816
+ parent.activeObj.activePoint.endX = parent.activeObj.activePoint.startX + dimObj['width'];
1817
+ parent.activeObj.activePoint.endY = parent.activeObj.activePoint.startY + dimObj['height'];
1818
+ };
1819
+ Shape.prototype.resizeImage = function (newWidth, aspectRatio) {
1820
+ var aspectRatioArray = aspectRatio.split(':');
1821
+ var aspectRatioWidth = parseInt(aspectRatioArray[0], 10);
1822
+ var aspectRatioHeight = parseInt(aspectRatioArray[1], 10);
1823
+ var newHeight = Math.round((newWidth * aspectRatioHeight) / aspectRatioWidth);
1824
+ return { width: newWidth, height: newHeight };
1825
+ };
1634
1826
  Shape.prototype.setTextBoxPos = function (actObj, degree, flip, x, y) {
1635
1827
  var point = { x: x, y: y };
1636
1828
  switch (degree) {
@@ -1794,73 +1986,76 @@ var Shape = /** @class */ (function () {
1794
1986
  };
1795
1987
  Shape.prototype.panObjColl = function (xDiff, yDiff, panRegion) {
1796
1988
  var parent = this.parent;
1797
- for (var i = 0, len = parent.objColl.length; i < len; i++) {
1798
- var currObj = parent.objColl[i];
1799
- if (panRegion === '' || panRegion === 'vertical') {
1800
- currObj.activePoint.startX += xDiff;
1801
- currObj.activePoint.endX += xDiff;
1802
- if (currObj.rotationCirclePointColl) {
1803
- currObj.rotationCirclePointColl.x += xDiff;
1804
- }
1805
- if (currObj.shape === 'path') {
1806
- for (var l = 0, len_3 = currObj.pointColl.length; l < len_3; l++) {
1807
- currObj.pointColl[l].x += xDiff;
1989
+ if (parent.objColl.length > 0) {
1990
+ for (var i = 0, len = parent.objColl.length; i < len; i++) {
1991
+ var currObj = parent.objColl[i];
1992
+ if (panRegion === '' || panRegion === 'vertical') {
1993
+ currObj.activePoint.startX += xDiff;
1994
+ currObj.activePoint.endX += xDiff;
1995
+ if (currObj.rotationCirclePointColl) {
1996
+ currObj.rotationCirclePointColl.x += xDiff;
1997
+ }
1998
+ if (currObj.shape === 'path') {
1999
+ for (var l = 0, len_3 = currObj.pointColl.length; l < len_3; l++) {
2000
+ currObj.pointColl[l].x += xDiff;
2001
+ }
1808
2002
  }
1809
2003
  }
1810
- }
1811
- else {
1812
- currObj.activePoint.startX -= xDiff;
1813
- currObj.activePoint.endX -= xDiff;
1814
- if (currObj.rotationCirclePointColl) {
1815
- currObj.rotationCirclePointColl.x -= xDiff;
1816
- }
1817
- if (currObj.shape === 'path') {
1818
- for (var l = 0, len_4 = currObj.pointColl.length; l < len_4; l++) {
1819
- currObj.pointColl[l].x -= xDiff;
2004
+ else {
2005
+ currObj.activePoint.startX -= xDiff;
2006
+ currObj.activePoint.endX -= xDiff;
2007
+ if (currObj.rotationCirclePointColl) {
2008
+ currObj.rotationCirclePointColl.x -= xDiff;
2009
+ }
2010
+ if (currObj.shape === 'path') {
2011
+ for (var l = 0, len_4 = currObj.pointColl.length; l < len_4; l++) {
2012
+ currObj.pointColl[l].x -= xDiff;
2013
+ }
1820
2014
  }
1821
2015
  }
1822
- }
1823
- if (panRegion === '' || panRegion === 'horizontal') {
1824
- currObj.activePoint.startY += yDiff;
1825
- currObj.activePoint.endY += yDiff;
1826
- if (currObj.rotationCirclePointColl) {
1827
- currObj.rotationCirclePointColl.y += yDiff;
1828
- }
1829
- if (currObj.shape === 'path') {
1830
- for (var l = 0; l < currObj.pointColl.length; l++) {
1831
- currObj.pointColl[l].y += yDiff;
2016
+ if (panRegion === '' || panRegion === 'horizontal') {
2017
+ currObj.activePoint.startY += yDiff;
2018
+ currObj.activePoint.endY += yDiff;
2019
+ if (currObj.rotationCirclePointColl) {
2020
+ currObj.rotationCirclePointColl.y += yDiff;
2021
+ }
2022
+ if (currObj.shape === 'path') {
2023
+ for (var l = 0; l < currObj.pointColl.length; l++) {
2024
+ currObj.pointColl[l].y += yDiff;
2025
+ }
1832
2026
  }
1833
2027
  }
1834
- }
1835
- else {
1836
- currObj.activePoint.startY -= yDiff;
1837
- currObj.activePoint.endY -= yDiff;
1838
- if (currObj.rotationCirclePointColl) {
1839
- currObj.rotationCirclePointColl.y -= yDiff;
1840
- }
1841
- if (currObj.shape === 'path') {
1842
- for (var l = 0; l < currObj.pointColl.length; l++) {
1843
- currObj.pointColl[l].y -= yDiff;
2028
+ else {
2029
+ currObj.activePoint.startY -= yDiff;
2030
+ currObj.activePoint.endY -= yDiff;
2031
+ if (currObj.rotationCirclePointColl) {
2032
+ currObj.rotationCirclePointColl.y -= yDiff;
2033
+ }
2034
+ if (currObj.shape === 'path') {
2035
+ for (var l = 0; l < currObj.pointColl.length; l++) {
2036
+ currObj.pointColl[l].y -= yDiff;
2037
+ }
1844
2038
  }
1845
2039
  }
1846
- }
1847
- currObj = this.updateWidthHeight(currObj);
1848
- parent.notify('draw', { prop: 'updateActiveObject', onPropertyChange: false, value: { actPoint: currObj.activePoint,
1849
- obj: currObj } });
1850
- if (currObj.shape === 'line' || currObj.shape === 'arrow') {
1851
- currObj.pointColl = this.getLinePoints(currObj.activePoint.startX, currObj.activePoint.startY, currObj.activePoint.endX, currObj.activePoint.endY);
1852
- for (var j = 0, len_5 = currObj.pointColl.length; j < len_5; j++) {
1853
- currObj.pointColl[j].ratioX =
1854
- (currObj.pointColl[j].x - parent.img.destLeft) / parent.img.destWidth;
1855
- currObj.pointColl[j].ratioY =
1856
- (currObj.pointColl[j].y - parent.img.destTop) / parent.img.destHeight;
2040
+ currObj = this.updateWidthHeight(currObj);
2041
+ parent.notify('draw', { prop: 'updateActiveObject', onPropertyChange: false, value: { actPoint: currObj.activePoint,
2042
+ obj: currObj } });
2043
+ if (currObj.shape === 'line' || currObj.shape === 'arrow') {
2044
+ currObj.pointColl = this.getLinePoints(currObj.activePoint.startX, currObj.activePoint.startY, currObj.activePoint.endX, currObj.activePoint.endY);
2045
+ for (var j = 0, len_5 = currObj.pointColl.length; j < len_5; j++) {
2046
+ currObj.pointColl[j].ratioX =
2047
+ (currObj.pointColl[j].x - parent.img.destLeft) / parent.img.destWidth;
2048
+ currObj.pointColl[j].ratioY =
2049
+ (currObj.pointColl[j].y - parent.img.destTop) / parent.img.destHeight;
2050
+ }
1857
2051
  }
2052
+ var temp = this.lowerContext.filter;
2053
+ this.lowerContext.filter = 'none';
2054
+ this.apply(currObj.shape, currObj);
2055
+ this.lowerContext.filter = temp;
2056
+ this.refreshActiveObj();
1858
2057
  }
1859
- var temp = this.lowerContext.filter;
1860
- this.lowerContext.filter = 'none';
1861
- this.apply(currObj.shape, currObj);
1862
- this.lowerContext.filter = temp;
1863
- this.refreshActiveObj();
2058
+ parent.notify('draw', { prop: 'applyFrame', value: { ctx: this.lowerContext, frame: parent.frameObj.type, preventImg: true } });
1864
2059
  }
1865
2060
  };
1866
2061
  Shape.prototype.updateFontStyles = function (isTextBox) {
@@ -2269,14 +2464,14 @@ var Shape = /** @class */ (function () {
2269
2464
  if (!parent.disabled && parent.isImageLoaded) {
2270
2465
  this.applyActObj();
2271
2466
  if (id.split('_')[0] === 'shape') {
2272
- var obj_1;
2467
+ var obj_3;
2273
2468
  for (var i = 0, len = parent.objColl.length; i < len; i++) {
2274
2469
  if (parent.objColl[i].currIndex === id) {
2275
- obj_1 = extend({}, parent.objColl[i], {}, true);
2470
+ obj_3 = extend({}, parent.objColl[i], {}, true);
2276
2471
  break;
2277
2472
  }
2278
2473
  }
2279
- shapeDetails = this.getObjDetails(obj_1);
2474
+ shapeDetails = this.getObjDetails(obj_3);
2280
2475
  }
2281
2476
  else if (id.split('_')[0] === 'pen') {
2282
2477
  shapeDetails = this.getFreehandDrawDetails(parseInt(id.split('_')[1], 10) - 1);
@@ -2428,19 +2623,19 @@ var Shape = /** @class */ (function () {
2428
2623
  if (!parent.disabled && parent.isImageLoaded) {
2429
2624
  this.applyActObj();
2430
2625
  if (id.split('_')[0] === 'shape') {
2431
- var obj_2;
2626
+ var obj_4;
2432
2627
  for (var i = 0, len = parent.objColl.length; i < len; i++) {
2433
2628
  if (parent.objColl[i].currIndex === id) {
2434
- obj_2 = extend({}, parent.objColl[i], {}, true);
2629
+ obj_4 = extend({}, parent.objColl[i], {}, true);
2435
2630
  break;
2436
2631
  }
2437
2632
  }
2438
- if (isNullOrUndefined(obj_2)) {
2633
+ if (isNullOrUndefined(obj_4)) {
2439
2634
  isSelected = false;
2440
2635
  }
2441
2636
  else {
2442
2637
  isSelected = true;
2443
- parent.activeObj = obj_2;
2638
+ parent.activeObj = obj_4;
2444
2639
  var object = { canvasFilter: null };
2445
2640
  parent.notify('toolbar', { prop: 'getCanvasFilter', onPropertyChange: false, value: { obj: object } });
2446
2641
  this.lowerContext.filter = object['canvasFilter'];
@@ -2479,9 +2674,9 @@ var Shape = /** @class */ (function () {
2479
2674
  if (object['bool']) {
2480
2675
  parent.okBtn();
2481
2676
  }
2482
- var obj_3 = { isIndex: false };
2483
- parent.notify('freehand-draw', { prop: 'isFHDIdx', value: { index: parseInt(id.split('_')[1], 10) - 1, obj: obj_3 } });
2484
- if (obj_3['isIndex']) {
2677
+ var obj_5 = { isIndex: false };
2678
+ parent.notify('freehand-draw', { prop: 'isFHDIdx', value: { index: parseInt(id.split('_')[1], 10) - 1, obj: obj_5 } });
2679
+ if (obj_5['isIndex']) {
2485
2680
  isSelected = true;
2486
2681
  parent.notify('freehand-draw', { prop: 'selectFhd', value: { id: id } });
2487
2682
  if (!isBlazor()) {
@@ -17,6 +17,9 @@ export declare class Transform {
17
17
  private isShape;
18
18
  private cropDimension;
19
19
  private isPreventSelect;
20
+ private prevResizeCurrObj;
21
+ private preventDownScale;
22
+ private resizedImgAngle;
20
23
  constructor(parent: ImageEditor);
21
24
  destroy(): void;
22
25
  private addEventListener;
@@ -64,4 +67,10 @@ export declare class Transform {
64
67
  private update;
65
68
  private calcMaxDimension;
66
69
  private updatePanPoints;
70
+ private resizeImage;
71
+ private resizeCrop;
72
+ private resizeImg;
73
+ private updateResize;
74
+ private resize;
75
+ private resizeEventHandler;
67
76
  }