@syncfusion/ej2-image-editor 20.3.56 → 20.4.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/.eslintrc.json +16 -1
  2. package/CHANGELOG.md +2 -10
  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 +6129 -4137
  7. package/dist/es6/ej2-image-editor.es2015.js.map +1 -1
  8. package/dist/es6/ej2-image-editor.es5.js +2468 -468
  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 +21 -23
  14. package/src/image-editor/image-editor-model.d.ts +102 -19
  15. package/src/image-editor/image-editor.d.ts +221 -31
  16. package/src/image-editor/image-editor.js +2468 -467
  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
@@ -1,5 +1,5 @@
1
- import { Browser, Event, EventHandler, L10n, NotifyPropertyChanges, Property, addClass, compile, detach, extend, getComponent, getInstance, getUniqueID, isNullOrUndefined, removeClass, select } from '@syncfusion/ej2-base';
2
- import { ColorPicker, SignatureBase, Uploader } from '@syncfusion/ej2-inputs';
1
+ import { Browser, ChildProperty, Complex, Event, EventHandler, L10n, NotifyPropertyChanges, Property, addClass, compile, detach, extend, getComponent, getInstance, getUniqueID, isNullOrUndefined, removeClass, select } from '@syncfusion/ej2-base';
2
+ import { ColorPicker, SignatureBase, Slider, Uploader } from '@syncfusion/ej2-inputs';
3
3
  import { Toolbar } from '@syncfusion/ej2-navigations';
4
4
  import { DropDownButton } from '@syncfusion/ej2-splitbuttons';
5
5
  import { createSpinner, hideSpinner, showSpinner } from '@syncfusion/ej2-popups';
@@ -23,6 +23,37 @@ var __decorate = (undefined && undefined.__decorate) || function (decorators, ta
23
23
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
24
24
  return c > 3 && r && Object.defineProperty(target, key, r), r;
25
25
  };
