@syncfusion/ej2-image-editor 25.2.4 → 26.1.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. package/.eslintrc.json +3 -2
  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 +2691 -830
  5. package/dist/es6/ej2-image-editor.es2015.js.map +1 -1
  6. package/dist/es6/ej2-image-editor.es5.js +2788 -887
  7. package/dist/es6/ej2-image-editor.es5.js.map +1 -1
  8. package/dist/global/ej2-image-editor.min.js +2 -2
  9. package/dist/global/ej2-image-editor.min.js.map +1 -1
  10. package/dist/global/index.d.ts +1 -1
  11. package/package.json +13 -12
  12. package/src/image-editor/action/crop.d.ts +0 -1
  13. package/src/image-editor/action/crop.js +35 -77
  14. package/src/image-editor/action/draw.d.ts +3 -0
  15. package/src/image-editor/action/draw.js +198 -83
  16. package/src/image-editor/action/export.d.ts +3 -0
  17. package/src/image-editor/action/export.js +99 -41
  18. package/src/image-editor/action/filter.d.ts +0 -1
  19. package/src/image-editor/action/filter.js +4 -24
  20. package/src/image-editor/action/freehand-draw.js +30 -8
  21. package/src/image-editor/action/selection.d.ts +10 -0
  22. package/src/image-editor/action/selection.js +444 -99
  23. package/src/image-editor/action/shape.d.ts +11 -1
  24. package/src/image-editor/action/shape.js +520 -127
  25. package/src/image-editor/action/transform.d.ts +0 -1
  26. package/src/image-editor/action/transform.js +53 -69
  27. package/src/image-editor/action/undo-redo.d.ts +2 -0
  28. package/src/image-editor/action/undo-redo.js +114 -29
  29. package/src/image-editor/base/enum.d.ts +5 -1
  30. package/src/image-editor/base/enum.js +4 -0
  31. package/src/image-editor/base/image-editor-model.d.ts +8 -6
  32. package/src/image-editor/base/image-editor.d.ts +116 -7
  33. package/src/image-editor/base/image-editor.js +385 -53
  34. package/src/image-editor/base/interface.d.ts +17 -0
  35. package/src/image-editor/base/interface.js +0 -1
  36. package/src/image-editor/renderer/toolbar.d.ts +14 -1
  37. package/src/image-editor/renderer/toolbar.js +831 -191
  38. package/styles/bootstrap-dark.css +279 -97
  39. package/styles/bootstrap-dark.scss +13 -1
  40. package/styles/bootstrap.css +282 -98
  41. package/styles/bootstrap.scss +13 -1
  42. package/styles/bootstrap4.css +280 -97
  43. package/styles/bootstrap4.scss +13 -1
  44. package/styles/bootstrap5-dark.css +280 -101
  45. package/styles/bootstrap5-dark.scss +13 -1
  46. package/styles/bootstrap5.css +280 -101
  47. package/styles/bootstrap5.scss +13 -1
  48. package/styles/fabric-dark.css +281 -97
  49. package/styles/fabric-dark.scss +13 -1
  50. package/styles/fabric.css +284 -97
  51. package/styles/fabric.scss +13 -1
  52. package/styles/fluent-dark.css +287 -101
  53. package/styles/fluent-dark.scss +13 -1
  54. package/styles/fluent.css +287 -101
  55. package/styles/fluent.scss +13 -1
  56. package/styles/fluent2.css +1852 -0
  57. package/styles/fluent2.scss +13 -0
  58. package/styles/highcontrast-light.css +279 -97
  59. package/styles/highcontrast-light.scss +13 -1
  60. package/styles/highcontrast.css +284 -97
  61. package/styles/highcontrast.scss +13 -1
  62. package/styles/image-editor/_bds-definition.scss +5 -0
  63. package/styles/image-editor/_bootstrap-dark-definition.scss +5 -0
  64. package/styles/image-editor/_bootstrap-definition.scss +5 -0
  65. package/styles/image-editor/_bootstrap4-definition.scss +5 -0
  66. package/styles/image-editor/_bootstrap5-definition.scss +5 -0
  67. package/styles/image-editor/_bootstrap5.3-definition.scss +26 -0
  68. package/styles/image-editor/_fabric-dark-definition.scss +5 -0
  69. package/styles/image-editor/_fabric-definition.scss +5 -0
  70. package/styles/image-editor/_fluent-definition.scss +5 -0
  71. package/styles/image-editor/_fluent2-definition.scss +26 -0
  72. package/styles/image-editor/_fusionnew-definition.scss +5 -0
  73. package/styles/image-editor/_highcontrast-definition.scss +5 -0
  74. package/styles/image-editor/_highcontrast-light-definition.scss +5 -0
  75. package/styles/image-editor/_layout.scss +355 -13
  76. package/styles/image-editor/_material-dark-definition.scss +5 -0
  77. package/styles/image-editor/_material-definition.scss +5 -0
  78. package/styles/image-editor/_material3-definition.scss +5 -0
  79. package/styles/image-editor/_tailwind-definition.scss +5 -0
  80. package/styles/image-editor/bootstrap-dark.css +279 -97
  81. package/styles/image-editor/bootstrap.css +282 -98
  82. package/styles/image-editor/bootstrap4.css +280 -97
  83. package/styles/image-editor/bootstrap5-dark.css +280 -101
  84. package/styles/image-editor/bootstrap5.css +280 -101
  85. package/styles/image-editor/fabric-dark.css +281 -97
  86. package/styles/image-editor/fabric.css +284 -97
  87. package/styles/image-editor/fluent-dark.css +287 -101
  88. package/styles/image-editor/fluent.css +287 -101
  89. package/styles/image-editor/fluent2.css +1852 -0
  90. package/styles/image-editor/fluent2.scss +13 -0
  91. package/styles/image-editor/highcontrast-light.css +279 -97
  92. package/styles/image-editor/highcontrast.css +284 -97
  93. package/styles/image-editor/icons/_bds.scss +1 -162
  94. package/styles/image-editor/icons/_bootstrap-dark.scss +1 -162
  95. package/styles/image-editor/icons/_bootstrap.scss +1 -162
  96. package/styles/image-editor/icons/_bootstrap4.scss +1 -162
  97. package/styles/image-editor/icons/_bootstrap5.3.scss +250 -0
  98. package/styles/image-editor/icons/_bootstrap5.scss +1 -168
  99. package/styles/image-editor/icons/_fabric-dark.scss +1 -162
  100. package/styles/image-editor/icons/_fabric.scss +1 -162
  101. package/styles/image-editor/icons/_fluent.scss +1 -168
  102. package/styles/image-editor/icons/_fluent2.scss +256 -0
  103. package/styles/image-editor/icons/_fusionnew.scss +1 -138
  104. package/styles/image-editor/icons/_highcontrast-light.scss +1 -162
  105. package/styles/image-editor/icons/_highcontrast.scss +1 -162
  106. package/styles/image-editor/icons/_material-dark.scss +2 -163
  107. package/styles/image-editor/icons/_material.scss +1 -162
  108. package/styles/image-editor/icons/_material3.scss +2 -169
  109. package/styles/image-editor/icons/_tailwind.scss +1 -162
  110. package/styles/image-editor/material-dark.css +299 -100
  111. package/styles/image-editor/material.css +302 -100
  112. package/styles/image-editor/material3-dark.css +314 -103
  113. package/styles/image-editor/material3.css +314 -103
  114. package/styles/image-editor/tailwind-dark.css +284 -97
  115. package/styles/image-editor/tailwind.css +284 -97
  116. package/styles/material-dark.css +299 -100
  117. package/styles/material-dark.scss +13 -1
  118. package/styles/material.css +302 -100
  119. package/styles/material.scss +13 -1
  120. package/styles/material3-dark.css +314 -103
  121. package/styles/material3-dark.scss +13 -1
  122. package/styles/material3.css +314 -103
  123. package/styles/material3.scss +13 -1
  124. package/styles/tailwind-dark.css +284 -97
  125. package/styles/tailwind-dark.scss +13 -1
  126. package/styles/tailwind.css +284 -97
  127. package/styles/tailwind.scss +13 -1
  128. package/CHANGELOG.md +0 -289
@@ -18,7 +18,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
18
18
  return c > 3 && r && Object.defineProperty(target, key, r), r;
19
19
  };
20
20
  import { Component, NotifyPropertyChanges, Property, addClass, removeClass, extend } from '@syncfusion/ej2-base';
