microboard-temp 0.4.103 → 0.4.104

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.
@@ -7066,7 +7066,8 @@ var conf = {
7066
7066
  FALLBACK_LNG: "en",
7067
7067
  cursorsMap,
7068
7068
  DECK_HORIZONTAL_OFFSET: 2,
7069
- DECK_VERTICAL_OFFSET: 0
7069
+ DECK_VERTICAL_OFFSET: 0,
7070
+ CARD_DIMENSIONS: { width: 250, height: 400 }
7070
7071
  };
7071
7072
  initDefaultI18N();
7072
7073
 
@@ -21490,6 +21491,7 @@ class BaseItem extends Mbr {
21490
21491
  shouldUseRelativeAlignment = true;
21491
21492
  enableResize = true;
21492
21493
  itemType = "";
21494
+ children = [];
21493
21495
  constructor(board, id = "", defaultItemData, isGroupItem) {
21494
21496
  super();
21495
21497
  this.defaultItemData = defaultItemData;
@@ -21507,6 +21509,9 @@ class BaseItem extends Mbr {
21507
21509
  this.linkTo = new LinkTo(this.id, board.events);
21508
21510
  this.transformation = new Transformation(this.id, board.events);
21509
21511
  }
21512
+ updateChildrenIds() {
21513
+ this.children = this.index?.items.listAll().map((item) => item.getId()) || [];
21514
+ }
21510
21515
  getId() {
21511
21516
  return this.id;
21512
21517
  }
@@ -21592,6 +21597,7 @@ class BaseItem extends Mbr {
21592
21597
  }
21593
21598
  }
21594
21599
  });
21600
+ this.updateChildrenIds();
21595
21601
  this.updateMbr();
21596
21602
  this.subject.publish(this);
21597
21603
  }
@@ -21609,6 +21615,7 @@ class BaseItem extends Mbr {
21609
21615
  }
21610
21616
  }
21611
21617
  });
21618
+ this.updateChildrenIds();
21612
21619
  this.updateMbr();
21613
21620
  this.subject.publish(this);
21614
21621
  }
@@ -47824,7 +47831,6 @@ var defaultCardData = {
47824
47831
  faceUrl: "",
47825
47832
  backsideUrl: ""
47826
47833
  };
47827
- var CARD_DIMENSIONS = { width: 250, height: 400 };
47828
47834
 
47829
47835
  class Card extends BaseItem {
47830
47836
  subject = new Subject;
@@ -47885,7 +47891,7 @@ class Card extends BaseItem {
47885
47891
  const ctx = context.ctx;
47886
47892
  if (this.imageToRender && this.imageToRender.complete) {
47887
47893
  ctx.save();
47888
- ctx.drawImage(this.imageToRender, typeof left === "number" ? left : this.left, typeof top === "number" ? top : this.top, CARD_DIMENSIONS.width, CARD_DIMENSIONS.height);
47894
+ ctx.drawImage(this.imageToRender, typeof left === "number" ? left : this.left, typeof top === "number" ? top : this.top, conf.CARD_DIMENSIONS.width, conf.CARD_DIMENSIONS.height);
47889
47895
  ctx.restore();
47890
47896
  }
47891
47897
  }
@@ -47893,8 +47899,8 @@ class Card extends BaseItem {
47893
47899
  const { translateX, translateY, scaleX, scaleY } = this.transformation.matrix;
47894
47900
  this.left = translateX;
47895
47901
  this.top = translateY;
47896
- this.right = this.left + CARD_DIMENSIONS.width * scaleX;
47897
- this.bottom = this.top + CARD_DIMENSIONS.height * scaleY;
47902
+ this.right = this.left + conf.CARD_DIMENSIONS.width * scaleX;
47903
+ this.bottom = this.top + conf.CARD_DIMENSIONS.height * scaleY;
47898
47904
  }
47899
47905
  getPath() {
47900
47906
  return new Path(this.getMbr().getLines());
@@ -47945,6 +47951,7 @@ class Deck extends BaseItem {
47945
47951
  cachedCanvas = null;
47946
47952
  isCacheDirty = true;
47947
47953
  enableResize = false;
47954
+ path = new Path;
47948
47955
  constructor(board, id = "") {
47949
47956
  super(board, id, defaultDeckData, true);
47950
47957
  this.index.getUnderPoint = () => [];
@@ -47978,6 +47985,7 @@ class Deck extends BaseItem {
47978
47985
  }
47979
47986
  }
47980
47987
  });
47988
+ this.updateChildrenIds();
47981
47989
  this.updateMbr();
47982
47990
  this.subject.publish(this);
47983
47991
  }
@@ -47996,6 +48004,7 @@ class Deck extends BaseItem {
47996
48004
  }
47997
48005
  }
47998
48006
  });
48007
+ this.updateChildrenIds();
47999
48008
  this.updateMbr();
48000
48009
  this.subject.publish(this);
48001
48010
  }
