@syncfusion/ej2-image-editor 24.2.3 → 24.2.4

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.
@@ -8302,6 +8302,7 @@ class Selection {
8302
8302
  this.isImageClarity = true;
8303
8303
  this.isPinching = false;
8304
8304
  this.isSliding = false;
8305
+ this.mouseDown = '';
8305
8306
  this.parent = parent;
8306
8307
  this.addEventListener();
8307
8308
  }
@@ -8590,6 +8591,7 @@ class Selection {
8590
8591
  this.currentDrawingShape = '';
8591
8592
  this.initialPrevObj = {};
8592
8593
  this.resizedElement = '';
8594
+ this.mouseDown = '';
8593
8595
  }
8594
8596
  performTabAction() {
8595
8597
  const parent = this.parent;
@@ -11005,6 +11007,8 @@ class Selection {
11005
11007
  }
11006
11008
  mouseDownEventHandler(e) {
11007
11009
  const parent = this.parent;
11010
+ this.mouseDown = e.currentTarget === parent.lowerCanvas || e.currentTarget === parent.upperCanvas ?
11011
+ 'canvas' : '';
11008
11012
  if (e.type === 'touchstart') {
11009
11013
  this.isTouch = true;
11010
11014
  }
@@ -11442,6 +11446,10 @@ class Selection {
11442
11446
  && !parent.element.querySelector('#' + id + '_headWrapper').parentElement.classList.contains('e-hide')))) {
11443
11447
  return;
11444
11448
  }
11449
+ else if (e.currentTarget === document && this.mouseDown === '') {
11450
+ e.stopImmediatePropagation();
11451
+ return;
11452
+ }
11445
11453
  if (e.type === 'touchstart') {
11446
11454
  this.isTouch = false;
11447
11455
  }
@@ -11701,6 +11709,7 @@ class Selection {
11701
11709
  parent.currObjType.shape = '';
11702
11710
  }
11703
11711
  this.dragElement = '';
11712
+ this.mouseDown = '';
11704
11713
  parent.currObjType.isInitialLine = parent.currObjType.isDragging = false;
11705
11714
  this.selMouseUpEvent();
11706
11715
  }