26
+ /**
27
+ * Interface for image finetune values.
28
+ */
29
+ var FinetuneSettings = /** @__PURE__ @class */ (function (_super) {
30
+ __extends(FinetuneSettings, _super);
31
+ function FinetuneSettings() {
32
+ return _super !== null && _super.apply(this, arguments) || this;
33
+ }
34
+ __decorate([
35
+ Property(null)
36
+ ], FinetuneSettings.prototype, "brightness", void 0);
37
+ __decorate([
38
+ Property(null)
39
+ ], FinetuneSettings.prototype, "contrast", void 0);
40
+ __decorate([
41
+ Property(null)
42
+ ], FinetuneSettings.prototype, "hue", void 0);
43
+ __decorate([
44
+ Property(null)
45
+ ], FinetuneSettings.prototype, "saturation", void 0);
46
+ __decorate([
47
+ Property(null)
48
+ ], FinetuneSettings.prototype, "exposure", void 0);
49
+ __decorate([
50
+ Property(null)
51
+ ], FinetuneSettings.prototype, "opacity", void 0);
52
+ __decorate([
53
+ Property(null)
54
+ ], FinetuneSettings.prototype, "blur", void 0);
55
+ return FinetuneSettings;
56
+ }(ChildProperty));
26
57
  /**
27
58
  * Image Editor is a graphical user interface that helps to edit an image by performing actions like selection,
28
59
  * cropping, rotating, inserting text and shapes (rectangles, ellipses, lines), and drawing free hand on top of an image.
@@ -49,7 +80,6 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
49
80
  function ImageEditor(options, element) {
50
81
  var _this = _super.call(this, options, element) || this;
51
82
  _this.degree = 0; // current rotated state
52
- _this.isUndoRedo = false;
53
83
  _this.dragCanvas = false;
54
84
  _this.dragElement = '';
55
85
  _this.keyHistory = ''; // text history
@@ -70,24 +100,18 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
70
100
  _this.pannStart = {};
71
101
  _this.pannEnd = {};
72
102
  _this.togglePan = false;
103
+ _this.disablePan = false;
73
104
  _this.lastX = 0;
74
105
  _this.lastY = 0;
75
106
  _this.dragStart = { x: 0, y: 0 };
76
- _this.dragged = false;
77
107
  _this.factor = 1; // current zoomed state
78
108
  _this.currFlipState = '';
79
109
  _this.touchEndPoint = {};
80
- _this.flipMethod = false;
81
- _this.flipDirection = '';
82
110
  _this.prevX = 0;
83
111
  _this.currX = 0;
84
112
  _this.prevY = 0;
85
113
  _this.currY = 0;
86
114
  _this.togglePen = false;
87
- _this.rotateMethod = false;
88
- _this.isBoldbtn = false;
89
- _this.isItalicbtn = false;
90
- _this.lastAction = '';
91
115
  _this.currentToolbar = 'main';
92
116
  _this.textStartPoints = { x: 0, y: 0 };
93
117
  _this.fontSizeColl = [];
@@ -98,11 +122,29 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
98
122
  _this.activeObj = { activePoint: { startX: 0, startY: 0, endX: 0, endY: 0, width: 0, height: 0 },
99
123
  flipObjColl: [] };
100
124
  _this.currObjType = { shape: '', isDragging: false, isActiveObj: false, isText: false, isInitialText: false, isLine: false,
101
- isInitialLine: false, isCustomCrop: false, isZoomed: false };
125
+ isInitialLine: false, isCustomCrop: false, isZoomed: false, isFiltered: false, isSave: false };
102
126
  _this.defToolbarItems = [];
103
- _this.baseImgSrc = '';
127
+ _this.baseImgSrc = {};
104
128
  _this.isTimer = false;
105
129
  _this.isScreenOriented = false;
130
+ _this.isFirstMove = false;
131
+ _this.startTouches = [];
132
+ _this.tempTouches = [];
133
+ _this.adjustmentLevel = { brightness: 0, contrast: 0, hue: 0, opacity: 100, saturation: 0, blur: 0,
134
+ exposure: 0, sharpen: false, bw: false };
135
+ _this.tempAdjustmentLevel = { brightness: 0, contrast: 0, hue: 0, opacity: 100, saturation: 0, blur: 0,
136
+ exposure: 0, sharpen: false, bw: false };
137
+ _this.adjustmentValue = '';
138
+ _this.initialAdjustmentValue = '';
139
+ _this.tempAdjustmentValue = '';
140
+ _this.currentFilter = '';
141
+ _this.tempFilter = '';
142
+ _this.canvasFilter = '';
143
+ _this.sharpenedImgData = false;
144
+ _this.tempSharpenFilter = false;
145
+ _this.tempBWFilter = false;
146
+ _this.isBrightnessAdjusted = false;
147
+ _this.isInitialLoading = false;
106
148
  return _this;
107
149
  }
108
150
  ImageEditor_1 = ImageEditor;
@@ -132,8 +174,28 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
132
174
  Crop: 'Crop',
133
175
  ZoomIn: 'Zoom In',
134
176
  ZoomOut: 'Zoom Out',
177
+ Undo: 'Undo',
178
+ Redo: 'Redo',
135
179
  Transform: 'Transform',
136
180
  Annotation: 'Annotation',
181
+ Finetune: 'Finetune',
182
+ Brightness: 'Brightness',
183
+ Contrast: 'Contrast',
184
+ Hue: 'Hue',
185
+ Saturation: 'Saturation',
186
+ Opacity: 'Opacity',
187
+ Blur: 'Blur',
188
+ Sharpen: 'Sharpen',
189
+ Exposure: 'Exposure',
190
+ Filter: 'Filter',
191
+ Default: 'Default',
192
+ Chrome: 'Chrome',
193
+ Cold: 'Cold',
194
+ Warm: 'Warm',
195
+ Grayscale: 'Grayscale',
196
+ BlackAndWhite: 'Black and White',
197
+ Sepia: 'Sepia',
198
+ Invert: 'Invert',
137
199
  Text: 'Add Text',
138
200
  Pen: 'Pen',
139
201
  Reset: 'Reset',
@@ -161,7 +223,6 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
161
223
  Ellipse: 'Ellipse',
162
224
  Rectangle: 'Rectangle',
163
225
  Line: 'Line',
164
- Default: 'Default',
165
226
  Bold: 'Bold',
166
227
  Italic: 'Italic',
167
228
  BoldItalic: 'Bold Italic',
@@ -170,7 +231,8 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
170
231
  Medium: 'Medium',
171
232
  Large: 'Large',
172
233
  XLarge: 'X-Large',
173
- ABC: 'ABC'
234
+ ABC: 'ABC',
235
+ Browse: 'Browse'
174
236
  };
175
237
  this.l10n = new L10n('image-editor', this.defaultLocale, this.locale);
176
238
  };
@@ -247,6 +309,12 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
247
309
  this.upperContext.fillStyle = this.themeColl[this.theme]['secondaryColor'];
248
310
  }
249
311
  break;
312
+ case 'finetuneSettings':
313
+ if (newProperties.finetuneSettings) {
314
+ this.finetuneSettings = newProperties.finetuneSettings;
315
+ this.updateFinetunes();
316
+ }
317
+ break;
250
318
  }
251
319
  }
252
320
  };
@@ -267,13 +335,17 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
267
335
  this.trigger('destroyed');
268
336
  };
269
337
  ImageEditor.prototype.initialize = function () {
338
+ this.updateFinetunes();
270
339
  this.createToolbar();
340
+ this.createContextualToolbar();
271
341
  this.createCanvas();
272
342
  this.wireEvent();
273
343
  this.updateContext(this.lowerContext);
274
344
  this.updateContext(this.upperContext);
275
345
  this.pannStart = { startX: 0, startY: 0, width: 0, height: 0 };
276
346
  this.pannEnd = { startX: 0, startY: 0, width: 0, height: 0 };
347
+ this.lowerContext.filter = this.canvasFilter = this.initialAdjustmentValue = this.adjustmentValue = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
348
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
277
349
  if (this.cssClass) {
278
350
  addClass([this.element], this.cssClass.split(' '));
279
351
  }
@@ -283,6 +355,39 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
283
355
  });
284
356
  }
285
357
  };
358
+ ImageEditor.prototype.updateFinetunes = function () {
359
+ if (this.finetuneSettings) {
360
+ if (this.finetuneSettings.brightness) {
361
+ this.adjustmentLevel.brightness = this.finetuneSettings.brightness.defaultValue;
362
+ this.tempAdjustmentLevel.brightness = this.finetuneSettings.brightness.defaultValue;
363
+ }
364
+ if (this.finetuneSettings.contrast) {
365
+ this.adjustmentLevel.contrast = this.finetuneSettings.contrast.defaultValue;
366
+ this.tempAdjustmentLevel.contrast = this.finetuneSettings.contrast.defaultValue;
367
+ }
368
+ if (this.finetuneSettings.hue) {
369
+ this.adjustmentLevel.hue = this.finetuneSettings.hue.defaultValue;
370
+ this.tempAdjustmentLevel.hue = this.finetuneSettings.hue.defaultValue;
371
+ }
372
+ if (this.finetuneSettings.saturation) {
373
+ this.adjustmentLevel.saturation = this.finetuneSettings.saturation.defaultValue;
374
+ this.tempAdjustmentLevel.saturation = this.finetuneSettings.saturation.defaultValue;
375
+ }
376
+ if (this.finetuneSettings.exposure) {
377
+ this.adjustmentLevel.exposure = this.finetuneSettings.exposure.defaultValue;
378
+ this.tempAdjustmentLevel.exposure = this.finetuneSettings.exposure.defaultValue;
379
+ }
380
+ if (this.finetuneSettings.opacity) {
381
+ this.adjustmentLevel.opacity = this.finetuneSettings.opacity.defaultValue;
382
+ this.tempAdjustmentLevel.opacity = this.finetuneSettings.opacity.defaultValue;
383
+ }
384
+ if (this.finetuneSettings.blur) {
385
+ this.adjustmentLevel.blur = this.finetuneSettings.blur.defaultValue;
386
+ this.tempAdjustmentLevel.blur = this.finetuneSettings.blur.defaultValue;
387
+ }
388
+ this.isInitialLoading = true;
389
+ }
390
+ };
286
391
  /**
287
392
  *
288
393
  * This Method will add events to component (element, event, method, current reference)
@@ -305,7 +410,7 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
305
410
  EventHandler.add(this.upperCanvas, 'dblclick', this.findTextPoint, this);
306
411
  EventHandler.add(this.textBox, 'mousedown', this.findTextPoint, this);
307
412
  window.addEventListener('resize', this.windowResizeHandler.bind(this));
308
- if ((!Browser.isIos && Browser.info.name !== 'safari')) {
413
+ if (!Browser.isIos && Browser.info.name !== 'safari' && screen && screen.orientation) {
309
414
  screen.orientation.addEventListener('change', this.screenOrientation.bind(this));
310
415
  }
311
416
  };
@@ -327,9 +432,17 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
327
432
  EventHandler.remove(this.lowerCanvas, 'mouseup', this.canvasMouseUpHandler);
328
433
  EventHandler.remove(document, 'mouseup', this.canvasMouseUpHandler);
329
434
  };
435
+ ImageEditor.prototype.initializeFilter = function () {
436
+ this.setBrightness(this.adjustmentLevel.brightness);
437
+ this.setContrast(this.adjustmentLevel.contrast);
438
+ this.setHue(this.adjustmentLevel.hue);
439
+ this.setSaturation(this.adjustmentLevel.saturation);
440
+ this.setExposure(this.adjustmentLevel.exposure);
441
+ this.setOpacity(this.adjustmentLevel.opacity);
442
+ this.setBlur(this.adjustmentLevel.blur);
443
+ };
330
444
  ImageEditor.prototype.destroySubComponents = function () {
331
445
  var inputElement = this.element.querySelectorAll('input.e-control');
332
- var divElement = this.element.querySelectorAll('div.e-control:not(.e-handle)');
333
446
  var btnElement = this.element.querySelectorAll('button.e-control');
334
447
  for (var i = 0, len = inputElement.length; i < len; i++) {
335
448
  if (inputElement[i].classList.contains('e-color-picker')) {
@@ -460,6 +573,58 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
460
573
  this.toolbarHeight = 0;
461
574
  }
462
575
  };
576
+ ImageEditor.prototype.createContextualToolbar = function () {
577
+ if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.length > 0)) {
578
+ this.element.appendChild(this.createElement('div', { id: this.element.id + '_contextualToolbarArea',
579
+ className: 'e-contextual-toolbar-wrapper e-hide', attrs: { style: 'position: absolute;' }
580
+ }));
581
+ var toolbarArea = document.getElementById(this.element.id + '_contextualToolbarArea');
582
+ var toolbar_2 = this.createElement('div', { id: this.element.id + '_contextualToolbar' });
583
+ toolbarArea.appendChild(toolbar_2);
584
+ }
585
+ };
586
+ ImageEditor.prototype.updateContextualToolbar = function (type, cType) {
587
+ if (this.toolbarTemplate) {
588
+ this.toolbarTemplateFn();
589
+ }
590
+ else {
591
+ var toolbarArea = this.element.querySelector('#' + this.element.id + '_toolbarArea');
592
+ var contextualToolbarArea = this.element.querySelector('#' + this.element.id + '_contextualToolbarArea');
593
+ if (!isNullOrUndefined(toolbarArea) && !isNullOrUndefined(contextualToolbarArea)) {
594
+ contextualToolbarArea.classList.remove('e-hide');
595
+ contextualToolbarArea.style.left = toolbarArea.offsetLeft + 'px';
596
+ }
597
+ if (type === 'filter') {
598
+ if (!isNullOrUndefined(document.getElementById(this.element.id + '_toolbar')) && this.defToolbarItems.length > 0) {
599
+ getComponent(document.getElementById(this.element.id + '_toolbar'), 'toolbar').destroy();
600
+ }
601
+ if (Browser.isDevice) {
602
+ this.initToolbarItem(false, true, true);
603
+ }
604
+ else {
605
+ this.initToolbarItem(true);
606
+ }
607
+ this.refreshSlider();
608
+ this.initFilterToolbarItem();
609
+ }
610
+ else {
611
+ if (!isNullOrUndefined(document.querySelector('#' + this.element.id + '_contextualToolbar'))
612
+ && document.querySelector('#' + this.element.id + '_contextualToolbar').classList.contains('e-control')) {
613
+ getComponent(document.getElementById(this.element.id + '_contextualToolbar'), 'toolbar').destroy();
614
+ }
615
+ this.refreshSlider();
616
+ this.renderSlider(cType);
617
+ }
618
+ if (Browser.isDevice) {
619
+ var cHt = contextualToolbarArea.offsetHeight;
620
+ var ht = this.element.querySelector('#' + this.element.id + '_canvasWrapper').offsetHeight;
621
+ contextualToolbarArea.style.top = this.toolbarHeight + ht - cHt + 'px';
622
+ }
623
+ else {
624
+ contextualToolbarArea.style.top = this.toolbarHeight + 1 + 'px';
625
+ }
626
+ }
627
+ };
463
628
  ImageEditor.prototype.createBottomToolbar = function () {
464
629
  if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.length > 0)) {
465
630
  this.element.appendChild(this.createElement('div', {
@@ -496,8 +661,8 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
496
661
  }, '#' + this.element.id + '_bottomToolbar');
497
662
  if (this.defToolbarItems.length > 0 && (!isNullOrUndefined(document.getElementById(this.element.id + '_bottomToolbar')))) {
498
663
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
499
- var toolbar_2 = getComponent(this.element.id + '_bottomToolbar', 'toolbar');
500
- toolbar_2.refreshOverflow();
664
+ var toolbar_3 = getComponent(this.element.id + '_bottomToolbar', 'toolbar');
665
+ toolbar_3.refreshOverflow();
501
666
  }
502
667
  }
503
668
  }
@@ -600,6 +765,14 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
600
765
  template: '<button id="' + this.element.id + '_transformBtn"></button>'
601
766
  });
602
767
  }
768
+ if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Finetune') > -1)) {
769
+ toolbarItems.push({ id: this.element.id + '_adjustment', prefixIcon: 'e-icons e-adjustment', cssClass: 'top-icon e-adjustment',
770
+ tooltipText: this.l10n.getConstant('Finetune'), align: 'Center' });
771
+ }
772
+ if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Filter') > -1)) {
773
+ toolbarItems.push({ id: this.element.id + '_filter', prefixIcon: 'e-icons e-filters', cssClass: 'top-icon e-filters',
774
+ tooltipText: this.l10n.getConstant('Filter'), align: 'Center' });
775
+ }
603
776
  var tempToolbarItems = this.processToolbar('center');
604
777
  for (var i = 0, len = tempToolbarItems.length; i < len; i++) {
605
778
  toolbarItems.push(tempToolbarItems[i]);
@@ -707,8 +880,8 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
707
880
  }
708
881
  if (this.isToolbar() && (!isNullOrUndefined(document.getElementById(this.element.id + '_toolbar')))) {
709
882
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
710
- var toolbar_3 = getComponent(this.element.id + '_toolbar', 'toolbar');
711
- toolbar_3.refreshOverflow();
883
+ var toolbar_4 = getComponent(this.element.id + '_toolbar', 'toolbar');
884
+ toolbar_4.refreshOverflow();
712
885
  }
713
886
  }
714
887
  };
@@ -805,7 +978,7 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
805
978
  items.push({ text: this.l10n.getConstant('Custom'), id: 'custom', iconCss: 'e-icons e-custom' });
806
979
  }
807
980
  if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('CircleSelection') > -1)) {
808
- items.push({ text: this.l10n.getConstant('Circle'), id: 'ellipse', iconCss: 'e-icons e-circle' });
981
+ items.push({ text: this.l10n.getConstant('Circle'), id: 'circle', iconCss: 'e-icons e-circle' });
809
982
  }
810
983
  if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('SquareSelection') > -1)) {
811
984
  items.push({ text: this.l10n.getConstant('Square'), id: 'square', iconCss: 'e-icons e-square' });
@@ -888,7 +1061,7 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
888
1061
  }
889
1062
  };
890
1063
  ImageEditor.prototype.cropSelect = function (args) {
891
- var text = args.item.text;
1064
+ var text = args.item.id;
892
1065
  this.select(text);
893
1066
  this.refreshToolbar('main', true, true);
894
1067
  };
@@ -994,9 +1167,16 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
994
1167
  modeSwitcher: false, noColor: true, value: '',
995
1168
  showButtons: false, mode: 'Palette', cssClass: 'e-shape-fill-color',
996
1169
  change: function (args) {
1170
+ _this.pushActItemIntoObj();
1171
+ var objColl = extend([], _this.objColl, [], true);
1172
+ _this.objColl.pop();
997
1173
  proxy.activeObj.strokeSettings.fillColor = args.currentValue.hex;
998
1174
  proxy.strokeSettings.fillColor = proxy.activeObj.strokeSettings.fillColor;
999
- proxy.redrawShape(_this.activeObj);
1175
+ _this.objColl.push(_this.activeObj);
1176
+ proxy.undoRedoColl.push({ operation: 'shapeTransform', value: null,
1177
+ currentObj: extend([], proxy.objColl, [], true), previousObj: objColl, factor: proxy.factor,
1178
+ sharpen: proxy.adjustmentLevel.sharpen, bw: proxy.adjustmentLevel.bw });
1179
+ proxy.redrawShape(proxy.objColl[proxy.objColl.length - 1]);
1000
1180
  if (args.currentValue.rgba === '') {
1001
1181
  fillDDB_1.element.children[0].classList.add('e-nocolor-item');
1002
1182
  }
@@ -1029,10 +1209,17 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
1029
1209
  modeSwitcher: false, noColor: false, value: '#fff',
1030
1210
  showButtons: false, mode: 'Palette', cssClass: 'e-shape-stroke-color',
1031
1211
  change: function (args) {
1212
+ _this.pushActItemIntoObj();
1213
+ var objColl = extend([], _this.objColl, [], true);
1214
+ _this.objColl.pop();
1032
1215
  proxy.activeObj.strokeSettings.strokeColor = args.currentValue.hex;
1033
1216
  proxy.strokeSettings.strokeColor = proxy.activeObj.strokeSettings.strokeColor;
1034
1217
  if (!proxy.togglePen) {
1035
- proxy.redrawShape(_this.activeObj);
1218
+ _this.objColl.push(_this.activeObj);
1219
+ proxy.undoRedoColl.push({ operation: 'shapeTransform', value: null,
1220
+ currentObj: extend([], proxy.objColl, [], true), previousObj: objColl, factor: proxy.factor,
1221
+ sharpen: proxy.adjustmentLevel.sharpen, bw: proxy.adjustmentLevel.bw });
1222
+ proxy.redrawShape(proxy.objColl[proxy.objColl.length - 1]);
1036
1223
  }
1037
1224
  strokeDDB_1.element.children[0].style.backgroundColor = args.currentValue.rgba;
1038
1225
  strokeDDB_1.toggle();
@@ -1082,6 +1269,9 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
1082
1269
  }
1083
1270
  },
1084
1271
  select: function (args) {
1272
+ _this.pushActItemIntoObj();
1273
+ var objColl = extend([], _this.objColl, [], true);
1274
+ _this.objColl.pop();
1085
1275
  spanElem_1.textContent = args.item.text;
1086
1276
  _this.activeObj.strokeSettings.strokeWidth = parseInt(args.item.id, 10);
1087
1277
  if (_this.lowerCanvas.width > _this.lowerCanvas.height) {
@@ -1091,19 +1281,23 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
1091
1281
  _this.activeObj.strokeSettings.strokeWidth *= ((ratio.height + ratio.width) / _this.factor);
1092
1282
  }
1093
1283
  _this.strokeSettings.strokeWidth = _this.activeObj.strokeSettings.strokeWidth;
1094
- _this.redrawShape(_this.activeObj);
1284
+ _this.objColl.push(_this.activeObj);
1285
+ _this.undoRedoColl.push({ operation: 'shapeTransform', value: null,
1286
+ currentObj: extend([], _this.objColl, [], true), previousObj: objColl, factor: _this.factor,
1287
+ sharpen: _this.adjustmentLevel.sharpen, bw: _this.adjustmentLevel.bw });
1288
+ _this.redrawShape(_this.objColl[_this.objColl.length - 1]);
1095
1289
  if (Browser.isDevice) {
1096
1290
  if (!isNullOrUndefined(document.getElementById(_this.element.id + '_bottomToolbar'))) {
1097
1291
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
1098
- var toolbar_4 = getComponent(_this.element.id + '_bottomToolbar', 'toolbar');
1099
- toolbar_4.refreshOverflow();
1292
+ var toolbar_5 = getComponent(_this.element.id + '_bottomToolbar', 'toolbar');
1293
+ toolbar_5.refreshOverflow();
1100
1294
  }
1101
1295
  }
1102
1296
  else {
1103
1297
  if (!isNullOrUndefined(document.getElementById(_this.element.id + '_toolbar'))) {
1104
1298
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
1105
- var toolbar_5 = getComponent(_this.element.id + '_toolbar', 'toolbar');
1106
- toolbar_5.refreshOverflow();
1299
+ var toolbar_6 = getComponent(_this.element.id + '_toolbar', 'toolbar');
1300
+ toolbar_6.refreshOverflow();
1107
1301
  }
1108
1302
  }
1109
1303
  }
@@ -1219,17 +1413,26 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
1219
1413
  modeSwitcher: false, value: '#fff',
1220
1414
  showButtons: false, mode: 'Palette', cssClass: 'e-text-fontt-color',
1221
1415
  change: function (args) {
1416
+ _this.pushActItemIntoObj();
1417
+ _this.objColl.pop();
1222
1418
  if (proxy.textBox.style.display === 'none') {
1223
1419
  proxy.strokeSettings.strokeColor = proxy.activeObj.strokeSettings.strokeColor = args.currentValue.hex;
1224
1420
  if (!proxy.togglePen) {
1225
- proxy.redrawShape(_this.activeObj);
1421
+ _this.objColl.push(_this.activeObj);
1422
+ proxy.redrawShape(proxy.objColl[proxy.objColl.length - 1]);
1226
1423
  }
1227
1424
  }
1228
1425
  else if (proxy.textBox.style.display === 'block') {
1229
1426
  proxy.textBox.style.color = args.currentValue.hex;
1427
+ var temp = proxy.activeObj.strokeSettings.strokeColor;
1428
+ proxy.activeObj.strokeSettings.strokeColor = args.currentValue.hex;
1429
+ _this.objColl.push(_this.activeObj);
1430
+ _this.objColl.pop();
1431
+ proxy.activeObj.strokeSettings.strokeColor = temp;
1230
1432
  }
1231
1433
  else if (!proxy.togglePen) {
1232
- proxy.redrawShape(_this.activeObj);
1434
+ _this.objColl.push(_this.activeObj);
1435
+ proxy.redrawShape(proxy.objColl[proxy.objColl.length - 1]);
1233
1436
  }
1234
1437
  strokeDDB_2.element.children[0].style.backgroundColor = args.currentValue.rgba;
1235
1438
  strokeDDB_2.toggle();
@@ -1251,6 +1454,17 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
1251
1454
  = '#fff';
1252
1455
  }
1253
1456
  };
1457
+ ImageEditor.prototype.pushActItemIntoObj = function () {
1458
+ if (this.textBox.style.display === 'none') {
1459
+ this.objColl.push(this.activeObj);
1460
+ }
1461
+ else {
1462
+ var temp = extend({}, this.activeObj, {}, true);
1463
+ this.setTextBoxStylesToActObj();
1464
+ this.objColl.push(this.activeObj);
1465
+ this.activeObj = temp;
1466
+ }
1467
+ };
1254
1468
  ImageEditor.prototype.createTextBtn = function (items) {
1255
1469
  var _this = this;
1256
1470
  var ratio = this.calcRatio();
@@ -1288,6 +1502,8 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
1288
1502
  + '"' + ']').classList.add('e-selected-btn');
1289
1503
  },
1290
1504
  select: function (args) {
1505
+ _this.pushActItemIntoObj();
1506
+ _this.objColl.pop();
1291
1507
  spanElem_2.textContent = args.item.text;
1292
1508
  if (Browser.isDevice) {
1293
1509
  spanElem_2.setAttribute('style', 'font-family:' + args.item.id);
@@ -1295,10 +1511,13 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
1295
1511
  if (_this.textBox.style.display === 'block') {
1296
1512
  var temp = _this.activeObj.textSettings.fontFamily;
1297
1513
  _this.activeObj.textSettings.fontFamily = _this.toPascalCase(args.item.id);
1298
- _this.updateFontStyles();
1299
- var width = _this.upperContext.measureText(_this.activeObj.keyHistory).width +
1300
- _this.activeObj.textSettings.fontSize * 0.5;
1301
- _this.textBox.style.width = Browser.isDevice ? width + 'px' : (width * ((ratio.width + ratio.height) / 2)) + 'px';
1514
+ _this.redrawText(ratio);
1515
+ _this.objColl.push(_this.activeObj);
1516
+ _this.objColl.pop();
1517
+ _this.upperContext.clearRect(0, 0, _this.upperCanvas.width, _this.upperCanvas.height);
1518
+ var width = _this.activeObj.activePoint.width +
1519
+ _this.activeObj.textSettings.fontSize * 0.25;
1520
+ _this.textBox.style.width = width / ratio.width + 'px';
1302
1521
  _this.textBox.style.fontFamily = _this.toPascalCase(args.item.id);
1303
1522
  _this.activeObj.textSettings.fontFamily = temp;
1304
1523
  _this.updateFontStyles();
@@ -1306,7 +1525,8 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
1306
1525
  else {
1307
1526
  _this.textSettings.fontFamily = _this.activeObj.textSettings.fontFamily = _this.toPascalCase(args.item.id);
1308
1527
  _this.redrawText(ratio);
1309
- _this.redrawShape(_this.activeObj);
1528
+ _this.objColl.push(_this.activeObj);
1529
+ _this.redrawShape(_this.objColl[_this.objColl.length - 1]);
1310
1530
  }
1311
1531
  }
1312
1532
  });
@@ -1405,10 +1625,14 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
1405
1625
  args.element.querySelector('[aria-label *= ' + '"' + activeBtn + '"' + ']').classList.add('e-selected-btn');
1406
1626
  },
1407
1627
  select: function (args) {
1628
+ _this.pushActItemIntoObj();
1629
+ _this.objColl.pop();
1408
1630
  fontSizeSpanElem_1.textContent = args.item.text;
1409
1631
  if (_this.textBox.style.display === 'block') {
1410
1632
  var temp = _this.activeObj.textSettings.fontSize;
1411
1633
  _this.activeObj.textSettings.fontSize = parseInt(_this.fontSizeColl[(parseInt(args.item.text, 10) - 1)].text, 10);
1634
+ _this.objColl.push(_this.activeObj);
1635
+ _this.objColl.pop();
1412
1636
  var textStyle = '';
1413
1637
  if (_this.textBox.style.fontWeight === 'bold') {
1414
1638
  textStyle = 'bold ';
@@ -1440,11 +1664,13 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
1440
1664
  var text = _this.getMaxText();
1441
1665
  var width = _this.upperContext.measureText(text).width +
1442
1666
  _this.activeObj.textSettings.fontSize * 0.5;
1443
- var height = rows.length * (_this.activeObj.textSettings.fontSize + _this.activeObj.textSettings.fontSize * 0.25);
1667
+ var height = rows.length * (_this.activeObj.textSettings.fontSize +
1668
+ _this.activeObj.textSettings.fontSize * 0.25);
1444
1669
  _this.setTextSelection(width, height);
1445
1670
  _this.updateActiveObject(ratio, _this.activeObj.activePoint, _this.activeObj);
1446
- _this.redrawShape(_this.activeObj);
1447
1671
  _this.redrawText(ratio);
1672
+ _this.objColl.push(_this.activeObj);
1673
+ _this.redrawShape(_this.objColl[_this.objColl.length - 1]);
1448
1674
  }
1449
1675
  }
1450
1676
  });
@@ -1495,14 +1721,43 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
1495
1721
  this.activeObj.textSettings.italic = tempItalic;
1496
1722
  return width;
1497
1723
  };
1724
+ ImageEditor.prototype.updateObjColl = function (item) {
1725
+ var tempBold = this.activeObj.textSettings.bold;
1726
+ var tempItalic = this.activeObj.textSettings.italic;
1727
+ switch (item) {
1728
+ case 'default':
1729
+ this.activeObj.textSettings.bold = false;
1730
+ this.activeObj.textSettings.italic = false;
1731
+ break;
1732
+ case 'bold':
1733
+ this.activeObj.textSettings.bold = true;
1734
+ this.activeObj.textSettings.italic = false;
1735
+ break;
1736
+ case 'italic':
1737
+ this.activeObj.textSettings.bold = false;
1738
+ this.activeObj.textSettings.italic = true;
1739
+ break;
1740
+ case 'bolditalic':
1741
+ this.activeObj.textSettings.bold = true;
1742
+ this.activeObj.textSettings.italic = true;
1743
+ break;
1744
+ }
1745
+ this.objColl.push(this.activeObj);
1746
+ this.objColl.pop();
1747
+ this.activeObj.textSettings.bold = tempBold;
1748
+ this.activeObj.textSettings.italic = tempItalic;
1749
+ };
1498
1750
  ImageEditor.prototype.applyFontStyle = function (item, ratio) {
1751
+ this.pushActItemIntoObj();
1752
+ this.objColl.pop();
1499
1753
  switch (item) {
1500
1754
  case 'default':
1501
1755
  if (this.textBox.style.display === 'block') {
1502
- var width = this.getTextAreaWidth(item);
1503
- this.textBox.style.width = Browser.isDevice ? width + 'px' : (width * ((ratio.width + ratio.height) / 2)) + 'px';
1756
+ var width = this.getTextAreaWidth(item) / ratio.width;
1757
+ this.textBox.style.width = width + 'px';
1504
1758
  this.textBox.style.fontWeight = 'normal';
1505
1759
  this.textBox.style.fontStyle = 'normal';
1760
+ this.updateObjColl(item);
1506
1761
  }
1507
1762
  else {
1508
1763
  this.textSettings.bold = this.activeObj.textSettings.bold = false;
@@ -1512,10 +1767,11 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
1512
1767
  break;
1513
1768
  case 'bold':
1514
1769
  if (this.textBox.style.display === 'block') {
1515
- var width = this.getTextAreaWidth(item);
1516
- this.textBox.style.width = Browser.isDevice ? width + 'px' : (width * ((ratio.width + ratio.height) / 2)) + 'px';
1770
+ var width = this.getTextAreaWidth(item) / ratio.width;
1771
+ this.textBox.style.width = width + 'px';
1517
1772
  this.textBox.style.fontWeight = 'bold';
1518
1773
  this.textBox.style.fontStyle = 'normal';
1774
+ this.updateObjColl(item);
1519
1775
  }
1520
1776
  else {
1521
1777
  this.textSettings.bold = this.activeObj.textSettings.bold = true;
@@ -1525,10 +1781,11 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
1525
1781
  break;
1526
1782
  case 'italic':
1527
1783
  if (this.textBox.style.display === 'block') {
1528
- var width = this.getTextAreaWidth(item);
1529
- this.textBox.style.width = Browser.isDevice ? width + 'px' : (width * ((ratio.width + ratio.height) / 2)) + 'px';
1784
+ var width = this.getTextAreaWidth(item) / ratio.width;
1785
+ this.textBox.style.width = width + 'px';
1530
1786
  this.textBox.style.fontWeight = 'normal';
1531
1787
  this.textBox.style.fontStyle = 'italic';
1788
+ this.updateObjColl(item);
1532
1789
  }
1533
1790
  else {
1534
1791
  this.textSettings.bold = this.activeObj.textSettings.bold = false;
@@ -1538,10 +1795,11 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
1538
1795
  break;
1539
1796
  case 'bolditalic':
1540
1797
  if (this.textBox.style.display === 'block') {
1541
- var width = this.getTextAreaWidth(item);
1542
- this.textBox.style.width = (width / ratio.width) + 'px';
1798
+ var width = this.getTextAreaWidth(item) / ratio.width;
1799
+ this.textBox.style.width = width + 'px';
1543
1800
  this.textBox.style.fontWeight = 'bold';
1544
1801
  this.textBox.style.fontStyle = 'italic';
1802
+ this.updateObjColl(item);
1545
1803
  }
1546
1804
  else {
1547
1805
  this.textSettings.bold = this.activeObj.textSettings.bold = true;
@@ -1569,12 +1827,25 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
1569
1827
  this.createLeftToolbarControls();
1570
1828
  if (this.defToolbarItems.length > 0 && (!isNullOrUndefined(document.getElementById(this.element.id + '_toolbar')))) {
1571
1829
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
1572
- var toolbar_6 = getComponent(this.element.id + '_toolbar', 'toolbar');
1573
- toolbar_6.refreshOverflow();
1830
+ var toolbar_7 = getComponent(this.element.id + '_toolbar', 'toolbar');
1831
+ toolbar_7.refreshOverflow();
1832
+ }
1833
+ };
1834
+ ImageEditor.prototype.contextualToolbarClicked = function (args) {
1835
+ var selEle = this.element.querySelector('.e-contextual-toolbar-wrapper .e-toolbar-item.e-selected');
1836
+ if (selEle) {
1837
+ selEle.classList.remove('e-selected');
1574
1838
  }
1839
+ document.getElementById(args.item.id + 'Canvas').parentElement.parentElement.classList.add('e-selected');
1840
+ this.currObjType.isFiltered = true;
1841
+ var type = args.item.id.replace(this.element.id, '').split('_')[1];
1842
+ var imageFiltering = { filter: this.toPascalCase(type) };
1843
+ this.trigger('imageFiltering', imageFiltering);
1844
+ this.setFilter(type.toLowerCase());
1845
+ this.currentFilter = args.item.id;
1575
1846
  };
1576
1847
  ImageEditor.prototype.defToolbarClicked = function (args) {
1577
- var ratio = this.calcRatio();
1848
+ this.element.querySelector('.e-contextual-toolbar-wrapper').classList.add('e-hide');
1578
1849
  var zoomIn;
1579
1850
  var type = args.item.id.replace(this.element.id + '_', '').toLowerCase();
1580
1851
  var imageEditorObj = getInstance(document.getElementById(this.element.id), ImageEditor_1);
@@ -1593,61 +1864,23 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
1593
1864
  if (!this.disabled) {
1594
1865
  switch (type) {
1595
1866
  case 'zoomin':
1867
+ this.currObjType.isFiltered = false;
1596
1868
  if (this.togglePen) {
1597
1869
  this.currObjType.isZoomed = true;
1598
1870
  this.freeHandDraw(false);
1599
1871
  }
1600
1872
  imageEditorObj.zoom(.1);
1601
- if (!this.togglePan) {
1602
- this.callMainToolbar(false, true);
1603
- }
1604
- if (this.factor > 0.95 && this.factor < 1.05) {
1605
- this.dragCanvas = this.togglePan = false;
1606
- this.callMainToolbar(false, true);
1607
- }
1608
- if (isNullOrUndefined(this.activeObj.activePoint) || this.activeObj.activePoint.width === 0) {
1609
- this.refreshToolbar('main');
1610
- }
1611
- else {
1612
- this.refreshToolbar('main', true, true);
1613
- }
1614
- panBtn = this.element.querySelector('.e-img-pan .e-btn');
1615
- if (!isNullOrUndefined(panBtn) && this.togglePan) {
1616
- panBtn.classList.add('e-selected-btn');
1617
- }
1618
- else if (!isNullOrUndefined(panBtn)) {
1619
- panBtn.classList.remove('e-selected-btn');
1620
- }
1621
1873
  break;
1622
1874
  case 'zoomout':
1875
+ this.currObjType.isFiltered = false;
1623
1876
  if (this.togglePen) {
1624
1877
  this.currObjType.isZoomed = true;
1625
1878
  this.freeHandDraw(false);
1626
1879
  }
1627
1880
  imageEditorObj.zoom(-.1);
1628
- if (!this.togglePan) {
1629
- this.callMainToolbar(false, true);
1630
- }
1631
- if (this.factor > 0.95 && this.factor < 1.05) {
1632
- this.dragCanvas = this.togglePan = false;
1633
- this.callMainToolbar(false, true);
1634
- }
1635
- if (isNullOrUndefined(this.activeObj.activePoint) || this.activeObj.activePoint.width === 0) {
1636
- this.refreshToolbar('main');
1637
- }
1638
- else {
1639
- this.refreshToolbar('main', true, true);
1640
- }
1641
- panBtn = this.element.querySelector('.e-img-pan .e-btn');
1642
- if (!isNullOrUndefined(panBtn) && this.togglePan) {
1643
- panBtn.classList.add('e-selected-btn');
1644
- }
1645
- else if (!isNullOrUndefined(panBtn)) {
1646
- panBtn.classList.remove('e-selected-btn');
1647
- }
1648
1881
  break;
1649
1882
  case 'pan':
1650
- this.currObjType.isCustomCrop = false;
1883
+ this.currObjType.isCustomCrop = this.currObjType.isFiltered = false;
1651
1884
  if (isCropSelection) {
1652
1885
  this.currObjType.isCustomCrop = false;
1653
1886
  this.refreshActiveObj();
@@ -1656,11 +1889,13 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
1656
1889
  }
1657
1890
  if (this.togglePan) {
1658
1891
  this.cancelPan();
1892
+ this.disablePan = true;
1659
1893
  }
1660
1894
  else {
1661
1895
  panBtn = this.element.querySelector('.e-img-pan .e-btn');
1662
1896
  panBtn.classList.add('e-selected-btn');
1663
1897
  imageEditorObj.pan(true);
1898
+ this.disablePan = false;
1664
1899
  }
1665
1900
  zoomIn = document.querySelector('#' + this.element.id + '_zoomIn');
1666
1901
  if (!isNullOrUndefined(zoomIn) && this.factor >= 8) {
@@ -1678,46 +1913,113 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
1678
1913
  this.activeObj.strokeSettings = this.tempStrokeSettings;
1679
1914
  this.activeObj.textSettings = this.tempTextSettings;
1680
1915
  }
1916
+ else if (!isNullOrUndefined(document.querySelector('#' + this.element.id + '_sliderWrapper')) ||
1917
+ this.currObjType.isFiltered) {
1918
+ this.lowerContext.filter = this.adjustmentValue = this.initialAdjustmentValue = this.tempAdjustmentValue;
1919
+ this.currentFilter = this.tempFilter;
1920
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
1921
+ this.redrawImgWithObj();
1922
+ this.currObjType.isFiltered = false;
1923
+ if (this.adjustmentLevel.sharpen || this.adjustmentLevel.bw) {
1924
+ if (this.adjustmentLevel.sharpen) {
1925
+ this.setSharpness(false);
1926
+ }
1927
+ else if (this.adjustmentLevel.bw) {
1928
+ this.setBlackAndWhiteFilter(false);
1929
+ }
1930
+ var tempFilter = this.lowerContext.filter;
1931
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
1932
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
1933
+ for (var j = 0; j < this.objColl.length; j++) {
1934
+ this.apply(this.objColl[j].shape, this.objColl[j]);
1935
+ this.refreshActiveObj();
1936
+ }
1937
+ this.lowerContext.filter = tempFilter;
1938
+ }
1939
+ this.adjustmentLevel = extend({}, this.tempAdjustmentLevel, {}, true);
1940
+ if (this.currentFilter === this.element.id + '_sharpen' || this.currentFilter === this.element.id + '_blackandwhite'
1941
+ || this.tempSharpenFilter || this.tempBWFilter) {
1942
+ if (this.currentFilter === this.element.id + '_sharpen' || this.tempSharpenFilter) {
1943
+ this.setSharpness(true);
1944
+ }
1945
+ else if (this.currentFilter === this.element.id + '_blackandwhite' || this.tempBWFilter) {
1946
+ this.setBlackAndWhiteFilter(true);
1947
+ }
1948
+ var tempFilter = this.lowerContext.filter;
1949
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
1950
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
1951
+ for (var j = 0; j < this.objColl.length; j++) {
1952
+ this.apply(this.objColl[j].shape, this.objColl[j]);
1953
+ this.refreshActiveObj();
1954
+ }
1955
+ this.lowerContext.filter = tempFilter;
1956
+ this.tempSharpenFilter = this.tempBWFilter = false;
1957
+ }
1958
+ this.element.querySelector('.e-contextual-toolbar-wrapper').classList.add('e-hide');
1959
+ }
1681
1960
  this.cancelItems();
1682
1961
  break;
1683
1962
  case 'ok':
1684
- if (isCropSelection) {
1685
- this.crop();
1686
- }
1687
- else if (this.togglePen) {
1688
- this.freeHandDraw(false);
1689
- }
1690
- else if (this.textBox.style.display === 'block') {
1691
- this.redrawActObj();
1692
- }
1693
- else {
1694
- this.applyActObj();
1695
- }
1696
- this.callMainToolbar(false);
1963
+ this.okBtn();
1697
1964
  break;
1698
1965
  case 'reset':
1699
1966
  imageEditorObj.reset();
1700
1967
  break;
1968
+ case 'adjustment':
1969
+ this.upperCanvas.style.display = 'block';
1970
+ this.refreshToolbar('adjustment');
1971
+ this.lowerContext.filter = this.initialAdjustmentValue;
1972
+ this.tempAdjustmentValue = this.lowerContext.filter;
1973
+ this.tempAdjustmentLevel = extend({}, this.adjustmentLevel, {}, true);
1974
+ this.tempFilter = this.currentFilter;
1975
+ this.tempSharpenFilter = this.adjustmentLevel.sharpen;
1976
+ this.tempBWFilter = this.adjustmentLevel.bw;
1977
+ break;
1978
+ case 'brightness':
1979
+ case 'contrast':
1980
+ case 'hue':
1981
+ case 'saturation':
1982
+ case 'opacity':
1983
+ case 'blur':
1984
+ case 'exposure':
1985
+ this.unselectBtn();
1986
+ this.currObjType.isFiltered = true;
1987
+ this.refreshToolbar('color', null, null, null, type);
1988
+ document.getElementById(this.element.id + '_' + type).classList.add('e-selected-btn');
1989
+ break;
1990
+ case 'filter':
1991
+ this.upperCanvas.style.display = 'block';
1992
+ this.refreshToolbar('filter');
1993
+ this.lowerContext.filter = this.initialAdjustmentValue;
1994
+ this.tempAdjustmentValue = this.lowerContext.filter;
1995
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
1996
+ this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
1997
+ for (var j = 0; j < this.objColl.length; j++) {
1998
+ this.apply(this.objColl[j].shape, this.objColl[j]);
1999
+ this.refreshActiveObj();
2000
+ }
2001
+ this.tempAdjustmentLevel = extend({}, this.adjustmentLevel, {}, true);
2002
+ this.tempFilter = this.currentFilter;
2003
+ this.tempSharpenFilter = this.adjustmentLevel.sharpen;
2004
+ this.tempBWFilter = this.adjustmentLevel.bw;
2005
+ break;
2006
+ case 'default':
2007
+ case 'chrome':
2008
+ case 'cold':
2009
+ case 'warm':
2010
+ case 'grayscale':
2011
+ case 'blackandwhite':
2012
+ case 'sepia':
2013
+ case 'invert':
2014
+ case 'sharpen':
2015
+ this.currObjType.isFiltered = true;
2016
+ this.setFilter(type);
2017
+ break;
1701
2018
  }
1702
2019
  }
1703
2020
  this.trigger('toolbarItemClicked', args);
1704
2021
  };
1705
- ImageEditor.prototype.cancelPan = function () {
1706
- this.applyActObj();
1707
- var panBtn = this.element.querySelector('.e-img-pan .e-btn');
1708
- panBtn.classList.remove('e-selected-btn');
1709
- this.pan(false);
1710
- };
1711
- ImageEditor.prototype.callMainToolbar = function (isApplyBtn, isZooming) {
1712
- if (this.factor === 1) {
1713
- this.refreshToolbar('main', isApplyBtn, false, isZooming);
1714
- }
1715
- else {
1716
- this.refreshToolbar('main', isApplyBtn, false, isZooming);
1717
- }
1718
- };
1719
- ImageEditor.prototype.cancelItems = function () {
1720
- var ratio = this.calcRatio();
2022
+ ImageEditor.prototype.okBtn = function () {
1721
2023
  var isCropSelection = false;
1722
2024
  var splitWords;
1723
2025
  if (this.activeObj.shape !== undefined) {
@@ -1729,107 +2031,795 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
1729
2031
  else if (splitWords !== undefined && splitWords[0] === 'crop') {
1730
2032
  isCropSelection = true;
1731
2033
  }
1732
- if (this.togglePen) {
1733
- this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
1734
- this.togglePen = false;
1735
- this.upperCanvas.style.cursor = 'default';
1736
- this.penDrawColl = [];
1737
- this.imageEditorPointsColl = [];
2034
+ var selElem = this.element.querySelector('.e-contextual-toolbar-wrapper .e-toolbar-item.e-selected');
2035
+ if (selElem) {
2036
+ this.currentFilter = selElem.children[0].children[0].id.replace('Canvas', '');
1738
2037
  }
1739
- else if (this.activeObj.shape === 'text') {
1740
- this.activeObj.strokeSettings = this.tempStrokeSettings;
1741
- this.activeObj.textSettings = this.tempTextSettings;
1742
- if (this.activeObj.keyHistory === 'Enter Text' && this.activeObj.activePoint.startX === this.textStartPoints.x
1743
- && this.activeObj.activePoint.startY === this.textStartPoints.y) {
1744
- this.refreshActiveObj();
1745
- this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
1746
- this.drawShapeText();
1747
- }
1748
- else {
1749
- this.redrawText(ratio);
1750
- this.redrawShape(this.activeObj);
1751
- if (!isCropSelection && this.activeObj.topLeftCircle !== undefined) {
1752
- this.applyActObj();
1753
- }
1754
- this.clearSelection();
1755
- }
1756
- this.tempTextSettings = { text: 'Enter Text', fontFamily: 'Arial', fontSize: null, bold: false, italic: false, underline: false };
2038
+ if (isCropSelection) {
2039
+ this.crop();
1757
2040
  }
1758
- else if (this.activeObj.shape === 'rectangle' || this.activeObj.shape === 'ellipse' || this.activeObj.shape === 'line') {
1759
- this.activeObj.strokeSettings = this.tempStrokeSettings;
1760
- this.redrawShape(this.activeObj);
1761
- this.applyActObj();
2041
+ else if (this.togglePen) {
2042
+ this.freeHandDraw(false);
2043
+ }
2044
+ else if (this.textBox.style.display === 'block') {
2045
+ this.redrawActObj();
2046
+ }
2047
+ else if (!isNullOrUndefined(document.querySelector('#' + this.element.id + '_sliderWrapper')) ||
2048
+ this.currObjType.isFiltered) {
2049
+ this.initialAdjustmentValue = this.canvasFilter = this.lowerContext.filter;
2050
+ this.currObjType.isFiltered = false;
1762
2051
  }
1763
2052
  else {
1764
- this.refreshActiveObj();
1765
- this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
2053
+ this.applyActObj();
1766
2054
  }
1767
- this.upperCanvas.style.cursor = 'default';
1768
- this.currObjType.isCustomCrop = false;
1769
- this.tempStrokeSettings = { strokeColor: '#fff', fillColor: '', strokeWidth: null };
1770
- this.callMainToolbar();
2055
+ this.callMainToolbar(false);
1771
2056
  };
1772
- ImageEditor.prototype.gradient = function (a, b) {
1773
- return (b.y - a.y) / (b.x - a.x);
2057
+ ImageEditor.prototype.unselectBtn = function () {
2058
+ if (document.querySelector('#' + this.element.id + '_brightness').classList.contains('e-selected-btn')) {
2059
+ document.querySelector('#' + this.element.id + '_brightness').classList.remove('e-selected-btn');
2060
+ }
2061
+ else if (document.querySelector('#' + this.element.id + '_contrast').classList.contains('e-selected-btn')) {
2062
+ document.querySelector('#' + this.element.id + '_contrast').classList.remove('e-selected-btn');
2063
+ }
2064
+ else if (document.querySelector('#' + this.element.id + '_hue').classList.contains('e-selected-btn')) {
2065
+ document.querySelector('#' + this.element.id + '_hue').classList.remove('e-selected-btn');
2066
+ }
2067
+ else if (document.querySelector('#' + this.element.id + '_saturation').classList.contains('e-selected-btn')) {
2068
+ document.querySelector('#' + this.element.id + '_saturation').classList.remove('e-selected-btn');
2069
+ }
2070
+ else if (document.querySelector('#' + this.element.id + '_opacity').classList.contains('e-selected-btn')) {
2071
+ document.querySelector('#' + this.element.id + '_opacity').classList.remove('e-selected-btn');
2072
+ }
2073
+ else if (document.querySelector('#' + this.element.id + '_blur').classList.contains('e-selected-btn')) {
2074
+ document.querySelector('#' + this.element.id + '_blur').classList.remove('e-selected-btn');
2075
+ }
2076
+ else if (document.querySelector('#' + this.element.id + '_exposure').classList.contains('e-selected-btn')) {
2077
+ document.querySelector('#' + this.element.id + '_exposure').classList.remove('e-selected-btn');
2078
+ }
1774
2079
  };
1775
- ImageEditor.prototype.applyPenDraw = function () {
1776
- if (this.togglePen && this.factor === 1 && !this.currObjType.isZoomed) {
1777
- this.apply();
1778
- this.penDrawColl = [];
1779
- this.imageEditorPointsColl = [];
2080
+ ImageEditor.prototype.refreshSlider = function () {
2081
+ var sliderWrapper = document.querySelector('#' + this.element.id + '_sliderWrapper');
2082
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
2083
+ var slider = document.querySelector('.e-slider');
2084
+ var hdrWrapper = document.querySelector('#' + this.element.id + '_headWrapper');
2085
+ if (hdrWrapper) {
2086
+ hdrWrapper.style.display = 'none';
1780
2087
  }
1781
- else {
1782
- var tempCanvas = this.lowerCanvas.appendChild(this.createElement('canvas', {
1783
- id: this.element.id + '_tempCanvas', attrs: { name: 'canvasImage' }
1784
- }));
1785
- var tempContext = tempCanvas.getContext('2d');
1786
- tempCanvas.width = this.lowerCanvas.width;
1787
- tempCanvas.height = this.lowerCanvas.height;
1788
- tempContext.drawImage(this.inMemoryCanvas, 0, 0);
1789
- this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
1790
- for (var i = 0; i < this.penDrawColl.length; i++) {
1791
- tempContext.lineWidth = 2 * this.penDrawColl[i].strokeWidth;
1792
- tempContext.strokeStyle = this.penDrawColl[i].strokeColor;
1793
- var nexP = void 0;
1794
- var preP = void 0;
1795
- var f = 0.3;
1796
- var t = 1;
1797
- tempContext.beginPath();
1798
- tempContext.moveTo(this.penDrawColl[i].points[0].x, this.penDrawColl[i].points[0].y);
1799
- var m = 0;
1800
- var dx1 = 0;
1801
- var dx2 = 0;
1802
- var dy1 = 0;
1803
- var dy2 = 0;
1804
- preP = this.penDrawColl[i].points[0];
1805
- for (var j = 1; j < this.penDrawColl[i].points.length; j++) {
1806
- var curP = this.penDrawColl[i].points[j];
1807
- nexP = this.penDrawColl[i].points[j + 1];
1808
- if (nexP) {
1809
- m = this.gradient(preP, nexP);
1810
- dx2 = (nexP.x - curP.x) * -f;
1811
- dy2 = dx2 * m * t;
1812
- }
1813
- else {
1814
- dx2 = 0;
1815
- dy2 = 0;
1816
- }
1817
- tempContext.bezierCurveTo(preP.x - dx1, preP.y - dy1, curP.x + dx2, curP.y + dy2, curP.x, curP.y);
1818
- dx1 = dx2;
1819
- dy1 = dy2;
1820
- preP = curP;
1821
- if (this.penDrawColl[i].points.length > 2) {
1822
- this.penDrawColl[i].points.shift();
1823
- }
1824
- tempContext.stroke();
2088
+ if (!isNullOrUndefined(sliderWrapper) && !isNullOrUndefined(slider)) {
2089
+ slider.ej2_instances[0].destroy();
2090
+ sliderWrapper.remove();
2091
+ }
2092
+ };
2093
+ ImageEditor.prototype.updateAdjustment = function (type, value, isPreview) {
2094
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
2095
+ var splitWords = this.lowerContext.filter.split(' ');
2096
+ var values = [];
2097
+ var opacityValue;
2098
+ var brightnessValue;
2099
+ if (splitWords[4] !== undefined) {
2100
+ opacityValue = parseFloat(splitWords[4].split('(')[1]);
2101
+ }
2102
+ if (splitWords[0] !== undefined) {
2103
+ brightnessValue = parseFloat(splitWords[0].split('(')[1]);
2104
+ }
2105
+ var brightness = this.getFilterValue(this.adjustmentLevel.brightness);
2106
+ var saturation = this.getFilterValue(this.adjustmentLevel.saturation);
2107
+ if (type !== 'brightness' && type !== 'contrast' && type !== 'hue' && type !== 'saturation' && type !== 'exposure'
2108
+ && type !== 'opacity' && type !== 'blur') {
2109
+ if (isNullOrUndefined(isPreview) && (this.adjustmentLevel.sharpen || this.adjustmentLevel.bw)) {
2110
+ if (this.adjustmentLevel.sharpen) {
2111
+ this.setSharpness(false);
2112
+ }
2113
+ else if (this.adjustmentLevel.bw) {
2114
+ this.setBlackAndWhiteFilter(false);
2115
+ }
2116
+ var temp_1 = this.lowerContext.filter;
2117
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
2118
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
2119
+ for (var i = 0; i < this.objColl.length; i++) {
2120
+ this.apply(this.objColl[i].shape, this.objColl[i]);
2121
+ this.refreshActiveObj();
1825
2122
  }
2123
+ this.lowerContext.filter = temp_1;
1826
2124
  }
1827
- this.penDrawColl = [];
1828
- this.imageEditorPointsColl = [];
1829
- this.togglePen = false;
1830
- var imgData = tempContext.getImageData(0, 0, tempCanvas.width, tempCanvas.height);
1831
- var tempObj = void 0;
1832
- for (var index = 0; index < this.imgDataColl.length; index++) {
2125
+ }
2126
+ if (brightness !== 1) {
2127
+ splitWords[4] = 'opacity(' + (opacityValue - 0.3) + ')';
2128
+ }
2129
+ var saturate;
2130
+ var bright;
2131
+ var contrast;
2132
+ var saturatePercentage;
2133
+ var saturatePercent;
2134
+ var tempFilter;
2135
+ var temp;
2136
+ switch (type) {
2137
+ case 'brightness':
2138
+ if (splitWords[3].split) {
2139
+ if (parseFloat(splitWords[3].split('(')[1]) !== 100) {
2140
+ value += 0.1;
2141
+ }
2142
+ }
2143
+ splitWords[0] = 'brightness(' + value + ')';
2144
+ this.adjustmentValue = splitWords.join(' ');
2145
+ break;
2146
+ case 'contrast':
2147
+ splitWords[1] = 'contrast(' + value + '%)';
2148
+ this.adjustmentValue = splitWords.join(' ');
2149
+ break;
2150
+ case 'hue':
2151
+ splitWords[2] = 'hue-rotate(' + value + 'deg)';
2152
+ this.adjustmentValue = splitWords.join(' ');
2153
+ break;
2154
+ case 'saturation':
2155
+ splitWords[3] = 'saturate(' + value + '%)';
2156
+ if (saturation !== 1) {
2157
+ splitWords[0] = 'brightness(' + (brightnessValue + 0.1) + ')';
2158
+ }
2159
+ this.adjustmentValue = splitWords.join(' ');
2160
+ break;
2161
+ case 'opacity':
2162
+ if (parseFloat(splitWords[0].split('(')[1]) !== 1) {
2163
+ value -= 0.2;
2164
+ }
2165
+ splitWords[4] = 'opacity(' + value + ')';
2166
+ this.adjustmentValue = splitWords.join(' ');
2167
+ break;
2168
+ case 'blur':
2169
+ splitWords[5] = 'blur(' + value + 'px)';
2170
+ this.adjustmentValue = splitWords.join(' ');
2171
+ break;
2172
+ case 'exposure':
2173
+ if (brightness !== 1) {
2174
+ splitWords[4] = 'opacity(' + (opacityValue - 0.3) + ')';
2175
+ }
2176
+ if (value > 1) {
2177
+ value -= 1;
2178
+ value += brightness;
2179
+ }
2180
+ else if (value < 1) {
2181
+ value = 1 - value;
2182
+ value = brightness - value;
2183
+ }
2184
+ splitWords[0] = 'brightness(' + value + ')';
2185
+ this.adjustmentValue = splitWords.join(' ');
2186
+ break;
2187
+ case 'chrome':
2188
+ saturate = this.getSaturationFilterValue(this.adjustmentLevel.saturation);
2189
+ saturate *= 100;
2190
+ value = saturate + (saturate * 0.4);
2191
+ splitWords[3] = 'saturate(' + value + '%)';
2192
+ values = this.adjustmentValue.split(' ');
2193
+ splitWords[0] = values[0];
2194
+ splitWords[1] = values[1];
2195
+ splitWords[2] = values[2];
2196
+ splitWords[4] = values[4];
2197
+ splitWords[5] = values[5];
2198
+ splitWords[6] = 'sepia(0%)';
2199
+ splitWords[7] = 'grayscale(0%)';
2200
+ splitWords[8] = 'invert(0%)';
2201
+ break;
2202
+ case 'cold':
2203
+ // Adjusting Brightness
2204
+ bright = this.getFilterValue(this.adjustmentLevel.brightness);
2205
+ bright *= 100;
2206
+ value = bright * 0.9;
2207
+ splitWords[0] = 'brightness(' + value + '%)';
2208
+ // Adjusting Contrast
2209
+ contrast = this.getFilterValue(this.adjustmentLevel.contrast);
2210
+ contrast *= 100;
2211
+ value = contrast + (contrast * 0.5);
2212
+ splitWords[1] = 'contrast(' + value + '%)';
2213
+ // Adjusting Saturation
2214
+ saturatePercentage = this.getSaturationFilterValue(this.adjustmentLevel.saturation);
2215
+ saturatePercentage *= 100;
2216
+ value = saturatePercentage;
2217
+ splitWords[3] = 'saturate(' + value + '%)';
2218
+ values = this.adjustmentValue.split(' ');
2219
+ splitWords[2] = values[2];
2220
+ splitWords[4] = values[4];
2221
+ splitWords[5] = values[5];
2222
+ splitWords[6] = 'sepia(0%)';
2223
+ splitWords[7] = 'grayscale(0%)';
2224
+ splitWords[8] = 'invert(0%)';
2225
+ break;
2226
+ case 'warm':
2227
+ saturatePercent = this.getSaturationFilterValue(this.adjustmentLevel.saturation);
2228
+ saturatePercent *= 100;
2229
+ value = saturatePercent + (saturatePercent * 0.4);
2230
+ splitWords[3] = 'saturate(' + value + '%)';
2231
+ splitWords[6] = 'sepia(25%)';
2232
+ values = this.adjustmentValue.split(' ');
2233
+ splitWords[0] = values[0];
2234
+ splitWords[1] = values[1];
2235
+ splitWords[2] = values[2];
2236
+ splitWords[4] = values[4];
2237
+ splitWords[5] = values[5];
2238
+ splitWords[7] = 'grayscale(0%)';
2239
+ splitWords[8] = 'invert(0%)';
2240
+ break;
2241
+ case 'grayscale':
2242
+ splitWords[7] = 'grayscale(100%)';
2243
+ values = this.adjustmentValue.split(' ');
2244
+ splitWords[0] = values[0];
2245
+ splitWords[1] = values[1];
2246
+ splitWords[2] = values[2];
2247
+ splitWords[3] = values[3];
2248
+ splitWords[4] = values[4];
2249
+ splitWords[5] = values[5];
2250
+ splitWords[6] = 'sepia(0%)';
2251
+ splitWords[8] = 'invert(0%)';
2252
+ break;
2253
+ case 'blackandwhite':
2254
+ values = this.adjustmentValue.split(' ');
2255
+ if (isPreview) {
2256
+ tempFilter = this.lowerContext.filter;
2257
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
2258
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
2259
+ this.setBlackAndWhiteFilter(true);
2260
+ for (var i = 0; i < this.objColl.length; i++) {
2261
+ this.apply(this.objColl[i].shape, this.objColl[i]);
2262
+ this.refreshActiveObj();
2263
+ }
2264
+ splitWords[0] = values[0];
2265
+ splitWords[1] = values[1];
2266
+ splitWords[2] = values[2];
2267
+ splitWords[3] = values[3];
2268
+ splitWords[4] = values[4];
2269
+ splitWords[5] = values[5];
2270
+ splitWords[6] = 'sepia(0%)';
2271
+ splitWords[7] = 'grayscale(0%)';
2272
+ splitWords[8] = 'invert(0%)';
2273
+ }
2274
+ else {
2275
+ tempFilter = this.lowerContext.filter;
2276
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
2277
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
2278
+ this.setBlackAndWhiteFilter(true);
2279
+ splitWords[0] = values[0];
2280
+ splitWords[1] = values[1];
2281
+ splitWords[2] = values[2];
2282
+ splitWords[3] = values[3];
2283
+ splitWords[4] = values[4];
2284
+ splitWords[5] = values[5];
2285
+ splitWords[6] = 'sepia(0%)';
2286
+ splitWords[7] = 'grayscale(0%)';
2287
+ splitWords[8] = 'invert(0%)';
2288
+ this.lowerContext.filter = this.initialAdjustmentValue = splitWords.join(' ');
2289
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
2290
+ this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
2291
+ tempFilter = this.lowerContext.filter;
2292
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
2293
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
2294
+ for (var i = 0; i < this.objColl.length; i++) {
2295
+ this.apply(this.objColl[i].shape, this.objColl[i]);
2296
+ this.refreshActiveObj();
2297
+ }
2298
+ this.lowerContext.filter = tempFilter;
2299
+ }
2300
+ break;
2301
+ case 'sepia':
2302
+ splitWords[6] = 'sepia(100%)';
2303
+ values = this.adjustmentValue.split(' ');
2304
+ splitWords[0] = values[0];
2305
+ splitWords[1] = values[1];
2306
+ splitWords[2] = values[2];
2307
+ splitWords[3] = values[3];
2308
+ splitWords[4] = values[4];
2309
+ splitWords[5] = values[5];
2310
+ splitWords[7] = 'grayscale(0%)';
2311
+ splitWords[8] = 'invert(0%)';
2312
+ break;
2313
+ case 'invert':
2314
+ splitWords[8] = 'invert(100%)';
2315
+ values = this.adjustmentValue.split(' ');
2316
+ splitWords[0] = values[0];
2317
+ splitWords[1] = values[1];
2318
+ splitWords[2] = values[2];
2319
+ splitWords[3] = values[3];
2320
+ splitWords[4] = values[4];
2321
+ splitWords[5] = values[5];
2322
+ splitWords[6] = 'sepia(0%)';
2323
+ splitWords[7] = 'grayscale(0%)';
2324
+ break;
2325
+ case 'sharpen':
2326
+ values = this.adjustmentValue.split(' ');
2327
+ if (isPreview) {
2328
+ temp = this.lowerContext.filter;
2329
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
2330
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
2331
+ for (var i = 0; i < this.objColl.length; i++) {
2332
+ this.apply(this.objColl[i].shape, this.objColl[i]);
2333
+ this.refreshActiveObj();
2334
+ }
2335
+ splitWords[0] = values[0];
2336
+ splitWords[1] = values[1];
2337
+ splitWords[2] = values[2];
2338
+ splitWords[3] = values[3];
2339
+ splitWords[4] = values[4];
2340
+ splitWords[5] = values[5];
2341
+ splitWords[6] = 'sepia(0%)';
2342
+ splitWords[7] = 'grayscale(0%)';
2343
+ splitWords[8] = 'invert(0%)';
2344
+ }
2345
+ else {
2346
+ temp = this.lowerContext.filter;
2347
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
2348
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
2349
+ this.setSharpness(true);
2350
+ splitWords[0] = values[0];
2351
+ splitWords[1] = values[1];
2352
+ splitWords[2] = values[2];
2353
+ splitWords[3] = values[3];
2354
+ splitWords[4] = values[4];
2355
+ splitWords[5] = values[5];
2356
+ splitWords[6] = 'sepia(0%)';
2357
+ splitWords[7] = 'grayscale(0%)';
2358
+ splitWords[8] = 'invert(0%)';
2359
+ this.lowerContext.filter = this.initialAdjustmentValue = splitWords.join(' ');
2360
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
2361
+ this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
2362
+ temp = this.lowerContext.filter;
2363
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
2364
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
2365
+ for (var i = 0; i < this.objColl.length; i++) {
2366
+ this.apply(this.objColl[i].shape, this.objColl[i]);
2367
+ this.refreshActiveObj();
2368
+ }
2369
+ this.lowerContext.filter = temp;
2370
+ }
2371
+ break;
2372
+ }
2373
+ if (type !== 'sharpen' && type !== 'blackandwhite') {
2374
+ if (isNullOrUndefined(isPreview)) {
2375
+ if (type === 'default') {
2376
+ splitWords = this.getDefaultFilter(splitWords);
2377
+ }
2378
+ this.lowerContext.filter = splitWords.join(' ');
2379
+ }
2380
+ splitWords = this.setTempFilterValue(brightness, isPreview, splitWords, type);
2381
+ this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
2382
+ if (brightness !== 1) {
2383
+ splitWords[4] = 'opacity(' + opacityValue + ')';
2384
+ }
2385
+ else if (saturation !== 1) {
2386
+ splitWords[0] = 'brightness(' + brightnessValue + ')';
2387
+ }
2388
+ if (type === 'exposure' && brightness !== 1) {
2389
+ splitWords[0] = 'brightness(' + brightnessValue + ')';
2390
+ }
2391
+ splitWords = this.setTempFilterValue(brightness, isPreview, splitWords, type);
2392
+ if (isNullOrUndefined(isPreview)) {
2393
+ this.lowerContext.filter = this.initialAdjustmentValue = splitWords.join(' ');
2394
+ }
2395
+ var tempFilter_1 = this.lowerContext.filter;
2396
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
2397
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
2398
+ for (var i = 0; i < this.objColl.length; i++) {
2399
+ this.apply(this.objColl[i].shape, this.objColl[i]);
2400
+ this.refreshActiveObj();
2401
+ }
2402
+ this.lowerContext.filter = tempFilter_1;
2403
+ if (brightness === 1) {
2404
+ this.isBrightnessAdjusted = false;
2405
+ }
2406
+ else {
2407
+ this.isBrightnessAdjusted = true;
2408
+ }
2409
+ }
2410
+ var filter = splitWords.join(' ');
2411
+ return filter;
2412
+ };
2413
+ ImageEditor.prototype.updateBrightnessFilter = function () {
2414
+ var splitWords = this.lowerContext.filter.split(' ');
2415
+ if (this.isBrightnessAdjusted && splitWords.length > 0 && !isNullOrUndefined(splitWords[4])) {
2416
+ var opacityValue = parseFloat(splitWords[4].split('(')[1]);
2417
+ splitWords[4] = 'opacity(' + (opacityValue - 0.3) + ')';
2418
+ this.lowerContext.filter = splitWords.join(' ');
2419
+ }
2420
+ };
2421
+ ImageEditor.prototype.autoEnablePan = function () {
2422
+ if (this.factor > 0.95 && this.factor < 1.05) {
2423
+ this.dragCanvas = this.togglePan = false;
2424
+ this.callMainToolbar(false, true);
2425
+ this.pan(false);
2426
+ this.disablePan = false;
2427
+ }
2428
+ else if (!this.disablePan) {
2429
+ this.pan(true);
2430
+ }
2431
+ else if (this.disablePan) {
2432
+ this.pan(false);
2433
+ }
2434
+ };
2435
+ ImageEditor.prototype.setTempFilterValue = function (brightness, isPreview, splitWords, type) {
2436
+ if (isPreview && brightness !== 1) {
2437
+ var tempSplitWords = this.lowerContext.filter.split(' ');
2438
+ tempSplitWords[4] = splitWords[4];
2439
+ this.lowerContext.filter = tempSplitWords.join(' ');
2440
+ }
2441
+ else if (isPreview && type === 'default') {
2442
+ splitWords = this.getDefaultFilter(splitWords);
2443
+ }
2444
+ return splitWords;
2445
+ };
2446
+ ImageEditor.prototype.getDefaultFilter = function (splitWords) {
2447
+ var values = this.adjustmentValue.split(' ');
2448
+ splitWords[0] = values[0];
2449
+ splitWords[1] = values[1];
2450
+ splitWords[2] = values[2];
2451
+ splitWords[3] = values[3];
2452
+ splitWords[4] = values[4];
2453
+ splitWords[5] = values[5];
2454
+ splitWords[6] = 'sepia(0%)';
2455
+ splitWords[7] = 'grayscale(0%)';
2456
+ splitWords[8] = 'invert(0%)';
2457
+ return splitWords;
2458
+ };
2459
+ ImageEditor.prototype.setAdjustment = function (type) {
2460
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
2461
+ var splitWords = this.lowerContext.filter.split(' ');
2462
+ var value;
2463
+ var valueArr;
2464
+ switch (type) {
2465
+ case 'brightness':
2466
+ valueArr = splitWords[0].split('(');
2467
+ value = parseFloat(valueArr[1].split(')')[0]);
2468
+ this.adjustmentLevel.brightness = this.setFilterValue(value);
2469
+ break;
2470
+ case 'contrast':
2471
+ valueArr = splitWords[1].split('(');
2472
+ value = parseFloat(valueArr[1].split(')')[0]);
2473
+ value /= 100;
2474
+ this.adjustmentLevel.contrast = this.setFilterValue(value);
2475
+ break;
2476
+ case 'hue':
2477
+ valueArr = splitWords[2].split('(');
2478
+ value = parseFloat(valueArr[1].split(')')[0]);
2479
+ value /= 3;
2480
+ this.adjustmentLevel.hue = value;
2481
+ break;
2482
+ case 'saturation':
2483
+ valueArr = splitWords[3].split('(');
2484
+ value = parseFloat(valueArr[1].split(')')[0]);
2485
+ value /= 100;
2486
+ this.adjustmentLevel.saturation = this.setSaturationFilterValue(value);
2487
+ break;
2488
+ case 'opacity':
2489
+ valueArr = splitWords[4].split('(');
2490
+ value = parseFloat(valueArr[1].split(')')[0]);
2491
+ if (value === 0.45) {
2492
+ value = 40;
2493
+ }
2494
+ else if (value === 0.40) {
2495
+ value = 30;
2496
+ }
2497
+ else if (value === 0.35) {
2498
+ value = 20;
2499
+ }
2500
+ else if (value === 0.30) {
2501
+ value = 10;
2502
+ }
2503
+ else if (value === 0.25) {
2504
+ value = 0;
2505
+ }
2506
+ else {
2507
+ value *= 100;
2508
+ }
2509
+ this.adjustmentLevel.opacity = value;
2510
+ break;
2511
+ case 'blur':
2512
+ valueArr = splitWords[5].split('(');
2513
+ value = parseFloat(valueArr[1].split(')')[0]);
2514
+ value *= 20;
2515
+ this.adjustmentLevel.blur = value;
2516
+ break;
2517
+ case 'exposure':
2518
+ valueArr = splitWords[0].split('(');
2519
+ value = parseFloat(valueArr[1].split(')')[0]);
2520
+ this.adjustmentLevel.exposure = this.setFilterValue(value);
2521
+ break;
2522
+ }
2523
+ var temp = this.lowerContext.filter;
2524
+ this.updateBrightnessFilter();
2525
+ this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
2526
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
2527
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
2528
+ for (var j = 0; j < this.objColl.length; j++) {
2529
+ this.apply(this.objColl[j].shape, this.objColl[j]);
2530
+ this.refreshActiveObj();
2531
+ }
2532
+ this.lowerContext.filter = temp;
2533
+ };
2534
+ ImageEditor.prototype.renderSlider = function (type) {
2535
+ var _this = this;
2536
+ var canvasWrapper = document.querySelector('#' + this.element.id + '_contextualToolbarArea');
2537
+ var hdrWrapper = document.querySelector('#' + this.element.id + '_headWrapper');
2538
+ var labelWrapper = document.querySelector('#' + this.element.id + '_labelWrapper');
2539
+ if (!hdrWrapper && !isNullOrUndefined(canvasWrapper)) {
2540
+ hdrWrapper = canvasWrapper.appendChild(this.createElement('div', {
2541
+ id: this.element.id + '_headWrapper',
2542
+ styles: 'position: relative'
2543
+ }));
2544
+ labelWrapper = hdrWrapper.appendChild(this.createElement('label', {
2545
+ id: this.element.id + '_labelWrapper',
2546
+ styles: Browser.isDevice ? 'position: absolute; top: 25%; left: calc(50% - 150px); font-size: 15px; text-transform: capitalize; font-weight: 400;'
2547
+ : 'position: absolute; top: 25%; left: calc(50% - 226px); font-size: 15px; text-transform: capitalize; font-weight: 400;'
2548
+ }));
2549
+ }
2550
+ else {
2551
+ hdrWrapper.style.display = 'block';
2552
+ }
2553
+ labelWrapper.textContent = this.l10n.getConstant(this.toPascalCase(type));
2554
+ var sliderWrapper = hdrWrapper.appendChild(this.createElement('div', {
2555
+ id: this.element.id + '_sliderWrapper',
2556
+ styles: 'position: absolute'
2557
+ }));
2558
+ var value = this.getCurrAdjustmentValue(type);
2559
+ var min;
2560
+ var max;
2561
+ var slider;
2562
+ if (type === 'brightness' || type === 'contrast' || type === 'saturation' || type === 'exposure') {
2563
+ if (this.finetuneSettings) {
2564
+ if (type === 'brightness' && this.finetuneSettings.brightness) {
2565
+ min = this.finetuneSettings.brightness.min;
2566
+ max = this.finetuneSettings.brightness.max;
2567
+ }
2568
+ else if (type === 'contrast' && this.finetuneSettings.contrast) {
2569
+ min = this.finetuneSettings.contrast.min;
2570
+ max = this.finetuneSettings.contrast.max;
2571
+ }
2572
+ else if (type === 'saturation' && this.finetuneSettings.saturation) {
2573
+ min = this.finetuneSettings.saturation.min;
2574
+ max = this.finetuneSettings.saturation.max;
2575
+ }
2576
+ else if (type === 'exposure' && this.finetuneSettings.exposure) {
2577
+ min = this.finetuneSettings.exposure.min;
2578
+ max = this.finetuneSettings.exposure.max;
2579
+ }
2580
+ else {
2581
+ min = -100;
2582
+ max = 100;
2583
+ }
2584
+ }
2585
+ else {
2586
+ min = -100;
2587
+ max = 100;
2588
+ }
2589
+ slider = new Slider({
2590
+ value: value,
2591
+ tooltip: { isVisible: true, placement: 'Before', showOn: 'Always' },
2592
+ type: 'MinRange',
2593
+ min: min,
2594
+ max: max,
2595
+ step: 10,
2596
+ width: Browser.isDevice ? '200px' : '300px',
2597
+ cssClass: 'e-slider',
2598
+ change: function (args) {
2599
+ _this.setCurrAdjustmentValue(type, args.value);
2600
+ }
2601
+ });
2602
+ }
2603
+ else if (type === 'hue' || type === 'blur' || type === 'opacity') {
2604
+ if (this.finetuneSettings) {
2605
+ if (type === 'hue' && this.finetuneSettings.hue) {
2606
+ min = this.finetuneSettings.hue.min;
2607
+ max = this.finetuneSettings.hue.max;
2608
+ }
2609
+ else if (type === 'blur' && this.finetuneSettings.blur) {
2610
+ min = this.finetuneSettings.blur.min;
2611
+ max = this.finetuneSettings.blur.max;
2612
+ }
2613
+ else if (type === 'opacity' && this.finetuneSettings.opacity) {
2614
+ min = this.finetuneSettings.opacity.min;
2615
+ max = this.finetuneSettings.opacity.max;
2616
+ }
2617
+ else {
2618
+ min = 0;
2619
+ max = 100;
2620
+ }
2621
+ }
2622
+ else {
2623
+ min = 0;
2624
+ max = 100;
2625
+ }
2626
+ slider = new Slider({
2627
+ value: value,
2628
+ tooltip: { isVisible: true, placement: 'Before', showOn: 'Always' },
2629
+ type: 'MinRange',
2630
+ min: min,
2631
+ max: max,
2632
+ step: 10,
2633
+ width: Browser.isDevice ? '200px' : '300px',
2634
+ cssClass: 'e-slider',
2635
+ change: function (args) {
2636
+ _this.setCurrAdjustmentValue(type, args.value);
2637
+ }
2638
+ });
2639
+ }
2640
+ slider.appendTo('#' + this.element.id + '_sliderWrapper');
2641
+ sliderWrapper.style.left = (parseFloat(canvasWrapper.style.width) - parseFloat(slider.width)) / 2 + 'px';
2642
+ };
2643
+ ImageEditor.prototype.getCurrAdjustmentValue = function (type) {
2644
+ var value;
2645
+ switch (type) {
2646
+ case 'brightness':
2647
+ value = this.adjustmentLevel.brightness;
2648
+ break;
2649
+ case 'contrast':
2650
+ value = this.adjustmentLevel.contrast;
2651
+ break;
2652
+ case 'hue':
2653
+ value = this.adjustmentLevel.hue;
2654
+ break;
2655
+ case 'saturation':
2656
+ value = this.adjustmentLevel.saturation;
2657
+ break;
2658
+ case 'opacity':
2659
+ value = this.adjustmentLevel.opacity;
2660
+ break;
2661
+ case 'blur':
2662
+ value = this.adjustmentLevel.blur;
2663
+ break;
2664
+ case 'exposure':
2665
+ value = this.adjustmentLevel.exposure;
2666
+ break;
2667
+ }
2668
+ return value;
2669
+ };
2670
+ ImageEditor.prototype.setCurrAdjustmentValue = function (type, value) {
2671
+ var fineTuneValueChanging = { finetune: this.toPascalCase(type), value: value };
2672
+ this.trigger('fineTuneValueChanging', fineTuneValueChanging);
2673
+ switch (type) {
2674
+ case 'brightness':
2675
+ this.setBrightness(value);
2676
+ break;
2677
+ case 'contrast':
2678
+ this.setContrast(value);
2679
+ break;
2680
+ case 'hue':
2681
+ this.setHue(value);
2682
+ break;
2683
+ case 'saturation':
2684
+ this.setSaturation(value);
2685
+ break;
2686
+ case 'opacity':
2687
+ this.setOpacity(value);
2688
+ break;
2689
+ case 'blur':
2690
+ this.setBlur(value);
2691
+ break;
2692
+ case 'exposure':
2693
+ this.setExposure(value);
2694
+ break;
2695
+ }
2696
+ };
2697
+ ImageEditor.prototype.cancelPan = function () {
2698
+ this.applyActObj();
2699
+ var panBtn = this.element.querySelector('.e-img-pan .e-btn');
2700
+ panBtn.classList.remove('e-selected-btn');
2701
+ this.pan(false);
2702
+ };
2703
+ ImageEditor.prototype.callMainToolbar = function (isApplyBtn, isZooming) {
2704
+ this.refreshToolbar('main', isApplyBtn, false, isZooming);
2705
+ };
2706
+ ImageEditor.prototype.cancelItems = function () {
2707
+ var ratio = this.calcRatio();
2708
+ var isCropSelection = false;
2709
+ var splitWords;
2710
+ if (this.activeObj.shape !== undefined) {
2711
+ splitWords = this.activeObj.shape.split('-');
2712
+ }
2713
+ if (splitWords === undefined && this.currObjType.isCustomCrop) {
2714
+ isCropSelection = true;
2715
+ }
2716
+ else if (splitWords !== undefined && splitWords[0] === 'crop') {
2717
+ isCropSelection = true;
2718
+ }
2719
+ if (this.togglePen) {
2720
+ this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
2721
+ this.togglePen = false;
2722
+ this.upperCanvas.style.cursor = 'default';
2723
+ this.penDrawColl = [];
2724
+ this.imageEditorPointsColl = [];
2725
+ }
2726
+ else if (this.activeObj.shape === 'text') {
2727
+ this.activeObj.strokeSettings = this.tempStrokeSettings;
2728
+ this.activeObj.textSettings = this.tempTextSettings;
2729
+ if (this.activeObj.keyHistory === 'Enter Text' && this.activeObj.activePoint.startX === this.textStartPoints.x
2730
+ && this.activeObj.activePoint.startY === this.textStartPoints.y) {
2731
+ this.refreshActiveObj();
2732
+ this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
2733
+ this.drawShapeText();
2734
+ }
2735
+ else {
2736
+ this.redrawText(ratio);
2737
+ this.redrawShape(this.activeObj);
2738
+ if (!isCropSelection && this.activeObj.topLeftCircle !== undefined) {
2739
+ this.applyActObj();
2740
+ }
2741
+ this.clearSelection();
2742
+ }
2743
+ this.tempTextSettings = { text: 'Enter Text', fontFamily: 'Arial', fontSize: null, bold: false, italic: false, underline: false };
2744
+ }
2745
+ else if (this.activeObj.shape === 'rectangle' || this.activeObj.shape === 'ellipse' || this.activeObj.shape === 'line') {
2746
+ this.activeObj.strokeSettings = this.tempStrokeSettings;
2747
+ this.redrawShape(this.activeObj);
2748
+ this.applyActObj();
2749
+ }
2750
+ else {
2751
+ this.refreshActiveObj();
2752
+ this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
2753
+ }
2754
+ this.upperCanvas.style.cursor = 'default';
2755
+ this.currObjType.isCustomCrop = false;
2756
+ this.tempStrokeSettings = { strokeColor: '#fff', fillColor: '', strokeWidth: null };
2757
+ this.callMainToolbar();
2758
+ };
2759
+ ImageEditor.prototype.gradient = function (a, b) {
2760
+ return (b.y - a.y) / (b.x - a.x);
2761
+ };
2762
+ ImageEditor.prototype.applyPenDraw = function () {
2763
+ if (this.togglePen && this.factor === 1 && !this.currObjType.isZoomed) {
2764
+ this.apply();
2765
+ this.penDrawColl = [];
2766
+ this.imageEditorPointsColl = [];
2767
+ }
2768
+ else {
2769
+ var tempCanvas = this.lowerCanvas.appendChild(this.createElement('canvas', {
2770
+ id: this.element.id + '_tempCanvas', attrs: { name: 'canvasImage' }
2771
+ }));
2772
+ var tempContext = tempCanvas.getContext('2d');
2773
+ tempCanvas.width = this.lowerCanvas.width;
2774
+ tempCanvas.height = this.lowerCanvas.height;
2775
+ var temp = this.lowerContext.filter;
2776
+ this.updateBrightnessFilter();
2777
+ tempContext.drawImage(this.inMemoryCanvas, 0, 0);
2778
+ this.lowerContext.filter = temp;
2779
+ this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
2780
+ for (var i = 0; i < this.penDrawColl.length; i++) {
2781
+ tempContext.lineWidth = 2 * this.penDrawColl[i].strokeWidth;
2782
+ tempContext.strokeStyle = this.penDrawColl[i].strokeColor;
2783
+ var nexP = void 0;
2784
+ var preP = void 0;
2785
+ var f = 0.3;
2786
+ var t = 1;
2787
+ tempContext.beginPath();
2788
+ tempContext.moveTo(this.penDrawColl[i].points[0].x, this.penDrawColl[i].points[0].y);
2789
+ var m = 0;
2790
+ var dx1 = 0;
2791
+ var dx2 = 0;
2792
+ var dy1 = 0;
2793
+ var dy2 = 0;
2794
+ preP = this.penDrawColl[i].points[0];
2795
+ for (var j = 1; j < this.penDrawColl[i].points.length; j++) {
2796
+ var curP = this.penDrawColl[i].points[j];
2797
+ nexP = this.penDrawColl[i].points[j + 1];
2798
+ if (nexP) {
2799
+ m = this.gradient(preP, nexP);
2800
+ dx2 = (nexP.x - curP.x) * -f;
2801
+ dy2 = dx2 * m * t;
2802
+ }
2803
+ else {
2804
+ dx2 = 0;
2805
+ dy2 = 0;
2806
+ }
2807
+ tempContext.bezierCurveTo(preP.x - dx1, preP.y - dy1, curP.x + dx2, curP.y + dy2, curP.x, curP.y);
2808
+ dx1 = dx2;
2809
+ dy1 = dy2;
2810
+ preP = curP;
2811
+ if (this.penDrawColl[i].points.length > 2) {
2812
+ this.penDrawColl[i].points.shift();
2813
+ }
2814
+ tempContext.stroke();
2815
+ }
2816
+ }
2817
+ this.penDrawColl = [];
2818
+ this.imageEditorPointsColl = [];
2819
+ this.togglePen = false;
2820
+ var imgData = tempContext.getImageData(0, 0, tempCanvas.width, tempCanvas.height);
2821
+ var tempObj = void 0;
2822
+ for (var index = 0; index < this.imgDataColl.length; index++) {
1833
2823
  if (this.imgDataColl[index].operation !== 'freehanddraw') {
1834
2824
  tempObj = this.imgDataColl[index];
1835
2825
  break;
@@ -1843,24 +2833,37 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
1843
2833
  this.inMemoryCanvas.height = imgData.height;
1844
2834
  this.inMemoryContext.putImageData(imgData, 0, 0);
1845
2835
  this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
1846
- this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
1847
- for (var j = 0; j < this.objColl.length; j++) {
1848
- this.apply(this.objColl[j].shape, this.objColl[j]);
1849
- this.refreshActiveObj();
1850
- }
2836
+ this.redrawImgWithObj();
1851
2837
  this.currObjType.isZoomed = false;
1852
2838
  }
1853
2839
  };
1854
- ImageEditor.prototype.refreshToolbar = function (type, isApplyBtn, isCropping, isZooming) {
1855
- var args = { toolbarType: type };
1856
- if (document.getElementById(this.element.id + '_toolbar') && this.defToolbarItems.length > 0) {
1857
- getComponent(document.getElementById(this.element.id + '_toolbar'), 'toolbar').destroy();
2840
+ ImageEditor.prototype.redrawImgWithObj = function () {
2841
+ this.lowerContext.filter = this.canvasFilter;
2842
+ var temp = this.lowerContext.filter;
2843
+ this.updateBrightnessFilter();
2844
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
2845
+ this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
2846
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
2847
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
2848
+ for (var j = 0; j < this.objColl.length; j++) {
2849
+ this.apply(this.objColl[j].shape, this.objColl[j]);
2850
+ this.refreshActiveObj();
1858
2851
  }
1859
- if (document.getElementById(this.element.id + '_bottomToolbar') && this.defToolbarItems.length > 0) {
1860
- if (document.getElementById(this.element.id + '_bottomToolbar').className.indexOf('e-control') > -1) {
1861
- getComponent(document.getElementById(this.element.id + '_bottomToolbar'), 'toolbar').destroy();
2852
+ this.lowerContext.filter = temp;
2853
+ };
2854
+ ImageEditor.prototype.refreshToolbar = function (type, isApplyBtn, isCropping, isZooming, cType) {
2855
+ var args = { toolbarType: type };
2856
+ if (type !== 'filter' && type !== 'color') {
2857
+ if (document.getElementById(this.element.id + '_toolbar') && this.defToolbarItems.length > 0) {
2858
+ getComponent(document.getElementById(this.element.id + '_toolbar'), 'toolbar').destroy();
2859
+ }
2860
+ if (document.getElementById(this.element.id + '_bottomToolbar') && this.defToolbarItems.length > 0) {
2861
+ if (document.getElementById(this.element.id + '_bottomToolbar').className.indexOf('e-control') > -1) {
2862
+ getComponent(document.getElementById(this.element.id + '_bottomToolbar'), 'toolbar').destroy();
2863
+ }
1862
2864
  }
1863
2865
  }
2866
+ this.refreshSlider();
1864
2867
  switch (type) {
1865
2868
  case 'main':
1866
2869
  if (Browser.isDevice) {
@@ -1910,7 +2913,104 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
1910
2913
  case 'pan':
1911
2914
  this.initZoomToolbarItem();
1912
2915
  break;
2916
+ case 'adjustment':
2917
+ if (Browser.isDevice) {
2918
+ this.initToolbarItem(false, true, true);
2919
+ }
2920
+ this.initAdjustmentToolbarItem();
2921
+ break;
2922
+ case 'filter':
2923
+ this.updateContextualToolbar(type);
2924
+ break;
2925
+ case 'color':
2926
+ this.updateContextualToolbar(type, cType);
2927
+ break;
2928
+ }
2929
+ };
2930
+ ImageEditor.prototype.getAdjustmentToolbarItem = function () {
2931
+ var toolbarItems = [];
2932
+ if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Brightness') > -1)) {
2933
+ toolbarItems.push({ id: this.element.id + '_brightness', prefixIcon: 'e-icons e-brightness', cssClass: 'top-icon e-brightness',
2934
+ tooltipText: this.l10n.getConstant('Brightness'), align: 'Center' });
2935
+ }
2936
+ if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Contrast') > -1)) {
2937
+ toolbarItems.push({ id: this.element.id + '_contrast', prefixIcon: 'e-icons e-contrast', cssClass: 'top-icon e-contrast',
2938
+ tooltipText: this.l10n.getConstant('Contrast'), align: 'Center' });
2939
+ }
2940
+ if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Hue') > -1)) {
2941
+ toolbarItems.push({ id: this.element.id + '_hue', prefixIcon: 'e-icons e-fade', cssClass: 'top-icon e-fade',
2942
+ tooltipText: this.l10n.getConstant('Hue'), align: 'Center' });
2943
+ }
2944
+ if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Saturation') > -1)) {
2945
+ toolbarItems.push({ id: this.element.id + '_saturation', prefixIcon: 'e-icons e-saturation', cssClass: 'top-icon e-saturation',
2946
+ tooltipText: this.l10n.getConstant('Saturation'), align: 'Center' });
2947
+ }
2948
+ if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Exposure') > -1)) {
2949
+ toolbarItems.push({ id: this.element.id + '_exposure', prefixIcon: 'e-icons e-grain', cssClass: 'top-icon e-grain',
2950
+ tooltipText: this.l10n.getConstant('Exposure'), align: 'Center' });
1913
2951
  }
2952
+ if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Opacity') > -1)) {
2953
+ toolbarItems.push({ id: this.element.id + '_opacity', prefixIcon: 'e-icons e-opacity', cssClass: 'top-icon e-opacity',
2954
+ tooltipText: this.l10n.getConstant('Opacity'), align: 'Center' });
2955
+ }
2956
+ if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Blur') > -1)) {
2957
+ toolbarItems.push({ id: this.element.id + '_blur', prefixIcon: 'e-icons e-tint', cssClass: 'top-icon e-tint',
2958
+ tooltipText: this.l10n.getConstant('Blur'), align: 'Center' });
2959
+ }
2960
+ var tempToolbarItems = this.processToolbar('center');
2961
+ for (var i = 0, len = tempToolbarItems.length; i < len; i++) {
2962
+ toolbarItems.push(tempToolbarItems[i]);
2963
+ }
2964
+ if (!Browser.isDevice) {
2965
+ toolbarItems.push({ id: this.element.id + '_ok', prefixIcon: 'e-icons e-check', cssClass: 'top-icon e-tick',
2966
+ tooltipText: this.l10n.getConstant('OK'), align: 'Right' });
2967
+ toolbarItems.push({ id: this.element.id + '_cancel', prefixIcon: 'e-icons e-close', cssClass: 'top-icon e-save',
2968
+ tooltipText: this.l10n.getConstant('Cancel'), align: 'Right' });
2969
+ }
2970
+ return toolbarItems;
2971
+ };
2972
+ ImageEditor.prototype.getFilterToolbarItem = function () {
2973
+ var toolbarItems = [];
2974
+ if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Default') > -1)) {
2975
+ toolbarItems.push({ id: this.element.id + '_default', prefixIcon: 'e-icons e-none', cssClass: 'top-icon e-none',
2976
+ tooltipText: this.l10n.getConstant('Default'), align: 'Center',
2977
+ 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>' });
2978
+ }
2979
+ if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Chrome') > -1)) {
2980
+ toolbarItems.push({ id: this.element.id + '_chrome', prefixIcon: 'e-icons e-none', cssClass: 'top-icon e-none',
2981
+ tooltipText: this.l10n.getConstant('Chrome'), align: 'Center',
2982
+ 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>' });
2983
+ }
2984
+ if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Cold') > -1)) {
2985
+ toolbarItems.push({ id: this.element.id + '_cold', prefixIcon: 'e-icons e-none', cssClass: 'top-icon e-none',
2986
+ tooltipText: this.l10n.getConstant('Cold'), align: 'Center',
2987
+ 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>' });
2988
+ }
2989
+ if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Warm') > -1)) {
2990
+ toolbarItems.push({ id: this.element.id + '_warm', prefixIcon: 'e-icons e-none', cssClass: 'top-icon e-none',
2991
+ tooltipText: this.l10n.getConstant('Warm'), align: 'Center',
2992
+ 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>' });
2993
+ }
2994
+ if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Grayscale') > -1)) {
2995
+ toolbarItems.push({ id: this.element.id + '_grayscale', prefixIcon: 'e-icons e-none', cssClass: 'top-icon e-none',
2996
+ tooltipText: this.l10n.getConstant('Grayscale'), align: 'Center',
2997
+ 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>' });
2998
+ }
2999
+ if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Sepia') > -1)) {
3000
+ toolbarItems.push({ id: this.element.id + '_sepia', prefixIcon: 'e-icons e-none', cssClass: 'top-icon e-none',
3001
+ tooltipText: this.l10n.getConstant('Sepia'), align: 'Center',
3002
+ 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>' });
3003
+ }
3004
+ if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Invert') > -1)) {
3005
+ toolbarItems.push({ id: this.element.id + '_invert', prefixIcon: 'e-icons e-none', cssClass: 'top-icon e-none',
3006
+ tooltipText: this.l10n.getConstant('Invert'), align: 'Center',
3007
+ 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>' });
3008
+ }
3009
+ var tempToolbarItems = this.processToolbar('center');
3010
+ for (var i = 0, len = tempToolbarItems.length; i < len; i++) {
3011
+ toolbarItems.push(tempToolbarItems[i]);
3012
+ }
3013
+ return toolbarItems;
1914
3014
  };
1915
3015
  ImageEditor.prototype.getPenToolbarItem = function (items) {
1916
3016
  var toolbarItems = [];
@@ -2031,7 +3131,12 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
2031
3131
  if (items.indexOf('strokeWidth') > -1) {
2032
3132
  var strokeWidthBtn = document.getElementById(this.element.id + '_penStrokeWidth');
2033
3133
  var spanElem_3 = document.createElement('span');
2034
- spanElem_3.innerHTML = this.l10n.getConstant('Small');
3134
+ if (isNullOrUndefined(this.penStrokeWidth)) {
3135
+ spanElem_3.innerHTML = this.l10n.getConstant('Small');
3136
+ }
3137
+ else {
3138
+ spanElem_3.innerHTML = this.getPenStroke(this.penStrokeWidth, this.calcRatio());
3139
+ }
2035
3140
  spanElem_3.className = 'e-pen-stroke-width';
2036
3141
  strokeWidthBtn.appendChild(spanElem_3);
2037
3142
  var drpDownBtn_2 = new DropDownButton({ items: strokeWidthItems,
@@ -2049,15 +3154,15 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
2049
3154
  if (Browser.isDevice) {
2050
3155
  if (!isNullOrUndefined(document.getElementById(_this.element.id + '_bottomToolbar'))) {
2051
3156
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
2052
- var toolbar_7 = getComponent(_this.element.id + '_bottomToolbar', 'toolbar');
2053
- toolbar_7.refreshOverflow();
3157
+ var toolbar_8 = getComponent(_this.element.id + '_bottomToolbar', 'toolbar');
3158
+ toolbar_8.refreshOverflow();
2054
3159
  }
2055
3160
  }
2056
3161
  else {
2057
3162
  if (!isNullOrUndefined(document.getElementById(_this.element.id + '_toolbar'))) {
2058
3163
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
2059
- var toolbar_8 = getComponent(_this.element.id + '_toolbar', 'toolbar');
2060
- toolbar_8.refreshOverflow();
3164
+ var toolbar_9 = getComponent(_this.element.id + '_toolbar', 'toolbar');
3165
+ toolbar_9.refreshOverflow();
2061
3166
  }
2062
3167
  }
2063
3168
  }
@@ -2085,6 +3190,159 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
2085
3190
  break;
2086
3191
  }
2087
3192
  };
3193
+ ImageEditor.prototype.getPenStroke = function (value, ratio) {
3194
+ var textContent = '';
3195
+ if (Math.round(value / 0.4) === Math.round(ratio.width + ratio.height)) {
3196
+ textContent = this.l10n.getConstant('XSmall');
3197
+ }
3198
+ else if (Math.round(value / 0.8) === Math.round(ratio.width + ratio.height)) {
3199
+ textContent = this.l10n.getConstant('Small');
3200
+ }
3201
+ else if (Math.round(value / 1.2) === Math.round(ratio.width + ratio.height)) {
3202
+ textContent = this.l10n.getConstant('Medium');
3203
+ }
3204
+ else if (Math.round(value / 1.6) === Math.round(ratio.width + ratio.height)) {
3205
+ textContent = this.l10n.getConstant('Large');
3206
+ }
3207
+ else if (Math.round(value / 2) === Math.round(ratio.width + ratio.height)) {
3208
+ textContent = this.l10n.getConstant('XLarge');
3209
+ }
3210
+ return textContent;
3211
+ };
3212
+ ImageEditor.prototype.initAdjustmentToolbarItem = function () {
3213
+ var _this = this;
3214
+ var leftItem = this.getLeftToolbarItem();
3215
+ var rightItem = this.getRightToolbarItem();
3216
+ var mainItem = this.getAdjustmentToolbarItem();
3217
+ var zoomItem = this.getZoomToolbarItem();
3218
+ if (Browser.isDevice) {
3219
+ this.defToolbarItems = mainItem;
3220
+ }
3221
+ else {
3222
+ this.defToolbarItems = leftItem.concat(zoomItem, mainItem, rightItem);
3223
+ }
3224
+ var toolbar = new Toolbar({
3225
+ width: '100%',
3226
+ items: this.defToolbarItems,
3227
+ clicked: this.defToolbarClicked.bind(this),
3228
+ created: function () {
3229
+ if (!Browser.isDevice) {
3230
+ _this.renderSaveBtn();
3231
+ }
3232
+ if (Browser.isDevice) {
3233
+ if (_this.defToolbarItems.length > 0 && (!isNullOrUndefined(document.getElementById(_this.element.id + '_toolbar')))) {
3234
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
3235
+ toolbar.refreshOverflow();
3236
+ }
3237
+ }
3238
+ else {
3239
+ _this.createLeftToolbarControls();
3240
+ if (_this.defToolbarItems.length > 0 && (!isNullOrUndefined(document.getElementById(_this.element.id + '_toolbar')))) {
3241
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
3242
+ toolbar.refreshOverflow();
3243
+ }
3244
+ }
3245
+ }
3246
+ });
3247
+ if (Browser.isDevice) {
3248
+ toolbar.appendTo('#' + this.element.id + '_bottomToolbar');
3249
+ }
3250
+ else {
3251
+ toolbar.appendTo('#' + this.element.id + '_toolbar');
3252
+ }
3253
+ };
3254
+ ImageEditor.prototype.initFilterToolbarItem = function () {
3255
+ var _this = this;
3256
+ var mainItem = this.getFilterToolbarItem();
3257
+ if (!isNullOrUndefined(document.querySelector('#' + this.element.id + '_contextualToolbar')) &&
3258
+ document.querySelector('#' + this.element.id + '_contextualToolbar').classList.contains('e-control')) {
3259
+ getComponent(document.getElementById(this.element.id + '_contextualToolbar'), 'toolbar').destroy();
3260
+ }
3261
+ var toolbar = new Toolbar({
3262
+ width: '100%',
3263
+ items: mainItem,
3264
+ clicked: this.contextualToolbarClicked.bind(this),
3265
+ created: function () {
3266
+ _this.createCanvasFilter();
3267
+ if (_this.currentFilter === '') {
3268
+ _this.currentFilter = _this.element.id + '_default';
3269
+ }
3270
+ var hdrWrapper = document.querySelector('#' + _this.element.id + '_headWrapper');
3271
+ if (hdrWrapper) {
3272
+ hdrWrapper.style.display = 'none';
3273
+ }
3274
+ document.getElementById(_this.currentFilter + 'Canvas').parentElement.parentElement.classList.add('e-selected');
3275
+ toolbar.refreshOverflow();
3276
+ }
3277
+ });
3278
+ toolbar.appendTo('#' + this.element.id + '_contextualToolbar');
3279
+ };
3280
+ ImageEditor.prototype.createCanvasFilter = function () {
3281
+ if (this.adjustmentLevel.sharpen || this.adjustmentLevel.bw) {
3282
+ this.inMemoryContext.clearRect(0, 0, this.inMemoryCanvas.width, this.inMemoryCanvas.height);
3283
+ this.inMemoryCanvas.width = this.tempImageData.width;
3284
+ this.inMemoryCanvas.height = this.tempImageData.height;
3285
+ this.inMemoryContext.putImageData(this.tempImageData, 0, 0);
3286
+ }
3287
+ var noFilter = document.querySelector('#' + this.element.id + '_defaultCanvas');
3288
+ noFilter.style.width = '100px';
3289
+ noFilter.style.height = '100px';
3290
+ noFilter.style.filter = this.updateAdjustment('default', null, true);
3291
+ var ctx = noFilter.getContext('2d');
3292
+ ctx.drawImage(this.inMemoryCanvas, 0, 0, 300, 150);
3293
+ var chrome = document.querySelector('#' + this.element.id + '_chromeCanvas');
3294
+ chrome.style.width = '100px';
3295
+ chrome.style.height = '100px';
3296
+ chrome.style.filter = this.updateAdjustment('chrome', null, true);
3297
+ ctx = chrome.getContext('2d');
3298
+ ctx.drawImage(this.inMemoryCanvas, 0, 0, 300, 150);
3299
+ var cold = document.querySelector('#' + this.element.id + '_coldCanvas');
3300
+ cold.style.width = '100px';
3301
+ cold.style.height = '100px';
3302
+ cold.style.filter = this.updateAdjustment('cold', null, true);
3303
+ ctx = cold.getContext('2d');
3304
+ ctx.drawImage(this.inMemoryCanvas, 0, 0, 300, 150);
3305
+ var warm = document.querySelector('#' + this.element.id + '_warmCanvas');
3306
+ warm.style.width = '100px';
3307
+ warm.style.height = '100px';
3308
+ warm.style.filter = this.updateAdjustment('warm', null, true);
3309
+ ctx = warm.getContext('2d');
3310
+ ctx.drawImage(this.inMemoryCanvas, 0, 0, 300, 150);
3311
+ var temp = this.lowerContext.filter;
3312
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
3313
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
3314
+ for (var i = 0; i < this.objColl.length; i++) {
3315
+ this.apply(this.objColl[i].shape, this.objColl[i]);
3316
+ this.refreshActiveObj();
3317
+ }
3318
+ this.lowerContext.filter = temp;
3319
+ var grayscale = document.querySelector('#' + this.element.id + '_grayscaleCanvas');
3320
+ grayscale.style.width = '100px';
3321
+ grayscale.style.height = '100px';
3322
+ grayscale.style.filter = this.updateAdjustment('grayscale', null, true);
3323
+ ctx = grayscale.getContext('2d');
3324
+ ctx.drawImage(this.inMemoryCanvas, 0, 0, 300, 150);
3325
+ var tempFilter = this.lowerContext.filter;
3326
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
3327
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
3328
+ for (var i = 0; i < this.objColl.length; i++) {
3329
+ this.apply(this.objColl[i].shape, this.objColl[i]);
3330
+ this.refreshActiveObj();
3331
+ }
3332
+ this.lowerContext.filter = tempFilter;
3333
+ var sepia = document.querySelector('#' + this.element.id + '_sepiaCanvas');
3334
+ sepia.style.width = '100px';
3335
+ sepia.style.height = '100px';
3336
+ sepia.style.filter = this.updateAdjustment('sepia', null, true);
3337
+ ctx = sepia.getContext('2d');
3338
+ ctx.drawImage(this.inMemoryCanvas, 0, 0, 300, 150);
3339
+ var invert = document.querySelector('#' + this.element.id + '_invertCanvas');
3340
+ invert.style.width = '100px';
3341
+ invert.style.height = '100px';
3342
+ invert.style.filter = this.updateAdjustment('invert', null, true);
3343
+ ctx = invert.getContext('2d');
3344
+ ctx.drawImage(this.inMemoryCanvas, 0, 0, 300, 150);
3345
+ };
2088
3346
  ImageEditor.prototype.updateCanvas = function () {
2089
3347
  this.lastX = this.baseImg.width / 2;
2090
3348
  this.lastY = this.baseImg.height / 2;
@@ -2103,9 +3361,10 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
2103
3361
  maxDimension.width -= toolbarHeight;
2104
3362
  maxDimension.height -= toolbarHeight;
2105
3363
  }
3364
+ var tempFilter = this.lowerContext.filter;
2106
3365
  this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
2107
- this.lowerCanvas.width = this.upperCanvas.width = this.inMemoryCanvas.width = this.baseImg.width;
2108
- this.lowerCanvas.height = this.upperCanvas.height = this.inMemoryCanvas.height = this.baseImg.height;
3366
+ this.lowerCanvas.width = this.upperCanvas.width = this.baseImg.width;
3367
+ this.lowerCanvas.height = this.upperCanvas.height = this.baseImg.height;
2109
3368
  this.lowerCanvas.style.maxWidth = this.upperCanvas.style.maxWidth = maxDimension.width + 'px';
2110
3369
  this.lowerCanvas.style.maxHeight = this.upperCanvas.style.maxHeight = maxDimension.height + 'px';
2111
3370
  this.lowerCanvas.style.left = this.upperCanvas.style.left = (wrapperWidth - maxDimension.width) / 2 + 1 + 'px';
@@ -2115,16 +3374,37 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
2115
3374
  if (canvasWrapper) {
2116
3375
  this.lowerCanvas.style.top = this.upperCanvas.style.top = (parseFloat(canvasWrapper.style.height) - maxDimension.height - 1) / 2 + 'px';
2117
3376
  }
2118
- this.lowerContext.drawImage(this.baseImg, 0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
2119
- this.updateInMemoryCanvas('updateCanvas');
3377
+ this.lowerContext.filter = tempFilter;
3378
+ if (this.lowerContext.filter === 'none' || this.lowerContext.filter === 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
3379
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)' ||
3380
+ this.isInitialLoading) {
3381
+ this.lowerContext.drawImage(this.baseImg, 0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
3382
+ this.updateInMemoryCanvas('updateCanvas');
3383
+ if (this.canvasFilter !== 'none') {
3384
+ this.lowerContext.filter = this.canvasFilter;
3385
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
3386
+ this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
3387
+ }
3388
+ if (this.isInitialLoading) {
3389
+ this.initializeFilter();
3390
+ this.isInitialLoading = false;
3391
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
3392
+ this.lowerContext.drawImage(this.baseImg, 0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
3393
+ }
3394
+ }
3395
+ else {
3396
+ var temp = this.lowerContext.filter;
3397
+ this.updateBrightnessFilter();
3398
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
3399
+ this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
3400
+ this.lowerContext.filter = temp;
3401
+ }
3402
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
3403
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
2120
3404
  for (var i = 0, len = this.objColl.length; i < len; i++) {
2121
3405
  this.apply(this.objColl[i].shape, this.objColl[i]);
2122
3406
  }
2123
- if (this.isUndoRedo) {
2124
- if (this.flipState !== '') {
2125
- this.flip(this.flipState);
2126
- }
2127
- }
3407
+ this.lowerContext.filter = tempFilter;
2128
3408
  if (this.disabled) {
2129
3409
  this.element.setAttribute('class', 'e-disabled');
2130
3410
  }
@@ -2134,7 +3414,7 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
2134
3414
  var _this = this;
2135
3415
  // eslint-disable-next-line @typescript-eslint/no-this-alias
2136
3416
  var proxy = this;
2137
- proxy.baseImg.src = proxy.baseImgSrc = src;
3417
+ proxy.baseImg.src = proxy.baseImgSrc.id = src;
2138
3418
  this.baseImg.onload = function () {
2139
3419
  _this.lowerContext.drawImage(_this.baseImg, 0, 0, _this.lowerCanvas.width, _this.lowerCanvas.height);
2140
3420
  if (_this.togglePen) {
@@ -2155,7 +3435,6 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
2155
3435
  hideSpinner(_this.element);
2156
3436
  _this.element.style.opacity = '1';
2157
3437
  _this.updateCanvas();
2158
- _this.isUndoRedo = false;
2159
3438
  }
2160
3439
  if (Browser.isDevice) {
2161
3440
  if (_this.isToolbar() && (!isNullOrUndefined(document.getElementById(_this.element.id + '_toolbar'))) &&
@@ -2332,9 +3611,6 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
2332
3611
  this.degree = 0;
2333
3612
  }
2334
3613
  };
2335
- ImageEditor.prototype.updateUndoRedoColl = function (operation, value, previousObj, currentObj) {
2336
- this.undoRedoColl.push({ operation: operation, value: value, previousObj: previousObj, currentObj: currentObj });
2337
- };
2338
3614
  ImageEditor.prototype.fileSelect = function (inputElement, args) {
2339
3615
  showSpinner(this.element);
2340
3616
  this.element.style.opacity = '0.5';
@@ -2493,7 +3769,7 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
2493
3769
  }
2494
3770
  if (strokeWidthElem) {
2495
3771
  var strokeWidth = Math.round((this.activeObj.strokeSettings.strokeWidth /
2496
- (ratio.width + ratio.height))).toString();
3772
+ (ratio.width + ratio.height)) * this.factor).toString();
2497
3773
  strokeWidthElem.textContent = this.getStrokeWidth(strokeWidth);
2498
3774
  }
2499
3775
  };
@@ -2505,10 +3781,32 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
2505
3781
  }
2506
3782
  }
2507
3783
  };
3784
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
3785
+ ImageEditor.prototype.targetTouches = function (touches) {
3786
+ var p1 = { x: touches[0].pageX, y: touches[0].pageY };
3787
+ var p2 = { x: touches[1].pageX, y: touches[1].pageY };
3788
+ var points = [p1, p2];
3789
+ return points;
3790
+ };
3791
+ ImageEditor.prototype.calculateScale = function (startTouches, endTouches) {
3792
+ var startDistance = this.getDistance(startTouches[0], startTouches[1]);
3793
+ var endDistance = this.getDistance(endTouches[0], endTouches[1]);
3794
+ return endDistance / startDistance;
3795
+ };
3796
+ ImageEditor.prototype.getDistance = function (a, b) {
3797
+ var x = a.x - b.x;
3798
+ var y = a.y - b.y;
3799
+ return Math.sqrt(x * x + y * y);
3800
+ };
2508
3801
  ImageEditor.prototype.touchStartHandler = function (e) {
2509
3802
  e.preventDefault();
2510
- this.timer = setTimeout(this.setTimer.bind(this), 1000, e);
2511
- this.mouseDownEventHandler(e);
3803
+ if (e.touches.length === 2) {
3804
+ this.isFirstMove = true;
3805
+ }
3806
+ else {
3807
+ this.timer = setTimeout(this.setTimer.bind(this), 1000, e);
3808
+ this.mouseDownEventHandler(e);
3809
+ }
2512
3810
  EventHandler.add(this.lowerCanvas, 'touchend', this.mouseUpEventHandler, this);
2513
3811
  EventHandler.add(this.lowerCanvas, 'touchmove', this.mouseMoveEventHandler, this); // Unbind mousedown to prevent double triggers from touch devices
2514
3812
  EventHandler.add(this.upperCanvas, 'touchend', this.mouseUpEventHandler, this);
@@ -2535,6 +3833,14 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
2535
3833
  this.touchEndPoint.y = y = e.touches[0].clientY;
2536
3834
  }
2537
3835
  this.redrawActObj(x, y);
3836
+ if ((!isNullOrUndefined(this.element.querySelector('#' + this.element.id + '_contextualToolbar')) &&
3837
+ !this.element.querySelector('#' + this.element.id + '_contextualToolbar').parentElement.classList.contains('e-hide')) ||
3838
+ (!isNullOrUndefined(this.element.querySelector('#' + this.element.id + '_headWrapper'))
3839
+ && !this.element.querySelector('#' + this.element.id + '_headWrapper').parentElement.classList.contains('e-hide'))) {
3840
+ this.element.querySelector('.e-contextual-toolbar-wrapper').classList.add('e-hide');
3841
+ this.okBtn();
3842
+ this.refreshToolbar('main');
3843
+ }
2538
3844
  if (this.upperCanvas.style.cursor === 'crosshair' || (Browser.isDevice && this.togglePen)) {
2539
3845
  if (this.togglePen) {
2540
3846
  this.canvasRatio = this.calcRatio();
@@ -2598,6 +3904,47 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
2598
3904
  };
2599
3905
  ImageEditor.prototype.mouseMoveEventHandler = function (e) {
2600
3906
  e.preventDefault();
3907
+ if (e.type === 'touchmove' && e.touches.length === 2) {
3908
+ if (this.isFirstMove) {
3909
+ this.startTouches = this.targetTouches(e.touches);
3910
+ this.tempTouches = [];
3911
+ this.tempTouches.push({ x: e.touches[0].clientX || (e.touches[0].pageX - this.lowerCanvas.offsetLeft),
3912
+ y: e.touches[0].clientY || (e.touches[0].pageY - this.lowerCanvas.offsetTop) });
3913
+ this.tempTouches.push({ x: e.touches[1].clientX || (e.touches[1].pageX - this.lowerCanvas.offsetLeft),
3914
+ y: e.touches[1].clientY || (e.touches[1].pageY - this.lowerCanvas.offsetTop) });
3915
+ }
3916
+ else {
3917
+ var ratio = this.calcRatio();
3918
+ var firstFingerX = e.touches[0].clientX || (e.touches[0].pageX - this.lowerCanvas.offsetLeft);
3919
+ var firstFingerY = e.touches[0].clientY || (e.touches[0].pageY - this.lowerCanvas.offsetTop);
3920
+ var secondFingerX = e.touches[1].clientX || (e.touches[1].pageX - this.lowerCanvas.offsetLeft);
3921
+ var secondFingerY = e.touches[1].clientY || (e.touches[1].pageY - this.lowerCanvas.offsetTop);
3922
+ this.lastX = firstFingerX > secondFingerX ? secondFingerX + (firstFingerX - secondFingerX) : firstFingerX +
3923
+ (secondFingerX - firstFingerX);
3924
+ this.lastY = firstFingerY > secondFingerY ? secondFingerY + (firstFingerY - secondFingerY) : firstFingerY +
3925
+ (secondFingerY - firstFingerY);
3926
+ this.lastX *= ratio.width;
3927
+ this.lastY *= ratio.height;
3928
+ var scale = this.calculateScale(this.startTouches, this.targetTouches(e.touches));
3929
+ // Need to set lastX and lastY points
3930
+ if (this.tempTouches[0].x !== firstFingerX && this.tempTouches[0].y !== firstFingerY &&
3931
+ this.tempTouches[1].x !== secondFingerX && this.tempTouches[1].y !== secondFingerY) {
3932
+ if (scale > 1) {
3933
+ this.zoom(1.1);
3934
+ }
3935
+ else {
3936
+ this.zoom(-1.1);
3937
+ }
3938
+ this.tempTouches = [];
3939
+ this.tempTouches.push({ x: e.touches[0].clientX || (e.touches[0].pageX - this.lowerCanvas.offsetLeft),
3940
+ y: e.touches[0].clientY || (e.touches[0].pageY - this.lowerCanvas.offsetTop) });
3941
+ this.tempTouches.push({ x: e.touches[1].clientX || (e.touches[1].pageX - this.lowerCanvas.offsetLeft),
3942
+ y: e.touches[1].clientY || (e.touches[1].pageY - this.lowerCanvas.offsetTop) });
3943
+ }
3944
+ }
3945
+ this.isFirstMove = false;
3946
+ return;
3947
+ }
2601
3948
  if (this.textBox.style.display === 'none') {
2602
3949
  this.isTimer = true;
2603
3950
  }
@@ -2616,6 +3963,11 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
2616
3963
  !this.dragCanvas || this.activeObj.activePoint !== undefined) {
2617
3964
  if (this.dragElement === '') {
2618
3965
  this.setCursor(x, y);
3966
+ if (this.activeObj.activePoint.width === 0 && this.upperCanvas.style.cursor !== 'default' &&
3967
+ this.upperCanvas.style.cursor !== 'move' && this.upperCanvas.style.cursor !== 'crosshair'
3968
+ && this.upperCanvas.style.cursor !== 'grab') {
3969
+ this.upperCanvas.style.cursor = 'move';
3970
+ }
2619
3971
  this.findTarget(x, y, e.type);
2620
3972
  }
2621
3973
  }
@@ -2638,6 +3990,8 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
2638
3990
  y = this.touchEndPoint.y;
2639
3991
  }
2640
3992
  if (e.type === 'touchend') {
3993
+ this.startTouches = this.tempTouches = [];
3994
+ this.isFirstMove = false;
2641
3995
  if (this.textBox.style.display === 'none') {
2642
3996
  this.isTimer = false;
2643
3997
  this.timer = 0;
@@ -2656,8 +4010,16 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
2656
4010
  if (e.currentTarget === this.upperCanvas) {
2657
4011
  this.currObjType.shape = this.currObjType.shape.toLowerCase();
2658
4012
  if (!this.togglePen && !this.dragCanvas) {
4013
+ if (!isNullOrUndefined(this.tempObjColl) && this.activeObj.activePoint.width !== 0) {
4014
+ this.objColl.push(this.activeObj);
4015
+ this.redrawShape(this.objColl[this.objColl.length - 1]);
4016
+ this.tempObjColl = undefined;
4017
+ }
2659
4018
  this.applyCurrActObj(x, y);
2660
4019
  }
4020
+ else if (this.dragCanvas) {
4021
+ this.setPanPoints();
4022
+ }
2661
4023
  }
2662
4024
  if (this.togglePen && e.currentTarget === this.upperCanvas) {
2663
4025
  this.penDrawColl.push({ strokeWidth: this.penStrokeWidth, strokeColor: this.activeObj.strokeSettings.strokeColor, points: this.imageEditorPointsColl });
@@ -2686,11 +4048,13 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
2686
4048
  e.stopImmediatePropagation();
2687
4049
  break;
2688
4050
  case 'Delete':
2689
- shapeChangingArgs = { action: 'delete', previousShapeSettings: this.activeObj, currentShapeSettings: null };
2690
- this.keyHistory = '';
2691
- this.clearSelection();
2692
- this.trigger('shapeChanging', shapeChangingArgs);
2693
- this.refreshToolbar('main');
4051
+ if (this.textBox.style.display === 'none') {
4052
+ shapeChangingArgs = { action: 'delete', previousShapeSettings: this.activeObj, currentShapeSettings: null };
4053
+ this.keyHistory = '';
4054
+ this.clearSelection();
4055
+ this.trigger('shapeChanging', shapeChangingArgs);
4056
+ this.refreshToolbar('main');
4057
+ }
2694
4058
  break;
2695
4059
  case 'Escape':
2696
4060
  if (this.togglePan) {
@@ -2712,7 +4076,10 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
2712
4076
  }
2713
4077
  };
2714
4078
  ImageEditor.prototype.keyUpEventHandler = function (e) {
2715
- setTimeout(this.textKeyDown.bind(this), 1, e);
4079
+ // eslint-disable-next-line
4080
+ if (this.textBox.style.display === 'block' && e.target.id === this.element.id + '_textBox') {
4081
+ setTimeout(this.textKeyDown.bind(this), 1, e);
4082
+ }
2716
4083
  };
2717
4084
  ImageEditor.prototype.canvasMouseDownHandler = function (e) {
2718
4085
  e.preventDefault();
@@ -2730,7 +4097,6 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
2730
4097
  if (this.dragCanvas || this.factor !== 1) {
2731
4098
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
2732
4099
  this.dragStart = this.lowerContext.transformedPoint(this.lastX, this.lastY);
2733
- this.dragged = false;
2734
4100
  }
2735
4101
  };
2736
4102
  ImageEditor.prototype.canvasMouseMoveHandler = function (e) {
@@ -2752,55 +4118,39 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
2752
4118
  }
2753
4119
  this.lastX *= ratio.width;
2754
4120
  this.lastY *= ratio.height;
2755
- this.dragged = true;
2756
4121
  if (this.dragStart && this.dragCanvas) {
2757
- /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
2758
- var pt = this.lowerContext.transformedPoint(this.lastX, this.lastY);
2759
- var transitionArgs = { startPoint: { x: this.dragStart.x, y: this.dragStart.y },
2760
- endPoint: { x: pt.x, y: pt.y } };
2761
- this.trigger('panning', transitionArgs);
2762
- var xDiff = pt.x - this.dragStart.x;
2763
- var yDiff = pt.y - this.dragStart.y;
2764
- var xxDiff = xDiff;
2765
- var yyDiff = yDiff;
2766
- this.lowerContext.translate(xDiff, yDiff);
2767
- this.upperContext.translate(xDiff, yDiff);
2768
- /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
2769
- var pt1 = this.lowerContext.transformedPoint(0, 0);
2770
- /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
2771
- var pt2 = this.lowerContext.transformedPoint(this.lowerCanvas.width, this.lowerCanvas.height);
2772
- if (xDiff >= 0) {
2773
- if (pt1.x < 1) {
2774
- xDiff = 0;
2775
- }
2776
- }
2777
- else {
2778
- if (pt2.x > this.lowerCanvas.width) {
2779
- xDiff = 0;
2780
- }
2781
- }
2782
- if (yDiff >= 0) {
2783
- if (pt1.y < 1) {
2784
- yDiff = 0;
2785
- }
2786
- }
2787
- else {
2788
- if (pt2.y > this.lowerCanvas.height) {
2789
- yDiff = 0;
2790
- }
2791
- }
2792
- this.lowerContext.translate(-xxDiff, -yyDiff);
2793
- this.upperContext.translate(-xxDiff, -yyDiff);
2794
- this.lowerContext.translate(xDiff, yDiff);
2795
- this.upperContext.translate(xDiff, yDiff);
2796
- this.redraw();
4122
+ this.drawPanImg();
2797
4123
  }
2798
4124
  };
2799
4125
  ImageEditor.prototype.canvasMouseUpHandler = function (e) {
2800
4126
  e.preventDefault();
4127
+ if (this.togglePan && e.currentTarget === this.lowerCanvas) {
4128
+ var ratio = this.calcRatio();
4129
+ if (e.type === 'mouseup') {
4130
+ this.lastX = e.offsetX || (e.pageX - this.lowerCanvas.offsetLeft);
4131
+ this.lastY = e.offsetY || (e.pageY - this.lowerCanvas.offsetTop);
4132
+ }
4133
+ else {
4134
+ this.lastX = e.touches[0].clientX || (e.touches[0].pageX - this.lowerCanvas.offsetLeft);
4135
+ this.lastY = e.touches[0].clientY || (e.touches[0].pageY - this.lowerCanvas.offsetTop);
4136
+ }
4137
+ this.lastX *= ratio.width;
4138
+ this.lastY *= ratio.height;
4139
+ this.setPanPoints();
4140
+ }
2801
4141
  this.dragStart = null;
4142
+ // zooms on mouse click point
4143
+ // if (e.currentTarget !== document) {
4144
+ // this.zoom(e.shiftKey ? -1 : 1 );
4145
+ // }
2802
4146
  this.currObjType.isDragging = false;
2803
4147
  };
4148
+ ImageEditor.prototype.setPanPoints = function () {
4149
+ if (this.dragCanvas || this.factor !== 1) {
4150
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
4151
+ this.dragStart = this.lowerContext.transformedPoint(this.lastX, this.lastY);
4152
+ }
4153
+ };
2804
4154
  ImageEditor.prototype.textKeyDown = function (e) {
2805
4155
  if (String.fromCharCode(e.which) === '\r') {
2806
4156
  this.textRow += 1;
@@ -2819,6 +4169,8 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
2819
4169
  ImageEditor.prototype.adjustToScreen = function () {
2820
4170
  // eslint-disable-next-line @typescript-eslint/no-this-alias
2821
4171
  var proxy = this;
4172
+ var tempFilter = this.lowerContext.filter;
4173
+ this.okBtn();
2822
4174
  this.applyActObj();
2823
4175
  this.refreshActiveObj();
2824
4176
  if (this.imgDataColl.length > 0) {
@@ -2840,15 +4192,32 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
2840
4192
  canvasWrapper.style.height = (parseFloat(canvasWrapper.style.height) - this.toolbarHeight) - 3 + 'px';
2841
4193
  }
2842
4194
  }
2843
- this.redrawImg();
2844
- // eslint-disable-next-line @typescript-eslint/tslint/config
2845
- this.lowerCanvas.toBlob(function (blob) {
2846
- proxy.baseImg.src = URL.createObjectURL(blob);
2847
- }, 'image/png');
4195
+ this.redrawImg(tempFilter);
4196
+ if (!this.currObjType.isSave) {
4197
+ // eslint-disable-next-line @typescript-eslint/tslint/config
4198
+ this.lowerCanvas.toBlob(function (blob) {
4199
+ proxy.lowerContext.filter = proxy.initialAdjustmentValue = proxy.adjustmentValue = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
4200
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
4201
+ if (proxy.cssClass) {
4202
+ addClass([proxy.element], proxy.cssClass.split(' '));
4203
+ }
4204
+ proxy.lowerContext.clearRect(0, 0, proxy.lowerCanvas.width, proxy.lowerCanvas.height);
4205
+ proxy.lowerContext.drawImage(proxy.inMemoryCanvas, 0, 0);
4206
+ proxy.baseImg.src = URL.createObjectURL(blob);
4207
+ proxy.lowerContext.filter = tempFilter;
4208
+ }, 'image/png');
4209
+ }
4210
+ else {
4211
+ hideSpinner(this.element);
4212
+ this.element.style.opacity = '1';
4213
+ }
2848
4214
  if (this.defToolbarItems.length > 0 && (!isNullOrUndefined(document.getElementById(this.element.id + '_toolbar')))) {
2849
4215
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
2850
- var toolbar_9 = getComponent(proxy.element.id + '_toolbar', 'toolbar');
2851
- toolbar_9.refreshOverflow();
4216
+ var toolbar_10 = getComponent(proxy.element.id + '_toolbar', 'toolbar');
4217
+ toolbar_10.refreshOverflow();
4218
+ if (!isNullOrUndefined(this.element.querySelector('.e-contextual-toolbar-wrapper'))) {
4219
+ this.element.querySelector('.e-contextual-toolbar-wrapper').classList.add('e-hide');
4220
+ }
2852
4221
  }
2853
4222
  };
2854
4223
  ImageEditor.prototype.screenOrientation = function () {
@@ -2862,7 +4231,49 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
2862
4231
  this.adjustToScreen();
2863
4232
  }
2864
4233
  };
2865
- ImageEditor.prototype.redrawImg = function () {
4234
+ ImageEditor.prototype.drawPanImg = function () {
4235
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
4236
+ var pt = this.lowerContext.transformedPoint(this.lastX, this.lastY);
4237
+ var transitionArgs = { startPoint: { x: this.dragStart.x, y: this.dragStart.y },
4238
+ endPoint: { x: pt.x, y: pt.y } };
4239
+ this.trigger('panning', transitionArgs);
4240
+ var xDiff = pt.x - this.dragStart.x;
4241
+ var yDiff = pt.y - this.dragStart.y;
4242
+ var xxDiff = xDiff;
4243
+ var yyDiff = yDiff;
4244
+ this.lowerContext.translate(xDiff, yDiff);
4245
+ this.upperContext.translate(xDiff, yDiff);
4246
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
4247
+ var pt1 = this.lowerContext.transformedPoint(0, 0);
4248
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
4249
+ var pt2 = this.lowerContext.transformedPoint(this.lowerCanvas.width, this.lowerCanvas.height);
4250
+ if (xDiff >= 0) {
4251
+ if (pt1.x < 1) {
4252
+ xDiff = 0;
4253
+ }
4254
+ }
4255
+ else {
4256
+ if (pt2.x > this.lowerCanvas.width) {
4257
+ xDiff = 0;
4258
+ }
4259
+ }
4260
+ if (yDiff >= 0) {
4261
+ if (pt1.y < 1) {
4262
+ yDiff = 0;
4263
+ }
4264
+ }
4265
+ else {
4266
+ if (pt2.y > this.lowerCanvas.height) {
4267
+ yDiff = 0;
4268
+ }
4269
+ }
4270
+ this.lowerContext.translate(-xxDiff, -yyDiff);
4271
+ this.upperContext.translate(-xxDiff, -yyDiff);
4272
+ this.lowerContext.translate(xDiff, yDiff);
4273
+ this.upperContext.translate(xDiff, yDiff);
4274
+ this.redraw();
4275
+ };
4276
+ ImageEditor.prototype.redrawImg = function (tempFilter) {
2866
4277
  var wrapperWidth;
2867
4278
  var canvasWrapper = document.querySelector('#' + this.element.id + '_canvasWrapper');
2868
4279
  if (this.isScreenOriented) {
@@ -2878,7 +4289,17 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
2878
4289
  this.lowerCanvas.style.maxHeight = this.upperCanvas.style.maxHeight = maxDimension.height + 'px';
2879
4290
  this.lowerCanvas.style.left = this.upperCanvas.style.left = (wrapperWidth - maxDimension.width) / 2 + 1 + 'px';
2880
4291
  this.lowerCanvas.style.top = this.upperCanvas.style.top = (this.element.offsetHeight - this.toolbarHeight - maxDimension.height) / 2 + 1 + 'px';
4292
+ this.lowerContext.filter = tempFilter;
4293
+ var temp = this.lowerContext.filter;
4294
+ this.updateBrightnessFilter();
2881
4295
  this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
4296
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
4297
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
4298
+ for (var i = 0; i < this.objColl.length; i++) {
4299
+ this.apply(this.objColl[i].shape, this.objColl[i]);
4300
+ this.refreshActiveObj();
4301
+ }
4302
+ this.lowerContext.filter = temp;
2882
4303
  };
2883
4304
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
2884
4305
  ImageEditor.prototype.updateContext = function (ctx) {
@@ -2927,7 +4348,7 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
2927
4348
  var transform = ctx.transform;
2928
4349
  ctx.transform = function (a, b, c, d, e, f) {
2929
4350
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
2930
- var m2 = new DOMMatrix([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
4351
+ var m2 = new DOMMatrix();
2931
4352
  m2.a = a;
2932
4353
  m2.b = b;
2933
4354
  m2.c = c;
@@ -2955,6 +4376,7 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
2955
4376
  return pt.matrixTransform(xform.inverse());
2956
4377
  };
2957
4378
  };
4379
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
2958
4380
  ImageEditor.prototype.scaleNonUniform = function (xform, sx, sy) {
2959
4381
  xform.m11 *= sx;
2960
4382
  xform.m12 *= sx;
@@ -2991,11 +4413,7 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
2991
4413
  this.upperContext.setTransform(1, 0, 0, 1, 0, 0);
2992
4414
  this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
2993
4415
  this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
2994
- this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
2995
- for (var j = 0; j < this.objColl.length; j++) {
2996
- this.apply(this.objColl[j].shape, this.objColl[j]);
2997
- this.refreshActiveObj();
2998
- }
4416
+ this.redrawImgWithObj();
2999
4417
  }
3000
4418
  else {
3001
4419
  if (this.factor > 1) {
@@ -3058,11 +4476,7 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
3058
4476
  this.upperContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
3059
4477
  this.lowerContext.restore();
3060
4478
  this.upperContext.restore();
3061
- this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
3062
- for (var j = 0; j < this.objColl.length; j++) {
3063
- this.apply(this.objColl[j].shape, this.objColl[j]);
3064
- this.refreshActiveObj();
3065
- }
4479
+ this.redrawImgWithObj();
3066
4480
  };
3067
4481
  ImageEditor.prototype.applyCurrActObj = function (x, y) {
3068
4482
  var isInside = false;
@@ -3086,9 +4500,13 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
3086
4500
  }
3087
4501
  if (this.activeObj.shape === 'text' || (this.currObjType.shape === 'ellipse' || this.currObjType.shape === 'rectangle' ||
3088
4502
  this.currObjType.shape === 'line')) {
4503
+ var tempFilter = this.lowerContext.filter;
4504
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
4505
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
3089
4506
  for (var j = 0; j < this.objColl.length; j++) {
3090
4507
  this.apply(this.objColl[j].shape, this.objColl[j]);
3091
4508
  }
4509
+ this.lowerContext.filter = tempFilter;
3092
4510
  this.apply('shape');
3093
4511
  }
3094
4512
  }
@@ -3114,6 +4532,24 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
3114
4532
  this.setTextSelection(width, height);
3115
4533
  this.updateActiveObject(ratio, this.activeObj.activePoint, this.activeObj);
3116
4534
  };
4535
+ ImageEditor.prototype.setTextBoxStylesToActObj = function () {
4536
+ var ratio = this.calcRatio();
4537
+ this.activeObj.textSettings.fontFamily = this.textBox.style.fontFamily;
4538
+ this.activeObj.strokeSettings.strokeColor = this.textBox.style.color;
4539
+ if (this.textBox.style.fontWeight === 'bold') {
4540
+ this.activeObj.textSettings.bold = true;
4541
+ }
4542
+ else {
4543
+ this.activeObj.textSettings.bold = false;
4544
+ }
4545
+ if (this.textBox.style.fontStyle === 'italic') {
4546
+ this.activeObj.textSettings.italic = true;
4547
+ }
4548
+ else {
4549
+ this.activeObj.textSettings.italic = false;
4550
+ }
4551
+ this.activeObj.textSettings.fontSize = (parseFloat(this.textBox.style.fontSize) * ((ratio.width + ratio.height) / 2)) / this.factor;
4552
+ };
3117
4553
  ImageEditor.prototype.redrawActObj = function (x, y) {
3118
4554
  var ratio = this.calcRatio();
3119
4555
  var splitWords;
@@ -3123,21 +4559,7 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
3123
4559
  }
3124
4560
  if (this.activeObj.horTopLine !== undefined && (this.activeObj.shape !== undefined && splitWords[0] !== 'crop')) {
3125
4561
  if (this.textBox.style.display === 'block') {
3126
- this.activeObj.textSettings.fontFamily = this.textBox.style.fontFamily;
3127
- this.activeObj.strokeSettings.strokeColor = this.textBox.style.color;
3128
- if (this.textBox.style.fontWeight === 'bold') {
3129
- this.activeObj.textSettings.bold = true;
3130
- }
3131
- else {
3132
- this.activeObj.textSettings.bold = false;
3133
- }
3134
- if (this.textBox.style.fontStyle === 'italic') {
3135
- this.activeObj.textSettings.italic = true;
3136
- }
3137
- else {
3138
- this.activeObj.textSettings.italic = false;
3139
- }
3140
- this.activeObj.textSettings.fontSize = (parseFloat(this.textBox.style.fontSize) * ((ratio.width + ratio.height) / 2)) / this.factor;
4562
+ this.setTextBoxStylesToActObj();
3141
4563
  if (x && y) {
3142
4564
  x -= bbox.left;
3143
4565
  y -= bbox.top;
@@ -3599,10 +5021,7 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
3599
5021
  }
3600
5022
  }
3601
5023
  this.lowerContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
3602
- this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
3603
- for (var i = 0; i < this.objColl.length; i++) {
3604
- this.apply(this.objColl[i].shape, this.objColl[i]);
3605
- }
5024
+ this.redrawImgWithObj();
3606
5025
  this.activeObj = temp;
3607
5026
  this.updateFontStyles();
3608
5027
  if (this.factor === 1) {
@@ -4007,7 +5426,7 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
4007
5426
  else {
4008
5427
  diff = Math.max(this.diffPoint.x, this.diffPoint.y);
4009
5428
  }
4010
- percentage = diff / 10;
5429
+ percentage = (diff / 10) * this.factor;
4011
5430
  this.activeObj.activePoint.startX -= (maxDimension.width / 100) * percentage;
4012
5431
  this.activeObj.activePoint.startY -= (maxDimension.height / 100) * percentage;
4013
5432
  this.activeObj.activePoint.width = this.activeObj.activePoint.endX - this.activeObj.activePoint.startX;
@@ -4152,7 +5571,7 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
4152
5571
  else {
4153
5572
  diff = Math.max(this.diffPoint.x, this.diffPoint.y);
4154
5573
  }
4155
- percentage = diff / 10;
5574
+ percentage = (diff / 10) * this.factor;
4156
5575
  this.activeObj.activePoint.endX += (maxDimension.width / 100) * percentage;
4157
5576
  this.activeObj.activePoint.startY -= (maxDimension.height / 100) * percentage;
4158
5577
  this.activeObj.activePoint.width = this.activeObj.activePoint.endX - this.activeObj.activePoint.startX;
@@ -4348,7 +5767,7 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
4348
5767
  else {
4349
5768
  diff = Math.max(this.diffPoint.x, this.diffPoint.y);
4350
5769
  }
4351
- percentage = diff / 10;
5770
+ percentage = (diff / 10) * this.factor;
4352
5771
  this.activeObj.activePoint.startX -= (maxDimension.width / 100) * percentage;
4353
5772
  this.activeObj.activePoint.endY += (maxDimension.height / 100) * percentage;
4354
5773
  this.activeObj.activePoint.width = this.activeObj.activePoint.endX - this.activeObj.activePoint.startX;
@@ -4495,7 +5914,7 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
4495
5914
  else {
4496
5915
  diff = Math.min(this.diffPoint.x, this.diffPoint.y);
4497
5916
  }
4498
- percentage = diff / 10;
5917
+ percentage = (diff / 10) * this.factor;
4499
5918
  this.activeObj.activePoint.endX += (maxDimension.width / 50) * percentage;
4500
5919
  this.activeObj.activePoint.endY += (maxDimension.height / 50) * percentage;
4501
5920
  this.activeObj.activePoint.width = this.activeObj.activePoint.endX - this.activeObj.activePoint.startX;
@@ -4541,8 +5960,6 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
4541
5960
  width = this.activeObj.activePoint.endX - x;
4542
5961
  height = this.activeObj.activePoint.endY - y;
4543
5962
  scale = Math.min(width, height);
4544
- var ratio = this.activeObj.shape.split('-');
4545
- ratio = ratio[1].split(':');
4546
5963
  var newScale = this.getScaleRatio(scale);
4547
5964
  this.activeObj.activePoint.endX -= newScale.x;
4548
5965
  this.activeObj.activePoint.endY -= newScale.y;
@@ -5201,6 +6618,7 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
5201
6618
  this.refreshActiveObj();
5202
6619
  return;
5203
6620
  }
6621
+ this.tempObjColl = extend([], this.objColl, [], true);
5204
6622
  this.currObjType.isCustomCrop = false;
5205
6623
  var temp = this.activeObj = extend({}, this.objColl[i], {}, true);
5206
6624
  this.objColl.splice(i, 1);
@@ -5210,11 +6628,35 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
5210
6628
  this.inMemoryContext.putImageData(this.imgDataColl[0].value, 0, 0);
5211
6629
  }
5212
6630
  else {
6631
+ if ((this.adjustmentLevel.sharpen || this.adjustmentLevel.bw) && !this.sharpenedImgData) {
6632
+ var data = void 0;
6633
+ var tempImageData = this.currImgData;
6634
+ if (this.adjustmentLevel.sharpen) {
6635
+ data = this.getSharpenData(this.currImgData);
6636
+ }
6637
+ else {
6638
+ data = this.getBlackAndWhiteData(tempImageData);
6639
+ }
6640
+ this.currImgData = data;
6641
+ this.sharpenedImgData = true;
6642
+ }
5213
6643
  this.inMemoryCanvas.width = this.currImgData.width;
5214
6644
  this.inMemoryCanvas.height = this.currImgData.height;
5215
6645
  this.inMemoryContext.putImageData(this.currImgData, 0, 0);
5216
6646
  }
5217
6647
  if (this.flipState !== '') {
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
+ }
5218
6660
  this.inMemoryContext.clearRect(0, 0, this.inMemoryCanvas.width, this.inMemoryCanvas.height);
5219
6661
  this.inMemoryContext.clearRect(0, 0, this.inMemoryCanvas.height, this.inMemoryCanvas.width);
5220
6662
  this.inMemoryCanvas.width = this.currImgData.width;
@@ -5223,15 +6665,10 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
5223
6665
  }
5224
6666
  this.setActivePoint();
5225
6667
  this.upperContext.drawImage(this.inMemoryCanvas, 0, 0);
6668
+ this.lowerContext.filter = this.canvasFilter;
5226
6669
  this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
5227
- this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
6670
+ this.redrawImgWithObj();
5228
6671
  this.upperContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
5229
- for (var j = 0; j < this.objColl.length; j++) {
5230
- if (this.objColl[j].shape === 'text' && this.objColl[j].shapeFlip !== this.currFlipState) {
5231
- this.objColl[j].flippedText = true;
5232
- }
5233
- this.apply(this.objColl[j].shape, this.objColl[j]);
5234
- }
5235
6672
  this.activeObj = extend({}, temp, {}, true);
5236
6673
  var endPoint = { x: this.lowerCanvas.width - this.pannEnd.startX, y: this.lowerCanvas.height - this.pannEnd.startY };
5237
6674
  if (this.factor !== 1 && (this.activeObj.activePoint.startX < this.pannStart.startX || this.activeObj.activePoint.startY <
@@ -5614,7 +7051,7 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
5614
7051
  }
5615
7052
  else {
5616
7053
  if (this.currObjType.isCustomCrop) {
5617
- this.upperCanvas.style.cursor = 'cross-hair';
7054
+ this.upperCanvas.style.cursor = 'crosshair';
5618
7055
  }
5619
7056
  this.upperCanvas.style.cursor = 'default';
5620
7057
  }
@@ -5711,7 +7148,7 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
5711
7148
  }
5712
7149
  else {
5713
7150
  if (this.currObjType.isCustomCrop) {
5714
- this.upperCanvas.style.cursor = 'cross-hair';
7151
+ this.upperCanvas.style.cursor = 'crosshair';
5715
7152
  }
5716
7153
  this.upperCanvas.style.cursor = 'default';
5717
7154
  }
@@ -5771,7 +7208,7 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
5771
7208
  // eslint-disable-next-line @typescript-eslint/tslint/config
5772
7209
  this.lowerCanvas.toBlob(function (blob) {
5773
7210
  var blobUrl = URL.createObjectURL(blob);
5774
- proxy.baseImg.src = blobUrl;
7211
+ //proxy.baseImg.src = blobUrl;
5775
7212
  proxy.downloadImg(blobUrl, fileName + '.' + type);
5776
7213
  }, 'image/png');
5777
7214
  };
@@ -5821,21 +7258,6 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
5821
7258
  this.inMemoryContext.putImageData(imgData, 0, 0);
5822
7259
  }
5823
7260
  };
5824
- ImageEditor.prototype.drawBaseImg = function () {
5825
- this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
5826
- this.lowerContext.clearRect(0, 0, this.lowerCanvas.height, this.lowerCanvas.width);
5827
- this.inMemoryContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
5828
- this.inMemoryContext.clearRect(0, 0, this.lowerCanvas.height, this.lowerCanvas.width);
5829
- this.inMemoryCanvas.width = this.lowerCanvas.width = this.imgDataColl[0].value.width;
5830
- this.inMemoryCanvas.height = this.lowerCanvas.height = this.imgDataColl[0].value.height;
5831
- this.inMemoryContext.putImageData(this.imgDataColl[0].value, 0, 0);
5832
- var maxDimension = this.calcMaxDimension(this.inMemoryCanvas.width, this.inMemoryCanvas.height);
5833
- this.lowerCanvas.style.maxWidth = this.upperCanvas.style.maxWidth = maxDimension.width + 'px';
5834
- this.lowerCanvas.style.maxHeight = this.upperCanvas.style.maxHeight = maxDimension.height + 'px';
5835
- this.lowerCanvas.style.left = this.upperCanvas.style.left = (this.element.clientWidth - maxDimension.width) / 2 + 1 + 'px';
5836
- this.lowerCanvas.style.top = this.upperCanvas.style.top = (this.element.clientHeight - this.toolbarHeight - maxDimension.height) / 2 + 1 + 'px';
5837
- this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
5838
- };
5839
7261
  ImageEditor.prototype.calcPrevRatio = function () {
5840
7262
  var oldWidthRatio;
5841
7263
  var oldHeightRatio;
@@ -5942,15 +7364,23 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
5942
7364
  }
5943
7365
  else if (degree === 90 || degree === -90) {
5944
7366
  this.updateCurrentActiveObjPoint(degree);
7367
+ var tempFilter = this.lowerContext.filter;
7368
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
7369
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
5945
7370
  for (var i = 0; i < this.objColl.length; i++) {
5946
7371
  this.apply(this.objColl[i].shape, this.objColl[i]);
5947
7372
  }
7373
+ this.lowerContext.filter = tempFilter;
5948
7374
  }
5949
7375
  else {
5950
7376
  this.updateCurrentActiveObjPoint('zoom');
7377
+ var tempFilter = this.lowerContext.filter;
7378
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
7379
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
5951
7380
  for (var i = 0; i < this.objColl.length; i++) {
5952
7381
  this.apply(this.objColl[i].shape, this.objColl[i]);
5953
7382
  }
7383
+ this.lowerContext.filter = tempFilter;
5954
7384
  }
5955
7385
  }
5956
7386
  else if (this.objColl.length === 0 && (degree === 'horizontal' || degree === 'vertical' || degree === 'Horizontal' || degree === 'Vertical')) {
@@ -5998,12 +7428,14 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
5998
7428
  if (this.objColl[i].activePoint.startX <= this.lowerCanvas.width / 2) {
5999
7429
  this.objColl[i].activePoint.startX = this.lowerCanvas.width / 2 + ((this.lowerCanvas.width / 2) -
6000
7430
  this.objColl[i].activePoint.endX);
6001
- this.objColl[i].activePoint.endX = this.objColl[i].activePoint.startX + this.objColl[i].activePoint.width;
7431
+ this.objColl[i].activePoint.endX = this.objColl[i].activePoint.startX +
7432
+ this.objColl[i].activePoint.width;
6002
7433
  this.updateActiveObject(ratio, this.objColl[i].activePoint, this.objColl[i]);
6003
7434
  }
6004
7435
  else if (this.objColl[i].activePoint.startX >= this.lowerCanvas.width / 2) {
6005
7436
  this.objColl[i].activePoint.startX = this.lowerCanvas.width - this.objColl[i].activePoint.endX;
6006
- this.objColl[i].activePoint.endX = this.objColl[i].activePoint.startX + this.objColl[i].activePoint.width;
7437
+ this.objColl[i].activePoint.endX = this.objColl[i].activePoint.startX +
7438
+ this.objColl[i].activePoint.width;
6007
7439
  this.updateActiveObject(ratio, this.objColl[i].activePoint, this.objColl[i]);
6008
7440
  }
6009
7441
  }
@@ -6013,12 +7445,14 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6013
7445
  if (this.objColl[i].activePoint.startY <= this.lowerCanvas.height / 2) {
6014
7446
  this.objColl[i].activePoint.startY = this.lowerCanvas.height / 2 + ((this.lowerCanvas.height / 2) -
6015
7447
  this.objColl[i].activePoint.endY);
6016
- this.objColl[i].activePoint.endY = this.objColl[i].activePoint.startY + this.objColl[i].activePoint.height;
7448
+ this.objColl[i].activePoint.endY = this.objColl[i].activePoint.startY +
7449
+ this.objColl[i].activePoint.height;
6017
7450
  this.updateActiveObject(ratio, this.objColl[i].activePoint, this.objColl[i]);
6018
7451
  }
6019
7452
  else if (this.objColl[i].activePoint.startY >= this.lowerCanvas.height / 2) {
6020
7453
  this.objColl[i].activePoint.startY = this.lowerCanvas.height - this.objColl[i].activePoint.endY;
6021
- this.objColl[i].activePoint.endY = this.objColl[i].activePoint.startY + this.objColl[i].activePoint.height;
7454
+ this.objColl[i].activePoint.endY = this.objColl[i].activePoint.startY +
7455
+ this.objColl[i].activePoint.height;
6022
7456
  this.updateActiveObject(ratio, this.objColl[i].activePoint, this.objColl[i]);
6023
7457
  }
6024
7458
  }
@@ -6033,22 +7467,30 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6033
7467
  this.objColl[i].activePoint.startY /= oldRatio.height;
6034
7468
  this.objColl[i].activePoint.endX /= oldRatio.width;
6035
7469
  this.objColl[i].activePoint.endY /= oldRatio.height;
6036
- this.objColl[i].activePoint.height = this.objColl[i].activePoint.endX - this.objColl[i].activePoint.startX;
6037
- this.objColl[i].activePoint.width = this.objColl[i].activePoint.endY - this.objColl[i].activePoint.startY;
7470
+ this.objColl[i].activePoint.height = this.objColl[i].activePoint.endX -
7471
+ this.objColl[i].activePoint.startX;
7472
+ this.objColl[i].activePoint.width = this.objColl[i].activePoint.endY -
7473
+ this.objColl[i].activePoint.startY;
6038
7474
  this.objColl[i].strokeSettings.strokeWidth /= (oldRatio.width / this.factor);
6039
7475
  this.calcCurrPoints(degree, this.objColl[i]);
6040
- this.objColl[i].activePoint.endX = this.objColl[i].activePoint.startX + this.objColl[i].activePoint.width;
6041
- this.objColl[i].activePoint.endY = this.objColl[i].activePoint.startY + this.objColl[i].activePoint.height;
6042
- this.objColl[i].activePoint.width = this.objColl[i].activePoint.endX - this.objColl[i].activePoint.startX;
6043
- this.objColl[i].activePoint.height = this.objColl[i].activePoint.endY - this.objColl[i].activePoint.startY;
7476
+ this.objColl[i].activePoint.endX = this.objColl[i].activePoint.startX +
7477
+ this.objColl[i].activePoint.width;
7478
+ this.objColl[i].activePoint.endY = this.objColl[i].activePoint.startY +
7479
+ this.objColl[i].activePoint.height;
7480
+ this.objColl[i].activePoint.width = this.objColl[i].activePoint.endX -
7481
+ this.objColl[i].activePoint.startX;
7482
+ this.objColl[i].activePoint.height = this.objColl[i].activePoint.endY -
7483
+ this.objColl[i].activePoint.startY;
6044
7484
  }
6045
7485
  for (var i = 0; i < this.objColl.length; i++) {
6046
7486
  this.objColl[i].activePoint.startX *= oldRatio.width;
6047
7487
  this.objColl[i].activePoint.startY *= oldRatio.height;
6048
7488
  this.objColl[i].activePoint.endX *= oldRatio.width;
6049
7489
  this.objColl[i].activePoint.endY *= oldRatio.height;
6050
- this.objColl[i].activePoint.width = this.objColl[i].activePoint.endX - this.objColl[i].activePoint.startX;
6051
- this.objColl[i].activePoint.height = this.objColl[i].activePoint.endY - this.objColl[i].activePoint.startY;
7490
+ this.objColl[i].activePoint.width = this.objColl[i].activePoint.endX -
7491
+ this.objColl[i].activePoint.startX;
7492
+ this.objColl[i].activePoint.height = this.objColl[i].activePoint.endY -
7493
+ this.objColl[i].activePoint.startY;
6052
7494
  this.objColl[i].strokeSettings.strokeWidth *= ratio.width;
6053
7495
  }
6054
7496
  for (var i = 0; i < this.objColl.length; i++) {
@@ -6118,10 +7560,7 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6118
7560
  tempObjColl = [];
6119
7561
  this.refreshActiveObj();
6120
7562
  this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
6121
- this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
6122
- for (var i = 0; i < this.objColl.length; i++) {
6123
- this.apply(this.objColl[i].shape, this.objColl[i]);
6124
- }
7563
+ this.redrawImgWithObj();
6125
7564
  this.activeObj.flippedText = false;
6126
7565
  this.currObjType.shape = '';
6127
7566
  this.refreshActiveObj();
@@ -6139,17 +7578,27 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6139
7578
  showSpinner(proxy_1.element);
6140
7579
  proxy_1.element.style.opacity = '0.5';
6141
7580
  proxy_1.lowerContext.clearRect(0, 0, proxy_1.lowerCanvas.width, proxy_1.lowerCanvas.height);
7581
+ var temp = proxy_1.lowerContext.filter;
7582
+ proxy_1.lowerContext.filter = proxy_1.initialAdjustmentValue = proxy_1.adjustmentValue = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
7583
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
7584
+ if (proxy_1.cssClass) {
7585
+ addClass([proxy_1.element], proxy_1.cssClass.split(' '));
7586
+ }
6142
7587
  proxy_1.lowerContext.drawImage(proxy_1.inMemoryCanvas, 0, 0);
6143
7588
  proxy_1.baseImg.src = URL.createObjectURL(blob);
6144
7589
  proxy_1.upperContext.clearRect(0, 0, proxy_1.upperCanvas.width, proxy_1.upperCanvas.height);
6145
7590
  proxy_1.togglePen = false;
6146
7591
  proxy_1.upperCanvas.style.cursor = 'default';
7592
+ proxy_1.lowerContext.filter = temp;
7593
+ var tempFilter = proxy_1.lowerContext.filter;
7594
+ proxy_1.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
7595
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
6147
7596
  for (var i = 0, len = proxy_1.objColl.length; i < len; i++) {
6148
7597
  proxy_1.apply(proxy_1.objColl[i].shape, proxy_1.objColl[i], 'duplicate');
6149
7598
  }
7599
+ proxy_1.lowerContext.filter = tempFilter;
6150
7600
  proxy_1.togglePen = true;
6151
7601
  }, 'image/png');
6152
- this.isUndoRedo = false;
6153
7602
  this.degree = 0;
6154
7603
  }
6155
7604
  else {
@@ -6164,7 +7613,6 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6164
7613
  }
6165
7614
  this.keyHistory = '';
6166
7615
  }
6167
- this.isUndoRedo = false;
6168
7616
  }
6169
7617
  }
6170
7618
  };
@@ -6297,6 +7745,9 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6297
7745
  if (this.activeObj.textSettings.fontSize < 20 * (ratio.width + ratio.height)) {
6298
7746
  this.activeObj.textSettings.fontSize = 20 * (ratio.width + ratio.height);
6299
7747
  }
7748
+ if (this.factor > 1) {
7749
+ this.activeObj.textSettings.fontSize /= this.factor;
7750
+ }
6300
7751
  }
6301
7752
  this.activeObj.shapeDegree = this.degree;
6302
7753
  this.activeObj.shapeFlip = this.currFlipState;
@@ -6315,6 +7766,8 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6315
7766
  this.setCenterPoints(true, width, height);
6316
7767
  }
6317
7768
  this.addLetter(this.activeObj.textSettings.text);
7769
+ this.objColl.push(this.activeObj);
7770
+ this.redrawShape(this.objColl[this.objColl.length - 1]);
6318
7771
  this.refreshToolbar('text');
6319
7772
  }
6320
7773
  };
@@ -6388,7 +7841,28 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6388
7841
  inRange = true;
6389
7842
  }
6390
7843
  }
6391
- return inRange;
7844
+ return inRange;
7845
+ };
7846
+ ImageEditor.prototype.updateInMemoryContext = function (imgData, isUpdate) {
7847
+ var temp = extend({}, this.activeObj, {}, true);
7848
+ this.redrawImgWithObj();
7849
+ this.activeObj = temp;
7850
+ if (isNullOrUndefined(isUpdate)) {
7851
+ imgData = this.lowerContext.getImageData(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
7852
+ }
7853
+ this.inMemoryContext.clearRect(0, 0, this.inMemoryCanvas.width, this.inMemoryCanvas.height);
7854
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
7855
+ this.inMemoryCanvas.width = imgData.width;
7856
+ this.inMemoryCanvas.height = imgData.height;
7857
+ this.inMemoryContext.putImageData(imgData, 0, 0);
7858
+ };
7859
+ ImageEditor.prototype.clearActObj = function () {
7860
+ if (this.textBox.style.display === 'none') {
7861
+ this.refreshActiveObj();
7862
+ this.applyActObj();
7863
+ this.refreshActiveObj();
7864
+ this.currObjType.isCustomCrop = false;
7865
+ }
6392
7866
  };
6393
7867
  ImageEditor.prototype.rotateMultiple = function (length, degree) {
6394
7868
  for (var i = 0; i < length; i++) {
@@ -6401,6 +7875,7 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6401
7875
  if (this.degree === 360) {
6402
7876
  this.degree = 0;
6403
7877
  }
7878
+ var temp = this.lowerContext.filter;
6404
7879
  this.lowerContext.save();
6405
7880
  this.setMaximumDimension(90 * (i + 1));
6406
7881
  this.lowerContext.translate(this.lowerCanvas.width / 2, this.lowerCanvas.height / 2);
@@ -6412,7 +7887,9 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6412
7887
  }
6413
7888
  this.lowerCanvas.style.left = this.upperCanvas.style.left = (this.element.clientWidth - parseInt(this.lowerCanvas.style.maxWidth, 10) - 18) / 2 + 1 + 'px';
6414
7889
  this.lowerCanvas.style.top = this.upperCanvas.style.top = (this.element.clientHeight - this.toolbarHeight - parseInt(this.lowerCanvas.style.maxHeight, 10)) / 2 + 1 + 'px';
7890
+ this.updateBrightnessFilter();
6415
7891
  this.lowerContext.drawImage(this.inMemoryCanvas, -this.lowerCanvas.height / 2, -this.lowerCanvas.width / 2);
7892
+ this.lowerContext.filter = temp;
6416
7893
  if (degree > 0) {
6417
7894
  this.lowerContext.rotate(Math.PI / 180 * -90);
6418
7895
  }
@@ -6426,7 +7903,11 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6426
7903
  this.inMemoryCanvas.width = this.currImgData.width;
6427
7904
  this.inMemoryCanvas.height = this.currImgData.height;
6428
7905
  this.inMemoryContext.putImageData(this.currImgData, 0, 0);
7906
+ this.lowerContext.filter = this.canvasFilter;
7907
+ this.updateBrightnessFilter();
7908
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
6429
7909
  this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
7910
+ this.lowerContext.filter = temp;
6430
7911
  if (degree > 0) {
6431
7912
  this.redrawObj(90);
6432
7913
  }
@@ -6435,6 +7916,415 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6435
7916
  }
6436
7917
  }
6437
7918
  };
7919
+ ImageEditor.prototype.setBrightness = function (value) {
7920
+ if (!this.disabled && this.imgDataColl.length > 0) {
7921
+ if (this.currObjType.shape === 'freehanddraw') {
7922
+ this.apply();
7923
+ this.upperCanvas.style.cursor = 'default';
7924
+ this.currObjType.shape = '';
7925
+ }
7926
+ this.clearActObj();
7927
+ this.adjustmentLevel.brightness = value;
7928
+ value = this.getFilterValue(value);
7929
+ this.updateAdjustment('brightness', value);
7930
+ }
7931
+ };
7932
+ ImageEditor.prototype.setContrast = function (value) {
7933
+ if (!this.disabled && this.imgDataColl.length > 0) {
7934
+ if (this.currObjType.shape === 'freehanddraw') {
7935
+ this.apply();
7936
+ this.upperCanvas.style.cursor = 'default';
7937
+ this.currObjType.shape = '';
7938
+ }
7939
+ this.clearActObj();
7940
+ this.adjustmentLevel.contrast = value;
7941
+ value = this.getFilterValue(value);
7942
+ value *= 100;
7943
+ this.updateAdjustment('contrast', value);
7944
+ }
7945
+ };
7946
+ ImageEditor.prototype.setHue = function (value) {
7947
+ if (!this.disabled && this.imgDataColl.length > 0) {
7948
+ if (this.currObjType.shape === 'freehanddraw') {
7949
+ this.apply();
7950
+ this.upperCanvas.style.cursor = 'default';
7951
+ this.currObjType.shape = '';
7952
+ }
7953
+ this.clearActObj();
7954
+ this.adjustmentLevel.hue = value;
7955
+ value *= 3;
7956
+ this.updateAdjustment('hue', value);
7957
+ }
7958
+ };
7959
+ ImageEditor.prototype.setSaturation = function (value) {
7960
+ if (!this.disabled && this.imgDataColl.length > 0) {
7961
+ if (this.currObjType.shape === 'freehanddraw') {
7962
+ this.apply();
7963
+ this.upperCanvas.style.cursor = 'default';
7964
+ this.currObjType.shape = '';
7965
+ }
7966
+ this.clearActObj();
7967
+ this.adjustmentLevel.saturation = value;
7968
+ value = this.getSaturationFilterValue(value);
7969
+ value *= 100;
7970
+ this.updateAdjustment('saturation', value);
7971
+ }
7972
+ };
7973
+ ImageEditor.prototype.setOpacity = function (value) {
7974
+ if (!this.disabled && this.imgDataColl.length > 0) {
7975
+ if (this.currObjType.shape === 'freehanddraw') {
7976
+ this.apply();
7977
+ this.upperCanvas.style.cursor = 'default';
7978
+ this.currObjType.shape = '';
7979
+ }
7980
+ this.clearActObj();
7981
+ this.adjustmentLevel.opacity = value;
7982
+ if (value >= 50) {
7983
+ value /= 100;
7984
+ }
7985
+ else if (value === 40) {
7986
+ value = 0.45;
7987
+ }
7988
+ else if (value === 30) {
7989
+ value = 0.40;
7990
+ }
7991
+ else if (value === 20) {
7992
+ value = 0.35;
7993
+ }
7994
+ else if (value === 10) {
7995
+ value = 0.30;
7996
+ }
7997
+ else if (value === 0) {
7998
+ value = 0.25;
7999
+ }
8000
+ this.updateAdjustment('opacity', value);
8001
+ }
8002
+ };
8003
+ ImageEditor.prototype.setBlur = function (value) {
8004
+ if (!this.disabled && this.imgDataColl.length > 0) {
8005
+ if (this.currObjType.shape === 'freehanddraw') {
8006
+ this.apply();
8007
+ this.upperCanvas.style.cursor = 'default';
8008
+ this.currObjType.shape = '';
8009
+ }
8010
+ this.clearActObj();
8011
+ this.adjustmentLevel.blur = value;
8012
+ value /= 20;
8013
+ this.updateAdjustment('blur', value);
8014
+ }
8015
+ };
8016
+ ImageEditor.prototype.setExposure = function (value) {
8017
+ if (!this.disabled && this.imgDataColl.length > 0) {
8018
+ if (this.currObjType.shape === 'freehanddraw') {
8019
+ this.apply();
8020
+ this.upperCanvas.style.cursor = 'default';
8021
+ this.currObjType.shape = '';
8022
+ }
8023
+ this.clearActObj();
8024
+ this.adjustmentLevel.exposure = value;
8025
+ value = this.getFilterValue(value);
8026
+ this.updateAdjustment('exposure', value);
8027
+ }
8028
+ };
8029
+ ImageEditor.prototype.setFilter = function (type) {
8030
+ if (!this.disabled && this.imgDataColl.length > 0) {
8031
+ if (this.currObjType.shape === 'freehanddraw') {
8032
+ this.apply();
8033
+ this.upperCanvas.style.cursor = 'default';
8034
+ this.currObjType.shape = '';
8035
+ }
8036
+ this.clearActObj();
8037
+ this.updateAdjustment(type, null);
8038
+ }
8039
+ };
8040
+ ImageEditor.prototype.setBlackAndWhiteFilter = function (boolean) {
8041
+ if (!this.disabled && this.imgDataColl.length > 0) {
8042
+ if (this.currObjType.shape === 'freehanddraw') {
8043
+ this.apply();
8044
+ this.upperCanvas.style.cursor = 'default';
8045
+ this.currObjType.shape = '';
8046
+ }
8047
+ this.clearActObj();
8048
+ this.adjustmentLevel.bw = boolean;
8049
+ if (boolean) {
8050
+ if (this.degree === 0 && this.currFlipState === '') {
8051
+ this.replaceBWSharpenData('bw');
8052
+ }
8053
+ else if (this.degree !== 0) {
8054
+ var tempDegree = this.degree;
8055
+ this.rotate(-tempDegree);
8056
+ this.replaceBWSharpenData('bw');
8057
+ this.rotate(tempDegree);
8058
+ this.refreshToolbar('filter');
8059
+ }
8060
+ else if (this.currFlipState !== '') {
8061
+ var tempFlipState = this.currFlipState;
8062
+ this.flip(tempFlipState);
8063
+ this.replaceBWSharpenData('bw');
8064
+ this.flip(tempFlipState);
8065
+ this.refreshToolbar('filter');
8066
+ }
8067
+ var data = this.inMemoryContext.getImageData(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
8068
+ var imageData = this.getBlackAndWhiteData(data);
8069
+ this.inMemoryContext.clearRect(0, 0, this.inMemoryCanvas.width, this.inMemoryCanvas.height);
8070
+ this.inMemoryCanvas.width = imageData.width;
8071
+ this.inMemoryCanvas.height = imageData.height;
8072
+ this.inMemoryContext.putImageData(imageData, 0, 0);
8073
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
8074
+ this.lowerContext.filter = this.canvasFilter;
8075
+ var temp = this.lowerContext.filter;
8076
+ this.updateBrightnessFilter();
8077
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
8078
+ this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
8079
+ this.lowerContext.filter = temp;
8080
+ }
8081
+ else {
8082
+ if (this.degree === 0 && this.currFlipState === '') {
8083
+ this.updateBWSharpness();
8084
+ }
8085
+ else if (this.degree !== 0) {
8086
+ var tempDegree = this.degree;
8087
+ this.rotate(-tempDegree);
8088
+ this.updateBWSharpness();
8089
+ this.rotate(tempDegree);
8090
+ this.refreshToolbar('filter');
8091
+ if (this.sharpenedImgData) {
8092
+ this.sharpenedImgData = false;
8093
+ }
8094
+ }
8095
+ else if (this.currFlipState !== '') {
8096
+ var tempFlipState = this.currFlipState;
8097
+ this.flip(tempFlipState);
8098
+ this.updateBWSharpness();
8099
+ this.flip(tempFlipState);
8100
+ this.refreshToolbar('filter');
8101
+ if (this.sharpenedImgData) {
8102
+ this.sharpenedImgData = false;
8103
+ }
8104
+ }
8105
+ }
8106
+ }
8107
+ };
8108
+ ImageEditor.prototype.setSharpness = function (boolean) {
8109
+ if (!this.disabled && this.imgDataColl.length > 0) {
8110
+ if (this.currObjType.shape === 'freehanddraw') {
8111
+ this.apply();
8112
+ this.upperCanvas.style.cursor = 'default';
8113
+ this.currObjType.shape = '';
8114
+ }
8115
+ this.clearActObj();
8116
+ this.adjustmentLevel.sharpen = boolean;
8117
+ if (boolean) {
8118
+ if (this.degree === 0 && this.currFlipState === '') {
8119
+ this.replaceBWSharpenData('sharpen');
8120
+ }
8121
+ else if (this.degree !== 0) {
8122
+ var tempDegree = this.degree;
8123
+ this.rotate(-tempDegree);
8124
+ this.replaceBWSharpenData('sharpen');
8125
+ this.rotate(tempDegree);
8126
+ this.refreshToolbar('filter');
8127
+ }
8128
+ else if (this.currFlipState !== '') {
8129
+ var tempFlipState = this.currFlipState;
8130
+ this.flip(tempFlipState);
8131
+ this.replaceBWSharpenData('sharpen');
8132
+ this.flip(tempFlipState);
8133
+ this.refreshToolbar('filter');
8134
+ }
8135
+ var data = this.inMemoryContext.getImageData(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
8136
+ var imageData = this.getSharpenData(data);
8137
+ this.inMemoryContext.clearRect(0, 0, this.inMemoryCanvas.width, this.inMemoryCanvas.height);
8138
+ this.inMemoryCanvas.width = imageData.width;
8139
+ this.inMemoryCanvas.height = imageData.height;
8140
+ this.inMemoryContext.putImageData(imageData, 0, 0);
8141
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
8142
+ this.lowerContext.filter = this.canvasFilter;
8143
+ var temp = this.lowerContext.filter;
8144
+ this.updateBrightnessFilter();
8145
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
8146
+ this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
8147
+ this.lowerContext.filter = temp;
8148
+ }
8149
+ else {
8150
+ if (this.degree === 0 && this.currFlipState === '') {
8151
+ this.updateBWSharpness();
8152
+ }
8153
+ else if (this.degree !== 0) {
8154
+ var tempDegree = this.degree;
8155
+ this.rotate(-tempDegree);
8156
+ this.updateBWSharpness();
8157
+ this.rotate(tempDegree);
8158
+ this.refreshToolbar('filter');
8159
+ if (this.sharpenedImgData) {
8160
+ this.sharpenedImgData = false;
8161
+ }
8162
+ }
8163
+ else if (this.currFlipState !== '') {
8164
+ var tempFlipState = this.currFlipState;
8165
+ this.flip(tempFlipState);
8166
+ this.updateBWSharpness();
8167
+ this.flip(tempFlipState);
8168
+ this.refreshToolbar('filter');
8169
+ if (this.sharpenedImgData) {
8170
+ this.sharpenedImgData = false;
8171
+ }
8172
+ }
8173
+ }
8174
+ }
8175
+ };
8176
+ ImageEditor.prototype.replaceBWSharpenData = function (type) {
8177
+ this.tempImageData = this.inMemoryContext.getImageData(0, 0, this.inMemoryCanvas.width, this.inMemoryCanvas.height);
8178
+ var imageData = this.inMemoryContext.getImageData(0, 0, this.inMemoryCanvas.width, this.inMemoryCanvas.height);
8179
+ if (type === 'sharpen') {
8180
+ imageData = this.getSharpenData(this.tempImageData);
8181
+ }
8182
+ else {
8183
+ imageData = this.getBlackAndWhiteData(imageData);
8184
+ }
8185
+ this.inMemoryContext.clearRect(0, 0, this.inMemoryCanvas.width, this.inMemoryCanvas.height);
8186
+ this.inMemoryCanvas.width = imageData.width;
8187
+ this.inMemoryCanvas.height = imageData.height;
8188
+ this.inMemoryContext.putImageData(imageData, 0, 0);
8189
+ var tempObj;
8190
+ for (var index = 0; index < this.imgDataColl.length; index++) {
8191
+ if (this.imgDataColl[index].operation !== 'freehanddraw') {
8192
+ tempObj = this.imgDataColl[index];
8193
+ break;
8194
+ }
8195
+ }
8196
+ this.imgDataColl.splice(0, 1, { operation: 'updateCanvas', value: imageData });
8197
+ this.imgDataColl.splice(1, 1, tempObj);
8198
+ this.inMemoryContext.clearRect(0, 0, this.inMemoryCanvas.width, this.inMemoryCanvas.height);
8199
+ this.inMemoryCanvas.width = this.tempImageData.width;
8200
+ this.inMemoryCanvas.height = this.tempImageData.height;
8201
+ this.inMemoryContext.putImageData(this.tempImageData, 0, 0);
8202
+ };
8203
+ ImageEditor.prototype.updateBWSharpness = function () {
8204
+ this.inMemoryContext.clearRect(0, 0, this.inMemoryCanvas.width, this.inMemoryCanvas.height);
8205
+ this.inMemoryCanvas.width = this.tempImageData.width;
8206
+ this.inMemoryCanvas.height = this.tempImageData.height;
8207
+ this.inMemoryContext.putImageData(this.tempImageData, 0, 0);
8208
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
8209
+ this.lowerContext.filter = this.canvasFilter;
8210
+ this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
8211
+ this.imgDataColl.shift();
8212
+ };
8213
+ ImageEditor.prototype.getSharpenData = function (imageData) {
8214
+ var data = imageData.data;
8215
+ var weights = [0, -1, 0, -1, 5, -1, 0, -1, 0];
8216
+ var side = Math.round(Math.sqrt(weights.length));
8217
+ var halfSide = Math.floor(side / 2);
8218
+ var sw = imageData.width;
8219
+ var sh = imageData.height;
8220
+ var output = this.inMemoryContext.createImageData(sw, sh);
8221
+ var dst = output.data;
8222
+ // go through the destination image pixels
8223
+ var alphaFac = 0;
8224
+ var r;
8225
+ var g;
8226
+ var b;
8227
+ var a;
8228
+ var dstOff;
8229
+ var scx;
8230
+ var scy;
8231
+ var srcOff;
8232
+ var wt;
8233
+ var x;
8234
+ var y;
8235
+ var cx;
8236
+ var cy;
8237
+ for (y = 0; y < sh; y++) {
8238
+ for (x = 0; x < sw; x++) {
8239
+ dstOff = (y * sw + x) * 4;
8240
+ r = 0;
8241
+ g = 0;
8242
+ b = 0;
8243
+ a = 0;
8244
+ for (cy = 0; cy < side; cy++) {
8245
+ for (cx = 0; cx < side; cx++) {
8246
+ scy = y + cy - halfSide;
8247
+ scx = x + cx - halfSide;
8248
+ if (scy < 0 || scy >= sh || scx < 0 || scx >= sw) {
8249
+ continue;
8250
+ }
8251
+ srcOff = (scy * sw + scx) * 4;
8252
+ wt = weights[cy * side + cx];
8253
+ r += data[srcOff] * wt;
8254
+ g += data[srcOff + 1] * wt;
8255
+ b += data[srcOff + 2] * wt;
8256
+ if (!alphaFac) {
8257
+ a += data[srcOff + 3] * wt;
8258
+ }
8259
+ }
8260
+ }
8261
+ dst[dstOff] = r;
8262
+ dst[dstOff + 1] = g;
8263
+ dst[dstOff + 2] = b;
8264
+ if (!alphaFac) {
8265
+ dst[dstOff + 3] = a;
8266
+ }
8267
+ else {
8268
+ dst[dstOff + 3] = data[dstOff + 3];
8269
+ }
8270
+ }
8271
+ }
8272
+ return output;
8273
+ };
8274
+ ImageEditor.prototype.getFilterValue = function (value) {
8275
+ var filterValue;
8276
+ if (value === 0) {
8277
+ filterValue = 1;
8278
+ }
8279
+ else {
8280
+ filterValue = 1 + ((value * 0.5) / 100);
8281
+ }
8282
+ return filterValue;
8283
+ };
8284
+ ImageEditor.prototype.setFilterValue = function (value) {
8285
+ var filterValue;
8286
+ if (value === 1) {
8287
+ filterValue = 0;
8288
+ }
8289
+ else {
8290
+ filterValue = ((value - 1) * 100) / 0.5;
8291
+ }
8292
+ return Math.round(filterValue);
8293
+ };
8294
+ ImageEditor.prototype.getSaturationFilterValue = function (value) {
8295
+ var filterValue;
8296
+ if (value === 0) {
8297
+ filterValue = 1;
8298
+ }
8299
+ else {
8300
+ filterValue = 1 + (value / 100);
8301
+ }
8302
+ return filterValue;
8303
+ };
8304
+ ImageEditor.prototype.setSaturationFilterValue = function (value) {
8305
+ var filterValue;
8306
+ if (value === 1) {
8307
+ filterValue = 0;
8308
+ }
8309
+ else {
8310
+ filterValue = (value - 1) * 100;
8311
+ }
8312
+ return Math.round(filterValue);
8313
+ };
8314
+ ImageEditor.prototype.getBlackAndWhiteData = function (imageData) {
8315
+ for (var i = 0; i < imageData.data.length; i += 4) {
8316
+ var count = imageData.data[i] + imageData.data[i + 1] + imageData.data[i + 2];
8317
+ var colour = 0;
8318
+ if (count > 383) {
8319
+ colour = 255;
8320
+ }
8321
+ imageData.data[i] = colour;
8322
+ imageData.data[i + 1] = colour;
8323
+ imageData.data[i + 2] = colour;
8324
+ imageData.data[i + 3] = 255;
8325
+ }
8326
+ return imageData;
8327
+ };
6438
8328
  /**
6439
8329
  * Clear a current selection.
6440
8330
  *
@@ -6471,11 +8361,22 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6471
8361
  // eslint-disable-next-line @typescript-eslint/no-this-alias
6472
8362
  var proxy_2 = this;
6473
8363
  isCrop = true;
8364
+ var canvasFilter = this.canvasFilter;
8365
+ var tempActObj = extend({}, this.activeObj, {}, true);
8366
+ this.lowerContext.filter = this.canvasFilter = 'none';
8367
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
8368
+ this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
8369
+ for (var j = 0; j < this.objColl.length; j++) {
8370
+ this.apply(this.objColl[j].shape, this.objColl[j]);
8371
+ this.refreshActiveObj();
8372
+ }
8373
+ this.activeObj = tempActObj;
6474
8374
  this.upperCanvas.style.display = 'none';
6475
8375
  var widthRatio = void 0;
6476
8376
  var heightRatio = void 0;
6477
8377
  var imgData = void 0;
6478
8378
  var zoomedRotate = false;
8379
+ var factor = this.factor;
6479
8380
  if (this.factor === 1) {
6480
8381
  imgData = this.lowerContext.getImageData(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
6481
8382
  widthRatio = this.lowerCanvas.width / parseInt(this.lowerCanvas.style.maxWidth, 10);
@@ -6510,6 +8411,7 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6510
8411
  this.updateInMemoryContext(imgData);
6511
8412
  }
6512
8413
  this.degree = 0;
8414
+ this.updateBrightnessFilter();
6513
8415
  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);
6514
8416
  }
6515
8417
  if (this.flipState !== '') {
@@ -6524,6 +8426,7 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6524
8426
  this.lowerCanvas.style.maxHeight = this.upperCanvas.style.maxHeight = maxDimension.height + 'px';
6525
8427
  this.lowerCanvas.width = this.upperCanvas.width = maxDimension.width * widthRatio;
6526
8428
  this.lowerCanvas.height = this.upperCanvas.height = maxDimension.height * heightRatio;
8429
+ this.updateBrightnessFilter();
6527
8430
  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);
6528
8431
  }
6529
8432
  }
@@ -6544,6 +8447,7 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6544
8447
  ((this.element.clientWidth - parseInt(cssObj.width, 10) - 18) / 2) + 1 + 'px';
6545
8448
  this.lowerCanvas.style.top = this.upperCanvas.style.top = ((this.element.clientHeight - this.toolbarHeight
6546
8449
  - parseInt(cssObj.height, 10)) / 2) + 1 + 'px';
8450
+ this.updateBrightnessFilter();
6547
8451
  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);
6548
8452
  }
6549
8453
  if (this.activeObj.shape === 'crop-circle') {
@@ -6552,6 +8456,7 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6552
8456
  this.inMemoryCanvas.height = imgData_1.height;
6553
8457
  this.inMemoryContext.putImageData(imgData_1, 0, 0);
6554
8458
  this.lowerContext.save();
8459
+ this.updateBrightnessFilter();
6555
8460
  this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0, this.baseImg.width, this.baseImg.height);
6556
8461
  this.lowerContext.globalCompositeOperation = 'destination-in';
6557
8462
  this.lowerContext.beginPath();
@@ -6564,18 +8469,11 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6564
8469
  showSpinner(this.element);
6565
8470
  this.element.style.opacity = '0.5';
6566
8471
  var blobUrl_1;
6567
- var data_1;
6568
8472
  // eslint-disable-next-line @typescript-eslint/tslint/config
6569
8473
  this.lowerCanvas.toBlob(function (blob) {
6570
8474
  blobUrl_1 = URL.createObjectURL(blob);
6571
- proxy_2.isUndoRedo = false;
6572
8475
  proxy_2.baseImg.src = blobUrl_1;
6573
- data_1 = proxy_2.lowerContext.getImageData(0, 0, proxy_2.lowerCanvas.width, proxy_2.lowerCanvas.height);
6574
8476
  proxy_2.imgDataColl = [];
6575
- if (!proxy_2.isUndoRedo) {
6576
- proxy_2.updateUndoRedoColl('crop', data_1, proxy_2.objColl);
6577
- }
6578
- proxy_2.isUndoRedo = false;
6579
8477
  }, 'image/png');
6580
8478
  this.objColl = [];
6581
8479
  this.refreshActiveObj();
@@ -6584,26 +8482,11 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6584
8482
  this.upperContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
6585
8483
  this.lowerContext.globalAlpha = 0;
6586
8484
  this.lowerContext.fillRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
6587
- this.lowerContext.setTransform(1, 0, 0, 1, 0, 0);
6588
- this.upperContext.setTransform(1, 0, 0, 1, 0, 0);
6589
8485
  this.factor = 1;
8486
+ this.canvasFilter = canvasFilter;
6590
8487
  }
6591
8488
  return isCrop;
6592
8489
  };
6593
- ImageEditor.prototype.updateInMemoryContext = function (imgData) {
6594
- this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
6595
- var temp = extend({}, this.activeObj, {}, true);
6596
- for (var i = 0; i < this.objColl.length; i++) {
6597
- this.apply(this.objColl[i].shape, this.objColl[i]);
6598
- }
6599
- this.activeObj = temp;
6600
- imgData = this.lowerContext.getImageData(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
6601
- this.inMemoryContext.clearRect(0, 0, this.inMemoryCanvas.width, this.inMemoryCanvas.height);
6602
- this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
6603
- this.inMemoryCanvas.width = imgData.width;
6604
- this.inMemoryCanvas.height = imgData.height;
6605
- this.inMemoryContext.putImageData(imgData, 0, 0);
6606
- };
6607
8490
  /**
6608
8491
  * Flips an image by horizontally or vertically.
6609
8492
  *
@@ -6620,8 +8503,8 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6620
8503
  }
6621
8504
  var transitionArgs = { direction: direction };
6622
8505
  this.trigger('flipping', transitionArgs);
6623
- this.lastAction = 'flip';
6624
- this.flipMethod = true;
8506
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
8507
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
6625
8508
  var splitWords = [];
6626
8509
  var activeObjShape = void 0;
6627
8510
  if (!isNullOrUndefined(this.activeObj.activePoint)) {
@@ -6642,7 +8525,6 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6642
8525
  this.lowerContext.scale(-1, 1);
6643
8526
  this.upperContext.translate(this.upperContext.canvas.width, 0);
6644
8527
  this.upperContext.scale(-1, 1);
6645
- this.flipDirection = 'horizontal';
6646
8528
  if (this.flipState === '' || this.flipState.toLowerCase() === 'vertical') {
6647
8529
  this.flipState = 'horizontal';
6648
8530
  }
@@ -6658,7 +8540,6 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6658
8540
  this.lowerContext.scale(1, -1);
6659
8541
  this.upperContext.translate(0, this.upperContext.canvas.height);
6660
8542
  this.upperContext.scale(1, -1);
6661
- this.flipDirection = 'vertical';
6662
8543
  if (this.flipState.toLowerCase() === '' || this.flipState.toLowerCase() === 'horizontal') {
6663
8544
  this.flipState = 'vertical';
6664
8545
  }
@@ -6669,13 +8550,25 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6669
8550
  this.currFlipState = 'vertical';
6670
8551
  }
6671
8552
  }
8553
+ var temp = this.lowerContext.filter;
8554
+ this.updateBrightnessFilter();
8555
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
6672
8556
  this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
8557
+ this.lowerContext.filter = temp;
6673
8558
  this.currImgData = this.lowerContext.getImageData(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
8559
+ this.lowerContext.filter = this.canvasFilter;
8560
+ this.updateBrightnessFilter();
8561
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
8562
+ this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
8563
+ this.lowerContext.filter = temp;
6674
8564
  this.inMemoryContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
6675
8565
  this.inMemoryCanvas.width = this.currImgData.width;
6676
8566
  this.inMemoryCanvas.height = this.currImgData.height;
6677
8567
  this.inMemoryContext.putImageData(this.currImgData, 0, 0);
6678
8568
  if (this.flipState.toLowerCase() === 'horizontal') {
8569
+ var tempFilter = this.lowerContext.filter;
8570
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
8571
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
6679
8572
  for (var i = 0, len = this.objColl.length; i < len; i++) {
6680
8573
  this.objColl[i].flippedText = false;
6681
8574
  if (this.objColl[i].shapeFlip !== '' && this.objColl[i].shapeFlip === this.currFlipState) {
@@ -6685,13 +8578,16 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6685
8578
  this.apply(this.objColl[i].shape, this.objColl[i]);
6686
8579
  }
6687
8580
  }
8581
+ this.lowerContext.filter = tempFilter;
6688
8582
  this.lowerContext.translate(this.lowerContext.canvas.width, 0);
6689
8583
  this.lowerContext.scale(-1, 1);
6690
8584
  this.upperContext.translate(this.upperContext.canvas.width, 0);
6691
8585
  this.upperContext.scale(-1, 1);
6692
- this.flipDirection = '';
6693
8586
  }
6694
8587
  else if (this.flipState.toLowerCase() === 'vertical') {
8588
+ var tempFilter = this.lowerContext.filter;
8589
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
8590
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
6695
8591
  for (var i = 0, len = this.objColl.length; i < len; i++) {
6696
8592
  this.objColl[i].flippedText = false;
6697
8593
  if (this.objColl[i].shapeFlip !== '' && this.objColl[i].shapeFlip === this.currFlipState) {
@@ -6701,11 +8597,11 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6701
8597
  this.apply(this.objColl[i].shape, this.objColl[i]);
6702
8598
  }
6703
8599
  }
8600
+ this.lowerContext.filter = tempFilter;
6704
8601
  this.lowerContext.translate(0, this.lowerContext.canvas.height);
6705
8602
  this.lowerContext.scale(1, -1);
6706
8603
  this.upperContext.translate(0, this.upperContext.canvas.height);
6707
8604
  this.upperContext.scale(1, -1);
6708
- this.flipDirection = '';
6709
8605
  }
6710
8606
  for (var i = 0, len = this.objColl.length; i < len; i++) {
6711
8607
  if (this.objColl[i].flipObjColl.length === 0) {
@@ -6720,15 +8616,15 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6720
8616
  }
6721
8617
  this.redrawObj(direction.toLowerCase());
6722
8618
  if (this.flipState === '') {
8619
+ var tempFilter = this.lowerContext.filter;
8620
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
8621
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
6723
8622
  for (var i = 0, len = this.objColl.length; i < len; i++) {
6724
8623
  this.apply(this.objColl[i].shape, this.objColl[i]);
6725
8624
  }
8625
+ this.lowerContext.filter = tempFilter;
6726
8626
  }
6727
8627
  this.refreshActiveObj();
6728
- if (!this.isUndoRedo) {
6729
- this.updateUndoRedoColl('flip', direction, this.objColl);
6730
- }
6731
- this.isUndoRedo = this.flipMethod = false;
6732
8628
  if (!isNullOrUndefined(activeObjShape)) {
6733
8629
  if (activeObjShape === 'custom') {
6734
8630
  this.activeObj.activePoint = { startX: 0, startY: 0, endX: this.lowerCanvas.width,
@@ -6740,6 +8636,7 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6740
8636
  this.select(activeObjShape);
6741
8637
  }
6742
8638
  }
8639
+ this.refreshToolbar('main');
6743
8640
  }
6744
8641
  };
6745
8642
  /**
@@ -6760,11 +8657,13 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6760
8657
  */