@@ -48045,14 +48054,18 @@ class Deck extends BaseItem {
48045
48054
  updateMbr() {
48046
48055
  const { translateX, translateY } = this.transformation.matrix;
48047
48056
  const items = this.index.list();
48048
- const itemsMbr = items[0]?.getMbr().combine(items.slice(1).map((item) => item.getMbr()));
48057
+ const itemsMbr = items[0].getMbr().combine(items.slice(1).map((item) => item.getMbr()));
48049
48058
  this.left = translateX;
48050
48059
  this.top = translateY;
48051
- this.right = translateX + (itemsMbr?.getWidth() || 0);
48052
- this.bottom = translateY + (itemsMbr?.getHeight() || 0);
48060
+ this.right = translateX + (itemsMbr?.getWidth() || conf.CARD_DIMENSIONS.width + conf.DECK_HORIZONTAL_OFFSET * ((this.children.length || 1) - 1));
48061
+ this.bottom = translateY + (itemsMbr?.getHeight() || conf.CARD_DIMENSIONS.height - conf.DECK_VERTICAL_OFFSET * ((this.children.length || 1) - 1));
48062
+ this.path = new Path(this.getMbr().getLines(), true, "#FFFFFF");
48053
48063
  }
48054
48064
  deserialize(data) {
48055
48065
  super.deserialize(data);
48066
+ if (data.children) {
48067
+ this.children = data.children;
48068
+ }
48056
48069
  this.updateMbr();
48057
48070
  this.subject.publish(this);
48058
48071
  return this;
@@ -48064,6 +48077,7 @@ class Deck extends BaseItem {
48064
48077
  const ctx = context.ctx;
48065
48078
  if (this.isCacheDirty || !this.cachedCanvas) {
48066
48079
  this.updateCache(context);
48080
+ this.path.render(context);
48067
48081
  }
48068
48082
  if (this.cachedCanvas && this.cachedCanvas.width && this.cachedCanvas.height) {
48069
48083
  ctx.save();
package/dist/cjs/index.js CHANGED
@@ -7066,7 +7066,8 @@ var conf = {
7066
7066
  FALLBACK_LNG: "en",
7067
7067
  cursorsMap,
7068
7068
  DECK_HORIZONTAL_OFFSET: 2,
7069
- DECK_VERTICAL_OFFSET: 0
7069
+ DECK_VERTICAL_OFFSET: 0,
7070
+ CARD_DIMENSIONS: { width: 250, height: 400 }
7070
7071
  };
7071
7072
  initDefaultI18N();
7072
7073
 
@@ -21490,6 +21491,7 @@ class BaseItem extends Mbr {
21490
21491
  shouldUseRelativeAlignment = true;
21491
21492
  enableResize = true;
21492
21493
  itemType = "";
21494
+ children = [];
21493
21495
  constructor(board, id = "", defaultItemData, isGroupItem) {
21494
21496
  super();
21495
21497
  this.defaultItemData = defaultItemData;
@@ -21507,6 +21509,9 @@ class BaseItem extends Mbr {
21507
21509
  this.linkTo = new LinkTo(this.id, board.events);
21508
21510
  this.transformation = new Transformation(this.id, board.events);
21509
21511
  }
21512
+ updateChildrenIds() {
21513
+ this.children = this.index?.items.listAll().map((item) => item.getId()) || [];
21514
+ }
21510
21515
  getId() {
21511
21516
  return this.id;
21512
21517
  }
@@ -21592,6 +21597,7 @@ class BaseItem extends Mbr {
21592
21597
  }
21593
21598
  }
21594
21599
  });
21600
+ this.updateChildrenIds();
21595
21601
  this.updateMbr();
21596
21602
  this.subject.publish(this);
21597
21603
  }
@@ -21609,6 +21615,7 @@ class BaseItem extends Mbr {
21609
21615
  }
21610
21616
  }
21611
21617
  });
21618
+ this.updateChildrenIds();
21612
21619
  this.updateMbr();
21613
21620
  this.subject.publish(this);
21614
21621
  }
@@ -47824,7 +47831,6 @@ var defaultCardData = {
47824
47831
  faceUrl: "",
47825
47832
  backsideUrl: ""
47826
47833
  };
47827
- var CARD_DIMENSIONS = { width: 250, height: 400 };
47828
47834
 
47829
47835
  class Card extends BaseItem {
47830
47836
  subject = new Subject;
@@ -47885,7 +47891,7 @@ class Card extends BaseItem {
47885
47891
  const ctx = context.ctx;
47886
47892
  if (this.imageToRender && this.imageToRender.complete) {
47887
47893
  ctx.save();
47888
- ctx.drawImage(this.imageToRender, typeof left === "number" ? left : this.left, typeof top === "number" ? top : this.top, CARD_DIMENSIONS.width, CARD_DIMENSIONS.height);
47894
+ ctx.drawImage(this.imageToRender, typeof left === "number" ? left : this.left, typeof top === "number" ? top : this.top, conf.CARD_DIMENSIONS.width, conf.CARD_DIMENSIONS.height);
47889
47895
  ctx.restore();
47890
47896
  }
47891
47897
  }
@@ -47893,8 +47899,8 @@ class Card extends BaseItem {
47893
47899
  const { translateX, translateY, scaleX, scaleY } = this.transformation.matrix;
47894
47900
  this.left = translateX;
47895
47901
  this.top = translateY;
47896
- this.right = this.left + CARD_DIMENSIONS.width * scaleX;
47897
- this.bottom = this.top + CARD_DIMENSIONS.height * scaleY;
47902
+ this.right = this.left + conf.CARD_DIMENSIONS.width * scaleX;
47903
+ this.bottom = this.top + conf.CARD_DIMENSIONS.height * scaleY;
47898
47904
  }
47899
47905
  getPath() {
47900
47906
  return new Path(this.getMbr().getLines());
@@ -47945,6 +47951,7 @@ class Deck extends BaseItem {
47945
47951
  cachedCanvas = null;
47946
47952
  isCacheDirty = true;
47947
47953
  enableResize = false;
47954
+ path = new Path;
47948
47955
  constructor(board, id = "") {
47949
47956
  super(board, id, defaultDeckData, true);
47950
47957
  this.index.getUnderPoint = () => [];
@@ -47978,6 +47985,7 @@ class Deck extends BaseItem {
47978
47985
  }
47979
47986
  }
47980
47987
  });
47988
+ this.updateChildrenIds();
47981
47989
  this.updateMbr();
47982
47990
  this.subject.publish(this);
47983
47991
  }
