@syncfusion/ej2-image-editor 20.3.50 → 20.4.38

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