@syncfusion/ej2-image-editor 23.2.7 → 24.1.43

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.
Files changed (99) hide show
  1. package/CHANGELOG.md +6 -54
  2. package/dist/ej2-image-editor.umd.min.js +2 -2
  3. package/dist/ej2-image-editor.umd.min.js.map +1 -1
  4. package/dist/es6/ej2-image-editor.es2015.js +7227 -4367
  5. package/dist/es6/ej2-image-editor.es2015.js.map +1 -1
  6. package/dist/es6/ej2-image-editor.es5.js +7295 -4422
  7. package/dist/es6/ej2-image-editor.es5.js.map +1 -1
  8. package/dist/global/ej2-image-editor.min.js +2 -2
  9. package/dist/global/ej2-image-editor.min.js.map +1 -1
  10. package/dist/global/index.d.ts +1 -1
  11. package/package.json +12 -12
  12. package/src/image-editor/action/crop.d.ts +6 -0
  13. package/src/image-editor/action/crop.js +347 -188
  14. package/src/image-editor/action/draw.d.ts +35 -2
  15. package/src/image-editor/action/draw.js +1691 -890
  16. package/src/image-editor/action/export.js +90 -29
  17. package/src/image-editor/action/filter.d.ts +3 -1
  18. package/src/image-editor/action/filter.js +74 -94
  19. package/src/image-editor/action/freehand-draw.d.ts +4 -0
  20. package/src/image-editor/action/freehand-draw.js +248 -147
  21. package/src/image-editor/action/selection.d.ts +6 -1
  22. package/src/image-editor/action/selection.js +1133 -1091
  23. package/src/image-editor/action/shape.d.ts +7 -0
  24. package/src/image-editor/action/shape.js +923 -550
  25. package/src/image-editor/action/transform.d.ts +2 -0
  26. package/src/image-editor/action/transform.js +518 -346
  27. package/src/image-editor/action/undo-redo.d.ts +2 -0
  28. package/src/image-editor/action/undo-redo.js +137 -36
  29. package/src/image-editor/base/enum.d.ts +2 -1
  30. package/src/image-editor/base/enum.js +1 -0
  31. package/src/image-editor/base/image-editor-model.d.ts +37 -2
  32. package/src/image-editor/base/image-editor.d.ts +124 -3
  33. package/src/image-editor/base/image-editor.js +675 -172
  34. package/src/image-editor/base/interface.d.ts +69 -15
  35. package/src/image-editor/renderer/toolbar.d.ts +10 -0
  36. package/src/image-editor/renderer/toolbar.js +1415 -835
  37. package/styles/bootstrap-dark.css +113 -8
  38. package/styles/bootstrap.css +112 -7
  39. package/styles/bootstrap4.css +113 -8
  40. package/styles/bootstrap5-dark.css +113 -8
  41. package/styles/bootstrap5.css +113 -8
  42. package/styles/fabric-dark.css +114 -9
  43. package/styles/fabric.css +113 -8
  44. package/styles/fluent-dark.css +118 -9
  45. package/styles/fluent.css +118 -9
  46. package/styles/highcontrast-light.css +112 -7
  47. package/styles/highcontrast.css +116 -7
  48. package/styles/image-editor/_bootstrap-dark-definition.scss +3 -0
  49. package/styles/image-editor/_bootstrap-definition.scss +3 -0
  50. package/styles/image-editor/_bootstrap4-definition.scss +3 -0
  51. package/styles/image-editor/_bootstrap5-definition.scss +3 -0
  52. package/styles/image-editor/_fabric-dark-definition.scss +3 -0
  53. package/styles/image-editor/_fabric-definition.scss +3 -0
  54. package/styles/image-editor/_fluent-definition.scss +3 -0
  55. package/styles/image-editor/_fusionnew-definition.scss +3 -0
  56. package/styles/image-editor/_highcontrast-definition.scss +3 -0
  57. package/styles/image-editor/_highcontrast-light-definition.scss +3 -0
  58. package/styles/image-editor/_layout.scss +138 -4
  59. package/styles/image-editor/_material-dark-definition.scss +3 -0
  60. package/styles/image-editor/_material-definition.scss +3 -0
  61. package/styles/image-editor/_material3-definition.scss +3 -0
  62. package/styles/image-editor/_tailwind-definition.scss +3 -0
  63. package/styles/image-editor/_theme.scss +2 -4
  64. package/styles/image-editor/bootstrap-dark.css +113 -8
  65. package/styles/image-editor/bootstrap.css +112 -7
  66. package/styles/image-editor/bootstrap4.css +113 -8
  67. package/styles/image-editor/bootstrap5-dark.css +113 -8
  68. package/styles/image-editor/bootstrap5.css +113 -8
  69. package/styles/image-editor/fabric-dark.css +114 -9
  70. package/styles/image-editor/fabric.css +113 -8
  71. package/styles/image-editor/fluent-dark.css +118 -9
  72. package/styles/image-editor/fluent.css +118 -9
  73. package/styles/image-editor/highcontrast-light.css +112 -7
  74. package/styles/image-editor/highcontrast.css +116 -7
  75. package/styles/image-editor/icons/_bootstrap-dark.scss +60 -0
  76. package/styles/image-editor/icons/_bootstrap.scss +60 -0
  77. package/styles/image-editor/icons/_bootstrap4.scss +60 -0
  78. package/styles/image-editor/icons/_bootstrap5.scss +60 -0
  79. package/styles/image-editor/icons/_fabric-dark.scss +60 -0
  80. package/styles/image-editor/icons/_fabric.scss +60 -0
  81. package/styles/image-editor/icons/_fluent.scss +66 -0
  82. package/styles/image-editor/icons/_highcontrast-light.scss +60 -0
  83. package/styles/image-editor/icons/_highcontrast.scss +60 -0
  84. package/styles/image-editor/icons/_material-dark.scss +60 -0
  85. package/styles/image-editor/icons/_material.scss +60 -0
  86. package/styles/image-editor/icons/_material3.scss +60 -0
  87. package/styles/image-editor/icons/_tailwind.scss +60 -0
  88. package/styles/image-editor/material-dark.css +113 -8
  89. package/styles/image-editor/material.css +113 -8
  90. package/styles/image-editor/material3-dark.css +126 -9
  91. package/styles/image-editor/material3.css +126 -9
  92. package/styles/image-editor/tailwind-dark.css +114 -9
  93. package/styles/image-editor/tailwind.css +114 -9
  94. package/styles/material-dark.css +113 -8
  95. package/styles/material.css +113 -8
  96. package/styles/material3-dark.css +126 -9
  97. package/styles/material3.css +126 -9
  98. package/styles/tailwind-dark.css +114 -9
  99. package/styles/tailwind.css +114 -9
@@ -2,7 +2,7 @@ import { EventHandler, extend, isBlazor, isNullOrUndefined } from '@syncfusion/e
2
2
  import { ShapeType } from '../index';