@@ -47996,6 +48004,7 @@ class Deck extends BaseItem {
47996
48004
  }
47997
48005
  }
47998
48006
  });
48007
+ this.updateChildrenIds();
47999
48008
  this.updateMbr();
48000
48009
  this.subject.publish(this);
48001
48010
  }
@@ -48045,14 +48054,18 @@ class Deck extends BaseItem {
48045
48054
  updateMbr() {
48046
48055
  const { translateX, translateY } = this.transformation.matrix;
48047
48056
  const items = this.index.list();
48048
- const itemsMbr = items[0]?.getMbr().combine(items.slice(1).map((item) => item.getMbr()));
48057
+ const itemsMbr = items[0].getMbr().combine(items.slice(1).map((item) => item.getMbr()));
48049
48058
  this.left = translateX;
48050
48059
  this.top = translateY;
48051
- this.right = translateX + (itemsMbr?.getWidth() || 0);
48052
- this.bottom = translateY + (itemsMbr?.getHeight() || 0);
48060
+ this.right = translateX + (itemsMbr?.getWidth() || conf.CARD_DIMENSIONS.width + conf.DECK_HORIZONTAL_OFFSET * ((this.children.length || 1) - 1));
48061
+ this.bottom = translateY + (itemsMbr?.getHeight() || conf.CARD_DIMENSIONS.height - conf.DECK_VERTICAL_OFFSET * ((this.children.length || 1) - 1));
48062
+ this.path = new Path(this.getMbr().getLines(), true, "#FFFFFF");
48053
48063
  }
48054
48064
  deserialize(data) {
48055
48065
  super.deserialize(data);
48066
+ if (data.children) {
48067
+ this.children = data.children;
48068
+ }
48056
48069
  this.updateMbr();
48057
48070
  this.subject.publish(this);
48058
48071
  return this;
@@ -48064,6 +48077,7 @@ class Deck extends BaseItem {
48064
48077
  const ctx = context.ctx;
48065
48078
  if (this.isCacheDirty || !this.cachedCanvas) {
48066
48079
  this.updateCache(context);
48080
+ this.path.render(context);
48067
48081
  }
48068
48082
  if (this.cachedCanvas && this.cachedCanvas.width && this.cachedCanvas.height) {
48069
48083
  ctx.save();
package/dist/cjs/node.js CHANGED
@@ -8103,7 +8103,8 @@ var conf = {
8103
8103
  FALLBACK_LNG: "en",
8104
8104
  cursorsMap,
8105
8105
  DECK_HORIZONTAL_OFFSET: 2,
8106
- DECK_VERTICAL_OFFSET: 0
8106
+ DECK_VERTICAL_OFFSET: 0,
8107
+ CARD_DIMENSIONS: { width: 250, height: 400 }
8107
8108
  };
8108
8109
  initDefaultI18N();
8109
8110
 
@@ -23962,6 +23963,7 @@ class BaseItem extends Mbr {
23962
23963
  shouldUseRelativeAlignment = true;
23963
23964
  enableResize = true;
23964
23965
  itemType = "";
23966
+ children = [];
23965
23967
  constructor(board, id = "", defaultItemData, isGroupItem) {
23966
23968
  super();
23967
23969
  this.defaultItemData = defaultItemData;
@@ -23979,6 +23981,9 @@ class BaseItem extends Mbr {
23979
23981
  this.linkTo = new LinkTo(this.id, board.events);
23980
23982
  this.transformation = new Transformation(this.id, board.events);
23981
23983
  }
23984
+ updateChildrenIds() {
23985
+ this.children = this.index?.items.listAll().map((item) => item.getId()) || [];
23986
+ }
23982
23987
  getId() {
23983
23988
  return this.id;
23984
23989
  }
@@ -24064,6 +24069,7 @@ class BaseItem extends Mbr {
24064
24069
  }
24065
24070
  }
24066
24071
  });
24072
+ this.updateChildrenIds();
24067
24073
  this.updateMbr();
24068
24074
  this.subject.publish(this);
24069
24075
  }
@@ -24081,6 +24087,7 @@ class BaseItem extends Mbr {
24081
24087
  }
24082
24088
  }
24083
24089
  });
24090
+ this.updateChildrenIds();
24084
24091
  this.updateMbr();
24085
24092
  this.subject.publish(this);
24086
24093
  }
@@ -50297,7 +50304,6 @@ var defaultCardData = {
50297
50304
  faceUrl: "",
50298
50305
  backsideUrl: ""
50299
50306
  };
50300
- var CARD_DIMENSIONS = { width: 250, height: 400 };
50301
50307
 