6761
8658
  ImageEditor.prototype.open = function (data) {
6762
8659
  if (!this.disabled) {
8660
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
8661
+ var proxy_3 = this;
6763
8662
  showSpinner(this.element);
6764
8663
  this.element.style.opacity = '0.5';
6765
- var toolbar_10 = document.querySelector('#' + this.element.id + '_currPos');
6766
- if (toolbar_10) {
6767
- toolbar_10.style.display = 'none';
8664
+ var toolbar_11 = document.querySelector('#' + this.element.id + '_currPos');
8665
+ if (toolbar_11) {
8666
+ toolbar_11.style.display = 'none';
6768
8667
  }
6769
8668
  if (this.defToolbarItems.length === 0 &&
6770
8669
  (isNullOrUndefined(document.getElementById(this.element.id + '_toolbar')))) {
@@ -6773,11 +8672,16 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6773
8672
  if (isNullOrUndefined(this.toolbarTemplate)) {
6774
8673
  this.update();
6775
8674
  }
8675
+ this.degree = 0;
8676
+ this.flipState = '';
8677
+ this.factor = 1;
8678
+ this.imgDataColl = [];
6776
8679
  var type = typeof (data);
6777
8680
  if (type === 'string') {
6778
8681
  this.imageOnLoad(data);
6779
8682
  }
6780
8683
  else {
8684
+ var tempFilter = this.lowerContext.filter;
6781
8685
  this.lowerCanvas = document.querySelector('#' + this.element.id + '_lowerCanvas');
6782
8686
  this.upperCanvas = document.querySelector('#' + this.element.id + '_upperCanvas');
6783
8687
  this.lowerContext = this.lowerCanvas.getContext('2d');
@@ -6791,10 +8695,19 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6791
8695
  this.imgDataColl.push({ operation: 'open', value: data });
6792
8696
  this.lowerCanvas.width = this.upperCanvas.width = data.width;
6793
8697
  this.lowerCanvas.height = this.upperCanvas.height = data.height;
8698
+ this.lowerContext.filter = tempFilter;
8699
+ var temp = this.lowerContext.filter;
8700
+ this.updateBrightnessFilter();
6794
8701
  this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
6795
- this.updateCanvas();
8702
+ this.lowerContext.filter = temp;
8703
+ this.redrawImg(this.lowerContext.filter);
6796
8704
  hideSpinner(this.element);
6797
8705
  this.element.style.opacity = '1';
8706
+ // eslint-disable-next-line @typescript-eslint/tslint/config
8707
+ this.lowerCanvas.toBlob(function (blob) {
8708
+ showSpinner(proxy_3.element);
8709
+ proxy_3.baseImg.src = URL.createObjectURL(blob);
8710
+ }, 'image/png');
6798
8711
  }
6799
8712
  }
6800
8713
  };
@@ -6811,6 +8724,8 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6811
8724
  this.lowerContext.clearRect(0, 0, this.inMemoryCanvas.height, this.inMemoryCanvas.width);
6812
8725
  this.upperContext.clearRect(0, 0, this.inMemoryCanvas.width, this.inMemoryCanvas.height);
6813
8726
  this.upperContext.clearRect(0, 0, this.inMemoryCanvas.height, this.inMemoryCanvas.width);
8727
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
8728
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
6814
8729
  showSpinner(this.element);
6815
8730
  this.element.style.opacity = '0.5';
6816
8731
  if (this.imgDataColl.length > 0) {
@@ -6821,11 +8736,13 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6821
8736
  this.inMemoryCanvas.width = this.imgDataColl[0].value.width;
6822
8737
  this.inMemoryCanvas.height = this.imgDataColl[0].value.height;
6823
8738
  this.inMemoryContext.putImageData(this.imgDataColl[0].value, 0, 0);
6824
- this.redrawImg();
8739
+ this.redrawImg(this.lowerContext.filter);
8740
+ this.lowerCanvas.width = this.baseImg.width;
8741
+ this.lowerCanvas.height = this.baseImg.height;
6825
8742
  }
6826
8743
  this.lowerContext.setTransform(1, 0, 0, 1, 0, 0);
6827
8744
  this.upperContext.setTransform(1, 0, 0, 1, 0, 0);
6828
- this.baseImg.src = this.baseImgSrc;
8745
+ this.baseImg.src = this.baseImgSrc.id;
6829
8746
  this.factor = 1;
6830
8747
  this.refreshToolbar('main');
6831
8748
  if (Browser.isDevice && document.getElementById(this.element.id + '_bottomToolbar')) {
@@ -6834,22 +8751,20 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6834
8751
  this.objColl = [];
6835
8752
  this.imgDataColl = [];
6836
8753
  this.degree = 0;
6837
- this.flipState = this.keyHistory = this.currFlipState = this.flipDirection = '';
8754
+ this.flipState = this.keyHistory = this.currFlipState = '';
6838
8755
  this.upperCanvas.style.display = 'none';
8756
+ this.togglePan = this.togglePen = false;
6839
8757
  this.upperCanvas.style.cursor = this.lowerCanvas.style.cursor = 'default';
6840
- this.undoRedoColl = [];
6841
- this.dragCanvas = this.dragged = this.isUndoRedo = this.activeObj.flippedText = this.flipMethod = false;
8758
+ this.dragCanvas = this.activeObj.flippedText = false;
6842
8759
  this.currImgData = {};
6843
8760
  this.pannStart = { startX: 0, startY: 0, width: 0, height: 0 };
6844
8761
  this.pannEnd = { startX: 0, startY: 0, width: 0, height: 0 };
6845
8762
  this.lowerContext.lineWidth = this.upperContext.lineWidth = undefined;
6846
- this.togglePan = this.togglePen = this.rotateMethod = false;
6847
8763
  this.lastX = this.lastY = 0;
6848
8764
  this.dragStart = { x: 0, y: 0 };
6849
8765
  this.touchEndPoint = {};
6850
8766
  this.prevX = this.currX = this.prevY = this.currY = 0;
6851
- this.lastAction = this.tempKeyHistory = '';
6852
- this.isBoldbtn = this.isItalicbtn = false;
8767
+ this.tempKeyHistory = '';
6853
8768
  this.currentToolbar = 'main';
6854
8769
  this.textStartPoints = { x: 0, y: 0 };
6855
8770
  this.fontSizeColl = this.penDrawColl = [];
@@ -6859,14 +8774,24 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6859
8774
  this.textSettings =
6860
8775
  { text: 'Enter Text', fontFamily: 'Arial', fontSize: null, bold: false, italic: false, underline: false };
6861
8776
  this.tempStrokeSettings = { strokeColor: '#fff', fillColor: '', strokeWidth: null };
6862
- this.penStrokeWidth = undefined;
6863
8777
  this.tempTextSettings =
6864
8778
  { text: 'Enter Text', fontFamily: 'Arial', fontSize: null, bold: false, italic: false, underline: false };
6865
8779
  this.refreshActiveObj();
6866
8780
  this.timer = undefined;
8781
+ this.penStrokeWidth = undefined;
6867
8782
  this.isScreenOriented = false;
8783
+ this.tempObjColl = [];
8784
+ this.tempObjColl = undefined;
8785
+ this.adjustmentLevel = { brightness: 0, contrast: 0, hue: 0, opacity: 100, saturation: 0, blur: 0, exposure: 0, sharpen: false, bw: false };
8786
+ this.tempAdjustmentLevel = { brightness: 0, contrast: 0, hue: 0, opacity: 100, saturation: 0, blur: 0, exposure: 0, sharpen: false, bw: false };
8787
+ this.canvasFilter = this.currentFilter = this.tempAdjustmentValue = '';
8788
+ this.lowerContext.filter = this.initialAdjustmentValue = this.adjustmentValue = 'brightness(' + 1 + ') ' + 'contrast(' + 100
8789
+ + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
8790
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
8791
+ this.tempImageData = undefined;
8792
+ this.sharpenedImgData = this.isBrightnessAdjusted = this.isInitialLoading = false;
6868
8793
  this.currObjType = { shape: '', isDragging: false, isActiveObj: false, isText: false, isInitialText: false, isLine: false,
6869
- isInitialLine: false, isCustomCrop: false, isZoomed: false };
8794
+ isInitialLine: false, isCustomCrop: false, isZoomed: false, isFiltered: false, isSave: false };
6870
8795
  }
6871
8796
  };
