@syncfusion/ej2-image-editor 20.3.50 → 20.4.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +16 -1
- package/CHANGELOG.md +6 -0
- package/README.md +65 -2
- package/dist/ej2-image-editor.umd.min.js +2 -2
- package/dist/ej2-image-editor.umd.min.js.map +1 -1
- package/dist/es6/ej2-image-editor.es2015.js +2639 -623
- package/dist/es6/ej2-image-editor.es2015.js.map +1 -1
- package/dist/es6/ej2-image-editor.es5.js +2676 -652
- package/dist/es6/ej2-image-editor.es5.js.map +1 -1
- package/dist/global/ej2-image-editor.min.js +2 -2
- package/dist/global/ej2-image-editor.min.js.map +1 -1
- package/dist/global/index.d.ts +1 -1
- package/package.json +22 -24
- package/src/image-editor/image-editor-model.d.ts +102 -19
- package/src/image-editor/image-editor.d.ts +232 -31
- package/src/image-editor/image-editor.js +2676 -651
- package/styles/bootstrap-dark.css +36 -0
- package/styles/bootstrap.css +36 -0
- package/styles/bootstrap4.css +36 -0
- package/styles/bootstrap5-dark.css +36 -0
- package/styles/bootstrap5.css +36 -0
- package/styles/fabric-dark.css +36 -0
- package/styles/fabric.css +36 -0
- package/styles/fluent-dark.css +36 -0
- package/styles/fluent.css +36 -0
- package/styles/highcontrast-light.css +36 -0
- package/styles/highcontrast.css +36 -0
- package/styles/image-editor/_bootstrap-dark-definition.scss +1 -0
- package/styles/image-editor/_bootstrap-definition.scss +1 -0
- package/styles/image-editor/_bootstrap4-definition.scss +1 -0
- package/styles/image-editor/_bootstrap5-definition.scss +1 -0
- package/styles/image-editor/_fabric-dark-definition.scss +1 -0
- package/styles/image-editor/_fabric-definition.scss +1 -0
- package/styles/image-editor/_fluent-definition.scss +1 -0
- package/styles/image-editor/_fusionnew-definition.scss +1 -0
- package/styles/image-editor/_highcontrast-definition.scss +1 -0
- package/styles/image-editor/_highcontrast-light-definition.scss +1 -0
- package/styles/image-editor/_layout.scss +38 -0
- package/styles/image-editor/_material-dark-definition.scss +1 -0
- package/styles/image-editor/_material-definition.scss +1 -0
- package/styles/image-editor/_material3-definition.scss +1 -0
- package/styles/image-editor/_tailwind-definition.scss +1 -0
- package/styles/image-editor/_theme.scss +11 -0
- package/styles/image-editor/bootstrap-dark.css +36 -0
- package/styles/image-editor/bootstrap-dark.scss +1 -0
- package/styles/image-editor/bootstrap.css +36 -0
- package/styles/image-editor/bootstrap.scss +1 -0
- package/styles/image-editor/bootstrap4.css +36 -0
- package/styles/image-editor/bootstrap4.scss +1 -0
- package/styles/image-editor/bootstrap5-dark.css +36 -0
- package/styles/image-editor/bootstrap5-dark.scss +1 -0
- package/styles/image-editor/bootstrap5.css +36 -0
- package/styles/image-editor/bootstrap5.scss +1 -0
- package/styles/image-editor/fabric-dark.css +36 -0
- package/styles/image-editor/fabric-dark.scss +1 -0
- package/styles/image-editor/fabric.css +36 -0
- package/styles/image-editor/fabric.scss +1 -0
- package/styles/image-editor/fluent-dark.css +36 -0
- package/styles/image-editor/fluent-dark.scss +1 -0
- package/styles/image-editor/fluent.css +36 -0
- package/styles/image-editor/fluent.scss +1 -0
- package/styles/image-editor/highcontrast-light.css +36 -0
- package/styles/image-editor/highcontrast-light.scss +1 -0
- package/styles/image-editor/highcontrast.css +36 -0
- package/styles/image-editor/highcontrast.scss +1 -0
- package/styles/image-editor/material-dark.css +36 -0
- package/styles/image-editor/material-dark.scss +1 -0
- package/styles/image-editor/material.css +36 -0
- package/styles/image-editor/material.scss +1 -0
- package/styles/image-editor/tailwind-dark.css +36 -0
- package/styles/image-editor/tailwind-dark.scss +1 -0
- package/styles/image-editor/tailwind.css +36 -0
- package/styles/image-editor/tailwind.scss +1 -0
- package/styles/material-dark.css +36 -0
- package/styles/material.css +36 -0
- package/styles/tailwind-dark.css +36 -0
- package/styles/tailwind.css +36 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Browser, Event, EventHandler, L10n, NotifyPropertyChanges, Property, addClass, compile, extend, getComponent, getInstance, getUniqueID, isNullOrUndefined, removeClass } from '@syncfusion/ej2-base';
|
|
2
|
-
import { ColorPicker, SignatureBase, Uploader } from '@syncfusion/ej2-inputs';
|
|
1
|
+
import { Browser, ChildProperty, Complex, Event, EventHandler, L10n, NotifyPropertyChanges, Property, addClass, compile, detach, extend, getComponent, getInstance, getUniqueID, isNullOrUndefined, removeClass, select } from '@syncfusion/ej2-base';
|
|
2
|
+
import { ColorPicker, SignatureBase, Slider, Uploader } from '@syncfusion/ej2-inputs';
|
|
3
3
|
import { Toolbar } from '@syncfusion/ej2-navigations';
|
|
4
4
|
import { DropDownButton } from '@syncfusion/ej2-splitbuttons';
|
|
5
5
|
import { createSpinner, hideSpinner, showSpinner } from '@syncfusion/ej2-popups';
|
|
@@ -11,6 +11,32 @@ var __decorate = (undefined && undefined.__decorate) || function (decorators, ta
|
|
|
11
11
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
12
12
|
};
|
|
13
13
|
var ImageEditor_1;
|
|
14
|
+
/**
|
|
15
|
+
* Interface for image finetune values.
|
|
16
|
+
*/
|
|
17
|
+
class FinetuneSettings extends ChildProperty {
|
|
18
|
+
}
|
|
19
|
+
__decorate([
|
|
20
|
+
Property(null)
|
|
21
|
+
], FinetuneSettings.prototype, "brightness", void 0);
|
|
22
|
+
__decorate([
|
|
23
|
+
Property(null)
|
|
24
|
+
], FinetuneSettings.prototype, "contrast", void 0);
|
|
25
|
+
__decorate([
|
|
26
|
+
Property(null)
|
|
27
|
+
], FinetuneSettings.prototype, "hue", void 0);
|
|
28
|
+
__decorate([
|
|
29
|
+
Property(null)
|
|
30
|
+
], FinetuneSettings.prototype, "saturation", void 0);
|
|
31
|
+
__decorate([
|
|
32
|
+
Property(null)
|
|
33
|
+
], FinetuneSettings.prototype, "exposure", void 0);
|
|
34
|
+
__decorate([
|
|
35
|
+
Property(null)
|
|
36
|
+
], FinetuneSettings.prototype, "opacity", void 0);
|
|
37
|
+
__decorate([
|
|
38
|
+
Property(null)
|
|
39
|
+
], FinetuneSettings.prototype, "blur", void 0);
|
|
14
40
|
/**
|
|
15
41
|
* Image Editor is a graphical user interface that helps to edit an image by performing actions like selection,
|
|
16
42
|
* cropping, rotating, inserting text and shapes (rectangles, ellipses, lines), and drawing free hand on top of an image.
|
|
@@ -36,7 +62,6 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
36
62
|
constructor(options, element) {
|
|
37
63
|
super(options, element);
|
|
38
64
|
this.degree = 0; // current rotated state
|
|
39
|
-
this.isUndoRedo = false;
|
|
40
65
|
this.dragCanvas = false;
|
|
41
66
|
this.dragElement = '';
|
|
42
67
|
this.keyHistory = ''; // text history
|
|
@@ -57,24 +82,18 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
57
82
|
this.pannStart = {};
|
|
58
83
|
this.pannEnd = {};
|
|
59
84
|
this.togglePan = false;
|
|
85
|
+
this.disablePan = false;
|
|
60
86
|
this.lastX = 0;
|
|
61
87
|
this.lastY = 0;
|
|
62
88
|
this.dragStart = { x: 0, y: 0 };
|
|
63
|
-
this.dragged = false;
|
|
64
89
|
this.factor = 1; // current zoomed state
|
|
65
90
|
this.currFlipState = '';
|
|
66
91
|
this.touchEndPoint = {};
|
|
67
|
-
this.flipMethod = false;
|
|
68
|
-
this.flipDirection = '';
|
|
69
92
|
this.prevX = 0;
|
|
70
93
|
this.currX = 0;
|
|
71
94
|
this.prevY = 0;
|
|
72
95
|
this.currY = 0;
|
|
73
96
|
this.togglePen = false;
|
|
74
|
-
this.rotateMethod = false;
|
|
75
|
-
this.isBoldbtn = false;
|
|
76
|
-
this.isItalicbtn = false;
|
|
77
|
-
this.lastAction = '';
|
|
78
97
|
this.currentToolbar = 'main';
|
|
79
98
|
this.textStartPoints = { x: 0, y: 0 };
|
|
80
99
|
this.fontSizeColl = [];
|
|
@@ -85,11 +104,29 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
85
104
|
this.activeObj = { activePoint: { startX: 0, startY: 0, endX: 0, endY: 0, width: 0, height: 0 },
|
|
86
105
|
flipObjColl: [] };
|
|
87
106
|
this.currObjType = { shape: '', isDragging: false, isActiveObj: false, isText: false, isInitialText: false, isLine: false,
|
|
88
|
-
isInitialLine: false, isCustomCrop: false, isZoomed: false };
|
|
107
|
+
isInitialLine: false, isCustomCrop: false, isZoomed: false, isFiltered: false, isSave: false };
|
|
89
108
|
this.defToolbarItems = [];
|
|
90
|
-
this.baseImgSrc =
|
|
109
|
+
this.baseImgSrc = {};
|
|
91
110
|
this.isTimer = false;
|
|
92
111
|
this.isScreenOriented = false;
|
|
112
|
+
this.isFirstMove = false;
|
|
113
|
+
this.startTouches = [];
|
|
114
|
+
this.tempTouches = [];
|
|
115
|
+
this.adjustmentLevel = { brightness: 0, contrast: 0, hue: 0, opacity: 100, saturation: 0, blur: 0,
|
|
116
|
+
exposure: 0, sharpen: false, bw: false };
|
|
117
|
+
this.tempAdjustmentLevel = { brightness: 0, contrast: 0, hue: 0, opacity: 100, saturation: 0, blur: 0,
|
|
118
|
+
exposure: 0, sharpen: false, bw: false };
|
|
119
|
+
this.adjustmentValue = '';
|
|
120
|
+
this.initialAdjustmentValue = '';
|
|
121
|
+
this.tempAdjustmentValue = '';
|
|
122
|
+
this.currentFilter = '';
|
|
123
|
+
this.tempFilter = '';
|
|
124
|
+
this.canvasFilter = '';
|
|
125
|
+
this.sharpenedImgData = false;
|
|
126
|
+
this.tempSharpenFilter = false;
|
|
127
|
+
this.tempBWFilter = false;
|
|
128
|
+
this.isBrightnessAdjusted = false;
|
|
129
|
+
this.isInitialLoading = false;
|
|
93
130
|
}
|
|
94
131
|
preRender() {
|
|
95
132
|
// pre render code snippets
|
|
@@ -117,8 +154,28 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
117
154
|
Crop: 'Crop',
|
|
118
155
|
ZoomIn: 'Zoom In',
|
|
119
156
|
ZoomOut: 'Zoom Out',
|
|
157
|
+
Undo: 'Undo',
|
|
158
|
+
Redo: 'Redo',
|
|
120
159
|
Transform: 'Transform',
|
|
121
160
|
Annotation: 'Annotation',
|
|
161
|
+
Finetune: 'Finetune',
|
|
162
|
+
Brightness: 'Brightness',
|
|
163
|
+
Contrast: 'Contrast',
|
|
164
|
+
Hue: 'Hue',
|
|
165
|
+
Saturation: 'Saturation',
|
|
166
|
+
Opacity: 'Opacity',
|
|
167
|
+
Blur: 'Blur',
|
|
168
|
+
Sharpen: 'Sharpen',
|
|
169
|
+
Exposure: 'Exposure',
|
|
170
|
+
Filter: 'Filter',
|
|
171
|
+
Default: 'Default',
|
|
172
|
+
Chrome: 'Chrome',
|
|
173
|
+
Cold: 'Cold',
|
|
174
|
+
Warm: 'Warm',
|
|
175
|
+
Grayscale: 'Grayscale',
|
|
176
|
+
BlackAndWhite: 'Black and White',
|
|
177
|
+
Sepia: 'Sepia',
|
|
178
|
+
Invert: 'Invert',
|
|
122
179
|
Text: 'Add Text',
|
|
123
180
|
Pen: 'Pen',
|
|
124
181
|
Reset: 'Reset',
|
|
@@ -146,7 +203,6 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
146
203
|
Ellipse: 'Ellipse',
|
|
147
204
|
Rectangle: 'Rectangle',
|
|
148
205
|
Line: 'Line',
|
|
149
|
-
Default: 'Default',
|
|
150
206
|
Bold: 'Bold',
|
|
151
207
|
Italic: 'Italic',
|
|
152
208
|
BoldItalic: 'Bold Italic',
|
|
@@ -155,7 +211,8 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
155
211
|
Medium: 'Medium',
|
|
156
212
|
Large: 'Large',
|
|
157
213
|
XLarge: 'X-Large',
|
|
158
|
-
ABC: 'ABC'
|
|
214
|
+
ABC: 'ABC',
|
|
215
|
+
Browse: 'Browse'
|
|
159
216
|
};
|
|
160
217
|
this.l10n = new L10n('image-editor', this.defaultLocale, this.locale);
|
|
161
218
|
}
|
|
@@ -231,6 +288,12 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
231
288
|
this.upperContext.fillStyle = this.themeColl[this.theme]['secondaryColor'];
|
|
232
289
|
}
|
|
233
290
|
break;
|
|
291
|
+
case 'finetuneSettings':
|
|
292
|
+
if (newProperties.finetuneSettings) {
|
|
293
|
+
this.finetuneSettings = newProperties.finetuneSettings;
|
|
294
|
+
this.updateFinetunes();
|
|
295
|
+
}
|
|
296
|
+
break;
|
|
234
297
|
}
|
|
235
298
|
}
|
|
236
299
|
}
|
|
@@ -244,19 +307,24 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
244
307
|
if (!this.element.getAttribute('class')) {
|
|
245
308
|
this.element.removeAttribute('class');
|
|
246
309
|
}
|
|
310
|
+
this.destroySubComponents();
|
|
247
311
|
this.unwireEvent();
|
|
248
312
|
super.destroy();
|
|
249
313
|
this.element.innerHTML = '';
|
|
250
314
|
this.trigger('destroyed');
|
|
251
315
|
}
|
|
252
316
|
initialize() {
|
|
317
|
+
this.updateFinetunes();
|
|
253
318
|
this.createToolbar();
|
|
319
|
+
this.createContextualToolbar();
|
|
254
320
|
this.createCanvas();
|
|
255
321
|
this.wireEvent();
|
|
256
322
|
this.updateContext(this.lowerContext);
|
|
257
323
|
this.updateContext(this.upperContext);
|
|
258
324
|
this.pannStart = { startX: 0, startY: 0, width: 0, height: 0 };
|
|
259
325
|
this.pannEnd = { startX: 0, startY: 0, width: 0, height: 0 };
|
|
326
|
+
this.lowerContext.filter = this.canvasFilter = this.initialAdjustmentValue = this.adjustmentValue = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
|
|
327
|
+
'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
|
|
260
328
|
if (this.cssClass) {
|
|
261
329
|
addClass([this.element], this.cssClass.split(' '));
|
|
262
330
|
}
|
|
@@ -266,6 +334,39 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
266
334
|
});
|
|
267
335
|
}
|
|
268
336
|
}
|
|
337
|
+
updateFinetunes() {
|
|
338
|
+
if (this.finetuneSettings) {
|
|
339
|
+
if (this.finetuneSettings.brightness) {
|
|
340
|
+
this.adjustmentLevel.brightness = this.finetuneSettings.brightness.defaultValue;
|
|
341
|
+
this.tempAdjustmentLevel.brightness = this.finetuneSettings.brightness.defaultValue;
|
|
342
|
+
}
|
|
343
|
+
if (this.finetuneSettings.contrast) {
|
|
344
|
+
this.adjustmentLevel.contrast = this.finetuneSettings.contrast.defaultValue;
|
|
345
|
+
this.tempAdjustmentLevel.contrast = this.finetuneSettings.contrast.defaultValue;
|
|
346
|
+
}
|
|
347
|
+
if (this.finetuneSettings.hue) {
|
|
348
|
+
this.adjustmentLevel.hue = this.finetuneSettings.hue.defaultValue;
|
|
349
|
+
this.tempAdjustmentLevel.hue = this.finetuneSettings.hue.defaultValue;
|
|
350
|
+
}
|
|
351
|
+
if (this.finetuneSettings.saturation) {
|
|
352
|
+
this.adjustmentLevel.saturation = this.finetuneSettings.saturation.defaultValue;
|
|
353
|
+
this.tempAdjustmentLevel.saturation = this.finetuneSettings.saturation.defaultValue;
|
|
354
|
+
}
|
|
355
|
+
if (this.finetuneSettings.exposure) {
|
|
356
|
+
this.adjustmentLevel.exposure = this.finetuneSettings.exposure.defaultValue;
|
|
357
|
+
this.tempAdjustmentLevel.exposure = this.finetuneSettings.exposure.defaultValue;
|
|
358
|
+
}
|
|
359
|
+
if (this.finetuneSettings.opacity) {
|
|
360
|
+
this.adjustmentLevel.opacity = this.finetuneSettings.opacity.defaultValue;
|
|
361
|
+
this.tempAdjustmentLevel.opacity = this.finetuneSettings.opacity.defaultValue;
|
|
362
|
+
}
|
|
363
|
+
if (this.finetuneSettings.blur) {
|
|
364
|
+
this.adjustmentLevel.blur = this.finetuneSettings.blur.defaultValue;
|
|
365
|
+
this.tempAdjustmentLevel.blur = this.finetuneSettings.blur.defaultValue;
|
|
366
|
+
}
|
|
367
|
+
this.isInitialLoading = true;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
269
370
|
/**
|
|
270
371
|
*
|
|
271
372
|
* This Method will add events to component (element, event, method, current reference)
|
|
@@ -288,7 +389,7 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
288
389
|
EventHandler.add(this.upperCanvas, 'dblclick', this.findTextPoint, this);
|
|
289
390
|
EventHandler.add(this.textBox, 'mousedown', this.findTextPoint, this);
|
|
290
391
|
window.addEventListener('resize', this.windowResizeHandler.bind(this));
|
|
291
|
-
if (
|
|
392
|
+
if (!Browser.isIos && Browser.info.name !== 'safari' && screen && screen.orientation) {
|
|
292
393
|
screen.orientation.addEventListener('change', this.screenOrientation.bind(this));
|
|
293
394
|
}
|
|
294
395
|
}
|
|
@@ -310,6 +411,35 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
310
411
|
EventHandler.remove(this.lowerCanvas, 'mouseup', this.canvasMouseUpHandler);
|
|
311
412
|
EventHandler.remove(document, 'mouseup', this.canvasMouseUpHandler);
|
|
312
413
|
}
|
|
414
|
+
initializeFilter() {
|
|
415
|
+
this.setBrightness(this.adjustmentLevel.brightness);
|
|
416
|
+
this.setContrast(this.adjustmentLevel.contrast);
|
|
417
|
+
this.setHue(this.adjustmentLevel.hue);
|
|
418
|
+
this.setSaturation(this.adjustmentLevel.saturation);
|
|
419
|
+
this.setExposure(this.adjustmentLevel.exposure);
|
|
420
|
+
this.setOpacity(this.adjustmentLevel.opacity);
|
|
421
|
+
this.setBlur(this.adjustmentLevel.blur);
|
|
422
|
+
}
|
|
423
|
+
destroySubComponents() {
|
|
424
|
+
const inputElement = this.element.querySelectorAll('input.e-control');
|
|
425
|
+
const btnElement = this.element.querySelectorAll('button.e-control');
|
|
426
|
+
for (let i = 0, len = inputElement.length; i < len; i++) {
|
|
427
|
+
if (inputElement[i].classList.contains('e-color-picker')) {
|
|
428
|
+
getComponent(inputElement[i], 'color-picker').destroy();
|
|
429
|
+
detach(select('input#' + inputElement[i].id, this.element));
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
for (let i = 0, len = btnElement.length; i < len; i++) {
|
|
433
|
+
if (btnElement[i].classList.contains('e-dropdown-btn')) {
|
|
434
|
+
getComponent(btnElement[i], 'dropdown-btn').destroy();
|
|
435
|
+
detach(select('button#' + btnElement[i].id, this.element));
|
|
436
|
+
}
|
|
437
|
+
else if (btnElement[i].classList.contains('e-btn')) {
|
|
438
|
+
getComponent(btnElement[i], 'btn').destroy();
|
|
439
|
+
detach(select('button#' + btnElement[i].id, this.element));
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
}
|
|
313
443
|
updateTheme() {
|
|
314
444
|
if (this.theme !== '') {
|
|
315
445
|
this.theme = this.toPascalCase(this.theme);
|
|
@@ -421,6 +551,58 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
421
551
|
this.toolbarHeight = 0;
|
|
422
552
|
}
|
|
423
553
|
}
|
|
554
|
+
createContextualToolbar() {
|
|
555
|
+
if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.length > 0)) {
|
|
556
|
+
this.element.appendChild(this.createElement('div', { id: this.element.id + '_contextualToolbarArea',
|
|
557
|
+
className: 'e-contextual-toolbar-wrapper e-hide', attrs: { style: 'position: absolute;' }
|
|
558
|
+
}));
|
|
559
|
+
const toolbarArea = document.getElementById(this.element.id + '_contextualToolbarArea');
|
|
560
|
+
const toolbar = this.createElement('div', { id: this.element.id + '_contextualToolbar' });
|
|
561
|
+
toolbarArea.appendChild(toolbar);
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
updateContextualToolbar(type, cType) {
|
|
565
|
+
if (this.toolbarTemplate) {
|
|
566
|
+
this.toolbarTemplateFn();
|
|
567
|
+
}
|
|
568
|
+
else {
|
|
569
|
+
const toolbarArea = this.element.querySelector('#' + this.element.id + '_toolbarArea');
|
|
570
|
+
const contextualToolbarArea = this.element.querySelector('#' + this.element.id + '_contextualToolbarArea');
|
|
571
|
+
if (!isNullOrUndefined(toolbarArea) && !isNullOrUndefined(contextualToolbarArea)) {
|
|
572
|
+
contextualToolbarArea.classList.remove('e-hide');
|
|
573
|
+
contextualToolbarArea.style.left = toolbarArea.offsetLeft + 'px';
|
|
574
|
+
}
|
|
575
|
+
if (type === 'filter') {
|
|
576
|
+
if (!isNullOrUndefined(document.getElementById(this.element.id + '_toolbar')) && this.defToolbarItems.length > 0) {
|
|
577
|
+
getComponent(document.getElementById(this.element.id + '_toolbar'), 'toolbar').destroy();
|
|
578
|
+
}
|
|
579
|
+
if (Browser.isDevice) {
|
|
580
|
+
this.initToolbarItem(false, true, true);
|
|
581
|
+
}
|
|
582
|
+
else {
|
|
583
|
+
this.initToolbarItem(true);
|
|
584
|
+
}
|
|
585
|
+
this.refreshSlider();
|
|
586
|
+
this.initFilterToolbarItem();
|
|
587
|
+
}
|
|
588
|
+
else {
|
|
589
|
+
if (!isNullOrUndefined(document.querySelector('#' + this.element.id + '_contextualToolbar'))
|
|
590
|
+
&& document.querySelector('#' + this.element.id + '_contextualToolbar').classList.contains('e-control')) {
|
|
591
|
+
getComponent(document.getElementById(this.element.id + '_contextualToolbar'), 'toolbar').destroy();
|
|
592
|
+
}
|
|
593
|
+
this.refreshSlider();
|
|
594
|
+
this.renderSlider(cType);
|
|
595
|
+
}
|
|
596
|
+
if (Browser.isDevice) {
|
|
597
|
+
const cHt = contextualToolbarArea.offsetHeight;
|
|
598
|
+
const ht = this.element.querySelector('#' + this.element.id + '_canvasWrapper').offsetHeight;
|
|
599
|
+
contextualToolbarArea.style.top = this.toolbarHeight + ht - cHt + 'px';
|
|
600
|
+
}
|
|
601
|
+
else {
|
|
602
|
+
contextualToolbarArea.style.top = this.toolbarHeight + 1 + 'px';
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
}
|
|
424
606
|
createBottomToolbar() {
|
|
425
607
|
if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.length > 0)) {
|
|
426
608
|
this.element.appendChild(this.createElement('div', {
|
|
@@ -560,6 +742,14 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
560
742
|
template: '<button id="' + this.element.id + '_transformBtn"></button>'
|
|
561
743
|
});
|
|
562
744
|
}
|
|
745
|
+
if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Finetune') > -1)) {
|
|
746
|
+
toolbarItems.push({ id: this.element.id + '_adjustment', prefixIcon: 'e-icons e-adjustment', cssClass: 'top-icon e-adjustment',
|
|
747
|
+
tooltipText: this.l10n.getConstant('Finetune'), align: 'Center' });
|
|
748
|
+
}
|
|
749
|
+
if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Filter') > -1)) {
|
|
750
|
+
toolbarItems.push({ id: this.element.id + '_filter', prefixIcon: 'e-icons e-filters', cssClass: 'top-icon e-filters',
|
|
751
|
+
tooltipText: this.l10n.getConstant('Filter'), align: 'Center' });
|
|
752
|
+
}
|
|
563
753
|
const tempToolbarItems = this.processToolbar('center');
|
|
564
754
|
for (let i = 0, len = tempToolbarItems.length; i < len; i++) {
|
|
565
755
|
toolbarItems.push(tempToolbarItems[i]);
|
|
@@ -762,7 +952,7 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
762
952
|
items.push({ text: this.l10n.getConstant('Custom'), id: 'custom', iconCss: 'e-icons e-custom' });
|
|
763
953
|
}
|
|
764
954
|
if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('CircleSelection') > -1)) {
|
|
765
|
-
items.push({ text: this.l10n.getConstant('Circle'), id: '
|
|
955
|
+
items.push({ text: this.l10n.getConstant('Circle'), id: 'circle', iconCss: 'e-icons e-circle' });
|
|
766
956
|
}
|
|
767
957
|
if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('SquareSelection') > -1)) {
|
|
768
958
|
items.push({ text: this.l10n.getConstant('Square'), id: 'square', iconCss: 'e-icons e-square' });
|
|
@@ -843,7 +1033,7 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
843
1033
|
}
|
|
844
1034
|
}
|
|
845
1035
|
cropSelect(args) {
|
|
846
|
-
const text = args.item.
|
|
1036
|
+
const text = args.item.id;
|
|
847
1037
|
this.select(text);
|
|
848
1038
|
this.refreshToolbar('main', true, true);
|
|
849
1039
|
}
|
|
@@ -947,9 +1137,16 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
947
1137
|
modeSwitcher: false, noColor: true, value: '',
|
|
948
1138
|
showButtons: false, mode: 'Palette', cssClass: 'e-shape-fill-color',
|
|
949
1139
|
change: (args) => {
|
|
1140
|
+
this.pushActItemIntoObj();
|
|
1141
|
+
const objColl = extend([], this.objColl, [], true);
|
|
1142
|
+
this.objColl.pop();
|
|
950
1143
|
proxy.activeObj.strokeSettings.fillColor = args.currentValue.hex;
|
|
951
1144
|
proxy.strokeSettings.fillColor = proxy.activeObj.strokeSettings.fillColor;
|
|
952
|
-
|
|
1145
|
+
this.objColl.push(this.activeObj);
|
|
1146
|
+
proxy.undoRedoColl.push({ operation: 'shapeTransform', value: null,
|
|
1147
|
+
currentObj: extend([], proxy.objColl, [], true), previousObj: objColl, factor: proxy.factor,
|
|
1148
|
+
sharpen: proxy.adjustmentLevel.sharpen, bw: proxy.adjustmentLevel.bw });
|
|
1149
|
+
proxy.redrawShape(proxy.objColl[proxy.objColl.length - 1]);
|
|
953
1150
|
if (args.currentValue.rgba === '') {
|
|
954
1151
|
fillDDB.element.children[0].classList.add('e-nocolor-item');
|
|
955
1152
|
}
|
|
@@ -982,10 +1179,17 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
982
1179
|
modeSwitcher: false, noColor: false, value: '#fff',
|
|
983
1180
|
showButtons: false, mode: 'Palette', cssClass: 'e-shape-stroke-color',
|
|
984
1181
|
change: (args) => {
|
|
1182
|
+
this.pushActItemIntoObj();
|
|
1183
|
+
const objColl = extend([], this.objColl, [], true);
|
|
1184
|
+
this.objColl.pop();
|
|
985
1185
|
proxy.activeObj.strokeSettings.strokeColor = args.currentValue.hex;
|
|
986
1186
|
proxy.strokeSettings.strokeColor = proxy.activeObj.strokeSettings.strokeColor;
|
|
987
1187
|
if (!proxy.togglePen) {
|
|
988
|
-
|
|
1188
|
+
this.objColl.push(this.activeObj);
|
|
1189
|
+
proxy.undoRedoColl.push({ operation: 'shapeTransform', value: null,
|
|
1190
|
+
currentObj: extend([], proxy.objColl, [], true), previousObj: objColl, factor: proxy.factor,
|
|
1191
|
+
sharpen: proxy.adjustmentLevel.sharpen, bw: proxy.adjustmentLevel.bw });
|
|
1192
|
+
proxy.redrawShape(proxy.objColl[proxy.objColl.length - 1]);
|
|
989
1193
|
}
|
|
990
1194
|
strokeDDB.element.children[0].style.backgroundColor = args.currentValue.rgba;
|
|
991
1195
|
strokeDDB.toggle();
|
|
@@ -1029,9 +1233,14 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
1029
1233
|
args.element.parentElement.offsetHeight + 'px';
|
|
1030
1234
|
}
|
|
1031
1235
|
const activeBtn = spanElem.innerHTML;
|
|
1032
|
-
|
|
1236
|
+
if (activeBtn !== '') {
|
|
1237
|
+
args.element.querySelector('[aria-label = ' + '"' + activeBtn + '"' + ']').classList.add('e-selected-btn');
|
|
1238
|
+
}
|
|
1033
1239
|
},
|
|
1034
1240
|
select: (args) => {
|
|
1241
|
+
this.pushActItemIntoObj();
|
|
1242
|
+
const objColl = extend([], this.objColl, [], true);
|
|
1243
|
+
this.objColl.pop();
|
|
1035
1244
|
spanElem.textContent = args.item.text;
|
|
1036
1245
|
this.activeObj.strokeSettings.strokeWidth = parseInt(args.item.id, 10);
|
|
1037
1246
|
if (this.lowerCanvas.width > this.lowerCanvas.height) {
|
|
@@ -1041,7 +1250,11 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
1041
1250
|
this.activeObj.strokeSettings.strokeWidth *= ((ratio.height + ratio.width) / this.factor);
|
|
1042
1251
|
}
|
|
1043
1252
|
this.strokeSettings.strokeWidth = this.activeObj.strokeSettings.strokeWidth;
|
|
1044
|
-
this.
|
|
1253
|
+
this.objColl.push(this.activeObj);
|
|
1254
|
+
this.undoRedoColl.push({ operation: 'shapeTransform', value: null,
|
|
1255
|
+
currentObj: extend([], this.objColl, [], true), previousObj: objColl, factor: this.factor,
|
|
1256
|
+
sharpen: this.adjustmentLevel.sharpen, bw: this.adjustmentLevel.bw });
|
|
1257
|
+
this.redrawShape(this.objColl[this.objColl.length - 1]);
|
|
1045
1258
|
if (Browser.isDevice) {
|
|
1046
1259
|
if (!isNullOrUndefined(document.getElementById(this.element.id + '_bottomToolbar'))) {
|
|
1047
1260
|
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
@@ -1167,17 +1380,26 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
1167
1380
|
modeSwitcher: false, value: '#fff',
|
|
1168
1381
|
showButtons: false, mode: 'Palette', cssClass: 'e-text-fontt-color',
|
|
1169
1382
|
change: (args) => {
|
|
1383
|
+
this.pushActItemIntoObj();
|
|
1384
|
+
this.objColl.pop();
|
|
1170
1385
|
if (proxy.textBox.style.display === 'none') {
|
|
1171
1386
|
proxy.strokeSettings.strokeColor = proxy.activeObj.strokeSettings.strokeColor = args.currentValue.hex;
|
|
1172
1387
|
if (!proxy.togglePen) {
|
|
1173
|
-
|
|
1388
|
+
this.objColl.push(this.activeObj);
|
|
1389
|
+
proxy.redrawShape(proxy.objColl[proxy.objColl.length - 1]);
|
|
1174
1390
|
}
|
|
1175
1391
|
}
|
|
1176
1392
|
else if (proxy.textBox.style.display === 'block') {
|
|
1177
1393
|
proxy.textBox.style.color = args.currentValue.hex;
|
|
1394
|
+
const temp = proxy.activeObj.strokeSettings.strokeColor;
|
|
1395
|
+
proxy.activeObj.strokeSettings.strokeColor = args.currentValue.hex;
|
|
1396
|
+
this.objColl.push(this.activeObj);
|
|
1397
|
+
this.objColl.pop();
|
|
1398
|
+
proxy.activeObj.strokeSettings.strokeColor = temp;
|
|
1178
1399
|
}
|
|
1179
1400
|
else if (!proxy.togglePen) {
|
|
1180
|
-
|
|
1401
|
+
this.objColl.push(this.activeObj);
|
|
1402
|
+
proxy.redrawShape(proxy.objColl[proxy.objColl.length - 1]);
|
|
1181
1403
|
}
|
|
1182
1404
|
strokeDDB.element.children[0].style.backgroundColor = args.currentValue.rgba;
|
|
1183
1405
|
strokeDDB.toggle();
|
|
@@ -1199,6 +1421,17 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
1199
1421
|
= '#fff';
|
|
1200
1422
|
}
|
|
1201
1423
|
}
|
|
1424
|
+
pushActItemIntoObj() {
|
|
1425
|
+
if (this.textBox.style.display === 'none') {
|
|
1426
|
+
this.objColl.push(this.activeObj);
|
|
1427
|
+
}
|
|
1428
|
+
else {
|
|
1429
|
+
const temp = extend({}, this.activeObj, {}, true);
|
|
1430
|
+
this.setTextBoxStylesToActObj();
|
|
1431
|
+
this.objColl.push(this.activeObj);
|
|
1432
|
+
this.activeObj = temp;
|
|
1433
|
+
}
|
|
1434
|
+
}
|
|
1202
1435
|
createTextBtn(items) {
|
|
1203
1436
|
const ratio = this.calcRatio();
|
|
1204
1437
|
if (items.indexOf('fontFamily') > -1) {
|
|
@@ -1235,6 +1468,8 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
1235
1468
|
+ '"' + ']').classList.add('e-selected-btn');
|
|
1236
1469
|
},
|
|
1237
1470
|
select: (args) => {
|
|
1471
|
+
this.pushActItemIntoObj();
|
|
1472
|
+
this.objColl.pop();
|
|
1238
1473
|
spanElem.textContent = args.item.text;
|
|
1239
1474
|
if (Browser.isDevice) {
|
|
1240
1475
|
spanElem.setAttribute('style', 'font-family:' + args.item.id);
|
|
@@ -1242,10 +1477,13 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
1242
1477
|
if (this.textBox.style.display === 'block') {
|
|
1243
1478
|
const temp = this.activeObj.textSettings.fontFamily;
|
|
1244
1479
|
this.activeObj.textSettings.fontFamily = this.toPascalCase(args.item.id);
|
|
1245
|
-
this.
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
this.
|
|
1480
|
+
this.redrawText(ratio);
|
|
1481
|
+
this.objColl.push(this.activeObj);
|
|
1482
|
+
this.objColl.pop();
|
|
1483
|
+
this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
|
|
1484
|
+
const width = this.activeObj.activePoint.width +
|
|
1485
|
+
this.activeObj.textSettings.fontSize * 0.25;
|
|
1486
|
+
this.textBox.style.width = width / ratio.width + 'px';
|
|
1249
1487
|
this.textBox.style.fontFamily = this.toPascalCase(args.item.id);
|
|
1250
1488
|
this.activeObj.textSettings.fontFamily = temp;
|
|
1251
1489
|
this.updateFontStyles();
|
|
@@ -1253,7 +1491,8 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
1253
1491
|
else {
|
|
1254
1492
|
this.textSettings.fontFamily = this.activeObj.textSettings.fontFamily = this.toPascalCase(args.item.id);
|
|
1255
1493
|
this.redrawText(ratio);
|
|
1256
|
-
this.
|
|
1494
|
+
this.objColl.push(this.activeObj);
|
|
1495
|
+
this.redrawShape(this.objColl[this.objColl.length - 1]);
|
|
1257
1496
|
}
|
|
1258
1497
|
}
|
|
1259
1498
|
});
|
|
@@ -1352,10 +1591,14 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
1352
1591
|
args.element.querySelector('[aria-label *= ' + '"' + activeBtn + '"' + ']').classList.add('e-selected-btn');
|
|
1353
1592
|
},
|
|
1354
1593
|
select: (args) => {
|
|
1594
|
+
this.pushActItemIntoObj();
|
|
1595
|
+
this.objColl.pop();
|
|
1355
1596
|
fontSizeSpanElem.textContent = args.item.text;
|
|
1356
1597
|
if (this.textBox.style.display === 'block') {
|
|
1357
1598
|
const temp = this.activeObj.textSettings.fontSize;
|
|
1358
1599
|
this.activeObj.textSettings.fontSize = parseInt(this.fontSizeColl[(parseInt(args.item.text, 10) - 1)].text, 10);
|
|
1600
|
+
this.objColl.push(this.activeObj);
|
|
1601
|
+
this.objColl.pop();
|
|
1359
1602
|
let textStyle = '';
|
|
1360
1603
|
if (this.textBox.style.fontWeight === 'bold') {
|
|
1361
1604
|
textStyle = 'bold ';
|
|
@@ -1387,11 +1630,13 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
1387
1630
|
const text = this.getMaxText();
|
|
1388
1631
|
const width = this.upperContext.measureText(text).width +
|
|
1389
1632
|
this.activeObj.textSettings.fontSize * 0.5;
|
|
1390
|
-
const height = rows.length * (this.activeObj.textSettings.fontSize +
|
|
1633
|
+
const height = rows.length * (this.activeObj.textSettings.fontSize +
|
|
1634
|
+
this.activeObj.textSettings.fontSize * 0.25);
|
|
1391
1635
|
this.setTextSelection(width, height);
|
|
1392
1636
|
this.updateActiveObject(ratio, this.activeObj.activePoint, this.activeObj);
|
|
1393
|
-
this.redrawShape(this.activeObj);
|
|
1394
1637
|
this.redrawText(ratio);
|
|
1638
|
+
this.objColl.push(this.activeObj);
|
|
1639
|
+
this.redrawShape(this.objColl[this.objColl.length - 1]);
|
|
1395
1640
|
}
|
|
1396
1641
|
}
|
|
1397
1642
|
});
|
|
@@ -1442,14 +1687,43 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
1442
1687
|
this.activeObj.textSettings.italic = tempItalic;
|
|
1443
1688
|
return width;
|
|
1444
1689
|
}
|
|
1690
|
+
updateObjColl(item) {
|
|
1691
|
+
const tempBold = this.activeObj.textSettings.bold;
|
|
1692
|
+
const tempItalic = this.activeObj.textSettings.italic;
|
|
1693
|
+
switch (item) {
|
|
1694
|
+
case 'default':
|
|
1695
|
+
this.activeObj.textSettings.bold = false;
|
|
1696
|
+
this.activeObj.textSettings.italic = false;
|
|
1697
|
+
break;
|
|
1698
|
+
case 'bold':
|
|
1699
|
+
this.activeObj.textSettings.bold = true;
|
|
1700
|
+
this.activeObj.textSettings.italic = false;
|
|
1701
|
+
break;
|
|
1702
|
+
case 'italic':
|
|
1703
|
+
this.activeObj.textSettings.bold = false;
|
|
1704
|
+
this.activeObj.textSettings.italic = true;
|
|
1705
|
+
break;
|
|
1706
|
+
case 'bolditalic':
|
|
1707
|
+
this.activeObj.textSettings.bold = true;
|
|
1708
|
+
this.activeObj.textSettings.italic = true;
|
|
1709
|
+
break;
|
|
1710
|
+
}
|
|
1711
|
+
this.objColl.push(this.activeObj);
|
|
1712
|
+
this.objColl.pop();
|
|
1713
|
+
this.activeObj.textSettings.bold = tempBold;
|
|
1714
|
+
this.activeObj.textSettings.italic = tempItalic;
|
|
1715
|
+
}
|
|
1445
1716
|
applyFontStyle(item, ratio) {
|
|
1717
|
+
this.pushActItemIntoObj();
|
|
1718
|
+
this.objColl.pop();
|
|
1446
1719
|
switch (item) {
|
|
1447
1720
|
case 'default':
|
|
1448
1721
|
if (this.textBox.style.display === 'block') {
|
|
1449
|
-
const width = this.getTextAreaWidth(item);
|
|
1450
|
-
this.textBox.style.width =
|
|
1722
|
+
const width = this.getTextAreaWidth(item) / ratio.width;
|
|
1723
|
+
this.textBox.style.width = width + 'px';
|
|
1451
1724
|
this.textBox.style.fontWeight = 'normal';
|
|
1452
1725
|
this.textBox.style.fontStyle = 'normal';
|
|
1726
|
+
this.updateObjColl(item);
|
|
1453
1727
|
}
|
|
1454
1728
|
else {
|
|
1455
1729
|
this.textSettings.bold = this.activeObj.textSettings.bold = false;
|
|
@@ -1459,10 +1733,11 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
1459
1733
|
break;
|
|
1460
1734
|
case 'bold':
|
|
1461
1735
|
if (this.textBox.style.display === 'block') {
|
|
1462
|
-
const width = this.getTextAreaWidth(item);
|
|
1463
|
-
this.textBox.style.width =
|
|
1736
|
+
const width = this.getTextAreaWidth(item) / ratio.width;
|
|
1737
|
+
this.textBox.style.width = width + 'px';
|
|
1464
1738
|
this.textBox.style.fontWeight = 'bold';
|
|
1465
1739
|
this.textBox.style.fontStyle = 'normal';
|
|
1740
|
+
this.updateObjColl(item);
|
|
1466
1741
|
}
|
|
1467
1742
|
else {
|
|
1468
1743
|
this.textSettings.bold = this.activeObj.textSettings.bold = true;
|
|
@@ -1472,10 +1747,11 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
1472
1747
|
break;
|
|
1473
1748
|
case 'italic':
|
|
1474
1749
|
if (this.textBox.style.display === 'block') {
|
|
1475
|
-
const width = this.getTextAreaWidth(item);
|
|
1476
|
-
this.textBox.style.width =
|
|
1750
|
+
const width = this.getTextAreaWidth(item) / ratio.width;
|
|
1751
|
+
this.textBox.style.width = width + 'px';
|
|
1477
1752
|
this.textBox.style.fontWeight = 'normal';
|
|
1478
1753
|
this.textBox.style.fontStyle = 'italic';
|
|
1754
|
+
this.updateObjColl(item);
|
|
1479
1755
|
}
|
|
1480
1756
|
else {
|
|
1481
1757
|
this.textSettings.bold = this.activeObj.textSettings.bold = false;
|
|
@@ -1485,10 +1761,11 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
1485
1761
|
break;
|
|
1486
1762
|
case 'bolditalic':
|
|
1487
1763
|
if (this.textBox.style.display === 'block') {
|
|
1488
|
-
const width = this.getTextAreaWidth(item);
|
|
1489
|
-
this.textBox.style.width =
|
|
1764
|
+
const width = this.getTextAreaWidth(item) / ratio.width;
|
|
1765
|
+
this.textBox.style.width = width + 'px';
|
|
1490
1766
|
this.textBox.style.fontWeight = 'bold';
|
|
1491
1767
|
this.textBox.style.fontStyle = 'italic';
|
|
1768
|
+
this.updateObjColl(item);
|
|
1492
1769
|
}
|
|
1493
1770
|
else {
|
|
1494
1771
|
this.textSettings.bold = this.activeObj.textSettings.bold = true;
|
|
@@ -1519,8 +1796,21 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
1519
1796
|
toolbar.refreshOverflow();
|
|
1520
1797
|
}
|
|
1521
1798
|
}
|
|
1799
|
+
contextualToolbarClicked(args) {
|
|
1800
|
+
const selEle = this.element.querySelector('.e-contextual-toolbar-wrapper .e-toolbar-item.e-selected');
|
|
1801
|
+
if (selEle) {
|
|
1802
|
+
selEle.classList.remove('e-selected');
|
|
1803
|
+
}
|
|
1804
|
+
document.getElementById(args.item.id + 'Canvas').parentElement.parentElement.classList.add('e-selected');
|
|
1805
|
+
this.currObjType.isFiltered = true;
|
|
1806
|
+
const type = args.item.id.replace(this.element.id, '').split('_')[1];
|
|
1807
|
+
const imageFiltering = { filter: this.toPascalCase(type) };
|
|
1808
|
+
this.trigger('imageFiltering', imageFiltering);
|
|
1809
|
+
this.setFilter(type.toLowerCase());
|
|
1810
|
+
this.currentFilter = args.item.id;
|
|
1811
|
+
}
|
|
1522
1812
|
defToolbarClicked(args) {
|
|
1523
|
-
|
|
1813
|
+
this.element.querySelector('.e-contextual-toolbar-wrapper').classList.add('e-hide');
|
|
1524
1814
|
let zoomIn;
|
|
1525
1815
|
const type = args.item.id.replace(this.element.id + '_', '').toLowerCase();
|
|
1526
1816
|
const imageEditorObj = getInstance(document.getElementById(this.element.id), ImageEditor_1);
|
|
@@ -1539,61 +1829,23 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
1539
1829
|
if (!this.disabled) {
|
|
1540
1830
|
switch (type) {
|
|
1541
1831
|
case 'zoomin':
|
|
1832
|
+
this.currObjType.isFiltered = false;
|
|
1542
1833
|
if (this.togglePen) {
|
|
1543
1834
|
this.currObjType.isZoomed = true;
|
|
1544
1835
|
this.freeHandDraw(false);
|
|
1545
1836
|
}
|
|
1546
1837
|
imageEditorObj.zoom(.1);
|
|
1547
|
-
if (!this.togglePan) {
|
|
1548
|
-
this.callMainToolbar(false, true);
|
|
1549
|
-
}
|
|
1550
|
-
if (this.factor > 0.95 && this.factor < 1.05) {
|
|
1551
|
-
this.dragCanvas = this.togglePan = false;
|
|
1552
|
-
this.callMainToolbar(false, true);
|
|
1553
|
-
}
|
|
1554
|
-
if (isNullOrUndefined(this.activeObj.activePoint) || this.activeObj.activePoint.width === 0) {
|
|
1555
|
-
this.refreshToolbar('main');
|
|
1556
|
-
}
|
|
1557
|
-
else {
|
|
1558
|
-
this.refreshToolbar('main', true, true);
|
|
1559
|
-
}
|
|
1560
|
-
panBtn = this.element.querySelector('.e-img-pan .e-btn');
|
|
1561
|
-
if (!isNullOrUndefined(panBtn) && this.togglePan) {
|
|
1562
|
-
panBtn.classList.add('e-selected-btn');
|
|
1563
|
-
}
|
|
1564
|
-
else if (!isNullOrUndefined(panBtn)) {
|
|
1565
|
-
panBtn.classList.remove('e-selected-btn');
|
|
1566
|
-
}
|
|
1567
1838
|
break;
|
|
1568
1839
|
case 'zoomout':
|
|
1840
|
+
this.currObjType.isFiltered = false;
|
|
1569
1841
|
if (this.togglePen) {
|
|
1570
1842
|
this.currObjType.isZoomed = true;
|
|
1571
1843
|
this.freeHandDraw(false);
|
|
1572
1844
|
}
|
|
1573
1845
|
imageEditorObj.zoom(-.1);
|
|
1574
|
-
if (!this.togglePan) {
|
|
1575
|
-
this.callMainToolbar(false, true);
|
|
1576
|
-
}
|
|
1577
|
-
if (this.factor > 0.95 && this.factor < 1.05) {
|
|
1578
|
-
this.dragCanvas = this.togglePan = false;
|
|
1579
|
-
this.callMainToolbar(false, true);
|
|
1580
|
-
}
|
|
1581
|
-
if (isNullOrUndefined(this.activeObj.activePoint) || this.activeObj.activePoint.width === 0) {
|
|
1582
|
-
this.refreshToolbar('main');
|
|
1583
|
-
}
|
|
1584
|
-
else {
|
|
1585
|
-
this.refreshToolbar('main', true, true);
|
|
1586
|
-
}
|
|
1587
|
-
panBtn = this.element.querySelector('.e-img-pan .e-btn');
|
|
1588
|
-
if (!isNullOrUndefined(panBtn) && this.togglePan) {
|
|
1589
|
-
panBtn.classList.add('e-selected-btn');
|
|
1590
|
-
}
|
|
1591
|
-
else if (!isNullOrUndefined(panBtn)) {
|
|
1592
|
-
panBtn.classList.remove('e-selected-btn');
|
|
1593
|
-
}
|
|
1594
1846
|
break;
|
|
1595
1847
|
case 'pan':
|
|
1596
|
-
this.currObjType.isCustomCrop = false;
|
|
1848
|
+
this.currObjType.isCustomCrop = this.currObjType.isFiltered = false;
|
|
1597
1849
|
if (isCropSelection) {
|
|
1598
1850
|
this.currObjType.isCustomCrop = false;
|
|
1599
1851
|
this.refreshActiveObj();
|
|
@@ -1602,11 +1854,13 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
1602
1854
|
}
|
|
1603
1855
|
if (this.togglePan) {
|
|
1604
1856
|
this.cancelPan();
|
|
1857
|
+
this.disablePan = true;
|
|
1605
1858
|
}
|
|
1606
1859
|
else {
|
|
1607
1860
|
panBtn = this.element.querySelector('.e-img-pan .e-btn');
|
|
1608
1861
|
panBtn.classList.add('e-selected-btn');
|
|
1609
1862
|
imageEditorObj.pan(true);
|
|
1863
|
+
this.disablePan = false;
|
|
1610
1864
|
}
|
|
1611
1865
|
zoomIn = document.querySelector('#' + this.element.id + '_zoomIn');
|
|
1612
1866
|
if (!isNullOrUndefined(zoomIn) && this.factor >= 8) {
|
|
@@ -1624,112 +1878,113 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
1624
1878
|
this.activeObj.strokeSettings = this.tempStrokeSettings;
|
|
1625
1879
|
this.activeObj.textSettings = this.tempTextSettings;
|
|
1626
1880
|
}
|
|
1881
|
+
else if (!isNullOrUndefined(document.querySelector('#' + this.element.id + '_sliderWrapper')) ||
|
|
1882
|
+
this.currObjType.isFiltered) {
|
|
1883
|
+
this.lowerContext.filter = this.adjustmentValue = this.initialAdjustmentValue = this.tempAdjustmentValue;
|
|
1884
|
+
this.currentFilter = this.tempFilter;
|
|
1885
|
+
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
1886
|
+
this.redrawImgWithObj();
|
|
1887
|
+
this.currObjType.isFiltered = false;
|
|
1888
|
+
if (this.adjustmentLevel.sharpen || this.adjustmentLevel.bw) {
|
|
1889
|
+
if (this.adjustmentLevel.sharpen) {
|
|
1890
|
+
this.setSharpness(false);
|
|
1891
|
+
}
|
|
1892
|
+
else if (this.adjustmentLevel.bw) {
|
|
1893
|
+
this.setBlackAndWhiteFilter(false);
|
|
1894
|
+
}
|
|
1895
|
+
const tempFilter = this.lowerContext.filter;
|
|
1896
|
+
this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
|
|
1897
|
+
'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
|
|
1898
|
+
for (let j = 0; j < this.objColl.length; j++) {
|
|
1899
|
+
this.apply(this.objColl[j].shape, this.objColl[j]);
|
|
1900
|
+
this.refreshActiveObj();
|
|
1901
|
+
}
|
|
1902
|
+
this.lowerContext.filter = tempFilter;
|
|
1903
|
+
}
|
|
1904
|
+
this.adjustmentLevel = extend({}, this.tempAdjustmentLevel, {}, true);
|
|
1905
|
+
if (this.currentFilter === this.element.id + '_sharpen' || this.currentFilter === this.element.id + '_blackandwhite'
|
|
1906
|
+
|| this.tempSharpenFilter || this.tempBWFilter) {
|
|
1907
|
+
if (this.currentFilter === this.element.id + '_sharpen' || this.tempSharpenFilter) {
|
|
1908
|
+
this.setSharpness(true);
|
|
1909
|
+
}
|
|
1910
|
+
else if (this.currentFilter === this.element.id + '_blackandwhite' || this.tempBWFilter) {
|
|
1911
|
+
this.setBlackAndWhiteFilter(true);
|
|
1912
|
+
}
|
|
1913
|
+
const tempFilter = this.lowerContext.filter;
|
|
1914
|
+
this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
|
|
1915
|
+
'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
|
|
1916
|
+
for (let j = 0; j < this.objColl.length; j++) {
|
|
1917
|
+
this.apply(this.objColl[j].shape, this.objColl[j]);
|
|
1918
|
+
this.refreshActiveObj();
|
|
1919
|
+
}
|
|
1920
|
+
this.lowerContext.filter = tempFilter;
|
|
1921
|
+
this.tempSharpenFilter = this.tempBWFilter = false;
|
|
1922
|
+
}
|
|
1923
|
+
this.element.querySelector('.e-contextual-toolbar-wrapper').classList.add('e-hide');
|
|
1924
|
+
}
|
|
1627
1925
|
this.cancelItems();
|
|
1628
1926
|
break;
|
|
1629
1927
|
case 'ok':
|
|
1630
|
-
|
|
1631
|
-
this.crop();
|
|
1632
|
-
}
|
|
1633
|
-
else if (this.togglePen) {
|
|
1634
|
-
this.freeHandDraw(false);
|
|
1635
|
-
}
|
|
1636
|
-
else if (this.textBox.style.display === 'block') {
|
|
1637
|
-
this.redrawActObj();
|
|
1638
|
-
}
|
|
1639
|
-
else {
|
|
1640
|
-
this.applyActObj();
|
|
1641
|
-
}
|
|
1642
|
-
this.callMainToolbar(false);
|
|
1643
|
-
break;
|
|
1644
|
-
case 'text':
|
|
1645
|
-
this.currObjType.isCustomCrop = false;
|
|
1646
|
-
imageEditorObj.drawShapeText();
|
|
1647
|
-
this.refreshToolbar(type);
|
|
1648
|
-
break;
|
|
1649
|
-
case 'pen':
|
|
1650
|
-
this.currObjType.isCustomCrop = false;
|
|
1651
|
-
this.freeHandDraw(true);
|
|
1652
|
-
this.refreshToolbar(type);
|
|
1928
|
+
this.okBtn();
|
|
1653
1929
|
break;
|
|
1654
1930
|
case 'reset':
|
|
1655
1931
|
imageEditorObj.reset();
|
|
1656
1932
|
break;
|
|
1657
|
-
case '
|
|
1658
|
-
|
|
1659
|
-
|
|
1933
|
+
case 'adjustment':
|
|
1934
|
+
this.upperCanvas.style.display = 'block';
|
|
1935
|
+
this.refreshToolbar('adjustment');
|
|
1936
|
+
this.lowerContext.filter = this.initialAdjustmentValue;
|
|
1937
|
+
this.tempAdjustmentValue = this.lowerContext.filter;
|
|
1938
|
+
this.tempAdjustmentLevel = extend({}, this.adjustmentLevel, {}, true);
|
|
1939
|
+
this.tempFilter = this.currentFilter;
|
|
1940
|
+
this.tempSharpenFilter = this.adjustmentLevel.sharpen;
|
|
1941
|
+
this.tempBWFilter = this.adjustmentLevel.bw;
|
|
1660
1942
|
break;
|
|
1661
|
-
case '
|
|
1943
|
+
case 'brightness':
|
|
1944
|
+
case 'contrast':
|
|
1945
|
+
case 'hue':
|
|
1946
|
+
case 'saturation':
|
|
1947
|
+
case 'opacity':
|
|
1948
|
+
case 'blur':
|
|
1949
|
+
case 'exposure':
|
|
1950
|
+
this.unselectBtn();
|
|
1951
|
+
this.currObjType.isFiltered = true;
|
|
1952
|
+
this.refreshToolbar('color', null, null, null, type);
|
|
1953
|
+
document.getElementById(this.element.id + '_' + type).classList.add('e-selected-btn');
|
|
1662
1954
|
break;
|
|
1663
|
-
case '
|
|
1664
|
-
this.
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
this.
|
|
1672
|
-
this.
|
|
1673
|
-
this.redrawText(ratio);
|
|
1955
|
+
case 'filter':
|
|
1956
|
+
this.upperCanvas.style.display = 'block';
|
|
1957
|
+
this.refreshToolbar('filter');
|
|
1958
|
+
this.lowerContext.filter = this.initialAdjustmentValue;
|
|
1959
|
+
this.tempAdjustmentValue = this.lowerContext.filter;
|
|
1960
|
+
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
1961
|
+
this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
|
|
1962
|
+
for (let j = 0; j < this.objColl.length; j++) {
|
|
1963
|
+
this.apply(this.objColl[j].shape, this.objColl[j]);
|
|
1964
|
+
this.refreshActiveObj();
|
|
1674
1965
|
}
|
|
1966
|
+
this.tempAdjustmentLevel = extend({}, this.adjustmentLevel, {}, true);
|
|
1967
|
+
this.tempFilter = this.currentFilter;
|
|
1968
|
+
this.tempSharpenFilter = this.adjustmentLevel.sharpen;
|
|
1969
|
+
this.tempBWFilter = this.adjustmentLevel.bw;
|
|
1675
1970
|
break;
|
|
1676
|
-
case '
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
}
|
|
1688
|
-
const width = this.upperContext.measureText(this.activeObj.keyHistory).width +
|
|
1689
|
-
this.activeObj.textSettings.fontSize * 0.5;
|
|
1690
|
-
const height = this.activeObj.textSettings.fontSize + this.activeObj.textSettings.fontSize * 0.25;
|
|
1691
|
-
this.setTextSelection(width, height);
|
|
1692
|
-
this.updateActiveObject(ratio, this.activeObj.activePoint, this.activeObj);
|
|
1693
|
-
this.redrawShape(this.activeObj);
|
|
1694
|
-
this.isItalicbtn = true;
|
|
1695
|
-
}
|
|
1696
|
-
else {
|
|
1697
|
-
this.activeObj.textSettings.italic = false;
|
|
1698
|
-
if (this.activeObj.textSettings.bold) {
|
|
1699
|
-
this.upperContext.font = 'bold ' + this.activeObj.textSettings.fontSize + 'px' + ' ' + this.activeObj.textSettings.fontFamily;
|
|
1700
|
-
}
|
|
1701
|
-
else {
|
|
1702
|
-
this.upperContext.font = this.activeObj.textSettings.fontSize + 'px' + ' ' + this.activeObj.textSettings.fontFamily;
|
|
1703
|
-
}
|
|
1704
|
-
const width = this.upperContext.measureText(this.activeObj.keyHistory).width +
|
|
1705
|
-
this.activeObj.textSettings.fontSize * 0.5;
|
|
1706
|
-
const height = this.activeObj.textSettings.fontSize + this.activeObj.textSettings.fontSize * 0.25;
|
|
1707
|
-
this.setTextSelection(width, height);
|
|
1708
|
-
this.updateActiveObject(ratio, this.activeObj.activePoint, this.activeObj);
|
|
1709
|
-
this.redrawShape(this.activeObj);
|
|
1710
|
-
this.isItalicbtn = false;
|
|
1711
|
-
}
|
|
1971
|
+
case 'default':
|
|
1972
|
+
case 'chrome':
|
|
1973
|
+
case 'cold':
|
|
1974
|
+
case 'warm':
|
|
1975
|
+
case 'grayscale':
|
|
1976
|
+
case 'blackandwhite':
|
|
1977
|
+
case 'sepia':
|
|
1978
|
+
case 'invert':
|
|
1979
|
+
case 'sharpen':
|
|
1980
|
+
this.currObjType.isFiltered = true;
|
|
1981
|
+
this.setFilter(type);
|
|
1712
1982
|
break;
|
|
1713
1983
|
}
|
|
1714
1984
|
}
|
|
1715
1985
|
this.trigger('toolbarItemClicked', args);
|
|
1716
1986
|
}
|
|
1717
|
-
|
|
1718
|
-
this.applyActObj();
|
|
1719
|
-
const panBtn = this.element.querySelector('.e-img-pan .e-btn');
|
|
1720
|
-
panBtn.classList.remove('e-selected-btn');
|
|
1721
|
-
this.pan(false);
|
|
1722
|
-
}
|
|
1723
|
-
callMainToolbar(isApplyBtn, isZooming) {
|
|
1724
|
-
if (this.factor === 1) {
|
|
1725
|
-
this.refreshToolbar('main', isApplyBtn, false, isZooming);
|
|
1726
|
-
}
|
|
1727
|
-
else {
|
|
1728
|
-
this.refreshToolbar('main', isApplyBtn, false, isZooming);
|
|
1729
|
-
}
|
|
1730
|
-
}
|
|
1731
|
-
cancelItems() {
|
|
1732
|
-
const ratio = this.calcRatio();
|
|
1987
|
+
okBtn() {
|
|
1733
1988
|
let isCropSelection = false;
|
|
1734
1989
|
let splitWords;
|
|
1735
1990
|
if (this.activeObj.shape !== undefined) {
|
|
@@ -1741,86 +1996,773 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
1741
1996
|
else if (splitWords !== undefined && splitWords[0] === 'crop') {
|
|
1742
1997
|
isCropSelection = true;
|
|
1743
1998
|
}
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
this.
|
|
1747
|
-
this.upperCanvas.style.cursor = 'default';
|
|
1748
|
-
this.penDrawColl = [];
|
|
1749
|
-
this.imageEditorPointsColl = [];
|
|
1999
|
+
const selElem = this.element.querySelector('.e-contextual-toolbar-wrapper .e-toolbar-item.e-selected');
|
|
2000
|
+
if (selElem) {
|
|
2001
|
+
this.currentFilter = selElem.children[0].children[0].id.replace('Canvas', '');
|
|
1750
2002
|
}
|
|
1751
|
-
|
|
1752
|
-
this.
|
|
1753
|
-
this.activeObj.textSettings = this.tempTextSettings;
|
|
1754
|
-
if (this.activeObj.keyHistory === 'Enter Text' && this.activeObj.activePoint.startX === this.textStartPoints.x
|
|
1755
|
-
&& this.activeObj.activePoint.startY === this.textStartPoints.y) {
|
|
1756
|
-
this.refreshActiveObj();
|
|
1757
|
-
this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
|
|
1758
|
-
this.drawShapeText();
|
|
1759
|
-
}
|
|
1760
|
-
else {
|
|
1761
|
-
this.redrawText(ratio);
|
|
1762
|
-
this.redrawShape(this.activeObj);
|
|
1763
|
-
if (!isCropSelection && this.activeObj.topLeftCircle !== undefined) {
|
|
1764
|
-
this.applyActObj();
|
|
1765
|
-
}
|
|
1766
|
-
this.clearSelection();
|
|
1767
|
-
}
|
|
1768
|
-
this.tempTextSettings = { text: 'Enter Text', fontFamily: 'Arial', fontSize: null, bold: false, italic: false, underline: false };
|
|
2003
|
+
if (isCropSelection) {
|
|
2004
|
+
this.crop();
|
|
1769
2005
|
}
|
|
1770
|
-
else if (this.
|
|
1771
|
-
this.
|
|
1772
|
-
|
|
1773
|
-
|
|
2006
|
+
else if (this.togglePen) {
|
|
2007
|
+
this.freeHandDraw(false);
|
|
2008
|
+
}
|
|
2009
|
+
else if (this.textBox.style.display === 'block') {
|
|
2010
|
+
this.redrawActObj();
|
|
2011
|
+
}
|
|
2012
|
+
else if (!isNullOrUndefined(document.querySelector('#' + this.element.id + '_sliderWrapper')) ||
|
|
2013
|
+
this.currObjType.isFiltered) {
|
|
2014
|
+
this.initialAdjustmentValue = this.canvasFilter = this.lowerContext.filter;
|
|
2015
|
+
this.currObjType.isFiltered = false;
|
|
1774
2016
|
}
|
|
1775
2017
|
else {
|
|
1776
|
-
this.
|
|
1777
|
-
this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
|
|
2018
|
+
this.applyActObj();
|
|
1778
2019
|
}
|
|
1779
|
-
this.
|
|
1780
|
-
this.currObjType.isCustomCrop = false;
|
|
1781
|
-
this.tempStrokeSettings = { strokeColor: '#fff', fillColor: '', strokeWidth: null };
|
|
1782
|
-
this.callMainToolbar();
|
|
2020
|
+
this.callMainToolbar(false);
|
|
1783
2021
|
}
|
|
1784
|
-
|
|
1785
|
-
|
|
2022
|
+
unselectBtn() {
|
|
2023
|
+
if (document.querySelector('#' + this.element.id + '_brightness').classList.contains('e-selected-btn')) {
|
|
2024
|
+
document.querySelector('#' + this.element.id + '_brightness').classList.remove('e-selected-btn');
|
|
2025
|
+
}
|
|
2026
|
+
else if (document.querySelector('#' + this.element.id + '_contrast').classList.contains('e-selected-btn')) {
|
|
2027
|
+
document.querySelector('#' + this.element.id + '_contrast').classList.remove('e-selected-btn');
|
|
2028
|
+
}
|
|
2029
|
+
else if (document.querySelector('#' + this.element.id + '_hue').classList.contains('e-selected-btn')) {
|
|
2030
|
+
document.querySelector('#' + this.element.id + '_hue').classList.remove('e-selected-btn');
|
|
2031
|
+
}
|
|
2032
|
+
else if (document.querySelector('#' + this.element.id + '_saturation').classList.contains('e-selected-btn')) {
|
|
2033
|
+
document.querySelector('#' + this.element.id + '_saturation').classList.remove('e-selected-btn');
|
|
2034
|
+
}
|
|
2035
|
+
else if (document.querySelector('#' + this.element.id + '_opacity').classList.contains('e-selected-btn')) {
|
|
2036
|
+
document.querySelector('#' + this.element.id + '_opacity').classList.remove('e-selected-btn');
|
|
2037
|
+
}
|
|
2038
|
+
else if (document.querySelector('#' + this.element.id + '_blur').classList.contains('e-selected-btn')) {
|
|
2039
|
+
document.querySelector('#' + this.element.id + '_blur').classList.remove('e-selected-btn');
|
|
2040
|
+
}
|
|
2041
|
+
else if (document.querySelector('#' + this.element.id + '_exposure').classList.contains('e-selected-btn')) {
|
|
2042
|
+
document.querySelector('#' + this.element.id + '_exposure').classList.remove('e-selected-btn');
|
|
2043
|
+
}
|
|
1786
2044
|
}
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
2045
|
+
refreshSlider() {
|
|
2046
|
+
const sliderWrapper = document.querySelector('#' + this.element.id + '_sliderWrapper');
|
|
2047
|
+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
2048
|
+
const slider = document.querySelector('.e-slider');
|
|
2049
|
+
const hdrWrapper = document.querySelector('#' + this.element.id + '_headWrapper');
|
|
2050
|
+
if (hdrWrapper) {
|
|
2051
|
+
hdrWrapper.style.display = 'none';
|
|
1792
2052
|
}
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
2053
|
+
if (!isNullOrUndefined(sliderWrapper) && !isNullOrUndefined(slider)) {
|
|
2054
|
+
slider.ej2_instances[0].destroy();
|
|
2055
|
+
sliderWrapper.remove();
|
|
2056
|
+
}
|
|
2057
|
+
}
|
|
2058
|
+
updateAdjustment(type, value, isPreview) {
|
|
2059
|
+
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
2060
|
+
let splitWords = this.lowerContext.filter.split(' ');
|
|
2061
|
+
let values = [];
|
|
2062
|
+
let opacityValue;
|
|
2063
|
+
let brightnessValue;
|
|
2064
|
+
if (splitWords[4] !== undefined) {
|
|
2065
|
+
opacityValue = parseFloat(splitWords[4].split('(')[1]);
|
|
2066
|
+
}
|
|
2067
|
+
if (splitWords[0] !== undefined) {
|
|
2068
|
+
brightnessValue = parseFloat(splitWords[0].split('(')[1]);
|
|
2069
|
+
}
|
|
2070
|
+
const brightness = this.getFilterValue(this.adjustmentLevel.brightness);
|
|
2071
|
+
const saturation = this.getFilterValue(this.adjustmentLevel.saturation);
|
|
2072
|
+
if (type !== 'brightness' && type !== 'contrast' && type !== 'hue' && type !== 'saturation' && type !== 'exposure'
|
|
2073
|
+
&& type !== 'opacity' && type !== 'blur') {
|
|
2074
|
+
if (isNullOrUndefined(isPreview) && (this.adjustmentLevel.sharpen || this.adjustmentLevel.bw)) {
|
|
2075
|
+
if (this.adjustmentLevel.sharpen) {
|
|
2076
|
+
this.setSharpness(false);
|
|
2077
|
+
}
|
|
2078
|
+
else if (this.adjustmentLevel.bw) {
|
|
2079
|
+
this.setBlackAndWhiteFilter(false);
|
|
2080
|
+
}
|
|
2081
|
+
const temp = this.lowerContext.filter;
|
|
2082
|
+
this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
|
|
2083
|
+
'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
|
|
2084
|
+
for (let i = 0; i < this.objColl.length; i++) {
|
|
2085
|
+
this.apply(this.objColl[i].shape, this.objColl[i]);
|
|
2086
|
+
this.refreshActiveObj();
|
|
2087
|
+
}
|
|
2088
|
+
this.lowerContext.filter = temp;
|
|
2089
|
+
}
|
|
2090
|
+
}
|
|
2091
|
+
if (brightness !== 1) {
|
|
2092
|
+
splitWords[4] = 'opacity(' + (opacityValue - 0.3) + ')';
|
|
2093
|
+
}
|
|
2094
|
+
let saturate;
|
|
2095
|
+
let bright;
|
|
2096
|
+
let contrast;
|
|
2097
|
+
let saturatePercentage;
|
|
2098
|
+
let saturatePercent;
|
|
2099
|
+
let tempFilter;
|
|
2100
|
+
let temp;
|
|
2101
|
+
switch (type) {
|
|
2102
|
+
case 'brightness':
|
|
2103
|
+
if (splitWords[3].split) {
|
|
2104
|
+
if (parseFloat(splitWords[3].split('(')[1]) !== 100) {
|
|
2105
|
+
value += 0.1;
|
|
2106
|
+
}
|
|
2107
|
+
}
|
|
2108
|
+
splitWords[0] = 'brightness(' + value + ')';
|
|
2109
|
+
this.adjustmentValue = splitWords.join(' ');
|
|
2110
|
+
break;
|
|
2111
|
+
case 'contrast':
|
|
2112
|
+
splitWords[1] = 'contrast(' + value + '%)';
|
|
2113
|
+
this.adjustmentValue = splitWords.join(' ');
|
|
2114
|
+
break;
|
|
2115
|
+
case 'hue':
|
|
2116
|
+
splitWords[2] = 'hue-rotate(' + value + 'deg)';
|
|
2117
|
+
this.adjustmentValue = splitWords.join(' ');
|
|
2118
|
+
break;
|
|
2119
|
+
case 'saturation':
|
|
2120
|
+
splitWords[3] = 'saturate(' + value + '%)';
|
|
2121
|
+
if (saturation !== 1) {
|
|
2122
|
+
splitWords[0] = 'brightness(' + (brightnessValue + 0.1) + ')';
|
|
2123
|
+
}
|
|
2124
|
+
this.adjustmentValue = splitWords.join(' ');
|
|
2125
|
+
break;
|
|
2126
|
+
case 'opacity':
|
|
2127
|
+
if (parseFloat(splitWords[0].split('(')[1]) !== 1) {
|
|
2128
|
+
value -= 0.2;
|
|
2129
|
+
}
|
|
2130
|
+
splitWords[4] = 'opacity(' + value + ')';
|
|
2131
|
+
this.adjustmentValue = splitWords.join(' ');
|
|
2132
|
+
break;
|
|
2133
|
+
case 'blur':
|
|
2134
|
+
splitWords[5] = 'blur(' + value + 'px)';
|
|
2135
|
+
this.adjustmentValue = splitWords.join(' ');
|
|
2136
|
+
break;
|
|
2137
|
+
case 'exposure':
|
|
2138
|
+
if (brightness !== 1) {
|
|
2139
|
+
splitWords[4] = 'opacity(' + (opacityValue - 0.3) + ')';
|
|
2140
|
+
}
|
|
2141
|
+
if (value > 1) {
|
|
2142
|
+
value -= 1;
|
|
2143
|
+
value += brightness;
|
|
2144
|
+
}
|
|
2145
|
+
else if (value < 1) {
|
|
2146
|
+
value = 1 - value;
|
|
2147
|
+
value = brightness - value;
|
|
2148
|
+
}
|
|
2149
|
+
splitWords[0] = 'brightness(' + value + ')';
|
|
2150
|
+
this.adjustmentValue = splitWords.join(' ');
|
|
2151
|
+
break;
|
|
2152
|
+
case 'chrome':
|
|
2153
|
+
saturate = this.getSaturationFilterValue(this.adjustmentLevel.saturation);
|
|
2154
|
+
saturate *= 100;
|
|
2155
|
+
value = saturate + (saturate * 0.4);
|
|
2156
|
+
splitWords[3] = 'saturate(' + value + '%)';
|
|
2157
|
+
values = this.adjustmentValue.split(' ');
|
|
2158
|
+
splitWords[0] = values[0];
|
|
2159
|
+
splitWords[1] = values[1];
|
|
2160
|
+
splitWords[2] = values[2];
|
|
2161
|
+
splitWords[4] = values[4];
|
|
2162
|
+
splitWords[5] = values[5];
|
|
2163
|
+
splitWords[6] = 'sepia(0%)';
|
|
2164
|
+
splitWords[7] = 'grayscale(0%)';
|
|
2165
|
+
splitWords[8] = 'invert(0%)';
|
|
2166
|
+
break;
|
|
2167
|
+
case 'cold':
|
|
2168
|
+
// Adjusting Brightness
|
|
2169
|
+
bright = this.getFilterValue(this.adjustmentLevel.brightness);
|
|
2170
|
+
bright *= 100;
|
|
2171
|
+
value = bright * 0.9;
|
|
2172
|
+
splitWords[0] = 'brightness(' + value + '%)';
|
|
2173
|
+
// Adjusting Contrast
|
|
2174
|
+
contrast = this.getFilterValue(this.adjustmentLevel.contrast);
|
|
2175
|
+
contrast *= 100;
|
|
2176
|
+
value = contrast + (contrast * 0.5);
|
|
2177
|
+
splitWords[1] = 'contrast(' + value + '%)';
|
|
2178
|
+
// Adjusting Saturation
|
|
2179
|
+
saturatePercentage = this.getSaturationFilterValue(this.adjustmentLevel.saturation);
|
|
2180
|
+
saturatePercentage *= 100;
|
|
2181
|
+
value = saturatePercentage;
|
|
2182
|
+
splitWords[3] = 'saturate(' + value + '%)';
|
|
2183
|
+
values = this.adjustmentValue.split(' ');
|
|
2184
|
+
splitWords[2] = values[2];
|
|
2185
|
+
splitWords[4] = values[4];
|
|
2186
|
+
splitWords[5] = values[5];
|
|
2187
|
+
splitWords[6] = 'sepia(0%)';
|
|
2188
|
+
splitWords[7] = 'grayscale(0%)';
|
|
2189
|
+
splitWords[8] = 'invert(0%)';
|
|
2190
|
+
break;
|
|
2191
|
+
case 'warm':
|
|
2192
|
+
saturatePercent = this.getSaturationFilterValue(this.adjustmentLevel.saturation);
|
|
2193
|
+
saturatePercent *= 100;
|
|
2194
|
+
value = saturatePercent + (saturatePercent * 0.4);
|
|
2195
|
+
splitWords[3] = 'saturate(' + value + '%)';
|
|
2196
|
+
splitWords[6] = 'sepia(25%)';
|
|
2197
|
+
values = this.adjustmentValue.split(' ');
|
|
2198
|
+
splitWords[0] = values[0];
|
|
2199
|
+
splitWords[1] = values[1];
|
|
2200
|
+
splitWords[2] = values[2];
|
|
2201
|
+
splitWords[4] = values[4];
|
|
2202
|
+
splitWords[5] = values[5];
|
|
2203
|
+
splitWords[7] = 'grayscale(0%)';
|
|
2204
|
+
splitWords[8] = 'invert(0%)';
|
|
2205
|
+
break;
|
|
2206
|
+
case 'grayscale':
|
|
2207
|
+
splitWords[7] = 'grayscale(100%)';
|
|
2208
|
+
values = this.adjustmentValue.split(' ');
|
|
2209
|
+
splitWords[0] = values[0];
|
|
2210
|
+
splitWords[1] = values[1];
|
|
2211
|
+
splitWords[2] = values[2];
|
|
2212
|
+
splitWords[3] = values[3];
|
|
2213
|
+
splitWords[4] = values[4];
|
|
2214
|
+
splitWords[5] = values[5];
|
|
2215
|
+
splitWords[6] = 'sepia(0%)';
|
|
2216
|
+
splitWords[8] = 'invert(0%)';
|
|
2217
|
+
break;
|
|
2218
|
+
case 'blackandwhite':
|
|
2219
|
+
values = this.adjustmentValue.split(' ');
|
|
2220
|
+
if (isPreview) {
|
|
2221
|
+
tempFilter = this.lowerContext.filter;
|
|
2222
|
+
this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
|
|
2223
|
+
'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
|
|
2224
|
+
this.setBlackAndWhiteFilter(true);
|
|
2225
|
+
for (let i = 0; i < this.objColl.length; i++) {
|
|
2226
|
+
this.apply(this.objColl[i].shape, this.objColl[i]);
|
|
2227
|
+
this.refreshActiveObj();
|
|
2228
|
+
}
|
|
2229
|
+
splitWords[0] = values[0];
|
|
2230
|
+
splitWords[1] = values[1];
|
|
2231
|
+
splitWords[2] = values[2];
|
|
2232
|
+
splitWords[3] = values[3];
|
|
2233
|
+
splitWords[4] = values[4];
|
|
2234
|
+
splitWords[5] = values[5];
|
|
2235
|
+
splitWords[6] = 'sepia(0%)';
|
|
2236
|
+
splitWords[7] = 'grayscale(0%)';
|
|
2237
|
+
splitWords[8] = 'invert(0%)';
|
|
2238
|
+
}
|
|
2239
|
+
else {
|
|
2240
|
+
tempFilter = this.lowerContext.filter;
|
|
2241
|
+
this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
|
|
2242
|
+
'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
|
|
2243
|
+
this.setBlackAndWhiteFilter(true);
|
|
2244
|
+
splitWords[0] = values[0];
|
|
2245
|
+
splitWords[1] = values[1];
|
|
2246
|
+
splitWords[2] = values[2];
|
|
2247
|
+
splitWords[3] = values[3];
|
|
2248
|
+
splitWords[4] = values[4];
|
|
2249
|
+
splitWords[5] = values[5];
|
|
2250
|
+
splitWords[6] = 'sepia(0%)';
|
|
2251
|
+
splitWords[7] = 'grayscale(0%)';
|
|
2252
|
+
splitWords[8] = 'invert(0%)';
|
|
2253
|
+
this.lowerContext.filter = this.initialAdjustmentValue = splitWords.join(' ');
|
|
2254
|
+
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
2255
|
+
this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
|
|
2256
|
+
tempFilter = this.lowerContext.filter;
|
|
2257
|
+
this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
|
|
2258
|
+
'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
|
|
2259
|
+
for (let i = 0; i < this.objColl.length; i++) {
|
|
2260
|
+
this.apply(this.objColl[i].shape, this.objColl[i]);
|
|
2261
|
+
this.refreshActiveObj();
|
|
2262
|
+
}
|
|
2263
|
+
this.lowerContext.filter = tempFilter;
|
|
2264
|
+
}
|
|
2265
|
+
break;
|
|
2266
|
+
case 'sepia':
|
|
2267
|
+
splitWords[6] = 'sepia(100%)';
|
|
2268
|
+
values = this.adjustmentValue.split(' ');
|
|
2269
|
+
splitWords[0] = values[0];
|
|
2270
|
+
splitWords[1] = values[1];
|
|
2271
|
+
splitWords[2] = values[2];
|
|
2272
|
+
splitWords[3] = values[3];
|
|
2273
|
+
splitWords[4] = values[4];
|
|
2274
|
+
splitWords[5] = values[5];
|
|
2275
|
+
splitWords[7] = 'grayscale(0%)';
|
|
2276
|
+
splitWords[8] = 'invert(0%)';
|
|
2277
|
+
break;
|
|
2278
|
+
case 'invert':
|
|
2279
|
+
splitWords[8] = 'invert(100%)';
|
|
2280
|
+
values = this.adjustmentValue.split(' ');
|
|
2281
|
+
splitWords[0] = values[0];
|
|
2282
|
+
splitWords[1] = values[1];
|
|
2283
|
+
splitWords[2] = values[2];
|
|
2284
|
+
splitWords[3] = values[3];
|
|
2285
|
+
splitWords[4] = values[4];
|
|
2286
|
+
splitWords[5] = values[5];
|
|
2287
|
+
splitWords[6] = 'sepia(0%)';
|
|
2288
|
+
splitWords[7] = 'grayscale(0%)';
|
|
2289
|
+
break;
|
|
2290
|
+
case 'sharpen':
|
|
2291
|
+
values = this.adjustmentValue.split(' ');
|
|
2292
|
+
if (isPreview) {
|
|
2293
|
+
temp = this.lowerContext.filter;
|
|
2294
|
+
this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
|
|
2295
|
+
'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
|
|
2296
|
+
for (let i = 0; i < this.objColl.length; i++) {
|
|
2297
|
+
this.apply(this.objColl[i].shape, this.objColl[i]);
|
|
2298
|
+
this.refreshActiveObj();
|
|
2299
|
+
}
|
|
2300
|
+
splitWords[0] = values[0];
|
|
2301
|
+
splitWords[1] = values[1];
|
|
2302
|
+
splitWords[2] = values[2];
|
|
2303
|
+
splitWords[3] = values[3];
|
|
2304
|
+
splitWords[4] = values[4];
|
|
2305
|
+
splitWords[5] = values[5];
|
|
2306
|
+
splitWords[6] = 'sepia(0%)';
|
|
2307
|
+
splitWords[7] = 'grayscale(0%)';
|
|
2308
|
+
splitWords[8] = 'invert(0%)';
|
|
2309
|
+
}
|
|
2310
|
+
else {
|
|
2311
|
+
temp = this.lowerContext.filter;
|
|
2312
|
+
this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
|
|
2313
|
+
'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
|
|
2314
|
+
this.setSharpness(true);
|
|
2315
|
+
splitWords[0] = values[0];
|
|
2316
|
+
splitWords[1] = values[1];
|
|
2317
|
+
splitWords[2] = values[2];
|
|
2318
|
+
splitWords[3] = values[3];
|
|
2319
|
+
splitWords[4] = values[4];
|
|
2320
|
+
splitWords[5] = values[5];
|
|
2321
|
+
splitWords[6] = 'sepia(0%)';
|
|
2322
|
+
splitWords[7] = 'grayscale(0%)';
|
|
2323
|
+
splitWords[8] = 'invert(0%)';
|
|
2324
|
+
this.lowerContext.filter = this.initialAdjustmentValue = splitWords.join(' ');
|
|
2325
|
+
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
2326
|
+
this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
|
|
2327
|
+
temp = this.lowerContext.filter;
|
|
2328
|
+
this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
|
|
2329
|
+
'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
|
|
2330
|
+
for (let i = 0; i < this.objColl.length; i++) {
|
|
2331
|
+
this.apply(this.objColl[i].shape, this.objColl[i]);
|
|
2332
|
+
this.refreshActiveObj();
|
|
2333
|
+
}
|
|
2334
|
+
this.lowerContext.filter = temp;
|
|
2335
|
+
}
|
|
2336
|
+
break;
|
|
2337
|
+
}
|
|
2338
|
+
if (type !== 'sharpen' && type !== 'blackandwhite') {
|
|
2339
|
+
if (isNullOrUndefined(isPreview)) {
|
|
2340
|
+
if (type === 'default') {
|
|
2341
|
+
splitWords = this.getDefaultFilter(splitWords);
|
|
2342
|
+
}
|
|
2343
|
+
this.lowerContext.filter = splitWords.join(' ');
|
|
2344
|
+
}
|
|
2345
|
+
splitWords = this.setTempFilterValue(brightness, isPreview, splitWords, type);
|
|
2346
|
+
this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
2347
|
+
if (brightness !== 1) {
|
|
2348
|
+
splitWords[4] = 'opacity(' + opacityValue + ')';
|
|
2349
|
+
}
|
|
2350
|
+
else if (saturation !== 1) {
|
|
2351
|
+
splitWords[0] = 'brightness(' + brightnessValue + ')';
|
|
2352
|
+
}
|
|
2353
|
+
if (type === 'exposure' && brightness !== 1) {
|
|
2354
|
+
splitWords[0] = 'brightness(' + brightnessValue + ')';
|
|
2355
|
+
}
|
|
2356
|
+
splitWords = this.setTempFilterValue(brightness, isPreview, splitWords, type);
|
|
2357
|
+
if (isNullOrUndefined(isPreview)) {
|
|
2358
|
+
this.lowerContext.filter = this.initialAdjustmentValue = splitWords.join(' ');
|
|
2359
|
+
}
|
|
2360
|
+
const tempFilter = this.lowerContext.filter;
|
|
2361
|
+
this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
|
|
2362
|
+
'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
|
|
2363
|
+
for (let i = 0; i < this.objColl.length; i++) {
|
|
2364
|
+
this.apply(this.objColl[i].shape, this.objColl[i]);
|
|
2365
|
+
this.refreshActiveObj();
|
|
2366
|
+
}
|
|
2367
|
+
this.lowerContext.filter = tempFilter;
|
|
2368
|
+
if (brightness === 1) {
|
|
2369
|
+
this.isBrightnessAdjusted = false;
|
|
2370
|
+
}
|
|
2371
|
+
else {
|
|
2372
|
+
this.isBrightnessAdjusted = true;
|
|
2373
|
+
}
|
|
2374
|
+
}
|
|
2375
|
+
const filter = splitWords.join(' ');
|
|
2376
|
+
return filter;
|
|
2377
|
+
}
|
|
2378
|
+
updateBrightnessFilter() {
|
|
2379
|
+
const splitWords = this.lowerContext.filter.split(' ');
|
|
2380
|
+
if (this.isBrightnessAdjusted && splitWords.length > 0 && !isNullOrUndefined(splitWords[4])) {
|
|
2381
|
+
const opacityValue = parseFloat(splitWords[4].split('(')[1]);
|
|
2382
|
+
splitWords[4] = 'opacity(' + (opacityValue - 0.3) + ')';
|
|
2383
|
+
this.lowerContext.filter = splitWords.join(' ');
|
|
2384
|
+
}
|
|
2385
|
+
}
|
|
2386
|
+
autoEnablePan() {
|
|
2387
|
+
if (this.factor > 0.95 && this.factor < 1.05) {
|
|
2388
|
+
this.dragCanvas = this.togglePan = false;
|
|
2389
|
+
this.callMainToolbar(false, true);
|
|
2390
|
+
this.pan(false);
|
|
2391
|
+
this.disablePan = false;
|
|
2392
|
+
}
|
|
2393
|
+
else if (!this.disablePan) {
|
|
2394
|
+
this.pan(true);
|
|
2395
|
+
}
|
|
2396
|
+
else if (this.disablePan) {
|
|
2397
|
+
this.pan(false);
|
|
2398
|
+
}
|
|
2399
|
+
}
|
|
2400
|
+
setTempFilterValue(brightness, isPreview, splitWords, type) {
|
|
2401
|
+
if (isPreview && brightness !== 1) {
|
|
2402
|
+
const tempSplitWords = this.lowerContext.filter.split(' ');
|
|
2403
|
+
tempSplitWords[4] = splitWords[4];
|
|
2404
|
+
this.lowerContext.filter = tempSplitWords.join(' ');
|
|
2405
|
+
}
|
|
2406
|
+
else if (isPreview && type === 'default') {
|
|
2407
|
+
splitWords = this.getDefaultFilter(splitWords);
|
|
2408
|
+
}
|
|
2409
|
+
return splitWords;
|
|
2410
|
+
}
|
|
2411
|
+
getDefaultFilter(splitWords) {
|
|
2412
|
+
const values = this.adjustmentValue.split(' ');
|
|
2413
|
+
splitWords[0] = values[0];
|
|
2414
|
+
splitWords[1] = values[1];
|
|
2415
|
+
splitWords[2] = values[2];
|
|
2416
|
+
splitWords[3] = values[3];
|
|
2417
|
+
splitWords[4] = values[4];
|
|
2418
|
+
splitWords[5] = values[5];
|
|
2419
|
+
splitWords[6] = 'sepia(0%)';
|
|
2420
|
+
splitWords[7] = 'grayscale(0%)';
|
|
2421
|
+
splitWords[8] = 'invert(0%)';
|
|
2422
|
+
return splitWords;
|
|
2423
|
+
}
|
|
2424
|
+
setAdjustment(type) {
|
|
2425
|
+
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
2426
|
+
const splitWords = this.lowerContext.filter.split(' ');
|
|
2427
|
+
let value;
|
|
2428
|
+
let valueArr;
|
|
2429
|
+
switch (type) {
|
|
2430
|
+
case 'brightness':
|
|
2431
|
+
valueArr = splitWords[0].split('(');
|
|
2432
|
+
value = parseFloat(valueArr[1].split(')')[0]);
|
|
2433
|
+
this.adjustmentLevel.brightness = this.setFilterValue(value);
|
|
2434
|
+
break;
|
|
2435
|
+
case 'contrast':
|
|
2436
|
+
valueArr = splitWords[1].split('(');
|
|
2437
|
+
value = parseFloat(valueArr[1].split(')')[0]);
|
|
2438
|
+
value /= 100;
|
|
2439
|
+
this.adjustmentLevel.contrast = this.setFilterValue(value);
|
|
2440
|
+
break;
|
|
2441
|
+
case 'hue':
|
|
2442
|
+
valueArr = splitWords[2].split('(');
|
|
2443
|
+
value = parseFloat(valueArr[1].split(')')[0]);
|
|
2444
|
+
value /= 3;
|
|
2445
|
+
this.adjustmentLevel.hue = value;
|
|
2446
|
+
break;
|
|
2447
|
+
case 'saturation':
|
|
2448
|
+
valueArr = splitWords[3].split('(');
|
|
2449
|
+
value = parseFloat(valueArr[1].split(')')[0]);
|
|
2450
|
+
value /= 100;
|
|
2451
|
+
this.adjustmentLevel.saturation = this.setSaturationFilterValue(value);
|
|
2452
|
+
break;
|
|
2453
|
+
case 'opacity':
|
|
2454
|
+
valueArr = splitWords[4].split('(');
|
|
2455
|
+
value = parseFloat(valueArr[1].split(')')[0]);
|
|
2456
|
+
if (value === 0.45) {
|
|
2457
|
+
value = 40;
|
|
2458
|
+
}
|
|
2459
|
+
else if (value === 0.40) {
|
|
2460
|
+
value = 30;
|
|
2461
|
+
}
|
|
2462
|
+
else if (value === 0.35) {
|
|
2463
|
+
value = 20;
|
|
2464
|
+
}
|
|
2465
|
+
else if (value === 0.30) {
|
|
2466
|
+
value = 10;
|
|
2467
|
+
}
|
|
2468
|
+
else if (value === 0.25) {
|
|
2469
|
+
value = 0;
|
|
2470
|
+
}
|
|
2471
|
+
else {
|
|
2472
|
+
value *= 100;
|
|
2473
|
+
}
|
|
2474
|
+
this.adjustmentLevel.opacity = value;
|
|
2475
|
+
break;
|
|
2476
|
+
case 'blur':
|
|
2477
|
+
valueArr = splitWords[5].split('(');
|
|
2478
|
+
value = parseFloat(valueArr[1].split(')')[0]);
|
|
2479
|
+
value *= 20;
|
|
2480
|
+
this.adjustmentLevel.blur = value;
|
|
2481
|
+
break;
|
|
2482
|
+
case 'exposure':
|
|
2483
|
+
valueArr = splitWords[0].split('(');
|
|
2484
|
+
value = parseFloat(valueArr[1].split(')')[0]);
|
|
2485
|
+
this.adjustmentLevel.exposure = this.setFilterValue(value);
|
|
2486
|
+
break;
|
|
2487
|
+
}
|
|
2488
|
+
const temp = this.lowerContext.filter;
|
|
2489
|
+
this.updateBrightnessFilter();
|
|
2490
|
+
this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
2491
|
+
this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
|
|
2492
|
+
'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
|
|
2493
|
+
for (let j = 0; j < this.objColl.length; j++) {
|
|
2494
|
+
this.apply(this.objColl[j].shape, this.objColl[j]);
|
|
2495
|
+
this.refreshActiveObj();
|
|
2496
|
+
}
|
|
2497
|
+
this.lowerContext.filter = temp;
|
|
2498
|
+
}
|
|
2499
|
+
renderSlider(type) {
|
|
2500
|
+
const canvasWrapper = document.querySelector('#' + this.element.id + '_contextualToolbarArea');
|
|
2501
|
+
let hdrWrapper = document.querySelector('#' + this.element.id + '_headWrapper');
|
|
2502
|
+
let labelWrapper = document.querySelector('#' + this.element.id + '_labelWrapper');
|
|
2503
|
+
if (!hdrWrapper && !isNullOrUndefined(canvasWrapper)) {
|
|
2504
|
+
hdrWrapper = canvasWrapper.appendChild(this.createElement('div', {
|
|
2505
|
+
id: this.element.id + '_headWrapper',
|
|
2506
|
+
styles: 'position: relative'
|
|
2507
|
+
}));
|
|
2508
|
+
labelWrapper = hdrWrapper.appendChild(this.createElement('label', {
|
|
2509
|
+
id: this.element.id + '_labelWrapper',
|
|
2510
|
+
styles: Browser.isDevice ? 'position: absolute; top: 25%; left: calc(50% - 150px); font-size: 15px; text-transform: capitalize; font-weight: 400;'
|
|
2511
|
+
: 'position: absolute; top: 25%; left: calc(50% - 226px); font-size: 15px; text-transform: capitalize; font-weight: 400;'
|
|
2512
|
+
}));
|
|
2513
|
+
}
|
|
2514
|
+
else {
|
|
2515
|
+
hdrWrapper.style.display = 'block';
|
|
2516
|
+
}
|
|
2517
|
+
labelWrapper.textContent = this.l10n.getConstant(this.toPascalCase(type));
|
|
2518
|
+
const sliderWrapper = hdrWrapper.appendChild(this.createElement('div', {
|
|
2519
|
+
id: this.element.id + '_sliderWrapper',
|
|
2520
|
+
styles: 'position: absolute'
|
|
2521
|
+
}));
|
|
2522
|
+
const value = this.getCurrAdjustmentValue(type);
|
|
2523
|
+
let min;
|
|
2524
|
+
let max;
|
|
2525
|
+
let slider;
|
|
2526
|
+
if (type === 'brightness' || type === 'contrast' || type === 'saturation' || type === 'exposure') {
|
|
2527
|
+
if (this.finetuneSettings) {
|
|
2528
|
+
if (type === 'brightness' && this.finetuneSettings.brightness) {
|
|
2529
|
+
min = this.finetuneSettings.brightness.min;
|
|
2530
|
+
max = this.finetuneSettings.brightness.max;
|
|
2531
|
+
}
|
|
2532
|
+
else if (type === 'contrast' && this.finetuneSettings.contrast) {
|
|
2533
|
+
min = this.finetuneSettings.contrast.min;
|
|
2534
|
+
max = this.finetuneSettings.contrast.max;
|
|
2535
|
+
}
|
|
2536
|
+
else if (type === 'saturation' && this.finetuneSettings.saturation) {
|
|
2537
|
+
min = this.finetuneSettings.saturation.min;
|
|
2538
|
+
max = this.finetuneSettings.saturation.max;
|
|
2539
|
+
}
|
|
2540
|
+
else if (type === 'exposure' && this.finetuneSettings.exposure) {
|
|
2541
|
+
min = this.finetuneSettings.exposure.min;
|
|
2542
|
+
max = this.finetuneSettings.exposure.max;
|
|
2543
|
+
}
|
|
2544
|
+
else {
|
|
2545
|
+
min = -100;
|
|
2546
|
+
max = 100;
|
|
2547
|
+
}
|
|
2548
|
+
}
|
|
2549
|
+
else {
|
|
2550
|
+
min = -100;
|
|
2551
|
+
max = 100;
|
|
2552
|
+
}
|
|
2553
|
+
slider = new Slider({
|
|
2554
|
+
value: value,
|
|
2555
|
+
tooltip: { isVisible: true, placement: 'Before', showOn: 'Always' },
|
|
2556
|
+
type: 'MinRange',
|
|
2557
|
+
min: min,
|
|
2558
|
+
max: max,
|
|
2559
|
+
step: 10,
|
|
2560
|
+
width: Browser.isDevice ? '200px' : '300px',
|
|
2561
|
+
cssClass: 'e-slider',
|
|
2562
|
+
change: (args) => {
|
|
2563
|
+
this.setCurrAdjustmentValue(type, args.value);
|
|
2564
|
+
}
|
|
2565
|
+
});
|
|
2566
|
+
}
|
|
2567
|
+
else if (type === 'hue' || type === 'blur' || type === 'opacity') {
|
|
2568
|
+
if (this.finetuneSettings) {
|
|
2569
|
+
if (type === 'hue' && this.finetuneSettings.hue) {
|
|
2570
|
+
min = this.finetuneSettings.hue.min;
|
|
2571
|
+
max = this.finetuneSettings.hue.max;
|
|
2572
|
+
}
|
|
2573
|
+
else if (type === 'blur' && this.finetuneSettings.blur) {
|
|
2574
|
+
min = this.finetuneSettings.blur.min;
|
|
2575
|
+
max = this.finetuneSettings.blur.max;
|
|
2576
|
+
}
|
|
2577
|
+
else if (type === 'opacity' && this.finetuneSettings.opacity) {
|
|
2578
|
+
min = this.finetuneSettings.opacity.min;
|
|
2579
|
+
max = this.finetuneSettings.opacity.max;
|
|
2580
|
+
}
|
|
2581
|
+
else {
|
|
2582
|
+
min = 0;
|
|
2583
|
+
max = 100;
|
|
2584
|
+
}
|
|
2585
|
+
}
|
|
2586
|
+
else {
|
|
2587
|
+
min = 0;
|
|
2588
|
+
max = 100;
|
|
2589
|
+
}
|
|
2590
|
+
slider = new Slider({
|
|
2591
|
+
value: value,
|
|
2592
|
+
tooltip: { isVisible: true, placement: 'Before', showOn: 'Always' },
|
|
2593
|
+
type: 'MinRange',
|
|
2594
|
+
min: min,
|
|
2595
|
+
max: max,
|
|
2596
|
+
step: 10,
|
|
2597
|
+
width: Browser.isDevice ? '200px' : '300px',
|
|
2598
|
+
cssClass: 'e-slider',
|
|
2599
|
+
change: (args) => {
|
|
2600
|
+
this.setCurrAdjustmentValue(type, args.value);
|
|
2601
|
+
}
|
|
2602
|
+
});
|
|
2603
|
+
}
|
|
2604
|
+
slider.appendTo('#' + this.element.id + '_sliderWrapper');
|
|
2605
|
+
sliderWrapper.style.left = (parseFloat(canvasWrapper.style.width) - parseFloat(slider.width)) / 2 + 'px';
|
|
2606
|
+
}
|
|
2607
|
+
getCurrAdjustmentValue(type) {
|
|
2608
|
+
let value;
|
|
2609
|
+
switch (type) {
|
|
2610
|
+
case 'brightness':
|
|
2611
|
+
value = this.adjustmentLevel.brightness;
|
|
2612
|
+
break;
|
|
2613
|
+
case 'contrast':
|
|
2614
|
+
value = this.adjustmentLevel.contrast;
|
|
2615
|
+
break;
|
|
2616
|
+
case 'hue':
|
|
2617
|
+
value = this.adjustmentLevel.hue;
|
|
2618
|
+
break;
|
|
2619
|
+
case 'saturation':
|
|
2620
|
+
value = this.adjustmentLevel.saturation;
|
|
2621
|
+
break;
|
|
2622
|
+
case 'opacity':
|
|
2623
|
+
value = this.adjustmentLevel.opacity;
|
|
2624
|
+
break;
|
|
2625
|
+
case 'blur':
|
|
2626
|
+
value = this.adjustmentLevel.blur;
|
|
2627
|
+
break;
|
|
2628
|
+
case 'exposure':
|
|
2629
|
+
value = this.adjustmentLevel.exposure;
|
|
2630
|
+
break;
|
|
2631
|
+
}
|
|
2632
|
+
return value;
|
|
2633
|
+
}
|
|
2634
|
+
setCurrAdjustmentValue(type, value) {
|
|
2635
|
+
const fineTuneValueChanging = { finetune: this.toPascalCase(type), value: value };
|
|
2636
|
+
this.trigger('fineTuneValueChanging', fineTuneValueChanging);
|
|
2637
|
+
switch (type) {
|
|
2638
|
+
case 'brightness':
|
|
2639
|
+
this.setBrightness(value);
|
|
2640
|
+
break;
|
|
2641
|
+
case 'contrast':
|
|
2642
|
+
this.setContrast(value);
|
|
2643
|
+
break;
|
|
2644
|
+
case 'hue':
|
|
2645
|
+
this.setHue(value);
|
|
2646
|
+
break;
|
|
2647
|
+
case 'saturation':
|
|
2648
|
+
this.setSaturation(value);
|
|
2649
|
+
break;
|
|
2650
|
+
case 'opacity':
|
|
2651
|
+
this.setOpacity(value);
|
|
2652
|
+
break;
|
|
2653
|
+
case 'blur':
|
|
2654
|
+
this.setBlur(value);
|
|
2655
|
+
break;
|
|
2656
|
+
case 'exposure':
|
|
2657
|
+
this.setExposure(value);
|
|
2658
|
+
break;
|
|
2659
|
+
}
|
|
2660
|
+
}
|
|
2661
|
+
cancelPan() {
|
|
2662
|
+
this.applyActObj();
|
|
2663
|
+
const panBtn = this.element.querySelector('.e-img-pan .e-btn');
|
|
2664
|
+
panBtn.classList.remove('e-selected-btn');
|
|
2665
|
+
this.pan(false);
|
|
2666
|
+
}
|
|
2667
|
+
callMainToolbar(isApplyBtn, isZooming) {
|
|
2668
|
+
this.refreshToolbar('main', isApplyBtn, false, isZooming);
|
|
2669
|
+
}
|
|
2670
|
+
cancelItems() {
|
|
2671
|
+
const ratio = this.calcRatio();
|
|
2672
|
+
let isCropSelection = false;
|
|
2673
|
+
let splitWords;
|
|
2674
|
+
if (this.activeObj.shape !== undefined) {
|
|
2675
|
+
splitWords = this.activeObj.shape.split('-');
|
|
2676
|
+
}
|
|
2677
|
+
if (splitWords === undefined && this.currObjType.isCustomCrop) {
|
|
2678
|
+
isCropSelection = true;
|
|
2679
|
+
}
|
|
2680
|
+
else if (splitWords !== undefined && splitWords[0] === 'crop') {
|
|
2681
|
+
isCropSelection = true;
|
|
2682
|
+
}
|
|
2683
|
+
if (this.togglePen) {
|
|
2684
|
+
this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
|
|
2685
|
+
this.togglePen = false;
|
|
2686
|
+
this.upperCanvas.style.cursor = 'default';
|
|
2687
|
+
this.penDrawColl = [];
|
|
2688
|
+
this.imageEditorPointsColl = [];
|
|
2689
|
+
}
|
|
2690
|
+
else if (this.activeObj.shape === 'text') {
|
|
2691
|
+
this.activeObj.strokeSettings = this.tempStrokeSettings;
|
|
2692
|
+
this.activeObj.textSettings = this.tempTextSettings;
|
|
2693
|
+
if (this.activeObj.keyHistory === 'Enter Text' && this.activeObj.activePoint.startX === this.textStartPoints.x
|
|
2694
|
+
&& this.activeObj.activePoint.startY === this.textStartPoints.y) {
|
|
2695
|
+
this.refreshActiveObj();
|
|
2696
|
+
this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
|
|
2697
|
+
this.drawShapeText();
|
|
2698
|
+
}
|
|
2699
|
+
else {
|
|
2700
|
+
this.redrawText(ratio);
|
|
2701
|
+
this.redrawShape(this.activeObj);
|
|
2702
|
+
if (!isCropSelection && this.activeObj.topLeftCircle !== undefined) {
|
|
2703
|
+
this.applyActObj();
|
|
2704
|
+
}
|
|
2705
|
+
this.clearSelection();
|
|
2706
|
+
}
|
|
2707
|
+
this.tempTextSettings = { text: 'Enter Text', fontFamily: 'Arial', fontSize: null, bold: false, italic: false, underline: false };
|
|
2708
|
+
}
|
|
2709
|
+
else if (this.activeObj.shape === 'rectangle' || this.activeObj.shape === 'ellipse' || this.activeObj.shape === 'line') {
|
|
2710
|
+
this.activeObj.strokeSettings = this.tempStrokeSettings;
|
|
2711
|
+
this.redrawShape(this.activeObj);
|
|
2712
|
+
this.applyActObj();
|
|
2713
|
+
}
|
|
2714
|
+
else {
|
|
2715
|
+
this.refreshActiveObj();
|
|
2716
|
+
this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
|
|
2717
|
+
}
|
|
2718
|
+
this.upperCanvas.style.cursor = 'default';
|
|
2719
|
+
this.currObjType.isCustomCrop = false;
|
|
2720
|
+
this.tempStrokeSettings = { strokeColor: '#fff', fillColor: '', strokeWidth: null };
|
|
2721
|
+
this.callMainToolbar();
|
|
2722
|
+
}
|
|
2723
|
+
gradient(a, b) {
|
|
2724
|
+
return (b.y - a.y) / (b.x - a.x);
|
|
2725
|
+
}
|
|
2726
|
+
applyPenDraw() {
|
|
2727
|
+
if (this.togglePen && this.factor === 1 && !this.currObjType.isZoomed) {
|
|
2728
|
+
this.apply();
|
|
2729
|
+
this.penDrawColl = [];
|
|
2730
|
+
this.imageEditorPointsColl = [];
|
|
2731
|
+
}
|
|
2732
|
+
else {
|
|
2733
|
+
const tempCanvas = this.lowerCanvas.appendChild(this.createElement('canvas', {
|
|
2734
|
+
id: this.element.id + '_tempCanvas', attrs: { name: 'canvasImage' }
|
|
2735
|
+
}));
|
|
2736
|
+
const tempContext = tempCanvas.getContext('2d');
|
|
2737
|
+
tempCanvas.width = this.lowerCanvas.width;
|
|
2738
|
+
tempCanvas.height = this.lowerCanvas.height;
|
|
2739
|
+
const temp = this.lowerContext.filter;
|
|
2740
|
+
this.updateBrightnessFilter();
|
|
2741
|
+
tempContext.drawImage(this.inMemoryCanvas, 0, 0);
|
|
2742
|
+
this.lowerContext.filter = temp;
|
|
2743
|
+
this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
|
|
2744
|
+
for (let i = 0; i < this.penDrawColl.length; i++) {
|
|
2745
|
+
tempContext.lineWidth = 2 * this.penDrawColl[i].strokeWidth;
|
|
2746
|
+
tempContext.strokeStyle = this.penDrawColl[i].strokeColor;
|
|
2747
|
+
let nexP;
|
|
2748
|
+
let preP;
|
|
2749
|
+
const f = 0.3;
|
|
2750
|
+
const t = 1;
|
|
2751
|
+
tempContext.beginPath();
|
|
2752
|
+
tempContext.moveTo(this.penDrawColl[i].points[0].x, this.penDrawColl[i].points[0].y);
|
|
2753
|
+
let m = 0;
|
|
2754
|
+
let dx1 = 0;
|
|
2755
|
+
let dx2 = 0;
|
|
2756
|
+
let dy1 = 0;
|
|
2757
|
+
let dy2 = 0;
|
|
2758
|
+
preP = this.penDrawColl[i].points[0];
|
|
2759
|
+
for (let j = 1; j < this.penDrawColl[i].points.length; j++) {
|
|
2760
|
+
const curP = this.penDrawColl[i].points[j];
|
|
2761
|
+
nexP = this.penDrawColl[i].points[j + 1];
|
|
2762
|
+
if (nexP) {
|
|
2763
|
+
m = this.gradient(preP, nexP);
|
|
2764
|
+
dx2 = (nexP.x - curP.x) * -f;
|
|
2765
|
+
dy2 = dx2 * m * t;
|
|
1824
2766
|
}
|
|
1825
2767
|
else {
|
|
1826
2768
|
dx2 = 0;
|
|
@@ -1855,24 +2797,37 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
1855
2797
|
this.inMemoryCanvas.height = imgData.height;
|
|
1856
2798
|
this.inMemoryContext.putImageData(imgData, 0, 0);
|
|
1857
2799
|
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
1858
|
-
this.
|
|
1859
|
-
for (let j = 0; j < this.objColl.length; j++) {
|
|
1860
|
-
this.apply(this.objColl[j].shape, this.objColl[j]);
|
|
1861
|
-
this.refreshActiveObj();
|
|
1862
|
-
}
|
|
2800
|
+
this.redrawImgWithObj();
|
|
1863
2801
|
this.currObjType.isZoomed = false;
|
|
1864
2802
|
}
|
|
1865
2803
|
}
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
2804
|
+
redrawImgWithObj() {
|
|
2805
|
+
this.lowerContext.filter = this.canvasFilter;
|
|
2806
|
+
const temp = this.lowerContext.filter;
|
|
2807
|
+
this.updateBrightnessFilter();
|
|
2808
|
+
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
2809
|
+
this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
|
|
2810
|
+
this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
|
|
2811
|
+
'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
|
|
2812
|
+
for (let j = 0; j < this.objColl.length; j++) {
|
|
2813
|
+
this.apply(this.objColl[j].shape, this.objColl[j]);
|
|
2814
|
+
this.refreshActiveObj();
|
|
1870
2815
|
}
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
2816
|
+
this.lowerContext.filter = temp;
|
|
2817
|
+
}
|
|
2818
|
+
refreshToolbar(type, isApplyBtn, isCropping, isZooming, cType) {
|
|
2819
|
+
const args = { toolbarType: type };
|
|
2820
|
+
if (type !== 'filter' && type !== 'color') {
|
|
2821
|
+
if (document.getElementById(this.element.id + '_toolbar') && this.defToolbarItems.length > 0) {
|
|
2822
|
+
getComponent(document.getElementById(this.element.id + '_toolbar'), 'toolbar').destroy();
|
|
2823
|
+
}
|
|
2824
|
+
if (document.getElementById(this.element.id + '_bottomToolbar') && this.defToolbarItems.length > 0) {
|
|
2825
|
+
if (document.getElementById(this.element.id + '_bottomToolbar').className.indexOf('e-control') > -1) {
|
|
2826
|
+
getComponent(document.getElementById(this.element.id + '_bottomToolbar'), 'toolbar').destroy();
|
|
2827
|
+
}
|
|
1874
2828
|
}
|
|
1875
2829
|
}
|
|
2830
|
+
this.refreshSlider();
|
|
1876
2831
|
switch (type) {
|
|
1877
2832
|
case 'main':
|
|
1878
2833
|
if (Browser.isDevice) {
|
|
@@ -1922,7 +2877,104 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
1922
2877
|
case 'pan':
|
|
1923
2878
|
this.initZoomToolbarItem();
|
|
1924
2879
|
break;
|
|
2880
|
+
case 'adjustment':
|
|
2881
|
+
if (Browser.isDevice) {
|
|
2882
|
+
this.initToolbarItem(false, true, true);
|
|
2883
|
+
}
|
|
2884
|
+
this.initAdjustmentToolbarItem();
|
|
2885
|
+
break;
|
|
2886
|
+
case 'filter':
|
|
2887
|
+
this.updateContextualToolbar(type);
|
|
2888
|
+
break;
|
|
2889
|
+
case 'color':
|
|
2890
|
+
this.updateContextualToolbar(type, cType);
|
|
2891
|
+
break;
|
|
2892
|
+
}
|
|
2893
|
+
}
|
|
2894
|
+
getAdjustmentToolbarItem() {
|
|
2895
|
+
const toolbarItems = [];
|
|
2896
|
+
if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Brightness') > -1)) {
|
|
2897
|
+
toolbarItems.push({ id: this.element.id + '_brightness', prefixIcon: 'e-icons e-brightness', cssClass: 'top-icon e-brightness',
|
|
2898
|
+
tooltipText: this.l10n.getConstant('Brightness'), align: 'Center' });
|
|
2899
|
+
}
|
|
2900
|
+
if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Contrast') > -1)) {
|
|
2901
|
+
toolbarItems.push({ id: this.element.id + '_contrast', prefixIcon: 'e-icons e-contrast', cssClass: 'top-icon e-contrast',
|
|
2902
|
+
tooltipText: this.l10n.getConstant('Contrast'), align: 'Center' });
|
|
2903
|
+
}
|
|
2904
|
+
if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Hue') > -1)) {
|
|
2905
|
+
toolbarItems.push({ id: this.element.id + '_hue', prefixIcon: 'e-icons e-fade', cssClass: 'top-icon e-fade',
|
|
2906
|
+
tooltipText: this.l10n.getConstant('Hue'), align: 'Center' });
|
|
2907
|
+
}
|
|
2908
|
+
if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Saturation') > -1)) {
|
|
2909
|
+
toolbarItems.push({ id: this.element.id + '_saturation', prefixIcon: 'e-icons e-saturation', cssClass: 'top-icon e-saturation',
|
|
2910
|
+
tooltipText: this.l10n.getConstant('Saturation'), align: 'Center' });
|
|
2911
|
+
}
|
|
2912
|
+
if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Exposure') > -1)) {
|
|
2913
|
+
toolbarItems.push({ id: this.element.id + '_exposure', prefixIcon: 'e-icons e-grain', cssClass: 'top-icon e-grain',
|
|
2914
|
+
tooltipText: this.l10n.getConstant('Exposure'), align: 'Center' });
|
|
2915
|
+
}
|
|
2916
|
+
if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Opacity') > -1)) {
|
|
2917
|
+
toolbarItems.push({ id: this.element.id + '_opacity', prefixIcon: 'e-icons e-opacity', cssClass: 'top-icon e-opacity',
|
|
2918
|
+
tooltipText: this.l10n.getConstant('Opacity'), align: 'Center' });
|
|
2919
|
+
}
|
|
2920
|
+
if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Blur') > -1)) {
|
|
2921
|
+
toolbarItems.push({ id: this.element.id + '_blur', prefixIcon: 'e-icons e-tint', cssClass: 'top-icon e-tint',
|
|
2922
|
+
tooltipText: this.l10n.getConstant('Blur'), align: 'Center' });
|
|
2923
|
+
}
|
|
2924
|
+
const tempToolbarItems = this.processToolbar('center');
|
|
2925
|
+
for (let i = 0, len = tempToolbarItems.length; i < len; i++) {
|
|
2926
|
+
toolbarItems.push(tempToolbarItems[i]);
|
|
2927
|
+
}
|
|
2928
|
+
if (!Browser.isDevice) {
|
|
2929
|
+
toolbarItems.push({ id: this.element.id + '_ok', prefixIcon: 'e-icons e-check', cssClass: 'top-icon e-tick',
|
|
2930
|
+
tooltipText: this.l10n.getConstant('OK'), align: 'Right' });
|
|
2931
|
+
toolbarItems.push({ id: this.element.id + '_cancel', prefixIcon: 'e-icons e-close', cssClass: 'top-icon e-save',
|
|
2932
|
+
tooltipText: this.l10n.getConstant('Cancel'), align: 'Right' });
|
|
2933
|
+
}
|
|
2934
|
+
return toolbarItems;
|
|
2935
|
+
}
|
|
2936
|
+
getFilterToolbarItem() {
|
|
2937
|
+
const toolbarItems = [];
|
|
2938
|
+
if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Default') > -1)) {
|
|
2939
|
+
toolbarItems.push({ id: this.element.id + '_default', prefixIcon: 'e-icons e-none', cssClass: 'top-icon e-none',
|
|
2940
|
+
tooltipText: this.l10n.getConstant('Default'), align: 'Center',
|
|
2941
|
+
template: '<div class="filterwrapper" style="box-sizing: content-box;"><canvas id=' + this.element.id + '_defaultCanvas' + '></canvas><div style="text-align:center;"><span>' + this.l10n.getConstant('Default') + '</span></div></div>' });
|
|
2942
|
+
}
|
|
2943
|
+
if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Chrome') > -1)) {
|
|
2944
|
+
toolbarItems.push({ id: this.element.id + '_chrome', prefixIcon: 'e-icons e-none', cssClass: 'top-icon e-none',
|
|
2945
|
+
tooltipText: this.l10n.getConstant('Chrome'), align: 'Center',
|
|
2946
|
+
template: '<div class="filterwrapper" style="box-sizing: content-box;"><canvas id=' + this.element.id + '_chromeCanvas' + '></canvas><div style="text-align:center;"><span>' + this.l10n.getConstant('Chrome') + '</span></div></div>' });
|
|
2947
|
+
}
|
|
2948
|
+
if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Cold') > -1)) {
|
|
2949
|
+
toolbarItems.push({ id: this.element.id + '_cold', prefixIcon: 'e-icons e-none', cssClass: 'top-icon e-none',
|
|
2950
|
+
tooltipText: this.l10n.getConstant('Cold'), align: 'Center',
|
|
2951
|
+
template: '<div class="filterwrapper" style="box-sizing: content-box;"><canvas id=' + this.element.id + '_coldCanvas' + '></canvas><div style="text-align:center;"><span>' + this.l10n.getConstant('Cold') + '</span></div></div>' });
|
|
2952
|
+
}
|
|
2953
|
+
if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Warm') > -1)) {
|
|
2954
|
+
toolbarItems.push({ id: this.element.id + '_warm', prefixIcon: 'e-icons e-none', cssClass: 'top-icon e-none',
|
|
2955
|
+
tooltipText: this.l10n.getConstant('Warm'), align: 'Center',
|
|
2956
|
+
template: '<div class="filterwrapper" style="box-sizing: content-box;"><canvas id=' + this.element.id + '_warmCanvas' + '></canvas><div style="text-align:center;"><span>' + this.l10n.getConstant('Warm') + '</span></div></div>' });
|
|
2957
|
+
}
|
|
2958
|
+
if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Grayscale') > -1)) {
|
|
2959
|
+
toolbarItems.push({ id: this.element.id + '_grayscale', prefixIcon: 'e-icons e-none', cssClass: 'top-icon e-none',
|
|
2960
|
+
tooltipText: this.l10n.getConstant('Grayscale'), align: 'Center',
|
|
2961
|
+
template: '<div class="filterwrapper" style="box-sizing: content-box;"><canvas id=' + this.element.id + '_grayscaleCanvas' + '></canvas><div style="text-align:center;"><span>' + this.l10n.getConstant('Grayscale') + '</span></div></div>' });
|
|
2962
|
+
}
|
|
2963
|
+
if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Sepia') > -1)) {
|
|
2964
|
+
toolbarItems.push({ id: this.element.id + '_sepia', prefixIcon: 'e-icons e-none', cssClass: 'top-icon e-none',
|
|
2965
|
+
tooltipText: this.l10n.getConstant('Sepia'), align: 'Center',
|
|
2966
|
+
template: '<div class="filterwrapper" style="box-sizing: content-box;"><canvas id=' + this.element.id + '_sepiaCanvas' + '></canvas><div style="text-align:center;"><span>' + this.l10n.getConstant('Sepia') + '</span></div></div>' });
|
|
2967
|
+
}
|
|
2968
|
+
if (isNullOrUndefined(this.toolbar) || (!isNullOrUndefined(this.toolbar) && this.toolbar.indexOf('Invert') > -1)) {
|
|
2969
|
+
toolbarItems.push({ id: this.element.id + '_invert', prefixIcon: 'e-icons e-none', cssClass: 'top-icon e-none',
|
|
2970
|
+
tooltipText: this.l10n.getConstant('Invert'), align: 'Center',
|
|
2971
|
+
template: '<div class="filterwrapper" style="box-sizing: content-box;"><canvas id=' + this.element.id + '_invertCanvas' + '></canvas><div style="text-align:center;"><span>' + this.l10n.getConstant('Invert') + '</span></div></div>' });
|
|
2972
|
+
}
|
|
2973
|
+
const tempToolbarItems = this.processToolbar('center');
|
|
2974
|
+
for (let i = 0, len = tempToolbarItems.length; i < len; i++) {
|
|
2975
|
+
toolbarItems.push(tempToolbarItems[i]);
|
|
1925
2976
|
}
|
|
2977
|
+
return toolbarItems;
|
|
1926
2978
|
}
|
|
1927
2979
|
getPenToolbarItem(items) {
|
|
1928
2980
|
const toolbarItems = [];
|
|
@@ -2040,7 +3092,12 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
2040
3092
|
if (items.indexOf('strokeWidth') > -1) {
|
|
2041
3093
|
const strokeWidthBtn = document.getElementById(this.element.id + '_penStrokeWidth');
|
|
2042
3094
|
const spanElem = document.createElement('span');
|
|
2043
|
-
|
|
3095
|
+
if (isNullOrUndefined(this.penStrokeWidth)) {
|
|
3096
|
+
spanElem.innerHTML = this.l10n.getConstant('Small');
|
|
3097
|
+
}
|
|
3098
|
+
else {
|
|
3099
|
+
spanElem.innerHTML = this.getPenStroke(this.penStrokeWidth, this.calcRatio());
|
|
3100
|
+
}
|
|
2044
3101
|
spanElem.className = 'e-pen-stroke-width';
|
|
2045
3102
|
strokeWidthBtn.appendChild(spanElem);
|
|
2046
3103
|
const drpDownBtn = new DropDownButton({ items: strokeWidthItems,
|
|
@@ -2094,6 +3151,157 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
2094
3151
|
break;
|
|
2095
3152
|
}
|
|
2096
3153
|
}
|
|
3154
|
+
getPenStroke(value, ratio) {
|
|
3155
|
+
let textContent = '';
|
|
3156
|
+
if (Math.round(value / 0.4) === Math.round(ratio.width + ratio.height)) {
|
|
3157
|
+
textContent = this.l10n.getConstant('XSmall');
|
|
3158
|
+
}
|
|
3159
|
+
else if (Math.round(value / 0.8) === Math.round(ratio.width + ratio.height)) {
|
|
3160
|
+
textContent = this.l10n.getConstant('Small');
|
|
3161
|
+
}
|
|
3162
|
+
else if (Math.round(value / 1.2) === Math.round(ratio.width + ratio.height)) {
|
|
3163
|
+
textContent = this.l10n.getConstant('Medium');
|
|
3164
|
+
}
|
|
3165
|
+
else if (Math.round(value / 1.6) === Math.round(ratio.width + ratio.height)) {
|
|
3166
|
+
textContent = this.l10n.getConstant('Large');
|
|
3167
|
+
}
|
|
3168
|
+
else if (Math.round(value / 2) === Math.round(ratio.width + ratio.height)) {
|
|
3169
|
+
textContent = this.l10n.getConstant('XLarge');
|
|
3170
|
+
}
|
|
3171
|
+
return textContent;
|
|
3172
|
+
}
|
|
3173
|
+
initAdjustmentToolbarItem() {
|
|
3174
|
+
const leftItem = this.getLeftToolbarItem();
|
|
3175
|
+
const rightItem = this.getRightToolbarItem();
|
|
3176
|
+
const mainItem = this.getAdjustmentToolbarItem();
|
|
3177
|
+
const zoomItem = this.getZoomToolbarItem();
|
|
3178
|
+
if (Browser.isDevice) {
|
|
3179
|
+
this.defToolbarItems = mainItem;
|
|
3180
|
+
}
|
|
3181
|
+
else {
|
|
3182
|
+
this.defToolbarItems = [...leftItem, ...zoomItem, ...mainItem, ...rightItem];
|
|
3183
|
+
}
|
|
3184
|
+
const toolbar = new Toolbar({
|
|
3185
|
+
width: '100%',
|
|
3186
|
+
items: this.defToolbarItems,
|
|
3187
|
+
clicked: this.defToolbarClicked.bind(this),
|
|
3188
|
+
created: () => {
|
|
3189
|
+
if (!Browser.isDevice) {
|
|
3190
|
+
this.renderSaveBtn();
|
|
3191
|
+
}
|
|
3192
|
+
if (Browser.isDevice) {
|
|
3193
|
+
if (this.defToolbarItems.length > 0 && (!isNullOrUndefined(document.getElementById(this.element.id + '_toolbar')))) {
|
|
3194
|
+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
3195
|
+
toolbar.refreshOverflow();
|
|
3196
|
+
}
|
|
3197
|
+
}
|
|
3198
|
+
else {
|
|
3199
|
+
this.createLeftToolbarControls();
|
|
3200
|
+
if (this.defToolbarItems.length > 0 && (!isNullOrUndefined(document.getElementById(this.element.id + '_toolbar')))) {
|
|
3201
|
+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
3202
|
+
toolbar.refreshOverflow();
|
|
3203
|
+
}
|
|
3204
|
+
}
|
|
3205
|
+
}
|
|
3206
|
+
});
|
|
3207
|
+
if (Browser.isDevice) {
|
|
3208
|
+
toolbar.appendTo('#' + this.element.id + '_bottomToolbar');
|
|
3209
|
+
}
|
|
3210
|
+
else {
|
|
3211
|
+
toolbar.appendTo('#' + this.element.id + '_toolbar');
|
|
3212
|
+
}
|
|
3213
|
+
}
|
|
3214
|
+
initFilterToolbarItem() {
|
|
3215
|
+
const mainItem = this.getFilterToolbarItem();
|
|
3216
|
+
if (!isNullOrUndefined(document.querySelector('#' + this.element.id + '_contextualToolbar')) &&
|
|
3217
|
+
document.querySelector('#' + this.element.id + '_contextualToolbar').classList.contains('e-control')) {
|
|
3218
|
+
getComponent(document.getElementById(this.element.id + '_contextualToolbar'), 'toolbar').destroy();
|
|
3219
|
+
}
|
|
3220
|
+
const toolbar = new Toolbar({
|
|
3221
|
+
width: '100%',
|
|
3222
|
+
items: mainItem,
|
|
3223
|
+
clicked: this.contextualToolbarClicked.bind(this),
|
|
3224
|
+
created: () => {
|
|
3225
|
+
this.createCanvasFilter();
|
|
3226
|
+
if (this.currentFilter === '') {
|
|
3227
|
+
this.currentFilter = this.element.id + '_default';
|
|
3228
|
+
}
|
|
3229
|
+
const hdrWrapper = document.querySelector('#' + this.element.id + '_headWrapper');
|
|
3230
|
+
if (hdrWrapper) {
|
|
3231
|
+
hdrWrapper.style.display = 'none';
|
|
3232
|
+
}
|
|
3233
|
+
document.getElementById(this.currentFilter + 'Canvas').parentElement.parentElement.classList.add('e-selected');
|
|
3234
|
+
toolbar.refreshOverflow();
|
|
3235
|
+
}
|
|
3236
|
+
});
|
|
3237
|
+
toolbar.appendTo('#' + this.element.id + '_contextualToolbar');
|
|
3238
|
+
}
|
|
3239
|
+
createCanvasFilter() {
|
|
3240
|
+
if (this.adjustmentLevel.sharpen || this.adjustmentLevel.bw) {
|
|
3241
|
+
this.inMemoryContext.clearRect(0, 0, this.inMemoryCanvas.width, this.inMemoryCanvas.height);
|
|
3242
|
+
this.inMemoryCanvas.width = this.tempImageData.width;
|
|
3243
|
+
this.inMemoryCanvas.height = this.tempImageData.height;
|
|
3244
|
+
this.inMemoryContext.putImageData(this.tempImageData, 0, 0);
|
|
3245
|
+
}
|
|
3246
|
+
const noFilter = document.querySelector('#' + this.element.id + '_defaultCanvas');
|
|
3247
|
+
noFilter.style.width = '100px';
|
|
3248
|
+
noFilter.style.height = '100px';
|
|
3249
|
+
noFilter.style.filter = this.updateAdjustment('default', null, true);
|
|
3250
|
+
let ctx = noFilter.getContext('2d');
|
|
3251
|
+
ctx.drawImage(this.inMemoryCanvas, 0, 0, 300, 150);
|
|
3252
|
+
const chrome = document.querySelector('#' + this.element.id + '_chromeCanvas');
|
|
3253
|
+
chrome.style.width = '100px';
|
|
3254
|
+
chrome.style.height = '100px';
|
|
3255
|
+
chrome.style.filter = this.updateAdjustment('chrome', null, true);
|
|
3256
|
+
ctx = chrome.getContext('2d');
|
|
3257
|
+
ctx.drawImage(this.inMemoryCanvas, 0, 0, 300, 150);
|
|
3258
|
+
const cold = document.querySelector('#' + this.element.id + '_coldCanvas');
|
|
3259
|
+
cold.style.width = '100px';
|
|
3260
|
+
cold.style.height = '100px';
|
|
3261
|
+
cold.style.filter = this.updateAdjustment('cold', null, true);
|
|
3262
|
+
ctx = cold.getContext('2d');
|
|
3263
|
+
ctx.drawImage(this.inMemoryCanvas, 0, 0, 300, 150);
|
|
3264
|
+
const warm = document.querySelector('#' + this.element.id + '_warmCanvas');
|
|
3265
|
+
warm.style.width = '100px';
|
|
3266
|
+
warm.style.height = '100px';
|
|
3267
|
+
warm.style.filter = this.updateAdjustment('warm', null, true);
|
|
3268
|
+
ctx = warm.getContext('2d');
|
|
3269
|
+
ctx.drawImage(this.inMemoryCanvas, 0, 0, 300, 150);
|
|
3270
|
+
const temp = this.lowerContext.filter;
|
|
3271
|
+
this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
|
|
3272
|
+
'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
|
|
3273
|
+
for (let i = 0; i < this.objColl.length; i++) {
|
|
3274
|
+
this.apply(this.objColl[i].shape, this.objColl[i]);
|
|
3275
|
+
this.refreshActiveObj();
|
|
3276
|
+
}
|
|
3277
|
+
this.lowerContext.filter = temp;
|
|
3278
|
+
const grayscale = document.querySelector('#' + this.element.id + '_grayscaleCanvas');
|
|
3279
|
+
grayscale.style.width = '100px';
|
|
3280
|
+
grayscale.style.height = '100px';
|
|
3281
|
+
grayscale.style.filter = this.updateAdjustment('grayscale', null, true);
|
|
3282
|
+
ctx = grayscale.getContext('2d');
|
|
3283
|
+
ctx.drawImage(this.inMemoryCanvas, 0, 0, 300, 150);
|
|
3284
|
+
const tempFilter = this.lowerContext.filter;
|
|
3285
|
+
this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
|
|
3286
|
+
'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
|
|
3287
|
+
for (let i = 0; i < this.objColl.length; i++) {
|
|
3288
|
+
this.apply(this.objColl[i].shape, this.objColl[i]);
|
|
3289
|
+
this.refreshActiveObj();
|
|
3290
|
+
}
|
|
3291
|
+
this.lowerContext.filter = tempFilter;
|
|
3292
|
+
const sepia = document.querySelector('#' + this.element.id + '_sepiaCanvas');
|
|
3293
|
+
sepia.style.width = '100px';
|
|
3294
|
+
sepia.style.height = '100px';
|
|
3295
|
+
sepia.style.filter = this.updateAdjustment('sepia', null, true);
|
|
3296
|
+
ctx = sepia.getContext('2d');
|
|
3297
|
+
ctx.drawImage(this.inMemoryCanvas, 0, 0, 300, 150);
|
|
3298
|
+
const invert = document.querySelector('#' + this.element.id + '_invertCanvas');
|
|
3299
|
+
invert.style.width = '100px';
|
|
3300
|
+
invert.style.height = '100px';
|
|
3301
|
+
invert.style.filter = this.updateAdjustment('invert', null, true);
|
|
3302
|
+
ctx = invert.getContext('2d');
|
|
3303
|
+
ctx.drawImage(this.inMemoryCanvas, 0, 0, 300, 150);
|
|
3304
|
+
}
|
|
2097
3305
|
updateCanvas() {
|
|
2098
3306
|
this.lastX = this.baseImg.width / 2;
|
|
2099
3307
|
this.lastY = this.baseImg.height / 2;
|
|
@@ -2112,9 +3320,10 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
2112
3320
|
maxDimension.width -= toolbarHeight;
|
|
2113
3321
|
maxDimension.height -= toolbarHeight;
|
|
2114
3322
|
}
|
|
3323
|
+
const tempFilter = this.lowerContext.filter;
|
|
2115
3324
|
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
2116
|
-
this.lowerCanvas.width = this.upperCanvas.width = this.
|
|
2117
|
-
this.lowerCanvas.height = this.upperCanvas.height = this.
|
|
3325
|
+
this.lowerCanvas.width = this.upperCanvas.width = this.baseImg.width;
|
|
3326
|
+
this.lowerCanvas.height = this.upperCanvas.height = this.baseImg.height;
|
|
2118
3327
|
this.lowerCanvas.style.maxWidth = this.upperCanvas.style.maxWidth = maxDimension.width + 'px';
|
|
2119
3328
|
this.lowerCanvas.style.maxHeight = this.upperCanvas.style.maxHeight = maxDimension.height + 'px';
|
|
2120
3329
|
this.lowerCanvas.style.left = this.upperCanvas.style.left = (wrapperWidth - maxDimension.width) / 2 + 1 + 'px';
|
|
@@ -2124,16 +3333,37 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
2124
3333
|
if (canvasWrapper) {
|
|
2125
3334
|
this.lowerCanvas.style.top = this.upperCanvas.style.top = (parseFloat(canvasWrapper.style.height) - maxDimension.height - 1) / 2 + 'px';
|
|
2126
3335
|
}
|
|
2127
|
-
this.lowerContext.
|
|
2128
|
-
this.
|
|
3336
|
+
this.lowerContext.filter = tempFilter;
|
|
3337
|
+
if (this.lowerContext.filter === 'none' || this.lowerContext.filter === 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
|
|
3338
|
+
'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)' ||
|
|
3339
|
+
this.isInitialLoading) {
|
|
3340
|
+
this.lowerContext.drawImage(this.baseImg, 0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
3341
|
+
this.updateInMemoryCanvas('updateCanvas');
|
|
3342
|
+
if (this.canvasFilter !== 'none') {
|
|
3343
|
+
this.lowerContext.filter = this.canvasFilter;
|
|
3344
|
+
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
3345
|
+
this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
|
|
3346
|
+
}
|
|
3347
|
+
if (this.isInitialLoading) {
|
|
3348
|
+
this.initializeFilter();
|
|
3349
|
+
this.isInitialLoading = false;
|
|
3350
|
+
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
3351
|
+
this.lowerContext.drawImage(this.baseImg, 0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
3352
|
+
}
|
|
3353
|
+
}
|
|
3354
|
+
else {
|
|
3355
|
+
const temp = this.lowerContext.filter;
|
|
3356
|
+
this.updateBrightnessFilter();
|
|
3357
|
+
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
3358
|
+
this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
|
|
3359
|
+
this.lowerContext.filter = temp;
|
|
3360
|
+
}
|
|
3361
|
+
this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
|
|
3362
|
+
'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
|
|
2129
3363
|
for (let i = 0, len = this.objColl.length; i < len; i++) {
|
|
2130
3364
|
this.apply(this.objColl[i].shape, this.objColl[i]);
|
|
2131
3365
|
}
|
|
2132
|
-
|
|
2133
|
-
if (this.flipState !== '') {
|
|
2134
|
-
this.flip(this.flipState);
|
|
2135
|
-
}
|
|
2136
|
-
}
|
|
3366
|
+
this.lowerContext.filter = tempFilter;
|
|
2137
3367
|
if (this.disabled) {
|
|
2138
3368
|
this.element.setAttribute('class', 'e-disabled');
|
|
2139
3369
|
}
|
|
@@ -2142,7 +3372,7 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
2142
3372
|
imageOnLoad(src) {
|
|
2143
3373
|
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
2144
3374
|
const proxy = this;
|
|
2145
|
-
proxy.baseImg.src = proxy.baseImgSrc = src;
|
|
3375
|
+
proxy.baseImg.src = proxy.baseImgSrc.id = src;
|
|
2146
3376
|
this.baseImg.onload = () => {
|
|
2147
3377
|
this.lowerContext.drawImage(this.baseImg, 0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
2148
3378
|
if (this.togglePen) {
|
|
@@ -2163,7 +3393,6 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
2163
3393
|
hideSpinner(this.element);
|
|
2164
3394
|
this.element.style.opacity = '1';
|
|
2165
3395
|
this.updateCanvas();
|
|
2166
|
-
this.isUndoRedo = false;
|
|
2167
3396
|
}
|
|
2168
3397
|
if (Browser.isDevice) {
|
|
2169
3398
|
if (this.isToolbar() && (!isNullOrUndefined(document.getElementById(this.element.id + '_toolbar'))) &&
|
|
@@ -2340,9 +3569,6 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
2340
3569
|
this.degree = 0;
|
|
2341
3570
|
}
|
|
2342
3571
|
}
|
|
2343
|
-
updateUndoRedoColl(operation, value, previousObj, currentObj) {
|
|
2344
|
-
this.undoRedoColl.push({ operation: operation, value: value, previousObj: previousObj, currentObj: currentObj });
|
|
2345
|
-
}
|
|
2346
3572
|
fileSelect(inputElement, args) {
|
|
2347
3573
|
showSpinner(this.element);
|
|
2348
3574
|
this.element.style.opacity = '0.5';
|
|
@@ -2501,7 +3727,7 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
2501
3727
|
}
|
|
2502
3728
|
if (strokeWidthElem) {
|
|
2503
3729
|
const strokeWidth = Math.round((this.activeObj.strokeSettings.strokeWidth /
|
|
2504
|
-
(ratio.width + ratio.height))).toString();
|
|
3730
|
+
(ratio.width + ratio.height)) * this.factor).toString();
|
|
2505
3731
|
strokeWidthElem.textContent = this.getStrokeWidth(strokeWidth);
|
|
2506
3732
|
}
|
|
2507
3733
|
}
|
|
@@ -2513,10 +3739,32 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
2513
3739
|
}
|
|
2514
3740
|
}
|
|
2515
3741
|
}
|
|
3742
|
+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
3743
|
+
targetTouches(touches) {
|
|
3744
|
+
const p1 = { x: touches[0].pageX, y: touches[0].pageY };
|
|
3745
|
+
const p2 = { x: touches[1].pageX, y: touches[1].pageY };
|
|
3746
|
+
const points = [p1, p2];
|
|
3747
|
+
return points;
|
|
3748
|
+
}
|
|
3749
|
+
calculateScale(startTouches, endTouches) {
|
|
3750
|
+
const startDistance = this.getDistance(startTouches[0], startTouches[1]);
|
|
3751
|
+
const endDistance = this.getDistance(endTouches[0], endTouches[1]);
|
|
3752
|
+
return endDistance / startDistance;
|
|
3753
|
+
}
|
|
3754
|
+
getDistance(a, b) {
|
|
3755
|
+
const x = a.x - b.x;
|
|
3756
|
+
const y = a.y - b.y;
|
|
3757
|
+
return Math.sqrt(x * x + y * y);
|
|
3758
|
+
}
|
|
2516
3759
|
touchStartHandler(e) {
|
|
2517
3760
|
e.preventDefault();
|
|
2518
|
-
|
|
2519
|
-
|
|
3761
|
+
if (e.touches.length === 2) {
|
|
3762
|
+
this.isFirstMove = true;
|
|
3763
|
+
}
|
|
3764
|
+
else {
|
|
3765
|
+
this.timer = setTimeout(this.setTimer.bind(this), 1000, e);
|
|
3766
|
+
this.mouseDownEventHandler(e);
|
|
3767
|
+
}
|
|
2520
3768
|
EventHandler.add(this.lowerCanvas, 'touchend', this.mouseUpEventHandler, this);
|
|
2521
3769
|
EventHandler.add(this.lowerCanvas, 'touchmove', this.mouseMoveEventHandler, this); // Unbind mousedown to prevent double triggers from touch devices
|
|
2522
3770
|
EventHandler.add(this.upperCanvas, 'touchend', this.mouseUpEventHandler, this);
|
|
@@ -2543,6 +3791,14 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
2543
3791
|
this.touchEndPoint.y = y = e.touches[0].clientY;
|
|
2544
3792
|
}
|
|
2545
3793
|
this.redrawActObj(x, y);
|
|
3794
|
+
if ((!isNullOrUndefined(this.element.querySelector('#' + this.element.id + '_contextualToolbar')) &&
|
|
3795
|
+
!this.element.querySelector('#' + this.element.id + '_contextualToolbar').parentElement.classList.contains('e-hide')) ||
|
|
3796
|
+
(!isNullOrUndefined(this.element.querySelector('#' + this.element.id + '_headWrapper'))
|
|
3797
|
+
&& !this.element.querySelector('#' + this.element.id + '_headWrapper').parentElement.classList.contains('e-hide'))) {
|
|
3798
|
+
this.element.querySelector('.e-contextual-toolbar-wrapper').classList.add('e-hide');
|
|
3799
|
+
this.okBtn();
|
|
3800
|
+
this.refreshToolbar('main');
|
|
3801
|
+
}
|
|
2546
3802
|
if (this.upperCanvas.style.cursor === 'crosshair' || (Browser.isDevice && this.togglePen)) {
|
|
2547
3803
|
if (this.togglePen) {
|
|
2548
3804
|
this.canvasRatio = this.calcRatio();
|
|
@@ -2606,6 +3862,47 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
2606
3862
|
}
|
|
2607
3863
|
mouseMoveEventHandler(e) {
|
|
2608
3864
|
e.preventDefault();
|
|
3865
|
+
if (e.type === 'touchmove' && e.touches.length === 2) {
|
|
3866
|
+
if (this.isFirstMove) {
|
|
3867
|
+
this.startTouches = this.targetTouches(e.touches);
|
|
3868
|
+
this.tempTouches = [];
|
|
3869
|
+
this.tempTouches.push({ x: e.touches[0].clientX || (e.touches[0].pageX - this.lowerCanvas.offsetLeft),
|
|
3870
|
+
y: e.touches[0].clientY || (e.touches[0].pageY - this.lowerCanvas.offsetTop) });
|
|
3871
|
+
this.tempTouches.push({ x: e.touches[1].clientX || (e.touches[1].pageX - this.lowerCanvas.offsetLeft),
|
|
3872
|
+
y: e.touches[1].clientY || (e.touches[1].pageY - this.lowerCanvas.offsetTop) });
|
|
3873
|
+
}
|
|
3874
|
+
else {
|
|
3875
|
+
const ratio = this.calcRatio();
|
|
3876
|
+
const firstFingerX = e.touches[0].clientX || (e.touches[0].pageX - this.lowerCanvas.offsetLeft);
|
|
3877
|
+
const firstFingerY = e.touches[0].clientY || (e.touches[0].pageY - this.lowerCanvas.offsetTop);
|
|
3878
|
+
const secondFingerX = e.touches[1].clientX || (e.touches[1].pageX - this.lowerCanvas.offsetLeft);
|
|
3879
|
+
const secondFingerY = e.touches[1].clientY || (e.touches[1].pageY - this.lowerCanvas.offsetTop);
|
|
3880
|
+
this.lastX = firstFingerX > secondFingerX ? secondFingerX + (firstFingerX - secondFingerX) : firstFingerX +
|
|
3881
|
+
(secondFingerX - firstFingerX);
|
|
3882
|
+
this.lastY = firstFingerY > secondFingerY ? secondFingerY + (firstFingerY - secondFingerY) : firstFingerY +
|
|
3883
|
+
(secondFingerY - firstFingerY);
|
|
3884
|
+
this.lastX *= ratio.width;
|
|
3885
|
+
this.lastY *= ratio.height;
|
|
3886
|
+
const scale = this.calculateScale(this.startTouches, this.targetTouches(e.touches));
|
|
3887
|
+
// Need to set lastX and lastY points
|
|
3888
|
+
if (this.tempTouches[0].x !== firstFingerX && this.tempTouches[0].y !== firstFingerY &&
|
|
3889
|
+
this.tempTouches[1].x !== secondFingerX && this.tempTouches[1].y !== secondFingerY) {
|
|
3890
|
+
if (scale > 1) {
|
|
3891
|
+
this.zoom(1.1);
|
|
3892
|
+
}
|
|
3893
|
+
else {
|
|
3894
|
+
this.zoom(-1.1);
|
|
3895
|
+
}
|
|
3896
|
+
this.tempTouches = [];
|
|
3897
|
+
this.tempTouches.push({ x: e.touches[0].clientX || (e.touches[0].pageX - this.lowerCanvas.offsetLeft),
|
|
3898
|
+
y: e.touches[0].clientY || (e.touches[0].pageY - this.lowerCanvas.offsetTop) });
|
|
3899
|
+
this.tempTouches.push({ x: e.touches[1].clientX || (e.touches[1].pageX - this.lowerCanvas.offsetLeft),
|
|
3900
|
+
y: e.touches[1].clientY || (e.touches[1].pageY - this.lowerCanvas.offsetTop) });
|
|
3901
|
+
}
|
|
3902
|
+
}
|
|
3903
|
+
this.isFirstMove = false;
|
|
3904
|
+
return;
|
|
3905
|
+
}
|
|
2609
3906
|
if (this.textBox.style.display === 'none') {
|
|
2610
3907
|
this.isTimer = true;
|
|
2611
3908
|
}
|
|
@@ -2624,6 +3921,11 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
2624
3921
|
!this.dragCanvas || this.activeObj.activePoint !== undefined) {
|
|
2625
3922
|
if (this.dragElement === '') {
|
|
2626
3923
|
this.setCursor(x, y);
|
|
3924
|
+
if (this.activeObj.activePoint.width === 0 && this.upperCanvas.style.cursor !== 'default' &&
|
|
3925
|
+
this.upperCanvas.style.cursor !== 'move' && this.upperCanvas.style.cursor !== 'crosshair'
|
|
3926
|
+
&& this.upperCanvas.style.cursor !== 'grab') {
|
|
3927
|
+
this.upperCanvas.style.cursor = 'move';
|
|
3928
|
+
}
|
|
2627
3929
|
this.findTarget(x, y, e.type);
|
|
2628
3930
|
}
|
|
2629
3931
|
}
|
|
@@ -2646,6 +3948,8 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
2646
3948
|
y = this.touchEndPoint.y;
|
|
2647
3949
|
}
|
|
2648
3950
|
if (e.type === 'touchend') {
|
|
3951
|
+
this.startTouches = this.tempTouches = [];
|
|
3952
|
+
this.isFirstMove = false;
|
|
2649
3953
|
if (this.textBox.style.display === 'none') {
|
|
2650
3954
|
this.isTimer = false;
|
|
2651
3955
|
this.timer = 0;
|
|
@@ -2664,8 +3968,16 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
2664
3968
|
if (e.currentTarget === this.upperCanvas) {
|
|
2665
3969
|
this.currObjType.shape = this.currObjType.shape.toLowerCase();
|
|
2666
3970
|
if (!this.togglePen && !this.dragCanvas) {
|
|
3971
|
+
if (!isNullOrUndefined(this.tempObjColl) && this.activeObj.activePoint.width !== 0) {
|
|
3972
|
+
this.objColl.push(this.activeObj);
|
|
3973
|
+
this.redrawShape(this.objColl[this.objColl.length - 1]);
|
|
3974
|
+
this.tempObjColl = undefined;
|
|
3975
|
+
}
|
|
2667
3976
|
this.applyCurrActObj(x, y);
|
|
2668
3977
|
}
|
|
3978
|
+
else if (this.dragCanvas) {
|
|
3979
|
+
this.setPanPoints();
|
|
3980
|
+
}
|
|
2669
3981
|
}
|
|
2670
3982
|
if (this.togglePen && e.currentTarget === this.upperCanvas) {
|
|
2671
3983
|
this.penDrawColl.push({ strokeWidth: this.penStrokeWidth, strokeColor: this.activeObj.strokeSettings.strokeColor, points: this.imageEditorPointsColl });
|
|
@@ -2693,11 +4005,13 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
2693
4005
|
e.stopImmediatePropagation();
|
|
2694
4006
|
break;
|
|
2695
4007
|
case 'Delete':
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
4008
|
+
if (this.textBox.style.display === 'none') {
|
|
4009
|
+
shapeChangingArgs = { action: 'delete', previousShapeSettings: this.activeObj, currentShapeSettings: null };
|
|
4010
|
+
this.keyHistory = '';
|
|
4011
|
+
this.clearSelection();
|
|
4012
|
+
this.trigger('shapeChanging', shapeChangingArgs);
|
|
4013
|
+
this.refreshToolbar('main');
|
|
4014
|
+
}
|
|
2701
4015
|
break;
|
|
2702
4016
|
case 'Escape':
|
|
2703
4017
|
if (this.togglePan) {
|
|
@@ -2719,7 +4033,10 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
2719
4033
|
}
|
|
2720
4034
|
}
|
|
2721
4035
|
keyUpEventHandler(e) {
|
|
2722
|
-
|
|
4036
|
+
// eslint-disable-next-line
|
|
4037
|
+
if (this.textBox.style.display === 'block' && e.target.id === this.element.id + '_textBox') {
|
|
4038
|
+
setTimeout(this.textKeyDown.bind(this), 1, e);
|
|
4039
|
+
}
|
|
2723
4040
|
}
|
|
2724
4041
|
canvasMouseDownHandler(e) {
|
|
2725
4042
|
e.preventDefault();
|
|
@@ -2737,7 +4054,6 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
2737
4054
|
if (this.dragCanvas || this.factor !== 1) {
|
|
2738
4055
|
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
2739
4056
|
this.dragStart = this.lowerContext.transformedPoint(this.lastX, this.lastY);
|
|
2740
|
-
this.dragged = false;
|
|
2741
4057
|
}
|
|
2742
4058
|
}
|
|
2743
4059
|
canvasMouseMoveHandler(e) {
|
|
@@ -2759,55 +4075,39 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
2759
4075
|
}
|
|
2760
4076
|
this.lastX *= ratio.width;
|
|
2761
4077
|
this.lastY *= ratio.height;
|
|
2762
|
-
this.dragged = true;
|
|
2763
4078
|
if (this.dragStart && this.dragCanvas) {
|
|
2764
|
-
|
|
2765
|
-
const pt = this.lowerContext.transformedPoint(this.lastX, this.lastY);
|
|
2766
|
-
const transitionArgs = { startPoint: { x: this.dragStart.x, y: this.dragStart.y },
|
|
2767
|
-
endPoint: { x: pt.x, y: pt.y } };
|
|
2768
|
-
this.trigger('panning', transitionArgs);
|
|
2769
|
-
let xDiff = pt.x - this.dragStart.x;
|
|
2770
|
-
let yDiff = pt.y - this.dragStart.y;
|
|
2771
|
-
const xxDiff = xDiff;
|
|
2772
|
-
const yyDiff = yDiff;
|
|
2773
|
-
this.lowerContext.translate(xDiff, yDiff);
|
|
2774
|
-
this.upperContext.translate(xDiff, yDiff);
|
|
2775
|
-
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
2776
|
-
const pt1 = this.lowerContext.transformedPoint(0, 0);
|
|
2777
|
-
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
2778
|
-
const pt2 = this.lowerContext.transformedPoint(this.lowerCanvas.width, this.lowerCanvas.height);
|
|
2779
|
-
if (xDiff >= 0) {
|
|
2780
|
-
if (pt1.x < 1) {
|
|
2781
|
-
xDiff = 0;
|
|
2782
|
-
}
|
|
2783
|
-
}
|
|
2784
|
-
else {
|
|
2785
|
-
if (pt2.x > this.lowerCanvas.width) {
|
|
2786
|
-
xDiff = 0;
|
|
2787
|
-
}
|
|
2788
|
-
}
|
|
2789
|
-
if (yDiff >= 0) {
|
|
2790
|
-
if (pt1.y < 1) {
|
|
2791
|
-
yDiff = 0;
|
|
2792
|
-
}
|
|
2793
|
-
}
|
|
2794
|
-
else {
|
|
2795
|
-
if (pt2.y > this.lowerCanvas.height) {
|
|
2796
|
-
yDiff = 0;
|
|
2797
|
-
}
|
|
2798
|
-
}
|
|
2799
|
-
this.lowerContext.translate(-xxDiff, -yyDiff);
|
|
2800
|
-
this.upperContext.translate(-xxDiff, -yyDiff);
|
|
2801
|
-
this.lowerContext.translate(xDiff, yDiff);
|
|
2802
|
-
this.upperContext.translate(xDiff, yDiff);
|
|
2803
|
-
this.redraw();
|
|
4079
|
+
this.drawPanImg();
|
|
2804
4080
|
}
|
|
2805
4081
|
}
|
|
2806
4082
|
canvasMouseUpHandler(e) {
|
|
2807
4083
|
e.preventDefault();
|
|
4084
|
+
if (this.togglePan && e.currentTarget === this.lowerCanvas) {
|
|
4085
|
+
const ratio = this.calcRatio();
|
|
4086
|
+
if (e.type === 'mouseup') {
|
|
4087
|
+
this.lastX = e.offsetX || (e.pageX - this.lowerCanvas.offsetLeft);
|
|
4088
|
+
this.lastY = e.offsetY || (e.pageY - this.lowerCanvas.offsetTop);
|
|
4089
|
+
}
|
|
4090
|
+
else {
|
|
4091
|
+
this.lastX = e.touches[0].clientX || (e.touches[0].pageX - this.lowerCanvas.offsetLeft);
|
|
4092
|
+
this.lastY = e.touches[0].clientY || (e.touches[0].pageY - this.lowerCanvas.offsetTop);
|
|
4093
|
+
}
|
|
4094
|
+
this.lastX *= ratio.width;
|
|
4095
|
+
this.lastY *= ratio.height;
|
|
4096
|
+
this.setPanPoints();
|
|
4097
|
+
}
|
|
2808
4098
|
this.dragStart = null;
|
|
4099
|
+
// zooms on mouse click point
|
|
4100
|
+
// if (e.currentTarget !== document) {
|
|
4101
|
+
// this.zoom(e.shiftKey ? -1 : 1 );
|
|
4102
|
+
// }
|
|
2809
4103
|
this.currObjType.isDragging = false;
|
|
2810
4104
|
}
|
|
4105
|
+
setPanPoints() {
|
|
4106
|
+
if (this.dragCanvas || this.factor !== 1) {
|
|
4107
|
+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
4108
|
+
this.dragStart = this.lowerContext.transformedPoint(this.lastX, this.lastY);
|
|
4109
|
+
}
|
|
4110
|
+
}
|
|
2811
4111
|
textKeyDown(e) {
|
|
2812
4112
|
if (String.fromCharCode(e.which) === '\r') {
|
|
2813
4113
|
this.textRow += 1;
|
|
@@ -2826,6 +4126,8 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
2826
4126
|
adjustToScreen() {
|
|
2827
4127
|
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
2828
4128
|
const proxy = this;
|
|
4129
|
+
const tempFilter = this.lowerContext.filter;
|
|
4130
|
+
this.okBtn();
|
|
2829
4131
|
this.applyActObj();
|
|
2830
4132
|
this.refreshActiveObj();
|
|
2831
4133
|
if (this.imgDataColl.length > 0) {
|
|
@@ -2847,15 +4149,32 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
2847
4149
|
canvasWrapper.style.height = (parseFloat(canvasWrapper.style.height) - this.toolbarHeight) - 3 + 'px';
|
|
2848
4150
|
}
|
|
2849
4151
|
}
|
|
2850
|
-
this.redrawImg();
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
4152
|
+
this.redrawImg(tempFilter);
|
|
4153
|
+
if (!this.currObjType.isSave) {
|
|
4154
|
+
// eslint-disable-next-line @typescript-eslint/tslint/config
|
|
4155
|
+
this.lowerCanvas.toBlob(function (blob) {
|
|
4156
|
+
proxy.lowerContext.filter = proxy.initialAdjustmentValue = proxy.adjustmentValue = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
|
|
4157
|
+
'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
|
|
4158
|
+
if (proxy.cssClass) {
|
|
4159
|
+
addClass([proxy.element], proxy.cssClass.split(' '));
|
|
4160
|
+
}
|
|
4161
|
+
proxy.lowerContext.clearRect(0, 0, proxy.lowerCanvas.width, proxy.lowerCanvas.height);
|
|
4162
|
+
proxy.lowerContext.drawImage(proxy.inMemoryCanvas, 0, 0);
|
|
4163
|
+
proxy.baseImg.src = URL.createObjectURL(blob);
|
|
4164
|
+
proxy.lowerContext.filter = tempFilter;
|
|
4165
|
+
}, 'image/png');
|
|
4166
|
+
}
|
|
4167
|
+
else {
|
|
4168
|
+
hideSpinner(this.element);
|
|
4169
|
+
this.element.style.opacity = '1';
|
|
4170
|
+
}
|
|
2855
4171
|
if (this.defToolbarItems.length > 0 && (!isNullOrUndefined(document.getElementById(this.element.id + '_toolbar')))) {
|
|
2856
4172
|
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
2857
4173
|
const toolbar = getComponent(proxy.element.id + '_toolbar', 'toolbar');
|
|
2858
4174
|
toolbar.refreshOverflow();
|
|
4175
|
+
if (!isNullOrUndefined(this.element.querySelector('.e-contextual-toolbar-wrapper'))) {
|
|
4176
|
+
this.element.querySelector('.e-contextual-toolbar-wrapper').classList.add('e-hide');
|
|
4177
|
+
}
|
|
2859
4178
|
}
|
|
2860
4179
|
}
|
|
2861
4180
|
screenOrientation() {
|
|
@@ -2869,7 +4188,49 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
2869
4188
|
this.adjustToScreen();
|
|
2870
4189
|
}
|
|
2871
4190
|
}
|
|
2872
|
-
|
|
4191
|
+
drawPanImg() {
|
|
4192
|
+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
4193
|
+
const pt = this.lowerContext.transformedPoint(this.lastX, this.lastY);
|
|
4194
|
+
const transitionArgs = { startPoint: { x: this.dragStart.x, y: this.dragStart.y },
|
|
4195
|
+
endPoint: { x: pt.x, y: pt.y } };
|
|
4196
|
+
this.trigger('panning', transitionArgs);
|
|
4197
|
+
let xDiff = pt.x - this.dragStart.x;
|
|
4198
|
+
let yDiff = pt.y - this.dragStart.y;
|
|
4199
|
+
const xxDiff = xDiff;
|
|
4200
|
+
const yyDiff = yDiff;
|
|
4201
|
+
this.lowerContext.translate(xDiff, yDiff);
|
|
4202
|
+
this.upperContext.translate(xDiff, yDiff);
|
|
4203
|
+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
4204
|
+
const pt1 = this.lowerContext.transformedPoint(0, 0);
|
|
4205
|
+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
4206
|
+
const pt2 = this.lowerContext.transformedPoint(this.lowerCanvas.width, this.lowerCanvas.height);
|
|
4207
|
+
if (xDiff >= 0) {
|
|
4208
|
+
if (pt1.x < 1) {
|
|
4209
|
+
xDiff = 0;
|
|
4210
|
+
}
|
|
4211
|
+
}
|
|
4212
|
+
else {
|
|
4213
|
+
if (pt2.x > this.lowerCanvas.width) {
|
|
4214
|
+
xDiff = 0;
|
|
4215
|
+
}
|
|
4216
|
+
}
|
|
4217
|
+
if (yDiff >= 0) {
|
|
4218
|
+
if (pt1.y < 1) {
|
|
4219
|
+
yDiff = 0;
|
|
4220
|
+
}
|
|
4221
|
+
}
|
|
4222
|
+
else {
|
|
4223
|
+
if (pt2.y > this.lowerCanvas.height) {
|
|
4224
|
+
yDiff = 0;
|
|
4225
|
+
}
|
|
4226
|
+
}
|
|
4227
|
+
this.lowerContext.translate(-xxDiff, -yyDiff);
|
|
4228
|
+
this.upperContext.translate(-xxDiff, -yyDiff);
|
|
4229
|
+
this.lowerContext.translate(xDiff, yDiff);
|
|
4230
|
+
this.upperContext.translate(xDiff, yDiff);
|
|
4231
|
+
this.redraw();
|
|
4232
|
+
}
|
|
4233
|
+
redrawImg(tempFilter) {
|
|
2873
4234
|
let wrapperWidth;
|
|
2874
4235
|
const canvasWrapper = document.querySelector('#' + this.element.id + '_canvasWrapper');
|
|
2875
4236
|
if (this.isScreenOriented) {
|
|
@@ -2885,14 +4246,24 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
2885
4246
|
this.lowerCanvas.style.maxHeight = this.upperCanvas.style.maxHeight = maxDimension.height + 'px';
|
|
2886
4247
|
this.lowerCanvas.style.left = this.upperCanvas.style.left = (wrapperWidth - maxDimension.width) / 2 + 1 + 'px';
|
|
2887
4248
|
this.lowerCanvas.style.top = this.upperCanvas.style.top = (this.element.offsetHeight - this.toolbarHeight - maxDimension.height) / 2 + 1 + 'px';
|
|
4249
|
+
this.lowerContext.filter = tempFilter;
|
|
4250
|
+
const temp = this.lowerContext.filter;
|
|
4251
|
+
this.updateBrightnessFilter();
|
|
2888
4252
|
this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
4253
|
+
this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
|
|
4254
|
+
'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
|
|
4255
|
+
for (let i = 0; i < this.objColl.length; i++) {
|
|
4256
|
+
this.apply(this.objColl[i].shape, this.objColl[i]);
|
|
4257
|
+
this.refreshActiveObj();
|
|
4258
|
+
}
|
|
4259
|
+
this.lowerContext.filter = temp;
|
|
2889
4260
|
}
|
|
2890
4261
|
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
2891
4262
|
updateContext(ctx) {
|
|
2892
4263
|
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
2893
4264
|
const proxy = this;
|
|
2894
4265
|
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
2895
|
-
let xform = new DOMMatrix();
|
|
4266
|
+
let xform = new DOMMatrix([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
|
|
2896
4267
|
ctx.getTransform = () => {
|
|
2897
4268
|
return xform;
|
|
2898
4269
|
};
|
|
@@ -2961,6 +4332,7 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
2961
4332
|
return pt.matrixTransform(xform.inverse());
|
|
2962
4333
|
};
|
|
2963
4334
|
}
|
|
4335
|
+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
2964
4336
|
scaleNonUniform(xform, sx, sy) {
|
|
2965
4337
|
xform.m11 *= sx;
|
|
2966
4338
|
xform.m12 *= sx;
|
|
@@ -2997,11 +4369,7 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
2997
4369
|
this.upperContext.setTransform(1, 0, 0, 1, 0, 0);
|
|
2998
4370
|
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
2999
4371
|
this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
|
|
3000
|
-
this.
|
|
3001
|
-
for (let j = 0; j < this.objColl.length; j++) {
|
|
3002
|
-
this.apply(this.objColl[j].shape, this.objColl[j]);
|
|
3003
|
-
this.refreshActiveObj();
|
|
3004
|
-
}
|
|
4372
|
+
this.redrawImgWithObj();
|
|
3005
4373
|
}
|
|
3006
4374
|
else {
|
|
3007
4375
|
if (this.factor > 1) {
|
|
@@ -3064,11 +4432,7 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
3064
4432
|
this.upperContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
3065
4433
|
this.lowerContext.restore();
|
|
3066
4434
|
this.upperContext.restore();
|
|
3067
|
-
this.
|
|
3068
|
-
for (let j = 0; j < this.objColl.length; j++) {
|
|
3069
|
-
this.apply(this.objColl[j].shape, this.objColl[j]);
|
|
3070
|
-
this.refreshActiveObj();
|
|
3071
|
-
}
|
|
4435
|
+
this.redrawImgWithObj();
|
|
3072
4436
|
}
|
|
3073
4437
|
applyCurrActObj(x, y) {
|
|
3074
4438
|
let isInside = false;
|
|
@@ -3092,9 +4456,13 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
3092
4456
|
}
|
|
3093
4457
|
if (this.activeObj.shape === 'text' || (this.currObjType.shape === 'ellipse' || this.currObjType.shape === 'rectangle' ||
|
|
3094
4458
|
this.currObjType.shape === 'line')) {
|
|
4459
|
+
const tempFilter = this.lowerContext.filter;
|
|
4460
|
+
this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
|
|
4461
|
+
'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
|
|
3095
4462
|
for (let j = 0; j < this.objColl.length; j++) {
|
|
3096
4463
|
this.apply(this.objColl[j].shape, this.objColl[j]);
|
|
3097
4464
|
}
|
|
4465
|
+
this.lowerContext.filter = tempFilter;
|
|
3098
4466
|
this.apply('shape');
|
|
3099
4467
|
}
|
|
3100
4468
|
}
|
|
@@ -3120,6 +4488,24 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
3120
4488
|
this.setTextSelection(width, height);
|
|
3121
4489
|
this.updateActiveObject(ratio, this.activeObj.activePoint, this.activeObj);
|
|
3122
4490
|
}
|
|
4491
|
+
setTextBoxStylesToActObj() {
|
|
4492
|
+
const ratio = this.calcRatio();
|
|
4493
|
+
this.activeObj.textSettings.fontFamily = this.textBox.style.fontFamily;
|
|
4494
|
+
this.activeObj.strokeSettings.strokeColor = this.textBox.style.color;
|
|
4495
|
+
if (this.textBox.style.fontWeight === 'bold') {
|
|
4496
|
+
this.activeObj.textSettings.bold = true;
|
|
4497
|
+
}
|
|
4498
|
+
else {
|
|
4499
|
+
this.activeObj.textSettings.bold = false;
|
|
4500
|
+
}
|
|
4501
|
+
if (this.textBox.style.fontStyle === 'italic') {
|
|
4502
|
+
this.activeObj.textSettings.italic = true;
|
|
4503
|
+
}
|
|
4504
|
+
else {
|
|
4505
|
+
this.activeObj.textSettings.italic = false;
|
|
4506
|
+
}
|
|
4507
|
+
this.activeObj.textSettings.fontSize = (parseFloat(this.textBox.style.fontSize) * ((ratio.width + ratio.height) / 2)) / this.factor;
|
|
4508
|
+
}
|
|
3123
4509
|
redrawActObj(x, y) {
|
|
3124
4510
|
const ratio = this.calcRatio();
|
|
3125
4511
|
let splitWords;
|
|
@@ -3129,21 +4515,7 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
3129
4515
|
}
|
|
3130
4516
|
if (this.activeObj.horTopLine !== undefined && (this.activeObj.shape !== undefined && splitWords[0] !== 'crop')) {
|
|
3131
4517
|
if (this.textBox.style.display === 'block') {
|
|
3132
|
-
this.
|
|
3133
|
-
this.activeObj.strokeSettings.strokeColor = this.textBox.style.color;
|
|
3134
|
-
if (this.textBox.style.fontWeight === 'bold') {
|
|
3135
|
-
this.activeObj.textSettings.bold = true;
|
|
3136
|
-
}
|
|
3137
|
-
else {
|
|
3138
|
-
this.activeObj.textSettings.bold = false;
|
|
3139
|
-
}
|
|
3140
|
-
if (this.textBox.style.fontStyle === 'italic') {
|
|
3141
|
-
this.activeObj.textSettings.italic = true;
|
|
3142
|
-
}
|
|
3143
|
-
else {
|
|
3144
|
-
this.activeObj.textSettings.italic = false;
|
|
3145
|
-
}
|
|
3146
|
-
this.activeObj.textSettings.fontSize = (parseFloat(this.textBox.style.fontSize) * ((ratio.width + ratio.height) / 2)) / this.factor;
|
|
4518
|
+
this.setTextBoxStylesToActObj();
|
|
3147
4519
|
if (x && y) {
|
|
3148
4520
|
x -= bbox.left;
|
|
3149
4521
|
y -= bbox.top;
|
|
@@ -3605,10 +4977,7 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
3605
4977
|
}
|
|
3606
4978
|
}
|
|
3607
4979
|
this.lowerContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
|
|
3608
|
-
this.
|
|
3609
|
-
for (let i = 0; i < this.objColl.length; i++) {
|
|
3610
|
-
this.apply(this.objColl[i].shape, this.objColl[i]);
|
|
3611
|
-
}
|
|
4980
|
+
this.redrawImgWithObj();
|
|
3612
4981
|
this.activeObj = temp;
|
|
3613
4982
|
this.updateFontStyles();
|
|
3614
4983
|
if (this.factor === 1) {
|
|
@@ -3760,8 +5129,8 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
3760
5129
|
else {
|
|
3761
5130
|
this.updateFontStyles();
|
|
3762
5131
|
}
|
|
3763
|
-
|
|
3764
|
-
|
|
5132
|
+
const textBoxWidth = (this.upperContext.measureText(text).width + (parseFloat(this.textBox.style.fontSize) / 2));
|
|
5133
|
+
const letterWidth = e ? this.upperContext.measureText(String.fromCharCode(e.which)).width : 0;
|
|
3765
5134
|
let actObj = extend({}, this.activeObj, {}, true);
|
|
3766
5135
|
if (this.factor !== 1) {
|
|
3767
5136
|
actObj = this.setCursorForZoomState(actObj, ratio, true);
|
|
@@ -4013,7 +5382,7 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
4013
5382
|
else {
|
|
4014
5383
|
diff = Math.max(this.diffPoint.x, this.diffPoint.y);
|
|
4015
5384
|
}
|
|
4016
|
-
percentage = diff / 10;
|
|
5385
|
+
percentage = (diff / 10) * this.factor;
|
|
4017
5386
|
this.activeObj.activePoint.startX -= (maxDimension.width / 100) * percentage;
|
|
4018
5387
|
this.activeObj.activePoint.startY -= (maxDimension.height / 100) * percentage;
|
|
4019
5388
|
this.activeObj.activePoint.width = this.activeObj.activePoint.endX - this.activeObj.activePoint.startX;
|
|
@@ -4158,7 +5527,7 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
4158
5527
|
else {
|
|
4159
5528
|
diff = Math.max(this.diffPoint.x, this.diffPoint.y);
|
|
4160
5529
|
}
|
|
4161
|
-
percentage = diff / 10;
|
|
5530
|
+
percentage = (diff / 10) * this.factor;
|
|
4162
5531
|
this.activeObj.activePoint.endX += (maxDimension.width / 100) * percentage;
|
|
4163
5532
|
this.activeObj.activePoint.startY -= (maxDimension.height / 100) * percentage;
|
|
4164
5533
|
this.activeObj.activePoint.width = this.activeObj.activePoint.endX - this.activeObj.activePoint.startX;
|
|
@@ -4354,7 +5723,7 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
4354
5723
|
else {
|
|
4355
5724
|
diff = Math.max(this.diffPoint.x, this.diffPoint.y);
|
|
4356
5725
|
}
|
|
4357
|
-
percentage = diff / 10;
|
|
5726
|
+
percentage = (diff / 10) * this.factor;
|
|
4358
5727
|
this.activeObj.activePoint.startX -= (maxDimension.width / 100) * percentage;
|
|
4359
5728
|
this.activeObj.activePoint.endY += (maxDimension.height / 100) * percentage;
|
|
4360
5729
|
this.activeObj.activePoint.width = this.activeObj.activePoint.endX - this.activeObj.activePoint.startX;
|
|
@@ -4501,7 +5870,7 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
4501
5870
|
else {
|
|
4502
5871
|
diff = Math.min(this.diffPoint.x, this.diffPoint.y);
|
|
4503
5872
|
}
|
|
4504
|
-
percentage = diff / 10;
|
|
5873
|
+
percentage = (diff / 10) * this.factor;
|
|
4505
5874
|
this.activeObj.activePoint.endX += (maxDimension.width / 50) * percentage;
|
|
4506
5875
|
this.activeObj.activePoint.endY += (maxDimension.height / 50) * percentage;
|
|
4507
5876
|
this.activeObj.activePoint.width = this.activeObj.activePoint.endX - this.activeObj.activePoint.startX;
|
|
@@ -4547,8 +5916,6 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
4547
5916
|
width = this.activeObj.activePoint.endX - x;
|
|
4548
5917
|
height = this.activeObj.activePoint.endY - y;
|
|
4549
5918
|
scale = Math.min(width, height);
|
|
4550
|
-
let ratio = this.activeObj.shape.split('-');
|
|
4551
|
-
ratio = ratio[1].split(':');
|
|
4552
5919
|
const newScale = this.getScaleRatio(scale);
|
|
4553
5920
|
this.activeObj.activePoint.endX -= newScale.x;
|
|
4554
5921
|
this.activeObj.activePoint.endY -= newScale.y;
|
|
@@ -5207,6 +6574,7 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
5207
6574
|
this.refreshActiveObj();
|
|
5208
6575
|
return;
|
|
5209
6576
|
}
|
|
6577
|
+
this.tempObjColl = extend([], this.objColl, [], true);
|
|
5210
6578
|
this.currObjType.isCustomCrop = false;
|
|
5211
6579
|
const temp = this.activeObj = extend({}, this.objColl[i], {}, true);
|
|
5212
6580
|
this.objColl.splice(i, 1);
|
|
@@ -5216,11 +6584,35 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
5216
6584
|
this.inMemoryContext.putImageData(this.imgDataColl[0].value, 0, 0);
|
|
5217
6585
|
}
|
|
5218
6586
|
else {
|
|
6587
|
+
if ((this.adjustmentLevel.sharpen || this.adjustmentLevel.bw) && !this.sharpenedImgData) {
|
|
6588
|
+
let data;
|
|
6589
|
+
const tempImageData = this.currImgData;
|
|
6590
|
+
if (this.adjustmentLevel.sharpen) {
|
|
6591
|
+
data = this.getSharpenData(this.currImgData);
|
|
6592
|
+
}
|
|
6593
|
+
else {
|
|
6594
|
+
data = this.getBlackAndWhiteData(tempImageData);
|
|
6595
|
+
}
|
|
6596
|
+
this.currImgData = data;
|
|
6597
|
+
this.sharpenedImgData = true;
|
|
6598
|
+
}
|
|
5219
6599
|
this.inMemoryCanvas.width = this.currImgData.width;
|
|
5220
6600
|
this.inMemoryCanvas.height = this.currImgData.height;
|
|
5221
6601
|
this.inMemoryContext.putImageData(this.currImgData, 0, 0);
|
|
5222
6602
|
}
|
|
5223
6603
|
if (this.flipState !== '') {
|
|
6604
|
+
if ((this.adjustmentLevel.sharpen || this.adjustmentLevel.bw) && !this.sharpenedImgData) {
|
|
6605
|
+
let data;
|
|
6606
|
+
const tempImageData = this.currImgData;
|
|
6607
|
+
if (this.adjustmentLevel.sharpen) {
|
|
6608
|
+
data = this.getSharpenData(this.currImgData);
|
|
6609
|
+
}
|
|
6610
|
+
else {
|
|
6611
|
+
data = this.getBlackAndWhiteData(tempImageData);
|
|
6612
|
+
}
|
|
6613
|
+
this.currImgData = data;
|
|
6614
|
+
this.sharpenedImgData = true;
|
|
6615
|
+
}
|
|
5224
6616
|
this.inMemoryContext.clearRect(0, 0, this.inMemoryCanvas.width, this.inMemoryCanvas.height);
|
|
5225
6617
|
this.inMemoryContext.clearRect(0, 0, this.inMemoryCanvas.height, this.inMemoryCanvas.width);
|
|
5226
6618
|
this.inMemoryCanvas.width = this.currImgData.width;
|
|
@@ -5229,15 +6621,10 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
5229
6621
|
}
|
|
5230
6622
|
this.setActivePoint();
|
|
5231
6623
|
this.upperContext.drawImage(this.inMemoryCanvas, 0, 0);
|
|
6624
|
+
this.lowerContext.filter = this.canvasFilter;
|
|
5232
6625
|
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
5233
|
-
this.
|
|
6626
|
+
this.redrawImgWithObj();
|
|
5234
6627
|
this.upperContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
5235
|
-
for (let j = 0; j < this.objColl.length; j++) {
|
|
5236
|
-
if (this.objColl[j].shape === 'text' && this.objColl[j].shapeFlip !== this.currFlipState) {
|
|
5237
|
-
this.objColl[j].flippedText = true;
|
|
5238
|
-
}
|
|
5239
|
-
this.apply(this.objColl[j].shape, this.objColl[j]);
|
|
5240
|
-
}
|
|
5241
6628
|
this.activeObj = extend({}, temp, {}, true);
|
|
5242
6629
|
const endPoint = { x: this.lowerCanvas.width - this.pannEnd.startX, y: this.lowerCanvas.height - this.pannEnd.startY };
|
|
5243
6630
|
if (this.factor !== 1 && (this.activeObj.activePoint.startX < this.pannStart.startX || this.activeObj.activePoint.startY <
|
|
@@ -5620,7 +7007,7 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
5620
7007
|
}
|
|
5621
7008
|
else {
|
|
5622
7009
|
if (this.currObjType.isCustomCrop) {
|
|
5623
|
-
this.upperCanvas.style.cursor = '
|
|
7010
|
+
this.upperCanvas.style.cursor = 'crosshair';
|
|
5624
7011
|
}
|
|
5625
7012
|
this.upperCanvas.style.cursor = 'default';
|
|
5626
7013
|
}
|
|
@@ -5717,7 +7104,7 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
5717
7104
|
}
|
|
5718
7105
|
else {
|
|
5719
7106
|
if (this.currObjType.isCustomCrop) {
|
|
5720
|
-
this.upperCanvas.style.cursor = '
|
|
7107
|
+
this.upperCanvas.style.cursor = 'crosshair';
|
|
5721
7108
|
}
|
|
5722
7109
|
this.upperCanvas.style.cursor = 'default';
|
|
5723
7110
|
}
|
|
@@ -5777,7 +7164,7 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
5777
7164
|
// eslint-disable-next-line @typescript-eslint/tslint/config
|
|
5778
7165
|
this.lowerCanvas.toBlob(function (blob) {
|
|
5779
7166
|
const blobUrl = URL.createObjectURL(blob);
|
|
5780
|
-
proxy.baseImg.src = blobUrl;
|
|
7167
|
+
//proxy.baseImg.src = blobUrl;
|
|
5781
7168
|
proxy.downloadImg(blobUrl, fileName + '.' + type);
|
|
5782
7169
|
}, 'image/png');
|
|
5783
7170
|
}
|
|
@@ -5827,21 +7214,6 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
5827
7214
|
this.inMemoryContext.putImageData(imgData, 0, 0);
|
|
5828
7215
|
}
|
|
5829
7216
|
}
|
|
5830
|
-
drawBaseImg() {
|
|
5831
|
-
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
5832
|
-
this.lowerContext.clearRect(0, 0, this.lowerCanvas.height, this.lowerCanvas.width);
|
|
5833
|
-
this.inMemoryContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
5834
|
-
this.inMemoryContext.clearRect(0, 0, this.lowerCanvas.height, this.lowerCanvas.width);
|
|
5835
|
-
this.inMemoryCanvas.width = this.lowerCanvas.width = this.imgDataColl[0].value.width;
|
|
5836
|
-
this.inMemoryCanvas.height = this.lowerCanvas.height = this.imgDataColl[0].value.height;
|
|
5837
|
-
this.inMemoryContext.putImageData(this.imgDataColl[0].value, 0, 0);
|
|
5838
|
-
const maxDimension = this.calcMaxDimension(this.inMemoryCanvas.width, this.inMemoryCanvas.height);
|
|
5839
|
-
this.lowerCanvas.style.maxWidth = this.upperCanvas.style.maxWidth = maxDimension.width + 'px';
|
|
5840
|
-
this.lowerCanvas.style.maxHeight = this.upperCanvas.style.maxHeight = maxDimension.height + 'px';
|
|
5841
|
-
this.lowerCanvas.style.left = this.upperCanvas.style.left = (this.element.clientWidth - maxDimension.width) / 2 + 1 + 'px';
|
|
5842
|
-
this.lowerCanvas.style.top = this.upperCanvas.style.top = (this.element.clientHeight - this.toolbarHeight - maxDimension.height) / 2 + 1 + 'px';
|
|
5843
|
-
this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
|
|
5844
|
-
}
|
|
5845
7217
|
calcPrevRatio() {
|
|
5846
7218
|
let oldWidthRatio;
|
|
5847
7219
|
let oldHeightRatio;
|
|
@@ -5948,15 +7320,23 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
5948
7320
|
}
|
|
5949
7321
|
else if (degree === 90 || degree === -90) {
|
|
5950
7322
|
this.updateCurrentActiveObjPoint(degree);
|
|
7323
|
+
const tempFilter = this.lowerContext.filter;
|
|
7324
|
+
this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
|
|
7325
|
+
'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
|
|
5951
7326
|
for (let i = 0; i < this.objColl.length; i++) {
|
|
5952
7327
|
this.apply(this.objColl[i].shape, this.objColl[i]);
|
|
5953
7328
|
}
|
|
7329
|
+
this.lowerContext.filter = tempFilter;
|
|
5954
7330
|
}
|
|
5955
7331
|
else {
|
|
5956
7332
|
this.updateCurrentActiveObjPoint('zoom');
|
|
7333
|
+
const tempFilter = this.lowerContext.filter;
|
|
7334
|
+
this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
|
|
7335
|
+
'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
|
|
5957
7336
|
for (let i = 0; i < this.objColl.length; i++) {
|
|
5958
7337
|
this.apply(this.objColl[i].shape, this.objColl[i]);
|
|
5959
7338
|
}
|
|
7339
|
+
this.lowerContext.filter = tempFilter;
|
|
5960
7340
|
}
|
|
5961
7341
|
}
|
|
5962
7342
|
else if (this.objColl.length === 0 && (degree === 'horizontal' || degree === 'vertical' || degree === 'Horizontal' || degree === 'Vertical')) {
|
|
@@ -6004,12 +7384,14 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
6004
7384
|
if (this.objColl[i].activePoint.startX <= this.lowerCanvas.width / 2) {
|
|
6005
7385
|
this.objColl[i].activePoint.startX = this.lowerCanvas.width / 2 + ((this.lowerCanvas.width / 2) -
|
|
6006
7386
|
this.objColl[i].activePoint.endX);
|
|
6007
|
-
this.objColl[i].activePoint.endX = this.objColl[i].activePoint.startX +
|
|
7387
|
+
this.objColl[i].activePoint.endX = this.objColl[i].activePoint.startX +
|
|
7388
|
+
this.objColl[i].activePoint.width;
|
|
6008
7389
|
this.updateActiveObject(ratio, this.objColl[i].activePoint, this.objColl[i]);
|
|
6009
7390
|
}
|
|
6010
7391
|
else if (this.objColl[i].activePoint.startX >= this.lowerCanvas.width / 2) {
|
|
6011
7392
|
this.objColl[i].activePoint.startX = this.lowerCanvas.width - this.objColl[i].activePoint.endX;
|
|
6012
|
-
this.objColl[i].activePoint.endX = this.objColl[i].activePoint.startX +
|
|
7393
|
+
this.objColl[i].activePoint.endX = this.objColl[i].activePoint.startX +
|
|
7394
|
+
this.objColl[i].activePoint.width;
|
|
6013
7395
|
this.updateActiveObject(ratio, this.objColl[i].activePoint, this.objColl[i]);
|
|
6014
7396
|
}
|
|
6015
7397
|
}
|
|
@@ -6019,12 +7401,14 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
6019
7401
|
if (this.objColl[i].activePoint.startY <= this.lowerCanvas.height / 2) {
|
|
6020
7402
|
this.objColl[i].activePoint.startY = this.lowerCanvas.height / 2 + ((this.lowerCanvas.height / 2) -
|
|
6021
7403
|
this.objColl[i].activePoint.endY);
|
|
6022
|
-
this.objColl[i].activePoint.endY = this.objColl[i].activePoint.startY +
|
|
7404
|
+
this.objColl[i].activePoint.endY = this.objColl[i].activePoint.startY +
|
|
7405
|
+
this.objColl[i].activePoint.height;
|
|
6023
7406
|
this.updateActiveObject(ratio, this.objColl[i].activePoint, this.objColl[i]);
|
|
6024
7407
|
}
|
|
6025
7408
|
else if (this.objColl[i].activePoint.startY >= this.lowerCanvas.height / 2) {
|
|
6026
7409
|
this.objColl[i].activePoint.startY = this.lowerCanvas.height - this.objColl[i].activePoint.endY;
|
|
6027
|
-
this.objColl[i].activePoint.endY = this.objColl[i].activePoint.startY +
|
|
7410
|
+
this.objColl[i].activePoint.endY = this.objColl[i].activePoint.startY +
|
|
7411
|
+
this.objColl[i].activePoint.height;
|
|
6028
7412
|
this.updateActiveObject(ratio, this.objColl[i].activePoint, this.objColl[i]);
|
|
6029
7413
|
}
|
|
6030
7414
|
}
|
|
@@ -6039,42 +7423,34 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
6039
7423
|
this.objColl[i].activePoint.startY /= oldRatio.height;
|
|
6040
7424
|
this.objColl[i].activePoint.endX /= oldRatio.width;
|
|
6041
7425
|
this.objColl[i].activePoint.endY /= oldRatio.height;
|
|
6042
|
-
this.objColl[i].activePoint.height = this.objColl[i].activePoint.endX -
|
|
6043
|
-
|
|
7426
|
+
this.objColl[i].activePoint.height = this.objColl[i].activePoint.endX -
|
|
7427
|
+
this.objColl[i].activePoint.startX;
|
|
7428
|
+
this.objColl[i].activePoint.width = this.objColl[i].activePoint.endY -
|
|
7429
|
+
this.objColl[i].activePoint.startY;
|
|
6044
7430
|
this.objColl[i].strokeSettings.strokeWidth /= (oldRatio.width / this.factor);
|
|
6045
7431
|
this.calcCurrPoints(degree, this.objColl[i]);
|
|
6046
|
-
this.objColl[i].activePoint.endX = this.objColl[i].activePoint.startX +
|
|
6047
|
-
|
|
6048
|
-
this.objColl[i].activePoint.
|
|
6049
|
-
|
|
7432
|
+
this.objColl[i].activePoint.endX = this.objColl[i].activePoint.startX +
|
|
7433
|
+
this.objColl[i].activePoint.width;
|
|
7434
|
+
this.objColl[i].activePoint.endY = this.objColl[i].activePoint.startY +
|
|
7435
|
+
this.objColl[i].activePoint.height;
|
|
7436
|
+
this.objColl[i].activePoint.width = this.objColl[i].activePoint.endX -
|
|
7437
|
+
this.objColl[i].activePoint.startX;
|
|
7438
|
+
this.objColl[i].activePoint.height = this.objColl[i].activePoint.endY -
|
|
7439
|
+
this.objColl[i].activePoint.startY;
|
|
6050
7440
|
}
|
|
6051
7441
|
for (let i = 0; i < this.objColl.length; i++) {
|
|
6052
7442
|
this.objColl[i].activePoint.startX *= oldRatio.width;
|
|
6053
7443
|
this.objColl[i].activePoint.startY *= oldRatio.height;
|
|
6054
7444
|
this.objColl[i].activePoint.endX *= oldRatio.width;
|
|
6055
7445
|
this.objColl[i].activePoint.endY *= oldRatio.height;
|
|
6056
|
-
this.objColl[i].activePoint.width = this.objColl[i].activePoint.endX -
|
|
6057
|
-
|
|
7446
|
+
this.objColl[i].activePoint.width = this.objColl[i].activePoint.endX -
|
|
7447
|
+
this.objColl[i].activePoint.startX;
|
|
7448
|
+
this.objColl[i].activePoint.height = this.objColl[i].activePoint.endY -
|
|
7449
|
+
this.objColl[i].activePoint.startY;
|
|
6058
7450
|
this.objColl[i].strokeSettings.strokeWidth *= ratio.width;
|
|
6059
7451
|
}
|
|
6060
7452
|
for (let i = 0; i < this.objColl.length; i++) {
|
|
6061
|
-
this.updateActiveObject(ratio, this.objColl[i].activePoint, this.objColl[i]);
|
|
6062
|
-
}
|
|
6063
|
-
}
|
|
6064
|
-
else if (degree === 'zoom') {
|
|
6065
|
-
for (let i = 0; i < this.objColl.length; i++) {
|
|
6066
|
-
this.objColl[i].activePoint.startX /= ratio.width;
|
|
6067
|
-
this.objColl[i].activePoint.startY /= ratio.height;
|
|
6068
|
-
this.objColl[i].activePoint.endX /= ratio.width;
|
|
6069
|
-
this.objColl[i].activePoint.endY /= ratio.height;
|
|
6070
|
-
this.objColl[i].activePoint.height = this.objColl[i].activePoint.endX - this.objColl[i].activePoint.startX;
|
|
6071
|
-
this.objColl[i].activePoint.width = this.objColl[i].activePoint.endY - this.objColl[i].activePoint.startY;
|
|
6072
|
-
this.objColl[i].activePoint.startX *= ratio.width;
|
|
6073
|
-
this.objColl[i].activePoint.startY *= ratio.height;
|
|
6074
|
-
this.objColl[i].activePoint.endX *= ratio.width;
|
|
6075
|
-
this.objColl[i].activePoint.endY *= ratio.height;
|
|
6076
|
-
this.objColl[i].activePoint.width = this.objColl[i].activePoint.endX - this.objColl[i].activePoint.startX;
|
|
6077
|
-
this.objColl[i].activePoint.height = this.objColl[i].activePoint.endY - this.objColl[i].activePoint.startY;
|
|
7453
|
+
this.updateActiveObject(ratio, this.objColl[i].activePoint, this.objColl[i]);
|
|
6078
7454
|
}
|
|
6079
7455
|
}
|
|
6080
7456
|
}
|
|
@@ -6140,10 +7516,7 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
6140
7516
|
tempObjColl = [];
|
|
6141
7517
|
this.refreshActiveObj();
|
|
6142
7518
|
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
6143
|
-
this.
|
|
6144
|
-
for (let i = 0; i < this.objColl.length; i++) {
|
|
6145
|
-
this.apply(this.objColl[i].shape, this.objColl[i]);
|
|
6146
|
-
}
|
|
7519
|
+
this.redrawImgWithObj();
|
|
6147
7520
|
this.activeObj.flippedText = false;
|
|
6148
7521
|
this.currObjType.shape = '';
|
|
6149
7522
|
this.refreshActiveObj();
|
|
@@ -6161,17 +7534,27 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
6161
7534
|
showSpinner(proxy.element);
|
|
6162
7535
|
proxy.element.style.opacity = '0.5';
|
|
6163
7536
|
proxy.lowerContext.clearRect(0, 0, proxy.lowerCanvas.width, proxy.lowerCanvas.height);
|
|
7537
|
+
const temp = proxy.lowerContext.filter;
|
|
7538
|
+
proxy.lowerContext.filter = proxy.initialAdjustmentValue = proxy.adjustmentValue = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
|
|
7539
|
+
'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
|
|
7540
|
+
if (proxy.cssClass) {
|
|
7541
|
+
addClass([proxy.element], proxy.cssClass.split(' '));
|
|
7542
|
+
}
|
|
6164
7543
|
proxy.lowerContext.drawImage(proxy.inMemoryCanvas, 0, 0);
|
|
6165
7544
|
proxy.baseImg.src = URL.createObjectURL(blob);
|
|
6166
7545
|
proxy.upperContext.clearRect(0, 0, proxy.upperCanvas.width, proxy.upperCanvas.height);
|
|
6167
7546
|
proxy.togglePen = false;
|
|
6168
7547
|
proxy.upperCanvas.style.cursor = 'default';
|
|
7548
|
+
proxy.lowerContext.filter = temp;
|
|
7549
|
+
const tempFilter = proxy.lowerContext.filter;
|
|
7550
|
+
proxy.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
|
|
7551
|
+
'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
|
|
6169
7552
|
for (let i = 0, len = proxy.objColl.length; i < len; i++) {
|
|
6170
7553
|
proxy.apply(proxy.objColl[i].shape, proxy.objColl[i], 'duplicate');
|
|
6171
7554
|
}
|
|
7555
|
+
proxy.lowerContext.filter = tempFilter;
|
|
6172
7556
|
proxy.togglePen = true;
|
|
6173
7557
|
}, 'image/png');
|
|
6174
|
-
this.isUndoRedo = false;
|
|
6175
7558
|
this.degree = 0;
|
|
6176
7559
|
}
|
|
6177
7560
|
else {
|
|
@@ -6186,7 +7569,6 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
6186
7569
|
}
|
|
6187
7570
|
this.keyHistory = '';
|
|
6188
7571
|
}
|
|
6189
|
-
this.isUndoRedo = false;
|
|
6190
7572
|
}
|
|
6191
7573
|
}
|
|
6192
7574
|
}
|
|
@@ -6313,104 +7695,591 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
6313
7695
|
if (this.lowerCanvas.width > this.lowerCanvas.height) {
|
|
6314
7696
|
this.activeObj.textSettings.fontSize = Math.floor((this.lowerCanvas.width / 20));
|
|
6315
7697
|
}
|
|
6316
|
-
else {
|
|
6317
|
-
this.activeObj.textSettings.fontSize = Math.floor((this.lowerCanvas.height / 20));
|
|
7698
|
+
else {
|
|
7699
|
+
this.activeObj.textSettings.fontSize = Math.floor((this.lowerCanvas.height / 20));
|
|
7700
|
+
}
|
|
7701
|
+
if (this.activeObj.textSettings.fontSize < 20 * (ratio.width + ratio.height)) {
|
|
7702
|
+
this.activeObj.textSettings.fontSize = 20 * (ratio.width + ratio.height);
|
|
7703
|
+
}
|
|
7704
|
+
if (this.factor > 1) {
|
|
7705
|
+
this.activeObj.textSettings.fontSize /= this.factor;
|
|
7706
|
+
}
|
|
7707
|
+
}
|
|
7708
|
+
this.activeObj.shapeDegree = this.degree;
|
|
7709
|
+
this.activeObj.shapeFlip = this.currFlipState;
|
|
7710
|
+
this.activeObj.flipObjColl = [];
|
|
7711
|
+
this.updateFontStyles();
|
|
7712
|
+
const width = this.upperContext.measureText(this.activeObj.textSettings.text).width +
|
|
7713
|
+
this.activeObj.textSettings.fontSize * 0.5;
|
|
7714
|
+
const height = this.activeObj.textSettings.fontSize + this.activeObj.textSettings.fontSize * 0.25;
|
|
7715
|
+
if (!isNullOrUndefined(x) && !isNullOrUndefined(y)) {
|
|
7716
|
+
this.activeObj.activePoint.startX = x;
|
|
7717
|
+
this.activeObj.activePoint.startY = y;
|
|
7718
|
+
this.activeObj.activePoint.endX = this.activeObj.activePoint.startX + width;
|
|
7719
|
+
this.activeObj.activePoint.endY = this.activeObj.activePoint.startY + height;
|
|
7720
|
+
}
|
|
7721
|
+
else {
|
|
7722
|
+
this.setCenterPoints(true, width, height);
|
|
7723
|
+
}
|
|
7724
|
+
this.addLetter(this.activeObj.textSettings.text);
|
|
7725
|
+
this.objColl.push(this.activeObj);
|
|
7726
|
+
this.redrawShape(this.objColl[this.objColl.length - 1]);
|
|
7727
|
+
this.refreshToolbar('text');
|
|
7728
|
+
}
|
|
7729
|
+
}
|
|
7730
|
+
drawPen(context) {
|
|
7731
|
+
const ratio = this.calcRatio();
|
|
7732
|
+
context = context ? context : this.upperContext;
|
|
7733
|
+
this.upperCanvas.style.display = 'block';
|
|
7734
|
+
this.canvasRatio = this.calcRatio();
|
|
7735
|
+
if (isNullOrUndefined(this.activeObj.strokeSettings)) {
|
|
7736
|
+
this.activeObj.strokeSettings = this.strokeSettings;
|
|
7737
|
+
}
|
|
7738
|
+
if (isNullOrUndefined(this.activeObj.strokeSettings.strokeWidth)) {
|
|
7739
|
+
this.activeObj.strokeSettings.strokeWidth = (ratio.width + ratio.height) * 0.4;
|
|
7740
|
+
}
|
|
7741
|
+
context.strokeStyle = this.activeObj.strokeSettings.strokeColor;
|
|
7742
|
+
context.lineWidth = 2 * (this.activeObj.strokeSettings.strokeWidth) / this.factor;
|
|
7743
|
+
context.beginPath();
|
|
7744
|
+
context.moveTo(this.prevX, this.prevY);
|
|
7745
|
+
context.lineTo(this.currX, this.currY);
|
|
7746
|
+
context.stroke();
|
|
7747
|
+
context.closePath();
|
|
7748
|
+
}
|
|
7749
|
+
getObjDetails(obj) {
|
|
7750
|
+
const shapeDetails = {};
|
|
7751
|
+
shapeDetails.id = obj.currIndex;
|
|
7752
|
+
shapeDetails.type = obj.shape;
|
|
7753
|
+
shapeDetails.startX = obj.activePoint.startX;
|
|
7754
|
+
shapeDetails.startY = obj.activePoint.startY;
|
|
7755
|
+
if (obj.shape === 'rectangle') {
|
|
7756
|
+
shapeDetails.width = obj.activePoint.width;
|
|
7757
|
+
shapeDetails.height = obj.activePoint.height;
|
|
7758
|
+
shapeDetails.strokeColor = obj.strokeSettings.strokeColor;
|
|
7759
|
+
shapeDetails.fillColor = obj.strokeSettings.fillColor;
|
|
7760
|
+
shapeDetails.strokeWidth = obj.strokeSettings.strokeWidth;
|
|
7761
|
+
}
|
|
7762
|
+
else if (obj.shape === 'ellipse') {
|
|
7763
|
+
shapeDetails.radius = obj.activePoint.width / 2;
|
|
7764
|
+
shapeDetails.strokeColor = obj.strokeSettings.strokeColor;
|
|
7765
|
+
shapeDetails.fillColor = obj.strokeSettings.fillColor;
|
|
7766
|
+
shapeDetails.strokeWidth = obj.strokeSettings.strokeWidth;
|
|
7767
|
+
}
|
|
7768
|
+
else if (obj.shape === 'line') {
|
|
7769
|
+
shapeDetails.length = obj.activePoint.width;
|
|
7770
|
+
shapeDetails.strokeColor = obj.strokeSettings.strokeColor;
|
|
7771
|
+
shapeDetails.strokeWidth = obj.strokeSettings.strokeWidth;
|
|
7772
|
+
}
|
|
7773
|
+
else if (obj.shape === 'text') {
|
|
7774
|
+
shapeDetails.text = obj.keyHistory;
|
|
7775
|
+
shapeDetails.fontSize = obj.textSettings.fontSize;
|
|
7776
|
+
shapeDetails.color = obj.strokeSettings.strokeColor;
|
|
7777
|
+
shapeDetails.fontStyle = [];
|
|
7778
|
+
if (obj.textSettings.bold) {
|
|
7779
|
+
shapeDetails.fontStyle.push('bold');
|
|
7780
|
+
}
|
|
7781
|
+
if (obj.textSettings.italic) {
|
|
7782
|
+
shapeDetails.fontStyle.push('italic');
|
|
7783
|
+
}
|
|
7784
|
+
}
|
|
7785
|
+
return shapeDetails;
|
|
7786
|
+
}
|
|
7787
|
+
isPointsInRange(x, y) {
|
|
7788
|
+
let inRange = false;
|
|
7789
|
+
if (this.factor === 1) {
|
|
7790
|
+
if (x >= 0 && y >= 0 && x <= this.lowerCanvas.width && y <= this.lowerCanvas.width) {
|
|
7791
|
+
inRange = true;
|
|
7792
|
+
}
|
|
7793
|
+
}
|
|
7794
|
+
else {
|
|
7795
|
+
const endPoint = { x: this.lowerCanvas.width - this.pannEnd.startX, y: this.lowerCanvas.height - this.pannEnd.startY };
|
|
7796
|
+
if (x >= this.pannStart.startX && y >= this.pannStart.startY && x <= endPoint.x && y <= endPoint.y) {
|
|
7797
|
+
inRange = true;
|
|
7798
|
+
}
|
|
7799
|
+
}
|
|
7800
|
+
return inRange;
|
|
7801
|
+
}
|
|
7802
|
+
updateInMemoryContext(imgData, isUpdate) {
|
|
7803
|
+
const temp = extend({}, this.activeObj, {}, true);
|
|
7804
|
+
this.redrawImgWithObj();
|
|
7805
|
+
this.activeObj = temp;
|
|
7806
|
+
if (isNullOrUndefined(isUpdate)) {
|
|
7807
|
+
imgData = this.lowerContext.getImageData(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
7808
|
+
}
|
|
7809
|
+
this.inMemoryContext.clearRect(0, 0, this.inMemoryCanvas.width, this.inMemoryCanvas.height);
|
|
7810
|
+
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
7811
|
+
this.inMemoryCanvas.width = imgData.width;
|
|
7812
|
+
this.inMemoryCanvas.height = imgData.height;
|
|
7813
|
+
this.inMemoryContext.putImageData(imgData, 0, 0);
|
|
7814
|
+
}
|
|
7815
|
+
clearActObj() {
|
|
7816
|
+
if (this.textBox.style.display === 'none') {
|
|
7817
|
+
this.refreshActiveObj();
|
|
7818
|
+
this.applyActObj();
|
|
7819
|
+
this.refreshActiveObj();
|
|
7820
|
+
this.currObjType.isCustomCrop = false;
|
|
7821
|
+
}
|
|
7822
|
+
}
|
|
7823
|
+
rotateMultiple(length, degree) {
|
|
7824
|
+
for (let i = 0; i < length; i++) {
|
|
7825
|
+
if (degree > 0) {
|
|
7826
|
+
this.degree += 90;
|
|
7827
|
+
}
|
|
7828
|
+
else {
|
|
7829
|
+
this.degree -= 90;
|
|
7830
|
+
}
|
|
7831
|
+
if (this.degree === 360) {
|
|
7832
|
+
this.degree = 0;
|
|
7833
|
+
}
|
|
7834
|
+
const temp = this.lowerContext.filter;
|
|
7835
|
+
this.lowerContext.save();
|
|
7836
|
+
this.setMaximumDimension(90 * (i + 1));
|
|
7837
|
+
this.lowerContext.translate(this.lowerCanvas.width / 2, this.lowerCanvas.height / 2);
|
|
7838
|
+
if (degree > 0) {
|
|
7839
|
+
this.lowerContext.rotate(Math.PI / 180 * 90);
|
|
7840
|
+
}
|
|
7841
|
+
else {
|
|
7842
|
+
this.lowerContext.rotate(Math.PI / 180 * -90);
|
|
7843
|
+
}
|
|
7844
|
+
this.lowerCanvas.style.left = this.upperCanvas.style.left = (this.element.clientWidth - parseInt(this.lowerCanvas.style.maxWidth, 10) - 18) / 2 + 1 + 'px';
|
|
7845
|
+
this.lowerCanvas.style.top = this.upperCanvas.style.top = (this.element.clientHeight - this.toolbarHeight - parseInt(this.lowerCanvas.style.maxHeight, 10)) / 2 + 1 + 'px';
|
|
7846
|
+
this.updateBrightnessFilter();
|
|
7847
|
+
this.lowerContext.drawImage(this.inMemoryCanvas, -this.lowerCanvas.height / 2, -this.lowerCanvas.width / 2);
|
|
7848
|
+
this.lowerContext.filter = temp;
|
|
7849
|
+
if (degree > 0) {
|
|
7850
|
+
this.lowerContext.rotate(Math.PI / 180 * -90);
|
|
7851
|
+
}
|
|
7852
|
+
else {
|
|
7853
|
+
this.lowerContext.rotate(Math.PI / 180 * 90);
|
|
7854
|
+
}
|
|
7855
|
+
this.lowerContext.translate(-this.lowerCanvas.width / 2, -this.lowerCanvas.height / 2);
|
|
7856
|
+
this.lowerContext.restore();
|
|
7857
|
+
this.currImgData = this.lowerContext.getImageData(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
7858
|
+
this.inMemoryContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
7859
|
+
this.inMemoryCanvas.width = this.currImgData.width;
|
|
7860
|
+
this.inMemoryCanvas.height = this.currImgData.height;
|
|
7861
|
+
this.inMemoryContext.putImageData(this.currImgData, 0, 0);
|
|
7862
|
+
this.lowerContext.filter = this.canvasFilter;
|
|
7863
|
+
this.updateBrightnessFilter();
|
|
7864
|
+
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
7865
|
+
this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
|
|
7866
|
+
this.lowerContext.filter = temp;
|
|
7867
|
+
if (degree > 0) {
|
|
7868
|
+
this.redrawObj(90);
|
|
7869
|
+
}
|
|
7870
|
+
else {
|
|
7871
|
+
this.redrawObj(-90);
|
|
7872
|
+
}
|
|
7873
|
+
}
|
|
7874
|
+
}
|
|
7875
|
+
setBrightness(value) {
|
|
7876
|
+
if (!this.disabled && this.imgDataColl.length > 0) {
|
|
7877
|
+
if (this.currObjType.shape === 'freehanddraw') {
|
|
7878
|
+
this.apply();
|
|
7879
|
+
this.upperCanvas.style.cursor = 'default';
|
|
7880
|
+
this.currObjType.shape = '';
|
|
7881
|
+
}
|
|
7882
|
+
this.clearActObj();
|
|
7883
|
+
this.adjustmentLevel.brightness = value;
|
|
7884
|
+
value = this.getFilterValue(value);
|
|
7885
|
+
this.updateAdjustment('brightness', value);
|
|
7886
|
+
}
|
|
7887
|
+
}
|
|
7888
|
+
setContrast(value) {
|
|
7889
|
+
if (!this.disabled && this.imgDataColl.length > 0) {
|
|
7890
|
+
if (this.currObjType.shape === 'freehanddraw') {
|
|
7891
|
+
this.apply();
|
|
7892
|
+
this.upperCanvas.style.cursor = 'default';
|
|
7893
|
+
this.currObjType.shape = '';
|
|
7894
|
+
}
|
|
7895
|
+
this.clearActObj();
|
|
7896
|
+
this.adjustmentLevel.contrast = value;
|
|
7897
|
+
value = this.getFilterValue(value);
|
|
7898
|
+
value *= 100;
|
|
7899
|
+
this.updateAdjustment('contrast', value);
|
|
7900
|
+
}
|
|
7901
|
+
}
|
|
7902
|
+
setHue(value) {
|
|
7903
|
+
if (!this.disabled && this.imgDataColl.length > 0) {
|
|
7904
|
+
if (this.currObjType.shape === 'freehanddraw') {
|
|
7905
|
+
this.apply();
|
|
7906
|
+
this.upperCanvas.style.cursor = 'default';
|
|
7907
|
+
this.currObjType.shape = '';
|
|
7908
|
+
}
|
|
7909
|
+
this.clearActObj();
|
|
7910
|
+
this.adjustmentLevel.hue = value;
|
|
7911
|
+
value *= 3;
|
|
7912
|
+
this.updateAdjustment('hue', value);
|
|
7913
|
+
}
|
|
7914
|
+
}
|
|
7915
|
+
setSaturation(value) {
|
|
7916
|
+
if (!this.disabled && this.imgDataColl.length > 0) {
|
|
7917
|
+
if (this.currObjType.shape === 'freehanddraw') {
|
|
7918
|
+
this.apply();
|
|
7919
|
+
this.upperCanvas.style.cursor = 'default';
|
|
7920
|
+
this.currObjType.shape = '';
|
|
7921
|
+
}
|
|
7922
|
+
this.clearActObj();
|
|
7923
|
+
this.adjustmentLevel.saturation = value;
|
|
7924
|
+
value = this.getSaturationFilterValue(value);
|
|
7925
|
+
value *= 100;
|
|
7926
|
+
this.updateAdjustment('saturation', value);
|
|
7927
|
+
}
|
|
7928
|
+
}
|
|
7929
|
+
setOpacity(value) {
|
|
7930
|
+
if (!this.disabled && this.imgDataColl.length > 0) {
|
|
7931
|
+
if (this.currObjType.shape === 'freehanddraw') {
|
|
7932
|
+
this.apply();
|
|
7933
|
+
this.upperCanvas.style.cursor = 'default';
|
|
7934
|
+
this.currObjType.shape = '';
|
|
7935
|
+
}
|
|
7936
|
+
this.clearActObj();
|
|
7937
|
+
this.adjustmentLevel.opacity = value;
|
|
7938
|
+
if (value >= 50) {
|
|
7939
|
+
value /= 100;
|
|
7940
|
+
}
|
|
7941
|
+
else if (value === 40) {
|
|
7942
|
+
value = 0.45;
|
|
7943
|
+
}
|
|
7944
|
+
else if (value === 30) {
|
|
7945
|
+
value = 0.40;
|
|
7946
|
+
}
|
|
7947
|
+
else if (value === 20) {
|
|
7948
|
+
value = 0.35;
|
|
7949
|
+
}
|
|
7950
|
+
else if (value === 10) {
|
|
7951
|
+
value = 0.30;
|
|
7952
|
+
}
|
|
7953
|
+
else if (value === 0) {
|
|
7954
|
+
value = 0.25;
|
|
7955
|
+
}
|
|
7956
|
+
this.updateAdjustment('opacity', value);
|
|
7957
|
+
}
|
|
7958
|
+
}
|
|
7959
|
+
setBlur(value) {
|
|
7960
|
+
if (!this.disabled && this.imgDataColl.length > 0) {
|
|
7961
|
+
if (this.currObjType.shape === 'freehanddraw') {
|
|
7962
|
+
this.apply();
|
|
7963
|
+
this.upperCanvas.style.cursor = 'default';
|
|
7964
|
+
this.currObjType.shape = '';
|
|
7965
|
+
}
|
|
7966
|
+
this.clearActObj();
|
|
7967
|
+
this.adjustmentLevel.blur = value;
|
|
7968
|
+
value /= 20;
|
|
7969
|
+
this.updateAdjustment('blur', value);
|
|
7970
|
+
}
|
|
7971
|
+
}
|
|
7972
|
+
setExposure(value) {
|
|
7973
|
+
if (!this.disabled && this.imgDataColl.length > 0) {
|
|
7974
|
+
if (this.currObjType.shape === 'freehanddraw') {
|
|
7975
|
+
this.apply();
|
|
7976
|
+
this.upperCanvas.style.cursor = 'default';
|
|
7977
|
+
this.currObjType.shape = '';
|
|
7978
|
+
}
|
|
7979
|
+
this.clearActObj();
|
|
7980
|
+
this.adjustmentLevel.exposure = value;
|
|
7981
|
+
value = this.getFilterValue(value);
|
|
7982
|
+
this.updateAdjustment('exposure', value);
|
|
7983
|
+
}
|
|
7984
|
+
}
|
|
7985
|
+
setFilter(type) {
|
|
7986
|
+
if (!this.disabled && this.imgDataColl.length > 0) {
|
|
7987
|
+
if (this.currObjType.shape === 'freehanddraw') {
|
|
7988
|
+
this.apply();
|
|
7989
|
+
this.upperCanvas.style.cursor = 'default';
|
|
7990
|
+
this.currObjType.shape = '';
|
|
7991
|
+
}
|
|
7992
|
+
this.clearActObj();
|
|
7993
|
+
this.updateAdjustment(type, null);
|
|
7994
|
+
}
|
|
7995
|
+
}
|
|
7996
|
+
setBlackAndWhiteFilter(boolean) {
|
|
7997
|
+
if (!this.disabled && this.imgDataColl.length > 0) {
|
|
7998
|
+
if (this.currObjType.shape === 'freehanddraw') {
|
|
7999
|
+
this.apply();
|
|
8000
|
+
this.upperCanvas.style.cursor = 'default';
|
|
8001
|
+
this.currObjType.shape = '';
|
|
8002
|
+
}
|
|
8003
|
+
this.clearActObj();
|
|
8004
|
+
this.adjustmentLevel.bw = boolean;
|
|
8005
|
+
if (boolean) {
|
|
8006
|
+
if (this.degree === 0 && this.currFlipState === '') {
|
|
8007
|
+
this.replaceBWSharpenData('bw');
|
|
8008
|
+
}
|
|
8009
|
+
else if (this.degree !== 0) {
|
|
8010
|
+
const tempDegree = this.degree;
|
|
8011
|
+
this.rotate(-tempDegree);
|
|
8012
|
+
this.replaceBWSharpenData('bw');
|
|
8013
|
+
this.rotate(tempDegree);
|
|
8014
|
+
this.refreshToolbar('filter');
|
|
8015
|
+
}
|
|
8016
|
+
else if (this.currFlipState !== '') {
|
|
8017
|
+
const tempFlipState = this.currFlipState;
|
|
8018
|
+
this.flip(tempFlipState);
|
|
8019
|
+
this.replaceBWSharpenData('bw');
|
|
8020
|
+
this.flip(tempFlipState);
|
|
8021
|
+
this.refreshToolbar('filter');
|
|
8022
|
+
}
|
|
8023
|
+
const data = this.inMemoryContext.getImageData(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
8024
|
+
const imageData = this.getBlackAndWhiteData(data);
|
|
8025
|
+
this.inMemoryContext.clearRect(0, 0, this.inMemoryCanvas.width, this.inMemoryCanvas.height);
|
|
8026
|
+
this.inMemoryCanvas.width = imageData.width;
|
|
8027
|
+
this.inMemoryCanvas.height = imageData.height;
|
|
8028
|
+
this.inMemoryContext.putImageData(imageData, 0, 0);
|
|
8029
|
+
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
8030
|
+
this.lowerContext.filter = this.canvasFilter;
|
|
8031
|
+
const temp = this.lowerContext.filter;
|
|
8032
|
+
this.updateBrightnessFilter();
|
|
8033
|
+
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
8034
|
+
this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
|
|
8035
|
+
this.lowerContext.filter = temp;
|
|
8036
|
+
}
|
|
8037
|
+
else {
|
|
8038
|
+
if (this.degree === 0 && this.currFlipState === '') {
|
|
8039
|
+
this.updateBWSharpness();
|
|
8040
|
+
}
|
|
8041
|
+
else if (this.degree !== 0) {
|
|
8042
|
+
const tempDegree = this.degree;
|
|
8043
|
+
this.rotate(-tempDegree);
|
|
8044
|
+
this.updateBWSharpness();
|
|
8045
|
+
this.rotate(tempDegree);
|
|
8046
|
+
this.refreshToolbar('filter');
|
|
8047
|
+
if (this.sharpenedImgData) {
|
|
8048
|
+
this.sharpenedImgData = false;
|
|
8049
|
+
}
|
|
8050
|
+
}
|
|
8051
|
+
else if (this.currFlipState !== '') {
|
|
8052
|
+
const tempFlipState = this.currFlipState;
|
|
8053
|
+
this.flip(tempFlipState);
|
|
8054
|
+
this.updateBWSharpness();
|
|
8055
|
+
this.flip(tempFlipState);
|
|
8056
|
+
this.refreshToolbar('filter');
|
|
8057
|
+
if (this.sharpenedImgData) {
|
|
8058
|
+
this.sharpenedImgData = false;
|
|
8059
|
+
}
|
|
8060
|
+
}
|
|
8061
|
+
}
|
|
8062
|
+
}
|
|
8063
|
+
}
|
|
8064
|
+
setSharpness(boolean) {
|
|
8065
|
+
if (!this.disabled && this.imgDataColl.length > 0) {
|
|
8066
|
+
if (this.currObjType.shape === 'freehanddraw') {
|
|
8067
|
+
this.apply();
|
|
8068
|
+
this.upperCanvas.style.cursor = 'default';
|
|
8069
|
+
this.currObjType.shape = '';
|
|
8070
|
+
}
|
|
8071
|
+
this.clearActObj();
|
|
8072
|
+
this.adjustmentLevel.sharpen = boolean;
|
|
8073
|
+
if (boolean) {
|
|
8074
|
+
if (this.degree === 0 && this.currFlipState === '') {
|
|
8075
|
+
this.replaceBWSharpenData('sharpen');
|
|
8076
|
+
}
|
|
8077
|
+
else if (this.degree !== 0) {
|
|
8078
|
+
const tempDegree = this.degree;
|
|
8079
|
+
this.rotate(-tempDegree);
|
|
8080
|
+
this.replaceBWSharpenData('sharpen');
|
|
8081
|
+
this.rotate(tempDegree);
|
|
8082
|
+
this.refreshToolbar('filter');
|
|
8083
|
+
}
|
|
8084
|
+
else if (this.currFlipState !== '') {
|
|
8085
|
+
const tempFlipState = this.currFlipState;
|
|
8086
|
+
this.flip(tempFlipState);
|
|
8087
|
+
this.replaceBWSharpenData('sharpen');
|
|
8088
|
+
this.flip(tempFlipState);
|
|
8089
|
+
this.refreshToolbar('filter');
|
|
8090
|
+
}
|
|
8091
|
+
const data = this.inMemoryContext.getImageData(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
8092
|
+
const imageData = this.getSharpenData(data);
|
|
8093
|
+
this.inMemoryContext.clearRect(0, 0, this.inMemoryCanvas.width, this.inMemoryCanvas.height);
|
|
8094
|
+
this.inMemoryCanvas.width = imageData.width;
|
|
8095
|
+
this.inMemoryCanvas.height = imageData.height;
|
|
8096
|
+
this.inMemoryContext.putImageData(imageData, 0, 0);
|
|
8097
|
+
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
8098
|
+
this.lowerContext.filter = this.canvasFilter;
|
|
8099
|
+
const temp = this.lowerContext.filter;
|
|
8100
|
+
this.updateBrightnessFilter();
|
|
8101
|
+
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
8102
|
+
this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
|
|
8103
|
+
this.lowerContext.filter = temp;
|
|
8104
|
+
}
|
|
8105
|
+
else {
|
|
8106
|
+
if (this.degree === 0 && this.currFlipState === '') {
|
|
8107
|
+
this.updateBWSharpness();
|
|
8108
|
+
}
|
|
8109
|
+
else if (this.degree !== 0) {
|
|
8110
|
+
const tempDegree = this.degree;
|
|
8111
|
+
this.rotate(-tempDegree);
|
|
8112
|
+
this.updateBWSharpness();
|
|
8113
|
+
this.rotate(tempDegree);
|
|
8114
|
+
this.refreshToolbar('filter');
|
|
8115
|
+
if (this.sharpenedImgData) {
|
|
8116
|
+
this.sharpenedImgData = false;
|
|
8117
|
+
}
|
|
6318
8118
|
}
|
|
6319
|
-
if (this.
|
|
6320
|
-
|
|
8119
|
+
else if (this.currFlipState !== '') {
|
|
8120
|
+
const tempFlipState = this.currFlipState;
|
|
8121
|
+
this.flip(tempFlipState);
|
|
8122
|
+
this.updateBWSharpness();
|
|
8123
|
+
this.flip(tempFlipState);
|
|
8124
|
+
this.refreshToolbar('filter');
|
|
8125
|
+
if (this.sharpenedImgData) {
|
|
8126
|
+
this.sharpenedImgData = false;
|
|
8127
|
+
}
|
|
6321
8128
|
}
|
|
6322
8129
|
}
|
|
6323
|
-
|
|
6324
|
-
|
|
6325
|
-
|
|
6326
|
-
|
|
6327
|
-
|
|
6328
|
-
|
|
6329
|
-
|
|
6330
|
-
|
|
6331
|
-
|
|
6332
|
-
|
|
6333
|
-
|
|
6334
|
-
|
|
8130
|
+
}
|
|
8131
|
+
}
|
|
8132
|
+
replaceBWSharpenData(type) {
|
|
8133
|
+
this.tempImageData = this.inMemoryContext.getImageData(0, 0, this.inMemoryCanvas.width, this.inMemoryCanvas.height);
|
|
8134
|
+
let imageData = this.inMemoryContext.getImageData(0, 0, this.inMemoryCanvas.width, this.inMemoryCanvas.height);
|
|
8135
|
+
if (type === 'sharpen') {
|
|
8136
|
+
imageData = this.getSharpenData(this.tempImageData);
|
|
8137
|
+
}
|
|
8138
|
+
else {
|
|
8139
|
+
imageData = this.getBlackAndWhiteData(imageData);
|
|
8140
|
+
}
|
|
8141
|
+
this.inMemoryContext.clearRect(0, 0, this.inMemoryCanvas.width, this.inMemoryCanvas.height);
|
|
8142
|
+
this.inMemoryCanvas.width = imageData.width;
|
|
8143
|
+
this.inMemoryCanvas.height = imageData.height;
|
|
8144
|
+
this.inMemoryContext.putImageData(imageData, 0, 0);
|
|
8145
|
+
let tempObj;
|
|
8146
|
+
for (let index = 0; index < this.imgDataColl.length; index++) {
|
|
8147
|
+
if (this.imgDataColl[index].operation !== 'freehanddraw') {
|
|
8148
|
+
tempObj = this.imgDataColl[index];
|
|
8149
|
+
break;
|
|
6335
8150
|
}
|
|
6336
|
-
|
|
6337
|
-
|
|
8151
|
+
}
|
|
8152
|
+
this.imgDataColl.splice(0, 1, { operation: 'updateCanvas', value: imageData });
|
|
8153
|
+
this.imgDataColl.splice(1, 1, tempObj);
|
|
8154
|
+
this.inMemoryContext.clearRect(0, 0, this.inMemoryCanvas.width, this.inMemoryCanvas.height);
|
|
8155
|
+
this.inMemoryCanvas.width = this.tempImageData.width;
|
|
8156
|
+
this.inMemoryCanvas.height = this.tempImageData.height;
|
|
8157
|
+
this.inMemoryContext.putImageData(this.tempImageData, 0, 0);
|
|
8158
|
+
}
|
|
8159
|
+
updateBWSharpness() {
|
|
8160
|
+
this.inMemoryContext.clearRect(0, 0, this.inMemoryCanvas.width, this.inMemoryCanvas.height);
|
|
8161
|
+
this.inMemoryCanvas.width = this.tempImageData.width;
|
|
8162
|
+
this.inMemoryCanvas.height = this.tempImageData.height;
|
|
8163
|
+
this.inMemoryContext.putImageData(this.tempImageData, 0, 0);
|
|
8164
|
+
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
8165
|
+
this.lowerContext.filter = this.canvasFilter;
|
|
8166
|
+
this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
|
|
8167
|
+
this.imgDataColl.shift();
|
|
8168
|
+
}
|
|
8169
|
+
getSharpenData(imageData) {
|
|
8170
|
+
const data = imageData.data;
|
|
8171
|
+
const weights = [0, -1, 0, -1, 5, -1, 0, -1, 0];
|
|
8172
|
+
const side = Math.round(Math.sqrt(weights.length));
|
|
8173
|
+
const halfSide = Math.floor(side / 2);
|
|
8174
|
+
const sw = imageData.width;
|
|
8175
|
+
const sh = imageData.height;
|
|
8176
|
+
const output = this.inMemoryContext.createImageData(sw, sh);
|
|
8177
|
+
const dst = output.data;
|
|
8178
|
+
// go through the destination image pixels
|
|
8179
|
+
const alphaFac = 0;
|
|
8180
|
+
let r;
|
|
8181
|
+
let g;
|
|
8182
|
+
let b;
|
|
8183
|
+
let a;
|
|
8184
|
+
let dstOff;
|
|
8185
|
+
let scx;
|
|
8186
|
+
let scy;
|
|
8187
|
+
let srcOff;
|
|
8188
|
+
let wt;
|
|
8189
|
+
let x;
|
|
8190
|
+
let y;
|
|
8191
|
+
let cx;
|
|
8192
|
+
let cy;
|
|
8193
|
+
for (y = 0; y < sh; y++) {
|
|
8194
|
+
for (x = 0; x < sw; x++) {
|
|
8195
|
+
dstOff = (y * sw + x) * 4;
|
|
8196
|
+
r = 0;
|
|
8197
|
+
g = 0;
|
|
8198
|
+
b = 0;
|
|
8199
|
+
a = 0;
|
|
8200
|
+
for (cy = 0; cy < side; cy++) {
|
|
8201
|
+
for (cx = 0; cx < side; cx++) {
|
|
8202
|
+
scy = y + cy - halfSide;
|
|
8203
|
+
scx = x + cx - halfSide;
|
|
8204
|
+
if (scy < 0 || scy >= sh || scx < 0 || scx >= sw) {
|
|
8205
|
+
continue;
|
|
8206
|
+
}
|
|
8207
|
+
srcOff = (scy * sw + scx) * 4;
|
|
8208
|
+
wt = weights[cy * side + cx];
|
|
8209
|
+
r += data[srcOff] * wt;
|
|
8210
|
+
g += data[srcOff + 1] * wt;
|
|
8211
|
+
b += data[srcOff + 2] * wt;
|
|
8212
|
+
if (!alphaFac) {
|
|
8213
|
+
a += data[srcOff + 3] * wt;
|
|
8214
|
+
}
|
|
8215
|
+
}
|
|
8216
|
+
}
|
|
8217
|
+
dst[dstOff] = r;
|
|
8218
|
+
dst[dstOff + 1] = g;
|
|
8219
|
+
dst[dstOff + 2] = b;
|
|
8220
|
+
if (!alphaFac) {
|
|
8221
|
+
dst[dstOff + 3] = a;
|
|
8222
|
+
}
|
|
8223
|
+
else {
|
|
8224
|
+
dst[dstOff + 3] = data[dstOff + 3];
|
|
8225
|
+
}
|
|
6338
8226
|
}
|
|
6339
|
-
this.addLetter(this.activeObj.textSettings.text);
|
|
6340
|
-
this.refreshToolbar('text');
|
|
6341
8227
|
}
|
|
8228
|
+
return output;
|
|
6342
8229
|
}
|
|
6343
|
-
|
|
6344
|
-
|
|
6345
|
-
|
|
6346
|
-
|
|
6347
|
-
this.canvasRatio = this.calcRatio();
|
|
6348
|
-
if (isNullOrUndefined(this.activeObj.strokeSettings)) {
|
|
6349
|
-
this.activeObj.strokeSettings = this.strokeSettings;
|
|
8230
|
+
getFilterValue(value) {
|
|
8231
|
+
let filterValue;
|
|
8232
|
+
if (value === 0) {
|
|
8233
|
+
filterValue = 1;
|
|
6350
8234
|
}
|
|
6351
|
-
|
|
6352
|
-
|
|
8235
|
+
else {
|
|
8236
|
+
filterValue = 1 + ((value * 0.5) / 100);
|
|
6353
8237
|
}
|
|
6354
|
-
|
|
6355
|
-
context.lineWidth = 2 * (this.activeObj.strokeSettings.strokeWidth) / this.factor;
|
|
6356
|
-
context.beginPath();
|
|
6357
|
-
context.moveTo(this.prevX, this.prevY);
|
|
6358
|
-
context.lineTo(this.currX, this.currY);
|
|
6359
|
-
context.stroke();
|
|
6360
|
-
context.closePath();
|
|
8238
|
+
return filterValue;
|
|
6361
8239
|
}
|
|
6362
|
-
|
|
6363
|
-
|
|
6364
|
-
|
|
6365
|
-
|
|
6366
|
-
shapeDetails.startX = obj.activePoint.startX;
|
|
6367
|
-
shapeDetails.startY = obj.activePoint.startY;
|
|
6368
|
-
if (obj.shape === 'rectangle') {
|
|
6369
|
-
shapeDetails.width = obj.activePoint.width;
|
|
6370
|
-
shapeDetails.height = obj.activePoint.height;
|
|
6371
|
-
shapeDetails.strokeColor = obj.strokeSettings.strokeColor;
|
|
6372
|
-
shapeDetails.fillColor = obj.strokeSettings.fillColor;
|
|
6373
|
-
shapeDetails.strokeWidth = obj.strokeSettings.strokeWidth;
|
|
8240
|
+
setFilterValue(value) {
|
|
8241
|
+
let filterValue;
|
|
8242
|
+
if (value === 1) {
|
|
8243
|
+
filterValue = 0;
|
|
6374
8244
|
}
|
|
6375
|
-
else
|
|
6376
|
-
|
|
6377
|
-
shapeDetails.strokeColor = obj.strokeSettings.strokeColor;
|
|
6378
|
-
shapeDetails.fillColor = obj.strokeSettings.fillColor;
|
|
6379
|
-
shapeDetails.strokeWidth = obj.strokeSettings.strokeWidth;
|
|
8245
|
+
else {
|
|
8246
|
+
filterValue = ((value - 1) * 100) / 0.5;
|
|
6380
8247
|
}
|
|
6381
|
-
|
|
6382
|
-
|
|
6383
|
-
|
|
6384
|
-
|
|
8248
|
+
return Math.round(filterValue);
|
|
8249
|
+
}
|
|
8250
|
+
getSaturationFilterValue(value) {
|
|
8251
|
+
let filterValue;
|
|
8252
|
+
if (value === 0) {
|
|
8253
|
+
filterValue = 1;
|
|
6385
8254
|
}
|
|
6386
|
-
else
|
|
6387
|
-
|
|
6388
|
-
shapeDetails.fontSize = obj.textSettings.fontSize;
|
|
6389
|
-
shapeDetails.color = obj.strokeSettings.strokeColor;
|
|
6390
|
-
shapeDetails.fontStyle = [];
|
|
6391
|
-
if (obj.textSettings.bold) {
|
|
6392
|
-
shapeDetails.fontStyle.push('bold');
|
|
6393
|
-
}
|
|
6394
|
-
if (obj.textSettings.italic) {
|
|
6395
|
-
shapeDetails.fontStyle.push('italic');
|
|
6396
|
-
}
|
|
8255
|
+
else {
|
|
8256
|
+
filterValue = 1 + (value / 100);
|
|
6397
8257
|
}
|
|
6398
|
-
return
|
|
8258
|
+
return filterValue;
|
|
6399
8259
|
}
|
|
6400
|
-
|
|
6401
|
-
let
|
|
6402
|
-
if (
|
|
6403
|
-
|
|
6404
|
-
inRange = true;
|
|
6405
|
-
}
|
|
8260
|
+
setSaturationFilterValue(value) {
|
|
8261
|
+
let filterValue;
|
|
8262
|
+
if (value === 1) {
|
|
8263
|
+
filterValue = 0;
|
|
6406
8264
|
}
|
|
6407
8265
|
else {
|
|
6408
|
-
|
|
6409
|
-
|
|
6410
|
-
|
|
8266
|
+
filterValue = (value - 1) * 100;
|
|
8267
|
+
}
|
|
8268
|
+
return Math.round(filterValue);
|
|
8269
|
+
}
|
|
8270
|
+
getBlackAndWhiteData(imageData) {
|
|
8271
|
+
for (let i = 0; i < imageData.data.length; i += 4) {
|
|
8272
|
+
const count = imageData.data[i] + imageData.data[i + 1] + imageData.data[i + 2];
|
|
8273
|
+
let colour = 0;
|
|
8274
|
+
if (count > 383) {
|
|
8275
|
+
colour = 255;
|
|
6411
8276
|
}
|
|
8277
|
+
imageData.data[i] = colour;
|
|
8278
|
+
imageData.data[i + 1] = colour;
|
|
8279
|
+
imageData.data[i + 2] = colour;
|
|
8280
|
+
imageData.data[i + 3] = 255;
|
|
6412
8281
|
}
|
|
6413
|
-
return
|
|
8282
|
+
return imageData;
|
|
6414
8283
|
}
|
|
6415
8284
|
/**
|
|
6416
8285
|
* Clear a current selection.
|
|
@@ -6448,11 +8317,22 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
6448
8317
|
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
6449
8318
|
const proxy = this;
|
|
6450
8319
|
isCrop = true;
|
|
8320
|
+
const canvasFilter = this.canvasFilter;
|
|
8321
|
+
const tempActObj = extend({}, this.activeObj, {}, true);
|
|
8322
|
+
this.lowerContext.filter = this.canvasFilter = 'none';
|
|
8323
|
+
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
8324
|
+
this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
|
|
8325
|
+
for (let j = 0; j < this.objColl.length; j++) {
|
|
8326
|
+
this.apply(this.objColl[j].shape, this.objColl[j]);
|
|
8327
|
+
this.refreshActiveObj();
|
|
8328
|
+
}
|
|
8329
|
+
this.activeObj = tempActObj;
|
|
6451
8330
|
this.upperCanvas.style.display = 'none';
|
|
6452
8331
|
let widthRatio;
|
|
6453
8332
|
let heightRatio;
|
|
6454
8333
|
let imgData;
|
|
6455
8334
|
let zoomedRotate = false;
|
|
8335
|
+
const factor = this.factor;
|
|
6456
8336
|
if (this.factor === 1) {
|
|
6457
8337
|
imgData = this.lowerContext.getImageData(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
6458
8338
|
widthRatio = this.lowerCanvas.width / parseInt(this.lowerCanvas.style.maxWidth, 10);
|
|
@@ -6487,6 +8367,7 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
6487
8367
|
this.updateInMemoryContext(imgData);
|
|
6488
8368
|
}
|
|
6489
8369
|
this.degree = 0;
|
|
8370
|
+
this.updateBrightnessFilter();
|
|
6490
8371
|
this.lowerContext.drawImage(this.inMemoryCanvas, tempObj.activePoint.startX, tempObj.activePoint.startY, tempObj.activePoint.width, tempObj.activePoint.height, 0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
6491
8372
|
}
|
|
6492
8373
|
if (this.flipState !== '') {
|
|
@@ -6501,6 +8382,7 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
6501
8382
|
this.lowerCanvas.style.maxHeight = this.upperCanvas.style.maxHeight = maxDimension.height + 'px';
|
|
6502
8383
|
this.lowerCanvas.width = this.upperCanvas.width = maxDimension.width * widthRatio;
|
|
6503
8384
|
this.lowerCanvas.height = this.upperCanvas.height = maxDimension.height * heightRatio;
|
|
8385
|
+
this.updateBrightnessFilter();
|
|
6504
8386
|
this.lowerContext.drawImage(this.inMemoryCanvas, tempObj.activePoint.startX, tempObj.activePoint.startY, tempObj.activePoint.width, tempObj.activePoint.height, 0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
6505
8387
|
}
|
|
6506
8388
|
}
|
|
@@ -6521,6 +8403,7 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
6521
8403
|
((this.element.clientWidth - parseInt(cssObj.width, 10) - 18) / 2) + 1 + 'px';
|
|
6522
8404
|
this.lowerCanvas.style.top = this.upperCanvas.style.top = ((this.element.clientHeight - this.toolbarHeight
|
|
6523
8405
|
- parseInt(cssObj.height, 10)) / 2) + 1 + 'px';
|
|
8406
|
+
this.updateBrightnessFilter();
|
|
6524
8407
|
this.lowerContext.drawImage(this.inMemoryCanvas, this.activeObj.activePoint.startX, this.activeObj.activePoint.startY, this.activeObj.activePoint.width, this.activeObj.activePoint.height, 0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
6525
8408
|
}
|
|
6526
8409
|
if (this.activeObj.shape === 'crop-circle') {
|
|
@@ -6529,6 +8412,7 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
6529
8412
|
this.inMemoryCanvas.height = imgData.height;
|
|
6530
8413
|
this.inMemoryContext.putImageData(imgData, 0, 0);
|
|
6531
8414
|
this.lowerContext.save();
|
|
8415
|
+
this.updateBrightnessFilter();
|
|
6532
8416
|
this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0, this.baseImg.width, this.baseImg.height);
|
|
6533
8417
|
this.lowerContext.globalCompositeOperation = 'destination-in';
|
|
6534
8418
|
this.lowerContext.beginPath();
|
|
@@ -6541,18 +8425,11 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
6541
8425
|
showSpinner(this.element);
|
|
6542
8426
|
this.element.style.opacity = '0.5';
|
|
6543
8427
|
let blobUrl;
|
|
6544
|
-
let data;
|
|
6545
8428
|
// eslint-disable-next-line @typescript-eslint/tslint/config
|
|
6546
8429
|
this.lowerCanvas.toBlob(function (blob) {
|
|
6547
8430
|
blobUrl = URL.createObjectURL(blob);
|
|
6548
|
-
proxy.isUndoRedo = false;
|
|
6549
8431
|
proxy.baseImg.src = blobUrl;
|
|
6550
|
-
data = proxy.lowerContext.getImageData(0, 0, proxy.lowerCanvas.width, proxy.lowerCanvas.height);
|
|
6551
8432
|
proxy.imgDataColl = [];
|
|
6552
|
-
if (!proxy.isUndoRedo) {
|
|
6553
|
-
proxy.updateUndoRedoColl('crop', data, proxy.objColl);
|
|
6554
|
-
}
|
|
6555
|
-
proxy.isUndoRedo = false;
|
|
6556
8433
|
}, 'image/png');
|
|
6557
8434
|
this.objColl = [];
|
|
6558
8435
|
this.refreshActiveObj();
|
|
@@ -6561,26 +8438,11 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
6561
8438
|
this.upperContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
6562
8439
|
this.lowerContext.globalAlpha = 0;
|
|
6563
8440
|
this.lowerContext.fillRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
6564
|
-
this.lowerContext.setTransform(1, 0, 0, 1, 0, 0);
|
|
6565
|
-
this.upperContext.setTransform(1, 0, 0, 1, 0, 0);
|
|
6566
8441
|
this.factor = 1;
|
|
8442
|
+
this.canvasFilter = canvasFilter;
|
|
6567
8443
|
}
|
|
6568
8444
|
return isCrop;
|
|
6569
8445
|
}
|
|
6570
|
-
updateInMemoryContext(imgData) {
|
|
6571
|
-
this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
|
|
6572
|
-
const temp = extend({}, this.activeObj, {}, true);
|
|
6573
|
-
for (let i = 0; i < this.objColl.length; i++) {
|
|
6574
|
-
this.apply(this.objColl[i].shape, this.objColl[i]);
|
|
6575
|
-
}
|
|
6576
|
-
this.activeObj = temp;
|
|
6577
|
-
imgData = this.lowerContext.getImageData(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
6578
|
-
this.inMemoryContext.clearRect(0, 0, this.inMemoryCanvas.width, this.inMemoryCanvas.height);
|
|
6579
|
-
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
6580
|
-
this.inMemoryCanvas.width = imgData.width;
|
|
6581
|
-
this.inMemoryCanvas.height = imgData.height;
|
|
6582
|
-
this.inMemoryContext.putImageData(imgData, 0, 0);
|
|
6583
|
-
}
|
|
6584
8446
|
/**
|
|
6585
8447
|
* Flips an image by horizontally or vertically.
|
|
6586
8448
|
*
|
|
@@ -6597,8 +8459,8 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
6597
8459
|
}
|
|
6598
8460
|
const transitionArgs = { direction: direction };
|
|
6599
8461
|
this.trigger('flipping', transitionArgs);
|
|
6600
|
-
this.
|
|
6601
|
-
|
|
8462
|
+
this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
|
|
8463
|
+
'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
|
|
6602
8464
|
let splitWords = [];
|
|
6603
8465
|
let activeObjShape;
|
|
6604
8466
|
if (!isNullOrUndefined(this.activeObj.activePoint)) {
|
|
@@ -6619,7 +8481,6 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
6619
8481
|
this.lowerContext.scale(-1, 1);
|
|
6620
8482
|
this.upperContext.translate(this.upperContext.canvas.width, 0);
|
|
6621
8483
|
this.upperContext.scale(-1, 1);
|
|
6622
|
-
this.flipDirection = 'horizontal';
|
|
6623
8484
|
if (this.flipState === '' || this.flipState.toLowerCase() === 'vertical') {
|
|
6624
8485
|
this.flipState = 'horizontal';
|
|
6625
8486
|
}
|
|
@@ -6635,7 +8496,6 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
6635
8496
|
this.lowerContext.scale(1, -1);
|
|
6636
8497
|
this.upperContext.translate(0, this.upperContext.canvas.height);
|
|
6637
8498
|
this.upperContext.scale(1, -1);
|
|
6638
|
-
this.flipDirection = 'vertical';
|
|
6639
8499
|
if (this.flipState.toLowerCase() === '' || this.flipState.toLowerCase() === 'horizontal') {
|
|
6640
8500
|
this.flipState = 'vertical';
|
|
6641
8501
|
}
|
|
@@ -6646,13 +8506,25 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
6646
8506
|
this.currFlipState = 'vertical';
|
|
6647
8507
|
}
|
|
6648
8508
|
}
|
|
8509
|
+
const temp = this.lowerContext.filter;
|
|
8510
|
+
this.updateBrightnessFilter();
|
|
8511
|
+
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
6649
8512
|
this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
|
|
8513
|
+
this.lowerContext.filter = temp;
|
|
6650
8514
|
this.currImgData = this.lowerContext.getImageData(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
8515
|
+
this.lowerContext.filter = this.canvasFilter;
|
|
8516
|
+
this.updateBrightnessFilter();
|
|
8517
|
+
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
8518
|
+
this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
|
|
8519
|
+
this.lowerContext.filter = temp;
|
|
6651
8520
|
this.inMemoryContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
6652
8521
|
this.inMemoryCanvas.width = this.currImgData.width;
|
|
6653
8522
|
this.inMemoryCanvas.height = this.currImgData.height;
|
|
6654
8523
|
this.inMemoryContext.putImageData(this.currImgData, 0, 0);
|
|
6655
8524
|
if (this.flipState.toLowerCase() === 'horizontal') {
|
|
8525
|
+
const tempFilter = this.lowerContext.filter;
|
|
8526
|
+
this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
|
|
8527
|
+
'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
|
|
6656
8528
|
for (let i = 0, len = this.objColl.length; i < len; i++) {
|
|
6657
8529
|
this.objColl[i].flippedText = false;
|
|
6658
8530
|
if (this.objColl[i].shapeFlip !== '' && this.objColl[i].shapeFlip === this.currFlipState) {
|
|
@@ -6662,13 +8534,16 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
6662
8534
|
this.apply(this.objColl[i].shape, this.objColl[i]);
|
|
6663
8535
|
}
|
|
6664
8536
|
}
|
|
8537
|
+
this.lowerContext.filter = tempFilter;
|
|
6665
8538
|
this.lowerContext.translate(this.lowerContext.canvas.width, 0);
|
|
6666
8539
|
this.lowerContext.scale(-1, 1);
|
|
6667
8540
|
this.upperContext.translate(this.upperContext.canvas.width, 0);
|
|
6668
8541
|
this.upperContext.scale(-1, 1);
|
|
6669
|
-
this.flipDirection = '';
|
|
6670
8542
|
}
|
|
6671
8543
|
else if (this.flipState.toLowerCase() === 'vertical') {
|
|
8544
|
+
const tempFilter = this.lowerContext.filter;
|
|
8545
|
+
this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
|
|
8546
|
+
'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
|
|
6672
8547
|
for (let i = 0, len = this.objColl.length; i < len; i++) {
|
|
6673
8548
|
this.objColl[i].flippedText = false;
|
|
6674
8549
|
if (this.objColl[i].shapeFlip !== '' && this.objColl[i].shapeFlip === this.currFlipState) {
|
|
@@ -6678,11 +8553,11 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
6678
8553
|
this.apply(this.objColl[i].shape, this.objColl[i]);
|
|
6679
8554
|
}
|
|
6680
8555
|
}
|
|
8556
|
+
this.lowerContext.filter = tempFilter;
|
|
6681
8557
|
this.lowerContext.translate(0, this.lowerContext.canvas.height);
|
|
6682
8558
|
this.lowerContext.scale(1, -1);
|
|
6683
8559
|
this.upperContext.translate(0, this.upperContext.canvas.height);
|
|
6684
8560
|
this.upperContext.scale(1, -1);
|
|
6685
|
-
this.flipDirection = '';
|
|
6686
8561
|
}
|
|
6687
8562
|
for (let i = 0, len = this.objColl.length; i < len; i++) {
|
|
6688
8563
|
if (this.objColl[i].flipObjColl.length === 0) {
|
|
@@ -6697,15 +8572,15 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
6697
8572
|
}
|
|
6698
8573
|
this.redrawObj(direction.toLowerCase());
|
|
6699
8574
|
if (this.flipState === '') {
|
|
8575
|
+
const tempFilter = this.lowerContext.filter;
|
|
8576
|
+
this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
|
|
8577
|
+
'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
|
|
6700
8578
|
for (let i = 0, len = this.objColl.length; i < len; i++) {
|
|
6701
8579
|
this.apply(this.objColl[i].shape, this.objColl[i]);
|
|
6702
8580
|
}
|
|
8581
|
+
this.lowerContext.filter = tempFilter;
|
|
6703
8582
|
}
|
|
6704
8583
|
this.refreshActiveObj();
|
|
6705
|
-
if (!this.isUndoRedo) {
|
|
6706
|
-
this.updateUndoRedoColl('flip', direction, this.objColl);
|
|
6707
|
-
}
|
|
6708
|
-
this.isUndoRedo = this.flipMethod = false;
|
|
6709
8584
|
if (!isNullOrUndefined(activeObjShape)) {
|
|
6710
8585
|
if (activeObjShape === 'custom') {
|
|
6711
8586
|
this.activeObj.activePoint = { startX: 0, startY: 0, endX: this.lowerCanvas.width,
|
|
@@ -6717,6 +8592,7 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
6717
8592
|
this.select(activeObjShape);
|
|
6718
8593
|
}
|
|
6719
8594
|
}
|
|
8595
|
+
this.refreshToolbar('main');
|
|
6720
8596
|
}
|
|
6721
8597
|
}
|
|
6722
8598
|
/**
|
|
@@ -6737,6 +8613,8 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
6737
8613
|
*/
|
|
6738
8614
|
open(data) {
|
|
6739
8615
|
if (!this.disabled) {
|
|
8616
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
8617
|
+
const proxy = this;
|
|
6740
8618
|
showSpinner(this.element);
|
|
6741
8619
|
this.element.style.opacity = '0.5';
|
|
6742
8620
|
const toolbar = document.querySelector('#' + this.element.id + '_currPos');
|
|
@@ -6750,11 +8628,16 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
6750
8628
|
if (isNullOrUndefined(this.toolbarTemplate)) {
|
|
6751
8629
|
this.update();
|
|
6752
8630
|
}
|
|
8631
|
+
this.degree = 0;
|
|
8632
|
+
this.flipState = '';
|
|
8633
|
+
this.factor = 1;
|
|
8634
|
+
this.imgDataColl = [];
|
|
6753
8635
|
const type = typeof (data);
|
|
6754
8636
|
if (type === 'string') {
|
|
6755
8637
|
this.imageOnLoad(data);
|
|
6756
8638
|
}
|
|
6757
8639
|
else {
|
|
8640
|
+
const tempFilter = this.lowerContext.filter;
|
|
6758
8641
|
this.lowerCanvas = document.querySelector('#' + this.element.id + '_lowerCanvas');
|
|
6759
8642
|
this.upperCanvas = document.querySelector('#' + this.element.id + '_upperCanvas');
|
|
6760
8643
|
this.lowerContext = this.lowerCanvas.getContext('2d');
|
|
@@ -6768,10 +8651,19 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
6768
8651
|
this.imgDataColl.push({ operation: 'open', value: data });
|
|
6769
8652
|
this.lowerCanvas.width = this.upperCanvas.width = data.width;
|
|
6770
8653
|
this.lowerCanvas.height = this.upperCanvas.height = data.height;
|
|
8654
|
+
this.lowerContext.filter = tempFilter;
|
|
8655
|
+
const temp = this.lowerContext.filter;
|
|
8656
|
+
this.updateBrightnessFilter();
|
|
6771
8657
|
this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
6772
|
-
this.
|
|
8658
|
+
this.lowerContext.filter = temp;
|
|
8659
|
+
this.redrawImg(this.lowerContext.filter);
|
|
6773
8660
|
hideSpinner(this.element);
|
|
6774
8661
|
this.element.style.opacity = '1';
|
|
8662
|
+
// eslint-disable-next-line @typescript-eslint/tslint/config
|
|
8663
|
+
this.lowerCanvas.toBlob(function (blob) {
|
|
8664
|
+
showSpinner(proxy.element);
|
|
8665
|
+
proxy.baseImg.src = URL.createObjectURL(blob);
|
|
8666
|
+
}, 'image/png');
|
|
6775
8667
|
}
|
|
6776
8668
|
}
|
|
6777
8669
|
}
|
|
@@ -6788,6 +8680,8 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
6788
8680
|
this.lowerContext.clearRect(0, 0, this.inMemoryCanvas.height, this.inMemoryCanvas.width);
|
|
6789
8681
|
this.upperContext.clearRect(0, 0, this.inMemoryCanvas.width, this.inMemoryCanvas.height);
|
|
6790
8682
|
this.upperContext.clearRect(0, 0, this.inMemoryCanvas.height, this.inMemoryCanvas.width);
|
|
8683
|
+
this.lowerContext.filter = 'brightness(' + 1 + ') ' + 'contrast(' + 100 + '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
|
|
8684
|
+
'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
|
|
6791
8685
|
showSpinner(this.element);
|
|
6792
8686
|
this.element.style.opacity = '0.5';
|
|
6793
8687
|
if (this.imgDataColl.length > 0) {
|
|
@@ -6798,11 +8692,13 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
6798
8692
|
this.inMemoryCanvas.width = this.imgDataColl[0].value.width;
|
|
6799
8693
|
this.inMemoryCanvas.height = this.imgDataColl[0].value.height;
|
|
6800
8694
|
this.inMemoryContext.putImageData(this.imgDataColl[0].value, 0, 0);
|
|
6801
|
-
this.redrawImg();
|
|
8695
|
+
this.redrawImg(this.lowerContext.filter);
|
|
8696
|
+
this.lowerCanvas.width = this.baseImg.width;
|
|
8697
|
+
this.lowerCanvas.height = this.baseImg.height;
|
|
6802
8698
|
}
|
|
6803
8699
|
this.lowerContext.setTransform(1, 0, 0, 1, 0, 0);
|
|
6804
8700
|
this.upperContext.setTransform(1, 0, 0, 1, 0, 0);
|
|
6805
|
-
this.baseImg.src = this.baseImgSrc;
|
|
8701
|
+
this.baseImg.src = this.baseImgSrc.id;
|
|
6806
8702
|
this.factor = 1;
|
|
6807
8703
|
this.refreshToolbar('main');
|
|
6808
8704
|
if (Browser.isDevice && document.getElementById(this.element.id + '_bottomToolbar')) {
|
|
@@ -6811,22 +8707,20 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
6811
8707
|
this.objColl = [];
|
|
6812
8708
|
this.imgDataColl = [];
|
|
6813
8709
|
this.degree = 0;
|
|
6814
|
-
this.flipState = this.keyHistory = this.currFlipState =
|
|
8710
|
+
this.flipState = this.keyHistory = this.currFlipState = '';
|
|
6815
8711
|
this.upperCanvas.style.display = 'none';
|
|
8712
|
+
this.togglePan = this.togglePen = false;
|
|
6816
8713
|
this.upperCanvas.style.cursor = this.lowerCanvas.style.cursor = 'default';
|
|
6817
|
-
this.
|
|
6818
|
-
this.dragCanvas = this.dragged = this.isUndoRedo = this.activeObj.flippedText = this.flipMethod = false;
|
|
8714
|
+
this.dragCanvas = this.activeObj.flippedText = false;
|
|
6819
8715
|
this.currImgData = {};
|
|
6820
8716
|
this.pannStart = { startX: 0, startY: 0, width: 0, height: 0 };
|
|
6821
8717
|
this.pannEnd = { startX: 0, startY: 0, width: 0, height: 0 };
|
|
6822
8718
|
this.lowerContext.lineWidth = this.upperContext.lineWidth = undefined;
|
|
6823
|
-
this.togglePan = this.togglePen = this.rotateMethod = false;
|
|
6824
8719
|
this.lastX = this.lastY = 0;
|
|
6825
8720
|
this.dragStart = { x: 0, y: 0 };
|
|
6826
8721
|
this.touchEndPoint = {};
|
|
6827
8722
|
this.prevX = this.currX = this.prevY = this.currY = 0;
|
|
6828
|
-
this.
|
|
6829
|
-
this.isBoldbtn = this.isItalicbtn = false;
|
|
8723
|
+
this.tempKeyHistory = '';
|
|
6830
8724
|
this.currentToolbar = 'main';
|
|
6831
8725
|
this.textStartPoints = { x: 0, y: 0 };
|
|
6832
8726
|
this.fontSizeColl = this.penDrawColl = [];
|
|
@@ -6836,14 +8730,24 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
6836
8730
|
this.textSettings =
|
|
6837
8731
|
{ text: 'Enter Text', fontFamily: 'Arial', fontSize: null, bold: false, italic: false, underline: false };
|
|
6838
8732
|
this.tempStrokeSettings = { strokeColor: '#fff', fillColor: '', strokeWidth: null };
|
|
6839
|
-
this.penStrokeWidth = undefined;
|
|
6840
8733
|
this.tempTextSettings =
|
|
6841
8734
|
{ text: 'Enter Text', fontFamily: 'Arial', fontSize: null, bold: false, italic: false, underline: false };
|
|
6842
8735
|
this.refreshActiveObj();
|
|
6843
8736
|
this.timer = undefined;
|
|
8737
|
+
this.penStrokeWidth = undefined;
|
|
6844
8738
|
this.isScreenOriented = false;
|
|
8739
|
+
this.tempObjColl = [];
|
|
8740
|
+
this.tempObjColl = undefined;
|
|
8741
|
+
this.adjustmentLevel = { brightness: 0, contrast: 0, hue: 0, opacity: 100, saturation: 0, blur: 0, exposure: 0, sharpen: false, bw: false };
|
|
8742
|
+
this.tempAdjustmentLevel = { brightness: 0, contrast: 0, hue: 0, opacity: 100, saturation: 0, blur: 0, exposure: 0, sharpen: false, bw: false };
|
|
8743
|
+
this.canvasFilter = this.currentFilter = this.tempAdjustmentValue = '';
|
|
8744
|
+
this.lowerContext.filter = this.initialAdjustmentValue = this.adjustmentValue = 'brightness(' + 1 + ') ' + 'contrast(' + 100
|
|
8745
|
+
+ '%) ' + 'hue-rotate(' + 0 + 'deg) ' +
|
|
8746
|
+
'saturate(' + 100 + '%) ' + 'opacity(' + 1 + ') ' + 'blur(' + 0 + 'px) ' + 'sepia(0%) ' + 'grayscale(0%) ' + 'invert(0%)';
|
|
8747
|
+
this.tempImageData = undefined;
|
|
8748
|
+
this.sharpenedImgData = this.isBrightnessAdjusted = this.isInitialLoading = false;
|
|
6845
8749
|
this.currObjType = { shape: '', isDragging: false, isActiveObj: false, isText: false, isInitialText: false, isLine: false,
|
|
6846
|
-
isInitialLine: false, isCustomCrop: false, isZoomed: false };
|
|
8750
|
+
isInitialLine: false, isCustomCrop: false, isZoomed: false, isFiltered: false, isSave: false };
|
|
6847
8751
|
}
|
|
6848
8752
|
}
|
|
6849
8753
|
/**
|
|
@@ -6860,8 +8764,6 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
6860
8764
|
isRotate = true;
|
|
6861
8765
|
const transitionArgs = { degree: degree };
|
|
6862
8766
|
this.trigger('rotating', transitionArgs);
|
|
6863
|
-
this.rotateMethod = true;
|
|
6864
|
-
this.lastAction = 'rotate';
|
|
6865
8767
|
let splitWords = [];
|
|
6866
8768
|
let activeObjShape;
|
|
6867
8769
|
if (!isNullOrUndefined(this.activeObj.activePoint)) {
|
|
@@ -6879,29 +8781,44 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
6879
8781
|
this.factor = 1;
|
|
6880
8782
|
this.refreshToolbar('main');
|
|
6881
8783
|
}
|
|
6882
|
-
|
|
6883
|
-
if (
|
|
6884
|
-
this.degree
|
|
8784
|
+
const length = Math.abs(degree / 90);
|
|
8785
|
+
if (length > 1) {
|
|
8786
|
+
this.rotateMultiple(length, degree);
|
|
8787
|
+
}
|
|
8788
|
+
else {
|
|
8789
|
+
this.degree += degree;
|
|
8790
|
+
if (this.degree === 360) {
|
|
8791
|
+
this.degree = 0;
|
|
8792
|
+
}
|
|
8793
|
+
const temp = this.lowerContext.filter;
|
|
8794
|
+
this.lowerContext.save();
|
|
8795
|
+
this.setMaximumDimension(this.degree);
|
|
8796
|
+
this.lowerContext.translate(this.lowerCanvas.width / 2, this.lowerCanvas.height / 2);
|
|
8797
|
+
this.lowerContext.rotate(Math.PI / 180 * degree);
|
|
8798
|
+
this.lowerCanvas.style.left = this.upperCanvas.style.left = (this.element.clientWidth - parseInt(this.lowerCanvas.style.maxWidth, 10) - 18) / 2 + 1 + 'px';
|
|
8799
|
+
this.lowerCanvas.style.top = this.upperCanvas.style.top = (this.element.clientHeight - this.toolbarHeight - parseInt(this.lowerCanvas.style.maxHeight, 10)) / 2 + 1 + 'px';
|
|
8800
|
+
this.updateBrightnessFilter();
|
|
8801
|
+
this.lowerContext.drawImage(this.inMemoryCanvas, -this.lowerCanvas.height / 2, -this.lowerCanvas.width / 2);
|
|
8802
|
+
this.lowerContext.filter = temp;
|
|
8803
|
+
this.lowerContext.rotate(Math.PI / 180 * -degree);
|
|
8804
|
+
this.lowerContext.translate(-this.lowerCanvas.width / 2, -this.lowerCanvas.height / 2);
|
|
8805
|
+
this.lowerContext.restore();
|
|
8806
|
+
this.currImgData = this.lowerContext.getImageData(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
8807
|
+
this.inMemoryContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
8808
|
+
this.inMemoryCanvas.width = this.currImgData.width;
|
|
8809
|
+
this.inMemoryCanvas.height = this.currImgData.height;
|
|
8810
|
+
this.inMemoryContext.putImageData(this.currImgData, 0, 0);
|
|
8811
|
+
this.lowerContext.filter = this.canvasFilter;
|
|
8812
|
+
this.updateBrightnessFilter();
|
|
8813
|
+
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
8814
|
+
this.lowerContext.drawImage(this.inMemoryCanvas, 0, 0);
|
|
8815
|
+
this.lowerContext.filter = temp;
|
|
8816
|
+
this.redrawObj(degree);
|
|
6885
8817
|
}
|
|
6886
|
-
this.lowerContext.save();
|
|
6887
|
-
this.setMaximumDimension(this.degree);
|
|
6888
|
-
this.lowerContext.translate(this.lowerCanvas.width / 2, this.lowerCanvas.height / 2);
|
|
6889
|
-
this.lowerContext.rotate(Math.PI / 180 * degree);
|
|
6890
|
-
this.lowerCanvas.style.left = this.upperCanvas.style.left = (this.element.clientWidth - parseInt(this.lowerCanvas.style.maxWidth, 10) - 18) / 2 + 1 + 'px';
|
|
6891
|
-
this.lowerCanvas.style.top = this.upperCanvas.style.top = (this.element.clientHeight - this.toolbarHeight - parseInt(this.lowerCanvas.style.maxHeight, 10)) / 2 + 1 + 'px';
|
|
6892
|
-
this.lowerContext.drawImage(this.inMemoryCanvas, -this.lowerCanvas.height / 2, -this.lowerCanvas.width / 2);
|
|
6893
|
-
this.lowerContext.rotate(Math.PI / 180 * -degree);
|
|
6894
|
-
this.lowerContext.translate(-this.lowerCanvas.width / 2, -this.lowerCanvas.height / 2);
|
|
6895
|
-
this.lowerContext.restore();
|
|
6896
|
-
this.currImgData = this.lowerContext.getImageData(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
6897
|
-
this.inMemoryContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
6898
|
-
this.inMemoryCanvas.width = this.currImgData.width;
|
|
6899
|
-
this.inMemoryCanvas.height = this.currImgData.height;
|
|
6900
|
-
this.inMemoryContext.putImageData(this.currImgData, 0, 0);
|
|
6901
|
-
this.redrawObj(degree);
|
|
6902
8818
|
if (!isNullOrUndefined(activeObjShape)) {
|
|
6903
8819
|
if (activeObjShape === 'custom') {
|
|
6904
|
-
const endPoint = { x: this.lowerCanvas.width - this.pannEnd.startX, y: this.lowerCanvas.height -
|
|
8820
|
+
const endPoint = { x: this.lowerCanvas.width - this.pannEnd.startX, y: this.lowerCanvas.height -
|
|
8821
|
+
this.pannEnd.startY };
|
|
6905
8822
|
this.activeObj.activePoint = { startX: this.pannStart.startX, startY: this.pannStart.startY, endX: endPoint.x,
|
|
6906
8823
|
endY: endPoint.y, width: endPoint.x - this.pannStart.startX, height: endPoint.y - this.pannStart.startY };
|
|
6907
8824
|
this.updateActiveObject(this.calcRatio(), this.activeObj.activePoint, this.activeObj);
|
|
@@ -6913,12 +8830,8 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
6913
8830
|
this.refreshToolbar('main', true, true);
|
|
6914
8831
|
}
|
|
6915
8832
|
this.factor = 1;
|
|
6916
|
-
|
|
6917
|
-
this.updateUndoRedoColl('rotate', degree, this.objColl);
|
|
6918
|
-
}
|
|
6919
|
-
this.isUndoRedo = false;
|
|
8833
|
+
this.refreshToolbar('main');
|
|
6920
8834
|
}
|
|
6921
|
-
this.rotateMethod = false;
|
|
6922
8835
|
return isRotate;
|
|
6923
8836
|
}
|
|
6924
8837
|
/**
|
|
@@ -6936,24 +8849,22 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
6936
8849
|
this.applyPenDraw();
|
|
6937
8850
|
}
|
|
6938
8851
|
this.applyActObj();
|
|
8852
|
+
this.lowerContext.filter = this.canvasFilter;
|
|
6939
8853
|
if (this.factor !== 1) {
|
|
6940
8854
|
this.lowerContext.setTransform(1, 0, 0, 1, 0, 0);
|
|
6941
8855
|
this.upperContext.setTransform(1, 0, 0, 1, 0, 0);
|
|
6942
8856
|
this.factor = 1;
|
|
6943
8857
|
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
6944
8858
|
this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
|
|
6945
|
-
this.
|
|
6946
|
-
for (let i = 0; i < this.objColl.length; i++) {
|
|
6947
|
-
this.apply(this.objColl[i].shape, this.objColl[i]);
|
|
6948
|
-
this.refreshActiveObj();
|
|
6949
|
-
}
|
|
8859
|
+
this.redrawImgWithObj();
|
|
6950
8860
|
}
|
|
6951
8861
|
type = type ? type : 'Png';
|
|
6952
8862
|
this.redrawActObj();
|
|
6953
|
-
const beforeSave = { cancel: false, fileName: 'ImageEditor', fileType: type };
|
|
6954
|
-
const saved = { fileName: 'ImageEditor', fileType: type };
|
|
8863
|
+
const beforeSave = { cancel: false, fileName: fileName ? fileName : 'ImageEditor', fileType: type };
|
|
8864
|
+
const saved = { fileName: fileName ? fileName : 'ImageEditor', fileType: type };
|
|
6955
8865
|
this.trigger('beforeSave', beforeSave, (observableSaveArgs) => {
|
|
6956
8866
|
if (!observableSaveArgs.cancel) {
|
|
8867
|
+
this.currObjType.isSave = true;
|
|
6957
8868
|
fileName = observableSaveArgs.fileName ? observableSaveArgs.fileName : fileName;
|
|
6958
8869
|
if (type.toLowerCase() === 'svg') {
|
|
6959
8870
|
fileName = fileName || 'ImageEditor';
|
|
@@ -7014,7 +8925,8 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
7014
8925
|
this.upperCanvas.style.cursor = 'crosshair';
|
|
7015
8926
|
if (Browser.isDevice) {
|
|
7016
8927
|
const arcRadius = (7.5 * (ratio.width > ratio.height ? ratio.width : ratio.height)) / this.factor;
|
|
7017
|
-
const endPoint = { x: this.lowerCanvas.width - this.pannEnd.startX, y: this.lowerCanvas.height -
|
|
8928
|
+
const endPoint = { x: this.lowerCanvas.width - this.pannEnd.startX, y: this.lowerCanvas.height -
|
|
8929
|
+
this.pannEnd.startY };
|
|
7018
8930
|
this.activeObj.activePoint = { startX: this.pannStart.startX + arcRadius, startY: this.pannStart.startY + arcRadius,
|
|
7019
8931
|
endX: endPoint.x - arcRadius, endY: endPoint.y - arcRadius };
|
|
7020
8932
|
this.activeObj.activePoint.width = this.activeObj.activePoint.endX - this.activeObj.activePoint.startX;
|
|
@@ -7061,12 +8973,13 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
7061
8973
|
*
|
|
7062
8974
|
* @param {boolean} value - Specifies a value whether enable or disable freehand drawing.
|
|
7063
8975
|
*
|
|
7064
|
-
*
|
|
8976
|
+
* @returns {void}.
|
|
8977
|
+
* @private
|
|
7065
8978
|
*/
|
|
7066
8979
|
freeHandDraw(value) {
|
|
7067
8980
|
if (value) {
|
|
7068
8981
|
this.togglePen = true;
|
|
7069
|
-
this.upperCanvas.style.cursor = '
|
|
8982
|
+
this.upperCanvas.style.cursor = 'crosshair';
|
|
7070
8983
|
this.drawPen();
|
|
7071
8984
|
}
|
|
7072
8985
|
else {
|
|
@@ -7075,6 +8988,16 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
7075
8988
|
}
|
|
7076
8989
|
this.refreshToolbar('pen');
|
|
7077
8990
|
}
|
|
8991
|
+
/**
|
|
8992
|
+
* Enable or disable a freehand drawing in an Image Editor.
|
|
8993
|
+
*
|
|
8994
|
+
* @param {boolean} value - Specifies a value whether enable or disable freehand drawing.
|
|
8995
|
+
*
|
|
8996
|
+
* @returns {void}.
|
|
8997
|
+
*/
|
|
8998
|
+
freehandDraw(value) {
|
|
8999
|
+
this.freeHandDraw(value);
|
|
9000
|
+
}
|
|
7078
9001
|
/**
|
|
7079
9002
|
* Enable or disable a panning on the Image Editor.
|
|
7080
9003
|
*
|
|
@@ -7121,17 +9044,8 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
7121
9044
|
this.redrawActObj();
|
|
7122
9045
|
this.refreshActiveObj();
|
|
7123
9046
|
this.upperContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
9047
|
+
this.lowerContext.filter = this.canvasFilter;
|
|
7124
9048
|
this.upperCanvas.style.cursor = 'default';
|
|
7125
|
-
let zoomState;
|
|
7126
|
-
if (value === 3.75 || value === 1) {
|
|
7127
|
-
zoomState = 0.1;
|
|
7128
|
-
}
|
|
7129
|
-
else if (value === -3.75) {
|
|
7130
|
-
zoomState = -0.1;
|
|
7131
|
-
}
|
|
7132
|
-
else {
|
|
7133
|
-
zoomState = value;
|
|
7134
|
-
}
|
|
7135
9049
|
if (this.degree !== 0) {
|
|
7136
9050
|
this.inMemoryContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
7137
9051
|
this.inMemoryContext.clearRect(0, 0, this.lowerCanvas.height, this.lowerCanvas.width);
|
|
@@ -7143,16 +9057,22 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
7143
9057
|
this.lastX = this.lowerCanvas.width / 2;
|
|
7144
9058
|
this.lastY = this.lowerCanvas.height / 2;
|
|
7145
9059
|
}
|
|
7146
|
-
if (value
|
|
7147
|
-
this.zoomImg(
|
|
9060
|
+
if (value === 1.1 || value === -1.1) {
|
|
9061
|
+
this.zoomImg(value);
|
|
7148
9062
|
}
|
|
7149
9063
|
else {
|
|
7150
|
-
|
|
9064
|
+
if (value > 0) {
|
|
9065
|
+
this.zoomImg(3.75);
|
|
9066
|
+
}
|
|
9067
|
+
else {
|
|
9068
|
+
this.zoomImg(-3.75);
|
|
9069
|
+
}
|
|
7151
9070
|
}
|
|
7152
9071
|
this.refreshActiveObj();
|
|
7153
9072
|
if (!isNullOrUndefined(activeObjShape)) {
|
|
7154
9073
|
if (activeObjShape === 'custom') {
|
|
7155
|
-
const endPoint = { x: this.lowerCanvas.width - this.pannEnd.startX, y: this.lowerCanvas.height -
|
|
9074
|
+
const endPoint = { x: this.lowerCanvas.width - this.pannEnd.startX, y: this.lowerCanvas.height -
|
|
9075
|
+
this.pannEnd.startY };
|
|
7156
9076
|
this.activeObj.activePoint = { startX: this.pannStart.startX, startY: this.pannStart.startY, endX: endPoint.x,
|
|
7157
9077
|
endY: endPoint.y, width: endPoint.x - this.pannStart.startX, height: endPoint.y - this.pannStart.startY };
|
|
7158
9078
|
this.updateActiveObject(this.calcRatio(), this.activeObj.activePoint, this.activeObj);
|
|
@@ -7163,10 +9083,6 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
7163
9083
|
}
|
|
7164
9084
|
this.refreshToolbar('main', true, true);
|
|
7165
9085
|
}
|
|
7166
|
-
if (!this.isUndoRedo) {
|
|
7167
|
-
this.updateUndoRedoColl('zoom', zoomState, this.objColl);
|
|
7168
|
-
}
|
|
7169
|
-
this.isUndoRedo = false;
|
|
7170
9086
|
const zoomOut = document.querySelector('#' + this.element.id + '_zoomOut');
|
|
7171
9087
|
if (!isNullOrUndefined(zoomOut) && this.factor === 1) {
|
|
7172
9088
|
zoomOut.classList.add('e-disabled');
|
|
@@ -7174,6 +9090,23 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
7174
9090
|
else if (!isNullOrUndefined(zoomOut)) {
|
|
7175
9091
|
zoomOut.classList.remove('e-disabled');
|
|
7176
9092
|
}
|
|
9093
|
+
if (!this.togglePan) {
|
|
9094
|
+
this.callMainToolbar(false, true);
|
|
9095
|
+
}
|
|
9096
|
+
this.autoEnablePan();
|
|
9097
|
+
if (isNullOrUndefined(this.activeObj.activePoint) || this.activeObj.activePoint.width === 0) {
|
|
9098
|
+
this.refreshToolbar('main');
|
|
9099
|
+
}
|
|
9100
|
+
else {
|
|
9101
|
+
this.refreshToolbar('main', true, true);
|
|
9102
|
+
}
|
|
9103
|
+
const panBtn = this.element.querySelector('.e-img-pan .e-btn');
|
|
9104
|
+
if (!isNullOrUndefined(panBtn) && this.togglePan) {
|
|
9105
|
+
panBtn.classList.add('e-selected-btn');
|
|
9106
|
+
}
|
|
9107
|
+
else if (!isNullOrUndefined(panBtn)) {
|
|
9108
|
+
panBtn.classList.remove('e-selected-btn');
|
|
9109
|
+
}
|
|
7177
9110
|
}
|
|
7178
9111
|
}
|
|
7179
9112
|
/**
|
|
@@ -7354,8 +9287,17 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
7354
9287
|
else {
|
|
7355
9288
|
isSelected = true;
|
|
7356
9289
|
this.activeObj = obj;
|
|
9290
|
+
this.lowerContext.filter = this.canvasFilter;
|
|
7357
9291
|
this.redrawShape(this.activeObj);
|
|
7358
|
-
this.
|
|
9292
|
+
if (this.activeObj.shape === 'text') {
|
|
9293
|
+
this.refreshToolbar('text');
|
|
9294
|
+
}
|
|
9295
|
+
else if (this.activeObj.shape === 'pen') {
|
|
9296
|
+
this.refreshToolbar('pen');
|
|
9297
|
+
}
|
|
9298
|
+
else {
|
|
9299
|
+
this.refreshToolbar('shapes');
|
|
9300
|
+
}
|
|
7359
9301
|
this.updateToolbarItems(this.calcRatio());
|
|
7360
9302
|
}
|
|
7361
9303
|
return isSelected;
|
|
@@ -7387,12 +9329,9 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
7387
9329
|
break;
|
|
7388
9330
|
}
|
|
7389
9331
|
}
|
|
9332
|
+
this.lowerContext.filter = this.canvasFilter;
|
|
7390
9333
|
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
7391
|
-
this.
|
|
7392
|
-
for (let i = 0; i < this.objColl.length; i++) {
|
|
7393
|
-
this.apply(this.objColl[i].shape, this.objColl[i]);
|
|
7394
|
-
this.refreshActiveObj();
|
|
7395
|
-
}
|
|
9334
|
+
this.redrawImgWithObj();
|
|
7396
9335
|
this.refreshToolbar('main');
|
|
7397
9336
|
}
|
|
7398
9337
|
/**
|
|
@@ -7457,9 +9396,60 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
7457
9396
|
canvasWrapper.style.height = this.element.offsetHeight - this.toolbarHeight - 1 + 'px';
|
|
7458
9397
|
this.lowerCanvas.height = this.upperCanvas.height = this.element.offsetHeight - this.toolbarHeight - 1;
|
|
7459
9398
|
}
|
|
9399
|
+
this.lowerContext.filter = this.canvasFilter;
|
|
7460
9400
|
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
7461
9401
|
this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
|
|
7462
9402
|
}
|
|
9403
|
+
/**
|
|
9404
|
+
* To apply the filters to an image
|
|
9405
|
+
*
|
|
9406
|
+
* @param {ImageFilterOptions } filterOption - Specifies the filter options to the image.
|
|
9407
|
+
* @returns {void}.
|
|
9408
|
+
*/
|
|
9409
|
+
applyImageFilter(filterOption) {
|
|
9410
|
+
if (this.initialAdjustmentValue === '') {
|
|
9411
|
+
this.initialAdjustmentValue = 'brightness(1) contrast(100%) hue-rotate(0deg) saturate(100%) opacity(1) blur(0px) sepia(0%) grayscale(0%) invert(0%)';
|
|
9412
|
+
}
|
|
9413
|
+
this.lowerContext.filter = this.initialAdjustmentValue;
|
|
9414
|
+
this.setFilter(filterOption.toString());
|
|
9415
|
+
}
|
|
9416
|
+
/**
|
|
9417
|
+
* To apply the filters to an image
|
|
9418
|
+
*
|
|
9419
|
+
* @param {ImageFinetuneOptions } finetuneOption - Specifies the finetune options to the image.
|
|
9420
|
+
* @param {number } value - Specifies the value for finetuning the image.
|
|
9421
|
+
* @returns {void}.
|
|
9422
|
+
*
|
|
9423
|
+
*/
|
|
9424
|
+
finetuneImage(finetuneOption, value) {
|
|
9425
|
+
if (this.initialAdjustmentValue === '') {
|
|
9426
|
+
this.initialAdjustmentValue = 'brightness(1) contrast(100%) hue-rotate(0deg) saturate(100%) opacity(1) blur(0px) sepia(0%) grayscale(0%) invert(0%)';
|
|
9427
|
+
}
|
|
9428
|
+
this.lowerContext.filter = this.initialAdjustmentValue;
|
|
9429
|
+
switch (finetuneOption) {
|
|
9430
|
+
case 'Brightness':
|
|
9431
|
+
this.setBrightness(value);
|
|
9432
|
+
break;
|
|
9433
|
+
case 'Contrast':
|
|
9434
|
+
this.setContrast(value);
|
|
9435
|
+
break;
|
|
9436
|
+
case 'Hue':
|
|
9437
|
+
this.setHue(value);
|
|
9438
|
+
break;
|
|
9439
|
+
case 'Saturation':
|
|
9440
|
+
this.setSaturation(value);
|
|
9441
|
+
break;
|
|
9442
|
+
case 'Opacity':
|
|
9443
|
+
this.setOpacity(value);
|
|
9444
|
+
break;
|
|
9445
|
+
case 'Blur':
|
|
9446
|
+
this.setBlur(value);
|
|
9447
|
+
break;
|
|
9448
|
+
case 'Exposure':
|
|
9449
|
+
this.setExposure(value);
|
|
9450
|
+
break;
|
|
9451
|
+
}
|
|
9452
|
+
}
|
|
7463
9453
|
/**
|
|
7464
9454
|
* To check whether the undo collection is empty or not.
|
|
7465
9455
|
*
|
|
@@ -7467,7 +9457,7 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
7467
9457
|
* @private
|
|
7468
9458
|
*/
|
|
7469
9459
|
canUndo() {
|
|
7470
|
-
return
|
|
9460
|
+
return false;
|
|
7471
9461
|
}
|
|
7472
9462
|
/**
|
|
7473
9463
|
* To check whether the redo collection is empty or not.
|
|
@@ -7476,7 +9466,7 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
7476
9466
|
* @private
|
|
7477
9467
|
*/
|
|
7478
9468
|
canRedo() {
|
|
7479
|
-
return
|
|
9469
|
+
return false;
|
|
7480
9470
|
}
|
|
7481
9471
|
/**
|
|
7482
9472
|
* Erases all the signature strokes signed by user.
|
|
@@ -7485,7 +9475,9 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
7485
9475
|
* @private
|
|
7486
9476
|
*/
|
|
7487
9477
|
clear() {
|
|
7488
|
-
|
|
9478
|
+
if (this.getModuleName() !== 'image-editor') {
|
|
9479
|
+
super.clear();
|
|
9480
|
+
}
|
|
7489
9481
|
}
|
|
7490
9482
|
/**
|
|
7491
9483
|
* To draw the signature based on the given text, with the font family and font size.
|
|
@@ -7498,7 +9490,9 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
7498
9490
|
* @private
|
|
7499
9491
|
*/
|
|
7500
9492
|
draw(text, fontFamily, fontSize) {
|
|
7501
|
-
|
|
9493
|
+
if (this.getModuleName() !== 'image-editor') {
|
|
9494
|
+
super.draw(text, fontFamily, fontSize);
|
|
9495
|
+
}
|
|
7502
9496
|
}
|
|
7503
9497
|
/**
|
|
7504
9498
|
* To get the signature as Blob.
|
|
@@ -7508,7 +9502,8 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
7508
9502
|
* @private
|
|
7509
9503
|
*/
|
|
7510
9504
|
getBlob(url) {
|
|
7511
|
-
|
|
9505
|
+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
9506
|
+
return url;
|
|
7512
9507
|
}
|
|
7513
9508
|
/**
|
|
7514
9509
|
* To check whether the signature is empty or not.
|
|
@@ -7517,7 +9512,7 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
7517
9512
|
* @private
|
|
7518
9513
|
*/
|
|
7519
9514
|
isEmpty() {
|
|
7520
|
-
return
|
|
9515
|
+
return false;
|
|
7521
9516
|
}
|
|
7522
9517
|
/**
|
|
7523
9518
|
* To load the signature with the given base 64 string, height and width.
|
|
@@ -7529,7 +9524,9 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
7529
9524
|
* @private
|
|
7530
9525
|
*/
|
|
7531
9526
|
load(signature, width, height) {
|
|
7532
|
-
|
|
9527
|
+
if (this.getModuleName() !== 'image-editor') {
|
|
9528
|
+
super.load(signature, width, height);
|
|
9529
|
+
}
|
|
7533
9530
|
}
|
|
7534
9531
|
/**
|
|
7535
9532
|
* Undo the last user action.
|
|
@@ -7538,7 +9535,9 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
7538
9535
|
* @private
|
|
7539
9536
|
*/
|
|
7540
9537
|
undo() {
|
|
7541
|
-
|
|
9538
|
+
if (this.getModuleName() !== 'image-editor') {
|
|
9539
|
+
super.undo();
|
|
9540
|
+
}
|
|
7542
9541
|
}
|
|
7543
9542
|
/**
|
|
7544
9543
|
* Redo the last user action.
|
|
@@ -7547,19 +9546,23 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
7547
9546
|
* @private
|
|
7548
9547
|
*/
|
|
7549
9548
|
redo() {
|
|
7550
|
-
|
|
9549
|
+
if (this.getModuleName() !== 'image-editor') {
|
|
9550
|
+
super.redo();
|
|
9551
|
+
}
|
|
7551
9552
|
}
|
|
7552
9553
|
/**
|
|
7553
9554
|
* To save the signature with the given file type and file name.
|
|
7554
9555
|
*
|
|
7555
|
-
* @param {
|
|
9556
|
+
* @param {FileType} type - specify type of the file to be saved a signature.
|
|
7556
9557
|
* @param {string} fileName - specify name of the file to be saved a signature.
|
|
7557
9558
|
*
|
|
7558
9559
|
* @returns {void}.
|
|
7559
9560
|
* @private
|
|
7560
9561
|
*/
|
|
7561
9562
|
save(type, fileName) {
|
|
7562
|
-
|
|
9563
|
+
if (this.getModuleName() !== 'image-editor') {
|
|
9564
|
+
super.save(type, fileName);
|
|
9565
|
+
}
|
|
7563
9566
|
}
|
|
7564
9567
|
/**
|
|
7565
9568
|
* To save the signature as Blob.
|
|
@@ -7568,16 +9571,17 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends SignatureBase {
|
|
|
7568
9571
|
* @private
|
|
7569
9572
|
*/
|
|
7570
9573
|
saveAsBlob() {
|
|
7571
|
-
return
|
|
9574
|
+
return null;
|
|
7572
9575
|
}
|
|
7573
9576
|
/**
|
|
7574
9577
|
* Returns the persistence data for component.
|
|
7575
9578
|
*
|
|
7576
|
-
* @returns any.
|
|
9579
|
+
* @returns {any}.
|
|
7577
9580
|
* @private
|
|
7578
9581
|
*/
|
|
9582
|
+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
7579
9583
|
getLocalData() {
|
|
7580
|
-
return
|
|
9584
|
+
return null;
|
|
7581
9585
|
}
|
|
7582
9586
|
};
|
|
7583
9587
|
__decorate([
|
|
@@ -7631,6 +9635,12 @@ __decorate([
|
|
|
7631
9635
|
__decorate([
|
|
7632
9636
|
Property(false)
|
|
7633
9637
|
], ImageEditor.prototype, "enablePersistence", void 0);
|
|
9638
|
+
__decorate([
|
|
9639
|
+
Complex({}, FinetuneSettings)
|
|
9640
|
+
], ImageEditor.prototype, "finetuneSettings", void 0);
|
|
9641
|
+
__decorate([
|
|
9642
|
+
Property('')
|
|
9643
|
+
], ImageEditor.prototype, "signatureValue", void 0);
|
|
7634
9644
|
__decorate([
|
|
7635
9645
|
Event()
|
|
7636
9646
|
], ImageEditor.prototype, "beforeSave", void 0);
|
|
@@ -7673,6 +9683,12 @@ __decorate([
|
|
|
7673
9683
|
__decorate([
|
|
7674
9684
|
Event()
|
|
7675
9685
|
], ImageEditor.prototype, "toolbarItemClicked", void 0);
|
|
9686
|
+
__decorate([
|
|
9687
|
+
Event()
|
|
9688
|
+
], ImageEditor.prototype, "imageFiltering", void 0);
|
|
9689
|
+
__decorate([
|
|
9690
|
+
Event()
|
|
9691
|
+
], ImageEditor.prototype, "fineTuneValueChanging", void 0);
|
|
7676
9692
|
ImageEditor = ImageEditor_1 = __decorate([
|
|
7677
9693
|
NotifyPropertyChanges
|
|
7678
9694
|
], ImageEditor);
|
|
@@ -7685,5 +9701,5 @@ ImageEditor = ImageEditor_1 = __decorate([
|
|
|
7685
9701
|
* ImageEditor all modules
|
|
7686
9702
|
*/
|
|
7687
9703
|
|
|
7688
|
-
export { ImageEditor };
|
|
9704
|
+
export { FinetuneSettings, ImageEditor };
|
|
7689
9705
|
//# sourceMappingURL=ej2-image-editor.es2015.js.map
|