@syncfusion/ej2-image-editor 27.1.48 → 27.1.50

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.
@@ -3433,11 +3433,19 @@ class Draw {
3433
3433
  parent.notify('filter', { prop: 'update-finetunes', onPropertyChange: false });
3434
3434
  }
3435
3435
  proxy.lowerContext.drawImage(parent.baseImg, 0, 0, proxy.parent.lowerCanvas.width, proxy.parent.lowerCanvas.height);
3436
+ let isCropped = false;
3437
+ let isSameDimension = false;
3438
+ if (parent.isImageUpdated) {
3439
+ const { srcWidth, srcHeight } = parent.img;
3440
+ const { width, height } = parent.baseImgCanvas;
3441
+ isCropped = srcWidth !== width || srcHeight !== height;
3442
+ isSameDimension = parent.baseImg.width === width && parent.baseImg.height === height;
3443
+ }
3436
3444
  hideSpinner(parent.element);
3437
3445
  parent.element.style.opacity = '1';
3438
3446
  proxy.updateBaseImgCanvas();
3439
3447
  const fileOpened = { fileName: this.fileName, fileType: this.fileType, isValidImage: true };
3440
- proxy.updateCanvas();
3448
+ proxy.updateCanvas(isCropped, isSameDimension);
3441
3449
  if (parent.currObjType.isUndoZoom) {
3442
3450
  parent.currObjType.isUndoZoom = false;
3443
3451
  proxy.parent.lowerCanvas.style.display = 'block';
@@ -3479,12 +3487,26 @@ class Draw {
3479
3487
  parent.baseImgCanvas.height = parent.baseImg.height;
3480
3488
  parent.baseImgCanvas.getContext('2d').drawImage(parent.baseImg, 0, 0);
3481
3489
  }
3482
- updateCanvas() {
3490
+ updateCanvas(isCropped, isSameDimension) {
3483
3491
  const parent = this.parent;
3484
- if (!parent.isImageUpdated) {
3492
+ if (!parent.isImageUpdated || !isCropped) {
3485
3493
  parent.img.srcWidth = parent.baseImgCanvas.width;
3486
3494
  parent.img.srcHeight = parent.baseImgCanvas.height;
3487
3495
  }
3496
+ else if (!isSameDimension && isCropped) {
3497
+ parent.img.srcLeft = 0;
3498
+ parent.img.srcTop = 0;
3499
+ parent.img.srcWidth = parent.baseImgCanvas.width;
3500
+ parent.img.srcHeight = parent.baseImgCanvas.height;
3501
+ parent.currSelectionPoint = null;
3502
+ parent.cropObj = { cropZoom: 0, defaultZoom: 0, totalPannedPoint: { x: 0, y: 0 }, totalPannedClientPoint: { x: 0, y: 0 },
3503
+ totalPannedInternalPoint: { x: 0, y: 0 }, tempFlipPanPoint: { x: 0, y: 0 }, activeObj: {}, rotateFlipColl: [],
3504
+ degree: 0, currFlipState: '', straighten: 0, destPoints: { startX: 0, startY: 0, width: 0, height: 0 },
3505
+ srcPoints: { startX: 0, startY: 0, width: 0, height: 0 }, filter: '', isBrightAdjust: false,
3506
+ zoomFactor: 0, previousZoomValue: 0, aspectWidth: null, aspectHeight: null, frame: 'none', straightenZoom: 0,
3507
+ adjustmentLevel: { brightness: 0, contrast: 0, hue: 0, opacity: 100, saturation: 0, blur: 0,
3508
+ exposure: 0, transparency: 100, sharpen: false, bw: false }, currentFilter: '' };
3509
+ }
3488
3510
  const obj = { width: 0, height: 0 };
3489
3511
  parent.notify('transform', { prop: 'calcMaxDimension', onPropertyChange: false,
3490
3512
  value: { width: parent.img.srcWidth, height: parent.img.srcHeight, obj: obj, isImgShape: null } });
@@ -8758,6 +8780,9 @@ class Selection {
8758
8780
  this.isSliderActive = false;
8759
8781
  this.arrowShape = [ArrowheadType.None, ArrowheadType.SolidArrow];
8760
8782
  this.isTouchDblClick = false;
8783
+ this.isMouseDown = false;
8784
+ this.isMouseUp = false;
8785
+ this.mouseWheel = 0;
8761
8786
  this.parent = parent;
8762
8787
  this.addEventListener();
8763
8788
  }
@@ -9068,6 +9093,7 @@ class Selection {
9068
9093
  this.isPreventDragging = false;
9069
9094
  this.timer = undefined;
9070
9095
  this.tempObjColl = undefined;
9096
+ this.mouseWheel = 0;
9071
9097
  this.textRow = 1;
9072
9098
  this.mouseDownPoint = { x: 0, y: 0 };
9073
9099
  this.previousPoint = { x: 0, y: 0 };
@@ -9088,6 +9114,7 @@ class Selection {
9088
9114
  this.mouseDown = '';
9089
9115
  this.isSliderActive = false;
9090
9116
  this.arrowShape = [ArrowheadType.None, ArrowheadType.SolidArrow];
9117
+ this.isMouseDown = this.isMouseUp = false;
9091
9118
  }
9092
9119
  performTabAction() {
9093
9120
  const parent = this.parent;
@@ -10086,6 +10113,12 @@ class Selection {
10086
10113
  parent.notify('shape', { prop: 'updateShapeChangeEventArgs', onPropertyChange: false, value: { shapeSettings: shapeResizingArgs.currentShapeSettings, allowShapeOverflow: shapeResizingArgs.allowShapeOverflow } });
10087
10114
  }
10088
10115
  else {
10116
+ if (this.isMouseDown) {
10117
+ shapeResizingArgs.action = 'resize-start';
10118
+ }
10119
+ else if (this.isMouseUp) {
10120
+ shapeResizingArgs.action = 'resize-end';
10121
+ }
10089
10122
  const selectionResizingArgs = { action: shapeResizingArgs.action,
10090
10123
  previousSelectionSettings: { type: parent.getSelectionType(parent.activeObj.shape),
10091
10124
  startX: shapeResizingArgs.previousShapeSettings.startX,
@@ -11878,6 +11911,8 @@ class Selection {
11878
11911
  }
11879
11912
  const imageEditorClickEventArgs = { point: this.setXYPoints(e) };
11880
11913
  parent.trigger('click', imageEditorClickEventArgs);
11914
+ this.isMouseDown = true;
11915
+ this.isMouseUp = false;
11881
11916
  this.clickEvent(imageEditorClickEventArgs, e);
11882
11917
  }
11883
11918
  getImagePoints(x, y) {
@@ -12239,6 +12274,7 @@ class Selection {
12239
12274
  }
12240
12275
  }
12241
12276
  if (type !== '') {
12277
+ parent.isZoomBtnClick = true;
12242
12278
  parent.notify('draw', { prop: 'performPointZoom', onPropertyChange: false,
12243
12279
  value: { x: center.x, y: center.y, type: type, isResize: null } });
12244
12280
  }
@@ -12321,11 +12357,14 @@ class Selection {
12321
12357
  this.dragCanvas = parent.togglePan = true;
12322
12358
  }
12323
12359
  }
12360
+ this.isMouseDown = false;
12361
+ this.isMouseUp = false;
12324
12362
  }
12325
12363
  mouseUpEventHandler(e) {
12326
12364
  const parent = this.parent;
12327
12365
  const id = parent.element.id;
12328
- parent.isKBDNavigation = false;
12366
+ parent.isKBDNavigation = this.isMouseDown = false;
12367
+ this.isMouseUp = true;
12329
12368
  if (!Browser.isDevice && ((parent.element.querySelector('#' + id + '_contextualToolbar') &&
12330
12369
  !parent.element.querySelector('#' + id + '_contextualToolbar').parentElement.classList.contains('e-hide')) ||
12331
12370
  (parent.element.querySelector('#' + id + '_headWrapper')
@@ -12495,6 +12534,11 @@ class Selection {
12495
12534
  parent.notify('toolbar', { prop: 'destroy-qa-toolbar', onPropertyChange: false });
12496
12535
  }
12497
12536
  }
12537
+ else if (isCropSelection && this.isMouseUp && parent.cursor.indexOf('resize') > -1) {
12538
+ const previousShapeSettings = this.updatePrevShapeSettings();
12539
+ const shapeResizingArgs = { cancel: false, action: 'resize-end', previousShapeSettings: previousShapeSettings };
12540
+ this.triggerShapeChange(shapeResizingArgs, shapeResizingArgs, 'resize');
12541
+ }
12498
12542
  if (parent.activeObj) {
12499
12543
  let isCropSelection = false;
12500
12544
  let splitWords;
@@ -12614,6 +12658,7 @@ class Selection {
12614
12658
  parent.isShapeDrawing = false;
12615
12659
  parent.notify('freehand-draw', { prop: 'resetSelPoints', onPropertyChange: false });
12616
12660
  }
12661
+ this.isMouseUp = false;
12617
12662
  }
12618
12663
  adjustActObjForLineArrow(obj) {
12619
12664
  let isAdjusted = false;
@@ -13069,6 +13114,7 @@ class Selection {
13069
13114
  case (e.ctrlKey && '+'):
13070
13115
  if ((parent.zoomSettings.zoomTrigger & ZoomTrigger.Commands) === ZoomTrigger.Commands) {
13071
13116
  this.zoomType = 'Commands';
13117
+ parent.isZoomBtnClick = true;
13072
13118
  parent.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
13073
13119
  value: { zoomFactor: .1, zoomPoint: null }, isResize: null });
13074
13120
  parent.notify('draw', { prop: 'redrawDownScale' });
@@ -13085,6 +13131,7 @@ class Selection {
13085
13131
  case (e.ctrlKey && '-'):
13086
13132
  if ((parent.zoomSettings.zoomTrigger & ZoomTrigger.Commands) === ZoomTrigger.Commands) {
13087
13133
  this.zoomType = 'Commands';
13134
+ parent.isZoomBtnClick = true;
13088
13135
  parent.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
13089
13136
  value: { zoomFactor: -.1, zoomPoint: null }, isResize: null });
13090
13137
  parent.notify('draw', { prop: 'redrawDownScale' });
@@ -13221,6 +13268,11 @@ class Selection {
13221
13268
  e.stopImmediatePropagation();
13222
13269
  }
13223
13270
  handleScroll(e) {
13271
+ this.mouseWheel++;
13272
+ if (this.mouseWheel === 2) {
13273
+ this.mouseWheel = 0;
13274
+ return;
13275
+ }
13224
13276
  const parent = this.parent;
13225
13277
  let x;
13226
13278
  let y;
@@ -13256,6 +13308,7 @@ class Selection {
13256
13308
  }
13257
13309
  }
13258
13310
  if (type !== '') {
13311
+ parent.isZoomBtnClick = true;
13259
13312
  parent.notify('draw', { prop: 'performPointZoom', onPropertyChange: false,
13260
13313
  value: { x: x, y: y, type: type, isResize: null } });
13261
13314
  parent.notify('draw', { prop: 'redrawDownScale' });
@@ -13620,6 +13673,12 @@ class Selection {
13620
13673
  parent.editCompleteArgs = shapeChangingArgs;
13621
13674
  }
13622
13675
  else {
13676
+ if (this.isMouseDown) {
13677
+ shapeChangingArgs.action = 'resize-start';
13678
+ }
13679
+ else if (this.isMouseUp) {
13680
+ shapeChangingArgs.action = 'resize-end';
13681
+ }
13623
13682
  const selectionChangingArgs = { action: shapeChangingArgs.action,
13624
13683
  previousSelectionSettings: { type: parent.getSelectionType(parent.activeObj.shape),
13625
13684
  startX: shapeChangingArgs.previousShapeSettings.startX,
@@ -14640,6 +14699,10 @@ class Shape {
14640
14699
  parent.activeObj.opacity = opacity;
14641
14700
  }
14642
14701
  strokeSettings.strokeWidth = strokeWidth ? strokeWidth : strokeSettings.strokeWidth;
14702
+ const shape = parent.activeObj.shape;
14703
+ if ((shape === 'rectangle' || shape === 'ellipse') && strokeWidth === 0) {
14704
+ strokeSettings.strokeWidth = 0;
14705
+ }
14643
14706
  strokeSettings.strokeColor = strokeColor ? strokeColor : strokeSettings.strokeColor;
14644
14707
  strokeSettings.fillColor = fillColor ? fillColor : strokeSettings.fillColor;
14645
14708
  strokeSettings.radius = radius ? radius : strokeSettings.radius;
@@ -22186,6 +22249,8 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends Component {
22186
22249
  this.notify('toolbar', { prop: 'getLocaleText', onPropertyChange: false, value: { obj: browseObj } });
22187
22250
  const supportObj = { key: 'SupportText' };
22188
22251
  this.notify('toolbar', { prop: 'getLocaleText', onPropertyChange: false, value: { obj: supportObj } });
22252
+ const andObj = { key: 'And' };
22253
+ this.notify('toolbar', { prop: 'getLocaleText', onPropertyChange: false, value: { obj: andObj } });
22189
22254
  const dropAreaElement = this.createElement('div', { id: this.element.id + '_dropArea', className: 'e-ie-drop-area', attrs: { style: 'position: relative;' } });
22190
22255
  const dropIconElement = this.createElement('span', { className: 'e-ie-drop-icon e-icons e-image', attrs: { style: 'position: absolute;' } });
22191
22256
  const dropContentElement = this.createElement('span', { className: 'e-ie-drop-content', attrs: { style: 'position: absolute; display: none;' } });
@@ -22201,7 +22266,7 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends Component {
22201
22266
  dropAnchorElement.href = '';
22202
22267
  minDropAnchorElem.href = '';
22203
22268
  const dropInfoElement = this.createElement('span', { className: 'e-ie-drop-info', attrs: { position: 'absolute' } });
22204
- dropInfoElement.textContent = supportObj['value'] + ' SVG, PNG, and JPG';
22269
+ dropInfoElement.textContent = supportObj['value'] + ' SVG, PNG, ' + andObj['value'] + ' JPG';
22205
22270
  const dropUploader = dropAreaElement.appendChild(this.createElement('input', {
22206
22271
  id: this.element.id + '_dropfileUpload', className: 'e-fileUpload e-image-upload'
22207
22272
  }));
@@ -22445,7 +22510,7 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends Component {
22445
22510
  this.notify('draw', { prop: 'open', value: { data: data } });
22446
22511
  }
22447
22512
  else {
22448
- this.updateImage(data, imageSettings.backgroundColor);
22513
+ this.updateImage(data, imageSettings ? imageSettings.backgroundColor : null);
22449
22514
  }
22450
22515
  }
22451
22516
  /**
@@ -23670,7 +23735,7 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends Component {
23670
23735
  }
23671
23736
  }
23672
23737
  updateImage(data, imageBackgroundColor) {
23673
- if (data || imageBackgroundColor) {
23738
+ if (data || imageBackgroundColor || imageBackgroundColor === '') {
23674
23739
  const prevCropObj = extend({}, this.cropObj, {}, true);
23675
23740
  const object = { currObj: {} };
23676
23741
  this.notify('filter', { prop: 'getCurrentObj', onPropertyChange: false, value: { object: object } });
@@ -23712,7 +23777,7 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends Component {
23712
23777
  }
23713
23778
  }, 100);
23714
23779
  }
23715
- if (imageBackgroundColor) {
23780
+ if (imageBackgroundColor || imageBackgroundColor === '') {
23716
23781
  this.notify('draw', { prop: 'imageBackgroundColor', onPropertyChange: false, value: { color: imageBackgroundColor } });
23717
23782
  this.notify('draw', { prop: 'render-image', value: { isMouseWheel: false } });
23718
23783
  if (!data) {
@@ -26419,7 +26484,8 @@ class ToolbarModule {
26419
26484
  BorderRadius: 'Border Radius',
26420
26485
  TextOutlineColor: 'Outline Color',
26421
26486
  TextOutlineWidth: 'Outline Width',
26422
- PixelSize: 'Pixel Size'
26487
+ PixelSize: 'Pixel Size',
26488
+ And: 'and'
26423
26489
  };
26424
26490
  this.l10n = new L10n('image-editor', this.defaultLocale, this.parent.locale);
26425
26491
  }
@@ -27084,13 +27150,11 @@ class ToolbarModule {
27084
27150
  zoomIn.addEventListener('mousedown', this.zoomInBtnMouseDownHandler.bind(this));
27085
27151
  zoomIn.addEventListener('mouseup', this.zoomBtnMouseUpHandler.bind(this));
27086
27152
  zoomIn.addEventListener('click', this.zoomInBtnClickHandler.bind(this));
27087
- zoomIn.addEventListener('touchstart', this.zoomInBtnClickHandler.bind(this));
27088
27153
  }
27089
27154
  if (zoomOut) {
27090
27155
  zoomOut.addEventListener('mousedown', this.zoomOutBtnMouseDownHandler.bind(this));
27091
27156
  zoomOut.addEventListener('mouseup', this.zoomBtnMouseUpHandler.bind(this));
27092
27157
  zoomOut.addEventListener('click', this.zoomOutBtnClickHandler.bind(this));
27093
- zoomIn.addEventListener('touchstart', this.zoomInBtnClickHandler.bind(this));
27094
27158
  }
27095
27159
  }
27096
27160
  widthPress(e) {
@@ -31610,6 +31674,7 @@ class ToolbarModule {
31610
31674
  parent.notify('draw', { prop: 'render-image', value: { isMouseWheel: null, isPreventClearRect: null, isFrame: true } });
31611
31675
  parent.isFrameBtnClick = true;
31612
31676
  parent.curFrameObjEvent = { previousFrameSetting: parent.tempFrameObj, currentFrameSetting: parent.frameObj };
31677
+ parent.notify('draw', { prop: 'triggerFrameChange', value: { prevFrameSettings: parent.tempFrameObj, obj: { frameChangeEventArgs: null } } });
31613
31678
  break;
31614
31679
  case 'redact':
31615
31680
  parent.currObjType.isRedact = true;
@@ -31736,6 +31801,7 @@ class ToolbarModule {
31736
31801
  parent.img.destTop += (parent.cxtTbarHeight / 2);
31737
31802
  }
31738
31803
  this.callFrameToolbar();
31804
+ parent.notify('draw', { prop: 'triggerFrameChange', value: { prevFrameSettings: parent.frameObj, obj: { frameChangeEventArgs: null } } });
31739
31805
  }
31740
31806
  }
31741
31807
  zoomToFrameRange() {