@syncfusion/ej2-image-editor 21.1.35 → 21.1.37
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 +8 -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 +104 -55
- package/dist/es6/ej2-image-editor.es2015.js.map +1 -1
- package/dist/es6/ej2-image-editor.es5.js +104 -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 +2 -0
- package/src/image-editor/image-editor.js +104 -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);
|
|
@@ -6210,7 +6225,7 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends Component {
|
|
|
6210
6225
|
this.currObjType.isUndoZoom = false;
|
|
6211
6226
|
this.lowerCanvas.style.display = 'block';
|
|
6212
6227
|
}
|
|
6213
|
-
this.isUndoRedo = false;
|
|
6228
|
+
this.isUndoRedo = this.isErrorImage = false;
|
|
6214
6229
|
if (Browser.isDevice) {
|
|
6215
6230
|
if (this.isToolbar() && (!isNullOrUndefined(document.getElementById(this.element.id + '_toolbar'))) &&
|
|
6216
6231
|
(!isNullOrUndefined(getComponent(document.getElementById(this.element.id + '_toolbar'), 'toolbar')))) {
|
|
@@ -6231,6 +6246,10 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends Component {
|
|
|
6231
6246
|
this.initToolbarItem(false, false, null);
|
|
6232
6247
|
}
|
|
6233
6248
|
};
|
|
6249
|
+
this.baseImg.onerror = () => {
|
|
6250
|
+
hideSpinner(this.element);
|
|
6251
|
+
this.isErrorImage = true;
|
|
6252
|
+
};
|
|
6234
6253
|
}
|
|
6235
6254
|
refreshActiveObj() {
|
|
6236
6255
|
this.activeObj = {};
|
|
@@ -6698,7 +6717,8 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends Component {
|
|
|
6698
6717
|
else if (!isShape && !isNullOrUndefined(activeObj.shape)) {
|
|
6699
6718
|
this.activeObj = activeObj;
|
|
6700
6719
|
const index = this.getCurrentIndex();
|
|
6701
|
-
if ((!isNullOrUndefined(index) &&
|
|
6720
|
+
if ((!isNullOrUndefined(index) &&
|
|
6721
|
+
JSON.stringify(this.activeObj.activePoint) === JSON.stringify(this.objColl[index].activePoint))) {
|
|
6702
6722
|
this.objColl.splice(index, 1);
|
|
6703
6723
|
}
|
|
6704
6724
|
else if (isNullOrUndefined(this.activeObj.currIndex)) {
|
|
@@ -13195,7 +13215,28 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends Component {
|
|
|
13195
13215
|
* @returns {ImageData}.
|
|
13196
13216
|
*/
|
|
13197
13217
|
getImageData() {
|
|
13218
|
+
if (!isNullOrUndefined(this.activeObj.shape)) {
|
|
13219
|
+
this.performCancel();
|
|
13220
|
+
}
|
|
13221
|
+
let currentObj;
|
|
13222
|
+
if (this.defaultZoomFactor > 0) {
|
|
13223
|
+
currentObj = this.getCurrentObj();
|
|
13224
|
+
currentObj.objColl = extend([], this.objColl, [], true);
|
|
13225
|
+
currentObj.pointColl = extend([], this.pointColl, [], true);
|
|
13226
|
+
currentObj.afterCropActions = extend([], this.afterCropActions, [], true);
|
|
13227
|
+
}
|
|
13228
|
+
this.resetZoom();
|
|
13198
13229
|
const data = this.lowerContext.getImageData(this.destLeft, this.destTop, this.destWidth, this.destHeight);
|
|
13230
|
+
if (!isNullOrUndefined(currentObj)) {
|
|
13231
|
+
this.setCurrentObj(currentObj);
|
|
13232
|
+
this.objColl = extend([], currentObj.objColl, [], true);
|
|
13233
|
+
this.pointColl = extend([], currentObj.pointColl, [], true);
|
|
13234
|
+
this.freehandCounter = this.pointColl.length;
|
|
13235
|
+
this.lowerContext.filter = 'none';
|
|
13236
|
+
this.zoomObjColl();
|
|
13237
|
+
this.zoomFreehandDrawColl();
|
|
13238
|
+
this.lowerContext.filter = currentObj.filter;
|
|
13239
|
+
}
|
|
13199
13240
|
return data;
|
|
13200
13241
|
}
|
|
13201
13242
|
/**
|
|
@@ -13218,12 +13259,15 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends Component {
|
|
|
13218
13259
|
}
|
|
13219
13260
|
if (this.defToolbarItems.length === 0 &&
|
|
13220
13261
|
(isNullOrUndefined(document.getElementById(this.element.id + '_toolbar')))) {
|
|
13221
|
-
this.
|
|
13222
|
-
|
|
13223
|
-
|
|
13224
|
-
this.
|
|
13225
|
-
|
|
13262
|
+
if (isNullOrUndefined(this.toolbarTemplate)) {
|
|
13263
|
+
this.toolbarHeight = 0;
|
|
13264
|
+
}
|
|
13265
|
+
else if (!isNullOrUndefined(this.element.querySelector('#' + this.element.id + '_toolbarArea'))) {
|
|
13266
|
+
this.toolbarHeight = this.element.querySelector('#' + this.element.id + '_toolbarArea').clientHeight;
|
|
13267
|
+
}
|
|
13226
13268
|
}
|
|
13269
|
+
this.reset();
|
|
13270
|
+
this.update();
|
|
13227
13271
|
this.degree = 0;
|
|
13228
13272
|
this.zoomFactor = 0;
|
|
13229
13273
|
this.isImageLoaded = false;
|
|
@@ -13265,7 +13309,7 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends Component {
|
|
|
13265
13309
|
* @returns {void}.
|
|
13266
13310
|
*/
|
|
13267
13311
|
reset() {
|
|
13268
|
-
if (!this.disabled) {
|
|
13312
|
+
if (!this.disabled && !this.isErrorImage) {
|
|
13269
13313
|
this.inMemoryContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
13270
13314
|
this.inMemoryContext.clearRect(0, 0, this.lowerCanvas.height, this.lowerCanvas.width);
|
|
13271
13315
|
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
@@ -13336,7 +13380,7 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends Component {
|
|
|
13336
13380
|
this.rotatedDestPoints = { startX: 0, startY: 0, width: 0, height: 0 };
|
|
13337
13381
|
this.croppedDegree = 0;
|
|
13338
13382
|
this.freehandDrawHoveredIndex = this.freehandDrawSelectedIndex = null;
|
|
13339
|
-
this.isFreehandDrawingPoint = this.isFreehandDrawEditing = false;
|
|
13383
|
+
this.isFreehandDrawingPoint = this.isFreehandDrawEditing = this.isErrorImage = false;
|
|
13340
13384
|
this.tempFreeHandDrawEditingStyles = { strokeColor: null, fillColor: null, strokeWidth: null };
|
|
13341
13385
|
this.totalPannedInternalPoint = { x: 0, y: 0 };
|
|
13342
13386
|
this.totalPannedClientPoint = { x: 0, y: 0 };
|
|
@@ -13490,6 +13534,11 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends Component {
|
|
|
13490
13534
|
*/
|
|
13491
13535
|
select(type, startX, startY, width, height) {
|
|
13492
13536
|
if (!this.disabled && this.isImageLoaded) {
|
|
13537
|
+
const previousObj = this.getCurrentObj();
|
|
13538
|
+
previousObj.objColl = extend([], this.objColl, [], true);
|
|
13539
|
+
previousObj.pointColl = extend([], this.pointColl, [], true);
|
|
13540
|
+
previousObj.afterCropActions = this.afterCropActions;
|
|
13541
|
+
this.previousCropCurrentObj = previousObj;
|
|
13493
13542
|
if (this.zoomFactor > 0 && !isNullOrUndefined(this.activeObj.shape) && this.activeObj.shape.split('-')[0] === 'crop' && isNullOrUndefined(this.currentSelectionPoint)) {
|
|
13494
13543
|
this.currentSelectionPoint = extend({}, this.activeObj, {}, true);
|
|
13495
13544
|
}
|