@syncfusion/ej2-image-editor 20.3.56 → 20.4.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/.eslintrc.json +16 -1
  2. package/CHANGELOG.md +5 -5
  3. package/README.md +65 -2
  4. package/dist/ej2-image-editor.umd.min.js +2 -2
  5. package/dist/ej2-image-editor.umd.min.js.map +1 -1
  6. package/dist/es6/ej2-image-editor.es2015.js +6191 -4168
  7. package/dist/es6/ej2-image-editor.es2015.js.map +1 -1
  8. package/dist/es6/ej2-image-editor.es5.js +2505 -474
  9. package/dist/es6/ej2-image-editor.es5.js.map +1 -1
  10. package/dist/global/ej2-image-editor.min.js +2 -2
  11. package/dist/global/ej2-image-editor.min.js.map +1 -1
  12. package/dist/global/index.d.ts +1 -1
  13. package/package.json +23 -24
  14. package/src/image-editor/image-editor-model.d.ts +114 -20
  15. package/src/image-editor/image-editor.d.ts +251 -33
  16. package/src/image-editor/image-editor.js +2505 -473
  17. package/styles/bootstrap-dark.css +36 -0
  18. package/styles/bootstrap.css +36 -0
  19. package/styles/bootstrap4.css +36 -0
  20. package/styles/bootstrap5-dark.css +36 -0
  21. package/styles/bootstrap5.css +36 -0
  22. package/styles/fabric-dark.css +36 -0
  23. package/styles/fabric.css +36 -0
  24. package/styles/fluent-dark.css +36 -0
  25. package/styles/fluent.css +36 -0
  26. package/styles/highcontrast-light.css +36 -0
  27. package/styles/highcontrast.css +36 -0
  28. package/styles/image-editor/_bootstrap-dark-definition.scss +1 -0
  29. package/styles/image-editor/_bootstrap-definition.scss +1 -0
  30. package/styles/image-editor/_bootstrap4-definition.scss +1 -0
  31. package/styles/image-editor/_bootstrap5-definition.scss +1 -0
  32. package/styles/image-editor/_fabric-dark-definition.scss +1 -0
  33. package/styles/image-editor/_fabric-definition.scss +1 -0
  34. package/styles/image-editor/_fluent-definition.scss +1 -0
  35. package/styles/image-editor/_fusionnew-definition.scss +1 -0
  36. package/styles/image-editor/_highcontrast-definition.scss +1 -0
  37. package/styles/image-editor/_highcontrast-light-definition.scss +1 -0
  38. package/styles/image-editor/_layout.scss +38 -0
  39. package/styles/image-editor/_material-dark-definition.scss +1 -0
  40. package/styles/image-editor/_material-definition.scss +1 -0
  41. package/styles/image-editor/_material3-definition.scss +1 -0
  42. package/styles/image-editor/_tailwind-definition.scss +1 -0
  43. package/styles/image-editor/_theme.scss +11 -0
  44. package/styles/image-editor/bootstrap-dark.css +36 -0
  45. package/styles/image-editor/bootstrap.css +36 -0
  46. package/styles/image-editor/bootstrap4.css +36 -0
  47. package/styles/image-editor/bootstrap5-dark.css +36 -0
  48. package/styles/image-editor/bootstrap5.css +36 -0
  49. package/styles/image-editor/fabric-dark.css +36 -0
  50. package/styles/image-editor/fabric.css +36 -0
  51. package/styles/image-editor/fluent-dark.css +36 -0
  52. package/styles/image-editor/fluent.css +36 -0
  53. package/styles/image-editor/highcontrast-light.css +36 -0
  54. package/styles/image-editor/highcontrast.css +36 -0
  55. package/styles/image-editor/material-dark.css +36 -0
  56. package/styles/image-editor/material.css +36 -0
  57. package/styles/image-editor/tailwind-dark.css +36 -0
  58. package/styles/image-editor/tailwind.css +36 -0
  59. package/styles/material-dark.css +36 -0
  60. package/styles/material.css +36 -0
  61. package/styles/tailwind-dark.css +36 -0
  62. package/styles/tailwind.css +36 -0
@@ -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,30 @@ 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;
148
+ _this.imageFileName = '';
106
149
  return _this;
107
150
  }
108
151
  ImageEditor_1 = ImageEditor;
@@ -132,8 +175,28 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
132
175
  Crop: 'Crop',
133
176
  ZoomIn: 'Zoom In',
134
177
  ZoomOut: 'Zoom Out',
178
+ Undo: 'Undo',
179
+ Redo: 'Redo',
135
180
  Transform: 'Transform',
136
181
  Annotation: 'Annotation',
182
+ Finetune: 'Finetune',
183
+ Brightness: 'Brightness',
184
+ Contrast: 'Contrast',
185
+ Hue: 'Hue',
186
+ Saturation: 'Saturation',
187
+ Opacity: 'Opacity',
188
+ Blur: 'Blur',
189
+ Sharpen: 'Sharpen',
190
+ Exposure: 'Exposure',
191
+ Filter: 'Filter',
192
+ Default: 'Default',
193
+ Chrome: 'Chrome',
194
+ Cold: 'Cold',
195
+ Warm: 'Warm',
196
+ Grayscale: 'Grayscale',
197
+ BlackAndWhite: 'Black and White',
198
+ Sepia: 'Sepia',
199
+ Invert: 'Invert',
137
200
  Text: 'Add Text',
138
201
  Pen: 'Pen',
139
202
  Reset: 'Reset',
@@ -161,7 +224,6 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
161
224
  Ellipse: 'Ellipse',
162
225
  Rectangle: 'Rectangle',
163
226
  Line: 'Line',
164
- Default: 'Default',
165
227
  Bold: 'Bold',
166
228
  Italic: 'Italic',
167
229
  BoldItalic: 'Bold Italic',
@@ -170,7 +232,8 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
170
232
  Medium: 'Medium',
171
233
  Large: 'Large',
172
234
  XLarge: 'X-Large',
173
- ABC: 'ABC'
235
+ ABC: 'ABC',
236
+ Browse: 'Browse'
174
237
  };
175
238
  this.l10n = new L10n('image-editor', this.defaultLocale, this.locale);
176
239
  };
@@ -247,6 +310,12 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
247
310
  this.upperContext.fillStyle = this.themeColl[this.theme]['secondaryColor'];
248
311
  }
249
312
  break;
313
+ case 'finetuneSettings':
314
+ if (newProperties.finetuneSettings) {
315
+ this.finetuneSettings = newProperties.finetuneSettings;
316
+ this.updateFinetunes();
317
+ }
318
+ break;
250
319
  }
251
320
  }
252
321
  };
@@ -267,13 +336,17 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
267
336
  this.trigger('destroyed');
268
337
  };
269
338
  ImageEditor.prototype.initialize = function () {
339
+ this.updateFinetunes();
270
340
  this.createToolbar();
341
+ this.createContextualToolbar();
271
342
  this.createCanvas();
272
343
  this.wireEvent();
273
344
  this.updateContext(this.lowerContext);
274
345
  this.updateContext(this.upperContext);
275
346
  this.pannStart = { startX: 0, startY: 0, width: 0, height: 0 };
276
347
  this.pannEnd = { startX: 0, startY: 0, width: 0, height: 0 };
348
+ this.lowerContext.filter = this.canvasFilter = this.initialAdjustmentValue = this.adjustmentValue = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
349
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
277
350
  if (this.cssClass) {
278
351
  addClass([this.element], this.cssClass.split(' '));
279
352
  }
@@ -283,6 +356,39 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
283
356
  });
284
357
  }
285
358
  };