@@ -19354,6 +19363,7 @@ class UndoRedo {
19354
19363
  undo() {
19355
19364
  const parent = this.parent;
19356
19365
  this.cancelCropSelection();
19366
+ parent.notify('draw', { prop: 'resetFrameZoom', onPropertyChange: false, value: { isOk: false } });
19357
19367
  if (!parent.disabled && parent.isImageLoaded) {
19358
19368
  if (this.undoRedoStep > 0) {
19359
19369
  this.refreshToolbarActions();
@@ -19492,6 +19502,7 @@ class UndoRedo {
19492
19502
  redo() {
19493
19503
  const parent = this.parent;
19494
19504
  this.cancelCropSelection();
19505
+ parent.notify('draw', { prop: 'resetFrameZoom', onPropertyChange: false, value: { isOk: false } });
19495
19506
  if (!parent.disabled && parent.isImageLoaded) {
19496
19507
  if (this.undoRedoStep < this.appliedUndoRedoColl.length) {
19497
19508
  this.refreshToolbarActions();
@@ -25574,7 +25585,13 @@ class ToolbarModule {
25574
25585
  const args = { toolbarType: parent.activeObj.shape ? parent.activeObj.shape : 'shapes',
25575
25586
  toolbarItems: this.defToolbarItems };
25576
25587
  parent.trigger('toolbarUpdating', args);
25577
- this.defToolbarItems = args.toolbarItems;
25588
+ if (this.isToolbarString(args.toolbarItems)) {
25589
+ items = args.toolbarItems;
25590
+ this.excludeItems(args.toolbarItems);
25591
+ }
25592
+ else {
25593
+ this.defToolbarItems = args.toolbarItems;
25594
+ }
25578
25595
  const toolbar = new Toolbar({
25579
25596
  width: '100%',
25580
25597
  items: this.defToolbarItems,
@@ -25584,8 +25601,12 @@ class ToolbarModule {
25584
25601
  this.createShapeColor(items);
25585
25602
  this.createShapeBtn(items);
25586
25603
  if (parent.activeObj.shape === 'arrow') {
25587
- this.createStartBtn();
25588
- this.createEndBtn();
25604
+ if (items.some(item => item.toLowerCase().indexOf('start') > -1)) {
25605
+ this.createStartBtn();
25606
+ }
25607
+ if (items.some(item => item.toLowerCase().indexOf('end') > -1)) {
25608
+ this.createEndBtn();
25609
+ }
25589
25610
  }
25590
25611
  this.wireZoomBtnEvents();
25591
25612
  if (!Browser.isDevice) {
@@ -25748,24 +25769,24 @@ class ToolbarModule {
25748
25769
  createShapeBtn(items) {
25749
25770
  const parent = this.parent;
25750
25771
  const id = parent.element.id;
25751
- let strokeWidthItems = [
25752
- { id: '1', text: this.l10n.getConstant('XSmall') },
25753
- { id: '2', text: this.l10n.getConstant('Small') },
25754
- { id: '3', text: this.l10n.getConstant('Medium') },
25755
- { id: '4', text: this.l10n.getConstant('Large') },
25756
- { id: '5', text: this.l10n.getConstant('XLarge') }
25757
- ];
25758
- if (parent.activeObj.shape && (parent.activeObj.shape === 'rectangle' || parent.activeObj.shape === 'ellipse')) {
25759
- strokeWidthItems = [
25760
- { id: '1', text: this.l10n.getConstant('NoOutline') },
25761
- { id: '2', text: this.l10n.getConstant('XSmall') },
25762
- { id: '3', text: this.l10n.getConstant('Small') },
25763
- { id: '4', text: this.l10n.getConstant('Medium') },
25764
- { id: '5', text: this.l10n.getConstant('Large') },
25765
- { id: '6', text: this.l10n.getConstant('XLarge') }
25766
- ];
25767
- }
25768
25772
  if (items.indexOf('strokeWidth') > -1) {
25773
+ let strokeWidthItems = [
25774
+ { id: '1', text: this.l10n.getConstant('XSmall') },
25775
+ { id: '2', text: this.l10n.getConstant('Small') },
25776
+ { id: '3', text: this.l10n.getConstant('Medium') },
25777
+ { id: '4', text: this.l10n.getConstant('Large') },
25778
+ { id: '5', text: this.l10n.getConstant('XLarge') }
25779
+ ];
25780
+ if (parent.activeObj.shape && (parent.activeObj.shape === 'rectangle' || parent.activeObj.shape === 'ellipse')) {
25781
+ strokeWidthItems = [
25782
+ { id: '1', text: this.l10n.getConstant('NoOutline') },
25783
+ { id: '2', text: this.l10n.getConstant('XSmall') },
25784
+ { id: '3', text: this.l10n.getConstant('Small') },
25785
+ { id: '4', text: this.l10n.getConstant('Medium') },
25786
+ { id: '5', text: this.l10n.getConstant('Large') },
25787
+ { id: '6', text: this.l10n.getConstant('XLarge') }
25788
+ ];
25789
+ }
25769
25790
  const strokeWidthBtn = document.getElementById(id + '_borderWidthBtn');
25770
25791
  const spanElem = document.createElement('span');
25771
25792
  spanElem.innerHTML = this.l10n.getConstant('XSmall');
@@ -25981,7 +26002,13 @@ class ToolbarModule {
25981
26002
  }
25982
26003
  const args = { toolbarType: 'text', toolbarItems: this.defToolbarItems };
25983
26004
  parent.trigger('toolbarUpdating', args);
25984
- this.defToolbarItems = args.toolbarItems;
26005
+ if (this.isToolbarString(args.toolbarItems)) {
26006
+ items = args.toolbarItems;
26007
+ this.excludeItems(args.toolbarItems);
26008
+ }
26009
+ else {
26010
+ this.defToolbarItems = args.toolbarItems;
26011
+ }
25985
26012
  const toolbar = new Toolbar({
25986
26013
  width: '100%',
25987
26014
  items: this.defToolbarItems,
@@ -26466,7 +26493,8 @@ class ToolbarModule {
26466
26493
  template: '<button id="' + id + '_penColorBtn"></button>' });
26467
26494
  }
26468
26495
  if (items.indexOf('strokeWidth') > -1) {
26469
- toolbarItems.push({ prefixIcon: 'e-icons e-copy', cssClass: 'top-icon e-size',
26496
+ toolbarItems.push({ prefixIcon: 'e-icons e-copy', id: id + '_pen_strokewidth',
26497
+ cssClass: 'top-icon e-size',
26470
26498
  tooltipText: this.l10n.getConstant('StrokeWidth'),
26471
26499
  align: 'Center', type: 'Input', template: '<button id="' + id + '_penStrokeWidth"></button>' });
26472
26500
  }
@@ -26502,7 +26530,13 @@ class ToolbarModule {
26502
26530
  }
26503
26531
  const args = { toolbarType: 'pen', toolbarItems: this.defToolbarItems };
26504
26532
  parent.trigger('toolbarUpdating', args);
26505
- this.defToolbarItems = args.toolbarItems;
26533
+ if (this.isToolbarString(args.toolbarItems)) {
26534
+ items = args.toolbarItems;
26535
+ this.excludeItems(args.toolbarItems);
26536
+ }
26537
+ else {
26538
+ this.defToolbarItems = args.toolbarItems;
26539
+ }
26506
26540
  const toolbar = new Toolbar({
26507
26541
  width: '100%',
26508
26542
  items: this.defToolbarItems,
@@ -27640,6 +27674,8 @@ class ToolbarModule {
27640
27674
  let ctx;
27641
27675
  parent.notify('draw', { prop: 'getNewPath', value: { obj: pathObject } });
27642
27676
  const type = args.item.id.replace(id + '_', '').toLowerCase();
27677
+ let left;
27678
+ let right;
27643
27679
  switch (type) {
27644
27680
  case 'duplicate':
27645
27681
  if (!parent.element.querySelector('#' + id + '_duplicate').classList.contains('e-disabled')) {
@@ -27689,8 +27725,10 @@ class ToolbarModule {
27689
27725
  break;
27690
27726
  case 'rotleft':
27691
27727
  case 'rotright':
27692
- if (!parent.element.querySelector('#' + id + '_rotLeft').classList.contains('e-disabled') ||
27693
- !parent.element.querySelector('#' + id + '_rotRight').classList.contains('e-disabled')) {
27728
+ left = parent.element.querySelector('#' + id + '_rotLeft');
27729
+ right = parent.element.querySelector('#' + id + '_rotRight');
27730
+ if ((left && !left.classList.contains('e-disabled')) ||
27731
+ (right && !right.classList.contains('e-disabled'))) {
27694
27732
  parent.rotateImage(args.item.id.replace(id + '_', '').toLowerCase());
27695
27733
  }
27696
27734
  break;
@@ -28817,6 +28855,80 @@ class ToolbarModule {
28817
28855
  parent.activeObj.textFlip = parent.transform.currFlipState;
28818
28856
  parent.activeObj.flipObjColl = [];
28819
28857
  }
28858
+ isToolbarString(items) {
28859
+ let isString = false;
28860
+ for (let i = 0; i < items.length; i++) {
28861
+ if (typeof (items[i]) === 'string') {
28862
+ isString = true;
28863
+ break;
28864
+ }
28865
+ }
28866
+ return isString;
28867
+ }
28868
+ excludeItems(items) {
28869
+ const indexArr = [];
28870
+ for (let i = 0; i < items.length; i++) {
28871
+ const index = this.getIndex(items[i]);
28872
+ if (index !== -1) {
28873
+ indexArr.push(index);
28874
+ }
28875
+ }
28876
+ const negativeIndexArr = [];
28877
+ for (let i = 0; i < this.defToolbarItems.length; i++) {
28878
+ if (this.defToolbarItems[i].align === 'Center' && !this.isSameIndex(indexArr, i) &&
28879
+ this.defToolbarItems[i].id !== this.parent.element.id + '_' + 'annotation') {
28880
+ negativeIndexArr.push(i);
28881
+ }
28882
+ }
28883
+ for (let i = negativeIndexArr.length - 1; i >= 0; i--) {
28884
+ this.defToolbarItems.splice(negativeIndexArr[i], 1);
28885
+ }
28886
+ }
28887
+ isSameIndex(indexArr, index) {
28888
+ for (let i = 0; i < indexArr.length; i++) {
28889
+ if (indexArr[i] === index) {
28890
+ return true;
28891
+ }
28892
+ }
28893
+ return false;
28894
+ }
28895
+ getIndex(item) {
28896
+ let index = -1;
28897
+ let isFontColor = false;
28898
+ if (item === 'rotateLeft') {
28899
+ item = 'rotLeft';
28900
+ }
28901
+ if (item === 'rotateRight') {
28902
+ item = 'rotRight';
28903
+ }
28904
+ if (item === 'horizontalFlip') {
28905
+ item = 'hflip';
28906
+ }
28907
+ if (item === 'verticalFlip') {
28908
+ item = 'vflip';
28909
+ }
28910
+ if (item === 'arrowStart') {
28911
+ item = 'start';
28912
+ }
28913
+ if (item === 'arrowEnd') {
28914
+ item = 'end';
28915
+ }
28916
+ if (item === 'fontColor') {
28917
+ item = 'strokeColor';
28918
+ isFontColor = true;
28919
+ }
28920
+ for (let i = 0; i < this.defToolbarItems.length; i++) {
28921
+ const id = this.defToolbarItems[i].id;
28922
+ if (id && id.toLowerCase().indexOf(item.toLowerCase()) !== -1) {
28923
+ index = i;
28924
+ break;
28925
+ }
28926
+ }
28927
+ if (isFontColor) {
28928
+ item = 'fontColor';
28929
+ }
28930
+ return index;
28931
+ }
28820
28932
  getModuleName() {
28821
28933
  return 'toolbar-module';
28822
28934
  }