@syncfusion/ej2-image-editor 23.2.7 → 24.1.41
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 +3 -59
- 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 +7146 -4325
- package/dist/es6/ej2-image-editor.es2015.js.map +1 -1
- package/dist/es6/ej2-image-editor.es5.js +7215 -4381
- 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 +12 -12
- package/src/image-editor/action/crop.d.ts +6 -0
- package/src/image-editor/action/crop.js +347 -188
- package/src/image-editor/action/draw.d.ts +35 -2
- package/src/image-editor/action/draw.js +1682 -881
- package/src/image-editor/action/export.js +90 -29
- package/src/image-editor/action/filter.d.ts +3 -1
- package/src/image-editor/action/filter.js +74 -94
- package/src/image-editor/action/freehand-draw.d.ts +4 -0
- package/src/image-editor/action/freehand-draw.js +248 -147
- package/src/image-editor/action/selection.d.ts +6 -1
- package/src/image-editor/action/selection.js +1133 -1091
- package/src/image-editor/action/shape.d.ts +7 -0
- package/src/image-editor/action/shape.js +921 -550
- package/src/image-editor/action/transform.d.ts +2 -0
- package/src/image-editor/action/transform.js +514 -346
- package/src/image-editor/action/undo-redo.d.ts +2 -0
- package/src/image-editor/action/undo-redo.js +137 -36
- package/src/image-editor/base/enum.d.ts +2 -1
- package/src/image-editor/base/enum.js +1 -0
- package/src/image-editor/base/image-editor-model.d.ts +37 -2
- package/src/image-editor/base/image-editor.d.ts +124 -3
- package/src/image-editor/base/image-editor.js +672 -171
- package/src/image-editor/base/interface.d.ts +69 -15
- package/src/image-editor/renderer/toolbar.d.ts +10 -0
- package/src/image-editor/renderer/toolbar.js +1371 -822
- package/styles/bootstrap-dark.css +113 -8
- package/styles/bootstrap.css +112 -7
- package/styles/bootstrap4.css +113 -8
- package/styles/bootstrap5-dark.css +113 -8
- package/styles/bootstrap5.css +113 -8
- package/styles/fabric-dark.css +114 -9
- package/styles/fabric.css +113 -8
- package/styles/fluent-dark.css +118 -9
- package/styles/fluent.css +118 -9
- package/styles/highcontrast-light.css +112 -7
- package/styles/highcontrast.css +116 -7
- package/styles/image-editor/_bootstrap-dark-definition.scss +3 -0
- package/styles/image-editor/_bootstrap-definition.scss +3 -0
- package/styles/image-editor/_bootstrap4-definition.scss +3 -0
- package/styles/image-editor/_bootstrap5-definition.scss +3 -0
- package/styles/image-editor/_fabric-dark-definition.scss +3 -0
- package/styles/image-editor/_fabric-definition.scss +3 -0
- package/styles/image-editor/_fluent-definition.scss +3 -0
- package/styles/image-editor/_fusionnew-definition.scss +3 -0
- package/styles/image-editor/_highcontrast-definition.scss +3 -0
- package/styles/image-editor/_highcontrast-light-definition.scss +3 -0
- package/styles/image-editor/_layout.scss +138 -4
- package/styles/image-editor/_material-dark-definition.scss +3 -0
- package/styles/image-editor/_material-definition.scss +3 -0
- package/styles/image-editor/_material3-definition.scss +3 -0
- package/styles/image-editor/_tailwind-definition.scss +3 -0
- package/styles/image-editor/_theme.scss +2 -4
- package/styles/image-editor/bootstrap-dark.css +113 -8
- package/styles/image-editor/bootstrap.css +112 -7
- package/styles/image-editor/bootstrap4.css +113 -8
- package/styles/image-editor/bootstrap5-dark.css +113 -8
- package/styles/image-editor/bootstrap5.css +113 -8
- package/styles/image-editor/fabric-dark.css +114 -9
- package/styles/image-editor/fabric.css +113 -8
- package/styles/image-editor/fluent-dark.css +118 -9
- package/styles/image-editor/fluent.css +118 -9
- package/styles/image-editor/highcontrast-light.css +112 -7
- package/styles/image-editor/highcontrast.css +116 -7
- package/styles/image-editor/icons/_bootstrap-dark.scss +60 -0
- package/styles/image-editor/icons/_bootstrap.scss +60 -0
- package/styles/image-editor/icons/_bootstrap4.scss +60 -0
- package/styles/image-editor/icons/_bootstrap5.scss +60 -0
- package/styles/image-editor/icons/_fabric-dark.scss +60 -0
- package/styles/image-editor/icons/_fabric.scss +60 -0
- package/styles/image-editor/icons/_fluent.scss +66 -0
- package/styles/image-editor/icons/_highcontrast-light.scss +60 -0
- package/styles/image-editor/icons/_highcontrast.scss +60 -0
- package/styles/image-editor/icons/_material-dark.scss +60 -0
- package/styles/image-editor/icons/_material.scss +60 -0
- package/styles/image-editor/icons/_material3.scss +60 -0
- package/styles/image-editor/icons/_tailwind.scss +60 -0
- package/styles/image-editor/material-dark.css +113 -8
- package/styles/image-editor/material.css +113 -8
- package/styles/image-editor/material3-dark.css +126 -9
- package/styles/image-editor/material3.css +126 -9
- package/styles/image-editor/tailwind-dark.css +114 -9
- package/styles/image-editor/tailwind.css +114 -9
- package/styles/material-dark.css +113 -8
- package/styles/material.css +113 -8
- package/styles/material3-dark.css +126 -9
- package/styles/material3.css +126 -9
- package/styles/tailwind-dark.css +114 -9
- package/styles/tailwind.css +114 -9
|
@@ -2,7 +2,7 @@ import { EventHandler, extend, isBlazor, isNullOrUndefined } from '@syncfusion/e
|
|
|
2
2
|
import { ShapeType } from '../index';
|
|
3
3
|
var Shape = /** @class */ (function () {
|
|
4
4
|
function Shape(parent) {
|
|
5
|
-
this.textSettings = { text: 'Enter Text', fontFamily: '
|
|
5
|
+
this.textSettings = { text: 'Enter Text', fontFamily: '', fontSize: null, fontRatio: null, bold: false, italic: false, underline: false };
|
|
6
6
|
this.strokeSettings = { strokeColor: '#fff', fillColor: '', strokeWidth: null };
|
|
7
7
|
this.keyHistory = ''; // text history
|
|
8
8
|
this.parent = parent;
|
|
@@ -23,6 +23,7 @@ var Shape = /** @class */ (function () {
|
|
|
23
23
|
this.parent.off('destroyed', this.destroy);
|
|
24
24
|
};
|
|
25
25
|
Shape.prototype.shape = function (args) {
|
|
26
|
+
var parent = this.parent;
|
|
26
27
|
this.initShapePvtProps();
|
|
27
28
|
var uploader;
|
|
28
29
|
switch (args.prop) {
|
|
@@ -120,17 +121,17 @@ var Shape = /** @class */ (function () {
|
|
|
120
121
|
this.applyActObj(args.value['isMouseDown']);
|
|
121
122
|
break;
|
|
122
123
|
case 'wireEvent':
|
|
123
|
-
EventHandler.add(
|
|
124
|
-
EventHandler.add(
|
|
125
|
-
uploader = document.getElementById(
|
|
124
|
+
EventHandler.add(parent.upperCanvas, 'dblclick', this.findTextTarget, this);
|
|
125
|
+
EventHandler.add(parent.textArea, 'mousedown', this.findTextTarget, this);
|
|
126
|
+
uploader = document.getElementById(parent.element.id + '_fileUpload');
|
|
126
127
|
if (uploader) {
|
|
127
128
|
EventHandler.add(uploader, 'change', this.fileChanged, this);
|
|
128
129
|
}
|
|
129
130
|
break;
|
|
130
131
|
case 'unWireEvent':
|
|
131
|
-
EventHandler.remove(
|
|
132
|
-
EventHandler.remove(
|
|
133
|
-
uploader = document.getElementById(
|
|
132
|
+
EventHandler.remove(parent.upperCanvas, 'dblclick', this.findTextTarget);
|
|
133
|
+
EventHandler.remove(parent.textArea, 'mousedown', this.findTextTarget);
|
|
134
|
+
uploader = document.getElementById(parent.element.id + '_fileUpload');
|
|
134
135
|
EventHandler.remove(uploader, 'change', this.fileChanged);
|
|
135
136
|
break;
|
|
136
137
|
case 'getShapeSetting':
|
|
@@ -216,7 +217,7 @@ var Shape = /** @class */ (function () {
|
|
|
216
217
|
this.getSquarePointForRotatedShape(args.value['obj'], args.value['object']);
|
|
217
218
|
break;
|
|
218
219
|
case 'drawImage':
|
|
219
|
-
this.drawImage(args.value['x'], args.value['y'], args.value['width'], args.value['height'], args.value['src'], args.value['degree'], args.value['isAspectRatio']);
|
|
220
|
+
this.drawImage(args.value['x'], args.value['y'], args.value['width'], args.value['height'], args.value['src'], args.value['degree'], args.value['isAspectRatio'], args.value['opacity']);
|
|
220
221
|
break;
|
|
221
222
|
case 'reset':
|
|
222
223
|
this.reset();
|
|
@@ -227,30 +228,52 @@ var Shape = /** @class */ (function () {
|
|
|
227
228
|
case 'updateObj':
|
|
228
229
|
this.updateObj(args.value['dimObj'], args.value['x'], args.value['y']);
|
|
229
230
|
break;
|
|
231
|
+
case 'straightenShapes':
|
|
232
|
+
this.straightenShapes();
|
|
233
|
+
break;
|
|
234
|
+
case 'straightenShapePoints':
|
|
235
|
+
this.straightenShapePoints(args.value['obj'], args.value['isReverse']);
|
|
236
|
+
break;
|
|
237
|
+
case 'straightenPath':
|
|
238
|
+
this.straightenPath(args.value['obj']);
|
|
239
|
+
break;
|
|
240
|
+
case 'straightenFHD':
|
|
241
|
+
this.straightenFHD();
|
|
242
|
+
break;
|
|
243
|
+
case 'getTextBoxPosition':
|
|
244
|
+
this.getTextBoxPosition(args.value['obj'], args.value['object']);
|
|
245
|
+
break;
|
|
230
246
|
case 'updateSelectionChangeEventArgs':
|
|
231
247
|
this.updateSelectionChangeEventArgs(args.value['selectionSettings']);
|
|
232
248
|
break;
|
|
249
|
+
case 'setFlipState':
|
|
250
|
+
this.setFlipState(args.value['x'], args.value['y'], args.value['obj'], args.value['object']);
|
|
251
|
+
break;
|
|
233
252
|
}
|
|
234
253
|
};
|
|
235
254
|
Shape.prototype.getModuleName = function () {
|
|
236
255
|
return 'shape';
|
|
237
256
|
};
|
|
238
257
|
Shape.prototype.initShapePvtProps = function () {
|
|
239
|
-
|
|
240
|
-
|
|
258
|
+
var parent = this.parent;
|
|
259
|
+
if (parent.lowerCanvas) {
|
|
260
|
+
this.lowerContext = parent.lowerCanvas.getContext('2d');
|
|
241
261
|
}
|
|
242
|
-
if (
|
|
243
|
-
this.upperContext =
|
|
262
|
+
if (parent.upperCanvas) {
|
|
263
|
+
this.upperContext = parent.upperCanvas.getContext('2d');
|
|
244
264
|
}
|
|
245
265
|
if (isNullOrUndefined(this.shapeImg)) {
|
|
246
|
-
this.shapeImg =
|
|
247
|
-
id:
|
|
266
|
+
this.shapeImg = parent.createElement('img', {
|
|
267
|
+
id: parent.element.id + '_shapeImg', attrs: { name: 'Image', crossorigin: 'anonymous' }
|
|
248
268
|
});
|
|
249
269
|
}
|
|
270
|
+
if (this.textSettings.fontFamily === '') {
|
|
271
|
+
this.textSettings.fontFamily = parent.fontFamily.default;
|
|
272
|
+
}
|
|
250
273
|
};
|
|
251
274
|
Shape.prototype.reset = function () {
|
|
252
275
|
this.textSettings =
|
|
253
|
-
{ text: 'Enter Text', fontFamily:
|
|
276
|
+
{ text: 'Enter Text', fontFamily: this.parent.fontFamily.default, fontSize: null, fontRatio: null, bold: false, italic: false, underline: false };
|
|
254
277
|
this.strokeSettings = { strokeColor: '#fff', fillColor: '', strokeWidth: null };
|
|
255
278
|
};
|
|
256
279
|
Shape.prototype.drawEllipse = function (x, y, radiusX, radiusY, strokeWidth, strokeColor, fillColor, degree) {
|
|
@@ -266,18 +289,19 @@ var Shape = /** @class */ (function () {
|
|
|
266
289
|
this.drawShape('line', strokeWidth, strokeColor, null, start, width, height);
|
|
267
290
|
};
|
|
268
291
|
Shape.prototype.drawPath = function (pointColl, strokeWidth, strokeColor) {
|
|
292
|
+
var parent = this.parent;
|
|
269
293
|
this.initializeShape('path');
|
|
270
294
|
if (pointColl) {
|
|
271
295
|
this.drawShape('path', strokeWidth, strokeColor, null, null, null, null, pointColl);
|
|
272
296
|
}
|
|
273
297
|
else {
|
|
274
|
-
this.drawShape('line', strokeWidth, strokeColor
|
|
275
|
-
var obj = extend({},
|
|
298
|
+
this.drawShape('line', strokeWidth, strokeColor);
|
|
299
|
+
var obj = extend({}, parent.objColl[parent.objColl.length - 1], null, true);
|
|
276
300
|
obj.shape = 'path';
|
|
277
301
|
obj.lineDraw = null;
|
|
278
302
|
obj.pointColl = [{ x: obj.activePoint.startX, y: obj.activePoint.startY },
|
|
279
303
|
{ x: obj.activePoint.endX, y: obj.activePoint.endY }];
|
|
280
|
-
|
|
304
|
+
parent.objColl[parent.objColl.length - 1] = obj;
|
|
281
305
|
}
|
|
282
306
|
};
|
|
283
307
|
Shape.prototype.drawArrow = function (startX, startY, endX, endY, strokeWidth, strokeColor, arrowStart, arrowEnd) {
|
|
@@ -296,14 +320,15 @@ var Shape = /** @class */ (function () {
|
|
|
296
320
|
this.drawShapeText(text, fontFamily, fontSize, bold, italic, color, x, y);
|
|
297
321
|
};
|
|
298
322
|
Shape.prototype.initializeShape = function (type) {
|
|
323
|
+
var parent = this.parent;
|
|
299
324
|
this.redrawActObj();
|
|
300
|
-
|
|
301
|
-
if (
|
|
325
|
+
parent.activeObj.shape = type;
|
|
326
|
+
if (parent.currObjType.shape === 'freehanddraw') {
|
|
302
327
|
this.apply();
|
|
303
|
-
|
|
304
|
-
|
|
328
|
+
parent.upperCanvas.style.cursor = parent.cursor = 'default';
|
|
329
|
+
parent.currObjType.shape = '';
|
|
305
330
|
}
|
|
306
|
-
|
|
331
|
+
parent.currObjType.isCustomCrop = false;
|
|
307
332
|
};
|
|
308
333
|
Shape.prototype.updateWidthHeight = function (obj) {
|
|
309
334
|
obj.activePoint.width = obj.activePoint.endX - obj.activePoint.startX;
|
|
@@ -311,12 +336,13 @@ var Shape = /** @class */ (function () {
|
|
|
311
336
|
return obj;
|
|
312
337
|
};
|
|
313
338
|
Shape.prototype.setDimension = function (width, height) {
|
|
339
|
+
var parent = this.parent;
|
|
314
340
|
if (width && height) {
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
if (
|
|
318
|
-
|
|
319
|
-
|
|
341
|
+
parent.activeObj.activePoint.width = width;
|
|
342
|
+
parent.activeObj.activePoint.height = height;
|
|
343
|
+
if (parent.currObjType.shape.toLowerCase() === 'ellipse') {
|
|
344
|
+
parent.activeObj.activePoint.width = 2 * width;
|
|
345
|
+
parent.activeObj.activePoint.height = 2 * height;
|
|
320
346
|
}
|
|
321
347
|
}
|
|
322
348
|
};
|
|
@@ -329,7 +355,7 @@ var Shape = /** @class */ (function () {
|
|
|
329
355
|
}
|
|
330
356
|
return arrowType;
|
|
331
357
|
};
|
|
332
|
-
Shape.prototype.drawShape = function (type, strokeWidth, strokeColor, fillColor, start, width, height, pointColl, arrowStart, arrowEnd, degree) {
|
|
358
|
+
Shape.prototype.drawShape = function (type, strokeWidth, strokeColor, fillColor, start, width, height, pointColl, arrowStart, arrowEnd, degree, opacity) {
|
|
333
359
|
var _this = this;
|
|
334
360
|
var parent = this.parent;
|
|
335
361
|
if (!parent.disabled && parent.isImageLoaded) {
|
|
@@ -338,13 +364,13 @@ var Shape = /** @class */ (function () {
|
|
|
338
364
|
var objColl_1 = extend([], parent.objColl, [], true);
|
|
339
365
|
parent.togglePen = false;
|
|
340
366
|
this.keyHistory = '';
|
|
341
|
-
|
|
367
|
+
parent.upperCanvas.style.display = 'block';
|
|
342
368
|
this.refreshActiveObj();
|
|
343
|
-
parent.currObjType.shape = type;
|
|
344
|
-
if (
|
|
345
|
-
parent.activeObj.shape =
|
|
369
|
+
parent.currObjType.shape = type = type.toLowerCase();
|
|
370
|
+
if (type === 'path' && isNullOrUndefined(pointColl)) {
|
|
371
|
+
parent.activeObj.shape = type;
|
|
346
372
|
parent.activeObj.pointColl = [];
|
|
347
|
-
parent.upperCanvas.style.cursor =
|
|
373
|
+
parent.upperCanvas.style.cursor = parent.cursor = 'crosshair';
|
|
348
374
|
parent.notify('selection', { prop: 'setCurrentDrawingShape', onPropertyChange: false, value: { value: 'path' } });
|
|
349
375
|
if (!isBlazor()) {
|
|
350
376
|
parent.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: { type: 'shapes',
|
|
@@ -353,32 +379,36 @@ var Shape = /** @class */ (function () {
|
|
|
353
379
|
}
|
|
354
380
|
}
|
|
355
381
|
else {
|
|
356
|
-
if (
|
|
357
|
-
parent.activeObj.shape =
|
|
382
|
+
if (type !== 'freehanddraw' && type !== '') {
|
|
383
|
+
parent.activeObj.shape = type;
|
|
384
|
+
var strokeSettings = parent.activeObj.strokeSettings;
|
|
358
385
|
this.upperContext.clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
|
|
359
|
-
if (isNullOrUndefined(
|
|
360
|
-
|
|
386
|
+
if (isNullOrUndefined(strokeSettings)) {
|
|
387
|
+
strokeSettings = this.strokeSettings;
|
|
361
388
|
}
|
|
362
|
-
if (
|
|
389
|
+
if (type === 'path' && pointColl) {
|
|
363
390
|
parent.activeObj.pointColl = pointColl;
|
|
364
391
|
}
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
392
|
+
if (opacity !== null && opacity !== undefined) {
|
|
393
|
+
parent.activeObj.opacity = opacity;
|
|
394
|
+
}
|
|
395
|
+
strokeSettings.strokeWidth = strokeWidth ? strokeWidth : strokeSettings.strokeWidth;
|
|
396
|
+
strokeSettings.strokeColor = strokeColor ? strokeColor : strokeSettings.strokeColor;
|
|
397
|
+
strokeSettings.fillColor = fillColor ? fillColor : strokeSettings.fillColor;
|
|
368
398
|
var tempWidth = parent.img.destWidth > 100 ? 100 : parent.img.destWidth / 2;
|
|
369
399
|
var tempHeight = parent.img.destHeight > 100 ? 100 : parent.img.destHeight / 2;
|
|
370
400
|
parent.activeObj.activePoint.width = tempWidth;
|
|
371
401
|
parent.activeObj.activePoint.height = tempHeight;
|
|
372
|
-
if (
|
|
402
|
+
if (type === 'line' || type === 'arrow') {
|
|
373
403
|
parent.activeObj.lineDraw = 'horizontal';
|
|
374
404
|
parent.activeObj.activePoint.height = 0;
|
|
375
|
-
if (
|
|
405
|
+
if (type === 'arrow') {
|
|
376
406
|
parent.activeObj.activePoint.width += 50;
|
|
377
407
|
parent.activeObj.start = this.getArrowType(arrowStart);
|
|
378
408
|
parent.activeObj.end = this.getArrowType(arrowEnd);
|
|
379
409
|
}
|
|
380
410
|
}
|
|
381
|
-
else if (
|
|
411
|
+
else if (type === 'rectangle') {
|
|
382
412
|
parent.activeObj.activePoint.width += parent.activeObj.activePoint.width / 2;
|
|
383
413
|
}
|
|
384
414
|
this.setDimension(width, height);
|
|
@@ -394,7 +424,7 @@ var Shape = /** @class */ (function () {
|
|
|
394
424
|
this.setCenterPoints();
|
|
395
425
|
}
|
|
396
426
|
this.setPointCollForLineAndArrow();
|
|
397
|
-
if (
|
|
427
|
+
if (type === 'arrow') {
|
|
398
428
|
parent.activeObj.triangleDirection = 'right';
|
|
399
429
|
}
|
|
400
430
|
parent.currObjType.isDragging = parent.currObjType.isCustomCrop = false;
|
|
@@ -402,11 +432,11 @@ var Shape = /** @class */ (function () {
|
|
|
402
432
|
var obj = { shapeSettingsObj: {} };
|
|
403
433
|
parent.notify('selection', { prop: 'updatePrevShapeSettings', onPropertyChange: false, value: { obj: obj } });
|
|
404
434
|
var shapeSettings = obj['shapeSettingsObj'];
|
|
405
|
-
var shapeChangingArgs = { action: 'insert', previousShapeSettings: shapeSettings,
|
|
435
|
+
var shapeChangingArgs = { cancel: false, action: 'insert', previousShapeSettings: shapeSettings,
|
|
406
436
|
currentShapeSettings: shapeSettings };
|
|
407
437
|
if (isBlazor() && parent.events && parent.events.shapeChanging.hasDelegate === true) {
|
|
408
438
|
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
409
|
-
|
|
439
|
+
parent.dotNetRef.invokeMethodAsync('ShapeEventAsync', 'OnShape', shapeChangingArgs, null).then(function (shapeChangingArgs) {
|
|
410
440
|
_this.updateShapeChangeEventArgs(shapeChangingArgs.currentShapeSettings);
|
|
411
441
|
_this.setDimension(width, height);
|
|
412
442
|
parent.notify('draw', { prop: 'drawObject', onPropertyChange: false, value: { canvas: 'duplicate' } });
|
|
@@ -461,8 +491,10 @@ var Shape = /** @class */ (function () {
|
|
|
461
491
|
};
|
|
462
492
|
Shape.prototype.setPointCollForLineAndArrow = function () {
|
|
463
493
|
var parent = this.parent;
|
|
464
|
-
|
|
465
|
-
|
|
494
|
+
var shape = parent.activeObj.shape;
|
|
495
|
+
var _a = parent.activeObj.activePoint, startX = _a.startX, startY = _a.startY, endX = _a.endX, endY = _a.endY;
|
|
496
|
+
if (shape === 'line' || shape === 'arrow') {
|
|
497
|
+
parent.activeObj.pointColl = this.getLinePoints(startX, startY, endX, endY);
|
|
466
498
|
if (parent.activeObj.pointColl) {
|
|
467
499
|
for (var i = 0, len = parent.activeObj.pointColl.length; i < len; i++) {
|
|
468
500
|
parent.activeObj.pointColl[i].ratioX = (parent.activeObj.pointColl[i].x -
|
|
@@ -533,11 +565,11 @@ var Shape = /** @class */ (function () {
|
|
|
533
565
|
var obj = { shapeSettingsObj: {} };
|
|
534
566
|
parent.notify('selection', { prop: 'updatePrevShapeSettings', onPropertyChange: false, value: { obj: obj } });
|
|
535
567
|
var shapeSettings = obj['shapeSettingsObj'];
|
|
536
|
-
var shapeChangingArgs = { action: 'insert', previousShapeSettings: shapeSettings,
|
|
568
|
+
var shapeChangingArgs = { cancel: false, action: 'insert', previousShapeSettings: shapeSettings,
|
|
537
569
|
currentShapeSettings: shapeSettings };
|
|
538
570
|
if (isBlazor() && parent.events && parent.events.shapeChanging.hasDelegate === true) {
|
|
539
571
|
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
540
|
-
parent.dotNetRef.invokeMethodAsync('ShapeEventAsync', 'OnShape', shapeChangingArgs).then(function (shapeChangingArgs) {
|
|
572
|
+
parent.dotNetRef.invokeMethodAsync('ShapeEventAsync', 'OnShape', shapeChangingArgs, null).then(function (shapeChangingArgs) {
|
|
541
573
|
_this.drawShapeTextEvent(shapeChangingArgs);
|
|
542
574
|
if (parent.isPublicMethod) {
|
|
543
575
|
parent.notify('undo-redo', { prop: 'updateUndoRedo', onPropertyChange: false });
|
|
@@ -563,9 +595,8 @@ var Shape = /** @class */ (function () {
|
|
|
563
595
|
var prevCropObj = extend({}, parent.cropObj, {}, true);
|
|
564
596
|
parent.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false,
|
|
565
597
|
value: { operation: 'shapeTransform', previousObj: this.prevObj, previousObjColl: this.prevObj.objColl,
|
|
566
|
-
previousPointColl: this.prevObj.pointColl, previousSelPointColl: this.prevObj.selPointColl,
|
|
567
|
-
|
|
568
|
-
currentText: null, previousFilter: null, isCircleCrop: null } });
|
|
598
|
+
previousPointColl: this.prevObj.pointColl, previousSelPointColl: this.prevObj.selPointColl, previousCropObj: prevCropObj,
|
|
599
|
+
previousText: null, currentText: null, previousFilter: null, isCircleCrop: null } });
|
|
569
600
|
parent.notify('selection', { prop: 'redrawShape', onPropertyChange: false,
|
|
570
601
|
value: { obj: parent.objColl[parent.objColl.length - 1] } });
|
|
571
602
|
if (isSelect) {
|
|
@@ -596,25 +627,24 @@ var Shape = /** @class */ (function () {
|
|
|
596
627
|
parent.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false,
|
|
597
628
|
value: { operation: 'shapeTransform', previousObj: this.prevObj, previousObjColl: this.prevObj.objColl,
|
|
598
629
|
previousPointColl: this.prevObj.pointColl, previousSelPointColl: this.prevObj.selPointColl,
|
|
599
|
-
previousCropObj: prevCropObj, previousText: null,
|
|
600
|
-
currentText: null, previousFilter: null, isCircleCrop: null } });
|
|
630
|
+
previousCropObj: prevCropObj, previousText: null, currentText: null, previousFilter: null, isCircleCrop: null } });
|
|
601
631
|
parent.notify('selection', { prop: 'redrawShape', onPropertyChange: false,
|
|
602
632
|
value: { obj: parent.objColl[parent.objColl.length - 1] } });
|
|
603
|
-
if (
|
|
604
|
-
parent.
|
|
633
|
+
if (isBlazor()) {
|
|
634
|
+
parent.updateToolbar(parent.element, 'quickAccessToolbar', 'text');
|
|
605
635
|
}
|
|
606
636
|
else {
|
|
607
|
-
parent.
|
|
637
|
+
parent.notify('toolbar', { prop: 'renderQAT', onPropertyChange: false, value: { isPenEdit: null } });
|
|
608
638
|
}
|
|
609
639
|
parent.notify('selection', { prop: 'isShapeInserted', onPropertyChange: false, value: { bool: true } });
|
|
610
|
-
if (
|
|
640
|
+
if (isBlazor()) {
|
|
641
|
+
parent.updateToolbar(parent.element, 'text');
|
|
642
|
+
}
|
|
643
|
+
else {
|
|
611
644
|
parent.notify('toolbar', { prop: 'refresh-toolbar', onPropertyChange: false, value: { type: 'text',
|
|
612
645
|
isApplyBtn: null, isCropping: null, isZooming: null, cType: null } });
|
|
613
646
|
parent.notify('toolbar', { prop: 'update-toolbar-items', onPropertyChange: false });
|
|
614
647
|
}
|
|
615
|
-
else {
|
|
616
|
-
parent.updateToolbar(parent.element, 'text');
|
|
617
|
-
}
|
|
618
648
|
};
|
|
619
649
|
Shape.prototype.initializeTextShape = function (text, fontFamily, fontSize, bold, italic, strokeColor) {
|
|
620
650
|
var parent = this.parent;
|
|
@@ -633,9 +663,9 @@ var Shape = /** @class */ (function () {
|
|
|
633
663
|
parent.activeObj.textSettings.bold = bold || parent.activeObj.textSettings.bold;
|
|
634
664
|
parent.activeObj.textSettings.italic = italic || parent.activeObj.textSettings.italic;
|
|
635
665
|
};
|
|
636
|
-
Shape.prototype.drawImage = function (x, y, width, height, src, degree, isAspectRatio) {
|
|
666
|
+
Shape.prototype.drawImage = function (x, y, width, height, src, degree, isAspectRatio, opacity) {
|
|
637
667
|
this.initializeShape('image');
|
|
638
|
-
this.onLoadImgShape(x, y, width, height, src, null, degree, isAspectRatio);
|
|
668
|
+
this.onLoadImgShape(x, y, width, height, src, null, degree, isAspectRatio, opacity);
|
|
639
669
|
};
|
|
640
670
|
Shape.prototype.redrawActObj = function (x, y, isMouseDown) {
|
|
641
671
|
var splitWords;
|
|
@@ -644,7 +674,7 @@ var Shape = /** @class */ (function () {
|
|
|
644
674
|
splitWords = parent.activeObj.shape.split('-');
|
|
645
675
|
}
|
|
646
676
|
if (parent.activeObj.horTopLine && (parent.activeObj.shape && splitWords[0] !== 'crop')) {
|
|
647
|
-
if (parent.textArea.style.display === 'block') {
|
|
677
|
+
if (parent.textArea.style.display === 'block' || parent.textArea.style.display === 'inline-block') {
|
|
648
678
|
parent.notify('selection', { prop: 'setTextBoxStylesToActObj', onPropertyChange: false });
|
|
649
679
|
this.updateFontRatio(parent.activeObj, true);
|
|
650
680
|
if (x && y) {
|
|
@@ -676,10 +706,6 @@ var Shape = /** @class */ (function () {
|
|
|
676
706
|
var temp = this.lowerContext.filter;
|
|
677
707
|
this.lowerContext.filter = 'none';
|
|
678
708
|
parent.togglePen = false;
|
|
679
|
-
this.iterateObjColl();
|
|
680
|
-
parent.notify('freehandDraw', { prop: 'freehandRedraw', onPropertyChange: false,
|
|
681
|
-
value: { context: this.lowerContext, points: null } });
|
|
682
|
-
parent.togglePen = false;
|
|
683
709
|
if (parent.isCircleCrop || (parent.currSelectionPoint &&
|
|
684
710
|
parent.currSelectionPoint.shape === 'crop-circle')) {
|
|
685
711
|
parent.notify('crop', { prop: 'cropCircle', onPropertyChange: false,
|
|
@@ -704,7 +730,6 @@ var Shape = /** @class */ (function () {
|
|
|
704
730
|
if (parent.activeObj.shape === 'text') {
|
|
705
731
|
parent.notify('draw', { prop: 'drawObject', onPropertyChange: false, value: { canvas: canvas, obj: obj, isCropRatio: null,
|
|
706
732
|
points: null, isPreventDrag: true, saveContext: null, isPreventSelection: null } });
|
|
707
|
-
parent.notify('draw', { prop: 'clearOuterCanvas', onPropertyChange: false, value: { context: this.lowerContext } });
|
|
708
733
|
}
|
|
709
734
|
else {
|
|
710
735
|
parent.notify('draw', { prop: 'drawObject', onPropertyChange: false, value: { canvas: canvas, obj: obj } });
|
|
@@ -737,61 +762,74 @@ var Shape = /** @class */ (function () {
|
|
|
737
762
|
};
|
|
738
763
|
Shape.prototype.updSelChangeEventArgs = function (selectionSettings) {
|
|
739
764
|
var parent = this.parent;
|
|
740
|
-
parent.activeObj.activePoint.startX
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
parent.activeObj.activePoint.endX = parent.activeObj.activePoint.startX + parent.activeObj.activePoint.width;
|
|
745
|
-
parent.activeObj.activePoint.endY = parent.activeObj.activePoint.startY + parent.activeObj.activePoint.height;
|
|
765
|
+
parent.activeObj.activePoint = { startX: selectionSettings.startX, startY: selectionSettings.startY,
|
|
766
|
+
endX: parent.activeObj.activePoint.startX + parent.activeObj.activePoint.width,
|
|
767
|
+
endY: parent.activeObj.activePoint.startY + parent.activeObj.activePoint.height,
|
|
768
|
+
width: selectionSettings.width, height: selectionSettings.height };
|
|
746
769
|
};
|
|
747
770
|
Shape.prototype.updateShapeChangeEventArgs = function (shapeSettings) {
|
|
748
771
|
var parent = this.parent;
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
parent.activeObj.strokeSettings.strokeColor = shapeSettings.strokeColor;
|
|
757
|
-
parent.activeObj.strokeSettings.fillColor = shapeSettings.fillColor;
|
|
758
|
-
if (isNullOrUndefined(shapeSettings.degree)) {
|
|
759
|
-
shapeSettings.degree = 0;
|
|
760
|
-
}
|
|
761
|
-
switch (parent.activeObj.shape) {
|
|
762
|
-
case 'ellipse':
|
|
763
|
-
parent.activeObj.activePoint.width = shapeSettings.radius * 2;
|
|
764
|
-
parent.activeObj.rotatedAngle = shapeSettings.degree * (Math.PI / 180);
|
|
765
|
-
break;
|
|
766
|
-
case 'line':
|
|
767
|
-
case 'arrow':
|
|
768
|
-
parent.activeObj.activePoint.width = shapeSettings.length;
|
|
769
|
-
break;
|
|
770
|
-
case 'text':
|
|
771
|
-
parent.activeObj.keyHistory = parent.activeObj.textSettings.text = shapeSettings.text;
|
|
772
|
-
parent.activeObj.textSettings.fontSize = shapeSettings.fontSize;
|
|
773
|
-
parent.activeObj.strokeSettings.strokeColor = shapeSettings.color;
|
|
774
|
-
parent.activeObj.textSettings.fontFamily = shapeSettings.fontFamily;
|
|
775
|
-
break;
|
|
776
|
-
case 'rectangle':
|
|
777
|
-
case 'image':
|
|
778
|
-
if (shapeSettings.degree) {
|
|
779
|
-
parent.activeObj.rotatedAngle = shapeSettings.degree * (Math.PI / 180);
|
|
780
|
-
}
|
|
781
|
-
break;
|
|
772
|
+
var shapeId;
|
|
773
|
+
if (shapeSettings.id && shapeSettings.id.split('_')[0] && shapeSettings.id.split('_')[0] === 'pen') {
|
|
774
|
+
shapeId = parseInt(shapeSettings.id.split('_')[1], 10) - 1;
|
|
775
|
+
parent.pointColl[shapeId].points = shapeSettings.points;
|
|
776
|
+
parent.pointColl[shapeId].strokeColor = shapeSettings.strokeColor;
|
|
777
|
+
parent.pointColl[shapeId].strokeWidth = shapeSettings.strokeWidth;
|
|
778
|
+
parent.pointColl[shapeId].opacity = shapeSettings.opacity;
|
|
782
779
|
}
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
780
|
+
else {
|
|
781
|
+
parent.activeObj.currIndex = shapeSettings.id;
|
|
782
|
+
parent.activeObj.activePoint.startX = shapeSettings.startX;
|
|
783
|
+
parent.activeObj.activePoint.startY = shapeSettings.startY;
|
|
784
|
+
if (shapeSettings.width && shapeSettings.height) {
|
|
785
|
+
parent.activeObj.activePoint.width = shapeSettings.width;
|
|
786
|
+
parent.activeObj.activePoint.height = shapeSettings.height;
|
|
787
|
+
parent.activeObj.activePoint.endX = parent.activeObj.activePoint.startX + parent.activeObj.activePoint.width;
|
|
788
|
+
parent.activeObj.activePoint.endY = parent.activeObj.activePoint.startY + parent.activeObj.activePoint.height;
|
|
789
|
+
}
|
|
790
|
+
parent.activeObj.strokeSettings.strokeColor = shapeSettings.strokeColor;
|
|
791
|
+
parent.activeObj.strokeSettings.fillColor = shapeSettings.fillColor;
|
|
792
|
+
parent.activeObj.opacity = shapeSettings.opacity;
|
|
793
|
+
if (isNullOrUndefined(shapeSettings.degree)) {
|
|
794
|
+
shapeSettings.degree = 0;
|
|
795
|
+
}
|
|
796
|
+
switch (parent.activeObj.shape) {
|
|
797
|
+
case 'ellipse':
|
|
798
|
+
parent.activeObj.activePoint.width = shapeSettings.radius * 2;
|
|
799
|
+
if (shapeSettings.degree) {
|
|
800
|
+
parent.activeObj.rotatedAngle = shapeSettings.degree * (Math.PI / 180);
|
|
801
|
+
}
|
|
802
|
+
break;
|
|
803
|
+
case 'line':
|
|
804
|
+
case 'arrow':
|
|
805
|
+
parent.activeObj.activePoint.width = shapeSettings.length;
|
|
806
|
+
break;
|
|
807
|
+
case 'text':
|
|
808
|
+
parent.activeObj.keyHistory = parent.activeObj.textSettings.text = shapeSettings.text;
|
|
809
|
+
parent.activeObj.textSettings.fontSize = shapeSettings.fontSize;
|
|
810
|
+
parent.activeObj.strokeSettings.strokeColor = shapeSettings.color;
|
|
811
|
+
parent.activeObj.textSettings.fontFamily = shapeSettings.fontFamily;
|
|
812
|
+
break;
|
|
813
|
+
case 'rectangle':
|
|
814
|
+
case 'image':
|
|
815
|
+
if (shapeSettings.degree) {
|
|
816
|
+
parent.activeObj.rotatedAngle = shapeSettings.degree * (Math.PI / 180);
|
|
817
|
+
}
|
|
818
|
+
break;
|
|
819
|
+
}
|
|
820
|
+
if (parent.activeObj.shape === 'text' && parent.activeObj.textSettings) {
|
|
821
|
+
for (var i = 0; i < shapeSettings.fontStyle.length; i++) {
|
|
822
|
+
switch (shapeSettings.fontStyle[i]) {
|
|
823
|
+
case 'bold':
|
|
824
|
+
parent.activeObj.textSettings.bold = true;
|
|
825
|
+
break;
|
|
826
|
+
case 'italic':
|
|
827
|
+
parent.activeObj.textSettings.italic = true;
|
|
828
|
+
break;
|
|
829
|
+
case 'underline':
|
|
830
|
+
parent.activeObj.textSettings.underline = true;
|
|
831
|
+
break;
|
|
832
|
+
}
|
|
795
833
|
}
|
|
796
834
|
}
|
|
797
835
|
}
|
|
@@ -810,6 +848,7 @@ var Shape = /** @class */ (function () {
|
|
|
810
848
|
Shape.prototype.addLetter = function (letter) {
|
|
811
849
|
var parent = this.parent;
|
|
812
850
|
if (parent.textArea.style.display === 'none' && (parent.currObjType.isText || parent.activeObj.shape === 'text')) {
|
|
851
|
+
var fontSize = parent.activeObj.textSettings.fontSize;
|
|
813
852
|
if (letter === 'Backspace') {
|
|
814
853
|
this.keyHistory = this.keyHistory.slice(0, -1);
|
|
815
854
|
}
|
|
@@ -818,11 +857,9 @@ var Shape = /** @class */ (function () {
|
|
|
818
857
|
}
|
|
819
858
|
this.upperContext.clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
|
|
820
859
|
this.updateFontStyles();
|
|
821
|
-
var width = this.upperContext.measureText(this.keyHistory).width
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
this.upperContext.fillText(this.keyHistory, parent.activeObj.activePoint.startX, parent.activeObj.activePoint.startY +
|
|
825
|
-
parent.activeObj.textSettings.fontSize);
|
|
860
|
+
var width = this.upperContext.measureText(this.keyHistory).width + fontSize * 0.5;
|
|
861
|
+
var height = fontSize + fontSize * 0.25;
|
|
862
|
+
this.upperContext.fillText(this.keyHistory, parent.activeObj.activePoint.startX, parent.activeObj.activePoint.startY + fontSize);
|
|
826
863
|
this.upperContext.clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
|
|
827
864
|
parent.currObjType.isText = true;
|
|
828
865
|
parent.notify('selection', { prop: 'setActivePoint', onPropertyChange: false,
|
|
@@ -831,18 +868,20 @@ var Shape = /** @class */ (function () {
|
|
|
831
868
|
};
|
|
832
869
|
Shape.prototype.redrawText = function () {
|
|
833
870
|
var parent = this.parent;
|
|
871
|
+
var _a = parent.activeObj.textSettings, fontSize = _a.fontSize, fontFamily = _a.fontFamily, bold = _a.bold, italic = _a.italic;
|
|
834
872
|
var fontStyle = '';
|
|
835
|
-
if (
|
|
873
|
+
if (bold) {
|
|
836
874
|
fontStyle += 'bold ';
|
|
837
875
|
}
|
|
838
|
-
if (
|
|
876
|
+
if (italic) {
|
|
839
877
|
fontStyle += 'italic ';
|
|
840
878
|
}
|
|
841
|
-
this.upperContext.font = fontStyle +
|
|
879
|
+
this.upperContext.font = fontStyle + fontSize + 'px ' + fontFamily;
|
|
842
880
|
var rows = parent.activeObj.keyHistory.split('\n');
|
|
843
|
-
var text = parent.textArea.style.display === 'block'
|
|
844
|
-
|
|
845
|
-
var
|
|
881
|
+
var text = (parent.textArea.style.display === 'block' || parent.textArea.style.display === 'inline-block') ?
|
|
882
|
+
this.getMaxText(true) : this.getMaxText();
|
|
883
|
+
var width = this.upperContext.measureText(text).width + fontSize * 0.5;
|
|
884
|
+
var height = rows.length * (fontSize + fontSize * 0.25);
|
|
846
885
|
parent.notify('selection', { prop: 'setTextSelection', onPropertyChange: false,
|
|
847
886
|
value: { width: width, height: height } });
|
|
848
887
|
parent.notify('draw', { prop: 'updateActiveObject', onPropertyChange: false, value: { actPoint: parent.activeObj.activePoint, obj: parent.activeObj,
|
|
@@ -853,13 +892,15 @@ var Shape = /** @class */ (function () {
|
|
|
853
892
|
Shape.prototype.updateTextFromTextArea = function () {
|
|
854
893
|
var parent = this.parent;
|
|
855
894
|
var allowUndoRedo = false;
|
|
895
|
+
var fontSize = parent.activeObj.textSettings.fontSize;
|
|
896
|
+
var tempActiveObj = extend({}, parent.activeObj, {}, true);
|
|
856
897
|
var prevCropObj = extend({}, parent.cropObj, {}, true);
|
|
857
898
|
var object = { currObj: {} };
|
|
858
899
|
parent.notify('filter', { prop: 'getCurrentObj', onPropertyChange: false, value: { object: object } });
|
|
859
900
|
var prevObj = object['currObj'];
|
|
860
901
|
prevObj.objColl = extend([], parent.objColl, [], true);
|
|
861
902
|
prevObj.pointColl = extend([], parent.pointColl, [], true);
|
|
862
|
-
prevObj.afterCropActions = extend([],
|
|
903
|
+
prevObj.afterCropActions = extend([], parent.afterCropActions, [], true);
|
|
863
904
|
var selPointCollObj = { selPointColl: null };
|
|
864
905
|
parent.notify('freehand-draw', { prop: 'getSelPointColl', onPropertyChange: false,
|
|
865
906
|
value: { obj: selPointCollObj } });
|
|
@@ -871,24 +912,44 @@ var Shape = /** @class */ (function () {
|
|
|
871
912
|
parent.textArea.style.display = 'none';
|
|
872
913
|
parent.textArea.value = '';
|
|
873
914
|
this.updateFontStyles();
|
|
874
|
-
var width = this.upperContext.measureText(parent.activeObj.keyHistory).width +
|
|
875
|
-
|
|
876
|
-
var height = parent.activeObj.textSettings.fontSize + this.parent.activeObj.textSettings.fontSize * 0.25;
|
|
915
|
+
var width = this.upperContext.measureText(parent.activeObj.keyHistory).width + fontSize * 0.5;
|
|
916
|
+
var height = fontSize + fontSize * 0.25;
|
|
877
917
|
var rows = parent.activeObj.keyHistory.split('\n');
|
|
878
918
|
if (rows.length > 1) {
|
|
879
919
|
height *= rows.length;
|
|
880
920
|
var widthColl = [];
|
|
881
921
|
for (var i = 0, len = rows.length; i < len; i++) {
|
|
882
|
-
widthColl.push(this.upperContext.measureText(rows[i]).width +
|
|
883
|
-
parent.activeObj.textSettings.fontSize * 0.5);
|
|
922
|
+
widthColl.push(this.upperContext.measureText(rows[i]).width + fontSize * 0.5);
|
|
884
923
|
}
|
|
885
924
|
width = Math.max.apply(Math, widthColl);
|
|
886
925
|
}
|
|
887
926
|
parent.notify('selection', { prop: 'setTextSelection', onPropertyChange: false,
|
|
888
927
|
value: { width: width, height: height } });
|
|
928
|
+
if (parent.activeObj.rotatedAngle !== 0) {
|
|
929
|
+
var width_1 = parent.activeObj.activePoint.width - tempActiveObj.activePoint.width;
|
|
930
|
+
var height_1 = parent.activeObj.activePoint.height - tempActiveObj.activePoint.height;
|
|
931
|
+
var value = '';
|
|
932
|
+
if (width_1 > 0 && height_1 > 0) {
|
|
933
|
+
value = 'widthHeight';
|
|
934
|
+
}
|
|
935
|
+
else if (width_1 !== 0) {
|
|
936
|
+
value = 'width';
|
|
937
|
+
}
|
|
938
|
+
else if (height_1 !== 0) {
|
|
939
|
+
value = 'height';
|
|
940
|
+
}
|
|
941
|
+
parent.activeObj.activePoint = extend({}, tempActiveObj.activePoint, {}, true);
|
|
942
|
+
parent.notify('selection', { prop: 'adjustRotationPoints', onPropertyChange: false, value: { rectangle: parent.activeObj.activePoint,
|
|
943
|
+
x: width_1, y: height_1, angle: parent.activeObj.rotatedAngle, type: 'text', elem: value } });
|
|
944
|
+
parent.notify('shape', { prop: 'updateFontSize', onPropertyChange: false,
|
|
945
|
+
value: { obj: parent.activeObj } });
|
|
946
|
+
}
|
|
889
947
|
parent.notify('draw', { prop: 'updateActiveObject', onPropertyChange: false, value: { actPoint: parent.activeObj.activePoint, obj: parent.activeObj,
|
|
890
948
|
isMouseMove: null, x: null, y: null } });
|
|
891
949
|
this.updImgRatioForActObj();
|
|
950
|
+
if (parent.activeObj.rotatedAngle !== 0) {
|
|
951
|
+
parent.notify('selection', { prop: 'updPtCollForShpRot', onPropertyChange: false, value: { obj: parent.activeObj } });
|
|
952
|
+
}
|
|
892
953
|
if (allowUndoRedo) {
|
|
893
954
|
this.apply(parent.activeObj.shape, parent.activeObj);
|
|
894
955
|
parent.objColl.push(extend({}, parent.activeObj, {}, true));
|
|
@@ -907,7 +968,10 @@ var Shape = /** @class */ (function () {
|
|
|
907
968
|
var parent = this.parent;
|
|
908
969
|
if (parent.objColl.length > 0) {
|
|
909
970
|
for (var i = 0, len = parent.objColl.length; i < len; i++) {
|
|
971
|
+
var temp = this.lowerContext.filter;
|
|
972
|
+
this.lowerContext.filter = 'none';
|
|
910
973
|
this.apply(parent.objColl[i].shape, parent.objColl[i]);
|
|
974
|
+
this.lowerContext.filter = temp;
|
|
911
975
|
this.refreshActiveObj();
|
|
912
976
|
}
|
|
913
977
|
parent.notify('draw', { prop: 'applyFrame', value: { ctx: this.lowerContext, frame: parent.frameObj.type, preventImg: true } });
|
|
@@ -915,18 +979,21 @@ var Shape = /** @class */ (function () {
|
|
|
915
979
|
};
|
|
916
980
|
Shape.prototype.updImgRatioForActObj = function () {
|
|
917
981
|
var parent = this.parent;
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
982
|
+
var destPoints = { startX: parent.img.destLeft, startY: parent.img.destTop,
|
|
983
|
+
width: parent.img.destWidth, height: parent.img.destHeight };
|
|
984
|
+
this.straightenShapes();
|
|
985
|
+
var _a = parent.img, destLeft = _a.destLeft, destTop = _a.destTop, destWidth = _a.destWidth, destHeight = _a.destHeight;
|
|
986
|
+
var activePoint = parent.activeObj.activePoint;
|
|
987
|
+
parent.activeObj.imageRatio = { startX: ((activePoint.startX - destLeft) /
|
|
988
|
+
destWidth), startY: ((activePoint.startY - destTop) / destHeight),
|
|
989
|
+
endX: ((activePoint.endX - destLeft) / destWidth),
|
|
990
|
+
endY: ((activePoint.endY - destTop) / destHeight),
|
|
991
|
+
width: destWidth / activePoint.width, height: destHeight / activePoint.height };
|
|
925
992
|
if (parent.activeObj.rotationCirclePointColl) {
|
|
926
993
|
parent.activeObj.rotationCirclePointColl.ratioX = (parent.activeObj.rotationCirclePointColl.x -
|
|
927
|
-
|
|
994
|
+
destLeft) / destWidth;
|
|
928
995
|
parent.activeObj.rotationCirclePointColl.ratioY = (parent.activeObj.rotationCirclePointColl.y -
|
|
929
|
-
|
|
996
|
+
destTop) / destHeight;
|
|
930
997
|
}
|
|
931
998
|
if (parent.activeObj.shape === 'path') {
|
|
932
999
|
this.updatePathRatio(parent.activeObj);
|
|
@@ -934,15 +1001,23 @@ var Shape = /** @class */ (function () {
|
|
|
934
1001
|
else if (parent.activeObj.shape === 'arrow') {
|
|
935
1002
|
this.updateArrowRatio(parent.activeObj);
|
|
936
1003
|
}
|
|
1004
|
+
parent.img.destLeft = destPoints.startX;
|
|
1005
|
+
parent.img.destTop = destPoints.startY;
|
|
1006
|
+
parent.img.destWidth = destPoints.width;
|
|
1007
|
+
parent.img.destHeight = destPoints.height;
|
|
937
1008
|
};
|
|
938
1009
|
Shape.prototype.zoomObjColl = function (preventApply) {
|
|
939
1010
|
var parent = this.parent;
|
|
1011
|
+
var destPoints = { startX: parent.img.destLeft, startY: parent.img.destTop,
|
|
1012
|
+
width: parent.img.destWidth, height: parent.img.destHeight };
|
|
1013
|
+
this.straightenShapes();
|
|
1014
|
+
var _a = parent.img, destLeft = _a.destLeft, destTop = _a.destTop, destWidth = _a.destWidth, destHeight = _a.destHeight;
|
|
940
1015
|
for (var i = 0, len = parent.objColl.length; i < len; i++) {
|
|
941
1016
|
var currObj = parent.objColl[i];
|
|
942
|
-
currObj.activePoint.startX = (currObj.imageRatio.startX *
|
|
943
|
-
currObj.activePoint.startY = (currObj.imageRatio.startY *
|
|
944
|
-
currObj.activePoint.endX = (currObj.imageRatio.endX *
|
|
945
|
-
currObj.activePoint.endY = (currObj.imageRatio.endY *
|
|
1017
|
+
currObj.activePoint.startX = (currObj.imageRatio.startX * destWidth) + destLeft;
|
|
1018
|
+
currObj.activePoint.startY = (currObj.imageRatio.startY * destHeight) + destTop;
|
|
1019
|
+
currObj.activePoint.endX = (currObj.imageRatio.endX * destWidth) + destLeft;
|
|
1020
|
+
currObj.activePoint.endY = (currObj.imageRatio.endY * destHeight) + destTop;
|
|
946
1021
|
currObj = this.updateWidthHeight(currObj);
|
|
947
1022
|
if (currObj.shape === 'text') {
|
|
948
1023
|
this.updateFontSize(currObj);
|
|
@@ -951,22 +1026,28 @@ var Shape = /** @class */ (function () {
|
|
|
951
1026
|
currObj.pointColl = this.getLinePoints(currObj.activePoint.startX, currObj.activePoint.startY, currObj.activePoint.endX, currObj.activePoint.endY);
|
|
952
1027
|
for (var n = 0, len_1 = currObj.pointColl.length; n < len_1; n++) {
|
|
953
1028
|
currObj.pointColl[n].ratioX =
|
|
954
|
-
(currObj.pointColl[n].x -
|
|
1029
|
+
(currObj.pointColl[n].x - destLeft) / destWidth;
|
|
955
1030
|
currObj.pointColl[n].ratioY =
|
|
956
|
-
(currObj.pointColl[n].y -
|
|
1031
|
+
(currObj.pointColl[n].y - destTop) / destHeight;
|
|
957
1032
|
}
|
|
958
1033
|
if (currObj.shape === 'arrow') {
|
|
959
1034
|
this.updateArrowSize(currObj);
|
|
960
1035
|
}
|
|
1036
|
+
if (parent.transform.straighten !== 0 && (currObj.shape === 'line' || currObj.shape === 'arrow')) {
|
|
1037
|
+
this.straightenShapePoints(currObj);
|
|
1038
|
+
}
|
|
961
1039
|
}
|
|
962
1040
|
else if (currObj.shape === 'path') {
|
|
963
1041
|
for (var l = 0, len_2 = currObj.pointColl.length; l < len_2; l++) {
|
|
964
|
-
currObj.pointColl[l].x = (currObj.pointColl[l].ratioX *
|
|
965
|
-
|
|
966
|
-
currObj.pointColl[l].y = (currObj.pointColl[l].ratioY *
|
|
967
|
-
|
|
1042
|
+
currObj.pointColl[l].x = (currObj.pointColl[l].ratioX * destWidth) +
|
|
1043
|
+
destLeft;
|
|
1044
|
+
currObj.pointColl[l].y = (currObj.pointColl[l].ratioY * destHeight) +
|
|
1045
|
+
destTop;
|
|
968
1046
|
}
|
|
969
1047
|
this.updatePathRatio(currObj);
|
|
1048
|
+
if (parent.transform.straighten !== 0) {
|
|
1049
|
+
this.straightenPath(currObj);
|
|
1050
|
+
}
|
|
970
1051
|
}
|
|
971
1052
|
parent.notify('draw', { prop: 'updateActiveObject', onPropertyChange: false, value: { actPoint: currObj.activePoint,
|
|
972
1053
|
obj: currObj } });
|
|
@@ -980,23 +1061,134 @@ var Shape = /** @class */ (function () {
|
|
|
980
1061
|
}
|
|
981
1062
|
if (currObj.shape !== 'line' && currObj.shape !== 'arrow' && currObj.shape !== 'path' && currObj.rotatedAngle !== 0) {
|
|
982
1063
|
this.setPointCollForShapeRotation(currObj);
|
|
983
|
-
currObj.rotationCirclePoint.x =
|
|
984
|
-
|
|
985
|
-
currObj.
|
|
986
|
-
|
|
987
|
-
currObj.rotationCirclePointColl.x =
|
|
988
|
-
(currObj.rotationCirclePointColl.ratioX * parent.img.destWidth) +
|
|
989
|
-
parent.img.destLeft;
|
|
990
|
-
currObj.rotationCirclePointColl.y =
|
|
991
|
-
(currObj.rotationCirclePointColl.ratioY * parent.img.destHeight) +
|
|
992
|
-
parent.img.destTop;
|
|
1064
|
+
currObj.rotationCirclePoint.x = (currObj.rotationCirclePoint.ratioX * destWidth) + destLeft;
|
|
1065
|
+
currObj.rotationCirclePoint.y = (currObj.rotationCirclePoint.ratioY * destHeight) + destTop;
|
|
1066
|
+
currObj.rotationCirclePointColl.x = (currObj.rotationCirclePointColl.ratioX * destWidth) + destLeft;
|
|
1067
|
+
currObj.rotationCirclePointColl.y = (currObj.rotationCirclePointColl.ratioY * destHeight) + destTop;
|
|
993
1068
|
}
|
|
994
1069
|
}
|
|
1070
|
+
parent.img.destLeft = destPoints.startX;
|
|
1071
|
+
parent.img.destTop = destPoints.startY;
|
|
1072
|
+
parent.img.destWidth = destPoints.width;
|
|
1073
|
+
parent.img.destHeight = destPoints.height;
|
|
1074
|
+
};
|
|
1075
|
+
Shape.prototype.straightenPath = function (obj) {
|
|
1076
|
+
var point;
|
|
1077
|
+
for (var j = 0, len = obj.pointColl.length; j < len; j++) {
|
|
1078
|
+
point = this.straightenPoints(obj.pointColl[j].x, obj.pointColl[j].y);
|
|
1079
|
+
obj.pointColl[j].x = point.x;
|
|
1080
|
+
obj.pointColl[j].y = point.y;
|
|
1081
|
+
}
|
|
1082
|
+
};
|
|
1083
|
+
Shape.prototype.straightenFHD = function () {
|
|
1084
|
+
var parent = this.parent;
|
|
1085
|
+
for (var i = 0, fLen = parent.freehandCounter; i < fLen; i++) {
|
|
1086
|
+
parent.points = extend([], parent.pointColl[i].points, []);
|
|
1087
|
+
var len = parent.points.length;
|
|
1088
|
+
var point = void 0;
|
|
1089
|
+
for (var l = 0; l < len; l++) {
|
|
1090
|
+
point = this.straightenPoints(parent.points[l].x, parent.points[l].y);
|
|
1091
|
+
parent.points[l].x = point.x;
|
|
1092
|
+
parent.points[l].y = point.y;
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
var selPointCollObj = { selPointColl: null };
|
|
1096
|
+
parent.notify('freehand-draw', { prop: 'getSelPointColl', onPropertyChange: false, value: { obj: selPointCollObj } });
|
|
1097
|
+
for (var i = 0, fLen = parent.freehandCounter; i < fLen; i++) {
|
|
1098
|
+
var len = selPointCollObj['selPointColl'][i].points.length;
|
|
1099
|
+
var point = void 0;
|
|
1100
|
+
for (var l = 0; l < len; l++) {
|
|
1101
|
+
point = this.straightenPoints(selPointCollObj['selPointColl'][i].points[l].x, selPointCollObj['selPointColl'][i].points[l].y);
|
|
1102
|
+
selPointCollObj['selPointColl'][i].points[l].x = point.x;
|
|
1103
|
+
selPointCollObj['selPointColl'][i].points[l].y = point.y;
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
var straightenObj = { straightenPoint: null };
|
|
1107
|
+
parent.notify('freehand-draw', { prop: 'getStraightenPoint', onPropertyChange: false, value: { obj: straightenObj } });
|
|
1108
|
+
if (straightenObj['straightenPoint']['x'] && straightenObj['straightenPoint']['y']) {
|
|
1109
|
+
var obj = { angle: 0 };
|
|
1110
|
+
parent.notify('freehand-draw', { prop: 'getStraightenPointAngle', onPropertyChange: false, value: { obj: obj } });
|
|
1111
|
+
var angle = (((parent.transform.straighten === 360 ? 0 : parent.transform.straighten) - obj['angle']) * (Math.PI / 180));
|
|
1112
|
+
var point = this.straightenPoints(straightenObj['straightenPoint']['x'], straightenObj['straightenPoint']['y'], angle);
|
|
1113
|
+
if (angle === 0) {
|
|
1114
|
+
point.x = straightenObj['straightenPoint']['x'];
|
|
1115
|
+
point.y = straightenObj['straightenPoint']['y'];
|
|
1116
|
+
}
|
|
1117
|
+
parent.notify('freehand-draw', { prop: 'setStraightenPoint', onPropertyChange: false, value: { x: point.x, y: point.y } });
|
|
1118
|
+
}
|
|
1119
|
+
};
|
|
1120
|
+
Shape.prototype.straightenPoints = function (x, y, angle) {
|
|
1121
|
+
var parent = this.parent;
|
|
1122
|
+
var center = { x: parent.img.destLeft + (parent.img.destWidth / 2), y: parent.img.destTop + (parent.img.destHeight / 2) };
|
|
1123
|
+
angle = angle ? angle : ((parent.transform.straighten) * (Math.PI / 180));
|
|
1124
|
+
var point = { x: Math.cos(angle) * (x - center.x) - Math.sin(angle) * (y - center.y) + center.x,
|
|
1125
|
+
y: Math.sin(angle) * (x - center.x) + Math.cos(angle) * (y - center.y) + center.y };
|
|
1126
|
+
return point;
|
|
1127
|
+
};
|
|
1128
|
+
Shape.prototype.straightenShapes = function () {
|
|
1129
|
+
var parent = this.parent;
|
|
1130
|
+
var _a = parent.img, destLeft = _a.destLeft, destTop = _a.destTop, destWidth = _a.destWidth, destHeight = _a.destHeight;
|
|
1131
|
+
var straightenObj = { bool: parent.isStraightening };
|
|
1132
|
+
if (!straightenObj['bool'] || parent.transform.straighten === 0) {
|
|
1133
|
+
return;
|
|
1134
|
+
}
|
|
1135
|
+
parent.notify('draw', { prop: 'updateImgCanvasPoints' });
|
|
1136
|
+
var object = { points: null };
|
|
1137
|
+
parent.notify('draw', { prop: 'getImageCanvasPoints', value: { obj: object } });
|
|
1138
|
+
var center = { x: destLeft + (destWidth / 2), y: destTop + (destHeight / 2) };
|
|
1139
|
+
var angle = -((parent.transform.straighten) * (Math.PI / 180));
|
|
1140
|
+
var p1 = { x: Math.cos(angle) * (object['points'][0]['x'] - center.x) - Math.sin(angle) *
|
|
1141
|
+
(object['points'][0]['y'] - center.y) + center.x,
|
|
1142
|
+
y: Math.sin(angle) * (object['points'][0]['x'] - center.x) + Math.cos(angle) *
|
|
1143
|
+
(object['points'][0]['y'] - center.y) + center.y };
|
|
1144
|
+
var p2 = { x: Math.cos(angle) * (object['points'][1]['x'] - center.x) - Math.sin(angle) *
|
|
1145
|
+
(object['points'][1]['y'] - center.y) + center.x,
|
|
1146
|
+
y: Math.sin(angle) * (object['points'][1]['x'] - center.x) + Math.cos(angle) * (object['points'][1]['y']
|
|
1147
|
+
- center.y) + center.y };
|
|
1148
|
+
var p3 = { x: Math.cos(angle) * (object['points'][2]['x'] - center.x) - Math.sin(angle) *
|
|
1149
|
+
(object['points'][2]['y'] - center.y) + center.x,
|
|
1150
|
+
y: Math.sin(angle) * (object['points'][2]['x'] - center.x) + Math.cos(angle) * (object['points'][2]['y']
|
|
1151
|
+
- center.y) + center.y };
|
|
1152
|
+
parent.img.destWidth = p2.x - p1.x;
|
|
1153
|
+
parent.img.destHeight = p3.y - p2.y;
|
|
1154
|
+
parent.img.destLeft = p1.x;
|
|
1155
|
+
parent.img.destTop = p1.y;
|
|
1156
|
+
};
|
|
1157
|
+
Shape.prototype.straightenShapePoints = function (obj, isReverse) {
|
|
1158
|
+
var parent = this.parent;
|
|
1159
|
+
var _a = parent.img, destLeft = _a.destLeft, destTop = _a.destTop, destWidth = _a.destWidth, destHeight = _a.destHeight;
|
|
1160
|
+
var straightenObj = { bool: parent.isStraightening };
|
|
1161
|
+
if (!straightenObj['bool']) {
|
|
1162
|
+
return;
|
|
1163
|
+
}
|
|
1164
|
+
if (obj.shape === 'line' || obj.shape === 'arrow') {
|
|
1165
|
+
obj.activePoint.width = obj.activePoint.endX > obj.activePoint.startX ? obj.activePoint.endX -
|
|
1166
|
+
obj.activePoint.startX : obj.activePoint.startX - obj.activePoint.endX;
|
|
1167
|
+
obj.activePoint.height = obj.activePoint.endY > obj.activePoint.startY ? obj.activePoint.endY -
|
|
1168
|
+
obj.activePoint.startY : obj.activePoint.startY - obj.activePoint.endY;
|
|
1169
|
+
var center = { x: destLeft + (destWidth / 2), y: destTop + (destHeight / 2) };
|
|
1170
|
+
var angle = (isReverse ? -parent.transform.straighten : parent.transform.straighten) * (Math.PI / 180);
|
|
1171
|
+
var start = { x: Math.cos(angle) * (obj.activePoint.startX - center.x) - Math.sin(angle) *
|
|
1172
|
+
(obj.activePoint.startY - center.y) + center.x, y: Math.sin(angle) * (obj.activePoint.startX - center.x) + Math.cos(angle)
|
|
1173
|
+
* (obj.activePoint.startY - center.y) + center.y };
|
|
1174
|
+
var end = { x: Math.cos(angle) * (obj.activePoint.endX - center.x) -
|
|
1175
|
+
Math.sin(angle) * (obj.activePoint.endY - center.y) + center.x, y: Math.sin(angle) * (obj.activePoint.endX - center.x) +
|
|
1176
|
+
Math.cos(angle) * (obj.activePoint.endY - center.y) + center.y };
|
|
1177
|
+
obj.activePoint.startX = start.x;
|
|
1178
|
+
obj.activePoint.startY = start.y;
|
|
1179
|
+
obj.activePoint.endX = end.x;
|
|
1180
|
+
obj.activePoint.endY = end.y;
|
|
1181
|
+
obj.activePoint.width = obj.activePoint.endX > obj.activePoint.startX ? obj.activePoint.endX -
|
|
1182
|
+
obj.activePoint.startX : obj.activePoint.startX - obj.activePoint.endX;
|
|
1183
|
+
obj.activePoint.height = obj.activePoint.endY > obj.activePoint.startY ? obj.activePoint.endY -
|
|
1184
|
+
obj.activePoint.startY : obj.activePoint.startY - obj.activePoint.endY;
|
|
1185
|
+
parent.notify('selection', { prop: 'adjustActObjForLineArrow', onPropertyChange: false, value: { obj: obj } });
|
|
1186
|
+
}
|
|
995
1187
|
};
|
|
996
1188
|
Shape.prototype.redrawObj = function (degree) {
|
|
997
1189
|
var parent = this.parent;
|
|
998
1190
|
var isShape = false;
|
|
999
|
-
if (
|
|
1191
|
+
if (parent.objColl.length > 0) {
|
|
1000
1192
|
if (degree === 'horizontal' || degree === 'vertical' || degree === 'Horizontal' || degree === 'Vertical' ||
|
|
1001
1193
|
degree === 'horizontalVertical' || degree === 'verticalHorizontal') {
|
|
1002
1194
|
this.updateCurrentActiveObjPoint(degree.toLowerCase());
|
|
@@ -1023,6 +1215,7 @@ var Shape = /** @class */ (function () {
|
|
|
1023
1215
|
Shape.prototype.updateCurrentActiveObjPoint = function (degree) {
|
|
1024
1216
|
var parent = this.parent;
|
|
1025
1217
|
var currActObjIndex;
|
|
1218
|
+
var _a = parent.img, destLeft = _a.destLeft, destTop = _a.destTop, destWidth = _a.destWidth, destHeight = _a.destHeight;
|
|
1026
1219
|
for (var index = 0, len = parent.objColl.length; index < len; index++) {
|
|
1027
1220
|
var currObj = parent.objColl[index];
|
|
1028
1221
|
if (parent.activeObj.shape === currObj.shape &&
|
|
@@ -1041,42 +1234,39 @@ var Shape = /** @class */ (function () {
|
|
|
1041
1234
|
for (var i = 0, len = parent.objColl.length; i < len; i++) {
|
|
1042
1235
|
var currObj = parent.objColl[i];
|
|
1043
1236
|
if (currObj.shapeFlip !== parent.transform.currFlipState) {
|
|
1044
|
-
if (currObj.activePoint.startX <=
|
|
1045
|
-
currObj.activePoint.endX = (
|
|
1046
|
-
parent.img.destLeft);
|
|
1237
|
+
if (currObj.activePoint.startX <= destLeft + (destWidth / 2)) {
|
|
1238
|
+
currObj.activePoint.endX = (destLeft + destWidth) - (currObj.activePoint.startX - destLeft);
|
|
1047
1239
|
currObj.activePoint.startX = currObj.activePoint.endX - currObj.activePoint.width;
|
|
1048
1240
|
parent.notify('draw', { prop: 'updateActiveObject', onPropertyChange: false, value: { actPoint: currObj.activePoint, obj: currObj } });
|
|
1049
1241
|
}
|
|
1050
|
-
else if (currObj.activePoint.startX >=
|
|
1051
|
-
currObj.activePoint.startX =
|
|
1052
|
-
currObj.activePoint.endX);
|
|
1242
|
+
else if (currObj.activePoint.startX >= destLeft + (destWidth / 2)) {
|
|
1243
|
+
currObj.activePoint.startX = destLeft + (destLeft + destWidth - currObj.activePoint.endX);
|
|
1053
1244
|
currObj.activePoint.endX = currObj.activePoint.startX + currObj.activePoint.width;
|
|
1054
|
-
parent.notify('draw', { prop: 'updateActiveObject', onPropertyChange: false, value: { actPoint: currObj.activePoint,
|
|
1055
|
-
obj: currObj } });
|
|
1245
|
+
parent.notify('draw', { prop: 'updateActiveObject', onPropertyChange: false, value: { actPoint: currObj.activePoint, obj: currObj } });
|
|
1056
1246
|
}
|
|
1057
1247
|
if (currObj.shape === 'line' || currObj.shape === 'arrow' || currObj.shape === 'path') {
|
|
1058
1248
|
this.flipLineArrowObj(currObj, 'horizontal');
|
|
1059
1249
|
}
|
|
1060
1250
|
else if (currObj.rotatedAngle !== 0) {
|
|
1061
1251
|
currObj.rotatedAngle = currObj.rotatedAngle + (Math.PI - currObj.rotatedAngle) * 2;
|
|
1062
|
-
if (currObj.rotationCirclePointColl.x <=
|
|
1063
|
-
currObj.rotationCirclePointColl.x = (
|
|
1064
|
-
(currObj.rotationCirclePointColl.x -
|
|
1252
|
+
if (currObj.rotationCirclePointColl.x <= destLeft + (destWidth / 2)) {
|
|
1253
|
+
currObj.rotationCirclePointColl.x = (destLeft + destWidth) -
|
|
1254
|
+
(currObj.rotationCirclePointColl.x - destLeft);
|
|
1065
1255
|
}
|
|
1066
|
-
else if (currObj.rotationCirclePointColl.x >=
|
|
1067
|
-
currObj.rotationCirclePointColl.x =
|
|
1068
|
-
(
|
|
1256
|
+
else if (currObj.rotationCirclePointColl.x >= destLeft + (destWidth / 2)) {
|
|
1257
|
+
currObj.rotationCirclePointColl.x = destLeft +
|
|
1258
|
+
(destLeft + destWidth - currObj.rotationCirclePointColl.x);
|
|
1069
1259
|
}
|
|
1070
1260
|
currObj.rotationCirclePointColl.ratioX =
|
|
1071
|
-
(currObj.rotationCirclePointColl.x -
|
|
1261
|
+
(currObj.rotationCirclePointColl.x - destLeft) / destWidth;
|
|
1072
1262
|
}
|
|
1073
1263
|
currObj.shapeFlip = parent.transform.currFlipState;
|
|
1074
|
-
currObj.imageRatio = { startX: ((currObj.activePoint.startX -
|
|
1075
|
-
startY: ((currObj.activePoint.startY -
|
|
1076
|
-
endX: ((currObj.activePoint.endX -
|
|
1077
|
-
endY: ((currObj.activePoint.endY -
|
|
1078
|
-
width:
|
|
1079
|
-
height:
|
|
1264
|
+
currObj.imageRatio = { startX: ((currObj.activePoint.startX - destLeft) / destWidth),
|
|
1265
|
+
startY: ((currObj.activePoint.startY - destTop) / destHeight),
|
|
1266
|
+
endX: ((currObj.activePoint.endX - destLeft) / destWidth),
|
|
1267
|
+
endY: ((currObj.activePoint.endY - destTop) / destHeight),
|
|
1268
|
+
width: destWidth / currObj.activePoint.width,
|
|
1269
|
+
height: destHeight / currObj.activePoint.height };
|
|
1080
1270
|
}
|
|
1081
1271
|
}
|
|
1082
1272
|
}
|
|
@@ -1084,18 +1274,15 @@ var Shape = /** @class */ (function () {
|
|
|
1084
1274
|
for (var i = 0; i < parent.objColl.length; i++) {
|
|
1085
1275
|
var currObj = parent.objColl[i];
|
|
1086
1276
|
if (currObj.shapeFlip !== parent.transform.currFlipState) {
|
|
1087
|
-
if (currObj.activePoint.startY <=
|
|
1088
|
-
currObj.activePoint.endY = (
|
|
1089
|
-
(currObj.activePoint.startY - parent.img.destTop);
|
|
1277
|
+
if (currObj.activePoint.startY <= destTop + (destHeight / 2)) {
|
|
1278
|
+
currObj.activePoint.endY = (destTop + destHeight) - (currObj.activePoint.startY - destTop);
|
|
1090
1279
|
currObj.activePoint.startY = currObj.activePoint.endY - currObj.activePoint.height;
|
|
1091
1280
|
parent.notify('draw', { prop: 'updateActiveObject', onPropertyChange: false, value: { actPoint: currObj.activePoint,
|
|
1092
1281
|
obj: currObj } });
|
|
1093
1282
|
}
|
|
1094
|
-
else if (currObj.activePoint.startY >=
|
|
1095
|
-
currObj.activePoint.startY =
|
|
1096
|
-
|
|
1097
|
-
currObj.activePoint.endY = currObj.activePoint.startY +
|
|
1098
|
-
currObj.activePoint.height;
|
|
1283
|
+
else if (currObj.activePoint.startY >= parent.lowerCanvas.height / 2) {
|
|
1284
|
+
currObj.activePoint.startY = destTop + (destTop + destHeight - currObj.activePoint.endY);
|
|
1285
|
+
currObj.activePoint.endY = currObj.activePoint.startY + currObj.activePoint.height;
|
|
1099
1286
|
parent.notify('draw', { prop: 'updateActiveObject', onPropertyChange: false, value: { actPoint: currObj.activePoint,
|
|
1100
1287
|
obj: currObj } });
|
|
1101
1288
|
}
|
|
@@ -1105,25 +1292,23 @@ var Shape = /** @class */ (function () {
|
|
|
1105
1292
|
}
|
|
1106
1293
|
else if (currObj.rotatedAngle !== 0) {
|
|
1107
1294
|
currObj.rotatedAngle = -currObj.rotatedAngle;
|
|
1108
|
-
if (currObj.rotationCirclePointColl.y <=
|
|
1109
|
-
currObj.rotationCirclePointColl.y = (
|
|
1110
|
-
(currObj.rotationCirclePointColl.y - parent.img.destTop);
|
|
1295
|
+
if (currObj.rotationCirclePointColl.y <= destTop + (destHeight / 2)) {
|
|
1296
|
+
currObj.rotationCirclePointColl.y = (destTop + destHeight) - (currObj.rotationCirclePointColl.y - destTop);
|
|
1111
1297
|
}
|
|
1112
|
-
else if (currObj.rotationCirclePointColl.y >=
|
|
1113
|
-
(
|
|
1114
|
-
currObj.rotationCirclePointColl.y =
|
|
1115
|
-
parent.img.destHeight - currObj.rotationCirclePointColl.y);
|
|
1298
|
+
else if (currObj.rotationCirclePointColl.y >= destTop +
|
|
1299
|
+
(destHeight / 2)) {
|
|
1300
|
+
currObj.rotationCirclePointColl.y = destTop + (destTop + destHeight - currObj.rotationCirclePointColl.y);
|
|
1116
1301
|
}
|
|
1117
1302
|
currObj.rotationCirclePointColl.ratioY =
|
|
1118
|
-
(currObj.rotationCirclePointColl.y -
|
|
1303
|
+
(currObj.rotationCirclePointColl.y - destTop) / destHeight;
|
|
1119
1304
|
}
|
|
1120
1305
|
currObj.shapeFlip = parent.transform.currFlipState;
|
|
1121
|
-
currObj.imageRatio = { startX: ((currObj.activePoint.startX -
|
|
1122
|
-
startY: ((currObj.activePoint.startY -
|
|
1123
|
-
endX: ((currObj.activePoint.endX -
|
|
1124
|
-
endY: ((currObj.activePoint.endY -
|
|
1125
|
-
width:
|
|
1126
|
-
height:
|
|
1306
|
+
currObj.imageRatio = { startX: ((currObj.activePoint.startX - destLeft) / destWidth),
|
|
1307
|
+
startY: ((currObj.activePoint.startY - destTop) / destHeight),
|
|
1308
|
+
endX: ((currObj.activePoint.endX - destLeft) / destWidth),
|
|
1309
|
+
endY: ((currObj.activePoint.endY - destTop) / destHeight),
|
|
1310
|
+
width: destWidth / currObj.activePoint.width,
|
|
1311
|
+
height: destHeight / currObj.activePoint.height };
|
|
1127
1312
|
}
|
|
1128
1313
|
}
|
|
1129
1314
|
}
|
|
@@ -1131,28 +1316,28 @@ var Shape = /** @class */ (function () {
|
|
|
1131
1316
|
for (var i = 0, len = parent.objColl.length; i < len; i++) {
|
|
1132
1317
|
var currObj = parent.objColl[i];
|
|
1133
1318
|
if (currObj.shapeFlip !== parent.transform.currFlipState) {
|
|
1134
|
-
if (currObj.activePoint.startX <=
|
|
1135
|
-
currObj.activePoint.endX = (
|
|
1136
|
-
|
|
1319
|
+
if (currObj.activePoint.startX <= destLeft + (destWidth / 2)) {
|
|
1320
|
+
currObj.activePoint.endX = (destLeft + destWidth) - (currObj.activePoint.startX -
|
|
1321
|
+
destLeft);
|
|
1137
1322
|
currObj.activePoint.startX = currObj.activePoint.endX - currObj.activePoint.width;
|
|
1138
1323
|
parent.notify('draw', { prop: 'updateActiveObject', onPropertyChange: false, value: { actPoint: currObj.activePoint, obj: currObj } });
|
|
1139
1324
|
}
|
|
1140
|
-
else if (currObj.activePoint.startX >=
|
|
1141
|
-
currObj.activePoint.startX =
|
|
1142
|
-
|
|
1325
|
+
else if (currObj.activePoint.startX >= destLeft + (destWidth / 2)) {
|
|
1326
|
+
currObj.activePoint.startX = destLeft + (destLeft +
|
|
1327
|
+
destWidth - currObj.activePoint.endX);
|
|
1143
1328
|
currObj.activePoint.endX = currObj.activePoint.startX + currObj.activePoint.width;
|
|
1144
1329
|
parent.notify('draw', { prop: 'updateActiveObject', onPropertyChange: false, value: { actPoint: currObj.activePoint, obj: currObj } });
|
|
1145
1330
|
}
|
|
1146
|
-
if (currObj.activePoint.startY <=
|
|
1147
|
-
currObj.activePoint.endY = (
|
|
1148
|
-
(currObj.activePoint.startY -
|
|
1331
|
+
if (currObj.activePoint.startY <= destTop + (destHeight / 2)) {
|
|
1332
|
+
currObj.activePoint.endY = (destTop + destHeight) -
|
|
1333
|
+
(currObj.activePoint.startY - destTop);
|
|
1149
1334
|
currObj.activePoint.startY = currObj.activePoint.endY -
|
|
1150
1335
|
currObj.activePoint.height;
|
|
1151
1336
|
parent.notify('draw', { prop: 'updateActiveObject', onPropertyChange: false, value: { actPoint: currObj.activePoint, obj: currObj } });
|
|
1152
1337
|
}
|
|
1153
|
-
else if (currObj.activePoint.startY >=
|
|
1154
|
-
currObj.activePoint.startY =
|
|
1155
|
-
|
|
1338
|
+
else if (currObj.activePoint.startY >= parent.lowerCanvas.height / 2) {
|
|
1339
|
+
currObj.activePoint.startY = destTop + (destTop +
|
|
1340
|
+
destHeight - currObj.activePoint.endY);
|
|
1156
1341
|
currObj.activePoint.endY = currObj.activePoint.startY +
|
|
1157
1342
|
currObj.activePoint.height;
|
|
1158
1343
|
parent.notify('draw', { prop: 'updateActiveObject', onPropertyChange: false, value: { actPoint: currObj.activePoint, obj: currObj } });
|
|
@@ -1161,12 +1346,12 @@ var Shape = /** @class */ (function () {
|
|
|
1161
1346
|
this.flipLineArrowObj(currObj, degree);
|
|
1162
1347
|
}
|
|
1163
1348
|
currObj.shapeFlip = parent.transform.currFlipState;
|
|
1164
|
-
currObj.imageRatio = { startX: ((currObj.activePoint.startX -
|
|
1165
|
-
startY: ((currObj.activePoint.startY -
|
|
1166
|
-
endX: ((currObj.activePoint.endX -
|
|
1167
|
-
endY: ((currObj.activePoint.endY -
|
|
1168
|
-
width:
|
|
1169
|
-
height:
|
|
1349
|
+
currObj.imageRatio = { startX: ((currObj.activePoint.startX - destLeft) / destWidth),
|
|
1350
|
+
startY: ((currObj.activePoint.startY - destTop) / destHeight),
|
|
1351
|
+
endX: ((currObj.activePoint.endX - destLeft) / destWidth),
|
|
1352
|
+
endY: ((currObj.activePoint.endY - destTop) / destHeight),
|
|
1353
|
+
width: destWidth / currObj.activePoint.width,
|
|
1354
|
+
height: destHeight / currObj.activePoint.height };
|
|
1170
1355
|
}
|
|
1171
1356
|
}
|
|
1172
1357
|
}
|
|
@@ -1195,45 +1380,41 @@ var Shape = /** @class */ (function () {
|
|
|
1195
1380
|
};
|
|
1196
1381
|
Shape.prototype.rotateObjColl = function () {
|
|
1197
1382
|
var parent = this.parent;
|
|
1383
|
+
var _a = parent.img, destWidth = _a.destWidth, destHeight = _a.destHeight, destLeft = _a.destLeft, destTop = _a.destTop;
|
|
1198
1384
|
for (var i = 0, len = parent.objColl.length; i < len; i++) {
|
|
1199
1385
|
var currObj = parent.objColl[i];
|
|
1200
|
-
|
|
1201
|
-
currObj.activePoint.
|
|
1202
|
-
currObj.activePoint.
|
|
1203
|
-
|
|
1204
|
-
currObj.activePoint.endX = (
|
|
1205
|
-
(parent.img.destWidth * currObj.imageRatio.startY);
|
|
1386
|
+
var shape = currObj.shape;
|
|
1387
|
+
currObj.activePoint.startY = destTop + (destHeight * currObj.imageRatio.startX);
|
|
1388
|
+
currObj.activePoint.endY = destTop + (destHeight * currObj.imageRatio.endX);
|
|
1389
|
+
currObj.activePoint.startX = (destLeft + destWidth) - (destWidth * currObj.imageRatio.endY);
|
|
1390
|
+
currObj.activePoint.endX = (destLeft + destWidth) - (destWidth * currObj.imageRatio.startY);
|
|
1206
1391
|
currObj = this.updateWidthHeight(parent.objColl[i]);
|
|
1207
1392
|
this.updateFontSize(currObj);
|
|
1208
|
-
if (
|
|
1209
|
-
currObj.shape === 'path') {
|
|
1393
|
+
if (shape === 'line' || shape === 'arrow' || shape === 'path') {
|
|
1210
1394
|
this.rotateLineArrowObj(currObj);
|
|
1211
|
-
if (
|
|
1395
|
+
if (shape === 'arrow') {
|
|
1212
1396
|
this.updateArrowSize(currObj);
|
|
1213
1397
|
}
|
|
1214
1398
|
}
|
|
1215
1399
|
else if (currObj.rotatedAngle !== 0) {
|
|
1216
|
-
currObj.rotationCirclePointColl.y =
|
|
1217
|
-
currObj.rotationCirclePointColl.x = (
|
|
1218
|
-
(
|
|
1219
|
-
currObj.rotationCirclePointColl.ratioX = (currObj.rotationCirclePointColl.x
|
|
1220
|
-
|
|
1221
|
-
currObj.rotationCirclePointColl.ratioY = (currObj.rotationCirclePointColl.y
|
|
1222
|
-
- parent.img.destTop) / parent.img.destHeight;
|
|
1400
|
+
currObj.rotationCirclePointColl.y = destTop + (destHeight * currObj.rotationCirclePointColl.ratioX);
|
|
1401
|
+
currObj.rotationCirclePointColl.x = (destLeft + destWidth) -
|
|
1402
|
+
(destWidth * currObj.rotationCirclePointColl.ratioY);
|
|
1403
|
+
currObj.rotationCirclePointColl.ratioX = (currObj.rotationCirclePointColl.x - destLeft) / destWidth;
|
|
1404
|
+
currObj.rotationCirclePointColl.ratioY = (currObj.rotationCirclePointColl.y - destTop) / destHeight;
|
|
1223
1405
|
}
|
|
1224
1406
|
}
|
|
1225
1407
|
for (var i = 0, len = parent.objColl.length; i < len; i++) {
|
|
1226
1408
|
parent.notify('draw', { prop: 'updateActiveObject', onPropertyChange: false, value: { actPoint: parent.objColl[i].activePoint, obj: parent.objColl[i] } });
|
|
1227
1409
|
}
|
|
1228
|
-
// Update current image ratio for all objects
|
|
1229
1410
|
for (var i = 0, len = parent.objColl.length; i < len; i++) {
|
|
1230
1411
|
var currObj = parent.objColl[i];
|
|
1231
|
-
currObj.imageRatio = { startX: ((currObj.activePoint.startX -
|
|
1232
|
-
startY: ((currObj.activePoint.startY -
|
|
1233
|
-
endX: ((currObj.activePoint.endX -
|
|
1234
|
-
endY: ((currObj.activePoint.endY -
|
|
1235
|
-
width:
|
|
1236
|
-
height:
|
|
1412
|
+
currObj.imageRatio = { startX: ((currObj.activePoint.startX - destLeft) / destWidth),
|
|
1413
|
+
startY: ((currObj.activePoint.startY - destTop) / destHeight),
|
|
1414
|
+
endX: ((currObj.activePoint.endX - destLeft) / destWidth),
|
|
1415
|
+
endY: ((currObj.activePoint.endY - destTop) / destHeight),
|
|
1416
|
+
width: destWidth / currObj.activePoint.width,
|
|
1417
|
+
height: destHeight / currObj.activePoint.height };
|
|
1237
1418
|
}
|
|
1238
1419
|
};
|
|
1239
1420
|
Shape.prototype.rotateLineArrowObj = function (obj) {
|
|
@@ -1241,15 +1422,16 @@ var Shape = /** @class */ (function () {
|
|
|
1241
1422
|
return;
|
|
1242
1423
|
}
|
|
1243
1424
|
var parent = this.parent;
|
|
1425
|
+
var _a = parent.img, destWidth = _a.destWidth, destHeight = _a.destHeight, destLeft = _a.destLeft, destTop = _a.destTop;
|
|
1244
1426
|
if (obj.pointColl.length > 0) {
|
|
1245
1427
|
for (var n = 0; n < obj.pointColl.length; n++) {
|
|
1246
|
-
obj.pointColl[n].y =
|
|
1247
|
-
obj.pointColl[n].x = (
|
|
1428
|
+
obj.pointColl[n].y = destTop + (destHeight * obj.pointColl[n].ratioX);
|
|
1429
|
+
obj.pointColl[n].x = (destLeft + destWidth) - (destWidth *
|
|
1248
1430
|
obj.pointColl[n].ratioY);
|
|
1249
1431
|
}
|
|
1250
1432
|
for (var n = 0; n < obj.pointColl.length; n++) {
|
|
1251
|
-
obj.pointColl[n].ratioX = (obj.pointColl[n].x -
|
|
1252
|
-
obj.pointColl[n].ratioY = (obj.pointColl[n].y -
|
|
1433
|
+
obj.pointColl[n].ratioX = (obj.pointColl[n].x - destLeft) / destWidth;
|
|
1434
|
+
obj.pointColl[n].ratioY = (obj.pointColl[n].y - destTop) / destHeight;
|
|
1253
1435
|
}
|
|
1254
1436
|
var prevPoint = void 0;
|
|
1255
1437
|
if (isNullOrUndefined(obj.pointColl[obj.pointColl.length - 2])) {
|
|
@@ -1268,13 +1450,14 @@ var Shape = /** @class */ (function () {
|
|
|
1268
1450
|
}
|
|
1269
1451
|
};
|
|
1270
1452
|
Shape.prototype.flipLineArrowObj = function (obj, value) {
|
|
1453
|
+
value = value.toLowerCase();
|
|
1271
1454
|
if (isNullOrUndefined(obj.pointColl)) {
|
|
1272
1455
|
return;
|
|
1273
1456
|
}
|
|
1274
|
-
if (value
|
|
1457
|
+
if (value === 'horizontal') {
|
|
1275
1458
|
this.lineArrowHorizontalFlip(obj);
|
|
1276
1459
|
}
|
|
1277
|
-
else if (value
|
|
1460
|
+
else if (value === 'vertical') {
|
|
1278
1461
|
this.lineArrowVerticalFlip(obj);
|
|
1279
1462
|
}
|
|
1280
1463
|
else {
|
|
@@ -1297,20 +1480,18 @@ var Shape = /** @class */ (function () {
|
|
|
1297
1480
|
};
|
|
1298
1481
|
Shape.prototype.lineArrowHorizontalFlip = function (obj) {
|
|
1299
1482
|
var parent = this.parent;
|
|
1300
|
-
|
|
1483
|
+
var _a = parent.img, destWidth = _a.destWidth, destHeight = _a.destHeight, destLeft = _a.destLeft, destTop = _a.destTop;
|
|
1301
1484
|
if (obj.shapeFlip !== parent.transform.currFlipState) {
|
|
1302
1485
|
for (var l = 0, len = obj.pointColl.length; l < len; l++) {
|
|
1303
1486
|
var currPoint = obj.pointColl[l];
|
|
1304
|
-
if (currPoint.x <=
|
|
1305
|
-
currPoint.x = (
|
|
1306
|
-
- parent.img.destLeft);
|
|
1487
|
+
if (currPoint.x <= destLeft + (destWidth / 2)) {
|
|
1488
|
+
currPoint.x = (destLeft + destWidth) - (currPoint.x - destLeft);
|
|
1307
1489
|
}
|
|
1308
|
-
else if (currPoint.x >=
|
|
1309
|
-
currPoint.x =
|
|
1310
|
-
currPoint.x);
|
|
1490
|
+
else if (currPoint.x >= destLeft + (destWidth / 2)) {
|
|
1491
|
+
currPoint.x = destLeft + (destLeft + destWidth - currPoint.x);
|
|
1311
1492
|
}
|
|
1312
|
-
currPoint.ratioX = (currPoint.x -
|
|
1313
|
-
currPoint.ratioY = (currPoint.y -
|
|
1493
|
+
currPoint.ratioX = (currPoint.x - destLeft) / destWidth;
|
|
1494
|
+
currPoint.ratioY = (currPoint.y - destTop) / destHeight;
|
|
1314
1495
|
}
|
|
1315
1496
|
if (obj.shape === 'arrow') {
|
|
1316
1497
|
var value = obj.start;
|
|
@@ -1322,20 +1503,18 @@ var Shape = /** @class */ (function () {
|
|
|
1322
1503
|
};
|
|
1323
1504
|
Shape.prototype.lineArrowVerticalFlip = function (obj) {
|
|
1324
1505
|
var parent = this.parent;
|
|
1325
|
-
|
|
1506
|
+
var _a = parent.img, destWidth = _a.destWidth, destHeight = _a.destHeight, destLeft = _a.destLeft, destTop = _a.destTop;
|
|
1326
1507
|
if (obj.shapeFlip !== parent.transform.currFlipState) {
|
|
1327
1508
|
for (var l = 0, len = obj.pointColl.length; l < len; l++) {
|
|
1328
1509
|
var currPoint = obj.pointColl[l];
|
|
1329
|
-
if (currPoint.y <=
|
|
1330
|
-
currPoint.y = (
|
|
1331
|
-
(currPoint.y - parent.img.destTop);
|
|
1510
|
+
if (currPoint.y <= destTop + (destHeight / 2)) {
|
|
1511
|
+
currPoint.y = (destTop + destHeight) - (currPoint.y - destTop);
|
|
1332
1512
|
}
|
|
1333
|
-
else if (currPoint.y >=
|
|
1334
|
-
currPoint.y =
|
|
1335
|
-
currPoint.y);
|
|
1513
|
+
else if (currPoint.y >= destTop + (destHeight / 2)) {
|
|
1514
|
+
currPoint.y = destTop + (destTop + destHeight - currPoint.y);
|
|
1336
1515
|
}
|
|
1337
|
-
currPoint.ratioX = (currPoint.x -
|
|
1338
|
-
currPoint.ratioY = (currPoint.y -
|
|
1516
|
+
currPoint.ratioX = (currPoint.x - destLeft) / destWidth;
|
|
1517
|
+
currPoint.ratioY = (currPoint.y - destTop) / destHeight;
|
|
1339
1518
|
}
|
|
1340
1519
|
obj.shapeFlip = parent.transform.currFlipState;
|
|
1341
1520
|
}
|
|
@@ -1357,20 +1536,23 @@ var Shape = /** @class */ (function () {
|
|
|
1357
1536
|
var parent = this.parent;
|
|
1358
1537
|
var degree = this.getRotDegOfShape(parent.activeObj);
|
|
1359
1538
|
this.transformTextArea();
|
|
1360
|
-
if (
|
|
1361
|
-
parent.
|
|
1539
|
+
if (isBlazor()) {
|
|
1540
|
+
parent.updateToolbar(parent.element, 'destroyQuickAccessToolbar');
|
|
1362
1541
|
}
|
|
1363
1542
|
else {
|
|
1364
|
-
parent.
|
|
1543
|
+
parent.notify('toolbar', { prop: 'destroy-qa-toolbar', onPropertyChange: false });
|
|
1365
1544
|
}
|
|
1366
|
-
|
|
1367
|
-
|
|
1545
|
+
var dupElem = parent.element.querySelector('#' + parent.element.id + '_duplicate');
|
|
1546
|
+
var removeElem = parent.element.querySelector('#' + parent.element.id + '_remove');
|
|
1547
|
+
var editTextElem = parent.element.querySelector('#' + parent.element.id + '_editText');
|
|
1548
|
+
if (dupElem) {
|
|
1549
|
+
dupElem.classList.add('e-disabled');
|
|
1368
1550
|
}
|
|
1369
|
-
if (
|
|
1370
|
-
|
|
1551
|
+
if (removeElem) {
|
|
1552
|
+
removeElem.classList.add('e-disabled');
|
|
1371
1553
|
}
|
|
1372
|
-
if (
|
|
1373
|
-
|
|
1554
|
+
if (editTextElem) {
|
|
1555
|
+
editTextElem.classList.add('e-disabled');
|
|
1374
1556
|
}
|
|
1375
1557
|
parent.textArea.style.display = 'block';
|
|
1376
1558
|
parent.textArea.style.left = x + 'px';
|
|
@@ -1402,6 +1584,9 @@ var Shape = /** @class */ (function () {
|
|
|
1402
1584
|
if (obj['flipColl'].length <= 1) {
|
|
1403
1585
|
this.setTextBoxHeight();
|
|
1404
1586
|
}
|
|
1587
|
+
if (parseFloat(parent.textArea.style.maxHeight) < parent.activeObj.textSettings.fontSize) {
|
|
1588
|
+
parent.textArea.style.maxHeight = parent.activeObj.textSettings.fontSize + 'px';
|
|
1589
|
+
}
|
|
1405
1590
|
if (degree % 90 === 0 && degree % 180 !== 0) {
|
|
1406
1591
|
if (parseFloat(parent.textArea.style.left) + parseFloat(parent.textArea.style.width) > parent.img.destTop +
|
|
1407
1592
|
parent.img.destHeight) {
|
|
@@ -1414,12 +1599,83 @@ var Shape = /** @class */ (function () {
|
|
|
1414
1599
|
this.alignTextAreaIntoCanvas();
|
|
1415
1600
|
}
|
|
1416
1601
|
}
|
|
1602
|
+
// Limit text area
|
|
1603
|
+
if (actObj.rotatedAngle !== 0) {
|
|
1604
|
+
var tempLeft = parseFloat(parent.textArea.style.left);
|
|
1605
|
+
var tempTop = parseFloat(parent.textArea.style.top);
|
|
1606
|
+
if (actObj.flipObjColl.length > 0) {
|
|
1607
|
+
var panObj = { panRegion: '' };
|
|
1608
|
+
var _b = parent.lowerCanvas, clientWidth = _b.clientWidth, clientHeight = _b.clientHeight;
|
|
1609
|
+
var center_1 = { x: 0, y: 0 };
|
|
1610
|
+
parent.notify('crop', { prop: 'getCurrFlipState', onPropertyChange: false,
|
|
1611
|
+
value: { panObj: panObj } });
|
|
1612
|
+
if (panObj['panRegion'] !== '') {
|
|
1613
|
+
if (panObj['panRegion'] === 'horizontal') {
|
|
1614
|
+
center_1.x = clientWidth - (clientWidth / 2);
|
|
1615
|
+
tempLeft = (center_1.x - tempLeft) + center_1.x;
|
|
1616
|
+
}
|
|
1617
|
+
else if (panObj['panRegion'] === 'vertical') {
|
|
1618
|
+
center_1.y = clientHeight - (clientHeight / 2);
|
|
1619
|
+
tempTop = (center_1.y - tempTop) + center_1.y;
|
|
1620
|
+
}
|
|
1621
|
+
else {
|
|
1622
|
+
center_1 = { x: clientWidth - (clientWidth / 2), y: clientHeight - (clientHeight / 2) };
|
|
1623
|
+
tempLeft = (center_1.x - tempLeft) + center_1.x;
|
|
1624
|
+
tempTop = (center_1.y - tempTop) + center_1.y;
|
|
1625
|
+
}
|
|
1626
|
+
}
|
|
1627
|
+
}
|
|
1628
|
+
var left = tempLeft + parseFloat(parent.textArea.style.width);
|
|
1629
|
+
var top_1 = tempTop + parseFloat(parent.textArea.style.height);
|
|
1630
|
+
var width1 = parseFloat(parent.textArea.style.width);
|
|
1631
|
+
var height1 = parseFloat(parent.textArea.style.height);
|
|
1632
|
+
var center = { x: left - (width1 / 2), y: top_1 - (height1 / 2) };
|
|
1633
|
+
var cosAngle = Math.cos(actObj.rotatedAngle);
|
|
1634
|
+
var sinAngle = Math.sin(actObj.rotatedAngle);
|
|
1635
|
+
var p1 = { x: cosAngle * (left - center.x) - sinAngle * (top_1 - center.y) + center.x,
|
|
1636
|
+
y: sinAngle * (left - center.x) + cosAngle * (top_1 - center.y) + center.y };
|
|
1637
|
+
if (p1.x > parent.img.destLeft && p1.x < parent.img.destLeft + parent.img.destWidth &&
|
|
1638
|
+
p1.y > parent.img.destTop && p1.y + parseFloat(parent.textArea.style.fontSize) < parent.img.destTop + parent.img.destHeight) {
|
|
1639
|
+
parent.textArea.style.width = parent.textArea.style.width;
|
|
1640
|
+
}
|
|
1641
|
+
else {
|
|
1642
|
+
var count = 0;
|
|
1643
|
+
var width2 = parseFloat(parent.textArea.style.width);
|
|
1644
|
+
while (true) {
|
|
1645
|
+
count++;
|
|
1646
|
+
width1 -= 1;
|
|
1647
|
+
left = tempLeft + width1;
|
|
1648
|
+
center = { x: left - (width1 / 2), y: top_1 - (height1 / 2) };
|
|
1649
|
+
p1 = { x: cosAngle * (left - center.x) - sinAngle * (top_1 - center.y) + center.x,
|
|
1650
|
+
y: sinAngle * (left - center.x) + cosAngle * (top_1 - center.y) + center.y };
|
|
1651
|
+
if ((p1.x > parent.img.destLeft && p1.x < parent.img.destLeft + parent.img.destWidth &&
|
|
1652
|
+
p1.y > parent.img.destTop && p1.y + parseFloat(parent.textArea.style.fontSize) < parent.img.destTop + parent.img.destHeight) ||
|
|
1653
|
+
count === width2) {
|
|
1654
|
+
parent.textArea.style.width = width1 + 'px';
|
|
1655
|
+
break;
|
|
1656
|
+
}
|
|
1657
|
+
}
|
|
1658
|
+
}
|
|
1659
|
+
}
|
|
1417
1660
|
parent.notify('selection', { prop: 'clearUpperCanvas', onPropertyChange: false });
|
|
1418
1661
|
};
|
|
1419
1662
|
Shape.prototype.setTextBoxWidth = function (e) {
|
|
1420
1663
|
var parent = this.parent;
|
|
1664
|
+
if (parent.activeObj.rotatedAngle !== 0) {
|
|
1665
|
+
parent.textArea.style.whiteSpace = 'nowrap';
|
|
1666
|
+
parent.textArea.style.textOverflow = 'ellipsis';
|
|
1667
|
+
parent.textArea.style.display = 'inline-block';
|
|
1668
|
+
return;
|
|
1669
|
+
}
|
|
1670
|
+
else {
|
|
1671
|
+
parent.textArea.style.whiteSpace = '';
|
|
1672
|
+
parent.textArea.style.textOverflow = '';
|
|
1673
|
+
if (parent.textArea.style.display === 'inline-block') {
|
|
1674
|
+
parent.textArea.style.display = 'block';
|
|
1675
|
+
}
|
|
1676
|
+
}
|
|
1421
1677
|
var text = this.getMaxText(true);
|
|
1422
|
-
if (parent.textArea.style.display === 'block') {
|
|
1678
|
+
if (parent.textArea.style.display === 'block' || parent.textArea.style.display === 'inline-block') {
|
|
1423
1679
|
this.updateFontStyles(true);
|
|
1424
1680
|
}
|
|
1425
1681
|
else {
|
|
@@ -1562,15 +1818,15 @@ var Shape = /** @class */ (function () {
|
|
|
1562
1818
|
var obj = { shape: null };
|
|
1563
1819
|
parent.notify('selection', { prop: 'getCurrentDrawingShape', value: { obj: obj } });
|
|
1564
1820
|
if (obj['shape'] === 'path') {
|
|
1565
|
-
var prevCropObj = extend({},
|
|
1821
|
+
var prevCropObj = extend({}, parent.cropObj, {}, true);
|
|
1566
1822
|
var object = { currObj: {} };
|
|
1567
|
-
|
|
1823
|
+
parent.notify('filter', { prop: 'getCurrentObj', onPropertyChange: false, value: { object: object } });
|
|
1568
1824
|
var prevObj = object['currObj'];
|
|
1569
|
-
prevObj.objColl = extend([],
|
|
1570
|
-
prevObj.pointColl = extend([],
|
|
1571
|
-
prevObj.afterCropActions = extend([],
|
|
1825
|
+
prevObj.objColl = extend([], parent.objColl, [], true);
|
|
1826
|
+
prevObj.pointColl = extend([], parent.pointColl, [], true);
|
|
1827
|
+
prevObj.afterCropActions = extend([], parent.afterCropActions, [], true);
|
|
1572
1828
|
var selPointCollObj = { selPointColl: null };
|
|
1573
|
-
|
|
1829
|
+
parent.notify('freehand-draw', { prop: 'getSelPointColl', onPropertyChange: false,
|
|
1574
1830
|
value: { obj: selPointCollObj } });
|
|
1575
1831
|
prevObj.selPointColl = extend([], selPointCollObj['selPointColl'], [], true);
|
|
1576
1832
|
parent.notify('selection', { prop: 'setCurrentDrawingShape', value: { value: '' } });
|
|
@@ -1579,6 +1835,9 @@ var Shape = /** @class */ (function () {
|
|
|
1579
1835
|
parent.activeObj.pointColl.pop();
|
|
1580
1836
|
}
|
|
1581
1837
|
this.updatePathRatio(parent.activeObj);
|
|
1838
|
+
if (isNullOrUndefined(parent.activeObj.imageRatio)) {
|
|
1839
|
+
parent.notify('shape', { prop: 'updImgRatioForActObj', onPropertyChange: false });
|
|
1840
|
+
}
|
|
1582
1841
|
parent.objColl.push(parent.activeObj);
|
|
1583
1842
|
parent.notify('undo-redo', { prop: 'updateUndoRedoColl', onPropertyChange: false,
|
|
1584
1843
|
value: { operation: 'shapeTransform', previousObj: prevObj, previousObjColl: prevObj.objColl,
|
|
@@ -1588,6 +1847,8 @@ var Shape = /** @class */ (function () {
|
|
|
1588
1847
|
parent.objColl.pop();
|
|
1589
1848
|
if (e) {
|
|
1590
1849
|
parent.notify('selection', { prop: 'mouseUpEventHandler', value: { e: e } });
|
|
1850
|
+
this.lowerContext.clearRect(0, 0, parent.lowerCanvas.width, parent.lowerCanvas.height);
|
|
1851
|
+
parent.notify('draw', { prop: 'redrawImgWithObj', onPropertyChange: false });
|
|
1591
1852
|
}
|
|
1592
1853
|
parent.notify('draw', { prop: 'setNewPath', value: { bool: true } });
|
|
1593
1854
|
if (parent.objColl[parent.objColl.length - 1]) {
|
|
@@ -1602,8 +1863,8 @@ var Shape = /** @class */ (function () {
|
|
|
1602
1863
|
var obj_1 = { shapeSettingsObj: {} };
|
|
1603
1864
|
parent.notify('selection', { prop: 'updatePrevShapeSettings', onPropertyChange: false, value: { obj: obj_1 } });
|
|
1604
1865
|
var shapeSettings = obj_1['shapeSettingsObj'];
|
|
1605
|
-
var shapeResizingArgs = { action: 'draw-end', previousShapeSettings: shapeSettings };
|
|
1606
|
-
var shapeMovingArgs = { action: 'move', previousShapeSettings: shapeSettings };
|
|
1866
|
+
var shapeResizingArgs = { cancel: false, action: 'draw-end', previousShapeSettings: shapeSettings };
|
|
1867
|
+
var shapeMovingArgs = { cancel: false, action: 'move', previousShapeSettings: shapeSettings };
|
|
1607
1868
|
parent.notify('selection', { prop: 'triggerShapeChange', onPropertyChange: false,
|
|
1608
1869
|
value: { shapeResizingArgs: shapeResizingArgs, shapeMovingArgs: shapeMovingArgs, type: 'mouse-up' } });
|
|
1609
1870
|
}
|
|
@@ -1612,8 +1873,23 @@ var Shape = /** @class */ (function () {
|
|
|
1612
1873
|
Shape.prototype.findTextTarget = function (e) {
|
|
1613
1874
|
var parent = this.parent;
|
|
1614
1875
|
if (parent.activeObj.shape !== 'text') {
|
|
1615
|
-
|
|
1616
|
-
|
|
1876
|
+
if (parent.activeObj.shape === 'path') {
|
|
1877
|
+
this.stopPathDrawing(e, null);
|
|
1878
|
+
return;
|
|
1879
|
+
}
|
|
1880
|
+
else if (e.type === 'dblclick') {
|
|
1881
|
+
var objColl = extend([], parent.objColl, [], true);
|
|
1882
|
+
var obj = { bool: null };
|
|
1883
|
+
parent.notify('selection', { prop: 'findTargetObj', onPropertyChange: false,
|
|
1884
|
+
value: { x: e.clientX, y: e.clientY, isCrop: false, obj: obj } });
|
|
1885
|
+
parent.objColl = objColl;
|
|
1886
|
+
if (!obj['bool'] || parent.activeObj.shape !== 'text') {
|
|
1887
|
+
return;
|
|
1888
|
+
}
|
|
1889
|
+
}
|
|
1890
|
+
else {
|
|
1891
|
+
return;
|
|
1892
|
+
}
|
|
1617
1893
|
}
|
|
1618
1894
|
var x;
|
|
1619
1895
|
var y;
|
|
@@ -1638,7 +1914,7 @@ var Shape = /** @class */ (function () {
|
|
|
1638
1914
|
parent.updateToolbar(parent.element, 'enableDisableToolbarBtn', 'textAreaClicked');
|
|
1639
1915
|
}
|
|
1640
1916
|
if (!isNullOrUndefined(x) && !isNullOrUndefined(y)) {
|
|
1641
|
-
var bbox =
|
|
1917
|
+
var bbox = parent.lowerCanvas.getBoundingClientRect();
|
|
1642
1918
|
x -= bbox.left;
|
|
1643
1919
|
y -= bbox.top;
|
|
1644
1920
|
var flip = '';
|
|
@@ -1671,11 +1947,12 @@ var Shape = /** @class */ (function () {
|
|
|
1671
1947
|
}
|
|
1672
1948
|
}
|
|
1673
1949
|
this.refreshActiveObj();
|
|
1674
|
-
this.upperContext.clearRect(0, 0,
|
|
1675
|
-
this.lowerContext.clearRect(0, 0,
|
|
1950
|
+
this.upperContext.clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
|
|
1951
|
+
this.lowerContext.clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
|
|
1676
1952
|
parent.notify('draw', { prop: 'redrawImgWithObj', onPropertyChange: false });
|
|
1677
|
-
|
|
1678
|
-
|
|
1953
|
+
parent.notify('draw', { prop: 'redrawDownScale' });
|
|
1954
|
+
parent.notify('draw', { prop: 'clearOuterCanvas', onPropertyChange: false, value: { context: this.lowerContext } });
|
|
1955
|
+
parent.notify('draw', { prop: 'clearOuterCanvas', onPropertyChange: false, value: { context: this.upperContext } });
|
|
1679
1956
|
if ((parent.currSelectionPoint && parent.currSelectionPoint.shape === 'crop-circle') || parent.isCircleCrop) {
|
|
1680
1957
|
parent.notify('crop', { prop: 'cropCircle', onPropertyChange: false,
|
|
1681
1958
|
value: { context: this.lowerContext, isSave: null, isFlip: null } });
|
|
@@ -1683,11 +1960,29 @@ var Shape = /** @class */ (function () {
|
|
|
1683
1960
|
parent.activeObj = temp;
|
|
1684
1961
|
this.updateFontStyles();
|
|
1685
1962
|
var actObj = extend({}, parent.activeObj, {}, true);
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1963
|
+
var radius = actObj.topLeftCircle.radius;
|
|
1964
|
+
var _a = actObj.activePoint, startX = _a.startX, startY = _a.startY, endX = _a.endX, endY = _a.endY, width = _a.width, height = _a.height;
|
|
1965
|
+
var center = { x: startX + (width / 2), y: startY +
|
|
1966
|
+
(height / 2) };
|
|
1967
|
+
var cosAngle = Math.cos(actObj.rotatedAngle);
|
|
1968
|
+
var sinAngle = Math.sin(actObj.rotatedAngle);
|
|
1969
|
+
var p1 = { x: cosAngle * (startX - center.x) - sinAngle * (startY - center.y) + center.x,
|
|
1970
|
+
y: sinAngle * (startX - center.x) + cosAngle * (startY - center.y) + center.y };
|
|
1971
|
+
var p2 = { x: cosAngle * (endX - center.x) - sinAngle * (startY - center.y) + center.x,
|
|
1972
|
+
y: sinAngle * (endX - center.x) + cosAngle * (startY - center.y) + center.y };
|
|
1973
|
+
var p3 = { x: cosAngle * (startX - center.x) - sinAngle * (endY - center.y) + center.x,
|
|
1974
|
+
y: sinAngle * (startX - center.x) + cosAngle * (endY - center.y) + center.y };
|
|
1975
|
+
var p4 = { x: cosAngle * (endX - center.x) - sinAngle * (endY - center.y) + center.x,
|
|
1976
|
+
y: sinAngle * (endX - center.x) + cosAngle * (endY - center.y) + center.y };
|
|
1977
|
+
var obj = { position: null, x: x, y: y, x1: p1.x, y1: p1.y, x2: p2.x, y2: p2.y,
|
|
1978
|
+
x3: p3.x, y3: p3.y, x4: p4.x, y4: p4.y };
|
|
1979
|
+
parent.notify('draw', { prop: 'checkPointPosition', onPropertyChange: false, value: { obj: obj } });
|
|
1980
|
+
if ((actObj.rotatedAngle !== 0 && (obj['position'] === 'inside' || obj['position'] === 'on')) ||
|
|
1981
|
+
(actObj.rotatedAngle === 0 && x >= (actObj.activePoint.startX - (radius * 2)) &&
|
|
1982
|
+
x <= (actObj.activePoint.endX + (radius * 2)) &&
|
|
1983
|
+
y >= (actObj.activePoint.startY - (radius * 2)) &&
|
|
1984
|
+
y <= (actObj.activePoint.endY + (radius * 2)))) {
|
|
1985
|
+
this.upperContext.clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
|
|
1691
1986
|
if (actObj.flipObjColl.length === 4) {
|
|
1692
1987
|
actObj.flipObjColl = [];
|
|
1693
1988
|
flip = '';
|
|
@@ -1707,8 +2002,12 @@ var Shape = /** @class */ (function () {
|
|
|
1707
2002
|
y = points.y;
|
|
1708
2003
|
}
|
|
1709
2004
|
if (parent.activeObj.rotatedAngle !== 0) {
|
|
1710
|
-
|
|
1711
|
-
|
|
2005
|
+
var point = this.getTextBoxPosition(parent.activeObj);
|
|
2006
|
+
x = point.x;
|
|
2007
|
+
y = point.y;
|
|
2008
|
+
point = this.setFlipState(x, y, parent.activeObj);
|
|
2009
|
+
x = point.x;
|
|
2010
|
+
y = point.y;
|
|
1712
2011
|
}
|
|
1713
2012
|
this.renderTextArea(x, y, actObj);
|
|
1714
2013
|
}
|
|
@@ -1717,7 +2016,8 @@ var Shape = /** @class */ (function () {
|
|
|
1717
2016
|
}
|
|
1718
2017
|
}
|
|
1719
2018
|
}
|
|
1720
|
-
else if (parent.textArea.style.display === 'block'
|
|
2019
|
+
else if ((parent.textArea.style.display === 'block' || parent.textArea.style.display === 'inline-block')
|
|
2020
|
+
&& this.selectedText() !== '' && e.type === 'mousedown') {
|
|
1721
2021
|
var temp = parent.textArea.value;
|
|
1722
2022
|
parent.textArea.value += 'a';
|
|
1723
2023
|
parent.textArea.value = temp;
|
|
@@ -1726,6 +2026,67 @@ var Shape = /** @class */ (function () {
|
|
|
1726
2026
|
parent.textArea.style.display = 'block';
|
|
1727
2027
|
}
|
|
1728
2028
|
};
|
|
2029
|
+
Shape.prototype.getTextBoxPosition = function (obj, object) {
|
|
2030
|
+
var point = { x: 0, y: 0 };
|
|
2031
|
+
var _a = obj.activePoint, startX = _a.startX, startY = _a.startY, endX = _a.endX, endY = _a.endY, width = _a.width, height = _a.height;
|
|
2032
|
+
var center = { x: startX + (width / 2), y: startY + (height / 2) };
|
|
2033
|
+
var cosAngle = Math.cos(obj.rotatedAngle);
|
|
2034
|
+
var sinAngle = Math.sin(obj.rotatedAngle);
|
|
2035
|
+
var p1 = { x: cosAngle * (startX - center.x) - sinAngle * (startY - center.y) + center.x,
|
|
2036
|
+
y: sinAngle * (startX - center.x) + cosAngle * (startY - center.y) + center.y };
|
|
2037
|
+
var p2 = { x: cosAngle * (endX - center.x) - sinAngle * (startY - center.y) + center.x,
|
|
2038
|
+
y: sinAngle * (endX - center.x) + cosAngle * (startY - center.y) + center.y };
|
|
2039
|
+
var p3 = { x: cosAngle * (startX - center.x) - sinAngle * (endY - center.y) + center.x,
|
|
2040
|
+
y: sinAngle * (startX - center.x) + cosAngle * (endY - center.y) + center.y };
|
|
2041
|
+
var p4 = { x: cosAngle * (endX - center.x) - sinAngle * (endY - center.y) + center.x,
|
|
2042
|
+
y: sinAngle * (endX - center.x) + cosAngle * (endY - center.y) + center.y };
|
|
2043
|
+
var degree = this.getRotDegOfShape(obj);
|
|
2044
|
+
if (degree === 0 || degree === 360) {
|
|
2045
|
+
point = { x: p1.x, y: p1.y };
|
|
2046
|
+
}
|
|
2047
|
+
else if (degree === 90 || degree === -270) {
|
|
2048
|
+
point = { x: p2.x, y: p2.y };
|
|
2049
|
+
}
|
|
2050
|
+
else if (degree === 180 || degree === -180) {
|
|
2051
|
+
point = { x: p4.x, y: p4.y };
|
|
2052
|
+
}
|
|
2053
|
+
else if (degree === 270 || degree === -90) {
|
|
2054
|
+
point = { x: p3.x, y: p3.y };
|
|
2055
|
+
}
|
|
2056
|
+
if (object) {
|
|
2057
|
+
object['x'] = point.x;
|
|
2058
|
+
object['y'] = point.y;
|
|
2059
|
+
}
|
|
2060
|
+
return point;
|
|
2061
|
+
};
|
|
2062
|
+
Shape.prototype.setFlipState = function (x, y, obj, object) {
|
|
2063
|
+
var parent = this.parent;
|
|
2064
|
+
var panObj = { panRegion: '' };
|
|
2065
|
+
var _a = parent.lowerCanvas, clientWidth = _a.clientWidth, clientHeight = _a.clientHeight;
|
|
2066
|
+
var center = { x: 0, y: 0 };
|
|
2067
|
+
parent.notify('crop', { prop: 'getCurrFlipState', onPropertyChange: false,
|
|
2068
|
+
value: { panObj: panObj } });
|
|
2069
|
+
if (panObj['panRegion'] !== '') {
|
|
2070
|
+
if (panObj['panRegion'] === 'horizontal') {
|
|
2071
|
+
center.x = clientWidth - (clientWidth / 2);
|
|
2072
|
+
x = (center.x - x) + center.x;
|
|
2073
|
+
}
|
|
2074
|
+
else if (panObj['panRegion'] === 'vertical') {
|
|
2075
|
+
center.y = clientHeight - (clientHeight / 2);
|
|
2076
|
+
y = (center.y - y) + center.y;
|
|
2077
|
+
}
|
|
2078
|
+
else {
|
|
2079
|
+
center = { x: clientWidth - (clientWidth / 2), y: clientHeight - (clientHeight / 2) };
|
|
2080
|
+
x = (center.x - x) + center.x;
|
|
2081
|
+
y = (center.y - y) + center.y;
|
|
2082
|
+
}
|
|
2083
|
+
}
|
|
2084
|
+
if (object) {
|
|
2085
|
+
object['x'] = x;
|
|
2086
|
+
object['y'] = y;
|
|
2087
|
+
}
|
|
2088
|
+
return { x: x, y: y };
|
|
2089
|
+
};
|
|
1729
2090
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1730
2091
|
Shape.prototype.fileChanged = function (e) {
|
|
1731
2092
|
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
@@ -1745,27 +2106,28 @@ var Shape = /** @class */ (function () {
|
|
|
1745
2106
|
document.getElementById(this.parent.element.id + '_fileUpload').value = '';
|
|
1746
2107
|
}
|
|
1747
2108
|
};
|
|
1748
|
-
Shape.prototype.onLoadImgShape = function (x, y, width, height, url, isSelect, degree, isAspectRatio) {
|
|
2109
|
+
Shape.prototype.onLoadImgShape = function (x, y, width, height, url, isSelect, degree, isAspectRatio, opacity) {
|
|
1749
2110
|
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
1750
2111
|
var proxy = this;
|
|
2112
|
+
var parent = this.parent;
|
|
1751
2113
|
if (typeof (url) === 'string') {
|
|
1752
2114
|
this.shapeImg.src = url;
|
|
1753
2115
|
}
|
|
1754
2116
|
else {
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
this.shapeImg.src =
|
|
2117
|
+
parent.inMemoryCanvas.width = url.width;
|
|
2118
|
+
parent.inMemoryCanvas.height = url.height;
|
|
2119
|
+
parent.inMemoryCanvas.getContext('2d').putImageData(url, 0, 0);
|
|
2120
|
+
this.shapeImg.src = parent.inMemoryCanvas.toDataURL();
|
|
1759
2121
|
}
|
|
1760
2122
|
this.prevObjColl();
|
|
1761
|
-
|
|
2123
|
+
parent.activeObj.shape = 'image';
|
|
1762
2124
|
this.initShapeProps();
|
|
1763
2125
|
this.shapeImg.onload = function () {
|
|
1764
2126
|
proxy.upperContext.drawImage(proxy.shapeImg, 0, 0, proxy.shapeImg.width, proxy.shapeImg.height);
|
|
1765
|
-
proxy.updateImgCanvas(isSelect, x, y, width, height, degree, isAspectRatio);
|
|
2127
|
+
proxy.updateImgCanvas(isSelect, x, y, width, height, degree, isAspectRatio, opacity);
|
|
1766
2128
|
};
|
|
1767
2129
|
};
|
|
1768
|
-
Shape.prototype.updateImgCanvas = function (isSelect, x, y, width, height, degree, isAspectRatio) {
|
|
2130
|
+
Shape.prototype.updateImgCanvas = function (isSelect, x, y, width, height, degree, isAspectRatio, opacity) {
|
|
1769
2131
|
var _this = this;
|
|
1770
2132
|
var parent = this.parent;
|
|
1771
2133
|
parent.activeObj.imageElement = this.shapeImg;
|
|
@@ -1800,6 +2162,9 @@ var Shape = /** @class */ (function () {
|
|
|
1800
2162
|
dimObj = { width: width, height: height };
|
|
1801
2163
|
}
|
|
1802
2164
|
}
|
|
2165
|
+
if (opacity !== null && opacity !== undefined) {
|
|
2166
|
+
parent.activeObj.opacity = opacity;
|
|
2167
|
+
}
|
|
1803
2168
|
this.updateObj(dimObj, x, y);
|
|
1804
2169
|
parent.notify('draw', { prop: 'drawObject', onPropertyChange: false, value: { canvas: 'duplicate' } });
|
|
1805
2170
|
this.shapeImg = null;
|
|
@@ -1810,11 +2175,11 @@ var Shape = /** @class */ (function () {
|
|
|
1810
2175
|
var obj = { shapeSettingsObj: {} };
|
|
1811
2176
|
parent.notify('selection', { prop: 'updatePrevShapeSettings', onPropertyChange: false, value: { obj: obj } });
|
|
1812
2177
|
var shapeSettings = obj['shapeSettingsObj'];
|
|
1813
|
-
var shapeChangingArgs = { action: 'insert', previousShapeSettings: shapeSettings,
|
|
2178
|
+
var shapeChangingArgs = { cancel: false, action: 'insert', previousShapeSettings: shapeSettings,
|
|
1814
2179
|
currentShapeSettings: shapeSettings };
|
|
1815
2180
|
if (isBlazor() && parent.events && parent.events.shapeChanging.hasDelegate === true) {
|
|
1816
2181
|
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
1817
|
-
parent.dotNetRef.invokeMethodAsync('ShapeEventAsync', 'OnShape', shapeChangingArgs).then(function (shapeChangingArgs) {
|
|
2182
|
+
parent.dotNetRef.invokeMethodAsync('ShapeEventAsync', 'OnShape', shapeChangingArgs, null).then(function (shapeChangingArgs) {
|
|
1818
2183
|
_this.drawShapeImageEvent(shapeChangingArgs, isSelect);
|
|
1819
2184
|
if (parent.isPublicMethod) {
|
|
1820
2185
|
parent.notify('undo-redo', { prop: 'updateUndoRedo', onPropertyChange: false });
|
|
@@ -1849,61 +2214,63 @@ var Shape = /** @class */ (function () {
|
|
|
1849
2214
|
};
|
|
1850
2215
|
Shape.prototype.setTextBoxPos = function (actObj, degree, flip, x, y) {
|
|
1851
2216
|
var point = { x: x, y: y };
|
|
2217
|
+
var _a = actObj.activePoint, startX = _a.startX, startY = _a.startY, endX = _a.endX, endY = _a.endY;
|
|
2218
|
+
flip = flip.toLowerCase();
|
|
1852
2219
|
switch (degree) {
|
|
1853
2220
|
case 0:
|
|
1854
|
-
if (flip
|
|
1855
|
-
point.x =
|
|
1856
|
-
point.y =
|
|
2221
|
+
if (flip === 'horizontal') {
|
|
2222
|
+
point.x = endX;
|
|
2223
|
+
point.y = startY;
|
|
1857
2224
|
}
|
|
1858
|
-
else if (flip
|
|
1859
|
-
point.x =
|
|
1860
|
-
point.y =
|
|
2225
|
+
else if (flip === 'vertical') {
|
|
2226
|
+
point.x = startX;
|
|
2227
|
+
point.y = endY;
|
|
1861
2228
|
}
|
|
1862
2229
|
else {
|
|
1863
|
-
point.x =
|
|
1864
|
-
point.y =
|
|
2230
|
+
point.x = startX;
|
|
2231
|
+
point.y = startY;
|
|
1865
2232
|
}
|
|
1866
2233
|
break;
|
|
1867
2234
|
case 90:
|
|
1868
|
-
if (flip
|
|
1869
|
-
point.x =
|
|
1870
|
-
point.y =
|
|
2235
|
+
if (flip === 'horizontal') {
|
|
2236
|
+
point.x = startX;
|
|
2237
|
+
point.y = startY;
|
|
1871
2238
|
}
|
|
1872
|
-
else if (flip
|
|
1873
|
-
point.x =
|
|
1874
|
-
point.y =
|
|
2239
|
+
else if (flip === 'vertical') {
|
|
2240
|
+
point.x = endX;
|
|
2241
|
+
point.y = endY;
|
|
1875
2242
|
}
|
|
1876
2243
|
else {
|
|
1877
|
-
point.x =
|
|
1878
|
-
point.y =
|
|
2244
|
+
point.x = endX;
|
|
2245
|
+
point.y = startY;
|
|
1879
2246
|
}
|
|
1880
2247
|
break;
|
|
1881
2248
|
case 180:
|
|
1882
|
-
if (flip
|
|
1883
|
-
point.x =
|
|
1884
|
-
point.y =
|
|
2249
|
+
if (flip === 'horizontal') {
|
|
2250
|
+
point.x = startX;
|
|
2251
|
+
point.y = endY;
|
|
1885
2252
|
}
|
|
1886
|
-
else if (flip
|
|
1887
|
-
point.x =
|
|
1888
|
-
point.y =
|
|
2253
|
+
else if (flip === 'vertical') {
|
|
2254
|
+
point.x = endX;
|
|
2255
|
+
point.y = startY;
|
|
1889
2256
|
}
|
|
1890
2257
|
else {
|
|
1891
|
-
point.x =
|
|
1892
|
-
point.y =
|
|
2258
|
+
point.x = endX;
|
|
2259
|
+
point.y = endY;
|
|
1893
2260
|
}
|
|
1894
2261
|
break;
|
|
1895
2262
|
case 270:
|
|
1896
|
-
if (flip
|
|
1897
|
-
point.x =
|
|
1898
|
-
point.y =
|
|
2263
|
+
if (flip === 'horizontal') {
|
|
2264
|
+
point.x = endX;
|
|
2265
|
+
point.y = endY;
|
|
1899
2266
|
}
|
|
1900
|
-
else if (flip
|
|
1901
|
-
point.x =
|
|
1902
|
-
point.y =
|
|
2267
|
+
else if (flip === 'vertical') {
|
|
2268
|
+
point.x = startX;
|
|
2269
|
+
point.y = startY;
|
|
1903
2270
|
}
|
|
1904
2271
|
else {
|
|
1905
|
-
point.x =
|
|
1906
|
-
point.y =
|
|
2272
|
+
point.x = startX;
|
|
2273
|
+
point.y = endY;
|
|
1907
2274
|
}
|
|
1908
2275
|
break;
|
|
1909
2276
|
}
|
|
@@ -1911,92 +2278,94 @@ var Shape = /** @class */ (function () {
|
|
|
1911
2278
|
};
|
|
1912
2279
|
Shape.prototype.setTextBoxPoints = function (actObj, degree, flip, x, y) {
|
|
1913
2280
|
var point = { x: x, y: y };
|
|
2281
|
+
var _a = actObj.activePoint, startX = _a.startX, startY = _a.startY, endX = _a.endX, endY = _a.endY;
|
|
2282
|
+
flip = flip.toLowerCase();
|
|
1914
2283
|
switch (degree) {
|
|
1915
2284
|
case 0:
|
|
1916
2285
|
if (actObj.flipObjColl[0] && actObj.flipObjColl[0].toLowerCase() === 'horizontal') {
|
|
1917
|
-
if (flip
|
|
1918
|
-
point.x =
|
|
1919
|
-
point.y =
|
|
2286
|
+
if (flip === 'horizontal') {
|
|
2287
|
+
point.x = startX;
|
|
2288
|
+
point.y = startY;
|
|
1920
2289
|
}
|
|
1921
|
-
else if (flip
|
|
1922
|
-
point.x =
|
|
1923
|
-
point.y =
|
|
2290
|
+
else if (flip === 'vertical') {
|
|
2291
|
+
point.x = endX;
|
|
2292
|
+
point.y = endY;
|
|
1924
2293
|
}
|
|
1925
2294
|
}
|
|
1926
2295
|
else {
|
|
1927
|
-
if (flip
|
|
1928
|
-
point.x =
|
|
1929
|
-
point.y =
|
|
2296
|
+
if (flip === 'horizontal') {
|
|
2297
|
+
point.x = endX;
|
|
2298
|
+
point.y = endY;
|
|
1930
2299
|
}
|
|
1931
|
-
else if (flip
|
|
1932
|
-
point.x =
|
|
1933
|
-
point.y =
|
|
2300
|
+
else if (flip === 'vertical') {
|
|
2301
|
+
point.x = endX;
|
|
2302
|
+
point.y = startY;
|
|
1934
2303
|
}
|
|
1935
2304
|
}
|
|
1936
2305
|
break;
|
|
1937
2306
|
case 90:
|
|
1938
2307
|
if (actObj.flipObjColl[0] && actObj.flipObjColl[0].toLowerCase() === 'horizontal') {
|
|
1939
|
-
if (flip
|
|
1940
|
-
point.x =
|
|
1941
|
-
point.y =
|
|
2308
|
+
if (flip === 'horizontal') {
|
|
2309
|
+
point.x = endX;
|
|
2310
|
+
point.y = endY;
|
|
1942
2311
|
}
|
|
1943
|
-
else if (flip
|
|
1944
|
-
point.x =
|
|
1945
|
-
point.y =
|
|
2312
|
+
else if (flip === 'vertical') {
|
|
2313
|
+
point.x = startX;
|
|
2314
|
+
point.y = endY;
|
|
1946
2315
|
}
|
|
1947
2316
|
}
|
|
1948
2317
|
else {
|
|
1949
|
-
if (flip
|
|
1950
|
-
point.x =
|
|
1951
|
-
point.y =
|
|
2318
|
+
if (flip === 'horizontal') {
|
|
2319
|
+
point.x = startX;
|
|
2320
|
+
point.y = endY;
|
|
1952
2321
|
}
|
|
1953
|
-
else if (flip
|
|
1954
|
-
point.x =
|
|
1955
|
-
point.y =
|
|
2322
|
+
else if (flip === 'vertical') {
|
|
2323
|
+
point.x = startX;
|
|
2324
|
+
point.y = startY;
|
|
1956
2325
|
}
|
|
1957
2326
|
}
|
|
1958
2327
|
break;
|
|
1959
2328
|
case 180:
|
|
1960
2329
|
if (actObj.flipObjColl[0] && actObj.flipObjColl[0].toLowerCase() === 'horizontal') {
|
|
1961
|
-
if (flip
|
|
1962
|
-
point.x =
|
|
1963
|
-
point.y =
|
|
2330
|
+
if (flip === 'horizontal') {
|
|
2331
|
+
point.x = startX;
|
|
2332
|
+
point.y = startY;
|
|
1964
2333
|
}
|
|
1965
|
-
else if (flip
|
|
1966
|
-
point.x =
|
|
1967
|
-
point.y =
|
|
2334
|
+
else if (flip === 'vertical') {
|
|
2335
|
+
point.x = startX;
|
|
2336
|
+
point.y = startY;
|
|
1968
2337
|
}
|
|
1969
2338
|
}
|
|
1970
2339
|
else {
|
|
1971
|
-
if (flip
|
|
1972
|
-
point.x =
|
|
1973
|
-
point.y =
|
|
2340
|
+
if (flip === 'horizontal') {
|
|
2341
|
+
point.x = startX;
|
|
2342
|
+
point.y = startY;
|
|
1974
2343
|
}
|
|
1975
|
-
else if (flip
|
|
1976
|
-
point.x =
|
|
1977
|
-
point.y =
|
|
2344
|
+
else if (flip === 'vertical') {
|
|
2345
|
+
point.x = startX;
|
|
2346
|
+
point.y = endY;
|
|
1978
2347
|
}
|
|
1979
2348
|
}
|
|
1980
2349
|
break;
|
|
1981
2350
|
case 270:
|
|
1982
2351
|
if (actObj.flipObjColl[0] && actObj.flipObjColl[0].toLowerCase() === 'horizontal') {
|
|
1983
|
-
if (flip
|
|
1984
|
-
point.x =
|
|
1985
|
-
point.y =
|
|
2352
|
+
if (flip === 'horizontal') {
|
|
2353
|
+
point.x = startX;
|
|
2354
|
+
point.y = startY;
|
|
1986
2355
|
}
|
|
1987
|
-
else if (flip
|
|
1988
|
-
point.x =
|
|
1989
|
-
point.y =
|
|
2356
|
+
else if (flip === 'vertical') {
|
|
2357
|
+
point.x = endX;
|
|
2358
|
+
point.y = startY;
|
|
1990
2359
|
}
|
|
1991
2360
|
}
|
|
1992
2361
|
else {
|
|
1993
|
-
if (flip
|
|
1994
|
-
point.x =
|
|
1995
|
-
point.y =
|
|
2362
|
+
if (flip === 'horizontal') {
|
|
2363
|
+
point.x = endX;
|
|
2364
|
+
point.y = startY;
|
|
1996
2365
|
}
|
|
1997
|
-
else if (flip
|
|
1998
|
-
point.x =
|
|
1999
|
-
point.y =
|
|
2366
|
+
else if (flip === 'vertical') {
|
|
2367
|
+
point.x = endX;
|
|
2368
|
+
point.y = endY;
|
|
2000
2369
|
}
|
|
2001
2370
|
}
|
|
2002
2371
|
break;
|
|
@@ -2004,9 +2373,10 @@ var Shape = /** @class */ (function () {
|
|
|
2004
2373
|
return point;
|
|
2005
2374
|
};
|
|
2006
2375
|
Shape.prototype.selectedText = function () {
|
|
2007
|
-
var
|
|
2008
|
-
var
|
|
2009
|
-
|
|
2376
|
+
var parent = this.parent;
|
|
2377
|
+
var start = parent.textArea.selectionStart;
|
|
2378
|
+
var finish = parent.textArea.selectionEnd;
|
|
2379
|
+
return parent.textArea.value.substring(start, finish);
|
|
2010
2380
|
};
|
|
2011
2381
|
Shape.prototype.panObjColl = function (xDiff, yDiff, panRegion) {
|
|
2012
2382
|
var parent = this.parent;
|
|
@@ -2097,7 +2467,8 @@ var Shape = /** @class */ (function () {
|
|
|
2097
2467
|
textStyle = 'italic bold ';
|
|
2098
2468
|
}
|
|
2099
2469
|
var fontSize = isTextBox ? parseFloat(parent.textArea.style.fontSize) : parent.activeObj.textSettings.fontSize;
|
|
2100
|
-
var fontFamily = parent.textArea.style.display === 'block'
|
|
2470
|
+
var fontFamily = (parent.textArea.style.display === 'block' || parent.textArea.style.display === 'inline-block') ?
|
|
2471
|
+
parent.textArea.style.fontFamily : parent.activeObj.textSettings.fontFamily;
|
|
2101
2472
|
this.upperContext.font = textStyle + fontSize + 'px' + ' ' + fontFamily;
|
|
2102
2473
|
};
|
|
2103
2474
|
Shape.prototype.applyFontStyle = function (item) {
|
|
@@ -2128,18 +2499,31 @@ var Shape = /** @class */ (function () {
|
|
|
2128
2499
|
this.updateFontStyle(item, objColl, 'bold', 'italic');
|
|
2129
2500
|
break;
|
|
2130
2501
|
}
|
|
2131
|
-
var shapeChangedArgs = { action: 'font-style',
|
|
2132
|
-
currentShapeSettings: extend({}, shapeSettings, {}, true) };
|
|
2502
|
+
var shapeChangedArgs = { action: 'font-style', currentShapeSettings: extend({}, shapeSettings, {}, true) };
|
|
2133
2503
|
shapeChangedArgs.currentShapeSettings.fontStyle = [item];
|
|
2134
2504
|
parent.triggerShapeChanged(shapeChangedArgs);
|
|
2135
2505
|
};
|
|
2136
2506
|
Shape.prototype.updateFontStyle = function (item, objColl, fontWeight, fontStyle) {
|
|
2137
2507
|
var parent = this.parent;
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2508
|
+
var style = parent.textArea.style;
|
|
2509
|
+
if (style.display === 'block' || style.display === 'inline-block') {
|
|
2510
|
+
if (style.fontWeight === 'normal' && fontWeight === 'bold') {
|
|
2511
|
+
style.fontWeight = 'bold';
|
|
2512
|
+
}
|
|
2513
|
+
else if (style.fontWeight === 'bold' && fontWeight === 'bold') {
|
|
2514
|
+
style.fontWeight = 'normal';
|
|
2515
|
+
}
|
|
2516
|
+
if (style.fontStyle === 'normal' && fontStyle === 'italic') {
|
|
2517
|
+
style.fontStyle = 'italic';
|
|
2518
|
+
}
|
|
2519
|
+
else if (style.fontStyle === 'italic' && fontStyle === 'italic') {
|
|
2520
|
+
style.fontStyle = 'normal';
|
|
2521
|
+
}
|
|
2522
|
+
var value = (style.fontWeight === 'normal' && style.fontStyle === 'normal' ? 'default' :
|
|
2523
|
+
(style.fontWeight === 'bold' && style.fontStyle === 'normal' ? 'bold' :
|
|
2524
|
+
(style.fontWeight === 'normal' && style.fontStyle === 'italic' ? 'italic' : 'bolditalic')));
|
|
2525
|
+
var width = this.getTextAreaWidth(value);
|
|
2526
|
+
style.width = width + 'px';
|
|
2143
2527
|
this.updateObjColl(item, objColl);
|
|
2144
2528
|
}
|
|
2145
2529
|
else {
|
|
@@ -2262,92 +2646,97 @@ var Shape = /** @class */ (function () {
|
|
|
2262
2646
|
parent.activeObj.textSettings.italic = tempItalic;
|
|
2263
2647
|
};
|
|
2264
2648
|
Shape.prototype.pushActItemIntoObj = function () {
|
|
2265
|
-
|
|
2266
|
-
|
|
2649
|
+
var parent = this.parent;
|
|
2650
|
+
if (parent.textArea.style.display === 'none') {
|
|
2651
|
+
parent.objColl.push(parent.activeObj);
|
|
2267
2652
|
}
|
|
2268
2653
|
else {
|
|
2269
|
-
var temp = extend({},
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2654
|
+
var temp = extend({}, parent.activeObj, {}, true);
|
|
2655
|
+
parent.notify('selection', { prop: 'setTextBoxStylesToActObj', onPropertyChange: false });
|
|
2656
|
+
parent.objColl.push(parent.activeObj);
|
|
2657
|
+
parent.activeObj = temp;
|
|
2273
2658
|
}
|
|
2274
2659
|
};
|
|
2275
2660
|
Shape.prototype.clearActObj = function () {
|
|
2276
|
-
|
|
2661
|
+
var parent = this.parent;
|
|
2662
|
+
if (parent.textArea.style.display === 'none') {
|
|
2277
2663
|
this.refreshActiveObj();
|
|
2278
2664
|
this.applyActObj();
|
|
2279
2665
|
this.refreshActiveObj();
|
|
2280
|
-
|
|
2666
|
+
parent.currObjType.isCustomCrop = false;
|
|
2281
2667
|
}
|
|
2282
2668
|
};
|
|
2283
2669
|
Shape.prototype.refreshActiveObj = function () {
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2670
|
+
var parent = this.parent;
|
|
2671
|
+
parent.activeObj = {};
|
|
2672
|
+
parent.activeObj.activePoint = { startX: 0, startY: 0, endX: 0, endY: 0, width: 0, height: 0 };
|
|
2673
|
+
parent.activeObj.triangle = [];
|
|
2674
|
+
parent.activeObj.triangleRatio = [];
|
|
2675
|
+
parent.activeObj.flipObjColl = [];
|
|
2676
|
+
parent.activeObj.strokeSettings = this.strokeSettings;
|
|
2677
|
+
parent.activeObj.textSettings = this.textSettings;
|
|
2678
|
+
parent.activeObj.rotatedAngle = 0;
|
|
2679
|
+
parent.activeObj.opacity = 1;
|
|
2292
2680
|
};
|
|
2293
2681
|
Shape.prototype.applyActObj = function (isMouseDown) {
|
|
2682
|
+
var parent = this.parent;
|
|
2294
2683
|
var isActObj = false;
|
|
2295
|
-
if (
|
|
2684
|
+
if (parent.activeObj.shape !== undefined && parent.activeObj.shape === 'text' && parent.activeObj.keyHistory === '') {
|
|
2296
2685
|
this.refreshActiveObj();
|
|
2297
|
-
this.upperContext.clearRect(0, 0,
|
|
2686
|
+
this.upperContext.clearRect(0, 0, parent.upperCanvas.width, parent.upperCanvas.height);
|
|
2298
2687
|
}
|
|
2299
2688
|
else {
|
|
2300
2689
|
var splitWords = void 0;
|
|
2301
2690
|
var isCropSelection = false;
|
|
2302
|
-
if (
|
|
2303
|
-
splitWords =
|
|
2691
|
+
if (parent.activeObj.shape !== undefined) {
|
|
2692
|
+
splitWords = parent.activeObj.shape.split('-');
|
|
2304
2693
|
}
|
|
2305
|
-
if (splitWords === undefined &&
|
|
2694
|
+
if (splitWords === undefined && parent.currObjType.isCustomCrop) {
|
|
2306
2695
|
isCropSelection = true;
|
|
2307
2696
|
}
|
|
2308
2697
|
else if (splitWords !== undefined && splitWords[0] === 'crop') {
|
|
2309
2698
|
isCropSelection = true;
|
|
2310
2699
|
}
|
|
2311
|
-
if (
|
|
2312
|
-
for (var i = 0; i <
|
|
2313
|
-
if (JSON.stringify(
|
|
2700
|
+
if (parent.activeObj.shape && !isCropSelection && parent.activeObj.shape !== 'shape') {
|
|
2701
|
+
for (var i = 0; i < parent.objColl.length; i++) {
|
|
2702
|
+
if (JSON.stringify(parent.activeObj) === JSON.stringify(parent.objColl[i])) {
|
|
2314
2703
|
isActObj = true;
|
|
2315
2704
|
break;
|
|
2316
2705
|
}
|
|
2317
2706
|
}
|
|
2318
2707
|
if (!isActObj) {
|
|
2319
|
-
if (isNullOrUndefined(
|
|
2320
|
-
|
|
2708
|
+
if (isNullOrUndefined(parent.activeObj.currIndex)) {
|
|
2709
|
+
parent.activeObj.currIndex = 'shape_' + (parent.objColl.length + 1);
|
|
2321
2710
|
}
|
|
2322
2711
|
this.updImgRatioForActObj();
|
|
2323
|
-
var splitWords_1 =
|
|
2324
|
-
var tempObjColl =
|
|
2325
|
-
tempObjColl.push(extend({},
|
|
2326
|
-
for (var i = 0; i <
|
|
2327
|
-
tempObjColl.push(
|
|
2712
|
+
var splitWords_1 = parent.activeObj.currIndex.split('_');
|
|
2713
|
+
var tempObjColl = parent.objColl.splice(0, parseInt(splitWords_1[1], 10) - 1);
|
|
2714
|
+
tempObjColl.push(extend({}, parent.activeObj, {}, true));
|
|
2715
|
+
for (var i = 0; i < parent.objColl.length; i++) {
|
|
2716
|
+
tempObjColl.push(parent.objColl[i]);
|
|
2328
2717
|
}
|
|
2329
|
-
|
|
2718
|
+
parent.objColl = tempObjColl;
|
|
2330
2719
|
tempObjColl = [];
|
|
2331
2720
|
this.refreshActiveObj();
|
|
2332
|
-
this.lowerContext.clearRect(0, 0,
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2721
|
+
this.lowerContext.clearRect(0, 0, parent.lowerCanvas.width, parent.lowerCanvas.height);
|
|
2722
|
+
parent.notify('draw', { prop: 'redrawImgWithObj', onPropertyChange: false });
|
|
2723
|
+
parent.notify('draw', { prop: 'clearOuterCanvas', onPropertyChange: false, value: { context: this.lowerContext } });
|
|
2724
|
+
parent.notify('draw', { prop: 'clearOuterCanvas', onPropertyChange: false, value: { context: this.upperContext } });
|
|
2725
|
+
parent.currObjType.shape = '';
|
|
2337
2726
|
this.refreshActiveObj();
|
|
2338
|
-
if (
|
|
2339
|
-
|
|
2727
|
+
if (parent.isCircleCrop) {
|
|
2728
|
+
parent.notify('crop', { prop: 'cropCircle', onPropertyChange: false,
|
|
2340
2729
|
value: { context: this.lowerContext, isSave: null, isFlip: null } });
|
|
2341
2730
|
}
|
|
2342
2731
|
if (!isBlazor()) {
|
|
2343
|
-
|
|
2732
|
+
parent.notify('toolbar', { prop: 'destroy-qa-toolbar', onPropertyChange: false });
|
|
2344
2733
|
}
|
|
2345
2734
|
else {
|
|
2346
|
-
|
|
2735
|
+
parent.updateToolbar(parent.element, 'destroyQuickAccessToolbar');
|
|
2347
2736
|
}
|
|
2348
2737
|
if (isNullOrUndefined(isMouseDown)) {
|
|
2349
|
-
|
|
2350
|
-
|
|
2738
|
+
parent.notify('undo-redo', { prop: 'updateCurrUrc', value: { type: 'ok' } });
|
|
2739
|
+
parent.notify('draw', { prop: 'setPrevActObj', onPropertyChange: false, value: { prevActObj: null } });
|
|
2351
2740
|
}
|
|
2352
2741
|
}
|
|
2353
2742
|
}
|
|
@@ -2372,7 +2761,6 @@ var Shape = /** @class */ (function () {
|
|
|
2372
2761
|
var scale = '';
|
|
2373
2762
|
var degree = this.getRotDegOfShape(parent.activeObj);
|
|
2374
2763
|
if (parent.activeObj.flipObjColl.length > 0) {
|
|
2375
|
-
// need to add scale value according to length.
|
|
2376
2764
|
for (var i = 0; i < parent.activeObj.flipObjColl.length; i++) {
|
|
2377
2765
|
if (degree !== 0 && degree % 90 === 0 && degree !== 180) {
|
|
2378
2766
|
scale += parent.activeObj.flipObjColl[i].toLowerCase() === 'horizontal' ? 'scale(1, -1)' :
|
|
@@ -2419,9 +2807,10 @@ var Shape = /** @class */ (function () {
|
|
|
2419
2807
|
parent.activeObj.textSettings.italic = true;
|
|
2420
2808
|
break;
|
|
2421
2809
|
}
|
|
2422
|
-
|
|
2810
|
+
var isTextArea = parent.textArea.style.display === 'none' ? false : true;
|
|
2811
|
+
this.updateFontStyles(isTextArea);
|
|
2423
2812
|
var width;
|
|
2424
|
-
if (
|
|
2813
|
+
if (!isTextArea) {
|
|
2425
2814
|
width = this.upperContext.measureText(parent.activeObj.keyHistory).width +
|
|
2426
2815
|
parent.activeObj.textSettings.fontSize * 0.5;
|
|
2427
2816
|
}
|
|
@@ -2528,8 +2917,9 @@ var Shape = /** @class */ (function () {
|
|
|
2528
2917
|
};
|
|
2529
2918
|
Shape.prototype.isPointsInRange = function (x, y, obj) {
|
|
2530
2919
|
var inRange = false;
|
|
2531
|
-
|
|
2532
|
-
|
|
2920
|
+
var parent = this.parent;
|
|
2921
|
+
if (!isNullOrUndefined(x) && !isNullOrUndefined(y) && x >= parent.img.destLeft && y >= parent.img.destTop &&
|
|
2922
|
+
x <= parent.img.destLeft + parent.img.destWidth && y <= parent.img.destTop + parent.img.destHeight) {
|
|
2533
2923
|
inRange = true;
|
|
2534
2924
|
}
|
|
2535
2925
|
obj['inRange'] = inRange;
|
|
@@ -2601,49 +2991,40 @@ var Shape = /** @class */ (function () {
|
|
|
2601
2991
|
return collection;
|
|
2602
2992
|
};
|
|
2603
2993
|
Shape.prototype.popForDefaultFlipState = function (collection) {
|
|
2604
|
-
for (var i = 0
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
(collection[i + 2] === 'vertical' || collection[i + 2] === 'Vertical' || collection[i] === 'verticalFlip') &&
|
|
2624
|
-
(collection[i + 3] === 'horizontal' || collection[i + 3] === 'Horizontal' || collection[i] === 'horizontalFlip')) {
|
|
2625
|
-
collection.pop();
|
|
2626
|
-
collection.pop();
|
|
2627
|
-
collection.pop();
|
|
2628
|
-
collection.pop();
|
|
2629
|
-
}
|
|
2994
|
+
for (var i = 0, iLen = collection.length - 3; i < iLen; i++) {
|
|
2995
|
+
var isHorizontal = collection[i] === 'horizontal' || collection[i] === 'Horizontal'
|
|
2996
|
+
|| collection[i] === 'horizontalFlip';
|
|
2997
|
+
var isVertical = collection[i] === 'vertical' || collection[i] === 'Vertical' ||
|
|
2998
|
+
collection[i] === 'verticalFlip';
|
|
2999
|
+
var isNextHorizontal = collection[i + 1] === 'horizontal' || collection[i + 1] === 'Horizontal' ||
|
|
3000
|
+
collection[i + 1] === 'horizontalFlip';
|
|
3001
|
+
var isNextVertical = collection[i + 1] === 'vertical' || collection[i + 1] === 'Vertical' ||
|
|
3002
|
+
collection[i + 1] === 'verticalFlip';
|
|
3003
|
+
var isNextToNextHorizontal = collection[i + 2] === 'horizontal' || collection[i + 2] === 'Horizontal' ||
|
|
3004
|
+
collection[i + 2] === 'horizontalFlip';
|
|
3005
|
+
var isNextToNextVertical = collection[i + 2] === 'vertical' || collection[i + 2] === 'Vertical' ||
|
|
3006
|
+
collection[i + 2] === 'verticalFlip';
|
|
3007
|
+
var isNextToNextToNextHorizontal = collection[i + 3] === 'horizontal' || collection[i + 3] === 'Horizontal' ||
|
|
3008
|
+
collection[i + 3] === 'horizontalFlip';
|
|
3009
|
+
if ((isHorizontal && isNextVertical && isNextToNextHorizontal && isNextToNextVertical) ||
|
|
3010
|
+
(isVertical && isNextHorizontal && isNextToNextVertical && isNextToNextToNextHorizontal)) {
|
|
3011
|
+
collection.splice(i, 4);
|
|
3012
|
+
i -= 4;
|
|
2630
3013
|
}
|
|
2631
3014
|
}
|
|
2632
3015
|
return collection;
|
|
2633
3016
|
};
|
|
2634
3017
|
Shape.prototype.popForDefaultRotateState = function (collection) {
|
|
2635
|
-
for (var i = 0; i < collection.length; i++) {
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
collection.pop();
|
|
2646
|
-
}
|
|
3018
|
+
for (var i = 0; i < collection.length - 1; i++) {
|
|
3019
|
+
var curr = collection[i];
|
|
3020
|
+
var next = collection[i + 1];
|
|
3021
|
+
if ((curr === 90 || curr === 'rotateRight') && (next === -90 || next === 'rotateLeft')) {
|
|
3022
|
+
collection.splice(i, 2);
|
|
3023
|
+
i -= 2;
|
|
3024
|
+
}
|
|
3025
|
+
else if ((curr === -90 || curr === 'rotateLeft') && (next === 90 || next === 'rotateRight')) {
|
|
3026
|
+
collection.splice(i, 2);
|
|
3027
|
+
i -= 2;
|
|
2647
3028
|
}
|
|
2648
3029
|
}
|
|
2649
3030
|
return collection;
|
|
@@ -2691,7 +3072,7 @@ var Shape = /** @class */ (function () {
|
|
|
2691
3072
|
else {
|
|
2692
3073
|
parent.updateToolbar(parent.element, parent.activeObj.shape);
|
|
2693
3074
|
if (parent.activeObj.shape === 'path') {
|
|
2694
|
-
parent.updateToolbar(
|
|
3075
|
+
parent.updateToolbar(parent.element, 'path', 'pathQuickAccessToolbar');
|
|
2695
3076
|
}
|
|
2696
3077
|
else {
|
|
2697
3078
|
parent.updateToolbar(parent.element, 'quickAccessToolbar', parent.activeObj.shape);
|
|
@@ -2710,14 +3091,14 @@ var Shape = /** @class */ (function () {
|
|
|
2710
3091
|
if (obj_6['isIndex']) {
|
|
2711
3092
|
isSelected = true;
|
|
2712
3093
|
parent.notify('freehand-draw', { prop: 'selectFhd', value: { id: id } });
|
|
2713
|
-
if (
|
|
2714
|
-
parent.notify('toolbar', { prop: 'renderQAT', onPropertyChange: false, value: { isPenEdit: true } });
|
|
2715
|
-
parent.notify('toolbar', { prop: 'update-toolbar-items', onPropertyChange: false });
|
|
2716
|
-
}
|
|
2717
|
-
else {
|
|
3094
|
+
if (isBlazor()) {
|
|
2718
3095
|
parent.updateToolbar(parent.element, 'pen');
|
|
2719
3096
|
parent.updateToolbar(parent.element, 'quickAccessToolbar', 'pen');
|
|
2720
3097
|
}
|
|
3098
|
+
else {
|
|
3099
|
+
parent.notify('toolbar', { prop: 'renderQAT', onPropertyChange: false, value: { isPenEdit: true } });
|
|
3100
|
+
parent.notify('toolbar', { prop: 'update-toolbar-items', onPropertyChange: false });
|
|
3101
|
+
}
|
|
2721
3102
|
}
|
|
2722
3103
|
else {
|
|
2723
3104
|
isSelected = false;
|
|
@@ -2873,31 +3254,27 @@ var Shape = /** @class */ (function () {
|
|
|
2873
3254
|
return point[1] - getSlope * point[0];
|
|
2874
3255
|
};
|
|
2875
3256
|
Shape.prototype.setPointCollForShapeRotation = function (obj) {
|
|
2876
|
-
var
|
|
2877
|
-
|
|
2878
|
-
var
|
|
2879
|
-
(
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
var
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
var p3 = { x:
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
(obj.activePoint.endY - center.y) + center.x,
|
|
2892
|
-
y: Math.sin(obj.rotatedAngle) * (obj.activePoint.endX - center.x) + Math.cos(obj.rotatedAngle) * (obj.activePoint.endY
|
|
2893
|
-
- center.y) + center.y };
|
|
3257
|
+
var parent = this.parent;
|
|
3258
|
+
var _a = obj.activePoint, startX = _a.startX, startY = _a.startY, endX = _a.endX, endY = _a.endY, width = _a.width, height = _a.height;
|
|
3259
|
+
var center = { x: startX + (width / 2), y: startY +
|
|
3260
|
+
(height / 2) };
|
|
3261
|
+
var cosAngle = Math.cos(obj.rotatedAngle);
|
|
3262
|
+
var sinAngle = Math.sin(obj.rotatedAngle);
|
|
3263
|
+
var p1 = { x: cosAngle * (startX - center.x) - sinAngle * (startY - center.y) + center.x,
|
|
3264
|
+
y: sinAngle * (startX - center.x) + cosAngle * (startY - center.y) + center.y };
|
|
3265
|
+
var p2 = { x: cosAngle * (endX - center.x) - sinAngle * (startY - center.y) + center.x,
|
|
3266
|
+
y: sinAngle * (endX - center.x) + cosAngle * (startY - center.y) + center.y };
|
|
3267
|
+
var p3 = { x: cosAngle * (startX - center.x) - sinAngle * (endY - center.y) + center.x,
|
|
3268
|
+
y: sinAngle * (startX - center.x) + cosAngle * (endY - center.y) + center.y };
|
|
3269
|
+
var p4 = { x: cosAngle * (endX - center.x) - sinAngle * (endY - center.y) + center.x,
|
|
3270
|
+
y: sinAngle * (endX - center.x) + cosAngle * (endY - center.y) + center.y };
|
|
3271
|
+
obj.horTopLinePointColl = this.getLinePoints(p1.x, p1.y, p2.x, p2.y);
|
|
2894
3272
|
obj.horTopLinePointColl = this.getLinePoints(p1.x, p1.y, p2.x, p2.y);
|
|
2895
3273
|
obj.horBottomLinePointColl = this.getLinePoints(p3.x, p3.y, p4.x, p4.y);
|
|
2896
3274
|
obj.verLeftLinePointColl = this.getLinePoints(p1.x, p1.y, p3.x, p3.y);
|
|
2897
3275
|
obj.verRightLinePointColl = this.getLinePoints(p2.x, p2.y, p4.x, p4.y);
|
|
2898
3276
|
obj.verLeftLinePointColl.reverse();
|
|
2899
3277
|
obj.verRightLinePointColl.reverse();
|
|
2900
|
-
// Updating ratio for point collection
|
|
2901
3278
|
for (var i = 0; i < obj.horTopLinePointColl.length; i++) {
|
|
2902
3279
|
obj.horTopLinePointColl[i].ratioX = (obj.horTopLinePointColl[i].x -
|
|
2903
3280
|
this.parent.img.destLeft) / this.parent.img.destWidth;
|
|
@@ -2922,42 +3299,36 @@ var Shape = /** @class */ (function () {
|
|
|
2922
3299
|
obj.verRightLinePointColl[i].ratioY = (obj.verRightLinePointColl[i].y -
|
|
2923
3300
|
this.parent.img.destTop) / this.parent.img.destHeight;
|
|
2924
3301
|
}
|
|
2925
|
-
if (
|
|
3302
|
+
if (parent.upperCanvas.style.cursor !== 'move') {
|
|
2926
3303
|
var object = { rotationCirclePoint: null };
|
|
2927
|
-
|
|
3304
|
+
parent.notify('selection', { prop: 'getTransRotationPoint', value: { obj: obj, object: object } });
|
|
2928
3305
|
var rotationCirclePoint = object['rotationCirclePoint'];
|
|
2929
3306
|
if (rotationCirclePoint) {
|
|
2930
|
-
obj.rotationCirclePointColl = { x:
|
|
2931
|
-
|
|
2932
|
-
y:
|
|
3307
|
+
obj.rotationCirclePointColl = { x: cosAngle * (rotationCirclePoint.x - center.x) -
|
|
3308
|
+
sinAngle * (rotationCirclePoint.y - center.y) + center.x,
|
|
3309
|
+
y: sinAngle * (rotationCirclePoint.x - center.x) + cosAngle
|
|
2933
3310
|
* (rotationCirclePoint.y - center.y) + center.y };
|
|
2934
|
-
obj.rotationCirclePointColl.ratioX = (obj.rotationCirclePointColl.x -
|
|
2935
|
-
|
|
2936
|
-
obj.rotationCirclePointColl.ratioY = (obj.rotationCirclePointColl.y -
|
|
2937
|
-
|
|
3311
|
+
obj.rotationCirclePointColl.ratioX = (obj.rotationCirclePointColl.x - parent.img.destLeft) /
|
|
3312
|
+
parent.img.destWidth;
|
|
3313
|
+
obj.rotationCirclePointColl.ratioY = (obj.rotationCirclePointColl.y - parent.img.destTop) /
|
|
3314
|
+
parent.img.destHeight;
|
|
2938
3315
|
}
|
|
2939
3316
|
}
|
|
2940
3317
|
};
|
|
2941
3318
|
Shape.prototype.getSquarePointForRotatedShape = function (obj, object) {
|
|
2942
3319
|
var point = { startX: 0, startY: 0, endX: 0, endY: 0, width: 0, height: 0 };
|
|
2943
|
-
var
|
|
2944
|
-
|
|
2945
|
-
var
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
var p2 = { x:
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
var
|
|
2954
|
-
|
|
2955
|
-
y: Math.sin(obj.rotatedAngle) * (obj.activePoint.startX - center.x) + Math.cos(obj.rotatedAngle) * (obj.activePoint.endY
|
|
2956
|
-
- center.y) + center.y };
|
|
2957
|
-
var p4 = { x: Math.cos(obj.rotatedAngle) * (obj.activePoint.endX - center.x) - Math.sin(obj.rotatedAngle) *
|
|
2958
|
-
(obj.activePoint.endY - center.y) + center.x,
|
|
2959
|
-
y: Math.sin(obj.rotatedAngle) * (obj.activePoint.endX - center.x) + Math.cos(obj.rotatedAngle) *
|
|
2960
|
-
(obj.activePoint.endY - center.y) + center.y };
|
|
3320
|
+
var _a = obj.activePoint, startX = _a.startX, startY = _a.startY, endX = _a.endX, endY = _a.endY, width = _a.width, height = _a.height;
|
|
3321
|
+
var center = { x: startX + (width / 2), y: startY + (height / 2) };
|
|
3322
|
+
var cosAngle = Math.cos(obj.rotatedAngle);
|
|
3323
|
+
var sinAngle = Math.sin(obj.rotatedAngle);
|
|
3324
|
+
var p1 = { x: cosAngle * (startX - center.x) - sinAngle * (startY - center.y) + center.x,
|
|
3325
|
+
y: sinAngle * (startX - center.x) + cosAngle * (startY - center.y) + center.y };
|
|
3326
|
+
var p2 = { x: cosAngle * (endX - center.x) - sinAngle * (startY - center.y) + center.x,
|
|
3327
|
+
y: sinAngle * (endX - center.x) + cosAngle * (startY - center.y) + center.y };
|
|
3328
|
+
var p3 = { x: cosAngle * (startX - center.x) - sinAngle * (endY - center.y) + center.x,
|
|
3329
|
+
y: sinAngle * (startX - center.x) + cosAngle * (endY - center.y) + center.y };
|
|
3330
|
+
var p4 = { x: cosAngle * (endX - center.x) - sinAngle * (endY - center.y) + center.x,
|
|
3331
|
+
y: sinAngle * (endX - center.x) + cosAngle * (endY - center.y) + center.y };
|
|
2961
3332
|
point.startX = p1.x;
|
|
2962
3333
|
point.startY = p1.y;
|
|
2963
3334
|
point.endX = p1.x;
|