359
+ ImageEditor.prototype.updateFinetunes = function () {
360
+ if (this.finetuneSettings) {
361
+ if (this.finetuneSettings.brightness) {
362
+ this.adjustmentLevel.brightness = this.finetuneSettings.brightness.defaultValue;
363
+ this.tempAdjustmentLevel.brightness = this.finetuneSettings.brightness.defaultValue;
364
+ }
365
+ if (this.finetuneSettings.contrast) {
366
+ this.adjustmentLevel.contrast = this.finetuneSettings.contrast.defaultValue;
367
+ this.tempAdjustmentLevel.contrast = this.finetuneSettings.contrast.defaultValue;
368
+ }
369
+ if (this.finetuneSettings.hue) {
370
+ this.adjustmentLevel.hue = this.finetuneSettings.hue.defaultValue;
371
+ this.tempAdjustmentLevel.hue = this.finetuneSettings.hue.defaultValue;
372
+ }
373
+ if (this.finetuneSettings.saturation) {
374
+ this.adjustmentLevel.saturation = this.finetuneSettings.saturation.defaultValue;
375
+ this.tempAdjustmentLevel.saturation = this.finetuneSettings.saturation.defaultValue;
376
+ }
377
+ if (this.finetuneSettings.exposure) {
378
+ this.adjustmentLevel.exposure = this.finetuneSettings.exposure.defaultValue;
379
+ this.tempAdjustmentLevel.exposure = this.finetuneSettings.exposure.defaultValue;
380
+ }
381
+ if (this.finetuneSettings.opacity) {
382
+ this.adjustmentLevel.opacity = this.finetuneSettings.opacity.defaultValue;
383
+ this.tempAdjustmentLevel.opacity = this.finetuneSettings.opacity.defaultValue;
384
+ }
385
+ if (this.finetuneSettings.blur) {
386
+ this.adjustmentLevel.blur = this.finetuneSettings.blur.defaultValue;
387
+ this.tempAdjustmentLevel.blur = this.finetuneSettings.blur.defaultValue;
388
+ }
389
+ this.isInitialLoading = true;
390
+ }
391
+ };
286
392
  /**
287
393
  *
288
394
  * This Method will add events to component (element, event, method, current reference)
@@ -305,7 +411,7 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
305
411
  EventHandler.add(this.upperCanvas, 'dblclick', this.findTextPoint, this);
306
412
  EventHandler.add(this.textBox, 'mousedown', this.findTextPoint, this);
307
413
  window.addEventListener('resize', this.windowResizeHandler.bind(this));
308
- if ((!Browser.isIos && Browser.info.name !== 'safari')) {
414
+ if (!Browser.isIos && Browser.info.name !== 'safari' && screen && screen.orientation) {
309
415
  screen.orientation.addEventListener('change', this.screenOrientation.bind(this));
310
416
  }
311
417
  };
@@ -327,9 +433,17 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
327
433
  EventHandler.remove(this.lowerCanvas, 'mouseup', this.canvasMouseUpHandler);
328
434
  EventHandler.remove(document, 'mouseup', this.canvasMouseUpHandler);
329
435
  };
436
+ ImageEditor.prototype.initializeFilter = function () {
437
+ this.setBrightness(this.adjustmentLevel.brightness);
438
+ this.setContrast(this.adjustmentLevel.contrast);
439
+ this.setHue(this.adjustmentLevel.hue);
440
+ this.setSaturation(this.adjustmentLevel.saturation);
441
+ this.setExposure(this.adjustmentLevel.exposure);
442
+ this.setOpacity(this.adjustmentLevel.opacity);
443
+ this.setBlur(this.adjustmentLevel.blur);
444
+ };
330
445
  ImageEditor.prototype.destroySubComponents = function () {
331
446
  var inputElement = this.element.querySelectorAll('input.e-control');
332
- var divElement = this.element.querySelectorAll('div.e-control:not(.e-handle)');
333
447
  var btnElement = this.element.querySelectorAll('button.e-control');
334
448
  for (var i = 0, len = inputElement.length; i < len; i++) {
335
449
  if (inputElement[i].classList.contains('e-color-picker')) {
@@ -460,6 +574,58 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
460
574
  this.toolbarHeight = 0;
461
575
  }
462
576
  };
577
+ ImageEditor.prototype.createContextualToolbar = function () {
578
+ if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.length > 0)) {
579
+ this.element.appendChild(this.createElement('div', { id: this.element.id + '_contextualToolbarArea',
580
+ className: 'e-contextual-toolbar-wrapper e-hide', attrs: { style: 'position: absolute;' }
581
+ }));
582
+ var toolbarArea = document.getElementById(this.element.id + '_contextualToolbarArea');
583
+ var toolbar_2 = this.createElement('div', { id: this.element.id + '_contextualToolbar' });
584
+ toolbarArea.appendChild(toolbar_2);
585
+ }
586
+ };
587
+ ImageEditor.prototype.updateContextualToolbar = function (type, cType) {
588
+ if (this.toolbarTemplate) {
589
+ this.toolbarTemplateFn();
590
+ }
591
+ else {
592
+ var toolbarArea = this.element.querySelector('#' + this.element.id + '_toolbarArea');
593
+ var contextualToolbarArea = this.element.querySelector('#' + this.element.id + '_contextualToolbarArea');
594
+ if (!isNullOrUndefined(toolbarArea) && !isNullOrUndefined(contextualToolbarArea)) {
595
+ contextualToolbarArea.classList.remove('e-hide');
596
+ contextualToolbarArea.style.left = toolbarArea.offsetLeft + 'px';
597
+ }
598
+ if (type === 'filter') {
599
+ if (!isNullOrUndefined(document.getElementById(this.element.id + '_toolbar')) && this.defToolbarItems.length > 0) {
600
+ getComponent(document.getElementById(this.element.id + '_toolbar'), 'toolbar').destroy();
601
+ }
602
+ if (Browser.isDevice) {
603
+ this.initToolbarItem(false, true, true);
604
+ }
605
+ else {
606
+ this.initToolbarItem(true);
607
+ }
608
+ this.refreshSlider();
609
+ this.initFilterToolbarItem();
610
+ }
611
+ else {
612
+ if (!isNullOrUndefined(document.querySelector('#' + this.element.id + '_contextualToolbar'))
613
+ && document.querySelector('#' + this.element.id + '_contextualToolbar').classList.contains('e-control')) {
614
+ getComponent(document.getElementById(this.element.id + '_contextualToolbar'), 'toolbar').destroy();
615
+ }
616
+ this.refreshSlider();
617
+ this.renderSlider(cType);
618
+ }
619
+ if (Browser.isDevice) {
620
+ var cHt = contextualToolbarArea.offsetHeight;
621
+ var ht = this.element.querySelector('#' + this.element.id + '_canvasWrapper').offsetHeight;
622
+ contextualToolbarArea.style.top = this.toolbarHeight + ht - cHt + 'px';
623
+ }
624
+ else {
625
+ contextualToolbarArea.style.top = this.toolbarHeight + 1 + 'px';
626
+ }
627
+ }
628
+ };
463
629
  ImageEditor.prototype.createBottomToolbar = function () {
464
630
  if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.length > 0)) {
465
631
  this.element.appendChild(this.createElement('div', {
@@ -496,8 +662,8 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
496
662
  }, '#' + this.element.id + '_bottomToolbar');
497
663
  if (this.defToolbarItems.length > 0 && (!isNullOrUndefined(document.getElementById(this.element.id + '_bottomToolbar')))) {
498
664
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
499
- var toolbar_2 = getComponent(this.element.id + '_bottomToolbar', 'toolbar');
500
- toolbar_2.refreshOverflow();
665
+ var toolbar_3 = getComponent(this.element.id + '_bottomToolbar', 'toolbar');
666
+ toolbar_3.refreshOverflow();
501
667
  }
502
668
  }
503
669
  }
@@ -600,6 +766,14 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
600
766
  template: '<button id="' + this.element.id + '_transformBtn"></button>'
601
767
  });
602
768
  }
769
+ if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Finetune') > -1)) {
770
+ toolbarItems.push({ id: this.element.id + '_adjustment', prefixIcon: 'e-icons e-adjustment', cssClass: 'top-icon e-adjustment',
771
+ tooltipText: this.l10n.getConstant('Finetune'), align: 'Center' });
772
+ }
773
+ if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Filter') > -1)) {
774
+ toolbarItems.push({ id: this.element.id + '_filter', prefixIcon: 'e-icons e-filters', cssClass: 'top-icon e-filters',
775
+ tooltipText: this.l10n.getConstant('Filter'), align: 'Center' });
776
+ }
603
777
  var tempToolbarItems = this.processToolbar('center');
604
778
  for (var i = 0, len = tempToolbarItems.length; i < len; i++) {
605
779
  toolbarItems.push(tempToolbarItems[i]);
@@ -707,8 +881,8 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
707
881
  }
708
882
  if (this.isToolbar() && (!isNullOrUndefined(document.getElementById(this.element.id + '_toolbar')))) {
709
883
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
710
- var toolbar_3 = getComponent(this.element.id + '_toolbar', 'toolbar');
711
- toolbar_3.refreshOverflow();
884
+ var toolbar_4 = getComponent(this.element.id + '_toolbar', 'toolbar');
885
+ toolbar_4.refreshOverflow();
712
886
  }
713
887
  }
714
888
  };
@@ -805,7 +979,7 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
805
979
  items.push({ text: this.l10n.getConstant('Custom'), id: 'custom', iconCss: 'e-icons e-custom' });
806
980
  }
807
981
  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' });
982
+ items.push({ text: this.l10n.getConstant('Circle'), id: 'circle', iconCss: 'e-icons e-circle' });
809
983
  }
810
984
  if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('SquareSelection') > -1)) {
811
985
  items.push({ text: this.l10n.getConstant('Square'), id: 'square', iconCss: 'e-icons e-square' });
@@ -888,7 +1062,7 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
888
1062
  }
889
1063
  };
890
1064
  ImageEditor.prototype.cropSelect = function (args) {
891
- var text = args.item.text;
1065
+ var text = args.item.id;
892
1066
  this.select(text);
893
1067
  this.refreshToolbar('main', true, true);
894
1068
  };
@@ -994,9 +1168,16 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
994
1168
  modeSwitcher: false, noColor: true, value: '',
995
1169
  showButtons: false, mode: 'Palette', cssClass: 'e-shape-fill-color',
996
1170
  change: function (args) {
1171
+ _this.pushActItemIntoObj();
1172
+ var objColl = extend([], _this.objColl, [], true);
1173
+ _this.objColl.pop();
997
1174
  proxy.activeObj.strokeSettings.fillColor = args.currentValue.hex;
998
1175
  proxy.strokeSettings.fillColor = proxy.activeObj.strokeSettings.fillColor;
999
- proxy.redrawShape(_this.activeObj);
1176
+ _this.objColl.push(_this.activeObj);
1177
+ proxy.undoRedoColl.push({ operation: 'shapeTransform', value: null,
1178
+ currentObj: extend([], proxy.objColl, [], true), previousObj: objColl, factor: proxy.factor,
1179
+ sharpen: proxy.adjustmentLevel.sharpen, bw: proxy.adjustmentLevel.bw });
1180
+ proxy.redrawShape(proxy.objColl[proxy.objColl.length - 1]);
1000
1181
  if (args.currentValue.rgba === '') {
1001
1182
  fillDDB_1.element.children[0].classList.add('e-nocolor-item');
1002
1183
  }
@@ -1029,10 +1210,17 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
1029
1210
  modeSwitcher: false, noColor: false, value: '#fff',
1030
1211
  showButtons: false, mode: 'Palette', cssClass: 'e-shape-stroke-color',
1031
1212
  change: function (args) {
1213
+ _this.pushActItemIntoObj();
1214
+ var objColl = extend([], _this.objColl, [], true);
1215
+ _this.objColl.pop();
1032
1216
  proxy.activeObj.strokeSettings.strokeColor = args.currentValue.hex;
1033
1217
  proxy.strokeSettings.strokeColor = proxy.activeObj.strokeSettings.strokeColor;
1034
1218
  if (!proxy.togglePen) {
1035
- proxy.redrawShape(_this.activeObj);
1219
+ _this.objColl.push(_this.activeObj);
1220
+ proxy.undoRedoColl.push({ operation: 'shapeTransform', value: null,
1221
+ currentObj: extend([], proxy.objColl, [], true), previousObj: objColl, factor: proxy.factor,
1222
+ sharpen: proxy.adjustmentLevel.sharpen, bw: proxy.adjustmentLevel.bw });
1223
+ proxy.redrawShape(proxy.objColl[proxy.objColl.length - 1]);
1036
1224
  }
1037
1225
  strokeDDB_1.element.children[0].style.backgroundColor = args.currentValue.rgba;
1038
1226
  strokeDDB_1.toggle();
@@ -1082,6 +1270,9 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
1082
1270
  }
1083
1271
  },
1084
1272
  select: function (args) {
1273
+ _this.pushActItemIntoObj();
1274
+ var objColl = extend([], _this.objColl, [], true);
1275
+ _this.objColl.pop();
1085
1276
  spanElem_1.textContent = args.item.text;
1086
1277
  _this.activeObj.strokeSettings.strokeWidth = parseInt(args.item.id, 10);
1087
1278
  if (_this.lowerCanvas.width > _this.lowerCanvas.height) {
@@ -1091,19 +1282,23 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
1091
1282
  _this.activeObj.strokeSettings.strokeWidth *= ((ratio.height + ratio.width) / _this.factor);
1092
1283
  }
1093
1284
  _this.strokeSettings.strokeWidth = _this.activeObj.strokeSettings.strokeWidth;
1094
- _this.redrawShape(_this.activeObj);
1285
+ _this.objColl.push(_this.activeObj);
1286
+ _this.undoRedoColl.push({ operation: 'shapeTransform', value: null,
1287
+ currentObj: extend([], _this.objColl, [], true), previousObj: objColl, factor: _this.factor,
1288
+ sharpen: _this.adjustmentLevel.sharpen, bw: _this.adjustmentLevel.bw });
1289
+ _this.redrawShape(_this.objColl[_this.objColl.length - 1]);
1095
1290
  if (Browser.isDevice) {
1096
1291
  if (!isNullOrUndefined(document.getElementById(_this.element.id + '_bottomToolbar'))) {
1097
1292
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
1098
- var toolbar_4 = getComponent(_this.element.id + '_bottomToolbar', 'toolbar');
1099
- toolbar_4.refreshOverflow();
1293
+ var toolbar_5 = getComponent(_this.element.id + '_bottomToolbar', 'toolbar');
1294
+ toolbar_5.refreshOverflow();
1100
1295
  }
1101
1296
  }
1102
1297
  else {
1103
1298
  if (!isNullOrUndefined(document.getElementById(_this.element.id + '_toolbar'))) {
1104
1299
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
1105
- var toolbar_5 = getComponent(_this.element.id + '_toolbar', 'toolbar');
1106
- toolbar_5.refreshOverflow();
1300
+ var toolbar_6 = getComponent(_this.element.id + '_toolbar', 'toolbar');
1301
+ toolbar_6.refreshOverflow();
1107
1302
  }
1108
1303
  }
1109
1304
  }
@@ -1219,17 +1414,26 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
1219
1414
  modeSwitcher: false, value: '#fff',
1220
1415
  showButtons: false, mode: 'Palette', cssClass: 'e-text-fontt-color',
1221
1416
  change: function (args) {
1417
+ _this.pushActItemIntoObj();
1418
+ _this.objColl.pop();
1222
1419
  if (proxy.textBox.style.display === 'none') {
1223
1420
  proxy.strokeSettings.strokeColor = proxy.activeObj.strokeSettings.strokeColor = args.currentValue.hex;
1224
1421
  if (!proxy.togglePen) {
1225
- proxy.redrawShape(_this.activeObj);
1422
+ _this.objColl.push(_this.activeObj);
1423
+ proxy.redrawShape(proxy.objColl[proxy.objColl.length - 1]);
1226
1424
  }
1227
1425
  }
1228
1426
  else if (proxy.textBox.style.display === 'block') {
1229
1427
  proxy.textBox.style.color = args.currentValue.hex;
1428
+ var temp = proxy.activeObj.strokeSettings.strokeColor;
1429
+ proxy.activeObj.strokeSettings.strokeColor = args.currentValue.hex;
1430
+ _this.objColl.push(_this.activeObj);
1431
+ _this.objColl.pop();
1432
+ proxy.activeObj.strokeSettings.strokeColor = temp;
1230
1433
  }
1231
1434
  else if (!proxy.togglePen) {
1232
- proxy.redrawShape(_this.activeObj);
1435
+ _this.objColl.push(_this.activeObj);
1436
+ proxy.redrawShape(proxy.objColl[proxy.objColl.length - 1]);
1233
1437
  }
1234
1438
  strokeDDB_2.element.children[0].style.backgroundColor = args.currentValue.rgba;
1235
1439
  strokeDDB_2.toggle();
@@ -1251,6 +1455,17 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
1251
1455
  = '#fff';
1252
1456
  }
1253
1457
  };
1458
+ ImageEditor.prototype.pushActItemIntoObj = function () {
1459
+ if (this.textBox.style.display === 'none') {
1460
+ this.objColl.push(this.activeObj);
1461
+ }
1462
+ else {
1463
+ var temp = extend({}, this.activeObj, {}, true);
1464
+ this.setTextBoxStylesToActObj();
1465
+ this.objColl.push(this.activeObj);
1466
+ this.activeObj = temp;
1467
+ }
1468
+ };
1254
1469
  ImageEditor.prototype.createTextBtn = function (items) {
1255
1470
  var _this = this;
1256
1471
  var ratio = this.calcRatio();
@@ -1288,6 +1503,8 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
1288
1503
  + '"' + ']').classList.add('e-selected-btn');
1289
1504
  },
1290
1505
  select: function (args) {
1506
+ _this.pushActItemIntoObj();
1507
+ _this.objColl.pop();
1291
1508
  spanElem_2.textContent = args.item.text;
1292
1509
  if (Browser.isDevice) {
1293
1510
  spanElem_2.setAttribute('style', 'font-family:' + args.item.id);
@@ -1295,10 +1512,13 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
1295
1512
  if (_this.textBox.style.display === 'block') {
1296
1513
  var temp = _this.activeObj.textSettings.fontFamily;
1297
1514
  _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';
1515
+ _this.redrawText(ratio);
1516
+ _this.objColl.push(_this.activeObj);
1517
+ _this.objColl.pop();
1518
+ _this.upperContext.clearRect(0, 0, _this.upperCanvas.width, _this.upperCanvas.height);
1519
+ var width = _this.activeObj.activePoint.width +
1520
+ _this.activeObj.textSettings.fontSize * 0.25;
1521
+ _this.textBox.style.width = width / ratio.width + 'px';
1302
1522
  _this.textBox.style.fontFamily = _this.toPascalCase(args.item.id);
1303
1523
  _this.activeObj.textSettings.fontFamily = temp;
1304
1524
  _this.updateFontStyles();
@@ -1306,7 +1526,8 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
1306
1526
  else {
1307
1527
  _this.textSettings.fontFamily = _this.activeObj.textSettings.fontFamily = _this.toPascalCase(args.item.id);
1308
1528
  _this.redrawText(ratio);
1309
- _this.redrawShape(_this.activeObj);
1529
+ _this.objColl.push(_this.activeObj);
1530
+ _this.redrawShape(_this.objColl[_this.objColl.length - 1]);
1310
1531
  }
1311
1532
  }
1312
1533
  });
@@ -1405,10 +1626,14 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
1405
1626
  args.element.querySelector('[aria-label *= ' + '"' + activeBtn + '"' + ']').classList.add('e-selected-btn');
1406
1627
  },
1407
1628
  select: function (args) {
1629
+ _this.pushActItemIntoObj();
1630
+ _this.objColl.pop();
1408
1631
  fontSizeSpanElem_1.textContent = args.item.text;
1409
1632
  if (_this.textBox.style.display === 'block') {
1410
1633
  var temp = _this.activeObj.textSettings.fontSize;
1411
1634
  _this.activeObj.textSettings.fontSize = parseInt(_this.fontSizeColl[(parseInt(args.item.text, 10) - 1)].text, 10);
1635
+ _this.objColl.push(_this.activeObj);
1636
+ _this.objColl.pop();
1412
1637
  var textStyle = '';
1413
1638
  if (_this.textBox.style.fontWeight === 'bold') {
1414
1639
  textStyle = 'bold ';
@@ -1440,11 +1665,13 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
1440
1665
  var text = _this.getMaxText();
1441
1666
  var width = _this.upperContext.measureText(text).width +
1442
1667
  _this.activeObj.textSettings.fontSize * 0.5;
1443
- var height = rows.length * (_this.activeObj.textSettings.fontSize + _this.activeObj.textSettings.fontSize * 0.25);
1668
+ var height = rows.length * (_this.activeObj.textSettings.fontSize +
1669
+ _this.activeObj.textSettings.fontSize * 0.25);
1444
1670
  _this.setTextSelection(width, height);
1445
1671
  _this.updateActiveObject(ratio, _this.activeObj.activePoint, _this.activeObj);
1446
- _this.redrawShape(_this.activeObj);
1447
1672
  _this.redrawText(ratio);
1673
+ _this.objColl.push(_this.activeObj);
1674
+ _this.redrawShape(_this.objColl[_this.objColl.length - 1]);
1448
1675
  }
1449
1676
  }
1450
1677
  });
@@ -1495,14 +1722,43 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
1495
1722
  this.activeObj.textSettings.italic = tempItalic;
1496
1723
  return width;
1497
1724
  };
1725
+ ImageEditor.prototype.updateObjColl = function (item) {
1726
+ var tempBold = this.activeObj.textSettings.bold;
1727
+ var tempItalic = this.activeObj.textSettings.italic;
1728
+ switch (item) {
1729
+ case 'default':
1730
+ this.activeObj.textSettings.bold = false;
1731
+ this.activeObj.textSettings.italic = false;
1732
+ break;
1733
+ case 'bold':
1734
+ this.activeObj.textSettings.bold = true;
1735
+ this.activeObj.textSettings.italic = false;
1736
+ break;
1737
+ case 'italic':
1738
+ this.activeObj.textSettings.bold = false;
1739
+ this.activeObj.textSettings.italic = true;
1740
+ break;
1741
+ case 'bolditalic':
1742
+ this.activeObj.textSettings.bold = true;
1743
+ this.activeObj.textSettings.italic = true;
1744
+ break;
1745
+ }
1746
+ this.objColl.push(this.activeObj);
1747
+ this.objColl.pop();
1748
+ this.activeObj.textSettings.bold = tempBold;
1749
+ this.activeObj.textSettings.italic = tempItalic;
1750
+ };
1498
1751
  ImageEditor.prototype.applyFontStyle = function (item, ratio) {
1752
+ this.pushActItemIntoObj();
1753
+ this.objColl.pop();
1499
1754
  switch (item) {
1500
1755
  case 'default':
1501
1756
  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';
1757
+ var width = this.getTextAreaWidth(item) / ratio.width;
1758
+ this.textBox.style.width = width + 'px';
1504
1759
  this.textBox.style.fontWeight = 'normal';
1505
1760
  this.textBox.style.fontStyle = 'normal';
1761
+ this.updateObjColl(item);
1506
1762
  }
1507
1763
  else {
1508
1764
  this.textSettings.bold = this.activeObj.textSettings.bold = false;
@@ -1512,10 +1768,11 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
1512
1768
  break;
1513
1769
  case 'bold':
1514
1770
  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';
1771
+ var width = this.getTextAreaWidth(item) / ratio.width;
1772
+ this.textBox.style.width = width + 'px';
1517
1773
  this.textBox.style.fontWeight = 'bold';
1518
1774
  this.textBox.style.fontStyle = 'normal';
1775
+ this.updateObjColl(item);
1519
1776
  }
1520
1777
  else {
1521
1778
  this.textSettings.bold = this.activeObj.textSettings.bold = true;
@@ -1525,10 +1782,11 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
1525
1782
  break;
1526
1783
  case 'italic':
1527
1784
  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';
1785
+ var width = this.getTextAreaWidth(item) / ratio.width;
1786
+ this.textBox.style.width = width + 'px';
1530
1787
  this.textBox.style.fontWeight = 'normal';
1531
1788
  this.textBox.style.fontStyle = 'italic';
1789
+ this.updateObjColl(item);
1532
1790
  }
1533
1791
  else {
1534
1792
  this.textSettings.bold = this.activeObj.textSettings.bold = false;
@@ -1538,10 +1796,11 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
1538
1796
  break;
1539
1797
  case 'bolditalic':
1540
1798
  if (this.textBox.style.display === 'block') {
1541
- var width = this.getTextAreaWidth(item);
1542
- this.textBox.style.width = (width / ratio.width) + 'px';
1799
+ var width = this.getTextAreaWidth(item) / ratio.width;
1800
+ this.textBox.style.width = width + 'px';
1543
1801
  this.textBox.style.fontWeight = 'bold';
1544
1802
  this.textBox.style.fontStyle = 'italic';
1803
+ this.updateObjColl(item);
1545
1804
  }
1546
1805
  else {
1547
1806
  this.textSettings.bold = this.activeObj.textSettings.bold = true;
@@ -1569,12 +1828,25 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
1569
1828
  this.createLeftToolbarControls();
1570
1829
  if (this.defToolbarItems.length > 0 && (!isNullOrUndefined(document.getElementById(this.element.id + '_toolbar')))) {
1571
1830
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
1572
- var toolbar_6 = getComponent(this.element.id + '_toolbar', 'toolbar');
1573
- toolbar_6.refreshOverflow();
1831
+ var toolbar_7 = getComponent(this.element.id + '_toolbar', 'toolbar');
1832
+ toolbar_7.refreshOverflow();
1833
+ }
1834
+ };
1835
+ ImageEditor.prototype.contextualToolbarClicked = function (args) {
1836
+ var selEle = this.element.querySelector('.e-contextual-toolbar-wrapper .e-toolbar-item.e-selected');
1837
+ if (selEle) {
1838
+ selEle.classList.remove('e-selected');
1574
1839
  }
1840
+ document.getElementById(args.item.id + 'Canvas').parentElement.parentElement.classList.add('e-selected');
1841
+ this.currObjType.isFiltered = true;
1842
+ var type = args.item.id.replace(this.element.id, '').split('_')[1];
1843
+ var imageFiltering = { filter: this.toPascalCase(type) };
1844
+ this.trigger('imageFiltering', imageFiltering);
1845
+ this.setFilter(type.toLowerCase());
1846
+ this.currentFilter = args.item.id;
1575
1847
  };
1576
1848
  ImageEditor.prototype.defToolbarClicked = function (args) {
1577
- var ratio = this.calcRatio();
1849
+ this.element.querySelector('.e-contextual-toolbar-wrapper').classList.add('e-hide');
1578
1850
  var zoomIn;
1579
1851
  var type = args.item.id.replace(this.element.id + '_', '').toLowerCase();
1580
1852
  var imageEditorObj = getInstance(document.getElementById(this.element.id), ImageEditor_1);
@@ -1593,61 +1865,23 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
1593
1865
  if (!this.disabled) {
1594
1866
  switch (type) {
1595
1867
  case 'zoomin':
1868
+ this.currObjType.isFiltered = false;
1596
1869
  if (this.togglePen) {
1597
1870
  this.currObjType.isZoomed = true;
1598
1871
  this.freeHandDraw(false);
1599
1872
  }
1600
1873
  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
1874
  break;
1622
1875
  case 'zoomout':
1876
+ this.currObjType.isFiltered = false;
1623
1877
  if (this.togglePen) {
1624
1878
  this.currObjType.isZoomed = true;
1625
1879
  this.freeHandDraw(false);
1626
1880
  }
1627
1881
  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
1882
  break;
1649
1883
  case 'pan':
1650
- this.currObjType.isCustomCrop = false;
1884
+ this.currObjType.isCustomCrop = this.currObjType.isFiltered = false;
1651
1885
  if (isCropSelection) {
1652
1886
  this.currObjType.isCustomCrop = false;
1653
1887
  this.refreshActiveObj();
@@ -1656,11 +1890,13 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
1656
1890
  }
1657
1891
  if (this.togglePan) {
1658
1892
  this.cancelPan();
1893
+ this.disablePan = true;
1659
1894
  }
1660
1895
  else {
1661
1896
  panBtn = this.element.querySelector('.e-img-pan .e-btn');
1662
1897
  panBtn.classList.add('e-selected-btn');
1663
1898
  imageEditorObj.pan(true);
1899
+ this.disablePan = false;
1664
1900
  }
1665
1901
  zoomIn = document.querySelector('#' + this.element.id + '_zoomIn');
1666
1902
  if (!isNullOrUndefined(zoomIn) && this.factor >= 8) {
@@ -1678,46 +1914,113 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
1678
1914
  this.activeObj.strokeSettings = this.tempStrokeSettings;
1679
1915
  this.activeObj.textSettings = this.tempTextSettings;
1680
1916
  }
1917
+ else if (!isNullOrUndefined(document.querySelector('#' + this.element.id + '_sliderWrapper')) ||
1918
+ this.currObjType.isFiltered) {
1919
+ this.lowerContext.filter = this.adjustmentValue = this.initialAdjustmentValue = this.tempAdjustmentValue;
1920
+ this.currentFilter = this.tempFilter;
1921
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
1922
+ this.redrawImgWithObj();
1923
+ this.currObjType.isFiltered = false;
1924
+ if (this.adjustmentLevel.sharpen || this.adjustmentLevel.bw) {
1925
+ if (this.adjustmentLevel.sharpen) {
1926
+ this.setSharpness(false);
1927
+ }
1928
+ else if (this.adjustmentLevel.bw) {
1929
+ this.setBlackAndWhiteFilter(false);
1930
+ }
1931
+ var tempFilter = this.lowerContext.filter;
1932
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
1933
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
1934
+ for (var j = 0; j < this.objColl.length; j++) {
1935
+ this.apply(this.objColl[j].shape, this.objColl[j]);
1936
+ this.refreshActiveObj();
1937
+ }
1938
+ this.lowerContext.filter = tempFilter;
1939
+ }
1940
+ this.adjustmentLevel = extend({}, this.tempAdjustmentLevel, {}, true);
1941
+ if (this.currentFilter === this.element.id + '_sharpen' || this.currentFilter === this.element.id + '_blackandwhite'
1942
+ || this.tempSharpenFilter || this.tempBWFilter) {
1943
+ if (this.currentFilter === this.element.id + '_sharpen' || this.tempSharpenFilter) {
1944
+ this.setSharpness(true);
1945
+ }
1946
+ else if (this.currentFilter === this.element.id + '_blackandwhite' || this.tempBWFilter) {
1947
+ this.setBlackAndWhiteFilter(true);
1948
+ }
1949
+ var tempFilter = this.lowerContext.filter;
1950
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
1951
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
1952
+ for (var j = 0; j < this.objColl.length; j++) {
1953
+ this.apply(this.objColl[j].shape, this.objColl[j]);
1954
+ this.refreshActiveObj();
1955
+ }
1956
+ this.lowerContext.filter = tempFilter;
1957
+ this.tempSharpenFilter = this.tempBWFilter = false;
1958
+ }
1959
+ this.element.querySelector('.e-contextual-toolbar-wrapper').classList.add('e-hide');
1960
+ }
1681
1961
  this.cancelItems();
1682
1962
  break;
1683
1963
  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);
1964
+ this.okBtn();
1697
1965
  break;
1698
1966
  case 'reset':
1699
1967
  imageEditorObj.reset();
1700
1968
  break;
1969
+ case 'adjustment':
1970
+ this.upperCanvas.style.display = 'block';
1971
+ this.refreshToolbar('adjustment');
1972
+ this.lowerContext.filter = this.initialAdjustmentValue;
1973
+ this.tempAdjustmentValue = this.lowerContext.filter;
1974
+ this.tempAdjustmentLevel = extend({}, this.adjustmentLevel, {}, true);
1975
+ this.tempFilter = this.currentFilter;
1976
+ this.tempSharpenFilter = this.adjustmentLevel.sharpen;
1977
+ this.tempBWFilter = this.adjustmentLevel.bw;
1978
+ break;
1979
+ case 'brightness':
1980
+ case 'contrast':
1981
+ case 'hue':
1982
+ case 'saturation':
1983
+ case 'opacity':
1984
+ case 'blur':
1985
+ case 'exposure':
1986
+ this.unselectBtn();
1987
+ this.currObjType.isFiltered = true;
1988
+ this.refreshToolbar('color', null, null, null, type);
1989
+ document.getElementById(this.element.id + '_' + type).classList.add('e-selected-btn');
1990
+ break;
1991
+ case 'filter':
1992
+ this.upperCanvas.style.display = 'block';
1993
+ this.refreshToolbar('filter');
1994
+ this.lowerContext.filter = this.initialAdjustmentValue;
1995
+ this.tempAdjustmentValue = this.lowerContext.filter;
1996
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
1997
+ this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
1998
+ for (var j = 0; j < this.objColl.length; j++) {
1999
+ this.apply(this.objColl[j].shape, this.objColl[j]);
2000
+ this.refreshActiveObj();
2001
+ }
2002
+ this.tempAdjustmentLevel = extend({}, this.adjustmentLevel, {}, true);
2003
+ this.tempFilter = this.currentFilter;
2004
+ this.tempSharpenFilter = this.adjustmentLevel.sharpen;
2005
+ this.tempBWFilter = this.adjustmentLevel.bw;
2006
+ break;
2007
+ case 'default':
2008
+ case 'chrome':
2009
+ case 'cold':
2010
+ case 'warm':
2011
+ case 'grayscale':
2012
+ case 'blackandwhite':
2013
+ case 'sepia':
2014
+ case 'invert':
2015
+ case 'sharpen':
2016
+ this.currObjType.isFiltered = true;
2017
+ this.setFilter(type);
2018
+ break;
1701
2019
  }
1702
2020
  }
1703
2021
  this.trigger('toolbarItemClicked', args);
1704
2022
  };
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();
2023
+ ImageEditor.prototype.okBtn = function () {
1721
2024
  var isCropSelection = false;
1722
2025
  var splitWords;
1723
2026
  if (this.activeObj.shape !== undefined) {
@@ -1729,107 +2032,795 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
1729
2032
  else if (splitWords !== undefined && splitWords[0] === 'crop') {
1730
2033
  isCropSelection = true;
1731
2034
  }
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 = [];
2035
+ var selElem = this.element.querySelector('.e-contextual-toolbar-wrapper .e-toolbar-item.e-selected');
2036
+ if (selElem) {
2037
+ this.currentFilter = selElem.children[0].children[0].id.replace('Canvas', '');
1738
2038
  }
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 };
2039
+ if (isCropSelection) {
2040
+ this.crop();
1757
2041
  }
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();
2042
+ else if (this.togglePen) {
2043
+ this.freeHandDraw(false);
2044
+ }
2045
+ else if (this.textBox.style.display === 'block') {
2046
+ this.redrawActObj();
2047
+ }
2048
+ else if (!isNullOrUndefined(document.querySelector('#' + this.element.id + '_sliderWrapper')) ||
2049
+ this.currObjType.isFiltered) {
2050
+ this.initialAdjustmentValue = this.canvasFilter = this.lowerContext.filter;
2051
+ this.currObjType.isFiltered = false;
1762
2052
  }
1763
2053
  else {
1764
- this.refreshActiveObj();
1765
- this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
2054
+ this.applyActObj();
1766
2055
  }
1767
- this.upperCanvas.style.cursor = 'default';
1768
- this.currObjType.isCustomCrop = false;
1769
- this.tempStrokeSettings = { strokeColor: '#fff', fillColor: '', strokeWidth: null };
1770
- this.callMainToolbar();
2056
+ this.callMainToolbar(false);
1771
2057
  };
1772
- ImageEditor.prototype.gradient = function (a, b) {
1773
- return (b.y - a.y) / (b.x - a.x);
2058
+ ImageEditor.prototype.unselectBtn = function () {
2059
+ if (document.querySelector('#' + this.element.id + '_brightness').classList.contains('e-selected-btn')) {
2060
+ document.querySelector('#' + this.element.id + '_brightness').classList.remove('e-selected-btn');
2061
+ }
2062
+ else if (document.querySelector('#' + this.element.id + '_contrast').classList.contains('e-selected-btn')) {
2063
+ document.querySelector('#' + this.element.id + '_contrast').classList.remove('e-selected-btn');
2064
+ }
2065
+ else if (document.querySelector('#' + this.element.id + '_hue').classList.contains('e-selected-btn')) {
2066
+ document.querySelector('#' + this.element.id + '_hue').classList.remove('e-selected-btn');
2067
+ }
2068
+ else if (document.querySelector('#' + this.element.id + '_saturation').classList.contains('e-selected-btn')) {
2069
+ document.querySelector('#' + this.element.id + '_saturation').classList.remove('e-selected-btn');
2070
+ }
2071
+ else if (document.querySelector('#' + this.element.id + '_opacity').classList.contains('e-selected-btn')) {
2072
+ document.querySelector('#' + this.element.id + '_opacity').classList.remove('e-selected-btn');
2073
+ }
2074
+ else if (document.querySelector('#' + this.element.id + '_blur').classList.contains('e-selected-btn')) {
2075
+ document.querySelector('#' + this.element.id + '_blur').classList.remove('e-selected-btn');
2076
+ }
2077
+ else if (document.querySelector('#' + this.element.id + '_exposure').classList.contains('e-selected-btn')) {
2078
+ document.querySelector('#' + this.element.id + '_exposure').classList.remove('e-selected-btn');
2079
+ }
1774
2080
  };
1775
- ImageEditor.prototype.applyPenDraw = function () {
1776
- if (this.togglePen && this.factor === 1 && !this.currObjType.isZoomed) {
1777
- this.apply();
1778
- this.penDrawColl = [];
1779
- this.imageEditorPointsColl = [];
2081
+ ImageEditor.prototype.refreshSlider = function () {
2082
+ var sliderWrapper = document.querySelector('#' + this.element.id + '_sliderWrapper');
2083
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
2084
+ var slider = document.querySelector('.e-slider');
2085
+ var hdrWrapper = document.querySelector('#' + this.element.id + '_headWrapper');
2086
+ if (hdrWrapper) {
2087
+ hdrWrapper.style.display = 'none';
1780
2088
  }
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();
2089
+ if (!isNullOrUndefined(sliderWrapper) && !isNullOrUndefined(slider)) {
2090
+ slider.ej2_instances[0].destroy();
2091
+ sliderWrapper.remove();
2092
+ }
2093
+ };
2094
+ ImageEditor.prototype.updateAdjustment = function (type, value, isPreview) {
2095
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
2096
+ var splitWords = this.lowerContext.filter.split(' ');
2097
+ var values = [];
2098
+ var opacityValue;
2099
+ var brightnessValue;
2100
+ if (splitWords[4] !== undefined) {
2101
+ opacityValue = parseFloat(splitWords[4].split('(')[1]);
2102
+ }
2103
+ if (splitWords[0] !== undefined) {
2104
+ brightnessValue = parseFloat(splitWords[0].split('(')[1]);
2105
+ }
2106
+ var brightness = this.getFilterValue(this.adjustmentLevel.brightness);
2107
+ var saturation = this.getFilterValue(this.adjustmentLevel.saturation);
2108
+ if (type !== 'brightness' && type !== 'contrast' && type !== 'hue' && type !== 'saturation' && type !== 'exposure'
2109
+ && type !== 'opacity' && type !== 'blur') {
2110
+ if (isNullOrUndefined(isPreview) && (this.adjustmentLevel.sharpen || this.adjustmentLevel.bw)) {
2111
+ if (this.adjustmentLevel.sharpen) {
2112
+ this.setSharpness(false);
2113
+ }
2114
+ else if (this.adjustmentLevel.bw) {
2115
+ this.setBlackAndWhiteFilter(false);
2116
+ }
2117
+ var temp_1 = this.lowerContext.filter;
2118
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
2119
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
2120
+ for (var i = 0; i < this.objColl.length; i++) {
2121
+ this.apply(this.objColl[i].shape, this.objColl[i]);
2122
+ this.refreshActiveObj();
1825
2123
  }
2124
+ this.lowerContext.filter = temp_1;
1826
2125
  }
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++) {
2126
+ }
2127
+ if (brightness !== 1) {
2128
+ splitWords[4] = 'opacity(' + (opacityValue - 0.3) + ')';
2129
+ }
2130
+ var saturate;
2131
+ var bright;
2132
+ var contrast;
2133
+ var saturatePercentage;
2134
+ var saturatePercent;
2135
+ var tempFilter;
2136
+ var temp;
2137
+ switch (type) {
2138
+ case 'brightness':
2139
+ if (splitWords[3].split) {
2140
+ if (parseFloat(splitWords[3].split('(')[1]) !== 100) {
2141
+ value += 0.1;
2142
+ }
2143
+ }
2144
+ splitWords[0] = 'brightness(' + value + ')';
2145
+ this.adjustmentValue = splitWords.join(' ');
2146
+ break;
2147
+ case 'contrast':
2148
+ splitWords[1] = 'contrast(' + value + '%)';
2149
+ this.adjustmentValue = splitWords.join(' ');
2150
+ break;
2151
+ case 'hue':
2152
+ splitWords[2] = 'hue-rotate(' + value + 'deg)';
2153
+ this.adjustmentValue = splitWords.join(' ');
2154
+ break;
2155
+ case 'saturation':
2156
+ splitWords[3] = 'saturate(' + value + '%)';
2157
+ if (saturation !== 1) {
2158
+ splitWords[0] = 'brightness(' + (brightnessValue + 0.1) + ')';
2159
+ }
2160
+ this.adjustmentValue = splitWords.join(' ');
2161
+ break;
2162
+ case 'opacity':
2163
+ if (parseFloat(splitWords[0].split('(')[1]) !== 1) {
2164
+ value -= 0.2;
2165
+ }
2166
+ splitWords[4] = 'opacity(' + value + ')';
2167
+ this.adjustmentValue = splitWords.join(' ');
2168
+ break;
2169
+ case 'blur':
2170
+ splitWords[5] = 'blur(' + value + 'px)';
2171
+ this.adjustmentValue = splitWords.join(' ');
2172
+ break;
2173
+ case 'exposure':
2174
+ if (brightness !== 1) {
2175
+ splitWords[4] = 'opacity(' + (opacityValue - 0.3) + ')';
2176
+ }
2177
+ if (value > 1) {
2178
+ value -= 1;
2179
+ value += brightness;
2180
+ }
2181
+ else if (value < 1) {
2182
+ value = 1 - value;
2183
+ value = brightness - value;
2184
+ }
2185
+ splitWords[0] = 'brightness(' + value + ')';
2186
+ this.adjustmentValue = splitWords.join(' ');
2187
+ break;
2188
+ case 'chrome':
2189
+ saturate = this.getSaturationFilterValue(this.adjustmentLevel.saturation);
2190
+ saturate *= 100;
2191
+ value = saturate + (saturate * 0.4);
2192
+ splitWords[3] = 'saturate(' + value + '%)';
2193
+ values = this.adjustmentValue.split(' ');
2194
+ splitWords[0] = values[0];
2195
+ splitWords[1] = values[1];
2196
+ splitWords[2] = values[2];
2197
+ splitWords[4] = values[4];
2198
+ splitWords[5] = values[5];
2199
+ splitWords[6] = 'sepia(0%)';
2200
+ splitWords[7] = 'grayscale(0%)';
2201
+ splitWords[8] = 'invert(0%)';
2202
+ break;
2203
+ case 'cold':
2204
+ // Adjusting Brightness
2205
+ bright = this.getFilterValue(this.adjustmentLevel.brightness);
2206
+ bright *= 100;
2207
+ value = bright * 0.9;
2208
+ splitWords[0] = 'brightness(' + value + '%)';
2209
+ // Adjusting Contrast
2210
+ contrast = this.getFilterValue(this.adjustmentLevel.contrast);
2211
+ contrast *= 100;
2212
+ value = contrast + (contrast * 0.5);
2213
+ splitWords[1] = 'contrast(' + value + '%)';
2214
+ // Adjusting Saturation
2215
+ saturatePercentage = this.getSaturationFilterValue(this.adjustmentLevel.saturation);
2216
+ saturatePercentage *= 100;
2217
+ value = saturatePercentage;
2218
+ splitWords[3] = 'saturate(' + value + '%)';
2219
+ values = this.adjustmentValue.split(' ');
2220
+ splitWords[2] = values[2];
2221
+ splitWords[4] = values[4];
2222
+ splitWords[5] = values[5];
2223
+ splitWords[6] = 'sepia(0%)';
2224
+ splitWords[7] = 'grayscale(0%)';
2225
+ splitWords[8] = 'invert(0%)';
2226
+ break;
2227
+ case 'warm':
2228
+ saturatePercent = this.getSaturationFilterValue(this.adjustmentLevel.saturation);
2229
+ saturatePercent *= 100;
2230
+ value = saturatePercent + (saturatePercent * 0.4);
2231
+ splitWords[3] = 'saturate(' + value + '%)';
2232
+ splitWords[6] = 'sepia(25%)';
2233
+ values = this.adjustmentValue.split(' ');
2234
+ splitWords[0] = values[0];
2235
+ splitWords[1] = values[1];
2236
+ splitWords[2] = values[2];
2237
+ splitWords[4] = values[4];
2238
+ splitWords[5] = values[5];
2239
+ splitWords[7] = 'grayscale(0%)';
2240
+ splitWords[8] = 'invert(0%)';
2241
+ break;
2242
+ case 'grayscale':
2243
+ splitWords[7] = 'grayscale(100%)';
2244
+ values = this.adjustmentValue.split(' ');
2245
+ splitWords[0] = values[0];
2246
+ splitWords[1] = values[1];
2247
+ splitWords[2] = values[2];
2248
+ splitWords[3] = values[3];
2249
+ splitWords[4] = values[4];
2250
+ splitWords[5] = values[5];
2251
+ splitWords[6] = 'sepia(0%)';
2252
+ splitWords[8] = 'invert(0%)';
2253
+ break;
2254
+ case 'blackandwhite':
2255
+ values = this.adjustmentValue.split(' ');
2256
+ if (isPreview) {
2257
+ tempFilter = this.lowerContext.filter;
2258
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
2259
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
2260
+ this.setBlackAndWhiteFilter(true);
2261
+ for (var i = 0; i < this.objColl.length; i++) {
2262
+ this.apply(this.objColl[i].shape, this.objColl[i]);
2263
+ this.refreshActiveObj();
2264
+ }
2265
+ splitWords[0] = values[0];
2266
+ splitWords[1] = values[1];
2267
+ splitWords[2] = values[2];
2268
+ splitWords[3] = values[3];
2269
+ splitWords[4] = values[4];
2270
+ splitWords[5] = values[5];
2271
+ splitWords[6] = 'sepia(0%)';
2272
+ splitWords[7] = 'grayscale(0%)';
2273
+ splitWords[8] = 'invert(0%)';
2274
+ }
2275
+ else {
2276
+ tempFilter = this.lowerContext.filter;
2277
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
2278
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
2279
+ this.setBlackAndWhiteFilter(true);
2280
+ splitWords[0] = values[0];
2281
+ splitWords[1] = values[1];
2282
+ splitWords[2] = values[2];
2283
+ splitWords[3] = values[3];
2284
+ splitWords[4] = values[4];
2285
+ splitWords[5] = values[5];
2286
+ splitWords[6] = 'sepia(0%)';
2287
+ splitWords[7] = 'grayscale(0%)';
2288
+ splitWords[8] = 'invert(0%)';
2289
+ this.lowerContext.filter = this.initialAdjustmentValue = splitWords.join(' ');
2290
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
2291
+ this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
2292
+ tempFilter = this.lowerContext.filter;
2293
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
2294
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
2295
+ for (var i = 0; i < this.objColl.length; i++) {
2296
+ this.apply(this.objColl[i].shape, this.objColl[i]);
2297
+ this.refreshActiveObj();
2298
+ }
2299
+ this.lowerContext.filter = tempFilter;
2300
+ }
2301
+ break;
2302
+ case 'sepia':
2303
+ splitWords[6] = 'sepia(100%)';
2304
+ values = this.adjustmentValue.split(' ');
2305
+ splitWords[0] = values[0];
2306
+ splitWords[1] = values[1];
2307
+ splitWords[2] = values[2];
2308
+ splitWords[3] = values[3];
2309
+ splitWords[4] = values[4];
2310
+ splitWords[5] = values[5];
2311
+ splitWords[7] = 'grayscale(0%)';
2312
+ splitWords[8] = 'invert(0%)';
2313
+ break;
2314
+ case 'invert':
2315
+ splitWords[8] = 'invert(100%)';
2316
+ values = this.adjustmentValue.split(' ');
2317
+ splitWords[0] = values[0];
2318
+ splitWords[1] = values[1];
2319
+ splitWords[2] = values[2];
2320
+ splitWords[3] = values[3];
2321
+ splitWords[4] = values[4];
2322
+ splitWords[5] = values[5];
2323
+ splitWords[6] = 'sepia(0%)';
2324
+ splitWords[7] = 'grayscale(0%)';
2325
+ break;
2326
+ case 'sharpen':
2327
+ values = this.adjustmentValue.split(' ');
2328
+ if (isPreview) {
2329
+ temp = this.lowerContext.filter;
2330
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
2331
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
2332
+ for (var i = 0; i < this.objColl.length; i++) {
2333
+ this.apply(this.objColl[i].shape, this.objColl[i]);
2334
+ this.refreshActiveObj();
2335
+ }
2336
+ splitWords[0] = values[0];
2337
+ splitWords[1] = values[1];
2338
+ splitWords[2] = values[2];
2339
+ splitWords[3] = values[3];
2340
+ splitWords[4] = values[4];
2341
+ splitWords[5] = values[5];
2342
+ splitWords[6] = 'sepia(0%)';
2343
+ splitWords[7] = 'grayscale(0%)';
2344
+ splitWords[8] = 'invert(0%)';
2345
+ }
2346
+ else {
2347
+ temp = this.lowerContext.filter;
2348
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
2349
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
2350
+ this.setSharpness(true);
2351
+ splitWords[0] = values[0];
2352
+ splitWords[1] = values[1];
2353
+ splitWords[2] = values[2];
2354
+ splitWords[3] = values[3];
2355
+ splitWords[4] = values[4];
2356
+ splitWords[5] = values[5];
2357
+ splitWords[6] = 'sepia(0%)';
2358
+ splitWords[7] = 'grayscale(0%)';
2359
+ splitWords[8] = 'invert(0%)';
2360
+ this.lowerContext.filter = this.initialAdjustmentValue = splitWords.join(' ');
2361
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
2362
+ this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
2363
+ temp = this.lowerContext.filter;
2364
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
2365
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
2366
+ for (var i = 0; i < this.objColl.length; i++) {
2367
+ this.apply(this.objColl[i].shape, this.objColl[i]);
2368
+ this.refreshActiveObj();
2369
+ }
2370
+ this.lowerContext.filter = temp;
2371
+ }
2372
+ break;
2373
+ }
2374
+ if (type !== 'sharpen' && type !== 'blackandwhite') {
2375
+ if (isNullOrUndefined(isPreview)) {
2376
+ if (type === 'default') {
2377
+ splitWords = this.getDefaultFilter(splitWords);
2378
+ }
2379
+ this.lowerContext.filter = splitWords.join(' ');
2380
+ }
2381
+ splitWords = this.setTempFilterValue(brightness, isPreview, splitWords, type);
2382
+ this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
2383
+ if (brightness !== 1) {
2384
+ splitWords[4] = 'opacity(' + opacityValue + ')';
2385
+ }
2386
+ else if (saturation !== 1) {
2387
+ splitWords[0] = 'brightness(' + brightnessValue + ')';
2388
+ }
2389
+ if (type === 'exposure' && brightness !== 1) {
2390
+ splitWords[0] = 'brightness(' + brightnessValue + ')';
2391
+ }
2392
+ splitWords = this.setTempFilterValue(brightness, isPreview, splitWords, type);
2393
+ if (isNullOrUndefined(isPreview)) {
2394
+ this.lowerContext.filter = this.initialAdjustmentValue = splitWords.join(' ');
2395
+ }
2396
+ var tempFilter_1 = this.lowerContext.filter;
2397
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
2398
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
2399
+ for (var i = 0; i < this.objColl.length; i++) {
2400
+ this.apply(this.objColl[i].shape, this.objColl[i]);
2401
+ this.refreshActiveObj();
2402
+ }
2403
+ this.lowerContext.filter = tempFilter_1;
2404
+ if (brightness === 1) {
2405
+ this.isBrightnessAdjusted = false;
2406
+ }
2407
+ else {
2408
+ this.isBrightnessAdjusted = true;
2409
+ }
2410
+ }
2411
+ var filter = splitWords.join(' ');
2412
+ return filter;
2413
+ };
2414
+ ImageEditor.prototype.updateBrightnessFilter = function () {
2415
+ var splitWords = this.lowerContext.filter.split(' ');
2416
+ if (this.isBrightnessAdjusted && splitWords.length > 0 && !isNullOrUndefined(splitWords[4])) {
2417
+ var opacityValue = parseFloat(splitWords[4].split('(')[1]);
2418
+ splitWords[4] = 'opacity(' + (opacityValue - 0.3) + ')';
2419
+ this.lowerContext.filter = splitWords.join(' ');
2420
+ }
2421
+ };
2422
+ ImageEditor.prototype.autoEnablePan = function () {
2423
+ if (this.factor > 0.95 && this.factor < 1.05) {
2424
+ this.dragCanvas = this.togglePan = false;
2425
+ this.callMainToolbar(false, true);
2426
+ this.pan(false);
2427
+ this.disablePan = false;
2428
+ }
2429
+ else if (!this.disablePan) {
2430
+ this.pan(true);
2431
+ }
2432
+ else if (this.disablePan) {
2433
+ this.pan(false);
2434
+ }
2435
+ };
2436
+ ImageEditor.prototype.setTempFilterValue = function (brightness, isPreview, splitWords, type) {
2437
+ if (isPreview && brightness !== 1) {
2438
+ var tempSplitWords = this.lowerContext.filter.split(' ');
2439
+ tempSplitWords[4] = splitWords[4];
2440
+ this.lowerContext.filter = tempSplitWords.join(' ');
2441
+ }
2442
+ else if (isPreview && type === 'default') {
2443
+ splitWords = this.getDefaultFilter(splitWords);
2444
+ }
2445
+ return splitWords;
2446
+ };
2447
+ ImageEditor.prototype.getDefaultFilter = function (splitWords) {
2448
+ var values = this.adjustmentValue.split(' ');
2449
+ splitWords[0] = values[0];
2450
+ splitWords[1] = values[1];
2451
+ splitWords[2] = values[2];
2452
+ splitWords[3] = values[3];
2453
+ splitWords[4] = values[4];
2454
+ splitWords[5] = values[5];
2455
+ splitWords[6] = 'sepia(0%)';
2456
+ splitWords[7] = 'grayscale(0%)';
2457
+ splitWords[8] = 'invert(0%)';
2458
+ return splitWords;
2459
+ };
2460
+ ImageEditor.prototype.setAdjustment = function (type) {
2461
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
2462
+ var splitWords = this.lowerContext.filter.split(' ');
2463
+ var value;
2464
+ var valueArr;
2465
+ switch (type) {
2466
+ case 'brightness':
2467
+ valueArr = splitWords[0].split('(');
2468
+ value = parseFloat(valueArr[1].split(')')[0]);
2469
+ this.adjustmentLevel.brightness = this.setFilterValue(value);
2470
+ break;
2471
+ case 'contrast':
2472
+ valueArr = splitWords[1].split('(');
2473
+ value = parseFloat(valueArr[1].split(')')[0]);
2474
+ value /= 100;
2475
+ this.adjustmentLevel.contrast = this.setFilterValue(value);
2476
+ break;
2477
+ case 'hue':
2478
+ valueArr = splitWords[2].split('(');
2479
+ value = parseFloat(valueArr[1].split(')')[0]);
2480
+ value /= 3;
2481
+ this.adjustmentLevel.hue = value;
2482
+ break;
2483
+ case 'saturation':
2484
+ valueArr = splitWords[3].split('(');
2485
+ value = parseFloat(valueArr[1].split(')')[0]);
2486
+ value /= 100;
2487
+ this.adjustmentLevel.saturation = this.setSaturationFilterValue(value);
2488
+ break;
2489
+ case 'opacity':
2490
+ valueArr = splitWords[4].split('(');
2491
+ value = parseFloat(valueArr[1].split(')')[0]);
2492
+ if (value === 0.45) {
2493
+ value = 40;
2494
+ }
2495
+ else if (value === 0.40) {
2496
+ value = 30;
2497
+ }
2498
+ else if (value === 0.35) {
2499
+ value = 20;
2500
+ }
2501
+ else if (value === 0.30) {
2502
+ value = 10;
2503
+ }
2504
+ else if (value === 0.25) {
2505
+ value = 0;
2506
+ }
2507
+ else {
2508
+ value *= 100;
2509
+ }
2510
+ this.adjustmentLevel.opacity = value;
2511
+ break;
2512
+ case 'blur':
2513
+ valueArr = splitWords[5].split('(');
2514
+ value = parseFloat(valueArr[1].split(')')[0]);
2515
+ value *= 20;
2516
+ this.adjustmentLevel.blur = value;
2517
+ break;
2518
+ case 'exposure':
2519
+ valueArr = splitWords[0].split('(');
2520
+ value = parseFloat(valueArr[1].split(')')[0]);
2521
+ this.adjustmentLevel.exposure = this.setFilterValue(value);
2522
+ break;
2523
+ }
2524
+ var temp = this.lowerContext.filter;
2525
+ this.updateBrightnessFilter();
2526
+ this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
2527
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
2528
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
2529
+ for (var j = 0; j < this.objColl.length; j++) {
2530
+ this.apply(this.objColl[j].shape, this.objColl[j]);
2531
+ this.refreshActiveObj();
2532
+ }
2533
+ this.lowerContext.filter = temp;
2534
+ };
2535
+ ImageEditor.prototype.renderSlider = function (type) {
2536
+ var _this = this;
2537
+ var canvasWrapper = document.querySelector('#' + this.element.id + '_contextualToolbarArea');
2538
+ var hdrWrapper = document.querySelector('#' + this.element.id + '_headWrapper');
2539
+ var labelWrapper = document.querySelector('#' + this.element.id + '_labelWrapper');
2540
+ if (!hdrWrapper && !isNullOrUndefined(canvasWrapper)) {
2541
+ hdrWrapper = canvasWrapper.appendChild(this.createElement('div', {
2542
+ id: this.element.id + '_headWrapper',
2543
+ styles: 'position: relative'
2544
+ }));
2545
+ labelWrapper = hdrWrapper.appendChild(this.createElement('label', {
2546
+ id: this.element.id + '_labelWrapper',
2547
+ styles: Browser.isDevice ? 'position: absolute; top: 25%; left: calc(50% - 150px); font-size: 15px; text-transform: capitalize; font-weight: 400;'
2548
+ : 'position: absolute; top: 25%; left: calc(50% - 226px); font-size: 15px; text-transform: capitalize; font-weight: 400;'
2549
+ }));
2550
+ }
2551
+ else {
2552
+ hdrWrapper.style.display = 'block';
2553
+ }
2554
+ labelWrapper.textContent = this.l10n.getConstant(this.toPascalCase(type));
2555
+ var sliderWrapper = hdrWrapper.appendChild(this.createElement('div', {
2556
+ id: this.element.id + '_sliderWrapper',
2557
+ styles: 'position: absolute'
2558
+ }));
2559
+ var value = this.getCurrAdjustmentValue(type);
2560
+ var min;
2561
+ var max;
2562
+ var slider;
2563
+ if (type === 'brightness' || type === 'contrast' || type === 'saturation' || type === 'exposure') {
2564
+ if (this.finetuneSettings) {
2565
+ if (type === 'brightness' && this.finetuneSettings.brightness) {
2566
+ min = this.finetuneSettings.brightness.min;
2567
+ max = this.finetuneSettings.brightness.max;
2568
+ }
2569
+ else if (type === 'contrast' && this.finetuneSettings.contrast) {
2570
+ min = this.finetuneSettings.contrast.min;
2571
+ max = this.finetuneSettings.contrast.max;
2572
+ }
2573
+ else if (type === 'saturation' && this.finetuneSettings.saturation) {
2574
+ min = this.finetuneSettings.saturation.min;
2575
+ max = this.finetuneSettings.saturation.max;
2576
+ }
2577
+ else if (type === 'exposure' && this.finetuneSettings.exposure) {
2578
+ min = this.finetuneSettings.exposure.min;
2579
+ max = this.finetuneSettings.exposure.max;
2580
+ }
2581
+ else {
2582
+ min = -100;
2583
+ max = 100;
2584
+ }
2585
+ }
2586
+ else {
2587
+ min = -100;
2588
+ max = 100;
2589
+ }
2590
+ slider = new Slider({
2591
+ value: value,
2592
+ tooltip: { isVisible: true, placement: 'Before', showOn: 'Always' },
2593
+ type: 'MinRange',
2594
+ min: min,
2595
+ max: max,
2596
+ step: 10,
2597
+ width: Browser.isDevice ? '200px' : '300px',
2598
+ cssClass: 'e-slider',
2599
+ change: function (args) {
2600
+ _this.setCurrAdjustmentValue(type, args.value);
2601
+ }
2602
+ });
2603
+ }
2604
+ else if (type === 'hue' || type === 'blur' || type === 'opacity') {
2605
+ if (this.finetuneSettings) {
2606
+ if (type === 'hue' && this.finetuneSettings.hue) {
2607
+ min = this.finetuneSettings.hue.min;
2608
+ max = this.finetuneSettings.hue.max;
2609
+ }
2610
+ else if (type === 'blur' && this.finetuneSettings.blur) {
2611
+ min = this.finetuneSettings.blur.min;
2612
+ max = this.finetuneSettings.blur.max;
2613
+ }
2614
+ else if (type === 'opacity' && this.finetuneSettings.opacity) {
2615
+ min = this.finetuneSettings.opacity.min;
2616
+ max = this.finetuneSettings.opacity.max;
2617
+ }
2618
+ else {
2619
+ min = 0;
2620
+ max = 100;
2621
+ }
2622
+ }
2623
+ else {
2624
+ min = 0;
2625
+ max = 100;
2626
+ }
2627
+ slider = new Slider({
2628
+ value: value,
2629
+ tooltip: { isVisible: true, placement: 'Before', showOn: 'Always' },
2630
+ type: 'MinRange',
2631
+ min: min,
2632
+ max: max,
2633
+ step: 10,
2634
+ width: Browser.isDevice ? '200px' : '300px',
2635
+ cssClass: 'e-slider',
2636
+ change: function (args) {
2637
+ _this.setCurrAdjustmentValue(type, args.value);
2638
+ }
2639
+ });
2640
+ }
2641
+ slider.appendTo('#' + this.element.id + '_sliderWrapper');
2642
+ sliderWrapper.style.left = (parseFloat(canvasWrapper.style.width) - parseFloat(slider.width)) / 2 + 'px';
2643
+ };
2644
+ ImageEditor.prototype.getCurrAdjustmentValue = function (type) {
2645
+ var value;
2646
+ switch (type) {
2647
+ case 'brightness':
2648
+ value = this.adjustmentLevel.brightness;
2649
+ break;
2650
+ case 'contrast':
2651
+ value = this.adjustmentLevel.contrast;
2652
+ break;
2653
+ case 'hue':
2654
+ value = this.adjustmentLevel.hue;
2655
+ break;
2656
+ case 'saturation':
2657
+ value = this.adjustmentLevel.saturation;
2658
+ break;
2659
+ case 'opacity':
2660
+ value = this.adjustmentLevel.opacity;
2661
+ break;
2662
+ case 'blur':
2663
+ value = this.adjustmentLevel.blur;
2664
+ break;
2665
+ case 'exposure':
2666
+ value = this.adjustmentLevel.exposure;
2667
+ break;
2668
+ }
2669
+ return value;
2670
+ };
2671
+ ImageEditor.prototype.setCurrAdjustmentValue = function (type, value) {
2672
+ var fineTuneValueChanging = { finetune: this.toPascalCase(type), value: value };
2673
+ this.trigger('fineTuneValueChanging', fineTuneValueChanging);
2674
+ switch (type) {
2675
+ case 'brightness':
2676
+ this.setBrightness(value);
2677
+ break;
2678
+ case 'contrast':
2679
+ this.setContrast(value);
2680
+ break;
2681
+ case 'hue':
2682
+ this.setHue(value);
2683
+ break;
2684
+ case 'saturation':
2685
+ this.setSaturation(value);
2686
+ break;
2687
+ case 'opacity':
2688
+ this.setOpacity(value);
2689
+ break;
2690
+ case 'blur':
2691
+ this.setBlur(value);
2692
+ break;
2693
+ case 'exposure':
2694
+ this.setExposure(value);
2695
+ break;
2696
+ }
2697
+ };
2698
+ ImageEditor.prototype.cancelPan = function () {
2699
+ this.applyActObj();
2700
+ var panBtn = this.element.querySelector('.e-img-pan .e-btn');
2701
+ panBtn.classList.remove('e-selected-btn');
2702
+ this.pan(false);
2703
+ };
2704
+ ImageEditor.prototype.callMainToolbar = function (isApplyBtn, isZooming) {
2705
+ this.refreshToolbar('main', isApplyBtn, false, isZooming);
2706
+ };
2707
+ ImageEditor.prototype.cancelItems = function () {
2708
+ var ratio = this.calcRatio();
2709
+ var isCropSelection = false;
2710
+ var splitWords;
2711
+ if (this.activeObj.shape !== undefined) {
2712
+ splitWords = this.activeObj.shape.split('-');
2713
+ }
2714
+ if (splitWords === undefined && this.currObjType.isCustomCrop) {
2715
+ isCropSelection = true;
2716
+ }
2717
+ else if (splitWords !== undefined && splitWords[0] === 'crop') {
2718
+ isCropSelection = true;
2719
+ }
2720
+ if (this.togglePen) {
2721
+ this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
2722
+ this.togglePen = false;
2723
+ this.upperCanvas.style.cursor = 'default';
2724
+ this.penDrawColl = [];
2725
+ this.imageEditorPointsColl = [];
2726
+ }
2727
+ else if (this.activeObj.shape === 'text') {
2728
+ this.activeObj.strokeSettings = this.tempStrokeSettings;
2729
+ this.activeObj.textSettings = this.tempTextSettings;
2730
+ if (this.activeObj.keyHistory === 'Enter Text' && this.activeObj.activePoint.startX === this.textStartPoints.x
2731
+ && this.activeObj.activePoint.startY === this.textStartPoints.y) {
2732
+ this.refreshActiveObj();
2733
+ this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
2734
+ this.drawShapeText();
2735
+ }
2736
+ else {
2737
+ this.redrawText(ratio);
2738
+ this.redrawShape(this.activeObj);
2739
+ if (!isCropSelection && this.activeObj.topLeftCircle !== undefined) {
2740
+ this.applyActObj();
2741
+ }
2742
+ this.clearSelection();
2743
+ }
2744
+ this.tempTextSettings = { text: 'Enter Text', fontFamily: 'Arial', fontSize: null, bold: false, italic: false, underline: false };
2745
+ }
2746
+ else if (this.activeObj.shape === 'rectangle' || this.activeObj.shape === 'ellipse' || this.activeObj.shape === 'line') {
2747
+ this.activeObj.strokeSettings = this.tempStrokeSettings;
2748
+ this.redrawShape(this.activeObj);
2749
+ this.applyActObj();
2750
+ }
2751
+ else {
2752
+ this.refreshActiveObj();
2753
+ this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
2754
+ }
2755
+ this.upperCanvas.style.cursor = 'default';
2756
+ this.currObjType.isCustomCrop = false;
2757
+ this.tempStrokeSettings = { strokeColor: '#fff', fillColor: '', strokeWidth: null };
2758
+ this.callMainToolbar();
2759
+ };
2760
+ ImageEditor.prototype.gradient = function (a, b) {
2761
+ return (b.y - a.y) / (b.x - a.x);
2762
+ };
2763
+ ImageEditor.prototype.applyPenDraw = function () {
2764
+ if (this.togglePen && this.factor === 1 && !this.currObjType.isZoomed) {
2765
+ this.apply();
2766
+ this.penDrawColl = [];
2767
+ this.imageEditorPointsColl = [];
2768
+ }
2769
+ else {
2770
+ var tempCanvas = this.lowerCanvas.appendChild(this.createElement('canvas', {
2771
+ id: this.element.id + '_tempCanvas', attrs: { name: 'canvasImage' }
2772
+ }));
2773
+ var tempContext = tempCanvas.getContext('2d');
2774
+ tempCanvas.width = this.lowerCanvas.width;
2775
+ tempCanvas.height = this.lowerCanvas.height;
2776
+ var temp = this.lowerContext.filter;
2777
+ this.updateBrightnessFilter();
2778
+ tempContext.drawImage(this.inMemoryCanvas, 0, 0);
2779
+ this.lowerContext.filter = temp;
2780
+ this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
2781
+ for (var i = 0; i < this.penDrawColl.length; i++) {
2782
+ tempContext.lineWidth = 2 * this.penDrawColl[i].strokeWidth;
2783
+ tempContext.strokeStyle = this.penDrawColl[i].strokeColor;
2784
+ var nexP = void 0;
2785
+ var preP = void 0;
2786
+ var f = 0.3;
2787
+ var t = 1;
2788
+ tempContext.beginPath();
2789
+ tempContext.moveTo(this.penDrawColl[i].points[0].x, this.penDrawColl[i].points[0].y);
2790
+ var m = 0;
2791
+ var dx1 = 0;
2792
+ var dx2 = 0;
2793
+ var dy1 = 0;
2794
+ var dy2 = 0;
2795
+ preP = this.penDrawColl[i].points[0];
2796
+ for (var j = 1; j < this.penDrawColl[i].points.length; j++) {
2797
+ var curP = this.penDrawColl[i].points[j];
2798
+ nexP = this.penDrawColl[i].points[j + 1];
2799
+ if (nexP) {
2800
+ m = this.gradient(preP, nexP);
2801
+ dx2 = (nexP.x - curP.x) * -f;
2802
+ dy2 = dx2 * m * t;
2803
+ }
2804
+ else {
2805
+ dx2 = 0;
2806
+ dy2 = 0;
2807
+ }
2808
+ tempContext.bezierCurveTo(preP.x - dx1, preP.y - dy1, curP.x + dx2, curP.y + dy2, curP.x, curP.y);
2809
+ dx1 = dx2;
2810
+ dy1 = dy2;
2811
+ preP = curP;
2812
+ if (this.penDrawColl[i].points.length > 2) {
2813
+ this.penDrawColl[i].points.shift();
2814
+ }
2815
+ tempContext.stroke();
2816
+ }
2817
+ }
2818
+ this.penDrawColl = [];
2819
+ this.imageEditorPointsColl = [];
2820
+ this.togglePen = false;
2821
+ var imgData = tempContext.getImageData(0, 0, tempCanvas.width, tempCanvas.height);
2822
+ var tempObj = void 0;
2823
+ for (var index = 0; index < this.imgDataColl.length; index++) {
1833
2824
  if (this.imgDataColl[index].operation !== 'freehanddraw') {
1834
2825
  tempObj = this.imgDataColl[index];
1835
2826
  break;
@@ -1843,24 +2834,37 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
1843
2834
  this.inMemoryCanvas.height = imgData.height;
1844
2835
  this.inMemoryContext.putImageData(imgData, 0, 0);
1845
2836
  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
- }
2837
+ this.redrawImgWithObj();
1851
2838
  this.currObjType.isZoomed = false;
1852
2839
  }
1853
2840
  };
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();
2841
+ ImageEditor.prototype.redrawImgWithObj = function () {
2842
+ this.lowerContext.filter = this.canvasFilter;
2843
+ var temp = this.lowerContext.filter;
2844
+ this.updateBrightnessFilter();
2845
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
2846
+ this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
2847
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
2848
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
2849
+ for (var j = 0; j < this.objColl.length; j++) {
2850
+ this.apply(this.objColl[j].shape, this.objColl[j]);
2851
+ this.refreshActiveObj();
1858
2852
  }
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();
2853
+ this.lowerContext.filter = temp;
2854
+ };
2855
+ ImageEditor.prototype.refreshToolbar = function (type, isApplyBtn, isCropping, isZooming, cType) {
2856
+ var args = { toolbarType: type };
2857
+ if (type !== 'filter' && type !== 'color') {
2858
+ if (document.getElementById(this.element.id + '_toolbar') && this.defToolbarItems.length > 0) {
2859
+ getComponent(document.getElementById(this.element.id + '_toolbar'), 'toolbar').destroy();
2860
+ }
2861
+ if (document.getElementById(this.element.id + '_bottomToolbar') && this.defToolbarItems.length > 0) {
2862
+ if (document.getElementById(this.element.id + '_bottomToolbar').className.indexOf('e-control') > -1) {
2863
+ getComponent(document.getElementById(this.element.id + '_bottomToolbar'), 'toolbar').destroy();
2864
+ }
1862
2865
  }
1863
2866
  }
2867
+ this.refreshSlider();
1864
2868
  switch (type) {
1865
2869
  case 'main':
1866
2870
  if (Browser.isDevice) {
@@ -1910,7 +2914,104 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
1910
2914
  case 'pan':
1911
2915
  this.initZoomToolbarItem();
1912
2916
  break;
2917
+ case 'adjustment':
2918
+ if (Browser.isDevice) {
2919
+ this.initToolbarItem(false, true, true);
2920
+ }
2921
+ this.initAdjustmentToolbarItem();
2922
+ break;
2923
+ case 'filter':
2924
+ this.updateContextualToolbar(type);
2925
+ break;
2926
+ case 'color':
2927
+ this.updateContextualToolbar(type, cType);
2928
+ break;
2929
+ }
2930
+ };
2931
+ ImageEditor.prototype.getAdjustmentToolbarItem = function () {
2932
+ var toolbarItems = [];
2933
+ if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Brightness') > -1)) {
2934
+ toolbarItems.push({ id: this.element.id + '_brightness', prefixIcon: 'e-icons e-brightness', cssClass: 'top-icon e-brightness',
2935
+ tooltipText: this.l10n.getConstant('Brightness'), align: 'Center' });
2936
+ }
2937
+ if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Contrast') > -1)) {
2938
+ toolbarItems.push({ id: this.element.id + '_contrast', prefixIcon: 'e-icons e-contrast', cssClass: 'top-icon e-contrast',
2939
+ tooltipText: this.l10n.getConstant('Contrast'), align: 'Center' });
2940
+ }
2941
+ if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Hue') > -1)) {
2942
+ toolbarItems.push({ id: this.element.id + '_hue', prefixIcon: 'e-icons e-fade', cssClass: 'top-icon e-fade',
2943
+ tooltipText: this.l10n.getConstant('Hue'), align: 'Center' });
2944
+ }
2945
+ if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Saturation') > -1)) {
2946
+ toolbarItems.push({ id: this.element.id + '_saturation', prefixIcon: 'e-icons e-saturation', cssClass: 'top-icon e-saturation',
2947
+ tooltipText: this.l10n.getConstant('Saturation'), align: 'Center' });
2948
+ }
2949
+ if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Exposure') > -1)) {
2950
+ toolbarItems.push({ id: this.element.id + '_exposure', prefixIcon: 'e-icons e-grain', cssClass: 'top-icon e-grain',
2951
+ tooltipText: this.l10n.getConstant('Exposure'), align: 'Center' });
2952
+ }
2953
+ if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Opacity') > -1)) {
2954
+ toolbarItems.push({ id: this.element.id + '_opacity', prefixIcon: 'e-icons e-opacity', cssClass: 'top-icon e-opacity',
2955
+ tooltipText: this.l10n.getConstant('Opacity'), align: 'Center' });
2956
+ }
2957
+ if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Blur') > -1)) {
2958
+ toolbarItems.push({ id: this.element.id + '_blur', prefixIcon: 'e-icons e-tint', cssClass: 'top-icon e-tint',
2959
+ tooltipText: this.l10n.getConstant('Blur'), align: 'Center' });
2960
+ }
2961
+ var tempToolbarItems = this.processToolbar('center');
2962
+ for (var i = 0, len = tempToolbarItems.length; i < len; i++) {
2963
+ toolbarItems.push(tempToolbarItems[i]);
2964
+ }
2965
+ if (!Browser.isDevice) {
2966
+ toolbarItems.push({ id: this.element.id + '_ok', prefixIcon: 'e-icons e-check', cssClass: 'top-icon e-tick',
2967
+ tooltipText: this.l10n.getConstant('OK'), align: 'Right' });
2968
+ toolbarItems.push({ id: this.element.id + '_cancel', prefixIcon: 'e-icons e-close', cssClass: 'top-icon e-save',
2969
+ tooltipText: this.l10n.getConstant('Cancel'), align: 'Right' });
2970
+ }
2971
+ return toolbarItems;
2972
+ };
2973
+ ImageEditor.prototype.getFilterToolbarItem = function () {
2974
+ var toolbarItems = [];
2975
+ if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Default') > -1)) {
2976
+ toolbarItems.push({ id: this.element.id + '_default', prefixIcon: 'e-icons e-none', cssClass: 'top-icon e-none',
2977
+ tooltipText: this.l10n.getConstant('Default'), align: 'Center',
2978
+ 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>' });
2979
+ }
2980
+ if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Chrome') > -1)) {
2981
+ toolbarItems.push({ id: this.element.id + '_chrome', prefixIcon: 'e-icons e-none', cssClass: 'top-icon e-none',
2982
+ tooltipText: this.l10n.getConstant('Chrome'), align: 'Center',
2983
+ 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>' });
2984
+ }
2985
+ if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Cold') > -1)) {
2986
+ toolbarItems.push({ id: this.element.id + '_cold', prefixIcon: 'e-icons e-none', cssClass: 'top-icon e-none',
2987
+ tooltipText: this.l10n.getConstant('Cold'), align: 'Center',
2988
+ 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>' });
2989
+ }
2990
+ if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Warm') > -1)) {
2991
+ toolbarItems.push({ id: this.element.id + '_warm', prefixIcon: 'e-icons e-none', cssClass: 'top-icon e-none',
2992
+ tooltipText: this.l10n.getConstant('Warm'), align: 'Center',
2993
+ 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>' });
2994
+ }
2995
+ if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Grayscale') > -1)) {
2996
+ toolbarItems.push({ id: this.element.id + '_grayscale', prefixIcon: 'e-icons e-none', cssClass: 'top-icon e-none',
2997
+ tooltipText: this.l10n.getConstant('Grayscale'), align: 'Center',
2998
+ 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>' });
2999
+ }
3000
+ if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Sepia') > -1)) {
3001
+ toolbarItems.push({ id: this.element.id + '_sepia', prefixIcon: 'e-icons e-none', cssClass: 'top-icon e-none',
3002
+ tooltipText: this.l10n.getConstant('Sepia'), align: 'Center',
3003
+ 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>' });
3004
+ }
3005
+ if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Invert') > -1)) {
3006
+ toolbarItems.push({ id: this.element.id + '_invert', prefixIcon: 'e-icons e-none', cssClass: 'top-icon e-none',
3007
+ tooltipText: this.l10n.getConstant('Invert'), align: 'Center',
3008
+ 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>' });
3009
+ }
3010
+ var tempToolbarItems = this.processToolbar('center');
3011
+ for (var i = 0, len = tempToolbarItems.length; i < len; i++) {
3012
+ toolbarItems.push(tempToolbarItems[i]);
1913
3013
  }
3014
+ return toolbarItems;
1914
3015
  };
1915
3016
  ImageEditor.prototype.getPenToolbarItem = function (items) {
1916
3017
  var toolbarItems = [];
@@ -2031,7 +3132,12 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
2031
3132
  if (items.indexOf('strokeWidth') > -1) {
2032
3133
  var strokeWidthBtn = document.getElementById(this.element.id + '_penStrokeWidth');
2033
3134
  var spanElem_3 = document.createElement('span');
2034
- spanElem_3.innerHTML = this.l10n.getConstant('Small');
3135
+ if (isNullOrUndefined(this.penStrokeWidth)) {
3136
+ spanElem_3.innerHTML = this.l10n.getConstant('Small');
3137
+ }
3138
+ else {
3139
+ spanElem_3.innerHTML = this.getPenStroke(this.penStrokeWidth, this.calcRatio());
3140
+ }
2035
3141
  spanElem_3.className = 'e-pen-stroke-width';
2036
3142
  strokeWidthBtn.appendChild(spanElem_3);
2037
3143
  var drpDownBtn_2 = new DropDownButton({ items: strokeWidthItems,
@@ -2049,15 +3155,15 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
2049
3155
  if (Browser.isDevice) {
2050
3156
  if (!isNullOrUndefined(document.getElementById(_this.element.id + '_bottomToolbar'))) {
2051
3157
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
2052
- var toolbar_7 = getComponent(_this.element.id + '_bottomToolbar', 'toolbar');
2053
- toolbar_7.refreshOverflow();
3158
+ var toolbar_8 = getComponent(_this.element.id + '_bottomToolbar', 'toolbar');
3159
+ toolbar_8.refreshOverflow();
2054
3160
  }
2055
3161
  }
2056
3162
  else {
2057
3163
  if (!isNullOrUndefined(document.getElementById(_this.element.id + '_toolbar'))) {
2058
3164
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
2059
- var toolbar_8 = getComponent(_this.element.id + '_toolbar', 'toolbar');
2060
- toolbar_8.refreshOverflow();
3165
+ var toolbar_9 = getComponent(_this.element.id + '_toolbar', 'toolbar');
3166
+ toolbar_9.refreshOverflow();
2061
3167
  }
2062
3168
  }
2063
3169
  }
@@ -2085,7 +3191,161 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
2085
3191
  break;
2086
3192
  }
2087
3193
  };
3194
+ ImageEditor.prototype.getPenStroke = function (value, ratio) {
3195
+ var textContent = '';
3196
+ if (Math.round(value / 0.4) === Math.round(ratio.width + ratio.height)) {
3197
+ textContent = this.l10n.getConstant('XSmall');
3198
+ }
3199
+ else if (Math.round(value / 0.8) === Math.round(ratio.width + ratio.height)) {
3200
+ textContent = this.l10n.getConstant('Small');
3201
+ }
3202
+ else if (Math.round(value / 1.2) === Math.round(ratio.width + ratio.height)) {
3203
+ textContent = this.l10n.getConstant('Medium');
3204
+ }
3205
+ else if (Math.round(value / 1.6) === Math.round(ratio.width + ratio.height)) {
3206
+ textContent = this.l10n.getConstant('Large');
3207
+ }
3208
+ else if (Math.round(value / 2) === Math.round(ratio.width + ratio.height)) {
3209
+ textContent = this.l10n.getConstant('XLarge');
3210
+ }
3211
+ return textContent;
3212
+ };
3213
+ ImageEditor.prototype.initAdjustmentToolbarItem = function () {
3214
+ var _this = this;
3215
+ var leftItem = this.getLeftToolbarItem();
3216
+ var rightItem = this.getRightToolbarItem();
3217
+ var mainItem = this.getAdjustmentToolbarItem();
3218
+ var zoomItem = this.getZoomToolbarItem();
3219
+ if (Browser.isDevice) {
3220
+ this.defToolbarItems = mainItem;
3221
+ }
3222
+ else {
3223
+ this.defToolbarItems = leftItem.concat(zoomItem, mainItem, rightItem);
3224
+ }
3225
+ var toolbar = new Toolbar({
3226
+ width: '100%',
3227
+ items: this.defToolbarItems,
3228
+ clicked: this.defToolbarClicked.bind(this),
3229
+ created: function () {
3230
+ if (!Browser.isDevice) {
3231
+ _this.renderSaveBtn();
3232
+ }
3233
+ if (Browser.isDevice) {
3234
+ if (_this.defToolbarItems.length > 0 && (!isNullOrUndefined(document.getElementById(_this.element.id + '_toolbar')))) {
3235
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
3236
+ toolbar.refreshOverflow();
3237
+ }
3238
+ }
3239
+ else {
3240
+ _this.createLeftToolbarControls();
3241
+ if (_this.defToolbarItems.length > 0 && (!isNullOrUndefined(document.getElementById(_this.element.id + '_toolbar')))) {
3242
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
3243
+ toolbar.refreshOverflow();
3244
+ }
3245
+ }
3246
+ }
3247
+ });
3248
+ if (Browser.isDevice) {
3249
+ toolbar.appendTo('#' + this.element.id + '_bottomToolbar');
3250
+ }
3251
+ else {
3252
+ toolbar.appendTo('#' + this.element.id + '_toolbar');
3253
+ }
3254
+ };
3255
+ ImageEditor.prototype.initFilterToolbarItem = function () {
3256
+ var _this = this;
3257
+ var mainItem = this.getFilterToolbarItem();
3258
+ if (!isNullOrUndefined(document.querySelector('#' + this.element.id + '_contextualToolbar')) &&
3259
+ document.querySelector('#' + this.element.id + '_contextualToolbar').classList.contains('e-control')) {
3260
+ getComponent(document.getElementById(this.element.id + '_contextualToolbar'), 'toolbar').destroy();
3261
+ }
3262
+ var toolbar = new Toolbar({
3263
+ width: '100%',
3264
+ items: mainItem,
3265
+ clicked: this.contextualToolbarClicked.bind(this),
3266
+ created: function () {
3267
+ _this.createCanvasFilter();
3268
+ if (_this.currentFilter === '') {
3269
+ _this.currentFilter = _this.element.id + '_default';
3270
+ }
3271
+ var hdrWrapper = document.querySelector('#' + _this.element.id + '_headWrapper');
3272
+ if (hdrWrapper) {
3273
+ hdrWrapper.style.display = 'none';
3274
+ }
3275
+ document.getElementById(_this.currentFilter + 'Canvas').parentElement.parentElement.classList.add('e-selected');
3276
+ toolbar.refreshOverflow();
3277
+ }
3278
+ });
3279
+ toolbar.appendTo('#' + this.element.id + '_contextualToolbar');
3280
+ };
3281
+ ImageEditor.prototype.createCanvasFilter = function () {
3282
+ if (this.adjustmentLevel.sharpen || this.adjustmentLevel.bw) {
3283
+ this.inMemoryContext.clearRect(0, 0, this.inMemoryCanvas.width, this.inMemoryCanvas.height);
3284
+ this.inMemoryCanvas.width = this.tempImageData.width;
3285
+ this.inMemoryCanvas.height = this.tempImageData.height;
3286
+ this.inMemoryContext.putImageData(this.tempImageData, 0, 0);
3287
+ }
3288
+ var noFilter = document.querySelector('#' + this.element.id + '_defaultCanvas');
3289
+ noFilter.style.width = '100px';
3290
+ noFilter.style.height = '100px';
3291
+ noFilter.style.filter = this.updateAdjustment('default', null, true);
3292
+ var ctx = noFilter.getContext('2d');
3293
+ ctx.drawImage(this.inMemoryCanvas, 0, 0, 300, 150);
3294
+ var chrome = document.querySelector('#' + this.element.id + '_chromeCanvas');
3295
+ chrome.style.width = '100px';
3296
+ chrome.style.height = '100px';
3297
+ chrome.style.filter = this.updateAdjustment('chrome', null, true);
3298
+ ctx = chrome.getContext('2d');
3299
+ ctx.drawImage(this.inMemoryCanvas, 0, 0, 300, 150);
3300
+ var cold = document.querySelector('#' + this.element.id + '_coldCanvas');
3301
+ cold.style.width = '100px';
3302
+ cold.style.height = '100px';
3303
+ cold.style.filter = this.updateAdjustment('cold', null, true);
3304
+ ctx = cold.getContext('2d');
3305
+ ctx.drawImage(this.inMemoryCanvas, 0, 0, 300, 150);
3306
+ var warm = document.querySelector('#' + this.element.id + '_warmCanvas');
3307
+ warm.style.width = '100px';
3308
+ warm.style.height = '100px';
3309
+ warm.style.filter = this.updateAdjustment('warm', null, true);
3310
+ ctx = warm.getContext('2d');
3311
+ ctx.drawImage(this.inMemoryCanvas, 0, 0, 300, 150);
3312
+ var temp = this.lowerContext.filter;
3313
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
3314
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
3315
+ for (var i = 0; i < this.objColl.length; i++) {
3316
+ this.apply(this.objColl[i].shape, this.objColl[i]);
3317
+ this.refreshActiveObj();
3318
+ }
3319
+ this.lowerContext.filter = temp;
3320
+ var grayscale = document.querySelector('#' + this.element.id + '_grayscaleCanvas');
3321
+ grayscale.style.width = '100px';
3322
+ grayscale.style.height = '100px';
3323
+ grayscale.style.filter = this.updateAdjustment('grayscale', null, true);
3324
+ ctx = grayscale.getContext('2d');
3325
+ ctx.drawImage(this.inMemoryCanvas, 0, 0, 300, 150);
3326
+ var tempFilter = this.lowerContext.filter;
3327
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
3328
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
3329
+ for (var i = 0; i < this.objColl.length; i++) {
3330
+ this.apply(this.objColl[i].shape, this.objColl[i]);
3331
+ this.refreshActiveObj();
3332
+ }
3333
+ this.lowerContext.filter = tempFilter;
3334
+ var sepia = document.querySelector('#' + this.element.id + '_sepiaCanvas');
3335
+ sepia.style.width = '100px';
3336
+ sepia.style.height = '100px';
3337
+ sepia.style.filter = this.updateAdjustment('sepia', null, true);
3338
+ ctx = sepia.getContext('2d');
3339
+ ctx.drawImage(this.inMemoryCanvas, 0, 0, 300, 150);
3340
+ var invert = document.querySelector('#' + this.element.id + '_invertCanvas');
3341
+ invert.style.width = '100px';
3342
+ invert.style.height = '100px';
3343
+ invert.style.filter = this.updateAdjustment('invert', null, true);
3344
+ ctx = invert.getContext('2d');
3345
+ ctx.drawImage(this.inMemoryCanvas, 0, 0, 300, 150);
3346
+ };
2088
3347
  ImageEditor.prototype.updateCanvas = function () {
3348
+ var fileOpened = { fileName: this.imageFileName, fileType: this.imageFileType };
2089
3349
  this.lastX = this.baseImg.width / 2;
2090
3350
  this.lastY = this.baseImg.height / 2;
2091
3351
  var wrapperWidth;
@@ -2103,9 +3363,10 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
2103
3363
  maxDimension.width -= toolbarHeight;
2104
3364
  maxDimension.height -= toolbarHeight;
2105
3365
  }
3366
+ var tempFilter = this.lowerContext.filter;
2106
3367
  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;
3368
+ this.lowerCanvas.width = this.upperCanvas.width = this.baseImg.width;
3369
+ this.lowerCanvas.height = this.upperCanvas.height = this.baseImg.height;
2109
3370
  this.lowerCanvas.style.maxWidth = this.upperCanvas.style.maxWidth = maxDimension.width + 'px';
2110
3371
  this.lowerCanvas.style.maxHeight = this.upperCanvas.style.maxHeight = maxDimension.height + 'px';
2111
3372
  this.lowerCanvas.style.left = this.upperCanvas.style.left = (wrapperWidth - maxDimension.width) / 2 + 1 + 'px';
@@ -2115,26 +3376,47 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
2115
3376
  if (canvasWrapper) {
2116
3377
  this.lowerCanvas.style.top = this.upperCanvas.style.top = (parseFloat(canvasWrapper.style.height) - maxDimension.height - 1) / 2 + 'px';
2117
3378
  }
2118
- this.lowerContext.drawImage(this.baseImg, 0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
2119
- this.updateInMemoryCanvas('updateCanvas');
3379
+ this.lowerContext.filter = tempFilter;
3380
+ if (this.lowerContext.filter === 'none' || this.lowerContext.filter === 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
3381
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)' ||
3382
+ this.isInitialLoading) {
3383
+ this.lowerContext.drawImage(this.baseImg, 0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
3384
+ this.updateInMemoryCanvas('updateCanvas');
3385
+ if (this.canvasFilter !== 'none') {
3386
+ this.lowerContext.filter = this.canvasFilter;
3387
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
3388
+ this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
3389
+ }
3390
+ if (this.isInitialLoading) {
3391
+ this.initializeFilter();
3392
+ this.isInitialLoading = false;
3393
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
3394
+ this.lowerContext.drawImage(this.baseImg, 0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
3395
+ }
3396
+ }
3397
+ else {
3398
+ var temp = this.lowerContext.filter;
3399
+ this.updateBrightnessFilter();
3400
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
3401
+ this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
3402
+ this.lowerContext.filter = temp;
3403
+ }
3404
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
3405
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
2120
3406
  for (var i = 0, len = this.objColl.length; i < len; i++) {
2121
3407
  this.apply(this.objColl[i].shape, this.objColl[i]);
2122
3408
  }
2123
- if (this.isUndoRedo) {
2124
- if (this.flipState !== '') {
2125
- this.flip(this.flipState);
2126
- }
2127
- }
3409
+ this.lowerContext.filter = tempFilter;
2128
3410
  if (this.disabled) {
2129
3411
  this.element.setAttribute('class', 'e-disabled');
2130
3412
  }
2131
- this.trigger('fileOpened');
3413
+ this.trigger('fileOpened', fileOpened);
2132
3414
  };
2133
3415
  ImageEditor.prototype.imageOnLoad = function (src) {
2134
3416
  var _this = this;
2135
3417
  // eslint-disable-next-line @typescript-eslint/no-this-alias
2136
3418
  var proxy = this;
2137
- proxy.baseImg.src = proxy.baseImgSrc = src;
3419
+ proxy.baseImg.src = proxy.baseImgSrc.id = src;
2138
3420
  this.baseImg.onload = function () {
2139
3421
  _this.lowerContext.drawImage(_this.baseImg, 0, 0, _this.lowerCanvas.width, _this.lowerCanvas.height);
2140
3422
  if (_this.togglePen) {
@@ -2155,7 +3437,6 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
2155
3437
  hideSpinner(_this.element);
2156
3438
  _this.element.style.opacity = '1';
2157
3439
  _this.updateCanvas();
2158
- _this.isUndoRedo = false;
2159
3440
  }
2160
3441
  if (Browser.isDevice) {
2161
3442
  if (_this.isToolbar() && (!isNullOrUndefined(document.getElementById(_this.element.id + '_toolbar'))) &&
@@ -2332,10 +3613,19 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
2332
3613
  this.degree = 0;
2333
3614
  }
2334
3615
  };
2335
- ImageEditor.prototype.updateUndoRedoColl = function (operation, value, previousObj, currentObj) {
2336
- this.undoRedoColl.push({ operation: operation, value: value, previousObj: previousObj, currentObj: currentObj });
2337
- };
2338
3616
  ImageEditor.prototype.fileSelect = function (inputElement, args) {
3617
+ this.imageFileName = inputElement.value.split('\\')[inputElement.value.split('\\').length - 1];
3618
+ this.imageFileName = this.imageFileName.split('.')[0];
3619
+ var fileType = inputElement.value.split('.');
3620
+ if (fileType[fileType.length - 1].toLowerCase() === 'jpg' || fileType[fileType.length - 1].toLowerCase() === 'jpeg') {
3621
+ this.imageFileType = 'Jpeg';
3622
+ }
3623
+ else if (fileType[fileType.length - 1].toLowerCase() === 'png') {
3624
+ this.imageFileType = 'Png';
3625
+ }
3626
+ else if (fileType[fileType.length - 1].toLowerCase() === 'svg') {
3627
+ this.imageFileType = 'Svg';
3628
+ }
2339
3629
  showSpinner(this.element);
2340
3630
  this.element.style.opacity = '0.5';
2341
3631
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
@@ -2493,7 +3783,7 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
2493
3783
  }
2494
3784
  if (strokeWidthElem) {
2495
3785
  var strokeWidth = Math.round((this.activeObj.strokeSettings.strokeWidth /
2496
- (ratio.width + ratio.height))).toString();
3786
+ (ratio.width + ratio.height)) * this.factor).toString();
2497
3787
  strokeWidthElem.textContent = this.getStrokeWidth(strokeWidth);
2498
3788
  }
2499
3789
  };
@@ -2505,10 +3795,32 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
2505
3795
  }
2506
3796
  }
2507
3797
  };
3798
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
3799
+ ImageEditor.prototype.targetTouches = function (touches) {
3800
+ var p1 = { x: touches[0].pageX, y: touches[0].pageY };
3801
+ var p2 = { x: touches[1].pageX, y: touches[1].pageY };
3802
+ var points = [p1, p2];
3803
+ return points;
3804
+ };
3805
+ ImageEditor.prototype.calculateScale = function (startTouches, endTouches) {
3806
+ var startDistance = this.getDistance(startTouches[0], startTouches[1]);
3807
+ var endDistance = this.getDistance(endTouches[0], endTouches[1]);
3808
+ return endDistance / startDistance;
3809
+ };
3810
+ ImageEditor.prototype.getDistance = function (a, b) {
3811
+ var x = a.x - b.x;
3812
+ var y = a.y - b.y;
3813
+ return Math.sqrt(x * x + y * y);
3814
+ };
2508
3815
  ImageEditor.prototype.touchStartHandler = function (e) {
2509
3816
  e.preventDefault();
2510
- this.timer = setTimeout(this.setTimer.bind(this), 1000, e);
2511
- this.mouseDownEventHandler(e);
3817
+ if (e.touches.length === 2) {
3818
+ this.isFirstMove = true;
3819
+ }
3820
+ else {
3821
+ this.timer = setTimeout(this.setTimer.bind(this), 1000, e);
3822
+ this.mouseDownEventHandler(e);
3823
+ }
2512
3824
  EventHandler.add(this.lowerCanvas, 'touchend', this.mouseUpEventHandler, this);
2513
3825
  EventHandler.add(this.lowerCanvas, 'touchmove', this.mouseMoveEventHandler, this); // Unbind mousedown to prevent double triggers from touch devices
2514
3826
  EventHandler.add(this.upperCanvas, 'touchend', this.mouseUpEventHandler, this);
@@ -2535,6 +3847,14 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
2535
3847
  this.touchEndPoint.y = y = e.touches[0].clientY;
2536
3848
  }
2537
3849
  this.redrawActObj(x, y);
3850
+ if ((!isNullOrUndefined(this.element.querySelector('#' + this.element.id + '_contextualToolbar')) &&
3851
+ !this.element.querySelector('#' + this.element.id + '_contextualToolbar').parentElement.classList.contains('e-hide')) ||
3852
+ (!isNullOrUndefined(this.element.querySelector('#' + this.element.id + '_headWrapper'))
3853
+ && !this.element.querySelector('#' + this.element.id + '_headWrapper').parentElement.classList.contains('e-hide'))) {
3854
+ this.element.querySelector('.e-contextual-toolbar-wrapper').classList.add('e-hide');
3855
+ this.okBtn();
3856
+ this.refreshToolbar('main');
3857
+ }
2538
3858
  if (this.upperCanvas.style.cursor === 'crosshair' || (Browser.isDevice && this.togglePen)) {
2539
3859
  if (this.togglePen) {
2540
3860
  this.canvasRatio = this.calcRatio();
@@ -2598,6 +3918,47 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
2598
3918
  };
2599
3919
  ImageEditor.prototype.mouseMoveEventHandler = function (e) {
2600
3920
  e.preventDefault();
3921
+ if (e.type === 'touchmove' && e.touches.length === 2) {
3922
+ if (this.isFirstMove) {
3923
+ this.startTouches = this.targetTouches(e.touches);
3924
+ this.tempTouches = [];
3925
+ this.tempTouches.push({ x: e.touches[0].clientX || (e.touches[0].pageX - this.lowerCanvas.offsetLeft),
3926
+ y: e.touches[0].clientY || (e.touches[0].pageY - this.lowerCanvas.offsetTop) });
3927
+ this.tempTouches.push({ x: e.touches[1].clientX || (e.touches[1].pageX - this.lowerCanvas.offsetLeft),
3928
+ y: e.touches[1].clientY || (e.touches[1].pageY - this.lowerCanvas.offsetTop) });
3929
+ }
3930
+ else {
3931
+ var ratio = this.calcRatio();
3932
+ var firstFingerX = e.touches[0].clientX || (e.touches[0].pageX - this.lowerCanvas.offsetLeft);
3933
+ var firstFingerY = e.touches[0].clientY || (e.touches[0].pageY - this.lowerCanvas.offsetTop);
3934
+ var secondFingerX = e.touches[1].clientX || (e.touches[1].pageX - this.lowerCanvas.offsetLeft);
3935
+ var secondFingerY = e.touches[1].clientY || (e.touches[1].pageY - this.lowerCanvas.offsetTop);
3936
+ this.lastX = firstFingerX > secondFingerX ? secondFingerX + (firstFingerX - secondFingerX) : firstFingerX +
3937
+ (secondFingerX - firstFingerX);
3938
+ this.lastY = firstFingerY > secondFingerY ? secondFingerY + (firstFingerY - secondFingerY) : firstFingerY +
3939
+ (secondFingerY - firstFingerY);
3940
+ this.lastX *= ratio.width;
3941
+ this.lastY *= ratio.height;
3942
+ var scale = this.calculateScale(this.startTouches, this.targetTouches(e.touches));
3943
+ // Need to set lastX and lastY points
3944
+ if (this.tempTouches[0].x !== firstFingerX && this.tempTouches[0].y !== firstFingerY &&
3945
+ this.tempTouches[1].x !== secondFingerX && this.tempTouches[1].y !== secondFingerY) {
3946
+ if (scale > 1) {
3947
+ this.zoom(1.1);
3948
+ }
3949
+ else {
3950
+ this.zoom(-1.1);
3951
+ }
3952
+ this.tempTouches = [];
3953
+ this.tempTouches.push({ x: e.touches[0].clientX || (e.touches[0].pageX - this.lowerCanvas.offsetLeft),
3954
+ y: e.touches[0].clientY || (e.touches[0].pageY - this.lowerCanvas.offsetTop) });
3955
+ this.tempTouches.push({ x: e.touches[1].clientX || (e.touches[1].pageX - this.lowerCanvas.offsetLeft),
3956
+ y: e.touches[1].clientY || (e.touches[1].pageY - this.lowerCanvas.offsetTop) });
3957
+ }
3958
+ }
3959
+ this.isFirstMove = false;
3960
+ return;
3961
+ }
2601
3962
  if (this.textBox.style.display === 'none') {
2602
3963
  this.isTimer = true;
2603
3964
  }
@@ -2616,6 +3977,11 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
2616
3977
  !this.dragCanvas || this.activeObj.activePoint !== undefined) {
2617
3978
  if (this.dragElement === '') {
2618
3979
  this.setCursor(x, y);
3980
+ if (this.activeObj.activePoint.width === 0 && this.upperCanvas.style.cursor !== 'default' &&
3981
+ this.upperCanvas.style.cursor !== 'move' && this.upperCanvas.style.cursor !== 'crosshair'
3982
+ && this.upperCanvas.style.cursor !== 'grab') {
3983
+ this.upperCanvas.style.cursor = 'move';
3984
+ }
2619
3985
  this.findTarget(x, y, e.type);
2620
3986
  }
2621
3987
  }
@@ -2638,6 +4004,8 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
2638
4004
  y = this.touchEndPoint.y;
2639
4005
  }
2640
4006
  if (e.type === 'touchend') {
4007
+ this.startTouches = this.tempTouches = [];
4008
+ this.isFirstMove = false;
2641
4009
  if (this.textBox.style.display === 'none') {
2642
4010
  this.isTimer = false;
2643
4011
  this.timer = 0;
@@ -2656,8 +4024,16 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
2656
4024
  if (e.currentTarget === this.upperCanvas) {
2657
4025
  this.currObjType.shape = this.currObjType.shape.toLowerCase();
2658
4026
  if (!this.togglePen && !this.dragCanvas) {
4027
+ if (!isNullOrUndefined(this.tempObjColl) && this.activeObj.activePoint.width !== 0) {
4028
+ this.objColl.push(this.activeObj);
4029
+ this.redrawShape(this.objColl[this.objColl.length - 1]);
4030
+ this.tempObjColl = undefined;
4031
+ }
2659
4032
  this.applyCurrActObj(x, y);
2660
4033
  }
4034
+ else if (this.dragCanvas) {
4035
+ this.setPanPoints();
4036
+ }
2661
4037
  }
2662
4038
  if (this.togglePen && e.currentTarget === this.upperCanvas) {
2663
4039
  this.penDrawColl.push({ strokeWidth: this.penStrokeWidth, strokeColor: this.activeObj.strokeSettings.strokeColor, points: this.imageEditorPointsColl });
@@ -2686,11 +4062,13 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
2686
4062
  e.stopImmediatePropagation();
2687
4063
  break;
2688
4064
  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');
4065
+ if (this.textBox.style.display === 'none') {
4066
+ shapeChangingArgs = { action: 'delete', previousShapeSettings: this.activeObj, currentShapeSettings: null };
4067
+ this.keyHistory = '';
4068
+ this.clearSelection();
4069
+ this.trigger('shapeChanging', shapeChangingArgs);
4070
+ this.refreshToolbar('main');
4071
+ }
2694
4072
  break;
2695
4073
  case 'Escape':
2696
4074
  if (this.togglePan) {
@@ -2712,7 +4090,10 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
2712
4090
  }
2713
4091
  };
2714
4092
  ImageEditor.prototype.keyUpEventHandler = function (e) {
2715
- setTimeout(this.textKeyDown.bind(this), 1, e);
4093
+ // eslint-disable-next-line
4094
+ if (this.textBox.style.display === 'block' && e.target.id === this.element.id + '_textBox') {
4095
+ setTimeout(this.textKeyDown.bind(this), 1, e);
4096
+ }
2716
4097
  };
2717
4098
  ImageEditor.prototype.canvasMouseDownHandler = function (e) {
2718
4099
  e.preventDefault();
@@ -2730,7 +4111,6 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
2730
4111
  if (this.dragCanvas || this.factor !== 1) {
2731
4112
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
2732
4113
  this.dragStart = this.lowerContext.transformedPoint(this.lastX, this.lastY);
2733
- this.dragged = false;
2734
4114
  }
2735
4115
  };
2736
4116
  ImageEditor.prototype.canvasMouseMoveHandler = function (e) {
@@ -2752,55 +4132,39 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
2752
4132
  }
2753
4133
  this.lastX *= ratio.width;
2754
4134
  this.lastY *= ratio.height;
2755
- this.dragged = true;
2756
4135
  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();
4136
+ this.drawPanImg();
2797
4137
  }
2798
4138
  };
2799
4139
  ImageEditor.prototype.canvasMouseUpHandler = function (e) {
2800
4140
  e.preventDefault();
4141
+ if (this.togglePan && e.currentTarget === this.lowerCanvas) {
4142
+ var ratio = this.calcRatio();
4143
+ if (e.type === 'mouseup') {
4144
+ this.lastX = e.offsetX || (e.pageX - this.lowerCanvas.offsetLeft);
4145
+ this.lastY = e.offsetY || (e.pageY - this.lowerCanvas.offsetTop);
4146
+ }
4147
+ else {
4148
+ this.lastX = e.touches[0].clientX || (e.touches[0].pageX - this.lowerCanvas.offsetLeft);
4149
+ this.lastY = e.touches[0].clientY || (e.touches[0].pageY - this.lowerCanvas.offsetTop);
4150
+ }
4151
+ this.lastX *= ratio.width;
4152
+ this.lastY *= ratio.height;
4153
+ this.setPanPoints();
4154
+ }
2801
4155
  this.dragStart = null;
4156
+ // zooms on mouse click point
4157
+ // if (e.currentTarget !== document) {
4158
+ // this.zoom(e.shiftKey ? -1 : 1 );
4159
+ // }
2802
4160
  this.currObjType.isDragging = false;
2803
4161
  };
4162
+ ImageEditor.prototype.setPanPoints = function () {
4163
+ if (this.dragCanvas || this.factor !== 1) {
4164
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
4165
+ this.dragStart = this.lowerContext.transformedPoint(this.lastX, this.lastY);
4166
+ }
4167
+ };
2804
4168
  ImageEditor.prototype.textKeyDown = function (e) {
2805
4169
  if (String.fromCharCode(e.which) === '\r') {
2806
4170
  this.textRow += 1;
@@ -2819,6 +4183,8 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
2819
4183
  ImageEditor.prototype.adjustToScreen = function () {
2820
4184
  // eslint-disable-next-line @typescript-eslint/no-this-alias
2821
4185
  var proxy = this;
4186
+ var tempFilter = this.lowerContext.filter;
4187
+ this.okBtn();
2822
4188
  this.applyActObj();
2823
4189
  this.refreshActiveObj();
2824
4190
  if (this.imgDataColl.length > 0) {
@@ -2840,15 +4206,32 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
2840
4206
  canvasWrapper.style.height = (parseFloat(canvasWrapper.style.height) - this.toolbarHeight) - 3 + 'px';
2841
4207
  }
2842
4208
  }
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');
4209
+ this.redrawImg(tempFilter);
4210
+ if (!this.currObjType.isSave) {
4211
+ // eslint-disable-next-line @typescript-eslint/tslint/config
4212
+ this.lowerCanvas.toBlob(function (blob) {
4213
+ proxy.lowerContext.filter = proxy.initialAdjustmentValue = proxy.adjustmentValue = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
4214
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
4215
+ if (proxy.cssClass) {
4216
+ addClass([proxy.element], proxy.cssClass.split(' '));
4217
+ }
4218
+ proxy.lowerContext.clearRect(0, 0, proxy.lowerCanvas.width, proxy.lowerCanvas.height);
4219
+ proxy.lowerContext.drawImage(proxy.inMemoryCanvas, 0, 0);
4220
+ proxy.baseImg.src = URL.createObjectURL(blob);
4221
+ proxy.lowerContext.filter = tempFilter;
4222
+ }, 'image/png');
4223
+ }
4224
+ else {
4225
+ hideSpinner(this.element);
4226
+ this.element.style.opacity = '1';
4227
+ }
2848
4228
  if (this.defToolbarItems.length > 0 && (!isNullOrUndefined(document.getElementById(this.element.id + '_toolbar')))) {
2849
4229
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
2850
- var toolbar_9 = getComponent(proxy.element.id + '_toolbar', 'toolbar');
2851
- toolbar_9.refreshOverflow();
4230
+ var toolbar_10 = getComponent(proxy.element.id + '_toolbar', 'toolbar');
4231
+ toolbar_10.refreshOverflow();
4232
+ if (!isNullOrUndefined(this.element.querySelector('.e-contextual-toolbar-wrapper'))) {
4233
+ this.element.querySelector('.e-contextual-toolbar-wrapper').classList.add('e-hide');
4234
+ }
2852
4235
  }
2853
4236
  };
2854
4237
  ImageEditor.prototype.screenOrientation = function () {
@@ -2862,7 +4245,49 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
2862
4245
  this.adjustToScreen();
2863
4246
  }
2864
4247
  };
2865
- ImageEditor.prototype.redrawImg = function () {
4248
+ ImageEditor.prototype.drawPanImg = function () {
4249
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
4250
+ var pt = this.lowerContext.transformedPoint(this.lastX, this.lastY);
4251
+ var transitionArgs = { startPoint: { x: this.dragStart.x, y: this.dragStart.y },
4252
+ endPoint: { x: pt.x, y: pt.y } };
4253
+ this.trigger('panning', transitionArgs);
4254
+ var xDiff = pt.x - this.dragStart.x;
4255
+ var yDiff = pt.y - this.dragStart.y;
4256
+ var xxDiff = xDiff;
4257
+ var yyDiff = yDiff;
4258
+ this.lowerContext.translate(xDiff, yDiff);
4259
+ this.upperContext.translate(xDiff, yDiff);
4260
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
4261
+ var pt1 = this.lowerContext.transformedPoint(0, 0);
4262
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
4263
+ var pt2 = this.lowerContext.transformedPoint(this.lowerCanvas.width, this.lowerCanvas.height);
4264
+ if (xDiff >= 0) {
4265
+ if (pt1.x < 1) {
4266
+ xDiff = 0;
4267
+ }
4268
+ }
4269
+ else {
4270
+ if (pt2.x > this.lowerCanvas.width) {
4271
+ xDiff = 0;
4272
+ }
4273
+ }
4274
+ if (yDiff >= 0) {
4275
+ if (pt1.y < 1) {
4276
+ yDiff = 0;
4277
+ }
4278
+ }
4279
+ else {
4280
+ if (pt2.y > this.lowerCanvas.height) {
4281
+ yDiff = 0;
4282
+ }
4283
+ }
4284
+ this.lowerContext.translate(-xxDiff, -yyDiff);
4285
+ this.upperContext.translate(-xxDiff, -yyDiff);
4286
+ this.lowerContext.translate(xDiff, yDiff);
4287
+ this.upperContext.translate(xDiff, yDiff);
4288
+ this.redraw();
4289
+ };
4290
+ ImageEditor.prototype.redrawImg = function (tempFilter) {
2866
4291
  var wrapperWidth;
2867
4292
  var canvasWrapper = document.querySelector('#' + this.element.id + '_canvasWrapper');
2868
4293
  if (this.isScreenOriented) {
@@ -2878,7 +4303,17 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
2878
4303
  this.lowerCanvas.style.maxHeight = this.upperCanvas.style.maxHeight = maxDimension.height + 'px';
2879
4304
  this.lowerCanvas.style.left = this.upperCanvas.style.left = (wrapperWidth - maxDimension.width) / 2 + 1 + 'px';
2880
4305
  this.lowerCanvas.style.top = this.upperCanvas.style.top = (this.element.offsetHeight - this.toolbarHeight - maxDimension.height) / 2 + 1 + 'px';
4306
+ this.lowerContext.filter = tempFilter;
4307
+ var temp = this.lowerContext.filter;
4308
+ this.updateBrightnessFilter();
2881
4309
  this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
4310
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
4311
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
4312
+ for (var i = 0; i < this.objColl.length; i++) {
4313
+ this.apply(this.objColl[i].shape, this.objColl[i]);
4314
+ this.refreshActiveObj();
4315
+ }
4316
+ this.lowerContext.filter = temp;
2882
4317
  };
2883
4318
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
2884
4319
  ImageEditor.prototype.updateContext = function (ctx) {
@@ -2927,7 +4362,7 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
2927
4362
  var transform = ctx.transform;
2928
4363
  ctx.transform = function (a, b, c, d, e, f) {
2929
4364
  /* 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]);
4365
+ var m2 = new DOMMatrix();
2931
4366
  m2.a = a;
2932
4367
  m2.b = b;
2933
4368
  m2.c = c;
@@ -2955,6 +4390,7 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
2955
4390
  return pt.matrixTransform(xform.inverse());
2956
4391
  };
2957
4392
  };
4393
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
2958
4394
  ImageEditor.prototype.scaleNonUniform = function (xform, sx, sy) {
2959
4395
  xform.m11 *= sx;
2960
4396
  xform.m12 *= sx;
@@ -2991,11 +4427,7 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
2991
4427
  this.upperContext.setTransform(1, 0, 0, 1, 0, 0);
2992
4428
  this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
2993
4429
  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
- }
4430
+ this.redrawImgWithObj();
2999
4431
  }
3000
4432
  else {
3001
4433
  if (this.factor > 1) {
@@ -3058,11 +4490,7 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
3058
4490
  this.upperContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
3059
4491
  this.lowerContext.restore();
3060
4492
  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
- }
4493
+ this.redrawImgWithObj();
3066
4494
  };
3067
4495
  ImageEditor.prototype.applyCurrActObj = function (x, y) {
3068
4496
  var isInside = false;
@@ -3086,9 +4514,13 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
3086
4514
  }
3087
4515
  if (this.activeObj.shape === 'text' || (this.currObjType.shape === 'ellipse' || this.currObjType.shape === 'rectangle' ||
3088
4516
  this.currObjType.shape === 'line')) {
4517
+ var tempFilter = this.lowerContext.filter;
4518
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
4519
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
3089
4520
  for (var j = 0; j < this.objColl.length; j++) {
3090
4521
  this.apply(this.objColl[j].shape, this.objColl[j]);
3091
4522
  }
4523
+ this.lowerContext.filter = tempFilter;
3092
4524
  this.apply('shape');
3093
4525
  }
3094
4526
  }
@@ -3114,6 +4546,24 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
3114
4546
  this.setTextSelection(width, height);
3115
4547
  this.updateActiveObject(ratio, this.activeObj.activePoint, this.activeObj);
3116
4548
  };
4549
+ ImageEditor.prototype.setTextBoxStylesToActObj = function () {
4550
+ var ratio = this.calcRatio();
4551
+ this.activeObj.textSettings.fontFamily = this.textBox.style.fontFamily;
4552
+ this.activeObj.strokeSettings.strokeColor = this.textBox.style.color;
4553
+ if (this.textBox.style.fontWeight === 'bold') {
4554
+ this.activeObj.textSettings.bold = true;
4555
+ }
4556
+ else {
4557
+ this.activeObj.textSettings.bold = false;
4558
+ }
4559
+ if (this.textBox.style.fontStyle === 'italic') {
4560
+ this.activeObj.textSettings.italic = true;
4561
+ }
4562
+ else {
4563
+ this.activeObj.textSettings.italic = false;
4564
+ }
4565
+ this.activeObj.textSettings.fontSize = (parseFloat(this.textBox.style.fontSize) * ((ratio.width + ratio.height) / 2)) / this.factor;
4566
+ };
3117
4567
  ImageEditor.prototype.redrawActObj = function (x, y) {
3118
4568
  var ratio = this.calcRatio();
3119
4569
  var splitWords;
@@ -3123,21 +4573,7 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
3123
4573
  }
3124
4574
  if (this.activeObj.horTopLine !== undefined && (this.activeObj.shape !== undefined && splitWords[0] !== 'crop')) {
3125
4575
  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;
4576
+ this.setTextBoxStylesToActObj();
3141
4577
  if (x && y) {
3142
4578
  x -= bbox.left;
3143
4579
  y -= bbox.top;
@@ -3599,10 +5035,7 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
3599
5035
  }
3600
5036
  }
3601
5037
  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
- }
5038
+ this.redrawImgWithObj();
3606
5039
  this.activeObj = temp;
3607
5040
  this.updateFontStyles();
3608
5041
  if (this.factor === 1) {
@@ -4007,7 +5440,7 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
4007
5440
  else {
4008
5441
  diff = Math.max(this.diffPoint.x, this.diffPoint.y);
4009
5442
  }
4010
- percentage = diff / 10;
5443
+ percentage = (diff / 10) * this.factor;
4011
5444
  this.activeObj.activePoint.startX -= (maxDimension.width / 100) * percentage;
4012
5445
  this.activeObj.activePoint.startY -= (maxDimension.height / 100) * percentage;
4013
5446
  this.activeObj.activePoint.width = this.activeObj.activePoint.endX - this.activeObj.activePoint.startX;
@@ -4152,7 +5585,7 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
4152
5585
  else {
4153
5586
  diff = Math.max(this.diffPoint.x, this.diffPoint.y);
4154
5587
  }
4155
- percentage = diff / 10;
5588
+ percentage = (diff / 10) * this.factor;
4156
5589
  this.activeObj.activePoint.endX += (maxDimension.width / 100) * percentage;
4157
5590
  this.activeObj.activePoint.startY -= (maxDimension.height / 100) * percentage;
4158
5591
  this.activeObj.activePoint.width = this.activeObj.activePoint.endX - this.activeObj.activePoint.startX;
@@ -4348,7 +5781,7 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
4348
5781
  else {
4349
5782
  diff = Math.max(this.diffPoint.x, this.diffPoint.y);
4350
5783
  }
4351
- percentage = diff / 10;
5784
+ percentage = (diff / 10) * this.factor;
4352
5785
  this.activeObj.activePoint.startX -= (maxDimension.width / 100) * percentage;
4353
5786
  this.activeObj.activePoint.endY += (maxDimension.height / 100) * percentage;
4354
5787
  this.activeObj.activePoint.width = this.activeObj.activePoint.endX - this.activeObj.activePoint.startX;
@@ -4495,7 +5928,7 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
4495
5928
  else {
4496
5929
  diff = Math.min(this.diffPoint.x, this.diffPoint.y);
4497
5930
  }
4498
- percentage = diff / 10;
5931
+ percentage = (diff / 10) * this.factor;
4499
5932
  this.activeObj.activePoint.endX += (maxDimension.width / 50) * percentage;
4500
5933
  this.activeObj.activePoint.endY += (maxDimension.height / 50) * percentage;
4501
5934
  this.activeObj.activePoint.width = this.activeObj.activePoint.endX - this.activeObj.activePoint.startX;
@@ -4541,8 +5974,6 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
4541
5974
  width = this.activeObj.activePoint.endX - x;
4542
5975
  height = this.activeObj.activePoint.endY - y;
4543
5976
  scale = Math.min(width, height);
4544
- var ratio = this.activeObj.shape.split('-');
4545
- ratio = ratio[1].split(':');
4546
5977
  var newScale = this.getScaleRatio(scale);
4547
5978
  this.activeObj.activePoint.endX -= newScale.x;
4548
5979
  this.activeObj.activePoint.endY -= newScale.y;
@@ -5201,6 +6632,7 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
5201
6632
  this.refreshActiveObj();
5202
6633
  return;
5203
6634
  }
6635
+ this.tempObjColl = extend([], this.objColl, [], true);
5204
6636
  this.currObjType.isCustomCrop = false;
5205
6637
  var temp = this.activeObj = extend({}, this.objColl[i], {}, true);
5206
6638
  this.objColl.splice(i, 1);
@@ -5210,11 +6642,35 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
5210
6642
  this.inMemoryContext.putImageData(this.imgDataColl[0].value, 0, 0);
5211
6643
  }
5212
6644
  else {
6645
+ if ((this.adjustmentLevel.sharpen || this.adjustmentLevel.bw) && !this.sharpenedImgData) {
6646
+ var data = void 0;
6647
+ var tempImageData = this.currImgData;
6648
+ if (this.adjustmentLevel.sharpen) {
6649
+ data = this.getSharpenData(this.currImgData);
6650
+ }
6651
+ else {
6652
+ data = this.getBlackAndWhiteData(tempImageData);
6653
+ }
6654
+ this.currImgData = data;
6655
+ this.sharpenedImgData = true;
6656
+ }
5213
6657
  this.inMemoryCanvas.width = this.currImgData.width;
5214
6658
  this.inMemoryCanvas.height = this.currImgData.height;
5215
6659
  this.inMemoryContext.putImageData(this.currImgData, 0, 0);
5216
6660
  }
5217
6661
  if (this.flipState !== '') {
6662
+ if ((this.adjustmentLevel.sharpen || this.adjustmentLevel.bw) && !this.sharpenedImgData) {
6663
+ var data = void 0;
6664
+ var tempImageData = this.currImgData;
6665
+ if (this.adjustmentLevel.sharpen) {
6666
+ data = this.getSharpenData(this.currImgData);
6667
+ }
6668
+ else {
6669
+ data = this.getBlackAndWhiteData(tempImageData);
6670
+ }
6671
+ this.currImgData = data;
6672
+ this.sharpenedImgData = true;
6673
+ }
5218
6674
  this.inMemoryContext.clearRect(0, 0, this.inMemoryCanvas.width, this.inMemoryCanvas.height);
5219
6675
  this.inMemoryContext.clearRect(0, 0, this.inMemoryCanvas.height, this.inMemoryCanvas.width);
5220
6676
  this.inMemoryCanvas.width = this.currImgData.width;
@@ -5223,15 +6679,10 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
5223
6679
  }
5224
6680
  this.setActivePoint();
5225
6681
  this.upperContext.drawImage(this.inMemoryCanvas, 0, 0);
6682
+ this.lowerContext.filter = this.canvasFilter;
5226
6683
  this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
5227
- this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
6684
+ this.redrawImgWithObj();
5228
6685
  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
6686
  this.activeObj = extend({}, temp, {}, true);
5236
6687
  var endPoint = { x: this.lowerCanvas.width - this.pannEnd.startX, y: this.lowerCanvas.height - this.pannEnd.startY };
5237
6688
  if (this.factor !== 1 && (this.activeObj.activePoint.startX < this.pannStart.startX || this.activeObj.activePoint.startY <
@@ -5614,7 +7065,7 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
5614
7065
  }
5615
7066
  else {
5616
7067
  if (this.currObjType.isCustomCrop) {
5617
- this.upperCanvas.style.cursor = 'cross-hair';
7068
+ this.upperCanvas.style.cursor = 'crosshair';
5618
7069
  }
5619
7070
  this.upperCanvas.style.cursor = 'default';
5620
7071
  }
@@ -5711,7 +7162,7 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
5711
7162
  }
5712
7163
  else {
5713
7164
  if (this.currObjType.isCustomCrop) {
5714
- this.upperCanvas.style.cursor = 'cross-hair';
7165
+ this.upperCanvas.style.cursor = 'crosshair';
5715
7166
  }
5716
7167
  this.upperCanvas.style.cursor = 'default';
5717
7168
  }
@@ -5771,7 +7222,7 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
5771
7222
  // eslint-disable-next-line @typescript-eslint/tslint/config
5772
7223
  this.lowerCanvas.toBlob(function (blob) {
5773
7224
  var blobUrl = URL.createObjectURL(blob);
5774
- proxy.baseImg.src = blobUrl;
7225
+ //proxy.baseImg.src = blobUrl;
5775
7226
  proxy.downloadImg(blobUrl, fileName + '.' + type);
5776
7227
  }, 'image/png');
5777
7228
  };
@@ -5821,21 +7272,6 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
5821
7272
  this.inMemoryContext.putImageData(imgData, 0, 0);
5822
7273
  }
5823
7274
  };
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
7275
  ImageEditor.prototype.calcPrevRatio = function () {
5840
7276
  var oldWidthRatio;
5841
7277
  var oldHeightRatio;
@@ -5942,15 +7378,23 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
5942
7378
  }
5943
7379
  else if (degree === 90 || degree === -90) {
5944
7380
  this.updateCurrentActiveObjPoint(degree);
7381
+ var tempFilter = this.lowerContext.filter;
7382
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
7383
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
5945
7384
  for (var i = 0; i < this.objColl.length; i++) {
5946
7385
  this.apply(this.objColl[i].shape, this.objColl[i]);
5947
7386
  }
7387
+ this.lowerContext.filter = tempFilter;
5948
7388
  }
5949
7389
  else {
5950
7390
  this.updateCurrentActiveObjPoint('zoom');
7391
+ var tempFilter = this.lowerContext.filter;
7392
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
7393
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
5951
7394
  for (var i = 0; i < this.objColl.length; i++) {
5952
7395
  this.apply(this.objColl[i].shape, this.objColl[i]);
5953
7396
  }
7397
+ this.lowerContext.filter = tempFilter;
5954
7398
  }
5955
7399
  }
5956
7400
  else if (this.objColl.length === 0 && (degree === 'horizontal' || degree === 'vertical' || degree === 'Horizontal' || degree === 'Vertical')) {
@@ -5998,12 +7442,14 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
5998
7442
  if (this.objColl[i].activePoint.startX <= this.lowerCanvas.width / 2) {
5999
7443
  this.objColl[i].activePoint.startX = this.lowerCanvas.width / 2 + ((this.lowerCanvas.width / 2) -
6000
7444
  this.objColl[i].activePoint.endX);
6001
- this.objColl[i].activePoint.endX = this.objColl[i].activePoint.startX + this.objColl[i].activePoint.width;
7445
+ this.objColl[i].activePoint.endX = this.objColl[i].activePoint.startX +
7446
+ this.objColl[i].activePoint.width;
6002
7447
  this.updateActiveObject(ratio, this.objColl[i].activePoint, this.objColl[i]);
6003
7448
  }
6004
7449
  else if (this.objColl[i].activePoint.startX >= this.lowerCanvas.width / 2) {
6005
7450
  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;
7451
+ this.objColl[i].activePoint.endX = this.objColl[i].activePoint.startX +
7452
+ this.objColl[i].activePoint.width;
6007
7453
  this.updateActiveObject(ratio, this.objColl[i].activePoint, this.objColl[i]);
6008
7454
  }
6009
7455
  }
@@ -6013,12 +7459,14 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6013
7459
  if (this.objColl[i].activePoint.startY <= this.lowerCanvas.height / 2) {
6014
7460
  this.objColl[i].activePoint.startY = this.lowerCanvas.height / 2 + ((this.lowerCanvas.height / 2) -
6015
7461
  this.objColl[i].activePoint.endY);
6016
- this.objColl[i].activePoint.endY = this.objColl[i].activePoint.startY + this.objColl[i].activePoint.height;
7462
+ this.objColl[i].activePoint.endY = this.objColl[i].activePoint.startY +
7463
+ this.objColl[i].activePoint.height;
6017
7464
  this.updateActiveObject(ratio, this.objColl[i].activePoint, this.objColl[i]);
6018
7465
  }
6019
7466
  else if (this.objColl[i].activePoint.startY >= this.lowerCanvas.height / 2) {
6020
7467
  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;
7468
+ this.objColl[i].activePoint.endY = this.objColl[i].activePoint.startY +
7469
+ this.objColl[i].activePoint.height;
6022
7470
  this.updateActiveObject(ratio, this.objColl[i].activePoint, this.objColl[i]);
6023
7471
  }
6024
7472
  }
@@ -6033,22 +7481,30 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6033
7481
  this.objColl[i].activePoint.startY /= oldRatio.height;
6034
7482
  this.objColl[i].activePoint.endX /= oldRatio.width;
6035
7483
  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;
7484
+ this.objColl[i].activePoint.height = this.objColl[i].activePoint.endX -
7485
+ this.objColl[i].activePoint.startX;
7486
+ this.objColl[i].activePoint.width = this.objColl[i].activePoint.endY -
7487
+ this.objColl[i].activePoint.startY;
6038
7488
  this.objColl[i].strokeSettings.strokeWidth /= (oldRatio.width / this.factor);
6039
7489
  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;
7490
+ this.objColl[i].activePoint.endX = this.objColl[i].activePoint.startX +
7491
+ this.objColl[i].activePoint.width;
7492
+ this.objColl[i].activePoint.endY = this.objColl[i].activePoint.startY +
7493
+ this.objColl[i].activePoint.height;
7494
+ this.objColl[i].activePoint.width = this.objColl[i].activePoint.endX -
7495
+ this.objColl[i].activePoint.startX;
7496
+ this.objColl[i].activePoint.height = this.objColl[i].activePoint.endY -
7497
+ this.objColl[i].activePoint.startY;
6044
7498
  }
6045
7499
  for (var i = 0; i < this.objColl.length; i++) {
6046
7500
  this.objColl[i].activePoint.startX *= oldRatio.width;
6047
7501
  this.objColl[i].activePoint.startY *= oldRatio.height;
6048
7502
  this.objColl[i].activePoint.endX *= oldRatio.width;
6049
7503
  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;
7504
+ this.objColl[i].activePoint.width = this.objColl[i].activePoint.endX -
7505
+ this.objColl[i].activePoint.startX;
7506
+ this.objColl[i].activePoint.height = this.objColl[i].activePoint.endY -
7507
+ this.objColl[i].activePoint.startY;
6052
7508
  this.objColl[i].strokeSettings.strokeWidth *= ratio.width;
6053
7509
  }
6054
7510
  for (var i = 0; i < this.objColl.length; i++) {
@@ -6118,10 +7574,7 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6118
7574
  tempObjColl = [];
6119
7575
  this.refreshActiveObj();
6120
7576
  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
- }
7577
+ this.redrawImgWithObj();
6125
7578
  this.activeObj.flippedText = false;
6126
7579
  this.currObjType.shape = '';
6127
7580
  this.refreshActiveObj();
@@ -6139,17 +7592,27 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6139
7592
  showSpinner(proxy_1.element);
6140
7593
  proxy_1.element.style.opacity = '0.5';
6141
7594
  proxy_1.lowerContext.clearRect(0, 0, proxy_1.lowerCanvas.width, proxy_1.lowerCanvas.height);
7595
+ var temp = proxy_1.lowerContext.filter;
7596
+ proxy_1.lowerContext.filter = proxy_1.initialAdjustmentValue = proxy_1.adjustmentValue = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
7597
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
7598
+ if (proxy_1.cssClass) {
7599
+ addClass([proxy_1.element], proxy_1.cssClass.split(' '));
7600
+ }
6142
7601
  proxy_1.lowerContext.drawImage(proxy_1.inMemoryCanvas, 0, 0);
6143
7602
  proxy_1.baseImg.src = URL.createObjectURL(blob);
6144
7603
  proxy_1.upperContext.clearRect(0, 0, proxy_1.upperCanvas.width, proxy_1.upperCanvas.height);
6145
7604
  proxy_1.togglePen = false;
6146
7605
  proxy_1.upperCanvas.style.cursor = 'default';
7606
+ proxy_1.lowerContext.filter = temp;
7607
+ var tempFilter = proxy_1.lowerContext.filter;
7608
+ proxy_1.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
7609
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
6147
7610
  for (var i = 0, len = proxy_1.objColl.length; i < len; i++) {
6148
7611
  proxy_1.apply(proxy_1.objColl[i].shape, proxy_1.objColl[i], 'duplicate');
6149
7612
  }
7613
+ proxy_1.lowerContext.filter = tempFilter;
6150
7614
  proxy_1.togglePen = true;
6151
7615
  }, 'image/png');
6152
- this.isUndoRedo = false;
6153
7616
  this.degree = 0;
6154
7617
  }
6155
7618
  else {
@@ -6164,7 +7627,6 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6164
7627
  }
6165
7628
  this.keyHistory = '';
6166
7629
  }
6167
- this.isUndoRedo = false;
6168
7630
  }
6169
7631
  }
6170
7632
  };
@@ -6297,6 +7759,9 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6297
7759
  if (this.activeObj.textSettings.fontSize < 20 * (ratio.width + ratio.height)) {
6298
7760
  this.activeObj.textSettings.fontSize = 20 * (ratio.width + ratio.height);
6299
7761
  }
7762
+ if (this.factor > 1) {
7763
+ this.activeObj.textSettings.fontSize /= this.factor;
7764
+ }
6300
7765
  }
6301
7766
  this.activeObj.shapeDegree = this.degree;
6302
7767
  this.activeObj.shapeFlip = this.currFlipState;
@@ -6315,6 +7780,8 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6315
7780
  this.setCenterPoints(true, width, height);
6316
7781
  }
6317
7782
  this.addLetter(this.activeObj.textSettings.text);
7783
+ this.objColl.push(this.activeObj);
7784
+ this.redrawShape(this.objColl[this.objColl.length - 1]);
6318
7785
  this.refreshToolbar('text');
6319
7786
  }
6320
7787
  };
@@ -6388,7 +7855,28 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6388
7855
  inRange = true;
6389
7856
  }
6390
7857
  }
6391
- return inRange;
7858
+ return inRange;
7859
+ };
7860
+ ImageEditor.prototype.updateInMemoryContext = function (imgData, isUpdate) {
7861
+ var temp = extend({}, this.activeObj, {}, true);
7862
+ this.redrawImgWithObj();
7863
+ this.activeObj = temp;
7864
+ if (isNullOrUndefined(isUpdate)) {
7865
+ imgData = this.lowerContext.getImageData(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
7866
+ }
7867
+ this.inMemoryContext.clearRect(0, 0, this.inMemoryCanvas.width, this.inMemoryCanvas.height);
7868
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
7869
+ this.inMemoryCanvas.width = imgData.width;
7870
+ this.inMemoryCanvas.height = imgData.height;
7871
+ this.inMemoryContext.putImageData(imgData, 0, 0);
7872
+ };
7873
+ ImageEditor.prototype.clearActObj = function () {
7874
+ if (this.textBox.style.display === 'none') {
7875
+ this.refreshActiveObj();
7876
+ this.applyActObj();
7877
+ this.refreshActiveObj();
7878
+ this.currObjType.isCustomCrop = false;
7879
+ }
6392
7880
  };
6393
7881
  ImageEditor.prototype.rotateMultiple = function (length, degree) {
6394
7882
  for (var i = 0; i < length; i++) {
@@ -6401,6 +7889,7 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6401
7889
  if (this.degree === 360) {
6402
7890
  this.degree = 0;
6403
7891
  }
7892
+ var temp = this.lowerContext.filter;
6404
7893
  this.lowerContext.save();
6405
7894
  this.setMaximumDimension(90 * (i + 1));
6406
7895
  this.lowerContext.translate(this.lowerCanvas.width / 2, this.lowerCanvas.height / 2);
@@ -6412,7 +7901,9 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6412
7901
  }
6413
7902
  this.lowerCanvas.style.left = this.upperCanvas.style.left = (this.element.clientWidth - parseInt(this.lowerCanvas.style.maxWidth, 10) - 18) / 2 + 1 + 'px';
6414
7903
  this.lowerCanvas.style.top = this.upperCanvas.style.top = (this.element.clientHeight - this.toolbarHeight - parseInt(this.lowerCanvas.style.maxHeight, 10)) / 2 + 1 + 'px';
7904
+ this.updateBrightnessFilter();
6415
7905
  this.lowerContext.drawImage(this.inMemoryCanvas, -this.lowerCanvas.height / 2, -this.lowerCanvas.width / 2);
7906
+ this.lowerContext.filter = temp;
6416
7907
  if (degree > 0) {
6417
7908
  this.lowerContext.rotate(Math.PI / 180 * -90);
6418
7909
  }
@@ -6426,7 +7917,11 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6426
7917
  this.inMemoryCanvas.width = this.currImgData.width;
6427
7918
  this.inMemoryCanvas.height = this.currImgData.height;
6428
7919
  this.inMemoryContext.putImageData(this.currImgData, 0, 0);
7920
+ this.lowerContext.filter = this.canvasFilter;
7921
+ this.updateBrightnessFilter();
7922
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
6429
7923
  this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
7924
+ this.lowerContext.filter = temp;
6430
7925
  if (degree > 0) {
6431
7926
  this.redrawObj(90);
6432
7927
  }
@@ -6435,6 +7930,415 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6435
7930
  }
6436
7931
  }
6437
7932
  };
7933
+ ImageEditor.prototype.setBrightness = function (value) {
7934
+ if (!this.disabled && this.imgDataColl.length > 0) {
7935
+ if (this.currObjType.shape === 'freehanddraw') {
7936
+ this.apply();
7937
+ this.upperCanvas.style.cursor = 'default';
7938
+ this.currObjType.shape = '';
7939
+ }
7940
+ this.clearActObj();
7941
+ this.adjustmentLevel.brightness = value;
7942
+ value = this.getFilterValue(value);
7943
+ this.updateAdjustment('brightness', value);
7944
+ }
7945
+ };
7946
+ ImageEditor.prototype.setContrast = 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.contrast = value;
7955
+ value = this.getFilterValue(value);
7956
+ value *= 100;
7957
+ this.updateAdjustment('contrast', value);
7958
+ }
7959
+ };
7960
+ ImageEditor.prototype.setHue = function (value) {
7961
+ if (!this.disabled && this.imgDataColl.length > 0) {
7962
+ if (this.currObjType.shape === 'freehanddraw') {
7963
+ this.apply();
7964
+ this.upperCanvas.style.cursor = 'default';
7965
+ this.currObjType.shape = '';
7966
+ }
7967
+ this.clearActObj();
7968
+ this.adjustmentLevel.hue = value;
7969
+ value *= 3;
7970
+ this.updateAdjustment('hue', value);
7971
+ }
7972
+ };
7973
+ ImageEditor.prototype.setSaturation = 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.saturation = value;
7982
+ value = this.getSaturationFilterValue(value);
7983
+ value *= 100;
7984
+ this.updateAdjustment('saturation', value);
7985
+ }
7986
+ };
7987
+ ImageEditor.prototype.setOpacity = function (value) {
7988
+ if (!this.disabled && this.imgDataColl.length > 0) {
7989
+ if (this.currObjType.shape === 'freehanddraw') {
7990
+ this.apply();
7991
+ this.upperCanvas.style.cursor = 'default';
7992
+ this.currObjType.shape = '';
7993
+ }
7994
+ this.clearActObj();
7995
+ this.adjustmentLevel.opacity = value;
7996
+ if (value >= 50) {
7997
+ value /= 100;
7998
+ }
7999
+ else if (value === 40) {
8000
+ value = 0.45;
8001
+ }
8002
+ else if (value === 30) {
8003
+ value = 0.40;
8004
+ }
8005
+ else if (value === 20) {
8006
+ value = 0.35;
8007
+ }
8008
+ else if (value === 10) {
8009
+ value = 0.30;
8010
+ }
8011
+ else if (value === 0) {
8012
+ value = 0.25;
8013
+ }
8014
+ this.updateAdjustment('opacity', value);
8015
+ }
8016
+ };
8017
+ ImageEditor.prototype.setBlur = function (value) {
8018
+ if (!this.disabled && this.imgDataColl.length > 0) {
8019
+ if (this.currObjType.shape === 'freehanddraw') {
8020
+ this.apply();
8021
+ this.upperCanvas.style.cursor = 'default';
8022
+ this.currObjType.shape = '';
8023
+ }
8024
+ this.clearActObj();
8025
+ this.adjustmentLevel.blur = value;
8026
+ value /= 20;
8027
+ this.updateAdjustment('blur', value);
8028
+ }
8029
+ };
8030
+ ImageEditor.prototype.setExposure = function (value) {
8031
+ if (!this.disabled && this.imgDataColl.length > 0) {
8032
+ if (this.currObjType.shape === 'freehanddraw') {
8033
+ this.apply();
8034
+ this.upperCanvas.style.cursor = 'default';
8035
+ this.currObjType.shape = '';
8036
+ }
8037
+ this.clearActObj();
8038
+ this.adjustmentLevel.exposure = value;
8039
+ value = this.getFilterValue(value);
8040
+ this.updateAdjustment('exposure', value);
8041
+ }
8042
+ };
8043
+ ImageEditor.prototype.setFilter = function (type) {
8044
+ if (!this.disabled && this.imgDataColl.length > 0) {
8045
+ if (this.currObjType.shape === 'freehanddraw') {
8046
+ this.apply();
8047
+ this.upperCanvas.style.cursor = 'default';
8048
+ this.currObjType.shape = '';
8049
+ }
8050
+ this.clearActObj();
8051
+ this.updateAdjustment(type, null);
8052
+ }
8053
+ };
8054
+ ImageEditor.prototype.setBlackAndWhiteFilter = function (boolean) {
8055
+ if (!this.disabled && this.imgDataColl.length > 0) {
8056
+ if (this.currObjType.shape === 'freehanddraw') {
8057
+ this.apply();
8058
+ this.upperCanvas.style.cursor = 'default';
8059
+ this.currObjType.shape = '';
8060
+ }
8061
+ this.clearActObj();
8062
+ this.adjustmentLevel.bw = boolean;
8063
+ if (boolean) {
8064
+ if (this.degree === 0 && this.currFlipState === '') {
8065
+ this.replaceBWSharpenData('bw');
8066
+ }
8067
+ else if (this.degree !== 0) {
8068
+ var tempDegree = this.degree;
8069
+ this.rotate(-tempDegree);
8070
+ this.replaceBWSharpenData('bw');
8071
+ this.rotate(tempDegree);
8072
+ this.refreshToolbar('filter');
8073
+ }
8074
+ else if (this.currFlipState !== '') {
8075
+ var tempFlipState = this.currFlipState;
8076
+ this.flip(tempFlipState);
8077
+ this.replaceBWSharpenData('bw');
8078
+ this.flip(tempFlipState);
8079
+ this.refreshToolbar('filter');
8080
+ }
8081
+ var data = this.inMemoryContext.getImageData(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
8082
+ var imageData = this.getBlackAndWhiteData(data);
8083
+ this.inMemoryContext.clearRect(0, 0, this.inMemoryCanvas.width, this.inMemoryCanvas.height);
8084
+ this.inMemoryCanvas.width = imageData.width;
8085
+ this.inMemoryCanvas.height = imageData.height;
8086
+ this.inMemoryContext.putImageData(imageData, 0, 0);
8087
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
8088
+ this.lowerContext.filter = this.canvasFilter;
8089
+ var temp = this.lowerContext.filter;
8090
+ this.updateBrightnessFilter();
8091
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
8092
+ this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
8093
+ this.lowerContext.filter = temp;
8094
+ }
8095
+ else {
8096
+ if (this.degree === 0 && this.currFlipState === '') {
8097
+ this.updateBWSharpness();
8098
+ }
8099
+ else if (this.degree !== 0) {
8100
+ var tempDegree = this.degree;
8101
+ this.rotate(-tempDegree);
8102
+ this.updateBWSharpness();
8103
+ this.rotate(tempDegree);
8104
+ this.refreshToolbar('filter');
8105
+ if (this.sharpenedImgData) {
8106
+ this.sharpenedImgData = false;
8107
+ }
8108
+ }
8109
+ else if (this.currFlipState !== '') {
8110
+ var tempFlipState = this.currFlipState;
8111
+ this.flip(tempFlipState);
8112
+ this.updateBWSharpness();
8113
+ this.flip(tempFlipState);
8114
+ this.refreshToolbar('filter');
8115
+ if (this.sharpenedImgData) {
8116
+ this.sharpenedImgData = false;
8117
+ }
8118
+ }
8119
+ }
8120
+ }
8121
+ };
8122
+ ImageEditor.prototype.setSharpness = function (boolean) {
8123
+ if (!this.disabled && this.imgDataColl.length > 0) {
8124
+ if (this.currObjType.shape === 'freehanddraw') {
8125
+ this.apply();
8126
+ this.upperCanvas.style.cursor = 'default';
8127
+ this.currObjType.shape = '';
8128
+ }
8129
+ this.clearActObj();
8130
+ this.adjustmentLevel.sharpen = boolean;
8131
+ if (boolean) {
8132
+ if (this.degree === 0 && this.currFlipState === '') {
8133
+ this.replaceBWSharpenData('sharpen');
8134
+ }
8135
+ else if (this.degree !== 0) {
8136
+ var tempDegree = this.degree;
8137
+ this.rotate(-tempDegree);
8138
+ this.replaceBWSharpenData('sharpen');
8139
+ this.rotate(tempDegree);
8140
+ this.refreshToolbar('filter');
8141
+ }
8142
+ else if (this.currFlipState !== '') {
8143
+ var tempFlipState = this.currFlipState;
8144
+ this.flip(tempFlipState);
8145
+ this.replaceBWSharpenData('sharpen');
8146
+ this.flip(tempFlipState);
8147
+ this.refreshToolbar('filter');
8148
+ }
8149
+ var data = this.inMemoryContext.getImageData(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
8150
+ var imageData = this.getSharpenData(data);
8151
+ this.inMemoryContext.clearRect(0, 0, this.inMemoryCanvas.width, this.inMemoryCanvas.height);
8152
+ this.inMemoryCanvas.width = imageData.width;
8153
+ this.inMemoryCanvas.height = imageData.height;
8154
+ this.inMemoryContext.putImageData(imageData, 0, 0);
8155
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
8156
+ this.lowerContext.filter = this.canvasFilter;
8157
+ var temp = this.lowerContext.filter;
8158
+ this.updateBrightnessFilter();
8159
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
8160
+ this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
8161
+ this.lowerContext.filter = temp;
8162
+ }
8163
+ else {
8164
+ if (this.degree === 0 && this.currFlipState === '') {
8165
+ this.updateBWSharpness();
8166
+ }
8167
+ else if (this.degree !== 0) {
8168
+ var tempDegree = this.degree;
8169
+ this.rotate(-tempDegree);
8170
+ this.updateBWSharpness();
8171
+ this.rotate(tempDegree);
8172
+ this.refreshToolbar('filter');
8173
+ if (this.sharpenedImgData) {
8174
+ this.sharpenedImgData = false;
8175
+ }
8176
+ }
8177
+ else if (this.currFlipState !== '') {
8178
+ var tempFlipState = this.currFlipState;
8179
+ this.flip(tempFlipState);
8180
+ this.updateBWSharpness();
8181
+ this.flip(tempFlipState);
8182
+ this.refreshToolbar('filter');
8183
+ if (this.sharpenedImgData) {
8184
+ this.sharpenedImgData = false;
8185
+ }
8186
+ }
8187
+ }
8188
+ }
8189
+ };
8190
+ ImageEditor.prototype.replaceBWSharpenData = function (type) {
8191
+ this.tempImageData = this.inMemoryContext.getImageData(0, 0, this.inMemoryCanvas.width, this.inMemoryCanvas.height);
8192
+ var imageData = this.inMemoryContext.getImageData(0, 0, this.inMemoryCanvas.width, this.inMemoryCanvas.height);
8193
+ if (type === 'sharpen') {
8194
+ imageData = this.getSharpenData(this.tempImageData);
8195
+ }
8196
+ else {
8197
+ imageData = this.getBlackAndWhiteData(imageData);
8198
+ }
8199
+ this.inMemoryContext.clearRect(0, 0, this.inMemoryCanvas.width, this.inMemoryCanvas.height);
8200
+ this.inMemoryCanvas.width = imageData.width;
8201
+ this.inMemoryCanvas.height = imageData.height;
8202
+ this.inMemoryContext.putImageData(imageData, 0, 0);
8203
+ var tempObj;
8204
+ for (var index = 0; index < this.imgDataColl.length; index++) {
8205
+ if (this.imgDataColl[index].operation !== 'freehanddraw') {
8206
+ tempObj = this.imgDataColl[index];
8207
+ break;
8208
+ }
8209
+ }
8210
+ this.imgDataColl.splice(0, 1, { operation: 'updateCanvas', value: imageData });
8211
+ this.imgDataColl.splice(1, 1, tempObj);
8212
+ this.inMemoryContext.clearRect(0, 0, this.inMemoryCanvas.width, this.inMemoryCanvas.height);
8213
+ this.inMemoryCanvas.width = this.tempImageData.width;
8214
+ this.inMemoryCanvas.height = this.tempImageData.height;
8215
+ this.inMemoryContext.putImageData(this.tempImageData, 0, 0);
8216
+ };
8217
+ ImageEditor.prototype.updateBWSharpness = function () {
8218
+ this.inMemoryContext.clearRect(0, 0, this.inMemoryCanvas.width, this.inMemoryCanvas.height);
8219
+ this.inMemoryCanvas.width = this.tempImageData.width;
8220
+ this.inMemoryCanvas.height = this.tempImageData.height;
8221
+ this.inMemoryContext.putImageData(this.tempImageData, 0, 0);
8222
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
8223
+ this.lowerContext.filter = this.canvasFilter;
8224
+ this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
8225
+ this.imgDataColl.shift();
8226
+ };
8227
+ ImageEditor.prototype.getSharpenData = function (imageData) {
8228
+ var data = imageData.data;
8229
+ var weights = [0, -1, 0, -1, 5, -1, 0, -1, 0];
8230
+ var side = Math.round(Math.sqrt(weights.length));
8231
+ var halfSide = Math.floor(side / 2);
8232
+ var sw = imageData.width;
8233
+ var sh = imageData.height;
8234
+ var output = this.inMemoryContext.createImageData(sw, sh);
8235
+ var dst = output.data;
8236
+ // go through the destination image pixels
8237
+ var alphaFac = 0;
8238
+ var r;
8239
+ var g;
8240
+ var b;
8241
+ var a;
8242
+ var dstOff;
8243
+ var scx;
8244
+ var scy;
8245
+ var srcOff;
8246
+ var wt;
8247
+ var x;
8248
+ var y;
8249
+ var cx;
8250
+ var cy;
8251
+ for (y = 0; y < sh; y++) {
8252
+ for (x = 0; x < sw; x++) {
8253
+ dstOff = (y * sw + x) * 4;
8254
+ r = 0;
8255
+ g = 0;
8256
+ b = 0;
8257
+ a = 0;
8258
+ for (cy = 0; cy < side; cy++) {
8259
+ for (cx = 0; cx < side; cx++) {
8260
+ scy = y + cy - halfSide;
8261
+ scx = x + cx - halfSide;
8262
+ if (scy < 0 || scy >= sh || scx < 0 || scx >= sw) {
8263
+ continue;
8264
+ }
8265
+ srcOff = (scy * sw + scx) * 4;
8266
+ wt = weights[cy * side + cx];
8267
+ r += data[srcOff] * wt;
8268
+ g += data[srcOff + 1] * wt;
8269
+ b += data[srcOff + 2] * wt;
8270
+ if (!alphaFac) {
8271
+ a += data[srcOff + 3] * wt;
8272
+ }
8273
+ }
8274
+ }
8275
+ dst[dstOff] = r;
8276
+ dst[dstOff + 1] = g;
8277
+ dst[dstOff + 2] = b;
8278
+ if (!alphaFac) {
8279
+ dst[dstOff + 3] = a;
8280
+ }
8281
+ else {
8282
+ dst[dstOff + 3] = data[dstOff + 3];
8283
+ }
8284
+ }
8285
+ }
8286
+ return output;
8287
+ };
8288
+ ImageEditor.prototype.getFilterValue = function (value) {
8289
+ var filterValue;
8290
+ if (value === 0) {
8291
+ filterValue = 1;
8292
+ }
8293
+ else {
8294
+ filterValue = 1 + ((value * 0.5) / 100);
8295
+ }
8296
+ return filterValue;
8297
+ };
8298
+ ImageEditor.prototype.setFilterValue = function (value) {
8299
+ var filterValue;
8300
+ if (value === 1) {
8301
+ filterValue = 0;
8302
+ }
8303
+ else {
8304
+ filterValue = ((value - 1) * 100) / 0.5;
8305
+ }
8306
+ return Math.round(filterValue);
8307
+ };
8308
+ ImageEditor.prototype.getSaturationFilterValue = function (value) {
8309
+ var filterValue;
8310
+ if (value === 0) {
8311
+ filterValue = 1;
8312
+ }
8313
+ else {
8314
+ filterValue = 1 + (value / 100);
8315
+ }
8316
+ return filterValue;
8317
+ };
8318
+ ImageEditor.prototype.setSaturationFilterValue = function (value) {
8319
+ var filterValue;
8320
+ if (value === 1) {
8321
+ filterValue = 0;
8322
+ }
8323
+ else {
8324
+ filterValue = (value - 1) * 100;
8325
+ }
8326
+ return Math.round(filterValue);
8327
+ };
8328
+ ImageEditor.prototype.getBlackAndWhiteData = function (imageData) {
8329
+ for (var i = 0; i < imageData.data.length; i += 4) {
8330
+ var count = imageData.data[i] + imageData.data[i + 1] + imageData.data[i + 2];
8331
+ var colour = 0;
8332
+ if (count > 383) {
8333
+ colour = 255;
8334
+ }
8335
+ imageData.data[i] = colour;
8336
+ imageData.data[i + 1] = colour;
8337
+ imageData.data[i + 2] = colour;
8338
+ imageData.data[i + 3] = 255;
8339
+ }
8340
+ return imageData;
8341
+ };
6438
8342
  /**
6439
8343
  * Clear a current selection.
6440
8344
  *
@@ -6471,6 +8375,16 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6471
8375
  // eslint-disable-next-line @typescript-eslint/no-this-alias
6472
8376
  var proxy_2 = this;
6473
8377
  isCrop = true;
8378
+ var canvasFilter = this.canvasFilter;
8379
+ var tempActObj = extend({}, this.activeObj, {}, true);
8380
+ this.lowerContext.filter = this.canvasFilter = 'none';
8381
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
8382
+ this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
8383
+ for (var j = 0; j < this.objColl.length; j++) {
8384
+ this.apply(this.objColl[j].shape, this.objColl[j]);
8385
+ this.refreshActiveObj();
8386
+ }
8387
+ this.activeObj = tempActObj;
6474
8388
  this.upperCanvas.style.display = 'none';
6475
8389
  var widthRatio = void 0;
6476
8390
  var heightRatio = void 0;
@@ -6510,6 +8424,7 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6510
8424
  this.updateInMemoryContext(imgData);
6511
8425
  }
6512
8426
  this.degree = 0;
8427
+ this.updateBrightnessFilter();
6513
8428
  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
8429
  }
6515
8430
  if (this.flipState !== '') {
@@ -6524,6 +8439,7 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6524
8439
  this.lowerCanvas.style.maxHeight = this.upperCanvas.style.maxHeight = maxDimension.height + 'px';
6525
8440
  this.lowerCanvas.width = this.upperCanvas.width = maxDimension.width * widthRatio;
6526
8441
  this.lowerCanvas.height = this.upperCanvas.height = maxDimension.height * heightRatio;
8442
+ this.updateBrightnessFilter();
6527
8443
  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
8444
  }
6529
8445
  }
@@ -6544,6 +8460,7 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6544
8460
  ((this.element.clientWidth - parseInt(cssObj.width, 10) - 18) / 2) + 1 + 'px';
6545
8461
  this.lowerCanvas.style.top = this.upperCanvas.style.top = ((this.element.clientHeight - this.toolbarHeight
6546
8462
  - parseInt(cssObj.height, 10)) / 2) + 1 + 'px';
8463
+ this.updateBrightnessFilter();
6547
8464
  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
8465
  }
6549
8466
  if (this.activeObj.shape === 'crop-circle') {
@@ -6552,6 +8469,7 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6552
8469
  this.inMemoryCanvas.height = imgData_1.height;
6553
8470
  this.inMemoryContext.putImageData(imgData_1, 0, 0);
6554
8471
  this.lowerContext.save();
8472
+ this.updateBrightnessFilter();
6555
8473
  this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0, this.baseImg.width, this.baseImg.height);
6556
8474
  this.lowerContext.globalCompositeOperation = 'destination-in';
6557
8475
  this.lowerContext.beginPath();
@@ -6564,18 +8482,11 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6564
8482
  showSpinner(this.element);
6565
8483
  this.element.style.opacity = '0.5';
6566
8484
  var blobUrl_1;
6567
- var data_1;
6568
8485
  // eslint-disable-next-line @typescript-eslint/tslint/config
6569
8486
  this.lowerCanvas.toBlob(function (blob) {
6570
8487
  blobUrl_1 = URL.createObjectURL(blob);
6571
- proxy_2.isUndoRedo = false;
6572
8488
  proxy_2.baseImg.src = blobUrl_1;
6573
- data_1 = proxy_2.lowerContext.getImageData(0, 0, proxy_2.lowerCanvas.width, proxy_2.lowerCanvas.height);
6574
8489
  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
8490
  }, 'image/png');
6580
8491
  this.objColl = [];
6581
8492
  this.refreshActiveObj();
@@ -6584,26 +8495,11 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6584
8495
  this.upperContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
6585
8496
  this.lowerContext.globalAlpha = 0;
6586
8497
  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
8498
  this.factor = 1;
8499
+ this.canvasFilter = canvasFilter;
6590
8500
  }
6591
8501
  return isCrop;
6592
8502
  };
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
8503
  /**
6608
8504
  * Flips an image by horizontally or vertically.
6609
8505
  *
@@ -6620,8 +8516,8 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6620
8516
  }
6621
8517
  var transitionArgs = { direction: direction };
6622
8518
  this.trigger('flipping', transitionArgs);
6623
- this.lastAction = 'flip';
6624
- this.flipMethod = true;
8519
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
8520
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
6625
8521
  var splitWords = [];
6626
8522
  var activeObjShape = void 0;
6627
8523
  if (!isNullOrUndefined(this.activeObj.activePoint)) {
@@ -6642,7 +8538,6 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6642
8538
  this.lowerContext.scale(-1, 1);
6643
8539
  this.upperContext.translate(this.upperContext.canvas.width, 0);
6644
8540
  this.upperContext.scale(-1, 1);
6645
- this.flipDirection = 'horizontal';
6646
8541
  if (this.flipState === '' || this.flipState.toLowerCase() === 'vertical') {
6647
8542
  this.flipState = 'horizontal';
6648
8543
  }
@@ -6658,7 +8553,6 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6658
8553
  this.lowerContext.scale(1, -1);
6659
8554
  this.upperContext.translate(0, this.upperContext.canvas.height);
6660
8555
  this.upperContext.scale(1, -1);
6661
- this.flipDirection = 'vertical';
6662
8556
  if (this.flipState.toLowerCase() === '' || this.flipState.toLowerCase() === 'horizontal') {
6663
8557
  this.flipState = 'vertical';
6664
8558
  }
@@ -6669,13 +8563,25 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6669
8563
  this.currFlipState = 'vertical';
6670
8564
  }
6671
8565
  }
8566
+ var temp = this.lowerContext.filter;
8567
+ this.updateBrightnessFilter();
8568
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
6672
8569
  this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
8570
+ this.lowerContext.filter = temp;
6673
8571
  this.currImgData = this.lowerContext.getImageData(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
8572
+ this.lowerContext.filter = this.canvasFilter;
8573
+ this.updateBrightnessFilter();
8574
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
8575
+ this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
8576
+ this.lowerContext.filter = temp;
6674
8577
  this.inMemoryContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
6675
8578
  this.inMemoryCanvas.width = this.currImgData.width;
6676
8579
  this.inMemoryCanvas.height = this.currImgData.height;
6677
8580
  this.inMemoryContext.putImageData(this.currImgData, 0, 0);
6678
8581
  if (this.flipState.toLowerCase() === 'horizontal') {
8582
+ var tempFilter = this.lowerContext.filter;
8583
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
8584
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
6679
8585
  for (var i = 0, len = this.objColl.length; i < len; i++) {
6680
8586
  this.objColl[i].flippedText = false;
6681
8587
  if (this.objColl[i].shapeFlip !== '' && this.objColl[i].shapeFlip === this.currFlipState) {
@@ -6685,13 +8591,16 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6685
8591
  this.apply(this.objColl[i].shape, this.objColl[i]);
6686
8592
  }
6687
8593
  }
8594
+ this.lowerContext.filter = tempFilter;
6688
8595
  this.lowerContext.translate(this.lowerContext.canvas.width, 0);
6689
8596
  this.lowerContext.scale(-1, 1);
6690
8597
  this.upperContext.translate(this.upperContext.canvas.width, 0);
6691
8598
  this.upperContext.scale(-1, 1);
6692
- this.flipDirection = '';
6693
8599
  }
6694
8600
  else if (this.flipState.toLowerCase() === 'vertical') {
8601
+ var tempFilter = this.lowerContext.filter;
8602
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
8603
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
6695
8604
  for (var i = 0, len = this.objColl.length; i < len; i++) {
6696
8605
  this.objColl[i].flippedText = false;
6697
8606
  if (this.objColl[i].shapeFlip !== '' && this.objColl[i].shapeFlip === this.currFlipState) {
@@ -6701,11 +8610,11 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6701
8610
  this.apply(this.objColl[i].shape, this.objColl[i]);
6702
8611
  }
6703
8612
  }
8613
+ this.lowerContext.filter = tempFilter;
6704
8614
  this.lowerContext.translate(0, this.lowerContext.canvas.height);
6705
8615
  this.lowerContext.scale(1, -1);
6706
8616
  this.upperContext.translate(0, this.upperContext.canvas.height);
6707
8617
  this.upperContext.scale(1, -1);
6708
- this.flipDirection = '';
6709
8618
  }
6710
8619
  for (var i = 0, len = this.objColl.length; i < len; i++) {
6711
8620
  if (this.objColl[i].flipObjColl.length === 0) {
@@ -6720,15 +8629,15 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6720
8629
  }
6721
8630
  this.redrawObj(direction.toLowerCase());
6722
8631
  if (this.flipState === '') {
8632
+ var tempFilter = this.lowerContext.filter;
8633
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
8634
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
6723
8635
  for (var i = 0, len = this.objColl.length; i < len; i++) {
6724
8636
  this.apply(this.objColl[i].shape, this.objColl[i]);
6725
8637
  }
8638
+ this.lowerContext.filter = tempFilter;
6726
8639
  }
6727
8640
  this.refreshActiveObj();
6728
- if (!this.isUndoRedo) {
6729
- this.updateUndoRedoColl('flip', direction, this.objColl);
6730
- }
6731
- this.isUndoRedo = this.flipMethod = false;
6732
8641
  if (!isNullOrUndefined(activeObjShape)) {
6733
8642
  if (activeObjShape === 'custom') {
6734
8643
  this.activeObj.activePoint = { startX: 0, startY: 0, endX: this.lowerCanvas.width,
@@ -6740,6 +8649,7 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6740
8649
  this.select(activeObjShape);
6741
8650
  }
6742
8651
  }
8652
+ this.refreshToolbar('main');
6743
8653
  }
6744
8654
  };
6745
8655
  /**
@@ -6760,11 +8670,13 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6760
8670
  */
