@syncfusion/ej2-image-editor 29.1.35 → 29.1.37

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.
@@ -972,6 +972,7 @@ class Draw {
972
972
  this.imageBackgroundColor = '';
973
973
  this.allowRedactStraighten = true;
974
974
  this.isNullExtension = true;
975
+ this.isRedactStraighten = false;
975
976
  this.parent = parent;
976
977
  this.addEventListener();
977
978
  }
@@ -1252,6 +1253,9 @@ class Draw {
1252
1253
  case 'setNullExtension':
1253
1254
  this.isNullExtension = args.value['extension'];
1254
1255
  break;
1256
+ case 'setRedactStraighten':
1257
+ this.isRedactStraighten = args.value['bool'];
1258
+ break;
1255
1259
  }
1256
1260
  }
1257
1261
  getModuleName() {
@@ -1305,6 +1309,7 @@ class Draw {
1305
1309
  this.tempStrokeWidth = null;
1306
1310
  this.straightenDestPoints = null;
1307
1311
  this.isCropSelect = this.isDownScale = this.preventStraightening = false;
1312
+ this.isRedactStraighten = false;
1308
1313
  }
1309
1314
  redrawDownScale() {
1310
1315
  const parent = this.parent;
@@ -6070,8 +6075,7 @@ class Draw {
6070
6075
  const imageWidth = canvas.width;
6071
6076
  const imageHeight = canvas.height;
6072
6077
  const tempRatio = Math.min(imageWidth, imageHeight) / 1000;
6073
- const straighten = this.parent.transform.straighten !== 0 ? this.parent.transform.straighten :
6074
- this.parent.cropObj.straighten;
6078
+ const straighten = Math.round(this.parent.activeObj.rotatedAngle * (180 / Math.PI));
6075
6079
  if (this.allowRedactStraighten && straighten !== 0) {
6076
6080
  const tempCanvas = document.createElement('canvas');
6077
6081
  const tempCtx = tempCanvas.getContext('2d');
@@ -6081,9 +6085,9 @@ class Draw {
6081
6085
  tempCtx.drawImage(canvas, 0, 0);
6082
6086
  }
6083
6087
  else {
6084
- tempCanvas.width = img.destWidth;
6085
- tempCanvas.height = img.destHeight;
6086
- tempCtx.drawImage(this.lowerContext.canvas, img.destLeft, img.destTop, img.destWidth, img.destHeight, 0, 0, img.destWidth, img.destHeight);
6088
+ tempCanvas.width = img.destWidth > canvas.width ? canvas.width : img.destWidth;
6089
+ tempCanvas.height = img.destHeight > canvas.height ? canvas.height : img.destHeight;
6090
+ tempCtx.drawImage(this.lowerContext.canvas, img.destLeft > 0 ? img.destLeft : 0, img.destTop > 0 ? img.destTop : 0, tempCanvas.width, tempCanvas.height, 0, 0, tempCanvas.width, tempCanvas.height);
6087
6091
  }
6088
6092
  const radians = -straighten * Math.PI / 180;
6089
6093
  const straightenCanvas = document.createElement('canvas');
@@ -6138,10 +6142,14 @@ class Draw {
6138
6142
  y: sinAngle * (p2.x - center.x) + cosAngle * (p2.y - center.y) + center.y };
6139
6143
  const newP3 = { x: cosAngle * (p3.x - center.x) - sinAngle * (p3.y - center.y) + center.x,
6140
6144
  y: sinAngle * (p3.x - center.x) + cosAngle * (p3.y - center.y) + center.y };
6141
- const tempWidth = isSaveCtx ? canvasDraw.canvas.width : img.destWidth;
6142
- const tempHeight = isSaveCtx ? canvasDraw.canvas.height : img.destHeight;
6145
+ const tempWidth = isSaveCtx ? canvasDraw.canvas.width :
6146
+ (img.destWidth > canvas.width ? canvas.width : img.destWidth);
6147
+ const tempHeight = isSaveCtx ? canvasDraw.canvas.height :
6148
+ (img.destHeight > canvas.height ? canvas.height : img.destHeight);
6143
6149
  const rotatedWidth = Math.abs(tempWidth * Math.cos(radians)) + Math.abs(tempHeight * Math.sin(radians));
6144
6150
  const rotatedHeight = Math.abs(tempWidth * Math.sin(radians)) + Math.abs(tempHeight * Math.cos(radians));
6151
+ const prevWidth = straightenCanvas.width;
6152
+ const prevHeight = straightenCanvas.height;
6145
6153
  straightenCanvas.width = rotatedWidth;
6146
6154
  straightenCanvas.height = rotatedHeight;
6147
6155
  straightenCtx.save();
@@ -6152,7 +6160,13 @@ class Draw {
6152
6160
  if (this.parent.activeObj.redactType === 'blur') {
6153
6161
  offscreenCanvas.width = width;
6154
6162
  offscreenCanvas.height = height;
6155
- offscreenCtx.drawImage(straightenCanvas, newP1.x + ((rotatedWidth - tempCanvas.width) / 2), newP1.y + ((rotatedHeight - tempCanvas.height) / 2), newP2.x - newP1.x, newP3.y - newP2.y, 0, 0, width, height);
6163
+ let x = newP1.x + ((rotatedWidth - prevWidth) / 2);
6164
+ let y = newP1.y + ((rotatedHeight - prevHeight) / 2);
6165
+ if (this.isRedactStraighten) {
6166
+ x = startX + ((rotatedWidth - prevWidth) / 2);
6167
+ y = startY + ((rotatedHeight - prevHeight) / 2);
6168
+ }
6169
+ offscreenCtx.drawImage(straightenCanvas, x, y, newP2.x - newP1.x, newP3.y - newP2.y, 0, 0, width, height);
6156
6170
  }
6157
6171
  else {
6158
6172
  let pixelSize = (obj.redactPixelate / 100) * 20;
@@ -6161,7 +6175,13 @@ class Draw {
6161
6175
  }
6162
6176
  offscreenCanvas.width = Math.ceil(width / pixelSize);
6163
6177
  offscreenCanvas.height = Math.ceil(height / pixelSize);
6164
- offscreenCtx.drawImage(straightenCanvas, newP1.x + ((rotatedWidth - tempCanvas.width) / 2), newP1.y + ((rotatedHeight - tempCanvas.height) / 2), newP2.x - newP1.x, newP3.y - newP2.y, 0, 0, offscreenCanvas.width, offscreenCanvas.height);
6178
+ let x = newP1.x + ((rotatedWidth - prevWidth) / 2);
6179
+ let y = newP1.y + ((rotatedHeight - prevHeight) / 2);
6180
+ if (this.isRedactStraighten) {
6181
+ x = startX + ((rotatedWidth - prevWidth) / 2);
6182
+ y = startY + ((rotatedHeight - prevHeight) / 2);
6183
+ }
6184
+ offscreenCtx.drawImage(straightenCanvas, x, y, newP2.x - newP1.x, newP3.y - newP2.y, 0, 0, offscreenCanvas.width, offscreenCanvas.height);
6165
6185
  }
6166
6186
  }
6167
6187
  if (this.parent.activeObj.redactType === 'blur') {
@@ -12319,7 +12339,11 @@ class Selection {
12319
12339
  parent.editCompleteArgs = shapeChangedArgs;
12320
12340
  }
12321
12341
  const isPenDraw = parent.togglePen;
12342
+ const tempCursor = parent.cursor;
12322
12343
  parent.notify('toolbar', { prop: 'close-contextual-toolbar', onPropertyChange: false });
12344
+ if (activeObj.shape === 'redact' && tempCursor !== 'default') {
12345
+ parent.cursor = tempCursor;
12346
+ }
12323
12347
  if (isPenDraw) {
12324
12348
  parent.freeHandDraw(true);
12325
12349
  }
@@ -15313,7 +15337,9 @@ class Shape {
15313
15337
  parent.pointColl[shapeId].strokeColor = shapeSettings.strokeColor;
15314
15338
  parent.pointColl[shapeId].strokeWidth = shapeSettings.strokeWidth;
15315
15339
  parent.pointColl[shapeId].opacity = shapeSettings.opacity;
15316
- parent.pointColl[shapeId].order = shapeSettings.index;
15340
+ if (shapeSettings.index) {
15341
+ parent.pointColl[shapeId].order = shapeSettings.index;
15342
+ }
15317
15343
  }
15318
15344
  else {
15319
15345
  parent.activeObj.activePoint.startX = shapeSettings.startX;
@@ -15330,7 +15356,9 @@ class Shape {
15330
15356
  }
15331
15357
  parent.activeObj.strokeSettings.fillColor = shapeSettings.fillColor;
15332
15358
  parent.activeObj.opacity = shapeSettings.opacity;
15333
- parent.activeObj.order = shapeSettings.index;
15359
+ if (shapeSettings.index) {
15360
+ parent.activeObj.order = shapeSettings.index;
15361
+ }
15334
15362
  parent.activeObj.preventShapeDragOut = !allowShapeOverflow;
15335
15363
  if (isNullOrUndefined(shapeSettings.degree)) {
15336
15364
  shapeSettings.degree = 0;
@@ -17150,16 +17178,16 @@ class Shape {
17150
17178
  const parent = this.parent;
17151
17179
  const style = parent.textArea.style;
17152
17180
  if (style.display === 'block' || style.display === 'inline-block') {
17153
- if (style.fontWeight === 'normal' && fontWeight === 'bold') {
17181
+ if (fontWeight === 'bold') {
17154
17182
  style.fontWeight = 'bold';
17155
17183
  }
17156
- else if (style.fontWeight === 'bold' && fontWeight === 'bold') {
17184
+ else {
17157
17185
  style.fontWeight = 'normal';
17158
17186
  }
17159
- if (style.fontStyle === 'normal' && fontStyle === 'italic') {
17187
+ if (fontStyle === 'italic') {
17160
17188
  style.fontStyle = 'italic';
17161
17189
  }
17162
- else if (style.fontStyle === 'italic' && fontStyle === 'italic') {
17190
+ else {
17163
17191
  style.fontStyle = 'normal';
17164
17192
  }
17165
17193
  const value = (style.fontWeight === 'normal' && style.fontStyle === 'normal' ? 'default' :
@@ -32073,6 +32101,9 @@ class ToolbarModule {
32073
32101
  let actionType;
32074
32102
  let actionArgs;
32075
32103
  let isRedactClick = false;
32104
+ let zoomLevel = 0;
32105
+ let actObj;
32106
+ let isRedact = false;
32076
32107
  if (parent.activeObj.shape !== undefined) {
32077
32108
  splitWords = parent.activeObj.shape.split('-');
32078
32109
  }
@@ -32322,7 +32353,36 @@ class ToolbarModule {
32322
32353
  case 'horizontalflip':
32323
32354
  case 'verticalflip':
32324
32355
  parent.transformSelect(type);
32356
+ for (let i = 0; i < parent.objColl.length; i++) {
32357
+ if (parent.objColl[i].shape === 'redact') {
32358
+ isRedact = true;
32359
+ break;
32360
+ }
32361
+ }
32362
+ if (isRedact) {
32363
+ parent.notify('draw', { prop: 'setRedactStraighten', value: { bool: true } });
32364
+ actObj = extend({}, parent.activeObj, {}, true);
32365
+ while (parent.img.destLeft < 0 || parent.img.destTop < 0) {
32366
+ parent.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
32367
+ parent.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
32368
+ value: { zoomFactor: -.125, zoomPoint: null, isResize: false } });
32369
+ zoomLevel += 1;
32370
+ }
32371
+ }
32325
32372
  this.updateRedactObj();
32373
+ if (isRedact) {
32374
+ if (zoomLevel > 0) {
32375
+ parent.isCropTab = true;
32376
+ for (let i = 0; i < zoomLevel; i++) {
32377
+ parent.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
32378
+ parent.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
32379
+ value: { zoomFactor: .125, zoomPoint: null, isResize: false } });
32380
+ }
32381
+ parent.activeObj = actObj;
32382
+ parent.notify('draw', { prop: 'drawObject', onPropertyChange: false, value: { canvas: 'duplicate' } });
32383
+ }
32384
+ parent.notify('draw', { prop: 'setRedactStraighten', value: { bool: false } });
32385
+ }
32326
32386
  if (type === 'rotateleft' || type === 'rotateright') {
32327
32387
  parent.notify('draw', { prop: 'resetStraightenDestPoints' });
32328
32388
  parent.notify('draw', { prop: 'setDestForStraighten' });