@syncfusion/ej2-image-editor 22.2.11 → 23.1.38

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 (119) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/ej2-image-editor.umd.min.js +3 -3
  3. package/dist/ej2-image-editor.umd.min.js.map +1 -1
  4. package/dist/es6/ej2-image-editor.es2015.js +4446 -678
  5. package/dist/es6/ej2-image-editor.es2015.js.map +1 -1
  6. package/dist/es6/ej2-image-editor.es5.js +4409 -632
  7. package/dist/es6/ej2-image-editor.es5.js.map +1 -1
  8. package/dist/global/ej2-image-editor.min.js +3 -3
  9. package/dist/global/ej2-image-editor.min.js.map +1 -1
  10. package/dist/global/index.d.ts +2 -2
  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.d.ts +1 -0
  20. package/src/image-editor/action/freehand-draw.js +92 -56
  21. package/src/image-editor/action/selection.d.ts +6 -0
  22. package/src/image-editor/action/selection.js +417 -68
  23. package/src/image-editor/action/shape.d.ts +8 -0
  24. package/src/image-editor/action/shape.js +303 -91
  25. package/src/image-editor/action/transform.d.ts +9 -0
  26. package/src/image-editor/action/transform.js +402 -52
  27. package/src/image-editor/action/undo-redo.d.ts +1 -0
  28. package/src/image-editor/action/undo-redo.js +138 -10
  29. package/src/image-editor/base/enum.d.ts +38 -1
  30. package/src/image-editor/base/enum.js +39 -0
  31. package/src/image-editor/base/image-editor-model.d.ts +16 -2
  32. package/src/image-editor/base/image-editor.d.ts +142 -7
  33. package/src/image-editor/base/image-editor.js +719 -70
  34. package/src/image-editor/base/interface.d.ts +233 -2
  35. package/src/image-editor/renderer/toolbar.d.ts +25 -0
  36. package/src/image-editor/renderer/toolbar.js +1274 -72
  37. package/styles/bootstrap-dark.css +73 -1
  38. package/styles/bootstrap.css +73 -1
  39. package/styles/bootstrap4.css +73 -1
  40. package/styles/bootstrap5-dark.css +73 -1
  41. package/styles/bootstrap5.css +73 -1
  42. package/styles/fabric-dark.css +73 -1
  43. package/styles/fabric.css +73 -1
  44. package/styles/fluent-dark.css +73 -1
  45. package/styles/fluent.css +73 -1
  46. package/styles/highcontrast-light.css +75 -3
  47. package/styles/highcontrast.css +74 -7
  48. package/styles/image-editor/_bootstrap-dark-definition.scss +1 -0
  49. package/styles/image-editor/_bootstrap-definition.scss +1 -0
  50. package/styles/image-editor/_bootstrap4-definition.scss +1 -0
  51. package/styles/image-editor/_bootstrap5-definition.scss +1 -0
  52. package/styles/image-editor/_fabric-dark-definition.scss +1 -0
  53. package/styles/image-editor/_fabric-definition.scss +1 -0
  54. package/styles/image-editor/_fluent-definition.scss +1 -0
  55. package/styles/image-editor/_fusionnew-definition.scss +1 -0
  56. package/styles/image-editor/_highcontrast-definition.scss +2 -1
  57. package/styles/image-editor/_highcontrast-light-definition.scss +2 -1
  58. package/styles/image-editor/_layout.scss +98 -0
  59. package/styles/image-editor/_material-dark-definition.scss +1 -0
  60. package/styles/image-editor/_material-definition.scss +1 -0
  61. package/styles/image-editor/_material3-definition.scss +2 -1
  62. package/styles/image-editor/_tailwind-definition.scss +1 -0
  63. package/styles/image-editor/_theme.scss +4 -2
  64. package/styles/image-editor/bootstrap-dark.css +73 -1
  65. package/styles/image-editor/bootstrap-dark.scss +1 -1
  66. package/styles/image-editor/bootstrap.css +73 -1
  67. package/styles/image-editor/bootstrap.scss +1 -1
  68. package/styles/image-editor/bootstrap4.css +73 -1
  69. package/styles/image-editor/bootstrap4.scss +1 -1
  70. package/styles/image-editor/bootstrap5-dark.css +73 -1
  71. package/styles/image-editor/bootstrap5-dark.scss +1 -1
  72. package/styles/image-editor/bootstrap5.css +73 -1
  73. package/styles/image-editor/bootstrap5.scss +1 -1
  74. package/styles/image-editor/fabric-dark.css +73 -1
  75. package/styles/image-editor/fabric-dark.scss +1 -1
  76. package/styles/image-editor/fabric.css +73 -1
  77. package/styles/image-editor/fabric.scss +1 -1
  78. package/styles/image-editor/fluent-dark.css +73 -1
  79. package/styles/image-editor/fluent-dark.scss +1 -1
  80. package/styles/image-editor/fluent.css +73 -1
  81. package/styles/image-editor/fluent.scss +1 -1
  82. package/styles/image-editor/highcontrast-light.css +75 -3
  83. package/styles/image-editor/highcontrast-light.scss +1 -1
  84. package/styles/image-editor/highcontrast.css +74 -7
  85. package/styles/image-editor/highcontrast.scss +1 -1
  86. package/styles/image-editor/icons/_bootstrap-dark.scss +1 -0
  87. package/styles/image-editor/icons/_bootstrap.scss +1 -0
  88. package/styles/image-editor/icons/_bootstrap4.scss +1 -0
  89. package/styles/image-editor/icons/_bootstrap5.scss +1 -0
  90. package/styles/image-editor/icons/_fabric-dark.scss +1 -0
  91. package/styles/image-editor/icons/_fabric.scss +1 -0
  92. package/styles/image-editor/icons/_fluent.scss +1 -0
  93. package/styles/image-editor/icons/_fusionnew.scss +1 -0
  94. package/styles/image-editor/icons/_highcontrast-light.scss +1 -0
  95. package/styles/image-editor/icons/_highcontrast.scss +1 -0
  96. package/styles/image-editor/icons/_material-dark.scss +1 -0
  97. package/styles/image-editor/icons/_material.scss +1 -0
  98. package/styles/image-editor/icons/_material3.scss +1 -0
  99. package/styles/image-editor/icons/_tailwind.scss +1 -0
  100. package/styles/image-editor/material-dark.css +73 -2
  101. package/styles/image-editor/material-dark.scss +1 -1
  102. package/styles/image-editor/material.css +73 -2
  103. package/styles/image-editor/material.scss +1 -1
  104. package/styles/image-editor/material3-dark.css +78 -4
  105. package/styles/image-editor/material3-dark.scss +1 -1
  106. package/styles/image-editor/material3.css +78 -4
  107. package/styles/image-editor/material3.scss +1 -1
  108. package/styles/image-editor/tailwind-dark.css +73 -2
  109. package/styles/image-editor/tailwind-dark.scss +1 -1
  110. package/styles/image-editor/tailwind.css +73 -2
  111. package/styles/image-editor/tailwind.scss +1 -1
  112. package/styles/material-dark.css +73 -2
  113. package/styles/material.css +73 -2
  114. package/styles/material3-dark.css +78 -4
  115. package/styles/material3-dark.scss +1 -1
  116. package/styles/material3.css +78 -4
  117. package/styles/material3.scss +1 -1
  118. package/styles/tailwind-dark.css +73 -2
  119. package/styles/tailwind.css +73 -2
