@syncfusion/ej2-image-editor 29.2.5 → 30.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 (95) hide show
  1. package/.eslintrc.json +2 -0
  2. package/dist/ej2-image-editor.umd.min.js +2 -2
  3. package/dist/ej2-image-editor.umd.min.js.map +1 -1
  4. package/dist/es6/ej2-image-editor.es2015.js +898 -227
  5. package/dist/es6/ej2-image-editor.es2015.js.map +1 -1
  6. package/dist/es6/ej2-image-editor.es5.js +920 -237
  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 +15 -47
  12. package/src/image-editor/action/crop.js +1 -1
  13. package/src/image-editor/action/draw.d.ts +1 -0
  14. package/src/image-editor/action/draw.js +103 -31
  15. package/src/image-editor/action/export.js +3 -0
  16. package/src/image-editor/action/selection.d.ts +1 -0
  17. package/src/image-editor/action/selection.js +43 -5
  18. package/src/image-editor/action/shape.d.ts +1 -0
  19. package/src/image-editor/action/shape.js +334 -49
  20. package/src/image-editor/action/transform.js +50 -43
  21. package/src/image-editor/action/undo-redo.d.ts +2 -0
  22. package/src/image-editor/action/undo-redo.js +22 -1
  23. package/src/image-editor/base/enum.d.ts +3 -1
  24. package/src/image-editor/base/enum.js +2 -0
  25. package/src/image-editor/base/image-editor.d.ts +13 -2
  26. package/src/image-editor/base/image-editor.js +242 -27
  27. package/src/image-editor/base/interface.d.ts +17 -1
  28. package/src/image-editor/renderer/toolbar.d.ts +2 -0
  29. package/src/image-editor/renderer/toolbar.js +121 -80
  30. package/styles/bds-lite.css +4 -0
  31. package/styles/bds.css +8 -0
  32. package/styles/bootstrap-dark-lite.css +4 -0
  33. package/styles/bootstrap-dark.css +4 -0
  34. package/styles/bootstrap-lite.css +4 -0
  35. package/styles/bootstrap.css +4 -0
  36. package/styles/bootstrap4-lite.css +4 -0
  37. package/styles/bootstrap4.css +4 -0
  38. package/styles/bootstrap5-dark-lite.css +4 -0
  39. package/styles/bootstrap5-dark.css +4 -0
  40. package/styles/bootstrap5-lite.css +4 -0
  41. package/styles/bootstrap5.3-lite.css +4 -0
  42. package/styles/bootstrap5.3.css +4 -0
  43. package/styles/bootstrap5.css +4 -0
  44. package/styles/fabric-dark-lite.css +4 -0
  45. package/styles/fabric-dark.css +19 -0
  46. package/styles/fabric-lite.css +4 -0
  47. package/styles/fabric.css +19 -0
  48. package/styles/fluent-dark-lite.css +4 -0
  49. package/styles/fluent-dark.css +13 -0
  50. package/styles/fluent-lite.css +4 -0
  51. package/styles/fluent.css +13 -0
  52. package/styles/fluent2-lite.css +8 -0
  53. package/styles/fluent2.css +12 -0
  54. package/styles/highcontrast-light-lite.css +4 -0
  55. package/styles/highcontrast-light.css +4 -0
  56. package/styles/highcontrast-lite.css +9 -1
  57. package/styles/highcontrast.css +14 -1
  58. package/styles/image-editor/_bigger.scss +56 -0
  59. package/styles/image-editor/_highcontrast-definition.scss +1 -1
  60. package/styles/image-editor/_layout.scss +39 -0
  61. package/styles/image-editor/bds.css +8 -0
  62. package/styles/image-editor/bootstrap-dark.css +4 -0
  63. package/styles/image-editor/bootstrap.css +4 -0
  64. package/styles/image-editor/bootstrap4.css +4 -0
  65. package/styles/image-editor/bootstrap5-dark.css +4 -0
  66. package/styles/image-editor/bootstrap5.3.css +4 -0
  67. package/styles/image-editor/bootstrap5.css +4 -0
  68. package/styles/image-editor/fabric-dark.css +19 -0
  69. package/styles/image-editor/fabric.css +19 -0
  70. package/styles/image-editor/fluent-dark.css +13 -0
  71. package/styles/image-editor/fluent.css +13 -0
  72. package/styles/image-editor/fluent2.css +12 -0
  73. package/styles/image-editor/highcontrast-light.css +4 -0
  74. package/styles/image-editor/highcontrast.css +14 -1
  75. package/styles/image-editor/material-dark.css +4 -0
  76. package/styles/image-editor/material.css +8 -0
  77. package/styles/image-editor/material3-dark.css +24 -1
  78. package/styles/image-editor/material3.css +24 -1
  79. package/styles/image-editor/tailwind-dark.css +8 -0
  80. package/styles/image-editor/tailwind.css +8 -0
  81. package/styles/image-editor/tailwind3.css +4 -0
  82. package/styles/material-dark-lite.css +4 -0
  83. package/styles/material-dark.css +4 -0
  84. package/styles/material-lite.css +4 -0
  85. package/styles/material.css +8 -0
  86. package/styles/material3-dark-lite.css +15 -0
  87. package/styles/material3-dark.css +24 -1
  88. package/styles/material3-lite.css +15 -0
  89. package/styles/material3.css +24 -1
  90. package/styles/tailwind-dark-lite.css +4 -0
  91. package/styles/tailwind-dark.css +8 -0
  92. package/styles/tailwind-lite.css +4 -0
  93. package/styles/tailwind.css +8 -0
  94. package/styles/tailwind3-lite.css +4 -0
  95. package/styles/tailwind3.css +4 -0
