@syncfusion/ej2-image-editor 20.4.51 → 21.1.36

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 (112) hide show
  1. package/.eslintrc.json +1 -0
  2. package/CHANGELOG.md +55 -5
  3. package/dist/ej2-image-editor.umd.min.js +2 -2
  4. package/dist/ej2-image-editor.umd.min.js.map +1 -1
  5. package/dist/es6/ej2-image-editor.es2015.js +20032 -11350
  6. package/dist/es6/ej2-image-editor.es2015.js.map +1 -1
  7. package/dist/es6/ej2-image-editor.es5.js +20027 -11313
  8. package/dist/es6/ej2-image-editor.es5.js.map +1 -1
  9. package/dist/global/ej2-image-editor.min.js +2 -2
  10. package/dist/global/ej2-image-editor.min.js.map +1 -1
  11. package/dist/global/index.d.ts +1 -1
  12. package/package.json +12 -12
  13. package/src/image-editor/action/crop.d.ts +36 -0
  14. package/src/image-editor/action/crop.js +829 -0
  15. package/src/image-editor/action/draw.d.ts +125 -0
  16. package/src/image-editor/action/draw.js +3263 -0
  17. package/src/image-editor/action/export.d.ts +23 -0
  18. package/src/image-editor/action/export.js +364 -0
  19. package/src/image-editor/action/filter.d.ts +35 -0
  20. package/src/image-editor/action/filter.js +699 -0
  21. package/src/image-editor/action/freehand-draw.d.ts +61 -0
  22. package/src/image-editor/action/freehand-draw.js +1015 -0
  23. package/src/image-editor/action/index.d.ts +9 -0
  24. package/src/image-editor/action/index.js +9 -0
  25. package/src/image-editor/action/selection.d.ts +139 -0
  26. package/src/image-editor/action/selection.js +4518 -0
  27. package/src/image-editor/action/shape.d.ts +94 -0
  28. package/src/image-editor/action/shape.js +2745 -0
  29. package/src/image-editor/action/transform.d.ts +67 -0
  30. package/src/image-editor/action/transform.js +1859 -0
  31. package/src/image-editor/action/undo-redo.d.ts +43 -0
  32. package/src/image-editor/action/undo-redo.js +800 -0
  33. package/src/image-editor/base/enum.d.ts +189 -0
  34. package/src/image-editor/base/enum.js +198 -0
  35. package/src/image-editor/base/image-editor-model.d.ts +626 -0
  36. package/src/image-editor/base/image-editor.d.ts +1300 -0
  37. package/src/image-editor/base/image-editor.js +2270 -0
  38. package/src/image-editor/base/index.d.ts +4 -0
  39. package/src/image-editor/base/index.js +2 -0
  40. package/src/image-editor/base/interface.d.ts +1128 -0
  41. package/src/image-editor/base/interface.js +1 -0
  42. package/src/image-editor/index.d.ts +3 -5
  43. package/src/image-editor/index.js +3 -4
  44. package/src/image-editor/renderer/index.d.ts +1 -0
  45. package/src/image-editor/renderer/index.js +1 -0
  46. package/src/image-editor/renderer/toolbar.d.ts +105 -0
  47. package/src/image-editor/renderer/toolbar.js +3018 -0
  48. package/styles/bootstrap-dark.css +79 -8
  49. package/styles/bootstrap.css +79 -8
  50. package/styles/bootstrap4.css +79 -8
  51. package/styles/bootstrap5-dark.css +81 -11
  52. package/styles/bootstrap5.css +81 -11
  53. package/styles/fabric-dark.css +79 -8
  54. package/styles/fabric.css +79 -8
  55. package/styles/fluent-dark.css +79 -8
  56. package/styles/fluent.css +79 -8
  57. package/styles/highcontrast-light.css +81 -10
  58. package/styles/highcontrast.css +82 -10
  59. package/styles/image-editor/_highcontrast-definition.scss +1 -1
  60. package/styles/image-editor/_highcontrast-light-definition.scss +1 -1
  61. package/styles/image-editor/_layout.scss +28 -18
  62. package/styles/image-editor/_material3-dark-definition.scss +1 -0
  63. package/styles/image-editor/_material3-definition.scss +10 -10
  64. package/styles/image-editor/_theme.scss +11 -6
  65. package/styles/image-editor/bootstrap-dark.css +79 -8
  66. package/styles/image-editor/bootstrap.css +79 -8
  67. package/styles/image-editor/bootstrap4.css +79 -8
  68. package/styles/image-editor/bootstrap5-dark.css +81 -11
  69. package/styles/image-editor/bootstrap5.css +81 -11
  70. package/styles/image-editor/fabric-dark.css +79 -8
  71. package/styles/image-editor/fabric.css +79 -8
  72. package/styles/image-editor/fluent-dark.css +79 -8
  73. package/styles/image-editor/fluent.css +79 -8
  74. package/styles/image-editor/highcontrast-light.css +81 -10
  75. package/styles/image-editor/highcontrast.css +82 -10
  76. package/styles/image-editor/icons/_bootstrap-dark.scss +132 -0
  77. package/styles/image-editor/icons/_bootstrap.scss +132 -0
  78. package/styles/image-editor/icons/_bootstrap4.scss +132 -0
  79. package/styles/image-editor/icons/_bootstrap5.scss +132 -0
  80. package/styles/image-editor/icons/_fabric-dark.scss +132 -0
  81. package/styles/image-editor/icons/_fabric.scss +132 -0
  82. package/styles/image-editor/icons/_fluent.scss +132 -0
  83. package/styles/image-editor/icons/_fusionnew.scss +132 -0
  84. package/styles/image-editor/icons/_highcontrast-light.scss +132 -0
  85. package/styles/image-editor/icons/_highcontrast.scss +132 -0
  86. package/styles/image-editor/icons/_material-dark.scss +132 -0
  87. package/styles/image-editor/icons/_material.scss +132 -0
  88. package/styles/image-editor/icons/_material3-dark.scss +1 -0
  89. package/styles/image-editor/icons/_material3.scss +133 -1
  90. package/styles/image-editor/icons/_tailwind.scss +132 -0
  91. package/styles/image-editor/material-dark.css +79 -16
  92. package/styles/image-editor/material.css +79 -11
  93. package/styles/image-editor/material3-dark.css +453 -0
  94. package/styles/image-editor/material3-dark.scss +14 -0
  95. package/styles/image-editor/material3.css +509 -0
  96. package/styles/image-editor/material3.scss +14 -0
  97. package/styles/image-editor/tailwind-dark.css +79 -8
  98. package/styles/image-editor/tailwind.css +79 -8
  99. package/styles/material-dark.css +79 -16
  100. package/styles/material.css +79 -11
  101. package/styles/material3-dark.css +453 -0
  102. package/styles/material3-dark.scss +3 -0
  103. package/styles/material3.css +509 -0
  104. package/styles/material3.scss +3 -0
  105. package/styles/tailwind-dark.css +79 -8
  106. package/styles/tailwind.css +79 -8
  107. package/GitLeaksReport.json +0 -1
  108. package/gitleaks-ci/gitleaks +0 -0
  109. package/gitleaks-ci.tar.gz +0 -0
  110. package/src/image-editor/image-editor-model.d.ts +0 -331
  111. package/src/image-editor/image-editor.d.ts +0 -1428
  112. package/src/image-editor/image-editor.js +0 -12849
