@syncfusion/ej2-image-editor 25.2.4 → 26.1.35

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 +2679 -830
  5. package/dist/es6/ej2-image-editor.es2015.js.map +1 -1
  6. package/dist/es6/ej2-image-editor.es5.js +2762 -873
  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 +190 -81
  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 +378 -52
  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 +1851 -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 +352 -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 +1851 -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
  };
@@ -940,6 +963,7 @@ var ImageEditor = /** @class */ (function (_super) {
940
963
  this.notify('toolbar', { prop: 'create-bottom-toolbar', onPropertyChange: false });
941
964
  }
942
965
  var isImageLoaded = this.isImageLoaded;
966
+ // eslint-disable-next-line max-len
943
967
  this.currObjType.isUndoAction = this.isUndoRedo = this.togglePan = this.togglePen = this.isImageLoaded = this.isFinetuning = false;
944
968
  this.isCircleCrop = this.isCropTab = false;
945
969
  this.objColl = [];
@@ -991,6 +1015,9 @@ var ImageEditor = /** @class */ (function (_super) {
991
1015
  this.cancelCropSelection = null;
992
1016
  this.aspectWidth = this.aspectHeight = null;
993
1017
  this.isResize = false;
1018
+ this.drawingShape = null;
1019
+ this.isShapeDrawing = this.noPushUndo = this.isUndoRedoStack = false;
1020
+ this.shapeColl = [];
994
1021
  var obj_1 = { initialZoomValue: false };
995
1022
  this.notify('draw', { prop: 'getInitialZoomValue', onPropertyChange: false, value: { obj: obj_1 } });
996
1023
  if (obj_1['initialZoomValue']) {
@@ -1062,6 +1089,7 @@ var ImageEditor = /** @class */ (function (_super) {
1062
1089
  * @returns {void}.
1063
1090
  */
1064
1091
  ImageEditor.prototype.export = function (type, fileName) {
1092
+ this.applyShapes();
1065
1093
  this.notify('export', { prop: 'export', onPropertyChange: false, value: { type: type, fileName: fileName } });
1066
1094
  };
1067
1095
  /**
@@ -1082,6 +1110,7 @@ var ImageEditor = /** @class */ (function (_super) {
1082
1110
  *
1083
1111
  */
1084
1112
  ImageEditor.prototype.select = function (type, startX, startY, width, height) {
1113
+ this.applyShapes();
1085
1114
  this.notify('toolbar', { prop: 'performCropTransformClick', value: { shape: 'crop-' + type } });
1086
1115
  this.notify('draw', { prop: 'select', onPropertyChange: false,
1087
1116
  value: { type: type, startX: startX, startY: startY, width: width, height: height } });
@@ -1123,6 +1152,7 @@ var ImageEditor = /** @class */ (function (_super) {
1123
1152
  */
1124
1153
  ImageEditor.prototype.freehandDraw = function (value) {
1125
1154
  if (!this.disabled && this.isImageLoaded) {
1155
+ this.applyShapes();
1126
1156
  this.freeHandDraw(value);
1127
1157
  }
1128
1158
  };
@@ -1139,6 +1169,7 @@ var ImageEditor = /** @class */ (function (_super) {
1139
1169
  * @returns {void}.
1140
1170
  */
1141
1171
  ImageEditor.prototype.pan = function (value, x, y) {
1172
+ this.applyShapes();
1142
1173
  this.notify('transform', { prop: 'pan', onPropertyChange: false, value: { value: value, x: x, y: y } });
1143
1174
  };
1144
1175
  /**
@@ -1260,6 +1291,7 @@ var ImageEditor = /** @class */ (function (_super) {
1260
1291
  }
1261
1292
  if (!this.disabled && this.isImageLoaded && (obj['inRange'] || isNullOrUndefined(pointColl))) {
1262
1293
  isPath = true;
1294
+ this.applyShapes();
1263
1295
  this.notify('shape', { prop: 'drawPath', onPropertyChange: false, value: { pointColl: pointColl,
1264
1296
  strokeWidth: strokeWidth, strokeColor: strokeColor, isSelected: isSelected } });
1265
1297
  this.notify('draw', { prop: 'redrawDownScale' });
@@ -1305,16 +1337,17 @@ var ImageEditor = /** @class */ (function (_super) {
1305
1337
  * @param {boolean} italic - Specifies whether the text is italic or not.
1306
1338
  * @param {string} color - Specifies font color of the text.
1307
1339
  * @param {boolean} isSelected - Specifies to show the text in the selected state.
1340
+ * @param {number} degree - Specifies the degree to rotate the text.
1308
1341
  * @returns {boolean}.
1309
1342
  *
1310
1343
  */
1311
- ImageEditor.prototype.drawText = function (x, y, text, fontFamily, fontSize, bold, italic, color, isSelected) {
1344
+ ImageEditor.prototype.drawText = function (x, y, text, fontFamily, fontSize, bold, italic, color, isSelected, degree) {
1312
1345
  var isText = false;
1313
1346
  var isPointsInRange = this.allowShape(x, y);
1314
1347
  if (!this.disabled && this.isImageLoaded && (isPointsInRange || (isNullOrUndefined(x) && isNullOrUndefined(y)))) {
1315
1348
  isText = true;
1316
1349
  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 } });
1350
+ fontSize: fontSize, bold: bold, italic: italic, color: color, isSelected: isSelected, degree: degree } });
1318
1351
  this.notify('draw', { prop: 'redrawDownScale' });
1319
1352
  }
1320
1353
  return isText;
@@ -1360,6 +1393,7 @@ var ImageEditor = /** @class */ (function (_super) {
1360
1393
  *
1361
1394
  */
1362
1395
  ImageEditor.prototype.selectShape = function (id) {
1396
+ this.applyShapes();
1363
1397
  var obj = { isSelected: false };
1364
1398
  this.notify('shape', { prop: 'selectShape', onPropertyChange: false, value: { id: id, obj: obj } });
1365
1399
  this.notify('draw', { prop: 'redrawDownScale' });
@@ -1376,6 +1410,7 @@ var ImageEditor = /** @class */ (function (_super) {
1376
1410
  *
1377
1411
  */
1378
1412
  ImageEditor.prototype.deleteShape = function (id) {
1413
+ this.applyShapes();
1379
1414
  this.notify('shape', { prop: 'deleteShape', onPropertyChange: false, value: { id: id } });
1380
1415
  this.notify('draw', { prop: 'redrawDownScale' });
1381
1416
  };
@@ -1389,6 +1424,7 @@ var ImageEditor = /** @class */ (function (_super) {
1389
1424
  *
1390
1425
  */
1391
1426
  ImageEditor.prototype.getShapeSetting = function (id) {
1427
+ this.applyShapes();
1392
1428
  var obj = { shapeDetails: null };
1393
1429
  this.notify('shape', { prop: 'getShapeSetting', onPropertyChange: false,
1394
1430
  value: { id: id, obj: obj } });
@@ -1402,6 +1438,7 @@ var ImageEditor = /** @class */ (function (_super) {
1402
1438
  * @returns {ShapeSettings[]}.
1403
1439
  */
1404
1440
  ImageEditor.prototype.getShapeSettings = function () {
1441
+ this.applyShapes();
1405
1442
  var obj = { shapeDetailsColl: [] };
1406
1443
  this.notify('shape', { prop: 'getShapeSettings', onPropertyChange: false, value: { obj: obj } });
1407
1444
  this.notify('draw', { prop: 'redrawDownScale' });
@@ -1429,6 +1466,7 @@ var ImageEditor = /** @class */ (function (_super) {
1429
1466
  */
1430
1467
  ImageEditor.prototype.finetuneImage = function (finetuneOption, value) {
1431
1468
  if (!this.disabled && this.isImageLoaded) {
1469
+ this.applyShapes();
1432
1470
  this.notify('filter', { prop: 'finetuneImage', value: { value: value, option: finetuneOption } });
1433
1471
  this.notify('draw', { prop: 'redrawDownScale' });
1434
1472
  }
@@ -1444,6 +1482,7 @@ var ImageEditor = /** @class */ (function (_super) {
1444
1482
  */
1445
1483
  ImageEditor.prototype.applyImageFilter = function (filterOption) {
1446
1484
  if (!this.disabled && this.isImageLoaded) {
1485
+ this.applyShapes();
1447
1486
  this.notify('filter', { prop: 'applyImageFilter', value: { option: filterOption.toString() } });
1448
1487
  this.notify('draw', { prop: 'redrawDownScale' });
1449
1488
  this.canvasFilter = this.lowerContext.filter;
@@ -1459,6 +1498,7 @@ var ImageEditor = /** @class */ (function (_super) {
1459
1498
  * @returns {void}.
1460
1499
  */
1461
1500
  ImageEditor.prototype.undo = function () {
1501
+ this.applyShapes();
1462
1502
  this.notify('undo-redo', { prop: 'undo', onPropertyChange: false });
1463
1503
  this.notify('draw', { prop: 'redrawDownScale' });
1464
1504
  };
@@ -1470,6 +1510,7 @@ var ImageEditor = /** @class */ (function (_super) {
1470
1510
  * @returns {void}.
1471
1511
  */
1472
1512
  ImageEditor.prototype.redo = function () {
1513
+ this.applyShapes();
1473
1514
  this.notify('undo-redo', { prop: 'redo', onPropertyChange: false });
1474
1515
  this.notify('draw', { prop: 'redrawDownScale' });
1475
1516
  };
@@ -1495,6 +1536,7 @@ var ImageEditor = /** @class */ (function (_super) {
1495
1536
  ImageEditor.prototype.resize = function (width, height, isAspectRatio) {
1496
1537
  var isResized = false;
1497
1538
  if ((width.toString()).length <= 4 && (height.toString()).length <= 4) {
1539
+ this.applyShapes();
1498
1540
  var destPoints = { startX: this.img.destLeft, startY: this.img.destTop, width: this.img.destWidth,
1499
1541
  height: this.img.destHeight };
1500
1542
  if (isAspectRatio) {
@@ -1544,6 +1586,7 @@ var ImageEditor = /** @class */ (function (_super) {
1544
1586
  * @returns {boolean}.
1545
1587
  */
1546
1588
  ImageEditor.prototype.drawFrame = function (frameType, color, gradientColor, size, inset, offset, borderRadius, frameLineStyle, lineCount) {
1589
+ this.applyShapes();
1547
1590
  var isFrame = false;
1548
1591
  var obj = { frameChangeEventArgs: null };
1549
1592
  color = color ? color : '#fff';
@@ -1604,6 +1647,7 @@ var ImageEditor = /** @class */ (function (_super) {
1604
1647
  ImageEditor.prototype.straightenImage = function (degree) {
1605
1648
  var isStraightened = false;
1606
1649
  if (degree >= -45 && degree <= 45) {
1650
+ this.applyShapes();
1607
1651
  isStraightened = true;
1608
1652
  this.notify('transform', { prop: 'straightenImage', value: { degree: degree } });
1609
1653
  this.notify('draw', { prop: 'redrawDownScale' });
@@ -1634,6 +1678,9 @@ var ImageEditor = /** @class */ (function (_super) {
1634
1678
  if (setting.strokeWidth) {
1635
1679
  this.activeObj.strokeSettings.strokeWidth = setting.strokeWidth;
1636
1680
  }
1681
+ if (setting.index) {
1682
+ this.activeObj.order = setting.index;
1683
+ }
1637
1684
  if (setting.type === 'FreehandDraw' && setting.strokeWidth) {
1638
1685
  this.notify('freehand-draw', { prop: 'setPenStrokeWidth', onPropertyChange: false, value: { value: setting.strokeWidth } });
1639
1686
  }
@@ -1641,7 +1688,7 @@ var ImageEditor = /** @class */ (function (_super) {
1641
1688
  else {
1642
1689
  if (setting.type.toLowerCase() === 'text' && (this.textArea.style.display === 'block' ||
1643
1690
  this.textArea.style.display === 'inline-block')) {
1644
- this.okBtn();
1691
+ this.okBtn(null, true);
1645
1692
  isTextArea = true;
1646
1693
  }
1647
1694
  this.notify('shape', { prop: 'selectShape', onPropertyChange: false, value: { id: setting.id, obj: obj } });
@@ -1673,7 +1720,7 @@ var ImageEditor = /** @class */ (function (_super) {
1673
1720
  if (freehandObj['bool']) {
1674
1721
  this.notify('undo-redo', { prop: 'setPreventUR', value: { bool: true } });
1675
1722
  }
1676
- this.okBtn(isSelected);
1723
+ this.okBtn(isSelected, true);
1677
1724
  if (freehandObj['bool']) {
1678
1725
  this.notify('undo-redo', { prop: 'setPreventUR', value: { bool: false } });
1679
1726
  }
@@ -1703,7 +1750,7 @@ var ImageEditor = /** @class */ (function (_super) {
1703
1750
  this.notify('shape', { prop: 'selectShape', onPropertyChange: false, value: { id: shapeId, obj: obj } });
1704
1751
  if (obj['isSelected']) {
1705
1752
  this.notify('toolbar', { prop: 'duplicateShape', onPropertyChange: false, value: { isPreventUndoRedo: false } });
1706
- this.okBtn();
1753
+ this.okBtn(null, true);
1707
1754
  this.notify('draw', { prop: 'redrawDownScale' });
1708
1755
  }
1709
1756
  }
@@ -1731,6 +1778,13 @@ var ImageEditor = /** @class */ (function (_super) {
1731
1778
  */
1732
1779
  ImageEditor.prototype.enableTextEditing = function () {
1733
1780
  var activeObj = extend({}, this.activeObj, {}, true);
1781
+ if (!activeObj.order) {
1782
+ this.noPushUndo = true;
1783
+ this.okBtn();
1784
+ this.noPushUndo = false;
1785
+ this.selectShape(activeObj.currIndex);
1786
+ activeObj.order = this.activeObj.order;
1787
+ }
1734
1788
  this.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
1735
1789
  this.notify('draw', { prop: 'render-image', value: { isMouseWheel: null, isPreventClearRect: null, isFrame: false } });
1736
1790
  this.activeObj = activeObj;
@@ -1776,7 +1830,173 @@ var ImageEditor = /** @class */ (function (_super) {
1776
1830
  }
1777
1831
  return canRedo;
1778
1832
  };
1833
+ /**
1834
+ * Applies the operations performed in the Image Editor, such as annotation drawings.
1835
+ *
1836
+ * @returns{void}
1837
+ * @remarks
1838
+ * This method applies the actions performed after enabling annotation drawings, ensuring that the drawn annotations are applied to the image.
1839
+ */
1840
+ ImageEditor.prototype.apply = function () {
1841
+ this.closeOverlayTbar();
1842
+ this.okBtn(null, true);
1843
+ };
1844
+ /**
1845
+ * Discards the operations performed in the Image Editor, such as annotation drawings.
1846
+ *
1847
+ * @returns{void}
1848
+ * @remarks
1849
+ * This method discards the actions performed after enabling annotation drawings, ensuring that the drawn annotations are not applied to the image.
1850
+ */
1851
+ ImageEditor.prototype.discard = function () {
1852
+ this.notify('draw', { prop: 'performCancel', value: { isContextualToolbar: this.closeOverlayTbar(), isFinalCancel: true } });
1853
+ };
1854
+ /**
1855
+ * Enable or disable a shape drawing option in an Image Editor.
1856
+ *
1857
+ * @param {ShapeType} shapeType - Specifies the type of shape to be enabled or disabled for drawing.
1858
+ * @param {boolean} isEnabled - Optional. Specifies a value to indicate whether to enable or disable shape drawing. The default value is true.
1859
+ *
1860
+ * @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.
1861
+ *
1862
+ * @returns {void}.
1863
+ */
1864
+ ImageEditor.prototype.enableShapeDrawing = function (shapeType, isEnabled) {
1865
+ if (isEnabled) {
1866
+ this.drawingShape = shapeType.toLowerCase();
1867
+ this.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
1868
+ }
1869
+ if (shapeType && isEnabled) {
1870
+ this.currObjType.shape = shapeType.toLowerCase();
1871
+ this.activeObj.shape = this.currObjType.shape;
1872
+ this.currObjType.isDragging = this.currObjType.isCustomCrop = false;
1873
+ this.activeObj.shapeDegree = this.transform.degree;
1874
+ this.activeObj.shapeFlip = this.transform.currFlipState;
1875
+ this.activeObj.textFlip = this.transform.currFlipState;
1876
+ this.activeObj.flipObjColl = [];
1877
+ var orderObj = { order: null };
1878
+ this.notify('shape', { prop: 'getNewOrder', onPropertyChange: false, value: { obj: orderObj } });
1879
+ this.activeObj.order = orderObj['order'];
1880
+ this.notify('selection', { prop: 'annotate', value: { shape: this.currObjType.shape } });
1881
+ if (this.currObjType.shape === 'text') {
1882
+ this.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: { type: 'text',
1883
+ isApplyBtn: null, isCropping: null, isZooming: null, cType: null } });
1884
+ }
1885
+ else {
1886
+ this.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: { type: 'shapes',
1887
+ isApplyBtn: null, isCropping: null, isZooming: null, cType: null } });
1888
+ }
1889
+ this.notify('toolbar', { prop: 'update-toolbar-items', onPropertyChange: false });
1890
+ }
1891
+ else if (!isEnabled) {
1892
+ this.okBtn(null, true);
1893
+ }
1894
+ };
1895
+ /**
1896
+ * Moves a shape to the front of all other shapes based on the given shape id.
1897
+ * Use 'getShapeSettings' method to get the shape id which is then passed to perform moving.
1898
+ *
1899
+ * @param {string} shapeId - Specifies the shape id to move the shape on an image.
1900
+ * @returns {void}.
1901
+ *
1902
+ */
1903
+ ImageEditor.prototype.bringToFront = function (shapeId) {
1904
+ if (this.selectShape(shapeId)) {
1905
+ this.updateShapeOrder(shapeId, 'bringToFront');
1906
+ this.apply();
1907
+ }
1908
+ };
1909
+ /**
1910
+ * Moves a shape to ahead of one shape based on the given shape id.
1911
+ * Use 'getShapeSettings' method to get the shape id which is then passed to perform moving.
1912
+ *
1913
+ * @param {string} shapeId - Specifies the shape id to move the shape on an image.
1914
+ * @returns {void}.
1915
+ *
1916
+ */
1917
+ ImageEditor.prototype.bringForward = function (shapeId) {
1918
+ if (this.selectShape(shapeId)) {
1919
+ this.updateShapeOrder(shapeId, 'bringForward');
1920
+ this.apply();
1921
+ }
1922
+ };
1923
+ /**
1924
+ * Moves a shape to behind all other shapes based on the given shape id.
1925
+ * Use 'getShapeSettings' method to get the shape id which is then passed to perform moving.
1926
+ *
1927
+ * @param {string} shapeId - Specifies the shape id to move the shape on an image.
1928
+ * @returns {void}.
1929
+ *
1930
+ */
1931
+ ImageEditor.prototype.sendToBack = function (shapeId) {
1932
+ if (this.selectShape(shapeId)) {
1933
+ this.updateShapeOrder(shapeId, 'sendToBack');
1934
+ this.apply();
1935
+ }
1936
+ };
1937
+ /**
1938
+ * Moves a shape to behind one shape based on the given shape id.
1939
+ * Use 'getShapeSettings' method to get the shape id which is then passed to perform moving.
1940
+ *
1941
+ * @param {string} shapeId - Specifies the shape id to move the shape on an image.
1942
+ * @returns {void}.
1943
+ *
1944
+ */
1945
+ ImageEditor.prototype.sendBackward = function (shapeId) {
1946
+ if (this.selectShape(shapeId)) {
1947
+ this.updateShapeOrder(shapeId, 'sendBackward');
1948
+ this.apply();
1949
+ }
1950
+ };
1951
+ /**
1952
+ * Clears the loaded image in the Image Editor.
1953
+ *
1954
+ * @returns{void}
1955
+ * @remarks
1956
+ * 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).
1957
+ */
1958
+ ImageEditor.prototype.clearImage = function () {
1959
+ this.reset();
1960
+ this.isImageLoaded = false;
1961
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
1962
+ this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
1963
+ var btoolbar = document.getElementById(this.element.id + '_bottomToolbar');
1964
+ if (Browser.isDevice && btoolbar) {
1965
+ document.getElementById(this.element.id + '_bottomToolbar').style.display = 'none';
1966
+ }
1967
+ this.notify('toolbar', { prop: 'destroy-top-toolbar', onPropertyChange: false });
1968
+ this.notify('toolbar', { prop: 'create-toolbar', onPropertyChange: false });
1969
+ this.notify('toolbar', { prop: 'create-contextual-toolbar', onPropertyChange: false });
1970
+ document.getElementById(this.element.id + '_dropArea').style.display = 'block';
1971
+ };
1779
1972
  // Toolbar related codes
1973
+ ImageEditor.prototype.applyShapes = function () {
1974
+ if (this.isUndoRedoStack) {
1975
+ return;
1976
+ }
1977
+ var shapes = ['rectangle', 'ellipse', 'line', 'arrow', 'path', 'text', 'image'];
1978
+ var dummyObj = { bool: false };
1979
+ this.notify('selection', { prop: 'getFreehandDrawEditing', onPropertyChange: false, value: { obj: dummyObj } });
1980
+ if (dummyObj['bool'] || this.togglePen || (this.activeObj.shape && shapes.indexOf(this.activeObj.shape) !== -1) ||
1981
+ this.drawingShape) {
1982
+ this.okBtn(null, true);
1983
+ }
1984
+ };
1985
+ ImageEditor.prototype.closeOverlayTbar = function () {
1986
+ var isContextualToolbar = false;
1987
+ var frameObject = { bool: null };
1988
+ this.notify('toolbar', { prop: 'getFrameToolbar', onPropertyChange: false, value: { obj: frameObject } });
1989
+ if (!frameObject['bool'] && this.element.querySelector('.e-contextual-toolbar-wrapper')) {
1990
+ if (!this.element.querySelector('.e-contextual-toolbar-wrapper').classList.contains('e-hide')) {
1991
+ isContextualToolbar = true;
1992
+ }
1993
+ var straightenObj = { bool: this.isStraightening };
1994
+ if (!Browser.isDevice || (Browser.isDevice && !straightenObj['bool'])) {
1995
+ this.element.querySelector('.e-contextual-toolbar-wrapper').classList.add('e-hide');
1996
+ }
1997
+ }
1998
+ return isContextualToolbar;
1999
+ };
1780
2000
  ImageEditor.prototype.toolbarTemplateFn = function () {
1781
2001
  var template;
1782
2002
  var templateID = this.element.id + '_toolbar';
@@ -1979,10 +2199,17 @@ var ImageEditor = /** @class */ (function (_super) {
1979
2199
  * Handles the OK button operation
1980
2200
  *
1981
2201
  * @param { boolean } isMouseDown - Specifies whether it is a mouse down.
2202
+ * @param { boolean } isFinalApply - Specifies whether it is a final apply.
1982
2203
  * @hidden
1983
2204
  * @returns {void}.
1984
2205
  */
1985
- ImageEditor.prototype.okBtn = function (isMouseDown) {
2206
+ ImageEditor.prototype.okBtn = function (isMouseDown, isFinalApply) {
2207
+ if (isFinalApply) {
2208
+ this.noPushUndo = false;
2209
+ var tempActiveObj = { activePoint: { startX: 0, startY: 0, endX: 0, endY: 0, width: 0, height: 0 },
2210
+ flipObjColl: [], triangle: [], triangleRatio: [], order: null };
2211
+ this.notify('selection', { prop: 'setTempActObj', onPropertyChange: false, value: { obj: tempActiveObj } });
2212
+ }
1986
2213
  var ctWrapper = this.element.querySelector('.e-contextual-toolbar-wrapper');
1987
2214
  if (ctWrapper) {
1988
2215
  ctWrapper.classList.remove('e-frame-wrapper');
@@ -2071,6 +2298,7 @@ var ImageEditor = /** @class */ (function (_super) {
2071
2298
  this.notify('selection', { prop: 'getFreehandDrawEditing', onPropertyChange: false, value: { obj: obj } });
2072
2299
  var frameObject = { bool: null };
2073
2300
  this.notify('toolbar', { prop: 'getFrameToolbar', onPropertyChange: false, value: { obj: frameObject } });
2301
+ var sliderWrap = document.querySelector('#' + this.element.id + '_sliderWrapper');
2074
2302
  if (selElem) {
2075
2303
  this.currentFilter = selElem.children[0].children[0].id.replace('Canvas', '');
2076
2304
  }
@@ -2102,17 +2330,18 @@ var ImageEditor = /** @class */ (function (_super) {
2102
2330
  this.notify('draw', { prop: 'clearOuterCanvas', onPropertyChange: false, value: { context: this.lowerContext } });
2103
2331
  this.notify('draw', { prop: 'clearOuterCanvas', onPropertyChange: false, value: { context: this.upperContext } });
2104
2332
  }
2105
- else if (document.querySelector('#' + this.element.id + '_sliderWrapper') || this.currObjType.isFiltered) {
2333
+ else if (sliderWrap || this.currObjType.isFiltered) {
2106
2334
  this.initialAdjustmentValue = this.canvasFilter = this.lowerContext.filter;
2107
2335
  this.currObjType.isFiltered = false;
2108
2336
  var obj_4 = { value: null };
2109
2337
  this.notify('draw', { prop: 'getTempAdjustmentValue', value: { obj: obj_4 } });
2110
- if (obj_4['value'] !== this.lowerContext.filter) {
2338
+ if (obj_4['value'] !== this.lowerContext.filter && (!sliderWrap ||
2339
+ !sliderWrap.classList.contains('e-ie-finetune-slider-wrap'))) {
2111
2340
  this.notify('undo-redo', { prop: 'updateCurrUrc', value: { type: 'ok' } });
2112
2341
  }
2113
2342
  if ((this.activeObj.activePoint.width !== 0 && this.activeObj.activePoint.height !== 0) ||
2114
2343
  (this.activeObj.shape === 'path' && this.activeObj.pointColl.length > 0)) {
2115
- this.notify('shape', { prop: 'applyActObj', onPropertyChange: false, value: { isMouseDown: isMouseDown } });
2344
+ this.notify('shape', { prop: 'applyActObj', onPropertyChange: false, value: { isMouseDown: null } });
2116
2345
  }
2117
2346
  }
2118
2347
  else if (obj['bool']) {
@@ -2120,13 +2349,14 @@ var ImageEditor = /** @class */ (function (_super) {
2120
2349
  this.notify('selection', { prop: 'setFreehandDrawCustomized', value: { isFreehandDrawCustomized: false } });
2121
2350
  this.notify('toolbar', { prop: 'destroy-qa-toolbar' });
2122
2351
  this.notify('undo-redo', { prop: 'updateCurrUrc', value: { type: 'ok' } });
2352
+ this.notify('freehand-draw', { prop: 'resetFreehandDrawSelectedId', onPropertyChange: false });
2123
2353
  }
2124
2354
  else if ((this.activeObj.activePoint.width !== 0 || this.activeObj.activePoint.height !== 0) ||
2125
2355
  (this.activeObj.shape === 'path' && this.activeObj.pointColl.length > 0)) {
2126
2356
  if (this.activeObj.shape === 'image') {
2127
2357
  this.notify('draw', { prop: 'setImageApply', onPropertyChange: false, value: { bool: true } });
2128
2358
  }
2129
- this.notify('shape', { prop: 'applyActObj', onPropertyChange: false, value: { isMouseDown: isMouseDown } });
2359
+ this.notify('shape', { prop: 'applyActObj', onPropertyChange: false, value: { isMouseDown: null } });
2130
2360
  }
2131
2361
  else {
2132
2362
  if (JSON.stringify(this.frameObj) !== JSON.stringify(this.tempFrameObj)) {
@@ -2154,6 +2384,35 @@ var ImageEditor = /** @class */ (function (_super) {
2154
2384
  this.isResizeOkBtn = false;
2155
2385
  this.notify('draw', { prop: 'redrawDownScale' });
2156
2386
  this.isChangesSaved = false;
2387
+ if (isFinalApply) {
2388
+ this.drawingShape = null;
2389
+ this.notify('draw', { prop: 'resetTempObjColl' });
2390
+ this.notify('draw', { prop: 'resetTempPointColl' });
2391
+ }
2392
+ };
2393
+ /**
2394
+ * Handles the OK button operation
2395
+ *
2396
+ * @param { string } id - Specifies shape id to return.
2397
+ * @hidden
2398
+ * @returns {SelectionPoint | Object}.
2399
+ */
2400
+ ImageEditor.prototype.getObjFromId = function (id) {
2401
+ var obj;
2402
+ if (this.activeObj.currIndex && this.activeObj.currIndex === id) {
2403
+ obj = extend({}, this.activeObj, {}, true);
2404
+ }
2405
+ else {
2406
+ for (var i = 0; i < this.shapeColl.length; i++) {
2407
+ var shapeId = this.shapeColl[i].id ? this.shapeColl[i].id :
2408
+ this.shapeColl[i].currIndex;
2409
+ if (shapeId === id) {
2410
+ obj = extend({}, this.shapeColl[i], {}, true);
2411
+ break;
2412
+ }
2413
+ }
2414
+ }
2415
+ return obj;
2157
2416
  };
2158
2417
  /**
2159
2418
  * Set the temporary filter properties.
@@ -2221,7 +2480,8 @@ var ImageEditor = /** @class */ (function (_super) {
2221
2480
  this.objColl = objColl;
2222
2481
  this.pointColl = pointColl;
2223
2482
  this.freehandCounter = pointColl.length;
2224
- this.notify('shape', { prop: 'iterateObjColl', onPropertyChange: false });
2483
+ this.notify('shape', { prop: 'drawAnnotations', onPropertyChange: false,
2484
+ value: { ctx: this.lowerContext, shape: 'iterate', pen: 'iterate', isPreventApply: null } });
2225
2485
  this.lowerContext.filter = this.canvasFilter = tempFilter;
2226
2486
  this.frameObj = tempFrame;
2227
2487
  return data;
@@ -2286,7 +2546,7 @@ var ImageEditor = /** @class */ (function (_super) {
2286
2546
  var typeToSelectionType = { 'CropCustom': 'Custom', 'CropSquare': 'Square', 'CropCircle': 'Circle',
2287
2547
  'Crop3:2': '3:2', 'Crop4:3': '4:3', 'Crop5:4': '5:4', 'Crop7:5': '7:5', 'Crop16:9': '16:9',
2288
2548
  'Crop2:3': '2:3', 'Crop3:4': '3:4', 'Crop4:5': '4:5', 'Crop5:7': '5:7', 'Crop9:16': '9:16' };
2289
- return typeToSelectionType["" + type];
2549
+ return typeToSelectionType["" + type] ? typeToSelectionType["" + type] : type.split('Crop')[1];
2290
2550
  };
2291
2551
  /** Clears the context.
2292
2552
  *
@@ -2349,6 +2609,7 @@ var ImageEditor = /** @class */ (function (_super) {
2349
2609
  toolbar_2.refreshOverflow();
2350
2610
  }
2351
2611
  }
2612
+ // eslint-disable-next-line max-len
2352
2613
  var shapeChangedArgs = { action: type, currentShapeSettings: extend({}, shapeSettings, {}, true) };
2353
2614
  this.trigger('shapeChange', shapeChangedArgs);
2354
2615
  };
@@ -2383,7 +2644,9 @@ var ImageEditor = /** @class */ (function (_super) {
2383
2644
  value: { obj: this.activeObj, isTextArea: true } });
2384
2645
  var temp = this.activeObj.textSettings.fontFamily;
2385
2646
  this.activeObj.textSettings.fontFamily = this.toPascalCase(id);
2386
- this.notify('shape', { prop: 'redraw-text' });
2647
+ if (this.activeObj.activePoint.width !== 0 || this.activeObj.activePoint.height !== 0) {
2648
+ this.notify('shape', { prop: 'redraw-text' });
2649
+ }
2387
2650
  this.objColl.push(this.activeObj);
2388
2651
  if (this.activeObj.activePoint.width !== 0 || this.activeObj.activePoint.height !== 0) {
2389
2652
  this.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false,
@@ -2408,7 +2671,9 @@ var ImageEditor = /** @class */ (function (_super) {
2408
2671
  var fontFamily = this.activeObj.textSettings.fontFamily = this.toPascalCase(id);
2409
2672
  this.notify('shape', { prop: 'setTextSettings', onPropertyChange: false,
2410
2673
  value: { textSettings: null, fontFamily: fontFamily, fontSize: null } });
2411
- this.notify('shape', { prop: 'redraw-text' });
2674
+ if (this.activeObj.activePoint.width !== 0 || this.activeObj.activePoint.height !== 0) {
2675
+ this.notify('shape', { prop: 'redraw-text' });
2676
+ }
2412
2677
  this.objColl.push(this.activeObj);
2413
2678
  if (this.activeObj.activePoint.width !== 0 || this.activeObj.activePoint.height !== 0) {
2414
2679
  this.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false,
@@ -2506,11 +2771,13 @@ var ImageEditor = /** @class */ (function (_super) {
2506
2771
  this.activeObj.textSettings.fontSize * 0.5;
2507
2772
  var height = rows.length * (this.activeObj.textSettings.fontSize +
2508
2773
  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' });
2774
+ if (this.activeObj.activePoint.width !== 0 || this.activeObj.activePoint.height !== 0) {
2775
+ this.notify('selection', { prop: 'setTextSelection', onPropertyChange: false,
2776
+ value: { width: width, height: height } });
2777
+ this.notify('draw', { prop: 'updateActiveObject', onPropertyChange: false, value: { actPoint: this.activeObj.activePoint, obj: this.activeObj,
2778
+ isMouseMove: null, x: null, y: null } });
2779
+ this.notify('shape', { prop: 'redraw-text' });
2780
+ }
2514
2781
  this.objColl.push(this.activeObj);
2515
2782
  if (this.activeObj.activePoint.width !== 0 || this.activeObj.activePoint.height !== 0) {
2516
2783
  this.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false,
@@ -2562,8 +2829,8 @@ var ImageEditor = /** @class */ (function (_super) {
2562
2829
  previousPointColl: prevObj.pointColl, previousSelPointColl: prevObj.selPointColl,
2563
2830
  previousCropObj: prevCropObj, previousText: null,
2564
2831
  currentText: null, previousFilter: null, isCircleCrop: null } });
2832
+ this.notify('selection', { prop: 'redrawShape', value: { obj: this.objColl[this.objColl.length - 1] } });
2565
2833
  }
2566
- this.notify('selection', { prop: 'redrawShape', value: { obj: this.objColl[this.objColl.length - 1] } });
2567
2834
  }
2568
2835
  }
2569
2836
  else if (this.textArea.style.display === 'block' || this.textArea.style.display === 'inline-block') {
@@ -2590,7 +2857,9 @@ var ImageEditor = /** @class */ (function (_super) {
2590
2857
  previousCropObj: prevCropObj, previousText: null,
2591
2858
  currentText: null, previousFilter: null, isCircleCrop: null } });
2592
2859
  }
2593
- this.notify('selection', { prop: 'redrawShape', value: { obj: this.objColl[this.objColl.length - 1] } });
2860
+ if (this.activeObj.activePoint.width !== 0 || this.activeObj.activePoint.height !== 0) {
2861
+ this.notify('selection', { prop: 'redrawShape', value: { obj: this.objColl[this.objColl.length - 1] } });
2862
+ }
2594
2863
  }
2595
2864
  var shapeChangedArgs = { action: 'font-color', currentShapeSettings: extend({}, shapeSettings, {}, true) };
2596
2865
  shapeChangedArgs.currentShapeSettings.fillColor = value;
@@ -2683,18 +2952,8 @@ var ImageEditor = /** @class */ (function (_super) {
2683
2952
  this.notify('freehand-draw', { prop: 'getFreehandSelectedIndex', onPropertyChange: false, value: { obj: indexObj } });
2684
2953
  if (indexObj['freehandSelectedIndex'] !== null && indexObj['freehandSelectedIndex'] !== undefined) {
2685
2954
  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
2955
  this.notify('draw', { prop: 'render-image', value: { isMouseWheel: null } });
2696
2956
  this.notify('draw', { prop: 'redrawDownScale' });
2697
- this.pointColl = temp_1;
2698
2957
  this.notify('freehand-draw', { prop: 'hoverFhd', onPropertyChange: false,
2699
2958
  value: { strokeColor: null, strokeWidth: null } });
2700
2959
  }
@@ -2960,7 +3219,6 @@ var ImageEditor = /** @class */ (function (_super) {
2960
3219
  * Apply rotate image.
2961
3220
  *
2962
3221
  * @param { string } rotate - Specifies the direction of rotation.
2963
- * @param { boolean } isPreventURC - Specifies to update undo redo collection.
2964
3222
  * @hidden
2965
3223
  * @returns {void}.
2966
3224
  */
@@ -2971,9 +3229,11 @@ var ImageEditor = /** @class */ (function (_super) {
2971
3229
  this.notify('shape', { prop: 'updImgRatioForActObj', onPropertyChange: false });
2972
3230
  }
2973
3231
  this.notify('shape', { prop: 'pushActItemIntoObj' });
3232
+ // eslint-disable-next-line prefer-const
2974
3233
  prevCropObj = extend({}, this.cropObj, {}, true);
2975
3234
  var object = { currObj: {} };
2976
3235
  this.notify('filter', { prop: 'getCurrentObj', onPropertyChange: false, value: { object: object } });
3236
+ // eslint-disable-next-line prefer-const
2977
3237
  prevObj = object['currObj'];
2978
3238
  prevObj.objColl = extend([], this.objColl, [], true);
2979
3239
  prevObj.pointColl = extend([], this.pointColl, [], true);
@@ -3061,8 +3321,9 @@ var ImageEditor = /** @class */ (function (_super) {
3061
3321
  */
3062
3322
  ImageEditor.prototype.transformSelect = function (type) {
3063
3323
  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) {
3324
+ 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',
3325
+ 'crop-9:16', 'crop-16:9'].indexOf(this.activeObj.shape) !== -1 || (this.activeObj.shape.indexOf('crop-') !== -1 &&
3326
+ this.activeObj.shape !== 'crop-custom' && this.activeObj.shape !== 'crop-square' && this.activeObj.shape !== 'crop-circle'))) {
3066
3327
  this.activeObj.shape = 'crop-' + this.activeObj.shape.split('-')[1].split(':')[1] + ':' + this.activeObj.shape.split('-')[1].split(':')[0];
3067
3328
  this.notify('toolbar', { prop: 'performCropTransformClick', value: { shape: this.activeObj.shape, isTransform: true } });
3068
3329
  }
@@ -3093,8 +3354,8 @@ var ImageEditor = /** @class */ (function (_super) {
3093
3354
  }
3094
3355
  }
3095
3356
  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 } });
3357
+ this.notify('shape', { prop: 'drawAnnotations', onPropertyChange: false,
3358
+ value: { ctx: this.lowerContext, shape: 'zoom', pen: 'zoom', isPreventApply: null } });
3098
3359
  }
3099
3360
  this.setInitialZoomState();
3100
3361
  var activeObj = extend({}, this.activeObj, {}, true);
@@ -3120,8 +3381,8 @@ var ImageEditor = /** @class */ (function (_super) {
3120
3381
  this.notify('selection', { prop: 'updPtCollForShpRot', onPropertyChange: false, value: { obj: this.objColl[i] } });
3121
3382
  }
3122
3383
  }
3123
- this.notify('shape', { prop: 'zoomObjColl', onPropertyChange: false, value: { isPreventApply: null } });
3124
- this.notify('freehand-draw', { prop: 'zoomFHDColl', onPropertyChange: false, value: { isPreventApply: null } });
3384
+ this.notify('shape', { prop: 'drawAnnotations', onPropertyChange: false,
3385
+ value: { ctx: this.lowerContext, shape: 'zoom', pen: 'zoom', isPreventApply: null } });
3125
3386
  this.notify('draw', { prop: 'render-image', value: { isMouseWheel: false } });
3126
3387
  this.notify('draw', { prop: 'drawObject', onPropertyChange: false, value: { canvas: 'duplicate', obj: straightenObj } });
3127
3388
  this.notify('draw', { prop: 'setStraightenActObj', value: { activeObj: null } });
@@ -3157,10 +3418,11 @@ var ImageEditor = /** @class */ (function (_super) {
3157
3418
  /**
3158
3419
  * Performs Straightening action.
3159
3420
  *
3421
+ * @param { number } value - Specifies the degree of straightening.
3160
3422
  * @hidden
3161
- * @returns {void}.
3423
+ * @returns {void} .
3162
3424
  */
3163
- ImageEditor.prototype.setStraighten = function (value, isMethod) {
3425
+ ImageEditor.prototype.setStraighten = function (value) {
3164
3426
  var straightenEventArgs = { cancel: false, previousDegree: this.transform.straighten, currentDegree: value };
3165
3427
  this.trigger('rotating', straightenEventArgs);
3166
3428
  if (!straightenEventArgs.cancel) {
@@ -3182,7 +3444,6 @@ var ImageEditor = /** @class */ (function (_super) {
3182
3444
  if (stValPan) {
3183
3445
  stValPan.innerHTML = value.toString() + '&#176';
3184
3446
  }
3185
- var prevValue = this.transform.straighten;
3186
3447
  var obj = extend({}, this.activeObj, null, true);
3187
3448
  this.notify('freehand-draw', { prop: 'setCenterSelPoints' });
3188
3449
  this.transform.straighten = value;
@@ -3238,6 +3499,7 @@ var ImageEditor = /** @class */ (function (_super) {
3238
3499
  value: { obj: obj_6, dimension: { width: ctx.canvas.width, height: ctx.canvas.height } } });
3239
3500
  }
3240
3501
  var dimension = void 0;
3502
+ // eslint-disable-next-line prefer-const
3241
3503
  dimension = this.getRotatedCanvasDim(this.baseImg.width, this.baseImg.height, this.transform.straighten);
3242
3504
  this.img.srcWidth = ctx.canvas.width = dimension.width;
3243
3505
  this.img.srcHeight = ctx.canvas.height = dimension.height;
@@ -3255,8 +3517,11 @@ var ImageEditor = /** @class */ (function (_super) {
3255
3517
  /**
3256
3518
  * Returns rotated canvas dimension.
3257
3519
  *
3520
+ * @param { number } width - Specifies the width of the canvas.
3521
+ * @param { number } height - Specifies the height of the canvas.
3522
+ * @param { number } angle - Specifies the angle of rotation in degrees.
3258
3523
  * @hidden
3259
- * @returns {void}.
3524
+ * @returns {void} .
3260
3525
  */
3261
3526
  ImageEditor.prototype.getRotatedCanvasDim = function (width, height, angle) {
3262
3527
  var angleRad = angle * Math.PI / 180;
@@ -3268,7 +3533,64 @@ var ImageEditor = /** @class */ (function (_super) {
3268
3533
  var maxY = Math.max(0, width * sinAngle, height * Math.sin(Math.PI / 2 - angleRad), width * sinAngle + height * Math.sin(Math.PI / 2 - angleRad));
3269
3534
  return { width: Math.ceil(maxX - minX), height: Math.ceil(maxY - minY) };
3270
3535
  };
3271
- ;
3536
+ /**
3537
+ * Apply Shape order.
3538
+ *
3539
+ * @param { string } id - Specifies the id of the shape to change the order.
3540
+ * @param { string } value - Specifies the order of the shapes.
3541
+ * @hidden
3542
+ * @returns {void}.
3543
+ */
3544
+ ImageEditor.prototype.updateShapeOrder = function (id, value) {
3545
+ var shapeObj = this.getObjFromId(id);
3546
+ if ((shapeObj.shape && (shapeObj.shape !== 'path' ||
3547
+ (shapeObj.shape === 'path' && shapeObj.pointColl.length > 0))) ||
3548
+ (shapeObj && shapeObj['id'] && shapeObj['id'].indexOf('pen') > -1)) {
3549
+ var obj = { shapeSettingsObj: {} };
3550
+ this.notify('selection', { prop: 'updatePrevShapeSettings', onPropertyChange: false, value: { obj: obj } });
3551
+ var shapeSettings = obj['shapeSettingsObj'];
3552
+ if (shapeObj.shape) {
3553
+ this.notify('shape', { prop: 'pushActItemIntoObj' });
3554
+ }
3555
+ var prevCropObj = extend({}, this.cropObj, {}, true);
3556
+ var object = { currObj: {} };
3557
+ this.notify('filter', { prop: 'getCurrentObj', onPropertyChange: false, value: { object: object } });
3558
+ var prevObj = object['currObj'];
3559
+ prevObj.objColl = extend([], this.objColl, [], true);
3560
+ prevObj.pointColl = extend([], this.pointColl, [], true);
3561
+ prevObj.afterCropActions = extend([], this.afterCropActions, [], true);
3562
+ var selPointCollObj = { selPointColl: null };
3563
+ this.notify('freehand-draw', { prop: 'getSelPointColl', onPropertyChange: false,
3564
+ value: { obj: selPointCollObj } });
3565
+ prevObj.selPointColl = extend([], selPointCollObj['selPointColl'], [], true);
3566
+ if (shapeObj.shape) {
3567
+ this.objColl.pop();
3568
+ }
3569
+ this.notify('shape', { prop: 'z-order', onPropertyChange: false, value: { obj: shapeObj, value: value } });
3570
+ if (shapeObj.shape) {
3571
+ this.notify('shape', { prop: 'setStrokeSettings', value: { strokeSettings: null, strokeColor: null, fillColor: null,
3572
+ strokeWidth: shapeObj.strokeSettings.strokeWidth } });
3573
+ this.objColl.push(shapeObj);
3574
+ }
3575
+ this.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false,
3576
+ value: { operation: 'shapeTransform', previousObj: prevObj, previousObjColl: prevObj.objColl,
3577
+ previousPointColl: prevObj.pointColl, previousSelPointColl: prevObj.selPointColl,
3578
+ previousCropObj: prevCropObj, previousText: null,
3579
+ currentText: null, previousFilter: null, isCircleCrop: null } });
3580
+ if (shapeObj.shape) {
3581
+ this.notify('selection', { prop: 'redrawShape', value: { obj: this.objColl[this.objColl.length - 1] } });
3582
+ this.activeObj.order = shapeObj.order;
3583
+ }
3584
+ var shapeChangedArgs = { action: 'stroke-width', previousShapeSettings: extend({}, shapeSettings, {}, true),
3585
+ currentShapeSettings: extend({}, shapeSettings, {}, true) };
3586
+ shapeChangedArgs.currentShapeSettings.strokeWidth = this.activeObj.strokeSettings.strokeWidth;
3587
+ }
3588
+ else if (this.activeObj.shape && (this.activeObj.shape === 'path' &&
3589
+ this.activeObj.pointColl.length === 0)) {
3590
+ this.notify('shape', { prop: 'setStrokeSettings', value: { strokeSettings: null, strokeColor: null, fillColor: null,
3591
+ strokeWidth: this.activeObj.strokeSettings.strokeWidth } });
3592
+ }
3593
+ };
3272
3594
  ImageEditor.prototype.getStraightenFlipState = function () {
3273
3595
  var flipState = '';
3274
3596
  if (this.rotateFlipColl.length > 0) {
@@ -3288,6 +3610,7 @@ var ImageEditor = /** @class */ (function (_super) {
3288
3610
  return flipState;
3289
3611
  };
3290
3612
  ImageEditor.prototype.initializeZoomSettings = function () {
3613
+ this.theme = isNullOrUndefined(this.theme) ? 'Bootstrap5' : this.theme;
3291
3614
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
3292
3615
  if (isNullOrUndefined(this.zoomSettings.zoomTrigger) || this.zoomSettings.zoomTrigger === 0) {
3293
3616
  this.zoomSettings.zoomTrigger = (ZoomTrigger.MouseWheel | ZoomTrigger.Pinch | ZoomTrigger.Toolbar | ZoomTrigger.Commands);
@@ -3316,7 +3639,10 @@ var ImageEditor = /** @class */ (function (_super) {
3316
3639
  FabricDark: { primaryColor: '#0074cc', secondaryColor: '#fff' },
3317
3640
  Highcontrast: { primaryColor: '#000000', secondaryColor: '#fff' },
3318
3641
  Material3: { primaryColor: '#6750a4', secondaryColor: '#fff' },
3319
- Material3Dark: { primaryColor: '#d0bcff', secondaryColor: '#fff' }
3642
+ Material3Dark: { primaryColor: '#d0bcff', secondaryColor: '#fff' },
3643
+ Fluent2: { primaryColor: '#0f6cbd', secondaryColor: '#fff' },
3644
+ Fluent2Dark: { primaryColor: '#115ea3', secondaryColor: '#fff' },
3645
+ Fluent2Highcontrast: { primaryColor: '#1aebff', secondaryColor: '#fff' }
3320
3646
  };
3321
3647
  };
3322
3648
  var ImageEditor_1;