@univerjs/sheets-drawing-ui 0.6.0-experimental.20250125-1d060b9 → 0.6.0-experimental.20250220-d9a8e74

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/lib/es/facade.js CHANGED
@@ -1,75 +1,76 @@
1
1
  var L = Object.defineProperty;
2
2
  var X = (r, t, e) => t in r ? L(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
3
- var T = (r, t, e) => X(r, typeof t != "symbol" ? t + "" : t, e);
4
- import { Inject as x, Injector as P, ICommandService as W, generateRandomId as Y, DrawingTypeEnum as _, ImageSourceType as I, FBase as V, ArrangeTypeEnum as v, toDisposable as C, FEnum as M, FEventName as z, FUniver as N } from "@univerjs/core";
5
- import { getImageSize as q, SetDrawingSelectedOperation as A, IDrawingManagerService as l } from "@univerjs/drawing";
3
+ var x = (r, t, e) => X(r, typeof t != "symbol" ? t + "" : t, e);
4
+ import { Inject as P, Injector as j, ICommandService as W, generateRandomId as Y, DrawingTypeEnum as _, ImageSourceType as I, ArrangeTypeEnum as v, toDisposable as k } from "@univerjs/core";
5
+ import { FBase as V, FEnum as M, FEventName as H, FUniver as z } from "@univerjs/core/facade";
6
+ import { getImageSize as q, IDrawingManagerService as f, SetDrawingSelectedOperation as A } from "@univerjs/drawing";
6
7
  import { IRenderManagerService as F } from "@univerjs/engine-render";
7
- import { SetSheetDrawingCommand as m, SetDrawingArrangeCommand as w, SheetCanvasFloatDomManagerService as G, InsertSheetDrawingCommand as S, RemoveSheetDrawingCommand as D } from "@univerjs/sheets-drawing-ui";
8
+ import { SetSheetDrawingCommand as h, SetDrawingArrangeCommand as w, SheetCanvasFloatDomManagerService as C, InsertSheetDrawingCommand as S, RemoveSheetDrawingCommand as R } from "@univerjs/sheets-drawing-ui";
8
9
  import { SheetSkeletonManagerService as U, ISheetSelectionRenderService as J, convertPositionSheetOverGridToAbsolute as Q, convertPositionCellToSheetOverGrid as Z } from "@univerjs/sheets-ui";
9
- import { ISheetDrawingService as u, SheetDrawingAnchorType as ee } from "@univerjs/sheets-drawing";
10
- import { transformComponentKey as E } from "@univerjs/sheets-ui/facade";
11
- import { FWorksheet as $ } from "@univerjs/sheets/facade";
12
- import { ComponentManager as y } from "@univerjs/ui";
13
- var te = Object.defineProperty, ie = Object.getOwnPropertyDescriptor, H = (r, t, e, i) => {
14
- for (var n = i > 1 ? void 0 : i ? ie(t, e) : t, s = r.length - 1, o; s >= 0; s--)
10
+ import { ISheetDrawingService as l, SheetDrawingAnchorType as ee } from "@univerjs/sheets-drawing";
11
+ import { transformComponentKey as y } from "@univerjs/sheets-ui/facade";
12
+ import { FWorksheet as N } from "@univerjs/sheets/facade";
13
+ import { ComponentManager as D } from "@univerjs/ui";
14
+ var te = Object.defineProperty, re = Object.getOwnPropertyDescriptor, $ = (r, t, e, i) => {
15
+ for (var n = i > 1 ? void 0 : i ? re(t, e) : t, s = r.length - 1, o; s >= 0; s--)
15
16
  (o = r[s]) && (n = (i ? o(t, e, n) : o(n)) || n);
16
17
  return i && n && te(t, e, n), n;
17
- }, R = (r, t) => (e, i) => t(e, i, r);
18
- function re(r, t) {
19
- const { from: e, to: i, flipY: n = !1, flipX: s = !1, angle: o = 0, skewX: c = 0, skewY: a = 0 } = r.sheetTransform, { column: h, columnOffset: d, row: f, rowOffset: p } = e, k = Q(
18
+ }, G = (r, t) => (e, i) => t(e, i, r);
19
+ function ie(r, t) {
20
+ const { from: e, to: i, flipY: n = !1, flipX: s = !1, angle: o = 0, skewX: d = 0, skewY: a = 0 } = r.sheetTransform, { column: g, columnOffset: c, row: u, rowOffset: b } = e, O = Q(
20
21
  r.unitId,
21
22
  r.subUnitId,
22
23
  { from: e, to: i },
23
24
  t
24
- ), { left: B, top: j, width: O, height: K } = k;
25
+ ), { left: B, top: T, width: E, height: K } = O;
25
26
  return {
26
27
  ...r,
27
- column: h,
28
- columnOffset: d,
29
- row: f,
30
- rowOffset: p,
31
- width: O,
28
+ column: g,
29
+ columnOffset: c,
30
+ row: u,
31
+ rowOffset: b,
32
+ width: E,
32
33
  height: K,
33
34
  flipY: n,
34
35
  flipX: s,
35
36
  angle: o,
36
- skewX: c,
37
+ skewX: d,
37
38
  skewY: a
38
39
  };
39
40
  }
40
41
  function ne(r, t, e) {
41
- const { column: i, columnOffset: n, row: s, rowOffset: o, flipY: c = !1, flipX: a = !1, angle: h = 0, skewX: d = 0, skewY: f = 0, width: p, height: k } = r, B = Z(
42
+ const { column: i, columnOffset: n, row: s, rowOffset: o, flipY: d = !1, flipX: a = !1, angle: g = 0, skewX: c = 0, skewY: u = 0, width: b, height: O } = r, B = Z(
42
43
  r.unitId,
43
44
  r.subUnitId,
44
45
  { column: i, columnOffset: n, row: s, rowOffset: o },
45
- p,
46
- k,
46
+ b,
47
+ O,
47
48
  t,
48
49
  e
49
- ), { sheetTransform: j, transform: O } = B;
50
+ ), { sheetTransform: T, transform: E } = B;
50
51
  return {
51
52
  ...r,
52
53
  sheetTransform: {
53
- ...j,
54
- flipY: c,
54
+ ...T,
55
+ flipY: d,
55
56
  flipX: a,
56
- angle: h,
57
- skewX: d,
58
- skewY: f
57
+ angle: g,
58
+ skewX: c,
59
+ skewY: u
59
60
  },
60
61
  transform: {
61
- ...O,
62
- flipY: c,
62
+ ...E,
63
+ flipY: d,
63
64
  flipX: a,
64
- angle: h,
65
- skewX: d,
66
- skewY: f
65
+ angle: g,
66
+ skewX: c,
67
+ skewY: u
67
68
  }
68
69
  };
69
70
  }
70
- let b = class {
71
+ let p = class {
71
72
  constructor(r, t, e) {
72
- T(this, "_image");
73
+ x(this, "_image");
73
74
  this._injector = e, this._image = {
74
75
  drawingId: Y(6),
75
76
  drawingType: _.DRAWING_IMAGE,
@@ -124,7 +125,7 @@ let b = class {
124
125
  row: 0,
125
126
  rowOffset: 0
126
127
  }
127
- }), this._image = re(r, i), this;
128
+ }), this._image = ie(r, i), this;
128
129
  }
129
130
  setSource(r, t) {
130
131
  const e = t != null ? t : I.URL;
@@ -370,10 +371,10 @@ let b = class {
370
371
  return ne(this._image, e, i);
371
372
  }
372
373
  };
373
- b = H([
374
- R(2, x(P))
375
- ], b);
376
- let g = class extends V {
374
+ p = $([
375
+ G(2, P(j))
376
+ ], p);
377
+ let m = class extends V {
377
378
  constructor(r, t, e) {
378
379
  super(), this._image = r, this._commandService = t, this._injector = e;
379
380
  }
@@ -396,7 +397,7 @@ let g = class extends V {
396
397
  * ```
397
398
  */
398
399
  remove() {
399
- return this._commandService.syncExecuteCommand(m.id, { unitId: this._image.unitId, drawings: [this._image] });
400
+ return this._commandService.syncExecuteCommand(h.id, { unitId: this._image.unitId, drawings: [this._image] });
400
401
  }
401
402
  /**
402
403
  * Convert the image to a FOverGridImageBuilder
@@ -413,18 +414,18 @@ let g = class extends V {
413
414
  * ```
414
415
  */
415
416
  toBuilder() {
416
- const r = this._injector.createInstance(b);
417
+ const r = this._injector.createInstance(p);
417
418
  return r.setImage(this._image), r;
418
419
  }
419
420
  setSource(r, t) {
420
421
  const e = t != null ? t : I.URL;
421
- return this._image.source = r, this._image.imageSourceType = e, this._commandService.syncExecuteCommand(m.id, { unitId: this._image.unitId, drawings: [this._image] });
422
+ return this._image.source = r, this._image.imageSourceType = e, this._commandService.syncExecuteCommand(h.id, { unitId: this._image.unitId, drawings: [this._image] });
422
423
  }
423
424
  async setPositionAsync(r, t, e, i) {
424
425
  const n = this.toBuilder();
425
426
  n.setColumn(t), n.setRow(r), e != null && n.setRowOffset(e), i != null && n.setColumnOffset(i);
426
427
  const s = await n.buildAsync();
427
- return this._commandService.syncExecuteCommand(m.id, { unitId: this._image.unitId, drawings: [s] });
428
+ return this._commandService.syncExecuteCommand(h.id, { unitId: this._image.unitId, drawings: [s] });
428
429
  }
429
430
  /**
430
431
  * Set the size of the image
@@ -443,7 +444,7 @@ let g = class extends V {
443
444
  const e = this.toBuilder();
444
445
  e.setWidth(r), e.setHeight(t);
445
446
  const i = await e.buildAsync();
446
- return this._commandService.syncExecuteCommand(m.id, { unitId: this._image.unitId, drawings: [i] });
447
+ return this._commandService.syncExecuteCommand(h.id, { unitId: this._image.unitId, drawings: [i] });
447
448
  }
448
449
  /**
449
450
  * Set the cropping region of the image by defining the top, bottom, left, and right edges, thereby displaying the specific part of the image you want.
@@ -467,7 +468,7 @@ let g = class extends V {
467
468
  left: 0,
468
469
  bottom: 0,
469
470
  right: 0
470
- }), r != null && (this._image.srcRect.top = r), t != null && (this._image.srcRect.left = t), e != null && (this._image.srcRect.bottom = e), i != null && (this._image.srcRect.right = i), this._commandService.syncExecuteCommand(m.id, { unitId: this._image.unitId, drawings: [this._image] });
471
+ }), r != null && (this._image.srcRect.top = r), t != null && (this._image.srcRect.left = t), e != null && (this._image.srcRect.bottom = e), i != null && (this._image.srcRect.right = i), this._commandService.syncExecuteCommand(h.id, { unitId: this._image.unitId, drawings: [this._image] });
471
472
  }
472
473
  // setPresetGeometry(prstGeom: PresetGeometryType): boolean {
473
474
  // this._image.prstGeom = prstGeom;
@@ -487,7 +488,7 @@ let g = class extends V {
487
488
  * ```
488
489
  */
489
490
  setRotate(r) {
490
- return this._image.sheetTransform.angle = r, this._commandService.syncExecuteCommand(m.id, { unitId: this._image.unitId, drawings: [this._image] });
491
+ return this._image.sheetTransform.angle = r, this._commandService.syncExecuteCommand(h.id, { unitId: this._image.unitId, drawings: [this._image] });
491
492
  }
492
493
  /**
493
494
  * Move the image layer forward by one level
@@ -570,13 +571,13 @@ let g = class extends V {
570
571
  });
571
572
  }
572
573
  };
573
- g = H([
574
- R(1, W),
575
- R(2, x(P))
576
- ], g);
577
- class se extends $ {
574
+ m = $([
575
+ G(1, W),
576
+ G(2, P(j))
577
+ ], m);
578
+ class se extends N {
578
579
  addFloatDomToPosition(t, e) {
579
- const i = this._workbook.getUnitId(), n = this._worksheet.getSheetId(), { key: s, disposableCollection: o } = E(t, this._injector.get(y)), a = this._injector.get(G).addFloatDomToPosition({ ...t, componentKey: s, unitId: i, subUnitId: n }, e);
580
+ const i = this._workbook.getUnitId(), n = this._worksheet.getSheetId(), { key: s, disposableCollection: o } = y(t, this._injector.get(D)), a = this._injector.get(C).addFloatDomToPosition({ ...t, componentKey: s, unitId: i, subUnitId: n }, e);
580
581
  return a ? (o.add(a.dispose), {
581
582
  id: a.id,
582
583
  dispose: () => {
@@ -585,20 +586,20 @@ class se extends $ {
585
586
  }) : (o.dispose(), null);
586
587
  }
587
588
  addFloatDomToRange(t, e, i, n) {
588
- const s = this._workbook.getUnitId(), o = this._worksheet.getSheetId(), { key: c, disposableCollection: a } = E(e, this._injector.get(y)), d = this._injector.get(G).addFloatDomToRange(t.getRange(), { ...e, componentKey: c, unitId: s, subUnitId: o }, i, n);
589
- return d ? (a.add(d.dispose), {
590
- id: d.id,
589
+ const s = this._workbook.getUnitId(), o = this._worksheet.getSheetId(), { key: d, disposableCollection: a } = y(e, this._injector.get(D)), c = this._injector.get(C).addFloatDomToRange(t.getRange(), { ...e, componentKey: d, unitId: s, subUnitId: o }, i, n);
590
+ return c ? (a.add(c.dispose), {
591
+ id: c.id,
591
592
  dispose: () => {
592
- a.dispose(), d.dispose();
593
+ a.dispose(), c.dispose();
593
594
  }
594
595
  }) : (a.dispose(), null);
595
596
  }
596
597
  addFloatDomToColumnHeader(t, e, i, n) {
597
- const s = this._workbook.getUnitId(), o = this._worksheet.getSheetId(), { key: c, disposableCollection: a } = E(e, this._injector.get(y)), d = this._injector.get(G).addFloatDomToColumnHeader(t, { ...e, componentKey: c, unitId: s, subUnitId: o }, i, n);
598
- return d ? (a.add(d.dispose), {
599
- id: d.id,
598
+ const s = this._workbook.getUnitId(), o = this._worksheet.getSheetId(), { key: d, disposableCollection: a } = y(e, this._injector.get(D)), c = this._injector.get(C).addFloatDomToColumnHeader(t, { ...e, componentKey: d, unitId: s, subUnitId: o }, i, n);
599
+ return c ? (a.add(c.dispose), {
600
+ id: c.id,
600
601
  dispose: () => {
601
- a.dispose(), d.dispose();
602
+ a.dispose(), c.dispose();
602
603
  }
603
604
  }) : (a.dispose(), null);
604
605
  }
@@ -607,12 +608,12 @@ class se extends $ {
607
608
  if (typeof t == "string")
608
609
  o.setSource(t);
609
610
  else {
610
- const h = await t.getBlob().getDataAsString();
611
- o.setSource(h, I.BASE64);
611
+ const g = await t.getBlob().getDataAsString();
612
+ o.setSource(g, I.BASE64);
612
613
  }
613
614
  e !== void 0 ? o.setColumn(e) : o.setColumn(0), i !== void 0 ? o.setRow(i) : o.setRow(0), n !== void 0 ? o.setColumnOffset(n) : o.setColumnOffset(0), s !== void 0 ? o.setRowOffset(s) : o.setRowOffset(0);
614
- const c = await o.buildAsync();
615
- return this._commandService.syncExecuteCommand(S.id, { unitId: this._fWorkbook.getId(), drawings: [c] });
615
+ const d = await o.buildAsync();
616
+ return this._commandService.syncExecuteCommand(S.id, { unitId: this._fWorkbook.getId(), drawings: [d] });
616
617
  }
617
618
  insertImages(t) {
618
619
  const e = t.map((i) => (i.unitId = this._fWorkbook.getId(), i.subUnitId = this.getSheetId(), i));
@@ -625,64 +626,64 @@ class se extends $ {
625
626
  subUnitId: this.getSheetId(),
626
627
  drawingType: i.getType()
627
628
  }));
628
- return this._commandService.syncExecuteCommand(D.id, { unitId: this._fWorkbook.getId(), drawings: e }), this;
629
+ return this._commandService.syncExecuteCommand(R.id, { unitId: this._fWorkbook.getId(), drawings: e }), this;
629
630
  }
630
631
  getImages() {
631
- const e = this._injector.get(u).getDrawingData(this._fWorkbook.getId(), this.getSheetId()), i = [];
632
+ const e = this._injector.get(l).getDrawingData(this._fWorkbook.getId(), this.getSheetId()), i = [];
632
633
  for (const n in e) {
633
634
  const s = e[n];
634
- s.drawingType === _.DRAWING_IMAGE && i.push(this._injector.createInstance(g, s));
635
+ s.drawingType === _.DRAWING_IMAGE && i.push(this._injector.createInstance(m, s));
635
636
  }
636
637
  return i;
637
638
  }
638
639
  getImageById(t) {
639
- const i = this._injector.get(u).getDrawingByParam({ unitId: this._fWorkbook.getId(), subUnitId: this.getSheetId(), drawingId: t });
640
- return i && i.drawingType === _.DRAWING_IMAGE ? this._injector.createInstance(g, i) : null;
640
+ const i = this._injector.get(l).getDrawingByParam({ unitId: this._fWorkbook.getId(), subUnitId: this.getSheetId(), drawingId: t });
641
+ return i && i.drawingType === _.DRAWING_IMAGE ? this._injector.createInstance(m, i) : null;
641
642
  }
642
643
  getActiveImages() {
643
- const e = this._injector.get(u).getFocusDrawings(), i = [];
644
+ const e = this._injector.get(l).getFocusDrawings(), i = [];
644
645
  for (const n in e) {
645
646
  const s = e[n];
646
- i.push(this._injector.createInstance(g, s));
647
+ i.push(this._injector.createInstance(m, s));
647
648
  }
648
649
  return i;
649
650
  }
650
651
  updateImages(t) {
651
- return this._commandService.syncExecuteCommand(m.id, { unitId: this._fWorkbook.getId(), drawings: t }), this;
652
+ return this._commandService.syncExecuteCommand(h.id, { unitId: this._fWorkbook.getId(), drawings: t }), this;
652
653
  }
653
654
  onImageInserted(t) {
654
- const e = this._injector.get(u);
655
- return C(e.add$.subscribe((i) => {
655
+ const e = this._injector.get(l);
656
+ return k(e.add$.subscribe((i) => {
656
657
  const n = i.map(
657
- (s) => this._injector.createInstance(g, e.getDrawingByParam(s))
658
+ (s) => this._injector.createInstance(m, e.getDrawingByParam(s))
658
659
  );
659
660
  t(n);
660
661
  }));
661
662
  }
662
663
  onImageDeleted(t) {
663
- const e = this._injector.get(u);
664
- return C(e.remove$.subscribe((i) => {
664
+ const e = this._injector.get(l);
665
+ return k(e.remove$.subscribe((i) => {
665
666
  const n = i.map(
666
- (s) => this._injector.createInstance(g, e.getDrawingByParam(s))
667
+ (s) => this._injector.createInstance(m, e.getDrawingByParam(s))
667
668
  );
668
669
  t(n);
669
670
  }));
670
671
  }
671
672
  onImageChanged(t) {
672
- const e = this._injector.get(u);
673
- return C(e.update$.subscribe((i) => {
673
+ const e = this._injector.get(l);
674
+ return k(e.update$.subscribe((i) => {
674
675
  const n = i.map(
675
- (s) => this._injector.createInstance(g, e.getDrawingByParam(s))
676
+ (s) => this._injector.createInstance(m, e.getDrawingByParam(s))
676
677
  );
677
678
  t(n);
678
679
  }));
679
680
  }
680
681
  newOverGridImage() {
681
682
  const t = this._fWorkbook.getId(), e = this.getSheetId();
682
- return this._injector.createInstance(b, t, e);
683
+ return this._injector.createInstance(p, t, e);
683
684
  }
684
685
  }
685
- $.extend(se);
686
+ N.extend(se);
686
687
  class oe extends M {
687
688
  get DrawingType() {
688
689
  return _;
@@ -695,7 +696,7 @@ class oe extends M {
695
696
  }
696
697
  }
697
698
  M.extend(oe);
698
- class ae extends z {
699
+ class ae extends H {
699
700
  get BeforeOverGridImageChange() {
700
701
  return "BeforeOverGridImageChange";
701
702
  }
@@ -721,156 +722,135 @@ class ae extends z {
721
722
  return "OverGridImageSelected";
722
723
  }
723
724
  }
724
- z.extend(ae);
725
- class ce extends N {
725
+ H.extend(ae);
726
+ class de extends z {
726
727
  /**
727
728
  * @ignore
728
729
  */
730
+ // eslint-disable-next-line max-lines-per-function
729
731
  _initialize(t) {
730
732
  const e = t.get(W);
731
- this.disposeWithMe(e.beforeCommandExecuted((i) => {
732
- switch (i.id) {
733
- case S.id:
734
- this._beforeOverGridImageInsert(i.params);
735
- break;
736
- case D.id:
737
- this._beforeOverGridImageRemove(i.params);
738
- break;
739
- case m.id:
740
- this._beforeOverGridImageChange(i.params);
741
- break;
742
- case A.id:
743
- this._beforeOverGridImageSelect(i.params);
744
- break;
745
- }
746
- })), this.disposeWithMe(e.onCommandExecuted((i) => {
747
- switch (i.id) {
748
- case S.id:
749
- this._overGridImageInserted(i.params);
750
- break;
751
- case D.id:
752
- this._overGridImageRemoved(i.params);
753
- break;
754
- case m.id:
755
- this._overGridImageChanged(i.params);
756
- break;
757
- case A.id:
758
- this._overGridImageSelected(i.params);
759
- break;
760
- }
761
- }));
762
- }
763
- _beforeOverGridImageInsert(t) {
764
- if (!this.hasEventCallback(this.Event.BeforeOverGridImageInsert))
765
- return;
766
- const e = this.getActiveWorkbook();
767
- if (e == null || t == null)
768
- return;
769
- const { drawings: i } = t, n = {
770
- workbook: e,
771
- insertImageParams: i
772
- };
773
- if (this.fireEvent(this.Event.BeforeOverGridImageInsert, n), n.cancel)
774
- throw new Error("Canceled by BeforeOverGridImageInsert event");
775
- }
776
- _overGridImageInserted(t) {
777
- if (!this.hasEventCallback(this.Event.OverGridImageInserted))
778
- return;
779
- const e = this.getActiveWorkbook();
780
- if (e == null || t == null)
781
- return;
782
- const { drawings: i } = t;
783
- this.fireEvent(this.Event.OverGridImageInserted, {
784
- workbook: e,
785
- images: this._createFOverGridImage(i)
786
- });
787
- }
788
- _beforeOverGridImageRemove(t) {
789
- if (!this.hasEventCallback(this.Event.BeforeOverGridImageRemove))
790
- return;
791
- const e = this.getActiveWorkbook();
792
- if (e == null || t == null)
793
- return;
794
- const { drawings: i } = t, n = this._injector.get(l), s = i.map((c) => n.getDrawingByParam(c)), o = {
795
- workbook: e,
796
- images: this._createFOverGridImage(s)
797
- };
798
- if (this.fireEvent(this.Event.BeforeOverGridImageRemove, o), o.cancel)
799
- throw new Error("Canceled by BeforeOverGridImageRemove event");
800
- }
801
- _overGridImageRemoved(t) {
802
- if (!this.hasEventCallback(this.Event.OverGridImageRemoved))
803
- return;
804
- const e = this.getActiveWorkbook();
805
- if (e == null || t == null)
806
- return;
807
- const { drawings: i } = t;
808
- this.fireEvent(this.Event.OverGridImageRemoved, {
809
- workbook: e,
810
- removeImageParams: i
811
- });
812
- }
813
- _beforeOverGridImageChange(t) {
814
- if (!this.hasEventCallback(this.Event.BeforeOverGridImageChange))
815
- return;
816
- const e = this.getActiveWorkbook();
817
- if (e == null || t == null)
818
- return;
819
- const { drawings: i } = t, n = this._injector.get(l), s = [];
820
- i.forEach((c) => {
821
- const a = n.getDrawingByParam(c);
822
- a != null && s.push({
823
- changeParam: c,
824
- image: this._injector.createInstance(g, a)
825
- });
826
- });
827
- const o = {
828
- workbook: e,
829
- images: s
830
- };
831
- if (this.fireEvent(this.Event.BeforeOverGridImageChange, o), o.cancel)
832
- throw n.updateNotification(i), new Error("Canceled by BeforeOverGridImageChange event");
833
- }
834
- _overGridImageChanged(t) {
835
- if (!this.hasEventCallback(this.Event.OverGridImageChanged))
836
- return;
837
- const e = this.getActiveWorkbook();
838
- if (e == null || t == null)
839
- return;
840
- const { drawings: i } = t, n = this._injector.get(l), s = i.map((o) => this._injector.createInstance(g, n.getDrawingByParam(o)));
841
- this.fireEvent(this.Event.OverGridImageChanged, {
842
- workbook: e,
843
- images: s
844
- });
845
- }
846
- _beforeOverGridImageSelect(t) {
847
- if (!this.hasEventCallback(this.Event.BeforeOverGridImageSelect))
848
- return;
849
- const e = this._injector.get(l), i = this.getActiveWorkbook();
850
- if (i == null)
851
- return;
852
- const n = e.getFocusDrawings(), s = t.map((c) => e.getDrawingByParam(c)), o = {
853
- workbook: i,
854
- selectedImages: this._createFOverGridImage(s),
855
- oldSelectedImages: this._createFOverGridImage(n)
856
- };
857
- if (this.fireEvent(this.Event.BeforeOverGridImageSelect, o), o.cancel)
858
- throw new Error("Canceled by BeforeOverGridImageSelect event");
859
- }
860
- _overGridImageSelected(t) {
861
- if (!this.hasEventCallback(this.Event.OverGridImageSelected))
862
- return;
863
- const e = this.getActiveWorkbook(), i = this._injector.get(l);
864
- if (e == null)
865
- return;
866
- const n = t.map((s) => i.getDrawingByParam(s));
867
- this.fireEvent(this.Event.OverGridImageSelected, {
868
- workbook: e,
869
- selectedImages: this._createFOverGridImage(n)
870
- });
733
+ this.registerEventHandler(
734
+ this.Event.BeforeOverGridImageInsert,
735
+ () => e.beforeCommandExecuted((i) => {
736
+ if (i.id !== S.id) return;
737
+ const n = i.params, s = this.getActiveWorkbook();
738
+ if (s == null || n == null)
739
+ return;
740
+ const { drawings: o } = n, d = {
741
+ workbook: s,
742
+ insertImageParams: o
743
+ };
744
+ if (this.fireEvent(this.Event.BeforeOverGridImageInsert, d), d.cancel)
745
+ throw new Error("Canceled by BeforeOverGridImageInsert event");
746
+ })
747
+ ), this.registerEventHandler(
748
+ this.Event.BeforeOverGridImageRemove,
749
+ () => e.beforeCommandExecuted((i) => {
750
+ if (i.id !== R.id) return;
751
+ const n = i.params, s = this.getActiveWorkbook();
752
+ if (s == null || n == null)
753
+ return;
754
+ const o = t.get(f), { drawings: d } = n, a = d.map((c) => o.getDrawingByParam(c)), g = {
755
+ workbook: s,
756
+ images: this._createFOverGridImage(a)
757
+ };
758
+ if (this.fireEvent(this.Event.BeforeOverGridImageRemove, g), g.cancel)
759
+ throw new Error("Canceled by BeforeOverGridImageRemove event");
760
+ })
761
+ ), this.registerEventHandler(
762
+ this.Event.BeforeOverGridImageChange,
763
+ () => e.beforeCommandExecuted((i) => {
764
+ if (i.id !== h.id) return;
765
+ const n = i.params, s = this.getActiveWorkbook();
766
+ if (s == null || n == null)
767
+ return;
768
+ const { drawings: o } = n, d = t.get(f), a = [];
769
+ o.forEach((c) => {
770
+ const u = d.getDrawingByParam(c);
771
+ u != null && a.push({
772
+ changeParam: c,
773
+ image: this._injector.createInstance(m, u)
774
+ });
775
+ });
776
+ const g = {
777
+ workbook: s,
778
+ images: a
779
+ };
780
+ if (this.fireEvent(this.Event.BeforeOverGridImageChange, g), g.cancel)
781
+ throw d.updateNotification(o), new Error("Canceled by BeforeOverGridImageChange event");
782
+ })
783
+ ), this.registerEventHandler(
784
+ this.Event.BeforeOverGridImageSelect,
785
+ () => e.beforeCommandExecuted((i) => {
786
+ if (i.id !== A.id) return;
787
+ const n = i.params, s = this.getActiveWorkbook();
788
+ if (s == null)
789
+ return;
790
+ const o = t.get(f), d = o.getFocusDrawings(), a = n.map((c) => o.getDrawingByParam(c)), g = {
791
+ workbook: s,
792
+ selectedImages: this._createFOverGridImage(a),
793
+ oldSelectedImages: this._createFOverGridImage(d)
794
+ };
795
+ if (this.fireEvent(this.Event.BeforeOverGridImageSelect, g), g.cancel)
796
+ throw new Error("Canceled by BeforeOverGridImageSelect event");
797
+ })
798
+ ), this.registerEventHandler(
799
+ this.Event.OverGridImageInserted,
800
+ () => e.onCommandExecuted((i) => {
801
+ if (i.id !== S.id) return;
802
+ const n = i.params, s = this.getActiveWorkbook();
803
+ if (s == null || n == null)
804
+ return;
805
+ const { drawings: o } = n;
806
+ this.fireEvent(this.Event.OverGridImageInserted, {
807
+ workbook: s,
808
+ images: this._createFOverGridImage(o)
809
+ });
810
+ })
811
+ ), this.registerEventHandler(
812
+ this.Event.OverGridImageRemoved,
813
+ () => e.onCommandExecuted((i) => {
814
+ if (i.id !== R.id) return;
815
+ const n = i.params, s = this.getActiveWorkbook();
816
+ if (s == null || n == null)
817
+ return;
818
+ const { drawings: o } = n;
819
+ this.fireEvent(this.Event.OverGridImageRemoved, {
820
+ workbook: s,
821
+ removeImageParams: o
822
+ });
823
+ })
824
+ ), this.registerEventHandler(
825
+ this.Event.OverGridImageChanged,
826
+ () => e.onCommandExecuted((i) => {
827
+ if (i.id !== h.id) return;
828
+ const n = i.params, s = this.getActiveWorkbook();
829
+ if (s == null || n == null)
830
+ return;
831
+ const { drawings: o } = n, d = t.get(f), a = o.map((g) => this._injector.createInstance(m, d.getDrawingByParam(g)));
832
+ this.fireEvent(this.Event.OverGridImageChanged, {
833
+ workbook: s,
834
+ images: a
835
+ });
836
+ })
837
+ ), this.registerEventHandler(
838
+ this.Event.OverGridImageSelected,
839
+ () => e.onCommandExecuted((i) => {
840
+ if (i.id !== A.id) return;
841
+ const n = i.params, s = this.getActiveWorkbook();
842
+ if (s == null)
843
+ return;
844
+ const o = t.get(f), d = n.map((a) => o.getDrawingByParam(a));
845
+ this.fireEvent(this.Event.OverGridImageSelected, {
846
+ workbook: s,
847
+ selectedImages: this._createFOverGridImage(d)
848
+ });
849
+ })
850
+ );
871
851
  }
872
852
  _createFOverGridImage(t) {
873
- return t.map((e) => this._injector.createInstance(g, e));
853
+ return t.map((e) => this._injector.createInstance(m, e));
874
854
  }
875
855
  }
876
- N.extend(ce);
856
+ z.extend(de);