3
3
  var Shape = /** @class */ (function () {
4
4
  function Shape(parent) {
5
- this.textSettings = { text: 'Enter Text', fontFamily: 'Arial', fontSize: null, fontRatio: null, bold: false, italic: false, underline: false };
5
+ this.textSettings = { text: 'Enter Text', fontFamily: '', fontSize: null, fontRatio: null, bold: false, italic: false, underline: false };
6
6
  this.strokeSettings = { strokeColor: '#fff', fillColor: '', strokeWidth: null };
7
7
  this.keyHistory = ''; // text history
8
8
  this.parent = parent;
@@ -23,6 +23,7 @@ var Shape = /** @class */ (function () {
23
23
  this.parent.off('destroyed', this.destroy);
24
24
  };
25
25
  Shape.prototype.shape = function (args) {
26
+ var parent = this.parent;
26
27
  this.initShapePvtProps();
27
28
  var uploader;
28
29
  switch (args.prop) {
@@ -120,17 +121,17 @@ var Shape = /** @class */ (function () {
120
121
  this.applyActObj(args.value['isMouseDown']);
121
122
  break;
122
123
  case 'wireEvent':
123
- EventHandler.add(this.parent.upperCanvas, 'dblclick', this.findTextTarget, this);
124
- EventHandler.add(this.parent.textArea, 'mousedown', this.findTextTarget, this);
125
- uploader = document.getElementById(this.parent.element.id + '_fileUpload');
124
+ EventHandler.add(parent.upperCanvas, 'dblclick', this.findTextTarget, this);
125
+ EventHandler.add(parent.textArea, 'mousedown', this.findTextTarget, this);
126
+ uploader = document.getElementById(parent.element.id + '_fileUpload');
126
127
  if (uploader) {
127
128
  EventHandler.add(uploader, 'change', this.fileChanged, this);
128
129
  }
129
130
  break;
130
131
  case 'unWireEvent':
131
- EventHandler.remove(this.parent.upperCanvas, 'dblclick', this.findTextTarget);
132
- EventHandler.remove(this.parent.textArea, 'mousedown', this.findTextTarget);
133
- uploader = document.getElementById(this.parent.element.id + '_fileUpload');
132
+ EventHandler.remove(parent.upperCanvas, 'dblclick', this.findTextTarget);
133
+ EventHandler.remove(parent.textArea, 'mousedown', this.findTextTarget);
134
+ uploader = document.getElementById(parent.element.id + '_fileUpload');
134
135
  EventHandler.remove(uploader, 'change', this.fileChanged);
135
136
  break;
136
137
  case 'getShapeSetting':
@@ -216,7 +217,7 @@ var Shape = /** @class */ (function () {
216
217
  this.getSquarePointForRotatedShape(args.value['obj'], args.value['object']);
217
218
  break;
218
219
  case 'drawImage':
219
- this.drawImage(args.value['x'], args.value['y'], args.value['width'], args.value['height'], args.value['src'], args.value['degree'], args.value['isAspectRatio']);
220
+ this.drawImage(args.value['x'], args.value['y'], args.value['width'], args.value['height'], args.value['src'], args.value['degree'], args.value['isAspectRatio'], args.value['opacity']);
220
221
  break;
221
222
  case 'reset':
222
223
  this.reset();
@@ -227,30 +228,52 @@ var Shape = /** @class */ (function () {
227
228
  case 'updateObj':
228
229
  this.updateObj(args.value['dimObj'], args.value['x'], args.value['y']);
229
230
  break;
231
+ case 'straightenShapes':
232
+ this.straightenShapes();
233
+ break;
234
+ case 'straightenShapePoints':
235
+ this.straightenShapePoints(args.value['obj'], args.value['isReverse']);
236
+ break;
237
+ case 'straightenPath':
238
+ this.straightenPath(args.value['obj']);
239
+ break;
240
+ case 'straightenFHD':
241
+ this.straightenFHD();
242
+ break;
243
+ case 'getTextBoxPosition':
244
+ this.getTextBoxPosition(args.value['obj'], args.value['object']);
245
+ break;
230
246
  case 'updateSelectionChangeEventArgs':
231
247
  this.updateSelectionChangeEventArgs(args.value['selectionSettings']);
232
248
  break;
249
+ case 'setFlipState':
250
+ this.setFlipState(args.value['x'], args.value['y'], args.value['obj'], args.value['object']);
251
+ break;
233
252
  }
234
253
  };
235
254
  Shape.prototype.getModuleName = function () {
236
255
  return 'shape';
237
256
  };
238
257
  Shape.prototype.initShapePvtProps = function () {
239
- if (this.parent.lowerCanvas) {
240
- this.lowerContext = this.parent.lowerCanvas.getContext('2d');
258
+ var parent = this.parent;
259
+ if (parent.lowerCanvas) {
260
+ this.lowerContext = parent.lowerCanvas.getContext('2d');
241
261
  }
242
- if (this.parent.upperCanvas) {
243
- this.upperContext = this.parent.upperCanvas.getContext('2d');
262
+ if (parent.upperCanvas) {
263
+ this.upperContext = parent.upperCanvas.getContext('2d');
244
264
  }
245
265
  if (isNullOrUndefined(this.shapeImg)) {
246
- this.shapeImg = this.parent.createElement('img', {
247
- id: this.parent.element.id + '_shapeImg', attrs: { name: 'Image', crossorigin: 'anonymous' }
266
+ this.shapeImg = parent.createElement('img', {
267
+ id: parent.element.id + '_shapeImg', attrs: { name: 'Image', crossorigin: 'anonymous' }
248
268
  });
249
269
  }
270
+ if (this.textSettings.fontFamily === '') {
271
+ this.textSettings.fontFamily = parent.fontFamily.default;
272
+ }
250
273
  };
251
274
  Shape.prototype.reset = function () {
252
275
  this.textSettings =
253
- { text: 'Enter Text', fontFamily: 'Arial', fontSize: null, fontRatio: null, bold: false, italic: false, underline: false };
276
+ { text: 'Enter Text', fontFamily: this.parent.fontFamily.default, fontSize: null, fontRatio: null, bold: false, italic: false, underline: false };
254
277
  this.strokeSettings = { strokeColor: '#fff', fillColor: '', strokeWidth: null };
255
278
  };
256
279
  Shape.prototype.drawEllipse = function (x, y, radiusX, radiusY, strokeWidth, strokeColor, fillColor, degree) {
@@ -266,18 +289,19 @@ var Shape = /** @class */ (function () {
266
289
  this.drawShape('line', strokeWidth, strokeColor, null, start, width, height);
267
290
  };
268
291
  Shape.prototype.drawPath = function (pointColl, strokeWidth, strokeColor) {
292
+ var parent = this.parent;
269
293
  this.initializeShape('path');
270
294
  if (pointColl) {
271
295
  this.drawShape('path', strokeWidth, strokeColor, null, null, null, null, pointColl);
272
296
  }
273
297
  else {
274
- this.drawShape('line', strokeWidth, strokeColor, null, null, null, null);
275
- var obj = extend({}, this.parent.objColl[this.parent.objColl.length - 1], null, true);
298
+ this.drawShape('line', strokeWidth, strokeColor);
299
+ var obj = extend({}, parent.objColl[parent.objColl.length - 1], null, true);
276
300
  obj.shape = 'path';
277
301
  obj.lineDraw = null;
278
302
  obj.pointColl = [{ x: obj.activePoint.startX, y: obj.activePoint.startY },
279
303
  { x: obj.activePoint.endX, y: obj.activePoint.endY }];
280
- this.parent.objColl[this.parent.objColl.length - 1] = obj;
304
+ parent.objColl[parent.objColl.length - 1] = obj;
281
305
  }
282
306
  };
283
307
  Shape.prototype.drawArrow = function (startX, startY, endX, endY, strokeWidth, strokeColor, arrowStart, arrowEnd) {
@@ -296,14 +320,15 @@ var Shape = /** @class */ (function () {
296
320
  this.drawShapeText(text, fontFamily, fontSize, bold, italic, color, x, y);
297
321
  };
298
322
  Shape.prototype.initializeShape = function (type) {
323
+ var parent = this.parent;
299
324
  this.redrawActObj();
300
- this.parent.activeObj.shape = type;
301
- if (this.parent.currObjType.shape === 'freehanddraw') {
325
+ parent.activeObj.shape = type;
326
+ if (parent.currObjType.shape === 'freehanddraw') {
302
327
  this.apply();
303
- this.parent.upperCanvas.style.cursor = this.parent.cursor = 'default';
304
- this.parent.currObjType.shape = '';
328
+ parent.upperCanvas.style.cursor = parent.cursor = 'default';
329
+ parent.currObjType.shape = '';
305
330
  }
306
- this.parent.currObjType.isCustomCrop = false;
331
+ parent.currObjType.isCustomCrop = false;
307
332
  };
308
333
  Shape.prototype.updateWidthHeight = function (obj) {
309
334
  obj.activePoint.width = obj.activePoint.endX - obj.activePoint.startX;
@@ -311,12 +336,13 @@ var Shape = /** @class */ (function () {
311
336
  return obj;
312
337
  };
313
338
  Shape.prototype.setDimension = function (width, height) {
339
+ var parent = this.parent;
314
340
  if (width && height) {
315
- this.parent.activeObj.activePoint.width = width;
316
- this.parent.activeObj.activePoint.height = height;
317
- if (this.parent.currObjType.shape.toLowerCase() === 'ellipse') {
318
- this.parent.activeObj.activePoint.width = 2 * width;
319
- this.parent.activeObj.activePoint.height = 2 * height;
341
+ parent.activeObj.activePoint.width = width;
342
+ parent.activeObj.activePoint.height = height;
343
+ if (parent.currObjType.shape.toLowerCase() === 'ellipse') {
344
+ parent.activeObj.activePoint.width = 2 * width;
345
+ parent.activeObj.activePoint.height = 2 * height;
320
346
  }
321
347
  }
322
348
  };
@@ -329,7 +355,7 @@ var Shape = /** @class */ (function () {
329
355
  }
330
356
  return arrowType;
331
357
  };
332
- Shape.prototype.drawShape = function (type, strokeWidth, strokeColor, fillColor, start, width, height, pointColl, arrowStart, arrowEnd, degree) {
358
+ Shape.prototype.drawShape = function (type, strokeWidth, strokeColor, fillColor, start, width, height, pointColl, arrowStart, arrowEnd, degree, opacity) {
333
359
  var _this = this;
334
360
  var parent = this.parent;
335
361
  if (!parent.disabled && parent.isImageLoaded) {
@@ -338,13 +364,13 @@ var Shape = /** @class */ (function () {
338
364
  var objColl_1 = extend([], parent.objColl, [], true);
339
365
  parent.togglePen = false;
340
366
  this.keyHistory = '';
341
- this.parent.upperCanvas.style.display = 'block';
367
+ parent.upperCanvas.style.display = 'block';
342
368
  this.refreshActiveObj();
343
- parent.currObjType.shape = type;
344
- if (parent.currObjType.shape.toLowerCase() === 'path' && isNullOrUndefined(pointColl)) {
345
- parent.activeObj.shape = parent.currObjType.shape.toLowerCase();
369
+ parent.currObjType.shape = type = type.toLowerCase();
370
+ if (type === 'path' && isNullOrUndefined(pointColl)) {
371
+ parent.activeObj.shape = type;
346
372
  parent.activeObj.pointColl = [];
347
- parent.upperCanvas.style.cursor = this.parent.cursor = 'crosshair';
373
+ parent.upperCanvas.style.cursor = parent.cursor = 'crosshair';
348
374
  parent.notify('selection', { prop: 'setCurrentDrawingShape', onPropertyChange: false, value: { value: 'path' } });
349
375
  if (!isBlazor()) {
350
376
  parent.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: { type: 'shapes',
@@ -353,32 +379,36 @@ var Shape = /** @class */ (function () {
353
379
  }
354
380
  }
355
381
  else {
356
- if (parent.currObjType.shape.toLowerCase() !== 'freehanddraw' && parent.currObjType.shape.toLowerCase() !== '') {
357
- parent.activeObj.shape = parent.currObjType.shape.toLowerCase();
382
+ if (type !== 'freehanddraw' && type !== '') {
383
+ parent.activeObj.shape = type;
384
+ var strokeSettings = parent.activeObj.strokeSettings;
358
385
  this.upperContext.clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
359
- if (isNullOrUndefined(parent.activeObj.strokeSettings)) {
360
- parent.activeObj.strokeSettings = this.strokeSettings;
386
+ if (isNullOrUndefined(strokeSettings)) {
387
+ strokeSettings = this.strokeSettings;
361
388
  }
362
- if (parent.currObjType.shape.toLowerCase() === 'path' && pointColl) {
389
+ if (type === 'path' && pointColl) {
363
390
  parent.activeObj.pointColl = pointColl;
364
391
  }
365
- parent.activeObj.strokeSettings.strokeWidth = strokeWidth ? strokeWidth : parent.activeObj.strokeSettings.strokeWidth;
366
- parent.activeObj.strokeSettings.strokeColor = strokeColor ? strokeColor : parent.activeObj.strokeSettings.strokeColor;
367
- parent.activeObj.strokeSettings.fillColor = fillColor ? fillColor : parent.activeObj.strokeSettings.fillColor;
392
+ if (opacity !== null && opacity !== undefined) {
393
+ parent.activeObj.opacity = opacity;
394
+ }
395
+ strokeSettings.strokeWidth = strokeWidth ? strokeWidth : strokeSettings.strokeWidth;
396
+ strokeSettings.strokeColor = strokeColor ? strokeColor : strokeSettings.strokeColor;
397
+ strokeSettings.fillColor = fillColor ? fillColor : strokeSettings.fillColor;
368
398
  var tempWidth = parent.img.destWidth > 100 ? 100 : parent.img.destWidth / 2;
369
399
  var tempHeight = parent.img.destHeight > 100 ? 100 : parent.img.destHeight / 2;
370
400
  parent.activeObj.activePoint.width = tempWidth;
371
401
  parent.activeObj.activePoint.height = tempHeight;
372
- if (parent.currObjType.shape.toLowerCase() === 'line' || parent.currObjType.shape.toLowerCase() === 'arrow') {
402
+ if (type === 'line' || type === 'arrow') {
373
403
  parent.activeObj.lineDraw = 'horizontal';
374
404
  parent.activeObj.activePoint.height = 0;
375
- if (parent.currObjType.shape.toLowerCase() === 'arrow') {
405
+ if (type === 'arrow') {
376
406
  parent.activeObj.activePoint.width += 50;
377
407
  parent.activeObj.start = this.getArrowType(arrowStart);
378
408
  parent.activeObj.end = this.getArrowType(arrowEnd);
379
409
  }
380
410
  }
381
- else if (parent.currObjType.shape.toLowerCase() === 'rectangle') {
411
+ else if (type === 'rectangle') {
382
412
  parent.activeObj.activePoint.width += parent.activeObj.activePoint.width / 2;
383
413
  }
384
414
  this.setDimension(width, height);
@@ -394,7 +424,7 @@ var Shape = /** @class */ (function () {
394
424
  this.setCenterPoints();
395
425
  }
396
426
  this.setPointCollForLineAndArrow();
397
- if (parent.currObjType.shape.toLowerCase() === 'arrow') {
427
+ if (type === 'arrow') {
398
428
  parent.activeObj.triangleDirection = 'right';
399
429
  }
400
430
  parent.currObjType.isDragging = parent.currObjType.isCustomCrop = false;
@@ -402,11 +432,11 @@ var Shape = /** @class */ (function () {
402
432
  var obj = { shapeSettingsObj: {} };
403
433
  parent.notify('selection', { prop: 'updatePrevShapeSettings', onPropertyChange: false, value: { obj: obj } });
404
434
  var shapeSettings = obj['shapeSettingsObj'];
405
- var shapeChangingArgs = { action: 'insert', previousShapeSettings: shapeSettings,
435
+ var shapeChangingArgs = { cancel: false, action: 'insert', previousShapeSettings: shapeSettings,
406
436
  currentShapeSettings: shapeSettings };
407
437
  if (isBlazor() && parent.events && parent.events.shapeChanging.hasDelegate === true) {
408
438
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
409
- this.parent.dotNetRef.invokeMethodAsync('ShapeEventAsync', 'OnShape', shapeChangingArgs).then(function (shapeChangingArgs) {
439
+ parent.dotNetRef.invokeMethodAsync('ShapeEventAsync', 'OnShape', shapeChangingArgs, null).then(function (shapeChangingArgs) {
410
440
  _this.updateShapeChangeEventArgs(shapeChangingArgs.currentShapeSettings);
411
441
  _this.setDimension(width, height);
412
442
  parent.notify('draw', { prop: 'drawObject', onPropertyChange: false, value: { canvas: 'duplicate' } });
@@ -461,8 +491,10 @@ var Shape = /** @class */ (function () {
461
491
  };
462
492
  Shape.prototype.setPointCollForLineAndArrow = function () {
463
493
  var parent = this.parent;
464
- if (parent.activeObj.shape === 'line' || parent.activeObj.shape === 'arrow') {
465
- parent.activeObj.pointColl = this.getLinePoints(parent.activeObj.activePoint.startX, parent.activeObj.activePoint.startY, parent.activeObj.activePoint.endX, parent.activeObj.activePoint.endY);
494
+ var shape = parent.activeObj.shape;
495
+ var _a = parent.activeObj.activePoint, startX = _a.startX, startY = _a.startY, endX = _a.endX, endY = _a.endY;
496
+ if (shape === 'line' || shape === 'arrow') {
497
+ parent.activeObj.pointColl = this.getLinePoints(startX, startY, endX, endY);
466
498
  if (parent.activeObj.pointColl) {
467
499
  for (var i = 0, len = parent.activeObj.pointColl.length; i < len; i++) {
468
500
  parent.activeObj.pointColl[i].ratioX = (parent.activeObj.pointColl[i].x -
@@ -533,11 +565,11 @@ var Shape = /** @class */ (function () {
533
565
  var obj = { shapeSettingsObj: {} };
534
566
  parent.notify('selection', { prop: 'updatePrevShapeSettings', onPropertyChange: false, value: { obj: obj } });
535
567
  var shapeSettings = obj['shapeSettingsObj'];
536
- var shapeChangingArgs = { action: 'insert', previousShapeSettings: shapeSettings,
568
+ var shapeChangingArgs = { cancel: false, action: 'insert', previousShapeSettings: shapeSettings,
537
569
  currentShapeSettings: shapeSettings };
538
570
  if (isBlazor() && parent.events && parent.events.shapeChanging.hasDelegate === true) {
539
571
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
540
- parent.dotNetRef.invokeMethodAsync('ShapeEventAsync', 'OnShape', shapeChangingArgs).then(function (shapeChangingArgs) {
572
+ parent.dotNetRef.invokeMethodAsync('ShapeEventAsync', 'OnShape', shapeChangingArgs, null).then(function (shapeChangingArgs) {
541
573
  _this.drawShapeTextEvent(shapeChangingArgs);
542
574
  if (parent.isPublicMethod) {
543
575
  parent.notify('undo-redo', { prop: 'updateUndoRedo', onPropertyChange: false });
@@ -563,9 +595,8 @@ var Shape = /** @class */ (function () {
563
595
  var prevCropObj = extend({}, parent.cropObj, {}, true);
564
596
  parent.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false,
565
597
  value: { operation: 'shapeTransform', previousObj: this.prevObj, previousObjColl: this.prevObj.objColl,
566
- previousPointColl: this.prevObj.pointColl, previousSelPointColl: this.prevObj.selPointColl,
567
- previousCropObj: prevCropObj, previousText: null,
568
- currentText: null, previousFilter: null, isCircleCrop: null } });
598
+ previousPointColl: this.prevObj.pointColl, previousSelPointColl: this.prevObj.selPointColl, previousCropObj: prevCropObj,
599
+ previousText: null, currentText: null, previousFilter: null, isCircleCrop: null } });
569
600
  parent.notify('selection', { prop: 'redrawShape', onPropertyChange: false,
570
601
  value: { obj: parent.objColl[parent.objColl.length - 1] } });
571
602
  if (isSelect) {
@@ -596,25 +627,24 @@ var Shape = /** @class */ (function () {
596
627
  parent.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false,
597
628
  value: { operation: 'shapeTransform', previousObj: this.prevObj, previousObjColl: this.prevObj.objColl,
598
629
  previousPointColl: this.prevObj.pointColl, previousSelPointColl: this.prevObj.selPointColl,
599
- previousCropObj: prevCropObj, previousText: null,
600
- currentText: null, previousFilter: null, isCircleCrop: null } });
630
+ previousCropObj: prevCropObj, previousText: null, currentText: null, previousFilter: null, isCircleCrop: null } });
601
631
  parent.notify('selection', { prop: 'redrawShape', onPropertyChange: false,
602
632
  value: { obj: parent.objColl[parent.objColl.length - 1] } });
603
- if (!isBlazor()) {
604
- parent.notify('toolbar', { prop: 'renderQAT', onPropertyChange: false, value: { isPenEdit: null } });
633
+ if (isBlazor()) {
634
+ parent.updateToolbar(parent.element, 'quickAccessToolbar', 'text');
605
635
  }
606
636
  else {
607
- parent.updateToolbar(parent.element, 'quickAccessToolbar', 'text');
637
+ parent.notify('toolbar', { prop: 'renderQAT', onPropertyChange: false, value: { isPenEdit: null } });
608
638
  }
609
639
  parent.notify('selection', { prop: 'isShapeInserted', onPropertyChange: false, value: { bool: true } });
610
- if (!isBlazor()) {
640
+ if (isBlazor()) {
641
+ parent.updateToolbar(parent.element, 'text');
642
+ }
643
+ else {
611
644
  parent.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: { type: 'text',
612
645
  isApplyBtn: null, isCropping: null, isZooming: null, cType: null } });
613
646
  parent.notify('toolbar', { prop: 'update-toolbar-items', onPropertyChange: false });
614
647
  }
615
- else {
616
- parent.updateToolbar(parent.element, 'text');
617
- }
618
648
  };
619
649
  Shape.prototype.initializeTextShape = function (text, fontFamily, fontSize, bold, italic, strokeColor) {
620
650
  var parent = this.parent;
@@ -633,9 +663,9 @@ var Shape = /** @class */ (function () {
633
663
  parent.activeObj.textSettings.bold = bold || parent.activeObj.textSettings.bold;
634
664
  parent.activeObj.textSettings.italic = italic || parent.activeObj.textSettings.italic;
635
665
  };
636
- Shape.prototype.drawImage = function (x, y, width, height, src, degree, isAspectRatio) {
666
+ Shape.prototype.drawImage = function (x, y, width, height, src, degree, isAspectRatio, opacity) {
637
667
  this.initializeShape('image');
638
- this.onLoadImgShape(x, y, width, height, src, null, degree, isAspectRatio);
668
+ this.onLoadImgShape(x, y, width, height, src, null, degree, isAspectRatio, opacity);
639
669
  };
640
670
  Shape.prototype.redrawActObj = function (x, y, isMouseDown) {
641
671
  var splitWords;
@@ -644,7 +674,7 @@ var Shape = /** @class */ (function () {
644
674
  splitWords = parent.activeObj.shape.split('-');
645
675
  }
646
676
  if (parent.activeObj.horTopLine && (parent.activeObj.shape && splitWords[0] !== 'crop')) {
647
- if (parent.textArea.style.display === 'block') {
677
+ if (parent.textArea.style.display === 'block' || parent.textArea.style.display === 'inline-block') {
648
678
  parent.notify('selection', { prop: 'setTextBoxStylesToActObj', onPropertyChange: false });
649
679
  this.updateFontRatio(parent.activeObj, true);
650
680
  if (x && y) {
@@ -676,10 +706,6 @@ var Shape = /** @class */ (function () {
676
706
  var temp = this.lowerContext.filter;
677
707
  this.lowerContext.filter = 'none';
678
708
  parent.togglePen = false;
679
- this.iterateObjColl();
680
- parent.notify('freehandDraw', { prop: 'freehandRedraw', onPropertyChange: false,
681
- value: { context: this.lowerContext, points: null } });
682
- parent.togglePen = false;
683
709
  if (parent.isCircleCrop || (parent.currSelectionPoint &&
684
710
  parent.currSelectionPoint.shape === 'crop-circle')) {
685
711
  parent.notify('crop', { prop: 'cropCircle', onPropertyChange: false,
@@ -704,7 +730,6 @@ var Shape = /** @class */ (function () {
704
730
  if (parent.activeObj.shape === 'text') {
705
731
  parent.notify('draw', { prop: 'drawObject', onPropertyChange: false, value: { canvas: canvas, obj: obj, isCropRatio: null,
706
732
  points: null, isPreventDrag: true, saveContext: null, isPreventSelection: null } });
707
- parent.notify('draw', { prop: 'clearOuterCanvas', onPropertyChange: false, value: { context: this.lowerContext } });
708
733
  }
709
734
  else {
710
735
  parent.notify('draw', { prop: 'drawObject', onPropertyChange: false, value: { canvas: canvas, obj: obj } });
@@ -737,61 +762,74 @@ var Shape = /** @class */ (function () {
737
762
  };
738
763
  Shape.prototype.updSelChangeEventArgs = function (selectionSettings) {
739
764
  var parent = this.parent;
740
- parent.activeObj.activePoint.startX = selectionSettings.startX;
741
- parent.activeObj.activePoint.startY = selectionSettings.startY;
742
- parent.activeObj.activePoint.width = selectionSettings.width;
743
- parent.activeObj.activePoint.height = selectionSettings.height;
744
- parent.activeObj.activePoint.endX = parent.activeObj.activePoint.startX + parent.activeObj.activePoint.width;
745
- parent.activeObj.activePoint.endY = parent.activeObj.activePoint.startY + parent.activeObj.activePoint.height;
765
+ parent.activeObj.activePoint = { startX: selectionSettings.startX, startY: selectionSettings.startY,
766
+ endX: parent.activeObj.activePoint.startX + parent.activeObj.activePoint.width,
767
+ endY: parent.activeObj.activePoint.startY + parent.activeObj.activePoint.height,
768
+ width: selectionSettings.width, height: selectionSettings.height };
746
769
  };
747
770
  Shape.prototype.updateShapeChangeEventArgs = function (shapeSettings) {
748
771
  var parent = this.parent;
749
- parent.activeObj.currIndex = shapeSettings.id;
750
- parent.activeObj.activePoint.startX = shapeSettings.startX;
751
- parent.activeObj.activePoint.startY = shapeSettings.startY;
752
- parent.activeObj.activePoint.width = shapeSettings.width;
753
- parent.activeObj.activePoint.height = shapeSettings.height;
754
- parent.activeObj.activePoint.endX = parent.activeObj.activePoint.startX + parent.activeObj.activePoint.width;
755
- parent.activeObj.activePoint.endY = parent.activeObj.activePoint.startY + parent.activeObj.activePoint.height;
756
- parent.activeObj.strokeSettings.strokeColor = shapeSettings.strokeColor;
757
- parent.activeObj.strokeSettings.fillColor = shapeSettings.fillColor;
758
- if (isNullOrUndefined(shapeSettings.degree)) {
759
- shapeSettings.degree = 0;
760
- }
761
- switch (parent.activeObj.shape) {
762
- case 'ellipse':
763
- parent.activeObj.activePoint.width = shapeSettings.radius * 2;
764
- parent.activeObj.rotatedAngle = shapeSettings.degree * (Math.PI / 180);
765
- break;
766
- case 'line':
767
- case 'arrow':
768
- parent.activeObj.activePoint.width = shapeSettings.length;
769
- break;
770
- case 'text':
771
- parent.activeObj.keyHistory = parent.activeObj.textSettings.text = shapeSettings.text;
772
- parent.activeObj.textSettings.fontSize = shapeSettings.fontSize;
773
- parent.activeObj.strokeSettings.strokeColor = shapeSettings.color;
774
- parent.activeObj.textSettings.fontFamily = shapeSettings.fontFamily;
775
- break;
776
- case 'rectangle':
777
- case 'image':
778
- if (shapeSettings.degree) {
779
- parent.activeObj.rotatedAngle = shapeSettings.degree * (Math.PI / 180);
780
- }
781
- break;
772
+ var shapeId;
773
+ if (shapeSettings.id && shapeSettings.id.split('_')[0] && shapeSettings.id.split('_')[0] === 'pen') {
774
+ shapeId = parseInt(shapeSettings.id.split('_')[1], 10) - 1;
775
+ parent.pointColl[shapeId].points = shapeSettings.points;
776
+ parent.pointColl[shapeId].strokeColor = shapeSettings.strokeColor;
777
+ parent.pointColl[shapeId].strokeWidth = shapeSettings.strokeWidth;
778
+ parent.pointColl[shapeId].opacity = shapeSettings.opacity;
782
779
  }
783
- if (parent.activeObj.shape === 'text' && parent.activeObj.textSettings) {
784
- for (var i = 0; i < shapeSettings.fontStyle.length; i++) {
785
- switch (shapeSettings.fontStyle[i]) {
786
- case 'bold':
787
- parent.activeObj.textSettings.bold = true;
788
- break;
789
- case 'italic':
790
- parent.activeObj.textSettings.italic = true;
791
- break;
792
- case 'underline':
793
- parent.activeObj.textSettings.underline = true;
794
- break;
780
+ else {
781
+ parent.activeObj.currIndex = shapeSettings.id;
782
+ parent.activeObj.activePoint.startX = shapeSettings.startX;
783
+ parent.activeObj.activePoint.startY = shapeSettings.startY;
784
+ if (shapeSettings.width && shapeSettings.height) {
785
+ parent.activeObj.activePoint.width = shapeSettings.width;
786
+ parent.activeObj.activePoint.height = shapeSettings.height;
787
+ parent.activeObj.activePoint.endX = parent.activeObj.activePoint.startX + parent.activeObj.activePoint.width;
788
+ parent.activeObj.activePoint.endY = parent.activeObj.activePoint.startY + parent.activeObj.activePoint.height;
789
+ }
790
+ parent.activeObj.strokeSettings.strokeColor = shapeSettings.strokeColor;
791
+ parent.activeObj.strokeSettings.fillColor = shapeSettings.fillColor;
792
+ parent.activeObj.opacity = shapeSettings.opacity;
793
+ if (isNullOrUndefined(shapeSettings.degree)) {
794
+ shapeSettings.degree = 0;
795
+ }
796
+ switch (parent.activeObj.shape) {
797
+ case 'ellipse':
798
+ parent.activeObj.activePoint.width = shapeSettings.radius * 2;
799
+ if (shapeSettings.degree) {
800
+ parent.activeObj.rotatedAngle = shapeSettings.degree * (Math.PI / 180);
801
+ }
802
+ break;
803
+ case 'line':
804
+ case 'arrow':
805
+ parent.activeObj.activePoint.width = shapeSettings.length;
806
+ break;
807
+ case 'text':
808
+ parent.activeObj.keyHistory = parent.activeObj.textSettings.text = shapeSettings.text;
809
+ parent.activeObj.textSettings.fontSize = shapeSettings.fontSize;
810
+ parent.activeObj.strokeSettings.strokeColor = shapeSettings.color;
811
+ parent.activeObj.textSettings.fontFamily = shapeSettings.fontFamily;
812
+ break;
813
+ case 'rectangle':
814
+ case 'image':
815
+ if (shapeSettings.degree) {
816
+ parent.activeObj.rotatedAngle = shapeSettings.degree * (Math.PI / 180);
817
+ }
818
+ break;
819
+ }
820
+ if (parent.activeObj.shape === 'text' && parent.activeObj.textSettings) {
821
+ for (var i = 0; i < shapeSettings.fontStyle.length; i++) {
822
+ switch (shapeSettings.fontStyle[i]) {
823
+ case 'bold':
824
+ parent.activeObj.textSettings.bold = true;
825
+ break;
826
+ case 'italic':
827
+ parent.activeObj.textSettings.italic = true;
828
+ break;
829
+ case 'underline':
830
+ parent.activeObj.textSettings.underline = true;
831
+ break;
832
+ }
795
833
  }
796
834
  }
797
835
  }
@@ -810,6 +848,7 @@ var Shape = /** @class */ (function () {
810
848
  Shape.prototype.addLetter = function (letter) {
811
849
  var parent = this.parent;
812
850
  if (parent.textArea.style.display === 'none' && (parent.currObjType.isText || parent.activeObj.shape === 'text')) {
851
+ var fontSize = parent.activeObj.textSettings.fontSize;
813
852
  if (letter === 'Backspace') {
814
853
  this.keyHistory = this.keyHistory.slice(0, -1);
815
854
  }
@@ -818,11 +857,9 @@ var Shape = /** @class */ (function () {
818
857
  }
819
858
  this.upperContext.clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
820
859
  this.updateFontStyles();
821
- var width = this.upperContext.measureText(this.keyHistory).width
822
- + parent.activeObj.textSettings.fontSize * 0.5;
823
- var height = parent.activeObj.textSettings.fontSize + parent.activeObj.textSettings.fontSize * 0.25;
824
- this.upperContext.fillText(this.keyHistory, parent.activeObj.activePoint.startX, parent.activeObj.activePoint.startY +
825
- parent.activeObj.textSettings.fontSize);
860
+ var width = this.upperContext.measureText(this.keyHistory).width + fontSize * 0.5;
861
+ var height = fontSize + fontSize * 0.25;
862
+ this.upperContext.fillText(this.keyHistory, parent.activeObj.activePoint.startX, parent.activeObj.activePoint.startY + fontSize);
826
863
  this.upperContext.clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
827
864
  parent.currObjType.isText = true;
828
865
  parent.notify('selection', { prop: 'setActivePoint', onPropertyChange: false,
@@ -831,18 +868,20 @@ var Shape = /** @class */ (function () {
831
868
  };
832
869
  Shape.prototype.redrawText = function () {
833
870
  var parent = this.parent;
871
+ var _a = parent.activeObj.textSettings, fontSize = _a.fontSize, fontFamily = _a.fontFamily, bold = _a.bold, italic = _a.italic;
834
872
  var fontStyle = '';
835
- if (parent.activeObj.textSettings.bold) {
873
+ if (bold) {
836
874
  fontStyle += 'bold ';
837
875
  }
838
- if (parent.activeObj.textSettings.italic) {
876
+ if (italic) {
839
877
  fontStyle += 'italic ';
840
878
  }
841
- this.upperContext.font = fontStyle + parent.activeObj.textSettings.fontSize + 'px ' + parent.activeObj.textSettings.fontFamily;
879
+ this.upperContext.font = fontStyle + fontSize + 'px ' + fontFamily;
842
880
  var rows = parent.activeObj.keyHistory.split('\n');
843
- var text = parent.textArea.style.display === 'block' ? this.getMaxText(true) : this.getMaxText();
844
- var width = this.upperContext.measureText(text).width + parent.activeObj.textSettings.fontSize * 0.5;
845
- var height = rows.length * (parent.activeObj.textSettings.fontSize + parent.activeObj.textSettings.fontSize * 0.25);
881
+ var text = (parent.textArea.style.display === 'block' || parent.textArea.style.display === 'inline-block') ?
882
+ this.getMaxText(true) : this.getMaxText();
883
+ var width = this.upperContext.measureText(text).width + fontSize * 0.5;
884
+ var height = rows.length * (fontSize + fontSize * 0.25);
846
885
  parent.notify('selection', { prop: 'setTextSelection', onPropertyChange: false,
847
886
  value: { width: width, height: height } });
848
887
  parent.notify('draw', { prop: 'updateActiveObject', onPropertyChange: false, value: { actPoint: parent.activeObj.activePoint, obj: parent.activeObj,
@@ -853,13 +892,15 @@ var Shape = /** @class */ (function () {
853
892
  Shape.prototype.updateTextFromTextArea = function () {
854
893
  var parent = this.parent;
855
894
  var allowUndoRedo = false;
895
+ var fontSize = parent.activeObj.textSettings.fontSize;
896
+ var tempActiveObj = extend({}, parent.activeObj, {}, true);
856
897
  var prevCropObj = extend({}, parent.cropObj, {}, true);
857
898
  var object = { currObj: {} };
858
899
  parent.notify('filter', { prop: 'getCurrentObj', onPropertyChange: false, value: { object: object } });
859
900
  var prevObj = object['currObj'];
860
901
  prevObj.objColl = extend([], parent.objColl, [], true);
861
902
  prevObj.pointColl = extend([], parent.pointColl, [], true);
862
- prevObj.afterCropActions = extend([], this.parent.afterCropActions, [], true);
903
+ prevObj.afterCropActions = extend([], parent.afterCropActions, [], true);
863
904
  var selPointCollObj = { selPointColl: null };
864
905
  parent.notify('freehand-draw', { prop: 'getSelPointColl', onPropertyChange: false,
865
906
  value: { obj: selPointCollObj } });
@@ -871,24 +912,44 @@ var Shape = /** @class */ (function () {
871
912
  parent.textArea.style.display = 'none';
872
913
  parent.textArea.value = '';
873
914
  this.updateFontStyles();
874
- var width = this.upperContext.measureText(parent.activeObj.keyHistory).width +
875
- parent.activeObj.textSettings.fontSize * 0.5;
876
- var height = parent.activeObj.textSettings.fontSize + this.parent.activeObj.textSettings.fontSize * 0.25;
915
+ var width = this.upperContext.measureText(parent.activeObj.keyHistory).width + fontSize * 0.5;
916
+ var height = fontSize + fontSize * 0.25;
877
917
  var rows = parent.activeObj.keyHistory.split('\n');
878
918
  if (rows.length > 1) {
879
919
  height *= rows.length;
880
920
  var widthColl = [];
881
921
  for (var i = 0, len = rows.length; i < len; i++) {
882
- widthColl.push(this.upperContext.measureText(rows[i]).width +
883
- parent.activeObj.textSettings.fontSize * 0.5);
922
+ widthColl.push(this.upperContext.measureText(rows[i]).width + fontSize * 0.5);
884
923
  }
885
924
  width = Math.max.apply(Math, widthColl);
886
925
  }
887
926
  parent.notify('selection', { prop: 'setTextSelection', onPropertyChange: false,
888
927
  value: { width: width, height: height } });
928
+ if (parent.activeObj.rotatedAngle !== 0) {
929
+ var width_1 = parent.activeObj.activePoint.width - tempActiveObj.activePoint.width;
930
+ var height_1 = parent.activeObj.activePoint.height - tempActiveObj.activePoint.height;
931
+ var value = '';
932
+ if (width_1 > 0 && height_1 > 0) {
933
+ value = 'widthHeight';
934
+ }
935
+ else if (width_1 !== 0) {
936
+ value = 'width';
937
+ }
938
+ else if (height_1 !== 0) {
939
+ value = 'height';
940
+ }
941
+ parent.activeObj.activePoint = extend({}, tempActiveObj.activePoint, {}, true);
942
+ parent.notify('selection', { prop: 'adjustRotationPoints', onPropertyChange: false, value: { rectangle: parent.activeObj.activePoint,
943
+ x: width_1, y: height_1, angle: parent.activeObj.rotatedAngle, type: 'text', elem: value } });
944
+ parent.notify('shape', { prop: 'updateFontSize', onPropertyChange: false,
945
+ value: { obj: parent.activeObj } });
946
+ }
889
947
  parent.notify('draw', { prop: 'updateActiveObject', onPropertyChange: false, value: { actPoint: parent.activeObj.activePoint, obj: parent.activeObj,
890
948
  isMouseMove: null, x: null, y: null } });
891
949
  this.updImgRatioForActObj();
950
+ if (parent.activeObj.rotatedAngle !== 0) {
951
+ parent.notify('selection', { prop: 'updPtCollForShpRot', onPropertyChange: false, value: { obj: parent.activeObj } });
952
+ }
892
953
  if (allowUndoRedo) {
893
954
  this.apply(parent.activeObj.shape, parent.activeObj);
894
955
  parent.objColl.push(extend({}, parent.activeObj, {}, true));
@@ -907,7 +968,10 @@ var Shape = /** @class */ (function () {
907
968
  var parent = this.parent;
908
969
  if (parent.objColl.length > 0) {
909
970
  for (var i = 0, len = parent.objColl.length; i < len; i++) {
971
+ var temp = this.lowerContext.filter;
972
+ this.lowerContext.filter = 'none';
910
973
  this.apply(parent.objColl[i].shape, parent.objColl[i]);
974
+ this.lowerContext.filter = temp;
911
975
  this.refreshActiveObj();
912
976
  }
913
977
  parent.notify('draw', { prop: 'applyFrame', value: { ctx: this.lowerContext, frame: parent.frameObj.type, preventImg: true } });
@@ -915,18 +979,21 @@ var Shape = /** @class */ (function () {
915
979
  };
916
980
  Shape.prototype.updImgRatioForActObj = function () {
917
981
  var parent = this.parent;
918
- parent.activeObj.imageRatio = { startX: ((parent.activeObj.activePoint.startX - parent.img.destLeft) /
919
- parent.img.destWidth),
920
- startY: ((parent.activeObj.activePoint.startY - parent.img.destTop) / parent.img.destHeight),
921
- endX: ((parent.activeObj.activePoint.endX - parent.img.destLeft) / parent.img.destWidth),
922
- endY: ((parent.activeObj.activePoint.endY - parent.img.destTop) / parent.img.destHeight),
923
- width: parent.img.destWidth / parent.activeObj.activePoint.width, height: parent.img.destHeight /
924
- parent.activeObj.activePoint.height };
982
+ var destPoints = { startX: parent.img.destLeft, startY: parent.img.destTop,
983
+ width: parent.img.destWidth, height: parent.img.destHeight };
984
+ this.straightenShapes();
985
+ var _a = parent.img, destLeft = _a.destLeft, destTop = _a.destTop, destWidth = _a.destWidth, destHeight = _a.destHeight;
986
+ var activePoint = parent.activeObj.activePoint;
987
+ parent.activeObj.imageRatio = { startX: ((activePoint.startX - destLeft) /
988
+ destWidth), startY: ((activePoint.startY - destTop) / destHeight),
989
+ endX: ((activePoint.endX - destLeft) / destWidth),
990
+ endY: ((activePoint.endY - destTop) / destHeight),
991
+ width: destWidth / activePoint.width, height: destHeight / activePoint.height };
925
992
  if (parent.activeObj.rotationCirclePointColl) {
926
993
  parent.activeObj.rotationCirclePointColl.ratioX = (parent.activeObj.rotationCirclePointColl.x -
927
- parent.img.destLeft) / parent.img.destWidth;
994
+ destLeft) / destWidth;
928
995
  parent.activeObj.rotationCirclePointColl.ratioY = (parent.activeObj.rotationCirclePointColl.y -
929
- parent.img.destTop) / parent.img.destHeight;
996
+ destTop) / destHeight;
930
997
  }
931
998
  if (parent.activeObj.shape === 'path') {
932
999
  this.updatePathRatio(parent.activeObj);
@@ -934,15 +1001,23 @@ var Shape = /** @class */ (function () {
934
1001
  else if (parent.activeObj.shape === 'arrow') {
935
1002
  this.updateArrowRatio(parent.activeObj);
936
1003
  }
1004
+ parent.img.destLeft = destPoints.startX;
1005
+ parent.img.destTop = destPoints.startY;
1006
+ parent.img.destWidth = destPoints.width;
1007
+ parent.img.destHeight = destPoints.height;
937
1008
  };
938
1009
  Shape.prototype.zoomObjColl = function (preventApply) {
939
1010
  var parent = this.parent;
1011
+ var destPoints = { startX: parent.img.destLeft, startY: parent.img.destTop,
1012
+ width: parent.img.destWidth, height: parent.img.destHeight };
1013
+ this.straightenShapes();
1014
+ var _a = parent.img, destLeft = _a.destLeft, destTop = _a.destTop, destWidth = _a.destWidth, destHeight = _a.destHeight;
940
1015
  for (var i = 0, len = parent.objColl.length; i < len; i++) {
941
1016
  var currObj = parent.objColl[i];
942
- currObj.activePoint.startX = (currObj.imageRatio.startX * parent.img.destWidth) + parent.img.destLeft;
943
- currObj.activePoint.startY = (currObj.imageRatio.startY * parent.img.destHeight) + parent.img.destTop;
944
- currObj.activePoint.endX = (currObj.imageRatio.endX * parent.img.destWidth) + parent.img.destLeft;
945
- currObj.activePoint.endY = (currObj.imageRatio.endY * parent.img.destHeight) + parent.img.destTop;
1017
+ currObj.activePoint.startX = (currObj.imageRatio.startX * destWidth) + destLeft;
1018
+ currObj.activePoint.startY = (currObj.imageRatio.startY * destHeight) + destTop;
1019
+ currObj.activePoint.endX = (currObj.imageRatio.endX * destWidth) + destLeft;
1020
+ currObj.activePoint.endY = (currObj.imageRatio.endY * destHeight) + destTop;
946
1021
  currObj = this.updateWidthHeight(currObj);
947
1022
  if (currObj.shape === 'text') {
948
1023
  this.updateFontSize(currObj);
@@ -951,22 +1026,28 @@ var Shape = /** @class */ (function () {
951
1026
  currObj.pointColl = this.getLinePoints(currObj.activePoint.startX, currObj.activePoint.startY, currObj.activePoint.endX, currObj.activePoint.endY);
952
1027
  for (var n = 0, len_1 = currObj.pointColl.length; n < len_1; n++) {
953
1028
  currObj.pointColl[n].ratioX =
954
- (currObj.pointColl[n].x - parent.img.destLeft) / parent.img.destWidth;
1029
+ (currObj.pointColl[n].x - destLeft) / destWidth;
955
1030
  currObj.pointColl[n].ratioY =
956
- (currObj.pointColl[n].y - parent.img.destTop) / parent.img.destHeight;
1031
+ (currObj.pointColl[n].y - destTop) / destHeight;
957
1032
  }
958
1033
  if (currObj.shape === 'arrow') {
959
1034
  this.updateArrowSize(currObj);
960
1035
  }
1036
+ if (parent.transform.straighten !== 0 && (currObj.shape === 'line' || currObj.shape === 'arrow')) {
1037
+ this.straightenShapePoints(currObj);
1038
+ }
961
1039
  }
962
1040
  else if (currObj.shape === 'path') {
963
1041
  for (var l = 0, len_2 = currObj.pointColl.length; l < len_2; l++) {
964
- currObj.pointColl[l].x = (currObj.pointColl[l].ratioX * parent.img.destWidth)
965
- + parent.img.destLeft;
966
- currObj.pointColl[l].y = (currObj.pointColl[l].ratioY * parent.img.destHeight) +
967
- parent.img.destTop;
1042
+ currObj.pointColl[l].x = (currObj.pointColl[l].ratioX * destWidth) +
1043
+ destLeft;
1044
+ currObj.pointColl[l].y = (currObj.pointColl[l].ratioY * destHeight) +
1045
+ destTop;
968
1046
  }
969
1047
  this.updatePathRatio(currObj);
1048
+ if (parent.transform.straighten !== 0) {
1049
+ this.straightenPath(currObj);
1050
+ }
970
1051
  }
971
1052
  parent.notify('draw', { prop: 'updateActiveObject', onPropertyChange: false, value: { actPoint: currObj.activePoint,
972
1053
  obj: currObj } });
@@ -980,23 +1061,134 @@ var Shape = /** @class */ (function () {
980
1061
  }
981
1062
  if (currObj.shape !== 'line' && currObj.shape !== 'arrow' && currObj.shape !== 'path' && currObj.rotatedAngle !== 0) {
982
1063
  this.setPointCollForShapeRotation(currObj);
983
- currObj.rotationCirclePoint.x =
984
- (currObj.rotationCirclePoint.ratioX * parent.img.destWidth) + parent.img.destLeft;
985
- currObj.rotationCirclePoint.y =
986
- (currObj.rotationCirclePoint.ratioY * parent.img.destHeight) + parent.img.destTop;
987
- currObj.rotationCirclePointColl.x =
988
- (currObj.rotationCirclePointColl.ratioX * parent.img.destWidth) +
989
- parent.img.destLeft;
990
- currObj.rotationCirclePointColl.y =
991
- (currObj.rotationCirclePointColl.ratioY * parent.img.destHeight) +
992
- parent.img.destTop;
1064
+ currObj.rotationCirclePoint.x = (currObj.rotationCirclePoint.ratioX * destWidth) + destLeft;
1065
+ currObj.rotationCirclePoint.y = (currObj.rotationCirclePoint.ratioY * destHeight) + destTop;
1066
+ currObj.rotationCirclePointColl.x = (currObj.rotationCirclePointColl.ratioX * destWidth) + destLeft;
1067
+ currObj.rotationCirclePointColl.y = (currObj.rotationCirclePointColl.ratioY * destHeight) + destTop;
1068
+ }
1069
+ }
1070
+ parent.img.destLeft = destPoints.startX;
1071
+ parent.img.destTop = destPoints.startY;
1072
+ parent.img.destWidth = destPoints.width;
1073
+ parent.img.destHeight = destPoints.height;
1074
+ };
1075
+ Shape.prototype.straightenPath = function (obj) {
1076
+ var point;
1077
+ for (var j = 0, len = obj.pointColl.length; j < len; j++) {
1078
+ point = this.straightenPoints(obj.pointColl[j].x, obj.pointColl[j].y);
1079
+ obj.pointColl[j].x = point.x;
1080
+ obj.pointColl[j].y = point.y;
1081
+ }
1082
+ };
1083
+ Shape.prototype.straightenFHD = function () {
1084
+ var parent = this.parent;
1085
+ for (var i = 0, fLen = parent.freehandCounter; i < fLen; i++) {
1086
+ parent.points = extend([], parent.pointColl[i].points, []);
1087
+ var len = parent.points.length;
1088
+ var point = void 0;
1089
+ for (var l = 0; l < len; l++) {
1090
+ point = this.straightenPoints(parent.points[l].x, parent.points[l].y);
1091
+ parent.points[l].x = point.x;
1092
+ parent.points[l].y = point.y;
993
1093
  }
994
1094
  }
1095
+ var selPointCollObj = { selPointColl: null };
1096
+ parent.notify('freehand-draw', { prop: 'getSelPointColl', onPropertyChange: false, value: { obj: selPointCollObj } });
1097
+ for (var i = 0, fLen = parent.freehandCounter; i < fLen; i++) {
1098
+ var len = selPointCollObj['selPointColl'][i].points.length;
1099
+ var point = void 0;
1100
+ for (var l = 0; l < len; l++) {
1101
+ point = this.straightenPoints(selPointCollObj['selPointColl'][i].points[l].x, selPointCollObj['selPointColl'][i].points[l].y);
1102
+ selPointCollObj['selPointColl'][i].points[l].x = point.x;
1103
+ selPointCollObj['selPointColl'][i].points[l].y = point.y;
1104
+ }
1105
+ }
1106
+ var straightenObj = { straightenPoint: null };
1107
+ parent.notify('freehand-draw', { prop: 'getStraightenPoint', onPropertyChange: false, value: { obj: straightenObj } });
1108
+ if (straightenObj['straightenPoint']['x'] && straightenObj['straightenPoint']['y']) {
1109
+ var obj = { angle: 0 };
1110
+ parent.notify('freehand-draw', { prop: 'getStraightenPointAngle', onPropertyChange: false, value: { obj: obj } });
1111
+ var angle = (((parent.transform.straighten === 360 ? 0 : parent.transform.straighten) - obj['angle']) * (Math.PI / 180));
1112
+ var point = this.straightenPoints(straightenObj['straightenPoint']['x'], straightenObj['straightenPoint']['y'], angle);
1113
+ if (angle === 0) {
1114
+ point.x = straightenObj['straightenPoint']['x'];
1115
+ point.y = straightenObj['straightenPoint']['y'];
1116
+ }
1117
+ parent.notify('freehand-draw', { prop: 'setStraightenPoint', onPropertyChange: false, value: { x: point.x, y: point.y } });
1118
+ }
1119
+ };
1120
+ Shape.prototype.straightenPoints = function (x, y, angle) {
1121
+ var parent = this.parent;
1122
+ var center = { x: parent.img.destLeft + (parent.img.destWidth / 2), y: parent.img.destTop + (parent.img.destHeight / 2) };
1123
+ angle = angle ? angle : ((parent.transform.straighten) * (Math.PI / 180));
1124
+ var point = { x: Math.cos(angle) * (x - center.x) - Math.sin(angle) * (y - center.y) + center.x,
1125
+ y: Math.sin(angle) * (x - center.x) + Math.cos(angle) * (y - center.y) + center.y };
1126
+ return point;
1127
+ };
1128
+ Shape.prototype.straightenShapes = function () {
1129
+ var parent = this.parent;
1130
+ var _a = parent.img, destLeft = _a.destLeft, destTop = _a.destTop, destWidth = _a.destWidth, destHeight = _a.destHeight;
1131
+ var straightenObj = { bool: parent.isStraightening };
1132
+ if (!straightenObj['bool'] || parent.transform.straighten === 0) {
1133
+ return;
1134
+ }
1135
+ parent.notify('draw', { prop: 'updateImgCanvasPoints' });
1136
+ var object = { points: null };
1137
+ parent.notify('draw', { prop: 'getImageCanvasPoints', value: { obj: object } });
1138
+ var center = { x: destLeft + (destWidth / 2), y: destTop + (destHeight / 2) };
1139
+ var angle = -((parent.transform.straighten) * (Math.PI / 180));
1140
+ var p1 = { x: Math.cos(angle) * (object['points'][0]['x'] - center.x) - Math.sin(angle) *
1141
+ (object['points'][0]['y'] - center.y) + center.x,
1142
+ y: Math.sin(angle) * (object['points'][0]['x'] - center.x) + Math.cos(angle) *
1143
+ (object['points'][0]['y'] - center.y) + center.y };
1144
+ var p2 = { x: Math.cos(angle) * (object['points'][1]['x'] - center.x) - Math.sin(angle) *
1145
+ (object['points'][1]['y'] - center.y) + center.x,
1146
+ y: Math.sin(angle) * (object['points'][1]['x'] - center.x) + Math.cos(angle) * (object['points'][1]['y']
1147
+ - center.y) + center.y };
1148
+ var p3 = { x: Math.cos(angle) * (object['points'][2]['x'] - center.x) - Math.sin(angle) *
1149
+ (object['points'][2]['y'] - center.y) + center.x,
1150
+ y: Math.sin(angle) * (object['points'][2]['x'] - center.x) + Math.cos(angle) * (object['points'][2]['y']
1151
+ - center.y) + center.y };
1152
+ parent.img.destWidth = p2.x - p1.x;
1153
+ parent.img.destHeight = p3.y - p2.y;
1154
+ parent.img.destLeft = p1.x;
1155
+ parent.img.destTop = p1.y;
1156
+ };
1157
+ Shape.prototype.straightenShapePoints = function (obj, isReverse) {
1158
+ var parent = this.parent;
1159
+ var _a = parent.img, destLeft = _a.destLeft, destTop = _a.destTop, destWidth = _a.destWidth, destHeight = _a.destHeight;
1160
+ var straightenObj = { bool: parent.isStraightening };
1161
+ if (!straightenObj['bool']) {
1162
+ return;
1163
+ }
1164
+ if (obj.shape === 'line' || obj.shape === 'arrow') {
1165
+ obj.activePoint.width = obj.activePoint.endX > obj.activePoint.startX ? obj.activePoint.endX -
1166
+ obj.activePoint.startX : obj.activePoint.startX - obj.activePoint.endX;
1167
+ obj.activePoint.height = obj.activePoint.endY > obj.activePoint.startY ? obj.activePoint.endY -
1168
+ obj.activePoint.startY : obj.activePoint.startY - obj.activePoint.endY;
1169
+ var center = { x: destLeft + (destWidth / 2), y: destTop + (destHeight / 2) };
1170
+ var angle = (isReverse ? -parent.transform.straighten : parent.transform.straighten) * (Math.PI / 180);
1171
+ var start = { x: Math.cos(angle) * (obj.activePoint.startX - center.x) - Math.sin(angle) *
1172
+ (obj.activePoint.startY - center.y) + center.x, y: Math.sin(angle) * (obj.activePoint.startX - center.x) + Math.cos(angle)
1173
+ * (obj.activePoint.startY - center.y) + center.y };
1174
+ var end = { x: Math.cos(angle) * (obj.activePoint.endX - center.x) -
1175
+ Math.sin(angle) * (obj.activePoint.endY - center.y) + center.x, y: Math.sin(angle) * (obj.activePoint.endX - center.x) +
1176
+ Math.cos(angle) * (obj.activePoint.endY - center.y) + center.y };
1177
+ obj.activePoint.startX = start.x;
1178
+ obj.activePoint.startY = start.y;
1179
+ obj.activePoint.endX = end.x;
1180
+ obj.activePoint.endY = end.y;
1181
+ obj.activePoint.width = obj.activePoint.endX > obj.activePoint.startX ? obj.activePoint.endX -
1182
+ obj.activePoint.startX : obj.activePoint.startX - obj.activePoint.endX;
1183
+ obj.activePoint.height = obj.activePoint.endY > obj.activePoint.startY ? obj.activePoint.endY -
1184
+ obj.activePoint.startY : obj.activePoint.startY - obj.activePoint.endY;
1185
+ parent.notify('selection', { prop: 'adjustActObjForLineArrow', onPropertyChange: false, value: { obj: obj } });
1186
+ }
995
1187
  };
996
1188
  Shape.prototype.redrawObj = function (degree) {
997
1189
  var parent = this.parent;
998
1190
  var isShape = false;
999
- if (this.parent.objColl.length > 0) {
1191
+ if (parent.objColl.length > 0) {
1000
1192
  if (degree === 'horizontal' || degree === 'vertical' || degree === 'Horizontal' || degree === 'Vertical' ||
1001
1193
  degree === 'horizontalVertical' || degree === 'verticalHorizontal') {
1002
1194
  this.updateCurrentActiveObjPoint(degree.toLowerCase());
@@ -1023,6 +1215,7 @@ var Shape = /** @class */ (function () {
1023
1215
  Shape.prototype.updateCurrentActiveObjPoint = function (degree) {
1024
1216
  var parent = this.parent;
1025
1217
  var currActObjIndex;
1218
+ var _a = parent.img, destLeft = _a.destLeft, destTop = _a.destTop, destWidth = _a.destWidth, destHeight = _a.destHeight;
1026
1219
  for (var index = 0, len = parent.objColl.length; index < len; index++) {
1027
1220
  var currObj = parent.objColl[index];
1028
1221
  if (parent.activeObj.shape === currObj.shape &&
@@ -1041,42 +1234,39 @@ var Shape = /** @class */ (function () {
1041
1234
  for (var i = 0, len = parent.objColl.length; i < len; i++) {
1042
1235
  var currObj = parent.objColl[i];
1043
1236
  if (currObj.shapeFlip !== parent.transform.currFlipState) {
1044
- if (currObj.activePoint.startX <= parent.img.destLeft + (parent.img.destWidth / 2)) {
1045
- currObj.activePoint.endX = (parent.img.destLeft + parent.img.destWidth) - (currObj.activePoint.startX -
1046
- parent.img.destLeft);
1237
+ if (currObj.activePoint.startX <= destLeft + (destWidth / 2)) {
1238
+ currObj.activePoint.endX = (destLeft + destWidth) - (currObj.activePoint.startX - destLeft);
1047
1239
  currObj.activePoint.startX = currObj.activePoint.endX - currObj.activePoint.width;
1048
1240
  parent.notify('draw', { prop: 'updateActiveObject', onPropertyChange: false, value: { actPoint: currObj.activePoint, obj: currObj } });
1049
1241
  }
1050
- else if (currObj.activePoint.startX >= parent.img.destLeft + (parent.img.destWidth / 2)) {
1051
- currObj.activePoint.startX = parent.img.destLeft + (parent.img.destLeft + parent.img.destWidth -
1052
- currObj.activePoint.endX);
1242
+ else if (currObj.activePoint.startX >= destLeft + (destWidth / 2)) {
1243
+ currObj.activePoint.startX = destLeft + (destLeft + destWidth - currObj.activePoint.endX);
1053
1244
  currObj.activePoint.endX = currObj.activePoint.startX + currObj.activePoint.width;
1054
- parent.notify('draw', { prop: 'updateActiveObject', onPropertyChange: false, value: { actPoint: currObj.activePoint,
1055
- obj: currObj } });
1245
+ parent.notify('draw', { prop: 'updateActiveObject', onPropertyChange: false, value: { actPoint: currObj.activePoint, obj: currObj } });
1056
1246
  }
1057
1247
  if (currObj.shape === 'line' || currObj.shape === 'arrow' || currObj.shape === 'path') {
1058
1248
  this.flipLineArrowObj(currObj, 'horizontal');
1059
1249
  }
1060
1250
  else if (currObj.rotatedAngle !== 0) {
1061
1251
  currObj.rotatedAngle = currObj.rotatedAngle + (Math.PI - currObj.rotatedAngle) * 2;
1062
- if (currObj.rotationCirclePointColl.x <= parent.img.destLeft + (parent.img.destWidth / 2)) {
1063
- currObj.rotationCirclePointColl.x = (parent.img.destLeft + parent.img.destWidth) -
1064
- (currObj.rotationCirclePointColl.x - parent.img.destLeft);
1252
+ if (currObj.rotationCirclePointColl.x <= destLeft + (destWidth / 2)) {
1253
+ currObj.rotationCirclePointColl.x = (destLeft + destWidth) -
1254
+ (currObj.rotationCirclePointColl.x - destLeft);
1065
1255
  }
1066
- else if (currObj.rotationCirclePointColl.x >= parent.img.destLeft + (parent.img.destWidth / 2)) {
1067
- currObj.rotationCirclePointColl.x = parent.img.destLeft +
1068
- (parent.img.destLeft + parent.img.destWidth - currObj.rotationCirclePointColl.x);
1256
+ else if (currObj.rotationCirclePointColl.x >= destLeft + (destWidth / 2)) {
1257
+ currObj.rotationCirclePointColl.x = destLeft +
1258
+ (destLeft + destWidth - currObj.rotationCirclePointColl.x);
1069
1259
  }
1070
1260
  currObj.rotationCirclePointColl.ratioX =
1071
- (currObj.rotationCirclePointColl.x - parent.img.destLeft) / parent.img.destWidth;
1261
+ (currObj.rotationCirclePointColl.x - destLeft) / destWidth;
1072
1262
  }
1073
1263
  currObj.shapeFlip = parent.transform.currFlipState;
1074
- currObj.imageRatio = { startX: ((currObj.activePoint.startX - parent.img.destLeft) / parent.img.destWidth),
1075
- startY: ((currObj.activePoint.startY - parent.img.destTop) / parent.img.destHeight),
1076
- endX: ((currObj.activePoint.endX - parent.img.destLeft) / parent.img.destWidth),
1077
- endY: ((currObj.activePoint.endY - parent.img.destTop) / parent.img.destHeight),
1078
- width: parent.img.destWidth / currObj.activePoint.width,
1079
- height: parent.img.destHeight / currObj.activePoint.height };
1264
+ currObj.imageRatio = { startX: ((currObj.activePoint.startX - destLeft) / destWidth),
1265
+ startY: ((currObj.activePoint.startY - destTop) / destHeight),
1266
+ endX: ((currObj.activePoint.endX - destLeft) / destWidth),
1267
+ endY: ((currObj.activePoint.endY - destTop) / destHeight),
1268
+ width: destWidth / currObj.activePoint.width,
1269
+ height: destHeight / currObj.activePoint.height };
1080
1270
  }
1081
1271
  }
1082
1272
  }
@@ -1084,18 +1274,15 @@ var Shape = /** @class */ (function () {
1084
1274
  for (var i = 0; i < parent.objColl.length; i++) {
1085
1275
  var currObj = parent.objColl[i];
1086
1276
  if (currObj.shapeFlip !== parent.transform.currFlipState) {
1087
- if (currObj.activePoint.startY <= parent.img.destTop + (parent.img.destHeight / 2)) {
1088
- currObj.activePoint.endY = (parent.img.destTop + parent.img.destHeight) -
1089
- (currObj.activePoint.startY - parent.img.destTop);
1277
+ if (currObj.activePoint.startY <= destTop + (destHeight / 2)) {
1278
+ currObj.activePoint.endY = (destTop + destHeight) - (currObj.activePoint.startY - destTop);
1090
1279
  currObj.activePoint.startY = currObj.activePoint.endY - currObj.activePoint.height;
1091
1280
  parent.notify('draw', { prop: 'updateActiveObject', onPropertyChange: false, value: { actPoint: currObj.activePoint,
1092
1281
  obj: currObj } });
1093
1282
  }
1094
- else if (currObj.activePoint.startY >= this.parent.lowerCanvas.height / 2) {
1095
- currObj.activePoint.startY = parent.img.destTop + (parent.img.destTop +
1096
- parent.img.destHeight - currObj.activePoint.endY);
1097
- currObj.activePoint.endY = currObj.activePoint.startY +
1098
- currObj.activePoint.height;
1283
+ else if (currObj.activePoint.startY >= parent.lowerCanvas.height / 2) {
1284
+ currObj.activePoint.startY = destTop + (destTop + destHeight - currObj.activePoint.endY);
1285
+ currObj.activePoint.endY = currObj.activePoint.startY + currObj.activePoint.height;
1099
1286
  parent.notify('draw', { prop: 'updateActiveObject', onPropertyChange: false, value: { actPoint: currObj.activePoint,
1100
1287
  obj: currObj } });
1101
1288
  }
@@ -1105,25 +1292,23 @@ var Shape = /** @class */ (function () {
1105
1292
  }
1106
1293
  else if (currObj.rotatedAngle !== 0) {
1107
1294
  currObj.rotatedAngle = -currObj.rotatedAngle;
1108
- if (currObj.rotationCirclePointColl.y <= parent.img.destTop + (parent.img.destHeight / 2)) {
1109
- currObj.rotationCirclePointColl.y = (parent.img.destTop + parent.img.destHeight) -
1110
- (currObj.rotationCirclePointColl.y - parent.img.destTop);
1295
+ if (currObj.rotationCirclePointColl.y <= destTop + (destHeight / 2)) {
1296
+ currObj.rotationCirclePointColl.y = (destTop + destHeight) - (currObj.rotationCirclePointColl.y - destTop);
1111
1297
  }
1112
- else if (currObj.rotationCirclePointColl.y >= parent.img.destTop +
1113
- (parent.img.destHeight / 2)) {
1114
- currObj.rotationCirclePointColl.y = parent.img.destTop + (parent.img.destTop +
1115
- parent.img.destHeight - currObj.rotationCirclePointColl.y);
1298
+ else if (currObj.rotationCirclePointColl.y >= destTop +
1299
+ (destHeight / 2)) {
1300
+ currObj.rotationCirclePointColl.y = destTop + (destTop + destHeight - currObj.rotationCirclePointColl.y);
1116
1301
  }
1117
1302
  currObj.rotationCirclePointColl.ratioY =
1118
- (currObj.rotationCirclePointColl.y - parent.img.destTop) / parent.img.destHeight;
1303
+ (currObj.rotationCirclePointColl.y - destTop) / destHeight;
1119
1304
  }
1120
1305
  currObj.shapeFlip = parent.transform.currFlipState;
1121
- currObj.imageRatio = { startX: ((currObj.activePoint.startX - parent.img.destLeft) / parent.img.destWidth),
1122
- startY: ((currObj.activePoint.startY - parent.img.destTop) / parent.img.destHeight),
1123
- endX: ((currObj.activePoint.endX - parent.img.destLeft) / parent.img.destWidth),
1124
- endY: ((currObj.activePoint.endY - parent.img.destTop) / parent.img.destHeight),
1125
- width: parent.img.destWidth / currObj.activePoint.width,
1126
- height: parent.img.destHeight / currObj.activePoint.height };
1306
+ currObj.imageRatio = { startX: ((currObj.activePoint.startX - destLeft) / destWidth),
1307
+ startY: ((currObj.activePoint.startY - destTop) / destHeight),
1308
+ endX: ((currObj.activePoint.endX - destLeft) / destWidth),
1309
+ endY: ((currObj.activePoint.endY - destTop) / destHeight),
1310
+ width: destWidth / currObj.activePoint.width,
1311
+ height: destHeight / currObj.activePoint.height };
1127
1312
  }
1128
1313
  }
1129
1314
  }
@@ -1131,28 +1316,28 @@ var Shape = /** @class */ (function () {
1131
1316
  for (var i = 0, len = parent.objColl.length; i < len; i++) {
1132
1317
  var currObj = parent.objColl[i];
1133
1318
  if (currObj.shapeFlip !== parent.transform.currFlipState) {
1134
- if (currObj.activePoint.startX <= parent.img.destLeft + (parent.img.destWidth / 2)) {
1135
- currObj.activePoint.endX = (parent.img.destLeft + parent.img.destWidth) - (currObj.activePoint.startX -
1136
- parent.img.destLeft);
1319
+ if (currObj.activePoint.startX <= destLeft + (destWidth / 2)) {
1320
+ currObj.activePoint.endX = (destLeft + destWidth) - (currObj.activePoint.startX -
1321
+ destLeft);
1137
1322
  currObj.activePoint.startX = currObj.activePoint.endX - currObj.activePoint.width;
1138
1323
  parent.notify('draw', { prop: 'updateActiveObject', onPropertyChange: false, value: { actPoint: currObj.activePoint, obj: currObj } });
1139
1324
  }
1140
- else if (currObj.activePoint.startX >= parent.img.destLeft + (parent.img.destWidth / 2)) {
1141
- currObj.activePoint.startX = parent.img.destLeft + (parent.img.destLeft +
1142
- parent.img.destWidth - currObj.activePoint.endX);
1325
+ else if (currObj.activePoint.startX >= destLeft + (destWidth / 2)) {
1326
+ currObj.activePoint.startX = destLeft + (destLeft +
1327
+ destWidth - currObj.activePoint.endX);
1143
1328
  currObj.activePoint.endX = currObj.activePoint.startX + currObj.activePoint.width;
1144
1329
  parent.notify('draw', { prop: 'updateActiveObject', onPropertyChange: false, value: { actPoint: currObj.activePoint, obj: currObj } });
1145
1330
  }
1146
- if (currObj.activePoint.startY <= parent.img.destTop + (parent.img.destHeight / 2)) {
1147
- currObj.activePoint.endY = (parent.img.destTop + parent.img.destHeight) -
1148
- (currObj.activePoint.startY - parent.img.destTop);
1331
+ if (currObj.activePoint.startY <= destTop + (destHeight / 2)) {
1332
+ currObj.activePoint.endY = (destTop + destHeight) -
1333
+ (currObj.activePoint.startY - destTop);
1149
1334
  currObj.activePoint.startY = currObj.activePoint.endY -
1150
1335
  currObj.activePoint.height;
1151
1336
  parent.notify('draw', { prop: 'updateActiveObject', onPropertyChange: false, value: { actPoint: currObj.activePoint, obj: currObj } });
1152
1337
  }
1153
- else if (currObj.activePoint.startY >= this.parent.lowerCanvas.height / 2) {
1154
- currObj.activePoint.startY = parent.img.destTop + (parent.img.destTop +
1155
- parent.img.destHeight - currObj.activePoint.endY);
1338
+ else if (currObj.activePoint.startY >= parent.lowerCanvas.height / 2) {
1339
+ currObj.activePoint.startY = destTop + (destTop +
1340
+ destHeight - currObj.activePoint.endY);
1156
1341
  currObj.activePoint.endY = currObj.activePoint.startY +
1157
1342
  currObj.activePoint.height;
1158
1343
  parent.notify('draw', { prop: 'updateActiveObject', onPropertyChange: false, value: { actPoint: currObj.activePoint, obj: currObj } });
@@ -1161,12 +1346,12 @@ var Shape = /** @class */ (function () {
1161
1346
  this.flipLineArrowObj(currObj, degree);
1162
1347
  }
1163
1348
  currObj.shapeFlip = parent.transform.currFlipState;
1164
- currObj.imageRatio = { startX: ((currObj.activePoint.startX - parent.img.destLeft) / parent.img.destWidth),
1165
- startY: ((currObj.activePoint.startY - parent.img.destTop) / parent.img.destHeight),
1166
- endX: ((currObj.activePoint.endX - parent.img.destLeft) / parent.img.destWidth),
1167
- endY: ((currObj.activePoint.endY - parent.img.destTop) / parent.img.destHeight),
1168
- width: parent.img.destWidth / currObj.activePoint.width,
1169
- height: parent.img.destHeight / currObj.activePoint.height };
1349
+ currObj.imageRatio = { startX: ((currObj.activePoint.startX - destLeft) / destWidth),
1350
+ startY: ((currObj.activePoint.startY - destTop) / destHeight),
1351
+ endX: ((currObj.activePoint.endX - destLeft) / destWidth),
1352
+ endY: ((currObj.activePoint.endY - destTop) / destHeight),
1353
+ width: destWidth / currObj.activePoint.width,
1354
+ height: destHeight / currObj.activePoint.height };
1170
1355
  }
1171
1356
  }
1172
1357
  }
@@ -1195,45 +1380,41 @@ var Shape = /** @class */ (function () {
1195
1380
  };
1196
1381
  Shape.prototype.rotateObjColl = function () {
1197
1382
  var parent = this.parent;
1383
+ var _a = parent.img, destWidth = _a.destWidth, destHeight = _a.destHeight, destLeft = _a.destLeft, destTop = _a.destTop;
1198
1384
  for (var i = 0, len = parent.objColl.length; i < len; i++) {
1199
1385
  var currObj = parent.objColl[i];
1200
- currObj.activePoint.startY = parent.img.destTop + (parent.img.destHeight * currObj.imageRatio.startX);
1201
- currObj.activePoint.endY = parent.img.destTop + (parent.img.destHeight * currObj.imageRatio.endX);
1202
- currObj.activePoint.startX = (parent.img.destLeft + parent.img.destWidth) -
1203
- (parent.img.destWidth * currObj.imageRatio.endY);
1204
- currObj.activePoint.endX = (parent.img.destLeft + parent.img.destWidth) -
1205
- (parent.img.destWidth * currObj.imageRatio.startY);
1386
+ var shape = currObj.shape;
1387
+ currObj.activePoint.startY = destTop + (destHeight * currObj.imageRatio.startX);
1388
+ currObj.activePoint.endY = destTop + (destHeight * currObj.imageRatio.endX);
1389
+ currObj.activePoint.startX = (destLeft + destWidth) - (destWidth * currObj.imageRatio.endY);
1390
+ currObj.activePoint.endX = (destLeft + destWidth) - (destWidth * currObj.imageRatio.startY);
1206
1391
  currObj = this.updateWidthHeight(parent.objColl[i]);
1207
1392
  this.updateFontSize(currObj);
1208
- if (currObj.shape === 'line' || currObj.shape === 'arrow' ||
1209
- currObj.shape === 'path') {
1393
+ if (shape === 'line' || shape === 'arrow' || shape === 'path') {
1210
1394
  this.rotateLineArrowObj(currObj);
1211
- if (currObj.shape === 'arrow') {
1395
+ if (shape === 'arrow') {
1212
1396
  this.updateArrowSize(currObj);
1213
1397
  }
1214
1398
  }
1215
1399
  else if (currObj.rotatedAngle !== 0) {
1216
- currObj.rotationCirclePointColl.y = parent.img.destTop + (parent.img.destHeight * currObj.rotationCirclePointColl.ratioX);
1217
- currObj.rotationCirclePointColl.x = (parent.img.destLeft + parent.img.destWidth) -
1218
- (parent.img.destWidth * currObj.rotationCirclePointColl.ratioY);
1219
- currObj.rotationCirclePointColl.ratioX = (currObj.rotationCirclePointColl.x
1220
- - parent.img.destLeft) / parent.img.destWidth;
1221
- currObj.rotationCirclePointColl.ratioY = (currObj.rotationCirclePointColl.y
1222
- - parent.img.destTop) / parent.img.destHeight;
1400
+ currObj.rotationCirclePointColl.y = destTop + (destHeight * currObj.rotationCirclePointColl.ratioX);
1401
+ currObj.rotationCirclePointColl.x = (destLeft + destWidth) -
1402
+ (destWidth * currObj.rotationCirclePointColl.ratioY);
1403
+ currObj.rotationCirclePointColl.ratioX = (currObj.rotationCirclePointColl.x - destLeft) / destWidth;
1404
+ currObj.rotationCirclePointColl.ratioY = (currObj.rotationCirclePointColl.y - destTop) / destHeight;
1223
1405
  }
1224
1406
  }
1225
1407
  for (var i = 0, len = parent.objColl.length; i < len; i++) {
1226
1408
  parent.notify('draw', { prop: 'updateActiveObject', onPropertyChange: false, value: { actPoint: parent.objColl[i].activePoint, obj: parent.objColl[i] } });
1227
1409
  }
1228
- // Update current image ratio for all objects
1229
1410
  for (var i = 0, len = parent.objColl.length; i < len; i++) {
1230
1411
  var currObj = parent.objColl[i];
1231
- currObj.imageRatio = { startX: ((currObj.activePoint.startX - parent.img.destLeft) / parent.img.destWidth),
1232
- startY: ((currObj.activePoint.startY - parent.img.destTop) / parent.img.destHeight),
1233
- endX: ((currObj.activePoint.endX - parent.img.destLeft) / parent.img.destWidth),
1234
- endY: ((currObj.activePoint.endY - parent.img.destTop) / parent.img.destHeight),
1235
- width: parent.img.destWidth / currObj.activePoint.width,
1236
- height: parent.img.destHeight / currObj.activePoint.height };
1412
+ currObj.imageRatio = { startX: ((currObj.activePoint.startX - destLeft) / destWidth),
1413
+ startY: ((currObj.activePoint.startY - destTop) / destHeight),
1414
+ endX: ((currObj.activePoint.endX - destLeft) / destWidth),
1415
+ endY: ((currObj.activePoint.endY - destTop) / destHeight),
1416
+ width: destWidth / currObj.activePoint.width,
1417
+ height: destHeight / currObj.activePoint.height };
1237
1418
  }
1238
1419
  };
1239
1420
  Shape.prototype.rotateLineArrowObj = function (obj) {
@@ -1241,15 +1422,16 @@ var Shape = /** @class */ (function () {
1241
1422
  return;
1242
1423
  }
1243
1424
  var parent = this.parent;
1425
+ var _a = parent.img, destWidth = _a.destWidth, destHeight = _a.destHeight, destLeft = _a.destLeft, destTop = _a.destTop;
1244
1426
  if (obj.pointColl.length > 0) {
1245
1427
  for (var n = 0; n < obj.pointColl.length; n++) {
1246
- obj.pointColl[n].y = parent.img.destTop + (parent.img.destHeight * obj.pointColl[n].ratioX);
1247
- obj.pointColl[n].x = (parent.img.destLeft + parent.img.destWidth) - (parent.img.destWidth *
1428
+ obj.pointColl[n].y = destTop + (destHeight * obj.pointColl[n].ratioX);
1429
+ obj.pointColl[n].x = (destLeft + destWidth) - (destWidth *
1248
1430
  obj.pointColl[n].ratioY);
1249
1431
  }
1250
1432
  for (var n = 0; n < obj.pointColl.length; n++) {
1251
- obj.pointColl[n].ratioX = (obj.pointColl[n].x - parent.img.destLeft) / parent.img.destWidth;
1252
- obj.pointColl[n].ratioY = (obj.pointColl[n].y - parent.img.destTop) / parent.img.destHeight;
1433
+ obj.pointColl[n].ratioX = (obj.pointColl[n].x - destLeft) / destWidth;
1434
+ obj.pointColl[n].ratioY = (obj.pointColl[n].y - destTop) / destHeight;
1253
1435
  }
1254
1436
  var prevPoint = void 0;
1255
1437
  if (isNullOrUndefined(obj.pointColl[obj.pointColl.length - 2])) {
@@ -1268,13 +1450,14 @@ var Shape = /** @class */ (function () {
1268
1450
  }
1269
1451
  };
1270
1452
  Shape.prototype.flipLineArrowObj = function (obj, value) {
1453
+ value = value.toLowerCase();
1271
1454
  if (isNullOrUndefined(obj.pointColl)) {
1272
1455
  return;
1273
1456
  }
1274
- if (value.toLowerCase() === 'horizontal') {
1457
+ if (value === 'horizontal') {
1275
1458
  this.lineArrowHorizontalFlip(obj);
1276
1459
  }
1277
- else if (value.toLowerCase() === 'vertical') {
1460
+ else if (value === 'vertical') {
1278
1461
  this.lineArrowVerticalFlip(obj);
1279
1462
  }
1280
1463
  else {
@@ -1297,20 +1480,18 @@ var Shape = /** @class */ (function () {
1297
1480
  };
1298
1481
  Shape.prototype.lineArrowHorizontalFlip = function (obj) {
1299
1482
  var parent = this.parent;
1300
- // Update flip value for point collection
1483
+ var _a = parent.img, destWidth = _a.destWidth, destHeight = _a.destHeight, destLeft = _a.destLeft, destTop = _a.destTop;
1301
1484
  if (obj.shapeFlip !== parent.transform.currFlipState) {
1302
1485
  for (var l = 0, len = obj.pointColl.length; l < len; l++) {
1303
1486
  var currPoint = obj.pointColl[l];
1304
- if (currPoint.x <= parent.img.destLeft + (parent.img.destWidth / 2)) {
1305
- currPoint.x = (parent.img.destLeft + parent.img.destWidth) - (currPoint.x
1306
- - parent.img.destLeft);
1487
+ if (currPoint.x <= destLeft + (destWidth / 2)) {
1488
+ currPoint.x = (destLeft + destWidth) - (currPoint.x - destLeft);
1307
1489
  }
1308
- else if (currPoint.x >= parent.img.destLeft + (parent.img.destWidth / 2)) {
1309
- currPoint.x = parent.img.destLeft + (parent.img.destLeft + parent.img.destWidth -
1310
- currPoint.x);
1490
+ else if (currPoint.x >= destLeft + (destWidth / 2)) {
1491
+ currPoint.x = destLeft + (destLeft + destWidth - currPoint.x);
1311
1492
  }
1312
- currPoint.ratioX = (currPoint.x - parent.img.destLeft) / parent.img.destWidth;
1313
- currPoint.ratioY = (currPoint.y - parent.img.destTop) / parent.img.destHeight;
1493
+ currPoint.ratioX = (currPoint.x - destLeft) / destWidth;
1494
+ currPoint.ratioY = (currPoint.y - destTop) / destHeight;
1314
1495
  }
1315
1496
  if (obj.shape === 'arrow') {
1316
1497
  var value = obj.start;
@@ -1322,20 +1503,18 @@ var Shape = /** @class */ (function () {
1322
1503
  };
1323
1504
  Shape.prototype.lineArrowVerticalFlip = function (obj) {
1324
1505
  var parent = this.parent;
1325
- // Update flip value for point collection
1506
+ var _a = parent.img, destWidth = _a.destWidth, destHeight = _a.destHeight, destLeft = _a.destLeft, destTop = _a.destTop;
1326
1507
  if (obj.shapeFlip !== parent.transform.currFlipState) {
1327
1508
  for (var l = 0, len = obj.pointColl.length; l < len; l++) {
1328
1509
  var currPoint = obj.pointColl[l];
1329
- if (currPoint.y <= parent.img.destTop + (parent.img.destHeight / 2)) {
1330
- currPoint.y = (parent.img.destTop + parent.img.destHeight) -
1331
- (currPoint.y - parent.img.destTop);
1510
+ if (currPoint.y <= destTop + (destHeight / 2)) {
1511
+ currPoint.y = (destTop + destHeight) - (currPoint.y - destTop);
1332
1512
  }
1333
- else if (currPoint.y >= parent.img.destTop + (parent.img.destHeight / 2)) {
1334
- currPoint.y = parent.img.destTop + (parent.img.destTop + parent.img.destHeight -
1335
- currPoint.y);
1513
+ else if (currPoint.y >= destTop + (destHeight / 2)) {
1514
+ currPoint.y = destTop + (destTop + destHeight - currPoint.y);
1336
1515
  }
1337
- currPoint.ratioX = (currPoint.x - parent.img.destLeft) / parent.img.destWidth;
1338
- currPoint.ratioY = (currPoint.y - parent.img.destTop) / parent.img.destHeight;
1516
+ currPoint.ratioX = (currPoint.x - destLeft) / destWidth;
1517
+ currPoint.ratioY = (currPoint.y - destTop) / destHeight;
1339
1518
  }
1340
1519
  obj.shapeFlip = parent.transform.currFlipState;
1341
1520
  }
@@ -1357,20 +1536,23 @@ var Shape = /** @class */ (function () {
1357
1536
  var parent = this.parent;
1358
1537
  var degree = this.getRotDegOfShape(parent.activeObj);
1359
1538
  this.transformTextArea();
1360
- if (!isBlazor()) {
1361
- parent.notify('toolbar', { prop: 'destroy-qa-toolbar', onPropertyChange: false });
1539
+ if (isBlazor()) {
1540
+ parent.updateToolbar(parent.element, 'destroyQuickAccessToolbar');
1362
1541
  }
1363
1542
  else {
1364
- parent.updateToolbar(parent.element, 'destroyQuickAccessToolbar');
1543
+ parent.notify('toolbar', { prop: 'destroy-qa-toolbar', onPropertyChange: false });
1365
1544
  }
1366
- if (parent.element.querySelector('#' + parent.element.id + '_duplicate')) {
1367
- parent.element.querySelector('#' + parent.element.id + '_duplicate').classList.add('e-disabled');
1545
+ var dupElem = parent.element.querySelector('#' + parent.element.id + '_duplicate');
1546
+ var removeElem = parent.element.querySelector('#' + parent.element.id + '_remove');
1547
+ var editTextElem = parent.element.querySelector('#' + parent.element.id + '_editText');
1548
+ if (dupElem) {
1549
+ dupElem.classList.add('e-disabled');
1368
1550
  }
1369
- if (parent.element.querySelector('#' + parent.element.id + '_remove')) {
1370
- parent.element.querySelector('#' + parent.element.id + '_remove').classList.add('e-disabled');
1551
+ if (removeElem) {
1552
+ removeElem.classList.add('e-disabled');
1371
1553
  }
1372
- if (parent.element.querySelector('#' + parent.element.id + '_editText')) {
1373
- parent.element.querySelector('#' + parent.element.id + '_editText').classList.add('e-disabled');
1554
+ if (editTextElem) {
1555
+ editTextElem.classList.add('e-disabled');
1374
1556
  }
1375
1557
  parent.textArea.style.display = 'block';
1376
1558
  parent.textArea.style.left = x + 'px';
@@ -1402,6 +1584,9 @@ var Shape = /** @class */ (function () {
1402
1584
  if (obj['flipColl'].length <= 1) {
1403
1585
  this.setTextBoxHeight();
1404
1586
  }
1587
+ if (parseFloat(parent.textArea.style.maxHeight) < parent.activeObj.textSettings.fontSize) {
1588
+ parent.textArea.style.maxHeight = parent.activeObj.textSettings.fontSize + 'px';
1589
+ }
1405
1590
  if (degree % 90 === 0 && degree % 180 !== 0) {
1406
1591
  if (parseFloat(parent.textArea.style.left) + parseFloat(parent.textArea.style.width) > parent.img.destTop +
1407
1592
  parent.img.destHeight) {
@@ -1414,12 +1599,83 @@ var Shape = /** @class */ (function () {
1414
1599
  this.alignTextAreaIntoCanvas();
1415
1600
  }
1416
1601
  }
1602
+ // Limit text area
1603
+ if (actObj.rotatedAngle !== 0) {
1604
+ var tempLeft = parseFloat(parent.textArea.style.left);
1605
+ var tempTop = parseFloat(parent.textArea.style.top);
1606
+ if (actObj.flipObjColl.length > 0) {
1607
+ var panObj = { panRegion: '' };
1608
+ var _b = parent.lowerCanvas, clientWidth = _b.clientWidth, clientHeight = _b.clientHeight;
1609
+ var center_1 = { x: 0, y: 0 };
1610
+ parent.notify('crop', { prop: 'getCurrFlipState', onPropertyChange: false,
1611
+ value: { panObj: panObj } });
1612
+ if (panObj['panRegion'] !== '') {
1613
+ if (panObj['panRegion'] === 'horizontal') {
1614
+ center_1.x = clientWidth - (clientWidth / 2);
1615
+ tempLeft = (center_1.x - tempLeft) + center_1.x;
1616
+ }
1617
+ else if (panObj['panRegion'] === 'vertical') {
1618
+ center_1.y = clientHeight - (clientHeight / 2);
1619
+ tempTop = (center_1.y - tempTop) + center_1.y;
1620
+ }
1621
+ else {
1622
+ center_1 = { x: clientWidth - (clientWidth / 2), y: clientHeight - (clientHeight / 2) };
1623
+ tempLeft = (center_1.x - tempLeft) + center_1.x;
1624
+ tempTop = (center_1.y - tempTop) + center_1.y;
1625
+ }
1626
+ }
1627
+ }
1628
+ var left = tempLeft + parseFloat(parent.textArea.style.width);
1629
+ var top_1 = tempTop + parseFloat(parent.textArea.style.height);
1630
+ var width1 = parseFloat(parent.textArea.style.width);
1631
+ var height1 = parseFloat(parent.textArea.style.height);
1632
+ var center = { x: left - (width1 / 2), y: top_1 - (height1 / 2) };
1633
+ var cosAngle = Math.cos(actObj.rotatedAngle);
1634
+ var sinAngle = Math.sin(actObj.rotatedAngle);
1635
+ var p1 = { x: cosAngle * (left - center.x) - sinAngle * (top_1 - center.y) + center.x,
1636
+ y: sinAngle * (left - center.x) + cosAngle * (top_1 - center.y) + center.y };
1637
+ if (p1.x > parent.img.destLeft && p1.x < parent.img.destLeft + parent.img.destWidth &&
1638
+ p1.y > parent.img.destTop && p1.y + parseFloat(parent.textArea.style.fontSize) < parent.img.destTop + parent.img.destHeight) {
1639
+ parent.textArea.style.width = parent.textArea.style.width;
1640
+ }
1641
+ else {
1642
+ var count = 0;
1643
+ var width2 = parseFloat(parent.textArea.style.width);
1644
+ while (true) {
1645
+ count++;
1646
+ width1 -= 1;
1647
+ left = tempLeft + width1;
1648
+ center = { x: left - (width1 / 2), y: top_1 - (height1 / 2) };
1649
+ p1 = { x: cosAngle * (left - center.x) - sinAngle * (top_1 - center.y) + center.x,
1650
+ y: sinAngle * (left - center.x) + cosAngle * (top_1 - center.y) + center.y };
1651
+ if ((p1.x > parent.img.destLeft && p1.x < parent.img.destLeft + parent.img.destWidth &&
1652
+ p1.y > parent.img.destTop && p1.y + parseFloat(parent.textArea.style.fontSize) < parent.img.destTop + parent.img.destHeight) ||
1653
+ count === width2) {
1654
+ parent.textArea.style.width = width1 + 'px';
1655
+ break;
1656
+ }
1657
+ }
1658
+ }
1659
+ }
1417
1660
  parent.notify('selection', { prop: 'clearUpperCanvas', onPropertyChange: false });
1418
1661
  };
1419
1662
  Shape.prototype.setTextBoxWidth = function (e) {
1420
1663
  var parent = this.parent;
1664
+ if (parent.activeObj.rotatedAngle !== 0) {
1665
+ parent.textArea.style.whiteSpace = 'nowrap';
1666
+ parent.textArea.style.textOverflow = 'ellipsis';
1667
+ parent.textArea.style.display = 'inline-block';
1668
+ return;
1669
+ }
1670
+ else {
1671
+ parent.textArea.style.whiteSpace = '';
1672
+ parent.textArea.style.textOverflow = '';
1673
+ if (parent.textArea.style.display === 'inline-block') {
1674
+ parent.textArea.style.display = 'block';
1675
+ }
1676
+ }
1421
1677
  var text = this.getMaxText(true);
1422
- if (parent.textArea.style.display === 'block') {
1678
+ if (parent.textArea.style.display === 'block' || parent.textArea.style.display === 'inline-block') {
1423
1679
  this.updateFontStyles(true);
1424
1680
  }
1425
1681
  else {
@@ -1562,15 +1818,15 @@ var Shape = /** @class */ (function () {
1562
1818
  var obj = { shape: null };
1563
1819
  parent.notify('selection', { prop: 'getCurrentDrawingShape', value: { obj: obj } });
1564
1820
  if (obj['shape'] === 'path') {
1565
- var prevCropObj = extend({}, this.parent.cropObj, {}, true);
1821
+ var prevCropObj = extend({}, parent.cropObj, {}, true);
1566
1822
  var object = { currObj: {} };
1567
- this.parent.notify('filter', { prop: 'getCurrentObj', onPropertyChange: false, value: { object: object } });
1823
+ parent.notify('filter', { prop: 'getCurrentObj', onPropertyChange: false, value: { object: object } });
1568
1824
  var prevObj = object['currObj'];
1569
- prevObj.objColl = extend([], this.parent.objColl, [], true);
1570
- prevObj.pointColl = extend([], this.parent.pointColl, [], true);
1571
- prevObj.afterCropActions = extend([], this.parent.afterCropActions, [], true);
1825
+ prevObj.objColl = extend([], parent.objColl, [], true);
1826
+ prevObj.pointColl = extend([], parent.pointColl, [], true);
1827
+ prevObj.afterCropActions = extend([], parent.afterCropActions, [], true);
1572
1828
  var selPointCollObj = { selPointColl: null };
1573
- this.parent.notify('freehand-draw', { prop: 'getSelPointColl', onPropertyChange: false,
1829
+ parent.notify('freehand-draw', { prop: 'getSelPointColl', onPropertyChange: false,
1574
1830
  value: { obj: selPointCollObj } });
1575
1831
  prevObj.selPointColl = extend([], selPointCollObj['selPointColl'], [], true);
1576
1832
  parent.notify('selection', { prop: 'setCurrentDrawingShape', value: { value: '' } });
@@ -1579,6 +1835,9 @@ var Shape = /** @class */ (function () {
1579
1835
  parent.activeObj.pointColl.pop();
1580
1836
  }
1581
1837
  this.updatePathRatio(parent.activeObj);
1838
+ if (isNullOrUndefined(parent.activeObj.imageRatio)) {
1839
+ parent.notify('shape', { prop: 'updImgRatioForActObj', onPropertyChange: false });
1840
+ }
1582
1841
  parent.objColl.push(parent.activeObj);
1583
1842
  parent.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false,
1584
1843
  value: { operation: 'shapeTransform', previousObj: prevObj, previousObjColl: prevObj.objColl,
@@ -1588,6 +1847,8 @@ var Shape = /** @class */ (function () {
1588
1847
  parent.objColl.pop();
1589
1848
  if (e) {
1590
1849
  parent.notify('selection', { prop: 'mouseUpEventHandler', value: { e: e } });
1850
+ this.lowerContext.clearRect(0, 0, parent.lowerCanvas.width, parent.lowerCanvas.height);
1851
+ parent.notify('draw', { prop: 'redrawImgWithObj', onPropertyChange: false });
1591
1852
  }
1592
1853
  parent.notify('draw', { prop: 'setNewPath', value: { bool: true } });
1593
1854
  if (parent.objColl[parent.objColl.length - 1]) {
@@ -1602,8 +1863,8 @@ var Shape = /** @class */ (function () {
1602
1863
  var obj_1 = { shapeSettingsObj: {} };
1603
1864
  parent.notify('selection', { prop: 'updatePrevShapeSettings', onPropertyChange: false, value: { obj: obj_1 } });
1604
1865
  var shapeSettings = obj_1['shapeSettingsObj'];
1605
- var shapeResizingArgs = { action: 'draw-end', previousShapeSettings: shapeSettings };
1606
- var shapeMovingArgs = { action: 'move', previousShapeSettings: shapeSettings };
1866
+ var shapeResizingArgs = { cancel: false, action: 'draw-end', previousShapeSettings: shapeSettings };
1867
+ var shapeMovingArgs = { cancel: false, action: 'move', previousShapeSettings: shapeSettings };
1607
1868
  parent.notify('selection', { prop: 'triggerShapeChange', onPropertyChange: false,
1608
1869
  value: { shapeResizingArgs: shapeResizingArgs, shapeMovingArgs: shapeMovingArgs, type: 'mouse-up' } });
1609
1870
  }
@@ -1612,8 +1873,25 @@ var Shape = /** @class */ (function () {
1612
1873
  Shape.prototype.findTextTarget = function (e) {
1613
1874
  var parent = this.parent;
1614
1875
  if (parent.activeObj.shape !== 'text') {
1615
- this.stopPathDrawing(e, null);
1616
- return;
1876
+ if (parent.activeObj.shape === 'path') {
1877
+ this.stopPathDrawing(e, null);
1878
+ return;
1879
+ }
1880
+ else if (e.type === 'dblclick') {
1881
+ var activeObj = extend({}, parent.activeObj, {}, true);
1882
+ var objColl = extend([], parent.objColl, [], true);
1883
+ var obj = { bool: null };
1884
+ parent.notify('selection', { prop: 'findTargetObj', onPropertyChange: false,
1885
+ value: { x: e.clientX, y: e.clientY, isCrop: false, obj: obj } });
1886
+ parent.objColl = objColl;
1887
+ if (!obj['bool'] || parent.activeObj.shape !== 'text') {
1888
+ parent.activeObj = extend({}, activeObj, {}, true);
1889
+ return;
1890
+ }
1891
+ }
1892
+ else {
1893
+ return;
1894
+ }
1617
1895
  }
1618
1896
  var x;
1619
1897
  var y;
@@ -1638,7 +1916,7 @@ var Shape = /** @class */ (function () {
1638
1916
  parent.updateToolbar(parent.element, 'enableDisableToolbarBtn', 'textAreaClicked');
1639
1917
  }
1640
1918
  if (!isNullOrUndefined(x) && !isNullOrUndefined(y)) {
1641
- var bbox = this.parent.lowerCanvas.getBoundingClientRect();
1919
+ var bbox = parent.lowerCanvas.getBoundingClientRect();
1642
1920
  x -= bbox.left;
1643
1921
  y -= bbox.top;
1644
1922
  var flip = '';
@@ -1671,11 +1949,12 @@ var Shape = /** @class */ (function () {
1671
1949
  }
1672
1950
  }
1673
1951
  this.refreshActiveObj();
1674
- this.upperContext.clearRect(0, 0, this.parent.upperCanvas.width, this.parent.upperCanvas.height);
1675
- this.lowerContext.clearRect(0, 0, this.parent.upperCanvas.width, this.parent.upperCanvas.height);
1952
+ this.upperContext.clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
1953
+ this.lowerContext.clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
1676
1954
  parent.notify('draw', { prop: 'redrawImgWithObj', onPropertyChange: false });
1677
- this.parent.notify('draw', { prop: 'clearOuterCanvas', onPropertyChange: false, value: { context: this.lowerContext } });
1678
- this.parent.notify('draw', { prop: 'clearOuterCanvas', onPropertyChange: false, value: { context: this.upperContext } });
1955
+ parent.notify('draw', { prop: 'redrawDownScale' });
1956
+ parent.notify('draw', { prop: 'clearOuterCanvas', onPropertyChange: false, value: { context: this.lowerContext } });
1957
+ parent.notify('draw', { prop: 'clearOuterCanvas', onPropertyChange: false, value: { context: this.upperContext } });
1679
1958
  if ((parent.currSelectionPoint && parent.currSelectionPoint.shape === 'crop-circle') || parent.isCircleCrop) {
1680
1959
  parent.notify('crop', { prop: 'cropCircle', onPropertyChange: false,
1681
1960
  value: { context: this.lowerContext, isSave: null, isFlip: null } });
@@ -1683,11 +1962,29 @@ var Shape = /** @class */ (function () {
1683
1962
  parent.activeObj = temp;
1684
1963
  this.updateFontStyles();
1685
1964
  var actObj = extend({}, parent.activeObj, {}, true);
1686
- if (x >= (actObj.activePoint.startX - (actObj.topLeftCircle.radius * 2)) &&
1687
- x <= (actObj.activePoint.endX + (actObj.topLeftCircle.radius * 2)) &&
1688
- y >= (actObj.activePoint.startY - (actObj.topLeftCircle.radius * 2)) &&
1689
- y <= (actObj.activePoint.endY + (actObj.topLeftCircle.radius * 2))) {
1690
- this.upperContext.clearRect(0, 0, this.parent.upperCanvas.width, this.parent.upperCanvas.height);
1965
+ var radius = actObj.topLeftCircle.radius;
1966
+ var _a = actObj.activePoint, startX = _a.startX, startY = _a.startY, endX = _a.endX, endY = _a.endY, width = _a.width, height = _a.height;
1967
+ var center = { x: startX + (width / 2), y: startY +
1968
+ (height / 2) };
1969
+ var cosAngle = Math.cos(actObj.rotatedAngle);
1970
+ var sinAngle = Math.sin(actObj.rotatedAngle);
1971
+ var p1 = { x: cosAngle * (startX - center.x) - sinAngle * (startY - center.y) + center.x,
1972
+ y: sinAngle * (startX - center.x) + cosAngle * (startY - center.y) + center.y };
1973
+ var p2 = { x: cosAngle * (endX - center.x) - sinAngle * (startY - center.y) + center.x,
1974
+ y: sinAngle * (endX - center.x) + cosAngle * (startY - center.y) + center.y };
1975
+ var p3 = { x: cosAngle * (startX - center.x) - sinAngle * (endY - center.y) + center.x,
1976
+ y: sinAngle * (startX - center.x) + cosAngle * (endY - center.y) + center.y };
1977
+ var p4 = { x: cosAngle * (endX - center.x) - sinAngle * (endY - center.y) + center.x,
1978
+ y: sinAngle * (endX - center.x) + cosAngle * (endY - center.y) + center.y };
1979
+ var obj = { position: null, x: x, y: y, x1: p1.x, y1: p1.y, x2: p2.x, y2: p2.y,
1980
+ x3: p3.x, y3: p3.y, x4: p4.x, y4: p4.y };
1981
+ parent.notify('draw', { prop: 'checkPointPosition', onPropertyChange: false, value: { obj: obj } });
1982
+ if ((actObj.rotatedAngle !== 0 && (obj['position'] === 'inside' || obj['position'] === 'on')) ||
1983
+ (actObj.rotatedAngle === 0 && x >= (actObj.activePoint.startX - (radius * 2)) &&
1984
+ x <= (actObj.activePoint.endX + (radius * 2)) &&
1985
+ y >= (actObj.activePoint.startY - (radius * 2)) &&
1986
+ y <= (actObj.activePoint.endY + (radius * 2)))) {
1987
+ this.upperContext.clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
1691
1988
  if (actObj.flipObjColl.length === 4) {
1692
1989
  actObj.flipObjColl = [];
1693
1990
  flip = '';
@@ -1707,8 +2004,12 @@ var Shape = /** @class */ (function () {
1707
2004
  y = points.y;
1708
2005
  }
1709
2006
  if (parent.activeObj.rotatedAngle !== 0) {
1710
- x = parent.activeObj.horTopLinePointColl[0].x;
1711
- y = parent.activeObj.horTopLinePointColl[0].y;
2007
+ var point = this.getTextBoxPosition(parent.activeObj);
2008
+ x = point.x;
2009
+ y = point.y;
2010
+ point = this.setFlipState(x, y, parent.activeObj);
2011
+ x = point.x;
2012
+ y = point.y;
1712
2013
  }
1713
2014
  this.renderTextArea(x, y, actObj);
1714
2015
  }
@@ -1717,7 +2018,8 @@ var Shape = /** @class */ (function () {
1717
2018
  }
1718
2019
  }
1719
2020
  }
1720
- else if (parent.textArea.style.display === 'block' && this.selectedText() !== '' && e.type === 'mousedown') {
2021
+ else if ((parent.textArea.style.display === 'block' || parent.textArea.style.display === 'inline-block')
2022
+ && this.selectedText() !== '' && e.type === 'mousedown') {
1721
2023
  var temp = parent.textArea.value;
1722
2024
  parent.textArea.value += 'a';
1723
2025
  parent.textArea.value = temp;
@@ -1726,6 +2028,67 @@ var Shape = /** @class */ (function () {
1726
2028
  parent.textArea.style.display = 'block';
1727
2029
  }
1728
2030
  };
2031
+ Shape.prototype.getTextBoxPosition = function (obj, object) {
2032
+ var point = { x: 0, y: 0 };
2033
+ var _a = obj.activePoint, startX = _a.startX, startY = _a.startY, endX = _a.endX, endY = _a.endY, width = _a.width, height = _a.height;
2034
+ var center = { x: startX + (width / 2), y: startY + (height / 2) };
2035
+ var cosAngle = Math.cos(obj.rotatedAngle);
2036
+ var sinAngle = Math.sin(obj.rotatedAngle);
2037
+ var p1 = { x: cosAngle * (startX - center.x) - sinAngle * (startY - center.y) + center.x,
2038
+ y: sinAngle * (startX - center.x) + cosAngle * (startY - center.y) + center.y };
2039
+ var p2 = { x: cosAngle * (endX - center.x) - sinAngle * (startY - center.y) + center.x,
2040
+ y: sinAngle * (endX - center.x) + cosAngle * (startY - center.y) + center.y };
2041
+ var p3 = { x: cosAngle * (startX - center.x) - sinAngle * (endY - center.y) + center.x,
2042
+ y: sinAngle * (startX - center.x) + cosAngle * (endY - center.y) + center.y };
2043
+ var p4 = { x: cosAngle * (endX - center.x) - sinAngle * (endY - center.y) + center.x,
2044
+ y: sinAngle * (endX - center.x) + cosAngle * (endY - center.y) + center.y };
2045
+ var degree = this.getRotDegOfShape(obj);
2046
+ if (degree === 0 || degree === 360) {
2047
+ point = { x: p1.x, y: p1.y };
2048
+ }
2049
+ else if (degree === 90 || degree === -270) {
2050
+ point = { x: p2.x, y: p2.y };
2051
+ }
2052
+ else if (degree === 180 || degree === -180) {
2053
+ point = { x: p4.x, y: p4.y };
2054
+ }
2055
+ else if (degree === 270 || degree === -90) {
2056
+ point = { x: p3.x, y: p3.y };
2057
+ }
2058
+ if (object) {
2059
+ object['x'] = point.x;
2060
+ object['y'] = point.y;
2061
+ }
2062
+ return point;
2063
+ };
2064
+ Shape.prototype.setFlipState = function (x, y, obj, object) {
2065
+ var parent = this.parent;
2066
+ var panObj = { panRegion: '' };
2067
+ var _a = parent.lowerCanvas, clientWidth = _a.clientWidth, clientHeight = _a.clientHeight;
2068
+ var center = { x: 0, y: 0 };
2069
+ parent.notify('crop', { prop: 'getCurrFlipState', onPropertyChange: false,
2070
+ value: { panObj: panObj } });
2071
+ if (panObj['panRegion'] !== '') {
2072
+ if (panObj['panRegion'] === 'horizontal') {
2073
+ center.x = clientWidth - (clientWidth / 2);
2074
+ x = (center.x - x) + center.x;
2075
+ }
2076
+ else if (panObj['panRegion'] === 'vertical') {
2077
+ center.y = clientHeight - (clientHeight / 2);
2078
+ y = (center.y - y) + center.y;
2079
+ }
2080
+ else {
2081
+ center = { x: clientWidth - (clientWidth / 2), y: clientHeight - (clientHeight / 2) };
2082
+ x = (center.x - x) + center.x;
2083
+ y = (center.y - y) + center.y;
2084
+ }
2085
+ }
2086
+ if (object) {
2087
+ object['x'] = x;
2088
+ object['y'] = y;
2089
+ }
2090
+ return { x: x, y: y };
2091
+ };
1729
2092
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1730
2093
  Shape.prototype.fileChanged = function (e) {
1731
2094
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
@@ -1745,27 +2108,28 @@ var Shape = /** @class */ (function () {
1745
2108
  document.getElementById(this.parent.element.id + '_fileUpload').value = '';
1746
2109
  }
1747
2110
  };
1748
- Shape.prototype.onLoadImgShape = function (x, y, width, height, url, isSelect, degree, isAspectRatio) {
2111
+ Shape.prototype.onLoadImgShape = function (x, y, width, height, url, isSelect, degree, isAspectRatio, opacity) {
1749
2112
  // eslint-disable-next-line @typescript-eslint/no-this-alias
1750
2113
  var proxy = this;
2114
+ var parent = this.parent;
1751
2115
  if (typeof (url) === 'string') {
1752
2116
  this.shapeImg.src = url;
1753
2117
  }
1754
2118
  else {
1755
- this.parent.inMemoryCanvas.width = url.width;
1756
- this.parent.inMemoryCanvas.height = url.height;
1757
- this.parent.inMemoryCanvas.getContext('2d').putImageData(url, 0, 0);
1758
- this.shapeImg.src = this.parent.inMemoryCanvas.toDataURL();
2119
+ parent.inMemoryCanvas.width = url.width;
2120
+ parent.inMemoryCanvas.height = url.height;
2121
+ parent.inMemoryCanvas.getContext('2d').putImageData(url, 0, 0);
2122
+ this.shapeImg.src = parent.inMemoryCanvas.toDataURL();
1759
2123
  }
1760
2124
  this.prevObjColl();
1761
- this.parent.activeObj.shape = 'image';
2125
+ parent.activeObj.shape = 'image';
1762
2126
  this.initShapeProps();
1763
2127
  this.shapeImg.onload = function () {
1764
2128
  proxy.upperContext.drawImage(proxy.shapeImg, 0, 0, proxy.shapeImg.width, proxy.shapeImg.height);
1765
- proxy.updateImgCanvas(isSelect, x, y, width, height, degree, isAspectRatio);
2129
+ proxy.updateImgCanvas(isSelect, x, y, width, height, degree, isAspectRatio, opacity);
1766
2130
  };
1767
2131
  };
1768
- Shape.prototype.updateImgCanvas = function (isSelect, x, y, width, height, degree, isAspectRatio) {
2132
+ Shape.prototype.updateImgCanvas = function (isSelect, x, y, width, height, degree, isAspectRatio, opacity) {
1769
2133
  var _this = this;
1770
2134
  var parent = this.parent;
1771
2135
  parent.activeObj.imageElement = this.shapeImg;
@@ -1800,6 +2164,9 @@ var Shape = /** @class */ (function () {
1800
2164
  dimObj = { width: width, height: height };
1801
2165
  }
1802
2166
  }
2167
+ if (opacity !== null && opacity !== undefined) {
2168
+ parent.activeObj.opacity = opacity;
2169
+ }
1803
2170
  this.updateObj(dimObj, x, y);
1804
2171
  parent.notify('draw', { prop: 'drawObject', onPropertyChange: false, value: { canvas: 'duplicate' } });
1805
2172
  this.shapeImg = null;
@@ -1810,11 +2177,11 @@ var Shape = /** @class */ (function () {
1810
2177
  var obj = { shapeSettingsObj: {} };
1811
2178
  parent.notify('selection', { prop: 'updatePrevShapeSettings', onPropertyChange: false, value: { obj: obj } });
1812
2179
  var shapeSettings = obj['shapeSettingsObj'];
1813
- var shapeChangingArgs = { action: 'insert', previousShapeSettings: shapeSettings,
2180
+ var shapeChangingArgs = { cancel: false, action: 'insert', previousShapeSettings: shapeSettings,
1814
2181
  currentShapeSettings: shapeSettings };
1815
2182
  if (isBlazor() && parent.events && parent.events.shapeChanging.hasDelegate === true) {
1816
2183
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
1817
- parent.dotNetRef.invokeMethodAsync('ShapeEventAsync', 'OnShape', shapeChangingArgs).then(function (shapeChangingArgs) {
2184
+ parent.dotNetRef.invokeMethodAsync('ShapeEventAsync', 'OnShape', shapeChangingArgs, null).then(function (shapeChangingArgs) {
1818
2185
  _this.drawShapeImageEvent(shapeChangingArgs, isSelect);
1819
2186
  if (parent.isPublicMethod) {
1820
2187
  parent.notify('undo-redo', { prop: 'updateUndoRedo', onPropertyChange: false });
@@ -1849,61 +2216,63 @@ var Shape = /** @class */ (function () {
1849
2216
  };
1850
2217
  Shape.prototype.setTextBoxPos = function (actObj, degree, flip, x, y) {
1851
2218
  var point = { x: x, y: y };
2219
+ var _a = actObj.activePoint, startX = _a.startX, startY = _a.startY, endX = _a.endX, endY = _a.endY;
2220
+ flip = flip.toLowerCase();
1852
2221
  switch (degree) {
1853
2222
  case 0:
1854
- if (flip.toLowerCase() === 'horizontal') {
1855
- point.x = actObj.activePoint.endX;
1856
- point.y = actObj.activePoint.startY;
2223
+ if (flip === 'horizontal') {
2224
+ point.x = endX;
2225
+ point.y = startY;
1857
2226
  }
1858
- else if (flip.toLowerCase() === 'vertical') {
1859
- point.x = actObj.activePoint.startX;
1860
- point.y = actObj.activePoint.endY;
2227
+ else if (flip === 'vertical') {
2228
+ point.x = startX;
2229
+ point.y = endY;
1861
2230
  }
1862
2231
  else {
1863
- point.x = actObj.activePoint.startX;
1864
- point.y = actObj.activePoint.startY;
2232
+ point.x = startX;
2233
+ point.y = startY;
1865
2234
  }
1866
2235
  break;
1867
2236
  case 90:
1868
- if (flip.toLowerCase() === 'horizontal') {
1869
- point.x = actObj.activePoint.startX;
1870
- point.y = actObj.activePoint.startY;
2237
+ if (flip === 'horizontal') {
2238
+ point.x = startX;
2239
+ point.y = startY;
1871
2240
  }
1872
- else if (flip.toLowerCase() === 'vertical') {
1873
- point.x = actObj.activePoint.endX;
1874
- point.y = actObj.activePoint.endY;
2241
+ else if (flip === 'vertical') {
2242
+ point.x = endX;
2243
+ point.y = endY;
1875
2244
  }
1876
2245
  else {
1877
- point.x = actObj.activePoint.endX;
1878
- point.y = actObj.activePoint.startY;
2246
+ point.x = endX;
2247
+ point.y = startY;
1879
2248
  }
1880
2249
  break;
1881
2250
  case 180:
1882
- if (flip.toLowerCase() === 'horizontal') {
1883
- point.x = actObj.activePoint.startX;
1884
- point.y = actObj.activePoint.endY;
2251
+ if (flip === 'horizontal') {
2252
+ point.x = startX;
2253
+ point.y = endY;
1885
2254
  }
1886
- else if (flip.toLowerCase() === 'vertical') {
1887
- point.x = actObj.activePoint.endX;
1888
- point.y = actObj.activePoint.startY;
2255
+ else if (flip === 'vertical') {
2256
+ point.x = endX;
2257
+ point.y = startY;
1889
2258
  }
1890
2259
  else {
1891
- point.x = actObj.activePoint.endX;
1892
- point.y = actObj.activePoint.endY;
2260
+ point.x = endX;
2261
+ point.y = endY;
1893
2262
  }
1894
2263
  break;
1895
2264
  case 270:
1896
- if (flip.toLowerCase() === 'horizontal') {
1897
- point.x = actObj.activePoint.endX;
1898
- point.y = actObj.activePoint.endY;
2265
+ if (flip === 'horizontal') {
2266
+ point.x = endX;
2267
+ point.y = endY;
1899
2268
  }
1900
- else if (flip.toLowerCase() === 'vertical') {
1901
- point.x = actObj.activePoint.startX;
1902
- point.y = actObj.activePoint.startY;
2269
+ else if (flip === 'vertical') {
2270
+ point.x = startX;
2271
+ point.y = startY;
1903
2272
  }
1904
2273
  else {
1905
- point.x = actObj.activePoint.startX;
1906
- point.y = actObj.activePoint.endY;
2274
+ point.x = startX;
2275
+ point.y = endY;
1907
2276
  }
1908
2277
  break;
1909
2278
  }
@@ -1911,92 +2280,94 @@ var Shape = /** @class */ (function () {
1911
2280
  };
1912
2281
  Shape.prototype.setTextBoxPoints = function (actObj, degree, flip, x, y) {
1913
2282
  var point = { x: x, y: y };
2283
+ var _a = actObj.activePoint, startX = _a.startX, startY = _a.startY, endX = _a.endX, endY = _a.endY;
2284
+ flip = flip.toLowerCase();
1914
2285
  switch (degree) {
1915
2286
  case 0:
1916
2287
  if (actObj.flipObjColl[0] && actObj.flipObjColl[0].toLowerCase() === 'horizontal') {
1917
- if (flip.toLowerCase() === 'horizontal') {
1918
- point.x = (actObj.activePoint.startX);
1919
- point.y = (actObj.activePoint.startY);
2288
+ if (flip === 'horizontal') {
2289
+ point.x = startX;
2290
+ point.y = startY;
1920
2291
  }
1921
- else if (flip.toLowerCase() === 'vertical') {
1922
- point.x = (actObj.activePoint.endX);
1923
- point.y = (actObj.activePoint.endY);
2292
+ else if (flip === 'vertical') {
2293
+ point.x = endX;
2294
+ point.y = endY;
1924
2295
  }
1925
2296
  }
1926
2297
  else {
1927
- if (flip.toLowerCase() === 'horizontal') {
1928
- point.x = (actObj.activePoint.endX);
1929
- point.y = (actObj.activePoint.endY);
2298
+ if (flip === 'horizontal') {
2299
+ point.x = endX;
2300
+ point.y = endY;
1930
2301
  }
1931
- else if (flip.toLowerCase() === 'vertical') {
1932
- point.x = (actObj.activePoint.endX);
1933
- point.y = (actObj.activePoint.startY);
2302
+ else if (flip === 'vertical') {
2303
+ point.x = endX;
2304
+ point.y = startY;
1934
2305
  }
1935
2306
  }
1936
2307
  break;
1937
2308
  case 90:
1938
2309
  if (actObj.flipObjColl[0] && actObj.flipObjColl[0].toLowerCase() === 'horizontal') {
1939
- if (flip.toLowerCase() === 'horizontal') {
1940
- point.x = (actObj.activePoint.endX);
1941
- point.y = (actObj.activePoint.endY);
2310
+ if (flip === 'horizontal') {
2311
+ point.x = endX;
2312
+ point.y = endY;
1942
2313
  }
1943
- else if (flip.toLowerCase() === 'vertical') {
1944
- point.x = (actObj.activePoint.startX);
1945
- point.y = (actObj.activePoint.endY);
2314
+ else if (flip === 'vertical') {
2315
+ point.x = startX;
2316
+ point.y = endY;
1946
2317
  }
1947
2318
  }
1948
2319
  else {
1949
- if (flip.toLowerCase() === 'horizontal') {
1950
- point.x = (actObj.activePoint.startX);
1951
- point.y = (actObj.activePoint.endY);
2320
+ if (flip === 'horizontal') {
2321
+ point.x = startX;
2322
+ point.y = endY;
1952
2323
  }
1953
- else if (flip.toLowerCase() === 'vertical') {
1954
- point.x = (actObj.activePoint.startX);
1955
- point.y = (actObj.activePoint.startY);
2324
+ else if (flip === 'vertical') {
2325
+ point.x = startX;
2326
+ point.y = startY;
1956
2327
  }
1957
2328
  }
1958
2329
  break;
1959
2330
  case 180:
1960
2331
  if (actObj.flipObjColl[0] && actObj.flipObjColl[0].toLowerCase() === 'horizontal') {
1961
- if (flip.toLowerCase() === 'horizontal') {
1962
- point.x = (actObj.activePoint.startX);
1963
- point.y = (actObj.activePoint.startY);
2332
+ if (flip === 'horizontal') {
2333
+ point.x = startX;
2334
+ point.y = startY;
1964
2335
  }
1965
- else if (flip.toLowerCase() === 'vertical') {
1966
- point.x = (actObj.activePoint.startX);
1967
- point.y = (actObj.activePoint.startY);
2336
+ else if (flip === 'vertical') {
2337
+ point.x = startX;
2338
+ point.y = startY;
1968
2339
  }
1969
2340
  }
1970
2341
  else {
1971
- if (flip.toLowerCase() === 'horizontal') {
1972
- point.x = (actObj.activePoint.startX);
1973
- point.y = (actObj.activePoint.startY);
2342
+ if (flip === 'horizontal') {
2343
+ point.x = startX;
2344
+ point.y = startY;
1974
2345
  }
1975
- else if (flip.toLowerCase() === 'vertical') {
1976
- point.x = (actObj.activePoint.startX);
1977
- point.y = (actObj.activePoint.endY);
2346
+ else if (flip === 'vertical') {
2347
+ point.x = startX;
2348
+ point.y = endY;
1978
2349
  }
1979
2350
  }
1980
2351
  break;
1981
2352
  case 270:
1982
2353
  if (actObj.flipObjColl[0] && actObj.flipObjColl[0].toLowerCase() === 'horizontal') {
1983
- if (flip.toLowerCase() === 'horizontal') {
1984
- point.x = (actObj.activePoint.startX);
1985
- point.y = (actObj.activePoint.startY);
2354
+ if (flip === 'horizontal') {
2355
+ point.x = startX;
2356
+ point.y = startY;
1986
2357
  }
1987
- else if (flip.toLowerCase() === 'vertical') {
1988
- point.x = (actObj.activePoint.endX);
1989
- point.y = (actObj.activePoint.startY);
2358
+ else if (flip === 'vertical') {
2359
+ point.x = endX;
2360
+ point.y = startY;
1990
2361
  }
1991
2362
  }
1992
2363
  else {
1993
- if (flip.toLowerCase() === 'horizontal') {
1994
- point.x = (actObj.activePoint.endX);
1995
- point.y = (actObj.activePoint.startY);
2364
+ if (flip === 'horizontal') {
2365
+ point.x = endX;
2366
+ point.y = startY;
1996
2367
  }
1997
- else if (flip.toLowerCase() === 'vertical') {
1998
- point.x = (actObj.activePoint.endX);
1999
- point.y = (actObj.activePoint.endY);
2368
+ else if (flip === 'vertical') {
2369
+ point.x = endX;
2370
+ point.y = endY;
2000
2371
  }
2001
2372
  }
2002
2373
  break;
@@ -2004,9 +2375,10 @@ var Shape = /** @class */ (function () {
2004
2375
  return point;
2005
2376
  };
2006
2377
  Shape.prototype.selectedText = function () {
2007
- var start = this.parent.textArea.selectionStart;
2008
- var finish = this.parent.textArea.selectionEnd;
2009
- return this.parent.textArea.value.substring(start, finish);
2378
+ var parent = this.parent;
2379
+ var start = parent.textArea.selectionStart;
2380
+ var finish = parent.textArea.selectionEnd;
2381
+ return parent.textArea.value.substring(start, finish);
2010
2382
  };
2011
2383
  Shape.prototype.panObjColl = function (xDiff, yDiff, panRegion) {
2012
2384
  var parent = this.parent;
@@ -2097,7 +2469,8 @@ var Shape = /** @class */ (function () {
2097
2469
  textStyle = 'italic bold ';
2098
2470
  }
2099
2471
  var fontSize = isTextBox ? parseFloat(parent.textArea.style.fontSize) : parent.activeObj.textSettings.fontSize;
2100
- var fontFamily = parent.textArea.style.display === 'block' ? parent.textArea.style.fontFamily : parent.activeObj.textSettings.fontFamily;
2472
+ var fontFamily = (parent.textArea.style.display === 'block' || parent.textArea.style.display === 'inline-block') ?
2473
+ parent.textArea.style.fontFamily : parent.activeObj.textSettings.fontFamily;
2101
2474
  this.upperContext.font = textStyle + fontSize + 'px' + ' ' + fontFamily;
2102
2475
  };
2103
2476
  Shape.prototype.applyFontStyle = function (item) {
@@ -2128,18 +2501,31 @@ var Shape = /** @class */ (function () {
2128
2501
  this.updateFontStyle(item, objColl, 'bold', 'italic');
2129
2502
  break;
2130
2503
  }
2131
- var shapeChangedArgs = { action: 'font-style', previousShapeSettings: extend({}, shapeSettings, {}, true),
2132
- currentShapeSettings: extend({}, shapeSettings, {}, true) };
2504
+ var shapeChangedArgs = { action: 'font-style', currentShapeSettings: extend({}, shapeSettings, {}, true) };
2133
2505
  shapeChangedArgs.currentShapeSettings.fontStyle = [item];
2134
2506
  parent.triggerShapeChanged(shapeChangedArgs);
2135
2507
  };
2136
2508
  Shape.prototype.updateFontStyle = function (item, objColl, fontWeight, fontStyle) {
2137
2509
  var parent = this.parent;
2138
- if (parent.textArea.style.display === 'block') {
2139
- var width = this.getTextAreaWidth(item);
2140
- parent.textArea.style.width = width + 'px';
2141
- parent.textArea.style.fontWeight = fontWeight;
2142
- parent.textArea.style.fontStyle = fontStyle;
2510
+ var style = parent.textArea.style;
2511
+ if (style.display === 'block' || style.display === 'inline-block') {
2512
+ if (style.fontWeight === 'normal' && fontWeight === 'bold') {
2513
+ style.fontWeight = 'bold';
2514
+ }
2515
+ else if (style.fontWeight === 'bold' && fontWeight === 'bold') {
2516
+ style.fontWeight = 'normal';
2517
+ }
2518
+ if (style.fontStyle === 'normal' && fontStyle === 'italic') {
2519
+ style.fontStyle = 'italic';
2520
+ }
2521
+ else if (style.fontStyle === 'italic' && fontStyle === 'italic') {
2522
+ style.fontStyle = 'normal';
2523
+ }
2524
+ var value = (style.fontWeight === 'normal' && style.fontStyle === 'normal' ? 'default' :
2525
+ (style.fontWeight === 'bold' && style.fontStyle === 'normal' ? 'bold' :
2526
+ (style.fontWeight === 'normal' && style.fontStyle === 'italic' ? 'italic' : 'bolditalic')));
2527
+ var width = this.getTextAreaWidth(value);
2528
+ style.width = width + 'px';
2143
2529
  this.updateObjColl(item, objColl);
2144
2530
  }
2145
2531
  else {
@@ -2262,92 +2648,97 @@ var Shape = /** @class */ (function () {
2262
2648
  parent.activeObj.textSettings.italic = tempItalic;
2263
2649
  };
2264
2650
  Shape.prototype.pushActItemIntoObj = function () {
2265
- if (this.parent.textArea.style.display === 'none') {
2266
- this.parent.objColl.push(this.parent.activeObj);
2651
+ var parent = this.parent;
2652
+ if (parent.textArea.style.display === 'none') {
2653
+ parent.objColl.push(parent.activeObj);
2267
2654
  }
2268
2655
  else {
2269
- var temp = extend({}, this.parent.activeObj, {}, true);
2270
- this.parent.notify('selection', { prop: 'setTextBoxStylesToActObj', onPropertyChange: false });
2271
- this.parent.objColl.push(this.parent.activeObj);
2272
- this.parent.activeObj = temp;
2656
+ var temp = extend({}, parent.activeObj, {}, true);
2657
+ parent.notify('selection', { prop: 'setTextBoxStylesToActObj', onPropertyChange: false });
2658
+ parent.objColl.push(parent.activeObj);
2659
+ parent.activeObj = temp;
2273
2660
  }
2274
2661
  };
2275
2662
  Shape.prototype.clearActObj = function () {
2276
- if (this.parent.textArea.style.display === 'none') {
2663
+ var parent = this.parent;
2664
+ if (parent.textArea.style.display === 'none') {
2277
2665
  this.refreshActiveObj();
2278
2666
  this.applyActObj();
2279
2667
  this.refreshActiveObj();
2280
- this.parent.currObjType.isCustomCrop = false;
2668
+ parent.currObjType.isCustomCrop = false;
2281
2669
  }
2282
2670
  };
2283
2671
  Shape.prototype.refreshActiveObj = function () {
2284
- this.parent.activeObj = {};
2285
- this.parent.activeObj.activePoint = { startX: 0, startY: 0, endX: 0, endY: 0, width: 0, height: 0 };
2286
- this.parent.activeObj.triangle = [];
2287
- this.parent.activeObj.triangleRatio = [];
2288
- this.parent.activeObj.flipObjColl = [];
2289
- this.parent.activeObj.strokeSettings = this.strokeSettings;
2290
- this.parent.activeObj.textSettings = this.textSettings;
2291
- this.parent.activeObj.rotatedAngle = 0;
2672
+ var parent = this.parent;
2673
+ parent.activeObj = {};
2674
+ parent.activeObj.activePoint = { startX: 0, startY: 0, endX: 0, endY: 0, width: 0, height: 0 };
2675
+ parent.activeObj.triangle = [];
2676
+ parent.activeObj.triangleRatio = [];
2677
+ parent.activeObj.flipObjColl = [];
2678
+ parent.activeObj.strokeSettings = this.strokeSettings;
2679
+ parent.activeObj.textSettings = this.textSettings;
2680
+ parent.activeObj.rotatedAngle = 0;
2681
+ parent.activeObj.opacity = 1;
2292
2682
  };
2293
2683
  Shape.prototype.applyActObj = function (isMouseDown) {
2684
+ var parent = this.parent;
2294
2685
  var isActObj = false;
2295
- if (this.parent.activeObj.shape !== undefined && this.parent.activeObj.shape === 'text' && this.parent.activeObj.keyHistory === '') {
2686
+ if (parent.activeObj.shape !== undefined && parent.activeObj.shape === 'text' && parent.activeObj.keyHistory === '') {
2296
2687
  this.refreshActiveObj();
2297
- this.upperContext.clearRect(0, 0, this.parent.upperCanvas.width, this.parent.upperCanvas.height);
2688
+ this.upperContext.clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
2298
2689
  }
2299
2690
  else {
2300
2691
  var splitWords = void 0;
2301
2692
  var isCropSelection = false;
2302
- if (this.parent.activeObj.shape !== undefined) {
2303
- splitWords = this.parent.activeObj.shape.split('-');
2693
+ if (parent.activeObj.shape !== undefined) {
2694
+ splitWords = parent.activeObj.shape.split('-');
2304
2695
  }
2305
- if (splitWords === undefined && this.parent.currObjType.isCustomCrop) {
2696
+ if (splitWords === undefined && parent.currObjType.isCustomCrop) {
2306
2697
  isCropSelection = true;
2307
2698
  }
2308
2699
  else if (splitWords !== undefined && splitWords[0] === 'crop') {
2309
2700
  isCropSelection = true;
2310
2701
  }
2311
- if (this.parent.activeObj.shape && !isCropSelection && this.parent.activeObj.shape !== 'shape') {
2312
- for (var i = 0; i < this.parent.objColl.length; i++) {
2313
- if (JSON.stringify(this.parent.activeObj) === JSON.stringify(this.parent.objColl[i])) {
2702
+ if (parent.activeObj.shape && !isCropSelection && parent.activeObj.shape !== 'shape') {
2703
+ for (var i = 0; i < parent.objColl.length; i++) {
2704
+ if (JSON.stringify(parent.activeObj) === JSON.stringify(parent.objColl[i])) {
2314
2705
  isActObj = true;
2315
2706
  break;
2316
2707
  }
2317
2708
  }
2318
2709
  if (!isActObj) {
2319
- if (isNullOrUndefined(this.parent.activeObj.currIndex)) {
2320
- this.parent.activeObj.currIndex = 'shape_' + (this.parent.objColl.length + 1);
2710
+ if (isNullOrUndefined(parent.activeObj.currIndex)) {
2711
+ parent.activeObj.currIndex = 'shape_' + (parent.objColl.length + 1);
2321
2712
  }
2322
2713
  this.updImgRatioForActObj();
2323
- var splitWords_1 = this.parent.activeObj.currIndex.split('_');
2324
- var tempObjColl = this.parent.objColl.splice(0, parseInt(splitWords_1[1], 10) - 1);
2325
- tempObjColl.push(extend({}, this.parent.activeObj, {}, true));
2326
- for (var i = 0; i < this.parent.objColl.length; i++) {
2327
- tempObjColl.push(this.parent.objColl[i]);
2714
+ var splitWords_1 = parent.activeObj.currIndex.split('_');
2715
+ var tempObjColl = parent.objColl.splice(0, parseInt(splitWords_1[1], 10) - 1);
2716
+ tempObjColl.push(extend({}, parent.activeObj, {}, true));
2717
+ for (var i = 0; i < parent.objColl.length; i++) {
2718
+ tempObjColl.push(parent.objColl[i]);
2328
2719
  }
2329
- this.parent.objColl = tempObjColl;
2720
+ parent.objColl = tempObjColl;
2330
2721
  tempObjColl = [];
2331
2722
  this.refreshActiveObj();
2332
- this.lowerContext.clearRect(0, 0, this.parent.lowerCanvas.width, this.parent.lowerCanvas.height);
2333
- this.parent.notify('draw', { prop: 'redrawImgWithObj', onPropertyChange: false });
2334
- this.parent.notify('draw', { prop: 'clearOuterCanvas', onPropertyChange: false, value: { context: this.lowerContext } });
2335
- this.parent.notify('draw', { prop: 'clearOuterCanvas', onPropertyChange: false, value: { context: this.upperContext } });
2336
- this.parent.currObjType.shape = '';
2723
+ this.lowerContext.clearRect(0, 0, parent.lowerCanvas.width, parent.lowerCanvas.height);
2724
+ parent.notify('draw', { prop: 'redrawImgWithObj', onPropertyChange: false });
2725
+ parent.notify('draw', { prop: 'clearOuterCanvas', onPropertyChange: false, value: { context: this.lowerContext } });
2726
+ parent.notify('draw', { prop: 'clearOuterCanvas', onPropertyChange: false, value: { context: this.upperContext } });
2727
+ parent.currObjType.shape = '';
2337
2728
  this.refreshActiveObj();
2338
- if (this.parent.isCircleCrop) {
2339
- this.parent.notify('crop', { prop: 'cropCircle', onPropertyChange: false,
2729
+ if (parent.isCircleCrop) {
2730
+ parent.notify('crop', { prop: 'cropCircle', onPropertyChange: false,
2340
2731
  value: { context: this.lowerContext, isSave: null, isFlip: null } });
2341
2732
  }
2342
2733
  if (!isBlazor()) {
2343
- this.parent.notify('toolbar', { prop: 'destroy-qa-toolbar', onPropertyChange: false });
2734
+ parent.notify('toolbar', { prop: 'destroy-qa-toolbar', onPropertyChange: false });
2344
2735
  }
2345
2736
  else {
2346
- this.parent.updateToolbar(this.parent.element, 'destroyQuickAccessToolbar');
2737
+ parent.updateToolbar(parent.element, 'destroyQuickAccessToolbar');
2347
2738
  }
2348
2739
  if (isNullOrUndefined(isMouseDown)) {
2349
- this.parent.notify('undo-redo', { prop: 'updateCurrUrc', value: { type: 'ok' } });
2350
- this.parent.notify('draw', { prop: 'setPrevActObj', onPropertyChange: false, value: { prevActObj: null } });
2740
+ parent.notify('undo-redo', { prop: 'updateCurrUrc', value: { type: 'ok' } });
2741
+ parent.notify('draw', { prop: 'setPrevActObj', onPropertyChange: false, value: { prevActObj: null } });
2351
2742
  }
2352
2743
  }
2353
2744
  }
@@ -2372,7 +2763,6 @@ var Shape = /** @class */ (function () {
2372
2763
  var scale = '';
2373
2764
  var degree = this.getRotDegOfShape(parent.activeObj);
2374
2765
  if (parent.activeObj.flipObjColl.length > 0) {
2375
- // need to add scale value according to length.
2376
2766
  for (var i = 0; i < parent.activeObj.flipObjColl.length; i++) {
2377
2767
  if (degree !== 0 && degree % 90 === 0 && degree !== 180) {
2378
2768
  scale += parent.activeObj.flipObjColl[i].toLowerCase() === 'horizontal' ? 'scale(1, -1)' :
@@ -2419,9 +2809,10 @@ var Shape = /** @class */ (function () {
2419
2809
  parent.activeObj.textSettings.italic = true;
2420
2810
  break;
2421
2811
  }
2422
- this.updateFontStyles();
2812
+ var isTextArea = parent.textArea.style.display === 'none' ? false : true;
2813
+ this.updateFontStyles(isTextArea);
2423
2814
  var width;
2424
- if (parent.textArea.style.display === 'none') {
2815
+ if (!isTextArea) {
2425
2816
  width = this.upperContext.measureText(parent.activeObj.keyHistory).width +
2426
2817
  parent.activeObj.textSettings.fontSize * 0.5;
2427
2818
  }
@@ -2528,8 +2919,9 @@ var Shape = /** @class */ (function () {
2528
2919
  };
2529
2920
  Shape.prototype.isPointsInRange = function (x, y, obj) {
2530
2921
  var inRange = false;
2531
- if (!isNullOrUndefined(x) && !isNullOrUndefined(y) && x >= this.parent.img.destLeft && y >= this.parent.img.destTop &&
2532
- x <= this.parent.img.destLeft + this.parent.img.destWidth && y <= this.parent.img.destTop + this.parent.img.destHeight) {
2922
+ var parent = this.parent;
2923
+ if (!isNullOrUndefined(x) && !isNullOrUndefined(y) && x >= parent.img.destLeft && y >= parent.img.destTop &&
2924
+ x <= parent.img.destLeft + parent.img.destWidth && y <= parent.img.destTop + parent.img.destHeight) {
2533
2925
  inRange = true;
2534
2926
  }
2535
2927
  obj['inRange'] = inRange;
@@ -2601,49 +2993,40 @@ var Shape = /** @class */ (function () {
2601
2993
  return collection;
2602
2994
  };
2603
2995
  Shape.prototype.popForDefaultFlipState = function (collection) {
2604
- for (var i = 0; i < collection.length; i++) {
2605
- if (!isNullOrUndefined(collection[i + 3])) {
2606
- if ((collection[i] === 'horizontal' || collection[i] === 'Horizontal'
2607
- || collection[i] === 'horizontalFlip')
2608
- && (collection[i + 1] === 'vertical' || collection[i + 1] === 'Vertical'
2609
- || collection[i] === 'verticalFlip') &&
2610
- (collection[i + 2] === 'horizontal' || collection[i + 2] === 'Horizontal'
2611
- || collection[i] === 'horizontalFlip') &&
2612
- (collection[i + 3] === 'vertical' || collection[i + 3] === 'Vertical'
2613
- || collection[i] === 'verticalFlip')) {
2614
- collection.pop();
2615
- collection.pop();
2616
- collection.pop();
2617
- collection.pop();
2618
- }
2619
- else if ((collection[i] === 'vertical' || collection[i] === 'Vertical'
2620
- || collection[i] === 'verticalFlip')
2621
- && (collection[i + 1] === 'horizontal' || collection[i + 1] === 'Horizontal'
2622
- || collection[i + 1] === 'horizontalFlip') &&
2623
- (collection[i + 2] === 'vertical' || collection[i + 2] === 'Vertical' || collection[i] === 'verticalFlip') &&
2624
- (collection[i + 3] === 'horizontal' || collection[i + 3] === 'Horizontal' || collection[i] === 'horizontalFlip')) {
2625
- collection.pop();
2626
- collection.pop();
2627
- collection.pop();
2628
- collection.pop();
2629
- }
2996
+ for (var i = 0, iLen = collection.length - 3; i < iLen; i++) {
2997
+ var isHorizontal = collection[i] === 'horizontal' || collection[i] === 'Horizontal'
2998
+ || collection[i] === 'horizontalFlip';
2999
+ var isVertical = collection[i] === 'vertical' || collection[i] === 'Vertical' ||
3000
+ collection[i] === 'verticalFlip';
3001
+ var isNextHorizontal = collection[i + 1] === 'horizontal' || collection[i + 1] === 'Horizontal' ||
3002
+ collection[i + 1] === 'horizontalFlip';
3003
+ var isNextVertical = collection[i + 1] === 'vertical' || collection[i + 1] === 'Vertical' ||
3004
+ collection[i + 1] === 'verticalFlip';
3005
+ var isNextToNextHorizontal = collection[i + 2] === 'horizontal' || collection[i + 2] === 'Horizontal' ||
3006
+ collection[i + 2] === 'horizontalFlip';
3007
+ var isNextToNextVertical = collection[i + 2] === 'vertical' || collection[i + 2] === 'Vertical' ||
3008
+ collection[i + 2] === 'verticalFlip';
3009
+ var isNextToNextToNextHorizontal = collection[i + 3] === 'horizontal' || collection[i + 3] === 'Horizontal' ||
3010
+ collection[i + 3] === 'horizontalFlip';
3011
+ if ((isHorizontal && isNextVertical && isNextToNextHorizontal && isNextToNextVertical) ||
3012
+ (isVertical && isNextHorizontal && isNextToNextVertical && isNextToNextToNextHorizontal)) {
3013
+ collection.splice(i, 4);
3014
+ i -= 4;
2630
3015
  }
2631
3016
  }
2632
3017
  return collection;
2633
3018
  };
2634
3019
  Shape.prototype.popForDefaultRotateState = function (collection) {
2635
- for (var i = 0; i < collection.length; i++) {
2636
- if (!isNullOrUndefined(collection[i + 1])) {
2637
- if ((collection[i] === 90 || collection[i] === 'rotateRight') &&
2638
- (collection[i + 1] === -90 || collection[i] === 'rotateLeft')) {
2639
- collection.pop();
2640
- collection.pop();
2641
- }
2642
- else if ((collection[i] === -90 || collection[i] === 'rotateLeft') &&
2643
- (collection[i + 1] === 90 || collection[i] === 'rotateRight')) {
2644
- collection.pop();
2645
- collection.pop();
2646
- }
3020
+ for (var i = 0; i < collection.length - 1; i++) {
3021
+ var curr = collection[i];
3022
+ var next = collection[i + 1];
3023
+ if ((curr === 90 || curr === 'rotateRight') && (next === -90 || next === 'rotateLeft')) {
3024
+ collection.splice(i, 2);
3025
+ i -= 2;
3026
+ }
3027
+ else if ((curr === -90 || curr === 'rotateLeft') && (next === 90 || next === 'rotateRight')) {
3028
+ collection.splice(i, 2);
3029
+ i -= 2;
2647
3030
  }
2648
3031
  }
2649
3032
  return collection;
@@ -2691,7 +3074,7 @@ var Shape = /** @class */ (function () {
2691
3074
  else {
2692
3075
  parent.updateToolbar(parent.element, parent.activeObj.shape);
2693
3076
  if (parent.activeObj.shape === 'path') {
2694
- parent.updateToolbar(this.parent.element, 'path', 'pathQuickAccessToolbar');
3077
+ parent.updateToolbar(parent.element, 'path', 'pathQuickAccessToolbar');
2695
3078
  }
2696
3079
  else {
2697
3080
  parent.updateToolbar(parent.element, 'quickAccessToolbar', parent.activeObj.shape);
@@ -2710,14 +3093,14 @@ var Shape = /** @class */ (function () {
2710
3093
  if (obj_6['isIndex']) {
2711
3094
  isSelected = true;
2712
3095
  parent.notify('freehand-draw', { prop: 'selectFhd', value: { id: id } });
2713
- if (!isBlazor()) {
2714
- parent.notify('toolbar', { prop: 'renderQAT', onPropertyChange: false, value: { isPenEdit: true } });
2715
- parent.notify('toolbar', { prop: 'update-toolbar-items', onPropertyChange: false });
2716
- }
2717
- else {
3096
+ if (isBlazor()) {
2718
3097
  parent.updateToolbar(parent.element, 'pen');
2719
3098
  parent.updateToolbar(parent.element, 'quickAccessToolbar', 'pen');
2720
3099
  }
3100
+ else {
3101
+ parent.notify('toolbar', { prop: 'renderQAT', onPropertyChange: false, value: { isPenEdit: true } });
3102
+ parent.notify('toolbar', { prop: 'update-toolbar-items', onPropertyChange: false });
3103
+ }
2721
3104
  }
2722
3105
  else {
2723
3106
  isSelected = false;
@@ -2873,31 +3256,27 @@ var Shape = /** @class */ (function () {
2873
3256
  return point[1] - getSlope * point[0];
2874
3257
  };
2875
3258
  Shape.prototype.setPointCollForShapeRotation = function (obj) {
2876
- var center = { x: obj.activePoint.startX + (obj.activePoint.width / 2), y: obj.activePoint.startY +
2877
- (obj.activePoint.height / 2) };
2878
- var p1 = { x: Math.cos(obj.rotatedAngle) * (obj.activePoint.startX - center.x) - Math.sin(obj.rotatedAngle) *
2879
- (obj.activePoint.startY - center.y) + center.x,
2880
- y: Math.sin(obj.rotatedAngle) * (obj.activePoint.startX - center.x) + Math.cos(obj.rotatedAngle) *
2881
- (obj.activePoint.startY - center.y) + center.y };
2882
- var p2 = { x: Math.cos(obj.rotatedAngle) * (obj.activePoint.endX - center.x) - Math.sin(obj.rotatedAngle) *
2883
- (obj.activePoint.startY - center.y) + center.x,
2884
- y: Math.sin(obj.rotatedAngle) * (obj.activePoint.endX - center.x) + Math.cos(obj.rotatedAngle) * (obj.activePoint.startY
2885
- - center.y) + center.y };
2886
- var p3 = { x: Math.cos(obj.rotatedAngle) * (obj.activePoint.startX - center.x) - Math.sin(obj.rotatedAngle) *
2887
- (obj.activePoint.endY - center.y) + center.x,
2888
- y: Math.sin(obj.rotatedAngle) * (obj.activePoint.startX - center.x) + Math.cos(obj.rotatedAngle) * (obj.activePoint.endY
2889
- - center.y) + center.y };
2890
- var p4 = { x: Math.cos(obj.rotatedAngle) * (obj.activePoint.endX - center.x) - Math.sin(obj.rotatedAngle) *
2891
- (obj.activePoint.endY - center.y) + center.x,
2892
- y: Math.sin(obj.rotatedAngle) * (obj.activePoint.endX - center.x) + Math.cos(obj.rotatedAngle) * (obj.activePoint.endY
2893
- - center.y) + center.y };
3259
+ var parent = this.parent;
3260
+ var _a = obj.activePoint, startX = _a.startX, startY = _a.startY, endX = _a.endX, endY = _a.endY, width = _a.width, height = _a.height;
3261
+ var center = { x: startX + (width / 2), y: startY +
3262
+ (height / 2) };
3263
+ var cosAngle = Math.cos(obj.rotatedAngle);
3264
+ var sinAngle = Math.sin(obj.rotatedAngle);
3265
+ var p1 = { x: cosAngle * (startX - center.x) - sinAngle * (startY - center.y) + center.x,
3266
+ y: sinAngle * (startX - center.x) + cosAngle * (startY - center.y) + center.y };
3267
+ var p2 = { x: cosAngle * (endX - center.x) - sinAngle * (startY - center.y) + center.x,
3268
+ y: sinAngle * (endX - center.x) + cosAngle * (startY - center.y) + center.y };
3269
+ var p3 = { x: cosAngle * (startX - center.x) - sinAngle * (endY - center.y) + center.x,
3270
+ y: sinAngle * (startX - center.x) + cosAngle * (endY - center.y) + center.y };
3271
+ var p4 = { x: cosAngle * (endX - center.x) - sinAngle * (endY - center.y) + center.x,
3272
+ y: sinAngle * (endX - center.x) + cosAngle * (endY - center.y) + center.y };
3273
+ obj.horTopLinePointColl = this.getLinePoints(p1.x, p1.y, p2.x, p2.y);
2894
3274
  obj.horTopLinePointColl = this.getLinePoints(p1.x, p1.y, p2.x, p2.y);
2895
3275
  obj.horBottomLinePointColl = this.getLinePoints(p3.x, p3.y, p4.x, p4.y);
2896
3276
  obj.verLeftLinePointColl = this.getLinePoints(p1.x, p1.y, p3.x, p3.y);
2897
3277
  obj.verRightLinePointColl = this.getLinePoints(p2.x, p2.y, p4.x, p4.y);
2898
3278
  obj.verLeftLinePointColl.reverse();
2899
3279
  obj.verRightLinePointColl.reverse();
2900
- // Updating ratio for point collection
2901
3280
  for (var i = 0; i < obj.horTopLinePointColl.length; i++) {
2902
3281
  obj.horTopLinePointColl[i].ratioX = (obj.horTopLinePointColl[i].x -
2903
3282
  this.parent.img.destLeft) / this.parent.img.destWidth;
@@ -2922,42 +3301,36 @@ var Shape = /** @class */ (function () {
2922
3301
  obj.verRightLinePointColl[i].ratioY = (obj.verRightLinePointColl[i].y -
2923
3302
  this.parent.img.destTop) / this.parent.img.destHeight;
2924
3303
  }
2925
- if (this.parent.upperCanvas.style.cursor !== 'move') {
3304
+ if (parent.upperCanvas.style.cursor !== 'move') {
2926
3305
  var object = { rotationCirclePoint: null };
2927
- this.parent.notify('selection', { prop: 'getTransRotationPoint', value: { obj: obj, object: object } });
3306
+ parent.notify('selection', { prop: 'getTransRotationPoint', value: { obj: obj, object: object } });
2928
3307
  var rotationCirclePoint = object['rotationCirclePoint'];
2929
3308
  if (rotationCirclePoint) {
2930
- obj.rotationCirclePointColl = { x: Math.cos(obj.rotatedAngle) * (rotationCirclePoint.x - center.x) -
2931
- Math.sin(obj.rotatedAngle) * (rotationCirclePoint.y - center.y) + center.x,
2932
- y: Math.sin(obj.rotatedAngle) * (rotationCirclePoint.x - center.x) + Math.cos(obj.rotatedAngle)
3309
+ obj.rotationCirclePointColl = { x: cosAngle * (rotationCirclePoint.x - center.x) -
3310
+ sinAngle * (rotationCirclePoint.y - center.y) + center.x,
3311
+ y: sinAngle * (rotationCirclePoint.x - center.x) + cosAngle
2933
3312
  * (rotationCirclePoint.y - center.y) + center.y };
2934
- obj.rotationCirclePointColl.ratioX = (obj.rotationCirclePointColl.x - this.parent.img.destLeft) /
2935
- this.parent.img.destWidth;
2936
- obj.rotationCirclePointColl.ratioY = (obj.rotationCirclePointColl.y - this.parent.img.destTop) /
2937
- this.parent.img.destHeight;
3313
+ obj.rotationCirclePointColl.ratioX = (obj.rotationCirclePointColl.x - parent.img.destLeft) /
3314
+ parent.img.destWidth;
3315
+ obj.rotationCirclePointColl.ratioY = (obj.rotationCirclePointColl.y - parent.img.destTop) /
3316
+ parent.img.destHeight;
2938
3317
  }
2939
3318
  }
2940
3319
  };
2941
3320
  Shape.prototype.getSquarePointForRotatedShape = function (obj, object) {
2942
3321
  var point = { startX: 0, startY: 0, endX: 0, endY: 0, width: 0, height: 0 };
2943
- var center = { x: obj.activePoint.startX + (obj.activePoint.width / 2), y: obj.activePoint.startY +
2944
- (obj.activePoint.height / 2) };
2945
- var p1 = { x: Math.cos(obj.rotatedAngle) * (obj.activePoint.startX - center.x) - Math.sin(obj.rotatedAngle)
2946
- * (obj.activePoint.startY - center.y) + center.x,
2947
- y: Math.sin(obj.rotatedAngle) * (obj.activePoint.startX - center.x) + Math.cos(obj.rotatedAngle) * (obj.activePoint.startY
2948
- - center.y) + center.y };
2949
- var p2 = { x: Math.cos(obj.rotatedAngle) * (obj.activePoint.endX - center.x) - Math.sin(obj.rotatedAngle) *
2950
- (obj.activePoint.startY - center.y) + center.x,
2951
- y: Math.sin(obj.rotatedAngle) * (obj.activePoint.endX - center.x) + Math.cos(obj.rotatedAngle) * (obj.activePoint.startY
2952
- - center.y) + center.y };
2953
- var p3 = { x: Math.cos(obj.rotatedAngle) * (obj.activePoint.startX - center.x) - Math.sin(obj.rotatedAngle) *
2954
- (obj.activePoint.endY - center.y) + center.x,
2955
- y: Math.sin(obj.rotatedAngle) * (obj.activePoint.startX - center.x) + Math.cos(obj.rotatedAngle) * (obj.activePoint.endY
2956
- - center.y) + center.y };
2957
- var p4 = { x: Math.cos(obj.rotatedAngle) * (obj.activePoint.endX - center.x) - Math.sin(obj.rotatedAngle) *
2958
- (obj.activePoint.endY - center.y) + center.x,
2959
- y: Math.sin(obj.rotatedAngle) * (obj.activePoint.endX - center.x) + Math.cos(obj.rotatedAngle) *
2960
- (obj.activePoint.endY - center.y) + center.y };
3322
+ var _a = obj.activePoint, startX = _a.startX, startY = _a.startY, endX = _a.endX, endY = _a.endY, width = _a.width, height = _a.height;
3323
+ var center = { x: startX + (width / 2), y: startY + (height / 2) };
3324
+ var cosAngle = Math.cos(obj.rotatedAngle);
3325
+ var sinAngle = Math.sin(obj.rotatedAngle);
3326
+ var p1 = { x: cosAngle * (startX - center.x) - sinAngle * (startY - center.y) + center.x,
3327
+ y: sinAngle * (startX - center.x) + cosAngle * (startY - center.y) + center.y };
3328
+ var p2 = { x: cosAngle * (endX - center.x) - sinAngle * (startY - center.y) + center.x,
3329
+ y: sinAngle * (endX - center.x) + cosAngle * (startY - center.y) + center.y };
3330
+ var p3 = { x: cosAngle * (startX - center.x) - sinAngle * (endY - center.y) + center.x,
3331
+ y: sinAngle * (startX - center.x) + cosAngle * (endY - center.y) + center.y };
3332
+ var p4 = { x: cosAngle * (endX - center.x) - sinAngle * (endY - center.y) + center.x,
3333
+ y: sinAngle * (endX - center.x) + cosAngle * (endY - center.y) + center.y };
2961
3334
  point.startX = p1.x;
2962
3335
  point.startY = p1.y;
2963
3336
  point.endX = p1.x;