@syncfusion/ej2-image-editor 27.1.58 → 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.
@@ -8865,6 +8865,7 @@ var Selection = /** @__PURE__ @class */ (function () {
8865
8865
  this.isMouseDown = false;
8866
8866
  this.isMouseUp = false;
8867
8867
  this.mouseWheel = 0;
8868
+ this.isTransformedShape = false;
8868
8869
  this.parent = parent;
8869
8870
  this.addEventListener();
8870
8871
  }
@@ -9145,6 +9146,15 @@ var Selection = /** @__PURE__ @class */ (function () {
9145
9146
  case 'redact':
9146
9147
  this.currentDrawingShape = args.value['shape'];
9147
9148
  break;
9149
+ case 'updateTransColl':
9150
+ args.value['obj']['coll'] = this.updateTransColl(args.value['object']);
9151
+ break;
9152
+ case 'getTransformedShape':
9153
+ args.value['obj']['bool'] = this.isTransformedShape;
9154
+ break;
9155
+ case 'setTransformedShape':
9156
+ this.isTransformedShape = args.value['bool'];
9157
+ break;
9148
9158
  }
9149
9159
  };
9150
9160
  Selection.prototype.getModuleName = function () {
@@ -9196,7 +9206,7 @@ var Selection = /** @__PURE__ @class */ (function () {
9196
9206
  this.mouseDown = '';
9197
9207
  this.isSliderActive = false;
9198
9208
  this.arrowShape = [ArrowheadType.None, ArrowheadType.SolidArrow];
9199
- this.isMouseDown = this.isMouseUp = false;
9209
+ this.isMouseDown = this.isMouseUp = this.isTransformedShape = false;
9200
9210
  };
9201
9211
  Selection.prototype.performTabAction = function () {
9202
9212
  var parent = this.parent;
@@ -11816,6 +11826,16 @@ var Selection = /** @__PURE__ @class */ (function () {
11816
11826
  else {
11817
11827
  degree = parent.transform.degree - parent.activeObj.shapeDegree;
11818
11828
  }
11829
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
11830
+ var coll = parent.activeObj.rotateFlipColl;
11831
+ if (this.isTransformedShape && coll) {
11832
+ degree = 0;
11833
+ for (var i = 0; i < coll.length; i++) {
11834
+ if (typeof (coll[i]) === 'number') {
11835
+ degree += (coll[i]);
11836
+ }
11837
+ }
11838
+ }
11819
11839
  if (degree < 0) {
11820
11840
  degree = 360 + degree;
11821
11841
  }
@@ -14227,8 +14247,8 @@ var Selection = /** @__PURE__ @class */ (function () {
14227
14247
  id: !isNullOrUndefined(currIndex) ? currIndex : null,
14228
14248
  type: parent.toPascalCase(shape),
14229
14249
  startX: startX, startY: startY, width: width, height: height,
14230
- strokeColor: strokeSettings ? strokeSettings.strokeColor : null,
14231
- strokeWidth: strokeSettings ? strokeSettings.strokeWidth : null,
14250
+ strokeColor: strokeSettings ? (shape === 'text' ? strokeSettings.outlineColor : strokeSettings.strokeColor) : null,
14251
+ strokeWidth: strokeSettings ? (shape === 'text' ? strokeSettings.outlineWidth : strokeSettings.strokeWidth) : null,
14232
14252
  fillColor: strokeSettings ? strokeSettings.fillColor : null,
14233
14253
  radius: shape === 'ellipse' ? width / 2 : null,
14234
14254
  length: shape === 'line' || shape === 'arrow' ? width : null,
@@ -14247,13 +14267,34 @@ var Selection = /** @__PURE__ @class */ (function () {
14247
14267
  arrowHead: shape === 'arrow' ? this.getArrowType(parent.activeObj.start) : null,
14248
14268
  arrowTail: shape === 'arrow' ? this.getArrowType(parent.activeObj.end) : null,
14249
14269
  points: shape === 'path' ? parent.activeObj.pointColl : null,
14250
- index: parent.activeObj.order
14270
+ index: parent.activeObj.order,
14271
+ transformCollection: shape === 'text' ? this.updateTransColl(parent.activeObj) : null
14251
14272
  };
14252
14273
  if (obj) {
14253
14274
  obj['shapeSettingsObj'] = shapeSettingsObj;
14254
14275
  }
14255
14276
  return shapeSettingsObj;
14256
14277
  };
14278
+ Selection.prototype.updateTransColl = function (object) {
14279
+ var parent = this.parent;
14280
+ var coll;
14281
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
14282
+ var tempColl = object.rotateFlipColl;
14283
+ if (tempColl && tempColl.length > 0) {
14284
+ var value = void 0;
14285
+ coll = [];
14286
+ for (var i = 0; i < tempColl.length; i++) {
14287
+ value = tempColl[i];
14288
+ if (typeof (value) === 'number') {
14289
+ coll.push({ degree: value });
14290
+ }
14291
+ else {
14292
+ coll.push({ flip: parent.toPascalCase(value) });
14293
+ }
14294
+ }
14295
+ }
14296
+ return coll;
14297
+ };
14257
14298
  Selection.prototype.getArrowType = function (type) {
14258
14299
  var typeToArrowType = { 'none': 'None', 'arrow': 'Arrow', 'arrowSolid': 'SolidArrow',
14259
14300
  'circle': 'Circle', 'circleSolid': 'SolidCircle', 'square': 'Square', 'squareSolid': 'SolidSquare', 'bar': 'Bar' };
@@ -14430,7 +14471,7 @@ var Shape = /** @__PURE__ @class */ (function () {
14430
14471
  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']);
14431
14472
  break;
14432
14473
  case 'drawText':
14433
- 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']);
14474
+ 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']);
14434
14475
  break;
14435
14476
  case 'redrawActObj':
14436
14477
  this.redrawActObj(args.value['x'], args.value['y'], args.value['isMouseDown']);
@@ -14729,8 +14770,8 @@ var Shape = /** @__PURE__ @class */ (function () {
14729
14770
  var start = x && y ? { x: x, y: y } : null;
14730
14771
  this.drawShape('redact', null, null, null, start, width, height, null, null, null, null, null, null, null, type, value);
14731
14772
  };
14732
- Shape.prototype.drawText = function (x, y, text, fontFamily, fontSize, bold, italic, color, isSelected, degree, fillColor, outlineColor, outlineWidth) {
14733
- this.drawShapeText(text, fontFamily, fontSize, bold, italic, color, x, y, isSelected, degree, fillColor, outlineColor, outlineWidth);
14773
+ Shape.prototype.drawText = function (x, y, text, fontFamily, fontSize, bold, italic, color, isSelected, degree, fillColor, outlineColor, outlineWidth, transformCollection) {
14774
+ this.drawShapeText(text, fontFamily, fontSize, bold, italic, color, x, y, isSelected, degree, fillColor, outlineColor, outlineWidth, transformCollection);
14734
14775
  };
14735
14776
  Shape.prototype.initializeShape = function (type) {
14736
14777
  var parent = this.parent;
@@ -14916,7 +14957,7 @@ var Shape = /** @__PURE__ @class */ (function () {
14916
14957
  value: { obj: selPointCollObj } });
14917
14958
  this.prevObj.selPointColl = extend([], selPointCollObj['selPointColl'], [], true);
14918
14959
  };
14919
- Shape.prototype.drawShapeText = function (text, fontFamily, fontSize, bold, italic, strokeColor, x, y, isSelected, degree, fillColor, outlineColor, outlineWidth) {
14960
+ Shape.prototype.drawShapeText = function (text, fontFamily, fontSize, bold, italic, strokeColor, x, y, isSelected, degree, fillColor, outlineColor, outlineWidth, transformCollection) {
14920
14961
  var parent = this.parent;
14921
14962
  if (!parent.disabled && parent.isImageLoaded) {
14922
14963
  if (parent.currObjType.shape === 'freehanddraw') {
@@ -14951,6 +14992,17 @@ var Shape = /** @__PURE__ @class */ (function () {
14951
14992
  var width = this.upperContext.measureText(parent.activeObj.textSettings.text).width +
14952
14993
  parent.activeObj.textSettings.fontSize * 0.5;
14953
14994
  var height = parent.activeObj.textSettings.fontSize;
14995
+ if (text) {
14996
+ parent.activeObj.keyHistory = text;
14997
+ var maxText = this.getMaxText();
14998
+ maxText = maxText ? maxText : parent.activeObj.textSettings.text;
14999
+ width = this.upperContext.measureText(maxText).width + parent.activeObj.textSettings.fontSize * 0.5;
15000
+ var rows = text.split('\n');
15001
+ if (rows.length > 1) {
15002
+ height = rows.length * parent.activeObj.textSettings.fontSize;
15003
+ height += (fontSize * 0.25);
15004
+ }
15005
+ }
14954
15006
  if (!isNullOrUndefined(x) && !isNullOrUndefined(y)) {
14955
15007
  parent.activeObj.activePoint.startX = x;
14956
15008
  parent.activeObj.activePoint.startY = y;
@@ -14960,6 +15012,27 @@ var Shape = /** @__PURE__ @class */ (function () {
14960
15012
  else {
14961
15013
  this.setCenterPoints(true, width, height);
14962
15014
  }
15015
+ if (transformCollection) {
15016
+ parent.notify('selection', { prop: 'setTransformedShape', onPropertyChange: false, value: { bool: true } });
15017
+ this.setTransformColl(transformCollection);
15018
+ var actObj = parent.activeObj;
15019
+ actObj.shapeDegree = 0;
15020
+ actObj.shapeFlip = '';
15021
+ var tempDegree = 0;
15022
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
15023
+ var coll = actObj.rotateFlipColl;
15024
+ for (var i = 0; i < coll.length; i++) {
15025
+ if (typeof (coll[i]) === 'number') {
15026
+ tempDegree += coll[i];
15027
+ }
15028
+ }
15029
+ if (tempDegree % 90 === 0 && Math.abs(tempDegree) % 180 === 90) {
15030
+ actObj.activePoint.endX = actObj.activePoint.startX + height;
15031
+ actObj.activePoint.endY = actObj.activePoint.startY + width;
15032
+ actObj.activePoint.width = actObj.activePoint.endX - actObj.activePoint.startX;
15033
+ actObj.activePoint.height = actObj.activePoint.endY - actObj.activePoint.startY;
15034
+ }
15035
+ }
14963
15036
  var obj = { shapeSettingsObj: {} };
14964
15037
  parent.notify('selection', { prop: 'updatePrevShapeSettings', onPropertyChange: false, value: { obj: obj } });
14965
15038
  var shapeSettings = obj['shapeSettingsObj'];
@@ -14993,6 +15066,20 @@ var Shape = /** @__PURE__ @class */ (function () {
14993
15066
  parent.isPublicMethod = false;
14994
15067
  }
14995
15068
  };
15069
+ Shape.prototype.setTransformColl = function (transformCollection) {
15070
+ var parent = this.parent;
15071
+ parent.activeObj.rotateFlipColl = [];
15072
+ if (transformCollection) {
15073
+ for (var i = 0; i < transformCollection.length; i++) {
15074
+ if (transformCollection[i].degree) {
15075
+ parent.activeObj.rotateFlipColl.push(transformCollection[i].degree);
15076
+ }
15077
+ else {
15078
+ parent.activeObj.rotateFlipColl.push(transformCollection[i].flip.toLowerCase());
15079
+ }
15080
+ }
15081
+ }
15082
+ };
14996
15083
  Shape.prototype.drawShapeImageEvent = function (shapeChangingArgs, isSelect) {
14997
15084
  var parent = this.parent;
14998
15085
  this.updateShapeChangeEventArgs(shapeChangingArgs.currentShapeSettings, shapeChangingArgs.allowShapeOverflow);
@@ -15185,9 +15272,11 @@ var Shape = /** @__PURE__ @class */ (function () {
15185
15272
  parent.activeObj.activePoint.endX = parent.activeObj.activePoint.startX + parent.activeObj.activePoint.width;
15186
15273
  parent.activeObj.activePoint.endY = parent.activeObj.activePoint.startY + parent.activeObj.activePoint.height;
15187
15274
  }
15188
- parent.activeObj.strokeSettings.strokeColor = shapeSettings.strokeColor;
15275
+ if (parent.activeObj.shape !== 'text') {
15276
+ parent.activeObj.strokeSettings.strokeColor = shapeSettings.strokeColor;
15277
+ parent.activeObj.strokeSettings.strokeWidth = shapeSettings.strokeWidth;
15278
+ }
15189
15279
  parent.activeObj.strokeSettings.fillColor = shapeSettings.fillColor;
15190
- parent.activeObj.strokeSettings.strokeWidth = shapeSettings.strokeWidth;
15191
15280
  parent.activeObj.opacity = shapeSettings.opacity;
15192
15281
  parent.activeObj.order = shapeSettings.index;
15193
15282
  parent.activeObj.preventShapeDragOut = !allowShapeOverflow;
@@ -15220,7 +15309,11 @@ var Shape = /** @__PURE__ @class */ (function () {
15220
15309
  parent.activeObj.keyHistory = parent.activeObj.textSettings.text = shapeSettings.text;
15221
15310
  parent.activeObj.textSettings.fontSize = shapeSettings.fontSize;
15222
15311
  parent.activeObj.strokeSettings.strokeColor = shapeSettings.color;
15312
+ parent.activeObj.strokeSettings.outlineColor = shapeSettings.strokeColor;
15313
+ parent.activeObj.strokeSettings.outlineWidth = shapeSettings.strokeWidth;
15314
+ parent.activeObj.strokeSettings.fillColor = shapeSettings.fillColor;
15223
15315
  parent.activeObj.textSettings.fontFamily = shapeSettings.fontFamily;
15316
+ this.setTransformColl(shapeSettings.transformCollection);
15224
15317
  if (shapeSettings.degree) {
15225
15318
  parent.activeObj.rotatedAngle = shapeSettings.degree * (Math.PI / 180);
15226
15319
  }
@@ -15995,7 +16088,8 @@ var Shape = /** @__PURE__ @class */ (function () {
15995
16088
  obj.shapeFlip = parent.transform.currFlipState;
15996
16089
  }
15997
16090
  };
15998
- Shape.prototype.getRotDegOfShape = function (obj) {
16091
+ Shape.prototype.getRotDegOfShape = function (obj, value) {
16092
+ var parent = this.parent;
15999
16093
  var degree;
16000
16094
  if (obj.shapeDegree === 0) {
16001
16095
  degree = this.parent.transform.degree;
@@ -16006,6 +16100,16 @@ var Shape = /** @__PURE__ @class */ (function () {
16006
16100
  if (degree < 0) {
16007
16101
  degree = 360 + degree;
16008
16102
  }
16103
+ var transformObj = { bool: false };
16104
+ parent.notify('selection', { prop: 'getTransformedShape', onPropertyChange: false, value: { obj: transformObj } });
16105
+ if (transformObj['bool'] && !value && parent.activeObj.rotateFlipColl) {
16106
+ degree = 0;
16107
+ for (var i = 0; i < parent.activeObj.rotateFlipColl.length; i++) {
16108
+ if (typeof (parent.activeObj.rotateFlipColl[i]) === 'number') {
16109
+ degree += (parent.activeObj.rotateFlipColl[i]);
16110
+ }
16111
+ }
16112
+ }
16009
16113
  return degree;
16010
16114
  };
16011
16115
  Shape.prototype.renderTextArea = function (x, y, actObj) {
@@ -17072,11 +17176,18 @@ var Shape = /** @__PURE__ @class */ (function () {
17072
17176
  }
17073
17177
  }
17074
17178
  else if (isTextArea) {
17075
- obj.textSettings.fontRatio = width / parseFloat(parent.textArea.style.fontSize);
17179
+ var transformObj = { bool: false };
17180
+ parent.notify('selection', { prop: 'getTransformedShape', onPropertyChange: false, value: { obj: transformObj } });
17181
+ if (!transformObj['bool'] || degree === 0 || Math.abs(degree) === 180) {
17182
+ obj.textSettings.fontRatio = width / parseFloat(parent.textArea.style.fontSize);
17183
+ }
17184
+ else {
17185
+ obj.textSettings.fontRatio = height / parseFloat(parent.textArea.style.fontSize);
17186
+ }
17076
17187
  }
17077
17188
  };
17078
17189
  Shape.prototype.updateFontSize = function (obj) {
17079
- var degree = this.getRotDegOfShape(obj);
17190
+ var degree = this.getRotDegOfShape(obj, true);
17080
17191
  if (degree === 0 || Math.abs(degree) === 180) {
17081
17192
  obj.textSettings.fontSize = (obj.activePoint.width / obj.textSettings.fontRatio);
17082
17193
  }
@@ -17380,6 +17491,7 @@ var Shape = /** @__PURE__ @class */ (function () {
17380
17491
  shapeDetails.startX = obj.activePoint.startX;
17381
17492
  shapeDetails.startY = obj.activePoint.startY;
17382
17493
  shapeDetails.index = obj.order;
17494
+ var transformObj = { coll: null };
17383
17495
  switch (obj.shape) {
17384
17496
  case 'rectangle':
17385
17497
  shapeDetails.width = obj.activePoint.width;
@@ -17418,6 +17530,9 @@ var Shape = /** @__PURE__ @class */ (function () {
17418
17530
  shapeDetails.fontSize = obj.textSettings.fontSize;
17419
17531
  shapeDetails.fontFamily = obj.textSettings.fontFamily;
17420
17532
  shapeDetails.color = obj.strokeSettings.strokeColor;
17533
+ shapeDetails.strokeColor = obj.strokeSettings.outlineColor;
17534
+ shapeDetails.fillColor = obj.strokeSettings.fillColor;
17535
+ shapeDetails.strokeWidth = obj.strokeSettings.outlineWidth;
17421
17536
  shapeDetails.fontStyle = [];
17422
17537
  if (obj.textSettings.bold) {
17423
17538
  shapeDetails.fontStyle.push('bold');
@@ -17426,6 +17541,8 @@ var Shape = /** @__PURE__ @class */ (function () {
17426
17541
  shapeDetails.fontStyle.push('italic');
17427
17542
  }
17428
17543
  shapeDetails.degree = obj.rotatedAngle * (180 / Math.PI);
17544
+ parent.notify('selection', { prop: 'updateTransColl', onPropertyChange: false, value: { obj: transformObj, object: obj } });
17545
+ shapeDetails.transformCollection = transformObj['coll'];
17429
17546
  break;
17430
17547
  case 'path':
17431
17548
  shapeDetails.strokeColor = obj.strokeSettings.strokeColor;
@@ -17727,6 +17844,9 @@ var Shape = /** @__PURE__ @class */ (function () {
17727
17844
  Shape.prototype.getMaxText = function (isTextBox, text, obj) {
17728
17845
  if (isNullOrUndefined(text)) {
17729
17846
  text = isTextBox ? this.parent.textArea.value : this.parent.activeObj.keyHistory;
17847
+ if (!text) {
17848
+ return text;
17849
+ }
17730
17850
  }
17731
17851
  var maxi;
17732
17852
  var rows = text.split('\n');
@@ -23094,17 +23214,18 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
23094
23214
  * @param {fillColor} fillColor - Specifies the background Color of the text.
23095
23215
  * @param {string} strokeColor - Specifies the outline color of the text annotation.
23096
23216
  * @param {number} strokeWidth - Specifies the outline stroke width of the text annotation.
23217
+ * @param {TransformationCollection[]} transformCollection - Specifies the transform collection of the text annotation.
23097
23218
  * @returns {boolean}.
23098
23219
  *
23099
23220
  */
23100
- ImageEditor.prototype.drawText = function (x, y, text, fontFamily, fontSize, bold, italic, color, isSelected, degree, fillColor, strokeColor, strokeWidth) {
23221
+ ImageEditor.prototype.drawText = function (x, y, text, fontFamily, fontSize, bold, italic, color, isSelected, degree, fillColor, strokeColor, strokeWidth, transformCollection) {
23101
23222
  var isText = false;
23102
23223
  var isPointsInRange = this.allowShape(x, y);
23103
23224
  if (!this.disabled && this.isImageLoaded && (isPointsInRange || (isNullOrUndefined(x) && isNullOrUndefined(y)))) {
23104
23225
  isText = true;
23105
23226
  this.notify('shape', { prop: 'drawText', onPropertyChange: false, value: { x: x, y: y, text: text, fontFamily: fontFamily,
23106
23227
  fontSize: fontSize, bold: bold, italic: italic, color: color, isSelected: isSelected, degree: degree, fillColor: fillColor,
23107
- outlineColor: strokeColor, outlineWidth: strokeWidth } });
23228
+ outlineColor: strokeColor, outlineWidth: strokeWidth, transformCollection: transformCollection } });
23108
23229
  this.editCompleted();
23109
23230
  }
23110
23231
  return isText;
@@ -29813,6 +29934,13 @@ var ToolbarModule = /** @__PURE__ @class */ (function () {
29813
29934
  parent.notify('draw', { prop: 'drawObject', onPropertyChange: false, value: { canvas: 'duplicate', obj: activeObj,
29814
29935
  isCropRatio: null, points: null, isPreventDrag: true } });
29815
29936
  }
29937
+ var panMoveObj = { panMove: null };
29938
+ parent.notify('transform', { prop: 'getPanMove', onPropertyChange: false,
29939
+ value: { obj: panMoveObj } });
29940
+ if (panMoveObj['panMove']) {
29941
+ parent.notify('transform', { prop: 'drawPannedImage', onPropertyChange: false,
29942
+ value: { xDiff: null, yDiff: null } });
29943
+ }
29816
29944
  };
29817
29945
  ToolbarModule.prototype.updateKBDNavigation = function (type) {
29818
29946
  var parent = this.parent;
@@ -32669,6 +32797,17 @@ var ToolbarModule = /** @__PURE__ @class */ (function () {
32669
32797
  fontSizeElem.textContent = (i + 1).toString();
32670
32798
  break;
32671
32799
  }
32800
+ else {
32801
+ if (Math.round(parent.activeObj.textSettings.fontSize) < parseInt(parent.fontSizeColl[0].text, 10)) {
32802
+ fontSizeElem.textContent = '1';
32803
+ break;
32804
+ }
32805
+ else if (Math.round(parent.activeObj.textSettings.fontSize) >
32806
+ parseInt(parent.fontSizeColl[parent.fontSizeColl.length - 1].text, 10)) {
32807
+ fontSizeElem.textContent = ((parent.fontSizeColl.length - 1) + 1).toString();
32808
+ break;
32809
+ }
32810
+ }
32672
32811
  }
32673
32812
  }
32674
32813
  if (boldBtn) {