@@ -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;
@@ -704,9 +752,13 @@ var Shape = /** @class */ (function () {
704
752
  parent.activeObj.activePoint.endY = parent.activeObj.activePoint.startY + parent.activeObj.activePoint.height;
705
753
  parent.activeObj.strokeSettings.strokeColor = shapeSettings.strokeColor;
706
754
  parent.activeObj.strokeSettings.fillColor = shapeSettings.fillColor;
755
+ if (isNullOrUndefined(shapeSettings.degree)) {
756
+ shapeSettings.degree = 0;
757
+ }
707
758
  switch (parent.activeObj.shape) {
708
759
  case 'ellipse':
709
760
  parent.activeObj.activePoint.width = shapeSettings.radius * 2;
761
+ parent.activeObj.rotatedAngle = shapeSettings.degree * (Math.PI / 180);
710
762
  break;
711
763
  case 'line':
712
764
  case 'arrow':
@@ -719,6 +771,10 @@ var Shape = /** @class */ (function () {
719
771
  parent.activeObj.textSettings.fontFamily = shapeSettings.fontFamily;
720
772
  break;
721
773
  case 'rectangle':
774
+ case 'image':
775
+ if (shapeSettings.degree) {
776
+ parent.activeObj.rotatedAngle = shapeSettings.degree * (Math.PI / 180);
777
+ }
722
778
  break;
723
779
  }
724
780
  if (parent.activeObj.shape === 'text' && parent.activeObj.textSettings) {
@@ -835,9 +891,12 @@ var Shape = /** @class */ (function () {
835
891
  };
836
892
  Shape.prototype.iterateObjColl = function () {
837
893
  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();
894
+ if (parent.objColl.length > 0) {
895
+ for (var i = 0, len = parent.objColl.length; i < len; i++) {
896
+ this.apply(parent.objColl[i].shape, parent.objColl[i]);
897
+ this.refreshActiveObj();
898
+ }
899
+ parent.notify('draw', { prop: 'applyFrame', value: { ctx: this.lowerContext, frame: parent.frameObj.type, preventImg: true } });
841
900
  }
842
901
  };
843
902
  Shape.prototype.updImgRatioForActObj = function () {
@@ -903,6 +962,7 @@ var Shape = /** @class */ (function () {
903
962
  this.apply(currObj.shape, currObj);
904
963
  this.refreshActiveObj();
905
964
  this.lowerContext.filter = temp;
965
+ parent.notify('draw', { prop: 'applyFrame', value: { ctx: this.lowerContext, frame: parent.frameObj.type, preventImg: true } });
906
966
  }
907
967
  if (currObj.shape !== 'line' && currObj.shape !== 'arrow' && currObj.shape !== 'path' && currObj.rotatedAngle !== 0) {
908
968
  this.setPointCollForShapeRotation(currObj);
@@ -921,6 +981,7 @@ var Shape = /** @class */ (function () {
921
981
  };
922
982
  Shape.prototype.redrawObj = function (degree) {
923
983
  var parent = this.parent;
984
+ var isShape = false;
924
985
  if (this.parent.objColl.length > 0) {
925
986
  if (degree === 'horizontal' || degree === 'vertical' || degree === 'Horizontal' || degree === 'Vertical' ||
926
987
  degree === 'horizontalVertical' || degree === 'verticalHorizontal') {
@@ -935,8 +996,12 @@ var Shape = /** @class */ (function () {
935
996
  var splitWords = parent.objColl[i].shape.split('-');
936
997
  if (splitWords[0] !== 'crop') {
937
998
  this.apply(parent.objColl[i].shape, parent.objColl[i]);
999
+ isShape = true;
938
1000
  }
939
1001
  }
1002
+ if (isShape) {
1003
+ parent.notify('draw', { prop: 'applyFrame', value: { ctx: this.lowerContext, frame: parent.frameObj.type, preventImg: true } });
1004
+ }
940
1005
  this.lowerContext.filter = tempFilter;
941
1006
  }
942
1007
  }
@@ -1477,7 +1542,7 @@ var Shape = /** @class */ (function () {
1477
1542
  currPoint.ratioY = (currPoint.y - parent.img.destTop) / parent.img.destHeight;
1478
1543
  }
1479
1544
  };
1480
- Shape.prototype.stopPathDrawing = function (e) {
1545
+ Shape.prototype.stopPathDrawing = function (e, isApply) {
1481
1546
  var parent = this.parent;
1482
1547
  if (parent.activeObj.shape === 'path') {
1483
1548
  var obj = { shape: null };
@@ -1496,7 +1561,7 @@ var Shape = /** @class */ (function () {
1496
1561
  prevObj.selPointColl = extend([], selPointCollObj['selPointColl'], [], true);
1497
1562
  parent.notify('selection', { prop: 'setCurrentDrawingShape', value: { value: '' } });
1498
1563
  parent.currObjType.isDragging = false;
1499
- if (e.type !== 'touchstart') {
1564
+ if (e && e.type !== 'touchstart' && isNullOrUndefined(isApply)) {
1500
1565
  parent.activeObj.pointColl.pop();
1501
1566
  }
1502
1567
  this.updatePathRatio(parent.activeObj);
@@ -1507,7 +1572,9 @@ var Shape = /** @class */ (function () {
1507
1572
  previousCropObj: prevCropObj, previousText: null,
1508
1573
  currentText: null, previousFilter: null, isCircleCrop: null } });
1509
1574
  parent.objColl.pop();
1510
- parent.notify('selection', { prop: 'mouseUpEventHandler', value: { e: e } });
1575
+ if (e) {
1576
+ parent.notify('selection', { prop: 'mouseUpEventHandler', value: { e: e } });
1577
+ }
1511
1578
  parent.notify('draw', { prop: 'setNewPath', value: { bool: true } });
1512
1579
  if (parent.objColl[parent.objColl.length - 1]) {
1513
1580
  parent.selectShape(parent.objColl[parent.objColl.length - 1].currIndex);
@@ -1518,13 +1585,20 @@ var Shape = /** @class */ (function () {
1518
1585
  else {
1519
1586
  parent.updateToolbar(parent.element, 'quickAccessToolbar', parent.activeObj.shape);
1520
1587
  }
1588
+ var obj_1 = { shapeSettingsObj: {} };
1589
+ parent.notify('selection', { prop: 'updatePrevShapeSettings', onPropertyChange: false, value: { obj: obj_1 } });
1590
+ var shapeSettings = obj_1['shapeSettingsObj'];
1591
+ var shapeResizingArgs = { action: 'draw-end', previousShapeSettings: shapeSettings };
1592
+ var shapeMovingArgs = { action: 'move', previousShapeSettings: shapeSettings };
1593
+ parent.notify('selection', { prop: 'triggerShapeChange', onPropertyChange: false,
1594
+ value: { shapeResizingArgs: shapeResizingArgs, shapeMovingArgs: shapeMovingArgs, type: 'mouse-up' } });
1521
1595
  }
1522
1596
  }
1523
1597
  };
1524
1598
  Shape.prototype.findTextTarget = function (e) {
1525
1599
  var parent = this.parent;
1526
1600
  if (parent.activeObj.shape !== 'text') {
1527
- this.stopPathDrawing(e);
1601
+ this.stopPathDrawing(e, null);
1528
1602
  return;
1529
1603
  }
1530
1604
  var x;
@@ -1539,11 +1613,16 @@ var Shape = /** @class */ (function () {
1539
1613
  parent.notify('selection', { prop: 'setTouchEndPoint', onPropertyChange: false,
1540
1614
  value: { x: e.touches[0].clientX, y: e.touches[0].clientY } });
1541
1615
  }
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 });
1616
+ if (!isBlazor()) {
1617
+ parent.notify('toolbar', { prop: 'setPreventZoomBtn', onPropertyChange: false, value: { isPrevent: true } });
1618
+ parent.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: { type: 'text',
1619
+ isApplyBtn: null, isCropping: null, isZooming: null, cType: null } });
1620
+ parent.notify('toolbar', { prop: 'setPreventZoomBtn', onPropertyChange: false, value: { isPrevent: false } });
1621
+ parent.notify('toolbar', { prop: 'update-toolbar-items', onPropertyChange: false });
1622
+ }
1623
+ else {
1624
+ parent.updateToolbar(parent.element, 'enableDisableToolbarBtn', 'textAreaClicked');
1625
+ }
1547
1626
  if (!isNullOrUndefined(x) && !isNullOrUndefined(y)) {
1548
1627
  var bbox = this.parent.lowerCanvas.getBoundingClientRect();
1549
1628
  x -= bbox.left;
@@ -1581,6 +1660,8 @@ var Shape = /** @class */ (function () {
1581
1660
  this.upperContext.clearRect(0, 0, this.parent.upperCanvas.width, this.parent.upperCanvas.height);
1582
1661
  this.lowerContext.clearRect(0, 0, this.parent.upperCanvas.width, this.parent.upperCanvas.height);
1583
1662
  parent.notify('draw', { prop: 'redrawImgWithObj', onPropertyChange: false });
1663
+ this.parent.notify('draw', { prop: 'clearOuterCanvas', onPropertyChange: false, value: { context: this.lowerContext } });
1664
+ this.parent.notify('draw', { prop: 'clearOuterCanvas', onPropertyChange: false, value: { context: this.upperContext } });
1584
1665
  if ((parent.currSelectionPoint && parent.currSelectionPoint.shape === 'crop-circle') || parent.isCircleCrop) {
1585
1666
  parent.notify('crop', { prop: 'cropCircle', onPropertyChange: false,
1586
1667
  value: { context: this.lowerContext, isSave: null, isFlip: null } });
@@ -1631,6 +1712,127 @@ var Shape = /** @class */ (function () {
1631
1712
  parent.textArea.style.display = 'block';
1632
1713
  }
1633
1714
  };
1715
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1716
+ Shape.prototype.fileChanged = function (e) {
1717
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
1718
+ var filesData = e.target.files[0];
1719
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
1720
+ var fileData = filesData;
1721
+ var fileExtension = fileData.name && fileData.name.split('.')[1].toLowerCase();
1722
+ if (fileExtension && ['jpg', 'jpeg', 'png', 'svg'].indexOf(fileExtension) === -1) {
1723
+ this.refreshActiveObj();
1724
+ return;
1725
+ }
1726
+ // eslint-disable-next-line @typescript-eslint/tslint/config, @typescript-eslint/no-explicit-any
1727
+ var URL = window.URL;
1728
+ var url = URL.createObjectURL(e.target.files[0]);
1729
+ this.onLoadImgShape(null, null, null, null, url.toString(), true);
1730
+ if (!isBlazor()) {
1731
+ document.getElementById(this.parent.element.id + '_fileUpload').value = '';
1732
+ }
1733
+ };
1734
+ Shape.prototype.onLoadImgShape = function (x, y, width, height, url, isSelect, degree, isAspectRatio) {
1735
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
1736
+ var proxy = this;
1737
+ if (typeof (url) === 'string') {
1738
+ this.shapeImg.src = url;
1739
+ }
1740
+ else {
1741
+ this.parent.inMemoryCanvas.width = url.width;
1742
+ this.parent.inMemoryCanvas.height = url.height;
1743
+ this.parent.inMemoryCanvas.getContext('2d').putImageData(url, 0, 0);
1744
+ this.shapeImg.src = this.parent.inMemoryCanvas.toDataURL();
1745
+ }
1746
+ this.prevObjColl();
1747
+ this.parent.activeObj.shape = 'image';
1748
+ this.initShapeProps();
1749
+ this.shapeImg.onload = function () {
1750
+ proxy.upperContext.drawImage(proxy.shapeImg, 0, 0, proxy.shapeImg.width, proxy.shapeImg.height);
1751
+ proxy.updateImgCanvas(isSelect, x, y, width, height, degree, isAspectRatio);
1752
+ };
1753
+ };
1754
+ Shape.prototype.updateImgCanvas = function (isSelect, x, y, width, height, degree, isAspectRatio) {
1755
+ var _this = this;
1756
+ var parent = this.parent;
1757
+ parent.activeObj.imageElement = this.shapeImg;
1758
+ parent.activeObj.imageCanvas = parent.createElement('canvas');
1759
+ var dimObj = { width: 0, height: 0 };
1760
+ parent.notify('transform', { prop: 'calcMaxDimension', onPropertyChange: false,
1761
+ value: { width: this.shapeImg.width, height: this.shapeImg.height, obj: dimObj, isImgShape: null } });
1762
+ if (width && height) {
1763
+ if (isAspectRatio) {
1764
+ var obj_2 = { ratio: null };
1765
+ parent.notify('selection', { prop: 'findImageRatio', onPropertyChange: false,
1766
+ value: { width: this.shapeImg.width, height: this.shapeImg.height, obj: obj_2 } });
1767
+ dimObj = this.resizeImage(width, obj_2['ratio']);
1768
+ }
1769
+ else {
1770
+ dimObj = { width: width, height: height };
1771
+ }
1772
+ }
1773
+ this.updateObj(dimObj, x, y);
1774
+ parent.notify('draw', { prop: 'downScaleImgCanvas', onPropertyChange: false,
1775
+ value: { ctx: parent.activeObj.imageCanvas.getContext('2d'), isImgAnnotation: true, isHFlip: null, isVFlip: null } });
1776
+ parent.notify('transform', { prop: 'calcMaxDimension', onPropertyChange: false,
1777
+ value: { width: this.shapeImg.width, height: this.shapeImg.height, obj: dimObj, isImgShape: true } });
1778
+ if (width && height) {
1779
+ if (isAspectRatio) {
1780
+ var obj_3 = { ratio: null };
1781
+ parent.notify('selection', { prop: 'findImageRatio', onPropertyChange: false,
1782
+ value: { width: this.shapeImg.width, height: this.shapeImg.height, obj: obj_3 } });
1783
+ dimObj = this.resizeImage(width, obj_3['ratio']);
1784
+ }
1785
+ else {
1786
+ dimObj = { width: width, height: height };
1787
+ }
1788
+ }
1789
+ this.updateObj(dimObj, x, y);
1790
+ parent.notify('draw', { prop: 'drawObject', onPropertyChange: false, value: { canvas: 'duplicate' } });
1791
+ this.shapeImg = null;
1792
+ if (degree) {
1793
+ parent.activeObj.rotatedAngle = degree * (Math.PI / 180);
1794
+ parent.notify('selection', { prop: 'updPtCollForShpRot', onPropertyChange: false, value: { obj: parent.activeObj } });
1795
+ }
1796
+ var obj = { shapeSettingsObj: {} };
1797
+ parent.notify('selection', { prop: 'updatePrevShapeSettings', onPropertyChange: false, value: { obj: obj } });
1798
+ var shapeSettings = obj['shapeSettingsObj'];
1799
+ var shapeChangingArgs = { action: 'insert', previousShapeSettings: shapeSettings,
1800
+ currentShapeSettings: shapeSettings };
1801
+ if (isBlazor() && parent.events && parent.events.shapeChanging.hasDelegate === true) {
1802
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
1803
+ parent.dotNetRef.invokeMethodAsync('ShapeEventAsync', 'OnShape', shapeChangingArgs).then(function (shapeChangingArgs) {
1804
+ _this.drawShapeImageEvent(shapeChangingArgs, isSelect);
1805
+ if (parent.isPublicMethod) {
1806
+ parent.notify('undo-redo', { prop: 'updateUndoRedo', onPropertyChange: false });
1807
+ }
1808
+ parent.isPublicMethod = false;
1809
+ });
1810
+ }
1811
+ else {
1812
+ parent.trigger('shapeChanging', shapeChangingArgs);
1813
+ this.drawShapeImageEvent(shapeChangingArgs, isSelect);
1814
+ if (parent.isPublicMethod) {
1815
+ parent.notify('undo-redo', { prop: 'updateUndoRedo', onPropertyChange: false });
1816
+ }
1817
+ parent.isPublicMethod = false;
1818
+ }
1819
+ };
1820
+ Shape.prototype.updateObj = function (dimObj, x, y) {
1821
+ var parent = this.parent;
1822
+ parent.activeObj.activePoint.width = dimObj['width'];
1823
+ parent.activeObj.activePoint.height = dimObj['height'];
1824
+ parent.activeObj.activePoint.startX = x ? x : (parent.lowerCanvas.width / 2) - (dimObj['width'] / 2);
1825
+ parent.activeObj.activePoint.startY = y ? y : (parent.lowerCanvas.height / 2) - (dimObj['height'] / 2);
1826
+ parent.activeObj.activePoint.endX = parent.activeObj.activePoint.startX + dimObj['width'];
1827
+ parent.activeObj.activePoint.endY = parent.activeObj.activePoint.startY + dimObj['height'];
1828
+ };
1829
+ Shape.prototype.resizeImage = function (newWidth, aspectRatio) {
1830
+ var aspectRatioArray = aspectRatio.split(':');
1831
+ var aspectRatioWidth = parseInt(aspectRatioArray[0], 10);
1832
+ var aspectRatioHeight = parseInt(aspectRatioArray[1], 10);
1833
+ var newHeight = Math.round((newWidth * aspectRatioHeight) / aspectRatioWidth);
1834
+ return { width: newWidth, height: newHeight };
1835
+ };
1634
1836
  Shape.prototype.setTextBoxPos = function (actObj, degree, flip, x, y) {
1635
1837
  var point = { x: x, y: y };
1636
1838
  switch (degree) {
@@ -1794,73 +1996,76 @@ var Shape = /** @class */ (function () {
1794
1996
  };
1795
1997
  Shape.prototype.panObjColl = function (xDiff, yDiff, panRegion) {
1796
1998
  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;
1999
+ if (parent.objColl.length > 0) {
2000
+ for (var i = 0, len = parent.objColl.length; i < len; i++) {
2001
+ var currObj = parent.objColl[i];
2002
+ if (panRegion === '' || panRegion === 'vertical') {
2003
+ currObj.activePoint.startX += xDiff;
2004
+ currObj.activePoint.endX += xDiff;
2005
+ if (currObj.rotationCirclePointColl) {
2006
+ currObj.rotationCirclePointColl.x += xDiff;
2007
+ }
2008
+ if (currObj.shape === 'path') {
2009
+ for (var l = 0, len_3 = currObj.pointColl.length; l < len_3; l++) {
2010
+ currObj.pointColl[l].x += xDiff;
2011
+ }
1808
2012
  }
1809
2013
  }
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;
2014
+ else {
2015
+ currObj.activePoint.startX -= xDiff;
2016
+ currObj.activePoint.endX -= xDiff;
2017
+ if (currObj.rotationCirclePointColl) {
2018
+ currObj.rotationCirclePointColl.x -= xDiff;
2019
+ }
2020
+ if (currObj.shape === 'path') {
2021
+ for (var l = 0, len_4 = currObj.pointColl.length; l < len_4; l++) {
2022
+ currObj.pointColl[l].x -= xDiff;
2023
+ }
1820
2024
  }
1821
2025
  }
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;
2026
+ if (panRegion === '' || panRegion === 'horizontal') {
2027
+ currObj.activePoint.startY += yDiff;
2028
+ currObj.activePoint.endY += yDiff;
2029
+ if (currObj.rotationCirclePointColl) {
2030
+ currObj.rotationCirclePointColl.y += yDiff;
2031
+ }
2032
+ if (currObj.shape === 'path') {
2033
+ for (var l = 0; l < currObj.pointColl.length; l++) {
2034
+ currObj.pointColl[l].y += yDiff;
2035
+ }
1832
2036
  }
1833
2037
  }
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;
2038
+ else {
2039
+ currObj.activePoint.startY -= yDiff;
2040
+ currObj.activePoint.endY -= yDiff;
2041
+ if (currObj.rotationCirclePointColl) {
2042
+ currObj.rotationCirclePointColl.y -= yDiff;
2043
+ }
2044
+ if (currObj.shape === 'path') {
2045
+ for (var l = 0; l < currObj.pointColl.length; l++) {
2046
+ currObj.pointColl[l].y -= yDiff;
2047
+ }
1844
2048
  }
1845
2049
  }
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;
2050
+ currObj = this.updateWidthHeight(currObj);
2051
+ parent.notify('draw', { prop: 'updateActiveObject', onPropertyChange: false, value: { actPoint: currObj.activePoint,
2052
+ obj: currObj } });
2053
+ if (currObj.shape === 'line' || currObj.shape === 'arrow') {
2054
+ currObj.pointColl = this.getLinePoints(currObj.activePoint.startX, currObj.activePoint.startY, currObj.activePoint.endX, currObj.activePoint.endY);
2055
+ for (var j = 0, len_5 = currObj.pointColl.length; j < len_5; j++) {
2056
+ currObj.pointColl[j].ratioX =
2057
+ (currObj.pointColl[j].x - parent.img.destLeft) / parent.img.destWidth;
2058
+ currObj.pointColl[j].ratioY =
2059
+ (currObj.pointColl[j].y - parent.img.destTop) / parent.img.destHeight;
2060
+ }
1857
2061
  }
2062
+ var temp = this.lowerContext.filter;
2063
+ this.lowerContext.filter = 'none';
2064
+ this.apply(currObj.shape, currObj);
2065
+ this.lowerContext.filter = temp;
2066
+ this.refreshActiveObj();
1858
2067
  }
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();
2068
+ parent.notify('draw', { prop: 'applyFrame', value: { ctx: this.lowerContext, frame: parent.frameObj.type, preventImg: true } });
1864
2069
  }
1865
2070
  };
1866
2071
  Shape.prototype.updateFontStyles = function (isTextBox) {
@@ -1883,6 +2088,9 @@ var Shape = /** @class */ (function () {
1883
2088
  };
1884
2089
  Shape.prototype.applyFontStyle = function (item) {
1885
2090
  var parent = this.parent;
2091
+ var obj = { shapeSettingsObj: {} };
2092
+ parent.notify('selection', { prop: 'updatePrevShapeSettings', onPropertyChange: false, value: { obj: obj } });
2093
+ var shapeSettings = obj['shapeSettingsObj'];
1886
2094
  this.pushActItemIntoObj();
1887
2095
  var objColl = extend([], parent.objColl, [], true);
1888
2096
  parent.objColl.pop();
@@ -1906,6 +2114,10 @@ var Shape = /** @class */ (function () {
1906
2114
  this.updateFontStyle(item, objColl, 'bold', 'italic');
1907
2115
  break;
1908
2116
  }
2117
+ var shapeChangedArgs = { action: 'font-style', previousShapeSettings: extend({}, shapeSettings, {}, true),
2118
+ currentShapeSettings: extend({}, shapeSettings, {}, true) };
2119
+ shapeChangedArgs.currentShapeSettings.fontStyle = [item];
2120
+ parent.triggerShapeChanged(shapeChangedArgs);
1909
2121
  };
1910
2122
  Shape.prototype.updateFontStyle = function (item, objColl, fontWeight, fontStyle) {
1911
2123
  var parent = this.parent;
@@ -2269,14 +2481,14 @@ var Shape = /** @class */ (function () {
2269
2481
  if (!parent.disabled && parent.isImageLoaded) {
2270
2482
  this.applyActObj();
2271
2483
  if (id.split('_')[0] === 'shape') {
2272
- var obj_1;
2484
+ var obj_4;
2273
2485
  for (var i = 0, len = parent.objColl.length; i < len; i++) {
2274
2486
  if (parent.objColl[i].currIndex === id) {
2275
- obj_1 = extend({}, parent.objColl[i], {}, true);
2487
+ obj_4 = extend({}, parent.objColl[i], {}, true);
2276
2488
  break;
2277
2489
  }
2278
2490
  }
2279
- shapeDetails = this.getObjDetails(obj_1);
2491
+ shapeDetails = this.getObjDetails(obj_4);
2280
2492
  }
2281
2493
  else if (id.split('_')[0] === 'pen') {
2282
2494
  shapeDetails = this.getFreehandDrawDetails(parseInt(id.split('_')[1], 10) - 1);
@@ -2428,19 +2640,19 @@ var Shape = /** @class */ (function () {
2428
2640
  if (!parent.disabled && parent.isImageLoaded) {
2429
2641
  this.applyActObj();
2430
2642
  if (id.split('_')[0] === 'shape') {
2431
- var obj_2;
2643
+ var obj_5;
2432
2644
  for (var i = 0, len = parent.objColl.length; i < len; i++) {
2433
2645
  if (parent.objColl[i].currIndex === id) {
2434
- obj_2 = extend({}, parent.objColl[i], {}, true);
2646
+ obj_5 = extend({}, parent.objColl[i], {}, true);
2435
2647
  break;
2436
2648
  }
2437
2649
  }
2438
- if (isNullOrUndefined(obj_2)) {
2650
+ if (isNullOrUndefined(obj_5)) {
2439
2651
  isSelected = false;
2440
2652
  }
2441
2653
  else {
2442
2654
  isSelected = true;
2443
- parent.activeObj = obj_2;
2655
+ parent.activeObj = obj_5;
2444
2656
  var object = { canvasFilter: null };
2445
2657
  parent.notify('toolbar', { prop: 'getCanvasFilter', onPropertyChange: false, value: { obj: object } });
2446
2658
  this.lowerContext.filter = object['canvasFilter'];
@@ -2479,9 +2691,9 @@ var Shape = /** @class */ (function () {
2479
2691
  if (object['bool']) {
2480
2692
  parent.okBtn();
2481
2693
  }
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']) {
2694
+ var obj_6 = { isIndex: false };
2695
+ parent.notify('freehand-draw', { prop: 'isFHDIdx', value: { index: parseInt(id.split('_')[1], 10) - 1, obj: obj_6 } });
2696
+ if (obj_6['isIndex']) {
2485
2697
  isSelected = true;
2486
2698
  parent.notify('freehand-draw', { prop: 'selectFhd', value: { id: id } });
2487
2699
  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
  }