@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
@@ -852,40 +852,40 @@ var Transform = /** @class */ (function () {
852
852
  destWidth: parent.img.destWidth, destHeight: parent.img.destHeight };
853
853
  if (parent.activeObj.shape) {
854
854
  var maxDimension = this.setZoomDimension(-0.1, parent.activeObj);
855
- if (!isNullOrUndefined(zoomOut)) {
856
- var actPoint = parent.activeObj.activePoint;
857
- if (parent.transform.straighten === 0) {
858
- if (parent.img.destLeft > actPoint.startX || parent.img.destTop >
859
- actPoint.startY || parent.img.destLeft + parent.img.destWidth <
860
- actPoint.endX || parent.img.destTop + parent.img.destHeight < actPoint.endY
861
- || zoomFactor === minZoomFactor) {
862
- zoomOut.classList.add('e-disabled');
863
- zoomOut.parentElement.classList.add('e-overlay');
864
- isDisabled = true;
865
- }
866
- else {
867
- zoomOut.classList.remove('e-disabled');
868
- zoomOut.parentElement.classList.remove('e-overlay');
869
- isDisabled = false;
870
- }
855
+ var actPoint = parent.activeObj.activePoint;
856
+ if (parent.transform.straighten === 0) {
857
+ if (parent.img.destLeft > actPoint.startX || parent.img.destTop >
858
+ actPoint.startY || parent.img.destLeft + parent.img.destWidth <
859
+ actPoint.endX || parent.img.destTop + parent.img.destHeight < actPoint.endY
860
+ || zoomFactor === minZoomFactor) {
861
+ isDisabled = true;
871
862
  }
872
863
  else {
873
- parent.img.destWidth = maxDimension.width;
874
- parent.img.destHeight = maxDimension.height;
875
- var obj = { isIntersect: null };
876
- parent.notify('draw', { prop: 'updateImgCanvasPoints', onPropertyChange: false });
877
- parent.notify('draw', { prop: 'isLinesIntersect', onPropertyChange: false, value: { obj: obj } });
878
- if (obj['isIntersect'] ||
879
- zoomFactor === minZoomFactor) {
880
- zoomOut.classList.add('e-disabled');
881
- zoomOut.parentElement.classList.add('e-overlay');
882
- isDisabled = true;
883
- }
884
- else {
885
- zoomOut.classList.remove('e-disabled');
886
- zoomOut.parentElement.classList.remove('e-overlay');
887
- isDisabled = false;
888
- }
864
+ isDisabled = false;
865
+ }
866
+ }
867
+ else {
868
+ parent.img.destWidth = maxDimension.width;
869
+ parent.img.destHeight = maxDimension.height;
870
+ var obj = { isIntersect: null };
871
+ parent.notify('draw', { prop: 'updateImgCanvasPoints', onPropertyChange: false });
872
+ parent.notify('draw', { prop: 'isLinesIntersect', onPropertyChange: false, value: { obj: obj } });
873
+ if (obj['isIntersect'] ||
874
+ zoomFactor === minZoomFactor) {
875
+ isDisabled = true;
876
+ }
877
+ else {
878
+ isDisabled = false;
879
+ }
880
+ }
881
+ if (zoomOut) {
882
+ if (isDisabled) {
883
+ zoomOut.classList.add('e-disabled');
884
+ zoomOut.parentElement.classList.add('e-overlay');
885
+ }
886
+ else {
887
+ zoomOut.classList.remove('e-disabled');
888
+ zoomOut.parentElement.classList.remove('e-overlay');
889
889
  }
890
890
  }
891
891
  }
@@ -921,7 +921,7 @@ var Transform = /** @class */ (function () {
921
921
  maxDimension.width += (maxDimension.width * parent.transform.zoomFactor);
922
922
  maxDimension.height += (maxDimension.height * parent.transform.zoomFactor);
923
923
  parent.img.destLeft = (parent.lowerCanvas.clientWidth - maxDimension.width) / 2;
924
- parent.img.destTop = (parent.lowerCanvas.clientHeight - maxDimension.height + 1) / 2;
924
+ parent.img.destTop = (parent.lowerCanvas.clientHeight - maxDimension.height) / 2;
925
925
  }
926
926
  parent.notify('draw', { prop: 'draw-image-to-canvas', value: { dimension: maxDimension } });
927
927
  maxDimension.width = this.cropDimension.width;
@@ -1645,7 +1645,7 @@ var Transform = /** @class */ (function () {
1645
1645
  maxDimension.height += (maxDimension.height * parent.transform.defaultZoomFactor);
1646
1646
  }
1647
1647
  parent.img.destLeft = (parent.lowerCanvas.clientWidth - maxDimension.width) / 2;
1648
- parent.img.destTop = (parent.lowerCanvas.clientHeight - maxDimension.height + 1) / 2;
1648
+ parent.img.destTop = (parent.lowerCanvas.clientHeight - maxDimension.height) / 2;
1649
1649
  if (parent.transform.degree === 0 && parent.transform.currFlipState === '') {
1650
1650
  if (parent.transform.defaultZoomFactor > 0) {
1651
1651
  parent.img.destLeft += parent.panPoint.totalPannedPoint.x;
@@ -1754,11 +1754,11 @@ var Transform = /** @class */ (function () {
1754
1754
  var object = { toolbarHeight: 0 };
1755
1755
  var parent = this.parent;
1756
1756
  parent.notify('toolbar', { prop: 'getToolbarHeight', value: { obj: object } });
1757
- var canvasMaxWidth = isImgShape ? parent.element.clientWidth / 3 :
1758
- parent.element.clientWidth;
1759
- var canvasMaxHeight = isImgShape ? (parent.element.clientHeight - object['toolbarHeight']) / 3 :
1760
- parent.element.clientHeight - (object['toolbarHeight']); // 1px border
1761
- canvasMaxHeight = Browser.isDevice ? canvasMaxHeight - (object['toolbarHeight']) : canvasMaxHeight; // 1px border
1757
+ var newWidth = parent.imageSettings.width ? parent.imageSettings.width : parent.element.clientWidth;
1758
+ var newHeight = parent.imageSettings.height ? parent.imageSettings.height : parent.element.clientHeight - (object['toolbarHeight']);
1759
+ var canvasMaxWidth = isImgShape ? parent.element.clientWidth / 3 : newWidth;
1760
+ var canvasMaxHeight = isImgShape ? (parent.element.clientHeight - object['toolbarHeight']) / 3 : newHeight;
1761
+ canvasMaxHeight = Browser.isDevice ? canvasMaxHeight - (object['toolbarHeight']) : canvasMaxHeight;
1762
1762
  if (Browser.isDevice && parent.isStraightening) {
1763
1763
  var cxtTbar = parent.element.querySelector('#' + parent.element.id + '_contextualToolbarArea');
1764
1764
  canvasMaxHeight -= cxtTbar ? cxtTbar.clientHeight : 0;
@@ -1766,7 +1766,8 @@ var Transform = /** @class */ (function () {
1766
1766
  if (!isImgShape && parent.element.clientHeight === 0) {
1767
1767
  canvasMaxHeight = 0;
1768
1768
  }
1769
- if (isNullOrUndefined(isImgShape)) {
1769
+ var isImageSettings = parent.imageSettings.width && parent.imageSettings.height ? true : false;
1770
+ if (isNullOrUndefined(isImgShape) && !(isImageSettings)) {
1770
1771
  if (canvasMaxWidth > 30) {
1771
1772
  canvasMaxWidth -= 30;
1772
1773
  }
@@ -1992,6 +1993,9 @@ var Transform = /** @class */ (function () {
1992
1993
  this.zoomAction(.0125, null, true, true);
1993
1994
  }
1994
1995
  }
1996
+ if (parent.isPublicMethod && parent.aspectWidth === width && parent.aspectHeight === height) {
1997
+ return;
1998
+ }
1995
1999
  this.resizeImg(activeObj, width, height);
1996
2000
  width = tempwidth;
1997
2001
  height = tempheight;
@@ -2037,9 +2041,12 @@ var Transform = /** @class */ (function () {
2037
2041
  value: { type: 'custom', startX: null, startY: null, width: null, height: null } });
2038
2042
  }
2039
2043
  if (isNullOrUndefined(parent.currSelectionPoint)) {
2040
- parent.notify('draw', { prop: 'select', onPropertyChange: false,
2041
- value: { type: 'custom', startX: parent.img.destLeft, startY: parent.img.destTop,
2042
- width: parent.img.destWidth, height: parent.img.destHeight } });
2044
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
2045
+ if (!parent.shapeColl.some(function (item) { return item.rotatedAngle && item.rotatedAngle !== 0; })) {
2046
+ parent.notify('draw', { prop: 'select', onPropertyChange: false,
2047
+ value: { type: 'custom', startX: parent.img.destLeft, startY: parent.img.destTop,
2048
+ width: parent.img.destWidth, height: parent.img.destHeight } });
2049
+ }
2043
2050
  }
2044
2051
  else {
2045
2052
  parent.notify('draw', { prop: 'select', onPropertyChange: false,
@@ -11,6 +11,8 @@ export declare class UndoRedo {
11
11
  private tempUndoRedoStep;
12
12
  private tempActObj;
13
13
  private isPreventing;
14
+ private preventEditComplete;
15
+ private preventApplyEditComplete;
14
16
  constructor(parent: ImageEditor);
15
17
  destroy(): void;
16
18
  private addEventListener;
@@ -7,6 +7,8 @@ var UndoRedo = /** @class */ (function () {
7
7
  this.tempUndoRedoColl = [];
8
8
  this.tempUndoRedoStep = 0;
9
9
  this.isPreventing = false;
10
+ this.preventEditComplete = false;
11
+ this.preventApplyEditComplete = false;
10
12
  this.parent = parent;
11
13
  this.addEventListener();
12
14
  }
@@ -88,6 +90,12 @@ var UndoRedo = /** @class */ (function () {
88
90
  case 'reset':
89
91
  this.reset();
90
92
  break;
93
+ case 'preventEditComplete':
94
+ args.value['obj']['bool'] = this.preventEditComplete;
95
+ break;
96
+ case 'preventApplyEditComplete':
97
+ this.preventApplyEditComplete = args.value['bool'];
98
+ break;
91
99
  }
92
100
  };
93
101
  UndoRedo.prototype.getModuleName = function () {
@@ -102,6 +110,7 @@ var UndoRedo = /** @class */ (function () {
102
110
  this.tempUndoRedoColl = [];
103
111
  this.tempUndoRedoStep = 0;
104
112
  this.isPreventing = false;
113
+ this.preventEditComplete = this.preventApplyEditComplete = false;
105
114
  };
106
115
  UndoRedo.prototype.refreshUrc = function (refreshToolbar) {
107
116
  var parent = this.parent;
@@ -813,6 +822,10 @@ var UndoRedo = /** @class */ (function () {
813
822
  textArea.style.color = obj.strokeSettings.strokeColor;
814
823
  textArea.style.fontWeight = obj.textSettings.bold ? 'bold' : 'normal';
815
824
  textArea.style.fontStyle = obj.textSettings.italic ? 'italic' : 'normal';
825
+ textArea.style.textDecoration = (obj.textSettings.underline && obj.textSettings.strikethrough) ? 'underline line-through' :
826
+ (obj.textSettings.underline) ? 'underline' :
827
+ (obj.textSettings.strikethrough) ? 'line-through' :
828
+ 'none';
816
829
  textArea.style.border = '2px solid ' + parent.themeColl[parent.theme]['primaryColor'];
817
830
  textArea.value = obj.keyHistory;
818
831
  parent.activeObj = extend({}, obj, {}, true);
@@ -1146,6 +1159,7 @@ var UndoRedo = /** @class */ (function () {
1146
1159
  var temp = parent.noPushUndo;
1147
1160
  parent.noPushUndo = false;
1148
1161
  parent.isUndoRedoStack = true;
1162
+ this.preventEditComplete = true;
1149
1163
  if (isPenDraw) {
1150
1164
  var tempTogglePen = parent.togglePen;
1151
1165
  var obj = { freehandDrawSelectedId: null };
@@ -1174,7 +1188,14 @@ var UndoRedo = /** @class */ (function () {
1174
1188
  parent.enableTextEditing();
1175
1189
  }
1176
1190
  }
1177
- parent.isUndoRedoStack = false;
1191
+ if (this.preventEditComplete) {
1192
+ parent.isUndoRedoStack = this.preventEditComplete = false;
1193
+ if (!this.preventApplyEditComplete) {
1194
+ this.triggerActionCompletedEvent('shape-customize');
1195
+ }
1196
+ this.triggerActionCompletedEvent('shape-select');
1197
+ }
1198
+ parent.isUndoRedoStack = this.preventEditComplete = false;
1178
1199
  }
1179
1200
  };
1180
1201
  return UndoRedo;
@@ -11,7 +11,9 @@ export declare enum FileType {
11
11
  /** The SVG file type. */
12
12
  Svg = "Svg",
13
13
  /** The WebP file type. */
14
- WebP = "WebP"
14
+ WebP = "WebP",
15
+ /** The BMP file type. */
16
+ Bmp = "Bmp"
15
17
  }
16
18
  /**
17
19
  * An enumeration representing the direction of an image editor operation.
@@ -13,6 +13,8 @@ export var FileType;
13
13
  FileType["Svg"] = "Svg";
14
14
  /** The WebP file type. */
15
15
  FileType["WebP"] = "WebP";
16
+ /** The BMP file type. */
17
+ FileType["Bmp"] = "Bmp";
16
18
  })(FileType || (FileType = {}));
17
19
  /**
18
20
  * An enumeration representing the direction of an image editor operation.
@@ -431,6 +431,12 @@ export declare class ImageEditor extends Component<HTMLDivElement> implements IN
431
431
  isSafari: boolean;
432
432
  /** @hidden */
433
433
  editCompleteArgs: object | RotateEventArgs | FlipEventArgs | CropEventArgs | FinetuneEventArgs | FrameChangeEventArgs | ImageFilterEventArgs | PanEventArgs | ResizeEventArgs | ShapeChangeEventArgs | ZoomEventArgs;
434
+ /** @hidden */
435
+ imageSettings: Dimension;
436
+ /** @hidden */
437
+ aspectRatioBaseDimension: boolean;
438
+ /** @hidden */
439
+ imageLoaded: boolean;
434
440
  private lowerContext;
435
441
  private upperContext;
436
442
  private inMemoryContext;
@@ -1075,7 +1081,7 @@ export declare class ImageEditor extends Component<HTMLDivElement> implements IN
1075
1081
  *
1076
1082
  * @param {string | ImageData } data - Specifies url of the image or image data.
1077
1083
  * @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.
1078
- * @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.
1084
+ * @param {ImageSettings} imageSettings - Optional. Specifies image settings to apply when loading an image.
1079
1085
  *
1080
1086
  * @remarks
1081
1087
  * The supported file types are JPG, JPEG, PNG, and SVG.
@@ -1275,10 +1281,12 @@ export declare class ImageEditor extends Component<HTMLDivElement> implements IN
1275
1281
  * @param {string} strokeColor - Specifies the outline color of the text annotation.
1276
1282
  * @param {number} strokeWidth - Specifies the outline stroke width of the text annotation.
1277
1283
  * @param {TransformationCollection[]} transformCollection - Specifies the transform collection of the text annotation.
1284
+ * @param {boolean} underline - Specifies whether the text should be underlined.
1285
+ * @param {boolean} strikethrough - Specifies whether the text should have a strikethrough.
1278
1286
  * @returns {boolean}.
1279
1287
  *
1280
1288
  */
1281
- drawText(x?: number, y?: number, text?: string, fontFamily?: string, fontSize?: number, bold?: boolean, italic?: boolean, color?: string, isSelected?: boolean, degree?: number, fillColor?: string, strokeColor?: string, strokeWidth?: number, transformCollection?: TransformationCollection[]): boolean;
1289
+ drawText(x?: number, y?: number, text?: string, fontFamily?: string, fontSize?: number, bold?: boolean, italic?: boolean, color?: string, isSelected?: boolean, degree?: number, fillColor?: string, strokeColor?: string, strokeWidth?: number, transformCollection?: TransformationCollection[], underline?: boolean, strikethrough?: boolean): boolean;
1282
1290
  /**
1283
1291
  * Draw an image as annotation on an image.
1284
1292
  *
@@ -1600,7 +1608,10 @@ export declare class ImageEditor extends Component<HTMLDivElement> implements IN
1600
1608
  private updateImage;
1601
1609
  private editCompleted;
1602
1610
  private updateColl;
1611
+ private scaleToFit;
1612
+ private setInitialZoomLevel;
1603
1613
  private resetToolbar;
1614
+ private setRotateZoom;
1604
1615
  private getData;
1605
1616
  private applyShapes;
1606
1617
  private closeOverlayTbar;