@syncfusion/ej2-image-editor 20.3.56 → 20.4.40

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 (62) hide show
  1. package/.eslintrc.json +16 -1
  2. package/CHANGELOG.md +5 -5
  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 +6191 -4168
  7. package/dist/es6/ej2-image-editor.es2015.js.map +1 -1
  8. package/dist/es6/ej2-image-editor.es5.js +2505 -474
  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 +23 -24
  14. package/src/image-editor/image-editor-model.d.ts +114 -20
  15. package/src/image-editor/image-editor.d.ts +251 -33
  16. package/src/image-editor/image-editor.js +2505 -473
  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.css +36 -0
  46. package/styles/image-editor/bootstrap4.css +36 -0
  47. package/styles/image-editor/bootstrap5-dark.css +36 -0
  48. package/styles/image-editor/bootstrap5.css +36 -0
  49. package/styles/image-editor/fabric-dark.css +36 -0
  50. package/styles/image-editor/fabric.css +36 -0
  51. package/styles/image-editor/fluent-dark.css +36 -0
  52. package/styles/image-editor/fluent.css +36 -0
  53. package/styles/image-editor/highcontrast-light.css +36 -0
  54. package/styles/image-editor/highcontrast.css +36 -0
  55. package/styles/image-editor/material-dark.css +36 -0
  56. package/styles/image-editor/material.css +36 -0
  57. package/styles/image-editor/tailwind-dark.css +36 -0
  58. package/styles/image-editor/tailwind.css +36 -0
  59. package/styles/material-dark.css +36 -0
  60. package/styles/material.css +36 -0
  61. package/styles/tailwind-dark.css +36 -0
  62. 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, detach, select } 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,30 @@ 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;
151
+ _this.imageFileName = '';
108
152
  return _this;
109
153
  }
110
154
  ImageEditor_1 = ImageEditor;