50302
50308
  class Card extends BaseItem {
50303
50309
  subject = new Subject;
@@ -50358,7 +50364,7 @@ class Card extends BaseItem {
50358
50364
  const ctx = context.ctx;
50359
50365
  if (this.imageToRender && this.imageToRender.complete) {
50360
50366
  ctx.save();
50361
- ctx.drawImage(this.imageToRender, typeof left === "number" ? left : this.left, typeof top === "number" ? top : this.top, CARD_DIMENSIONS.width, CARD_DIMENSIONS.height);
50367
+ ctx.drawImage(this.imageToRender, typeof left === "number" ? left : this.left, typeof top === "number" ? top : this.top, conf.CARD_DIMENSIONS.width, conf.CARD_DIMENSIONS.height);
50362
50368
  ctx.restore();
50363
50369
  }
50364
50370
  }
@@ -50366,8 +50372,8 @@ class Card extends BaseItem {
50366
50372
  const { translateX, translateY, scaleX, scaleY } = this.transformation.matrix;
50367
50373
  this.left = translateX;
50368
50374
  this.top = translateY;
50369
- this.right = this.left + CARD_DIMENSIONS.width * scaleX;
50370
- this.bottom = this.top + CARD_DIMENSIONS.height * scaleY;
50375
+ this.right = this.left + conf.CARD_DIMENSIONS.width * scaleX;
50376
+ this.bottom = this.top + conf.CARD_DIMENSIONS.height * scaleY;
50371
50377
  }
50372
50378
  getPath() {
50373
50379
  return new Path(this.getMbr().getLines());
@@ -50418,6 +50424,7 @@ class Deck extends BaseItem {
50418
50424
  cachedCanvas = null;
50419
50425
  isCacheDirty = true;
50420
50426
  enableResize = false;
50427
+ path = new Path;
50421
50428
  constructor(board, id = "") {
50422
50429
  super(board, id, defaultDeckData, true);
50423
50430
  this.index.getUnderPoint = () => [];
@@ -50451,6 +50458,7 @@ class Deck extends BaseItem {
50451
50458
  }
50452
50459
  }
50453
50460
  });
50461
+ this.updateChildrenIds();
50454
50462
  this.updateMbr();
50455
50463
  this.subject.publish(this);
50456
50464
  }
@@ -50469,6 +50477,7 @@ class Deck extends BaseItem {
50469
50477
  }
50470
50478
  }
50471
50479
  });
50480
+ this.updateChildrenIds();
50472
50481
  this.updateMbr();
50473
50482
  this.subject.publish(this);
50474
50483
  }
@@ -50518,14 +50527,18 @@ class Deck extends BaseItem {
50518
50527
  updateMbr() {
50519
50528
  const { translateX, translateY } = this.transformation.matrix;
50520
50529
  const items = this.index.list();
50521
- const itemsMbr = items[0]?.getMbr().combine(items.slice(1).map((item) => item.getMbr()));
50530
+ const itemsMbr = items[0].getMbr().combine(items.slice(1).map((item) => item.getMbr()));
50522
50531
  this.left = translateX;
50523
50532
  this.top = translateY;
50524
- this.right = translateX + (itemsMbr?.getWidth() || 0);
50525
- this.bottom = translateY + (itemsMbr?.getHeight() || 0);
50533
+ this.right = translateX + (itemsMbr?.getWidth() || conf.CARD_DIMENSIONS.width + conf.DECK_HORIZONTAL_OFFSET * ((this.children.length || 1) - 1));
50534
+ this.bottom = translateY + (itemsMbr?.getHeight() || conf.CARD_DIMENSIONS.height - conf.DECK_VERTICAL_OFFSET * ((this.children.length || 1) - 1));
50535
+ this.path = new Path(this.getMbr().getLines(), true, "#FFFFFF");
50526
50536
  }
50527
50537
  deserialize(data) {
50528
50538
  super.deserialize(data);
50539
+ if (data.children) {
50540
+ this.children = data.children;
50541
+ }
50529
50542
  this.updateMbr();
50530
50543
  this.subject.publish(this);
50531
50544
  return this;
@@ -50537,6 +50550,7 @@ class Deck extends BaseItem {
50537
50550
  const ctx = context.ctx;
50538
50551
  if (this.isCacheDirty || !this.cachedCanvas) {
50539
50552
  this.updateCache(context);
50553
+ this.path.render(context);
50540
50554
  }
50541
50555
  if (this.cachedCanvas && this.cachedCanvas.width && this.cachedCanvas.height) {
50542
50556
  ctx.save();
@@ -6906,7 +6906,8 @@ var conf = {
6906
6906
  FALLBACK_LNG: "en",
6907
6907
  cursorsMap,
6908
6908
  DECK_HORIZONTAL_OFFSET: 2,
6909
- DECK_VERTICAL_OFFSET: 0
6909
+ DECK_VERTICAL_OFFSET: 0,
6910
+ CARD_DIMENSIONS: { width: 250, height: 400 }
6910
6911
  };
6911
6912
  initDefaultI18N();
6912
6913
 
@@ -21339,6 +21340,7 @@ class BaseItem extends Mbr {
21339
21340
  shouldUseRelativeAlignment = true;
21340
21341
  enableResize = true;
21341
21342
  itemType = "";
21343
+ children = [];
21342
21344
  constructor(board, id = "", defaultItemData, isGroupItem) {
21343
21345
  super();
21344
21346
  this.defaultItemData = defaultItemData;
@@ -21356,6 +21358,9 @@ class BaseItem extends Mbr {
21356
21358
  this.linkTo = new LinkTo(this.id, board.events);
21357
21359
  this.transformation = new Transformation(this.id, board.events);
21358
21360
  }
21361
+ updateChildrenIds() {
21362
+ this.children = this.index?.items.listAll().map((item) => item.getId()) || [];
21363
+ }
21359
21364
  getId() {
21360
21365
  return this.id;
21361
21366
  }
@@ -21441,6 +21446,7 @@ class BaseItem extends Mbr {
21441
21446
  }
21442
21447
  }
21443
21448
  });
21449
+ this.updateChildrenIds();
21444
21450
  this.updateMbr();
21445
21451
  this.subject.publish(this);
21446
21452
  }
@@ -21458,6 +21464,7 @@ class BaseItem extends Mbr {
21458
21464
  }
21459
21465
  }
21460
21466
  });