@@ -301,6 +301,12 @@ var ImageEditor = /** @class */ (function (_super) {
301
301
  _this.tempRedactBlur = 50;
302
302
  /** @hidden */
303
303
  _this.tempRedactPixel = 40;
304
+ /** @hidden */
305
+ _this.imageSettings = { width: null, height: null };
306
+ /** @hidden */
307
+ _this.aspectRatioBaseDimension = false;
308
+ /** @hidden */
309
+ _this.imageLoaded = false;
304
310
  _this.tempToolbarHeight = 0;
305
311
  _this.tempToolbar = [];
306
312
  ImageEditor_1.Inject(Crop, Draw, Selection, Transform, Export, ToolbarModule);
@@ -405,11 +411,13 @@ var ImageEditor = /** @class */ (function (_super) {
405
411
  break;
406
412
  case 'disabled':
407
413
  if (newProperties.disabled) {
408
- this.element.classList.add('e-disabled');
414
+ this.element.classList.add('e-disabled', 'e-overlay');
415
+ this.element.style.opacity = '0.5';
409
416
  this.unwireEvent();
410
417
  }
411
418
  else {
412
- this.element.classList.remove('e-disabled');
419
+ this.element.classList.remove('e-disabled', 'e-overlay');
420
+ this.element.style.opacity = '1';
413
421
  this.wireEvent();
414
422
  }
415
423
  break;
@@ -527,7 +535,7 @@ var ImageEditor = /** @class */ (function (_super) {
527
535
  if (newProperties.uploadSettings) {
528
536
  this.uploadSettings = newProperties.uploadSettings;
529
537
  if (!this.uploadSettings.allowedExtensions) {
530
- this.uploadSettings.allowedExtensions = '.jpg, .jpeg, .png, .svg, .webp';
538
+ this.uploadSettings.allowedExtensions = '.jpg, .jpeg, .png, .svg, .webp, .bmp';
531
539
  this.notify('draw', { prop: 'setNullExtension', value: { extension: true } });
532
540
  }
533
541
  else {
@@ -576,6 +584,10 @@ var ImageEditor = /** @class */ (function (_super) {
576
584
  this.element.innerHTML = '';
577
585
  };
578
586
  ImageEditor.prototype.initialize = function () {
587
+ if (this.disabled) {
588
+ this.element.classList.add('e-disabled', 'e-overlay');
589
+ this.element.style.opacity = '0.5';
590
+ }
579
591
  if (this.toolbarTemplate) {
580
592
  this.element.appendChild(this.createElement('div', {
581
593
  id: this.element.id + '_toolbarArea', className: 'e-toolbar-area'
@@ -587,7 +599,7 @@ var ImageEditor = /** @class */ (function (_super) {
587
599
  this.notify('toolbar', { prop: 'create-contextual-toolbar', onPropertyChange: false });
588
600
  }
589
601
  if (!this.uploadSettings.allowedExtensions) {
590
- this.setProperties({ uploadSettings: { allowedExtensions: '.jpg, .jpeg, .png, .svg, .webp' } }, true);
602
+ this.setProperties({ uploadSettings: { allowedExtensions: '.jpg, .jpeg, .png, .svg, .webp, .bmp' } }, true);
591
603
  }
592
604
  else {
593
605
  this.notify('draw', { prop: 'setNullExtension', value: { extension: false } });
@@ -788,7 +800,7 @@ var ImageEditor = /** @class */ (function (_super) {
788
800
  * @returns {string[]}.
789
801
  */
790
802
  ImageEditor.prototype.getExtensionArray = function () {
791
- var validExtensions = ['jpeg', 'jpg', 'png', 'svg', 'webp'];
803
+ var validExtensions = ['jpeg', 'jpg', 'png', 'svg', 'webp', 'bmp'];
792
804
  var split = this.uploadSettings.allowedExtensions.split(',');
793
805
  var extension = [];
794
806
  for (var _i = 0, split_1 = split; _i < split_1.length; _i++) {
@@ -840,6 +852,9 @@ var ImageEditor = /** @class */ (function (_super) {
840
852
  case 'webp':
841
853
  words += ' WebP,';
842
854
  break;
855
+ case 'bmp':
856
+ words += ' BMP,';
857
+ break;
843
858
  }
844
859
  if (i === extension.length - 1) {
845
860
  words = words.slice(0, -1);
@@ -1128,10 +1143,16 @@ var ImageEditor = /** @class */ (function (_super) {
1128
1143
  */
1129
1144
  ImageEditor.prototype.flip = function (direction) {
1130
1145
  this.applyShapes();
1131
- this.updateImageTransformColl(direction.toLowerCase() + 'flip');
1132
- this.notify('transform', { prop: 'flip', value: { direction: direction } });
1133
- this.notify('draw', { prop: 'redrawDownScale' });
1134
- this.notify('undo-redo', { prop: 'updateCurrUrc', value: { type: 'ok' } });
1146
+ if (this.activeObj.shape && this.activeObj.shape.indexOf('crop') > -1) {
1147
+ this.transformSelect(direction.toLowerCase() + 'flip');
1148
+ }
1149
+ else {
1150
+ this.updateImageTransformColl(direction.toLowerCase() + 'flip');
1151
+ this.setRotateZoom();
1152
+ this.notify('transform', { prop: 'flip', value: { direction: direction } });
1153
+ this.notify('draw', { prop: 'redrawDownScale' });
1154
+ this.notify('undo-redo', { prop: 'updateCurrUrc', value: { type: 'ok' } });
1155
+ }
1135
1156
  var actionArgs = { action: 'flip', actionEventArgs: this.editCompleteArgs };
1136
1157
  this.triggerEditCompleteEvent(actionArgs);
1137
1158
  };
@@ -1170,7 +1191,7 @@ var ImageEditor = /** @class */ (function (_super) {
1170
1191
  *
1171
1192
  * @param {string | ImageData } data - Specifies url of the image or image data.
1172
1193
  * @param {boolean} [resetChanges=true] - Optional. Determines whether to reset existing changes when opening the image. The default value is true, which resets all existing changes.
1173
- * @param {ImageSettings} imageSettings - Optional. Specifies the image setting that contains background color to apply when opening a transparent image. The default value of background color is an empty string (''), meaning no background color is applied by default when a transparent image is opened.
1194
+ * @param {ImageSettings} imageSettings - Optional. Specifies image settings to apply when loading an image.
1174
1195
  *
1175
1196
  * @remarks
1176
1197
  * The supported file types are JPG, JPEG, PNG, and SVG.
@@ -1178,16 +1199,88 @@ var ImageEditor = /** @class */ (function (_super) {
1178
1199
  * @returns {void}.
1179
1200
  */
1180
1201
  ImageEditor.prototype.open = function (data, resetChanges, imageSettings) {
1202
+ var _this = this;
1181
1203
  resetChanges = isNullOrUndefined(resetChanges) ? true : resetChanges;
1182
1204
  if (resetChanges) {
1183
- if (isNullOrUndefined(data)) {
1205
+ if (isNullOrUndefined(data) || this.disabled) {
1184
1206
  return;
1185
1207
  }
1186
1208
  var dropArea = document.getElementById(this.element.id + '_dropArea');
1187
1209
  if (dropArea) {
1188
1210
  dropArea.style.display = 'none';
1189
1211
  }
1190
- this.notify('draw', { prop: 'open', value: { data: data } });
1212
+ this.imageSettings = { width: null, height: null };
1213
+ this.aspectRatioBaseDimension = null;
1214
+ if (imageSettings && (imageSettings.width || imageSettings.height)) {
1215
+ var tempImageSettings_1 = extend({}, imageSettings, {}, true);
1216
+ imageSettings = this.scaleToFit(imageSettings);
1217
+ this.aspectRatioBaseDimension = imageSettings.isAspectRatio;
1218
+ if (!imageSettings.isAspectRatio && imageSettings.width && imageSettings.height) {
1219
+ this.imageSettings.width = imageSettings.width;
1220
+ this.imageSettings.height = imageSettings.height;
1221
+ this.notify('draw', { prop: 'open', value: { data: data } });
1222
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1223
+ var intervalId_1 = setInterval(function () {
1224
+ if (_this.imageLoaded && _this.baseImg.width && _this.baseImg.height) {
1225
+ _this.setInitialZoomLevel(tempImageSettings_1);
1226
+ clearInterval(intervalId_1);
1227
+ }
1228
+ }, 1);
1229
+ }
1230
+ else if (imageSettings.width || imageSettings.height) {
1231
+ this.notify('draw', { prop: 'open', value: { data: data } });
1232
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1233
+ var intervalId_2 = setInterval(function () {
1234
+ if (_this.imageLoaded && _this.baseImg.width && _this.baseImg.height) {
1235
+ _this.imageSettings.width = imageSettings.width;
1236
+ _this.imageSettings.height = imageSettings.height;
1237
+ var originalWidth = _this.baseImg.width;
1238
+ var originalHeight = _this.baseImg.height;
1239
+ var maxValue = '';
1240
+ var aspectRatioValue = void 0;
1241
+ var value = void 0;
1242
+ var newValue = void 0;
1243
+ if (imageSettings.width && imageSettings.height) {
1244
+ maxValue = imageSettings.width > imageSettings.height ? 'width' : 'height';
1245
+ }
1246
+ if (maxValue === 'width' || (imageSettings.width && maxValue !== 'height')) {
1247
+ aspectRatioValue = imageSettings.width;
1248
+ value = aspectRatioValue / (originalWidth / originalHeight);
1249
+ newValue = value % 1 >= 0.5 || value % 1 <= -0.5 ? Math.round(value) : (value < 0) ? Math.ceil(value) : Math.floor(value);
1250
+ if (!imageSettings.height || newValue > imageSettings.height) {
1251
+ _this.imageSettings.height = imageSettings.height = newValue;
1252
+ }
1253
+ else {
1254
+ aspectRatioValue = imageSettings.height;
1255
+ value = aspectRatioValue / (originalHeight / originalWidth);
1256
+ newValue = value % 1 >= 0.5 || value % 1 <= -0.5 ? Math.round(value) : (value < 0) ? Math.ceil(value) : Math.floor(value);
1257
+ _this.imageSettings.width = imageSettings.width = newValue;
1258
+ }
1259
+ }
1260
+ else if (maxValue === 'height' || (imageSettings.height && maxValue !== 'width')) {
1261
+ aspectRatioValue = imageSettings.height;
1262
+ value = aspectRatioValue / (originalHeight / originalWidth);
1263
+ newValue = value % 1 >= 0.5 || value % 1 <= -0.5 ? Math.round(value) : (value < 0) ? Math.ceil(value) : Math.floor(value);
1264
+ if (!imageSettings.width || newValue > imageSettings.width) {
1265
+ _this.imageSettings.width = imageSettings.width = newValue;
1266
+ }
1267
+ else {
1268
+ aspectRatioValue = imageSettings.width;
1269
+ value = aspectRatioValue / (originalWidth / originalHeight);
1270
+ newValue = value % 1 >= 0.5 || value % 1 <= -0.5 ? Math.round(value) : (value < 0) ? Math.ceil(value) : Math.floor(value);
1271
+ _this.imageSettings.height = imageSettings.height = newValue;
1272
+ }
1273
+ }
1274
+ _this.notify('draw', { prop: 'open', value: { data: data } });
1275
+ _this.setInitialZoomLevel(tempImageSettings_1);
1276
+ clearInterval(intervalId_2);
1277
+ }
1278
+ }, 1);
1279
+ }
1280
+ }
1281
+ else {
1282
+ this.notify('draw', { prop: 'open', value: { data: data } });
1283
+ }
1191
1284
  }
1192
1285
  else {
1193
1286
  this.updateImage(data, imageSettings ? imageSettings.backgroundColor : null);
@@ -1341,11 +1434,18 @@ var ImageEditor = /** @class */ (function (_super) {
1341
1434
  ImageEditor.prototype.rotate = function (degree) {
1342
1435
  var obj = { isRotate: false };
1343
1436
  this.applyShapes();
1344
- if (degree === 90 || degree === -90) {
1345
- this.updateImageTransformColl(degree === 90 ? 'rotateright' : 'rotateleft');
1437
+ if (this.activeObj.shape && this.activeObj.shape.indexOf('crop') > -1) {
1438
+ this.transformSelect(degree === 90 ? 'rotateright' : 'rotateleft');
1439
+ obj['isRotate'] = true;
1440
+ }
1441
+ else {
1442
+ if (degree === 90 || degree === -90) {
1443
+ this.updateImageTransformColl(degree === 90 ? 'rotateright' : 'rotateleft');
1444
+ }
1445
+ this.setRotateZoom();
1446
+ this.notify('transform', { prop: 'rotate', value: { degree: degree, obj: obj } });
1447
+ this.notify('draw', { prop: 'redrawDownScale' });
1346
1448
  }
1347
- this.notify('transform', { prop: 'rotate', value: { degree: degree, obj: obj } });
1348
- this.notify('draw', { prop: 'redrawDownScale' });
1349
1449
  var actionArgs = { action: 'rotate', actionEventArgs: this.editCompleteArgs };
1350
1450
  this.triggerEditCompleteEvent(actionArgs);
1351
1451
  return obj['isRotate'];
@@ -1363,7 +1463,7 @@ var ImageEditor = /** @class */ (function (_super) {
1363
1463
  * @returns {void}.
1364
1464
  */
1365
1465
  ImageEditor.prototype.export = function (type, fileName, imageQuality) {
1366
- this.applyShapes();
1466
+ this.manageActiveAction();
1367
1467
  this.notify('export', { prop: 'export', onPropertyChange: false, value: { type: type, fileName: fileName, imgQuality: imageQuality } });
1368
1468
  };
1369
1469
  /**
@@ -1471,6 +1571,17 @@ var ImageEditor = /** @class */ (function (_super) {
1471
1571
  */
1472
1572
  ImageEditor.prototype.zoom = function (zoomFactor, zoomPoint) {
1473
1573
  this.isZoomBtnClick = true;
1574
+ var prevZoom = this.transform.zoomFactor;
1575
+ if (prevZoom !== 0) {
1576
+ var zoomObj = { previousZoomValue: null };
1577
+ this.notify('transform', { prop: 'getPreviousZoomValue', value: { obj: zoomObj } });
1578
+ prevZoom = zoomObj.previousZoomValue;
1579
+ }
1580
+ if (zoomFactor !== 1 && prevZoom !== 0 && ((prevZoom < 1 && zoomFactor > 1) || (prevZoom > 1 && zoomFactor < 1))) {
1581
+ this.notify('transform', { prop: 'zoom', onPropertyChange: false,
1582
+ value: { zoomFactor: 1, zoomPoint: zoomPoint }
1583
+ });
1584
+ }
1474
1585
  this.notify('transform', { prop: 'zoom', onPropertyChange: false,
1475
1586
  value: { zoomFactor: zoomFactor, zoomPoint: zoomPoint } });
1476
1587
  this.notify('draw', { prop: 'redrawDownScale' });
@@ -1633,10 +1744,12 @@ var ImageEditor = /** @class */ (function (_super) {
1633
1744
  * @param {string} strokeColor - Specifies the outline color of the text annotation.
1634
1745
  * @param {number} strokeWidth - Specifies the outline stroke width of the text annotation.
1635
1746
  * @param {TransformationCollection[]} transformCollection - Specifies the transform collection of the text annotation.
1747
+ * @param {boolean} underline - Specifies whether the text should be underlined.
1748
+ * @param {boolean} strikethrough - Specifies whether the text should have a strikethrough.
1636
1749
  * @returns {boolean}.
1637
1750
  *
1638
1751
  */
1639
- ImageEditor.prototype.drawText = function (x, y, text, fontFamily, fontSize, bold, italic, color, isSelected, degree, fillColor, strokeColor, strokeWidth, transformCollection) {
1752
+ ImageEditor.prototype.drawText = function (x, y, text, fontFamily, fontSize, bold, italic, color, isSelected, degree, fillColor, strokeColor, strokeWidth, transformCollection, underline, strikethrough) {
1640
1753
  var isText = false;
1641
1754
  var isPointsInRange = this.allowShape(x, y);
1642
1755
  if (!this.disabled && this.isImageLoaded && (isPointsInRange || (isNullOrUndefined(x) && isNullOrUndefined(y)))) {
@@ -1644,7 +1757,7 @@ var ImageEditor = /** @class */ (function (_super) {
1644
1757
  this.manageActiveAction();
1645
1758
  this.notify('shape', { prop: 'drawText', onPropertyChange: false, value: { x: x, y: y, text: text, fontFamily: fontFamily,
1646
1759
  fontSize: fontSize, bold: bold, italic: italic, color: color, isSelected: isSelected, degree: degree, fillColor: fillColor,
1647
- outlineColor: strokeColor, outlineWidth: strokeWidth, transformCollection: transformCollection } });
1760
+ outlineColor: strokeColor, outlineWidth: strokeWidth, transformCollection: transformCollection, underline: underline, strikethrough: strikethrough } });
1648
1761
  this.editCompleted();
1649
1762
  }
1650
1763
  return isText;
@@ -1669,14 +1782,27 @@ var ImageEditor = /** @class */ (function (_super) {
1669
1782
  var isImage = false;
1670
1783
  var isPointsInRange = this.allowShape(x, y);
1671
1784
  if (!this.disabled && this.isImageLoaded && (isPointsInRange || (isNullOrUndefined(x) && isNullOrUndefined(y)))) {
1785
+ if (typeof data === 'string') {
1786
+ try {
1787
+ var request = new XMLHttpRequest();
1788
+ var isBlob = data.indexOf('blob:') === 0;
1789
+ request.open(isBlob ? 'GET' : 'HEAD', data, false);
1790
+ request.send();
1791
+ isImage = request.status >= 200 && request.status < 300;
1792
+ }
1793
+ catch (error) {
1794
+ isImage = false;
1795
+ }
1796
+ }
1797
+ else if (data instanceof ImageData) {
1798
+ if (data.data instanceof Uint8ClampedArray && data.width > 0 && data.height > 0) {
1799
+ isImage = true;
1800
+ }
1801
+ }
1672
1802
  this.manageActiveAction();
1673
- var length_1 = this.objColl.length;
1674
1803
  this.notify('shape', { prop: 'drawImage', onPropertyChange: false, value: { x: x, y: y, width: width, height: height,
1675
1804
  src: data, degree: degree, isAspectRatio: isAspectRatio, opacity: opacity, isSelected: isSelected } });
1676
1805
  this.editCompleted();
1677
- if (this.objColl.length > length_1) {
1678
- isImage = true;
1679
- }
1680
1806
  }
1681
1807
  return isImage;
1682
1808
  };
@@ -1801,6 +1927,8 @@ var ImageEditor = /** @class */ (function (_super) {
1801
1927
  this.applyShapes();
1802
1928
  this.notify('shape', { prop: 'deleteShape', onPropertyChange: false, value: { id: id, isShape: true } });
1803
1929
  this.editCompleted('shape-delete');
1930
+ this.notify('draw', { prop: 'clearOuterCanvas', onPropertyChange: false, value: { context: this.lowerContext } });
1931
+ this.notify('draw', { prop: 'clearOuterCanvas', onPropertyChange: false, value: { context: this.upperContext } });
1804
1932
  };
1805
1933
  /**
1806
1934
  * Get particular shapes details based on id of the shape which is drawn on an image editor.
@@ -2012,6 +2140,7 @@ var ImageEditor = /** @class */ (function (_super) {
2012
2140
  var isResized = false;
2013
2141
  if (((width.toString()).length <= 4 && (height.toString()).length <= 4) && (!this.isCircleCrop || isAspectRatio)) {
2014
2142
  this.manageActiveAction();
2143
+ this.isPublicMethod = true;
2015
2144
  this.notify('toolbar', { prop: 'resizeClick', value: { bool: false } });
2016
2145
  var destPoints = { startX: this.img.destLeft, startY: this.img.destTop, width: this.img.destWidth,
2017
2146
  height: this.img.destHeight };
@@ -2047,6 +2176,7 @@ var ImageEditor = /** @class */ (function (_super) {
2047
2176
  else {
2048
2177
  this.notify('draw', { prop: 'performCancel', value: { isContextualToolbar: null } });
2049
2178
  }
2179
+ this.isPublicMethod = false;
2050
2180
  this.notify('draw', { prop: 'redrawDownScale' });
2051
2181
  }
2052
2182
  return isResized;
@@ -2551,6 +2681,70 @@ var ImageEditor = /** @class */ (function (_super) {
2551
2681
  }
2552
2682
  };
2553
2683
  // Toolbar related codes
2684
+ ImageEditor.prototype.scaleToFit = function (imageSettings) {
2685
+ var tempImageSettings = extend({}, imageSettings, {}, true);
2686
+ var viewPortWidth = this.lowerCanvas.clientWidth;
2687
+ var viewPortHeight = this.lowerCanvas.clientHeight;
2688
+ if (imageSettings.width && imageSettings.height && (imageSettings.width > viewPortWidth ||
2689
+ imageSettings.height > viewPortHeight)) {
2690
+ var widthScale = viewPortWidth / imageSettings.width;
2691
+ var heightScale = viewPortHeight / imageSettings.height;
2692
+ var scale = Math.min(widthScale, heightScale);
2693
+ tempImageSettings.width = Math.round(imageSettings.width * scale);
2694
+ tempImageSettings.height = Math.round(imageSettings.height * scale);
2695
+ }
2696
+ else if (imageSettings.width && imageSettings.width > viewPortWidth) {
2697
+ var scale = viewPortWidth / imageSettings.width;
2698
+ tempImageSettings.width = Math.round(imageSettings.width * scale);
2699
+ }
2700
+ else if (imageSettings.height && imageSettings.height > viewPortHeight) {
2701
+ var scale = viewPortHeight / imageSettings.height;
2702
+ tempImageSettings.height = Math.round(imageSettings.height * scale);
2703
+ }
2704
+ return tempImageSettings;
2705
+ };
2706
+ ImageEditor.prototype.setInitialZoomLevel = function (oldImageSettings) {
2707
+ var _this = this;
2708
+ var zoomLevel = 1;
2709
+ var newWidth = this.img.destWidth;
2710
+ var newHeight = this.img.destHeight;
2711
+ var oldWidth = oldImageSettings.width;
2712
+ var oldHeight = oldImageSettings.height;
2713
+ var dimObj = { width: 0, height: 0 };
2714
+ this.notify('transform', { prop: 'calcMaxDimension', onPropertyChange: false,
2715
+ value: { width: this.img.srcWidth, height: this.img.srcHeight, obj: dimObj, isImgShape: null } });
2716
+ while ((newWidth && oldWidth && oldWidth > newWidth) || (newHeight && oldHeight && oldHeight > newHeight)) {
2717
+ newWidth = dimObj['width'] + (dimObj['width'] * 0.025 * zoomLevel);
2718
+ newHeight = dimObj['height'] + (dimObj['height'] * 0.025 * zoomLevel);
2719
+ if (Math.abs(newWidth) >= Math.abs(oldWidth) && Math.abs(newHeight) >= Math.abs(oldHeight)) {
2720
+ break;
2721
+ }
2722
+ zoomLevel++;
2723
+ }
2724
+ if (zoomLevel > 1) {
2725
+ this.isImageLoaded = true;
2726
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2727
+ var intervalId_3 = setInterval(function () {
2728
+ if (_this.imageLoaded) {
2729
+ for (var i = 1; i < zoomLevel; i++) {
2730
+ if (Math.round(i / 4) < _this.zoomSettings.maxZoomFactor) {
2731
+ _this.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
2732
+ value: { zoomFactor: 0.025, zoomPoint: null, isResize: true } });
2733
+ }
2734
+ else {
2735
+ zoomLevel = i;
2736
+ break;
2737
+ }
2738
+ }
2739
+ _this.setProperties({ zoomSettings: { zoomFactor: Math.round(zoomLevel / 4) } }, true);
2740
+ _this.notify('transform', { prop: 'setPreviousZoomValue', onPropertyChange: false,
2741
+ value: { previousZoomValue: _this.zoomSettings.zoomFactor } });
2742
+ _this.notify('toolbar', { prop: 'enable-disable-btns' });
2743
+ clearInterval(intervalId_3);
2744
+ }
2745
+ }, 1);
2746
+ }
2747
+ };
2554
2748
  ImageEditor.prototype.resetToolbar = function () {
2555
2749
  if (this.toolbarHeight !== this.tempToolbarHeight && !((isNullOrUndefined(this.toolbar) ||
2556
2750
  (this.toolbar && this.toolbar.length > 0)
@@ -2565,6 +2759,14 @@ var ImageEditor = /** @class */ (function (_super) {
2565
2759
  this.update();
2566
2760
  }
2567
2761
  };
2762
+ ImageEditor.prototype.setRotateZoom = function () {
2763
+ if (this.transform.zoomFactor > 0) {
2764
+ this.notify('draw', { prop: 'setRotateZoom', onPropertyChange: false, value: { isRotateZoom: true } });
2765
+ }
2766
+ else {
2767
+ this.notify('draw', { prop: 'setRotateZoom', onPropertyChange: false, value: { isRotateZoom: false } });
2768
+ }
2769
+ };
2568
2770
  ImageEditor.prototype.getData = function (isMaskImage) {
2569
2771
  if (isMaskImage) {
2570
2772
  this.resetToolbar();
@@ -3201,6 +3403,11 @@ var ImageEditor = /** @class */ (function (_super) {
3201
3403
  }
3202
3404
  };
3203
3405
  ImageEditor.prototype.triggerEditCompleteEvent = function (args) {
3406
+ var obj = { bool: false };
3407
+ this.notify('undo-redo', { prop: 'preventEditComplete', value: { obj: obj } });
3408
+ if (obj['bool']) {
3409
+ return;
3410
+ }
3204
3411
  if (args.action === 'shape-insert' && args.actionEventArgs &&
3205
3412
  args.actionEventArgs.currentShapeSettings &&
3206
3413
  args.actionEventArgs.currentShapeSettings.type.toString() === 'Redact') {
@@ -4489,9 +4696,17 @@ var ImageEditor = /** @class */ (function (_super) {
4489
4696
  this.notify('crop', { prop: 'calcRatio', onPropertyChange: false,
4490
4697
  value: { obj: obj_7, dimension: { width: ctx.canvas.width, height: ctx.canvas.height } } });
4491
4698
  }
4492
- var dimension = void 0;
4493
- // eslint-disable-next-line prefer-const
4494
- dimension = this.getRotatedCanvasDim(this.baseImg.width, this.baseImg.height, this.transform.straighten);
4699
+ var width = this.baseImg.width;
4700
+ var height = this.baseImg.height;
4701
+ if (!this.aspectRatioBaseDimension && this.imageSettings.width && this.imageSettings.height) {
4702
+ var widthRatio = this.baseImg.width / this.imageSettings.width;
4703
+ var heightRatio = this.baseImg.height / this.imageSettings.height;
4704
+ var ratio = (widthRatio + heightRatio) / 2;
4705
+ ratio = ratio < 1 ? 1 : ratio;
4706
+ width = this.imageSettings.width * ratio;
4707
+ height = this.imageSettings.height * ratio;
4708
+ }
4709
+ var dimension = this.getRotatedCanvasDim(width, height, this.transform.straighten);
4495
4710
  this.img.srcWidth = ctx.canvas.width = dimension.width;
4496
4711
  this.img.srcHeight = ctx.canvas.height = dimension.height;
4497
4712
  var x = ctx.canvas.width / 2;
@@ -4499,7 +4714,7 @@ var ImageEditor = /** @class */ (function (_super) {
4499
4714
  ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
4500
4715
  ctx.translate(x, y);
4501
4716
  ctx.rotate(straighten * Math.PI / 180);
4502
- ctx.drawImage(this.baseImg, -this.baseImg.width / 2, -this.baseImg.height / 2, this.baseImg.width, this.baseImg.height);
4717
+ ctx.drawImage(this.baseImg, -width / 2, -height / 2, width, height);
4503
4718
  ctx.setTransform(1, 0, 0, 1, 0, 0);
4504
4719
  var obj = { width: 0, height: 0 };
4505
4720
  this.notify('crop', { prop: 'calcRatio', onPropertyChange: false, value: { obj: obj, dimension: { width: ctx.canvas.width, height: ctx.canvas.height } } });
@@ -709,9 +709,21 @@ export interface FrameSettings {
709
709
  */
710
710
  export interface ImageSettings {
711
711
  /**
712
- * Returns the background color of an image.
712
+ * Specifies the background color of an image. The default value of background color is an empty string (''), meaning no background color is applied by default when a transparent image is opened.
713
713
  */
714
714
  backgroundColor: string;
715
+ /**
716
+ * Specifies the target width at which the image should be rendered on the canvas.
717
+ */
718
+ width?: number;
719
+ /**
720
+ * Specifies the target height at which the image should be rendered on the canvas.
721
+ */
722
+ height?: number;
723
+ /**
724
+ * Indicates whether to maintain the original aspect ratio when scaling the image.
725
+ */
726
+ isAspectRatio?: boolean;
715
727
  }
716
728
  /**
717
729
  * The Interface which contains the tranformation collection of annotation in Image Editor.
@@ -1054,6 +1066,10 @@ export interface TextSettings {
1054
1066
  * Specifies the underline styles for the text content.
1055
1067
  */
1056
1068
  underline: boolean;
1069
+ /**
1070
+ * Specifies the strikethrough styles for the text content.
1071
+ */
1072
+ strikethrough: boolean;
1057
1073
  }
1058
1074
  /**
1059
1075
  * Interface for Transition occur in the Image Editor.
@@ -131,6 +131,8 @@ export declare class ToolbarModule {
131
131
  private duplicateShape;
132
132
  private defToolbarClicked;
133
133
  private performDefTbrClick;
134
+ private getFontStyle;
135
+ private toggleStyle;
134
136
  private updateRedactType;
135
137
  private frameToolbarClick;
136
138
  private zoomToFrameRange;