6761
8671
  ImageEditor.prototype.open = function (data) {
6762
8672
  if (!this.disabled) {
8673
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
8674
+ var proxy_3 = this;
6763
8675
  showSpinner(this.element);
6764
8676
  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';
8677
+ var toolbar_11 = document.querySelector('#' + this.element.id + '_currPos');
8678
+ if (toolbar_11) {
8679
+ toolbar_11.style.display = 'none';
6768
8680
  }
6769
8681
  if (this.defToolbarItems.length === 0 &&
6770
8682
  (isNullOrUndefined(document.getElementById(this.element.id + '_toolbar')))) {
@@ -6773,11 +8685,30 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6773
8685
  if (isNullOrUndefined(this.toolbarTemplate)) {
6774
8686
  this.update();
6775
8687
  }
8688
+ this.degree = 0;
8689
+ this.flipState = '';
8690
+ this.factor = 1;
8691
+ this.imgDataColl = [];
6776
8692
  var type = typeof (data);
6777
8693
  if (type === 'string') {
8694
+ var fileName = data.split('.');
8695
+ if (fileName[fileName.length - 1].toLowerCase() === 'jpg' || fileName[fileName.length - 1].toLowerCase() === 'jpeg') {
8696
+ this.imageFileType = 'Jpeg';
8697
+ }
8698
+ else if (fileName[fileName.length - 1].toLowerCase() === 'png') {
8699
+ this.imageFileType = 'Png';
8700
+ }
8701
+ else if (fileName[fileName.length - 1].toLowerCase() === 'svg') {
8702
+ this.imageFileType = 'Svg';
8703
+ }
8704
+ fileName = fileName[fileName.length - 2].split('/');
8705
+ this.imageFileName = fileName[fileName.length - 1];
6778
8706
  this.imageOnLoad(data);
6779
8707
  }
6780
8708
  else {
8709
+ this.imageFileName = 'ImageEditor';
8710
+ this.imageFileType = 'Jpeg';
8711
+ var tempFilter = this.lowerContext.filter;
6781
8712
  this.lowerCanvas = document.querySelector('#' + this.element.id + '_lowerCanvas');
6782
8713
  this.upperCanvas = document.querySelector('#' + this.element.id + '_upperCanvas');
6783
8714
  this.lowerContext = this.lowerCanvas.getContext('2d');
@@ -6791,10 +8722,19 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6791
8722
  this.imgDataColl.push({ operation: 'open', value: data });
6792
8723
  this.lowerCanvas.width = this.upperCanvas.width = data.width;
6793
8724
  this.lowerCanvas.height = this.upperCanvas.height = data.height;
8725
+ this.lowerContext.filter = tempFilter;
8726
+ var temp = this.lowerContext.filter;
8727
+ this.updateBrightnessFilter();
6794
8728
  this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
6795
- this.updateCanvas();
8729
+ this.lowerContext.filter = temp;
8730
+ this.redrawImg(this.lowerContext.filter);
6796
8731
  hideSpinner(this.element);
6797
8732
  this.element.style.opacity = '1';
8733
+ // eslint-disable-next-line @typescript-eslint/tslint/config
8734
+ this.lowerCanvas.toBlob(function (blob) {
8735
+ showSpinner(proxy_3.element);
8736
+ proxy_3.baseImg.src = URL.createObjectURL(blob);
8737
+ }, 'image/png');
6798
8738
  }
6799
8739
  }
6800
8740
  };
@@ -6811,6 +8751,8 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6811
8751
  this.lowerContext.clearRect(0, 0, this.inMemoryCanvas.height, this.inMemoryCanvas.width);
6812
8752
  this.upperContext.clearRect(0, 0, this.inMemoryCanvas.width, this.inMemoryCanvas.height);
6813
8753
  this.upperContext.clearRect(0, 0, this.inMemoryCanvas.height, this.inMemoryCanvas.width);
8754
+ this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
8755
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
6814
8756
  showSpinner(this.element);
6815
8757
  this.element.style.opacity = '0.5';
6816
8758
  if (this.imgDataColl.length > 0) {
@@ -6821,11 +8763,13 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6821
8763
  this.inMemoryCanvas.width = this.imgDataColl[0].value.width;
6822
8764
  this.inMemoryCanvas.height = this.imgDataColl[0].value.height;
6823
8765
  this.inMemoryContext.putImageData(this.imgDataColl[0].value, 0, 0);
6824
- this.redrawImg();
8766
+ this.redrawImg(this.lowerContext.filter);
8767
+ this.lowerCanvas.width = this.baseImg.width;
8768
+ this.lowerCanvas.height = this.baseImg.height;
6825
8769
  }
6826
8770
  this.lowerContext.setTransform(1, 0, 0, 1, 0, 0);
6827
8771
  this.upperContext.setTransform(1, 0, 0, 1, 0, 0);
6828
- this.baseImg.src = this.baseImgSrc;
8772
+ this.baseImg.src = this.baseImgSrc.id;
6829
8773
  this.factor = 1;
6830
8774
  this.refreshToolbar('main');
6831
8775
  if (Browser.isDevice && document.getElementById(this.element.id + '_bottomToolbar')) {
@@ -6834,22 +8778,20 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6834
8778
  this.objColl = [];
6835
8779
  this.imgDataColl = [];
6836
8780
  this.degree = 0;
6837
- this.flipState = this.keyHistory = this.currFlipState = this.flipDirection = '';
8781
+ this.flipState = this.keyHistory = this.currFlipState = '';
6838
8782
  this.upperCanvas.style.display = 'none';
8783
+ this.togglePan = this.togglePen = false;
6839
8784
  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;
8785
+ this.dragCanvas = this.activeObj.flippedText = false;
6842
8786
  this.currImgData = {};
6843
8787
  this.pannStart = { startX: 0, startY: 0, width: 0, height: 0 };
6844
8788
  this.pannEnd = { startX: 0, startY: 0, width: 0, height: 0 };
6845
8789
  this.lowerContext.lineWidth = this.upperContext.lineWidth = undefined;
6846
- this.togglePan = this.togglePen = this.rotateMethod = false;
6847
8790
  this.lastX = this.lastY = 0;
6848
8791
  this.dragStart = { x: 0, y: 0 };
6849
8792
  this.touchEndPoint = {};
6850
8793
  this.prevX = this.currX = this.prevY = this.currY = 0;
6851
- this.lastAction = this.tempKeyHistory = '';
6852
- this.isBoldbtn = this.isItalicbtn = false;
8794
+ this.tempKeyHistory = '';
6853
8795
  this.currentToolbar = 'main';
6854
8796
  this.textStartPoints = { x: 0, y: 0 };
6855
8797
  this.fontSizeColl = this.penDrawColl = [];
@@ -6859,14 +8801,26 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6859
8801
  this.textSettings =
6860
8802
  { text: 'Enter Text', fontFamily: 'Arial', fontSize: null, bold: false, italic: false, underline: false };
6861
8803
  this.tempStrokeSettings = { strokeColor: '#fff', fillColor: '', strokeWidth: null };
6862
- this.penStrokeWidth = undefined;
6863
8804
  this.tempTextSettings =
6864
8805
  { text: 'Enter Text', fontFamily: 'Arial', fontSize: null, bold: false, italic: false, underline: false };
6865
8806
  this.refreshActiveObj();
6866
8807
  this.timer = undefined;
8808
+ this.penStrokeWidth = undefined;
6867
8809
  this.isScreenOriented = false;
8810
+ this.tempObjColl = [];
8811
+ this.tempObjColl = undefined;
8812
+ this.adjustmentLevel = { brightness: 0, contrast: 0, hue: 0, opacity: 100, saturation: 0, blur: 0, exposure: 0, sharpen: false, bw: false };
8813
+ this.tempAdjustmentLevel = { brightness: 0, contrast: 0, hue: 0, opacity: 100, saturation: 0, blur: 0, exposure: 0, sharpen: false, bw: false };
8814
+ this.imageFileName = '';
8815
+ this.imageFileType = undefined;
8816
+ this.canvasFilter = this.currentFilter = this.tempAdjustmentValue = '';
8817
+ this.lowerContext.filter = this.initialAdjustmentValue = this.adjustmentValue = 'brightness(' + 1 + ') ' + 'contrast(' + 100
8818
+ + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
8819
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
8820
+ this.tempImageData = undefined;
8821
+ this.sharpenedImgData = this.isBrightnessAdjusted = this.isInitialLoading = false;
6868
8822
  this.currObjType = { shape: '', isDragging: false, isActiveObj: false, isText: false, isInitialText: false, isLine: false,
6869
- isInitialLine: false, isCustomCrop: false, isZoomed: false };
8823
+ isInitialLine: false, isCustomCrop: false, isZoomed: false, isFiltered: false, isSave: false };
6870
8824
  }
