@syncfusion/ej2-image-editor 20.4.38 → 20.4.40

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.
@@ -127,6 +127,7 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
127
127
  this.tempBWFilter = false;
128
128
  this.isBrightnessAdjusted = false;
129
129
  this.isInitialLoading = false;
130
+ this.imageFileName = '';
130
131
  }
131
132
  preRender() {
132
133
  // pre render code snippets
@@ -3303,6 +3304,7 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
3303
3304
  ctx.drawImage(this.inMemoryCanvas, 0, 0, 300, 150);
3304
3305
  }
3305
3306
  updateCanvas() {
3307
+ const fileOpened = { fileName: this.imageFileName, fileType: this.imageFileType };
3306
3308
  this.lastX = this.baseImg.width / 2;
3307
3309
  this.lastY = this.baseImg.height / 2;
3308
3310
  let wrapperWidth;
@@ -3367,7 +3369,7 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
3367
3369
  if (this.disabled) {
3368
3370
  this.element.setAttribute('class', 'e-disabled');
3369
3371
  }
3370
- this.trigger('fileOpened');
3372
+ this.trigger('fileOpened', fileOpened);
3371
3373
  }
3372
3374
  imageOnLoad(src) {
3373
3375
  // eslint-disable-next-line @typescript-eslint/no-this-alias
@@ -3570,6 +3572,18 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
3570
3572
  }
3571
3573
  }
3572
3574
  fileSelect(inputElement, args) {
3575
+ this.imageFileName = inputElement.value.split('\\')[inputElement.value.split('\\').length - 1];
3576
+ this.imageFileName = this.imageFileName.split('.')[0];
3577
+ const fileType = inputElement.value.split('.');
3578
+ if (fileType[fileType.length - 1].toLowerCase() === 'jpg' || fileType[fileType.length - 1].toLowerCase() === 'jpeg') {
3579
+ this.imageFileType = 'Jpeg';
3580
+ }
3581
+ else if (fileType[fileType.length - 1].toLowerCase() === 'png') {
3582
+ this.imageFileType = 'Png';
3583
+ }
3584
+ else if (fileType[fileType.length - 1].toLowerCase() === 'svg') {
3585
+ this.imageFileType = 'Svg';
3586
+ }
3573
3587
  showSpinner(this.element);
3574
3588
  this.element.style.opacity = '0.5';
3575
3589
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
@@ -8332,7 +8346,6 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
8332
8346
  let heightRatio;
8333
8347
  let imgData;
8334
8348
  let zoomedRotate = false;
8335
- const factor = this.factor;
8336
8349
  if (this.factor === 1) {
8337
8350
  imgData = this.lowerContext.getImageData(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
8338
8351
  widthRatio = this.lowerCanvas.width / parseInt(this.lowerCanvas.style.maxWidth, 10);
@@ -8634,9 +8647,23 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
8634
8647
  this.imgDataColl = [];
8635
8648
  const type = typeof (data);
8636
8649
  if (type === 'string') {
8650
+ let fileName = data.split('.');
8651
+ if (fileName[fileName.length - 1].toLowerCase() === 'jpg' || fileName[fileName.length - 1].toLowerCase() === 'jpeg') {
8652
+ this.imageFileType = 'Jpeg';
8653
+ }
8654
+ else if (fileName[fileName.length - 1].toLowerCase() === 'png') {
8655
+ this.imageFileType = 'Png';
8656
+ }
8657
+ else if (fileName[fileName.length - 1].toLowerCase() === 'svg') {
8658
+ this.imageFileType = 'Svg';
8659
+ }
8660
+ fileName = fileName[fileName.length - 2].split('/');
8661
+ this.imageFileName = fileName[fileName.length - 1];
8637
8662
  this.imageOnLoad(data);
8638
8663
  }
8639
8664
  else {
8665
+ this.imageFileName = 'ImageEditor';
8666
+ this.imageFileType = 'Jpeg';
8640
8667
  const tempFilter = this.lowerContext.filter;
8641
8668
  this.lowerCanvas = document.querySelector('#' + this.element.id + '_lowerCanvas');
8642
8669
  this.upperCanvas = document.querySelector('#' + this.element.id + '_upperCanvas');
@@ -8740,6 +8767,8 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
8740
8767
  this.tempObjColl = undefined;
8741
8768
  this.adjustmentLevel = { brightness: 0, contrast: 0, hue: 0, opacity: 100, saturation: 0, blur: 0, exposure: 0, sharpen: false, bw: false };
8742
8769
  this.tempAdjustmentLevel = { brightness: 0, contrast: 0, hue: 0, opacity: 100, saturation: 0, blur: 0, exposure: 0, sharpen: false, bw: false };
8770
+ this.imageFileName = '';
8771
+ this.imageFileType = undefined;
8743
8772
  this.canvasFilter = this.currentFilter = this.tempAdjustmentValue = '';
8744
8773
  this.lowerContext.filter = this.initialAdjustmentValue = this.adjustmentValue = 'brightness(' + 1 + ') ' + 'contrast(' + 100
8745
8774
  + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
@@ -8860,22 +8889,23 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
8860
8889
  }
8861
8890
  type = type ? type : 'Png';
8862
8891
  this.redrawActObj();
8863
- const beforeSave = { cancel: false, fileName: fileName ? fileName : 'ImageEditor', fileType: type };
8864
- const saved = { fileName: fileName ? fileName : 'ImageEditor', fileType: type };
8892
+ fileName = fileName ? fileName : this.imageFileName;
8893
+ const beforeSave = { cancel: false, fileName: fileName, fileType: type };
8894
+ const saved = { fileName: fileName ? fileName : this.imageFileName, fileType: type };
8865
8895
  this.trigger('beforeSave', beforeSave, (observableSaveArgs) => {
8866
8896
  if (!observableSaveArgs.cancel) {
8867
8897
  this.currObjType.isSave = true;
8868
8898
  fileName = observableSaveArgs.fileName ? observableSaveArgs.fileName : fileName;
8869
8899
  if (type.toLowerCase() === 'svg') {
8870
- fileName = fileName || 'ImageEditor';
8900
+ fileName = fileName || this.imageFileName;
8871
8901
  this.toSVGImg(fileName);
8872
8902
  }
8873
8903
  else if (type.toLowerCase() === 'jpeg') {
8874
- fileName = fileName || 'ImageEditor';
8904
+ fileName = fileName || this.imageFileName;
8875
8905
  this.toBlobFn(fileName, type.toLowerCase());
8876
8906
  }
8877
8907
  else {
8878
- fileName = fileName || 'ImageEditor';
8908
+ fileName = fileName || this.imageFileName;
8879
8909
  this.toBlobFn(fileName, type.toLowerCase());
8880
8910
  }
8881
8911
  this.trigger('saved', saved);
@@ -9411,7 +9441,8 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
9411
9441
  this.initialAdjustmentValue = 'brightness(1) contrast(100%) hue-rotate(0deg) saturate(100%) opacity(1) blur(0px) sepia(0%) grayscale(0%) invert(0%)';
9412
9442
  }
9413
9443
  this.lowerContext.filter = this.initialAdjustmentValue;
9414
- this.setFilter(filterOption.toString());
9444
+ const filterValue = filterOption.split(' ');
9445
+ this.setFilter(filterValue.join('').toLowerCase());
9415
9446
  }
9416
9447
  /**
9417
9448
  * To apply the filters to an image