@syncfusion/ej2-image-editor 20.4.49 → 20.4.51
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 +16 -0
- package/GitLeaksReport.json +1 -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 +1154 -877
- package/dist/es6/ej2-image-editor.es2015.js.map +1 -1
- package/dist/es6/ej2-image-editor.es5.js +1150 -873
- 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/gitleaks-ci/gitleaks +0 -0
- package/gitleaks-ci.tar.gz +0 -0
- package/package.json +11 -11
- package/src/image-editor/image-editor.d.ts +15 -4
- package/src/image-editor/image-editor.js +1150 -863
|
@@ -180,9 +180,9 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
180
180
|
_this.isAllowCropPan = false;
|
|
181
181
|
_this.tempPannedPoint = { x: 0, y: 0 };
|
|
182
182
|
_this.cropObj = { cropZoom: 0, defaultZoom: 0, totalPannedPoint: { x: 0, y: 0 }, totalPannedClientPoint: { x: 0, y: 0 },
|
|
183
|
-
totalPannedInternalPoint: { x: 0, y: 0 }, activeObj: {}, rotateFlipColl: [],
|
|
184
|
-
currFlipState: '', destPoints: { startX: 0, startY: 0, width: 0, height: 0 },
|
|
185
|
-
srcPoints: { startX: 0, startY: 0, width: 0, height: 0 } };
|
|
183
|
+
totalPannedInternalPoint: { x: 0, y: 0 }, tempFlipPanPoint: { x: 0, y: 0 }, activeObj: {}, rotateFlipColl: [],
|
|
184
|
+
degree: 0, currFlipState: '', destPoints: { startX: 0, startY: 0, width: 0, height: 0 },
|
|
185
|
+
srcPoints: { startX: 0, startY: 0, width: 0, height: 0 }, filter: '' };
|
|
186
186
|
_this.afterCropActions = [];
|
|
187
187
|
_this.isCancelAction = false;
|
|
188
188
|
_this.isFreehandPointMoved = false;
|
|
@@ -401,7 +401,6 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
401
401
|
this.unwireEvent();
|
|
402
402
|
_super.prototype.destroy.call(this);
|
|
403
403
|
this.element.innerHTML = '';
|
|
404
|
-
this.trigger('destroyed');
|
|
405
404
|
};
|
|
406
405
|
ImageEditor.prototype.initialize = function () {
|
|
407
406
|
this.updateFinetunes();
|
|
@@ -969,7 +968,7 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
969
968
|
redo.parentElement.classList.remove('e-overlay');
|
|
970
969
|
}
|
|
971
970
|
var zoomIn = document.querySelector('#' + this.element.id + '_zoomIn');
|
|
972
|
-
if (!isNullOrUndefined(zoomIn) && this.zoomFactor >=
|
|
971
|
+
if (!isNullOrUndefined(zoomIn) && this.zoomFactor >= 2) {
|
|
973
972
|
zoomIn.classList.add('e-disabled');
|
|
974
973
|
zoomIn.parentElement.classList.add('e-overlay');
|
|
975
974
|
}
|
|
@@ -1182,32 +1181,34 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
1182
1181
|
ImageEditor.prototype.cropSelect = function (args) {
|
|
1183
1182
|
this.isCropTab = true;
|
|
1184
1183
|
this.zoomFactor = this.cropZoomFactor;
|
|
1185
|
-
var
|
|
1184
|
+
var prevCropObj = extend({}, this.cropObj, {}, true);
|
|
1185
|
+
var previousObj = this.getCurrentObj();
|
|
1186
|
+
previousObj.objColl = extend([], this.objColl, [], true);
|
|
1187
|
+
previousObj.pointColl = extend([], this.pointColl, [], true);
|
|
1188
|
+
previousObj.afterCropActions = this.afterCropActions;
|
|
1186
1189
|
var text = args.item.id;
|
|
1187
1190
|
this.currentToolbar = 'crop';
|
|
1188
1191
|
this.currSelectionPoint = null;
|
|
1189
1192
|
this.select(text);
|
|
1190
1193
|
this.refreshToolbar('main', true, true);
|
|
1191
1194
|
this.refreshDropDownBtn(true);
|
|
1192
|
-
this.
|
|
1193
|
-
currentObj: extend([], this.objColl, [], true),
|
|
1194
|
-
previousObj: extend([], this.objColl, [], true),
|
|
1195
|
-
previousSelectionObj: extend({}, activeObj, {}, true),
|
|
1196
|
-
currentSelectionObj: extend({}, this.activeObj, {}, true),
|
|
1197
|
-
zoomFactor: this.zoomFactor, sharpen: this.adjustmentLevel.sharpen, bw: this.adjustmentLevel.bw });
|
|
1198
|
-
this.undoRedoStep++;
|
|
1195
|
+
this.updateUndoRedoColl('selectionTransform', previousObj, previousObj.objColl, previousObj.pointColl, prevCropObj);
|
|
1199
1196
|
this.enableDisableToolbarBtn();
|
|
1200
1197
|
};
|
|
1201
1198
|
ImageEditor.prototype.transformSelect = function (args) {
|
|
1202
1199
|
this.cropSelectedState();
|
|
1203
1200
|
this.currentSelectionPoint = null;
|
|
1204
1201
|
this.performTransformation(args.item.id);
|
|
1205
|
-
this.afterCropActions.push(args.item.id);
|
|
1206
1202
|
};
|
|
1207
1203
|
ImageEditor.prototype.performTransformation = function (text) {
|
|
1208
1204
|
var tempZoomFactor = this.defaultZoomFactor;
|
|
1209
1205
|
var isUndoRedo = this.isUndoRedo;
|
|
1206
|
+
var prevCropObj = extend({}, this.cropObj, {}, true);
|
|
1210
1207
|
if (this.defaultZoomFactor !== 0) {
|
|
1208
|
+
this.transformCurrentObj = this.getCurrentObj();
|
|
1209
|
+
this.transformCurrentObj.objColl = extend([], this.objColl, null, true);
|
|
1210
|
+
this.transformCurrentObj.pointColl = extend({}, this.pointColl, null, true);
|
|
1211
|
+
this.transformCurrentObj.afterCropActions = extend([], this.afterCropActions, [], true);
|
|
1211
1212
|
this.isUndoRedo = true;
|
|
1212
1213
|
if (this.defaultZoomFactor > 0) {
|
|
1213
1214
|
this.zoom(-this.defaultZoomFactor);
|
|
@@ -1222,10 +1223,19 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
1222
1223
|
this.isUndoRedo = true;
|
|
1223
1224
|
this.zoom(tempZoomFactor);
|
|
1224
1225
|
this.isUndoRedo = isUndoRedo;
|
|
1226
|
+
var state = '';
|
|
1227
|
+
if (text === 'rotateleft' || text === 'rotateright') {
|
|
1228
|
+
state = 'rotate';
|
|
1229
|
+
}
|
|
1230
|
+
else if (text === 'horizontalflip' || text === 'verticalflip') {
|
|
1231
|
+
state = 'flip';
|
|
1232
|
+
}
|
|
1233
|
+
this.updateUndoRedoColl(state, this.transformCurrentObj, this.transformCurrentObj.objColl, this.transformCurrentObj.pointColl, prevCropObj);
|
|
1234
|
+
this.transformCurrentObj = null;
|
|
1225
1235
|
}
|
|
1226
1236
|
};
|
|
1227
1237
|
ImageEditor.prototype.updateTransform = function (text) {
|
|
1228
|
-
switch (text) {
|
|
1238
|
+
switch (text.toLowerCase()) {
|
|
1229
1239
|
case 'rotateleft':
|
|
1230
1240
|
this.rotate(-90);
|
|
1231
1241
|
break;
|
|
@@ -1327,15 +1337,16 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
1327
1337
|
showButtons: false, mode: 'Palette', cssClass: 'e-shape-fill-color',
|
|
1328
1338
|
change: function (args) {
|
|
1329
1339
|
_this.pushActItemIntoObj();
|
|
1330
|
-
var
|
|
1340
|
+
var prevCropObj = extend({}, _this.cropObj, {}, true);
|
|
1341
|
+
var prevObj = _this.getCurrentObj();
|
|
1342
|
+
prevObj.objColl = extend([], _this.objColl, [], true);
|
|
1343
|
+
prevObj.pointColl = extend([], _this.pointColl, [], true);
|
|
1344
|
+
prevObj.afterCropActions = extend([], _this.afterCropActions, [], true);
|
|
1331
1345
|
_this.objColl.pop();
|
|
1332
1346
|
proxy.activeObj.strokeSettings.fillColor = args.currentValue.hex;
|
|
1333
1347
|
proxy.strokeSettings.fillColor = proxy.activeObj.strokeSettings.fillColor;
|
|
1334
1348
|
_this.objColl.push(_this.activeObj);
|
|
1335
|
-
|
|
1336
|
-
previousObj: objColl, zoomFactor: proxy.zoomFactor, sharpen: proxy.adjustmentLevel.sharpen,
|
|
1337
|
-
bw: proxy.adjustmentLevel.bw });
|
|
1338
|
-
proxy.undoRedoStep++;
|
|
1349
|
+
_this.updateUndoRedoColl('shapeTransform', prevObj, prevObj.objColl, prevObj.pointColl, prevCropObj);
|
|
1339
1350
|
proxy.redrawShape(proxy.objColl[proxy.objColl.length - 1]);
|
|
1340
1351
|
if (args.currentValue.rgba === '') {
|
|
1341
1352
|
fillDDB_1.element.children[0].classList.add('e-nocolor-item');
|
|
@@ -1370,17 +1381,17 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
1370
1381
|
showButtons: false, mode: 'Palette', cssClass: 'e-shape-stroke-color',
|
|
1371
1382
|
change: function (args) {
|
|
1372
1383
|
_this.pushActItemIntoObj();
|
|
1373
|
-
var
|
|
1384
|
+
var prevCropObj = extend({}, _this.cropObj, {}, true);
|
|
1385
|
+
var prevObj = _this.getCurrentObj();
|
|
1386
|
+
prevObj.objColl = extend([], _this.objColl, [], true);
|
|
1387
|
+
prevObj.pointColl = extend([], _this.pointColl, [], true);
|
|
1388
|
+
prevObj.afterCropActions = extend([], _this.afterCropActions, [], true);
|
|
1374
1389
|
_this.objColl.pop();
|
|
1375
1390
|
proxy.activeObj.strokeSettings.strokeColor = args.currentValue.hex;
|
|
1376
1391
|
proxy.strokeSettings.strokeColor = proxy.activeObj.strokeSettings.strokeColor;
|
|
1377
1392
|
if (!proxy.togglePen) {
|
|
1378
1393
|
_this.objColl.push(_this.activeObj);
|
|
1379
|
-
proxy.
|
|
1380
|
-
currentObj: extend([], proxy.objColl, [], true),
|
|
1381
|
-
previousObj: objColl, zoomFactor: proxy.zoomFactor,
|
|
1382
|
-
sharpen: proxy.adjustmentLevel.sharpen, bw: proxy.adjustmentLevel.bw });
|
|
1383
|
-
proxy.undoRedoStep++;
|
|
1394
|
+
proxy.updateUndoRedoColl('shapeTransform', prevObj, prevObj.objColl, prevObj.pointColl, prevCropObj);
|
|
1384
1395
|
proxy.redrawShape(proxy.objColl[proxy.objColl.length - 1]);
|
|
1385
1396
|
}
|
|
1386
1397
|
strokeDDB_1.element.children[0].style.backgroundColor = args.currentValue.rgba;
|
|
@@ -1431,18 +1442,18 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
1431
1442
|
},
|
|
1432
1443
|
select: function (args) {
|
|
1433
1444
|
_this.pushActItemIntoObj();
|
|
1434
|
-
var
|
|
1445
|
+
var prevCropObj = extend({}, _this.cropObj, {}, true);
|
|
1446
|
+
var prevObj = _this.getCurrentObj();
|
|
1447
|
+
prevObj.objColl = extend([], _this.objColl, [], true);
|
|
1448
|
+
prevObj.pointColl = extend([], _this.pointColl, [], true);
|
|
1449
|
+
prevObj.afterCropActions = extend([], _this.afterCropActions, [], true);
|
|
1435
1450
|
_this.objColl.pop();
|
|
1436
1451
|
spanElem_1.textContent = args.item.text;
|
|
1437
1452
|
_this.activeObj.strokeSettings.strokeWidth = parseInt(args.item.id, 10);
|
|
1438
1453
|
_this.activeObj.strokeSettings.strokeWidth *= 2;
|
|
1439
1454
|
_this.strokeSettings.strokeWidth = _this.activeObj.strokeSettings.strokeWidth;
|
|
1440
1455
|
_this.objColl.push(_this.activeObj);
|
|
1441
|
-
_this.
|
|
1442
|
-
currentObj: extend([], _this.objColl, [], true),
|
|
1443
|
-
previousObj: objColl, zoomFactor: _this.zoomFactor,
|
|
1444
|
-
sharpen: _this.adjustmentLevel.sharpen, bw: _this.adjustmentLevel.bw });
|
|
1445
|
-
_this.undoRedoStep++;
|
|
1456
|
+
_this.updateUndoRedoColl('shapeTransform', prevObj, prevObj.objColl, prevObj.pointColl, prevCropObj);
|
|
1446
1457
|
_this.redrawShape(_this.objColl[_this.objColl.length - 1]);
|
|
1447
1458
|
if (Browser.isDevice) {
|
|
1448
1459
|
if (!isNullOrUndefined(document.getElementById(_this.element.id + '_bottomToolbar'))) {
|
|
@@ -1573,17 +1584,17 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
1573
1584
|
showButtons: false, mode: 'Palette', cssClass: 'e-text-fontt-color',
|
|
1574
1585
|
change: function (args) {
|
|
1575
1586
|
_this.pushActItemIntoObj();
|
|
1576
|
-
var
|
|
1587
|
+
var prevCropObj = extend({}, _this.cropObj, {}, true);
|
|
1588
|
+
var prevObj = _this.getCurrentObj();
|
|
1589
|
+
prevObj.objColl = extend([], _this.objColl, [], true);
|
|
1590
|
+
prevObj.pointColl = extend([], _this.pointColl, [], true);
|
|
1591
|
+
prevObj.afterCropActions = extend([], _this.afterCropActions, [], true);
|
|
1577
1592
|
_this.objColl.pop();
|
|
1578
1593
|
if (proxy.textArea.style.display === 'none') {
|
|
1579
1594
|
proxy.strokeSettings.strokeColor = proxy.activeObj.strokeSettings.strokeColor = args.currentValue.hex;
|
|
1580
1595
|
if (!proxy.togglePen) {
|
|
1581
1596
|
_this.objColl.push(_this.activeObj);
|
|
1582
|
-
proxy.
|
|
1583
|
-
value: null, currentObj: extend([], proxy.objColl, [], true),
|
|
1584
|
-
previousObj: objColl, zoomFactor: proxy.zoomFactor,
|
|
1585
|
-
sharpen: proxy.adjustmentLevel.sharpen, bw: proxy.adjustmentLevel.bw });
|
|
1586
|
-
proxy.undoRedoStep++;
|
|
1597
|
+
proxy.updateUndoRedoColl('shapeTransform', prevObj, prevObj.objColl, prevObj.pointColl, prevCropObj);
|
|
1587
1598
|
proxy.redrawShape(proxy.objColl[proxy.objColl.length - 1]);
|
|
1588
1599
|
}
|
|
1589
1600
|
}
|
|
@@ -1592,21 +1603,13 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
1592
1603
|
var temp = proxy.activeObj.strokeSettings.strokeColor;
|
|
1593
1604
|
proxy.activeObj.strokeSettings.strokeColor = args.currentValue.hex;
|
|
1594
1605
|
_this.objColl.push(_this.activeObj);
|
|
1595
|
-
_this.
|
|
1596
|
-
currentObj: extend([], _this.objColl, [], true),
|
|
1597
|
-
previousObj: objColl, zoomFactor: proxy.zoomFactor,
|
|
1598
|
-
sharpen: proxy.adjustmentLevel.sharpen, bw: proxy.adjustmentLevel.bw });
|
|
1599
|
-
_this.undoRedoStep++;
|
|
1606
|
+
_this.updateUndoRedoColl('textAreaCustomization', prevObj, prevObj.objColl, prevObj.pointColl, prevCropObj);
|
|
1600
1607
|
_this.objColl.pop();
|
|
1601
1608
|
proxy.activeObj.strokeSettings.strokeColor = temp;
|
|
1602
1609
|
}
|
|
1603
1610
|
else if (!proxy.togglePen) {
|
|
1604
1611
|
_this.objColl.push(_this.activeObj);
|
|
1605
|
-
|
|
1606
|
-
currentObj: extend([], proxy.objColl, [], true),
|
|
1607
|
-
previousObj: objColl, zoomFactor: proxy.zoomFactor,
|
|
1608
|
-
sharpen: proxy.adjustmentLevel.sharpen, bw: proxy.adjustmentLevel.bw });
|
|
1609
|
-
proxy.undoRedoStep++;
|
|
1612
|
+
_this.updateUndoRedoColl('shapeTransform', prevObj, prevObj.objColl, prevObj.pointColl, prevCropObj);
|
|
1610
1613
|
proxy.redrawShape(proxy.objColl[proxy.objColl.length - 1]);
|
|
1611
1614
|
}
|
|
1612
1615
|
strokeDDB_2.element.children[0].style.backgroundColor = args.currentValue.rgba;
|
|
@@ -1678,6 +1681,11 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
1678
1681
|
select: function (args) {
|
|
1679
1682
|
_this.pushActItemIntoObj();
|
|
1680
1683
|
var objColl = extend([], _this.objColl, [], true);
|
|
1684
|
+
var prevCropObj = extend({}, _this.cropObj, {}, true);
|
|
1685
|
+
var prevObj = _this.getCurrentObj();
|
|
1686
|
+
prevObj.objColl = extend([], _this.objColl, [], true);
|
|
1687
|
+
prevObj.pointColl = extend([], _this.pointColl, [], true);
|
|
1688
|
+
prevObj.afterCropActions = extend([], _this.afterCropActions, [], true);
|
|
1681
1689
|
_this.objColl.pop();
|
|
1682
1690
|
spanElem_2.textContent = args.item.text;
|
|
1683
1691
|
if (Browser.isDevice) {
|
|
@@ -1689,11 +1697,7 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
1689
1697
|
_this.activeObj.textSettings.fontFamily = _this.toPascalCase(args.item.id);
|
|
1690
1698
|
_this.redrawText();
|
|
1691
1699
|
_this.objColl.push(_this.activeObj);
|
|
1692
|
-
_this.
|
|
1693
|
-
currentObj: extend([], _this.objColl, [], true),
|
|
1694
|
-
previousObj: objColl, zoomFactor: _this.zoomFactor,
|
|
1695
|
-
sharpen: _this.adjustmentLevel.sharpen, bw: _this.adjustmentLevel.bw });
|
|
1696
|
-
_this.undoRedoStep++;
|
|
1700
|
+
_this.updateUndoRedoColl('textAreaCustomization', prevObj, prevObj.objColl, prevObj.pointColl, prevCropObj);
|
|
1697
1701
|
_this.objColl.pop();
|
|
1698
1702
|
_this.upperContext.clearRect(0, 0, _this.upperCanvas.width, _this.upperCanvas.height);
|
|
1699
1703
|
var width = _this.activeObj.activePoint.width +
|
|
@@ -1708,11 +1712,7 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
1708
1712
|
_this.textSettings.fontFamily = _this.activeObj.textSettings.fontFamily = _this.toPascalCase(args.item.id);
|
|
1709
1713
|
_this.redrawText();
|
|
1710
1714
|
_this.objColl.push(_this.activeObj);
|
|
1711
|
-
_this.
|
|
1712
|
-
currentObj: extend([], _this.objColl, [], true),
|
|
1713
|
-
previousObj: objColl, zoomFactor: _this.zoomFactor,
|
|
1714
|
-
sharpen: _this.adjustmentLevel.sharpen, bw: _this.adjustmentLevel.bw });
|
|
1715
|
-
_this.undoRedoStep++;
|
|
1715
|
+
_this.updateUndoRedoColl('shapeTransform', prevObj, objColl, extend([], _this.pointColl, [], true), prevCropObj);
|
|
1716
1716
|
_this.redrawShape(_this.objColl[_this.objColl.length - 1]);
|
|
1717
1717
|
}
|
|
1718
1718
|
}
|
|
@@ -1813,7 +1813,11 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
1813
1813
|
},
|
|
1814
1814
|
select: function (args) {
|
|
1815
1815
|
_this.pushActItemIntoObj();
|
|
1816
|
-
var
|
|
1816
|
+
var prevCropObj = extend({}, _this.cropObj, {}, true);
|
|
1817
|
+
var prevObj = _this.getCurrentObj();
|
|
1818
|
+
prevObj.objColl = extend([], _this.objColl, [], true);
|
|
1819
|
+
prevObj.pointColl = extend([], _this.pointColl, [], true);
|
|
1820
|
+
prevObj.afterCropActions = extend([], _this.afterCropActions, [], true);
|
|
1817
1821
|
_this.objColl.pop();
|
|
1818
1822
|
fontSizeSpanElem_1.textContent = args.item.text;
|
|
1819
1823
|
if (_this.textArea.style.display === 'block') {
|
|
@@ -1821,11 +1825,7 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
1821
1825
|
var temp = _this.activeObj.textSettings.fontSize;
|
|
1822
1826
|
_this.activeObj.textSettings.fontSize = parseInt(_this.fontSizeColl[(parseInt(args.item.text, 10) - 1)].text, 10);
|
|
1823
1827
|
_this.objColl.push(_this.activeObj);
|
|
1824
|
-
_this.
|
|
1825
|
-
currentObj: extend([], _this.objColl, [], true),
|
|
1826
|
-
previousObj: objColl, zoomFactor: _this.zoomFactor,
|
|
1827
|
-
sharpen: _this.adjustmentLevel.sharpen, bw: _this.adjustmentLevel.bw });
|
|
1828
|
-
_this.undoRedoStep++;
|
|
1828
|
+
_this.updateUndoRedoColl('textAreaCustomization', prevObj, prevObj.objColl, prevObj.pointColl, prevCropObj);
|
|
1829
1829
|
_this.objColl.pop();
|
|
1830
1830
|
var textStyle = '';
|
|
1831
1831
|
if (_this.textArea.style.fontWeight === 'bold') {
|
|
@@ -1865,11 +1865,7 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
1865
1865
|
_this.updateActiveObject(_this.activeObj.activePoint, _this.activeObj);
|
|
1866
1866
|
_this.redrawText();
|
|
1867
1867
|
_this.objColl.push(_this.activeObj);
|
|
1868
|
-
_this.
|
|
1869
|
-
currentObj: extend([], _this.objColl, [], true),
|
|
1870
|
-
previousObj: objColl, zoomFactor: _this.zoomFactor,
|
|
1871
|
-
sharpen: _this.adjustmentLevel.sharpen, bw: _this.adjustmentLevel.bw });
|
|
1872
|
-
_this.undoRedoStep++;
|
|
1868
|
+
_this.updateUndoRedoColl('shapeTransform', prevObj, prevObj.objColl, prevObj.pointColl, prevCropObj);
|
|
1873
1869
|
_this.redrawShape(_this.objColl[_this.objColl.length - 1]);
|
|
1874
1870
|
}
|
|
1875
1871
|
}
|
|
@@ -1929,14 +1925,27 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
1929
1925
|
return width;
|
|
1930
1926
|
};
|
|
1931
1927
|
ImageEditor.prototype.updateUndoRedoObj = function (objColl) {
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1928
|
+
if (this.allowUndoRedo) {
|
|
1929
|
+
this.objColl.push(this.activeObj);
|
|
1930
|
+
var cropObj = extend({}, this.cropObj, {}, true);
|
|
1931
|
+
var obj = this.getCurrentObj();
|
|
1932
|
+
obj.objColl = extend([], this.objColl, [], true);
|
|
1933
|
+
obj.pointColl = extend([], this.pointColl, [], true);
|
|
1934
|
+
obj.afterCropActions = extend([], this.afterCropActions, [], true);
|
|
1935
|
+
this.undoRedoColl.push({ operation: 'shapeTransform', previousObj: obj, currentObj: obj,
|
|
1936
|
+
previousObjColl: objColl, currentObjColl: obj.objColl,
|
|
1937
|
+
previousPointColl: obj.pointColl, currentPointColl: obj.pointColl,
|
|
1938
|
+
previousCropObj: cropObj, currentCropObj: cropObj });
|
|
1939
|
+
this.undoRedoStep++;
|
|
1940
|
+
this.redrawShape(this.objColl[this.objColl.length - 1]);
|
|
1941
|
+
}
|
|
1938
1942
|
};
|
|
1939
1943
|
ImageEditor.prototype.updateObjColl = function (item, objColl) {
|
|
1944
|
+
var prevCropObj = extend({}, this.cropObj, {}, true);
|
|
1945
|
+
var prevObj = this.getCurrentObj();
|
|
1946
|
+
prevObj.objColl = extend([], this.objColl, [], true);
|
|
1947
|
+
prevObj.pointColl = extend([], this.pointColl, [], true);
|
|
1948
|
+
prevObj.afterCropActions = extend([], this.afterCropActions, [], true);
|
|
1940
1949
|
var tempBold = this.activeObj.textSettings.bold;
|
|
1941
1950
|
var tempItalic = this.activeObj.textSettings.italic;
|
|
1942
1951
|
switch (item) {
|
|
@@ -1958,10 +1967,7 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
1958
1967
|
break;
|
|
1959
1968
|
}
|
|
1960
1969
|
this.objColl.push(this.activeObj);
|
|
1961
|
-
this.
|
|
1962
|
-
currentObj: extend([], this.objColl, [], true), previousObj: objColl, zoomFactor: this.zoomFactor,
|
|
1963
|
-
sharpen: this.adjustmentLevel.sharpen, bw: this.adjustmentLevel.bw });
|
|
1964
|
-
this.undoRedoStep++;
|
|
1970
|
+
this.updateUndoRedoColl('textAreaCustomization', prevObj, prevObj.objColl, prevObj.pointColl, prevCropObj);
|
|
1965
1971
|
this.objColl.pop();
|
|
1966
1972
|
this.activeObj.textSettings.bold = tempBold;
|
|
1967
1973
|
this.activeObj.textSettings.italic = tempItalic;
|
|
@@ -2190,7 +2196,7 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
2190
2196
|
this.disablePan = false;
|
|
2191
2197
|
}
|
|
2192
2198
|
zoomIn = document.querySelector('#' + this.element.id + '_zoomIn');
|
|
2193
|
-
if (!isNullOrUndefined(zoomIn) && this.zoomFactor >=
|
|
2199
|
+
if (!isNullOrUndefined(zoomIn) && this.zoomFactor >= 2) {
|
|
2194
2200
|
zoomIn.classList.add('e-disabled');
|
|
2195
2201
|
zoomIn.parentElement.classList.add('e-overlay');
|
|
2196
2202
|
}
|
|
@@ -2210,7 +2216,12 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
2210
2216
|
break;
|
|
2211
2217
|
case 'crop':
|
|
2212
2218
|
if (!isNullOrUndefined(this.currSelectionPoint)) {
|
|
2213
|
-
this.
|
|
2219
|
+
if (this.currObjType.isUndoAction) {
|
|
2220
|
+
this.refreshUndoRedoColl();
|
|
2221
|
+
}
|
|
2222
|
+
if (!isNullOrUndefined(this.cropObj.activeObj.shape)) {
|
|
2223
|
+
this.select(this.cropObj.activeObj.shape);
|
|
2224
|
+
}
|
|
2214
2225
|
this.refreshToolbar('main', true, true);
|
|
2215
2226
|
getComponent(this.element.querySelector('#' + this.element.id + '_cropBtn'), 'dropdown-btn').toggle();
|
|
2216
2227
|
if (!isNullOrUndefined(this.activeObj.shape)) {
|
|
@@ -2222,12 +2233,12 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
2222
2233
|
imageEditorObj.reset();
|
|
2223
2234
|
this.currentToolbar = 'main';
|
|
2224
2235
|
break;
|
|
2225
|
-
case 'undo':
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
case 'redo':
|
|
2229
|
-
|
|
2230
|
-
|
|
2236
|
+
// case 'undo':
|
|
2237
|
+
// this.callUndo();
|
|
2238
|
+
// break;
|
|
2239
|
+
// case 'redo':
|
|
2240
|
+
// this.callRedo();
|
|
2241
|
+
// break;
|
|
2231
2242
|
case 'adjustment':
|
|
2232
2243
|
if (!isDisabledAdjustment) {
|
|
2233
2244
|
this.refreshToolbar('adjustment');
|
|
@@ -2259,6 +2270,9 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
2259
2270
|
case 'sepia':
|
|
2260
2271
|
case 'invert':
|
|
2261
2272
|
case 'sharpen':
|
|
2273
|
+
if (this.currObjType.isUndoAction) {
|
|
2274
|
+
this.refreshUndoRedoColl();
|
|
2275
|
+
}
|
|
2262
2276
|
this.currObjType.isFiltered = true;
|
|
2263
2277
|
this.setFilter(type);
|
|
2264
2278
|
break;
|
|
@@ -2291,7 +2305,6 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
2291
2305
|
this.currObjType.isFiltered = false;
|
|
2292
2306
|
this.adjustmentLevel = extend({}, this.tempAdjustmentLevel, {}, true);
|
|
2293
2307
|
this.element.querySelector('.e-contextual-toolbar-wrapper').classList.add('e-hide');
|
|
2294
|
-
this.undoRedoColl = extend([], this.tempUndoRedoColl, [], true);
|
|
2295
2308
|
this.undoRedoStep = this.tempUndoRedoStep;
|
|
2296
2309
|
this.upperCanvas.style.cursor = 'default';
|
|
2297
2310
|
this.currObjType.isCustomCrop = false;
|
|
@@ -2330,7 +2343,9 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
2330
2343
|
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
2331
2344
|
this.renderImage();
|
|
2332
2345
|
this.refreshToolbar('main');
|
|
2333
|
-
this.pointColl[this.freehandDrawSelectedIndex]
|
|
2346
|
+
if (!isNullOrUndefined(this.pointColl[this.freehandDrawSelectedIndex])) {
|
|
2347
|
+
this.pointColl[this.freehandDrawSelectedIndex].isSelected = false;
|
|
2348
|
+
}
|
|
2334
2349
|
this.isFreehandDrawEditing = this.isFreehandDrawingPoint = false;
|
|
2335
2350
|
this.freehandDrawHoveredIndex = this.freehandDrawSelectedIndex = null;
|
|
2336
2351
|
};
|
|
@@ -2342,8 +2357,10 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
2342
2357
|
this.pointColl[n].strokeWidth = this.tempFreeHandDrawEditingStyles.strokeWidth;
|
|
2343
2358
|
}
|
|
2344
2359
|
this.pointCounter = 0;
|
|
2345
|
-
this.pointColl[this.freehandDrawSelectedIndex]
|
|
2346
|
-
|
|
2360
|
+
if (!isNullOrUndefined(this.pointColl[this.freehandDrawSelectedIndex])) {
|
|
2361
|
+
this.pointColl[this.freehandDrawSelectedIndex].isSelected = false;
|
|
2362
|
+
}
|
|
2363
|
+
this.freehandDrawHoveredIndex = this.freehandDrawSelectedIndex = this.freehandDrawSelectedId = null;
|
|
2347
2364
|
this.isFreehandDrawEditing = this.isFreehandDrawingPoint = false;
|
|
2348
2365
|
this.tempFreeHandDrawEditingStyles = { strokeColor: null, strokeWidth: null, fillColor: null };
|
|
2349
2366
|
this.refreshToolbar('main');
|
|
@@ -2881,6 +2898,9 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
2881
2898
|
width: Browser.isDevice ? '200px' : '300px',
|
|
2882
2899
|
cssClass: 'e-slider',
|
|
2883
2900
|
change: function (args) {
|
|
2901
|
+
if (_this.currObjType.isUndoAction) {
|
|
2902
|
+
_this.refreshUndoRedoColl();
|
|
2903
|
+
}
|
|
2884
2904
|
_this.setCurrAdjustmentValue(type, args.value);
|
|
2885
2905
|
_this.enableDisableToolbarBtn();
|
|
2886
2906
|
}
|
|
@@ -2985,11 +3005,80 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
2985
3005
|
this.iterateObjColl();
|
|
2986
3006
|
this.freehandRedraw(this.lowerContext);
|
|
2987
3007
|
this.lowerContext.filter = temp;
|
|
3008
|
+
this.currSelectionPoint = null;
|
|
3009
|
+
}
|
|
3010
|
+
else {
|
|
3011
|
+
if (this.cropObj.cropZoom > 0) {
|
|
3012
|
+
var cropObjColl_1 = extend([], this.objColl, null, true);
|
|
3013
|
+
var cropPointColl_1 = extend([], this.pointColl, null, true);
|
|
3014
|
+
this.objColl = [];
|
|
3015
|
+
this.pointColl = [];
|
|
3016
|
+
this.freehandCounter = 0;
|
|
3017
|
+
this.zoom(this.cropObj.cropZoom);
|
|
3018
|
+
this.objColl = cropObjColl_1;
|
|
3019
|
+
this.pointColl = cropPointColl_1;
|
|
3020
|
+
this.freehandCounter = this.pointColl.length;
|
|
3021
|
+
this.currSelectionPoint = extend({}, this.cropObj.activeObj, null, true);
|
|
3022
|
+
if (this.cropObj.currFlipState !== '') {
|
|
3023
|
+
this.cropObj.totalPannedPoint.x += this.cropObj.tempFlipPanPoint.x;
|
|
3024
|
+
this.cropObj.totalPannedPoint.y += this.cropObj.tempFlipPanPoint.y;
|
|
3025
|
+
}
|
|
3026
|
+
}
|
|
3027
|
+
var destPoints = { startX: this.destLeft, startY: this.destTop, width: this.destWidth, height: this.destHeight };
|
|
3028
|
+
this.destLeft = this.currSelectionPoint.activePoint.startX;
|
|
3029
|
+
this.destTop = this.currSelectionPoint.activePoint.startY;
|
|
3030
|
+
this.destWidth = this.currSelectionPoint.activePoint.width;
|
|
3031
|
+
this.destHeight = this.currSelectionPoint.activePoint.height;
|
|
3032
|
+
this.zoomObjColl();
|
|
3033
|
+
this.zoomFreehandDrawColl();
|
|
3034
|
+
this.destLeft = destPoints.startX;
|
|
3035
|
+
this.destTop = destPoints.startY;
|
|
3036
|
+
this.destWidth = destPoints.width;
|
|
3037
|
+
this.destHeight = destPoints.height;
|
|
3038
|
+
this.updatePannedRegion();
|
|
3039
|
+
this.updateObjAndFreeHandDrawColl();
|
|
3040
|
+
var cropObjColl = extend([], this.objColl, null, true);
|
|
3041
|
+
var cropPointColl = extend([], this.pointColl, null, true);
|
|
3042
|
+
this.objColl = [];
|
|
3043
|
+
this.pointColl = [];
|
|
3044
|
+
this.freehandCounter = 0;
|
|
3045
|
+
this.setCurrentObj();
|
|
3046
|
+
var activeObj = extend({}, this.activeObj, null, true);
|
|
3047
|
+
this.refreshActiveObj();
|
|
3048
|
+
this.objColl = cropObjColl;
|
|
3049
|
+
this.pointColl = cropPointColl;
|
|
3050
|
+
this.freehandCounter = this.pointColl.length;
|
|
3051
|
+
this.zoomObjColl();
|
|
3052
|
+
this.zoomFreehandDrawColl();
|
|
3053
|
+
this.currSelectionPoint = null;
|
|
3054
|
+
if (this.degree === 0) {
|
|
3055
|
+
this.drawPannImage({ x: 0, y: 0 });
|
|
3056
|
+
}
|
|
3057
|
+
this.activeObj = activeObj;
|
|
3058
|
+
this.drawObject('duplicate');
|
|
3059
|
+
}
|
|
3060
|
+
};
|
|
3061
|
+
ImageEditor.prototype.updatePannedRegion = function () {
|
|
3062
|
+
var pannedPoint = this.degree === 0 ? this.cropObj.totalPannedPoint : this.cropObj.totalPannedClientPoint;
|
|
3063
|
+
if (this.currFlipState === this.cropObj.currFlipState) {
|
|
3064
|
+
this.panObjColl(-pannedPoint.x, -pannedPoint.y, '');
|
|
3065
|
+
this.panFreehandDrawColl(-pannedPoint.x, -pannedPoint.y, '');
|
|
2988
3066
|
}
|
|
2989
3067
|
else {
|
|
2990
|
-
this.
|
|
3068
|
+
if (this.currFlipState === 'horizontal' && this.cropObj.currFlipState === '' ||
|
|
3069
|
+
this.currFlipState === 'vertical' && this.cropObj.currFlipState === '') {
|
|
3070
|
+
this.panObjColl(-pannedPoint.x, -pannedPoint.y, '');
|
|
3071
|
+
this.panFreehandDrawColl(-pannedPoint.x, -pannedPoint.y, '');
|
|
3072
|
+
}
|
|
3073
|
+
else if (this.currFlipState === '' && this.cropObj.currFlipState === 'horizontal') {
|
|
3074
|
+
this.panObjColl(pannedPoint.x, -pannedPoint.y, '');
|
|
3075
|
+
this.panFreehandDrawColl(pannedPoint.x, -pannedPoint.y, '');
|
|
3076
|
+
}
|
|
3077
|
+
else if (this.currFlipState === '' && this.cropObj.currFlipState === 'vertical') {
|
|
3078
|
+
this.panObjColl(-pannedPoint.x, pannedPoint.y, '');
|
|
3079
|
+
this.panFreehandDrawColl(-pannedPoint.x, pannedPoint.y, '');
|
|
3080
|
+
}
|
|
2991
3081
|
}
|
|
2992
|
-
this.currSelectionPoint = null;
|
|
2993
3082
|
};
|
|
2994
3083
|
ImageEditor.prototype.updateObjAndFreeHandDrawColl = function () {
|
|
2995
3084
|
for (var i = 0; i < this.objColl.length; i++) {
|
|
@@ -3109,7 +3198,7 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
3109
3198
|
var activeObj = extend({}, this.activeObj, {});
|
|
3110
3199
|
this.destLeft += (-this.totalPannedPoint.x);
|
|
3111
3200
|
this.destTop += (-this.totalPannedPoint.y);
|
|
3112
|
-
this.drawPannImage({ x: -this.totalPannedPoint.x, y: -this.totalPannedPoint.y }
|
|
3201
|
+
this.drawPannImage({ x: -this.totalPannedPoint.x, y: -this.totalPannedPoint.y });
|
|
3113
3202
|
this.updateFlipPan(activeObj);
|
|
3114
3203
|
this.totalPannedPoint = { x: 0, y: 0 };
|
|
3115
3204
|
}
|
|
@@ -3129,6 +3218,7 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
3129
3218
|
else {
|
|
3130
3219
|
this.zoom(Math.abs(length_1));
|
|
3131
3220
|
}
|
|
3221
|
+
this.cropZoomFactor = this.tempZoomFactor;
|
|
3132
3222
|
}
|
|
3133
3223
|
else {
|
|
3134
3224
|
this.isCancelAction = true;
|
|
@@ -3138,7 +3228,7 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
3138
3228
|
this.freehandCounter = 0;
|
|
3139
3229
|
var cropObj = extend({}, this.cropObj, {});
|
|
3140
3230
|
var afterCropActions = extend([], this.afterCropActions, {}, true);
|
|
3141
|
-
this.
|
|
3231
|
+
this.setCurrentObj();
|
|
3142
3232
|
this.cropImg();
|
|
3143
3233
|
this.cropObj = cropObj;
|
|
3144
3234
|
this.afterCropActions = afterCropActions;
|
|
@@ -3191,6 +3281,11 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
3191
3281
|
}
|
|
3192
3282
|
}
|
|
3193
3283
|
context.closePath();
|
|
3284
|
+
var prevCropObj = extend({}, this.cropObj, {}, true);
|
|
3285
|
+
var prevObj = this.getCurrentObj();
|
|
3286
|
+
prevObj.objColl = extend([], this.objColl, [], true);
|
|
3287
|
+
prevObj.pointColl = extend([], this.pointColl, [], true);
|
|
3288
|
+
prevObj.afterCropActions = extend([], this.afterCropActions, [], true);
|
|
3194
3289
|
this.pointColl[this.freehandCounter] = {};
|
|
3195
3290
|
this.pointColl[this.freehandCounter].points = extend([], this.points);
|
|
3196
3291
|
this.pointColl[this.freehandCounter].strokeColor = this.activeObj.strokeSettings.strokeColor;
|
|
@@ -3202,16 +3297,7 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
3202
3297
|
this.freehandCounter++;
|
|
3203
3298
|
this.currentFreehandDrawIndex++;
|
|
3204
3299
|
this.isFreehandDrawing = false;
|
|
3205
|
-
|
|
3206
|
-
var currentObj = extend([], this.pointColl, [], true);
|
|
3207
|
-
this.pointColl = {};
|
|
3208
|
-
for (var i = 0; i < this.freehandCounter - 1; i++) {
|
|
3209
|
-
this.pointColl[i] = currentObj[i];
|
|
3210
|
-
}
|
|
3211
|
-
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
3212
|
-
var previousObj = extend([], this.pointColl, [], true);
|
|
3213
|
-
this.updateUndoRedoColl('freehanddraw', null, previousObj, currentObj, this.zoomFactor);
|
|
3214
|
-
this.pointColl = currentObj;
|
|
3300
|
+
this.updateUndoRedoColl('freehanddraw', prevObj, prevObj.objColl, prevObj.pointColl, prevCropObj);
|
|
3215
3301
|
};
|
|
3216
3302
|
ImageEditor.prototype.freehandMoveHandler = function (e) {
|
|
3217
3303
|
this.isFreehandPointMoved = true;
|
|
@@ -3695,8 +3781,11 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
3695
3781
|
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
3696
3782
|
var temp = extend([], _this.pointColl, [], true);
|
|
3697
3783
|
_this.updateFreehandDrawColorChange();
|
|
3698
|
-
|
|
3699
|
-
var
|
|
3784
|
+
var prevCropObj = extend({}, _this.cropObj, {}, true);
|
|
3785
|
+
var prevObj = _this.getCurrentObj();
|
|
3786
|
+
prevObj.objColl = extend([], _this.objColl, [], true);
|
|
3787
|
+
prevObj.pointColl = extend([], _this.pointColl, [], true);
|
|
3788
|
+
prevObj.afterCropActions = extend([], _this.afterCropActions, [], true);
|
|
3700
3789
|
_this.pointColl = temp;
|
|
3701
3790
|
proxy.isFreehandDrawCustomized = true;
|
|
3702
3791
|
proxy.activeObj.strokeSettings.strokeColor = proxy.selectedFreehandColor = args.currentValue.hex;
|
|
@@ -3704,7 +3793,7 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
3704
3793
|
_this.upperContext.clearRect(0, 0, _this.upperCanvas.width, _this.upperCanvas.height);
|
|
3705
3794
|
_this.pointColl[_this.freehandDrawSelectedIndex].strokeColor = args.currentValue.hex;
|
|
3706
3795
|
_this.hoverFreehandraw(args.currentValue.hex);
|
|
3707
|
-
_this.updateUndoRedoColl('freehanddrawCustomized',
|
|
3796
|
+
_this.updateUndoRedoColl('freehanddrawCustomized', prevObj, prevObj.objColl, prevObj.pointColl, prevCropObj);
|
|
3708
3797
|
}
|
|
3709
3798
|
else if (!proxy.togglePen) {
|
|
3710
3799
|
proxy.redrawShape(_this.activeObj);
|
|
@@ -3769,8 +3858,11 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
3769
3858
|
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
3770
3859
|
var temp = extend([], _this.pointColl, [], true);
|
|
3771
3860
|
_this.updateFreehandDrawColorChange();
|
|
3772
|
-
|
|
3773
|
-
var
|
|
3861
|
+
var prevCropObj = extend({}, _this.cropObj, {}, true);
|
|
3862
|
+
var prevObj = _this.getCurrentObj();
|
|
3863
|
+
prevObj.objColl = extend([], _this.objColl, [], true);
|
|
3864
|
+
prevObj.pointColl = extend([], _this.pointColl, [], true);
|
|
3865
|
+
prevObj.afterCropActions = extend([], _this.afterCropActions, [], true);
|
|
3774
3866
|
_this.pointColl = temp;
|
|
3775
3867
|
_this.isFreehandDrawCustomized = true;
|
|
3776
3868
|
spanElem_3.textContent = args.item.text;
|
|
@@ -3779,7 +3871,7 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
3779
3871
|
_this.upperContext.clearRect(0, 0, _this.upperCanvas.width, _this.upperCanvas.height);
|
|
3780
3872
|
_this.hoverFreehandraw(null, _this.penStrokeWidth);
|
|
3781
3873
|
_this.pointColl[_this.freehandDrawSelectedIndex].strokeWidth = _this.penStrokeWidth;
|
|
3782
|
-
_this.updateUndoRedoColl('freehanddrawCustomized',
|
|
3874
|
+
_this.updateUndoRedoColl('freehanddrawCustomized', prevObj, prevObj.objColl, prevObj.pointColl, prevCropObj);
|
|
3783
3875
|
}
|
|
3784
3876
|
if (Browser.isDevice) {
|
|
3785
3877
|
if (!isNullOrUndefined(document.getElementById(_this.element.id + '_bottomToolbar'))) {
|
|
@@ -3988,6 +4080,9 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
3988
4080
|
this.destLeft += this.totalPannedInternalPoint.x;
|
|
3989
4081
|
this.destTop += this.totalPannedInternalPoint.y;
|
|
3990
4082
|
var temp = this.lowerContext.filter;
|
|
4083
|
+
if (this.degree === 0) {
|
|
4084
|
+
this.setDestPointsForFlipState();
|
|
4085
|
+
}
|
|
3991
4086
|
this.updateBrightnessFilter();
|
|
3992
4087
|
this.lowerContext.drawImage(this.baseImg, this.srcLeft, this.srcTop, this.srcWidth, this.srcHeight, this.destLeft, this.destTop, this.destWidth, this.destHeight);
|
|
3993
4088
|
this.updateCurrentTransformedState('reverse');
|
|
@@ -4231,6 +4326,10 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
4231
4326
|
context.strokeStyle = '#fff';
|
|
4232
4327
|
minStrokeWidth = maxStrokeWidth = this.penStrokeWidth = strokeWidth ?
|
|
4233
4328
|
strokeWidth : this.pointColl[idx].strokeWidth;
|
|
4329
|
+
if (len === 1) {
|
|
4330
|
+
controlPoint1 = controlPoint2 = startPoint = endPoint = this.points[0];
|
|
4331
|
+
this.startDraw(context, controlPoint1, controlPoint2, startPoint, endPoint, minStrokeWidth, maxStrokeWidth);
|
|
4332
|
+
}
|
|
4234
4333
|
for (var l = 0; l < len - 3; l++) {
|
|
4235
4334
|
if (this.points[l + 1] && this.points[l + 2] && this.points[l + 2]) {
|
|
4236
4335
|
controlPoint1 = (this.calcCurveControlPoints(this.points[l + 0], this.points[l + 1], this.points[l + 2])).controlPoint2;
|
|
@@ -4239,55 +4338,64 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
4239
4338
|
endPoint = this.points[l + 2];
|
|
4240
4339
|
this.startDraw(context, controlPoint1, controlPoint2, startPoint, endPoint, minStrokeWidth, maxStrokeWidth);
|
|
4241
4340
|
}
|
|
4242
|
-
if (len === 1) {
|
|
4243
|
-
controlPoint1 = controlPoint2 = startPoint = endPoint = this.points[0];
|
|
4244
|
-
this.startDraw(context, controlPoint1, controlPoint2, startPoint, endPoint, minStrokeWidth, maxStrokeWidth);
|
|
4245
|
-
}
|
|
4246
4341
|
}
|
|
4247
4342
|
context.closePath();
|
|
4248
4343
|
};
|
|
4249
|
-
ImageEditor.prototype.
|
|
4250
|
-
|
|
4251
|
-
|
|
4252
|
-
|
|
4253
|
-
|
|
4254
|
-
|
|
4255
|
-
|
|
4256
|
-
|
|
4257
|
-
|
|
4258
|
-
this.points[l].x = (this.destLeft + this.destWidth) - (this.points[l].x - this.destLeft);
|
|
4259
|
-
}
|
|
4260
|
-
else if (this.points[l].x >= this.destLeft + (this.destWidth / 2)) {
|
|
4261
|
-
this.points[l].x = this.destLeft + (this.destLeft + this.destWidth - this.points[l].x);
|
|
4262
|
-
}
|
|
4263
|
-
this.points[l].ratioX = (this.points[l].x - this.destLeft) / this.destWidth;
|
|
4264
|
-
this.points[l].ratioY = (this.points[l].y - this.destTop) / this.destHeight;
|
|
4344
|
+
ImageEditor.prototype.pointsHorizontalFlip = function () {
|
|
4345
|
+
for (var n = 0; n < this.freehandCounter; n++) {
|
|
4346
|
+
if (this.pointColl[n].shapeFlip !== this.currFlipState) {
|
|
4347
|
+
this.points = extend([], this.pointColl[n].points, []);
|
|
4348
|
+
this.pointCounter = 0;
|
|
4349
|
+
var len = this.points.length;
|
|
4350
|
+
for (var l = 0; l < len; l++) {
|
|
4351
|
+
if (this.points[l].x <= this.destLeft + (this.destWidth / 2)) {
|
|
4352
|
+
this.points[l].x = (this.destLeft + this.destWidth) - (this.points[l].x - this.destLeft);
|
|
4265
4353
|
}
|
|
4266
|
-
this.
|
|
4354
|
+
else if (this.points[l].x >= this.destLeft + (this.destWidth / 2)) {
|
|
4355
|
+
this.points[l].x = this.destLeft + (this.destLeft + this.destWidth - this.points[l].x);
|
|
4356
|
+
}
|
|
4357
|
+
this.points[l].ratioX = (this.points[l].x - this.destLeft) / this.destWidth;
|
|
4358
|
+
this.points[l].ratioY = (this.points[l].y - this.destTop) / this.destHeight;
|
|
4267
4359
|
}
|
|
4360
|
+
this.pointColl[n].shapeFlip = this.currFlipState;
|
|
4268
4361
|
}
|
|
4269
4362
|
}
|
|
4270
|
-
|
|
4271
|
-
|
|
4272
|
-
|
|
4273
|
-
|
|
4274
|
-
|
|
4275
|
-
|
|
4276
|
-
|
|
4277
|
-
|
|
4278
|
-
|
|
4279
|
-
|
|
4280
|
-
|
|
4281
|
-
|
|
4282
|
-
|
|
4283
|
-
this.points[l].ratioX = (this.points[l].x - this.destLeft) / this.destWidth;
|
|
4284
|
-
this.points[l].ratioY = (this.points[l].y - this.destTop) / this.destHeight;
|
|
4363
|
+
};
|
|
4364
|
+
ImageEditor.prototype.pointsVerticalFlip = function () {
|
|
4365
|
+
for (var n = 0; n < this.freehandCounter; n++) {
|
|
4366
|
+
if (this.pointColl[n].shapeFlip !== this.currFlipState) {
|
|
4367
|
+
this.points = extend([], this.pointColl[n].points, []);
|
|
4368
|
+
this.pointCounter = 0;
|
|
4369
|
+
var len = this.points.length;
|
|
4370
|
+
for (var l = 0; l < len; l++) {
|
|
4371
|
+
if (this.points[l].y <= this.destTop + (this.destHeight / 2)) {
|
|
4372
|
+
this.points[l].y = (this.destTop + this.destHeight) - (this.points[l].y - this.destTop);
|
|
4373
|
+
}
|
|
4374
|
+
else if (this.points[l].y >= this.destTop + (this.destHeight / 2)) {
|
|
4375
|
+
this.points[l].y = this.destTop + (this.destTop + this.destHeight - this.points[l].y);
|
|
4285
4376
|
}
|
|
4286
|
-
this.
|
|
4377
|
+
this.points[l].ratioX = (this.points[l].x - this.destLeft) / this.destWidth;
|
|
4378
|
+
this.points[l].ratioY = (this.points[l].y - this.destTop) / this.destHeight;
|
|
4287
4379
|
}
|
|
4380
|
+
this.pointColl[n].shapeFlip = this.currFlipState;
|
|
4288
4381
|
}
|
|
4289
4382
|
}
|
|
4290
4383
|
};
|
|
4384
|
+
ImageEditor.prototype.flipFreehandrawColl = function (value) {
|
|
4385
|
+
if (value.toLowerCase() === 'horizontal') {
|
|
4386
|
+
this.pointsHorizontalFlip();
|
|
4387
|
+
}
|
|
4388
|
+
else if (value.toLowerCase() === 'vertical') {
|
|
4389
|
+
this.pointsVerticalFlip();
|
|
4390
|
+
}
|
|
4391
|
+
else {
|
|
4392
|
+
this.pointsHorizontalFlip();
|
|
4393
|
+
for (var i = 0; i < this.freehandCounter; i++) {
|
|
4394
|
+
this.pointColl[i].shapeFlip = '';
|
|
4395
|
+
}
|
|
4396
|
+
this.pointsVerticalFlip();
|
|
4397
|
+
}
|
|
4398
|
+
};
|
|
4291
4399
|
ImageEditor.prototype.rotateFreehandDrawColl = function () {
|
|
4292
4400
|
for (var n = 0; n < this.freehandCounter; n++) {
|
|
4293
4401
|
this.points = extend([], this.pointColl[n].points, []);
|
|
@@ -4309,7 +4417,7 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
4309
4417
|
}
|
|
4310
4418
|
}
|
|
4311
4419
|
};
|
|
4312
|
-
ImageEditor.prototype.zoomFreehandDrawColl = function () {
|
|
4420
|
+
ImageEditor.prototype.zoomFreehandDrawColl = function (isPreventApply) {
|
|
4313
4421
|
for (var n = 0; n < this.freehandCounter; n++) {
|
|
4314
4422
|
this.points = extend([], this.pointColl[n].points, []);
|
|
4315
4423
|
this.pointCounter = 0;
|
|
@@ -4319,7 +4427,9 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
4319
4427
|
this.points[l].y = this.zoomY(this.points[l].ratioY);
|
|
4320
4428
|
}
|
|
4321
4429
|
}
|
|
4322
|
-
|
|
4430
|
+
if (isNullOrUndefined(isPreventApply)) {
|
|
4431
|
+
this.freehandRedraw(this.lowerContext);
|
|
4432
|
+
}
|
|
4323
4433
|
};
|
|
4324
4434
|
ImageEditor.prototype.zoomX = function (x) {
|
|
4325
4435
|
return (x * this.destWidth) + this.destLeft;
|
|
@@ -4488,170 +4598,154 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
4488
4598
|
};
|
|
4489
4599
|
ImageEditor.prototype.updateCropObj = function () {
|
|
4490
4600
|
this.afterCropActions = [];
|
|
4491
|
-
|
|
4492
|
-
this.cropObj
|
|
4493
|
-
this.cropObj.totalPannedPoint = extend({}, this.totalPannedPoint, {}, true);
|
|
4494
|
-
this.cropObj.totalPannedClientPoint = extend({}, this.totalPannedClientPoint, {}, true);
|
|
4495
|
-
this.cropObj.totalPannedInternalPoint = extend({}, this.totalPannedInternalPoint, {}, true);
|
|
4496
|
-
this.cropObj.activeObj = extend({}, this.activeObj, {}, true);
|
|
4497
|
-
this.cropObj.rotateFlipColl = extend([], this.rotateFlipColl, [], true);
|
|
4498
|
-
this.cropObj.degree = this.degree;
|
|
4499
|
-
this.cropObj.currFlipState = this.currFlipState;
|
|
4500
|
-
this.cropObj.destPoints = { startX: this.destLeft, startY: this.destTop, endX: 0, endY: 0,
|
|
4501
|
-
width: this.destWidth, height: this.destHeight };
|
|
4502
|
-
this.cropObj.srcPoints = { startX: this.srcLeft, startY: this.srcTop, endX: 0, endY: 0,
|
|
4503
|
-
width: this.srcWidth, height: this.srcHeight };
|
|
4601
|
+
var obj = this.getCurrentObj();
|
|
4602
|
+
this.cropObj = extend({}, obj, {}, true);
|
|
4504
4603
|
};
|
|
4505
|
-
ImageEditor.prototype.
|
|
4506
|
-
|
|
4507
|
-
|
|
4508
|
-
this.
|
|
4509
|
-
this.
|
|
4510
|
-
|
|
4511
|
-
|
|
4512
|
-
|
|
4513
|
-
|
|
4514
|
-
|
|
4515
|
-
|
|
4516
|
-
|
|
4517
|
-
|
|
4518
|
-
|
|
4519
|
-
|
|
4520
|
-
|
|
4521
|
-
this.
|
|
4522
|
-
this.
|
|
4523
|
-
|
|
4524
|
-
|
|
4525
|
-
|
|
4526
|
-
|
|
4604
|
+
ImageEditor.prototype.setCurrentObj = function (obj) {
|
|
4605
|
+
var isObj = obj ? true : false;
|
|
4606
|
+
obj = obj ? obj : this.cropObj;
|
|
4607
|
+
this.cropZoomFactor = obj.cropZoom;
|
|
4608
|
+
this.defaultZoomFactor = obj.defaultZoom;
|
|
4609
|
+
if (!isObj) {
|
|
4610
|
+
this.zoomFactor = obj.cropZoom;
|
|
4611
|
+
}
|
|
4612
|
+
else {
|
|
4613
|
+
if (!isNullOrUndefined(obj.activeObj.shape) && obj.activeObj.shape.split('-')[0] === 'crop') {
|
|
4614
|
+
this.zoomFactor = obj.cropZoom;
|
|
4615
|
+
}
|
|
4616
|
+
else {
|
|
4617
|
+
this.zoomFactor = obj.defaultZoom;
|
|
4618
|
+
}
|
|
4619
|
+
}
|
|
4620
|
+
this.totalPannedPoint = extend({}, obj.totalPannedPoint, {}, true);
|
|
4621
|
+
this.totalPannedClientPoint = extend({}, obj.totalPannedClientPoint, {}, true);
|
|
4622
|
+
this.totalPannedInternalPoint = extend({}, obj.totalPannedInternalPoint, {}, true);
|
|
4623
|
+
this.tempFlipPanPoint = extend({}, obj.tempFlipPanPoint, {}, true);
|
|
4624
|
+
this.rotateFlipColl = extend([], obj.rotateFlipColl, [], true);
|
|
4625
|
+
this.degree = obj.degree;
|
|
4626
|
+
this.currFlipState = obj.currFlipState;
|
|
4627
|
+
this.destLeft = obj.destPoints.startX;
|
|
4628
|
+
this.destTop = obj.destPoints.startY;
|
|
4629
|
+
this.destWidth = obj.destPoints.width;
|
|
4630
|
+
this.destHeight = obj.destPoints.height;
|
|
4631
|
+
this.srcLeft = obj.srcPoints.startX;
|
|
4632
|
+
this.srcTop = obj.srcPoints.startY;
|
|
4633
|
+
this.srcWidth = obj.srcPoints.width;
|
|
4634
|
+
this.srcHeight = obj.srcPoints.height;
|
|
4635
|
+
this.lowerContext.filter = obj.filter;
|
|
4636
|
+
if (this.lowerContext.filter.split(' ').length > 1) {
|
|
4637
|
+
if (this.lowerContext.filter.split(' ')[0].split('(')[1].split(')')[0] === '1') {
|
|
4638
|
+
this.isBrightnessAdjusted = false;
|
|
4639
|
+
}
|
|
4640
|
+
else {
|
|
4641
|
+
this.isBrightnessAdjusted = true;
|
|
4527
4642
|
}
|
|
4643
|
+
}
|
|
4644
|
+
var isCircleCrop = this.isCircleCrop;
|
|
4645
|
+
var currSelectionPoint = extend({}, this.currSelectionPoint, {}, true);
|
|
4646
|
+
this.currSelectionPoint = null;
|
|
4647
|
+
this.isCircleCrop = false;
|
|
4648
|
+
this.drawCropSelectionImage(obj, false);
|
|
4649
|
+
if (this.degree !== 0) {
|
|
4528
4650
|
this.currentPannedPoint = { x: 0, y: 0 };
|
|
4529
4651
|
this.rotatePan();
|
|
4530
4652
|
}
|
|
4531
|
-
this.activeObj = extend({},
|
|
4653
|
+
this.activeObj = extend({}, obj.activeObj, {}, true);
|
|
4532
4654
|
this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
|
|
4533
|
-
this.
|
|
4534
|
-
|
|
4655
|
+
if (this.activeObj.activePoint.width !== 0 && this.activeObj.activePoint.height !== 0) {
|
|
4656
|
+
this.drawObject('duplicate');
|
|
4657
|
+
}
|
|
4658
|
+
var activeObj = extend({}, obj.activeObj, {}, true);
|
|
4535
4659
|
var isAfterCropAction = false;
|
|
4536
|
-
|
|
4660
|
+
this.afterCropActions = this.alignRotateFlipColl(this.afterCropActions);
|
|
4661
|
+
var afterCropActions = extend([], this.afterCropActions, [], true);
|
|
4662
|
+
if (!isObj && afterCropActions.length > 0) {
|
|
4537
4663
|
isAfterCropAction = true;
|
|
4538
|
-
var
|
|
4539
|
-
var pointColl = extend([], this.pointColl, {}, true);
|
|
4540
|
-
var freehandCounter = this.freehandCounter;
|
|
4541
|
-
this.objColl = [];
|
|
4542
|
-
this.pointColl = [];
|
|
4543
|
-
this.freehandCounter = 0;
|
|
4544
|
-
var isCircleCrop = this.isCircleCrop;
|
|
4545
|
-
var currSelectionPoint = extend({}, this.currSelectionPoint, {}, true);
|
|
4546
|
-
this.currSelectionPoint = null;
|
|
4547
|
-
this.isCircleCrop = false;
|
|
4548
|
-
var isFlip = false;
|
|
4549
|
-
for (var i = 0; i < this.afterCropActions.length; i++) {
|
|
4664
|
+
for (var i = 0; i < afterCropActions.length; i++) {
|
|
4550
4665
|
if (this.degree % 90 === 0 && this.degree % 180 !== 0 &&
|
|
4551
|
-
(
|
|
4666
|
+
(afterCropActions[i] === 'horizontalflip' || afterCropActions[i] === 'verticalflip')) {
|
|
4552
4667
|
this.rotatedFlipCropSelection = true;
|
|
4553
4668
|
}
|
|
4554
|
-
this.updateTransform(
|
|
4555
|
-
if (
|
|
4556
|
-
if (
|
|
4557
|
-
this.
|
|
4558
|
-
this.
|
|
4669
|
+
this.updateTransform(afterCropActions[i]);
|
|
4670
|
+
if (afterCropActions[i] === 'horizontalflip' || afterCropActions[i] === 'verticalflip') {
|
|
4671
|
+
if (afterCropActions.length === 1) {
|
|
4672
|
+
this.activeObj = extend({}, this.cropObj.activeObj, {}, true);
|
|
4673
|
+
this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
|
|
4674
|
+
this.drawObject('duplicate');
|
|
4559
4675
|
}
|
|
4560
|
-
isFlip = true;
|
|
4561
4676
|
}
|
|
4562
4677
|
}
|
|
4563
|
-
this.isCircleCrop = isCircleCrop;
|
|
4564
|
-
this.currSelectionPoint = currSelectionPoint;
|
|
4565
|
-
var destPoints = { startX: this.destLeft, startY: this.destTop, width: this.destWidth, height: this.destHeight };
|
|
4566
4678
|
activeObj = extend({}, this.activeObj, {}, true);
|
|
4567
|
-
this.refreshActiveObj();
|
|
4568
|
-
this.objColl = objColl;
|
|
4569
|
-
this.pointColl = pointColl;
|
|
4570
|
-
this.freehandCounter = freehandCounter;
|
|
4571
|
-
if (this.rotateFlipColl.length > 1 && typeof (this.rotateFlipColl[this.rotateFlipColl.length - 1]) === 'string') {
|
|
4572
|
-
this.iterateObjColl();
|
|
4573
|
-
this.freehandRedraw(this.lowerContext);
|
|
4574
|
-
}
|
|
4575
|
-
else if (this.rotateFlipColl.length > 1 && typeof (this.rotateFlipColl[this.rotateFlipColl.length - 1]) === 'number' ||
|
|
4576
|
-
this.rotateFlipColl.length >= 0) {
|
|
4577
|
-
this.destLeft = activeObj.activePoint.startX;
|
|
4578
|
-
this.destTop = activeObj.activePoint.startY;
|
|
4579
|
-
this.destWidth = activeObj.activePoint.width;
|
|
4580
|
-
this.destHeight = activeObj.activePoint.height;
|
|
4581
|
-
this.zoomObjColl();
|
|
4582
|
-
this.zoomFreehandDrawColl();
|
|
4583
|
-
}
|
|
4584
|
-
this.destLeft = destPoints.startX;
|
|
4585
|
-
this.destTop = destPoints.startY;
|
|
4586
|
-
this.destWidth = destPoints.width;
|
|
4587
|
-
this.destHeight = destPoints.height;
|
|
4588
4679
|
this.totalPannedPoint = { x: 0, y: 0 };
|
|
4589
4680
|
this.totalPannedClientPoint = { x: 0, y: 0 };
|
|
4590
4681
|
this.totalPannedInternalPoint = { x: 0, y: 0 };
|
|
4591
4682
|
this.activeObj = activeObj;
|
|
4592
4683
|
this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
|
|
4593
|
-
this.
|
|
4594
|
-
|
|
4684
|
+
if (this.activeObj.activePoint.width !== 0 && this.activeObj.activePoint.height !== 0) {
|
|
4685
|
+
this.drawObject('duplicate');
|
|
4686
|
+
}
|
|
4687
|
+
if (obj.degree !== this.degree) {
|
|
4595
4688
|
this.cropZoomFactor = this.zoomFactor = 0;
|
|
4596
4689
|
}
|
|
4597
4690
|
this.updateObjAndFreeHandDrawColl();
|
|
4598
|
-
if (isFlip) {
|
|
4599
|
-
if (this.degree === 0) {
|
|
4600
|
-
var currSelectionPoint_1 = extend({}, this.currSelectionPoint, {}, true);
|
|
4601
|
-
this.currSelectionPoint = null;
|
|
4602
|
-
this.isCircleCrop = false;
|
|
4603
|
-
this.drawPannImage({ x: 0, y: 0 }, this.getCurrentPanRegion());
|
|
4604
|
-
this.updateFlipPan(activeObj);
|
|
4605
|
-
this.isCircleCrop = isCircleCrop;
|
|
4606
|
-
this.currSelectionPoint = currSelectionPoint_1;
|
|
4607
|
-
}
|
|
4608
|
-
this.activeObj = activeObj;
|
|
4609
|
-
this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
|
|
4610
|
-
this.drawObject('duplicate');
|
|
4611
|
-
}
|
|
4612
4691
|
if (this.rotatedFlipCropSelection) {
|
|
4613
4692
|
// this.totalPannedInternalPoint = extend({}, this.cropObj.totalPannedInternalPoint, {}, true) as Point;
|
|
4614
4693
|
this.rotatedFlipCropSelection = false;
|
|
4615
4694
|
}
|
|
4616
4695
|
}
|
|
4696
|
+
this.afterCropActions = afterCropActions;
|
|
4617
4697
|
if (!this.isCancelAction && !isAfterCropAction) {
|
|
4618
|
-
this.setDestPointsForFlipState();
|
|
4619
4698
|
this.updateObjAndFreeHandDrawColl();
|
|
4620
4699
|
this.zoomFreehandDrawColl();
|
|
4621
|
-
this.destLeft =
|
|
4622
|
-
this.destTop =
|
|
4700
|
+
this.destLeft = obj.destPoints.startX;
|
|
4701
|
+
this.destTop = obj.destPoints.startY;
|
|
4623
4702
|
}
|
|
4624
4703
|
this.activeObj = activeObj;
|
|
4704
|
+
this.isCircleCrop = isCircleCrop;
|
|
4705
|
+
this.currSelectionPoint = currSelectionPoint;
|
|
4625
4706
|
};
|
|
4626
|
-
ImageEditor.prototype.drawCropSelectionImage = function () {
|
|
4707
|
+
ImageEditor.prototype.drawCropSelectionImage = function (obj, isObj) {
|
|
4627
4708
|
var temp = this.lowerContext.filter;
|
|
4628
4709
|
this.upperContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
4629
4710
|
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
4630
4711
|
this.reverseTransformedState();
|
|
4631
|
-
|
|
4712
|
+
if (isObj) {
|
|
4713
|
+
this.updateCurrentTransformedState('initial');
|
|
4714
|
+
}
|
|
4715
|
+
else {
|
|
4716
|
+
this.iterateRotateFlipColl(this.lowerContext, 'initial');
|
|
4717
|
+
}
|
|
4718
|
+
this.setDestPointsForFlipState();
|
|
4632
4719
|
this.updateBrightnessFilter();
|
|
4633
4720
|
this.lowerContext.drawImage(this.baseImg, this.srcLeft, this.srcTop, this.srcWidth, this.srcHeight, this.destLeft, this.destTop, this.destWidth, this.destHeight);
|
|
4634
|
-
|
|
4635
|
-
|
|
4721
|
+
if (isObj) {
|
|
4722
|
+
this.updateCurrentTransformedState('reverse');
|
|
4723
|
+
}
|
|
4724
|
+
else {
|
|
4725
|
+
this.iterateRotateFlipColl(this.lowerContext, 'reverse');
|
|
4726
|
+
}
|
|
4727
|
+
this.destLeft = this.cropObj.destPoints.startX;
|
|
4728
|
+
this.destTop = this.cropObj.destPoints.startY;
|
|
4729
|
+
var activeObj = extend({}, obj.activeObj, {}, true);
|
|
4636
4730
|
this.lowerContext.filter = 'none';
|
|
4637
4731
|
if (this.isCancelAction) {
|
|
4638
4732
|
this.zoomObjColl();
|
|
4639
4733
|
this.zoomFreehandDrawColl();
|
|
4640
4734
|
}
|
|
4641
4735
|
else {
|
|
4642
|
-
this.destLeft =
|
|
4643
|
-
this.destTop =
|
|
4644
|
-
this.destWidth =
|
|
4645
|
-
this.destHeight =
|
|
4646
|
-
this.srcLeft =
|
|
4647
|
-
this.srcTop =
|
|
4648
|
-
this.srcWidth =
|
|
4649
|
-
this.srcHeight =
|
|
4736
|
+
this.destLeft = obj.destPoints.startX;
|
|
4737
|
+
this.destTop = obj.destPoints.startY;
|
|
4738
|
+
this.destWidth = obj.destPoints.width;
|
|
4739
|
+
this.destHeight = obj.destPoints.height;
|
|
4740
|
+
this.srcLeft = obj.srcPoints.startX;
|
|
4741
|
+
this.srcTop = obj.srcPoints.startY;
|
|
4742
|
+
this.srcWidth = obj.srcPoints.width;
|
|
4743
|
+
this.srcHeight = obj.srcPoints.height;
|
|
4650
4744
|
var destPoints = { startX: this.destLeft, startY: this.destTop, width: this.destWidth, height: this.destHeight };
|
|
4651
|
-
this.destLeft =
|
|
4652
|
-
this.destTop =
|
|
4653
|
-
this.destWidth =
|
|
4654
|
-
this.destHeight =
|
|
4745
|
+
this.destLeft = obj.activeObj.activePoint.startX;
|
|
4746
|
+
this.destTop = obj.activeObj.activePoint.startY;
|
|
4747
|
+
this.destWidth = obj.activeObj.activePoint.width;
|
|
4748
|
+
this.destHeight = obj.activeObj.activePoint.height;
|
|
4655
4749
|
this.zoomObjColl();
|
|
4656
4750
|
this.zoomFreehandDrawColl();
|
|
4657
4751
|
this.destLeft = destPoints.startX;
|
|
@@ -4668,10 +4762,12 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
4668
4762
|
}
|
|
4669
4763
|
if (isNullOrUndefined(isRotateCrop) && this.degree !== 0) {
|
|
4670
4764
|
this.updateCropObj();
|
|
4765
|
+
this.currDestinationPoint = { startX: this.destLeft, startY: this.destTop, width: this.destWidth, height: this.destHeight };
|
|
4671
4766
|
this.rotateCrop();
|
|
4672
4767
|
}
|
|
4673
4768
|
else if (isNullOrUndefined(isRotateCrop) && this.currFlipState !== '') {
|
|
4674
4769
|
this.updateCropObj();
|
|
4770
|
+
this.currDestinationPoint = { startX: this.destLeft, startY: this.destTop, width: this.destWidth, height: this.destHeight };
|
|
4675
4771
|
this.flipCrop();
|
|
4676
4772
|
}
|
|
4677
4773
|
else {
|
|
@@ -4681,6 +4777,7 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
4681
4777
|
this.updateCropObj();
|
|
4682
4778
|
this.resetPanPoints();
|
|
4683
4779
|
this.updateImageRatioForActObj();
|
|
4780
|
+
this.currDestinationPoint = { startX: this.destLeft, startY: this.destTop, width: this.destWidth, height: this.destHeight };
|
|
4684
4781
|
this.currSelectionPoint = extend({}, this.activeObj, {}, true);
|
|
4685
4782
|
this.cropDestPoints = { startX: this.destLeft, startY: this.destTop, width: this.destWidth, height: this.destHeight };
|
|
4686
4783
|
}
|
|
@@ -4870,21 +4967,35 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
4870
4967
|
}
|
|
4871
4968
|
return panRegion;
|
|
4872
4969
|
};
|
|
4873
|
-
ImageEditor.prototype.drawPannImage = function (point
|
|
4970
|
+
ImageEditor.prototype.drawPannImage = function (point) {
|
|
4971
|
+
var destPoints = { startX: this.destLeft, startY: this.destTop, width: this.destWidth, height: this.destHeight };
|
|
4874
4972
|
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
4973
|
+
this.updateCurrentTransformedState('initial');
|
|
4974
|
+
this.destLeft = destPoints.startX;
|
|
4975
|
+
this.destTop = destPoints.startY;
|
|
4976
|
+
this.destWidth = destPoints.width;
|
|
4977
|
+
this.destHeight = destPoints.height;
|
|
4978
|
+
this.setDestPointsForFlipState();
|
|
4875
4979
|
this.updateBrightnessFilter();
|
|
4876
4980
|
this.lowerContext.drawImage(this.baseImg, this.srcLeft, this.srcTop, this.srcWidth, this.srcHeight, this.destLeft, this.destTop, this.destWidth, this.destHeight);
|
|
4877
4981
|
if ((!isNullOrUndefined(this.currSelectionPoint) && this.currSelectionPoint.shape === 'crop-circle') || this.isCircleCrop) {
|
|
4878
4982
|
this.cropCircle(this.lowerContext, null, true);
|
|
4879
4983
|
}
|
|
4984
|
+
this.updateCurrentTransformedState('reverse');
|
|
4985
|
+
this.destLeft = destPoints.startX;
|
|
4986
|
+
this.destTop = destPoints.startY;
|
|
4987
|
+
this.destWidth = destPoints.width;
|
|
4988
|
+
this.destHeight = destPoints.height;
|
|
4880
4989
|
this.lowerContext.filter = 'none';
|
|
4881
|
-
this.panObjColl(point.x, point.y,
|
|
4882
|
-
this.panFreehandDrawColl(point.x, point.y,
|
|
4990
|
+
this.panObjColl(point.x, point.y, '');
|
|
4991
|
+
this.panFreehandDrawColl(point.x, point.y, '');
|
|
4883
4992
|
if (this.isCircleCrop) {
|
|
4884
4993
|
this.cropCircle(this.lowerContext, null, true);
|
|
4885
4994
|
}
|
|
4886
4995
|
};
|
|
4887
4996
|
ImageEditor.prototype.drawPannedImage = function (xDiff, yDiff) {
|
|
4997
|
+
var panEventArgs = { startPoint: this.panDown, endPoint: this.panMove };
|
|
4998
|
+
this.trigger('panning', panEventArgs);
|
|
4888
4999
|
var isObjCreated = false;
|
|
4889
5000
|
if (isNullOrUndefined(this.activeObj.shape)) {
|
|
4890
5001
|
isObjCreated = true;
|
|
@@ -4909,11 +5020,10 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
4909
5020
|
this.updateActiveObject(this.activeObj.activePoint, this.activeObj);
|
|
4910
5021
|
this.isCropTab = true;
|
|
4911
5022
|
}
|
|
4912
|
-
var panRegion = this.getCurrentPanRegion();
|
|
4913
5023
|
if (this.degree === 0) {
|
|
4914
5024
|
var point = void 0;
|
|
4915
5025
|
if (isNullOrUndefined(xDiff) && isNullOrUndefined(yDiff)) {
|
|
4916
|
-
point = this.updatePanPoints(
|
|
5026
|
+
point = this.updatePanPoints('');
|
|
4917
5027
|
}
|
|
4918
5028
|
else {
|
|
4919
5029
|
point = { x: xDiff, y: yDiff };
|
|
@@ -4922,7 +5032,7 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
4922
5032
|
this.totalPannedPoint.y += point.y;
|
|
4923
5033
|
var tempSelectionObj = extend({}, this.activeObj, {}, true);
|
|
4924
5034
|
var temp = this.lowerContext.filter;
|
|
4925
|
-
this.drawPannImage(point
|
|
5035
|
+
this.drawPannImage(point);
|
|
4926
5036
|
this.lowerContext.filter = temp;
|
|
4927
5037
|
this.tempPanMove = extend({}, this.panMove, {}, true);
|
|
4928
5038
|
this.activeObj = extend({}, tempSelectionObj, {}, true);
|
|
@@ -4930,13 +5040,12 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
4930
5040
|
if (!isNullOrUndefined(this.activeObj.shape)) {
|
|
4931
5041
|
this.drawObject('duplicate', this.activeObj);
|
|
4932
5042
|
}
|
|
4933
|
-
this.updateFlipPan(tempSelectionObj);
|
|
4934
5043
|
}
|
|
4935
5044
|
else {
|
|
4936
5045
|
var tempFlipState = this.currFlipState;
|
|
4937
5046
|
this.isCropTab = true;
|
|
4938
5047
|
if (isNullOrUndefined(xDiff) && isNullOrUndefined(yDiff)) {
|
|
4939
|
-
this.currentPannedPoint = this.updatePanPoints(
|
|
5048
|
+
this.currentPannedPoint = this.updatePanPoints('');
|
|
4940
5049
|
}
|
|
4941
5050
|
else {
|
|
4942
5051
|
this.currentPannedPoint = { x: xDiff, y: yDiff };
|
|
@@ -5020,45 +5129,23 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
5020
5129
|
var tempFlipColl = this.flipColl;
|
|
5021
5130
|
this.flipColl = [];
|
|
5022
5131
|
this.updateImageRatioForActObj();
|
|
5023
|
-
this.
|
|
5132
|
+
this.objColl.push(this.activeObj);
|
|
5133
|
+
if (this.zoomFactor > 0) {
|
|
5134
|
+
var zoomFactor = this.zoomFactor;
|
|
5135
|
+
var isUndoRedo = this.isUndoRedo;
|
|
5136
|
+
for (var i = 0; i < (zoomFactor * 10); i++) {
|
|
5137
|
+
this.isUndoRedo = true;
|
|
5138
|
+
this.zoom(-0.1);
|
|
5139
|
+
}
|
|
5140
|
+
this.isUndoRedo = isUndoRedo;
|
|
5141
|
+
this.resetPanPoints();
|
|
5142
|
+
}
|
|
5143
|
+
this.currSelectionPoint = extend({}, this.objColl[this.objColl.length - 1], {}, true);
|
|
5024
5144
|
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
5025
5145
|
this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
|
|
5026
5146
|
var temp = this.lowerContext.filter;
|
|
5027
5147
|
this.updateBrightnessFilter();
|
|
5028
|
-
if (!isNullOrUndefined(this.tempPannedPoint) && this.totalPannedPoint.x === 0 && this.totalPannedPoint.y === 0) {
|
|
5029
|
-
this.totalPannedPoint = extend({}, this.tempPannedPoint, {}, true);
|
|
5030
|
-
this.tempPannedPoint = { x: 0, y: 0 };
|
|
5031
|
-
}
|
|
5032
|
-
var isPrevent = true;
|
|
5033
|
-
if (!isNullOrUndefined(this.activeObj.shape) && this.activeObj.shape.split('-')[0] === 'crop' &&
|
|
5034
|
-
this.zoomFactor === 0 && this.cropObj.cropZoom !== 0) {
|
|
5035
|
-
isPrevent = false;
|
|
5036
|
-
}
|
|
5037
|
-
if (this.zoomFactor === 0 && isPrevent) {
|
|
5038
|
-
if (this.totalPannedPoint.x > 0) {
|
|
5039
|
-
this.destLeft -= Math.abs(this.totalPannedPoint.x);
|
|
5040
|
-
}
|
|
5041
|
-
else {
|
|
5042
|
-
this.destLeft += Math.abs(this.totalPannedPoint.x);
|
|
5043
|
-
}
|
|
5044
|
-
if (this.totalPannedPoint.y > 0) {
|
|
5045
|
-
this.destTop -= Math.abs(this.totalPannedPoint.y);
|
|
5046
|
-
}
|
|
5047
|
-
else {
|
|
5048
|
-
this.destTop += Math.abs(this.totalPannedPoint.y);
|
|
5049
|
-
}
|
|
5050
|
-
}
|
|
5051
5148
|
this.lowerContext.drawImage(this.baseImg, this.srcLeft, this.srcTop, this.srcWidth, this.srcHeight, this.destLeft, this.destTop, this.destWidth, this.destHeight);
|
|
5052
|
-
var destLeft = this.destLeft;
|
|
5053
|
-
var destTop = this.destTop;
|
|
5054
|
-
if (this.currFlipState === 'horizontal' && this.zoomFactor > 0 && this.totalPannedPoint.x !== 0) {
|
|
5055
|
-
this.destLeft = destLeft - this.totalPannedPoint.x;
|
|
5056
|
-
}
|
|
5057
|
-
else if (this.currFlipState === 'vertical' && this.zoomFactor > 0 && this.totalPannedPoint.y !== 0) {
|
|
5058
|
-
this.destTop = destTop - this.totalPannedPoint.y;
|
|
5059
|
-
}
|
|
5060
|
-
this.updateImageRatioForActObj();
|
|
5061
|
-
this.objColl.push(this.activeObj);
|
|
5062
5149
|
for (var i = 0; i < this.objColl.length; i++) {
|
|
5063
5150
|
this.objColl[i].shapeFlip = '';
|
|
5064
5151
|
}
|
|
@@ -5066,37 +5153,21 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
5066
5153
|
this.pointColl[i].shapeFlip = '';
|
|
5067
5154
|
}
|
|
5068
5155
|
this.redrawObj(this.getCurrentPanRegion());
|
|
5069
|
-
this.flipFreehandrawColl(this.
|
|
5070
|
-
if (this.zoomFactor === 0 && isPrevent) {
|
|
5071
|
-
if (this.getCurrentPanRegion() === 'horizontal') {
|
|
5072
|
-
this.panObjColl(this.totalPannedPoint.x, -this.totalPannedPoint.y, this.getCurrentPanRegion());
|
|
5073
|
-
this.panFreehandDrawColl(this.totalPannedPoint.x, -this.totalPannedPoint.y, this.getCurrentPanRegion());
|
|
5074
|
-
}
|
|
5075
|
-
else if (this.getCurrentPanRegion() === 'vertical') {
|
|
5076
|
-
this.panObjColl(-this.totalPannedPoint.x, this.totalPannedPoint.y, this.getCurrentPanRegion());
|
|
5077
|
-
this.panFreehandDrawColl(-this.totalPannedPoint.x, this.totalPannedPoint.y, this.getCurrentPanRegion());
|
|
5078
|
-
}
|
|
5079
|
-
else {
|
|
5080
|
-
this.panObjColl(-this.totalPannedPoint.x, -this.totalPannedPoint.y, this.getCurrentPanRegion());
|
|
5081
|
-
this.panFreehandDrawColl(-this.totalPannedPoint.x, -this.totalPannedPoint.y, this.getCurrentPanRegion());
|
|
5082
|
-
}
|
|
5083
|
-
}
|
|
5156
|
+
this.flipFreehandrawColl(this.getCurrentPanRegion());
|
|
5084
5157
|
this.activeObj = extend({}, this.objColl[this.objColl.length - 1], {}, true);
|
|
5085
5158
|
this.objColl.pop();
|
|
5159
|
+
this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
|
|
5086
5160
|
this.drawObject('duplicate');
|
|
5087
|
-
this.destLeft = destLeft;
|
|
5088
|
-
this.destTop = destTop;
|
|
5089
5161
|
this.cropImg(true);
|
|
5090
|
-
this.
|
|
5162
|
+
this.isReverseRotate = true;
|
|
5163
|
+
this.reverseTransformedState();
|
|
5091
5164
|
this.setDestinationPoints();
|
|
5165
|
+
this.currentTransformedState('initial');
|
|
5092
5166
|
this.updateBrightnessFilter();
|
|
5093
5167
|
this.lowerContext.drawImage(this.baseImg, this.srcLeft, this.srcTop, this.srcWidth, this.srcHeight, this.destLeft, this.destTop, this.destWidth, this.destHeight);
|
|
5094
5168
|
this.lowerContext.filter = temp;
|
|
5095
5169
|
this.isRotateZoom = false;
|
|
5096
5170
|
this.updateCurrentTransformedState('reverse');
|
|
5097
|
-
if (tempCurrFlipState === '' && this.currFlipState !== '') {
|
|
5098
|
-
tempCurrFlipState = this.currFlipState;
|
|
5099
|
-
}
|
|
5100
5171
|
this.currFlipState = tempCurrFlipState;
|
|
5101
5172
|
this.flipColl = tempFlipColl;
|
|
5102
5173
|
this.lowerContext.filter = 'none';
|
|
@@ -5107,9 +5178,9 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
5107
5178
|
this.pointColl[i].shapeFlip = '';
|
|
5108
5179
|
}
|
|
5109
5180
|
this.redrawObj(this.getCurrentPanRegion());
|
|
5110
|
-
this.flipFreehandrawColl(this.
|
|
5111
|
-
this.
|
|
5112
|
-
this.
|
|
5181
|
+
this.flipFreehandrawColl(this.getCurrentPanRegion());
|
|
5182
|
+
this.zoomObjColl();
|
|
5183
|
+
this.zoomFreehandDrawColl();
|
|
5113
5184
|
this.lowerContext.filter = temp;
|
|
5114
5185
|
if ((!isNullOrUndefined(this.currSelectionPoint) && this.currSelectionPoint.shape === 'crop-circle') || this.isCircleCrop) {
|
|
5115
5186
|
this.cropCircle(this.lowerContext);
|
|
@@ -5120,6 +5191,7 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
5120
5191
|
this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
|
|
5121
5192
|
this.isReverseFlip = false;
|
|
5122
5193
|
this.resetPanPoints();
|
|
5194
|
+
this.tempFlipPanPoint = { x: 0, y: 0 };
|
|
5123
5195
|
};
|
|
5124
5196
|
ImageEditor.prototype.rotateCrop = function () {
|
|
5125
5197
|
var shape = '';
|
|
@@ -5162,31 +5234,19 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
5162
5234
|
}
|
|
5163
5235
|
var activeObj = extend({}, this.objColl[this.objColl.length - 1], {}, true);
|
|
5164
5236
|
if (this.currFlipState !== '') {
|
|
5165
|
-
var flipState = '';
|
|
5166
5237
|
for (var i = 0; i < this.objColl.length; i++) {
|
|
5167
5238
|
this.objColl[i].shapeFlip = '';
|
|
5168
5239
|
}
|
|
5169
|
-
if (this.currFlipState === 'horizontal') {
|
|
5170
|
-
flipState = this.degree % 90 === 0 && this.degree % 180 !== 0 ? 'vertical' : 'horizontal';
|
|
5171
|
-
this.redrawObj(flipState);
|
|
5172
|
-
}
|
|
5173
|
-
else if (this.currFlipState === 'vertical') {
|
|
5174
|
-
flipState = this.degree % 90 === 0 && this.degree % 180 !== 0 ? 'horizontal' : 'vertical';
|
|
5175
|
-
this.redrawObj(flipState);
|
|
5176
|
-
}
|
|
5177
5240
|
for (var i = 0; i < this.freehandCounter; i++) {
|
|
5178
5241
|
this.pointColl[i].shapeFlip = '';
|
|
5179
5242
|
}
|
|
5180
|
-
|
|
5181
|
-
|
|
5182
|
-
|
|
5183
|
-
}
|
|
5184
|
-
else if (this.currFlipState === 'vertical') {
|
|
5185
|
-
flipState = this.degree % 90 === 0 && this.degree % 180 !== 0 ? 'horizontal' : 'vertical';
|
|
5186
|
-
this.flipFreehandrawColl(flipState);
|
|
5187
|
-
}
|
|
5243
|
+
var flipState = this.getCurrentCropState('initial');
|
|
5244
|
+
this.redrawObj(flipState);
|
|
5245
|
+
this.flipFreehandrawColl(flipState);
|
|
5188
5246
|
}
|
|
5247
|
+
this.zoomObjColl();
|
|
5189
5248
|
this.zoomFreehandDrawColl();
|
|
5249
|
+
activeObj = extend({}, this.objColl[this.objColl.length - 1], {}, true);
|
|
5190
5250
|
this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
|
|
5191
5251
|
this.drawObject('duplicate', activeObj);
|
|
5192
5252
|
this.objColl.pop();
|
|
@@ -5215,25 +5275,16 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
5215
5275
|
this.rotateObjColl();
|
|
5216
5276
|
this.rotateFreehandDrawColl();
|
|
5217
5277
|
}
|
|
5218
|
-
if (this.
|
|
5278
|
+
if (this.getCurrentPanRegion() !== '') {
|
|
5219
5279
|
for (var i = 0; i < this.objColl.length; i++) {
|
|
5220
5280
|
this.objColl[i].shapeFlip = '';
|
|
5221
5281
|
}
|
|
5222
|
-
if (this.currFlipState === 'horizontal') {
|
|
5223
|
-
this.redrawObj('horizontal');
|
|
5224
|
-
}
|
|
5225
|
-
else if (this.currFlipState === 'vertical') {
|
|
5226
|
-
this.redrawObj('vertical');
|
|
5227
|
-
}
|
|
5228
5282
|
for (var i = 0; i < this.freehandCounter; i++) {
|
|
5229
5283
|
this.pointColl[i].shapeFlip = '';
|
|
5230
5284
|
}
|
|
5231
|
-
|
|
5232
|
-
|
|
5233
|
-
|
|
5234
|
-
else if (this.currFlipState === 'vertical') {
|
|
5235
|
-
this.flipFreehandrawColl('vertical');
|
|
5236
|
-
}
|
|
5285
|
+
var flipState = this.getCurrentCropState('reverse');
|
|
5286
|
+
this.redrawObj(flipState);
|
|
5287
|
+
this.flipFreehandrawColl(flipState);
|
|
5237
5288
|
}
|
|
5238
5289
|
this.isReverseRotate = false;
|
|
5239
5290
|
if (shape === 'crop-circle') {
|
|
@@ -5256,37 +5307,141 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
5256
5307
|
this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
|
|
5257
5308
|
this.resetPanPoints();
|
|
5258
5309
|
};
|
|
5259
|
-
ImageEditor.prototype.
|
|
5260
|
-
|
|
5261
|
-
|
|
5262
|
-
|
|
5263
|
-
|
|
5310
|
+
ImageEditor.prototype.getCurrentCropState = function (type, isAllowInvert) {
|
|
5311
|
+
var flipState = '';
|
|
5312
|
+
var state = [];
|
|
5313
|
+
if (type === 'initial') {
|
|
5314
|
+
if (this.degree === 180 || this.degree === -180) {
|
|
5315
|
+
flipState = this.flipColl.length > 1 ? this.getCurrentPanRegion() : this.currFlipState;
|
|
5264
5316
|
}
|
|
5265
|
-
else
|
|
5266
|
-
|
|
5267
|
-
|
|
5317
|
+
else {
|
|
5318
|
+
for (var i = 0; i < this.rotateFlipColl.length; i++) {
|
|
5319
|
+
if (typeof (this.rotateFlipColl[i]) === 'number') {
|
|
5320
|
+
state.push('number');
|
|
5321
|
+
}
|
|
5322
|
+
else if (typeof (this.rotateFlipColl[i]) === 'string') {
|
|
5323
|
+
state.push('string');
|
|
5324
|
+
}
|
|
5325
|
+
}
|
|
5326
|
+
if (state.length > 1 && state[state.length - 1] === 'string' && state[state.length - 2] === 'number') {
|
|
5327
|
+
if (this.currFlipState === 'horizontal') {
|
|
5328
|
+
flipState = 'vertical';
|
|
5329
|
+
}
|
|
5330
|
+
else if (this.currFlipState === 'vertical') {
|
|
5331
|
+
flipState = 'horizontal';
|
|
5332
|
+
}
|
|
5333
|
+
}
|
|
5334
|
+
else if (state.length > 1 && state[state.length - 1] === 'number' && state[state.length - 2] === 'string') {
|
|
5335
|
+
flipState = this.flipColl.length > 1 ? this.getCurrentPanRegion() : this.currFlipState;
|
|
5336
|
+
}
|
|
5268
5337
|
}
|
|
5269
5338
|
}
|
|
5270
5339
|
else {
|
|
5271
|
-
|
|
5272
|
-
|
|
5273
|
-
this.
|
|
5274
|
-
|
|
5275
|
-
|
|
5276
|
-
|
|
5277
|
-
|
|
5340
|
+
flipState = this.getCurrentPanRegion();
|
|
5341
|
+
if (isAllowInvert || !this.isInitialRotate()) {
|
|
5342
|
+
if (this.degree === -90 || this.degree === -270) {
|
|
5343
|
+
if (flipState === 'horizontal') {
|
|
5344
|
+
flipState = 'vertical';
|
|
5345
|
+
}
|
|
5346
|
+
else if (flipState === 'vertical') {
|
|
5347
|
+
flipState = 'horizontal';
|
|
5348
|
+
}
|
|
5349
|
+
}
|
|
5278
5350
|
}
|
|
5279
5351
|
}
|
|
5352
|
+
if (flipState === '') {
|
|
5353
|
+
flipState = this.flipColl.length > 1 ? this.getCurrentPanRegion() : this.currFlipState;
|
|
5354
|
+
}
|
|
5355
|
+
return flipState;
|
|
5280
5356
|
};
|
|
5281
|
-
ImageEditor.prototype.
|
|
5282
|
-
|
|
5283
|
-
|
|
5284
|
-
|
|
5285
|
-
if (!isNullOrUndefined(this.activeObj.activePoint) && !isNullOrUndefined(this.activeObj.shape)) {
|
|
5286
|
-
rotatePanActiveObj = extend({}, this.activeObj, {}, true);
|
|
5357
|
+
ImageEditor.prototype.isInitialRotate = function () {
|
|
5358
|
+
var isRotate = false;
|
|
5359
|
+
if (this.rotateFlipColl.length > 0 && typeof (this.rotateFlipColl[0]) === 'number') {
|
|
5360
|
+
isRotate = true;
|
|
5287
5361
|
}
|
|
5288
|
-
|
|
5362
|
+
return isRotate;
|
|
5363
|
+
};
|
|
5364
|
+
ImageEditor.prototype.updateRotatePanPoints = function () {
|
|
5365
|
+
var panRegion = '';
|
|
5366
|
+
if (this.isInitialRotate() && this.degree < 0) {
|
|
5367
|
+
panRegion = this.getCurrentCropState('reverse', true);
|
|
5368
|
+
}
|
|
5369
|
+
else {
|
|
5370
|
+
panRegion = this.getCurrentPanRegion();
|
|
5371
|
+
}
|
|
5372
|
+
if (this.degree % 90 === 0 && this.degree % 180 !== 0) {
|
|
5373
|
+
if (this.degree === 90 || (this.degree === -90 && (panRegion === 'horizontal' || panRegion === 'vertical'))
|
|
5374
|
+
|| (this.degree === -270 && (panRegion === '' || panRegion === 'verticalHorizontal' || panRegion === 'horizontalVertical'))) {
|
|
5375
|
+
if (panRegion === '') {
|
|
5376
|
+
this.destLeft += this.currentPannedPoint.y;
|
|
5377
|
+
this.destTop -= this.currentPannedPoint.x;
|
|
5378
|
+
}
|
|
5379
|
+
else if (panRegion === 'horizontal') {
|
|
5380
|
+
this.destLeft += this.currentPannedPoint.y;
|
|
5381
|
+
this.destTop += this.currentPannedPoint.x;
|
|
5382
|
+
}
|
|
5383
|
+
else if (panRegion === 'vertical') {
|
|
5384
|
+
this.destLeft -= this.currentPannedPoint.y;
|
|
5385
|
+
this.destTop -= this.currentPannedPoint.x;
|
|
5386
|
+
}
|
|
5387
|
+
else {
|
|
5388
|
+
this.destLeft -= this.currentPannedPoint.y;
|
|
5389
|
+
this.destTop += this.currentPannedPoint.x;
|
|
5390
|
+
}
|
|
5391
|
+
}
|
|
5392
|
+
else if (this.degree === 270 || (this.degree === -270 && (panRegion === 'horizontal' || panRegion === 'vertical'))
|
|
5393
|
+
|| (this.degree === -90 && (panRegion === '' || panRegion === 'verticalHorizontal' || panRegion === 'horizontalVertical'))) {
|
|
5394
|
+
if (panRegion === '') {
|
|
5395
|
+
this.destLeft -= this.currentPannedPoint.y;
|
|
5396
|
+
this.destTop += this.currentPannedPoint.x;
|
|
5397
|
+
}
|
|
5398
|
+
else if (panRegion === 'horizontal') {
|
|
5399
|
+
this.destLeft -= this.currentPannedPoint.y;
|
|
5400
|
+
this.destTop -= this.currentPannedPoint.x;
|
|
5401
|
+
}
|
|
5402
|
+
else if (panRegion === 'vertical') {
|
|
5403
|
+
this.destLeft += this.currentPannedPoint.y;
|
|
5404
|
+
this.destTop += this.currentPannedPoint.x;
|
|
5405
|
+
}
|
|
5406
|
+
else {
|
|
5407
|
+
this.destLeft += this.currentPannedPoint.y;
|
|
5408
|
+
this.destTop -= this.currentPannedPoint.x;
|
|
5409
|
+
}
|
|
5410
|
+
}
|
|
5411
|
+
}
|
|
5412
|
+
else {
|
|
5413
|
+
if (this.degree === 180 || this.degree === -180) {
|
|
5414
|
+
if (panRegion === '') {
|
|
5415
|
+
this.destLeft -= this.currentPannedPoint.x;
|
|
5416
|
+
this.destTop -= this.currentPannedPoint.y;
|
|
5417
|
+
}
|
|
5418
|
+
else if (panRegion === 'horizontal') {
|
|
5419
|
+
this.destLeft += this.currentPannedPoint.x;
|
|
5420
|
+
this.destTop -= this.currentPannedPoint.y;
|
|
5421
|
+
}
|
|
5422
|
+
else if (panRegion === 'vertical') {
|
|
5423
|
+
this.destLeft -= this.currentPannedPoint.x;
|
|
5424
|
+
this.destTop += this.currentPannedPoint.y;
|
|
5425
|
+
}
|
|
5426
|
+
else {
|
|
5427
|
+
this.destLeft += this.currentPannedPoint.x;
|
|
5428
|
+
this.destTop += this.currentPannedPoint.y;
|
|
5429
|
+
}
|
|
5430
|
+
}
|
|
5431
|
+
}
|
|
5432
|
+
};
|
|
5433
|
+
ImageEditor.prototype.rotatePan = function (isCropSelection, isDefaultZoom) {
|
|
5434
|
+
this.isReverseRotate = true;
|
|
5435
|
+
var tempDegree = this.degree;
|
|
5436
|
+
var rotatePanActiveObj;
|
|
5437
|
+
if (!isNullOrUndefined(this.activeObj.activePoint) && !isNullOrUndefined(this.activeObj.shape)) {
|
|
5438
|
+
rotatePanActiveObj = extend({}, this.activeObj, {}, true);
|
|
5439
|
+
}
|
|
5440
|
+
var tempObjColl = extend([], this.objColl, [], true);
|
|
5441
|
+
var tempPointColl = extend([], this.pointColl, [], true);
|
|
5289
5442
|
this.objColl = [];
|
|
5443
|
+
this.pointColl = [];
|
|
5444
|
+
this.freehandCounter = 0;
|
|
5290
5445
|
this.refreshActiveObj();
|
|
5291
5446
|
this.isRotateZoom = true;
|
|
5292
5447
|
this.updateCurrentTransformedState('initial');
|
|
@@ -5315,15 +5470,25 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
5315
5470
|
this.totalPannedClientPoint.x = this.destLeft - destLeft;
|
|
5316
5471
|
this.totalPannedClientPoint.y = this.destTop - destTop;
|
|
5317
5472
|
this.objColl = tempObjColl;
|
|
5473
|
+
this.pointColl = tempPointColl;
|
|
5474
|
+
this.freehandCounter = this.pointColl.length;
|
|
5318
5475
|
this.degree = tempDegree;
|
|
5319
|
-
this.objColl = extend([], tempObjColl, [], true);
|
|
5320
5476
|
this.lowerContext.filter = 'none';
|
|
5321
|
-
var panRegion = this.getCurrentPanRegion();
|
|
5322
5477
|
if (isCropSelection) {
|
|
5323
|
-
|
|
5478
|
+
if (isDefaultZoom) {
|
|
5479
|
+
this.totalPannedClientPoint.x = -this.totalPannedClientPoint.x;
|
|
5480
|
+
this.totalPannedClientPoint.y = -this.totalPannedClientPoint.y;
|
|
5481
|
+
this.currentPannedPoint = extend({}, this.totalPannedClientPoint, {}, true);
|
|
5482
|
+
this.totalPannedClientPoint = { x: 0, y: 0 };
|
|
5483
|
+
this.destLeft += this.currentPannedPoint.x;
|
|
5484
|
+
this.destTop += this.currentPannedPoint.y;
|
|
5485
|
+
}
|
|
5486
|
+
else {
|
|
5487
|
+
this.currentPannedPoint = extend({}, this.totalPannedClientPoint, {}, true);
|
|
5488
|
+
}
|
|
5324
5489
|
}
|
|
5325
|
-
this.panObjColl(this.currentPannedPoint.x, this.currentPannedPoint.y,
|
|
5326
|
-
this.panFreehandDrawColl(this.currentPannedPoint.x, this.currentPannedPoint.y,
|
|
5490
|
+
this.panObjColl(this.currentPannedPoint.x, this.currentPannedPoint.y, '');
|
|
5491
|
+
this.panFreehandDrawColl(this.currentPannedPoint.x, this.currentPannedPoint.y, '');
|
|
5327
5492
|
this.lowerContext.filter = temp;
|
|
5328
5493
|
this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
|
|
5329
5494
|
this.activeObj = extend({}, rotatePanActiveObj, {}, true);
|
|
@@ -5371,7 +5536,7 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
5371
5536
|
this.zoomFactor += value;
|
|
5372
5537
|
}
|
|
5373
5538
|
if (this.isCropTab) {
|
|
5374
|
-
this.cropZoomFactor
|
|
5539
|
+
this.cropZoomFactor = this.zoomFactor;
|
|
5375
5540
|
}
|
|
5376
5541
|
else {
|
|
5377
5542
|
this.defaultZoomFactor = this.zoomFactor;
|
|
@@ -5413,18 +5578,32 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
5413
5578
|
}
|
|
5414
5579
|
this.destLeft = destLeft - ((maxDimension.width - this.destWidth) / 2);
|
|
5415
5580
|
this.destTop = destTop - ((maxDimension.height - this.destHeight) / 2);
|
|
5581
|
+
destLeft = this.destLeft;
|
|
5582
|
+
destTop = this.destTop;
|
|
5416
5583
|
if (!isNullOrUndefined(selectionObj)) {
|
|
5417
5584
|
if (this.destLeft > selectionObj.activePoint.startX) {
|
|
5418
5585
|
this.destLeft = selectionObj.activePoint.startX;
|
|
5586
|
+
if (this.degree === 0) {
|
|
5587
|
+
this.totalPannedPoint.x -= (destLeft - this.destLeft);
|
|
5588
|
+
}
|
|
5419
5589
|
}
|
|
5420
5590
|
if (this.destTop > selectionObj.activePoint.startY) {
|
|
5421
5591
|
this.destTop = selectionObj.activePoint.startY;
|
|
5592
|
+
if (this.degree === 0) {
|
|
5593
|
+
this.totalPannedPoint.y -= (destTop - this.destTop);
|
|
5594
|
+
}
|
|
5422
5595
|
}
|
|
5423
5596
|
if (this.destLeft + maxDimension.width < selectionObj.activePoint.endX) {
|
|
5424
5597
|
this.destLeft = selectionObj.activePoint.endX - maxDimension.width;
|
|
5598
|
+
if (this.degree === 0) {
|
|
5599
|
+
this.totalPannedPoint.x -= (destLeft - this.destLeft);
|
|
5600
|
+
}
|
|
5425
5601
|
}
|
|
5426
5602
|
if (this.destTop + maxDimension.height < selectionObj.activePoint.endY) {
|
|
5427
5603
|
this.destTop = selectionObj.activePoint.endY - maxDimension.height;
|
|
5604
|
+
if (this.degree === 0) {
|
|
5605
|
+
this.totalPannedPoint.y -= (destTop - this.destTop);
|
|
5606
|
+
}
|
|
5428
5607
|
}
|
|
5429
5608
|
}
|
|
5430
5609
|
return maxDimension;
|
|
@@ -5646,11 +5825,44 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
5646
5825
|
this.degree = 0;
|
|
5647
5826
|
}
|
|
5648
5827
|
};
|
|
5649
|
-
ImageEditor.prototype.
|
|
5650
|
-
|
|
5828
|
+
ImageEditor.prototype.getCurrentObj = function () {
|
|
5829
|
+
var obj = { cropZoom: 0, defaultZoom: 0, totalPannedPoint: { x: 0, y: 0 }, totalPannedClientPoint: { x: 0, y: 0 },
|
|
5830
|
+
totalPannedInternalPoint: { x: 0, y: 0 }, tempFlipPanPoint: { x: 0, y: 0 }, activeObj: {},
|
|
5831
|
+
rotateFlipColl: [], degree: 0, currFlipState: '',
|
|
5832
|
+
destPoints: { startX: 0, startY: 0, width: 0, height: 0 },
|
|
5833
|
+
srcPoints: { startX: 0, startY: 0, width: 0, height: 0 }, filter: '' };
|
|
5834
|
+
obj.cropZoom = this.cropZoomFactor;
|
|
5835
|
+
obj.defaultZoom = this.defaultZoomFactor;
|
|
5836
|
+
obj.totalPannedPoint = extend({}, this.totalPannedPoint, {}, true);
|
|
5837
|
+
obj.totalPannedClientPoint = extend({}, this.totalPannedClientPoint, {}, true);
|
|
5838
|
+
obj.totalPannedInternalPoint = extend({}, this.totalPannedInternalPoint, {}, true);
|
|
5839
|
+
obj.tempFlipPanPoint = extend({}, this.tempFlipPanPoint, {}, true);
|
|
5840
|
+
obj.activeObj = extend({}, this.activeObj, {}, true);
|
|
5841
|
+
obj.rotateFlipColl = extend([], this.rotateFlipColl, [], true);
|
|
5842
|
+
obj.degree = this.degree;
|
|
5843
|
+
obj.currFlipState = this.currFlipState;
|
|
5844
|
+
obj.destPoints = { startX: this.destLeft, startY: this.destTop, endX: 0, endY: 0,
|
|
5845
|
+
width: this.destWidth, height: this.destHeight };
|
|
5846
|
+
obj.srcPoints = { startX: this.srcLeft, startY: this.srcTop, endX: 0, endY: 0,
|
|
5847
|
+
width: this.srcWidth, height: this.srcHeight };
|
|
5848
|
+
obj.filter = this.lowerContext.filter;
|
|
5849
|
+
return obj;
|
|
5850
|
+
};
|
|
5851
|
+
ImageEditor.prototype.updateUndoRedoColl = function (operation, previousObj, previousObjColl, previousPointColl, previousCropObj, previousText, currentText, previousFilter) {
|
|
5852
|
+
if (!this.isInitialLoading && this.allowUndoRedo) {
|
|
5853
|
+
if (this.currObjType.isUndoAction) {
|
|
5854
|
+
this.refreshUndoRedoColl();
|
|
5855
|
+
}
|
|
5651
5856
|
this.undoRedoStep++;
|
|
5652
|
-
this.
|
|
5653
|
-
|
|
5857
|
+
var currentObj = this.getCurrentObj();
|
|
5858
|
+
currentObj.objColl = extend([], this.objColl, [], true);
|
|
5859
|
+
currentObj.pointColl = extend([], this.pointColl, [], true);
|
|
5860
|
+
currentObj.afterCropActions = extend([], this.afterCropActions, [], true);
|
|
5861
|
+
this.undoRedoColl.push({ operation: operation, previousObj: previousObj, currentObj: currentObj,
|
|
5862
|
+
previousObjColl: previousObjColl, currentObjColl: currentObj.objColl,
|
|
5863
|
+
previousPointColl: previousPointColl, currentPointColl: currentObj.pointColl,
|
|
5864
|
+
previousCropObj: previousCropObj, currentCropObj: extend({}, this.cropObj, {}, true),
|
|
5865
|
+
previousText: previousText, currentText: currentText, filter: previousFilter });
|
|
5654
5866
|
if (this.undoRedoColl.length > 16) {
|
|
5655
5867
|
this.undoRedoColl.splice(0, 1);
|
|
5656
5868
|
this.undoRedoStep--;
|
|
@@ -5925,6 +6137,7 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
5925
6137
|
}
|
|
5926
6138
|
this.freehandDrawSelectedIndex = this.freehandDrawHoveredIndex;
|
|
5927
6139
|
this.pointColl[this.freehandDrawSelectedIndex].isSelected = true;
|
|
6140
|
+
this.freehandDrawSelectedId = this.pointColl[this.freehandDrawSelectedIndex].id;
|
|
5928
6141
|
if (this.pointColl[this.freehandDrawHoveredIndex].strokeColor !== '#42a5f5') {
|
|
5929
6142
|
this.tempFreeHandDrawEditingStyles.strokeColor = this.pointColl[this.freehandDrawHoveredIndex].strokeColor;
|
|
5930
6143
|
}
|
|
@@ -6217,15 +6430,16 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
6217
6430
|
}
|
|
6218
6431
|
if (e.currentTarget === this.upperCanvas) {
|
|
6219
6432
|
this.currObjType.shape = this.currObjType.shape.toLowerCase();
|
|
6220
|
-
|
|
6433
|
+
var prevCropObj = extend({}, this.cropObj, {}, true);
|
|
6434
|
+
var prevObj = this.getCurrentObj();
|
|
6435
|
+
prevObj.objColl = extend([], this.objColl, [], true);
|
|
6436
|
+
prevObj.pointColl = extend([], this.pointColl, [], true);
|
|
6437
|
+
prevObj.afterCropActions = extend([], this.afterCropActions, [], true);
|
|
6438
|
+
if (!this.togglePen && !isCropSelection) {
|
|
6221
6439
|
if (!isNullOrUndefined(this.tempObjColl) && this.activeObj.activePoint.width !== 0) {
|
|
6222
6440
|
this.objColl.push(this.activeObj);
|
|
6223
6441
|
if (JSON.stringify(this.activeObj.activePoint) !== JSON.stringify(this.tempActiveObj.activePoint)) {
|
|
6224
|
-
this.
|
|
6225
|
-
currentObj: extend([], this.objColl, [], true),
|
|
6226
|
-
previousObj: this.tempObjColl, zoomFactor: this.zoomFactor,
|
|
6227
|
-
sharpen: this.adjustmentLevel.sharpen, bw: this.adjustmentLevel.bw });
|
|
6228
|
-
this.undoRedoStep++;
|
|
6442
|
+
this.updateUndoRedoColl('shapeTransform', prevObj, this.tempObjColl, prevObj.pointColl, prevCropObj);
|
|
6229
6443
|
}
|
|
6230
6444
|
this.redrawShape(this.objColl[this.objColl.length - 1]);
|
|
6231
6445
|
this.tempObjColl = undefined;
|
|
@@ -6236,13 +6450,8 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
6236
6450
|
}
|
|
6237
6451
|
else if (isCropSelection && !this.togglePen) {
|
|
6238
6452
|
if (JSON.stringify(this.activeObj.activePoint) !== JSON.stringify(this.tempActiveObj.activePoint)) {
|
|
6239
|
-
|
|
6240
|
-
|
|
6241
|
-
previousObj: this.objColl, zoomFactor: this.zoomFactor,
|
|
6242
|
-
currentSelectionObj: extend([], this.activeObj, {}, true),
|
|
6243
|
-
previousSelectionObj: extend([], this.tempActiveObj, {}, true),
|
|
6244
|
-
sharpen: this.adjustmentLevel.sharpen, bw: this.adjustmentLevel.bw });
|
|
6245
|
-
this.undoRedoStep++;
|
|
6453
|
+
prevObj.activeObj = extend([], this.tempActiveObj, {}, true);
|
|
6454
|
+
this.updateUndoRedoColl('selectionTransform', prevObj, prevObj.objColl, prevObj.pointColl, prevCropObj);
|
|
6246
6455
|
}
|
|
6247
6456
|
}
|
|
6248
6457
|
}
|
|
@@ -6273,27 +6482,34 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
6273
6482
|
e.preventDefault();
|
|
6274
6483
|
e.stopImmediatePropagation();
|
|
6275
6484
|
break;
|
|
6276
|
-
case (e.ctrlKey && 'z'):
|
|
6277
|
-
|
|
6278
|
-
|
|
6279
|
-
|
|
6280
|
-
|
|
6281
|
-
case (e.ctrlKey && 'y'):
|
|
6282
|
-
|
|
6283
|
-
|
|
6284
|
-
|
|
6285
|
-
|
|
6485
|
+
// case (e.ctrlKey && 'z'):
|
|
6486
|
+
// if (this.allowUndoRedo) {
|
|
6487
|
+
// this.callUndo();
|
|
6488
|
+
// }
|
|
6489
|
+
// break;
|
|
6490
|
+
// case (e.ctrlKey && 'y'):
|
|
6491
|
+
// if (this.allowUndoRedo) {
|
|
6492
|
+
// this.callRedo();
|
|
6493
|
+
// }
|
|
6494
|
+
// break;
|
|
6286
6495
|
case 'Delete':
|
|
6287
6496
|
if (this.isFreehandDrawEditing) {
|
|
6288
6497
|
this.updateFreehandDrawColorChange();
|
|
6289
|
-
|
|
6290
|
-
var
|
|
6291
|
-
|
|
6292
|
-
|
|
6498
|
+
var prevCropObj = extend({}, this.cropObj, {}, true);
|
|
6499
|
+
var prevObj = this.getCurrentObj();
|
|
6500
|
+
prevObj.objColl = extend([], this.objColl, [], true);
|
|
6501
|
+
prevObj.pointColl = extend([], this.pointColl, [], true);
|
|
6502
|
+
prevObj.afterCropActions = extend([], this.afterCropActions, [], true);
|
|
6503
|
+
this.deleteFreehandDraw(parseInt(this.freehandDrawSelectedId.split('_')[1], 10) - 1, true);
|
|
6504
|
+
this.updateUndoRedoColl('deleteFreehandDrawing', prevObj, prevObj.objColl, prevObj.pointColl, prevCropObj);
|
|
6293
6505
|
}
|
|
6294
6506
|
else if (this.textArea.style.display === 'none') {
|
|
6295
6507
|
this.objColl.push(this.activeObj);
|
|
6296
|
-
var
|
|
6508
|
+
var prevCropObj = extend({}, this.cropObj, {}, true);
|
|
6509
|
+
var prevObj = this.getCurrentObj();
|
|
6510
|
+
prevObj.objColl = extend([], this.objColl, [], true);
|
|
6511
|
+
prevObj.pointColl = extend([], this.pointColl, [], true);
|
|
6512
|
+
prevObj.afterCropActions = extend([], this.afterCropActions, [], true);
|
|
6297
6513
|
this.objColl.pop();
|
|
6298
6514
|
previousShapeSettings = this.updatePreviousShapeSettings();
|
|
6299
6515
|
shapeChangingArgs = { action: 'delete', previousShapeSettings: previousShapeSettings, currentShapeSettings: null };
|
|
@@ -6301,7 +6517,7 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
6301
6517
|
this.clearSelection();
|
|
6302
6518
|
this.trigger('shapeChanging', shapeChangingArgs);
|
|
6303
6519
|
this.refreshToolbar('main');
|
|
6304
|
-
this.updateUndoRedoColl('
|
|
6520
|
+
this.updateUndoRedoColl('deleteObj', prevObj, prevObj.objColl, prevObj.pointColl, prevCropObj);
|
|
6305
6521
|
}
|
|
6306
6522
|
break;
|
|
6307
6523
|
case 'Escape':
|
|
@@ -6356,6 +6572,10 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
6356
6572
|
this.lastPan = { x: this.destLeft, y: this.destTop };
|
|
6357
6573
|
if (isNullOrUndefined(this.tempPanMove)) {
|
|
6358
6574
|
this.tempPanMove = { x: x, y: y };
|
|
6575
|
+
this.panStartObj = this.getCurrentObj();
|
|
6576
|
+
this.panStartObj.objColl = extend([], this.objColl, [], true);
|
|
6577
|
+
this.panStartObj.pointColl = extend([], this.pointColl, [], true);
|
|
6578
|
+
this.panStartObj.afterCropActions = this.afterCropActions;
|
|
6359
6579
|
}
|
|
6360
6580
|
};
|
|
6361
6581
|
ImageEditor.prototype.canvasMouseMoveHandler = function (e) {
|
|
@@ -6388,10 +6608,12 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
6388
6608
|
e.preventDefault();
|
|
6389
6609
|
if (this.togglePan) {
|
|
6390
6610
|
if (this.panDown && this.panMove && this.togglePan && this.dragCanvas) {
|
|
6611
|
+
var prevCropObj = extend({}, this.cropObj, {}, true);
|
|
6612
|
+
this.updateUndoRedoColl('pan', this.panStartObj, this.panStartObj.objColl, this.panStartObj.pointColl, prevCropObj);
|
|
6391
6613
|
this.panDown = null;
|
|
6392
6614
|
this.panMove = null;
|
|
6393
6615
|
this.tempPanMove = null;
|
|
6394
|
-
this.
|
|
6616
|
+
this.panStartObj = null;
|
|
6395
6617
|
}
|
|
6396
6618
|
}
|
|
6397
6619
|
this.currObjType.isDragging = false;
|
|
@@ -6704,7 +6926,12 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
6704
6926
|
};
|
|
6705
6927
|
ImageEditor.prototype.updateTextFromTextArea = function () {
|
|
6706
6928
|
if (this.activeObj.keyHistory !== this.textArea.value) {
|
|
6707
|
-
|
|
6929
|
+
var prevCropObj = extend({}, this.cropObj, {}, true);
|
|
6930
|
+
var prevObj = this.getCurrentObj();
|
|
6931
|
+
prevObj.objColl = extend([], this.objColl, [], true);
|
|
6932
|
+
prevObj.pointColl = extend([], this.pointColl, [], true);
|
|
6933
|
+
prevObj.afterCropActions = extend([], this.afterCropActions, [], true);
|
|
6934
|
+
this.updateUndoRedoColl('text', prevObj, prevObj.objColl, prevObj.pointColl, prevCropObj, this.activeObj.keyHistory, this.textArea.value);
|
|
6708
6935
|
}
|
|
6709
6936
|
this.activeObj.keyHistory = this.textArea.value;
|
|
6710
6937
|
this.textArea.style.display = 'none';
|
|
@@ -6985,7 +7212,6 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
6985
7212
|
this.refreshActiveObj();
|
|
6986
7213
|
this.lowerContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
|
|
6987
7214
|
this.redrawImgWithObj();
|
|
6988
|
-
//this.zoomFreehandDrawColl();
|
|
6989
7215
|
if ((!isNullOrUndefined(this.currSelectionPoint) && this.currSelectionPoint.shape === 'crop-circle') || this.isCircleCrop) {
|
|
6990
7216
|
this.cropCircle(this.lowerContext);
|
|
6991
7217
|
}
|
|
@@ -8189,6 +8415,7 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
8189
8415
|
this.activeObj = extend({}, tempObj, {}, true);
|
|
8190
8416
|
};
|
|
8191
8417
|
ImageEditor.prototype.drawObject = function (canvas, obj, isCropRatio, points, isPreventDrag, saveContext) {
|
|
8418
|
+
this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
|
|
8192
8419
|
var canvasDraw;
|
|
8193
8420
|
if (canvas.toLowerCase() === 'original') {
|
|
8194
8421
|
canvasDraw = this.lowerContext;
|
|
@@ -9939,28 +10166,6 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
9939
10166
|
height: this.destHeight / this.objColl[i].activePoint.height };
|
|
9940
10167
|
}
|
|
9941
10168
|
};
|
|
9942
|
-
ImageEditor.prototype.setTextFontSize = function (obj) {
|
|
9943
|
-
if (obj.shape === 'text') {
|
|
9944
|
-
var maxText = this.getMaxText(null, obj.keyHistory);
|
|
9945
|
-
var degree = void 0;
|
|
9946
|
-
if (obj.shapeDegree === 0) {
|
|
9947
|
-
degree = this.degree;
|
|
9948
|
-
}
|
|
9949
|
-
else {
|
|
9950
|
-
degree = this.degree - obj.shapeDegree;
|
|
9951
|
-
}
|
|
9952
|
-
var multiplier = 2;
|
|
9953
|
-
if (maxText.length === 1) {
|
|
9954
|
-
multiplier = 1;
|
|
9955
|
-
}
|
|
9956
|
-
if (degree === 0 || degree === 180 || degree === -180) {
|
|
9957
|
-
obj.textSettings.fontSize = (obj.activePoint.width / maxText.length) * multiplier;
|
|
9958
|
-
}
|
|
9959
|
-
else {
|
|
9960
|
-
obj.textSettings.fontSize = (obj.activePoint.height / maxText.length) * multiplier;
|
|
9961
|
-
}
|
|
9962
|
-
}
|
|
9963
|
-
};
|
|
9964
10169
|
ImageEditor.prototype.redrawShape = function (obj) {
|
|
9965
10170
|
for (var i = 0; i < this.objColl.length; i++) {
|
|
9966
10171
|
if (JSON.stringify(obj) === JSON.stringify(this.objColl[i])) {
|
|
@@ -10161,7 +10366,10 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
10161
10366
|
}
|
|
10162
10367
|
this.togglePen = false;
|
|
10163
10368
|
this.redrawActObj();
|
|
10164
|
-
var
|
|
10369
|
+
var prevObj = this.getCurrentObj();
|
|
10370
|
+
prevObj.objColl = extend([], this.objColl, [], true);
|
|
10371
|
+
prevObj.pointColl = extend([], this.pointColl, [], true);
|
|
10372
|
+
prevObj.afterCropActions = extend([], this.afterCropActions, [], true);
|
|
10165
10373
|
this.keyHistory = '';
|
|
10166
10374
|
this.refreshActiveObj();
|
|
10167
10375
|
this.activeObj.shape = 'text';
|
|
@@ -10225,10 +10433,8 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
10225
10433
|
this.activeObj.textFlip = this.currFlipState;
|
|
10226
10434
|
this.updateFontRatio(this.activeObj);
|
|
10227
10435
|
this.objColl.push(this.activeObj);
|
|
10228
|
-
|
|
10229
|
-
|
|
10230
|
-
sharpen: this.adjustmentLevel.sharpen, bw: this.adjustmentLevel.bw });
|
|
10231
|
-
this.undoRedoStep++;
|
|
10436
|
+
var prevCropObj = extend({}, this.cropObj, {}, true);
|
|
10437
|
+
this.updateUndoRedoColl('shapeTransform', prevObj, prevObj.objColl, prevObj.pointColl, prevCropObj);
|
|
10232
10438
|
this.redrawShape(this.objColl[this.objColl.length - 1]);
|
|
10233
10439
|
this.isShapeInserted = true;
|
|
10234
10440
|
this.refreshToolbar('text');
|
|
@@ -10373,6 +10579,43 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
10373
10579
|
}
|
|
10374
10580
|
}
|
|
10375
10581
|
this.freehandRedraw(this.lowerContext);
|
|
10582
|
+
this.updateCurrSelectionPoint(degree);
|
|
10583
|
+
};
|
|
10584
|
+
ImageEditor.prototype.updateCurrSelectionPoint = function (degree) {
|
|
10585
|
+
if (!isNullOrUndefined(this.currSelectionPoint) && !isNullOrUndefined(this.currDestinationPoint)) {
|
|
10586
|
+
var activeObj = extend({}, this.activeObj, {}, true);
|
|
10587
|
+
var objColl = extend([], this.objColl, [], true);
|
|
10588
|
+
var srcPoints = { startX: this.srcLeft, startY: this.srcTop, width: this.srcWidth, height: this.srcHeight };
|
|
10589
|
+
var destPoints = { startX: this.destLeft, startY: this.destTop, width: this.destWidth, height: this.destHeight };
|
|
10590
|
+
this.objColl = [];
|
|
10591
|
+
this.objColl.push(extend({}, this.currSelectionPoint, {}, true));
|
|
10592
|
+
this.srcLeft = 0;
|
|
10593
|
+
this.srcTop = 0;
|
|
10594
|
+
this.srcWidth = this.baseImg.width;
|
|
10595
|
+
this.srcHeight = this.baseImg.height;
|
|
10596
|
+
this.destLeft = this.currDestinationPoint.startX;
|
|
10597
|
+
this.destTop = this.currDestinationPoint.startY;
|
|
10598
|
+
this.destWidth = this.currDestinationPoint.width;
|
|
10599
|
+
this.destHeight = this.currDestinationPoint.height;
|
|
10600
|
+
if (typeof (degree) === 'number') {
|
|
10601
|
+
this.setDestinationPoints();
|
|
10602
|
+
this.setClientTransformedDimension();
|
|
10603
|
+
}
|
|
10604
|
+
this.objColl[0].shapeFlip = '';
|
|
10605
|
+
this.redrawObj(degree);
|
|
10606
|
+
this.currSelectionPoint = extend({}, this.objColl[0], {}, true);
|
|
10607
|
+
this.currDestinationPoint = { startX: this.destLeft, startY: this.destTop, width: this.destWidth, height: this.destHeight };
|
|
10608
|
+
this.objColl = objColl;
|
|
10609
|
+
this.activeObj = activeObj;
|
|
10610
|
+
this.srcLeft = srcPoints.startX;
|
|
10611
|
+
this.srcTop = srcPoints.startY;
|
|
10612
|
+
this.srcWidth = srcPoints.width;
|
|
10613
|
+
this.srcHeight = srcPoints.height;
|
|
10614
|
+
this.destLeft = destPoints.startX;
|
|
10615
|
+
this.destTop = destPoints.startY;
|
|
10616
|
+
this.destWidth = destPoints.width;
|
|
10617
|
+
this.destHeight = destPoints.height;
|
|
10618
|
+
}
|
|
10376
10619
|
};
|
|
10377
10620
|
ImageEditor.prototype.setClientTransformedDimension = function (isPreventDimension) {
|
|
10378
10621
|
if (this.degree % 90 === 0 && this.degree % 180 !== 0) {
|
|
@@ -10389,100 +10632,110 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
10389
10632
|
}
|
|
10390
10633
|
}
|
|
10391
10634
|
};
|
|
10392
|
-
ImageEditor.prototype.popForDefaultTransformedState = function () {
|
|
10635
|
+
ImageEditor.prototype.popForDefaultTransformedState = function (collection) {
|
|
10393
10636
|
var rotateRight = 0;
|
|
10394
10637
|
var rotateleft = 0;
|
|
10395
10638
|
var horizontal = 0;
|
|
10396
10639
|
var vertical = 0;
|
|
10397
|
-
for (var i = 0; i <
|
|
10398
|
-
if (
|
|
10640
|
+
for (var i = 0; i < collection.length; i++) {
|
|
10641
|
+
if (collection[i] === 90 || collection[i] === 'rotateRight') {
|
|
10399
10642
|
rotateRight++;
|
|
10400
10643
|
rotateleft = 0;
|
|
10401
10644
|
horizontal = 0;
|
|
10402
10645
|
vertical = 0;
|
|
10403
10646
|
if (rotateRight === 4) {
|
|
10404
|
-
|
|
10405
|
-
|
|
10406
|
-
|
|
10407
|
-
|
|
10647
|
+
collection.pop();
|
|
10648
|
+
collection.pop();
|
|
10649
|
+
collection.pop();
|
|
10650
|
+
collection.pop();
|
|
10408
10651
|
}
|
|
10409
10652
|
}
|
|
10410
|
-
else if (
|
|
10653
|
+
else if (collection[i] === -90 || collection[i] === 'rotateLeft') {
|
|
10411
10654
|
rotateleft++;
|
|
10412
10655
|
rotateRight = 0;
|
|
10413
10656
|
horizontal = 0;
|
|
10414
10657
|
vertical = 0;
|
|
10415
10658
|
if (rotateleft === 4) {
|
|
10416
|
-
|
|
10417
|
-
|
|
10418
|
-
|
|
10419
|
-
|
|
10659
|
+
collection.pop();
|
|
10660
|
+
collection.pop();
|
|
10661
|
+
collection.pop();
|
|
10662
|
+
collection.pop();
|
|
10420
10663
|
}
|
|
10421
10664
|
}
|
|
10422
|
-
else if (
|
|
10665
|
+
else if (collection[i] === 'horizontal' || collection[i] === 'horizontalflip') {
|
|
10423
10666
|
horizontal++;
|
|
10424
10667
|
rotateleft = 0;
|
|
10425
10668
|
rotateRight = 0;
|
|
10426
10669
|
vertical = 0;
|
|
10427
10670
|
if (horizontal === 2) {
|
|
10428
|
-
|
|
10429
|
-
|
|
10671
|
+
collection.pop();
|
|
10672
|
+
collection.pop();
|
|
10430
10673
|
}
|
|
10431
10674
|
}
|
|
10432
|
-
else if (
|
|
10675
|
+
else if (collection[i] === 'vertical' || collection[i] === 'verticalflip') {
|
|
10433
10676
|
vertical++;
|
|
10434
10677
|
horizontal = 0;
|
|
10435
10678
|
rotateleft = 0;
|
|
10436
10679
|
rotateRight = 0;
|
|
10437
10680
|
if (vertical === 2) {
|
|
10438
|
-
|
|
10439
|
-
|
|
10681
|
+
collection.pop();
|
|
10682
|
+
collection.pop();
|
|
10440
10683
|
}
|
|
10441
10684
|
}
|
|
10442
10685
|
}
|
|
10686
|
+
return collection;
|
|
10443
10687
|
};
|
|
10444
|
-
ImageEditor.prototype.popForDefaultFlipState = function () {
|
|
10445
|
-
for (var i = 0; i <
|
|
10446
|
-
if (!isNullOrUndefined(
|
|
10447
|
-
if (
|
|
10448
|
-
|
|
10449
|
-
|
|
10450
|
-
|
|
10451
|
-
|
|
10452
|
-
|
|
10688
|
+
ImageEditor.prototype.popForDefaultFlipState = function (collection) {
|
|
10689
|
+
for (var i = 0; i < collection.length; i++) {
|
|
10690
|
+
if (!isNullOrUndefined(collection[i + 3])) {
|
|
10691
|
+
if ((collection[i] === 'horizontal' || collection[i] === 'horizontalFlip')
|
|
10692
|
+
&& (collection[i + 1] === 'vertical' || collection[i] === 'verticalFlip') &&
|
|
10693
|
+
(collection[i + 2] === 'horizontal' || collection[i] === 'horizontalFlip') &&
|
|
10694
|
+
(collection[i + 3] === 'vertical' || collection[i] === 'verticalFlip')) {
|
|
10695
|
+
collection.pop();
|
|
10696
|
+
collection.pop();
|
|
10697
|
+
collection.pop();
|
|
10698
|
+
collection.pop();
|
|
10453
10699
|
}
|
|
10454
|
-
else if (
|
|
10455
|
-
|
|
10456
|
-
|
|
10457
|
-
|
|
10458
|
-
|
|
10459
|
-
|
|
10700
|
+
else if ((collection[i] === 'vertical' || collection[i] === 'verticalFlip')
|
|
10701
|
+
&& (collection[i + 1] === 'horizontal' || collection[i + 1] === 'horizontalFlip') &&
|
|
10702
|
+
(collection[i + 2] === 'vertical' || collection[i] === 'verticalFlip') &&
|
|
10703
|
+
(collection[i + 3] === 'horizontal' || collection[i] === 'horizontalFlip')) {
|
|
10704
|
+
collection.pop();
|
|
10705
|
+
collection.pop();
|
|
10706
|
+
collection.pop();
|
|
10707
|
+
collection.pop();
|
|
10460
10708
|
}
|
|
10461
10709
|
}
|
|
10462
10710
|
}
|
|
10711
|
+
return collection;
|
|
10463
10712
|
};
|
|
10464
|
-
ImageEditor.prototype.popForDefaultRotateState = function () {
|
|
10465
|
-
for (var i = 0; i <
|
|
10466
|
-
if (!isNullOrUndefined(
|
|
10467
|
-
if (
|
|
10468
|
-
|
|
10469
|
-
|
|
10713
|
+
ImageEditor.prototype.popForDefaultRotateState = function (collection) {
|
|
10714
|
+
for (var i = 0; i < collection.length; i++) {
|
|
10715
|
+
if (!isNullOrUndefined(collection[i + 1])) {
|
|
10716
|
+
if ((collection[i] === 90 || collection[i] === 'rotateRight') &&
|
|
10717
|
+
(collection[i + 1] === -90 || collection[i] === 'rotateLeft')) {
|
|
10718
|
+
collection.pop();
|
|
10719
|
+
collection.pop();
|
|
10470
10720
|
}
|
|
10471
|
-
else if (
|
|
10472
|
-
|
|
10473
|
-
|
|
10721
|
+
else if ((collection[i] === -90 || collection[i] === 'rotateLeft') &&
|
|
10722
|
+
(collection[i + 1] === 90 || collection[i] === 'rotateRight')) {
|
|
10723
|
+
collection.pop();
|
|
10724
|
+
collection.pop();
|
|
10474
10725
|
}
|
|
10475
10726
|
}
|
|
10476
10727
|
}
|
|
10728
|
+
return collection;
|
|
10477
10729
|
};
|
|
10478
|
-
ImageEditor.prototype.alignRotateFlipColl = function () {
|
|
10479
|
-
this.popForDefaultTransformedState();
|
|
10480
|
-
this.popForDefaultFlipState();
|
|
10481
|
-
this.popForDefaultRotateState();
|
|
10482
|
-
if (
|
|
10730
|
+
ImageEditor.prototype.alignRotateFlipColl = function (collection, isRotateFlipCollection) {
|
|
10731
|
+
collection = this.popForDefaultTransformedState(collection);
|
|
10732
|
+
collection = this.popForDefaultFlipState(collection);
|
|
10733
|
+
collection = this.popForDefaultRotateState(collection);
|
|
10734
|
+
if (collection.length === 0 && isRotateFlipCollection) {
|
|
10483
10735
|
this.degree = 0;
|
|
10484
10736
|
this.currFlipState = '';
|
|
10485
10737
|
}
|
|
10738
|
+
return collection;
|
|
10486
10739
|
};
|
|
10487
10740
|
ImageEditor.prototype.updateFlipColl = function (direction) {
|
|
10488
10741
|
if (this.flipColl.length === 0) {
|
|
@@ -10653,35 +10906,51 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
10653
10906
|
this.applyPenDraw();
|
|
10654
10907
|
this.adjustmentLevel.brightness = value;
|
|
10655
10908
|
value = this.getFilterValue(value);
|
|
10656
|
-
var
|
|
10909
|
+
var prevCropObj = extend({}, this.cropObj, {}, true);
|
|
10910
|
+
var prevObj = this.getCurrentObj();
|
|
10911
|
+
prevObj.objColl = extend([], this.objColl, [], true);
|
|
10912
|
+
prevObj.pointColl = extend([], this.pointColl, [], true);
|
|
10913
|
+
prevObj.afterCropActions = extend([], this.afterCropActions, [], true);
|
|
10657
10914
|
this.updateAdjustment('brightness', value);
|
|
10658
|
-
this.updateUndoRedoColl('brightness',
|
|
10915
|
+
this.updateUndoRedoColl('brightness', prevObj, prevObj.objColl, prevObj.pointColl, prevCropObj);
|
|
10659
10916
|
};
|
|
10660
10917
|
ImageEditor.prototype.setContrast = function (value) {
|
|
10661
10918
|
this.applyPenDraw();
|
|
10662
10919
|
this.adjustmentLevel.contrast = value;
|
|
10663
|
-
var temp = this.lowerContext.filter;
|
|
10664
10920
|
value = this.getFilterValue(value);
|
|
10665
10921
|
value *= 100;
|
|
10922
|
+
var prevCropObj = extend({}, this.cropObj, {}, true);
|
|
10923
|
+
var prevObj = this.getCurrentObj();
|
|
10924
|
+
prevObj.objColl = extend([], this.objColl, [], true);
|
|
10925
|
+
prevObj.pointColl = extend([], this.pointColl, [], true);
|
|
10926
|
+
prevObj.afterCropActions = extend([], this.afterCropActions, [], true);
|
|
10666
10927
|
this.updateAdjustment('contrast', value);
|
|
10667
|
-
this.updateUndoRedoColl('contrast',
|
|
10928
|
+
this.updateUndoRedoColl('contrast', prevObj, prevObj.objColl, prevObj.pointColl, prevCropObj);
|
|
10668
10929
|
};
|
|
10669
10930
|
ImageEditor.prototype.setHue = function (value) {
|
|
10670
10931
|
this.applyPenDraw();
|
|
10671
10932
|
this.adjustmentLevel.hue = value;
|
|
10672
10933
|
value *= 3;
|
|
10673
|
-
var
|
|
10934
|
+
var prevCropObj = extend({}, this.cropObj, {}, true);
|
|
10935
|
+
var prevObj = this.getCurrentObj();
|
|
10936
|
+
prevObj.objColl = extend([], this.objColl, [], true);
|
|
10937
|
+
prevObj.pointColl = extend([], this.pointColl, [], true);
|
|
10938
|
+
prevObj.afterCropActions = extend([], this.afterCropActions, [], true);
|
|
10674
10939
|
this.updateAdjustment('hue', value);
|
|
10675
|
-
this.updateUndoRedoColl('hue',
|
|
10940
|
+
this.updateUndoRedoColl('hue', prevObj, prevObj.objColl, prevObj.pointColl, prevCropObj);
|
|
10676
10941
|
};
|
|
10677
10942
|
ImageEditor.prototype.setSaturation = function (value) {
|
|
10678
10943
|
this.applyPenDraw();
|
|
10679
10944
|
this.adjustmentLevel.saturation = value;
|
|
10680
10945
|
value = this.getSaturationFilterValue(value);
|
|
10681
10946
|
value *= 100;
|
|
10682
|
-
var
|
|
10947
|
+
var prevCropObj = extend({}, this.cropObj, {}, true);
|
|
10948
|
+
var prevObj = this.getCurrentObj();
|
|
10949
|
+
prevObj.objColl = extend([], this.objColl, [], true);
|
|
10950
|
+
prevObj.pointColl = extend([], this.pointColl, [], true);
|
|
10951
|
+
prevObj.afterCropActions = extend([], this.afterCropActions, [], true);
|
|
10683
10952
|
this.updateAdjustment('saturation', value);
|
|
10684
|
-
this.updateUndoRedoColl('saturation',
|
|
10953
|
+
this.updateUndoRedoColl('saturation', prevObj, prevObj.objColl, prevObj.pointColl, prevCropObj);
|
|
10685
10954
|
};
|
|
10686
10955
|
ImageEditor.prototype.setOpacity = function (value) {
|
|
10687
10956
|
this.applyPenDraw();
|
|
@@ -10704,9 +10973,13 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
10704
10973
|
else if (value === 0) {
|
|
10705
10974
|
value = 0.25;
|
|
10706
10975
|
}
|
|
10707
|
-
var
|
|
10976
|
+
var prevCropObj = extend({}, this.cropObj, {}, true);
|
|
10977
|
+
var prevObj = this.getCurrentObj();
|
|
10978
|
+
prevObj.objColl = extend([], this.objColl, [], true);
|
|
10979
|
+
prevObj.pointColl = extend([], this.pointColl, [], true);
|
|
10980
|
+
prevObj.afterCropActions = extend([], this.afterCropActions, [], true);
|
|
10708
10981
|
this.updateAdjustment('opacity', value);
|
|
10709
|
-
this.updateUndoRedoColl('opacity',
|
|
10982
|
+
this.updateUndoRedoColl('opacity', prevObj, prevObj.objColl, prevObj.pointColl, prevCropObj);
|
|
10710
10983
|
};
|
|
10711
10984
|
ImageEditor.prototype.setBlur = function (value) {
|
|
10712
10985
|
this.applyPenDraw();
|
|
@@ -10714,25 +10987,37 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
10714
10987
|
value /= 20;
|
|
10715
10988
|
// Since 0.5 is not working in blur we consider from 1
|
|
10716
10989
|
value += 0.5;
|
|
10717
|
-
var
|
|
10990
|
+
var prevCropObj = extend({}, this.cropObj, {}, true);
|
|
10991
|
+
var prevObj = this.getCurrentObj();
|
|
10992
|
+
prevObj.objColl = extend([], this.objColl, [], true);
|
|
10993
|
+
prevObj.pointColl = extend([], this.pointColl, [], true);
|
|
10994
|
+
prevObj.afterCropActions = extend([], this.afterCropActions, [], true);
|
|
10718
10995
|
this.updateAdjustment('blur', value);
|
|
10719
|
-
this.updateUndoRedoColl('blur',
|
|
10996
|
+
this.updateUndoRedoColl('blur', prevObj, prevObj.objColl, prevObj.pointColl, prevCropObj);
|
|
10720
10997
|
};
|
|
10721
10998
|
ImageEditor.prototype.setExposure = function (value) {
|
|
10722
10999
|
this.applyPenDraw();
|
|
10723
11000
|
this.adjustmentLevel.exposure = value;
|
|
10724
11001
|
value = this.getFilterValue(value);
|
|
10725
|
-
var
|
|
11002
|
+
var prevCropObj = extend({}, this.cropObj, {}, true);
|
|
11003
|
+
var prevObj = this.getCurrentObj();
|
|
11004
|
+
prevObj.objColl = extend([], this.objColl, [], true);
|
|
11005
|
+
prevObj.pointColl = extend([], this.pointColl, [], true);
|
|
11006
|
+
prevObj.afterCropActions = extend([], this.afterCropActions, [], true);
|
|
10726
11007
|
this.updateAdjustment('exposure', value);
|
|
10727
|
-
this.updateUndoRedoColl('exposure',
|
|
11008
|
+
this.updateUndoRedoColl('exposure', prevObj, prevObj.objColl, prevObj.pointColl, prevCropObj);
|
|
10728
11009
|
};
|
|
10729
11010
|
ImageEditor.prototype.setFilter = function (type) {
|
|
10730
11011
|
type = type.toLowerCase();
|
|
10731
11012
|
this.applyPenDraw();
|
|
10732
|
-
var tempFilter = this.lowerContext.filter;
|
|
10733
11013
|
var prevFilter = this.currentFilter;
|
|
11014
|
+
var prevCropObj = extend({}, this.cropObj, {}, true);
|
|
11015
|
+
var prevObj = this.getCurrentObj();
|
|
11016
|
+
prevObj.objColl = extend([], this.objColl, [], true);
|
|
11017
|
+
prevObj.pointColl = extend([], this.pointColl, [], true);
|
|
11018
|
+
prevObj.afterCropActions = extend([], this.afterCropActions, [], true);
|
|
10734
11019
|
this.updateAdjustment(type, null);
|
|
10735
|
-
this.updateUndoRedoColl(type,
|
|
11020
|
+
this.updateUndoRedoColl(type, prevObj, prevObj.objColl, prevObj.pointColl, prevCropObj, null, null, prevFilter);
|
|
10736
11021
|
};
|
|
10737
11022
|
ImageEditor.prototype.renderImage = function () {
|
|
10738
11023
|
var temp = this.lowerContext.filter;
|
|
@@ -10767,8 +11052,81 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
10767
11052
|
this.updateFontStyles();
|
|
10768
11053
|
this.textArea.style.width = this.activeObj.activePoint.width + 'px';
|
|
10769
11054
|
};
|
|
11055
|
+
ImageEditor.prototype.drawNewSelection = function (type, startX, startY, width, height) {
|
|
11056
|
+
var points;
|
|
11057
|
+
var cropShape = 'crop-' + type;
|
|
11058
|
+
if (cropShape.toLowerCase() === 'crop-custom') {
|
|
11059
|
+
if (this.currObjType.shape === '') {
|
|
11060
|
+
this.drawCustomSelection('crop-custom');
|
|
11061
|
+
}
|
|
11062
|
+
if (startX && startY) {
|
|
11063
|
+
this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
|
|
11064
|
+
this.currObjType.shape = this.activeObj.shape = cropShape.toLowerCase();
|
|
11065
|
+
this.activeObj.activePoint.startX = startX;
|
|
11066
|
+
this.activeObj.activePoint.startY = startY;
|
|
11067
|
+
this.activeObj.activePoint.endX = this.lowerCanvas.width;
|
|
11068
|
+
this.activeObj.activePoint.endY = this.lowerCanvas.height;
|
|
11069
|
+
this.activeObj.activePoint.width = this.activeObj.activePoint.endX - this.activeObj.activePoint.startX;
|
|
11070
|
+
this.activeObj.activePoint.height = this.activeObj.activePoint.endY - this.activeObj.activePoint.startY;
|
|
11071
|
+
this.drawObject('duplicate');
|
|
11072
|
+
}
|
|
11073
|
+
}
|
|
11074
|
+
else if (cropShape.toLowerCase() === 'crop-canvas') {
|
|
11075
|
+
this.upperCanvas.style.display = 'none';
|
|
11076
|
+
this.dragCanvas = true;
|
|
11077
|
+
}
|
|
11078
|
+
else {
|
|
11079
|
+
this.currObjType.isCustomCrop = false;
|
|
11080
|
+
this.currObjType.shape = cropShape.toLowerCase();
|
|
11081
|
+
if (width && height) {
|
|
11082
|
+
points = { startX: startX, startY: startY, endX: startX + width, endY: startY + height,
|
|
11083
|
+
width: width, height: height };
|
|
11084
|
+
}
|
|
11085
|
+
else if (width && cropShape === 'crop-circle') {
|
|
11086
|
+
points = { startX: startX, startY: startY, endX: startX + width, endY: startY + width,
|
|
11087
|
+
width: width, height: width };
|
|
11088
|
+
}
|
|
11089
|
+
this.activeObj.shape = cropShape.toLowerCase();
|
|
11090
|
+
this.drawObject('duplicate', null, true, points);
|
|
11091
|
+
}
|
|
11092
|
+
};
|
|
11093
|
+
ImageEditor.prototype.setDestPointsForFlipState = function (isUpdate) {
|
|
11094
|
+
if (this.getCurrentPanRegion() !== '') {
|
|
11095
|
+
if (this.getCurrentPanRegion() === 'horizontal') {
|
|
11096
|
+
this.destLeft = this.lowerCanvas.clientWidth - (this.destWidth + this.destLeft);
|
|
11097
|
+
}
|
|
11098
|
+
else if (this.getCurrentPanRegion() === 'vertical') {
|
|
11099
|
+
this.destTop = this.lowerCanvas.clientHeight - (this.destHeight + this.destTop);
|
|
11100
|
+
}
|
|
11101
|
+
else {
|
|
11102
|
+
this.destLeft = this.lowerCanvas.clientWidth - (this.destWidth + this.destLeft);
|
|
11103
|
+
this.destTop = this.lowerCanvas.clientHeight - (this.destHeight + this.destTop);
|
|
11104
|
+
}
|
|
11105
|
+
}
|
|
11106
|
+
};
|
|
11107
|
+
ImageEditor.prototype.performUndoDefaultAction = function (obj) {
|
|
11108
|
+
this.lowerContext.filter = obj.previousObj.filter;
|
|
11109
|
+
this.objColl = [];
|
|
11110
|
+
this.pointColl = [];
|
|
11111
|
+
this.freehandCounter = 0;
|
|
11112
|
+
this.setCurrentObj(obj.previousObj);
|
|
11113
|
+
this.destLeft = obj.previousObj.destPoints.startX;
|
|
11114
|
+
this.destTop = obj.previousObj.destPoints.startY;
|
|
11115
|
+
var activeObj = extend({}, this.activeObj, {}, true);
|
|
11116
|
+
this.objColl = extend([], obj.previousObjColl, [], true);
|
|
11117
|
+
this.pointColl = extend([], obj.previousPointColl, [], true);
|
|
11118
|
+
this.freehandCounter = this.pointColl.length;
|
|
11119
|
+
this.lowerContext.filter = 'none';
|
|
11120
|
+
this.iterateObjColl();
|
|
11121
|
+
this.freehandRedraw(this.lowerContext);
|
|
11122
|
+
this.lowerContext.filter = obj.previousObj.filter;
|
|
11123
|
+
this.activeObj = activeObj;
|
|
11124
|
+
this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
|
|
11125
|
+
if (this.activeObj.activePoint.width !== 0 && this.activeObj.activePoint.height !== 0) {
|
|
11126
|
+
this.drawObject('duplicate');
|
|
11127
|
+
}
|
|
11128
|
+
};
|
|
10770
11129
|
ImageEditor.prototype.setAdjustment = function (type) {
|
|
10771
|
-
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
10772
11130
|
var splitWords = this.lowerContext.filter.split(' ');
|
|
10773
11131
|
var value;
|
|
10774
11132
|
var valueArr;
|
|
@@ -10831,59 +11189,25 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
10831
11189
|
this.adjustmentLevel.exposure = this.setFilterValue(value);
|
|
10832
11190
|
break;
|
|
10833
11191
|
}
|
|
10834
|
-
this.callUpdateCurrentTransformedState();
|
|
10835
|
-
};
|
|
10836
|
-
ImageEditor.prototype.updateFilter = function (obj) {
|
|
10837
|
-
var selEle = this.element.querySelector('.e-contextual-toolbar-wrapper .e-toolbar-item.e-selected');
|
|
10838
|
-
if (selEle) {
|
|
10839
|
-
selEle.classList.remove('e-selected');
|
|
10840
|
-
}
|
|
10841
|
-
var filterCanvas = document.getElementById(obj.value + 'Canvas');
|
|
10842
|
-
if (filterCanvas) {
|
|
10843
|
-
filterCanvas.parentElement.classList.add('e-selected');
|
|
10844
|
-
}
|
|
10845
|
-
this.currentFilter = obj.value;
|
|
10846
|
-
this.lowerContext.filter = this.canvasFilter = obj.previousObj;
|
|
10847
|
-
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
10848
|
-
this.isUndoRedo = true;
|
|
10849
|
-
this.redrawImgWithObj();
|
|
10850
11192
|
};
|
|
10851
|
-
ImageEditor.prototype.
|
|
10852
|
-
|
|
10853
|
-
|
|
10854
|
-
|
|
10855
|
-
|
|
10856
|
-
|
|
11193
|
+
ImageEditor.prototype.updateFilter = function (type, previousFilter) {
|
|
11194
|
+
if (type === 'default' || type === 'chrome' || type === 'cold' ||
|
|
11195
|
+
type === 'warm' || type === 'grayscale' || type === 'blackandwhite' ||
|
|
11196
|
+
type === 'sepia' || type === 'invert' || type === 'sharpen') {
|
|
11197
|
+
var selEle = this.element.querySelector('.e-contextual-toolbar-wrapper .e-toolbar-item.e-selected');
|
|
11198
|
+
if (selEle) {
|
|
11199
|
+
selEle.classList.remove('e-selected');
|
|
10857
11200
|
}
|
|
10858
|
-
|
|
10859
|
-
|
|
10860
|
-
|
|
10861
|
-
this.activeObj.activePoint.startX = startX;
|
|
10862
|
-
this.activeObj.activePoint.startY = startY;
|
|
10863
|
-
this.activeObj.activePoint.endX = this.lowerCanvas.width;
|
|
10864
|
-
this.activeObj.activePoint.endY = this.lowerCanvas.height;
|
|
10865
|
-
this.activeObj.activePoint.width = this.activeObj.activePoint.endX - this.activeObj.activePoint.startX;
|
|
10866
|
-
this.activeObj.activePoint.height = this.activeObj.activePoint.endY - this.activeObj.activePoint.startY;
|
|
10867
|
-
this.drawObject('duplicate');
|
|
11201
|
+
var filterCanvas = document.getElementById(this.element.id + '_' + type + 'Canvas');
|
|
11202
|
+
if (filterCanvas) {
|
|
11203
|
+
filterCanvas.parentElement.classList.add('e-selected');
|
|
10868
11204
|
}
|
|
10869
|
-
|
|
10870
|
-
|
|
10871
|
-
this.upperCanvas.style.display = 'none';
|
|
10872
|
-
this.dragCanvas = true;
|
|
10873
|
-
}
|
|
10874
|
-
else {
|
|
10875
|
-
this.currObjType.isCustomCrop = false;
|
|
10876
|
-
this.currObjType.shape = cropShape.toLowerCase();
|
|
10877
|
-
if (width && height) {
|
|
10878
|
-
points = { startX: startX, startY: startY, endX: startX + width, endY: startY + height,
|
|
10879
|
-
width: width, height: height };
|
|
11205
|
+
if (!isNullOrUndefined(previousFilter)) {
|
|
11206
|
+
this.currentFilter = previousFilter;
|
|
10880
11207
|
}
|
|
10881
|
-
else
|
|
10882
|
-
|
|
10883
|
-
width: width, height: width };
|
|
11208
|
+
else {
|
|
11209
|
+
this.currentFilter = this.element.id + '_' + type;
|
|
10884
11210
|
}
|
|
10885
|
-
this.activeObj.shape = cropShape.toLowerCase();
|
|
10886
|
-
this.drawObject('duplicate', null, true, points);
|
|
10887
11211
|
}
|
|
10888
11212
|
};
|
|
10889
11213
|
/**
|
|
@@ -10924,11 +11248,15 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
10924
11248
|
}
|
|
10925
11249
|
if (!this.disabled && this.activeObj.horTopLine !== undefined && (this.currObjType.isCustomCrop || splitWords[0] === 'crop')) {
|
|
10926
11250
|
isCrop = true;
|
|
10927
|
-
var
|
|
11251
|
+
var prevCropObj = extend({}, this.cropObj, {}, true);
|
|
11252
|
+
var prevObj = this.getCurrentObj();
|
|
11253
|
+
prevObj.objColl = extend([], this.objColl, [], true);
|
|
11254
|
+
prevObj.pointColl = extend([], this.pointColl, [], true);
|
|
11255
|
+
prevObj.afterCropActions = extend([], this.afterCropActions, [], true);
|
|
10928
11256
|
this.cropImg();
|
|
10929
11257
|
this.zoomFactor = 0;
|
|
10930
11258
|
this.enableDisableToolbarBtn();
|
|
10931
|
-
this.updateUndoRedoColl('crop',
|
|
11259
|
+
this.updateUndoRedoColl('crop', prevObj, prevObj.objColl, prevObj.pointColl, prevCropObj);
|
|
10932
11260
|
}
|
|
10933
11261
|
}
|
|
10934
11262
|
return isCrop;
|
|
@@ -10941,9 +11269,17 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
10941
11269
|
*/
|
|
10942
11270
|
ImageEditor.prototype.flip = function (direction) {
|
|
10943
11271
|
if (!this.disabled && this.isImageLoaded) {
|
|
10944
|
-
var zoomFactor = this.zoomFactor;
|
|
10945
11272
|
var transitionArgs = { direction: direction };
|
|
10946
11273
|
this.trigger('flipping', transitionArgs);
|
|
11274
|
+
var prevCropObj = extend({}, this.cropObj, {}, true);
|
|
11275
|
+
var prevObj = void 0;
|
|
11276
|
+
if (isNullOrUndefined(this.transformCurrentObj)) {
|
|
11277
|
+
prevObj = this.getCurrentObj();
|
|
11278
|
+
prevObj.objColl = extend([], this.objColl, null, true);
|
|
11279
|
+
prevObj.pointColl = extend({}, this.pointColl, null, true);
|
|
11280
|
+
prevObj.afterCropActions = extend([], this.afterCropActions, [], true);
|
|
11281
|
+
}
|
|
11282
|
+
this.afterCropActions.push(direction.toLowerCase() === 'horizontal' ? 'horizontalflip' : 'verticalflip');
|
|
10947
11283
|
var splitWords = [];
|
|
10948
11284
|
var activeObjShape = void 0;
|
|
10949
11285
|
if (!isNullOrUndefined(this.activeObj.activePoint)) {
|
|
@@ -11002,7 +11338,12 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
11002
11338
|
this.rotateFlipColl.push(direction.toLowerCase());
|
|
11003
11339
|
}
|
|
11004
11340
|
if (this.rotateFlipColl.length === 1) {
|
|
11005
|
-
this.
|
|
11341
|
+
if (this.getCurrentPanRegion() === '') {
|
|
11342
|
+
this.setClientTransformedDimension();
|
|
11343
|
+
}
|
|
11344
|
+
else {
|
|
11345
|
+
this.setDestPointsForFlipState();
|
|
11346
|
+
}
|
|
11006
11347
|
}
|
|
11007
11348
|
if (this.isCircleCrop) {
|
|
11008
11349
|
this.cropCircle(this.lowerContext);
|
|
@@ -11041,8 +11382,9 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
11041
11382
|
}
|
|
11042
11383
|
this.lowerContext.filter = tempFilter;
|
|
11043
11384
|
this.refreshActiveObj();
|
|
11044
|
-
|
|
11045
|
-
|
|
11385
|
+
this.updateCurrSelectionPoint(direction.toLowerCase());
|
|
11386
|
+
if (!this.isUndoRedo && isNullOrUndefined(this.transformCurrentObj)) {
|
|
11387
|
+
this.updateUndoRedoColl('flip', prevObj, prevObj.objColl, prevObj.pointColl, prevCropObj);
|
|
11046
11388
|
}
|
|
11047
11389
|
this.isUndoRedo = false;
|
|
11048
11390
|
this.clearOuterCanvas(this.lowerContext);
|
|
@@ -11062,7 +11404,7 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
11062
11404
|
else if (!this.isReverseFlip) {
|
|
11063
11405
|
this.refreshToolbar('main', true, true);
|
|
11064
11406
|
}
|
|
11065
|
-
this.alignRotateFlipColl();
|
|
11407
|
+
this.rotateFlipColl = this.alignRotateFlipColl(this.rotateFlipColl, true);
|
|
11066
11408
|
}
|
|
11067
11409
|
};
|
|
11068
11410
|
/**
|
|
@@ -11224,17 +11566,16 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
11224
11566
|
this.selectedFreehandColor = '#42a5f5';
|
|
11225
11567
|
this.isFreehandDrawCustomized = false;
|
|
11226
11568
|
this.isShapeInserted = false;
|
|
11227
|
-
this.
|
|
11228
|
-
this.
|
|
11569
|
+
this.isAllowCropPan = false;
|
|
11570
|
+
this.tempPannedPoint = { x: 0, y: 0 };
|
|
11229
11571
|
this.currObjType = { shape: '', isDragging: false, isActiveObj: false, isText: false, isInitialText: false, isLine: false,
|
|
11230
11572
|
isInitialLine: false, isCustomCrop: false, isZoomed: false, isUndoZoom: false,
|
|
11231
11573
|
isUndoAction: false, isFiltered: false, isSave: false };
|
|
11232
|
-
this.isAllowCropPan = false;
|
|
11233
|
-
this.tempPannedPoint = { x: 0, y: 0 };
|
|
11234
11574
|
this.cropObj = { cropZoom: 0, defaultZoom: 0, totalPannedPoint: { x: 0, y: 0 }, totalPannedClientPoint: { x: 0, y: 0 },
|
|
11235
|
-
totalPannedInternalPoint: { x: 0, y: 0 },
|
|
11236
|
-
|
|
11237
|
-
|
|
11575
|
+
totalPannedInternalPoint: { x: 0, y: 0 }, tempFlipPanPoint: { x: 0, y: 0 }, activeObj: {},
|
|
11576
|
+
rotateFlipColl: [], degree: 0, currFlipState: '',
|
|
11577
|
+
destPoints: { startX: 0, startY: 0, width: 0, height: 0 },
|
|
11578
|
+
srcPoints: { startX: 0, startY: 0, width: 0, height: 0 }, filter: '' };
|
|
11238
11579
|
this.afterCropActions = [];
|
|
11239
11580
|
this.isCancelAction = this.preventZoomBtn = this.isFreehandPointMoved = false;
|
|
11240
11581
|
this.isTouch = false;
|
|
@@ -11244,6 +11585,11 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
11244
11585
|
this.tempCurrentFreehandDrawIndex = 0;
|
|
11245
11586
|
this.cancelObjColl = [];
|
|
11246
11587
|
this.cancelPointColl = [];
|
|
11588
|
+
this.freehandDrawSelectedId = null;
|
|
11589
|
+
this.transformCurrentObj = null;
|
|
11590
|
+
this.rotatedFlipCropSelection = false;
|
|
11591
|
+
this.panStartObj = null;
|
|
11592
|
+
this.currDestinationPoint = null;
|
|
11247
11593
|
this.updateCanvas();
|
|
11248
11594
|
this.refreshDropDownBtn(false);
|
|
11249
11595
|
this.enableDisableToolbarBtn();
|
|
@@ -11263,6 +11609,15 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
11263
11609
|
isRotate = true;
|
|
11264
11610
|
var transitionArgs = { degree: degree };
|
|
11265
11611
|
this.trigger('rotating', transitionArgs);
|
|
11612
|
+
var prevCropObj = extend({}, this.cropObj, {}, true);
|
|
11613
|
+
var prevObj = void 0;
|
|
11614
|
+
if (isNullOrUndefined(this.transformCurrentObj)) {
|
|
11615
|
+
prevObj = this.getCurrentObj();
|
|
11616
|
+
prevObj.objColl = extend([], this.objColl, null, true);
|
|
11617
|
+
prevObj.pointColl = extend({}, this.pointColl, null, true);
|
|
11618
|
+
prevObj.afterCropActions = extend([], this.afterCropActions, [], true);
|
|
11619
|
+
}
|
|
11620
|
+
this.afterCropActions.push(degree === 90 ? 'rotateRight' : 'rotateLeft');
|
|
11266
11621
|
var splitWords = [];
|
|
11267
11622
|
var activeObjShape = void 0;
|
|
11268
11623
|
if (!isNullOrUndefined(this.activeObj.activePoint) && !isNullOrUndefined(this.activeObj.shape)) {
|
|
@@ -11278,7 +11633,6 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
11278
11633
|
}
|
|
11279
11634
|
this.redrawActObj();
|
|
11280
11635
|
this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
|
|
11281
|
-
var zoomFactor = this.zoomFactor;
|
|
11282
11636
|
this.drawRotatedImage(degree);
|
|
11283
11637
|
this.clearOuterCanvas(this.lowerContext);
|
|
11284
11638
|
this.clearOuterCanvas(this.upperContext);
|
|
@@ -11291,8 +11645,8 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
11291
11645
|
this.refreshToolbar('main', true, true);
|
|
11292
11646
|
}
|
|
11293
11647
|
}
|
|
11294
|
-
if (!this.isUndoRedo) {
|
|
11295
|
-
this.updateUndoRedoColl('rotate',
|
|
11648
|
+
if (!this.isUndoRedo && isNullOrUndefined(this.transformCurrentObj)) {
|
|
11649
|
+
this.updateUndoRedoColl('rotate', prevObj, prevObj.objColl, prevObj.pointColl, prevCropObj);
|
|
11296
11650
|
}
|
|
11297
11651
|
this.isUndoRedo = false;
|
|
11298
11652
|
if (isNullOrUndefined(this.activeObj.shape) && !this.isReverseRotate) {
|
|
@@ -11301,7 +11655,7 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
11301
11655
|
else if (!this.isReverseRotate) {
|
|
11302
11656
|
this.refreshToolbar('main', true, true);
|
|
11303
11657
|
}
|
|
11304
|
-
this.alignRotateFlipColl();
|
|
11658
|
+
this.rotateFlipColl = this.alignRotateFlipColl(this.rotateFlipColl, true);
|
|
11305
11659
|
}
|
|
11306
11660
|
return isRotate;
|
|
11307
11661
|
};
|
|
@@ -11398,6 +11752,11 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
11398
11752
|
else if (splitWords !== undefined && splitWords[0] === 'crop') {
|
|
11399
11753
|
isPrevent = true;
|
|
11400
11754
|
}
|
|
11755
|
+
var prevCropObj = extend({}, this.cropObj, {}, true);
|
|
11756
|
+
var prevObj = this.getCurrentObj();
|
|
11757
|
+
prevObj.objColl = extend([], this.objColl, [], true);
|
|
11758
|
+
prevObj.pointColl = extend([], this.pointColl, [], true);
|
|
11759
|
+
prevObj.afterCropActions = extend([], this.afterCropActions, [], true);
|
|
11401
11760
|
this.redrawActObj();
|
|
11402
11761
|
this.refreshActiveObj();
|
|
11403
11762
|
this.keyHistory = '';
|
|
@@ -11409,19 +11768,26 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
11409
11768
|
if (this.defaultZoomFactor > 0) {
|
|
11410
11769
|
var zoomFactor = this.zoomFactor = this.defaultZoomFactor;
|
|
11411
11770
|
this.isCropTab = false;
|
|
11771
|
+
var isUndoRedo = this.isUndoRedo;
|
|
11412
11772
|
for (var i = 0; i < (zoomFactor * 10); i++) {
|
|
11773
|
+
this.isUndoRedo = true;
|
|
11413
11774
|
this.zoom(-0.1);
|
|
11414
11775
|
}
|
|
11776
|
+
this.isUndoRedo = isUndoRedo;
|
|
11415
11777
|
this.resetPanPoints();
|
|
11416
11778
|
}
|
|
11417
11779
|
this.cancelObjColl = extend([], this.objColl, [], true);
|
|
11418
11780
|
this.cancelPointColl = extend([], this.pointColl, [], true);
|
|
11781
|
+
this.updateObjAndFreeHandDrawColl();
|
|
11419
11782
|
this.isCropTab = true;
|
|
11420
11783
|
this.setCurrSelectionPoints(true);
|
|
11421
11784
|
this.zoomFactor = this.cropZoomFactor;
|
|
11422
11785
|
if (isNullOrUndefined(this.cropObj.activeObj.shape)) {
|
|
11423
11786
|
this.drawNewSelection(type, startX, startY, width, height);
|
|
11424
11787
|
}
|
|
11788
|
+
else {
|
|
11789
|
+
this.updateUndoRedoColl('crop-selection', prevObj, prevObj.objColl, prevObj.pointColl, prevCropObj);
|
|
11790
|
+
}
|
|
11425
11791
|
}
|
|
11426
11792
|
else {
|
|
11427
11793
|
if (type === 'custom') {
|
|
@@ -11496,23 +11862,6 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
11496
11862
|
}
|
|
11497
11863
|
}
|
|
11498
11864
|
};
|
|
11499
|
-
ImageEditor.prototype.setDestPointsForFlipState = function (isUpdate) {
|
|
11500
|
-
if (this.getCurrentPanRegion() !== '') {
|
|
11501
|
-
if (this.getCurrentPanRegion() === 'horizontal') {
|
|
11502
|
-
this.destLeft = this.lowerCanvas.clientWidth - (this.destWidth + this.destLeft);
|
|
11503
|
-
}
|
|
11504
|
-
else if (this.getCurrentPanRegion() === 'vertical') {
|
|
11505
|
-
this.destTop = this.lowerCanvas.clientHeight - (this.destHeight + this.destTop);
|
|
11506
|
-
}
|
|
11507
|
-
else {
|
|
11508
|
-
this.destLeft = this.lowerCanvas.clientWidth - (this.destWidth + this.destLeft);
|
|
11509
|
-
this.destTop = this.lowerCanvas.clientHeight - (this.destHeight + this.destTop);
|
|
11510
|
-
}
|
|
11511
|
-
if (!isNullOrUndefined(isUpdate)) {
|
|
11512
|
-
this.updateObjAndFreeHandDrawColl();
|
|
11513
|
-
}
|
|
11514
|
-
}
|
|
11515
|
-
};
|
|
11516
11865
|
/**
|
|
11517
11866
|
* Increase / Decrease the magnification of an image.
|
|
11518
11867
|
*
|
|
@@ -11521,7 +11870,7 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
11521
11870
|
*/
|
|
11522
11871
|
ImageEditor.prototype.zoom = function (value) {
|
|
11523
11872
|
if (!this.disabled && this.isImageLoaded) {
|
|
11524
|
-
if ((this.zoomFactor === 0 && value < 0) || (this.zoomFactor >
|
|
11873
|
+
if ((this.zoomFactor === 0 && value < 0) || (this.zoomFactor > 2 && value > 0 ||
|
|
11525
11874
|
(this.zoomFactor > 0 && value < 0 && this.disableZoomOutBtn()))) {
|
|
11526
11875
|
return;
|
|
11527
11876
|
}
|
|
@@ -11538,6 +11887,24 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
11538
11887
|
else if (!isNullOrUndefined(this.activeObj.shape) && splitWords[0] !== 'crop') {
|
|
11539
11888
|
isShape = true;
|
|
11540
11889
|
}
|
|
11890
|
+
var zoomPoint = void 0;
|
|
11891
|
+
var zoomLevel = void 0;
|
|
11892
|
+
if (this.isCropTab && !isNullOrUndefined(tempActiveObj)) {
|
|
11893
|
+
zoomLevel = this.cropZoomFactor;
|
|
11894
|
+
zoomPoint = { x: this.activeObj.activePoint.startX + (this.activeObj.activePoint.width / 2),
|
|
11895
|
+
y: this.activeObj.activePoint.startY + (this.activeObj.activePoint.height / 2) };
|
|
11896
|
+
}
|
|
11897
|
+
else {
|
|
11898
|
+
zoomLevel = this.defaultZoomFactor;
|
|
11899
|
+
zoomPoint = { x: this.lowerCanvas.clientWidth / 2, y: this.lowerCanvas.clientHeight / 2 };
|
|
11900
|
+
}
|
|
11901
|
+
var zoomEventArgs = { zoomPoint: zoomPoint, zoomLevel: zoomLevel };
|
|
11902
|
+
this.trigger('zooming', zoomEventArgs);
|
|
11903
|
+
var prevCropObj = extend({}, this.cropObj, {}, true);
|
|
11904
|
+
var prevObj = this.getCurrentObj();
|
|
11905
|
+
prevObj.objColl = extend([], this.objColl, [], true);
|
|
11906
|
+
prevObj.pointColl = extend([], this.pointColl, [], true);
|
|
11907
|
+
prevObj.afterCropActions = extend([], this.afterCropActions, [], true);
|
|
11541
11908
|
this.redrawActObj();
|
|
11542
11909
|
this.refreshActiveObj();
|
|
11543
11910
|
this.upperContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
@@ -11558,9 +11925,9 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
11558
11925
|
if (this.degree !== 0) {
|
|
11559
11926
|
this.redrawActObj();
|
|
11560
11927
|
this.currentPannedPoint = { x: 0, y: 0 };
|
|
11561
|
-
this.rotatePan();
|
|
11928
|
+
this.rotatePan(true, true);
|
|
11562
11929
|
}
|
|
11563
|
-
this.
|
|
11930
|
+
this.updateObjAndFreeHandDrawColl();
|
|
11564
11931
|
}
|
|
11565
11932
|
if (this.degree === 0) {
|
|
11566
11933
|
this.drawZoomImgToCanvas(value, tempActiveObj);
|
|
@@ -11569,13 +11936,19 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
11569
11936
|
this.tempFlipPanPoint.y += this.totalPannedPoint.y;
|
|
11570
11937
|
objColl = extend([], this.objColl, [], true);
|
|
11571
11938
|
this.objColl = [];
|
|
11939
|
+
var destLeft = this.destLeft;
|
|
11940
|
+
var destTop = this.destTop;
|
|
11941
|
+
this.setDestPointsForFlipState();
|
|
11572
11942
|
this.rotatedFlip();
|
|
11573
|
-
|
|
11574
|
-
|
|
11575
|
-
|
|
11576
|
-
|
|
11577
|
-
|
|
11578
|
-
|
|
11943
|
+
this.destLeft = destLeft;
|
|
11944
|
+
this.destTop = destTop;
|
|
11945
|
+
this.objColl = objColl;
|
|
11946
|
+
this.zoomObjColl();
|
|
11947
|
+
this.zoomFreehandDrawColl();
|
|
11948
|
+
this.updateObjAndFreeHandDrawColl();
|
|
11949
|
+
}
|
|
11950
|
+
if (this.zoomFactor === 0 && !this.isCropTab) {
|
|
11951
|
+
this.totalPannedPoint = { x: 0, y: 0 };
|
|
11579
11952
|
}
|
|
11580
11953
|
}
|
|
11581
11954
|
else {
|
|
@@ -11598,19 +11971,6 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
11598
11971
|
this.zoomFreehandDrawColl();
|
|
11599
11972
|
this.lowerContext.filter = temp;
|
|
11600
11973
|
}
|
|
11601
|
-
else if (this.degree === 0) {
|
|
11602
|
-
var temp = this.lowerContext.filter;
|
|
11603
|
-
this.lowerContext.filter = 'none';
|
|
11604
|
-
var destLeft = this.destLeft;
|
|
11605
|
-
var destTop = this.destTop;
|
|
11606
|
-
this.setDestPointsForFlipState();
|
|
11607
|
-
this.objColl = objColl;
|
|
11608
|
-
this.zoomObjColl();
|
|
11609
|
-
this.zoomFreehandDrawColl();
|
|
11610
|
-
this.destLeft = destLeft;
|
|
11611
|
-
this.destTop = destTop;
|
|
11612
|
-
this.lowerContext.filter = temp;
|
|
11613
|
-
}
|
|
11614
11974
|
if ((!isNullOrUndefined(this.currSelectionPoint) && this.currSelectionPoint.shape === 'crop-circle') || this.isCircleCrop) {
|
|
11615
11975
|
this.cropCircle(this.lowerContext);
|
|
11616
11976
|
}
|
|
@@ -11619,18 +11979,12 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
11619
11979
|
if (!isNullOrUndefined(tempActiveObj)) {
|
|
11620
11980
|
this.activeObj = extend({}, tempActiveObj, {}, true);
|
|
11621
11981
|
this.drawObject('duplicate', this.activeObj);
|
|
11622
|
-
if (this.currentToolbar === 'crop') {
|
|
11623
|
-
this.refreshToolbar('main', true, true);
|
|
11624
|
-
}
|
|
11625
|
-
else {
|
|
11626
|
-
this.refreshToolbar(this.currentToolbar, true, true);
|
|
11627
|
-
}
|
|
11628
11982
|
if (this.zoomFactor === 0) {
|
|
11629
11983
|
this.currSelectionPoint = null;
|
|
11630
11984
|
}
|
|
11631
11985
|
}
|
|
11632
11986
|
if (!this.isUndoRedo) {
|
|
11633
|
-
this.updateUndoRedoColl('zoom',
|
|
11987
|
+
this.updateUndoRedoColl('zoom', prevObj, prevObj.objColl, prevObj.pointColl, prevCropObj);
|
|
11634
11988
|
}
|
|
11635
11989
|
this.isUndoRedo = false;
|
|
11636
11990
|
var zoomOut = document.querySelector('#' + this.element.id + '_zoomOut');
|
|
@@ -11642,9 +11996,6 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
11642
11996
|
zoomOut.classList.remove('e-disabled');
|
|
11643
11997
|
zoomOut.parentElement.classList.remove('e-overlay');
|
|
11644
11998
|
}
|
|
11645
|
-
if (!this.togglePan) {
|
|
11646
|
-
this.callMainToolbar(false, true);
|
|
11647
|
-
}
|
|
11648
11999
|
this.autoEnablePan();
|
|
11649
12000
|
if (!isNullOrUndefined(tempActiveObj)) {
|
|
11650
12001
|
this.activeObj = extend({}, tempActiveObj, {}, true);
|
|
@@ -11652,24 +12003,6 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
11652
12003
|
if (this.activeObj.shape === 'crop-custom') {
|
|
11653
12004
|
this.currObjType.isCustomCrop = true;
|
|
11654
12005
|
}
|
|
11655
|
-
if (isNullOrUndefined(this.activeObj.activePoint) || this.activeObj.activePoint.width === 0) {
|
|
11656
|
-
if (this.currentToolbar === 'crop' || !isNullOrUndefined(tempActiveObj)) {
|
|
11657
|
-
this.refreshToolbar('main', true, true);
|
|
11658
|
-
}
|
|
11659
|
-
else {
|
|
11660
|
-
this.refreshToolbar('main');
|
|
11661
|
-
this.currentToolbar = 'main';
|
|
11662
|
-
}
|
|
11663
|
-
}
|
|
11664
|
-
else {
|
|
11665
|
-
if (this.currentToolbar === 'crop' || !isNullOrUndefined(tempActiveObj)) {
|
|
11666
|
-
this.refreshToolbar('main', true, true);
|
|
11667
|
-
}
|
|
11668
|
-
else {
|
|
11669
|
-
this.refreshToolbar('main');
|
|
11670
|
-
this.currentToolbar = 'main';
|
|
11671
|
-
}
|
|
11672
|
-
}
|
|
11673
12006
|
var panBtn = this.element.querySelector('.e-img-pan .e-btn');
|
|
11674
12007
|
if (!isNullOrUndefined(panBtn) && this.togglePan) {
|
|
11675
12008
|
panBtn.classList.add('e-selected-btn');
|
|
@@ -11681,12 +12014,6 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
11681
12014
|
this.activeObj = extend({}, this.objColl[this.objColl.length - 1], {}, true);
|
|
11682
12015
|
this.objColl.pop();
|
|
11683
12016
|
this.drawObject('duplicate', this.activeObj);
|
|
11684
|
-
if (this.activeObj.shape === 'text') {
|
|
11685
|
-
this.refreshToolbar('text');
|
|
11686
|
-
}
|
|
11687
|
-
else {
|
|
11688
|
-
this.refreshToolbar('shapes');
|
|
11689
|
-
}
|
|
11690
12017
|
this.updateToolbarItems();
|
|
11691
12018
|
}
|
|
11692
12019
|
}
|
|
@@ -12090,14 +12417,13 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
12090
12417
|
else {
|
|
12091
12418
|
this.refreshToolbar('main');
|
|
12092
12419
|
}
|
|
12093
|
-
if (this.activeObj.activePoint.width !== 0) {
|
|
12420
|
+
if (!isNullOrUndefined(this.activeObj.activePoint) && this.activeObj.activePoint.width !== 0) {
|
|
12094
12421
|
this.tempActObj = this.activeObj;
|
|
12095
12422
|
}
|
|
12096
|
-
|
|
12423
|
+
this.refreshActiveObj();
|
|
12097
12424
|
this.undoRedoStep--;
|
|
12098
12425
|
this.enableDisableToolbarBtn();
|
|
12099
12426
|
this.isUndoRedo = true;
|
|
12100
|
-
this.lowerContext.filter = this.canvasFilter;
|
|
12101
12427
|
var obj = this.undoRedoColl[this.undoRedoStep];
|
|
12102
12428
|
if (this.undoRedoColl.length === this.undoRedoStep) {
|
|
12103
12429
|
this.currObjType.isUndoAction = false;
|
|
@@ -12105,82 +12431,47 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
12105
12431
|
else {
|
|
12106
12432
|
this.currObjType.isUndoAction = true;
|
|
12107
12433
|
}
|
|
12108
|
-
if (obj.operation !== '
|
|
12434
|
+
if (obj.operation !== 'textAreaCustomization' && this.textArea.style.display === 'block') {
|
|
12109
12435
|
this.textArea.style.display = 'none';
|
|
12110
12436
|
}
|
|
12111
12437
|
this.element.querySelector('.e-contextual-toolbar-wrapper').classList.add('e-hide');
|
|
12112
|
-
|
|
12113
|
-
var
|
|
12114
|
-
|
|
12115
|
-
|
|
12116
|
-
|
|
12438
|
+
this.isCancelAction = true;
|
|
12439
|
+
var activeObj = void 0;
|
|
12440
|
+
this.cropObj = extend({}, obj.previousCropObj, {}, true);
|
|
12441
|
+
this.afterCropActions = obj.previousObj.afterCropActions;
|
|
12442
|
+
this.lowerContext.filter = this.canvasFilter = obj.previousObj.filter;
|
|
12117
12443
|
switch (obj.operation) {
|
|
12118
|
-
case '
|
|
12119
|
-
|
|
12120
|
-
|
|
12121
|
-
|
|
12122
|
-
else if (obj.value === -90) {
|
|
12123
|
-
value = 'rotateright';
|
|
12124
|
-
}
|
|
12125
|
-
this.performTransformation(value);
|
|
12126
|
-
break;
|
|
12127
|
-
case 'flip':
|
|
12128
|
-
if (obj.value.toLowerCase() === 'horizontal') {
|
|
12129
|
-
value = 'horizontalflip';
|
|
12130
|
-
}
|
|
12131
|
-
else if (obj.value.toLowerCase() === 'vertical') {
|
|
12132
|
-
value = 'verticalflip';
|
|
12133
|
-
}
|
|
12134
|
-
this.performTransformation(value);
|
|
12135
|
-
break;
|
|
12136
|
-
case 'zoom':
|
|
12137
|
-
if (this.zoomFactor === 0 && obj.zoomFactor !== 0) {
|
|
12138
|
-
this.zoomFactor = obj.zoomFactor;
|
|
12139
|
-
}
|
|
12140
|
-
this.zoom(-obj.value);
|
|
12444
|
+
case 'shapeTransform':
|
|
12445
|
+
this.objColl = extend([], obj.previousObjColl, [], true);
|
|
12446
|
+
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
12447
|
+
this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
|
|
12141
12448
|
this.isUndoRedo = true;
|
|
12142
|
-
|
|
12143
|
-
|
|
12144
|
-
xDiff = this.destLeft;
|
|
12145
|
-
yDiff = this.destTop;
|
|
12146
|
-
this.destLeft = obj.previousObj.x;
|
|
12147
|
-
this.destTop = obj.previousObj.y;
|
|
12148
|
-
xDiff += this.destLeft;
|
|
12149
|
-
yDiff += this.destTop;
|
|
12150
|
-
this.drawPannedImage(xDiff, yDiff);
|
|
12151
|
-
break;
|
|
12152
|
-
case 'crop':
|
|
12153
|
-
if (!isNullOrUndefined(this.currSelectionPoint)) {
|
|
12154
|
-
tempUndoRedoColl = extend([], this.undoRedoColl, [], true);
|
|
12155
|
-
this.select('Custom');
|
|
12156
|
-
this.refreshToolbar('main', true, true);
|
|
12157
|
-
getComponent(this.element.querySelector('#' + this.element.id + '_cropBtn'), 'dropdown-btn').toggle();
|
|
12158
|
-
this.undoRedoColl = tempUndoRedoColl;
|
|
12159
|
-
this.enableDisableToolbarBtn();
|
|
12160
|
-
}
|
|
12449
|
+
this.redrawImgWithObj();
|
|
12450
|
+
this.refreshActiveObj();
|
|
12161
12451
|
break;
|
|
12162
12452
|
case 'freehanddraw':
|
|
12163
|
-
this.pointColl = obj.
|
|
12164
|
-
this.freehandCounter
|
|
12453
|
+
this.pointColl = obj.previousPointColl;
|
|
12454
|
+
this.freehandCounter = this.pointColl.length;
|
|
12165
12455
|
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
12166
12456
|
this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
|
|
12167
12457
|
this.isUndoRedo = true;
|
|
12168
12458
|
this.redrawImgWithObj();
|
|
12169
12459
|
break;
|
|
12170
12460
|
case 'freehanddrawCustomized':
|
|
12171
|
-
this.pointColl = obj.
|
|
12461
|
+
this.pointColl = obj.previousPointColl;
|
|
12172
12462
|
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
12173
12463
|
this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
|
|
12174
12464
|
this.isUndoRedo = true;
|
|
12175
12465
|
this.redrawImgWithObj();
|
|
12176
12466
|
break;
|
|
12177
|
-
case '
|
|
12178
|
-
|
|
12179
|
-
|
|
12180
|
-
this.
|
|
12467
|
+
case 'deleteFreehandDrawing':
|
|
12468
|
+
case 'deleteObj':
|
|
12469
|
+
if (obj.operation === 'deleteFreehandDrawing') {
|
|
12470
|
+
this.pointColl = obj.previousPointColl;
|
|
12471
|
+
this.freehandCounter = this.pointColl.length;
|
|
12181
12472
|
}
|
|
12182
|
-
else if (obj.
|
|
12183
|
-
this.objColl = obj.
|
|
12473
|
+
else if (obj.operation === 'deleteObj') {
|
|
12474
|
+
this.objColl = obj.previousObjColl;
|
|
12184
12475
|
}
|
|
12185
12476
|
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
12186
12477
|
this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
|
|
@@ -12188,7 +12479,7 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
12188
12479
|
this.redrawImgWithObj();
|
|
12189
12480
|
break;
|
|
12190
12481
|
case 'selectionTransform':
|
|
12191
|
-
this.activeObj = extend({}, obj.
|
|
12482
|
+
this.activeObj = extend({}, obj.previousObj.activeObj, {}, true);
|
|
12192
12483
|
this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
|
|
12193
12484
|
if (this.activeObj.activePoint.width !== 0 && this.activeObj.activePoint.height !== 0) {
|
|
12194
12485
|
this.drawObject('duplicate', this.activeObj);
|
|
@@ -12196,83 +12487,84 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
12196
12487
|
}
|
|
12197
12488
|
else {
|
|
12198
12489
|
this.refreshToolbar('main');
|
|
12490
|
+
this.performUndoDefaultAction(obj);
|
|
12199
12491
|
}
|
|
12200
12492
|
this.currObjType.isCustomCrop = false;
|
|
12201
12493
|
break;
|
|
12202
|
-
case '
|
|
12203
|
-
this.objColl = extend([], obj.
|
|
12204
|
-
|
|
12205
|
-
|
|
12206
|
-
|
|
12207
|
-
|
|
12208
|
-
|
|
12209
|
-
|
|
12210
|
-
|
|
12211
|
-
|
|
12212
|
-
|
|
12213
|
-
|
|
12214
|
-
prevObj = extend({}, obj.previousObj[i], {}, true);
|
|
12494
|
+
case 'textAreaCustomization':
|
|
12495
|
+
this.objColl = extend([], obj.previousObjColl, [], true);
|
|
12496
|
+
for (var i = 0; i < obj.previousObjColl.length; i++) {
|
|
12497
|
+
if (!isNullOrUndefined(this.tempActObj)) {
|
|
12498
|
+
if (this.tempActObj.currIndex === obj.previousObjColl[i].currIndex) {
|
|
12499
|
+
activeObj = extend({}, obj.previousObjColl[i], {}, true);
|
|
12500
|
+
this.objColl.splice(i, 1);
|
|
12501
|
+
break;
|
|
12502
|
+
}
|
|
12503
|
+
}
|
|
12504
|
+
else {
|
|
12505
|
+
activeObj = extend({}, obj.previousObjColl[obj.previousObjColl.length - 1], {}, true);
|
|
12215
12506
|
this.objColl.splice(i, 1);
|
|
12216
12507
|
break;
|
|
12217
12508
|
}
|
|
12218
12509
|
}
|
|
12219
|
-
if (!isNullOrUndefined(
|
|
12220
|
-
this.updateTextBox(
|
|
12510
|
+
if (!isNullOrUndefined(activeObj)) {
|
|
12511
|
+
this.updateTextBox(activeObj);
|
|
12221
12512
|
}
|
|
12222
12513
|
break;
|
|
12223
12514
|
case 'text':
|
|
12224
12515
|
if (!isNullOrUndefined(this.tempActObj)) {
|
|
12225
12516
|
this.activeObj = extend({}, this.tempActObj, {}, true);
|
|
12226
12517
|
}
|
|
12227
|
-
if (obj.
|
|
12518
|
+
if (obj.previousObjColl.length === 0 && this.objColl.length === 1) {
|
|
12228
12519
|
this.tempActObj = extend({}, this.objColl[0], {}, true);
|
|
12229
12520
|
}
|
|
12230
12521
|
else {
|
|
12231
12522
|
for (var i = 0; i < this.objColl.length; i++) {
|
|
12232
12523
|
if (!isNullOrUndefined(this.objColl[i]) &&
|
|
12233
|
-
isNullOrUndefined(obj.
|
|
12234
|
-
this.tempActObj = extend({},
|
|
12524
|
+
isNullOrUndefined(obj.previousObjColl[i])) {
|
|
12525
|
+
this.tempActObj = extend({}, this.objColl[i], {}, true);
|
|
12235
12526
|
break;
|
|
12236
12527
|
}
|
|
12237
|
-
if (obj.
|
|
12528
|
+
if (obj.previousObjColl[i].currIndex !== this.objColl[i].currIndex) {
|
|
12238
12529
|
this.tempActObj = extend({}, this.objColl[i], {}, true);
|
|
12239
12530
|
break;
|
|
12240
12531
|
}
|
|
12241
12532
|
}
|
|
12242
12533
|
}
|
|
12243
12534
|
this.activeObj = extend({}, this.tempActObj, {}, true);
|
|
12244
|
-
this.objColl = extend([], obj.
|
|
12535
|
+
this.objColl = extend([], obj.previousObjColl, [], true);
|
|
12245
12536
|
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
12246
12537
|
this.isUndoRedo = true;
|
|
12247
12538
|
this.redrawImgWithObj();
|
|
12248
|
-
this.
|
|
12249
|
-
|
|
12250
|
-
|
|
12251
|
-
|
|
12252
|
-
|
|
12253
|
-
|
|
12254
|
-
|
|
12255
|
-
case 'opacity':
|
|
12256
|
-
case 'blur':
|
|
12257
|
-
case 'exposure':
|
|
12258
|
-
this.lowerContext.filter = this.canvasFilter = obj.previousObj;
|
|
12259
|
-
if (this.lowerContext.filter.split(' ').length > 1 &&
|
|
12260
|
-
this.lowerContext.filter.split(' ')[0].split('(')[1].split(')')[0] === '1') {
|
|
12261
|
-
this.isBrightnessAdjusted = false;
|
|
12539
|
+
if (!isNullOrUndefined(this.activeObj) && this.activeObj.activePoint.width !== 0
|
|
12540
|
+
&& this.activeObj.activePoint.height !== 0) {
|
|
12541
|
+
this.drawObject('duplicate');
|
|
12542
|
+
}
|
|
12543
|
+
else {
|
|
12544
|
+
this.textArea.style.display = 'block';
|
|
12545
|
+
this.textArea.value = obj.previousText;
|
|
12262
12546
|
}
|
|
12263
|
-
this.setAdjustment(obj.operation);
|
|
12264
|
-
this.isUndoRedo = true;
|
|
12265
12547
|
break;
|
|
12266
|
-
|
|
12267
|
-
|
|
12268
|
-
|
|
12269
|
-
|
|
12270
|
-
case 'grayscale':
|
|
12271
|
-
case 'sepia':
|
|
12272
|
-
case 'invert':
|
|
12273
|
-
this.updateFilter(obj);
|
|
12548
|
+
default:
|
|
12549
|
+
this.performUndoDefaultAction(obj);
|
|
12550
|
+
this.setAdjustment(obj.operation);
|
|
12551
|
+
this.updateFilter(obj.operation, obj.filter);
|
|
12274
12552
|
break;
|
|
12275
12553
|
}
|
|
12554
|
+
this.clearOuterCanvas(this.lowerContext);
|
|
12555
|
+
if (this.isCircleCrop && obj.operation !== 'crop') {
|
|
12556
|
+
this.cropCircle(this.lowerContext);
|
|
12557
|
+
}
|
|
12558
|
+
if (this.zoomFactor > 0) {
|
|
12559
|
+
this.dragCanvas = true;
|
|
12560
|
+
}
|
|
12561
|
+
this.isCancelAction = false;
|
|
12562
|
+
if (!isNullOrUndefined(this.activeObj.shape) && this.activeObj.shape.split('-')[0] === 'crop') {
|
|
12563
|
+
this.refreshToolbar('main', true, true);
|
|
12564
|
+
}
|
|
12565
|
+
else {
|
|
12566
|
+
this.refreshToolbar('main');
|
|
12567
|
+
}
|
|
12276
12568
|
}
|
|
12277
12569
|
}
|
|
12278
12570
|
};
|
|
@@ -12294,7 +12586,6 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
12294
12586
|
this.undoRedoStep++;
|
|
12295
12587
|
this.enableDisableToolbarBtn();
|
|
12296
12588
|
this.isUndoRedo = true;
|
|
12297
|
-
this.lowerContext.filter = this.canvasFilter;
|
|
12298
12589
|
var obj = this.undoRedoColl[this.undoRedoStep - 1];
|
|
12299
12590
|
if (this.undoRedoColl.length === this.undoRedoStep) {
|
|
12300
12591
|
this.currObjType.isUndoAction = false;
|
|
@@ -12302,74 +12593,49 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
12302
12593
|
else {
|
|
12303
12594
|
this.currObjType.isUndoAction = true;
|
|
12304
12595
|
}
|
|
12305
|
-
if (obj.operation !== '
|
|
12596
|
+
if (obj.operation !== 'textAreaCustomization' && this.textArea.style.display === 'block') {
|
|
12306
12597
|
this.textArea.style.display = 'none';
|
|
12307
12598
|
}
|
|
12308
12599
|
this.element.querySelector('.e-contextual-toolbar-wrapper').classList.add('e-hide');
|
|
12309
|
-
|
|
12310
|
-
|
|
12311
|
-
|
|
12600
|
+
this.isCancelAction = true;
|
|
12601
|
+
this.cropObj = extend({}, obj.currentCropObj, {}, true);
|
|
12602
|
+
this.afterCropActions = obj.currentObj.afterCropActions;
|
|
12603
|
+
this.lowerContext.filter = this.canvasFilter = obj.currentObj.filter;
|
|
12604
|
+
var activeObj = void 0;
|
|
12312
12605
|
var tempUndoRedoColl = void 0;
|
|
12313
12606
|
var tempUndoRedoStep = void 0;
|
|
12314
|
-
var value = '';
|
|
12315
|
-
var currObj = void 0;
|
|
12316
12607
|
switch (obj.operation) {
|
|
12317
|
-
case '
|
|
12318
|
-
|
|
12319
|
-
|
|
12320
|
-
|
|
12321
|
-
|
|
12322
|
-
|
|
12323
|
-
|
|
12324
|
-
this.performTransformation(value);
|
|
12325
|
-
break;
|
|
12326
|
-
case 'flip':
|
|
12327
|
-
if (obj.value.toLowerCase() === 'horizontal') {
|
|
12328
|
-
value = 'horizontalflip';
|
|
12329
|
-
}
|
|
12330
|
-
else if (obj.value.toLowerCase() === 'vertical') {
|
|
12331
|
-
value = 'verticalflip';
|
|
12332
|
-
}
|
|
12333
|
-
this.performTransformation(value);
|
|
12334
|
-
break;
|
|
12335
|
-
case 'zoom':
|
|
12336
|
-
this.zoom(obj.value);
|
|
12337
|
-
break;
|
|
12338
|
-
case 'pan':
|
|
12339
|
-
xDiff = this.destLeft;
|
|
12340
|
-
yDiff = this.destTop;
|
|
12341
|
-
this.destLeft = obj.currentObj.x;
|
|
12342
|
-
this.destTop = obj.currentObj.y;
|
|
12343
|
-
xDiff += this.destLeft;
|
|
12344
|
-
yDiff += this.destTop;
|
|
12345
|
-
this.drawPannedImage(xDiff, yDiff);
|
|
12346
|
-
break;
|
|
12347
|
-
case 'crop':
|
|
12348
|
-
this.cropImg();
|
|
12349
|
-
this.refreshToolbar('main');
|
|
12608
|
+
case 'shapeTransform':
|
|
12609
|
+
this.objColl = extend([], obj.currentObjColl, [], true);
|
|
12610
|
+
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
12611
|
+
this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
|
|
12612
|
+
this.isUndoRedo = true;
|
|
12613
|
+
this.redrawImgWithObj();
|
|
12614
|
+
this.refreshActiveObj();
|
|
12350
12615
|
break;
|
|
12351
12616
|
case 'freehanddraw':
|
|
12352
|
-
this.pointColl = obj.
|
|
12353
|
-
this.freehandCounter
|
|
12617
|
+
this.pointColl = obj.currentPointColl;
|
|
12618
|
+
this.freehandCounter = this.pointColl.length;
|
|
12354
12619
|
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
12355
12620
|
this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
|
|
12356
12621
|
this.isUndoRedo = true;
|
|
12357
12622
|
this.redrawImgWithObj();
|
|
12358
12623
|
break;
|
|
12359
12624
|
case 'freehanddrawCustomized':
|
|
12360
|
-
this.pointColl = obj.
|
|
12625
|
+
this.pointColl = obj.currentPointColl;
|
|
12361
12626
|
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
12362
12627
|
this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
|
|
12363
12628
|
this.isUndoRedo = true;
|
|
12364
12629
|
this.redrawImgWithObj();
|
|
12365
12630
|
break;
|
|
12366
|
-
case '
|
|
12367
|
-
|
|
12368
|
-
|
|
12369
|
-
this.
|
|
12631
|
+
case 'deleteFreehandDrawing':
|
|
12632
|
+
case 'deleteObj':
|
|
12633
|
+
if (obj.operation === 'deleteFreehandDrawing') {
|
|
12634
|
+
this.pointColl = obj.currentPointColl;
|
|
12635
|
+
this.freehandCounter = this.pointColl.length;
|
|
12370
12636
|
}
|
|
12371
|
-
else if (obj.
|
|
12372
|
-
this.objColl = obj.
|
|
12637
|
+
else if (obj.operation === 'deleteObj') {
|
|
12638
|
+
this.objColl = obj.currentObjColl;
|
|
12373
12639
|
}
|
|
12374
12640
|
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
12375
12641
|
this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
|
|
@@ -12377,15 +12643,7 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
12377
12643
|
this.redrawImgWithObj();
|
|
12378
12644
|
break;
|
|
12379
12645
|
case 'selectionTransform':
|
|
12380
|
-
|
|
12381
|
-
if (this.zoomFactor > 0) {
|
|
12382
|
-
this.zoom(-this.zoomFactor);
|
|
12383
|
-
}
|
|
12384
|
-
else {
|
|
12385
|
-
this.zoom(Math.abs(this.zoomFactor));
|
|
12386
|
-
}
|
|
12387
|
-
}
|
|
12388
|
-
this.activeObj = extend({}, obj.currentSelectionObj, {}, true);
|
|
12646
|
+
this.activeObj = extend({}, obj.currentObj.activeObj, {}, true);
|
|
12389
12647
|
this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
|
|
12390
12648
|
if (this.activeObj.activePoint.width !== 0 && this.activeObj.activePoint.height !== 0) {
|
|
12391
12649
|
this.drawObject('duplicate', this.activeObj);
|
|
@@ -12394,38 +12652,57 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
12394
12652
|
else {
|
|
12395
12653
|
this.refreshToolbar('main');
|
|
12396
12654
|
}
|
|
12655
|
+
this.currObjType.isCustomCrop = false;
|
|
12397
12656
|
break;
|
|
12398
|
-
case '
|
|
12399
|
-
this.objColl = extend([], obj.
|
|
12400
|
-
|
|
12401
|
-
|
|
12402
|
-
|
|
12403
|
-
|
|
12404
|
-
|
|
12405
|
-
|
|
12406
|
-
|
|
12407
|
-
|
|
12408
|
-
|
|
12409
|
-
|
|
12410
|
-
currObj = extend({}, obj.currentObj[i], {}, true);
|
|
12657
|
+
case 'textAreaCustomization':
|
|
12658
|
+
this.objColl = extend([], obj.currentObjColl, [], true);
|
|
12659
|
+
for (var i = 0; i < obj.currentObjColl.length; i++) {
|
|
12660
|
+
if (!isNullOrUndefined(this.tempActObj)) {
|
|
12661
|
+
if (this.tempActObj.currIndex === obj.currentObjColl[i].currIndex) {
|
|
12662
|
+
activeObj = extend({}, obj.currentObjColl[i], {}, true);
|
|
12663
|
+
this.objColl.splice(i, 1);
|
|
12664
|
+
break;
|
|
12665
|
+
}
|
|
12666
|
+
}
|
|
12667
|
+
else {
|
|
12668
|
+
activeObj = extend({}, obj.currentObjColl[obj.currentObjColl.length - 1], {}, true);
|
|
12411
12669
|
this.objColl.splice(i, 1);
|
|
12412
12670
|
break;
|
|
12413
12671
|
}
|
|
12414
12672
|
}
|
|
12415
|
-
if (!isNullOrUndefined(
|
|
12416
|
-
this.updateTextBox(
|
|
12673
|
+
if (!isNullOrUndefined(activeObj)) {
|
|
12674
|
+
this.updateTextBox(activeObj);
|
|
12417
12675
|
}
|
|
12418
12676
|
break;
|
|
12419
12677
|
case 'text':
|
|
12420
12678
|
if (!isNullOrUndefined(this.tempActObj)) {
|
|
12421
12679
|
this.activeObj = extend({}, this.tempActObj, {}, true);
|
|
12422
12680
|
}
|
|
12423
|
-
|
|
12681
|
+
if (obj.previousObjColl.length === 0 && this.objColl.length === 1) {
|
|
12682
|
+
this.tempActObj = extend({}, this.objColl[0], {}, true);
|
|
12683
|
+
}
|
|
12684
|
+
else {
|
|
12685
|
+
for (var i = 0; i < this.objColl.length; i++) {
|
|
12686
|
+
if (!isNullOrUndefined(this.objColl[i]) &&
|
|
12687
|
+
isNullOrUndefined(obj.previousObjColl[i])) {
|
|
12688
|
+
this.tempActObj = extend({}, this.objColl[i], {}, true);
|
|
12689
|
+
break;
|
|
12690
|
+
}
|
|
12691
|
+
if (obj.previousObjColl[i].currIndex !== this.objColl[i].currIndex) {
|
|
12692
|
+
this.tempActObj = extend({}, this.objColl[i], {}, true);
|
|
12693
|
+
break;
|
|
12694
|
+
}
|
|
12695
|
+
}
|
|
12696
|
+
}
|
|
12697
|
+
this.objColl = extend([], obj.currentObjColl, [], true);
|
|
12424
12698
|
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
12425
12699
|
this.isUndoRedo = true;
|
|
12426
12700
|
this.redrawImgWithObj();
|
|
12701
|
+
if (!isNullOrUndefined(this.tempActObj)) {
|
|
12702
|
+
this.activeObj = extend({}, this.tempActObj, {}, true);
|
|
12703
|
+
}
|
|
12427
12704
|
this.textArea.style.display = 'block';
|
|
12428
|
-
this.textArea.value = obj.
|
|
12705
|
+
this.textArea.value = obj.currentText;
|
|
12429
12706
|
tempUndoRedoColl = extend([], this.undoRedoColl, [], true);
|
|
12430
12707
|
tempUndoRedoStep = this.undoRedoStep;
|
|
12431
12708
|
this.redrawActObj();
|
|
@@ -12433,39 +12710,49 @@ var ImageEditor = /** @class */ (function (_super) {
|
|
|
12433
12710
|
this.undoRedoStep = tempUndoRedoStep;
|
|
12434
12711
|
this.textArea.style.display = 'none';
|
|
12435
12712
|
this.textArea.value = '';
|
|
12713
|
+
this.redrawActObj();
|
|
12436
12714
|
break;
|
|
12437
|
-
|
|
12438
|
-
|
|
12439
|
-
|
|
12440
|
-
|
|
12441
|
-
|
|
12442
|
-
|
|
12443
|
-
|
|
12444
|
-
|
|
12445
|
-
this.
|
|
12446
|
-
|
|
12447
|
-
|
|
12448
|
-
|
|
12449
|
-
|
|
12450
|
-
|
|
12451
|
-
|
|
12452
|
-
|
|
12453
|
-
|
|
12454
|
-
if (
|
|
12455
|
-
|
|
12456
|
-
}
|
|
12457
|
-
if (document.getElementById(this.element.id + '_' + obj.operation + 'Canvas')) {
|
|
12458
|
-
document.getElementById(this.element.id + '_' + obj.operation + 'Canvas').parentElement.classList.add('e-selected');
|
|
12715
|
+
default:
|
|
12716
|
+
this.objColl = [];
|
|
12717
|
+
this.pointColl = [];
|
|
12718
|
+
this.freehandCounter = 0;
|
|
12719
|
+
this.setCurrentObj(obj.currentObj);
|
|
12720
|
+
this.destLeft = obj.currentObj.destPoints.startX;
|
|
12721
|
+
this.destTop = obj.currentObj.destPoints.startY;
|
|
12722
|
+
activeObj = extend({}, this.activeObj, {}, true);
|
|
12723
|
+
this.objColl = extend([], obj.currentObjColl, [], true);
|
|
12724
|
+
this.pointColl = extend([], obj.currentPointColl, [], true);
|
|
12725
|
+
this.freehandCounter = this.pointColl.length;
|
|
12726
|
+
this.lowerContext.filter = 'none';
|
|
12727
|
+
this.iterateObjColl();
|
|
12728
|
+
this.freehandRedraw(this.lowerContext);
|
|
12729
|
+
this.lowerContext.filter = obj.currentObj.filter;
|
|
12730
|
+
this.activeObj = activeObj;
|
|
12731
|
+
this.upperContext.clearRect(0, 0, this.upperCanvas.width, this.upperCanvas.height);
|
|
12732
|
+
if (this.activeObj.activePoint.width !== 0 && this.activeObj.activePoint.height !== 0) {
|
|
12733
|
+
this.drawObject('duplicate');
|
|
12459
12734
|
}
|
|
12460
|
-
this.
|
|
12461
|
-
this.
|
|
12462
|
-
this.lowerContext.clearRect(0, 0, this.lowerCanvas.width, this.lowerCanvas.height);
|
|
12463
|
-
this.redrawImgWithObj();
|
|
12735
|
+
this.setAdjustment(obj.operation);
|
|
12736
|
+
this.updateFilter(obj.operation);
|
|
12464
12737
|
break;
|
|
12465
12738
|
}
|
|
12739
|
+
this.clearOuterCanvas(this.lowerContext);
|
|
12740
|
+
if (this.isCircleCrop) {
|
|
12741
|
+
this.cropCircle(this.lowerContext);
|
|
12742
|
+
}
|
|
12743
|
+
if (this.zoomFactor > 0) {
|
|
12744
|
+
this.dragCanvas = true;
|
|
12745
|
+
}
|
|
12746
|
+
this.isCancelAction = false;
|
|
12466
12747
|
if (this.undoRedoStep === this.undoRedoColl.length) {
|
|
12467
12748
|
this.isUndoRedo = false;
|
|
12468
12749
|
}
|
|
12750
|
+
if (!isNullOrUndefined(this.activeObj.shape) && this.activeObj.shape.split('-')[0] === 'crop') {
|
|
12751
|
+
this.refreshToolbar('main', true, true);
|
|
12752
|
+
}
|
|
12753
|
+
else {
|
|
12754
|
+
this.refreshToolbar('main');
|
|
12755
|
+
}
|
|
12469
12756
|
}
|
|
12470
12757
|
}
|
|
12471
12758
|
};
|