21
- import { Event, EventHandler, getComponent, isNullOrUndefined, getUniqueID } from '@syncfusion/ej2-base';
21
+ import { Event, EventHandler, getComponent, isNullOrUndefined, getUniqueID, setValue } from '@syncfusion/ej2-base';
22
22
  import { Dialog, createSpinner } from '@syncfusion/ej2-popups';
23
23
  import { Complex, Browser, ChildProperty, compile as templateCompiler, compile } from '@syncfusion/ej2-base';
24
24
  import { ToolbarModule, Crop, Draw, Filter, FreehandDrawing, Selection, Shape, Transform, UndoRedo, Export, FrameLineStyle, ShapeType } from './../index';
@@ -147,7 +147,7 @@ var ImageEditor = /** @class */ (function (_super) {
147
147
  _this.isImageLoaded = false;
148
148
  /** @hidden */
149
149
  _this.activeObj = { activePoint: { startX: 0, startY: 0, endX: 0, endY: 0, width: 0, height: 0 },
150
- flipObjColl: [], triangle: [], triangleRatio: [], rotatedAngle: 0, opacity: 1 };
150
+ flipObjColl: [], triangle: [], triangleRatio: [], rotatedAngle: 0, opacity: 1, order: null };
151
151
  // current object's ui interaction properties
152
152
  /** @hidden */
153
153
  _this.currObjType = { shape: '', isDragging: false, isActiveObj: false, isText: false, isInitialText: false, isLine: false, isInitialLine: false,
@@ -252,6 +252,15 @@ var ImageEditor = /** @class */ (function (_super) {
252
252
  _this.isFrameBtnClick = false;
253
253
  /** @hidden */
254
254
  _this.isChangesSaved = false;
255
+ /** @hidden */
256
+ _this.isShapeDrawing = false;
257
+ /** @hidden */
258
+ _this.noPushUndo = false;
259
+ /** @hidden */
260
+ _this.isUndoRedoStack = false;
261
+ /** @hidden */
262
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
263
+ _this.shapeColl = [];
255
264
  ImageEditor_1.Inject(Crop, Draw, Selection, Transform, Export, ToolbarModule);
256
265
  ImageEditor_1.Inject(UndoRedo);
257
266
  ImageEditor_1.Inject(Filter);
@@ -299,6 +308,14 @@ var ImageEditor = /** @class */ (function (_super) {
299
308
  * @returns {void}
300
309
  */
301
310
  ImageEditor.prototype.render = function () {
311
+ if (this.isAngular) {
312
+ var originalElement = this.element;
313
+ var clonedElement = originalElement.cloneNode(true);
314
+ originalElement.parentNode.replaceChild(clonedElement, originalElement);
315
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
316
+ this.element = clonedElement;
317
+ setValue('ej2_instances', [this], this.element);
318
+ }
302
319
  this.initialize();
303
320
  };
304
321
  /**
@@ -468,6 +485,10 @@ var ImageEditor = /** @class */ (function (_super) {
468
485
  ImageEditor.prototype.destroy = function () {
469
486
  var classList = [];
470
487
  this.element.removeAttribute('tabindex');
488
+ var saveDialog = this.element.querySelector('#' + this.element.id + '_saveDialog');
489
+ if (saveDialog && saveDialog.style.display === 'block') {
490
+ getComponent(document.getElementById(this.element.id + '_saveDialog'), 'dialog').destroy();
491
+ }
471
492
  if (this.cssClass) {
472
493
  classList = classList.concat(this.cssClass.replace(/\s+/g, ' ').trim().split(' '));
473
494
  }
@@ -535,6 +556,9 @@ var ImageEditor = /** @class */ (function (_super) {
535
556
  });
536
557
  }
537
558
  this.initializeZoomSettings();
559
+ if (this.imgSrc) {
560
+ this.open(this.imgSrc);
561
+ }
538
562
  };
539
563
  ImageEditor.prototype.createDropUploader = function () {
540
564
  var _this = this;
@@ -547,10 +571,12 @@ var ImageEditor = /** @class */ (function (_super) {
547
571
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
548
572
  var type = args.filesData[0].type;
549
573
  var errType = 'unsupported';
574
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
550
575
  if ((args.event.type === 'change' || (args.event.type === 'drop' && args.event.dataTransfer.files.length === 1)) && (type === 'png' || type === 'jpg' || type === 'jpeg' || type === 'svg')) {
551
576
  _this.notify('draw', { prop: 'fileSelect', value: { inputElement: _this.element.querySelector('#' + _this.element.id + '_dropfileUpload'), args: args } });
552
577
  }
553
578
  else {
579
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
554
580
  if (args.event.type === 'drop' && args.event.dataTransfer.files.length > 1) {
555
581
  errType = 'multi-select-image';
556
582
  }
@@ -785,8 +811,8 @@ var ImageEditor = /** @class */ (function (_super) {
785
811
  this.notify('selection', { prop: 'keyDownEventHandler', onPropertyChange: false, value: { e: e } });
786
812
  };
787
813
  ImageEditor.prototype.keyUpEventHandler = function (e) {
788
- // eslint-disable-next-line
789
814
  if ((this.textArea.style.display === 'block' || this.textArea.style.display === 'inline-block')
815
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
790
816
  && e.target.id === this.element.id + '_textArea') {
791
817
  this.notify('selection', { prop: 'textKeyDown', value: { e: e } });
792
818
  }
@@ -831,6 +857,7 @@ var ImageEditor = /** @class */ (function (_super) {
831
857
  };
832
858
  ImageEditor.prototype.allowShape = function (x, y) {
833
859
  this.isPublicMethod = true;
860
+ this.applyShapes();
834
861
  var obj = { inRange: false };
835
862
  this.notify('shape', { prop: 'isPointsInRange', onPropertyChange: false,
836
863
  value: { x: x, y: y, obj: obj } });
@@ -892,11 +919,7 @@ var ImageEditor = /** @class */ (function (_super) {
892
919
  */
893
920
  ImageEditor.prototype.getImageData = function () {
894
921
  var obj = { canvas: null };
895
- var dummyObj = { bool: false };
896
- this.notify('selection', { prop: 'getFreehandDrawEditing', onPropertyChange: false, value: { obj: dummyObj } });
897
- if (dummyObj['bool'] || this.togglePen || this.activeObj.shape) {
898
- this.okBtn();
899
- }
922
+ this.applyShapes();
900
923
  this.notify('export', { prop: 'exportToCanvas', value: { object: obj } });
901
924
  return obj['canvas'].getContext('2d').getImageData(0, 0, obj['canvas'].width, obj['canvas'].height);
902
925
  };
@@ -914,7 +937,10 @@ var ImageEditor = /** @class */ (function (_super) {
914
937
  if (isNullOrUndefined(data)) {
915
938
  return;
916
939
  }
917
- document.getElementById(this.element.id + '_dropArea').style.display = 'none';
940
+ var dropArea = document.getElementById(this.element.id + '_dropArea');
941
+ if (dropArea) {
942
+ dropArea.style.display = 'none';
943
+ }
918
944
  this.notify('draw', { prop: 'open', value: { data: data } });
919
945
  };
920
946
  /**
@@ -940,6 +966,7 @@ var ImageEditor = /** @class */ (function (_super) {
940
966
  this.notify('toolbar', { prop: 'create-bottom-toolbar', onPropertyChange: false });
941
967
  }
942
968
  var isImageLoaded = this.isImageLoaded;
969
+ // eslint-disable-next-line max-len
943
970
  this.currObjType.isUndoAction = this.isUndoRedo = this.togglePan = this.togglePen = this.isImageLoaded = this.isFinetuning = false;
944
971
  this.isCircleCrop = this.isCropTab = false;
945
972
  this.objColl = [];
@@ -991,6 +1018,9 @@ var ImageEditor = /** @class */ (function (_super) {
991
1018
  this.cancelCropSelection = null;
992
1019
  this.aspectWidth = this.aspectHeight = null;
993
1020
  this.isResize = false;
1021
+ this.drawingShape = null;
1022
+ this.isShapeDrawing = this.noPushUndo = this.isUndoRedoStack = false;
1023
+ this.shapeColl = [];
994
1024
  var obj_1 = { initialZoomValue: false };
995
1025
  this.notify('draw', { prop: 'getInitialZoomValue', onPropertyChange: false, value: { obj: obj_1 } });
996
1026
  if (obj_1['initialZoomValue']) {
@@ -1062,6 +1092,7 @@ var ImageEditor = /** @class */ (function (_super) {
1062
1092
  * @returns {void}.
1063
1093
  */
1064
1094
  ImageEditor.prototype.export = function (type, fileName) {
1095
+ this.applyShapes();
1065
1096
  this.notify('export', { prop: 'export', onPropertyChange: false, value: { type: type, fileName: fileName } });
1066
1097
  };
1067
1098
  /**
@@ -1082,6 +1113,7 @@ var ImageEditor = /** @class */ (function (_super) {
1082
1113
  *
1083
1114
  */
1084
1115
  ImageEditor.prototype.select = function (type, startX, startY, width, height) {
1116
+ this.applyShapes();
1085
1117
  this.notify('toolbar', { prop: 'performCropTransformClick', value: { shape: 'crop-' + type } });
1086
1118
  this.notify('draw', { prop: 'select', onPropertyChange: false,
1087
1119
  value: { type: type, startX: startX, startY: startY, width: width, height: height } });
@@ -1123,6 +1155,7 @@ var ImageEditor = /** @class */ (function (_super) {
1123
1155
  */
1124
1156
  ImageEditor.prototype.freehandDraw = function (value) {
1125
1157
  if (!this.disabled && this.isImageLoaded) {
1158
+ this.applyShapes();
1126
1159
  this.freeHandDraw(value);
1127
1160
  }
1128
1161
  };
@@ -1139,6 +1172,7 @@ var ImageEditor = /** @class */ (function (_super) {
1139
1172
  * @returns {void}.
1140
1173
  */
1141
1174
  ImageEditor.prototype.pan = function (value, x, y) {
1175
+ this.applyShapes();
1142
1176
  this.notify('transform', { prop: 'pan', onPropertyChange: false, value: { value: value, x: x, y: y } });
1143
1177
  };
1144
1178
  /**
@@ -1260,6 +1294,7 @@ var ImageEditor = /** @class */ (function (_super) {
1260
1294
  }
1261
1295
  if (!this.disabled && this.isImageLoaded && (obj['inRange'] || isNullOrUndefined(pointColl))) {
1262
1296
  isPath = true;
1297
+ this.applyShapes();
1263
1298
  this.notify('shape', { prop: 'drawPath', onPropertyChange: false, value: { pointColl: pointColl,
1264
1299
  strokeWidth: strokeWidth, strokeColor: strokeColor, isSelected: isSelected } });
1265
1300
  this.notify('draw', { prop: 'redrawDownScale' });
@@ -1305,16 +1340,17 @@ var ImageEditor = /** @class */ (function (_super) {
1305
1340
  * @param {boolean} italic - Specifies whether the text is italic or not.
1306
1341
  * @param {string} color - Specifies font color of the text.
1307
1342
  * @param {boolean} isSelected - Specifies to show the text in the selected state.
1343
+ * @param {number} degree - Specifies the degree to rotate the text.
1308
1344
  * @returns {boolean}.
1309
1345
  *
1310
1346
  */
1311
- ImageEditor.prototype.drawText = function (x, y, text, fontFamily, fontSize, bold, italic, color, isSelected) {
1347
+ ImageEditor.prototype.drawText = function (x, y, text, fontFamily, fontSize, bold, italic, color, isSelected, degree) {
1312
1348
  var isText = false;
1313
1349
  var isPointsInRange = this.allowShape(x, y);
1314
1350
  if (!this.disabled && this.isImageLoaded && (isPointsInRange || (isNullOrUndefined(x) && isNullOrUndefined(y)))) {
1315
1351
  isText = true;
1316
1352
  this.notify('shape', { prop: 'drawText', onPropertyChange: false, value: { x: x, y: y, text: text, fontFamily: fontFamily,
1317
- fontSize: fontSize, bold: bold, italic: italic, color: color, isSelected: isSelected } });
1353
+ fontSize: fontSize, bold: bold, italic: italic, color: color, isSelected: isSelected, degree: degree } });
1318
1354
  this.notify('draw', { prop: 'redrawDownScale' });
1319
1355
  }
1320
1356
  return isText;
@@ -1360,6 +1396,7 @@ var ImageEditor = /** @class */ (function (_super) {
1360
1396
  *
1361
1397
  */
1362
1398
  ImageEditor.prototype.selectShape = function (id) {
1399
+ this.applyShapes();
1363
1400
  var obj = { isSelected: false };
1364
1401
  this.notify('shape', { prop: 'selectShape', onPropertyChange: false, value: { id: id, obj: obj } });
1365
1402
  this.notify('draw', { prop: 'redrawDownScale' });
@@ -1376,6 +1413,7 @@ var ImageEditor = /** @class */ (function (_super) {
1376
1413
  *
1377
1414
  */
1378
1415
  ImageEditor.prototype.deleteShape = function (id) {
1416
+ this.applyShapes();
1379
1417
  this.notify('shape', { prop: 'deleteShape', onPropertyChange: false, value: { id: id } });
1380
1418
  this.notify('draw', { prop: 'redrawDownScale' });
1381
1419
  };
@@ -1389,6 +1427,7 @@ var ImageEditor = /** @class */ (function (_super) {
1389
1427
  *
1390
1428
  */
1391
1429
  ImageEditor.prototype.getShapeSetting = function (id) {
1430
+ this.applyShapes();
1392
1431
  var obj = { shapeDetails: null };
1393
1432
  this.notify('shape', { prop: 'getShapeSetting', onPropertyChange: false,
1394
1433
  value: { id: id, obj: obj } });
@@ -1402,6 +1441,7 @@ var ImageEditor = /** @class */ (function (_super) {
1402
1441
  * @returns {ShapeSettings[]}.
1403
1442
  */
1404
1443
  ImageEditor.prototype.getShapeSettings = function () {
1444
+ this.applyShapes();
1405
1445
  var obj = { shapeDetailsColl: [] };
1406
1446
  this.notify('shape', { prop: 'getShapeSettings', onPropertyChange: false, value: { obj: obj } });
1407
1447
  this.notify('draw', { prop: 'redrawDownScale' });
@@ -1429,6 +1469,7 @@ var ImageEditor = /** @class */ (function (_super) {
1429
1469
  */
1430
1470
  ImageEditor.prototype.finetuneImage = function (finetuneOption, value) {
1431
1471
  if (!this.disabled && this.isImageLoaded) {
1472
+ this.applyShapes();
1432
1473
  this.notify('filter', { prop: 'finetuneImage', value: { value: value, option: finetuneOption } });
1433
1474
  this.notify('draw', { prop: 'redrawDownScale' });
1434
1475
  }
@@ -1444,6 +1485,7 @@ var ImageEditor = /** @class */ (function (_super) {
1444
1485
  */
1445
1486
  ImageEditor.prototype.applyImageFilter = function (filterOption) {
1446
1487
  if (!this.disabled && this.isImageLoaded) {
1488
+ this.applyShapes();
1447
1489
  this.notify('filter', { prop: 'applyImageFilter', value: { option: filterOption.toString() } });
1448
1490
  this.notify('draw', { prop: 'redrawDownScale' });
1449
1491
  this.canvasFilter = this.lowerContext.filter;
@@ -1459,6 +1501,7 @@ var ImageEditor = /** @class */ (function (_super) {
1459
1501
  * @returns {void}.
1460
1502
  */
1461
1503
  ImageEditor.prototype.undo = function () {
1504
+ this.applyShapes();
1462
1505
  this.notify('undo-redo', { prop: 'undo', onPropertyChange: false });
1463
1506
  this.notify('draw', { prop: 'redrawDownScale' });
1464
1507
  };
@@ -1470,6 +1513,7 @@ var ImageEditor = /** @class */ (function (_super) {
1470
1513
  * @returns {void}.
1471
1514
  */
1472
1515
  ImageEditor.prototype.redo = function () {
1516
+ this.applyShapes();
1473
1517
  this.notify('undo-redo', { prop: 'redo', onPropertyChange: false });
1474
1518
  this.notify('draw', { prop: 'redrawDownScale' });
1475
1519
  };
@@ -1495,6 +1539,7 @@ var ImageEditor = /** @class */ (function (_super) {
1495
1539
  ImageEditor.prototype.resize = function (width, height, isAspectRatio) {
1496
1540
  var isResized = false;
1497
1541
  if ((width.toString()).length <= 4 && (height.toString()).length <= 4) {
1542
+ this.applyShapes();
1498
1543
  var destPoints = { startX: this.img.destLeft, startY: this.img.destTop, width: this.img.destWidth,
1499
1544
  height: this.img.destHeight };
1500
1545
  if (isAspectRatio) {
@@ -1544,6 +1589,7 @@ var ImageEditor = /** @class */ (function (_super) {
1544
1589
  * @returns {boolean}.
1545
1590
  */
1546
1591
  ImageEditor.prototype.drawFrame = function (frameType, color, gradientColor, size, inset, offset, borderRadius, frameLineStyle, lineCount) {
1592
+ this.applyShapes();
1547
1593
  var isFrame = false;
1548
1594
  var obj = { frameChangeEventArgs: null };
1549
1595
  color = color ? color : '#fff';
@@ -1604,6 +1650,7 @@ var ImageEditor = /** @class */ (function (_super) {
1604
1650
  ImageEditor.prototype.straightenImage = function (degree) {
1605
1651
  var isStraightened = false;
1606
1652
  if (degree >= -45 && degree <= 45) {
1653
+ this.applyShapes();
1607
1654
  isStraightened = true;
1608
1655
  this.notify('transform', { prop: 'straightenImage', value: { degree: degree } });
1609
1656
  this.notify('draw', { prop: 'redrawDownScale' });
@@ -1634,6 +1681,9 @@ var ImageEditor = /** @class */ (function (_super) {
1634
1681
  if (setting.strokeWidth) {
1635
1682
  this.activeObj.strokeSettings.strokeWidth = setting.strokeWidth;
1636
1683
  }
1684
+ if (setting.index) {
1685
+ this.activeObj.order = setting.index;
1686
+ }
1637
1687
  if (setting.type === 'FreehandDraw' && setting.strokeWidth) {
1638
1688
  this.notify('freehand-draw', { prop: 'setPenStrokeWidth', onPropertyChange: false, value: { value: setting.strokeWidth } });
1639
1689
  }
@@ -1641,7 +1691,7 @@ var ImageEditor = /** @class */ (function (_super) {
1641
1691
  else {
1642
1692
  if (setting.type.toLowerCase() === 'text' && (this.textArea.style.display === 'block' ||
1643
1693
  this.textArea.style.display === 'inline-block')) {
1644
- this.okBtn();
1694
+ this.okBtn(null, true);
1645
1695
  isTextArea = true;
1646
1696
  }
1647
1697
  this.notify('shape', { prop: 'selectShape', onPropertyChange: false, value: { id: setting.id, obj: obj } });
@@ -1673,7 +1723,7 @@ var ImageEditor = /** @class */ (function (_super) {
1673
1723
  if (freehandObj['bool']) {
1674
1724
  this.notify('undo-redo', { prop: 'setPreventUR', value: { bool: true } });
1675
1725
  }
1676
- this.okBtn(isSelected);
1726
+ this.okBtn(isSelected, true);
1677
1727
  if (freehandObj['bool']) {
1678
1728
  this.notify('undo-redo', { prop: 'setPreventUR', value: { bool: false } });
1679
1729
  }
@@ -1703,7 +1753,7 @@ var ImageEditor = /** @class */ (function (_super) {
1703
1753
  this.notify('shape', { prop: 'selectShape', onPropertyChange: false, value: { id: shapeId, obj: obj } });
1704
1754
  if (obj['isSelected']) {
1705
1755
  this.notify('toolbar', { prop: 'duplicateShape', onPropertyChange: false, value: { isPreventUndoRedo: false } });
1706
- this.okBtn();
1756
+ this.okBtn(null, true);
1707
1757
  this.notify('draw', { prop: 'redrawDownScale' });
1708
1758
  }
1709
1759
  }
@@ -1731,6 +1781,13 @@ var ImageEditor = /** @class */ (function (_super) {
1731
1781
  */
1732
1782
  ImageEditor.prototype.enableTextEditing = function () {
1733
1783
  var activeObj = extend({}, this.activeObj, {}, true);
1784
+ if (!activeObj.order) {
1785
+ this.noPushUndo = true;
1786
+ this.okBtn();
1787
+ this.noPushUndo = false;
1788
+ this.selectShape(activeObj.currIndex);
1789
+ activeObj.order = this.activeObj.order;
1790
+ }
1734
1791
  this.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
1735
1792
  this.notify('draw', { prop: 'render-image', value: { isMouseWheel: null, isPreventClearRect: null, isFrame: false } });
1736
1793
  this.activeObj = activeObj;
@@ -1776,7 +1833,176 @@ var ImageEditor = /** @class */ (function (_super) {
1776
1833
  }
1777
1834
  return canRedo;
1778
1835
  };
1836
+ /**
1837
+ * Applies the operations performed in the Image Editor, such as annotation drawings.
1838
+ *
1839
+ * @returns{void}
1840
+ * @remarks
1841
+ * This method applies the actions performed after enabling annotation drawings, ensuring that the drawn annotations are applied to the image.
1842
+ */
1843
+ ImageEditor.prototype.apply = function () {
1844
+ this.closeOverlayTbar();
1845
+ this.okBtn(null, true);
1846
+ };
1847
+ /**
1848
+ * Discards the operations performed in the Image Editor, such as annotation drawings.
1849
+ *
1850
+ * @returns{void}
1851
+ * @remarks
1852
+ * This method discards the actions performed after enabling annotation drawings, ensuring that the drawn annotations are not applied to the image.
1853
+ */
1854
+ ImageEditor.prototype.discard = function () {
1855
+ this.notify('draw', { prop: 'performCancel', value: { isContextualToolbar: this.closeOverlayTbar(), isFinalCancel: true } });
1856
+ };
1857
+ /**
1858
+ * Enable or disable a shape drawing option in an Image Editor.
1859
+ *
1860
+ * @param {ShapeType} shapeType - Specifies the type of shape to be enabled or disabled for drawing.
1861
+ * @param {boolean} isEnabled - Optional. Specifies a value to indicate whether to enable or disable shape drawing. The default value is true.
1862
+ *
1863
+ * @remarks This function allows the user to toggle the shape drawing feature in the Image Editor. When enabled, users can draw shapes on the image. When disabled, the shape drawing functionality is not available.
1864
+ *
1865
+ * @returns {void}.
1866
+ */
1867
+ ImageEditor.prototype.enableShapeDrawing = function (shapeType, isEnabled) {
1868
+ if (isEnabled) {
1869
+ this.drawingShape = shapeType.toLowerCase();
1870
+ this.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
1871
+ }
1872
+ if (shapeType && isEnabled) {
1873
+ this.currObjType.shape = shapeType.toLowerCase();
1874
+ this.activeObj.shape = this.currObjType.shape;
1875
+ this.currObjType.isDragging = this.currObjType.isCustomCrop = false;
1876
+ this.activeObj.shapeDegree = this.transform.degree;
1877
+ this.activeObj.shapeFlip = this.transform.currFlipState;
1878
+ this.activeObj.textFlip = this.transform.currFlipState;
1879
+ this.activeObj.flipObjColl = [];
1880
+ var orderObj = { order: null };
1881
+ this.notify('shape', { prop: 'getNewOrder', onPropertyChange: false, value: { obj: orderObj } });
1882
+ this.activeObj.order = orderObj['order'];
1883
+ this.notify('selection', { prop: 'annotate', value: { shape: this.currObjType.shape } });
1884
+ if (this.currObjType.shape === 'text') {
1885
+ this.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: { type: 'text',
1886
+ isApplyBtn: null, isCropping: null, isZooming: null, cType: null } });
1887
+ }
1888
+ else {
1889
+ this.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: { type: 'shapes',
1890
+ isApplyBtn: null, isCropping: null, isZooming: null, cType: null } });
1891
+ }
1892
+ this.notify('toolbar', { prop: 'update-toolbar-items', onPropertyChange: false });
1893
+ }
1894
+ else if (!isEnabled) {
1895
+ this.okBtn(null, true);
1896
+ }
1897
+ };
1898
+ /**
1899
+ * Moves a shape to the front of all other shapes based on the given shape id.
1900
+ * Use 'getShapeSettings' method to get the shape id which is then passed to perform moving.
1901
+ *
1902
+ * @param {string} shapeId - Specifies the shape id to move the shape on an image.
1903
+ * @returns {void}.
1904
+ *
1905
+ */
1906
+ ImageEditor.prototype.bringToFront = function (shapeId) {
1907
+ if (this.selectShape(shapeId)) {
1908
+ this.updateShapeOrder(shapeId, 'bringToFront');
1909
+ this.apply();
1910
+ }
1911
+ };
1912
+ /**
1913
+ * Moves a shape to ahead of one shape based on the given shape id.
1914
+ * Use 'getShapeSettings' method to get the shape id which is then passed to perform moving.
1915
+ *
1916
+ * @param {string} shapeId - Specifies the shape id to move the shape on an image.
1917
+ * @returns {void}.
1918
+ *
1919
+ */
1920
+ ImageEditor.prototype.bringForward = function (shapeId) {
1921
+ if (this.selectShape(shapeId)) {
1922
+ this.updateShapeOrder(shapeId, 'bringForward');
1923
+ this.apply();
1924
+ }
1925
+ };
1926
+ /**
1927
+ * Moves a shape to behind all other shapes based on the given shape id.
1928
+ * Use 'getShapeSettings' method to get the shape id which is then passed to perform moving.
1929
+ *
1930
+ * @param {string} shapeId - Specifies the shape id to move the shape on an image.
1931
+ * @returns {void}.
1932
+ *
1933
+ */
1934
+ ImageEditor.prototype.sendToBack = function (shapeId) {
1935
+ if (this.selectShape(shapeId)) {
1936
+ this.updateShapeOrder(shapeId, 'sendToBack');
1937
+ this.apply();
1938
+ }
1939
+ };
1940
+ /**
1941
+ * Moves a shape to behind one shape based on the given shape id.
1942
+ * Use 'getShapeSettings' method to get the shape id which is then passed to perform moving.
1943
+ *
1944
+ * @param {string} shapeId - Specifies the shape id to move the shape on an image.
1945
+ * @returns {void}.
1946
+ *
1947
+ */
1948
+ ImageEditor.prototype.sendBackward = function (shapeId) {
1949
+ if (this.selectShape(shapeId)) {
1950
+ this.updateShapeOrder(shapeId, 'sendBackward');
1951
+ this.apply();
1952
+ }
1953
+ };
1954
+ /**
1955
+ * Clears the loaded image in the Image Editor.
1956
+ *
1957
+ * @returns{void}
1958
+ * @remarks
1959
+ * This method clears the loaded image and updates the component's user interface to its initial state (the initial user interface without a loaded image).
1960
+ */
1961
+ ImageEditor.prototype.clearImage = function () {
1962
+ this.reset();
1963
+ this.isImageLoaded = false;
1964
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
1965
+ this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
1966
+ var btoolbar = document.getElementById(this.element.id + '_bottomToolbar');
1967
+ if (Browser.isDevice && btoolbar) {
1968
+ document.getElementById(this.element.id + '_bottomToolbar').style.display = 'none';
1969
+ }
1970
+ this.notify('toolbar', { prop: 'destroy-top-toolbar', onPropertyChange: false });
1971
+ this.notify('toolbar', { prop: 'create-toolbar', onPropertyChange: false });
1972
+ this.notify('toolbar', { prop: 'create-contextual-toolbar', onPropertyChange: false });
1973
+ var dropArea = document.getElementById(this.element.id + '_dropArea');
1974
+ if (dropArea) {
1975
+ dropArea.style.display = 'block';
1976
+ }
1977
+ };
1779
1978
  // Toolbar related codes
1979
+ ImageEditor.prototype.applyShapes = function () {
1980
+ if (this.isUndoRedoStack) {
1981
+ return;
1982
+ }
1983
+ var shapes = ['rectangle', 'ellipse', 'line', 'arrow', 'path', 'text', 'image'];
1984
+ var dummyObj = { bool: false };
1985
+ this.notify('selection', { prop: 'getFreehandDrawEditing', onPropertyChange: false, value: { obj: dummyObj } });
1986
+ if (dummyObj['bool'] || this.togglePen || (this.activeObj.shape && shapes.indexOf(this.activeObj.shape) !== -1) ||
1987
+ this.drawingShape) {
1988
+ this.okBtn(null, true);
1989
+ }
1990
+ };
1991
+ ImageEditor.prototype.closeOverlayTbar = function () {
1992
+ var isContextualToolbar = false;
1993
+ var frameObject = { bool: null };
1994
+ this.notify('toolbar', { prop: 'getFrameToolbar', onPropertyChange: false, value: { obj: frameObject } });
1995
+ if (!frameObject['bool'] && this.element.querySelector('.e-contextual-toolbar-wrapper')) {
1996
+ if (!this.element.querySelector('.e-contextual-toolbar-wrapper').classList.contains('e-hide')) {
1997
+ isContextualToolbar = true;
1998
+ }
1999
+ var straightenObj = { bool: this.isStraightening };
2000
+ if (!Browser.isDevice || (Browser.isDevice && !straightenObj['bool'])) {
2001
+ this.element.querySelector('.e-contextual-toolbar-wrapper').classList.add('e-hide');
2002
+ }
2003
+ }
2004
+ return isContextualToolbar;
2005
+ };
1780
2006
  ImageEditor.prototype.toolbarTemplateFn = function () {
1781
2007
  var template;
1782
2008
  var templateID = this.element.id + '_toolbar';
@@ -1979,10 +2205,17 @@ var ImageEditor = /** @class */ (function (_super) {
1979
2205
  * Handles the OK button operation
1980
2206
  *
1981
2207
  * @param { boolean } isMouseDown - Specifies whether it is a mouse down.
2208
+ * @param { boolean } isFinalApply - Specifies whether it is a final apply.
1982
2209
  * @hidden
1983
2210
  * @returns {void}.
1984
2211
  */
1985
- ImageEditor.prototype.okBtn = function (isMouseDown) {
2212
+ ImageEditor.prototype.okBtn = function (isMouseDown, isFinalApply) {
2213
+ if (isFinalApply) {
2214
+ this.noPushUndo = false;
2215
+ var tempActiveObj = { activePoint: { startX: 0, startY: 0, endX: 0, endY: 0, width: 0, height: 0 },
2216
+ flipObjColl: [], triangle: [], triangleRatio: [], order: null };
2217
+ this.notify('selection', { prop: 'setTempActObj', onPropertyChange: false, value: { obj: tempActiveObj } });
2218
+ }
1986
2219
  var ctWrapper = this.element.querySelector('.e-contextual-toolbar-wrapper');
1987
2220
  if (ctWrapper) {
1988
2221
  ctWrapper.classList.remove('e-frame-wrapper');
@@ -2071,6 +2304,7 @@ var ImageEditor = /** @class */ (function (_super) {
2071
2304
  this.notify('selection', { prop: 'getFreehandDrawEditing', onPropertyChange: false, value: { obj: obj } });
2072
2305
  var frameObject = { bool: null };
2073
2306
  this.notify('toolbar', { prop: 'getFrameToolbar', onPropertyChange: false, value: { obj: frameObject } });
2307
+ var sliderWrap = document.querySelector('#' + this.element.id + '_sliderWrapper');
2074
2308
  if (selElem) {
2075
2309
  this.currentFilter = selElem.children[0].children[0].id.replace('Canvas', '');
2076
2310
  }
@@ -2102,17 +2336,18 @@ var ImageEditor = /** @class */ (function (_super) {
2102
2336
  this.notify('draw', { prop: 'clearOuterCanvas', onPropertyChange: false, value: { context: this.lowerContext } });
2103
2337
  this.notify('draw', { prop: 'clearOuterCanvas', onPropertyChange: false, value: { context: this.upperContext } });
2104
2338
  }
2105
- else if (document.querySelector('#' + this.element.id + '_sliderWrapper') || this.currObjType.isFiltered) {
2339
+ else if (sliderWrap || this.currObjType.isFiltered) {
2106
2340
  this.initialAdjustmentValue = this.canvasFilter = this.lowerContext.filter;
2107
2341
  this.currObjType.isFiltered = false;
2108
2342
  var obj_4 = { value: null };
2109
2343
  this.notify('draw', { prop: 'getTempAdjustmentValue', value: { obj: obj_4 } });
2110
- if (obj_4['value'] !== this.lowerContext.filter) {
2344
+ if (obj_4['value'] !== this.lowerContext.filter && (!sliderWrap ||
2345
+ !sliderWrap.classList.contains('e-ie-finetune-slider-wrap'))) {
2111
2346
  this.notify('undo-redo', { prop: 'updateCurrUrc', value: { type: 'ok' } });
2112
2347
  }
2113
2348
  if ((this.activeObj.activePoint.width !== 0 && this.activeObj.activePoint.height !== 0) ||
2114
2349
  (this.activeObj.shape === 'path' && this.activeObj.pointColl.length > 0)) {
2115
- this.notify('shape', { prop: 'applyActObj', onPropertyChange: false, value: { isMouseDown: isMouseDown } });
2350
+ this.notify('shape', { prop: 'applyActObj', onPropertyChange: false, value: { isMouseDown: null } });
2116
2351
  }
2117
2352
  }
2118
2353
  else if (obj['bool']) {
@@ -2120,13 +2355,14 @@ var ImageEditor = /** @class */ (function (_super) {
2120
2355
  this.notify('selection', { prop: 'setFreehandDrawCustomized', value: { isFreehandDrawCustomized: false } });
2121
2356
  this.notify('toolbar', { prop: 'destroy-qa-toolbar' });
2122
2357
  this.notify('undo-redo', { prop: 'updateCurrUrc', value: { type: 'ok' } });
2358
+ this.notify('freehand-draw', { prop: 'resetFreehandDrawSelectedId', onPropertyChange: false });
2123
2359
  }
2124
2360
  else if ((this.activeObj.activePoint.width !== 0 || this.activeObj.activePoint.height !== 0) ||
2125
2361
  (this.activeObj.shape === 'path' && this.activeObj.pointColl.length > 0)) {
2126
2362
  if (this.activeObj.shape === 'image') {
2127
2363
  this.notify('draw', { prop: 'setImageApply', onPropertyChange: false, value: { bool: true } });
2128
2364
  }
2129
- this.notify('shape', { prop: 'applyActObj', onPropertyChange: false, value: { isMouseDown: isMouseDown } });
2365
+ this.notify('shape', { prop: 'applyActObj', onPropertyChange: false, value: { isMouseDown: null } });
2130
2366
  }
2131
2367
  else {
2132
2368
  if (JSON.stringify(this.frameObj) !== JSON.stringify(this.tempFrameObj)) {
@@ -2154,6 +2390,35 @@ var ImageEditor = /** @class */ (function (_super) {
2154
2390
  this.isResizeOkBtn = false;
2155
2391
  this.notify('draw', { prop: 'redrawDownScale' });
2156
2392
  this.isChangesSaved = false;
2393
+ if (isFinalApply) {
2394
+ this.drawingShape = null;
2395
+ this.notify('draw', { prop: 'resetTempObjColl' });
2396
+ this.notify('draw', { prop: 'resetTempPointColl' });
2397
+ }
2398
+ };
2399
+ /**
2400
+ * Handles the OK button operation
2401
+ *
2402
+ * @param { string } id - Specifies shape id to return.
2403
+ * @hidden
2404
+ * @returns {SelectionPoint | Object}.
2405
+ */
2406
+ ImageEditor.prototype.getObjFromId = function (id) {
2407
+ var obj;
2408
+ if (this.activeObj.currIndex && this.activeObj.currIndex === id) {
2409
+ obj = extend({}, this.activeObj, {}, true);
2410
+ }
2411
+ else {
2412
+ for (var i = 0; i < this.shapeColl.length; i++) {
2413
+ var shapeId = this.shapeColl[i].id ? this.shapeColl[i].id :
2414
+ this.shapeColl[i].currIndex;
2415
+ if (shapeId === id) {
2416
+ obj = extend({}, this.shapeColl[i], {}, true);
2417
+ break;
2418
+ }
2419
+ }
2420
+ }
2421
+ return obj;
2157
2422
  };
2158
2423
  /**
2159
2424
  * Set the temporary filter properties.
@@ -2221,7 +2486,8 @@ var ImageEditor = /** @class */ (function (_super) {
2221
2486
  this.objColl = objColl;
2222
2487
  this.pointColl = pointColl;
2223
2488
  this.freehandCounter = pointColl.length;
2224
- this.notify('shape', { prop: 'iterateObjColl', onPropertyChange: false });
2489
+ this.notify('shape', { prop: 'drawAnnotations', onPropertyChange: false,
2490
+ value: { ctx: this.lowerContext, shape: 'iterate', pen: 'iterate', isPreventApply: null } });
2225
2491
  this.lowerContext.filter = this.canvasFilter = tempFilter;
2226
2492
  this.frameObj = tempFrame;
2227
2493
  return data;
@@ -2286,7 +2552,7 @@ var ImageEditor = /** @class */ (function (_super) {
2286
2552
  var typeToSelectionType = { 'CropCustom': 'Custom', 'CropSquare': 'Square', 'CropCircle': 'Circle',
2287
2553
  'Crop3:2': '3:2', 'Crop4:3': '4:3', 'Crop5:4': '5:4', 'Crop7:5': '7:5', 'Crop16:9': '16:9',
2288
2554
  'Crop2:3': '2:3', 'Crop3:4': '3:4', 'Crop4:5': '4:5', 'Crop5:7': '5:7', 'Crop9:16': '9:16' };
2289
- return typeToSelectionType["" + type];
2555
+ return typeToSelectionType["" + type] ? typeToSelectionType["" + type] : type.split('Crop')[1];
2290
2556
  };
2291
2557
  /** Clears the context.
2292
2558
  *
@@ -2349,6 +2615,7 @@ var ImageEditor = /** @class */ (function (_super) {
2349
2615
  toolbar_2.refreshOverflow();
2350
2616
  }
2351
2617
  }
2618
+ // eslint-disable-next-line max-len
2352
2619
  var shapeChangedArgs = { action: type, currentShapeSettings: extend({}, shapeSettings, {}, true) };
2353
2620
  this.trigger('shapeChange', shapeChangedArgs);
2354
2621
  };
@@ -2383,7 +2650,9 @@ var ImageEditor = /** @class */ (function (_super) {
2383
2650
  value: { obj: this.activeObj, isTextArea: true } });
2384
2651
  var temp = this.activeObj.textSettings.fontFamily;
2385
2652
  this.activeObj.textSettings.fontFamily = this.toPascalCase(id);
2386
- this.notify('shape', { prop: 'redraw-text' });
2653
+ if (this.activeObj.activePoint.width !== 0 || this.activeObj.activePoint.height !== 0) {
2654
+ this.notify('shape', { prop: 'redraw-text' });
2655
+ }
2387
2656
  this.objColl.push(this.activeObj);
2388
2657
  if (this.activeObj.activePoint.width !== 0 || this.activeObj.activePoint.height !== 0) {
2389
2658
  this.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false,
@@ -2408,7 +2677,9 @@ var ImageEditor = /** @class */ (function (_super) {
2408
2677
  var fontFamily = this.activeObj.textSettings.fontFamily = this.toPascalCase(id);
2409
2678
  this.notify('shape', { prop: 'setTextSettings', onPropertyChange: false,
2410
2679
  value: { textSettings: null, fontFamily: fontFamily, fontSize: null } });
2411
- this.notify('shape', { prop: 'redraw-text' });
2680
+ if (this.activeObj.activePoint.width !== 0 || this.activeObj.activePoint.height !== 0) {
2681
+ this.notify('shape', { prop: 'redraw-text' });
2682
+ }
2412
2683
  this.objColl.push(this.activeObj);
2413
2684
  if (this.activeObj.activePoint.width !== 0 || this.activeObj.activePoint.height !== 0) {
2414
2685
  this.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false,
@@ -2506,11 +2777,13 @@ var ImageEditor = /** @class */ (function (_super) {
2506
2777
  this.activeObj.textSettings.fontSize * 0.5;
2507
2778
  var height = rows.length * (this.activeObj.textSettings.fontSize +
2508
2779
  this.activeObj.textSettings.fontSize * 0.25);
2509
- this.notify('selection', { prop: 'setTextSelection', onPropertyChange: false,
2510
- value: { width: width, height: height } });
2511
- this.notify('draw', { prop: 'updateActiveObject', onPropertyChange: false, value: { actPoint: this.activeObj.activePoint, obj: this.activeObj,
2512
- isMouseMove: null, x: null, y: null } });
2513
- this.notify('shape', { prop: 'redraw-text' });
2780
+ if (this.activeObj.activePoint.width !== 0 || this.activeObj.activePoint.height !== 0) {
2781
+ this.notify('selection', { prop: 'setTextSelection', onPropertyChange: false,
2782
+ value: { width: width, height: height } });
2783
+ this.notify('draw', { prop: 'updateActiveObject', onPropertyChange: false, value: { actPoint: this.activeObj.activePoint, obj: this.activeObj,
2784
+ isMouseMove: null, x: null, y: null } });
2785
+ this.notify('shape', { prop: 'redraw-text' });
2786
+ }
2514
2787
  this.objColl.push(this.activeObj);
2515
2788
  if (this.activeObj.activePoint.width !== 0 || this.activeObj.activePoint.height !== 0) {
2516
2789
  this.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false,
@@ -2562,8 +2835,8 @@ var ImageEditor = /** @class */ (function (_super) {
2562
2835
  previousPointColl: prevObj.pointColl, previousSelPointColl: prevObj.selPointColl,
2563
2836
  previousCropObj: prevCropObj, previousText: null,
2564
2837
  currentText: null, previousFilter: null, isCircleCrop: null } });
2838
+ this.notify('selection', { prop: 'redrawShape', value: { obj: this.objColl[this.objColl.length - 1] } });
2565
2839
  }
2566
- this.notify('selection', { prop: 'redrawShape', value: { obj: this.objColl[this.objColl.length - 1] } });
2567
2840
  }
2568
2841
  }
2569
2842
  else if (this.textArea.style.display === 'block' || this.textArea.style.display === 'inline-block') {
@@ -2590,7 +2863,9 @@ var ImageEditor = /** @class */ (function (_super) {
2590
2863
  previousCropObj: prevCropObj, previousText: null,
2591
2864
  currentText: null, previousFilter: null, isCircleCrop: null } });
2592
2865
  }
2593
- this.notify('selection', { prop: 'redrawShape', value: { obj: this.objColl[this.objColl.length - 1] } });
2866
+ if (this.activeObj.activePoint.width !== 0 || this.activeObj.activePoint.height !== 0) {
2867
+ this.notify('selection', { prop: 'redrawShape', value: { obj: this.objColl[this.objColl.length - 1] } });
2868
+ }
2594
2869
  }
2595
2870
  var shapeChangedArgs = { action: 'font-color', currentShapeSettings: extend({}, shapeSettings, {}, true) };
2596
2871
  shapeChangedArgs.currentShapeSettings.fillColor = value;
@@ -2683,18 +2958,8 @@ var ImageEditor = /** @class */ (function (_super) {
2683
2958
  this.notify('freehand-draw', { prop: 'getFreehandSelectedIndex', onPropertyChange: false, value: { obj: indexObj } });
2684
2959
  if (indexObj['freehandSelectedIndex'] !== null && indexObj['freehandSelectedIndex'] !== undefined) {
2685
2960
  this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
2686
- // Temporary delete the selected freehand drawing from the collection
2687
- var count = 0;
2688
- var temp_1 = extend({}, this.pointColl, {}, true);
2689
- for (var i = 0; i < this.freehandCounter; i++) {
2690
- if (parseInt(temp_1[i].id.split('_')[1], 10) - 1 !== indexObj['freehandSelectedIndex']) {
2691
- this.pointColl[count] = temp_1[i];
2692
- count++;
2693
- }
2694
- }
2695
2961
  this.notify('draw', { prop: 'render-image', value: { isMouseWheel: null } });
2696
2962
  this.notify('draw', { prop: 'redrawDownScale' });
2697
- this.pointColl = temp_1;
2698
2963
  this.notify('freehand-draw', { prop: 'hoverFhd', onPropertyChange: false,
2699
2964
  value: { strokeColor: null, strokeWidth: null } });
2700
2965
  }
@@ -2960,7 +3225,6 @@ var ImageEditor = /** @class */ (function (_super) {
2960
3225
  * Apply rotate image.
2961
3226
  *
2962
3227
  * @param { string } rotate - Specifies the direction of rotation.
2963
- * @param { boolean } isPreventURC - Specifies to update undo redo collection.
2964
3228
  * @hidden
2965
3229
  * @returns {void}.
2966
3230
  */
@@ -2971,9 +3235,11 @@ var ImageEditor = /** @class */ (function (_super) {
2971
3235
  this.notify('shape', { prop: 'updImgRatioForActObj', onPropertyChange: false });
2972
3236
  }
2973
3237
  this.notify('shape', { prop: 'pushActItemIntoObj' });
3238
+ // eslint-disable-next-line prefer-const
2974
3239
  prevCropObj = extend({}, this.cropObj, {}, true);
2975
3240
  var object = { currObj: {} };
2976
3241
  this.notify('filter', { prop: 'getCurrentObj', onPropertyChange: false, value: { object: object } });
3242
+ // eslint-disable-next-line prefer-const
2977
3243
  prevObj = object['currObj'];
2978
3244
  prevObj.objColl = extend([], this.objColl, [], true);
2979
3245
  prevObj.pointColl = extend([], this.pointColl, [], true);
@@ -3061,8 +3327,9 @@ var ImageEditor = /** @class */ (function (_super) {
3061
3327
  */
3062
3328
  ImageEditor.prototype.transformSelect = function (type) {
3063
3329
  if (this.transform.straighten === 0 && (type === 'rotateleft' || type === 'rotateright') &&
3064
- this.activeObj.shape && ['crop-2:3', 'crop-3:2', 'crop-3:4', 'crop-4:3', 'crop-4:5', 'crop-5:4', 'crop-5:7', 'crop-7:5',
3065
- 'crop-9:16', 'crop-16:9'].indexOf(this.activeObj.shape) !== -1) {
3330
+ this.activeObj.shape && (['crop-2:3', 'crop-3:2', 'crop-3:4', 'crop-4:3', 'crop-4:5', 'crop-5:4', 'crop-5:7', 'crop-7:5',
3331
+ 'crop-9:16', 'crop-16:9'].indexOf(this.activeObj.shape) !== -1 || (this.activeObj.shape.indexOf('crop-') !== -1 &&
3332
+ this.activeObj.shape !== 'crop-custom' && this.activeObj.shape !== 'crop-square' && this.activeObj.shape !== 'crop-circle'))) {
3066
3333
  this.activeObj.shape = 'crop-' + this.activeObj.shape.split('-')[1].split(':')[1] + ':' + this.activeObj.shape.split('-')[1].split(':')[0];
3067
3334
  this.notify('toolbar', { prop: 'performCropTransformClick', value: { shape: this.activeObj.shape, isTransform: true } });
3068
3335
  }
@@ -3093,8 +3360,8 @@ var ImageEditor = /** @class */ (function (_super) {
3093
3360
  }
3094
3361
  }
3095
3362
  this.notify('draw', { prop: 'render-image', value: { isMouseWheel: false } });
3096
- this.notify('shape', { prop: 'zoomObjColl', onPropertyChange: false, value: { isPreventApply: null } });
3097
- this.notify('freehand-draw', { prop: 'zoomFHDColl', onPropertyChange: false, value: { isPreventApply: null } });
3363
+ this.notify('shape', { prop: 'drawAnnotations', onPropertyChange: false,
3364
+ value: { ctx: this.lowerContext, shape: 'zoom', pen: 'zoom', isPreventApply: null } });
3098
3365
  }
3099
3366
  this.setInitialZoomState();
3100
3367
  var activeObj = extend({}, this.activeObj, {}, true);
@@ -3120,8 +3387,8 @@ var ImageEditor = /** @class */ (function (_super) {
3120
3387
  this.notify('selection', { prop: 'updPtCollForShpRot', onPropertyChange: false, value: { obj: this.objColl[i] } });
3121
3388
  }
3122
3389
  }
3123
- this.notify('shape', { prop: 'zoomObjColl', onPropertyChange: false, value: { isPreventApply: null } });
3124
- this.notify('freehand-draw', { prop: 'zoomFHDColl', onPropertyChange: false, value: { isPreventApply: null } });
3390
+ this.notify('shape', { prop: 'drawAnnotations', onPropertyChange: false,
3391
+ value: { ctx: this.lowerContext, shape: 'zoom', pen: 'zoom', isPreventApply: null } });
3125
3392
  this.notify('draw', { prop: 'render-image', value: { isMouseWheel: false } });
3126
3393
  this.notify('draw', { prop: 'drawObject', onPropertyChange: false, value: { canvas: 'duplicate', obj: straightenObj } });
3127
3394
  this.notify('draw', { prop: 'setStraightenActObj', value: { activeObj: null } });
@@ -3157,10 +3424,11 @@ var ImageEditor = /** @class */ (function (_super) {
3157
3424
  /**
3158
3425
  * Performs Straightening action.
3159
3426
  *
3427
+ * @param { number } value - Specifies the degree of straightening.
3160
3428
  * @hidden
3161
- * @returns {void}.
3429
+ * @returns {void} .
3162
3430
  */
3163
- ImageEditor.prototype.setStraighten = function (value, isMethod) {
3431
+ ImageEditor.prototype.setStraighten = function (value) {
3164
3432
  var straightenEventArgs = { cancel: false, previousDegree: this.transform.straighten, currentDegree: value };
3165
3433
  this.trigger('rotating', straightenEventArgs);
3166
3434
  if (!straightenEventArgs.cancel) {
@@ -3182,7 +3450,6 @@ var ImageEditor = /** @class */ (function (_super) {
3182
3450
  if (stValPan) {
3183
3451
  stValPan.innerHTML = value.toString() + '&#176';
3184
3452
  }
3185
- var prevValue = this.transform.straighten;
3186
3453
  var obj = extend({}, this.activeObj, null, true);
3187
3454
  this.notify('freehand-draw', { prop: 'setCenterSelPoints' });
3188
3455
  this.transform.straighten = value;
@@ -3238,6 +3505,7 @@ var ImageEditor = /** @class */ (function (_super) {
3238
3505
  value: { obj: obj_6, dimension: { width: ctx.canvas.width, height: ctx.canvas.height } } });
3239
3506
  }
3240
3507
  var dimension = void 0;
3508
+ // eslint-disable-next-line prefer-const
3241
3509
  dimension = this.getRotatedCanvasDim(this.baseImg.width, this.baseImg.height, this.transform.straighten);
3242
3510
  this.img.srcWidth = ctx.canvas.width = dimension.width;
3243
3511
  this.img.srcHeight = ctx.canvas.height = dimension.height;
@@ -3255,8 +3523,11 @@ var ImageEditor = /** @class */ (function (_super) {
3255
3523
  /**
3256
3524
  * Returns rotated canvas dimension.
3257
3525
  *
3526
+ * @param { number } width - Specifies the width of the canvas.
3527
+ * @param { number } height - Specifies the height of the canvas.
3528
+ * @param { number } angle - Specifies the angle of rotation in degrees.
3258
3529
  * @hidden
3259
- * @returns {void}.
3530
+ * @returns {void} .
3260
3531
  */
3261
3532
  ImageEditor.prototype.getRotatedCanvasDim = function (width, height, angle) {
3262
3533
  var angleRad = angle * Math.PI / 180;
@@ -3268,7 +3539,64 @@ var ImageEditor = /** @class */ (function (_super) {
3268
3539
  var maxY = Math.max(0, width * sinAngle, height * Math.sin(Math.PI / 2 - angleRad), width * sinAngle + height * Math.sin(Math.PI / 2 - angleRad));
3269
3540
  return { width: Math.ceil(maxX - minX), height: Math.ceil(maxY - minY) };
3270
3541
  };
3271
- ;
3542
+ /**
3543
+ * Apply Shape order.
3544
+ *
3545
+ * @param { string } id - Specifies the id of the shape to change the order.
3546
+ * @param { string } value - Specifies the order of the shapes.
3547
+ * @hidden
3548
+ * @returns {void}.
3549
+ */
3550
+ ImageEditor.prototype.updateShapeOrder = function (id, value) {
3551
+ var shapeObj = this.getObjFromId(id);
3552
+ if ((shapeObj.shape && (shapeObj.shape !== 'path' ||
3553
+ (shapeObj.shape === 'path' && shapeObj.pointColl.length > 0))) ||
3554
+ (shapeObj && shapeObj['id'] && shapeObj['id'].indexOf('pen') > -1)) {
3555
+ var obj = { shapeSettingsObj: {} };
3556
+ this.notify('selection', { prop: 'updatePrevShapeSettings', onPropertyChange: false, value: { obj: obj } });
3557
+ var shapeSettings = obj['shapeSettingsObj'];
3558
+ if (shapeObj.shape) {
3559
+ this.notify('shape', { prop: 'pushActItemIntoObj' });
3560
+ }
3561
+ var prevCropObj = extend({}, this.cropObj, {}, true);
3562
+ var object = { currObj: {} };
3563
+ this.notify('filter', { prop: 'getCurrentObj', onPropertyChange: false, value: { object: object } });
3564
+ var prevObj = object['currObj'];
3565
+ prevObj.objColl = extend([], this.objColl, [], true);
3566
+ prevObj.pointColl = extend([], this.pointColl, [], true);
3567
+ prevObj.afterCropActions = extend([], this.afterCropActions, [], true);
3568
+ var selPointCollObj = { selPointColl: null };
3569
+ this.notify('freehand-draw', { prop: 'getSelPointColl', onPropertyChange: false,
3570
+ value: { obj: selPointCollObj } });
3571
+ prevObj.selPointColl = extend([], selPointCollObj['selPointColl'], [], true);
3572
+ if (shapeObj.shape) {
3573
+ this.objColl.pop();
3574
+ }
3575
+ this.notify('shape', { prop: 'z-order', onPropertyChange: false, value: { obj: shapeObj, value: value } });
3576
+ if (shapeObj.shape) {
3577
+ this.notify('shape', { prop: 'setStrokeSettings', value: { strokeSettings: null, strokeColor: null, fillColor: null,
3578
+ strokeWidth: shapeObj.strokeSettings.strokeWidth } });
3579
+ this.objColl.push(shapeObj);
3580
+ }
3581
+ this.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false,
3582
+ value: { operation: 'shapeTransform', previousObj: prevObj, previousObjColl: prevObj.objColl,
3583
+ previousPointColl: prevObj.pointColl, previousSelPointColl: prevObj.selPointColl,
3584
+ previousCropObj: prevCropObj, previousText: null,
3585
+ currentText: null, previousFilter: null, isCircleCrop: null } });
3586
+ if (shapeObj.shape) {
3587
+ this.notify('selection', { prop: 'redrawShape', value: { obj: this.objColl[this.objColl.length - 1] } });
3588
+ this.activeObj.order = shapeObj.order;
3589
+ }
3590
+ var shapeChangedArgs = { action: 'stroke-width', previousShapeSettings: extend({}, shapeSettings, {}, true),
3591
+ currentShapeSettings: extend({}, shapeSettings, {}, true) };
3592
+ shapeChangedArgs.currentShapeSettings.strokeWidth = this.activeObj.strokeSettings.strokeWidth;
3593
+ }
3594
+ else if (this.activeObj.shape && (this.activeObj.shape === 'path' &&
3595
+ this.activeObj.pointColl.length === 0)) {
3596
+ this.notify('shape', { prop: 'setStrokeSettings', value: { strokeSettings: null, strokeColor: null, fillColor: null,
3597
+ strokeWidth: this.activeObj.strokeSettings.strokeWidth } });
3598
+ }
3599
+ };
3272
3600
  ImageEditor.prototype.getStraightenFlipState = function () {
3273
3601
  var flipState = '';
3274
3602
  if (this.rotateFlipColl.length > 0) {
@@ -3288,6 +3616,7 @@ var ImageEditor = /** @class */ (function (_super) {
3288
3616
  return flipState;
3289
3617
  };
3290
3618
  ImageEditor.prototype.initializeZoomSettings = function () {
3619
+ this.theme = isNullOrUndefined(this.theme) ? 'Bootstrap5' : this.theme;
3291
3620
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
3292
3621
  if (isNullOrUndefined(this.zoomSettings.zoomTrigger) || this.zoomSettings.zoomTrigger === 0) {
3293
3622
  this.zoomSettings.zoomTrigger = (ZoomTrigger.MouseWheel | ZoomTrigger.Pinch | ZoomTrigger.Toolbar | ZoomTrigger.Commands);
@@ -3316,7 +3645,10 @@ var ImageEditor = /** @class */ (function (_super) {
3316
3645
  FabricDark: { primaryColor: '#0074cc', secondaryColor: '#fff' },
3317
3646
  Highcontrast: { primaryColor: '#000000', secondaryColor: '#fff' },
3318
3647
  Material3: { primaryColor: '#6750a4', secondaryColor: '#fff' },
3319
- Material3Dark: { primaryColor: '#d0bcff', secondaryColor: '#fff' }
3648
+ Material3Dark: { primaryColor: '#d0bcff', secondaryColor: '#fff' },
3649
+ Fluent2: { primaryColor: '#0f6cbd', secondaryColor: '#fff' },
3650
+ Fluent2Dark: { primaryColor: '#115ea3', secondaryColor: '#fff' },
3651
+ Fluent2Highcontrast: { primaryColor: '#1aebff', secondaryColor: '#fff' }
3320
3652
  };
3321
3653
  };
3322
3654
  var ImageEditor_1;