@@ -0,0 +1,2270 @@
1
+ var __extends = (this && this.__extends) || (function () {
2
+ var extendStatics = function (d, b) {
3
+ extendStatics = Object.setPrototypeOf ||
4
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6
+ return extendStatics(d, b);
7
+ };
8
+ return function (d, b) {
9
+ extendStatics(d, b);
10
+ function __() { this.constructor = d; }
11
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12
+ };
13
+ })();
14
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
15
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
16
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
17
+ 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;
18
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
19
+ };
20
+ import { Component, NotifyPropertyChanges, Property, addClass, removeClass, extend, isBlazor } from '@syncfusion/ej2-base';
21
+ import { Event, EventHandler, getComponent, isNullOrUndefined, getUniqueID } from '@syncfusion/ej2-base';
22
+ import { createSpinner } from '@syncfusion/ej2-popups';
23
+ import { Complex, Browser, ChildProperty, compile as templateCompiler, compile } from '@syncfusion/ej2-base';
24
+ import { ToolbarModule, Crop, Draw, Filter, FreehandDrawing, Selection, Shape, Transform, UndoRedo, Export } from './../index';
25
+ import { ZoomTrigger, ImageFinetuneOption } from './../index';
26
+ /**
27
+ * This interface is used to specify settings for finetuning operations on images, including brightness, contrast, hue, saturation, exposure, opacity, and blur. It includes properties for setting minimum and maximum values for each of these options, as well as a default value.
28
+ */
29
+ var FinetuneSettings = /** @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));
57
+ export { FinetuneSettings };
58
+ /**
59
+ * An interface used to define the settings such as minimum, maximum, and default zoom factors, and the type of zooming which are available in the image editor control.
60
+ */
61
+ var ZoomSettings = /** @class */ (function (_super) {
62
+ __extends(ZoomSettings, _super);
63
+ function ZoomSettings() {
64
+ return _super !== null && _super.apply(this, arguments) || this;
65
+ }
66
+ __decorate([
67
+ Property(null)
68
+ ], ZoomSettings.prototype, "zoomTrigger", void 0);
69
+ __decorate([
70
+ Property(1)
71
+ ], ZoomSettings.prototype, "minZoomFactor", void 0);
72
+ __decorate([
73
+ Property(10)
74
+ ], ZoomSettings.prototype, "maxZoomFactor", void 0);
75
+ __decorate([
76
+ Property(1)
77
+ ], ZoomSettings.prototype, "zoomFactor", void 0);
78
+ __decorate([
79
+ Property(null)
80
+ ], ZoomSettings.prototype, "zoomPoint", void 0);
81
+ return ZoomSettings;
82
+ }(ChildProperty));
83
+ export { ZoomSettings };
84
+ /**
85
+ * This interface is used to specify settings for selection operations on images, including visibility, stroke color and fill color.
86
+ */
87
+ var SelectionSettings = /** @class */ (function (_super) {
88
+ __extends(SelectionSettings, _super);
89
+ function SelectionSettings() {
90
+ return _super !== null && _super.apply(this, arguments) || this;
91
+ }
92
+ __decorate([
93
+ Property(true)
94
+ ], SelectionSettings.prototype, "showCircle", void 0);
95
+ __decorate([
96
+ Property(null)
97
+ ], SelectionSettings.prototype, "strokeColor", void 0);
98
+ __decorate([
99
+ Property(null)
100
+ ], SelectionSettings.prototype, "fillColor", void 0);
101
+ return SelectionSettings;
102
+ }(ChildProperty));
103
+ export { SelectionSettings };
104
+ /**
105
+ * The Image Editor is a graphical user interface for editing images.
106
+ *
107
+ * {% codeBlock src='image-editor/default/index.md' %}{% endcodeBlock %}
108
+ *
109
+ * @remarks
110
+ * The Image Editor component provides various image editing features such as zooming, cropping, rotating, inserting text and shapes (rectangles, ellipses, and lines), drawing freehand on top of an image, undo/redo, and more.
111
+ *
112
+ */
113
+ var ImageEditor = /** @class */ (function (_super) {
114
+ __extends(ImageEditor, _super);
115
+ /**
116
+ *
117
+ * Constructor for creating the widget
118
+ *
119
+ * @param {ImageEditorModel} options - Specifies the image editor model
120
+ * @param {string|HTMLDivElement} element - Specifies the target element
121
+ */
122
+ function ImageEditor(options, element) {
123
+ var _this = _super.call(this, options) || this;
124
+ /**
125
+ *
126
+ * Image Editor Private Properties
127
+ */
128
+ /** @hidden */
129
+ _this.isImageLoaded = false;
130
+ /** @hidden */
131
+ _this.activeObj = { activePoint: { startX: 0, startY: 0, endX: 0, endY: 0, width: 0, height: 0 },
132
+ flipObjColl: [], triangle: [], triangleRatio: [], rotatedAngle: 0 };
133
+ // current object's ui interaction properties
134
+ /** @hidden */
135
+ _this.currObjType = { shape: '', isDragging: false, isActiveObj: false, isText: false, isInitialText: false, isLine: false, isInitialLine: false,
136
+ isCustomCrop: false, isZoomed: false, isUndoZoom: false, isUndoAction: false, isFiltered: false, isSave: false, isResize: false };
137
+ /** @hidden */
138
+ _this.objColl = [];
139
+ /** @hidden */
140
+ // eslint-disable-next-line
141
+ _this.pointColl = {};
142
+ /** @hidden */
143
+ _this.freehandCounter = 0;
144
+ /** @hidden */
145
+ _this.points = [];
146
+ /** @hidden */
147
+ _this.togglePen = false;
148
+ /** @hidden */
149
+ _this.togglePan = false;
150
+ /** @hidden */
151
+ _this.img = { destLeft: 0, destTop: 0, destWidth: 0, destHeight: 0, srcLeft: 0, srcTop: 0, srcWidth: 0, srcHeight: 0 };
152
+ /** @hidden */
153
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
154
+ _this.rotateFlipColl = [];
155
+ // All prop values saved while cropping (to restore the image to its original state)
156
+ /** @hidden */
157
+ _this.cropObj = { cropZoom: 0, defaultZoom: 0, totalPannedPoint: { x: 0, y: 0 }, totalPannedClientPoint: { x: 0, y: 0 },
158
+ totalPannedInternalPoint: { x: 0, y: 0 }, tempFlipPanPoint: { x: 0, y: 0 }, activeObj: {}, rotateFlipColl: [],
159
+ degree: 0, currFlipState: '', destPoints: { startX: 0, startY: 0, width: 0, height: 0 },
160
+ srcPoints: { startX: 0, startY: 0, width: 0, height: 0 }, filter: '', zoomFactor: 0, previousZoomValue: 0 };
161
+ // Stored transformations performed after cropping
162
+ /** @hidden */
163
+ _this.afterCropActions = [];
164
+ /** @hidden */
165
+ _this.transform = { degree: 0, currFlipState: '', zoomFactor: 0, cropZoomFactor: null, defaultZoomFactor: 0 };
166
+ /** @hidden */
167
+ _this.panPoint = { currentPannedPoint: { x: 0, y: 0 }, totalPannedPoint: { x: 0, y: 0 }, totalPannedInternalPoint: { x: 0, y: 0 },
168
+ totalPannedClientPoint: { x: 0, y: 0 } };
169
+ /** @hidden */
170
+ _this.isUndoRedo = false;
171
+ /** @hidden */
172
+ _this.isCropTab = false;
173
+ /** @hidden */
174
+ _this.isCircleCrop = false;
175
+ /** @hidden */
176
+ _this.fontSizeColl = [];
177
+ /** @hidden */
178
+ _this.initialAdjustmentValue = '';
179
+ /** @hidden */
180
+ _this.currentFilter = '';
181
+ /** @hidden */
182
+ _this.canvasFilter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
183
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
184
+ /** @hidden */
185
+ _this.toolbarHeight = 0;
186
+ /** @hidden */
187
+ _this.isPublicMethod = false;
188
+ /** @hidden */
189
+ _this.isCropToolbar = false;
190
+ /** @hidden */
191
+ _this.cursor = 'default';
192
+ if (!isBlazor()) {
193
+ ImageEditor_1.Inject(Crop, Draw, Selection, Transform, Export, ToolbarModule);
194
+ ImageEditor_1.Inject(UndoRedo);
195
+ ImageEditor_1.Inject(Filter);
196
+ ImageEditor_1.Inject(Shape);
197
+ ImageEditor_1.Inject(FreehandDrawing);
198
+ if (element) {
199
+ _this.appendTo(element);
200
+ }
201
+ }
202
+ else {
203
+ new Crop(_this);
204
+ new Draw(_this);
205
+ new Filter(_this);
206
+ new FreehandDrawing(_this);
207
+ new Selection(_this);
208
+ new Shape(_this);
209
+ new Transform(_this);
210
+ new UndoRedo(_this);
211
+ new Export(_this);
212
+ }
213
+ return _this;
214
+ }
215
+ ImageEditor_1 = ImageEditor;
216
+ /**
217
+ * To provide the array of modules needed for component rendering.
218
+ *
219
+ * @returns {ModuleDeclaration[]} - To provide the array of modules needed for component rendering.
220
+ * @hidden
221
+ */
222
+ ImageEditor.prototype.requiredModules = function () {
223
+ var modules = [];
224
+ modules.push({ member: 'crop', args: [this] });
225
+ modules.push({ member: 'draw', args: [this] });
226
+ modules.push({ member: 'selection', args: [this] });
227
+ modules.push({ member: 'transform', args: [this] });
228
+ modules.push({ member: 'export', args: [this] });
229
+ modules.push({ member: 'toolbar-module', args: [this] });
230
+ modules.push({ member: 'undo-redo', args: [this] });
231
+ modules.push({ member: 'filter', args: [this] });
232
+ modules.push({ member: 'shape', args: [this] });
233
+ modules.push({ member: 'freehand-draw', args: [this] });
234
+ return modules;
235
+ };
236
+ ImageEditor.prototype.preRender = function () {
237
+ // pre render code snippets
238
+ this.element.id = this.element.id || getUniqueID('ej2-image-editor');
239
+ if (Browser.isDevice) {
240
+ this.element.classList.add('e-device');
241
+ }
242
+ this.initializeThemeColl();
243
+ };
244
+ /**
245
+ *
246
+ * To Initialize the component rendering
247
+ *
248
+ * @private
249
+ * @returns {void}
250
+ */
251
+ ImageEditor.prototype.render = function () {
252
+ this.initialize();
253
+ };
254
+ /**
255
+ * To get component name.
256
+ *
257
+ * @returns {string} - Module Name
258
+ * @private
259
+ */
260
+ ImageEditor.prototype.getModuleName = function () {
261
+ return 'image-editor';
262
+ };
263
+ /**
264
+ *
265
+ * To get the properties to be maintained in the persisted state.
266
+ *
267
+ * @returns {string} - Persist data
268
+ * @private
269
+ */
270
+ ImageEditor.prototype.getPersistData = function () {
271
+ return this.addOnPersist([]);
272
+ };
273
+ /**
274
+ *
275
+ * Called internally if any of the property value changed.
276
+ *
277
+ * @param {ImageEditorModel} newProperties - Specifies new properties
278
+ * @param {ImageEditorModel} oldProperties - Specifies old properties
279
+ * @returns {void}
280
+ * @private
281
+ */
282
+ ImageEditor.prototype.onPropertyChanged = function (newProperties, oldProperties) {
283
+ for (var _i = 0, _a = Object.keys(newProperties); _i < _a.length; _i++) {
284
+ var prop = _a[_i];
285
+ switch (prop) {
286
+ case 'cssClass':
287
+ if (oldProperties.cssClass) {
288
+ removeClass([this.element], oldProperties.cssClass.replace(/\s+/g, ' ').trim().split(' '));
289
+ }
290
+ if (newProperties.cssClass) {
291
+ addClass([this.element], newProperties.cssClass.replace(/\s+/g, ' ').trim().split(' '));
292
+ }
293
+ break;
294
+ case 'disabled':
295
+ if (newProperties.disabled) {
296
+ this.element.classList.add('e-disabled');
297
+ this.unwireEvent();
298
+ }
299
+ else {
300
+ this.element.classList.remove('e-disabled');
301
+ this.wireEvent();
302
+ }
303
+ break;
304
+ case 'height':
305
+ this.element.style.height = newProperties.height;
306
+ break;
307
+ case 'width':
308
+ this.element.style.width = newProperties.width;
309
+ break;
310
+ case 'theme':
311
+ if (newProperties.theme) {
312
+ if (this.theme && this.theme !== '') {
313
+ this.theme = this.toPascalCase(this.theme);
314
+ }
315
+ else {
316
+ this.theme = 'Bootstrap5';
317
+ }
318
+ this.upperContext.strokeStyle = this.themeColl[this.theme]['primaryColor'];
319
+ this.upperContext.fillStyle = this.themeColl[this.theme]['secondaryColor'];
320
+ }
321
+ break;
322
+ case 'finetuneSettings':
323
+ if (newProperties.finetuneSettings) {
324
+ this.finetuneSettings = newProperties.finetuneSettings;
325
+ this.notify('filter', { prop: 'update-finetunes' });
326
+ }
327
+ break;
328
+ case 'locale':
329
+ if (newProperties.locale) {
330
+ this.notify('toolbar', { prop: 'setLocale', onPropertyChange: false, value: { locale: newProperties.locale } });
331
+ this.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: { type: 'main',
332
+ isApplyBtn: null, isCropping: null, isZooming: null, cType: null } });
333
+ }
334
+ break;
335
+ case 'allowUndoRedo':
336
+ if (newProperties.allowUndoRedo) {
337
+ this.allowUndoRedo = true;
338
+ }
339
+ else {
340
+ this.allowUndoRedo = false;
341
+ }
342
+ this.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: { type: 'main',
343
+ isApplyBtn: null, isCropping: null, isZooming: null, cType: null } });
344
+ break;
345
+ case 'showQuickAccessToolbar':
346
+ if (newProperties.showQuickAccessToolbar) {
347
+ this.showQuickAccessToolbar = true;
348
+ this.notify('toolbar', { prop: 'create-qa-toolbar', onPropertyChange: false });
349
+ this.notify('toolbar', { prop: 'renderQAT', onPropertyChange: false, value: { isPenEdit: null } });
350
+ }
351
+ else {
352
+ this.showQuickAccessToolbar = false;
353
+ this.notify('toolbar', { prop: 'destroy-qa-toolbar', onPropertyChange: false });
354
+ }
355
+ break;
356
+ case 'zoomSettings':
357
+ if (newProperties.zoomSettings) {
358
+ this.zoomSettings.zoomTrigger = newProperties.zoomSettings.zoomTrigger;
359
+ }
360
+ if (isNullOrUndefined(this.zoomSettings.zoomTrigger)) {
361
+ this.zoomSettings.zoomTrigger = (ZoomTrigger.MouseWheel | ZoomTrigger.Pinch | ZoomTrigger.Toolbar |
362
+ ZoomTrigger.Commands);
363
+ this.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: { type: 'main',
364
+ isApplyBtn: null, isCropping: null, isZooming: null, cType: null } });
365
+ }
366
+ else if ((newProperties.zoomSettings.zoomTrigger & ZoomTrigger.Toolbar) === ZoomTrigger.Toolbar) {
367
+ this.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: { type: 'main',
368
+ isApplyBtn: null, isCropping: null, isZooming: null, cType: null } });
369
+ }
370
+ break;
371
+ case 'selectionSettings':
372
+ if (newProperties.selectionSettings) {
373
+ this.selectionSettings = newProperties.selectionSettings;
374
+ if (this.activeObj.shape) {
375
+ this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
376
+ this.notify('draw', { prop: 'drawObject', onPropertyChange: false, value: { canvas: 'duplicate', obj: this.activeObj } });
377
+ }
378
+ }
379
+ break;
380
+ }
381
+ }
382
+ };
383
+ ImageEditor.prototype.destroy = function () {
384
+ var classList = [];
385
+ this.element.removeAttribute('tabindex');
386
+ if (this.cssClass) {
387
+ classList = classList.concat(this.cssClass.replace(/\s+/g, ' ').trim().split(' '));
388
+ }
389
+ removeClass([this.element], classList);
390
+ if (!this.element.getAttribute('class')) {
391
+ this.element.removeAttribute('class');
392
+ }
393
+ if (!isBlazor()) {
394
+ this.notify('toolbar', { prop: 'destroySubComponents', onPropertyChange: false });
395
+ this.notify('destroyed', null);
396
+ _super.prototype.destroy.call(this);
397
+ }
398
+ else {
399
+ this.element.classList.remove('e-image-editor');
400
+ }
401
+ this.unwireEvent();
402
+ this.element.innerHTML = '';
403
+ };
404
+ ImageEditor.prototype.initialize = function () {
405
+ if (this.toolbarTemplate) {
406
+ this.element.appendChild(this.createElement('div', {
407
+ id: this.element.id + '_toolbarArea', className: 'e-toolbar-area'
408
+ }));
409
+ this.toolbarTemplateFn();
410
+ }
411
+ else {
412
+ this.notify('toolbar', { prop: 'create-toolbar', onPropertyChange: false });
413
+ this.notify('toolbar', { prop: 'create-contextual-toolbar', onPropertyChange: false });
414
+ }
415
+ this.createCanvas();
416
+ if (this.showQuickAccessToolbar) {
417
+ var canvasWrapper = document.querySelector('#' + this.element.id + '_canvasWrapper');
418
+ canvasWrapper.appendChild(this.createElement('div', {
419
+ id: this.element.id + '_quickAccessToolbarArea', className: 'e-quick-access-toolbar-area'
420
+ }));
421
+ var quickAccessToolbar = document.getElementById(this.element.id + '_quickAccessToolbarArea');
422
+ quickAccessToolbar.style.position = 'absolute';
423
+ quickAccessToolbar.style.display = 'none';
424
+ if (this.activeObj) {
425
+ quickAccessToolbar.style.left = this.activeObj.activePoint.startX + 'px';
426
+ quickAccessToolbar.style.top = this.activeObj.activePoint.startY + 'px';
427
+ }
428
+ quickAccessToolbar.style.width = '100%';
429
+ }
430
+ if (this.quickAccessToolbarTemplate) {
431
+ this.quickAccessToolbarTemplateFn();
432
+ }
433
+ else {
434
+ this.notify('toolbar', { prop: 'create-qa-toolbar', onPropertyChange: false });
435
+ }
436
+ this.wireEvent();
437
+ this.lowerContext = this.lowerCanvas.getContext('2d');
438
+ this.upperContext = this.upperCanvas.getContext('2d');
439
+ this.inMemoryContext = this.inMemoryCanvas.getContext('2d');
440
+ this.lowerContext.filter = this.getDefaultFilter();
441
+ this.notify('filter', { prop: 'setAdjustmentValue', onPropertyChange: false, value: { adjustmentValue: this.lowerContext.filter } });
442
+ this.notify('toolbar', { prop: 'setCanvasFilter', onPropertyChange: false, value: { filter: this.lowerContext.filter } });
443
+ this.notify('toolbar', { prop: 'setInitialAdjustmentValue', onPropertyChange: false, value: { value: this.lowerContext.filter } });
444
+ if (this.cssClass) {
445
+ addClass([this.element], this.cssClass.replace(/\s+/g, ' ').trim().split(' '));
446
+ }
447
+ if (this.element) {
448
+ createSpinner({
449
+ target: this.element
450
+ });
451
+ }
452
+ this.initializeZoomSettings();
453
+ };
454
+ /**
455
+ *
456
+ * This Method will add events to component (element, event, method, current reference)
457
+ *
458
+ * @returns {void}.
459
+ */
460
+ ImageEditor.prototype.wireEvent = function () {
461
+ EventHandler.add(document, 'keydown', this.keyDownEventHandler, this);
462
+ EventHandler.add(document, 'keypress', this.keyUpEventHandler, this);
463
+ EventHandler.add(this.upperCanvas, 'mousedown', this.mouseDownEventHandler, this);
464
+ EventHandler.add(this.upperCanvas, 'mousemove', this.mouseMoveEventHandler, this);
465
+ EventHandler.add(this.upperCanvas, 'mouseup', this.mouseUpEventHandler, this);
466
+ EventHandler.add(document, 'mouseup', this.mouseUpEventHandler, this);
467
+ EventHandler.add(this.lowerCanvas, 'mousedown', this.canvasMouseDownHandler, this);
468
+ EventHandler.add(this.lowerCanvas, 'mousemove', this.canvasMouseMoveHandler, this);
469
+ EventHandler.add(this.lowerCanvas, 'mouseup', this.canvasMouseUpHandler, this);
470
+ EventHandler.add(document, 'mouseup', this.canvasMouseUpHandler, this);
471
+ EventHandler.add(this.upperCanvas, 'touchstart', this.touchStartHandler, this);
472
+ EventHandler.add(this.lowerCanvas, 'touchstart', this.touchStartHandler, this);
473
+ EventHandler.add(this.lowerCanvas, 'mousewheel DOMMouseScroll', this.handleScroll, this);
474
+ EventHandler.add(this.upperCanvas, 'mousewheel DOMMouseScroll', this.handleScroll, this);
475
+ window.addEventListener('resize', this.windowResizeHandler.bind(this));
476
+ if ((!Browser.isIos && Browser.info.name !== 'safari')) {
477
+ screen.orientation.addEventListener('change', this.screenOrientation.bind(this));
478
+ }
479
+ this.notify('shape', { prop: 'wireEvent', onPropertyChange: false });
480
+ };
481
+ /**
482
+ *
483
+ * This Method will remove events from component
484
+ *
485
+ * @returns {void}.
486
+ */
487
+ ImageEditor.prototype.unwireEvent = function () {
488
+ EventHandler.remove(document, 'keydown', this.keyDownEventHandler);
489
+ EventHandler.remove(document, 'keypress', this.keyUpEventHandler);
490
+ EventHandler.remove(this.upperCanvas, 'mousedown', this.mouseDownEventHandler);
491
+ EventHandler.remove(this.upperCanvas, 'mousemove', this.mouseMoveEventHandler);
492
+ EventHandler.remove(this.upperCanvas, 'mouseup', this.mouseUpEventHandler);
493
+ EventHandler.remove(document, 'mouseup', this.mouseUpEventHandler);
494
+ EventHandler.remove(this.lowerCanvas, 'mousedown', this.canvasMouseDownHandler);
495
+ EventHandler.remove(this.lowerCanvas, 'mousemove', this.canvasMouseMoveHandler);
496
+ EventHandler.remove(this.lowerCanvas, 'mouseup', this.canvasMouseUpHandler);
497
+ EventHandler.remove(document, 'mouseup', this.canvasMouseUpHandler);
498
+ EventHandler.remove(this.upperCanvas, 'touchstart', this.touchStartHandler);
499
+ EventHandler.remove(this.lowerCanvas, 'touchstart', this.touchStartHandler);
500
+ EventHandler.remove(this.lowerCanvas, 'mousewheel DOMMouseScroll', this.handleScroll);
501
+ EventHandler.remove(this.upperCanvas, 'mousewheel DOMMouseScroll', this.handleScroll);
502
+ window.removeEventListener('resize', this.windowResizeHandler.bind(this));
503
+ if ((!Browser.isIos && Browser.info.name !== 'safari')) {
504
+ screen.orientation.removeEventListener('change', this.screenOrientation.bind(this));
505
+ }
506
+ this.notify('shape', { prop: 'unWireEvent', onPropertyChange: false });
507
+ };
508
+ ImageEditor.prototype.createCanvas = function () {
509
+ this.element.style.boxSizing = 'border-box';
510
+ var obj = { toolbarHeight: 0 };
511
+ this.notify('toolbar', { prop: 'getToolbarHeight', value: { obj: obj } });
512
+ var height = obj['toolbarHeight'];
513
+ this.element.style.width = this.width;
514
+ this.element.style.height = this.height;
515
+ var canvasWrapper = this.element.appendChild(this.createElement('div', { id: this.element.id + '_canvasWrapper',
516
+ className: 'e-canvas-wrapper', attrs: { style: 'height:' + (this.element.offsetHeight - height - 2) + 'px; width:' +
517
+ (this.element.offsetWidth - 2)
518
+ + 'px; position: relative; overflow: hidden; margin: 0 auto;' }
519
+ }));
520
+ this.lowerCanvas = canvasWrapper.appendChild(this.createElement('canvas', {
521
+ id: this.element.id + '_lowerCanvas', attrs: { name: 'canvasImage' }
522
+ }));
523
+ this.upperCanvas = canvasWrapper.appendChild(this.createElement('canvas', {
524
+ id: this.element.id + '_upperCanvas', attrs: { name: 'canvasImage' }
525
+ }));
526
+ this.inMemoryCanvas = this.createElement('canvas', {
527
+ id: this.element.id + '_inMemoryCanvas', attrs: { name: 'canvasImage' }
528
+ });
529
+ this.textArea = canvasWrapper.appendChild(this.createElement('textarea', {
530
+ id: this.element.id + '_textArea', className: 'e-textarea', attrs: { name: 'textArea' }
531
+ }));
532
+ var dialog = this.element.appendChild(this.createElement('div', {
533
+ id: this.element.id + '_dialog', className: 'e-dialog'
534
+ }));
535
+ dialog.style.display = 'none';
536
+ this.textArea.setAttribute('spellcheck', 'false');
537
+ this.textArea.style.lineHeight = 'normal';
538
+ this.lowerCanvas.style.width = this.upperCanvas.style.width = this.inMemoryCanvas.style.width = '100%';
539
+ this.lowerCanvas.style.height = this.upperCanvas.style.height = this.inMemoryCanvas.style.height = '100%';
540
+ this.upperCanvas.style.position = this.lowerCanvas.style.position = this.textArea.style.position = 'absolute';
541
+ this.textArea.style.backgroundColor = 'transparent';
542
+ this.textArea.style.display = 'none';
543
+ this.textArea.style.resize = 'none';
544
+ this.lowerContext = this.lowerCanvas.getContext('2d');
545
+ this.baseImg = this.createElement('img', {
546
+ id: this.element.id + '_orgImg', attrs: { name: 'Image', crossorigin: 'anonymous' }
547
+ });
548
+ this.upperCanvas.style.cursor = this.cursor = 'default';
549
+ this.upperCanvas.style.display = 'block';
550
+ this.upperContext = this.upperCanvas.getContext('2d');
551
+ };
552
+ ImageEditor.prototype.touchStartHandler = function (e) {
553
+ this.notify('selection', { prop: 'touchStartHandler', onPropertyChange: false, value: { e: e } });
554
+ };
555
+ ImageEditor.prototype.mouseDownEventHandler = function (e) {
556
+ this.notify('selection', { prop: 'mouseDownEventHandler', onPropertyChange: false, value: { e: e } });
557
+ };
558
+ ImageEditor.prototype.mouseMoveEventHandler = function (e) {
559
+ this.notify('selection', { prop: 'mouseMoveEventHandler', onPropertyChange: false, value: { e: e } });
560
+ };
561
+ ImageEditor.prototype.mouseUpEventHandler = function (e) {
562
+ this.notify('selection', { prop: 'mouseUpEventHandler', onPropertyChange: false, value: { e: e } });
563
+ };
564
+ ImageEditor.prototype.keyDownEventHandler = function (e) {
565
+ this.notify('selection', { prop: 'keyDownEventHandler', onPropertyChange: false, value: { e: e } });
566
+ };
567
+ ImageEditor.prototype.keyUpEventHandler = function (e) {
568
+ // eslint-disable-next-line
569
+ if (this.textArea.style.display === 'block' && e.target.id === this.element.id + '_textArea') {
570
+ this.notify('selection', { prop: 'textKeyDown', value: { e: e } });
571
+ }
572
+ };
573
+ ImageEditor.prototype.canvasMouseDownHandler = function (e) {
574
+ this.notify('selection', { prop: 'canvasMouseDownHandler', onPropertyChange: false, value: { e: e } });
575
+ };
576
+ ImageEditor.prototype.canvasMouseMoveHandler = function (e) {
577
+ this.notify('selection', { prop: 'canvasMouseMoveHandler', onPropertyChange: false, value: { e: e } });
578
+ };
579
+ ImageEditor.prototype.canvasMouseUpHandler = function (e) {
580
+ this.notify('selection', { prop: 'canvasMouseUpHandler', onPropertyChange: false, value: { e: e } });
581
+ };
582
+ ImageEditor.prototype.handleScroll = function (e) {
583
+ this.notify('selection', { prop: 'handleScroll', onPropertyChange: false, value: { e: e } });
584
+ };
585
+ ImageEditor.prototype.adjustToScreen = function () {
586
+ this.update();
587
+ };
588
+ ImageEditor.prototype.screenOrientation = function () {
589
+ if (Browser.isDevice) {
590
+ setTimeout(this.adjustToScreen.bind(this), 100);
591
+ }
592
+ };
593
+ ImageEditor.prototype.windowResizeHandler = function () {
594
+ if (!Browser.isDevice && this.element.classList.contains('e-image-editor')) {
595
+ this.adjustToScreen();
596
+ }
597
+ };
598
+ ImageEditor.prototype.notifyResetForAllModules = function () {
599
+ var modules = this.requiredModules();
600
+ for (var i = 0; i < modules.length; i++) {
601
+ this.notify(modules[i].member, { prop: 'reset', onPropertyChange: false });
602
+ }
603
+ };
604
+ ImageEditor.prototype.allowShape = function (x, y) {
605
+ this.isPublicMethod = true;
606
+ var obj = { inRange: false };
607
+ this.notify('shape', { prop: 'isPointsInRange', onPropertyChange: false,
608
+ value: { x: x, y: y, obj: obj } });
609
+ return obj['inRange'];
610
+ };
611
+ /**
612
+ * Clears the current selection performed in the image editor.
613
+ *
614
+ * @returns {void}.
615
+ */
616
+ ImageEditor.prototype.clearSelection = function () {
617
+ this.notify('selection', { prop: 'clearSelection', onPropertyChange: false });
618
+ };
619
+ /**
620
+ * Crops an image based on the selection done in the image editor.
621
+ *
622
+ * {% codeBlock src='image-editor/crop/index.md' %}{% endcodeBlock %}
623
+ *
624
+ * @remarks
625
+ * The selection can be done through programmatically using the 'select' method or through UI interactions.
626
+ *
627
+ * @returns {boolean}.
628
+ *
629
+ */
630
+ ImageEditor.prototype.crop = function () {
631
+ var obj = { isCrop: false };
632
+ this.notify('crop', { prop: 'crop', onPropertyChange: false, value: { obj: obj } });
633
+ return obj['isCrop'];
634
+ };
635
+ /**
636
+ * Flips an image by horizontally or vertically in the image editor.
637
+ *
638
+ * {% codeBlock src='image-editor/zoom/index.md' %}{% endcodeBlock %}
639
+ *
640
+ * @param { Direction } direction - Specifies the direction to flip the image.
641
+ * A horizontal direction for horizontal flipping and vertical direction for vertical flipping.
642
+ *
643
+ * @remarks
644
+ * It flips the shapes including rectangle, circle, line, text, and freehand drawings.
645
+ *
646
+ * @returns {void}.
647
+ *
648
+ */
649
+ ImageEditor.prototype.flip = function (direction) {
650
+ this.notify('transform', { prop: 'flip', value: { direction: direction } });
651
+ this.notify('undo-redo', { prop: 'updateCurrUrc', value: { type: 'ok' } });
652
+ };
653
+ /**
654
+ * Returns an image as ImageData to load it in to a canvas.
655
+ *
656
+ * @remarks
657
+ * The data returned from this method is directly drawn in a canvas using 'putImageData' method.
658
+ * And then the user can get the base64 string from the canvas using toDataURL method.
659
+ *
660
+ * @returns {ImageData}.
661
+ */
662
+ ImageEditor.prototype.getImageData = function () {
663
+ var obj = { canvas: null };
664
+ this.notify('export', { prop: 'exportToCanvas', value: { object: obj } });
665
+ return obj['canvas'].getContext('2d').getImageData(0, 0, obj['canvas'].width, obj['canvas'].height);
666
+ };
667
+ /**
668
+ * Opens an image as URL or ImageData for editing in an image editor.
669
+ *
670
+ * @param {string | ImageData } data - Specifies url of the image or image data.
671
+ *
672
+ * @remarks
673
+ * The supported file types are JPG, JPEG, PNG, and SVG.
674
+ *
675
+ * @returns {void}.
676
+ */
677
+ ImageEditor.prototype.open = function (data) {
678
+ this.notify('draw', { prop: 'open', value: { data: data } });
679
+ };
680
+ /**
681
+ * Reset all the changes done in an image editor and revert to original image.
682
+ *
683
+ * @remarks
684
+ * The undo redo collection also cleared while resetting the image editor.
685
+ *
686
+ * @returns {void}.
687
+ */
688
+ ImageEditor.prototype.reset = function () {
689
+ var obj = { isErrorImage: false };
690
+ this.notify('draw', { prop: 'getErrorImage', value: { obj: obj } });
691
+ if (!this.disabled && !obj['isErrorImage']) {
692
+ this.clearContext(this.inMemoryContext);
693
+ this.clearContext(this.lowerContext);
694
+ this.clearContext(this.upperContext);
695
+ this.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
696
+ if (!isBlazor()) {
697
+ this.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: { type: 'main',
698
+ isApplyBtn: false, isCropping: false, isZooming: null, cType: null } });
699
+ if (Browser.isDevice && document.getElementById(this.element.id + '_bottomToolbar')) {
700
+ getComponent(document.getElementById(this.element.id + '_bottomToolbar'), 'toolbar').destroy();
701
+ this.notify('toolbar', { prop: 'create-bottom-toolbar', onPropertyChange: false });
702
+ }
703
+ }
704
+ this.currObjType.isUndoAction = this.isUndoRedo = this.togglePan = this.togglePen = this.isImageLoaded = false;
705
+ this.isCircleCrop = this.isCropTab = false;
706
+ this.objColl = [];
707
+ this.transform.degree = 0;
708
+ this.upperCanvas.style.display = 'block';
709
+ this.transform.currFlipState = '';
710
+ this.upperCanvas.style.cursor = this.cursor = this.lowerCanvas.style.cursor = 'default';
711
+ this.lowerContext.lineWidth = this.upperContext.lineWidth = undefined;
712
+ this.textArea.value = this.textArea.textContent = '';
713
+ this.textArea.style.display = 'none';
714
+ this.lowerContext.filter = this.canvasFilter = this.getDefaultFilter();
715
+ this.img.destLeft = this.img.destTop = this.img.srcLeft = this.img.srcTop = 0;
716
+ this.img.destWidth = this.img.destHeight = this.img.srcWidth = this.img.srcHeight = null;
717
+ this.currSelectionPoint = null;
718
+ this.panPoint.currentPannedPoint = { x: 0, y: 0 };
719
+ this.rotateFlipColl = [];
720
+ this.points = [];
721
+ this.pointColl = {};
722
+ this.freehandCounter = 0;
723
+ this.notify('draw', { prop: 'resetPanPoints' });
724
+ this.lowerCanvas.style.left = this.upperCanvas.style.left = '';
725
+ this.fontSizeColl = [];
726
+ this.lowerCanvas.style.top = this.upperCanvas.style.top = '';
727
+ this.lowerCanvas.style.maxWidth = this.upperCanvas.style.maxWidth = '';
728
+ this.lowerCanvas.style.maxHeight = this.upperCanvas.style.maxHeight = '';
729
+ this.transform.defaultZoomFactor = this.transform.zoomFactor = 0;
730
+ this.transform.cropZoomFactor = null;
731
+ this.currObjType = { shape: '', isDragging: false, isActiveObj: false, isText: false, isInitialText: false, isLine: false,
732
+ isInitialLine: false, isCustomCrop: false, isZoomed: false, isUndoZoom: false,
733
+ isUndoAction: false, isFiltered: false, isSave: false, isResize: false };
734
+ this.cropObj = { cropZoom: 0, defaultZoom: 0, totalPannedPoint: { x: 0, y: 0 }, totalPannedClientPoint: { x: 0, y: 0 },
735
+ totalPannedInternalPoint: { x: 0, y: 0 }, tempFlipPanPoint: { x: 0, y: 0 }, activeObj: {},
736
+ rotateFlipColl: [], degree: 0, currFlipState: '', zoomFactor: 0, previousZoomValue: 0,
737
+ destPoints: { startX: 0, startY: 0, width: 0, height: 0 },
738
+ srcPoints: { startX: 0, startY: 0, width: 0, height: 0 }, filter: '' };
739
+ this.afterCropActions = [];
740
+ this.currentFilter = '';
741
+ var obj_1 = { initialZoomValue: false };
742
+ this.notify('draw', { prop: 'getInitialZoomValue', onPropertyChange: false, value: { obj: obj_1 } });
743
+ if (obj_1['initialZoomValue']) {
744
+ this.setProperties({ zoomSettings: { zoomFactor: obj_1['initialZoomValue'] } }, true);
745
+ }
746
+ if (document.getElementById(this.element.id + '_quickAccessToolbarArea')) {
747
+ document.getElementById(this.element.id + '_quickAccessToolbarArea').style.display = 'none';
748
+ }
749
+ this.notifyResetForAllModules();
750
+ this.notify('filter', { prop: 'update-finetunes' });
751
+ this.isImageLoaded = false;
752
+ this.notify('draw', { prop: 'update-canvas', onPropertyChange: false });
753
+ this.isImageLoaded = true;
754
+ if (!isBlazor()) {
755
+ if (this.element.querySelector('.e-contextual-toolbar-wrapper')) {
756
+ this.element.querySelector('.e-contextual-toolbar-wrapper').classList.add('e-hide');
757
+ }
758
+ this.notify('toolbar', { prop: 'refresh-dropdown-btn', value: { isDisabled: false } });
759
+ this.notify('toolbar', { prop: 'enable-disable-btns' });
760
+ }
761
+ }
762
+ };
763
+ /**
764
+ * Rotate an image to clockwise and anti-clockwise.
765
+ *
766
+ * {% codeBlock src='image-editor/rotate/index.md' %}{% endcodeBlock %}
767
+ *
768
+ * @param {number} degree - Specifies a degree to rotate an image.
769
+ * A positive integer value for clockwise and negative integer value for anti-clockwise rotation.
770
+ *
771
+ * @remarks
772
+ * It rotated the shapes including rectangle, circle, line, text, and freehand drawings.
773
+ *
774
+ * @returns {boolean}.
775
+ *
776
+ */
777
+ ImageEditor.prototype.rotate = function (degree) {
778
+ var obj = { isRotate: false };
779
+ this.notify('transform', { prop: 'rotate', value: { degree: degree, obj: obj } });
780
+ this.notify('undo-redo', { prop: 'updateCurrUrc', value: { type: 'ok' } });
781
+ return obj['isRotate'];
782
+ };
783
+ /**
784
+ * Export an image using the specified file name and the extension.
785
+ *
786
+ * @param {string} type - Specifies a format of image to be saved.
787
+ * @param {string} fileName – Specifies a file name to be saved
788
+ *
789
+ * @remarks
790
+ * The supported file types are JPG, JPEG, PNG, and SVG.
791
+ *
792
+ * @returns {void}.
793
+ */
794
+ ImageEditor.prototype.export = function (type, fileName) {
795
+ this.notify('export', { prop: 'export', onPropertyChange: false, value: { type: type, fileName: fileName } });
796
+ };
797
+ /**
798
+ * Perform selection in an image editor. The selection helps to crop an image.
799
+ *
800
+ * {% codeBlock src='image-editor/select/index.md' %}{% endcodeBlock %}
801
+ *
802
+ * @param {string} type - Specifies the shape - circle / square / custom selection / pre-defined ratios.
803
+ * @param {number} startX – Specifies the start x-coordinate point of the selection.
804
+ * @param {number} startY – Specifies the start y-coordinate point of the selection.
805
+ * @param {number} width - Specifies the width of the selection area.
806
+ * @param {number} height - Specifies the height of the selection area.
807
+ *
808
+ * @remarks
809
+ * The selection UI is based on the 'theme' property.
810
+ *
811
+ * @returns {void}.
812
+ *
813
+ */
814
+ ImageEditor.prototype.select = function (type, startX, startY, width, height) {
815
+ this.notify('draw', { prop: 'select', onPropertyChange: false,
816
+ value: { type: type, startX: startX, startY: startY, width: width, height: height } });
817
+ };
818
+ /**
819
+ * Enable or disable a freehand drawing option in an Image Editor.
820
+ *
821
+ * @param {boolean} value - Specifies a value whether to enable or disable freehand drawing.
822
+ *
823
+ * @returns {void}.
824
+ * @private
825
+ */
826
+ ImageEditor.prototype.freeHandDraw = function (value) {
827
+ this.notify('freehand-draw', { prop: 'freeHandDraw', onPropertyChange: false, value: { value: value } });
828
+ };
829
+ /**
830
+ * Enable or disable a freehand drawing in an Image Editor.
831
+ *
832
+ * @param {boolean} value - Specifies a value whether to enable or disable freehand drawing.
833
+ *
834
+ * @remarks
835
+ * User can directly drawing on a canvas after enabling this option.
836
+ *
837
+ * @returns {void}.
838
+ */
839
+ ImageEditor.prototype.freehandDraw = function (value) {
840
+ if (!this.disabled && this.isImageLoaded) {
841
+ this.freeHandDraw(value);
842
+ }
843
+ };
844
+ /**
845
+ * Enable or disable a panning on the Image Editor.
846
+ *
847
+ * @param {boolean} value - Specifies a value whether enable or disable panning.
848
+ *
849
+ * @remarks
850
+ * This option will take into effect once the image's visibility is hidden when zooming an image or selection has been performed.
851
+ *
852
+ * @returns {void}.
853
+ */
854
+ ImageEditor.prototype.pan = function (value) {
855
+ this.notify('transform', { prop: 'pan', onPropertyChange: false, value: { value: value } });
856
+ };
857
+ /**
858
+ * Zoom in or out on a point in the image editor.
859
+ *
860
+ * @param {number} zoomFactor - The percentage-based zoom factor to use (e.g. 20 for 2x zoom).
861
+ * @param {Point} zoomPoint - The point in the image editor to zoom in/out on.
862
+ *
863
+ * @remarks
864
+ * Zooming directly enables the panning option when the image's visibility is hidden.
865
+ * User can disable it by using 'Pan' method.
866
+ * @returns {void}
867
+ *
868
+ */
869
+ ImageEditor.prototype.zoom = function (zoomFactor, zoomPoint) {
870
+ this.notify('transform', { prop: 'zoom', onPropertyChange: false,
871
+ value: { zoomFactor: zoomFactor, zoomPoint: zoomPoint } });
872
+ };
873
+ /**
874
+ * Draw ellipse on an image.
875
+ *
876
+ * {% codeBlock src='image-editor/ellipse/index.md' %}{% endcodeBlock %}
877
+ *
878
+ * @param {number} x - Specifies x-coordinate of ellipse.
879
+ * @param {number} y - Specifies y-coordinate of ellipse.
880
+ * @param {number} radiusX - Specifies the radius x point for the ellipse.
881
+ * @param {number} radiusY - Specifies the radius y point for the ellipse.
882
+ * @param {number} strokeWidth - Specifies the stroke width of ellipse.
883
+ * @param {string} strokeColor - Specifies the stroke color of ellipse.
884
+ * @param {string} fillColor - Specifies the fill color of the ellipse.
885
+ * @returns {boolean}.
886
+ *
887
+ */
888
+ ImageEditor.prototype.drawEllipse = function (x, y, radiusX, radiusY, strokeWidth, strokeColor, fillColor) {
889
+ var isEllipse = false;
890
+ var isPointsInRange = this.allowShape(x, y);
891
+ if (!this.disabled && this.isImageLoaded && (isPointsInRange || (isNullOrUndefined(x) && isNullOrUndefined(y)))) {
892
+ isEllipse = true;
893
+ this.notify('shape', { prop: 'drawEllipse', onPropertyChange: false, value: { x: x, y: y, radiusX: radiusX, radiusY: radiusY,
894
+ strokeWidth: strokeWidth, strokeColor: strokeColor, fillColor: fillColor } });
895
+ }
896
+ return isEllipse;
897
+ };
898
+ /**
899
+ * Draw line on an image.
900
+ *
901
+ * @param {number} startX – Specifies start point x-coordinate of line.
902
+ * @param {number} startY – Specifies start point y-coordinate of line.
903
+ * @param {number} endX - Specifies end point x-coordinates of line.
904
+ * @param {number} endY - Specifies end point y-coordinates of the line.
905
+ * @param {number} strokeWidth - Specifies the stroke width of line.
906
+ * @param {string} strokeColor - Specifies the stroke color of line.
907
+ * @returns {boolean}.
908
+ */
909
+ ImageEditor.prototype.drawLine = function (startX, startY, endX, endY, strokeWidth, strokeColor) {
910
+ var isLine = false;
911
+ var isPointsInRange = this.allowShape(startX, startY);
912
+ if (!this.disabled && this.isImageLoaded && (isPointsInRange || (isNullOrUndefined(startX) && isNullOrUndefined(startY)))) {
913
+ isLine = true;
914
+ this.notify('shape', { prop: 'drawLine', onPropertyChange: false, value: { startX: startX, startY: startY, endX: endX,
915
+ endY: endY, strokeWidth: strokeWidth, strokeColor: strokeColor } });
916
+ }
917
+ return isLine;
918
+ };
919
+ /**
920
+ * Draw arrow on an image.
921
+ *
922
+ * @param {number} startX – Specifies start point x-coordinate of arrow.
923
+ * @param {number} startY – Specifies start point y-coordinate of arrow.
924
+ * @param {number} endX - Specifies end point x-coordinates of arrow.
925
+ * @param {number} endY - Specifies end point y-coordinates of the arrow.
926
+ * @param {number} strokeWidth - Specifies the stroke width of arrow.
927
+ * @param {string} strokeColor - Specifies the stroke color of arrow.
928
+ * @param {ArrowheadType} arrowStart – Specifies the type of arrowhead for start position. The default value is ‘None’.
929
+ * @param {ArrowheadType} arrowEnd – Specifies the type of arrowhead for end position. The default value is ‘SolidArrow’.
930
+ * @returns {boolean}.
931
+ */
932
+ ImageEditor.prototype.drawArrow = function (startX, startY, endX, endY, strokeWidth, strokeColor, arrowStart, arrowEnd) {
933
+ var isArrow = false;
934
+ var isPointsInRange = this.allowShape(startX, startY);
935
+ if (!this.disabled && this.isImageLoaded && (isPointsInRange || (isNullOrUndefined(startX) && isNullOrUndefined(startY)))) {
936
+ isArrow = true;
937
+ this.notify('shape', { prop: 'drawArrow', onPropertyChange: false, value: { startX: startX, startY: startY, endX: endX,
938
+ endY: endY, strokeWidth: strokeWidth, strokeColor: strokeColor, arrowStart: arrowStart, arrowEnd: arrowEnd } });
939
+ }
940
+ return isArrow;
941
+ };
942
+ /**
943
+ * Draw path on an image.
944
+ *
945
+ * @param {Point[]} pointColl – Specifies collection of start and end x, y-coordinates of path.
946
+ * @param {number} strokeWidth - Specifies the stroke width of path.
947
+ * @param {string} strokeColor - Specifies the stroke color of path.
948
+ * @returns {boolean}.
949
+ */
950
+ ImageEditor.prototype.drawPath = function (pointColl, strokeWidth, strokeColor) {
951
+ this.isPublicMethod = true;
952
+ var obj = { inRange: false };
953
+ var isPath = false;
954
+ if (pointColl && pointColl.length > 0) {
955
+ for (var i = 0; i < pointColl.length; i++) {
956
+ if (obj['inRange']) {
957
+ break;
958
+ }
959
+ this.notify('shape', { prop: 'isPointsInRange', onPropertyChange: false,
960
+ value: { x: pointColl[i].x, y: pointColl[i].y, obj: obj } });
961
+ }
962
+ }
963
+ if (!this.disabled && this.isImageLoaded && (obj['inRange'] || isNullOrUndefined(pointColl))) {
964
+ isPath = true;
965
+ this.notify('shape', { prop: 'drawPath', onPropertyChange: false, value: { pointColl: pointColl,
966
+ strokeWidth: strokeWidth, strokeColor: strokeColor } });
967
+ }
968
+ return isPath;
969
+ };
970
+ /**
971
+ * Draw a rectangle on an image.
972
+ *
973
+ * @param {number} x - Specifies x-coordinate of rectangle.
974
+ * @param {number} y - Specifies y-coordinate of rectangle.
975
+ * @param {number} width - Specifies the width of the rectangle.
976
+ * @param {number} height - Specifies the height of the rectangle.
977
+ * @param {number} strokeWidth - Specifies the stroke width of rectangle.
978
+ * @param {string} strokeColor - Specifies the stroke color of rectangle.
979
+ * @param {string} fillColor - Specifies the fill color of the rectangle.
980
+ * @returns {boolean}.
981
+ */
982
+ ImageEditor.prototype.drawRectangle = function (x, y, width, height, strokeWidth, strokeColor, fillColor) {
983
+ var isRectangle = false;
984
+ var isPointsInRange = this.allowShape(x, y);
985
+ if (!this.disabled && this.isImageLoaded && (isPointsInRange || (isNullOrUndefined(x) && isNullOrUndefined(y)))) {
986
+ isRectangle = true;
987
+ this.notify('shape', { prop: 'drawRectangle', onPropertyChange: false, value: { x: x, y: y, width: width, height: height,
988
+ strokeWidth: strokeWidth, strokeColor: strokeColor, fillColor: fillColor } });
989
+ }
990
+ return isRectangle;
991
+ };
992
+ /**
993
+ * Draw a text on an image.
994
+ *
995
+ * {% codeBlock src='image-editor/text/index.md' %}{% endcodeBlock %}
996
+ *
997
+ * @param {number} x - Specifies x-coordinate of text.
998
+ * @param {number} y - Specifies y-coordinate of text.
999
+ * @param {string} text - Specifies the text to add on an image.
1000
+ * @param {string} fontFamily - Specifies the font family of the text.
1001
+ * @param {number} fontSize - Specifies the font size of the text.
1002
+ * @param {boolean} bold - Specifies whether the text is bold or not.
1003
+ * @param {boolean} italic - Specifies whether the text is italic or not.
1004
+ * @param {string} color - Specifies font color of the text.
1005
+ * @returns {boolean}.
1006
+ *
1007
+ */
1008
+ ImageEditor.prototype.drawText = function (x, y, text, fontFamily, fontSize, bold, italic, color) {
1009
+ var isText = false;
1010
+ var isPointsInRange = this.allowShape(x, y);
1011
+ if (!this.disabled && this.isImageLoaded && (isPointsInRange || (isNullOrUndefined(x) && isNullOrUndefined(y)))) {
1012
+ isText = true;
1013
+ this.notify('shape', { prop: 'drawText', onPropertyChange: false, value: { x: x, y: y, text: text, fontFamily: fontFamily,
1014
+ fontSize: fontSize, bold: bold, italic: italic, color: color } });
1015
+ }
1016
+ return isText;
1017
+ };
1018
+ /**
1019
+ * Select a shape based on the given shape id.
1020
+ * Use 'getShapeSettings' method to get the shape id which is then passed to perform selection.
1021
+ *
1022
+ * {% codeBlock src='image-editor/selectShape/index.md' %}{% endcodeBlock %}
1023
+ *
1024
+ * @param {string} id - Specifies the shape id to select a shape on an image.
1025
+ * @returns {boolean}.
1026
+ *
1027
+ */
1028
+ ImageEditor.prototype.selectShape = function (id) {
1029
+ var obj = { isSelected: false };
1030
+ this.notify('shape', { prop: 'selectShape', onPropertyChange: false, value: { id: id, obj: obj } });
1031
+ return obj['isSelected'];
1032
+ };
1033
+ /**
1034
+ * Deletes a shape based on the given shape id.
1035
+ * Use 'getShapeSettings' method to get the shape id which is then passed to perform selection.
1036
+ *
1037
+ * {% codeBlock src='image-editor/deleteShape/index.md' %}{% endcodeBlock %}
1038
+ *
1039
+ * @param {string} id - Specifies the shape id to delete the shape on an image.
1040
+ * @returns {void}.
1041
+ *
1042
+ */
1043
+ ImageEditor.prototype.deleteShape = function (id) {
1044
+ this.notify('shape', { prop: 'deleteShape', onPropertyChange: false, value: { id: id } });
1045
+ };
1046
+ /**
1047
+ * Get particular shapes details based on id of the shape which is drawn on an image editor.
1048
+ *
1049
+ * {% codeBlock src='image-editor/getShapeSetting/index.md' %}{% endcodeBlock %}
1050
+ *
1051
+ * @param {string} id - Specifies the shape id on an image.
1052
+ * @returns {ShapeSettings}.
1053
+ *
1054
+ */
1055
+ ImageEditor.prototype.getShapeSetting = function (id) {
1056
+ var shapeDetails = {};
1057
+ this.notify('shape', { prop: 'getShapeSetting', onPropertyChange: false,
1058
+ value: { id: id, obj: shapeDetails } });
1059
+ return shapeDetails;
1060
+ };
1061
+ /**
1062
+ * Get all the shapes details which is drawn on an image editor.
1063
+ *
1064
+ * @returns {ShapeSettings[]}.
1065
+ */
1066
+ ImageEditor.prototype.getShapeSettings = function () {
1067
+ var obj = { shapeDetailsColl: [] };
1068
+ this.notify('shape', { prop: 'getShapeSettings', onPropertyChange: false, value: { obj: obj } });
1069
+ return obj['shapeDetailsColl'];
1070
+ };
1071
+ /**
1072
+ * To refresh the Canvas Wrapper.
1073
+ *
1074
+ * @returns {void}.
1075
+ */
1076
+ ImageEditor.prototype.update = function () {
1077
+ this.notify('transform', { prop: 'update' });
1078
+ };
1079
+ /**
1080
+ * Finetuning an image with the given type of finetune and its value in the image editor.
1081
+ *
1082
+ * @param {ImageFinetuneOption } finetuneOption - Specifies the finetune options to be performed in the image.
1083
+ * @param {number } value - Specifies the value for finetuning the image.
1084
+ *
1085
+ * @remarks
1086
+ * The finetuning will not affect the shapes background and border color.
1087
+ *
1088
+ * @returns {void}.
1089
+ *
1090
+ */
1091
+ ImageEditor.prototype.finetuneImage = function (finetuneOption, value) {
1092
+ if (!this.disabled && this.isImageLoaded) {
1093
+ this.notify('filter', { prop: 'finetuneImage', value: { value: value, option: finetuneOption } });
1094
+ }
1095
+ };
1096
+ /**
1097
+ * Filtering an image with the given type of filters.
1098
+ *
1099
+ * @param {ImageFilterOption } filterOption - Specifies the filter options to the image.
1100
+ *
1101
+ * @remarks
1102
+ * The filtering will not affect the shape's background and border color.
1103
+ * @returns {void}.
1104
+ */
1105
+ ImageEditor.prototype.applyImageFilter = function (filterOption) {
1106
+ if (!this.disabled && this.isImageLoaded) {
1107
+ this.notify('filter', { prop: 'applyImageFilter', value: { option: filterOption.toString() } });
1108
+ this.canvasFilter = this.lowerContext.filter;
1109
+ this.notify('undo-redo', { prop: 'updateCurrUrc', value: { type: 'ok' } });
1110
+ }
1111
+ };
1112
+ /**
1113
+ * Reverse the last action which performed by the user in the Image Editor.
1114
+ *
1115
+ * @remarks
1116
+ * This method will take into effect once the 'allowUndoRedo' property is enabled.
1117
+ *
1118
+ * @returns {void}.
1119
+ */
1120
+ ImageEditor.prototype.undo = function () {
1121
+ this.notify('undo-redo', { prop: 'undo', onPropertyChange: false });
1122
+ };
1123
+ /**
1124
+ * Redo the last user action that was undone by the user or `undo` method.
1125
+ *
1126
+ * @remarks
1127
+ * This method will take into effect once the 'allowUndoRedo' property is enabled.
1128
+ * @returns {void}.
1129
+ */
1130
+ ImageEditor.prototype.redo = function () {
1131
+ this.notify('undo-redo', { prop: 'redo', onPropertyChange: false });
1132
+ };
1133
+ /**
1134
+ * Get the dimension of an image in the image editor such as x, y, width, and height.
1135
+ * The method helps to get dimension after cropped an image.
1136
+ *
1137
+ * @returns {Dimension}.
1138
+ * A Dimension object containing the x, y, width, and height of an image.
1139
+ */
1140
+ ImageEditor.prototype.getImageDimension = function () {
1141
+ return { x: this.img.destLeft, y: this.img.destTop, width: this.img.destWidth, height: this.img.destHeight };
1142
+ };
1143
+ // Toolbar related codes
1144
+ ImageEditor.prototype.toolbarTemplateFn = function () {
1145
+ var template;
1146
+ var templateID = this.element.id + '_toolbar';
1147
+ var toolbarArea = this.element.querySelector('#' + this.element.id + '_toolbarArea');
1148
+ if (this.toolbarTemplate) {
1149
+ this.toolbarFn = this.templateParser(this.toolbarTemplate);
1150
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1151
+ if (this.isReact) {
1152
+ template = this.toolbarFn({ type: 'toolbar' }, this, 'Template', templateID)[0];
1153
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1154
+ }
1155
+ else if (this.isAngular) {
1156
+ var templateColl = this.toolbarFn({ type: 'toolbar' }, this, 'Template', templateID);
1157
+ template = (templateColl[0].nodeType === 3) ? templateColl[1] : templateColl[0];
1158
+ }
1159
+ else {
1160
+ template = this.toolbarFn({ type: 'toolbar' }, this, 'Template', templateID)[0];
1161
+ }
1162
+ toolbarArea.appendChild(template);
1163
+ this.toolbarHeight = toolbarArea.clientHeight;
1164
+ this.notify('toolbar', { prop: 'setToolbarHeight', value: { height: this.toolbarHeight } });
1165
+ this['renderReactTemplates']();
1166
+ }
1167
+ };
1168
+ ImageEditor.prototype.quickAccessToolbarTemplateFn = function () {
1169
+ var template;
1170
+ var templateID = this.element.id + '_quickAccessToolbar';
1171
+ var toolbarArea = this.element.querySelector('#' + this.element.id + '_quickAccessToolbarArea');
1172
+ if (this.quickAccessToolbarTemplate) {
1173
+ this.qatFn = this.templateParser(this.quickAccessToolbarTemplate);
1174
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1175
+ if (this.isReact) {
1176
+ template = this.qatFn({ type: 'toolbar' }, this, 'Template', templateID)[0];
1177
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1178
+ }
1179
+ else if (this.isAngular) {
1180
+ var templateColl = this.qatFn({ type: 'toolbar' }, this, 'Template', templateID);
1181
+ template = (templateColl[0].nodeType === 3) ? templateColl[1] : templateColl[0];
1182
+ }
1183
+ else {
1184
+ template = this.qatFn({ type: 'toolbar' }, this, 'Template', templateID)[0];
1185
+ }
1186
+ toolbarArea.appendChild(template);
1187
+ this['renderReactTemplates']();
1188
+ }
1189
+ };
1190
+ ImageEditor.prototype.templateParser = function (template) {
1191
+ if (template) {
1192
+ try {
1193
+ if (typeof template !== 'function' && document.querySelectorAll(template).length) {
1194
+ return templateCompiler(document.querySelector(template).innerHTML.trim());
1195
+ }
1196
+ else {
1197
+ return compile(template);
1198
+ }
1199
+ }
1200
+ catch (error) {
1201
+ return templateCompiler(template);
1202
+ }
1203
+ }
1204
+ return undefined;
1205
+ };
1206
+ // Common codes for EJ2 and Blazor
1207
+ ImageEditor.prototype.getTextFromId = function (id) {
1208
+ var idToValue = { '1': 'none', '2': 'bar', '3': 'arrow', '4': 'arrowSolid',
1209
+ '5': 'circle', '6': 'circleSolid', '7': 'square', '8': 'squareSolid' };
1210
+ return idToValue["" + id];
1211
+ };
1212
+ ImageEditor.prototype.getFinetuneOption = function (type) {
1213
+ var typeToOption = { 'brightness': ImageFinetuneOption.Brightness, 'contrast': ImageFinetuneOption.Contrast,
1214
+ 'hue': ImageFinetuneOption.Hue, 'saturation': ImageFinetuneOption.Saturation, 'opacity': ImageFinetuneOption.Opacity,
1215
+ 'blur': ImageFinetuneOption.Blur, 'exposure': ImageFinetuneOption.Exposure };
1216
+ return typeToOption["" + type];
1217
+ };
1218
+ ImageEditor.prototype.setPenStroke = function (args) {
1219
+ this.notify('freehand-draw', { prop: 'setPenStrokeWidth', onPropertyChange: false, value: { value: parseInt(args, 10) } });
1220
+ };
1221
+ ImageEditor.prototype.updateFreehandDrawColorChange = function () {
1222
+ var obj = { tempFreeHandDrawEditingStyles: null };
1223
+ this.notify('freehand-draw', { prop: 'getTempFreeHandDrawEditingStyles', value: { obj: obj } });
1224
+ this.notify('freehand-draw', { prop: 'color-change', value: { color: obj['tempFreeHandDrawEditingStyles'].strokeColor } });
1225
+ };
1226
+ ImageEditor.prototype.setInitialZoomState = function () {
1227
+ this.objColl.push(this.activeObj);
1228
+ this.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
1229
+ var isUndoRedo = this.isUndoRedo;
1230
+ this.isCropTab = false;
1231
+ this.isUndoRedo = true;
1232
+ if (this.transform.cropZoomFactor && this.transform.cropZoomFactor > 0) {
1233
+ this.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
1234
+ value: { zoomFactor: -this.transform.cropZoomFactor, zoomPoint: null } });
1235
+ }
1236
+ else {
1237
+ this.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
1238
+ value: { zoomFactor: Math.abs(this.transform.cropZoomFactor), zoomPoint: null } });
1239
+ }
1240
+ this.isUndoRedo = isUndoRedo;
1241
+ this.panPoint.totalPannedPoint = { x: 0, y: 0 };
1242
+ this.transform.cropZoomFactor = 0;
1243
+ this.notify('freehand-draw', { prop: 'updateFHDColl', onPropertyChange: false });
1244
+ this.activeObj = extend({}, this.objColl[this.objColl.length - 1], {}, true);
1245
+ this.objColl.pop();
1246
+ this.isCropTab = true;
1247
+ this.notify('draw', { prop: 'drawObject', onPropertyChange: false, value: { canvas: 'duplicate', obj: this.activeObj } });
1248
+ };
1249
+ /**
1250
+ * Set the old item Transform item state.
1251
+ *
1252
+ * @hidden
1253
+ * @returns {void}.
1254
+ */
1255
+ ImageEditor.prototype.updateCropTransformItems = function () {
1256
+ this.prevCurrSelectionPoint = extend({}, this.currSelectionPoint, {}, true);
1257
+ var object = { currObj: {} };
1258
+ this.notify('filter', { prop: 'getCurrentObj', onPropertyChange: false, value: { object: object } });
1259
+ var currentObj = object['currObj'];
1260
+ currentObj.objColl = extend([], this.objColl, [], true);
1261
+ currentObj.pointColl = extend([], this.pointColl, [], true);
1262
+ currentObj.afterCropActions = extend([], this.afterCropActions, [], true);
1263
+ var selPointCollObj = { selPointColl: null };
1264
+ this.notify('freehand-draw', { prop: 'getSelPointColl', onPropertyChange: false,
1265
+ value: { obj: selPointCollObj } });
1266
+ currentObj.selPointColl = extend([], selPointCollObj['selPointColl'], [], true);
1267
+ this.cancelCropSelection = { operation: 'cropTransform', previousObj: currentObj, currentObj: currentObj,
1268
+ previousObjColl: currentObj.objColl, currentObjColl: currentObj.objColl,
1269
+ previousPointColl: currentObj.pointColl, currentPointColl: currentObj.pointColl,
1270
+ previousSelPointColl: currentObj.selPointColl, currentSelPointColl: currentObj.selPointColl,
1271
+ previousCropObj: extend({}, this.cropObj, {}, true),
1272
+ currentCropObj: extend({}, this.cropObj, {}, true),
1273
+ previousText: null, currentText: null, filter: null, isCircleCrop: this.isCircleCrop };
1274
+ };
1275
+ /**
1276
+ * Get the pascal case.
1277
+ *
1278
+ * @param { string } str - Specifies the string to convert to pascal case.
1279
+ * @param { Object } obj - Specifies the string to convert to pascal case.
1280
+ * @hidden
1281
+ * @returns {string}.
1282
+ * A pascal case string.
1283
+ */
1284
+ ImageEditor.prototype.toPascalCase = function (str, obj) {
1285
+ var strArr = [];
1286
+ if (!isNullOrUndefined(str)) {
1287
+ strArr = str.toLowerCase().split('-');
1288
+ }
1289
+ for (var i = 0; i < strArr.length; i++) {
1290
+ strArr[i] = strArr[i].charAt(0).toUpperCase() + strArr[i].slice(1);
1291
+ }
1292
+ if (obj) {
1293
+ obj['maxText'] = strArr.join('');
1294
+ }
1295
+ return strArr.join('');
1296
+ };
1297
+ /**
1298
+ * Get the font sizes.
1299
+ *
1300
+ * @hidden
1301
+ * @returns {DropDownButtonItemModel[]}.
1302
+ * A font size collections.
1303
+ */
1304
+ ImageEditor.prototype.getFontSizes = function () {
1305
+ var items = [];
1306
+ this.fontSizeColl = [];
1307
+ var fontSize;
1308
+ if (this.transform.degree === 0 || this.transform.degree % 180 === 0) {
1309
+ fontSize = this.img.destWidth / 25;
1310
+ }
1311
+ else {
1312
+ fontSize = this.img.destHeight / 25;
1313
+ }
1314
+ for (var i = 1; i <= 10; i++) {
1315
+ this.fontSizeColl.push({ text: (i * (Math.round(fontSize / 2))).toString() });
1316
+ items.push({ text: (i.toString()) });
1317
+ }
1318
+ return items;
1319
+ };
1320
+ /**
1321
+ * Handles the OK button operation
1322
+ *
1323
+ * @param { boolean } isMouseDown - Specifies whether it is a mouse down.
1324
+ * @hidden
1325
+ * @returns {void}.
1326
+ */
1327
+ ImageEditor.prototype.okBtn = function (isMouseDown) {
1328
+ var isCropSelection = false;
1329
+ var splitWords;
1330
+ if (this.activeObj.shape !== undefined) {
1331
+ splitWords = this.activeObj.shape.split('-');
1332
+ }
1333
+ if (splitWords === undefined && this.currObjType.isCustomCrop) {
1334
+ isCropSelection = true;
1335
+ }
1336
+ else if (splitWords !== undefined && splitWords[0] === 'crop') {
1337
+ isCropSelection = true;
1338
+ }
1339
+ var selElem = this.element.querySelector('.e-contextual-toolbar-wrapper .e-toolbar-item.e-selected');
1340
+ var obj = { bool: false };
1341
+ this.notify('selection', { prop: 'getFreehandDrawEditing', onPropertyChange: false, value: { obj: obj } });
1342
+ if (selElem) {
1343
+ this.currentFilter = selElem.children[0].children[0].id.replace('Canvas', '');
1344
+ }
1345
+ if (isCropSelection) {
1346
+ this.crop();
1347
+ }
1348
+ else if (this.togglePen) {
1349
+ this.freeHandDraw(false);
1350
+ this.notify('undo-redo', { prop: 'updateCurrUrc', value: { type: 'ok' } });
1351
+ }
1352
+ else if (this.textArea.style.display === 'block') {
1353
+ this.notify('shape', { prop: 'redrawActObj', onPropertyChange: false,
1354
+ value: { x: null, y: null, isMouseDown: null } });
1355
+ if (isNullOrUndefined(isMouseDown)) {
1356
+ this.notify('undo-redo', { prop: 'updateCurrUrc', value: { type: 'ok' } });
1357
+ }
1358
+ }
1359
+ else if ((!isBlazor() && document.querySelector('#' + this.element.id + '_sliderWrapper')) || (isBlazor() && !this.element.querySelector('.e-ie-contextual-slider').classList.contains('e-hidden')) ||
1360
+ this.currObjType.isFiltered) {
1361
+ this.initialAdjustmentValue = this.canvasFilter = this.lowerContext.filter;
1362
+ this.currObjType.isFiltered = false;
1363
+ var obj_2 = { value: null };
1364
+ this.notify('draw', { prop: 'getTempAdjustmentValue', value: { obj: obj_2 } });
1365
+ if (obj_2['value'] !== this.lowerContext.filter) {
1366
+ this.notify('undo-redo', { prop: 'updateCurrUrc', value: { type: 'ok' } });
1367
+ }
1368
+ }
1369
+ else if (obj['bool']) {
1370
+ this.notify('freehand-draw', { prop: 'applyFhd', onPropertyChange: false });
1371
+ this.notify('selection', { prop: 'setFreehandDrawCustomized', value: { isFreehandDrawCustomized: false } });
1372
+ if (!isBlazor()) {
1373
+ this.notify('toolbar', { prop: 'destroy-qa-toolbar' });
1374
+ }
1375
+ else {
1376
+ this.updateToolbar(this.element, 'destroyQuickAccessToolbar');
1377
+ }
1378
+ this.notify('undo-redo', { prop: 'updateCurrUrc', value: { type: 'ok' } });
1379
+ }
1380
+ else if ((this.activeObj.activePoint.width !== 0 && this.activeObj.activePoint.height !== 0) ||
1381
+ (this.activeObj.shape === 'path' && this.activeObj.pointColl.length > 0)) {
1382
+ this.notify('shape', { prop: 'applyActObj', onPropertyChange: false, value: { isMouseDown: isMouseDown } });
1383
+ }
1384
+ if (!isBlazor() && !obj['isCropToolbar']) {
1385
+ this.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: { type: 'main',
1386
+ isApplyBtn: false, isCropping: null, isZooming: null, cType: null } });
1387
+ }
1388
+ this.notify('draw', { prop: 'setNewPath', value: { bool: false } });
1389
+ this.isCropTab = false;
1390
+ this.transform.zoomFactor = this.transform.defaultZoomFactor;
1391
+ this.notify('selection', { prop: 'setCurrentDrawingShape', onPropertyChange: false, value: { value: '' } });
1392
+ };
1393
+ /**
1394
+ * Set the temporary filter properties.
1395
+ *
1396
+ * @hidden
1397
+ * @returns {void}.
1398
+ */
1399
+ ImageEditor.prototype.setTempFilterProperties = function () {
1400
+ this.upperCanvas.style.display = 'block';
1401
+ this.cropSelectedState();
1402
+ var obj = { adjustmentLevel: null };
1403
+ this.notify('filter', { prop: 'getAdjustmentLevel', onPropertyChange: false,
1404
+ value: { obj: obj } });
1405
+ this.lowerContext.filter = this.initialAdjustmentValue;
1406
+ this.notify('draw', { prop: 'setTempAdjustmentValue', value: { tempAdjustmentValue: this.lowerContext.filter } });
1407
+ this.notify('filter', { prop: 'setTempAdjustmentLevel', onPropertyChange: false,
1408
+ value: { tempAdjustmentLevel: extend({}, obj['adjustmentLevel'], {}, true) } });
1409
+ this.notify('draw', { prop: 'setTempFilter', value: { tempFilter: this.currentFilter } });
1410
+ var undoRedoObj = { undoRedoStep: null };
1411
+ this.notify('undo-redo', { prop: 'getUndoRedoStep', value: { obj: undoRedoObj } });
1412
+ this.notify('draw', { prop: 'setTempUndoRedoStep', value: { tempUndoRedoStep: undoRedoObj['undoRedoStep'] } });
1413
+ };
1414
+ /**
1415
+ * To crop the selection.
1416
+ *
1417
+ * @hidden
1418
+ * @returns {void}.
1419
+ */
1420
+ ImageEditor.prototype.cropSelectedState = function () {
1421
+ if (this.activeObj.shape && this.activeObj.shape.split('-')[0] === 'crop') {
1422
+ this.okBtn();
1423
+ }
1424
+ };
1425
+ /**
1426
+ * Get the current canvas data.
1427
+ *
1428
+ * @hidden
1429
+ * @returns {ImageData}.
1430
+ * An ImageData returns the current canvas image data object.
1431
+ */
1432
+ ImageEditor.prototype.getCurrentCanvasData = function () {
1433
+ var tempFilter = this.lowerContext.filter;
1434
+ this.lowerContext.filter = this.canvasFilter = 'none';
1435
+ var objColl = extend([], this.objColl, null, true);
1436
+ var pointColl = extend([], this.pointColl, null, true);
1437
+ this.objColl = [];
1438
+ this.pointColl = [];
1439
+ this.freehandCounter = 0;
1440
+ this.notify('draw', { prop: 'render-image', value: { isMouseWheel: false } });
1441
+ var data = this.getImageData();
1442
+ if (!isBlazor()) {
1443
+ this.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: { type: 'main',
1444
+ isApplyBtn: true, isCropping: false } });
1445
+ this.element.querySelector('#' + this.element.id + '_contextualToolbarArea').classList.remove('e-hide');
1446
+ }
1447
+ this.objColl = objColl;
1448
+ this.pointColl = pointColl;
1449
+ this.freehandCounter = pointColl.length;
1450
+ this.notify('shape', { prop: 'iterateObjColl', onPropertyChange: false });
1451
+ this.lowerContext.filter = this.canvasFilter = tempFilter;
1452
+ return data;
1453
+ };
1454
+ /**
1455
+ * To set current adjustment value
1456
+ *
1457
+ * @param { string } type - Specifies the type of adjustment.
1458
+ * @param { number } value - Specifies the value to adjust.
1459
+ * @hidden
1460
+ * @returns {void}.
1461
+ */
1462
+ ImageEditor.prototype.setCurrAdjustmentValue = function (type, value) {
1463
+ var _this = this;
1464
+ var finetuneValueChanging = { finetune: this.getFinetuneOption(type),
1465
+ value: value, cancel: false };
1466
+ if (isBlazor() && this.events && this.events.finetuneValueChanging.hasDelegate === true) {
1467
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
1468
+ this.dotNetRef.invokeMethodAsync('OnFinetuneValueChangeAsync', finetuneValueChanging).then(function (finetuneValueChanging) {
1469
+ if (finetuneValueChanging.cancel) {
1470
+ return;
1471
+ }
1472
+ _this.notify('filter', { prop: 'setCurrAdjValue', value: { type: type.toLowerCase(), value: value } });
1473
+ });
1474
+ }
1475
+ else {
1476
+ this.trigger('finetuneValueChanging', finetuneValueChanging);
1477
+ if (finetuneValueChanging.cancel) {
1478
+ return;
1479
+ }
1480
+ this.notify('filter', { prop: 'setCurrAdjValue', value: { type: type.toLowerCase(), value: value } });
1481
+ }
1482
+ };
1483
+ /**
1484
+ * Get the square point for path.
1485
+ *
1486
+ * @param { SelectionPoint } obj - Specifies the points of path.
1487
+ * @hidden
1488
+ * @returns {ActivePoint}.
1489
+ * An ActivePoint object which returns the square point.
1490
+ */
1491
+ ImageEditor.prototype.getSquarePointForPath = function (obj) {
1492
+ var point = { startX: 0, startY: 0, endX: 0, endY: 0, width: 0, height: 0 };
1493
+ if (obj.pointColl.length > 0) {
1494
+ point = { startX: obj.pointColl[0].x, startY: obj.pointColl[0].y, endX: obj.pointColl[0].x, endY: obj.pointColl[0].y };
1495
+ for (var i = 1; i < obj.pointColl.length; i++) {
1496
+ if (obj.pointColl[i].x < point.startX) {
1497
+ point.startX = obj.pointColl[i].x;
1498
+ }
1499
+ if (obj.pointColl[i].y < point.startY) {
1500
+ point.startY = obj.pointColl[i].y;
1501
+ }
1502
+ if (obj.pointColl[i].x > point.endX) {
1503
+ point.endX = obj.pointColl[i].x;
1504
+ }
1505
+ if (obj.pointColl[i].y > point.endY) {
1506
+ point.endY = obj.pointColl[i].y;
1507
+ }
1508
+ }
1509
+ point.width = point.endX - point.startX;
1510
+ point.height = point.endY - point.startY;
1511
+ }
1512
+ return point;
1513
+ };
1514
+ /**
1515
+ * Get the SelectionType.
1516
+ *
1517
+ * @param { string } type - Specifies the SelectionType.
1518
+ * @hidden
1519
+ * @returns {string}.
1520
+ * An string which returns the SelectionType.
1521
+ */
1522
+ ImageEditor.prototype.getSelectionType = function (type) {
1523
+ var typeToSelectionType = { 'CropCustom': 'Custom', 'CropSquare': 'Square', 'CropCircle': 'Circle',
1524
+ 'Crop3:2': '3:2', 'Crop4:3': '4:3', 'Crop5:4': '5:4', 'Crop7:5': '7:5', 'Crop16:9': '16:9' };
1525
+ return typeToSelectionType["" + type];
1526
+ };
1527
+ /** Clears the context.
1528
+ *
1529
+ * @param { CanvasRenderingContext2D } ctx - Specifies the canvas context.
1530
+ * @hidden
1531
+ * @returns {void}.
1532
+ */
1533
+ ImageEditor.prototype.clearContext = function (ctx) {
1534
+ ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
1535
+ ctx.clearRect(0, 0, ctx.canvas.height, ctx.canvas.width);
1536
+ };
1537
+ /**
1538
+ * Apply Arrow for start and end.
1539
+ *
1540
+ * @param { string } type - Specifies the start arrow or end arrow.
1541
+ * @param { string } id - Specifies the start arrow or end arrow item id.
1542
+ * @hidden
1543
+ * @returns {void}.
1544
+ */
1545
+ ImageEditor.prototype.updateArrow = function (type, id) {
1546
+ this.notify('shape', { prop: 'pushActItemIntoObj' });
1547
+ var prevCropObj = extend({}, this.cropObj, {}, true);
1548
+ var object = { currObj: {} };
1549
+ this.notify('filter', { prop: 'getCurrentObj', onPropertyChange: false, value: { object: object } });
1550
+ var prevObj = object['currObj'];
1551
+ prevObj.objColl = extend([], this.objColl, [], true);
1552
+ prevObj.pointColl = extend([], this.pointColl, [], true);
1553
+ prevObj.afterCropActions = extend([], this.afterCropActions, [], true);
1554
+ this.objColl.pop();
1555
+ if (type === 'startArrow') {
1556
+ this.activeObj.start = this.getTextFromId(id);
1557
+ }
1558
+ else if (type === 'endArrow') {
1559
+ this.activeObj.end = this.getTextFromId(id);
1560
+ }
1561
+ this.notify('shape', { prop: 'setStrokeSettings', value: { strokeSettings: null, strokeColor: null, fillColor: null,
1562
+ strokeWidth: this.activeObj.strokeSettings.strokeWidth } });
1563
+ this.objColl.push(this.activeObj);
1564
+ this.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false,
1565
+ value: { operation: 'shapeTransform', previousObj: prevObj, previousObjColl: prevObj.objColl,
1566
+ previousPointColl: prevObj.pointColl, previousCropObj: prevCropObj, previousText: null,
1567
+ currentText: null, previousFilter: null, isCircleCrop: null } });
1568
+ this.notify('selection', { prop: 'redrawShape', value: { obj: this.objColl[this.objColl.length - 1] } });
1569
+ if (!isBlazor()) {
1570
+ if (Browser.isDevice) {
1571
+ if (document.getElementById(this.element.id + '_bottomToolbar')) {
1572
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
1573
+ var toolbar_1 = getComponent(this.element.id + '_bottomToolbar', 'toolbar');
1574
+ toolbar_1.refreshOverflow();
1575
+ }
1576
+ }
1577
+ else {
1578
+ if (document.getElementById(this.element.id + '_toolbar')) {
1579
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
1580
+ var toolbar_2 = getComponent(this.element.id + '_toolbar', 'toolbar');
1581
+ toolbar_2.refreshOverflow();
1582
+ }
1583
+ }
1584
+ }
1585
+ };
1586
+ /**
1587
+ * Apply Font style for text.
1588
+ *
1589
+ * @param { string } id - Specifies the selected item id.
1590
+ * @hidden
1591
+ * @returns {void}.
1592
+ */
1593
+ ImageEditor.prototype.updateFontFamily = function (id) {
1594
+ this.notify('selection', { prop: 'setInitialTextEdit', value: { bool: false } });
1595
+ this.notify('shape', { prop: 'pushActItemIntoObj' });
1596
+ var objColl = extend([], this.objColl, [], true);
1597
+ var prevCropObj = extend({}, this.cropObj, {}, true);
1598
+ var object = { currObj: {} };
1599
+ this.notify('filter', { prop: 'getCurrentObj', onPropertyChange: false, value: { object: object } });
1600
+ var prevObj = object['currObj'];
1601
+ prevObj.objColl = extend([], this.objColl, [], true);
1602
+ prevObj.pointColl = extend([], this.pointColl, [], true);
1603
+ prevObj.afterCropActions = extend([], this.afterCropActions, [], true);
1604
+ var selPointCollObj = { selPointColl: null };
1605
+ this.notify('freehand-draw', { prop: 'getSelPointColl', onPropertyChange: false,
1606
+ value: { obj: selPointCollObj } });
1607
+ prevObj.selPointColl = extend([], selPointCollObj['selPointColl'], [], true);
1608
+ this.objColl.pop();
1609
+ if (this.textArea.style.display === 'block') {
1610
+ this.notify('shape', { prop: 'updateFontRatio', onPropertyChange: false,
1611
+ value: { obj: this.activeObj, isTextArea: true } });
1612
+ var temp = this.activeObj.textSettings.fontFamily;
1613
+ this.activeObj.textSettings.fontFamily = this.toPascalCase(id);
1614
+ this.notify('shape', { prop: 'redraw-text' });
1615
+ this.objColl.push(this.activeObj);
1616
+ this.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false,
1617
+ value: { operation: 'textAreaCustomization', previousObj: prevObj, previousObjColl: prevObj.objColl,
1618
+ previousPointColl: prevObj.pointColl, previousSelPointColl: prevObj.selPointColl,
1619
+ previousCropObj: prevCropObj, previousText: null,
1620
+ currentText: null, previousFilter: null, isCircleCrop: null } });
1621
+ this.objColl.pop();
1622
+ this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
1623
+ var width = this.activeObj.activePoint.width +
1624
+ this.activeObj.textSettings.fontSize * 0.25;
1625
+ this.textArea.style.width = width + 'px';
1626
+ this.textArea.style.fontFamily = this.toPascalCase(id);
1627
+ this.activeObj.textSettings.fontFamily = temp;
1628
+ this.notify('shape', { prop: 'updateFontStyles', onPropertyChange: false,
1629
+ value: { isTextBox: null } });
1630
+ }
1631
+ else {
1632
+ this.notify('shape', { prop: 'updateFontRatio', onPropertyChange: false,
1633
+ value: { obj: this.activeObj, isTextArea: null } });
1634
+ var fontFamily = this.activeObj.textSettings.fontFamily = this.toPascalCase(id);
1635
+ this.notify('shape', { prop: 'setTextSettings', onPropertyChange: false,
1636
+ value: { textSettings: null, fontFamily: fontFamily, fontSize: null } });
1637
+ this.notify('shape', { prop: 'redraw-text' });
1638
+ this.objColl.push(this.activeObj);
1639
+ this.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false,
1640
+ value: { operation: 'shapeTransform', previousObj: prevObj, previousObjColl: objColl,
1641
+ previousPointColl: extend([], this.pointColl, [], true),
1642
+ previousSelPointColl: prevObj.selPointColl, previousCropObj: prevCropObj, previousText: null,
1643
+ currentText: null, previousFilter: null, isCircleCrop: null } });
1644
+ this.notify('selection', { prop: 'redrawShape', value: { obj: this.objColl[this.objColl.length - 1] } });
1645
+ }
1646
+ };
1647
+ /**
1648
+ * Apply Font size for text.
1649
+ *
1650
+ * @param { string } text - Specifies the selected item text.
1651
+ * @hidden
1652
+ * @returns {void}.
1653
+ */
1654
+ ImageEditor.prototype.updateFontSize = function (text) {
1655
+ var itemText = text;
1656
+ this.notify('selection', { prop: 'setInitialTextEdit', value: { bool: false } });
1657
+ this.notify('shape', { prop: 'pushActItemIntoObj' });
1658
+ var prevCropObj = extend({}, this.cropObj, {}, true);
1659
+ var object = { currObj: {} };
1660
+ this.notify('filter', { prop: 'getCurrentObj', onPropertyChange: false, value: { object: object } });
1661
+ var prevObj = object['currObj'];
1662
+ prevObj.objColl = extend([], this.objColl, [], true);
1663
+ prevObj.pointColl = extend([], this.pointColl, [], true);
1664
+ prevObj.afterCropActions = extend([], this.afterCropActions, [], true);
1665
+ var selPointCollObj = { selPointColl: null };
1666
+ this.notify('freehand-draw', { prop: 'getSelPointColl', onPropertyChange: false,
1667
+ value: { obj: selPointCollObj } });
1668
+ prevObj.selPointColl = extend([], selPointCollObj['selPointColl'], [], true);
1669
+ this.objColl.pop();
1670
+ if (this.textArea.style.display === 'block') {
1671
+ this.notify('shape', { prop: 'updateFontRatio', onPropertyChange: false,
1672
+ value: { obj: this.activeObj, isTextArea: true } });
1673
+ var temp = this.activeObj.textSettings.fontSize;
1674
+ this.activeObj.textSettings.fontSize = parseInt(this.fontSizeColl[(parseInt(itemText, 10) - 1)].text, 10);
1675
+ this.objColl.push(this.activeObj);
1676
+ this.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false,
1677
+ value: { operation: 'textAreaCustomization', previousObj: prevObj, previousObjColl: prevObj.objColl,
1678
+ previousPointColl: prevObj.pointColl, previousSelPointColl: prevObj.selPointColl,
1679
+ previousCropObj: prevCropObj, previousText: null,
1680
+ currentText: null, previousFilter: null, isCircleCrop: null } });
1681
+ this.objColl.pop();
1682
+ var textStyle = '';
1683
+ if (this.textArea.style.fontWeight === 'bold') {
1684
+ textStyle = 'bold ';
1685
+ }
1686
+ if (this.textArea.style.fontStyle === 'italic') {
1687
+ textStyle = 'italic ';
1688
+ }
1689
+ if (this.textArea.style.fontWeight === 'bold' && this.textArea.style.fontStyle === 'italic') {
1690
+ textStyle = 'italic bold ';
1691
+ }
1692
+ this.upperContext.font = textStyle + this.activeObj.textSettings.fontSize + 'px' + ' ' + this.textArea.style.fontFamily;
1693
+ var rows = this.textArea.value.split('\n');
1694
+ var obj = { maxText: '' };
1695
+ this.notify('shape', { prop: 'getMaxText', onPropertyChange: false,
1696
+ value: { isTextBox: true, text: null, obj: obj } });
1697
+ var text_1 = obj['maxText'];
1698
+ var width = this.upperContext.measureText(text_1).width +
1699
+ this.activeObj.textSettings.fontSize * 0.5;
1700
+ this.textArea.style.width = width + 'px';
1701
+ this.textArea.style.height = rows.length * (this.activeObj.textSettings.fontSize + this.activeObj.textSettings.fontSize * 0.25) + 'px';
1702
+ this.activeObj.textSettings.fontSize = temp;
1703
+ this.upperContext.font = this.activeObj.textSettings.fontSize + 'px' + ' ' + this.activeObj.textSettings.fontFamily;
1704
+ this.textArea.style.fontSize = parseInt(this.fontSizeColl[(parseInt(itemText, 10) - 1)].text, 10) + 'px';
1705
+ if (this.textArea.style.fontFamily === 'georgia') {
1706
+ this.textArea.style.width = parseFloat(this.textArea.style.width) + parseFloat(this.textArea.style.fontSize) + 'px';
1707
+ }
1708
+ }
1709
+ else {
1710
+ this.notify('shape', { prop: 'updateFontRatio', onPropertyChange: false,
1711
+ value: { obj: this.activeObj, isTextArea: null } });
1712
+ var fontSize = this.activeObj.textSettings.fontSize = parseInt(this.fontSizeColl[(parseInt(itemText, 10) - 1)].text, 10);
1713
+ this.notify('shape', { prop: 'setTextSettings', onPropertyChange: false,
1714
+ value: { textSettings: null, fontFamily: null, fontSize: fontSize } });
1715
+ this.upperContext.font = this.activeObj.textSettings.fontSize + 'px' + ' ' + this.activeObj.textSettings.fontFamily;
1716
+ var rows = this.activeObj.keyHistory.split('\n');
1717
+ var obj = { maxText: '' };
1718
+ this.notify('shape', { prop: 'getMaxText', onPropertyChange: false,
1719
+ value: { isTextBox: null, text: null, obj: obj } });
1720
+ var text_2 = obj['maxText'];
1721
+ var width = this.upperContext.measureText(text_2).width +
1722
+ this.activeObj.textSettings.fontSize * 0.5;
1723
+ var height = rows.length * (this.activeObj.textSettings.fontSize +
1724
+ this.activeObj.textSettings.fontSize * 0.25);
1725
+ this.notify('selection', { prop: 'setTextSelection', onPropertyChange: false,
1726
+ value: { width: width, height: height } });
1727
+ this.notify('draw', { prop: 'updateActiveObject', onPropertyChange: false, value: { actPoint: this.activeObj.activePoint, obj: this.activeObj,
1728
+ isMouseMove: null, x: null, y: null } });
1729
+ this.notify('shape', { prop: 'redraw-text' });
1730
+ this.objColl.push(this.activeObj);
1731
+ this.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false,
1732
+ value: { operation: 'shapeTransform', previousObj: prevObj, previousObjColl: prevObj.objColl,
1733
+ previousPointColl: prevObj.pointColl, previousSelPointColl: prevObj.selPointColl,
1734
+ previousCropObj: prevCropObj, previousText: null,
1735
+ currentText: null, previousFilter: null, isCircleCrop: null } });
1736
+ this.notify('selection', { prop: 'redrawShape', value: { obj: this.objColl[this.objColl.length - 1] } });
1737
+ }
1738
+ };
1739
+ /**
1740
+ * Apply Font color for text.
1741
+ *
1742
+ * @param { string } value - Specifies the selected color item value.
1743
+ * @hidden
1744
+ * @returns {void}.
1745
+ */
1746
+ ImageEditor.prototype.updateFontColor = function (value) {
1747
+ this.notify('selection', { prop: 'setInitialTextEdit', value: { bool: false } });
1748
+ this.notify('shape', { prop: 'pushActItemIntoObj' });
1749
+ var prevCropObj = extend({}, this.cropObj, {}, true);
1750
+ var object = { currObj: {} };
1751
+ this.notify('filter', { prop: 'getCurrentObj', onPropertyChange: false, value: { object: object } });
1752
+ var prevObj = object['currObj'];
1753
+ prevObj.objColl = extend([], this.objColl, [], true);
1754
+ prevObj.pointColl = extend([], this.pointColl, [], true);
1755
+ prevObj.afterCropActions = extend([], this.afterCropActions, [], true);
1756
+ var selPointCollObj = { selPointColl: null };
1757
+ this.notify('freehand-draw', { prop: 'getSelPointColl', onPropertyChange: false,
1758
+ value: { obj: selPointCollObj } });
1759
+ prevObj.selPointColl = extend([], selPointCollObj['selPointColl'], [], true);
1760
+ this.objColl.pop();
1761
+ if (this.textArea.style.display === 'none') {
1762
+ this.activeObj.strokeSettings.strokeColor = value;
1763
+ this.notify('shape', { prop: 'setStrokeSettings', value: { strokeSettings: null,
1764
+ strokeColor: this.activeObj.strokeSettings.strokeColor, fillColor: null, strokeWidth: null } });
1765
+ if (!this.togglePen) {
1766
+ this.objColl.push(this.activeObj);
1767
+ this.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false,
1768
+ value: { operation: 'shapeTransform', previousObj: prevObj, previousObjColl: prevObj.objColl,
1769
+ previousPointColl: prevObj.pointColl, previousSelPointColl: prevObj.selPointColl,
1770
+ previousCropObj: prevCropObj, previousText: null,
1771
+ currentText: null, previousFilter: null, isCircleCrop: null } });
1772
+ this.notify('selection', { prop: 'redrawShape', value: { obj: this.objColl[this.objColl.length - 1] } });
1773
+ }
1774
+ }
1775
+ else if (this.textArea.style.display === 'block') {
1776
+ this.textArea.style.color = value;
1777
+ var temp = this.activeObj.strokeSettings.strokeColor;
1778
+ this.activeObj.strokeSettings.strokeColor = value;
1779
+ this.objColl.push(this.activeObj);
1780
+ this.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false,
1781
+ value: { operation: 'textAreaCustomization', previousObj: prevObj, previousObjColl: prevObj.objColl,
1782
+ previousPointColl: prevObj.pointColl, previousSelPointColl: prevObj.selPointColl,
1783
+ previousCropObj: prevCropObj, previousText: null,
1784
+ currentText: null, previousFilter: null, isCircleCrop: null } });
1785
+ this.objColl.pop();
1786
+ this.activeObj.strokeSettings.strokeColor = temp;
1787
+ }
1788
+ else if (!this.togglePen) {
1789
+ this.objColl.push(this.activeObj);
1790
+ this.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false,
1791
+ value: { operation: 'shapeTransform', previousObj: prevObj, previousObjColl: prevObj.objColl,
1792
+ previousPointColl: prevObj.pointColl, previousSelPointColl: prevObj.selPointColl,
1793
+ previousCropObj: prevCropObj, previousText: null,
1794
+ currentText: null, previousFilter: null, isCircleCrop: null } });
1795
+ this.notify('selection', { prop: 'redrawShape', value: { obj: this.objColl[this.objColl.length - 1] } });
1796
+ }
1797
+ };
1798
+ /**
1799
+ * Apply Pen stroke width.
1800
+ *
1801
+ * @param { string } id - Specifies the selected item id.
1802
+ * @hidden
1803
+ * @returns {void}.
1804
+ */
1805
+ ImageEditor.prototype.updatePenStrokeWidth = function (id) {
1806
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
1807
+ var temp = extend([], this.pointColl, [], true);
1808
+ this.updateFreehandDrawColorChange();
1809
+ var prevCropObj = extend({}, this.cropObj, {}, true);
1810
+ var object = { currObj: {} };
1811
+ this.notify('filter', { prop: 'getCurrentObj', onPropertyChange: false, value: { object: object } });
1812
+ var prevObj = object['currObj'];
1813
+ prevObj.objColl = extend([], this.objColl, [], true);
1814
+ prevObj.pointColl = extend([], this.pointColl, [], true);
1815
+ prevObj.afterCropActions = extend([], this.afterCropActions, [], true);
1816
+ var selPointCollObj = { selPointColl: null };
1817
+ this.notify('freehand-draw', { prop: 'getSelPointColl', onPropertyChange: false,
1818
+ value: { obj: selPointCollObj } });
1819
+ prevObj.selPointColl = extend([], selPointCollObj['selPointColl'], [], true);
1820
+ this.pointColl = temp;
1821
+ this.notify('selection', { prop: 'setFreehandDrawCustomized', value: { isFreehandDrawCustomized: true } });
1822
+ this.setPenStroke(id);
1823
+ var obj = { bool: false };
1824
+ this.notify('selection', { prop: 'getFreehandDrawEditing', onPropertyChange: false, value: { obj: obj } });
1825
+ if (obj['bool']) {
1826
+ var obj_3 = { penStrokeWidth: null };
1827
+ this.notify('freehand-draw', { prop: 'getPenStrokeWidth', onPropertyChange: false, value: { obj: obj_3 } });
1828
+ this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
1829
+ this.notify('freehand-draw', { prop: 'hoverFhd', onPropertyChange: false,
1830
+ value: { strokeColor: null, strokeWidth: obj_3['penStrokeWidth'] } });
1831
+ var indexObj = { freehandSelectedIndex: null };
1832
+ this.notify('freehand-draw', { prop: 'getFreehandSelectedIndex', onPropertyChange: false, value: { obj: indexObj } });
1833
+ this.pointColl[indexObj['freehandSelectedIndex']].strokeWidth = obj_3['penStrokeWidth'];
1834
+ this.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false,
1835
+ value: { operation: 'freehanddrawCustomized', previousObj: prevObj, previousObjColl: prevObj.objColl,
1836
+ previousPointColl: prevObj.pointColl, previousSelPointColl: prevObj.selPointColl,
1837
+ previousCropObj: prevCropObj, previousText: null,
1838
+ currentText: null, previousFilter: null, isCircleCrop: null } });
1839
+ }
1840
+ };
1841
+ /**
1842
+ * Apply Pen stroke color.
1843
+ *
1844
+ * @param { string } value - Specifies the selected color item value.
1845
+ * @hidden
1846
+ * @returns {void}.
1847
+ */
1848
+ ImageEditor.prototype.updatePenStrokeColor = function (value) {
1849
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
1850
+ var temp = extend([], this.pointColl, [], true);
1851
+ this.updateFreehandDrawColorChange();
1852
+ var prevCropObj = extend({}, this.cropObj, {}, true);
1853
+ var object = { currObj: {} };
1854
+ this.notify('filter', { prop: 'getCurrentObj', onPropertyChange: false, value: { object: object } });
1855
+ var prevObj = object['currObj'];
1856
+ prevObj.objColl = extend([], this.objColl, [], true);
1857
+ prevObj.pointColl = extend([], this.pointColl, [], true);
1858
+ prevObj.afterCropActions = extend([], this.afterCropActions, [], true);
1859
+ var selPointCollObj = { selPointColl: null };
1860
+ this.notify('freehand-draw', { prop: 'getSelPointColl', onPropertyChange: false,
1861
+ value: { obj: selPointCollObj } });
1862
+ prevObj.selPointColl = extend([], selPointCollObj['selPointColl'], [], true);
1863
+ this.pointColl = temp;
1864
+ this.notify('selection', { prop: 'setFreehandDrawCustomized', value: { isFreehandDrawCustomized: true } });
1865
+ this.activeObj.strokeSettings.strokeColor = value;
1866
+ var obj = { bool: false };
1867
+ this.notify('selection', { prop: 'getFreehandDrawEditing', onPropertyChange: false, value: { obj: obj } });
1868
+ if (obj['bool']) {
1869
+ var indexObj = { freehandSelectedIndex: null };
1870
+ this.notify('freehand-draw', { prop: 'getFreehandSelectedIndex', onPropertyChange: false, value: { obj: indexObj } });
1871
+ this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
1872
+ this.pointColl[indexObj['freehandSelectedIndex']].strokeColor = value;
1873
+ this.notify('freehand-draw', { prop: 'hoverFhd', onPropertyChange: false,
1874
+ value: { strokeColor: value } });
1875
+ this.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false,
1876
+ value: { operation: 'freehanddrawCustomized', previousObj: prevObj, previousObjColl: prevObj.objColl,
1877
+ previousPointColl: prevObj.pointColl, previousSelPointColl: prevObj.selPointColl,
1878
+ previousCropObj: prevCropObj, previousText: null,
1879
+ currentText: null, previousFilter: null, isCircleCrop: null } });
1880
+ }
1881
+ else if (!this.togglePen) {
1882
+ this.notify('selection', { prop: 'redrawShape', value: { obj: this.activeObj } });
1883
+ }
1884
+ };
1885
+ /**
1886
+ * Apply Shape stroke width.
1887
+ *
1888
+ * @param { string } id - Specifies the selected item id.
1889
+ * @hidden
1890
+ * @returns {void}.
1891
+ */
1892
+ ImageEditor.prototype.updateStrokeWidth = function (id) {
1893
+ this.notify('shape', { prop: 'pushActItemIntoObj' });
1894
+ var prevCropObj = extend({}, this.cropObj, {}, true);
1895
+ var object = { currObj: {} };
1896
+ this.notify('filter', { prop: 'getCurrentObj', onPropertyChange: false, value: { object: object } });
1897
+ var prevObj = object['currObj'];
1898
+ prevObj.objColl = extend([], this.objColl, [], true);
1899
+ prevObj.pointColl = extend([], this.pointColl, [], true);
1900
+ prevObj.afterCropActions = extend([], this.afterCropActions, [], true);
1901
+ var selPointCollObj = { selPointColl: null };
1902
+ this.notify('freehand-draw', { prop: 'getSelPointColl', onPropertyChange: false,
1903
+ value: { obj: selPointCollObj } });
1904
+ prevObj.selPointColl = extend([], selPointCollObj['selPointColl'], [], true);
1905
+ this.objColl.pop();
1906
+ this.activeObj.strokeSettings.strokeWidth = parseInt(id, 10);
1907
+ this.activeObj.strokeSettings.strokeWidth *= 2;
1908
+ this.notify('shape', { prop: 'setStrokeSettings', value: { strokeSettings: null, strokeColor: null, fillColor: null,
1909
+ strokeWidth: this.activeObj.strokeSettings.strokeWidth } });
1910
+ this.objColl.push(this.activeObj);
1911
+ this.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false,
1912
+ value: { operation: 'shapeTransform', previousObj: prevObj, previousObjColl: prevObj.objColl,
1913
+ previousPointColl: prevObj.pointColl, previousSelPointColl: prevObj.selPointColl,
1914
+ previousCropObj: prevCropObj, previousText: null,
1915
+ currentText: null, previousFilter: null, isCircleCrop: null } });
1916
+ this.notify('selection', { prop: 'redrawShape', value: { obj: this.objColl[this.objColl.length - 1] } });
1917
+ };
1918
+ /**
1919
+ * Apply Shape stroke color.
1920
+ *
1921
+ * @param { string } value - Specifies the selected color item value.
1922
+ * @hidden
1923
+ * @returns {void}.
1924
+ */
1925
+ ImageEditor.prototype.updateStrokeColor = function (value) {
1926
+ this.notify('shape', { prop: 'pushActItemIntoObj' });
1927
+ var prevCropObj = extend({}, this.cropObj, {}, true);
1928
+ var object = { currObj: {} };
1929
+ this.notify('filter', { prop: 'getCurrentObj', onPropertyChange: false, value: { object: object } });
1930
+ var prevObj = object['currObj'];
1931
+ prevObj.objColl = extend([], this.objColl, [], true);
1932
+ prevObj.pointColl = extend([], this.pointColl, [], true);
1933
+ prevObj.afterCropActions = extend([], this.afterCropActions, [], true);
1934
+ var selPointCollObj = { selPointColl: null };
1935
+ this.notify('freehand-draw', { prop: 'getSelPointColl', onPropertyChange: false,
1936
+ value: { obj: selPointCollObj } });
1937
+ prevObj.selPointColl = extend([], selPointCollObj['selPointColl'], [], true);
1938
+ this.objColl.pop();
1939
+ this.activeObj.strokeSettings.strokeColor = value;
1940
+ this.notify('shape', { prop: 'setStrokeSettings', value: { strokeSettings: null, strokeColor: this.activeObj.strokeSettings.strokeColor, fillColor: null, strokeWidth: null } });
1941
+ if (!this.togglePen) {
1942
+ this.objColl.push(this.activeObj);
1943
+ this.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false,
1944
+ value: { operation: 'shapeTransform', previousObj: prevObj, previousObjColl: prevObj.objColl,
1945
+ previousPointColl: prevObj.pointColl, previousSelPointColl: prevObj.selPointColl,
1946
+ previousCropObj: prevCropObj, previousText: null,
1947
+ currentText: null, previousFilter: null, isCircleCrop: null } });
1948
+ this.notify('selection', { prop: 'redrawShape', value: { obj: this.objColl[this.objColl.length - 1] } });
1949
+ }
1950
+ };
1951
+ /**
1952
+ * Apply Shape fill color.
1953
+ *
1954
+ * @param { string } value - Specifies the selected color item value.
1955
+ * @hidden
1956
+ * @returns {void}.
1957
+ */
1958
+ ImageEditor.prototype.updateFillColor = function (value) {
1959
+ this.notify('shape', { prop: 'pushActItemIntoObj' });
1960
+ var prevCropObj = extend({}, this.cropObj, {}, true);
1961
+ var object = { currObj: {} };
1962
+ this.notify('filter', { prop: 'getCurrentObj', onPropertyChange: false, value: { object: object } });
1963
+ var prevObj = object['currObj'];
1964
+ prevObj.objColl = extend([], this.objColl, [], true);
1965
+ prevObj.pointColl = extend([], this.pointColl, [], true);
1966
+ prevObj.afterCropActions = extend([], this.afterCropActions, [], true);
1967
+ var selPointCollObj = { selPointColl: null };
1968
+ this.notify('freehand-draw', { prop: 'getSelPointColl', onPropertyChange: false,
1969
+ value: { obj: selPointCollObj } });
1970
+ prevObj.selPointColl = extend([], selPointCollObj['selPointColl'], [], true);
1971
+ this.objColl.pop();
1972
+ this.activeObj.strokeSettings.fillColor = value;
1973
+ this.notify('shape', { prop: 'setStrokeSettings',
1974
+ value: { strokeSettings: null, strokeColor: null, fillColor: this.activeObj.strokeSettings.fillColor,
1975
+ strokeWidth: null } });
1976
+ this.objColl.push(this.activeObj);
1977
+ this.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false,
1978
+ value: { operation: 'shapeTransform', previousObj: prevObj, previousObjColl: prevObj.objColl,
1979
+ previousPointColl: prevObj.pointColl, previousSelPointColl: prevObj.selPointColl,
1980
+ previousCropObj: prevCropObj, previousText: null,
1981
+ currentText: null, previousFilter: null, isCircleCrop: null } });
1982
+ this.notify('selection', { prop: 'redrawShape', value: { obj: this.objColl[this.objColl.length - 1] } });
1983
+ };
1984
+ /**
1985
+ * Get pascalToSplitWords from string.
1986
+ *
1987
+ * @param { string } str - Specifies the word.
1988
+ * @hidden
1989
+ * @returns {string}.
1990
+ */
1991
+ ImageEditor.prototype.pascalToSplitWords = function (str) {
1992
+ str = str.charAt(0).toUpperCase() + str.slice(1);
1993
+ var splitStr = str.match(/[A-Z][a-z]+/g);
1994
+ if (isNullOrUndefined(splitStr)) {
1995
+ return str;
1996
+ }
1997
+ else {
1998
+ return splitStr.map(function (word) { return word.charAt(0).toUpperCase() + word.slice(1); }).join(' ');
1999
+ }
2000
+ };
2001
+ /**
2002
+ * Get Slider Value.
2003
+ *
2004
+ * @param { string } type - Finetune type.
2005
+ * @hidden
2006
+ * @returns {number}.
2007
+ */
2008
+ ImageEditor.prototype.getCurrAdjustmentValue = function (type) {
2009
+ var obj = { adjustmentLevel: null };
2010
+ this.notify('filter', { prop: 'getAdjustmentLevel', onPropertyChange: false,
2011
+ value: { obj: obj } });
2012
+ var typeToAdjustmentLevel = { 'brightness': obj['adjustmentLevel'].brightness,
2013
+ 'contrast': obj['adjustmentLevel'].contrast, 'hue': obj['adjustmentLevel'].hue,
2014
+ 'saturation': obj['adjustmentLevel'].saturation, 'opacity': obj['adjustmentLevel'].opacity,
2015
+ 'blur': obj['adjustmentLevel'].blur, 'exposure': obj['adjustmentLevel'].exposure };
2016
+ return typeToAdjustmentLevel["" + type];
2017
+ };
2018
+ /**
2019
+ * Apply transformSelect.
2020
+ *
2021
+ * @param { string } type - Specifies the selected item text.
2022
+ * @hidden
2023
+ * @returns {void}.
2024
+ */
2025
+ ImageEditor.prototype.transformSelect = function (type) {
2026
+ this.isCropToolbar = true;
2027
+ this.setInitialZoomState();
2028
+ var activeObj = extend({}, this.activeObj, {}, true);
2029
+ this.cropSelectedState();
2030
+ this.notify('draw', { prop: 'resetCurrentSelectionPoint' });
2031
+ this.notify('transform', { prop: 'performTransformation', value: { text: type } });
2032
+ this.notify('draw', { prop: 'moveToSelectionRange', value: { type: type, activeObj: activeObj } });
2033
+ this.isCropToolbar = false;
2034
+ };
2035
+ /**
2036
+ * Returns default filter.
2037
+ *
2038
+ * @hidden
2039
+ * @returns {string}.
2040
+ */
2041
+ ImageEditor.prototype.getDefaultFilter = function () {
2042
+ return 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
2043
+ 'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' +
2044
+ 'grayscale(0%) ' + 'invert(0%)';
2045
+ };
2046
+ // Blazor codes
2047
+ /**
2048
+ * To Initialize the component rendering
2049
+ *
2050
+ * @private
2051
+ * @param {HTMLCanvasElement} element - Specifies the canvas element.
2052
+ * @param {BlazorDotnetObject} dotnetRef - Specifies for blazor client to server communication.
2053
+ * @returns {void}
2054
+ */
2055
+ ImageEditor.prototype.initializeImageEditor = function (element, dotnetRef) {
2056
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
2057
+ this.element = element;
2058
+ var canvasWrapper = this.element.querySelector('.e-canvas-wrapper');
2059
+ if (this.element.querySelector('#' + this.element.id + '_toolbar')) {
2060
+ this.toolbarHeight = this.element.querySelector('#' + this.element.id + '_toolbar').clientHeight;
2061
+ }
2062
+ else {
2063
+ this.toolbarHeight = 0;
2064
+ }
2065
+ canvasWrapper.style.height = (this.element.offsetHeight - this.toolbarHeight - 2) + 'px';
2066
+ canvasWrapper.style.width = (this.element.offsetWidth - 2) + 'px';
2067
+ this.lowerCanvas = this.element.querySelector('.e-lower-canvas');
2068
+ this.upperCanvas = this.element.querySelector('.e-upper-canvas');
2069
+ this.lowerCanvas.id = this.element.id + '_lowerCanvas';
2070
+ this.upperCanvas.id = this.element.id + '_upperCanvas';
2071
+ this.textArea = this.element.querySelector('.e-textbox');
2072
+ this.inMemoryCanvas = this.createElement('canvas', {
2073
+ id: this.element.id + '_inMemoryCanvas', attrs: { name: 'canvasImage' }
2074
+ });
2075
+ this.upperCanvas.width = this.lowerCanvas.width = this.inMemoryCanvas.width = this.element.offsetWidth;
2076
+ this.upperCanvas.height = this.lowerCanvas.height = this.inMemoryCanvas.height = (this.element.offsetHeight - this.toolbarHeight);
2077
+ this.baseImg = this.createElement('img', {
2078
+ id: this.element.id + '_orgImg', attrs: { name: 'Image', crossorigin: 'anonymous' }
2079
+ });
2080
+ this.lowerContext = this.lowerCanvas.getContext('2d');
2081
+ this.baseImg = this.createElement('img', {
2082
+ id: this.element.id + '_orgImg', attrs: { name: 'Image', crossorigin: 'anonymous' }
2083
+ });
2084
+ this.upperContext = this.upperCanvas.getContext('2d');
2085
+ this.inMemoryContext = this.inMemoryCanvas.getContext('2d');
2086
+ if (dotnetRef) {
2087
+ this.dotNetRef = dotnetRef;
2088
+ }
2089
+ this.prerender();
2090
+ this.wireEvent();
2091
+ this.lowerContext.filter = this.getDefaultFilter();
2092
+ this.notify('filter', { prop: 'setAdjustmentValue', onPropertyChange: false, value: { adjustmentValue: this.lowerContext.filter } });
2093
+ this.canvasFilter = this.initialAdjustmentValue = this.lowerContext.filter;
2094
+ if (this.cssClass) {
2095
+ addClass([this.element], this.cssClass.replace(/\s+/g, ' ').trim().split(' '));
2096
+ }
2097
+ if (this.element) {
2098
+ createSpinner({
2099
+ target: this.element
2100
+ });
2101
+ }
2102
+ this.initializeZoomSettings();
2103
+ };
2104
+ ImageEditor.prototype.prerender = function () {
2105
+ // pre render code snippets
2106
+ this.element.id = this.element.id || getUniqueID('ej2-image-editor');
2107
+ if (Browser.isDevice) {
2108
+ this.element.classList.add('e-device');
2109
+ }
2110
+ this.initializeThemeColl();
2111
+ };
2112
+ ImageEditor.prototype.initializeZoomSettings = function () {
2113
+ if (isNullOrUndefined(this.zoomSettings.zoomTrigger)) {
2114
+ this.zoomSettings.zoomTrigger = (ZoomTrigger.MouseWheel | ZoomTrigger.Pinch | ZoomTrigger.Toolbar | ZoomTrigger.Commands);
2115
+ }
2116
+ if (isNullOrUndefined(this.selectionSettings.strokeColor)) {
2117
+ this.selectionSettings.strokeColor = this.themeColl[this.theme]['primaryColor'];
2118
+ }
2119
+ if (isNullOrUndefined(this.selectionSettings.fillColor)) {
2120
+ this.selectionSettings.fillColor = this.themeColl[this.theme]['secondaryColor'];
2121
+ }
2122
+ };
2123
+ ImageEditor.prototype.initializeThemeColl = function () {
2124
+ this.themeColl = {
2125
+ Bootstrap5: { primaryColor: '#0d6efd', secondaryColor: '#fff' },
2126
+ Bootstrap5Dark: { primaryColor: '#0d6efd', secondaryColor: '#fff' },
2127
+ Tailwind: { primaryColor: '#4f46e5', secondaryColor: '#fff' },
2128
+ TailwindDark: { primaryColor: '#22d3ee', secondaryColor: '#fff' },
2129
+ Fluent: { primaryColor: '#0078d4', secondaryColor: '#fff' },
2130
+ FluentDark: { primaryColor: '#0078d4', secondaryColor: '#fff' },
2131
+ Bootstrap4: { primaryColor: '#007bff', secondaryColor: '#fff' },
2132
+ Bootstrap: { primaryColor: '#317ab9', secondaryColor: '#fff' },
2133
+ BootstrapDark: { primaryColor: '#317ab9', secondaryColor: '#fff' },
2134
+ Material: { primaryColor: '#e3165b', secondaryColor: '#fff' },
2135
+ MaterialDark: { primaryColor: '#00b0ff', secondaryColor: '#fff' },
2136
+ Fabric: { primaryColor: '#0078d6', secondaryColor: '#fff' },
2137
+ FabricDark: { primaryColor: '#0074cc', secondaryColor: '#fff' },
2138
+ Highcontrast: { primaryColor: '#000000', secondaryColor: '#fff' },
2139
+ Material3: { primaryColor: '#6750a4', secondaryColor: '#fff' },
2140
+ Material3Dark: { primaryColor: '#d0bcff', secondaryColor: '#fff' }
2141
+ };
2142
+ };
2143
+ /**
2144
+ * Get the square point for path.
2145
+ *
2146
+ * @param { HTMLDivElement } element - Specifies element.
2147
+ * @param { string } type - Specifies the type.
2148
+ * @param { string } value - Specifies the value.
2149
+ * @hidden
2150
+ * @private
2151
+ * @returns {void}.
2152
+ */
2153
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function
2154
+ ImageEditor.prototype.updateToolbar = function (element, type, value) {
2155
+ };
2156
+ var ImageEditor_1;
2157
+ __decorate([
2158
+ Property('')
2159
+ ], ImageEditor.prototype, "cssClass", void 0);
2160
+ __decorate([
2161
+ Property(false)
2162
+ ], ImageEditor.prototype, "disabled", void 0);
2163
+ __decorate([
2164
+ Property('100%')
2165
+ ], ImageEditor.prototype, "height", void 0);
2166
+ __decorate([
2167
+ Property('Bootstrap5')
2168
+ ], ImageEditor.prototype, "theme", void 0);
2169
+ __decorate([
2170
+ Property()
2171
+ ], ImageEditor.prototype, "toolbar", void 0);
2172
+ __decorate([
2173
+ Property()
2174
+ ], ImageEditor.prototype, "toolbarTemplate", void 0);
2175
+ __decorate([
2176
+ Property('100%')
2177
+ ], ImageEditor.prototype, "width", void 0);
2178
+ __decorate([
2179
+ Property(true)
2180
+ ], ImageEditor.prototype, "allowUndoRedo", void 0);
2181
+ __decorate([
2182
+ Property(true)
2183
+ ], ImageEditor.prototype, "showQuickAccessToolbar", void 0);
2184
+ __decorate([
2185
+ Property()
2186
+ ], ImageEditor.prototype, "quickAccessToolbarTemplate", void 0);
2187
+ __decorate([
2188
+ Property(false)
2189
+ ], ImageEditor.prototype, "isReadOnly", void 0);
2190
+ __decorate([
2191
+ Property(false)
2192
+ ], ImageEditor.prototype, "enableRtl", void 0);
2193
+ __decorate([
2194
+ Property(false)
2195
+ ], ImageEditor.prototype, "enablePersistence", void 0);
2196
+ __decorate([
2197
+ Complex({}, FinetuneSettings)
2198
+ ], ImageEditor.prototype, "finetuneSettings", void 0);
2199
+ __decorate([
2200
+ Complex({}, ZoomSettings)
2201
+ ], ImageEditor.prototype, "zoomSettings", void 0);
2202
+ __decorate([
2203
+ Complex({}, SelectionSettings)
2204
+ ], ImageEditor.prototype, "selectionSettings", void 0);
2205
+ __decorate([
2206
+ Event()
2207
+ ], ImageEditor.prototype, "beforeSave", void 0);
2208
+ __decorate([
2209
+ Event()
2210
+ ], ImageEditor.prototype, "created", void 0);
2211
+ __decorate([
2212
+ Event()
2213
+ ], ImageEditor.prototype, "destroyed", void 0);
2214
+ __decorate([
2215
+ Event()
2216
+ ], ImageEditor.prototype, "zooming", void 0);
2217
+ __decorate([
2218
+ Event()
2219
+ ], ImageEditor.prototype, "panning", void 0);
2220
+ __decorate([
2221
+ Event()
2222
+ ], ImageEditor.prototype, "cropping", void 0);
2223
+ __decorate([
2224
+ Event()
2225
+ ], ImageEditor.prototype, "rotating", void 0);
2226
+ __decorate([
2227
+ Event()
2228
+ ], ImageEditor.prototype, "flipping", void 0);
2229
+ __decorate([
2230
+ Event()
2231
+ ], ImageEditor.prototype, "shapeChanging", void 0);
2232
+ __decorate([
2233
+ Event()
2234
+ ], ImageEditor.prototype, "selectionChanging", void 0);
2235
+ __decorate([
2236
+ Event()
2237
+ ], ImageEditor.prototype, "fileOpened", void 0);
2238
+ __decorate([
2239
+ Event()
2240
+ ], ImageEditor.prototype, "saved", void 0);
2241
+ __decorate([
2242
+ Event()
2243
+ ], ImageEditor.prototype, "toolbarCreated", void 0);
2244
+ __decorate([
2245
+ Event()
2246
+ ], ImageEditor.prototype, "toolbarUpdating", void 0);
2247
+ __decorate([
2248
+ Event()
2249
+ ], ImageEditor.prototype, "toolbarItemClicked", void 0);
2250
+ __decorate([
2251
+ Event()
2252
+ ], ImageEditor.prototype, "imageFiltering", void 0);
2253
+ __decorate([
2254
+ Event()
2255
+ ], ImageEditor.prototype, "finetuneValueChanging", void 0);
2256
+ __decorate([
2257
+ Event()
2258
+ ], ImageEditor.prototype, "click", void 0);
2259
+ __decorate([
2260
+ Event()
2261
+ ], ImageEditor.prototype, "quickAccessToolbarOpen", void 0);
2262
+ __decorate([
2263
+ Event()
2264
+ ], ImageEditor.prototype, "quickAccessToolbarItemClick", void 0);
2265
+ ImageEditor = ImageEditor_1 = __decorate([
2266
+ NotifyPropertyChanges
2267
+ ], ImageEditor);
2268
+ return ImageEditor;
2269
+ }(Component));
2270
+ export { ImageEditor };