@syncfusion/ej2-image-editor 22.2.11 → 23.1.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- 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 +4269 -687
- package/dist/es6/ej2-image-editor.es2015.js.map +1 -1
- package/dist/es6/ej2-image-editor.es5.js +4232 -641
- 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 +12 -12
- package/src/image-editor/action/crop.js +47 -30
- package/src/image-editor/action/draw.d.ts +16 -0
- package/src/image-editor/action/draw.js +827 -81
- package/src/image-editor/action/export.d.ts +3 -0
- package/src/image-editor/action/export.js +84 -20
- package/src/image-editor/action/filter.d.ts +0 -1
- package/src/image-editor/action/filter.js +28 -41
- package/src/image-editor/action/freehand-draw.js +42 -32
- package/src/image-editor/action/selection.d.ts +6 -0
- package/src/image-editor/action/selection.js +380 -66
- package/src/image-editor/action/shape.d.ts +8 -0
- package/src/image-editor/action/shape.js +286 -91
- package/src/image-editor/action/transform.d.ts +9 -0
- package/src/image-editor/action/transform.js +402 -52
- package/src/image-editor/action/undo-redo.d.ts +1 -0
- package/src/image-editor/action/undo-redo.js +138 -10
- package/src/image-editor/base/enum.d.ts +38 -1
- package/src/image-editor/base/enum.js +39 -0
- package/src/image-editor/base/image-editor-model.d.ts +16 -2
- package/src/image-editor/base/image-editor.d.ts +134 -7
- package/src/image-editor/base/image-editor.js +611 -69
- package/src/image-editor/base/interface.d.ts +233 -2
- package/src/image-editor/renderer/toolbar.d.ts +25 -0
- package/src/image-editor/renderer/toolbar.js +1273 -72
- package/styles/bootstrap-dark.css +68 -1
- package/styles/bootstrap.css +68 -1
- package/styles/bootstrap4.css +68 -1
- package/styles/bootstrap5-dark.css +68 -1
- package/styles/bootstrap5.css +68 -1
- package/styles/fabric-dark.css +68 -1
- package/styles/fabric.css +68 -1
- package/styles/fluent-dark.css +68 -1
- package/styles/fluent.css +68 -1
- package/styles/highcontrast-light.css +70 -3
- package/styles/highcontrast.css +69 -7
- 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 +2 -1
- package/styles/image-editor/_highcontrast-light-definition.scss +2 -1
- package/styles/image-editor/_layout.scss +92 -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 +2 -1
- package/styles/image-editor/_tailwind-definition.scss +1 -0
- package/styles/image-editor/_theme.scss +4 -2
- package/styles/image-editor/bootstrap-dark.css +68 -1
- package/styles/image-editor/bootstrap-dark.scss +1 -1
- package/styles/image-editor/bootstrap.css +68 -1
- package/styles/image-editor/bootstrap.scss +1 -1
- package/styles/image-editor/bootstrap4.css +68 -1
- package/styles/image-editor/bootstrap4.scss +1 -1
- package/styles/image-editor/bootstrap5-dark.css +68 -1
- package/styles/image-editor/bootstrap5-dark.scss +1 -1
- package/styles/image-editor/bootstrap5.css +68 -1
- package/styles/image-editor/bootstrap5.scss +1 -1
- package/styles/image-editor/fabric-dark.css +68 -1
- package/styles/image-editor/fabric-dark.scss +1 -1
- package/styles/image-editor/fabric.css +68 -1
- package/styles/image-editor/fabric.scss +1 -1
- package/styles/image-editor/fluent-dark.css +68 -1
- package/styles/image-editor/fluent-dark.scss +1 -1
- package/styles/image-editor/fluent.css +68 -1
- package/styles/image-editor/fluent.scss +1 -1
- package/styles/image-editor/highcontrast-light.css +70 -3
- package/styles/image-editor/highcontrast-light.scss +1 -1
- package/styles/image-editor/highcontrast.css +69 -7
- package/styles/image-editor/highcontrast.scss +1 -1
- package/styles/image-editor/icons/_bootstrap-dark.scss +1 -0
- package/styles/image-editor/icons/_bootstrap.scss +1 -0
- package/styles/image-editor/icons/_bootstrap4.scss +1 -0
- package/styles/image-editor/icons/_bootstrap5.scss +1 -0
- package/styles/image-editor/icons/_fabric-dark.scss +1 -0
- package/styles/image-editor/icons/_fabric.scss +1 -0
- package/styles/image-editor/icons/_fluent.scss +1 -0
- package/styles/image-editor/icons/_fusionnew.scss +1 -0
- package/styles/image-editor/icons/_highcontrast-light.scss +1 -0
- package/styles/image-editor/icons/_highcontrast.scss +1 -0
- package/styles/image-editor/icons/_material-dark.scss +1 -0
- package/styles/image-editor/icons/_material.scss +1 -0
- package/styles/image-editor/icons/_material3.scss +1 -0
- package/styles/image-editor/icons/_tailwind.scss +1 -0
- package/styles/image-editor/material-dark.css +68 -2
- package/styles/image-editor/material-dark.scss +1 -1
- package/styles/image-editor/material.css +68 -2
- package/styles/image-editor/material.scss +1 -1
- package/styles/image-editor/material3-dark.css +73 -4
- package/styles/image-editor/material3-dark.scss +1 -1
- package/styles/image-editor/material3.css +73 -4
- package/styles/image-editor/material3.scss +1 -1
- package/styles/image-editor/tailwind-dark.css +68 -2
- package/styles/image-editor/tailwind-dark.scss +1 -1
- package/styles/image-editor/tailwind.css +68 -2
- package/styles/image-editor/tailwind.scss +1 -1
- package/styles/material-dark.css +68 -2
- package/styles/material.css +68 -2
- package/styles/material3-dark.css +73 -4
- package/styles/material3-dark.scss +1 -1
- package/styles/material3.css +73 -4
- package/styles/material3.scss +1 -1
- package/styles/tailwind-dark.css +68 -2
- package/styles/tailwind.css +68 -2
|
@@ -19,10 +19,11 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
19
19
|
};
|
|
20
20
|
import { Component, NotifyPropertyChanges, Property, addClass, removeClass, extend, isBlazor } from '@syncfusion/ej2-base';
|
|
21
21
|
import { Event, EventHandler, getComponent, isNullOrUndefined, getUniqueID } from '@syncfusion/ej2-base';
|
|
22
|
-
import { createSpinner } from '@syncfusion/ej2-popups';
|
|
22
|
+
import { Dialog, createSpinner } from '@syncfusion/ej2-popups';
|
|
23
23
|
import { Complex, Browser, ChildProperty, compile as templateCompiler, compile } from '@syncfusion/ej2-base';
|
|
24
24
|
import { ToolbarModule, Crop, Draw, Filter, FreehandDrawing, Selection, Shape, Transform, UndoRedo, Export } from './../index';
|
|
25
25
|
import { ZoomTrigger, ImageFinetuneOption } from './../index';
|
|
26
|
+
import { Uploader } from '@syncfusion/ej2-inputs';
|
|
26
27
|
/**
|
|
27
28
|
* This interface is used to specify settings for finetuning operations on images, including brightness, contrast, hue, saturation, exposure, opacity, and blur. It includes properties for setting minimum and maximum values for each of these options, as well as a default value.
|
|
28
29
|
*/
|
|
@@ -158,7 +159,7 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
158
159
|
totalPannedInternalPoint: { x: 0, y: 0 }, tempFlipPanPoint: { x: 0, y: 0 }, activeObj: {}, rotateFlipColl: [],
|
|
159
160
|
degree: 0, currFlipState: '', destPoints: { startX: 0, startY: 0, width: 0, height: 0 },
|
|
160
161
|
srcPoints: { startX: 0, startY: 0, width: 0, height: 0 }, filter: '', isBrightAdjust: false,
|
|
161
|
-
zoomFactor: 0, previousZoomValue: 0 };
|
|
162
|
+
zoomFactor: 0, previousZoomValue: 0, aspectWidth: null, aspectHeight: null, frame: 'none' };
|
|
162
163
|
// Stored transformations performed after cropping
|
|
163
164
|
/** @hidden */
|
|
164
165
|
_this.afterCropActions = [];
|
|
@@ -190,6 +191,30 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
190
191
|
_this.isCropToolbar = false;
|
|
191
192
|
/** @hidden */
|
|
192
193
|
_this.cursor = 'default';
|
|
194
|
+
/** @hidden */
|
|
195
|
+
_this.resizeSrc = { startX: _this.img.srcLeft, startY: _this.img.srcTop, width: _this.img.srcWidth, height: _this.img.srcHeight };
|
|
196
|
+
/** @hidden */
|
|
197
|
+
_this.isResize = false;
|
|
198
|
+
/** @hidden */
|
|
199
|
+
_this.isAspectRatio = false;
|
|
200
|
+
/** @hidden */
|
|
201
|
+
_this.frameObj = { type: 'none', color: '#fff', size: 20, inset: 20, offset: 20, radius: 0, amount: 1, border: 'solid', gradientColor: '' };
|
|
202
|
+
/** @hidden */
|
|
203
|
+
_this.tempFrameObj = { type: 'none', color: '#fff', size: 20, inset: 20, offset: 20, radius: 0, amount: 1, border: 'solid', gradientColor: '' };
|
|
204
|
+
/** @hidden */
|
|
205
|
+
_this.allowDownScale = true;
|
|
206
|
+
/** @hidden */
|
|
207
|
+
_this.gradientColor = '';
|
|
208
|
+
/** @hidden */
|
|
209
|
+
_this.size = 20;
|
|
210
|
+
/** @hidden */
|
|
211
|
+
_this.inset = 0;
|
|
212
|
+
/** @hidden */
|
|
213
|
+
_this.offset = 0;
|
|
214
|
+
/** @hidden */
|
|
215
|
+
_this.borderRadius = 0;
|
|
216
|
+
/** @hidden */
|
|
217
|
+
_this.lineCount = 0;
|
|
193
218
|
if (!isBlazor()) {
|
|
194
219
|
ImageEditor_1.Inject(Crop, Draw, Selection, Transform, Export, ToolbarModule);
|
|
195
220
|
ImageEditor_1.Inject(UndoRedo);
|
|
@@ -414,6 +439,7 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
414
439
|
this.notify('toolbar', { prop: 'create-contextual-toolbar', onPropertyChange: false });
|
|
415
440
|
}
|
|
416
441
|
this.createCanvas();
|
|
442
|
+
this.createDropUploader();
|
|
417
443
|
if (this.showQuickAccessToolbar) {
|
|
418
444
|
var canvasWrapper = document.querySelector('#' + this.element.id + '_canvasWrapper');
|
|
419
445
|
canvasWrapper.appendChild(this.createElement('div', {
|
|
@@ -452,6 +478,56 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
452
478
|
}
|
|
453
479
|
this.initializeZoomSettings();
|
|
454
480
|
};
|
|
481
|
+
ImageEditor.prototype.createDropUploader = function () {
|
|
482
|
+
var _this = this;
|
|
483
|
+
var uploadObj = new Uploader({
|
|
484
|
+
dropArea: document.getElementsByClassName('e-canvas-wrapper')[0],
|
|
485
|
+
allowedExtensions: '.jpg, .jpeg, .png,.svg',
|
|
486
|
+
selected: function (args) {
|
|
487
|
+
if (args.event.type === 'change' || args.event.type === 'drop') {
|
|
488
|
+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
489
|
+
var type = args.filesData[0].type;
|
|
490
|
+
if (type === 'png' || type === 'jpg' || type === 'jpeg' || type === 'svg') {
|
|
491
|
+
_this.notify('draw', { prop: 'fileSelect', value: { inputElement: _this.element.querySelector('#' + _this.element.id + '_dropfileUpload'), args: args } });
|
|
492
|
+
}
|
|
493
|
+
else {
|
|
494
|
+
_this.showDialogPopup();
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
});
|
|
499
|
+
uploadObj.appendTo('#' + this.element.id + '_dropfileUpload');
|
|
500
|
+
};
|
|
501
|
+
ImageEditor.prototype.dlgCloseBtnClick = function () {
|
|
502
|
+
getComponent(document.getElementById(this.element.id + '_dialog'), 'dialog').destroy();
|
|
503
|
+
};
|
|
504
|
+
ImageEditor.prototype.showDialogPopup = function () {
|
|
505
|
+
this.element.querySelector('#' + this.element.id + '_dialog').style.display = 'block';
|
|
506
|
+
var headerObj = { key: 'AlertDialogHeader' };
|
|
507
|
+
this.notify('toolbar', { prop: 'getLocaleText', onPropertyChange: false, value: { obj: headerObj } });
|
|
508
|
+
var contentObj = { key: 'AlertDialogContent' };
|
|
509
|
+
this.notify('toolbar', { prop: 'getLocaleText', onPropertyChange: false, value: { obj: contentObj } });
|
|
510
|
+
var supportObj = { key: 'SupportText' };
|
|
511
|
+
this.notify('toolbar', { prop: 'getLocaleText', onPropertyChange: false, value: { obj: supportObj } });
|
|
512
|
+
var okObj = { key: 'OK' };
|
|
513
|
+
this.notify('toolbar', { prop: 'getLocaleText', onPropertyChange: false, value: { obj: okObj } });
|
|
514
|
+
var dialog = new Dialog({
|
|
515
|
+
header: headerObj['value'],
|
|
516
|
+
closeOnEscape: true,
|
|
517
|
+
content: '<span>' + contentObj['value'] + ' ' + supportObj['value'] + '<b> JPG, PNG, and SVG</b></span>',
|
|
518
|
+
target: document.getElementById('target'),
|
|
519
|
+
width: '285px',
|
|
520
|
+
isModal: true,
|
|
521
|
+
animationSettings: { effect: 'Zoom' },
|
|
522
|
+
close: this.dlgCloseBtnClick.bind(this),
|
|
523
|
+
buttons: [
|
|
524
|
+
{ click: this.dlgCloseBtnClick.bind(this),
|
|
525
|
+
buttonModel: { content: okObj['value'], iconCss: 'e-icons e-close' }
|
|
526
|
+
}
|
|
527
|
+
]
|
|
528
|
+
});
|
|
529
|
+
dialog.appendTo('#' + this.element.id + '_dialog');
|
|
530
|
+
};
|
|
455
531
|
/**
|
|
456
532
|
*
|
|
457
533
|
* This Method will add events to component (element, event, method, current reference)
|
|
@@ -508,6 +584,7 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
508
584
|
this.notify('selection', { prop: 'unWireEvent', onPropertyChange: false });
|
|
509
585
|
};
|
|
510
586
|
ImageEditor.prototype.createCanvas = function () {
|
|
587
|
+
var _this = this;
|
|
511
588
|
this.element.style.boxSizing = 'border-box';
|
|
512
589
|
var obj = { toolbarHeight: 0 };
|
|
513
590
|
this.notify('toolbar', { prop: 'getToolbarHeight', value: { obj: obj } });
|
|
@@ -519,6 +596,31 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
519
596
|
(this.element.offsetWidth - 2)
|
|
520
597
|
+ 'px; position: relative; overflow: hidden; margin: 0 auto;' }
|
|
521
598
|
}));
|
|
599
|
+
var dragObj = { key: 'DragText' };
|
|
600
|
+
this.notify('toolbar', { prop: 'getLocaleText', onPropertyChange: false, value: { obj: dragObj } });
|
|
601
|
+
var browseObj = { key: 'BrowseText' };
|
|
602
|
+
this.notify('toolbar', { prop: 'getLocaleText', onPropertyChange: false, value: { obj: browseObj } });
|
|
603
|
+
var supportObj = { key: 'SupportText' };
|
|
604
|
+
this.notify('toolbar', { prop: 'getLocaleText', onPropertyChange: false, value: { obj: supportObj } });
|
|
605
|
+
var dropAreaElement = this.createElement('div', { id: this.element.id + '_dropArea', className: 'e-ie-drop-area', attrs: { style: 'position: relative;' } });
|
|
606
|
+
var dropIconElement = this.createElement('span', { className: 'e-ie-drop-icon e-icons e-image', attrs: { style: 'position: absolute;' } });
|
|
607
|
+
var dropContentElement = this.createElement('span', { className: 'e-ie-drop-content', attrs: { style: 'position: absolute;' } });
|
|
608
|
+
dropContentElement.textContent = dragObj['value'] + ' ';
|
|
609
|
+
var dropAnchorElement = this.createElement('a', { id: this.element.id + '_dropBrowse', className: 'e-ie-drop-browse' });
|
|
610
|
+
dropAnchorElement.textContent = browseObj['value'];
|
|
611
|
+
dropContentElement.appendChild(dropAnchorElement);
|
|
612
|
+
dropAnchorElement.href = '';
|
|
613
|
+
var dropInfoElement = this.createElement('span', { className: 'e-ie-drop-info', attrs: { position: 'absolute' } });
|
|
614
|
+
dropInfoElement.textContent = supportObj['value'] + ' SVG, PNG, and JPG';
|
|
615
|
+
var dropUploader = dropAreaElement.appendChild(this.createElement('input', {
|
|
616
|
+
id: this.element.id + '_dropfileUpload', className: 'e-fileUpload e-image-upload'
|
|
617
|
+
}));
|
|
618
|
+
dropUploader.setAttribute('type', 'file');
|
|
619
|
+
dropUploader.setAttribute('accept', 'image/*');
|
|
620
|
+
dropAreaElement.appendChild(dropIconElement);
|
|
621
|
+
dropAreaElement.appendChild(dropContentElement);
|
|
622
|
+
dropAreaElement.appendChild(dropInfoElement);
|
|
623
|
+
canvasWrapper.appendChild(dropAreaElement);
|
|
522
624
|
this.lowerCanvas = canvasWrapper.appendChild(this.createElement('canvas', {
|
|
523
625
|
id: this.element.id + '_lowerCanvas', attrs: { name: 'canvasImage' }
|
|
524
626
|
}));
|
|
@@ -528,6 +630,9 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
528
630
|
this.inMemoryCanvas = this.createElement('canvas', {
|
|
529
631
|
id: this.element.id + '_inMemoryCanvas', attrs: { name: 'canvasImage' }
|
|
530
632
|
});
|
|
633
|
+
this.baseImgCanvas = this.createElement('canvas', {
|
|
634
|
+
id: this.element.id + '_baseImgCanvas', attrs: { name: 'canvasImage' }
|
|
635
|
+
});
|
|
531
636
|
this.textArea = canvasWrapper.appendChild(this.createElement('textarea', {
|
|
532
637
|
id: this.element.id + '_textArea', className: 'e-textarea', attrs: { name: 'textArea' }
|
|
533
638
|
}));
|
|
@@ -535,6 +640,12 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
535
640
|
id: this.element.id + '_dialog', className: 'e-dialog'
|
|
536
641
|
}));
|
|
537
642
|
dialog.style.display = 'none';
|
|
643
|
+
var uploader = this.element.appendChild(this.createElement('input', {
|
|
644
|
+
id: this.element.id + '_fileUpload', className: 'e-fileUpload'
|
|
645
|
+
}));
|
|
646
|
+
uploader.setAttribute('type', 'file');
|
|
647
|
+
uploader.setAttribute('accept', 'image/*');
|
|
648
|
+
uploader.style.display = 'none';
|
|
538
649
|
this.textArea.setAttribute('spellcheck', 'false');
|
|
539
650
|
this.textArea.style.lineHeight = 'normal';
|
|
540
651
|
this.lowerCanvas.style.width = this.upperCanvas.style.width = this.inMemoryCanvas.style.width = '100%';
|
|
@@ -550,17 +661,27 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
550
661
|
this.upperCanvas.style.cursor = this.cursor = 'default';
|
|
551
662
|
this.upperCanvas.style.display = 'block';
|
|
552
663
|
this.upperContext = this.upperCanvas.getContext('2d');
|
|
664
|
+
document.getElementById(this.element.id + '_dropBrowse').onclick = function () {
|
|
665
|
+
_this.element.querySelector('#' + _this.element.id + '_dropfileUpload').click();
|
|
666
|
+
return false;
|
|
667
|
+
};
|
|
553
668
|
};
|
|
554
669
|
ImageEditor.prototype.touchStartHandler = function (e) {
|
|
555
670
|
this.notify('selection', { prop: 'touchStartHandler', onPropertyChange: false, value: { e: e } });
|
|
556
671
|
};
|
|
557
672
|
ImageEditor.prototype.mouseDownEventHandler = function (e) {
|
|
673
|
+
if (e.target.className === 'e-ie-drop-browse') {
|
|
674
|
+
return;
|
|
675
|
+
}
|
|
558
676
|
this.notify('selection', { prop: 'mouseDownEventHandler', onPropertyChange: false, value: { e: e } });
|
|
559
677
|
};
|
|
560
678
|
ImageEditor.prototype.mouseMoveEventHandler = function (e) {
|
|
561
679
|
this.notify('selection', { prop: 'mouseMoveEventHandler', onPropertyChange: false, value: { e: e } });
|
|
562
680
|
};
|
|
563
681
|
ImageEditor.prototype.mouseUpEventHandler = function (e) {
|
|
682
|
+
if (e.target.className === 'e-ie-drop-browse') {
|
|
683
|
+
return;
|
|
684
|
+
}
|
|
564
685
|
this.notify('selection', { prop: 'mouseUpEventHandler', onPropertyChange: false, value: { e: e } });
|
|
565
686
|
};
|
|
566
687
|
ImageEditor.prototype.keyDownEventHandler = function (e) {
|
|
@@ -573,12 +694,18 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
573
694
|
}
|
|
574
695
|
};
|
|
575
696
|
ImageEditor.prototype.canvasMouseDownHandler = function (e) {
|
|
697
|
+
if (e.target.className === 'e-ie-drop-browse') {
|
|
698
|
+
return;
|
|
699
|
+
}
|
|
576
700
|
this.notify('selection', { prop: 'canvasMouseDownHandler', onPropertyChange: false, value: { e: e } });
|
|
577
701
|
};
|
|
578
702
|
ImageEditor.prototype.canvasMouseMoveHandler = function (e) {
|
|
579
703
|
this.notify('selection', { prop: 'canvasMouseMoveHandler', onPropertyChange: false, value: { e: e } });
|
|
580
704
|
};
|
|
581
705
|
ImageEditor.prototype.canvasMouseUpHandler = function (e) {
|
|
706
|
+
if (e.target.className === 'e-ie-drop-browse') {
|
|
707
|
+
return;
|
|
708
|
+
}
|
|
582
709
|
this.notify('selection', { prop: 'canvasMouseUpHandler', onPropertyChange: false, value: { e: e } });
|
|
583
710
|
};
|
|
584
711
|
ImageEditor.prototype.handleScroll = function (e) {
|
|
@@ -643,7 +770,7 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
643
770
|
* A horizontal direction for horizontal flipping and vertical direction for vertical flipping.
|
|
644
771
|
*
|
|
645
772
|
* @remarks
|
|
646
|
-
* It flips the shapes including rectangle, circle, line, text, and freehand drawings.
|
|
773
|
+
* It flips the shapes including rectangle, circle, line, text, image, and freehand drawings.
|
|
647
774
|
*
|
|
648
775
|
* @returns {void}.
|
|
649
776
|
*
|
|
@@ -677,6 +804,7 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
677
804
|
* @returns {void}.
|
|
678
805
|
*/
|
|
679
806
|
ImageEditor.prototype.open = function (data) {
|
|
807
|
+
document.getElementById(this.element.id + '_dropArea').style.display = 'none';
|
|
680
808
|
this.notify('draw', { prop: 'open', value: { data: data } });
|
|
681
809
|
};
|
|
682
810
|
/**
|
|
@@ -703,14 +831,17 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
703
831
|
this.notify('toolbar', { prop: 'create-bottom-toolbar', onPropertyChange: false });
|
|
704
832
|
}
|
|
705
833
|
}
|
|
834
|
+
var isImageLoaded = this.isImageLoaded;
|
|
706
835
|
this.currObjType.isUndoAction = this.isUndoRedo = this.togglePan = this.togglePen = this.isImageLoaded = false;
|
|
707
836
|
this.isCircleCrop = this.isCropTab = false;
|
|
708
837
|
this.objColl = [];
|
|
709
838
|
this.transform.degree = 0;
|
|
710
839
|
this.upperCanvas.style.display = 'block';
|
|
711
840
|
this.transform.currFlipState = '';
|
|
841
|
+
this.allowDownScale = true;
|
|
712
842
|
this.upperCanvas.style.cursor = this.cursor = this.lowerCanvas.style.cursor = 'default';
|
|
713
843
|
this.lowerContext.lineWidth = this.upperContext.lineWidth = undefined;
|
|
844
|
+
this.frameDestPoints = null;
|
|
714
845
|
this.textArea.value = this.textArea.textContent = '';
|
|
715
846
|
this.textArea.style.display = 'none';
|
|
716
847
|
this.lowerContext.filter = this.canvasFilter = this.getDefaultFilter();
|
|
@@ -730,16 +861,20 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
730
861
|
this.lowerCanvas.style.maxHeight = this.upperCanvas.style.maxHeight = '';
|
|
731
862
|
this.transform.defaultZoomFactor = this.transform.zoomFactor = 0;
|
|
732
863
|
this.transform.cropZoomFactor = null;
|
|
864
|
+
this.frameObj = { type: 'none', color: '#fff', size: 20, inset: 20, offset: 20, radius: 0, amount: 1, border: 'solid', gradientColor: '' };
|
|
865
|
+
this.tempFrameObj = { type: 'none', color: '#fff', size: 20, inset: 20, offset: 20, radius: 0, amount: 1, border: 'solid', gradientColor: '' };
|
|
733
866
|
this.currObjType = { shape: '', isDragging: false, isActiveObj: false, isText: false, isInitialText: false, isLine: false,
|
|
734
867
|
isInitialLine: false, isCustomCrop: false, isZoomed: false, isUndoZoom: false,
|
|
735
868
|
isUndoAction: false, isFiltered: false, isSave: false, isResize: false };
|
|
736
869
|
this.cropObj = { cropZoom: 0, defaultZoom: 0, totalPannedPoint: { x: 0, y: 0 }, totalPannedClientPoint: { x: 0, y: 0 },
|
|
737
870
|
totalPannedInternalPoint: { x: 0, y: 0 }, tempFlipPanPoint: { x: 0, y: 0 }, activeObj: {},
|
|
738
871
|
rotateFlipColl: [], degree: 0, currFlipState: '', zoomFactor: 0, previousZoomValue: 0,
|
|
739
|
-
destPoints: { startX: 0, startY: 0, width: 0, height: 0 },
|
|
740
|
-
srcPoints: { startX: 0, startY: 0, width: 0, height: 0 }, filter: '', isBrightAdjust: false
|
|
872
|
+
destPoints: { startX: 0, startY: 0, width: 0, height: 0 }, frame: 'none',
|
|
873
|
+
srcPoints: { startX: 0, startY: 0, width: 0, height: 0 }, filter: '', isBrightAdjust: false,
|
|
874
|
+
aspectWidth: null, aspectHeight: null };
|
|
741
875
|
this.afterCropActions = [];
|
|
742
876
|
this.currentFilter = '';
|
|
877
|
+
this.tempFrameZoomLevel = null;
|
|
743
878
|
var obj_1 = { initialZoomValue: false };
|
|
744
879
|
this.notify('draw', { prop: 'getInitialZoomValue', onPropertyChange: false, value: { obj: obj_1 } });
|
|
745
880
|
if (obj_1['initialZoomValue']) {
|
|
@@ -752,7 +887,7 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
752
887
|
this.notify('filter', { prop: 'update-finetunes' });
|
|
753
888
|
this.isImageLoaded = false;
|
|
754
889
|
this.notify('draw', { prop: 'update-canvas', onPropertyChange: false });
|
|
755
|
-
this.isImageLoaded =
|
|
890
|
+
this.isImageLoaded = isImageLoaded;
|
|
756
891
|
if (!isBlazor()) {
|
|
757
892
|
if (this.element.querySelector('.e-contextual-toolbar-wrapper')) {
|
|
758
893
|
this.element.querySelector('.e-contextual-toolbar-wrapper').classList.add('e-hide');
|
|
@@ -771,7 +906,7 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
771
906
|
* A positive integer value for clockwise and negative integer value for anti-clockwise rotation.
|
|
772
907
|
*
|
|
773
908
|
* @remarks
|
|
774
|
-
* It rotated the shapes including rectangle, circle, line, text, and freehand drawings.
|
|
909
|
+
* It rotated the shapes including rectangle, circle, line, text, image, and freehand drawings.
|
|
775
910
|
*
|
|
776
911
|
* @returns {boolean}.
|
|
777
912
|
*
|
|
@@ -884,16 +1019,17 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
884
1019
|
* @param {number} strokeWidth - Specifies the stroke width of ellipse.
|
|
885
1020
|
* @param {string} strokeColor - Specifies the stroke color of ellipse.
|
|
886
1021
|
* @param {string} fillColor - Specifies the fill color of the ellipse.
|
|
1022
|
+
* @param {number} degree - Specifies the degree to rotate the ellipse.
|
|
887
1023
|
* @returns {boolean}.
|
|
888
1024
|
*
|
|
889
1025
|
*/
|
|
890
|
-
ImageEditor.prototype.drawEllipse = function (x, y, radiusX, radiusY, strokeWidth, strokeColor, fillColor) {
|
|
1026
|
+
ImageEditor.prototype.drawEllipse = function (x, y, radiusX, radiusY, strokeWidth, strokeColor, fillColor, degree) {
|
|
891
1027
|
var isEllipse = false;
|
|
892
1028
|
var isPointsInRange = this.allowShape(x, y);
|
|
893
1029
|
if (!this.disabled && this.isImageLoaded && (isPointsInRange || (isNullOrUndefined(x) && isNullOrUndefined(y)))) {
|
|
894
1030
|
isEllipse = true;
|
|
895
1031
|
this.notify('shape', { prop: 'drawEllipse', onPropertyChange: false, value: { x: x, y: y, radiusX: radiusX, radiusY: radiusY,
|
|
896
|
-
strokeWidth: strokeWidth, strokeColor: strokeColor, fillColor: fillColor } });
|
|
1032
|
+
strokeWidth: strokeWidth, strokeColor: strokeColor, fillColor: fillColor, degree: degree } });
|
|
897
1033
|
}
|
|
898
1034
|
return isEllipse;
|
|
899
1035
|
};
|
|
@@ -979,15 +1115,16 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
979
1115
|
* @param {number} strokeWidth - Specifies the stroke width of rectangle.
|
|
980
1116
|
* @param {string} strokeColor - Specifies the stroke color of rectangle.
|
|
981
1117
|
* @param {string} fillColor - Specifies the fill color of the rectangle.
|
|
1118
|
+
* @param {number} degree - Specifies the degree to rotate the rectangle.
|
|
982
1119
|
* @returns {boolean}.
|
|
983
1120
|
*/
|
|
984
|
-
ImageEditor.prototype.drawRectangle = function (x, y, width, height, strokeWidth, strokeColor, fillColor) {
|
|
1121
|
+
ImageEditor.prototype.drawRectangle = function (x, y, width, height, strokeWidth, strokeColor, fillColor, degree) {
|
|
985
1122
|
var isRectangle = false;
|
|
986
1123
|
var isPointsInRange = this.allowShape(x, y);
|
|
987
1124
|
if (!this.disabled && this.isImageLoaded && (isPointsInRange || (isNullOrUndefined(x) && isNullOrUndefined(y)))) {
|
|
988
1125
|
isRectangle = true;
|
|
989
1126
|
this.notify('shape', { prop: 'drawRectangle', onPropertyChange: false, value: { x: x, y: y, width: width, height: height,
|
|
990
|
-
strokeWidth: strokeWidth, strokeColor: strokeColor, fillColor: fillColor } });
|
|
1127
|
+
strokeWidth: strokeWidth, strokeColor: strokeColor, fillColor: fillColor, degree: degree } });
|
|
991
1128
|
}
|
|
992
1129
|
return isRectangle;
|
|
993
1130
|
};
|
|
@@ -1017,6 +1154,33 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
1017
1154
|
}
|
|
1018
1155
|
return isText;
|
|
1019
1156
|
};
|
|
1157
|
+
/**
|
|
1158
|
+
* Draw an image as annotation on an image.
|
|
1159
|
+
*
|
|
1160
|
+
*
|
|
1161
|
+
* @param {string | ImageData} data - Specifies url of the image or image data.
|
|
1162
|
+
* @param {number} x - Specifies x-coordinate of a starting point for an image.
|
|
1163
|
+
* @param {number} y - Specifies y-coordinate of a starting point for an image.
|
|
1164
|
+
* @param {number} width - Specifies the width of the image.
|
|
1165
|
+
* @param {number} height - Specifies the height of the image.
|
|
1166
|
+
* @param {boolean} isAspectRatio - Specifies whether to maintain aspect ratio or not.
|
|
1167
|
+
* @param {number} degree - Specifies the degree to rotate the image.
|
|
1168
|
+
* @returns {boolean}.
|
|
1169
|
+
*
|
|
1170
|
+
*/
|
|
1171
|
+
ImageEditor.prototype.drawImage = function (data, x, y, width, height, isAspectRatio, degree) {
|
|
1172
|
+
var isImage = false;
|
|
1173
|
+
var isPointsInRange = this.allowShape(x, y);
|
|
1174
|
+
if (!this.disabled && this.isImageLoaded && (isPointsInRange || (isNullOrUndefined(x) && isNullOrUndefined(y)))) {
|
|
1175
|
+
var length_1 = this.objColl.length;
|
|
1176
|
+
this.notify('shape', { prop: 'drawImage', onPropertyChange: false, value: { x: x, y: y, width: width, height: height,
|
|
1177
|
+
src: data, degree: degree, isAspectRatio: isAspectRatio } });
|
|
1178
|
+
if (this.objColl.length > length_1) {
|
|
1179
|
+
isImage = true;
|
|
1180
|
+
}
|
|
1181
|
+
}
|
|
1182
|
+
return isImage;
|
|
1183
|
+
};
|
|
1020
1184
|
/**
|
|
1021
1185
|
* Select a shape based on the given shape id.
|
|
1022
1186
|
* Use 'getShapeSettings' method to get the shape id which is then passed to perform selection.
|
|
@@ -1142,6 +1306,113 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
1142
1306
|
ImageEditor.prototype.getImageDimension = function () {
|
|
1143
1307
|
return { x: this.img.destLeft, y: this.img.destTop, width: this.img.destWidth, height: this.img.destHeight };
|
|
1144
1308
|
};
|
|
1309
|
+
/**
|
|
1310
|
+
* Resize an image by changing its width and height.
|
|
1311
|
+
*
|
|
1312
|
+
* @param {number} width - Specifies the width of an image.
|
|
1313
|
+
* @param {number} height - Specifies the height of an image.
|
|
1314
|
+
* @param {boolean} isAspectRatio - Specifies whether the scaling option is enabled or not.
|
|
1315
|
+
*
|
|
1316
|
+
* @returns {boolean} - A boolean value indicating the success of the resizing operation.
|
|
1317
|
+
*/
|
|
1318
|
+
ImageEditor.prototype.resize = function (width, height, isAspectRatio) {
|
|
1319
|
+
var isResized = false;
|
|
1320
|
+
if ((width.toString()).length <= 4 && (height.toString()).length <= 4) {
|
|
1321
|
+
var destPoints = { startX: this.img.destLeft, startY: this.img.destTop, width: this.img.destWidth,
|
|
1322
|
+
height: this.img.destHeight };
|
|
1323
|
+
if (isBlazor()) {
|
|
1324
|
+
this.updateToolbar(this.element, 'resize');
|
|
1325
|
+
}
|
|
1326
|
+
else {
|
|
1327
|
+
if (isAspectRatio) {
|
|
1328
|
+
this.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: { type: 'resize',
|
|
1329
|
+
isApplyBtn: false, isCropping: false } });
|
|
1330
|
+
this.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: { type: 'resize',
|
|
1331
|
+
isApplyBtn: false, isCropping: false } });
|
|
1332
|
+
}
|
|
1333
|
+
else {
|
|
1334
|
+
this.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: { type: 'resize',
|
|
1335
|
+
isApplyBtn: false, isCropping: false } });
|
|
1336
|
+
}
|
|
1337
|
+
var aspectRatioWidth = this.element.querySelector('#' + this.element.id + '_resizeWidth');
|
|
1338
|
+
var aspectRatioHeight = this.element.querySelector('#' + this.element.id + '_resizeHeight');
|
|
1339
|
+
if (aspectRatioWidth && aspectRatioHeight) {
|
|
1340
|
+
getComponent(aspectRatioWidth, 'numerictextbox').value = Math.floor(width);
|
|
1341
|
+
aspectRatioWidth.value = Math.floor(width).toString() + ' px';
|
|
1342
|
+
getComponent(aspectRatioHeight, 'numerictextbox').value = Math.floor(height);
|
|
1343
|
+
aspectRatioHeight.value = Math.floor(height).toString() + ' px';
|
|
1344
|
+
}
|
|
1345
|
+
}
|
|
1346
|
+
this.notify('transform', { prop: 'resize', value: { width: width, height: height, isAspectRatio: isAspectRatio } });
|
|
1347
|
+
if (destPoints.startX !== this.img.destLeft || destPoints.startY !== this.img.destTop ||
|
|
1348
|
+
destPoints.width !== this.img.destWidth || destPoints.height !== this.img.destHeight) {
|
|
1349
|
+
isResized = true;
|
|
1350
|
+
this.okBtn();
|
|
1351
|
+
}
|
|
1352
|
+
else {
|
|
1353
|
+
this.notify('draw', { prop: 'performCancel', value: { isContextualToolbar: null } });
|
|
1354
|
+
}
|
|
1355
|
+
}
|
|
1356
|
+
return isResized;
|
|
1357
|
+
};
|
|
1358
|
+
/**
|
|
1359
|
+
* Draw a frame on an image.
|
|
1360
|
+
*
|
|
1361
|
+
* @param { FrameType} frameType - Specifies the frame option to be drawn on an image.
|
|
1362
|
+
* @param {string} color - Specifies the color of a frame on an image. The default value is ‘#fff’.
|
|
1363
|
+
* @param {string} gradientColor - Specifies the gradient color of a frame on an image. The default value is ‘’.
|
|
1364
|
+
* @param {number} size - Specifies the size of the frame as a percentage. It can be provided as an integer percentage (e.g., 10). Defaults to 20 if not specified.
|
|
1365
|
+
* @param {number} inset - Specifies the inset value for line, hook, and inset type frames, as a percentage. It can be provided as an integer percentage (e.g., 10). Defaults to 0 if not specified.
|
|
1366
|
+
* @param {number} offset - Specifies the offset value for line and inset type frames, as a percentage. It can be provided as an integer percentage (e.g., 10). Defaults to 0 if not specified.
|
|
1367
|
+
* @param {number} borderRadius - Specifies the border radius for line-type frames, as a percentage. It can be provided as an integer percentage (e.g., 10). Defaults to 0 if not specified.
|
|
1368
|
+
* @param {FrameLineStyle} frameLineStyle - Specifies the type of line to be drawn for line-type frames. Default to Solid if not specified.
|
|
1369
|
+
* @param {number} lineCount - Specifies the number of lines for line-type frames. Defaults to 0 if not specified.
|
|
1370
|
+
*
|
|
1371
|
+
* @returns {boolean}.
|
|
1372
|
+
*/
|
|
1373
|
+
ImageEditor.prototype.drawFrame = function (frameType, color, gradientColor, size, inset, offset, borderRadius, frameLineStyle, lineCount) {
|
|
1374
|
+
var isFrame = false;
|
|
1375
|
+
var obj = { frameChangeEventArgs: null };
|
|
1376
|
+
var prevFrameSettings = { type: this.toPascalCase(this.frameObj.type), color: this.frameObj.color,
|
|
1377
|
+
gradientColor: this.frameObj.gradientColor, size: this.frameObj.size, inset: this.frameObj.inset,
|
|
1378
|
+
offset: this.frameObj.offset, borderRadius: this.frameObj.radius, frameLineStyle: this.toPascalCase(this.frameObj.border),
|
|
1379
|
+
lineCount: this.frameObj.amount };
|
|
1380
|
+
extend(this.tempFrameObj, this.frameObj);
|
|
1381
|
+
this.tempFrameZoomLevel = this.transform.zoomFactor;
|
|
1382
|
+
this.frameDestPoints = extend({}, this.img, {}, true);
|
|
1383
|
+
if (!isBlazor()) {
|
|
1384
|
+
this.notify('toolbar', { prop: 'frameToolbarClick' });
|
|
1385
|
+
}
|
|
1386
|
+
else {
|
|
1387
|
+
this.performFrameClick();
|
|
1388
|
+
}
|
|
1389
|
+
this.frameObj.type = frameType.toLowerCase();
|
|
1390
|
+
this.frameObj.color = color;
|
|
1391
|
+
this.frameObj.gradientColor = gradientColor;
|
|
1392
|
+
this.frameObj.size = size;
|
|
1393
|
+
this.frameObj.inset = inset;
|
|
1394
|
+
this.frameObj.offset = offset;
|
|
1395
|
+
this.frameObj.radius = borderRadius;
|
|
1396
|
+
this.frameObj.border = frameLineStyle.toLowerCase();
|
|
1397
|
+
this.frameObj.amount = lineCount;
|
|
1398
|
+
this.notify('draw', { prop: 'triggerFrameChange', value: { prevFrameSettings: prevFrameSettings, obj: obj } });
|
|
1399
|
+
if (obj['frameChangeEventArgs'] && !obj['frameChangeEventArgs'].cancel) {
|
|
1400
|
+
this.notify('draw', { prop: 'render-image', value: { isMouseWheel: null } });
|
|
1401
|
+
if (JSON.stringify(this.frameObj) !== JSON.stringify(this.tempFrameObj)) {
|
|
1402
|
+
isFrame = true;
|
|
1403
|
+
this.okBtn();
|
|
1404
|
+
}
|
|
1405
|
+
else {
|
|
1406
|
+
this.tempFrameZoomLevel = null;
|
|
1407
|
+
}
|
|
1408
|
+
}
|
|
1409
|
+
else {
|
|
1410
|
+
this.notify('draw', { prop: 'performCancel', value: { isContextualToolbar: null } });
|
|
1411
|
+
extend(this.frameObj, this.tempFrameObj);
|
|
1412
|
+
this.tempFrameZoomLevel = null;
|
|
1413
|
+
}
|
|
1414
|
+
return isFrame;
|
|
1415
|
+
};
|
|
1145
1416
|
// Toolbar related codes
|
|
1146
1417
|
ImageEditor.prototype.toolbarTemplateFn = function () {
|
|
1147
1418
|
var template;
|
|
@@ -1225,6 +1496,33 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
1225
1496
|
this.notify('freehand-draw', { prop: 'getTempFreeHandDrawEditingStyles', value: { obj: obj } });
|
|
1226
1497
|
this.notify('freehand-draw', { prop: 'color-change', value: { color: obj['tempFreeHandDrawEditingStyles'].strokeColor } });
|
|
1227
1498
|
};
|
|
1499
|
+
ImageEditor.prototype.updateImageTransformColl = function (type) {
|
|
1500
|
+
var value;
|
|
1501
|
+
if (type === 'rotateleft') {
|
|
1502
|
+
value = -90;
|
|
1503
|
+
}
|
|
1504
|
+
else if (type === 'rotateright') {
|
|
1505
|
+
value = 90;
|
|
1506
|
+
}
|
|
1507
|
+
else if (type === 'horizontalflip') {
|
|
1508
|
+
value = 'horizontal';
|
|
1509
|
+
}
|
|
1510
|
+
else if (type === 'verticalflip') {
|
|
1511
|
+
value = 'vertical';
|
|
1512
|
+
}
|
|
1513
|
+
for (var i = 0; i < this.objColl.length; i++) {
|
|
1514
|
+
if (this.objColl[i].shape === 'image') {
|
|
1515
|
+
if (isNullOrUndefined(this.objColl[i].rotateFlipColl)) {
|
|
1516
|
+
this.objColl[i].rotateFlipColl = [];
|
|
1517
|
+
}
|
|
1518
|
+
this.objColl[i].rotateFlipColl.push(value);
|
|
1519
|
+
var obj = { collection: this.objColl[i].rotateFlipColl };
|
|
1520
|
+
this.notify('shape', { prop: 'alignRotateFlipColl', onPropertyChange: false,
|
|
1521
|
+
value: { collection: this.objColl[i].rotateFlipColl, isRotateFlipCollection: false, obj: obj } });
|
|
1522
|
+
this.objColl[i].rotateFlipColl = obj['collection'];
|
|
1523
|
+
}
|
|
1524
|
+
}
|
|
1525
|
+
};
|
|
1228
1526
|
ImageEditor.prototype.setInitialZoomState = function () {
|
|
1229
1527
|
this.objColl.push(this.activeObj);
|
|
1230
1528
|
this.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
|
|
@@ -1233,11 +1531,11 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
1233
1531
|
this.isUndoRedo = true;
|
|
1234
1532
|
if (this.transform.cropZoomFactor && this.transform.cropZoomFactor > 0) {
|
|
1235
1533
|
this.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
|
|
1236
|
-
value: { zoomFactor: -this.transform.cropZoomFactor, zoomPoint: null } });
|
|
1534
|
+
value: { zoomFactor: -this.transform.cropZoomFactor, zoomPoint: null, isResize: null } });
|
|
1237
1535
|
}
|
|
1238
1536
|
else {
|
|
1239
1537
|
this.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
|
|
1240
|
-
value: { zoomFactor: Math.abs(this.transform.cropZoomFactor), zoomPoint: null } });
|
|
1538
|
+
value: { zoomFactor: Math.abs(this.transform.cropZoomFactor), zoomPoint: null, isResize: null } });
|
|
1241
1539
|
}
|
|
1242
1540
|
this.isUndoRedo = isUndoRedo;
|
|
1243
1541
|
this.panPoint.totalPannedPoint = { x: 0, y: 0 };
|
|
@@ -1327,8 +1625,13 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
1327
1625
|
* @returns {void}.
|
|
1328
1626
|
*/
|
|
1329
1627
|
ImageEditor.prototype.okBtn = function (isMouseDown) {
|
|
1628
|
+
this.element.querySelector('.e-contextual-toolbar-wrapper').classList.remove('e-frame-wrapper');
|
|
1330
1629
|
var isCropSelection = false;
|
|
1331
1630
|
var splitWords;
|
|
1631
|
+
var aspectIcon = this.element.querySelector('#' + this.element.id + '_aspectratio');
|
|
1632
|
+
var nonAspectIcon = this.element.querySelector('#' + this.element.id + '_nonaspectratio');
|
|
1633
|
+
var blrAspRatElem = this.element.querySelector('.e-ie-toolbar-aspect-ratio-btn');
|
|
1634
|
+
var blrNAspRatElem = this.element.querySelector('.e-ie-toolbar-nonaspect-ratio-btn');
|
|
1332
1635
|
if (this.activeObj.shape !== undefined) {
|
|
1333
1636
|
splitWords = this.activeObj.shape.split('-');
|
|
1334
1637
|
}
|
|
@@ -1338,9 +1641,53 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
1338
1641
|
else if (splitWords !== undefined && splitWords[0] === 'crop') {
|
|
1339
1642
|
isCropSelection = true;
|
|
1340
1643
|
}
|
|
1644
|
+
this.allowDownScale = true;
|
|
1645
|
+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
1646
|
+
if (aspectIcon || nonAspectIcon || (isBlazor() && this.currentToolbar === 'resize-toolbar')) {
|
|
1647
|
+
var obj_2 = { width: null, height: null };
|
|
1648
|
+
this.notify('selection', { prop: 'getNumTextValue', onPropertyChange: false, value: { obj: obj_2 } });
|
|
1649
|
+
var point = { x: obj_2['width'], y: obj_2['height'] };
|
|
1650
|
+
var obj1 = { prevCropObj: this.prevCropObj };
|
|
1651
|
+
var obj2 = { prevObj: this.prevObj };
|
|
1652
|
+
if (point && point.x && point.y && obj1['prevCropObj'] && obj2['prevObj']) {
|
|
1653
|
+
if (nonAspectIcon || (blrNAspRatElem && !blrNAspRatElem.classList.contains('e-hidden'))) {
|
|
1654
|
+
this.notify('transform', { prop: 'resize', value: { width: point.x, height: point.y, isAspectRatio: false } });
|
|
1655
|
+
}
|
|
1656
|
+
else if (aspectIcon || (blrAspRatElem && !blrAspRatElem.classList.contains('e-hidden'))) {
|
|
1657
|
+
this.notify('transform', { prop: 'resize', value: { width: point.x, height: null, isAspectRatio: true } });
|
|
1658
|
+
}
|
|
1659
|
+
this.isResize = false;
|
|
1660
|
+
this.aspectWidth = point.x;
|
|
1661
|
+
this.aspectHeight = point.y;
|
|
1662
|
+
this.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: { type: 'main',
|
|
1663
|
+
isApplyBtn: false, isCropping: false, isZooming: null, cType: null } });
|
|
1664
|
+
this.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
|
|
1665
|
+
value: { zoomFactor: -this.transform.zoomFactor, zoomPoint: null, isResize: true } });
|
|
1666
|
+
this.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
|
|
1667
|
+
value: { zoomFactor: obj2['prevObj']['defaultZoom'], zoomPoint: null, isResize: true } });
|
|
1668
|
+
if (obj2['prevObj'].zoomFactor) {
|
|
1669
|
+
this.setProperties({ zoomSettings: { zoomFactor: obj2['prevObj'].zoomFactor } }, true);
|
|
1670
|
+
}
|
|
1671
|
+
this.notify('transform', { prop: 'setPreviousZoomValue', onPropertyChange: false,
|
|
1672
|
+
value: { previousZoomValue: this.zoomSettings.zoomFactor } });
|
|
1673
|
+
this.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false, value: { operation: 'resize',
|
|
1674
|
+
previousObj: obj2['prevObj'], previousObjColl: obj2['prevObj']['objColl'],
|
|
1675
|
+
previousPointColl: obj2['prevObj']['pointColl'], previousSelPointColl: obj2['prevObj']['selPointColl'],
|
|
1676
|
+
previousCropObj: obj1['prevCropObj'], previousText: null, currentText: null, previousFilter: null,
|
|
1677
|
+
isCircleCrop: null } });
|
|
1678
|
+
this.notify('undo-redo', { prop: 'updateCurrUrc', value: { type: 'ok' } });
|
|
1679
|
+
}
|
|
1680
|
+
else {
|
|
1681
|
+
this.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: { type: 'main',
|
|
1682
|
+
isApplyBtn: false, isCropping: false, isZooming: null, cType: null } });
|
|
1683
|
+
}
|
|
1684
|
+
this.isAspectRatio = false;
|
|
1685
|
+
}
|
|
1341
1686
|
var selElem = this.element.querySelector('.e-contextual-toolbar-wrapper .e-toolbar-item.e-selected');
|
|
1342
1687
|
var obj = { bool: false };
|
|
1343
1688
|
this.notify('selection', { prop: 'getFreehandDrawEditing', onPropertyChange: false, value: { obj: obj } });
|
|
1689
|
+
var frameObject = { bool: null };
|
|
1690
|
+
this.notify('toolbar', { prop: 'getFrameToolbar', onPropertyChange: false, value: { obj: frameObject } });
|
|
1344
1691
|
if (selElem) {
|
|
1345
1692
|
this.currentFilter = selElem.children[0].children[0].id.replace('Canvas', '');
|
|
1346
1693
|
}
|
|
@@ -1358,15 +1705,20 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
1358
1705
|
this.notify('undo-redo', { prop: 'updateCurrUrc', value: { type: 'ok' } });
|
|
1359
1706
|
}
|
|
1360
1707
|
}
|
|
1361
|
-
else if ((!isBlazor() && document.querySelector('#' + this.element.id + '_sliderWrapper')) ||
|
|
1708
|
+
else if ((!isBlazor() && document.querySelector('#' + this.element.id + '_sliderWrapper')) ||
|
|
1709
|
+
(isBlazor() && !this.element.querySelector('.e-ie-contextual-slider').classList.contains('e-hidden')) ||
|
|
1362
1710
|
this.currObjType.isFiltered) {
|
|
1363
1711
|
this.initialAdjustmentValue = this.canvasFilter = this.lowerContext.filter;
|
|
1364
1712
|
this.currObjType.isFiltered = false;
|
|
1365
|
-
var
|
|
1366
|
-
this.notify('draw', { prop: 'getTempAdjustmentValue', value: { obj:
|
|
1367
|
-
if (
|
|
1713
|
+
var obj_3 = { value: null };
|
|
1714
|
+
this.notify('draw', { prop: 'getTempAdjustmentValue', value: { obj: obj_3 } });
|
|
1715
|
+
if (obj_3['value'] !== this.lowerContext.filter) {
|
|
1368
1716
|
this.notify('undo-redo', { prop: 'updateCurrUrc', value: { type: 'ok' } });
|
|
1369
1717
|
}
|
|
1718
|
+
if ((this.activeObj.activePoint.width !== 0 && this.activeObj.activePoint.height !== 0) ||
|
|
1719
|
+
(this.activeObj.shape === 'path' && this.activeObj.pointColl.length > 0)) {
|
|
1720
|
+
this.notify('shape', { prop: 'applyActObj', onPropertyChange: false, value: { isMouseDown: isMouseDown } });
|
|
1721
|
+
}
|
|
1370
1722
|
}
|
|
1371
1723
|
else if (obj['bool']) {
|
|
1372
1724
|
this.notify('freehand-draw', { prop: 'applyFhd', onPropertyChange: false });
|
|
@@ -1381,12 +1733,35 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
1381
1733
|
}
|
|
1382
1734
|
else if ((this.activeObj.activePoint.width !== 0 && this.activeObj.activePoint.height !== 0) ||
|
|
1383
1735
|
(this.activeObj.shape === 'path' && this.activeObj.pointColl.length > 0)) {
|
|
1736
|
+
if (this.activeObj.shape === 'image') {
|
|
1737
|
+
this.notify('draw', { prop: 'setImageApply', onPropertyChange: false, value: { bool: true } });
|
|
1738
|
+
}
|
|
1384
1739
|
this.notify('shape', { prop: 'applyActObj', onPropertyChange: false, value: { isMouseDown: isMouseDown } });
|
|
1385
1740
|
}
|
|
1741
|
+
else {
|
|
1742
|
+
if (JSON.stringify(this.frameObj) !== JSON.stringify(this.tempFrameObj)) {
|
|
1743
|
+
var object = { currObj: {} };
|
|
1744
|
+
this.notify('filter', { prop: 'getCurrentObj', onPropertyChange: false, value: { object: object } });
|
|
1745
|
+
this.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false, value: {
|
|
1746
|
+
operation: 'frame', previousObj: object['currObj'], previousObjColl: object['currObj']['objColl'],
|
|
1747
|
+
previousPointColl: object['currObj']['pointColl'], previousSelPointColl: object['currObj']['selPointColl'],
|
|
1748
|
+
previousCropObj: extend({}, this.cropObj, {}, true), previousText: null, currentText: null,
|
|
1749
|
+
previousFilter: null, isCircleCrop: null
|
|
1750
|
+
} });
|
|
1751
|
+
this.notify('draw', { prop: 'render-image', value: { isMouseWheel: null, isPreventClearRect: null, isFrame: true } });
|
|
1752
|
+
this.notify('undo-redo', { prop: 'updateCurrUrc', value: { type: 'ok' } });
|
|
1753
|
+
this.tempFrameObj = extend({}, this.frameObj, {}, true);
|
|
1754
|
+
this.notify('draw', { prop: 'setTempFrame', onPropertyChange: false, value: { frame: this.frameObj.type } });
|
|
1755
|
+
}
|
|
1756
|
+
this.notify('draw', { prop: 'resetFrameZoom', onPropertyChange: false });
|
|
1757
|
+
}
|
|
1386
1758
|
if (!isBlazor() && !obj['isCropToolbar']) {
|
|
1387
1759
|
this.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: { type: 'main',
|
|
1388
1760
|
isApplyBtn: false, isCropping: null, isZooming: null, cType: null } });
|
|
1389
1761
|
}
|
|
1762
|
+
else if (isBlazor() && !obj['isCropToolbar'] && (this.currentToolbar == 'resize-toolbar' || this.currentToolbar == 'frame-toolbar')) {
|
|
1763
|
+
this.updateToolbar(this.element, 'imageLoaded');
|
|
1764
|
+
}
|
|
1390
1765
|
this.notify('draw', { prop: 'setNewPath', value: { bool: false } });
|
|
1391
1766
|
this.isCropTab = false;
|
|
1392
1767
|
this.transform.zoomFactor = this.transform.defaultZoomFactor;
|
|
@@ -1432,6 +1807,8 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
1432
1807
|
* An ImageData returns the current canvas image data object.
|
|
1433
1808
|
*/
|
|
1434
1809
|
ImageEditor.prototype.getCurrentCanvasData = function () {
|
|
1810
|
+
var tempFrame = extend({}, this.frameObj, {}, true);
|
|
1811
|
+
this.frameObj = { type: 'none', color: '#fff', size: 20, inset: 20, offset: 20, radius: 0, amount: 1, border: 'solid', gradientColor: '' };
|
|
1435
1812
|
var tempFilter = this.lowerContext.filter;
|
|
1436
1813
|
this.lowerContext.filter = this.canvasFilter = 'none';
|
|
1437
1814
|
var objColl = extend([], this.objColl, null, true);
|
|
@@ -1440,7 +1817,17 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
1440
1817
|
this.pointColl = [];
|
|
1441
1818
|
this.freehandCounter = 0;
|
|
1442
1819
|
this.notify('draw', { prop: 'render-image', value: { isMouseWheel: false } });
|
|
1820
|
+
if (this.element.querySelector('.e-contextual-toolbar-wrapper')) {
|
|
1821
|
+
this.element.querySelector('.e-contextual-toolbar-wrapper').classList.add('e-hide');
|
|
1822
|
+
}
|
|
1443
1823
|
var data = this.getImageData();
|
|
1824
|
+
if (this.element.querySelector('.e-contextual-toolbar-wrapper')) {
|
|
1825
|
+
this.element.querySelector('.e-contextual-toolbar-wrapper').classList.remove('e-hide');
|
|
1826
|
+
if (isBlazor()) {
|
|
1827
|
+
this.element.querySelector('.e-ie-toolbar-check-btn').classList.remove('e-hidden');
|
|
1828
|
+
this.element.querySelector('.e-ie-toolbar-close-btn').classList.remove('e-hidden');
|
|
1829
|
+
}
|
|
1830
|
+
}
|
|
1444
1831
|
if (!isBlazor()) {
|
|
1445
1832
|
if (!Browser.isDevice) {
|
|
1446
1833
|
this.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: { type: 'main',
|
|
@@ -1453,6 +1840,7 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
1453
1840
|
this.freehandCounter = pointColl.length;
|
|
1454
1841
|
this.notify('shape', { prop: 'iterateObjColl', onPropertyChange: false });
|
|
1455
1842
|
this.lowerContext.filter = this.canvasFilter = tempFilter;
|
|
1843
|
+
this.frameObj = tempFrame;
|
|
1456
1844
|
return data;
|
|
1457
1845
|
};
|
|
1458
1846
|
/**
|
|
@@ -1827,14 +2215,14 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
1827
2215
|
var obj = { bool: false };
|
|
1828
2216
|
this.notify('selection', { prop: 'getFreehandDrawEditing', onPropertyChange: false, value: { obj: obj } });
|
|
1829
2217
|
if (obj['bool']) {
|
|
1830
|
-
var
|
|
1831
|
-
this.notify('freehand-draw', { prop: 'getPenStrokeWidth', onPropertyChange: false, value: { obj:
|
|
2218
|
+
var obj_4 = { penStrokeWidth: null };
|
|
2219
|
+
this.notify('freehand-draw', { prop: 'getPenStrokeWidth', onPropertyChange: false, value: { obj: obj_4 } });
|
|
1832
2220
|
this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
|
|
1833
2221
|
this.notify('freehand-draw', { prop: 'hoverFhd', onPropertyChange: false,
|
|
1834
|
-
value: { strokeColor: null, strokeWidth:
|
|
2222
|
+
value: { strokeColor: null, strokeWidth: obj_4['penStrokeWidth'] } });
|
|
1835
2223
|
var indexObj = { freehandSelectedIndex: null };
|
|
1836
2224
|
this.notify('freehand-draw', { prop: 'getFreehandSelectedIndex', onPropertyChange: false, value: { obj: indexObj } });
|
|
1837
|
-
this.pointColl[indexObj['freehandSelectedIndex']].strokeWidth =
|
|
2225
|
+
this.pointColl[indexObj['freehandSelectedIndex']].strokeWidth = obj_4['penStrokeWidth'];
|
|
1838
2226
|
this.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false,
|
|
1839
2227
|
value: { operation: 'freehanddrawCustomized', previousObj: prevObj, previousObjColl: prevObj.objColl,
|
|
1840
2228
|
previousPointColl: prevObj.pointColl, previousSelPointColl: prevObj.selPointColl,
|
|
@@ -1894,30 +2282,40 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
1894
2282
|
* @returns {void}.
|
|
1895
2283
|
*/
|
|
1896
2284
|
ImageEditor.prototype.updateStrokeWidth = function (id) {
|
|
1897
|
-
this.
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
2285
|
+
if (this.activeObj.shape && (this.activeObj.shape !== 'path' || (this.activeObj.shape === 'path' &&
|
|
2286
|
+
this.activeObj.pointColl.length > 0))) {
|
|
2287
|
+
this.notify('shape', { prop: 'pushActItemIntoObj' });
|
|
2288
|
+
var prevCropObj = extend({}, this.cropObj, {}, true);
|
|
2289
|
+
var object = { currObj: {} };
|
|
2290
|
+
this.notify('filter', { prop: 'getCurrentObj', onPropertyChange: false, value: { object: object } });
|
|
2291
|
+
var prevObj = object['currObj'];
|
|
2292
|
+
prevObj.objColl = extend([], this.objColl, [], true);
|
|
2293
|
+
prevObj.pointColl = extend([], this.pointColl, [], true);
|
|
2294
|
+
prevObj.afterCropActions = extend([], this.afterCropActions, [], true);
|
|
2295
|
+
var selPointCollObj = { selPointColl: null };
|
|
2296
|
+
this.notify('freehand-draw', { prop: 'getSelPointColl', onPropertyChange: false,
|
|
2297
|
+
value: { obj: selPointCollObj } });
|
|
2298
|
+
prevObj.selPointColl = extend([], selPointCollObj['selPointColl'], [], true);
|
|
2299
|
+
this.objColl.pop();
|
|
2300
|
+
this.activeObj.strokeSettings.strokeWidth = parseInt(id, 10);
|
|
2301
|
+
this.activeObj.strokeSettings.strokeWidth *= 2;
|
|
2302
|
+
this.notify('shape', { prop: 'setStrokeSettings', value: { strokeSettings: null, strokeColor: null, fillColor: null,
|
|
2303
|
+
strokeWidth: this.activeObj.strokeSettings.strokeWidth } });
|
|
2304
|
+
this.objColl.push(this.activeObj);
|
|
2305
|
+
this.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false,
|
|
2306
|
+
value: { operation: 'shapeTransform', previousObj: prevObj, previousObjColl: prevObj.objColl,
|
|
2307
|
+
previousPointColl: prevObj.pointColl, previousSelPointColl: prevObj.selPointColl,
|
|
2308
|
+
previousCropObj: prevCropObj, previousText: null,
|
|
2309
|
+
currentText: null, previousFilter: null, isCircleCrop: null } });
|
|
2310
|
+
this.notify('selection', { prop: 'redrawShape', value: { obj: this.objColl[this.objColl.length - 1] } });
|
|
2311
|
+
}
|
|
2312
|
+
else if (this.activeObj.shape && (this.activeObj.shape === 'path' &&
|
|
2313
|
+
this.activeObj.pointColl.length === 0)) {
|
|
2314
|
+
this.activeObj.strokeSettings.strokeWidth = parseInt(id, 10);
|
|
2315
|
+
this.activeObj.strokeSettings.strokeWidth *= 2;
|
|
2316
|
+
this.notify('shape', { prop: 'setStrokeSettings', value: { strokeSettings: null, strokeColor: null, fillColor: null,
|
|
2317
|
+
strokeWidth: this.activeObj.strokeSettings.strokeWidth } });
|
|
2318
|
+
}
|
|
1921
2319
|
};
|
|
1922
2320
|
/**
|
|
1923
2321
|
* Apply Shape stroke color.
|
|
@@ -1927,29 +2325,37 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
1927
2325
|
* @returns {void}.
|
|
1928
2326
|
*/
|
|
1929
2327
|
ImageEditor.prototype.updateStrokeColor = function (value) {
|
|
1930
|
-
this.
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
this.
|
|
1947
|
-
this.
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
2328
|
+
if (this.activeObj.shape && (this.activeObj.shape !== 'path' || (this.activeObj.shape === 'path' &&
|
|
2329
|
+
this.activeObj.pointColl.length > 0))) {
|
|
2330
|
+
this.notify('shape', { prop: 'pushActItemIntoObj' });
|
|
2331
|
+
var prevCropObj = extend({}, this.cropObj, {}, true);
|
|
2332
|
+
var object = { currObj: {} };
|
|
2333
|
+
this.notify('filter', { prop: 'getCurrentObj', onPropertyChange: false, value: { object: object } });
|
|
2334
|
+
var prevObj = object['currObj'];
|
|
2335
|
+
prevObj.objColl = extend([], this.objColl, [], true);
|
|
2336
|
+
prevObj.pointColl = extend([], this.pointColl, [], true);
|
|
2337
|
+
prevObj.afterCropActions = extend([], this.afterCropActions, [], true);
|
|
2338
|
+
var selPointCollObj = { selPointColl: null };
|
|
2339
|
+
this.notify('freehand-draw', { prop: 'getSelPointColl', onPropertyChange: false,
|
|
2340
|
+
value: { obj: selPointCollObj } });
|
|
2341
|
+
prevObj.selPointColl = extend([], selPointCollObj['selPointColl'], [], true);
|
|
2342
|
+
this.objColl.pop();
|
|
2343
|
+
this.activeObj.strokeSettings.strokeColor = value;
|
|
2344
|
+
this.notify('shape', { prop: 'setStrokeSettings', value: { strokeSettings: null, strokeColor: this.activeObj.strokeSettings.strokeColor, fillColor: null, strokeWidth: null } });
|
|
2345
|
+
if (!this.togglePen) {
|
|
2346
|
+
this.objColl.push(this.activeObj);
|
|
2347
|
+
this.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false,
|
|
2348
|
+
value: { operation: 'shapeTransform', previousObj: prevObj, previousObjColl: prevObj.objColl,
|
|
2349
|
+
previousPointColl: prevObj.pointColl, previousSelPointColl: prevObj.selPointColl,
|
|
2350
|
+
previousCropObj: prevCropObj, previousText: null,
|
|
2351
|
+
currentText: null, previousFilter: null, isCircleCrop: null } });
|
|
2352
|
+
this.notify('selection', { prop: 'redrawShape', value: { obj: this.objColl[this.objColl.length - 1] } });
|
|
2353
|
+
}
|
|
2354
|
+
}
|
|
2355
|
+
else if (this.activeObj.shape && (this.activeObj.shape === 'path' &&
|
|
2356
|
+
this.activeObj.pointColl.length === 0)) {
|
|
2357
|
+
this.activeObj.strokeSettings.strokeColor = value;
|
|
2358
|
+
this.notify('shape', { prop: 'setStrokeSettings', value: { strokeSettings: null, strokeColor: this.activeObj.strokeSettings.strokeColor, fillColor: null, strokeWidth: null } });
|
|
1953
2359
|
}
|
|
1954
2360
|
};
|
|
1955
2361
|
/**
|
|
@@ -1985,6 +2391,121 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
1985
2391
|
currentText: null, previousFilter: null, isCircleCrop: null } });
|
|
1986
2392
|
this.notify('selection', { prop: 'redrawShape', value: { obj: this.objColl[this.objColl.length - 1] } });
|
|
1987
2393
|
};
|
|
2394
|
+
/**
|
|
2395
|
+
* Apply horizontal flip.
|
|
2396
|
+
*
|
|
2397
|
+
* @param { CanvasRenderingContext2D } ctx - Specifies the canvas context 2D.
|
|
2398
|
+
* @param { boolean } isPreventURC - Specifies to update undo redo collection.
|
|
2399
|
+
* @hidden
|
|
2400
|
+
* @returns {void}.
|
|
2401
|
+
*/
|
|
2402
|
+
ImageEditor.prototype.horizontalFlip = function (ctx, isPreventURC) {
|
|
2403
|
+
var prevCropObj;
|
|
2404
|
+
var prevObj;
|
|
2405
|
+
if (isNullOrUndefined(isPreventURC)) {
|
|
2406
|
+
this.notify('shape', { prop: 'pushActItemIntoObj' });
|
|
2407
|
+
prevCropObj = extend({}, this.cropObj, {}, true);
|
|
2408
|
+
var object = { currObj: {} };
|
|
2409
|
+
this.notify('filter', { prop: 'getCurrentObj', onPropertyChange: false, value: { object: object } });
|
|
2410
|
+
prevObj = object['currObj'];
|
|
2411
|
+
prevObj.objColl = extend([], this.objColl, [], true);
|
|
2412
|
+
prevObj.pointColl = extend([], this.pointColl, [], true);
|
|
2413
|
+
prevObj.afterCropActions = extend([], this.afterCropActions, [], true);
|
|
2414
|
+
var selPointCollObj = { selPointColl: null };
|
|
2415
|
+
this.notify('freehand-draw', { prop: 'getSelPointColl', onPropertyChange: false,
|
|
2416
|
+
value: { obj: selPointCollObj } });
|
|
2417
|
+
prevObj.selPointColl = extend([], selPointCollObj['selPointColl'], [], true);
|
|
2418
|
+
this.objColl.pop();
|
|
2419
|
+
}
|
|
2420
|
+
if (!isBlazor()) {
|
|
2421
|
+
this.notify('toolbar', { prop: 'refreshSlider' });
|
|
2422
|
+
}
|
|
2423
|
+
ctx.clearRect(0, 0, this.activeObj.imageCanvas.width, this.activeObj.imageCanvas.height);
|
|
2424
|
+
this.notify('draw', { prop: 'downScaleImgCanvas', onPropertyChange: false,
|
|
2425
|
+
value: { ctx: this.activeObj.imageCanvas.getContext('2d'), isImgAnnotation: true, isHFlip: true, isVFlip: null } });
|
|
2426
|
+
this.notify('draw', { prop: 'drawObject', onPropertyChange: false, value: { canvas: 'duplicate' } });
|
|
2427
|
+
if (isNullOrUndefined(isPreventURC)) {
|
|
2428
|
+
this.objColl.push(this.activeObj);
|
|
2429
|
+
this.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false,
|
|
2430
|
+
value: { operation: 'imageHFlip', previousObj: prevObj, previousObjColl: prevObj.objColl,
|
|
2431
|
+
previousPointColl: prevObj.pointColl, previousSelPointColl: prevObj.selPointColl,
|
|
2432
|
+
previousCropObj: prevCropObj, previousText: null,
|
|
2433
|
+
currentText: null, previousFilter: null, isCircleCrop: null } });
|
|
2434
|
+
this.notify('selection', { prop: 'redrawShape', value: { obj: this.objColl[this.objColl.length - 1] } });
|
|
2435
|
+
}
|
|
2436
|
+
};
|
|
2437
|
+
/**
|
|
2438
|
+
* Apply vertical flip.
|
|
2439
|
+
*
|
|
2440
|
+
* @param { CanvasRenderingContext2D } ctx - Specifies the canvas context 2D.
|
|
2441
|
+
* @param { boolean } isPreventURC - Specifies to update undo redo collection.
|
|
2442
|
+
* @hidden
|
|
2443
|
+
* @returns {void}.
|
|
2444
|
+
*/
|
|
2445
|
+
ImageEditor.prototype.verticalFlip = function (ctx, isPreventURC) {
|
|
2446
|
+
var prevCropObj;
|
|
2447
|
+
var prevObj;
|
|
2448
|
+
if (isNullOrUndefined(isPreventURC)) {
|
|
2449
|
+
this.notify('shape', { prop: 'pushActItemIntoObj' });
|
|
2450
|
+
prevCropObj = extend({}, this.cropObj, {}, true);
|
|
2451
|
+
var object = { currObj: {} };
|
|
2452
|
+
this.notify('filter', { prop: 'getCurrentObj', onPropertyChange: false, value: { object: object } });
|
|
2453
|
+
prevObj = object['currObj'];
|
|
2454
|
+
prevObj.objColl = extend([], this.objColl, [], true);
|
|
2455
|
+
prevObj.pointColl = extend([], this.pointColl, [], true);
|
|
2456
|
+
prevObj.afterCropActions = extend([], this.afterCropActions, [], true);
|
|
2457
|
+
var selPointCollObj = { selPointColl: null };
|
|
2458
|
+
this.notify('freehand-draw', { prop: 'getSelPointColl', onPropertyChange: false,
|
|
2459
|
+
value: { obj: selPointCollObj } });
|
|
2460
|
+
prevObj.selPointColl = extend([], selPointCollObj['selPointColl'], [], true);
|
|
2461
|
+
this.objColl.pop();
|
|
2462
|
+
}
|
|
2463
|
+
if (!isBlazor()) {
|
|
2464
|
+
this.notify('toolbar', { prop: 'refreshSlider' });
|
|
2465
|
+
}
|
|
2466
|
+
ctx.clearRect(0, 0, this.activeObj.imageCanvas.width, this.activeObj.imageCanvas.height);
|
|
2467
|
+
this.notify('draw', { prop: 'downScaleImgCanvas', onPropertyChange: false,
|
|
2468
|
+
value: { ctx: this.activeObj.imageCanvas.getContext('2d'), isImgAnnotation: true, isHFlip: null, isVFlip: true } });
|
|
2469
|
+
this.notify('draw', { prop: 'drawObject', onPropertyChange: false, value: { canvas: 'duplicate' } });
|
|
2470
|
+
if (isNullOrUndefined(isPreventURC)) {
|
|
2471
|
+
this.objColl.push(this.activeObj);
|
|
2472
|
+
this.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false,
|
|
2473
|
+
value: { operation: 'imageVFlip', previousObj: prevObj, previousObjColl: prevObj.objColl,
|
|
2474
|
+
previousPointColl: prevObj.pointColl, previousSelPointColl: prevObj.selPointColl,
|
|
2475
|
+
previousCropObj: prevCropObj, previousText: null,
|
|
2476
|
+
currentText: null, previousFilter: null, isCircleCrop: null } });
|
|
2477
|
+
this.notify('selection', { prop: 'redrawShape', value: { obj: this.objColl[this.objColl.length - 1] } });
|
|
2478
|
+
}
|
|
2479
|
+
};
|
|
2480
|
+
/**
|
|
2481
|
+
* Apply rotate image.
|
|
2482
|
+
*
|
|
2483
|
+
* @param { string } rotate - Specifies the direction of rotation.
|
|
2484
|
+
* @hidden
|
|
2485
|
+
* @returns {void}.
|
|
2486
|
+
*/
|
|
2487
|
+
ImageEditor.prototype.rotateImage = function (rotate) {
|
|
2488
|
+
if (!isBlazor()) {
|
|
2489
|
+
this.notify('toolbar', { prop: 'refreshSlider' });
|
|
2490
|
+
}
|
|
2491
|
+
if (rotate === 'rotleft') {
|
|
2492
|
+
this.activeObj.rotatedAngle -= (90 * (Math.PI / 180));
|
|
2493
|
+
}
|
|
2494
|
+
else {
|
|
2495
|
+
this.activeObj.rotatedAngle += (90 * (Math.PI / 180));
|
|
2496
|
+
}
|
|
2497
|
+
this.notify('selection', { prop: 'updPtCollForShpRot', onPropertyChange: false, value: { obj: this.activeObj } });
|
|
2498
|
+
this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
|
|
2499
|
+
this.notify('draw', { prop: 'drawObject', onPropertyChange: false, value: { canvas: 'duplicate' } });
|
|
2500
|
+
if (!isBlazor()) {
|
|
2501
|
+
this.notify('toolbar', { prop: 'destroy-qa-toolbar' });
|
|
2502
|
+
this.notify('toolbar', { prop: 'renderQAT', onPropertyChange: false, value: { isPenEdit: null } });
|
|
2503
|
+
}
|
|
2504
|
+
else {
|
|
2505
|
+
this.updateToolbar(this.element, 'destroyQuickAccessToolbar');
|
|
2506
|
+
this.updateToolbar(this.element, 'quickAccessToolbar', 'image');
|
|
2507
|
+
}
|
|
2508
|
+
};
|
|
1988
2509
|
/**
|
|
1989
2510
|
* Get pascalToSplitWords from string.
|
|
1990
2511
|
*
|
|
@@ -2016,7 +2537,8 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
2016
2537
|
var typeToAdjustmentLevel = { 'brightness': obj['adjustmentLevel'].brightness,
|
|
2017
2538
|
'contrast': obj['adjustmentLevel'].contrast, 'hue': obj['adjustmentLevel'].hue,
|
|
2018
2539
|
'saturation': obj['adjustmentLevel'].saturation, 'opacity': obj['adjustmentLevel'].opacity,
|
|
2019
|
-
'blur': obj['adjustmentLevel'].blur, 'exposure': obj['adjustmentLevel'].exposure
|
|
2540
|
+
'blur': obj['adjustmentLevel'].blur, 'exposure': obj['adjustmentLevel'].exposure,
|
|
2541
|
+
'transparency': obj['adjustmentLevel'].transparency };
|
|
2020
2542
|
return typeToAdjustmentLevel["" + type];
|
|
2021
2543
|
};
|
|
2022
2544
|
/**
|
|
@@ -2028,10 +2550,12 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
2028
2550
|
*/
|
|
2029
2551
|
ImageEditor.prototype.transformSelect = function (type) {
|
|
2030
2552
|
this.isCropToolbar = true;
|
|
2553
|
+
this.allowDownScale = false;
|
|
2031
2554
|
this.setInitialZoomState();
|
|
2032
2555
|
var activeObj = extend({}, this.activeObj, {}, true);
|
|
2033
2556
|
this.cropSelectedState();
|
|
2034
2557
|
this.notify('draw', { prop: 'resetCurrentSelectionPoint' });
|
|
2558
|
+
this.updateImageTransformColl(type);
|
|
2035
2559
|
this.notify('transform', { prop: 'performTransformation', value: { text: type } });
|
|
2036
2560
|
this.notify('draw', { prop: 'moveToSelectionRange', value: { type: type, activeObj: activeObj } });
|
|
2037
2561
|
this.isCropToolbar = false;
|
|
@@ -2059,6 +2583,15 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
2059
2583
|
ImageEditor.prototype.initializeImageEditor = function (element, dotnetRef) {
|
|
2060
2584
|
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
2061
2585
|
this.element = element;
|
|
2586
|
+
if (isBlazor() && this.element.querySelector('.place-holder')) {
|
|
2587
|
+
this.element.querySelector('.place-holder').remove();
|
|
2588
|
+
}
|
|
2589
|
+
if (isBlazor() && this.element.querySelector('.e-ie-drop-area')) {
|
|
2590
|
+
this.element.querySelector('.e-ie-drop-area').style.display = 'block';
|
|
2591
|
+
}
|
|
2592
|
+
if (isBlazor() && this.element.querySelector('.e-toolbar-area')) {
|
|
2593
|
+
this.element.querySelector('.e-toolbar-area').style.display = 'block';
|
|
2594
|
+
}
|
|
2062
2595
|
var canvasWrapper = this.element.querySelector('.e-canvas-wrapper');
|
|
2063
2596
|
if (this.element.querySelector('#' + this.element.id + '_toolbarArea')) {
|
|
2064
2597
|
this.toolbarHeight = this.element.querySelector('#' + this.element.id + '_toolbarArea').clientHeight;
|
|
@@ -2076,6 +2609,9 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
2076
2609
|
this.inMemoryCanvas = this.createElement('canvas', {
|
|
2077
2610
|
id: this.element.id + '_inMemoryCanvas', attrs: { name: 'canvasImage' }
|
|
2078
2611
|
});
|
|
2612
|
+
this.baseImgCanvas = this.createElement('canvas', {
|
|
2613
|
+
id: this.element.id + '_baseImgCanvas', attrs: { name: 'canvasImage' }
|
|
2614
|
+
});
|
|
2079
2615
|
this.upperCanvas.width = this.lowerCanvas.width = this.inMemoryCanvas.width = this.element.offsetWidth;
|
|
2080
2616
|
this.upperCanvas.height = this.lowerCanvas.height = this.inMemoryCanvas.height = (this.element.offsetHeight - this.toolbarHeight);
|
|
2081
2617
|
this.lowerContext = this.lowerCanvas.getContext('2d');
|
|
@@ -2260,9 +2796,15 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
2260
2796
|
__decorate([
|
|
2261
2797
|
Event()
|
|
2262
2798
|
], ImageEditor.prototype, "quickAccessToolbarOpen", void 0);
|
|
2799
|
+
__decorate([
|
|
2800
|
+
Event()
|
|
2801
|
+
], ImageEditor.prototype, "resizing", void 0);
|
|
2263
2802
|
__decorate([
|
|
2264
2803
|
Event()
|
|
2265
2804
|
], ImageEditor.prototype, "quickAccessToolbarItemClick", void 0);
|
|
2805
|
+
__decorate([
|
|
2806
|
+
Event()
|
|
2807
|
+
], ImageEditor.prototype, "frameChange", void 0);
|
|
2266
2808
|
ImageEditor = ImageEditor_1 = __decorate([
|
|
2267
2809
|
NotifyPropertyChanges
|
|
2268
2810
|
], ImageEditor);
|