6871
8825
  };
6872
8826
  /**
@@ -6894,7 +8848,6 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6894
8848
  }
6895
8849
  }
6896
8850
  this.redrawActObj();
6897
- var factor = this.factor;
6898
8851
  if (this.factor !== 1) {
6899
8852
  this.lowerContext.setTransform(1, 0, 0, 1, 0, 0);
6900
8853
  this.upperContext.setTransform(1, 0, 0, 1, 0, 0);
@@ -6910,13 +8863,16 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6910
8863
  if (this.degree === 360) {
6911
8864
  this.degree = 0;
6912
8865
  }
8866
+ var temp = this.lowerContext.filter;
6913
8867
  this.lowerContext.save();
6914
8868
  this.setMaximumDimension(this.degree);
6915
8869
  this.lowerContext.translate(this.lowerCanvas.width / 2, this.lowerCanvas.height / 2);
6916
8870
  this.lowerContext.rotate(Math.PI / 180 * degree);
6917
8871
  this.lowerCanvas.style.left = this.upperCanvas.style.left = (this.element.clientWidth - parseInt(this.lowerCanvas.style.maxWidth, 10) - 18) / 2 + 1 + 'px';
6918
8872
  this.lowerCanvas.style.top = this.upperCanvas.style.top = (this.element.clientHeight - this.toolbarHeight - parseInt(this.lowerCanvas.style.maxHeight, 10)) / 2 + 1 + 'px';
8873
+ this.updateBrightnessFilter();
6919
8874
  this.lowerContext.drawImage(this.inMemoryCanvas, -this.lowerCanvas.height / 2, -this.lowerCanvas.width / 2);
8875
+ this.lowerContext.filter = temp;
6920
8876
  this.lowerContext.rotate(Math.PI / 180 * -degree);
6921
8877
  this.lowerContext.translate(-this.lowerCanvas.width / 2, -this.lowerCanvas.height / 2);
6922
8878
  this.lowerContext.restore();
@@ -6925,12 +8881,17 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6925
8881
  this.inMemoryCanvas.width = this.currImgData.width;
6926
8882
  this.inMemoryCanvas.height = this.currImgData.height;
6927
8883
  this.inMemoryContext.putImageData(this.currImgData, 0, 0);
8884
+ this.lowerContext.filter = this.canvasFilter;
8885
+ this.updateBrightnessFilter();
8886
+ this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
6928
8887
  this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
8888
+ this.lowerContext.filter = temp;
6929
8889
  this.redrawObj(degree);
6930
8890
  }
6931
8891
  if (!isNullOrUndefined(activeObjShape)) {
6932
8892
  if (activeObjShape === 'custom') {
6933
- var endPoint = { x: this.lowerCanvas.width - this.pannEnd.startX, y: this.lowerCanvas.height - this.pannEnd.startY };
8893
+ var endPoint = { x: this.lowerCanvas.width - this.pannEnd.startX, y: this.lowerCanvas.height -
8894
+ this.pannEnd.startY };
6934
8895
  this.activeObj.activePoint = { startX: this.pannStart.startX, startY: this.pannStart.startY, endX: endPoint.x,
6935
8896
  endY: endPoint.y, width: endPoint.x - this.pannStart.startX, height: endPoint.y - this.pannStart.startY };
6936
8897
  this.updateActiveObject(this.calcRatio(), this.activeObj.activePoint, this.activeObj);
@@ -6942,10 +8903,6 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6942
8903
  this.refreshToolbar('main', true, true);
6943
8904
  }
6944
8905
  this.factor = 1;
6945
- if (!this.isUndoRedo) {
6946
- this.updateUndoRedoColl('rotate', degree, this.objColl, null);
6947
- }
6948
- this.isUndoRedo = false;
6949
8906
  this.refreshToolbar('main');
6950
8907
  }
6951
8908
  return isRotate;
@@ -6966,35 +8923,34 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
6966
8923
  this.applyPenDraw();
6967
8924
  }
6968
8925
  this.applyActObj();
8926
+ this.lowerContext.filter = this.canvasFilter;
6969
8927
  if (this.factor !== 1) {
6970
8928
  this.lowerContext.setTransform(1, 0, 0, 1, 0, 0);
6971
8929
  this.upperContext.setTransform(1, 0, 0, 1, 0, 0);
6972
8930
  this.factor = 1;
6973
8931
  this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
6974
8932
  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
- }
8933
+ this.redrawImgWithObj();
6980
8934
  }
6981
8935
  type = type ? type : 'Png';
6982
8936
  this.redrawActObj();
6983
- var beforeSave = { cancel: false, fileName: fileName ? fileName : 'ImageEditor', fileType: type };
6984
- var saved_1 = { fileName: fileName ? fileName : 'ImageEditor', fileType: type };
8937
+ fileName = fileName ? fileName : this.imageFileName;
8938
+ var beforeSave = { cancel: false, fileName: fileName, fileType: type };
8939
+ var saved_1 = { fileName: fileName ? fileName : this.imageFileName, fileType: type };
6985
8940
  this.trigger('beforeSave', beforeSave, function (observableSaveArgs) {
6986
8941
  if (!observableSaveArgs.cancel) {
8942
+ _this.currObjType.isSave = true;
6987
8943
  fileName = observableSaveArgs.fileName ? observableSaveArgs.fileName : fileName;
6988
8944
  if (type.toLowerCase() === 'svg') {
6989
- fileName = fileName || 'ImageEditor';
8945
+ fileName = fileName || _this.imageFileName;
6990
8946
  _this.toSVGImg(fileName);
6991
8947
  }
6992
8948
  else if (type.toLowerCase() === 'jpeg') {
6993
- fileName = fileName || 'ImageEditor';
8949
+ fileName = fileName || _this.imageFileName;
6994
8950
  _this.toBlobFn(fileName, type.toLowerCase());
6995
8951
  }
6996
8952
  else {
6997
- fileName = fileName || 'ImageEditor';
8953
+ fileName = fileName || _this.imageFileName;
6998
8954
  _this.toBlobFn(fileName, type.toLowerCase());
6999
8955
  }
7000
8956
  _this.trigger('saved', saved_1);
@@ -7044,7 +9000,8 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
7044
9000
  this.upperCanvas.style.cursor = 'crosshair';
7045
9001
  if (Browser.isDevice) {
7046
9002
  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 };
9003
+ var endPoint = { x: this.lowerCanvas.width - this.pannEnd.startX, y: this.lowerCanvas.height -
9004
+ this.pannEnd.startY };
7048
9005
  this.activeObj.activePoint = { startX: this.pannStart.startX + arcRadius, startY: this.pannStart.startY + arcRadius,
7049
9006
  endX: endPoint.x - arcRadius, endY: endPoint.y - arcRadius };
7050
9007
  this.activeObj.activePoint.width = this.activeObj.activePoint.endX - this.activeObj.activePoint.startX;
@@ -7097,7 +9054,7 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
7097
9054
  ImageEditor.prototype.freeHandDraw = function (value) {
7098
9055
  if (value) {
7099
9056
  this.togglePen = true;
7100
- this.upperCanvas.style.cursor = 'cross-hair';
9057
+ this.upperCanvas.style.cursor = 'crosshair';
7101
9058
  this.drawPen();
7102
9059
  }
7103
9060
  else {
@@ -7111,7 +9068,7 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
7111
9068
  *
7112
9069
  * @param {boolean} value - Specifies a value whether enable or disable freehand drawing.
7113
9070
  *
7114
- * @returns {void}.
9071
+ * @returns {void}.
7115
9072
  */
