@syncfusion/ej2-image-editor 29.1.35 → 29.1.38

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') {
@@ -10466,18 +10486,22 @@ var Selection = /** @__PURE__ @class */ (function () {
10466
10486
  var endY = isStart ? actPoint.endY : actPoint.startY;
10467
10487
  var wrapperWidth = parent.upperCanvas.width;
10468
10488
  var wrapperHeight = parent.upperCanvas.height;
10489
+ var minX = destLeft < 0 ? 0 : destLeft;
10490
+ var minY = destTop < 0 ? 0 : destTop;
10491
+ var maxX = destLeft + destWidth > wrapperWidth ? wrapperWidth : destLeft + destWidth;
10492
+ var maxY = destTop + destHeight > wrapperHeight ? wrapperHeight : destTop + destHeight;
10469
10493
  if (Browser.isDevice) {
10470
- if (startX < 0 && destLeft < 0) {
10471
- startX = 0;
10494
+ if (startX < minX) {
10495
+ startX = minX;
10472
10496
  }
10473
- if (startY < 0 && destTop < 0) {
10474
- startY = 0;
10497
+ if (startY < minY) {
10498
+ startY = minY;
10475
10499
  }
10476
- if (endX > wrapperWidth && destLeft + destWidth > wrapperWidth) {
10477
- endX = wrapperWidth;
10500
+ if (endX > maxX) {
10501
+ endX = maxX;
10478
10502
  }
10479
- if (endY > wrapperHeight && destTop + destHeight > wrapperHeight) {
10480
- endY = wrapperHeight;
10503
+ if (endY > maxY) {
10504
+ endY = maxY;
10481
10505
  }
10482
10506
  }
10483
10507
  else {
@@ -12382,7 +12406,11 @@ var Selection = /** @__PURE__ @class */ (function () {
12382
12406
  parent.editCompleteArgs = shapeChangedArgs;
12383
12407
  }
12384
12408
  var isPenDraw = parent.togglePen;
12409
+ var tempCursor_1 = parent.cursor;
12385
12410
  parent.notify('toolbar', { prop: 'close-contextual-toolbar', onPropertyChange: false });
12411
+ if (activeObj.shape === 'redact' && tempCursor_1 !== 'default') {
12412
+ parent.cursor = tempCursor_1;
12413
+ }
12386
12414
  if (isPenDraw) {
12387
12415
  parent.freeHandDraw(true);
12388
12416
  }
@@ -12419,7 +12447,7 @@ var Selection = /** @__PURE__ @class */ (function () {
12419
12447
  this.dragElement = '';
12420
12448
  this.dragPoint.startX = this.dragPoint.startY = this.dragPoint.endX = this.dragPoint.endY = 0;
12421
12449
  }
12422
- if (((this.isTouch && tempCursor !== 'crosshair' || parent.cursor !== 'crosshair') &&
12450
+ if (((this.isTouch && tempCursor_1 !== 'crosshair' || parent.cursor !== 'crosshair') &&
12423
12451
  e.type.toLowerCase() === 'touchstart') ||
12424
12452
  (parent.currObjType.isActiveObj && parent.cursor !== 'default' && !parent.togglePen)) {
12425
12453
  parent.notify('draw', { prop: 'updateTempObjColl' });
@@ -15377,7 +15405,9 @@ var Shape = /** @__PURE__ @class */ (function () {
15377
15405
  parent.pointColl[shapeId].strokeColor = shapeSettings.strokeColor;
15378
15406
  parent.pointColl[shapeId].strokeWidth = shapeSettings.strokeWidth;
15379
15407
  parent.pointColl[shapeId].opacity = shapeSettings.opacity;
15380
- parent.pointColl[shapeId].order = shapeSettings.index;
15408
+ if (shapeSettings.index) {
15409
+ parent.pointColl[shapeId].order = shapeSettings.index;
15410
+ }
15381
15411
  }
15382
15412
  else {
15383
15413
  parent.activeObj.activePoint.startX = shapeSettings.startX;
@@ -15394,7 +15424,9 @@ var Shape = /** @__PURE__ @class */ (function () {
15394
15424
  }
15395
15425
  parent.activeObj.strokeSettings.fillColor = shapeSettings.fillColor;
15396
15426
  parent.activeObj.opacity = shapeSettings.opacity;
15397
- parent.activeObj.order = shapeSettings.index;
15427
+ if (shapeSettings.index) {
15428
+ parent.activeObj.order = shapeSettings.index;
15429
+ }
15398
15430
  parent.activeObj.preventShapeDragOut = !allowShapeOverflow;
15399
15431
  if (isNullOrUndefined(shapeSettings.degree)) {
15400
15432
  shapeSettings.degree = 0;
@@ -17214,16 +17246,16 @@ var Shape = /** @__PURE__ @class */ (function () {
17214
17246
  var parent = this.parent;
17215
17247
  var style = parent.textArea.style;
17216
17248
  if (style.display === 'block' || style.display === 'inline-block') {
17217
- if (style.fontWeight === 'normal' && fontWeight === 'bold') {
17249
+ if (fontWeight === 'bold') {
17218
17250
  style.fontWeight = 'bold';
17219
17251
  }
17220
- else if (style.fontWeight === 'bold' && fontWeight === 'bold') {
17252
+ else {
17221
17253
  style.fontWeight = 'normal';
17222
17254
  }
17223
- if (style.fontStyle === 'normal' && fontStyle === 'italic') {
17255
+ if (fontStyle === 'italic') {
17224
17256
  style.fontStyle = 'italic';
17225
17257
  }
17226
- else if (style.fontStyle === 'italic' && fontStyle === 'italic') {
17258
+ else {
17227
17259
  style.fontStyle = 'normal';
17228
17260
  }
17229
17261
  var value = (style.fontWeight === 'normal' && style.fontStyle === 'normal' ? 'default' :
@@ -32225,6 +32257,9 @@ var ToolbarModule = /** @__PURE__ @class */ (function () {
32225
32257
  var actionType;
32226
32258
  var actionArgs;
32227
32259
  var isRedactClick = false;
32260
+ var zoomLevel = 0;
32261
+ var actObj;
32262
+ var isRedact = false;
32228
32263
  if (parent.activeObj.shape !== undefined) {
32229
32264
  splitWords = parent.activeObj.shape.split('-');
32230
32265
  }
@@ -32474,7 +32509,36 @@ var ToolbarModule = /** @__PURE__ @class */ (function () {
32474
32509
  case 'horizontalflip':
32475
32510
  case 'verticalflip':
32476
32511
  parent.transformSelect(type);
32512
+ for (var i = 0; i < parent.objColl.length; i++) {
32513
+ if (parent.objColl[i].shape === 'redact') {
32514
+ isRedact = true;
32515
+ break;
32516
+ }
32517
+ }
32518
+ if (isRedact) {
32519
+ parent.notify('draw', { prop: 'setRedactStraighten', value: { bool: true } });
32520
+ actObj = extend({}, parent.activeObj, {}, true);
32521
+ while (parent.img.destLeft < 0 || parent.img.destTop < 0) {
32522
+ parent.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
32523
+ parent.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
32524
+ value: { zoomFactor: -.125, zoomPoint: null, isResize: false } });
32525
+ zoomLevel += 1;
32526
+ }
32527
+ }
32477
32528
  this.updateRedactObj();
32529
+ if (isRedact) {
32530
+ if (zoomLevel > 0) {
32531
+ parent.isCropTab = true;
32532
+ for (var i = 0; i < zoomLevel; i++) {
32533
+ parent.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
32534
+ parent.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
32535
+ value: { zoomFactor: .125, zoomPoint: null, isResize: false } });
32536
+ }
32537
+ parent.activeObj = actObj;
32538
+ parent.notify('draw', { prop: 'drawObject', onPropertyChange: false, value: { canvas: 'duplicate' } });
32539
+ }
32540
+ parent.notify('draw', { prop: 'setRedactStraighten', value: { bool: false } });
32541
+ }
32478
32542
  if (type === 'rotateleft' || type === 'rotateright') {
32479
32543
  parent.notify('draw', { prop: 'resetStraightenDestPoints' });
32480
32544
  parent.notify('draw', { prop: 'setDestForStraighten' });