@syncfusion/ej2-image-editor 20.3.50 → 20.4.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/.eslintrc.json +16 -1
  2. package/CHANGELOG.md +6 -0
  3. package/README.md +65 -2
  4. package/dist/ej2-image-editor.umd.min.js +2 -2
  5. package/dist/ej2-image-editor.umd.min.js.map +1 -1
  6. package/dist/es6/ej2-image-editor.es2015.js +2639 -623
  7. package/dist/es6/ej2-image-editor.es2015.js.map +1 -1
  8. package/dist/es6/ej2-image-editor.es5.js +2676 -652
  9. package/dist/es6/ej2-image-editor.es5.js.map +1 -1
  10. package/dist/global/ej2-image-editor.min.js +2 -2
  11. package/dist/global/ej2-image-editor.min.js.map +1 -1
  12. package/dist/global/index.d.ts +1 -1
  13. package/package.json +22 -24
  14. package/src/image-editor/image-editor-model.d.ts +102 -19
  15. package/src/image-editor/image-editor.d.ts +232 -31
  16. package/src/image-editor/image-editor.js +2676 -651
  17. package/styles/bootstrap-dark.css +36 -0
  18. package/styles/bootstrap.css +36 -0
  19. package/styles/bootstrap4.css +36 -0
  20. package/styles/bootstrap5-dark.css +36 -0
  21. package/styles/bootstrap5.css +36 -0
  22. package/styles/fabric-dark.css +36 -0
  23. package/styles/fabric.css +36 -0
  24. package/styles/fluent-dark.css +36 -0
  25. package/styles/fluent.css +36 -0
  26. package/styles/highcontrast-light.css +36 -0
  27. package/styles/highcontrast.css +36 -0
  28. package/styles/image-editor/_bootstrap-dark-definition.scss +1 -0
  29. package/styles/image-editor/_bootstrap-definition.scss +1 -0
  30. package/styles/image-editor/_bootstrap4-definition.scss +1 -0
  31. package/styles/image-editor/_bootstrap5-definition.scss +1 -0
  32. package/styles/image-editor/_fabric-dark-definition.scss +1 -0
  33. package/styles/image-editor/_fabric-definition.scss +1 -0
  34. package/styles/image-editor/_fluent-definition.scss +1 -0
  35. package/styles/image-editor/_fusionnew-definition.scss +1 -0
  36. package/styles/image-editor/_highcontrast-definition.scss +1 -0
  37. package/styles/image-editor/_highcontrast-light-definition.scss +1 -0
  38. package/styles/image-editor/_layout.scss +38 -0
  39. package/styles/image-editor/_material-dark-definition.scss +1 -0
  40. package/styles/image-editor/_material-definition.scss +1 -0
  41. package/styles/image-editor/_material3-definition.scss +1 -0
  42. package/styles/image-editor/_tailwind-definition.scss +1 -0
  43. package/styles/image-editor/_theme.scss +11 -0
  44. package/styles/image-editor/bootstrap-dark.css +36 -0
  45. package/styles/image-editor/bootstrap-dark.scss +1 -0
  46. package/styles/image-editor/bootstrap.css +36 -0
  47. package/styles/image-editor/bootstrap.scss +1 -0
  48. package/styles/image-editor/bootstrap4.css +36 -0
  49. package/styles/image-editor/bootstrap4.scss +1 -0
  50. package/styles/image-editor/bootstrap5-dark.css +36 -0
  51. package/styles/image-editor/bootstrap5-dark.scss +1 -0
  52. package/styles/image-editor/bootstrap5.css +36 -0
  53. package/styles/image-editor/bootstrap5.scss +1 -0
  54. package/styles/image-editor/fabric-dark.css +36 -0
  55. package/styles/image-editor/fabric-dark.scss +1 -0
  56. package/styles/image-editor/fabric.css +36 -0
  57. package/styles/image-editor/fabric.scss +1 -0
  58. package/styles/image-editor/fluent-dark.css +36 -0
  59. package/styles/image-editor/fluent-dark.scss +1 -0
  60. package/styles/image-editor/fluent.css +36 -0
  61. package/styles/image-editor/fluent.scss +1 -0
  62. package/styles/image-editor/highcontrast-light.css +36 -0
  63. package/styles/image-editor/highcontrast-light.scss +1 -0
  64. package/styles/image-editor/highcontrast.css +36 -0
  65. package/styles/image-editor/highcontrast.scss +1 -0
  66. package/styles/image-editor/material-dark.css +36 -0
  67. package/styles/image-editor/material-dark.scss +1 -0
  68. package/styles/image-editor/material.css +36 -0
  69. package/styles/image-editor/material.scss +1 -0
  70. package/styles/image-editor/tailwind-dark.css +36 -0
  71. package/styles/image-editor/tailwind-dark.scss +1 -0
  72. package/styles/image-editor/tailwind.css +36 -0
  73. package/styles/image-editor/tailwind.scss +1 -0
  74. package/styles/material-dark.css +36 -0
  75. package/styles/material.css +36 -0
  76. package/styles/tailwind-dark.css +36 -0
  77. package/styles/tailwind.css +36 -0
