@syncfusion/ej2-image-editor 27.2.2 → 27.2.3

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.
@@ -8805,6 +8805,7 @@ class Selection {
8805
8805
  this.isMouseDown = false;
8806
8806
  this.isMouseUp = false;
8807
8807
  this.mouseWheel = 0;
8808
+ this.isTransformedShape = false;
8808
8809
  this.parent = parent;
8809
8810
  this.addEventListener();
8810
8811
  }
@@ -9085,6 +9086,15 @@ class Selection {
9085
9086
  case 'redact':
9086
9087
  this.currentDrawingShape = args.value['shape'];
9087
9088
  break;
9089
+ case 'updateTransColl':
9090
+ args.value['obj']['coll'] = this.updateTransColl(args.value['object']);
9091
+ break;
9092
+ case 'getTransformedShape':
9093
+ args.value['obj']['bool'] = this.isTransformedShape;
9094
+ break;
9095
+ case 'setTransformedShape':
9096
+ this.isTransformedShape = args.value['bool'];
9097
+ break;
9088
9098
  }
9089
9099
  }
9090
9100
  getModuleName() {
@@ -9136,7 +9146,7 @@ class Selection {
9136
9146
  this.mouseDown = '';
9137
9147
  this.isSliderActive = false;
9138
9148
  this.arrowShape = [ArrowheadType.None, ArrowheadType.SolidArrow];
9139
- this.isMouseDown = this.isMouseUp = false;
9149
+ this.isMouseDown = this.isMouseUp = this.isTransformedShape = false;
9140
9150
  }
9141
9151
  performTabAction() {
9142
9152
  const parent = this.parent;
@@ -11754,6 +11764,16 @@ class Selection {
11754
11764
  else {
11755
11765
  degree = parent.transform.degree - parent.activeObj.shapeDegree;
11756
11766
  }
11767
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
11768
+ const coll = parent.activeObj.rotateFlipColl;
11769
+ if (this.isTransformedShape && coll) {
11770
+ degree = 0;
11771
+ for (let i = 0; i < coll.length; i++) {
11772
+ if (typeof (coll[i]) === 'number') {
11773
+ degree += (coll[i]);
11774
+ }
11775
+ }
11776
+ }
11757
11777
  if (degree < 0) {
11758
11778
  degree = 360 + degree;
11759
11779
  }
@@ -14165,8 +14185,8 @@ class Selection {
14165
14185
  id: !isNullOrUndefined(currIndex) ? currIndex : null,
14166
14186
  type: parent.toPascalCase(shape),
14167
14187
  startX: startX, startY: startY, width: width, height: height,
14168
- strokeColor: strokeSettings ? strokeSettings.strokeColor : null,
14169
- strokeWidth: strokeSettings ? strokeSettings.strokeWidth : null,
14188
+ strokeColor: strokeSettings ? (shape === 'text' ? strokeSettings.outlineColor : strokeSettings.strokeColor) : null,
14189
+ strokeWidth: strokeSettings ? (shape === 'text' ? strokeSettings.outlineWidth : strokeSettings.strokeWidth) : null,
14170
14190
  fillColor: strokeSettings ? strokeSettings.fillColor : null,
14171
14191
  radius: shape === 'ellipse' ? width / 2 : null,
14172
14192
  length: shape === 'line' || shape === 'arrow' ? width : null,
@@ -14185,13 +14205,34 @@ class Selection {
14185
14205
  arrowHead: shape === 'arrow' ? this.getArrowType(parent.activeObj.start) : null,
14186
14206
  arrowTail: shape === 'arrow' ? this.getArrowType(parent.activeObj.end) : null,
14187
14207
  points: shape === 'path' ? parent.activeObj.pointColl : null,
14188
- index: parent.activeObj.order
14208
+ index: parent.activeObj.order,
14209
+ transformCollection: shape === 'text' ? this.updateTransColl(parent.activeObj) : null
14189
14210
  };
14190
14211
  if (obj) {
14191
14212
  obj['shapeSettingsObj'] = shapeSettingsObj;
14192
14213
  }
14193
14214
  return shapeSettingsObj;
14194
14215
  }
14216
+ updateTransColl(object) {
14217
+ const parent = this.parent;
14218
+ let coll;
14219
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
14220
+ const tempColl = object.rotateFlipColl;
14221
+ if (tempColl && tempColl.length > 0) {
14222
+ let value;
14223
+ coll = [];
14224
+ for (let i = 0; i < tempColl.length; i++) {
14225
+ value = tempColl[i];
14226
+ if (typeof (value) === 'number') {
14227
+ coll.push({ degree: value });
14228
+ }
14229
+ else {
14230
+ coll.push({ flip: parent.toPascalCase(value) });
14231
+ }
14232
+ }
14233
+ }
14234
+ return coll;
14235
+ }
14195
14236
  getArrowType(type) {
14196
14237
  const typeToArrowType = { 'none': 'None', 'arrow': 'Arrow', 'arrowSolid': 'SolidArrow',
14197
14238
  'circle': 'Circle', 'circleSolid': 'SolidCircle', 'square': 'Square', 'squareSolid': 'SolidSquare', 'bar': 'Bar' };
@@ -14367,7 +14408,7 @@ class Shape {
14367
14408
  this.drawRectangle(args.value['x'], args.value['y'], args.value['width'], args.value['height'], args.value['strokeWidth'], args.value['strokeColor'], args.value['fillColor'], args.value['degree'], args.value['isSelected'], args.value['radius']);
14368
14409
  break;
14369
14410
  case 'drawText':
14370
- this.drawText(args.value['x'], args.value['y'], args.value['text'], args.value['fontFamily'], args.value['fontSize'], args.value['bold'], args.value['italic'], args.value['color'], args.value['isSelected'], args.value['degree'], args.value['fillColor'], args.value['outlineColor'], args.value['outlineWidth']);
14411
+ this.drawText(args.value['x'], args.value['y'], args.value['text'], args.value['fontFamily'], args.value['fontSize'], args.value['bold'], args.value['italic'], args.value['color'], args.value['isSelected'], args.value['degree'], args.value['fillColor'], args.value['outlineColor'], args.value['outlineWidth'], args.value['transformCollection']);
14371
14412
  break;
14372
14413
  case 'redrawActObj':
14373
14414
  this.redrawActObj(args.value['x'], args.value['y'], args.value['isMouseDown']);
@@ -14666,8 +14707,8 @@ class Shape {
14666
14707
  const start = x && y ? { x: x, y: y } : null;
14667
14708
  this.drawShape('redact', null, null, null, start, width, height, null, null, null, null, null, null, null, type, value);
14668
14709
  }
14669
- drawText(x, y, text, fontFamily, fontSize, bold, italic, color, isSelected, degree, fillColor, outlineColor, outlineWidth) {
14670
- this.drawShapeText(text, fontFamily, fontSize, bold, italic, color, x, y, isSelected, degree, fillColor, outlineColor, outlineWidth);
14710
+ drawText(x, y, text, fontFamily, fontSize, bold, italic, color, isSelected, degree, fillColor, outlineColor, outlineWidth, transformCollection) {
14711
+ this.drawShapeText(text, fontFamily, fontSize, bold, italic, color, x, y, isSelected, degree, fillColor, outlineColor, outlineWidth, transformCollection);
14671
14712
  }
14672
14713
  initializeShape(type) {
14673
14714
  const parent = this.parent;
@@ -14853,7 +14894,7 @@ class Shape {
14853
14894
  value: { obj: selPointCollObj } });
14854
14895
  this.prevObj.selPointColl = extend([], selPointCollObj['selPointColl'], [], true);
14855
14896
  }
14856
- drawShapeText(text, fontFamily, fontSize, bold, italic, strokeColor, x, y, isSelected, degree, fillColor, outlineColor, outlineWidth) {
14897
+ drawShapeText(text, fontFamily, fontSize, bold, italic, strokeColor, x, y, isSelected, degree, fillColor, outlineColor, outlineWidth, transformCollection) {
14857
14898
  const parent = this.parent;
14858
14899
  if (!parent.disabled && parent.isImageLoaded) {
14859
14900
  if (parent.currObjType.shape === 'freehanddraw') {
@@ -14885,9 +14926,20 @@ class Shape {
14885
14926
  parent.activeObj.flipObjColl = [];
14886
14927
  this.updateFontStyles();
14887
14928
  parent.activeObj.order = this.getNewOrder();
14888
- const width = this.upperContext.measureText(parent.activeObj.textSettings.text).width +
14929
+ let width = this.upperContext.measureText(parent.activeObj.textSettings.text).width +
14889
14930
  parent.activeObj.textSettings.fontSize * 0.5;
14890
- const height = parent.activeObj.textSettings.fontSize;
14931
+ let height = parent.activeObj.textSettings.fontSize;
14932
+ if (text) {
14933
+ parent.activeObj.keyHistory = text;
14934
+ let maxText = this.getMaxText();
14935
+ maxText = maxText ? maxText : parent.activeObj.textSettings.text;
14936
+ width = this.upperContext.measureText(maxText).width + parent.activeObj.textSettings.fontSize * 0.5;
14937
+ const rows = text.split('\n');
14938
+ if (rows.length > 1) {
14939
+ height = rows.length * parent.activeObj.textSettings.fontSize;
14940
+ height += (fontSize * 0.25);
14941
+ }
14942
+ }
14891
14943
  if (!isNullOrUndefined(x) && !isNullOrUndefined(y)) {
14892
14944
  parent.activeObj.activePoint.startX = x;
14893
14945
  parent.activeObj.activePoint.startY = y;
@@ -14897,6 +14949,27 @@ class Shape {
14897
14949
  else {
14898
14950
  this.setCenterPoints(true, width, height);
14899
14951
  }
14952
+ if (transformCollection) {
14953
+ parent.notify('selection', { prop: 'setTransformedShape', onPropertyChange: false, value: { bool: true } });
14954
+ this.setTransformColl(transformCollection);
14955
+ const actObj = parent.activeObj;
14956
+ actObj.shapeDegree = 0;
14957
+ actObj.shapeFlip = '';
14958
+ let tempDegree = 0;
14959
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
14960
+ const coll = actObj.rotateFlipColl;
14961
+ for (let i = 0; i < coll.length; i++) {
14962
+ if (typeof (coll[i]) === 'number') {
14963
+ tempDegree += coll[i];
14964
+ }
14965
+ }
14966
+ if (tempDegree % 90 === 0 && Math.abs(tempDegree) % 180 === 90) {
14967
+ actObj.activePoint.endX = actObj.activePoint.startX + height;
14968
+ actObj.activePoint.endY = actObj.activePoint.startY + width;
14969
+ actObj.activePoint.width = actObj.activePoint.endX - actObj.activePoint.startX;
14970
+ actObj.activePoint.height = actObj.activePoint.endY - actObj.activePoint.startY;
14971
+ }
14972
+ }
14900
14973
  const obj = { shapeSettingsObj: {} };
14901
14974
  parent.notify('selection', { prop: 'updatePrevShapeSettings', onPropertyChange: false, value: { obj: obj } });
14902
14975
  const shapeSettings = obj['shapeSettingsObj'];
@@ -14930,6 +15003,20 @@ class Shape {
14930
15003
  parent.isPublicMethod = false;
14931
15004
  }
14932
15005
  }
15006
+ setTransformColl(transformCollection) {
15007
+ const parent = this.parent;
15008
+ parent.activeObj.rotateFlipColl = [];
15009
+ if (transformCollection) {
15010
+ for (let i = 0; i < transformCollection.length; i++) {
15011
+ if (transformCollection[i].degree) {
15012
+ parent.activeObj.rotateFlipColl.push(transformCollection[i].degree);
15013
+ }
15014
+ else {
15015
+ parent.activeObj.rotateFlipColl.push(transformCollection[i].flip.toLowerCase());
15016
+ }
15017
+ }
15018
+ }
15019
+ }
14933
15020
  drawShapeImageEvent(shapeChangingArgs, isSelect) {
14934
15021
  const parent = this.parent;
14935
15022
  this.updateShapeChangeEventArgs(shapeChangingArgs.currentShapeSettings, shapeChangingArgs.allowShapeOverflow);
@@ -15122,9 +15209,11 @@ class Shape {
15122
15209
  parent.activeObj.activePoint.endX = parent.activeObj.activePoint.startX + parent.activeObj.activePoint.width;
15123
15210
  parent.activeObj.activePoint.endY = parent.activeObj.activePoint.startY + parent.activeObj.activePoint.height;
15124
15211
  }
15125
- parent.activeObj.strokeSettings.strokeColor = shapeSettings.strokeColor;
15212
+ if (parent.activeObj.shape !== 'text') {
15213
+ parent.activeObj.strokeSettings.strokeColor = shapeSettings.strokeColor;
15214
+ parent.activeObj.strokeSettings.strokeWidth = shapeSettings.strokeWidth;
15215
+ }
15126
15216
  parent.activeObj.strokeSettings.fillColor = shapeSettings.fillColor;
15127
- parent.activeObj.strokeSettings.strokeWidth = shapeSettings.strokeWidth;
15128
15217
  parent.activeObj.opacity = shapeSettings.opacity;
15129
15218
  parent.activeObj.order = shapeSettings.index;
15130
15219
  parent.activeObj.preventShapeDragOut = !allowShapeOverflow;
@@ -15157,7 +15246,11 @@ class Shape {
15157
15246
  parent.activeObj.keyHistory = parent.activeObj.textSettings.text = shapeSettings.text;
15158
15247
  parent.activeObj.textSettings.fontSize = shapeSettings.fontSize;
15159
15248
  parent.activeObj.strokeSettings.strokeColor = shapeSettings.color;
15249
+ parent.activeObj.strokeSettings.outlineColor = shapeSettings.strokeColor;
15250
+ parent.activeObj.strokeSettings.outlineWidth = shapeSettings.strokeWidth;
15251
+ parent.activeObj.strokeSettings.fillColor = shapeSettings.fillColor;
15160
15252
  parent.activeObj.textSettings.fontFamily = shapeSettings.fontFamily;
15253
+ this.setTransformColl(shapeSettings.transformCollection);
15161
15254
  if (shapeSettings.degree) {
15162
15255
  parent.activeObj.rotatedAngle = shapeSettings.degree * (Math.PI / 180);
15163
15256
  }
@@ -15932,7 +16025,8 @@ class Shape {
15932
16025
  obj.shapeFlip = parent.transform.currFlipState;
15933
16026
  }
15934
16027
  }
15935
- getRotDegOfShape(obj) {
16028
+ getRotDegOfShape(obj, value) {
16029
+ const parent = this.parent;
15936
16030
  let degree;
15937
16031
  if (obj.shapeDegree === 0) {
15938
16032
  degree = this.parent.transform.degree;
@@ -15943,6 +16037,16 @@ class Shape {
15943
16037
  if (degree < 0) {
15944
16038
  degree = 360 + degree;
15945
16039
  }
16040
+ const transformObj = { bool: false };
16041
+ parent.notify('selection', { prop: 'getTransformedShape', onPropertyChange: false, value: { obj: transformObj } });
16042
+ if (transformObj['bool'] && !value && parent.activeObj.rotateFlipColl) {
16043
+ degree = 0;
16044
+ for (let i = 0; i < parent.activeObj.rotateFlipColl.length; i++) {
16045
+ if (typeof (parent.activeObj.rotateFlipColl[i]) === 'number') {
16046
+ degree += (parent.activeObj.rotateFlipColl[i]);
16047
+ }
16048
+ }
16049
+ }
15946
16050
  return degree;
15947
16051
  }
15948
16052
  renderTextArea(x, y, actObj) {
@@ -17007,11 +17111,18 @@ class Shape {
17007
17111
  }
17008
17112
  }
17009
17113
  else if (isTextArea) {
17010
- obj.textSettings.fontRatio = width / parseFloat(parent.textArea.style.fontSize);
17114
+ const transformObj = { bool: false };
17115
+ parent.notify('selection', { prop: 'getTransformedShape', onPropertyChange: false, value: { obj: transformObj } });
17116
+ if (!transformObj['bool'] || degree === 0 || Math.abs(degree) === 180) {
17117
+ obj.textSettings.fontRatio = width / parseFloat(parent.textArea.style.fontSize);
17118
+ }
17119
+ else {
17120
+ obj.textSettings.fontRatio = height / parseFloat(parent.textArea.style.fontSize);
17121
+ }
17011
17122
  }
17012
17123
  }
17013
17124
  updateFontSize(obj) {
17014
- const degree = this.getRotDegOfShape(obj);
17125
+ const degree = this.getRotDegOfShape(obj, true);
17015
17126
  if (degree === 0 || Math.abs(degree) === 180) {
17016
17127
  obj.textSettings.fontSize = (obj.activePoint.width / obj.textSettings.fontRatio);
17017
17128
  }
@@ -17315,6 +17426,7 @@ class Shape {
17315
17426
  shapeDetails.startX = obj.activePoint.startX;
17316
17427
  shapeDetails.startY = obj.activePoint.startY;
17317
17428
  shapeDetails.index = obj.order;
17429
+ const transformObj = { coll: null };
17318
17430
  switch (obj.shape) {
17319
17431
  case 'rectangle':
17320
17432
  shapeDetails.width = obj.activePoint.width;
@@ -17353,6 +17465,9 @@ class Shape {
17353
17465
  shapeDetails.fontSize = obj.textSettings.fontSize;
17354
17466
  shapeDetails.fontFamily = obj.textSettings.fontFamily;
17355
17467
  shapeDetails.color = obj.strokeSettings.strokeColor;
17468
+ shapeDetails.strokeColor = obj.strokeSettings.outlineColor;
17469
+ shapeDetails.fillColor = obj.strokeSettings.fillColor;
17470
+ shapeDetails.strokeWidth = obj.strokeSettings.outlineWidth;
17356
17471
  shapeDetails.fontStyle = [];
17357
17472
  if (obj.textSettings.bold) {
17358
17473
  shapeDetails.fontStyle.push('bold');
@@ -17361,6 +17476,8 @@ class Shape {
17361
17476
  shapeDetails.fontStyle.push('italic');
17362
17477
  }
17363
17478
  shapeDetails.degree = obj.rotatedAngle * (180 / Math.PI);
17479
+ parent.notify('selection', { prop: 'updateTransColl', onPropertyChange: false, value: { obj: transformObj, object: obj } });
17480
+ shapeDetails.transformCollection = transformObj['coll'];
17364
17481
  break;
17365
17482
  case 'path':
17366
17483
  shapeDetails.strokeColor = obj.strokeSettings.strokeColor;
@@ -17662,6 +17779,9 @@ class Shape {
17662
17779
  getMaxText(isTextBox, text, obj) {
17663
17780
  if (isNullOrUndefined(text)) {
17664
17781
  text = isTextBox ? this.parent.textArea.value : this.parent.activeObj.keyHistory;
17782
+ if (!text) {
17783
+ return text;
17784
+ }
17665
17785
  }
17666
17786
  let maxi;
17667
17787
  const rows = text.split('\n');
@@ -22988,17 +23108,18 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends Component {
22988
23108
  * @param {fillColor} fillColor - Specifies the background Color of the text.
22989
23109
  * @param {string} strokeColor - Specifies the outline color of the text annotation.
22990
23110
  * @param {number} strokeWidth - Specifies the outline stroke width of the text annotation.
23111
+ * @param {TransformationCollection[]} transformCollection - Specifies the transform collection of the text annotation.
22991
23112
  * @returns {boolean}.
22992
23113
  *
22993
23114
  */
22994
- drawText(x, y, text, fontFamily, fontSize, bold, italic, color, isSelected, degree, fillColor, strokeColor, strokeWidth) {
23115
+ drawText(x, y, text, fontFamily, fontSize, bold, italic, color, isSelected, degree, fillColor, strokeColor, strokeWidth, transformCollection) {
22995
23116
  let isText = false;
22996
23117
  const isPointsInRange = this.allowShape(x, y);
22997
23118
  if (!this.disabled && this.isImageLoaded && (isPointsInRange || (isNullOrUndefined(x) && isNullOrUndefined(y)))) {
22998
23119
  isText = true;
22999
23120
  this.notify('shape', { prop: 'drawText', onPropertyChange: false, value: { x: x, y: y, text: text, fontFamily: fontFamily,
23000
23121
  fontSize: fontSize, bold: bold, italic: italic, color: color, isSelected: isSelected, degree: degree, fillColor: fillColor,
23001
- outlineColor: strokeColor, outlineWidth: strokeWidth } });
23122
+ outlineColor: strokeColor, outlineWidth: strokeWidth, transformCollection: transformCollection } });
23002
23123
  this.editCompleted();
23003
23124
  }
23004
23125
  return isText;
@@ -29681,6 +29802,13 @@ class ToolbarModule {
29681
29802
  parent.notify('draw', { prop: 'drawObject', onPropertyChange: false, value: { canvas: 'duplicate', obj: activeObj,
29682
29803
  isCropRatio: null, points: null, isPreventDrag: true } });
29683
29804
  }
29805
+ const panMoveObj = { panMove: null };
29806
+ parent.notify('transform', { prop: 'getPanMove', onPropertyChange: false,
29807
+ value: { obj: panMoveObj } });
29808
+ if (panMoveObj['panMove']) {
29809
+ parent.notify('transform', { prop: 'drawPannedImage', onPropertyChange: false,
29810
+ value: { xDiff: null, yDiff: null } });
29811
+ }
29684
29812
  }
29685
29813
  updateKBDNavigation(type) {
29686
29814
  const parent = this.parent;
@@ -32522,6 +32650,17 @@ class ToolbarModule {
32522
32650
  fontSizeElem.textContent = (i + 1).toString();
32523
32651
  break;
32524
32652
  }
32653
+ else {
32654
+ if (Math.round(parent.activeObj.textSettings.fontSize) < parseInt(parent.fontSizeColl[0].text, 10)) {
32655
+ fontSizeElem.textContent = '1';
32656
+ break;
32657
+ }
32658
+ else if (Math.round(parent.activeObj.textSettings.fontSize) >
32659
+ parseInt(parent.fontSizeColl[parent.fontSizeColl.length - 1].text, 10)) {
32660
+ fontSizeElem.textContent = ((parent.fontSizeColl.length - 1) + 1).toString();
32661
+ break;
32662
+ }
32663
+ }
32525
32664
  }
32526
32665
  }
32527
32666
  if (boldBtn) {