@syncfusion/ej2-image-editor 29.1.37 → 29.2.4

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 (81) hide show
  1. package/dist/ej2-image-editor.umd.min.js +2 -2
  2. package/dist/ej2-image-editor.umd.min.js.map +1 -1
  3. package/dist/es6/ej2-image-editor.es2015.js +80 -17
  4. package/dist/es6/ej2-image-editor.es2015.js.map +1 -1
  5. package/dist/es6/ej2-image-editor.es5.js +80 -17
  6. package/dist/es6/ej2-image-editor.es5.js.map +1 -1
  7. package/dist/global/ej2-image-editor.min.js +2 -2
  8. package/dist/global/ej2-image-editor.min.js.map +1 -1
  9. package/dist/global/index.d.ts +1 -1
  10. package/package.json +12 -12
  11. package/src/image-editor/action/draw.js +1 -0
  12. package/src/image-editor/action/selection.js +12 -8
  13. package/src/image-editor/base/image-editor-model.d.ts +25 -0
  14. package/src/image-editor/base/image-editor.d.ts +24 -0
  15. package/src/image-editor/base/image-editor.js +14 -0
  16. package/src/image-editor/renderer/toolbar.d.ts +1 -0
  17. package/src/image-editor/renderer/toolbar.js +53 -9
  18. package/styles/bds-lite.css +2 -2
  19. package/styles/bds.css +2 -2
  20. package/styles/bootstrap-dark-lite.css +2 -2
  21. package/styles/bootstrap-dark.css +2 -2
  22. package/styles/bootstrap-lite.css +2 -2
  23. package/styles/bootstrap.css +2 -2
  24. package/styles/bootstrap4-lite.css +2 -2
  25. package/styles/bootstrap4.css +2 -2
  26. package/styles/bootstrap5-dark-lite.css +2 -2
  27. package/styles/bootstrap5-dark.css +2 -2
  28. package/styles/bootstrap5-lite.css +2 -2
  29. package/styles/bootstrap5.3-lite.css +2 -2
  30. package/styles/bootstrap5.3.css +2 -2
  31. package/styles/bootstrap5.css +2 -2
  32. package/styles/fabric-dark-lite.css +2 -2
  33. package/styles/fabric-dark.css +2 -2
  34. package/styles/fabric-lite.css +2 -2
  35. package/styles/fabric.css +2 -2
  36. package/styles/fluent-dark-lite.css +2 -2
  37. package/styles/fluent-dark.css +2 -2
  38. package/styles/fluent-lite.css +2 -2
  39. package/styles/fluent.css +2 -2
  40. package/styles/fluent2-lite.css +2 -2
  41. package/styles/fluent2.css +2 -2
  42. package/styles/highcontrast-light-lite.css +2 -2
  43. package/styles/highcontrast-light.css +2 -2
  44. package/styles/highcontrast-lite.css +2 -2
  45. package/styles/highcontrast.css +2 -2
  46. package/styles/image-editor/_layout.scss +2 -2
  47. package/styles/image-editor/bds.css +2 -2
  48. package/styles/image-editor/bootstrap-dark.css +2 -2
  49. package/styles/image-editor/bootstrap.css +2 -2
  50. package/styles/image-editor/bootstrap4.css +2 -2
  51. package/styles/image-editor/bootstrap5-dark.css +2 -2
  52. package/styles/image-editor/bootstrap5.3.css +2 -2
  53. package/styles/image-editor/bootstrap5.css +2 -2
  54. package/styles/image-editor/fabric-dark.css +2 -2
  55. package/styles/image-editor/fabric.css +2 -2
  56. package/styles/image-editor/fluent-dark.css +2 -2
  57. package/styles/image-editor/fluent.css +2 -2
  58. package/styles/image-editor/fluent2.css +2 -2
  59. package/styles/image-editor/highcontrast-light.css +2 -2
  60. package/styles/image-editor/highcontrast.css +2 -2
  61. package/styles/image-editor/material-dark.css +2 -2
  62. package/styles/image-editor/material.css +2 -2
  63. package/styles/image-editor/material3-dark.css +2 -2
  64. package/styles/image-editor/material3.css +2 -2
  65. package/styles/image-editor/tailwind-dark.css +2 -2
  66. package/styles/image-editor/tailwind.css +2 -2
  67. package/styles/image-editor/tailwind3.css +2 -2
  68. package/styles/material-dark-lite.css +2 -2
  69. package/styles/material-dark.css +2 -2
  70. package/styles/material-lite.css +2 -2
  71. package/styles/material.css +2 -2
  72. package/styles/material3-dark-lite.css +2 -2
  73. package/styles/material3-dark.css +2 -2
  74. package/styles/material3-lite.css +2 -2
  75. package/styles/material3.css +2 -2
  76. package/styles/tailwind-dark-lite.css +2 -2
  77. package/styles/tailwind-dark.css +2 -2
  78. package/styles/tailwind-lite.css +2 -2
  79. package/styles/tailwind.css +2 -2
  80. package/styles/tailwind3-lite.css +2 -2
  81. package/styles/tailwind3.css +2 -2