6872
8797
  /**
@@ -6894,7 +8819,6 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6894
8819
  }
6895
8820
  }
6896
8821
  this.redrawActObj();
6897
- var factor = this.factor;
6898
8822
  if (this.factor !== 1) {
6899
8823
  this.lowerContext.setTransform(1, 0, 0, 1, 0, 0);
6900
8824
  this.upperContext.setTransform(1, 0, 0, 1, 0, 0);
@@ -6910,13 +8834,16 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6910
8834
  if (this.degree === 360) {
6911
8835
  this.degree = 0;
6912
8836
  }
8837
+ var temp = this.lowerContext.filter;
6913
8838
  this.lowerContext.save();
6914
8839
  this.setMaximumDimension(this.degree);
6915
8840
  this.lowerContext.translate(this.lowerCanvas.width / 2, this.lowerCanvas.height / 2);
6916
8841
  this.lowerContext.rotate(Math.PI / 180 * degree);
6917
8842
  this.lowerCanvas.style.left = this.upperCanvas.style.left = (this.element.clientWidth - parseInt(this.lowerCanvas.style.maxWidth, 10) - 18) / 2 + 1 + 'px';
6918
8843
  this.lowerCanvas.style.top = this.upperCanvas.style.top = (this.element.clientHeight - this.toolbarHeight - parseInt(this.lowerCanvas.style.maxHeight, 10)) / 2 + 1 + 'px';
8844
+ this.updateBrightnessFilter();
6919
8845
  this.lowerContext.drawImage(this.inMemoryCanvas, -this.lowerCanvas.height / 2, -this.lowerCanvas.width / 2);
8846
+ this.lowerContext.filter = temp;
6920
8847
  this.lowerContext.rotate(Math.PI / 180 * -degree);
6921
8848
  this.lowerContext.translate(-this.lowerCanvas.width / 2, -this.lowerCanvas.height / 2);
6922
8849
  this.lowerContext.restore();
@@ -6925,12 +8852,17 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6925
8852
  this.inMemoryCanvas.width = this.currImgData.width;
6926
8853
  this.inMemoryCanvas.height = this.currImgData.height;
6927
8854
  this.inMemoryContext.putImageData(this.currImgData, 0, 0);
8855
+ this.lowerContext.filter = this.canvasFilter;
8856
+ this.updateBrightnessFilter();
8857
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
6928
8858
  this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
8859
+ this.lowerContext.filter = temp;
6929
8860
  this.redrawObj(degree);
6930
8861
  }
6931
8862
  if (!isNullOrUndefined(activeObjShape)) {
6932
8863
  if (activeObjShape === 'custom') {
6933
- var endPoint = { x: this.lowerCanvas.width - this.pannEnd.startX, y: this.lowerCanvas.height - this.pannEnd.startY };
8864
+ var endPoint = { x: this.lowerCanvas.width - this.pannEnd.startX, y: this.lowerCanvas.height -
8865
+ this.pannEnd.startY };
6934
8866
  this.activeObj.activePoint = { startX: this.pannStart.startX, startY: this.pannStart.startY, endX: endPoint.x,
6935
8867
  endY: endPoint.y, width: endPoint.x - this.pannStart.startX, height: endPoint.y - this.pannStart.startY };
6936
8868
  this.updateActiveObject(this.calcRatio(), this.activeObj.activePoint, this.activeObj);
@@ -6942,10 +8874,6 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6942
8874
  this.refreshToolbar('main', true, true);
6943
8875
  }
6944
8876
  this.factor = 1;
6945
- if (!this.isUndoRedo) {
6946
- this.updateUndoRedoColl('rotate', degree, this.objColl, null);
6947
- }
6948
- this.isUndoRedo = false;
6949
8877
  this.refreshToolbar('main');
6950
8878
  }
6951
8879
  return isRotate;
@@ -6966,17 +8894,14 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6966
8894
  this.applyPenDraw();
6967
8895
  }
6968
8896
  this.applyActObj();
8897
+ this.lowerContext.filter = this.canvasFilter;
6969
8898
  if (this.factor !== 1) {
6970
8899
  this.lowerContext.setTransform(1, 0, 0, 1, 0, 0);
6971
8900
  this.upperContext.setTransform(1, 0, 0, 1, 0, 0);
6972
8901
  this.factor = 1;
6973
8902
  this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
6974
8903
  this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
6975
- this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
6976
- for (var i = 0; i < this.objColl.length; i++) {
6977
- this.apply(this.objColl[i].shape, this.objColl[i]);
6978
- this.refreshActiveObj();
6979
- }
8904
+ this.redrawImgWithObj();
6980
8905
  }
6981
8906
  type = type ? type : 'Png';
6982
8907
  this.redrawActObj();
@@ -6984,6 +8909,7 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6984
8909
  var saved_1 = { fileName: fileName ? fileName : 'ImageEditor', fileType: type };
6985
8910
  this.trigger('beforeSave', beforeSave, function (observableSaveArgs) {
6986
8911
  if (!observableSaveArgs.cancel) {
8912
+ _this.currObjType.isSave = true;
6987
8913
  fileName = observableSaveArgs.fileName ? observableSaveArgs.fileName : fileName;
6988
8914
  if (type.toLowerCase() === 'svg') {
6989
8915
  fileName = fileName || 'ImageEditor';
@@ -7044,7 +8970,8 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
7044
8970
  this.upperCanvas.style.cursor = 'crosshair';
7045
8971
  if (Browser.isDevice) {
7046
8972
  var arcRadius = (7.5 * (ratio.width > ratio.height ? ratio.width : ratio.height)) / this.factor;
7047
- var endPoint = { x: this.lowerCanvas.width - this.pannEnd.startX, y: this.lowerCanvas.height - this.pannEnd.startY };
8973
+ var endPoint = { x: this.lowerCanvas.width - this.pannEnd.startX, y: this.lowerCanvas.height -
8974
+ this.pannEnd.startY };
7048
8975
  this.activeObj.activePoint = { startX: this.pannStart.startX + arcRadius, startY: this.pannStart.startY + arcRadius,
7049
8976
  endX: endPoint.x - arcRadius, endY: endPoint.y - arcRadius };
7050
8977
  this.activeObj.activePoint.width = this.activeObj.activePoint.endX - this.activeObj.activePoint.startX;
@@ -7097,7 +9024,7 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
7097
9024
  ImageEditor.prototype.freeHandDraw = function (value) {
7098
9025
  if (value) {
7099
9026
  this.togglePen = true;
7100
- this.upperCanvas.style.cursor = 'cross-hair';
9027
+ this.upperCanvas.style.cursor = 'crosshair';
7101
9028
  this.drawPen();
7102
9029
  }
7103
9030
  else {
@@ -7111,7 +9038,7 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
7111
9038
  *
7112
9039
  * @param {boolean} value - Specifies a value whether enable or disable freehand drawing.
7113
9040
  *
7114
- * @returns {void}.
9041
+ * @returns {void}.
7115
9042
  */
