@syncfusion/ej2-image-editor 22.1.34 → 22.1.37

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 (35) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/ej2-image-editor.umd.min.js +2 -2
  3. package/dist/ej2-image-editor.umd.min.js.map +1 -1
  4. package/dist/es6/ej2-image-editor.es2015.js +1018 -1064
  5. package/dist/es6/ej2-image-editor.es2015.js.map +1 -1
  6. package/dist/es6/ej2-image-editor.es5.js +1016 -1066
  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 +9 -9
  12. package/src/image-editor/action/crop.d.ts +1 -0
  13. package/src/image-editor/action/crop.js +12 -1
  14. package/src/image-editor/action/draw.d.ts +4 -1
  15. package/src/image-editor/action/draw.js +137 -127
  16. package/src/image-editor/action/filter.js +1 -1
  17. package/src/image-editor/action/freehand-draw.js +9 -9
  18. package/src/image-editor/action/selection.d.ts +1 -1
  19. package/src/image-editor/action/selection.js +64 -226
  20. package/src/image-editor/action/shape.d.ts +1 -0
  21. package/src/image-editor/action/shape.js +97 -9
  22. package/src/image-editor/action/transform.js +211 -22
  23. package/src/image-editor/action/undo-redo.js +9 -7
  24. package/src/image-editor/base/image-editor-model.d.ts +2 -2
  25. package/src/image-editor/base/image-editor.d.ts +0 -15
  26. package/src/image-editor/base/image-editor.js +35 -225
  27. package/src/image-editor/base/interface.d.ts +11 -3
  28. package/src/image-editor/renderer/toolbar.js +362 -363
  29. package/styles/highcontrast-light.css +2 -2
  30. package/styles/highcontrast.css +6 -1
  31. package/styles/image-editor/_highcontrast-definition.scss +1 -1
  32. package/styles/image-editor/_highcontrast-light-definition.scss +1 -1
  33. package/styles/image-editor/_theme.scss +2 -4
  34. package/styles/image-editor/highcontrast-light.css +2 -2
  35. package/styles/image-editor/highcontrast.css +6 -1