@@ -3453,6 +3453,7 @@ class Draw {
3453
3453
  if (!parent.isUndoRedo) {
3454
3454
  parent.notify('filter', { prop: 'update-finetunes', onPropertyChange: false });
3455
3455
  }
3456
+ proxy.lowerContext.imageSmoothingQuality = parent.imageSmoothingEnabled ? 'high' : 'low';
3456
3457
  proxy.lowerContext.drawImage(parent.baseImg, 0, 0, proxy.parent.lowerCanvas.width, proxy.parent.lowerCanvas.height);
3457
3458
  let isCropped = false;
3458
3459
  let isSameDimension = false;
@@ -10424,18 +10425,22 @@ class Selection {
10424
10425
  let endY = isStart ? actPoint.endY : actPoint.startY;
10425
10426
  const wrapperWidth = parent.upperCanvas.width;
10426
10427
  const wrapperHeight = parent.upperCanvas.height;
10428
+ const minX = destLeft < 0 ? 0 : destLeft;
10429
+ const minY = destTop < 0 ? 0 : destTop;
10430
+ const maxX = destLeft + destWidth > wrapperWidth ? wrapperWidth : destLeft + destWidth;
10431
+ const maxY = destTop + destHeight > wrapperHeight ? wrapperHeight : destTop + destHeight;
10427
10432
  if (Browser.isDevice) {
10428
- if (startX < 0 && destLeft < 0) {
10429
- startX = 0;
10433
+ if (startX < minX) {
10434
+ startX = minX;
10430
10435
  }
10431
- if (startY < 0 && destTop < 0) {
10432
- startY = 0;
10436
+ if (startY < minY) {
10437
+ startY = minY;
10433
10438
  }
10434
- if (endX > wrapperWidth && destLeft + destWidth > wrapperWidth) {
10435
- endX = wrapperWidth;
10439
+ if (endX > maxX) {
10440
+ endX = maxX;
10436
10441
  }
10437
- if (endY > wrapperHeight && destTop + destHeight > wrapperHeight) {
10438
- endY = wrapperHeight;
10442
+ if (endY > maxY) {
10443
+ endY = maxY;
10439
10444
  }
10440
10445
  }
10441
10446
  else {
@@ -22366,6 +22371,17 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends Component {
22366
22371
  }
22367
22372
  this.updateDropInfoContent(this.element.querySelector('.e-ie-drop-info'));
22368
22373
  break;
22374
+ case 'imageSmoothingEnabled':
22375
+ if (newProperties.imageSmoothingEnabled) {
22376
+ this.imageSmoothingEnabled = true;
22377
+ this.lowerContext.imageSmoothingQuality = 'high';
22378
+ }
22379
+ else {
22380
+ this.imageSmoothingEnabled = false;
22381
+ this.lowerContext.imageSmoothingQuality = 'low';
22382
+ }
22383
+ this.notify('draw', { prop: 'render-image', value: { isMouseWheel: false } });
22384
+ break;
22369
22385
  }
22370
22386
  }
22371
22387
  }
@@ -26507,6 +26523,9 @@ __decorate([
26507
26523
  __decorate([
26508
26524
  Property()
26509
26525
  ], ImageEditor.prototype, "quickAccessToolbarTemplate", void 0);
26526
+ __decorate([
26527
+ Property(false)
26528
+ ], ImageEditor.prototype, "imageSmoothingEnabled", void 0);
26510
26529
  __decorate([
26511
26530
  Property(false)
26512
26531
  ], ImageEditor.prototype, "isReadOnly", void 0);
@@ -28606,6 +28625,47 @@ class ToolbarModule {
28606
28625
  ]
28607
28626
  });
28608
28627
  dialog.appendTo('#' + id + '_saveDialog');
28628
+ this.updateSavePreviewImage();
28629
+ }
28630
+ updateSavePreviewImage() {
28631
+ const parent = this.parent;
28632
+ const id = parent.element.id;
28633
+ const elem = parent.element.querySelector('#' + id + '_saveDialog');
28634
+ if (Browser.isDevice || !elem) {
28635
+ return;
28636
+ }
28637
+ const dialogWidth = elem.offsetWidth;
28638
+ const dialogMaxHeight = parseInt(elem.style.maxHeight, 10);
28639
+ const headerHeight = elem.querySelector('.e-dlg-header-content').offsetHeight;
28640
+ const footerHeight = elem.querySelector('.e-footer-content').offsetHeight;
28641
+ const padding = parseInt(window.getComputedStyle(elem.querySelector('#' + id + '_saveDialog_dialog-content')).padding, 10);
28642
+ const imageSizeContent = 20; // Image size text container div height
28643
+ const canvasMaxWidth = dialogWidth * (35 / 100); // 35% of dialog's width
28644
+ const canvasMaxHeight = dialogMaxHeight - headerHeight - footerHeight - imageSizeContent - (padding * 2);
28645
+ const canvas = parent.element.querySelector('#' + id + '_imgPic');
28646
+ const width = canvas.width;
28647
+ const height = canvas.height;
28648
+ const widthScale = canvasMaxWidth / width;
28649
+ const heightScale = canvasMaxHeight / height;
28650
+ let cssMaxWidth = Math.min(width, canvasMaxWidth);
28651
+ let cssMaxHeight = Math.min(height, canvasMaxHeight);
28652
+ if (widthScale < 1 && widthScale < heightScale) {
28653
+ cssMaxWidth = width * widthScale;
28654
+ cssMaxHeight = height * widthScale;
28655
+ }
28656
+ else if (heightScale < 1 && heightScale < widthScale) {
28657
+ cssMaxWidth = width * heightScale;
28658
+ cssMaxHeight = height * heightScale;
28659
+ }
28660
+ const imageObj = { canvas: null };
28661
+ parent.notify('export', { prop: 'exportToCanvas', value: { object: imageObj } });
28662
+ const ctx = canvas.getContext('2d');
28663
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
28664
+ canvas.width = cssMaxWidth;
28665
+ canvas.height = cssMaxHeight;
28666
+ const tempCanvas = imageObj['canvas'];
28667
+ ctx.imageSmoothingQuality = 'medium';
28668
+ ctx.drawImage(tempCanvas, 0, 0, tempCanvas.width, tempCanvas.height, 0, 0, cssMaxWidth, cssMaxHeight);
28609
28669
  }
28610
28670
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
28611
28671
  saveDialogClosed(id) {
@@ -28705,6 +28765,7 @@ class ToolbarModule {
28705
28765
  this.updateImageSize(isNullOrUndefined(this.currentQuality) ? 1 : this.currentQuality, obj['canvas'], this.fileType);
28706
28766
  document.getElementById(id + '_' + this.imageQuality).checked = true;
28707
28767
  }
28768
+ this.updateSavePreviewImage();
28708
28769
  }
28709
28770
  });
28710
28771
  drpDownBtn.appendTo('#' + id + '_saveDropdownbtn');
@@ -28759,12 +28820,14 @@ class ToolbarModule {
28759
28820
  created: () => {
28760
28821
  this.updateImageSize(this.currentQuality, obj['canvas'], 'jpeg');
28761
28822
  qualitySliderValueSpan.innerHTML = (Math.round(this.currentQuality * 100)).toString();
28823
+ this.updateSavePreviewImage();
28762
28824
  },
28763
28825
  changed: (args) => {
28764
28826
  this.currentQuality = args.value;
28765
28827
  qualitySliderValueSpan.innerHTML = (Math.round(this.currentQuality * 100)).toString();
28766
28828
  parent.notify('export', { prop: 'setImageQuality', value: { value: args.value } });
28767
28829
  this.updateImageSize(args.value, obj['canvas'], 'jpeg');
28830
+ this.updateSavePreviewImage();
28768
28831
  }
28769
28832
  });
