@syncfusion/ej2-image-editor 26.2.10 → 27.1.48

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 (187) hide show
  1. package/README.md +1 -1
  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 +3207 -732
  5. package/dist/es6/ej2-image-editor.es2015.js.map +1 -1
  6. package/dist/es6/ej2-image-editor.es5.js +3286 -797
  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 +14 -13
  12. package/src/image-editor/action/crop.d.ts +0 -1
  13. package/src/image-editor/action/crop.js +8 -19
  14. package/src/image-editor/action/draw.d.ts +4 -0
  15. package/src/image-editor/action/draw.js +377 -45
  16. package/src/image-editor/action/export.js +21 -13
  17. package/src/image-editor/action/filter.d.ts +13 -0
  18. package/src/image-editor/action/filter.js +272 -1
  19. package/src/image-editor/action/freehand-draw.d.ts +1 -0
  20. package/src/image-editor/action/freehand-draw.js +44 -23
  21. package/src/image-editor/action/selection.d.ts +6 -0
  22. package/src/image-editor/action/selection.js +382 -97
  23. package/src/image-editor/action/shape.d.ts +5 -0
  24. package/src/image-editor/action/shape.js +287 -141
  25. package/src/image-editor/action/transform.js +56 -82
  26. package/src/image-editor/action/undo-redo.d.ts +2 -0
  27. package/src/image-editor/action/undo-redo.js +100 -1
  28. package/src/image-editor/base/enum.d.ts +11 -0
  29. package/src/image-editor/base/enum.js +12 -0
  30. package/src/image-editor/base/image-editor-model.d.ts +13 -1
  31. package/src/image-editor/base/image-editor.d.ts +142 -20
  32. package/src/image-editor/base/image-editor.js +816 -149
  33. package/src/image-editor/base/interface.d.ts +140 -1
  34. package/src/image-editor/renderer/toolbar.d.ts +8 -0
  35. package/src/image-editor/renderer/toolbar.js +873 -191
  36. package/styles/bootstrap-dark-lite.css +746 -0
  37. package/styles/bootstrap-dark-lite.scss +13 -0
  38. package/styles/bootstrap-dark.css +150 -105
  39. package/styles/bootstrap-dark.scss +1 -0
  40. package/styles/bootstrap-lite.css +747 -0
  41. package/styles/bootstrap-lite.scss +13 -0
  42. package/styles/bootstrap.css +151 -106
  43. package/styles/bootstrap.scss +1 -0
  44. package/styles/bootstrap4-lite.css +747 -0
  45. package/styles/bootstrap4-lite.scss +13 -0
  46. package/styles/bootstrap4.css +150 -105
  47. package/styles/bootstrap4.scss +1 -0
  48. package/styles/bootstrap5-dark-lite.css +757 -0
  49. package/styles/bootstrap5-dark-lite.scss +13 -0
  50. package/styles/bootstrap5-dark.css +152 -113
  51. package/styles/bootstrap5-dark.scss +1 -0
  52. package/styles/bootstrap5-lite.css +757 -0
  53. package/styles/bootstrap5-lite.scss +13 -0
  54. package/styles/bootstrap5.3-lite.css +760 -0
  55. package/styles/bootstrap5.3-lite.scss +13 -0
  56. package/styles/bootstrap5.3.css +867 -0
  57. package/styles/bootstrap5.3.scss +14 -0
  58. package/styles/bootstrap5.css +152 -113
  59. package/styles/bootstrap5.scss +1 -0
  60. package/styles/fabric-dark-lite.css +749 -0
  61. package/styles/fabric-dark-lite.scss +13 -0
  62. package/styles/fabric-dark.css +150 -105
  63. package/styles/fabric-dark.scss +1 -0
  64. package/styles/fabric-lite.css +751 -0
  65. package/styles/fabric-lite.scss +13 -0
  66. package/styles/fabric.css +151 -106
  67. package/styles/fabric.scss +1 -0
  68. package/styles/fluent-dark-lite.css +758 -0
  69. package/styles/fluent-dark-lite.scss +13 -0
  70. package/styles/fluent-dark.css +150 -111
  71. package/styles/fluent-dark.scss +1 -0
  72. package/styles/fluent-lite.css +758 -0
  73. package/styles/fluent-lite.scss +13 -0
  74. package/styles/fluent.css +150 -111
  75. package/styles/fluent.scss +1 -0
  76. package/styles/fluent2-lite.css +791 -0
  77. package/styles/fluent2-lite.scss +13 -0
  78. package/styles/fluent2.css +173 -117
  79. package/styles/fluent2.scss +1 -0
  80. package/styles/highcontrast-light-lite.css +748 -0
  81. package/styles/highcontrast-light-lite.scss +13 -0
  82. package/styles/highcontrast-light.css +149 -104
  83. package/styles/highcontrast-light.scss +1 -0
  84. package/styles/highcontrast-lite.css +753 -0
  85. package/styles/highcontrast-lite.scss +13 -0
  86. package/styles/highcontrast.css +150 -104
  87. package/styles/highcontrast.scss +1 -0
  88. package/styles/image-editor/_bds-definition.scss +3 -1
  89. package/styles/image-editor/_bigger.scss +216 -0
  90. package/styles/image-editor/_bootstrap-dark-definition.scss +3 -1
  91. package/styles/image-editor/_bootstrap-definition.scss +3 -1
  92. package/styles/image-editor/_bootstrap4-definition.scss +3 -1
  93. package/styles/image-editor/_bootstrap5-definition.scss +3 -1
  94. package/styles/image-editor/_bootstrap5.3-definition.scss +3 -1
  95. package/styles/image-editor/_fabric-dark-definition.scss +3 -1
  96. package/styles/image-editor/_fabric-definition.scss +3 -1
  97. package/styles/image-editor/_fluent-definition.scss +3 -1
  98. package/styles/image-editor/_fluent2-definition.scss +4 -2
  99. package/styles/image-editor/_fusionnew-definition.scss +3 -1
  100. package/styles/image-editor/_highcontrast-definition.scss +3 -1
  101. package/styles/image-editor/_highcontrast-light-definition.scss +3 -1
  102. package/styles/image-editor/_layout.scss +75 -212
  103. package/styles/image-editor/_material-dark-definition.scss +3 -1
  104. package/styles/image-editor/_material-definition.scss +3 -1
  105. package/styles/image-editor/_material3-definition.scss +5 -3
  106. package/styles/image-editor/_tailwind-definition.scss +5 -3
  107. package/styles/image-editor/_theme.scss +48 -11
  108. package/styles/image-editor/bootstrap-dark.css +150 -105
  109. package/styles/image-editor/bootstrap-dark.scss +1 -0
  110. package/styles/image-editor/bootstrap.css +151 -106
  111. package/styles/image-editor/bootstrap.scss +1 -0
  112. package/styles/image-editor/bootstrap4.css +150 -105
  113. package/styles/image-editor/bootstrap4.scss +1 -0
  114. package/styles/image-editor/bootstrap5-dark.css +152 -113
  115. package/styles/image-editor/bootstrap5-dark.scss +1 -0
  116. package/styles/image-editor/bootstrap5.3.css +867 -0
  117. package/styles/image-editor/bootstrap5.3.scss +14 -0
  118. package/styles/image-editor/bootstrap5.css +152 -113
  119. package/styles/image-editor/bootstrap5.scss +1 -0
  120. package/styles/image-editor/fabric-dark.css +150 -105
  121. package/styles/image-editor/fabric-dark.scss +1 -0
  122. package/styles/image-editor/fabric.css +151 -106
  123. package/styles/image-editor/fabric.scss +1 -0
  124. package/styles/image-editor/fluent-dark.css +150 -111
  125. package/styles/image-editor/fluent-dark.scss +1 -0
  126. package/styles/image-editor/fluent.css +150 -111
  127. package/styles/image-editor/fluent.scss +1 -0
  128. package/styles/image-editor/fluent2.css +173 -117
  129. package/styles/image-editor/fluent2.scss +1 -0
  130. package/styles/image-editor/highcontrast-light.css +149 -104
  131. package/styles/image-editor/highcontrast-light.scss +1 -0
  132. package/styles/image-editor/highcontrast.css +150 -104
  133. package/styles/image-editor/highcontrast.scss +1 -0
  134. package/styles/image-editor/icons/_bds.scss +10 -1
  135. package/styles/image-editor/icons/_bootstrap-dark.scss +10 -1
  136. package/styles/image-editor/icons/_bootstrap.scss +10 -1
  137. package/styles/image-editor/icons/_bootstrap4.scss +10 -1
  138. package/styles/image-editor/icons/_bootstrap5.3.scss +10 -1
  139. package/styles/image-editor/icons/_bootstrap5.scss +10 -1
  140. package/styles/image-editor/icons/_fabric-dark.scss +10 -1
  141. package/styles/image-editor/icons/_fabric.scss +10 -1
  142. package/styles/image-editor/icons/_fluent.scss +10 -1
  143. package/styles/image-editor/icons/_fluent2.scss +10 -1
  144. package/styles/image-editor/icons/_fusionnew.scss +10 -1
  145. package/styles/image-editor/icons/_highcontrast-light.scss +10 -1
  146. package/styles/image-editor/icons/_highcontrast.scss +10 -1
  147. package/styles/image-editor/icons/_material-dark.scss +10 -1
  148. package/styles/image-editor/icons/_material.scss +10 -1
  149. package/styles/image-editor/icons/_material3.scss +10 -1
  150. package/styles/image-editor/icons/_tailwind.scss +10 -1
  151. package/styles/image-editor/material-dark.css +153 -108
  152. package/styles/image-editor/material-dark.scss +1 -0
  153. package/styles/image-editor/material.css +159 -114
  154. package/styles/image-editor/material.scss +1 -0
  155. package/styles/image-editor/material3-dark.css +171 -123
  156. package/styles/image-editor/material3-dark.scss +1 -0
  157. package/styles/image-editor/material3.css +171 -123
  158. package/styles/image-editor/material3.scss +1 -0
  159. package/styles/image-editor/tailwind-dark.css +154 -116
  160. package/styles/image-editor/tailwind-dark.scss +1 -0
  161. package/styles/image-editor/tailwind.css +154 -116
  162. package/styles/image-editor/tailwind.scss +1 -0
  163. package/styles/material-dark-lite.css +767 -0
  164. package/styles/material-dark-lite.scss +13 -0
  165. package/styles/material-dark.css +153 -108
  166. package/styles/material-dark.scss +1 -0
  167. package/styles/material-lite.css +769 -0
  168. package/styles/material-lite.scss +13 -0
  169. package/styles/material.css +159 -114
  170. package/styles/material.scss +1 -0
  171. package/styles/material3-dark-lite.css +799 -0
  172. package/styles/material3-dark-lite.scss +13 -0
  173. package/styles/material3-dark.css +171 -123
  174. package/styles/material3-dark.scss +1 -0
  175. package/styles/material3-lite.css +801 -0
  176. package/styles/material3-lite.scss +13 -0
  177. package/styles/material3.css +171 -123
  178. package/styles/material3.scss +1 -0
  179. package/styles/tailwind-dark-lite.css +751 -0
  180. package/styles/tailwind-dark-lite.scss +13 -0
  181. package/styles/tailwind-dark.css +154 -116
  182. package/styles/tailwind-dark.scss +1 -0
  183. package/styles/tailwind-lite.css +751 -0
  184. package/styles/tailwind-lite.scss +13 -0
  185. package/styles/tailwind.css +154 -116
  186. package/styles/tailwind.scss +1 -0
  187. package/hotfix/26.1.35_Vol2.txt +0 -1
