@syncfusion/ej2-image-editor 27.1.51 → 27.1.53

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.
@@ -2284,8 +2284,13 @@ class Draw {
2284
2284
  const baseRadius = isTempCanvas ? radius * 10 * ((ratio.width + ratio.height) / 2) : radius * 10;
2285
2285
  const adjustedRadius = baseRadius + (baseRadius * zoomFactor);
2286
2286
  if (radius !== null) {
2287
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
2288
- canvasDraw.roundRect(startX, startY, width, height, adjustedRadius);
2287
+ if (parent.isSafari) {
2288
+ this.drawRoundedRect(canvasDraw, startX, startY, width, height, adjustedRadius);
2289
+ }
2290
+ else {
2291
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2292
+ canvasDraw.roundRect(startX, startY, width, height, adjustedRadius);
2293
+ }
2289
2294
  }
2290
2295
  else {
2291
2296
  canvasDraw.rect(startX, startY, width, height);
@@ -2295,8 +2300,13 @@ class Draw {
2295
2300
  canvasDraw.fill();
2296
2301
  }
2297
2302
  if (radius !== null) {
2298
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
2299
- canvasDraw.roundRect(startX + strokeWidth, startY + strokeWidth, width - (2 * strokeWidth), height - (2 * strokeWidth), adjustedRadius);
2303
+ if (parent.isSafari) {
2304
+ this.drawRoundedRect(canvasDraw, startX + strokeWidth, startY + strokeWidth, width - (2 * strokeWidth), height - (2 * strokeWidth), adjustedRadius);
2305
+ }
2306
+ else {
2307
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2308
+ canvasDraw.roundRect(startX + strokeWidth, startY + strokeWidth, width - (2 * strokeWidth), height - (2 * strokeWidth), adjustedRadius);
2309
+ }
2300
2310
  }
2301
2311
  else {
2302
2312
  canvasDraw.rect(startX + strokeWidth, startY + strokeWidth, width - (2 * strokeWidth), height - (2 * strokeWidth));
@@ -2305,6 +2315,15 @@ class Draw {
2305
2315
  canvasDraw.fill('evenodd');
2306
2316
  canvasDraw.closePath();
2307
2317
  }
2318
+ drawRoundedRect(canvasDraw, startX, startY, width, height, radius) {
2319
+ const rectRadius = Math.max(0, Math.min(radius, width / 2, height / 2));
2320
+ canvasDraw.moveTo(startX + rectRadius, startY);
2321
+ canvasDraw.arcTo(startX + width, startY, startX + width, startY + height, rectRadius);
2322
+ canvasDraw.arcTo(startX + width, startY + height, startY, startY + height, rectRadius);
2323
+ canvasDraw.arcTo(startX, startY + height, startX, startY, rectRadius);
2324
+ canvasDraw.arcTo(startX, startY, startX + width, startY, rectRadius);
2325
+ canvasDraw.closePath();
2326
+ }
2308
2327
  drawSelection(horLineWidth, verLineHeight) {
2309
2328
  const parent = this.parent;
2310
2329
  const actObj = parent.activeObj;
@@ -3004,12 +3023,7 @@ class Draw {
3004
3023
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
3005
3024
  let coll = actObj.rotateFlipColl[i];
3006
3025
  if (typeof (coll) === 'number') {
3007
- if (actObj.shapeDegree === 0) {
3008
- tempDegree = coll;
3009
- }
3010
- else {
3011
- tempDegree = coll - actObj.shapeDegree;
3012
- }
3026
+ tempDegree = coll;
3013
3027
  if (tempDegree === -450) {
3014
3028
  tempDegree = -90;
3015
3029
  }
@@ -3107,12 +3121,7 @@ class Draw {
3107
3121
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
3108
3122
  let coll = actObj.rotateFlipColl[i];
3109
3123
  if (typeof (coll) === 'number') {
3110
- if (actObj.shapeDegree === 0) {
3111
- tempDegree = coll;
3112
- }
3113
- else {
3114
- tempDegree = coll - actObj.shapeDegree;
3115
- }
3124
+ tempDegree = coll;
3116
3125
  if (tempDegree === -450) {
3117
3126
  tempDegree = -90;
3118
3127
  }
@@ -6042,10 +6051,21 @@ class Draw {
6042
6051
  y: sinAngle * (p2.x - center.x) + cosAngle * (p2.y - center.y) + center.y };
6043
6052
  const newP3 = { x: cosAngle * (p3.x - center.x) - sinAngle * (p3.y - center.y) + center.x,
6044
6053
  y: sinAngle * (p3.x - center.x) + cosAngle * (p3.y - center.y) + center.y };
6054
+ const tempWidth = isSaveCtx ? canvasDraw.canvas.width : img.destWidth;
6055
+ const tempHeight = isSaveCtx ? canvasDraw.canvas.height : img.destHeight;
6056
+ const rotatedWidth = Math.abs(tempWidth * Math.cos(radians)) + Math.abs(tempHeight * Math.sin(radians));
6057
+ const rotatedHeight = Math.abs(tempWidth * Math.sin(radians)) + Math.abs(tempHeight * Math.cos(radians));
6058
+ straightenCanvas.width = rotatedWidth;
6059
+ straightenCanvas.height = rotatedHeight;
6060
+ straightenCtx.save();
6061
+ straightenCtx.translate(rotatedWidth / 2, rotatedHeight / 2);
6062
+ straightenCtx.rotate(radians);
6063
+ straightenCtx.drawImage(tempCanvas, -tempCanvas.width / 2, -tempCanvas.height / 2);
6064
+ straightenCtx.restore();
6045
6065
  if (this.parent.activeObj.redactType === 'blur') {
6046
6066
  offscreenCanvas.width = width;
6047
6067
  offscreenCanvas.height = height;
6048
- offscreenCtx.drawImage(straightenCanvas, newP1.x, newP1.y, newP2.x - newP1.x, newP3.y - newP2.y, 0, 0, width, height);
6068
+ 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);
6049
6069
  }
6050
6070
  else {
6051
6071
  let pixelSize = (obj.redactPixelate / 100) * 20;
@@ -6054,7 +6074,7 @@ class Draw {
6054
6074
  }
6055
6075
  offscreenCanvas.width = Math.ceil(width / pixelSize);
6056
6076
  offscreenCanvas.height = Math.ceil(height / pixelSize);
6057
- offscreenCtx.drawImage(straightenCanvas, newP1.x, newP1.y, newP2.x - newP1.x, newP3.y - newP2.y, 0, 0, offscreenCanvas.width, offscreenCanvas.height);
6077
+ 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);
6058
6078
  }
6059
6079
  }
6060
6080
  if (this.parent.activeObj.redactType === 'blur') {
@@ -7300,7 +7320,7 @@ class Filter {
7300
7320
  parseFilterString(filterString) {
7301
7321
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
7302
7322
  let filterArray = [];
7303
- if (filterString !== 'none') {
7323
+ if (filterString && filterString !== 'none') {
7304
7324
  filterArray = filterString.split(' ').map((filter) => {
7305
7325
  const [name, value] = filter.match(/([a-z-]+)\(([^)]+)\)/).slice(1, 3);
7306
7326
  return { filter: name, value: value };
@@ -12006,6 +12026,7 @@ class Selection {
12006
12026
  this.triggerShapeChange(shapeResizingArgs, shapeMovingArgs, 'mouse-down');
12007
12027
  parent.activeObj.activePoint = activePoint;
12008
12028
  parent.isShapeDrawing = true;
12029
+ this.tempActiveObj = extend({}, parent.activeObj, {}, true);
12009
12030
  return;
12010
12031
  }
12011
12032
  parent.notify('draw', { prop: 'resetFrameZoom', onPropertyChange: false, value: { isOk: true } });
@@ -14658,7 +14679,8 @@ class Shape {
14658
14679
  }
14659
14680
  setDimension(width, height) {
14660
14681
  const parent = this.parent;
14661
- if (width && height) {
14682
+ const shape = parent.activeObj.shape;
14683
+ if ((width && height) || ((shape === 'line' || shape === 'arrow') && (width || height))) {
14662
14684
  parent.activeObj.activePoint.width = width;
14663
14685
  parent.activeObj.activePoint.height = height;
14664
14686
  if (parent.currObjType.shape.toLowerCase() === 'ellipse') {
@@ -14706,7 +14728,7 @@ class Shape {
14706
14728
  strokeSettings.strokeWidth = 0;
14707
14729
  }
14708
14730
  strokeSettings.strokeColor = strokeColor ? strokeColor : strokeSettings.strokeColor;
14709
- strokeSettings.fillColor = fillColor ? fillColor : strokeSettings.fillColor;
14731
+ strokeSettings.fillColor = fillColor || fillColor === '' ? fillColor : strokeSettings.fillColor;
14710
14732
  strokeSettings.radius = radius ? radius : strokeSettings.radius;
14711
14733
  const tempWidth = parent.img.destWidth > 100 ? 100 : parent.img.destWidth / 2;
14712
14734
  const tempHeight = parent.img.destHeight > 100 ? 100 : parent.img.destHeight / 2;
@@ -22166,7 +22188,9 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends Component {
22166
22188
  this.notify('toolbar', { prop: 'getLocaleText', onPropertyChange: false, value: { obj: contentObj } });
22167
22189
  const supportObj = { key: 'SupportText' };
22168
22190
  this.notify('toolbar', { prop: 'getLocaleText', onPropertyChange: false, value: { obj: supportObj } });
22169
- content = '<span>' + contentObj['value'] + ' ' + supportObj['value'] + '<b> JPG, PNG, and SVG</b></span>';
22191
+ const andObj = { key: 'And' };
22192
+ this.notify('toolbar', { prop: 'getLocaleText', onPropertyChange: false, value: { obj: andObj } });
22193
+ content = '<span>' + contentObj['value'] + ' ' + supportObj['value'] + '<b> JPG, PNG, ' + andObj['value'] + ' SVG</b></span>';
22170
22194
  }
22171
22195
  const dialog = new Dialog({
22172
22196
  header: headerObj['value'],
@@ -27912,7 +27936,7 @@ class ToolbarModule {
27912
27936
  qualityOptionDiv.appendChild(parent.createElement('button', { id: id + '_qualitybuttonIcon', className: 'e-ie-img-icon-button', attrs: { type: 'button' } }));
27913
27937
  qualityNameDiv.appendChild(qualityOptionDiv);
27914
27938
  if (Browser.isDevice) {
27915
- qualityNameDiv.appendChild(parent.createElement('span', {
27939
+ dialogRightContent.appendChild(parent.createElement('span', {
27916
27940
  id: id + '_qualitySize', className: 'e-ie-img-quality-size'
27917
27941
  }));
27918
27942
  }
@@ -28170,39 +28194,11 @@ class ToolbarModule {
28170
28194
  }).bind(this), 'image/jpeg', quality);
28171
28195
  }
28172
28196
  else if (!isNullOrUndefined(fileType) && fileType.toLowerCase() === 'png') {
28173
- if (Browser.isDevice) {
28174
- canvas.style.display = 'none';
28175
- }
28176
- else {
28177
- ctx.drawImage(tempCanvas, 0, 0);
28178
- tempCanvas.toBlob((function (blob) {
28179
- fileSize = Math.floor(blob.size / 1024);
28180
- if (fileSize > 1000) {
28181
- const megabytes = fileSize / 1024;
28182
- imageNameLabel.innerHTML = this.l10n.getConstant('ImageSize') + ': ' + megabytes.toFixed(2) + ' MB';
28183
- fileSize = +megabytes.toFixed(2);
28184
- }
28185
- else {
28186
- imageNameLabel.innerHTML = this.l10n.getConstant('ImageSize') + ': ' + fileSize.toFixed(2) + ' KB';
28187
- fileSize = +fileSize.toFixed(2);
28188
- }
28189
- this.fileSize = fileSize;
28190
- }).bind(this), 'image/png', 1);
28191
- }
28192
- }
28193
- else if (!isNullOrUndefined(fileType) && fileType.toLowerCase() === 'svg') {
28194
- if (Browser.isDevice) {
28195
- canvas.style.display = 'none';
28196
- }
28197
- else {
28198
- ctx.drawImage(tempCanvas, 0, 0);
28199
- const svgDataUrl = tempCanvas.toDataURL('image/svg+xml');
28200
- const base64Data = svgDataUrl.split(',')[1];
28201
- const binaryStringLength = base64Data.length;
28202
- const rawByteSize = binaryStringLength;
28203
- let fileSize = Math.floor(rawByteSize / 1024); // KB
28197
+ ctx.drawImage(tempCanvas, 0, 0);
28198
+ tempCanvas.toBlob((function (blob) {
28199
+ fileSize = Math.floor(blob.size / 1024);
28204
28200
  if (fileSize > 1000) {
28205
- const megabytes = fileSize / 1024; // Convert to MB
28201
+ const megabytes = fileSize / 1024;
28206
28202
  imageNameLabel.innerHTML = this.l10n.getConstant('ImageSize') + ': ' + megabytes.toFixed(2) + ' MB';
28207
28203
  fileSize = +megabytes.toFixed(2);
28208
28204
  }
@@ -28210,6 +28206,30 @@ class ToolbarModule {
28210
28206
  imageNameLabel.innerHTML = this.l10n.getConstant('ImageSize') + ': ' + fileSize.toFixed(2) + ' KB';
28211
28207
  fileSize = +fileSize.toFixed(2);
28212
28208
  }
28209
+ if (Browser.isDevice) {
28210
+ canvas.style.display = 'none';
28211
+ }
28212
+ this.fileSize = fileSize;
28213
+ }).bind(this), 'image/png', 1);
28214
+ }
28215
+ else if (!isNullOrUndefined(fileType) && fileType.toLowerCase() === 'svg') {
28216
+ ctx.drawImage(tempCanvas, 0, 0);
28217
+ const svgDataUrl = tempCanvas.toDataURL('image/svg+xml');
28218
+ const base64Data = svgDataUrl.split(',')[1];
28219
+ const binaryStringLength = base64Data.length;
28220
+ const rawByteSize = binaryStringLength;
28221
+ let fileSize = Math.floor(rawByteSize / 1024); // KB
28222
+ if (fileSize > 1000) {
28223
+ const megabytes = fileSize / 1024; // Convert to MB
28224
+ imageNameLabel.innerHTML = this.l10n.getConstant('ImageSize') + ': ' + megabytes.toFixed(2) + ' MB';
28225
+ fileSize = +megabytes.toFixed(2);
28226
+ }
28227
+ else {
28228
+ imageNameLabel.innerHTML = this.l10n.getConstant('ImageSize') + ': ' + fileSize.toFixed(2) + ' KB';
28229
+ fileSize = +fileSize.toFixed(2);
28230
+ }
28231
+ if (Browser.isDevice) {
28232
+ canvas.style.display = 'none';
28213
28233
  }
28214
28234
  this.fileSize = fileSize;
28215
28235
  }