7116
9073
  ImageEditor.prototype.freehandDraw = function (value) {
7117
9074
  this.freeHandDraw(value);
@@ -7162,17 +9119,8 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
7162
9119
  this.redrawActObj();
7163
9120
  this.refreshActiveObj();
7164
9121
  this.upperContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
9122
+ this.lowerContext.filter = this.canvasFilter;
7165
9123
  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
9124
  if (this.degree !== 0) {
7177
9125
  this.inMemoryContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
7178
9126
  this.inMemoryContext.clearRect(0, 0, this.lowerCanvas.height, this.lowerCanvas.width);
@@ -7184,16 +9132,22 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
7184
9132
  this.lastX = this.lowerCanvas.width / 2;
7185
9133
  this.lastY = this.lowerCanvas.height / 2;
7186
9134
  }
7187
- if (value > 0) {
7188
- this.zoomImg(3.75);
9135
+ if (value === 1.1 || value === -1.1) {
9136
+ this.zoomImg(value);
7189
9137
  }
7190
9138
  else {
7191
- this.zoomImg(-3.75);
9139
+ if (value > 0) {
9140
+ this.zoomImg(3.75);
9141
+ }
9142
+ else {
9143
+ this.zoomImg(-3.75);
9144
+ }
7192
9145
  }
7193
9146
  this.refreshActiveObj();
7194
9147
  if (!isNullOrUndefined(activeObjShape)) {
7195
9148
  if (activeObjShape === 'custom') {
7196
- var endPoint = { x: this.lowerCanvas.width - this.pannEnd.startX, y: this.lowerCanvas.height - this.pannEnd.startY };
9149
+ var endPoint = { x: this.lowerCanvas.width - this.pannEnd.startX, y: this.lowerCanvas.height -
9150
+ this.pannEnd.startY };
7197
9151
  this.activeObj.activePoint = { startX: this.pannStart.startX, startY: this.pannStart.startY, endX: endPoint.x,
7198
9152
  endY: endPoint.y, width: endPoint.x - this.pannStart.startX, height: endPoint.y - this.pannStart.startY };
7199
9153
  this.updateActiveObject(this.calcRatio(), this.activeObj.activePoint, this.activeObj);
@@ -7204,10 +9158,6 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
7204
9158
  }
7205
9159
  this.refreshToolbar('main', true, true);
7206
9160
  }
7207
- if (!this.isUndoRedo) {
7208
- this.updateUndoRedoColl('zoom', zoomState, this.objColl);
7209
- }
7210
- this.isUndoRedo = false;
7211
9161
  var zoomOut = document.querySelector('#' + this.element.id + '_zoomOut');
7212
9162
  if (!isNullOrUndefined(zoomOut) && this.factor === 1) {
7213
9163
  zoomOut.classList.add('e-disabled');
@@ -7215,6 +9165,23 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
7215
9165
  else if (!isNullOrUndefined(zoomOut)) {
7216
9166
  zoomOut.classList.remove('e-disabled');
7217
9167
  }
9168
+ if (!this.togglePan) {
9169
+ this.callMainToolbar(false, true);
9170
+ }
9171
+ this.autoEnablePan();
9172
+ if (isNullOrUndefined(this.activeObj.activePoint) || this.activeObj.activePoint.width === 0) {
9173
+ this.refreshToolbar('main');
9174
+ }
9175
+ else {
9176
+ this.refreshToolbar('main', true, true);
9177
+ }
9178
+ var panBtn = this.element.querySelector('.e-img-pan .e-btn');
9179
+ if (!isNullOrUndefined(panBtn) && this.togglePan) {
9180
+ panBtn.classList.add('e-selected-btn');
9181
+ }
9182
+ else if (!isNullOrUndefined(panBtn)) {
9183
+ panBtn.classList.remove('e-selected-btn');
9184
+ }
7218
9185
  }
7219
9186
  };
7220
9187
  /**
@@ -7395,6 +9362,7 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
7395
9362
  else {
7396
9363
  isSelected = true;
7397
9364
  this.activeObj = obj;
9365
+ this.lowerContext.filter = this.canvasFilter;
7398
9366
  this.redrawShape(this.activeObj);
7399
9367
  if (this.activeObj.shape === 'text') {
7400
9368
  this.refreshToolbar('text');
@@ -7436,12 +9404,9 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
7436
9404
  break;
7437
9405
  }
7438
9406
  }
9407
+ this.lowerContext.filter = this.canvasFilter;
7439
9408
  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
- }
9409
+ this.redrawImgWithObj();
7445
9410
  this.refreshToolbar('main');
7446
9411
  };
7447
9412
  /**
@@ -7506,9 +9471,61 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
7506
9471
  canvasWrapper.style.height = this.element.offsetHeight - this.toolbarHeight - 1 + 'px';
7507
9472
  this.lowerCanvas.height = this.upperCanvas.height = this.element.offsetHeight - this.toolbarHeight - 1;
7508
9473
  }
9474
+ this.lowerContext.filter = this.canvasFilter;
7509
9475
  this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
7510
9476
  this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
7511
9477
  };
9478
+ /**
9479
+ * To apply the filters to an image
9480
+ *
9481
+ * @param {ImageFilterOptions } filterOption - Specifies the filter options to the image.
9482
+ * @returns {void}.
9483
+ */
9484
+ ImageEditor.prototype.applyImageFilter = function (filterOption) {
9485
+ if (this.initialAdjustmentValue === '') {
9486
+ this.initialAdjustmentValue = 'brightness(1) contrast(100%) hue-rotate(0deg) saturate(100%) opacity(1) blur(0px) sepia(0%) grayscale(0%) invert(0%)';
9487
+ }
9488
+ this.lowerContext.filter = this.initialAdjustmentValue;
9489
+ var filterValue = filterOption.split(' ');
9490
+ this.setFilter(filterValue.join('').toLowerCase());
9491
+ };
9492
+ /**
9493
+ * To apply the filters to an image
9494
+ *
9495
+ * @param {ImageFinetuneOptions } finetuneOption - Specifies the finetune options to the image.
9496
+ * @param {number } value - Specifies the value for finetuning the image.
9497
+ * @returns {void}.
9498
+ *
9499
+ */
9500
+ ImageEditor.prototype.finetuneImage = function (finetuneOption, value) {
9501
+ if (this.initialAdjustmentValue === '') {
9502
+ this.initialAdjustmentValue = 'brightness(1) contrast(100%) hue-rotate(0deg) saturate(100%) opacity(1) blur(0px) sepia(0%) grayscale(0%) invert(0%)';
9503
+ }
9504
+ this.lowerContext.filter = this.initialAdjustmentValue;
9505
+ switch (finetuneOption) {
9506
+ case 'Brightness':
9507
+ this.setBrightness(value);
9508
+ break;
9509
+ case 'Contrast':
9510
+ this.setContrast(value);
9511
+ break;
9512
+ case 'Hue':
9513
+ this.setHue(value);
9514
+ break;
9515
+ case 'Saturation':
9516
+ this.setSaturation(value);
9517
+ break;
9518
+ case 'Opacity':
9519
+ this.setOpacity(value);
9520
+ break;
9521
+ case 'Blur':
9522
+ this.setBlur(value);
9523
+ break;
9524
+ case 'Exposure':
9525
+ this.setExposure(value);
9526
+ break;
9527
+ }
9528
+ };
7512
9529
  /**
7513
9530
  * To check whether the undo collection is empty or not.
7514
9531
  *
@@ -7561,7 +9578,8 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
7561
9578
  * @private
7562
9579
  */
7563
9580
  ImageEditor.prototype.getBlob = function (url) {
7564
- return null;
9581
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
9582
+ return url;
7565
9583
  };
7566
9584
  /**
7567
9585
  * To check whether the signature is empty or not.
@@ -7611,7 +9629,7 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
7611
9629
  /**
7612
9630
  * To save the signature with the given file type and file name.
7613
9631
  *
7614
- * @param {SignatureFileType} type - specify type of the file to be saved a signature.
9632
+ * @param {FileType} type - specify type of the file to be saved a signature.
7615
9633
  * @param {string} fileName - specify name of the file to be saved a signature.
7616
9634
  *
7617
9635
  * @returns {void}.
@@ -7634,9 +9652,10 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
7634
9652
  /**
7635
9653
  * Returns the persistence data for component.
7636
9654
  *
7637
- * @returns any.
9655
+ * @returns {any}.
7638
9656
  * @private
7639
9657
  */
9658
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
7640
9659
  ImageEditor.prototype.getLocalData = function () {
7641
9660
  return null;
7642
9661
  };
@@ -7692,6 +9711,12 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
7692
9711
  __decorate([
7693
9712
  Property(false)
7694
9713
  ], ImageEditor.prototype, "enablePersistence", void 0);
9714
+ __decorate([
9715
+ Complex({}, FinetuneSettings)
9716
+ ], ImageEditor.prototype, "finetuneSettings", void 0);
9717
+ __decorate([
9718
+ Property('')
9719
+ ], ImageEditor.prototype, "signatureValue", void 0);
7695
9720
  __decorate([
7696
9721
  Event()
7697
9722
  ], ImageEditor.prototype, "beforeSave", void 0);
@@ -7734,6 +9759,12 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
7734
9759
  __decorate([
7735
9760
  Event()
7736
9761
  ], ImageEditor.prototype, "toolbarItemClicked", void 0);
9762
+ __decorate([
9763
+ Event()
9764
+ ], ImageEditor.prototype, "imageFiltering", void 0);
9765
+ __decorate([
9766
+ Event()
9767
+ ], ImageEditor.prototype, "fineTuneValueChanging", void 0);
7737
9768
  ImageEditor = ImageEditor_1 = __decorate([
7738
9769
  NotifyPropertyChanges
7739
9770
  ], ImageEditor);
@@ -7748,5 +9779,5 @@ var ImageEditor = /** @__PURE__ @class */ (function (_super) {
7748
9779
  * ImageEditor all modules
7749
9780
  */
7750
9781
 
7751
- export { ImageEditor };
9782
+ export { FinetuneSettings, ImageEditor };
7752
9783
  //# sourceMappingURL=ej2-image-editor.es5.js.map