@syncfusion/ej2-image-editor 22.1.38 → 22.2.5

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.
@@ -10,6 +10,7 @@ var Crop = /** @__PURE__ @class */ (function () {
10
10
  this.cropDestPoints = { startX: 0, startY: 0, width: 0, height: 0 }; // To redraw old image when navigate to crop tab
11
11
  this.tempFlipPanPoint = { x: 0, y: 0 };
12
12
  this.isPreventScaling = false;
13
+ this.isInitCrop = false;
13
14
  this.parent = parent;
14
15
  this.addEventListener();
15
16
  }
@@ -24,7 +25,7 @@ var Crop = /** @__PURE__ @class */ (function () {
24
25
  this.parent.on('destroyed', this.destroy, this);
25
26
  };
26
27
  Crop.prototype.removeEventListener = function () {
27
- this.parent.off('crop', this.crop);
28
+ this.parent.off('crop', this.cropping);
28
29
  this.parent.off('destroyed', this.destroy);
29
30
  };
30
31
  Crop.prototype.cropping = function (args) {
@@ -98,6 +99,7 @@ var Crop = /** @__PURE__ @class */ (function () {
98
99
  this.cropDestPoints = { startX: 0, startY: 0, width: 0, height: 0 };
99
100
  this.tempFlipPanPoint = { x: 0, y: 0 };
100
101
  this.isPreventScaling = false;
102
+ this.isInitCrop = false;
101
103
  };
102
104
  Crop.prototype.cropImg = function (isRotateCrop) {
103
105
  var parent = this.parent;
@@ -151,7 +153,7 @@ var Crop = /** @__PURE__ @class */ (function () {
151
153
  parent.img.destWidth = maxDimension.width;
152
154
  parent.img.destHeight = maxDimension.height;
153
155
  var temp = this.lowerContext.filter;
154
- parent.notify('finetune', { prop: 'updateBrightFilter', onPropertyChange: false });
156
+ parent.notify('filter', { prop: 'updateBrightFilter', onPropertyChange: false });
155
157
  this.lowerContext.drawImage(parent.baseImg, parent.img.srcLeft, parent.img.srcTop, parent.img.srcWidth, parent.img.srcHeight, parent.img.destLeft, parent.img.destTop, parent.img.destWidth, parent.img.destHeight);
156
158
  this.lowerContext.filter = 'none';
157
159
  var activeObj = extend({}, parent.activeObj, {}, true);
@@ -203,6 +205,8 @@ var Crop = /** @__PURE__ @class */ (function () {
203
205
  parent.notify('transform', { prop: 'setPreventSelect', onPropertyChange: false, value: { bool: true } });
204
206
  var coll = extend([], parent.rotateFlipColl, [], true);
205
207
  this.panToSelRangle(true);
208
+ this.resetZoom();
209
+ var afterCropActions = extend([], parent.afterCropActions, [], true);
206
210
  this.revertTransform('initial', coll);
207
211
  activeObj = extend({}, parent.objColl[parent.objColl.length - 1], {}, true);
208
212
  this.upperContext.clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
@@ -211,6 +215,7 @@ var Crop = /** @__PURE__ @class */ (function () {
211
215
  parent.transform.degree = 0;
212
216
  this.cropImg(true);
213
217
  this.revertTransform('reverse', coll);
218
+ parent.afterCropActions = afterCropActions;
214
219
  parent.currSelectionPoint = tempCurrSelObj;
215
220
  parent.notify('transform', { prop: 'setPreventSelect', onPropertyChange: false, value: { bool: preventSelObj['bool'] } });
216
221
  parent.notify('draw', { prop: 'clearOuterCanvas', onPropertyChange: false, value: { context: this.lowerContext } });
@@ -261,18 +266,8 @@ var Crop = /** @__PURE__ @class */ (function () {
261
266
  }
262
267
  }
263
268
  };
264
- Crop.prototype.flipCrop = function () {
269
+ Crop.prototype.resetZoom = function () {
265
270
  var parent = this.parent;
266
- parent.notify('transform', { prop: 'setReverseFlip', onPropertyChange: false, value: { isReverseFlip: true } });
267
- parent.panPoint.totalPannedPoint.x += this.tempFlipPanPoint.x;
268
- parent.panPoint.totalPannedPoint.y += this.tempFlipPanPoint.y;
269
- var tempCurrFlipState = parent.transform.currFlipState;
270
- var obj = { flipColl: null };
271
- parent.notify('transform', { prop: 'getFlipColl', onPropertyChange: false, value: { obj: obj } });
272
- var tempFlipColl = obj['flipColl'];
273
- parent.notify('transform', { prop: 'setFlipColl', onPropertyChange: false, value: { flipColl: [] } });
274
- parent.notify('shape', { prop: 'updImgRatioForActObj', onPropertyChange: false });
275
- parent.objColl.push(parent.activeObj);
276
271
  if (parent.transform.zoomFactor > 0) {
277
272
  var zoomFactor = parent.transform.zoomFactor;
278
273
  var isUndoRedo = parent.isUndoRedo;
@@ -284,11 +279,25 @@ var Crop = /** @__PURE__ @class */ (function () {
284
279
  parent.isUndoRedo = isUndoRedo;
285
280
  parent.notify('draw', { prop: 'resetPanPoints', onPropertyChange: false });
286
281
  }
282
+ };
283
+ Crop.prototype.flipCrop = function () {
284
+ var parent = this.parent;
285
+ parent.notify('transform', { prop: 'setReverseFlip', onPropertyChange: false, value: { isReverseFlip: true } });
286
+ parent.panPoint.totalPannedPoint.x += this.tempFlipPanPoint.x;
287
+ parent.panPoint.totalPannedPoint.y += this.tempFlipPanPoint.y;
288
+ var tempCurrFlipState = parent.transform.currFlipState;
289
+ var obj = { flipColl: null };
290
+ parent.notify('transform', { prop: 'getFlipColl', onPropertyChange: false, value: { obj: obj } });
291
+ var tempFlipColl = obj['flipColl'];
292
+ parent.notify('transform', { prop: 'setFlipColl', onPropertyChange: false, value: { flipColl: [] } });
293
+ parent.notify('shape', { prop: 'updImgRatioForActObj', onPropertyChange: false });
294
+ parent.objColl.push(parent.activeObj);
295
+ this.resetZoom();
287
296
  parent.currSelectionPoint = extend({}, parent.objColl[parent.objColl.length - 1], {}, true);
288
297
  this.lowerContext.clearRect(0, 0, parent.lowerCanvas.width, parent.lowerCanvas.height);
289
298
  this.upperContext.clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
290
299
  var temp = this.lowerContext.filter;
291
- parent.notify('finetune', { prop: 'updateBrightFilter', onPropertyChange: false });
300
+ parent.notify('filter', { prop: 'updateBrightFilter', onPropertyChange: false });
292
301
  this.lowerContext.drawImage(parent.baseImg, parent.img.srcLeft, parent.img.srcTop, parent.img.srcWidth, parent.img.srcHeight, parent.img.destLeft, parent.img.destTop, parent.img.destWidth, parent.img.destHeight);
293
302
  for (var i = 0, len = parent.objColl.length; i < len; i++) {
294
303
  parent.objColl[i].shapeFlip = '';
@@ -309,7 +318,7 @@ var Crop = /** @__PURE__ @class */ (function () {
309
318
  parent.notify('draw', { prop: 'setDestPoints', onPropertyChange: false });
310
319
  parent.notify('draw', { prop: 'currTransState', onPropertyChange: false,
311
320
  value: { type: 'initial', isPreventDestination: null, context: null, isPreventCircleCrop: null } });
312
- parent.notify('finetune', { prop: 'updateBrightFilter', onPropertyChange: false });
321
+ parent.notify('filter', { prop: 'updateBrightFilter', onPropertyChange: false });
313
322
  this.lowerContext.drawImage(parent.baseImg, parent.img.srcLeft, parent.img.srcTop, parent.img.srcWidth, parent.img.srcHeight, parent.img.destLeft, parent.img.destTop, parent.img.destWidth, parent.img.destHeight);
314
323
  this.lowerContext.filter = temp;
315
324
  parent.notify('draw', { prop: 'setRotateZoom', onPropertyChange: false, value: { isRotateZoom: false } });
@@ -431,6 +440,7 @@ var Crop = /** @__PURE__ @class */ (function () {
431
440
  Crop.prototype.setCurrSelPoints = function (isSetDimension) {
432
441
  var parent = this.parent;
433
442
  var destPoint = this.cropDestPoints;
443
+ var filter = this.lowerContext.filter;
434
444
  parent.img.srcLeft = 0;
435
445
  parent.img.srcTop = 0;
436
446
  parent.img.srcWidth = parent.baseImg.width;
@@ -458,6 +468,7 @@ var Crop = /** @__PURE__ @class */ (function () {
458
468
  }
459
469
  parent.notify('filter', { prop: 'updateBrightFilter', onPropertyChange: false });
460
470
  this.lowerContext.drawImage(parent.baseImg, parent.img.srcLeft, parent.img.srcTop, parent.img.srcWidth, parent.img.srcHeight, parent.img.destLeft, parent.img.destTop, parent.img.destWidth, parent.img.destHeight);
471
+ this.lowerContext.filter = filter;
461
472
  parent.notify('draw', { prop: 'currTransState', onPropertyChange: false,
462
473
  value: { type: 'reverse', isPreventDestination: null, context: null, isPreventCircleCrop: true } });
463
474
  var cropObjColl = extend([], parent.objColl, null, true);
@@ -523,6 +534,16 @@ var Crop = /** @__PURE__ @class */ (function () {
523
534
  parent.notify('draw', { prop: 'drawObject', onPropertyChange: false, value: { canvas: 'duplicate' } });
524
535
  parent.notify('transform', { prop: 'setTempPanMove', onPropertyChange: false,
525
536
  value: { point: null } });
537
+ if (!this.isInitCrop && parent.transform.degree === 0 && parent.cropObj.currFlipState !== '' &&
538
+ parent.cropObj.cropZoom !== 0) {
539
+ this.isInitCrop = true;
540
+ parent.notify('draw', { prop: 'performCancel', value: { isContextualToolbar: null } });
541
+ parent.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: { type: 'croptransform',
542
+ isApplyBtn: false, isCropping: null, isZooming: null, cType: null } });
543
+ }
544
+ else {
545
+ this.isInitCrop = false;
546
+ }
526
547
  }
527
548
  else {
528
549
  var temp = this.lowerContext.filter;
@@ -536,22 +557,18 @@ var Crop = /** @__PURE__ @class */ (function () {
536
557
  };
537
558
  Crop.prototype.panToSelRangle = function (isReverse) {
538
559
  var parent = this.parent;
539
- var panX = parent.transform.degree === 0 ?
540
- isReverse ? -parent.cropObj.totalPannedPoint.x : parent.cropObj.totalPannedPoint.x :
541
- isReverse ? -parent.cropObj.totalPannedClientPoint.x : parent.cropObj.totalPannedClientPoint.x;
542
- var panY = parent.transform.degree === 0 ?
543
- isReverse ? -parent.cropObj.totalPannedPoint.y : parent.cropObj.totalPannedPoint.y :
544
- isReverse ? -parent.cropObj.totalPannedClientPoint.y : parent.cropObj.totalPannedClientPoint.y;
545
- if (parent.transform.degree === 0) {
546
- parent.img.destLeft += panX;
547
- parent.img.destTop += panY;
548
- parent.notify('transform', { prop: 'drawPannImage', value: { point: { x: panX, y: panY } } });
549
- }
550
- else {
560
+ var obj = extend({}, parent.currSelectionPoint, null, true);
561
+ parent.currSelectionPoint = null;
562
+ var panX = parent.transform.degree !== 0 ?
563
+ isReverse ? -parent.cropObj.totalPannedClientPoint.x : parent.cropObj.totalPannedClientPoint.x : 0;
564
+ var panY = parent.transform.degree !== 0 ?
565
+ isReverse ? -parent.cropObj.totalPannedClientPoint.y : parent.cropObj.totalPannedClientPoint.y : 0;
566
+ if (parent.transform.degree !== 0) {
551
567
  parent.panPoint.currentPannedPoint = { x: panX, y: panY };
552
568
  parent.notify('transform', { prop: 'drawPannedImage', value: { xDiff: panX, yDiff: panY } });
553
569
  parent.panPoint.currentPannedPoint = { x: 0, y: 0 };
554
570
  }
571
+ parent.currSelectionPoint = obj;
555
572
  };
556
573
  Crop.prototype.cropCircle = function (context, isSave, isFlip) {
557
574
  var parent = this.parent;
@@ -826,8 +843,6 @@ var Crop = /** @__PURE__ @class */ (function () {
826
843
 
827
844
  var Draw = /** @__PURE__ @class */ (function () {
828
845
  function Draw(parent) {
829
- this.cancelObjColl = [];
830
- this.cancelPointColl = [];
831
846
  this.isInitialLoading = false; // Specifies whether image is loaded for the first time or not (for applying initial filter)
832
847
  this.fileName = '';
833
848
  this.isErrorImage = false;
@@ -1047,7 +1062,6 @@ var Draw = /** @__PURE__ @class */ (function () {
1047
1062
  };
1048
1063
  Draw.prototype.reset = function () {
1049
1064
  this.isInitialLoading = this.isErrorImage = this.isNewPath = false;
1050
- this.cancelObjColl = this.cancelPointColl = [];
1051
1065
  this.isShapeTextInserted = false;
1052
1066
  this.initZoomValue = null;
1053
1067
  this.tempFilter = '';
@@ -1932,12 +1946,30 @@ var Draw = /** @__PURE__ @class */ (function () {
1932
1946
  canvasDraw.stroke();
1933
1947
  canvasDraw.lineWidth = tempLineWidth;
1934
1948
  };
1949
+ Draw.prototype.manipulateSaveCtx = function (canvasDraw, x, y) {
1950
+ if (canvasDraw !== this.lowerContext && canvasDraw !== this.upperContext) {
1951
+ var obj = { width: 0, height: 0 };
1952
+ this.parent.notify('crop', { prop: 'calcRatio', onPropertyChange: false,
1953
+ value: { obj: obj, dimension: { width: canvasDraw.canvas.width, height: canvasDraw.canvas.height } } });
1954
+ var ratio = obj;
1955
+ if (x) {
1956
+ x *= (ratio.width);
1957
+ }
1958
+ if (y) {
1959
+ y *= (ratio.height);
1960
+ }
1961
+ }
1962
+ return { x: x, y: y };
1963
+ };
1935
1964
  Draw.prototype.arrow = function (canvasDraw, start) {
1936
1965
  var parent = this.parent;
1937
1966
  var actPoint = parent.activeObj.activePoint;
1938
1967
  canvasDraw.lineWidth = (parent.activeObj.strokeSettings.strokeWidth);
1939
- var x = this.arrowDimension['arrow']['width'] + parent.activeObj.strokeSettings.strokeWidth;
1940
- var y = this.arrowDimension['arrow']['height'] + parent.activeObj.strokeSettings.strokeWidth;
1968
+ var x = this.arrowDimension['arrow']['width'];
1969
+ var y = this.arrowDimension['arrow']['height'];
1970
+ var point = this.manipulateSaveCtx(canvasDraw, x, y);
1971
+ x = point.x + parent.activeObj.strokeSettings.strokeWidth;
1972
+ y = point.y + parent.activeObj.strokeSettings.strokeWidth;
1941
1973
  this.dx = actPoint.endX - actPoint.startX;
1942
1974
  this.dy = actPoint.endY - actPoint.startY;
1943
1975
  canvasDraw.fillStyle = parent.activeObj.strokeSettings.strokeColor;
@@ -1972,8 +2004,11 @@ var Draw = /** @__PURE__ @class */ (function () {
1972
2004
  Draw.prototype.arrowSolid = function (canvasDraw, start) {
1973
2005
  var parent = this.parent;
1974
2006
  var actPoint = parent.activeObj.activePoint;
1975
- var x = this.arrowDimension['arrowSolid']['width'] + parent.activeObj.strokeSettings.strokeWidth;
1976
- var y = this.arrowDimension['arrowSolid']['height'] + parent.activeObj.strokeSettings.strokeWidth;
2007
+ var x = this.arrowDimension['arrowSolid']['width'];
2008
+ var y = this.arrowDimension['arrowSolid']['height'];
2009
+ var point = this.manipulateSaveCtx(canvasDraw, x, y);
2010
+ x = point.x + parent.activeObj.strokeSettings.strokeWidth;
2011
+ y = point.y + parent.activeObj.strokeSettings.strokeWidth;
1977
2012
  this.dx = actPoint.endX - actPoint.startX;
1978
2013
  this.dy = actPoint.endY - actPoint.startY;
1979
2014
  var angle = Math.atan2(this.dy, this.dx);
@@ -2023,8 +2058,11 @@ var Draw = /** @__PURE__ @class */ (function () {
2023
2058
  canvasDraw.lineWidth = (parent.activeObj.strokeSettings.strokeWidth);
2024
2059
  canvasDraw.beginPath();
2025
2060
  canvasDraw.fillStyle = parent.activeObj.strokeSettings.strokeColor;
2026
- var x = this.arrowDimension['square']['width'] + parent.activeObj.strokeSettings.strokeWidth;
2027
- var y = this.arrowDimension['square']['height'] + parent.activeObj.strokeSettings.strokeWidth;
2061
+ var x = this.arrowDimension['square']['width'];
2062
+ var y = this.arrowDimension['square']['height'];
2063
+ var point = this.manipulateSaveCtx(canvasDraw, x, y);
2064
+ x = point.x + parent.activeObj.strokeSettings.strokeWidth;
2065
+ y = point.y + parent.activeObj.strokeSettings.strokeWidth;
2028
2066
  this.dx = actPoint.endX - actPoint.startX;
2029
2067
  this.dy = actPoint.endY - actPoint.startY;
2030
2068
  var angle = Math.atan2(this.dy, this.dx);
@@ -2079,8 +2117,11 @@ var Draw = /** @__PURE__ @class */ (function () {
2079
2117
  Draw.prototype.arrowSquareEnd = function (canvasDraw) {
2080
2118
  var parent = this.parent;
2081
2119
  var actPoint = parent.activeObj.activePoint;
2082
- var x = this.arrowDimension['square']['width'] + parent.activeObj.strokeSettings.strokeWidth;
2083
- var y = this.arrowDimension['square']['height'] + parent.activeObj.strokeSettings.strokeWidth;
2120
+ var x = this.arrowDimension['square']['width'];
2121
+ var y = this.arrowDimension['square']['height'];
2122
+ var point = this.manipulateSaveCtx(canvasDraw, x, y);
2123
+ x = point.x + parent.activeObj.strokeSettings.strokeWidth;
2124
+ y = point.y + parent.activeObj.strokeSettings.strokeWidth;
2084
2125
  this.dx = actPoint.endX - actPoint.startX;
2085
2126
  this.dy = actPoint.endY - actPoint.startY;
2086
2127
  var angle = Math.atan2(this.dy, this.dx);
@@ -2142,7 +2183,9 @@ var Draw = /** @__PURE__ @class */ (function () {
2142
2183
  if ((start && parent.activeObj.triangleDirection === 'left') ||
2143
2184
  (!start && parent.activeObj.triangleDirection === 'right')) {
2144
2185
  canvasDraw.lineWidth = (parent.activeObj.strokeSettings.strokeWidth);
2145
- var circleRadius = this.arrowDimension['circle']['width'] + parent.activeObj.strokeSettings.strokeWidth;
2186
+ var circleRadius = this.arrowDimension['circle']['width'];
2187
+ var point = this.manipulateSaveCtx(canvasDraw, circleRadius, null);
2188
+ circleRadius = point.x + parent.activeObj.strokeSettings.strokeWidth;
2146
2189
  canvasDraw.beginPath();
2147
2190
  canvasDraw.arc(actPoint.endX, actPoint.endY, circleRadius, 0, 2 * Math.PI);
2148
2191
  canvasDraw.stroke();
@@ -2190,7 +2233,9 @@ var Draw = /** @__PURE__ @class */ (function () {
2190
2233
  else if ((start && parent.activeObj.triangleDirection === 'right') ||
2191
2234
  (!start && parent.activeObj.triangleDirection === 'left')) {
2192
2235
  canvasDraw.lineWidth = (parent.activeObj.strokeSettings.strokeWidth);
2193
- var circleRadius = this.arrowDimension['circle']['width'] + parent.activeObj.strokeSettings.strokeWidth;
2236
+ var circleRadius = this.arrowDimension['circle']['width'];
2237
+ var point = this.manipulateSaveCtx(canvasDraw, circleRadius, null);
2238
+ circleRadius = point.x + parent.activeObj.strokeSettings.strokeWidth;
2194
2239
  canvasDraw.beginPath();
2195
2240
  canvasDraw.arc(actPoint.startX, actPoint.startY, circleRadius, 0, 2 * Math.PI);
2196
2241
  canvasDraw.stroke();
@@ -2248,7 +2293,9 @@ var Draw = /** @__PURE__ @class */ (function () {
2248
2293
  (!start && (parent.activeObj.end === 'circleSolid' && parent.activeObj.start === 'none'))) {
2249
2294
  this.shapeLine(canvasDraw, actPoint.startX, actPoint.startY, actPoint.endX, actPoint.endY);
2250
2295
  }
2251
- var circleRadius = this.arrowDimension['circle']['width'] + parent.activeObj.strokeSettings.strokeWidth;
2296
+ var circleRadius = this.arrowDimension['circle']['width'];
2297
+ var point = this.manipulateSaveCtx(canvasDraw, circleRadius, null);
2298
+ circleRadius = point.x + parent.activeObj.strokeSettings.strokeWidth;
2252
2299
  this.dx = actPoint.endX - actPoint.startX;
2253
2300
  this.dy = actPoint.endY - actPoint.startY;
2254
2301
  canvasDraw.save();
@@ -2269,7 +2316,9 @@ var Draw = /** @__PURE__ @class */ (function () {
2269
2316
  !start && (parent.activeObj.end === 'circleSolid' && parent.activeObj.start === 'none')) {
2270
2317
  this.shapeLine(canvasDraw, actPoint.startX, actPoint.startY, actPoint.endX, actPoint.endY);
2271
2318
  }
2272
- var circleRadius = this.arrowDimension['circle']['width'] + parent.activeObj.strokeSettings.strokeWidth;
2319
+ var circleRadius = this.arrowDimension['circle']['width'];
2320
+ var point = this.manipulateSaveCtx(canvasDraw, circleRadius, null);
2321
+ circleRadius = point.x + parent.activeObj.strokeSettings.strokeWidth;
2273
2322
  this.dx = actPoint.endX - actPoint.startX;
2274
2323
  this.dy = actPoint.endY - actPoint.startY;
2275
2324
  canvasDraw.save();
@@ -2295,8 +2344,11 @@ var Draw = /** @__PURE__ @class */ (function () {
2295
2344
  (parent.activeObj.end === 'bar' && (parent.activeObj.start !== 'circle' && parent.activeObj.start !== 'square'))))) {
2296
2345
  this.shapeLine(canvasDraw, actPoint.startX, actPoint.startY, actPoint.endX, actPoint.endY);
2297
2346
  }
2298
- var x = this.arrowDimension['bar']['width'] + parent.activeObj.strokeSettings.strokeWidth;
2299
- var y = this.arrowDimension['bar']['height'] + parent.activeObj.strokeSettings.strokeWidth;
2347
+ var x = this.arrowDimension['bar']['width'];
2348
+ var y = this.arrowDimension['bar']['height'];
2349
+ var point = this.manipulateSaveCtx(canvasDraw, x, y);
2350
+ x = point.x + parent.activeObj.strokeSettings.strokeWidth;
2351
+ y = point.y + parent.activeObj.strokeSettings.strokeWidth;
2300
2352
  this.dx = actPoint.endX - actPoint.startX;
2301
2353
  this.dy = actPoint.endY - actPoint.startY;
2302
2354
  var angle = Math.atan2(this.dy, this.dx);
@@ -2317,8 +2369,11 @@ var Draw = /** @__PURE__ @class */ (function () {
2317
2369
  (!start && (parent.activeObj.end === 'bar' && parent.activeObj.start === 'none'))) {
2318
2370
  this.shapeLine(canvasDraw, actPoint.startX, actPoint.startY, actPoint.endX, actPoint.endY);
2319
2371
  }
2320
- var x = this.arrowDimension['bar']['width'] + parent.activeObj.strokeSettings.strokeWidth;
2321
- var y = this.arrowDimension['bar']['height'] + parent.activeObj.strokeSettings.strokeWidth;
2372
+ var x = this.arrowDimension['bar']['width'];
2373
+ var y = this.arrowDimension['bar']['height'];
2374
+ var point = this.manipulateSaveCtx(canvasDraw, x, y);
2375
+ x = point.x + parent.activeObj.strokeSettings.strokeWidth;
2376
+ y = point.y + parent.activeObj.strokeSettings.strokeWidth;
2322
2377
  this.dx = actPoint.endX - actPoint.startX;
2323
2378
  this.dy = actPoint.endY - actPoint.startY;
2324
2379
  var angle = Math.atan2(this.dy, this.dx);
@@ -3178,8 +3233,6 @@ var Draw = /** @__PURE__ @class */ (function () {
3178
3233
  parent.isCropTab = isCropTab;
3179
3234
  this.resetPanPoints();
3180
3235
  }
3181
- this.cancelObjColl = extend([], parent.objColl, [], true);
3182
- this.cancelPointColl = extend([], parent.pointColl, [], true);
3183
3236
  parent.notify('freehand-draw', { prop: 'updateFHDColl', onPropertyChange: false });
3184
3237
  parent.isCropTab = true;
3185
3238
  parent.isCircleCrop = false;
@@ -3489,7 +3542,7 @@ var Draw = /** @__PURE__ @class */ (function () {
3489
3542
  parent.afterCropActions = obj.afterCropActions;
3490
3543
  }
3491
3544
  this.lowerContext.filter = obj.filter;
3492
- parent.notify('filter', { prop: 'setBrightnessAdjusted', onPropertyChange: false, value: { isBrightnessAdjusted: false } });
3545
+ parent.notify('filter', { prop: 'setBrightnessAdjusted', onPropertyChange: false, value: { isBrightnessAdjusted: obj.isBrightAdjust } });
3493
3546
  var isCircleCrop = parent.isCircleCrop;
3494
3547
  var currSelectionPoint;
3495
3548
  if (isNullOrUndefined(parent.currSelectionPoint)) {
@@ -3585,6 +3638,7 @@ var Draw = /** @__PURE__ @class */ (function () {
3585
3638
  this.setTransformColl(this.lowerContext, 'initial');
3586
3639
  }
3587
3640
  parent.notify('transform', { prop: 'setDestPointsForFlipState', onPropertyChange: false });
3641
+ parent.notify('filter', { prop: 'updateBrightFilter', onPropertyChange: false });
3588
3642
  this.lowerContext.drawImage(parent.baseImg, parent.img.srcLeft, parent.img.srcTop, parent.img.srcWidth, parent.img.srcHeight, parent.img.destLeft, parent.img.destTop, parent.img.destWidth, parent.img.destHeight);
3589
3643
  if (isObj) {
3590
3644
  this.updateCurrTransState('reverse');
@@ -3912,7 +3966,7 @@ var Draw = /** @__PURE__ @class */ (function () {
3912
3966
  object['isInitialLoaded'] = this.isInitialLoading;
3913
3967
  };
3914
3968
  Draw.prototype.getFileExtensionFromURL = function (url) {
3915
- var lastDotIndex = url.lastIndexOf(".");
3969
+ var lastDotIndex = url.lastIndexOf('.');
3916
3970
  if (lastDotIndex !== -1) {
3917
3971
  return url.slice(lastDotIndex + 1).toLowerCase();
3918
3972
  }
@@ -4292,7 +4346,6 @@ var Export = /** @__PURE__ @class */ (function () {
4292
4346
  id: parent.element.id + '_tempCanvas', attrs: { name: 'canvasImage' }
4293
4347
  });
4294
4348
  var tempContext = tempCanvas.getContext('2d');
4295
- tempContext.filter = this.lowerContext.filter;
4296
4349
  tempCanvas.width = width;
4297
4350
  tempCanvas.height = height;
4298
4351
  var dimObj = { width: 0, height: 0 };
@@ -4301,9 +4354,9 @@ var Export = /** @__PURE__ @class */ (function () {
4301
4354
  var maxDimension = dimObj;
4302
4355
  tempCanvas.style.maxWidth = maxDimension.width + 'px';
4303
4356
  tempCanvas.style.maxHeight = maxDimension.height + 'px';
4304
- tempContext.filter = this.lowerContext.filter;
4305
4357
  var temp = this.lowerContext.filter;
4306
4358
  parent.notify('filter', { prop: 'updateBrightFilter', onPropertyChange: false });
4359
+ tempContext.filter = this.lowerContext.filter;
4307
4360
  tempContext.drawImage(parent.baseImg, parent.img.srcLeft, parent.img.srcTop, parent.img.srcWidth, parent.img.srcHeight, 0, 0, width, height);
4308
4361
  this.lowerContext.filter = temp;
4309
4362
  if (parent.transform.degree !== 0 || parent.transform.currFlipState !== '') {
@@ -4334,6 +4387,14 @@ var Export = /** @__PURE__ @class */ (function () {
4334
4387
  if (parent.objColl[i].shape === 'text') {
4335
4388
  parent.objColl[i].textSettings.fontSize *= ((ratio.width + ratio.height) / 2);
4336
4389
  }
4390
+ else if (parent.objColl[i].shape === 'path') {
4391
+ for (var l = 0; l < parent.objColl[i].pointColl.length; l++) {
4392
+ parent.objColl[i].pointColl[l].x =
4393
+ (parent.objColl[i].pointColl[l].x - parent.img.destLeft) * ratio.width;
4394
+ parent.objColl[i].pointColl[l].y =
4395
+ (parent.objColl[i].pointColl[l].y - parent.img.destTop) * ratio.height;
4396
+ }
4397
+ }
4337
4398
  parent.notify('draw', { prop: 'drawObject', onPropertyChange: false, value: { canvas: 'saveContext', obj: parent.objColl[i], isCropRatio: null,
4338
4399
  points: null, isPreventDrag: true, saveContext: tempContext, isPreventSelection: null } });
4339
4400
  }
@@ -4921,8 +4982,6 @@ var Filter = /** @__PURE__ @class */ (function () {
4921
4982
  parent.notify('freehand-draw', { prop: 'getSelPointColl', onPropertyChange: false, value: { obj: selPointCollObj } });
4922
4983
  prevObj.selPointColl = extend([], selPointCollObj['selPointColl'], [], true);
4923
4984
  this.updateAdj(type, value);
4924
- var filter = this.lowerContext.filter;
4925
- this.lowerContext.filter = this.appliedFilter;
4926
4985
  parent.notify('undo-redo', {
4927
4986
  prop: 'updateUndoRedoColl',
4928
4987
  onPropertyChange: false,
@@ -4939,7 +4998,6 @@ var Filter = /** @__PURE__ @class */ (function () {
4939
4998
  isCircleCrop: null
4940
4999
  }
4941
5000
  });
4942
- this.lowerContext.filter = filter;
4943
5001
  };
4944
5002
  Filter.prototype.setFilter = function (type) {
4945
5003
  var parent = this.parent;
@@ -4957,15 +5015,12 @@ var Filter = /** @__PURE__ @class */ (function () {
4957
5015
  value: { obj: selPointCollObj } });
4958
5016
  prevObj.selPointColl = extend([], selPointCollObj['selPointColl'], [], true);
4959
5017
  this.updateAdj(type, null);
4960
- var filter = this.lowerContext.filter;
4961
- this.lowerContext.filter = this.appliedFilter;
4962
5018
  parent.notify('draw', { prop: 'setImageEdited', onPropertyChange: false });
4963
5019
  parent.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false,
4964
5020
  value: { operation: type, previousObj: prevObj, previousObjColl: prevObj.objColl,
4965
5021
  previousPointColl: prevObj.pointColl, previousSelPointColl: prevObj.selPointColl,
4966
5022
  previousCropObj: prevCropObj, previousText: null,
4967
5023
  currentText: null, previousFilter: prevFilter, isCircleCrop: null } });
4968
- this.lowerContext.filter = filter;
4969
5024
  };
4970
5025
  Filter.prototype.setAdjustment = function (type) {
4971
5026
  var splitWords = this.lowerContext.filter.split(' ');
@@ -5118,7 +5173,7 @@ var Filter = /** @__PURE__ @class */ (function () {
5118
5173
  totalPannedInternalPoint: { x: 0, y: 0 }, tempFlipPanPoint: { x: 0, y: 0 }, activeObj: {},
5119
5174
  rotateFlipColl: [], degree: 0, currFlipState: '', zoomFactor: 0, previousZoomValue: 0,
5120
5175
  destPoints: { startX: 0, startY: 0, width: 0, height: 0 },
5121
- srcPoints: { startX: 0, startY: 0, width: 0, height: 0 }, filter: '' };
5176
+ srcPoints: { startX: 0, startY: 0, width: 0, height: 0 }, filter: '', isBrightAdjust: this.isBrightnessAdjusted };
5122
5177
  obj.cropZoom = parent.transform.cropZoomFactor;
5123
5178
  obj.defaultZoom = parent.transform.defaultZoomFactor;
5124
5179
  obj.zoomFactor = parent.zoomSettings.zoomFactor;
@@ -5155,6 +5210,7 @@ var FreehandDrawing = /** @__PURE__ @class */ (function () {
5155
5210
  this.selPointColl = {};
5156
5211
  this.currFHDIdx = 0; // Specifies id for every freehand drawing - uses while deleting
5157
5212
  this.selPoints = [];
5213
+ this.dummyPoints = [];
5158
5214
  this.tempFHDStyles = { strokeColor: null, fillColor: null, strokeWidth: null };
5159
5215
  this.parent = parent;
5160
5216
  this.addEventListener();
@@ -5308,6 +5364,7 @@ var FreehandDrawing = /** @__PURE__ @class */ (function () {
5308
5364
  this.fhdObj = { lastWidth: 0, lastVelocity: 0, time: 0, pointX: 0, pointY: 0 };
5309
5365
  this.isFreehandDrawing = this.isFreehandPointMoved = false;
5310
5366
  this.selPoints = [];
5367
+ this.dummyPoints = [];
5311
5368
  this.freehandDownPoint = { x: 0, y: 0 };
5312
5369
  this.selPointColl = {};
5313
5370
  this.fhdHovIdx = null;
@@ -5356,7 +5413,12 @@ var FreehandDrawing = /** @__PURE__ @class */ (function () {
5356
5413
  if (parent.points[l + 1] && parent.points[l + 2] && parent.points[l + 2]) {
5357
5414
  controlPoint1 = (this.calcCurveCP(parent.points[l + 0], parent.points[l + 1], parent.points[l + 2])).controlPoint2;
5358
5415
  controlPoint2 = (this.calcCurveCP(parent.points[l + 1], parent.points[l + 2], parent.points[l + 3])).controlPoint1;
5359
- startPoint = parent.points[l + 1];
5416
+ if (l === 0) {
5417
+ startPoint = parent.points[l];
5418
+ }
5419
+ else {
5420
+ startPoint = parent.points[l + 1];
5421
+ }
5360
5422
  endPoint = parent.points[l + 2];
5361
5423
  this.startDraw(context, controlPoint1, controlPoint2, startPoint, endPoint, minStrokeWidth, maxStrokeWidth);
5362
5424
  }
@@ -5423,6 +5485,7 @@ var FreehandDrawing = /** @__PURE__ @class */ (function () {
5423
5485
  parent.pointColl[fhCnt].flipState = parent.transform.currFlipState;
5424
5486
  parent.pointColl[fhCnt].id = 'pen_' + (this.currFHDIdx + 1);
5425
5487
  parent.points = [];
5488
+ this.dummyPoints = [];
5426
5489
  this.selPointColl[fhCnt] = {};
5427
5490
  this.selPointColl[fhCnt].points = extend([], this.selPoints);
5428
5491
  this.selPoints = [];
@@ -5470,15 +5533,21 @@ var FreehandDrawing = /** @__PURE__ @class */ (function () {
5470
5533
  parent.points.push({ x: x, y: y, ratioX: (x - parent.img.destLeft) / parent.img.destWidth,
5471
5534
  ratioY: (y - parent.img.destTop) / parent.img.destHeight,
5472
5535
  time: this.fhdObj.time });
5473
- if (parent.points.length > 3) {
5474
- var p0 = parent.points[this.pointCounter];
5475
- var p1 = parent.points[this.pointCounter + 1];
5476
- var p2 = parent.points[this.pointCounter + 2];
5477
- var p3 = parent.points[this.pointCounter + 3];
5536
+ this.dummyPoints.push({ x: x, y: y, ratioX: (x - parent.img.destLeft) / parent.img.destWidth,
5537
+ ratioY: (y - parent.img.destTop) / parent.img.destHeight,
5538
+ time: this.fhdObj.time });
5539
+ if (this.dummyPoints.length > 2) {
5540
+ if (this.dummyPoints.length === 3) {
5541
+ this.dummyPoints.unshift(this.dummyPoints[0]);
5542
+ }
5543
+ var p0 = this.dummyPoints[0];
5544
+ var p1 = this.dummyPoints[1];
5545
+ var p2 = this.dummyPoints[2];
5546
+ var p3 = this.dummyPoints[3];
5478
5547
  controlPoint1 = this.calcCurveCP(p0, p1, p2).controlPoint2;
5479
5548
  controlPoint2 = this.calcCurveCP(p1, p2, p3).controlPoint1;
5480
- startPoint = parent.points[this.pointCounter + 1];
5481
- endPoint = parent.points[this.pointCounter + 2];
5549
+ startPoint = this.dummyPoints[1];
5550
+ endPoint = this.dummyPoints[2];
5482
5551
  var minStrokeWidth = 0.5;
5483
5552
  var maxStrokeWidth = 5;
5484
5553
  if (!isNullOrUndefined(this.penStrokeWidth)) {
@@ -5486,6 +5555,7 @@ var FreehandDrawing = /** @__PURE__ @class */ (function () {
5486
5555
  }
5487
5556
  this.startDraw(context, controlPoint1, controlPoint2, startPoint, endPoint, minStrokeWidth, maxStrokeWidth);
5488
5557
  this.pointCounter++;
5558
+ this.dummyPoints.shift();
5489
5559
  }
5490
5560
  if (mouseDown) {
5491
5561
  controlPoint1 = controlPoint2 = startPoint = endPoint = { x: x, y: y, time: new Date().getTime() };
@@ -5656,7 +5726,12 @@ var FreehandDrawing = /** @__PURE__ @class */ (function () {
5656
5726
  if (parent.points[l + 1] && parent.points[l + 2] && parent.points[l + 2]) {
5657
5727
  controlPoint1 = (this.calcCurveCP(parent.points[l + 0], parent.points[l + 1], parent.points[l + 2])).controlPoint2;
5658
5728
  controlPoint2 = (this.calcCurveCP(parent.points[l + 1], parent.points[l + 2], parent.points[l + 3])).controlPoint1;
5659
- startPoint = parent.points[l + 1];
5729
+ if (l === 0) {
5730
+ startPoint = parent.points[l];
5731
+ }
5732
+ else {
5733
+ startPoint = parent.points[l + 1];
5734
+ }
5660
5735
  endPoint = parent.points[l + 2];
5661
5736
  this.startDraw(context, controlPoint1, controlPoint2, startPoint, endPoint, minStrokeWidth, maxStrokeWidth);
5662
5737
  }
@@ -5783,18 +5858,21 @@ var FreehandDrawing = /** @__PURE__ @class */ (function () {
5783
5858
  if (isBlazor() && parent.events && parent.events.shapeChanging.hasDelegate === true) {
5784
5859
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
5785
5860
  parent.dotNetRef.invokeMethodAsync('ShapeEventAsync', 'OnShape', shapeChangingArgs).then(function (shapeChangingArgs) {
5786
- parent.pointColl[_this.fhdSelIdx].strokeColor = shapeChangingArgs.currentShapeSettings.strokeColor;
5787
- parent.pointColl[_this.fhdSelIdx].strokeWidth = shapeChangingArgs.currentShapeSettings.strokeWidth;
5861
+ parent.activeObj.strokeSettings.strokeColor = parent.pointColl[_this.fhdSelIdx].strokeColor =
5862
+ shapeChangingArgs.currentShapeSettings.strokeColor;
5863
+ parent.activeObj.strokeSettings.strokeWidth = parent.pointColl[_this.fhdSelIdx].strokeWidth =
5864
+ shapeChangingArgs.currentShapeSettings.strokeWidth;
5788
5865
  parent.pointColl[_this.fhdSelIdx].points = shapeChangingArgs.currentShapeSettings.points;
5789
5866
  _this.freehandRedraw(_this.upperContext);
5790
- parent.updateToolbar(parent.element, 'imageLoaded');
5791
- parent.updateToolbar(parent.element, 'pen');
5867
+ parent.updateToolbar(parent.element, 'colorToolbar');
5792
5868
  });
5793
5869
  }
5794
5870
  else {
5795
5871
  parent.trigger('shapeChanging', shapeChangingArgs);
5796
- parent.pointColl[this.fhdSelIdx].strokeColor = shapeChangingArgs.currentShapeSettings.strokeColor;
5797
- parent.pointColl[this.fhdSelIdx].strokeWidth = shapeChangingArgs.currentShapeSettings.strokeWidth;
5872
+ parent.activeObj.strokeSettings.strokeColor = parent.pointColl[this.fhdSelIdx].strokeColor =
5873
+ shapeChangingArgs.currentShapeSettings.strokeColor;
5874
+ parent.activeObj.strokeSettings.strokeWidth = parent.pointColl[this.fhdSelIdx].strokeWidth =
5875
+ shapeChangingArgs.currentShapeSettings.strokeWidth;
5798
5876
  parent.pointColl[this.fhdSelIdx].points = shapeChangingArgs.currentShapeSettings.points;
5799
5877
  this.freehandRedraw(this.upperContext);
5800
5878
  parent.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: { type: 'pen',
@@ -6113,6 +6191,7 @@ var FreehandDrawing = /** @__PURE__ @class */ (function () {
6113
6191
  var parent = this.parent;
6114
6192
  if (value) {
6115
6193
  parent.points = [];
6194
+ this.dummyPoints = [];
6116
6195
  parent.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
6117
6196
  parent.togglePen = true;
6118
6197
  parent.upperCanvas.style.cursor = parent.cursor = 'crosshair';
@@ -7039,12 +7118,8 @@ var Selection = /** @__PURE__ @class */ (function () {
7039
7118
  var previousShapeSettings = this.updatePrevShapeSettings();
7040
7119
  var shapeResizingArgs = { action: 'resize', previousShapeSettings: previousShapeSettings };
7041
7120
  var shapeMovingArgs = { action: 'move', previousShapeSettings: previousShapeSettings };
7042
- if (isNullOrUndefined(this.shapeResizingArgs)) {
7043
- this.shapeResizingArgs = shapeResizingArgs;
7044
- }
7045
- if (isNullOrUndefined(this.shapeMovingArgs)) {
7046
- this.shapeMovingArgs = shapeMovingArgs;
7047
- }
7121
+ this.shapeResizingArgs = shapeResizingArgs;
7122
+ this.shapeMovingArgs = shapeMovingArgs;
7048
7123
  if (parent.activeObj.shape === 'text' && this.dragElement !== '') {
7049
7124
  parent.notify('shape', { prop: 'updateFontRatio', onPropertyChange: false,
7050
7125
  value: { obj: parent.activeObj, isTextArea: null } });
@@ -7243,8 +7318,8 @@ var Selection = /** @__PURE__ @class */ (function () {
7243
7318
  parent.activeObj.activePoint.width = parent.activeObj.activePoint.endX - parent.activeObj.activePoint.startX;
7244
7319
  parent.activeObj.activePoint.height = parent.activeObj.activePoint.endY - parent.activeObj.activePoint.startY;
7245
7320
  var currentShapeSettings = this.updatePrevShapeSettings();
7246
- shapeResizingArgs.currentShapeSettings = currentShapeSettings;
7247
- shapeMovingArgs.currentShapeSettings = currentShapeSettings;
7321
+ shapeResizingArgs.currentShapeSettings = this.shapeResizingArgs.currentShapeSettings = currentShapeSettings;
7322
+ shapeMovingArgs.currentShapeSettings = this.shapeMovingArgs.currentShapeSettings = currentShapeSettings;
7248
7323
  if (type === 'resize') {
7249
7324
  this.isCropSelection = false;
7250
7325
  var splitWords = void 0;
@@ -7255,7 +7330,7 @@ var Selection = /** @__PURE__ @class */ (function () {
7255
7330
  this.isCropSelection = true;
7256
7331
  }
7257
7332
  if (!this.isCropSelection && this.parent.eventType !== 'resize' && isBlazor() && parent.events && this.parent.events.onShapeResizeStart.hasDelegate === true) {
7258
- shapeResizingArgs.action = 'resize-start';
7333
+ shapeResizingArgs.action = this.currentDrawingShape !== '' ? 'drawing' : 'resize-start';
7259
7334
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
7260
7335
  parent.dotNetRef.invokeMethodAsync('ShapeEventAsync', 'OnShapeResizeStart', shapeResizingArgs).then(function (shapeResizingArgs) {
7261
7336
  parent.notify('shape', { prop: 'updateShapeChangeEventArgs', onPropertyChange: false,
@@ -7263,6 +7338,9 @@ var Selection = /** @__PURE__ @class */ (function () {
7263
7338
  });
7264
7339
  }
7265
7340
  else if (!this.isCropSelection) {
7341
+ if (this.currentDrawingShape !== '') {
7342
+ shapeResizingArgs.action = 'drawing';
7343
+ }
7266
7344
  parent.trigger('shapeChanging', shapeResizingArgs);
7267
7345
  parent.notify('shape', { prop: 'updateShapeChangeEventArgs', onPropertyChange: false,
7268
7346
  value: { shapeSettings: shapeResizingArgs.currentShapeSettings } });
@@ -7279,9 +7357,7 @@ var Selection = /** @__PURE__ @class */ (function () {
7279
7357
  startY: shapeResizingArgs.currentShapeSettings.startY,
7280
7358
  width: shapeResizingArgs.currentShapeSettings.width,
7281
7359
  height: shapeResizingArgs.currentShapeSettings.height } };
7282
- if (isNullOrUndefined(this.selectionResizingArgs)) {
7283
- this.selectionResizingArgs = selectionResizingArgs;
7284
- }
7360
+ this.selectionResizingArgs = selectionResizingArgs;
7285
7361
  if (isBlazor() && isNullOrUndefined(this.parent.eventType) && parent.events &&
7286
7362
  parent.events.onSelectionResizeStart.hasDelegate === true) {
7287
7363
  selectionResizingArgs.action = 'resize-start';
@@ -9193,7 +9269,7 @@ var Selection = /** @__PURE__ @class */ (function () {
9193
9269
  else if (this.parent.eventType === 'resize') {
9194
9270
  if (!this.isCropSelection && this.parent.events && this.parent.events.onShapeResizeEnd.hasDelegate === true) {
9195
9271
  this.shapeResizingArgs.currentShapeSettings = this.updatePrevShapeSettings();
9196
- this.shapeResizingArgs.action = 'resize-end';
9272
+ this.shapeResizingArgs.action = this.currentDrawingShape !== '' ? 'drawing' : 'resize-end';
9197
9273
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
9198
9274
  this.parent.dotNetRef.invokeMethodAsync('ShapeEventAsync', 'OnShapeResizeEnd', this.shapeResizingArgs).then(function (shapeResizingArgs) {
9199
9275
  _this.parent.notify('shape', { prop: 'updateShapeChangeEventArgs', onPropertyChange: false,
@@ -9612,7 +9688,8 @@ var Selection = /** @__PURE__ @class */ (function () {
9612
9688
  isApply = false;
9613
9689
  }
9614
9690
  else if (parent.upperCanvas.style.cursor !== 'default' && parent.upperCanvas.style.cursor !== 'grab' &&
9615
- parent.upperCanvas.style.cursor !== 'crosshair' && parent.upperCanvas.style.cursor !== 'pointer') {
9691
+ parent.upperCanvas.style.cursor !== 'crosshair' && parent.upperCanvas.style.cursor !== 'pointer' &&
9692
+ parent.upperCanvas.style.cursor !== 'move') {
9616
9693
  isApply = false;
9617
9694
  }
9618
9695
  else {
@@ -10359,10 +10436,21 @@ var Selection = /** @__PURE__ @class */ (function () {
10359
10436
  if (isNullOrUndefined(actObj.activePoint)) {
10360
10437
  return;
10361
10438
  }
10362
- if ((x >= Math.floor(actObj.activePoint.startX) && x <= Math.ceil(actObj.activePoint.endX) &&
10363
- y >= Math.floor(actObj.activePoint.startY) && y <= Math.ceil(actObj.activePoint.endY))) {
10439
+ var radius = actObj.topLeftCircle ? actObj.topLeftCircle.radius : 0;
10440
+ if ((x >= Math.floor(actObj.activePoint.startX) &&
10441
+ x <= Math.ceil(actObj.activePoint.endX) &&
10442
+ y >= Math.floor(actObj.activePoint.startY) &&
10443
+ y <= Math.ceil(actObj.activePoint.endY))) {
10364
10444
  isInside = true;
10365
10445
  }
10446
+ else if (radius !== 0 && (x >= Math.floor(actObj.activePoint.startX) - radius &&
10447
+ x <= Math.ceil(actObj.activePoint.endX) + radius &&
10448
+ y >= Math.floor(actObj.activePoint.startY) - radius &&
10449
+ y <= Math.ceil(actObj.activePoint.endY) + radius)) {
10450
+ isInside = true;
10451
+ this.tempActiveObj = { activePoint: { startX: 0, startY: 0, endX: 0, endY: 0, width: 0, height: 0 },
10452
+ flipObjColl: [], triangle: [], triangleRatio: [] };
10453
+ }
10366
10454
  else if (actObj.shape === 'text' && this.dragElement !== '') {
10367
10455
  isInside = true;
10368
10456
  }
@@ -10451,7 +10539,9 @@ var Selection = /** @__PURE__ @class */ (function () {
10451
10539
  Selection.prototype.setTextBoxStylesToActObj = function () {
10452
10540
  var parent = this.parent;
10453
10541
  parent.activeObj.textSettings.fontFamily = parent.textArea.style.fontFamily;
10454
- parent.activeObj.strokeSettings.strokeColor = parent.textArea.style.color !== '' ?
10542
+ parent.activeObj.strokeSettings.strokeColor = parent.textArea.style.color !== '' &&
10543
+ parent.textArea.style.color.split('(')[1] && parent.textArea.style.color.split('(')[1].split(',')[0] &&
10544
+ parent.textArea.style.color.split('(')[1].split(',')[1] && parent.textArea.style.color.split('(')[1].split(',')[2] ?
10455
10545
  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])) :
10456
10546
  parent.textArea.style.color;
10457
10547
  if (parent.textArea.style.fontWeight === 'bold') {
@@ -11281,6 +11371,9 @@ var Shape = /** @__PURE__ @class */ (function () {
11281
11371
  isApplyBtn: null, isCropping: null, isZooming: null, cType: null } });
11282
11372
  parent.notify('toolbar', { prop: 'update-toolbar-items', onPropertyChange: false });
11283
11373
  }
11374
+ else {
11375
+ parent.updateToolbar(parent.element, 'text');
11376
+ }
11284
11377
  };
11285
11378
  Shape.prototype.initializeTextShape = function (text, fontFamily, fontSize, bold, italic, strokeColor) {
11286
11379
  var parent = this.parent;
@@ -11312,14 +11405,10 @@ var Shape = /** @__PURE__ @class */ (function () {
11312
11405
  if (x && y) {
11313
11406
  if ((x !== parent.activeObj.activePoint.startX) && (y !== parent.activeObj.activePoint.startY)) {
11314
11407
  this.updateTextFromTextArea();
11315
- this.applyActObj();
11316
11408
  }
11317
11409
  }
11318
11410
  else {
11319
11411
  this.updateTextFromTextArea();
11320
- this.apply(parent.activeObj.shape, parent.activeObj);
11321
- parent.objColl.push(parent.activeObj);
11322
- this.refreshActiveObj();
11323
11412
  parent.textArea.style.transform = '';
11324
11413
  parent.notify('toolbar', { prop: 'refresh-main-toolbar', onPropertyChange: false });
11325
11414
  }
@@ -11422,7 +11511,7 @@ var Shape = /** @__PURE__ @class */ (function () {
11422
11511
  parent.activeObj.strokeSettings.fillColor = shapeSettings.fillColor;
11423
11512
  switch (parent.activeObj.shape) {
11424
11513
  case 'ellipse':
11425
- parent.activeObj.activePoint.width = shapeSettings.radius / 2;
11514
+ parent.activeObj.activePoint.width = shapeSettings.radius * 2;
11426
11515
  break;
11427
11516
  case 'line':
11428
11517
  case 'arrow':
@@ -11498,23 +11587,20 @@ var Shape = /** @__PURE__ @class */ (function () {
11498
11587
  };
11499
11588
  Shape.prototype.updateTextFromTextArea = function () {
11500
11589
  var parent = this.parent;
11590
+ var allowUndoRedo = false;
11591
+ var prevCropObj = extend({}, parent.cropObj, {}, true);
11592
+ var object = { currObj: {} };
11593
+ parent.notify('filter', { prop: 'getCurrentObj', onPropertyChange: false, value: { object: object } });
11594
+ var prevObj = object['currObj'];
11595
+ prevObj.objColl = extend([], parent.objColl, [], true);
11596
+ prevObj.pointColl = extend([], parent.pointColl, [], true);
11597
+ prevObj.afterCropActions = extend([], this.parent.afterCropActions, [], true);
11598
+ var selPointCollObj = { selPointColl: null };
11599
+ parent.notify('freehand-draw', { prop: 'getSelPointColl', onPropertyChange: false,
11600
+ value: { obj: selPointCollObj } });
11601
+ prevObj.selPointColl = extend([], selPointCollObj['selPointColl'], [], true);
11501
11602
  if (parent.activeObj.keyHistory !== parent.textArea.value) {
11502
- var prevCropObj = extend({}, parent.cropObj, {}, true);
11503
- var object = { currObj: {} };
11504
- parent.notify('filter', { prop: 'getCurrentObj', onPropertyChange: false, value: { object: object } });
11505
- var prevObj = object['currObj'];
11506
- prevObj.objColl = extend([], parent.objColl, [], true);
11507
- prevObj.pointColl = extend([], parent.pointColl, [], true);
11508
- prevObj.afterCropActions = extend([], this.parent.afterCropActions, [], true);
11509
- var selPointCollObj = { selPointColl: null };
11510
- parent.notify('freehand-draw', { prop: 'getSelPointColl', onPropertyChange: false,
11511
- value: { obj: selPointCollObj } });
11512
- prevObj.selPointColl = extend([], selPointCollObj['selPointColl'], [], true);
11513
- parent.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false,
11514
- value: { operation: 'text', previousObj: prevObj, previousObjColl: prevObj.objColl,
11515
- previousPointColl: prevObj.pointColl, previousSelPointColl: prevObj.selPointColl,
11516
- previousCropObj: prevCropObj, previousText: parent.activeObj.keyHistory,
11517
- currentText: parent.textArea.value, previousFilter: null, isCircleCrop: null } });
11603
+ allowUndoRedo = true;
11518
11604
  }
11519
11605
  parent.activeObj.keyHistory = parent.textArea.value;
11520
11606
  parent.textArea.style.display = 'none';
@@ -11538,6 +11624,19 @@ var Shape = /** @__PURE__ @class */ (function () {
11538
11624
  parent.notify('draw', { prop: 'updateActiveObject', onPropertyChange: false, value: { actPoint: parent.activeObj.activePoint, obj: parent.activeObj,
11539
11625
  isMouseMove: null, x: null, y: null } });
11540
11626
  this.updImgRatioForActObj();
11627
+ if (allowUndoRedo) {
11628
+ this.apply(parent.activeObj.shape, parent.activeObj);
11629
+ parent.objColl.push(extend({}, parent.activeObj, {}, true));
11630
+ parent.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false,
11631
+ value: { operation: 'text', previousObj: prevObj, previousObjColl: prevObj.objColl,
11632
+ previousPointColl: prevObj.pointColl, previousSelPointColl: prevObj.selPointColl,
11633
+ previousCropObj: prevCropObj, previousText: parent.activeObj.keyHistory,
11634
+ currentText: parent.textArea.value, previousFilter: null, isCircleCrop: null } });
11635
+ }
11636
+ else {
11637
+ this.apply(parent.activeObj.shape, parent.activeObj);
11638
+ parent.objColl.push(extend({}, parent.activeObj, {}, true));
11639
+ }
11541
11640
  };
11542
11641
  Shape.prototype.iterateObjColl = function () {
11543
11642
  var parent = this.parent;
@@ -12206,11 +12305,13 @@ var Shape = /** @__PURE__ @class */ (function () {
12206
12305
  parent.activeObj.pointColl.pop();
12207
12306
  }
12208
12307
  this.updatePathRatio(parent.activeObj);
12308
+ parent.objColl.push(parent.activeObj);
12209
12309
  parent.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false,
12210
12310
  value: { operation: 'shapeTransform', previousObj: prevObj, previousObjColl: prevObj.objColl,
12211
12311
  previousPointColl: prevObj.pointColl, previousSelPointColl: prevObj.selPointColl,
12212
12312
  previousCropObj: prevCropObj, previousText: null,
12213
12313
  currentText: null, previousFilter: null, isCircleCrop: null } });
12314
+ parent.objColl.pop();
12214
12315
  parent.notify('selection', { prop: 'mouseUpEventHandler', value: { e: e } });
12215
12316
  parent.notify('draw', { prop: 'setNewPath', value: { bool: true } });
12216
12317
  if (parent.objColl[parent.objColl.length - 1]) {
@@ -12632,8 +12733,7 @@ var Shape = /** @__PURE__ @class */ (function () {
12632
12733
  var object = { arrowDimension: null };
12633
12734
  parent.notify('draw', { prop: 'getArrowDimension', onPropertyChange: false, value: { obj: object } });
12634
12735
  var length;
12635
- var degree = this.getRotDegOfShape(obj);
12636
- if (degree === 0 || degree === 180 || degree === -180) {
12736
+ if (Math.abs(obj.activePoint.width) > Math.abs(obj.activePoint.height)) {
12637
12737
  length = Math.abs(obj.activePoint.width);
12638
12738
  }
12639
12739
  else {
@@ -12653,8 +12753,7 @@ var Shape = /** @__PURE__ @class */ (function () {
12653
12753
  var object = { arrowDimension: null };
12654
12754
  this.parent.notify('draw', { prop: 'getArrowDimension', onPropertyChange: false, value: { obj: object } });
12655
12755
  var length;
12656
- var degree = this.getRotDegOfShape(obj);
12657
- if (degree === 0 || degree === 180 || degree === -180) {
12756
+ if (Math.abs(obj.activePoint.width) > Math.abs(obj.activePoint.height)) {
12658
12757
  length = Math.abs(obj.activePoint.width);
12659
12758
  }
12660
12759
  else {
@@ -14688,6 +14787,7 @@ var Transform = /** @__PURE__ @class */ (function () {
14688
14787
  };
14689
14788
  Transform.prototype.drawPannImage = function (point) {
14690
14789
  var parent = this.parent;
14790
+ var filter = this.lowerContext.filter;
14691
14791
  var destPoints = { startX: parent.img.destLeft, startY: parent.img.destTop, width: parent.img.destWidth,
14692
14792
  height: parent.img.destHeight };
14693
14793
  this.lowerContext.clearRect(0, 0, parent.lowerCanvas.width, parent.lowerCanvas.height);
@@ -14704,6 +14804,7 @@ var Transform = /** @__PURE__ @class */ (function () {
14704
14804
  parent.notify('crop', { prop: 'cropCircle', onPropertyChange: false,
14705
14805
  value: { context: this.lowerContext, isSave: null, isFlip: true } });
14706
14806
  }
14807
+ this.lowerContext.filter = filter;
14707
14808
  parent.notify('draw', { prop: 'updateCurrTransState', onPropertyChange: false,
14708
14809
  value: { type: 'reverse', isPreventDestination: null, isRotatePan: null } });
14709
14810
  parent.img.destLeft = destPoints.startX;
@@ -16305,7 +16406,8 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
16305
16406
  _this.cropObj = { cropZoom: 0, defaultZoom: 0, totalPannedPoint: { x: 0, y: 0 }, totalPannedClientPoint: { x: 0, y: 0 },
16306
16407
  totalPannedInternalPoint: { x: 0, y: 0 }, tempFlipPanPoint: { x: 0, y: 0 }, activeObj: {}, rotateFlipColl: [],
16307
16408
  degree: 0, currFlipState: '', destPoints: { startX: 0, startY: 0, width: 0, height: 0 },
16308
- srcPoints: { startX: 0, startY: 0, width: 0, height: 0 }, filter: '', zoomFactor: 0, previousZoomValue: 0 };
16409
+ srcPoints: { startX: 0, startY: 0, width: 0, height: 0 }, filter: '', isBrightAdjust: false,
16410
+ zoomFactor: 0, previousZoomValue: 0 };
16309
16411
  // Stored transformations performed after cropping
16310
16412
  /** @hidden */
16311
16413
  _this.afterCropActions = [];
@@ -16884,7 +16986,7 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
16884
16986
  totalPannedInternalPoint: { x: 0, y: 0 }, tempFlipPanPoint: { x: 0, y: 0 }, activeObj: {},
16885
16987
  rotateFlipColl: [], degree: 0, currFlipState: '', zoomFactor: 0, previousZoomValue: 0,
16886
16988
  destPoints: { startX: 0, startY: 0, width: 0, height: 0 },
16887
- srcPoints: { startX: 0, startY: 0, width: 0, height: 0 }, filter: '' };
16989
+ srcPoints: { startX: 0, startY: 0, width: 0, height: 0 }, filter: '', isBrightAdjust: false };
16888
16990
  this.afterCropActions = [];
16889
16991
  this.currentFilter = '';
16890
16992
  var obj_1 = { initialZoomValue: false };
@@ -20545,7 +20647,6 @@ var ToolbarModule = /** @__PURE__ @class */ (function () {
20545
20647
  }
20546
20648
  spanElem_3.className = 'e-pen-stroke-width';
20547
20649
  strokeWidthBtn.appendChild(spanElem_3);
20548
- // eslint-disable-next-line @typescript-eslint/no-this-alias
20549
20650
  var drpDownBtn_2 = new DropDownButton({ items: strokeWidthItems,
20550
20651
  open: function (args) {
20551
20652
  if (Browser.isDevice) {
@@ -21476,6 +21577,9 @@ var ToolbarModule = /** @__PURE__ @class */ (function () {
21476
21577
  };
21477
21578
  ToolbarModule.prototype.updateToolbarItems = function () {
21478
21579
  var parent = this.parent;
21580
+ if (!parent.isImageLoaded) {
21581
+ return;
21582
+ }
21479
21583
  var selFillElem = parent.element.querySelector('.e-fill.e-template .e-dropdownbtn-preview');
21480
21584
  var selStrokeElem = parent.element.querySelector('.e-stroke.e-template .e-dropdownbtn-preview');
21481
21585
  var selTextStrokeElem = parent.element.querySelector('.e-text-font-color.e-template .e-dropdownbtn-preview');