@syncfusion/ej2-image-editor 26.2.14 → 27.1.50

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 (186) 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 +3267 -731
  5. package/dist/es6/ej2-image-editor.es2015.js.map +1 -1
  6. package/dist/es6/ej2-image-editor.es5.js +3345 -795
  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 +13 -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 +401 -47
  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 +9 -0
  22. package/src/image-editor/action/selection.js +420 -98
  23. package/src/image-editor/action/shape.d.ts +5 -0
  24. package/src/image-editor/action/shape.js +291 -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 +814 -150
  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 +876 -193
  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
@@ -38,6 +38,10 @@ var Selection = /** @class */ (function () {
38
38
  this.mouseDown = '';
39
39
  this.isSliderActive = false;
40
40
  this.arrowShape = [ArrowheadType.None, ArrowheadType.SolidArrow];
41
+ this.isTouchDblClick = false;
42
+ this.isMouseDown = false;
43
+ this.isMouseUp = false;
44
+ this.mouseWheel = 0;
41
45
  this.parent = parent;
42
46
  this.addEventListener();
43
47
  }
@@ -306,6 +310,18 @@ var Selection = /** @class */ (function () {
306
310
  case 'updateSEPoints':
307
311
  this.updateSEPoints(args.value['x'], args.value['y']);
308
312
  break;
313
+ case 'drawMaskCircle':
314
+ this.drawMaskCircle(args.value['x'], args.value['y']);
315
+ break;
316
+ case 'isValueUpdated':
317
+ this.isValueUpdated();
318
+ break;
319
+ case 'getDistance':
320
+ this.getDistance(args.value['x'], args.value['y']);
321
+ break;
322
+ case 'redact':
323
+ this.currentDrawingShape = args.value['shape'];
324
+ break;
309
325
  }
310
326
  };
311
327
  Selection.prototype.getModuleName = function () {
@@ -329,12 +345,14 @@ var Selection = /** @class */ (function () {
329
345
  flipObjColl: [], triangle: [], triangleRatio: [], order: null };
330
346
  this.isFirstMove = false;
331
347
  this.cursorTargetId = this.dragElement = '';
348
+ this.isTouchDblClick = false;
332
349
  this.startTouches = [];
333
350
  this.tempTouches = [];
334
351
  this.currMousePoint = { x: 0, y: 0 };
335
352
  this.isPreventDragging = false;
336
353
  this.timer = undefined;
337
354
  this.tempObjColl = undefined;
355
+ this.mouseWheel = 0;
338
356
  this.textRow = 1;
339
357
  this.mouseDownPoint = { x: 0, y: 0 };
340
358
  this.previousPoint = { x: 0, y: 0 };
@@ -355,6 +373,7 @@ var Selection = /** @class */ (function () {
355
373
  this.mouseDown = '';
356
374
  this.isSliderActive = false;
357
375
  this.arrowShape = [ArrowheadType.None, ArrowheadType.SolidArrow];
376
+ this.isMouseDown = this.isMouseUp = false;
358
377
  };
359
378
  Selection.prototype.performTabAction = function () {
360
379
  var parent = this.parent;
@@ -458,6 +477,12 @@ var Selection = /** @class */ (function () {
458
477
  }
459
478
  var isCropSelection = false;
460
479
  var splitWords;
480
+ if (parent.activeObj.shape) {
481
+ splitWords = parent.activeObj.shape.split('-');
482
+ }
483
+ if ((!splitWords && parent.currObjType.isCustomCrop) || (splitWords && splitWords[0] === 'crop')) {
484
+ isCropSelection = true;
485
+ }
461
486
  if (parent.currObjType.isDragging) {
462
487
  if (this.dragElement === '') {
463
488
  parent.upperCanvas.style.cursor = parent.cursor = 'move';
@@ -469,6 +494,10 @@ var Selection = /** @class */ (function () {
469
494
  }
470
495
  if (parent.togglePen) {
471
496
  parent.upperCanvas.style.cursor = parent.cursor = 'crosshair';
497
+ if (parent.isMaskImage) {
498
+ this.drawMaskCircle(x, y);
499
+ parent.upperCanvas.style.cursor = 'none';
500
+ }
472
501
  return;
473
502
  }
474
503
  if (parent.activeObj.shape) {
@@ -550,6 +579,22 @@ var Selection = /** @class */ (function () {
550
579
  }
551
580
  return highestOrder;
552
581
  };
582
+ Selection.prototype.drawMaskCircle = function (x, y) {
583
+ var parent = this.parent;
584
+ if (parent.isMaskImage) {
585
+ var radius = parent.activeObj.strokeSettings.strokeWidth * 2;
586
+ var canvasDraw = parent.maskCanvas.getContext('2d');
587
+ canvasDraw.clearRect(0, 0, parent.maskCanvas.width, parent.maskCanvas.height);
588
+ canvasDraw.fillStyle = parent.activeObj.strokeSettings.strokeColor;
589
+ canvasDraw.strokeStyle = '#fff';
590
+ canvasDraw.beginPath();
591
+ canvasDraw.ellipse(x, y, radius / 2, radius / 2, 0, 0, 2 * Math.PI, false);
592
+ canvasDraw.fill();
593
+ canvasDraw.stroke();
594
+ canvasDraw.closePath();
595
+ parent.maskCanvas.style.cursor = 'none';
596
+ }
597
+ };
553
598
  Selection.prototype.setCursorForActObj = function (splitWords, isCropSelection, x, y) {
554
599
  var parent = this.parent;
555
600
  if (parent.activeObj.horTopLine !== undefined) {
@@ -981,16 +1026,31 @@ var Selection = /** @class */ (function () {
981
1026
  return false;
982
1027
  }
983
1028
  };
1029
+ Selection.prototype.preventResizing = function (tempActiveObj) {
1030
+ var parent = this.parent;
1031
+ if (parent.activeObj.preventShapeDragOut && this.isShapeDragOut()) {
1032
+ var actPoint = parent.activeObj.activePoint;
1033
+ actPoint.startX = tempActiveObj.activePoint.startX;
1034
+ actPoint.startY = tempActiveObj.activePoint.startY;
1035
+ actPoint.endX = tempActiveObj.activePoint.endX;
1036
+ actPoint.endY = tempActiveObj.activePoint.endY;
1037
+ actPoint.width = tempActiveObj.activePoint.width;
1038
+ actPoint.height = tempActiveObj.activePoint.height;
1039
+ parent.activeObj.rotatedAngle = tempActiveObj.rotatedAngle;
1040
+ parent.notify('draw', { prop: 'updateActiveObject', onPropertyChange: false,
1041
+ value: { actPoint: actPoint, obj: parent.activeObj, isMouseMove: null, x: null, y: null } });
1042
+ }
1043
+ };
984
1044
  Selection.prototype.updateActivePoint = function (x, y, isCropSelection) {
985
1045
  var parent = this.parent;
986
1046
  var obj = { width: 0, height: 0 };
987
- var _a = parent.activeObj.activePoint, startX = _a.startX, startY = _a.startY, endX = _a.endX, endY = _a.endY;
1047
+ var _a = parent.activeObj.activePoint, startX = _a.startX, startY = _a.startY;
988
1048
  var _b = parent.activeObj.activePoint, width = _b.width, height = _b.height;
989
1049
  parent.notify('transform', { prop: 'calcMaxDimension', onPropertyChange: false,
990
1050
  value: { width: width, height: height, obj: obj, isImgShape: null } });
991
1051
  var previousShapeSettings = this.updatePrevShapeSettings();
992
- var shapeResizingArgs = { cancel: false, action: 'resize', previousShapeSettings: previousShapeSettings };
993
- var shapeMovingArgs = { cancel: false, action: 'move', previousShapeSettings: previousShapeSettings };
1052
+ var shapeResizingArgs = { cancel: false, action: 'resize', previousShapeSettings: previousShapeSettings, allowShapeOverflow: this.allowOutofBound() };
1053
+ var shapeMovingArgs = { cancel: false, action: 'move', previousShapeSettings: previousShapeSettings, allowShapeOverflow: this.allowOutofBound() };
994
1054
  this.shapeResizingArgs = shapeResizingArgs;
995
1055
  this.shapeMovingArgs = shapeMovingArgs;
996
1056
  if (parent.activeObj.shape === 'text' && this.dragElement !== '') {
@@ -1031,51 +1091,68 @@ var Selection = /** @class */ (function () {
1031
1091
  if (isCropSelection && parent.transform.straighten !== 0 && this.isMouseOutsideImg(x, y)) {
1032
1092
  return;
1033
1093
  }
1094
+ var tempActiveObj = extend({}, parent.activeObj, {}, true);
1095
+ var splitWords;
1096
+ var cropResize;
1097
+ if (parent.activeObj.shape !== undefined) {
1098
+ splitWords = parent.activeObj.shape.split('-');
1099
+ }
1100
+ if (splitWords !== undefined && splitWords[0] === 'crop') {
1101
+ cropResize = true;
1102
+ }
1034
1103
  switch (this.dragElement.toLowerCase()) {
1035
1104
  case 'nw-resize':
1036
1105
  this.updateNWPoints(x, y);
1106
+ this.preventResizing(tempActiveObj);
1037
1107
  parent.notify('shape', { prop: 'updateArrowDirection', onPropertyChange: false,
1038
1108
  value: { obj: parent.activeObj, flip: null, rotatedDegree: null } });
1039
1109
  this.triggerShapeChange(shapeResizingArgs, shapeMovingArgs, 'resize');
1040
1110
  break;
1041
1111
  case 'n-resize':
1042
1112
  this.updateNPoints(x, y);
1113
+ this.preventResizing(tempActiveObj);
1043
1114
  parent.notify('shape', { prop: 'updateArrowDirection', onPropertyChange: false,
1044
1115
  value: { obj: parent.activeObj, flip: null, rotatedDegree: null } });
1045
1116
  this.triggerShapeChange(shapeResizingArgs, shapeMovingArgs, 'resize');
1046
1117
  break;
1047
1118
  case 'ne-resize':
1048
1119
  this.updateNEPoints(x, y);
1120
+ this.preventResizing(tempActiveObj);
1049
1121
  parent.notify('shape', { prop: 'updateArrowDirection', onPropertyChange: false,
1050
1122
  value: { obj: parent.activeObj, flip: null, rotatedDegree: null } });
1051
1123
  this.triggerShapeChange(shapeResizingArgs, shapeMovingArgs, 'resize');
1052
1124
  break;
1053
1125
  case 'w-resize':
1054
1126
  this.updateWPoints(x, y);
1127
+ this.preventResizing(tempActiveObj);
1055
1128
  parent.notify('shape', { prop: 'updateArrowDirection', onPropertyChange: false,
1056
1129
  value: { obj: parent.activeObj, flip: null, rotatedDegree: null } });
1057
1130
  this.triggerShapeChange(shapeResizingArgs, shapeMovingArgs, 'resize');
1058
1131
  break;
1059
1132
  case 'e-resize':
1060
1133
  this.updateEPoints(x, y);
1134
+ this.preventResizing(tempActiveObj);
1061
1135
  parent.notify('shape', { prop: 'updateArrowDirection', onPropertyChange: false,
1062
1136
  value: { obj: parent.activeObj, flip: null, rotatedDegree: null } });
1063
1137
  this.triggerShapeChange(shapeResizingArgs, shapeMovingArgs, 'resize');
1064
1138
  break;
1065
1139
  case 'sw-resize':
1066
1140
  this.updateSWPoints(x, y);
1141
+ this.preventResizing(tempActiveObj);
1067
1142
  parent.notify('shape', { prop: 'updateArrowDirection', onPropertyChange: false,
1068
1143
  value: { obj: parent.activeObj, flip: null, rotatedDegree: null } });
1069
1144
  this.triggerShapeChange(shapeResizingArgs, shapeMovingArgs, 'resize');
1070
1145
  break;
1071
1146
  case 's-resize':
1072
1147
  this.updateSPoints(x, y);
1148
+ this.preventResizing(tempActiveObj);
1073
1149
  parent.notify('shape', { prop: 'updateArrowDirection', onPropertyChange: false,
1074
1150
  value: { obj: parent.activeObj, flip: null, rotatedDegree: null } });
1075
1151
  this.triggerShapeChange(shapeResizingArgs, shapeMovingArgs, 'resize');
1076
1152
  break;
1077
1153
  case 'se-resize':
1078
1154
  this.updateSEPoints(x, y);
1155
+ this.preventResizing(tempActiveObj);
1079
1156
  parent.notify('shape', { prop: 'updateArrowDirection', onPropertyChange: false,
1080
1157
  value: { obj: parent.activeObj, flip: null, rotatedDegree: null } });
1081
1158
  this.triggerShapeChange(shapeResizingArgs, shapeMovingArgs, 'resize');
@@ -1125,6 +1202,7 @@ var Selection = /** @class */ (function () {
1125
1202
  parent.activeObj.rotatedAngle -= (180 * (Math.PI / 180));
1126
1203
  }
1127
1204
  }
1205
+ this.preventResizing(tempActiveObj);
1128
1206
  break;
1129
1207
  case 'pathdrag':
1130
1208
  if (!isNullOrUndefined(this.pathAdjustedIndex)) {
@@ -1144,8 +1222,6 @@ var Selection = /** @class */ (function () {
1144
1222
  activePoint.endY += height_1;
1145
1223
  startX = activePoint.startX;
1146
1224
  startY = activePoint.startY;
1147
- endX = activePoint.endX;
1148
- endY = activePoint.endY;
1149
1225
  if (parent.activeObj.shape !== 'line' && parent.activeObj.shape !== 'arrow' &&
1150
1226
  parent.activeObj.rotationCirclePointColl) {
1151
1227
  parent.activeObj.rotationCirclePointColl.x += width_1;
@@ -1159,10 +1235,7 @@ var Selection = /** @class */ (function () {
1159
1235
  parent.activeObj.pointColl[i].y += height_1;
1160
1236
  }
1161
1237
  }
1162
- if (!this.isPreventDragging && parent.activeObj.shape !== 'line' && (parent.activeObj.rotatedAngle === 0 && (startX < parent.img.destLeft ||
1163
- startY < parent.img.destTop || endX >
1164
- parent.img.destLeft + parent.img.destWidth || endY > parent.img.destTop
1165
- + parent.img.destHeight))) {
1238
+ if ((!this.isPreventDragging && this.isShapeDragOut()) && (parent.activeObj.preventShapeDragOut || parent.activeObj.shape === 'redact' || cropResize)) {
1166
1239
  activePoint.startX -= width_1;
1167
1240
  activePoint.endX -= width_1;
1168
1241
  activePoint.startY -= height_1;
@@ -1174,8 +1247,33 @@ var Selection = /** @class */ (function () {
1174
1247
  parent.activeObj.rotationCirclePoint.x -= width_1;
1175
1248
  parent.activeObj.rotationCirclePoint.y -= height_1;
1176
1249
  }
1177
- this.setDragWidth(width_1);
1178
- this.setDragHeight(height_1);
1250
+ else if (parent.activeObj.shape === 'path') {
1251
+ for (var l = 0, len = parent.activeObj.pointColl.length; l < len; l++) {
1252
+ parent.activeObj.pointColl[l].x -= width_1;
1253
+ parent.activeObj.pointColl[l].y -= height_1;
1254
+ }
1255
+ }
1256
+ if (parent.activeObj.rotatedAngle === 0) {
1257
+ var tempEndX = parent.activeObj.activePoint.endX;
1258
+ var tempEndY = parent.activeObj.activePoint.endY;
1259
+ if (parent.activeObj.shape === 'path') {
1260
+ parent.activeObj.activePoint = parent.getSquarePointForPath(parent.activeObj);
1261
+ }
1262
+ this.setDragWidth(width_1);
1263
+ this.setDragHeight(height_1);
1264
+ var currObj = parent.activeObj;
1265
+ var xDiff = currObj.activePoint.endX - tempEndX;
1266
+ var yDiff = currObj.activePoint.endY - tempEndY;
1267
+ if (currObj.shape === 'path') {
1268
+ for (var l = 0, len = currObj.pointColl.length; l < len; l++) {
1269
+ currObj.pointColl[l].x += xDiff;
1270
+ currObj.pointColl[l].y += yDiff;
1271
+ }
1272
+ }
1273
+ }
1274
+ else {
1275
+ parent.notify('selection', { prop: 'updPtCollForShpRot', onPropertyChange: false, value: { obj: parent.activeObj } });
1276
+ }
1179
1277
  }
1180
1278
  }
1181
1279
  else {
@@ -1191,6 +1289,55 @@ var Selection = /** @class */ (function () {
1191
1289
  break;
1192
1290
  }
1193
1291
  };
1292
+ Selection.prototype.isShapeDragOut = function () {
1293
+ var parent = this.parent;
1294
+ var isShapeDragOut = false;
1295
+ var allowPreventing = false;
1296
+ var shape = parent.activeObj.shape;
1297
+ if (parent.activeObj.preventShapeDragOut) {
1298
+ allowPreventing = true;
1299
+ }
1300
+ else if (parent.activeObj.rotatedAngle === 0 &&
1301
+ (shape !== 'line' && shape !== 'arrow' && shape !== 'path')) {
1302
+ allowPreventing = true;
1303
+ }
1304
+ if (allowPreventing) {
1305
+ var _a = parent.activeObj.activePoint, startX = _a.startX, startY = _a.startY, endX = _a.endX, endY = _a.endY;
1306
+ if (shape === 'path') {
1307
+ var path = parent.getSquarePointForPath(parent.activeObj);
1308
+ startX = path.startX;
1309
+ startY = path.startY;
1310
+ endX = path.endX;
1311
+ endY = path.endY;
1312
+ }
1313
+ if (parent.activeObj.rotatedAngle === 0 || shape === 'arrow') {
1314
+ isShapeDragOut = this.isObjOutsideImg(startX, startY, endX, endY, shape);
1315
+ }
1316
+ else {
1317
+ var obj = { isIntersect: null, arr: null };
1318
+ parent.notify('draw', { prop: 'updateImgCanvasPoints', onPropertyChange: false });
1319
+ parent.notify('draw', { prop: 'isLinesIntersect', onPropertyChange: false, value: { obj: obj } });
1320
+ if (obj['arr'][0] || obj['arr'][1] || obj['arr'][2] || obj['arr'][3]) {
1321
+ isShapeDragOut = true;
1322
+ }
1323
+ else {
1324
+ isShapeDragOut = this.isObjOutsideImg(startX, startY, endX, endY, shape);
1325
+ }
1326
+ }
1327
+ }
1328
+ return isShapeDragOut;
1329
+ };
1330
+ Selection.prototype.isObjOutsideImg = function (startX, startY, endX, endY, shape) {
1331
+ var parent = this.parent;
1332
+ var _a = parent.img, destLeft = _a.destLeft, destTop = _a.destTop, destWidth = _a.destWidth, destHeight = _a.destHeight;
1333
+ if (startX < destLeft || startY < destTop || endX > destLeft + destWidth ||
1334
+ endY > destTop + destHeight || ((shape === 'line' || shape === 'arrow') &&
1335
+ (startX > destLeft + destWidth || startY > destTop + destHeight ||
1336
+ endX < destLeft || endY < destTop))) {
1337
+ return true;
1338
+ }
1339
+ return false;
1340
+ };
1194
1341
  Selection.prototype.triggerShapeChange = function (shapeResizingArgs, shapeMovingArgs, type) {
1195
1342
  var parent = this.parent;
1196
1343
  var actPoint = parent.activeObj.activePoint;
@@ -1218,12 +1365,20 @@ var Selection = /** @class */ (function () {
1218
1365
  if (this.currentDrawingShape !== '' && parent.upperCanvas.style.cursor === 'crosshair') {
1219
1366
  shapeResizingArgs.action = 'drawing';
1220
1367
  }
1221
- parent.trigger('shapeChanging', shapeResizingArgs);
1368
+ if (!parent.currObjType.isRedact || parent.activeObj.shape !== 'redact') {
1369
+ parent.trigger('shapeChanging', shapeResizingArgs);
1370
+ }
1371
+ parent.editCompleteArgs = shapeResizingArgs;
1222
1372
  this.isPreventShaping = shapeResizingArgs.cancel;
1223
- parent.notify('shape', { prop: 'updateShapeChangeEventArgs', onPropertyChange: false,
1224
- value: { shapeSettings: shapeResizingArgs.currentShapeSettings } });
1373
+ parent.notify('shape', { prop: 'updateShapeChangeEventArgs', onPropertyChange: false, value: { shapeSettings: shapeResizingArgs.currentShapeSettings, allowShapeOverflow: shapeResizingArgs.allowShapeOverflow } });
1225
1374
  }
1226
1375
  else {
1376
+ if (this.isMouseDown) {
1377
+ shapeResizingArgs.action = 'resize-start';
1378
+ }
1379
+ else if (this.isMouseUp) {
1380
+ shapeResizingArgs.action = 'resize-end';
1381
+ }
1227
1382
  var selectionResizingArgs = { action: shapeResizingArgs.action,
1228
1383
  previousSelectionSettings: { type: parent.getSelectionType(parent.activeObj.shape),
1229
1384
  startX: shapeResizingArgs.previousShapeSettings.startX,
@@ -1237,21 +1392,28 @@ var Selection = /** @class */ (function () {
1237
1392
  height: shapeResizingArgs.currentShapeSettings.height } };
1238
1393
  this.selectionResizingArgs = selectionResizingArgs;
1239
1394
  parent.trigger('selectionChanging', selectionResizingArgs);
1395
+ parent.editCompleteArgs = selectionResizingArgs;
1240
1396
  parent.notify('shape', { prop: 'updSelChangeEventArgs', onPropertyChange: false,
1241
1397
  value: { selectionSettings: selectionResizingArgs.currentSelectionSettings } });
1242
1398
  }
1243
1399
  }
1244
1400
  else if (type === 'mouse-down' || type === 'mouse-up') {
1245
- parent.trigger('shapeChanging', shapeResizingArgs);
1401
+ if (parent.activeObj.shape !== 'redact') {
1402
+ parent.trigger('shapeChanging', shapeResizingArgs);
1403
+ }
1404
+ parent.editCompleteArgs = shapeResizingArgs;
1246
1405
  this.isPreventShaping = shapeResizingArgs.cancel;
1247
1406
  parent.notify('shape', { prop: 'updateShapeChangeEventArgs', onPropertyChange: false,
1248
- value: { shapeSettings: shapeResizingArgs.currentShapeSettings } });
1407
+ value: { shapeSettings: shapeResizingArgs.currentShapeSettings, allowShapeOverflow: shapeResizingArgs.allowShapeOverflow } });
1249
1408
  }
1250
1409
  else {
1251
- parent.trigger('shapeChanging', shapeMovingArgs);
1410
+ if (parent.activeObj.shape !== 'redact') {
1411
+ parent.trigger('shapeChanging', shapeMovingArgs);
1412
+ }
1413
+ parent.editCompleteArgs = shapeMovingArgs;
1252
1414
  this.isPreventShaping = shapeMovingArgs.cancel;
1253
1415
  parent.notify('shape', { prop: 'updateShapeChangeEventArgs', onPropertyChange: false,
1254
- value: { shapeSettings: shapeMovingArgs.currentShapeSettings } });
1416
+ value: { shapeSettings: shapeMovingArgs.currentShapeSettings, allowShapeOverflow: shapeMovingArgs.allowShapeOverflow } });
1255
1417
  }
1256
1418
  parent.eventType = type;
1257
1419
  };
@@ -1260,13 +1422,20 @@ var Selection = /** @class */ (function () {
1260
1422
  var actPoint = parent.activeObj.activePoint;
1261
1423
  var _a = parent.img, destLeft = _a.destLeft, destWidth = _a.destWidth;
1262
1424
  var tempWidth = width;
1425
+ var shape = parent.activeObj.shape;
1426
+ var preventDragOut = false;
1427
+ if (parent.activeObj.preventShapeDragOut && (shape === 'line' || shape === 'arrow')) {
1428
+ preventDragOut = true;
1429
+ }
1263
1430
  if (tempWidth >= 0) {
1264
1431
  for (var i = 0; i < tempWidth; i++) {
1265
1432
  width = tempWidth - i;
1266
1433
  actPoint.startX += width;
1267
1434
  actPoint.endX += width;
1268
- if (actPoint.startX >= destLeft &&
1269
- actPoint.endX <= destLeft + destWidth) {
1435
+ if ((actPoint.startX >= destLeft &&
1436
+ actPoint.endX <= destLeft + destWidth && !preventDragOut) ||
1437
+ (actPoint.startX >= destLeft && actPoint.endX <= destLeft + destWidth &&
1438
+ actPoint.endX >= destLeft && actPoint.startX <= destLeft + destWidth && preventDragOut)) {
1270
1439
  break;
1271
1440
  }
1272
1441
  else {
@@ -1280,8 +1449,10 @@ var Selection = /** @class */ (function () {
1280
1449
  width = tempWidth + i;
1281
1450
  actPoint.startX += width;
1282
1451
  actPoint.endX += width;
1283
- if (actPoint.startX >= destLeft &&
1284
- actPoint.endX <= destLeft + destWidth) {
1452
+ if ((actPoint.startX >= destLeft &&
1453
+ actPoint.endX <= destLeft + destWidth && !preventDragOut) ||
1454
+ (actPoint.startX >= destLeft && actPoint.endX <= destLeft + destWidth &&
1455
+ actPoint.endX >= destLeft && actPoint.startX <= destLeft + destWidth && preventDragOut)) {
1285
1456
  break;
1286
1457
  }
1287
1458
  else {
@@ -1296,13 +1467,20 @@ var Selection = /** @class */ (function () {
1296
1467
  var actPoint = parent.activeObj.activePoint;
1297
1468
  var _a = parent.img, destTop = _a.destTop, destHeight = _a.destHeight;
1298
1469
  var tempHeight = height;
1470
+ var shape = parent.activeObj.shape;
1471
+ var preventDragOut = false;
1472
+ if (parent.activeObj.preventShapeDragOut && (shape === 'line' || shape === 'arrow')) {
1473
+ preventDragOut = true;
1474
+ }
1299
1475
  if (tempHeight >= 0) {
1300
1476
  for (var i = 1; i < tempHeight; i++) {
1301
1477
  height = tempHeight - i;
1302
1478
  actPoint.startY += height;
1303
1479
  actPoint.endY += height;
1304
- if (actPoint.startY >= destTop &&
1305
- actPoint.endY <= destTop + destHeight) {
1480
+ if ((actPoint.startY >= destTop &&
1481
+ actPoint.endY <= destTop + destHeight && !preventDragOut) ||
1482
+ (actPoint.startY >= destTop && actPoint.endY <= destTop + destHeight &&
1483
+ actPoint.endY >= destTop && actPoint.startY <= destTop + destHeight && preventDragOut)) {
1306
1484
  break;
1307
1485
  }
1308
1486
  else {
@@ -1316,8 +1494,10 @@ var Selection = /** @class */ (function () {
1316
1494
  height = tempHeight + i;
1317
1495
  actPoint.startY += height;
1318
1496
  actPoint.endY += height;
1319
- if (actPoint.startY >= destTop &&
1320
- actPoint.endY <= destTop + destHeight) {
1497
+ if ((actPoint.startY >= destTop &&
1498
+ actPoint.endY <= destTop + destHeight && !preventDragOut) ||
1499
+ (actPoint.startY >= destTop && actPoint.endY <= destTop + destHeight &&
1500
+ actPoint.endY >= destTop && actPoint.startY <= destTop + destHeight && preventDragOut)) {
1321
1501
  break;
1322
1502
  }
1323
1503
  else {
@@ -1336,17 +1516,35 @@ var Selection = /** @class */ (function () {
1336
1516
  var startY = isStart ? actPoint.startY : actPoint.endY;
1337
1517
  var endX = isStart ? actPoint.endX : actPoint.startX;
1338
1518
  var endY = isStart ? actPoint.endY : actPoint.startY;
1339
- if (startX < destLeft) {
1340
- startX = destLeft;
1341
- }
1342
- if (startY < destTop) {
1343
- startY = destTop;
1344
- }
1345
- if (endX > destLeft + destWidth) {
1346
- endX = destLeft + destWidth;
1519
+ var wrapperWidth = parent.upperCanvas.width;
1520
+ var wrapperHeight = parent.upperCanvas.height;
1521
+ if (Browser.isDevice) {
1522
+ if (startX < 0 && destLeft < 0) {
1523
+ startX = 0;
1524
+ }
1525
+ if (startY < 0 && destTop < 0) {
1526
+ startY = 0;
1527
+ }
1528
+ if (endX > wrapperWidth && destLeft + destWidth > wrapperWidth) {
1529
+ endX = wrapperWidth;
1530
+ }
1531
+ if (endY > wrapperHeight && destTop + destHeight > wrapperHeight) {
1532
+ endY = wrapperHeight;
1533
+ }
1347
1534
  }
1348
- if (endY > destTop + destHeight) {
1349
- endY = destTop + destHeight;
1535
+ else {
1536
+ if (startX < destLeft) {
1537
+ startX = destLeft;
1538
+ }
1539
+ if (startY < destTop) {
1540
+ startY = destTop;
1541
+ }
1542
+ if (endX > destLeft + destWidth) {
1543
+ endX = destLeft + destWidth;
1544
+ }
1545
+ if (endY > destTop + destHeight) {
1546
+ endY = destTop + destHeight;
1547
+ }
1350
1548
  }
1351
1549
  if (parent.transform.straighten !== 0) {
1352
1550
  var obj = { isIntersect: null, arr: null };
@@ -1382,7 +1580,15 @@ var Selection = /** @class */ (function () {
1382
1580
  if (parent.activeObj.shape === 'image') {
1383
1581
  return isLimiting;
1384
1582
  }
1385
- if (!this.isPreventDragging && parent.activeObj.rotatedAngle === 0) {
1583
+ var splitWords;
1584
+ var cropResize;
1585
+ if (parent.activeObj.shape !== undefined) {
1586
+ splitWords = parent.activeObj.shape.split('-');
1587
+ }
1588
+ if (splitWords !== undefined && splitWords[0] === 'crop') {
1589
+ cropResize = true;
1590
+ }
1591
+ if ((!this.isPreventDragging && parent.activeObj.rotatedAngle === 0) && (parent.activeObj.preventShapeDragOut || parent.activeObj.shape === 'redact' || cropResize)) {
1386
1592
  isLimiting = this.limitDrag(true);
1387
1593
  var shapeColl = ['line', 'arrow', 'path'];
1388
1594
  if (shapeColl.indexOf(parent.activeObj.shape) > -1) {
@@ -2591,7 +2797,15 @@ var Selection = /** @class */ (function () {
2591
2797
  else {
2592
2798
  var rotationCirclePoint = this.getTransRotationPoint(actObj);
2593
2799
  var radius = actObj.topLeftCircle.radius;
2594
- if (x >= (actObj.topLeftCircle.startX - (radius * 2)) &&
2800
+ if (rotationCirclePoint &&
2801
+ x >= rotationCirclePoint.x - (radius * 2) &&
2802
+ x <= rotationCirclePoint.x + (radius * 2) &&
2803
+ y >= rotationCirclePoint.y - (radius * 2) &&
2804
+ y <= rotationCirclePoint.y + (radius * 2) && this.dragElement !== 'grabbing') {
2805
+ parent.upperCanvas.style.cursor = parent.cursor = 'grabbing';
2806
+ this.dragElement = parent.upperCanvas.style.cursor;
2807
+ }
2808
+ else if (x >= (actObj.topLeftCircle.startX - (radius * 2)) &&
2595
2809
  x <= (actObj.topLeftCircle.startX + (radius * 2)) &&
2596
2810
  y >= (actObj.topLeftCircle.startY - (radius * 2)) &&
2597
2811
  y <= (actObj.topLeftCircle.startY + (radius * 2)) && this.dragElement !== 'nw-resize') {
@@ -2663,14 +2877,6 @@ var Selection = /** @class */ (function () {
2663
2877
  isResize = true;
2664
2878
  this.dragElement = parent.upperCanvas.style.cursor;
2665
2879
  }
2666
- else if (rotationCirclePoint &&
2667
- x >= rotationCirclePoint.x - (radius * 2) &&
2668
- x <= rotationCirclePoint.x + (radius * 2) &&
2669
- y >= rotationCirclePoint.y - (radius * 2) &&
2670
- y <= rotationCirclePoint.y + (radius * 2) && this.dragElement !== 'grabbing') {
2671
- parent.upperCanvas.style.cursor = parent.cursor = 'grabbing';
2672
- this.dragElement = parent.upperCanvas.style.cursor;
2673
- }
2674
2880
  else {
2675
2881
  this.dragPoint.startX = this.previousPoint.x = this.dragPoint.endX = x;
2676
2882
  this.dragPoint.startY = this.previousPoint.y = this.dragPoint.endY = y;
@@ -2960,12 +3166,14 @@ var Selection = /** @class */ (function () {
2960
3166
  this.isGrabbing = true;
2961
3167
  parent.notify('selection', { prop: 'updatePrevShapeSettings', onPropertyChange: false, value: { obj: obj } });
2962
3168
  var shapeSettings = obj['shapeSettingsObj'];
2963
- var shapeResizingArgs = { cancel: false, action: 'rotate-start', previousShapeSettings: shapeSettings };
2964
- var shapeMovingArgs = { cancel: false, action: 'rotate-start', previousShapeSettings: shapeSettings };
3169
+ var shapeResizingArgs = { cancel: false, action: 'rotate-start', previousShapeSettings: shapeSettings, allowShapeOverflow: this.allowOutofBound() };
3170
+ var shapeMovingArgs = { cancel: false, action: 'rotate-start', previousShapeSettings: shapeSettings, allowShapeOverflow: this.allowOutofBound() };
2965
3171
  this.triggerShapeChange(shapeResizingArgs, shapeMovingArgs, 'mouse-down');
2966
3172
  }
2967
3173
  var imageEditorClickEventArgs = { point: this.setXYPoints(e) };
2968
3174
  parent.trigger('click', imageEditorClickEventArgs);
3175
+ this.isMouseDown = true;
3176
+ this.isMouseUp = false;
2969
3177
  this.clickEvent(imageEditorClickEventArgs, e);
2970
3178
  };
2971
3179
  Selection.prototype.getImagePoints = function (x, y) {
@@ -2992,6 +3200,7 @@ var Selection = /** @class */ (function () {
2992
3200
  var y = imageEditorClickEventArgs.point.y;
2993
3201
  var cursor = parent.activeObj.shape && parent.activeObj.shape === 'text' ?
2994
3202
  parent.cursor : 'default';
3203
+ var tempCursor = parent.upperCanvas.style.cursor;
2995
3204
  if (parent.isResize) {
2996
3205
  this.performEnterAction();
2997
3206
  parent.upperCanvas.style.cursor = 'default';
@@ -3000,8 +3209,8 @@ var Selection = /** @class */ (function () {
3000
3209
  else if (JSON.stringify(parent.frameObj) !== JSON.stringify(parent.tempFrameObj)) {
3001
3210
  parent.okBtn();
3002
3211
  }
3003
- else if (this.currentDrawingShape !== '' && ((this.isTouch && !this.isShapeTouch(e, this.isCropSelection))
3004
- || parent.upperCanvas.style.cursor === 'crosshair' || parent.isShapeDrawing)) {
3212
+ else if (this.currentDrawingShape !== '' && (!this.isShapeTouch(e, this.isCropSelection) &&
3213
+ ((this.isTouch) || tempCursor === 'crosshair' || parent.isShapeDrawing))) {
3005
3214
  if (parent.drawingShape && !parent.isShapeDrawing) {
3006
3215
  parent.okBtn();
3007
3216
  parent.enableShapeDrawing(parent.toPascalCase(parent.drawingShape), true);
@@ -3049,8 +3258,8 @@ var Selection = /** @class */ (function () {
3049
3258
  }
3050
3259
  parent.currObjType.isDragging = true;
3051
3260
  var previousShapeSettings = this.updatePrevShapeSettings();
3052
- var shapeResizingArgs = { cancel: false, action: 'draw-start', previousShapeSettings: previousShapeSettings };
3053
- var shapeMovingArgs = { cancel: false, action: 'move', previousShapeSettings: previousShapeSettings };
3261
+ var shapeResizingArgs = { cancel: false, action: 'draw-start', previousShapeSettings: previousShapeSettings, allowShapeOverflow: this.allowOutofBound() };
3262
+ var shapeMovingArgs = { cancel: false, action: 'move', previousShapeSettings: previousShapeSettings, allowShapeOverflow: this.allowOutofBound() };
3054
3263
  this.shapeResizingArgs = shapeResizingArgs;
3055
3264
  this.shapeMovingArgs = shapeMovingArgs;
3056
3265
  this.triggerShapeChange(shapeResizingArgs, shapeMovingArgs, 'mouse-down');
@@ -3096,7 +3305,7 @@ var Selection = /** @class */ (function () {
3096
3305
  parent.notify('undo-redo', { prop: 'updateCurrUrc', value: { type: 'ok' } });
3097
3306
  }
3098
3307
  }
3099
- if (!isShape && !parent.togglePen && !this.isCropSelection) {
3308
+ if (!isShape && !parent.togglePen && !this.isCropSelection && parent.activeObj.redactType !== 'blur' && parent.activeObj.redactType !== 'pixelate') {
3100
3309
  parent.notify('toolbar', { prop: 'refresh-main-toolbar', onPropertyChange: false });
3101
3310
  parent.notify('toolbar', { prop: 'close-contextual-toolbar', onPropertyChange: false });
3102
3311
  }
@@ -3117,7 +3326,7 @@ var Selection = /** @class */ (function () {
3117
3326
  parent.notify('toolbar', { prop: 'destroy-qa-toolbar', onPropertyChange: false });
3118
3327
  }
3119
3328
  var shape = parent.activeObj.shape;
3120
- var shapeColl = ['rectangle', 'ellipse', 'line', 'arrow', 'path', 'text', 'image'];
3329
+ var shapeColl = ['rectangle', 'ellipse', 'line', 'arrow', 'path', 'text', 'image', 'redact'];
3121
3330
  if (shape && shapeColl.indexOf(shape) > -1) {
3122
3331
  parent.notify('shape', { prop: 'redrawActObj', onPropertyChange: false,
3123
3332
  value: { x: null, y: null, isMouseDown: null } });
@@ -3125,6 +3334,16 @@ var Selection = /** @class */ (function () {
3125
3334
  parent.notify('toolbar', { prop: 'setCurrentToolbar', value: { type: 'main' } });
3126
3335
  parent.notify('toolbar', { prop: 'refresh-main-toolbar', onPropertyChange: false });
3127
3336
  }
3337
+ var isCropSelection = false;
3338
+ if (parent.activeObj.shape && parent.activeObj.shape.indexOf('crop-') > -1) {
3339
+ isCropSelection = true;
3340
+ }
3341
+ if (parent.element.querySelector('.e-contextual-toolbar-wrapper') && !isCropSelection) {
3342
+ if (!parent.element.querySelector('.e-contextual-toolbar-wrapper').classList.contains('e-hide')) {
3343
+ parent.okBtn();
3344
+ parent.element.querySelector('.e-contextual-toolbar-wrapper').classList.add('e-hide');
3345
+ }
3346
+ }
3128
3347
  this.canvasMouseDownHandler(e);
3129
3348
  }
3130
3349
  else {
@@ -3201,6 +3420,7 @@ var Selection = /** @class */ (function () {
3201
3420
  index: point.order };
3202
3421
  var shapeChangedArgs = { action: 'apply', currentShapeSettings: extend({}, shapeSettings, {}, true) };
3203
3422
  parent.trigger('shapeChange', shapeChangedArgs);
3423
+ parent.editCompleteArgs = shapeChangedArgs;
3204
3424
  }
3205
3425
  var isPenDraw = parent.togglePen;
3206
3426
  parent.notify('toolbar', { prop: 'close-contextual-toolbar', onPropertyChange: false });
@@ -3228,6 +3448,7 @@ var Selection = /** @class */ (function () {
3228
3448
  }
3229
3449
  this.upperContext.strokeStyle = parent.activeObj.strokeSettings.strokeColor;
3230
3450
  this.upperContext.fillStyle = parent.activeObj.strokeSettings.strokeColor;
3451
+ parent.notify('freehand-draw', { prop: 'resetSelPoints', onPropertyChange: false });
3231
3452
  parent.notify('freehand-draw', { prop: 'freehandDownHandler', onPropertyChange: false,
3232
3453
  value: { e: e, canvas: parent.upperCanvas } });
3233
3454
  }
@@ -3239,7 +3460,8 @@ var Selection = /** @class */ (function () {
3239
3460
  this.dragElement = '';
3240
3461
  this.dragPoint.startX = this.dragPoint.startY = this.dragPoint.endX = this.dragPoint.endY = 0;
3241
3462
  }
3242
- if ((parent.cursor !== 'crosshair' && e.type.toLowerCase() === 'touchstart') ||
3463
+ if (((this.isTouch && tempCursor !== 'crosshair' || parent.cursor !== 'crosshair') &&
3464
+ e.type.toLowerCase() === 'touchstart') ||
3243
3465
  (parent.currObjType.isActiveObj && parent.cursor !== 'default' && !parent.togglePen)) {
3244
3466
  parent.notify('draw', { prop: 'updateTempObjColl' });
3245
3467
  parent.notify('draw', { prop: 'updateTempPointColl' });
@@ -3262,19 +3484,24 @@ var Selection = /** @class */ (function () {
3262
3484
  var cursor = parent.cursor;
3263
3485
  var canvasCursor = parent.upperCanvas.style.cursor;
3264
3486
  e.preventDefault();
3265
- if (this.isPreventShaping) {
3487
+ if (this.isPreventShaping || (parent.isShapeDrawing && parent.currObjType.isDragging && this.isTouch &&
3488
+ parent.activeObj.shape && parent.activeObj.shape === 'path')) {
3266
3489
  return;
3267
3490
  }
3268
3491
  if (parent.cursor === 'grabbing' && this.isGrabbing) {
3269
3492
  var obj = { shapeSettingsObj: {} };
3270
3493
  parent.notify('selection', { prop: 'updatePrevShapeSettings', onPropertyChange: false, value: { obj: obj } });
3271
3494
  var shapeSettings = obj['shapeSettingsObj'];
3272
- var shapeResizingArgs = { cancel: false, action: 'rotating', previousShapeSettings: shapeSettings };
3273
- var shapeMovingArgs = { cancel: false, action: 'rotating', previousShapeSettings: shapeSettings };
3495
+ var shapeResizingArgs = { cancel: false, action: 'rotating', previousShapeSettings: shapeSettings, allowShapeOverflow: this.allowOutofBound() };
3496
+ var shapeMovingArgs = { cancel: false, action: 'rotating', previousShapeSettings: shapeSettings, allowShapeOverflow: this.allowOutofBound() };
3274
3497
  this.triggerShapeChange(shapeResizingArgs, shapeMovingArgs, 'mouse-down');
3275
3498
  }
3276
- if (this.timer && this.timer > 0) {
3277
- this.timer = 0;
3499
+ if (this.timer && this.timer > 0 && this.dragPoint.startX && this.dragPoint.startY) {
3500
+ var width = Math.abs(this.dragPoint.startX - e.touches[0].clientX);
3501
+ var height = Math.abs(this.dragPoint.startY - e.touches[0].clientY);
3502
+ if (width > 10 || height > 10) {
3503
+ this.timer = 0;
3504
+ }
3278
3505
  }
3279
3506
  var bbox = parent.lowerCanvas.getBoundingClientRect();
3280
3507
  if (e.type === 'touchmove' && e.touches.length === 2) {
@@ -3308,6 +3535,7 @@ var Selection = /** @class */ (function () {
3308
3535
  }
3309
3536
  }
3310
3537
  if (type !== '') {
3538
+ parent.isZoomBtnClick = true;
3311
3539
  parent.notify('draw', { prop: 'performPointZoom', onPropertyChange: false,
3312
3540
  value: { x: center.x, y: center.y, type: type, isResize: null } });
3313
3541
  }
@@ -3367,14 +3595,16 @@ var Selection = /** @class */ (function () {
3367
3595
  }
3368
3596
  var _a = parent.img, destLeft = _a.destLeft, destTop = _a.destTop, destWidth = _a.destWidth, destHeight = _a.destHeight;
3369
3597
  if (parent.currObjType.isDragging) {
3598
+ if (parent.activeObj.shape && parent.activeObj.preventShapeDragOut) {
3599
+ if (x < destLeft || x > destLeft + destWidth || y < destTop || y > destTop + destHeight) {
3600
+ return;
3601
+ }
3602
+ }
3370
3603
  this.upperContext.clearRect(0, 0, parent.lowerCanvas.width, parent.lowerCanvas.height);
3371
3604
  this.updateActivePoint(x, y, isCropSelection);
3372
3605
  parent.notify('shape', { prop: 'updateTrianglePoints', onPropertyChange: false, value: { obj: parent.activeObj } });
3373
3606
  if (this.isPreventDragging) {
3374
- if ((parent.activeObj.activePoint.startX > destLeft) &&
3375
- (parent.activeObj.activePoint.endX < destLeft + destWidth) &&
3376
- (parent.activeObj.activePoint.startY > destTop)
3377
- && (parent.activeObj.activePoint.endY < destTop + destHeight)) {
3607
+ if (!this.isShapeDragOut()) {
3378
3608
  this.isPreventDragging = false;
3379
3609
  }
3380
3610
  parent.notify('draw', { prop: 'drawObject', onPropertyChange: false, value: { canvas: 'duplicate', obj: null, isCropRatio: null,
@@ -3388,23 +3618,28 @@ var Selection = /** @class */ (function () {
3388
3618
  this.dragCanvas = parent.togglePan = true;
3389
3619
  }
3390
3620
  }
3621
+ this.isMouseDown = false;
3622
+ this.isMouseUp = false;
3391
3623
  };
3392
3624
  Selection.prototype.mouseUpEventHandler = function (e) {
3393
3625
  var parent = this.parent;
3394
3626
  var id = parent.element.id;
3395
- parent.isKBDNavigation = false;
3627
+ parent.isKBDNavigation = this.isMouseDown = false;
3628
+ this.isMouseUp = true;
3396
3629
  if (!Browser.isDevice && ((parent.element.querySelector('#' + id + '_contextualToolbar') &&
3397
3630
  !parent.element.querySelector('#' + id + '_contextualToolbar').parentElement.classList.contains('e-hide')) ||
3398
3631
  (parent.element.querySelector('#' + id + '_headWrapper')
3399
3632
  && !parent.element.querySelector('#' + id + '_headWrapper').parentElement.classList.contains('e-hide')))) {
3400
- return;
3633
+ if (!(parent.activeObj.shape && parent.activeObj.shape === 'redact' && parent.isShapeDrawing)) {
3634
+ return;
3635
+ }
3401
3636
  }
3402
3637
  if (parent.cursor === 'grabbing' && this.isGrabbing) {
3403
3638
  var obj = { shapeSettingsObj: {} };
3404
3639
  parent.notify('selection', { prop: 'updatePrevShapeSettings', onPropertyChange: false, value: { obj: obj } });
3405
3640
  var shapeSettings = obj['shapeSettingsObj'];
3406
- var shapeResizingArgs = { cancel: false, action: 'rotate-end', previousShapeSettings: shapeSettings };
3407
- var shapeMovingArgs = { cancel: false, action: 'rotate-end', previousShapeSettings: shapeSettings };
3641
+ var shapeResizingArgs = { cancel: false, action: 'rotate-end', previousShapeSettings: shapeSettings, allowShapeOverflow: this.allowOutofBound() };
3642
+ var shapeMovingArgs = { cancel: false, action: 'rotate-end', previousShapeSettings: shapeSettings, allowShapeOverflow: this.allowOutofBound() };
3408
3643
  this.triggerShapeChange(shapeResizingArgs, shapeMovingArgs, 'mouse-up');
3409
3644
  }
3410
3645
  this.isGrabbing = false;
@@ -3430,7 +3665,7 @@ var Selection = /** @class */ (function () {
3430
3665
  x = e.clientX;
3431
3666
  y = e.clientY;
3432
3667
  }
3433
- else {
3668
+ else if (!this.isTouchDblClick) {
3434
3669
  x = this.touchEndPoint.x;
3435
3670
  y = this.touchEndPoint.y;
3436
3671
  }
@@ -3483,6 +3718,12 @@ var Selection = /** @class */ (function () {
3483
3718
  parent.notify('draw', { prop: 'drawObject', onPropertyChange: false, value: { canvas: 'duplicate', obj: parent.activeObj, isCropRatio: null,
3484
3719
  points: null, isPreventDrag: true, saveContext: null, isPreventSelection: true } });
3485
3720
  }
3721
+ if (parent.currObjType.isDragging && this.isTouch &&
3722
+ parent.activeObj.shape && parent.activeObj.shape === 'path') {
3723
+ this.upperContext.clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
3724
+ parent.notify('draw', { prop: 'drawObject', onPropertyChange: false, value: { canvas: 'duplicate', obj: parent.activeObj, isCropRatio: null,
3725
+ points: null, isPreventDrag: true, saveContext: null, isPreventSelection: true } });
3726
+ }
3486
3727
  return;
3487
3728
  }
3488
3729
  if (e.currentTarget === parent.upperCanvas && !parent.isResize) {
@@ -3515,6 +3756,9 @@ var Selection = /** @class */ (function () {
3515
3756
  this.shapeMovingArgs = shapeMovingArgs;
3516
3757
  this.triggerShapeChange(shapeResizingArgs, shapeMovingArgs, 'mouse-up');
3517
3758
  }
3759
+ if (parent.activeObj.shape && parent.activeObj.shape === 'path' && parent.activeObj.pointColl.length > 0) {
3760
+ parent.activeObj.activePoint = parent.getSquarePointForPath(parent.activeObj);
3761
+ }
3518
3762
  this.adjustActObjForLineArrow();
3519
3763
  this.updPtCollForShpRot();
3520
3764
  parent.currObjType.shape = parent.currObjType.shape.toLowerCase();
@@ -3551,6 +3795,11 @@ var Selection = /** @class */ (function () {
3551
3795
  parent.notify('toolbar', { prop: 'destroy-qa-toolbar', onPropertyChange: false });
3552
3796
  }
3553
3797
  }
3798
+ else if (isCropSelection && this.isMouseUp && parent.cursor.indexOf('resize') > -1) {
3799
+ var previousShapeSettings = this.updatePrevShapeSettings();
3800
+ var shapeResizingArgs = { cancel: false, action: 'resize-end', previousShapeSettings: previousShapeSettings };
3801
+ this.triggerShapeChange(shapeResizingArgs, shapeResizingArgs, 'resize');
3802
+ }
3554
3803
  if (parent.activeObj) {
3555
3804
  var isCropSelection_1 = false;
3556
3805
  var splitWords_1;
@@ -3576,6 +3825,10 @@ var Selection = /** @class */ (function () {
3576
3825
  isApplyBtn: null, isCropping: null, isZooming: null, cType: null } });
3577
3826
  }
3578
3827
  }
3828
+ else if (shape === 'redact') {
3829
+ parent.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: { type: 'redact',
3830
+ isApplyBtn: null, isCropping: null, isZooming: null, cType: null } });
3831
+ }
3579
3832
  else if (this.isFhdEditing) {
3580
3833
  parent.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: { type: 'pen',
3581
3834
  isApplyBtn: null, isCropping: null, isZooming: null, cType: null } });
@@ -3590,6 +3843,9 @@ var Selection = /** @class */ (function () {
3590
3843
  parent.activeObj.textSettings.fontSize === 11 && Math.floor(parent.activeObj.activePoint.width) === 55 &&
3591
3844
  Math.floor(parent.activeObj.activePoint.height) === 11) {
3592
3845
  parent.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
3846
+ if (parent.drawingShape === 'text' && !parent.activeObj.keyHistory) {
3847
+ parent.activeObj.keyHistory = 'Enter Text';
3848
+ }
3593
3849
  }
3594
3850
  if (!isCropSelection_1) {
3595
3851
  this.adjustActObjForLineArrow();
@@ -3617,6 +3873,10 @@ var Selection = /** @class */ (function () {
3617
3873
  parent.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: { type: 'text',
3618
3874
  isApplyBtn: null, isCropping: null, isZooming: null, cType: null } });
3619
3875
  }
3876
+ else if (parent.activeObj.shape === 'redact') {
3877
+ parent.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: { type: 'redact',
3878
+ isApplyBtn: null, isCropping: null, isZooming: null, cType: null } });
3879
+ }
3620
3880
  else {
3621
3881
  var temp = this.currentDrawingShape;
3622
3882
  this.currentDrawingShape = '';
@@ -3632,8 +3892,8 @@ var Selection = /** @class */ (function () {
3632
3892
  if (parent.togglePen && e.currentTarget === parent.upperCanvas && !obj['freehandDrawSelectedId']) {
3633
3893
  parent.notify('freehand-draw', { prop: 'freehandUpHandler', onPropertyChange: false,
3634
3894
  value: { e: e, canvas: parent.upperCanvas, context: this.upperContext } });
3635
- if (parent.togglePen && (isNullOrUndefined(parent.toolbar) || (parent.toolbar && parent.toolbar.length > 0)
3636
- || !isNullOrUndefined(parent.toolbarTemplate))) {
3895
+ if (parent.togglePen && !parent.isMaskImage && (isNullOrUndefined(parent.toolbar) ||
3896
+ (parent.toolbar && parent.toolbar.length > 0) || !isNullOrUndefined(parent.toolbarTemplate))) {
3637
3897
  parent.okBtn();
3638
3898
  parent.freeHandDraw(true);
3639
3899
  }
@@ -3657,7 +3917,9 @@ var Selection = /** @class */ (function () {
3657
3917
  }
3658
3918
  }
3659
3919
  parent.isShapeDrawing = false;
3920
+ parent.notify('freehand-draw', { prop: 'resetSelPoints', onPropertyChange: false });
3660
3921
  }
3922
+ this.isMouseUp = false;
3661
3923
  };
3662
3924
  Selection.prototype.adjustActObjForLineArrow = function (obj) {
3663
3925
  var isAdjusted = false;
@@ -3816,7 +4078,8 @@ var Selection = /** @class */ (function () {
3816
4078
  parent.objColl.splice(index, 1);
3817
4079
  }
3818
4080
  }
3819
- else if (!isShape && activeObj.shape && (activeObj.activePoint.width !== 0 || activeObj.activePoint.height !== 0)) {
4081
+ else if (!isShape && activeObj.shape && (activeObj.activePoint.width !== 0 || activeObj.activePoint.height !== 0 ||
4082
+ (activeObj.shape === 'path' && activeObj.pointColl.length > 0))) {
3820
4083
  parent.activeObj = activeObj;
3821
4084
  var index = this.getCurrentIndex();
3822
4085
  if (!isCropSelection) {
@@ -4044,8 +4307,15 @@ var Selection = /** @class */ (function () {
4044
4307
  }
4045
4308
  else {
4046
4309
  if (((new Date().getTime()) - this.touchTime) < 400) {
4310
+ this.isTouchDblClick = true;
4311
+ var temp = parent.isShapeDrawing;
4047
4312
  parent.notify('shape', { prop: 'stopPathDrawing', onPropertyChange: false, value: { e: e, isApply: null } });
4313
+ this.isTouchDblClick = false;
4048
4314
  this.touchTime = 0;
4315
+ if (temp !== parent.isShapeDrawing && parent.activeObj.shape &&
4316
+ parent.activeObj.shape === 'path') {
4317
+ return;
4318
+ }
4049
4319
  }
4050
4320
  else {
4051
4321
  this.touchTime = new Date().getTime();
@@ -4105,6 +4375,7 @@ var Selection = /** @class */ (function () {
4105
4375
  case (e.ctrlKey && '+'):
4106
4376
  if ((parent.zoomSettings.zoomTrigger & ZoomTrigger.Commands) === ZoomTrigger.Commands) {
4107
4377
  this.zoomType = 'Commands';
4378
+ parent.isZoomBtnClick = true;
4108
4379
  parent.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
4109
4380
  value: { zoomFactor: .1, zoomPoint: null }, isResize: null });
4110
4381
  parent.notify('draw', { prop: 'redrawDownScale' });
@@ -4121,6 +4392,7 @@ var Selection = /** @class */ (function () {
4121
4392
  case (e.ctrlKey && '-'):
4122
4393
  if ((parent.zoomSettings.zoomTrigger & ZoomTrigger.Commands) === ZoomTrigger.Commands) {
4123
4394
  this.zoomType = 'Commands';
4395
+ parent.isZoomBtnClick = true;
4124
4396
  parent.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
4125
4397
  value: { zoomFactor: -.1, zoomPoint: null }, isResize: null });
4126
4398
  parent.notify('draw', { prop: 'redrawDownScale' });
@@ -4227,6 +4499,7 @@ var Selection = /** @class */ (function () {
4227
4499
  Selection.prototype.focusRatioBtn = function () {
4228
4500
  var id = this.parent.element.id;
4229
4501
  if (this.parent.isKBDNavigation) {
4502
+ // eslint-disable-next-line @typescript-eslint/tslint/config
4230
4503
  setTimeout(function () {
4231
4504
  if (document.getElementById(id + '_aspectratio')) {
4232
4505
  document.getElementById(id + '_aspectratio').focus();
@@ -4256,6 +4529,11 @@ var Selection = /** @class */ (function () {
4256
4529
  e.stopImmediatePropagation();
4257
4530
  };
4258
4531
  Selection.prototype.handleScroll = function (e) {
4532
+ this.mouseWheel++;
4533
+ if (this.mouseWheel === 2) {
4534
+ this.mouseWheel = 0;
4535
+ return;
4536
+ }
4259
4537
  var parent = this.parent;
4260
4538
  var x;
4261
4539
  var y;
@@ -4291,6 +4569,7 @@ var Selection = /** @class */ (function () {
4291
4569
  }
4292
4570
  }
4293
4571
  if (type !== '') {
4572
+ parent.isZoomBtnClick = true;
4294
4573
  parent.notify('draw', { prop: 'performPointZoom', onPropertyChange: false,
4295
4574
  value: { x: x, y: y, type: type, isResize: null } });
4296
4575
  parent.notify('draw', { prop: 'redrawDownScale' });
@@ -4545,7 +4824,7 @@ var Selection = /** @class */ (function () {
4545
4824
  }
4546
4825
  else {
4547
4826
  if (this.isTouch || parent.cursor === 'move' || parent.cursor === 'grab' || this.isShapeInserted) {
4548
- if (prevIndex === 0 || prevIndex < actObj.order) {
4827
+ if (prevIndex === 0 || (prevIndex < actObj.order && (actObj.shape !== 'redact' || parent.drawingShape === 'redact'))) {
4549
4828
  prevIndex = actObj.order;
4550
4829
  i = index;
4551
4830
  }
@@ -4575,7 +4854,7 @@ var Selection = /** @class */ (function () {
4575
4854
  else {
4576
4855
  if (this.isTouch || cursor === 'move' || cursor === 'grabbing' || this.isShapeInserted
4577
4856
  || parent.cursor === 'move' || parent.cursor === 'grabbing') {
4578
- if (prevIndex === 0 || prevIndex < actObj.order) {
4857
+ if (prevIndex === 0 || (prevIndex < actObj.order && (actObj.shape !== 'redact' || parent.drawingShape === 'redact'))) {
4579
4858
  prevIndex = actObj.order;
4580
4859
  i = index;
4581
4860
  }
@@ -4636,7 +4915,7 @@ var Selection = /** @class */ (function () {
4636
4915
  parent.notify('draw', { prop: 'setTempTextSettings', onPropertyChange: false, value: { tempTextSettings: tempTextSettings } });
4637
4916
  var shapeSettings = this.updatePrevShapeSettings();
4638
4917
  var shapeChangingArgs = { cancel: false, action: 'select', previousShapeSettings: shapeSettings,
4639
- currentShapeSettings: shapeSettings };
4918
+ currentShapeSettings: shapeSettings, allowShapeOverflow: this.allowOutofBound() };
4640
4919
  if (parent.activeObj.shape === 'line' || parent.activeObj.shape === 'arrow') {
4641
4920
  shapeChangingArgs.currentShapeSettings.width = parent.activeObj.activePoint.endX - parent.activeObj.activePoint.startX;
4642
4921
  shapeChangingArgs.currentShapeSettings.height = parent.activeObj.activePoint.endY - parent.activeObj.activePoint.startY;
@@ -4649,11 +4928,18 @@ var Selection = /** @class */ (function () {
4649
4928
  if (splitWords !== undefined && splitWords[0] === 'crop') {
4650
4929
  this.isCropSelection = true;
4651
4930
  }
4652
- if (!this.isCropSelection) {
4931
+ if (!this.isCropSelection && parent.activeObj.shape !== 'redact') {
4653
4932
  parent.trigger('shapeChanging', shapeChangingArgs);
4654
4933
  this.shapeEvent(shapeChangingArgs);
4934
+ parent.editCompleteArgs = shapeChangingArgs;
4655
4935
  }
4656
4936
  else {
4937
+ if (this.isMouseDown) {
4938
+ shapeChangingArgs.action = 'resize-start';
4939
+ }
4940
+ else if (this.isMouseUp) {
4941
+ shapeChangingArgs.action = 'resize-end';
4942
+ }
4657
4943
  var selectionChangingArgs = { action: shapeChangingArgs.action,
4658
4944
  previousSelectionSettings: { type: parent.getSelectionType(parent.activeObj.shape),
4659
4945
  startX: shapeChangingArgs.previousShapeSettings.startX,
@@ -4666,6 +4952,7 @@ var Selection = /** @class */ (function () {
4666
4952
  width: shapeChangingArgs.currentShapeSettings.width,
4667
4953
  height: shapeChangingArgs.currentShapeSettings.height } };
4668
4954
  parent.trigger('selectionChanging', selectionChangingArgs);
4955
+ parent.editCompleteArgs = selectionChangingArgs;
4669
4956
  shapeChangingArgs.currentShapeSettings.startX = selectionChangingArgs.currentSelectionSettings.startX;
4670
4957
  shapeChangingArgs.currentShapeSettings.startY = selectionChangingArgs.currentSelectionSettings.startY;
4671
4958
  shapeChangingArgs.currentShapeSettings.width = selectionChangingArgs.currentSelectionSettings.width;
@@ -4680,7 +4967,7 @@ var Selection = /** @class */ (function () {
4680
4967
  Selection.prototype.shapeEvent = function (shapeChangingArgs) {
4681
4968
  var parent = this.parent;
4682
4969
  parent.notify('shape', { prop: 'updateShapeChangeEventArgs', onPropertyChange: false,
4683
- value: { shapeSettings: shapeChangingArgs.currentShapeSettings } });
4970
+ value: { shapeSettings: shapeChangingArgs.currentShapeSettings, allowShapeOverflow: shapeChangingArgs.allowShapeOverflow } });
4684
4971
  if (parent.activeObj.activePoint) {
4685
4972
  var obj = { prevActObj: null };
4686
4973
  parent.notify('draw', { prop: 'getPrevActObj', onPropertyChange: false, value: { obj: obj } });
@@ -4695,18 +4982,15 @@ var Selection = /** @class */ (function () {
4695
4982
  parent.notify('draw', { prop: 'drawObject', onPropertyChange: false, value: { canvas: 'duplicate', obj: parent.activeObj, isCropRatio: null,
4696
4983
  points: null, isPreventDrag: true, saveContext: null, isPreventSelection: true } });
4697
4984
  if (!this.isShapeInserted) {
4698
- var activePoint = parent.activeObj.activePoint;
4699
- var _a = parent.img, destLeft = _a.destLeft, destWidth = _a.destWidth, destTop = _a.destTop, destHeight = _a.destHeight;
4700
- this.isPreventDragging =
4701
- activePoint.startX < destLeft ||
4702
- activePoint.endX > destLeft + destWidth ||
4703
- activePoint.startY < destTop ||
4704
- activePoint.endY > destTop + destHeight;
4985
+ this.isPreventDragging = this.isShapeDragOut();
4705
4986
  }
4706
4987
  }
4707
4988
  };
4708
4989
  Selection.prototype.upgradeImageQuality = function () {
4709
4990
  var parent = this.parent;
4991
+ if (!parent.activeObj.imageCanvas) {
4992
+ return;
4993
+ }
4710
4994
  var activeObj = extend({}, parent.activeObj, null, true);
4711
4995
  var ctx = parent.activeObj.imageCanvas.getContext('2d');
4712
4996
  var dimObj = { width: 0, height: 0 };
@@ -4766,6 +5050,17 @@ var Selection = /** @class */ (function () {
4766
5050
  for (var i = 0, len = parent.objColl.length; i < len; i++) {
4767
5051
  if (JSON.stringify(obj) === JSON.stringify(parent.objColl[i])) {
4768
5052
  parent.objColl.splice(i, 1);
5053
+ if (obj.shape && parent.textArea.style.display === 'none') {
5054
+ var actObj = extend({}, obj, {}, true);
5055
+ parent.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
5056
+ this.lowerContext.clearRect(0, 0, parent.lowerCanvas.width, parent.lowerCanvas.height);
5057
+ parent.notify('draw', { prop: 'render-image', value: { isMouseWheel: null } });
5058
+ if (parent.rotateFlipColl.length > 0 && (parent.panPoint.totalPannedClientPoint.x !== 0 ||
5059
+ parent.panPoint.totalPannedClientPoint.y !== 0)) {
5060
+ parent.notify('draw', { prop: 'redrawImgWithObj', onPropertyChange: false });
5061
+ }
5062
+ obj = parent.activeObj = actObj;
5063
+ }
4769
5064
  break;
4770
5065
  }
4771
5066
  }
@@ -4793,6 +5088,11 @@ var Selection = /** @class */ (function () {
4793
5088
  points: null, isPreventDrag: true, saveContext: null, isPreventSelection: null } });
4794
5089
  }
4795
5090
  else {
5091
+ if (parent.activeObj.shape === 'redact') {
5092
+ this.lowerContext.clearRect(0, 0, parent.lowerCanvas.width, parent.lowerCanvas.height);
5093
+ parent.notify('draw', { prop: 'redrawImgWithObj', onPropertyChange: false });
5094
+ parent.notify('draw', { prop: 'clearOuterCanvas', onPropertyChange: false, value: { context: this.lowerContext } });
5095
+ }
4796
5096
  parent.notify('draw', { prop: 'drawObject', onPropertyChange: false, value: { canvas: 'duplicate', obj: null, isCropRatio: null,
4797
5097
  points: null, isPreventDrag: true, saveContext: null, isPreventSelection: null } });
4798
5098
  }
@@ -4833,8 +5133,9 @@ var Selection = /** @class */ (function () {
4833
5133
  else if (actObj.shape === 'line' || actObj.shape === 'arrow') {
4834
5134
  var smallPoint = { x: startX < endX ? startX : endX, y: startY < endY ? startY : endY };
4835
5135
  var largePoint = { x: startX > endX ? startX : endX, y: startY > endY ? startY : endY };
4836
- if (x >= (Math.floor(smallPoint.x) - 5) && x <= (Math.ceil(largePoint.x) + 5) &&
4837
- y >= (Math.floor(smallPoint.y) - 5) && y <= (Math.ceil(largePoint.y) + 5)) {
5136
+ if ((x >= (Math.floor(smallPoint.x) - 5) && x <= (Math.ceil(largePoint.x) + 5) &&
5137
+ y >= (Math.floor(smallPoint.y) - 5) && y <= (Math.ceil(largePoint.y) + 5)) ||
5138
+ parent.activeObj.preventShapeDragOut) {
4838
5139
  isInside = true;
4839
5140
  }
4840
5141
  }
@@ -4866,7 +5167,11 @@ var Selection = /** @class */ (function () {
4866
5167
  parent.notify('shape', { prop: 'updImgRatioForActObj', onPropertyChange: false });
4867
5168
  if (parent.activeObj.horTopLine !== undefined && parent.activeObj.horTopLine.startX !== 0 && parent.activeObj.horTopLine.endX
4868
5169
  !== 0 && !parent.currObjType.isCustomCrop && parent.currObjType.shape !== '') {
4869
- parent.objColl.push(extend({}, parent.activeObj, {}, true));
5170
+ if (parent.objColl.length > 0 &&
5171
+ JSON.stringify(parent.objColl[parent.objColl.length - 1].activePoint) !==
5172
+ JSON.stringify(parent.activeObj.activePoint)) {
5173
+ parent.objColl.push(extend({}, parent.activeObj, {}, true));
5174
+ }
4870
5175
  }
4871
5176
  var shapeColl = ['rectangle', 'ellipse', 'line', 'arrow', 'path', 'text', 'image'];
4872
5177
  if (shapeColl.indexOf(parent.activeObj.shape) > -1) {
@@ -4874,16 +5179,6 @@ var Selection = /** @class */ (function () {
4874
5179
  this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
4875
5180
  'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' +
4876
5181
  'invert(0%)';
4877
- for (var i = 0; i < parent.objColl.length; i++) {
4878
- var obj = { isInside: false };
4879
- parent.notify('crop', { prop: 'isObjInImage', onPropertyChange: false,
4880
- value: { obj: parent.objColl[i], object: obj } });
4881
- if (obj['isInside']) {
4882
- parent.notify('shape', { prop: 'apply', onPropertyChange: false,
4883
- value: { shape: parent.objColl[i].shape, obj: parent.objColl[i], canvas: null } });
4884
- parent.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
4885
- }
4886
- }
4887
5182
  parent.notify('shape', { prop: 'drawAnnotations', onPropertyChange: false,
4888
5183
  value: { ctx: this.lowerContext, shape: 'zoom', pen: 'zoom', isPreventApply: null } });
4889
5184
  this.lowerContext.filter = tempFilter;
@@ -4921,6 +5216,20 @@ var Selection = /** @class */ (function () {
4921
5216
  && parent.textArea.style.color.split('(')[1].split(',')[3] ?
4922
5217
  this.rgbToHex(parseFloat(parent.textArea.style.color.split('(')[1].split(',')[0]), parseFloat(parent.textArea.style.color.split('(')[1].split(',')[1]), parseFloat(parent.textArea.style.color.split('(')[1].split(',')[2]), parseFloat(parent.textArea.style.color.split('(')[1].split(',')[3])) :
4923
5218
  parent.textArea.style.color;
5219
+ parent.activeObj.strokeSettings.fillColor = parent.textArea.style.backgroundColor !== '' &&
5220
+ parent.textArea.style.backgroundColor.split('(')[1] && parent.textArea.style.backgroundColor.split('(')[1].split(',')[0] &&
5221
+ parent.textArea.style.backgroundColor.split('(')[1].split(',')[1] && parent.textArea.style.backgroundColor.split('(')[1].split(',')[2]
5222
+ && parent.textArea.style.backgroundColor.split('(')[1].split(',')[3] ?
5223
+ this.rgbToHex(parseFloat(parent.textArea.style.backgroundColor.split('(')[1].split(',')[0]), parseFloat(parent.textArea.style.backgroundColor.split('(')[1].split(',')[1]), parseFloat(parent.textArea.style.backgroundColor.split('(')[1].split(',')[2]), parseFloat(parent.textArea.style.backgroundColor.split('(')[1].split(',')[3])) :
5224
+ parent.textArea.style.backgroundColor;
5225
+ parent.activeObj.strokeSettings.outlineColor = parent.textArea.style.textShadow !== '' &&
5226
+ parent.textArea.style.textShadow.split('(')[1] && parent.textArea.style.textShadow.split('(')[1].split(',')[0] &&
5227
+ parent.textArea.style.textShadow.split('(')[1].split(',')[1] && parent.textArea.style.textShadow.split('(')[1].split(',')[2]
5228
+ && parent.textArea.style.textShadow.split('(')[1].split(',')[3] ?
5229
+ this.rgbToHex(parseFloat(parent.textArea.style.textShadow.split('(')[1].split(',')[0]), parseFloat(parent.textArea.style.textShadow.split('(')[1].split(',')[1]), parseFloat(parent.textArea.style.textShadow.split('(')[1].split(',')[2]), parseFloat(parent.textArea.style.textShadow.split('(')[1].split(',')[3])) :
5230
+ (parent.textArea.style.textShadow.match(/^(\s*[\w#]+)\s/) ?
5231
+ parent.textArea.style.textShadow.match(/^(\s*[\w#]+)\s/)[1].trim() :
5232
+ parent.textArea.style.textShadow);
4924
5233
  if (parent.textArea.style.fontWeight === 'bold') {
4925
5234
  parent.activeObj.textSettings.bold = true;
4926
5235
  }
@@ -4944,7 +5253,13 @@ var Selection = /** @class */ (function () {
4944
5253
  var hexG = this.padLeft(g.toString(16), 2, '0');
4945
5254
  var hexB = this.padLeft(b.toString(16), 2, '0');
4946
5255
  var hexA = this.padLeft(Math.round(a * 255).toString(16), 2, '0');
4947
- var hex = "#" + hexR + hexG + hexB + hexA;
5256
+ var hex;
5257
+ if (isNaN(Number(hexA))) {
5258
+ hex = "#" + hexR + hexG + hexB;
5259
+ }
5260
+ else {
5261
+ hex = "#" + hexR + hexG + hexB + hexA;
5262
+ }
4948
5263
  return hex;
4949
5264
  };
4950
5265
  Selection.prototype.padLeft = function (value, length, padChar) {
@@ -5026,6 +5341,7 @@ var Selection = /** @class */ (function () {
5026
5341
  parent.notify('shape', { prop: 'setKeyHistory', onPropertyChange: false, value: { keyHistory: '' } });
5027
5342
  parent.clearSelection();
5028
5343
  parent.trigger('shapeChanging', shapeChangingArgs);
5344
+ parent.editCompleteArgs = shapeChangingArgs;
5029
5345
  parent.notify('toolbar', { prop: 'refresh-main-toolbar', onPropertyChange: false });
5030
5346
  parent.notify('draw', { prop: 'render-image', value: { isMouseWheel: null } });
5031
5347
  if (!isNullOrUndefined(prevObj.objColl[prevObj.objColl.length - 1].currIndex)) {
@@ -5232,6 +5548,12 @@ var Selection = /** @class */ (function () {
5232
5548
  }
5233
5549
  return isValue;
5234
5550
  };
5551
+ Selection.prototype.allowOutofBound = function () {
5552
+ var shapes = ['ellipse', 'rectangle', 'text', 'image', 'redact'];
5553
+ // eslint-disable-next-line max-len
5554
+ var allowOutofBound = (shapes.indexOf(this.parent.activeObj.shape) !== -1 && this.parent.activeObj.rotatedAngle === 0) ? false : true;
5555
+ return allowOutofBound;
5556
+ };
5235
5557
  return Selection;
5236
5558
  }());
5237
5559
  export { Selection };