@syncfusion/ej2-image-editor 24.1.41 → 24.1.43

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.
@@ -1547,7 +1547,7 @@ class Draw {
1547
1547
  let width;
1548
1548
  let height;
1549
1549
  const canvasWidth = parent.lowerCanvas.clientWidth;
1550
- const canvasHeight = parent.lowerCanvas.clientHeight;
1550
+ const canvasHeight = parent.lowerCanvas.clientHeight + 1;
1551
1551
  const { destLeft, destTop, destWidth, destHeight } = parent.img;
1552
1552
  if (parent.transform.zoomFactor > 0 && this.currSelPoint) {
1553
1553
  const activeObj = extend({}, parent.activeObj, {}, true);
@@ -3422,6 +3422,7 @@ class Draw {
3422
3422
  hideSpinner(parent.element);
3423
3423
  parent.element.style.opacity = '1';
3424
3424
  proxy.updateBaseImgCanvas();
3425
+ const fileOpened = { fileName: this.fileName, fileType: this.fileType, isValidImage: true };
3425
3426
  proxy.updateCanvas();
3426
3427
  if (parent.currObjType.isUndoZoom) {
3427
3428
  parent.currObjType.isUndoZoom = false;
@@ -3451,6 +3452,14 @@ class Draw {
3451
3452
  - parent.toolbarHeight * 2) - 1 + 'px';
3452
3453
  }
3453
3454
  }
3455
+ if (parent.isImageLoaded && parent.element.style.opacity !== '0.5') {
3456
+ if (isBlazor() && parent.events && parent.events.fileOpened.hasDelegate === true) {
3457
+ parent.dotNetRef.invokeMethodAsync('FileOpenEventAsync', 'FileOpened', fileOpened);
3458
+ }
3459
+ else {
3460
+ parent.trigger('fileOpened', fileOpened);
3461
+ }
3462
+ }
3454
3463
  };
3455
3464
  parent.baseImg.onerror = () => {
3456
3465
  hideSpinner(parent.element);
@@ -3476,7 +3485,6 @@ class Draw {
3476
3485
  }
3477
3486
  updateCanvas() {
3478
3487
  const parent = this.parent;
3479
- const fileOpened = { fileName: this.fileName, fileType: this.fileType, isValidImage: true };
3480
3488
  parent.img.srcWidth = parent.baseImgCanvas.width;
3481
3489
  parent.img.srcHeight = parent.baseImgCanvas.height;
3482
3490
  const obj = { width: 0, height: 0 };
@@ -3512,14 +3520,6 @@ class Draw {
3512
3520
  if (parent.disabled) {
3513
3521
  parent.element.setAttribute('class', 'e-disabled');
3514
3522
  }
3515
- if (parent.isImageLoaded && parent.element.style.opacity !== '0.5') {
3516
- if (isBlazor() && parent.events && parent.events.fileOpened.hasDelegate === true) {
3517
- parent.dotNetRef.invokeMethodAsync('FileOpenEventAsync', 'FileOpened', fileOpened);
3518
- }
3519
- else {
3520
- parent.trigger('fileOpened', fileOpened);
3521
- }
3522
- }
3523
3523
  if (parent.zoomSettings.zoomFactor !== 1 || parent.zoomSettings.zoomPoint) {
3524
3524
  parent.zoom(parent.zoomSettings.zoomFactor, parent.zoomSettings.zoomPoint);
3525
3525
  }
@@ -15130,12 +15130,14 @@ class Shape {
15130
15130
  return;
15131
15131
  }
15132
15132
  else if (e.type === 'dblclick') {
15133
+ const activeObj = extend({}, parent.activeObj, {}, true);
15133
15134
  const objColl = extend([], parent.objColl, [], true);
15134
15135
  const obj = { bool: null };
15135
15136
  parent.notify('selection', { prop: 'findTargetObj', onPropertyChange: false,
15136
15137
  value: { x: e.clientX, y: e.clientY, isCrop: false, obj: obj } });
15137
15138
  parent.objColl = objColl;
15138
15139
  if (!obj['bool'] || parent.activeObj.shape !== 'text') {
15140
+ parent.activeObj = extend({}, activeObj, {}, true);
15139
15141
  return;
15140
15142
  }
15141
15143
  }
@@ -19028,12 +19030,16 @@ class Transform {
19028
19030
  }
19029
19031
  straightenImage(degree) {
19030
19032
  const parent = this.parent;
19033
+ if (parent.toolbar && parent.toolbar.length === 0) {
19034
+ parent.notify('draw', { prop: 'select', onPropertyChange: false,
19035
+ value: { type: 'custom', startX: null, startY: null, width: null, height: null } });
19036
+ }
19031
19037
  if (isBlazor()) {
19032
19038
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
19033
19039
  parent.performCropClick();
19034
19040
  }
19035
19041
  else {
19036
- parent.notify('toolbar', { prop: 'performCropTransformClick' });
19042
+ parent.notify('toolbar', { prop: 'performCropTransformClick', value: { shape: null } });
19037
19043
  }
19038
19044
  parent.setStraighten(degree, true);
19039
19045
  if ((isBlazor() && parent.events && parent.events.straightening.hasDelegate === false) || !isBlazor()) {
@@ -21170,6 +21176,7 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends Component {
21170
21176
  *
21171
21177
  */
21172
21178
  select(type, startX, startY, width, height) {
21179
+ this.notify('toolbar', { prop: 'performCropTransformClick', value: { shape: 'crop-' + type } });
21173
21180
  this.notify('draw', { prop: 'select', onPropertyChange: false,
21174
21181
  value: { type: type, startX: startX, startY: startY, width: width, height: height } });
21175
21182
  this.notify('draw', { prop: 'select', onPropertyChange: false,
@@ -23359,7 +23366,8 @@ let ImageEditor = ImageEditor_1 = class ImageEditor extends Component {
23359
23366
  this.initializeThemeColl();
23360
23367
  }
23361
23368
  initializeZoomSettings() {
23362
- if (isNullOrUndefined(this.zoomSettings.zoomTrigger)) {
23369
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
23370
+ if (isNullOrUndefined(this.zoomSettings.zoomTrigger) || this.zoomSettings.zoomTrigger === 0) {
23363
23371
  this.zoomSettings.zoomTrigger = (ZoomTrigger.MouseWheel | ZoomTrigger.Pinch | ZoomTrigger.Toolbar | ZoomTrigger.Commands);
23364
23372
  }
23365
23373
  if (isNullOrUndefined(this.selectionSettings.strokeColor)) {
@@ -24151,7 +24159,7 @@ class ToolbarModule {
24151
24159
  this.frameToolbarClick();
24152
24160
  break;
24153
24161
  case 'performCropTransformClick':
24154
- this.performCropTransformClick();
24162
+ this.performCropTransformClick(args.value['shape']);
24155
24163
  break;
24156
24164
  case 'duplicateShape':
24157
24165
  this.duplicateShape(args.value['isPreventUndoRedo'], true);
@@ -24343,6 +24351,9 @@ class ToolbarModule {
24343
24351
  else {
24344
24352
  this.defToolbarItems = [...leftItem, ...mainItem, ...rightItem, ...zoomItem];
24345
24353
  }
24354
+ const args = { toolbarType: 'main', toolbarItems: this.defToolbarItems };
24355
+ parent.trigger('toolbarUpdating', args);
24356
+ this.defToolbarItems = args.toolbarItems;
24346
24357
  const toolbarObj = new Toolbar({
24347
24358
  width: '100%',
24348
24359
  items: this.defToolbarItems,
@@ -24375,7 +24386,10 @@ class ToolbarModule {
24375
24386
  const parent = this.parent;
24376
24387
  const id = parent.element.id;
24377
24388
  if (isNullOrUndefined(parent.toolbar) || (parent.toolbar && parent.toolbar.length > 0)) {
24378
- const items = this.getMainToolbarItem();
24389
+ let items = this.getMainToolbarItem();
24390
+ const args = { toolbarType: 'bottom-toolbar', toolbarItems: items };
24391
+ parent.trigger('toolbarUpdating', args);
24392
+ items = args.toolbarItems;
24379
24393
  const toolbarObj = new Toolbar({ items: items, width: '100%',
24380
24394
  created: () => {
24381
24395
  this.renderAnnotationBtn();
@@ -24799,6 +24813,9 @@ class ToolbarModule {
24799
24813
  else {
24800
24814
  this.defToolbarItems = [...leftItem, ...zoomItem, ...mainItem, ...rightItem];
24801
24815
  }
24816
+ const args = { toolbarType: 'resize', toolbarItems: this.defToolbarItems };
24817
+ parent.trigger('toolbarUpdating', args);
24818
+ this.defToolbarItems = args.toolbarItems;
24802
24819
  const toolbar = new Toolbar({
24803
24820
  width: '100%',
24804
24821
  items: this.defToolbarItems,
@@ -25099,7 +25116,7 @@ class ToolbarModule {
25099
25116
  }
25100
25117
  }
25101
25118
  }
25102
- renderCropBtn() {
25119
+ renderCropBtn(shapeString) {
25103
25120
  const parent = this.parent;
25104
25121
  const items = [];
25105
25122
  let isCustomized = false;
@@ -25135,7 +25152,11 @@ class ToolbarModule {
25135
25152
  }
25136
25153
  let iconCss;
25137
25154
  let shape;
25138
- if (parent.activeObj.shape) {
25155
+ if (shapeString) {
25156
+ iconCss = this.getCurrentShapeIcon(shapeString);
25157
+ shape = shapeString;
25158
+ }
25159
+ else if (parent.activeObj.shape) {
25139
25160
  iconCss = this.getCurrentShapeIcon(parent.activeObj.shape);
25140
25161
  shape = parent.activeObj.shape;
25141
25162
  }
@@ -25345,7 +25366,7 @@ class ToolbarModule {
25345
25366
  }
25346
25367
  return toolbarItems;
25347
25368
  }
25348
- initCropTransformToolbar() {
25369
+ initCropTransformToolbar(shape) {
25349
25370
  const parent = this.parent;
25350
25371
  const id = parent.element.id;
25351
25372
  const leftItem = this.getLeftToolbarItem();
@@ -25358,12 +25379,15 @@ class ToolbarModule {
25358
25379
  else {
25359
25380
  this.defToolbarItems = [...leftItem, ...zoomItem, ...mainItem, ...rightItem];
25360
25381
  }
25382
+ const args = { toolbarType: 'crop-transform', toolbarItems: this.defToolbarItems };
25383
+ parent.trigger('toolbarUpdating', args);
25384
+ this.defToolbarItems = args.toolbarItems;
25361
25385
  const toolbar = new Toolbar({
25362
25386
  width: '100%',
25363
25387
  items: this.defToolbarItems,
25364
25388
  clicked: this.defToolbarClicked.bind(this),
25365
25389
  created: () => {
25366
- this.renderCropBtn();
25390
+ this.renderCropBtn(shape);
25367
25391
  this.renderStraightenSlider();
25368
25392
  this.wireZoomBtnEvents();
25369
25393
  if (!Browser.isDevice) {
@@ -25405,8 +25429,6 @@ class ToolbarModule {
25405
25429
  && slider && slider.parentElement.scrollHeight > this.toolbarHeight) {
25406
25430
  this.toolbarHeight = parent.toolbarHeight = slider.parentElement.scrollHeight;
25407
25431
  }
25408
- /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
25409
- toolbar.refreshOverflow();
25410
25432
  this.enableDisableTbrBtn();
25411
25433
  parent.notify('transform', { prop: 'disableZoomOutBtn', value: { isZoomOut: true } });
25412
25434
  }
@@ -25465,6 +25487,10 @@ class ToolbarModule {
25465
25487
  else {
25466
25488
  this.defToolbarItems = [...leftItem, ...zoomItem, ...mainItem, ...rightItem];
25467
25489
  }
25490
+ const args = { toolbarType: parent.activeObj.shape ? parent.activeObj.shape : 'shapes',
25491
+ toolbarItems: this.defToolbarItems };
25492
+ parent.trigger('toolbarUpdating', args);
25493
+ this.defToolbarItems = args.toolbarItems;
25468
25494
  const toolbar = new Toolbar({
25469
25495
  width: '100%',
25470
25496
  items: this.defToolbarItems,
@@ -25869,6 +25895,9 @@ class ToolbarModule {
25869
25895
  else {
25870
25896
  this.defToolbarItems = [...leftItem, ...zoomItem, ...mainItem, ...rightItem];
25871
25897
  }
25898
+ const args = { toolbarType: 'text', toolbarItems: this.defToolbarItems };
25899
+ parent.trigger('toolbarUpdating', args);
25900
+ this.defToolbarItems = args.toolbarItems;
25872
25901
  const toolbar = new Toolbar({
25873
25902
  width: '100%',
25874
25903
  items: this.defToolbarItems,
@@ -25992,8 +26021,10 @@ class ToolbarModule {
25992
26021
  else {
25993
26022
  fontFamily = parent.activeObj.textSettings.fontFamily;
25994
26023
  }
25995
- args.element.querySelector('[id *= ' + '"' + fontFamily.toLowerCase()
25996
- + '"' + ']').classList.add('e-selected-btn');
26024
+ const elem = args.element.querySelector('[id *= ' + '"' + fontFamily.toLowerCase() + '"' + ']');
26025
+ if (elem) {
26026
+ elem.classList.add('e-selected-btn');
26027
+ }
25997
26028
  },
25998
26029
  select: (args) => {
25999
26030
  spanElem.textContent = args.item.text;
@@ -26031,14 +26062,13 @@ class ToolbarModule {
26031
26062
  fontSizeBtn.appendTo('#' + id + '_fontSizeBtn');
26032
26063
  }
26033
26064
  }
26034
- refreshToolbar(type, isApplyBtn, isCropping, isZooming, cType) {
26065
+ refreshToolbar(type, isApplyBtn, isCropping, isZooming, cType, shape) {
26035
26066
  const parent = this.parent;
26036
26067
  const id = parent.element.id;
26037
26068
  if (!parent.isImageLoaded || parent.isCropToolbar) {
26038
26069
  return;
26039
26070
  }
26040
- const item = type === 'shapes' && parent.activeObj.shape ? parent.activeObj.shape : type;
26041
- const args = { toolbarType: item };
26071
+ const args = {};
26042
26072
  let aspectIcon;
26043
26073
  let nonAspectIcon;
26044
26074
  if (type !== 'filter' && type !== 'color') {
@@ -26104,7 +26134,6 @@ class ToolbarModule {
26104
26134
  else {
26105
26135
  args.toolbarItems = ['fillColor', 'strokeColor', 'strokeWidth', 'duplicate', 'remove'];
26106
26136
  }
26107
- parent.trigger('toolbarUpdating', args);
26108
26137
  this.initShapesToolbarItem(args.toolbarItems);
26109
26138
  break;
26110
26139
  case 'text':
@@ -26112,7 +26141,6 @@ class ToolbarModule {
26112
26141
  this.initMainToolbar(false, true, true);
26113
26142
  }
26114
26143
  args.toolbarItems = ['fontFamily', 'fontSize', 'fontColor', 'bold', 'italic', 'duplicate', 'remove', 'text'];
26115
- parent.trigger('toolbarUpdating', args);
26116
26144
  this.initTextToolbarItem(args.toolbarItems);
26117
26145
  break;
26118
26146
  case 'pen':
@@ -26120,7 +26148,6 @@ class ToolbarModule {
26120
26148
  this.initMainToolbar(false, true, true);
26121
26149
  }
26122
26150
  args.toolbarItems = ['strokeColor', 'strokeWidth', 'remove', 'transparency'];
26123
- parent.trigger('toolbarUpdating', args);
26124
26151
  this.initPenToolbarItem(args.toolbarItems);
26125
26152
  break;
26126
26153
  case 'adjustment':
@@ -26162,7 +26189,7 @@ class ToolbarModule {
26162
26189
  this.initMainToolbar(false, true, true);
26163
26190
  }
26164
26191
  parent.updateCropTransformItems();
26165
- this.initCropTransformToolbar();
26192
+ this.initCropTransformToolbar(shape);
26166
26193
  if (Browser.isDevice) {
26167
26194
  this.updateContextualToolbar('color', 'straighten', true);
26168
26195
  }
@@ -26189,7 +26216,7 @@ class ToolbarModule {
26189
26216
  this.currToolbar = type;
26190
26217
  this.refreshDropDownBtn(isCropping);
26191
26218
  }
26192
- performCropTransformClick() {
26219
+ performCropTransformClick(shape) {
26193
26220
  const parent = this.parent;
26194
26221
  parent.notify('draw', { prop: 'setTempStraightenZoomDeg' });
26195
26222
  parent.tempStraighten = parent.transform.straighten;
@@ -26197,7 +26224,7 @@ class ToolbarModule {
26197
26224
  parent.okBtn();
26198
26225
  }
26199
26226
  parent.isStraightening = true;
26200
- this.refreshToolbar('croptransform');
26227
+ this.refreshToolbar('croptransform', null, null, null, null, shape);
26201
26228
  parent.notify('draw', { prop: 'setDestForStraighten' });
26202
26229
  parent.notify('draw', { prop: 'setTempDestForStraighten' });
26203
26230
  }
@@ -26389,6 +26416,9 @@ class ToolbarModule {
26389
26416
  else {
26390
26417
  this.defToolbarItems = [...leftItem, ...zoomItem, ...mainItem, ...rightItem];
26391
26418
  }
26419
+ const args = { toolbarType: 'pen', toolbarItems: this.defToolbarItems };
26420
+ parent.trigger('toolbarUpdating', args);
26421
+ this.defToolbarItems = args.toolbarItems;
26392
26422
  const toolbar = new Toolbar({
26393
26423
  width: '100%',
26394
26424
  items: this.defToolbarItems,
@@ -26555,6 +26585,9 @@ class ToolbarModule {
26555
26585
  else {
26556
26586
  this.defToolbarItems = [...leftItem, ...zoomItem, ...mainItem, ...rightItem];
26557
26587
  }
26588
+ const args = { toolbarType: 'finetune', toolbarItems: this.defToolbarItems };
26589
+ parent.trigger('toolbarUpdating', args);
26590
+ this.defToolbarItems = args.toolbarItems;
26558
26591
  const toolbar = new Toolbar({
26559
26592
  width: '100%',
26560
26593
  items: this.defToolbarItems,
@@ -26604,7 +26637,10 @@ class ToolbarModule {
26604
26637
  id: id + '_customizeWrapper',
26605
26638
  styles: 'position: absolute'
26606
26639
  }));
26607
- const mainItem = this.getFrameToolbarItem();
26640
+ let mainItem = this.getFrameToolbarItem();
26641
+ const args = { toolbarType: 'frame', toolbarItems: mainItem };
26642
+ parent.trigger('toolbarUpdating', args);
26643
+ mainItem = args.toolbarItems;
26608
26644
  const toolbar = new Toolbar({
26609
26645
  width: '100%',
26610
26646
  items: mainItem,
@@ -27228,7 +27264,10 @@ class ToolbarModule {
27228
27264
  initFilterToolbarItem() {
27229
27265
  const parent = this.parent;
27230
27266
  const id = parent.element.id;
27231
- const mainItem = this.getFilterToolbarItem();
27267
+ let mainItem = this.getFilterToolbarItem();
27268
+ const args = { toolbarType: 'filter', toolbarItems: mainItem };
27269
+ parent.trigger('toolbarUpdating', args);
27270
+ mainItem = args.toolbarItems;
27232
27271
  if (document.querySelector('#' + id + '_contextualToolbar').classList.contains('e-control')) {
27233
27272
  getComponent(document.getElementById(id + '_contextualToolbar'), 'toolbar').destroy();
27234
27273
  }