@@ -22,9 +22,41 @@ import { Event, EventHandler, getComponent, getInstance, isNullOrUndefined, L10n
22
22
  import { SignatureBase } from '@syncfusion/ej2-inputs';
23
23
  import { Toolbar } from '@syncfusion/ej2-navigations';
24
24
  import { DropDownButton } from '@syncfusion/ej2-splitbuttons';
25
- import { ColorPicker, Uploader } from '@syncfusion/ej2-inputs';
25
+ import { ColorPicker, Uploader, Slider } from '@syncfusion/ej2-inputs';
26
26
  import { createSpinner, showSpinner, hideSpinner } from '@syncfusion/ej2-popups';
27
- import { compile, compile as templateCompiler, Browser } from '@syncfusion/ej2-base';
27
+ import { Complex, compile, compile as templateCompiler, Browser, detach, select, ChildProperty } from '@syncfusion/ej2-base';
28
+ /**
29
+ * Interface for image finetune values.
30
+ */
31
+ var FinetuneSettings = /** @class */ (function (_super) {
32
+ __extends(FinetuneSettings, _super);
33
+ function FinetuneSettings() {
34
+ return _super !== null && _super.apply(this, arguments) || this;
35
+ }
36
+ __decorate([
37
+ Property(null)
38
+ ], FinetuneSettings.prototype, "brightness", void 0);
39
+ __decorate([
40
+ Property(null)
41
+ ], FinetuneSettings.prototype, "contrast", void 0);
42
+ __decorate([
43
+ Property(null)
44
+ ], FinetuneSettings.prototype, "hue", void 0);
45
+ __decorate([
46
+ Property(null)
47
+ ], FinetuneSettings.prototype, "saturation", void 0);
48
+ __decorate([
49
+ Property(null)
50
+ ], FinetuneSettings.prototype, "exposure", void 0);
51
+ __decorate([
52
+ Property(null)
53
+ ], FinetuneSettings.prototype, "opacity", void 0);
54
+ __decorate([
55
+ Property(null)
56
+ ], FinetuneSettings.prototype, "blur", void 0);
57
+ return FinetuneSettings;
58
+ }(ChildProperty));
59
+ export { FinetuneSettings };
28
60
  /**
29
61
  * Image Editor is a graphical user interface that helps to edit an image by performing actions like selection,
30
62
  * cropping, rotating, inserting text and shapes (rectangles, ellipses, lines), and drawing free hand on top of an image.
@@ -51,7 +83,6 @@ var ImageEditor = /** @class */ (function (_super) {
51
83
  function ImageEditor(options, element) {
52
84
  var _this = _super.call(this, options, element) || this;
53
85
  _this.degree = 0; // current rotated state
54
- _this.isUndoRedo = false;
55
86
  _this.dragCanvas = false;
56
87
  _this.dragElement = '';
57
88
  _this.keyHistory = ''; // text history
@@ -72,24 +103,18 @@ var ImageEditor = /** @class */ (function (_super) {
72
103
  _this.pannStart = {};
73
104
  _this.pannEnd = {};
74
105
  _this.togglePan = false;
106
+ _this.disablePan = false;
75
107
  _this.lastX = 0;
76
108
  _this.lastY = 0;
77
109
  _this.dragStart = { x: 0, y: 0 };
78
- _this.dragged = false;
79
110
  _this.factor = 1; // current zoomed state
80
111
  _this.currFlipState = '';
81
112
  _this.touchEndPoint = {};
82
- _this.flipMethod = false;
83
- _this.flipDirection = '';
84
113
  _this.prevX = 0;
85
114
  _this.currX = 0;
86
115
  _this.prevY = 0;
87
116
  _this.currY = 0;
88
117
  _this.togglePen = false;
89
- _this.rotateMethod = false;
90
- _this.isBoldbtn = false;
91
- _this.isItalicbtn = false;
92
- _this.lastAction = '';
93
118
  _this.currentToolbar = 'main';
94
119
  _this.textStartPoints = { x: 0, y: 0 };
95
120
  _this.fontSizeColl = [];
@@ -100,11 +125,29 @@ var ImageEditor = /** @class */ (function (_super) {
100
125
  _this.activeObj = { activePoint: { startX: 0, startY: 0, endX: 0, endY: 0, width: 0, height: 0 },
101
126
  flipObjColl: [] };
102
127
  _this.currObjType = { shape: '', isDragging: false, isActiveObj: false, isText: false, isInitialText: false, isLine: false,
103
- isInitialLine: false, isCustomCrop: false, isZoomed: false };
128
+ isInitialLine: false, isCustomCrop: false, isZoomed: false, isFiltered: false, isSave: false };
104
129
  _this.defToolbarItems = [];
105
- _this.baseImgSrc = '';
130
+ _this.baseImgSrc = {};
106
131
  _this.isTimer = false;
107
132
  _this.isScreenOriented = false;
133
+ _this.isFirstMove = false;
134
+ _this.startTouches = [];
135
+ _this.tempTouches = [];
136
+ _this.adjustmentLevel = { brightness: 0, contrast: 0, hue: 0, opacity: 100, saturation: 0, blur: 0,
137
+ exposure: 0, sharpen: false, bw: false };
138
+ _this.tempAdjustmentLevel = { brightness: 0, contrast: 0, hue: 0, opacity: 100, saturation: 0, blur: 0,
139
+ exposure: 0, sharpen: false, bw: false };
140
+ _this.adjustmentValue = '';
141
+ _this.initialAdjustmentValue = '';
142
+ _this.tempAdjustmentValue = '';
143
+ _this.currentFilter = '';
144
+ _this.tempFilter = '';
145
+ _this.canvasFilter = '';
146
+ _this.sharpenedImgData = false;
147
+ _this.tempSharpenFilter = false;
148
+ _this.tempBWFilter = false;
149
+ _this.isBrightnessAdjusted = false;
150
+ _this.isInitialLoading = false;
108
151
  return _this;
109
152
  }
110
153
  ImageEditor_1 = ImageEditor;
@@ -134,8 +177,28 @@ var ImageEditor = /** @class */ (function (_super) {
134
177
  Crop: 'Crop',
135
178
  ZoomIn: 'Zoom In',
136
179
  ZoomOut: 'Zoom Out',
180
+ Undo: 'Undo',
181
+ Redo: 'Redo',
137
182
  Transform: 'Transform',
138
183
  Annotation: 'Annotation',
184
+ Finetune: 'Finetune',
185
+ Brightness: 'Brightness',
186
+ Contrast: 'Contrast',
187
+ Hue: 'Hue',
188
+ Saturation: 'Saturation',
189
+ Opacity: 'Opacity',
190
+ Blur: 'Blur',
191
+ Sharpen: 'Sharpen',
192
+ Exposure: 'Exposure',
193
+ Filter: 'Filter',
194
+ Default: 'Default',
195
+ Chrome: 'Chrome',
196
+ Cold: 'Cold',
197
+ Warm: 'Warm',
198
+ Grayscale: 'Grayscale',
199
+ BlackAndWhite: 'Black and White',
200
+ Sepia: 'Sepia',
201
+ Invert: 'Invert',
139
202
  Text: 'Add Text',
140
203
  Pen: 'Pen',
141
204
  Reset: 'Reset',
@@ -163,7 +226,6 @@ var ImageEditor = /** @class */ (function (_super) {
163
226
  Ellipse: 'Ellipse',
164
227
  Rectangle: 'Rectangle',
165
228
  Line: 'Line',
166
- Default: 'Default',
167
229
  Bold: 'Bold',
168
230
  Italic: 'Italic',
169
231
  BoldItalic: 'Bold Italic',
@@ -172,7 +234,8 @@ var ImageEditor = /** @class */ (function (_super) {
172
234
  Medium: 'Medium',
173
235
  Large: 'Large',
174
236
  XLarge: 'X-Large',
175
- ABC: 'ABC'
237
+ ABC: 'ABC',
238
+ Browse: 'Browse'
176
239
  };
177
240
  this.l10n = new L10n('image-editor', this.defaultLocale, this.locale);
178
241
  };
@@ -249,6 +312,12 @@ var ImageEditor = /** @class */ (function (_super) {
249
312
  this.upperContext.fillStyle = this.themeColl[this.theme]['secondaryColor'];
250
313
  }
251
314
  break;
315
+ case 'finetuneSettings':
316
+ if (newProperties.finetuneSettings) {
317
+ this.finetuneSettings = newProperties.finetuneSettings;
318
+ this.updateFinetunes();
319
+ }
320
+ break;
252
321
  }
253
322
  }
254
323
  };
@@ -262,19 +331,24 @@ var ImageEditor = /** @class */ (function (_super) {
262
331
  if (!this.element.getAttribute('class')) {
263
332
  this.element.removeAttribute('class');
264
333
  }
334
+ this.destroySubComponents();
265
335
  this.unwireEvent();
266
336
  _super.prototype.destroy.call(this);
267
337
  this.element.innerHTML = '';
268
338
  this.trigger('destroyed');
269
339
  };
270
340
  ImageEditor.prototype.initialize = function () {
341
+ this.updateFinetunes();
271
342
  this.createToolbar();
343
+ this.createContextualToolbar();
272
344
  this.createCanvas();
273
345
  this.wireEvent();
274
346
  this.updateContext(this.lowerContext);
275
347
  this.updateContext(this.upperContext);
276
348
  this.pannStart = { startX: 0, startY: 0, width: 0, height: 0 };
277
349
  this.pannEnd = { startX: 0, startY: 0, width: 0, height: 0 };
350
+ this.lowerContext.filter = this.canvasFilter = this.initialAdjustmentValue = this.adjustmentValue = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
351
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
278
352
  if (this.cssClass) {
279
353
  addClass([this.element], this.cssClass.split(' '));
280
354
  }
@@ -284,6 +358,39 @@ var ImageEditor = /** @class */ (function (_super) {
284
358
  });
285
359
  }
286
360
  };
361
+ ImageEditor.prototype.updateFinetunes = function () {
362
+ if (this.finetuneSettings) {
363
+ if (this.finetuneSettings.brightness) {
364
+ this.adjustmentLevel.brightness = this.finetuneSettings.brightness.defaultValue;
365
+ this.tempAdjustmentLevel.brightness = this.finetuneSettings.brightness.defaultValue;
366
+ }
367
+ if (this.finetuneSettings.contrast) {
368
+ this.adjustmentLevel.contrast = this.finetuneSettings.contrast.defaultValue;
369
+ this.tempAdjustmentLevel.contrast = this.finetuneSettings.contrast.defaultValue;
370
+ }
371
+ if (this.finetuneSettings.hue) {
372
+ this.adjustmentLevel.hue = this.finetuneSettings.hue.defaultValue;
373
+ this.tempAdjustmentLevel.hue = this.finetuneSettings.hue.defaultValue;
374
+ }
375
+ if (this.finetuneSettings.saturation) {
376
+ this.adjustmentLevel.saturation = this.finetuneSettings.saturation.defaultValue;
377
+ this.tempAdjustmentLevel.saturation = this.finetuneSettings.saturation.defaultValue;
378
+ }
379
+ if (this.finetuneSettings.exposure) {
380
+ this.adjustmentLevel.exposure = this.finetuneSettings.exposure.defaultValue;
381
+ this.tempAdjustmentLevel.exposure = this.finetuneSettings.exposure.defaultValue;
382
+ }
383
+ if (this.finetuneSettings.opacity) {
384
+ this.adjustmentLevel.opacity = this.finetuneSettings.opacity.defaultValue;
385
+ this.tempAdjustmentLevel.opacity = this.finetuneSettings.opacity.defaultValue;
386
+ }
387
+ if (this.finetuneSettings.blur) {
388
+ this.adjustmentLevel.blur = this.finetuneSettings.blur.defaultValue;
389
+ this.tempAdjustmentLevel.blur = this.finetuneSettings.blur.defaultValue;
390
+ }
391
+ this.isInitialLoading = true;
392
+ }
393
+ };
287
394
  /**
288
395
  *
289
396
  * This Method will add events to component (element, event, method, current reference)
@@ -306,7 +413,7 @@ var ImageEditor = /** @class */ (function (_super) {
306
413
  EventHandler.add(this.upperCanvas, 'dblclick', this.findTextPoint, this);
307
414
  EventHandler.add(this.textBox, 'mousedown', this.findTextPoint, this);
308
415
  window.addEventListener('resize', this.windowResizeHandler.bind(this));
309
- if ((!Browser.isIos && Browser.info.name !== 'safari')) {
416
+ if (!Browser.isIos && Browser.info.name !== 'safari' && screen && screen.orientation) {
310
417
  screen.orientation.addEventListener('change', this.screenOrientation.bind(this));
311
418
  }
312
419
  };
@@ -328,6 +435,35 @@ var ImageEditor = /** @class */ (function (_super) {
328
435
  EventHandler.remove(this.lowerCanvas, 'mouseup', this.canvasMouseUpHandler);
329
436
  EventHandler.remove(document, 'mouseup', this.canvasMouseUpHandler);
330
437
  };
438
+ ImageEditor.prototype.initializeFilter = function () {
439
+ this.setBrightness(this.adjustmentLevel.brightness);
440
+ this.setContrast(this.adjustmentLevel.contrast);
441
+ this.setHue(this.adjustmentLevel.hue);
442
+ this.setSaturation(this.adjustmentLevel.saturation);
443
+ this.setExposure(this.adjustmentLevel.exposure);
444
+ this.setOpacity(this.adjustmentLevel.opacity);
445
+ this.setBlur(this.adjustmentLevel.blur);
446
+ };
447
+ ImageEditor.prototype.destroySubComponents = function () {
448
+ var inputElement = this.element.querySelectorAll('input.e-control');
449
+ var btnElement = this.element.querySelectorAll('button.e-control');
450
+ for (var i = 0, len = inputElement.length; i < len; i++) {
451
+ if (inputElement[i].classList.contains('e-color-picker')) {
452
+ getComponent(inputElement[i], 'color-picker').destroy();
453
+ detach(select('input#' + inputElement[i].id, this.element));
454
+ }
455
+ }
456
+ for (var i = 0, len = btnElement.length; i < len; i++) {
457
+ if (btnElement[i].classList.contains('e-dropdown-btn')) {
458
+ getComponent(btnElement[i], 'dropdown-btn').destroy();
459
+ detach(select('button#' + btnElement[i].id, this.element));
460
+ }
461
+ else if (btnElement[i].classList.contains('e-btn')) {
462
+ getComponent(btnElement[i], 'btn').destroy();
463
+ detach(select('button#' + btnElement[i].id, this.element));
464
+ }
465
+ }
466
+ };
331
467
  ImageEditor.prototype.updateTheme = function () {
332
468
  if (this.theme !== '') {
333
469
  this.theme = this.toPascalCase(this.theme);
@@ -440,6 +576,58 @@ var ImageEditor = /** @class */ (function (_super) {
440
576
  this.toolbarHeight = 0;
441
577
  }
442
578
  };
579
+ ImageEditor.prototype.createContextualToolbar = function () {
580
+ if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.length > 0)) {
581
+ this.element.appendChild(this.createElement('div', { id: this.element.id + '_contextualToolbarArea',
582
+ className: 'e-contextual-toolbar-wrapper e-hide', attrs: { style: 'position: absolute;' }
583
+ }));
584
+ var toolbarArea = document.getElementById(this.element.id + '_contextualToolbarArea');
585
+ var toolbar_2 = this.createElement('div', { id: this.element.id + '_contextualToolbar' });
586
+ toolbarArea.appendChild(toolbar_2);
587
+ }
588
+ };
589
+ ImageEditor.prototype.updateContextualToolbar = function (type, cType) {
590
+ if (this.toolbarTemplate) {
591
+ this.toolbarTemplateFn();
592
+ }
593
+ else {
594
+ var toolbarArea = this.element.querySelector('#' + this.element.id + '_toolbarArea');
595
+ var contextualToolbarArea = this.element.querySelector('#' + this.element.id + '_contextualToolbarArea');
596
+ if (!isNullOrUndefined(toolbarArea) && !isNullOrUndefined(contextualToolbarArea)) {
597
+ contextualToolbarArea.classList.remove('e-hide');
598
+ contextualToolbarArea.style.left = toolbarArea.offsetLeft + 'px';
599
+ }
600
+ if (type === 'filter') {
601
+ if (!isNullOrUndefined(document.getElementById(this.element.id + '_toolbar')) && this.defToolbarItems.length > 0) {
602
+ getComponent(document.getElementById(this.element.id + '_toolbar'), 'toolbar').destroy();
603
+ }
604
+ if (Browser.isDevice) {
605
+ this.initToolbarItem(false, true, true);
606
+ }
607
+ else {
608
+ this.initToolbarItem(true);
609
+ }
610
+ this.refreshSlider();
611
+ this.initFilterToolbarItem();
612
+ }
613
+ else {
614
+ if (!isNullOrUndefined(document.querySelector('#' + this.element.id + '_contextualToolbar'))
615
+ && document.querySelector('#' + this.element.id + '_contextualToolbar').classList.contains('e-control')) {
616
+ getComponent(document.getElementById(this.element.id + '_contextualToolbar'), 'toolbar').destroy();
617
+ }
618
+ this.refreshSlider();
619
+ this.renderSlider(cType);
620
+ }
621
+ if (Browser.isDevice) {
622
+ var cHt = contextualToolbarArea.offsetHeight;
623
+ var ht = this.element.querySelector('#' + this.element.id + '_canvasWrapper').offsetHeight;
624
+ contextualToolbarArea.style.top = this.toolbarHeight + ht - cHt + 'px';
625
+ }
626
+ else {
627
+ contextualToolbarArea.style.top = this.toolbarHeight + 1 + 'px';
628
+ }
629
+ }
630
+ };
443
631
  ImageEditor.prototype.createBottomToolbar = function () {
444
632
  if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.length > 0)) {
445
633
  this.element.appendChild(this.createElement('div', {
@@ -476,8 +664,8 @@ var ImageEditor = /** @class */ (function (_super) {
476
664
  }, '#' + this.element.id + '_bottomToolbar');
477
665
  if (this.defToolbarItems.length > 0 && (!isNullOrUndefined(document.getElementById(this.element.id + '_bottomToolbar')))) {
478
666
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
479
- var toolbar_2 = getComponent(this.element.id + '_bottomToolbar', 'toolbar');
480
- toolbar_2.refreshOverflow();
667
+ var toolbar_3 = getComponent(this.element.id + '_bottomToolbar', 'toolbar');
668
+ toolbar_3.refreshOverflow();
481
669
  }
482
670
  }
483
671
  }
@@ -580,6 +768,14 @@ var ImageEditor = /** @class */ (function (_super) {
580
768
  template: '<button id="' + this.element.id + '_transformBtn"></button>'
581
769
  });
582
770
  }
771
+ if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Finetune') > -1)) {
772
+ toolbarItems.push({ id: this.element.id + '_adjustment', prefixIcon: 'e-icons e-adjustment', cssClass: 'top-icon e-adjustment',
773
+ tooltipText: this.l10n.getConstant('Finetune'), align: 'Center' });
774
+ }
775
+ if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Filter') > -1)) {
776
+ toolbarItems.push({ id: this.element.id + '_filter', prefixIcon: 'e-icons e-filters', cssClass: 'top-icon e-filters',
777
+ tooltipText: this.l10n.getConstant('Filter'), align: 'Center' });
778
+ }
583
779
  var tempToolbarItems = this.processToolbar('center');
584
780
  for (var i = 0, len = tempToolbarItems.length; i < len; i++) {
585
781
  toolbarItems.push(tempToolbarItems[i]);
@@ -687,8 +883,8 @@ var ImageEditor = /** @class */ (function (_super) {
687
883
  }
688
884
  if (this.isToolbar() && (!isNullOrUndefined(document.getElementById(this.element.id + '_toolbar')))) {
689
885
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
690
- var toolbar_3 = getComponent(this.element.id + '_toolbar', 'toolbar');
691
- toolbar_3.refreshOverflow();
886
+ var toolbar_4 = getComponent(this.element.id + '_toolbar', 'toolbar');
887
+ toolbar_4.refreshOverflow();
692
888
  }
693
889
  }
694
890
  };
@@ -785,7 +981,7 @@ var ImageEditor = /** @class */ (function (_super) {
785
981
  items.push({ text: this.l10n.getConstant('Custom'), id: 'custom', iconCss: 'e-icons e-custom' });
786
982
  }
787
983
  if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('CircleSelection') > -1)) {
788
- items.push({ text: this.l10n.getConstant('Circle'), id: 'ellipse', iconCss: 'e-icons e-circle' });
984
+ items.push({ text: this.l10n.getConstant('Circle'), id: 'circle', iconCss: 'e-icons e-circle' });
789
985
  }
790
986
  if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('SquareSelection') > -1)) {
791
987
  items.push({ text: this.l10n.getConstant('Square'), id: 'square', iconCss: 'e-icons e-square' });
@@ -868,7 +1064,7 @@ var ImageEditor = /** @class */ (function (_super) {
868
1064
  }
869
1065
  };
870
1066
  ImageEditor.prototype.cropSelect = function (args) {
871
- var text = args.item.text;
1067
+ var text = args.item.id;
872
1068
  this.select(text);
873
1069
  this.refreshToolbar('main', true, true);
874
1070
  };
@@ -974,9 +1170,16 @@ var ImageEditor = /** @class */ (function (_super) {
974
1170
  modeSwitcher: false, noColor: true, value: '',
975
1171
  showButtons: false, mode: 'Palette', cssClass: 'e-shape-fill-color',
976
1172
  change: function (args) {
1173
+ _this.pushActItemIntoObj();
1174
+ var objColl = extend([], _this.objColl, [], true);
1175
+ _this.objColl.pop();
977
1176
  proxy.activeObj.strokeSettings.fillColor = args.currentValue.hex;
978
1177
  proxy.strokeSettings.fillColor = proxy.activeObj.strokeSettings.fillColor;
979
- proxy.redrawShape(_this.activeObj);
1178
+ _this.objColl.push(_this.activeObj);
1179
+ proxy.undoRedoColl.push({ operation: 'shapeTransform', value: null,
1180
+ currentObj: extend([], proxy.objColl, [], true), previousObj: objColl, factor: proxy.factor,
1181
+ sharpen: proxy.adjustmentLevel.sharpen, bw: proxy.adjustmentLevel.bw });
1182
+ proxy.redrawShape(proxy.objColl[proxy.objColl.length - 1]);
980
1183
  if (args.currentValue.rgba === '') {
981
1184
  fillDDB_1.element.children[0].classList.add('e-nocolor-item');
982
1185
  }
@@ -1009,10 +1212,17 @@ var ImageEditor = /** @class */ (function (_super) {
1009
1212
  modeSwitcher: false, noColor: false, value: '#fff',
1010
1213
  showButtons: false, mode: 'Palette', cssClass: 'e-shape-stroke-color',
1011
1214
  change: function (args) {
1215
+ _this.pushActItemIntoObj();
1216
+ var objColl = extend([], _this.objColl, [], true);
1217
+ _this.objColl.pop();
1012
1218
  proxy.activeObj.strokeSettings.strokeColor = args.currentValue.hex;
1013
1219
  proxy.strokeSettings.strokeColor = proxy.activeObj.strokeSettings.strokeColor;
1014
1220
  if (!proxy.togglePen) {
1015
- proxy.redrawShape(_this.activeObj);
1221
+ _this.objColl.push(_this.activeObj);
1222
+ proxy.undoRedoColl.push({ operation: 'shapeTransform', value: null,
1223
+ currentObj: extend([], proxy.objColl, [], true), previousObj: objColl, factor: proxy.factor,
1224
+ sharpen: proxy.adjustmentLevel.sharpen, bw: proxy.adjustmentLevel.bw });
1225
+ proxy.redrawShape(proxy.objColl[proxy.objColl.length - 1]);
1016
1226
  }
1017
1227
  strokeDDB_1.element.children[0].style.backgroundColor = args.currentValue.rgba;
1018
1228
  strokeDDB_1.toggle();
@@ -1057,9 +1267,14 @@ var ImageEditor = /** @class */ (function (_super) {
1057
1267
  args.element.parentElement.offsetHeight + 'px';
1058
1268
  }
1059
1269
  var activeBtn = spanElem_1.innerHTML;
1060
- args.element.querySelector('[aria-label = ' + '"' + activeBtn + '"' + ']').classList.add('e-selected-btn');
1270
+ if (activeBtn !== '') {
1271
+ args.element.querySelector('[aria-label = ' + '"' + activeBtn + '"' + ']').classList.add('e-selected-btn');
1272
+ }
1061
1273
  },
1062
1274
  select: function (args) {
1275
+ _this.pushActItemIntoObj();
1276
+ var objColl = extend([], _this.objColl, [], true);
1277
+ _this.objColl.pop();
1063
1278
  spanElem_1.textContent = args.item.text;
1064
1279
  _this.activeObj.strokeSettings.strokeWidth = parseInt(args.item.id, 10);
1065
1280
  if (_this.lowerCanvas.width > _this.lowerCanvas.height) {
@@ -1069,19 +1284,23 @@ var ImageEditor = /** @class */ (function (_super) {
1069
1284
  _this.activeObj.strokeSettings.strokeWidth *= ((ratio.height + ratio.width) / _this.factor);
1070
1285
  }
1071
1286
  _this.strokeSettings.strokeWidth = _this.activeObj.strokeSettings.strokeWidth;
1072
- _this.redrawShape(_this.activeObj);
1287
+ _this.objColl.push(_this.activeObj);
1288
+ _this.undoRedoColl.push({ operation: 'shapeTransform', value: null,
1289
+ currentObj: extend([], _this.objColl, [], true), previousObj: objColl, factor: _this.factor,
1290
+ sharpen: _this.adjustmentLevel.sharpen, bw: _this.adjustmentLevel.bw });
1291
+ _this.redrawShape(_this.objColl[_this.objColl.length - 1]);
1073
1292
  if (Browser.isDevice) {
1074
1293
  if (!isNullOrUndefined(document.getElementById(_this.element.id + '_bottomToolbar'))) {
1075
1294
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
1076
- var toolbar_4 = getComponent(_this.element.id + '_bottomToolbar', 'toolbar');
1077
- toolbar_4.refreshOverflow();
1295
+ var toolbar_5 = getComponent(_this.element.id + '_bottomToolbar', 'toolbar');
1296
+ toolbar_5.refreshOverflow();
1078
1297
  }
1079
1298
  }
1080
1299
  else {
1081
1300
  if (!isNullOrUndefined(document.getElementById(_this.element.id + '_toolbar'))) {
1082
1301
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
1083
- var toolbar_5 = getComponent(_this.element.id + '_toolbar', 'toolbar');
1084
- toolbar_5.refreshOverflow();
1302
+ var toolbar_6 = getComponent(_this.element.id + '_toolbar', 'toolbar');
1303
+ toolbar_6.refreshOverflow();
1085
1304
  }
1086
1305
  }
1087
1306
  }
@@ -1197,17 +1416,26 @@ var ImageEditor = /** @class */ (function (_super) {
1197
1416
  modeSwitcher: false, value: '#fff',
1198
1417
  showButtons: false, mode: 'Palette', cssClass: 'e-text-fontt-color',
1199
1418
  change: function (args) {
1419
+ _this.pushActItemIntoObj();
1420
+ _this.objColl.pop();
1200
1421
  if (proxy.textBox.style.display === 'none') {
1201
1422
  proxy.strokeSettings.strokeColor = proxy.activeObj.strokeSettings.strokeColor = args.currentValue.hex;
1202
1423
  if (!proxy.togglePen) {
1203
- proxy.redrawShape(_this.activeObj);
1424
+ _this.objColl.push(_this.activeObj);
1425
+ proxy.redrawShape(proxy.objColl[proxy.objColl.length - 1]);
1204
1426
  }
1205
1427
  }
1206
1428
  else if (proxy.textBox.style.display === 'block') {
1207
1429
  proxy.textBox.style.color = args.currentValue.hex;
1430
+ var temp = proxy.activeObj.strokeSettings.strokeColor;
1431
+ proxy.activeObj.strokeSettings.strokeColor = args.currentValue.hex;
1432
+ _this.objColl.push(_this.activeObj);
1433
+ _this.objColl.pop();
1434
+ proxy.activeObj.strokeSettings.strokeColor = temp;
1208
1435
  }
1209
1436
  else if (!proxy.togglePen) {
1210
- proxy.redrawShape(_this.activeObj);
1437
+ _this.objColl.push(_this.activeObj);
1438
+ proxy.redrawShape(proxy.objColl[proxy.objColl.length - 1]);
1211
1439
  }
1212
1440
  strokeDDB_2.element.children[0].style.backgroundColor = args.currentValue.rgba;
1213
1441
  strokeDDB_2.toggle();
@@ -1229,6 +1457,17 @@ var ImageEditor = /** @class */ (function (_super) {
1229
1457
  = '#fff';
1230
1458
  }
1231
1459
  };
1460
+ ImageEditor.prototype.pushActItemIntoObj = function () {
1461
+ if (this.textBox.style.display === 'none') {
1462
+ this.objColl.push(this.activeObj);
1463
+ }
1464
+ else {
1465
+ var temp = extend({}, this.activeObj, {}, true);
1466
+ this.setTextBoxStylesToActObj();
1467
+ this.objColl.push(this.activeObj);
1468
+ this.activeObj = temp;
1469
+ }
1470
+ };
1232
1471
  ImageEditor.prototype.createTextBtn = function (items) {
1233
1472
  var _this = this;
1234
1473
  var ratio = this.calcRatio();
@@ -1266,6 +1505,8 @@ var ImageEditor = /** @class */ (function (_super) {
1266
1505
  + '"' + ']').classList.add('e-selected-btn');
1267
1506
  },
1268
1507
  select: function (args) {
1508
+ _this.pushActItemIntoObj();
1509
+ _this.objColl.pop();
1269
1510
  spanElem_2.textContent = args.item.text;
1270
1511
  if (Browser.isDevice) {
1271
1512
  spanElem_2.setAttribute('style', 'font-family:' + args.item.id);
@@ -1273,10 +1514,13 @@ var ImageEditor = /** @class */ (function (_super) {
1273
1514
  if (_this.textBox.style.display === 'block') {
1274
1515
  var temp = _this.activeObj.textSettings.fontFamily;
1275
1516
  _this.activeObj.textSettings.fontFamily = _this.toPascalCase(args.item.id);
1276
- _this.updateFontStyles();
1277
- var width = _this.upperContext.measureText(_this.activeObj.keyHistory).width +
1278
- _this.activeObj.textSettings.fontSize * 0.5;
1279
- _this.textBox.style.width = Browser.isDevice ? width + 'px' : (width * ((ratio.width + ratio.height) / 2)) + 'px';
1517
+ _this.redrawText(ratio);
1518
+ _this.objColl.push(_this.activeObj);
1519
+ _this.objColl.pop();
1520
+ _this.upperContext.clearRect(0, 0, _this.upperCanvas.width, _this.upperCanvas.height);
1521
+ var width = _this.activeObj.activePoint.width +
1522
+ _this.activeObj.textSettings.fontSize * 0.25;
1523
+ _this.textBox.style.width = width / ratio.width + 'px';
1280
1524
  _this.textBox.style.fontFamily = _this.toPascalCase(args.item.id);
1281
1525
  _this.activeObj.textSettings.fontFamily = temp;
1282
1526
  _this.updateFontStyles();
@@ -1284,7 +1528,8 @@ var ImageEditor = /** @class */ (function (_super) {
1284
1528
  else {
1285
1529
  _this.textSettings.fontFamily = _this.activeObj.textSettings.fontFamily = _this.toPascalCase(args.item.id);
1286
1530
  _this.redrawText(ratio);
1287
- _this.redrawShape(_this.activeObj);
1531
+ _this.objColl.push(_this.activeObj);
1532
+ _this.redrawShape(_this.objColl[_this.objColl.length - 1]);
1288
1533
  }
1289
1534
  }
1290
1535
  });
@@ -1383,10 +1628,14 @@ var ImageEditor = /** @class */ (function (_super) {
1383
1628
  args.element.querySelector('[aria-label *= ' + '"' + activeBtn + '"' + ']').classList.add('e-selected-btn');
1384
1629
  },
1385
1630
  select: function (args) {
1631
+ _this.pushActItemIntoObj();
1632
+ _this.objColl.pop();
1386
1633
  fontSizeSpanElem_1.textContent = args.item.text;
1387
1634
  if (_this.textBox.style.display === 'block') {
1388
1635
  var temp = _this.activeObj.textSettings.fontSize;
1389
1636
  _this.activeObj.textSettings.fontSize = parseInt(_this.fontSizeColl[(parseInt(args.item.text, 10) - 1)].text, 10);
1637
+ _this.objColl.push(_this.activeObj);
1638
+ _this.objColl.pop();
1390
1639
  var textStyle = '';
1391
1640
  if (_this.textBox.style.fontWeight === 'bold') {
1392
1641
  textStyle = 'bold ';
@@ -1418,11 +1667,13 @@ var ImageEditor = /** @class */ (function (_super) {
1418
1667
  var text = _this.getMaxText();
1419
1668
  var width = _this.upperContext.measureText(text).width +
1420
1669
  _this.activeObj.textSettings.fontSize * 0.5;
1421
- var height = rows.length * (_this.activeObj.textSettings.fontSize + _this.activeObj.textSettings.fontSize * 0.25);
1670
+ var height = rows.length * (_this.activeObj.textSettings.fontSize +
1671
+ _this.activeObj.textSettings.fontSize * 0.25);
1422
1672
  _this.setTextSelection(width, height);
1423
1673
  _this.updateActiveObject(ratio, _this.activeObj.activePoint, _this.activeObj);
1424
- _this.redrawShape(_this.activeObj);
1425
1674
  _this.redrawText(ratio);
1675
+ _this.objColl.push(_this.activeObj);
1676
+ _this.redrawShape(_this.objColl[_this.objColl.length - 1]);
1426
1677
  }
1427
1678
  }
1428
1679
  });
@@ -1473,14 +1724,43 @@ var ImageEditor = /** @class */ (function (_super) {
1473
1724
  this.activeObj.textSettings.italic = tempItalic;
1474
1725
  return width;
1475
1726
  };
1727
+ ImageEditor.prototype.updateObjColl = function (item) {
1728
+ var tempBold = this.activeObj.textSettings.bold;
1729
+ var tempItalic = this.activeObj.textSettings.italic;
1730
+ switch (item) {
1731
+ case 'default':
1732
+ this.activeObj.textSettings.bold = false;
1733
+ this.activeObj.textSettings.italic = false;
1734
+ break;
1735
+ case 'bold':
1736
+ this.activeObj.textSettings.bold = true;
1737
+ this.activeObj.textSettings.italic = false;
1738
+ break;
1739
+ case 'italic':
1740
+ this.activeObj.textSettings.bold = false;
1741
+ this.activeObj.textSettings.italic = true;
1742
+ break;
1743
+ case 'bolditalic':
1744
+ this.activeObj.textSettings.bold = true;
1745
+ this.activeObj.textSettings.italic = true;
1746
+ break;
1747
+ }
1748
+ this.objColl.push(this.activeObj);
1749
+ this.objColl.pop();
1750
+ this.activeObj.textSettings.bold = tempBold;
1751
+ this.activeObj.textSettings.italic = tempItalic;
1752
+ };
1476
1753
  ImageEditor.prototype.applyFontStyle = function (item, ratio) {
1754
+ this.pushActItemIntoObj();
1755
+ this.objColl.pop();
1477
1756
  switch (item) {
1478
1757
  case 'default':
1479
1758
  if (this.textBox.style.display === 'block') {
1480
- var width = this.getTextAreaWidth(item);
1481
- this.textBox.style.width = Browser.isDevice ? width + 'px' : (width * ((ratio.width + ratio.height) / 2)) + 'px';
1759
+ var width = this.getTextAreaWidth(item) / ratio.width;
1760
+ this.textBox.style.width = width + 'px';
1482
1761
  this.textBox.style.fontWeight = 'normal';
1483
1762
  this.textBox.style.fontStyle = 'normal';
1763
+ this.updateObjColl(item);
1484
1764
  }
1485
1765
  else {
1486
1766
  this.textSettings.bold = this.activeObj.textSettings.bold = false;
@@ -1490,10 +1770,11 @@ var ImageEditor = /** @class */ (function (_super) {
1490
1770
  break;
1491
1771
  case 'bold':
1492
1772
  if (this.textBox.style.display === 'block') {
1493
- var width = this.getTextAreaWidth(item);
1494
- this.textBox.style.width = Browser.isDevice ? width + 'px' : (width * ((ratio.width + ratio.height) / 2)) + 'px';
1773
+ var width = this.getTextAreaWidth(item) / ratio.width;
1774
+ this.textBox.style.width = width + 'px';
1495
1775
  this.textBox.style.fontWeight = 'bold';
1496
1776
  this.textBox.style.fontStyle = 'normal';
1777
+ this.updateObjColl(item);
1497
1778
  }
1498
1779
  else {
1499
1780
  this.textSettings.bold = this.activeObj.textSettings.bold = true;
@@ -1503,10 +1784,11 @@ var ImageEditor = /** @class */ (function (_super) {
1503
1784
  break;
1504
1785
  case 'italic':
1505
1786
  if (this.textBox.style.display === 'block') {
1506
- var width = this.getTextAreaWidth(item);
1507
- this.textBox.style.width = Browser.isDevice ? width + 'px' : (width * ((ratio.width + ratio.height) / 2)) + 'px';
1787
+ var width = this.getTextAreaWidth(item) / ratio.width;
1788
+ this.textBox.style.width = width + 'px';
1508
1789
  this.textBox.style.fontWeight = 'normal';
1509
1790
  this.textBox.style.fontStyle = 'italic';
1791
+ this.updateObjColl(item);
1510
1792
  }
1511
1793
  else {
1512
1794
  this.textSettings.bold = this.activeObj.textSettings.bold = false;
@@ -1516,10 +1798,11 @@ var ImageEditor = /** @class */ (function (_super) {
1516
1798
  break;
1517
1799
  case 'bolditalic':
1518
1800
  if (this.textBox.style.display === 'block') {
1519
- var width = this.getTextAreaWidth(item);
1520
- this.textBox.style.width = (width / ratio.width) + 'px';
1801
+ var width = this.getTextAreaWidth(item) / ratio.width;
1802
+ this.textBox.style.width = width + 'px';
1521
1803
  this.textBox.style.fontWeight = 'bold';
1522
1804
  this.textBox.style.fontStyle = 'italic';
1805
+ this.updateObjColl(item);
1523
1806
  }
1524
1807
  else {
1525
1808
  this.textSettings.bold = this.activeObj.textSettings.bold = true;
@@ -1547,12 +1830,25 @@ var ImageEditor = /** @class */ (function (_super) {
1547
1830
  this.createLeftToolbarControls();
1548
1831
  if (this.defToolbarItems.length > 0 && (!isNullOrUndefined(document.getElementById(this.element.id + '_toolbar')))) {
1549
1832
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
1550
- var toolbar_6 = getComponent(this.element.id + '_toolbar', 'toolbar');
1551
- toolbar_6.refreshOverflow();
1833
+ var toolbar_7 = getComponent(this.element.id + '_toolbar', 'toolbar');
1834
+ toolbar_7.refreshOverflow();
1835
+ }
1836
+ };
1837
+ ImageEditor.prototype.contextualToolbarClicked = function (args) {
1838
+ var selEle = this.element.querySelector('.e-contextual-toolbar-wrapper .e-toolbar-item.e-selected');
1839
+ if (selEle) {
1840
+ selEle.classList.remove('e-selected');
1552
1841
  }
1842
+ document.getElementById(args.item.id + 'Canvas').parentElement.parentElement.classList.add('e-selected');
1843
+ this.currObjType.isFiltered = true;
1844
+ var type = args.item.id.replace(this.element.id, '').split('_')[1];
1845
+ var imageFiltering = { filter: this.toPascalCase(type) };
1846
+ this.trigger('imageFiltering', imageFiltering);
1847
+ this.setFilter(type.toLowerCase());
1848
+ this.currentFilter = args.item.id;
1553
1849
  };
1554
1850
  ImageEditor.prototype.defToolbarClicked = function (args) {
1555
- var ratio = this.calcRatio();
1851
+ this.element.querySelector('.e-contextual-toolbar-wrapper').classList.add('e-hide');
1556
1852
  var zoomIn;
1557
1853
  var type = args.item.id.replace(this.element.id + '_', '').toLowerCase();
1558
1854
  var imageEditorObj = getInstance(document.getElementById(this.element.id), ImageEditor_1);
@@ -1571,61 +1867,23 @@ var ImageEditor = /** @class */ (function (_super) {
1571
1867
  if (!this.disabled) {
1572
1868
  switch (type) {
1573
1869
  case 'zoomin':
1870
+ this.currObjType.isFiltered = false;
1574
1871
  if (this.togglePen) {
1575
1872
  this.currObjType.isZoomed = true;
1576
1873
  this.freeHandDraw(false);
1577
1874
  }
1578
1875
  imageEditorObj.zoom(.1);
1579
- if (!this.togglePan) {
1580
- this.callMainToolbar(false, true);
1581
- }
1582
- if (this.factor > 0.95 && this.factor < 1.05) {
1583
- this.dragCanvas = this.togglePan = false;
1584
- this.callMainToolbar(false, true);
1585
- }
1586
- if (isNullOrUndefined(this.activeObj.activePoint) || this.activeObj.activePoint.width === 0) {
1587
- this.refreshToolbar('main');
1588
- }
1589
- else {
1590
- this.refreshToolbar('main', true, true);
1591
- }
1592
- panBtn = this.element.querySelector('.e-img-pan .e-btn');
1593
- if (!isNullOrUndefined(panBtn) && this.togglePan) {
1594
- panBtn.classList.add('e-selected-btn');
1595
- }
1596
- else if (!isNullOrUndefined(panBtn)) {
1597
- panBtn.classList.remove('e-selected-btn');
1598
- }
1599
1876
  break;
1600
1877
  case 'zoomout':
1878
+ this.currObjType.isFiltered = false;
1601
1879
  if (this.togglePen) {
1602
1880
  this.currObjType.isZoomed = true;
1603
1881
  this.freeHandDraw(false);
1604
1882
  }
1605
1883
  imageEditorObj.zoom(-.1);
1606
- if (!this.togglePan) {
1607
- this.callMainToolbar(false, true);
1608
- }
1609
- if (this.factor > 0.95 && this.factor < 1.05) {
1610
- this.dragCanvas = this.togglePan = false;
1611
- this.callMainToolbar(false, true);
1612
- }
1613
- if (isNullOrUndefined(this.activeObj.activePoint) || this.activeObj.activePoint.width === 0) {
1614
- this.refreshToolbar('main');
1615
- }
1616
- else {
1617
- this.refreshToolbar('main', true, true);
1618
- }
1619
- panBtn = this.element.querySelector('.e-img-pan .e-btn');
1620
- if (!isNullOrUndefined(panBtn) && this.togglePan) {
1621
- panBtn.classList.add('e-selected-btn');
1622
- }
1623
- else if (!isNullOrUndefined(panBtn)) {
1624
- panBtn.classList.remove('e-selected-btn');
1625
- }
1626
1884
  break;
1627
1885
  case 'pan':
1628
- this.currObjType.isCustomCrop = false;
1886
+ this.currObjType.isCustomCrop = this.currObjType.isFiltered = false;
1629
1887
  if (isCropSelection) {
1630
1888
  this.currObjType.isCustomCrop = false;
1631
1889
  this.refreshActiveObj();
@@ -1634,11 +1892,13 @@ var ImageEditor = /** @class */ (function (_super) {
1634
1892
  }
1635
1893
  if (this.togglePan) {
1636
1894
  this.cancelPan();
1895
+ this.disablePan = true;
1637
1896
  }
1638
1897
  else {
1639
1898
  panBtn = this.element.querySelector('.e-img-pan .e-btn');
1640
1899
  panBtn.classList.add('e-selected-btn');
1641
1900
  imageEditorObj.pan(true);
1901
+ this.disablePan = false;
1642
1902
  }
1643
1903
  zoomIn = document.querySelector('#' + this.element.id + '_zoomIn');
1644
1904
  if (!isNullOrUndefined(zoomIn) && this.factor >= 8) {
@@ -1656,112 +1916,113 @@ var ImageEditor = /** @class */ (function (_super) {
1656
1916
  this.activeObj.strokeSettings = this.tempStrokeSettings;
1657
1917
  this.activeObj.textSettings = this.tempTextSettings;
1658
1918
  }
1919
+ else if (!isNullOrUndefined(document.querySelector('#' + this.element.id + '_sliderWrapper')) ||
1920
+ this.currObjType.isFiltered) {
1921
+ this.lowerContext.filter = this.adjustmentValue = this.initialAdjustmentValue = this.tempAdjustmentValue;
1922
+ this.currentFilter = this.tempFilter;
1923
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
1924
+ this.redrawImgWithObj();
1925
+ this.currObjType.isFiltered = false;
1926
+ if (this.adjustmentLevel.sharpen || this.adjustmentLevel.bw) {
1927
+ if (this.adjustmentLevel.sharpen) {
1928
+ this.setSharpness(false);
1929
+ }
1930
+ else if (this.adjustmentLevel.bw) {
1931
+ this.setBlackAndWhiteFilter(false);
1932
+ }
1933
+ var tempFilter = this.lowerContext.filter;
1934
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
1935
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
1936
+ for (var j = 0; j < this.objColl.length; j++) {
1937
+ this.apply(this.objColl[j].shape, this.objColl[j]);
1938
+ this.refreshActiveObj();
1939
+ }
1940
+ this.lowerContext.filter = tempFilter;
1941
+ }
1942
+ this.adjustmentLevel = extend({}, this.tempAdjustmentLevel, {}, true);
1943
+ if (this.currentFilter === this.element.id + '_sharpen' || this.currentFilter === this.element.id + '_blackandwhite'
1944
+ || this.tempSharpenFilter || this.tempBWFilter) {
1945
+ if (this.currentFilter === this.element.id + '_sharpen' || this.tempSharpenFilter) {
1946
+ this.setSharpness(true);
1947
+ }
1948
+ else if (this.currentFilter === this.element.id + '_blackandwhite' || this.tempBWFilter) {
1949
+ this.setBlackAndWhiteFilter(true);
1950
+ }
1951
+ var tempFilter = this.lowerContext.filter;
1952
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
1953
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
1954
+ for (var j = 0; j < this.objColl.length; j++) {
1955
+ this.apply(this.objColl[j].shape, this.objColl[j]);
1956
+ this.refreshActiveObj();
1957
+ }
1958
+ this.lowerContext.filter = tempFilter;
1959
+ this.tempSharpenFilter = this.tempBWFilter = false;
1960
+ }
1961
+ this.element.querySelector('.e-contextual-toolbar-wrapper').classList.add('e-hide');
1962
+ }
1659
1963
  this.cancelItems();
1660
1964
  break;
1661
1965
  case 'ok':
1662
- if (isCropSelection) {
1663
- this.crop();
1664
- }
1665
- else if (this.togglePen) {
1666
- this.freeHandDraw(false);
1667
- }
1668
- else if (this.textBox.style.display === 'block') {
1669
- this.redrawActObj();
1670
- }
1671
- else {
1672
- this.applyActObj();
1673
- }
1674
- this.callMainToolbar(false);
1675
- break;
1676
- case 'text':
1677
- this.currObjType.isCustomCrop = false;
1678
- imageEditorObj.drawShapeText();
1679
- this.refreshToolbar(type);
1680
- break;
1681
- case 'pen':
1682
- this.currObjType.isCustomCrop = false;
1683
- this.freeHandDraw(true);
1684
- this.refreshToolbar(type);
1966
+ this.okBtn();
1685
1967
  break;
1686
1968
  case 'reset':
1687
1969
  imageEditorObj.reset();
1688
1970
  break;
1689
- case 'load':
1690
- break;
1691
- case 'save':
1971
+ case 'adjustment':
1972
+ this.upperCanvas.style.display = 'block';
1973
+ this.refreshToolbar('adjustment');
1974
+ this.lowerContext.filter = this.initialAdjustmentValue;
1975
+ this.tempAdjustmentValue = this.lowerContext.filter;
1976
+ this.tempAdjustmentLevel = extend({}, this.adjustmentLevel, {}, true);
1977
+ this.tempFilter = this.currentFilter;
1978
+ this.tempSharpenFilter = this.adjustmentLevel.sharpen;
1979
+ this.tempBWFilter = this.adjustmentLevel.bw;
1692
1980
  break;
1693
- case 'select':
1981
+ case 'brightness':
1982
+ case 'contrast':
1983
+ case 'hue':
1984
+ case 'saturation':
1985
+ case 'opacity':
1986
+ case 'blur':
1987
+ case 'exposure':
1988
+ this.unselectBtn();
1989
+ this.currObjType.isFiltered = true;
1990
+ this.refreshToolbar('color', null, null, null, type);
1991
+ document.getElementById(this.element.id + '_' + type).classList.add('e-selected-btn');
1694
1992
  break;
1695
- case 'bold':
1696
- this.currObjType.isCustomCrop = false;
1697
- if (!this.isBoldbtn) {
1698
- this.activeObj.textSettings.bold = true;
1699
- this.isBoldbtn = true;
1700
- this.redrawText(ratio);
1701
- }
1702
- else {
1703
- this.activeObj.textSettings.bold = false;
1704
- this.isBoldbtn = false;
1705
- this.redrawText(ratio);
1993
+ case 'filter':
1994
+ this.upperCanvas.style.display = 'block';
1995
+ this.refreshToolbar('filter');
1996
+ this.lowerContext.filter = this.initialAdjustmentValue;
1997
+ this.tempAdjustmentValue = this.lowerContext.filter;
1998
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
1999
+ this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
2000
+ for (var j = 0; j < this.objColl.length; j++) {
2001
+ this.apply(this.objColl[j].shape, this.objColl[j]);
2002
+ this.refreshActiveObj();
1706
2003
  }
2004
+ this.tempAdjustmentLevel = extend({}, this.adjustmentLevel, {}, true);
2005
+ this.tempFilter = this.currentFilter;
2006
+ this.tempSharpenFilter = this.adjustmentLevel.sharpen;
2007
+ this.tempBWFilter = this.adjustmentLevel.bw;
1707
2008
  break;
1708
- case 'italic':
1709
- this.currObjType.isCustomCrop = false;
1710
- if (!this.isItalicbtn) {
1711
- this.activeObj.textSettings.italic = true;
1712
- if (this.activeObj.textSettings.bold) {
1713
- this.upperContext.font = 'italic bold ' + this.activeObj.textSettings.fontSize + 'px' +
1714
- ' ' + this.activeObj.textSettings.fontFamily;
1715
- }
1716
- else {
1717
- this.upperContext.font = 'italic ' + this.activeObj.textSettings.fontSize + 'px' + ' ' +
1718
- this.activeObj.textSettings.fontFamily;
1719
- }
1720
- var width = this.upperContext.measureText(this.activeObj.keyHistory).width +
1721
- this.activeObj.textSettings.fontSize * 0.5;
1722
- var height = this.activeObj.textSettings.fontSize + this.activeObj.textSettings.fontSize * 0.25;
1723
- this.setTextSelection(width, height);
1724
- this.updateActiveObject(ratio, this.activeObj.activePoint, this.activeObj);
1725
- this.redrawShape(this.activeObj);
1726
- this.isItalicbtn = true;
1727
- }
1728
- else {
1729
- this.activeObj.textSettings.italic = false;
1730
- if (this.activeObj.textSettings.bold) {
1731
- this.upperContext.font = 'bold ' + this.activeObj.textSettings.fontSize + 'px' + ' ' + this.activeObj.textSettings.fontFamily;
1732
- }
1733
- else {
1734
- this.upperContext.font = this.activeObj.textSettings.fontSize + 'px' + ' ' + this.activeObj.textSettings.fontFamily;
1735
- }
1736
- var width = this.upperContext.measureText(this.activeObj.keyHistory).width +
1737
- this.activeObj.textSettings.fontSize * 0.5;
1738
- var height = this.activeObj.textSettings.fontSize + this.activeObj.textSettings.fontSize * 0.25;
1739
- this.setTextSelection(width, height);
1740
- this.updateActiveObject(ratio, this.activeObj.activePoint, this.activeObj);
1741
- this.redrawShape(this.activeObj);
1742
- this.isItalicbtn = false;
1743
- }
2009
+ case 'default':
2010
+ case 'chrome':
2011
+ case 'cold':
2012
+ case 'warm':
2013
+ case 'grayscale':
2014
+ case 'blackandwhite':
2015
+ case 'sepia':
2016
+ case 'invert':
2017
+ case 'sharpen':
2018
+ this.currObjType.isFiltered = true;
2019
+ this.setFilter(type);
1744
2020
  break;
1745
2021
  }
1746
2022
  }
1747
2023
  this.trigger('toolbarItemClicked', args);
1748
2024
  };
1749
- ImageEditor.prototype.cancelPan = function () {
1750
- this.applyActObj();
1751
- var panBtn = this.element.querySelector('.e-img-pan .e-btn');
1752
- panBtn.classList.remove('e-selected-btn');
1753
- this.pan(false);
1754
- };
1755
- ImageEditor.prototype.callMainToolbar = function (isApplyBtn, isZooming) {
1756
- if (this.factor === 1) {
1757
- this.refreshToolbar('main', isApplyBtn, false, isZooming);
1758
- }
1759
- else {
1760
- this.refreshToolbar('main', isApplyBtn, false, isZooming);
1761
- }
1762
- };
1763
- ImageEditor.prototype.cancelItems = function () {
1764
- var ratio = this.calcRatio();
2025
+ ImageEditor.prototype.okBtn = function () {
1765
2026
  var isCropSelection = false;
1766
2027
  var splitWords;
1767
2028
  if (this.activeObj.shape !== undefined) {
@@ -1773,96 +2034,784 @@ var ImageEditor = /** @class */ (function (_super) {
1773
2034
  else if (splitWords !== undefined && splitWords[0] === 'crop') {
1774
2035
  isCropSelection = true;
1775
2036
  }
1776
- if (this.togglePen) {
1777
- this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
1778
- this.togglePen = false;
1779
- this.upperCanvas.style.cursor = 'default';
1780
- this.penDrawColl = [];
1781
- this.imageEditorPointsColl = [];
2037
+ var selElem = this.element.querySelector('.e-contextual-toolbar-wrapper .e-toolbar-item.e-selected');
2038
+ if (selElem) {
2039
+ this.currentFilter = selElem.children[0].children[0].id.replace('Canvas', '');
1782
2040
  }
1783
- else if (this.activeObj.shape === 'text') {
1784
- this.activeObj.strokeSettings = this.tempStrokeSettings;
1785
- this.activeObj.textSettings = this.tempTextSettings;
1786
- if (this.activeObj.keyHistory === 'Enter Text' && this.activeObj.activePoint.startX === this.textStartPoints.x
1787
- && this.activeObj.activePoint.startY === this.textStartPoints.y) {
1788
- this.refreshActiveObj();
1789
- this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
1790
- this.drawShapeText();
1791
- }
1792
- else {
1793
- this.redrawText(ratio);
1794
- this.redrawShape(this.activeObj);
1795
- if (!isCropSelection && this.activeObj.topLeftCircle !== undefined) {
1796
- this.applyActObj();
1797
- }
1798
- this.clearSelection();
1799
- }
1800
- this.tempTextSettings = { text: 'Enter Text', fontFamily: 'Arial', fontSize: null, bold: false, italic: false, underline: false };
2041
+ if (isCropSelection) {
2042
+ this.crop();
1801
2043
  }
1802
- else if (this.activeObj.shape === 'rectangle' || this.activeObj.shape === 'ellipse' || this.activeObj.shape === 'line') {
1803
- this.activeObj.strokeSettings = this.tempStrokeSettings;
1804
- this.redrawShape(this.activeObj);
1805
- this.applyActObj();
2044
+ else if (this.togglePen) {
2045
+ this.freeHandDraw(false);
2046
+ }
2047
+ else if (this.textBox.style.display === 'block') {
2048
+ this.redrawActObj();
2049
+ }
2050
+ else if (!isNullOrUndefined(document.querySelector('#' + this.element.id + '_sliderWrapper')) ||
2051
+ this.currObjType.isFiltered) {
2052
+ this.initialAdjustmentValue = this.canvasFilter = this.lowerContext.filter;
2053
+ this.currObjType.isFiltered = false;
1806
2054
  }
1807
2055
  else {
1808
- this.refreshActiveObj();
1809
- this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
2056
+ this.applyActObj();
1810
2057
  }
1811
- this.upperCanvas.style.cursor = 'default';
1812
- this.currObjType.isCustomCrop = false;
1813
- this.tempStrokeSettings = { strokeColor: '#fff', fillColor: '', strokeWidth: null };
1814
- this.callMainToolbar();
2058
+ this.callMainToolbar(false);
1815
2059
  };
1816
- ImageEditor.prototype.gradient = function (a, b) {
1817
- return (b.y - a.y) / (b.x - a.x);
2060
+ ImageEditor.prototype.unselectBtn = function () {
2061
+ if (document.querySelector('#' + this.element.id + '_brightness').classList.contains('e-selected-btn')) {
2062
+ document.querySelector('#' + this.element.id + '_brightness').classList.remove('e-selected-btn');
2063
+ }
2064
+ else if (document.querySelector('#' + this.element.id + '_contrast').classList.contains('e-selected-btn')) {
2065
+ document.querySelector('#' + this.element.id + '_contrast').classList.remove('e-selected-btn');
2066
+ }
2067
+ else if (document.querySelector('#' + this.element.id + '_hue').classList.contains('e-selected-btn')) {
2068
+ document.querySelector('#' + this.element.id + '_hue').classList.remove('e-selected-btn');
2069
+ }
2070
+ else if (document.querySelector('#' + this.element.id + '_saturation').classList.contains('e-selected-btn')) {
2071
+ document.querySelector('#' + this.element.id + '_saturation').classList.remove('e-selected-btn');
2072
+ }
2073
+ else if (document.querySelector('#' + this.element.id + '_opacity').classList.contains('e-selected-btn')) {
2074
+ document.querySelector('#' + this.element.id + '_opacity').classList.remove('e-selected-btn');
2075
+ }
2076
+ else if (document.querySelector('#' + this.element.id + '_blur').classList.contains('e-selected-btn')) {
2077
+ document.querySelector('#' + this.element.id + '_blur').classList.remove('e-selected-btn');
2078
+ }
2079
+ else if (document.querySelector('#' + this.element.id + '_exposure').classList.contains('e-selected-btn')) {
2080
+ document.querySelector('#' + this.element.id + '_exposure').classList.remove('e-selected-btn');
2081
+ }
1818
2082
  };
1819
- ImageEditor.prototype.applyPenDraw = function () {
1820
- if (this.togglePen && this.factor === 1 && !this.currObjType.isZoomed) {
1821
- this.apply();
1822
- this.penDrawColl = [];
1823
- this.imageEditorPointsColl = [];
2083
+ ImageEditor.prototype.refreshSlider = function () {
2084
+ var sliderWrapper = document.querySelector('#' + this.element.id + '_sliderWrapper');
2085
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
2086
+ var slider = document.querySelector('.e-slider');
2087
+ var hdrWrapper = document.querySelector('#' + this.element.id + '_headWrapper');
2088
+ if (hdrWrapper) {
2089
+ hdrWrapper.style.display = 'none';
1824
2090
  }
1825
- else {
1826
- var tempCanvas = this.lowerCanvas.appendChild(this.createElement('canvas', {
1827
- id: this.element.id + '_tempCanvas', attrs: { name: 'canvasImage' }
1828
- }));
1829
- var tempContext = tempCanvas.getContext('2d');
1830
- tempCanvas.width = this.lowerCanvas.width;
1831
- tempCanvas.height = this.lowerCanvas.height;
1832
- tempContext.drawImage(this.inMemoryCanvas, 0, 0);
1833
- this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
1834
- for (var i = 0; i < this.penDrawColl.length; i++) {
1835
- tempContext.lineWidth = 2 * this.penDrawColl[i].strokeWidth;
1836
- tempContext.strokeStyle = this.penDrawColl[i].strokeColor;
1837
- var nexP = void 0;
1838
- var preP = void 0;
1839
- var f = 0.3;
1840
- var t = 1;
1841
- tempContext.beginPath();
1842
- tempContext.moveTo(this.penDrawColl[i].points[0].x, this.penDrawColl[i].points[0].y);
1843
- var m = 0;
1844
- var dx1 = 0;
1845
- var dx2 = 0;
1846
- var dy1 = 0;
1847
- var dy2 = 0;
1848
- preP = this.penDrawColl[i].points[0];
1849
- for (var j = 1; j < this.penDrawColl[i].points.length; j++) {
1850
- var curP = this.penDrawColl[i].points[j];
1851
- nexP = this.penDrawColl[i].points[j + 1];
1852
- if (nexP) {
1853
- m = this.gradient(preP, nexP);
1854
- dx2 = (nexP.x - curP.x) * -f;
1855
- dy2 = dx2 * m * t;
1856
- }
1857
- else {
1858
- dx2 = 0;
1859
- dy2 = 0;
1860
- }
1861
- tempContext.bezierCurveTo(preP.x - dx1, preP.y - dy1, curP.x + dx2, curP.y + dy2, curP.x, curP.y);
1862
- dx1 = dx2;
1863
- dy1 = dy2;
1864
- preP = curP;
1865
- if (this.penDrawColl[i].points.length > 2) {
2091
+ if (!isNullOrUndefined(sliderWrapper) && !isNullOrUndefined(slider)) {
2092
+ slider.ej2_instances[0].destroy();
2093
+ sliderWrapper.remove();
2094
+ }
2095
+ };
2096
+ ImageEditor.prototype.updateAdjustment = function (type, value, isPreview) {
2097
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
2098
+ var splitWords = this.lowerContext.filter.split(' ');
2099
+ var values = [];
2100
+ var opacityValue;
2101
+ var brightnessValue;
2102
+ if (splitWords[4] !== undefined) {
2103
+ opacityValue = parseFloat(splitWords[4].split('(')[1]);
2104
+ }
2105
+ if (splitWords[0] !== undefined) {
2106
+ brightnessValue = parseFloat(splitWords[0].split('(')[1]);
2107
+ }
2108
+ var brightness = this.getFilterValue(this.adjustmentLevel.brightness);
2109
+ var saturation = this.getFilterValue(this.adjustmentLevel.saturation);
2110
+ if (type !== 'brightness' && type !== 'contrast' && type !== 'hue' && type !== 'saturation' && type !== 'exposure'
2111
+ && type !== 'opacity' && type !== 'blur') {
2112
+ if (isNullOrUndefined(isPreview) && (this.adjustmentLevel.sharpen || this.adjustmentLevel.bw)) {
2113
+ if (this.adjustmentLevel.sharpen) {
2114
+ this.setSharpness(false);
2115
+ }
2116
+ else if (this.adjustmentLevel.bw) {
2117
+ this.setBlackAndWhiteFilter(false);
2118
+ }
2119
+ var temp_1 = this.lowerContext.filter;
2120
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
2121
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
2122
+ for (var i = 0; i < this.objColl.length; i++) {
2123
+ this.apply(this.objColl[i].shape, this.objColl[i]);
2124
+ this.refreshActiveObj();
2125
+ }
2126
+ this.lowerContext.filter = temp_1;
2127
+ }
2128
+ }
2129
+ if (brightness !== 1) {
2130
+ splitWords[4] = 'opacity(' + (opacityValue - 0.3) + ')';
2131
+ }
2132
+ var saturate;
2133
+ var bright;
2134
+ var contrast;
2135
+ var saturatePercentage;
2136
+ var saturatePercent;
2137
+ var tempFilter;
2138
+ var temp;
2139
+ switch (type) {
2140
+ case 'brightness':
2141
+ if (splitWords[3].split) {
2142
+ if (parseFloat(splitWords[3].split('(')[1]) !== 100) {
2143
+ value += 0.1;
2144
+ }
2145
+ }
2146
+ splitWords[0] = 'brightness(' + value + ')';
2147
+ this.adjustmentValue = splitWords.join(' ');
2148
+ break;
2149
+ case 'contrast':
2150
+ splitWords[1] = 'contrast(' + value + '%)';
2151
+ this.adjustmentValue = splitWords.join(' ');
2152
+ break;
2153
+ case 'hue':
2154
+ splitWords[2] = 'hue-rotate(' + value + 'deg)';
2155
+ this.adjustmentValue = splitWords.join(' ');
2156
+ break;
2157
+ case 'saturation':
2158
+ splitWords[3] = 'saturate(' + value + '%)';
2159
+ if (saturation !== 1) {
2160
+ splitWords[0] = 'brightness(' + (brightnessValue + 0.1) + ')';
2161
+ }
2162
+ this.adjustmentValue = splitWords.join(' ');
2163
+ break;
2164
+ case 'opacity':
2165
+ if (parseFloat(splitWords[0].split('(')[1]) !== 1) {
2166
+ value -= 0.2;
2167
+ }
2168
+ splitWords[4] = 'opacity(' + value + ')';
2169
+ this.adjustmentValue = splitWords.join(' ');
2170
+ break;
2171
+ case 'blur':
2172
+ splitWords[5] = 'blur(' + value + 'px)';
2173
+ this.adjustmentValue = splitWords.join(' ');
2174
+ break;
2175
+ case 'exposure':
2176
+ if (brightness !== 1) {
2177
+ splitWords[4] = 'opacity(' + (opacityValue - 0.3) + ')';
2178
+ }
2179
+ if (value > 1) {
2180
+ value -= 1;
2181
+ value += brightness;
2182
+ }
2183
+ else if (value < 1) {
2184
+ value = 1 - value;
2185
+ value = brightness - value;
2186
+ }
2187
+ splitWords[0] = 'brightness(' + value + ')';
2188
+ this.adjustmentValue = splitWords.join(' ');
2189
+ break;
2190
+ case 'chrome':
2191
+ saturate = this.getSaturationFilterValue(this.adjustmentLevel.saturation);
2192
+ saturate *= 100;
2193
+ value = saturate + (saturate * 0.4);
2194
+ splitWords[3] = 'saturate(' + value + '%)';
2195
+ values = this.adjustmentValue.split(' ');
2196
+ splitWords[0] = values[0];
2197
+ splitWords[1] = values[1];
2198
+ splitWords[2] = values[2];
2199
+ splitWords[4] = values[4];
2200
+ splitWords[5] = values[5];
2201
+ splitWords[6] = 'sepia(0%)';
2202
+ splitWords[7] = 'grayscale(0%)';
2203
+ splitWords[8] = 'invert(0%)';
2204
+ break;
2205
+ case 'cold':
2206
+ // Adjusting Brightness
2207
+ bright = this.getFilterValue(this.adjustmentLevel.brightness);
2208
+ bright *= 100;
2209
+ value = bright * 0.9;
2210
+ splitWords[0] = 'brightness(' + value + '%)';
2211
+ // Adjusting Contrast
2212
+ contrast = this.getFilterValue(this.adjustmentLevel.contrast);
2213
+ contrast *= 100;
2214
+ value = contrast + (contrast * 0.5);
2215
+ splitWords[1] = 'contrast(' + value + '%)';
2216
+ // Adjusting Saturation
2217
+ saturatePercentage = this.getSaturationFilterValue(this.adjustmentLevel.saturation);
2218
+ saturatePercentage *= 100;
2219
+ value = saturatePercentage;
2220
+ splitWords[3] = 'saturate(' + value + '%)';
2221
+ values = this.adjustmentValue.split(' ');
2222
+ splitWords[2] = values[2];
2223
+ splitWords[4] = values[4];
2224
+ splitWords[5] = values[5];
2225
+ splitWords[6] = 'sepia(0%)';
2226
+ splitWords[7] = 'grayscale(0%)';
2227
+ splitWords[8] = 'invert(0%)';
2228
+ break;
2229
+ case 'warm':
2230
+ saturatePercent = this.getSaturationFilterValue(this.adjustmentLevel.saturation);
2231
+ saturatePercent *= 100;
2232
+ value = saturatePercent + (saturatePercent * 0.4);
2233
+ splitWords[3] = 'saturate(' + value + '%)';
2234
+ splitWords[6] = 'sepia(25%)';
2235
+ values = this.adjustmentValue.split(' ');
2236
+ splitWords[0] = values[0];
2237
+ splitWords[1] = values[1];
2238
+ splitWords[2] = values[2];
2239
+ splitWords[4] = values[4];
2240
+ splitWords[5] = values[5];
2241
+ splitWords[7] = 'grayscale(0%)';
2242
+ splitWords[8] = 'invert(0%)';
2243
+ break;
2244
+ case 'grayscale':
2245
+ splitWords[7] = 'grayscale(100%)';
2246
+ values = this.adjustmentValue.split(' ');
2247
+ splitWords[0] = values[0];
2248
+ splitWords[1] = values[1];
2249
+ splitWords[2] = values[2];
2250
+ splitWords[3] = values[3];
2251
+ splitWords[4] = values[4];
2252
+ splitWords[5] = values[5];
2253
+ splitWords[6] = 'sepia(0%)';
2254
+ splitWords[8] = 'invert(0%)';
2255
+ break;
2256
+ case 'blackandwhite':
2257
+ values = this.adjustmentValue.split(' ');
2258
+ if (isPreview) {
2259
+ tempFilter = this.lowerContext.filter;
2260
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
2261
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
2262
+ this.setBlackAndWhiteFilter(true);
2263
+ for (var i = 0; i < this.objColl.length; i++) {
2264
+ this.apply(this.objColl[i].shape, this.objColl[i]);
2265
+ this.refreshActiveObj();
2266
+ }
2267
+ splitWords[0] = values[0];
2268
+ splitWords[1] = values[1];
2269
+ splitWords[2] = values[2];
2270
+ splitWords[3] = values[3];
2271
+ splitWords[4] = values[4];
2272
+ splitWords[5] = values[5];
2273
+ splitWords[6] = 'sepia(0%)';
2274
+ splitWords[7] = 'grayscale(0%)';
2275
+ splitWords[8] = 'invert(0%)';
2276
+ }
2277
+ else {
2278
+ tempFilter = this.lowerContext.filter;
2279
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
2280
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
2281
+ this.setBlackAndWhiteFilter(true);
2282
+ splitWords[0] = values[0];
2283
+ splitWords[1] = values[1];
2284
+ splitWords[2] = values[2];
2285
+ splitWords[3] = values[3];
2286
+ splitWords[4] = values[4];
2287
+ splitWords[5] = values[5];
2288
+ splitWords[6] = 'sepia(0%)';
2289
+ splitWords[7] = 'grayscale(0%)';
2290
+ splitWords[8] = 'invert(0%)';
2291
+ this.lowerContext.filter = this.initialAdjustmentValue = splitWords.join(' ');
2292
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
2293
+ this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
2294
+ tempFilter = this.lowerContext.filter;
2295
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
2296
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
2297
+ for (var i = 0; i < this.objColl.length; i++) {
2298
+ this.apply(this.objColl[i].shape, this.objColl[i]);
2299
+ this.refreshActiveObj();
2300
+ }
2301
+ this.lowerContext.filter = tempFilter;
2302
+ }
2303
+ break;
2304
+ case 'sepia':
2305
+ splitWords[6] = 'sepia(100%)';
2306
+ values = this.adjustmentValue.split(' ');
2307
+ splitWords[0] = values[0];
2308
+ splitWords[1] = values[1];
2309
+ splitWords[2] = values[2];
2310
+ splitWords[3] = values[3];
2311
+ splitWords[4] = values[4];
2312
+ splitWords[5] = values[5];
2313
+ splitWords[7] = 'grayscale(0%)';
2314
+ splitWords[8] = 'invert(0%)';
2315
+ break;
2316
+ case 'invert':
2317
+ splitWords[8] = 'invert(100%)';
2318
+ values = this.adjustmentValue.split(' ');
2319
+ splitWords[0] = values[0];
2320
+ splitWords[1] = values[1];
2321
+ splitWords[2] = values[2];
2322
+ splitWords[3] = values[3];
2323
+ splitWords[4] = values[4];
2324
+ splitWords[5] = values[5];
2325
+ splitWords[6] = 'sepia(0%)';
2326
+ splitWords[7] = 'grayscale(0%)';
2327
+ break;
2328
+ case 'sharpen':
2329
+ values = this.adjustmentValue.split(' ');
2330
+ if (isPreview) {
2331
+ temp = this.lowerContext.filter;
2332
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
2333
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
2334
+ for (var i = 0; i < this.objColl.length; i++) {
2335
+ this.apply(this.objColl[i].shape, this.objColl[i]);
2336
+ this.refreshActiveObj();
2337
+ }
2338
+ splitWords[0] = values[0];
2339
+ splitWords[1] = values[1];
2340
+ splitWords[2] = values[2];
2341
+ splitWords[3] = values[3];
2342
+ splitWords[4] = values[4];
2343
+ splitWords[5] = values[5];
2344
+ splitWords[6] = 'sepia(0%)';
2345
+ splitWords[7] = 'grayscale(0%)';
2346
+ splitWords[8] = 'invert(0%)';
2347
+ }
2348
+ else {
2349
+ temp = this.lowerContext.filter;
2350
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
2351
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
2352
+ this.setSharpness(true);
2353
+ splitWords[0] = values[0];
2354
+ splitWords[1] = values[1];
2355
+ splitWords[2] = values[2];
2356
+ splitWords[3] = values[3];
2357
+ splitWords[4] = values[4];
2358
+ splitWords[5] = values[5];
2359
+ splitWords[6] = 'sepia(0%)';
2360
+ splitWords[7] = 'grayscale(0%)';
2361
+ splitWords[8] = 'invert(0%)';
2362
+ this.lowerContext.filter = this.initialAdjustmentValue = splitWords.join(' ');
2363
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
2364
+ this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
2365
+ temp = this.lowerContext.filter;
2366
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
2367
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
2368
+ for (var i = 0; i < this.objColl.length; i++) {
2369
+ this.apply(this.objColl[i].shape, this.objColl[i]);
2370
+ this.refreshActiveObj();
2371
+ }
2372
+ this.lowerContext.filter = temp;
2373
+ }
2374
+ break;
2375
+ }
2376
+ if (type !== 'sharpen' && type !== 'blackandwhite') {
2377
+ if (isNullOrUndefined(isPreview)) {
2378
+ if (type === 'default') {
2379
+ splitWords = this.getDefaultFilter(splitWords);
2380
+ }
2381
+ this.lowerContext.filter = splitWords.join(' ');
2382
+ }
2383
+ splitWords = this.setTempFilterValue(brightness, isPreview, splitWords, type);
2384
+ this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
2385
+ if (brightness !== 1) {
2386
+ splitWords[4] = 'opacity(' + opacityValue + ')';
2387
+ }
2388
+ else if (saturation !== 1) {
2389
+ splitWords[0] = 'brightness(' + brightnessValue + ')';
2390
+ }
2391
+ if (type === 'exposure' && brightness !== 1) {
2392
+ splitWords[0] = 'brightness(' + brightnessValue + ')';
2393
+ }
2394
+ splitWords = this.setTempFilterValue(brightness, isPreview, splitWords, type);
2395
+ if (isNullOrUndefined(isPreview)) {
2396
+ this.lowerContext.filter = this.initialAdjustmentValue = splitWords.join(' ');
2397
+ }
2398
+ var tempFilter_1 = this.lowerContext.filter;
2399
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
2400
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
2401
+ for (var i = 0; i < this.objColl.length; i++) {
2402
+ this.apply(this.objColl[i].shape, this.objColl[i]);
2403
+ this.refreshActiveObj();
2404
+ }
2405
+ this.lowerContext.filter = tempFilter_1;
2406
+ if (brightness === 1) {
2407
+ this.isBrightnessAdjusted = false;
2408
+ }
2409
+ else {
2410
+ this.isBrightnessAdjusted = true;
2411
+ }
2412
+ }
2413
+ var filter = splitWords.join(' ');
2414
+ return filter;
2415
+ };
2416
+ ImageEditor.prototype.updateBrightnessFilter = function () {
2417
+ var splitWords = this.lowerContext.filter.split(' ');
2418
+ if (this.isBrightnessAdjusted && splitWords.length > 0 && !isNullOrUndefined(splitWords[4])) {
2419
+ var opacityValue = parseFloat(splitWords[4].split('(')[1]);
2420
+ splitWords[4] = 'opacity(' + (opacityValue - 0.3) + ')';
2421
+ this.lowerContext.filter = splitWords.join(' ');
2422
+ }
2423
+ };
2424
+ ImageEditor.prototype.autoEnablePan = function () {
2425
+ if (this.factor > 0.95 && this.factor < 1.05) {
2426
+ this.dragCanvas = this.togglePan = false;
2427
+ this.callMainToolbar(false, true);
2428
+ this.pan(false);
2429
+ this.disablePan = false;
2430
+ }
2431
+ else if (!this.disablePan) {
2432
+ this.pan(true);
2433
+ }
2434
+ else if (this.disablePan) {
2435
+ this.pan(false);
2436
+ }
2437
+ };
2438
+ ImageEditor.prototype.setTempFilterValue = function (brightness, isPreview, splitWords, type) {
2439
+ if (isPreview && brightness !== 1) {
2440
+ var tempSplitWords = this.lowerContext.filter.split(' ');
2441
+ tempSplitWords[4] = splitWords[4];
2442
+ this.lowerContext.filter = tempSplitWords.join(' ');
2443
+ }
2444
+ else if (isPreview && type === 'default') {
2445
+ splitWords = this.getDefaultFilter(splitWords);
2446
+ }
2447
+ return splitWords;
2448
+ };
2449
+ ImageEditor.prototype.getDefaultFilter = function (splitWords) {
2450
+ var values = this.adjustmentValue.split(' ');
2451
+ splitWords[0] = values[0];
2452
+ splitWords[1] = values[1];
2453
+ splitWords[2] = values[2];
2454
+ splitWords[3] = values[3];
2455
+ splitWords[4] = values[4];
2456
+ splitWords[5] = values[5];
2457
+ splitWords[6] = 'sepia(0%)';
2458
+ splitWords[7] = 'grayscale(0%)';
2459
+ splitWords[8] = 'invert(0%)';
2460
+ return splitWords;
2461
+ };
2462
+ ImageEditor.prototype.setAdjustment = function (type) {
2463
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
2464
+ var splitWords = this.lowerContext.filter.split(' ');
2465
+ var value;
2466
+ var valueArr;
2467
+ switch (type) {
2468
+ case 'brightness':
2469
+ valueArr = splitWords[0].split('(');
2470
+ value = parseFloat(valueArr[1].split(')')[0]);
2471
+ this.adjustmentLevel.brightness = this.setFilterValue(value);
2472
+ break;
2473
+ case 'contrast':
2474
+ valueArr = splitWords[1].split('(');
2475
+ value = parseFloat(valueArr[1].split(')')[0]);
2476
+ value /= 100;
2477
+ this.adjustmentLevel.contrast = this.setFilterValue(value);
2478
+ break;
2479
+ case 'hue':
2480
+ valueArr = splitWords[2].split('(');
2481
+ value = parseFloat(valueArr[1].split(')')[0]);
2482
+ value /= 3;
2483
+ this.adjustmentLevel.hue = value;
2484
+ break;
2485
+ case 'saturation':
2486
+ valueArr = splitWords[3].split('(');
2487
+ value = parseFloat(valueArr[1].split(')')[0]);
2488
+ value /= 100;
2489
+ this.adjustmentLevel.saturation = this.setSaturationFilterValue(value);
2490
+ break;
2491
+ case 'opacity':
2492
+ valueArr = splitWords[4].split('(');
2493
+ value = parseFloat(valueArr[1].split(')')[0]);
2494
+ if (value === 0.45) {
2495
+ value = 40;
2496
+ }
2497
+ else if (value === 0.40) {
2498
+ value = 30;
2499
+ }
2500
+ else if (value === 0.35) {
2501
+ value = 20;
2502
+ }
2503
+ else if (value === 0.30) {
2504
+ value = 10;
2505
+ }
2506
+ else if (value === 0.25) {
2507
+ value = 0;
2508
+ }
2509
+ else {
2510
+ value *= 100;
2511
+ }
2512
+ this.adjustmentLevel.opacity = value;
2513
+ break;
2514
+ case 'blur':
2515
+ valueArr = splitWords[5].split('(');
2516
+ value = parseFloat(valueArr[1].split(')')[0]);
2517
+ value *= 20;
2518
+ this.adjustmentLevel.blur = value;
2519
+ break;
2520
+ case 'exposure':
2521
+ valueArr = splitWords[0].split('(');
2522
+ value = parseFloat(valueArr[1].split(')')[0]);
2523
+ this.adjustmentLevel.exposure = this.setFilterValue(value);
2524
+ break;
2525
+ }
2526
+ var temp = this.lowerContext.filter;
2527
+ this.updateBrightnessFilter();
2528
+ this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
2529
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
2530
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
2531
+ for (var j = 0; j < this.objColl.length; j++) {
2532
+ this.apply(this.objColl[j].shape, this.objColl[j]);
2533
+ this.refreshActiveObj();
2534
+ }
2535
+ this.lowerContext.filter = temp;
2536
+ };
2537
+ ImageEditor.prototype.renderSlider = function (type) {
2538
+ var _this = this;
2539
+ var canvasWrapper = document.querySelector('#' + this.element.id + '_contextualToolbarArea');
2540
+ var hdrWrapper = document.querySelector('#' + this.element.id + '_headWrapper');
2541
+ var labelWrapper = document.querySelector('#' + this.element.id + '_labelWrapper');
2542
+ if (!hdrWrapper && !isNullOrUndefined(canvasWrapper)) {
2543
+ hdrWrapper = canvasWrapper.appendChild(this.createElement('div', {
2544
+ id: this.element.id + '_headWrapper',
2545
+ styles: 'position: relative'
2546
+ }));
2547
+ labelWrapper = hdrWrapper.appendChild(this.createElement('label', {
2548
+ id: this.element.id + '_labelWrapper',
2549
+ styles: Browser.isDevice ? 'position: absolute; top: 25%; left: calc(50% - 150px); font-size: 15px; text-transform: capitalize; font-weight: 400;'
2550
+ : 'position: absolute; top: 25%; left: calc(50% - 226px); font-size: 15px; text-transform: capitalize; font-weight: 400;'
2551
+ }));
2552
+ }
2553
+ else {
2554
+ hdrWrapper.style.display = 'block';
2555
+ }
2556
+ labelWrapper.textContent = this.l10n.getConstant(this.toPascalCase(type));
2557
+ var sliderWrapper = hdrWrapper.appendChild(this.createElement('div', {
2558
+ id: this.element.id + '_sliderWrapper',
2559
+ styles: 'position: absolute'
2560
+ }));
2561
+ var value = this.getCurrAdjustmentValue(type);
2562
+ var min;
2563
+ var max;
2564
+ var slider;
2565
+ if (type === 'brightness' || type === 'contrast' || type === 'saturation' || type === 'exposure') {
2566
+ if (this.finetuneSettings) {
2567
+ if (type === 'brightness' && this.finetuneSettings.brightness) {
2568
+ min = this.finetuneSettings.brightness.min;
2569
+ max = this.finetuneSettings.brightness.max;
2570
+ }
2571
+ else if (type === 'contrast' && this.finetuneSettings.contrast) {
2572
+ min = this.finetuneSettings.contrast.min;
2573
+ max = this.finetuneSettings.contrast.max;
2574
+ }
2575
+ else if (type === 'saturation' && this.finetuneSettings.saturation) {
2576
+ min = this.finetuneSettings.saturation.min;
2577
+ max = this.finetuneSettings.saturation.max;
2578
+ }
2579
+ else if (type === 'exposure' && this.finetuneSettings.exposure) {
2580
+ min = this.finetuneSettings.exposure.min;
2581
+ max = this.finetuneSettings.exposure.max;
2582
+ }
2583
+ else {
2584
+ min = -100;
2585
+ max = 100;
2586
+ }
2587
+ }
2588
+ else {
2589
+ min = -100;
2590
+ max = 100;
2591
+ }
2592
+ slider = new Slider({
2593
+ value: value,
2594
+ tooltip: { isVisible: true, placement: 'Before', showOn: 'Always' },
2595
+ type: 'MinRange',
2596
+ min: min,
2597
+ max: max,
2598
+ step: 10,
2599
+ width: Browser.isDevice ? '200px' : '300px',
2600
+ cssClass: 'e-slider',
2601
+ change: function (args) {
2602
+ _this.setCurrAdjustmentValue(type, args.value);
2603
+ }
2604
+ });
2605
+ }
2606
+ else if (type === 'hue' || type === 'blur' || type === 'opacity') {
2607
+ if (this.finetuneSettings) {
2608
+ if (type === 'hue' && this.finetuneSettings.hue) {
2609
+ min = this.finetuneSettings.hue.min;
2610
+ max = this.finetuneSettings.hue.max;
2611
+ }
2612
+ else if (type === 'blur' && this.finetuneSettings.blur) {
2613
+ min = this.finetuneSettings.blur.min;
2614
+ max = this.finetuneSettings.blur.max;
2615
+ }
2616
+ else if (type === 'opacity' && this.finetuneSettings.opacity) {
2617
+ min = this.finetuneSettings.opacity.min;
2618
+ max = this.finetuneSettings.opacity.max;
2619
+ }
2620
+ else {
2621
+ min = 0;
2622
+ max = 100;
2623
+ }
2624
+ }
2625
+ else {
2626
+ min = 0;
2627
+ max = 100;
2628
+ }
2629
+ slider = new Slider({
2630
+ value: value,
2631
+ tooltip: { isVisible: true, placement: 'Before', showOn: 'Always' },
2632
+ type: 'MinRange',
2633
+ min: min,
2634
+ max: max,
2635
+ step: 10,
2636
+ width: Browser.isDevice ? '200px' : '300px',
2637
+ cssClass: 'e-slider',
2638
+ change: function (args) {
2639
+ _this.setCurrAdjustmentValue(type, args.value);
2640
+ }
2641
+ });
2642
+ }
2643
+ slider.appendTo('#' + this.element.id + '_sliderWrapper');
2644
+ sliderWrapper.style.left = (parseFloat(canvasWrapper.style.width) - parseFloat(slider.width)) / 2 + 'px';
2645
+ };
2646
+ ImageEditor.prototype.getCurrAdjustmentValue = function (type) {
2647
+ var value;
2648
+ switch (type) {
2649
+ case 'brightness':
2650
+ value = this.adjustmentLevel.brightness;
2651
+ break;
2652
+ case 'contrast':
2653
+ value = this.adjustmentLevel.contrast;
2654
+ break;
2655
+ case 'hue':
2656
+ value = this.adjustmentLevel.hue;
2657
+ break;
2658
+ case 'saturation':
2659
+ value = this.adjustmentLevel.saturation;
2660
+ break;
2661
+ case 'opacity':
2662
+ value = this.adjustmentLevel.opacity;
2663
+ break;
2664
+ case 'blur':
2665
+ value = this.adjustmentLevel.blur;
2666
+ break;
2667
+ case 'exposure':
2668
+ value = this.adjustmentLevel.exposure;
2669
+ break;
2670
+ }
2671
+ return value;
2672
+ };
2673
+ ImageEditor.prototype.setCurrAdjustmentValue = function (type, value) {
2674
+ var fineTuneValueChanging = { finetune: this.toPascalCase(type), value: value };
2675
+ this.trigger('fineTuneValueChanging', fineTuneValueChanging);
2676
+ switch (type) {
2677
+ case 'brightness':
2678
+ this.setBrightness(value);
2679
+ break;
2680
+ case 'contrast':
2681
+ this.setContrast(value);
2682
+ break;
2683
+ case 'hue':
2684
+ this.setHue(value);
2685
+ break;
2686
+ case 'saturation':
2687
+ this.setSaturation(value);
2688
+ break;
2689
+ case 'opacity':
2690
+ this.setOpacity(value);
2691
+ break;
2692
+ case 'blur':
2693
+ this.setBlur(value);
2694
+ break;
2695
+ case 'exposure':
2696
+ this.setExposure(value);
2697
+ break;
2698
+ }
2699
+ };
2700
+ ImageEditor.prototype.cancelPan = function () {
2701
+ this.applyActObj();
2702
+ var panBtn = this.element.querySelector('.e-img-pan .e-btn');
2703
+ panBtn.classList.remove('e-selected-btn');
2704
+ this.pan(false);
2705
+ };
2706
+ ImageEditor.prototype.callMainToolbar = function (isApplyBtn, isZooming) {
2707
+ this.refreshToolbar('main', isApplyBtn, false, isZooming);
2708
+ };
2709
+ ImageEditor.prototype.cancelItems = function () {
2710
+ var ratio = this.calcRatio();
2711
+ var isCropSelection = false;
2712
+ var splitWords;
2713
+ if (this.activeObj.shape !== undefined) {
2714
+ splitWords = this.activeObj.shape.split('-');
2715
+ }
2716
+ if (splitWords === undefined && this.currObjType.isCustomCrop) {
2717
+ isCropSelection = true;
2718
+ }
2719
+ else if (splitWords !== undefined && splitWords[0] === 'crop') {
2720
+ isCropSelection = true;
2721
+ }
2722
+ if (this.togglePen) {
2723
+ this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
2724
+ this.togglePen = false;
2725
+ this.upperCanvas.style.cursor = 'default';
2726
+ this.penDrawColl = [];
2727
+ this.imageEditorPointsColl = [];
2728
+ }
2729
+ else if (this.activeObj.shape === 'text') {
2730
+ this.activeObj.strokeSettings = this.tempStrokeSettings;
2731
+ this.activeObj.textSettings = this.tempTextSettings;
2732
+ if (this.activeObj.keyHistory === 'Enter Text' && this.activeObj.activePoint.startX === this.textStartPoints.x
2733
+ && this.activeObj.activePoint.startY === this.textStartPoints.y) {
2734
+ this.refreshActiveObj();
2735
+ this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
2736
+ this.drawShapeText();
2737
+ }
2738
+ else {
2739
+ this.redrawText(ratio);
2740
+ this.redrawShape(this.activeObj);
2741
+ if (!isCropSelection && this.activeObj.topLeftCircle !== undefined) {
2742
+ this.applyActObj();
2743
+ }
2744
+ this.clearSelection();
2745
+ }
2746
+ this.tempTextSettings = { text: 'Enter Text', fontFamily: 'Arial', fontSize: null, bold: false, italic: false, underline: false };
2747
+ }
2748
+ else if (this.activeObj.shape === 'rectangle' || this.activeObj.shape === 'ellipse' || this.activeObj.shape === 'line') {
2749
+ this.activeObj.strokeSettings = this.tempStrokeSettings;
2750
+ this.redrawShape(this.activeObj);
2751
+ this.applyActObj();
2752
+ }
2753
+ else {
2754
+ this.refreshActiveObj();
2755
+ this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
2756
+ }
2757
+ this.upperCanvas.style.cursor = 'default';
2758
+ this.currObjType.isCustomCrop = false;
2759
+ this.tempStrokeSettings = { strokeColor: '#fff', fillColor: '', strokeWidth: null };
2760
+ this.callMainToolbar();
2761
+ };
2762
+ ImageEditor.prototype.gradient = function (a, b) {
2763
+ return (b.y - a.y) / (b.x - a.x);
2764
+ };
2765
+ ImageEditor.prototype.applyPenDraw = function () {
2766
+ if (this.togglePen && this.factor === 1 && !this.currObjType.isZoomed) {
2767
+ this.apply();
2768
+ this.penDrawColl = [];
2769
+ this.imageEditorPointsColl = [];
2770
+ }
2771
+ else {
2772
+ var tempCanvas = this.lowerCanvas.appendChild(this.createElement('canvas', {
2773
+ id: this.element.id + '_tempCanvas', attrs: { name: 'canvasImage' }
2774
+ }));
2775
+ var tempContext = tempCanvas.getContext('2d');
2776
+ tempCanvas.width = this.lowerCanvas.width;
2777
+ tempCanvas.height = this.lowerCanvas.height;
2778
+ var temp = this.lowerContext.filter;
2779
+ this.updateBrightnessFilter();
2780
+ tempContext.drawImage(this.inMemoryCanvas, 0, 0);
2781
+ this.lowerContext.filter = temp;
2782
+ this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
2783
+ for (var i = 0; i < this.penDrawColl.length; i++) {
2784
+ tempContext.lineWidth = 2 * this.penDrawColl[i].strokeWidth;
2785
+ tempContext.strokeStyle = this.penDrawColl[i].strokeColor;
2786
+ var nexP = void 0;
2787
+ var preP = void 0;
2788
+ var f = 0.3;
2789
+ var t = 1;
2790
+ tempContext.beginPath();
2791
+ tempContext.moveTo(this.penDrawColl[i].points[0].x, this.penDrawColl[i].points[0].y);
2792
+ var m = 0;
2793
+ var dx1 = 0;
2794
+ var dx2 = 0;
2795
+ var dy1 = 0;
2796
+ var dy2 = 0;
2797
+ preP = this.penDrawColl[i].points[0];
2798
+ for (var j = 1; j < this.penDrawColl[i].points.length; j++) {
2799
+ var curP = this.penDrawColl[i].points[j];
2800
+ nexP = this.penDrawColl[i].points[j + 1];
2801
+ if (nexP) {
2802
+ m = this.gradient(preP, nexP);
2803
+ dx2 = (nexP.x - curP.x) * -f;
2804
+ dy2 = dx2 * m * t;
2805
+ }
2806
+ else {
2807
+ dx2 = 0;
2808
+ dy2 = 0;
2809
+ }
2810
+ tempContext.bezierCurveTo(preP.x - dx1, preP.y - dy1, curP.x + dx2, curP.y + dy2, curP.x, curP.y);
2811
+ dx1 = dx2;
2812
+ dy1 = dy2;
2813
+ preP = curP;
2814
+ if (this.penDrawColl[i].points.length > 2) {
1866
2815
  this.penDrawColl[i].points.shift();
1867
2816
  }
1868
2817
  tempContext.stroke();
@@ -1887,24 +2836,37 @@ var ImageEditor = /** @class */ (function (_super) {
1887
2836
  this.inMemoryCanvas.height = imgData.height;
1888
2837
  this.inMemoryContext.putImageData(imgData, 0, 0);
1889
2838
  this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
1890
- this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
1891
- for (var j = 0; j < this.objColl.length; j++) {
1892
- this.apply(this.objColl[j].shape, this.objColl[j]);
1893
- this.refreshActiveObj();
1894
- }
2839
+ this.redrawImgWithObj();
1895
2840
  this.currObjType.isZoomed = false;
1896
2841
  }
1897
2842
  };
1898
- ImageEditor.prototype.refreshToolbar = function (type, isApplyBtn, isCropping, isZooming) {
2843
+ ImageEditor.prototype.redrawImgWithObj = function () {
2844
+ this.lowerContext.filter = this.canvasFilter;
2845
+ var temp = this.lowerContext.filter;
2846
+ this.updateBrightnessFilter();
2847
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
2848
+ this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
2849
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
2850
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
2851
+ for (var j = 0; j < this.objColl.length; j++) {
2852
+ this.apply(this.objColl[j].shape, this.objColl[j]);
2853
+ this.refreshActiveObj();
2854
+ }
2855
+ this.lowerContext.filter = temp;
2856
+ };
2857
+ ImageEditor.prototype.refreshToolbar = function (type, isApplyBtn, isCropping, isZooming, cType) {
1899
2858
  var args = { toolbarType: type };
1900
- if (document.getElementById(this.element.id + '_toolbar') && this.defToolbarItems.length > 0) {
1901
- getComponent(document.getElementById(this.element.id + '_toolbar'), 'toolbar').destroy();
1902
- }
1903
- if (document.getElementById(this.element.id + '_bottomToolbar') && this.defToolbarItems.length > 0) {
1904
- if (document.getElementById(this.element.id + '_bottomToolbar').className.indexOf('e-control') > -1) {
1905
- getComponent(document.getElementById(this.element.id + '_bottomToolbar'), 'toolbar').destroy();
2859
+ if (type !== 'filter' && type !== 'color') {
2860
+ if (document.getElementById(this.element.id + '_toolbar') && this.defToolbarItems.length > 0) {
2861
+ getComponent(document.getElementById(this.element.id + '_toolbar'), 'toolbar').destroy();
2862
+ }
2863
+ if (document.getElementById(this.element.id + '_bottomToolbar') && this.defToolbarItems.length > 0) {
2864
+ if (document.getElementById(this.element.id + '_bottomToolbar').className.indexOf('e-control') > -1) {
2865
+ getComponent(document.getElementById(this.element.id + '_bottomToolbar'), 'toolbar').destroy();
2866
+ }
1906
2867
  }
1907
2868
  }
2869
+ this.refreshSlider();
1908
2870
  switch (type) {
1909
2871
  case 'main':
1910
2872
  if (Browser.isDevice) {
@@ -1954,7 +2916,104 @@ var ImageEditor = /** @class */ (function (_super) {
1954
2916
  case 'pan':
1955
2917
  this.initZoomToolbarItem();
1956
2918
  break;
2919
+ case 'adjustment':
2920
+ if (Browser.isDevice) {
2921
+ this.initToolbarItem(false, true, true);
2922
+ }
2923
+ this.initAdjustmentToolbarItem();
2924
+ break;
2925
+ case 'filter':
2926
+ this.updateContextualToolbar(type);
2927
+ break;
2928
+ case 'color':
2929
+ this.updateContextualToolbar(type, cType);
2930
+ break;
2931
+ }
2932
+ };
2933
+ ImageEditor.prototype.getAdjustmentToolbarItem = function () {
2934
+ var toolbarItems = [];
2935
+ if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Brightness') > -1)) {
2936
+ toolbarItems.push({ id: this.element.id + '_brightness', prefixIcon: 'e-icons e-brightness', cssClass: 'top-icon e-brightness',
2937
+ tooltipText: this.l10n.getConstant('Brightness'), align: 'Center' });
2938
+ }
2939
+ if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Contrast') > -1)) {
2940
+ toolbarItems.push({ id: this.element.id + '_contrast', prefixIcon: 'e-icons e-contrast', cssClass: 'top-icon e-contrast',
2941
+ tooltipText: this.l10n.getConstant('Contrast'), align: 'Center' });
2942
+ }
2943
+ if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Hue') > -1)) {
2944
+ toolbarItems.push({ id: this.element.id + '_hue', prefixIcon: 'e-icons e-fade', cssClass: 'top-icon e-fade',
2945
+ tooltipText: this.l10n.getConstant('Hue'), align: 'Center' });
2946
+ }
2947
+ if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Saturation') > -1)) {
2948
+ toolbarItems.push({ id: this.element.id + '_saturation', prefixIcon: 'e-icons e-saturation', cssClass: 'top-icon e-saturation',
2949
+ tooltipText: this.l10n.getConstant('Saturation'), align: 'Center' });
2950
+ }
2951
+ if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Exposure') > -1)) {
2952
+ toolbarItems.push({ id: this.element.id + '_exposure', prefixIcon: 'e-icons e-grain', cssClass: 'top-icon e-grain',
2953
+ tooltipText: this.l10n.getConstant('Exposure'), align: 'Center' });
2954
+ }
2955
+ if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Opacity') > -1)) {
2956
+ toolbarItems.push({ id: this.element.id + '_opacity', prefixIcon: 'e-icons e-opacity', cssClass: 'top-icon e-opacity',
2957
+ tooltipText: this.l10n.getConstant('Opacity'), align: 'Center' });
2958
+ }
2959
+ if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Blur') > -1)) {
2960
+ toolbarItems.push({ id: this.element.id + '_blur', prefixIcon: 'e-icons e-tint', cssClass: 'top-icon e-tint',
2961
+ tooltipText: this.l10n.getConstant('Blur'), align: 'Center' });
2962
+ }
2963
+ var tempToolbarItems = this.processToolbar('center');
2964
+ for (var i = 0, len = tempToolbarItems.length; i < len; i++) {
2965
+ toolbarItems.push(tempToolbarItems[i]);
2966
+ }
2967
+ if (!Browser.isDevice) {
2968
+ toolbarItems.push({ id: this.element.id + '_ok', prefixIcon: 'e-icons e-check', cssClass: 'top-icon e-tick',
2969
+ tooltipText: this.l10n.getConstant('OK'), align: 'Right' });
2970
+ toolbarItems.push({ id: this.element.id + '_cancel', prefixIcon: 'e-icons e-close', cssClass: 'top-icon e-save',
2971
+ tooltipText: this.l10n.getConstant('Cancel'), align: 'Right' });
2972
+ }
2973
+ return toolbarItems;
2974
+ };
2975
+ ImageEditor.prototype.getFilterToolbarItem = function () {
2976
+ var toolbarItems = [];
2977
+ if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Default') > -1)) {
2978
+ toolbarItems.push({ id: this.element.id + '_default', prefixIcon: 'e-icons e-none', cssClass: 'top-icon e-none',
2979
+ tooltipText: this.l10n.getConstant('Default'), align: 'Center',
2980
+ template: '<div class="filterwrapper" style="box-sizing: content-box;"><canvas id=' + this.element.id + '_defaultCanvas' + '></canvas><div style="text-align:center;"><span>' + this.l10n.getConstant('Default') + '</span></div></div>' });
2981
+ }
2982
+ if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Chrome') > -1)) {
2983
+ toolbarItems.push({ id: this.element.id + '_chrome', prefixIcon: 'e-icons e-none', cssClass: 'top-icon e-none',
2984
+ tooltipText: this.l10n.getConstant('Chrome'), align: 'Center',
2985
+ template: '<div class="filterwrapper" style="box-sizing: content-box;"><canvas id=' + this.element.id + '_chromeCanvas' + '></canvas><div style="text-align:center;"><span>' + this.l10n.getConstant('Chrome') + '</span></div></div>' });
2986
+ }
2987
+ if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Cold') > -1)) {
2988
+ toolbarItems.push({ id: this.element.id + '_cold', prefixIcon: 'e-icons e-none', cssClass: 'top-icon e-none',
2989
+ tooltipText: this.l10n.getConstant('Cold'), align: 'Center',
2990
+ template: '<div class="filterwrapper" style="box-sizing: content-box;"><canvas id=' + this.element.id + '_coldCanvas' + '></canvas><div style="text-align:center;"><span>' + this.l10n.getConstant('Cold') + '</span></div></div>' });
2991
+ }
2992
+ if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Warm') > -1)) {
2993
+ toolbarItems.push({ id: this.element.id + '_warm', prefixIcon: 'e-icons e-none', cssClass: 'top-icon e-none',
2994
+ tooltipText: this.l10n.getConstant('Warm'), align: 'Center',
2995
+ template: '<div class="filterwrapper" style="box-sizing: content-box;"><canvas id=' + this.element.id + '_warmCanvas' + '></canvas><div style="text-align:center;"><span>' + this.l10n.getConstant('Warm') + '</span></div></div>' });
2996
+ }
2997
+ if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Grayscale') > -1)) {
2998
+ toolbarItems.push({ id: this.element.id + '_grayscale', prefixIcon: 'e-icons e-none', cssClass: 'top-icon e-none',
2999
+ tooltipText: this.l10n.getConstant('Grayscale'), align: 'Center',
3000
+ template: '<div class="filterwrapper" style="box-sizing: content-box;"><canvas id=' + this.element.id + '_grayscaleCanvas' + '></canvas><div style="text-align:center;"><span>' + this.l10n.getConstant('Grayscale') + '</span></div></div>' });
3001
+ }
3002
+ if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Sepia') > -1)) {
3003
+ toolbarItems.push({ id: this.element.id + '_sepia', prefixIcon: 'e-icons e-none', cssClass: 'top-icon e-none',
3004
+ tooltipText: this.l10n.getConstant('Sepia'), align: 'Center',
3005
+ template: '<div class="filterwrapper" style="box-sizing: content-box;"><canvas id=' + this.element.id + '_sepiaCanvas' + '></canvas><div style="text-align:center;"><span>' + this.l10n.getConstant('Sepia') + '</span></div></div>' });
3006
+ }
3007
+ if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Invert') > -1)) {
3008
+ toolbarItems.push({ id: this.element.id + '_invert', prefixIcon: 'e-icons e-none', cssClass: 'top-icon e-none',
3009
+ tooltipText: this.l10n.getConstant('Invert'), align: 'Center',
3010
+ template: '<div class="filterwrapper" style="box-sizing: content-box;"><canvas id=' + this.element.id + '_invertCanvas' + '></canvas><div style="text-align:center;"><span>' + this.l10n.getConstant('Invert') + '</span></div></div>' });
3011
+ }
3012
+ var tempToolbarItems = this.processToolbar('center');
3013
+ for (var i = 0, len = tempToolbarItems.length; i < len; i++) {
3014
+ toolbarItems.push(tempToolbarItems[i]);
1957
3015
  }
3016
+ return toolbarItems;
1958
3017
  };
1959
3018
  ImageEditor.prototype.getPenToolbarItem = function (items) {
1960
3019
  var toolbarItems = [];
@@ -2075,7 +3134,12 @@ var ImageEditor = /** @class */ (function (_super) {
2075
3134
  if (items.indexOf('strokeWidth') > -1) {
2076
3135
  var strokeWidthBtn = document.getElementById(this.element.id + '_penStrokeWidth');
2077
3136
  var spanElem_3 = document.createElement('span');
2078
- spanElem_3.innerHTML = this.l10n.getConstant('Small');
3137
+ if (isNullOrUndefined(this.penStrokeWidth)) {
3138
+ spanElem_3.innerHTML = this.l10n.getConstant('Small');
3139
+ }
3140
+ else {
3141
+ spanElem_3.innerHTML = this.getPenStroke(this.penStrokeWidth, this.calcRatio());
3142
+ }
2079
3143
  spanElem_3.className = 'e-pen-stroke-width';
2080
3144
  strokeWidthBtn.appendChild(spanElem_3);
2081
3145
  var drpDownBtn_2 = new DropDownButton({ items: strokeWidthItems,
@@ -2093,15 +3157,15 @@ var ImageEditor = /** @class */ (function (_super) {
2093
3157
  if (Browser.isDevice) {
2094
3158
  if (!isNullOrUndefined(document.getElementById(_this.element.id + '_bottomToolbar'))) {
2095
3159
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
2096
- var toolbar_7 = getComponent(_this.element.id + '_bottomToolbar', 'toolbar');
2097
- toolbar_7.refreshOverflow();
3160
+ var toolbar_8 = getComponent(_this.element.id + '_bottomToolbar', 'toolbar');
3161
+ toolbar_8.refreshOverflow();
2098
3162
  }
2099
3163
  }
2100
3164
  else {
2101
3165
  if (!isNullOrUndefined(document.getElementById(_this.element.id + '_toolbar'))) {
2102
3166
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
2103
- var toolbar_8 = getComponent(_this.element.id + '_toolbar', 'toolbar');
2104
- toolbar_8.refreshOverflow();
3167
+ var toolbar_9 = getComponent(_this.element.id + '_toolbar', 'toolbar');
3168
+ toolbar_9.refreshOverflow();
2105
3169
  }
2106
3170
  }
2107
3171
  }
@@ -2129,6 +3193,159 @@ var ImageEditor = /** @class */ (function (_super) {
2129
3193
  break;
2130
3194
  }
2131
3195
  };
3196
+ ImageEditor.prototype.getPenStroke = function (value, ratio) {
3197
+ var textContent = '';
3198
+ if (Math.round(value / 0.4) === Math.round(ratio.width + ratio.height)) {
3199
+ textContent = this.l10n.getConstant('XSmall');
3200
+ }
3201
+ else if (Math.round(value / 0.8) === Math.round(ratio.width + ratio.height)) {
3202
+ textContent = this.l10n.getConstant('Small');
3203
+ }
3204
+ else if (Math.round(value / 1.2) === Math.round(ratio.width + ratio.height)) {
3205
+ textContent = this.l10n.getConstant('Medium');
3206
+ }
3207
+ else if (Math.round(value / 1.6) === Math.round(ratio.width + ratio.height)) {
3208
+ textContent = this.l10n.getConstant('Large');
3209
+ }
3210
+ else if (Math.round(value / 2) === Math.round(ratio.width + ratio.height)) {
3211
+ textContent = this.l10n.getConstant('XLarge');
3212
+ }
3213
+ return textContent;
3214
+ };
3215
+ ImageEditor.prototype.initAdjustmentToolbarItem = function () {
3216
+ var _this = this;
3217
+ var leftItem = this.getLeftToolbarItem();
3218
+ var rightItem = this.getRightToolbarItem();
3219
+ var mainItem = this.getAdjustmentToolbarItem();
3220
+ var zoomItem = this.getZoomToolbarItem();
3221
+ if (Browser.isDevice) {
3222
+ this.defToolbarItems = mainItem;
3223
+ }
3224
+ else {
3225
+ this.defToolbarItems = leftItem.concat(zoomItem, mainItem, rightItem);
3226
+ }
3227
+ var toolbar = new Toolbar({
3228
+ width: '100%',
3229
+ items: this.defToolbarItems,
3230
+ clicked: this.defToolbarClicked.bind(this),
3231
+ created: function () {
3232
+ if (!Browser.isDevice) {
3233
+ _this.renderSaveBtn();
3234
+ }
3235
+ if (Browser.isDevice) {
3236
+ if (_this.defToolbarItems.length > 0 && (!isNullOrUndefined(document.getElementById(_this.element.id + '_toolbar')))) {
3237
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
3238
+ toolbar.refreshOverflow();
3239
+ }
3240
+ }
3241
+ else {
3242
+ _this.createLeftToolbarControls();
3243
+ if (_this.defToolbarItems.length > 0 && (!isNullOrUndefined(document.getElementById(_this.element.id + '_toolbar')))) {
3244
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
3245
+ toolbar.refreshOverflow();
3246
+ }
3247
+ }
3248
+ }
3249
+ });
3250
+ if (Browser.isDevice) {
3251
+ toolbar.appendTo('#' + this.element.id + '_bottomToolbar');
3252
+ }
3253
+ else {
3254
+ toolbar.appendTo('#' + this.element.id + '_toolbar');
3255
+ }
3256
+ };
3257
+ ImageEditor.prototype.initFilterToolbarItem = function () {
3258
+ var _this = this;
3259
+ var mainItem = this.getFilterToolbarItem();
3260
+ if (!isNullOrUndefined(document.querySelector('#' + this.element.id + '_contextualToolbar')) &&
3261
+ document.querySelector('#' + this.element.id + '_contextualToolbar').classList.contains('e-control')) {
3262
+ getComponent(document.getElementById(this.element.id + '_contextualToolbar'), 'toolbar').destroy();
3263
+ }
3264
+ var toolbar = new Toolbar({
3265
+ width: '100%',
3266
+ items: mainItem,
3267
+ clicked: this.contextualToolbarClicked.bind(this),
3268
+ created: function () {
3269
+ _this.createCanvasFilter();
3270
+ if (_this.currentFilter === '') {
3271
+ _this.currentFilter = _this.element.id + '_default';
3272
+ }
3273
+ var hdrWrapper = document.querySelector('#' + _this.element.id + '_headWrapper');
3274
+ if (hdrWrapper) {
3275
+ hdrWrapper.style.display = 'none';
3276
+ }
3277
+ document.getElementById(_this.currentFilter + 'Canvas').parentElement.parentElement.classList.add('e-selected');
3278
+ toolbar.refreshOverflow();
3279
+ }
3280
+ });
3281
+ toolbar.appendTo('#' + this.element.id + '_contextualToolbar');
3282
+ };
3283
+ ImageEditor.prototype.createCanvasFilter = function () {
3284
+ if (this.adjustmentLevel.sharpen || this.adjustmentLevel.bw) {
3285
+ this.inMemoryContext.clearRect(0, 0, this.inMemoryCanvas.width, this.inMemoryCanvas.height);
3286
+ this.inMemoryCanvas.width = this.tempImageData.width;
3287
+ this.inMemoryCanvas.height = this.tempImageData.height;
3288
+ this.inMemoryContext.putImageData(this.tempImageData, 0, 0);
3289
+ }
3290
+ var noFilter = document.querySelector('#' + this.element.id + '_defaultCanvas');
3291
+ noFilter.style.width = '100px';
3292
+ noFilter.style.height = '100px';
3293
+ noFilter.style.filter = this.updateAdjustment('default', null, true);
3294
+ var ctx = noFilter.getContext('2d');
3295
+ ctx.drawImage(this.inMemoryCanvas, 0, 0, 300, 150);
3296
+ var chrome = document.querySelector('#' + this.element.id + '_chromeCanvas');
3297
+ chrome.style.width = '100px';
3298
+ chrome.style.height = '100px';
3299
+ chrome.style.filter = this.updateAdjustment('chrome', null, true);
3300
+ ctx = chrome.getContext('2d');
3301
+ ctx.drawImage(this.inMemoryCanvas, 0, 0, 300, 150);
3302
+ var cold = document.querySelector('#' + this.element.id + '_coldCanvas');
3303
+ cold.style.width = '100px';
3304
+ cold.style.height = '100px';
3305
+ cold.style.filter = this.updateAdjustment('cold', null, true);
3306
+ ctx = cold.getContext('2d');
3307
+ ctx.drawImage(this.inMemoryCanvas, 0, 0, 300, 150);
3308
+ var warm = document.querySelector('#' + this.element.id + '_warmCanvas');
3309
+ warm.style.width = '100px';
3310
+ warm.style.height = '100px';
3311
+ warm.style.filter = this.updateAdjustment('warm', null, true);
3312
+ ctx = warm.getContext('2d');
3313
+ ctx.drawImage(this.inMemoryCanvas, 0, 0, 300, 150);
3314
+ var temp = this.lowerContext.filter;
3315
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
3316
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
3317
+ for (var i = 0; i < this.objColl.length; i++) {
3318
+ this.apply(this.objColl[i].shape, this.objColl[i]);
3319
+ this.refreshActiveObj();
3320
+ }
3321
+ this.lowerContext.filter = temp;
3322
+ var grayscale = document.querySelector('#' + this.element.id + '_grayscaleCanvas');
3323
+ grayscale.style.width = '100px';
3324
+ grayscale.style.height = '100px';
3325
+ grayscale.style.filter = this.updateAdjustment('grayscale', null, true);
3326
+ ctx = grayscale.getContext('2d');
3327
+ ctx.drawImage(this.inMemoryCanvas, 0, 0, 300, 150);
3328
+ var tempFilter = this.lowerContext.filter;
3329
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
3330
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
3331
+ for (var i = 0; i < this.objColl.length; i++) {
3332
+ this.apply(this.objColl[i].shape, this.objColl[i]);
3333
+ this.refreshActiveObj();
3334
+ }
3335
+ this.lowerContext.filter = tempFilter;
3336
+ var sepia = document.querySelector('#' + this.element.id + '_sepiaCanvas');
3337
+ sepia.style.width = '100px';
3338
+ sepia.style.height = '100px';
3339
+ sepia.style.filter = this.updateAdjustment('sepia', null, true);
3340
+ ctx = sepia.getContext('2d');
3341
+ ctx.drawImage(this.inMemoryCanvas, 0, 0, 300, 150);
3342
+ var invert = document.querySelector('#' + this.element.id + '_invertCanvas');
3343
+ invert.style.width = '100px';
3344
+ invert.style.height = '100px';
3345
+ invert.style.filter = this.updateAdjustment('invert', null, true);
3346
+ ctx = invert.getContext('2d');
3347
+ ctx.drawImage(this.inMemoryCanvas, 0, 0, 300, 150);
3348
+ };
2132
3349
  ImageEditor.prototype.updateCanvas = function () {
2133
3350
  this.lastX = this.baseImg.width / 2;
2134
3351
  this.lastY = this.baseImg.height / 2;
@@ -2147,9 +3364,10 @@ var ImageEditor = /** @class */ (function (_super) {
2147
3364
  maxDimension.width -= toolbarHeight;
2148
3365
  maxDimension.height -= toolbarHeight;
2149
3366
  }
3367
+ var tempFilter = this.lowerContext.filter;
2150
3368
  this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
2151
- this.lowerCanvas.width = this.upperCanvas.width = this.inMemoryCanvas.width = this.baseImg.width;
2152
- this.lowerCanvas.height = this.upperCanvas.height = this.inMemoryCanvas.height = this.baseImg.height;
3369
+ this.lowerCanvas.width = this.upperCanvas.width = this.baseImg.width;
3370
+ this.lowerCanvas.height = this.upperCanvas.height = this.baseImg.height;
2153
3371
  this.lowerCanvas.style.maxWidth = this.upperCanvas.style.maxWidth = maxDimension.width + 'px';
2154
3372
  this.lowerCanvas.style.maxHeight = this.upperCanvas.style.maxHeight = maxDimension.height + 'px';
2155
3373
  this.lowerCanvas.style.left = this.upperCanvas.style.left = (wrapperWidth - maxDimension.width) / 2 + 1 + 'px';
@@ -2159,16 +3377,37 @@ var ImageEditor = /** @class */ (function (_super) {
2159
3377
  if (canvasWrapper) {
2160
3378
  this.lowerCanvas.style.top = this.upperCanvas.style.top = (parseFloat(canvasWrapper.style.height) - maxDimension.height - 1) / 2 + 'px';
2161
3379
  }
2162
- this.lowerContext.drawImage(this.baseImg, 0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
2163
- this.updateInMemoryCanvas('updateCanvas');
3380
+ this.lowerContext.filter = tempFilter;
3381
+ if (this.lowerContext.filter === 'none' || this.lowerContext.filter === 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
3382
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)' ||
3383
+ this.isInitialLoading) {
3384
+ this.lowerContext.drawImage(this.baseImg, 0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
3385
+ this.updateInMemoryCanvas('updateCanvas');
3386
+ if (this.canvasFilter !== 'none') {
3387
+ this.lowerContext.filter = this.canvasFilter;
3388
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
3389
+ this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
3390
+ }
3391
+ if (this.isInitialLoading) {
3392
+ this.initializeFilter();
3393
+ this.isInitialLoading = false;
3394
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
3395
+ this.lowerContext.drawImage(this.baseImg, 0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
3396
+ }
3397
+ }
3398
+ else {
3399
+ var temp = this.lowerContext.filter;
3400
+ this.updateBrightnessFilter();
3401
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
3402
+ this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
3403
+ this.lowerContext.filter = temp;
3404
+ }
3405
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
3406
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
2164
3407
  for (var i = 0, len = this.objColl.length; i < len; i++) {
2165
3408
  this.apply(this.objColl[i].shape, this.objColl[i]);
2166
3409
  }
2167
- if (this.isUndoRedo) {
2168
- if (this.flipState !== '') {
2169
- this.flip(this.flipState);
2170
- }
2171
- }
3410
+ this.lowerContext.filter = tempFilter;
2172
3411
  if (this.disabled) {
2173
3412
  this.element.setAttribute('class', 'e-disabled');
2174
3413
  }
@@ -2178,7 +3417,7 @@ var ImageEditor = /** @class */ (function (_super) {
2178
3417
  var _this = this;
2179
3418
  // eslint-disable-next-line @typescript-eslint/no-this-alias
2180
3419
  var proxy = this;
2181
- proxy.baseImg.src = proxy.baseImgSrc = src;
3420
+ proxy.baseImg.src = proxy.baseImgSrc.id = src;
2182
3421
  this.baseImg.onload = function () {
2183
3422
  _this.lowerContext.drawImage(_this.baseImg, 0, 0, _this.lowerCanvas.width, _this.lowerCanvas.height);
2184
3423
  if (_this.togglePen) {
@@ -2199,7 +3438,6 @@ var ImageEditor = /** @class */ (function (_super) {
2199
3438
  hideSpinner(_this.element);
2200
3439
  _this.element.style.opacity = '1';
2201
3440
  _this.updateCanvas();
2202
- _this.isUndoRedo = false;
2203
3441
  }
2204
3442
  if (Browser.isDevice) {
2205
3443
  if (_this.isToolbar() && (!isNullOrUndefined(document.getElementById(_this.element.id + '_toolbar'))) &&
@@ -2376,9 +3614,6 @@ var ImageEditor = /** @class */ (function (_super) {
2376
3614
  this.degree = 0;
2377
3615
  }
2378
3616
  };
2379
- ImageEditor.prototype.updateUndoRedoColl = function (operation, value, previousObj, currentObj) {
2380
- this.undoRedoColl.push({ operation: operation, value: value, previousObj: previousObj, currentObj: currentObj });
2381
- };
2382
3617
  ImageEditor.prototype.fileSelect = function (inputElement, args) {
2383
3618
  showSpinner(this.element);
2384
3619
  this.element.style.opacity = '0.5';
@@ -2537,7 +3772,7 @@ var ImageEditor = /** @class */ (function (_super) {
2537
3772
  }
2538
3773
  if (strokeWidthElem) {
2539
3774
  var strokeWidth = Math.round((this.activeObj.strokeSettings.strokeWidth /
2540
- (ratio.width + ratio.height))).toString();
3775
+ (ratio.width + ratio.height)) * this.factor).toString();
2541
3776
  strokeWidthElem.textContent = this.getStrokeWidth(strokeWidth);
2542
3777
  }
2543
3778
  };
@@ -2549,10 +3784,32 @@ var ImageEditor = /** @class */ (function (_super) {
2549
3784
  }
2550
3785
  }
2551
3786
  };
3787
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
3788
+ ImageEditor.prototype.targetTouches = function (touches) {
3789
+ var p1 = { x: touches[0].pageX, y: touches[0].pageY };
3790
+ var p2 = { x: touches[1].pageX, y: touches[1].pageY };
3791
+ var points = [p1, p2];
3792
+ return points;
3793
+ };
3794
+ ImageEditor.prototype.calculateScale = function (startTouches, endTouches) {
3795
+ var startDistance = this.getDistance(startTouches[0], startTouches[1]);
3796
+ var endDistance = this.getDistance(endTouches[0], endTouches[1]);
3797
+ return endDistance / startDistance;
3798
+ };
3799
+ ImageEditor.prototype.getDistance = function (a, b) {
3800
+ var x = a.x - b.x;
3801
+ var y = a.y - b.y;
3802
+ return Math.sqrt(x * x + y * y);
3803
+ };
2552
3804
  ImageEditor.prototype.touchStartHandler = function (e) {
2553
3805
  e.preventDefault();
2554
- this.timer = setTimeout(this.setTimer.bind(this), 1000, e);
2555
- this.mouseDownEventHandler(e);
3806
+ if (e.touches.length === 2) {
3807
+ this.isFirstMove = true;
3808
+ }
3809
+ else {
3810
+ this.timer = setTimeout(this.setTimer.bind(this), 1000, e);
3811
+ this.mouseDownEventHandler(e);
3812
+ }
2556
3813
  EventHandler.add(this.lowerCanvas, 'touchend', this.mouseUpEventHandler, this);
2557
3814
  EventHandler.add(this.lowerCanvas, 'touchmove', this.mouseMoveEventHandler, this); // Unbind mousedown to prevent double triggers from touch devices
2558
3815
  EventHandler.add(this.upperCanvas, 'touchend', this.mouseUpEventHandler, this);
@@ -2579,6 +3836,14 @@ var ImageEditor = /** @class */ (function (_super) {
2579
3836
  this.touchEndPoint.y = y = e.touches[0].clientY;
2580
3837
  }
2581
3838
  this.redrawActObj(x, y);
3839
+ if ((!isNullOrUndefined(this.element.querySelector('#' + this.element.id + '_contextualToolbar')) &&
3840
+ !this.element.querySelector('#' + this.element.id + '_contextualToolbar').parentElement.classList.contains('e-hide')) ||
3841
+ (!isNullOrUndefined(this.element.querySelector('#' + this.element.id + '_headWrapper'))
3842
+ && !this.element.querySelector('#' + this.element.id + '_headWrapper').parentElement.classList.contains('e-hide'))) {
3843
+ this.element.querySelector('.e-contextual-toolbar-wrapper').classList.add('e-hide');
3844
+ this.okBtn();
3845
+ this.refreshToolbar('main');
3846
+ }
2582
3847
  if (this.upperCanvas.style.cursor === 'crosshair' || (Browser.isDevice && this.togglePen)) {
2583
3848
  if (this.togglePen) {
2584
3849
  this.canvasRatio = this.calcRatio();
@@ -2642,6 +3907,47 @@ var ImageEditor = /** @class */ (function (_super) {
2642
3907
  };
2643
3908
  ImageEditor.prototype.mouseMoveEventHandler = function (e) {
2644
3909
  e.preventDefault();
3910
+ if (e.type === 'touchmove' && e.touches.length === 2) {
3911
+ if (this.isFirstMove) {
3912
+ this.startTouches = this.targetTouches(e.touches);
3913
+ this.tempTouches = [];
3914
+ this.tempTouches.push({ x: e.touches[0].clientX || (e.touches[0].pageX - this.lowerCanvas.offsetLeft),
3915
+ y: e.touches[0].clientY || (e.touches[0].pageY - this.lowerCanvas.offsetTop) });
3916
+ this.tempTouches.push({ x: e.touches[1].clientX || (e.touches[1].pageX - this.lowerCanvas.offsetLeft),
3917
+ y: e.touches[1].clientY || (e.touches[1].pageY - this.lowerCanvas.offsetTop) });
3918
+ }
3919
+ else {
3920
+ var ratio = this.calcRatio();
3921
+ var firstFingerX = e.touches[0].clientX || (e.touches[0].pageX - this.lowerCanvas.offsetLeft);
3922
+ var firstFingerY = e.touches[0].clientY || (e.touches[0].pageY - this.lowerCanvas.offsetTop);
3923
+ var secondFingerX = e.touches[1].clientX || (e.touches[1].pageX - this.lowerCanvas.offsetLeft);
3924
+ var secondFingerY = e.touches[1].clientY || (e.touches[1].pageY - this.lowerCanvas.offsetTop);
3925
+ this.lastX = firstFingerX > secondFingerX ? secondFingerX + (firstFingerX - secondFingerX) : firstFingerX +
3926
+ (secondFingerX - firstFingerX);
3927
+ this.lastY = firstFingerY > secondFingerY ? secondFingerY + (firstFingerY - secondFingerY) : firstFingerY +
3928
+ (secondFingerY - firstFingerY);
3929
+ this.lastX *= ratio.width;
3930
+ this.lastY *= ratio.height;
3931
+ var scale = this.calculateScale(this.startTouches, this.targetTouches(e.touches));
3932
+ // Need to set lastX and lastY points
3933
+ if (this.tempTouches[0].x !== firstFingerX && this.tempTouches[0].y !== firstFingerY &&
3934
+ this.tempTouches[1].x !== secondFingerX && this.tempTouches[1].y !== secondFingerY) {
3935
+ if (scale > 1) {
3936
+ this.zoom(1.1);
3937
+ }
3938
+ else {
3939
+ this.zoom(-1.1);
3940
+ }
3941
+ this.tempTouches = [];
3942
+ this.tempTouches.push({ x: e.touches[0].clientX || (e.touches[0].pageX - this.lowerCanvas.offsetLeft),
3943
+ y: e.touches[0].clientY || (e.touches[0].pageY - this.lowerCanvas.offsetTop) });
3944
+ this.tempTouches.push({ x: e.touches[1].clientX || (e.touches[1].pageX - this.lowerCanvas.offsetLeft),
3945
+ y: e.touches[1].clientY || (e.touches[1].pageY - this.lowerCanvas.offsetTop) });
3946
+ }
3947
+ }
3948
+ this.isFirstMove = false;
3949
+ return;
3950
+ }
2645
3951
  if (this.textBox.style.display === 'none') {
2646
3952
  this.isTimer = true;
2647
3953
  }
@@ -2660,6 +3966,11 @@ var ImageEditor = /** @class */ (function (_super) {
2660
3966
  !this.dragCanvas || this.activeObj.activePoint !== undefined) {
2661
3967
  if (this.dragElement === '') {
2662
3968
  this.setCursor(x, y);
3969
+ if (this.activeObj.activePoint.width === 0 && this.upperCanvas.style.cursor !== 'default' &&
3970
+ this.upperCanvas.style.cursor !== 'move' && this.upperCanvas.style.cursor !== 'crosshair'
3971
+ && this.upperCanvas.style.cursor !== 'grab') {
3972
+ this.upperCanvas.style.cursor = 'move';
3973
+ }
2663
3974
  this.findTarget(x, y, e.type);
2664
3975
  }
2665
3976
  }
@@ -2682,6 +3993,8 @@ var ImageEditor = /** @class */ (function (_super) {
2682
3993
  y = this.touchEndPoint.y;
2683
3994
  }
2684
3995
  if (e.type === 'touchend') {
3996
+ this.startTouches = this.tempTouches = [];
3997
+ this.isFirstMove = false;
2685
3998
  if (this.textBox.style.display === 'none') {
2686
3999
  this.isTimer = false;
2687
4000
  this.timer = 0;
@@ -2700,8 +4013,16 @@ var ImageEditor = /** @class */ (function (_super) {
2700
4013
  if (e.currentTarget === this.upperCanvas) {
2701
4014
  this.currObjType.shape = this.currObjType.shape.toLowerCase();
2702
4015
  if (!this.togglePen && !this.dragCanvas) {
4016
+ if (!isNullOrUndefined(this.tempObjColl) && this.activeObj.activePoint.width !== 0) {
4017
+ this.objColl.push(this.activeObj);
4018
+ this.redrawShape(this.objColl[this.objColl.length - 1]);
4019
+ this.tempObjColl = undefined;
4020
+ }
2703
4021
  this.applyCurrActObj(x, y);
2704
4022
  }
4023
+ else if (this.dragCanvas) {
4024
+ this.setPanPoints();
4025
+ }
2705
4026
  }
2706
4027
  if (this.togglePen && e.currentTarget === this.upperCanvas) {
2707
4028
  this.penDrawColl.push({ strokeWidth: this.penStrokeWidth, strokeColor: this.activeObj.strokeSettings.strokeColor, points: this.imageEditorPointsColl });
@@ -2730,11 +4051,13 @@ var ImageEditor = /** @class */ (function (_super) {
2730
4051
  e.stopImmediatePropagation();
2731
4052
  break;
2732
4053
  case 'Delete':
2733
- shapeChangingArgs = { action: 'delete', previousShapeSettings: this.activeObj, currentShapeSettings: null };
2734
- this.keyHistory = '';
2735
- this.clearSelection();
2736
- this.trigger('shapeChanging', shapeChangingArgs);
2737
- this.refreshToolbar('main');
4054
+ if (this.textBox.style.display === 'none') {
4055
+ shapeChangingArgs = { action: 'delete', previousShapeSettings: this.activeObj, currentShapeSettings: null };
4056
+ this.keyHistory = '';
4057
+ this.clearSelection();
4058
+ this.trigger('shapeChanging', shapeChangingArgs);
4059
+ this.refreshToolbar('main');
4060
+ }
2738
4061
  break;
2739
4062
  case 'Escape':
2740
4063
  if (this.togglePan) {
@@ -2756,7 +4079,10 @@ var ImageEditor = /** @class */ (function (_super) {
2756
4079
  }
2757
4080
  };
2758
4081
  ImageEditor.prototype.keyUpEventHandler = function (e) {
2759
- setTimeout(this.textKeyDown.bind(this), 1, e);
4082
+ // eslint-disable-next-line
4083
+ if (this.textBox.style.display === 'block' && e.target.id === this.element.id + '_textBox') {
4084
+ setTimeout(this.textKeyDown.bind(this), 1, e);
4085
+ }
2760
4086
  };
2761
4087
  ImageEditor.prototype.canvasMouseDownHandler = function (e) {
2762
4088
  e.preventDefault();
@@ -2774,7 +4100,6 @@ var ImageEditor = /** @class */ (function (_super) {
2774
4100
  if (this.dragCanvas || this.factor !== 1) {
2775
4101
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
2776
4102
  this.dragStart = this.lowerContext.transformedPoint(this.lastX, this.lastY);
2777
- this.dragged = false;
2778
4103
  }
2779
4104
  };
2780
4105
  ImageEditor.prototype.canvasMouseMoveHandler = function (e) {
@@ -2796,55 +4121,39 @@ var ImageEditor = /** @class */ (function (_super) {
2796
4121
  }
2797
4122
  this.lastX *= ratio.width;
2798
4123
  this.lastY *= ratio.height;
2799
- this.dragged = true;
2800
4124
  if (this.dragStart && this.dragCanvas) {
2801
- /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
2802
- var pt = this.lowerContext.transformedPoint(this.lastX, this.lastY);
2803
- var transitionArgs = { startPoint: { x: this.dragStart.x, y: this.dragStart.y },
2804
- endPoint: { x: pt.x, y: pt.y } };
2805
- this.trigger('panning', transitionArgs);
2806
- var xDiff = pt.x - this.dragStart.x;
2807
- var yDiff = pt.y - this.dragStart.y;
2808
- var xxDiff = xDiff;
2809
- var yyDiff = yDiff;
2810
- this.lowerContext.translate(xDiff, yDiff);
2811
- this.upperContext.translate(xDiff, yDiff);
2812
- /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
2813
- var pt1 = this.lowerContext.transformedPoint(0, 0);
2814
- /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
2815
- var pt2 = this.lowerContext.transformedPoint(this.lowerCanvas.width, this.lowerCanvas.height);
2816
- if (xDiff >= 0) {
2817
- if (pt1.x < 1) {
2818
- xDiff = 0;
2819
- }
2820
- }
2821
- else {
2822
- if (pt2.x > this.lowerCanvas.width) {
2823
- xDiff = 0;
2824
- }
2825
- }
2826
- if (yDiff >= 0) {
2827
- if (pt1.y < 1) {
2828
- yDiff = 0;
2829
- }
2830
- }
2831
- else {
2832
- if (pt2.y > this.lowerCanvas.height) {
2833
- yDiff = 0;
2834
- }
2835
- }
2836
- this.lowerContext.translate(-xxDiff, -yyDiff);
2837
- this.upperContext.translate(-xxDiff, -yyDiff);
2838
- this.lowerContext.translate(xDiff, yDiff);
2839
- this.upperContext.translate(xDiff, yDiff);
2840
- this.redraw();
4125
+ this.drawPanImg();
2841
4126
  }
2842
4127
  };
2843
4128
  ImageEditor.prototype.canvasMouseUpHandler = function (e) {
2844
4129
  e.preventDefault();
4130
+ if (this.togglePan && e.currentTarget === this.lowerCanvas) {
4131
+ var ratio = this.calcRatio();
4132
+ if (e.type === 'mouseup') {
4133
+ this.lastX = e.offsetX || (e.pageX - this.lowerCanvas.offsetLeft);
4134
+ this.lastY = e.offsetY || (e.pageY - this.lowerCanvas.offsetTop);
4135
+ }
4136
+ else {
4137
+ this.lastX = e.touches[0].clientX || (e.touches[0].pageX - this.lowerCanvas.offsetLeft);
4138
+ this.lastY = e.touches[0].clientY || (e.touches[0].pageY - this.lowerCanvas.offsetTop);
4139
+ }
4140
+ this.lastX *= ratio.width;
4141
+ this.lastY *= ratio.height;
4142
+ this.setPanPoints();
4143
+ }
2845
4144
  this.dragStart = null;
4145
+ // zooms on mouse click point
4146
+ // if (e.currentTarget !== document) {
4147
+ // this.zoom(e.shiftKey ? -1 : 1 );
4148
+ // }
2846
4149
  this.currObjType.isDragging = false;
2847
4150
  };
4151
+ ImageEditor.prototype.setPanPoints = function () {
4152
+ if (this.dragCanvas || this.factor !== 1) {
4153
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
4154
+ this.dragStart = this.lowerContext.transformedPoint(this.lastX, this.lastY);
4155
+ }
4156
+ };
2848
4157
  ImageEditor.prototype.textKeyDown = function (e) {
2849
4158
  if (String.fromCharCode(e.which) === '\r') {
2850
4159
  this.textRow += 1;
@@ -2863,6 +4172,8 @@ var ImageEditor = /** @class */ (function (_super) {
2863
4172
  ImageEditor.prototype.adjustToScreen = function () {
2864
4173
  // eslint-disable-next-line @typescript-eslint/no-this-alias
2865
4174
  var proxy = this;
4175
+ var tempFilter = this.lowerContext.filter;
4176
+ this.okBtn();
2866
4177
  this.applyActObj();
2867
4178
  this.refreshActiveObj();
2868
4179
  if (this.imgDataColl.length > 0) {
@@ -2884,15 +4195,32 @@ var ImageEditor = /** @class */ (function (_super) {
2884
4195
  canvasWrapper.style.height = (parseFloat(canvasWrapper.style.height) - this.toolbarHeight) - 3 + 'px';
2885
4196
  }
2886
4197
  }
2887
- this.redrawImg();
2888
- // eslint-disable-next-line @typescript-eslint/tslint/config
2889
- this.lowerCanvas.toBlob(function (blob) {
2890
- proxy.baseImg.src = URL.createObjectURL(blob);
2891
- }, 'image/png');
4198
+ this.redrawImg(tempFilter);
4199
+ if (!this.currObjType.isSave) {
4200
+ // eslint-disable-next-line @typescript-eslint/tslint/config
4201
+ this.lowerCanvas.toBlob(function (blob) {
4202
+ proxy.lowerContext.filter = proxy.initialAdjustmentValue = proxy.adjustmentValue = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
4203
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
4204
+ if (proxy.cssClass) {
4205
+ addClass([proxy.element], proxy.cssClass.split(' '));
4206
+ }
4207
+ proxy.lowerContext.clearRect(0, 0, proxy.lowerCanvas.width, proxy.lowerCanvas.height);
4208
+ proxy.lowerContext.drawImage(proxy.inMemoryCanvas, 0, 0);
4209
+ proxy.baseImg.src = URL.createObjectURL(blob);
4210
+ proxy.lowerContext.filter = tempFilter;
4211
+ }, 'image/png');
4212
+ }
4213
+ else {
4214
+ hideSpinner(this.element);
4215
+ this.element.style.opacity = '1';
4216
+ }
2892
4217
  if (this.defToolbarItems.length > 0 && (!isNullOrUndefined(document.getElementById(this.element.id + '_toolbar')))) {
2893
4218
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
2894
- var toolbar_9 = getComponent(proxy.element.id + '_toolbar', 'toolbar');
2895
- toolbar_9.refreshOverflow();
4219
+ var toolbar_10 = getComponent(proxy.element.id + '_toolbar', 'toolbar');
4220
+ toolbar_10.refreshOverflow();
4221
+ if (!isNullOrUndefined(this.element.querySelector('.e-contextual-toolbar-wrapper'))) {
4222
+ this.element.querySelector('.e-contextual-toolbar-wrapper').classList.add('e-hide');
4223
+ }
2896
4224
  }
2897
4225
  };
2898
4226
  ImageEditor.prototype.screenOrientation = function () {
@@ -2906,7 +4234,49 @@ var ImageEditor = /** @class */ (function (_super) {
2906
4234
  this.adjustToScreen();
2907
4235
  }
2908
4236
  };
2909
- ImageEditor.prototype.redrawImg = function () {
4237
+ ImageEditor.prototype.drawPanImg = function () {
4238
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
4239
+ var pt = this.lowerContext.transformedPoint(this.lastX, this.lastY);
4240
+ var transitionArgs = { startPoint: { x: this.dragStart.x, y: this.dragStart.y },
4241
+ endPoint: { x: pt.x, y: pt.y } };
4242
+ this.trigger('panning', transitionArgs);
4243
+ var xDiff = pt.x - this.dragStart.x;
4244
+ var yDiff = pt.y - this.dragStart.y;
4245
+ var xxDiff = xDiff;
4246
+ var yyDiff = yDiff;
4247
+ this.lowerContext.translate(xDiff, yDiff);
4248
+ this.upperContext.translate(xDiff, yDiff);
4249
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
4250
+ var pt1 = this.lowerContext.transformedPoint(0, 0);
4251
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
4252
+ var pt2 = this.lowerContext.transformedPoint(this.lowerCanvas.width, this.lowerCanvas.height);
4253
+ if (xDiff >= 0) {
4254
+ if (pt1.x < 1) {
4255
+ xDiff = 0;
4256
+ }
4257
+ }
4258
+ else {
4259
+ if (pt2.x > this.lowerCanvas.width) {
4260
+ xDiff = 0;
4261
+ }
4262
+ }
4263
+ if (yDiff >= 0) {
4264
+ if (pt1.y < 1) {
4265
+ yDiff = 0;
4266
+ }
4267
+ }
4268
+ else {
4269
+ if (pt2.y > this.lowerCanvas.height) {
4270
+ yDiff = 0;
4271
+ }
4272
+ }
4273
+ this.lowerContext.translate(-xxDiff, -yyDiff);
4274
+ this.upperContext.translate(-xxDiff, -yyDiff);
4275
+ this.lowerContext.translate(xDiff, yDiff);
4276
+ this.upperContext.translate(xDiff, yDiff);
4277
+ this.redraw();
4278
+ };
4279
+ ImageEditor.prototype.redrawImg = function (tempFilter) {
2910
4280
  var wrapperWidth;
2911
4281
  var canvasWrapper = document.querySelector('#' + this.element.id + '_canvasWrapper');
2912
4282
  if (this.isScreenOriented) {
@@ -2922,7 +4292,17 @@ var ImageEditor = /** @class */ (function (_super) {
2922
4292
  this.lowerCanvas.style.maxHeight = this.upperCanvas.style.maxHeight = maxDimension.height + 'px';
2923
4293
  this.lowerCanvas.style.left = this.upperCanvas.style.left = (wrapperWidth - maxDimension.width) / 2 + 1 + 'px';
2924
4294
  this.lowerCanvas.style.top = this.upperCanvas.style.top = (this.element.offsetHeight - this.toolbarHeight - maxDimension.height) / 2 + 1 + 'px';
4295
+ this.lowerContext.filter = tempFilter;
4296
+ var temp = this.lowerContext.filter;
4297
+ this.updateBrightnessFilter();
2925
4298
  this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
4299
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
4300
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
4301
+ for (var i = 0; i < this.objColl.length; i++) {
4302
+ this.apply(this.objColl[i].shape, this.objColl[i]);
4303
+ this.refreshActiveObj();
4304
+ }
4305
+ this.lowerContext.filter = temp;
2926
4306
  };
2927
4307
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
2928
4308
  ImageEditor.prototype.updateContext = function (ctx) {
@@ -2930,7 +4310,7 @@ var ImageEditor = /** @class */ (function (_super) {
2930
4310
  // eslint-disable-next-line @typescript-eslint/no-this-alias
2931
4311
  var proxy = this;
2932
4312
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
2933
- var xform = new DOMMatrix();
4313
+ var xform = new DOMMatrix([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
2934
4314
  ctx.getTransform = function () {
2935
4315
  return xform;
2936
4316
  };
@@ -2999,6 +4379,7 @@ var ImageEditor = /** @class */ (function (_super) {
2999
4379
  return pt.matrixTransform(xform.inverse());
3000
4380
  };
3001
4381
  };
4382
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
3002
4383
  ImageEditor.prototype.scaleNonUniform = function (xform, sx, sy) {
3003
4384
  xform.m11 *= sx;
3004
4385
  xform.m12 *= sx;
@@ -3035,11 +4416,7 @@ var ImageEditor = /** @class */ (function (_super) {
3035
4416
  this.upperContext.setTransform(1, 0, 0, 1, 0, 0);
3036
4417
  this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
3037
4418
  this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
3038
- this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
3039
- for (var j = 0; j < this.objColl.length; j++) {
3040
- this.apply(this.objColl[j].shape, this.objColl[j]);
3041
- this.refreshActiveObj();
3042
- }
4419
+ this.redrawImgWithObj();
3043
4420
  }
3044
4421
  else {
3045
4422
  if (this.factor > 1) {
@@ -3102,11 +4479,7 @@ var ImageEditor = /** @class */ (function (_super) {
3102
4479
  this.upperContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
3103
4480
  this.lowerContext.restore();
3104
4481
  this.upperContext.restore();
3105
- this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
3106
- for (var j = 0; j < this.objColl.length; j++) {
3107
- this.apply(this.objColl[j].shape, this.objColl[j]);
3108
- this.refreshActiveObj();
3109
- }
4482
+ this.redrawImgWithObj();
3110
4483
  };
3111
4484
  ImageEditor.prototype.applyCurrActObj = function (x, y) {
3112
4485
  var isInside = false;
@@ -3130,9 +4503,13 @@ var ImageEditor = /** @class */ (function (_super) {
3130
4503
  }
3131
4504
  if (this.activeObj.shape === 'text' || (this.currObjType.shape === 'ellipse' || this.currObjType.shape === 'rectangle' ||
3132
4505
  this.currObjType.shape === 'line')) {
4506
+ var tempFilter = this.lowerContext.filter;
4507
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
4508
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
3133
4509
  for (var j = 0; j < this.objColl.length; j++) {
3134
4510
  this.apply(this.objColl[j].shape, this.objColl[j]);
3135
4511
  }
4512
+ this.lowerContext.filter = tempFilter;
3136
4513
  this.apply('shape');
3137
4514
  }
3138
4515
  }
@@ -3158,6 +4535,24 @@ var ImageEditor = /** @class */ (function (_super) {
3158
4535
  this.setTextSelection(width, height);
3159
4536
  this.updateActiveObject(ratio, this.activeObj.activePoint, this.activeObj);
3160
4537
  };
4538
+ ImageEditor.prototype.setTextBoxStylesToActObj = function () {
4539
+ var ratio = this.calcRatio();
4540
+ this.activeObj.textSettings.fontFamily = this.textBox.style.fontFamily;
4541
+ this.activeObj.strokeSettings.strokeColor = this.textBox.style.color;
4542
+ if (this.textBox.style.fontWeight === 'bold') {
4543
+ this.activeObj.textSettings.bold = true;
4544
+ }
4545
+ else {
4546
+ this.activeObj.textSettings.bold = false;
4547
+ }
4548
+ if (this.textBox.style.fontStyle === 'italic') {
4549
+ this.activeObj.textSettings.italic = true;
4550
+ }
4551
+ else {
4552
+ this.activeObj.textSettings.italic = false;
4553
+ }
4554
+ this.activeObj.textSettings.fontSize = (parseFloat(this.textBox.style.fontSize) * ((ratio.width + ratio.height) / 2)) / this.factor;
4555
+ };
3161
4556
  ImageEditor.prototype.redrawActObj = function (x, y) {
3162
4557
  var ratio = this.calcRatio();
3163
4558
  var splitWords;
@@ -3167,21 +4562,7 @@ var ImageEditor = /** @class */ (function (_super) {
3167
4562
  }
3168
4563
  if (this.activeObj.horTopLine !== undefined && (this.activeObj.shape !== undefined && splitWords[0] !== 'crop')) {
3169
4564
  if (this.textBox.style.display === 'block') {
3170
- this.activeObj.textSettings.fontFamily = this.textBox.style.fontFamily;
3171
- this.activeObj.strokeSettings.strokeColor = this.textBox.style.color;
3172
- if (this.textBox.style.fontWeight === 'bold') {
3173
- this.activeObj.textSettings.bold = true;
3174
- }
3175
- else {
3176
- this.activeObj.textSettings.bold = false;
3177
- }
3178
- if (this.textBox.style.fontStyle === 'italic') {
3179
- this.activeObj.textSettings.italic = true;
3180
- }
3181
- else {
3182
- this.activeObj.textSettings.italic = false;
3183
- }
3184
- this.activeObj.textSettings.fontSize = (parseFloat(this.textBox.style.fontSize) * ((ratio.width + ratio.height) / 2)) / this.factor;
4565
+ this.setTextBoxStylesToActObj();
3185
4566
  if (x && y) {
3186
4567
  x -= bbox.left;
3187
4568
  y -= bbox.top;
@@ -3643,10 +5024,7 @@ var ImageEditor = /** @class */ (function (_super) {
3643
5024
  }
3644
5025
  }
3645
5026
  this.lowerContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
3646
- this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
3647
- for (var i = 0; i < this.objColl.length; i++) {
3648
- this.apply(this.objColl[i].shape, this.objColl[i]);
3649
- }
5027
+ this.redrawImgWithObj();
3650
5028
  this.activeObj = temp;
3651
5029
  this.updateFontStyles();
3652
5030
  if (this.factor === 1) {
@@ -4051,7 +5429,7 @@ var ImageEditor = /** @class */ (function (_super) {
4051
5429
  else {
4052
5430
  diff = Math.max(this.diffPoint.x, this.diffPoint.y);
4053
5431
  }
4054
- percentage = diff / 10;
5432
+ percentage = (diff / 10) * this.factor;
4055
5433
  this.activeObj.activePoint.startX -= (maxDimension.width / 100) * percentage;
4056
5434
  this.activeObj.activePoint.startY -= (maxDimension.height / 100) * percentage;
4057
5435
  this.activeObj.activePoint.width = this.activeObj.activePoint.endX - this.activeObj.activePoint.startX;
@@ -4196,7 +5574,7 @@ var ImageEditor = /** @class */ (function (_super) {
4196
5574
  else {
4197
5575
  diff = Math.max(this.diffPoint.x, this.diffPoint.y);
4198
5576
  }
4199
- percentage = diff / 10;
5577
+ percentage = (diff / 10) * this.factor;
4200
5578
  this.activeObj.activePoint.endX += (maxDimension.width / 100) * percentage;
4201
5579
  this.activeObj.activePoint.startY -= (maxDimension.height / 100) * percentage;
4202
5580
  this.activeObj.activePoint.width = this.activeObj.activePoint.endX - this.activeObj.activePoint.startX;
@@ -4392,7 +5770,7 @@ var ImageEditor = /** @class */ (function (_super) {
4392
5770
  else {
4393
5771
  diff = Math.max(this.diffPoint.x, this.diffPoint.y);
4394
5772
  }
4395
- percentage = diff / 10;
5773
+ percentage = (diff / 10) * this.factor;
4396
5774
  this.activeObj.activePoint.startX -= (maxDimension.width / 100) * percentage;
4397
5775
  this.activeObj.activePoint.endY += (maxDimension.height / 100) * percentage;
4398
5776
  this.activeObj.activePoint.width = this.activeObj.activePoint.endX - this.activeObj.activePoint.startX;
@@ -4539,7 +5917,7 @@ var ImageEditor = /** @class */ (function (_super) {
4539
5917
  else {
4540
5918
  diff = Math.min(this.diffPoint.x, this.diffPoint.y);
4541
5919
  }
4542
- percentage = diff / 10;
5920
+ percentage = (diff / 10) * this.factor;
4543
5921
  this.activeObj.activePoint.endX += (maxDimension.width / 50) * percentage;
4544
5922
  this.activeObj.activePoint.endY += (maxDimension.height / 50) * percentage;
4545
5923
  this.activeObj.activePoint.width = this.activeObj.activePoint.endX - this.activeObj.activePoint.startX;
@@ -4585,8 +5963,6 @@ var ImageEditor = /** @class */ (function (_super) {
4585
5963
  width = this.activeObj.activePoint.endX - x;
4586
5964
  height = this.activeObj.activePoint.endY - y;
4587
5965
  scale = Math.min(width, height);
4588
- var ratio = this.activeObj.shape.split('-');
4589
- ratio = ratio[1].split(':');
4590
5966
  var newScale = this.getScaleRatio(scale);
4591
5967
  this.activeObj.activePoint.endX -= newScale.x;
4592
5968
  this.activeObj.activePoint.endY -= newScale.y;
@@ -5245,6 +6621,7 @@ var ImageEditor = /** @class */ (function (_super) {
5245
6621
  this.refreshActiveObj();
5246
6622
  return;
5247
6623
  }
6624
+ this.tempObjColl = extend([], this.objColl, [], true);
5248
6625
  this.currObjType.isCustomCrop = false;
5249
6626
  var temp = this.activeObj = extend({}, this.objColl[i], {}, true);
5250
6627
  this.objColl.splice(i, 1);
@@ -5254,11 +6631,35 @@ var ImageEditor = /** @class */ (function (_super) {
5254
6631
  this.inMemoryContext.putImageData(this.imgDataColl[0].value, 0, 0);
5255
6632
  }
5256
6633
  else {
6634
+ if ((this.adjustmentLevel.sharpen || this.adjustmentLevel.bw) && !this.sharpenedImgData) {
6635
+ var data = void 0;
6636
+ var tempImageData = this.currImgData;
6637
+ if (this.adjustmentLevel.sharpen) {
6638
+ data = this.getSharpenData(this.currImgData);
6639
+ }
6640
+ else {
6641
+ data = this.getBlackAndWhiteData(tempImageData);
6642
+ }
6643
+ this.currImgData = data;
6644
+ this.sharpenedImgData = true;
6645
+ }
5257
6646
  this.inMemoryCanvas.width = this.currImgData.width;
5258
6647
  this.inMemoryCanvas.height = this.currImgData.height;
5259
6648
  this.inMemoryContext.putImageData(this.currImgData, 0, 0);
5260
6649
  }
5261
6650
  if (this.flipState !== '') {
6651
+ if ((this.adjustmentLevel.sharpen || this.adjustmentLevel.bw) && !this.sharpenedImgData) {
6652
+ var data = void 0;
6653
+ var tempImageData = this.currImgData;
6654
+ if (this.adjustmentLevel.sharpen) {
6655
+ data = this.getSharpenData(this.currImgData);
6656
+ }
6657
+ else {
6658
+ data = this.getBlackAndWhiteData(tempImageData);
6659
+ }
6660
+ this.currImgData = data;
6661
+ this.sharpenedImgData = true;
6662
+ }
5262
6663
  this.inMemoryContext.clearRect(0, 0, this.inMemoryCanvas.width, this.inMemoryCanvas.height);
5263
6664
  this.inMemoryContext.clearRect(0, 0, this.inMemoryCanvas.height, this.inMemoryCanvas.width);
5264
6665
  this.inMemoryCanvas.width = this.currImgData.width;
@@ -5267,15 +6668,10 @@ var ImageEditor = /** @class */ (function (_super) {
5267
6668
  }
5268
6669
  this.setActivePoint();
5269
6670
  this.upperContext.drawImage(this.inMemoryCanvas, 0, 0);
6671
+ this.lowerContext.filter = this.canvasFilter;
5270
6672
  this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
5271
- this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
6673
+ this.redrawImgWithObj();
5272
6674
  this.upperContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
5273
- for (var j = 0; j < this.objColl.length; j++) {
5274
- if (this.objColl[j].shape === 'text' && this.objColl[j].shapeFlip !== this.currFlipState) {
5275
- this.objColl[j].flippedText = true;
5276
- }
5277
- this.apply(this.objColl[j].shape, this.objColl[j]);
5278
- }
5279
6675
  this.activeObj = extend({}, temp, {}, true);
5280
6676
  var endPoint = { x: this.lowerCanvas.width - this.pannEnd.startX, y: this.lowerCanvas.height - this.pannEnd.startY };
5281
6677
  if (this.factor !== 1 && (this.activeObj.activePoint.startX < this.pannStart.startX || this.activeObj.activePoint.startY <
@@ -5658,7 +7054,7 @@ var ImageEditor = /** @class */ (function (_super) {
5658
7054
  }
5659
7055
  else {
5660
7056
  if (this.currObjType.isCustomCrop) {
5661
- this.upperCanvas.style.cursor = 'cross-hair';
7057
+ this.upperCanvas.style.cursor = 'crosshair';
5662
7058
  }
5663
7059
  this.upperCanvas.style.cursor = 'default';
5664
7060
  }
@@ -5755,7 +7151,7 @@ var ImageEditor = /** @class */ (function (_super) {
5755
7151
  }
5756
7152
  else {
5757
7153
  if (this.currObjType.isCustomCrop) {
5758
- this.upperCanvas.style.cursor = 'cross-hair';
7154
+ this.upperCanvas.style.cursor = 'crosshair';
5759
7155
  }
5760
7156
  this.upperCanvas.style.cursor = 'default';
5761
7157
  }
@@ -5815,7 +7211,7 @@ var ImageEditor = /** @class */ (function (_super) {
5815
7211
  // eslint-disable-next-line @typescript-eslint/tslint/config
5816
7212
  this.lowerCanvas.toBlob(function (blob) {
5817
7213
  var blobUrl = URL.createObjectURL(blob);
5818
- proxy.baseImg.src = blobUrl;
7214
+ //proxy.baseImg.src = blobUrl;
5819
7215
  proxy.downloadImg(blobUrl, fileName + '.' + type);
5820
7216
  }, 'image/png');
5821
7217
  };
@@ -5861,24 +7257,9 @@ var ImageEditor = /** @class */ (function (_super) {
5861
7257
  var imgData = this.lowerContext.getImageData(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
5862
7258
  this.imgDataColl.push({ operation: operation, value: imgData });
5863
7259
  this.inMemoryCanvas.width = imgData.width;
5864
- this.inMemoryCanvas.height = imgData.height;
5865
- this.inMemoryContext.putImageData(imgData, 0, 0);
5866
- }
5867
- };
5868
- ImageEditor.prototype.drawBaseImg = function () {
5869
- this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
5870
- this.lowerContext.clearRect(0, 0, this.lowerCanvas.height, this.lowerCanvas.width);
5871
- this.inMemoryContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
5872
- this.inMemoryContext.clearRect(0, 0, this.lowerCanvas.height, this.lowerCanvas.width);
5873
- this.inMemoryCanvas.width = this.lowerCanvas.width = this.imgDataColl[0].value.width;
5874
- this.inMemoryCanvas.height = this.lowerCanvas.height = this.imgDataColl[0].value.height;
5875
- this.inMemoryContext.putImageData(this.imgDataColl[0].value, 0, 0);
5876
- var maxDimension = this.calcMaxDimension(this.inMemoryCanvas.width, this.inMemoryCanvas.height);
5877
- this.lowerCanvas.style.maxWidth = this.upperCanvas.style.maxWidth = maxDimension.width + 'px';
5878
- this.lowerCanvas.style.maxHeight = this.upperCanvas.style.maxHeight = maxDimension.height + 'px';
5879
- this.lowerCanvas.style.left = this.upperCanvas.style.left = (this.element.clientWidth - maxDimension.width) / 2 + 1 + 'px';
5880
- this.lowerCanvas.style.top = this.upperCanvas.style.top = (this.element.clientHeight - this.toolbarHeight - maxDimension.height) / 2 + 1 + 'px';
5881
- this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
7260
+ this.inMemoryCanvas.height = imgData.height;
7261
+ this.inMemoryContext.putImageData(imgData, 0, 0);
7262
+ }
5882
7263
  };
5883
7264
  ImageEditor.prototype.calcPrevRatio = function () {
5884
7265
  var oldWidthRatio;
@@ -5986,15 +7367,23 @@ var ImageEditor = /** @class */ (function (_super) {
5986
7367
  }
5987
7368
  else if (degree === 90 || degree === -90) {
5988
7369
  this.updateCurrentActiveObjPoint(degree);
7370
+ var tempFilter = this.lowerContext.filter;
7371
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
7372
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
5989
7373
  for (var i = 0; i < this.objColl.length; i++) {
5990
7374
  this.apply(this.objColl[i].shape, this.objColl[i]);
5991
7375
  }
7376
+ this.lowerContext.filter = tempFilter;
5992
7377
  }
5993
7378
  else {
5994
7379
  this.updateCurrentActiveObjPoint('zoom');
7380
+ var tempFilter = this.lowerContext.filter;
7381
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
7382
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
5995
7383
  for (var i = 0; i < this.objColl.length; i++) {
5996
7384
  this.apply(this.objColl[i].shape, this.objColl[i]);
5997
7385
  }
7386
+ this.lowerContext.filter = tempFilter;
5998
7387
  }
5999
7388
  }
6000
7389
  else if (this.objColl.length === 0 && (degree === 'horizontal' || degree === 'vertical' || degree === 'Horizontal' || degree === 'Vertical')) {
@@ -6042,12 +7431,14 @@ var ImageEditor = /** @class */ (function (_super) {
6042
7431
  if (this.objColl[i].activePoint.startX <= this.lowerCanvas.width / 2) {
6043
7432
  this.objColl[i].activePoint.startX = this.lowerCanvas.width / 2 + ((this.lowerCanvas.width / 2) -
6044
7433
  this.objColl[i].activePoint.endX);
6045
- this.objColl[i].activePoint.endX = this.objColl[i].activePoint.startX + this.objColl[i].activePoint.width;
7434
+ this.objColl[i].activePoint.endX = this.objColl[i].activePoint.startX +
7435
+ this.objColl[i].activePoint.width;
6046
7436
  this.updateActiveObject(ratio, this.objColl[i].activePoint, this.objColl[i]);
6047
7437
  }
6048
7438
  else if (this.objColl[i].activePoint.startX >= this.lowerCanvas.width / 2) {
6049
7439
  this.objColl[i].activePoint.startX = this.lowerCanvas.width - this.objColl[i].activePoint.endX;
6050
- this.objColl[i].activePoint.endX = this.objColl[i].activePoint.startX + this.objColl[i].activePoint.width;
7440
+ this.objColl[i].activePoint.endX = this.objColl[i].activePoint.startX +
7441
+ this.objColl[i].activePoint.width;
6051
7442
  this.updateActiveObject(ratio, this.objColl[i].activePoint, this.objColl[i]);
6052
7443
  }
6053
7444
  }
@@ -6057,12 +7448,14 @@ var ImageEditor = /** @class */ (function (_super) {
6057
7448
  if (this.objColl[i].activePoint.startY <= this.lowerCanvas.height / 2) {
6058
7449
  this.objColl[i].activePoint.startY = this.lowerCanvas.height / 2 + ((this.lowerCanvas.height / 2) -
6059
7450
  this.objColl[i].activePoint.endY);
6060
- this.objColl[i].activePoint.endY = this.objColl[i].activePoint.startY + this.objColl[i].activePoint.height;
7451
+ this.objColl[i].activePoint.endY = this.objColl[i].activePoint.startY +
7452
+ this.objColl[i].activePoint.height;
6061
7453
  this.updateActiveObject(ratio, this.objColl[i].activePoint, this.objColl[i]);
6062
7454
  }
6063
7455
  else if (this.objColl[i].activePoint.startY >= this.lowerCanvas.height / 2) {
6064
7456
  this.objColl[i].activePoint.startY = this.lowerCanvas.height - this.objColl[i].activePoint.endY;
6065
- this.objColl[i].activePoint.endY = this.objColl[i].activePoint.startY + this.objColl[i].activePoint.height;
7457
+ this.objColl[i].activePoint.endY = this.objColl[i].activePoint.startY +
7458
+ this.objColl[i].activePoint.height;
6066
7459
  this.updateActiveObject(ratio, this.objColl[i].activePoint, this.objColl[i]);
6067
7460
  }
6068
7461
  }
@@ -6077,44 +7470,36 @@ var ImageEditor = /** @class */ (function (_super) {
6077
7470
  this.objColl[i].activePoint.startY /= oldRatio.height;
6078
7471
  this.objColl[i].activePoint.endX /= oldRatio.width;
6079
7472
  this.objColl[i].activePoint.endY /= oldRatio.height;
6080
- this.objColl[i].activePoint.height = this.objColl[i].activePoint.endX - this.objColl[i].activePoint.startX;
6081
- this.objColl[i].activePoint.width = this.objColl[i].activePoint.endY - this.objColl[i].activePoint.startY;
7473
+ this.objColl[i].activePoint.height = this.objColl[i].activePoint.endX -
7474
+ this.objColl[i].activePoint.startX;
7475
+ this.objColl[i].activePoint.width = this.objColl[i].activePoint.endY -
7476
+ this.objColl[i].activePoint.startY;
6082
7477
  this.objColl[i].strokeSettings.strokeWidth /= (oldRatio.width / this.factor);
6083
7478
  this.calcCurrPoints(degree, this.objColl[i]);
6084
- this.objColl[i].activePoint.endX = this.objColl[i].activePoint.startX + this.objColl[i].activePoint.width;
6085
- this.objColl[i].activePoint.endY = this.objColl[i].activePoint.startY + this.objColl[i].activePoint.height;
6086
- this.objColl[i].activePoint.width = this.objColl[i].activePoint.endX - this.objColl[i].activePoint.startX;
6087
- this.objColl[i].activePoint.height = this.objColl[i].activePoint.endY - this.objColl[i].activePoint.startY;
7479
+ this.objColl[i].activePoint.endX = this.objColl[i].activePoint.startX +
7480
+ this.objColl[i].activePoint.width;
7481
+ this.objColl[i].activePoint.endY = this.objColl[i].activePoint.startY +
7482
+ this.objColl[i].activePoint.height;
7483
+ this.objColl[i].activePoint.width = this.objColl[i].activePoint.endX -
7484
+ this.objColl[i].activePoint.startX;
7485
+ this.objColl[i].activePoint.height = this.objColl[i].activePoint.endY -
7486
+ this.objColl[i].activePoint.startY;
6088
7487
  }
6089
7488
  for (var i = 0; i < this.objColl.length; i++) {
6090
7489
  this.objColl[i].activePoint.startX *= oldRatio.width;
6091
7490
  this.objColl[i].activePoint.startY *= oldRatio.height;
6092
7491
  this.objColl[i].activePoint.endX *= oldRatio.width;
6093
7492
  this.objColl[i].activePoint.endY *= oldRatio.height;
6094
- this.objColl[i].activePoint.width = this.objColl[i].activePoint.endX - this.objColl[i].activePoint.startX;
6095
- this.objColl[i].activePoint.height = this.objColl[i].activePoint.endY - this.objColl[i].activePoint.startY;
7493
+ this.objColl[i].activePoint.width = this.objColl[i].activePoint.endX -
7494
+ this.objColl[i].activePoint.startX;
7495
+ this.objColl[i].activePoint.height = this.objColl[i].activePoint.endY -
7496
+ this.objColl[i].activePoint.startY;
6096
7497
  this.objColl[i].strokeSettings.strokeWidth *= ratio.width;
6097
7498
  }
6098
7499
  for (var i = 0; i < this.objColl.length; i++) {
6099
7500
  this.updateActiveObject(ratio, this.objColl[i].activePoint, this.objColl[i]);
6100
7501
  }
6101
7502
  }
6102
- else if (degree === 'zoom') {
6103
- for (var i = 0; i < this.objColl.length; i++) {
6104
- this.objColl[i].activePoint.startX /= ratio.width;
6105
- this.objColl[i].activePoint.startY /= ratio.height;
6106
- this.objColl[i].activePoint.endX /= ratio.width;
6107
- this.objColl[i].activePoint.endY /= ratio.height;
6108
- this.objColl[i].activePoint.height = this.objColl[i].activePoint.endX - this.objColl[i].activePoint.startX;
6109
- this.objColl[i].activePoint.width = this.objColl[i].activePoint.endY - this.objColl[i].activePoint.startY;
6110
- this.objColl[i].activePoint.startX *= ratio.width;
6111
- this.objColl[i].activePoint.startY *= ratio.height;
6112
- this.objColl[i].activePoint.endX *= ratio.width;
6113
- this.objColl[i].activePoint.endY *= ratio.height;
6114
- this.objColl[i].activePoint.width = this.objColl[i].activePoint.endX - this.objColl[i].activePoint.startX;
6115
- this.objColl[i].activePoint.height = this.objColl[i].activePoint.endY - this.objColl[i].activePoint.startY;
6116
- }
6117
- }
6118
7503
  };
6119
7504
  ImageEditor.prototype.calcCurrPoints = function (degree, obj) {
6120
7505
  var oldRatio = this.calcPrevRatio();
@@ -6178,10 +7563,7 @@ var ImageEditor = /** @class */ (function (_super) {
6178
7563
  tempObjColl = [];
6179
7564
  this.refreshActiveObj();
6180
7565
  this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
6181
- this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
6182
- for (var i = 0; i < this.objColl.length; i++) {
6183
- this.apply(this.objColl[i].shape, this.objColl[i]);
6184
- }
7566
+ this.redrawImgWithObj();
6185
7567
  this.activeObj.flippedText = false;
6186
7568
  this.currObjType.shape = '';
6187
7569
  this.refreshActiveObj();
@@ -6199,17 +7581,27 @@ var ImageEditor = /** @class */ (function (_super) {
6199
7581
  showSpinner(proxy_1.element);
6200
7582
  proxy_1.element.style.opacity = '0.5';
6201
7583
  proxy_1.lowerContext.clearRect(0, 0, proxy_1.lowerCanvas.width, proxy_1.lowerCanvas.height);
7584
+ var temp = proxy_1.lowerContext.filter;
7585
+ proxy_1.lowerContext.filter = proxy_1.initialAdjustmentValue = proxy_1.adjustmentValue = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
7586
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
7587
+ if (proxy_1.cssClass) {
7588
+ addClass([proxy_1.element], proxy_1.cssClass.split(' '));
7589
+ }
6202
7590
  proxy_1.lowerContext.drawImage(proxy_1.inMemoryCanvas, 0, 0);
6203
7591
  proxy_1.baseImg.src = URL.createObjectURL(blob);
6204
7592
  proxy_1.upperContext.clearRect(0, 0, proxy_1.upperCanvas.width, proxy_1.upperCanvas.height);
6205
7593
  proxy_1.togglePen = false;
6206
7594
  proxy_1.upperCanvas.style.cursor = 'default';
7595
+ proxy_1.lowerContext.filter = temp;
7596
+ var tempFilter = proxy_1.lowerContext.filter;
7597
+ proxy_1.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
7598
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
6207
7599
  for (var i = 0, len = proxy_1.objColl.length; i < len; i++) {
6208
7600
  proxy_1.apply(proxy_1.objColl[i].shape, proxy_1.objColl[i], 'duplicate');
6209
7601
  }
7602
+ proxy_1.lowerContext.filter = tempFilter;
6210
7603
  proxy_1.togglePen = true;
6211
7604
  }, 'image/png');
6212
- this.isUndoRedo = false;
6213
7605
  this.degree = 0;
6214
7606
  }
6215
7607
  else {
@@ -6224,7 +7616,6 @@ var ImageEditor = /** @class */ (function (_super) {
6224
7616
  }
6225
7617
  this.keyHistory = '';
6226
7618
  }
6227
- this.isUndoRedo = false;
6228
7619
  }
6229
7620
  }
6230
7621
  };
@@ -6351,104 +7742,591 @@ var ImageEditor = /** @class */ (function (_super) {
6351
7742
  if (this.lowerCanvas.width > this.lowerCanvas.height) {
6352
7743
  this.activeObj.textSettings.fontSize = Math.floor((this.lowerCanvas.width / 20));
6353
7744
  }
6354
- else {
6355
- this.activeObj.textSettings.fontSize = Math.floor((this.lowerCanvas.height / 20));
7745
+ else {
7746
+ this.activeObj.textSettings.fontSize = Math.floor((this.lowerCanvas.height / 20));
7747
+ }
7748
+ if (this.activeObj.textSettings.fontSize < 20 * (ratio.width + ratio.height)) {
7749
+ this.activeObj.textSettings.fontSize = 20 * (ratio.width + ratio.height);
7750
+ }
7751
+ if (this.factor > 1) {
7752
+ this.activeObj.textSettings.fontSize /= this.factor;
7753
+ }
7754
+ }
7755
+ this.activeObj.shapeDegree = this.degree;
7756
+ this.activeObj.shapeFlip = this.currFlipState;
7757
+ this.activeObj.flipObjColl = [];
7758
+ this.updateFontStyles();
7759
+ var width = this.upperContext.measureText(this.activeObj.textSettings.text).width +
7760
+ this.activeObj.textSettings.fontSize * 0.5;
7761
+ var height = this.activeObj.textSettings.fontSize + this.activeObj.textSettings.fontSize * 0.25;
7762
+ if (!isNullOrUndefined(x) && !isNullOrUndefined(y)) {
7763
+ this.activeObj.activePoint.startX = x;
7764
+ this.activeObj.activePoint.startY = y;
7765
+ this.activeObj.activePoint.endX = this.activeObj.activePoint.startX + width;
7766
+ this.activeObj.activePoint.endY = this.activeObj.activePoint.startY + height;
7767
+ }
7768
+ else {
7769
+ this.setCenterPoints(true, width, height);
7770
+ }
7771
+ this.addLetter(this.activeObj.textSettings.text);
7772
+ this.objColl.push(this.activeObj);
7773
+ this.redrawShape(this.objColl[this.objColl.length - 1]);
7774
+ this.refreshToolbar('text');
7775
+ }
7776
+ };
7777
+ ImageEditor.prototype.drawPen = function (context) {
7778
+ var ratio = this.calcRatio();
7779
+ context = context ? context : this.upperContext;
7780
+ this.upperCanvas.style.display = 'block';
7781
+ this.canvasRatio = this.calcRatio();
7782
+ if (isNullOrUndefined(this.activeObj.strokeSettings)) {
7783
+ this.activeObj.strokeSettings = this.strokeSettings;
7784
+ }
7785
+ if (isNullOrUndefined(this.activeObj.strokeSettings.strokeWidth)) {
7786
+ this.activeObj.strokeSettings.strokeWidth = (ratio.width + ratio.height) * 0.4;
7787
+ }
7788
+ context.strokeStyle = this.activeObj.strokeSettings.strokeColor;
7789
+ context.lineWidth = 2 * (this.activeObj.strokeSettings.strokeWidth) / this.factor;
7790
+ context.beginPath();
7791
+ context.moveTo(this.prevX, this.prevY);
7792
+ context.lineTo(this.currX, this.currY);
7793
+ context.stroke();
7794
+ context.closePath();
7795
+ };
7796
+ ImageEditor.prototype.getObjDetails = function (obj) {
7797
+ var shapeDetails = {};
7798
+ shapeDetails.id = obj.currIndex;
7799
+ shapeDetails.type = obj.shape;
7800
+ shapeDetails.startX = obj.activePoint.startX;
7801
+ shapeDetails.startY = obj.activePoint.startY;
7802
+ if (obj.shape === 'rectangle') {
7803
+ shapeDetails.width = obj.activePoint.width;
7804
+ shapeDetails.height = obj.activePoint.height;
7805
+ shapeDetails.strokeColor = obj.strokeSettings.strokeColor;
7806
+ shapeDetails.fillColor = obj.strokeSettings.fillColor;
7807
+ shapeDetails.strokeWidth = obj.strokeSettings.strokeWidth;
7808
+ }
7809
+ else if (obj.shape === 'ellipse') {
7810
+ shapeDetails.radius = obj.activePoint.width / 2;
7811
+ shapeDetails.strokeColor = obj.strokeSettings.strokeColor;
7812
+ shapeDetails.fillColor = obj.strokeSettings.fillColor;
7813
+ shapeDetails.strokeWidth = obj.strokeSettings.strokeWidth;
7814
+ }
7815
+ else if (obj.shape === 'line') {
7816
+ shapeDetails.length = obj.activePoint.width;
7817
+ shapeDetails.strokeColor = obj.strokeSettings.strokeColor;
7818
+ shapeDetails.strokeWidth = obj.strokeSettings.strokeWidth;
7819
+ }
7820
+ else if (obj.shape === 'text') {
7821
+ shapeDetails.text = obj.keyHistory;
7822
+ shapeDetails.fontSize = obj.textSettings.fontSize;
7823
+ shapeDetails.color = obj.strokeSettings.strokeColor;
7824
+ shapeDetails.fontStyle = [];
7825
+ if (obj.textSettings.bold) {
7826
+ shapeDetails.fontStyle.push('bold');
7827
+ }
7828
+ if (obj.textSettings.italic) {
7829
+ shapeDetails.fontStyle.push('italic');
7830
+ }
7831
+ }
7832
+ return shapeDetails;
7833
+ };
7834
+ ImageEditor.prototype.isPointsInRange = function (x, y) {
7835
+ var inRange = false;
7836
+ if (this.factor === 1) {
7837
+ if (x >= 0 && y >= 0 && x <= this.lowerCanvas.width && y <= this.lowerCanvas.width) {
7838
+ inRange = true;
7839
+ }
7840
+ }
7841
+ else {
7842
+ var endPoint = { x: this.lowerCanvas.width - this.pannEnd.startX, y: this.lowerCanvas.height - this.pannEnd.startY };
7843
+ if (x >= this.pannStart.startX && y >= this.pannStart.startY && x <= endPoint.x && y <= endPoint.y) {
7844
+ inRange = true;
7845
+ }
7846
+ }
7847
+ return inRange;
7848
+ };
7849
+ ImageEditor.prototype.updateInMemoryContext = function (imgData, isUpdate) {
7850
+ var temp = extend({}, this.activeObj, {}, true);
7851
+ this.redrawImgWithObj();
7852
+ this.activeObj = temp;
7853
+ if (isNullOrUndefined(isUpdate)) {
7854
+ imgData = this.lowerContext.getImageData(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
7855
+ }
7856
+ this.inMemoryContext.clearRect(0, 0, this.inMemoryCanvas.width, this.inMemoryCanvas.height);
7857
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
7858
+ this.inMemoryCanvas.width = imgData.width;
7859
+ this.inMemoryCanvas.height = imgData.height;
7860
+ this.inMemoryContext.putImageData(imgData, 0, 0);
7861
+ };
7862
+ ImageEditor.prototype.clearActObj = function () {
7863
+ if (this.textBox.style.display === 'none') {
7864
+ this.refreshActiveObj();
7865
+ this.applyActObj();
7866
+ this.refreshActiveObj();
7867
+ this.currObjType.isCustomCrop = false;
7868
+ }
7869
+ };
7870
+ ImageEditor.prototype.rotateMultiple = function (length, degree) {
7871
+ for (var i = 0; i < length; i++) {
7872
+ if (degree > 0) {
7873
+ this.degree += 90;
7874
+ }
7875
+ else {
7876
+ this.degree -= 90;
7877
+ }
7878
+ if (this.degree === 360) {
7879
+ this.degree = 0;
7880
+ }
7881
+ var temp = this.lowerContext.filter;
7882
+ this.lowerContext.save();
7883
+ this.setMaximumDimension(90 * (i + 1));
7884
+ this.lowerContext.translate(this.lowerCanvas.width / 2, this.lowerCanvas.height / 2);
7885
+ if (degree > 0) {
7886
+ this.lowerContext.rotate(Math.PI / 180 * 90);
7887
+ }
7888
+ else {
7889
+ this.lowerContext.rotate(Math.PI / 180 * -90);
7890
+ }
7891
+ this.lowerCanvas.style.left = this.upperCanvas.style.left = (this.element.clientWidth - parseInt(this.lowerCanvas.style.maxWidth, 10) - 18) / 2 + 1 + 'px';
7892
+ this.lowerCanvas.style.top = this.upperCanvas.style.top = (this.element.clientHeight - this.toolbarHeight - parseInt(this.lowerCanvas.style.maxHeight, 10)) / 2 + 1 + 'px';
7893
+ this.updateBrightnessFilter();
7894
+ this.lowerContext.drawImage(this.inMemoryCanvas, -this.lowerCanvas.height / 2, -this.lowerCanvas.width / 2);
7895
+ this.lowerContext.filter = temp;
7896
+ if (degree > 0) {
7897
+ this.lowerContext.rotate(Math.PI / 180 * -90);
7898
+ }
7899
+ else {
7900
+ this.lowerContext.rotate(Math.PI / 180 * 90);
7901
+ }
7902
+ this.lowerContext.translate(-this.lowerCanvas.width / 2, -this.lowerCanvas.height / 2);
7903
+ this.lowerContext.restore();
7904
+ this.currImgData = this.lowerContext.getImageData(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
7905
+ this.inMemoryContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
7906
+ this.inMemoryCanvas.width = this.currImgData.width;
7907
+ this.inMemoryCanvas.height = this.currImgData.height;
7908
+ this.inMemoryContext.putImageData(this.currImgData, 0, 0);
7909
+ this.lowerContext.filter = this.canvasFilter;
7910
+ this.updateBrightnessFilter();
7911
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
7912
+ this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
7913
+ this.lowerContext.filter = temp;
7914
+ if (degree > 0) {
7915
+ this.redrawObj(90);
7916
+ }
7917
+ else {
7918
+ this.redrawObj(-90);
7919
+ }
7920
+ }
7921
+ };
7922
+ ImageEditor.prototype.setBrightness = function (value) {
7923
+ if (!this.disabled && this.imgDataColl.length > 0) {
7924
+ if (this.currObjType.shape === 'freehanddraw') {
7925
+ this.apply();
7926
+ this.upperCanvas.style.cursor = 'default';
7927
+ this.currObjType.shape = '';
7928
+ }
7929
+ this.clearActObj();
7930
+ this.adjustmentLevel.brightness = value;
7931
+ value = this.getFilterValue(value);
7932
+ this.updateAdjustment('brightness', value);
7933
+ }
7934
+ };
7935
+ ImageEditor.prototype.setContrast = function (value) {
7936
+ if (!this.disabled && this.imgDataColl.length > 0) {
7937
+ if (this.currObjType.shape === 'freehanddraw') {
7938
+ this.apply();
7939
+ this.upperCanvas.style.cursor = 'default';
7940
+ this.currObjType.shape = '';
7941
+ }
7942
+ this.clearActObj();
7943
+ this.adjustmentLevel.contrast = value;
7944
+ value = this.getFilterValue(value);
7945
+ value *= 100;
7946
+ this.updateAdjustment('contrast', value);
7947
+ }
7948
+ };
7949
+ ImageEditor.prototype.setHue = function (value) {
7950
+ if (!this.disabled && this.imgDataColl.length > 0) {
7951
+ if (this.currObjType.shape === 'freehanddraw') {
7952
+ this.apply();
7953
+ this.upperCanvas.style.cursor = 'default';
7954
+ this.currObjType.shape = '';
7955
+ }
7956
+ this.clearActObj();
7957
+ this.adjustmentLevel.hue = value;
7958
+ value *= 3;
7959
+ this.updateAdjustment('hue', value);
7960
+ }
7961
+ };
7962
+ ImageEditor.prototype.setSaturation = function (value) {
7963
+ if (!this.disabled && this.imgDataColl.length > 0) {
7964
+ if (this.currObjType.shape === 'freehanddraw') {
7965
+ this.apply();
7966
+ this.upperCanvas.style.cursor = 'default';
7967
+ this.currObjType.shape = '';
7968
+ }
7969
+ this.clearActObj();
7970
+ this.adjustmentLevel.saturation = value;
7971
+ value = this.getSaturationFilterValue(value);
7972
+ value *= 100;
7973
+ this.updateAdjustment('saturation', value);
7974
+ }
7975
+ };
7976
+ ImageEditor.prototype.setOpacity = function (value) {
7977
+ if (!this.disabled && this.imgDataColl.length > 0) {
7978
+ if (this.currObjType.shape === 'freehanddraw') {
7979
+ this.apply();
7980
+ this.upperCanvas.style.cursor = 'default';
7981
+ this.currObjType.shape = '';
7982
+ }
7983
+ this.clearActObj();
7984
+ this.adjustmentLevel.opacity = value;
7985
+ if (value >= 50) {
7986
+ value /= 100;
7987
+ }
7988
+ else if (value === 40) {
7989
+ value = 0.45;
7990
+ }
7991
+ else if (value === 30) {
7992
+ value = 0.40;
7993
+ }
7994
+ else if (value === 20) {
7995
+ value = 0.35;
7996
+ }
7997
+ else if (value === 10) {
7998
+ value = 0.30;
7999
+ }
8000
+ else if (value === 0) {
8001
+ value = 0.25;
8002
+ }
8003
+ this.updateAdjustment('opacity', value);
8004
+ }
8005
+ };
8006
+ ImageEditor.prototype.setBlur = function (value) {
8007
+ if (!this.disabled && this.imgDataColl.length > 0) {
8008
+ if (this.currObjType.shape === 'freehanddraw') {
8009
+ this.apply();
8010
+ this.upperCanvas.style.cursor = 'default';
8011
+ this.currObjType.shape = '';
8012
+ }
8013
+ this.clearActObj();
8014
+ this.adjustmentLevel.blur = value;
8015
+ value /= 20;
8016
+ this.updateAdjustment('blur', value);
8017
+ }
8018
+ };
8019
+ ImageEditor.prototype.setExposure = function (value) {
8020
+ if (!this.disabled && this.imgDataColl.length > 0) {
8021
+ if (this.currObjType.shape === 'freehanddraw') {
8022
+ this.apply();
8023
+ this.upperCanvas.style.cursor = 'default';
8024
+ this.currObjType.shape = '';
8025
+ }
8026
+ this.clearActObj();
8027
+ this.adjustmentLevel.exposure = value;
8028
+ value = this.getFilterValue(value);
8029
+ this.updateAdjustment('exposure', value);
8030
+ }
8031
+ };
8032
+ ImageEditor.prototype.setFilter = function (type) {
8033
+ if (!this.disabled && this.imgDataColl.length > 0) {
8034
+ if (this.currObjType.shape === 'freehanddraw') {
8035
+ this.apply();
8036
+ this.upperCanvas.style.cursor = 'default';
8037
+ this.currObjType.shape = '';
8038
+ }
8039
+ this.clearActObj();
8040
+ this.updateAdjustment(type, null);
8041
+ }
8042
+ };
8043
+ ImageEditor.prototype.setBlackAndWhiteFilter = function (boolean) {
8044
+ if (!this.disabled && this.imgDataColl.length > 0) {
8045
+ if (this.currObjType.shape === 'freehanddraw') {
8046
+ this.apply();
8047
+ this.upperCanvas.style.cursor = 'default';
8048
+ this.currObjType.shape = '';
8049
+ }
8050
+ this.clearActObj();
8051
+ this.adjustmentLevel.bw = boolean;
8052
+ if (boolean) {
8053
+ if (this.degree === 0 && this.currFlipState === '') {
8054
+ this.replaceBWSharpenData('bw');
8055
+ }
8056
+ else if (this.degree !== 0) {
8057
+ var tempDegree = this.degree;
8058
+ this.rotate(-tempDegree);
8059
+ this.replaceBWSharpenData('bw');
8060
+ this.rotate(tempDegree);
8061
+ this.refreshToolbar('filter');
8062
+ }
8063
+ else if (this.currFlipState !== '') {
8064
+ var tempFlipState = this.currFlipState;
8065
+ this.flip(tempFlipState);
8066
+ this.replaceBWSharpenData('bw');
8067
+ this.flip(tempFlipState);
8068
+ this.refreshToolbar('filter');
8069
+ }
8070
+ var data = this.inMemoryContext.getImageData(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
8071
+ var imageData = this.getBlackAndWhiteData(data);
8072
+ this.inMemoryContext.clearRect(0, 0, this.inMemoryCanvas.width, this.inMemoryCanvas.height);
8073
+ this.inMemoryCanvas.width = imageData.width;
8074
+ this.inMemoryCanvas.height = imageData.height;
8075
+ this.inMemoryContext.putImageData(imageData, 0, 0);
8076
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
8077
+ this.lowerContext.filter = this.canvasFilter;
8078
+ var temp = this.lowerContext.filter;
8079
+ this.updateBrightnessFilter();
8080
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
8081
+ this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
8082
+ this.lowerContext.filter = temp;
8083
+ }
8084
+ else {
8085
+ if (this.degree === 0 && this.currFlipState === '') {
8086
+ this.updateBWSharpness();
8087
+ }
8088
+ else if (this.degree !== 0) {
8089
+ var tempDegree = this.degree;
8090
+ this.rotate(-tempDegree);
8091
+ this.updateBWSharpness();
8092
+ this.rotate(tempDegree);
8093
+ this.refreshToolbar('filter');
8094
+ if (this.sharpenedImgData) {
8095
+ this.sharpenedImgData = false;
8096
+ }
8097
+ }
8098
+ else if (this.currFlipState !== '') {
8099
+ var tempFlipState = this.currFlipState;
8100
+ this.flip(tempFlipState);
8101
+ this.updateBWSharpness();
8102
+ this.flip(tempFlipState);
8103
+ this.refreshToolbar('filter');
8104
+ if (this.sharpenedImgData) {
8105
+ this.sharpenedImgData = false;
8106
+ }
8107
+ }
8108
+ }
8109
+ }
8110
+ };
8111
+ ImageEditor.prototype.setSharpness = function (boolean) {
8112
+ if (!this.disabled && this.imgDataColl.length > 0) {
8113
+ if (this.currObjType.shape === 'freehanddraw') {
8114
+ this.apply();
8115
+ this.upperCanvas.style.cursor = 'default';
8116
+ this.currObjType.shape = '';
8117
+ }
8118
+ this.clearActObj();
8119
+ this.adjustmentLevel.sharpen = boolean;
8120
+ if (boolean) {
8121
+ if (this.degree === 0 && this.currFlipState === '') {
8122
+ this.replaceBWSharpenData('sharpen');
8123
+ }
8124
+ else if (this.degree !== 0) {
8125
+ var tempDegree = this.degree;
8126
+ this.rotate(-tempDegree);
8127
+ this.replaceBWSharpenData('sharpen');
8128
+ this.rotate(tempDegree);
8129
+ this.refreshToolbar('filter');
8130
+ }
8131
+ else if (this.currFlipState !== '') {
8132
+ var tempFlipState = this.currFlipState;
8133
+ this.flip(tempFlipState);
8134
+ this.replaceBWSharpenData('sharpen');
8135
+ this.flip(tempFlipState);
8136
+ this.refreshToolbar('filter');
8137
+ }
8138
+ var data = this.inMemoryContext.getImageData(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
8139
+ var imageData = this.getSharpenData(data);
8140
+ this.inMemoryContext.clearRect(0, 0, this.inMemoryCanvas.width, this.inMemoryCanvas.height);
8141
+ this.inMemoryCanvas.width = imageData.width;
8142
+ this.inMemoryCanvas.height = imageData.height;
8143
+ this.inMemoryContext.putImageData(imageData, 0, 0);
8144
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
8145
+ this.lowerContext.filter = this.canvasFilter;
8146
+ var temp = this.lowerContext.filter;
8147
+ this.updateBrightnessFilter();
8148
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
8149
+ this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
8150
+ this.lowerContext.filter = temp;
8151
+ }
8152
+ else {
8153
+ if (this.degree === 0 && this.currFlipState === '') {
8154
+ this.updateBWSharpness();
8155
+ }
8156
+ else if (this.degree !== 0) {
8157
+ var tempDegree = this.degree;
8158
+ this.rotate(-tempDegree);
8159
+ this.updateBWSharpness();
8160
+ this.rotate(tempDegree);
8161
+ this.refreshToolbar('filter');
8162
+ if (this.sharpenedImgData) {
8163
+ this.sharpenedImgData = false;
8164
+ }
6356
8165
  }
6357
- if (this.activeObj.textSettings.fontSize < 20 * (ratio.width + ratio.height)) {
6358
- this.activeObj.textSettings.fontSize = 20 * (ratio.width + ratio.height);
8166
+ else if (this.currFlipState !== '') {
8167
+ var tempFlipState = this.currFlipState;
8168
+ this.flip(tempFlipState);
8169
+ this.updateBWSharpness();
8170
+ this.flip(tempFlipState);
8171
+ this.refreshToolbar('filter');
8172
+ if (this.sharpenedImgData) {
8173
+ this.sharpenedImgData = false;
8174
+ }
6359
8175
  }
6360
8176
  }
6361
- this.activeObj.shapeDegree = this.degree;
6362
- this.activeObj.shapeFlip = this.currFlipState;
6363
- this.activeObj.flipObjColl = [];
6364
- this.updateFontStyles();
6365
- var width = this.upperContext.measureText(this.activeObj.textSettings.text).width +
6366
- this.activeObj.textSettings.fontSize * 0.5;
6367
- var height = this.activeObj.textSettings.fontSize + this.activeObj.textSettings.fontSize * 0.25;
6368
- if (!isNullOrUndefined(x) && !isNullOrUndefined(y)) {
6369
- this.activeObj.activePoint.startX = x;
6370
- this.activeObj.activePoint.startY = y;
6371
- this.activeObj.activePoint.endX = this.activeObj.activePoint.startX + width;
6372
- this.activeObj.activePoint.endY = this.activeObj.activePoint.startY + height;
8177
+ }
8178
+ };
8179
+ ImageEditor.prototype.replaceBWSharpenData = function (type) {
8180
+ this.tempImageData = this.inMemoryContext.getImageData(0, 0, this.inMemoryCanvas.width, this.inMemoryCanvas.height);
8181
+ var imageData = this.inMemoryContext.getImageData(0, 0, this.inMemoryCanvas.width, this.inMemoryCanvas.height);
8182
+ if (type === 'sharpen') {
8183
+ imageData = this.getSharpenData(this.tempImageData);
8184
+ }
8185
+ else {
8186
+ imageData = this.getBlackAndWhiteData(imageData);
8187
+ }
8188
+ this.inMemoryContext.clearRect(0, 0, this.inMemoryCanvas.width, this.inMemoryCanvas.height);
8189
+ this.inMemoryCanvas.width = imageData.width;
8190
+ this.inMemoryCanvas.height = imageData.height;
8191
+ this.inMemoryContext.putImageData(imageData, 0, 0);
8192
+ var tempObj;
8193
+ for (var index = 0; index < this.imgDataColl.length; index++) {
8194
+ if (this.imgDataColl[index].operation !== 'freehanddraw') {
8195
+ tempObj = this.imgDataColl[index];
8196
+ break;
6373
8197
  }
6374
- else {
6375
- this.setCenterPoints(true, width, height);
8198
+ }
8199
+ this.imgDataColl.splice(0, 1, { operation: 'updateCanvas', value: imageData });
8200
+ this.imgDataColl.splice(1, 1, tempObj);
8201
+ this.inMemoryContext.clearRect(0, 0, this.inMemoryCanvas.width, this.inMemoryCanvas.height);
8202
+ this.inMemoryCanvas.width = this.tempImageData.width;
8203
+ this.inMemoryCanvas.height = this.tempImageData.height;
8204
+ this.inMemoryContext.putImageData(this.tempImageData, 0, 0);
8205
+ };
8206
+ ImageEditor.prototype.updateBWSharpness = function () {
8207
+ this.inMemoryContext.clearRect(0, 0, this.inMemoryCanvas.width, this.inMemoryCanvas.height);
8208
+ this.inMemoryCanvas.width = this.tempImageData.width;
8209
+ this.inMemoryCanvas.height = this.tempImageData.height;
8210
+ this.inMemoryContext.putImageData(this.tempImageData, 0, 0);
8211
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
8212
+ this.lowerContext.filter = this.canvasFilter;
8213
+ this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
8214
+ this.imgDataColl.shift();
8215
+ };
8216
+ ImageEditor.prototype.getSharpenData = function (imageData) {
8217
+ var data = imageData.data;
8218
+ var weights = [0, -1, 0, -1, 5, -1, 0, -1, 0];
8219
+ var side = Math.round(Math.sqrt(weights.length));
8220
+ var halfSide = Math.floor(side / 2);
8221
+ var sw = imageData.width;
8222
+ var sh = imageData.height;
8223
+ var output = this.inMemoryContext.createImageData(sw, sh);
8224
+ var dst = output.data;
8225
+ // go through the destination image pixels
8226
+ var alphaFac = 0;
8227
+ var r;
8228
+ var g;
8229
+ var b;
8230
+ var a;
8231
+ var dstOff;
8232
+ var scx;
8233
+ var scy;
8234
+ var srcOff;
8235
+ var wt;
8236
+ var x;
8237
+ var y;
8238
+ var cx;
8239
+ var cy;
8240
+ for (y = 0; y < sh; y++) {
8241
+ for (x = 0; x < sw; x++) {
8242
+ dstOff = (y * sw + x) * 4;
8243
+ r = 0;
8244
+ g = 0;
8245
+ b = 0;
8246
+ a = 0;
8247
+ for (cy = 0; cy < side; cy++) {
8248
+ for (cx = 0; cx < side; cx++) {
8249
+ scy = y + cy - halfSide;
8250
+ scx = x + cx - halfSide;
8251
+ if (scy < 0 || scy >= sh || scx < 0 || scx >= sw) {
8252
+ continue;
8253
+ }
8254
+ srcOff = (scy * sw + scx) * 4;
8255
+ wt = weights[cy * side + cx];
8256
+ r += data[srcOff] * wt;
8257
+ g += data[srcOff + 1] * wt;
8258
+ b += data[srcOff + 2] * wt;
8259
+ if (!alphaFac) {
8260
+ a += data[srcOff + 3] * wt;
8261
+ }
8262
+ }
8263
+ }
8264
+ dst[dstOff] = r;
8265
+ dst[dstOff + 1] = g;
8266
+ dst[dstOff + 2] = b;
8267
+ if (!alphaFac) {
8268
+ dst[dstOff + 3] = a;
8269
+ }
8270
+ else {
8271
+ dst[dstOff + 3] = data[dstOff + 3];
8272
+ }
6376
8273
  }
6377
- this.addLetter(this.activeObj.textSettings.text);
6378
- this.refreshToolbar('text');
6379
8274
  }
8275
+ return output;
6380
8276
  };
6381
- ImageEditor.prototype.drawPen = function (context) {
6382
- var ratio = this.calcRatio();
6383
- context = context ? context : this.upperContext;
6384
- this.upperCanvas.style.display = 'block';
6385
- this.canvasRatio = this.calcRatio();
6386
- if (isNullOrUndefined(this.activeObj.strokeSettings)) {
6387
- this.activeObj.strokeSettings = this.strokeSettings;
8277
+ ImageEditor.prototype.getFilterValue = function (value) {
8278
+ var filterValue;
8279
+ if (value === 0) {
8280
+ filterValue = 1;
6388
8281
  }
6389
- if (isNullOrUndefined(this.activeObj.strokeSettings.strokeWidth)) {
6390
- this.activeObj.strokeSettings.strokeWidth = (ratio.width + ratio.height) * 0.4;
8282
+ else {
8283
+ filterValue = 1 + ((value * 0.5) / 100);
6391
8284
  }
6392
- context.strokeStyle = this.activeObj.strokeSettings.strokeColor;
6393
- context.lineWidth = 2 * (this.activeObj.strokeSettings.strokeWidth) / this.factor;
6394
- context.beginPath();
6395
- context.moveTo(this.prevX, this.prevY);
6396
- context.lineTo(this.currX, this.currY);
6397
- context.stroke();
6398
- context.closePath();
8285
+ return filterValue;
6399
8286
  };
6400
- ImageEditor.prototype.getObjDetails = function (obj) {
6401
- var shapeDetails = {};
6402
- shapeDetails.id = obj.currIndex;
6403
- shapeDetails.type = obj.shape;
6404
- shapeDetails.startX = obj.activePoint.startX;
6405
- shapeDetails.startY = obj.activePoint.startY;
6406
- if (obj.shape === 'rectangle') {
6407
- shapeDetails.width = obj.activePoint.width;
6408
- shapeDetails.height = obj.activePoint.height;
6409
- shapeDetails.strokeColor = obj.strokeSettings.strokeColor;
6410
- shapeDetails.fillColor = obj.strokeSettings.fillColor;
6411
- shapeDetails.strokeWidth = obj.strokeSettings.strokeWidth;
8287
+ ImageEditor.prototype.setFilterValue = function (value) {
8288
+ var filterValue;
8289
+ if (value === 1) {
8290
+ filterValue = 0;
6412
8291
  }
6413
- else if (obj.shape === 'ellipse') {
6414
- shapeDetails.radius = obj.activePoint.width / 2;
6415
- shapeDetails.strokeColor = obj.strokeSettings.strokeColor;
6416
- shapeDetails.fillColor = obj.strokeSettings.fillColor;
6417
- shapeDetails.strokeWidth = obj.strokeSettings.strokeWidth;
8292
+ else {
8293
+ filterValue = ((value - 1) * 100) / 0.5;
6418
8294
  }
6419
- else if (obj.shape === 'line') {
6420
- shapeDetails.length = obj.activePoint.width;
6421
- shapeDetails.strokeColor = obj.strokeSettings.strokeColor;
6422
- shapeDetails.strokeWidth = obj.strokeSettings.strokeWidth;
8295
+ return Math.round(filterValue);
8296
+ };
8297
+ ImageEditor.prototype.getSaturationFilterValue = function (value) {
8298
+ var filterValue;
8299
+ if (value === 0) {
8300
+ filterValue = 1;
6423
8301
  }
6424
- else if (obj.shape === 'text') {
6425
- shapeDetails.text = obj.keyHistory;
6426
- shapeDetails.fontSize = obj.textSettings.fontSize;
6427
- shapeDetails.color = obj.strokeSettings.strokeColor;
6428
- shapeDetails.fontStyle = [];
6429
- if (obj.textSettings.bold) {
6430
- shapeDetails.fontStyle.push('bold');
6431
- }
6432
- if (obj.textSettings.italic) {
6433
- shapeDetails.fontStyle.push('italic');
6434
- }
8302
+ else {
8303
+ filterValue = 1 + (value / 100);
6435
8304
  }
6436
- return shapeDetails;
8305
+ return filterValue;
6437
8306
  };
6438
- ImageEditor.prototype.isPointsInRange = function (x, y) {
6439
- var inRange = false;
6440
- if (this.factor === 1) {
6441
- if (x >= 0 && y >= 0 && x <= this.lowerCanvas.width && y <= this.lowerCanvas.width) {
6442
- inRange = true;
6443
- }
8307
+ ImageEditor.prototype.setSaturationFilterValue = function (value) {
8308
+ var filterValue;
8309
+ if (value === 1) {
8310
+ filterValue = 0;
6444
8311
  }
6445
8312
  else {
6446
- var endPoint = { x: this.lowerCanvas.width - this.pannEnd.startX, y: this.lowerCanvas.height - this.pannEnd.startY };
6447
- if (x >= this.pannStart.startX && y >= this.pannStart.startY && x <= endPoint.x && y <= endPoint.y) {
6448
- inRange = true;
8313
+ filterValue = (value - 1) * 100;
8314
+ }
8315
+ return Math.round(filterValue);
8316
+ };
8317
+ ImageEditor.prototype.getBlackAndWhiteData = function (imageData) {
8318
+ for (var i = 0; i < imageData.data.length; i += 4) {
8319
+ var count = imageData.data[i] + imageData.data[i + 1] + imageData.data[i + 2];
8320
+ var colour = 0;
8321
+ if (count > 383) {
8322
+ colour = 255;
6449
8323
  }
8324
+ imageData.data[i] = colour;
8325
+ imageData.data[i + 1] = colour;
8326
+ imageData.data[i + 2] = colour;
8327
+ imageData.data[i + 3] = 255;
6450
8328
  }
6451
- return inRange;
8329
+ return imageData;
6452
8330
  };
6453
8331
  /**
6454
8332
  * Clear a current selection.
@@ -6486,11 +8364,22 @@ var ImageEditor = /** @class */ (function (_super) {
6486
8364
  // eslint-disable-next-line @typescript-eslint/no-this-alias
6487
8365
  var proxy_2 = this;
6488
8366
  isCrop = true;
8367
+ var canvasFilter = this.canvasFilter;
8368
+ var tempActObj = extend({}, this.activeObj, {}, true);
8369
+ this.lowerContext.filter = this.canvasFilter = 'none';
8370
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
8371
+ this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
8372
+ for (var j = 0; j < this.objColl.length; j++) {
8373
+ this.apply(this.objColl[j].shape, this.objColl[j]);
8374
+ this.refreshActiveObj();
8375
+ }
8376
+ this.activeObj = tempActObj;
6489
8377
  this.upperCanvas.style.display = 'none';
6490
8378
  var widthRatio = void 0;
6491
8379
  var heightRatio = void 0;
6492
8380
  var imgData = void 0;
6493
8381
  var zoomedRotate = false;
8382
+ var factor = this.factor;
6494
8383
  if (this.factor === 1) {
6495
8384
  imgData = this.lowerContext.getImageData(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
6496
8385
  widthRatio = this.lowerCanvas.width / parseInt(this.lowerCanvas.style.maxWidth, 10);
@@ -6525,6 +8414,7 @@ var ImageEditor = /** @class */ (function (_super) {
6525
8414
  this.updateInMemoryContext(imgData);
6526
8415
  }
6527
8416
  this.degree = 0;
8417
+ this.updateBrightnessFilter();
6528
8418
  this.lowerContext.drawImage(this.inMemoryCanvas, tempObj.activePoint.startX, tempObj.activePoint.startY, tempObj.activePoint.width, tempObj.activePoint.height, 0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
6529
8419
  }
6530
8420
  if (this.flipState !== '') {
@@ -6539,6 +8429,7 @@ var ImageEditor = /** @class */ (function (_super) {
6539
8429
  this.lowerCanvas.style.maxHeight = this.upperCanvas.style.maxHeight = maxDimension.height + 'px';
6540
8430
  this.lowerCanvas.width = this.upperCanvas.width = maxDimension.width * widthRatio;
6541
8431
  this.lowerCanvas.height = this.upperCanvas.height = maxDimension.height * heightRatio;
8432
+ this.updateBrightnessFilter();
6542
8433
  this.lowerContext.drawImage(this.inMemoryCanvas, tempObj.activePoint.startX, tempObj.activePoint.startY, tempObj.activePoint.width, tempObj.activePoint.height, 0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
6543
8434
  }
6544
8435
  }
@@ -6559,6 +8450,7 @@ var ImageEditor = /** @class */ (function (_super) {
6559
8450
  ((this.element.clientWidth - parseInt(cssObj.width, 10) - 18) / 2) + 1 + 'px';
6560
8451
  this.lowerCanvas.style.top = this.upperCanvas.style.top = ((this.element.clientHeight - this.toolbarHeight
6561
8452
  - parseInt(cssObj.height, 10)) / 2) + 1 + 'px';
8453
+ this.updateBrightnessFilter();
6562
8454
  this.lowerContext.drawImage(this.inMemoryCanvas, this.activeObj.activePoint.startX, this.activeObj.activePoint.startY, this.activeObj.activePoint.width, this.activeObj.activePoint.height, 0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
6563
8455
  }
6564
8456
  if (this.activeObj.shape === 'crop-circle') {
@@ -6567,6 +8459,7 @@ var ImageEditor = /** @class */ (function (_super) {
6567
8459
  this.inMemoryCanvas.height = imgData_1.height;
6568
8460
  this.inMemoryContext.putImageData(imgData_1, 0, 0);
6569
8461
  this.lowerContext.save();
8462
+ this.updateBrightnessFilter();
6570
8463
  this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0, this.baseImg.width, this.baseImg.height);
6571
8464
  this.lowerContext.globalCompositeOperation = 'destination-in';
6572
8465
  this.lowerContext.beginPath();
@@ -6579,18 +8472,11 @@ var ImageEditor = /** @class */ (function (_super) {
6579
8472
  showSpinner(this.element);
6580
8473
  this.element.style.opacity = '0.5';
6581
8474
  var blobUrl_1;
6582
- var data_1;
6583
8475
  // eslint-disable-next-line @typescript-eslint/tslint/config
6584
8476
  this.lowerCanvas.toBlob(function (blob) {
6585
8477
  blobUrl_1 = URL.createObjectURL(blob);
6586
- proxy_2.isUndoRedo = false;
6587
8478
  proxy_2.baseImg.src = blobUrl_1;
6588
- data_1 = proxy_2.lowerContext.getImageData(0, 0, proxy_2.lowerCanvas.width, proxy_2.lowerCanvas.height);
6589
8479
  proxy_2.imgDataColl = [];
6590
- if (!proxy_2.isUndoRedo) {
6591
- proxy_2.updateUndoRedoColl('crop', data_1, proxy_2.objColl);
6592
- }
6593
- proxy_2.isUndoRedo = false;
6594
8480
  }, 'image/png');
6595
8481
  this.objColl = [];
6596
8482
  this.refreshActiveObj();
@@ -6599,26 +8485,11 @@ var ImageEditor = /** @class */ (function (_super) {
6599
8485
  this.upperContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
6600
8486
  this.lowerContext.globalAlpha = 0;
6601
8487
  this.lowerContext.fillRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
6602
- this.lowerContext.setTransform(1, 0, 0, 1, 0, 0);
6603
- this.upperContext.setTransform(1, 0, 0, 1, 0, 0);
6604
8488
  this.factor = 1;
8489
+ this.canvasFilter = canvasFilter;
6605
8490
  }
6606
8491
  return isCrop;
6607
8492
  };
6608
- ImageEditor.prototype.updateInMemoryContext = function (imgData) {
6609
- this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
6610
- var temp = extend({}, this.activeObj, {}, true);
6611
- for (var i = 0; i < this.objColl.length; i++) {
6612
- this.apply(this.objColl[i].shape, this.objColl[i]);
6613
- }
6614
- this.activeObj = temp;
6615
- imgData = this.lowerContext.getImageData(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
6616
- this.inMemoryContext.clearRect(0, 0, this.inMemoryCanvas.width, this.inMemoryCanvas.height);
6617
- this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
6618
- this.inMemoryCanvas.width = imgData.width;
6619
- this.inMemoryCanvas.height = imgData.height;
6620
- this.inMemoryContext.putImageData(imgData, 0, 0);
6621
- };
6622
8493
  /**
6623
8494
  * Flips an image by horizontally or vertically.
6624
8495
  *
@@ -6635,8 +8506,8 @@ var ImageEditor = /** @class */ (function (_super) {
6635
8506
  }
6636
8507
  var transitionArgs = { direction: direction };
6637
8508
  this.trigger('flipping', transitionArgs);
6638
- this.lastAction = 'flip';
6639
- this.flipMethod = true;
8509
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
8510
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
6640
8511
  var splitWords = [];
6641
8512
  var activeObjShape = void 0;
6642
8513
  if (!isNullOrUndefined(this.activeObj.activePoint)) {
@@ -6657,7 +8528,6 @@ var ImageEditor = /** @class */ (function (_super) {
6657
8528
  this.lowerContext.scale(-1, 1);
6658
8529
  this.upperContext.translate(this.upperContext.canvas.width, 0);
6659
8530
  this.upperContext.scale(-1, 1);
6660
- this.flipDirection = 'horizontal';
6661
8531
  if (this.flipState === '' || this.flipState.toLowerCase() === 'vertical') {
6662
8532
  this.flipState = 'horizontal';
6663
8533
  }
@@ -6673,7 +8543,6 @@ var ImageEditor = /** @class */ (function (_super) {
6673
8543
  this.lowerContext.scale(1, -1);
6674
8544
  this.upperContext.translate(0, this.upperContext.canvas.height);
6675
8545
  this.upperContext.scale(1, -1);
6676
- this.flipDirection = 'vertical';
6677
8546
  if (this.flipState.toLowerCase() === '' || this.flipState.toLowerCase() === 'horizontal') {
6678
8547
  this.flipState = 'vertical';
6679
8548
  }
@@ -6684,13 +8553,25 @@ var ImageEditor = /** @class */ (function (_super) {
6684
8553
  this.currFlipState = 'vertical';
6685
8554
  }
6686
8555
  }
8556
+ var temp = this.lowerContext.filter;
8557
+ this.updateBrightnessFilter();
8558
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
6687
8559
  this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
8560
+ this.lowerContext.filter = temp;
6688
8561
  this.currImgData = this.lowerContext.getImageData(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
8562
+ this.lowerContext.filter = this.canvasFilter;
8563
+ this.updateBrightnessFilter();
8564
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
8565
+ this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
8566
+ this.lowerContext.filter = temp;
6689
8567
  this.inMemoryContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
6690
8568
  this.inMemoryCanvas.width = this.currImgData.width;
6691
8569
  this.inMemoryCanvas.height = this.currImgData.height;
6692
8570
  this.inMemoryContext.putImageData(this.currImgData, 0, 0);
6693
8571
  if (this.flipState.toLowerCase() === 'horizontal') {
8572
+ var tempFilter = this.lowerContext.filter;
8573
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
8574
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
6694
8575
  for (var i = 0, len = this.objColl.length; i < len; i++) {
6695
8576
  this.objColl[i].flippedText = false;
6696
8577
  if (this.objColl[i].shapeFlip !== '' && this.objColl[i].shapeFlip === this.currFlipState) {
@@ -6700,13 +8581,16 @@ var ImageEditor = /** @class */ (function (_super) {
6700
8581
  this.apply(this.objColl[i].shape, this.objColl[i]);
6701
8582
  }
6702
8583
  }
8584
+ this.lowerContext.filter = tempFilter;
6703
8585
  this.lowerContext.translate(this.lowerContext.canvas.width, 0);
6704
8586
  this.lowerContext.scale(-1, 1);
6705
8587
  this.upperContext.translate(this.upperContext.canvas.width, 0);
6706
8588
  this.upperContext.scale(-1, 1);
6707
- this.flipDirection = '';
6708
8589
  }
6709
8590
  else if (this.flipState.toLowerCase() === 'vertical') {
8591
+ var tempFilter = this.lowerContext.filter;
8592
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
8593
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
6710
8594
  for (var i = 0, len = this.objColl.length; i < len; i++) {
6711
8595
  this.objColl[i].flippedText = false;
6712
8596
  if (this.objColl[i].shapeFlip !== '' && this.objColl[i].shapeFlip === this.currFlipState) {
@@ -6716,11 +8600,11 @@ var ImageEditor = /** @class */ (function (_super) {
6716
8600
  this.apply(this.objColl[i].shape, this.objColl[i]);
6717
8601
  }
6718
8602
  }
8603
+ this.lowerContext.filter = tempFilter;
6719
8604
  this.lowerContext.translate(0, this.lowerContext.canvas.height);
6720
8605
  this.lowerContext.scale(1, -1);
6721
8606
  this.upperContext.translate(0, this.upperContext.canvas.height);
6722
8607
  this.upperContext.scale(1, -1);
6723
- this.flipDirection = '';
6724
8608
  }
6725
8609
  for (var i = 0, len = this.objColl.length; i < len; i++) {
6726
8610
  if (this.objColl[i].flipObjColl.length === 0) {
@@ -6735,15 +8619,15 @@ var ImageEditor = /** @class */ (function (_super) {
6735
8619
  }
6736
8620
  this.redrawObj(direction.toLowerCase());
6737
8621
  if (this.flipState === '') {
8622
+ var tempFilter = this.lowerContext.filter;
8623
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
8624
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
6738
8625
  for (var i = 0, len = this.objColl.length; i < len; i++) {
6739
8626
  this.apply(this.objColl[i].shape, this.objColl[i]);
6740
8627
  }
8628
+ this.lowerContext.filter = tempFilter;
6741
8629
  }
6742
8630
  this.refreshActiveObj();
6743
- if (!this.isUndoRedo) {
6744
- this.updateUndoRedoColl('flip', direction, this.objColl);
6745
- }
6746
- this.isUndoRedo = this.flipMethod = false;
6747
8631
  if (!isNullOrUndefined(activeObjShape)) {
6748
8632
  if (activeObjShape === 'custom') {
6749
8633
  this.activeObj.activePoint = { startX: 0, startY: 0, endX: this.lowerCanvas.width,
@@ -6755,6 +8639,7 @@ var ImageEditor = /** @class */ (function (_super) {
6755
8639
  this.select(activeObjShape);
6756
8640
  }
6757
8641
  }
8642
+ this.refreshToolbar('main');
6758
8643
  }
6759
8644
  };
6760
8645
  /**
@@ -6775,11 +8660,13 @@ var ImageEditor = /** @class */ (function (_super) {
6775
8660
  */
6776
8661
  ImageEditor.prototype.open = function (data) {
6777
8662
  if (!this.disabled) {
8663
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
8664
+ var proxy_3 = this;
6778
8665
  showSpinner(this.element);
6779
8666
  this.element.style.opacity = '0.5';
6780
- var toolbar_10 = document.querySelector('#' + this.element.id + '_currPos');
6781
- if (toolbar_10) {
6782
- toolbar_10.style.display = 'none';
8667
+ var toolbar_11 = document.querySelector('#' + this.element.id + '_currPos');
8668
+ if (toolbar_11) {
8669
+ toolbar_11.style.display = 'none';
6783
8670
  }
6784
8671
  if (this.defToolbarItems.length === 0 &&
6785
8672
  (isNullOrUndefined(document.getElementById(this.element.id + '_toolbar')))) {
@@ -6788,11 +8675,16 @@ var ImageEditor = /** @class */ (function (_super) {
6788
8675
  if (isNullOrUndefined(this.toolbarTemplate)) {
6789
8676
  this.update();
6790
8677
  }
8678
+ this.degree = 0;
8679
+ this.flipState = '';
8680
+ this.factor = 1;
8681
+ this.imgDataColl = [];
6791
8682
  var type = typeof (data);
6792
8683
  if (type === 'string') {
6793
8684
  this.imageOnLoad(data);
6794
8685
  }
6795
8686
  else {
8687
+ var tempFilter = this.lowerContext.filter;
6796
8688
  this.lowerCanvas = document.querySelector('#' + this.element.id + '_lowerCanvas');
6797
8689
  this.upperCanvas = document.querySelector('#' + this.element.id + '_upperCanvas');
6798
8690
  this.lowerContext = this.lowerCanvas.getContext('2d');
@@ -6806,10 +8698,19 @@ var ImageEditor = /** @class */ (function (_super) {
6806
8698
  this.imgDataColl.push({ operation: 'open', value: data });
6807
8699
  this.lowerCanvas.width = this.upperCanvas.width = data.width;
6808
8700
  this.lowerCanvas.height = this.upperCanvas.height = data.height;
8701
+ this.lowerContext.filter = tempFilter;
8702
+ var temp = this.lowerContext.filter;
8703
+ this.updateBrightnessFilter();
6809
8704
  this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
6810
- this.updateCanvas();
8705
+ this.lowerContext.filter = temp;
8706
+ this.redrawImg(this.lowerContext.filter);
6811
8707
  hideSpinner(this.element);
6812
8708
  this.element.style.opacity = '1';
8709
+ // eslint-disable-next-line @typescript-eslint/tslint/config
8710
+ this.lowerCanvas.toBlob(function (blob) {
8711
+ showSpinner(proxy_3.element);
8712
+ proxy_3.baseImg.src = URL.createObjectURL(blob);
8713
+ }, 'image/png');
6813
8714
  }
6814
8715
  }
6815
8716
  };
@@ -6826,6 +8727,8 @@ var ImageEditor = /** @class */ (function (_super) {
6826
8727
  this.lowerContext.clearRect(0, 0, this.inMemoryCanvas.height, this.inMemoryCanvas.width);
6827
8728
  this.upperContext.clearRect(0, 0, this.inMemoryCanvas.width, this.inMemoryCanvas.height);
6828
8729
  this.upperContext.clearRect(0, 0, this.inMemoryCanvas.height, this.inMemoryCanvas.width);
8730
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
8731
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
6829
8732
  showSpinner(this.element);
6830
8733
  this.element.style.opacity = '0.5';
6831
8734
  if (this.imgDataColl.length > 0) {
@@ -6836,11 +8739,13 @@ var ImageEditor = /** @class */ (function (_super) {
6836
8739
  this.inMemoryCanvas.width = this.imgDataColl[0].value.width;
6837
8740
  this.inMemoryCanvas.height = this.imgDataColl[0].value.height;
6838
8741
  this.inMemoryContext.putImageData(this.imgDataColl[0].value, 0, 0);
6839
- this.redrawImg();
8742
+ this.redrawImg(this.lowerContext.filter);
8743
+ this.lowerCanvas.width = this.baseImg.width;
8744
+ this.lowerCanvas.height = this.baseImg.height;
6840
8745
  }
6841
8746
  this.lowerContext.setTransform(1, 0, 0, 1, 0, 0);
6842
8747
  this.upperContext.setTransform(1, 0, 0, 1, 0, 0);
6843
- this.baseImg.src = this.baseImgSrc;
8748
+ this.baseImg.src = this.baseImgSrc.id;
6844
8749
  this.factor = 1;
6845
8750
  this.refreshToolbar('main');
6846
8751
  if (Browser.isDevice && document.getElementById(this.element.id + '_bottomToolbar')) {
@@ -6849,22 +8754,20 @@ var ImageEditor = /** @class */ (function (_super) {
6849
8754
  this.objColl = [];
6850
8755
  this.imgDataColl = [];
6851
8756
  this.degree = 0;
6852
- this.flipState = this.keyHistory = this.currFlipState = this.flipDirection = '';
8757
+ this.flipState = this.keyHistory = this.currFlipState = '';
6853
8758
  this.upperCanvas.style.display = 'none';
8759
+ this.togglePan = this.togglePen = false;
6854
8760
  this.upperCanvas.style.cursor = this.lowerCanvas.style.cursor = 'default';
6855
- this.undoRedoColl = [];
6856
- this.dragCanvas = this.dragged = this.isUndoRedo = this.activeObj.flippedText = this.flipMethod = false;
8761
+ this.dragCanvas = this.activeObj.flippedText = false;
6857
8762
  this.currImgData = {};
6858
8763
  this.pannStart = { startX: 0, startY: 0, width: 0, height: 0 };
6859
8764
  this.pannEnd = { startX: 0, startY: 0, width: 0, height: 0 };
6860
8765
  this.lowerContext.lineWidth = this.upperContext.lineWidth = undefined;
6861
- this.togglePan = this.togglePen = this.rotateMethod = false;
6862
8766
  this.lastX = this.lastY = 0;
6863
8767
  this.dragStart = { x: 0, y: 0 };
6864
8768
  this.touchEndPoint = {};
6865
8769
  this.prevX = this.currX = this.prevY = this.currY = 0;
6866
- this.lastAction = this.tempKeyHistory = '';
6867
- this.isBoldbtn = this.isItalicbtn = false;
8770
+ this.tempKeyHistory = '';
6868
8771
  this.currentToolbar = 'main';
6869
8772
  this.textStartPoints = { x: 0, y: 0 };
6870
8773
  this.fontSizeColl = this.penDrawColl = [];
@@ -6874,14 +8777,24 @@ var ImageEditor = /** @class */ (function (_super) {
6874
8777
  this.textSettings =
6875
8778
  { text: 'Enter Text', fontFamily: 'Arial', fontSize: null, bold: false, italic: false, underline: false };
6876
8779
  this.tempStrokeSettings = { strokeColor: '#fff', fillColor: '', strokeWidth: null };
6877
- this.penStrokeWidth = undefined;
6878
8780
  this.tempTextSettings =
6879
8781
  { text: 'Enter Text', fontFamily: 'Arial', fontSize: null, bold: false, italic: false, underline: false };
6880
8782
  this.refreshActiveObj();
6881
8783
  this.timer = undefined;
8784
+ this.penStrokeWidth = undefined;
6882
8785
  this.isScreenOriented = false;
8786
+ this.tempObjColl = [];
8787
+ this.tempObjColl = undefined;
8788
+ this.adjustmentLevel = { brightness: 0, contrast: 0, hue: 0, opacity: 100, saturation: 0, blur: 0, exposure: 0, sharpen: false, bw: false };
8789
+ this.tempAdjustmentLevel = { brightness: 0, contrast: 0, hue: 0, opacity: 100, saturation: 0, blur: 0, exposure: 0, sharpen: false, bw: false };
8790
+ this.canvasFilter = this.currentFilter = this.tempAdjustmentValue = '';
8791
+ this.lowerContext.filter = this.initialAdjustmentValue = this.adjustmentValue = 'brightness(' + 1 + ') ' + 'contrast(' + 100
8792
+ + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
8793
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
8794
+ this.tempImageData = undefined;
8795
+ this.sharpenedImgData = this.isBrightnessAdjusted = this.isInitialLoading = false;
6883
8796
  this.currObjType = { shape: '', isDragging: false, isActiveObj: false, isText: false, isInitialText: false, isLine: false,
6884
- isInitialLine: false, isCustomCrop: false, isZoomed: false };
8797
+ isInitialLine: false, isCustomCrop: false, isZoomed: false, isFiltered: false, isSave: false };
6885
8798
  }
6886
8799
  };
6887
8800
  /**
@@ -6898,8 +8811,6 @@ var ImageEditor = /** @class */ (function (_super) {
6898
8811
  isRotate = true;
6899
8812
  var transitionArgs = { degree: degree };
6900
8813
  this.trigger('rotating', transitionArgs);
6901
- this.rotateMethod = true;
6902
- this.lastAction = 'rotate';
6903
8814
  var splitWords = [];
6904
8815
  var activeObjShape = void 0;
6905
8816
  if (!isNullOrUndefined(this.activeObj.activePoint)) {
@@ -6917,29 +8828,44 @@ var ImageEditor = /** @class */ (function (_super) {
6917
8828
  this.factor = 1;
6918
8829
  this.refreshToolbar('main');
6919
8830
  }
6920
- this.degree += degree;
6921
- if (this.degree === 360) {
6922
- this.degree = 0;
8831
+ var length_1 = Math.abs(degree / 90);
8832
+ if (length_1 > 1) {
8833
+ this.rotateMultiple(length_1, degree);
8834
+ }
8835
+ else {
8836
+ this.degree += degree;
8837
+ if (this.degree === 360) {
8838
+ this.degree = 0;
8839
+ }
8840
+ var temp = this.lowerContext.filter;
8841
+ this.lowerContext.save();
8842
+ this.setMaximumDimension(this.degree);
8843
+ this.lowerContext.translate(this.lowerCanvas.width / 2, this.lowerCanvas.height / 2);
8844
+ this.lowerContext.rotate(Math.PI / 180 * degree);
8845
+ this.lowerCanvas.style.left = this.upperCanvas.style.left = (this.element.clientWidth - parseInt(this.lowerCanvas.style.maxWidth, 10) - 18) / 2 + 1 + 'px';
8846
+ this.lowerCanvas.style.top = this.upperCanvas.style.top = (this.element.clientHeight - this.toolbarHeight - parseInt(this.lowerCanvas.style.maxHeight, 10)) / 2 + 1 + 'px';
8847
+ this.updateBrightnessFilter();
8848
+ this.lowerContext.drawImage(this.inMemoryCanvas, -this.lowerCanvas.height / 2, -this.lowerCanvas.width / 2);
8849
+ this.lowerContext.filter = temp;
8850
+ this.lowerContext.rotate(Math.PI / 180 * -degree);
8851
+ this.lowerContext.translate(-this.lowerCanvas.width / 2, -this.lowerCanvas.height / 2);
8852
+ this.lowerContext.restore();
8853
+ this.currImgData = this.lowerContext.getImageData(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
8854
+ this.inMemoryContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
8855
+ this.inMemoryCanvas.width = this.currImgData.width;
8856
+ this.inMemoryCanvas.height = this.currImgData.height;
8857
+ this.inMemoryContext.putImageData(this.currImgData, 0, 0);
8858
+ this.lowerContext.filter = this.canvasFilter;
8859
+ this.updateBrightnessFilter();
8860
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
8861
+ this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
8862
+ this.lowerContext.filter = temp;
8863
+ this.redrawObj(degree);
6923
8864
  }
6924
- this.lowerContext.save();
6925
- this.setMaximumDimension(this.degree);
6926
- this.lowerContext.translate(this.lowerCanvas.width / 2, this.lowerCanvas.height / 2);
6927
- this.lowerContext.rotate(Math.PI / 180 * degree);
6928
- this.lowerCanvas.style.left = this.upperCanvas.style.left = (this.element.clientWidth - parseInt(this.lowerCanvas.style.maxWidth, 10) - 18) / 2 + 1 + 'px';
6929
- this.lowerCanvas.style.top = this.upperCanvas.style.top = (this.element.clientHeight - this.toolbarHeight - parseInt(this.lowerCanvas.style.maxHeight, 10)) / 2 + 1 + 'px';
6930
- this.lowerContext.drawImage(this.inMemoryCanvas, -this.lowerCanvas.height / 2, -this.lowerCanvas.width / 2);
6931
- this.lowerContext.rotate(Math.PI / 180 * -degree);
6932
- this.lowerContext.translate(-this.lowerCanvas.width / 2, -this.lowerCanvas.height / 2);
6933
- this.lowerContext.restore();
6934
- this.currImgData = this.lowerContext.getImageData(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
6935
- this.inMemoryContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
6936
- this.inMemoryCanvas.width = this.currImgData.width;
6937
- this.inMemoryCanvas.height = this.currImgData.height;
6938
- this.inMemoryContext.putImageData(this.currImgData, 0, 0);
6939
- this.redrawObj(degree);
6940
8865
  if (!isNullOrUndefined(activeObjShape)) {
6941
8866
  if (activeObjShape === 'custom') {
6942
- var endPoint = { x: this.lowerCanvas.width - this.pannEnd.startX, y: this.lowerCanvas.height - this.pannEnd.startY };
8867
+ var endPoint = { x: this.lowerCanvas.width - this.pannEnd.startX, y: this.lowerCanvas.height -
8868
+ this.pannEnd.startY };
6943
8869
  this.activeObj.activePoint = { startX: this.pannStart.startX, startY: this.pannStart.startY, endX: endPoint.x,
6944
8870
  endY: endPoint.y, width: endPoint.x - this.pannStart.startX, height: endPoint.y - this.pannStart.startY };
6945
8871
  this.updateActiveObject(this.calcRatio(), this.activeObj.activePoint, this.activeObj);
@@ -6951,12 +8877,8 @@ var ImageEditor = /** @class */ (function (_super) {
6951
8877
  this.refreshToolbar('main', true, true);
6952
8878
  }
6953
8879
  this.factor = 1;
6954
- if (!this.isUndoRedo) {
6955
- this.updateUndoRedoColl('rotate', degree, this.objColl);
6956
- }
6957
- this.isUndoRedo = false;
8880
+ this.refreshToolbar('main');
6958
8881
  }
6959
- this.rotateMethod = false;
6960
8882
  return isRotate;
6961
8883
  };
6962
8884
  /**
@@ -6975,24 +8897,22 @@ var ImageEditor = /** @class */ (function (_super) {
6975
8897
  this.applyPenDraw();
6976
8898
  }
6977
8899
  this.applyActObj();
8900
+ this.lowerContext.filter = this.canvasFilter;
6978
8901
  if (this.factor !== 1) {
6979
8902
  this.lowerContext.setTransform(1, 0, 0, 1, 0, 0);
6980
8903
  this.upperContext.setTransform(1, 0, 0, 1, 0, 0);
6981
8904
  this.factor = 1;
6982
8905
  this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
6983
8906
  this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
6984
- this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
6985
- for (var i = 0; i < this.objColl.length; i++) {
6986
- this.apply(this.objColl[i].shape, this.objColl[i]);
6987
- this.refreshActiveObj();
6988
- }
8907
+ this.redrawImgWithObj();
6989
8908
  }
6990
8909
  type = type ? type : 'Png';
6991
8910
  this.redrawActObj();
6992
- var beforeSave = { cancel: false, fileName: 'ImageEditor', fileType: type };
6993
- var saved_1 = { fileName: 'ImageEditor', fileType: type };
8911
+ var beforeSave = { cancel: false, fileName: fileName ? fileName : 'ImageEditor', fileType: type };
8912
+ var saved_1 = { fileName: fileName ? fileName : 'ImageEditor', fileType: type };
6994
8913
  this.trigger('beforeSave', beforeSave, function (observableSaveArgs) {
6995
8914
  if (!observableSaveArgs.cancel) {
8915
+ _this.currObjType.isSave = true;
6996
8916
  fileName = observableSaveArgs.fileName ? observableSaveArgs.fileName : fileName;
6997
8917
  if (type.toLowerCase() === 'svg') {
6998
8918
  fileName = fileName || 'ImageEditor';
@@ -7053,7 +8973,8 @@ var ImageEditor = /** @class */ (function (_super) {
7053
8973
  this.upperCanvas.style.cursor = 'crosshair';
7054
8974
  if (Browser.isDevice) {
7055
8975
  var arcRadius = (7.5 * (ratio.width > ratio.height ? ratio.width : ratio.height)) / this.factor;
7056
- var endPoint = { x: this.lowerCanvas.width - this.pannEnd.startX, y: this.lowerCanvas.height - this.pannEnd.startY };
8976
+ var endPoint = { x: this.lowerCanvas.width - this.pannEnd.startX, y: this.lowerCanvas.height -
8977
+ this.pannEnd.startY };
7057
8978
  this.activeObj.activePoint = { startX: this.pannStart.startX + arcRadius, startY: this.pannStart.startY + arcRadius,
7058
8979
  endX: endPoint.x - arcRadius, endY: endPoint.y - arcRadius };
7059
8980
  this.activeObj.activePoint.width = this.activeObj.activePoint.endX - this.activeObj.activePoint.startX;
@@ -7100,12 +9021,13 @@ var ImageEditor = /** @class */ (function (_super) {
7100
9021
  *
7101
9022
  * @param {boolean} value - Specifies a value whether enable or disable freehand drawing.
7102
9023
  *
7103
- * @returns {void}.
9024
+ * @returns {void}.
9025
+ * @private
7104
9026
  */
7105
9027
  ImageEditor.prototype.freeHandDraw = function (value) {
7106
9028
  if (value) {
7107
9029
  this.togglePen = true;
7108
- this.upperCanvas.style.cursor = 'cross-hair';
9030
+ this.upperCanvas.style.cursor = 'crosshair';
7109
9031
  this.drawPen();
7110
9032
  }
7111
9033
  else {
@@ -7114,6 +9036,16 @@ var ImageEditor = /** @class */ (function (_super) {
7114
9036
  }
7115
9037
  this.refreshToolbar('pen');
7116
9038
  };
9039
+ /**
9040
+ * Enable or disable a freehand drawing in an Image Editor.
9041
+ *
9042
+ * @param {boolean} value - Specifies a value whether enable or disable freehand drawing.
9043
+ *
9044
+ * @returns {void}.
9045
+ */
9046
+ ImageEditor.prototype.freehandDraw = function (value) {
9047
+ this.freeHandDraw(value);
9048
+ };
7117
9049
  /**
7118
9050
  * Enable or disable a panning on the Image Editor.
7119
9051
  *
@@ -7160,17 +9092,8 @@ var ImageEditor = /** @class */ (function (_super) {
7160
9092
  this.redrawActObj();
7161
9093
  this.refreshActiveObj();
7162
9094
  this.upperContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
9095
+ this.lowerContext.filter = this.canvasFilter;
7163
9096
  this.upperCanvas.style.cursor = 'default';
7164
- var zoomState = void 0;
7165
- if (value === 3.75 || value === 1) {
7166
- zoomState = 0.1;
7167
- }
7168
- else if (value === -3.75) {
7169
- zoomState = -0.1;
7170
- }
7171
- else {
7172
- zoomState = value;
7173
- }
7174
9097
  if (this.degree !== 0) {
7175
9098
  this.inMemoryContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
7176
9099
  this.inMemoryContext.clearRect(0, 0, this.lowerCanvas.height, this.lowerCanvas.width);
@@ -7182,16 +9105,22 @@ var ImageEditor = /** @class */ (function (_super) {
7182
9105
  this.lastX = this.lowerCanvas.width / 2;
7183
9106
  this.lastY = this.lowerCanvas.height / 2;
7184
9107
  }
7185
- if (value > 0) {
7186
- this.zoomImg(3.75);
9108
+ if (value === 1.1 || value === -1.1) {
9109
+ this.zoomImg(value);
7187
9110
  }
7188
9111
  else {
7189
- this.zoomImg(-3.75);
9112
+ if (value > 0) {
9113
+ this.zoomImg(3.75);
9114
+ }
9115
+ else {
9116
+ this.zoomImg(-3.75);
9117
+ }
7190
9118
  }
7191
9119
  this.refreshActiveObj();
7192
9120
  if (!isNullOrUndefined(activeObjShape)) {
7193
9121
  if (activeObjShape === 'custom') {
7194
- var endPoint = { x: this.lowerCanvas.width - this.pannEnd.startX, y: this.lowerCanvas.height - this.pannEnd.startY };
9122
+ var endPoint = { x: this.lowerCanvas.width - this.pannEnd.startX, y: this.lowerCanvas.height -
9123
+ this.pannEnd.startY };
7195
9124
  this.activeObj.activePoint = { startX: this.pannStart.startX, startY: this.pannStart.startY, endX: endPoint.x,
7196
9125
  endY: endPoint.y, width: endPoint.x - this.pannStart.startX, height: endPoint.y - this.pannStart.startY };
7197
9126
  this.updateActiveObject(this.calcRatio(), this.activeObj.activePoint, this.activeObj);
@@ -7202,10 +9131,6 @@ var ImageEditor = /** @class */ (function (_super) {
7202
9131
  }
7203
9132
  this.refreshToolbar('main', true, true);
7204
9133
  }
7205
- if (!this.isUndoRedo) {
7206
- this.updateUndoRedoColl('zoom', zoomState, this.objColl);
7207
- }
7208
- this.isUndoRedo = false;
7209
9134
  var zoomOut = document.querySelector('#' + this.element.id + '_zoomOut');
7210
9135
  if (!isNullOrUndefined(zoomOut) && this.factor === 1) {
7211
9136
  zoomOut.classList.add('e-disabled');
@@ -7213,6 +9138,23 @@ var ImageEditor = /** @class */ (function (_super) {
7213
9138
  else if (!isNullOrUndefined(zoomOut)) {
7214
9139
  zoomOut.classList.remove('e-disabled');
7215
9140
  }
9141
+ if (!this.togglePan) {
9142
+ this.callMainToolbar(false, true);
9143
+ }
9144
+ this.autoEnablePan();
9145
+ if (isNullOrUndefined(this.activeObj.activePoint) || this.activeObj.activePoint.width === 0) {
9146
+ this.refreshToolbar('main');
9147
+ }
9148
+ else {
9149
+ this.refreshToolbar('main', true, true);
9150
+ }
9151
+ var panBtn = this.element.querySelector('.e-img-pan .e-btn');
9152
+ if (!isNullOrUndefined(panBtn) && this.togglePan) {
9153
+ panBtn.classList.add('e-selected-btn');
9154
+ }
9155
+ else if (!isNullOrUndefined(panBtn)) {
9156
+ panBtn.classList.remove('e-selected-btn');
9157
+ }
7216
9158
  }
7217
9159
  };
7218
9160
  /**
@@ -7393,8 +9335,17 @@ var ImageEditor = /** @class */ (function (_super) {
7393
9335
  else {
7394
9336
  isSelected = true;
7395
9337
  this.activeObj = obj;
9338
+ this.lowerContext.filter = this.canvasFilter;
7396
9339
  this.redrawShape(this.activeObj);
7397
- this.refreshToolbar('shapes');
9340
+ if (this.activeObj.shape === 'text') {
9341
+ this.refreshToolbar('text');
9342
+ }
9343
+ else if (this.activeObj.shape === 'pen') {
9344
+ this.refreshToolbar('pen');
9345
+ }
9346
+ else {
9347
+ this.refreshToolbar('shapes');
9348
+ }
7398
9349
  this.updateToolbarItems(this.calcRatio());
7399
9350
  }
7400
9351
  return isSelected;
@@ -7426,12 +9377,9 @@ var ImageEditor = /** @class */ (function (_super) {
7426
9377
  break;
7427
9378
  }
7428
9379
  }
9380
+ this.lowerContext.filter = this.canvasFilter;
7429
9381
  this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
7430
- this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
7431
- for (var i = 0; i < this.objColl.length; i++) {
7432
- this.apply(this.objColl[i].shape, this.objColl[i]);
7433
- this.refreshActiveObj();
7434
- }
9382
+ this.redrawImgWithObj();
7435
9383
  this.refreshToolbar('main');
7436
9384
  };
7437
9385
  /**
@@ -7496,9 +9444,60 @@ var ImageEditor = /** @class */ (function (_super) {
7496
9444
  canvasWrapper.style.height = this.element.offsetHeight - this.toolbarHeight - 1 + 'px';
7497
9445
  this.lowerCanvas.height = this.upperCanvas.height = this.element.offsetHeight - this.toolbarHeight - 1;
7498
9446
  }
9447
+ this.lowerContext.filter = this.canvasFilter;
7499
9448
  this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
7500
9449
  this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
7501
9450
  };
9451
+ /**
9452
+ * To apply the filters to an image
9453
+ *
9454
+ * @param {ImageFilterOptions } filterOption - Specifies the filter options to the image.
9455
+ * @returns {void}.
9456
+ */
9457
+ ImageEditor.prototype.applyImageFilter = function (filterOption) {
9458
+ if (this.initialAdjustmentValue === '') {
9459
+ this.initialAdjustmentValue = 'brightness(1) contrast(100%) hue-rotate(0deg) saturate(100%) opacity(1) blur(0px) sepia(0%) grayscale(0%) invert(0%)';
9460
+ }
9461
+ this.lowerContext.filter = this.initialAdjustmentValue;
9462
+ this.setFilter(filterOption.toString());
9463
+ };
9464
+ /**
9465
+ * To apply the filters to an image
9466
+ *
9467
+ * @param {ImageFinetuneOptions } finetuneOption - Specifies the finetune options to the image.
9468
+ * @param {number } value - Specifies the value for finetuning the image.
9469
+ * @returns {void}.
9470
+ *
9471
+ */
9472
+ ImageEditor.prototype.finetuneImage = function (finetuneOption, value) {
9473
+ if (this.initialAdjustmentValue === '') {
9474
+ this.initialAdjustmentValue = 'brightness(1) contrast(100%) hue-rotate(0deg) saturate(100%) opacity(1) blur(0px) sepia(0%) grayscale(0%) invert(0%)';
9475
+ }
9476
+ this.lowerContext.filter = this.initialAdjustmentValue;
9477
+ switch (finetuneOption) {
9478
+ case 'Brightness':
9479
+ this.setBrightness(value);
9480
+ break;
9481
+ case 'Contrast':
9482
+ this.setContrast(value);
9483
+ break;
9484
+ case 'Hue':
9485
+ this.setHue(value);
9486
+ break;
9487
+ case 'Saturation':
9488
+ this.setSaturation(value);
9489
+ break;
9490
+ case 'Opacity':
9491
+ this.setOpacity(value);
9492
+ break;
9493
+ case 'Blur':
9494
+ this.setBlur(value);
9495
+ break;
9496
+ case 'Exposure':
9497
+ this.setExposure(value);
9498
+ break;
9499
+ }
9500
+ };
7502
9501
  /**
7503
9502
  * To check whether the undo collection is empty or not.
7504
9503
  *
@@ -7506,7 +9505,7 @@ var ImageEditor = /** @class */ (function (_super) {
7506
9505
  * @private
7507
9506
  */
7508
9507
  ImageEditor.prototype.canUndo = function () {
7509
- return _super.prototype.canUndo.call(this);
9508
+ return false;
7510
9509
  };
7511
9510
  /**
7512
9511
  * To check whether the redo collection is empty or not.
@@ -7515,7 +9514,7 @@ var ImageEditor = /** @class */ (function (_super) {
7515
9514
  * @private
7516
9515
  */
7517
9516
  ImageEditor.prototype.canRedo = function () {
7518
- return _super.prototype.canRedo.call(this);
9517
+ return false;
7519
9518
  };
7520
9519
  /**
7521
9520
  * Erases all the signature strokes signed by user.
@@ -7524,7 +9523,9 @@ var ImageEditor = /** @class */ (function (_super) {
7524
9523
  * @private
7525
9524
  */
7526
9525
  ImageEditor.prototype.clear = function () {
7527
- _super.prototype.clear.call(this);
9526
+ if (this.getModuleName() !== 'image-editor') {
9527
+ _super.prototype.clear.call(this);
9528
+ }
7528
9529
  };
7529
9530
  /**
7530
9531
  * To draw the signature based on the given text, with the font family and font size.
@@ -7537,7 +9538,9 @@ var ImageEditor = /** @class */ (function (_super) {
7537
9538
  * @private
7538
9539
  */
7539
9540
  ImageEditor.prototype.draw = function (text, fontFamily, fontSize) {
7540
- _super.prototype.draw.call(this, text, fontFamily, fontSize);
9541
+ if (this.getModuleName() !== 'image-editor') {
9542
+ _super.prototype.draw.call(this, text, fontFamily, fontSize);
9543
+ }
7541
9544
  };
7542
9545
  /**
7543
9546
  * To get the signature as Blob.
@@ -7547,7 +9550,8 @@ var ImageEditor = /** @class */ (function (_super) {
7547
9550
  * @private
7548
9551
  */
7549
9552
  ImageEditor.prototype.getBlob = function (url) {
7550
- return _super.prototype.getBlob.call(this, url);
9553
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
9554
+ return url;
7551
9555
  };
7552
9556
  /**
7553
9557
  * To check whether the signature is empty or not.
@@ -7556,7 +9560,7 @@ var ImageEditor = /** @class */ (function (_super) {
7556
9560
  * @private
7557
9561
  */
7558
9562
  ImageEditor.prototype.isEmpty = function () {
7559
- return _super.prototype.isEmpty.call(this);
9563
+ return false;
7560
9564
  };
7561
9565
  /**
7562
9566
  * To load the signature with the given base 64 string, height and width.
@@ -7568,7 +9572,9 @@ var ImageEditor = /** @class */ (function (_super) {
7568
9572
  * @private
7569
9573
  */
7570
9574
  ImageEditor.prototype.load = function (signature, width, height) {
7571
- _super.prototype.load.call(this, signature, width, height);
9575
+ if (this.getModuleName() !== 'image-editor') {
9576
+ _super.prototype.load.call(this, signature, width, height);
9577
+ }
7572
9578
  };
7573
9579
  /**
7574
9580
  * Undo the last user action.
@@ -7577,7 +9583,9 @@ var ImageEditor = /** @class */ (function (_super) {
7577
9583
  * @private
7578
9584
  */
7579
9585
  ImageEditor.prototype.undo = function () {
7580
- _super.prototype.undo.call(this);
9586
+ if (this.getModuleName() !== 'image-editor') {
9587
+ _super.prototype.undo.call(this);
9588
+ }
7581
9589
  };
7582
9590
  /**
7583
9591
  * Redo the last user action.
@@ -7586,19 +9594,23 @@ var ImageEditor = /** @class */ (function (_super) {
7586
9594
  * @private
7587
9595
  */
7588
9596
  ImageEditor.prototype.redo = function () {
7589
- _super.prototype.redo.call(this);
9597
+ if (this.getModuleName() !== 'image-editor') {
9598
+ _super.prototype.redo.call(this);
9599
+ }
7590
9600
  };
7591
9601
  /**
7592
9602
  * To save the signature with the given file type and file name.
7593
9603
  *
7594
- * @param {SignatureFileType} type - specify type of the file to be saved a signature.
9604
+ * @param {FileType} type - specify type of the file to be saved a signature.
7595
9605
  * @param {string} fileName - specify name of the file to be saved a signature.
7596
9606
  *
7597
9607
  * @returns {void}.
7598
9608
  * @private
7599
9609
  */
7600
9610
  ImageEditor.prototype.save = function (type, fileName) {
7601
- _super.prototype.save.call(this, type, fileName);
9611
+ if (this.getModuleName() !== 'image-editor') {
9612
+ _super.prototype.save.call(this, type, fileName);
9613
+ }
7602
9614
  };
7603
9615
  /**
7604
9616
  * To save the signature as Blob.
@@ -7607,16 +9619,17 @@ var ImageEditor = /** @class */ (function (_super) {
7607
9619
  * @private
7608
9620
  */
7609
9621
  ImageEditor.prototype.saveAsBlob = function () {
7610
- return _super.prototype.saveAsBlob.call(this);
9622
+ return null;
7611
9623
  };
7612
9624
  /**
7613
9625
  * Returns the persistence data for component.
7614
9626
  *
7615
- * @returns any.
9627
+ * @returns {any}.
7616
9628
  * @private
7617
9629
  */
9630
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
7618
9631
  ImageEditor.prototype.getLocalData = function () {
7619
- return _super.prototype.getLocalData.call(this);
9632
+ return null;
7620
9633
  };
7621
9634
  var ImageEditor_1;
7622
9635
  __decorate([
@@ -7670,6 +9683,12 @@ var ImageEditor = /** @class */ (function (_super) {
7670
9683
  __decorate([
7671
9684
  Property(false)
7672
9685
  ], ImageEditor.prototype, "enablePersistence", void 0);
9686
+ __decorate([
9687
+ Complex({}, FinetuneSettings)
9688
+ ], ImageEditor.prototype, "finetuneSettings", void 0);
9689
+ __decorate([
9690
+ Property('')
9691
+ ], ImageEditor.prototype, "signatureValue", void 0);
7673
9692
  __decorate([
7674
9693
  Event()
7675
9694
  ], ImageEditor.prototype, "beforeSave", void 0);
@@ -7712,6 +9731,12 @@ var ImageEditor = /** @class */ (function (_super) {
7712
9731
  __decorate([
7713
9732
  Event()
7714
9733
  ], ImageEditor.prototype, "toolbarItemClicked", void 0);
9734
+ __decorate([
9735
+ Event()
9736
+ ], ImageEditor.prototype, "imageFiltering", void 0);
9737
+ __decorate([
9738
+ Event()
9739
+ ], ImageEditor.prototype, "fineTuneValueChanging", void 0);
7715
9740
  ImageEditor = ImageEditor_1 = __decorate([
7716
9741
  NotifyPropertyChanges
7717
9742
  ], ImageEditor);