@@ -134,8 +178,28 @@ var ImageEditor = /** @class */ (function (_super) {
134
178
  Crop: 'Crop',
135
179
  ZoomIn: 'Zoom In',
136
180
  ZoomOut: 'Zoom Out',
181
+ Undo: 'Undo',
182
+ Redo: 'Redo',
137
183
  Transform: 'Transform',
138
184
  Annotation: 'Annotation',
185
+ Finetune: 'Finetune',
186
+ Brightness: 'Brightness',
187
+ Contrast: 'Contrast',
188
+ Hue: 'Hue',
189
+ Saturation: 'Saturation',
190
+ Opacity: 'Opacity',
191
+ Blur: 'Blur',
192
+ Sharpen: 'Sharpen',
193
+ Exposure: 'Exposure',
194
+ Filter: 'Filter',
195
+ Default: 'Default',
196
+ Chrome: 'Chrome',
197
+ Cold: 'Cold',
198
+ Warm: 'Warm',
199
+ Grayscale: 'Grayscale',
200
+ BlackAndWhite: 'Black and White',
201
+ Sepia: 'Sepia',
202
+ Invert: 'Invert',
139
203
  Text: 'Add Text',
140
204
  Pen: 'Pen',
141
205
  Reset: 'Reset',
@@ -163,7 +227,6 @@ var ImageEditor = /** @class */ (function (_super) {
163
227
  Ellipse: 'Ellipse',
164
228
  Rectangle: 'Rectangle',
165
229
  Line: 'Line',
166
- Default: 'Default',
167
230
  Bold: 'Bold',
168
231
  Italic: 'Italic',
169
232
  BoldItalic: 'Bold Italic',
@@ -172,7 +235,8 @@ var ImageEditor = /** @class */ (function (_super) {
172
235
  Medium: 'Medium',
173
236
  Large: 'Large',
174
237
  XLarge: 'X-Large',
175
- ABC: 'ABC'
238
+ ABC: 'ABC',
239
+ Browse: 'Browse'
176
240
  };
177
241
  this.l10n = new L10n('image-editor', this.defaultLocale, this.locale);
178
242
  };
@@ -249,6 +313,12 @@ var ImageEditor = /** @class */ (function (_super) {
249
313
  this.upperContext.fillStyle = this.themeColl[this.theme]['secondaryColor'];
250
314
  }
251
315
  break;
316
+ case 'finetuneSettings':
317
+ if (newProperties.finetuneSettings) {
318
+ this.finetuneSettings = newProperties.finetuneSettings;
319
+ this.updateFinetunes();
320
+ }
321
+ break;
252
322
  }
253
323
  }
254
324
  };
@@ -269,13 +339,17 @@ var ImageEditor = /** @class */ (function (_super) {
269
339
  this.trigger('destroyed');
270
340
  };
271
341
  ImageEditor.prototype.initialize = function () {
342
+ this.updateFinetunes();
272
343
  this.createToolbar();
344
+ this.createContextualToolbar();
273
345
  this.createCanvas();
274
346
  this.wireEvent();
275
347
  this.updateContext(this.lowerContext);
276
348
  this.updateContext(this.upperContext);
277
349
  this.pannStart = { startX: 0, startY: 0, width: 0, height: 0 };
278
350
  this.pannEnd = { startX: 0, startY: 0, width: 0, height: 0 };
351
+ this.lowerContext.filter = this.canvasFilter = this.initialAdjustmentValue = this.adjustmentValue = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
352
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
279
353
  if (this.cssClass) {
280
354
  addClass([this.element], this.cssClass.split(' '));
281
355
  }
@@ -285,6 +359,39 @@ var ImageEditor = /** @class */ (function (_super) {
285
359
  });
286
360
  }
287
361
  };
362
+ ImageEditor.prototype.updateFinetunes = function () {
363
+ if (this.finetuneSettings) {
364
+ if (this.finetuneSettings.brightness) {
365
+ this.adjustmentLevel.brightness = this.finetuneSettings.brightness.defaultValue;
366
+ this.tempAdjustmentLevel.brightness = this.finetuneSettings.brightness.defaultValue;
367
+ }
368
+ if (this.finetuneSettings.contrast) {
369
+ this.adjustmentLevel.contrast = this.finetuneSettings.contrast.defaultValue;
370
+ this.tempAdjustmentLevel.contrast = this.finetuneSettings.contrast.defaultValue;
371
+ }
372
+ if (this.finetuneSettings.hue) {
373
+ this.adjustmentLevel.hue = this.finetuneSettings.hue.defaultValue;
374
+ this.tempAdjustmentLevel.hue = this.finetuneSettings.hue.defaultValue;
375
+ }
376
+ if (this.finetuneSettings.saturation) {
377
+ this.adjustmentLevel.saturation = this.finetuneSettings.saturation.defaultValue;
378
+ this.tempAdjustmentLevel.saturation = this.finetuneSettings.saturation.defaultValue;
379
+ }
380
+ if (this.finetuneSettings.exposure) {
381
+ this.adjustmentLevel.exposure = this.finetuneSettings.exposure.defaultValue;
382
+ this.tempAdjustmentLevel.exposure = this.finetuneSettings.exposure.defaultValue;
383
+ }
384
+ if (this.finetuneSettings.opacity) {
385
+ this.adjustmentLevel.opacity = this.finetuneSettings.opacity.defaultValue;
386
+ this.tempAdjustmentLevel.opacity = this.finetuneSettings.opacity.defaultValue;
387
+ }
388
+ if (this.finetuneSettings.blur) {
389
+ this.adjustmentLevel.blur = this.finetuneSettings.blur.defaultValue;
390
+ this.tempAdjustmentLevel.blur = this.finetuneSettings.blur.defaultValue;
391
+ }
392
+ this.isInitialLoading = true;
393
+ }
394
+ };
288
395
  /**
289
396
  *
290
397
  * This Method will add events to component (element, event, method, current reference)
@@ -307,7 +414,7 @@ var ImageEditor = /** @class */ (function (_super) {
307
414
  EventHandler.add(this.upperCanvas, 'dblclick', this.findTextPoint, this);
308
415
  EventHandler.add(this.textBox, 'mousedown', this.findTextPoint, this);
309
416
  window.addEventListener('resize', this.windowResizeHandler.bind(this));
310
- if ((!Browser.isIos && Browser.info.name !== 'safari')) {
417
+ if (!Browser.isIos && Browser.info.name !== 'safari' && screen && screen.orientation) {
311
418
  screen.orientation.addEventListener('change', this.screenOrientation.bind(this));
312
419
  }
313
420
  };
@@ -329,9 +436,17 @@ var ImageEditor = /** @class */ (function (_super) {
329
436
  EventHandler.remove(this.lowerCanvas, 'mouseup', this.canvasMouseUpHandler);
330
437
  EventHandler.remove(document, 'mouseup', this.canvasMouseUpHandler);
331
438
  };
439
+ ImageEditor.prototype.initializeFilter = function () {
440
+ this.setBrightness(this.adjustmentLevel.brightness);
441
+ this.setContrast(this.adjustmentLevel.contrast);
442
+ this.setHue(this.adjustmentLevel.hue);
443
+ this.setSaturation(this.adjustmentLevel.saturation);
444
+ this.setExposure(this.adjustmentLevel.exposure);
445
+ this.setOpacity(this.adjustmentLevel.opacity);
446
+ this.setBlur(this.adjustmentLevel.blur);
447
+ };
332
448
  ImageEditor.prototype.destroySubComponents = function () {
333
449
  var inputElement = this.element.querySelectorAll('input.e-control');
334
- var divElement = this.element.querySelectorAll('div.e-control:not(.e-handle)');
335
450
  var btnElement = this.element.querySelectorAll('button.e-control');
336
451
  for (var i = 0, len = inputElement.length; i < len; i++) {
337
452
  if (inputElement[i].classList.contains('e-color-picker')) {
@@ -462,6 +577,58 @@ var ImageEditor = /** @class */ (function (_super) {
462
577
  this.toolbarHeight = 0;
463
578
  }
464
579
  };
580
+ ImageEditor.prototype.createContextualToolbar = function () {
581
+ if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.length > 0)) {
582
+ this.element.appendChild(this.createElement('div', { id: this.element.id + '_contextualToolbarArea',
583
+ className: 'e-contextual-toolbar-wrapper e-hide', attrs: { style: 'position: absolute;' }
584
+ }));
585
+ var toolbarArea = document.getElementById(this.element.id + '_contextualToolbarArea');
586
+ var toolbar_2 = this.createElement('div', { id: this.element.id + '_contextualToolbar' });
587
+ toolbarArea.appendChild(toolbar_2);
588
+ }
589
+ };
590
+ ImageEditor.prototype.updateContextualToolbar = function (type, cType) {
591
+ if (this.toolbarTemplate) {
592
+ this.toolbarTemplateFn();
593
+ }
594
+ else {
595
+ var toolbarArea = this.element.querySelector('#' + this.element.id + '_toolbarArea');
596
+ var contextualToolbarArea = this.element.querySelector('#' + this.element.id + '_contextualToolbarArea');
597
+ if (!isNullOrUndefined(toolbarArea) && !isNullOrUndefined(contextualToolbarArea)) {
598
+ contextualToolbarArea.classList.remove('e-hide');
599
+ contextualToolbarArea.style.left = toolbarArea.offsetLeft + 'px';
600
+ }
601
+ if (type === 'filter') {
602
+ if (!isNullOrUndefined(document.getElementById(this.element.id + '_toolbar')) && this.defToolbarItems.length > 0) {
603
+ getComponent(document.getElementById(this.element.id + '_toolbar'), 'toolbar').destroy();
604
+ }
605
+ if (Browser.isDevice) {
606
+ this.initToolbarItem(false, true, true);
607
+ }
608
+ else {
609
+ this.initToolbarItem(true);
610
+ }
611
+ this.refreshSlider();
612
+ this.initFilterToolbarItem();
613
+ }
614
+ else {
615
+ if (!isNullOrUndefined(document.querySelector('#' + this.element.id + '_contextualToolbar'))
616
+ && document.querySelector('#' + this.element.id + '_contextualToolbar').classList.contains('e-control')) {
617
+ getComponent(document.getElementById(this.element.id + '_contextualToolbar'), 'toolbar').destroy();
618
+ }
619
+ this.refreshSlider();
620
+ this.renderSlider(cType);
621
+ }
622
+ if (Browser.isDevice) {
623
+ var cHt = contextualToolbarArea.offsetHeight;
624
+ var ht = this.element.querySelector('#' + this.element.id + '_canvasWrapper').offsetHeight;
625
+ contextualToolbarArea.style.top = this.toolbarHeight + ht - cHt + 'px';
626
+ }
627
+ else {
628
+ contextualToolbarArea.style.top = this.toolbarHeight + 1 + 'px';
629
+ }
630
+ }
631
+ };
465
632
  ImageEditor.prototype.createBottomToolbar = function () {
466
633
  if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.length > 0)) {
467
634
  this.element.appendChild(this.createElement('div', {
@@ -498,8 +665,8 @@ var ImageEditor = /** @class */ (function (_super) {
498
665
  }, '#' + this.element.id + '_bottomToolbar');
499
666
  if (this.defToolbarItems.length > 0 && (!isNullOrUndefined(document.getElementById(this.element.id + '_bottomToolbar')))) {
500
667
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
501
- var toolbar_2 = getComponent(this.element.id + '_bottomToolbar', 'toolbar');
502
- toolbar_2.refreshOverflow();
668
+ var toolbar_3 = getComponent(this.element.id + '_bottomToolbar', 'toolbar');
669
+ toolbar_3.refreshOverflow();
503
670
  }
504
671
  }
505
672
  }
@@ -602,6 +769,14 @@ var ImageEditor = /** @class */ (function (_super) {
602
769
  template: '<button id="' + this.element.id + '_transformBtn"></button>'
603
770
  });
604
771
  }
772
+ if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Finetune') > -1)) {
773
+ toolbarItems.push({ id: this.element.id + '_adjustment', prefixIcon: 'e-icons e-adjustment', cssClass: 'top-icon e-adjustment',
774
+ tooltipText: this.l10n.getConstant('Finetune'), align: 'Center' });
775
+ }
776
+ if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Filter') > -1)) {
777
+ toolbarItems.push({ id: this.element.id + '_filter', prefixIcon: 'e-icons e-filters', cssClass: 'top-icon e-filters',
778
+ tooltipText: this.l10n.getConstant('Filter'), align: 'Center' });
779
+ }
605
780
  var tempToolbarItems = this.processToolbar('center');
606
781
  for (var i = 0, len = tempToolbarItems.length; i < len; i++) {
607
782
  toolbarItems.push(tempToolbarItems[i]);
@@ -709,8 +884,8 @@ var ImageEditor = /** @class */ (function (_super) {
709
884
  }
710
885
  if (this.isToolbar() && (!isNullOrUndefined(document.getElementById(this.element.id + '_toolbar')))) {
711
886
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
712
- var toolbar_3 = getComponent(this.element.id + '_toolbar', 'toolbar');
713
- toolbar_3.refreshOverflow();
887
+ var toolbar_4 = getComponent(this.element.id + '_toolbar', 'toolbar');
888
+ toolbar_4.refreshOverflow();
714
889
  }
715
890
  }
716
891
  };
@@ -807,7 +982,7 @@ var ImageEditor = /** @class */ (function (_super) {
807
982
  items.push({ text: this.l10n.getConstant('Custom'), id: 'custom', iconCss: 'e-icons e-custom' });
808
983
  }
809
984
  if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('CircleSelection') > -1)) {
810
- items.push({ text: this.l10n.getConstant('Circle'), id: 'ellipse', iconCss: 'e-icons e-circle' });
985
+ items.push({ text: this.l10n.getConstant('Circle'), id: 'circle', iconCss: 'e-icons e-circle' });
811
986
  }
812
987
  if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('SquareSelection') > -1)) {
813
988
  items.push({ text: this.l10n.getConstant('Square'), id: 'square', iconCss: 'e-icons e-square' });
@@ -890,7 +1065,7 @@ var ImageEditor = /** @class */ (function (_super) {
890
1065
  }
891
1066
  };
892
1067
  ImageEditor.prototype.cropSelect = function (args) {
893
- var text = args.item.text;
1068
+ var text = args.item.id;
894
1069
  this.select(text);
895
1070
  this.refreshToolbar('main', true, true);
896
1071
  };
@@ -996,9 +1171,16 @@ var ImageEditor = /** @class */ (function (_super) {
996
1171
  modeSwitcher: false, noColor: true, value: '',
997
1172
  showButtons: false, mode: 'Palette', cssClass: 'e-shape-fill-color',
998
1173
  change: function (args) {
1174
+ _this.pushActItemIntoObj();
1175
+ var objColl = extend([], _this.objColl, [], true);
1176
+ _this.objColl.pop();
999
1177
  proxy.activeObj.strokeSettings.fillColor = args.currentValue.hex;
1000
1178
  proxy.strokeSettings.fillColor = proxy.activeObj.strokeSettings.fillColor;
1001
- proxy.redrawShape(_this.activeObj);
1179
+ _this.objColl.push(_this.activeObj);
1180
+ proxy.undoRedoColl.push({ operation: 'shapeTransform', value: null,
1181
+ currentObj: extend([], proxy.objColl, [], true), previousObj: objColl, factor: proxy.factor,
1182
+ sharpen: proxy.adjustmentLevel.sharpen, bw: proxy.adjustmentLevel.bw });
1183
+ proxy.redrawShape(proxy.objColl[proxy.objColl.length - 1]);
1002
1184
  if (args.currentValue.rgba === '') {
1003
1185
  fillDDB_1.element.children[0].classList.add('e-nocolor-item');
1004
1186
  }
@@ -1031,10 +1213,17 @@ var ImageEditor = /** @class */ (function (_super) {
1031
1213
  modeSwitcher: false, noColor: false, value: '#fff',
1032
1214
  showButtons: false, mode: 'Palette', cssClass: 'e-shape-stroke-color',
1033
1215
  change: function (args) {
1216
+ _this.pushActItemIntoObj();
1217
+ var objColl = extend([], _this.objColl, [], true);
1218
+ _this.objColl.pop();
1034
1219
  proxy.activeObj.strokeSettings.strokeColor = args.currentValue.hex;
1035
1220
  proxy.strokeSettings.strokeColor = proxy.activeObj.strokeSettings.strokeColor;
1036
1221
  if (!proxy.togglePen) {
1037
- proxy.redrawShape(_this.activeObj);
1222
+ _this.objColl.push(_this.activeObj);
1223
+ proxy.undoRedoColl.push({ operation: 'shapeTransform', value: null,
1224
+ currentObj: extend([], proxy.objColl, [], true), previousObj: objColl, factor: proxy.factor,
1225
+ sharpen: proxy.adjustmentLevel.sharpen, bw: proxy.adjustmentLevel.bw });
1226
+ proxy.redrawShape(proxy.objColl[proxy.objColl.length - 1]);
1038
1227
  }
1039
1228
  strokeDDB_1.element.children[0].style.backgroundColor = args.currentValue.rgba;
1040
1229
  strokeDDB_1.toggle();
@@ -1084,6 +1273,9 @@ var ImageEditor = /** @class */ (function (_super) {
1084
1273
  }
1085
1274
  },
1086
1275
  select: function (args) {
1276
+ _this.pushActItemIntoObj();
1277
+ var objColl = extend([], _this.objColl, [], true);
1278
+ _this.objColl.pop();
1087
1279
  spanElem_1.textContent = args.item.text;
1088
1280
  _this.activeObj.strokeSettings.strokeWidth = parseInt(args.item.id, 10);
1089
1281
  if (_this.lowerCanvas.width > _this.lowerCanvas.height) {
@@ -1093,19 +1285,23 @@ var ImageEditor = /** @class */ (function (_super) {
1093
1285
  _this.activeObj.strokeSettings.strokeWidth *= ((ratio.height + ratio.width) / _this.factor);
1094
1286
  }
1095
1287
  _this.strokeSettings.strokeWidth = _this.activeObj.strokeSettings.strokeWidth;
1096
- _this.redrawShape(_this.activeObj);
1288
+ _this.objColl.push(_this.activeObj);
1289
+ _this.undoRedoColl.push({ operation: 'shapeTransform', value: null,
1290
+ currentObj: extend([], _this.objColl, [], true), previousObj: objColl, factor: _this.factor,
1291
+ sharpen: _this.adjustmentLevel.sharpen, bw: _this.adjustmentLevel.bw });
1292
+ _this.redrawShape(_this.objColl[_this.objColl.length - 1]);
1097
1293
  if (Browser.isDevice) {
1098
1294
  if (!isNullOrUndefined(document.getElementById(_this.element.id + '_bottomToolbar'))) {
1099
1295
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
1100
- var toolbar_4 = getComponent(_this.element.id + '_bottomToolbar', 'toolbar');
1101
- toolbar_4.refreshOverflow();
1296
+ var toolbar_5 = getComponent(_this.element.id + '_bottomToolbar', 'toolbar');
1297
+ toolbar_5.refreshOverflow();
1102
1298
  }
1103
1299
  }
1104
1300
  else {
1105
1301
  if (!isNullOrUndefined(document.getElementById(_this.element.id + '_toolbar'))) {
1106
1302
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
1107
- var toolbar_5 = getComponent(_this.element.id + '_toolbar', 'toolbar');
1108
- toolbar_5.refreshOverflow();
1303
+ var toolbar_6 = getComponent(_this.element.id + '_toolbar', 'toolbar');
1304
+ toolbar_6.refreshOverflow();
1109
1305
  }
1110
1306
  }
1111
1307
  }
@@ -1221,17 +1417,26 @@ var ImageEditor = /** @class */ (function (_super) {
1221
1417
  modeSwitcher: false, value: '#fff',
1222
1418
  showButtons: false, mode: 'Palette', cssClass: 'e-text-fontt-color',
1223
1419
  change: function (args) {
1420
+ _this.pushActItemIntoObj();
1421
+ _this.objColl.pop();
1224
1422
  if (proxy.textBox.style.display === 'none') {
1225
1423
  proxy.strokeSettings.strokeColor = proxy.activeObj.strokeSettings.strokeColor = args.currentValue.hex;
1226
1424
  if (!proxy.togglePen) {
1227
- proxy.redrawShape(_this.activeObj);
1425
+ _this.objColl.push(_this.activeObj);
1426
+ proxy.redrawShape(proxy.objColl[proxy.objColl.length - 1]);
1228
1427
  }
1229
1428
  }
1230
1429
  else if (proxy.textBox.style.display === 'block') {
1231
1430
  proxy.textBox.style.color = args.currentValue.hex;
1431
+ var temp = proxy.activeObj.strokeSettings.strokeColor;
1432
+ proxy.activeObj.strokeSettings.strokeColor = args.currentValue.hex;
1433
+ _this.objColl.push(_this.activeObj);
1434
+ _this.objColl.pop();
1435
+ proxy.activeObj.strokeSettings.strokeColor = temp;
1232
1436
  }
1233
1437
  else if (!proxy.togglePen) {
1234
- proxy.redrawShape(_this.activeObj);
1438
+ _this.objColl.push(_this.activeObj);
1439
+ proxy.redrawShape(proxy.objColl[proxy.objColl.length - 1]);
1235
1440
  }
1236
1441
  strokeDDB_2.element.children[0].style.backgroundColor = args.currentValue.rgba;
1237
1442
  strokeDDB_2.toggle();
@@ -1253,6 +1458,17 @@ var ImageEditor = /** @class */ (function (_super) {
1253
1458
  = '#fff';
1254
1459
  }
1255
1460
  };
1461
+ ImageEditor.prototype.pushActItemIntoObj = function () {
1462
+ if (this.textBox.style.display === 'none') {
1463
+ this.objColl.push(this.activeObj);
1464
+ }
1465
+ else {
1466
+ var temp = extend({}, this.activeObj, {}, true);
1467
+ this.setTextBoxStylesToActObj();
1468
+ this.objColl.push(this.activeObj);
1469
+ this.activeObj = temp;
1470
+ }
1471
+ };
1256
1472
  ImageEditor.prototype.createTextBtn = function (items) {
1257
1473
  var _this = this;
1258
1474
  var ratio = this.calcRatio();
@@ -1290,6 +1506,8 @@ var ImageEditor = /** @class */ (function (_super) {
1290
1506
  + '"' + ']').classList.add('e-selected-btn');
1291
1507
  },
1292
1508
  select: function (args) {
1509
+ _this.pushActItemIntoObj();
1510
+ _this.objColl.pop();
1293
1511
  spanElem_2.textContent = args.item.text;
1294
1512
  if (Browser.isDevice) {
1295
1513
  spanElem_2.setAttribute('style', 'font-family:' + args.item.id);
@@ -1297,10 +1515,13 @@ var ImageEditor = /** @class */ (function (_super) {
1297
1515
  if (_this.textBox.style.display === 'block') {
1298
1516
  var temp = _this.activeObj.textSettings.fontFamily;
1299
1517
  _this.activeObj.textSettings.fontFamily = _this.toPascalCase(args.item.id);
1300
- _this.updateFontStyles();
1301
- var width = _this.upperContext.measureText(_this.activeObj.keyHistory).width +
1302
- _this.activeObj.textSettings.fontSize * 0.5;
1303
- _this.textBox.style.width = Browser.isDevice ? width + 'px' : (width * ((ratio.width + ratio.height) / 2)) + 'px';
1518
+ _this.redrawText(ratio);
1519
+ _this.objColl.push(_this.activeObj);
1520
+ _this.objColl.pop();
1521
+ _this.upperContext.clearRect(0, 0, _this.upperCanvas.width, _this.upperCanvas.height);
1522
+ var width = _this.activeObj.activePoint.width +
1523
+ _this.activeObj.textSettings.fontSize * 0.25;
1524
+ _this.textBox.style.width = width / ratio.width + 'px';
1304
1525
  _this.textBox.style.fontFamily = _this.toPascalCase(args.item.id);
1305
1526
  _this.activeObj.textSettings.fontFamily = temp;
1306
1527
  _this.updateFontStyles();
@@ -1308,7 +1529,8 @@ var ImageEditor = /** @class */ (function (_super) {
1308
1529
  else {
1309
1530
  _this.textSettings.fontFamily = _this.activeObj.textSettings.fontFamily = _this.toPascalCase(args.item.id);
1310
1531
  _this.redrawText(ratio);
1311
- _this.redrawShape(_this.activeObj);
1532
+ _this.objColl.push(_this.activeObj);
1533
+ _this.redrawShape(_this.objColl[_this.objColl.length - 1]);
1312
1534
  }
1313
1535
  }
1314
1536
  });
@@ -1407,10 +1629,14 @@ var ImageEditor = /** @class */ (function (_super) {
1407
1629
  args.element.querySelector('[aria-label *= ' + '"' + activeBtn + '"' + ']').classList.add('e-selected-btn');
1408
1630
  },
1409
1631
  select: function (args) {
1632
+ _this.pushActItemIntoObj();
1633
+ _this.objColl.pop();
1410
1634
  fontSizeSpanElem_1.textContent = args.item.text;
1411
1635
  if (_this.textBox.style.display === 'block') {
1412
1636
  var temp = _this.activeObj.textSettings.fontSize;
1413
1637
  _this.activeObj.textSettings.fontSize = parseInt(_this.fontSizeColl[(parseInt(args.item.text, 10) - 1)].text, 10);
1638
+ _this.objColl.push(_this.activeObj);
1639
+ _this.objColl.pop();
1414
1640
  var textStyle = '';
1415
1641
  if (_this.textBox.style.fontWeight === 'bold') {
1416
1642
  textStyle = 'bold ';
@@ -1442,11 +1668,13 @@ var ImageEditor = /** @class */ (function (_super) {
1442
1668
  var text = _this.getMaxText();
1443
1669
  var width = _this.upperContext.measureText(text).width +
1444
1670
  _this.activeObj.textSettings.fontSize * 0.5;
1445
- var height = rows.length * (_this.activeObj.textSettings.fontSize + _this.activeObj.textSettings.fontSize * 0.25);
1671
+ var height = rows.length * (_this.activeObj.textSettings.fontSize +
1672
+ _this.activeObj.textSettings.fontSize * 0.25);
1446
1673
  _this.setTextSelection(width, height);
1447
1674
  _this.updateActiveObject(ratio, _this.activeObj.activePoint, _this.activeObj);
1448
- _this.redrawShape(_this.activeObj);
1449
1675
  _this.redrawText(ratio);
1676
+ _this.objColl.push(_this.activeObj);
1677
+ _this.redrawShape(_this.objColl[_this.objColl.length - 1]);
1450
1678
  }
1451
1679
  }
1452
1680
  });
@@ -1497,14 +1725,43 @@ var ImageEditor = /** @class */ (function (_super) {
1497
1725
  this.activeObj.textSettings.italic = tempItalic;
1498
1726
  return width;
1499
1727
  };
1728
+ ImageEditor.prototype.updateObjColl = function (item) {
1729
+ var tempBold = this.activeObj.textSettings.bold;
1730
+ var tempItalic = this.activeObj.textSettings.italic;
1731
+ switch (item) {
1732
+ case 'default':
1733
+ this.activeObj.textSettings.bold = false;
1734
+ this.activeObj.textSettings.italic = false;
1735
+ break;
1736
+ case 'bold':
1737
+ this.activeObj.textSettings.bold = true;
1738
+ this.activeObj.textSettings.italic = false;
1739
+ break;
1740
+ case 'italic':
1741
+ this.activeObj.textSettings.bold = false;
1742
+ this.activeObj.textSettings.italic = true;
1743
+ break;
1744
+ case 'bolditalic':
1745
+ this.activeObj.textSettings.bold = true;
1746
+ this.activeObj.textSettings.italic = true;
1747
+ break;
1748
+ }
1749
+ this.objColl.push(this.activeObj);
1750
+ this.objColl.pop();
1751
+ this.activeObj.textSettings.bold = tempBold;
1752
+ this.activeObj.textSettings.italic = tempItalic;
1753
+ };
1500
1754
  ImageEditor.prototype.applyFontStyle = function (item, ratio) {
1755
+ this.pushActItemIntoObj();
1756
+ this.objColl.pop();
1501
1757
  switch (item) {
1502
1758
  case 'default':
1503
1759
  if (this.textBox.style.display === 'block') {
1504
- var width = this.getTextAreaWidth(item);
1505
- this.textBox.style.width = Browser.isDevice ? width + 'px' : (width * ((ratio.width + ratio.height) / 2)) + 'px';
1760
+ var width = this.getTextAreaWidth(item) / ratio.width;
1761
+ this.textBox.style.width = width + 'px';
1506
1762
  this.textBox.style.fontWeight = 'normal';
1507
1763
  this.textBox.style.fontStyle = 'normal';
1764
+ this.updateObjColl(item);
1508
1765
  }
1509
1766
  else {
1510
1767
  this.textSettings.bold = this.activeObj.textSettings.bold = false;
@@ -1514,10 +1771,11 @@ var ImageEditor = /** @class */ (function (_super) {
1514
1771
  break;
1515
1772
  case 'bold':
1516
1773
  if (this.textBox.style.display === 'block') {
1517
- var width = this.getTextAreaWidth(item);
1518
- this.textBox.style.width = Browser.isDevice ? width + 'px' : (width * ((ratio.width + ratio.height) / 2)) + 'px';
1774
+ var width = this.getTextAreaWidth(item) / ratio.width;
1775
+ this.textBox.style.width = width + 'px';
1519
1776
  this.textBox.style.fontWeight = 'bold';
1520
1777
  this.textBox.style.fontStyle = 'normal';
1778
+ this.updateObjColl(item);
1521
1779
  }
1522
1780
  else {
1523
1781
  this.textSettings.bold = this.activeObj.textSettings.bold = true;
@@ -1527,10 +1785,11 @@ var ImageEditor = /** @class */ (function (_super) {
1527
1785
  break;
1528
1786
  case 'italic':
1529
1787
  if (this.textBox.style.display === 'block') {
1530
- var width = this.getTextAreaWidth(item);
1531
- this.textBox.style.width = Browser.isDevice ? width + 'px' : (width * ((ratio.width + ratio.height) / 2)) + 'px';
1788
+ var width = this.getTextAreaWidth(item) / ratio.width;
1789
+ this.textBox.style.width = width + 'px';
1532
1790
  this.textBox.style.fontWeight = 'normal';
1533
1791
  this.textBox.style.fontStyle = 'italic';
1792
+ this.updateObjColl(item);
1534
1793
  }
1535
1794
  else {
1536
1795
  this.textSettings.bold = this.activeObj.textSettings.bold = false;
@@ -1540,10 +1799,11 @@ var ImageEditor = /** @class */ (function (_super) {
1540
1799
  break;
1541
1800
  case 'bolditalic':
1542
1801
  if (this.textBox.style.display === 'block') {
1543
- var width = this.getTextAreaWidth(item);
1544
- this.textBox.style.width = (width / ratio.width) + 'px';
1802
+ var width = this.getTextAreaWidth(item) / ratio.width;
1803
+ this.textBox.style.width = width + 'px';
1545
1804
  this.textBox.style.fontWeight = 'bold';
1546
1805
  this.textBox.style.fontStyle = 'italic';
1806
+ this.updateObjColl(item);
1547
1807
  }
1548
1808
  else {
1549
1809
  this.textSettings.bold = this.activeObj.textSettings.bold = true;
@@ -1571,12 +1831,25 @@ var ImageEditor = /** @class */ (function (_super) {
1571
1831
  this.createLeftToolbarControls();
1572
1832
  if (this.defToolbarItems.length > 0 && (!isNullOrUndefined(document.getElementById(this.element.id + '_toolbar')))) {
1573
1833
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
1574
- var toolbar_6 = getComponent(this.element.id + '_toolbar', 'toolbar');
1575
- toolbar_6.refreshOverflow();
1834
+ var toolbar_7 = getComponent(this.element.id + '_toolbar', 'toolbar');
1835
+ toolbar_7.refreshOverflow();
1836
+ }
1837
+ };
1838
+ ImageEditor.prototype.contextualToolbarClicked = function (args) {
1839
+ var selEle = this.element.querySelector('.e-contextual-toolbar-wrapper .e-toolbar-item.e-selected');
1840
+ if (selEle) {
1841
+ selEle.classList.remove('e-selected');
1576
1842
  }
1843
+ document.getElementById(args.item.id + 'Canvas').parentElement.parentElement.classList.add('e-selected');
1844
+ this.currObjType.isFiltered = true;
1845
+ var type = args.item.id.replace(this.element.id, '').split('_')[1];
1846
+ var imageFiltering = { filter: this.toPascalCase(type) };
1847
+ this.trigger('imageFiltering', imageFiltering);
1848
+ this.setFilter(type.toLowerCase());
1849
+ this.currentFilter = args.item.id;
1577
1850
  };
1578
1851
  ImageEditor.prototype.defToolbarClicked = function (args) {
1579
- var ratio = this.calcRatio();
1852
+ this.element.querySelector('.e-contextual-toolbar-wrapper').classList.add('e-hide');
1580
1853
  var zoomIn;
1581
1854
  var type = args.item.id.replace(this.element.id + '_', '').toLowerCase();
1582
1855
  var imageEditorObj = getInstance(document.getElementById(this.element.id), ImageEditor_1);
@@ -1595,61 +1868,23 @@ var ImageEditor = /** @class */ (function (_super) {
1595
1868
  if (!this.disabled) {
1596
1869
  switch (type) {
1597
1870
  case 'zoomin':
1871
+ this.currObjType.isFiltered = false;
1598
1872
  if (this.togglePen) {
1599
1873
  this.currObjType.isZoomed = true;
1600
1874
  this.freeHandDraw(false);
1601
1875
  }
1602
1876
  imageEditorObj.zoom(.1);
1603
- if (!this.togglePan) {
1604
- this.callMainToolbar(false, true);
1605
- }
1606
- if (this.factor > 0.95 && this.factor < 1.05) {
1607
- this.dragCanvas = this.togglePan = false;
1608
- this.callMainToolbar(false, true);
1609
- }
1610
- if (isNullOrUndefined(this.activeObj.activePoint) || this.activeObj.activePoint.width === 0) {
1611
- this.refreshToolbar('main');
1612
- }
1613
- else {
1614
- this.refreshToolbar('main', true, true);
1615
- }
1616
- panBtn = this.element.querySelector('.e-img-pan .e-btn');
1617
- if (!isNullOrUndefined(panBtn) && this.togglePan) {
1618
- panBtn.classList.add('e-selected-btn');
1619
- }
1620
- else if (!isNullOrUndefined(panBtn)) {
1621
- panBtn.classList.remove('e-selected-btn');
1622
- }
1623
1877
  break;
1624
1878
  case 'zoomout':
1879
+ this.currObjType.isFiltered = false;
1625
1880
  if (this.togglePen) {
1626
1881
  this.currObjType.isZoomed = true;
1627
1882
  this.freeHandDraw(false);
1628
1883
  }
1629
1884
  imageEditorObj.zoom(-.1);
1630
- if (!this.togglePan) {
1631
- this.callMainToolbar(false, true);
1632
- }
1633
- if (this.factor > 0.95 && this.factor < 1.05) {
1634
- this.dragCanvas = this.togglePan = false;
1635
- this.callMainToolbar(false, true);
1636
- }
1637
- if (isNullOrUndefined(this.activeObj.activePoint) || this.activeObj.activePoint.width === 0) {
1638
- this.refreshToolbar('main');
1639
- }
1640
- else {
1641
- this.refreshToolbar('main', true, true);
1642
- }
1643
- panBtn = this.element.querySelector('.e-img-pan .e-btn');
1644
- if (!isNullOrUndefined(panBtn) && this.togglePan) {
1645
- panBtn.classList.add('e-selected-btn');
1646
- }
1647
- else if (!isNullOrUndefined(panBtn)) {
1648
- panBtn.classList.remove('e-selected-btn');
1649
- }
1650
1885
  break;
1651
1886
  case 'pan':
1652
- this.currObjType.isCustomCrop = false;
1887
+ this.currObjType.isCustomCrop = this.currObjType.isFiltered = false;
1653
1888
  if (isCropSelection) {
1654
1889
  this.currObjType.isCustomCrop = false;
1655
1890
  this.refreshActiveObj();
@@ -1658,11 +1893,13 @@ var ImageEditor = /** @class */ (function (_super) {
1658
1893
  }
1659
1894
  if (this.togglePan) {
1660
1895
  this.cancelPan();
1896
+ this.disablePan = true;
1661
1897
  }
1662
1898
  else {
1663
1899
  panBtn = this.element.querySelector('.e-img-pan .e-btn');
1664
1900
  panBtn.classList.add('e-selected-btn');
1665
1901
  imageEditorObj.pan(true);
1902
+ this.disablePan = false;
1666
1903
  }
1667
1904
  zoomIn = document.querySelector('#' + this.element.id + '_zoomIn');
1668
1905
  if (!isNullOrUndefined(zoomIn) && this.factor >= 8) {
@@ -1680,46 +1917,113 @@ var ImageEditor = /** @class */ (function (_super) {
1680
1917
  this.activeObj.strokeSettings = this.tempStrokeSettings;
1681
1918
  this.activeObj.textSettings = this.tempTextSettings;
1682
1919
  }
1920
+ else if (!isNullOrUndefined(document.querySelector('#' + this.element.id + '_sliderWrapper')) ||
1921
+ this.currObjType.isFiltered) {
1922
+ this.lowerContext.filter = this.adjustmentValue = this.initialAdjustmentValue = this.tempAdjustmentValue;
1923
+ this.currentFilter = this.tempFilter;
1924
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
1925
+ this.redrawImgWithObj();
1926
+ this.currObjType.isFiltered = false;
1927
+ if (this.adjustmentLevel.sharpen || this.adjustmentLevel.bw) {
1928
+ if (this.adjustmentLevel.sharpen) {
1929
+ this.setSharpness(false);
1930
+ }
1931
+ else if (this.adjustmentLevel.bw) {
1932
+ this.setBlackAndWhiteFilter(false);
1933
+ }
1934
+ var tempFilter = this.lowerContext.filter;
1935
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
1936
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
1937
+ for (var j = 0; j < this.objColl.length; j++) {
1938
+ this.apply(this.objColl[j].shape, this.objColl[j]);
1939
+ this.refreshActiveObj();
1940
+ }
1941
+ this.lowerContext.filter = tempFilter;
1942
+ }
1943
+ this.adjustmentLevel = extend({}, this.tempAdjustmentLevel, {}, true);
1944
+ if (this.currentFilter === this.element.id + '_sharpen' || this.currentFilter === this.element.id + '_blackandwhite'
1945
+ || this.tempSharpenFilter || this.tempBWFilter) {
1946
+ if (this.currentFilter === this.element.id + '_sharpen' || this.tempSharpenFilter) {
1947
+ this.setSharpness(true);
1948
+ }
1949
+ else if (this.currentFilter === this.element.id + '_blackandwhite' || this.tempBWFilter) {
1950
+ this.setBlackAndWhiteFilter(true);
1951
+ }
1952
+ var tempFilter = this.lowerContext.filter;
1953
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
1954
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
1955
+ for (var j = 0; j < this.objColl.length; j++) {
1956
+ this.apply(this.objColl[j].shape, this.objColl[j]);
1957
+ this.refreshActiveObj();
1958
+ }
1959
+ this.lowerContext.filter = tempFilter;
1960
+ this.tempSharpenFilter = this.tempBWFilter = false;
1961
+ }
1962
+ this.element.querySelector('.e-contextual-toolbar-wrapper').classList.add('e-hide');
1963
+ }
1683
1964
  this.cancelItems();
1684
1965
  break;
1685
1966
  case 'ok':
1686
- if (isCropSelection) {
1687
- this.crop();
1688
- }
1689
- else if (this.togglePen) {
1690
- this.freeHandDraw(false);
1691
- }
1692
- else if (this.textBox.style.display === 'block') {
1693
- this.redrawActObj();
1694
- }
1695
- else {
1696
- this.applyActObj();
1697
- }
1698
- this.callMainToolbar(false);
1967
+ this.okBtn();
1699
1968
  break;
1700
1969
  case 'reset':
1701
1970
  imageEditorObj.reset();
1702
1971
  break;
1972
+ case 'adjustment':
1973
+ this.upperCanvas.style.display = 'block';
1974
+ this.refreshToolbar('adjustment');
1975
+ this.lowerContext.filter = this.initialAdjustmentValue;
1976
+ this.tempAdjustmentValue = this.lowerContext.filter;
1977
+ this.tempAdjustmentLevel = extend({}, this.adjustmentLevel, {}, true);
1978
+ this.tempFilter = this.currentFilter;
1979
+ this.tempSharpenFilter = this.adjustmentLevel.sharpen;
1980
+ this.tempBWFilter = this.adjustmentLevel.bw;
1981
+ break;
1982
+ case 'brightness':
1983
+ case 'contrast':
1984
+ case 'hue':
1985
+ case 'saturation':
1986
+ case 'opacity':
1987
+ case 'blur':
1988
+ case 'exposure':
1989
+ this.unselectBtn();
1990
+ this.currObjType.isFiltered = true;
1991
+ this.refreshToolbar('color', null, null, null, type);
1992
+ document.getElementById(this.element.id + '_' + type).classList.add('e-selected-btn');
1993
+ break;
1994
+ case 'filter':
1995
+ this.upperCanvas.style.display = 'block';
1996
+ this.refreshToolbar('filter');
1997
+ this.lowerContext.filter = this.initialAdjustmentValue;
1998
+ this.tempAdjustmentValue = this.lowerContext.filter;
1999
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
2000
+ this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
2001
+ for (var j = 0; j < this.objColl.length; j++) {
2002
+ this.apply(this.objColl[j].shape, this.objColl[j]);
2003
+ this.refreshActiveObj();
2004
+ }
2005
+ this.tempAdjustmentLevel = extend({}, this.adjustmentLevel, {}, true);
2006
+ this.tempFilter = this.currentFilter;
2007
+ this.tempSharpenFilter = this.adjustmentLevel.sharpen;
2008
+ this.tempBWFilter = this.adjustmentLevel.bw;
2009
+ break;
2010
+ case 'default':
2011
+ case 'chrome':
2012
+ case 'cold':
2013
+ case 'warm':
2014
+ case 'grayscale':
2015
+ case 'blackandwhite':
2016
+ case 'sepia':
2017
+ case 'invert':
2018
+ case 'sharpen':
2019
+ this.currObjType.isFiltered = true;
2020
+ this.setFilter(type);
2021
+ break;
1703
2022
  }
1704
2023
  }
1705
2024
  this.trigger('toolbarItemClicked', args);
1706
2025
  };
1707
- ImageEditor.prototype.cancelPan = function () {
1708
- this.applyActObj();
1709
- var panBtn = this.element.querySelector('.e-img-pan .e-btn');
1710
- panBtn.classList.remove('e-selected-btn');
1711
- this.pan(false);
1712
- };
1713
- ImageEditor.prototype.callMainToolbar = function (isApplyBtn, isZooming) {
1714
- if (this.factor === 1) {
1715
- this.refreshToolbar('main', isApplyBtn, false, isZooming);
1716
- }
1717
- else {
1718
- this.refreshToolbar('main', isApplyBtn, false, isZooming);
1719
- }
1720
- };
1721
- ImageEditor.prototype.cancelItems = function () {
1722
- var ratio = this.calcRatio();
2026
+ ImageEditor.prototype.okBtn = function () {
1723
2027
  var isCropSelection = false;
1724
2028
  var splitWords;
1725
2029
  if (this.activeObj.shape !== undefined) {
@@ -1731,107 +2035,795 @@ var ImageEditor = /** @class */ (function (_super) {
1731
2035
  else if (splitWords !== undefined && splitWords[0] === 'crop') {
1732
2036
  isCropSelection = true;
1733
2037
  }
1734
- if (this.togglePen) {
1735
- this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
1736
- this.togglePen = false;
1737
- this.upperCanvas.style.cursor = 'default';
1738
- this.penDrawColl = [];
1739
- this.imageEditorPointsColl = [];
2038
+ var selElem = this.element.querySelector('.e-contextual-toolbar-wrapper .e-toolbar-item.e-selected');
2039
+ if (selElem) {
2040
+ this.currentFilter = selElem.children[0].children[0].id.replace('Canvas', '');
1740
2041
  }
1741
- else if (this.activeObj.shape === 'text') {
1742
- this.activeObj.strokeSettings = this.tempStrokeSettings;
1743
- this.activeObj.textSettings = this.tempTextSettings;
1744
- if (this.activeObj.keyHistory === 'Enter Text' && this.activeObj.activePoint.startX === this.textStartPoints.x
1745
- && this.activeObj.activePoint.startY === this.textStartPoints.y) {
1746
- this.refreshActiveObj();
1747
- this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
1748
- this.drawShapeText();
1749
- }
1750
- else {
1751
- this.redrawText(ratio);
1752
- this.redrawShape(this.activeObj);
1753
- if (!isCropSelection && this.activeObj.topLeftCircle !== undefined) {
1754
- this.applyActObj();
1755
- }
1756
- this.clearSelection();
1757
- }
1758
- this.tempTextSettings = { text: 'Enter Text', fontFamily: 'Arial', fontSize: null, bold: false, italic: false, underline: false };
2042
+ if (isCropSelection) {
2043
+ this.crop();
1759
2044
  }
1760
- else if (this.activeObj.shape === 'rectangle' || this.activeObj.shape === 'ellipse' || this.activeObj.shape === 'line') {
1761
- this.activeObj.strokeSettings = this.tempStrokeSettings;
1762
- this.redrawShape(this.activeObj);
1763
- this.applyActObj();
2045
+ else if (this.togglePen) {
2046
+ this.freeHandDraw(false);
2047
+ }
2048
+ else if (this.textBox.style.display === 'block') {
2049
+ this.redrawActObj();
2050
+ }
2051
+ else if (!isNullOrUndefined(document.querySelector('#' + this.element.id + '_sliderWrapper')) ||
2052
+ this.currObjType.isFiltered) {
2053
+ this.initialAdjustmentValue = this.canvasFilter = this.lowerContext.filter;
2054
+ this.currObjType.isFiltered = false;
1764
2055
  }
1765
2056
  else {
1766
- this.refreshActiveObj();
1767
- this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
2057
+ this.applyActObj();
1768
2058
  }
1769
- this.upperCanvas.style.cursor = 'default';
1770
- this.currObjType.isCustomCrop = false;
1771
- this.tempStrokeSettings = { strokeColor: '#fff', fillColor: '', strokeWidth: null };
1772
- this.callMainToolbar();
2059
+ this.callMainToolbar(false);
1773
2060
  };
1774
- ImageEditor.prototype.gradient = function (a, b) {
1775
- return (b.y - a.y) / (b.x - a.x);
2061
+ ImageEditor.prototype.unselectBtn = function () {
2062
+ if (document.querySelector('#' + this.element.id + '_brightness').classList.contains('e-selected-btn')) {
2063
+ document.querySelector('#' + this.element.id + '_brightness').classList.remove('e-selected-btn');
2064
+ }
2065
+ else if (document.querySelector('#' + this.element.id + '_contrast').classList.contains('e-selected-btn')) {
2066
+ document.querySelector('#' + this.element.id + '_contrast').classList.remove('e-selected-btn');
2067
+ }
2068
+ else if (document.querySelector('#' + this.element.id + '_hue').classList.contains('e-selected-btn')) {
2069
+ document.querySelector('#' + this.element.id + '_hue').classList.remove('e-selected-btn');
2070
+ }
2071
+ else if (document.querySelector('#' + this.element.id + '_saturation').classList.contains('e-selected-btn')) {
2072
+ document.querySelector('#' + this.element.id + '_saturation').classList.remove('e-selected-btn');
2073
+ }
2074
+ else if (document.querySelector('#' + this.element.id + '_opacity').classList.contains('e-selected-btn')) {
2075
+ document.querySelector('#' + this.element.id + '_opacity').classList.remove('e-selected-btn');
2076
+ }
2077
+ else if (document.querySelector('#' + this.element.id + '_blur').classList.contains('e-selected-btn')) {
2078
+ document.querySelector('#' + this.element.id + '_blur').classList.remove('e-selected-btn');
2079
+ }
2080
+ else if (document.querySelector('#' + this.element.id + '_exposure').classList.contains('e-selected-btn')) {
2081
+ document.querySelector('#' + this.element.id + '_exposure').classList.remove('e-selected-btn');
2082
+ }
1776
2083
  };
1777
- ImageEditor.prototype.applyPenDraw = function () {
1778
- if (this.togglePen && this.factor === 1 && !this.currObjType.isZoomed) {
1779
- this.apply();
1780
- this.penDrawColl = [];
1781
- this.imageEditorPointsColl = [];
2084
+ ImageEditor.prototype.refreshSlider = function () {
2085
+ var sliderWrapper = document.querySelector('#' + this.element.id + '_sliderWrapper');
2086
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
2087
+ var slider = document.querySelector('.e-slider');
2088
+ var hdrWrapper = document.querySelector('#' + this.element.id + '_headWrapper');
2089
+ if (hdrWrapper) {
2090
+ hdrWrapper.style.display = 'none';
1782
2091
  }
1783
- else {
1784
- var tempCanvas = this.lowerCanvas.appendChild(this.createElement('canvas', {
1785
- id: this.element.id + '_tempCanvas', attrs: { name: 'canvasImage' }
1786
- }));
1787
- var tempContext = tempCanvas.getContext('2d');
1788
- tempCanvas.width = this.lowerCanvas.width;
1789
- tempCanvas.height = this.lowerCanvas.height;
1790
- tempContext.drawImage(this.inMemoryCanvas, 0, 0);
1791
- this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
1792
- for (var i = 0; i < this.penDrawColl.length; i++) {
1793
- tempContext.lineWidth = 2 * this.penDrawColl[i].strokeWidth;
1794
- tempContext.strokeStyle = this.penDrawColl[i].strokeColor;
1795
- var nexP = void 0;
1796
- var preP = void 0;
1797
- var f = 0.3;
1798
- var t = 1;
1799
- tempContext.beginPath();
1800
- tempContext.moveTo(this.penDrawColl[i].points[0].x, this.penDrawColl[i].points[0].y);
1801
- var m = 0;
1802
- var dx1 = 0;
1803
- var dx2 = 0;
1804
- var dy1 = 0;
1805
- var dy2 = 0;
1806
- preP = this.penDrawColl[i].points[0];
1807
- for (var j = 1; j < this.penDrawColl[i].points.length; j++) {
1808
- var curP = this.penDrawColl[i].points[j];
1809
- nexP = this.penDrawColl[i].points[j + 1];
1810
- if (nexP) {
1811
- m = this.gradient(preP, nexP);
1812
- dx2 = (nexP.x - curP.x) * -f;
1813
- dy2 = dx2 * m * t;
1814
- }
1815
- else {
1816
- dx2 = 0;
1817
- dy2 = 0;
1818
- }
1819
- tempContext.bezierCurveTo(preP.x - dx1, preP.y - dy1, curP.x + dx2, curP.y + dy2, curP.x, curP.y);
1820
- dx1 = dx2;
1821
- dy1 = dy2;
1822
- preP = curP;
1823
- if (this.penDrawColl[i].points.length > 2) {
1824
- this.penDrawColl[i].points.shift();
1825
- }
1826
- tempContext.stroke();
2092
+ if (!isNullOrUndefined(sliderWrapper) && !isNullOrUndefined(slider)) {
2093
+ slider.ej2_instances[0].destroy();
2094
+ sliderWrapper.remove();
2095
+ }
2096
+ };
2097
+ ImageEditor.prototype.updateAdjustment = function (type, value, isPreview) {
2098
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
2099
+ var splitWords = this.lowerContext.filter.split(' ');
2100
+ var values = [];
2101
+ var opacityValue;
2102
+ var brightnessValue;
2103
+ if (splitWords[4] !== undefined) {
2104
+ opacityValue = parseFloat(splitWords[4].split('(')[1]);
2105
+ }
2106
+ if (splitWords[0] !== undefined) {
2107
+ brightnessValue = parseFloat(splitWords[0].split('(')[1]);
2108
+ }
2109
+ var brightness = this.getFilterValue(this.adjustmentLevel.brightness);
2110
+ var saturation = this.getFilterValue(this.adjustmentLevel.saturation);
2111
+ if (type !== 'brightness' && type !== 'contrast' && type !== 'hue' && type !== 'saturation' && type !== 'exposure'
2112
+ && type !== 'opacity' && type !== 'blur') {
2113
+ if (isNullOrUndefined(isPreview) && (this.adjustmentLevel.sharpen || this.adjustmentLevel.bw)) {
2114
+ if (this.adjustmentLevel.sharpen) {
2115
+ this.setSharpness(false);
2116
+ }
2117
+ else if (this.adjustmentLevel.bw) {
2118
+ this.setBlackAndWhiteFilter(false);
2119
+ }
2120
+ var temp_1 = this.lowerContext.filter;
2121
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
2122
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
2123
+ for (var i = 0; i < this.objColl.length; i++) {
2124
+ this.apply(this.objColl[i].shape, this.objColl[i]);
2125
+ this.refreshActiveObj();
1827
2126
  }
2127
+ this.lowerContext.filter = temp_1;
1828
2128
  }
1829
- this.penDrawColl = [];
1830
- this.imageEditorPointsColl = [];
1831
- this.togglePen = false;
1832
- var imgData = tempContext.getImageData(0, 0, tempCanvas.width, tempCanvas.height);
1833
- var tempObj = void 0;
1834
- for (var index = 0; index < this.imgDataColl.length; index++) {
2129
+ }
2130
+ if (brightness !== 1) {
2131
+ splitWords[4] = 'opacity(' + (opacityValue - 0.3) + ')';
2132
+ }
2133
+ var saturate;
2134
+ var bright;
2135
+ var contrast;
2136
+ var saturatePercentage;
2137
+ var saturatePercent;
2138
+ var tempFilter;
2139
+ var temp;
2140
+ switch (type) {
2141
+ case 'brightness':
2142
+ if (splitWords[3].split) {
2143
+ if (parseFloat(splitWords[3].split('(')[1]) !== 100) {
2144
+ value += 0.1;
2145
+ }
2146
+ }
2147
+ splitWords[0] = 'brightness(' + value + ')';
2148
+ this.adjustmentValue = splitWords.join(' ');
2149
+ break;
2150
+ case 'contrast':
2151
+ splitWords[1] = 'contrast(' + value + '%)';
2152
+ this.adjustmentValue = splitWords.join(' ');
2153
+ break;
2154
+ case 'hue':
2155
+ splitWords[2] = 'hue-rotate(' + value + 'deg)';
2156
+ this.adjustmentValue = splitWords.join(' ');
2157
+ break;
2158
+ case 'saturation':
2159
+ splitWords[3] = 'saturate(' + value + '%)';
2160
+ if (saturation !== 1) {
2161
+ splitWords[0] = 'brightness(' + (brightnessValue + 0.1) + ')';
2162
+ }
2163
+ this.adjustmentValue = splitWords.join(' ');
2164
+ break;
2165
+ case 'opacity':
2166
+ if (parseFloat(splitWords[0].split('(')[1]) !== 1) {
2167
+ value -= 0.2;
2168
+ }
2169
+ splitWords[4] = 'opacity(' + value + ')';
2170
+ this.adjustmentValue = splitWords.join(' ');
2171
+ break;
2172
+ case 'blur':
2173
+ splitWords[5] = 'blur(' + value + 'px)';
2174
+ this.adjustmentValue = splitWords.join(' ');
2175
+ break;
2176
+ case 'exposure':
2177
+ if (brightness !== 1) {
2178
+ splitWords[4] = 'opacity(' + (opacityValue - 0.3) + ')';
2179
+ }
2180
+ if (value > 1) {
2181
+ value -= 1;
2182
+ value += brightness;
2183
+ }
2184
+ else if (value < 1) {
2185
+ value = 1 - value;
2186
+ value = brightness - value;
2187
+ }
2188
+ splitWords[0] = 'brightness(' + value + ')';
2189
+ this.adjustmentValue = splitWords.join(' ');
2190
+ break;
2191
+ case 'chrome':
2192
+ saturate = this.getSaturationFilterValue(this.adjustmentLevel.saturation);
2193
+ saturate *= 100;
2194
+ value = saturate + (saturate * 0.4);
2195
+ splitWords[3] = 'saturate(' + value + '%)';
2196
+ values = this.adjustmentValue.split(' ');
2197
+ splitWords[0] = values[0];
2198
+ splitWords[1] = values[1];
2199
+ splitWords[2] = values[2];
2200
+ splitWords[4] = values[4];
2201
+ splitWords[5] = values[5];
2202
+ splitWords[6] = 'sepia(0%)';
2203
+ splitWords[7] = 'grayscale(0%)';
2204
+ splitWords[8] = 'invert(0%)';
2205
+ break;
2206
+ case 'cold':
2207
+ // Adjusting Brightness
2208
+ bright = this.getFilterValue(this.adjustmentLevel.brightness);
2209
+ bright *= 100;
2210
+ value = bright * 0.9;
2211
+ splitWords[0] = 'brightness(' + value + '%)';
2212
+ // Adjusting Contrast
2213
+ contrast = this.getFilterValue(this.adjustmentLevel.contrast);
2214
+ contrast *= 100;
2215
+ value = contrast + (contrast * 0.5);
2216
+ splitWords[1] = 'contrast(' + value + '%)';
2217
+ // Adjusting Saturation
2218
+ saturatePercentage = this.getSaturationFilterValue(this.adjustmentLevel.saturation);
2219
+ saturatePercentage *= 100;
2220
+ value = saturatePercentage;
2221
+ splitWords[3] = 'saturate(' + value + '%)';
2222
+ values = this.adjustmentValue.split(' ');
2223
+ splitWords[2] = values[2];
2224
+ splitWords[4] = values[4];
2225
+ splitWords[5] = values[5];
2226
+ splitWords[6] = 'sepia(0%)';
2227
+ splitWords[7] = 'grayscale(0%)';
2228
+ splitWords[8] = 'invert(0%)';
2229
+ break;
2230
+ case 'warm':
2231
+ saturatePercent = this.getSaturationFilterValue(this.adjustmentLevel.saturation);
2232
+ saturatePercent *= 100;
2233
+ value = saturatePercent + (saturatePercent * 0.4);
2234
+ splitWords[3] = 'saturate(' + value + '%)';
2235
+ splitWords[6] = 'sepia(25%)';
2236
+ values = this.adjustmentValue.split(' ');
2237
+ splitWords[0] = values[0];
2238
+ splitWords[1] = values[1];
2239
+ splitWords[2] = values[2];
2240
+ splitWords[4] = values[4];
2241
+ splitWords[5] = values[5];
2242
+ splitWords[7] = 'grayscale(0%)';
2243
+ splitWords[8] = 'invert(0%)';
2244
+ break;
2245
+ case 'grayscale':
2246
+ splitWords[7] = 'grayscale(100%)';
2247
+ values = this.adjustmentValue.split(' ');
2248
+ splitWords[0] = values[0];
2249
+ splitWords[1] = values[1];
2250
+ splitWords[2] = values[2];
2251
+ splitWords[3] = values[3];
2252
+ splitWords[4] = values[4];
2253
+ splitWords[5] = values[5];
2254
+ splitWords[6] = 'sepia(0%)';
2255
+ splitWords[8] = 'invert(0%)';
2256
+ break;
2257
+ case 'blackandwhite':
2258
+ values = this.adjustmentValue.split(' ');
2259
+ if (isPreview) {
2260
+ tempFilter = this.lowerContext.filter;
2261
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
2262
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
2263
+ this.setBlackAndWhiteFilter(true);
2264
+ for (var i = 0; i < this.objColl.length; i++) {
2265
+ this.apply(this.objColl[i].shape, this.objColl[i]);
2266
+ this.refreshActiveObj();
2267
+ }
2268
+ splitWords[0] = values[0];
2269
+ splitWords[1] = values[1];
2270
+ splitWords[2] = values[2];
2271
+ splitWords[3] = values[3];
2272
+ splitWords[4] = values[4];
2273
+ splitWords[5] = values[5];
2274
+ splitWords[6] = 'sepia(0%)';
2275
+ splitWords[7] = 'grayscale(0%)';
2276
+ splitWords[8] = 'invert(0%)';
2277
+ }
2278
+ else {
2279
+ tempFilter = this.lowerContext.filter;
2280
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
2281
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
2282
+ this.setBlackAndWhiteFilter(true);
2283
+ splitWords[0] = values[0];
2284
+ splitWords[1] = values[1];
2285
+ splitWords[2] = values[2];
2286
+ splitWords[3] = values[3];
2287
+ splitWords[4] = values[4];
2288
+ splitWords[5] = values[5];
2289
+ splitWords[6] = 'sepia(0%)';
2290
+ splitWords[7] = 'grayscale(0%)';
2291
+ splitWords[8] = 'invert(0%)';
2292
+ this.lowerContext.filter = this.initialAdjustmentValue = splitWords.join(' ');
2293
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
2294
+ this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
2295
+ tempFilter = this.lowerContext.filter;
2296
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
2297
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
2298
+ for (var i = 0; i < this.objColl.length; i++) {
2299
+ this.apply(this.objColl[i].shape, this.objColl[i]);
2300
+ this.refreshActiveObj();
2301
+ }
2302
+ this.lowerContext.filter = tempFilter;
2303
+ }
2304
+ break;
2305
+ case 'sepia':
2306
+ splitWords[6] = 'sepia(100%)';
2307
+ values = this.adjustmentValue.split(' ');
2308
+ splitWords[0] = values[0];
2309
+ splitWords[1] = values[1];
2310
+ splitWords[2] = values[2];
2311
+ splitWords[3] = values[3];
2312
+ splitWords[4] = values[4];
2313
+ splitWords[5] = values[5];
2314
+ splitWords[7] = 'grayscale(0%)';
2315
+ splitWords[8] = 'invert(0%)';
2316
+ break;
2317
+ case 'invert':
2318
+ splitWords[8] = 'invert(100%)';
2319
+ values = this.adjustmentValue.split(' ');
2320
+ splitWords[0] = values[0];
2321
+ splitWords[1] = values[1];
2322
+ splitWords[2] = values[2];
2323
+ splitWords[3] = values[3];
2324
+ splitWords[4] = values[4];
2325
+ splitWords[5] = values[5];
2326
+ splitWords[6] = 'sepia(0%)';
2327
+ splitWords[7] = 'grayscale(0%)';
2328
+ break;
2329
+ case 'sharpen':
2330
+ values = this.adjustmentValue.split(' ');
2331
+ if (isPreview) {
2332
+ temp = this.lowerContext.filter;
2333
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
2334
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
2335
+ for (var i = 0; i < this.objColl.length; i++) {
2336
+ this.apply(this.objColl[i].shape, this.objColl[i]);
2337
+ this.refreshActiveObj();
2338
+ }
2339
+ splitWords[0] = values[0];
2340
+ splitWords[1] = values[1];
2341
+ splitWords[2] = values[2];
2342
+ splitWords[3] = values[3];
2343
+ splitWords[4] = values[4];
2344
+ splitWords[5] = values[5];
2345
+ splitWords[6] = 'sepia(0%)';
2346
+ splitWords[7] = 'grayscale(0%)';
2347
+ splitWords[8] = 'invert(0%)';
2348
+ }
2349
+ else {
2350
+ temp = this.lowerContext.filter;
2351
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
2352
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
2353
+ this.setSharpness(true);
2354
+ splitWords[0] = values[0];
2355
+ splitWords[1] = values[1];
2356
+ splitWords[2] = values[2];
2357
+ splitWords[3] = values[3];
2358
+ splitWords[4] = values[4];
2359
+ splitWords[5] = values[5];
2360
+ splitWords[6] = 'sepia(0%)';
2361
+ splitWords[7] = 'grayscale(0%)';
2362
+ splitWords[8] = 'invert(0%)';
2363
+ this.lowerContext.filter = this.initialAdjustmentValue = splitWords.join(' ');
2364
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
2365
+ this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
2366
+ temp = this.lowerContext.filter;
2367
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
2368
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
2369
+ for (var i = 0; i < this.objColl.length; i++) {
2370
+ this.apply(this.objColl[i].shape, this.objColl[i]);
2371
+ this.refreshActiveObj();
2372
+ }
2373
+ this.lowerContext.filter = temp;
2374
+ }
2375
+ break;
2376
+ }
2377
+ if (type !== 'sharpen' && type !== 'blackandwhite') {
2378
+ if (isNullOrUndefined(isPreview)) {
2379
+ if (type === 'default') {
2380
+ splitWords = this.getDefaultFilter(splitWords);
2381
+ }
2382
+ this.lowerContext.filter = splitWords.join(' ');
2383
+ }
2384
+ splitWords = this.setTempFilterValue(brightness, isPreview, splitWords, type);
2385
+ this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
2386
+ if (brightness !== 1) {
2387
+ splitWords[4] = 'opacity(' + opacityValue + ')';
2388
+ }
2389
+ else if (saturation !== 1) {
2390
+ splitWords[0] = 'brightness(' + brightnessValue + ')';
2391
+ }
2392
+ if (type === 'exposure' && brightness !== 1) {
2393
+ splitWords[0] = 'brightness(' + brightnessValue + ')';
2394
+ }
2395
+ splitWords = this.setTempFilterValue(brightness, isPreview, splitWords, type);
2396
+ if (isNullOrUndefined(isPreview)) {
2397
+ this.lowerContext.filter = this.initialAdjustmentValue = splitWords.join(' ');
2398
+ }
2399
+ var tempFilter_1 = this.lowerContext.filter;
2400
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
2401
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
2402
+ for (var i = 0; i < this.objColl.length; i++) {
2403
+ this.apply(this.objColl[i].shape, this.objColl[i]);
2404
+ this.refreshActiveObj();
2405
+ }
2406
+ this.lowerContext.filter = tempFilter_1;
2407
+ if (brightness === 1) {
2408
+ this.isBrightnessAdjusted = false;
2409
+ }
2410
+ else {
2411
+ this.isBrightnessAdjusted = true;
2412
+ }
2413
+ }
2414
+ var filter = splitWords.join(' ');
2415
+ return filter;
2416
+ };
2417
+ ImageEditor.prototype.updateBrightnessFilter = function () {
2418
+ var splitWords = this.lowerContext.filter.split(' ');
2419
+ if (this.isBrightnessAdjusted && splitWords.length > 0 && !isNullOrUndefined(splitWords[4])) {
2420
+ var opacityValue = parseFloat(splitWords[4].split('(')[1]);
2421
+ splitWords[4] = 'opacity(' + (opacityValue - 0.3) + ')';
2422
+ this.lowerContext.filter = splitWords.join(' ');
2423
+ }
2424
+ };
2425
+ ImageEditor.prototype.autoEnablePan = function () {
2426
+ if (this.factor > 0.95 && this.factor < 1.05) {
2427
+ this.dragCanvas = this.togglePan = false;
2428
+ this.callMainToolbar(false, true);
2429
+ this.pan(false);
2430
+ this.disablePan = false;
2431
+ }
2432
+ else if (!this.disablePan) {
2433
+ this.pan(true);
2434
+ }
2435
+ else if (this.disablePan) {
2436
+ this.pan(false);
2437
+ }
2438
+ };
2439
+ ImageEditor.prototype.setTempFilterValue = function (brightness, isPreview, splitWords, type) {
2440
+ if (isPreview && brightness !== 1) {
2441
+ var tempSplitWords = this.lowerContext.filter.split(' ');
2442
+ tempSplitWords[4] = splitWords[4];
2443
+ this.lowerContext.filter = tempSplitWords.join(' ');
2444
+ }
2445
+ else if (isPreview && type === 'default') {
2446
+ splitWords = this.getDefaultFilter(splitWords);
2447
+ }
2448
+ return splitWords;
2449
+ };
2450
+ ImageEditor.prototype.getDefaultFilter = function (splitWords) {
2451
+ var values = this.adjustmentValue.split(' ');
2452
+ splitWords[0] = values[0];
2453
+ splitWords[1] = values[1];
2454
+ splitWords[2] = values[2];
2455
+ splitWords[3] = values[3];
2456
+ splitWords[4] = values[4];
2457
+ splitWords[5] = values[5];
2458
+ splitWords[6] = 'sepia(0%)';
2459
+ splitWords[7] = 'grayscale(0%)';
2460
+ splitWords[8] = 'invert(0%)';
2461
+ return splitWords;
2462
+ };
2463
+ ImageEditor.prototype.setAdjustment = function (type) {
2464
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
2465
+ var splitWords = this.lowerContext.filter.split(' ');
2466
+ var value;
2467
+ var valueArr;
2468
+ switch (type) {
2469
+ case 'brightness':
2470
+ valueArr = splitWords[0].split('(');
2471
+ value = parseFloat(valueArr[1].split(')')[0]);
2472
+ this.adjustmentLevel.brightness = this.setFilterValue(value);
2473
+ break;
2474
+ case 'contrast':
2475
+ valueArr = splitWords[1].split('(');
2476
+ value = parseFloat(valueArr[1].split(')')[0]);
2477
+ value /= 100;
2478
+ this.adjustmentLevel.contrast = this.setFilterValue(value);
2479
+ break;
2480
+ case 'hue':
2481
+ valueArr = splitWords[2].split('(');
2482
+ value = parseFloat(valueArr[1].split(')')[0]);
2483
+ value /= 3;
2484
+ this.adjustmentLevel.hue = value;
2485
+ break;
2486
+ case 'saturation':
2487
+ valueArr = splitWords[3].split('(');
2488
+ value = parseFloat(valueArr[1].split(')')[0]);
2489
+ value /= 100;
2490
+ this.adjustmentLevel.saturation = this.setSaturationFilterValue(value);
2491
+ break;
2492
+ case 'opacity':
2493
+ valueArr = splitWords[4].split('(');
2494
+ value = parseFloat(valueArr[1].split(')')[0]);
2495
+ if (value === 0.45) {
2496
+ value = 40;
2497
+ }
2498
+ else if (value === 0.40) {
2499
+ value = 30;
2500
+ }
2501
+ else if (value === 0.35) {
2502
+ value = 20;
2503
+ }
2504
+ else if (value === 0.30) {
2505
+ value = 10;
2506
+ }
2507
+ else if (value === 0.25) {
2508
+ value = 0;
2509
+ }
2510
+ else {
2511
+ value *= 100;
2512
+ }
2513
+ this.adjustmentLevel.opacity = value;
2514
+ break;
2515
+ case 'blur':
2516
+ valueArr = splitWords[5].split('(');
2517
+ value = parseFloat(valueArr[1].split(')')[0]);
2518
+ value *= 20;
2519
+ this.adjustmentLevel.blur = value;
2520
+ break;
2521
+ case 'exposure':
2522
+ valueArr = splitWords[0].split('(');
2523
+ value = parseFloat(valueArr[1].split(')')[0]);
2524
+ this.adjustmentLevel.exposure = this.setFilterValue(value);
2525
+ break;
2526
+ }
2527
+ var temp = this.lowerContext.filter;
2528
+ this.updateBrightnessFilter();
2529
+ this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
2530
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
2531
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
2532
+ for (var j = 0; j < this.objColl.length; j++) {
2533
+ this.apply(this.objColl[j].shape, this.objColl[j]);
2534
+ this.refreshActiveObj();
2535
+ }
2536
+ this.lowerContext.filter = temp;
2537
+ };
2538
+ ImageEditor.prototype.renderSlider = function (type) {
2539
+ var _this = this;
2540
+ var canvasWrapper = document.querySelector('#' + this.element.id + '_contextualToolbarArea');
2541
+ var hdrWrapper = document.querySelector('#' + this.element.id + '_headWrapper');
2542
+ var labelWrapper = document.querySelector('#' + this.element.id + '_labelWrapper');
2543
+ if (!hdrWrapper && !isNullOrUndefined(canvasWrapper)) {
2544
+ hdrWrapper = canvasWrapper.appendChild(this.createElement('div', {
2545
+ id: this.element.id + '_headWrapper',
2546
+ styles: 'position: relative'
2547
+ }));
2548
+ labelWrapper = hdrWrapper.appendChild(this.createElement('label', {
2549
+ id: this.element.id + '_labelWrapper',
2550
+ styles: Browser.isDevice ? 'position: absolute; top: 25%; left: calc(50% - 150px); font-size: 15px; text-transform: capitalize; font-weight: 400;'
2551
+ : 'position: absolute; top: 25%; left: calc(50% - 226px); font-size: 15px; text-transform: capitalize; font-weight: 400;'
2552
+ }));
2553
+ }
2554
+ else {
2555
+ hdrWrapper.style.display = 'block';
2556
+ }
2557
+ labelWrapper.textContent = this.l10n.getConstant(this.toPascalCase(type));
2558
+ var sliderWrapper = hdrWrapper.appendChild(this.createElement('div', {
2559
+ id: this.element.id + '_sliderWrapper',
2560
+ styles: 'position: absolute'
2561
+ }));
2562
+ var value = this.getCurrAdjustmentValue(type);
2563
+ var min;
2564
+ var max;
2565
+ var slider;
2566
+ if (type === 'brightness' || type === 'contrast' || type === 'saturation' || type === 'exposure') {
2567
+ if (this.finetuneSettings) {
2568
+ if (type === 'brightness' && this.finetuneSettings.brightness) {
2569
+ min = this.finetuneSettings.brightness.min;
2570
+ max = this.finetuneSettings.brightness.max;
2571
+ }
2572
+ else if (type === 'contrast' && this.finetuneSettings.contrast) {
2573
+ min = this.finetuneSettings.contrast.min;
2574
+ max = this.finetuneSettings.contrast.max;
2575
+ }
2576
+ else if (type === 'saturation' && this.finetuneSettings.saturation) {
2577
+ min = this.finetuneSettings.saturation.min;
2578
+ max = this.finetuneSettings.saturation.max;
2579
+ }
2580
+ else if (type === 'exposure' && this.finetuneSettings.exposure) {
2581
+ min = this.finetuneSettings.exposure.min;
2582
+ max = this.finetuneSettings.exposure.max;
2583
+ }
2584
+ else {
2585
+ min = -100;
2586
+ max = 100;
2587
+ }
2588
+ }
2589
+ else {
2590
+ min = -100;
2591
+ max = 100;
2592
+ }
2593
+ slider = new Slider({
2594
+ value: value,
2595
+ tooltip: { isVisible: true, placement: 'Before', showOn: 'Always' },
2596
+ type: 'MinRange',
2597
+ min: min,
2598
+ max: max,
2599
+ step: 10,
2600
+ width: Browser.isDevice ? '200px' : '300px',
2601
+ cssClass: 'e-slider',
2602
+ change: function (args) {
2603
+ _this.setCurrAdjustmentValue(type, args.value);
2604
+ }
2605
+ });
2606
+ }
2607
+ else if (type === 'hue' || type === 'blur' || type === 'opacity') {
2608
+ if (this.finetuneSettings) {
2609
+ if (type === 'hue' && this.finetuneSettings.hue) {
2610
+ min = this.finetuneSettings.hue.min;
2611
+ max = this.finetuneSettings.hue.max;
2612
+ }
2613
+ else if (type === 'blur' && this.finetuneSettings.blur) {
2614
+ min = this.finetuneSettings.blur.min;
2615
+ max = this.finetuneSettings.blur.max;
2616
+ }
2617
+ else if (type === 'opacity' && this.finetuneSettings.opacity) {
2618
+ min = this.finetuneSettings.opacity.min;
2619
+ max = this.finetuneSettings.opacity.max;
2620
+ }
2621
+ else {
2622
+ min = 0;
2623
+ max = 100;
2624
+ }
2625
+ }
2626
+ else {
2627
+ min = 0;
2628
+ max = 100;
2629
+ }
2630
+ slider = new Slider({
2631
+ value: value,
2632
+ tooltip: { isVisible: true, placement: 'Before', showOn: 'Always' },
2633
+ type: 'MinRange',
2634
+ min: min,
2635
+ max: max,
2636
+ step: 10,
2637
+ width: Browser.isDevice ? '200px' : '300px',
2638
+ cssClass: 'e-slider',
2639
+ change: function (args) {
2640
+ _this.setCurrAdjustmentValue(type, args.value);
2641
+ }
2642
+ });
2643
+ }
2644
+ slider.appendTo('#' + this.element.id + '_sliderWrapper');
2645
+ sliderWrapper.style.left = (parseFloat(canvasWrapper.style.width) - parseFloat(slider.width)) / 2 + 'px';
2646
+ };
2647
+ ImageEditor.prototype.getCurrAdjustmentValue = function (type) {
2648
+ var value;
2649
+ switch (type) {
2650
+ case 'brightness':
2651
+ value = this.adjustmentLevel.brightness;
2652
+ break;
2653
+ case 'contrast':
2654
+ value = this.adjustmentLevel.contrast;
2655
+ break;
2656
+ case 'hue':
2657
+ value = this.adjustmentLevel.hue;
2658
+ break;
2659
+ case 'saturation':
2660
+ value = this.adjustmentLevel.saturation;
2661
+ break;
2662
+ case 'opacity':
2663
+ value = this.adjustmentLevel.opacity;
2664
+ break;
2665
+ case 'blur':
2666
+ value = this.adjustmentLevel.blur;
2667
+ break;
2668
+ case 'exposure':
2669
+ value = this.adjustmentLevel.exposure;
2670
+ break;
2671
+ }
2672
+ return value;
2673
+ };
2674
+ ImageEditor.prototype.setCurrAdjustmentValue = function (type, value) {
2675
+ var fineTuneValueChanging = { finetune: this.toPascalCase(type), value: value };
2676
+ this.trigger('fineTuneValueChanging', fineTuneValueChanging);
2677
+ switch (type) {
2678
+ case 'brightness':
2679
+ this.setBrightness(value);
2680
+ break;
2681
+ case 'contrast':
2682
+ this.setContrast(value);
2683
+ break;
2684
+ case 'hue':
2685
+ this.setHue(value);
2686
+ break;
2687
+ case 'saturation':
2688
+ this.setSaturation(value);
2689
+ break;
2690
+ case 'opacity':
2691
+ this.setOpacity(value);
2692
+ break;
2693
+ case 'blur':
2694
+ this.setBlur(value);
2695
+ break;
2696
+ case 'exposure':
2697
+ this.setExposure(value);
2698
+ break;
2699
+ }
2700
+ };
2701
+ ImageEditor.prototype.cancelPan = function () {
2702
+ this.applyActObj();
2703
+ var panBtn = this.element.querySelector('.e-img-pan .e-btn');
2704
+ panBtn.classList.remove('e-selected-btn');
2705
+ this.pan(false);
2706
+ };
2707
+ ImageEditor.prototype.callMainToolbar = function (isApplyBtn, isZooming) {
2708
+ this.refreshToolbar('main', isApplyBtn, false, isZooming);
2709
+ };
2710
+ ImageEditor.prototype.cancelItems = function () {
2711
+ var ratio = this.calcRatio();
2712
+ var isCropSelection = false;
2713
+ var splitWords;
2714
+ if (this.activeObj.shape !== undefined) {
2715
+ splitWords = this.activeObj.shape.split('-');
2716
+ }
2717
+ if (splitWords === undefined && this.currObjType.isCustomCrop) {
2718
+ isCropSelection = true;
2719
+ }
2720
+ else if (splitWords !== undefined && splitWords[0] === 'crop') {
2721
+ isCropSelection = true;
2722
+ }
2723
+ if (this.togglePen) {
2724
+ this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
2725
+ this.togglePen = false;
2726
+ this.upperCanvas.style.cursor = 'default';
2727
+ this.penDrawColl = [];
2728
+ this.imageEditorPointsColl = [];
2729
+ }
2730
+ else if (this.activeObj.shape === 'text') {
2731
+ this.activeObj.strokeSettings = this.tempStrokeSettings;
2732
+ this.activeObj.textSettings = this.tempTextSettings;
2733
+ if (this.activeObj.keyHistory === 'Enter Text' && this.activeObj.activePoint.startX === this.textStartPoints.x
2734
+ && this.activeObj.activePoint.startY === this.textStartPoints.y) {
2735
+ this.refreshActiveObj();
2736
+ this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
2737
+ this.drawShapeText();
2738
+ }
2739
+ else {
2740
+ this.redrawText(ratio);
2741
+ this.redrawShape(this.activeObj);
2742
+ if (!isCropSelection && this.activeObj.topLeftCircle !== undefined) {
2743
+ this.applyActObj();
2744
+ }
2745
+ this.clearSelection();
2746
+ }
2747
+ this.tempTextSettings = { text: 'Enter Text', fontFamily: 'Arial', fontSize: null, bold: false, italic: false, underline: false };
2748
+ }
2749
+ else if (this.activeObj.shape === 'rectangle' || this.activeObj.shape === 'ellipse' || this.activeObj.shape === 'line') {
2750
+ this.activeObj.strokeSettings = this.tempStrokeSettings;
2751
+ this.redrawShape(this.activeObj);
2752
+ this.applyActObj();
2753
+ }
2754
+ else {
2755
+ this.refreshActiveObj();
2756
+ this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
2757
+ }
2758
+ this.upperCanvas.style.cursor = 'default';
2759
+ this.currObjType.isCustomCrop = false;
2760
+ this.tempStrokeSettings = { strokeColor: '#fff', fillColor: '', strokeWidth: null };
2761
+ this.callMainToolbar();
2762
+ };
2763
+ ImageEditor.prototype.gradient = function (a, b) {
2764
+ return (b.y - a.y) / (b.x - a.x);
2765
+ };
2766
+ ImageEditor.prototype.applyPenDraw = function () {
2767
+ if (this.togglePen && this.factor === 1 && !this.currObjType.isZoomed) {
2768
+ this.apply();
2769
+ this.penDrawColl = [];
2770
+ this.imageEditorPointsColl = [];
2771
+ }
2772
+ else {
2773
+ var tempCanvas = this.lowerCanvas.appendChild(this.createElement('canvas', {
2774
+ id: this.element.id + '_tempCanvas', attrs: { name: 'canvasImage' }
2775
+ }));
2776
+ var tempContext = tempCanvas.getContext('2d');
2777
+ tempCanvas.width = this.lowerCanvas.width;
2778
+ tempCanvas.height = this.lowerCanvas.height;
2779
+ var temp = this.lowerContext.filter;
2780
+ this.updateBrightnessFilter();
2781
+ tempContext.drawImage(this.inMemoryCanvas, 0, 0);
2782
+ this.lowerContext.filter = temp;
2783
+ this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
2784
+ for (var i = 0; i < this.penDrawColl.length; i++) {
2785
+ tempContext.lineWidth = 2 * this.penDrawColl[i].strokeWidth;
2786
+ tempContext.strokeStyle = this.penDrawColl[i].strokeColor;
2787
+ var nexP = void 0;
2788
+ var preP = void 0;
2789
+ var f = 0.3;
2790
+ var t = 1;
2791
+ tempContext.beginPath();
2792
+ tempContext.moveTo(this.penDrawColl[i].points[0].x, this.penDrawColl[i].points[0].y);
2793
+ var m = 0;
2794
+ var dx1 = 0;
2795
+ var dx2 = 0;
2796
+ var dy1 = 0;
2797
+ var dy2 = 0;
2798
+ preP = this.penDrawColl[i].points[0];
2799
+ for (var j = 1; j < this.penDrawColl[i].points.length; j++) {
2800
+ var curP = this.penDrawColl[i].points[j];
2801
+ nexP = this.penDrawColl[i].points[j + 1];
2802
+ if (nexP) {
2803
+ m = this.gradient(preP, nexP);
2804
+ dx2 = (nexP.x - curP.x) * -f;
2805
+ dy2 = dx2 * m * t;
2806
+ }
2807
+ else {
2808
+ dx2 = 0;
2809
+ dy2 = 0;
2810
+ }
2811
+ tempContext.bezierCurveTo(preP.x - dx1, preP.y - dy1, curP.x + dx2, curP.y + dy2, curP.x, curP.y);
2812
+ dx1 = dx2;
2813
+ dy1 = dy2;
2814
+ preP = curP;
2815
+ if (this.penDrawColl[i].points.length > 2) {
2816
+ this.penDrawColl[i].points.shift();
2817
+ }
2818
+ tempContext.stroke();
2819
+ }
2820
+ }
2821
+ this.penDrawColl = [];
2822
+ this.imageEditorPointsColl = [];
2823
+ this.togglePen = false;
2824
+ var imgData = tempContext.getImageData(0, 0, tempCanvas.width, tempCanvas.height);
2825
+ var tempObj = void 0;
2826
+ for (var index = 0; index < this.imgDataColl.length; index++) {
1835
2827
  if (this.imgDataColl[index].operation !== 'freehanddraw') {
1836
2828
  tempObj = this.imgDataColl[index];
1837
2829
  break;
@@ -1845,24 +2837,37 @@ var ImageEditor = /** @class */ (function (_super) {
1845
2837
  this.inMemoryCanvas.height = imgData.height;
1846
2838
  this.inMemoryContext.putImageData(imgData, 0, 0);
1847
2839
  this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
1848
- this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
1849
- for (var j = 0; j < this.objColl.length; j++) {
1850
- this.apply(this.objColl[j].shape, this.objColl[j]);
1851
- this.refreshActiveObj();
1852
- }
2840
+ this.redrawImgWithObj();
1853
2841
  this.currObjType.isZoomed = false;
1854
2842
  }
1855
2843
  };
1856
- ImageEditor.prototype.refreshToolbar = function (type, isApplyBtn, isCropping, isZooming) {
1857
- var args = { toolbarType: type };
1858
- if (document.getElementById(this.element.id + '_toolbar') && this.defToolbarItems.length > 0) {
1859
- getComponent(document.getElementById(this.element.id + '_toolbar'), 'toolbar').destroy();
2844
+ ImageEditor.prototype.redrawImgWithObj = function () {
2845
+ this.lowerContext.filter = this.canvasFilter;
2846
+ var temp = this.lowerContext.filter;
2847
+ this.updateBrightnessFilter();
2848
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
2849
+ this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
2850
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
2851
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
2852
+ for (var j = 0; j < this.objColl.length; j++) {
2853
+ this.apply(this.objColl[j].shape, this.objColl[j]);
2854
+ this.refreshActiveObj();
1860
2855
  }
1861
- if (document.getElementById(this.element.id + '_bottomToolbar') && this.defToolbarItems.length > 0) {
1862
- if (document.getElementById(this.element.id + '_bottomToolbar').className.indexOf('e-control') > -1) {
1863
- getComponent(document.getElementById(this.element.id + '_bottomToolbar'), 'toolbar').destroy();
2856
+ this.lowerContext.filter = temp;
2857
+ };
2858
+ ImageEditor.prototype.refreshToolbar = function (type, isApplyBtn, isCropping, isZooming, cType) {
2859
+ var args = { toolbarType: type };
2860
+ if (type !== 'filter' && type !== 'color') {
2861
+ if (document.getElementById(this.element.id + '_toolbar') && this.defToolbarItems.length > 0) {
2862
+ getComponent(document.getElementById(this.element.id + '_toolbar'), 'toolbar').destroy();
2863
+ }
2864
+ if (document.getElementById(this.element.id + '_bottomToolbar') && this.defToolbarItems.length > 0) {
2865
+ if (document.getElementById(this.element.id + '_bottomToolbar').className.indexOf('e-control') > -1) {
2866
+ getComponent(document.getElementById(this.element.id + '_bottomToolbar'), 'toolbar').destroy();
2867
+ }
1864
2868
  }
1865
2869
  }
2870
+ this.refreshSlider();
1866
2871
  switch (type) {
1867
2872
  case 'main':
1868
2873
  if (Browser.isDevice) {
@@ -1912,7 +2917,104 @@ var ImageEditor = /** @class */ (function (_super) {
1912
2917
  case 'pan':
1913
2918
  this.initZoomToolbarItem();
1914
2919
  break;
2920
+ case 'adjustment':
2921
+ if (Browser.isDevice) {
2922
+ this.initToolbarItem(false, true, true);
2923
+ }
2924
+ this.initAdjustmentToolbarItem();
2925
+ break;
2926
+ case 'filter':
2927
+ this.updateContextualToolbar(type);
2928
+ break;
2929
+ case 'color':
2930
+ this.updateContextualToolbar(type, cType);
2931
+ break;
2932
+ }
2933
+ };
2934
+ ImageEditor.prototype.getAdjustmentToolbarItem = function () {
2935
+ var toolbarItems = [];
2936
+ if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Brightness') > -1)) {
2937
+ toolbarItems.push({ id: this.element.id + '_brightness', prefixIcon: 'e-icons e-brightness', cssClass: 'top-icon e-brightness',
2938
+ tooltipText: this.l10n.getConstant('Brightness'), align: 'Center' });
2939
+ }
2940
+ if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Contrast') > -1)) {
2941
+ toolbarItems.push({ id: this.element.id + '_contrast', prefixIcon: 'e-icons e-contrast', cssClass: 'top-icon e-contrast',
2942
+ tooltipText: this.l10n.getConstant('Contrast'), align: 'Center' });
2943
+ }
2944
+ if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Hue') > -1)) {
2945
+ toolbarItems.push({ id: this.element.id + '_hue', prefixIcon: 'e-icons e-fade', cssClass: 'top-icon e-fade',
2946
+ tooltipText: this.l10n.getConstant('Hue'), align: 'Center' });
2947
+ }
2948
+ if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Saturation') > -1)) {
2949
+ toolbarItems.push({ id: this.element.id + '_saturation', prefixIcon: 'e-icons e-saturation', cssClass: 'top-icon e-saturation',
2950
+ tooltipText: this.l10n.getConstant('Saturation'), align: 'Center' });
2951
+ }
2952
+ if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Exposure') > -1)) {
2953
+ toolbarItems.push({ id: this.element.id + '_exposure', prefixIcon: 'e-icons e-grain', cssClass: 'top-icon e-grain',
2954
+ tooltipText: this.l10n.getConstant('Exposure'), align: 'Center' });
2955
+ }
2956
+ if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Opacity') > -1)) {
2957
+ toolbarItems.push({ id: this.element.id + '_opacity', prefixIcon: 'e-icons e-opacity', cssClass: 'top-icon e-opacity',
2958
+ tooltipText: this.l10n.getConstant('Opacity'), align: 'Center' });
2959
+ }
2960
+ if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Blur') > -1)) {
2961
+ toolbarItems.push({ id: this.element.id + '_blur', prefixIcon: 'e-icons e-tint', cssClass: 'top-icon e-tint',
2962
+ tooltipText: this.l10n.getConstant('Blur'), align: 'Center' });
2963
+ }
2964
+ var tempToolbarItems = this.processToolbar('center');
2965
+ for (var i = 0, len = tempToolbarItems.length; i < len; i++) {
2966
+ toolbarItems.push(tempToolbarItems[i]);
2967
+ }
2968
+ if (!Browser.isDevice) {
2969
+ toolbarItems.push({ id: this.element.id + '_ok', prefixIcon: 'e-icons e-check', cssClass: 'top-icon e-tick',
2970
+ tooltipText: this.l10n.getConstant('OK'), align: 'Right' });
2971
+ toolbarItems.push({ id: this.element.id + '_cancel', prefixIcon: 'e-icons e-close', cssClass: 'top-icon e-save',
2972
+ tooltipText: this.l10n.getConstant('Cancel'), align: 'Right' });
2973
+ }
2974
+ return toolbarItems;
2975
+ };
2976
+ ImageEditor.prototype.getFilterToolbarItem = function () {
2977
+ var toolbarItems = [];
2978
+ if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Default') > -1)) {
2979
+ toolbarItems.push({ id: this.element.id + '_default', prefixIcon: 'e-icons e-none', cssClass: 'top-icon e-none',
2980
+ tooltipText: this.l10n.getConstant('Default'), align: 'Center',
2981
+ 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>' });
2982
+ }
2983
+ if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Chrome') > -1)) {
2984
+ toolbarItems.push({ id: this.element.id + '_chrome', prefixIcon: 'e-icons e-none', cssClass: 'top-icon e-none',
2985
+ tooltipText: this.l10n.getConstant('Chrome'), align: 'Center',
2986
+ 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>' });
2987
+ }
2988
+ if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Cold') > -1)) {
2989
+ toolbarItems.push({ id: this.element.id + '_cold', prefixIcon: 'e-icons e-none', cssClass: 'top-icon e-none',
2990
+ tooltipText: this.l10n.getConstant('Cold'), align: 'Center',
2991
+ 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>' });
2992
+ }
2993
+ if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Warm') > -1)) {
2994
+ toolbarItems.push({ id: this.element.id + '_warm', prefixIcon: 'e-icons e-none', cssClass: 'top-icon e-none',
2995
+ tooltipText: this.l10n.getConstant('Warm'), align: 'Center',
2996
+ 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>' });
2997
+ }
2998
+ if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Grayscale') > -1)) {
2999
+ toolbarItems.push({ id: this.element.id + '_grayscale', prefixIcon: 'e-icons e-none', cssClass: 'top-icon e-none',
3000
+ tooltipText: this.l10n.getConstant('Grayscale'), align: 'Center',
3001
+ 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>' });
3002
+ }
3003
+ if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Sepia') > -1)) {
3004
+ toolbarItems.push({ id: this.element.id + '_sepia', prefixIcon: 'e-icons e-none', cssClass: 'top-icon e-none',
3005
+ tooltipText: this.l10n.getConstant('Sepia'), align: 'Center',
3006
+ 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>' });
3007
+ }
3008
+ if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Invert') > -1)) {
3009
+ toolbarItems.push({ id: this.element.id + '_invert', prefixIcon: 'e-icons e-none', cssClass: 'top-icon e-none',
3010
+ tooltipText: this.l10n.getConstant('Invert'), align: 'Center',
3011
+ 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>' });
3012
+ }
3013
+ var tempToolbarItems = this.processToolbar('center');
3014
+ for (var i = 0, len = tempToolbarItems.length; i < len; i++) {
3015
+ toolbarItems.push(tempToolbarItems[i]);
1915
3016
  }
3017
+ return toolbarItems;
1916
3018
  };
1917
3019
  ImageEditor.prototype.getPenToolbarItem = function (items) {
1918
3020
  var toolbarItems = [];
@@ -2033,7 +3135,12 @@ var ImageEditor = /** @class */ (function (_super) {
2033
3135
  if (items.indexOf('strokeWidth') > -1) {
2034
3136
  var strokeWidthBtn = document.getElementById(this.element.id + '_penStrokeWidth');
2035
3137
  var spanElem_3 = document.createElement('span');
2036
- spanElem_3.innerHTML = this.l10n.getConstant('Small');
3138
+ if (isNullOrUndefined(this.penStrokeWidth)) {
3139
+ spanElem_3.innerHTML = this.l10n.getConstant('Small');
3140
+ }
3141
+ else {
3142
+ spanElem_3.innerHTML = this.getPenStroke(this.penStrokeWidth, this.calcRatio());
3143
+ }
2037
3144
  spanElem_3.className = 'e-pen-stroke-width';
2038
3145
  strokeWidthBtn.appendChild(spanElem_3);
2039
3146
  var drpDownBtn_2 = new DropDownButton({ items: strokeWidthItems,
@@ -2051,15 +3158,15 @@ var ImageEditor = /** @class */ (function (_super) {
2051
3158
  if (Browser.isDevice) {
2052
3159
  if (!isNullOrUndefined(document.getElementById(_this.element.id + '_bottomToolbar'))) {
2053
3160
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
2054
- var toolbar_7 = getComponent(_this.element.id + '_bottomToolbar', 'toolbar');
2055
- toolbar_7.refreshOverflow();
3161
+ var toolbar_8 = getComponent(_this.element.id + '_bottomToolbar', 'toolbar');
3162
+ toolbar_8.refreshOverflow();
2056
3163
  }
2057
3164
  }
2058
3165
  else {
2059
3166
  if (!isNullOrUndefined(document.getElementById(_this.element.id + '_toolbar'))) {
2060
3167
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
2061
- var toolbar_8 = getComponent(_this.element.id + '_toolbar', 'toolbar');
2062
- toolbar_8.refreshOverflow();
3168
+ var toolbar_9 = getComponent(_this.element.id + '_toolbar', 'toolbar');
3169
+ toolbar_9.refreshOverflow();
2063
3170
  }
2064
3171
  }
2065
3172
  }
@@ -2087,7 +3194,161 @@ var ImageEditor = /** @class */ (function (_super) {
2087
3194
  break;
2088
3195
  }
2089
3196
  };
3197
+ ImageEditor.prototype.getPenStroke = function (value, ratio) {
3198
+ var textContent = '';
3199
+ if (Math.round(value / 0.4) === Math.round(ratio.width + ratio.height)) {
3200
+ textContent = this.l10n.getConstant('XSmall');
3201
+ }
3202
+ else if (Math.round(value / 0.8) === Math.round(ratio.width + ratio.height)) {
3203
+ textContent = this.l10n.getConstant('Small');
3204
+ }
3205
+ else if (Math.round(value / 1.2) === Math.round(ratio.width + ratio.height)) {
3206
+ textContent = this.l10n.getConstant('Medium');
3207
+ }
3208
+ else if (Math.round(value / 1.6) === Math.round(ratio.width + ratio.height)) {
3209
+ textContent = this.l10n.getConstant('Large');
3210
+ }
3211
+ else if (Math.round(value / 2) === Math.round(ratio.width + ratio.height)) {
3212
+ textContent = this.l10n.getConstant('XLarge');
3213
+ }
3214
+ return textContent;
3215
+ };
3216
+ ImageEditor.prototype.initAdjustmentToolbarItem = function () {
3217
+ var _this = this;
3218
+ var leftItem = this.getLeftToolbarItem();
3219
+ var rightItem = this.getRightToolbarItem();
3220
+ var mainItem = this.getAdjustmentToolbarItem();
3221
+ var zoomItem = this.getZoomToolbarItem();
3222
+ if (Browser.isDevice) {
3223
+ this.defToolbarItems = mainItem;
3224
+ }
3225
+ else {
3226
+ this.defToolbarItems = leftItem.concat(zoomItem, mainItem, rightItem);
3227
+ }
3228
+ var toolbar = new Toolbar({
3229
+ width: '100%',
3230
+ items: this.defToolbarItems,
3231
+ clicked: this.defToolbarClicked.bind(this),
3232
+ created: function () {
3233
+ if (!Browser.isDevice) {
3234
+ _this.renderSaveBtn();
3235
+ }
3236
+ if (Browser.isDevice) {
3237
+ if (_this.defToolbarItems.length > 0 && (!isNullOrUndefined(document.getElementById(_this.element.id + '_toolbar')))) {
3238
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
3239
+ toolbar.refreshOverflow();
3240
+ }
3241
+ }
3242
+ else {
3243
+ _this.createLeftToolbarControls();
3244
+ if (_this.defToolbarItems.length > 0 && (!isNullOrUndefined(document.getElementById(_this.element.id + '_toolbar')))) {
3245
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
3246
+ toolbar.refreshOverflow();
3247
+ }
3248
+ }
3249
+ }
3250
+ });
3251
+ if (Browser.isDevice) {
3252
+ toolbar.appendTo('#' + this.element.id + '_bottomToolbar');
3253
+ }
3254
+ else {
3255
+ toolbar.appendTo('#' + this.element.id + '_toolbar');
3256
+ }
3257
+ };
3258
+ ImageEditor.prototype.initFilterToolbarItem = function () {
3259
+ var _this = this;
3260
+ var mainItem = this.getFilterToolbarItem();
3261
+ if (!isNullOrUndefined(document.querySelector('#' + this.element.id + '_contextualToolbar')) &&
3262
+ document.querySelector('#' + this.element.id + '_contextualToolbar').classList.contains('e-control')) {
3263
+ getComponent(document.getElementById(this.element.id + '_contextualToolbar'), 'toolbar').destroy();
3264
+ }
3265
+ var toolbar = new Toolbar({
3266
+ width: '100%',
3267
+ items: mainItem,
3268
+ clicked: this.contextualToolbarClicked.bind(this),
3269
+ created: function () {
3270
+ _this.createCanvasFilter();
3271
+ if (_this.currentFilter === '') {
3272
+ _this.currentFilter = _this.element.id + '_default';
3273
+ }
3274
+ var hdrWrapper = document.querySelector('#' + _this.element.id + '_headWrapper');
3275
+ if (hdrWrapper) {
3276
+ hdrWrapper.style.display = 'none';
3277
+ }
3278
+ document.getElementById(_this.currentFilter + 'Canvas').parentElement.parentElement.classList.add('e-selected');
3279
+ toolbar.refreshOverflow();
3280
+ }
3281
+ });
3282
+ toolbar.appendTo('#' + this.element.id + '_contextualToolbar');
3283
+ };
3284
+ ImageEditor.prototype.createCanvasFilter = function () {
3285
+ if (this.adjustmentLevel.sharpen || this.adjustmentLevel.bw) {
3286
+ this.inMemoryContext.clearRect(0, 0, this.inMemoryCanvas.width, this.inMemoryCanvas.height);
3287
+ this.inMemoryCanvas.width = this.tempImageData.width;
3288
+ this.inMemoryCanvas.height = this.tempImageData.height;
3289
+ this.inMemoryContext.putImageData(this.tempImageData, 0, 0);
3290
+ }
3291
+ var noFilter = document.querySelector('#' + this.element.id + '_defaultCanvas');
3292
+ noFilter.style.width = '100px';
3293
+ noFilter.style.height = '100px';
3294
+ noFilter.style.filter = this.updateAdjustment('default', null, true);
3295
+ var ctx = noFilter.getContext('2d');
3296
+ ctx.drawImage(this.inMemoryCanvas, 0, 0, 300, 150);
3297
+ var chrome = document.querySelector('#' + this.element.id + '_chromeCanvas');
3298
+ chrome.style.width = '100px';
3299
+ chrome.style.height = '100px';
3300
+ chrome.style.filter = this.updateAdjustment('chrome', null, true);
3301
+ ctx = chrome.getContext('2d');
3302
+ ctx.drawImage(this.inMemoryCanvas, 0, 0, 300, 150);
3303
+ var cold = document.querySelector('#' + this.element.id + '_coldCanvas');
3304
+ cold.style.width = '100px';
3305
+ cold.style.height = '100px';
3306
+ cold.style.filter = this.updateAdjustment('cold', null, true);
3307
+ ctx = cold.getContext('2d');
3308
+ ctx.drawImage(this.inMemoryCanvas, 0, 0, 300, 150);
3309
+ var warm = document.querySelector('#' + this.element.id + '_warmCanvas');
3310
+ warm.style.width = '100px';
3311
+ warm.style.height = '100px';
3312
+ warm.style.filter = this.updateAdjustment('warm', null, true);
3313
+ ctx = warm.getContext('2d');
3314
+ ctx.drawImage(this.inMemoryCanvas, 0, 0, 300, 150);
3315
+ var temp = this.lowerContext.filter;
3316
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
3317
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
3318
+ for (var i = 0; i < this.objColl.length; i++) {
3319
+ this.apply(this.objColl[i].shape, this.objColl[i]);
3320
+ this.refreshActiveObj();
3321
+ }
3322
+ this.lowerContext.filter = temp;
3323
+ var grayscale = document.querySelector('#' + this.element.id + '_grayscaleCanvas');
3324
+ grayscale.style.width = '100px';
3325
+ grayscale.style.height = '100px';
3326
+ grayscale.style.filter = this.updateAdjustment('grayscale', null, true);
3327
+ ctx = grayscale.getContext('2d');
3328
+ ctx.drawImage(this.inMemoryCanvas, 0, 0, 300, 150);
3329
+ var tempFilter = this.lowerContext.filter;
3330
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
3331
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
3332
+ for (var i = 0; i < this.objColl.length; i++) {
3333
+ this.apply(this.objColl[i].shape, this.objColl[i]);
3334
+ this.refreshActiveObj();
3335
+ }
3336
+ this.lowerContext.filter = tempFilter;
3337
+ var sepia = document.querySelector('#' + this.element.id + '_sepiaCanvas');
3338
+ sepia.style.width = '100px';
3339
+ sepia.style.height = '100px';
3340
+ sepia.style.filter = this.updateAdjustment('sepia', null, true);
3341
+ ctx = sepia.getContext('2d');
3342
+ ctx.drawImage(this.inMemoryCanvas, 0, 0, 300, 150);
3343
+ var invert = document.querySelector('#' + this.element.id + '_invertCanvas');
3344
+ invert.style.width = '100px';
3345
+ invert.style.height = '100px';
3346
+ invert.style.filter = this.updateAdjustment('invert', null, true);
3347
+ ctx = invert.getContext('2d');
3348
+ ctx.drawImage(this.inMemoryCanvas, 0, 0, 300, 150);
3349
+ };
2090
3350
  ImageEditor.prototype.updateCanvas = function () {
3351
+ var fileOpened = { fileName: this.imageFileName, fileType: this.imageFileType };
2091
3352
  this.lastX = this.baseImg.width / 2;
2092
3353
  this.lastY = this.baseImg.height / 2;
2093
3354
  var wrapperWidth;
@@ -2105,9 +3366,10 @@ var ImageEditor = /** @class */ (function (_super) {
2105
3366
  maxDimension.width -= toolbarHeight;
2106
3367
  maxDimension.height -= toolbarHeight;
2107
3368
  }
3369
+ var tempFilter = this.lowerContext.filter;
2108
3370
  this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
2109
- this.lowerCanvas.width = this.upperCanvas.width = this.inMemoryCanvas.width = this.baseImg.width;
2110
- this.lowerCanvas.height = this.upperCanvas.height = this.inMemoryCanvas.height = this.baseImg.height;
3371
+ this.lowerCanvas.width = this.upperCanvas.width = this.baseImg.width;
3372
+ this.lowerCanvas.height = this.upperCanvas.height = this.baseImg.height;
2111
3373
  this.lowerCanvas.style.maxWidth = this.upperCanvas.style.maxWidth = maxDimension.width + 'px';
2112
3374
  this.lowerCanvas.style.maxHeight = this.upperCanvas.style.maxHeight = maxDimension.height + 'px';
2113
3375
  this.lowerCanvas.style.left = this.upperCanvas.style.left = (wrapperWidth - maxDimension.width) / 2 + 1 + 'px';
@@ -2117,26 +3379,47 @@ var ImageEditor = /** @class */ (function (_super) {
2117
3379
  if (canvasWrapper) {
2118
3380
  this.lowerCanvas.style.top = this.upperCanvas.style.top = (parseFloat(canvasWrapper.style.height) - maxDimension.height - 1) / 2 + 'px';
2119
3381
  }
2120
- this.lowerContext.drawImage(this.baseImg, 0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
2121
- this.updateInMemoryCanvas('updateCanvas');
3382
+ this.lowerContext.filter = tempFilter;
3383
+ if (this.lowerContext.filter === 'none' || this.lowerContext.filter === 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
3384
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)' ||
3385
+ this.isInitialLoading) {
3386
+ this.lowerContext.drawImage(this.baseImg, 0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
3387
+ this.updateInMemoryCanvas('updateCanvas');
3388
+ if (this.canvasFilter !== 'none') {
3389
+ this.lowerContext.filter = this.canvasFilter;
3390
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
3391
+ this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
3392
+ }
3393
+ if (this.isInitialLoading) {
3394
+ this.initializeFilter();
3395
+ this.isInitialLoading = false;
3396
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
3397
+ this.lowerContext.drawImage(this.baseImg, 0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
3398
+ }
3399
+ }
3400
+ else {
3401
+ var temp = this.lowerContext.filter;
3402
+ this.updateBrightnessFilter();
3403
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
3404
+ this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
3405
+ this.lowerContext.filter = temp;
3406
+ }
3407
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
3408
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
2122
3409
  for (var i = 0, len = this.objColl.length; i < len; i++) {
2123
3410
  this.apply(this.objColl[i].shape, this.objColl[i]);
2124
3411
  }
2125
- if (this.isUndoRedo) {
2126
- if (this.flipState !== '') {
2127
- this.flip(this.flipState);
2128
- }
2129
- }
3412
+ this.lowerContext.filter = tempFilter;
2130
3413
  if (this.disabled) {
2131
3414
  this.element.setAttribute('class', 'e-disabled');
2132
3415
  }
2133
- this.trigger('fileOpened');
3416
+ this.trigger('fileOpened', fileOpened);
2134
3417
  };
2135
3418
  ImageEditor.prototype.imageOnLoad = function (src) {
2136
3419
  var _this = this;
2137
3420
  // eslint-disable-next-line @typescript-eslint/no-this-alias
2138
3421
  var proxy = this;
2139
- proxy.baseImg.src = proxy.baseImgSrc = src;
3422
+ proxy.baseImg.src = proxy.baseImgSrc.id = src;
2140
3423
  this.baseImg.onload = function () {
2141
3424
  _this.lowerContext.drawImage(_this.baseImg, 0, 0, _this.lowerCanvas.width, _this.lowerCanvas.height);
2142
3425
  if (_this.togglePen) {
@@ -2157,7 +3440,6 @@ var ImageEditor = /** @class */ (function (_super) {
2157
3440
  hideSpinner(_this.element);
2158
3441
  _this.element.style.opacity = '1';
2159
3442
  _this.updateCanvas();
2160
- _this.isUndoRedo = false;
2161
3443
  }
2162
3444
  if (Browser.isDevice) {
2163
3445
  if (_this.isToolbar() && (!isNullOrUndefined(document.getElementById(_this.element.id + '_toolbar'))) &&
@@ -2334,10 +3616,19 @@ var ImageEditor = /** @class */ (function (_super) {
2334
3616
  this.degree = 0;
2335
3617
  }
2336
3618
  };
2337
- ImageEditor.prototype.updateUndoRedoColl = function (operation, value, previousObj, currentObj) {
2338
- this.undoRedoColl.push({ operation: operation, value: value, previousObj: previousObj, currentObj: currentObj });
2339
- };
2340
3619
  ImageEditor.prototype.fileSelect = function (inputElement, args) {
3620
+ this.imageFileName = inputElement.value.split('\\')[inputElement.value.split('\\').length - 1];
3621
+ this.imageFileName = this.imageFileName.split('.')[0];
3622
+ var fileType = inputElement.value.split('.');
3623
+ if (fileType[fileType.length - 1].toLowerCase() === 'jpg' || fileType[fileType.length - 1].toLowerCase() === 'jpeg') {
3624
+ this.imageFileType = 'Jpeg';
3625
+ }
3626
+ else if (fileType[fileType.length - 1].toLowerCase() === 'png') {
3627
+ this.imageFileType = 'Png';
3628
+ }
3629
+ else if (fileType[fileType.length - 1].toLowerCase() === 'svg') {
3630
+ this.imageFileType = 'Svg';
3631
+ }
2341
3632
  showSpinner(this.element);
2342
3633
  this.element.style.opacity = '0.5';
2343
3634
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
@@ -2495,7 +3786,7 @@ var ImageEditor = /** @class */ (function (_super) {
2495
3786
  }
2496
3787
  if (strokeWidthElem) {
2497
3788
  var strokeWidth = Math.round((this.activeObj.strokeSettings.strokeWidth /
2498
- (ratio.width + ratio.height))).toString();
3789
+ (ratio.width + ratio.height)) * this.factor).toString();
2499
3790
  strokeWidthElem.textContent = this.getStrokeWidth(strokeWidth);
2500
3791
  }
2501
3792
  };
@@ -2507,10 +3798,32 @@ var ImageEditor = /** @class */ (function (_super) {
2507
3798
  }
2508
3799
  }
2509
3800
  };
3801
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
3802
+ ImageEditor.prototype.targetTouches = function (touches) {
3803
+ var p1 = { x: touches[0].pageX, y: touches[0].pageY };
3804
+ var p2 = { x: touches[1].pageX, y: touches[1].pageY };
3805
+ var points = [p1, p2];
3806
+ return points;
3807
+ };
3808
+ ImageEditor.prototype.calculateScale = function (startTouches, endTouches) {
3809
+ var startDistance = this.getDistance(startTouches[0], startTouches[1]);
3810
+ var endDistance = this.getDistance(endTouches[0], endTouches[1]);
3811
+ return endDistance / startDistance;
3812
+ };
3813
+ ImageEditor.prototype.getDistance = function (a, b) {
3814
+ var x = a.x - b.x;
3815
+ var y = a.y - b.y;
3816
+ return Math.sqrt(x * x + y * y);
3817
+ };
2510
3818
  ImageEditor.prototype.touchStartHandler = function (e) {
2511
3819
  e.preventDefault();
2512
- this.timer = setTimeout(this.setTimer.bind(this), 1000, e);
2513
- this.mouseDownEventHandler(e);
3820
+ if (e.touches.length === 2) {
3821
+ this.isFirstMove = true;
3822
+ }
3823
+ else {
3824
+ this.timer = setTimeout(this.setTimer.bind(this), 1000, e);
3825
+ this.mouseDownEventHandler(e);
3826
+ }
2514
3827
  EventHandler.add(this.lowerCanvas, 'touchend', this.mouseUpEventHandler, this);
2515
3828
  EventHandler.add(this.lowerCanvas, 'touchmove', this.mouseMoveEventHandler, this); // Unbind mousedown to prevent double triggers from touch devices
2516
3829
  EventHandler.add(this.upperCanvas, 'touchend', this.mouseUpEventHandler, this);
@@ -2537,6 +3850,14 @@ var ImageEditor = /** @class */ (function (_super) {
2537
3850
  this.touchEndPoint.y = y = e.touches[0].clientY;
2538
3851
  }
2539
3852
  this.redrawActObj(x, y);
3853
+ if ((!isNullOrUndefined(this.element.querySelector('#' + this.element.id + '_contextualToolbar')) &&
3854
+ !this.element.querySelector('#' + this.element.id + '_contextualToolbar').parentElement.classList.contains('e-hide')) ||
3855
+ (!isNullOrUndefined(this.element.querySelector('#' + this.element.id + '_headWrapper'))
3856
+ && !this.element.querySelector('#' + this.element.id + '_headWrapper').parentElement.classList.contains('e-hide'))) {
3857
+ this.element.querySelector('.e-contextual-toolbar-wrapper').classList.add('e-hide');
3858
+ this.okBtn();
3859
+ this.refreshToolbar('main');
3860
+ }
2540
3861
  if (this.upperCanvas.style.cursor === 'crosshair' || (Browser.isDevice && this.togglePen)) {
2541
3862
  if (this.togglePen) {
2542
3863
  this.canvasRatio = this.calcRatio();
@@ -2600,6 +3921,47 @@ var ImageEditor = /** @class */ (function (_super) {
2600
3921
  };
2601
3922
  ImageEditor.prototype.mouseMoveEventHandler = function (e) {
2602
3923
  e.preventDefault();
3924
+ if (e.type === 'touchmove' && e.touches.length === 2) {
3925
+ if (this.isFirstMove) {
3926
+ this.startTouches = this.targetTouches(e.touches);
3927
+ this.tempTouches = [];
3928
+ this.tempTouches.push({ x: e.touches[0].clientX || (e.touches[0].pageX - this.lowerCanvas.offsetLeft),
3929
+ y: e.touches[0].clientY || (e.touches[0].pageY - this.lowerCanvas.offsetTop) });
3930
+ this.tempTouches.push({ x: e.touches[1].clientX || (e.touches[1].pageX - this.lowerCanvas.offsetLeft),
3931
+ y: e.touches[1].clientY || (e.touches[1].pageY - this.lowerCanvas.offsetTop) });
3932
+ }
3933
+ else {
3934
+ var ratio = this.calcRatio();
3935
+ var firstFingerX = e.touches[0].clientX || (e.touches[0].pageX - this.lowerCanvas.offsetLeft);
3936
+ var firstFingerY = e.touches[0].clientY || (e.touches[0].pageY - this.lowerCanvas.offsetTop);
3937
+ var secondFingerX = e.touches[1].clientX || (e.touches[1].pageX - this.lowerCanvas.offsetLeft);
3938
+ var secondFingerY = e.touches[1].clientY || (e.touches[1].pageY - this.lowerCanvas.offsetTop);
3939
+ this.lastX = firstFingerX > secondFingerX ? secondFingerX + (firstFingerX - secondFingerX) : firstFingerX +
3940
+ (secondFingerX - firstFingerX);
3941
+ this.lastY = firstFingerY > secondFingerY ? secondFingerY + (firstFingerY - secondFingerY) : firstFingerY +
3942
+ (secondFingerY - firstFingerY);
3943
+ this.lastX *= ratio.width;
3944
+ this.lastY *= ratio.height;
3945
+ var scale = this.calculateScale(this.startTouches, this.targetTouches(e.touches));
3946
+ // Need to set lastX and lastY points
3947
+ if (this.tempTouches[0].x !== firstFingerX && this.tempTouches[0].y !== firstFingerY &&
3948
+ this.tempTouches[1].x !== secondFingerX && this.tempTouches[1].y !== secondFingerY) {
3949
+ if (scale > 1) {
3950
+ this.zoom(1.1);
3951
+ }
3952
+ else {
3953
+ this.zoom(-1.1);
3954
+ }
3955
+ this.tempTouches = [];
3956
+ this.tempTouches.push({ x: e.touches[0].clientX || (e.touches[0].pageX - this.lowerCanvas.offsetLeft),
3957
+ y: e.touches[0].clientY || (e.touches[0].pageY - this.lowerCanvas.offsetTop) });
3958
+ this.tempTouches.push({ x: e.touches[1].clientX || (e.touches[1].pageX - this.lowerCanvas.offsetLeft),
3959
+ y: e.touches[1].clientY || (e.touches[1].pageY - this.lowerCanvas.offsetTop) });
3960
+ }
3961
+ }
3962
+ this.isFirstMove = false;
3963
+ return;
3964
+ }
2603
3965
  if (this.textBox.style.display === 'none') {
2604
3966
  this.isTimer = true;
2605
3967
  }
@@ -2618,6 +3980,11 @@ var ImageEditor = /** @class */ (function (_super) {
2618
3980
  !this.dragCanvas || this.activeObj.activePoint !== undefined) {
2619
3981
  if (this.dragElement === '') {
2620
3982
  this.setCursor(x, y);
3983
+ if (this.activeObj.activePoint.width === 0 && this.upperCanvas.style.cursor !== 'default' &&
3984
+ this.upperCanvas.style.cursor !== 'move' && this.upperCanvas.style.cursor !== 'crosshair'
3985
+ && this.upperCanvas.style.cursor !== 'grab') {
3986
+ this.upperCanvas.style.cursor = 'move';
3987
+ }
2621
3988
  this.findTarget(x, y, e.type);
2622
3989
  }
2623
3990
  }
@@ -2640,6 +4007,8 @@ var ImageEditor = /** @class */ (function (_super) {
2640
4007
  y = this.touchEndPoint.y;
2641
4008
  }
2642
4009
  if (e.type === 'touchend') {
4010
+ this.startTouches = this.tempTouches = [];
4011
+ this.isFirstMove = false;
2643
4012
  if (this.textBox.style.display === 'none') {
2644
4013
  this.isTimer = false;
2645
4014
  this.timer = 0;
@@ -2658,8 +4027,16 @@ var ImageEditor = /** @class */ (function (_super) {
2658
4027
  if (e.currentTarget === this.upperCanvas) {
2659
4028
  this.currObjType.shape = this.currObjType.shape.toLowerCase();
2660
4029
  if (!this.togglePen && !this.dragCanvas) {
4030
+ if (!isNullOrUndefined(this.tempObjColl) && this.activeObj.activePoint.width !== 0) {
4031
+ this.objColl.push(this.activeObj);
4032
+ this.redrawShape(this.objColl[this.objColl.length - 1]);
4033
+ this.tempObjColl = undefined;
4034
+ }
2661
4035
  this.applyCurrActObj(x, y);
2662
4036
  }
4037
+ else if (this.dragCanvas) {
4038
+ this.setPanPoints();
4039
+ }
2663
4040
  }
2664
4041
  if (this.togglePen && e.currentTarget === this.upperCanvas) {
2665
4042
  this.penDrawColl.push({ strokeWidth: this.penStrokeWidth, strokeColor: this.activeObj.strokeSettings.strokeColor, points: this.imageEditorPointsColl });
@@ -2688,11 +4065,13 @@ var ImageEditor = /** @class */ (function (_super) {
2688
4065
  e.stopImmediatePropagation();
2689
4066
  break;
2690
4067
  case 'Delete':
2691
- shapeChangingArgs = { action: 'delete', previousShapeSettings: this.activeObj, currentShapeSettings: null };
2692
- this.keyHistory = '';
2693
- this.clearSelection();
2694
- this.trigger('shapeChanging', shapeChangingArgs);
2695
- this.refreshToolbar('main');
4068
+ if (this.textBox.style.display === 'none') {
4069
+ shapeChangingArgs = { action: 'delete', previousShapeSettings: this.activeObj, currentShapeSettings: null };
4070
+ this.keyHistory = '';
4071
+ this.clearSelection();
4072
+ this.trigger('shapeChanging', shapeChangingArgs);
4073
+ this.refreshToolbar('main');
4074
+ }
2696
4075
  break;
2697
4076
  case 'Escape':
2698
4077
  if (this.togglePan) {
@@ -2714,7 +4093,10 @@ var ImageEditor = /** @class */ (function (_super) {
2714
4093
  }
2715
4094
  };
2716
4095
  ImageEditor.prototype.keyUpEventHandler = function (e) {
2717
- setTimeout(this.textKeyDown.bind(this), 1, e);
4096
+ // eslint-disable-next-line
4097
+ if (this.textBox.style.display === 'block' && e.target.id === this.element.id + '_textBox') {
4098
+ setTimeout(this.textKeyDown.bind(this), 1, e);
4099
+ }
2718
4100
  };
2719
4101
  ImageEditor.prototype.canvasMouseDownHandler = function (e) {
2720
4102
  e.preventDefault();
@@ -2732,7 +4114,6 @@ var ImageEditor = /** @class */ (function (_super) {
2732
4114
  if (this.dragCanvas || this.factor !== 1) {
2733
4115
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
2734
4116
  this.dragStart = this.lowerContext.transformedPoint(this.lastX, this.lastY);
2735
- this.dragged = false;
2736
4117
  }
2737
4118
  };
2738
4119
  ImageEditor.prototype.canvasMouseMoveHandler = function (e) {
@@ -2754,55 +4135,39 @@ var ImageEditor = /** @class */ (function (_super) {
2754
4135
  }
2755
4136
  this.lastX *= ratio.width;
2756
4137
  this.lastY *= ratio.height;
2757
- this.dragged = true;
2758
4138
  if (this.dragStart && this.dragCanvas) {
2759
- /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
2760
- var pt = this.lowerContext.transformedPoint(this.lastX, this.lastY);
2761
- var transitionArgs = { startPoint: { x: this.dragStart.x, y: this.dragStart.y },
2762
- endPoint: { x: pt.x, y: pt.y } };
2763
- this.trigger('panning', transitionArgs);
2764
- var xDiff = pt.x - this.dragStart.x;
2765
- var yDiff = pt.y - this.dragStart.y;
2766
- var xxDiff = xDiff;
2767
- var yyDiff = yDiff;
2768
- this.lowerContext.translate(xDiff, yDiff);
2769
- this.upperContext.translate(xDiff, yDiff);
2770
- /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
2771
- var pt1 = this.lowerContext.transformedPoint(0, 0);
2772
- /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
2773
- var pt2 = this.lowerContext.transformedPoint(this.lowerCanvas.width, this.lowerCanvas.height);
2774
- if (xDiff >= 0) {
2775
- if (pt1.x < 1) {
2776
- xDiff = 0;
2777
- }
2778
- }
2779
- else {
2780
- if (pt2.x > this.lowerCanvas.width) {
2781
- xDiff = 0;
2782
- }
2783
- }
2784
- if (yDiff >= 0) {
2785
- if (pt1.y < 1) {
2786
- yDiff = 0;
2787
- }
2788
- }
2789
- else {
2790
- if (pt2.y > this.lowerCanvas.height) {
2791
- yDiff = 0;
2792
- }
2793
- }
2794
- this.lowerContext.translate(-xxDiff, -yyDiff);
2795
- this.upperContext.translate(-xxDiff, -yyDiff);
2796
- this.lowerContext.translate(xDiff, yDiff);
2797
- this.upperContext.translate(xDiff, yDiff);
2798
- this.redraw();
4139
+ this.drawPanImg();
2799
4140
  }
2800
4141
  };
2801
4142
  ImageEditor.prototype.canvasMouseUpHandler = function (e) {
2802
4143
  e.preventDefault();
4144
+ if (this.togglePan && e.currentTarget === this.lowerCanvas) {
4145
+ var ratio = this.calcRatio();
4146
+ if (e.type === 'mouseup') {
4147
+ this.lastX = e.offsetX || (e.pageX - this.lowerCanvas.offsetLeft);
4148
+ this.lastY = e.offsetY || (e.pageY - this.lowerCanvas.offsetTop);
4149
+ }
4150
+ else {
4151
+ this.lastX = e.touches[0].clientX || (e.touches[0].pageX - this.lowerCanvas.offsetLeft);
4152
+ this.lastY = e.touches[0].clientY || (e.touches[0].pageY - this.lowerCanvas.offsetTop);
4153
+ }
4154
+ this.lastX *= ratio.width;
4155
+ this.lastY *= ratio.height;
4156
+ this.setPanPoints();
4157
+ }
2803
4158
  this.dragStart = null;
4159
+ // zooms on mouse click point
4160
+ // if (e.currentTarget !== document) {
4161
+ // this.zoom(e.shiftKey ? -1 : 1 );
4162
+ // }
2804
4163
  this.currObjType.isDragging = false;
2805
4164
  };
4165
+ ImageEditor.prototype.setPanPoints = function () {
4166
+ if (this.dragCanvas || this.factor !== 1) {
4167
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
4168
+ this.dragStart = this.lowerContext.transformedPoint(this.lastX, this.lastY);
4169
+ }
4170
+ };
2806
4171
  ImageEditor.prototype.textKeyDown = function (e) {
2807
4172
  if (String.fromCharCode(e.which) === '\r') {
2808
4173
  this.textRow += 1;
@@ -2821,6 +4186,8 @@ var ImageEditor = /** @class */ (function (_super) {
2821
4186
  ImageEditor.prototype.adjustToScreen = function () {
2822
4187
  // eslint-disable-next-line @typescript-eslint/no-this-alias
2823
4188
  var proxy = this;
4189
+ var tempFilter = this.lowerContext.filter;
4190
+ this.okBtn();
2824
4191
  this.applyActObj();
2825
4192
  this.refreshActiveObj();
2826
4193
  if (this.imgDataColl.length > 0) {
@@ -2842,15 +4209,32 @@ var ImageEditor = /** @class */ (function (_super) {
2842
4209
  canvasWrapper.style.height = (parseFloat(canvasWrapper.style.height) - this.toolbarHeight) - 3 + 'px';
2843
4210
  }
2844
4211
  }
2845
- this.redrawImg();
2846
- // eslint-disable-next-line @typescript-eslint/tslint/config
2847
- this.lowerCanvas.toBlob(function (blob) {
2848
- proxy.baseImg.src = URL.createObjectURL(blob);
2849
- }, 'image/png');
4212
+ this.redrawImg(tempFilter);
4213
+ if (!this.currObjType.isSave) {
4214
+ // eslint-disable-next-line @typescript-eslint/tslint/config
4215
+ this.lowerCanvas.toBlob(function (blob) {
4216
+ proxy.lowerContext.filter = proxy.initialAdjustmentValue = proxy.adjustmentValue = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
4217
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
4218
+ if (proxy.cssClass) {
4219
+ addClass([proxy.element], proxy.cssClass.split(' '));
4220
+ }
4221
+ proxy.lowerContext.clearRect(0, 0, proxy.lowerCanvas.width, proxy.lowerCanvas.height);
4222
+ proxy.lowerContext.drawImage(proxy.inMemoryCanvas, 0, 0);
4223
+ proxy.baseImg.src = URL.createObjectURL(blob);
4224
+ proxy.lowerContext.filter = tempFilter;
4225
+ }, 'image/png');
4226
+ }
4227
+ else {
4228
+ hideSpinner(this.element);
4229
+ this.element.style.opacity = '1';
4230
+ }
2850
4231
  if (this.defToolbarItems.length > 0 && (!isNullOrUndefined(document.getElementById(this.element.id + '_toolbar')))) {
2851
4232
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
2852
- var toolbar_9 = getComponent(proxy.element.id + '_toolbar', 'toolbar');
2853
- toolbar_9.refreshOverflow();
4233
+ var toolbar_10 = getComponent(proxy.element.id + '_toolbar', 'toolbar');
4234
+ toolbar_10.refreshOverflow();
4235
+ if (!isNullOrUndefined(this.element.querySelector('.e-contextual-toolbar-wrapper'))) {
4236
+ this.element.querySelector('.e-contextual-toolbar-wrapper').classList.add('e-hide');
4237
+ }
2854
4238
  }
2855
4239
  };
2856
4240
  ImageEditor.prototype.screenOrientation = function () {
@@ -2864,7 +4248,49 @@ var ImageEditor = /** @class */ (function (_super) {
2864
4248
  this.adjustToScreen();
2865
4249
  }
2866
4250
  };
2867
- ImageEditor.prototype.redrawImg = function () {
4251
+ ImageEditor.prototype.drawPanImg = function () {
4252
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
4253
+ var pt = this.lowerContext.transformedPoint(this.lastX, this.lastY);
4254
+ var transitionArgs = { startPoint: { x: this.dragStart.x, y: this.dragStart.y },
4255
+ endPoint: { x: pt.x, y: pt.y } };
4256
+ this.trigger('panning', transitionArgs);
4257
+ var xDiff = pt.x - this.dragStart.x;
4258
+ var yDiff = pt.y - this.dragStart.y;
4259
+ var xxDiff = xDiff;
4260
+ var yyDiff = yDiff;
4261
+ this.lowerContext.translate(xDiff, yDiff);
4262
+ this.upperContext.translate(xDiff, yDiff);
4263
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
4264
+ var pt1 = this.lowerContext.transformedPoint(0, 0);
4265
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
4266
+ var pt2 = this.lowerContext.transformedPoint(this.lowerCanvas.width, this.lowerCanvas.height);
4267
+ if (xDiff >= 0) {
4268
+ if (pt1.x < 1) {
4269
+ xDiff = 0;
4270
+ }
4271
+ }
4272
+ else {
4273
+ if (pt2.x > this.lowerCanvas.width) {
4274
+ xDiff = 0;
4275
+ }
4276
+ }
4277
+ if (yDiff >= 0) {
4278
+ if (pt1.y < 1) {
4279
+ yDiff = 0;
4280
+ }
4281
+ }
4282
+ else {
4283
+ if (pt2.y > this.lowerCanvas.height) {
4284
+ yDiff = 0;
4285
+ }
4286
+ }
4287
+ this.lowerContext.translate(-xxDiff, -yyDiff);
4288
+ this.upperContext.translate(-xxDiff, -yyDiff);
4289
+ this.lowerContext.translate(xDiff, yDiff);
4290
+ this.upperContext.translate(xDiff, yDiff);
4291
+ this.redraw();
4292
+ };
4293
+ ImageEditor.prototype.redrawImg = function (tempFilter) {
2868
4294
  var wrapperWidth;
2869
4295
  var canvasWrapper = document.querySelector('#' + this.element.id + '_canvasWrapper');
2870
4296
  if (this.isScreenOriented) {
@@ -2880,7 +4306,17 @@ var ImageEditor = /** @class */ (function (_super) {
2880
4306
  this.lowerCanvas.style.maxHeight = this.upperCanvas.style.maxHeight = maxDimension.height + 'px';
2881
4307
  this.lowerCanvas.style.left = this.upperCanvas.style.left = (wrapperWidth - maxDimension.width) / 2 + 1 + 'px';
2882
4308
  this.lowerCanvas.style.top = this.upperCanvas.style.top = (this.element.offsetHeight - this.toolbarHeight - maxDimension.height) / 2 + 1 + 'px';
4309
+ this.lowerContext.filter = tempFilter;
4310
+ var temp = this.lowerContext.filter;
4311
+ this.updateBrightnessFilter();
2883
4312
  this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
4313
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
4314
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
4315
+ for (var i = 0; i < this.objColl.length; i++) {
4316
+ this.apply(this.objColl[i].shape, this.objColl[i]);
4317
+ this.refreshActiveObj();
4318
+ }
4319
+ this.lowerContext.filter = temp;
2884
4320
  };
2885
4321
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
2886
4322
  ImageEditor.prototype.updateContext = function (ctx) {
@@ -2929,7 +4365,7 @@ var ImageEditor = /** @class */ (function (_super) {
2929
4365
  var transform = ctx.transform;
2930
4366
  ctx.transform = function (a, b, c, d, e, f) {
2931
4367
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
2932
- var m2 = new DOMMatrix([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
4368
+ var m2 = new DOMMatrix();
2933
4369
  m2.a = a;
2934
4370
  m2.b = b;
2935
4371
  m2.c = c;
@@ -2957,6 +4393,7 @@ var ImageEditor = /** @class */ (function (_super) {
2957
4393
  return pt.matrixTransform(xform.inverse());
2958
4394
  };
2959
4395
  };
4396
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
2960
4397
  ImageEditor.prototype.scaleNonUniform = function (xform, sx, sy) {
2961
4398
  xform.m11 *= sx;
2962
4399
  xform.m12 *= sx;
@@ -2993,11 +4430,7 @@ var ImageEditor = /** @class */ (function (_super) {
2993
4430
  this.upperContext.setTransform(1, 0, 0, 1, 0, 0);
2994
4431
  this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
2995
4432
  this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
2996
- this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
2997
- for (var j = 0; j < this.objColl.length; j++) {
2998
- this.apply(this.objColl[j].shape, this.objColl[j]);
2999
- this.refreshActiveObj();
3000
- }
4433
+ this.redrawImgWithObj();
3001
4434
  }
3002
4435
  else {
3003
4436
  if (this.factor > 1) {
@@ -3060,11 +4493,7 @@ var ImageEditor = /** @class */ (function (_super) {
3060
4493
  this.upperContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
3061
4494
  this.lowerContext.restore();
3062
4495
  this.upperContext.restore();
3063
- this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
3064
- for (var j = 0; j < this.objColl.length; j++) {
3065
- this.apply(this.objColl[j].shape, this.objColl[j]);
3066
- this.refreshActiveObj();
3067
- }
4496
+ this.redrawImgWithObj();
3068
4497
  };
3069
4498
  ImageEditor.prototype.applyCurrActObj = function (x, y) {
3070
4499
  var isInside = false;
@@ -3088,9 +4517,13 @@ var ImageEditor = /** @class */ (function (_super) {
3088
4517
  }
3089
4518
  if (this.activeObj.shape === 'text' || (this.currObjType.shape === 'ellipse' || this.currObjType.shape === 'rectangle' ||
3090
4519
  this.currObjType.shape === 'line')) {
4520
+ var tempFilter = this.lowerContext.filter;
4521
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
4522
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
3091
4523
  for (var j = 0; j < this.objColl.length; j++) {
3092
4524
  this.apply(this.objColl[j].shape, this.objColl[j]);
3093
4525
  }
4526
+ this.lowerContext.filter = tempFilter;
3094
4527
  this.apply('shape');
3095
4528
  }
3096
4529
  }
@@ -3116,6 +4549,24 @@ var ImageEditor = /** @class */ (function (_super) {
3116
4549
  this.setTextSelection(width, height);
3117
4550
  this.updateActiveObject(ratio, this.activeObj.activePoint, this.activeObj);
3118
4551
  };
4552
+ ImageEditor.prototype.setTextBoxStylesToActObj = function () {
4553
+ var ratio = this.calcRatio();
4554
+ this.activeObj.textSettings.fontFamily = this.textBox.style.fontFamily;
4555
+ this.activeObj.strokeSettings.strokeColor = this.textBox.style.color;
4556
+ if (this.textBox.style.fontWeight === 'bold') {
4557
+ this.activeObj.textSettings.bold = true;
4558
+ }
4559
+ else {
4560
+ this.activeObj.textSettings.bold = false;
4561
+ }
4562
+ if (this.textBox.style.fontStyle === 'italic') {
4563
+ this.activeObj.textSettings.italic = true;
4564
+ }
4565
+ else {
4566
+ this.activeObj.textSettings.italic = false;
4567
+ }
4568
+ this.activeObj.textSettings.fontSize = (parseFloat(this.textBox.style.fontSize) * ((ratio.width + ratio.height) / 2)) / this.factor;
4569
+ };
3119
4570
  ImageEditor.prototype.redrawActObj = function (x, y) {
3120
4571
  var ratio = this.calcRatio();
3121
4572
  var splitWords;
@@ -3125,21 +4576,7 @@ var ImageEditor = /** @class */ (function (_super) {
3125
4576
  }
3126
4577
  if (this.activeObj.horTopLine !== undefined && (this.activeObj.shape !== undefined && splitWords[0] !== 'crop')) {
3127
4578
  if (this.textBox.style.display === 'block') {
3128
- this.activeObj.textSettings.fontFamily = this.textBox.style.fontFamily;
3129
- this.activeObj.strokeSettings.strokeColor = this.textBox.style.color;
3130
- if (this.textBox.style.fontWeight === 'bold') {
3131
- this.activeObj.textSettings.bold = true;
3132
- }
3133
- else {
3134
- this.activeObj.textSettings.bold = false;
3135
- }
3136
- if (this.textBox.style.fontStyle === 'italic') {
3137
- this.activeObj.textSettings.italic = true;
3138
- }
3139
- else {
3140
- this.activeObj.textSettings.italic = false;
3141
- }
3142
- this.activeObj.textSettings.fontSize = (parseFloat(this.textBox.style.fontSize) * ((ratio.width + ratio.height) / 2)) / this.factor;
4579
+ this.setTextBoxStylesToActObj();
3143
4580
  if (x && y) {
3144
4581
  x -= bbox.left;
3145
4582
  y -= bbox.top;
@@ -3601,10 +5038,7 @@ var ImageEditor = /** @class */ (function (_super) {
3601
5038
  }
3602
5039
  }
3603
5040
  this.lowerContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
3604
- this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
3605
- for (var i = 0; i < this.objColl.length; i++) {
3606
- this.apply(this.objColl[i].shape, this.objColl[i]);
3607
- }
5041
+ this.redrawImgWithObj();
3608
5042
  this.activeObj = temp;
3609
5043
  this.updateFontStyles();
3610
5044
  if (this.factor === 1) {
@@ -4009,7 +5443,7 @@ var ImageEditor = /** @class */ (function (_super) {
4009
5443
  else {
4010
5444
  diff = Math.max(this.diffPoint.x, this.diffPoint.y);
4011
5445
  }
4012
- percentage = diff / 10;
5446
+ percentage = (diff / 10) * this.factor;
4013
5447
  this.activeObj.activePoint.startX -= (maxDimension.width / 100) * percentage;
4014
5448
  this.activeObj.activePoint.startY -= (maxDimension.height / 100) * percentage;
4015
5449
  this.activeObj.activePoint.width = this.activeObj.activePoint.endX - this.activeObj.activePoint.startX;
@@ -4154,7 +5588,7 @@ var ImageEditor = /** @class */ (function (_super) {
4154
5588
  else {
4155
5589
  diff = Math.max(this.diffPoint.x, this.diffPoint.y);
4156
5590
  }
4157
- percentage = diff / 10;
5591
+ percentage = (diff / 10) * this.factor;
4158
5592
  this.activeObj.activePoint.endX += (maxDimension.width / 100) * percentage;
4159
5593
  this.activeObj.activePoint.startY -= (maxDimension.height / 100) * percentage;
4160
5594
  this.activeObj.activePoint.width = this.activeObj.activePoint.endX - this.activeObj.activePoint.startX;
@@ -4350,7 +5784,7 @@ var ImageEditor = /** @class */ (function (_super) {
4350
5784
  else {
4351
5785
  diff = Math.max(this.diffPoint.x, this.diffPoint.y);
4352
5786
  }
4353
- percentage = diff / 10;
5787
+ percentage = (diff / 10) * this.factor;
4354
5788
  this.activeObj.activePoint.startX -= (maxDimension.width / 100) * percentage;
4355
5789
  this.activeObj.activePoint.endY += (maxDimension.height / 100) * percentage;
4356
5790
  this.activeObj.activePoint.width = this.activeObj.activePoint.endX - this.activeObj.activePoint.startX;
@@ -4497,7 +5931,7 @@ var ImageEditor = /** @class */ (function (_super) {
4497
5931
  else {
4498
5932
  diff = Math.min(this.diffPoint.x, this.diffPoint.y);
4499
5933
  }
4500
- percentage = diff / 10;
5934
+ percentage = (diff / 10) * this.factor;
4501
5935
  this.activeObj.activePoint.endX += (maxDimension.width / 50) * percentage;
4502
5936
  this.activeObj.activePoint.endY += (maxDimension.height / 50) * percentage;
4503
5937
  this.activeObj.activePoint.width = this.activeObj.activePoint.endX - this.activeObj.activePoint.startX;
@@ -4543,8 +5977,6 @@ var ImageEditor = /** @class */ (function (_super) {
4543
5977
  width = this.activeObj.activePoint.endX - x;
4544
5978
  height = this.activeObj.activePoint.endY - y;
4545
5979
  scale = Math.min(width, height);
4546
- var ratio = this.activeObj.shape.split('-');
4547
- ratio = ratio[1].split(':');
4548
5980
  var newScale = this.getScaleRatio(scale);
4549
5981
  this.activeObj.activePoint.endX -= newScale.x;
4550
5982
  this.activeObj.activePoint.endY -= newScale.y;
@@ -5203,6 +6635,7 @@ var ImageEditor = /** @class */ (function (_super) {
5203
6635
  this.refreshActiveObj();
5204
6636
  return;
5205
6637
  }
6638
+ this.tempObjColl = extend([], this.objColl, [], true);
5206
6639
  this.currObjType.isCustomCrop = false;
5207
6640
  var temp = this.activeObj = extend({}, this.objColl[i], {}, true);
5208
6641
  this.objColl.splice(i, 1);
@@ -5212,11 +6645,35 @@ var ImageEditor = /** @class */ (function (_super) {
5212
6645
  this.inMemoryContext.putImageData(this.imgDataColl[0].value, 0, 0);
5213
6646
  }
5214
6647
  else {
6648
+ if ((this.adjustmentLevel.sharpen || this.adjustmentLevel.bw) && !this.sharpenedImgData) {
6649
+ var data = void 0;
6650
+ var tempImageData = this.currImgData;
6651
+ if (this.adjustmentLevel.sharpen) {
6652
+ data = this.getSharpenData(this.currImgData);
6653
+ }
6654
+ else {
6655
+ data = this.getBlackAndWhiteData(tempImageData);
6656
+ }
6657
+ this.currImgData = data;
6658
+ this.sharpenedImgData = true;
6659
+ }
5215
6660
  this.inMemoryCanvas.width = this.currImgData.width;
5216
6661
  this.inMemoryCanvas.height = this.currImgData.height;
5217
6662
  this.inMemoryContext.putImageData(this.currImgData, 0, 0);
5218
6663
  }
5219
6664
  if (this.flipState !== '') {
6665
+ if ((this.adjustmentLevel.sharpen || this.adjustmentLevel.bw) && !this.sharpenedImgData) {
6666
+ var data = void 0;
6667
+ var tempImageData = this.currImgData;
6668
+ if (this.adjustmentLevel.sharpen) {
6669
+ data = this.getSharpenData(this.currImgData);
6670
+ }
6671
+ else {
6672
+ data = this.getBlackAndWhiteData(tempImageData);
6673
+ }
6674
+ this.currImgData = data;
6675
+ this.sharpenedImgData = true;
6676
+ }
5220
6677
  this.inMemoryContext.clearRect(0, 0, this.inMemoryCanvas.width, this.inMemoryCanvas.height);
5221
6678
  this.inMemoryContext.clearRect(0, 0, this.inMemoryCanvas.height, this.inMemoryCanvas.width);
5222
6679
  this.inMemoryCanvas.width = this.currImgData.width;
@@ -5225,15 +6682,10 @@ var ImageEditor = /** @class */ (function (_super) {
5225
6682
  }
5226
6683
  this.setActivePoint();
5227
6684
  this.upperContext.drawImage(this.inMemoryCanvas, 0, 0);
6685
+ this.lowerContext.filter = this.canvasFilter;
5228
6686
  this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
5229
- this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
6687
+ this.redrawImgWithObj();
5230
6688
  this.upperContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
5231
- for (var j = 0; j < this.objColl.length; j++) {
5232
- if (this.objColl[j].shape === 'text' && this.objColl[j].shapeFlip !== this.currFlipState) {
5233
- this.objColl[j].flippedText = true;
5234
- }
5235
- this.apply(this.objColl[j].shape, this.objColl[j]);
5236
- }
5237
6689
  this.activeObj = extend({}, temp, {}, true);
5238
6690
  var endPoint = { x: this.lowerCanvas.width - this.pannEnd.startX, y: this.lowerCanvas.height - this.pannEnd.startY };
5239
6691
  if (this.factor !== 1 && (this.activeObj.activePoint.startX < this.pannStart.startX || this.activeObj.activePoint.startY <
@@ -5616,7 +7068,7 @@ var ImageEditor = /** @class */ (function (_super) {
5616
7068
  }
5617
7069
  else {
5618
7070
  if (this.currObjType.isCustomCrop) {
5619
- this.upperCanvas.style.cursor = 'cross-hair';
7071
+ this.upperCanvas.style.cursor = 'crosshair';
5620
7072
  }
5621
7073
  this.upperCanvas.style.cursor = 'default';
5622
7074
  }
@@ -5713,7 +7165,7 @@ var ImageEditor = /** @class */ (function (_super) {
5713
7165
  }
5714
7166
  else {
5715
7167
  if (this.currObjType.isCustomCrop) {
5716
- this.upperCanvas.style.cursor = 'cross-hair';
7168
+ this.upperCanvas.style.cursor = 'crosshair';
5717
7169
  }
5718
7170
  this.upperCanvas.style.cursor = 'default';
5719
7171
  }
@@ -5773,7 +7225,7 @@ var ImageEditor = /** @class */ (function (_super) {
5773
7225
  // eslint-disable-next-line @typescript-eslint/tslint/config
5774
7226
  this.lowerCanvas.toBlob(function (blob) {
5775
7227
  var blobUrl = URL.createObjectURL(blob);
5776
- proxy.baseImg.src = blobUrl;
7228
+ //proxy.baseImg.src = blobUrl;
5777
7229
  proxy.downloadImg(blobUrl, fileName + '.' + type);
5778
7230
  }, 'image/png');
5779
7231
  };
@@ -5823,21 +7275,6 @@ var ImageEditor = /** @class */ (function (_super) {
5823
7275
  this.inMemoryContext.putImageData(imgData, 0, 0);
5824
7276
  }
5825
7277
  };
5826
- ImageEditor.prototype.drawBaseImg = function () {
5827
- this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
5828
- this.lowerContext.clearRect(0, 0, this.lowerCanvas.height, this.lowerCanvas.width);
5829
- this.inMemoryContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
5830
- this.inMemoryContext.clearRect(0, 0, this.lowerCanvas.height, this.lowerCanvas.width);
5831
- this.inMemoryCanvas.width = this.lowerCanvas.width = this.imgDataColl[0].value.width;
5832
- this.inMemoryCanvas.height = this.lowerCanvas.height = this.imgDataColl[0].value.height;
5833
- this.inMemoryContext.putImageData(this.imgDataColl[0].value, 0, 0);
5834
- var maxDimension = this.calcMaxDimension(this.inMemoryCanvas.width, this.inMemoryCanvas.height);
5835
- this.lowerCanvas.style.maxWidth = this.upperCanvas.style.maxWidth = maxDimension.width + 'px';
5836
- this.lowerCanvas.style.maxHeight = this.upperCanvas.style.maxHeight = maxDimension.height + 'px';
5837
- this.lowerCanvas.style.left = this.upperCanvas.style.left = (this.element.clientWidth - maxDimension.width) / 2 + 1 + 'px';
5838
- this.lowerCanvas.style.top = this.upperCanvas.style.top = (this.element.clientHeight - this.toolbarHeight - maxDimension.height) / 2 + 1 + 'px';
5839
- this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
5840
- };
5841
7278
  ImageEditor.prototype.calcPrevRatio = function () {
5842
7279
  var oldWidthRatio;
5843
7280
  var oldHeightRatio;
@@ -5944,15 +7381,23 @@ var ImageEditor = /** @class */ (function (_super) {
5944
7381
  }
5945
7382
  else if (degree === 90 || degree === -90) {
5946
7383
  this.updateCurrentActiveObjPoint(degree);
7384
+ var tempFilter = this.lowerContext.filter;
7385
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
7386
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
5947
7387
  for (var i = 0; i < this.objColl.length; i++) {
5948
7388
  this.apply(this.objColl[i].shape, this.objColl[i]);
5949
7389
  }
7390
+ this.lowerContext.filter = tempFilter;
5950
7391
  }
5951
7392
  else {
5952
7393
  this.updateCurrentActiveObjPoint('zoom');
7394
+ var tempFilter = this.lowerContext.filter;
7395
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
7396
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
5953
7397
  for (var i = 0; i < this.objColl.length; i++) {
5954
7398
  this.apply(this.objColl[i].shape, this.objColl[i]);
5955
7399
  }
7400
+ this.lowerContext.filter = tempFilter;
5956
7401
  }
5957
7402
  }
5958
7403
  else if (this.objColl.length === 0 && (degree === 'horizontal' || degree === 'vertical' || degree === 'Horizontal' || degree === 'Vertical')) {
@@ -6000,12 +7445,14 @@ var ImageEditor = /** @class */ (function (_super) {
6000
7445
  if (this.objColl[i].activePoint.startX <= this.lowerCanvas.width / 2) {
6001
7446
  this.objColl[i].activePoint.startX = this.lowerCanvas.width / 2 + ((this.lowerCanvas.width / 2) -
6002
7447
  this.objColl[i].activePoint.endX);
6003
- this.objColl[i].activePoint.endX = this.objColl[i].activePoint.startX + this.objColl[i].activePoint.width;
7448
+ this.objColl[i].activePoint.endX = this.objColl[i].activePoint.startX +
7449
+ this.objColl[i].activePoint.width;
6004
7450
  this.updateActiveObject(ratio, this.objColl[i].activePoint, this.objColl[i]);
6005
7451
  }
6006
7452
  else if (this.objColl[i].activePoint.startX >= this.lowerCanvas.width / 2) {
6007
7453
  this.objColl[i].activePoint.startX = this.lowerCanvas.width - this.objColl[i].activePoint.endX;
6008
- this.objColl[i].activePoint.endX = this.objColl[i].activePoint.startX + this.objColl[i].activePoint.width;
7454
+ this.objColl[i].activePoint.endX = this.objColl[i].activePoint.startX +
7455
+ this.objColl[i].activePoint.width;
6009
7456
  this.updateActiveObject(ratio, this.objColl[i].activePoint, this.objColl[i]);
6010
7457
  }
6011
7458
  }
@@ -6015,12 +7462,14 @@ var ImageEditor = /** @class */ (function (_super) {
6015
7462
  if (this.objColl[i].activePoint.startY <= this.lowerCanvas.height / 2) {
6016
7463
  this.objColl[i].activePoint.startY = this.lowerCanvas.height / 2 + ((this.lowerCanvas.height / 2) -
6017
7464
  this.objColl[i].activePoint.endY);
6018
- this.objColl[i].activePoint.endY = this.objColl[i].activePoint.startY + this.objColl[i].activePoint.height;
7465
+ this.objColl[i].activePoint.endY = this.objColl[i].activePoint.startY +
7466
+ this.objColl[i].activePoint.height;
6019
7467
  this.updateActiveObject(ratio, this.objColl[i].activePoint, this.objColl[i]);
6020
7468
  }
6021
7469
  else if (this.objColl[i].activePoint.startY >= this.lowerCanvas.height / 2) {
6022
7470
  this.objColl[i].activePoint.startY = this.lowerCanvas.height - this.objColl[i].activePoint.endY;
6023
- this.objColl[i].activePoint.endY = this.objColl[i].activePoint.startY + this.objColl[i].activePoint.height;
7471
+ this.objColl[i].activePoint.endY = this.objColl[i].activePoint.startY +
7472
+ this.objColl[i].activePoint.height;
6024
7473
  this.updateActiveObject(ratio, this.objColl[i].activePoint, this.objColl[i]);
6025
7474
  }
6026
7475
  }
@@ -6035,22 +7484,30 @@ var ImageEditor = /** @class */ (function (_super) {
6035
7484
  this.objColl[i].activePoint.startY /= oldRatio.height;
6036
7485
  this.objColl[i].activePoint.endX /= oldRatio.width;
6037
7486
  this.objColl[i].activePoint.endY /= oldRatio.height;
6038
- this.objColl[i].activePoint.height = this.objColl[i].activePoint.endX - this.objColl[i].activePoint.startX;
6039
- this.objColl[i].activePoint.width = this.objColl[i].activePoint.endY - this.objColl[i].activePoint.startY;
7487
+ this.objColl[i].activePoint.height = this.objColl[i].activePoint.endX -
7488
+ this.objColl[i].activePoint.startX;
7489
+ this.objColl[i].activePoint.width = this.objColl[i].activePoint.endY -
7490
+ this.objColl[i].activePoint.startY;
6040
7491
  this.objColl[i].strokeSettings.strokeWidth /= (oldRatio.width / this.factor);
6041
7492
  this.calcCurrPoints(degree, this.objColl[i]);
6042
- this.objColl[i].activePoint.endX = this.objColl[i].activePoint.startX + this.objColl[i].activePoint.width;
6043
- this.objColl[i].activePoint.endY = this.objColl[i].activePoint.startY + this.objColl[i].activePoint.height;
6044
- this.objColl[i].activePoint.width = this.objColl[i].activePoint.endX - this.objColl[i].activePoint.startX;
6045
- this.objColl[i].activePoint.height = this.objColl[i].activePoint.endY - this.objColl[i].activePoint.startY;
7493
+ this.objColl[i].activePoint.endX = this.objColl[i].activePoint.startX +
7494
+ this.objColl[i].activePoint.width;
7495
+ this.objColl[i].activePoint.endY = this.objColl[i].activePoint.startY +
7496
+ this.objColl[i].activePoint.height;
7497
+ this.objColl[i].activePoint.width = this.objColl[i].activePoint.endX -
7498
+ this.objColl[i].activePoint.startX;
7499
+ this.objColl[i].activePoint.height = this.objColl[i].activePoint.endY -
7500
+ this.objColl[i].activePoint.startY;
6046
7501
  }
6047
7502
  for (var i = 0; i < this.objColl.length; i++) {
6048
7503
  this.objColl[i].activePoint.startX *= oldRatio.width;
6049
7504
  this.objColl[i].activePoint.startY *= oldRatio.height;
6050
7505
  this.objColl[i].activePoint.endX *= oldRatio.width;
6051
7506
  this.objColl[i].activePoint.endY *= oldRatio.height;
6052
- this.objColl[i].activePoint.width = this.objColl[i].activePoint.endX - this.objColl[i].activePoint.startX;
6053
- this.objColl[i].activePoint.height = this.objColl[i].activePoint.endY - this.objColl[i].activePoint.startY;
7507
+ this.objColl[i].activePoint.width = this.objColl[i].activePoint.endX -
7508
+ this.objColl[i].activePoint.startX;
7509
+ this.objColl[i].activePoint.height = this.objColl[i].activePoint.endY -
7510
+ this.objColl[i].activePoint.startY;
6054
7511
  this.objColl[i].strokeSettings.strokeWidth *= ratio.width;
6055
7512
  }
6056
7513
  for (var i = 0; i < this.objColl.length; i++) {
@@ -6120,10 +7577,7 @@ var ImageEditor = /** @class */ (function (_super) {
6120
7577
  tempObjColl = [];
6121
7578
  this.refreshActiveObj();
6122
7579
  this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
6123
- this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
6124
- for (var i = 0; i < this.objColl.length; i++) {
6125
- this.apply(this.objColl[i].shape, this.objColl[i]);
6126
- }
7580
+ this.redrawImgWithObj();
6127
7581
  this.activeObj.flippedText = false;
6128
7582
  this.currObjType.shape = '';
6129
7583
  this.refreshActiveObj();
@@ -6141,17 +7595,27 @@ var ImageEditor = /** @class */ (function (_super) {
6141
7595
  showSpinner(proxy_1.element);
6142
7596
  proxy_1.element.style.opacity = '0.5';
6143
7597
  proxy_1.lowerContext.clearRect(0, 0, proxy_1.lowerCanvas.width, proxy_1.lowerCanvas.height);
7598
+ var temp = proxy_1.lowerContext.filter;
7599
+ proxy_1.lowerContext.filter = proxy_1.initialAdjustmentValue = proxy_1.adjustmentValue = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
7600
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
7601
+ if (proxy_1.cssClass) {
7602
+ addClass([proxy_1.element], proxy_1.cssClass.split(' '));
7603
+ }
6144
7604
  proxy_1.lowerContext.drawImage(proxy_1.inMemoryCanvas, 0, 0);
6145
7605
  proxy_1.baseImg.src = URL.createObjectURL(blob);
6146
7606
  proxy_1.upperContext.clearRect(0, 0, proxy_1.upperCanvas.width, proxy_1.upperCanvas.height);
6147
7607
  proxy_1.togglePen = false;
6148
7608
  proxy_1.upperCanvas.style.cursor = 'default';
7609
+ proxy_1.lowerContext.filter = temp;
7610
+ var tempFilter = proxy_1.lowerContext.filter;
7611
+ proxy_1.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
7612
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
6149
7613
  for (var i = 0, len = proxy_1.objColl.length; i < len; i++) {
6150
7614
  proxy_1.apply(proxy_1.objColl[i].shape, proxy_1.objColl[i], 'duplicate');
6151
7615
  }
7616
+ proxy_1.lowerContext.filter = tempFilter;
6152
7617
  proxy_1.togglePen = true;
6153
7618
  }, 'image/png');
6154
- this.isUndoRedo = false;
6155
7619
  this.degree = 0;
6156
7620
  }
6157
7621
  else {
@@ -6166,7 +7630,6 @@ var ImageEditor = /** @class */ (function (_super) {
6166
7630
  }
6167
7631
  this.keyHistory = '';
6168
7632
  }
6169
- this.isUndoRedo = false;
6170
7633
  }
6171
7634
  }
6172
7635
  };
@@ -6299,6 +7762,9 @@ var ImageEditor = /** @class */ (function (_super) {
6299
7762
  if (this.activeObj.textSettings.fontSize < 20 * (ratio.width + ratio.height)) {
6300
7763
  this.activeObj.textSettings.fontSize = 20 * (ratio.width + ratio.height);
6301
7764
  }
7765
+ if (this.factor > 1) {
7766
+ this.activeObj.textSettings.fontSize /= this.factor;
7767
+ }
6302
7768
  }
6303
7769
  this.activeObj.shapeDegree = this.degree;
6304
7770
  this.activeObj.shapeFlip = this.currFlipState;
@@ -6317,6 +7783,8 @@ var ImageEditor = /** @class */ (function (_super) {
6317
7783
  this.setCenterPoints(true, width, height);
6318
7784
  }
6319
7785
  this.addLetter(this.activeObj.textSettings.text);
7786
+ this.objColl.push(this.activeObj);
7787
+ this.redrawShape(this.objColl[this.objColl.length - 1]);
6320
7788
  this.refreshToolbar('text');
6321
7789
  }
6322
7790
  };
@@ -6390,7 +7858,28 @@ var ImageEditor = /** @class */ (function (_super) {
6390
7858
  inRange = true;
6391
7859
  }
6392
7860
  }
6393
- return inRange;
7861
+ return inRange;
7862
+ };
7863
+ ImageEditor.prototype.updateInMemoryContext = function (imgData, isUpdate) {
7864
+ var temp = extend({}, this.activeObj, {}, true);
7865
+ this.redrawImgWithObj();
7866
+ this.activeObj = temp;
7867
+ if (isNullOrUndefined(isUpdate)) {
7868
+ imgData = this.lowerContext.getImageData(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
7869
+ }
7870
+ this.inMemoryContext.clearRect(0, 0, this.inMemoryCanvas.width, this.inMemoryCanvas.height);
7871
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
7872
+ this.inMemoryCanvas.width = imgData.width;
7873
+ this.inMemoryCanvas.height = imgData.height;
7874
+ this.inMemoryContext.putImageData(imgData, 0, 0);
7875
+ };
7876
+ ImageEditor.prototype.clearActObj = function () {
7877
+ if (this.textBox.style.display === 'none') {
7878
+ this.refreshActiveObj();
7879
+ this.applyActObj();
7880
+ this.refreshActiveObj();
7881
+ this.currObjType.isCustomCrop = false;
7882
+ }
6394
7883
  };
6395
7884
  ImageEditor.prototype.rotateMultiple = function (length, degree) {
6396
7885
  for (var i = 0; i < length; i++) {
@@ -6403,6 +7892,7 @@ var ImageEditor = /** @class */ (function (_super) {
6403
7892
  if (this.degree === 360) {
6404
7893
  this.degree = 0;
6405
7894
  }
7895
+ var temp = this.lowerContext.filter;
6406
7896
  this.lowerContext.save();
6407
7897
  this.setMaximumDimension(90 * (i + 1));
6408
7898
  this.lowerContext.translate(this.lowerCanvas.width / 2, this.lowerCanvas.height / 2);
@@ -6414,7 +7904,9 @@ var ImageEditor = /** @class */ (function (_super) {
6414
7904
  }
6415
7905
  this.lowerCanvas.style.left = this.upperCanvas.style.left = (this.element.clientWidth - parseInt(this.lowerCanvas.style.maxWidth, 10) - 18) / 2 + 1 + 'px';
6416
7906
  this.lowerCanvas.style.top = this.upperCanvas.style.top = (this.element.clientHeight - this.toolbarHeight - parseInt(this.lowerCanvas.style.maxHeight, 10)) / 2 + 1 + 'px';
7907
+ this.updateBrightnessFilter();
6417
7908
  this.lowerContext.drawImage(this.inMemoryCanvas, -this.lowerCanvas.height / 2, -this.lowerCanvas.width / 2);
7909
+ this.lowerContext.filter = temp;
6418
7910
  if (degree > 0) {
6419
7911
  this.lowerContext.rotate(Math.PI / 180 * -90);
6420
7912
  }
@@ -6428,7 +7920,11 @@ var ImageEditor = /** @class */ (function (_super) {
6428
7920
  this.inMemoryCanvas.width = this.currImgData.width;
6429
7921
  this.inMemoryCanvas.height = this.currImgData.height;
6430
7922
  this.inMemoryContext.putImageData(this.currImgData, 0, 0);
7923
+ this.lowerContext.filter = this.canvasFilter;
7924
+ this.updateBrightnessFilter();
7925
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
6431
7926
  this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
7927
+ this.lowerContext.filter = temp;
6432
7928
  if (degree > 0) {
6433
7929
  this.redrawObj(90);
6434
7930
  }
@@ -6437,6 +7933,415 @@ var ImageEditor = /** @class */ (function (_super) {
6437
7933
  }
6438
7934
  }
6439
7935
  };
7936
+ ImageEditor.prototype.setBrightness = function (value) {
7937
+ if (!this.disabled && this.imgDataColl.length > 0) {
7938
+ if (this.currObjType.shape === 'freehanddraw') {
7939
+ this.apply();
7940
+ this.upperCanvas.style.cursor = 'default';
7941
+ this.currObjType.shape = '';
7942
+ }
7943
+ this.clearActObj();
7944
+ this.adjustmentLevel.brightness = value;
7945
+ value = this.getFilterValue(value);
7946
+ this.updateAdjustment('brightness', value);
7947
+ }
7948
+ };
7949
+ ImageEditor.prototype.setContrast = 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.contrast = value;
7958
+ value = this.getFilterValue(value);
7959
+ value *= 100;
7960
+ this.updateAdjustment('contrast', value);
7961
+ }
7962
+ };
7963
+ ImageEditor.prototype.setHue = function (value) {
7964
+ if (!this.disabled && this.imgDataColl.length > 0) {
7965
+ if (this.currObjType.shape === 'freehanddraw') {
7966
+ this.apply();
7967
+ this.upperCanvas.style.cursor = 'default';
7968
+ this.currObjType.shape = '';
7969
+ }
7970
+ this.clearActObj();
7971
+ this.adjustmentLevel.hue = value;
7972
+ value *= 3;
7973
+ this.updateAdjustment('hue', value);
7974
+ }
7975
+ };
7976
+ ImageEditor.prototype.setSaturation = 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.saturation = value;
7985
+ value = this.getSaturationFilterValue(value);
7986
+ value *= 100;
7987
+ this.updateAdjustment('saturation', value);
7988
+ }
7989
+ };
7990
+ ImageEditor.prototype.setOpacity = function (value) {
7991
+ if (!this.disabled && this.imgDataColl.length > 0) {
7992
+ if (this.currObjType.shape === 'freehanddraw') {
7993
+ this.apply();
7994
+ this.upperCanvas.style.cursor = 'default';
7995
+ this.currObjType.shape = '';
7996
+ }
7997
+ this.clearActObj();
7998
+ this.adjustmentLevel.opacity = value;
7999
+ if (value >= 50) {
8000
+ value /= 100;
8001
+ }
8002
+ else if (value === 40) {
8003
+ value = 0.45;
8004
+ }
8005
+ else if (value === 30) {
8006
+ value = 0.40;
8007
+ }
8008
+ else if (value === 20) {
8009
+ value = 0.35;
8010
+ }
8011
+ else if (value === 10) {
8012
+ value = 0.30;
8013
+ }
8014
+ else if (value === 0) {
8015
+ value = 0.25;
8016
+ }
8017
+ this.updateAdjustment('opacity', value);
8018
+ }
8019
+ };
8020
+ ImageEditor.prototype.setBlur = function (value) {
8021
+ if (!this.disabled && this.imgDataColl.length > 0) {
8022
+ if (this.currObjType.shape === 'freehanddraw') {
8023
+ this.apply();
8024
+ this.upperCanvas.style.cursor = 'default';
8025
+ this.currObjType.shape = '';
8026
+ }
8027
+ this.clearActObj();
8028
+ this.adjustmentLevel.blur = value;
8029
+ value /= 20;
8030
+ this.updateAdjustment('blur', value);
8031
+ }
8032
+ };
8033
+ ImageEditor.prototype.setExposure = function (value) {
8034
+ if (!this.disabled && this.imgDataColl.length > 0) {
8035
+ if (this.currObjType.shape === 'freehanddraw') {
8036
+ this.apply();
8037
+ this.upperCanvas.style.cursor = 'default';
8038
+ this.currObjType.shape = '';
8039
+ }
8040
+ this.clearActObj();
8041
+ this.adjustmentLevel.exposure = value;
8042
+ value = this.getFilterValue(value);
8043
+ this.updateAdjustment('exposure', value);
8044
+ }
8045
+ };
8046
+ ImageEditor.prototype.setFilter = function (type) {
8047
+ if (!this.disabled && this.imgDataColl.length > 0) {
8048
+ if (this.currObjType.shape === 'freehanddraw') {
8049
+ this.apply();
8050
+ this.upperCanvas.style.cursor = 'default';
8051
+ this.currObjType.shape = '';
8052
+ }
8053
+ this.clearActObj();
8054
+ this.updateAdjustment(type, null);
8055
+ }
8056
+ };
8057
+ ImageEditor.prototype.setBlackAndWhiteFilter = function (boolean) {
8058
+ if (!this.disabled && this.imgDataColl.length > 0) {
8059
+ if (this.currObjType.shape === 'freehanddraw') {
8060
+ this.apply();
8061
+ this.upperCanvas.style.cursor = 'default';
8062
+ this.currObjType.shape = '';
8063
+ }
8064
+ this.clearActObj();
8065
+ this.adjustmentLevel.bw = boolean;
8066
+ if (boolean) {
8067
+ if (this.degree === 0 && this.currFlipState === '') {
8068
+ this.replaceBWSharpenData('bw');
8069
+ }
8070
+ else if (this.degree !== 0) {
8071
+ var tempDegree = this.degree;
8072
+ this.rotate(-tempDegree);
8073
+ this.replaceBWSharpenData('bw');
8074
+ this.rotate(tempDegree);
8075
+ this.refreshToolbar('filter');
8076
+ }
8077
+ else if (this.currFlipState !== '') {
8078
+ var tempFlipState = this.currFlipState;
8079
+ this.flip(tempFlipState);
8080
+ this.replaceBWSharpenData('bw');
8081
+ this.flip(tempFlipState);
8082
+ this.refreshToolbar('filter');
8083
+ }
8084
+ var data = this.inMemoryContext.getImageData(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
8085
+ var imageData = this.getBlackAndWhiteData(data);
8086
+ this.inMemoryContext.clearRect(0, 0, this.inMemoryCanvas.width, this.inMemoryCanvas.height);
8087
+ this.inMemoryCanvas.width = imageData.width;
8088
+ this.inMemoryCanvas.height = imageData.height;
8089
+ this.inMemoryContext.putImageData(imageData, 0, 0);
8090
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
8091
+ this.lowerContext.filter = this.canvasFilter;
8092
+ var temp = this.lowerContext.filter;
8093
+ this.updateBrightnessFilter();
8094
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
8095
+ this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
8096
+ this.lowerContext.filter = temp;
8097
+ }
8098
+ else {
8099
+ if (this.degree === 0 && this.currFlipState === '') {
8100
+ this.updateBWSharpness();
8101
+ }
8102
+ else if (this.degree !== 0) {
8103
+ var tempDegree = this.degree;
8104
+ this.rotate(-tempDegree);
8105
+ this.updateBWSharpness();
8106
+ this.rotate(tempDegree);
8107
+ this.refreshToolbar('filter');
8108
+ if (this.sharpenedImgData) {
8109
+ this.sharpenedImgData = false;
8110
+ }
8111
+ }
8112
+ else if (this.currFlipState !== '') {
8113
+ var tempFlipState = this.currFlipState;
8114
+ this.flip(tempFlipState);
8115
+ this.updateBWSharpness();
8116
+ this.flip(tempFlipState);
8117
+ this.refreshToolbar('filter');
8118
+ if (this.sharpenedImgData) {
8119
+ this.sharpenedImgData = false;
8120
+ }
8121
+ }
8122
+ }
8123
+ }
8124
+ };
8125
+ ImageEditor.prototype.setSharpness = function (boolean) {
8126
+ if (!this.disabled && this.imgDataColl.length > 0) {
8127
+ if (this.currObjType.shape === 'freehanddraw') {
8128
+ this.apply();
8129
+ this.upperCanvas.style.cursor = 'default';
8130
+ this.currObjType.shape = '';
8131
+ }
8132
+ this.clearActObj();
8133
+ this.adjustmentLevel.sharpen = boolean;
8134
+ if (boolean) {
8135
+ if (this.degree === 0 && this.currFlipState === '') {
8136
+ this.replaceBWSharpenData('sharpen');
8137
+ }
8138
+ else if (this.degree !== 0) {
8139
+ var tempDegree = this.degree;
8140
+ this.rotate(-tempDegree);
8141
+ this.replaceBWSharpenData('sharpen');
8142
+ this.rotate(tempDegree);
8143
+ this.refreshToolbar('filter');
8144
+ }
8145
+ else if (this.currFlipState !== '') {
8146
+ var tempFlipState = this.currFlipState;
8147
+ this.flip(tempFlipState);
8148
+ this.replaceBWSharpenData('sharpen');
8149
+ this.flip(tempFlipState);
8150
+ this.refreshToolbar('filter');
8151
+ }
8152
+ var data = this.inMemoryContext.getImageData(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
8153
+ var imageData = this.getSharpenData(data);
8154
+ this.inMemoryContext.clearRect(0, 0, this.inMemoryCanvas.width, this.inMemoryCanvas.height);
8155
+ this.inMemoryCanvas.width = imageData.width;
8156
+ this.inMemoryCanvas.height = imageData.height;
8157
+ this.inMemoryContext.putImageData(imageData, 0, 0);
8158
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
8159
+ this.lowerContext.filter = this.canvasFilter;
8160
+ var temp = this.lowerContext.filter;
8161
+ this.updateBrightnessFilter();
8162
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
8163
+ this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
8164
+ this.lowerContext.filter = temp;
8165
+ }
8166
+ else {
8167
+ if (this.degree === 0 && this.currFlipState === '') {
8168
+ this.updateBWSharpness();
8169
+ }
8170
+ else if (this.degree !== 0) {
8171
+ var tempDegree = this.degree;
8172
+ this.rotate(-tempDegree);
8173
+ this.updateBWSharpness();
8174
+ this.rotate(tempDegree);
8175
+ this.refreshToolbar('filter');
8176
+ if (this.sharpenedImgData) {
8177
+ this.sharpenedImgData = false;
8178
+ }
8179
+ }
8180
+ else if (this.currFlipState !== '') {
8181
+ var tempFlipState = this.currFlipState;
8182
+ this.flip(tempFlipState);
8183
+ this.updateBWSharpness();
8184
+ this.flip(tempFlipState);
8185
+ this.refreshToolbar('filter');
8186
+ if (this.sharpenedImgData) {
8187
+ this.sharpenedImgData = false;
8188
+ }
8189
+ }
8190
+ }
8191
+ }
8192
+ };
8193
+ ImageEditor.prototype.replaceBWSharpenData = function (type) {
8194
+ this.tempImageData = this.inMemoryContext.getImageData(0, 0, this.inMemoryCanvas.width, this.inMemoryCanvas.height);
8195
+ var imageData = this.inMemoryContext.getImageData(0, 0, this.inMemoryCanvas.width, this.inMemoryCanvas.height);
8196
+ if (type === 'sharpen') {
8197
+ imageData = this.getSharpenData(this.tempImageData);
8198
+ }
8199
+ else {
8200
+ imageData = this.getBlackAndWhiteData(imageData);
8201
+ }
8202
+ this.inMemoryContext.clearRect(0, 0, this.inMemoryCanvas.width, this.inMemoryCanvas.height);
8203
+ this.inMemoryCanvas.width = imageData.width;
8204
+ this.inMemoryCanvas.height = imageData.height;
8205
+ this.inMemoryContext.putImageData(imageData, 0, 0);
8206
+ var tempObj;
8207
+ for (var index = 0; index < this.imgDataColl.length; index++) {
8208
+ if (this.imgDataColl[index].operation !== 'freehanddraw') {
8209
+ tempObj = this.imgDataColl[index];
8210
+ break;
8211
+ }
8212
+ }
8213
+ this.imgDataColl.splice(0, 1, { operation: 'updateCanvas', value: imageData });
8214
+ this.imgDataColl.splice(1, 1, tempObj);
8215
+ this.inMemoryContext.clearRect(0, 0, this.inMemoryCanvas.width, this.inMemoryCanvas.height);
8216
+ this.inMemoryCanvas.width = this.tempImageData.width;
8217
+ this.inMemoryCanvas.height = this.tempImageData.height;
8218
+ this.inMemoryContext.putImageData(this.tempImageData, 0, 0);
8219
+ };
8220
+ ImageEditor.prototype.updateBWSharpness = function () {
8221
+ this.inMemoryContext.clearRect(0, 0, this.inMemoryCanvas.width, this.inMemoryCanvas.height);
8222
+ this.inMemoryCanvas.width = this.tempImageData.width;
8223
+ this.inMemoryCanvas.height = this.tempImageData.height;
8224
+ this.inMemoryContext.putImageData(this.tempImageData, 0, 0);
8225
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
8226
+ this.lowerContext.filter = this.canvasFilter;
8227
+ this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
8228
+ this.imgDataColl.shift();
8229
+ };
8230
+ ImageEditor.prototype.getSharpenData = function (imageData) {
8231
+ var data = imageData.data;
8232
+ var weights = [0, -1, 0, -1, 5, -1, 0, -1, 0];
8233
+ var side = Math.round(Math.sqrt(weights.length));
8234
+ var halfSide = Math.floor(side / 2);
8235
+ var sw = imageData.width;
8236
+ var sh = imageData.height;
8237
+ var output = this.inMemoryContext.createImageData(sw, sh);
8238
+ var dst = output.data;
8239
+ // go through the destination image pixels
8240
+ var alphaFac = 0;
8241
+ var r;
8242
+ var g;
8243
+ var b;
8244
+ var a;
8245
+ var dstOff;
8246
+ var scx;
8247
+ var scy;
8248
+ var srcOff;
8249
+ var wt;
8250
+ var x;
8251
+ var y;
8252
+ var cx;
8253
+ var cy;
8254
+ for (y = 0; y < sh; y++) {
8255
+ for (x = 0; x < sw; x++) {
8256
+ dstOff = (y * sw + x) * 4;
8257
+ r = 0;
8258
+ g = 0;
8259
+ b = 0;
8260
+ a = 0;
8261
+ for (cy = 0; cy < side; cy++) {
8262
+ for (cx = 0; cx < side; cx++) {
8263
+ scy = y + cy - halfSide;
8264
+ scx = x + cx - halfSide;
8265
+ if (scy < 0 || scy >= sh || scx < 0 || scx >= sw) {
8266
+ continue;
8267
+ }
8268
+ srcOff = (scy * sw + scx) * 4;
8269
+ wt = weights[cy * side + cx];
8270
+ r += data[srcOff] * wt;
8271
+ g += data[srcOff + 1] * wt;
8272
+ b += data[srcOff + 2] * wt;
8273
+ if (!alphaFac) {
8274
+ a += data[srcOff + 3] * wt;
8275
+ }
8276
+ }
8277
+ }
8278
+ dst[dstOff] = r;
8279
+ dst[dstOff + 1] = g;
8280
+ dst[dstOff + 2] = b;
8281
+ if (!alphaFac) {
8282
+ dst[dstOff + 3] = a;
8283
+ }
8284
+ else {
8285
+ dst[dstOff + 3] = data[dstOff + 3];
8286
+ }
8287
+ }
8288
+ }
8289
+ return output;
8290
+ };
8291
+ ImageEditor.prototype.getFilterValue = function (value) {
8292
+ var filterValue;
8293
+ if (value === 0) {
8294
+ filterValue = 1;
8295
+ }
8296
+ else {
8297
+ filterValue = 1 + ((value * 0.5) / 100);
8298
+ }
8299
+ return filterValue;
8300
+ };
8301
+ ImageEditor.prototype.setFilterValue = function (value) {
8302
+ var filterValue;
8303
+ if (value === 1) {
8304
+ filterValue = 0;
8305
+ }
8306
+ else {
8307
+ filterValue = ((value - 1) * 100) / 0.5;
8308
+ }
8309
+ return Math.round(filterValue);
8310
+ };
8311
+ ImageEditor.prototype.getSaturationFilterValue = function (value) {
8312
+ var filterValue;
8313
+ if (value === 0) {
8314
+ filterValue = 1;
8315
+ }
8316
+ else {
8317
+ filterValue = 1 + (value / 100);
8318
+ }
8319
+ return filterValue;
8320
+ };
8321
+ ImageEditor.prototype.setSaturationFilterValue = function (value) {
8322
+ var filterValue;
8323
+ if (value === 1) {
8324
+ filterValue = 0;
8325
+ }
8326
+ else {
8327
+ filterValue = (value - 1) * 100;
8328
+ }
8329
+ return Math.round(filterValue);
8330
+ };
8331
+ ImageEditor.prototype.getBlackAndWhiteData = function (imageData) {
8332
+ for (var i = 0; i < imageData.data.length; i += 4) {
8333
+ var count = imageData.data[i] + imageData.data[i + 1] + imageData.data[i + 2];
8334
+ var colour = 0;
8335
+ if (count > 383) {
8336
+ colour = 255;
8337
+ }
8338
+ imageData.data[i] = colour;
8339
+ imageData.data[i + 1] = colour;
8340
+ imageData.data[i + 2] = colour;
8341
+ imageData.data[i + 3] = 255;
8342
+ }
8343
+ return imageData;
8344
+ };
6440
8345
  /**
6441
8346
  * Clear a current selection.
6442
8347
  *
@@ -6473,6 +8378,16 @@ var ImageEditor = /** @class */ (function (_super) {
6473
8378
  // eslint-disable-next-line @typescript-eslint/no-this-alias
6474
8379
  var proxy_2 = this;
6475
8380
  isCrop = true;
8381
+ var canvasFilter = this.canvasFilter;
8382
+ var tempActObj = extend({}, this.activeObj, {}, true);
8383
+ this.lowerContext.filter = this.canvasFilter = 'none';
8384
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
8385
+ this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
8386
+ for (var j = 0; j < this.objColl.length; j++) {
8387
+ this.apply(this.objColl[j].shape, this.objColl[j]);
8388
+ this.refreshActiveObj();
8389
+ }
8390
+ this.activeObj = tempActObj;
6476
8391
  this.upperCanvas.style.display = 'none';
6477
8392
  var widthRatio = void 0;
6478
8393
  var heightRatio = void 0;
@@ -6512,6 +8427,7 @@ var ImageEditor = /** @class */ (function (_super) {
6512
8427
  this.updateInMemoryContext(imgData);
6513
8428
  }
6514
8429
  this.degree = 0;
8430
+ this.updateBrightnessFilter();
6515
8431
  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);
6516
8432
  }
6517
8433
  if (this.flipState !== '') {
@@ -6526,6 +8442,7 @@ var ImageEditor = /** @class */ (function (_super) {
6526
8442
  this.lowerCanvas.style.maxHeight = this.upperCanvas.style.maxHeight = maxDimension.height + 'px';
6527
8443
  this.lowerCanvas.width = this.upperCanvas.width = maxDimension.width * widthRatio;
6528
8444
  this.lowerCanvas.height = this.upperCanvas.height = maxDimension.height * heightRatio;
8445
+ this.updateBrightnessFilter();
6529
8446
  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);
6530
8447
  }
6531
8448
  }
@@ -6546,6 +8463,7 @@ var ImageEditor = /** @class */ (function (_super) {
6546
8463
  ((this.element.clientWidth - parseInt(cssObj.width, 10) - 18) / 2) + 1 + 'px';
6547
8464
  this.lowerCanvas.style.top = this.upperCanvas.style.top = ((this.element.clientHeight - this.toolbarHeight
6548
8465
  - parseInt(cssObj.height, 10)) / 2) + 1 + 'px';
8466
+ this.updateBrightnessFilter();
6549
8467
  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);
6550
8468
  }
6551
8469
  if (this.activeObj.shape === 'crop-circle') {
@@ -6554,6 +8472,7 @@ var ImageEditor = /** @class */ (function (_super) {
6554
8472
  this.inMemoryCanvas.height = imgData_1.height;
6555
8473
  this.inMemoryContext.putImageData(imgData_1, 0, 0);
6556
8474
  this.lowerContext.save();
8475
+ this.updateBrightnessFilter();
6557
8476
  this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0, this.baseImg.width, this.baseImg.height);
6558
8477
  this.lowerContext.globalCompositeOperation = 'destination-in';
6559
8478
  this.lowerContext.beginPath();
@@ -6566,18 +8485,11 @@ var ImageEditor = /** @class */ (function (_super) {
6566
8485
  showSpinner(this.element);
6567
8486
  this.element.style.opacity = '0.5';
6568
8487
  var blobUrl_1;
6569
- var data_1;
6570
8488
  // eslint-disable-next-line @typescript-eslint/tslint/config
6571
8489
  this.lowerCanvas.toBlob(function (blob) {
6572
8490
  blobUrl_1 = URL.createObjectURL(blob);
6573
- proxy_2.isUndoRedo = false;
6574
8491
  proxy_2.baseImg.src = blobUrl_1;
6575
- data_1 = proxy_2.lowerContext.getImageData(0, 0, proxy_2.lowerCanvas.width, proxy_2.lowerCanvas.height);
6576
8492
  proxy_2.imgDataColl = [];
6577
- if (!proxy_2.isUndoRedo) {
6578
- proxy_2.updateUndoRedoColl('crop', data_1, proxy_2.objColl);
6579
- }
6580
- proxy_2.isUndoRedo = false;
6581
8493
  }, 'image/png');
6582
8494
  this.objColl = [];
6583
8495
  this.refreshActiveObj();
@@ -6586,26 +8498,11 @@ var ImageEditor = /** @class */ (function (_super) {
6586
8498
  this.upperContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
6587
8499
  this.lowerContext.globalAlpha = 0;
6588
8500
  this.lowerContext.fillRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
6589
- this.lowerContext.setTransform(1, 0, 0, 1, 0, 0);
6590
- this.upperContext.setTransform(1, 0, 0, 1, 0, 0);
6591
8501
  this.factor = 1;
8502
+ this.canvasFilter = canvasFilter;
6592
8503
  }
6593
8504
  return isCrop;
6594
8505
  };
6595
- ImageEditor.prototype.updateInMemoryContext = function (imgData) {
6596
- this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
6597
- var temp = extend({}, this.activeObj, {}, true);
6598
- for (var i = 0; i < this.objColl.length; i++) {
6599
- this.apply(this.objColl[i].shape, this.objColl[i]);
6600
- }
6601
- this.activeObj = temp;
6602
- imgData = this.lowerContext.getImageData(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
6603
- this.inMemoryContext.clearRect(0, 0, this.inMemoryCanvas.width, this.inMemoryCanvas.height);
6604
- this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
6605
- this.inMemoryCanvas.width = imgData.width;
6606
- this.inMemoryCanvas.height = imgData.height;
6607
- this.inMemoryContext.putImageData(imgData, 0, 0);
6608
- };
6609
8506
  /**
6610
8507
  * Flips an image by horizontally or vertically.
6611
8508
  *
@@ -6622,8 +8519,8 @@ var ImageEditor = /** @class */ (function (_super) {
6622
8519
  }
6623
8520
  var transitionArgs = { direction: direction };
6624
8521
  this.trigger('flipping', transitionArgs);
6625
- this.lastAction = 'flip';
6626
- this.flipMethod = true;
8522
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
8523
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
6627
8524
  var splitWords = [];
6628
8525
  var activeObjShape = void 0;
6629
8526
  if (!isNullOrUndefined(this.activeObj.activePoint)) {
@@ -6644,7 +8541,6 @@ var ImageEditor = /** @class */ (function (_super) {
6644
8541
  this.lowerContext.scale(-1, 1);
6645
8542
  this.upperContext.translate(this.upperContext.canvas.width, 0);
6646
8543
  this.upperContext.scale(-1, 1);
6647
- this.flipDirection = 'horizontal';
6648
8544
  if (this.flipState === '' || this.flipState.toLowerCase() === 'vertical') {
6649
8545
  this.flipState = 'horizontal';
6650
8546
  }
@@ -6660,7 +8556,6 @@ var ImageEditor = /** @class */ (function (_super) {
6660
8556
  this.lowerContext.scale(1, -1);
6661
8557
  this.upperContext.translate(0, this.upperContext.canvas.height);
6662
8558
  this.upperContext.scale(1, -1);
6663
- this.flipDirection = 'vertical';
6664
8559
  if (this.flipState.toLowerCase() === '' || this.flipState.toLowerCase() === 'horizontal') {
6665
8560
  this.flipState = 'vertical';
6666
8561
  }
@@ -6671,13 +8566,25 @@ var ImageEditor = /** @class */ (function (_super) {
6671
8566
  this.currFlipState = 'vertical';
6672
8567
  }
6673
8568
  }
8569
+ var temp = this.lowerContext.filter;
8570
+ this.updateBrightnessFilter();
8571
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
6674
8572
  this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
8573
+ this.lowerContext.filter = temp;
6675
8574
  this.currImgData = this.lowerContext.getImageData(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
8575
+ this.lowerContext.filter = this.canvasFilter;
8576
+ this.updateBrightnessFilter();
8577
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
8578
+ this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
8579
+ this.lowerContext.filter = temp;
6676
8580
  this.inMemoryContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
6677
8581
  this.inMemoryCanvas.width = this.currImgData.width;
6678
8582
  this.inMemoryCanvas.height = this.currImgData.height;
6679
8583
  this.inMemoryContext.putImageData(this.currImgData, 0, 0);
6680
8584
  if (this.flipState.toLowerCase() === 'horizontal') {
8585
+ var tempFilter = this.lowerContext.filter;
8586
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
8587
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
6681
8588
  for (var i = 0, len = this.objColl.length; i < len; i++) {
6682
8589
  this.objColl[i].flippedText = false;
6683
8590
  if (this.objColl[i].shapeFlip !== '' && this.objColl[i].shapeFlip === this.currFlipState) {
@@ -6687,13 +8594,16 @@ var ImageEditor = /** @class */ (function (_super) {
6687
8594
  this.apply(this.objColl[i].shape, this.objColl[i]);
6688
8595
  }
6689
8596
  }
8597
+ this.lowerContext.filter = tempFilter;
6690
8598
  this.lowerContext.translate(this.lowerContext.canvas.width, 0);
6691
8599
  this.lowerContext.scale(-1, 1);
6692
8600
  this.upperContext.translate(this.upperContext.canvas.width, 0);
6693
8601
  this.upperContext.scale(-1, 1);
6694
- this.flipDirection = '';
6695
8602
  }
6696
8603
  else if (this.flipState.toLowerCase() === 'vertical') {
8604
+ var tempFilter = this.lowerContext.filter;
8605
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
8606
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
6697
8607
  for (var i = 0, len = this.objColl.length; i < len; i++) {
6698
8608
  this.objColl[i].flippedText = false;
6699
8609
  if (this.objColl[i].shapeFlip !== '' && this.objColl[i].shapeFlip === this.currFlipState) {
@@ -6703,11 +8613,11 @@ var ImageEditor = /** @class */ (function (_super) {
6703
8613
  this.apply(this.objColl[i].shape, this.objColl[i]);
6704
8614
  }
6705
8615
  }
8616
+ this.lowerContext.filter = tempFilter;
6706
8617
  this.lowerContext.translate(0, this.lowerContext.canvas.height);
6707
8618
  this.lowerContext.scale(1, -1);
6708
8619
  this.upperContext.translate(0, this.upperContext.canvas.height);
6709
8620
  this.upperContext.scale(1, -1);
6710
- this.flipDirection = '';
6711
8621
  }
6712
8622
  for (var i = 0, len = this.objColl.length; i < len; i++) {
6713
8623
  if (this.objColl[i].flipObjColl.length === 0) {
@@ -6722,15 +8632,15 @@ var ImageEditor = /** @class */ (function (_super) {
6722
8632
  }
6723
8633
  this.redrawObj(direction.toLowerCase());
6724
8634
  if (this.flipState === '') {
8635
+ var tempFilter = this.lowerContext.filter;
8636
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
8637
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
6725
8638
  for (var i = 0, len = this.objColl.length; i < len; i++) {
6726
8639
  this.apply(this.objColl[i].shape, this.objColl[i]);
6727
8640
  }
8641
+ this.lowerContext.filter = tempFilter;
6728
8642
  }
6729
8643
  this.refreshActiveObj();
6730
- if (!this.isUndoRedo) {
6731
- this.updateUndoRedoColl('flip', direction, this.objColl);
6732
- }
6733
- this.isUndoRedo = this.flipMethod = false;
6734
8644
  if (!isNullOrUndefined(activeObjShape)) {
6735
8645
  if (activeObjShape === 'custom') {
6736
8646
  this.activeObj.activePoint = { startX: 0, startY: 0, endX: this.lowerCanvas.width,
@@ -6742,6 +8652,7 @@ var ImageEditor = /** @class */ (function (_super) {
6742
8652
  this.select(activeObjShape);
6743
8653
  }
6744
8654
  }
8655
+ this.refreshToolbar('main');
6745
8656
  }
6746
8657
  };
6747
8658
  /**
@@ -6762,11 +8673,13 @@ var ImageEditor = /** @class */ (function (_super) {
6762
8673
  */
6763
8674
  ImageEditor.prototype.open = function (data) {
6764
8675
  if (!this.disabled) {
8676
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
8677
+ var proxy_3 = this;
6765
8678
  showSpinner(this.element);
6766
8679
  this.element.style.opacity = '0.5';
6767
- var toolbar_10 = document.querySelector('#' + this.element.id + '_currPos');
6768
- if (toolbar_10) {
6769
- toolbar_10.style.display = 'none';
8680
+ var toolbar_11 = document.querySelector('#' + this.element.id + '_currPos');
8681
+ if (toolbar_11) {
8682
+ toolbar_11.style.display = 'none';
6770
8683
  }
6771
8684
  if (this.defToolbarItems.length === 0 &&
6772
8685
  (isNullOrUndefined(document.getElementById(this.element.id + '_toolbar')))) {
@@ -6775,11 +8688,30 @@ var ImageEditor = /** @class */ (function (_super) {
6775
8688
  if (isNullOrUndefined(this.toolbarTemplate)) {
6776
8689
  this.update();
6777
8690
  }
8691
+ this.degree = 0;
8692
+ this.flipState = '';
8693
+ this.factor = 1;
8694
+ this.imgDataColl = [];
6778
8695
  var type = typeof (data);
6779
8696
  if (type === 'string') {
8697
+ var fileName = data.split('.');
8698
+ if (fileName[fileName.length - 1].toLowerCase() === 'jpg' || fileName[fileName.length - 1].toLowerCase() === 'jpeg') {
8699
+ this.imageFileType = 'Jpeg';
8700
+ }
8701
+ else if (fileName[fileName.length - 1].toLowerCase() === 'png') {
8702
+ this.imageFileType = 'Png';
8703
+ }
8704
+ else if (fileName[fileName.length - 1].toLowerCase() === 'svg') {
8705
+ this.imageFileType = 'Svg';
8706
+ }
8707
+ fileName = fileName[fileName.length - 2].split('/');
8708
+ this.imageFileName = fileName[fileName.length - 1];
6780
8709
  this.imageOnLoad(data);
6781
8710
  }
6782
8711
  else {
8712
+ this.imageFileName = 'ImageEditor';
8713
+ this.imageFileType = 'Jpeg';
8714
+ var tempFilter = this.lowerContext.filter;
6783
8715
  this.lowerCanvas = document.querySelector('#' + this.element.id + '_lowerCanvas');
6784
8716
  this.upperCanvas = document.querySelector('#' + this.element.id + '_upperCanvas');
6785
8717
  this.lowerContext = this.lowerCanvas.getContext('2d');
@@ -6793,10 +8725,19 @@ var ImageEditor = /** @class */ (function (_super) {
6793
8725
  this.imgDataColl.push({ operation: 'open', value: data });
6794
8726
  this.lowerCanvas.width = this.upperCanvas.width = data.width;
6795
8727
  this.lowerCanvas.height = this.upperCanvas.height = data.height;
8728
+ this.lowerContext.filter = tempFilter;
8729
+ var temp = this.lowerContext.filter;
8730
+ this.updateBrightnessFilter();
6796
8731
  this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
6797
- this.updateCanvas();
8732
+ this.lowerContext.filter = temp;
8733
+ this.redrawImg(this.lowerContext.filter);
6798
8734
  hideSpinner(this.element);
6799
8735
  this.element.style.opacity = '1';
8736
+ // eslint-disable-next-line @typescript-eslint/tslint/config
8737
+ this.lowerCanvas.toBlob(function (blob) {
8738
+ showSpinner(proxy_3.element);
8739
+ proxy_3.baseImg.src = URL.createObjectURL(blob);
8740
+ }, 'image/png');
6800
8741
  }
6801
8742
  }
6802
8743
  };
@@ -6813,6 +8754,8 @@ var ImageEditor = /** @class */ (function (_super) {
6813
8754
  this.lowerContext.clearRect(0, 0, this.inMemoryCanvas.height, this.inMemoryCanvas.width);
6814
8755
  this.upperContext.clearRect(0, 0, this.inMemoryCanvas.width, this.inMemoryCanvas.height);
6815
8756
  this.upperContext.clearRect(0, 0, this.inMemoryCanvas.height, this.inMemoryCanvas.width);
8757
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
8758
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
6816
8759
  showSpinner(this.element);
6817
8760
  this.element.style.opacity = '0.5';
6818
8761
  if (this.imgDataColl.length > 0) {
@@ -6823,11 +8766,13 @@ var ImageEditor = /** @class */ (function (_super) {
6823
8766
  this.inMemoryCanvas.width = this.imgDataColl[0].value.width;
6824
8767
  this.inMemoryCanvas.height = this.imgDataColl[0].value.height;
6825
8768
  this.inMemoryContext.putImageData(this.imgDataColl[0].value, 0, 0);
6826
- this.redrawImg();
8769
+ this.redrawImg(this.lowerContext.filter);
8770
+ this.lowerCanvas.width = this.baseImg.width;
8771
+ this.lowerCanvas.height = this.baseImg.height;
6827
8772
  }
6828
8773
  this.lowerContext.setTransform(1, 0, 0, 1, 0, 0);
6829
8774
  this.upperContext.setTransform(1, 0, 0, 1, 0, 0);
6830
- this.baseImg.src = this.baseImgSrc;
8775
+ this.baseImg.src = this.baseImgSrc.id;
6831
8776
  this.factor = 1;
6832
8777
  this.refreshToolbar('main');
6833
8778
  if (Browser.isDevice && document.getElementById(this.element.id + '_bottomToolbar')) {
@@ -6836,22 +8781,20 @@ var ImageEditor = /** @class */ (function (_super) {
6836
8781
  this.objColl = [];
6837
8782
  this.imgDataColl = [];
6838
8783
  this.degree = 0;
6839
- this.flipState = this.keyHistory = this.currFlipState = this.flipDirection = '';
8784
+ this.flipState = this.keyHistory = this.currFlipState = '';
6840
8785
  this.upperCanvas.style.display = 'none';
8786
+ this.togglePan = this.togglePen = false;
6841
8787
  this.upperCanvas.style.cursor = this.lowerCanvas.style.cursor = 'default';
6842
- this.undoRedoColl = [];
6843
- this.dragCanvas = this.dragged = this.isUndoRedo = this.activeObj.flippedText = this.flipMethod = false;
8788
+ this.dragCanvas = this.activeObj.flippedText = false;
6844
8789
  this.currImgData = {};
6845
8790
  this.pannStart = { startX: 0, startY: 0, width: 0, height: 0 };
6846
8791
  this.pannEnd = { startX: 0, startY: 0, width: 0, height: 0 };
6847
8792
  this.lowerContext.lineWidth = this.upperContext.lineWidth = undefined;
6848
- this.togglePan = this.togglePen = this.rotateMethod = false;
6849
8793
  this.lastX = this.lastY = 0;
6850
8794
  this.dragStart = { x: 0, y: 0 };
6851
8795
  this.touchEndPoint = {};
6852
8796
  this.prevX = this.currX = this.prevY = this.currY = 0;
6853
- this.lastAction = this.tempKeyHistory = '';
6854
- this.isBoldbtn = this.isItalicbtn = false;
8797
+ this.tempKeyHistory = '';
6855
8798
  this.currentToolbar = 'main';
6856
8799
  this.textStartPoints = { x: 0, y: 0 };
6857
8800
  this.fontSizeColl = this.penDrawColl = [];
@@ -6861,14 +8804,26 @@ var ImageEditor = /** @class */ (function (_super) {
6861
8804
  this.textSettings =
6862
8805
  { text: 'Enter Text', fontFamily: 'Arial', fontSize: null, bold: false, italic: false, underline: false };
6863
8806
  this.tempStrokeSettings = { strokeColor: '#fff', fillColor: '', strokeWidth: null };
6864
- this.penStrokeWidth = undefined;
6865
8807
  this.tempTextSettings =
6866
8808
  { text: 'Enter Text', fontFamily: 'Arial', fontSize: null, bold: false, italic: false, underline: false };
6867
8809
  this.refreshActiveObj();
6868
8810
  this.timer = undefined;
8811
+ this.penStrokeWidth = undefined;
6869
8812
  this.isScreenOriented = false;
8813
+ this.tempObjColl = [];
8814
+ this.tempObjColl = undefined;
8815
+ this.adjustmentLevel = { brightness: 0, contrast: 0, hue: 0, opacity: 100, saturation: 0, blur: 0, exposure: 0, sharpen: false, bw: false };
8816
+ this.tempAdjustmentLevel = { brightness: 0, contrast: 0, hue: 0, opacity: 100, saturation: 0, blur: 0, exposure: 0, sharpen: false, bw: false };
8817
+ this.imageFileName = '';
8818
+ this.imageFileType = undefined;
8819
+ this.canvasFilter = this.currentFilter = this.tempAdjustmentValue = '';
8820
+ this.lowerContext.filter = this.initialAdjustmentValue = this.adjustmentValue = 'brightness(' + 1 + ') ' + 'contrast(' + 100
8821
+ + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
8822
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
8823
+ this.tempImageData = undefined;
8824
+ this.sharpenedImgData = this.isBrightnessAdjusted = this.isInitialLoading = false;
6870
8825
  this.currObjType = { shape: '', isDragging: false, isActiveObj: false, isText: false, isInitialText: false, isLine: false,
6871
- isInitialLine: false, isCustomCrop: false, isZoomed: false };
8826
+ isInitialLine: false, isCustomCrop: false, isZoomed: false, isFiltered: false, isSave: false };
6872
8827
  }
6873
8828
  };
6874
8829
  /**
@@ -6896,7 +8851,6 @@ var ImageEditor = /** @class */ (function (_super) {
6896
8851
  }
6897
8852
  }
6898
8853
  this.redrawActObj();
6899
- var factor = this.factor;
6900
8854
  if (this.factor !== 1) {
6901
8855
  this.lowerContext.setTransform(1, 0, 0, 1, 0, 0);
6902
8856
  this.upperContext.setTransform(1, 0, 0, 1, 0, 0);
@@ -6912,13 +8866,16 @@ var ImageEditor = /** @class */ (function (_super) {
6912
8866
  if (this.degree === 360) {
6913
8867
  this.degree = 0;
6914
8868
  }
8869
+ var temp = this.lowerContext.filter;
6915
8870
  this.lowerContext.save();
6916
8871
  this.setMaximumDimension(this.degree);
6917
8872
  this.lowerContext.translate(this.lowerCanvas.width / 2, this.lowerCanvas.height / 2);
6918
8873
  this.lowerContext.rotate(Math.PI / 180 * degree);
6919
8874
  this.lowerCanvas.style.left = this.upperCanvas.style.left = (this.element.clientWidth - parseInt(this.lowerCanvas.style.maxWidth, 10) - 18) / 2 + 1 + 'px';
6920
8875
  this.lowerCanvas.style.top = this.upperCanvas.style.top = (this.element.clientHeight - this.toolbarHeight - parseInt(this.lowerCanvas.style.maxHeight, 10)) / 2 + 1 + 'px';
8876
+ this.updateBrightnessFilter();
6921
8877
  this.lowerContext.drawImage(this.inMemoryCanvas, -this.lowerCanvas.height / 2, -this.lowerCanvas.width / 2);
8878
+ this.lowerContext.filter = temp;
6922
8879
  this.lowerContext.rotate(Math.PI / 180 * -degree);
6923
8880
  this.lowerContext.translate(-this.lowerCanvas.width / 2, -this.lowerCanvas.height / 2);
6924
8881
  this.lowerContext.restore();
@@ -6927,12 +8884,17 @@ var ImageEditor = /** @class */ (function (_super) {
6927
8884
  this.inMemoryCanvas.width = this.currImgData.width;
6928
8885
  this.inMemoryCanvas.height = this.currImgData.height;
6929
8886
  this.inMemoryContext.putImageData(this.currImgData, 0, 0);
8887
+ this.lowerContext.filter = this.canvasFilter;
8888
+ this.updateBrightnessFilter();
8889
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
6930
8890
  this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
8891
+ this.lowerContext.filter = temp;
6931
8892
  this.redrawObj(degree);
6932
8893
  }
6933
8894
  if (!isNullOrUndefined(activeObjShape)) {
6934
8895
  if (activeObjShape === 'custom') {
6935
- var endPoint = { x: this.lowerCanvas.width - this.pannEnd.startX, y: this.lowerCanvas.height - this.pannEnd.startY };
8896
+ var endPoint = { x: this.lowerCanvas.width - this.pannEnd.startX, y: this.lowerCanvas.height -
8897
+ this.pannEnd.startY };
6936
8898
  this.activeObj.activePoint = { startX: this.pannStart.startX, startY: this.pannStart.startY, endX: endPoint.x,
6937
8899
  endY: endPoint.y, width: endPoint.x - this.pannStart.startX, height: endPoint.y - this.pannStart.startY };
6938
8900
  this.updateActiveObject(this.calcRatio(), this.activeObj.activePoint, this.activeObj);
@@ -6944,10 +8906,6 @@ var ImageEditor = /** @class */ (function (_super) {
6944
8906
  this.refreshToolbar('main', true, true);
6945
8907
  }
6946
8908
  this.factor = 1;
6947
- if (!this.isUndoRedo) {
6948
- this.updateUndoRedoColl('rotate', degree, this.objColl, null);
6949
- }
6950
- this.isUndoRedo = false;
6951
8909
  this.refreshToolbar('main');
6952
8910
  }
6953
8911
  return isRotate;
@@ -6968,35 +8926,34 @@ var ImageEditor = /** @class */ (function (_super) {
6968
8926
  this.applyPenDraw();
6969
8927
  }
6970
8928
  this.applyActObj();
8929
+ this.lowerContext.filter = this.canvasFilter;
6971
8930
  if (this.factor !== 1) {
6972
8931
  this.lowerContext.setTransform(1, 0, 0, 1, 0, 0);
6973
8932
  this.upperContext.setTransform(1, 0, 0, 1, 0, 0);
6974
8933
  this.factor = 1;
6975
8934
  this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
6976
8935
  this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
6977
- this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
6978
- for (var i = 0; i < this.objColl.length; i++) {
6979
- this.apply(this.objColl[i].shape, this.objColl[i]);
6980
- this.refreshActiveObj();
6981
- }
8936
+ this.redrawImgWithObj();
6982
8937
  }
6983
8938
  type = type ? type : 'Png';
6984
8939
  this.redrawActObj();
6985
- var beforeSave = { cancel: false, fileName: fileName ? fileName : 'ImageEditor', fileType: type };
6986
- var saved_1 = { fileName: fileName ? fileName : 'ImageEditor', fileType: type };
8940
+ fileName = fileName ? fileName : this.imageFileName;
8941
+ var beforeSave = { cancel: false, fileName: fileName, fileType: type };
8942
+ var saved_1 = { fileName: fileName ? fileName : this.imageFileName, fileType: type };
6987
8943
  this.trigger('beforeSave', beforeSave, function (observableSaveArgs) {
6988
8944
  if (!observableSaveArgs.cancel) {
8945
+ _this.currObjType.isSave = true;
6989
8946
  fileName = observableSaveArgs.fileName ? observableSaveArgs.fileName : fileName;
6990
8947
  if (type.toLowerCase() === 'svg') {
6991
- fileName = fileName || 'ImageEditor';
8948
+ fileName = fileName || _this.imageFileName;
6992
8949
  _this.toSVGImg(fileName);
6993
8950
  }
6994
8951
  else if (type.toLowerCase() === 'jpeg') {
6995
- fileName = fileName || 'ImageEditor';
8952
+ fileName = fileName || _this.imageFileName;
6996
8953
  _this.toBlobFn(fileName, type.toLowerCase());
6997
8954
  }
6998
8955
  else {
6999
- fileName = fileName || 'ImageEditor';
8956
+ fileName = fileName || _this.imageFileName;
7000
8957
  _this.toBlobFn(fileName, type.toLowerCase());
7001
8958
  }
7002
8959
  _this.trigger('saved', saved_1);
@@ -7046,7 +9003,8 @@ var ImageEditor = /** @class */ (function (_super) {
7046
9003
  this.upperCanvas.style.cursor = 'crosshair';
7047
9004
  if (Browser.isDevice) {
7048
9005
  var arcRadius = (7.5 * (ratio.width > ratio.height ? ratio.width : ratio.height)) / this.factor;
7049
- var endPoint = { x: this.lowerCanvas.width - this.pannEnd.startX, y: this.lowerCanvas.height - this.pannEnd.startY };
9006
+ var endPoint = { x: this.lowerCanvas.width - this.pannEnd.startX, y: this.lowerCanvas.height -
9007
+ this.pannEnd.startY };
7050
9008
  this.activeObj.activePoint = { startX: this.pannStart.startX + arcRadius, startY: this.pannStart.startY + arcRadius,
7051
9009
  endX: endPoint.x - arcRadius, endY: endPoint.y - arcRadius };
7052
9010
  this.activeObj.activePoint.width = this.activeObj.activePoint.endX - this.activeObj.activePoint.startX;
@@ -7099,7 +9057,7 @@ var ImageEditor = /** @class */ (function (_super) {
7099
9057
  ImageEditor.prototype.freeHandDraw = function (value) {
7100
9058
  if (value) {
7101
9059
  this.togglePen = true;
7102
- this.upperCanvas.style.cursor = 'cross-hair';
9060
+ this.upperCanvas.style.cursor = 'crosshair';
7103
9061
  this.drawPen();
7104
9062
  }
7105
9063
  else {
@@ -7113,7 +9071,7 @@ var ImageEditor = /** @class */ (function (_super) {
7113
9071
  *
7114
9072
  * @param {boolean} value - Specifies a value whether enable or disable freehand drawing.
7115
9073
  *
7116
- * @returns {void}.
9074
+ * @returns {void}.
7117
9075
  */
7118
9076
  ImageEditor.prototype.freehandDraw = function (value) {
7119
9077
  this.freeHandDraw(value);
@@ -7164,17 +9122,8 @@ var ImageEditor = /** @class */ (function (_super) {
7164
9122
  this.redrawActObj();
7165
9123
  this.refreshActiveObj();
7166
9124
  this.upperContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
9125
+ this.lowerContext.filter = this.canvasFilter;
7167
9126
  this.upperCanvas.style.cursor = 'default';
7168
- var zoomState = void 0;
7169
- if (value === 3.75 || value === 1) {
7170
- zoomState = 0.1;
7171
- }
7172
- else if (value === -3.75) {
7173
- zoomState = -0.1;
7174
- }
7175
- else {
7176
- zoomState = value;
7177
- }
7178
9127
  if (this.degree !== 0) {
7179
9128
  this.inMemoryContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
7180
9129
  this.inMemoryContext.clearRect(0, 0, this.lowerCanvas.height, this.lowerCanvas.width);
@@ -7186,16 +9135,22 @@ var ImageEditor = /** @class */ (function (_super) {
7186
9135
  this.lastX = this.lowerCanvas.width / 2;
7187
9136
  this.lastY = this.lowerCanvas.height / 2;
7188
9137
  }
7189
- if (value > 0) {
7190
- this.zoomImg(3.75);
9138
+ if (value === 1.1 || value === -1.1) {
9139
+ this.zoomImg(value);
7191
9140
  }
7192
9141
  else {
7193
- this.zoomImg(-3.75);
9142
+ if (value > 0) {
9143
+ this.zoomImg(3.75);
9144
+ }
9145
+ else {
9146
+ this.zoomImg(-3.75);
9147
+ }
7194
9148
  }
7195
9149
  this.refreshActiveObj();
7196
9150
  if (!isNullOrUndefined(activeObjShape)) {
7197
9151
  if (activeObjShape === 'custom') {
7198
- var endPoint = { x: this.lowerCanvas.width - this.pannEnd.startX, y: this.lowerCanvas.height - this.pannEnd.startY };
9152
+ var endPoint = { x: this.lowerCanvas.width - this.pannEnd.startX, y: this.lowerCanvas.height -
9153
+ this.pannEnd.startY };
7199
9154
  this.activeObj.activePoint = { startX: this.pannStart.startX, startY: this.pannStart.startY, endX: endPoint.x,
7200
9155
  endY: endPoint.y, width: endPoint.x - this.pannStart.startX, height: endPoint.y - this.pannStart.startY };
7201
9156
  this.updateActiveObject(this.calcRatio(), this.activeObj.activePoint, this.activeObj);
@@ -7206,10 +9161,6 @@ var ImageEditor = /** @class */ (function (_super) {
7206
9161
  }
7207
9162
  this.refreshToolbar('main', true, true);
7208
9163
  }
7209
- if (!this.isUndoRedo) {
7210
- this.updateUndoRedoColl('zoom', zoomState, this.objColl);
7211
- }
7212
- this.isUndoRedo = false;
7213
9164
  var zoomOut = document.querySelector('#' + this.element.id + '_zoomOut');
7214
9165
  if (!isNullOrUndefined(zoomOut) && this.factor === 1) {
7215
9166
  zoomOut.classList.add('e-disabled');
@@ -7217,6 +9168,23 @@ var ImageEditor = /** @class */ (function (_super) {
7217
9168
  else if (!isNullOrUndefined(zoomOut)) {
7218
9169
  zoomOut.classList.remove('e-disabled');
7219
9170
  }
9171
+ if (!this.togglePan) {
9172
+ this.callMainToolbar(false, true);
9173
+ }
9174
+ this.autoEnablePan();
9175
+ if (isNullOrUndefined(this.activeObj.activePoint) || this.activeObj.activePoint.width === 0) {
9176
+ this.refreshToolbar('main');
9177
+ }
9178
+ else {
9179
+ this.refreshToolbar('main', true, true);
9180
+ }
9181
+ var panBtn = this.element.querySelector('.e-img-pan .e-btn');
9182
+ if (!isNullOrUndefined(panBtn) && this.togglePan) {
9183
+ panBtn.classList.add('e-selected-btn');
9184
+ }
9185
+ else if (!isNullOrUndefined(panBtn)) {
9186
+ panBtn.classList.remove('e-selected-btn');
9187
+ }
7220
9188
  }
7221
9189
  };
7222
9190
  /**
@@ -7397,6 +9365,7 @@ var ImageEditor = /** @class */ (function (_super) {
7397
9365
  else {
7398
9366
  isSelected = true;
7399
9367
  this.activeObj = obj;
9368
+ this.lowerContext.filter = this.canvasFilter;
7400
9369
  this.redrawShape(this.activeObj);
7401
9370
  if (this.activeObj.shape === 'text') {
7402
9371
  this.refreshToolbar('text');
@@ -7438,12 +9407,9 @@ var ImageEditor = /** @class */ (function (_super) {
7438
9407
  break;
7439
9408
  }
7440
9409
  }
9410
+ this.lowerContext.filter = this.canvasFilter;
7441
9411
  this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
7442
- this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
7443
- for (var i = 0; i < this.objColl.length; i++) {
7444
- this.apply(this.objColl[i].shape, this.objColl[i]);
7445
- this.refreshActiveObj();
7446
- }
9412
+ this.redrawImgWithObj();
7447
9413
  this.refreshToolbar('main');
7448
9414
  };
7449
9415
  /**
@@ -7508,9 +9474,61 @@ var ImageEditor = /** @class */ (function (_super) {
7508
9474
  canvasWrapper.style.height = this.element.offsetHeight - this.toolbarHeight - 1 + 'px';
7509
9475
  this.lowerCanvas.height = this.upperCanvas.height = this.element.offsetHeight - this.toolbarHeight - 1;
7510
9476
  }
9477
+ this.lowerContext.filter = this.canvasFilter;
7511
9478
  this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
7512
9479
  this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
7513
9480
  };
9481
+ /**
9482
+ * To apply the filters to an image
9483
+ *
9484
+ * @param {ImageFilterOptions } filterOption - Specifies the filter options to the image.
9485
+ * @returns {void}.
9486
+ */
9487
+ ImageEditor.prototype.applyImageFilter = function (filterOption) {
9488
+ if (this.initialAdjustmentValue === '') {
9489
+ this.initialAdjustmentValue = 'brightness(1) contrast(100%) hue-rotate(0deg) saturate(100%) opacity(1) blur(0px) sepia(0%) grayscale(0%) invert(0%)';
9490
+ }
9491
+ this.lowerContext.filter = this.initialAdjustmentValue;
9492
+ var filterValue = filterOption.split(' ');
9493
+ this.setFilter(filterValue.join('').toLowerCase());
9494
+ };
9495
+ /**
9496
+ * To apply the filters to an image
9497
+ *
9498
+ * @param {ImageFinetuneOptions } finetuneOption - Specifies the finetune options to the image.
9499
+ * @param {number } value - Specifies the value for finetuning the image.
9500
+ * @returns {void}.
9501
+ *
9502
+ */
9503
+ ImageEditor.prototype.finetuneImage = function (finetuneOption, value) {
9504
+ if (this.initialAdjustmentValue === '') {
9505
+ this.initialAdjustmentValue = 'brightness(1) contrast(100%) hue-rotate(0deg) saturate(100%) opacity(1) blur(0px) sepia(0%) grayscale(0%) invert(0%)';
9506
+ }
9507
+ this.lowerContext.filter = this.initialAdjustmentValue;
9508
+ switch (finetuneOption) {
9509
+ case 'Brightness':
9510
+ this.setBrightness(value);
9511
+ break;
9512
+ case 'Contrast':
9513
+ this.setContrast(value);
9514
+ break;
9515
+ case 'Hue':
9516
+ this.setHue(value);
9517
+ break;
9518
+ case 'Saturation':
9519
+ this.setSaturation(value);
9520
+ break;
9521
+ case 'Opacity':
9522
+ this.setOpacity(value);
9523
+ break;
9524
+ case 'Blur':
9525
+ this.setBlur(value);
9526
+ break;
9527
+ case 'Exposure':
9528
+ this.setExposure(value);
9529
+ break;
9530
+ }
9531
+ };
7514
9532
  /**
7515
9533
  * To check whether the undo collection is empty or not.
7516
9534
  *
@@ -7563,7 +9581,8 @@ var ImageEditor = /** @class */ (function (_super) {
7563
9581
  * @private
7564
9582
  */
7565
9583
  ImageEditor.prototype.getBlob = function (url) {
7566
- return null;
9584
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
9585
+ return url;
7567
9586
  };
7568
9587
  /**
7569
9588
  * To check whether the signature is empty or not.
@@ -7613,7 +9632,7 @@ var ImageEditor = /** @class */ (function (_super) {
7613
9632
  /**
7614
9633
  * To save the signature with the given file type and file name.
7615
9634
  *
7616
- * @param {SignatureFileType} type - specify type of the file to be saved a signature.
9635
+ * @param {FileType} type - specify type of the file to be saved a signature.
7617
9636
  * @param {string} fileName - specify name of the file to be saved a signature.
7618
9637
  *
7619
9638
  * @returns {void}.
@@ -7636,9 +9655,10 @@ var ImageEditor = /** @class */ (function (_super) {
7636
9655
  /**
7637
9656
  * Returns the persistence data for component.
7638
9657
  *
7639
- * @returns any.
9658
+ * @returns {any}.
7640
9659
  * @private
7641
9660
  */
9661
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
7642
9662
  ImageEditor.prototype.getLocalData = function () {
7643
9663
  return null;
7644
9664
  };
@@ -7694,6 +9714,12 @@ var ImageEditor = /** @class */ (function (_super) {
7694
9714
  __decorate([
7695
9715
  Property(false)
7696
9716
  ], ImageEditor.prototype, "enablePersistence", void 0);
9717
+ __decorate([
9718
+ Complex({}, FinetuneSettings)
9719
+ ], ImageEditor.prototype, "finetuneSettings", void 0);
9720
+ __decorate([
9721
+ Property('')
9722
+ ], ImageEditor.prototype, "signatureValue", void 0);
7697
9723
  __decorate([
7698
9724
  Event()
7699
9725
  ], ImageEditor.prototype, "beforeSave", void 0);
@@ -7736,6 +9762,12 @@ var ImageEditor = /** @class */ (function (_super) {
7736
9762
  __decorate([
7737
9763
  Event()
7738
9764
  ], ImageEditor.prototype, "toolbarItemClicked", void 0);
9765
+ __decorate([
9766
+ Event()
9767
+ ], ImageEditor.prototype, "imageFiltering", void 0);
9768
+ __decorate([
9769
+ Event()
9770
+ ], ImageEditor.prototype, "fineTuneValueChanging", void 0);
7739
9771
  ImageEditor = ImageEditor_1 = __decorate([
7740
9772
  NotifyPropertyChanges
7741
9773
  ], ImageEditor);