@syncfusion/ej2-image-editor 21.1.35 → 21.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/CHANGELOG.md +22 -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 +119 -55
- package/dist/es6/ej2-image-editor.es2015.js.map +1 -1
- package/dist/es6/ej2-image-editor.es5.js +119 -55
- 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 +11 -11
- package/src/image-editor/image-editor.d.ts +3 -0
- package/src/image-editor/image-editor.js +119 -55
|
@@ -199,6 +199,7 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends Component {
|
|
|
199
199
|
this.isShapeInserted = false;
|
|
200
200
|
this.isInitialTextEdited = false;
|
|
201
201
|
this.isShapeTextInserted = false;
|
|
202
|
+
this.isErrorImage = false;
|
|
202
203
|
}
|
|
203
204
|
preRender() {
|
|
204
205
|
// pre render code snippets
|
|
@@ -401,7 +402,8 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends Component {
|
|
|
401
402
|
this.zoomSettings.zoomTrigger = newProperties.zoomSettings.zoomTrigger;
|
|
402
403
|
}
|
|
403
404
|
if (isNullOrUndefined(this.zoomSettings.zoomTrigger)) {
|
|
404
|
-
this.zoomSettings.zoomTrigger = (ZoomTrigger.MouseWheel | ZoomTrigger.Pinch | ZoomTrigger.Toolbar |
|
|
405
|
+
this.zoomSettings.zoomTrigger = (ZoomTrigger.MouseWheel | ZoomTrigger.Pinch | ZoomTrigger.Toolbar |
|
|
406
|
+
ZoomTrigger.Commands);
|
|
405
407
|
this.refreshToolbar('main');
|
|
406
408
|
}
|
|
407
409
|
else if ((newProperties.zoomSettings.zoomTrigger & ZoomTrigger.Toolbar) === ZoomTrigger.Toolbar) {
|
|
@@ -1293,11 +1295,9 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends Component {
|
|
|
1293
1295
|
this.performTransformation(args.item.id);
|
|
1294
1296
|
this.updateCurrentUndoRedoColl('ok');
|
|
1295
1297
|
}
|
|
1296
|
-
|
|
1297
|
-
const tempZoomFactor = this.defaultZoomFactor;
|
|
1298
|
-
const isUndoRedo = this.isUndoRedo;
|
|
1299
|
-
const prevCropObj = extend({}, this.cropObj, {}, true);
|
|
1298
|
+
resetZoom() {
|
|
1300
1299
|
if (this.defaultZoomFactor !== 0) {
|
|
1300
|
+
const isUndoRedo = this.isUndoRedo;
|
|
1301
1301
|
this.transformCurrentObj = this.getCurrentObj();
|
|
1302
1302
|
this.transformCurrentObj.objColl = extend([], this.objColl, null, true);
|
|
1303
1303
|
this.transformCurrentObj.pointColl = extend({}, this.pointColl, null, true);
|
|
@@ -1311,6 +1311,12 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends Component {
|
|
|
1311
1311
|
}
|
|
1312
1312
|
this.isUndoRedo = isUndoRedo;
|
|
1313
1313
|
}
|
|
1314
|
+
}
|
|
1315
|
+
performTransformation(text) {
|
|
1316
|
+
const tempZoomFactor = this.defaultZoomFactor;
|
|
1317
|
+
const isUndoRedo = this.isUndoRedo;
|
|
1318
|
+
const prevCropObj = extend({}, this.cropObj, {}, true);
|
|
1319
|
+
this.resetZoom();
|
|
1314
1320
|
this.updateTransform(text);
|
|
1315
1321
|
if (tempZoomFactor !== 0) {
|
|
1316
1322
|
this.isUndoRedo = true;
|
|
@@ -2287,7 +2293,6 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends Component {
|
|
|
2287
2293
|
isDisabledFilter = true;
|
|
2288
2294
|
}
|
|
2289
2295
|
this.enableDisableToolbarBtn();
|
|
2290
|
-
let previousObj;
|
|
2291
2296
|
let duplicateObj;
|
|
2292
2297
|
let objColl;
|
|
2293
2298
|
if (!this.disabled) {
|
|
@@ -2337,11 +2342,6 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends Component {
|
|
|
2337
2342
|
this.currentToolbar = 'main';
|
|
2338
2343
|
break;
|
|
2339
2344
|
case 'crop':
|
|
2340
|
-
previousObj = this.getCurrentObj();
|
|
2341
|
-
previousObj.objColl = extend([], this.objColl, [], true);
|
|
2342
|
-
previousObj.pointColl = extend([], this.pointColl, [], true);
|
|
2343
|
-
previousObj.afterCropActions = this.afterCropActions;
|
|
2344
|
-
this.previousCropCurrentObj = previousObj;
|
|
2345
2345
|
if (!isNullOrUndefined(this.currSelectionPoint)) {
|
|
2346
2346
|
if (this.currObjType.isUndoAction) {
|
|
2347
2347
|
this.refreshUndoRedoColl();
|
|
@@ -4401,48 +4401,63 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends Component {
|
|
|
4401
4401
|
this.inMemoryCanvas.width = imageData.width;
|
|
4402
4402
|
this.inMemoryCanvas.height = imageData.height;
|
|
4403
4403
|
this.inMemoryContext.putImageData(imageData, 0, 0);
|
|
4404
|
+
let ctx;
|
|
4404
4405
|
const noFilter = document.querySelector('#' + this.element.id + '_defaultCanvas');
|
|
4405
|
-
|
|
4406
|
-
|
|
4407
|
-
|
|
4408
|
-
|
|
4409
|
-
|
|
4406
|
+
if (!isNullOrUndefined(noFilter)) {
|
|
4407
|
+
ctx = noFilter.getContext('2d');
|
|
4408
|
+
noFilter.style.width = '100px';
|
|
4409
|
+
noFilter.style.height = '100px';
|
|
4410
|
+
ctx.filter = this.updateAdjustment('default', null, true);
|
|
4411
|
+
ctx.drawImage(this.inMemoryCanvas, 0, 0, 300, 150);
|
|
4412
|
+
}
|
|
4410
4413
|
const chrome = document.querySelector('#' + this.element.id + '_chromeCanvas');
|
|
4411
|
-
|
|
4412
|
-
|
|
4413
|
-
|
|
4414
|
-
|
|
4415
|
-
|
|
4414
|
+
if (!isNullOrUndefined(chrome)) {
|
|
4415
|
+
ctx = chrome.getContext('2d');
|
|
4416
|
+
chrome.style.width = '100px';
|
|
4417
|
+
chrome.style.height = '100px';
|
|
4418
|
+
ctx.filter = this.updateAdjustment('chrome', null, true);
|
|
4419
|
+
ctx.drawImage(this.inMemoryCanvas, 0, 0, 300, 150);
|
|
4420
|
+
}
|
|
4416
4421
|
const cold = document.querySelector('#' + this.element.id + '_coldCanvas');
|
|
4417
|
-
|
|
4418
|
-
|
|
4419
|
-
|
|
4420
|
-
|
|
4421
|
-
|
|
4422
|
+
if (!isNullOrUndefined(cold)) {
|
|
4423
|
+
ctx = cold.getContext('2d');
|
|
4424
|
+
cold.style.width = '100px';
|
|
4425
|
+
cold.style.height = '100px';
|
|
4426
|
+
ctx.filter = this.updateAdjustment('cold', null, true);
|
|
4427
|
+
ctx.drawImage(this.inMemoryCanvas, 0, 0, 300, 150);
|
|
4428
|
+
}
|
|
4422
4429
|
const warm = document.querySelector('#' + this.element.id + '_warmCanvas');
|
|
4423
|
-
|
|
4424
|
-
|
|
4425
|
-
|
|
4426
|
-
|
|
4427
|
-
|
|
4430
|
+
if (!isNullOrUndefined(warm)) {
|
|
4431
|
+
ctx = warm.getContext('2d');
|
|
4432
|
+
warm.style.width = '100px';
|
|
4433
|
+
warm.style.height = '100px';
|
|
4434
|
+
ctx.filter = this.updateAdjustment('warm', null, true);
|
|
4435
|
+
ctx.drawImage(this.inMemoryCanvas, 0, 0, 300, 150);
|
|
4436
|
+
}
|
|
4428
4437
|
const grayscale = document.querySelector('#' + this.element.id + '_grayscaleCanvas');
|
|
4429
|
-
|
|
4430
|
-
|
|
4431
|
-
|
|
4432
|
-
|
|
4433
|
-
|
|
4438
|
+
if (!isNullOrUndefined(grayscale)) {
|
|
4439
|
+
ctx = grayscale.getContext('2d');
|
|
4440
|
+
grayscale.style.width = '100px';
|
|
4441
|
+
grayscale.style.height = '100px';
|
|
4442
|
+
ctx.filter = this.updateAdjustment('grayscale', null, true);
|
|
4443
|
+
ctx.drawImage(this.inMemoryCanvas, 0, 0, 300, 150);
|
|
4444
|
+
}
|
|
4434
4445
|
const sepia = document.querySelector('#' + this.element.id + '_sepiaCanvas');
|
|
4435
|
-
|
|
4436
|
-
|
|
4437
|
-
|
|
4438
|
-
|
|
4439
|
-
|
|
4446
|
+
if (!isNullOrUndefined(sepia)) {
|
|
4447
|
+
ctx = sepia.getContext('2d');
|
|
4448
|
+
sepia.style.width = '100px';
|
|
4449
|
+
sepia.style.height = '100px';
|
|
4450
|
+
ctx.filter = this.updateAdjustment('sepia', null, true);
|
|
4451
|
+
ctx.drawImage(this.inMemoryCanvas, 0, 0, 300, 150);
|
|
4452
|
+
}
|
|
4440
4453
|
const invert = document.querySelector('#' + this.element.id + '_invertCanvas');
|
|
4441
|
-
|
|
4442
|
-
|
|
4443
|
-
|
|
4444
|
-
|
|
4445
|
-
|
|
4454
|
+
if (!isNullOrUndefined(invert)) {
|
|
4455
|
+
ctx = invert.getContext('2d');
|
|
4456
|
+
invert.style.width = '100px';
|
|
4457
|
+
invert.style.height = '100px';
|
|
4458
|
+
ctx.filter = this.updateAdjustment('invert', null, true);
|
|
4459
|
+
ctx.drawImage(this.inMemoryCanvas, 0, 0, 300, 150);
|
|
4460
|
+
}
|
|
4446
4461
|
}
|
|
4447
4462
|
callUpdateCurrentTransformedState() {
|
|
4448
4463
|
const tempObjColl = extend([], this.objColl, [], true);
|
|
@@ -5080,6 +5095,7 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends Component {
|
|
|
5080
5095
|
this.activeObj.activePoint.height = this.activeObj.activePoint.endY - this.activeObj.activePoint.startY;
|
|
5081
5096
|
this.updateActiveObject(this.activeObj.activePoint, this.activeObj);
|
|
5082
5097
|
}
|
|
5098
|
+
this.updateSelectionInsert();
|
|
5083
5099
|
this.drawObject('duplicate', this.activeObj, null, null, true);
|
|
5084
5100
|
}
|
|
5085
5101
|
clearOuterCanvas(context) {
|
|
@@ -6210,7 +6226,7 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends Component {
|
|
|
6210
6226
|
this.currObjType.isUndoZoom = false;
|
|
6211
6227
|
this.lowerCanvas.style.display = 'block';
|
|
6212
6228
|
}
|
|
6213
|
-
this.isUndoRedo = false;
|
|
6229
|
+
this.isUndoRedo = this.isErrorImage = false;
|
|
6214
6230
|
if (Browser.isDevice) {
|
|
6215
6231
|
if (this.isToolbar() && (!isNullOrUndefined(document.getElementById(this.element.id + '_toolbar'))) &&
|
|
6216
6232
|
(!isNullOrUndefined(getComponent(document.getElementById(this.element.id + '_toolbar'), 'toolbar')))) {
|
|
@@ -6231,6 +6247,10 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends Component {
|
|
|
6231
6247
|
this.initToolbarItem(false, false, null);
|
|
6232
6248
|
}
|
|
6233
6249
|
};
|
|
6250
|
+
this.baseImg.onerror = () => {
|
|
6251
|
+
hideSpinner(this.element);
|
|
6252
|
+
this.isErrorImage = true;
|
|
6253
|
+
};
|
|
6234
6254
|
}
|
|
6235
6255
|
refreshActiveObj() {
|
|
6236
6256
|
this.activeObj = {};
|
|
@@ -6698,7 +6718,8 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends Component {
|
|
|
6698
6718
|
else if (!isShape && !isNullOrUndefined(activeObj.shape)) {
|
|
6699
6719
|
this.activeObj = activeObj;
|
|
6700
6720
|
const index = this.getCurrentIndex();
|
|
6701
|
-
if ((!isNullOrUndefined(index) &&
|
|
6721
|
+
if ((!isNullOrUndefined(index) &&
|
|
6722
|
+
JSON.stringify(this.activeObj.activePoint) === JSON.stringify(this.objColl[index].activePoint))) {
|
|
6702
6723
|
this.objColl.splice(index, 1);
|
|
6703
6724
|
}
|
|
6704
6725
|
else if (isNullOrUndefined(this.activeObj.currIndex)) {
|
|
@@ -12772,6 +12793,13 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends Component {
|
|
|
12772
12793
|
width: width, height: width };
|
|
12773
12794
|
}
|
|
12774
12795
|
this.activeObj.shape = cropShape.toLowerCase();
|
|
12796
|
+
this.updateSelectionInsert();
|
|
12797
|
+
if (this.activeObj.activePoint.startX !== 0 || this.activeObj.activePoint.startY !== 0 ||
|
|
12798
|
+
this.activeObj.activePoint.width !== 0 || this.activeObj.activePoint.height !== 0) {
|
|
12799
|
+
points = { startX: this.activeObj.activePoint.startX, startY: this.activeObj.activePoint.startY,
|
|
12800
|
+
endX: this.activeObj.activePoint.endX, endY: this.activeObj.activePoint.endY,
|
|
12801
|
+
width: this.activeObj.activePoint.width, height: this.activeObj.activePoint.height };
|
|
12802
|
+
}
|
|
12775
12803
|
this.drawObject('duplicate', null, true, points);
|
|
12776
12804
|
}
|
|
12777
12805
|
}
|
|
@@ -13195,7 +13223,28 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends Component {
|
|
|
13195
13223
|
* @returns {ImageData}.
|
|
13196
13224
|
*/
|
|
13197
13225
|
getImageData() {
|
|
13226
|
+
if (!isNullOrUndefined(this.activeObj.shape)) {
|
|
13227
|
+
this.performCancel();
|
|
13228
|
+
}
|
|
13229
|
+
let currentObj;
|
|
13230
|
+
if (this.defaultZoomFactor > 0) {
|
|
13231
|
+
currentObj = this.getCurrentObj();
|
|
13232
|
+
currentObj.objColl = extend([], this.objColl, [], true);
|
|
13233
|
+
currentObj.pointColl = extend([], this.pointColl, [], true);
|
|
13234
|
+
currentObj.afterCropActions = extend([], this.afterCropActions, [], true);
|
|
13235
|
+
}
|
|
13236
|
+
this.resetZoom();
|
|
13198
13237
|
const data = this.lowerContext.getImageData(this.destLeft, this.destTop, this.destWidth, this.destHeight);
|
|
13238
|
+
if (!isNullOrUndefined(currentObj)) {
|
|
13239
|
+
this.setCurrentObj(currentObj);
|
|
13240
|
+
this.objColl = extend([], currentObj.objColl, [], true);
|
|
13241
|
+
this.pointColl = extend([], currentObj.pointColl, [], true);
|
|
13242
|
+
this.freehandCounter = this.pointColl.length;
|
|
13243
|
+
this.lowerContext.filter = 'none';
|
|
13244
|
+
this.zoomObjColl();
|
|
13245
|
+
this.zoomFreehandDrawColl();
|
|
13246
|
+
this.lowerContext.filter = currentObj.filter;
|
|
13247
|
+
}
|
|
13199
13248
|
return data;
|
|
13200
13249
|
}
|
|
13201
13250
|
/**
|
|
@@ -13218,12 +13267,15 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends Component {
|
|
|
13218
13267
|
}
|
|
13219
13268
|
if (this.defToolbarItems.length === 0 &&
|
|
13220
13269
|
(isNullOrUndefined(document.getElementById(this.element.id + '_toolbar')))) {
|
|
13221
|
-
this.
|
|
13222
|
-
|
|
13223
|
-
|
|
13224
|
-
this.
|
|
13225
|
-
|
|
13270
|
+
if (isNullOrUndefined(this.toolbarTemplate)) {
|
|
13271
|
+
this.toolbarHeight = 0;
|
|
13272
|
+
}
|
|
13273
|
+
else if (!isNullOrUndefined(this.element.querySelector('#' + this.element.id + '_toolbarArea'))) {
|
|
13274
|
+
this.toolbarHeight = this.element.querySelector('#' + this.element.id + '_toolbarArea').clientHeight;
|
|
13275
|
+
}
|
|
13226
13276
|
}
|
|
13277
|
+
this.reset();
|
|
13278
|
+
this.update();
|
|
13227
13279
|
this.degree = 0;
|
|
13228
13280
|
this.zoomFactor = 0;
|
|
13229
13281
|
this.isImageLoaded = false;
|
|
@@ -13265,7 +13317,7 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends Component {
|
|
|
13265
13317
|
* @returns {void}.
|
|
13266
13318
|
*/
|
|
13267
13319
|
reset() {
|
|
13268
|
-
if (!this.disabled) {
|
|
13320
|
+
if (!this.disabled && !this.isErrorImage) {
|
|
13269
13321
|
this.inMemoryContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
13270
13322
|
this.inMemoryContext.clearRect(0, 0, this.lowerCanvas.height, this.lowerCanvas.width);
|
|
13271
13323
|
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
@@ -13336,7 +13388,7 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends Component {
|
|
|
13336
13388
|
this.rotatedDestPoints = { startX: 0, startY: 0, width: 0, height: 0 };
|
|
13337
13389
|
this.croppedDegree = 0;
|
|
13338
13390
|
this.freehandDrawHoveredIndex = this.freehandDrawSelectedIndex = null;
|
|
13339
|
-
this.isFreehandDrawingPoint = this.isFreehandDrawEditing = false;
|
|
13391
|
+
this.isFreehandDrawingPoint = this.isFreehandDrawEditing = this.isErrorImage = false;
|
|
13340
13392
|
this.tempFreeHandDrawEditingStyles = { strokeColor: null, fillColor: null, strokeWidth: null };
|
|
13341
13393
|
this.totalPannedInternalPoint = { x: 0, y: 0 };
|
|
13342
13394
|
this.totalPannedClientPoint = { x: 0, y: 0 };
|
|
@@ -13490,6 +13542,11 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends Component {
|
|
|
13490
13542
|
*/
|
|
13491
13543
|
select(type, startX, startY, width, height) {
|
|
13492
13544
|
if (!this.disabled && this.isImageLoaded) {
|
|
13545
|
+
const previousObj = this.getCurrentObj();
|
|
13546
|
+
previousObj.objColl = extend([], this.objColl, [], true);
|
|
13547
|
+
previousObj.pointColl = extend([], this.pointColl, [], true);
|
|
13548
|
+
previousObj.afterCropActions = this.afterCropActions;
|
|
13549
|
+
this.previousCropCurrentObj = previousObj;
|
|
13493
13550
|
if (this.zoomFactor > 0 && !isNullOrUndefined(this.activeObj.shape) && this.activeObj.shape.split('-')[0] === 'crop' && isNullOrUndefined(this.currentSelectionPoint)) {
|
|
13494
13551
|
this.currentSelectionPoint = extend({}, this.activeObj, {}, true);
|
|
13495
13552
|
}
|
|
@@ -13546,6 +13603,13 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends Component {
|
|
|
13546
13603
|
}
|
|
13547
13604
|
}
|
|
13548
13605
|
}
|
|
13606
|
+
updateSelectionInsert() {
|
|
13607
|
+
const shapeSettings = this.updatePreviousShapeSettings();
|
|
13608
|
+
const shapeChangingArgs = { action: 'insert', previousShapeSettings: shapeSettings,
|
|
13609
|
+
currentShapeSettings: shapeSettings };
|
|
13610
|
+
this.trigger('shapeChanging', shapeChangingArgs);
|
|
13611
|
+
this.updateShapeChangeEventArgs(shapeChangingArgs.currentShapeSettings);
|
|
13612
|
+
}
|
|
13549
13613
|
/**
|
|
13550
13614
|
* Enable or disable a freehand drawing option in an Image Editor.
|
|
13551
13615
|
*
|