@syncfusion/ej2-image-editor 27.2.5 → 28.1.39
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/README.md +2 -2
- package/dist/ej2-image-editor.umd.min.js +3 -3
- package/dist/ej2-image-editor.umd.min.js.map +1 -1
- package/dist/es6/ej2-image-editor.es2015.js +380 -52
- package/dist/es6/ej2-image-editor.es2015.js.map +1 -1
- package/dist/es6/ej2-image-editor.es5.js +388 -52
- package/dist/es6/ej2-image-editor.es5.js.map +1 -1
- package/dist/global/ej2-image-editor.min.js +3 -3
- package/dist/global/ej2-image-editor.min.js.map +1 -1
- package/dist/global/index.d.ts +2 -2
- package/package.json +13 -13
- package/src/image-editor/action/draw.d.ts +4 -0
- package/src/image-editor/action/draw.js +97 -11
- package/src/image-editor/action/export.js +1 -1
- package/src/image-editor/action/shape.d.ts +1 -1
- package/src/image-editor/action/shape.js +22 -15
- package/src/image-editor/action/transform.js +1 -0
- package/src/image-editor/base/enum.d.ts +8 -2
- package/src/image-editor/base/enum.js +6 -0
- package/src/image-editor/base/image-editor-model.d.ts +51 -0
- package/src/image-editor/base/image-editor.d.ts +79 -2
- package/src/image-editor/base/image-editor.js +223 -12
- package/src/image-editor/renderer/toolbar.js +38 -12
- package/styles/bds-lite.css +867 -0
- package/styles/bds-lite.scss +13 -0
- package/styles/bds.css +973 -0
- package/styles/bds.scss +14 -0
- package/styles/bootstrap-dark-lite.css +9 -3
- package/styles/bootstrap-dark.css +9 -3
- package/styles/bootstrap-lite.css +9 -3
- package/styles/bootstrap.css +9 -3
- package/styles/bootstrap4-lite.css +9 -3
- package/styles/bootstrap4.css +9 -3
- package/styles/bootstrap5-dark-lite.css +9 -3
- package/styles/bootstrap5-dark.css +9 -3
- package/styles/bootstrap5-lite.css +9 -3
- package/styles/bootstrap5.3-lite.css +9 -3
- package/styles/bootstrap5.3.css +9 -3
- package/styles/bootstrap5.css +9 -3
- package/styles/fabric-dark-lite.css +9 -3
- package/styles/fabric-dark.css +9 -3
- package/styles/fabric-lite.css +9 -3
- package/styles/fabric.css +9 -3
- package/styles/fluent-dark-lite.css +9 -3
- package/styles/fluent-dark.css +9 -3
- package/styles/fluent-lite.css +9 -3
- package/styles/fluent.css +9 -3
- package/styles/fluent2-lite.css +9 -3
- package/styles/fluent2.css +9 -3
- package/styles/highcontrast-light-lite.css +9 -3
- package/styles/highcontrast-light.css +9 -3
- package/styles/highcontrast-lite.css +9 -3
- package/styles/highcontrast.css +9 -3
- package/styles/image-editor/_layout.scss +18 -4
- package/styles/image-editor/_tailwind3-definition.scss +29 -0
- package/styles/image-editor/bds.css +973 -0
- package/styles/image-editor/bds.scss +14 -0
- package/styles/image-editor/bootstrap-dark.css +9 -3
- package/styles/image-editor/bootstrap.css +9 -3
- package/styles/image-editor/bootstrap4.css +9 -3
- package/styles/image-editor/bootstrap5-dark.css +9 -3
- package/styles/image-editor/bootstrap5.3.css +9 -3
- package/styles/image-editor/bootstrap5.css +9 -3
- package/styles/image-editor/fabric-dark.css +9 -3
- package/styles/image-editor/fabric.css +9 -3
- package/styles/image-editor/fluent-dark.css +9 -3
- package/styles/image-editor/fluent.css +9 -3
- package/styles/image-editor/fluent2.css +9 -3
- package/styles/image-editor/highcontrast-light.css +9 -3
- package/styles/image-editor/highcontrast.css +9 -3
- package/styles/image-editor/icons/_tailwind3.scss +259 -0
- package/styles/image-editor/material-dark.css +9 -3
- package/styles/image-editor/material.css +9 -3
- package/styles/image-editor/material3-dark.css +9 -3
- package/styles/image-editor/material3.css +9 -3
- package/styles/image-editor/tailwind-dark.css +9 -3
- package/styles/image-editor/tailwind.css +9 -3
- package/styles/image-editor/tailwind3.css +864 -0
- package/styles/image-editor/tailwind3.scss +14 -0
- package/styles/material-dark-lite.css +9 -3
- package/styles/material-dark.css +9 -3
- package/styles/material-lite.css +9 -3
- package/styles/material.css +9 -3
- package/styles/material3-dark-lite.css +9 -3
- package/styles/material3-dark.css +9 -3
- package/styles/material3-lite.css +9 -3
- package/styles/material3.css +9 -3
- package/styles/tailwind-dark-lite.css +9 -3
- package/styles/tailwind-dark.css +9 -3
- package/styles/tailwind-lite.css +9 -3
- package/styles/tailwind.css +9 -3
- package/styles/tailwind3-lite.css +759 -0
- package/styles/tailwind3-lite.scss +13 -0
- package/styles/tailwind3.css +864 -0
- package/styles/tailwind3.scss +14 -0
|
@@ -25,6 +25,26 @@ import { Complex, Browser, ChildProperty, compile as templateCompiler, compile }
|
|
|
25
25
|
import { ToolbarModule, Crop, Draw, Filter, FreehandDrawing, Selection, Shape, Transform, UndoRedo, Export, FrameLineStyle, ShapeType } from './../index';
|
|
26
26
|
import { ZoomTrigger, ImageFinetuneOption } from './../index';
|
|
27
27
|
import { Uploader } from '@syncfusion/ej2-inputs';
|
|
28
|
+
/**
|
|
29
|
+
* Defines the settings for restricting uploaded images.
|
|
30
|
+
*/
|
|
31
|
+
var UploadSettings = /** @class */ (function (_super) {
|
|
32
|
+
__extends(UploadSettings, _super);
|
|
33
|
+
function UploadSettings() {
|
|
34
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
35
|
+
}
|
|
36
|
+
__decorate([
|
|
37
|
+
Property(null)
|
|
38
|
+
], UploadSettings.prototype, "allowedExtensions", void 0);
|
|
39
|
+
__decorate([
|
|
40
|
+
Property(null)
|
|
41
|
+
], UploadSettings.prototype, "minFileSize", void 0);
|
|
42
|
+
__decorate([
|
|
43
|
+
Property(null)
|
|
44
|
+
], UploadSettings.prototype, "maxFileSize", void 0);
|
|
45
|
+
return UploadSettings;
|
|
46
|
+
}(ChildProperty));
|
|
47
|
+
export { UploadSettings };
|
|
28
48
|
/**
|
|
29
49
|
* 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.
|
|
30
50
|
*/
|
|
@@ -503,6 +523,24 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
503
523
|
this.quickAccessToolbarTemplateFn();
|
|
504
524
|
}
|
|
505
525
|
break;
|
|
526
|
+
case 'uploadSettings':
|
|
527
|
+
if (newProperties.uploadSettings) {
|
|
528
|
+
this.uploadSettings = newProperties.uploadSettings;
|
|
529
|
+
if (!this.uploadSettings.allowedExtensions) {
|
|
530
|
+
this.uploadSettings.allowedExtensions = '.jpg, .jpeg, .png, .svg, .webp';
|
|
531
|
+
this.notify('draw', { prop: 'setNullExtension', value: { extension: true } });
|
|
532
|
+
}
|
|
533
|
+
else {
|
|
534
|
+
this.notify('draw', { prop: 'setNullExtension', value: { extension: false } });
|
|
535
|
+
}
|
|
536
|
+
this.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: { type: 'main',
|
|
537
|
+
isApplyBtn: null, isCropping: null, isZooming: null, cType: null } });
|
|
538
|
+
}
|
|
539
|
+
else {
|
|
540
|
+
this.notify('draw', { prop: 'setNullExtension', value: { extension: true } });
|
|
541
|
+
}
|
|
542
|
+
this.updateDropInfoContent(this.element.querySelector('.e-ie-drop-info'));
|
|
543
|
+
break;
|
|
506
544
|
}
|
|
507
545
|
}
|
|
508
546
|
};
|
|
@@ -537,6 +575,12 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
537
575
|
this.notify('toolbar', { prop: 'create-toolbar', onPropertyChange: false });
|
|
538
576
|
this.notify('toolbar', { prop: 'create-contextual-toolbar', onPropertyChange: false });
|
|
539
577
|
}
|
|
578
|
+
if (!this.uploadSettings.allowedExtensions) {
|
|
579
|
+
this.setProperties({ uploadSettings: { allowedExtensions: '.jpg, .jpeg, .png, .svg, .webp' } }, true);
|
|
580
|
+
}
|
|
581
|
+
else {
|
|
582
|
+
this.notify('draw', { prop: 'setNullExtension', value: { extension: false } });
|
|
583
|
+
}
|
|
540
584
|
this.createCanvas();
|
|
541
585
|
if (this.element.offsetWidth > 359 && this.element.querySelector('.e-ie-min-drop-content') && this.element.querySelector('.e-ie-drop-content')) {
|
|
542
586
|
this.element.querySelector('.e-ie-min-drop-content').style.display = 'none';
|
|
@@ -586,17 +630,28 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
586
630
|
};
|
|
587
631
|
ImageEditor.prototype.createDropUploader = function () {
|
|
588
632
|
var _this = this;
|
|
633
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
634
|
+
var proxy = this;
|
|
589
635
|
var uploadObj = new Uploader({
|
|
590
636
|
dropArea: this.element.getElementsByClassName('e-canvas-wrapper')[0],
|
|
591
|
-
allowedExtensions:
|
|
637
|
+
allowedExtensions: this.uploadSettings.allowedExtensions,
|
|
592
638
|
multiple: false,
|
|
593
639
|
selected: function (args) {
|
|
594
640
|
if (args.event.type === 'change' || args.event.type === 'drop') {
|
|
595
641
|
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
596
642
|
var type = args.filesData[0].type;
|
|
597
643
|
var errType = 'unsupported';
|
|
644
|
+
var extension = _this.getExtensionArray();
|
|
645
|
+
var isAllowedFileType = (extension.indexOf(type) > -1 ||
|
|
646
|
+
(type === 'jpeg' && (proxy.uploadSettings.allowedExtensions.indexOf('jpg') > -1 ||
|
|
647
|
+
proxy.uploadSettings.allowedExtensions.indexOf('jpeg') > -1)));
|
|
648
|
+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
649
|
+
var size = args.filesData[0].size;
|
|
650
|
+
var isInvalidSize = (proxy.uploadSettings.minFileSize && size < proxy.uploadSettings.minFileSize) ||
|
|
651
|
+
(proxy.uploadSettings.maxFileSize && size > proxy.uploadSettings.maxFileSize);
|
|
598
652
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
599
|
-
if ((args.event.type === 'change' || (args.event.type === 'drop' && args.event.dataTransfer.files.length === 1)) &&
|
|
653
|
+
if ((args.event.type === 'change' || (args.event.type === 'drop' && args.event.dataTransfer.files.length === 1)) && isAllowedFileType &&
|
|
654
|
+
!isInvalidSize) {
|
|
600
655
|
_this.notify('draw', { prop: 'fileSelect', value: { inputElement: _this.element.querySelector('#' + _this.element.id + '_dropfileUpload'), args: args } });
|
|
601
656
|
}
|
|
602
657
|
else {
|
|
@@ -604,7 +659,7 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
604
659
|
if (args.event.type === 'drop' && args.event.dataTransfer.files.length > 1) {
|
|
605
660
|
errType = 'multi-select-image';
|
|
606
661
|
}
|
|
607
|
-
_this.showDialogPopup(errType);
|
|
662
|
+
_this.showDialogPopup(errType, !isAllowedFileType);
|
|
608
663
|
}
|
|
609
664
|
}
|
|
610
665
|
}
|
|
@@ -618,10 +673,11 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
618
673
|
* Show dialog popup for unsupported files.
|
|
619
674
|
*
|
|
620
675
|
* @param { string } type - Specifies the type of error.
|
|
676
|
+
* @param { boolean } fileTypeError - Specifies the error is due to file type.
|
|
621
677
|
* @hidden
|
|
622
678
|
* @returns {void}.
|
|
623
679
|
*/
|
|
624
|
-
ImageEditor.prototype.showDialogPopup = function (type) {
|
|
680
|
+
ImageEditor.prototype.showDialogPopup = function (type, fileTypeError) {
|
|
625
681
|
var content = '';
|
|
626
682
|
this.element.querySelector('#' + this.element.id + '_dialog').style.display = 'block';
|
|
627
683
|
var headerObj;
|
|
@@ -641,16 +697,38 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
641
697
|
this.notify('toolbar', { prop: 'getLocaleText', onPropertyChange: false, value: { obj: contentObj } });
|
|
642
698
|
var supportObj = { key: 'SupportText' };
|
|
643
699
|
this.notify('toolbar', { prop: 'getLocaleText', onPropertyChange: false, value: { obj: supportObj } });
|
|
700
|
+
var extension = this.getExtensionString();
|
|
701
|
+
var fileSizeObj = { key: 'MinMaxSizeAlert' };
|
|
702
|
+
this.notify('toolbar', { prop: 'getLocaleText', onPropertyChange: false, value: { obj: fileSizeObj } });
|
|
644
703
|
var andObj = { key: 'And' };
|
|
645
704
|
this.notify('toolbar', { prop: 'getLocaleText', onPropertyChange: false, value: { obj: andObj } });
|
|
646
|
-
|
|
705
|
+
var size = void 0;
|
|
706
|
+
if (this.uploadSettings.minFileSize && this.uploadSettings.maxFileSize) {
|
|
707
|
+
size = ' ' + fileSizeObj['value'] + ' <b> ' + this.formatSizeUnits(this.uploadSettings.minFileSize) + ' </b> ' + andObj['value'] + ' <b> ' + this.formatSizeUnits(this.uploadSettings.maxFileSize) + ' </b> ';
|
|
708
|
+
}
|
|
709
|
+
else if (this.uploadSettings.minFileSize) {
|
|
710
|
+
fileSizeObj['key'] = 'MinSizeAlert';
|
|
711
|
+
this.notify('toolbar', { prop: 'getLocaleText', onPropertyChange: false, value: { obj: fileSizeObj } });
|
|
712
|
+
size = ' ' + fileSizeObj['value'] + ' <b> ' + this.formatSizeUnits(this.uploadSettings.minFileSize) + ' </b> ';
|
|
713
|
+
}
|
|
714
|
+
else if (this.uploadSettings.maxFileSize) {
|
|
715
|
+
fileSizeObj['key'] = 'MaxSizeAlert';
|
|
716
|
+
this.notify('toolbar', { prop: 'getLocaleText', onPropertyChange: false, value: { obj: fileSizeObj } });
|
|
717
|
+
size = ' ' + fileSizeObj['value'] + ' <b> ' + this.formatSizeUnits(this.uploadSettings.maxFileSize) + ' </b> ';
|
|
718
|
+
}
|
|
719
|
+
if (fileTypeError) {
|
|
720
|
+
content = '<span>' + contentObj['value'] + ' ' + supportObj['value'] + '<b>' + extension + '</b>' + '</span>';
|
|
721
|
+
}
|
|
722
|
+
else if (size) {
|
|
723
|
+
content = '<span>' + contentObj['value'] + ' ' + supportObj['value'] + size + '</span>';
|
|
724
|
+
}
|
|
647
725
|
}
|
|
648
726
|
var dialog = new Dialog({
|
|
649
727
|
header: headerObj['value'],
|
|
650
728
|
closeOnEscape: true,
|
|
651
729
|
content: content,
|
|
652
730
|
target: document.getElementById('target'),
|
|
653
|
-
width: '285px',
|
|
731
|
+
width: Browser.isDevice ? '285px' : '400px',
|
|
654
732
|
isModal: true,
|
|
655
733
|
animationSettings: { effect: 'Zoom' },
|
|
656
734
|
close: this.dlgCloseBtnClick.bind(this),
|
|
@@ -662,6 +740,99 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
662
740
|
});
|
|
663
741
|
dialog.appendTo('#' + this.element.id + '_dialog');
|
|
664
742
|
};
|
|
743
|
+
/**
|
|
744
|
+
* Returns bytes in string format.
|
|
745
|
+
*
|
|
746
|
+
* @param { number } bytes - Specifies the bytes.
|
|
747
|
+
*
|
|
748
|
+
* @hidden
|
|
749
|
+
* @returns {string}.
|
|
750
|
+
*/
|
|
751
|
+
ImageEditor.prototype.formatSizeUnits = function (bytes) {
|
|
752
|
+
var byte = '';
|
|
753
|
+
if (bytes >= 1073741824) {
|
|
754
|
+
byte = (bytes / 1073741824).toFixed(2) + ' GB';
|
|
755
|
+
}
|
|
756
|
+
else if (bytes >= 1048576) {
|
|
757
|
+
byte = (bytes / 1048576).toFixed(2) + ' MB';
|
|
758
|
+
}
|
|
759
|
+
else if (bytes >= 1024) {
|
|
760
|
+
byte = (bytes / 1024).toFixed(2) + ' KB';
|
|
761
|
+
}
|
|
762
|
+
else if (bytes > 1) {
|
|
763
|
+
byte = bytes + ' bytes';
|
|
764
|
+
}
|
|
765
|
+
else if (bytes === 1) {
|
|
766
|
+
byte = bytes + ' byte';
|
|
767
|
+
}
|
|
768
|
+
else {
|
|
769
|
+
byte = '0 bytes';
|
|
770
|
+
}
|
|
771
|
+
return byte;
|
|
772
|
+
};
|
|
773
|
+
/**
|
|
774
|
+
* Returns allowed file type extensions in string[].
|
|
775
|
+
*
|
|
776
|
+
* @hidden
|
|
777
|
+
* @returns {string[]}.
|
|
778
|
+
*/
|
|
779
|
+
ImageEditor.prototype.getExtensionArray = function () {
|
|
780
|
+
var validExtensions = ['jpeg', 'jpg', 'png', 'svg', 'webp'];
|
|
781
|
+
var split = this.uploadSettings.allowedExtensions.split(',');
|
|
782
|
+
var extension = [];
|
|
783
|
+
for (var _i = 0, split_1 = split; _i < split_1.length; _i++) {
|
|
784
|
+
var ext = split_1[_i];
|
|
785
|
+
var trimmedExt = ext.trim();
|
|
786
|
+
for (var _a = 0, validExtensions_1 = validExtensions; _a < validExtensions_1.length; _a++) {
|
|
787
|
+
var valid = validExtensions_1[_a];
|
|
788
|
+
if (trimmedExt.indexOf(valid) !== -1) {
|
|
789
|
+
extension.push(valid);
|
|
790
|
+
break;
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
return extension;
|
|
795
|
+
};
|
|
796
|
+
/**
|
|
797
|
+
* Returns allowed file type extensions in string.
|
|
798
|
+
*
|
|
799
|
+
* @hidden
|
|
800
|
+
* @returns {string}.
|
|
801
|
+
*/
|
|
802
|
+
ImageEditor.prototype.getExtensionString = function () {
|
|
803
|
+
var andObj = { key: 'And' };
|
|
804
|
+
this.notify('toolbar', { prop: 'getLocaleText', onPropertyChange: false, value: { obj: andObj } });
|
|
805
|
+
var extension = this.getExtensionArray();
|
|
806
|
+
var words = '';
|
|
807
|
+
for (var i = 0; i < extension.length; i++) {
|
|
808
|
+
if (i === extension.length - 1 && extension.length > 1 &&
|
|
809
|
+
!((extension[i] === 'jpeg' || extension[i] === 'jpg') &&
|
|
810
|
+
(words.indexOf('JPG') > -1))) {
|
|
811
|
+
words += ' ' + andObj['value'];
|
|
812
|
+
}
|
|
813
|
+
switch (extension[i]) {
|
|
814
|
+
case 'jpeg':
|
|
815
|
+
case 'jpg':
|
|
816
|
+
if (words.indexOf('JPG') === -1) {
|
|
817
|
+
words += ' JPG,';
|
|
818
|
+
}
|
|
819
|
+
break;
|
|
820
|
+
case 'png':
|
|
821
|
+
words += ' PNG,';
|
|
822
|
+
break;
|
|
823
|
+
case 'svg':
|
|
824
|
+
words += ' SVG,';
|
|
825
|
+
break;
|
|
826
|
+
case 'webp':
|
|
827
|
+
words += ' WebP,';
|
|
828
|
+
break;
|
|
829
|
+
}
|
|
830
|
+
if (i === extension.length - 1) {
|
|
831
|
+
words = words.slice(0, -1);
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
return words;
|
|
835
|
+
};
|
|
665
836
|
/**
|
|
666
837
|
*
|
|
667
838
|
* This Method will add events to component (element, event, method, current reference)
|
|
@@ -736,10 +907,6 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
736
907
|
this.notify('toolbar', { prop: 'getLocaleText', onPropertyChange: false, value: { obj: dropObj } });
|
|
737
908
|
var browseObj = { key: 'BrowseText' };
|
|
738
909
|
this.notify('toolbar', { prop: 'getLocaleText', onPropertyChange: false, value: { obj: browseObj } });
|
|
739
|
-
var supportObj = { key: 'SupportText' };
|
|
740
|
-
this.notify('toolbar', { prop: 'getLocaleText', onPropertyChange: false, value: { obj: supportObj } });
|
|
741
|
-
var andObj = { key: 'And' };
|
|
742
|
-
this.notify('toolbar', { prop: 'getLocaleText', onPropertyChange: false, value: { obj: andObj } });
|
|
743
910
|
var dropAreaElement = this.createElement('div', { id: this.element.id + '_dropArea', className: 'e-ie-drop-area', attrs: { style: 'position: relative;' } });
|
|
744
911
|
var dropIconElement = this.createElement('span', { className: 'e-ie-drop-icon e-icons e-image', attrs: { style: 'position: absolute;' } });
|
|
745
912
|
var dropContentElement = this.createElement('span', { className: 'e-ie-drop-content', attrs: { style: 'position: absolute; display: none;' } });
|
|
@@ -755,7 +922,7 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
755
922
|
dropAnchorElement.href = '';
|
|
756
923
|
minDropAnchorElem.href = '';
|
|
757
924
|
var dropInfoElement = this.createElement('span', { className: 'e-ie-drop-info', attrs: { position: 'absolute' } });
|
|
758
|
-
dropInfoElement
|
|
925
|
+
this.updateDropInfoContent(dropInfoElement);
|
|
759
926
|
var dropUploader = dropAreaElement.appendChild(this.createElement('input', {
|
|
760
927
|
id: this.element.id + '_dropfileUpload', className: 'e-fileUpload e-image-upload'
|
|
761
928
|
}));
|
|
@@ -2689,6 +2856,45 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
2689
2856
|
}
|
|
2690
2857
|
return items;
|
|
2691
2858
|
};
|
|
2859
|
+
/**
|
|
2860
|
+
* Updates drop area content dynamically.
|
|
2861
|
+
*
|
|
2862
|
+
* @param { HTMLElement } dropInfoElement - Specifies the drop area element.
|
|
2863
|
+
* @hidden
|
|
2864
|
+
* @returns {void}.
|
|
2865
|
+
*/
|
|
2866
|
+
ImageEditor.prototype.updateDropInfoContent = function (dropInfoElement) {
|
|
2867
|
+
if (!dropInfoElement) {
|
|
2868
|
+
return;
|
|
2869
|
+
}
|
|
2870
|
+
var supportObj = { key: 'SupportText' };
|
|
2871
|
+
this.notify('toolbar', { prop: 'getLocaleText', onPropertyChange: false, value: { obj: supportObj } });
|
|
2872
|
+
var words = this.getExtensionString();
|
|
2873
|
+
var fileSizeObj = { key: 'MinMaxSize' };
|
|
2874
|
+
this.notify('toolbar', { prop: 'getLocaleText', onPropertyChange: false, value: { obj: fileSizeObj } });
|
|
2875
|
+
var andObj = { key: 'And' };
|
|
2876
|
+
this.notify('toolbar', { prop: 'getLocaleText', onPropertyChange: false, value: { obj: andObj } });
|
|
2877
|
+
var size;
|
|
2878
|
+
if (this.uploadSettings.minFileSize && this.uploadSettings.maxFileSize) {
|
|
2879
|
+
size = ' ' + fileSizeObj['value'] + ' ' + this.formatSizeUnits(this.uploadSettings.minFileSize) + ' ' + andObj['value'] + ' ' + this.formatSizeUnits(this.uploadSettings.maxFileSize);
|
|
2880
|
+
}
|
|
2881
|
+
else if (this.uploadSettings.minFileSize) {
|
|
2882
|
+
fileSizeObj['key'] = 'MinSize';
|
|
2883
|
+
this.notify('toolbar', { prop: 'getLocaleText', onPropertyChange: false, value: { obj: fileSizeObj } });
|
|
2884
|
+
size = ' ' + fileSizeObj['value'] + ' ' + this.formatSizeUnits(this.uploadSettings.minFileSize);
|
|
2885
|
+
}
|
|
2886
|
+
else if (this.uploadSettings.maxFileSize) {
|
|
2887
|
+
fileSizeObj['key'] = 'MaxSize';
|
|
2888
|
+
this.notify('toolbar', { prop: 'getLocaleText', onPropertyChange: false, value: { obj: fileSizeObj } });
|
|
2889
|
+
size = ' ' + fileSizeObj['value'] + ' ' + this.formatSizeUnits(this.uploadSettings.maxFileSize);
|
|
2890
|
+
}
|
|
2891
|
+
if (size) {
|
|
2892
|
+
dropInfoElement.textContent = supportObj['value'] + words + size;
|
|
2893
|
+
}
|
|
2894
|
+
else {
|
|
2895
|
+
dropInfoElement.textContent = supportObj['value'] + words;
|
|
2896
|
+
}
|
|
2897
|
+
};
|
|
2692
2898
|
/**
|
|
2693
2899
|
* Handles the OK button operation
|
|
2694
2900
|
*
|
|
@@ -4344,7 +4550,9 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
4344
4550
|
Fluent2Dark: { primaryColor: '#115ea3', secondaryColor: '#fff' },
|
|
4345
4551
|
Fluent2Highcontrast: { primaryColor: '#1aebff', secondaryColor: '#fff' },
|
|
4346
4552
|
'Bootstrap5.3': { primaryColor: '#0d6efd', secondaryColor: '#fff' },
|
|
4347
|
-
'Bootstrap5.3Dark': { primaryColor: '#0d6efd', secondaryColor: '#fff' }
|
|
4553
|
+
'Bootstrap5.3Dark': { primaryColor: '#0d6efd', secondaryColor: '#fff' },
|
|
4554
|
+
Tailwind3: { primaryColor: '#4f46e5', secondaryColor: '#ffffff' },
|
|
4555
|
+
Tailwind3Dark: { primaryColor: '#6366f1', secondaryColor: '#ffffff03' }
|
|
4348
4556
|
};
|
|
4349
4557
|
};
|
|
4350
4558
|
/**
|
|
@@ -4424,6 +4632,9 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
4424
4632
|
__decorate([
|
|
4425
4633
|
Complex({}, FontFamily)
|
|
4426
4634
|
], ImageEditor.prototype, "fontFamily", void 0);
|
|
4635
|
+
__decorate([
|
|
4636
|
+
Complex({}, UploadSettings)
|
|
4637
|
+
], ImageEditor.prototype, "uploadSettings", void 0);
|
|
4427
4638
|
__decorate([
|
|
4428
4639
|
Event()
|
|
4429
4640
|
], ImageEditor.prototype, "beforeSave", void 0);
|
|
@@ -173,6 +173,14 @@ var ToolbarModule = /** @class */ (function () {
|
|
|
173
173
|
ConfirmDialogContent: 'Do you want to save the changes you made to the image?',
|
|
174
174
|
AlertDialogHeader: 'Unsupported file',
|
|
175
175
|
AlertDialogContent: 'The selected file is unsupported.',
|
|
176
|
+
MinMaxSize: 'with file size between',
|
|
177
|
+
MinMaxSizeAlert: 'File size between',
|
|
178
|
+
MinSize: 'with minimum file size of',
|
|
179
|
+
MinSizeAlert: 'A minimum file size of',
|
|
180
|
+
MaxSize: 'with maximum file size of',
|
|
181
|
+
MaxSizeAlert: 'A maximum file size of',
|
|
182
|
+
To: 'to',
|
|
183
|
+
Bytes: 'bytes',
|
|
176
184
|
Yes: 'Yes',
|
|
177
185
|
No: 'No',
|
|
178
186
|
ImageErrorDialogHeader: 'Image Selection Error',
|
|
@@ -416,7 +424,7 @@ var ToolbarModule = /** @class */ (function () {
|
|
|
416
424
|
id: id + '_toolbarArea', className: 'e-toolbar-area'
|
|
417
425
|
}));
|
|
418
426
|
var toolbarItems = { cssClass: 'e-image-upload', align: 'Left', type: 'Input',
|
|
419
|
-
tooltipText: this.l10n.getConstant('Browse'), template: new Uploader({ allowedExtensions:
|
|
427
|
+
tooltipText: this.l10n.getConstant('Browse'), template: new Uploader({ allowedExtensions: parent.uploadSettings.allowedExtensions, multiple: false }) };
|
|
420
428
|
if (isNullOrUndefined(this.defToolbarItems)) {
|
|
421
429
|
this.defToolbarItems = [];
|
|
422
430
|
}
|
|
@@ -430,7 +438,7 @@ var ToolbarModule = /** @class */ (function () {
|
|
|
430
438
|
align: 'Left', type: 'Input',
|
|
431
439
|
tooltipText: this.l10n.getConstant('Browse'),
|
|
432
440
|
template: new Uploader({
|
|
433
|
-
allowedExtensions:
|
|
441
|
+
allowedExtensions: parent.uploadSettings.allowedExtensions,
|
|
434
442
|
multiple: false,
|
|
435
443
|
selected: function () {
|
|
436
444
|
var toolbar = document.getElementById(id + '_toolbar');
|
|
@@ -517,7 +525,7 @@ var ToolbarModule = /** @class */ (function () {
|
|
|
517
525
|
var id = parent.element.id;
|
|
518
526
|
if (parent.showQuickAccessToolbar) {
|
|
519
527
|
var toolbarItems = { cssClass: 'e-image-upload', align: 'Left', type: 'Input',
|
|
520
|
-
tooltipText: this.l10n.getConstant('Browse'), template: new Uploader({ allowedExtensions:
|
|
528
|
+
tooltipText: this.l10n.getConstant('Browse'), template: new Uploader({ allowedExtensions: parent.uploadSettings.allowedExtensions, multiple: false }) };
|
|
521
529
|
if (isNullOrUndefined(this.defToolbarItems)) {
|
|
522
530
|
this.defToolbarItems = [];
|
|
523
531
|
}
|
|
@@ -615,11 +623,11 @@ var ToolbarModule = /** @class */ (function () {
|
|
|
615
623
|
var toolbarItems = [];
|
|
616
624
|
if (!isOkBtn || isResize) {
|
|
617
625
|
if (isNullOrUndefined(parent.toolbar) || (parent.toolbar && parent.toolbar.indexOf('Open') > -1)) {
|
|
618
|
-
toolbarItems.push({ id: id + '_upload', cssClass: 'e-image-upload', align: 'Left', type: 'Input', template: new Uploader({ allowedExtensions:
|
|
626
|
+
toolbarItems.push({ id: id + '_upload', cssClass: 'e-image-upload', align: 'Left', type: 'Input', template: new Uploader({ allowedExtensions: parent.uploadSettings.allowedExtensions, multiple: false }) });
|
|
619
627
|
toolbarItems.push({ visible: false, cssClass: 'e-image-position e-btn e-flat', tooltipText: this.l10n.getConstant('Browse'), align: 'Left' });
|
|
620
628
|
}
|
|
621
629
|
else if (Browser.isDevice && (parent.toolbar && parent.toolbar.indexOf('Open') === -1)) {
|
|
622
|
-
toolbarItems.push({ visible: false, id: id + '_upload', cssClass: 'e-image-upload', align: 'Left', type: 'Input', template: new Uploader({ allowedExtensions:
|
|
630
|
+
toolbarItems.push({ visible: false, id: id + '_upload', cssClass: 'e-image-upload', align: 'Left', type: 'Input', template: new Uploader({ allowedExtensions: parent.uploadSettings.allowedExtensions, multiple: false }) });
|
|
623
631
|
toolbarItems.push({ visible: false, cssClass: 'e-image-position e-btn e-flat', tooltipText: this.l10n.getConstant('Browse'), align: 'Left' });
|
|
624
632
|
}
|
|
625
633
|
}
|
|
@@ -1170,18 +1178,33 @@ var ToolbarModule = /** @class */ (function () {
|
|
|
1170
1178
|
}
|
|
1171
1179
|
};
|
|
1172
1180
|
ToolbarModule.prototype.fileSelect = function (inputElement, args) {
|
|
1181
|
+
var parent = this.parent;
|
|
1173
1182
|
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
1174
1183
|
var type = inputElement.files[0].type.split('/')[1];
|
|
1175
|
-
var filesTypes =
|
|
1184
|
+
var filesTypes = this.parent.getExtensionArray();
|
|
1185
|
+
var isJPG = ((type === 'jpg' || type === 'jpeg') &&
|
|
1186
|
+
(parent.uploadSettings.allowedExtensions.indexOf('jpg') > -1 ||
|
|
1187
|
+
parent.uploadSettings.allowedExtensions.indexOf('jpeg') > -1));
|
|
1176
1188
|
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
1177
1189
|
this.fileName = inputElement.files[0].name.split('.')[0];
|
|
1178
1190
|
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
1191
|
+
var size = inputElement.files[0].size;
|
|
1192
|
+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
1179
1193
|
this.parent.notify('toolbar', { prop: 'setInitialSize', value: { value: inputElement.files[0].size } });
|
|
1180
|
-
if (filesTypes.indexOf(type) > -1)
|
|
1194
|
+
if ((filesTypes.indexOf(type) > -1 || isJPG || (type.indexOf('svg') > -1 && filesTypes.indexOf('svg') > -1)) &&
|
|
1195
|
+
(!this.parent.uploadSettings.minFileSize || size > this.parent.uploadSettings.minFileSize) &&
|
|
1196
|
+
(!this.parent.uploadSettings.maxFileSize || size < this.parent.uploadSettings.maxFileSize)) {
|
|
1181
1197
|
this.parent.notify('draw', { prop: 'fileSelect', value: { inputElement: inputElement, args: args } });
|
|
1182
1198
|
}
|
|
1183
1199
|
else {
|
|
1184
|
-
this.parent.
|
|
1200
|
+
if (!this.parent.isImageLoaded) {
|
|
1201
|
+
this.destroyTopToolbar();
|
|
1202
|
+
this.createToolbar();
|
|
1203
|
+
if (Browser.isDevice) {
|
|
1204
|
+
this.destroyBottomToolbar();
|
|
1205
|
+
}
|
|
1206
|
+
}
|
|
1207
|
+
this.parent.showDialogPopup('unsupported', !((filesTypes.indexOf(type) > -1 || isJPG || (type.indexOf('svg') > -1 && filesTypes.indexOf('svg') > -1))));
|
|
1185
1208
|
}
|
|
1186
1209
|
};
|
|
1187
1210
|
ToolbarModule.prototype.triggerTbarClickEvent = function (args) {
|
|
@@ -1688,7 +1711,8 @@ var ToolbarModule = /** @class */ (function () {
|
|
|
1688
1711
|
var items = [
|
|
1689
1712
|
{ id: 'jpeg', text: 'JPEG' },
|
|
1690
1713
|
{ id: 'png', text: 'PNG' },
|
|
1691
|
-
{ id: 'svg', text: 'SVG' }
|
|
1714
|
+
{ id: 'svg', text: 'SVG' },
|
|
1715
|
+
{ id: 'webp', text: 'WebP' }
|
|
1692
1716
|
];
|
|
1693
1717
|
var inputObj = new TextBox({
|
|
1694
1718
|
placeholder: this.l10n.getConstant('ImageName')
|
|
@@ -1720,7 +1744,7 @@ var ToolbarModule = /** @class */ (function () {
|
|
|
1720
1744
|
var ddbElem = document.getElementById(id + '_saveDropdownbtn');
|
|
1721
1745
|
if (ddbElem) {
|
|
1722
1746
|
var spanElem_1 = document.createElement('span');
|
|
1723
|
-
spanElem_1.innerHTML = this.fileType.toUpperCase();
|
|
1747
|
+
spanElem_1.innerHTML = this.fileType === 'Webp' ? 'Webp' : this.fileType.toUpperCase();
|
|
1724
1748
|
if (ddbElem) {
|
|
1725
1749
|
ddbElem.appendChild(spanElem_1);
|
|
1726
1750
|
}
|
|
@@ -1884,8 +1908,10 @@ var ToolbarModule = /** @class */ (function () {
|
|
|
1884
1908
|
this.fileSize = fileSize;
|
|
1885
1909
|
}).bind(this), 'image/jpeg', quality);
|
|
1886
1910
|
}
|
|
1887
|
-
else if (!isNullOrUndefined(fileType) && fileType.toLowerCase() === 'png') {
|
|
1911
|
+
else if (!isNullOrUndefined(fileType) && (fileType.toLowerCase() === 'png' || fileType.toLowerCase() === 'webp')) {
|
|
1912
|
+
var type = 'image/' + fileType.toLowerCase();
|
|
1888
1913
|
ctx.drawImage(tempCanvas, 0, 0);
|
|
1914
|
+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
1889
1915
|
tempCanvas.toBlob((function (blob) {
|
|
1890
1916
|
fileSize = Math.floor(blob.size / 1024);
|
|
1891
1917
|
if (fileSize > 1000) {
|
|
@@ -1901,7 +1927,7 @@ var ToolbarModule = /** @class */ (function () {
|
|
|
1901
1927
|
canvas.style.display = 'none';
|
|
1902
1928
|
}
|
|
1903
1929
|
this.fileSize = fileSize;
|
|
1904
|
-
}).bind(this),
|
|
1930
|
+
}).bind(this), type, 1);
|
|
1905
1931
|
}
|
|
1906
1932
|
else if (!isNullOrUndefined(fileType) && fileType.toLowerCase() === 'svg') {
|
|
1907
1933
|
ctx.drawImage(tempCanvas, 0, 0);
|