21467
+ this.updateChildrenIds();
21461
21468
  this.updateMbr();
21462
21469
  this.subject.publish(this);
21463
21470
  }
@@ -47673,7 +47680,6 @@ var defaultCardData = {
47673
47680
  faceUrl: "",
47674
47681
  backsideUrl: ""
47675
47682
  };
47676
- var CARD_DIMENSIONS = { width: 250, height: 400 };
47677
47683
 
47678
47684
  class Card extends BaseItem {
47679
47685
  subject = new Subject;
@@ -47734,7 +47740,7 @@ class Card extends BaseItem {
47734
47740
  const ctx = context.ctx;
47735
47741
  if (this.imageToRender && this.imageToRender.complete) {
47736
47742
  ctx.save();
47737
- ctx.drawImage(this.imageToRender, typeof left === "number" ? left : this.left, typeof top === "number" ? top : this.top, CARD_DIMENSIONS.width, CARD_DIMENSIONS.height);
47743
+ ctx.drawImage(this.imageToRender, typeof left === "number" ? left : this.left, typeof top === "number" ? top : this.top, conf.CARD_DIMENSIONS.width, conf.CARD_DIMENSIONS.height);
47738
47744
  ctx.restore();
47739
47745
  }
47740
47746
  }
@@ -47742,8 +47748,8 @@ class Card extends BaseItem {
47742
47748
  const { translateX, translateY, scaleX, scaleY } = this.transformation.matrix;
47743
47749
  this.left = translateX;
47744
47750
  this.top = translateY;
47745
- this.right = this.left + CARD_DIMENSIONS.width * scaleX;
47746
- this.bottom = this.top + CARD_DIMENSIONS.height * scaleY;
47751
+ this.right = this.left + conf.CARD_DIMENSIONS.width * scaleX;
47752
+ this.bottom = this.top + conf.CARD_DIMENSIONS.height * scaleY;
47747
47753
  }
47748
47754
  getPath() {
47749
47755
  return new Path(this.getMbr().getLines());
@@ -47794,6 +47800,7 @@ class Deck extends BaseItem {
47794
47800
  cachedCanvas = null;
47795
47801
  isCacheDirty = true;
47796
47802
  enableResize = false;
47803
+ path = new Path;
47797
47804
  constructor(board, id = "") {
47798
47805
  super(board, id, defaultDeckData, true);
47799
47806
  this.index.getUnderPoint = () => [];
@@ -47827,6 +47834,7 @@ class Deck extends BaseItem {
47827
47834
  }
47828
47835
  }
47829
47836
  });
47837
+ this.updateChildrenIds();
47830
47838
  this.updateMbr();
47831
47839
  this.subject.publish(this);
47832
47840
  }
@@ -47845,6 +47853,7 @@ class Deck extends BaseItem {
47845
47853
  }
47846
47854
  }
47847
47855
  });
47856
+ this.updateChildrenIds();
47848
47857
  this.updateMbr();
47849
47858
  this.subject.publish(this);
47850
47859
  }
