@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.
@@ -1001,6 +1001,7 @@ var Draw = /** @__PURE__ @class */ (function () {
1001
1001
  this.imageBackgroundColor = '';
1002
1002
  this.allowRedactStraighten = true;
1003
1003
  this.isNullExtension = true;
1004
+ this.isRedactStraighten = false;
1004
1005
  this.parent = parent;
1005
1006
  this.addEventListener();
1006
1007
  }
@@ -1281,6 +1282,9 @@ var Draw = /** @__PURE__ @class */ (function () {
1281
1282
  case 'setNullExtension':
1282
1283
  this.isNullExtension = args.value['extension'];
1283
1284
  break;
1285
+ case 'setRedactStraighten':
1286
+ this.isRedactStraighten = args.value['bool'];
1287
+ break;
1284
1288
  }
1285
1289
  };
1286
1290
  Draw.prototype.getModuleName = function () {
@@ -1334,6 +1338,7 @@ var Draw = /** @__PURE__ @class */ (function () {
1334
1338
  this.tempStrokeWidth = null;
1335
1339
  this.straightenDestPoints = null;
1336
1340
  this.isCropSelect = this.isDownScale = this.preventStraightening = false;
1341
+ this.isRedactStraighten = false;
1337
1342
  };
1338
1343
  Draw.prototype.redrawDownScale = function () {
1339
1344
  var parent = this.parent;
@@ -6117,8 +6122,7 @@ var Draw = /** @__PURE__ @class */ (function () {
6117
6122
  var imageWidth = canvas.width;
6118
6123
  var imageHeight = canvas.height;
6119
6124
  var tempRatio = Math.min(imageWidth, imageHeight) / 1000;
6120
- var straighten = this.parent.transform.straighten !== 0 ? this.parent.transform.straighten :
6121
- this.parent.cropObj.straighten;
6125
+ var straighten = Math.round(this.parent.activeObj.rotatedAngle * (180 / Math.PI));
6122
6126
  if (this.allowRedactStraighten && straighten !== 0) {
6123
6127
  var tempCanvas = document.createElement('canvas');
6124
6128
  var tempCtx = tempCanvas.getContext('2d');
@@ -6128,9 +6132,9 @@ var Draw = /** @__PURE__ @class */ (function () {
6128
6132
  tempCtx.drawImage(canvas, 0, 0);
6129
6133
  }
6130
6134
  else {
6131
- tempCanvas.width = img.destWidth;
6132
- tempCanvas.height = img.destHeight;
6133
- tempCtx.drawImage(this.lowerContext.canvas, img.destLeft, img.destTop, img.destWidth, img.destHeight, 0, 0, img.destWidth, img.destHeight);
6135
+ tempCanvas.width = img.destWidth > canvas.width ? canvas.width : img.destWidth;
6136
+ tempCanvas.height = img.destHeight > canvas.height ? canvas.height : img.destHeight;
6137
+ 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);
6134
6138
  }
6135
6139
  var radians = -straighten * Math.PI / 180;
6136
6140
  var straightenCanvas = document.createElement('canvas');
@@ -6185,10 +6189,14 @@ var Draw = /** @__PURE__ @class */ (function () {
6185
6189
  y: sinAngle * (p2.x - center.x) + cosAngle * (p2.y - center.y) + center.y };
6186
6190
  var newP3 = { x: cosAngle * (p3.x - center.x) - sinAngle * (p3.y - center.y) + center.x,
6187
6191
  y: sinAngle * (p3.x - center.x) + cosAngle * (p3.y - center.y) + center.y };
6188
- var tempWidth = isSaveCtx ? canvasDraw.canvas.width : img.destWidth;
6189
- var tempHeight = isSaveCtx ? canvasDraw.canvas.height : img.destHeight;
6192
+ var tempWidth = isSaveCtx ? canvasDraw.canvas.width :
6193
+ (img.destWidth > canvas.width ? canvas.width : img.destWidth);
6194
+ var tempHeight = isSaveCtx ? canvasDraw.canvas.height :
6195
+ (img.destHeight > canvas.height ? canvas.height : img.destHeight);
6190
6196
  var rotatedWidth = Math.abs(tempWidth * Math.cos(radians)) + Math.abs(tempHeight * Math.sin(radians));
6191
6197
  var rotatedHeight = Math.abs(tempWidth * Math.sin(radians)) + Math.abs(tempHeight * Math.cos(radians));
6198
+ var prevWidth = straightenCanvas.width;
6199
+ var prevHeight = straightenCanvas.height;
6192
6200
  straightenCanvas.width = rotatedWidth;
6193
6201
  straightenCanvas.height = rotatedHeight;
6194
6202
  straightenCtx.save();
@@ -6199,7 +6207,13 @@ var Draw = /** @__PURE__ @class */ (function () {
6199
6207
  if (this.parent.activeObj.redactType === 'blur') {
6200
6208
  offscreenCanvas.width = width;
6201
6209
  offscreenCanvas.height = height;
6202
- 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);
6210
+ var x = newP1.x + ((rotatedWidth - prevWidth) / 2);
6211
+ var y = newP1.y + ((rotatedHeight - prevHeight) / 2);
6212
+ if (this.isRedactStraighten) {
6213
+ x = startX + ((rotatedWidth - prevWidth) / 2);
6214
+ y = startY + ((rotatedHeight - prevHeight) / 2);
6215
+ }
6216
+ offscreenCtx.drawImage(straightenCanvas, x, y, newP2.x - newP1.x, newP3.y - newP2.y, 0, 0, width, height);
6203
6217
  }
6204
6218
  else {
6205
6219
  var pixelSize = (obj.redactPixelate / 100) * 20;
@@ -6208,7 +6222,13 @@ var Draw = /** @__PURE__ @class */ (function () {
6208
6222
  }
6209
6223
  offscreenCanvas.width = Math.ceil(width / pixelSize);
6210
6224
  offscreenCanvas.height = Math.ceil(height / pixelSize);
6211
- 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);
6225
+ var x = newP1.x + ((rotatedWidth - prevWidth) / 2);
6226
+ var y = newP1.y + ((rotatedHeight - prevHeight) / 2);
6227
+ if (this.isRedactStraighten) {
6228
+ x = startX + ((rotatedWidth - prevWidth) / 2);
6229
+ y = startY + ((rotatedHeight - prevHeight) / 2);
6230
+ }
6231
+ offscreenCtx.drawImage(straightenCanvas, x, y, newP2.x - newP1.x, newP3.y - newP2.y, 0, 0, offscreenCanvas.width, offscreenCanvas.height);
6212
6232
  }
6213
6233
  }
6214
6234
  if (this.parent.activeObj.redactType === 'blur') {
@@ -12382,7 +12402,11 @@ var Selection = /** @__PURE__ @class */ (function () {
12382
12402
  parent.editCompleteArgs = shapeChangedArgs;
12383
12403
  }
12384
12404
  var isPenDraw = parent.togglePen;
12405
+ var tempCursor_1 = parent.cursor;
12385
12406
  parent.notify('toolbar', { prop: 'close-contextual-toolbar', onPropertyChange: false });
12407
+ if (activeObj.shape === 'redact' && tempCursor_1 !== 'default') {
12408
+ parent.cursor = tempCursor_1;
12409
+ }
12386
12410
  if (isPenDraw) {
12387
12411
  parent.freeHandDraw(true);
12388
12412
  }
@@ -12419,7 +12443,7 @@ var Selection = /** @__PURE__ @class */ (function () {
12419
12443
  this.dragElement = '';
12420
12444
  this.dragPoint.startX = this.dragPoint.startY = this.dragPoint.endX = this.dragPoint.endY = 0;
12421
12445
  }
12422
- if (((this.isTouch && tempCursor !== 'crosshair' || parent.cursor !== 'crosshair') &&
12446
+ if (((this.isTouch && tempCursor_1 !== 'crosshair' || parent.cursor !== 'crosshair') &&
12423
12447
  e.type.toLowerCase() === 'touchstart') ||
12424
12448
  (parent.currObjType.isActiveObj && parent.cursor !== 'default' && !parent.togglePen)) {
12425
12449
  parent.notify('draw', { prop: 'updateTempObjColl' });
@@ -15377,7 +15401,9 @@ var Shape = /** @__PURE__ @class */ (function () {
15377
15401
  parent.pointColl[shapeId].strokeColor = shapeSettings.strokeColor;
15378
15402
  parent.pointColl[shapeId].strokeWidth = shapeSettings.strokeWidth;
15379
15403
  parent.pointColl[shapeId].opacity = shapeSettings.opacity;
15380
- parent.pointColl[shapeId].order = shapeSettings.index;
15404
+ if (shapeSettings.index) {
15405
+ parent.pointColl[shapeId].order = shapeSettings.index;
15406
+ }
15381
15407
  }
15382
15408
  else {
15383
15409
  parent.activeObj.activePoint.startX = shapeSettings.startX;
@@ -15394,7 +15420,9 @@ var Shape = /** @__PURE__ @class */ (function () {
15394
15420
  }
15395
15421
  parent.activeObj.strokeSettings.fillColor = shapeSettings.fillColor;
15396
15422
  parent.activeObj.opacity = shapeSettings.opacity;
15397
- parent.activeObj.order = shapeSettings.index;
15423
+ if (shapeSettings.index) {
15424
+ parent.activeObj.order = shapeSettings.index;
15425
+ }
15398
15426
  parent.activeObj.preventShapeDragOut = !allowShapeOverflow;
15399
15427
  if (isNullOrUndefined(shapeSettings.degree)) {
15400
15428
  shapeSettings.degree = 0;
@@ -17214,16 +17242,16 @@ var Shape = /** @__PURE__ @class */ (function () {
17214
17242
  var parent = this.parent;
17215
17243
  var style = parent.textArea.style;
17216
17244
  if (style.display === 'block' || style.display === 'inline-block') {
17217
- if (style.fontWeight === 'normal' && fontWeight === 'bold') {
17245
+ if (fontWeight === 'bold') {
17218
17246
  style.fontWeight = 'bold';
17219
17247
  }
17220
- else if (style.fontWeight === 'bold' && fontWeight === 'bold') {
17248
+ else {
17221
17249
  style.fontWeight = 'normal';
17222
17250
  }
17223
- if (style.fontStyle === 'normal' && fontStyle === 'italic') {
17251
+ if (fontStyle === 'italic') {
17224
17252
  style.fontStyle = 'italic';
17225
17253
  }
17226
- else if (style.fontStyle === 'italic' && fontStyle === 'italic') {
17254
+ else {
17227
17255
  style.fontStyle = 'normal';
17228
17256
  }
17229
17257
  var value = (style.fontWeight === 'normal' && style.fontStyle === 'normal' ? 'default' :
@@ -32225,6 +32253,9 @@ var ToolbarModule = /** @__PURE__ @class */ (function () {
32225
32253
  var actionType;
32226
32254
  var actionArgs;
32227
32255
  var isRedactClick = false;
32256
+ var zoomLevel = 0;
32257
+ var actObj;
32258
+ var isRedact = false;
32228
32259
  if (parent.activeObj.shape !== undefined) {
32229
32260
  splitWords = parent.activeObj.shape.split('-');
32230
32261
  }
@@ -32474,7 +32505,36 @@ var ToolbarModule = /** @__PURE__ @class */ (function () {
32474
32505
  case 'horizontalflip':
32475
32506
  case 'verticalflip':
32476
32507
  parent.transformSelect(type);
32508
+ for (var i = 0; i < parent.objColl.length; i++) {
32509
+ if (parent.objColl[i].shape === 'redact') {
32510
+ isRedact = true;
32511
+ break;
32512
+ }
32513
+ }
32514
+ if (isRedact) {
32515
+ parent.notify('draw', { prop: 'setRedactStraighten', value: { bool: true } });
32516
+ actObj = extend({}, parent.activeObj, {}, true);
32517
+ while (parent.img.destLeft < 0 || parent.img.destTop < 0) {
32518
+ parent.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
32519
+ parent.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
32520
+ value: { zoomFactor: -.125, zoomPoint: null, isResize: false } });
32521
+ zoomLevel += 1;
32522
+ }
32523
+ }
32477
32524
  this.updateRedactObj();
32525
+ if (isRedact) {
32526
+ if (zoomLevel > 0) {
32527
+ parent.isCropTab = true;
32528
+ for (var i = 0; i < zoomLevel; i++) {
32529
+ parent.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
32530
+ parent.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
32531
+ value: { zoomFactor: .125, zoomPoint: null, isResize: false } });
32532
+ }
32533
+ parent.activeObj = actObj;
32534
+ parent.notify('draw', { prop: 'drawObject', onPropertyChange: false, value: { canvas: 'duplicate' } });
32535
+ }
32536
+ parent.notify('draw', { prop: 'setRedactStraighten', value: { bool: false } });
32537
+ }
32478
32538
  if (type === 'rotateleft' || type === 'rotateright') {
32479
32539
  parent.notify('draw', { prop: 'resetStraightenDestPoints' });
32480
32540
  parent.notify('draw', { prop: 'setDestForStraighten' });