7116
9043
  ImageEditor.prototype.freehandDraw = function (value) {
7117
9044
  this.freeHandDraw(value);
@@ -7162,17 +9089,8 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
7162
9089
  this.redrawActObj();
7163
9090
  this.refreshActiveObj();
7164
9091
  this.upperContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
9092
+ this.lowerContext.filter = this.canvasFilter;
7165
9093
  this.upperCanvas.style.cursor = 'default';
7166
- var zoomState = void 0;
7167
- if (value === 3.75 || value === 1) {
7168
- zoomState = 0.1;
7169
- }
7170
- else if (value === -3.75) {
7171
- zoomState = -0.1;
7172
- }
7173
- else {
7174
- zoomState = value;
7175
- }
7176
9094
  if (this.degree !== 0) {
7177
9095
  this.inMemoryContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
7178
9096
  this.inMemoryContext.clearRect(0, 0, this.lowerCanvas.height, this.lowerCanvas.width);
@@ -7184,16 +9102,22 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
7184
9102
  this.lastX = this.lowerCanvas.width / 2;
7185
9103
  this.lastY = this.lowerCanvas.height / 2;
7186
9104
  }
7187
- if (value > 0) {
7188
- this.zoomImg(3.75);
9105
+ if (value === 1.1 || value === -1.1) {
9106
+ this.zoomImg(value);
7189
9107
  }
7190
9108
  else {
7191
- this.zoomImg(-3.75);
9109
+ if (value > 0) {
9110
+ this.zoomImg(3.75);
9111
+ }
9112
+ else {
9113
+ this.zoomImg(-3.75);
9114
+ }
7192
9115
  }
7193
9116
  this.refreshActiveObj();
7194
9117
  if (!isNullOrUndefined(activeObjShape)) {
7195
9118
  if (activeObjShape === 'custom') {
7196
- var endPoint = { x: this.lowerCanvas.width - this.pannEnd.startX, y: this.lowerCanvas.height - this.pannEnd.startY };
9119
+ var endPoint = { x: this.lowerCanvas.width - this.pannEnd.startX, y: this.lowerCanvas.height -
9120
+ this.pannEnd.startY };
7197
9121
  this.activeObj.activePoint = { startX: this.pannStart.startX, startY: this.pannStart.startY, endX: endPoint.x,
7198
9122
  endY: endPoint.y, width: endPoint.x - this.pannStart.startX, height: endPoint.y - this.pannStart.startY };
7199
9123
  this.updateActiveObject(this.calcRatio(), this.activeObj.activePoint, this.activeObj);
@@ -7204,10 +9128,6 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
7204
9128
  }
7205
9129
  this.refreshToolbar('main', true, true);
7206
9130
  }
7207
- if (!this.isUndoRedo) {
7208
- this.updateUndoRedoColl('zoom', zoomState, this.objColl);
7209
- }
7210
- this.isUndoRedo = false;
7211
9131
  var zoomOut = document.querySelector('#' + this.element.id + '_zoomOut');
7212
9132
  if (!isNullOrUndefined(zoomOut) && this.factor === 1) {
7213
9133
  zoomOut.classList.add('e-disabled');
@@ -7215,6 +9135,23 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
7215
9135
  else if (!isNullOrUndefined(zoomOut)) {
7216
9136
  zoomOut.classList.remove('e-disabled');
7217
9137
  }
9138
+ if (!this.togglePan) {
9139
+ this.callMainToolbar(false, true);
9140
+ }
9141
+ this.autoEnablePan();
9142
+ if (isNullOrUndefined(this.activeObj.activePoint) || this.activeObj.activePoint.width === 0) {
9143
+ this.refreshToolbar('main');
9144
+ }
9145
+ else {
9146
+ this.refreshToolbar('main', true, true);
9147
+ }
9148
+ var panBtn = this.element.querySelector('.e-img-pan .e-btn');
9149
+ if (!isNullOrUndefined(panBtn) && this.togglePan) {
9150
+ panBtn.classList.add('e-selected-btn');
9151
+ }
9152
+ else if (!isNullOrUndefined(panBtn)) {
9153
+ panBtn.classList.remove('e-selected-btn');
9154
+ }
7218
9155
  }
7219
9156
  };
7220
9157
  /**
@@ -7395,6 +9332,7 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
7395
9332
  else {
7396
9333
  isSelected = true;
7397
9334
  this.activeObj = obj;
9335
+ this.lowerContext.filter = this.canvasFilter;
7398
9336
  this.redrawShape(this.activeObj);
7399
9337
  if (this.activeObj.shape === 'text') {
7400
9338
  this.refreshToolbar('text');
@@ -7436,12 +9374,9 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
7436
9374
  break;
7437
9375
  }
7438
9376
  }
9377
+ this.lowerContext.filter = this.canvasFilter;
7439
9378
  this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
7440
- this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
7441
- for (var i = 0; i < this.objColl.length; i++) {
7442
- this.apply(this.objColl[i].shape, this.objColl[i]);
7443
- this.refreshActiveObj();
7444
- }
9379
+ this.redrawImgWithObj();
7445
9380
  this.refreshToolbar('main');
7446
9381
  };
7447
9382
  /**
@@ -7506,9 +9441,60 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
7506
9441
  canvasWrapper.style.height = this.element.offsetHeight - this.toolbarHeight - 1 + 'px';
7507
9442
  this.lowerCanvas.height = this.upperCanvas.height = this.element.offsetHeight - this.toolbarHeight - 1;
7508
9443
  }
9444
+ this.lowerContext.filter = this.canvasFilter;
7509
9445
  this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
7510
9446
  this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
7511
9447
  };
9448
+ /**
9449
+ * To apply the filters to an image
9450
+ *
9451
+ * @param {ImageFilterOptions } filterOption - Specifies the filter options to the image.
9452
+ * @returns {void}.
9453
+ */
9454
+ ImageEditor.prototype.applyImageFilter = function (filterOption) {
9455
+ if (this.initialAdjustmentValue === '') {
9456
+ this.initialAdjustmentValue = 'brightness(1) contrast(100%) hue-rotate(0deg) saturate(100%) opacity(1) blur(0px) sepia(0%) grayscale(0%) invert(0%)';
9457
+ }
9458
+ this.lowerContext.filter = this.initialAdjustmentValue;
9459
+ this.setFilter(filterOption.toString());
9460
+ };
9461
+ /**
9462
+ * To apply the filters to an image
9463
+ *
9464
+ * @param {ImageFinetuneOptions } finetuneOption - Specifies the finetune options to the image.
9465
+ * @param {number } value - Specifies the value for finetuning the image.
9466
+ * @returns {void}.
9467
+ *
9468
+ */
9469
+ ImageEditor.prototype.finetuneImage = function (finetuneOption, value) {
9470
+ if (this.initialAdjustmentValue === '') {
9471
+ this.initialAdjustmentValue = 'brightness(1) contrast(100%) hue-rotate(0deg) saturate(100%) opacity(1) blur(0px) sepia(0%) grayscale(0%) invert(0%)';
9472
+ }
9473
+ this.lowerContext.filter = this.initialAdjustmentValue;
9474
+ switch (finetuneOption) {
9475
+ case 'Brightness':
9476
+ this.setBrightness(value);
9477
+ break;
9478
+ case 'Contrast':
9479
+ this.setContrast(value);
9480
+ break;
9481
+ case 'Hue':
9482
+ this.setHue(value);
9483
+ break;
9484
+ case 'Saturation':
9485
+ this.setSaturation(value);
9486
+ break;
9487
+ case 'Opacity':
9488
+ this.setOpacity(value);
9489
+ break;
9490
+ case 'Blur':
9491
+ this.setBlur(value);
9492
+ break;
9493
+ case 'Exposure':
9494
+ this.setExposure(value);
9495
+ break;
9496
+ }
9497
+ };
7512
9498
  /**
7513
9499
  * To check whether the undo collection is empty or not.
7514
9500
  *
@@ -7561,7 +9547,8 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
7561
9547
  * @private
7562
9548
  */
7563
9549
  ImageEditor.prototype.getBlob = function (url) {
7564
- return null;
9550
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
9551
+ return url;
7565
9552
  };
7566
9553
  /**
7567
9554
  * To check whether the signature is empty or not.
@@ -7611,7 +9598,7 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
7611
9598
  /**
7612
9599
  * To save the signature with the given file type and file name.
7613
9600
  *
7614
- * @param {SignatureFileType} type - specify type of the file to be saved a signature.
9601
+ * @param {FileType} type - specify type of the file to be saved a signature.
7615
9602
  * @param {string} fileName - specify name of the file to be saved a signature.
7616
9603
  *
7617
9604
  * @returns {void}.
@@ -7634,9 +9621,10 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
7634
9621
  /**
7635
9622
  * Returns the persistence data for component.
7636
9623
  *
7637
- * @returns any.
9624
+ * @returns {any}.
7638
9625
  * @private
7639
9626
  */
9627
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
7640
9628
  ImageEditor.prototype.getLocalData = function () {
7641
9629
  return null;
7642
9630
  };
@@ -7692,6 +9680,12 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
7692
9680
  __decorate([
7693
9681
  Property(false)
7694
9682
  ], ImageEditor.prototype, "enablePersistence", void 0);
9683
+ __decorate([
9684
+ Complex({}, FinetuneSettings)
9685
+ ], ImageEditor.prototype, "finetuneSettings", void 0);
9686
+ __decorate([
9687
+ Property('')
9688
+ ], ImageEditor.prototype, "signatureValue", void 0);
7695
9689
  __decorate([
7696
9690
  Event()
7697
9691
  ], ImageEditor.prototype, "beforeSave", void 0);
@@ -7734,6 +9728,12 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
7734
9728
  __decorate([
7735
9729
  Event()
7736
9730
  ], ImageEditor.prototype, "toolbarItemClicked", void 0);
9731
+ __decorate([
9732
+ Event()
9733
+ ], ImageEditor.prototype, "imageFiltering", void 0);
9734
+ __decorate([
9735
+ Event()
9736
+ ], ImageEditor.prototype, "fineTuneValueChanging", void 0);
7737
9737
  ImageEditor = ImageEditor_1 = __decorate([
7738
9738
  NotifyPropertyChanges
7739
9739
  ], ImageEditor);
@@ -7748,5 +9748,5 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
7748
9748
  * ImageEditor all modules
7749
9749
  */
7750
9750
 
7751
- export { ImageEditor };
9751
+ export { FinetuneSettings, ImageEditor };
7752
9752
  //# sourceMappingURL=ej2-image-editor.es5.js.map