@syncfusion/ej2-image-editor 29.1.35 → 29.1.38
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/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 +87 -23
- package/dist/es6/ej2-image-editor.es2015.js.map +1 -1
- package/dist/es6/ej2-image-editor.es5.js +88 -24
- package/dist/es6/ej2-image-editor.es5.js.map +1 -1
- package/dist/global/ej2-image-editor.min.js +2 -2
- package/dist/global/ej2-image-editor.min.js.map +1 -1
- package/dist/global/index.d.ts +1 -1
- package/package.json +10 -10
- package/src/image-editor/action/draw.d.ts +1 -0
- package/src/image-editor/action/draw.js +29 -9
- package/src/image-editor/action/selection.js +17 -9
- package/src/image-editor/action/shape.js +10 -6
- package/src/image-editor/renderer/toolbar.js +32 -0
|
@@ -972,6 +972,7 @@ class Draw {
|
|
|
972
972
|
this.imageBackgroundColor = '';
|
|
973
973
|
this.allowRedactStraighten = true;
|
|
974
974
|
this.isNullExtension = true;
|
|
975
|
+
this.isRedactStraighten = false;
|
|
975
976
|
this.parent = parent;
|
|
976
977
|
this.addEventListener();
|
|
977
978
|
}
|
|
@@ -1252,6 +1253,9 @@ class Draw {
|
|
|
1252
1253
|
case 'setNullExtension':
|
|
1253
1254
|
this.isNullExtension = args.value['extension'];
|
|
1254
1255
|
break;
|
|
1256
|
+
case 'setRedactStraighten':
|
|
1257
|
+
this.isRedactStraighten = args.value['bool'];
|
|
1258
|
+
break;
|
|
1255
1259
|
}
|
|
1256
1260
|
}
|
|
1257
1261
|
getModuleName() {
|
|
@@ -1305,6 +1309,7 @@ class Draw {
|
|
|
1305
1309
|
this.tempStrokeWidth = null;
|
|
1306
1310
|
this.straightenDestPoints = null;
|
|
1307
1311
|
this.isCropSelect = this.isDownScale = this.preventStraightening = false;
|
|
1312
|
+
this.isRedactStraighten = false;
|
|
1308
1313
|
}
|
|
1309
1314
|
redrawDownScale() {
|
|
1310
1315
|
const parent = this.parent;
|
|
@@ -6070,8 +6075,7 @@ class Draw {
|
|
|
6070
6075
|
const imageWidth = canvas.width;
|
|
6071
6076
|
const imageHeight = canvas.height;
|
|
6072
6077
|
const tempRatio = Math.min(imageWidth, imageHeight) / 1000;
|
|
6073
|
-
const straighten = this.parent.
|
|
6074
|
-
this.parent.cropObj.straighten;
|
|
6078
|
+
const straighten = Math.round(this.parent.activeObj.rotatedAngle * (180 / Math.PI));
|
|
6075
6079
|
if (this.allowRedactStraighten && straighten !== 0) {
|
|
6076
6080
|
const tempCanvas = document.createElement('canvas');
|
|
6077
6081
|
const tempCtx = tempCanvas.getContext('2d');
|
|
@@ -6081,9 +6085,9 @@ class Draw {
|
|
|
6081
6085
|
tempCtx.drawImage(canvas, 0, 0);
|
|
6082
6086
|
}
|
|
6083
6087
|
else {
|
|
6084
|
-
tempCanvas.width = img.destWidth;
|
|
6085
|
-
tempCanvas.height = img.destHeight;
|
|
6086
|
-
tempCtx.drawImage(this.lowerContext.canvas, img.destLeft, img.destTop
|
|
6088
|
+
tempCanvas.width = img.destWidth > canvas.width ? canvas.width : img.destWidth;
|
|
6089
|
+
tempCanvas.height = img.destHeight > canvas.height ? canvas.height : img.destHeight;
|
|
6090
|
+
tempCtx.drawImage(this.lowerContext.canvas, img.destLeft > 0 ? img.destLeft : 0, img.destTop > 0 ? img.destTop : 0, tempCanvas.width, tempCanvas.height, 0, 0, tempCanvas.width, tempCanvas.height);
|
|
6087
6091
|
}
|
|
6088
6092
|
const radians = -straighten * Math.PI / 180;
|
|
6089
6093
|
const straightenCanvas = document.createElement('canvas');
|
|
@@ -6138,10 +6142,14 @@ class Draw {
|
|
|
6138
6142
|
y: sinAngle * (p2.x - center.x) + cosAngle * (p2.y - center.y) + center.y };
|
|
6139
6143
|
const newP3 = { x: cosAngle * (p3.x - center.x) - sinAngle * (p3.y - center.y) + center.x,
|
|
6140
6144
|
y: sinAngle * (p3.x - center.x) + cosAngle * (p3.y - center.y) + center.y };
|
|
6141
|
-
const tempWidth = isSaveCtx ? canvasDraw.canvas.width :
|
|
6142
|
-
|
|
6145
|
+
const tempWidth = isSaveCtx ? canvasDraw.canvas.width :
|
|
6146
|
+
(img.destWidth > canvas.width ? canvas.width : img.destWidth);
|
|
6147
|
+
const tempHeight = isSaveCtx ? canvasDraw.canvas.height :
|
|
6148
|
+
(img.destHeight > canvas.height ? canvas.height : img.destHeight);
|
|
6143
6149
|
const rotatedWidth = Math.abs(tempWidth * Math.cos(radians)) + Math.abs(tempHeight * Math.sin(radians));
|
|
6144
6150
|
const rotatedHeight = Math.abs(tempWidth * Math.sin(radians)) + Math.abs(tempHeight * Math.cos(radians));
|
|
6151
|
+
const prevWidth = straightenCanvas.width;
|
|
6152
|
+
const prevHeight = straightenCanvas.height;
|
|
6145
6153
|
straightenCanvas.width = rotatedWidth;
|
|
6146
6154
|
straightenCanvas.height = rotatedHeight;
|
|
6147
6155
|
straightenCtx.save();
|
|
@@ -6152,7 +6160,13 @@ class Draw {
|
|
|
6152
6160
|
if (this.parent.activeObj.redactType === 'blur') {
|
|
6153
6161
|
offscreenCanvas.width = width;
|
|
6154
6162
|
offscreenCanvas.height = height;
|
|
6155
|
-
|
|
6163
|
+
let x = newP1.x + ((rotatedWidth - prevWidth) / 2);
|
|
6164
|
+
let y = newP1.y + ((rotatedHeight - prevHeight) / 2);
|
|
6165
|
+
if (this.isRedactStraighten) {
|
|
6166
|
+
x = startX + ((rotatedWidth - prevWidth) / 2);
|
|
6167
|
+
y = startY + ((rotatedHeight - prevHeight) / 2);
|
|
6168
|
+
}
|
|
6169
|
+
offscreenCtx.drawImage(straightenCanvas, x, y, newP2.x - newP1.x, newP3.y - newP2.y, 0, 0, width, height);
|
|
6156
6170
|
}
|
|
6157
6171
|
else {
|
|
6158
6172
|
let pixelSize = (obj.redactPixelate / 100) * 20;
|
|
@@ -6161,7 +6175,13 @@ class Draw {
|
|
|
6161
6175
|
}
|
|
6162
6176
|
offscreenCanvas.width = Math.ceil(width / pixelSize);
|
|
6163
6177
|
offscreenCanvas.height = Math.ceil(height / pixelSize);
|
|
6164
|
-
|
|
6178
|
+
let x = newP1.x + ((rotatedWidth - prevWidth) / 2);
|
|
6179
|
+
let y = newP1.y + ((rotatedHeight - prevHeight) / 2);
|
|
6180
|
+
if (this.isRedactStraighten) {
|
|
6181
|
+
x = startX + ((rotatedWidth - prevWidth) / 2);
|
|
6182
|
+
y = startY + ((rotatedHeight - prevHeight) / 2);
|
|
6183
|
+
}
|
|
6184
|
+
offscreenCtx.drawImage(straightenCanvas, x, y, newP2.x - newP1.x, newP3.y - newP2.y, 0, 0, offscreenCanvas.width, offscreenCanvas.height);
|
|
6165
6185
|
}
|
|
6166
6186
|
}
|
|
6167
6187
|
if (this.parent.activeObj.redactType === 'blur') {
|
|
@@ -10404,18 +10424,22 @@ class Selection {
|
|
|
10404
10424
|
let endY = isStart ? actPoint.endY : actPoint.startY;
|
|
10405
10425
|
const wrapperWidth = parent.upperCanvas.width;
|
|
10406
10426
|
const wrapperHeight = parent.upperCanvas.height;
|
|
10427
|
+
const minX = destLeft < 0 ? 0 : destLeft;
|
|
10428
|
+
const minY = destTop < 0 ? 0 : destTop;
|
|
10429
|
+
const maxX = destLeft + destWidth > wrapperWidth ? wrapperWidth : destLeft + destWidth;
|
|
10430
|
+
const maxY = destTop + destHeight > wrapperHeight ? wrapperHeight : destTop + destHeight;
|
|
10407
10431
|
if (Browser.isDevice) {
|
|
10408
|
-
if (startX <
|
|
10409
|
-
startX =
|
|
10432
|
+
if (startX < minX) {
|
|
10433
|
+
startX = minX;
|
|
10410
10434
|
}
|
|
10411
|
-
if (startY <
|
|
10412
|
-
startY =
|
|
10435
|
+
if (startY < minY) {
|
|
10436
|
+
startY = minY;
|
|
10413
10437
|
}
|
|
10414
|
-
if (endX >
|
|
10415
|
-
endX =
|
|
10438
|
+
if (endX > maxX) {
|
|
10439
|
+
endX = maxX;
|
|
10416
10440
|
}
|
|
10417
|
-
if (endY >
|
|
10418
|
-
endY =
|
|
10441
|
+
if (endY > maxY) {
|
|
10442
|
+
endY = maxY;
|
|
10419
10443
|
}
|
|
10420
10444
|
}
|
|
10421
10445
|
else {
|
|
@@ -12319,7 +12343,11 @@ class Selection {
|
|
|
12319
12343
|
parent.editCompleteArgs = shapeChangedArgs;
|
|
12320
12344
|
}
|
|
12321
12345
|
const isPenDraw = parent.togglePen;
|
|
12346
|
+
const tempCursor = parent.cursor;
|
|
12322
12347
|
parent.notify('toolbar', { prop: 'close-contextual-toolbar', onPropertyChange: false });
|
|
12348
|
+
if (activeObj.shape === 'redact' && tempCursor !== 'default') {
|
|
12349
|
+
parent.cursor = tempCursor;
|
|
12350
|
+
}
|
|
12323
12351
|
if (isPenDraw) {
|
|
12324
12352
|
parent.freeHandDraw(true);
|
|
12325
12353
|
}
|
|
@@ -15313,7 +15341,9 @@ class Shape {
|
|
|
15313
15341
|
parent.pointColl[shapeId].strokeColor = shapeSettings.strokeColor;
|
|
15314
15342
|
parent.pointColl[shapeId].strokeWidth = shapeSettings.strokeWidth;
|
|
15315
15343
|
parent.pointColl[shapeId].opacity = shapeSettings.opacity;
|
|
15316
|
-
|
|
15344
|
+
if (shapeSettings.index) {
|
|
15345
|
+
parent.pointColl[shapeId].order = shapeSettings.index;
|
|
15346
|
+
}
|
|
15317
15347
|
}
|
|
15318
15348
|
else {
|
|
15319
15349
|
parent.activeObj.activePoint.startX = shapeSettings.startX;
|
|
@@ -15330,7 +15360,9 @@ class Shape {
|
|
|
15330
15360
|
}
|
|
15331
15361
|
parent.activeObj.strokeSettings.fillColor = shapeSettings.fillColor;
|
|
15332
15362
|
parent.activeObj.opacity = shapeSettings.opacity;
|
|
15333
|
-
|
|
15363
|
+
if (shapeSettings.index) {
|
|
15364
|
+
parent.activeObj.order = shapeSettings.index;
|
|
15365
|
+
}
|
|
15334
15366
|
parent.activeObj.preventShapeDragOut = !allowShapeOverflow;
|
|
15335
15367
|
if (isNullOrUndefined(shapeSettings.degree)) {
|
|
15336
15368
|
shapeSettings.degree = 0;
|
|
@@ -17150,16 +17182,16 @@ class Shape {
|
|
|
17150
17182
|
const parent = this.parent;
|
|
17151
17183
|
const style = parent.textArea.style;
|
|
17152
17184
|
if (style.display === 'block' || style.display === 'inline-block') {
|
|
17153
|
-
if (
|
|
17185
|
+
if (fontWeight === 'bold') {
|
|
17154
17186
|
style.fontWeight = 'bold';
|
|
17155
17187
|
}
|
|
17156
|
-
else
|
|
17188
|
+
else {
|
|
17157
17189
|
style.fontWeight = 'normal';
|
|
17158
17190
|
}
|
|
17159
|
-
if (
|
|
17191
|
+
if (fontStyle === 'italic') {
|
|
17160
17192
|
style.fontStyle = 'italic';
|
|
17161
17193
|
}
|
|
17162
|
-
else
|
|
17194
|
+
else {
|
|
17163
17195
|
style.fontStyle = 'normal';
|
|
17164
17196
|
}
|
|
17165
17197
|
const value = (style.fontWeight === 'normal' && style.fontStyle === 'normal' ? 'default' :
|
|
@@ -32073,6 +32105,9 @@ class ToolbarModule {
|
|
|
32073
32105
|
let actionType;
|
|
32074
32106
|
let actionArgs;
|
|
32075
32107
|
let isRedactClick = false;
|
|
32108
|
+
let zoomLevel = 0;
|
|
32109
|
+
let actObj;
|
|
32110
|
+
let isRedact = false;
|
|
32076
32111
|
if (parent.activeObj.shape !== undefined) {
|
|
32077
32112
|
splitWords = parent.activeObj.shape.split('-');
|
|
32078
32113
|
}
|
|
@@ -32322,7 +32357,36 @@ class ToolbarModule {
|
|
|
32322
32357
|
case 'horizontalflip':
|
|
32323
32358
|
case 'verticalflip':
|
|
32324
32359
|
parent.transformSelect(type);
|
|
32360
|
+
for (let i = 0; i < parent.objColl.length; i++) {
|
|
32361
|
+
if (parent.objColl[i].shape === 'redact') {
|
|
32362
|
+
isRedact = true;
|
|
32363
|
+
break;
|
|
32364
|
+
}
|
|
32365
|
+
}
|
|
32366
|
+
if (isRedact) {
|
|
32367
|
+
parent.notify('draw', { prop: 'setRedactStraighten', value: { bool: true } });
|
|
32368
|
+
actObj = extend({}, parent.activeObj, {}, true);
|
|
32369
|
+
while (parent.img.destLeft < 0 || parent.img.destTop < 0) {
|
|
32370
|
+
parent.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
|
|
32371
|
+
parent.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
|
|
32372
|
+
value: { zoomFactor: -.125, zoomPoint: null, isResize: false } });
|
|
32373
|
+
zoomLevel += 1;
|
|
32374
|
+
}
|
|
32375
|
+
}
|
|
32325
32376
|
this.updateRedactObj();
|
|
32377
|
+
if (isRedact) {
|
|
32378
|
+
if (zoomLevel > 0) {
|
|
32379
|
+
parent.isCropTab = true;
|
|
32380
|
+
for (let i = 0; i < zoomLevel; i++) {
|
|
32381
|
+
parent.notify('shape', { prop: 'refreshActiveObj', onPropertyChange: false });
|
|
32382
|
+
parent.notify('transform', { prop: 'zoomAction', onPropertyChange: false,
|
|
32383
|
+
value: { zoomFactor: .125, zoomPoint: null, isResize: false } });
|
|
32384
|
+
}
|
|
32385
|
+
parent.activeObj = actObj;
|
|
32386
|
+
parent.notify('draw', { prop: 'drawObject', onPropertyChange: false, value: { canvas: 'duplicate' } });
|
|
32387
|
+
}
|
|
32388
|
+
parent.notify('draw', { prop: 'setRedactStraighten', value: { bool: false } });
|
|
32389
|
+
}
|
|
32326
32390
|
if (type === 'rotateleft' || type === 'rotateright') {
|
|
32327
32391
|
parent.notify('draw', { prop: 'resetStraightenDestPoints' });
|
|
32328
32392
|
parent.notify('draw', { prop: 'setDestForStraighten' });
|