@@ -47894,14 +47903,18 @@ class Deck extends BaseItem {
47894
47903
  updateMbr() {
47895
47904
  const { translateX, translateY } = this.transformation.matrix;
47896
47905
  const items = this.index.list();
47897
- const itemsMbr = items[0]?.getMbr().combine(items.slice(1).map((item) => item.getMbr()));
47906
+ const itemsMbr = items[0].getMbr().combine(items.slice(1).map((item) => item.getMbr()));
47898
47907
  this.left = translateX;
47899
47908
  this.top = translateY;
47900
- this.right = translateX + (itemsMbr?.getWidth() || 0);
47901
- this.bottom = translateY + (itemsMbr?.getHeight() || 0);
47909
+ this.right = translateX + (itemsMbr?.getWidth() || conf.CARD_DIMENSIONS.width + conf.DECK_HORIZONTAL_OFFSET * ((this.children.length || 1) - 1));
47910
+ this.bottom = translateY + (itemsMbr?.getHeight() || conf.CARD_DIMENSIONS.height - conf.DECK_VERTICAL_OFFSET * ((this.children.length || 1) - 1));
47911
+ this.path = new Path(this.getMbr().getLines(), true, "#FFFFFF");
47902
47912
  }
47903
47913
  deserialize(data) {
47904
47914
  super.deserialize(data);
47915
+ if (data.children) {
47916
+ this.children = data.children;
47917
+ }
47905
47918
  this.updateMbr();
47906
47919
  this.subject.publish(this);
47907
47920
  return this;
@@ -47913,6 +47926,7 @@ class Deck extends BaseItem {
47913
47926
  const ctx = context.ctx;
47914
47927
  if (this.isCacheDirty || !this.cachedCanvas) {
47915
47928
  this.updateCache(context);
47929
+ this.path.render(context);
47916
47930
  }
47917
47931
  if (this.cachedCanvas && this.cachedCanvas.width && this.cachedCanvas.height) {
47918
47932
  ctx.save();
package/dist/esm/index.js CHANGED
@@ -6899,7 +6899,8 @@ var conf = {
6899
6899
  FALLBACK_LNG: "en",
6900
6900
  cursorsMap,
6901
6901
  DECK_HORIZONTAL_OFFSET: 2,
6902
- DECK_VERTICAL_OFFSET: 0
6902
+ DECK_VERTICAL_OFFSET: 0,
6903
+ CARD_DIMENSIONS: { width: 250, height: 400 }
6903
6904
  };
6904
6905
  initDefaultI18N();
6905
6906
 
@@ -21332,6 +21333,7 @@ class BaseItem extends Mbr {
21332
21333
  shouldUseRelativeAlignment = true;
21333
21334
  enableResize = true;
21334
21335
  itemType = "";
21336
+ children = [];
21335
21337
  constructor(board, id = "", defaultItemData, isGroupItem) {
21336
21338
  super();
21337
21339
  this.defaultItemData = defaultItemData;
@@ -21349,6 +21351,9 @@ class BaseItem extends Mbr {
21349
21351
  this.linkTo = new LinkTo(this.id, board.events);
21350
21352
  this.transformation = new Transformation(this.id, board.events);
21351
21353
  }
21354
+ updateChildrenIds() {
21355
+ this.children = this.index?.items.listAll().map((item) => item.getId()) || [];
21356
+ }
21352
21357
  getId() {
21353
21358
  return this.id;
21354
21359
  }
@@ -21434,6 +21439,7 @@ class BaseItem extends Mbr {
21434
21439
  }
21435
21440
  }
21436
21441
  });
21442
+ this.updateChildrenIds();
21437
21443
  this.updateMbr();
21438
21444
  this.subject.publish(this);
21439
21445
  }
@@ -21451,6 +21457,7 @@ class BaseItem extends Mbr {
21451
21457
  }
21452
21458
  }
21453
21459
  });
21460
+ this.updateChildrenIds();
21454
21461
  this.updateMbr();
21455
21462
  this.subject.publish(this);
21456
21463
  }
@@ -47666,7 +47673,6 @@ var defaultCardData = {
47666
47673
  faceUrl: "",
47667
47674
  backsideUrl: ""
47668
47675
  };
47669
- var CARD_DIMENSIONS = { width: 250, height: 400 };
47670
47676
 
47671
47677
  class Card extends BaseItem {
47672
47678
  subject = new Subject;
@@ -47727,7 +47733,7 @@ class Card extends BaseItem {
47727
47733
  const ctx = context.ctx;
47728
47734
  if (this.imageToRender && this.imageToRender.complete) {
47729
47735
  ctx.save();
47730
- ctx.drawImage(this.imageToRender, typeof left === "number" ? left : this.left, typeof top === "number" ? top : this.top, CARD_DIMENSIONS.width, CARD_DIMENSIONS.height);
47736
+ ctx.drawImage(this.imageToRender, typeof left === "number" ? left : this.left, typeof top === "number" ? top : this.top, conf.CARD_DIMENSIONS.width, conf.CARD_DIMENSIONS.height);
47731
47737
  ctx.restore();
47732
47738
  }
47733
47739
  }
@@ -47735,8 +47741,8 @@ class Card extends BaseItem {
47735
47741
  const { translateX, translateY, scaleX, scaleY } = this.transformation.matrix;
47736
47742
  this.left = translateX;
47737
47743
  this.top = translateY;
47738
- this.right = this.left + CARD_DIMENSIONS.width * scaleX;
47739
- this.bottom = this.top + CARD_DIMENSIONS.height * scaleY;
47744
+ this.right = this.left + conf.CARD_DIMENSIONS.width * scaleX;
47745
+ this.bottom = this.top + conf.CARD_DIMENSIONS.height * scaleY;
47740
47746
  }
47741
47747
  getPath() {
47742
47748
  return new Path(this.getMbr().getLines());
@@ -47787,6 +47793,7 @@ class Deck extends BaseItem {
47787
47793
  cachedCanvas = null;
47788
47794
  isCacheDirty = true;
47789
47795
  enableResize = false;
47796
+ path = new Path;
47790
47797
  constructor(board, id = "") {
47791
47798
  super(board, id, defaultDeckData, true);
47792
47799
  this.index.getUnderPoint = () => [];
@@ -47820,6 +47827,7 @@ class Deck extends BaseItem {
47820
47827
  }
47821
47828
  }
47822
47829
  });
47830
+ this.updateChildrenIds();
47823
47831
  this.updateMbr();
47824
47832
  this.subject.publish(this);
47825
47833
  }
@@ -47838,6 +47846,7 @@ class Deck extends BaseItem {
47838
47846
  }
47839
47847
  }
47840
47848
  });
47849
+ this.updateChildrenIds();
47841
47850
  this.updateMbr();
47842
47851
  this.subject.publish(this);
47843
47852
  }