@@ -44,7 +44,7 @@ var Draw = /** @class */ (function () {
44
44
  this.isErrorImage = false;
45
45
  this.isShapeTextInserted = false;
46
46
  this.isRotateZoom = false; // To restore zoomed image on selection crop selection
47
- this.tempStrokeSettings = { strokeColor: '#fff', fillColor: '', strokeWidth: null }; // restore stroke settings on cancel
47
+ this.tempStrokeSettings = { strokeColor: '#fff', fillColor: '', strokeWidth: null, outlineColor: '', radius: null, outlineWidth: null }; // restore stroke settings on cancel
48
48
  this.tempTextSettings = { text: 'Enter Text', fontFamily: '', fontSize: null, fontRatio: null, bold: false, italic: false, underline: false }; // restore text settings on cancel
49
49
  this.tempAdjValue = ''; // for temp internal slider value
50
50
  this.tempFilter = ''; // restore filter style on cancel
@@ -71,6 +71,8 @@ var Draw = /** @class */ (function () {
71
71
  this.tempObjColl = [];
72
72
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
73
73
  this.tempPointColl = {};
74
+ this.imageBackgroundColor = '';
75
+ this.allowRedactStraighten = true;
74
76
  this.parent = parent;
75
77
  this.addEventListener();
76
78
  }
@@ -143,7 +145,7 @@ var Draw = /** @class */ (function () {
143
145
  this.redrawImgWithObj();
144
146
  break;
145
147
  case 'setCurrentObj':
146
- this.setCurrentObj(args.value['obj'], args.value['isUndoRedo']);
148
+ this.setCurrentObj(args.value['obj'], args.value['isUndoRedo'], args.value['isCircleCrop']);
147
149
  break;
148
150
  case 'performPointZoom':
149
151
  this.performPointZoom(args.value['x'], args.value['y'], args.value['type'], args.value['isResize']);
@@ -336,6 +338,18 @@ var Draw = /** @class */ (function () {
336
338
  case 'resetTempPointColl':
337
339
  this.tempPointColl = {};
338
340
  break;
341
+ case 'showDialogPopup':
342
+ this.showDialogPopup();
343
+ break;
344
+ case 'imageBackgroundColor':
345
+ this.imageBackgroundColor = args.value['color'];
346
+ break;
347
+ case 'getImageBackgroundColor':
348
+ args.value['obj']['color'] = this.imageBackgroundColor;
349
+ break;
350
+ case 'setTempStrokeWidth':
351
+ this.tempStrokeWidth = args.value['strokeWidth'];
352
+ break;
339
353
  }
340
354
  };
341
355
  Draw.prototype.getModuleName = function () {
@@ -366,7 +380,7 @@ var Draw = /** @class */ (function () {
366
380
  this.currSelPoint = null;
367
381
  this.isRotateZoom = false;
368
382
  this.tempAdjValue = '';
369
- this.tempStrokeSettings = { strokeColor: '#fff', fillColor: '', strokeWidth: null };
383
+ this.tempStrokeSettings = { strokeColor: '#fff', fillColor: '', strokeWidth: null, radius: null, outlineColor: '', outlineWidth: null };
370
384
  this.tempTextSettings =
371
385
  { text: 'Enter Text', fontFamily: this.parent.fontFamily.default, fontSize: null, fontRatio: null, bold: false, italic: false, underline: false };
372
386
  this.tempUndoRedoStep = this.tempFreehandCounter = this.tempCurrFhdIndex = 0;
@@ -381,8 +395,11 @@ var Draw = /** @class */ (function () {
381
395
  this.straightenActObj = null;
382
396
  this.imgCanvasPoints = [];
383
397
  this.straightenInitZoom = null;
398
+ this.allowRedactStraighten = true;
384
399
  this.tempObjColl = [];
385
400
  this.tempPointColl = {};
401
+ this.imageBackgroundColor = '';
402
+ this.tempStrokeWidth = null;
386
403
  this.straightenDestPoints = null;
387
404
  this.isCropSelect = this.isDownScale = this.preventStraightening = false;
388
405
  };
@@ -553,7 +570,7 @@ var Draw = /** @class */ (function () {
553
570
  var parent = this.parent;
554
571
  var actPoint = parent.activeObj.activePoint;
555
572
  var _a = parent.activeObj, shape = _a.shape, rotatedAngle = _a.rotatedAngle;
556
- if (actPoint && shape !== 'image' && shape !== 'line' && rotatedAngle === 0) {
573
+ if (actPoint && shape !== 'image' && shape !== 'line' && rotatedAngle === 0 && parent.activeObj.preventShapeDragOut) {
557
574
  var _b = parent.img, destLeft = _b.destLeft, destTop = _b.destTop, destWidth = _b.destWidth, destHeight = _b.destHeight;
558
575
  if (actPoint.startX < destLeft) {
559
576
  actPoint.startX = destLeft;
@@ -580,8 +597,6 @@ var Draw = /** @class */ (function () {
580
597
  var y;
581
598
  var width;
582
599
  var height;
583
- var canvasWidth = parent.lowerCanvas.clientWidth;
584
- var canvasHeight = parent.lowerCanvas.clientHeight + 1;
585
600
  var _a = parent.img, destLeft = _a.destLeft, destTop = _a.destTop, destWidth = _a.destWidth, destHeight = _a.destHeight;
586
601
  if (parent.transform.zoomFactor > 0 && this.currSelPoint) {
587
602
  var activeObj = extend({}, parent.activeObj, {}, true);
@@ -594,18 +609,8 @@ var Draw = /** @class */ (function () {
594
609
  height = width;
595
610
  }
596
611
  else {
597
- if (destLeft + destLeft + destWidth <= canvasWidth) {
598
- width = actPoint.width;
599
- }
600
- else {
601
- width = parent.transform.straighten === 0 ? canvasWidth - destLeft : actPoint.width;
602
- }
603
- if (destTop + destTop + destHeight <= canvasHeight) {
604
- height = actPoint.height;
605
- }
606
- else {
607
- height = parent.transform.straighten === 0 ? canvasHeight - destTop : actPoint.height;
608
- }
612
+ width = actPoint.width;
613
+ height = actPoint.height;
609
614
  }
610
615
  parent.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
611
616
  parent.activeObj = activeObj;
@@ -950,7 +955,9 @@ var Draw = /** @class */ (function () {
950
955
  canvasDraw.lineWidth /= 2;
951
956
  }
952
957
  else {
953
- this.drawCenterCircles(canvasDraw);
958
+ if (parent.activeObj.shape !== 'redact') {
959
+ this.drawCenterCircles(canvasDraw);
960
+ }
954
961
  }
955
962
  canvasDraw.strokeStyle = strokeColor;
956
963
  canvasDraw.fillStyle = fillColor;
@@ -1006,7 +1013,7 @@ var Draw = /** @class */ (function () {
1006
1013
  canvasDraw = saveContext;
1007
1014
  }
1008
1015
  var shapeType = parent.currObjType.shape.toLowerCase();
1009
- var shapeColl = ['rectangle', 'ellipse', 'line', 'arrow', 'path', 'image'];
1016
+ var shapeColl = ['rectangle', 'ellipse', 'line', 'arrow', 'path', 'image', 'redact'];
1010
1017
  if (shapeColl.indexOf(shapeType) !== -1) {
1011
1018
  actObj.shape = parent.currObjType.shape;
1012
1019
  }
@@ -1032,6 +1039,13 @@ var Draw = /** @class */ (function () {
1032
1039
  this.drawOuterSelection(canvasDraw);
1033
1040
  }
1034
1041
  break;
1042
+ case 'redact':
1043
+ this.drawRedact(canvasDraw, actObj);
1044
+ if (isNullOrUndefined(isPreventSelection) && canvasDraw === this.upperContext) {
1045
+ this.drawOuterSelection(canvasDraw);
1046
+ }
1047
+ parent.currObjType.isRedact = true;
1048
+ break;
1035
1049
  case 'ellipse':
1036
1050
  selectionWidth = Math.abs(selectionWidth);
1037
1051
  selectionHeight = Math.abs(selectionHeight);
@@ -1050,9 +1064,6 @@ var Draw = /** @class */ (function () {
1050
1064
  }
1051
1065
  break;
1052
1066
  case 'crop-circle':
1053
- if (canvasDraw === this.lowerContext) {
1054
- canvasDraw = this.upperContext;
1055
- }
1056
1067
  this.shapeCircle(canvasDraw, selectionWidth, selectionHeight);
1057
1068
  break;
1058
1069
  case 'line':
@@ -1096,7 +1107,7 @@ var Draw = /** @class */ (function () {
1096
1107
  if (activeObj.pointColl.length > 1) {
1097
1108
  var obj = { shape: null };
1098
1109
  parent.notify('selection', { prop: 'getCurrentDrawingShape', value: { obj: obj } });
1099
- if (obj['shape'] === 'path') {
1110
+ if (obj['shape'] === 'path' && parent.isShapeDrawing) {
1100
1111
  var nextPoint = { x: 0, y: 0 };
1101
1112
  for (var i = 0, len = activeObj.pointColl.length; i < len; i++) {
1102
1113
  if (isNullOrUndefined(activeObj.pointColl[i + 1])) {
@@ -1113,6 +1124,10 @@ var Draw = /** @class */ (function () {
1113
1124
  actPoint.endY = nextPoint.y;
1114
1125
  parent.activeObj = this.updateWidthHeight(parent.activeObj);
1115
1126
  this.shapeLine(canvasDraw, actPoint.startX, actPoint.startY, actPoint.endX, actPoint.endY);
1127
+ if (Browser.isDevice) {
1128
+ activeObj.activePoint.endX = nextPoint.x;
1129
+ activeObj.activePoint.endY = nextPoint.y;
1130
+ }
1116
1131
  }
1117
1132
  }
1118
1133
  else {
@@ -1350,7 +1365,7 @@ var Draw = /** @class */ (function () {
1350
1365
  var parent = this.parent;
1351
1366
  var actObj = parent.activeObj;
1352
1367
  var _a = actObj.activePoint, startX = _a.startX, startY = _a.startY, width = _a.width, height = _a.height;
1353
- var _b = actObj.strokeSettings, fillColor = _b.fillColor, strokeColor = _b.strokeColor, strokeWidth = _b.strokeWidth;
1368
+ var _b = actObj.strokeSettings, fillColor = _b.fillColor, strokeColor = _b.strokeColor, strokeWidth = _b.strokeWidth, radius = _b.radius;
1354
1369
  if (actObj.shape) {
1355
1370
  splitWords = actObj.shape.split('-');
1356
1371
  }
@@ -1361,12 +1376,33 @@ var Draw = /** @class */ (function () {
1361
1376
  canvasDraw.strokeStyle = strokeColor;
1362
1377
  }
1363
1378
  canvasDraw.beginPath();
1364
- canvasDraw.rect(startX, startY, width, height);
1379
+ var obj = { width: 0, height: 0 };
1380
+ var ratio = { width: 1, height: 1 };
1381
+ parent.notify('crop', { prop: 'calcRatio', onPropertyChange: false,
1382
+ value: { obj: obj, dimension: { width: canvasDraw.canvas.width, height: canvasDraw.canvas.height } } });
1383
+ ratio = obj;
1384
+ var isTempCanvas = canvasDraw.canvas.id === parent.element.id + '_tempCanvas';
1385
+ var zoomFactor = parent.transform.zoomFactor;
1386
+ var baseRadius = isTempCanvas ? radius * 10 * ((ratio.width + ratio.height) / 2) : radius * 10;
1387
+ var adjustedRadius = baseRadius + (baseRadius * zoomFactor);
1388
+ if (radius !== null) {
1389
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1390
+ canvasDraw.roundRect(startX, startY, width, height, adjustedRadius);
1391
+ }
1392
+ else {
1393
+ canvasDraw.rect(startX, startY, width, height);
1394
+ }
1365
1395
  if (fillColor !== '') {
1366
1396
  canvasDraw.fillStyle = fillColor;
1367
1397
  canvasDraw.fill();
1368
1398
  }
1369
- canvasDraw.rect(startX + strokeWidth, startY + strokeWidth, width - (2 * strokeWidth), height - (2 * strokeWidth));
1399
+ if (radius !== null) {
1400
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1401
+ canvasDraw.roundRect(startX + strokeWidth, startY + strokeWidth, width - (2 * strokeWidth), height - (2 * strokeWidth), adjustedRadius);
1402
+ }
1403
+ else {
1404
+ canvasDraw.rect(startX + strokeWidth, startY + strokeWidth, width - (2 * strokeWidth), height - (2 * strokeWidth));
1405
+ }
1370
1406
  canvasDraw.fillStyle = strokeColor;
1371
1407
  canvasDraw.fill('evenodd');
1372
1408
  canvasDraw.closePath();
@@ -1662,6 +1698,9 @@ var Draw = /** @class */ (function () {
1662
1698
  else if (actObj.start === 'square' && actObj.end === 'square') {
1663
1699
  this.shapeLine(canvasDraw, this.squareEndIntersectX1, this.squareEndIntersectY1, this.squareStartIntersectX1, this.squareStartIntersectY1);
1664
1700
  }
1701
+ else if (actObj.end === 'squareSolid' && actObj.start === 'none') {
1702
+ this.shapeLine(canvasDraw, startX, startY, endX, endY);
1703
+ }
1665
1704
  }
1666
1705
  };
1667
1706
  Draw.prototype.arrowCircle = function (canvasDraw, start) {
@@ -1923,6 +1962,13 @@ var Draw = /** @class */ (function () {
1923
1962
  var lHeight = fontSize + fontSize * 0.25;
1924
1963
  var lineHeight = ((lHeight * rows.length) - (fontSize * rows.length)) / rows.length;
1925
1964
  canvasDraw.filter = 'none';
1965
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1966
+ var tempFill = canvasDraw.fillStyle;
1967
+ if (actObj.strokeSettings.fillColor !== '') {
1968
+ canvasDraw.fillStyle = actObj.strokeSettings.fillColor;
1969
+ canvasDraw.fillRect(actObj.activePoint.startX, actObj.activePoint.startY, actObj.activePoint.width, actObj.activePoint.height);
1970
+ }
1971
+ canvasDraw.fillStyle = tempFill;
1926
1972
  for (var i = 0; i < rows.length; i++) {
1927
1973
  var text = rows[i];
1928
1974
  var yPoint = ((i + 1) * fontSize * 0.85) + (i * lineHeight);
@@ -1939,8 +1985,29 @@ var Draw = /** @class */ (function () {
1939
1985
  fontSize = actObj.textSettings.fontSize = width - (width * 0.1);
1940
1986
  }
1941
1987
  }
1942
- canvasDraw.strokeStyle = actObj.strokeSettings.strokeColor;
1988
+ canvasDraw.strokeStyle = actObj.strokeSettings.outlineColor;
1943
1989
  canvasDraw.fillStyle = actObj.strokeSettings.strokeColor;
1990
+ var tempWidth = canvasDraw.lineWidth;
1991
+ var obj = { width: 0, height: 0 };
1992
+ var ratio = { width: 1, height: 1 };
1993
+ parent.notify('crop', { prop: 'calcRatio', onPropertyChange: false,
1994
+ value: { obj: obj, dimension: { width: canvasDraw.canvas.width, height: canvasDraw.canvas.height } } });
1995
+ ratio = obj;
1996
+ var isTempCanvas = canvasDraw.canvas.id === parent.element.id + '_tempCanvas';
1997
+ var baseWidth = Math.max(1, actObj.strokeSettings.outlineWidth / 2);
1998
+ if (/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$|^[a-zA-Z]+$/.test(actObj.strokeSettings.outlineColor)) {
1999
+ canvasDraw.lineWidth = baseWidth * ((isTempCanvas ? Math.floor((fontSize - 1) / 60) :
2000
+ Math.floor((fontSize - 1) / 16)) * 0.5 + 0.5);
2001
+ if (isTempCanvas) {
2002
+ canvasDraw.lineWidth *= ((ratio.width + ratio.height) / 2);
2003
+ if (parent.transform.degree !== 0) {
2004
+ canvasDraw.lineWidth /= 1.8;
2005
+ }
2006
+ }
2007
+ }
2008
+ else {
2009
+ canvasDraw.lineWidth = 0;
2010
+ }
1944
2011
  var textStyle = '';
1945
2012
  if (bold) {
1946
2013
  textStyle = 'bold ';
@@ -1960,11 +2027,16 @@ var Draw = /** @class */ (function () {
1960
2027
  this.rotateText(canvasDraw);
1961
2028
  }
1962
2029
  else {
2030
+ canvasDraw.strokeText(text, startX + fontSize * 0.1, startY + yPoint);
1963
2031
  canvasDraw.fillText(text, startX + fontSize * 0.1, startY + yPoint);
1964
2032
  }
2033
+ canvasDraw.lineWidth = tempWidth;
1965
2034
  }
1966
2035
  canvasDraw.filter = filter;
1967
2036
  parent.currObjType.isText = false;
2037
+ if (this.upperContext === canvasDraw) {
2038
+ this.drawOuterSelection(canvasDraw);
2039
+ }
1968
2040
  };
1969
2041
  Draw.prototype.updateActPoint = function (degree, canvasDraw) {
1970
2042
  var parent = this.parent;
@@ -2222,6 +2294,8 @@ var Draw = /** @class */ (function () {
2222
2294
  }
2223
2295
  yPoint += fontSize + fontSize * 0.15;
2224
2296
  }
2297
+ canvasDraw.strokeText(text, startX + fontSize * 0.15, startY +
2298
+ yPoint + (i > 0 ? fontSize * 0.25 : -fontSize * 0.35));
2225
2299
  canvasDraw.fillText(text, startX + fontSize * 0.15, startY +
2226
2300
  yPoint + (i > 0 ? fontSize * 0.25 : -fontSize * 0.35));
2227
2301
  }
@@ -2462,7 +2536,9 @@ var Draw = /** @class */ (function () {
2462
2536
  parent.baseImg.src = src;
2463
2537
  parent.baseImg.onload = function () {
2464
2538
  parent.imgSrc = src;
2465
- parent.notify('filter', { prop: 'update-finetunes', onPropertyChange: false });
2539
+ if (!parent.isUndoRedo) {
2540
+ parent.notify('filter', { prop: 'update-finetunes', onPropertyChange: false });
2541
+ }
2466
2542
  proxy.lowerContext.drawImage(parent.baseImg, 0, 0, proxy.parent.lowerCanvas.width, proxy.parent.lowerCanvas.height);
2467
2543
  hideSpinner(parent.element);
2468
2544
  parent.element.style.opacity = '1';
@@ -2489,6 +2565,8 @@ var Draw = /** @class */ (function () {
2489
2565
  }
2490
2566
  if (parent.isImageLoaded && parent.element.style.opacity !== '0.5') {
2491
2567
  parent.trigger('fileOpened', fileOpened);
2568
+ var action = { action: 'file-open', actionEventArgs: fileOpened };
2569
+ parent.triggerEditCompleteEvent(action);
2492
2570
  }
2493
2571
  };
2494
2572
  parent.baseImg.onerror = function () {
@@ -2510,8 +2588,10 @@ var Draw = /** @class */ (function () {
2510
2588
  };
2511
2589
  Draw.prototype.updateCanvas = function () {
2512
2590
  var parent = this.parent;
2513
- parent.img.srcWidth = parent.baseImgCanvas.width;
2514
- parent.img.srcHeight = parent.baseImgCanvas.height;
2591
+ if (!parent.isImageUpdated) {
2592
+ parent.img.srcWidth = parent.baseImgCanvas.width;
2593
+ parent.img.srcHeight = parent.baseImgCanvas.height;
2594
+ }
2515
2595
  var obj = { width: 0, height: 0 };
2516
2596
  parent.notify('transform', { prop: 'calcMaxDimension', onPropertyChange: false,
2517
2597
  value: { width: parent.img.srcWidth, height: parent.img.srcHeight, obj: obj, isImgShape: null } });
@@ -2586,12 +2666,15 @@ var Draw = /** @class */ (function () {
2586
2666
  this.renderImage(null, null, true);
2587
2667
  }
2588
2668
  this.resetFrameZoom(false);
2669
+ var editCompleteArgs = { action: '' };
2589
2670
  if (obj['bool']) {
2671
+ editCompleteArgs['action'] = 'freehand-draw';
2590
2672
  parent.notify('freehand-draw', { prop: 'cancelFhd', onPropertyChange: false });
2591
2673
  parent.notify('toolbar', { prop: 'destroy-qa-toolbar', onPropertyChange: false });
2592
2674
  parent.notify('undo-redo', { prop: 'updateCurrUrc', value: { type: 'ok' } });
2593
2675
  }
2594
2676
  else if (parent.textArea.style.display === 'block' || parent.textArea.style.display === 'inline-block') {
2677
+ editCompleteArgs['action'] = 'text-editing';
2595
2678
  parent.textArea.style.display = 'none';
2596
2679
  parent.textArea.value = '';
2597
2680
  parent.textArea.style.transform = '';
@@ -2614,8 +2697,9 @@ var Draw = /** @class */ (function () {
2614
2697
  parent.enableShapeDrawing(parent.toPascalCase(parent.drawingShape), true);
2615
2698
  }
2616
2699
  }
2617
- else if (((!Browser.isDevice || (Browser.isDevice && !straightenObj['bool'])) &&
2618
- document.querySelector('#' + parent.element.id + '_sliderWrapper')) || parent.currObjType.isFiltered) {
2700
+ else if ((!parent.activeObj.shape || parent.activeObj.shape !== 'redact') && (((!Browser.isDevice || (Browser.isDevice && !straightenObj['bool'])) &&
2701
+ document.querySelector('#' + parent.element.id + '_sliderWrapper')) || parent.currObjType.isFiltered)) {
2702
+ editCompleteArgs['action'] = parent.isFinetuneBtnClick ? 'fine-tune' : 'filter';
2619
2703
  this.lowerContext.filter = this.tempAdjValue;
2620
2704
  parent.canvasFilter = this.tempAdjValue;
2621
2705
  parent.notify('filter', { prop: 'setAdjustmentValue', onPropertyChange: false, value: { adjustmentValue: this.tempAdjValue } });
@@ -2636,7 +2720,7 @@ var Draw = /** @class */ (function () {
2636
2720
  parent.notify('undo-redo', { prop: 'setUndoRedoStep', onPropertyChange: false, value: { step: this.tempUndoRedoStep } });
2637
2721
  parent.upperCanvas.style.cursor = parent.cursor = 'default';
2638
2722
  parent.currObjType.isCustomCrop = false;
2639
- this.tempStrokeSettings = { strokeColor: '#fff', fillColor: '', strokeWidth: null };
2723
+ this.tempStrokeSettings = { strokeColor: '#fff', fillColor: '', strokeWidth: null, radius: null, outlineColor: '', outlineWidth: null };
2640
2724
  this.clearOuterCanvas(this.lowerContext);
2641
2725
  if ((parent.currSelectionPoint && parent.currSelectionPoint.shape === 'crop-circle') || parent.isCircleCrop) {
2642
2726
  parent.notify('crop', { prop: 'cropCircle', onPropertyChange: false,
@@ -2651,14 +2735,18 @@ var Draw = /** @class */ (function () {
2651
2735
  parent.notify('undo-redo', { prop: 'updateCurrUrc', value: { type: 'cancel' } });
2652
2736
  parent.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
2653
2737
  this.upperContext.clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
2738
+ if (parent.drawingShape) {
2739
+ parent.drawingShape = null;
2740
+ parent.notify('selection', { prop: 'setCurrentDrawingShape', onPropertyChange: false, value: { value: '' } });
2741
+ }
2654
2742
  }
2655
2743
  else {
2656
- if (isContextualToolbar && (!Browser.isDevice || (Browser.isDevice && !straightenObj['bool']))) {
2744
+ if ((!parent.activeObj.shape || parent.activeObj.shape !== 'redact') && isContextualToolbar && (!Browser.isDevice || (Browser.isDevice && !straightenObj['bool']))) {
2657
2745
  var eventargs = { type: 'main', isApplyBtn: null, isCropping: null, isZooming: null };
2658
2746
  parent.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: eventargs });
2659
2747
  }
2660
2748
  else {
2661
- this.cancelItems();
2749
+ this.cancelItems(editCompleteArgs);
2662
2750
  if (parent.transform.zoomFactor > 0) {
2663
2751
  parent.togglePan = true;
2664
2752
  parent.notify('selection', { prop: 'setDragCanvas', value: { bool: true } });
@@ -2679,15 +2767,18 @@ var Draw = /** @class */ (function () {
2679
2767
  parent.drawingShape = null;
2680
2768
  parent.notify('draw', { prop: 'resetTempObjColl' });
2681
2769
  parent.notify('draw', { prop: 'resetTempPointColl' });
2770
+ parent.isMaskImage = parent.isFinetuneBtnClick = false;
2771
+ var actionArgs = { action: 'cancel', actionEventArgs: editCompleteArgs };
2772
+ parent.triggerEditCompleteEvent(actionArgs);
2682
2773
  };
2683
- Draw.prototype.cancelItems = function () {
2774
+ Draw.prototype.cancelItems = function (editCompleteArgs) {
2684
2775
  var parent = this.parent;
2685
2776
  var isCropSelection = false;
2686
2777
  var id = parent.element.id;
2687
2778
  var ascpectIcon = parent.element.querySelector('#' + id + '_aspectratio');
2688
2779
  var nonAspectIcon = parent.element.querySelector('#' + id + '_nonaspectratio');
2689
2780
  var splitWords;
2690
- var shapes = ['rectangle', 'ellipse', 'line', 'arrow', 'path', 'image'];
2781
+ var shapes = ['rectangle', 'ellipse', 'line', 'arrow', 'path', 'image', 'redact'];
2691
2782
  if (parent.activeObj.shape !== undefined) {
2692
2783
  splitWords = parent.activeObj.shape.split('-');
2693
2784
  }
@@ -2704,6 +2795,7 @@ var Draw = /** @class */ (function () {
2704
2795
  if (parent.isResize) {
2705
2796
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
2706
2797
  if (ascpectIcon || nonAspectIcon || parent.currentToolbar === 'resize-toolbar') {
2798
+ editCompleteArgs['action'] = 'resize';
2707
2799
  var obj = { width: null, height: null };
2708
2800
  parent.notify('selection', { prop: 'getNumTextValue', onPropertyChange: false, value: { obj: obj } });
2709
2801
  var point = { x: obj['width'], y: obj['height'] };
@@ -2760,15 +2852,20 @@ var Draw = /** @class */ (function () {
2760
2852
  }
2761
2853
  switch (true) {
2762
2854
  case parent.togglePen:
2855
+ editCompleteArgs['action'] = 'freehand-draw';
2763
2856
  this.cancelPen();
2764
2857
  break;
2765
2858
  case parent.activeObj.shape === 'text':
2859
+ editCompleteArgs['action'] = 'text';
2766
2860
  this.cancelText();
2767
2861
  break;
2768
2862
  case shapes.indexOf(parent.activeObj.shape) !== -1:
2863
+ editCompleteArgs['action'] = parent.activeObj.shape;
2769
2864
  this.cancelShape();
2865
+ parent.currObjType.isRedact = false;
2770
2866
  break;
2771
2867
  case isCropSelection:
2868
+ editCompleteArgs['action'] = 'crop-selection';
2772
2869
  this.cancelSelection();
2773
2870
  break;
2774
2871
  default:
@@ -2780,7 +2877,7 @@ var Draw = /** @class */ (function () {
2780
2877
  parent.notify('selection', { prop: 'setCurrentDrawingShape', onPropertyChange: false, value: { value: '' } });
2781
2878
  parent.upperCanvas.style.cursor = parent.cursor = 'default';
2782
2879
  parent.currObjType.isCustomCrop = false;
2783
- this.tempStrokeSettings = { strokeColor: '#fff', fillColor: '', strokeWidth: null };
2880
+ this.tempStrokeSettings = { strokeColor: '#fff', fillColor: '', strokeWidth: null, radius: null, outlineColor: '', outlineWidth: null };
2784
2881
  var eventargs = { type: 'main', isApplyBtn: null, isCropping: false, isZooming: null };
2785
2882
  parent.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: eventargs });
2786
2883
  };
@@ -2798,8 +2895,9 @@ var Draw = /** @class */ (function () {
2798
2895
  parent.freehandCounter = this.tempFreehandCounter;
2799
2896
  parent.notify('freehand-draw', { prop: 'setCurrentFreehandDrawIndex', value: { value: this.tempCurrFhdIndex } });
2800
2897
  parent.activeObj.strokeSettings = this.tempStrokeSettings;
2801
- parent.notify('shape', { prop: 'setStrokeSettings',
2802
- value: { strokeSettings: parent.activeObj.strokeSettings, strokeColor: null, fillColor: null, strokeWidth: null } });
2898
+ parent.notify('shape', { prop: 'setStrokeSettings', value: { strokeSettings: parent.activeObj.strokeSettings, strokeColor: null,
2899
+ fillColor: null, strokeWidth: null, radius: null } });
2900
+ parent.notify('freehand-draw', { prop: 'setPenStrokeWidth', onPropertyChange: false, value: { value: this.tempStrokeWidth } });
2803
2901
  parent.notify('undo-redo', { prop: 'updateCurrUrc', value: { type: 'cancel' } });
2804
2902
  parent.notify('selection', { prop: 'setFreehandDrawCustomized', value: { isFreehandDrawCustomized: false } });
2805
2903
  parent.objColl = extend([], this.tempObjColl, [], true);
@@ -2814,7 +2912,7 @@ var Draw = /** @class */ (function () {
2814
2912
  parent.notify('shape', { prop: 'setTextSettings', onPropertyChange: false,
2815
2913
  value: { textSettings: this.tempTextSettings, fontFamily: null, fontSize: null } });
2816
2914
  parent.notify('shape', { prop: 'setStrokeSettings',
2817
- value: { strokeSettings: this.tempStrokeSettings, strokeColor: null, fillColor: null, strokeWidth: null } });
2915
+ value: { strokeSettings: this.tempStrokeSettings, strokeColor: null, fillColor: null, strokeWidth: null, radius: null } });
2818
2916
  if (isNullOrUndefined(parent.activeObj.currIndex)) {
2819
2917
  parent.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
2820
2918
  this.upperContext.clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
@@ -2846,7 +2944,7 @@ var Draw = /** @class */ (function () {
2846
2944
  Draw.prototype.cancelShape = function () {
2847
2945
  var parent = this.parent;
2848
2946
  parent.notify('shape', { prop: 'setStrokeSettings',
2849
- value: { strokeSettings: this.tempStrokeSettings, strokeColor: null, fillColor: null, strokeWidth: null } });
2947
+ value: { strokeSettings: this.tempStrokeSettings, strokeColor: null, fillColor: null, strokeWidth: null, radius: null } });
2850
2948
  if (isNullOrUndefined(parent.activeObj.currIndex)) {
2851
2949
  parent.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
2852
2950
  this.upperContext.clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
@@ -3097,6 +3195,7 @@ var Draw = /** @class */ (function () {
3097
3195
  var selectionChangingArgs = { action: 'insert', previousSelectionSettings: selectionSettings,
3098
3196
  currentSelectionSettings: selectionSettings };
3099
3197
  parent.trigger('selectionChanging', selectionChangingArgs);
3198
+ parent.editCompleteArgs = selectionChangingArgs;
3100
3199
  parent.notify('shape', { prop: 'updSelChangeEventArgs', onPropertyChange: false,
3101
3200
  value: { selectionSettings: selectionChangingArgs.currentSelectionSettings } });
3102
3201
  if (selectionChangingArgs.currentSelectionSettings.type === 'Custom') {
@@ -3299,8 +3398,11 @@ var Draw = /** @class */ (function () {
3299
3398
  var tempTogglePen = parent.togglePen;
3300
3399
  parent.togglePen = false;
3301
3400
  this.lowerContext.filter = 'none';
3401
+ var widthObj = { penStrokeWidth: null };
3402
+ parent.notify('freehand-draw', { prop: 'getPenStrokeWidth', onPropertyChange: false, value: { obj: widthObj } });
3302
3403
  parent.notify('shape', { prop: 'drawAnnotations', onPropertyChange: false,
3303
3404
  value: { ctx: this.lowerContext, shape: 'iterate', pen: 'iterate', isPreventApply: null } });
3405
+ parent.notify('freehand-draw', { prop: 'setPenStrokeWidth', onPropertyChange: false, value: { value: widthObj['penStrokeWidth'] } });
3304
3406
  parent.img.destLeft += parent.panPoint.totalPannedInternalPoint.x;
3305
3407
  parent.img.destTop += parent.panPoint.totalPannedInternalPoint.y;
3306
3408
  parent.img.destLeft -= parent.panPoint.totalPannedInternalPoint.x;
@@ -3353,7 +3455,7 @@ var Draw = /** @class */ (function () {
3353
3455
  value: { context: this.lowerContext, isSave: null, isFlip: null } });
3354
3456
  }
3355
3457
  };
3356
- Draw.prototype.setCurrentObj = function (obj, isUndoRedo) {
3458
+ Draw.prototype.setCurrentObj = function (obj, isUndoRedo, isCircleCropped) {
3357
3459
  var parent = this.parent;
3358
3460
  var isObj = obj ? true : false;
3359
3461
  if (!isObj) {
@@ -3405,6 +3507,7 @@ var Draw = /** @class */ (function () {
3405
3507
  }
3406
3508
  this.lowerContext.filter = obj.filter;
3407
3509
  parent.notify('filter', { prop: 'setBrightnessAdjusted', onPropertyChange: false, value: { isBrightnessAdjusted: obj.isBrightAdjust } });
3510
+ parent.notify('draw', { prop: 'imageBackgroundColor', onPropertyChange: false, value: { color: obj.bgColor } });
3408
3511
  var isCircleCrop = parent.isCircleCrop;
3409
3512
  var currSelectionPoint;
3410
3513
  if (isNullOrUndefined(parent.currSelectionPoint)) {
@@ -3415,6 +3518,9 @@ var Draw = /** @class */ (function () {
3415
3518
  parent.currSelectionPoint = null;
3416
3519
  }
3417
3520
  parent.isCircleCrop = false;
3521
+ if (isCircleCropped) {
3522
+ parent.frameObj.type = 'none';
3523
+ }
3418
3524
  this.drawCropSelectionImage(obj, false);
3419
3525
  if (parent.transform.degree !== 0) {
3420
3526
  if (parent.transform.currFlipState === '') {
@@ -3535,6 +3641,16 @@ var Draw = /** @class */ (function () {
3535
3641
  Draw.prototype.performPointZoom = function (x, y, type, isResize, value) {
3536
3642
  var parent = this.parent;
3537
3643
  var _a = parent.img, destLeft = _a.destLeft, destTop = _a.destTop, destWidth = _a.destWidth, destHeight = _a.destHeight;
3644
+ var isCropSelection = false;
3645
+ if (parent.activeObj.shape && parent.activeObj.shape.indexOf('crop-') > -1) {
3646
+ isCropSelection = true;
3647
+ }
3648
+ if (parent.element.querySelector('.e-contextual-toolbar-wrapper') && !isCropSelection) {
3649
+ if (!parent.element.querySelector('.e-contextual-toolbar-wrapper').classList.contains('e-hide')) {
3650
+ parent.okBtn();
3651
+ parent.element.querySelector('.e-contextual-toolbar-wrapper').classList.add('e-hide');
3652
+ }
3653
+ }
3538
3654
  var ratioX = (x - destLeft) / destWidth;
3539
3655
  var ratioY = (y - destTop) / destHeight;
3540
3656
  var isUndoRedo = parent.isUndoRedo;
@@ -3669,6 +3785,7 @@ var Draw = /** @class */ (function () {
3669
3785
  var parent = this.parent;
3670
3786
  var activeObj = extend({}, parent.activeObj, {}, true);
3671
3787
  var _a = activeObj.activePoint, startX = _a.startX, startY = _a.startY, width = _a.width, height = _a.height;
3788
+ this.allowRedactStraighten = true;
3672
3789
  var straightenObj = { straightenPoint: null };
3673
3790
  parent.notify('freehand-draw', { prop: 'getStraightenPoint', onPropertyChange: false,
3674
3791
  value: { obj: straightenObj } });
@@ -3815,6 +3932,8 @@ var Draw = /** @class */ (function () {
3815
3932
  return [3 /*break*/, 3];
3816
3933
  case 2:
3817
3934
  ex_1 = _a.sent();
3935
+ // eslint-disable-next-line no-console
3936
+ console.log(ex_1.message);
3818
3937
  return [3 /*break*/, 3];
3819
3938
  case 3: return [2 /*return*/];
3820
3939
  }
@@ -4132,6 +4251,10 @@ var Draw = /** @class */ (function () {
4132
4251
  tempCanvas.getContext('2d').drawImage(img, 0, 0, tempCanvas.width, tempCanvas.height);
4133
4252
  }
4134
4253
  else {
4254
+ if (this.imageBackgroundColor !== '') {
4255
+ ctx.fillStyle = this.imageBackgroundColor;
4256
+ ctx.fillRect(parent.img.destLeft, parent.img.destTop, parent.img.destWidth, parent.img.destHeight);
4257
+ }
4135
4258
  tempCanvas.getContext('2d').drawImage(canvas, parent.img.srcLeft, parent.img.srcTop, parent.img.srcWidth, parent.img.srcHeight, 0, 0, tempCanvas.width, tempCanvas.height);
4136
4259
  }
4137
4260
  if (isImgAnnotation || this.isDownScale) {
@@ -4192,9 +4315,16 @@ var Draw = /** @class */ (function () {
4192
4315
  else {
4193
4316
  if ((isNullOrUndefined(isImgAnnotation) || !isImgAnnotation) && parent.baseImgCanvas.width !== 0 &&
4194
4317
  parent.baseImgCanvas.height !== 0) {
4318
+ if (this.imageBackgroundColor !== '') {
4319
+ ctx.fillStyle = this.imageBackgroundColor;
4320
+ ctx.fillRect(parent.img.destLeft, parent.img.destTop, parent.img.destWidth, parent.img.destHeight);
4321
+ }
4195
4322
  ctx.drawImage(parent.baseImgCanvas, parent.img.srcLeft, parent.img.srcTop, parent.img.srcWidth, parent.img.srcHeight, parent.img.destLeft, parent.img.destTop, parent.img.destWidth, parent.img.destHeight);
4196
4323
  }
4197
4324
  }
4325
+ if (parent.isSafari) {
4326
+ parent.notify('filter', { prop: 'apply-filter', onPropertyChange: false, value: { context: ctx } });
4327
+ }
4198
4328
  };
4199
4329
  Draw.prototype.downScale = function (canvas, width, height, isImgAnnotation) {
4200
4330
  var parent = this.parent;
@@ -4535,6 +4665,7 @@ var Draw = /** @class */ (function () {
4535
4665
  var frameChange = { cancel: false, previousFrameSetting: prevFrameSettings,
4536
4666
  currentFrameSetting: currFrameSettings };
4537
4667
  parent.trigger('frameChange', frameChange);
4668
+ parent.editCompleteArgs = frameChange;
4538
4669
  if (!frameChange.cancel) {
4539
4670
  this.setFrameObj(frameChange.currentFrameSetting);
4540
4671
  }
@@ -4556,6 +4687,7 @@ var Draw = /** @class */ (function () {
4556
4687
  var parent = this.parent;
4557
4688
  if (this.straightenActObj && JSON.stringify(this.straightenActObj.activePoint) === JSON.stringify(activeObj.activePoint)) {
4558
4689
  parent.activeObj = extend({}, this.straightenActObj, null, true);
4690
+ this.allowRedactStraighten = false;
4559
4691
  if (parent.transform.straighten === 0) {
4560
4692
  var destWidth = parent.img.destWidth;
4561
4693
  var destHeight = parent.img.destHeight;
@@ -4727,12 +4859,18 @@ var Draw = /** @class */ (function () {
4727
4859
  p3 = { x: destLeft + destWidth - (points[0].x / width), y: destTop + destHeight };
4728
4860
  p4 = { x: destLeft, y: destTop + destHeight - (points[1].y / height) };
4729
4861
  }
4730
- else {
4862
+ else if (parent.transform.straighten < 0) {
4731
4863
  p1 = { x: destLeft, y: destTop + (points[0].y / height) };
4732
4864
  p2 = { x: destLeft + (points[1].x / width), y: destTop };
4733
4865
  p3 = { x: destLeft + destWidth, y: destTop + destHeight - (points[0].y / height) };
4734
4866
  p4 = { x: destLeft + destWidth - (points[1].x / width), y: destTop + destHeight };
4735
4867
  }
4868
+ else if (parent.transform.straighten === 0) {
4869
+ p1 = { x: destLeft, y: destTop };
4870
+ p2 = { x: destLeft + destWidth, y: destTop };
4871
+ p3 = { x: destLeft + destWidth, y: destTop + destHeight };
4872
+ p4 = { x: destLeft, y: destTop + destHeight };
4873
+ }
4736
4874
  p1.ratioX = (p1.x - destLeft) / destWidth;
4737
4875
  p1.ratioY = (p1.y - destTop) / destHeight;
4738
4876
  p2.ratioX = (p2.x - destLeft) / destWidth;
@@ -4746,6 +4884,30 @@ var Draw = /** @class */ (function () {
4746
4884
  Draw.prototype.isLinesIntersect = function (obj) {
4747
4885
  var parent = this.parent;
4748
4886
  var point = parent.activeObj.activePoint;
4887
+ if (parent.activeObj.rotatedAngle !== 0) {
4888
+ var _a = parent.activeObj.activePoint, startX = _a.startX, startY = _a.startY, endX = _a.endX, endY = _a.endY, width = _a.width, height = _a.height;
4889
+ var center = { x: startX + (width / 2), y: startY +
4890
+ (height / 2) };
4891
+ var cosAngle = Math.cos(parent.activeObj.rotatedAngle);
4892
+ var sinAngle = Math.sin(parent.activeObj.rotatedAngle);
4893
+ var p1 = { x: cosAngle * (startX - center.x) - sinAngle * (startY - center.y) + center.x,
4894
+ y: sinAngle * (startX - center.x) + cosAngle * (startY - center.y) + center.y };
4895
+ var p2 = { x: cosAngle * (endX - center.x) - sinAngle * (startY - center.y) + center.x,
4896
+ y: sinAngle * (endX - center.x) + cosAngle * (startY - center.y) + center.y };
4897
+ var p3 = { x: cosAngle * (startX - center.x) - sinAngle * (endY - center.y) + center.x,
4898
+ y: sinAngle * (startX - center.x) + cosAngle * (endY - center.y) + center.y };
4899
+ var p4 = { x: cosAngle * (endX - center.x) - sinAngle * (endY - center.y) + center.x,
4900
+ y: sinAngle * (endX - center.x) + cosAngle * (endY - center.y) + center.y };
4901
+ var imgPoints_1 = this.imgCanvasPoints;
4902
+ var isTopIntersect_1 = this.doIntersect(p1, p2, imgPoints_1[0], imgPoints_1[1]);
4903
+ var isRightIntersect_1 = this.doIntersect(p2, p4, imgPoints_1[1], imgPoints_1[2]);
4904
+ var isBottomIntersect_1 = this.doIntersect(p3, p4, imgPoints_1[2], imgPoints_1[3]);
4905
+ var isLeftIntersect_1 = this.doIntersect(p1, p3, imgPoints_1[3], imgPoints_1[0]);
4906
+ if (obj) {
4907
+ obj['arr'] = [isTopIntersect_1, isRightIntersect_1, isBottomIntersect_1, isLeftIntersect_1];
4908
+ }
4909
+ return isTopIntersect_1 || isRightIntersect_1 || isBottomIntersect_1 || isLeftIntersect_1;
4910
+ }
4749
4911
  var imgPoints = this.imgCanvasPoints;
4750
4912
  var isTopIntersect = this.doIntersect({ x: point.startX, y: point.startY }, { x: point.endX, y: point.startY }, imgPoints[0], imgPoints[1]);
4751
4913
  var isRightIntersect = this.doIntersect({ x: point.endX, y: point.startY }, { x: point.endX, y: point.endY }, imgPoints[1], imgPoints[2]);
@@ -4890,6 +5052,176 @@ var Draw = /** @class */ (function () {
4890
5052
  parent.img.destHeight = destHeight;
4891
5053
  }
4892
5054
  };
5055
+ Draw.prototype.drawRedact = function (canvasDraw, obj) {
5056
+ var _a = obj.activePoint, startX = _a.startX, startY = _a.startY, endX = _a.endX, endY = _a.endY;
5057
+ var _b = obj.activePoint, width = _b.width, height = _b.height;
5058
+ var isSaveCtx = false;
5059
+ var canvas = canvasDraw.canvas;
5060
+ if (canvas.id.indexOf('_tempCanvas') !== -1) {
5061
+ isSaveCtx = true;
5062
+ }
5063
+ var img = this.parent.img;
5064
+ if (width <= 0 || height <= 0) {
5065
+ return;
5066
+ }
5067
+ else if (this.parent.isCropTab) {
5068
+ canvasDraw.drawImage(obj.redactImage, 0, 0, obj.redactImage.width, obj.redactImage.height, startX, startY, width, height);
5069
+ }
5070
+ else {
5071
+ var offscreenCanvas = document.createElement('canvas');
5072
+ var offscreenCtx = offscreenCanvas.getContext('2d');
5073
+ var imageWidth = canvas.width;
5074
+ var imageHeight = canvas.height;
5075
+ var tempRatio = Math.min(imageWidth, imageHeight) / 1000;
5076
+ var straighten = this.parent.transform.straighten !== 0 ? this.parent.transform.straighten :
5077
+ this.parent.cropObj.straighten;
5078
+ if (this.allowRedactStraighten && straighten !== 0) {
5079
+ var tempCanvas = document.createElement('canvas');
5080
+ var tempCtx = tempCanvas.getContext('2d');
5081
+ if (isSaveCtx) {
5082
+ tempCanvas.width = canvas.width;
5083
+ tempCanvas.height = canvas.height;
5084
+ tempCtx.drawImage(canvas, 0, 0);
5085
+ }
5086
+ else {
5087
+ tempCanvas.width = img.destWidth;
5088
+ tempCanvas.height = img.destHeight;
5089
+ tempCtx.drawImage(this.lowerContext.canvas, img.destLeft, img.destTop, img.destWidth, img.destHeight, 0, 0, img.destWidth, img.destHeight);
5090
+ }
5091
+ var radians = -straighten * Math.PI / 180;
5092
+ var straightenCanvas = document.createElement('canvas');
5093
+ var straightenCtx = straightenCanvas.getContext('2d');
5094
+ straightenCanvas.width = tempCanvas.width;
5095
+ straightenCanvas.height = tempCanvas.height;
5096
+ if (img.destWidth > canvas.width && !isSaveCtx) {
5097
+ straightenCanvas.width = canvas.width;
5098
+ }
5099
+ if (img.destHeight > canvas.height && !isSaveCtx) {
5100
+ straightenCanvas.height = canvas.height;
5101
+ }
5102
+ straightenCtx.save();
5103
+ straightenCtx.translate(tempCanvas.width / 2, tempCanvas.height / 2);
5104
+ straightenCtx.rotate(radians);
5105
+ straightenCtx.drawImage(tempCanvas, -tempCanvas.width / 2, -tempCanvas.height / 2);
5106
+ straightenCtx.restore();
5107
+ if (img.destLeft > 0 && !isSaveCtx) {
5108
+ startX -= img.destLeft;
5109
+ endX -= img.destLeft;
5110
+ }
5111
+ if (img.destTop > 0 && !isSaveCtx) {
5112
+ startY -= img.destTop;
5113
+ endY -= img.destTop;
5114
+ }
5115
+ var center = { x: startX + (width / 2), y: startY + (height / 2) };
5116
+ var cosAngle = Math.cos(straighten * Math.PI / 180);
5117
+ var sinAngle = Math.sin(straighten * Math.PI / 180);
5118
+ var p1 = { x: cosAngle * (startX - center.x) - sinAngle * (startY - center.y) + center.x,
5119
+ y: sinAngle * (startX - center.x) + cosAngle * (startY - center.y) + center.y };
5120
+ var p2 = { x: cosAngle * (endX - center.x) - sinAngle * (startY - center.y) + center.x,
5121
+ y: sinAngle * (endX - center.x) + cosAngle * (startY - center.y) + center.y };
5122
+ var p3 = { x: cosAngle * (startX - center.x) - sinAngle * (endY - center.y) + center.x,
5123
+ y: sinAngle * (startX - center.x) + cosAngle * (endY - center.y) + center.y };
5124
+ if (!isSaveCtx) {
5125
+ center = { x: img.destWidth / 2, y: img.destHeight / 2 };
5126
+ if (img.destWidth > canvas.width) {
5127
+ center.x = canvas.width / 2;
5128
+ }
5129
+ if (img.destHeight > canvas.height) {
5130
+ center.y = canvas.height / 2;
5131
+ }
5132
+ }
5133
+ else {
5134
+ center = { x: canvas.width / 2, y: canvas.height / 2 };
5135
+ }
5136
+ cosAngle = Math.cos(radians);
5137
+ sinAngle = Math.sin(radians);
5138
+ var newP1 = { x: cosAngle * (p1.x - center.x) - sinAngle * (p1.y - center.y) + center.x,
5139
+ y: sinAngle * (p1.x - center.x) + cosAngle * (p1.y - center.y) + center.y };
5140
+ var newP2 = { x: cosAngle * (p2.x - center.x) - sinAngle * (p2.y - center.y) + center.x,
5141
+ y: sinAngle * (p2.x - center.x) + cosAngle * (p2.y - center.y) + center.y };
5142
+ var newP3 = { x: cosAngle * (p3.x - center.x) - sinAngle * (p3.y - center.y) + center.x,
5143
+ y: sinAngle * (p3.x - center.x) + cosAngle * (p3.y - center.y) + center.y };
5144
+ if (this.parent.activeObj.redactType === 'blur') {
5145
+ offscreenCanvas.width = width;
5146
+ offscreenCanvas.height = height;
5147
+ offscreenCtx.drawImage(straightenCanvas, newP1.x, newP1.y, newP2.x - newP1.x, newP3.y - newP2.y, 0, 0, width, height);
5148
+ }
5149
+ else {
5150
+ var pixelSize = (obj.redactPixelate / 100) * 20;
5151
+ if (isSaveCtx) {
5152
+ pixelSize = tempRatio * (obj.redactPixelate / 100) * 35;
5153
+ }
5154
+ offscreenCanvas.width = Math.ceil(width / pixelSize);
5155
+ offscreenCanvas.height = Math.ceil(height / pixelSize);
5156
+ offscreenCtx.drawImage(straightenCanvas, newP1.x, newP1.y, newP2.x - newP1.x, newP3.y - newP2.y, 0, 0, offscreenCanvas.width, offscreenCanvas.height);
5157
+ }
5158
+ }
5159
+ if (this.parent.activeObj.redactType === 'blur') {
5160
+ if (straighten === 0) {
5161
+ offscreenCanvas.width = width;
5162
+ offscreenCanvas.height = height;
5163
+ offscreenCtx.drawImage((isSaveCtx) ? canvas : this.lowerContext.canvas, startX, startY, width, height, 0, 0, width, height);
5164
+ }
5165
+ if (isSaveCtx) {
5166
+ var blur_1 = tempRatio * ((obj.redactBlur / 100) * 34);
5167
+ offscreenCtx.filter = "blur(" + blur_1 + "px)";
5168
+ }
5169
+ else {
5170
+ offscreenCtx.filter = "blur(" + (obj.redactBlur / 100) * 17 + "px)";
5171
+ }
5172
+ offscreenCtx.drawImage(offscreenCanvas, 0, 0);
5173
+ if (straighten === 0) {
5174
+ offscreenCtx.drawImage((isSaveCtx) ? canvas : this.lowerContext.canvas, startX, startY, width, height, 0, 0, width, height);
5175
+ }
5176
+ else {
5177
+ if (img.destLeft > 0 && !isSaveCtx) {
5178
+ startX += img.destLeft;
5179
+ endX += img.destLeft;
5180
+ }
5181
+ if (img.destTop > 0 && !isSaveCtx) {
5182
+ startY += img.destTop;
5183
+ endY += img.destTop;
5184
+ }
5185
+ }
5186
+ if (this.parent.isSafari) {
5187
+ this.parent.notify('filter', { prop: 'apply-filter', onPropertyChange: false, value: { context: offscreenCtx } });
5188
+ }
5189
+ canvasDraw.drawImage(offscreenCanvas, 0, 0, width, height, startX, startY, width, height);
5190
+ }
5191
+ else {
5192
+ var pixelSize = (obj.redactPixelate / 100) * 20;
5193
+ if (isSaveCtx) {
5194
+ pixelSize = tempRatio * (obj.redactPixelate / 100) * 35;
5195
+ }
5196
+ if (straighten === 0) {
5197
+ offscreenCanvas.width = Math.ceil(width / pixelSize);
5198
+ offscreenCanvas.height = Math.ceil(height / pixelSize);
5199
+ offscreenCtx.drawImage((isSaveCtx) ? canvas : this.lowerContext.canvas, startX, startY, width, height, 0, 0, offscreenCanvas.width, offscreenCanvas.height);
5200
+ }
5201
+ else {
5202
+ if (img.destLeft > 0 && !isSaveCtx) {
5203
+ startX += img.destLeft;
5204
+ endX += img.destLeft;
5205
+ }
5206
+ if (img.destTop > 0 && !isSaveCtx) {
5207
+ startY += img.destTop;
5208
+ endY += img.destTop;
5209
+ }
5210
+ }
5211
+ canvasDraw.imageSmoothingEnabled = false;
5212
+ canvasDraw.drawImage(offscreenCanvas, 0, 0, offscreenCanvas.width, offscreenCanvas.height, startX, startY, width, height);
5213
+ }
5214
+ obj.redactImage = this.parent.createElement('canvas');
5215
+ obj.redactImage.width = offscreenCanvas.width;
5216
+ obj.redactImage.height = offscreenCanvas.height;
5217
+ obj.redactImage.getContext('2d').drawImage(offscreenCanvas, 0, 0);
5218
+ canvasDraw.beginPath();
5219
+ canvasDraw.rect(startX, startY, width, height);
5220
+ canvasDraw.rect(startX, startY, width, height);
5221
+ canvasDraw.fill('evenodd');
5222
+ canvasDraw.closePath();
5223
+ }
5224
+ };
4893
5225
  return Draw;
4894
5226
  }());
4895
5227
  export { Draw };