@@ -205,6 +205,9 @@ var Shape = /** @class */ (function () {
205
205
  case 'updateArrowRatio':
206
206
  this.updateArrowRatio(args.value['obj']);
207
207
  break;
208
+ case 'getSquarePointForRotatedShape':
209
+ this.getSquarePointForRotatedShape(args.value['obj'], args.value['object']);
210
+ break;
208
211
  case 'reset':
209
212
  this.reset();
210
213
  break;
@@ -228,30 +231,41 @@ var Shape = /** @class */ (function () {
228
231
  };
229
232
  Shape.prototype.drawEllipse = function (x, y, radiusX, radiusY, strokeWidth, strokeColor, fillColor) {
230
233
  this.initializeShape('ellipse');
231
- var start = { x: x, y: y };
234
+ var start = x && y ? { x: x, y: y } : null;
232
235
  this.drawShape('ellipse', strokeWidth, strokeColor, fillColor, start, radiusX, radiusY);
233
236
  };
234
237
  Shape.prototype.drawLine = function (startX, startY, endX, endY, strokeWidth, strokeColor) {
235
238
  this.initializeShape('line');
236
- var start = { x: startX, y: startY };
239
+ var start = startX && startY ? { x: startX, y: startY } : null;
237
240
  var width = endX - startX;
238
241
  var height = endY - startY;
239
242
  this.drawShape('line', strokeWidth, strokeColor, null, start, width, height);
240
243
  };
241
244
  Shape.prototype.drawPath = function (pointColl, strokeWidth, strokeColor) {
242
245
  this.initializeShape('path');
243
- this.drawShape('path', strokeWidth, strokeColor, null, null, null, null, pointColl);
246
+ if (pointColl) {
247
+ this.drawShape('path', strokeWidth, strokeColor, null, null, null, null, pointColl);
248
+ }
249
+ else {
250
+ this.drawShape('line', strokeWidth, strokeColor, null, null, null, null);
251
+ var obj = extend({}, this.parent.objColl[this.parent.objColl.length - 1], null, true);
252
+ obj.shape = 'path';
253
+ obj.lineDraw = null;
254
+ obj.pointColl = [{ x: obj.activePoint.startX, y: obj.activePoint.startY },
255
+ { x: obj.activePoint.endX, y: obj.activePoint.endY }];
256
+ this.parent.objColl[this.parent.objColl.length - 1] = obj;
257
+ }
244
258
  };
245
259
  Shape.prototype.drawArrow = function (startX, startY, endX, endY, strokeWidth, strokeColor, arrowStart, arrowEnd) {
246
260
  this.initializeShape('arrow');
247
- var start = { x: startX, y: startY };
261
+ var start = startX && startY ? { x: startX, y: startY } : null;
248
262
  var width = endX - startX;
249
263
  var height = endY - startY;
250
264
  this.drawShape('arrow', strokeWidth, strokeColor, null, start, width, height, null, arrowStart, arrowEnd);
251
265
  };
252
266
  Shape.prototype.drawRectangle = function (x, y, width, height, strokeWidth, strokeColor, fillColor) {
253
267
  this.initializeShape('rectangle');
254
- var start = { x: x, y: y };
268
+ var start = x && y ? { x: x, y: y } : null;
255
269
  this.drawShape('rectangle', strokeWidth, strokeColor, fillColor, start, width, height);
256
270
  };
257
271
  Shape.prototype.drawText = function (x, y, text, fontFamily, fontSize, bold, italic, color) {
@@ -413,7 +427,7 @@ var Shape = /** @class */ (function () {
413
427
  var parent = this.parent;
414
428
  if (parent.activeObj.shape === 'line' || parent.activeObj.shape === 'arrow') {
415
429
  parent.activeObj.pointColl = this.getLinePoints(parent.activeObj.activePoint.startX, parent.activeObj.activePoint.startY, parent.activeObj.activePoint.endX, parent.activeObj.activePoint.endY);
416
- if (!isNullOrUndefined(parent.activeObj.pointColl)) {
430
+ if (parent.activeObj.pointColl) {
417
431
  for (var i = 0, len = parent.activeObj.pointColl.length; i < len; i++) {
418
432
  parent.activeObj.pointColl[i].ratioX = (parent.activeObj.pointColl[i].x -
419
433
  parent.img.destLeft) / parent.img.destWidth;
@@ -1536,7 +1550,7 @@ var Shape = /** @class */ (function () {
1536
1550
  this.upperContext.clearRect(0, 0, this.parent.upperCanvas.width, this.parent.upperCanvas.height);
1537
1551
  this.lowerContext.clearRect(0, 0, this.parent.upperCanvas.width, this.parent.upperCanvas.height);
1538
1552
  parent.notify('draw', { prop: 'redrawImgWithObj', onPropertyChange: false });
1539
- if ((!isNullOrUndefined(parent.currSelectionPoint) && parent.currSelectionPoint.shape === 'crop-circle') || parent.isCircleCrop) {
1553
+ if ((parent.currSelectionPoint && parent.currSelectionPoint.shape === 'crop-circle') || parent.isCircleCrop) {
1540
1554
  parent.notify('crop', { prop: 'cropCircle', onPropertyChange: false,
1541
1555
  value: { context: this.lowerContext, isSave: null, isFlip: null } });
1542
1556
  }
@@ -2254,8 +2268,8 @@ var Shape = /** @class */ (function () {
2254
2268
  };
2255
2269
  Shape.prototype.isPointsInRange = function (x, y, obj) {
2256
2270
  var inRange = false;
2257
- if (!isNullOrUndefined(x) && !isNullOrUndefined(y) && x >= 0 && y >= 0 &&
2258
- x <= this.parent.lowerCanvas.width && y <= this.parent.lowerCanvas.width) {
2271
+ if (!isNullOrUndefined(x) && !isNullOrUndefined(y) && x >= this.parent.img.destLeft && y >= this.parent.img.destTop &&
2272
+ x <= this.parent.img.destLeft + this.parent.img.destWidth && y <= this.parent.img.destTop + this.parent.img.destHeight) {
2259
2273
  inRange = true;
2260
2274
  }
2261
2275
  obj['inRange'] = inRange;
@@ -2412,8 +2426,10 @@ var Shape = /** @class */ (function () {
2412
2426
  isApplyBtn: null, isCropping: null, isZooming: null, cType: null } });
2413
2427
  }
2414
2428
  parent.notify('toolbar', { prop: 'update-toolbar-items', onPropertyChange: false });
2429
+ parent.notify('toolbar', { prop: 'renderQAT', onPropertyChange: false, value: { isPenEdit: null } });
2415
2430
  }
2416
2431
  else {
2432
+ parent.updateToolbar(parent.element, parent.activeObj.shape);
2417
2433
  if (parent.activeObj.shape === 'path') {
2418
2434
  parent.updateToolbar(this.parent.element, 'path', 'pathQuickAccessToolbar');
2419
2435
  }
@@ -2435,8 +2451,13 @@ var Shape = /** @class */ (function () {
2435
2451
  isSelected = true;
2436
2452
  parent.notify('freehand-draw', { prop: 'selectFhd', value: { id: id } });
2437
2453
  if (!isBlazor()) {
2454
+ parent.notify('toolbar', { prop: 'renderQAT', onPropertyChange: false, value: { isPenEdit: true } });
2438
2455
  parent.notify('toolbar', { prop: 'update-toolbar-items', onPropertyChange: false });
2439
2456
  }
2457
+ else {
2458
+ parent.updateToolbar(parent.element, 'pen');
2459
+ parent.updateToolbar(parent.element, 'quickAccessToolbar', 'pen');
2460
+ }
2440
2461
  }
2441
2462
  else {
2442
2463
  isSelected = false;
@@ -2652,6 +2673,73 @@ var Shape = /** @class */ (function () {
2652
2673
  }
2653
2674
  }
2654
2675
  };
2676
+ Shape.prototype.getSquarePointForRotatedShape = function (obj, object) {
2677
+ var point = { startX: 0, startY: 0, endX: 0, endY: 0, width: 0, height: 0 };
2678
+ var center = { x: obj.activePoint.startX + (obj.activePoint.width / 2), y: obj.activePoint.startY +
2679
+ (obj.activePoint.height / 2) };
2680
+ var p1 = { x: Math.cos(obj.rotatedAngle) * (obj.activePoint.startX - center.x) - Math.sin(obj.rotatedAngle)
2681
+ * (obj.activePoint.startY - center.y) + center.x,
2682
+ y: Math.sin(obj.rotatedAngle) * (obj.activePoint.startX - center.x) + Math.cos(obj.rotatedAngle) * (obj.activePoint.startY
2683
+ - center.y) + center.y };
2684
+ var p2 = { x: Math.cos(obj.rotatedAngle) * (obj.activePoint.endX - center.x) - Math.sin(obj.rotatedAngle) *
2685
+ (obj.activePoint.startY - center.y) + center.x,
2686
+ y: Math.sin(obj.rotatedAngle) * (obj.activePoint.endX - center.x) + Math.cos(obj.rotatedAngle) * (obj.activePoint.startY
2687
+ - center.y) + center.y };
2688
+ var p3 = { x: Math.cos(obj.rotatedAngle) * (obj.activePoint.startX - center.x) - Math.sin(obj.rotatedAngle) *
2689
+ (obj.activePoint.endY - center.y) + center.x,
2690
+ y: Math.sin(obj.rotatedAngle) * (obj.activePoint.startX - center.x) + Math.cos(obj.rotatedAngle) * (obj.activePoint.endY
2691
+ - center.y) + center.y };
2692
+ var p4 = { x: Math.cos(obj.rotatedAngle) * (obj.activePoint.endX - center.x) - Math.sin(obj.rotatedAngle) *
2693
+ (obj.activePoint.endY - center.y) + center.x,
2694
+ y: Math.sin(obj.rotatedAngle) * (obj.activePoint.endX - center.x) + Math.cos(obj.rotatedAngle) *
2695
+ (obj.activePoint.endY - center.y) + center.y };
2696
+ point.startX = p1.x;
2697
+ point.startY = p1.y;
2698
+ point.endX = p1.x;
2699
+ point.endY = p1.y;
2700
+ if (point.startX > p2.x) {
2701
+ point.startX = p2.x;
2702
+ }
2703
+ if (point.startX > p3.x) {
2704
+ point.startX = p3.x;
2705
+ }
2706
+ if (point.startX > p4.x) {
2707
+ point.startX = p4.x;
2708
+ }
2709
+ if (point.startY > p2.y) {
2710
+ point.startY = p2.y;
2711
+ }
2712
+ if (point.startY > p3.y) {
2713
+ point.startY = p3.y;
2714
+ }
2715
+ if (point.startY > p4.y) {
2716
+ point.startY = p4.y;
2717
+ }
2718
+ if (point.endX < p2.x) {
2719
+ point.endX = p2.x;
2720
+ }
2721
+ if (point.endX < p3.x) {
2722
+ point.endX = p3.x;
2723
+ }
2724
+ if (point.endX < p4.x) {
2725
+ point.endX = p4.x;
2726
+ }
2727
+ if (point.endY < p2.y) {
2728
+ point.endY = p2.y;
2729
+ }
2730
+ if (point.endY < p3.y) {
2731
+ point.endY = p3.y;
2732
+ }
2733
+ if (point.endY < p4.y) {
2734
+ point.endY = p4.y;
2735
+ }
2736
+ point.width = point.endX - point.startX;
2737
+ point.height = point.endY - point.startY;
2738
+ if (object) {
2739
+ object['activePoint'] = point;
2740
+ }
2741
+ return point;
2742
+ };
2655
2743
  return Shape;
2656
2744
  }());
2657
2745
  export { Shape };
@@ -1,5 +1,6 @@
1
- import { Browser, extend, isBlazor, isNullOrUndefined } from '@syncfusion/ej2-base';
1
+ import { Browser, extend, getComponent, isBlazor, isNullOrUndefined } from '@syncfusion/ej2-base';
2
2
  import { Direction } from '../index';
3
+ import { hideSpinner, showSpinner } from '@syncfusion/ej2-popups';
3
4
  var Transform = /** @class */ (function () {
4
5
  function Transform(parent) {
5
6
  this.isReverseFlip = false; // True when rotate method is called from iteration
@@ -176,7 +177,7 @@ var Transform = /** @class */ (function () {
176
177
  var parent = this.parent;
177
178
  var transitionArgs = { cancel: false, previousDegree: parent.transform.degree,
178
179
  currentDegree: Math.abs(parent.transform.degree + degree) === 360 ? 0 : parent.transform.degree + degree };
179
- if (!this.isPreventSelect && isBlazor() && !isNullOrUndefined(parent.events) && parent.events.rotating.hasDelegate === true) {
180
+ if (!this.isPreventSelect && isBlazor() && parent.events && parent.events.rotating.hasDelegate === true) {
180
181
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
181
182
  parent.dotNetRef.invokeMethodAsync('RotateEventAsync', 'OnRotate', transitionArgs).then(function (args) {
182
183
  _this.rotateEvent(args, degree);
@@ -208,7 +209,7 @@ var Transform = /** @class */ (function () {
208
209
  parent.afterCropActions.push(degree === 90 ? 'rotateRight' : 'rotateLeft');
209
210
  var splitWords = [];
210
211
  var activeObjShape = void 0;
211
- if (!isNullOrUndefined(parent.activeObj.activePoint) && !isNullOrUndefined(parent.activeObj.shape)) {
212
+ if (parent.activeObj.activePoint && parent.activeObj.shape) {
212
213
  if (parent.activeObj.shape !== undefined) {
213
214
  splitWords = parent.activeObj.shape.split('-');
214
215
  }
@@ -362,7 +363,7 @@ var Transform = /** @class */ (function () {
362
363
  var parent = this.parent;
363
364
  var transitionArgs = { direction: direction, cancel: false,
364
365
  previousDirection: parent.toPascalCase(parent.transform.currFlipState) };
365
- if (!this.isPreventSelect && isBlazor() && !isNullOrUndefined(parent.events) && parent.events.flipping.hasDelegate === true) {
366
+ if (!this.isPreventSelect && isBlazor() && parent.events && parent.events.flipping.hasDelegate === true) {
366
367
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
367
368
  parent.dotNetRef.invokeMethodAsync('FlipEventAsync', 'OnFlip', transitionArgs).then(function (args) {
368
369
  _this.flipEvent(args, direction);
@@ -500,7 +501,7 @@ var Transform = /** @class */ (function () {
500
501
  parent.notify('crop', { prop: 'cropCircle', onPropertyChange: false,
501
502
  value: { context: this.lowerContext, isSave: null, isFlip: null } });
502
503
  }
503
- if (!isNullOrUndefined(activeObjShape)) {
504
+ if (activeObjShape) {
504
505
  this.upperContext.clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
505
506
  parent.activeObj = extend({}, parent.objColl[parent.objColl.length - 1], {}, true);
506
507
  parent.objColl.pop();
@@ -632,13 +633,13 @@ var Transform = /** @class */ (function () {
632
633
  this.tempActiveObj = extend({}, parent.activeObj, {}, true);
633
634
  parent.isCropTab = true;
634
635
  }
635
- else if (!isNullOrUndefined(parent.activeObj.shape) && splitWords[0] !== 'crop') {
636
+ else if (parent.activeObj.shape && splitWords[0] !== 'crop') {
636
637
  this.isShape = true;
637
638
  }
638
639
  var obj = { zoomType: null };
639
640
  parent.notify('selection', { prop: 'getZoomType', onPropertyChange: false, value: { obj: obj } });
640
641
  if (isNullOrUndefined(zoomPoint)) {
641
- if (parent.isCropTab && !isNullOrUndefined(this.tempActiveObj)) {
642
+ if (parent.isCropTab && this.tempActiveObj) {
642
643
  zoomPoint = { x: parent.activeObj.activePoint.startX + (parent.activeObj.activePoint.width / 2),
643
644
  y: parent.activeObj.activePoint.startY + (parent.activeObj.activePoint.height / 2) };
644
645
  }
@@ -652,7 +653,7 @@ var Transform = /** @class */ (function () {
652
653
  var previousZoomFactor = parent.zoomSettings.zoomFactor - (zoomFactor * 10);
653
654
  var zoomEventArgs = { zoomPoint: zoomPoint, cancel: false, previousZoomFactor: previousZoomFactor,
654
655
  currentZoomFactor: parent.zoomSettings.zoomFactor, zoomTrigger: obj['zoomType'] };
655
- if (!parent.isCropToolbar && isBlazor() && !isNullOrUndefined(parent.events) && parent.events.zooming.hasDelegate === true) {
656
+ if (!parent.isCropToolbar && isBlazor() && parent.events && parent.events.zooming.hasDelegate === true) {
656
657
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
657
658
  parent.dotNetRef.invokeMethodAsync('ZoomEventAsync', 'OnZoom', zoomEventArgs).then(function (args) {
658
659
  _this.zoomEvent(args, zoomFactor);
@@ -789,7 +790,7 @@ var Transform = /** @class */ (function () {
789
790
  }
790
791
  }
791
792
  this.autoEnablePan();
792
- if (!isNullOrUndefined(this.tempActiveObj)) {
793
+ if (this.tempActiveObj) {
793
794
  parent.activeObj = extend({}, this.tempActiveObj, {}, true);
794
795
  }
795
796
  if (parent.activeObj.shape === 'crop-custom') {
@@ -1096,7 +1097,7 @@ var Transform = /** @class */ (function () {
1096
1097
  var obj = { panDown: null };
1097
1098
  parent.notify('selection', { prop: 'getPanDown', onPropertyChange: false, value: { obj: obj } });
1098
1099
  var panEventArgs = { startPoint: obj['panDown'], endPoint: this.panMove, cancel: false };
1099
- if (isBlazor() && isNullOrUndefined(this.parent.eventType) && !isNullOrUndefined(parent.events) && parent.events.onPanStart.hasDelegate === true) {
1100
+ if (isBlazor() && isNullOrUndefined(this.parent.eventType) && parent.events && parent.events.onPanStart.hasDelegate === true) {
1100
1101
  this.parent.eventType = 'pan';
1101
1102
  this.parent.panEventArgs = panEventArgs;
1102
1103
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
@@ -1310,7 +1311,7 @@ var Transform = /** @class */ (function () {
1310
1311
  var tempDegree = parent.transform.degree;
1311
1312
  var rotatePanActiveObj;
1312
1313
  var object = { selPointColl: null };
1313
- if (!isNullOrUndefined(parent.activeObj.activePoint) && !isNullOrUndefined(parent.activeObj.shape)) {
1314
+ if (parent.activeObj.activePoint && parent.activeObj.shape) {
1314
1315
  rotatePanActiveObj = extend({}, parent.activeObj, {}, true);
1315
1316
  }
1316
1317
  var tempObjColl = extend([], parent.objColl, [], true);
@@ -1381,7 +1382,7 @@ var Transform = /** @class */ (function () {
1381
1382
  parent.notify('draw', { prop: 'clearOuterCanvas', onPropertyChange: false, value: { context: this.lowerContext } });
1382
1383
  this.upperContext.clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
1383
1384
  parent.activeObj = extend({}, rotatePanActiveObj, {}, true);
1384
- if (!isNullOrUndefined(parent.activeObj.activePoint)) {
1385
+ if (parent.activeObj.activePoint) {
1385
1386
  parent.notify('draw', { prop: 'drawObject', onPropertyChange: false, value: { canvas: 'duplicate', obj: parent.activeObj, isCropRatio: null,
1386
1387
  points: null, isPreventDrag: true, saveContext: null, isPreventSelection: null } });
1387
1388
  }
@@ -1549,26 +1550,72 @@ var Transform = /** @class */ (function () {
1549
1550
  Transform.prototype.update = function () {
1550
1551
  var parent = this.parent;
1551
1552
  var toolbarHeight = 0;
1553
+ var isActiveObj = false;
1554
+ var freehandObj = { bool: false };
1555
+ if (parent.isImageLoaded) {
1556
+ if ((parent.element.querySelector('#' + parent.element.id + '_contextualToolbar') &&
1557
+ !parent.element.querySelector('#' + parent.element.id + '_contextualToolbar').parentElement.classList.contains('e-hide')) ||
1558
+ (parent.element.querySelector('#' + parent.element.id + '_headWrapper')
1559
+ && !parent.element.querySelector('#' + parent.element.id + '_headWrapper').parentElement.classList.contains('e-hide'))) {
1560
+ parent.element.querySelector('.e-contextual-toolbar-wrapper').classList.add('e-hide');
1561
+ parent.okBtn();
1562
+ if (!isBlazor()) {
1563
+ parent.notify('toolbar', { prop: 'refresh-main-toolbar', onPropertyChange: false });
1564
+ parent.notify('toolbar', { prop: 'destroy-qa-toolbar', onPropertyChange: false });
1565
+ }
1566
+ else {
1567
+ parent.updateToolbar(parent.element, 'imageLoaded');
1568
+ }
1569
+ }
1570
+ parent.notify('selection', { prop: 'getFreehandDrawEditing', onPropertyChange: false, value: { obj: freehandObj } });
1571
+ if (freehandObj['bool']) {
1572
+ if (!isBlazor()) {
1573
+ parent.notify('toolbar', { prop: 'destroy-qa-toolbar', onPropertyChange: false });
1574
+ }
1575
+ else {
1576
+ parent.updateToolbar(parent.element, 'destroyQuickAccessToolbar');
1577
+ }
1578
+ }
1579
+ if (parent.activeObj.shape !== undefined) {
1580
+ isActiveObj = true;
1581
+ if (parent.textArea.style.display === 'block') {
1582
+ parent.notify('shape', { prop: 'redrawActObj', onPropertyChange: false,
1583
+ value: { x: null, y: null, isMouseDown: null } });
1584
+ if (!isBlazor()) {
1585
+ parent.notify('toolbar', { prop: 'destroy-qa-toolbar', onPropertyChange: false });
1586
+ }
1587
+ else {
1588
+ parent.updateToolbar(parent.element, 'destroyQuickAccessToolbar');
1589
+ }
1590
+ }
1591
+ else {
1592
+ parent.notify('shape', { prop: 'updImgRatioForActObj', onPropertyChange: false });
1593
+ parent.objColl.push(parent.activeObj);
1594
+ }
1595
+ parent.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
1596
+ }
1597
+ }
1598
+ var tempFilter = this.lowerContext.filter;
1552
1599
  var canvasWrapper = document.querySelector('#' + parent.element.id + '_canvasWrapper');
1553
- if (!isNullOrUndefined(canvasWrapper)) {
1600
+ if (canvasWrapper) {
1554
1601
  canvasWrapper.style.width = parent.element.offsetWidth - 2 + 'px';
1555
1602
  }
1556
1603
  parent.lowerCanvas.width = parent.upperCanvas.width = parent.element.offsetWidth - 2;
1557
- if (!isNullOrUndefined(parent.toolbarTemplate)) {
1558
- parent.notify('toolbar', { prop: 'setToolbarHeight', value: { height: 0 } });
1604
+ if (parent.toolbarTemplate) {
1605
+ toolbarHeight = parent.element.querySelector('#' + parent.element.id + '_toolbarArea').clientHeight;
1559
1606
  }
1560
1607
  else if (parent.element.querySelector('#' + parent.element.id + '_toolbar')) {
1561
1608
  toolbarHeight = parent.element.querySelector('#' + parent.element.id + '_toolbar').clientHeight;
1562
- parent.notify('toolbar', { prop: 'setToolbarHeight', value: { height: toolbarHeight } });
1563
1609
  }
1610
+ parent.notify('toolbar', { prop: 'setToolbarHeight', value: { height: toolbarHeight } });
1564
1611
  if (Browser.isDevice) {
1565
- if (!isNullOrUndefined(canvasWrapper)) {
1612
+ if (canvasWrapper) {
1566
1613
  canvasWrapper.style.height = parent.element.offsetHeight - (2 * toolbarHeight) - 5 + 'px';
1567
1614
  }
1568
1615
  parent.lowerCanvas.height = parent.upperCanvas.height = parent.element.offsetHeight - (2 * toolbarHeight) - 5;
1569
1616
  }
1570
1617
  else {
1571
- if (!isNullOrUndefined(canvasWrapper)) {
1618
+ if (canvasWrapper) {
1572
1619
  canvasWrapper.style.height = parent.element.offsetHeight - toolbarHeight - 3 + 'px';
1573
1620
  }
1574
1621
  parent.lowerCanvas.height = parent.upperCanvas.height = parent.element.offsetHeight - toolbarHeight - 3;
@@ -1577,10 +1624,144 @@ var Transform = /** @class */ (function () {
1577
1624
  'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
1578
1625
  'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
1579
1626
  parent.notify('filter', { prop: 'setAdjustmentValue', onPropertyChange: false, value: { adjustmentValue: this.lowerContext.filter } });
1580
- this.parent.canvasFilter = this.lowerContext.filter;
1627
+ parent.canvasFilter = this.lowerContext.filter;
1581
1628
  this.parent.initialAdjustmentValue = this.lowerContext.filter;
1582
- this.parent.clearContext(this.lowerContext);
1629
+ parent.clearContext(this.lowerContext);
1583
1630
  this.parent.clearContext(this.upperContext);
1631
+ if (parent.isImageLoaded) {
1632
+ parent.notify('shape', { prop: 'applyActObj', onPropertyChange: false, value: { isMouseDown: null } });
1633
+ parent.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
1634
+ this.lowerContext.filter = tempFilter;
1635
+ parent.initialAdjustmentValue = tempFilter;
1636
+ if (parent.isImageLoaded) {
1637
+ showSpinner(parent.element);
1638
+ parent.element.style.opacity = '0.5';
1639
+ }
1640
+ this.lowerContext.clearRect(0, 0, parent.lowerCanvas.width, parent.lowerCanvas.height);
1641
+ this.upperContext.clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
1642
+ if (canvasWrapper) {
1643
+ canvasWrapper.style.width = parent.element.offsetWidth - 2 + 'px';
1644
+ canvasWrapper.style.height = parent.element.offsetHeight + 'px';
1645
+ var obj_1 = { toolbarHeight: !isBlazor() ? 0 : parent.toolbarHeight };
1646
+ if (!isBlazor()) {
1647
+ parent.notify('toolbar', { prop: 'getToolbarHeight', value: { obj: obj_1 } });
1648
+ }
1649
+ if (Browser.isDevice) {
1650
+ canvasWrapper.style.height = (parseFloat(canvasWrapper.style.height) - (2 * obj_1['toolbarHeight'])) - 3 + 'px';
1651
+ }
1652
+ else {
1653
+ canvasWrapper.style.height = (parseFloat(canvasWrapper.style.height) - obj_1['toolbarHeight']) - 3 + 'px';
1654
+ }
1655
+ }
1656
+ var obj = { width: 0, height: 0 };
1657
+ parent.notify('transform', { prop: 'calcMaxDimension', onPropertyChange: false,
1658
+ value: { width: parent.img.srcWidth, height: parent.img.srcHeight, obj: obj } });
1659
+ var maxDimension = obj;
1660
+ if (parent.transform.defaultZoomFactor > 0) {
1661
+ maxDimension.width += (maxDimension.width * parent.transform.defaultZoomFactor);
1662
+ maxDimension.height += (maxDimension.height * parent.transform.defaultZoomFactor);
1663
+ }
1664
+ parent.img.destLeft = (parent.lowerCanvas.clientWidth - maxDimension.width) / 2;
1665
+ parent.img.destTop = (parent.lowerCanvas.clientHeight - maxDimension.height) / 2;
1666
+ if (parent.transform.degree === 0 && parent.transform.currFlipState === '') {
1667
+ if (parent.transform.defaultZoomFactor > 0) {
1668
+ parent.img.destLeft += parent.panPoint.totalPannedPoint.x;
1669
+ parent.img.destTop += parent.panPoint.totalPannedPoint.y;
1670
+ }
1671
+ parent.notify('draw', { prop: 'draw-image-to-canvas', value: { dimension: maxDimension } });
1672
+ }
1673
+ else {
1674
+ parent.notify('draw', { prop: 'draw-image-to-canvas', value: { dimension: maxDimension } });
1675
+ parent.notify('draw', { prop: 'updateCurrTransState', onPropertyChange: false,
1676
+ value: { type: 'initial', isPreventDestination: null, isRotatePan: null } });
1677
+ var temp = this.lowerContext.filter;
1678
+ parent.notify('filter', { prop: 'updateBrightFilter', onPropertyChange: false });
1679
+ 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);
1680
+ this.lowerContext.filter = temp;
1681
+ parent.notify('draw', { prop: 'updateCurrTransState', onPropertyChange: false,
1682
+ value: { type: 'reverse', isPreventDestination: null, isRotatePan: null } });
1683
+ }
1684
+ parent.notify('shape', { prop: 'zoomObjColl', onPropertyChange: false, value: { isPreventApply: null } });
1685
+ parent.notify('freehand-draw', { prop: 'zoomFHDColl', onPropertyChange: false, value: { isPreventApply: null } });
1686
+ if (parent.isCircleCrop) {
1687
+ parent.notify('crop', { prop: 'cropCircle', onPropertyChange: false,
1688
+ value: { context: this.lowerContext, isSave: null, isFlip: null } });
1689
+ }
1690
+ hideSpinner(parent.element);
1691
+ parent.element.style.opacity = '1';
1692
+ var obj1 = { defToolbarItems: null };
1693
+ if (!isBlazor()) {
1694
+ parent.notify('toolbar', { prop: 'getDefToolbarItems', value: { obj: obj1 } });
1695
+ if (obj1['defToolbarItems'] && obj1['defToolbarItems'].length > 0 && document.getElementById(parent.element.id + '_toolbar')) {
1696
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
1697
+ var toolbar_1 = getComponent(parent.element.id + '_toolbar', 'toolbar');
1698
+ toolbar_1.refreshOverflow();
1699
+ if (parent.element.querySelector('.e-contextual-toolbar-wrapper')) {
1700
+ parent.element.querySelector('.e-contextual-toolbar-wrapper').classList.add('e-hide');
1701
+ }
1702
+ }
1703
+ }
1704
+ parent.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
1705
+ this.upperContext.clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
1706
+ if (isActiveObj) {
1707
+ parent.activeObj = extend({}, parent.objColl[parent.objColl.length - 1], null, true);
1708
+ parent.objColl.pop();
1709
+ if (parent.activeObj.activePoint.width !== 0 && parent.activeObj.activePoint.height !== 0) {
1710
+ parent.notify('draw', { prop: 'drawObject', onPropertyChange: false, value: { canvas: 'duplicate', obj: parent.activeObj } });
1711
+ if (parent.activeObj.shape === 'rectangle' || parent.activeObj.shape === 'ellipse' || parent.activeObj.shape === 'text' ||
1712
+ parent.activeObj.shape === 'line' || parent.activeObj.shape === 'arrow' || parent.activeObj.shape === 'path') {
1713
+ if (!isBlazor()) {
1714
+ parent.notify('toolbar', { prop: 'renderQAT', onPropertyChange: false, value: { isPenEdit: null } });
1715
+ }
1716
+ else {
1717
+ parent.updateToolbar(parent.element, 'quickAccessToolbar', parent.activeObj.shape);
1718
+ }
1719
+ }
1720
+ }
1721
+ }
1722
+ if (freehandObj['bool']) {
1723
+ if (!isBlazor()) {
1724
+ parent.notify('toolbar', { prop: 'renderQAT', onPropertyChange: false, value: { isPenEdit: true } });
1725
+ }
1726
+ else {
1727
+ parent.updateToolbar(parent.element, 'quickAccessToolbar', 'pen');
1728
+ }
1729
+ }
1730
+ if ((parent.transform.degree !== 0 || parent.transform.currFlipState !== '') && parent.transform.defaultZoomFactor > 0) {
1731
+ var totalPannedPoint = extend({}, parent.panPoint.totalPannedPoint, null, true);
1732
+ var totalPannedInternalPoint = extend({}, parent.panPoint.totalPannedInternalPoint, null, true);
1733
+ var totalPannedClientPoint = extend({}, parent.panPoint.totalPannedClientPoint, null, true);
1734
+ parent.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
1735
+ value: { zoomFactor: .1, zoomPoint: null } });
1736
+ parent.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
1737
+ value: { zoomFactor: -.1, zoomPoint: null } });
1738
+ if (parent.transform.degree === 0) {
1739
+ parent.img.destLeft += totalPannedPoint.x;
1740
+ parent.img.destTop += totalPannedPoint.y;
1741
+ parent.panPoint.totalPannedPoint = totalPannedPoint;
1742
+ parent.notify('draw', { prop: 'updateFlipPan', value: { tempSelectionObj: null } });
1743
+ }
1744
+ else {
1745
+ parent.panPoint.totalPannedInternalPoint = totalPannedInternalPoint;
1746
+ parent.panPoint.totalPannedClientPoint = totalPannedClientPoint;
1747
+ parent.panPoint.currentPannedPoint = { x: 0, y: 0 };
1748
+ parent.isCropTab = true;
1749
+ parent.notify('transform', { prop: 'rotatePan', onPropertyChange: false,
1750
+ value: { isCropSelection: null, isDefaultZoom: null } });
1751
+ parent.isCropTab = false;
1752
+ }
1753
+ }
1754
+ else if (parent.transform.degree !== 0 && parent.transform.cropZoomFactor > 0) {
1755
+ parent.transform.zoomFactor = 0;
1756
+ parent.transform.cropZoomFactor = null;
1757
+ if (!isBlazor()) {
1758
+ parent.notify('toolbar', { prop: 'enable-disable-btns', onPropertyChange: false });
1759
+ }
1760
+ else {
1761
+ parent.updateToolbar(parent.element, 'enableDisableToolbarBtn');
1762
+ }
1763
+ }
1764
+ }
1584
1765
  };
1585
1766
  Transform.prototype.calcMaxDimension = function (width, height, obj) {
1586
1767
  var object = { toolbarHeight: 0 };
@@ -1611,7 +1792,15 @@ var Transform = /** @class */ (function () {
1611
1792
  cssMaxWidth = width * heightScale;
1612
1793
  cssMaxHeight = height * heightScale;
1613
1794
  }
1614
- if (!isNullOrUndefined(obj)) {
1795
+ var cropObj = { bool: null };
1796
+ this.parent.notify('crop', { prop: 'getPreventScaling', onPropertyChange: false,
1797
+ value: { obj: cropObj } });
1798
+ if (cropObj['bool'] && this.parent.cropObj.activeObj.activePoint &&
1799
+ this.parent.cropObj.activeObj.activePoint.width !== 0 && this.parent.cropObj.activeObj.activePoint.height !== 0) {
1800
+ cssMaxWidth = this.parent.cropObj.activeObj.activePoint.width;
1801
+ cssMaxHeight = this.parent.cropObj.activeObj.activePoint.height;
1802
+ }
1803
+ if (obj) {
1615
1804
  obj['width'] = cssMaxWidth;
1616
1805
  obj['height'] = cssMaxHeight;
1617
1806
  }
@@ -1659,7 +1848,7 @@ var Transform = /** @class */ (function () {
1659
1848
  }
1660
1849
  this.limitPan();
1661
1850
  parent.activeObj = tempActObj;
1662
- if (!isNullOrUndefined(obj)) {
1851
+ if (obj) {
1663
1852
  obj['x'] = parent.img.destLeft - tempDestLeft;
1664
1853
  obj['y'] = parent.img.destTop - tempDestTop;
1665
1854
  }
@@ -24,10 +24,10 @@ var UndoRedo = /** @class */ (function () {
24
24
  this.parent.off('destroyed', this.destroy);
25
25
  };
26
26
  UndoRedo.prototype.initializeUrPvtProp = function () {
27
- if (!isNullOrUndefined(this.parent.lowerCanvas)) {
27
+ if (this.parent.lowerCanvas) {
28
28
  this.lowerContext = this.parent.lowerCanvas.getContext('2d');
29
29
  }
30
- if (!isNullOrUndefined(this.parent.upperCanvas)) {
30
+ if (this.parent.upperCanvas) {
31
31
  this.upperContext = this.parent.upperCanvas.getContext('2d');
32
32
  }
33
33
  };
@@ -247,14 +247,16 @@ var UndoRedo = /** @class */ (function () {
247
247
  if (!parent.disabled && parent.isImageLoaded) {
248
248
  if (this.undoRedoStep > 0) {
249
249
  this.refreshToolbarActions();
250
- if (!isNullOrUndefined(parent.activeObj.activePoint) && parent.activeObj.activePoint.width !== 0) {
250
+ if (parent.activeObj.activePoint && parent.activeObj.activePoint.width !== 0) {
251
251
  this.tempActObj = parent.activeObj;
252
252
  }
253
253
  parent.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
254
254
  this.undoRedoStep--;
255
255
  if (!isBlazor()) {
256
256
  parent.notify('toolbar', { prop: 'enable-disable-btns' });
257
- parent.element.querySelector('.e-contextual-toolbar-wrapper').classList.add('e-hide');
257
+ if (parent.element.querySelector('.e-contextual-toolbar-wrapper')) {
258
+ parent.element.querySelector('.e-contextual-toolbar-wrapper').classList.add('e-hide');
259
+ }
258
260
  }
259
261
  else {
260
262
  parent.updateToolbar(parent.element, 'enableDisableToolbarBtn');
@@ -357,7 +359,7 @@ var UndoRedo = /** @class */ (function () {
357
359
  parent.cropObj = extend({}, obj.currentCropObj, {}, true);
358
360
  parent.afterCropActions = obj.currentObj.afterCropActions;
359
361
  this.lowerContext.filter = obj.currentObj.filter;
360
- if (!isBlazor()) {
362
+ if (!isBlazor() && parent.element.querySelector('.e-contextual-toolbar-wrapper')) {
361
363
  parent.element.querySelector('.e-contextual-toolbar-wrapper').classList.add('e-hide');
362
364
  }
363
365
  parent.canvasFilter = this.lowerContext.filter;
@@ -419,10 +421,10 @@ var UndoRedo = /** @class */ (function () {
419
421
  if (obj.operation === 'crop' && !obj.isCircleCrop) {
420
422
  parent.isCircleCrop = false;
421
423
  }
422
- if (obj.operation === 'crop' && !isNullOrUndefined(obj.currentObj.currSelectionPoint)) {
424
+ if (obj.operation === 'crop' && obj.currentObj.currSelectionPoint) {
423
425
  parent.currSelectionPoint = extend({}, obj.currentObj.currSelectionPoint, {}, true);
424
426
  }
425
- if (!isNullOrUndefined(parent.currSelectionPoint) && isNullOrUndefined(parent.currSelectionPoint.shape)) {
427
+ if (parent.currSelectionPoint && isNullOrUndefined(parent.currSelectionPoint.shape)) {
426
428
  parent.currSelectionPoint = null;
427
429
  }
428
430
  this.endUndoRedo(obj.operation, false);
@@ -270,7 +270,7 @@ export interface ImageEditorModel extends ComponentModel{
270
270
  * - Save: save the modified image.
271
271
  * - Open: open an image to perform editing.
272
272
  * - Reset: reset the modification and restore the original image.
273
- *
273
+ *
274
274
  * {% codeBlock src='image-editor/toolbar/index.md' %}{% endcodeBlock %}
275
275
  *
276
276
  * @remarks
@@ -285,7 +285,7 @@ export interface ImageEditorModel extends ComponentModel{
285
285
  * A string that specifies a custom template for the toolbar of the image editor. If this property is defined, the 'toolbar' property will not have any effect.
286
286
  *
287
287
  * {% codeBlock src='image-editor/toolbarTemplate/index.md' %}{% endcodeBlock %}
288
- *
288
+ *
289
289
  * @remarks
290
290
  * Use this property if you want to customize the entire toolbar in your own way. The template should be a string that contains the HTML markup for the custom toolbar.
291
291
  *
@@ -939,9 +939,7 @@ export declare class ImageEditor extends Component<HTMLDivElement> implements IN
939
939
  * @param {string} strokeColor - Specifies the stroke color of arrow.
940
940
  * @param {ArrowheadType} arrowStart – Specifies the type of arrowhead for start position. The default value is ‘None’.
941
941
  * @param {ArrowheadType} arrowEnd – Specifies the type of arrowhead for end position. The default value is ‘SolidArrow’.
942
-
943
942
  * @returns {boolean}.
944
- * @private
945
943
  */
946
944
  drawArrow(startX?: number, startY?: number, endX?: number, endY?: number, strokeWidth?: number, strokeColor?: string, arrowStart?: ArrowheadType, arrowEnd?: ArrowheadType): boolean;
947
945
  /**
@@ -1083,9 +1081,6 @@ export declare class ImageEditor extends Component<HTMLDivElement> implements IN
1083
1081
  private setPenStroke;
1084
1082
  private updateFreehandDrawColorChange;
1085
1083
  private setInitialZoomState;
1086
- private moveToSelectionRange;
1087
- private isSelectionBiggerThanCanvas;
1088
- private isSelectionOutsideCanvas;
1089
1084
  /**
1090
1085
  * Set the old item Transform item state.
1091
1086
  *
@@ -1150,16 +1145,6 @@ export declare class ImageEditor extends Component<HTMLDivElement> implements IN
1150
1145
  * @returns {void}.
1151
1146
  */
1152
1147
  setCurrAdjustmentValue(type: string, value: number): void;
1153
- /**
1154
- * Get the square point for rotated shape.
1155
- *
1156
- * @param { SelectionPoint } obj - Specifies the selection point.
1157
- * @param { Object } object - Specifies the object.
1158
- * @hidden
1159
- * @returns {ActivePoint}.
1160
- * An ActivePoint object which returns the square point.
1161
- */
1162
- getSquarePointForRotatedShape(obj: SelectionPoint, object?: Object): ActivePoint;
1163
1148
  /**
1164
1149
  * Get the square point for path.
1165
1150
  *