@@ -47887,14 +47896,18 @@ class Deck extends BaseItem {
47887
47896
  updateMbr() {
47888
47897
  const { translateX, translateY } = this.transformation.matrix;
47889
47898
  const items = this.index.list();
47890
- const itemsMbr = items[0]?.getMbr().combine(items.slice(1).map((item) => item.getMbr()));
47899
+ const itemsMbr = items[0].getMbr().combine(items.slice(1).map((item) => item.getMbr()));
47891
47900
  this.left = translateX;
47892
47901
  this.top = translateY;
47893
- this.right = translateX + (itemsMbr?.getWidth() || 0);
47894
- this.bottom = translateY + (itemsMbr?.getHeight() || 0);
47902
+ this.right = translateX + (itemsMbr?.getWidth() || conf.CARD_DIMENSIONS.width + conf.DECK_HORIZONTAL_OFFSET * ((this.children.length || 1) - 1));
47903
+ this.bottom = translateY + (itemsMbr?.getHeight() || conf.CARD_DIMENSIONS.height - conf.DECK_VERTICAL_OFFSET * ((this.children.length || 1) - 1));
47904
+ this.path = new Path(this.getMbr().getLines(), true, "#FFFFFF");
47895
47905
  }
47896
47906
  deserialize(data) {
47897
47907
  super.deserialize(data);
47908
+ if (data.children) {
47909
+ this.children = data.children;
47910
+ }
47898
47911
  this.updateMbr();
47899
47912
  this.subject.publish(this);
47900
47913
  return this;
@@ -47906,6 +47919,7 @@ class Deck extends BaseItem {
47906
47919
  const ctx = context.ctx;
47907
47920
  if (this.isCacheDirty || !this.cachedCanvas) {
47908
47921
  this.updateCache(context);
47922
+ this.path.render(context);
47909
47923
  }
47910
47924
  if (this.cachedCanvas && this.cachedCanvas.width && this.cachedCanvas.height) {
47911
47925
  ctx.save();
package/dist/esm/node.js CHANGED
@@ -7683,7 +7683,8 @@ var conf = {
7683
7683
  FALLBACK_LNG: "en",
7684
7684
  cursorsMap,
7685
7685
  DECK_HORIZONTAL_OFFSET: 2,
7686
- DECK_VERTICAL_OFFSET: 0
7686
+ DECK_VERTICAL_OFFSET: 0,
7687
+ CARD_DIMENSIONS: { width: 250, height: 400 }
7687
7688
  };
7688
7689
  initDefaultI18N();
7689
7690
 
@@ -23799,6 +23800,7 @@ class BaseItem extends Mbr {
23799
23800
  shouldUseRelativeAlignment = true;
23800
23801
  enableResize = true;
23801
23802
  itemType = "";
23803
+ children = [];
23802
23804
  constructor(board, id = "", defaultItemData, isGroupItem) {
23803
23805
  super();
23804
23806
  this.defaultItemData = defaultItemData;
@@ -23816,6 +23818,9 @@ class BaseItem extends Mbr {
23816
23818
  this.linkTo = new LinkTo(this.id, board.events);
23817
23819
  this.transformation = new Transformation(this.id, board.events);
23818
23820
  }
23821
+ updateChildrenIds() {
23822
+ this.children = this.index?.items.listAll().map((item) => item.getId()) || [];
23823
+ }
23819
23824
  getId() {
23820
23825
  return this.id;
23821
23826
  }
@@ -23901,6 +23906,7 @@ class BaseItem extends Mbr {
23901
23906
  }
23902
23907
  }
23903
23908
  });
23909
+ this.updateChildrenIds();
23904
23910
  this.updateMbr();
23905
23911
  this.subject.publish(this);
23906
23912
  }
@@ -23918,6 +23924,7 @@ class BaseItem extends Mbr {
23918
23924
  }
23919
23925
  }
23920
23926
  });
23927
+ this.updateChildrenIds();
23921
23928
  this.updateMbr();
23922
23929
  this.subject.publish(this);
23923
23930
  }
@@ -50134,7 +50141,6 @@ var defaultCardData = {
50134
50141
  faceUrl: "",
50135
50142
  backsideUrl: ""
50136
50143
  };
50137
- var CARD_DIMENSIONS = { width: 250, height: 400 };
50138
50144
 
50139
50145
  class Card extends BaseItem {
50140
50146
  subject = new Subject;
@@ -50195,7 +50201,7 @@ class Card extends BaseItem {
50195
50201
  const ctx = context.ctx;
50196
50202
  if (this.imageToRender && this.imageToRender.complete) {
50197
50203
  ctx.save();
50198
- ctx.drawImage(this.imageToRender, typeof left === "number" ? left : this.left, typeof top === "number" ? top : this.top, CARD_DIMENSIONS.width, CARD_DIMENSIONS.height);
50204
+ ctx.drawImage(this.imageToRender, typeof left === "number" ? left : this.left, typeof top === "number" ? top : this.top, conf.CARD_DIMENSIONS.width, conf.CARD_DIMENSIONS.height);
50199
50205
  ctx.restore();
50200
50206
  }
50201
50207
  }
@@ -50203,8 +50209,8 @@ class Card extends BaseItem {
50203
50209
  const { translateX, translateY, scaleX, scaleY } = this.transformation.matrix;
50204
50210
  this.left = translateX;
50205
50211
  this.top = translateY;
50206
- this.right = this.left + CARD_DIMENSIONS.width * scaleX;
50207
- this.bottom = this.top + CARD_DIMENSIONS.height * scaleY;
50212
+ this.right = this.left + conf.CARD_DIMENSIONS.width * scaleX;
50213
+ this.bottom = this.top + conf.CARD_DIMENSIONS.height * scaleY;
50208
50214
  }
50209
50215
  getPath() {
50210
50216
  return new Path(this.getMbr().getLines());
@@ -50255,6 +50261,7 @@ class Deck extends BaseItem {
50255
50261
  cachedCanvas = null;
50256
50262
  isCacheDirty = true;
50257
50263
  enableResize = false;
50264
+ path = new Path;
50258
50265
  constructor(board, id = "") {
50259
50266
  super(board, id, defaultDeckData, true);
50260
50267
  this.index.getUnderPoint = () => [];
@@ -50288,6 +50295,7 @@ class Deck extends BaseItem {
50288
50295
  }
50289
50296
  }
50290
50297
  });
50298
+ this.updateChildrenIds();
50291
50299
  this.updateMbr();
50292
50300
  this.subject.publish(this);
50293
50301
  }