28770
28833
  sliderObj.appendTo('#' + id + '_qualitySlider');
@@ -28785,6 +28848,7 @@ class ToolbarModule {
28785
28848
  this.currentQuality = compressionValues[target.textContent];
28786
28849
  this.imageQuality = target.textContent.toLowerCase();
28787
28850
  this.updateImageSize(compressionValues[target.textContent], obj['canvas'], 'jpeg');
28851
+ this.updateSavePreviewImage();
28788
28852
  }
28789
28853
  }
28790
28854
  updateImageSize(quality, tempCanvas, fileType) {
@@ -28801,7 +28865,11 @@ class ToolbarModule {
28801
28865
  else {
28802
28866
  imageNameLabel = document.getElementById(id + '_imageNameLabel');
28803
28867
  }
28868
+ const imageSmoothingEnabled = parent.imageSmoothingEnabled;
28869
+ ctx.canvas.getContext('2d').imageSmoothingQuality = imageSmoothingEnabled ? 'high' : 'low';
28804
28870
  if (fileType.toLowerCase() === 'jpeg') {
28871
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
28872
+ ctx.drawImage(tempCanvas, 0, 0);
28805
28873
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
28806
28874
  tempCanvas.toBlob((function (blob) {
28807
28875
  fileSize = Math.floor(blob.size / 1024);
@@ -28817,20 +28885,12 @@ class ToolbarModule {
28817
28885
  if (Browser.isDevice) {
28818
28886
  canvas.style.display = 'none';
28819
28887
  }
28820
- else {
28821
- const compressedImage = new Image();
28822
- compressedImage.src = URL.createObjectURL(blob);
28823
- // eslint-disable-next-line @typescript-eslint/tslint/config
28824
- compressedImage.onload = function () {
28825
- ctx.drawImage(compressedImage, 0, 0);
28826
- URL.revokeObjectURL(compressedImage.src);
28827
- };
28828
- }
28829
28888
  this.fileSize = fileSize;
28830
28889
  }).bind(this), 'image/jpeg', quality);
28831
28890
  }
28832
28891
  else if (!isNullOrUndefined(fileType) && (fileType.toLowerCase() === 'png' || fileType.toLowerCase() === 'webp')) {
28833
28892
  const type = 'image/' + fileType.toLowerCase();
28893
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
28834
28894
  ctx.drawImage(tempCanvas, 0, 0);
28835
28895
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
28836
28896
  tempCanvas.toBlob((function (blob) {
@@ -28851,6 +28911,7 @@ class ToolbarModule {
28851
28911
  }).bind(this), type, 1);
28852
28912
  }
28853
28913
  else if (!isNullOrUndefined(fileType) && fileType.toLowerCase() === 'svg') {
28914
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
28854
28915
  ctx.drawImage(tempCanvas, 0, 0);
28855
28916
  const svgDataUrl = tempCanvas.toDataURL('image/svg+xml');
28856
28917
  const base64Data = svgDataUrl.split(',')[1];
@@ -28876,6 +28937,7 @@ class ToolbarModule {
28876
28937
  canvas.style.display = 'none';
28877
28938
  }
28878
28939
  else {
28940
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
28879
28941
  ctx.drawImage(tempCanvas, 0, 0);
28880
28942
  if (this.initialSize > 1000) {
28881
28943
  const megabytes = this.initialSize / 1048576;
@@ -31521,6 +31583,7 @@ class ToolbarModule {
31521
31583
  if (filter) {
31522
31584
  let ctx = filter.getContext('2d');
31523
31585
  ctx = filter.getContext('2d');
31586
+ ctx.imageSmoothingQuality = parent.imageSmoothingEnabled ? 'high' : 'low';
31524
31587
  filter.style.width = '100px';
31525
31588
  filter.style.height = '100px';
31526
31589
  parent.notify('filter', { prop: 'updateAdj', value: { type: type, value: null, isPreview: true, ctx: ctx } });