@@ -50306,6 +50314,7 @@ class Deck extends BaseItem {
50306
50314
  }
50307
50315
  }
50308
50316
  });
50317
+ this.updateChildrenIds();
50309
50318
  this.updateMbr();
50310
50319
  this.subject.publish(this);
50311
50320
  }
@@ -50355,14 +50364,18 @@ class Deck extends BaseItem {
50355
50364
  updateMbr() {
50356
50365
  const { translateX, translateY } = this.transformation.matrix;
50357
50366
  const items = this.index.list();
50358
- const itemsMbr = items[0]?.getMbr().combine(items.slice(1).map((item) => item.getMbr()));
50367
+ const itemsMbr = items[0].getMbr().combine(items.slice(1).map((item) => item.getMbr()));
50359
50368
  this.left = translateX;
50360
50369
  this.top = translateY;
50361
- this.right = translateX + (itemsMbr?.getWidth() || 0);
50362
- this.bottom = translateY + (itemsMbr?.getHeight() || 0);
50370
+ this.right = translateX + (itemsMbr?.getWidth() || conf.CARD_DIMENSIONS.width + conf.DECK_HORIZONTAL_OFFSET * ((this.children.length || 1) - 1));
50371
+ this.bottom = translateY + (itemsMbr?.getHeight() || conf.CARD_DIMENSIONS.height - conf.DECK_VERTICAL_OFFSET * ((this.children.length || 1) - 1));
50372
+ this.path = new Path(this.getMbr().getLines(), true, "#FFFFFF");
50363
50373
  }
50364
50374
  deserialize(data) {
50365
50375
  super.deserialize(data);
50376
+ if (data.children) {
50377
+ this.children = data.children;
50378
+ }
50366
50379
  this.updateMbr();
50367
50380
  this.subject.publish(this);
50368
50381
  return this;
@@ -50374,6 +50387,7 @@ class Deck extends BaseItem {
50374
50387
  const ctx = context.ctx;
50375
50388
  if (this.isCacheDirty || !this.cachedCanvas) {
50376
50389
  this.updateCache(context);
50390
+ this.path.render(context);
50377
50391
  }
50378
50392
  if (this.cachedCanvas && this.cachedCanvas.width && this.cachedCanvas.height) {
50379
50393
  ctx.save();
@@ -39,7 +39,9 @@ export declare class BaseItem extends Mbr implements Geometry {
39
39
  shouldUseRelativeAlignment: boolean;
40
40
  enableResize: boolean;
41
41
  itemType: string;
42
+ children: string[];
42
43
  constructor(board: Board, id?: string, defaultItemData?: BaseItemData | undefined, isGroupItem?: boolean);
44
+ updateChildrenIds(): void;
43
45
  getId(): string;
44
46
  setId(id: string): this;
45
47
  getChildrenIds(): string[] | null;
@@ -6,10 +6,6 @@ import { Subject } from "Subject";
6
6
  import { Paths } from "Items/Path/Paths";
7
7
  import { CardOperation } from "Items/Examples/CardGame/Card/CardOperation";
8
8
  export declare const defaultCardData: BaseItemData;
9
- export declare const CARD_DIMENSIONS: {
10
- width: number;
11
- height: number;
12
- };
13
9
  export declare class Card extends BaseItem {
14
10
  readonly subject: Subject<Card>;
15
11
  private faceUrl;
@@ -4,6 +4,7 @@ import { Subject } from "Subject";
4
4
  import { Card } from "Items/Examples/CardGame/Card/Card";
5
5
  import { DrawingContext } from "Items/DrawingContext";
6
6
  import { DeckOperation } from "Items/Examples/CardGame/Deck/DeckOperation";
7
+ import { Path } from "../../../Path";
7
8
  export declare const defaultDeckData: BaseItemData;
8
9
  export declare class Deck extends BaseItem {
9
10
  readonly subject: Subject<Deck>;
@@ -11,6 +12,7 @@ export declare class Deck extends BaseItem {
11
12
  private cachedCanvas;
12
13
  private isCacheDirty;
13
14
  enableResize: boolean;
15
+ path: Path;
14
16
  constructor(board: Board, id?: string);
15
17
  applyAddChildren(childIds: string[]): void;
16
18
  applyRemoveChildren(childIds: string[]): void;
@@ -232,6 +232,10 @@ export declare const conf: {
232
232
  cursorsMap: Partial<Record<import("./Pointer/Cursor").CursorName, string>>;
233
233
  DECK_HORIZONTAL_OFFSET: number;
234
234
  DECK_VERTICAL_OFFSET: number;
235
+ CARD_DIMENSIONS: {
236
+ width: number;
237
+ height: number;
238
+ };
235
239
  };
236
240
  export type Settings = typeof conf;
237
241
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "microboard-temp",
3
- "version": "0.4.103",
3
+ "version": "0.4.104",
4
4
  "description": "A flexible interactive whiteboard library",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",